Update ooo320-m1
[ooovba.git] / sw / inc / ndhints.hxx
blob620d8a0c2f998d5ae197fd6dc55f01daf7526130
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ndhints.hxx,v $
10 * $Revision: 1.13 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _NDHINTS_HXX
31 #define _NDHINTS_HXX
34 #include <svtools/svarray.hxx>
35 #include <tools/mempool.hxx>
37 #include "swtypes.hxx"
39 //#include "numrule.hxx"
41 class SwTxtNode;
42 class SwRegHistory; // steht im RolBck.hxx
43 class SwTxtAttr;
44 class SwTxtAttrNesting;
46 class SfxPoolItem;
47 class SfxItemSet;
48 class SwDoc;
50 SW_DLLPRIVATE SwTxtAttr *
51 MakeTxtAttr( SwDoc & rDoc, SfxPoolItem & rNew,
52 xub_StrLen nStt, xub_StrLen nEnd );
53 SW_DLLPRIVATE SwTxtAttr *
54 MakeTxtAttr( SwDoc & rDoc, const SfxItemSet & rSet,
55 xub_StrLen nStt, xub_StrLen nEnd );
57 // create redline dummy text hint that must not be inserted into hints array
58 SW_DLLPRIVATE SwTxtAttr*
59 MakeRedlineTxtAttr( SwDoc & rDoc, SfxPoolItem& rAttr );
63 * Ableitung der Klasse SwpHints ueber den Umweg ueber SwpHts, da
64 * lediglich die Klasse SwTxtNode Attribute einfuegen und
65 * loeschen koennen soll. Anderen Klassen wie den Frames steht
66 * lediglich ein lesender Zugriff ueber den Index-Operator zur
67 * Verfuegung.
68 * Groesse beim Anlegen gleich 1, weil nur dann ein Array erzeug wird, wenn
69 * auch ein Hint eingefuegt wird.
72 /*************************************************************************
73 * class SwpHtStart/End
74 *************************************************************************/
76 SV_DECL_PTRARR_SORT(SwpHtStart,SwTxtAttr*,1,1)
77 SV_DECL_PTRARR_SORT(SwpHtEnd,SwTxtAttr*,1,1)
79 /*************************************************************************
80 * class SwpHintsArr
81 *************************************************************************/
83 /// the Hints array
84 class SwpHintsArray
87 protected:
88 SwpHtStart m_HintStarts;
89 SwpHtEnd m_HintEnds;
91 //FIXME: why are the non-const methods public?
92 public:
93 void Insert( const SwTxtAttr *pHt );
94 void DeleteAtPos( const USHORT nPosInStart );
95 bool Resort();
96 SwTxtAttr * Cut( const USHORT nPosInStart );
98 inline const SwTxtAttr * GetStart( const USHORT nPos ) const
99 { return m_HintStarts[nPos]; }
100 inline const SwTxtAttr * GetEnd ( const USHORT nPos ) const
101 { return m_HintEnds [nPos]; }
102 inline SwTxtAttr * GetStart( const USHORT nPos )
103 { return m_HintStarts[nPos]; }
104 inline SwTxtAttr * GetEnd ( const USHORT nPos )
105 { return m_HintEnds [nPos]; }
107 inline USHORT GetEndCount() const { return m_HintEnds .Count(); }
108 inline USHORT GetStartCount() const { return m_HintStarts.Count(); }
110 inline USHORT GetStartOf( const SwTxtAttr *pHt ) const;
111 inline USHORT GetPos( const SwTxtAttr *pHt ) const
112 { return m_HintStarts.GetPos( pHt ); }
114 inline SwTxtAttr * GetTextHint( const USHORT nIdx )
115 { return GetStart(nIdx); }
116 inline const SwTxtAttr * operator[]( const USHORT nIdx ) const
117 { return m_HintStarts[nIdx]; }
118 inline USHORT Count() const { return m_HintStarts.Count(); }
120 #ifndef PRODUCT
121 bool Check() const;
122 #endif
125 /*************************************************************************
126 * class SwpHints
127 *************************************************************************/
129 // public interface
130 class SwpHints : public SwpHintsArray
132 private:
133 SwRegHistory* m_pHistory; // for Undo
135 bool m_bFontChange : 1; // font change
136 // true: the Node is in Split and Frames are moved
137 bool m_bInSplitNode : 1;
138 // m_bHasHiddenParaField is invalid, call CalcHiddenParaField()
139 bool m_bCalcHiddenParaField : 1;
140 bool m_bHasHiddenParaField : 1; // HiddenParaFld
141 bool m_bFootnote : 1; // footnotes
142 bool m_bDDEFields : 1; // the TextNode has DDE fields
144 // records a new attibute in m_pHistory.
145 void NoteInHistory( SwTxtAttr *pAttr, const bool bNew = false );
147 void CalcFlags( );
149 // Delete methods may only be called by the TextNode!
150 // Because the TextNode also guarantees removal of the Character for
151 // attributes without an end.
152 friend class SwTxtNode;
153 void DeleteAtPos( const USHORT nPos );
154 // Delete the given Hint. The Hint must actually be in the array!
155 void Delete( SwTxtAttr* pTxtHt );
157 inline void SetInSplitNode(bool bInSplit) { m_bInSplitNode = bInSplit; }
158 inline void SetCalcHiddenParaField() { m_bCalcHiddenParaField = true; }
159 inline void SetHiddenParaField( const bool bNew )
160 { m_bHasHiddenParaField = bNew; }
161 inline bool HasHiddenParaField() const
163 if ( m_bCalcHiddenParaField )
165 (const_cast<SwpHints*>(this))->CalcHiddenParaField();
167 return m_bHasHiddenParaField;
170 void InsertNesting(SwTxtAttrNesting & rNewHint);
171 bool TryInsertNesting(SwTxtNode & rNode, SwTxtAttrNesting & rNewHint);
172 void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint,
173 const SetAttrMode nMode );
174 bool MergePortions( SwTxtNode& rNode );
176 public:
177 SwpHints();
179 inline bool CanBeDeleted() const { return !Count(); }
181 // register a History, which receives all attribute changes (for Undo)
182 void Register( SwRegHistory* pHist ) { m_pHistory = pHist; }
183 // deregister the currently registered History
184 void DeRegister() { Register(0); }
185 SwRegHistory* GetHistory() const { return m_pHistory; }
187 /// try to insert the hint
188 /// @return true iff hint successfully inserted
189 bool TryInsertHint( SwTxtAttr * const pHint, SwTxtNode & rNode,
190 const SetAttrMode nMode = nsSetAttrMode::SETATTR_DEFAULT );
192 inline bool HasFtn() const { return m_bFootnote; }
193 inline bool IsInSplitNode() const { return m_bInSplitNode; }
195 // calc current value of m_bHasHiddenParaField, returns true iff changed
196 bool CalcHiddenParaField();
198 DECL_FIXEDMEMPOOL_NEWDEL(SwpHints)
201 // Ausgabeoperator fuer die Texthints
202 SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream
204 /*************************************************************************
205 * Inline Implementations
206 *************************************************************************/
208 inline USHORT SwpHintsArray::GetStartOf( const SwTxtAttr *pHt ) const
210 USHORT nPos;
211 if ( !m_HintStarts.Seek_Entry( pHt, &nPos ) )
213 nPos = USHRT_MAX;
215 return nPos;
218 inline SwTxtAttr *SwpHintsArray::Cut( const USHORT nPosInStart )
220 SwTxtAttr *pHt = GetTextHint(nPosInStart);
221 DeleteAtPos( nPosInStart );
222 return pHt;
226 #endif