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