Branch libreoffice-5-0-4
[LibreOffice.git] / sw / inc / txatritr.hxx
blob6ab4f0c1a06dbdfda3356d0fb18aa7d9f5750f85
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_SW_INC_TXATRITR_HXX
20 #define INCLUDED_SW_INC_TXATRITR_HXX
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>
29 class SwTextNode;
30 class SwTextAttr;
31 class SfxPoolItem;
33 class SwScriptIterator
35 const OUString& m_rText;
36 sal_Int32 m_nChgPos;
37 sal_uInt16 nCurScript;
38 bool bForward;
40 public:
41 SwScriptIterator( const OUString& rStr, sal_Int32 nStart = 0,
42 bool bFrwrd = true );
44 bool Next();
46 sal_uInt16 GetCurrScript() const { return nCurScript; }
47 sal_Int32 GetScriptChgPos() const { return (m_nChgPos == -1) ? COMPLETE_STRING : m_nChgPos; }
48 const OUString& GetText() const { return m_rText; }
51 class SwTextAttrIterator
53 SwScriptIterator aSIter;
54 std::deque<const SwTextAttr*> aStack;
55 const SwTextNode& rTextNd;
56 const SfxPoolItem *pParaItem, *pCurItem;
57 size_t nAttrPos;
58 sal_Int32 nChgPos;
59 sal_uInt16 nWhichId;
60 bool bIsUseGetWhichOfScript;
62 void AddToStack( const SwTextAttr& rAttr );
63 void SearchNextChg();
65 public:
66 SwTextAttrIterator( const SwTextNode& rTextNd, sal_uInt16 nWhichId,
67 sal_Int32 nStart = 0, bool bUseGetWhichOfScript = true );
69 bool Next();
71 const SfxPoolItem& GetAttr() const { return *pCurItem; }
72 sal_Int32 GetChgPos() const { return nChgPos; }
75 class SwLanguageIterator : public SwTextAttrIterator
77 public:
78 SwLanguageIterator( const SwTextNode& rTextNode, sal_Int32 nStart = 0,
79 sal_uInt16 nWhich = RES_CHRATR_LANGUAGE,
80 bool bUseGetWhichOfScript = true )
81 : SwTextAttrIterator( rTextNode, nWhich, nStart, bUseGetWhichOfScript )
84 sal_uInt16 GetLanguage() const
85 { return static_cast<const SvxLanguageItem&>(GetAttr()).GetValue(); }
88 #endif
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */