1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _TXATRITR_HXX 24 #define _TXATRITR_HXX 25 26 #include <tools/solar.h> 27 #include <sal/types.h> 28 #include <svl/svarray.hxx> 29 #include <editeng/langitem.hxx> 30 #include <hintids.hxx> 31 32 class String; 33 class SwTxtNode; 34 class SwTxtAttr; 35 class SfxPoolItem; 36 37 38 class SwScriptIterator 39 { 40 const String& rText; 41 xub_StrLen nChgPos; 42 sal_uInt16 nCurScript; 43 sal_Bool bForward; 44 45 public: 46 SwScriptIterator( const String& rStr, xub_StrLen nStart = 0, 47 sal_Bool bFrwrd = sal_True ); 48 49 sal_Bool Next(); 50 GetCurrScript() const51 sal_uInt16 GetCurrScript() const { return nCurScript; } GetScriptChgPos() const52 xub_StrLen GetScriptChgPos() const { return nChgPos; } GetText() const53 const String& GetText() const { return rText; } 54 }; 55 56 57 class SwTxtAttrIterator 58 { 59 SwScriptIterator aSIter; 60 SvPtrarr aStack; 61 const SwTxtNode& rTxtNd; 62 const SfxPoolItem *pParaItem, *pCurItem; 63 xub_StrLen nChgPos; 64 sal_uInt16 nAttrPos, nWhichId; 65 sal_Bool bIsUseGetWhichOfScript; 66 67 void AddToStack( const SwTxtAttr& rAttr ); 68 void SearchNextChg(); 69 70 public: 71 SwTxtAttrIterator( const SwTxtNode& rTxtNd, sal_uInt16 nWhichId, 72 xub_StrLen nStart = 0, sal_Bool bUseGetWhichOfScript = sal_True ); 73 74 sal_Bool Next(); 75 GetAttr() const76 const SfxPoolItem& GetAttr() const { return *pCurItem; } GetChgPos() const77 xub_StrLen GetChgPos() const { return nChgPos; } 78 }; 79 80 81 class SwLanguageIterator : public SwTxtAttrIterator 82 { 83 public: SwLanguageIterator(const SwTxtNode & rTxtNode,xub_StrLen nStart=0,sal_uInt16 nWhich=RES_CHRATR_LANGUAGE,sal_Bool bUseGetWhichOfScript=sal_True)84 SwLanguageIterator( const SwTxtNode& rTxtNode, xub_StrLen nStart = 0, 85 sal_uInt16 nWhich = RES_CHRATR_LANGUAGE, 86 sal_Bool bUseGetWhichOfScript = sal_True ) 87 : SwTxtAttrIterator( rTxtNode, nWhich, nStart, bUseGetWhichOfScript ) 88 {} 89 GetLanguage() const90 sal_uInt16 GetLanguage() const 91 { return ((SvxLanguageItem&)GetAttr()).GetValue(); } 92 }; 93 94 95 #endif 96