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

Generated by: LCOV version 1.10