xref: /AOO41X/main/sw/source/ui/inc/fldmgr.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _FLDMGR_HXX
28*cdf0e10cSrcweir #define _FLDMGR_HXX
29*cdf0e10cSrcweir #ifndef _SVSTDARR_HXX
30*cdf0e10cSrcweir #define _SVSTDARR_STRINGSDTOR
31*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
32*cdf0e10cSrcweir #endif
33*cdf0e10cSrcweir #include <tools/string.hxx>
34*cdf0e10cSrcweir #include "swdllapi.h"
35*cdf0e10cSrcweir #include "swtypes.hxx"
36*cdf0e10cSrcweir #include <com/sun/star/uno/Reference.h>
37*cdf0e10cSrcweir #include <com/sun/star/uno/Any.h>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir namespace com{namespace sun{namespace star{
40*cdf0e10cSrcweir 	namespace container{
41*cdf0e10cSrcweir 		class XNameAccess;
42*cdf0e10cSrcweir 	}
43*cdf0e10cSrcweir 	namespace text{
44*cdf0e10cSrcweir 		class XNumberingTypeInfo;
45*cdf0e10cSrcweir 	}
46*cdf0e10cSrcweir }}}
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir class SwWrtShell;
49*cdf0e10cSrcweir class SwField;
50*cdf0e10cSrcweir class SwFieldType;
51*cdf0e10cSrcweir class SbModule;
52*cdf0e10cSrcweir class SvxMacroItem;
53*cdf0e10cSrcweir class SvNumberFormatter;
54*cdf0e10cSrcweir class Window;
55*cdf0e10cSrcweir /*--------------------------------------------------------------------
56*cdf0e10cSrcweir 	Beschreibung: Die Gruppen von Feldern
57*cdf0e10cSrcweir  --------------------------------------------------------------------*/
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir enum SwFldGroups
60*cdf0e10cSrcweir {
61*cdf0e10cSrcweir 	GRP_DOC,
62*cdf0e10cSrcweir 	GRP_FKT,
63*cdf0e10cSrcweir 	GRP_REF,
64*cdf0e10cSrcweir 	GRP_REG,
65*cdf0e10cSrcweir 	GRP_DB,
66*cdf0e10cSrcweir 	GRP_VAR
67*cdf0e10cSrcweir };
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir struct SwFldGroupRgn
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 	sal_uInt16 nStart;
72*cdf0e10cSrcweir 	sal_uInt16 nEnd;
73*cdf0e10cSrcweir };
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir /*--------------------------------------------------------------------
76*cdf0e10cSrcweir 	Beschreibung:  Der FeldManager handelt das Einfuegen von Felder
77*cdf0e10cSrcweir 					ueber Command-Strings
78*cdf0e10cSrcweir  --------------------------------------------------------------------*/
79*cdf0e10cSrcweir struct SwInsertFld_Data
80*cdf0e10cSrcweir {
81*cdf0e10cSrcweir     sal_uInt16 nTypeId;
82*cdf0e10cSrcweir     sal_uInt16 nSubType;
83*cdf0e10cSrcweir     const String sPar1;
84*cdf0e10cSrcweir     const String sPar2;
85*cdf0e10cSrcweir     sal_uLong nFormatId;
86*cdf0e10cSrcweir     SwWrtShell* pSh;
87*cdf0e10cSrcweir     sal_Unicode cSeparator;
88*cdf0e10cSrcweir     sal_Bool bIsAutomaticLanguage;
89*cdf0e10cSrcweir     ::com::sun::star::uno::Any aDBDataSource;
90*cdf0e10cSrcweir     ::com::sun::star::uno::Any aDBConnection;
91*cdf0e10cSrcweir     ::com::sun::star::uno::Any aDBColumn;
92*cdf0e10cSrcweir     Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
93*cdf0e10cSrcweir 
94*cdf0e10cSrcweir     SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const String& rPar1, const String& rPar2,
95*cdf0e10cSrcweir                     sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) :
96*cdf0e10cSrcweir         nTypeId(nType),
97*cdf0e10cSrcweir         nSubType(nSub),
98*cdf0e10cSrcweir         sPar1(rPar1),
99*cdf0e10cSrcweir         sPar2(rPar2),
100*cdf0e10cSrcweir         nFormatId(nFmtId),
101*cdf0e10cSrcweir         pSh(pShell),
102*cdf0e10cSrcweir         cSeparator(cSep),
103*cdf0e10cSrcweir         bIsAutomaticLanguage(bIsAutoLanguage),
104*cdf0e10cSrcweir         pParent(0) {}
105*cdf0e10cSrcweir 
106*cdf0e10cSrcweir     SwInsertFld_Data() :
107*cdf0e10cSrcweir         pSh(0),
108*cdf0e10cSrcweir         cSeparator(' '),
109*cdf0e10cSrcweir         bIsAutomaticLanguage(sal_True){}
110*cdf0e10cSrcweir 
111*cdf0e10cSrcweir };
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir class SW_DLLPUBLIC SwFldMgr
114*cdf0e10cSrcweir {
115*cdf0e10cSrcweir private:
116*cdf0e10cSrcweir 	SwField*			pCurFld;
117*cdf0e10cSrcweir 	SbModule*			pModule;
118*cdf0e10cSrcweir 	const SvxMacroItem*	pMacroItem;
119*cdf0e10cSrcweir 	SwWrtShell* 		pWrtShell; // darf auch NULL sein!
120*cdf0e10cSrcweir 	String			aCurPar1;
121*cdf0e10cSrcweir 	String			aCurPar2;
122*cdf0e10cSrcweir 	String 			sCurFrame;
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir 	String          sMacroPath;
125*cdf0e10cSrcweir 	String          sMacroName;
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir 	sal_uLong			nCurFmt;
128*cdf0e10cSrcweir 	sal_Bool			bEvalExp;
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 	SW_DLLPRIVATE sal_uInt16			GetCurrLanguage() const;
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 	com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
133*cdf0e10cSrcweir 	com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
134*cdf0e10cSrcweir 	SW_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir public:
137*cdf0e10cSrcweir 	SwFldMgr(SwWrtShell* pSh = 0);
138*cdf0e10cSrcweir 	~SwFldMgr();
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     void                SetWrtShell( SwWrtShell* pShell )
141*cdf0e10cSrcweir                         {   pWrtShell = pShell;     }
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir     // Feld einfuegen ueber TypeId (TYP_ ...)
144*cdf0e10cSrcweir     sal_Bool            InsertFld(  const SwInsertFld_Data& rData );
145*cdf0e10cSrcweir 
146*cdf0e10cSrcweir 	// Direkt das aktuelle Feld aendern
147*cdf0e10cSrcweir 	void 			UpdateCurFld(sal_uLong nFormat,
148*cdf0e10cSrcweir 								 const String& rPar1,
149*cdf0e10cSrcweir 								 const String& rPar2,
150*cdf0e10cSrcweir                                  SwField * _pField = 0); // #111840#
151*cdf0e10cSrcweir 
152*cdf0e10cSrcweir 	inline const String& GetCurFldPar1() const;
153*cdf0e10cSrcweir 	inline const String& GetCurFldPar2() const;
154*cdf0e10cSrcweir 	inline sal_uLong   GetCurFldFmt() const;
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 	// Ein Feld ermitteln
157*cdf0e10cSrcweir 	SwField*		GetCurFld();
158*cdf0e10cSrcweir 
159*cdf0e10cSrcweir 	void			InsertFldType(SwFieldType& rType);
160*cdf0e10cSrcweir 
161*cdf0e10cSrcweir 	sal_Bool			ChooseMacro(const String &rSelMacro = aEmptyStr);
162*cdf0e10cSrcweir 	void			SetMacroPath(const String& rPath);
163*cdf0e10cSrcweir 	inline const String& GetMacroPath() const		  { return (sMacroPath); }
164*cdf0e10cSrcweir 	inline const String& GetMacroName() const		  { return (sMacroName); }
165*cdf0e10cSrcweir 	inline void		SetMacroModule(SbModule* pMod)	  { pModule = pMod; }
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir 	// Vorheriger Naechster gleichen Typ
168*cdf0e10cSrcweir 	sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 );
169*cdf0e10cSrcweir 	sal_Bool GoNext( SwFieldType* pTyp = 0 )	{ return GoNextPrev( sal_True, pTyp ); }
170*cdf0e10cSrcweir 	sal_Bool GoPrev( SwFieldType* pTyp = 0 )	{ return GoNextPrev( sal_False, pTyp ); }
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir 	// Erfragen von Werten aus Datenbankfeldern (BASIC )
173*cdf0e10cSrcweir //	String			GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
174*cdf0e10cSrcweir 	sal_Bool			IsDBNumeric(const String& rDBName, const String& rTblQryName,
175*cdf0e10cSrcweir 										sal_Bool bIsTable, const String& rFldName);
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir 	// RefMark mit Namen organisieren
178*cdf0e10cSrcweir 	sal_Bool 			CanInsertRefMark( const String& rStr );
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir 	// Zugriff ueber ResId auf Feldtypen
182*cdf0e10cSrcweir 	sal_uInt16 			GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const;
183*cdf0e10cSrcweir 	SwFieldType* 	GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const;
184*cdf0e10cSrcweir 	SwFieldType* 	GetFldType(sal_uInt16 nResId, const String& rName) const;
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir 	void 			RemoveFldType(sal_uInt16 nResId, const String& rName);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir 	// Zugriff ueber TypeId aus dem Dialog
189*cdf0e10cSrcweir 	// Ids fuer einen Bereich von Feldern
190*cdf0e10cSrcweir 	const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const;
191*cdf0e10cSrcweir 	sal_uInt16			GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const;
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir 	// TypeId des aktuellen Feldes
194*cdf0e10cSrcweir 	sal_uInt16			GetCurTypeId() const;
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     // TypeId fuer einen konkrete Pos in der Liste
197*cdf0e10cSrcweir     static sal_uInt16   GetTypeId(sal_uInt16 nPos);
198*cdf0e10cSrcweir 	// Name des Typen in der Liste der Felder
199*cdf0e10cSrcweir     static const String&  GetTypeStr(sal_uInt16 nPos);
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir 	// Pos in der Liste der Felder
202*cdf0e10cSrcweir     static sal_uInt16   GetPos(sal_uInt16 nTypeId);
203*cdf0e10cSrcweir 
204*cdf0e10cSrcweir 	// Untertypen zu einem Typ
205*cdf0e10cSrcweir     sal_Bool            GetSubTypes(sal_uInt16 nId, SvStringsDtor& rToFill);
206*cdf0e10cSrcweir 
207*cdf0e10cSrcweir 	// Formate zu einem Typ
208*cdf0e10cSrcweir 	sal_uInt16 			GetFormatCount(sal_uInt16 nTypeId, sal_Bool bIsText, sal_Bool bHtmlMode = sal_False) const;
209*cdf0e10cSrcweir 	String 			GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
210*cdf0e10cSrcweir 	sal_uInt16			GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
211*cdf0e10cSrcweir 	sal_uLong			GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir 	// Evaluierung der ExpressionFelder ausschalten fuer das Einfuegen
214*cdf0e10cSrcweir 	// vieler Expressionfelder (siehe Etiketten)
215*cdf0e10cSrcweir 	//
216*cdf0e10cSrcweir 	inline void		SetEvalExpFlds(sal_Bool bEval);
217*cdf0e10cSrcweir 	void			EvalExpFlds(SwWrtShell* pSh = NULL);
218*cdf0e10cSrcweir };
219*cdf0e10cSrcweir 
220*cdf0e10cSrcweir inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval)
221*cdf0e10cSrcweir 	{ bEvalExp = bEval; }
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir inline const String& SwFldMgr::GetCurFldPar1() const
224*cdf0e10cSrcweir 	{ return aCurPar1; }
225*cdf0e10cSrcweir 
226*cdf0e10cSrcweir inline const String& SwFldMgr::GetCurFldPar2() const
227*cdf0e10cSrcweir 	{ return aCurPar2; }
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir inline sal_uLong SwFldMgr::GetCurFldFmt() const
230*cdf0e10cSrcweir 	{ return nCurFmt; }
231*cdf0e10cSrcweir 
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir #endif
234*cdf0e10cSrcweir 
235