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 SwPaM; 48 class SbModule; 49 class SvxMacroItem; 50 class SvNumberFormatter; 51 class Window; 52 /*-------------------------------------------------------------------- 53 Beschreibung: Die Gruppen von Feldern 54 --------------------------------------------------------------------*/ 55 56 enum SwFldGroups 57 { 58 GRP_DOC, 59 GRP_FKT, 60 GRP_REF, 61 GRP_REG, 62 GRP_DB, 63 GRP_VAR 64 }; 65 66 struct SwFldGroupRgn 67 { 68 sal_uInt16 nStart; 69 sal_uInt16 nEnd; 70 }; 71 72 /*-------------------------------------------------------------------- 73 Beschreibung: Der FeldManager handelt das Einfuegen von Felder 74 ueber Command-Strings 75 --------------------------------------------------------------------*/ 76 struct SwInsertFld_Data 77 { 78 sal_uInt16 nTypeId; 79 sal_uInt16 nSubType; 80 const String sPar1; 81 const String sPar2; 82 sal_uLong nFormatId; 83 SwWrtShell* pSh; 84 sal_Unicode cSeparator; 85 sal_Bool bIsAutomaticLanguage; 86 ::com::sun::star::uno::Any aDBDataSource; 87 ::com::sun::star::uno::Any aDBConnection; 88 ::com::sun::star::uno::Any aDBColumn; 89 Window* pParent; // parent dialog used for SwWrtShell::StartInputFldDlg() 90 91 SwInsertFld_Data(sal_uInt16 nType, sal_uInt16 nSub, const String& rPar1, const String& rPar2, 92 sal_uLong nFmtId, SwWrtShell* pShell = NULL, sal_Unicode cSep = ' ', sal_Bool bIsAutoLanguage = sal_True) : 93 nTypeId(nType), 94 nSubType(nSub), 95 sPar1(rPar1), 96 sPar2(rPar2), 97 nFormatId(nFmtId), 98 pSh(pShell), 99 cSeparator(cSep), 100 bIsAutomaticLanguage(bIsAutoLanguage), 101 pParent(0) {} 102 103 SwInsertFld_Data() : 104 pSh(0), 105 cSeparator(' '), 106 bIsAutomaticLanguage(sal_True){} 107 108 }; 109 110 class SW_DLLPUBLIC SwFldMgr 111 { 112 private: 113 SwField* pCurFld; 114 SbModule* pModule; 115 const SvxMacroItem* pMacroItem; 116 SwWrtShell* pWrtShell; // darf auch NULL sein! 117 String aCurPar1; 118 String aCurPar2; 119 String sCurFrame; 120 121 String sMacroPath; 122 String sMacroName; 123 124 sal_uLong nCurFmt; 125 sal_Bool bEvalExp; 126 127 SW_DLLPRIVATE sal_uInt16 GetCurrLanguage() const; 128 129 com::sun::star::uno::Reference<com::sun::star::container::XNameAccess> xDBContext; 130 com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> xNumberingInfo; 131 SW_DLLPRIVATE com::sun::star::uno::Reference<com::sun::star::text::XNumberingTypeInfo> GetNumberingInfo()const; 132 133 public: 134 SwFldMgr(SwWrtShell* pSh = 0); 135 ~SwFldMgr(); 136 137 void SetWrtShell( SwWrtShell* pShell ) 138 { pWrtShell = pShell; } 139 140 // insert field using TypeID (TYP_ ...) 141 sal_Bool InsertFld( 142 const SwInsertFld_Data& rData, 143 const SwPaM* pPam = 0 ); 144 145 // Direkt das aktuelle Feld aendern 146 void UpdateCurFld(sal_uLong nFormat, 147 const String& rPar1, 148 const String& rPar2, 149 SwField * _pField = 0); // #111840# 150 151 inline const String& GetCurFldPar1() const; 152 inline const String& GetCurFldPar2() const; 153 inline sal_uLong GetCurFldFmt() const; 154 155 // Ein Feld ermitteln 156 SwField* GetCurFld(); 157 158 void InsertFldType(SwFieldType& rType); 159 160 sal_Bool ChooseMacro(const String &rSelMacro = aEmptyStr); 161 void SetMacroPath(const String& rPath); 162 inline const String& GetMacroPath() const { return (sMacroPath); } 163 inline const String& GetMacroName() const { return (sMacroName); } 164 inline void SetMacroModule(SbModule* pMod) { pModule = pMod; } 165 166 // Vorheriger Naechster gleichen Typ 167 sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 ); 168 sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); } 169 sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); } 170 171 // Erfragen von Werten aus Datenbankfeldern (BASIC ) 172 // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh); 173 sal_Bool IsDBNumeric(const String& rDBName, const String& rTblQryName, 174 sal_Bool bIsTable, const String& rFldName); 175 176 // RefMark mit Namen organisieren 177 sal_Bool CanInsertRefMark( const String& rStr ); 178 179 180 // Zugriff ueber ResId auf Feldtypen 181 sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const; 182 SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const; 183 SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const; 184 185 void RemoveFldType(sal_uInt16 nResId, const String& rName); 186 187 // Zugriff ueber TypeId aus dem Dialog 188 // Ids fuer einen Bereich von Feldern 189 const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const; 190 sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const; 191 192 // TypeId des aktuellen Feldes 193 sal_uInt16 GetCurTypeId() const; 194 195 // TypeId fuer einen konkrete Pos in der Liste 196 static sal_uInt16 GetTypeId(sal_uInt16 nPos); 197 // Name des Typen in der Liste der Felder 198 static const String& GetTypeStr(sal_uInt16 nPos); 199 200 // Pos in der Liste der Felder 201 static sal_uInt16 GetPos(sal_uInt16 nTypeId); 202 203 // Untertypen zu einem Typ 204 sal_Bool GetSubTypes(sal_uInt16 nId, SvStringsDtor& rToFill); 205 206 // Formate zu einem Typ 207 sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, sal_Bool bIsText, sal_Bool bHtmlMode = sal_False) const; 208 String GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const; 209 sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const; 210 sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L); 211 212 // Evaluierung der ExpressionFelder ausschalten fuer das Einfuegen 213 // vieler Expressionfelder (siehe Etiketten) 214 // 215 inline void SetEvalExpFlds(sal_Bool bEval); 216 void EvalExpFlds(SwWrtShell* pSh = NULL); 217 }; 218 219 inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval) 220 { bEvalExp = bEval; } 221 222 inline const String& SwFldMgr::GetCurFldPar1() const 223 { return aCurPar1; } 224 225 inline const String& SwFldMgr::GetCurFldPar2() const 226 { return aCurPar2; } 227 228 inline sal_uLong SwFldMgr::GetCurFldFmt() const 229 { return nCurFmt; } 230 231 232 #endif 233 234