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_SOURCE_CORE_TEXT_ITRATR_HXX
20 : #define INCLUDED_SW_SOURCE_CORE_TEXT_ITRATR_HXX
21 : #include <atrhndl.hxx>
22 :
23 : #include "swtypes.hxx"
24 : #include "swfont.hxx"
25 : #include "porlay.hxx"
26 :
27 : class OutputDevice;
28 : class SwFont;
29 : class SwpHints;
30 : class SwTextAttr;
31 : class SwAttrSet;
32 : class SwTextNode;
33 : class SwRedlineItr;
34 : class SwViewShell;
35 : class SwTextFrm;
36 :
37 : class SwAttrIter
38 : {
39 : friend class SwFontSave;
40 : protected:
41 :
42 : SwAttrHandler aAttrHandler;
43 : SwViewShell *pShell;
44 : SwFont *pFnt;
45 : SwpHints *pHints;
46 : const SwAttrSet* pAttrSet; // The char attribute set
47 : SwScriptInfo* pScriptInfo;
48 :
49 : private:
50 : VclPtr<OutputDevice> pLastOut;
51 : short nChgCnt;
52 : SwRedlineItr *pRedln;
53 : size_t nStartIndex;
54 : size_t nEndIndex;
55 : sal_Int32 nPos;
56 : sal_uInt8 nPropFont;
57 : const void* aMagicNo[ SW_SCRIPTS ];
58 : sal_uInt16 aFntIdx[ SW_SCRIPTS ];
59 : const SwTextNode* m_pTextNode;
60 :
61 : void SeekFwd( const sal_Int32 nPos );
62 20 : void SetFnt( SwFont* pNew ) { pFnt = pNew; }
63 :
64 : protected:
65 : void Chg( SwTextAttr *pHt );
66 : void Rst( SwTextAttr *pHt );
67 : void CtorInitAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf, SwTextFrm* pFrm = 0 );
68 184833 : explicit SwAttrIter(SwTextNode* pTextNode)
69 : : pShell(0)
70 : , pFnt(0)
71 : , pHints(0)
72 : , pAttrSet(0)
73 : , pScriptInfo(0)
74 : , pLastOut(0)
75 : , nChgCnt(0)
76 : , pRedln(0)
77 : , nStartIndex(0)
78 : , nEndIndex(0)
79 : , nPos(0)
80 : , nPropFont(0)
81 184833 : , m_pTextNode(pTextNode)
82 : {
83 184833 : aMagicNo[SW_LATIN] = aMagicNo[SW_CJK] = aMagicNo[SW_CTL] = NULL;
84 184833 : }
85 :
86 : public:
87 : // Constructor, destructor
88 437 : SwAttrIter( SwTextNode& rTextNode, SwScriptInfo& rScrInf )
89 437 : : pShell(0), pFnt(0), pHints(0), pScriptInfo(0), pLastOut(0), nChgCnt(0), pRedln(0),nPropFont(0), m_pTextNode(&rTextNode)
90 437 : { CtorInitAttrIter( rTextNode, rScrInf ); }
91 :
92 : virtual ~SwAttrIter();
93 :
94 210129 : SwRedlineItr *GetRedln() { return pRedln; }
95 : // The parameter returns the position of the next change before or at the
96 : // char position.
97 : sal_Int32 GetNextAttr( ) const;
98 : /// Enables the attributes used at char pos nPos in the logical font
99 : bool Seek( const sal_Int32 nPos );
100 : // Creates the font at the specified position via Seek() and checks
101 : // if it's a symbol font.
102 : bool IsSymbol( const sal_Int32 nPos );
103 :
104 : /** Executes ChgPhysFnt if Seek() returns true
105 : * and change font to merge character border with neighbours.
106 : **/
107 : bool SeekAndChgAttrIter( const sal_Int32 nPos, OutputDevice* pOut );
108 : bool SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont = false );
109 :
110 : // Do we have an attribute change at all?
111 623 : bool HasHints() const { return 0 != pHints; }
112 :
113 : // Returns the attribute for a position
114 : SwTextAttr *GetAttr( const sal_Int32 nPos ) const;
115 :
116 : const SwAttrSet* GetAttrSet() const { return pAttrSet; }
117 :
118 52969 : const SwpHints *GetHints() const { return pHints; }
119 :
120 291030 : SwFont *GetFnt() { return pFnt; }
121 443884 : const SwFont *GetFnt() const { return pFnt; }
122 :
123 69424 : sal_uInt8 GetPropFont() const { return nPropFont; }
124 459 : void SetPropFont( const sal_uInt8 nNew ) { nPropFont = nNew; }
125 :
126 10898 : SwAttrHandler& GetAttrHandler() { return aAttrHandler; }
127 : };
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|