1*353d8f4dSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*353d8f4dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*353d8f4dSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*353d8f4dSAndrew Rist * distributed with this work for additional information 6*353d8f4dSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*353d8f4dSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*353d8f4dSAndrew Rist * "License"); you may not use this file except in compliance 9*353d8f4dSAndrew Rist * with the License. You may obtain a copy of the License at 10*353d8f4dSAndrew Rist * 11*353d8f4dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*353d8f4dSAndrew Rist * 13*353d8f4dSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*353d8f4dSAndrew Rist * software distributed under the License is distributed on an 15*353d8f4dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*353d8f4dSAndrew Rist * KIND, either express or implied. See the License for the 17*353d8f4dSAndrew Rist * specific language governing permissions and limitations 18*353d8f4dSAndrew Rist * under the License. 19*353d8f4dSAndrew Rist * 20*353d8f4dSAndrew Rist *************************************************************/ 21*353d8f4dSAndrew Rist 22*353d8f4dSAndrew Rist 23cdf0e10cSrcweir #ifndef _SFXDOCTEMPL_HXX 24cdf0e10cSrcweir #define _SFXDOCTEMPL_HXX 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "sal/config.h" 27cdf0e10cSrcweir #include "sfx2/dllapi.h" 28cdf0e10cSrcweir #include "sal/types.h" 29cdf0e10cSrcweir #include <tools/ref.hxx> 30cdf0e10cSrcweir #include <tools/string.hxx> 31cdf0e10cSrcweir 32cdf0e10cSrcweir // CLASS ----------------------------------------------------------------- 33cdf0e10cSrcweir 34cdf0e10cSrcweir class SfxObjectShell; 35cdf0e10cSrcweir 36cdf0e10cSrcweir #ifndef SFX_DECL_OBJECTSHELL_DEFINED 37cdf0e10cSrcweir #define SFX_DECL_OBJECTSHELL_DEFINED 38cdf0e10cSrcweir SV_DECL_REF(SfxObjectShell) 39cdf0e10cSrcweir #endif 40cdf0e10cSrcweir 41cdf0e10cSrcweir class SfxDocTemplate_Impl; 42cdf0e10cSrcweir 43cdf0e10cSrcweir #ifndef SFX_DECL_DOCTEMPLATES_DEFINED 44cdf0e10cSrcweir #define SFX_DECL_DOCTEMPLATES_DEFINED 45cdf0e10cSrcweir SV_DECL_REF(SfxDocTemplate_Impl) 46cdf0e10cSrcweir #endif 47cdf0e10cSrcweir 48cdf0e10cSrcweir // class SfxDocumentTemplates -------------------------------------------- 49cdf0e10cSrcweir 50cdf0e10cSrcweir class SFX2_DLLPUBLIC SfxDocumentTemplates 51cdf0e10cSrcweir { 52cdf0e10cSrcweir private: 53cdf0e10cSrcweir SfxDocTemplate_ImplRef pImp; 54cdf0e10cSrcweir 55cdf0e10cSrcweir SAL_DLLPRIVATE sal_Bool CopyOrMove( sal_uInt16 nTargetRegion, sal_uInt16 nTargetIdx, 56cdf0e10cSrcweir sal_uInt16 nSourceRegion, sal_uInt16 nSourceIdx, sal_Bool bMove ); 57cdf0e10cSrcweir public: 58cdf0e10cSrcweir SfxDocumentTemplates(); 59cdf0e10cSrcweir SfxDocumentTemplates(const SfxDocumentTemplates &); 60cdf0e10cSrcweir ~SfxDocumentTemplates(); 61cdf0e10cSrcweir IsConstructed()62cdf0e10cSrcweir sal_Bool IsConstructed() { return pImp != NULL; } 63cdf0e10cSrcweir void Construct(); 64cdf0e10cSrcweir 65cdf0e10cSrcweir static sal_Bool SaveDir( /*SfxTemplateDir &rEntry */ ) ; 66cdf0e10cSrcweir const SfxDocumentTemplates &operator=(const SfxDocumentTemplates &); 67cdf0e10cSrcweir 68cdf0e10cSrcweir sal_Bool Rescan( ); // Aktualisieren 69cdf0e10cSrcweir void ReInitFromComponent(); 70cdf0e10cSrcweir 71cdf0e10cSrcweir sal_Bool IsRegionLoaded( sal_uInt16 nIdx ) const; 72cdf0e10cSrcweir sal_uInt16 GetRegionCount() const; 73cdf0e10cSrcweir const String& GetRegionName(sal_uInt16 nIdx) const; //dv! 74cdf0e10cSrcweir String GetFullRegionName(sal_uInt16 nIdx) const; 75cdf0e10cSrcweir sal_uInt16 GetRegionNo( const String &rRegionName ) const; 76cdf0e10cSrcweir 77cdf0e10cSrcweir sal_uInt16 GetCount(sal_uInt16 nRegion) const; 78cdf0e10cSrcweir sal_uInt16 GetCount( const String &rName) const; 79cdf0e10cSrcweir const String& GetName(sal_uInt16 nRegion, sal_uInt16 nIdx) const; //dv! 80cdf0e10cSrcweir String GetFileName(sal_uInt16 nRegion, sal_uInt16 nIdx) const; 81cdf0e10cSrcweir String GetPath(sal_uInt16 nRegion, sal_uInt16 nIdx) const; 82cdf0e10cSrcweir 83cdf0e10cSrcweir String GetDefaultTemplatePath(const String &rLongName); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // Pfad zur Vorlage geben lassen; logischer Name muss angegeben 86cdf0e10cSrcweir // werden, damit beim Ueberschreiben einer Vorlage der 87cdf0e10cSrcweir // richtige Dateiname gefunden werden kann 88cdf0e10cSrcweir String GetTemplatePath(sal_uInt16 nRegion, const String &rLongName) const; 89cdf0e10cSrcweir 90cdf0e10cSrcweir // Allows to retrieve the target template URL from the UCB 91cdf0e10cSrcweir ::rtl::OUString GetTemplateTargetURLFromComponent( const ::rtl::OUString& aGroupName, 92cdf0e10cSrcweir const ::rtl::OUString& aTitle ); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // Speichern als Vorlage hat geklappt -> Aktualisieren 95cdf0e10cSrcweir void NewTemplate(sal_uInt16 nRegion, 96cdf0e10cSrcweir const String &rLongName, 97cdf0e10cSrcweir const String &rFileName); 98cdf0e10cSrcweir 99cdf0e10cSrcweir sal_Bool Copy(sal_uInt16 nTargetRegion, 100cdf0e10cSrcweir sal_uInt16 nTargetIdx, 101cdf0e10cSrcweir sal_uInt16 nSourceRegion, 102cdf0e10cSrcweir sal_uInt16 nSourceIdx); 103cdf0e10cSrcweir sal_Bool Move(sal_uInt16 nTargetRegion, 104cdf0e10cSrcweir sal_uInt16 nTargetIdx, 105cdf0e10cSrcweir sal_uInt16 nSourceRegion, 106cdf0e10cSrcweir sal_uInt16 nSourceIdx); 107cdf0e10cSrcweir sal_Bool Delete(sal_uInt16 nRegion, sal_uInt16 nIdx); 108cdf0e10cSrcweir sal_Bool InsertDir(const String &rText, sal_uInt16 nRegion); 109cdf0e10cSrcweir sal_Bool SetName(const String &rName, sal_uInt16 nRegion, sal_uInt16 nIdx); 110cdf0e10cSrcweir 111cdf0e10cSrcweir sal_Bool CopyTo(sal_uInt16 nRegion, sal_uInt16 nIdx, const String &rName) const; 112cdf0e10cSrcweir sal_Bool CopyFrom(sal_uInt16 nRegion, sal_uInt16 nIdx, String &rName); 113cdf0e10cSrcweir 114cdf0e10cSrcweir SfxObjectShellRef CreateObjectShell(sal_uInt16 nRegion, sal_uInt16 nIdx); 115cdf0e10cSrcweir sal_Bool DeleteObjectShell(sal_uInt16, sal_uInt16); 116cdf0e10cSrcweir 117cdf0e10cSrcweir sal_Bool GetFull( const String& rRegion, const String& rName, String& rPath ); 118cdf0e10cSrcweir sal_Bool GetLogicNames( const String& rPath, String& rRegion, String& rName ) const; 119cdf0e10cSrcweir 120cdf0e10cSrcweir /** updates the configuration where the document templates structure is stored. 121cdf0e10cSrcweir 122cdf0e10cSrcweir <p>The info about the document templates (which files, which groups etc.) is stored in the 123cdf0e10cSrcweir configuration. This means that just by copying files into OOo's template directories, this 124cdf0e10cSrcweir change is not reflected in the SfxDocumentTemplates - 'cause the configuration is not synchronous with 125cdf0e10cSrcweir the file system. This can be enforced with this method.</p> 126cdf0e10cSrcweir 127cdf0e10cSrcweir @param _bSmart 128cdf0e10cSrcweir The update of the configuration is rather expensive - nothing you want to do regulary if you don't really 129cdf0e10cSrcweir need it. So you have the possibility to do a smart update - it first checks if the update if necessary. 130cdf0e10cSrcweir In case the update is needed, the additional check made it somewhat more expensive. In case it's not 131cdf0e10cSrcweir necessary (which should be the usual case), the check alone is (much) less expensive than the real update. 132cdf0e10cSrcweir <br/> 133cdf0e10cSrcweir So set <arg>_bSmart</arg> to <TRUE/> to do a check for necessity first. 134cdf0e10cSrcweir */ 135cdf0e10cSrcweir void Update( sal_Bool _bSmart = sal_True ); 136cdf0e10cSrcweir 137cdf0e10cSrcweir // allows to detect whether it is allowed to delete ( at least partially ) 138cdf0e10cSrcweir // a group or a template, or to edit a template 139cdf0e10cSrcweir sal_Bool HasUserContents( sal_uInt16 nRegion, sal_uInt16 nIdx ) const; 140cdf0e10cSrcweir }; 141cdf0e10cSrcweir 142cdf0e10cSrcweir #endif // #ifndef _SFXDOCTEMPL_HXX 143cdf0e10cSrcweir 144cdf0e10cSrcweir 145