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