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 INCLUDED_SW_INC_TXATRITR_HXX
20 : #define INCLUDED_SW_INC_TXATRITR_HXX
21 :
22 : #include <tools/solar.h>
23 : #include <sal/types.h>
24 : #include <editeng/langitem.hxx>
25 : #include <hintids.hxx>
26 : #include <swtypes.hxx>
27 : #include <deque>
28 :
29 : class SwTxtNode;
30 : class SwTxtAttr;
31 : class SfxPoolItem;
32 :
33 : class SwScriptIterator
34 : {
35 : const OUString& m_rText;
36 : sal_Int32 m_nChgPos;
37 : sal_uInt16 nCurScript;
38 : bool bForward;
39 :
40 : public:
41 : SwScriptIterator( const OUString& rStr, sal_Int32 nStart = 0,
42 : bool bFrwrd = true );
43 :
44 : bool Next();
45 :
46 0 : sal_uInt16 GetCurrScript() const { return nCurScript; }
47 0 : sal_Int32 GetScriptChgPos() const { return (m_nChgPos == -1) ? COMPLETE_STRING : m_nChgPos; }
48 0 : const OUString& GetText() const { return m_rText; }
49 : };
50 :
51 0 : class SwTxtAttrIterator
52 : {
53 : SwScriptIterator aSIter;
54 : std::deque<const SwTxtAttr*> aStack;
55 : const SwTxtNode& rTxtNd;
56 : const SfxPoolItem *pParaItem, *pCurItem;
57 : sal_Int32 nChgPos;
58 : sal_uInt16 nAttrPos, nWhichId;
59 : bool bIsUseGetWhichOfScript;
60 :
61 : void AddToStack( const SwTxtAttr& rAttr );
62 : void SearchNextChg();
63 :
64 : public:
65 : SwTxtAttrIterator( const SwTxtNode& rTxtNd, sal_uInt16 nWhichId,
66 : sal_Int32 nStart = 0, bool bUseGetWhichOfScript = true );
67 :
68 : bool Next();
69 :
70 0 : const SfxPoolItem& GetAttr() const { return *pCurItem; }
71 0 : sal_Int32 GetChgPos() const { return nChgPos; }
72 : };
73 :
74 0 : class SwLanguageIterator : public SwTxtAttrIterator
75 : {
76 : public:
77 0 : SwLanguageIterator( const SwTxtNode& rTxtNode, sal_Int32 nStart = 0,
78 : sal_uInt16 nWhich = RES_CHRATR_LANGUAGE,
79 : bool bUseGetWhichOfScript = true )
80 0 : : SwTxtAttrIterator( rTxtNode, nWhich, nStart, bUseGetWhichOfScript )
81 0 : {}
82 :
83 0 : sal_uInt16 GetLanguage() const
84 0 : { return ((SvxLanguageItem&)GetAttr()).GetValue(); }
85 : };
86 :
87 : #endif
88 :
89 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|