1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: propcontroller.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
32 #define _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_
34 #include "composeduiupdate.hxx"
35 #include "formbrowsertools.hxx"
36 #include "formmetadata.hxx"
37 #include "proplinelistener.hxx"
38 #include "propcontrolobserver.hxx"
39 #include "browserview.hxx"
40 #ifndef _EXTENSIONS_PROPCTRLR_MODULEPCR_HXX_
41 #include "modulepcr.hxx"
43 #include "propertyinfo.hxx"
44 #include "pcrcomponentcontext.hxx"
46 /** === begin UNO includes === **/
47 #include <com/sun/star/awt/XFocusListener.hpp>
48 #include <com/sun/star/beans/XPropertyState.hpp>
49 #include <com/sun/star/beans/XPropertySet.hpp>
50 #include <com/sun/star/beans/XPropertyChangeListener.hpp>
51 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
52 #include <com/sun/star/uno/XComponentContext.hpp>
53 #include <com/sun/star/form/XForm.hpp>
54 #include <com/sun/star/script/XEventAttacherManager.hpp>
55 #include <com/sun/star/sdbc/XRowSet.hpp>
56 #include <com/sun/star/uno/Sequence.hxx>
57 #include <com/sun/star/frame/XController.hpp>
58 #include <com/sun/star/lang/XServiceInfo.hpp>
59 #include <com/sun/star/lang/XEventListener.hpp>
60 #include <com/sun/star/sdbc/XConnection.hpp>
61 #include <com/sun/star/awt/XLayoutConstrains.hpp>
62 #include <com/sun/star/awt/XLayoutConstrains.hpp>
63 #include <com/sun/star/awt/XControlContainer.hpp>
64 #include <com/sun/star/inspection/XPropertyControlFactory.hpp>
65 #include <com/sun/star/inspection/XObjectInspector.hpp>
66 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
67 #include <com/sun/star/inspection/XPropertyHandler.hpp>
68 #include <com/sun/star/lang/XInitialization.hpp>
69 /** === end UNO includes === **/
70 #include <connectivity/dbtools.hxx>
71 #include <cppuhelper/interfacecontainer.hxx>
72 #include <cppuhelper/implbase7.hxx>
73 #include <comphelper/broadcasthelper.hxx>
80 class SvNumberFormatsSupplierObj
;
85 //............................................................................
88 //............................................................................
90 class OPropertyEditor
;
91 struct OLineDescriptor
;
93 #if OSL_DEBUG_LEVEL > 0
94 const char* CheckPropertyBrowserInvariants( const void* pVoid
);
95 // for dignostics with DBG_CHKTHIS
97 DBG_NAMEEX( OPropertyBrowserController
)
99 //========================================================================
100 //= OPropertyBrowserController
101 //========================================================================
102 // #95343#------------------------------------------------------------------------------------
103 typedef ::cppu::WeakImplHelper7
< ::com::sun::star::lang::XServiceInfo
104 , ::com::sun::star::awt::XFocusListener
105 , ::com::sun::star::awt::XLayoutConstrains
106 , ::com::sun::star::beans::XPropertyChangeListener
107 , ::com::sun::star::inspection::XPropertyControlFactory
108 , ::com::sun::star::inspection::XObjectInspector
109 , ::com::sun::star::lang::XInitialization
110 > OPropertyBrowserController_Base
;
112 class OPropertyBrowserController
113 :public ::comphelper::OMutexAndBroadcastHelper
114 ,public OPropertyBrowserController_Base
115 ,public ::com::sun::star::inspection::XObjectInspectorUI
116 // that's intentionally *not* part of the OPropertyBrowserController_Base
117 // We do not want this to be available in queryInterface, getTypes, and the like.
118 ,public IPropertyLineListener
119 ,public IPropertyControlObserver
120 ,public IPropertyExistenceCheck
123 typedef ::std::map
< sal_Int32
, ::com::sun::star::beans::Property
> OrderedPropertyMap
;
124 typedef ::std::vector
< ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> >
128 ComponentContext m_aContext
;
131 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
132 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xView
;
134 ::cppu::OInterfaceContainerHelper m_aDisposeListeners
;
135 ::cppu::OInterfaceContainerHelper m_aControlObservers
;
136 // meta data about the properties
137 OPropertyBrowserView
* m_pView
;
139 ::rtl::OUString m_sPageSelection
;
140 ::rtl::OUString m_sLastValidPageSelection
;
142 typedef ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyHandler
>
144 typedef ::std::vector
< PropertyHandlerRef
> PropertyHandlerArray
;
145 typedef ::std::hash_map
< ::rtl::OUString
, PropertyHandlerRef
, ::rtl::OUStringHash
>
146 PropertyHandlerRepository
;
147 typedef ::std::hash_multimap
< ::rtl::OUString
, PropertyHandlerRef
, ::rtl::OUStringHash
>
148 PropertyHandlerMultiRepository
;
149 PropertyHandlerRepository m_aPropertyHandlers
;
150 PropertyHandlerMultiRepository m_aDependencyHandlers
;
151 PropertyHandlerRef m_xInteractiveHandler
;
153 ::std::auto_ptr
< ComposedPropertyUIUpdate
> m_pUIRequestComposer
;
155 /// our InspectorModel
156 ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>
158 /// the object(s) we're currently inspecting
159 InterfaceArray m_aInspectedObjects
;
160 /// the properties of the currently inspected object(s)
161 OrderedPropertyMap m_aProperties
;
162 /// the property we're just committing
163 ::rtl::OUString m_sCommittingProperty
;
165 typedef ::std::hash_map
< ::rtl::OUString
, sal_uInt16
, ::rtl::OUStringHash
> HashString2Int16
;
166 HashString2Int16 m_aPageIds
;
168 bool m_bContainerFocusListening
;
169 bool m_bSuspendingPropertyHandlers
;
176 virtual ::rtl::OUString SAL_CALL
getImplementationName( ) throw(::com::sun::star::uno::RuntimeException
);
177 virtual sal_Bool SAL_CALL
supportsService( const ::rtl::OUString
& ServiceName
) throw(::com::sun::star::uno::RuntimeException
);
178 virtual ::com::sun::star::uno::Sequence
< ::rtl::OUString
> SAL_CALL
getSupportedServiceNames( ) throw(::com::sun::star::uno::RuntimeException
);
181 virtual void SAL_CALL
attachFrame( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
) throw(::com::sun::star::uno::RuntimeException
);
182 virtual sal_Bool SAL_CALL
attachModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
>& xModel
) throw(::com::sun::star::uno::RuntimeException
);
183 virtual sal_Bool SAL_CALL
suspend( sal_Bool bSuspend
) throw(::com::sun::star::uno::RuntimeException
);
184 virtual ::com::sun::star::uno::Any SAL_CALL
getViewData( ) throw(::com::sun::star::uno::RuntimeException
);
185 virtual void SAL_CALL
restoreViewData( const ::com::sun::star::uno::Any
& Data
) throw(::com::sun::star::uno::RuntimeException
);
186 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModel
> SAL_CALL
getModel( ) throw(::com::sun::star::uno::RuntimeException
);
187 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> SAL_CALL
getFrame( ) throw(::com::sun::star::uno::RuntimeException
);
190 virtual void SAL_CALL
dispose( ) throw(::com::sun::star::uno::RuntimeException
);
191 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw(::com::sun::star::uno::RuntimeException
);
192 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw(::com::sun::star::uno::RuntimeException
);
195 virtual void SAL_CALL
focusGained( const ::com::sun::star::awt::FocusEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
);
196 virtual void SAL_CALL
focusLost( const ::com::sun::star::awt::FocusEvent
& _rSource
) throw (::com::sun::star::uno::RuntimeException
);
199 virtual void SAL_CALL
disposing( const ::com::sun::star::lang::EventObject
& Source
) throw(::com::sun::star::uno::RuntimeException
);
201 // XLayoutConstrains #95343# ----------------
202 virtual ::com::sun::star::awt::Size SAL_CALL
getMinimumSize( ) throw (::com::sun::star::uno::RuntimeException
);
203 virtual ::com::sun::star::awt::Size SAL_CALL
getPreferredSize( ) throw (::com::sun::star::uno::RuntimeException
);
204 virtual ::com::sun::star::awt::Size SAL_CALL
calcAdjustedSize( const ::com::sun::star::awt::Size
& aNewSize
) throw (::com::sun::star::uno::RuntimeException
);
206 // XPropertyChangeListener
207 virtual void SAL_CALL
propertyChange( const ::com::sun::star::beans::PropertyChangeEvent
& _rEvent
) throw (::com::sun::star::uno::RuntimeException
);
209 /** XPropertyControlFactory
211 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
);
214 OPropertyBrowserController(
215 const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>& _rxContext
);
218 virtual ~OPropertyBrowserController();
221 // XServiceInfo - static versions
222 static ::rtl::OUString
getImplementationName_static( ) throw(::com::sun::star::uno::RuntimeException
);
223 static ::com::sun::star::uno::Sequence
< ::rtl::OUString
> getSupportedServiceNames_static( ) throw(::com::sun::star::uno::RuntimeException
);
224 static ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XInterface
> SAL_CALL
225 Create(const ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
>&);
228 // IPropertyLineListener
229 virtual void Clicked( const ::rtl::OUString
& _rName
, sal_Bool _bPrimary
);
230 virtual void Commit( const ::rtl::OUString
& _rName
, const ::com::sun::star::uno::Any
& _rVal
);
232 // IPropertyControlObserver
233 virtual void focusGained( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _Control
);
234 virtual void valueChanged( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
>& _Control
);
236 // IPropertyExistenceCheck
237 virtual ::sal_Bool SAL_CALL
hasPropertyByName( const ::rtl::OUString
& _rName
) throw (::com::sun::star::uno::RuntimeException
);
239 // XObjectInspectorUI
240 virtual void SAL_CALL
enablePropertyUI( const ::rtl::OUString
& _rPropertyName
, ::sal_Bool _bEnable
) throw (::com::sun::star::uno::RuntimeException
);
241 virtual void SAL_CALL
enablePropertyUIElements( const ::rtl::OUString
& _rPropertyName
, ::sal_Int16 _nElements
, ::sal_Bool _bEnable
) throw (::com::sun::star::uno::RuntimeException
);
242 virtual void SAL_CALL
rebuildPropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
243 virtual void SAL_CALL
showPropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
244 virtual void SAL_CALL
hidePropertyUI( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
245 virtual void SAL_CALL
showCategory( const ::rtl::OUString
& _rCategory
, ::sal_Bool _bShow
) throw (::com::sun::star::uno::RuntimeException
);
246 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControl
> SAL_CALL
getPropertyControl( const ::rtl::OUString
& _rPropertyName
) throw (::com::sun::star::uno::RuntimeException
);
247 virtual void SAL_CALL
registerControlObserver( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlObserver
>& _Observer
) throw (::com::sun::star::uno::RuntimeException
);
248 virtual void SAL_CALL
revokeControlObserver( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XPropertyControlObserver
>& _Observer
) throw (::com::sun::star::uno::RuntimeException
);
249 virtual void SAL_CALL
setHelpSectionText( const ::rtl::OUString
& HelpText
) throw (::com::sun::star::lang::NoSupportException
, ::com::sun::star::uno::RuntimeException
);
252 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
> SAL_CALL
getInspectorModel() throw (::com::sun::star::uno::RuntimeException
);
253 virtual void SAL_CALL
setInspectorModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _inspectormodel
) throw (::com::sun::star::uno::RuntimeException
);
254 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorUI
> SAL_CALL
getInspectorUI() throw (::com::sun::star::uno::RuntimeException
);
255 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
);
258 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
);
259 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
);
262 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
);
267 void startContainerWindowListening();
268 void stopContainerWindowListening();
270 // stop the inspection
271 void stopInspection( bool _bCommitModified
);
273 sal_Bool
haveView() const { return NULL
!= m_pView
; }
274 OPropertyEditor
& getPropertyBox() { return m_pView
->getPropertyBox(); }
276 // does the inspection of the objects as indicated by our model
279 // bind the browser to m_xIntrospecteeAsProperty
280 void impl_rebindToInspectee_nothrow( const InterfaceArray
& _rObjects
);
282 /** retrieves special property handlers for our introspectee
284 void getPropertyHandlers( const InterfaceArray
& _rObjects
, PropertyHandlerArray
& _rHandlers
);
286 /** called when a property changed, to broadcast any handlers which might have
287 registered for this property
289 @param _bFirstTimeInit
290 if set to <FALSE/>, this is a real change in the property value, not just a call
291 for purposes of initialization.
293 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;
295 /** determines whether the given property is an actuating property, that is, at least one
296 handler expressed interest in changes to this property's value.
298 inline bool impl_isActuatingProperty_nothrow( const ::rtl::OUString
& _rPropertyName
) const
300 return ( m_aDependencyHandlers
.find( _rPropertyName
) != m_aDependencyHandlers
.end() );
303 sal_uInt32
GetPropertyPos(const ::rtl::OUString
& _rPropName
);
305 /** retrieves the value of the given property, by asking the appropriate XPropertyHandler
306 @param _rPropertyName
307 the name whose handler is to be obtained. Must be the name of a property
308 for which a handler is registered.
310 RuntimeException if there is no handler for the given property
312 the value of this property
314 ::com::sun::star::uno::Any
315 impl_getPropertyValue_throw( const ::rtl::OUString
& _rPropertyName
);
317 /// calls XPropertyHandler::suspend for all our property handlers
318 sal_Bool
suspendPropertyHandlers_nothrow( sal_Bool _bSuspend
);
320 /// suspends the complete inspector
321 sal_Bool
suspendAll_nothrow();
323 /** selects a page according to our current view data
325 void selectPageFromViewData();
327 /** updates our view data from the currently active page
329 void updateViewDataFromActivePage();
331 /// describes the UI for the given property
332 void describePropertyLine( const ::com::sun::star::beans::Property
& _rPropertyName
, OLineDescriptor
& _rDescriptor
)
333 SAL_THROW((::com::sun::star::uno::Exception
));
335 /** retrieves the position of the property given by name in m_aProperties
337 <TRUE/> if and only if the property could be found. In this case, <arg>_pProperty</arg> (if
338 not <NULL/> contains the iterator pointing to this property.
340 bool impl_findObjectProperty_nothrow( const ::rtl::OUString
& _rName
, OrderedPropertyMap::const_iterator
* _pProperty
= NULL
);
342 sal_Bool
Construct(Window
* _pParentWin
);
344 /** retrieves the property handler for a given property name
345 @param _rPropertyName
346 the name whose handler is to be obtained. Must be the name of a property
347 for which a handler is registered.
349 RuntimeException if there is no handler for the given property
351 the handler which is responsible for the given property
354 impl_getHandlerForProperty_throw( const ::rtl::OUString
& _rPropertyName
) const;
356 /** determines whether we have a handler for the given property
357 @param _rPropertyName
358 the name of the property for which the existence of a handler should be checked
361 impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString
& _rPropertyName
) const;
363 /** builds up m_aPageIds from InspectorModel::describeCategories, and insert all the
364 respective tab pages into our view
367 @throws ::com::sun::star::uno::RuntimeException
368 if one of the callees of this method throws this exception
371 impl_buildCategories_throw();
373 /** retrieves the id of the tab page which represents a given category.
374 @param _rCategoryName
375 the programmatic name of a category.
377 the id of the tab page, or <code>(sal_uInt16)-1</code> if there
378 is no tab page for the given category
381 impl_getPageIdForCategory_nothrow( const ::rtl::OUString
& _rCategoryName
) const;
383 /** adds or removes ourself as XEventListener to/from all our inspectees
385 void impl_toggleInspecteeListening_nothrow( bool _bOn
);
387 /** binds the instance to a new model
389 void impl_bindToNewModel_nothrow( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _rxInspectorModel
);
391 /** initializes our view, as indicated by the model's view-relevant properties
393 It's allowed to call this method when no model exists, yet. In this case, nothing
396 void impl_initializeView_nothrow();
398 /** determines whether the view should be readonly.
400 Effectively, this means that the method simply checks the IsReadOnly attribute of the model.
401 If there is no model, <FALSE/> is returned.
403 @throws ::com::sun::star::uno::RuntimeException
404 in case asking the model for its IsReadOnly attribute throws a ::com::sun::star::uno::RuntimeException
407 bool impl_isReadOnlyModel_throw() const;
409 /** updates our view so that it is read-only, as indicated by the model property
410 @see impl_isReadOnlyModel_throw
412 void impl_updateReadOnlyView_nothrow();
414 /** starts or stops listening at the model
416 void impl_startOrStopModelListening_nothrow( bool _bDoListen
) const;
419 DECL_LINK(OnPageActivation
, void*);
423 void createDefault();
424 void createWithModel( const ::com::sun::star::uno::Reference
< ::com::sun::star::inspection::XObjectInspectorModel
>& _rxModel
);
427 //............................................................................
429 //............................................................................
431 #endif // _EXTENSIONS_PROPCTRLR_PROPCONTROLLER_HXX_