bump product version to 4.1.6.2
[LibreOffice.git] / sw / source / ui / inc / fldmgr.hxx
blobd745c41484b58abeb34770f28442120ab5f71466
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef _FLDMGR_HXX
20 #define _FLDMGR_HXX
22 #include <tools/string.hxx>
23 #include "swdllapi.h"
24 #include "swtypes.hxx"
25 #include <com/sun/star/uno/Reference.h>
26 #include <com/sun/star/uno/Any.h>
27 #include <vector>
29 namespace com{namespace sun{namespace star{
30 namespace container{
31 class XNameAccess;
33 namespace text{
34 class XNumberingTypeInfo;
36 }}}
38 class SwWrtShell;
39 class SwField;
40 class SwFieldType;
41 class SwPaM;
42 class SbModule;
43 class SvxMacroItem;
44 class SvNumberFormatter;
45 class Window;
47 /*--------------------------------------------------------------------
48 Description: the groups of fields
49 --------------------------------------------------------------------*/
50 enum SwFldGroups
52 GRP_DOC,
53 GRP_FKT,
54 GRP_REF,
55 GRP_REG,
56 GRP_DB,
57 GRP_VAR
60 struct SwFldGroupRgn
62 sal_uInt16 nStart;
63 sal_uInt16 nEnd;
66 /*--------------------------------------------------------------------
67 Description: the field manager handles the insertation of fields
68 with command strings
69 --------------------------------------------------------------------*/
70 struct SwInsertFld_Data
72 sal_uInt16 nTypeId;
73 sal_uInt16 nSubType;
74 const String sPar1;
75 const String sPar2;
76 sal_uLong nFormatId;
77 SwWrtShell* pSh;
78 sal_Unicode cSeparator;
79 sal_Bool bIsAutomaticLanguage;
80 ::com::sun::star::uno::Any aDBDataSource;
81 ::com::sun::star::uno::Any aDBConnection;
82 ::com::sun::star::uno::Any aDBColumn;
83 Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
85 SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const String& rPar1, const String& rPar2,
86 sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) :
87 nTypeId(nType),
88 nSubType(nSub),
89 sPar1(rPar1),
90 sPar2(rPar2),
91 nFormatId(nFmtId),
92 pSh(pShell),
93 cSeparator(cSep),
94 bIsAutomaticLanguage(bIsAutoLanguage),
95 pParent(0) {}
97 SwInsertFld_Data() :
98 pSh(0),
99 cSeparator(' '),
100 bIsAutomaticLanguage(sal_True){}
104 class SW_DLLPUBLIC SwFldMgr
106 private:
107 SwField* pCurFld;
108 SbModule* pModule;
109 const SvxMacroItem* pMacroItem;
110 SwWrtShell* pWrtShell; // can be ZERO too!
111 String aCurPar1;
112 String aCurPar2;
113 String sCurFrame;
115 String sMacroPath;
116 String sMacroName;
118 sal_uLong nCurFmt;
119 sal_Bool bEvalExp;
121 SW_DLLPRIVATE sal_uInt16 GetCurrLanguage() const;
123 com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
124 com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
125 SW_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
127 public:
128 SwFldMgr(SwWrtShell* pSh = 0);
129 ~SwFldMgr();
131 void SetWrtShell( SwWrtShell* pShell )
132 { pWrtShell = pShell; }
134 // insert field using TypeID (TYP_ ...)
135 sal_Bool InsertFld( const SwInsertFld_Data& rData, SwPaM* pPam = 0 );
137 // change the current field directly
138 void UpdateCurFld(sal_uLong nFormat,
139 const String& rPar1,
140 const String& rPar2,
141 SwField * _pField = 0); // #111840#
143 inline const String& GetCurFldPar1() const;
144 inline const String& GetCurFldPar2() const;
145 inline sal_uLong GetCurFldFmt() const;
147 // determine a field
148 SwField* GetCurFld();
150 void InsertFldType(SwFieldType& rType);
152 sal_Bool ChooseMacro(const String &rSelMacro = aEmptyStr);
153 void SetMacroPath(const String& rPath);
154 inline const String& GetMacroPath() const { return (sMacroPath); }
155 inline const String& GetMacroName() const { return (sMacroName); }
156 inline void SetMacroModule(SbModule* pMod) { pModule = pMod; }
158 // previous and next of the same type
159 sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 );
160 sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); }
161 sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); }
163 // query values from database fields (BASIC )
164 // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
165 sal_Bool IsDBNumeric(const String& rDBName, const String& rTblQryName,
166 sal_Bool bIsTable, const String& rFldName);
168 // organise RefMark with names
169 bool CanInsertRefMark( const String& rStr );
172 // access to field types via ResId
173 sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const;
174 SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const;
175 SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const;
177 void RemoveFldType(sal_uInt16 nResId, const String& rName);
179 // access via TypeId from the dialog
180 // Ids for a range of fields
181 const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const;
182 sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const;
184 // the current field's TypeId
185 sal_uInt16 GetCurTypeId() const;
187 // TypeId for a concrete position in the list
188 static sal_uInt16 GetTypeId(sal_uInt16 nPos);
189 // name of the type in the list of fields
190 static const String& GetTypeStr(sal_uInt16 nPos);
192 // Pos in the list of fields
193 static sal_uInt16 GetPos(sal_uInt16 nTypeId);
195 // subtypes to a type
196 bool GetSubTypes(sal_uInt16 nId, std::vector<OUString>& rToFill);
198 // format to a type
199 sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool bHtmlMode = sal_False) const;
200 String GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
201 sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
202 sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
204 // turn off evaluation of expression fields for insertation
205 // of many expressino fields (see labels)
207 inline void SetEvalExpFlds(sal_Bool bEval);
208 void EvalExpFlds(SwWrtShell* pSh = NULL);
211 inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval)
212 { bEvalExp = bEval; }
214 inline const String& SwFldMgr::GetCurFldPar1() const
215 { return aCurPar1; }
217 inline const String& SwFldMgr::GetCurFldPar2() const
218 { return aCurPar2; }
220 inline sal_uLong SwFldMgr::GetCurFldFmt() const
221 { return nCurFmt; }
223 #endif
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */