xref: /trunk/main/sw/source/core/inc/docfld.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
11d2dbeb0SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
31d2dbeb0SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
41d2dbeb0SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
51d2dbeb0SAndrew Rist  * distributed with this work for additional information
61d2dbeb0SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
71d2dbeb0SAndrew Rist  * to you under the Apache License, Version 2.0 (the
81d2dbeb0SAndrew Rist  * "License"); you may not use this file except in compliance
91d2dbeb0SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
111d2dbeb0SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
131d2dbeb0SAndrew Rist  * Unless required by applicable law or agreed to in writing,
141d2dbeb0SAndrew Rist  * software distributed under the License is distributed on an
151d2dbeb0SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
161d2dbeb0SAndrew Rist  * KIND, either express or implied.  See the License for the
171d2dbeb0SAndrew Rist  * specific language governing permissions and limitations
181d2dbeb0SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
201d2dbeb0SAndrew Rist  *************************************************************/
211d2dbeb0SAndrew Rist 
221d2dbeb0SAndrew Rist 
23cdf0e10cSrcweir #ifndef _DOCFLD_HXX
24cdf0e10cSrcweir #define _DOCFLD_HXX
25cdf0e10cSrcweir 
26cdf0e10cSrcweir #include <calc.hxx>         // fuer SwHash
27cdf0e10cSrcweir 
28cdf0e10cSrcweir class SwTxtFld;
29cdf0e10cSrcweir class SwIndex;
30cdf0e10cSrcweir class SwNodeIndex;
31cdf0e10cSrcweir class SwCntntNode;
32cdf0e10cSrcweir class SwCntntFrm;
33cdf0e10cSrcweir class SwSectionNode;
34cdf0e10cSrcweir class SwSection;
35cdf0e10cSrcweir class SwTxtTOXMark;
36cdf0e10cSrcweir class SwTableBox;
37cdf0e10cSrcweir class SwTxtINetFmt;
38cdf0e10cSrcweir class SwFlyFrmFmt;
39cdf0e10cSrcweir class SwDoc;
40cdf0e10cSrcweir class SwNode;
41cdf0e10cSrcweir struct SwPosition;
42cdf0e10cSrcweir 
43cdf0e10cSrcweir // Update an den Expression Feldern
44cdf0e10cSrcweir class _SetGetExpFld
45cdf0e10cSrcweir {
46cdf0e10cSrcweir     sal_uLong nNode;
47cdf0e10cSrcweir     xub_StrLen nCntnt;
48cdf0e10cSrcweir     union {
49cdf0e10cSrcweir         const SwTxtFld* pTxtFld;
50cdf0e10cSrcweir         const SwSection* pSection;
51cdf0e10cSrcweir         const SwPosition* pPos;
52cdf0e10cSrcweir         const SwTxtTOXMark* pTxtTOX;
53cdf0e10cSrcweir         const SwTableBox* pTBox;
54cdf0e10cSrcweir         const SwTxtINetFmt* pTxtINet;
55cdf0e10cSrcweir         const SwFlyFrmFmt* pFlyFmt;
56cdf0e10cSrcweir     } CNTNT;
57cdf0e10cSrcweir     enum _SetGetExpFldType
58cdf0e10cSrcweir         {
59cdf0e10cSrcweir             TEXTFIELD, TEXTTOXMARK, SECTIONNODE, CRSRPOS, TABLEBOX,
60cdf0e10cSrcweir             TEXTINET, FLYFRAME
61cdf0e10cSrcweir         } eSetGetExpFldType;
62cdf0e10cSrcweir 
63cdf0e10cSrcweir public:
64cdf0e10cSrcweir     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtFld* pFld = 0,
65cdf0e10cSrcweir                     const SwIndex* pIdx = 0 );
66cdf0e10cSrcweir 
67cdf0e10cSrcweir     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtINetFmt& rINet,
68cdf0e10cSrcweir                     const SwIndex* pIdx = 0 );
69cdf0e10cSrcweir 
70cdf0e10cSrcweir     _SetGetExpFld( const SwSectionNode& rSectNode,
71cdf0e10cSrcweir                     const SwPosition* pPos = 0  );
72cdf0e10cSrcweir 
73cdf0e10cSrcweir     _SetGetExpFld( const SwTableBox& rTableBox,
74cdf0e10cSrcweir                     const SwPosition* pPos = 0  );
75cdf0e10cSrcweir 
76cdf0e10cSrcweir     _SetGetExpFld( const SwNodeIndex& rNdIdx, const SwTxtTOXMark& rTOX,
77cdf0e10cSrcweir                     const SwIndex* pIdx );
78cdf0e10cSrcweir 
79cdf0e10cSrcweir     _SetGetExpFld( const SwPosition& rPos );
80cdf0e10cSrcweir 
81cdf0e10cSrcweir     _SetGetExpFld( const SwFlyFrmFmt& rFlyFmt, const SwPosition* pPos = 0 );
82cdf0e10cSrcweir 
83*69a74367SOliver-Rainer Wittmann     sal_Bool operator==( const _SetGetExpFld& rFld ) const;
84cdf0e10cSrcweir     sal_Bool operator<( const _SetGetExpFld& rFld ) const;
85cdf0e10cSrcweir 
GetTxtFld() const86c0286415SOliver-Rainer Wittmann     const SwTxtFld* GetTxtFld() const
87cdf0e10cSrcweir         { return TEXTFIELD == eSetGetExpFldType ? CNTNT.pTxtFld : 0; }
GetTOX() const88cdf0e10cSrcweir     const SwTxtTOXMark* GetTOX() const
89cdf0e10cSrcweir         { return TEXTTOXMARK == eSetGetExpFldType ? CNTNT.pTxtTOX : 0; }
GetSection() const90cdf0e10cSrcweir     const SwSection* GetSection() const
91cdf0e10cSrcweir         { return SECTIONNODE == eSetGetExpFldType ? CNTNT.pSection : 0; }
GetTableBox() const92cdf0e10cSrcweir     const SwTableBox* GetTableBox() const
93cdf0e10cSrcweir         { return TABLEBOX == eSetGetExpFldType ? CNTNT.pTBox : 0; }
GetINetFmt() const94cdf0e10cSrcweir     const SwTxtINetFmt* GetINetFmt() const
95cdf0e10cSrcweir         { return TEXTINET == eSetGetExpFldType ? CNTNT.pTxtINet : 0; }
GetFlyFmt() const96cdf0e10cSrcweir     const SwFlyFrmFmt* GetFlyFmt() const
97cdf0e10cSrcweir         { return FLYFRAME == eSetGetExpFldType ? CNTNT.pFlyFmt : 0; }
98cdf0e10cSrcweir 
GetNode() const99cdf0e10cSrcweir     sal_uLong GetNode() const { return nNode; }
GetCntnt() const100cdf0e10cSrcweir     xub_StrLen GetCntnt() const { return nCntnt; }
GetPointer() const101cdf0e10cSrcweir     const void* GetPointer() const { return CNTNT.pTxtFld; }
102cdf0e10cSrcweir 
103cdf0e10cSrcweir     void GetPos( SwPosition& rPos ) const;
104cdf0e10cSrcweir     void GetPosOfContent( SwPosition& rPos ) const;
105cdf0e10cSrcweir 
106cdf0e10cSrcweir     const SwNode* GetNodeFromCntnt() const;
107cdf0e10cSrcweir     xub_StrLen GetCntPosFromCntnt() const;
108cdf0e10cSrcweir 
109cdf0e10cSrcweir     void SetBodyPos( const SwCntntFrm& rFrm );
110cdf0e10cSrcweir };
111cdf0e10cSrcweir 
112cdf0e10cSrcweir typedef _SetGetExpFld* _SetGetExpFldPtr;
113cdf0e10cSrcweir SV_DECL_PTRARR_SORT_DEL( _SetGetExpFlds, _SetGetExpFldPtr, 0, 10 )
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 
116cdf0e10cSrcweir // Struktur zum Speichern der Strings aus SetExp-String-Feldern
117cdf0e10cSrcweir struct _HashStr : public SwHash
118cdf0e10cSrcweir {
119cdf0e10cSrcweir     String aSetStr;
120cdf0e10cSrcweir     _HashStr( const String& rName, const String& rText, _HashStr* = 0 );
121cdf0e10cSrcweir };
122cdf0e10cSrcweir 
123cdf0e10cSrcweir struct SwCalcFldType : public SwHash
124cdf0e10cSrcweir {
125cdf0e10cSrcweir     const SwFieldType* pFldType;
126cdf0e10cSrcweir 
SwCalcFldTypeSwCalcFldType127cdf0e10cSrcweir     SwCalcFldType( const String& rStr, const SwFieldType* pFldTyp )
128cdf0e10cSrcweir         : SwHash( rStr ), pFldType( pFldTyp )
129cdf0e10cSrcweir     {}
130cdf0e10cSrcweir };
131cdf0e10cSrcweir 
132cdf0e10cSrcweir // Suche nach dem String, der unter dem Namen in der HashTabelle abgelegt
133cdf0e10cSrcweir // wurde
134cdf0e10cSrcweir void LookString( SwHash** ppTbl, sal_uInt16 nSize, const String& rName,
135cdf0e10cSrcweir                     String& rRet, sal_uInt16* pPos = 0 );
136cdf0e10cSrcweir 
137cdf0e10cSrcweir 
138cdf0e10cSrcweir // --------
139cdf0e10cSrcweir 
140cdf0e10cSrcweir const int GETFLD_ALL        = 3;        // veroderte Flags !!
141cdf0e10cSrcweir const int GETFLD_CALC       = 1;
142cdf0e10cSrcweir const int GETFLD_EXPAND     = 2;
143cdf0e10cSrcweir 
144cdf0e10cSrcweir class SwDocUpdtFld
145cdf0e10cSrcweir {
146cdf0e10cSrcweir     _SetGetExpFlds* pFldSortLst;    // akt. Field-Liste zum Calculieren
147cdf0e10cSrcweir     SwCalcFldType*  aFldTypeTable[ TBLSZ ];
148cdf0e10cSrcweir 
149cdf0e10cSrcweir // noch eine weitere Optimierung - wird z.Z. nicht angesprochen!
150cdf0e10cSrcweir     long nFldUpdtPos;               // ab dieser Position mit Update starten
151cdf0e10cSrcweir     SwCntntNode* pCNode;            // der TxtNode zur UpdatePos.
152cdf0e10cSrcweir 
153cdf0e10cSrcweir     sal_uLong nNodes;                   // sollte die NodesAnzahl unterschiedlich sein
154cdf0e10cSrcweir     sal_uInt8 nFldLstGetMode;
155cdf0e10cSrcweir 
156cdf0e10cSrcweir     sal_Bool bInUpdateFlds : 1;         // zur Zeit laeuft ein UpdateFlds,
157cdf0e10cSrcweir     sal_Bool bFldsDirty : 1;            // irgendwelche Felder sind ungueltig
158cdf0e10cSrcweir 
159cdf0e10cSrcweir     void _MakeFldList( SwDoc& pDoc, int eGetMode );
160cdf0e10cSrcweir     void GetBodyNode( const SwTxtFld& , sal_uInt16 nFldWhich );
161cdf0e10cSrcweir     void GetBodyNode( const SwSectionNode&);
162cdf0e10cSrcweir public:
163cdf0e10cSrcweir     SwDocUpdtFld();
164cdf0e10cSrcweir     ~SwDocUpdtFld();
165cdf0e10cSrcweir 
GetSortLst() const166cdf0e10cSrcweir     const _SetGetExpFlds* GetSortLst() const { return pFldSortLst; }
167cdf0e10cSrcweir 
168cdf0e10cSrcweir     void MakeFldList( SwDoc& rDoc, int bAll, int eGetMode );
169cdf0e10cSrcweir 
170cdf0e10cSrcweir     void InsDelFldInFldLst( sal_Bool bIns, const SwTxtFld& rFld );
171cdf0e10cSrcweir 
172cdf0e10cSrcweir     void InsertFldType( const SwFieldType& rType );
173cdf0e10cSrcweir     void RemoveFldType( const SwFieldType& rType );
174cdf0e10cSrcweir 
IsInUpdateFlds() const175cdf0e10cSrcweir     sal_Bool IsInUpdateFlds() const         { return bInUpdateFlds; }
SetInUpdateFlds(sal_Bool b)176cdf0e10cSrcweir     void SetInUpdateFlds( sal_Bool b )      { bInUpdateFlds = b; }
177cdf0e10cSrcweir 
IsFieldsDirty() const178cdf0e10cSrcweir     sal_Bool IsFieldsDirty() const          { return bFldsDirty; }
SetFieldsDirty(sal_Bool b)179cdf0e10cSrcweir     void SetFieldsDirty( sal_Bool b )       { bFldsDirty = b; }
180cdf0e10cSrcweir 
GetFldTypeTable() const181cdf0e10cSrcweir     SwHash**    GetFldTypeTable() const { return (SwHash**)aFldTypeTable; }
182cdf0e10cSrcweir };
183cdf0e10cSrcweir 
184cdf0e10cSrcweir 
185cdf0e10cSrcweir #endif  // _DOCFLD_HXX
186