update dev300-m58
[ooovba.git] / sw / inc / ndhints.hxx
blob851cff58c5d7aecc31c7dafa0b5280728c3f1492
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 "numrule.hxx"
39 class SwTxtNode;
40 class SwRegHistory; // steht im RolBck.hxx
41 class SwTxtAttr;
44 * Ableitung der Klasse SwpHints ueber den Umweg ueber SwpHts, da
45 * lediglich die Klasse SwTxtNode Attribute einfuegen und
46 * loeschen koennen soll. Anderen Klassen wie den Frames steht
47 * lediglich ein lesender Zugriff ueber den Index-Operator zur
48 * Verfuegung.
49 * Groesse beim Anlegen gleich 1, weil nur dann ein Array erzeug wird, wenn
50 * auch ein Hint eingefuegt wird.
53 /*************************************************************************
54 * class SwpHtStart/End
55 *************************************************************************/
57 SV_DECL_PTRARR_SORT(SwpHtStart,SwTxtAttr*,1,1)
58 SV_DECL_PTRARR_SORT(SwpHtEnd,SwTxtAttr*,1,1)
60 /*************************************************************************
61 * class SwpHintsArr
62 *************************************************************************/
64 /// the Hints array
65 class SwpHintsArray
68 protected:
69 SwpHtStart m_HintStarts;
70 SwpHtEnd m_HintEnds;
72 //FIXME: why are the non-const methods public?
73 public:
74 void Insert( const SwTxtAttr *pHt );
75 void DeleteAtPos( const USHORT nPosInStart );
76 bool Resort();
77 SwTxtAttr * Cut( const USHORT nPosInStart );
79 inline const SwTxtAttr * GetStart( const USHORT nPos ) const
80 { return m_HintStarts[nPos]; }
81 inline const SwTxtAttr * GetEnd ( const USHORT nPos ) const
82 { return m_HintEnds [nPos]; }
83 inline SwTxtAttr * GetStart( const USHORT nPos )
84 { return m_HintStarts[nPos]; }
85 inline SwTxtAttr * GetEnd ( const USHORT nPos )
86 { return m_HintEnds [nPos]; }
88 inline USHORT GetEndCount() const { return m_HintEnds .Count(); }
89 inline USHORT GetStartCount() const { return m_HintStarts.Count(); }
91 inline USHORT GetStartOf( const SwTxtAttr *pHt ) const;
92 inline USHORT GetPos( const SwTxtAttr *pHt ) const
93 { return m_HintStarts.GetPos( pHt ); }
95 inline SwTxtAttr * GetTextHint( const USHORT nIdx )
96 { return GetStart(nIdx); }
97 inline const SwTxtAttr * operator[]( const USHORT nIdx ) const
98 { return m_HintStarts[nIdx]; }
99 inline USHORT Count() const { return m_HintStarts.Count(); }
101 #ifndef PRODUCT
102 bool Check() const;
103 #endif
106 /*************************************************************************
107 * class SwpHints
108 *************************************************************************/
110 // public interface
111 class SwpHints : public SwpHintsArray
113 private:
114 SwRegHistory* m_pHistory; // for Undo
116 bool m_bFontChange : 1; // font change
117 // true: the Node is in Split and Frames are moved
118 bool m_bInSplitNode : 1;
119 // m_bHasHiddenParaField is invalid, call CalcHiddenParaField()
120 bool m_bCalcHiddenParaField : 1;
121 bool m_bHasHiddenParaField : 1; // HiddenParaFld
122 bool m_bFootnote : 1; // footnotes
123 bool m_bDDEFields : 1; // the TextNode has DDE fields
125 // records a new attibute in m_pHistory.
126 void NoteInHistory( SwTxtAttr *pAttr, const bool bNew = false );
128 void CalcFlags( );
130 // Delete methods may only be called by the TextNode!
131 // Because the TextNode also guarantees removal of the Character for
132 // attributes without an end.
133 friend class SwTxtNode;
134 void DeleteAtPos( const USHORT nPos );
135 // Delete the given Hint. The Hint must actually be in the array!
136 void Delete( SwTxtAttr* pTxtHt );
138 inline void SetInSplitNode(bool bInSplit) { m_bInSplitNode = bInSplit; }
139 inline void SetCalcHiddenParaField() { m_bCalcHiddenParaField = true; }
140 inline void SetHiddenParaField( const bool bNew )
141 { m_bHasHiddenParaField = bNew; }
142 inline bool HasHiddenParaField() const
144 if ( m_bCalcHiddenParaField )
146 (const_cast<SwpHints*>(this))->CalcHiddenParaField();
148 return m_bHasHiddenParaField;
151 void BuildPortions( SwTxtNode& rNode, SwTxtAttr& rNewHint, USHORT nMode );
152 bool MergePortions( SwTxtNode& rNode );
154 public:
155 SwpHints();
157 inline bool CanBeDeleted() const { return !Count(); }
159 // register a History, which receives all attribute changes (for Undo)
160 void Register( SwRegHistory* pHist ) { m_pHistory = pHist; }
161 // deregister the currently registered History
162 void DeRegister() { Register(0); }
163 SwRegHistory* GetHistory() const { return m_pHistory; }
165 void Insert( SwTxtAttr* pHt, SwTxtNode &rNode, USHORT nMode = 0 );
167 inline bool HasFtn() const { return m_bFootnote; }
168 inline bool IsInSplitNode() const { return m_bInSplitNode; }
170 // calc current value of m_bHasHiddenParaField, returns true iff changed
171 bool CalcHiddenParaField();
173 DECL_FIXEDMEMPOOL_NEWDEL(SwpHints)
176 // Ausgabeoperator fuer die Texthints
177 SvStream &operator<<(SvStream &aS, const SwpHints &rHints); //$ ostream
179 /*************************************************************************
180 * Inline Implementations
181 *************************************************************************/
183 inline USHORT SwpHintsArray::GetStartOf( const SwTxtAttr *pHt ) const
185 USHORT nPos;
186 if ( !m_HintStarts.Seek_Entry( pHt, &nPos ) )
188 nPos = USHRT_MAX;
190 return nPos;
193 inline SwTxtAttr *SwpHintsArray::Cut( const USHORT nPosInStart )
195 SwTxtAttr *pHt = GetTextHint(nPosInStart);
196 DeleteAtPos( nPosInStart );
197 return pHt;
201 #endif