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 _FLDMGR_HXX
24cdf0e10cSrcweir #define _FLDMGR_HXX
25cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
26cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
27cdf0e10cSrcweir #include <svl/svstdarr.hxx>
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #include <tools/string.hxx>
30cdf0e10cSrcweir #include "swdllapi.h"
31cdf0e10cSrcweir #include "swtypes.hxx"
32cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
33cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
34cdf0e10cSrcweir
35cdf0e10cSrcweir namespace com{namespace sun{namespace star{
36cdf0e10cSrcweir namespace container{
37cdf0e10cSrcweir class XNameAccess;
38cdf0e10cSrcweir }
39cdf0e10cSrcweir namespace text{
40cdf0e10cSrcweir class XNumberingTypeInfo;
41cdf0e10cSrcweir }
42cdf0e10cSrcweir }}}
43cdf0e10cSrcweir
44cdf0e10cSrcweir class SwWrtShell;
45cdf0e10cSrcweir class SwField;
46cdf0e10cSrcweir class SwFieldType;
473b32dd21SOliver-Rainer Wittmann class SwPaM;
48cdf0e10cSrcweir class SbModule;
49cdf0e10cSrcweir class SvxMacroItem;
50cdf0e10cSrcweir class SvNumberFormatter;
51cdf0e10cSrcweir class Window;
52cdf0e10cSrcweir /*--------------------------------------------------------------------
53cdf0e10cSrcweir Beschreibung: Die Gruppen von Feldern
54cdf0e10cSrcweir --------------------------------------------------------------------*/
55cdf0e10cSrcweir
56cdf0e10cSrcweir enum SwFldGroups
57cdf0e10cSrcweir {
58cdf0e10cSrcweir GRP_DOC,
59cdf0e10cSrcweir GRP_FKT,
60cdf0e10cSrcweir GRP_REF,
61cdf0e10cSrcweir GRP_REG,
62cdf0e10cSrcweir GRP_DB,
63cdf0e10cSrcweir GRP_VAR
64cdf0e10cSrcweir };
65cdf0e10cSrcweir
66cdf0e10cSrcweir struct SwFldGroupRgn
67cdf0e10cSrcweir {
68cdf0e10cSrcweir sal_uInt16 nStart;
69cdf0e10cSrcweir sal_uInt16 nEnd;
70cdf0e10cSrcweir };
71cdf0e10cSrcweir
72cdf0e10cSrcweir /*--------------------------------------------------------------------
73cdf0e10cSrcweir Beschreibung: Der FeldManager handelt das Einfuegen von Felder
74cdf0e10cSrcweir ueber Command-Strings
75cdf0e10cSrcweir --------------------------------------------------------------------*/
76cdf0e10cSrcweir struct SwInsertFld_Data
77cdf0e10cSrcweir {
78cdf0e10cSrcweir sal_uInt16 nTypeId;
79cdf0e10cSrcweir sal_uInt16 nSubType;
80cdf0e10cSrcweir const String sPar1;
81cdf0e10cSrcweir const String sPar2;
82cdf0e10cSrcweir sal_uLong nFormatId;
83cdf0e10cSrcweir SwWrtShell* pSh;
84cdf0e10cSrcweir sal_Unicode cSeparator;
85cdf0e10cSrcweir sal_Bool bIsAutomaticLanguage;
86cdf0e10cSrcweir ::com::sun::star::uno::Any aDBDataSource;
87cdf0e10cSrcweir ::com::sun::star::uno::Any aDBConnection;
88cdf0e10cSrcweir ::com::sun::star::uno::Any aDBColumn;
89cdf0e10cSrcweir Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
90cdf0e10cSrcweir
SwInsertFld_DataSwInsertFld_Data91cdf0e10cSrcweir SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const String& rPar1, const String& rPar2,
92cdf0e10cSrcweir sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) :
93cdf0e10cSrcweir nTypeId(nType),
94cdf0e10cSrcweir nSubType(nSub),
95cdf0e10cSrcweir sPar1(rPar1),
96cdf0e10cSrcweir sPar2(rPar2),
97cdf0e10cSrcweir nFormatId(nFmtId),
98cdf0e10cSrcweir pSh(pShell),
99cdf0e10cSrcweir cSeparator(cSep),
100cdf0e10cSrcweir bIsAutomaticLanguage(bIsAutoLanguage),
101cdf0e10cSrcweir pParent(0) {}
102cdf0e10cSrcweir
SwInsertFld_DataSwInsertFld_Data103cdf0e10cSrcweir SwInsertFld_Data() :
104cdf0e10cSrcweir pSh(0),
105cdf0e10cSrcweir cSeparator(' '),
106cdf0e10cSrcweir bIsAutomaticLanguage(sal_True){}
107cdf0e10cSrcweir
108cdf0e10cSrcweir };
109cdf0e10cSrcweir
110cdf0e10cSrcweir class SW_DLLPUBLIC SwFldMgr
111cdf0e10cSrcweir {
112cdf0e10cSrcweir private:
113cdf0e10cSrcweir SwField* pCurFld;
114cdf0e10cSrcweir SbModule* pModule;
115cdf0e10cSrcweir const SvxMacroItem* pMacroItem;
116cdf0e10cSrcweir SwWrtShell* pWrtShell; // darf auch NULL sein!
117cdf0e10cSrcweir String aCurPar1;
118cdf0e10cSrcweir String aCurPar2;
119cdf0e10cSrcweir String sCurFrame;
120cdf0e10cSrcweir
121cdf0e10cSrcweir String sMacroPath;
122cdf0e10cSrcweir String sMacroName;
123cdf0e10cSrcweir
124cdf0e10cSrcweir sal_uLong nCurFmt;
125cdf0e10cSrcweir sal_Bool bEvalExp;
126cdf0e10cSrcweir
127cdf0e10cSrcweir SW_DLLPRIVATE sal_uInt16 GetCurrLanguage() const;
128cdf0e10cSrcweir
129cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
130cdf0e10cSrcweir com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
131cdf0e10cSrcweir SW_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
132cdf0e10cSrcweir
133cdf0e10cSrcweir public:
134cdf0e10cSrcweir SwFldMgr(SwWrtShell* pSh = 0);
135cdf0e10cSrcweir ~SwFldMgr();
136cdf0e10cSrcweir
SetWrtShell(SwWrtShell * pShell)137cdf0e10cSrcweir void SetWrtShell( SwWrtShell* pShell )
138cdf0e10cSrcweir { pWrtShell = pShell; }
139cdf0e10cSrcweir
1403b32dd21SOliver-Rainer Wittmann // insert field using TypeID (TYP_ ...)
141*dec99bbdSOliver-Rainer Wittmann sal_Bool InsertFld( const SwInsertFld_Data& rData );
142cdf0e10cSrcweir
143cdf0e10cSrcweir // Direkt das aktuelle Feld aendern
144cdf0e10cSrcweir void UpdateCurFld(sal_uLong nFormat,
145cdf0e10cSrcweir const String& rPar1,
146cdf0e10cSrcweir const String& rPar2,
147cdf0e10cSrcweir SwField * _pField = 0); // #111840#
148cdf0e10cSrcweir
149cdf0e10cSrcweir inline const String& GetCurFldPar1() const;
150cdf0e10cSrcweir inline const String& GetCurFldPar2() const;
151cdf0e10cSrcweir inline sal_uLong GetCurFldFmt() const;
152cdf0e10cSrcweir
153cdf0e10cSrcweir // Ein Feld ermitteln
154cdf0e10cSrcweir SwField* GetCurFld();
155cdf0e10cSrcweir
156cdf0e10cSrcweir void InsertFldType(SwFieldType& rType);
157cdf0e10cSrcweir
158cdf0e10cSrcweir sal_Bool ChooseMacro(const String &rSelMacro = aEmptyStr);
159cdf0e10cSrcweir void SetMacroPath(const String& rPath);
GetMacroPath() const160cdf0e10cSrcweir inline const String& GetMacroPath() const { return (sMacroPath); }
GetMacroName() const161cdf0e10cSrcweir inline const String& GetMacroName() const { return (sMacroName); }
SetMacroModule(SbModule * pMod)162cdf0e10cSrcweir inline void SetMacroModule(SbModule* pMod) { pModule = pMod; }
163cdf0e10cSrcweir
164cdf0e10cSrcweir // Vorheriger Naechster gleichen Typ
165cdf0e10cSrcweir sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 );
GoNext(SwFieldType * pTyp=0)166cdf0e10cSrcweir sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); }
GoPrev(SwFieldType * pTyp=0)167cdf0e10cSrcweir sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); }
168cdf0e10cSrcweir
169cdf0e10cSrcweir // Erfragen von Werten aus Datenbankfeldern (BASIC )
170cdf0e10cSrcweir // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
171cdf0e10cSrcweir sal_Bool IsDBNumeric(const String& rDBName, const String& rTblQryName,
172cdf0e10cSrcweir sal_Bool bIsTable, const String& rFldName);
173cdf0e10cSrcweir
174cdf0e10cSrcweir // RefMark mit Namen organisieren
175cdf0e10cSrcweir sal_Bool CanInsertRefMark( const String& rStr );
176cdf0e10cSrcweir
177cdf0e10cSrcweir
178cdf0e10cSrcweir // Zugriff ueber ResId auf Feldtypen
179cdf0e10cSrcweir sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const;
180cdf0e10cSrcweir SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const;
181cdf0e10cSrcweir SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const;
182cdf0e10cSrcweir
183cdf0e10cSrcweir void RemoveFldType(sal_uInt16 nResId, const String& rName);
184cdf0e10cSrcweir
185cdf0e10cSrcweir // Zugriff ueber TypeId aus dem Dialog
186cdf0e10cSrcweir // Ids fuer einen Bereich von Feldern
187cdf0e10cSrcweir const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const;
188cdf0e10cSrcweir sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const;
189cdf0e10cSrcweir
190cdf0e10cSrcweir // TypeId des aktuellen Feldes
191cdf0e10cSrcweir sal_uInt16 GetCurTypeId() const;
192cdf0e10cSrcweir
193cdf0e10cSrcweir // TypeId fuer einen konkrete Pos in der Liste
194cdf0e10cSrcweir static sal_uInt16 GetTypeId(sal_uInt16 nPos);
195cdf0e10cSrcweir // Name des Typen in der Liste der Felder
196cdf0e10cSrcweir static const String& GetTypeStr(sal_uInt16 nPos);
197cdf0e10cSrcweir
198cdf0e10cSrcweir // Pos in der Liste der Felder
199cdf0e10cSrcweir static sal_uInt16 GetPos(sal_uInt16 nTypeId);
200cdf0e10cSrcweir
201cdf0e10cSrcweir // Untertypen zu einem Typ
202cdf0e10cSrcweir sal_Bool GetSubTypes(sal_uInt16 nId, SvStringsDtor& rToFill);
203cdf0e10cSrcweir
204cdf0e10cSrcweir // Formate zu einem Typ
205cdf0e10cSrcweir sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, sal_Bool bIsText, sal_Bool bHtmlMode = sal_False) const;
206cdf0e10cSrcweir String GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
207cdf0e10cSrcweir sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
208cdf0e10cSrcweir sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
209cdf0e10cSrcweir
210cdf0e10cSrcweir // Evaluierung der ExpressionFelder ausschalten fuer das Einfuegen
211cdf0e10cSrcweir // vieler Expressionfelder (siehe Etiketten)
212cdf0e10cSrcweir //
213cdf0e10cSrcweir inline void SetEvalExpFlds(sal_Bool bEval);
214cdf0e10cSrcweir void EvalExpFlds(SwWrtShell* pSh = NULL);
215cdf0e10cSrcweir };
216cdf0e10cSrcweir
SetEvalExpFlds(sal_Bool bEval)217cdf0e10cSrcweir inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval)
218cdf0e10cSrcweir { bEvalExp = bEval; }
219cdf0e10cSrcweir
GetCurFldPar1() const220cdf0e10cSrcweir inline const String& SwFldMgr::GetCurFldPar1() const
221cdf0e10cSrcweir { return aCurPar1; }
222cdf0e10cSrcweir
GetCurFldPar2() const223cdf0e10cSrcweir inline const String& SwFldMgr::GetCurFldPar2() const
224cdf0e10cSrcweir { return aCurPar2; }
225cdf0e10cSrcweir
GetCurFldFmt() const226cdf0e10cSrcweir inline sal_uLong SwFldMgr::GetCurFldFmt() const
227cdf0e10cSrcweir { return nCurFmt; }
228cdf0e10cSrcweir
229cdf0e10cSrcweir
230cdf0e10cSrcweir #endif
231