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 _ITRATR_HXX
20 : #define _ITRATR_HXX
21 : #include <atrhndl.hxx>
22 :
23 : #include "txttypes.hxx"
24 : #include "swfont.hxx"
25 : #include "porlay.hxx"
26 :
27 :
28 : class OutputDevice;
29 : class SwFont;
30 : class SwpHints;
31 : class SwTxtAttr;
32 : class SwAttrSet;
33 : class SwTxtNode;
34 : class SwRedlineItr;
35 : class ViewShell;
36 : class SwTxtFrm;
37 :
38 : /*************************************************************************
39 : * class SwAttrIter
40 : *************************************************************************/
41 :
42 : class SwAttrIter
43 : {
44 : friend class SwFontSave;
45 : protected:
46 :
47 : SwAttrHandler aAttrHandler;
48 : ViewShell *pShell;
49 : SwFont *pFnt;
50 : SwpHints *pHints;
51 : const SwAttrSet* pAttrSet; // The char attribute set
52 : SwScriptInfo* pScriptInfo;
53 :
54 : private:
55 : OutputDevice *pLastOut;
56 : MSHORT nChgCnt;
57 : SwRedlineItr *pRedln;
58 : xub_StrLen nStartIndex, nEndIndex, nPos;
59 : sal_uInt8 nPropFont;
60 : void SeekFwd( const xub_StrLen nPos );
61 0 : inline void SetFnt( SwFont* pNew ) { pFnt = pNew; }
62 : const void* aMagicNo[ SW_SCRIPTS ];
63 : MSHORT aFntIdx[ SW_SCRIPTS ];
64 : const SwTxtNode* m_pTxtNode;
65 :
66 : protected:
67 : void Chg( SwTxtAttr *pHt );
68 : void Rst( SwTxtAttr *pHt );
69 : void CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, SwTxtFrm* pFrm = 0 );
70 4152 : inline SwAttrIter(SwTxtNode* pTxtNode)
71 4152 : : pShell(0), pFnt(0), pHints(0), pAttrSet(0), pScriptInfo(0), pLastOut(0), nChgCnt(0), pRedln(0), nPropFont(0), m_pTxtNode(pTxtNode) {
72 4152 : aMagicNo[SW_LATIN] = aMagicNo[SW_CJK] = aMagicNo[SW_CTL] = NULL;
73 4152 : }
74 :
75 : public:
76 : // Constructor, destructor
77 7 : inline SwAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf )
78 7 : : pShell(0), pFnt(0), pHints(0), pScriptInfo(0), pLastOut(0), nChgCnt(0), pRedln(0),nPropFont(0), m_pTxtNode(&rTxtNode)
79 7 : { CtorInitAttrIter( rTxtNode, rScrInf ); }
80 :
81 : virtual ~SwAttrIter();
82 :
83 2430 : inline SwRedlineItr *GetRedln() { return pRedln; }
84 : // The parameter returns the position of the next change before or at the
85 : // char position.
86 : // Returns sal_False, if there's no change before or at the positon,
87 : // else sal_True.
88 : xub_StrLen GetNextAttr( ) const;
89 : // Enables the attributes used at char pos nPos in the logical font
90 : sal_Bool Seek( const xub_StrLen nPos );
91 : // Creates the font at the specified position via Seek() and checks
92 : // if it's a symbol font.
93 : sal_Bool IsSymbol( const xub_StrLen nPos );
94 :
95 : // Executes ChgPhysFnt if Seek() returns sal_True
96 : sal_Bool SeekAndChgAttrIter( const xub_StrLen nPos, OutputDevice* pOut );
97 : sal_Bool SeekStartAndChgAttrIter( OutputDevice* pOut, const sal_Bool bParaFont = sal_False );
98 :
99 : // Do we have an attribute change at all?
100 9 : inline sal_Bool HasHints() const { return 0 != pHints; }
101 :
102 : // Returns the attribute for a position
103 : SwTxtAttr *GetAttr( const xub_StrLen nPos ) const;
104 :
105 : inline const SwAttrSet* GetAttrSet() const { return pAttrSet; }
106 :
107 662 : inline const SwpHints *GetHints() const { return pHints; }
108 :
109 6123 : inline SwFont *GetFnt() { return pFnt; }
110 2457 : inline const SwFont *GetFnt() const { return pFnt; }
111 :
112 2264 : inline sal_uInt8 GetPropFont() const { return nPropFont; }
113 3 : inline void SetPropFont( const sal_uInt8 nNew ) { nPropFont = nNew; }
114 :
115 34 : inline SwAttrHandler& GetAttrHandler() { return aAttrHandler; }
116 : };
117 :
118 : #endif
119 :
120 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|