update dev300-m58
[ooovba.git] / sw / source / ui / inc / fldmgr.hxx
blob6b6396409f4c9b767bf5731addfb29d0029f4d18
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: fldmgr.hxx,v $
10 * $Revision: 1.16.214.1 $
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 _FLDMGR_HXX
31 #define _FLDMGR_HXX
32 #ifndef _SVSTDARR_HXX
33 #define _SVSTDARR_STRINGSDTOR
34 #include <svtools/svstdarr.hxx>
35 #endif
36 #include <tools/string.hxx>
37 #include "swdllapi.h"
38 #include "swtypes.hxx"
39 #include <com/sun/star/uno/Reference.h>
40 #include <com/sun/star/uno/Any.h>
42 namespace com{namespace sun{namespace star{
43 namespace container{
44 class XNameAccess;
46 namespace text{
47 class XNumberingTypeInfo;
49 }}}
51 class SwWrtShell;
52 class SwField;
53 class SwFieldType;
54 class SbModule;
55 class SvxMacroItem;
56 class SvNumberFormatter;
57 class Window;
58 /*--------------------------------------------------------------------
59 Beschreibung: Die Gruppen von Feldern
60 --------------------------------------------------------------------*/
62 enum SwFldGroups
64 GRP_DOC,
65 GRP_FKT,
66 GRP_REF,
67 GRP_REG,
68 GRP_DB,
69 GRP_VAR
72 struct SwFldGroupRgn
74 USHORT nStart;
75 USHORT nEnd;
78 /*--------------------------------------------------------------------
79 Beschreibung: Der FeldManager handelt das Einfuegen von Felder
80 ueber Command-Strings
81 --------------------------------------------------------------------*/
82 struct SwInsertFld_Data
84 USHORT nTypeId;
85 USHORT nSubType;
86 const String sPar1;
87 const String sPar2;
88 ULONG nFormatId;
89 SwWrtShell* pSh;
90 sal_Unicode cSeparator;
91 BOOL bIsAutomaticLanguage;
92 ::com::sun::star::uno::Any aDBDataSource;
93 ::com::sun::star::uno::Any aDBConnection;
94 ::com::sun::star::uno::Any aDBColumn;
95 Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
97 SwInsertFld_Data(USHORT nType, USHORT nSub, const String& rPar1, const String& rPar2,
98 ULONG nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', BOOL bIsAutoLanguage = TRUE) :
99 nTypeId(nType),
100 nSubType(nSub),
101 sPar1(rPar1),
102 sPar2(rPar2),
103 nFormatId(nFmtId),
104 pSh(pShell),
105 cSeparator(cSep),
106 bIsAutomaticLanguage(bIsAutoLanguage),
107 pParent(0) {}
109 SwInsertFld_Data() :
110 pSh(0),
111 cSeparator(' '),
112 bIsAutomaticLanguage(TRUE){}
116 class SW_DLLPUBLIC SwFldMgr
118 private:
119 SwField* pCurFld;
120 SbModule* pModule;
121 const SvxMacroItem* pMacroItem;
122 SwWrtShell* pWrtShell; // darf auch NULL sein!
123 String aCurPar1;
124 String aCurPar2;
125 String sCurFrame;
127 String sMacroPath;
128 String sMacroName;
130 ULONG nCurFmt;
131 BOOL bEvalExp;
133 SW_DLLPRIVATE USHORT GetCurrLanguage() const;
135 com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
136 com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
137 SW_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
139 public:
140 SwFldMgr(SwWrtShell* pSh = 0);
141 ~SwFldMgr();
143 void SetWrtShell( SwWrtShell* pShell )
144 { pWrtShell = pShell; }
146 // Feld einfuegen ueber TypeId (TYP_ ...)
147 BOOL InsertFld( const SwInsertFld_Data& rData );
149 // Direkt das aktuelle Feld aendern
150 void UpdateCurFld(ULONG nFormat,
151 const String& rPar1,
152 const String& rPar2,
153 SwField * _pField = 0); // #111840#
155 inline const String& GetCurFldPar1() const;
156 inline const String& GetCurFldPar2() const;
157 inline ULONG GetCurFldFmt() const;
159 // Ein Feld ermitteln
160 SwField* GetCurFld();
162 void InsertFldType(SwFieldType& rType);
164 BOOL ChooseMacro(const String &rSelMacro = aEmptyStr);
165 void SetMacroPath(const String& rPath);
166 inline const String& GetMacroPath() const { return (sMacroPath); }
167 inline const String& GetMacroName() const { return (sMacroName); }
168 inline void SetMacroModule(SbModule* pMod) { pModule = pMod; }
170 // Vorheriger Naechster gleichen Typ
171 BOOL GoNextPrev( BOOL bNext = TRUE, SwFieldType* pTyp = 0 );
172 BOOL GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( TRUE, pTyp ); }
173 BOOL GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( FALSE, pTyp ); }
175 // Erfragen von Werten aus Datenbankfeldern (BASIC )
176 // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
177 BOOL IsDBNumeric(const String& rDBName, const String& rTblQryName,
178 BOOL bIsTable, const String& rFldName);
180 // RefMark mit Namen organisieren
181 BOOL CanInsertRefMark( const String& rStr );
184 // Zugriff ueber ResId auf Feldtypen
185 USHORT GetFldTypeCount(USHORT nResId = USHRT_MAX) const;
186 SwFieldType* GetFldType(USHORT nResId, USHORT nId = 0) const;
187 SwFieldType* GetFldType(USHORT nResId, const String& rName) const;
189 void RemoveFldType(USHORT nResId, const String& rName);
191 // Zugriff ueber TypeId aus dem Dialog
192 // Ids fuer einen Bereich von Feldern
193 const SwFldGroupRgn& GetGroupRange(BOOL bHtmlMode, USHORT nGrpId) const;
194 USHORT GetGroup(BOOL bHtmlMode, USHORT nTypeId, USHORT nSubType = 0) const;
196 // TypeId des aktuellen Feldes
197 USHORT GetCurTypeId() const;
199 // TypeId fuer einen konkrete Pos in der Liste
200 static USHORT GetTypeId(USHORT nPos);
201 // Name des Typen in der Liste der Felder
202 static const String& GetTypeStr(USHORT nPos);
204 // Pos in der Liste der Felder
205 static USHORT GetPos(USHORT nTypeId);
207 // Untertypen zu einem Typ
208 BOOL GetSubTypes(USHORT nId, SvStringsDtor& rToFill);
210 // Formate zu einem Typ
211 USHORT GetFormatCount(USHORT nTypeId, BOOL bIsText, BOOL bHtmlMode = FALSE) const;
212 String GetFormatStr(USHORT nTypeId, ULONG nFormatId) const;
213 USHORT GetFormatId(USHORT nTypeId, ULONG nFormatId) const;
214 ULONG GetDefaultFormat(USHORT nTypeId, BOOL bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
216 // Evaluierung der ExpressionFelder ausschalten fuer das Einfuegen
217 // vieler Expressionfelder (siehe Etiketten)
219 inline void SetEvalExpFlds(BOOL bEval);
220 void EvalExpFlds(SwWrtShell* pSh = NULL);
223 inline void SwFldMgr::SetEvalExpFlds(BOOL bEval)
224 { bEvalExp = bEval; }
226 inline const String& SwFldMgr::GetCurFldPar1() const
227 { return aCurPar1; }
229 inline const String& SwFldMgr::GetCurFldPar2() const
230 { return aCurPar2; }
232 inline ULONG SwFldMgr::GetCurFldFmt() const
233 { return nCurFmt; }
236 #endif