Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
30 : : #define __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
31 : :
32 : :
33 : : /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble
34 : : with solaris headers ...
35 : : */
36 : : #include <vector>
37 : : #include <list>
38 : : #include <boost/unordered_map.hpp>
39 : :
40 : : #include <threadhelp/threadhelpbase.hxx>
41 : : #include <macros/generic.hxx>
42 : : #include <macros/xinterface.hxx>
43 : : #include <macros/xtypeprovider.hxx>
44 : : #include <macros/xserviceinfo.hxx>
45 : : #include <stdtypes.h>
46 : : #include <uiconfiguration/imagemanager.hxx>
47 : :
48 : : #include <com/sun/star/lang/XServiceInfo.hpp>
49 : : #include <com/sun/star/lang/XTypeProvider.hpp>
50 : : #include <com/sun/star/lang/XComponent.hpp>
51 : : #include <com/sun/star/ui/XUIConfiguration.hpp>
52 : : #include <com/sun/star/ui/XUIConfigurationPersistence.hpp>
53 : :
54 : : #include <com/sun/star/ui/XUIConfigurationStorage.hpp>
55 : : #include <com/sun/star/ui/XUIConfigurationManager.hpp>
56 : : #include <com/sun/star/ui/ConfigurationEvent.hpp>
57 : : #include <com/sun/star/ui/UIElementType.hpp>
58 : : #include <com/sun/star/container/XIndexContainer.hpp>
59 : :
60 : : #include <cppuhelper/weak.hxx>
61 : : #include <cppuhelper/interfacecontainer.hxx>
62 : : #include <rtl/ustring.hxx>
63 : :
64 : :
65 : : namespace framework
66 : : {
67 : : class UIConfigurationManager : public com::sun::star::lang::XTypeProvider ,
68 : : public com::sun::star::lang::XServiceInfo ,
69 : : public com::sun::star::lang::XComponent ,
70 : : public ::com::sun::star::ui::XUIConfiguration ,
71 : : public ::com::sun::star::ui::XUIConfigurationManager ,
72 : : public ::com::sun::star::ui::XUIConfigurationPersistence ,
73 : : public ::com::sun::star::ui::XUIConfigurationStorage ,
74 : : private ThreadHelpBase , // Struct for right initalization of mutex member! Must be first of baseclasses.
75 : : public ::cppu::OWeakObject
76 : : {
77 : : public:
78 : : // XInterface, XTypeProvider, XServiceInfo
79 : : FWK_DECLARE_XINTERFACE
80 : : FWK_DECLARE_XTYPEPROVIDER
81 : : DECLARE_XSERVICEINFO
82 : :
83 : : UIConfigurationManager( com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > xServiceManager );
84 : : virtual ~UIConfigurationManager();
85 : :
86 : : // XComponent
87 : : virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
88 : : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
89 : : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
90 : :
91 : : // XUIConfiguration
92 : : virtual void SAL_CALL addConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
93 : : virtual void SAL_CALL removeConfigurationListener( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XUIConfigurationListener >& Listener ) throw (::com::sun::star::uno::RuntimeException);
94 : :
95 : : // XUIConfigurationManager
96 : : virtual void SAL_CALL reset() throw (::com::sun::star::uno::RuntimeException);
97 : : virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > > SAL_CALL getUIElementsInfo( sal_Int16 ElementType ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
98 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > SAL_CALL createSettings( ) throw (::com::sun::star::uno::RuntimeException);
99 : : virtual sal_Bool SAL_CALL hasSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
100 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess > SAL_CALL getSettings( const ::rtl::OUString& ResourceURL, sal_Bool bWriteable ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
101 : : virtual void SAL_CALL replaceSettings( const ::rtl::OUString& ResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
102 : : virtual void SAL_CALL removeSettings( const ::rtl::OUString& ResourceURL ) throw (::com::sun::star::container::NoSuchElementException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
103 : : virtual void SAL_CALL insertSettings( const ::rtl::OUString& NewResourceURL, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexAccess >& aNewData ) throw (::com::sun::star::container::ElementExistException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::IllegalAccessException, ::com::sun::star::uno::RuntimeException);
104 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getImageManager() throw (::com::sun::star::uno::RuntimeException);
105 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getShortCutManager() throw (::com::sun::star::uno::RuntimeException);
106 : : virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL getEventsManager() throw (::com::sun::star::uno::RuntimeException);
107 : :
108 : : // XUIConfigurationPersistence
109 : : virtual void SAL_CALL reload() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
110 : : virtual void SAL_CALL store() throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
111 : : virtual void SAL_CALL storeToStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
112 : : virtual sal_Bool SAL_CALL isModified() throw (::com::sun::star::uno::RuntimeException);
113 : : virtual sal_Bool SAL_CALL isReadOnly() throw (::com::sun::star::uno::RuntimeException);
114 : :
115 : : // XUIConfigurationStorage
116 : : virtual void SAL_CALL setStorage( const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& Storage ) throw (::com::sun::star::uno::RuntimeException);
117 : : virtual sal_Bool SAL_CALL hasStorage() throw (::com::sun::star::uno::RuntimeException);
118 : :
119 : : private:
120 : : // private data types
121 : : enum NotifyOp
122 : : {
123 : : NotifyOp_Remove,
124 : : NotifyOp_Insert,
125 : : NotifyOp_Replace
126 : : };
127 : :
128 : 0 : struct UIElementInfo
129 : : {
130 : 0 : UIElementInfo( const rtl::OUString& rResourceURL, const rtl::OUString& rUIName ) :
131 : 0 : aResourceURL( rResourceURL), aUIName( rUIName ) {}
132 : : rtl::OUString aResourceURL;
133 : : rtl::OUString aUIName;
134 : : };
135 : :
136 : 0 : struct UIElementData
137 : : {
138 : 0 : UIElementData() : bModified( false ), bDefault( true ) {};
139 : :
140 : : rtl::OUString aResourceURL;
141 : : rtl::OUString aName;
142 : : bool bModified; // has been changed since last storing
143 : : bool bDefault; // default settings
144 : : com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess > xSettings;
145 : : };
146 : :
147 : : struct UIElementType;
148 : : friend struct UIElementType;
149 : : typedef ::boost::unordered_map< rtl::OUString, UIElementData, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementDataHashMap;
150 : :
151 : 15944 : struct UIElementType
152 : : {
153 : 17096 : UIElementType() : bModified( false ),
154 : : bLoaded( false ),
155 : : bDefaultLayer( false ),
156 [ + - ]: 17096 : nElementType( ::com::sun::star::ui::UIElementType::UNKNOWN ) {}
157 : :
158 : :
159 : : bool bModified;
160 : : bool bLoaded;
161 : : bool bDefaultLayer;
162 : : sal_Int16 nElementType;
163 : : UIElementDataHashMap aElementsHashMap;
164 : : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > xStorage;
165 : : };
166 : :
167 : : typedef ::std::vector< UIElementType > UIElementTypesVector;
168 : : typedef ::std::vector< ::com::sun::star::ui::ConfigurationEvent > ConfigEventNotifyContainer;
169 : : typedef ::boost::unordered_map< rtl::OUString, UIElementInfo, OUStringHashCode, ::std::equal_to< rtl::OUString > > UIElementInfoHashMap;
170 : :
171 : : // private methods
172 : : void impl_Initialize();
173 : : void implts_notifyContainerListener( const ::com::sun::star::ui::ConfigurationEvent& aEvent, NotifyOp eOp );
174 : : void impl_fillSequenceWithElementTypeInfo( UIElementInfoHashMap& aUIElementInfoCollection, sal_Int16 nElementType );
175 : : void impl_preloadUIElementTypeList( sal_Int16 nElementType );
176 : : UIElementData* impl_findUIElementData( const rtl::OUString& aResourceURL, sal_Int16 nElementType, bool bLoad = true );
177 : : void impl_requestUIElementData( sal_Int16 nElementType, UIElementData& aUIElementData );
178 : : void impl_storeElementTypeData( com::sun::star::uno::Reference< com::sun::star::embed::XStorage >& xStorage, UIElementType& rElementType, bool bResetModifyState = true );
179 : : void impl_resetElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer );
180 : : void impl_reloadElementTypeData( UIElementType& rDocElementType, ConfigEventNotifyContainer& rRemoveNotifyContainer, ConfigEventNotifyContainer& rReplaceNotifyContainer );
181 : :
182 : : UIElementTypesVector m_aUIElements;
183 : : com::sun::star::uno::Reference< com::sun::star::embed::XStorage > m_xDocConfigStorage;
184 : : bool m_bReadOnly;
185 : : bool m_bModified;
186 : : bool m_bConfigRead;
187 : : bool m_bDisposed;
188 : : rtl::OUString m_aXMLPostfix;
189 : : rtl::OUString m_aPropUIName;
190 : : rtl::OUString m_aPropResourceURL;
191 : : rtl::OUString m_aModuleIdentifier;
192 : : com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
193 : : ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
194 : : com::sun::star::uno::Reference< com::sun::star::lang::XComponent > m_xImageManager;
195 : : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > m_xAccConfig;
196 : : };
197 : : }
198 : :
199 : : #endif // __FRAMEWORK_UICONFIGURATION_UICONFIGMANAGER_HXX_
200 : :
201 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|