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