LCOV - code coverage report
Current view: top level - framework/source/uiconfiguration - windowstateconfiguration.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 362 593 61.0 %
Date: 2015-06-13 12:38:46 Functions: 26 40 65.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 <unordered_map>
      46             : #include <vector>
      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       25810 :         struct WindowStateInfo
     170             :         {
     171        4509 :             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        4509 :                 , nMask(0)
     187             :             {
     188        4509 :             }
     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 std::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         132 : ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( const OUString& aModuleName, const Reference< XComponentContext >& rxContext ) :
     235             :     m_aConfigWindowAccess( "/org.openoffice.Office.UI." ),
     236             :     m_bConfigAccessInitialized( false ),
     237         132 :     m_bModified( false )
     238             : {
     239             :     // Create configuration hierarchical access name
     240         132 :     m_aConfigWindowAccess += aModuleName;
     241         132 :     m_aConfigWindowAccess += "/UIElements/States";
     242         132 :     m_xConfigProvider = theDefaultProvider::get( rxContext );
     243             : 
     244             :     // Initialize access array with property names.
     245         132 :     sal_Int32 n = 0;
     246        2376 :     while ( CONFIGURATION_PROPERTIES[n] )
     247             :     {
     248        2112 :         m_aPropArray.push_back( OUString::createFromAscii( CONFIGURATION_PROPERTIES[n] ));
     249        2112 :         ++n;
     250             :     }
     251         132 : }
     252             : 
     253         354 : ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState()
     254             : {
     255             :     // SAFE
     256         118 :     osl::MutexGuard g(m_aMutex);
     257         236 :     Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
     258         118 :     if ( xContainer.is() )
     259         236 :         xContainer->removeContainerListener(m_xConfigListener);
     260         236 : }
     261             : 
     262             : // XNameAccess
     263      161078 : Any SAL_CALL ConfigurationAccess_WindowState::getByName( const OUString& rResourceURL )
     264             : throw ( NoSuchElementException, WrappedTargetException, RuntimeException, std::exception)
     265             : {
     266             :     // SAFE
     267      161078 :     osl::MutexGuard g(m_aMutex);
     268             : 
     269      161078 :     ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
     270      161078 :     if ( pIter != m_aResourceURLToInfoCache.end() )
     271      161078 :         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      161078 :     }
     280             : }
     281             : 
     282        3290 : Sequence< OUString > SAL_CALL ConfigurationAccess_WindowState::getElementNames()
     283             : throw ( RuntimeException, std::exception )
     284             : {
     285             :     // SAFE
     286        3290 :     osl::MutexGuard g(m_aMutex);
     287             : 
     288        3290 :     if ( !m_bConfigAccessInitialized )
     289             :     {
     290          74 :         impl_initializeConfigAccess();
     291          74 :         m_bConfigAccessInitialized = true;
     292             :     }
     293             : 
     294        3290 :     if ( m_xConfigAccess.is() )
     295        3290 :         return m_xConfigAccess->getElementNames();
     296             :     else
     297           0 :         return Sequence< OUString > ();
     298             : }
     299             : 
     300      166124 : sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName( const OUString& rResourceURL )
     301             : throw (::com::sun::star::uno::RuntimeException, std::exception)
     302             : {
     303             :     // SAFE
     304      166124 :     osl::MutexGuard g(m_aMutex);
     305             : 
     306      166124 :     ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
     307      166124 :     if ( pIter != m_aResourceURLToInfoCache.end() )
     308      158302 :         return sal_True;
     309             :     else
     310             :     {
     311        7822 :         Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
     312        7822 :         if ( a == Any() )
     313        3313 :             return sal_False;
     314             :         else
     315        4509 :             return sal_True;
     316      166124 :     }
     317             : }
     318             : 
     319             : // XElementAccess
     320           0 : Type SAL_CALL ConfigurationAccess_WindowState::getElementType()
     321             : throw ( RuntimeException, std::exception )
     322             : {
     323           0 :     return( cppu::UnoType<Sequence< PropertyValue >>::get() );
     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        1772 : 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        1772 :     osl::ResettableMutexGuard g(m_aMutex);
     450             : 
     451        3544 :     Sequence< PropertyValue > aPropSet;
     452        1772 :     if ( aPropertySet >>= aPropSet )
     453             :     {
     454        1772 :         ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
     455        1772 :         if ( pIter != m_aResourceURLToInfoCache.end() )
     456             :         {
     457        1772 :             WindowStateInfo& rWinStateInfo = pIter->second;
     458        1772 :             impl_fillStructFromSequence( rWinStateInfo, aPropSet );
     459        1772 :             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        1772 :         if ( m_bModified && pIter != m_aResourceURLToInfoCache.end() )
     485             :         {
     486        1772 :             Reference< XNameContainer > xNameContainer( m_xConfigAccess, UNO_QUERY );
     487        1772 :             if ( xNameContainer.is() )
     488             :             {
     489        1772 :                 WindowStateInfo aWinStateInfo( pIter->second );
     490        3544 :                 OUString        aResourceURL( pIter->first );
     491        1772 :                 m_bModified = false;
     492        1772 :                 g.clear();
     493             : 
     494             :                 try
     495             :                 {
     496        1772 :                     Reference< XPropertySet > xPropSet;
     497        1772 :                     if ( xNameContainer->getByName( aResourceURL ) >>= xPropSet )
     498             :                     {
     499        1772 :                         impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
     500             : 
     501        1772 :                         Reference< XChangesBatch > xFlush( m_xConfigAccess, UNO_QUERY );
     502        1772 :                         if ( xFlush.is() )
     503        1772 :                             xFlush->commitChanges();
     504        1772 :                     }
     505             :                 }
     506           0 :                 catch ( const Exception& )
     507             :                 {
     508        1772 :                 }
     509        1772 :             }
     510             :         }
     511             :     }
     512             :     else
     513        1772 :         throw IllegalArgumentException();
     514        1772 : }
     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      161078 : Any ConfigurationAccess_WindowState::impl_getSequenceFromStruct( const WindowStateInfo& rWinStateInfo )
     545             : {
     546      161078 :     sal_Int32                 i( 0 );
     547      161078 :     sal_Int32                 nCount( m_aPropArray.size() );
     548      161078 :     Sequence< PropertyValue > aPropSeq;
     549             : 
     550     2738326 :     for ( i = 0; i < nCount; i++ )
     551             :     {
     552     2577248 :         if ( rWinStateInfo.nMask & ( 1 << i ))
     553             :         {
     554             :             // put value into the return sequence
     555     1778955 :             sal_Int32 nIndex( aPropSeq.getLength());
     556     1778955 :             aPropSeq.realloc( nIndex+1 );
     557     1778955 :             aPropSeq[nIndex].Name = m_aPropArray[i];
     558             : 
     559     1778955 :             switch ( i )
     560             :             {
     561             :                 case PROPERTY_LOCKED:
     562      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bLocked ); break;
     563             :                 case PROPERTY_DOCKED:
     564      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bDocked ); break;
     565             :                 case PROPERTY_VISIBLE:
     566      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bVisible ); break;
     567             :                 case PROPERTY_CONTEXT:
     568      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bContext ); break;
     569             :                 case PROPERTY_HIDEFROMMENU:
     570      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bHideFromMenu ); break;
     571             :                 case PROPERTY_NOCLOSE:
     572      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bNoClose ); break;
     573             :                 case PROPERTY_SOFTCLOSE:
     574      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bSoftClose ); break;
     575             :                 case PROPERTY_CONTEXTACTIVE:
     576      161078 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.bContextActive ); break;
     577             :                 case PROPERTY_DOCKINGAREA:
     578       81599 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aDockingArea ); break;
     579             :                 case PROPERTY_POS:
     580        3249 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aPos ); break;
     581             :                 case PROPERTY_SIZE:
     582        3163 :                     aPropSeq[nIndex].Value = makeAny( rWinStateInfo.aSize ); break;
     583             :                 case PROPERTY_UINAME:
     584      161078 :                     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      161078 :                     aPropSeq[nIndex].Value = makeAny( sal_Int16( rWinStateInfo.nStyle )); break;
     589             :                 case PROPERTY_DOCKPOS:
     590       80164 :                     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      161078 :     return makeAny( aPropSeq );
     600             : }
     601             : 
     602        4509 : Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence( const OUString& rResourceURL, Reference< XNameAccess >& xNameAccess )
     603             : {
     604        4509 :     sal_Int32                 nMask( 0 );
     605        4509 :     sal_Int32                 nCount( m_aPropArray.size() );
     606        4509 :     sal_Int32                 i( 0 );
     607        4509 :     sal_Int32                 nIndex( 0 );
     608        4509 :     Sequence< PropertyValue > aPropSeq;
     609        9018 :     WindowStateInfo           aWindowStateInfo;
     610             : 
     611       76653 :     for ( i = 0; i < nCount; i++ )
     612             :     {
     613             :         try
     614             :         {
     615       72144 :             bool    bAddToSeq( false );
     616       72144 :             Any     a( xNameAccess->getByName( m_aPropArray[i] ) );
     617       72144 :             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       36072 :                     if ( a >>= bValue )
     630             :                     {
     631       36072 :                         sal_Int32 nValue( 1 << i );
     632       36072 :                         nMask |= nValue;
     633       36072 :                         bAddToSeq = true;
     634       36072 :                         switch ( i )
     635             :                         {
     636             :                             case PROPERTY_LOCKED:
     637        4509 :                                 aWindowStateInfo.bLocked = bValue; break;
     638             :                             case PROPERTY_DOCKED:
     639        4509 :                                 aWindowStateInfo.bDocked = bValue; break;
     640             :                             case PROPERTY_VISIBLE:
     641        4509 :                                 aWindowStateInfo.bVisible = bValue; break;
     642             :                             case PROPERTY_CONTEXT:
     643        4509 :                                 aWindowStateInfo.bContext = bValue; break;
     644             :                             case PROPERTY_HIDEFROMMENU:
     645        4509 :                                 aWindowStateInfo.bHideFromMenu = bValue; break;
     646             :                             case PROPERTY_NOCLOSE:
     647        4509 :                                 aWindowStateInfo.bNoClose = bValue; break;
     648             :                             case PROPERTY_SOFTCLOSE:
     649        4509 :                                 aWindowStateInfo.bSoftClose = bValue; break;
     650             :                             case PROPERTY_CONTEXTACTIVE:
     651        4509 :                                 aWindowStateInfo.bContextActive = bValue; break;
     652             :                         }
     653             :                     }
     654             :                 }
     655       36072 :                 break;
     656             : 
     657             :                 case PROPERTY_DOCKINGAREA:
     658             :                 {
     659        4509 :                     sal_Int32 nDockingArea = 0;
     660        4509 :                     if ( a >>= nDockingArea )
     661             :                     {
     662        4142 :                         if (( nDockingArea >= 0 ) &&
     663        2071 :                             ( nDockingArea <= sal_Int32( DockingArea_DOCKINGAREA_RIGHT )))
     664             :                         {
     665        2071 :                             aWindowStateInfo.aDockingArea = (DockingArea)nDockingArea;
     666        2071 :                             nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
     667        2071 :                             a = makeAny( aWindowStateInfo.aDockingArea );
     668        2071 :                             bAddToSeq = true;
     669             :                         }
     670             :                     }
     671             :                 }
     672        4509 :                 break;
     673             : 
     674             :                 case PROPERTY_POS:
     675             :                 case PROPERTY_DOCKPOS:
     676             :                 {
     677        9018 :                     OUString aString;
     678        9018 :                     if ( a >>= aString )
     679             :                     {
     680        1941 :                         sal_Int32 nToken( 0 );
     681        1941 :                         OUString aXStr = aString.getToken( 0, ',', nToken );
     682        1941 :                         if ( nToken > 0 )
     683             :                         {
     684        1941 :                             com::sun::star::awt::Point aPos;
     685        1941 :                             aPos.X = aXStr.toInt32();
     686        1941 :                             aPos.Y = aString.getToken( 0, ',', nToken ).toInt32();
     687             : 
     688        1941 :                             if ( i == PROPERTY_POS )
     689             :                             {
     690          28 :                                 aWindowStateInfo.aPos = aPos;
     691          28 :                                 nMask |= WINDOWSTATE_MASK_POS;
     692             :                             }
     693             :                             else
     694             :                             {
     695        1913 :                                 aWindowStateInfo.aDockPos = aPos;
     696        1913 :                                 nMask |= WINDOWSTATE_MASK_DOCKPOS;
     697             :                             }
     698             : 
     699        1941 :                             a <<= aPos;
     700        1941 :                             bAddToSeq = true;
     701        1941 :                         }
     702        9018 :                     }
     703             :                 }
     704        9018 :                 break;
     705             : 
     706             :                 case PROPERTY_SIZE:
     707             :                 case PROPERTY_DOCKSIZE:
     708             :                 {
     709        9018 :                     OUString aString;
     710        9018 :                     if ( a >>= aString )
     711             :                     {
     712          18 :                         sal_Int32 nToken( 0 );
     713          18 :                         OUString aStr = aString.getToken( 0, ',', nToken );
     714          18 :                         if ( nToken > 0 )
     715             :                         {
     716          18 :                             com::sun::star::awt::Size aSize;
     717          18 :                             aSize.Width = aStr.toInt32();
     718          18 :                             aSize.Height = aString.getToken( 0, ',', nToken ).toInt32();
     719          18 :                             if ( i == PROPERTY_SIZE )
     720             :                             {
     721          18 :                                 aWindowStateInfo.aSize = aSize;
     722          18 :                                 nMask |= WINDOWSTATE_MASK_SIZE;
     723             :                             }
     724             :                             else
     725             :                             {
     726           0 :                                 aWindowStateInfo.aDockSize = aSize;
     727           0 :                                 nMask |= WINDOWSTATE_MASK_DOCKSIZE;
     728             :                             }
     729             : 
     730          18 :                             a <<= aSize;
     731          18 :                             bAddToSeq = true;
     732          18 :                         }
     733        9018 :                     }
     734             :                 }
     735        9018 :                 break;
     736             : 
     737             :                 case PROPERTY_UINAME:
     738             :                 {
     739        4509 :                     OUString aValue;
     740        4509 :                     if ( a >>= aValue )
     741             :                     {
     742        4509 :                         nMask |= WINDOWSTATE_MASK_UINAME;
     743        4509 :                         aWindowStateInfo.aUIName = aValue;
     744        4509 :                         bAddToSeq = true;
     745        4509 :                     }
     746             :                 }
     747        4509 :                 break;
     748             : 
     749             :                 case PROPERTY_INTERNALSTATE:
     750             :                 {
     751        4509 :                     sal_uInt32 nValue = 0;
     752        4509 :                     if ( a >>= nValue )
     753             :                     {
     754           0 :                         nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
     755           0 :                         aWindowStateInfo.nInternalState = nValue;
     756           0 :                         bAddToSeq = true;
     757             :                     }
     758             :                 }
     759        4509 :                 break;
     760             : 
     761             :                 case PROPERTY_STYLE:
     762             :                 {
     763        4509 :                     sal_Int32 nValue = 0;
     764        4509 :                     if ( a >>= nValue )
     765             :                     {
     766        4509 :                         nMask |= WINDOWSTATE_MASK_STYLE;
     767        4509 :                         aWindowStateInfo.nStyle = sal_uInt16( nValue );
     768        4509 :                         bAddToSeq = true;
     769             :                     }
     770             :                 }
     771        4509 :                 break;
     772             : 
     773             :                 default:
     774             :                     DBG_ASSERT( false, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
     775             :             }
     776             : 
     777       72144 :             if ( bAddToSeq )
     778             :             {
     779             :                 // put value into the return sequence
     780       49120 :                 nIndex = aPropSeq.getLength();
     781       49120 :                 aPropSeq.realloc( nIndex+1 );
     782       49120 :                 aPropSeq[nIndex].Name  = m_aPropArray[i];
     783       49120 :                 aPropSeq[nIndex].Value = a;
     784       72144 :             }
     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        4509 :     aWindowStateInfo.nMask = nMask;
     795        4509 :     m_aResourceURLToInfoCache.insert( ResourceURLToInfoCache::value_type( rResourceURL, aWindowStateInfo ));
     796        9018 :     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        7822 : Any ConfigurationAccess_WindowState::impl_getWindowStateFromResourceURL( const OUString& rResourceURL )
     975             : {
     976        7822 :     if ( !m_bConfigAccessInitialized )
     977             :     {
     978          56 :         impl_initializeConfigAccess();
     979          56 :         m_bConfigAccessInitialized = true;
     980             :     }
     981             : 
     982             :     try
     983             :     {
     984             :         // Try to ask our configuration access
     985        7822 :         if ( m_xConfigAccess.is() && m_xConfigAccess->hasByName( rResourceURL ) )
     986             :         {
     987             : 
     988        4509 :             Reference< XNameAccess > xNameAccess( m_xConfigAccess->getByName( rResourceURL ), UNO_QUERY );
     989        4509 :             if ( xNameAccess.is() )
     990        4509 :                 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        3313 :     return Any();
    1001             : }
    1002             : 
    1003        1772 : void ConfigurationAccess_WindowState::impl_fillStructFromSequence( WindowStateInfo& rWinStateInfo, const Sequence< PropertyValue >& rSeq )
    1004             : {
    1005        1772 :     sal_Int32 nCompareCount( m_aPropArray.size() );
    1006        1772 :     sal_Int32 nCount( rSeq.getLength() );
    1007        1772 :     sal_Int32 i( 0 );
    1008             : 
    1009       17720 :     for ( i = 0; i < nCount; i++ )
    1010             :     {
    1011      136444 :         for ( sal_Int32 j = 0; j < nCompareCount; j++ )
    1012             :         {
    1013      136444 :             if ( rSeq[i].Name.equals( m_aPropArray[j] ))
    1014             :             {
    1015       15948 :                 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        5316 :                         if ( rSeq[i].Value >>= bValue )
    1028             :                         {
    1029        5316 :                             sal_Int32 nValue( 1 << j );
    1030        5316 :                             rWinStateInfo.nMask |= nValue;
    1031        5316 :                             switch ( j )
    1032             :                             {
    1033             :                                 case PROPERTY_LOCKED:
    1034        1772 :                                     rWinStateInfo.bLocked = bValue;
    1035        1772 :                                     break;
    1036             :                                 case PROPERTY_DOCKED:
    1037        1772 :                                     rWinStateInfo.bDocked = bValue;
    1038        1772 :                                     break;
    1039             :                                 case PROPERTY_VISIBLE:
    1040        1772 :                                     rWinStateInfo.bVisible = bValue;
    1041        1772 :                                     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        5316 :                     break;
    1061             : 
    1062             :                     case PROPERTY_DOCKINGAREA:
    1063             :                     {
    1064             :                         ::com::sun::star::ui::DockingArea eDockingArea;
    1065        1772 :                         if ( rSeq[i].Value >>= eDockingArea )
    1066             :                         {
    1067        1772 :                             rWinStateInfo.aDockingArea = eDockingArea;
    1068        1772 :                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
    1069             :                         }
    1070             :                     }
    1071        1772 :                     break;
    1072             : 
    1073             :                     case PROPERTY_POS:
    1074             :                     case PROPERTY_DOCKPOS:
    1075             :                     {
    1076        3544 :                         com::sun::star::awt::Point aPoint;
    1077        3544 :                         if ( rSeq[i].Value >>= aPoint )
    1078             :                         {
    1079        3544 :                             if ( j == PROPERTY_POS )
    1080             :                             {
    1081        1772 :                                 rWinStateInfo.aPos = aPoint;
    1082        1772 :                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_POS;
    1083             :                             }
    1084             :                             else
    1085             :                             {
    1086        1772 :                                 rWinStateInfo.aDockPos = aPoint;
    1087        1772 :                                 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKPOS;
    1088             :                             }
    1089             :                         }
    1090             :                     }
    1091        3544 :                     break;
    1092             : 
    1093             :                     case PROPERTY_SIZE:
    1094             :                     case PROPERTY_DOCKSIZE:
    1095             :                     {
    1096        1772 :                         com::sun::star::awt::Size aSize;
    1097        1772 :                         if ( rSeq[i].Value >>= aSize )
    1098             :                         {
    1099        1772 :                             if ( j == PROPERTY_SIZE )
    1100             :                             {
    1101        1772 :                                 rWinStateInfo.aSize = aSize;
    1102        1772 :                                 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        1772 :                     break;
    1112             : 
    1113             :                     case PROPERTY_UINAME:
    1114             :                     {
    1115        1772 :                         OUString aValue;
    1116        1772 :                         if ( rSeq[i].Value >>= aValue )
    1117             :                         {
    1118        1772 :                             rWinStateInfo.aUIName = aValue;
    1119        1772 :                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_UINAME;
    1120        1772 :                         }
    1121             :                     }
    1122        1772 :                     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        1772 :                         sal_Int32 nValue = 0;
    1138        1772 :                         if ( rSeq[i].Value >>= nValue )
    1139             :                         {
    1140        1772 :                             rWinStateInfo.nStyle = sal_uInt16( nValue );
    1141        1772 :                             rWinStateInfo.nMask |= WINDOWSTATE_MASK_STYLE;
    1142             :                         }
    1143             :                     }
    1144        1772 :                     break;
    1145             : 
    1146             :                     default:
    1147             :                         DBG_ASSERT( false, "Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
    1148             :                 }
    1149             : 
    1150       15948 :                 break;
    1151             :             }
    1152             :         }
    1153             :     }
    1154        1772 : }
    1155             : 
    1156        1772 : void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct( const WindowStateInfo& rWinStateInfo, Reference< XPropertySet >& xPropSet )
    1157             : {
    1158        1772 :     sal_Int32                 i( 0 );
    1159        1772 :     sal_Int32                 nCount( m_aPropArray.size() );
    1160        1772 :     OUString                  aDelim( "," );
    1161             : 
    1162       30124 :     for ( i = 0; i < nCount; i++ )
    1163             :     {
    1164       28352 :         if ( rWinStateInfo.nMask & ( 1 << i ))
    1165             :         {
    1166             :             try
    1167             :             {
    1168             :                 // put values into the property set
    1169       24808 :                 switch ( i )
    1170             :                 {
    1171             :                     case PROPERTY_LOCKED:
    1172        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bLocked ) ); break;
    1173             :                     case PROPERTY_DOCKED:
    1174        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bDocked ) ); break;
    1175             :                     case PROPERTY_VISIBLE:
    1176        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bVisible ) ); break;
    1177             :                     case PROPERTY_CONTEXT:
    1178        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bContext ) ); break;
    1179             :                     case PROPERTY_HIDEFROMMENU:
    1180        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bHideFromMenu ) ); break;
    1181             :                     case PROPERTY_NOCLOSE:
    1182        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bNoClose ) ); break;
    1183             :                     case PROPERTY_SOFTCLOSE:
    1184        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bSoftClose ) ); break;
    1185             :                     case PROPERTY_CONTEXTACTIVE:
    1186        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( rWinStateInfo.bContextActive ) ); break;
    1187             :                     case PROPERTY_DOCKINGAREA:
    1188        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( sal_Int16( rWinStateInfo.aDockingArea ) ) ); break;
    1189             :                     case PROPERTY_POS:
    1190             :                     case PROPERTY_DOCKPOS:
    1191             :                     {
    1192        3544 :                         OUString aPosStr;
    1193        3544 :                         if ( i == PROPERTY_POS )
    1194        1772 :                             aPosStr = OUString::number( rWinStateInfo.aPos.X );
    1195             :                         else
    1196        1772 :                             aPosStr = OUString::number( rWinStateInfo.aDockPos.X );
    1197        3544 :                         aPosStr += aDelim;
    1198        3544 :                         if ( i == PROPERTY_POS )
    1199        1772 :                             aPosStr += OUString::number( rWinStateInfo.aPos.Y );
    1200             :                         else
    1201        1772 :                             aPosStr += OUString::number( rWinStateInfo.aDockPos.Y );
    1202        3544 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aPosStr ) );
    1203        3544 :                         break;
    1204             :                     }
    1205             :                     case PROPERTY_SIZE:
    1206             :                     case PROPERTY_DOCKSIZE:
    1207             :                     {
    1208        1772 :                         OUString aSizeStr;
    1209        1772 :                         if ( i == PROPERTY_SIZE )
    1210        1772 :                             aSizeStr = ( OUString::number( rWinStateInfo.aSize.Width ));
    1211             :                         else
    1212           0 :                             aSizeStr = ( OUString::number( rWinStateInfo.aDockSize.Width ));
    1213        1772 :                         aSizeStr += aDelim;
    1214        1772 :                         if ( i == PROPERTY_SIZE )
    1215        1772 :                             aSizeStr += OUString::number( rWinStateInfo.aSize.Height );
    1216             :                         else
    1217           0 :                             aSizeStr += OUString::number( rWinStateInfo.aDockSize.Height );
    1218        1772 :                         xPropSet->setPropertyValue( m_aPropArray[i], makeAny( aSizeStr ) );
    1219        1772 :                         break;
    1220             :                     }
    1221             :                     case PROPERTY_UINAME:
    1222        1772 :                         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        1772 :                         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        1772 :     }
    1236        1772 : }
    1237             : 
    1238         130 : bool ConfigurationAccess_WindowState::impl_initializeConfigAccess()
    1239             : {
    1240         130 :     Sequence< Any > aArgs( 2 );
    1241         260 :     PropertyValue   aPropValue;
    1242             : 
    1243             :     try
    1244             :     {
    1245         130 :         aPropValue.Name  = "nodepath";
    1246         130 :         aPropValue.Value <<= m_aConfigWindowAccess;
    1247         130 :         aArgs[0] <<= aPropValue;
    1248         130 :         aPropValue.Name = "lazywrite";
    1249         130 :         aPropValue.Value <<= sal_True;
    1250         130 :         aArgs[1] <<= aPropValue;
    1251             : 
    1252         390 :         m_xConfigAccess = Reference< XNameAccess >( m_xConfigProvider->createInstanceWithArguments(
    1253         260 :                     "com.sun.star.configuration.ConfigurationUpdateAccess", aArgs ), UNO_QUERY );
    1254         130 :         if ( m_xConfigAccess.is() )
    1255             :         {
    1256             :             // Add as container listener
    1257         130 :             Reference< XContainer > xContainer( m_xConfigAccess, UNO_QUERY );
    1258         130 :             if ( xContainer.is() )
    1259             :             {
    1260         130 :                 m_xConfigListener = new WeakContainerListener(this);
    1261         130 :                 xContainer->addContainerListener(m_xConfigListener);
    1262         130 :             }
    1263             :         }
    1264             : 
    1265         130 :         return true;
    1266             :     }
    1267           0 :     catch ( const WrappedTargetException& )
    1268             :     {
    1269             :     }
    1270           0 :     catch ( const Exception& )
    1271             :     {
    1272             :     }
    1273             : 
    1274         130 :     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           1 :     virtual OUString SAL_CALL getImplementationName()
    1288             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
    1289             :     {
    1290           1 :         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           1 :     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
    1300             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
    1301             :     {
    1302           1 :         css::uno::Sequence< OUString > aSeq(1);
    1303           1 :         aSeq[0] = "com.sun.star.ui.WindowStateConfiguration";
    1304           1 :         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 std::unordered_map< OUString,
    1324             :                                 OUString,
    1325             :                                 OUStringHash,
    1326             :                                 std::equal_to< OUString > > ModuleToWindowStateFileMap;
    1327             : 
    1328             :     typedef std::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         111 : WindowStateConfiguration::WindowStateConfiguration( const Reference< XComponentContext >& rxContext ) :
    1340             :     WindowStateConfiguration_BASE(m_aMutex),
    1341         111 :     m_xContext( rxContext )
    1342             : {
    1343             :     css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
    1344         111 :         ModuleManager::create( m_xContext );
    1345         222 :     Reference< XNameAccess > xEmptyNameAccess;
    1346         222 :     Sequence< OUString > aElementNames;
    1347             :     try
    1348             :     {
    1349         111 :         aElementNames = xModuleManager->getElementNames();
    1350             :     }
    1351           0 :     catch (const ::com::sun::star::uno::RuntimeException &)
    1352             :     {
    1353             :     }
    1354         222 :     Sequence< PropertyValue > aSeq;
    1355         222 :     OUString                  aModuleIdentifier;
    1356             : 
    1357        2442 :     for ( sal_Int32 i = 0; i < aElementNames.getLength(); i++ )
    1358             :     {
    1359        2331 :         aModuleIdentifier = aElementNames[i];
    1360        2331 :         if ( xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
    1361             :         {
    1362        2331 :             OUString aWindowStateFileStr;
    1363        2331 :             for ( sal_Int32 y = 0; y < aSeq.getLength(); y++ )
    1364             :             {
    1365        2331 :                 if ( aSeq[y].Name == "ooSetupFactoryWindowStateConfigRef" )
    1366             :                 {
    1367        2331 :                     aSeq[y].Value >>= aWindowStateFileStr;
    1368        2331 :                     break;
    1369             :                 }
    1370             :             }
    1371             : 
    1372        2331 :             if ( !aWindowStateFileStr.isEmpty() )
    1373             :             {
    1374             :                 // Create first mapping ModuleIdentifier ==> Window state configuration file
    1375        2331 :                 m_aModuleToFileHashMap.insert( ModuleToWindowStateFileMap::value_type( aModuleIdentifier, aWindowStateFileStr ));
    1376             : 
    1377             :                 // Create second mapping Command File ==> Window state configuration instance
    1378        2331 :                 ModuleToWindowStateConfigHashMap::iterator pIter = m_aModuleToWindowStateHashMap.find( aWindowStateFileStr );
    1379        2331 :                 if ( pIter == m_aModuleToWindowStateHashMap.end() )
    1380        2220 :                     m_aModuleToWindowStateHashMap.insert( ModuleToWindowStateConfigHashMap::value_type( aWindowStateFileStr, xEmptyNameAccess ));
    1381        2331 :             }
    1382             :         }
    1383         111 :     }
    1384         111 : }
    1385             : 
    1386         300 : WindowStateConfiguration::~WindowStateConfiguration()
    1387             : {
    1388         100 :     osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
    1389         100 :     m_aModuleToFileHashMap.clear();
    1390         100 :     m_aModuleToWindowStateHashMap.clear();
    1391         200 : }
    1392             : 
    1393        3292 : 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        3292 :     osl::MutexGuard g(cppu::WeakComponentImplHelperBase::rBHelper.rMutex);
    1397             : 
    1398        3292 :     ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aModuleIdentifier );
    1399        3292 :     if ( pIter != m_aModuleToFileHashMap.end() )
    1400             :     {
    1401        3292 :         Any a;
    1402        3292 :         OUString aWindowStateConfigFile( pIter->second );
    1403             : 
    1404        3292 :         ModuleToWindowStateConfigHashMap::iterator pModuleIter = m_aModuleToWindowStateHashMap.find( aWindowStateConfigFile );
    1405        3292 :         if ( pModuleIter != m_aModuleToWindowStateHashMap.end() )
    1406             :         {
    1407        3292 :             if ( pModuleIter->second.is() )
    1408        3160 :                 a = makeAny( pModuleIter->second );
    1409             :             else
    1410             :             {
    1411         132 :                 Reference< XNameAccess > xResourceURLWindowState;
    1412         132 :                 ConfigurationAccess_WindowState* pModuleWindowState = new ConfigurationAccess_WindowState( aWindowStateConfigFile, m_xContext );
    1413         132 :                 xResourceURLWindowState = Reference< XNameAccess >( static_cast< cppu::OWeakObject* >( pModuleWindowState ),UNO_QUERY );
    1414         132 :                 pModuleIter->second = xResourceURLWindowState;
    1415         132 :                 a <<= xResourceURLWindowState;
    1416             :             }
    1417             : 
    1418        6584 :             return a;
    1419           0 :         }
    1420             :     }
    1421             : 
    1422        3292 :     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         111 : struct Instance {
    1467         111 :     explicit Instance(
    1468             :         css::uno::Reference<css::uno::XComponentContext> const & context):
    1469             :         instance(static_cast<cppu::OWeakObject *>(
    1470         111 :                     new WindowStateConfiguration(context)))
    1471             :     {
    1472         111 :     }
    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         112 : 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         112 :                 Singleton::get(context).instance.get()));
    1491             : }
    1492             : 
    1493             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11