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>
50#include <unordered_map>
66const sal_Int16 PROPERTY_LOCKED = 0;
67const sal_Int16 PROPERTY_DOCKED = 1;
69const sal_Int16 PROPERTY_CONTEXT = 3;
70const sal_Int16 PROPERTY_HIDEFROMMENU = 4;
71const sal_Int16 PROPERTY_NOCLOSE = 5;
72const sal_Int16 PROPERTY_SOFTCLOSE = 6;
73const sal_Int16 PROPERTY_CONTEXTACTIVE = 7;
74const sal_Int16 PROPERTY_DOCKINGAREA = 8;
75const sal_Int16 PROPERTY_POS = 9;
77const sal_Int16 PROPERTY_UINAME = 11;
78const sal_Int16 PROPERTY_INTERNALSTATE = 12;
79const sal_Int16 PROPERTY_STYLE = 13;
80const sal_Int16 PROPERTY_DOCKPOS = 14;
81const sal_Int16 PROPERTY_DOCKSIZE = 15;
84rtl::OUStringConstExpr CONFIGURATION_PROPERTIES[]
106class ConfigurationAccess_WindowState :
public ::cppu::WeakImplHelper< XNameContainer, XContainerListener >
110 virtual ~ConfigurationAccess_WindowState()
override;
113 virtual css::uno::Any SAL_CALL getByName(
const OUString& aName )
override;
115 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
override;
117 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override;
120 virtual void SAL_CALL removeByName(
const OUString& sName )
override;
122 virtual void SAL_CALL insertByName(
const OUString& sName,
const css::uno::Any& aPropertySet )
override;
125 virtual void SAL_CALL replaceByName(
const OUString& sName,
const css::uno::Any& aPropertySet )
override;
128 virtual css::uno::Type SAL_CALL getElementType()
override;
130 virtual sal_Bool SAL_CALL hasElements()
override;
133 virtual void SAL_CALL
elementInserted(
const ContainerEvent& aEvent )
override;
134 virtual void SAL_CALL
elementRemoved (
const ContainerEvent& aEvent )
override;
135 virtual void SAL_CALL
elementReplaced(
const ContainerEvent& aEvent )
override;
138 virtual void SAL_CALL disposing(
const EventObject& aEvent )
override;
143 WINDOWSTATE_MASK_DOCKINGAREA = 256,
144 WINDOWSTATE_MASK_POS = 512,
145 WINDOWSTATE_MASK_SIZE = 1024,
146 WINDOWSTATE_MASK_UINAME = 2048,
147 WINDOWSTATE_MASK_INTERNALSTATE = 4096,
148 WINDOWSTATE_MASK_STYLE = 8192,
149 WINDOWSTATE_MASK_DOCKPOS = 16384,
150 WINDOWSTATE_MASK_DOCKSIZE = 32768
155 struct WindowStateInfo
162 , bHideFromMenu(false)
165 , bContextActive(false)
166 , aDockingArea(css::ui::DockingArea_DOCKINGAREA_TOP)
184 css::ui::DockingArea aDockingArea;
185 css::awt::Point aDockPos;
186 css::awt::Size aDockSize;
187 css::awt::Point aPos;
188 css::awt::Size aSize;
190 sal_uInt32 nInternalState;
197 WindowStateInfo& impl_insertCacheAndReturnWinState(
const OUString& rResourceURL,
Reference< XNameAccess > const & rNameAccess );
198 Any impl_getSequenceFromStruct(
const WindowStateInfo& rWinStateInfo );
200 Any impl_getWindowStateFromResourceURL(
const OUString& rResourceURL );
201 void impl_initializeConfigAccess();
204 typedef std::unordered_map< OUString,
205 WindowStateInfo > ResourceURLToInfoCache;
208 OUString m_aConfigWindowAccess;
212 ResourceURLToInfoCache m_aResourceURLToInfoCache;
215 std::vector< OUString > m_aPropArray;
218ConfigurationAccess_WindowState::ConfigurationAccess_WindowState( std::u16string_view aModuleName,
const Reference< XComponentContext >& rxContext ) :
220 m_aConfigWindowAccess(
221 OUString::
Concat(
"/org.openoffice.Office.UI.") + aModuleName +
"/UIElements/States"),
227 for (
const rtl::OUStringConstExpr & s : CONFIGURATION_PROPERTIES )
228 m_aPropArray.push_back(s);
231ConfigurationAccess_WindowState::~ConfigurationAccess_WindowState()
236 if ( xContainer.is() )
241Any SAL_CALL ConfigurationAccess_WindowState::getByName(
const OUString& rResourceURL )
246 ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
247 if ( pIter != m_aResourceURLToInfoCache.end() )
248 return impl_getSequenceFromStruct( pIter->second );
251 Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
253 throw NoSuchElementException();
265 impl_initializeConfigAccess();
275sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasByName(
const OUString& rResourceURL )
280 ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
281 if ( pIter != m_aResourceURLToInfoCache.end() )
285 Any a( impl_getWindowStateFromResourceURL( rResourceURL ) );
294Type SAL_CALL ConfigurationAccess_WindowState::getElementType()
299sal_Bool SAL_CALL ConfigurationAccess_WindowState::hasElements()
306 impl_initializeConfigAccess();
317void SAL_CALL ConfigurationAccess_WindowState::removeByName(
const OUString& rResourceURL )
322 ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
323 if ( pIter != m_aResourceURLToInfoCache.end() )
324 m_aResourceURLToInfoCache.erase( pIter );
328 impl_initializeConfigAccess();
336 if ( xNameContainer.is() )
340 xNameContainer->removeByName( rResourceURL );
343 xFlush->commitChanges();
346 catch (
const css::lang::WrappedTargetException& )
351void SAL_CALL ConfigurationAccess_WindowState::insertByName(
const OUString& rResourceURL,
const css::uno::Any& aPropertySet )
357 if ( !(aPropertySet >>= aPropSet) )
358 throw IllegalArgumentException();
360 ResourceURLToInfoCache::const_iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
361 if ( pIter != m_aResourceURLToInfoCache.end() )
362 throw ElementExistException();
366 impl_initializeConfigAccess();
375 throw ElementExistException();
377 WindowStateInfo aWinStateInfo;
378 impl_fillStructFromSequence( aWinStateInfo, aPropSet );
379 m_aResourceURLToInfoCache.emplace( rResourceURL, aWinStateInfo );
383 if ( !xNameContainer.is() )
395 impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
397 xNameContainer->insertByName( rResourceURL, a );
400 xFlush->commitChanges();
403 catch (
const Exception& )
409void SAL_CALL ConfigurationAccess_WindowState::replaceByName(
const OUString& rResourceURL,
const css::uno::Any& aPropertySet )
415 if ( !(aPropertySet >>= aPropSet) )
416 throw IllegalArgumentException();
418 ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.find( rResourceURL );
419 if ( pIter != m_aResourceURLToInfoCache.end() )
421 WindowStateInfo& rWinStateInfo = pIter->second;
422 impl_fillStructFromSequence( rWinStateInfo, aPropSet );
429 impl_initializeConfigAccess();
437 if ( !(a >>= xNameAccess) )
438 throw NoSuchElementException();
440 WindowStateInfo& rWinStateInfo( impl_insertCacheAndReturnWinState( rResourceURL, xNameAccess ));
441 impl_fillStructFromSequence( rWinStateInfo, aPropSet );
443 pIter = m_aResourceURLToInfoCache.find( rResourceURL );
447 if ( !(m_bModified && pIter != m_aResourceURLToInfoCache.end()) )
451 if ( !xNameContainer.is() )
454 WindowStateInfo aWinStateInfo( pIter->second );
455 OUString aResourceURL( pIter->first );
462 if ( xNameContainer->getByName( aResourceURL ) >>= xPropSet )
464 impl_putPropertiesFromStruct( aWinStateInfo, xPropSet );
468 xFlush->commitChanges();
471 catch (
const Exception& )
478void SAL_CALL ConfigurationAccess_WindowState::elementInserted(
const ContainerEvent& )
483void SAL_CALL ConfigurationAccess_WindowState::elementRemoved (
const ContainerEvent& )
487void SAL_CALL ConfigurationAccess_WindowState::elementReplaced(
const ContainerEvent& )
492void SAL_CALL ConfigurationAccess_WindowState::disposing(
const EventObject& aEvent )
500 if ( xIfac1 == xIfac2 )
505Any ConfigurationAccess_WindowState::impl_getSequenceFromStruct(
const WindowStateInfo& rWinStateInfo )
508 sal_Int32
nCount( m_aPropArray.size() );
509 std::vector< PropertyValue > aPropVec;
513 if ( rWinStateInfo.nMask & ( 1 << i ))
517 pv.Name = m_aPropArray[
i];
521 case PROPERTY_LOCKED:
522 pv.Value <<= rWinStateInfo.bLocked;
break;
523 case PROPERTY_DOCKED:
524 pv.Value <<= rWinStateInfo.bDocked;
break;
526 pv.Value <<= rWinStateInfo.bVisible;
break;
527 case PROPERTY_CONTEXT:
528 pv.Value <<= rWinStateInfo.bContext;
break;
529 case PROPERTY_HIDEFROMMENU:
530 pv.Value <<= rWinStateInfo.bHideFromMenu;
break;
531 case PROPERTY_NOCLOSE:
532 pv.Value <<= rWinStateInfo.bNoClose;
break;
533 case PROPERTY_SOFTCLOSE:
534 pv.Value <<= rWinStateInfo.bSoftClose;
break;
535 case PROPERTY_CONTEXTACTIVE:
536 pv.Value <<= rWinStateInfo.bContextActive;
break;
537 case PROPERTY_DOCKINGAREA:
538 pv.Value <<= rWinStateInfo.aDockingArea;
break;
540 pv.Value <<= rWinStateInfo.aPos;
break;
542 pv.Value <<= rWinStateInfo.aSize;
break;
543 case PROPERTY_UINAME:
544 pv.Value <<= rWinStateInfo.aUIName;
break;
545 case PROPERTY_INTERNALSTATE:
546 pv.Value <<= sal_Int32( rWinStateInfo.nInternalState );
break;
548 pv.Value <<= sal_Int16( rWinStateInfo.nStyle );
break;
549 case PROPERTY_DOCKPOS:
550 pv.Value <<= rWinStateInfo.aDockPos;
break;
551 case PROPERTY_DOCKSIZE:
552 pv.Value <<= rWinStateInfo.aDockSize;
break;
554 assert(
false &&
"Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
556 aPropVec.push_back(pv);
563Any ConfigurationAccess_WindowState::impl_insertCacheAndReturnSequence(
const OUString& rResourceURL,
Reference< XNameAccess > const & xNameAccess )
565 sal_Int32 nMask( 0 );
566 sal_Int32
nCount( m_aPropArray.size() );
568 std::vector< PropertyValue > aPropVec;
569 WindowStateInfo aWindowStateInfo;
575 bool bAddToSeq(
false );
576 Any a( xNameAccess->getByName( m_aPropArray[i] ) );
579 case PROPERTY_LOCKED:
580 case PROPERTY_DOCKED:
582 case PROPERTY_CONTEXT:
583 case PROPERTY_HIDEFROMMENU:
584 case PROPERTY_NOCLOSE:
585 case PROPERTY_SOFTCLOSE:
586 case PROPERTY_CONTEXTACTIVE:
591 sal_Int32
nValue( 1 << i );
596 case PROPERTY_LOCKED:
597 aWindowStateInfo.bLocked = bValue;
break;
598 case PROPERTY_DOCKED:
599 aWindowStateInfo.bDocked = bValue;
break;
601 aWindowStateInfo.bVisible = bValue;
break;
602 case PROPERTY_CONTEXT:
603 aWindowStateInfo.bContext = bValue;
break;
604 case PROPERTY_HIDEFROMMENU:
605 aWindowStateInfo.bHideFromMenu = bValue;
break;
606 case PROPERTY_NOCLOSE:
607 aWindowStateInfo.bNoClose = bValue;
break;
608 case PROPERTY_SOFTCLOSE:
609 aWindowStateInfo.bSoftClose = bValue;
break;
610 case PROPERTY_CONTEXTACTIVE:
611 aWindowStateInfo.bContextActive = bValue;
break;
617 case PROPERTY_DOCKINGAREA:
619 sal_Int32 nDockingArea = 0;
620 if ( a >>= nDockingArea )
622 if (( nDockingArea >= 0 ) &&
623 ( nDockingArea <= sal_Int32( DockingArea_DOCKINGAREA_RIGHT )))
625 aWindowStateInfo.aDockingArea =
static_cast<DockingArea
>(nDockingArea);
626 nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
627 a <<= aWindowStateInfo.aDockingArea;
635 case PROPERTY_DOCKPOS:
641 std::u16string_view aXStr =
o3tl::getToken(aString, 0,
',', nToken );
644 css::awt::Point aPos;
648 if ( i == PROPERTY_POS )
650 aWindowStateInfo.aPos = aPos;
651 nMask |= WINDOWSTATE_MASK_POS;
655 aWindowStateInfo.aDockPos = aPos;
656 nMask |= WINDOWSTATE_MASK_DOCKPOS;
667 case PROPERTY_DOCKSIZE:
676 css::awt::Size aSize;
679 if ( i == PROPERTY_SIZE )
681 aWindowStateInfo.aSize = aSize;
682 nMask |= WINDOWSTATE_MASK_SIZE;
686 aWindowStateInfo.aDockSize = aSize;
687 nMask |= WINDOWSTATE_MASK_DOCKSIZE;
697 case PROPERTY_UINAME:
702 nMask |= WINDOWSTATE_MASK_UINAME;
703 aWindowStateInfo.aUIName = aValue;
709 case PROPERTY_INTERNALSTATE:
714 nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
715 aWindowStateInfo.nInternalState =
nValue;
726 nMask |= WINDOWSTATE_MASK_STYLE;
727 aWindowStateInfo.nStyle = sal_uInt16( nValue );
734 assert(
false &&
"Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
741 pv.Name = m_aPropArray[
i];
743 aPropVec.push_back(pv);
746 catch(
const css::container::NoSuchElementException& )
749 catch (
const css::lang::WrappedTargetException& )
754 aWindowStateInfo.nMask = nMask;
755 m_aResourceURLToInfoCache.emplace( rResourceURL, aWindowStateInfo );
759ConfigurationAccess_WindowState::WindowStateInfo& ConfigurationAccess_WindowState::impl_insertCacheAndReturnWinState(
const OUString& rResourceURL,
Reference< XNameAccess > const & rNameAccess )
761 sal_Int32 nMask( 0 );
762 sal_Int32
nCount( m_aPropArray.size() );
764 WindowStateInfo aWindowStateInfo;
770 Any a( rNameAccess->getByName( m_aPropArray[i] ) );
773 case PROPERTY_LOCKED:
774 case PROPERTY_DOCKED:
776 case PROPERTY_CONTEXT:
777 case PROPERTY_HIDEFROMMENU:
778 case PROPERTY_NOCLOSE:
779 case PROPERTY_SOFTCLOSE:
780 case PROPERTY_CONTEXTACTIVE:
785 sal_Int32
nValue( 1 << i );
789 case PROPERTY_LOCKED:
790 aWindowStateInfo.bLocked = bValue;
break;
791 case PROPERTY_DOCKED:
792 aWindowStateInfo.bDocked = bValue;
break;
794 aWindowStateInfo.bVisible = bValue;
break;
795 case PROPERTY_CONTEXT:
796 aWindowStateInfo.bContext = bValue;
break;
797 case PROPERTY_HIDEFROMMENU:
798 aWindowStateInfo.bHideFromMenu = bValue;
break;
799 case PROPERTY_NOCLOSE:
800 aWindowStateInfo.bNoClose = bValue;
break;
801 case PROPERTY_SOFTCLOSE:
802 aWindowStateInfo.bNoClose = bValue;
break;
803 case PROPERTY_CONTEXTACTIVE:
804 aWindowStateInfo.bContextActive = bValue;
break;
806 SAL_WARN(
"fwk.uiconfiguration",
"Unknown boolean property in WindowState found!" );
812 case PROPERTY_DOCKINGAREA:
814 sal_Int32 nDockingArea = 0;
815 if ( a >>= nDockingArea )
817 if (( nDockingArea >= 0 ) &&
818 ( nDockingArea <= sal_Int32( DockingArea_DOCKINGAREA_RIGHT )))
820 aWindowStateInfo.aDockingArea =
static_cast<DockingArea
>(nDockingArea);
821 nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
828 case PROPERTY_DOCKPOS:
834 std::u16string_view aXStr =
o3tl::getToken(aString, 0,
',', nToken );
837 css::awt::Point aPos;
841 if ( i == PROPERTY_POS )
843 aWindowStateInfo.aPos = aPos;
844 nMask |= WINDOWSTATE_MASK_POS;
848 aWindowStateInfo.aDockPos = aPos;
849 nMask |= WINDOWSTATE_MASK_DOCKPOS;
857 case PROPERTY_DOCKSIZE:
866 css::awt::Size aSize;
869 if ( i == PROPERTY_SIZE )
871 aWindowStateInfo.aSize = aSize;
872 nMask |= WINDOWSTATE_MASK_SIZE;
876 aWindowStateInfo.aDockSize = aSize;
877 nMask |= WINDOWSTATE_MASK_DOCKSIZE;
884 case PROPERTY_UINAME:
889 nMask |= WINDOWSTATE_MASK_UINAME;
890 aWindowStateInfo.aUIName = aValue;
895 case PROPERTY_INTERNALSTATE:
900 nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
901 aWindowStateInfo.nInternalState = sal_uInt32( nValue );
911 nMask |= WINDOWSTATE_MASK_STYLE;
912 aWindowStateInfo.nStyle = sal_uInt16( nValue );
918 assert(
false &&
"Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
921 catch(
const css::container::NoSuchElementException& )
924 catch (
const css::lang::WrappedTargetException& )
929 aWindowStateInfo.nMask = nMask;
930 ResourceURLToInfoCache::iterator pIter = m_aResourceURLToInfoCache.emplace( rResourceURL, aWindowStateInfo ).first;
931 return pIter->second;
934Any ConfigurationAccess_WindowState::impl_getWindowStateFromResourceURL(
const OUString& rResourceURL )
938 impl_initializeConfigAccess();
949 if ( xNameAccess.is() )
950 return impl_insertCacheAndReturnSequence( rResourceURL, xNameAccess );
953 catch(
const css::container::NoSuchElementException& )
956 catch (
const css::lang::WrappedTargetException& )
963void ConfigurationAccess_WindowState::impl_fillStructFromSequence( WindowStateInfo& rWinStateInfo,
const Sequence< PropertyValue >& rSeq )
965 sal_Int32 nCompareCount( m_aPropArray.size() );
966 sal_Int32
nCount( rSeq.getLength() );
971 for ( sal_Int32 j = 0; j < nCompareCount; j++ )
973 if ( rSeq[i].Name == m_aPropArray[j] )
977 case PROPERTY_LOCKED:
978 case PROPERTY_DOCKED:
980 case PROPERTY_CONTEXT:
981 case PROPERTY_HIDEFROMMENU:
982 case PROPERTY_NOCLOSE:
983 case PROPERTY_SOFTCLOSE:
984 case PROPERTY_CONTEXTACTIVE:
987 if ( rSeq[i].Value >>= bValue )
989 sal_Int32
nValue( 1 << j );
990 rWinStateInfo.nMask |=
nValue;
993 case PROPERTY_LOCKED:
994 rWinStateInfo.bLocked = bValue;
996 case PROPERTY_DOCKED:
997 rWinStateInfo.bDocked = bValue;
1000 rWinStateInfo.bVisible = bValue;
1002 case PROPERTY_CONTEXT:
1003 rWinStateInfo.bContext = bValue;
1005 case PROPERTY_HIDEFROMMENU:
1006 rWinStateInfo.bHideFromMenu = bValue;
1008 case PROPERTY_NOCLOSE:
1009 rWinStateInfo.bNoClose = bValue;
1011 case PROPERTY_SOFTCLOSE:
1012 rWinStateInfo.bSoftClose = bValue;
1014 case PROPERTY_CONTEXTACTIVE:
1015 rWinStateInfo.bContextActive = bValue;
1022 case PROPERTY_DOCKINGAREA:
1024 css::ui::DockingArea eDockingArea;
1025 if ( rSeq[i].Value >>= eDockingArea )
1027 rWinStateInfo.aDockingArea = eDockingArea;
1028 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKINGAREA;
1034 case PROPERTY_DOCKPOS:
1036 css::awt::Point aPoint;
1037 if ( rSeq[i].Value >>= aPoint )
1039 if ( j == PROPERTY_POS )
1041 rWinStateInfo.aPos = aPoint;
1042 rWinStateInfo.nMask |= WINDOWSTATE_MASK_POS;
1046 rWinStateInfo.aDockPos = aPoint;
1047 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKPOS;
1054 case PROPERTY_DOCKSIZE:
1056 css::awt::Size aSize;
1057 if ( rSeq[i].Value >>= aSize )
1059 if ( j == PROPERTY_SIZE )
1061 rWinStateInfo.aSize = aSize;
1062 rWinStateInfo.nMask |= WINDOWSTATE_MASK_SIZE;
1066 rWinStateInfo.aDockSize = aSize;
1067 rWinStateInfo.nMask |= WINDOWSTATE_MASK_DOCKSIZE;
1073 case PROPERTY_UINAME:
1076 if ( rSeq[i].Value >>= aValue )
1078 rWinStateInfo.aUIName = aValue;
1079 rWinStateInfo.nMask |= WINDOWSTATE_MASK_UINAME;
1084 case PROPERTY_INTERNALSTATE:
1087 if ( rSeq[i].Value >>= nValue )
1089 rWinStateInfo.nInternalState = sal_uInt32( nValue );
1090 rWinStateInfo.nMask |= WINDOWSTATE_MASK_INTERNALSTATE;
1095 case PROPERTY_STYLE:
1098 if ( rSeq[i].Value >>= nValue )
1100 rWinStateInfo.nStyle = sal_uInt16( nValue );
1101 rWinStateInfo.nMask |= WINDOWSTATE_MASK_STYLE;
1107 assert(
false &&
"Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
1116void ConfigurationAccess_WindowState::impl_putPropertiesFromStruct(
const WindowStateInfo& rWinStateInfo,
Reference< XPropertySet > const & xPropSet )
1119 sal_Int32
nCount( m_aPropArray.size() );
1120 OUString aDelim(
"," );
1124 if ( rWinStateInfo.nMask & ( 1 << i ))
1131 case PROPERTY_LOCKED:
1132 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bLocked ) );
break;
1133 case PROPERTY_DOCKED:
1134 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bDocked ) );
break;
1136 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bVisible ) );
break;
1137 case PROPERTY_CONTEXT:
1138 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bContext ) );
break;
1139 case PROPERTY_HIDEFROMMENU:
1140 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bHideFromMenu ) );
break;
1141 case PROPERTY_NOCLOSE:
1142 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bNoClose ) );
break;
1143 case PROPERTY_SOFTCLOSE:
1144 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bSoftClose ) );
break;
1145 case PROPERTY_CONTEXTACTIVE:
1146 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.bContextActive ) );
break;
1147 case PROPERTY_DOCKINGAREA:
1148 xPropSet->setPropertyValue( m_aPropArray[i],
Any( sal_Int16( rWinStateInfo.aDockingArea ) ) );
break;
1150 case PROPERTY_DOCKPOS:
1153 if ( i == PROPERTY_POS )
1154 aPosStr = OUString::number( rWinStateInfo.aPos.X );
1156 aPosStr = OUString::number( rWinStateInfo.aDockPos.X );
1158 if ( i == PROPERTY_POS )
1159 aPosStr += OUString::number( rWinStateInfo.aPos.Y );
1161 aPosStr += OUString::number( rWinStateInfo.aDockPos.Y );
1162 xPropSet->setPropertyValue( m_aPropArray[i],
Any( aPosStr ) );
1166 case PROPERTY_DOCKSIZE:
1169 if ( i == PROPERTY_SIZE )
1170 aSizeStr = OUString::number( rWinStateInfo.aSize.Width );
1172 aSizeStr = OUString::number( rWinStateInfo.aDockSize.Width );
1174 if ( i == PROPERTY_SIZE )
1175 aSizeStr += OUString::number( rWinStateInfo.aSize.Height );
1177 aSizeStr += OUString::number( rWinStateInfo.aDockSize.Height );
1178 xPropSet->setPropertyValue( m_aPropArray[i],
Any( aSizeStr ) );
1181 case PROPERTY_UINAME:
1182 xPropSet->setPropertyValue( m_aPropArray[i],
Any( rWinStateInfo.aUIName ) );
break;
1183 case PROPERTY_INTERNALSTATE:
1184 xPropSet->setPropertyValue( m_aPropArray[i],
Any( sal_Int32( rWinStateInfo.nInternalState )) );
break;
1185 case PROPERTY_STYLE:
1186 xPropSet->setPropertyValue( m_aPropArray[i],
Any( sal_Int32( rWinStateInfo.nStyle )) );
break;
1188 assert(
false &&
"Wrong value for ConfigurationAccess_WindowState. Who has forgotten to add this new property!" );
1191 catch(
const Exception& )
1198void ConfigurationAccess_WindowState::impl_initializeConfigAccess()
1204 {
"nodepath",
Any(m_aConfigWindowAccess)}
1207 "com.sun.star.configuration.ConfigurationUpdateAccess", aArgs ), UNO_QUERY );
1212 if ( xContainer.is() )
1219 catch (
const WrappedTargetException& )
1222 catch (
const Exception& )
1228 css::lang::XServiceInfo> WindowStateConfiguration_BASE;
1230class WindowStateConfiguration :
public WindowStateConfiguration_BASE
1233 explicit WindowStateConfiguration(
const css::uno::Reference< css::uno::XComponentContext >& rxContext );
1234 virtual ~WindowStateConfiguration()
override;
1238 return "com.sun.star.comp.framework.WindowStateConfiguration";
1248 return {
"com.sun.star.ui.WindowStateConfiguration"};
1252 virtual css::uno::Any SAL_CALL getByName(
const OUString& aName )
override;
1254 virtual css::uno::Sequence< OUString > SAL_CALL getElementNames()
override;
1256 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override;
1259 virtual css::uno::Type SAL_CALL getElementType()
override;
1260 virtual sal_Bool SAL_CALL hasElements()
override;
1262 typedef std::unordered_map< OUString,
1263 OUString > ModuleToWindowStateFileMap;
1265 typedef std::unordered_map< OUString,
1266 css::uno::Reference< css::container::XNameAccess > > ModuleToWindowStateConfigHashMap;
1269 css::uno::Reference< css::uno::XComponentContext>
m_xContext;
1270 ModuleToWindowStateFileMap m_aModuleToFileHashMap;
1271 ModuleToWindowStateConfigHashMap m_aModuleToWindowStateHashMap;
1277 css::uno::Reference< css::frame::XModuleManager2 > xModuleManager =
1283 aElementNames = xModuleManager->getElementNames();
1285 catch (
const css::uno::RuntimeException &)
1290 for ( OUString
const & aModuleIdentifier : std::as_const(aElementNames) )
1292 if ( xModuleManager->getByName( aModuleIdentifier ) >>= aSeq )
1294 OUString aWindowStateFileStr;
1295 for ( PropertyValue
const & rProp : std::as_const(aSeq) )
1297 if ( rProp.Name ==
"ooSetupFactoryWindowStateConfigRef" )
1299 rProp.Value >>= aWindowStateFileStr;
1304 if ( !aWindowStateFileStr.isEmpty() )
1307 m_aModuleToFileHashMap.emplace( aModuleIdentifier, aWindowStateFileStr );
1310 ModuleToWindowStateConfigHashMap::iterator pIter = m_aModuleToWindowStateHashMap.find( aWindowStateFileStr );
1311 if ( pIter == m_aModuleToWindowStateHashMap.end() )
1312 m_aModuleToWindowStateHashMap.emplace( aWindowStateFileStr, xEmptyNameAccess );
1318WindowStateConfiguration::~WindowStateConfiguration()
1321 m_aModuleToFileHashMap.clear();
1322 m_aModuleToWindowStateHashMap.clear();
1325Any SAL_CALL WindowStateConfiguration::getByName(
const OUString& aModuleIdentifier )
1329 ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aModuleIdentifier );
1330 if ( pIter != m_aModuleToFileHashMap.end() )
1333 OUString aWindowStateConfigFile( pIter->second );
1335 ModuleToWindowStateConfigHashMap::iterator pModuleIter = m_aModuleToWindowStateHashMap.find( aWindowStateConfigFile );
1336 if ( pModuleIter != m_aModuleToWindowStateHashMap.end() )
1338 if ( pModuleIter->second.is() )
1339 a <<= pModuleIter->second;
1343 pModuleIter->second = xResourceURLWindowState;
1344 a <<= xResourceURLWindowState;
1351 throw NoSuchElementException();
1361sal_Bool SAL_CALL WindowStateConfiguration::hasByName(
const OUString& aName )
1365 ModuleToWindowStateFileMap::const_iterator pIter = m_aModuleToFileHashMap.find( aName );
1366 return ( pIter != m_aModuleToFileHashMap.end() );
1370Type SAL_CALL WindowStateConfiguration::getElementType()
1375sal_Bool SAL_CALL WindowStateConfiguration::hasElements()
1383extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface *
1385 css::uno::XComponentContext *context,
1386 css::uno::Sequence<css::uno::Any>
const &)
1388 return cppu::acquire(
new WindowStateConfiguration(context));
css::uno::Type const & get()
Reference< XSingleServiceFactory > xFactory
constexpr OUStringLiteral PROPERTY_SIZE
css::uno::Reference< css::container::XNameAccess > m_xConfigAccess
css::uno::Reference< css::uno::XComponentContext > m_xContext
void SAL_CALL elementReplaced(const css::container::ContainerEvent &Event) override
void SAL_CALL elementRemoved(const css::container::ContainerEvent &Event) override
DECL_LISTENERMULTIPLEXER_END void SAL_CALL elementInserted(const css::container::ContainerEvent &Event) override
Sequence< sal_Int8 > aSeq
#define SAL_WARN(area, stream)
css::uno::Sequence< css::uno::Any > InitAnyPropertySequence(::std::initializer_list< ::std::pair< OUString, css::uno::Any > > vInit)
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
css::uno::Sequence< DstElementType > containerToSequence(const SrcType &i_Container)
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
Reference< XMultiServiceFactory > m_xConfigProvider
Reference< XContainerListener > m_xConfigListener
bool m_bConfigAccessInitialized
constexpr OUStringLiteral PROPERTY_VISIBLE
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_framework_WindowStateConfiguration_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_INTERNALSTATE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_VISIBLE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKINGAREA
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_POS
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKSIZE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_LOCKED
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_STYLE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKPOS
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_HIDEFROMENU
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_DOCKED
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_NOCLOSE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_SIZE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_CONTEXTACTIVE
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_UINAME
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_CONTEXT
constexpr OUStringLiteral WINDOWSTATE_PROPERTY_SOFTCLOSE