1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _TXATRITR_HXX 28 #define _TXATRITR_HXX 29 30 #include <tools/solar.h> 31 #include <sal/types.h> 32 #include <svl/svarray.hxx> 33 #include <editeng/langitem.hxx> 34 #include <hintids.hxx> 35 36 class String; 37 class SwTxtNode; 38 class SwTxtAttr; 39 class SfxPoolItem; 40 41 42 class SwScriptIterator 43 { 44 const String& rText; 45 xub_StrLen nChgPos; 46 sal_uInt16 nCurScript; 47 sal_Bool bForward; 48 49 public: 50 SwScriptIterator( const String& rStr, xub_StrLen nStart = 0, 51 sal_Bool bFrwrd = sal_True ); 52 53 sal_Bool Next(); 54 55 sal_uInt16 GetCurrScript() const { return nCurScript; } 56 xub_StrLen GetScriptChgPos() const { return nChgPos; } 57 const String& GetText() const { return rText; } 58 }; 59 60 61 class SwTxtAttrIterator 62 { 63 SwScriptIterator aSIter; 64 SvPtrarr aStack; 65 const SwTxtNode& rTxtNd; 66 const SfxPoolItem *pParaItem, *pCurItem; 67 xub_StrLen nChgPos; 68 sal_uInt16 nAttrPos, nWhichId; 69 sal_Bool bIsUseGetWhichOfScript; 70 71 void AddToStack( const SwTxtAttr& rAttr ); 72 void SearchNextChg(); 73 74 public: 75 SwTxtAttrIterator( const SwTxtNode& rTxtNd, sal_uInt16 nWhichId, 76 xub_StrLen nStart = 0, sal_Bool bUseGetWhichOfScript = sal_True ); 77 78 sal_Bool Next(); 79 80 const SfxPoolItem& GetAttr() const { return *pCurItem; } 81 xub_StrLen GetChgPos() const { return nChgPos; } 82 }; 83 84 85 class SwLanguageIterator : public SwTxtAttrIterator 86 { 87 public: 88 SwLanguageIterator( const SwTxtNode& rTxtNode, xub_StrLen nStart = 0, 89 sal_uInt16 nWhich = RES_CHRATR_LANGUAGE, 90 sal_Bool bUseGetWhichOfScript = sal_True ) 91 : SwTxtAttrIterator( rTxtNode, nWhich, nStart, bUseGetWhichOfScript ) 92 {} 93 94 sal_uInt16 GetLanguage() const 95 { return ((SvxLanguageItem&)GetAttr()).GetValue(); } 96 }; 97 98 99 #endif 100