xref: /AOO41X/main/framework/source/uiconfiguration/moduleuiconfigurationmanager.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_framework.hxx"
30*cdf0e10cSrcweir #include <uiconfiguration/moduleuiconfigurationmanager.hxx>
31*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
32*cdf0e10cSrcweir #include <services.h>
33*cdf0e10cSrcweir #include <uielement/constitemcontainer.hxx>
34*cdf0e10cSrcweir #include <uielement/rootitemcontainer.hxx>
35*cdf0e10cSrcweir #include <uielement/uielementtypenames.hxx>
36*cdf0e10cSrcweir #include <framework/menuconfiguration.hxx>
37*cdf0e10cSrcweir #include <framework/toolboxconfiguration.hxx>
38*cdf0e10cSrcweir 
39*cdf0e10cSrcweir #ifndef __FRAMEWORK_XML_STATUSBARCONFIGURATION_HXX_
40*cdf0e10cSrcweir #include <framework/statusbarconfiguration.hxx>
41*cdf0e10cSrcweir #endif
42*cdf0e10cSrcweir 
43*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
44*cdf0e10cSrcweir //	interface includes
45*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
46*cdf0e10cSrcweir #include <com/sun/star/ui/UIElementType.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/ui/ConfigurationEvent.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/lang/DisposedException.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
50*cdf0e10cSrcweir #include <com/sun/star/embed/ElementModes.hpp>
51*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
52*cdf0e10cSrcweir #include <com/sun/star/io/XStream.hpp>
53*cdf0e10cSrcweir 
54*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
55*cdf0e10cSrcweir //	other includes
56*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir #include <vcl/svapp.hxx>
59*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
60*cdf0e10cSrcweir #include <comphelper/sequenceashashmap.hxx>
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
63*cdf0e10cSrcweir //	namespaces
64*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
65*cdf0e10cSrcweir 
66*cdf0e10cSrcweir using rtl::OUString;
67*cdf0e10cSrcweir using namespace com::sun::star::uno;
68*cdf0e10cSrcweir using namespace com::sun::star::io;
69*cdf0e10cSrcweir using namespace com::sun::star::embed;
70*cdf0e10cSrcweir using namespace com::sun::star::lang;
71*cdf0e10cSrcweir using namespace com::sun::star::container;
72*cdf0e10cSrcweir using namespace com::sun::star::beans;
73*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
74*cdf0e10cSrcweir 
75*cdf0e10cSrcweir namespace framework
76*cdf0e10cSrcweir {
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir //*****************************************************************************************************************
79*cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
80*cdf0e10cSrcweir //*****************************************************************************************************************
81*cdf0e10cSrcweir DEFINE_XINTERFACE_8                    (    ModuleUIConfigurationManager                                                    ,
82*cdf0e10cSrcweir                                             OWeakObject                                                                     ,
83*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XTypeProvider                                      ),
84*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XServiceInfo                                       ),
85*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XComponent                                         ),
86*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XInitialization                                    ),
87*cdf0e10cSrcweir 											DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfiguration                  ),
88*cdf0e10cSrcweir                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationManager           ),
89*cdf0e10cSrcweir 											DIRECT_INTERFACE( ::com::sun::star::ui::XModuleUIConfigurationManager     ),
90*cdf0e10cSrcweir                                             DIRECT_INTERFACE( ::com::sun::star::ui::XUIConfigurationPersistence       )
91*cdf0e10cSrcweir 										)
92*cdf0e10cSrcweir 
93*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_8                  (   ModuleUIConfigurationManager                                ,
94*cdf0e10cSrcweir                                             css::lang::XTypeProvider			                        ,
95*cdf0e10cSrcweir                                             css::lang::XServiceInfo				                        ,
96*cdf0e10cSrcweir                                             css::lang::XComponent                                       ,
97*cdf0e10cSrcweir                                             css::lang::XInitialization                                  ,
98*cdf0e10cSrcweir                                             ::com::sun::star::ui::XUIConfiguration                ,
99*cdf0e10cSrcweir 											::com::sun::star::ui::XUIConfigurationManager         ,
100*cdf0e10cSrcweir                                             ::com::sun::star::ui::XModuleUIConfigurationManager   ,
101*cdf0e10cSrcweir                                             ::com::sun::star::ui::XUIConfigurationPersistence
102*cdf0e10cSrcweir 										)
103*cdf0e10cSrcweir 
104*cdf0e10cSrcweir DEFINE_XSERVICEINFO_MULTISERVICE        (   ModuleUIConfigurationManager                    ,
105*cdf0e10cSrcweir                                             ::cppu::OWeakObject                             ,
106*cdf0e10cSrcweir                                             SERVICENAME_MODULEUICONFIGURATIONMANAGER	    ,
107*cdf0e10cSrcweir 											IMPLEMENTATIONNAME_MODULEUICONFIGURATIONMANAGER
108*cdf0e10cSrcweir 										)
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   ModuleUIConfigurationManager, {} )
111*cdf0e10cSrcweir 
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir // important: The order and position of the elements must match the constant
114*cdf0e10cSrcweir // definition of "::com::sun::star::ui::UIElementType"
115*cdf0e10cSrcweir static const char* UIELEMENTTYPENAMES[] =
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir     "",  // Dummy value for unknown!
118*cdf0e10cSrcweir     UIELEMENTTYPE_MENUBAR_NAME,
119*cdf0e10cSrcweir     UIELEMENTTYPE_POPUPMENU_NAME,
120*cdf0e10cSrcweir     UIELEMENTTYPE_TOOLBAR_NAME,
121*cdf0e10cSrcweir     UIELEMENTTYPE_STATUSBAR_NAME,
122*cdf0e10cSrcweir     UIELEMENTTYPE_FLOATINGWINDOW_NAME,
123*cdf0e10cSrcweir     UIELEMENTTYPE_PROGRESSBAR_NAME,
124*cdf0e10cSrcweir     UIELEMENTTYPE_TOOLPANEL_NAME
125*cdf0e10cSrcweir };
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir static const char       RESOURCEURL_PREFIX[] = "private:resource/";
128*cdf0e10cSrcweir static const sal_Int32  RESOURCEURL_PREFIX_SIZE = 17;
129*cdf0e10cSrcweir static const char       RESOURCEURL_CUSTOM_ELEMENT[] = "custom_";
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir static sal_Int16 RetrieveTypeFromResourceURL( const rtl::OUString& aResourceURL )
132*cdf0e10cSrcweir {
133*cdf0e10cSrcweir 
134*cdf0e10cSrcweir     if (( aResourceURL.indexOf( OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) &&
135*cdf0e10cSrcweir         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
136*cdf0e10cSrcweir     {
137*cdf0e10cSrcweir         OUString    aTmpStr     = aResourceURL.copy( RESOURCEURL_PREFIX_SIZE );
138*cdf0e10cSrcweir         sal_Int32   nIndex      = aTmpStr.indexOf( '/' );
139*cdf0e10cSrcweir         if (( nIndex > 0 ) &&  ( aTmpStr.getLength() > nIndex ))
140*cdf0e10cSrcweir         {
141*cdf0e10cSrcweir             OUString aTypeStr( aTmpStr.copy( 0, nIndex ));
142*cdf0e10cSrcweir             for ( int i = 0; i < UIElementType::COUNT; i++ )
143*cdf0e10cSrcweir             {
144*cdf0e10cSrcweir                 if ( aTypeStr.equalsAscii( UIELEMENTTYPENAMES[i] ))
145*cdf0e10cSrcweir                     return sal_Int16( i );
146*cdf0e10cSrcweir             }
147*cdf0e10cSrcweir         }
148*cdf0e10cSrcweir     }
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir     return UIElementType::UNKNOWN;
151*cdf0e10cSrcweir }
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir static OUString RetrieveNameFromResourceURL( const rtl::OUString& aResourceURL )
154*cdf0e10cSrcweir {
155*cdf0e10cSrcweir     if (( aResourceURL.indexOf( OUString( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_PREFIX ))) == 0 ) &&
156*cdf0e10cSrcweir         ( aResourceURL.getLength() > RESOURCEURL_PREFIX_SIZE ))
157*cdf0e10cSrcweir     {
158*cdf0e10cSrcweir         sal_Int32 nIndex = aResourceURL.lastIndexOf( '/' );
159*cdf0e10cSrcweir         if (( nIndex > 0 ) && (( nIndex+1 ) < aResourceURL.getLength()))
160*cdf0e10cSrcweir             return aResourceURL.copy( nIndex+1 );
161*cdf0e10cSrcweir     }
162*cdf0e10cSrcweir 
163*cdf0e10cSrcweir     return OUString();
164*cdf0e10cSrcweir }
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType )
167*cdf0e10cSrcweir {
168*cdf0e10cSrcweir     // preload list of element types on demand
169*cdf0e10cSrcweir     impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
170*cdf0e10cSrcweir     impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir     UIElementDataHashMap& rUserElements = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
173*cdf0e10cSrcweir     UIElementDataHashMap::const_iterator pUserIter = rUserElements.begin();
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     OUString aCustomUrlPrefix( RTL_CONSTASCII_USTRINGPARAM( RESOURCEURL_CUSTOM_ELEMENT ));
176*cdf0e10cSrcweir     while ( pUserIter != rUserElements.end() )
177*cdf0e10cSrcweir     {
178*cdf0e10cSrcweir         sal_Int32 nIndex = pUserIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
179*cdf0e10cSrcweir         if ( nIndex > RESOURCEURL_PREFIX_SIZE )
180*cdf0e10cSrcweir         {
181*cdf0e10cSrcweir             // Performance: Retrieve user interface name only for custom user interface elements.
182*cdf0e10cSrcweir             // It's only used by them!
183*cdf0e10cSrcweir             UIElementData* pDataSettings = impl_findUIElementData( pUserIter->second.aResourceURL, nElementType );
184*cdf0e10cSrcweir             if ( pDataSettings )
185*cdf0e10cSrcweir             {
186*cdf0e10cSrcweir                 // Retrieve user interface name from XPropertySet interface
187*cdf0e10cSrcweir                 rtl::OUString aUIName;
188*cdf0e10cSrcweir                 Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
189*cdf0e10cSrcweir                 if ( xPropSet.is() )
190*cdf0e10cSrcweir                 {
191*cdf0e10cSrcweir                     Any a = xPropSet->getPropertyValue( m_aPropUIName );
192*cdf0e10cSrcweir                     a >>= aUIName;
193*cdf0e10cSrcweir                 }
194*cdf0e10cSrcweir 
195*cdf0e10cSrcweir                 UIElementInfo aInfo( pUserIter->second.aResourceURL, aUIName );
196*cdf0e10cSrcweir                 aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
197*cdf0e10cSrcweir             }
198*cdf0e10cSrcweir         }
199*cdf0e10cSrcweir         else
200*cdf0e10cSrcweir         {
201*cdf0e10cSrcweir             // The user interface name for standard user interface elements is stored in the WindowState.xcu file
202*cdf0e10cSrcweir             UIElementInfo aInfo( pUserIter->second.aResourceURL, OUString() );
203*cdf0e10cSrcweir             aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pUserIter->second.aResourceURL, aInfo ));
204*cdf0e10cSrcweir         }
205*cdf0e10cSrcweir         ++pUserIter;
206*cdf0e10cSrcweir     }
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir     UIElementDataHashMap& rDefaultElements = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
209*cdf0e10cSrcweir     UIElementDataHashMap::const_iterator pDefIter = rDefaultElements.begin();
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     while ( pDefIter != rDefaultElements.end() )
212*cdf0e10cSrcweir     {
213*cdf0e10cSrcweir         UIElementInfoHashMap::const_iterator pIterInfo = aUIElementInfoCollection.find( pDefIter->second.aResourceURL );
214*cdf0e10cSrcweir         if ( pIterInfo == aUIElementInfoCollection.end() )
215*cdf0e10cSrcweir         {
216*cdf0e10cSrcweir             sal_Int32 nIndex = pDefIter->second.aResourceURL.indexOf( aCustomUrlPrefix, RESOURCEURL_PREFIX_SIZE );
217*cdf0e10cSrcweir             if ( nIndex > RESOURCEURL_PREFIX_SIZE )
218*cdf0e10cSrcweir             {
219*cdf0e10cSrcweir                 // Performance: Retrieve user interface name only for custom user interface elements.
220*cdf0e10cSrcweir                 // It's only used by them!
221*cdf0e10cSrcweir                 UIElementData* pDataSettings = impl_findUIElementData( pDefIter->second.aResourceURL, nElementType );
222*cdf0e10cSrcweir                 if ( pDataSettings )
223*cdf0e10cSrcweir                 {
224*cdf0e10cSrcweir                     // Retrieve user interface name from XPropertySet interface
225*cdf0e10cSrcweir                     rtl::OUString aUIName;
226*cdf0e10cSrcweir                     Reference< XPropertySet > xPropSet( pDataSettings->xSettings, UNO_QUERY );
227*cdf0e10cSrcweir                     if ( xPropSet.is() )
228*cdf0e10cSrcweir                     {
229*cdf0e10cSrcweir                         Any a = xPropSet->getPropertyValue( m_aPropUIName );
230*cdf0e10cSrcweir                         a >>= aUIName;
231*cdf0e10cSrcweir                     }
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir                     UIElementInfo aInfo( pDefIter->second.aResourceURL, aUIName );
234*cdf0e10cSrcweir                     aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
235*cdf0e10cSrcweir                 }
236*cdf0e10cSrcweir             }
237*cdf0e10cSrcweir             else
238*cdf0e10cSrcweir             {
239*cdf0e10cSrcweir                 // The user interface name for standard user interface elements is stored in the WindowState.xcu file
240*cdf0e10cSrcweir                 UIElementInfo aInfo( pDefIter->second.aResourceURL, OUString() );
241*cdf0e10cSrcweir                 aUIElementInfoCollection.insert( UIElementInfoHashMap::value_type( pDefIter->second.aResourceURL, aInfo ));
242*cdf0e10cSrcweir             }
243*cdf0e10cSrcweir         }
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir         ++pDefIter;
246*cdf0e10cSrcweir     }
247*cdf0e10cSrcweir }
248*cdf0e10cSrcweir 
249*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_preloadUIElementTypeList( Layer eLayer, sal_Int16 nElementType )
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir     if ( !rElementTypeData.bLoaded )
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
256*cdf0e10cSrcweir         if ( xElementTypeStorage.is() )
257*cdf0e10cSrcweir         {
258*cdf0e10cSrcweir             rtl::OUStringBuffer aBuf( RESOURCEURL_PREFIX_SIZE );
259*cdf0e10cSrcweir             aBuf.appendAscii( RESOURCEURL_PREFIX );
260*cdf0e10cSrcweir             aBuf.appendAscii( UIELEMENTTYPENAMES[ nElementType ] );
261*cdf0e10cSrcweir             aBuf.appendAscii( "/" );
262*cdf0e10cSrcweir             OUString aResURLPrefix( aBuf.makeStringAndClear() );
263*cdf0e10cSrcweir 
264*cdf0e10cSrcweir             UIElementDataHashMap& rHashMap = rElementTypeData.aElementsHashMap;
265*cdf0e10cSrcweir             Reference< XNameAccess > xNameAccess( xElementTypeStorage, UNO_QUERY );
266*cdf0e10cSrcweir             Sequence< OUString > aUIElementNames = xNameAccess->getElementNames();
267*cdf0e10cSrcweir             for ( sal_Int32 n = 0; n < aUIElementNames.getLength(); n++ )
268*cdf0e10cSrcweir             {
269*cdf0e10cSrcweir                 UIElementData aUIElementData;
270*cdf0e10cSrcweir 
271*cdf0e10cSrcweir                 // Resource name must be without ".xml"
272*cdf0e10cSrcweir                 sal_Int32 nIndex = aUIElementNames[n].lastIndexOf( '.' );
273*cdf0e10cSrcweir                 if (( nIndex > 0 ) && ( nIndex < aUIElementNames[n].getLength() ))
274*cdf0e10cSrcweir                 {
275*cdf0e10cSrcweir                     OUString aExtension( aUIElementNames[n].copy( nIndex+1 ));
276*cdf0e10cSrcweir                     OUString aUIElementName( aUIElementNames[n].copy( 0, nIndex ));
277*cdf0e10cSrcweir 
278*cdf0e10cSrcweir                     if (( aUIElementName.getLength() > 0 ) &&
279*cdf0e10cSrcweir                         ( aExtension.equalsIgnoreAsciiCaseAsciiL( "xml", 3 )))
280*cdf0e10cSrcweir                     {
281*cdf0e10cSrcweir                         aUIElementData.aResourceURL = aResURLPrefix + aUIElementName;
282*cdf0e10cSrcweir                         aUIElementData.aName        = aUIElementNames[n];
283*cdf0e10cSrcweir 
284*cdf0e10cSrcweir                         if ( eLayer == LAYER_USERDEFINED )
285*cdf0e10cSrcweir                         {
286*cdf0e10cSrcweir                             aUIElementData.bModified    = false;
287*cdf0e10cSrcweir                             aUIElementData.bDefault     = false;
288*cdf0e10cSrcweir                             aUIElementData.bDefaultNode = false;
289*cdf0e10cSrcweir                         }
290*cdf0e10cSrcweir 
291*cdf0e10cSrcweir                         // Create hash_map entries for all user interface elements inside the storage. We don't load the
292*cdf0e10cSrcweir                         // settings to speed up the process.
293*cdf0e10cSrcweir                         rHashMap.insert( UIElementDataHashMap::value_type( aUIElementData.aResourceURL, aUIElementData ));
294*cdf0e10cSrcweir                     }
295*cdf0e10cSrcweir                 }
296*cdf0e10cSrcweir 				rElementTypeData.bLoaded = true;
297*cdf0e10cSrcweir             }
298*cdf0e10cSrcweir         }
299*cdf0e10cSrcweir     }
300*cdf0e10cSrcweir 
301*cdf0e10cSrcweir     //rElementTypeData.bLoaded = true;
302*cdf0e10cSrcweir }
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_requestUIElementData( sal_Int16 nElementType, Layer eLayer, UIElementData& aUIElementData )
305*cdf0e10cSrcweir {
306*cdf0e10cSrcweir     UIElementType& rElementTypeData = m_aUIElements[eLayer][nElementType];
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir     Reference< XStorage > xElementTypeStorage = rElementTypeData.xStorage;
309*cdf0e10cSrcweir     if ( xElementTypeStorage.is() && aUIElementData.aName.getLength() )
310*cdf0e10cSrcweir     {
311*cdf0e10cSrcweir         try
312*cdf0e10cSrcweir         {
313*cdf0e10cSrcweir             Reference< XStream > xStream = xElementTypeStorage->openStreamElement( aUIElementData.aName, ElementModes::READ );
314*cdf0e10cSrcweir             Reference< XInputStream > xInputStream = xStream->getInputStream();
315*cdf0e10cSrcweir 
316*cdf0e10cSrcweir             if ( xInputStream.is() )
317*cdf0e10cSrcweir             {
318*cdf0e10cSrcweir                 switch ( nElementType )
319*cdf0e10cSrcweir                 {
320*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::UNKNOWN:
321*cdf0e10cSrcweir                     break;
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::MENUBAR:
324*cdf0e10cSrcweir                     {
325*cdf0e10cSrcweir                         try
326*cdf0e10cSrcweir                         {
327*cdf0e10cSrcweir                             MenuConfiguration aMenuCfg( m_xServiceManager );
328*cdf0e10cSrcweir                             Reference< XIndexAccess > xContainer( aMenuCfg.CreateMenuBarConfigurationFromXML( xInputStream ));
329*cdf0e10cSrcweir                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xContainer );
330*cdf0e10cSrcweir                             if ( pRootItemContainer )
331*cdf0e10cSrcweir                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
332*cdf0e10cSrcweir                             else
333*cdf0e10cSrcweir                                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( xContainer, sal_True ) ), UNO_QUERY );
334*cdf0e10cSrcweir                             return;
335*cdf0e10cSrcweir                         }
336*cdf0e10cSrcweir                         catch ( ::com::sun::star::lang::WrappedTargetException& )
337*cdf0e10cSrcweir                         {
338*cdf0e10cSrcweir                         }
339*cdf0e10cSrcweir                     }
340*cdf0e10cSrcweir                     break;
341*cdf0e10cSrcweir 
342*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::POPUPMENU:
343*cdf0e10cSrcweir                     {
344*cdf0e10cSrcweir                         break;
345*cdf0e10cSrcweir                     }
346*cdf0e10cSrcweir 
347*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::TOOLBAR:
348*cdf0e10cSrcweir                     {
349*cdf0e10cSrcweir                         try
350*cdf0e10cSrcweir                         {
351*cdf0e10cSrcweir                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
352*cdf0e10cSrcweir                             ToolBoxConfiguration::LoadToolBox( m_xServiceManager, xInputStream, xIndexContainer );
353*cdf0e10cSrcweir                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
354*cdf0e10cSrcweir                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
355*cdf0e10cSrcweir                             return;
356*cdf0e10cSrcweir                         }
357*cdf0e10cSrcweir                         catch ( ::com::sun::star::lang::WrappedTargetException& )
358*cdf0e10cSrcweir                         {
359*cdf0e10cSrcweir                         }
360*cdf0e10cSrcweir 
361*cdf0e10cSrcweir                         break;
362*cdf0e10cSrcweir                     }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::STATUSBAR:
365*cdf0e10cSrcweir                     {
366*cdf0e10cSrcweir                         try
367*cdf0e10cSrcweir                         {
368*cdf0e10cSrcweir                             Reference< XIndexContainer > xIndexContainer( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
369*cdf0e10cSrcweir                             StatusBarConfiguration::LoadStatusBar( m_xServiceManager, xInputStream, xIndexContainer );
370*cdf0e10cSrcweir                             RootItemContainer* pRootItemContainer = RootItemContainer::GetImplementation( xIndexContainer );
371*cdf0e10cSrcweir                             aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( pRootItemContainer, sal_True ) ), UNO_QUERY );
372*cdf0e10cSrcweir                             return;
373*cdf0e10cSrcweir                         }
374*cdf0e10cSrcweir                         catch ( ::com::sun::star::lang::WrappedTargetException& )
375*cdf0e10cSrcweir                         {
376*cdf0e10cSrcweir                         }
377*cdf0e10cSrcweir 
378*cdf0e10cSrcweir                         break;
379*cdf0e10cSrcweir                     }
380*cdf0e10cSrcweir 
381*cdf0e10cSrcweir                     case ::com::sun::star::ui::UIElementType::FLOATINGWINDOW:
382*cdf0e10cSrcweir                     {
383*cdf0e10cSrcweir                         break;
384*cdf0e10cSrcweir                     }
385*cdf0e10cSrcweir                 }
386*cdf0e10cSrcweir             }
387*cdf0e10cSrcweir         }
388*cdf0e10cSrcweir         catch ( ::com::sun::star::embed::InvalidStorageException& )
389*cdf0e10cSrcweir         {
390*cdf0e10cSrcweir         }
391*cdf0e10cSrcweir 		catch (	::com::sun::star::lang::IllegalArgumentException& )
392*cdf0e10cSrcweir         {
393*cdf0e10cSrcweir         }
394*cdf0e10cSrcweir         catch ( ::com::sun::star::io::IOException& )
395*cdf0e10cSrcweir         {
396*cdf0e10cSrcweir         }
397*cdf0e10cSrcweir         catch ( ::com::sun::star::embed::StorageWrappedTargetException& )
398*cdf0e10cSrcweir         {
399*cdf0e10cSrcweir         }
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     // At least we provide an empty settings container!
403*cdf0e10cSrcweir     aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer() ), UNO_QUERY );
404*cdf0e10cSrcweir }
405*cdf0e10cSrcweir 
406*cdf0e10cSrcweir ModuleUIConfigurationManager::UIElementData*  ModuleUIConfigurationManager::impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad )
407*cdf0e10cSrcweir {
408*cdf0e10cSrcweir     // preload list of element types on demand
409*cdf0e10cSrcweir     impl_preloadUIElementTypeList( LAYER_USERDEFINED, nElementType );
410*cdf0e10cSrcweir     impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
411*cdf0e10cSrcweir 
412*cdf0e10cSrcweir     // first try to look into our user-defined vector/hash_map combination
413*cdf0e10cSrcweir     UIElementDataHashMap& rUserHashMap = m_aUIElements[LAYER_USERDEFINED][nElementType].aElementsHashMap;
414*cdf0e10cSrcweir     UIElementDataHashMap::iterator pIter = rUserHashMap.find( aResourceURL );
415*cdf0e10cSrcweir     if ( pIter != rUserHashMap.end() )
416*cdf0e10cSrcweir     {
417*cdf0e10cSrcweir         // Default data settings data must be retrieved from the default layer!
418*cdf0e10cSrcweir         if ( !pIter->second.bDefault )
419*cdf0e10cSrcweir         {
420*cdf0e10cSrcweir             if ( !pIter->second.xSettings.is() && bLoad )
421*cdf0e10cSrcweir                 impl_requestUIElementData( nElementType, LAYER_USERDEFINED, pIter->second );
422*cdf0e10cSrcweir             return &(pIter->second);
423*cdf0e10cSrcweir         }
424*cdf0e10cSrcweir     }
425*cdf0e10cSrcweir 
426*cdf0e10cSrcweir     // Not successfull, we have to look into our default vector/hash_map combination
427*cdf0e10cSrcweir     UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
428*cdf0e10cSrcweir     pIter = rDefaultHashMap.find( aResourceURL );
429*cdf0e10cSrcweir     if ( pIter != rDefaultHashMap.end() )
430*cdf0e10cSrcweir     {
431*cdf0e10cSrcweir         if ( !pIter->second.xSettings.is() && bLoad )
432*cdf0e10cSrcweir             impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
433*cdf0e10cSrcweir         return &(pIter->second);
434*cdf0e10cSrcweir     }
435*cdf0e10cSrcweir 
436*cdf0e10cSrcweir     // Nothing has been found!
437*cdf0e10cSrcweir     return NULL;
438*cdf0e10cSrcweir }
439*cdf0e10cSrcweir 
440*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_storeElementTypeData( Reference< XStorage > xStorage, UIElementType& rElementType, bool bResetModifyState )
441*cdf0e10cSrcweir {
442*cdf0e10cSrcweir     UIElementDataHashMap& rHashMap          = rElementType.aElementsHashMap;
443*cdf0e10cSrcweir     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
444*cdf0e10cSrcweir 
445*cdf0e10cSrcweir     while ( pIter != rHashMap.end() )
446*cdf0e10cSrcweir     {
447*cdf0e10cSrcweir         UIElementData& rElement = pIter->second;
448*cdf0e10cSrcweir         if ( rElement.bModified )
449*cdf0e10cSrcweir         {
450*cdf0e10cSrcweir             if ( rElement.bDefault )
451*cdf0e10cSrcweir             {
452*cdf0e10cSrcweir                 xStorage->removeElement( rElement.aName );
453*cdf0e10cSrcweir                 rElement.bModified = sal_False; // mark as not modified
454*cdf0e10cSrcweir             }
455*cdf0e10cSrcweir             else
456*cdf0e10cSrcweir             {
457*cdf0e10cSrcweir                 Reference< XStream > xStream( xStorage->openStreamElement( rElement.aName, ElementModes::WRITE|ElementModes::TRUNCATE ), UNO_QUERY );
458*cdf0e10cSrcweir                 Reference< XOutputStream > xOutputStream( xStream->getOutputStream() );
459*cdf0e10cSrcweir 
460*cdf0e10cSrcweir                 if ( xOutputStream.is() )
461*cdf0e10cSrcweir                 {
462*cdf0e10cSrcweir                     switch( rElementType.nElementType )
463*cdf0e10cSrcweir                     {
464*cdf0e10cSrcweir                         case ::com::sun::star::ui::UIElementType::MENUBAR:
465*cdf0e10cSrcweir                         {
466*cdf0e10cSrcweir                             try
467*cdf0e10cSrcweir                             {
468*cdf0e10cSrcweir                                 MenuConfiguration aMenuCfg( m_xServiceManager );
469*cdf0e10cSrcweir                                 aMenuCfg.StoreMenuBarConfigurationToXML( rElement.xSettings, xOutputStream );
470*cdf0e10cSrcweir                             }
471*cdf0e10cSrcweir                             catch ( ::com::sun::star::lang::WrappedTargetException& )
472*cdf0e10cSrcweir                             {
473*cdf0e10cSrcweir                             }
474*cdf0e10cSrcweir                         }
475*cdf0e10cSrcweir                         break;
476*cdf0e10cSrcweir 
477*cdf0e10cSrcweir                         case ::com::sun::star::ui::UIElementType::TOOLBAR:
478*cdf0e10cSrcweir                         {
479*cdf0e10cSrcweir                             try
480*cdf0e10cSrcweir                             {
481*cdf0e10cSrcweir                                 ToolBoxConfiguration::StoreToolBox( m_xServiceManager, xOutputStream, rElement.xSettings );
482*cdf0e10cSrcweir                             }
483*cdf0e10cSrcweir                             catch ( ::com::sun::star::lang::WrappedTargetException& )
484*cdf0e10cSrcweir                             {
485*cdf0e10cSrcweir                             }
486*cdf0e10cSrcweir                         }
487*cdf0e10cSrcweir                         break;
488*cdf0e10cSrcweir 
489*cdf0e10cSrcweir                         case ::com::sun::star::ui::UIElementType::STATUSBAR:
490*cdf0e10cSrcweir                         {
491*cdf0e10cSrcweir                             try
492*cdf0e10cSrcweir                             {
493*cdf0e10cSrcweir                                 StatusBarConfiguration::StoreStatusBar( m_xServiceManager, xOutputStream, rElement.xSettings );
494*cdf0e10cSrcweir                             }
495*cdf0e10cSrcweir                             catch ( ::com::sun::star::lang::WrappedTargetException& )
496*cdf0e10cSrcweir                             {
497*cdf0e10cSrcweir                             }
498*cdf0e10cSrcweir                         }
499*cdf0e10cSrcweir                         break;
500*cdf0e10cSrcweir 
501*cdf0e10cSrcweir                         default:
502*cdf0e10cSrcweir                         break;
503*cdf0e10cSrcweir                     }
504*cdf0e10cSrcweir                 }
505*cdf0e10cSrcweir 
506*cdf0e10cSrcweir                 // mark as not modified if we store to our own storage
507*cdf0e10cSrcweir                 if ( bResetModifyState )
508*cdf0e10cSrcweir                     rElement.bModified = sal_False;
509*cdf0e10cSrcweir             }
510*cdf0e10cSrcweir         }
511*cdf0e10cSrcweir 
512*cdf0e10cSrcweir         ++pIter;
513*cdf0e10cSrcweir     }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir     // commit element type storage
516*cdf0e10cSrcweir     Reference< XTransactedObject > xTransactedObject( xStorage, UNO_QUERY );
517*cdf0e10cSrcweir 	if ( xTransactedObject.is() )
518*cdf0e10cSrcweir     	xTransactedObject->commit();
519*cdf0e10cSrcweir 
520*cdf0e10cSrcweir     // mark UIElementType as not modified if we store to our own storage
521*cdf0e10cSrcweir     if ( bResetModifyState )
522*cdf0e10cSrcweir         rElementType.bModified = sal_False;
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir // This is only allowed to be called on the LAYER_USER_DEFINED!
526*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_resetElementTypeData(
527*cdf0e10cSrcweir     UIElementType& rUserElementType,
528*cdf0e10cSrcweir     UIElementType& rDefaultElementType,
529*cdf0e10cSrcweir     ConfigEventNotifyContainer& rRemoveNotifyContainer,
530*cdf0e10cSrcweir     ConfigEventNotifyContainer& rReplaceNotifyContainer )
531*cdf0e10cSrcweir {
532*cdf0e10cSrcweir     UIElementDataHashMap& rHashMap          = rUserElementType.aElementsHashMap;
533*cdf0e10cSrcweir     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
534*cdf0e10cSrcweir 
535*cdf0e10cSrcweir     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
536*cdf0e10cSrcweir     Reference< XInterface > xIfac( xThis, UNO_QUERY );
537*cdf0e10cSrcweir     Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
538*cdf0e10cSrcweir     sal_Int16 nType = rUserElementType.nElementType;
539*cdf0e10cSrcweir 
540*cdf0e10cSrcweir     // Make copies of the event structures to be thread-safe. We have to unlock our mutex before calling
541*cdf0e10cSrcweir     // our listeners!
542*cdf0e10cSrcweir     while ( pIter != rHashMap.end() )
543*cdf0e10cSrcweir     {
544*cdf0e10cSrcweir         UIElementData& rElement = pIter->second;
545*cdf0e10cSrcweir         if ( !rElement.bDefault )
546*cdf0e10cSrcweir         {
547*cdf0e10cSrcweir             if ( xDefaultNameAccess->hasByName( rElement.aName ))
548*cdf0e10cSrcweir             {
549*cdf0e10cSrcweir                 // Replace settings with data from default layer
550*cdf0e10cSrcweir                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
551*cdf0e10cSrcweir                 impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
552*cdf0e10cSrcweir 
553*cdf0e10cSrcweir                 ConfigurationEvent aReplaceEvent;
554*cdf0e10cSrcweir                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
555*cdf0e10cSrcweir                 aReplaceEvent.Accessor <<= xThis;
556*cdf0e10cSrcweir                 aReplaceEvent.Source = xIfac;
557*cdf0e10cSrcweir                 aReplaceEvent.ReplacedElement <<= xOldSettings;
558*cdf0e10cSrcweir                 aReplaceEvent.Element <<= rElement.xSettings;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir                 rReplaceNotifyContainer.push_back( aReplaceEvent );
561*cdf0e10cSrcweir 
562*cdf0e10cSrcweir                 // Mark element as default and not modified. That means "not active"
563*cdf0e10cSrcweir                 // in the user layer anymore.
564*cdf0e10cSrcweir                 rElement.bModified = false;
565*cdf0e10cSrcweir                 rElement.bDefault  = true;
566*cdf0e10cSrcweir             }
567*cdf0e10cSrcweir             else
568*cdf0e10cSrcweir             {
569*cdf0e10cSrcweir                 // Remove user-defined settings from user layer
570*cdf0e10cSrcweir                 ConfigurationEvent aEvent;
571*cdf0e10cSrcweir                 aEvent.ResourceURL = rElement.aResourceURL;
572*cdf0e10cSrcweir                 aEvent.Accessor <<= xThis;
573*cdf0e10cSrcweir                 aEvent.Source = xIfac;
574*cdf0e10cSrcweir                 aEvent.Element <<= rElement.xSettings;
575*cdf0e10cSrcweir 
576*cdf0e10cSrcweir                 rRemoveNotifyContainer.push_back( aEvent );
577*cdf0e10cSrcweir 
578*cdf0e10cSrcweir                 // Mark element as default and not modified. That means "not active"
579*cdf0e10cSrcweir                 // in the user layer anymore.
580*cdf0e10cSrcweir                 rElement.bModified = false;
581*cdf0e10cSrcweir                 rElement.bDefault  = true;
582*cdf0e10cSrcweir             }
583*cdf0e10cSrcweir         }
584*cdf0e10cSrcweir 
585*cdf0e10cSrcweir         ++pIter;
586*cdf0e10cSrcweir     }
587*cdf0e10cSrcweir 
588*cdf0e10cSrcweir     // Remove all settings from our user interface elements
589*cdf0e10cSrcweir     rHashMap.clear();
590*cdf0e10cSrcweir }
591*cdf0e10cSrcweir 
592*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_reloadElementTypeData(
593*cdf0e10cSrcweir     UIElementType&              rUserElementType,
594*cdf0e10cSrcweir     UIElementType&              rDefaultElementType,
595*cdf0e10cSrcweir     ConfigEventNotifyContainer& rRemoveNotifyContainer,
596*cdf0e10cSrcweir     ConfigEventNotifyContainer& rReplaceNotifyContainer )
597*cdf0e10cSrcweir {
598*cdf0e10cSrcweir     UIElementDataHashMap& rHashMap          = rUserElementType.aElementsHashMap;
599*cdf0e10cSrcweir     UIElementDataHashMap::iterator pIter    = rHashMap.begin();
600*cdf0e10cSrcweir     Reference< XStorage > xUserStorage( rUserElementType.xStorage );
601*cdf0e10cSrcweir     Reference< XStorage > xDefaultStorage( rDefaultElementType.xStorage );
602*cdf0e10cSrcweir     Reference< XNameAccess > xUserNameAccess( rUserElementType.xStorage, UNO_QUERY );
603*cdf0e10cSrcweir     Reference< XNameAccess > xDefaultNameAccess( rDefaultElementType.xStorage, UNO_QUERY );
604*cdf0e10cSrcweir 
605*cdf0e10cSrcweir     Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
606*cdf0e10cSrcweir     Reference< XInterface > xIfac( xThis, UNO_QUERY );
607*cdf0e10cSrcweir     sal_Int16 nType = rUserElementType.nElementType;
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir     while ( pIter != rHashMap.end() )
610*cdf0e10cSrcweir     {
611*cdf0e10cSrcweir         UIElementData& rElement = pIter->second;
612*cdf0e10cSrcweir         if ( rElement.bModified )
613*cdf0e10cSrcweir         {
614*cdf0e10cSrcweir             if ( xUserNameAccess->hasByName( rElement.aName ))
615*cdf0e10cSrcweir             {
616*cdf0e10cSrcweir                 // Replace settings with data from user layer
617*cdf0e10cSrcweir                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
618*cdf0e10cSrcweir 
619*cdf0e10cSrcweir                 impl_requestUIElementData( nType, LAYER_USERDEFINED, rElement );
620*cdf0e10cSrcweir 
621*cdf0e10cSrcweir                 ConfigurationEvent aReplaceEvent;
622*cdf0e10cSrcweir 
623*cdf0e10cSrcweir                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
624*cdf0e10cSrcweir                 aReplaceEvent.Accessor <<= xThis;
625*cdf0e10cSrcweir                 aReplaceEvent.Source = xIfac;
626*cdf0e10cSrcweir                 aReplaceEvent.ReplacedElement <<= xOldSettings;
627*cdf0e10cSrcweir                 aReplaceEvent.Element <<= rElement.xSettings;
628*cdf0e10cSrcweir                 rReplaceNotifyContainer.push_back( aReplaceEvent );
629*cdf0e10cSrcweir 
630*cdf0e10cSrcweir                 rElement.bModified = false;
631*cdf0e10cSrcweir             }
632*cdf0e10cSrcweir             else if ( xDefaultNameAccess->hasByName( rElement.aName ))
633*cdf0e10cSrcweir             {
634*cdf0e10cSrcweir                 // Replace settings with data from default layer
635*cdf0e10cSrcweir                 Reference< XIndexAccess > xOldSettings( rElement.xSettings );
636*cdf0e10cSrcweir 
637*cdf0e10cSrcweir                 impl_requestUIElementData( nType, LAYER_DEFAULT, rElement );
638*cdf0e10cSrcweir 
639*cdf0e10cSrcweir                 ConfigurationEvent aReplaceEvent;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir                 aReplaceEvent.ResourceURL = rElement.aResourceURL;
642*cdf0e10cSrcweir                 aReplaceEvent.Accessor <<= xThis;
643*cdf0e10cSrcweir                 aReplaceEvent.Source = xIfac;
644*cdf0e10cSrcweir                 aReplaceEvent.ReplacedElement <<= xOldSettings;
645*cdf0e10cSrcweir                 aReplaceEvent.Element <<= rElement.xSettings;
646*cdf0e10cSrcweir                 rReplaceNotifyContainer.push_back( aReplaceEvent );
647*cdf0e10cSrcweir 
648*cdf0e10cSrcweir                 // Mark element as default and not modified. That means "not active"
649*cdf0e10cSrcweir                 // in the user layer anymore.
650*cdf0e10cSrcweir                 rElement.bModified = false;
651*cdf0e10cSrcweir                 rElement.bDefault  = true;
652*cdf0e10cSrcweir             }
653*cdf0e10cSrcweir             else
654*cdf0e10cSrcweir             {
655*cdf0e10cSrcweir                 // Element settings are not in any storage => remove
656*cdf0e10cSrcweir                 ConfigurationEvent aRemoveEvent;
657*cdf0e10cSrcweir 
658*cdf0e10cSrcweir                 aRemoveEvent.ResourceURL = rElement.aResourceURL;
659*cdf0e10cSrcweir                 aRemoveEvent.Accessor <<= xThis;
660*cdf0e10cSrcweir                 aRemoveEvent.Source = xIfac;
661*cdf0e10cSrcweir                 aRemoveEvent.Element <<= rElement.xSettings;
662*cdf0e10cSrcweir 
663*cdf0e10cSrcweir                 rRemoveNotifyContainer.push_back( aRemoveEvent );
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir                 // Mark element as default and not modified. That means "not active"
666*cdf0e10cSrcweir                 // in the user layer anymore.
667*cdf0e10cSrcweir                 rElement.bModified = false;
668*cdf0e10cSrcweir                 rElement.bDefault  = true;
669*cdf0e10cSrcweir             }
670*cdf0e10cSrcweir         }
671*cdf0e10cSrcweir         ++pIter;
672*cdf0e10cSrcweir     }
673*cdf0e10cSrcweir 
674*cdf0e10cSrcweir     rUserElementType.bModified = sal_False;
675*cdf0e10cSrcweir }
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir void ModuleUIConfigurationManager::impl_Initialize()
678*cdf0e10cSrcweir {
679*cdf0e10cSrcweir     // Initialize the top-level structures with the storage data
680*cdf0e10cSrcweir     if ( m_xUserConfigStorage.is() )
681*cdf0e10cSrcweir     {
682*cdf0e10cSrcweir         // Try to access our module sub folder
683*cdf0e10cSrcweir         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
684*cdf0e10cSrcweir               i++ )
685*cdf0e10cSrcweir         {
686*cdf0e10cSrcweir             Reference< XStorage > xElementTypeStorage;
687*cdf0e10cSrcweir             try
688*cdf0e10cSrcweir             {
689*cdf0e10cSrcweir                 if ( m_pStorageHandler[i] )
690*cdf0e10cSrcweir                     xElementTypeStorage = m_pStorageHandler[i]->getWorkingStorageUser();
691*cdf0e10cSrcweir             }
692*cdf0e10cSrcweir             catch ( com::sun::star::container::NoSuchElementException& )
693*cdf0e10cSrcweir             {
694*cdf0e10cSrcweir             }
695*cdf0e10cSrcweir             catch ( ::com::sun::star::embed::InvalidStorageException& )
696*cdf0e10cSrcweir             {
697*cdf0e10cSrcweir             }
698*cdf0e10cSrcweir             catch ( ::com::sun::star::lang::IllegalArgumentException& )
699*cdf0e10cSrcweir             {
700*cdf0e10cSrcweir             }
701*cdf0e10cSrcweir             catch ( ::com::sun::star::io::IOException& )
702*cdf0e10cSrcweir             {
703*cdf0e10cSrcweir             }
704*cdf0e10cSrcweir             catch ( ::com::sun::star::embed::StorageWrappedTargetException& )
705*cdf0e10cSrcweir             {
706*cdf0e10cSrcweir             }
707*cdf0e10cSrcweir 
708*cdf0e10cSrcweir             m_aUIElements[LAYER_USERDEFINED][i].nElementType = i;
709*cdf0e10cSrcweir             m_aUIElements[LAYER_USERDEFINED][i].bModified = false;
710*cdf0e10cSrcweir             m_aUIElements[LAYER_USERDEFINED][i].xStorage = xElementTypeStorage;
711*cdf0e10cSrcweir             m_aUIElements[LAYER_USERDEFINED][i].bDefaultLayer = false;
712*cdf0e10cSrcweir         }
713*cdf0e10cSrcweir     }
714*cdf0e10cSrcweir 
715*cdf0e10cSrcweir     if ( m_xDefaultConfigStorage.is() )
716*cdf0e10cSrcweir     {
717*cdf0e10cSrcweir         Reference< XNameAccess > xNameAccess( m_xDefaultConfigStorage, UNO_QUERY_THROW );
718*cdf0e10cSrcweir 
719*cdf0e10cSrcweir         // Try to access our module sub folder
720*cdf0e10cSrcweir         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT;
721*cdf0e10cSrcweir               i++ )
722*cdf0e10cSrcweir         {
723*cdf0e10cSrcweir             Reference< XStorage > xElementTypeStorage;
724*cdf0e10cSrcweir             try
725*cdf0e10cSrcweir             {
726*cdf0e10cSrcweir 				const OUString sName( OUString::createFromAscii( UIELEMENTTYPENAMES[i] ) );
727*cdf0e10cSrcweir 				if( xNameAccess->hasByName( sName ) )
728*cdf0e10cSrcweir 	                xNameAccess->getByName( sName ) >>= xElementTypeStorage;
729*cdf0e10cSrcweir             }
730*cdf0e10cSrcweir             catch ( com::sun::star::container::NoSuchElementException& )
731*cdf0e10cSrcweir             {
732*cdf0e10cSrcweir             }
733*cdf0e10cSrcweir 
734*cdf0e10cSrcweir             m_aUIElements[LAYER_DEFAULT][i].nElementType = i;
735*cdf0e10cSrcweir             m_aUIElements[LAYER_DEFAULT][i].bModified = false;
736*cdf0e10cSrcweir             m_aUIElements[LAYER_DEFAULT][i].xStorage = xElementTypeStorage;
737*cdf0e10cSrcweir             m_aUIElements[LAYER_DEFAULT][i].bDefaultLayer = true;
738*cdf0e10cSrcweir         }
739*cdf0e10cSrcweir     }
740*cdf0e10cSrcweir }
741*cdf0e10cSrcweir 
742*cdf0e10cSrcweir ModuleUIConfigurationManager::ModuleUIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager ) :
743*cdf0e10cSrcweir     ThreadHelpBase( &Application::GetSolarMutex() )
744*cdf0e10cSrcweir     , m_xDefaultConfigStorage( 0 )
745*cdf0e10cSrcweir     , m_xUserConfigStorage( 0 )
746*cdf0e10cSrcweir     , m_bReadOnly( true )
747*cdf0e10cSrcweir     , m_bInitialized( false )
748*cdf0e10cSrcweir     , m_bModified( false )
749*cdf0e10cSrcweir     , m_bConfigRead( false )
750*cdf0e10cSrcweir     , m_bDisposed( false )
751*cdf0e10cSrcweir     , m_aXMLPostfix( RTL_CONSTASCII_USTRINGPARAM( ".xml" ))
752*cdf0e10cSrcweir     , m_aPropUIName( RTL_CONSTASCII_USTRINGPARAM( "UIName" ))
753*cdf0e10cSrcweir     , m_aPropResourceURL( RTL_CONSTASCII_USTRINGPARAM( "ResourceURL" ))
754*cdf0e10cSrcweir     , m_xServiceManager( xServiceManager )
755*cdf0e10cSrcweir     , m_aListenerContainer( m_aLock.getShareableOslMutex() )
756*cdf0e10cSrcweir {
757*cdf0e10cSrcweir     for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
758*cdf0e10cSrcweir         m_pStorageHandler[i] = 0;
759*cdf0e10cSrcweir 
760*cdf0e10cSrcweir     // Make sure we have a default initialized entry for every layer and user interface element type!
761*cdf0e10cSrcweir     // The following code depends on this!
762*cdf0e10cSrcweir     m_aUIElements[LAYER_DEFAULT].resize( ::com::sun::star::ui::UIElementType::COUNT );
763*cdf0e10cSrcweir     m_aUIElements[LAYER_USERDEFINED].resize( ::com::sun::star::ui::UIElementType::COUNT );
764*cdf0e10cSrcweir }
765*cdf0e10cSrcweir 
766*cdf0e10cSrcweir ModuleUIConfigurationManager::~ModuleUIConfigurationManager()
767*cdf0e10cSrcweir {
768*cdf0e10cSrcweir     for ( int i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
769*cdf0e10cSrcweir         delete m_pStorageHandler[i];
770*cdf0e10cSrcweir }
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir // XComponent
773*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::dispose() throw (::com::sun::star::uno::RuntimeException)
774*cdf0e10cSrcweir {
775*cdf0e10cSrcweir     Reference< XComponent > xThis( static_cast< OWeakObject* >(this), UNO_QUERY );
776*cdf0e10cSrcweir 
777*cdf0e10cSrcweir     css::lang::EventObject aEvent( xThis );
778*cdf0e10cSrcweir     m_aListenerContainer.disposeAndClear( aEvent );
779*cdf0e10cSrcweir 
780*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
781*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
782*cdf0e10cSrcweir     Reference< XComponent > xModuleImageManager( m_xModuleImageManager );
783*cdf0e10cSrcweir     m_xModuleImageManager.clear();
784*cdf0e10cSrcweir     m_xModuleAcceleratorManager.clear();
785*cdf0e10cSrcweir     m_aUIElements[LAYER_USERDEFINED].clear();
786*cdf0e10cSrcweir     m_aUIElements[LAYER_DEFAULT].clear();
787*cdf0e10cSrcweir     m_xDefaultConfigStorage.clear();
788*cdf0e10cSrcweir     m_xUserConfigStorage.clear();
789*cdf0e10cSrcweir     m_xUserRootCommit.clear();
790*cdf0e10cSrcweir     m_bConfigRead = false;
791*cdf0e10cSrcweir     m_bModified = false;
792*cdf0e10cSrcweir     m_bDisposed = true;
793*cdf0e10cSrcweir     aGuard.unlock();
794*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir     try
797*cdf0e10cSrcweir     {
798*cdf0e10cSrcweir         if ( xModuleImageManager.is() )
799*cdf0e10cSrcweir             xModuleImageManager->dispose();
800*cdf0e10cSrcweir     }
801*cdf0e10cSrcweir     catch ( Exception& )
802*cdf0e10cSrcweir     {
803*cdf0e10cSrcweir     }
804*cdf0e10cSrcweir }
805*cdf0e10cSrcweir 
806*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::addEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
807*cdf0e10cSrcweir {
808*cdf0e10cSrcweir     {
809*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
810*cdf0e10cSrcweir 
811*cdf0e10cSrcweir 	    /* SAFE AREA ----------------------------------------------------------------------------------------------- */
812*cdf0e10cSrcweir         if ( m_bDisposed )
813*cdf0e10cSrcweir             throw DisposedException();
814*cdf0e10cSrcweir     }
815*cdf0e10cSrcweir 
816*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
817*cdf0e10cSrcweir }
818*cdf0e10cSrcweir 
819*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::removeEventListener( const Reference< XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
820*cdf0e10cSrcweir {
821*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
822*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XEventListener >* ) NULL ), xListener );
823*cdf0e10cSrcweir }
824*cdf0e10cSrcweir 
825*cdf0e10cSrcweir // XInitialization
826*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::initialize( const Sequence< Any >& aArguments ) throw ( Exception, RuntimeException )
827*cdf0e10cSrcweir {
828*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir     if ( !m_bInitialized )
831*cdf0e10cSrcweir     {
832*cdf0e10cSrcweir         ::comphelper::SequenceAsHashMap lArgs(aArguments);
833*cdf0e10cSrcweir         m_aModuleIdentifier = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleIdentifier"), ::rtl::OUString());
834*cdf0e10cSrcweir         m_aModuleShortName  = lArgs.getUnpackedValueOrDefault(::rtl::OUString::createFromAscii("ModuleShortName"), ::rtl::OUString());
835*cdf0e10cSrcweir 
836*cdf0e10cSrcweir         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
837*cdf0e10cSrcweir         {
838*cdf0e10cSrcweir             rtl::OUString aResourceType;
839*cdf0e10cSrcweir             if ( i == ::com::sun::star::ui::UIElementType::MENUBAR )
840*cdf0e10cSrcweir                 aResourceType = PresetHandler::RESOURCETYPE_MENUBAR();
841*cdf0e10cSrcweir             else if ( i == ::com::sun::star::ui::UIElementType::TOOLBAR )
842*cdf0e10cSrcweir                 aResourceType = PresetHandler::RESOURCETYPE_TOOLBAR();
843*cdf0e10cSrcweir             else if ( i == ::com::sun::star::ui::UIElementType::STATUSBAR )
844*cdf0e10cSrcweir                 aResourceType = PresetHandler::RESOURCETYPE_STATUSBAR();
845*cdf0e10cSrcweir 
846*cdf0e10cSrcweir             if ( aResourceType.getLength() > 0 )
847*cdf0e10cSrcweir             {
848*cdf0e10cSrcweir                 m_pStorageHandler[i] = new PresetHandler( m_xServiceManager );
849*cdf0e10cSrcweir                 m_pStorageHandler[i]->connectToResource( PresetHandler::E_MODULES,
850*cdf0e10cSrcweir                                                          aResourceType, // this path wont be used later ... seee next lines!
851*cdf0e10cSrcweir                                                          m_aModuleShortName,
852*cdf0e10cSrcweir                                                          css::uno::Reference< css::embed::XStorage >()); // no document root used here!
853*cdf0e10cSrcweir             }
854*cdf0e10cSrcweir         }
855*cdf0e10cSrcweir 
856*cdf0e10cSrcweir         // initialize root storages for all resource types
857*cdf0e10cSrcweir         m_xUserRootCommit       = css::uno::Reference< css::embed::XTransactedObject >(
858*cdf0e10cSrcweir                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getOrCreateRootStorageUser(), css::uno::UNO_QUERY); // can be empty
859*cdf0e10cSrcweir         m_xDefaultConfigStorage = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageShare(
860*cdf0e10cSrcweir                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageShare());
861*cdf0e10cSrcweir         m_xUserConfigStorage    = m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getParentStorageUser(
862*cdf0e10cSrcweir                                     m_pStorageHandler[::com::sun::star::ui::UIElementType::MENUBAR]->getWorkingStorageUser());
863*cdf0e10cSrcweir 
864*cdf0e10cSrcweir         if ( m_xUserConfigStorage.is() )
865*cdf0e10cSrcweir         {
866*cdf0e10cSrcweir             Reference< XPropertySet > xPropSet( m_xUserConfigStorage, UNO_QUERY );
867*cdf0e10cSrcweir             if ( xPropSet.is() )
868*cdf0e10cSrcweir             {
869*cdf0e10cSrcweir                 long nOpenMode = 0;
870*cdf0e10cSrcweir                 Any a = xPropSet->getPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "OpenMode" )));
871*cdf0e10cSrcweir                 if ( a >>= nOpenMode )
872*cdf0e10cSrcweir                     m_bReadOnly = !( nOpenMode & ElementModes::WRITE );
873*cdf0e10cSrcweir             }
874*cdf0e10cSrcweir         }
875*cdf0e10cSrcweir 
876*cdf0e10cSrcweir         impl_Initialize();
877*cdf0e10cSrcweir 
878*cdf0e10cSrcweir         m_bInitialized = true;
879*cdf0e10cSrcweir     }
880*cdf0e10cSrcweir }
881*cdf0e10cSrcweir 
882*cdf0e10cSrcweir // XUIConfiguration
883*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::addConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
884*cdf0e10cSrcweir {
885*cdf0e10cSrcweir     {
886*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
887*cdf0e10cSrcweir 
888*cdf0e10cSrcweir         /* SAFE AREA ----------------------------------------------------------------------------------------------- */
889*cdf0e10cSrcweir         if ( m_bDisposed )
890*cdf0e10cSrcweir             throw DisposedException();
891*cdf0e10cSrcweir     }
892*cdf0e10cSrcweir 
893*cdf0e10cSrcweir     m_aListenerContainer.addInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
894*cdf0e10cSrcweir }
895*cdf0e10cSrcweir 
896*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::removeConfigurationListener( const Reference< ::com::sun::star::ui::XUIConfigurationListener >& xListener ) throw (::com::sun::star::uno::RuntimeException)
897*cdf0e10cSrcweir {
898*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
899*cdf0e10cSrcweir     m_aListenerContainer.removeInterface( ::getCppuType( ( const Reference< XUIConfigurationListener >* ) NULL ), xListener );
900*cdf0e10cSrcweir }
901*cdf0e10cSrcweir 
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir // XUIConfigurationManager
904*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::reset() throw (::com::sun::star::uno::RuntimeException)
905*cdf0e10cSrcweir {
906*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
907*cdf0e10cSrcweir 
908*cdf0e10cSrcweir     /* SAFE AREA ----------------------------------------------------------------------------------------------- */
909*cdf0e10cSrcweir     if ( m_bDisposed )
910*cdf0e10cSrcweir         throw DisposedException();
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir     bool bResetStorage( false );
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir     if ( !isReadOnly() )
915*cdf0e10cSrcweir     {
916*cdf0e10cSrcweir         // Remove all elements from our user-defined storage!
917*cdf0e10cSrcweir         try
918*cdf0e10cSrcweir         {
919*cdf0e10cSrcweir             for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
920*cdf0e10cSrcweir             {
921*cdf0e10cSrcweir                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
922*cdf0e10cSrcweir                 Reference< XStorage > xSubStorage( rElementType.xStorage, UNO_QUERY );
923*cdf0e10cSrcweir 
924*cdf0e10cSrcweir                 if ( xSubStorage.is() )
925*cdf0e10cSrcweir                 {
926*cdf0e10cSrcweir                     bool bCommitSubStorage( false );
927*cdf0e10cSrcweir                     Reference< XNameAccess > xSubStorageNameAccess( xSubStorage, UNO_QUERY );
928*cdf0e10cSrcweir                     Sequence< OUString > aUIElementStreamNames = xSubStorageNameAccess->getElementNames();
929*cdf0e10cSrcweir                     for ( sal_Int32 j = 0; j < aUIElementStreamNames.getLength(); j++ )
930*cdf0e10cSrcweir                     {
931*cdf0e10cSrcweir                         xSubStorage->removeElement( aUIElementStreamNames[j] );
932*cdf0e10cSrcweir                         bCommitSubStorage = true;
933*cdf0e10cSrcweir                     }
934*cdf0e10cSrcweir 
935*cdf0e10cSrcweir                     if ( bCommitSubStorage )
936*cdf0e10cSrcweir                     {
937*cdf0e10cSrcweir                         Reference< XTransactedObject > xTransactedObject( xSubStorage, UNO_QUERY );
938*cdf0e10cSrcweir 						if ( xTransactedObject.is() )
939*cdf0e10cSrcweir                         	xTransactedObject->commit();
940*cdf0e10cSrcweir                         m_pStorageHandler[i]->commitUserChanges();
941*cdf0e10cSrcweir                     }
942*cdf0e10cSrcweir                 }
943*cdf0e10cSrcweir             }
944*cdf0e10cSrcweir 
945*cdf0e10cSrcweir             bResetStorage = true;
946*cdf0e10cSrcweir 
947*cdf0e10cSrcweir             // remove settings from user defined layer and notify listener about removed settings data!
948*cdf0e10cSrcweir             ConfigEventNotifyContainer aRemoveEventNotifyContainer;
949*cdf0e10cSrcweir             ConfigEventNotifyContainer aReplaceEventNotifyContainer;
950*cdf0e10cSrcweir             for ( sal_Int16 j = 1; j < ::com::sun::star::ui::UIElementType::COUNT; j++ )
951*cdf0e10cSrcweir             {
952*cdf0e10cSrcweir                 try
953*cdf0e10cSrcweir                 {
954*cdf0e10cSrcweir                     UIElementType& rUserElementType     = m_aUIElements[LAYER_USERDEFINED][j];
955*cdf0e10cSrcweir                     UIElementType& rDefaultElementType  = m_aUIElements[LAYER_DEFAULT][j];
956*cdf0e10cSrcweir 
957*cdf0e10cSrcweir                     impl_resetElementTypeData( rUserElementType, rDefaultElementType, aRemoveEventNotifyContainer, aReplaceEventNotifyContainer );
958*cdf0e10cSrcweir                     rUserElementType.bModified = sal_False;
959*cdf0e10cSrcweir                 }
960*cdf0e10cSrcweir                 catch ( Exception& )
961*cdf0e10cSrcweir                 {
962*cdf0e10cSrcweir                     throw IOException();
963*cdf0e10cSrcweir                 }
964*cdf0e10cSrcweir             }
965*cdf0e10cSrcweir 
966*cdf0e10cSrcweir             m_bModified = sal_False;
967*cdf0e10cSrcweir 
968*cdf0e10cSrcweir             // Unlock mutex before notify our listeners
969*cdf0e10cSrcweir             aGuard.unlock();
970*cdf0e10cSrcweir 
971*cdf0e10cSrcweir             // Notify our listeners
972*cdf0e10cSrcweir 		    sal_uInt32 k = 0;
973*cdf0e10cSrcweir             for ( k = 0; k < aRemoveEventNotifyContainer.size(); k++ )
974*cdf0e10cSrcweir                 implts_notifyContainerListener( aRemoveEventNotifyContainer[k], NotifyOp_Remove );
975*cdf0e10cSrcweir             for ( k = 0; k < aReplaceEventNotifyContainer.size(); k++ )
976*cdf0e10cSrcweir                 implts_notifyContainerListener( aReplaceEventNotifyContainer[k], NotifyOp_Replace );
977*cdf0e10cSrcweir         }
978*cdf0e10cSrcweir         catch ( ::com::sun::star::lang::IllegalArgumentException& )
979*cdf0e10cSrcweir         {
980*cdf0e10cSrcweir         }
981*cdf0e10cSrcweir         catch ( ::com::sun::star::container::NoSuchElementException& )
982*cdf0e10cSrcweir         {
983*cdf0e10cSrcweir         }
984*cdf0e10cSrcweir         catch ( ::com::sun::star::embed::InvalidStorageException& )
985*cdf0e10cSrcweir         {
986*cdf0e10cSrcweir         }
987*cdf0e10cSrcweir         catch ( ::com::sun::star::embed::StorageWrappedTargetException& )
988*cdf0e10cSrcweir         {
989*cdf0e10cSrcweir         }
990*cdf0e10cSrcweir     }
991*cdf0e10cSrcweir }
992*cdf0e10cSrcweir 
993*cdf0e10cSrcweir Sequence< Sequence< PropertyValue > > SAL_CALL ModuleUIConfigurationManager::getUIElementsInfo( sal_Int16 ElementType )
994*cdf0e10cSrcweir throw ( IllegalArgumentException, RuntimeException )
995*cdf0e10cSrcweir {
996*cdf0e10cSrcweir     if (( ElementType < 0 ) || ( ElementType >= ::com::sun::star::ui::UIElementType::COUNT ))
997*cdf0e10cSrcweir         throw IllegalArgumentException();
998*cdf0e10cSrcweir 
999*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1000*cdf0e10cSrcweir     if ( m_bDisposed )
1001*cdf0e10cSrcweir         throw DisposedException();
1002*cdf0e10cSrcweir 
1003*cdf0e10cSrcweir     Sequence< Sequence< PropertyValue > > aElementInfoSeq;
1004*cdf0e10cSrcweir     UIElementInfoHashMap aUIElementInfoCollection;
1005*cdf0e10cSrcweir 
1006*cdf0e10cSrcweir     if ( ElementType == ::com::sun::star::ui::UIElementType::UNKNOWN )
1007*cdf0e10cSrcweir     {
1008*cdf0e10cSrcweir         for ( sal_Int16 i = 0; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1009*cdf0e10cSrcweir             impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, sal_Int16( i ) );
1010*cdf0e10cSrcweir     }
1011*cdf0e10cSrcweir     else
1012*cdf0e10cSrcweir         impl_fillSequenceWithElementTypeInfo( aUIElementInfoCollection, ElementType );
1013*cdf0e10cSrcweir 
1014*cdf0e10cSrcweir     Sequence< PropertyValue > aUIElementInfo( 2 );
1015*cdf0e10cSrcweir     aUIElementInfo[0].Name = m_aPropResourceURL;
1016*cdf0e10cSrcweir     aUIElementInfo[1].Name = m_aPropUIName;
1017*cdf0e10cSrcweir 
1018*cdf0e10cSrcweir     aElementInfoSeq.realloc( aUIElementInfoCollection.size() );
1019*cdf0e10cSrcweir     UIElementInfoHashMap::const_iterator pIter = aUIElementInfoCollection.begin();
1020*cdf0e10cSrcweir 
1021*cdf0e10cSrcweir     sal_Int32 n = 0;
1022*cdf0e10cSrcweir     while ( pIter != aUIElementInfoCollection.end() )
1023*cdf0e10cSrcweir     {
1024*cdf0e10cSrcweir         aUIElementInfo[0].Value <<= pIter->second.aResourceURL;
1025*cdf0e10cSrcweir         aUIElementInfo[1].Value <<= pIter->second.aUIName;
1026*cdf0e10cSrcweir         aElementInfoSeq[n++] = aUIElementInfo;
1027*cdf0e10cSrcweir         ++pIter;
1028*cdf0e10cSrcweir     }
1029*cdf0e10cSrcweir 
1030*cdf0e10cSrcweir     return aElementInfoSeq;
1031*cdf0e10cSrcweir }
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir Reference< XIndexContainer > SAL_CALL ModuleUIConfigurationManager::createSettings() throw (::com::sun::star::uno::RuntimeException)
1034*cdf0e10cSrcweir {
1035*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1036*cdf0e10cSrcweir 
1037*cdf0e10cSrcweir     if ( m_bDisposed )
1038*cdf0e10cSrcweir         throw DisposedException();
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir     // Creates an empty item container which can be filled from outside
1041*cdf0e10cSrcweir     return Reference< XIndexContainer >( static_cast< OWeakObject * >( new RootItemContainer() ), UNO_QUERY );
1042*cdf0e10cSrcweir }
1043*cdf0e10cSrcweir 
1044*cdf0e10cSrcweir sal_Bool SAL_CALL ModuleUIConfigurationManager::hasSettings( const ::rtl::OUString& ResourceURL )
1045*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1046*cdf0e10cSrcweir {
1047*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1048*cdf0e10cSrcweir 
1049*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1050*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1051*cdf0e10cSrcweir         throw IllegalArgumentException();
1052*cdf0e10cSrcweir     else
1053*cdf0e10cSrcweir     {
1054*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1055*cdf0e10cSrcweir 
1056*cdf0e10cSrcweir         if ( m_bDisposed )
1057*cdf0e10cSrcweir             throw DisposedException();
1058*cdf0e10cSrcweir 
1059*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
1060*cdf0e10cSrcweir         if ( pDataSettings )
1061*cdf0e10cSrcweir             return sal_True;
1062*cdf0e10cSrcweir     }
1063*cdf0e10cSrcweir 
1064*cdf0e10cSrcweir     return sal_False;
1065*cdf0e10cSrcweir }
1066*cdf0e10cSrcweir 
1067*cdf0e10cSrcweir Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable )
1068*cdf0e10cSrcweir throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1069*cdf0e10cSrcweir {
1070*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1071*cdf0e10cSrcweir 
1072*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1073*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1074*cdf0e10cSrcweir         throw IllegalArgumentException();
1075*cdf0e10cSrcweir     else
1076*cdf0e10cSrcweir     {
1077*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1078*cdf0e10cSrcweir 
1079*cdf0e10cSrcweir         if ( m_bDisposed )
1080*cdf0e10cSrcweir             throw DisposedException();
1081*cdf0e10cSrcweir 
1082*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1083*cdf0e10cSrcweir         if ( pDataSettings )
1084*cdf0e10cSrcweir         {
1085*cdf0e10cSrcweir             // Create a copy of our data if someone wants to change the data.
1086*cdf0e10cSrcweir             if ( bWriteable )
1087*cdf0e10cSrcweir                 return Reference< XIndexAccess >( static_cast< OWeakObject * >( new RootItemContainer( pDataSettings->xSettings ) ), UNO_QUERY );
1088*cdf0e10cSrcweir             else
1089*cdf0e10cSrcweir                 return pDataSettings->xSettings;
1090*cdf0e10cSrcweir         }
1091*cdf0e10cSrcweir     }
1092*cdf0e10cSrcweir 
1093*cdf0e10cSrcweir     throw NoSuchElementException();
1094*cdf0e10cSrcweir }
1095*cdf0e10cSrcweir 
1096*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::replaceSettings( const ::rtl::OUString& ResourceURL, const Reference< ::com::sun::star::container::XIndexAccess >& aNewData )
1097*cdf0e10cSrcweir throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException)
1098*cdf0e10cSrcweir {
1099*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1100*cdf0e10cSrcweir 
1101*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1102*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1103*cdf0e10cSrcweir         throw IllegalArgumentException();
1104*cdf0e10cSrcweir     else if ( m_bReadOnly )
1105*cdf0e10cSrcweir         throw IllegalAccessException();
1106*cdf0e10cSrcweir     else
1107*cdf0e10cSrcweir     {
1108*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1109*cdf0e10cSrcweir 
1110*cdf0e10cSrcweir         if ( m_bDisposed )
1111*cdf0e10cSrcweir             throw DisposedException();
1112*cdf0e10cSrcweir 
1113*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1114*cdf0e10cSrcweir         if ( pDataSettings )
1115*cdf0e10cSrcweir         {
1116*cdf0e10cSrcweir             if ( !pDataSettings->bDefaultNode )
1117*cdf0e10cSrcweir             {
1118*cdf0e10cSrcweir                 // we have a settings entry in our user-defined layer - replace
1119*cdf0e10cSrcweir                 Reference< XIndexAccess > xOldSettings = pDataSettings->xSettings;
1120*cdf0e10cSrcweir 
1121*cdf0e10cSrcweir                 // Create a copy of the data if the container is not const
1122*cdf0e10cSrcweir                 Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1123*cdf0e10cSrcweir                 if ( xReplace.is() )
1124*cdf0e10cSrcweir                     pDataSettings->xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1125*cdf0e10cSrcweir                 else
1126*cdf0e10cSrcweir                     pDataSettings->xSettings = aNewData;
1127*cdf0e10cSrcweir                 pDataSettings->bDefault  = false;
1128*cdf0e10cSrcweir                 pDataSettings->bModified = true;
1129*cdf0e10cSrcweir                 m_bModified = true;
1130*cdf0e10cSrcweir 
1131*cdf0e10cSrcweir                 // Modify type container
1132*cdf0e10cSrcweir                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1133*cdf0e10cSrcweir                 rElementType.bModified = true;
1134*cdf0e10cSrcweir 
1135*cdf0e10cSrcweir                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1136*cdf0e10cSrcweir 
1137*cdf0e10cSrcweir                 // Create event to notify listener about replaced element settings
1138*cdf0e10cSrcweir                 ConfigurationEvent aEvent;
1139*cdf0e10cSrcweir                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir                 aEvent.ResourceURL = ResourceURL;
1142*cdf0e10cSrcweir                 aEvent.Accessor <<= xThis;
1143*cdf0e10cSrcweir                 aEvent.Source = xIfac;
1144*cdf0e10cSrcweir                 aEvent.ReplacedElement <<= xOldSettings;
1145*cdf0e10cSrcweir                 aEvent.Element <<= pDataSettings->xSettings;
1146*cdf0e10cSrcweir 
1147*cdf0e10cSrcweir                 aGuard.unlock();
1148*cdf0e10cSrcweir 
1149*cdf0e10cSrcweir                 implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1150*cdf0e10cSrcweir             }
1151*cdf0e10cSrcweir             else
1152*cdf0e10cSrcweir             {
1153*cdf0e10cSrcweir                 // we have no settings in our user-defined layer - insert
1154*cdf0e10cSrcweir                 UIElementData aUIElementData;
1155*cdf0e10cSrcweir 
1156*cdf0e10cSrcweir                 aUIElementData.bDefault     = false;
1157*cdf0e10cSrcweir                 aUIElementData.bDefaultNode = false;
1158*cdf0e10cSrcweir                 aUIElementData.bModified    = true;
1159*cdf0e10cSrcweir 
1160*cdf0e10cSrcweir                 // Create a copy of the data if the container is not const
1161*cdf0e10cSrcweir                 Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1162*cdf0e10cSrcweir                 if ( xReplace.is() )
1163*cdf0e10cSrcweir                     aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1164*cdf0e10cSrcweir                 else
1165*cdf0e10cSrcweir                     aUIElementData.xSettings = aNewData;
1166*cdf0e10cSrcweir                 aUIElementData.aName        = RetrieveNameFromResourceURL( ResourceURL ) + m_aXMLPostfix;
1167*cdf0e10cSrcweir                 aUIElementData.aResourceURL = ResourceURL;
1168*cdf0e10cSrcweir                 m_bModified = true;
1169*cdf0e10cSrcweir 
1170*cdf0e10cSrcweir                 // Modify type container
1171*cdf0e10cSrcweir                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1172*cdf0e10cSrcweir                 rElementType.bModified = true;
1173*cdf0e10cSrcweir 
1174*cdf0e10cSrcweir                 UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
1175*cdf0e10cSrcweir 
1176*cdf0e10cSrcweir                 // Check our user element settings hash map as it can already contain settings that have been set to default!
1177*cdf0e10cSrcweir                 // If no node can be found, we have to insert it.
1178*cdf0e10cSrcweir                 UIElementDataHashMap::iterator pIter = rElements.find( ResourceURL );
1179*cdf0e10cSrcweir                 if ( pIter != rElements.end() )
1180*cdf0e10cSrcweir                     pIter->second = aUIElementData;
1181*cdf0e10cSrcweir                 else
1182*cdf0e10cSrcweir                     rElements.insert( UIElementDataHashMap::value_type( ResourceURL, aUIElementData ));
1183*cdf0e10cSrcweir 
1184*cdf0e10cSrcweir                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1185*cdf0e10cSrcweir                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
1186*cdf0e10cSrcweir 
1187*cdf0e10cSrcweir                 // Create event to notify listener about replaced element settings
1188*cdf0e10cSrcweir                 ConfigurationEvent aEvent;
1189*cdf0e10cSrcweir 
1190*cdf0e10cSrcweir                 aEvent.ResourceURL = ResourceURL;
1191*cdf0e10cSrcweir                 aEvent.Accessor <<= xThis;
1192*cdf0e10cSrcweir                 aEvent.Source = xIfac;
1193*cdf0e10cSrcweir                 aEvent.ReplacedElement <<= pDataSettings->xSettings;
1194*cdf0e10cSrcweir                 aEvent.Element <<= aUIElementData.xSettings;
1195*cdf0e10cSrcweir 
1196*cdf0e10cSrcweir                 aGuard.unlock();
1197*cdf0e10cSrcweir 
1198*cdf0e10cSrcweir                 implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1199*cdf0e10cSrcweir             }
1200*cdf0e10cSrcweir         }
1201*cdf0e10cSrcweir         else
1202*cdf0e10cSrcweir             throw NoSuchElementException();
1203*cdf0e10cSrcweir     }
1204*cdf0e10cSrcweir }
1205*cdf0e10cSrcweir 
1206*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::removeSettings( const ::rtl::OUString& ResourceURL )
1207*cdf0e10cSrcweir throw ( NoSuchElementException, IllegalArgumentException, IllegalAccessException, RuntimeException)
1208*cdf0e10cSrcweir {
1209*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1210*cdf0e10cSrcweir 
1211*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1212*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1213*cdf0e10cSrcweir         throw IllegalArgumentException();
1214*cdf0e10cSrcweir     else if ( m_bReadOnly )
1215*cdf0e10cSrcweir         throw IllegalAccessException();
1216*cdf0e10cSrcweir     else
1217*cdf0e10cSrcweir     {
1218*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1219*cdf0e10cSrcweir 
1220*cdf0e10cSrcweir         if ( m_bDisposed )
1221*cdf0e10cSrcweir             throw DisposedException();
1222*cdf0e10cSrcweir 
1223*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1224*cdf0e10cSrcweir         if ( pDataSettings )
1225*cdf0e10cSrcweir         {
1226*cdf0e10cSrcweir             // If element settings are default, we don't need to change anything!
1227*cdf0e10cSrcweir             if ( pDataSettings->bDefault )
1228*cdf0e10cSrcweir                 return;
1229*cdf0e10cSrcweir             else
1230*cdf0e10cSrcweir             {
1231*cdf0e10cSrcweir                 Reference< XIndexAccess > xRemovedSettings = pDataSettings->xSettings;
1232*cdf0e10cSrcweir                 pDataSettings->bDefault = true;
1233*cdf0e10cSrcweir 
1234*cdf0e10cSrcweir                 // check if this is a default layer node
1235*cdf0e10cSrcweir                 if ( !pDataSettings->bDefaultNode )
1236*cdf0e10cSrcweir                     pDataSettings->bModified = true; // we have to remove this node from the user layer!
1237*cdf0e10cSrcweir                 pDataSettings->xSettings.clear();
1238*cdf0e10cSrcweir                 m_bModified = true; // user layer must be written
1239*cdf0e10cSrcweir 
1240*cdf0e10cSrcweir                 // Modify type container
1241*cdf0e10cSrcweir                 UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1242*cdf0e10cSrcweir                 rElementType.bModified = true;
1243*cdf0e10cSrcweir 
1244*cdf0e10cSrcweir                 Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1245*cdf0e10cSrcweir                 Reference< XInterface > xIfac( xThis, UNO_QUERY );
1246*cdf0e10cSrcweir 
1247*cdf0e10cSrcweir                 // Check if we have settings in the default layer which replaces the user-defined one!
1248*cdf0e10cSrcweir                 UIElementData* pDefaultDataSettings = impl_findUIElementData( ResourceURL, nElementType );
1249*cdf0e10cSrcweir                 if ( pDefaultDataSettings )
1250*cdf0e10cSrcweir                 {
1251*cdf0e10cSrcweir                     // Create event to notify listener about replaced element settings
1252*cdf0e10cSrcweir                     ConfigurationEvent aEvent;
1253*cdf0e10cSrcweir 
1254*cdf0e10cSrcweir                     aEvent.ResourceURL = ResourceURL;
1255*cdf0e10cSrcweir                     aEvent.Accessor <<= xThis;
1256*cdf0e10cSrcweir                     aEvent.Source = xIfac;
1257*cdf0e10cSrcweir                     aEvent.Element <<= xRemovedSettings;
1258*cdf0e10cSrcweir                     aEvent.ReplacedElement <<= pDefaultDataSettings->xSettings;
1259*cdf0e10cSrcweir 
1260*cdf0e10cSrcweir                     aGuard.unlock();
1261*cdf0e10cSrcweir 
1262*cdf0e10cSrcweir                     implts_notifyContainerListener( aEvent, NotifyOp_Replace );
1263*cdf0e10cSrcweir                 }
1264*cdf0e10cSrcweir                 else
1265*cdf0e10cSrcweir                 {
1266*cdf0e10cSrcweir                     // Create event to notify listener about removed element settings
1267*cdf0e10cSrcweir                     ConfigurationEvent aEvent;
1268*cdf0e10cSrcweir 
1269*cdf0e10cSrcweir                     aEvent.ResourceURL = ResourceURL;
1270*cdf0e10cSrcweir                     aEvent.Accessor <<= xThis;
1271*cdf0e10cSrcweir                     aEvent.Source = xIfac;
1272*cdf0e10cSrcweir                     aEvent.Element <<= xRemovedSettings;
1273*cdf0e10cSrcweir 
1274*cdf0e10cSrcweir                     aGuard.unlock();
1275*cdf0e10cSrcweir 
1276*cdf0e10cSrcweir                     implts_notifyContainerListener( aEvent, NotifyOp_Remove );
1277*cdf0e10cSrcweir                 }
1278*cdf0e10cSrcweir             }
1279*cdf0e10cSrcweir         }
1280*cdf0e10cSrcweir         else
1281*cdf0e10cSrcweir             throw NoSuchElementException();
1282*cdf0e10cSrcweir     }
1283*cdf0e10cSrcweir }
1284*cdf0e10cSrcweir 
1285*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::insertSettings( const ::rtl::OUString& NewResourceURL, const Reference< XIndexAccess >& aNewData )
1286*cdf0e10cSrcweir throw ( ElementExistException, IllegalArgumentException, IllegalAccessException, RuntimeException )
1287*cdf0e10cSrcweir {
1288*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( NewResourceURL );
1289*cdf0e10cSrcweir 
1290*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1291*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1292*cdf0e10cSrcweir         throw IllegalArgumentException();
1293*cdf0e10cSrcweir     else if ( m_bReadOnly )
1294*cdf0e10cSrcweir         throw IllegalAccessException();
1295*cdf0e10cSrcweir     else
1296*cdf0e10cSrcweir     {
1297*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1298*cdf0e10cSrcweir 
1299*cdf0e10cSrcweir         if ( m_bDisposed )
1300*cdf0e10cSrcweir             throw DisposedException();
1301*cdf0e10cSrcweir 
1302*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( NewResourceURL, nElementType );
1303*cdf0e10cSrcweir         if ( !pDataSettings )
1304*cdf0e10cSrcweir         {
1305*cdf0e10cSrcweir             UIElementData aUIElementData;
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir             aUIElementData.bDefault     = false;
1308*cdf0e10cSrcweir             aUIElementData.bDefaultNode = false;
1309*cdf0e10cSrcweir             aUIElementData.bModified    = true;
1310*cdf0e10cSrcweir 
1311*cdf0e10cSrcweir             // Create a copy of the data if the container is not const
1312*cdf0e10cSrcweir             Reference< XIndexReplace > xReplace( aNewData, UNO_QUERY );
1313*cdf0e10cSrcweir             if ( xReplace.is() )
1314*cdf0e10cSrcweir                 aUIElementData.xSettings = Reference< XIndexAccess >( static_cast< OWeakObject * >( new ConstItemContainer( aNewData ) ), UNO_QUERY );
1315*cdf0e10cSrcweir             else
1316*cdf0e10cSrcweir                 aUIElementData.xSettings = aNewData;
1317*cdf0e10cSrcweir             aUIElementData.aName        = RetrieveNameFromResourceURL( NewResourceURL ) + m_aXMLPostfix;
1318*cdf0e10cSrcweir             aUIElementData.aResourceURL = NewResourceURL;
1319*cdf0e10cSrcweir             m_bModified = true;
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir             UIElementType& rElementType = m_aUIElements[LAYER_USERDEFINED][nElementType];
1322*cdf0e10cSrcweir             rElementType.bModified = true;
1323*cdf0e10cSrcweir 
1324*cdf0e10cSrcweir             UIElementDataHashMap& rElements = rElementType.aElementsHashMap;
1325*cdf0e10cSrcweir             rElements.insert( UIElementDataHashMap::value_type( NewResourceURL, aUIElementData ));
1326*cdf0e10cSrcweir 
1327*cdf0e10cSrcweir             Reference< XIndexAccess > xInsertSettings( aUIElementData.xSettings );
1328*cdf0e10cSrcweir             Reference< XUIConfigurationManager > xThis( static_cast< OWeakObject* >( this ), UNO_QUERY );
1329*cdf0e10cSrcweir             Reference< XInterface > xIfac( xThis, UNO_QUERY );
1330*cdf0e10cSrcweir 
1331*cdf0e10cSrcweir             // Create event to notify listener about removed element settings
1332*cdf0e10cSrcweir             ConfigurationEvent aEvent;
1333*cdf0e10cSrcweir 
1334*cdf0e10cSrcweir             aEvent.ResourceURL = NewResourceURL;
1335*cdf0e10cSrcweir             aEvent.Accessor <<= xThis;
1336*cdf0e10cSrcweir             aEvent.Source = xIfac;
1337*cdf0e10cSrcweir             aEvent.Element <<= xInsertSettings;
1338*cdf0e10cSrcweir 
1339*cdf0e10cSrcweir             aGuard.unlock();
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir             implts_notifyContainerListener( aEvent, NotifyOp_Insert );
1342*cdf0e10cSrcweir         }
1343*cdf0e10cSrcweir         else
1344*cdf0e10cSrcweir             throw ElementExistException();
1345*cdf0e10cSrcweir     }
1346*cdf0e10cSrcweir }
1347*cdf0e10cSrcweir 
1348*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getImageManager() throw (::com::sun::star::uno::RuntimeException)
1349*cdf0e10cSrcweir {
1350*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1351*cdf0e10cSrcweir 
1352*cdf0e10cSrcweir     if ( m_bDisposed )
1353*cdf0e10cSrcweir         throw DisposedException();
1354*cdf0e10cSrcweir 
1355*cdf0e10cSrcweir     if ( !m_xModuleImageManager.is() )
1356*cdf0e10cSrcweir     {
1357*cdf0e10cSrcweir         m_xModuleImageManager = Reference< XComponent >( static_cast< cppu::OWeakObject *>( new ModuleImageManager( m_xServiceManager )),
1358*cdf0e10cSrcweir                                                          UNO_QUERY );
1359*cdf0e10cSrcweir         Reference< XInitialization > xInit( m_xModuleImageManager, UNO_QUERY );
1360*cdf0e10cSrcweir 
1361*cdf0e10cSrcweir         Sequence< Any > aPropSeq( 3 );
1362*cdf0e10cSrcweir         PropertyValue aPropValue;
1363*cdf0e10cSrcweir         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserConfigStorage" ));
1364*cdf0e10cSrcweir         aPropValue.Value = makeAny( m_xUserConfigStorage );
1365*cdf0e10cSrcweir         aPropSeq[0] = makeAny( aPropValue );
1366*cdf0e10cSrcweir         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ModuleIdentifier" ));
1367*cdf0e10cSrcweir         aPropValue.Value = makeAny( m_aModuleIdentifier );
1368*cdf0e10cSrcweir         aPropSeq[1] = makeAny( aPropValue );
1369*cdf0e10cSrcweir         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "UserRootCommit" ));
1370*cdf0e10cSrcweir         aPropValue.Value = makeAny( m_xUserRootCommit );
1371*cdf0e10cSrcweir         aPropSeq[2] = makeAny( aPropValue );
1372*cdf0e10cSrcweir 
1373*cdf0e10cSrcweir         xInit->initialize( aPropSeq );
1374*cdf0e10cSrcweir     }
1375*cdf0e10cSrcweir 
1376*cdf0e10cSrcweir     return Reference< XInterface >( m_xModuleImageManager, UNO_QUERY );
1377*cdf0e10cSrcweir }
1378*cdf0e10cSrcweir 
1379*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getShortCutManager() throw (::com::sun::star::uno::RuntimeException)
1380*cdf0e10cSrcweir {
1381*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1382*cdf0e10cSrcweir 
1383*cdf0e10cSrcweir     if ( m_bDisposed )
1384*cdf0e10cSrcweir         throw DisposedException();
1385*cdf0e10cSrcweir 
1386*cdf0e10cSrcweir     Reference< XMultiServiceFactory > xSMGR   = m_xServiceManager;
1387*cdf0e10cSrcweir     ::rtl::OUString                   aModule = m_aModuleIdentifier;
1388*cdf0e10cSrcweir 
1389*cdf0e10cSrcweir     if ( !m_xModuleAcceleratorManager.is() )
1390*cdf0e10cSrcweir     {
1391*cdf0e10cSrcweir         Reference< XInterface >      xManager = xSMGR->createInstance(SERVICENAME_MODULEACCELERATORCONFIGURATION);
1392*cdf0e10cSrcweir         Reference< XInitialization > xInit    (xManager, UNO_QUERY_THROW);
1393*cdf0e10cSrcweir 
1394*cdf0e10cSrcweir         PropertyValue aProp;
1395*cdf0e10cSrcweir         aProp.Name    = ::rtl::OUString::createFromAscii("ModuleIdentifier");
1396*cdf0e10cSrcweir         aProp.Value <<= aModule;
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir         Sequence< Any > lArgs(1);
1399*cdf0e10cSrcweir         lArgs[0] <<= aProp;
1400*cdf0e10cSrcweir 
1401*cdf0e10cSrcweir         xInit->initialize(lArgs);
1402*cdf0e10cSrcweir         m_xModuleAcceleratorManager = Reference< XInterface >( xManager, UNO_QUERY );
1403*cdf0e10cSrcweir     }
1404*cdf0e10cSrcweir 
1405*cdf0e10cSrcweir     return m_xModuleAcceleratorManager;
1406*cdf0e10cSrcweir }
1407*cdf0e10cSrcweir 
1408*cdf0e10cSrcweir Reference< XInterface > SAL_CALL ModuleUIConfigurationManager::getEventsManager() throw (::com::sun::star::uno::RuntimeException)
1409*cdf0e10cSrcweir {
1410*cdf0e10cSrcweir     return Reference< XInterface >();
1411*cdf0e10cSrcweir }
1412*cdf0e10cSrcweir 
1413*cdf0e10cSrcweir // XModuleUIConfigurationManager
1414*cdf0e10cSrcweir sal_Bool SAL_CALL ModuleUIConfigurationManager::isDefaultSettings( const ::rtl::OUString& ResourceURL )
1415*cdf0e10cSrcweir throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1416*cdf0e10cSrcweir {
1417*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1420*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1421*cdf0e10cSrcweir         throw IllegalArgumentException();
1422*cdf0e10cSrcweir     else
1423*cdf0e10cSrcweir     {
1424*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1425*cdf0e10cSrcweir 
1426*cdf0e10cSrcweir         if ( m_bDisposed )
1427*cdf0e10cSrcweir             throw DisposedException();
1428*cdf0e10cSrcweir 
1429*cdf0e10cSrcweir         UIElementData* pDataSettings = impl_findUIElementData( ResourceURL, nElementType, false );
1430*cdf0e10cSrcweir         if ( pDataSettings && pDataSettings->bDefaultNode )
1431*cdf0e10cSrcweir             return sal_True;
1432*cdf0e10cSrcweir     }
1433*cdf0e10cSrcweir 
1434*cdf0e10cSrcweir     return sal_False;
1435*cdf0e10cSrcweir }
1436*cdf0e10cSrcweir 
1437*cdf0e10cSrcweir Reference< XIndexAccess > SAL_CALL ModuleUIConfigurationManager::getDefaultSettings( const ::rtl::OUString& ResourceURL )
1438*cdf0e10cSrcweir throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException)
1439*cdf0e10cSrcweir {
1440*cdf0e10cSrcweir     sal_Int16 nElementType = RetrieveTypeFromResourceURL( ResourceURL );
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir     if (( nElementType == ::com::sun::star::ui::UIElementType::UNKNOWN ) ||
1443*cdf0e10cSrcweir         ( nElementType >= ::com::sun::star::ui::UIElementType::COUNT   ))
1444*cdf0e10cSrcweir         throw IllegalArgumentException();
1445*cdf0e10cSrcweir     else
1446*cdf0e10cSrcweir     {
1447*cdf0e10cSrcweir         ResetableGuard aGuard( m_aLock );
1448*cdf0e10cSrcweir 
1449*cdf0e10cSrcweir         if ( m_bDisposed )
1450*cdf0e10cSrcweir             throw DisposedException();
1451*cdf0e10cSrcweir 
1452*cdf0e10cSrcweir         // preload list of element types on demand
1453*cdf0e10cSrcweir         impl_preloadUIElementTypeList( LAYER_DEFAULT, nElementType );
1454*cdf0e10cSrcweir 
1455*cdf0e10cSrcweir         // Look into our default vector/hash_map combination
1456*cdf0e10cSrcweir         UIElementDataHashMap& rDefaultHashMap = m_aUIElements[LAYER_DEFAULT][nElementType].aElementsHashMap;
1457*cdf0e10cSrcweir         UIElementDataHashMap::iterator pIter = rDefaultHashMap.find( ResourceURL );
1458*cdf0e10cSrcweir         if ( pIter != rDefaultHashMap.end() )
1459*cdf0e10cSrcweir         {
1460*cdf0e10cSrcweir             if ( !pIter->second.xSettings.is() )
1461*cdf0e10cSrcweir                 impl_requestUIElementData( nElementType, LAYER_DEFAULT, pIter->second );
1462*cdf0e10cSrcweir             return pIter->second.xSettings;
1463*cdf0e10cSrcweir         }
1464*cdf0e10cSrcweir     }
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir     // Nothing has been found!
1467*cdf0e10cSrcweir     throw NoSuchElementException();
1468*cdf0e10cSrcweir }
1469*cdf0e10cSrcweir 
1470*cdf0e10cSrcweir // XUIConfigurationPersistence
1471*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1472*cdf0e10cSrcweir {
1473*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1474*cdf0e10cSrcweir 
1475*cdf0e10cSrcweir     if ( m_bDisposed )
1476*cdf0e10cSrcweir         throw DisposedException();
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1479*cdf0e10cSrcweir     {
1480*cdf0e10cSrcweir         // Try to access our module sub folder
1481*cdf0e10cSrcweir         ConfigEventNotifyContainer aRemoveNotifyContainer;
1482*cdf0e10cSrcweir         ConfigEventNotifyContainer aReplaceNotifyContainer;
1483*cdf0e10cSrcweir         for ( sal_Int16 i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1484*cdf0e10cSrcweir         {
1485*cdf0e10cSrcweir             try
1486*cdf0e10cSrcweir             {
1487*cdf0e10cSrcweir                 UIElementType& rUserElementType    = m_aUIElements[LAYER_USERDEFINED][i];
1488*cdf0e10cSrcweir                 UIElementType& rDefaultElementType = m_aUIElements[LAYER_DEFAULT][i];
1489*cdf0e10cSrcweir 
1490*cdf0e10cSrcweir                 if ( rUserElementType.bModified )
1491*cdf0e10cSrcweir                     impl_reloadElementTypeData( rUserElementType, rDefaultElementType, aRemoveNotifyContainer, aReplaceNotifyContainer );
1492*cdf0e10cSrcweir             }
1493*cdf0e10cSrcweir             catch ( Exception& )
1494*cdf0e10cSrcweir             {
1495*cdf0e10cSrcweir                 throw IOException();
1496*cdf0e10cSrcweir             }
1497*cdf0e10cSrcweir         }
1498*cdf0e10cSrcweir 
1499*cdf0e10cSrcweir         m_bModified = sal_False;
1500*cdf0e10cSrcweir 
1501*cdf0e10cSrcweir         // Unlock mutex before notify our listeners
1502*cdf0e10cSrcweir         aGuard.unlock();
1503*cdf0e10cSrcweir 
1504*cdf0e10cSrcweir         // Notify our listeners
1505*cdf0e10cSrcweir         for ( sal_uInt32 j = 0; j < aRemoveNotifyContainer.size(); j++ )
1506*cdf0e10cSrcweir             implts_notifyContainerListener( aRemoveNotifyContainer[j], NotifyOp_Remove );
1507*cdf0e10cSrcweir         for ( sal_uInt32 k = 0; k < aReplaceNotifyContainer.size(); k++ )
1508*cdf0e10cSrcweir             implts_notifyContainerListener( aReplaceNotifyContainer[k], NotifyOp_Replace );
1509*cdf0e10cSrcweir     }
1510*cdf0e10cSrcweir }
1511*cdf0e10cSrcweir 
1512*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1513*cdf0e10cSrcweir {
1514*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir     if ( m_bDisposed )
1517*cdf0e10cSrcweir         throw DisposedException();
1518*cdf0e10cSrcweir 
1519*cdf0e10cSrcweir     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1520*cdf0e10cSrcweir     {
1521*cdf0e10cSrcweir         // Try to access our module sub folder
1522*cdf0e10cSrcweir         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1523*cdf0e10cSrcweir         {
1524*cdf0e10cSrcweir             try
1525*cdf0e10cSrcweir             {
1526*cdf0e10cSrcweir                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
1527*cdf0e10cSrcweir                 Reference< XStorage > xStorage( rElementType.xStorage, UNO_QUERY );
1528*cdf0e10cSrcweir 
1529*cdf0e10cSrcweir                 if ( rElementType.bModified && xStorage.is() )
1530*cdf0e10cSrcweir                 {
1531*cdf0e10cSrcweir                     impl_storeElementTypeData( xStorage, rElementType );
1532*cdf0e10cSrcweir                     m_pStorageHandler[i]->commitUserChanges();
1533*cdf0e10cSrcweir                 }
1534*cdf0e10cSrcweir             }
1535*cdf0e10cSrcweir             catch ( Exception& )
1536*cdf0e10cSrcweir             {
1537*cdf0e10cSrcweir                 throw IOException();
1538*cdf0e10cSrcweir             }
1539*cdf0e10cSrcweir         }
1540*cdf0e10cSrcweir 
1541*cdf0e10cSrcweir         m_bModified = false;
1542*cdf0e10cSrcweir     }
1543*cdf0e10cSrcweir }
1544*cdf0e10cSrcweir 
1545*cdf0e10cSrcweir void SAL_CALL ModuleUIConfigurationManager::storeToStorage( const Reference< XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException)
1546*cdf0e10cSrcweir {
1547*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1548*cdf0e10cSrcweir 
1549*cdf0e10cSrcweir     if ( m_bDisposed )
1550*cdf0e10cSrcweir         throw DisposedException();
1551*cdf0e10cSrcweir 
1552*cdf0e10cSrcweir     if ( m_xUserConfigStorage.is() && m_bModified && !m_bReadOnly )
1553*cdf0e10cSrcweir     {
1554*cdf0e10cSrcweir         // Try to access our module sub folder
1555*cdf0e10cSrcweir         for ( int i = 1; i < ::com::sun::star::ui::UIElementType::COUNT; i++ )
1556*cdf0e10cSrcweir         {
1557*cdf0e10cSrcweir             try
1558*cdf0e10cSrcweir             {
1559*cdf0e10cSrcweir                 Reference< XStorage > xElementTypeStorage( Storage->openStorageElement(
1560*cdf0e10cSrcweir                                                             OUString::createFromAscii( UIELEMENTTYPENAMES[i] ), ElementModes::READWRITE ));
1561*cdf0e10cSrcweir                 UIElementType&        rElementType = m_aUIElements[LAYER_USERDEFINED][i];
1562*cdf0e10cSrcweir 
1563*cdf0e10cSrcweir                 if ( rElementType.bModified && xElementTypeStorage.is() )
1564*cdf0e10cSrcweir                     impl_storeElementTypeData( xElementTypeStorage, rElementType, false ); // store data to storage, but don't reset modify flag!
1565*cdf0e10cSrcweir             }
1566*cdf0e10cSrcweir             catch ( Exception& )
1567*cdf0e10cSrcweir             {
1568*cdf0e10cSrcweir                 throw IOException();
1569*cdf0e10cSrcweir             }
1570*cdf0e10cSrcweir         }
1571*cdf0e10cSrcweir 
1572*cdf0e10cSrcweir         Reference< XTransactedObject > xTransactedObject( Storage, UNO_QUERY );
1573*cdf0e10cSrcweir 		if ( xTransactedObject.is() )
1574*cdf0e10cSrcweir         	xTransactedObject->commit();
1575*cdf0e10cSrcweir     }
1576*cdf0e10cSrcweir }
1577*cdf0e10cSrcweir 
1578*cdf0e10cSrcweir sal_Bool SAL_CALL ModuleUIConfigurationManager::isModified() throw (::com::sun::star::uno::RuntimeException)
1579*cdf0e10cSrcweir {
1580*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1581*cdf0e10cSrcweir 
1582*cdf0e10cSrcweir     return m_bModified;
1583*cdf0e10cSrcweir }
1584*cdf0e10cSrcweir 
1585*cdf0e10cSrcweir sal_Bool SAL_CALL ModuleUIConfigurationManager::isReadOnly() throw (::com::sun::star::uno::RuntimeException)
1586*cdf0e10cSrcweir {
1587*cdf0e10cSrcweir     ResetableGuard aGuard( m_aLock );
1588*cdf0e10cSrcweir 
1589*cdf0e10cSrcweir     return m_bReadOnly;
1590*cdf0e10cSrcweir }
1591*cdf0e10cSrcweir 
1592*cdf0e10cSrcweir void ModuleUIConfigurationManager::implts_notifyContainerListener( const ConfigurationEvent& aEvent, NotifyOp eOp )
1593*cdf0e10cSrcweir {
1594*cdf0e10cSrcweir     ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( ::getCppuType( ( const css::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >*) NULL ) );
1595*cdf0e10cSrcweir     if ( pContainer != NULL )
1596*cdf0e10cSrcweir 	{
1597*cdf0e10cSrcweir         ::cppu::OInterfaceIteratorHelper pIterator( *pContainer );
1598*cdf0e10cSrcweir         while ( pIterator.hasMoreElements() )
1599*cdf0e10cSrcweir         {
1600*cdf0e10cSrcweir             try
1601*cdf0e10cSrcweir             {
1602*cdf0e10cSrcweir                 switch ( eOp )
1603*cdf0e10cSrcweir                 {
1604*cdf0e10cSrcweir                     case NotifyOp_Replace:
1605*cdf0e10cSrcweir                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementReplaced( aEvent );
1606*cdf0e10cSrcweir                         break;
1607*cdf0e10cSrcweir                     case NotifyOp_Insert:
1608*cdf0e10cSrcweir                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementInserted( aEvent );
1609*cdf0e10cSrcweir                         break;
1610*cdf0e10cSrcweir                     case NotifyOp_Remove:
1611*cdf0e10cSrcweir                         ((::com::sun::star::ui::XUIConfigurationListener*)pIterator.next())->elementRemoved( aEvent );
1612*cdf0e10cSrcweir                         break;
1613*cdf0e10cSrcweir                 }
1614*cdf0e10cSrcweir             }
1615*cdf0e10cSrcweir             catch( css::uno::RuntimeException& )
1616*cdf0e10cSrcweir             {
1617*cdf0e10cSrcweir                 pIterator.remove();
1618*cdf0e10cSrcweir             }
1619*cdf0e10cSrcweir         }
1620*cdf0e10cSrcweir 	}
1621*cdf0e10cSrcweir }
1622*cdf0e10cSrcweir 
1623*cdf0e10cSrcweir } // namespace framework
1624