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