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