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 28 #ifndef _LOCALIZATIONMGR_HXX 29 #define _LOCALIZATIONMGR_HXX 30 31 #include <com/sun/star/resource/XStringResourceManager.hpp> 32 #include <com/sun/star/container/XNameContainer.hpp> 33 34 #include "scriptdocument.hxx" 35 36 class BasicIDEShell; 37 class DlgEditor; 38 39 class LocalizationMgr 40 { 41 ::com::sun::star::uno::Reference 42 < ::com::sun::star::resource::XStringResourceManager > m_xStringResourceManager; 43 44 BasicIDEShell* m_pIDEShell; 45 46 ScriptDocument m_aDocument; 47 String m_aLibName; 48 49 ::com::sun::star::lang::Locale m_aLocaleBeforeBasicStart; 50 51 enum HandleResourceMode 52 { 53 SET_IDS, 54 RESET_IDS, 55 RENAME_DIALOG_IDS, 56 RENAME_CONTROL_IDS, 57 REMOVE_IDS_FROM_RESOURCE, 58 MOVE_RESOURCES, 59 COPY_RESOURCES 60 }; 61 static sal_Int32 implHandleControlResourceProperties( ::com::sun::star::uno::Any aControlAny, 62 const ::rtl::OUString& aDialogName, const ::rtl::OUString& aCtrlName, 63 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > 64 xStringResourceManager, ::com::sun::star::uno::Reference< ::com::sun::star::resource:: 65 XStringResourceResolver > xSourceStringResolver, HandleResourceMode eMode ); 66 67 void enableResourceForAllLibraryDialogs( void ) 68 { 69 implEnableDisableResourceForAllLibraryDialogs( SET_IDS ); 70 } 71 void disableResourceForAllLibraryDialogs( void ) 72 { 73 implEnableDisableResourceForAllLibraryDialogs( RESET_IDS ); 74 } 75 void implEnableDisableResourceForAllLibraryDialogs( HandleResourceMode eMode ); 76 77 public: 78 LocalizationMgr( BasicIDEShell* pIDEShell, const ScriptDocument& rDocument, String aLibName, 79 const ::com::sun::star::uno::Reference 80 < ::com::sun::star::resource::XStringResourceManager >& xStringResourceManager ); 81 ::com::sun::star::uno::Reference 82 < ::com::sun::star::resource::XStringResourceManager >getStringResourceManager( void ) 83 { 84 return m_xStringResourceManager; 85 } 86 87 bool isLibraryLocalized( void ); 88 89 void handleTranslationbar( void ); 90 91 void handleAddLocales( ::com::sun::star::uno::Sequence 92 < ::com::sun::star::lang::Locale > aLocaleSeq ); 93 94 void handleRemoveLocales( ::com::sun::star::uno::Sequence 95 < ::com::sun::star::lang::Locale > aLocaleSeq ); 96 97 void handleSetDefaultLocale( ::com::sun::star::lang::Locale aLocale ); 98 99 void handleSetCurrentLocale( ::com::sun::star::lang::Locale aLocale ); 100 101 void handleBasicStarted( void ); 102 103 void handleBasicStopped( void ); 104 105 static void setControlResourceIDsForNewEditorObject( DlgEditor* pEditor, 106 ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName ); 107 108 static void renameControlResourceIDsForEditorObject( DlgEditor* pEditor, 109 ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aNewCtrlName ); 110 111 static void deleteControlResourceIDsForDeletedEditorObject( DlgEditor* pEditor, 112 ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName ); 113 114 static void setStringResourceAtDialog( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName, 115 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel ); 116 117 static void renameStringResourceIDs( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName, 118 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel ); 119 120 static void removeResourceForDialog( const ScriptDocument& rDocument, const String& aLibName, const String& aDlgName, 121 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel ); 122 123 static ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > 124 getStringResourceFromDialogLibrary( ::com::sun::star::uno::Reference 125 < ::com::sun::star::container::XNameContainer > xDialogLib ); 126 127 // Clipboard / Drag & Drop 128 static void resetResourceForDialog( 129 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel, 130 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager ); 131 132 static void setResourceIDsForDialog( 133 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel, 134 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager ); 135 136 static void copyResourcesForPastedEditorObject( DlgEditor* pEditor, 137 ::com::sun::star::uno::Any aControlAny, const ::rtl::OUString& aCtrlName, 138 ::com::sun::star::uno::Reference< ::com::sun::star::resource:: 139 XStringResourceResolver > xSourceStringResolver ); 140 141 static void copyResourceForDroppedDialog( 142 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > xDialogModel, 143 const ::rtl::OUString& aDialogName, 144 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceManager > xStringResourceManager, 145 ::com::sun::star::uno::Reference< ::com::sun::star::resource::XStringResourceResolver > xSourceStringResolver ); 146 147 static void copyResourceForDialog( 148 const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& xDialogModel, 149 const ::com::sun::star::uno::Reference< ::com::sun::star::resource:: 150 XStringResourceResolver >& xSourceStringResolver, 151 const ::com::sun::star::uno::Reference< ::com::sun::star::resource:: 152 XStringResourceManager >& xTargetStringResourceManager ); 153 }; 154 155 #endif 156