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( const SwInsertFld_Data& rData ); 142 143 // Direkt das aktuelle Feld aendern 144 void UpdateCurFld(sal_uLong nFormat, 145 const String& rPar1, 146 const String& rPar2, 147 SwField * _pField = 0); // #111840# 148 149 inline const String& GetCurFldPar1() const; 150 inline const String& GetCurFldPar2() const; 151 inline sal_uLong GetCurFldFmt() const; 152 153 // Ein Feld ermitteln 154 SwField* GetCurFld(); 155 156 void InsertFldType(SwFieldType& rType); 157 158 sal_Bool ChooseMacro(const String &rSelMacro = aEmptyStr); 159 void SetMacroPath(const String& rPath); 160 inline const String& GetMacroPath() const { return (sMacroPath); } 161 inline const String& GetMacroName() const { return (sMacroName); } 162 inline void SetMacroModule(SbModule* pMod) { pModule = pMod; } 163 164 // Vorheriger Naechster gleichen Typ 165 sal_Bool GoNextPrev( sal_Bool bNext = sal_True, SwFieldType* pTyp = 0 ); 166 sal_Bool GoNext( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_True, pTyp ); } 167 sal_Bool GoPrev( SwFieldType* pTyp = 0 ) { return GoNextPrev( sal_False, pTyp ); } 168 169 // Erfragen von Werten aus Datenbankfeldern (BASIC ) 170 // String GetDataBaseFieldValue(const String &rDBName, const String &rFieldName, SwWrtShell* pSh); 171 sal_Bool IsDBNumeric(const String& rDBName, const String& rTblQryName, 172 sal_Bool bIsTable, const String& rFldName); 173 174 // RefMark mit Namen organisieren 175 sal_Bool CanInsertRefMark( const String& rStr ); 176 177 178 // Zugriff ueber ResId auf Feldtypen 179 sal_uInt16 GetFldTypeCount(sal_uInt16 nResId = USHRT_MAX) const; 180 SwFieldType* GetFldType(sal_uInt16 nResId, sal_uInt16 nId = 0) const; 181 SwFieldType* GetFldType(sal_uInt16 nResId, const String& rName) const; 182 183 void RemoveFldType(sal_uInt16 nResId, const String& rName); 184 185 // Zugriff ueber TypeId aus dem Dialog 186 // Ids fuer einen Bereich von Feldern 187 const SwFldGroupRgn& GetGroupRange(sal_Bool bHtmlMode, sal_uInt16 nGrpId) const; 188 sal_uInt16 GetGroup(sal_Bool bHtmlMode, sal_uInt16 nTypeId, sal_uInt16 nSubType = 0) const; 189 190 // TypeId des aktuellen Feldes 191 sal_uInt16 GetCurTypeId() const; 192 193 // TypeId fuer einen konkrete Pos in der Liste 194 static sal_uInt16 GetTypeId(sal_uInt16 nPos); 195 // Name des Typen in der Liste der Felder 196 static const String& GetTypeStr(sal_uInt16 nPos); 197 198 // Pos in der Liste der Felder 199 static sal_uInt16 GetPos(sal_uInt16 nTypeId); 200 201 // Untertypen zu einem Typ 202 sal_Bool GetSubTypes(sal_uInt16 nId, SvStringsDtor& rToFill); 203 204 // Formate zu einem Typ 205 sal_uInt16 GetFormatCount(sal_uInt16 nTypeId, sal_Bool bIsText, sal_Bool bHtmlMode = sal_False) const; 206 String GetFormatStr(sal_uInt16 nTypeId, sal_uLong nFormatId) const; 207 sal_uInt16 GetFormatId(sal_uInt16 nTypeId, sal_uLong nFormatId) const; 208 sal_uLong GetDefaultFormat(sal_uInt16 nTypeId, sal_Bool bIsText, SvNumberFormatter* pFormatter, double* pVal = 0L); 209 210 // Evaluierung der ExpressionFelder ausschalten fuer das Einfuegen 211 // vieler Expressionfelder (siehe Etiketten) 212 // 213 inline void SetEvalExpFlds(sal_Bool bEval); 214 void EvalExpFlds(SwWrtShell* pSh = NULL); 215 }; 216 217 inline void SwFldMgr::SetEvalExpFlds(sal_Bool bEval) 218 { bEvalExp = bEval; } 219 220 inline const String& SwFldMgr::GetCurFldPar1() const 221 { return aCurPar1; } 222 223 inline const String& SwFldMgr::GetCurFldPar2() const 224 { return aCurPar2; } 225 226 inline sal_uLong SwFldMgr::GetCurFldFmt() const 227 { return nCurFmt; } 228 229 230 #endif 231 232