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 SwTxtAttr;
31 : class SwAttrSet;
32 : class SwTxtNode;
33 : class SwRedlineItr;
34 : class SwViewShell;
35 : class SwTxtFrm;
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 : 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 SwTxtNode* m_pTxtNode;
60 :
61 : void SeekFwd( const sal_Int32 nPos );
62 80 : void SetFnt( SwFont* pNew ) { pFnt = pNew; }
63 :
64 : protected:
65 : void Chg( SwTxtAttr *pHt );
66 : void Rst( SwTxtAttr *pHt );
67 : void CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, SwTxtFrm* pFrm = 0 );
68 318182 : SwAttrIter(SwTxtNode* pTxtNode)
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 318182 : , m_pTxtNode(pTxtNode)
82 : {
83 318182 : aMagicNo[SW_LATIN] = aMagicNo[SW_CJK] = aMagicNo[SW_CTL] = NULL;
84 318182 : }
85 :
86 : public:
87 : // Constructor, destructor
88 798 : SwAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf )
89 798 : : pShell(0), pFnt(0), pHints(0), pScriptInfo(0), pLastOut(0), nChgCnt(0), pRedln(0),nPropFont(0), m_pTxtNode(&rTxtNode)
90 798 : { CtorInitAttrIter( rTxtNode, rScrInf ); }
91 :
92 : virtual ~SwAttrIter();
93 :
94 356748 : 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 1132 : bool HasHints() const { return 0 != pHints; }
112 :
113 : // Returns the attribute for a position
114 : SwTxtAttr *GetAttr( const sal_Int32 nPos ) const;
115 :
116 : const SwAttrSet* GetAttrSet() const { return pAttrSet; }
117 :
118 94178 : const SwpHints *GetHints() const { return pHints; }
119 :
120 501469 : SwFont *GetFnt() { return pFnt; }
121 736661 : const SwFont *GetFnt() const { return pFnt; }
122 :
123 119521 : sal_uInt8 GetPropFont() const { return nPropFont; }
124 1020 : void SetPropFont( const sal_uInt8 nNew ) { nPropFont = nNew; }
125 :
126 20600 : SwAttrHandler& GetAttrHandler() { return aAttrHandler; }
127 : };
128 :
129 : #endif
130 :
131 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|