1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docfld.hxx,v $
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 ************************************************************************/
33 #include <calc.hxx> // fuer SwHash
50 // Update an den Expression Feldern
56 const SwTxtFld
* pTxtFld
;
57 const SwSection
* pSection
;
58 const SwPosition
* pPos
;
59 const SwTxtTOXMark
* pTxtTOX
;
60 const SwTableBox
* pTBox
;
61 const SwTxtINetFmt
* pTxtINet
;
62 const SwFlyFrmFmt
* pFlyFmt
;
64 enum _SetGetExpFldType
66 TEXTFIELD
, TEXTTOXMARK
, SECTIONNODE
, CRSRPOS
, TABLEBOX
,
71 _SetGetExpFld( const SwNodeIndex
& rNdIdx
, const SwTxtFld
* pFld
= 0,
72 const SwIndex
* pIdx
= 0 );
74 _SetGetExpFld( const SwNodeIndex
& rNdIdx
, const SwTxtINetFmt
& rINet
,
75 const SwIndex
* pIdx
= 0 );
77 _SetGetExpFld( const SwSectionNode
& rSectNode
,
78 const SwPosition
* pPos
= 0 );
80 _SetGetExpFld( const SwTableBox
& rTableBox
,
81 const SwPosition
* pPos
= 0 );
83 _SetGetExpFld( const SwNodeIndex
& rNdIdx
, const SwTxtTOXMark
& rTOX
,
84 const SwIndex
* pIdx
);
86 _SetGetExpFld( const SwPosition
& rPos
);
88 _SetGetExpFld( const SwFlyFrmFmt
& rFlyFmt
, const SwPosition
* pPos
= 0 );
90 BOOL
operator==( const _SetGetExpFld
& rFld
) const
91 { return nNode
== rFld
.nNode
&& nCntnt
== rFld
.nCntnt
&&
92 ( !CNTNT
.pTxtFld
|| !rFld
.CNTNT
.pTxtFld
||
93 CNTNT
.pTxtFld
== rFld
.CNTNT
.pTxtFld
); }
94 BOOL
operator<( const _SetGetExpFld
& rFld
) const;
96 const SwTxtFld
* GetFld() const
97 { return TEXTFIELD
== eSetGetExpFldType
? CNTNT
.pTxtFld
: 0; }
98 const SwTxtTOXMark
* GetTOX() const
99 { return TEXTTOXMARK
== eSetGetExpFldType
? CNTNT
.pTxtTOX
: 0; }
100 const SwSection
* GetSection() const
101 { return SECTIONNODE
== eSetGetExpFldType
? CNTNT
.pSection
: 0; }
102 const SwTableBox
* GetTableBox() const
103 { return TABLEBOX
== eSetGetExpFldType
? CNTNT
.pTBox
: 0; }
104 const SwTxtINetFmt
* GetINetFmt() const
105 { return TEXTINET
== eSetGetExpFldType
? CNTNT
.pTxtINet
: 0; }
106 const SwFlyFrmFmt
* GetFlyFmt() const
107 { return FLYFRAME
== eSetGetExpFldType
? CNTNT
.pFlyFmt
: 0; }
109 ULONG
GetNode() const { return nNode
; }
110 xub_StrLen
GetCntnt() const { return nCntnt
; }
111 const void* GetPointer() const { return CNTNT
.pTxtFld
; }
113 void GetPos( SwPosition
& rPos
) const;
114 void GetPosOfContent( SwPosition
& rPos
) const;
116 const SwNode
* GetNodeFromCntnt() const;
117 xub_StrLen
GetCntPosFromCntnt() const;
119 void SetBodyPos( const SwCntntFrm
& rFrm
);
122 typedef _SetGetExpFld
* _SetGetExpFldPtr
;
123 SV_DECL_PTRARR_SORT_DEL( _SetGetExpFlds
, _SetGetExpFldPtr
, 0, 10 )
126 // Struktur zum Speichern der Strings aus SetExp-String-Feldern
127 struct _HashStr
: public SwHash
130 _HashStr( const String
& rName
, const String
& rText
, _HashStr
* = 0 );
133 struct SwCalcFldType
: public SwHash
135 const SwFieldType
* pFldType
;
137 SwCalcFldType( const String
& rStr
, const SwFieldType
* pFldTyp
)
138 : SwHash( rStr
), pFldType( pFldTyp
)
142 // Suche nach dem String, der unter dem Namen in der HashTabelle abgelegt
144 void LookString( SwHash
** ppTbl
, USHORT nSize
, const String
& rName
,
145 String
& rRet
, USHORT
* pPos
= 0 );
150 const int GETFLD_ALL
= 3; // veroderte Flags !!
151 const int GETFLD_CALC
= 1;
152 const int GETFLD_EXPAND
= 2;
156 _SetGetExpFlds
* pFldSortLst
; // akt. Field-Liste zum Calculieren
157 SwCalcFldType
* aFldTypeTable
[ TBLSZ
];
159 // noch eine weitere Optimierung - wird z.Z. nicht angesprochen!
160 long nFldUpdtPos
; // ab dieser Position mit Update starten
161 SwCntntNode
* pCNode
; // der TxtNode zur UpdatePos.
163 ULONG nNodes
; // sollte die NodesAnzahl unterschiedlich sein
166 BOOL bInUpdateFlds
: 1; // zur Zeit laeuft ein UpdateFlds,
167 BOOL bFldsDirty
: 1; // irgendwelche Felder sind ungueltig
169 void _MakeFldList( SwDoc
& pDoc
, int eGetMode
);
170 void GetBodyNode( const SwTxtFld
& , USHORT nFldWhich
);
171 void GetBodyNode( const SwSectionNode
&);
176 const _SetGetExpFlds
* GetSortLst() const { return pFldSortLst
; }
178 void MakeFldList( SwDoc
& rDoc
, int bAll
, int eGetMode
);
180 void InsDelFldInFldLst( BOOL bIns
, const SwTxtFld
& rFld
);
182 void InsertFldType( const SwFieldType
& rType
);
183 void RemoveFldType( const SwFieldType
& rType
);
185 BOOL
IsInUpdateFlds() const { return bInUpdateFlds
; }
186 void SetInUpdateFlds( BOOL b
) { bInUpdateFlds
= b
; }
188 BOOL
IsFieldsDirty() const { return bFldsDirty
; }
189 void SetFieldsDirty( BOOL b
) { bFldsDirty
= b
; }
191 SwHash
** GetFldTypeTable() const { return (SwHash
**)aFldTypeTable
; }
195 #endif // _DOCFLD_HXX