Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 : #ifndef _TXATRITR_HXX
20 : #define _TXATRITR_HXX
21 :
22 : #include <tools/solar.h>
23 : #include <sal/types.h>
24 : #include <editeng/langitem.hxx>
25 : #include <hintids.hxx>
26 : #include <deque>
27 :
28 : class String;
29 : class SwTxtNode;
30 : class SwTxtAttr;
31 : class SfxPoolItem;
32 :
33 :
34 : class SwScriptIterator
35 : {
36 : const String& rText;
37 : xub_StrLen nChgPos;
38 : sal_uInt16 nCurScript;
39 : bool bForward;
40 :
41 : public:
42 : SwScriptIterator( const String& rStr, xub_StrLen nStart = 0,
43 : bool bFrwrd = true );
44 :
45 : bool Next();
46 :
47 0 : sal_uInt16 GetCurrScript() const { return nCurScript; }
48 0 : xub_StrLen GetScriptChgPos() const { return nChgPos; }
49 0 : const String& GetText() const { return rText; }
50 : };
51 :
52 :
53 0 : class SwTxtAttrIterator
54 : {
55 : SwScriptIterator aSIter;
56 : std::deque<const SwTxtAttr*> aStack;
57 : const SwTxtNode& rTxtNd;
58 : const SfxPoolItem *pParaItem, *pCurItem;
59 : xub_StrLen nChgPos;
60 : sal_uInt16 nAttrPos, nWhichId;
61 : bool bIsUseGetWhichOfScript;
62 :
63 : void AddToStack( const SwTxtAttr& rAttr );
64 : void SearchNextChg();
65 :
66 : public:
67 : SwTxtAttrIterator( const SwTxtNode& rTxtNd, sal_uInt16 nWhichId,
68 : xub_StrLen nStart = 0, bool bUseGetWhichOfScript = true );
69 :
70 : bool Next();
71 :
72 0 : const SfxPoolItem& GetAttr() const { return *pCurItem; }
73 0 : xub_StrLen GetChgPos() const { return nChgPos; }
74 : };
75 :
76 :
77 0 : class SwLanguageIterator : public SwTxtAttrIterator
78 : {
79 : public:
80 0 : SwLanguageIterator( const SwTxtNode& rTxtNode, xub_StrLen nStart = 0,
81 : sal_uInt16 nWhich = RES_CHRATR_LANGUAGE,
82 : bool bUseGetWhichOfScript = true )
83 0 : : SwTxtAttrIterator( rTxtNode, nWhich, nStart, bUseGetWhichOfScript )
84 0 : {}
85 :
86 0 : sal_uInt16 GetLanguage() const
87 0 : { return ((SvxLanguageItem&)GetAttr()).GetValue(); }
88 : };
89 :
90 :
91 : #endif
92 :
93 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|