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 _SFX_OBJFAC_HXX 24 #define _SFX_OBJFAC_HXX 25 26 #include "sal/config.h" 27 #include "sfx2/dllapi.h" 28 #include <sal/types.h> 29 #include <tools/solar.h> 30 #include <tools/rtti.hxx> 31 32 // SFX_IMPL_MODULE_LIB 33 #include <vos/module.hxx> 34 #include <rtl/ustring.hxx> 35 36 #include <sfx2/objsh.hxx> 37 #include <sfx2/sfxdefs.hxx> 38 39 class SfxObjectFactoryArr_Impl; 40 class SfxMedium; 41 class SfxFilter; 42 class SfxViewFactory; 43 struct SfxObjectFactory_Impl; 44 class SfxFilterContainer; 45 class SfxBindings; 46 47 //==================================================================== 48 49 typedef void (*SfxVoidFunc)(); 50 51 #define SDT_SDT_DOCFACTPRIO 10 // Explorer 52 #define SDT_SW_DOCFACTPRIO 20 // Text-Dokument 53 #define SDT_SWW_DOCFACTPRIO 21 // Web-Dokument 54 #define SDT_SC_DOCFACTPRIO 30 // Tabellen-Dokument 55 #define SDT_SI_DOCFACTPRIO 40 // Impress-Dokument 56 #define SDT_SD_DOCFACTPRIO 41 // Draw-Dokument 57 #define SDT_SCH_DOCFACTPRIO 50 // Chart-Dokument 58 #define SDT_SMA_DOCFACTPRIO 60 // Math-Dokument 59 #define SDT_SIM_DOCFACTPRIO 70 // Image-Dokument 60 #define SDT_FRM_DOCFACTPRIO 100 // Rahmen-Dokument 61 #define SDT_MSG_DOCFACTPRIO 110 // Nachrichten-Dokument 62 #define SDT_SDB_DOCFACTPRIO 200 // Datenbank-Dokument 63 64 //==================================================================== 65 66 class SFX2_DLLPUBLIC SfxObjectFactory 67 { 68 private: 69 const char* pShortName; // Objekt-Kurzname 70 SfxObjectFactory_Impl* pImpl; // Zusatzdaten 71 SfxObjectShellFlags nFlags; 72 SAL_DLLPRIVATE void Construct(); 73 74 public: 75 SfxObjectFactory( const SvGlobalName &rName, SfxObjectShellFlags nFlags, const char* pShortName ); 76 ~SfxObjectFactory(); 77 78 const SvGlobalName& GetClassId() const; GetFlags()79 SfxObjectShellFlags GetFlags() { return nFlags; } GetShortName() const80 const char* GetShortName() const { return pShortName; } 81 String GetFactoryURL() const; // shortcut for "private:factory/GetShortName()" GetFactoryName() const82 String GetFactoryName() const { return String::CreateFromAscii( pShortName ); } 83 String GetModuleName() const; 84 void SetDocumentTypeNameResource( const ResId& rId ); 85 String GetDocumentTypeName() const; 86 SfxFilterContainer *GetFilterContainer( sal_Bool bForceLoad = sal_True) const; 87 88 // Views 89 void RegisterViewFactory(SfxViewFactory &rFactory); 90 sal_uInt16 GetViewFactoryCount() const; 91 SfxViewFactory& GetViewFactory(sal_uInt16 i = 0) const; 92 93 /// returns the view factory whose GetAPIViewName or GetLegacyViewName delivers the requested logical name 94 SfxViewFactory* GetViewFactoryByViewName( const String& i_rViewName ) const; 95 96 // Filter 97 const SfxFilter* GetTemplateFilter() const; 98 static String GetStandardTemplate( const String& rServiceName ); 99 static void SetStandardTemplate( const String& rServiceName, const String& rTemplateName ); 100 static void SetSystemTemplate( const String& rServiceName, const String& rTemplateName ); 101 102 void SetDocumentServiceName( const rtl::OUString& rServiceName ); 103 const rtl::OUString& GetDocumentServiceName() const; 104 105 SfxModule* GetModule() const; 106 107 //#if 0 // _SOLAR__PRIVATE 108 SAL_DLLPRIVATE void SetModule_Impl( SfxModule* ); 109 SAL_DLLPRIVATE static void UpdateFilterContainers_Impl(); 110 SAL_DLLPRIVATE sal_uInt16 GetViewNo_Impl( const sal_uInt16 i_nViewId, const sal_uInt16 i_nFallback ) const; 111 //#endif 112 113 private: 114 // Kopieren verboten 115 SAL_DLLPRIVATE SfxObjectFactory(const SfxObjectFactory&); 116 SAL_DLLPRIVATE const SfxObjectFactory& operator=(const SfxObjectFactory &); 117 }; 118 119 //========================================================================= 120 121 #define SFX_DECL_OBJECTFACTORY() \ 122 private: \ 123 static SfxObjectFactory* pObjectFactory; \ 124 public: \ 125 static SfxObjectFactory& Factory(); \ 126 virtual SfxObjectFactory& GetFactory() const { return Factory(); } 127 128 #define SFX_IMPL_OBJECTFACTORY(ClassName,GlobName,Flags,ShortName) \ 129 SfxObjectFactory* ClassName::pObjectFactory = 0; \ 130 SfxObjectFactory& ClassName::Factory() \ 131 { if (!pObjectFactory) \ 132 pObjectFactory = \ 133 new SfxObjectFactory( GlobName, Flags, ShortName ); \ 134 return *pObjectFactory; \ 135 } 136 #endif // #ifndef _SFX_OBJFAC_HXX 137 138