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