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 "txttypes.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 : MSHORT nChgCnt;
52 : SwRedlineItr *pRedln;
53 : sal_Int32 nStartIndex, nEndIndex, nPos;
54 : sal_uInt8 nPropFont;
55 : const void* aMagicNo[ SW_SCRIPTS ];
56 : MSHORT aFntIdx[ SW_SCRIPTS ];
57 : const SwTxtNode* m_pTxtNode;
58 :
59 : void SeekFwd( const sal_Int32 nPos );
60 0 : void SetFnt( SwFont* pNew ) { pFnt = pNew; }
61 :
62 : protected:
63 : void Chg( SwTxtAttr *pHt );
64 : void Rst( SwTxtAttr *pHt );
65 : void CtorInitAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf, SwTxtFrm* pFrm = 0 );
66 0 : SwAttrIter(SwTxtNode* pTxtNode)
67 : : pShell(0)
68 : , pFnt(0)
69 : , pHints(0)
70 : , pAttrSet(0)
71 : , pScriptInfo(0)
72 : , pLastOut(0)
73 : , nChgCnt(0)
74 : , pRedln(0)
75 : , nStartIndex(0)
76 : , nEndIndex(0)
77 : , nPos(0)
78 : , nPropFont(0)
79 0 : , m_pTxtNode(pTxtNode)
80 : {
81 0 : aMagicNo[SW_LATIN] = aMagicNo[SW_CJK] = aMagicNo[SW_CTL] = NULL;
82 0 : }
83 :
84 : public:
85 : // Constructor, destructor
86 0 : SwAttrIter( SwTxtNode& rTxtNode, SwScriptInfo& rScrInf )
87 0 : : pShell(0), pFnt(0), pHints(0), pScriptInfo(0), pLastOut(0), nChgCnt(0), pRedln(0),nPropFont(0), m_pTxtNode(&rTxtNode)
88 0 : { CtorInitAttrIter( rTxtNode, rScrInf ); }
89 :
90 : virtual ~SwAttrIter();
91 :
92 0 : SwRedlineItr *GetRedln() { return pRedln; }
93 : // The parameter returns the position of the next change before or at the
94 : // char position.
95 : sal_Int32 GetNextAttr( ) const;
96 : /// Enables the attributes used at char pos nPos in the logical font
97 : bool Seek( const sal_Int32 nPos );
98 : // Creates the font at the specified position via Seek() and checks
99 : // if it's a symbol font.
100 : bool IsSymbol( const sal_Int32 nPos );
101 :
102 : /** Executes ChgPhysFnt if Seek() returns true
103 : * and change font to merge character border with neighbours.
104 : **/
105 : bool SeekAndChgAttrIter( const sal_Int32 nPos, OutputDevice* pOut );
106 : bool SeekStartAndChgAttrIter( OutputDevice* pOut, const bool bParaFont = false );
107 :
108 : // Do we have an attribute change at all?
109 0 : bool HasHints() const { return 0 != pHints; }
110 :
111 : // Returns the attribute for a position
112 : SwTxtAttr *GetAttr( const sal_Int32 nPos ) const;
113 :
114 : const SwAttrSet* GetAttrSet() const { return pAttrSet; }
115 :
116 0 : const SwpHints *GetHints() const { return pHints; }
117 :
118 0 : SwFont *GetFnt() { return pFnt; }
119 0 : const SwFont *GetFnt() const { return pFnt; }
120 :
121 0 : sal_uInt8 GetPropFont() const { return nPropFont; }
122 0 : void SetPropFont( const sal_uInt8 nNew ) { nPropFont = nNew; }
123 :
124 0 : SwAttrHandler& GetAttrHandler() { return aAttrHandler; }
125 : };
126 :
127 : #endif
128 :
129 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|