xref: /AOO41X/main/framework/source/uiconfiguration/windowstateconfiguration.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 
31*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
32*cdf0e10cSrcweir //	my own includes
33*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
34*cdf0e10cSrcweir #include "uiconfiguration/windowstateconfiguration.hxx"
35*cdf0e10cSrcweir #include <threadhelp/resetableguard.hxx>
36*cdf0e10cSrcweir #include "services.h"
37*cdf0e10cSrcweir 
38*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
39*cdf0e10cSrcweir //	interface includes
40*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
41*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
42*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
43*cdf0e10cSrcweir #include <com/sun/star/container/XNameAccess.hpp>
44*cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
45*cdf0e10cSrcweir #include <com/sun/star/container/XContainer.hpp>
46*cdf0e10cSrcweir #include <com/sun/star/awt/Point.hpp>
47*cdf0e10cSrcweir #include <com/sun/star/awt/Size.hpp>
48*cdf0e10cSrcweir #include <com/sun/star/ui/DockingArea.hpp>
49*cdf0e10cSrcweir #include <com/sun/star/util/XChangesBatch.hpp>
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
52*cdf0e10cSrcweir //	includes of other projects
53*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
54*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
55*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
56*cdf0e10cSrcweir #include <tools/debug.hxx>
57*cdf0e10cSrcweir 
58*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
59*cdf0e10cSrcweir //	Defines
60*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
61*cdf0e10cSrcweir //
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir using namespace com::sun::star::uno;
64*cdf0e10cSrcweir using namespace com::sun::star::lang;
65*cdf0e10cSrcweir using namespace com::sun::star::beans;
66*cdf0e10cSrcweir using namespace com::sun::star::util;
67*cdf0e10cSrcweir using namespace com::sun::star::container;
68*cdf0e10cSrcweir using namespace ::com::sun::star::frame;
69*cdf0e10cSrcweir using namespace ::com::sun::star::ui;
70*cdf0e10cSrcweir 
71*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
72*cdf0e10cSrcweir //	Namespace
73*cdf0e10cSrcweir //_________________________________________________________________________________________________________________
74*cdf0e10cSrcweir //
75*cdf0e10cSrcweir 
76*cdf0e10cSrcweir static const char CONFIGURATION_ROOT_ACCESS[]               = "/org.openoffice.Office.UI.";
77*cdf0e10cSrcweir static const char CONFIGURATION_WINDOWSTATE_ACCESS[]        = "/UIElements/States";
78*cdf0e10cSrcweir 
79*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_LOCKED[]           = WINDOWSTATE_PROPERTY_LOCKED;
80*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_DOCKED[]           = WINDOWSTATE_PROPERTY_DOCKED;
81*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_VISIBLE[]          = WINDOWSTATE_PROPERTY_VISIBLE;
82*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_DOCKINGAREA[]      = WINDOWSTATE_PROPERTY_DOCKINGAREA;
83*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_DOCKPOS[]          = WINDOWSTATE_PROPERTY_DOCKPOS;
84*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_DOCKSIZE[]         = WINDOWSTATE_PROPERTY_DOCKSIZE;
85*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_POS[]              = WINDOWSTATE_PROPERTY_POS;
86*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_SIZE[]             = WINDOWSTATE_PROPERTY_SIZE;
87*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_UINAME[]           = WINDOWSTATE_PROPERTY_UINAME;
88*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_INTERNALSTATE[]    = WINDOWSTATE_PROPERTY_INTERNALSTATE;
89*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_STYLE[]            = WINDOWSTATE_PROPERTY_STYLE;
90*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_CONTEXT[]          = WINDOWSTATE_PROPERTY_CONTEXT;
91*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_HIDEFROMMENU[]     = WINDOWSTATE_PROPERTY_HIDEFROMENU;
92*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_NOCLOSE[]          = WINDOWSTATE_PROPERTY_NOCLOSE;
93*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_SOFTCLOSE[]        = WINDOWSTATE_PROPERTY_SOFTCLOSE;
94*cdf0e10cSrcweir static const char CONFIGURATION_PROPERTY_CONTEXTACTIVE[]    = WINDOWSTATE_PROPERTY_CONTEXTACTIVE;
95*cdf0e10cSrcweir 
96*cdf0e10cSrcweir // Zero based indexes, order must be the same as WindowStateMask && CONFIGURATION_PROPERTIES!
97*cdf0e10cSrcweir static const sal_Int16 PROPERTY_LOCKED                  = 0;
98*cdf0e10cSrcweir static const sal_Int16 PROPERTY_DOCKED                  = 1;
99*cdf0e10cSrcweir static const sal_Int16 PROPERTY_VISIBLE                 = 2;
100*cdf0e10cSrcweir static const sal_Int16 PROPERTY_CONTEXT                 = 3;
101*cdf0e10cSrcweir static const sal_Int16 PROPERTY_HIDEFROMMENU            = 4;
102*cdf0e10cSrcweir static const sal_Int16 PROPERTY_NOCLOSE                 = 5;
103*cdf0e10cSrcweir static const sal_Int16 PROPERTY_SOFTCLOSE               = 6;
104*cdf0e10cSrcweir static const sal_Int16 PROPERTY_CONTEXTACTIVE           = 7;
105*cdf0e10cSrcweir static const sal_Int16 PROPERTY_DOCKINGAREA             = 8;
106*cdf0e10cSrcweir static const sal_Int16 PROPERTY_POS                     = 9;
107*cdf0e10cSrcweir static const sal_Int16 PROPERTY_SIZE                    = 10;
108*cdf0e10cSrcweir static const sal_Int16 PROPERTY_UINAME                  = 11;
109*cdf0e10cSrcweir static const sal_Int16 PROPERTY_INTERNALSTATE           = 12;
110*cdf0e10cSrcweir static const sal_Int16 PROPERTY_STYLE                   = 13;
111*cdf0e10cSrcweir static const sal_Int16 PROPERTY_DOCKPOS                 = 14;
112*cdf0e10cSrcweir static const sal_Int16 PROPERTY_DOCKSIZE                = 15;
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir // Order must be the same as WindowStateMask!!
115*cdf0e10cSrcweir static const char* CONFIGURATION_PROPERTIES[]           =
116*cdf0e10cSrcweir {
117*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_LOCKED,
118*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_DOCKED,
119*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_VISIBLE,
120*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_CONTEXT,
121*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_HIDEFROMMENU,
122*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_NOCLOSE,
123*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_SOFTCLOSE,
124*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_CONTEXTACTIVE,
125*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_DOCKINGAREA,
126*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_POS,
127*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_SIZE,
128*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_UINAME,
129*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_INTERNALSTATE,
130*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_STYLE,
131*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_DOCKPOS,
132*cdf0e10cSrcweir     CONFIGURATION_PROPERTY_DOCKSIZE,
133*cdf0e10cSrcweir     0
134*cdf0e10cSrcweir };
135*cdf0e10cSrcweir 
136*cdf0e10cSrcweir namespace framework
137*cdf0e10cSrcweir {
138*cdf0e10cSrcweir 
139*cdf0e10cSrcweir //*****************************************************************************************************************
140*cdf0e10cSrcweir //	Configuration access class for WindowState supplier implementation
141*cdf0e10cSrcweir //*****************************************************************************************************************
142*cdf0e10cSrcweir 
143*cdf0e10cSrcweir class ConfigurationAccess_WindowState : // interfaces
144*cdf0e10cSrcweir                                         public  XTypeProvider                            ,
145*cdf0e10cSrcweir                                         public  XNameContainer                           ,
146*cdf0e10cSrcweir                                         public  XContainerListener                       ,
147*cdf0e10cSrcweir                                         // baseclasses
148*cdf0e10cSrcweir 							            // Order is neccessary for right initialization!
149*cdf0e10cSrcweir                                         private ThreadHelpBase                           ,
150*cdf0e10cSrcweir                                         public  ::cppu::OWeakObject
151*cdf0e10cSrcweir {
152*cdf0e10cSrcweir     public:
153*cdf0e10cSrcweir                                   ConfigurationAccess_WindowState( const ::rtl::OUString& aWindowStateConfigFile, const Reference< XMultiServiceFactory >& rServiceManager );
154*cdf0e10cSrcweir         virtual                   ~ConfigurationAccess_WindowState();
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir         //  XInterface, XTypeProvider
157*cdf0e10cSrcweir         FWK_DECLARE_XINTERFACE
158*cdf0e10cSrcweir         FWK_DECLARE_XTYPEPROVIDER
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir         // XNameAccess
161*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Any SAL_CALL getByName( const ::rtl::OUString& aName )
162*cdf0e10cSrcweir             throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getElementNames()
165*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir         virtual sal_Bool SAL_CALL hasByName( const ::rtl::OUString& aName )
168*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir         // XNameContainer
171*cdf0e10cSrcweir         virtual void SAL_CALL removeByName( const ::rtl::OUString& sName )
172*cdf0e10cSrcweir             throw(css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException );
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir         virtual void SAL_CALL insertByName( const ::rtl::OUString& sName, const css::uno::Any&   aPropertySet )
175*cdf0e10cSrcweir             throw(css::lang::IllegalArgumentException, css::container::ElementExistException, css::lang::WrappedTargetException, css::uno::RuntimeException );
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir         // XNameReplace
178*cdf0e10cSrcweir         virtual void SAL_CALL replaceByName( const ::rtl::OUString& sName, const css::uno::Any& aPropertySet )
179*cdf0e10cSrcweir             throw(css::lang::IllegalArgumentException, css::container::NoSuchElementException, css::lang::WrappedTargetException, css::uno::RuntimeException );
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir         // XElementAccess
182*cdf0e10cSrcweir         virtual ::com::sun::star::uno::Type SAL_CALL getElementType()
183*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
184*cdf0e10cSrcweir 
185*cdf0e10cSrcweir         virtual sal_Bool SAL_CALL hasElements()
186*cdf0e10cSrcweir             throw (::com::sun::star::uno::RuntimeException);
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir         // container.XContainerListener
189*cdf0e10cSrcweir         virtual void SAL_CALL     elementInserted( const ContainerEvent& aEvent ) throw(RuntimeException);
190*cdf0e10cSrcweir         virtual void SAL_CALL     elementRemoved ( const ContainerEvent& aEvent ) throw(RuntimeException);
191*cdf0e10cSrcweir         virtual void SAL_CALL     elementReplaced( const ContainerEvent& aEvent ) throw(RuntimeException);
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir         // lang.XEventListener
194*cdf0e10cSrcweir         virtual void SAL_CALL disposing( const EventObject& aEvent ) throw(RuntimeException);
195*cdf0e10cSrcweir 
196*cdf0e10cSrcweir     protected:
197*cdf0e10cSrcweir         enum WindowStateMask
198*cdf0e10cSrcweir         {
199*cdf0e10cSrcweir             WINDOWSTATE_MASK_LOCKED         = 1,
200*cdf0e10cSrcweir             WINDOWSTATE_MASK_DOCKED         = 2,
201*cdf0e10cSrcweir             WINDOWSTATE_MASK_VISIBLE        = 4,
202*cdf0e10cSrcweir             WINDOWSTATE_MASK_CONTEXT        = 8,
203*cdf0e10cSrcweir             WINDOWSTATE_MASK_HIDEFROMMENU   = 16,
204*cdf0e10cSrcweir             WINDOWSTATE_MASK_NOCLOSE        = 32,
205*cdf0e10cSrcweir             WINDOWSTATE_MASK_SOFTCLOSE      = 64,
206*cdf0e10cSrcweir             WINDOWSTATE_MASK_CONTEXTACTIVE  = 128,
207*cdf0e10cSrcweir             WINDOWSTATE_MASK_DOCKINGAREA    = 256,
208*cdf0e10cSrcweir             WINDOWSTATE_MASK_POS            = 512,
209*cdf0e10cSrcweir             WINDOWSTATE_MASK_SIZE           = 1024,
210*cdf0e10cSrcweir             WINDOWSTATE_MASK_UINAME         = 2048,
211*cdf0e10cSrcweir             WINDOWSTATE_MASK_INTERNALSTATE  = 4096,
212*cdf0e10cSrcweir             WINDOWSTATE_MASK_STYLE          = 8192,
213*cdf0e10cSrcweir             WINDOWSTATE_MASK_DOCKPOS        = 16384,
214*cdf0e10cSrcweir             WINDOWSTATE_MASK_DOCKSIZE       = 32768
215*cdf0e10cSrcweir         };
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         // Cache structure. Valid values are described by tje eMask member. All other values should not be
218*cdf0e10cSrcweir         // provided to outside code!
219*cdf0e10cSrcweir         struct WindowStateInfo
220*cdf0e10cSrcweir         {
221*cdf0e10cSrcweir             WindowStateInfo() : aDockingArea( ::com::sun::star::ui::DockingArea_DOCKINGAREA_TOP ),
222*cdf0e10cSrcweir                                 aDockPos( 0, 0 ),
223*cdf0e10cSrcweir                                 aPos( 0, 0 ),
224*cdf0e10cSrcweir                                 aSize( 0, 0 ),
225*cdf0e10cSrcweir                                 nInternalState( 0 ),
226*cdf0e10cSrcweir                                 nStyle( 0 ),
227*cdf0e10cSrcweir                                 nMask( 0 ) {}
228*cdf0e10cSrcweir 
229*cdf0e10cSrcweir             bool                                    bLocked : 1,
230*cdf0e10cSrcweir                                                     bDocked : 1,
231*cdf0e10cSrcweir                                                     bVisible : 1,
232*cdf0e10cSrcweir                                                     bContext : 1,
233*cdf0e10cSrcweir                                                     bHideFromMenu : 1,
234*cdf0e10cSrcweir                                                     bNoClose : 1,
235*cdf0e10cSrcweir                                                     bSoftClose : 1,
236*cdf0e10cSrcweir                                                     bContextActive : 1;
237*cdf0e10cSrcweir             ::com::sun::star::ui::DockingArea       aDockingArea;
238*cdf0e10cSrcweir             com::sun::star::awt::Point              aDockPos;
239*cdf0e10cSrcweir             com::sun::star::awt::Size               aDockSize;
240*cdf0e10cSrcweir             com::sun::star::awt::Point              aPos;
241*cdf0e10cSrcweir             com::sun::star::awt::Size               aSize;
242*cdf0e10cSrcweir             rtl::OUString                           aUIName;
243*cdf0e10cSrcweir             sal_uInt32                              nInternalState;
244*cdf0e10cSrcweir             sal_uInt16                              nStyle;
245*cdf0e10cSrcweir             sal_uInt32                              nMask; // see WindowStateMask
246*cdf0e10cSrcweir         };
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir         void                      impl_putPropertiesFromStruct( const WindowStateInfo& rWinStateInfo, Reference< XPropertySet >& xPropSet );
249*cdf0e10cSrcweir         Any                       impl_insertCacheAndReturnSequence( const rtl::OUString& rResourceURL, Reference< XNameAccess >& rNameAccess );
250*cdf0e10cSrcweir         WindowStateInfo&          impl_insertCacheAndReturnWinState( const rtl::OUString& rResourceURL, Reference< XNameAccess >& rNameAccess );
251*cdf0e10cSrcweir         Any                       impl_getSequenceFromStruct( const WindowStateInfo& rWinStateInfo );
252*cdf0e10cSrcweir         void                      impl_fillStructFromSequence( WindowStateInfo& rWinStateInfo, const Sequence< PropertyValue >& rSeq );
253*cdf0e10cSrcweir         Any                       impl_getWindowStateFromResourceURL( const rtl::OUString& rResourceURL );
254*cdf0e10cSrcweir         sal_Bool                  impl_initializeConfigAccess();
255*cdf0e10cSrcweir 
256*cdf0e10cSrcweir     private:
257*cdf0e10cSrcweir         typedef ::std::hash_map< ::rtl::OUString,
258*cdf0e10cSrcweir                                  WindowStateInfo,
259*cdf0e10cSrcweir                                  OUStringHashCode,
260*cdf0e10cSrcweir                                  ::std::equal_to< ::rtl::OUString > > ResourceURLToInfoCache;
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir         rtl::OUString                     m_aConfigWindowAccess;
263*cdf0e10cSrcweir         Reference< XMultiServiceFactory > m_xServiceManager;
264*cdf0e10cSrcweir         Reference< XMultiServiceFactory > m_xConfigProvider;
265*cdf0e10cSrcweir         Reference< XNameAccess >          m_xConfigAccess;
266*cdf0e10cSrcweir         ResourceURLToInfoCache            m_aResourceURLToInfoCache;
267*cdf0e10cSrcweir         sal_Bool                          m_bConfigAccessInitialized : 1,
268*cdf0e10cSrcweir                                           m_bModified : 1;
269*cdf0e10cSrcweir         std::vector< ::rtl::OUString >           m_aPropArray;
270*cdf0e10cSrcweir };
271*cdf0e10cSrcweir 
272*cdf0e10cSrcweir //*****************************************************************************************************************
273*cdf0e10cSrcweir //	XInterface, XTypeProvider
274*cdf0e10cSrcweir //*****************************************************************************************************************
275*cdf0e10cSrcweir DEFINE_XINTERFACE_7     (   ConfigurationAccess_WindowState                                                   ,
276*cdf0e10cSrcweir                             OWeakObject                                                                     ,
277*cdf0e10cSrcweir                             DIRECT_INTERFACE ( css::container::XNameContainer                               ),
278*cdf0e10cSrcweir                             DIRECT_INTERFACE ( css::container::XContainerListener                           ),
279*cdf0e10cSrcweir                             DIRECT_INTERFACE ( css::lang::XTypeProvider                                     ),
280*cdf0e10cSrcweir                             DERIVED_INTERFACE( css::container::XElementAccess, css::container::XNameAccess  ),
281*cdf0e10cSrcweir                             DERIVED_INTERFACE( css::container::XNameAccess, css::container::XNameReplace    ),
282*cdf0e10cSrcweir                             DERIVED_INTERFACE( css::container::XNameReplace, css::container::XNameContainer ),
283*cdf0e10cSrcweir                             DERIVED_INTERFACE( css::lang::XEventListener, XContainerListener                )
284*cdf0e10cSrcweir 						)
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_7  (   ConfigurationAccess_WindowState         ,
287*cdf0e10cSrcweir                             css::container::XNameContainer          ,
288*cdf0e10cSrcweir                             css::container::XNameReplace            ,
289*cdf0e10cSrcweir                             css::container::XNameAccess             ,
290*cdf0e10cSrcweir                             css::container::XElementAccess          ,
291*cdf0e10cSrcweir                             css::container::XContainerListener      ,
292*cdf0e10cSrcweir                             css::lang::XEventListener               ,
293*cdf0e10cSrcweir                             css::lang::XTypeProvider
294*cdf0e10cSrcweir 						)
295*cdf0e10cSrcweir 
296*cdf0e10cSrcweir ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const rtl::OUString& aModuleName, const Reference< XMultiServiceFactory >& rServiceManager ) :
297*cdf0e10cSrcweir     ThreadHelpBase(),
298*cdf0e10cSrcweir     m_aConfigWindowAccess( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_ROOT_ACCESS )),
299*cdf0e10cSrcweir     m_xServiceManager( rServiceManager ),
300*cdf0e10cSrcweir     m_bConfigAccessInitialized( sal_False ),
301*cdf0e10cSrcweir     m_bModified( sal_False )
302*cdf0e10cSrcweir {
303*cdf0e10cSrcweir     // Create configuration hierachical access name
304*cdf0e10cSrcweir     m_aConfigWindowAccess += aModuleName;
305*cdf0e10cSrcweir     m_aConfigWindowAccess += rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( CONFIGURATION_WINDOWSTATE_ACCESS ));
306*cdf0e10cSrcweir     m_xConfigProvider = Reference< XMultiServiceFactory >( rServiceManager->createInstance( SERVICENAME_CFGPROVIDER ), UNO_QUERY );
307*cdf0e10cSrcweir 
308*cdf0e10cSrcweir     // Initialize access array with property names.
309*cdf0e10cSrcweir     sal_Int32 n = 0;
310*cdf0e10cSrcweir     while ( CONFIGURATION_PROPERTIES[n] )
311*cdf0e10cSrcweir     {
312*cdf0e10cSrcweir         m_aPropArray.push_back( ::rtl::OUString::createFromAscii( CONFIGURATION_PROPERTIES[n] ));
313*cdf0e10cSrcweir         ++n;
314*cdf0e10cSrcweir     }
315*cdf0e10cSrcweir }
316*cdf0e10cSrcweir 
317*cdf0e10cSrcweir ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState()
318*cdf0e10cSrcweir {
319*cdf0e10cSrcweir     // SAFE
320*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
321*cdf0e10cSrcweir     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
322*cdf0e10cSrcweir     if ( xContainer.is() )
323*cdf0e10cSrcweir         xContainer->removeContainerListener( this );
324*cdf0e10cSrcweir }
325*cdf0e10cSrcweir 
326*cdf0e10cSrcweir // XNameAccess
327*cdf0e10cSrcweir Any SAL_CALL ConfigurationAccess_WindowState::getByName( const ::rtl::OUString& rResourceURL )
328*cdf0e10cSrcweir throw ( NoSuchElementException, WrappedTargetException, RuntimeException)
329*cdf0e10cSrcweir {
330*cdf0e10cSrcweir     // SAFE
331*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir     ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
334*cdf0e10cSrcweir     if ( pIter != m_aResourceURLToInfoCache.end() )
335*cdf0e10cSrcweir         return impl_getSequenceFromStruct( pIter->second );
336*cdf0e10cSrcweir     else
337*cdf0e10cSrcweir     {
338*cdf0e10cSrcweir         Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
339*cdf0e10cSrcweir         if ( a == Any() )
340*cdf0e10cSrcweir             throw NoSuchElementException();
341*cdf0e10cSrcweir         else
342*cdf0e10cSrcweir             return a;
343*cdf0e10cSrcweir     }
344*cdf0e10cSrcweir }
345*cdf0e10cSrcweir 
346*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL ConfigurationAccess_WindowState::getElementNames()
347*cdf0e10cSrcweir throw ( RuntimeException )
348*cdf0e10cSrcweir {
349*cdf0e10cSrcweir     // SAFE
350*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
351*cdf0e10cSrcweir 
352*cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
353*cdf0e10cSrcweir     {
354*cdf0e10cSrcweir         impl_initializeConfigAccess();
355*cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
356*cdf0e10cSrcweir     }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir     if ( m_xConfigAccess.is() )
359*cdf0e10cSrcweir         return m_xConfigAccess->getElementNames();
360*cdf0e10cSrcweir     else
361*cdf0e10cSrcweir         return Sequence< ::rtl::OUString > ();
362*cdf0e10cSrcweir }
363*cdf0e10cSrcweir 
364*cdf0e10cSrcweir sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName( const ::rtl::OUString& rResourceURL )
365*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
366*cdf0e10cSrcweir {
367*cdf0e10cSrcweir     // SAFE
368*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
369*cdf0e10cSrcweir 
370*cdf0e10cSrcweir     ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
371*cdf0e10cSrcweir     if ( pIter != m_aResourceURLToInfoCache.end() )
372*cdf0e10cSrcweir         return sal_True;
373*cdf0e10cSrcweir     else
374*cdf0e10cSrcweir     {
375*cdf0e10cSrcweir         Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
376*cdf0e10cSrcweir         if ( a == Any() )
377*cdf0e10cSrcweir             return sal_False;
378*cdf0e10cSrcweir         else
379*cdf0e10cSrcweir             return sal_True;
380*cdf0e10cSrcweir     }
381*cdf0e10cSrcweir }
382*cdf0e10cSrcweir 
383*cdf0e10cSrcweir // XElementAccess
384*cdf0e10cSrcweir Type SAL_CALL ConfigurationAccess_WindowState::getElementType()
385*cdf0e10cSrcweir throw ( RuntimeException )
386*cdf0e10cSrcweir {
387*cdf0e10cSrcweir     return( ::getCppuType( (const Sequence< PropertyValue >*)NULL ) );
388*cdf0e10cSrcweir }
389*cdf0e10cSrcweir 
390*cdf0e10cSrcweir sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements()
391*cdf0e10cSrcweir throw ( RuntimeException )
392*cdf0e10cSrcweir {
393*cdf0e10cSrcweir     // SAFE
394*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
395*cdf0e10cSrcweir 
396*cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
397*cdf0e10cSrcweir     {
398*cdf0e10cSrcweir         impl_initializeConfigAccess();
399*cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
400*cdf0e10cSrcweir     }
401*cdf0e10cSrcweir 
402*cdf0e10cSrcweir     if ( m_xConfigAccess.is() )
403*cdf0e10cSrcweir         return m_xConfigAccess->hasElements();
404*cdf0e10cSrcweir     else
405*cdf0e10cSrcweir         return sal_False;
406*cdf0e10cSrcweir }
407*cdf0e10cSrcweir 
408*cdf0e10cSrcweir // XNameContainer
409*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::removeByName( const ::rtl::OUString& rResourceURL )
410*cdf0e10cSrcweir throw( NoSuchElementException, WrappedTargetException, RuntimeException )
411*cdf0e10cSrcweir {
412*cdf0e10cSrcweir     // SAFE
413*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
414*cdf0e10cSrcweir 
415*cdf0e10cSrcweir     ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
416*cdf0e10cSrcweir     if ( pIter != m_aResourceURLToInfoCache.end() )
417*cdf0e10cSrcweir         m_aResourceURLToInfoCache.erase( pIter );
418*cdf0e10cSrcweir 
419*cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
420*cdf0e10cSrcweir     {
421*cdf0e10cSrcweir         impl_initializeConfigAccess();
422*cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
423*cdf0e10cSrcweir     }
424*cdf0e10cSrcweir 
425*cdf0e10cSrcweir     try
426*cdf0e10cSrcweir     {
427*cdf0e10cSrcweir         // Remove must be write-through => remove element from configuration
428*cdf0e10cSrcweir         Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
429*cdf0e10cSrcweir         if ( xNameContainer.is() )
430*cdf0e10cSrcweir         {
431*cdf0e10cSrcweir             aLock.unlock();
432*cdf0e10cSrcweir 
433*cdf0e10cSrcweir             xNameContainer->removeByName( rResourceURL );
434*cdf0e10cSrcweir             Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
435*cdf0e10cSrcweir             if ( xFlush.is() )
436*cdf0e10cSrcweir                 xFlush->commitChanges();
437*cdf0e10cSrcweir         }
438*cdf0e10cSrcweir     }
439*cdf0e10cSrcweir     catch ( com::sun::star::lang::WrappedTargetException& )
440*cdf0e10cSrcweir     {
441*cdf0e10cSrcweir     }
442*cdf0e10cSrcweir }
443*cdf0e10cSrcweir 
444*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::insertByName( const ::rtl::OUString& rResourceURL, const css::uno::Any& aPropertySet )
445*cdf0e10cSrcweir throw( IllegalArgumentException, ElementExistException, WrappedTargetException, RuntimeException )
446*cdf0e10cSrcweir {
447*cdf0e10cSrcweir     // SAFE
448*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
449*cdf0e10cSrcweir 
450*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSet;
451*cdf0e10cSrcweir     if ( aPropertySet >>= aPropSet )
452*cdf0e10cSrcweir     {
453*cdf0e10cSrcweir         ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
454*cdf0e10cSrcweir         if ( pIter != m_aResourceURLToInfoCache.end() )
455*cdf0e10cSrcweir             throw ElementExistException();
456*cdf0e10cSrcweir         else
457*cdf0e10cSrcweir         {
458*cdf0e10cSrcweir             if ( !m_bConfigAccessInitialized )
459*cdf0e10cSrcweir             {
460*cdf0e10cSrcweir                 impl_initializeConfigAccess();
461*cdf0e10cSrcweir                 m_bConfigAccessInitialized = sal_True;
462*cdf0e10cSrcweir             }
463*cdf0e10cSrcweir 
464*cdf0e10cSrcweir             // Try to ask our configuration access
465*cdf0e10cSrcweir             if ( m_xConfigAccess.is() )
466*cdf0e10cSrcweir             {
467*cdf0e10cSrcweir                 if ( m_xConfigAccess->hasByName( rResourceURL ) )
468*cdf0e10cSrcweir                     throw ElementExistException();
469*cdf0e10cSrcweir                 else
470*cdf0e10cSrcweir                 {
471*cdf0e10cSrcweir                     WindowStateInfo aWinStateInfo;
472*cdf0e10cSrcweir                     impl_fillStructFromSequence( aWinStateInfo, aPropSet );
473*cdf0e10cSrcweir                     m_aResourceURLToInfoCache.insert( ResourceURLToInfoCache::value_type( rResourceURL, aWinStateInfo ));
474*cdf0e10cSrcweir 
475*cdf0e10cSrcweir                     // insert must be write-through => insert element into configuration
476*cdf0e10cSrcweir                     Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
477*cdf0e10cSrcweir                     if ( xNameContainer.is() )
478*cdf0e10cSrcweir                     {
479*cdf0e10cSrcweir                         Reference< XSingleServiceFactory > xFactory( m_xConfigAccess, UNO_QUERY );
480*cdf0e10cSrcweir                         aLock.unlock();
481*cdf0e10cSrcweir 
482*cdf0e10cSrcweir                         try
483*cdf0e10cSrcweir                         {
484*cdf0e10cSrcweir                             Reference< XPropertySet > xPropSet( xFactory->createInstance(), UNO_QUERY );
485*cdf0e10cSrcweir                             if ( xPropSet.is() )
486*cdf0e10cSrcweir                             {
487*cdf0e10cSrcweir                                 Any a;
488*cdf0e10cSrcweir                                 impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
489*cdf0e10cSrcweir                                 a <<= xPropSet;
490*cdf0e10cSrcweir                                 xNameContainer->insertByName( rResourceURL, a );
491*cdf0e10cSrcweir                                 Reference< XChangesBatch > xFlush( xFactory, UNO_QUERY );
492*cdf0e10cSrcweir                                 if ( xFlush.is() )
493*cdf0e10cSrcweir                                     xFlush->commitChanges();
494*cdf0e10cSrcweir                             }
495*cdf0e10cSrcweir                         }
496*cdf0e10cSrcweir                         catch ( Exception& )
497*cdf0e10cSrcweir                         {
498*cdf0e10cSrcweir                         }
499*cdf0e10cSrcweir                     }
500*cdf0e10cSrcweir                 }
501*cdf0e10cSrcweir             }
502*cdf0e10cSrcweir         }
503*cdf0e10cSrcweir     }
504*cdf0e10cSrcweir     else
505*cdf0e10cSrcweir         throw IllegalArgumentException();
506*cdf0e10cSrcweir }
507*cdf0e10cSrcweir 
508*cdf0e10cSrcweir // XNameReplace
509*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::replaceByName( const ::rtl::OUString& rResourceURL, const css::uno::Any& aPropertySet )
510*cdf0e10cSrcweir throw( IllegalArgumentException, NoSuchElementException, WrappedTargetException, RuntimeException )
511*cdf0e10cSrcweir {
512*cdf0e10cSrcweir     // SAFE
513*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSet;
516*cdf0e10cSrcweir     if ( aPropertySet >>= aPropSet )
517*cdf0e10cSrcweir     {
518*cdf0e10cSrcweir         ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
519*cdf0e10cSrcweir         if ( pIter != m_aResourceURLToInfoCache.end() )
520*cdf0e10cSrcweir         {
521*cdf0e10cSrcweir             WindowStateInfo& rWinStateInfo = pIter->second;
522*cdf0e10cSrcweir             impl_fillStructFromSequence( rWinStateInfo, aPropSet );
523*cdf0e10cSrcweir             m_bModified = sal_True;
524*cdf0e10cSrcweir         }
525*cdf0e10cSrcweir         else
526*cdf0e10cSrcweir         {
527*cdf0e10cSrcweir             if ( !m_bConfigAccessInitialized )
528*cdf0e10cSrcweir             {
529*cdf0e10cSrcweir                 impl_initializeConfigAccess();
530*cdf0e10cSrcweir                 m_bConfigAccessInitialized = sal_True;
531*cdf0e10cSrcweir             }
532*cdf0e10cSrcweir 
533*cdf0e10cSrcweir             // Try to ask our configuration access
534*cdf0e10cSrcweir             Reference< XNameAccess > xNameAccess;
535*cdf0e10cSrcweir             Any a( m_xConfigAccess->getByName( rResourceURL ));
536*cdf0e10cSrcweir 
537*cdf0e10cSrcweir             if ( a >>= xNameAccess )
538*cdf0e10cSrcweir             {
539*cdf0e10cSrcweir                 WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess ));
540*cdf0e10cSrcweir                 impl_fillStructFromSequence( rWinStateInfo, aPropSet );
541*cdf0e10cSrcweir                 m_bModified = sal_True;
542*cdf0e10cSrcweir                 pIter = m_aResourceURLToInfoCache.find( rResourceURL );
543*cdf0e10cSrcweir             }
544*cdf0e10cSrcweir             else
545*cdf0e10cSrcweir                 throw NoSuchElementException();
546*cdf0e10cSrcweir         }
547*cdf0e10cSrcweir 
548*cdf0e10cSrcweir         if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() )
549*cdf0e10cSrcweir         {
550*cdf0e10cSrcweir             Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
551*cdf0e10cSrcweir             if ( xNameContainer.is() )
552*cdf0e10cSrcweir             {
553*cdf0e10cSrcweir                 WindowStateInfo aWinStateInfo( pIter->second );
554*cdf0e10cSrcweir                 ::rtl::OUString        aResourceURL( pIter->first );
555*cdf0e10cSrcweir                 m_bModified = sal_False;
556*cdf0e10cSrcweir                 aLock.unlock();
557*cdf0e10cSrcweir 
558*cdf0e10cSrcweir                 try
559*cdf0e10cSrcweir                 {
560*cdf0e10cSrcweir                     Reference< XPropertySet > xPropSet;
561*cdf0e10cSrcweir                     if ( xNameContainer->getByName( aResourceURL ) >>= xPropSet )
562*cdf0e10cSrcweir                     {
563*cdf0e10cSrcweir                         impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
564*cdf0e10cSrcweir 
565*cdf0e10cSrcweir                         Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
566*cdf0e10cSrcweir                         if ( xFlush.is() )
567*cdf0e10cSrcweir                             xFlush->commitChanges();
568*cdf0e10cSrcweir                     }
569*cdf0e10cSrcweir                 }
570*cdf0e10cSrcweir                 catch ( Exception& )
571*cdf0e10cSrcweir                 {
572*cdf0e10cSrcweir                 }
573*cdf0e10cSrcweir             }
574*cdf0e10cSrcweir         }
575*cdf0e10cSrcweir     }
576*cdf0e10cSrcweir     else
577*cdf0e10cSrcweir         throw IllegalArgumentException();
578*cdf0e10cSrcweir }
579*cdf0e10cSrcweir 
580*cdf0e10cSrcweir // container.XContainerListener
581*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::elementInserted( const ContainerEvent& ) throw(RuntimeException)
582*cdf0e10cSrcweir {
583*cdf0e10cSrcweir     // do nothing - next time someone wants to retrieve this node we will find it in the configuration
584*cdf0e10cSrcweir }
585*cdf0e10cSrcweir 
586*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::elementRemoved ( const ContainerEvent& ) throw(RuntimeException)
587*cdf0e10cSrcweir {
588*cdf0e10cSrcweir     //
589*cdf0e10cSrcweir }
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::elementReplaced( const ContainerEvent& ) throw(RuntimeException)
592*cdf0e10cSrcweir {
593*cdf0e10cSrcweir     //
594*cdf0e10cSrcweir }
595*cdf0e10cSrcweir 
596*cdf0e10cSrcweir // lang.XEventListener
597*cdf0e10cSrcweir void SAL_CALL ConfigurationAccess_WindowState::disposing( const EventObject& aEvent ) throw(RuntimeException)
598*cdf0e10cSrcweir {
599*cdf0e10cSrcweir     // SAFE
600*cdf0e10cSrcweir     // remove our reference to the config access
601*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
602*cdf0e10cSrcweir 
603*cdf0e10cSrcweir     Reference< XInterface > xIfac1( aEvent.Source, UNO_QUERY );
604*cdf0e10cSrcweir     Reference< XInterface > xIfac2( m_xConfigAccess, UNO_QUERY );
605*cdf0e10cSrcweir     if ( xIfac1 == xIfac2 )
606*cdf0e10cSrcweir         m_xConfigAccess.clear();
607*cdf0e10cSrcweir }
608*cdf0e10cSrcweir 
609*cdf0e10cSrcweir // private helper methods
610*cdf0e10cSrcweir Any ConfigurationAccess_WindowState::impl_getSequenceFromStruct( const WindowStateInfo& rWinStateInfo )
611*cdf0e10cSrcweir {
612*cdf0e10cSrcweir     sal_Int32                 i( 0 );
613*cdf0e10cSrcweir     sal_Int32                 nCount( m_aPropArray.size() );
614*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSeq;
615*cdf0e10cSrcweir 
616*cdf0e10cSrcweir     for ( i = 0; i < nCount; i++ )
617*cdf0e10cSrcweir     {
618*cdf0e10cSrcweir         if ( rWinStateInfo.nMask & ( 1 << i ))
619*cdf0e10cSrcweir         {
620*cdf0e10cSrcweir             // put value into the return sequence
621*cdf0e10cSrcweir             sal_Int32 nIndex( aPropSeq.getLength());
622*cdf0e10cSrcweir             aPropSeq.realloc( nIndex+1 );
623*cdf0e10cSrcweir             aPropSeq[nIndex].Name = m_aPropArray[i];
624*cdf0e10cSrcweir 
625*cdf0e10cSrcweir             switch ( i )
626*cdf0e10cSrcweir             {
627*cdf0e10cSrcweir                 case PROPERTY_LOCKED:
628*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bLocked ); break;
629*cdf0e10cSrcweir                 case PROPERTY_DOCKED:
630*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bDocked ); break;
631*cdf0e10cSrcweir                 case PROPERTY_VISIBLE:
632*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bVisible ); break;
633*cdf0e10cSrcweir                 case PROPERTY_CONTEXT:
634*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bContext ); break;
635*cdf0e10cSrcweir                 case PROPERTY_HIDEFROMMENU:
636*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bHideFromMenu ); break;
637*cdf0e10cSrcweir                 case PROPERTY_NOCLOSE:
638*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bNoClose ); break;
639*cdf0e10cSrcweir                 case PROPERTY_SOFTCLOSE:
640*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bSoftClose ); break;
641*cdf0e10cSrcweir                 case PROPERTY_CONTEXTACTIVE:
642*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bContextActive ); break;
643*cdf0e10cSrcweir                 case PROPERTY_DOCKINGAREA:
644*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aDockingArea ); break;
645*cdf0e10cSrcweir                 case PROPERTY_POS:
646*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aPos ); break;
647*cdf0e10cSrcweir                 case PROPERTY_SIZE:
648*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aSize ); break;
649*cdf0e10cSrcweir                 case PROPERTY_UINAME:
650*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aUIName ); break;
651*cdf0e10cSrcweir                 case PROPERTY_INTERNALSTATE:
652*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( sal_Int32( rWinStateInfo.nInternalState )); break;
653*cdf0e10cSrcweir                 case PROPERTY_STYLE:
654*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( sal_Int16( rWinStateInfo.nStyle )); break;
655*cdf0e10cSrcweir                 case PROPERTY_DOCKPOS:
656*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aDockPos ); break;
657*cdf0e10cSrcweir                 case PROPERTY_DOCKSIZE:
658*cdf0e10cSrcweir                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aDockSize ); break;
659*cdf0e10cSrcweir                 default:
660*cdf0e10cSrcweir                     DBG_ASSERT( sal_False, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
661*cdf0e10cSrcweir             }
662*cdf0e10cSrcweir         }
663*cdf0e10cSrcweir     }
664*cdf0e10cSrcweir 
665*cdf0e10cSrcweir     return makeAny( aPropSeq );
666*cdf0e10cSrcweir }
667*cdf0e10cSrcweir 
668*cdf0e10cSrcweir Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const rtl::OUString& rResourceURL, Reference< XNameAccess >& xNameAccess )
669*cdf0e10cSrcweir {
670*cdf0e10cSrcweir     sal_Int32                 nMask( 0 );
671*cdf0e10cSrcweir     sal_Int32                 nCount( m_aPropArray.size() );
672*cdf0e10cSrcweir     sal_Int32                 i( 0 );
673*cdf0e10cSrcweir     sal_Int32                 nIndex( 0 );
674*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSeq;
675*cdf0e10cSrcweir     WindowStateInfo           aWindowStateInfo;
676*cdf0e10cSrcweir 
677*cdf0e10cSrcweir     for ( i = 0; i < nCount; i++ )
678*cdf0e10cSrcweir     {
679*cdf0e10cSrcweir         try
680*cdf0e10cSrcweir         {
681*cdf0e10cSrcweir             bool    bAddToSeq( false );
682*cdf0e10cSrcweir             Any     a( xNameAccess->getByName( m_aPropArray[i] ) );
683*cdf0e10cSrcweir             switch ( i )
684*cdf0e10cSrcweir             {
685*cdf0e10cSrcweir                 case PROPERTY_LOCKED:
686*cdf0e10cSrcweir                 case PROPERTY_DOCKED:
687*cdf0e10cSrcweir                 case PROPERTY_VISIBLE:
688*cdf0e10cSrcweir                 case PROPERTY_CONTEXT:
689*cdf0e10cSrcweir                 case PROPERTY_HIDEFROMMENU:
690*cdf0e10cSrcweir                 case PROPERTY_NOCLOSE:
691*cdf0e10cSrcweir                 case PROPERTY_SOFTCLOSE:
692*cdf0e10cSrcweir                 case PROPERTY_CONTEXTACTIVE:
693*cdf0e10cSrcweir                 {
694*cdf0e10cSrcweir                     sal_Bool bValue = sal_Bool();
695*cdf0e10cSrcweir                     if ( a >>= bValue )
696*cdf0e10cSrcweir                     {
697*cdf0e10cSrcweir                         sal_Int32 nValue( 1 << i );
698*cdf0e10cSrcweir                         nMask |= nValue;
699*cdf0e10cSrcweir                         bAddToSeq = true;
700*cdf0e10cSrcweir                         switch ( i )
701*cdf0e10cSrcweir                         {
702*cdf0e10cSrcweir                             case PROPERTY_LOCKED:
703*cdf0e10cSrcweir                                 aWindowStateInfo.bLocked = bValue; break;
704*cdf0e10cSrcweir                             case PROPERTY_DOCKED:
705*cdf0e10cSrcweir                                 aWindowStateInfo.bDocked = bValue; break;
706*cdf0e10cSrcweir                             case PROPERTY_VISIBLE:
707*cdf0e10cSrcweir                                 aWindowStateInfo.bVisible = bValue; break;
708*cdf0e10cSrcweir                             case PROPERTY_CONTEXT:
709*cdf0e10cSrcweir                                 aWindowStateInfo.bContext = bValue; break;
710*cdf0e10cSrcweir                             case PROPERTY_HIDEFROMMENU:
711*cdf0e10cSrcweir                                 aWindowStateInfo.bHideFromMenu = bValue; break;
712*cdf0e10cSrcweir                             case PROPERTY_NOCLOSE:
713*cdf0e10cSrcweir                                 aWindowStateInfo.bNoClose = bValue; break;
714*cdf0e10cSrcweir                             case PROPERTY_SOFTCLOSE:
715*cdf0e10cSrcweir                                 aWindowStateInfo.bSoftClose = bValue; break;
716*cdf0e10cSrcweir                             case PROPERTY_CONTEXTACTIVE:
717*cdf0e10cSrcweir                                 aWindowStateInfo.bContextActive = bValue; break;
718*cdf0e10cSrcweir                         }
719*cdf0e10cSrcweir                     }
720*cdf0e10cSrcweir                 }
721*cdf0e10cSrcweir                 break;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir                 case PROPERTY_DOCKINGAREA:
724*cdf0e10cSrcweir                 {
725*cdf0e10cSrcweir                     sal_Int32 nDockingArea = 0;
726*cdf0e10cSrcweir                     if ( a >>= nDockingArea )
727*cdf0e10cSrcweir                     {
728*cdf0e10cSrcweir                         if (( nDockingArea >= 0 ) &&
729*cdf0e10cSrcweir                             ( nDockingArea <= sal_Int32( DockingArea_DOCKINGAREA_RIGHT )))
730*cdf0e10cSrcweir                         {
731*cdf0e10cSrcweir                             aWindowStateInfo.aDockingArea = (DockingArea)nDockingArea;
732*cdf0e10cSrcweir                             nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
733*cdf0e10cSrcweir                             a = makeAny( aWindowStateInfo.aDockingArea );
734*cdf0e10cSrcweir                             bAddToSeq = true;
735*cdf0e10cSrcweir                         }
736*cdf0e10cSrcweir                     }
737*cdf0e10cSrcweir                 }
738*cdf0e10cSrcweir                 break;
739*cdf0e10cSrcweir 
740*cdf0e10cSrcweir                 case PROPERTY_POS:
741*cdf0e10cSrcweir                 case PROPERTY_DOCKPOS:
742*cdf0e10cSrcweir                 {
743*cdf0e10cSrcweir                     ::rtl::OUString aString;
744*cdf0e10cSrcweir                     if ( a >>= aString )
745*cdf0e10cSrcweir                     {
746*cdf0e10cSrcweir                         sal_Int32 nToken( 0 );
747*cdf0e10cSrcweir                         ::rtl::OUString aXStr = aString.getToken( 0, ',', nToken );
748*cdf0e10cSrcweir                         if ( nToken > 0 )
749*cdf0e10cSrcweir                         {
750*cdf0e10cSrcweir                             com::sun::star::awt::Point aPos;
751*cdf0e10cSrcweir                             aPos.X = aXStr.toInt32();
752*cdf0e10cSrcweir                             aPos.Y = aString.getToken( 0, ',', nToken ).toInt32();
753*cdf0e10cSrcweir 
754*cdf0e10cSrcweir                             if ( i == PROPERTY_POS )
755*cdf0e10cSrcweir                             {
756*cdf0e10cSrcweir                                 aWindowStateInfo.aPos = aPos;
757*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_POS;
758*cdf0e10cSrcweir                             }
759*cdf0e10cSrcweir                             else
760*cdf0e10cSrcweir                             {
761*cdf0e10cSrcweir                                 aWindowStateInfo.aDockPos = aPos;
762*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_DOCKPOS;
763*cdf0e10cSrcweir                             }
764*cdf0e10cSrcweir 
765*cdf0e10cSrcweir                             a <<= aPos;
766*cdf0e10cSrcweir                             bAddToSeq = true;
767*cdf0e10cSrcweir                         }
768*cdf0e10cSrcweir                     }
769*cdf0e10cSrcweir                 }
770*cdf0e10cSrcweir                 break;
771*cdf0e10cSrcweir 
772*cdf0e10cSrcweir                 case PROPERTY_SIZE:
773*cdf0e10cSrcweir                 case PROPERTY_DOCKSIZE:
774*cdf0e10cSrcweir                 {
775*cdf0e10cSrcweir                     ::rtl::OUString aString;
776*cdf0e10cSrcweir                     if ( a >>= aString )
777*cdf0e10cSrcweir                     {
778*cdf0e10cSrcweir                         sal_Int32 nToken( 0 );
779*cdf0e10cSrcweir                         ::rtl::OUString aStr = aString.getToken( 0, ',', nToken );
780*cdf0e10cSrcweir                         if ( nToken > 0 )
781*cdf0e10cSrcweir                         {
782*cdf0e10cSrcweir                             com::sun::star::awt::Size aSize;
783*cdf0e10cSrcweir                             aSize.Width = aStr.toInt32();
784*cdf0e10cSrcweir                             aSize.Height = aString.getToken( 0, ',', nToken ).toInt32();
785*cdf0e10cSrcweir                             if ( i == PROPERTY_SIZE )
786*cdf0e10cSrcweir                             {
787*cdf0e10cSrcweir                                 aWindowStateInfo.aSize = aSize;
788*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_SIZE;
789*cdf0e10cSrcweir                             }
790*cdf0e10cSrcweir                             else
791*cdf0e10cSrcweir                             {
792*cdf0e10cSrcweir                                 aWindowStateInfo.aDockSize = aSize;
793*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_DOCKSIZE;
794*cdf0e10cSrcweir                             }
795*cdf0e10cSrcweir 
796*cdf0e10cSrcweir                             a <<= aSize;
797*cdf0e10cSrcweir                             bAddToSeq = true;
798*cdf0e10cSrcweir                         }
799*cdf0e10cSrcweir                     }
800*cdf0e10cSrcweir                 }
801*cdf0e10cSrcweir                 break;
802*cdf0e10cSrcweir 
803*cdf0e10cSrcweir                 case PROPERTY_UINAME:
804*cdf0e10cSrcweir                 {
805*cdf0e10cSrcweir                     ::rtl::OUString aValue;
806*cdf0e10cSrcweir                     if ( a >>= aValue )
807*cdf0e10cSrcweir                     {
808*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_UINAME;
809*cdf0e10cSrcweir                         aWindowStateInfo.aUIName = aValue;
810*cdf0e10cSrcweir                         bAddToSeq = true;
811*cdf0e10cSrcweir                     }
812*cdf0e10cSrcweir                 }
813*cdf0e10cSrcweir                 break;
814*cdf0e10cSrcweir 
815*cdf0e10cSrcweir                 case PROPERTY_INTERNALSTATE:
816*cdf0e10cSrcweir                 {
817*cdf0e10cSrcweir                     sal_uInt32 nValue = 0;
818*cdf0e10cSrcweir                     if ( a >>= nValue )
819*cdf0e10cSrcweir                     {
820*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
821*cdf0e10cSrcweir                         aWindowStateInfo.nInternalState = nValue;
822*cdf0e10cSrcweir                         bAddToSeq = true;
823*cdf0e10cSrcweir                     }
824*cdf0e10cSrcweir                 }
825*cdf0e10cSrcweir                 break;
826*cdf0e10cSrcweir 
827*cdf0e10cSrcweir                 case PROPERTY_STYLE:
828*cdf0e10cSrcweir                 {
829*cdf0e10cSrcweir                     sal_Int32 nValue = 0;
830*cdf0e10cSrcweir                     if ( a >>= nValue )
831*cdf0e10cSrcweir                     {
832*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_STYLE;
833*cdf0e10cSrcweir                         aWindowStateInfo.nStyle = sal_uInt16( nValue );
834*cdf0e10cSrcweir                         bAddToSeq = true;
835*cdf0e10cSrcweir                     }
836*cdf0e10cSrcweir                 }
837*cdf0e10cSrcweir                 break;
838*cdf0e10cSrcweir 
839*cdf0e10cSrcweir                 default:
840*cdf0e10cSrcweir                     DBG_ASSERT( sal_False, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
841*cdf0e10cSrcweir             }
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir             if ( bAddToSeq )
844*cdf0e10cSrcweir             {
845*cdf0e10cSrcweir                 // put value into the return sequence
846*cdf0e10cSrcweir                 nIndex = aPropSeq.getLength();
847*cdf0e10cSrcweir                 aPropSeq.realloc( nIndex+1 );
848*cdf0e10cSrcweir                 aPropSeq[nIndex].Name  = m_aPropArray[i];
849*cdf0e10cSrcweir                 aPropSeq[nIndex].Value = a;
850*cdf0e10cSrcweir             }
851*cdf0e10cSrcweir         }
852*cdf0e10cSrcweir         catch( com::sun::star::container::NoSuchElementException& )
853*cdf0e10cSrcweir         {
854*cdf0e10cSrcweir         }
855*cdf0e10cSrcweir         catch ( com::sun::star::lang::WrappedTargetException& )
856*cdf0e10cSrcweir         {
857*cdf0e10cSrcweir         }
858*cdf0e10cSrcweir     }
859*cdf0e10cSrcweir 
860*cdf0e10cSrcweir     aWindowStateInfo.nMask = nMask;
861*cdf0e10cSrcweir     m_aResourceURLToInfoCache.insert( ResourceURLToInfoCache::value_type( rResourceURL, aWindowStateInfo ));
862*cdf0e10cSrcweir     return makeAny( aPropSeq );
863*cdf0e10cSrcweir }
864*cdf0e10cSrcweir 
865*cdf0e10cSrcweir ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowState::impl_insertCacheAndReturnWinState( const rtl::OUString& rResourceURL, Reference< XNameAccess >& rNameAccess )
866*cdf0e10cSrcweir {
867*cdf0e10cSrcweir     sal_Int32                 nMask( 0 );
868*cdf0e10cSrcweir     sal_Int32                 nCount( m_aPropArray.size() );
869*cdf0e10cSrcweir     sal_Int32                 i( 0 );
870*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSeq;
871*cdf0e10cSrcweir     WindowStateInfo           aWindowStateInfo;
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir     for ( i = 0; i < nCount; i++ )
874*cdf0e10cSrcweir     {
875*cdf0e10cSrcweir         try
876*cdf0e10cSrcweir         {
877*cdf0e10cSrcweir             Any     a( rNameAccess->getByName( m_aPropArray[i] ) );
878*cdf0e10cSrcweir             switch ( i )
879*cdf0e10cSrcweir             {
880*cdf0e10cSrcweir                 case PROPERTY_LOCKED:
881*cdf0e10cSrcweir                 case PROPERTY_DOCKED:
882*cdf0e10cSrcweir                 case PROPERTY_VISIBLE:
883*cdf0e10cSrcweir                 case PROPERTY_CONTEXT:
884*cdf0e10cSrcweir                 case PROPERTY_HIDEFROMMENU:
885*cdf0e10cSrcweir                 case PROPERTY_NOCLOSE:
886*cdf0e10cSrcweir                 case PROPERTY_SOFTCLOSE:
887*cdf0e10cSrcweir                 case PROPERTY_CONTEXTACTIVE:
888*cdf0e10cSrcweir                 {
889*cdf0e10cSrcweir                     sal_Bool bValue = sal_Bool();
890*cdf0e10cSrcweir                     if ( a >>= bValue )
891*cdf0e10cSrcweir                     {
892*cdf0e10cSrcweir                         sal_Int32 nValue( 1 << i );
893*cdf0e10cSrcweir                         nMask |= nValue;
894*cdf0e10cSrcweir                         switch ( i )
895*cdf0e10cSrcweir                         {
896*cdf0e10cSrcweir                             case PROPERTY_LOCKED:
897*cdf0e10cSrcweir                                 aWindowStateInfo.bLocked = bValue; break;
898*cdf0e10cSrcweir                             case PROPERTY_DOCKED:
899*cdf0e10cSrcweir                                 aWindowStateInfo.bDocked = bValue; break;
900*cdf0e10cSrcweir                             case PROPERTY_VISIBLE:
901*cdf0e10cSrcweir                                 aWindowStateInfo.bVisible = bValue; break;
902*cdf0e10cSrcweir                             case PROPERTY_CONTEXT:
903*cdf0e10cSrcweir                                 aWindowStateInfo.bContext = bValue; break;
904*cdf0e10cSrcweir                             case PROPERTY_HIDEFROMMENU:
905*cdf0e10cSrcweir                                 aWindowStateInfo.bHideFromMenu = bValue; break;
906*cdf0e10cSrcweir                             case PROPERTY_NOCLOSE:
907*cdf0e10cSrcweir                                 aWindowStateInfo.bNoClose = bValue; break;
908*cdf0e10cSrcweir                             case PROPERTY_SOFTCLOSE:
909*cdf0e10cSrcweir                                 aWindowStateInfo.bNoClose = bValue; break;
910*cdf0e10cSrcweir                             case PROPERTY_CONTEXTACTIVE:
911*cdf0e10cSrcweir                                 aWindowStateInfo.bContextActive = bValue; break;
912*cdf0e10cSrcweir                             default:
913*cdf0e10cSrcweir                                 DBG_ASSERT( sal_False, "Unknown boolean property in WindowState found!" );
914*cdf0e10cSrcweir                         }
915*cdf0e10cSrcweir                     }
916*cdf0e10cSrcweir                 }
917*cdf0e10cSrcweir                 break;
918*cdf0e10cSrcweir 
919*cdf0e10cSrcweir                 case PROPERTY_DOCKINGAREA:
920*cdf0e10cSrcweir                 {
921*cdf0e10cSrcweir                     sal_Int32 nDockingArea = 0;
922*cdf0e10cSrcweir                     if ( a >>= nDockingArea )
923*cdf0e10cSrcweir                     {
924*cdf0e10cSrcweir                         if (( nDockingArea >= 0 ) &&
925*cdf0e10cSrcweir                             ( nDockingArea <= sal_Int32( DockingArea_DOCKINGAREA_RIGHT )))
926*cdf0e10cSrcweir                         {
927*cdf0e10cSrcweir                             aWindowStateInfo.aDockingArea = (DockingArea)nDockingArea;
928*cdf0e10cSrcweir                             nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
929*cdf0e10cSrcweir                         }
930*cdf0e10cSrcweir                     }
931*cdf0e10cSrcweir                 }
932*cdf0e10cSrcweir                 break;
933*cdf0e10cSrcweir 
934*cdf0e10cSrcweir                 case PROPERTY_POS:
935*cdf0e10cSrcweir                 case PROPERTY_DOCKPOS:
936*cdf0e10cSrcweir                 {
937*cdf0e10cSrcweir                     ::rtl::OUString aString;
938*cdf0e10cSrcweir                     if ( a >>= aString )
939*cdf0e10cSrcweir                     {
940*cdf0e10cSrcweir                         sal_Int32 nToken( 0 );
941*cdf0e10cSrcweir                         ::rtl::OUString aXStr = aString.getToken( 0, ',', nToken );
942*cdf0e10cSrcweir                         if ( nToken > 0 )
943*cdf0e10cSrcweir                         {
944*cdf0e10cSrcweir                             com::sun::star::awt::Point aPos;
945*cdf0e10cSrcweir                             aPos.X = aXStr.toInt32();
946*cdf0e10cSrcweir                             aPos.Y = aString.getToken( 0, ',', nToken ).toInt32();
947*cdf0e10cSrcweir 
948*cdf0e10cSrcweir                             if ( i == PROPERTY_POS )
949*cdf0e10cSrcweir                             {
950*cdf0e10cSrcweir                                 aWindowStateInfo.aPos = aPos;
951*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_POS;
952*cdf0e10cSrcweir                             }
953*cdf0e10cSrcweir                             else
954*cdf0e10cSrcweir                             {
955*cdf0e10cSrcweir                                 aWindowStateInfo.aDockPos = aPos;
956*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_DOCKPOS;
957*cdf0e10cSrcweir                             }
958*cdf0e10cSrcweir                         }
959*cdf0e10cSrcweir                     }
960*cdf0e10cSrcweir                 }
961*cdf0e10cSrcweir                 break;
962*cdf0e10cSrcweir 
963*cdf0e10cSrcweir                 case PROPERTY_SIZE:
964*cdf0e10cSrcweir                 case PROPERTY_DOCKSIZE:
965*cdf0e10cSrcweir                 {
966*cdf0e10cSrcweir                     ::rtl::OUString aString;
967*cdf0e10cSrcweir                     if ( a >>= aString )
968*cdf0e10cSrcweir                     {
969*cdf0e10cSrcweir                         sal_Int32 nToken( 0 );
970*cdf0e10cSrcweir                         ::rtl::OUString aStr = aString.getToken( 0, ',', nToken );
971*cdf0e10cSrcweir                         if ( nToken > 0 )
972*cdf0e10cSrcweir                         {
973*cdf0e10cSrcweir                             com::sun::star::awt::Size aSize;
974*cdf0e10cSrcweir                             aSize.Width  = aStr.toInt32();
975*cdf0e10cSrcweir                             aSize.Height = aString.getToken( 0, ',', nToken ).toInt32();
976*cdf0e10cSrcweir                             if ( i == PROPERTY_SIZE )
977*cdf0e10cSrcweir                             {
978*cdf0e10cSrcweir                                 aWindowStateInfo.aSize = aSize;
979*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_SIZE;
980*cdf0e10cSrcweir                             }
981*cdf0e10cSrcweir                             else
982*cdf0e10cSrcweir                             {
983*cdf0e10cSrcweir                                 aWindowStateInfo.aDockSize = aSize;
984*cdf0e10cSrcweir                                 nMask |= WINDOWSTATE_MASK_DOCKSIZE;
985*cdf0e10cSrcweir                             }
986*cdf0e10cSrcweir                         }
987*cdf0e10cSrcweir                     }
988*cdf0e10cSrcweir                 }
989*cdf0e10cSrcweir                 break;
990*cdf0e10cSrcweir 
991*cdf0e10cSrcweir                 case PROPERTY_UINAME:
992*cdf0e10cSrcweir                 {
993*cdf0e10cSrcweir                     ::rtl::OUString aValue;
994*cdf0e10cSrcweir                     if ( a >>= aValue )
995*cdf0e10cSrcweir                     {
996*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_UINAME;
997*cdf0e10cSrcweir                         aWindowStateInfo.aUIName = aValue;
998*cdf0e10cSrcweir                     }
999*cdf0e10cSrcweir                 }
1000*cdf0e10cSrcweir                 break;
1001*cdf0e10cSrcweir 
1002*cdf0e10cSrcweir                 case PROPERTY_INTERNALSTATE:
1003*cdf0e10cSrcweir                 {
1004*cdf0e10cSrcweir                     sal_Int32 nValue = 0;
1005*cdf0e10cSrcweir                     if ( a >>= nValue )
1006*cdf0e10cSrcweir                     {
1007*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
1008*cdf0e10cSrcweir                         aWindowStateInfo.nInternalState = sal_uInt32( nValue );
1009*cdf0e10cSrcweir                     }
1010*cdf0e10cSrcweir                 }
1011*cdf0e10cSrcweir                 break;
1012*cdf0e10cSrcweir 
1013*cdf0e10cSrcweir                 case PROPERTY_STYLE:
1014*cdf0e10cSrcweir                 {
1015*cdf0e10cSrcweir                     sal_Int32 nValue = 0;
1016*cdf0e10cSrcweir                     if ( a >>= nValue )
1017*cdf0e10cSrcweir                     {
1018*cdf0e10cSrcweir                         nMask |= WINDOWSTATE_MASK_STYLE;
1019*cdf0e10cSrcweir                         aWindowStateInfo.nStyle = sal_uInt16( nValue );
1020*cdf0e10cSrcweir                     }
1021*cdf0e10cSrcweir                 }
1022*cdf0e10cSrcweir 
1023*cdf0e10cSrcweir                 default:
1024*cdf0e10cSrcweir                     DBG_ASSERT( sal_False, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
1025*cdf0e10cSrcweir             }
1026*cdf0e10cSrcweir         }
1027*cdf0e10cSrcweir         catch( com::sun::star::container::NoSuchElementException& )
1028*cdf0e10cSrcweir         {
1029*cdf0e10cSrcweir         }
1030*cdf0e10cSrcweir         catch ( com::sun::star::lang::WrappedTargetException& )
1031*cdf0e10cSrcweir         {
1032*cdf0e10cSrcweir         }
1033*cdf0e10cSrcweir     }
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir     aWindowStateInfo.nMask = nMask;
1036*cdf0e10cSrcweir     ResourceURLToInfoCache::iterator pIter = (m_aResourceURLToInfoCache.insert( ResourceURLToInfoCache::value_type( rResourceURL, aWindowStateInfo ))).first;
1037*cdf0e10cSrcweir     return pIter->second;
1038*cdf0e10cSrcweir }
1039*cdf0e10cSrcweir 
1040*cdf0e10cSrcweir Any ConfigurationAccess_WindowState::impl_getWindowStateFromResourceURL( const rtl::OUString& rResourceURL )
1041*cdf0e10cSrcweir {
1042*cdf0e10cSrcweir     if ( !m_bConfigAccessInitialized )
1043*cdf0e10cSrcweir     {
1044*cdf0e10cSrcweir         impl_initializeConfigAccess();
1045*cdf0e10cSrcweir         m_bConfigAccessInitialized = sal_True;
1046*cdf0e10cSrcweir     }
1047*cdf0e10cSrcweir 
1048*cdf0e10cSrcweir     try
1049*cdf0e10cSrcweir     {
1050*cdf0e10cSrcweir         // Try to ask our configuration access
1051*cdf0e10cSrcweir         if ( m_xConfigAccess.is() && m_xConfigAccess->hasByName( rResourceURL ) )
1052*cdf0e10cSrcweir         {
1053*cdf0e10cSrcweir 
1054*cdf0e10cSrcweir             Reference< XNameAccess > xNameAccess( m_xConfigAccess->getByName( rResourceURL ), UNO_QUERY );
1055*cdf0e10cSrcweir             if ( xNameAccess.is() )
1056*cdf0e10cSrcweir                 return impl_insertCacheAndReturnSequence( rResourceURL, xNameAccess );
1057*cdf0e10cSrcweir         }
1058*cdf0e10cSrcweir     }
1059*cdf0e10cSrcweir     catch( com::sun::star::container::NoSuchElementException& )
1060*cdf0e10cSrcweir     {
1061*cdf0e10cSrcweir     }
1062*cdf0e10cSrcweir     catch ( com::sun::star::lang::WrappedTargetException& )
1063*cdf0e10cSrcweir     {
1064*cdf0e10cSrcweir     }
1065*cdf0e10cSrcweir 
1066*cdf0e10cSrcweir     return Any();
1067*cdf0e10cSrcweir }
1068*cdf0e10cSrcweir 
1069*cdf0e10cSrcweir void ConfigurationAccess_WindowState::impl_fillStructFromSequence( WindowStateInfo& rWinStateInfo, const Sequence< PropertyValue >& rSeq )
1070*cdf0e10cSrcweir {
1071*cdf0e10cSrcweir     sal_Int32 nCompareCount( m_aPropArray.size() );
1072*cdf0e10cSrcweir     sal_Int32 nCount( rSeq.getLength() );
1073*cdf0e10cSrcweir     sal_Int32 i( 0 );
1074*cdf0e10cSrcweir 
1075*cdf0e10cSrcweir     for ( i = 0; i < nCount; i++ )
1076*cdf0e10cSrcweir     {
1077*cdf0e10cSrcweir         for ( sal_Int32 j = 0; j < nCompareCount; j++ )
1078*cdf0e10cSrcweir         {
1079*cdf0e10cSrcweir             if ( rSeq[i].Name.equals( m_aPropArray[j] ))
1080*cdf0e10cSrcweir             {
1081*cdf0e10cSrcweir                 switch ( j )
1082*cdf0e10cSrcweir                 {
1083*cdf0e10cSrcweir                     case PROPERTY_LOCKED:
1084*cdf0e10cSrcweir                     case PROPERTY_DOCKED:
1085*cdf0e10cSrcweir                     case PROPERTY_VISIBLE:
1086*cdf0e10cSrcweir                     case PROPERTY_CONTEXT:
1087*cdf0e10cSrcweir                     case PROPERTY_HIDEFROMMENU:
1088*cdf0e10cSrcweir                     case PROPERTY_NOCLOSE:
1089*cdf0e10cSrcweir                     case PROPERTY_SOFTCLOSE:
1090*cdf0e10cSrcweir                     case PROPERTY_CONTEXTACTIVE:
1091*cdf0e10cSrcweir                     {
1092*cdf0e10cSrcweir                         sal_Bool bValue = sal_Bool();
1093*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= bValue )
1094*cdf0e10cSrcweir                         {
1095*cdf0e10cSrcweir                             sal_Int32 nValue( 1 << j );
1096*cdf0e10cSrcweir                             rWinStateInfo.nMask |= nValue;
1097*cdf0e10cSrcweir                             switch ( j )
1098*cdf0e10cSrcweir                             {
1099*cdf0e10cSrcweir                                 case PROPERTY_LOCKED:
1100*cdf0e10cSrcweir                                     rWinStateInfo.bLocked = bValue;
1101*cdf0e10cSrcweir                                     break;
1102*cdf0e10cSrcweir                                 case PROPERTY_DOCKED:
1103*cdf0e10cSrcweir                                     rWinStateInfo.bDocked = bValue;
1104*cdf0e10cSrcweir                                     break;
1105*cdf0e10cSrcweir                                 case PROPERTY_VISIBLE:
1106*cdf0e10cSrcweir                                     rWinStateInfo.bVisible = bValue;
1107*cdf0e10cSrcweir                                     break;
1108*cdf0e10cSrcweir                                 case PROPERTY_CONTEXT:
1109*cdf0e10cSrcweir                                     rWinStateInfo.bContext = bValue;
1110*cdf0e10cSrcweir                                     break;
1111*cdf0e10cSrcweir                                 case PROPERTY_HIDEFROMMENU:
1112*cdf0e10cSrcweir                                     rWinStateInfo.bHideFromMenu = bValue;
1113*cdf0e10cSrcweir                                     break;
1114*cdf0e10cSrcweir                                 case PROPERTY_NOCLOSE:
1115*cdf0e10cSrcweir                                     rWinStateInfo.bNoClose = bValue;
1116*cdf0e10cSrcweir                                     break;
1117*cdf0e10cSrcweir                                 case PROPERTY_SOFTCLOSE:
1118*cdf0e10cSrcweir                                     rWinStateInfo.bSoftClose = bValue;
1119*cdf0e10cSrcweir                                     break;
1120*cdf0e10cSrcweir                                 case PROPERTY_CONTEXTACTIVE:
1121*cdf0e10cSrcweir                                     rWinStateInfo.bContextActive = bValue;
1122*cdf0e10cSrcweir                                     break;
1123*cdf0e10cSrcweir                                 default:
1124*cdf0e10cSrcweir                                     DBG_ASSERT( sal_False, "Unknown boolean property in WindowState found!" );
1125*cdf0e10cSrcweir                             }
1126*cdf0e10cSrcweir                         }
1127*cdf0e10cSrcweir                     }
1128*cdf0e10cSrcweir                     break;
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir                     case PROPERTY_DOCKINGAREA:
1131*cdf0e10cSrcweir                     {
1132*cdf0e10cSrcweir                         ::com::sun::star::ui::DockingArea eDockingArea;
1133*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= eDockingArea )
1134*cdf0e10cSrcweir                         {
1135*cdf0e10cSrcweir                             rWinStateInfo.aDockingArea = eDockingArea;
1136*cdf0e10cSrcweir                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
1137*cdf0e10cSrcweir                         }
1138*cdf0e10cSrcweir                     }
1139*cdf0e10cSrcweir                     break;
1140*cdf0e10cSrcweir 
1141*cdf0e10cSrcweir                     case PROPERTY_POS:
1142*cdf0e10cSrcweir                     case PROPERTY_DOCKPOS:
1143*cdf0e10cSrcweir                     {
1144*cdf0e10cSrcweir                         com::sun::star::awt::Point aPoint;
1145*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= aPoint )
1146*cdf0e10cSrcweir                         {
1147*cdf0e10cSrcweir                             if ( j == PROPERTY_POS )
1148*cdf0e10cSrcweir                             {
1149*cdf0e10cSrcweir                                 rWinStateInfo.aPos = aPoint;
1150*cdf0e10cSrcweir                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_POS;
1151*cdf0e10cSrcweir                             }
1152*cdf0e10cSrcweir                             else
1153*cdf0e10cSrcweir                             {
1154*cdf0e10cSrcweir                                 rWinStateInfo.aDockPos = aPoint;
1155*cdf0e10cSrcweir                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKPOS;
1156*cdf0e10cSrcweir                             }
1157*cdf0e10cSrcweir                         }
1158*cdf0e10cSrcweir                     }
1159*cdf0e10cSrcweir                     break;
1160*cdf0e10cSrcweir 
1161*cdf0e10cSrcweir                     case PROPERTY_SIZE:
1162*cdf0e10cSrcweir                     case PROPERTY_DOCKSIZE:
1163*cdf0e10cSrcweir                     {
1164*cdf0e10cSrcweir                         com::sun::star::awt::Size aSize;
1165*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= aSize )
1166*cdf0e10cSrcweir                         {
1167*cdf0e10cSrcweir                             if ( j == PROPERTY_SIZE )
1168*cdf0e10cSrcweir                             {
1169*cdf0e10cSrcweir                                 rWinStateInfo.aSize = aSize;
1170*cdf0e10cSrcweir                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_SIZE;
1171*cdf0e10cSrcweir                             }
1172*cdf0e10cSrcweir                             else
1173*cdf0e10cSrcweir                             {
1174*cdf0e10cSrcweir                                 rWinStateInfo.aDockSize = aSize;
1175*cdf0e10cSrcweir                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKSIZE;
1176*cdf0e10cSrcweir                             }
1177*cdf0e10cSrcweir                         }
1178*cdf0e10cSrcweir                     }
1179*cdf0e10cSrcweir                     break;
1180*cdf0e10cSrcweir 
1181*cdf0e10cSrcweir                     case PROPERTY_UINAME:
1182*cdf0e10cSrcweir                     {
1183*cdf0e10cSrcweir                         ::rtl::OUString aValue;
1184*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= aValue )
1185*cdf0e10cSrcweir                         {
1186*cdf0e10cSrcweir                             rWinStateInfo.aUIName = aValue;
1187*cdf0e10cSrcweir                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_UINAME;
1188*cdf0e10cSrcweir                         }
1189*cdf0e10cSrcweir                     }
1190*cdf0e10cSrcweir                     break;
1191*cdf0e10cSrcweir 
1192*cdf0e10cSrcweir                     case PROPERTY_INTERNALSTATE:
1193*cdf0e10cSrcweir                     {
1194*cdf0e10cSrcweir                         sal_Int32 nValue = 0;
1195*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= nValue )
1196*cdf0e10cSrcweir                         {
1197*cdf0e10cSrcweir                             rWinStateInfo.nInternalState = sal_uInt32( nValue );
1198*cdf0e10cSrcweir                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
1199*cdf0e10cSrcweir                         }
1200*cdf0e10cSrcweir                     }
1201*cdf0e10cSrcweir                     break;
1202*cdf0e10cSrcweir 
1203*cdf0e10cSrcweir                     case PROPERTY_STYLE:
1204*cdf0e10cSrcweir                     {
1205*cdf0e10cSrcweir                         sal_Int32 nValue = 0;
1206*cdf0e10cSrcweir                         if ( rSeq[i].Value >>= nValue )
1207*cdf0e10cSrcweir                         {
1208*cdf0e10cSrcweir                             rWinStateInfo.nStyle = sal_uInt16( nValue );
1209*cdf0e10cSrcweir                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_STYLE;
1210*cdf0e10cSrcweir                         }
1211*cdf0e10cSrcweir                     }
1212*cdf0e10cSrcweir                     break;
1213*cdf0e10cSrcweir 
1214*cdf0e10cSrcweir                     default:
1215*cdf0e10cSrcweir                         DBG_ASSERT( sal_False, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
1216*cdf0e10cSrcweir                 }
1217*cdf0e10cSrcweir 
1218*cdf0e10cSrcweir                 break;
1219*cdf0e10cSrcweir             }
1220*cdf0e10cSrcweir         }
1221*cdf0e10cSrcweir     }
1222*cdf0e10cSrcweir }
1223*cdf0e10cSrcweir 
1224*cdf0e10cSrcweir void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct( const WindowStateInfo& rWinStateInfo, Reference< XPropertySet >& xPropSet )
1225*cdf0e10cSrcweir {
1226*cdf0e10cSrcweir     sal_Int32                 i( 0 );
1227*cdf0e10cSrcweir     sal_Int32                 nCount( m_aPropArray.size() );
1228*cdf0e10cSrcweir     Sequence< PropertyValue > aPropSeq;
1229*cdf0e10cSrcweir     ::rtl::OUString                  aDelim( ::rtl::OUString::createFromAscii( "," ));
1230*cdf0e10cSrcweir 
1231*cdf0e10cSrcweir     for ( i = 0; i < nCount; i++ )
1232*cdf0e10cSrcweir     {
1233*cdf0e10cSrcweir         if ( rWinStateInfo.nMask & ( 1 << i ))
1234*cdf0e10cSrcweir         {
1235*cdf0e10cSrcweir             try
1236*cdf0e10cSrcweir             {
1237*cdf0e10cSrcweir                 // put values into the property set
1238*cdf0e10cSrcweir                 switch ( i )
1239*cdf0e10cSrcweir                 {
1240*cdf0e10cSrcweir                     case PROPERTY_LOCKED:
1241*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bLocked )) ); break;
1242*cdf0e10cSrcweir                     case PROPERTY_DOCKED:
1243*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bDocked )) ); break;
1244*cdf0e10cSrcweir                     case PROPERTY_VISIBLE:
1245*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bVisible )) ); break;
1246*cdf0e10cSrcweir                     case PROPERTY_CONTEXT:
1247*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bContext )) ); break;
1248*cdf0e10cSrcweir                     case PROPERTY_HIDEFROMMENU:
1249*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bHideFromMenu )) ); break;
1250*cdf0e10cSrcweir                     case PROPERTY_NOCLOSE:
1251*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bNoClose )) ); break;
1252*cdf0e10cSrcweir                     case PROPERTY_SOFTCLOSE:
1253*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bSoftClose )) ); break;
1254*cdf0e10cSrcweir                     case PROPERTY_CONTEXTACTIVE:
1255*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Bool( rWinStateInfo.bContextActive )) ); break;
1256*cdf0e10cSrcweir                     case PROPERTY_DOCKINGAREA:
1257*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int16( rWinStateInfo.aDockingArea ) ) ); break;
1258*cdf0e10cSrcweir                     case PROPERTY_POS:
1259*cdf0e10cSrcweir                     case PROPERTY_DOCKPOS:
1260*cdf0e10cSrcweir                     {
1261*cdf0e10cSrcweir                         ::rtl::OUString aPosStr;
1262*cdf0e10cSrcweir                         if ( i == PROPERTY_POS )
1263*cdf0e10cSrcweir                             aPosStr = ::rtl::OUString::valueOf( rWinStateInfo.aPos.X );
1264*cdf0e10cSrcweir                         else
1265*cdf0e10cSrcweir                             aPosStr = ::rtl::OUString::valueOf( rWinStateInfo.aDockPos.X );
1266*cdf0e10cSrcweir                         aPosStr += aDelim;
1267*cdf0e10cSrcweir                         if ( i == PROPERTY_POS )
1268*cdf0e10cSrcweir                             aPosStr += ::rtl::OUString::valueOf( rWinStateInfo.aPos.Y );
1269*cdf0e10cSrcweir                         else
1270*cdf0e10cSrcweir                             aPosStr += ::rtl::OUString::valueOf( rWinStateInfo.aDockPos.Y );
1271*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aPosStr ) );
1272*cdf0e10cSrcweir                         break;
1273*cdf0e10cSrcweir                     }
1274*cdf0e10cSrcweir                     case PROPERTY_SIZE:
1275*cdf0e10cSrcweir                     case PROPERTY_DOCKSIZE:
1276*cdf0e10cSrcweir                     {
1277*cdf0e10cSrcweir                         ::rtl::OUString aSizeStr;
1278*cdf0e10cSrcweir                         if ( i == PROPERTY_SIZE )
1279*cdf0e10cSrcweir                             aSizeStr = ( ::rtl::OUString::valueOf( rWinStateInfo.aSize.Width ));
1280*cdf0e10cSrcweir                         else
1281*cdf0e10cSrcweir                             aSizeStr = ( ::rtl::OUString::valueOf( rWinStateInfo.aDockSize.Width ));
1282*cdf0e10cSrcweir                         aSizeStr += aDelim;
1283*cdf0e10cSrcweir                         if ( i == PROPERTY_SIZE )
1284*cdf0e10cSrcweir                             aSizeStr += ::rtl::OUString::valueOf( rWinStateInfo.aSize.Height );
1285*cdf0e10cSrcweir                         else
1286*cdf0e10cSrcweir                             aSizeStr += ::rtl::OUString::valueOf( rWinStateInfo.aDockSize.Height );
1287*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aSizeStr ) );
1288*cdf0e10cSrcweir                         break;
1289*cdf0e10cSrcweir                     }
1290*cdf0e10cSrcweir                     case PROPERTY_UINAME:
1291*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.aUIName ) ); break;
1292*cdf0e10cSrcweir                     case PROPERTY_INTERNALSTATE:
1293*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int32( rWinStateInfo.nInternalState )) ); break;
1294*cdf0e10cSrcweir                     case PROPERTY_STYLE:
1295*cdf0e10cSrcweir                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int32( rWinStateInfo.nStyle )) ); break;
1296*cdf0e10cSrcweir                     default:
1297*cdf0e10cSrcweir                         DBG_ASSERT( sal_False, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
1298*cdf0e10cSrcweir                 }
1299*cdf0e10cSrcweir             }
1300*cdf0e10cSrcweir             catch( Exception& )
1301*cdf0e10cSrcweir             {
1302*cdf0e10cSrcweir             }
1303*cdf0e10cSrcweir         }
1304*cdf0e10cSrcweir     }
1305*cdf0e10cSrcweir }
1306*cdf0e10cSrcweir 
1307*cdf0e10cSrcweir sal_Bool ConfigurationAccess_WindowState::impl_initializeConfigAccess()
1308*cdf0e10cSrcweir {
1309*cdf0e10cSrcweir     Sequence< Any > aArgs( 2 );
1310*cdf0e10cSrcweir     PropertyValue   aPropValue;
1311*cdf0e10cSrcweir 
1312*cdf0e10cSrcweir     try
1313*cdf0e10cSrcweir     {
1314*cdf0e10cSrcweir         aPropValue.Name  = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "nodepath" ));
1315*cdf0e10cSrcweir         aPropValue.Value <<= m_aConfigWindowAccess;
1316*cdf0e10cSrcweir         aArgs[0] <<= aPropValue;
1317*cdf0e10cSrcweir         aPropValue.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "lazywrite" ));
1318*cdf0e10cSrcweir         aPropValue.Value <<= sal_True;
1319*cdf0e10cSrcweir         aArgs[1] <<= aPropValue;
1320*cdf0e10cSrcweir 
1321*cdf0e10cSrcweir         m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
1322*cdf0e10cSrcweir                                                         SERVICENAME_CFGUPDATEACCESS, aArgs ),
1323*cdf0e10cSrcweir                                                     UNO_QUERY );
1324*cdf0e10cSrcweir         if ( m_xConfigAccess.is() )
1325*cdf0e10cSrcweir         {
1326*cdf0e10cSrcweir             // Add as container listener
1327*cdf0e10cSrcweir             Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
1328*cdf0e10cSrcweir             if ( xContainer.is() )
1329*cdf0e10cSrcweir                 xContainer->addContainerListener( this );
1330*cdf0e10cSrcweir         }
1331*cdf0e10cSrcweir 
1332*cdf0e10cSrcweir         return sal_True;
1333*cdf0e10cSrcweir     }
1334*cdf0e10cSrcweir     catch ( WrappedTargetException& )
1335*cdf0e10cSrcweir     {
1336*cdf0e10cSrcweir     }
1337*cdf0e10cSrcweir     catch ( Exception& )
1338*cdf0e10cSrcweir     {
1339*cdf0e10cSrcweir     }
1340*cdf0e10cSrcweir 
1341*cdf0e10cSrcweir     return sal_False;
1342*cdf0e10cSrcweir }
1343*cdf0e10cSrcweir 
1344*cdf0e10cSrcweir 
1345*cdf0e10cSrcweir //*****************************************************************************************************************
1346*cdf0e10cSrcweir //	XInterface, XTypeProvider, XServiceInfo
1347*cdf0e10cSrcweir //*****************************************************************************************************************
1348*cdf0e10cSrcweir DEFINE_XINTERFACE_4                    (    WindowStateConfiguration                                                            ,
1349*cdf0e10cSrcweir                                             OWeakObject                                                                     ,
1350*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XTypeProvider                                      ),
1351*cdf0e10cSrcweir                                             DIRECT_INTERFACE( css::lang::XServiceInfo                                       ),
1352*cdf0e10cSrcweir 											DIRECT_INTERFACE( css::container::XNameAccess		                            ),
1353*cdf0e10cSrcweir                                             DERIVED_INTERFACE( css::container::XElementAccess, css::container::XNameAccess  )
1354*cdf0e10cSrcweir 										)
1355*cdf0e10cSrcweir 
1356*cdf0e10cSrcweir DEFINE_XTYPEPROVIDER_4                  (   WindowStateConfiguration		    ,
1357*cdf0e10cSrcweir                                             css::lang::XTypeProvider		,
1358*cdf0e10cSrcweir                                             css::lang::XServiceInfo			,
1359*cdf0e10cSrcweir                                             css::container::XNameAccess     ,
1360*cdf0e10cSrcweir 											css::container::XElementAccess
1361*cdf0e10cSrcweir 										)
1362*cdf0e10cSrcweir 
1363*cdf0e10cSrcweir DEFINE_XSERVICEINFO_ONEINSTANCESERVICE  (   WindowStateConfiguration				    ,
1364*cdf0e10cSrcweir                                             ::cppu::OWeakObject						    ,
1365*cdf0e10cSrcweir                                             SERVICENAME_WINDOWSTATECONFIGURATION	    ,
1366*cdf0e10cSrcweir 											IMPLEMENTATIONNAME_WINDOWSTATECONFIGURATION
1367*cdf0e10cSrcweir 										)
1368*cdf0e10cSrcweir 
1369*cdf0e10cSrcweir DEFINE_INIT_SERVICE                     (   WindowStateConfiguration, {} )
1370*cdf0e10cSrcweir 
1371*cdf0e10cSrcweir WindowStateConfiguration::WindowStateConfiguration( const Reference< XMultiServiceFactory >& xServiceManager ) :
1372*cdf0e10cSrcweir     ThreadHelpBase(),
1373*cdf0e10cSrcweir     m_xServiceManager( xServiceManager )
1374*cdf0e10cSrcweir {
1375*cdf0e10cSrcweir     m_xModuleManager = Reference< XModuleManager >( m_xServiceManager->createInstance( SERVICENAME_MODULEMANAGER ),
1376*cdf0e10cSrcweir                                                     UNO_QUERY );
1377*cdf0e10cSrcweir     Reference< XNameAccess > xEmptyNameAccess;
1378*cdf0e10cSrcweir     Reference< XNameAccess > xNameAccess( m_xModuleManager, UNO_QUERY_THROW );
1379*cdf0e10cSrcweir     Sequence< rtl::OUString > aElementNames = xNameAccess->getElementNames();
1380*cdf0e10cSrcweir     Sequence< PropertyValue > aSeq;
1381*cdf0e10cSrcweir     ::rtl::OUString                  aModuleIdentifier;
1382*cdf0e10cSrcweir 
1383*cdf0e10cSrcweir     for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
1384*cdf0e10cSrcweir     {
1385*cdf0e10cSrcweir         aModuleIdentifier = aElementNames[i];
1386*cdf0e10cSrcweir         if ( xNameAccess->getByName( aModuleIdentifier ) >>= aSeq )
1387*cdf0e10cSrcweir         {
1388*cdf0e10cSrcweir             ::rtl::OUString aWindowStateFileStr;
1389*cdf0e10cSrcweir             for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
1390*cdf0e10cSrcweir             {
1391*cdf0e10cSrcweir                 if ( aSeq[y].Name.equalsAscii("ooSetupFactoryWindowStateConfigRef") )
1392*cdf0e10cSrcweir                 {
1393*cdf0e10cSrcweir                     aSeq[y].Value >>= aWindowStateFileStr;
1394*cdf0e10cSrcweir                     break;
1395*cdf0e10cSrcweir                 }
1396*cdf0e10cSrcweir             }
1397*cdf0e10cSrcweir 
1398*cdf0e10cSrcweir             if ( aWindowStateFileStr.getLength() > 0 )
1399*cdf0e10cSrcweir             {
1400*cdf0e10cSrcweir                 // Create first mapping ModuleIdentifier ==> Window state configuration file
1401*cdf0e10cSrcweir                 m_aModuleToFileHashMap.insert( ModuleToWindowStateFileMap::value_type( aModuleIdentifier, aWindowStateFileStr ));
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir                 // Create second mapping Command File ==> Window state configuration instance
1404*cdf0e10cSrcweir                 ModuleToWindowStateConfigHashMap::iterator pIter = m_aModuleToWindowStateHashMap.find( aWindowStateFileStr );
1405*cdf0e10cSrcweir                 if ( pIter == m_aModuleToWindowStateHashMap.end() )
1406*cdf0e10cSrcweir                     m_aModuleToWindowStateHashMap.insert( ModuleToWindowStateConfigHashMap::value_type( aWindowStateFileStr, xEmptyNameAccess ));
1407*cdf0e10cSrcweir             }
1408*cdf0e10cSrcweir         }
1409*cdf0e10cSrcweir     }
1410*cdf0e10cSrcweir }
1411*cdf0e10cSrcweir 
1412*cdf0e10cSrcweir WindowStateConfiguration::~WindowStateConfiguration()
1413*cdf0e10cSrcweir {
1414*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
1415*cdf0e10cSrcweir     m_aModuleToFileHashMap.clear();
1416*cdf0e10cSrcweir     m_aModuleToWindowStateHashMap.clear();
1417*cdf0e10cSrcweir }
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir Any SAL_CALL WindowStateConfiguration::getByName( const ::rtl::OUString& aModuleIdentifier )
1420*cdf0e10cSrcweir throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException)
1421*cdf0e10cSrcweir {
1422*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
1423*cdf0e10cSrcweir 
1424*cdf0e10cSrcweir     ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aModuleIdentifier );
1425*cdf0e10cSrcweir     if ( pIter != m_aModuleToFileHashMap.end() )
1426*cdf0e10cSrcweir     {
1427*cdf0e10cSrcweir         Any a;
1428*cdf0e10cSrcweir         ::rtl::OUString aWindowStateConfigFile( pIter->second );
1429*cdf0e10cSrcweir 
1430*cdf0e10cSrcweir         ModuleToWindowStateConfigHashMap::iterator pModuleIter = m_aModuleToWindowStateHashMap.find( aWindowStateConfigFile );
1431*cdf0e10cSrcweir         if ( pModuleIter != m_aModuleToWindowStateHashMap.end() )
1432*cdf0e10cSrcweir         {
1433*cdf0e10cSrcweir             if ( pModuleIter->second.is() )
1434*cdf0e10cSrcweir                 a = makeAny( pModuleIter->second );
1435*cdf0e10cSrcweir             else
1436*cdf0e10cSrcweir             {
1437*cdf0e10cSrcweir                 Reference< XNameAccess > xResourceURLWindowState;
1438*cdf0e10cSrcweir                 ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xServiceManager );
1439*cdf0e10cSrcweir                 xResourceURLWindowState = Reference< XNameAccess >( static_cast< cppu::OWeakObject* >( pModuleWindowState ),UNO_QUERY );
1440*cdf0e10cSrcweir                 pModuleIter->second = xResourceURLWindowState;
1441*cdf0e10cSrcweir                 a <<= xResourceURLWindowState;
1442*cdf0e10cSrcweir             }
1443*cdf0e10cSrcweir 
1444*cdf0e10cSrcweir             return a;
1445*cdf0e10cSrcweir         }
1446*cdf0e10cSrcweir     }
1447*cdf0e10cSrcweir 
1448*cdf0e10cSrcweir     throw NoSuchElementException();
1449*cdf0e10cSrcweir }
1450*cdf0e10cSrcweir 
1451*cdf0e10cSrcweir Sequence< ::rtl::OUString > SAL_CALL WindowStateConfiguration::getElementNames()
1452*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1453*cdf0e10cSrcweir {
1454*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
1455*cdf0e10cSrcweir 
1456*cdf0e10cSrcweir     Sequence< rtl::OUString > aSeq( m_aModuleToFileHashMap.size() );
1457*cdf0e10cSrcweir 
1458*cdf0e10cSrcweir     sal_Int32 n = 0;
1459*cdf0e10cSrcweir     ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.begin();
1460*cdf0e10cSrcweir     while ( pIter != m_aModuleToFileHashMap.end() )
1461*cdf0e10cSrcweir     {
1462*cdf0e10cSrcweir         aSeq[n] = pIter->first;
1463*cdf0e10cSrcweir         ++pIter;
1464*cdf0e10cSrcweir     }
1465*cdf0e10cSrcweir 
1466*cdf0e10cSrcweir     return aSeq;
1467*cdf0e10cSrcweir }
1468*cdf0e10cSrcweir 
1469*cdf0e10cSrcweir sal_Bool SAL_CALL WindowStateConfiguration::hasByName( const ::rtl::OUString& aName )
1470*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1471*cdf0e10cSrcweir {
1472*cdf0e10cSrcweir     ResetableGuard aLock( m_aLock );
1473*cdf0e10cSrcweir 
1474*cdf0e10cSrcweir     ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aName );
1475*cdf0e10cSrcweir     return ( pIter != m_aModuleToFileHashMap.end() );
1476*cdf0e10cSrcweir }
1477*cdf0e10cSrcweir 
1478*cdf0e10cSrcweir // XElementAccess
1479*cdf0e10cSrcweir Type SAL_CALL WindowStateConfiguration::getElementType()
1480*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1481*cdf0e10cSrcweir {
1482*cdf0e10cSrcweir     return( ::getCppuType( (const Reference< XNameAccess >*)NULL ) );
1483*cdf0e10cSrcweir }
1484*cdf0e10cSrcweir 
1485*cdf0e10cSrcweir sal_Bool SAL_CALL WindowStateConfiguration::hasElements()
1486*cdf0e10cSrcweir throw (::com::sun::star::uno::RuntimeException)
1487*cdf0e10cSrcweir {
1488*cdf0e10cSrcweir     // We always have at least one module. So it is valid to return true!
1489*cdf0e10cSrcweir     return sal_True;
1490*cdf0e10cSrcweir }
1491*cdf0e10cSrcweir 
1492*cdf0e10cSrcweir } // namespace framework
1493*cdf0e10cSrcweir 
1494