1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
29 #define _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
31 #include "composeduiupdate.hxx"
32 #include "formbrowsertools.hxx"
33 #include "formmetadata.hxx"
34 #include "proplinelistener.hxx"
35 #include "propcontrolobserver.hxx"
36 #include "browserview.hxx"
37 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
38 #include "modulepcr.hxx"
40 #include "propertyinfo.hxx"
41 #include "pcrcomponentcontext.hxx"
43 /** === begin UNO includes === **/
44 #include <com/sun/star/awt/XFocusListener.hpp>
45 #include <com/sun/star/beans/XPropertyState.hpp>
46 #include <com/sun/star/beans/XPropertySet.hpp>
47 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
48 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
49 #include <com/sun/star/uno/XComponentContext.hpp>
50 #include <com/sun/star/form/XForm.hpp>
51 #include <com/sun/star/script/XEventAttacherManager.hpp>
52 #include <com/sun/star/sdbc/XRowSet.hpp>
53 #include <com/sun/star/uno/Sequence.hxx>
54 #include <com/sun/star/frame/XController.hpp>
55 #include <com/sun/star/lang/XServiceInfo.hpp>
56 #include <com/sun/star/lang/XEventListener.hpp>
57 #include <com/sun/star/sdbc/XConnection.hpp>
58 #include <com/sun/star/awt/XLayoutConstrains.hpp>
59 #include <com/sun/star/awt/XLayoutConstrains.hpp>
60 #include <com/sun/star/awt/XControlContainer.hpp>
61 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
62 #include <com/sun/star/inspection/XObjectInspector.hpp>
63 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
64 #include <com/sun/star/inspection/XPropertyHandler.hpp>
65 #include <com/sun/star/lang/XInitialization.hpp>
66 /** === end UNO includes === **/
67 #include <connectivity/dbtools.hxx>
68 #include <cppuhelper/interfacecontainer.hxx>
69 #include <cppuhelper/implbase7.hxx>
70 #include <comphelper/broadcasthelper.hxx>
77 class SvNumberFormatsSupplierObj
;
82 //............................................................................
85 //............................................................................
87 class OPropertyEditor
;
88 struct OLineDescriptor
;
90 #if OSL_DEBUG_LEVEL > 0
91 const char* CheckPropertyBrowserInvariants( const void* pVoid
);
92 // for dignostics with DBG_CHKTHIS
94 DBG_NAMEEX( OPropertyBrowserController
)
96 //========================================================================
97 //= OPropertyBrowserController
98 //========================================================================
99 // #95343#------------------------------------------------------------------------------------
100 typedef ::cppu::WeakImplHelper7
< ::com::sun::star::lang::XServiceInfo
101 , ::com::sun::star::awt::XFocusListener
102 , ::com::sun::star::awt::XLayoutConstrains
103 , ::com::sun::star::beans::XPropertyChangeListener
104 , ::com::sun::star::inspection::XPropertyControlFactory
105 , ::com::sun::star::inspection::XObjectInspector
106 , ::com::sun::star::lang::XInitialization
107 > OPropertyBrowserController_Base
;
109 class OPropertyBrowserController
110 :public ::comphelper::OMutexAndBroadcastHelper
111 ,public OPropertyBrowserController_Base
112 ,public ::com::sun::star::inspection::XObjectInspectorUI
113 // that's intentionally *not* part of the OPropertyBrowserController_Base
114 // We do not want this to be available in queryInterface, getTypes, and the like.
115 ,public IPropertyLineListener
116 ,public IPropertyControlObserver
117 ,public IPropertyExistenceCheck
120 typedef ::std::map
< sal_Int32
, ::com::sun::star::beans::Property
> OrderedPropertyMap
;
121 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >
125 ComponentContext m_aContext
;
128 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
129 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xView
;
131 ::cppu::OInterfaceContainerHelper m_aDisposeListeners
;
132 ::cppu::OInterfaceContainerHelper m_aControlObservers
;
133 // meta data about the properties
134 OPropertyBrowserView
* m_pView
;
136 ::rtl::OUString m_sPageSelection
;
137 ::rtl::OUString m_sLastValidPageSelection
;
139 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>
141 typedef ::std::vector
< PropertyHandlerRef
> PropertyHandlerArray
;
142 typedef ::std::hash_map
< ::rtl::OUString
, PropertyHandlerRef
, ::rtl::OUStringHash
>
143 PropertyHandlerRepository
;
144 typedef ::std::hash_multimap
< ::rtl::OUString
, PropertyHandlerRef
, ::rtl::OUStringHash
>
145 PropertyHandlerMultiRepository
;
146 PropertyHandlerRepository m_aPropertyHandlers
;
147 PropertyHandlerMultiRepository m_aDependencyHandlers
;
148 PropertyHandlerRef m_xInteractiveHandler
;
150 ::std::auto_ptr
< ComposedPropertyUIUpdate
> m_pUIRequestComposer
;
152 /// our InspectorModel
153 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>
155 /// the object(s) we're currently inspecting
156 InterfaceArray m_aInspectedObjects
;
157 /// the properties of the currently inspected object(s)
158 OrderedPropertyMap m_aProperties
;
159 /// the property we're just committing
160 ::rtl::OUString m_sCommittingProperty
;
162 typedef ::std::hash_map
< ::rtl::OUString
, sal_uInt16
, ::rtl::OUStringHash
> HashString2Int16
;
163 HashString2Int16 m_aPageIds
;
165 bool m_bContainerFocusListening
;
166 bool m_bSuspendingPropertyHandlers
;
168 bool m_bBindingIntrospectee
;
174 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
175 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
176 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
179 virtual void SAL_CALL
attachFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
) throw(::com::sun::star::uno::RuntimeException
);
180 virtual sal_Bool SAL_CALL
attachModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModel
) throw(::com::sun::star::uno::RuntimeException
);
181 virtual sal_Bool SAL_CALL
suspend( sal_Bool bSuspend
) throw(::com::sun::star::uno::RuntimeException
);
182 virtual ::com::sun::star::uno::Any SAL_CALL
getViewData( ) throw(::com::sun::star::uno::RuntimeException
);
183 virtual void SAL_CALL
restoreViewData( const ::com::sun::star::uno::Any
& Data
) throw(::com::sun::star::uno::RuntimeException
);
184 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> SAL_CALL
getModel( ) throw(::com::sun::star::uno::RuntimeException
);
185 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SAL_CALL
getFrame( ) throw(::com::sun::star::uno::RuntimeException
);
188 virtual void SAL_CALL
dispose( ) throw(::com::sun::star::uno::RuntimeException
);
189 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
193 virtual void SAL_CALL
focusGained( const ::com::sun::star::awt::FocusEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
);
194 virtual void SAL_CALL
focusLost( const ::com::sun::star::awt::FocusEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
);
197 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
199 // XLayoutConstrains #95343# ----------------
200 virtual ::com::sun::star::awt::Size SAL_CALL
getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException
);
201 virtual ::com::sun::star::awt::Size SAL_CALL
getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException
);
202 virtual ::com::sun::star::awt::Size SAL_CALL
calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
) throw (::com::sun::star::uno::RuntimeException
);
204 // XPropertyChangeListener
205 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
);
207 /** XPropertyControlFactory
209 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
> SAL_CALL
createPropertyControl( ::sal_Int16 ControlType
, ::sal_Bool CreateReadOnly
) throw (::com::sun::star::lang::IllegalArgumentException
, ::com::sun::star::uno::RuntimeException
);
212 OPropertyBrowserController(
213 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
);
216 virtual ~OPropertyBrowserController();
219 // XServiceInfo - static versions
220 static ::rtl::OUString
getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException
);
221 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException
);
222 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
223 Create(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&);
226 // IPropertyLineListener
227 virtual void Clicked( const ::rtl::OUString
& _rName
, sal_Bool _bPrimary
);
228 virtual void Commit( const ::rtl::OUString
& _rName
, const ::com::sun::star::uno::Any
& _rVal
);
230 // IPropertyControlObserver
231 virtual void focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _Control
);
232 virtual void valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _Control
);
234 // IPropertyExistenceCheck
235 virtual ::sal_Bool SAL_CALL
hasPropertyByName( const ::rtl::OUString
& _rName
) throw (::com::sun::star::uno::RuntimeException
);
237 // XObjectInspectorUI
238 virtual void SAL_CALL
enablePropertyUI( const ::rtl::OUString
& _rPropertyName
, ::sal_Bool _bEnable
) throw (::com::sun::star::uno::RuntimeException
);
239 virtual void SAL_CALL
enablePropertyUIElements( const ::rtl::OUString
& _rPropertyName
, ::sal_Int16 _nElements
, ::sal_Bool _bEnable
) throw (::com::sun::star::uno::RuntimeException
);
240 virtual void SAL_CALL
rebuildPropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
showPropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
242 virtual void SAL_CALL
hidePropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
243 virtual void SAL_CALL
showCategory( const ::rtl::OUString
& _rCategory
, ::sal_Bool _bShow
) throw (::com::sun::star::uno::RuntimeException
);
244 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
> SAL_CALL
getPropertyControl( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
245 virtual void SAL_CALL
registerControlObserver( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlObserver
>& _Observer
) throw (::com::sun::star::uno::RuntimeException
);
246 virtual void SAL_CALL
revokeControlObserver( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlObserver
>& _Observer
) throw (::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
setHelpSectionText( const ::rtl::OUString
& HelpText
) throw (::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
250 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
> SAL_CALL
getInspectorModel() throw (::com::sun::star::uno::RuntimeException
);
251 virtual void SAL_CALL
setInspectorModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _inspectormodel
) throw (::com::sun::star::uno::RuntimeException
);
252 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorUI
> SAL_CALL
getInspectorUI() throw (::com::sun::star::uno::RuntimeException
);
253 virtual void SAL_CALL
inspect( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >& Objects
) throw (::com::sun::star::util::VetoException
, ::com::sun::star::uno::RuntimeException
);
256 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> SAL_CALL
queryDispatch( const ::com::sun::star::util::URL
& URL
, const ::rtl::OUString
& TargetFrameName
, ::sal_Int32 SearchFlags
) throw (::com::sun::star::uno::RuntimeException
);
257 virtual ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> > SAL_CALL
queryDispatches( const ::com::sun::star::uno::Sequence
< ::com::sun::star::frame::DispatchDescriptor
>& Requests
) throw (::com::sun::star::uno::RuntimeException
);
260 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
) throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
);
265 void startContainerWindowListening();
266 void stopContainerWindowListening();
268 // stop the inspection
269 void stopInspection( bool _bCommitModified
);
271 sal_Bool
haveView() const { return NULL
!= m_pView
; }
272 OPropertyEditor
& getPropertyBox() { return m_pView
->getPropertyBox(); }
274 // does the inspection of the objects as indicated by our model
277 // bind the browser to m_xIntrospecteeAsProperty
278 void impl_rebindToInspectee_nothrow( const InterfaceArray
& _rObjects
);
280 /** retrieves special property handlers for our introspectee
282 void getPropertyHandlers( const InterfaceArray
& _rObjects
, PropertyHandlerArray
& _rHandlers
);
284 /** called when a property changed, to broadcast any handlers which might have
285 registered for this property
287 @param _bFirstTimeInit
288 if set to <FALSE/>, this is a real change in the property value, not just a call
289 for purposes of initialization.
291 void impl_broadcastPropertyChange_nothrow( const ::rtl::OUString
& _rPropertyName
, const ::com::sun::star::uno::Any
& _rNewValue
, const ::com::sun::star::uno::Any
& _rOldValue
, bool _bFirstTimeInit
) const;
293 /** determines whether the given property is an actuating property, that is, at least one
294 handler expressed interest in changes to this property's value.
296 inline bool impl_isActuatingProperty_nothrow( const ::rtl::OUString
& _rPropertyName
) const
298 return ( m_aDependencyHandlers
.find( _rPropertyName
) != m_aDependencyHandlers
.end() );
301 sal_uInt32
GetPropertyPos(const ::rtl::OUString
& _rPropName
);
303 /** retrieves the value of the given property, by asking the appropriate XPropertyHandler
304 @param _rPropertyName
305 the name whose handler is to be obtained. Must be the name of a property
306 for which a handler is registered.
308 RuntimeException if there is no handler for the given property
310 the value of this property
312 ::com::sun::star::uno::Any
313 impl_getPropertyValue_throw( const ::rtl::OUString
& _rPropertyName
);
315 /// calls XPropertyHandler::suspend for all our property handlers
316 sal_Bool
suspendPropertyHandlers_nothrow( sal_Bool _bSuspend
);
318 /// suspends the complete inspector
319 sal_Bool
suspendAll_nothrow();
321 /** selects a page according to our current view data
323 void selectPageFromViewData();
325 /** updates our view data from the currently active page
327 void updateViewDataFromActivePage();
329 /// describes the UI for the given property
330 void describePropertyLine( const ::com::sun::star::beans::Property
& _rPropertyName
, OLineDescriptor
& _rDescriptor
)
331 SAL_THROW((::com::sun::star::uno::Exception
));
333 /** retrieves the position of the property given by name in m_aProperties
335 <TRUE/> if and only if the property could be found. In this case, <arg>_pProperty</arg> (if
336 not <NULL/> contains the iterator pointing to this property.
338 bool impl_findObjectProperty_nothrow( const ::rtl::OUString
& _rName
, OrderedPropertyMap::const_iterator
* _pProperty
= NULL
);
340 sal_Bool
Construct(Window
* _pParentWin
);
342 /** retrieves the property handler for a given property name
343 @param _rPropertyName
344 the name whose handler is to be obtained. Must be the name of a property
345 for which a handler is registered.
347 RuntimeException if there is no handler for the given property
349 the handler which is responsible for the given property
352 impl_getHandlerForProperty_throw( const ::rtl::OUString
& _rPropertyName
) const;
354 /** determines whether we have a handler for the given property
355 @param _rPropertyName
356 the name of the property for which the existence of a handler should be checked
359 impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString
& _rPropertyName
) const;
361 /** builds up m_aPageIds from InspectorModel::describeCategories, and insert all the
362 respective tab pages into our view
365 @throws ::com::sun::star::uno::RuntimeException
366 if one of the callees of this method throws this exception
369 impl_buildCategories_throw();
371 /** retrieves the id of the tab page which represents a given category.
372 @param _rCategoryName
373 the programmatic name of a category.
375 the id of the tab page, or <code>(sal_uInt16)-1</code> if there
376 is no tab page for the given category
379 impl_getPageIdForCategory_nothrow( const ::rtl::OUString
& _rCategoryName
) const;
381 /** adds or removes ourself as XEventListener to/from all our inspectees
383 void impl_toggleInspecteeListening_nothrow( bool _bOn
);
385 /** binds the instance to a new model
387 void impl_bindToNewModel_nothrow( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _rxInspectorModel
);
389 /** initializes our view, as indicated by the model's view-relevant properties
391 It's allowed to call this method when no model exists, yet. In this case, nothing
394 void impl_initializeView_nothrow();
396 /** determines whether the view should be readonly.
398 Effectively, this means that the method simply checks the IsReadOnly attribute of the model.
399 If there is no model, <FALSE/> is returned.
401 @throws ::com::sun::star::uno::RuntimeException
402 in case asking the model for its IsReadOnly attribute throws a ::com::sun::star::uno::RuntimeException
405 bool impl_isReadOnlyModel_throw() const;
407 /** updates our view so that it is read-only, as indicated by the model property
408 @see impl_isReadOnlyModel_throw
410 void impl_updateReadOnlyView_nothrow();
412 /** starts or stops listening at the model
414 void impl_startOrStopModelListening_nothrow( bool _bDoListen
) const;
417 DECL_LINK(OnPageActivation
, void*);
421 void createDefault();
422 void createWithModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _rxModel
);
425 //............................................................................
427 //............................................................................
429 #endif // _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_