Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 : #ifndef INCLUDED_SW_SOURCE_UI_INC_FLDMGR_HXX
20 : #define INCLUDED_SW_SOURCE_UI_INC_FLDMGR_HXX
21 :
22 : #include "swdllapi.h"
23 : #include "swtypes.hxx"
24 : #include <com/sun/star/uno/Reference.h>
25 : #include <com/sun/star/uno/Any.h>
26 : #include <vector>
27 :
28 : namespace com{namespace sun{namespace star{
29 : namespace container{
30 : class XNameAccess;
31 : }
32 : namespace text{
33 : class XNumberingTypeInfo;
34 : }
35 : }}}
36 :
37 : class SwWrtShell;
38 : class SwField;
39 : class SwFieldType;
40 : class SwPaM;
41 : class SbModule;
42 : class SvxMacroItem;
43 : class SvNumberFormatter;
44 : class Window;
45 :
46 : /*--------------------------------------------------------------------
47 : Description: the groups of fields
48 : --------------------------------------------------------------------*/
49 : enum SwFldGroups
50 : {
51 : GRP_DOC,
52 : GRP_FKT,
53 : GRP_REF,
54 : GRP_REG,
55 : GRP_DB,
56 : GRP_VAR
57 : };
58 :
59 : struct SwFldGroupRgn
60 : {
61 : sal_uInt16 nStart;
62 : sal_uInt16 nEnd;
63 : };
64 :
65 : /*--------------------------------------------------------------------
66 : Description: the field manager handles the insertation of fields
67 : with command strings
68 : --------------------------------------------------------------------*/
69 0 : struct SwInsertFld_Data
70 : {
71 : sal_uInt16 nTypeId;
72 : sal_uInt16 nSubType;
73 : const OUString sPar1;
74 : const OUString sPar2;
75 : sal_uLong nFormatId;
76 : SwWrtShell* pSh;
77 : sal_Unicode cSeparator;
78 : sal_Bool bIsAutomaticLanguage;
79 : ::com::sun::star::uno::Any aDBDataSource;
80 : ::com::sun::star::uno::Any aDBConnection;
81 : ::com::sun::star::uno::Any aDBColumn;
82 : Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg()
83 :
84 0 : SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const OUString& rPar1, const OUString& rPar2,
85 : sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) :
86 : nTypeId(nType),
87 : nSubType(nSub),
88 : sPar1(rPar1),
89 : sPar2(rPar2),
90 : nFormatId(nFmtId),
91 : pSh(pShell),
92 : cSeparator(cSep),
93 : bIsAutomaticLanguage(bIsAutoLanguage),
94 0 : pParent(0) {}
95 :
96 : SwInsertFld_Data() :
97 : pSh(0),
98 : cSeparator(' '),
99 : bIsAutomaticLanguage(sal_True){}
100 :
101 : };
102 :
103 : class SW_DLLPUBLIC SwFldMgr
104 : {
105 : private:
106 : SwField* pCurFld;
107 : SbModule* pModule;
108 : const SvxMacroItem* pMacroItem;
109 : SwWrtShell* pWrtShell; // can be ZERO too!
110 : OUString aCurPar1;
111 : OUString aCurPar2;
112 : OUString sCurFrame;
113 :
114 : OUString sMacroPath;
115 : OUString sMacroName;
116 :
117 : sal_uLong nCurFmt;
118 : sal_Bool bEvalExp;
119 :
120 : SAL_DLLPRIVATE sal_uInt16 GetCurrLanguage() const;
121 :
122 : com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext;
123 : com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo;
124 : SAL_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const;
125 :
126 : public:
127 : SwFldMgr(SwWrtShell* pSh = 0);
128 : ~SwFldMgr();
129 :
130 0 : void SetWrtShell( SwWrtShell* pShell )
131 0 : { pWrtShell = pShell; }
132 :
133 : // insert field using TypeID (TYP_ ...)
134 : sal_Bool InsertFld( const SwInsertFld_Data& rData );
135 :
136 : // change the current field directly
137 : void UpdateCurFld(sal_uLong nFormat,
138 : const OUString& rPar1,
139 : const OUString& rPar2,
140 : SwField * _pField = 0); // #111840#
141 :
142 0 : OUString GetCurFldPar1() const { return aCurPar1; }
143 0 : OUString GetCurFldPar2() const { return aCurPar2; }
144 : inline sal_uLong GetCurFldFmt() const;
145 :
146 : // determine a field
147 : SwField* GetCurFld();
148 :
149 : void InsertFldType(SwFieldType& rType);
150 :
151 : sal_Bool ChooseMacro(const OUString &rSelMacro = OUString());
152 : void SetMacroPath(const OUString& rPath);
153 0 : inline OUString GetMacroPath() const { return sMacroPath; }
154 0 : inline OUString GetMacroName() const { return sMacroName; }
155 : inline void SetMacroModule(SbModule* pMod) { pModule = pMod; }
156 :
157 : // previous and next of the same type
158 : sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 );
159 0 : sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); }
160 0 : sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); }
161 :
162 : // query values from database fields (BASIC )
163 : // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh);
164 : sal_Bool IsDBNumeric(const OUString& rDBName, const OUString& rTblQryName,
165 : sal_Bool bIsTable, const OUString& rFldName);
166 :
167 : // organise RefMark with names
168 : bool CanInsertRefMark( const OUString& rStr );
169 :
170 : // access to field types via ResId
171 : sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const;
172 : SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const;
173 : SwFieldType* GetFldType(sal_uInt16 nResId, const OUString& rName) const;
174 :
175 : void RemoveFldType(sal_uInt16 nResId, const OUString& rName);
176 :
177 : // access via TypeId from the dialog
178 : // Ids for a range of fields
179 : const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const;
180 : sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const;
181 :
182 : // the current field's TypeId
183 : sal_uInt16 GetCurTypeId() const;
184 :
185 : // TypeId for a concrete position in the list
186 : static sal_uInt16 GetTypeId(sal_uInt16 nPos);
187 : // name of the type in the list of fields
188 : static OUString GetTypeStr(sal_uInt16 nPos);
189 :
190 : // Pos in the list of fields
191 : static sal_uInt16 GetPos(sal_uInt16 nTypeId);
192 :
193 : // subtypes to a type
194 : bool GetSubTypes(sal_uInt16 nId, std::vector<OUString>& rToFill);
195 :
196 : // format to a type
197 : sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, bool bIsText, sal_Bool bHtmlMode = sal_False) const;
198 : OUString GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
199 : sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const;
200 : sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L);
201 :
202 : // turn off evaluation of expression fields for insertation
203 : // of many expressino fields (see labels)
204 :
205 : inline void SetEvalExpFlds(sal_Bool bEval);
206 : void EvalExpFlds(SwWrtShell* pSh = NULL);
207 : };
208 :
209 0 : inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval)
210 0 : { bEvalExp = bEval; }
211 :
212 : inline sal_uLong SwFldMgr::GetCurFldFmt() const
213 : { return nCurFmt; }
214 :
215 : #endif
216 :
217 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|