LCOV - code coverage report
Current view: top level - libreoffice/framework/source/uiconfiguration - windowstateconfiguration.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 222 587 37.8 %
Date: 2012-12-27 Functions: 28 51 54.9 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10