xref: /AOO41X/main/extensions/source/propctrlr/propcontroller.cxx (revision 2a97ec55f1442d65917e8c8b82a55ab76c9ff676)
1*2a97ec55SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2a97ec55SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2a97ec55SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2a97ec55SAndrew Rist  * distributed with this work for additional information
6*2a97ec55SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2a97ec55SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2a97ec55SAndrew Rist  * "License"); you may not use this file except in compliance
9*2a97ec55SAndrew Rist  * with the License.  You may obtain a copy of the License at
10cdf0e10cSrcweir  *
11*2a97ec55SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir  *
13*2a97ec55SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2a97ec55SAndrew Rist  * software distributed under the License is distributed on an
15*2a97ec55SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2a97ec55SAndrew Rist  * KIND, either express or implied.  See the License for the
17*2a97ec55SAndrew Rist  * specific language governing permissions and limitations
18*2a97ec55SAndrew Rist  * under the License.
19cdf0e10cSrcweir  *
20*2a97ec55SAndrew Rist  *************************************************************/
21*2a97ec55SAndrew Rist 
22*2a97ec55SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_extensions.hxx"
26cdf0e10cSrcweir #include "propcontroller.hxx"
27cdf0e10cSrcweir #include "pcrstrings.hxx"
28cdf0e10cSrcweir #include "standardcontrol.hxx"
29cdf0e10cSrcweir #include "linedescriptor.hxx"
30cdf0e10cSrcweir #ifndef EXTENSIONS_PROPRESID_HRC
31cdf0e10cSrcweir #include "propresid.hrc"
32cdf0e10cSrcweir #endif
33cdf0e10cSrcweir #ifndef _EXTENSIONS_FORMCTRLR_PROPRESID_HRC_
34cdf0e10cSrcweir #include "formresid.hrc"
35cdf0e10cSrcweir #endif
36cdf0e10cSrcweir #include "propertyeditor.hxx"
37cdf0e10cSrcweir #ifndef _EXTENSIONS_PROPCTRLR_MODULEPRC_HXX_
38cdf0e10cSrcweir #include "modulepcr.hxx"
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include "formstrings.hxx"
41cdf0e10cSrcweir #include "formmetadata.hxx"
42cdf0e10cSrcweir #include "formbrowsertools.hxx"
43cdf0e10cSrcweir #include "propertycomposer.hxx"
44cdf0e10cSrcweir 
45cdf0e10cSrcweir /** === begin UNO includes === **/
46cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
47cdf0e10cSrcweir #include <com/sun/star/util/XCloseable.hpp>
48cdf0e10cSrcweir #include <com/sun/star/inspection/PropertyControlType.hpp>
49cdf0e10cSrcweir #include <com/sun/star/ucb/AlreadyInitializedException.hpp>
50cdf0e10cSrcweir /** === end UNO includes === **/
51cdf0e10cSrcweir #include <tools/debug.hxx>
52cdf0e10cSrcweir #include <tools/diagnose_ex.h>
53cdf0e10cSrcweir #include <comphelper/types.hxx>
54cdf0e10cSrcweir #include <comphelper/extract.hxx>
55cdf0e10cSrcweir #include <toolkit/awt/vclxwindow.hxx>
56cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
57cdf0e10cSrcweir #include <toolkit/unohlp.hxx>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #include <comphelper/property.hxx>
60cdf0e10cSrcweir #include <vcl/msgbox.hxx>
61cdf0e10cSrcweir #include <vcl/svapp.hxx>
62cdf0e10cSrcweir #include <vos/mutex.hxx>
63cdf0e10cSrcweir #include <cppuhelper/component_context.hxx>
64cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
65cdf0e10cSrcweir 
66cdf0e10cSrcweir #include <algorithm>
67cdf0e10cSrcweir #include <functional>
68cdf0e10cSrcweir 
69cdf0e10cSrcweir //------------------------------------------------------------------------
70cdf0e10cSrcweir // !!! outside the namespace !!!
71cdf0e10cSrcweir extern "C" void SAL_CALL createRegistryInfo_OPropertyBrowserController()
72cdf0e10cSrcweir {
73cdf0e10cSrcweir 	::pcr::OAutoRegistration< ::pcr::OPropertyBrowserController > aAutoRegistration;
74cdf0e10cSrcweir }
75cdf0e10cSrcweir 
76cdf0e10cSrcweir //............................................................................
77cdf0e10cSrcweir namespace pcr
78cdf0e10cSrcweir {
79cdf0e10cSrcweir //............................................................................
80cdf0e10cSrcweir 
81cdf0e10cSrcweir 	using namespace ::com::sun::star;
82cdf0e10cSrcweir 	using namespace ::com::sun::star::uno;
83cdf0e10cSrcweir 	using namespace ::com::sun::star::awt;
84cdf0e10cSrcweir 	using namespace ::com::sun::star::form;
85cdf0e10cSrcweir 	using namespace ::com::sun::star::beans;
86cdf0e10cSrcweir 	using namespace ::com::sun::star::script;
87cdf0e10cSrcweir 	using namespace ::com::sun::star::lang;
88cdf0e10cSrcweir 	using namespace ::com::sun::star::container;
89cdf0e10cSrcweir 	using namespace ::com::sun::star::frame;
90cdf0e10cSrcweir 	using namespace ::com::sun::star::util;
91cdf0e10cSrcweir 	using namespace ::com::sun::star::inspection;
92cdf0e10cSrcweir 	using namespace ::com::sun::star::ucb;
93cdf0e10cSrcweir 	using namespace ::comphelper;
94cdf0e10cSrcweir 
95cdf0e10cSrcweir #define THISREF()	static_cast< XController* >(this)
96cdf0e10cSrcweir 
97cdf0e10cSrcweir     //========================================================================
98cdf0e10cSrcweir 	//= OPropertyBrowserController
99cdf0e10cSrcweir 	//========================================================================
100cdf0e10cSrcweir 	DBG_NAME(OPropertyBrowserController)
101cdf0e10cSrcweir 	//------------------------------------------------------------------------
102cdf0e10cSrcweir 	OPropertyBrowserController::OPropertyBrowserController( const Reference< XComponentContext >& _rxContext )
103cdf0e10cSrcweir             :m_aContext(_rxContext)
104cdf0e10cSrcweir 			,m_aDisposeListeners( m_aMutex )
105cdf0e10cSrcweir             ,m_aControlObservers( m_aMutex )
106cdf0e10cSrcweir 			,m_pView(NULL)
107cdf0e10cSrcweir 			,m_bContainerFocusListening( false )
108cdf0e10cSrcweir             ,m_bSuspendingPropertyHandlers( false )
109cdf0e10cSrcweir             ,m_bConstructed( false )
110cdf0e10cSrcweir             ,m_bBindingIntrospectee( false )
111cdf0e10cSrcweir 	{
112cdf0e10cSrcweir 		DBG_CTOR(OPropertyBrowserController,NULL);
113cdf0e10cSrcweir 	}
114cdf0e10cSrcweir 
115cdf0e10cSrcweir 	//------------------------------------------------------------------------
116cdf0e10cSrcweir 	OPropertyBrowserController::~OPropertyBrowserController()
117cdf0e10cSrcweir 	{
118cdf0e10cSrcweir         // stop listening for property changes
119cdf0e10cSrcweir         acquire();
120cdf0e10cSrcweir 		stopInspection( true );
121cdf0e10cSrcweir 		DBG_DTOR(OPropertyBrowserController,NULL);
122cdf0e10cSrcweir 	}
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 	//------------------------------------------------------------------------
125cdf0e10cSrcweir     IMPLEMENT_FORWARD_REFCOUNT( OPropertyBrowserController, OPropertyBrowserController_Base )
126cdf0e10cSrcweir 
127cdf0e10cSrcweir 	//------------------------------------------------------------------------
128cdf0e10cSrcweir     Any SAL_CALL OPropertyBrowserController::queryInterface( const Type& _rType ) throw (RuntimeException)
129cdf0e10cSrcweir 	{
130cdf0e10cSrcweir         Any aReturn = OPropertyBrowserController_Base::queryInterface( _rType );
131cdf0e10cSrcweir         if ( !aReturn.hasValue() )
132cdf0e10cSrcweir             aReturn = ::cppu::queryInterface(
133cdf0e10cSrcweir                 _rType,
134cdf0e10cSrcweir                 static_cast< XObjectInspectorUI* >( this )
135cdf0e10cSrcweir             );
136cdf0e10cSrcweir         return aReturn;
137cdf0e10cSrcweir 	}
138cdf0e10cSrcweir 
139cdf0e10cSrcweir 	//------------------------------------------------------------------------
140cdf0e10cSrcweir 	void OPropertyBrowserController::startContainerWindowListening()
141cdf0e10cSrcweir 	{
142cdf0e10cSrcweir 		if (m_bContainerFocusListening)
143cdf0e10cSrcweir 			return;
144cdf0e10cSrcweir 
145cdf0e10cSrcweir 		if (m_xFrame.is())
146cdf0e10cSrcweir 		{
147cdf0e10cSrcweir 			Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
148cdf0e10cSrcweir 			if (xContainerWindow.is())
149cdf0e10cSrcweir 			{
150cdf0e10cSrcweir 				xContainerWindow->addFocusListener(this);
151cdf0e10cSrcweir 				m_bContainerFocusListening = sal_True;
152cdf0e10cSrcweir 			}
153cdf0e10cSrcweir 		}
154cdf0e10cSrcweir 
155cdf0e10cSrcweir 		DBG_ASSERT(m_bContainerFocusListening, "OPropertyBrowserController::startContainerWindowListening: unable to start listening (inconsistence)!");
156cdf0e10cSrcweir 	}
157cdf0e10cSrcweir 
158cdf0e10cSrcweir 	//------------------------------------------------------------------------
159cdf0e10cSrcweir 	void OPropertyBrowserController::stopContainerWindowListening()
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		if (!m_bContainerFocusListening)
162cdf0e10cSrcweir 			return;
163cdf0e10cSrcweir 
164cdf0e10cSrcweir 		if (m_xFrame.is())
165cdf0e10cSrcweir 		{
166cdf0e10cSrcweir 			Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
167cdf0e10cSrcweir 			if (xContainerWindow.is())
168cdf0e10cSrcweir 			{
169cdf0e10cSrcweir 				xContainerWindow->removeFocusListener(this);
170cdf0e10cSrcweir 				m_bContainerFocusListening = sal_False;
171cdf0e10cSrcweir 			}
172cdf0e10cSrcweir 		}
173cdf0e10cSrcweir 
174cdf0e10cSrcweir 		DBG_ASSERT(!m_bContainerFocusListening, "OPropertyBrowserController::stopContainerWindowListening: unable to stop listening (inconsistence)!");
175cdf0e10cSrcweir 	}
176cdf0e10cSrcweir 
177cdf0e10cSrcweir     //--------------------------------------------------------------------
178cdf0e10cSrcweir     Reference< XObjectInspectorModel > SAL_CALL OPropertyBrowserController::getInspectorModel() throw (RuntimeException)
179cdf0e10cSrcweir     {
180cdf0e10cSrcweir         return m_xModel;
181cdf0e10cSrcweir     }
182cdf0e10cSrcweir 
183cdf0e10cSrcweir     //--------------------------------------------------------------------
184cdf0e10cSrcweir     void OPropertyBrowserController::impl_initializeView_nothrow()
185cdf0e10cSrcweir     {
186cdf0e10cSrcweir         OSL_PRECOND( haveView(), "OPropertyBrowserController::impl_initializeView_nothrow: not to be called when we have no view!" );
187cdf0e10cSrcweir         if ( !haveView() )
188cdf0e10cSrcweir             return;
189cdf0e10cSrcweir 
190cdf0e10cSrcweir         if ( !m_xModel.is() )
191cdf0e10cSrcweir             // allowed
192cdf0e10cSrcweir             return;
193cdf0e10cSrcweir 
194cdf0e10cSrcweir         try
195cdf0e10cSrcweir         {
196cdf0e10cSrcweir             getPropertyBox().EnableHelpSection( m_xModel->getHasHelpSection() );
197cdf0e10cSrcweir             getPropertyBox().SetHelpLineLimites( m_xModel->getMinHelpTextLines(), m_xModel->getMaxHelpTextLines() );
198cdf0e10cSrcweir         }
199cdf0e10cSrcweir         catch( const Exception& )
200cdf0e10cSrcweir         {
201cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
202cdf0e10cSrcweir         }
203cdf0e10cSrcweir     }
204cdf0e10cSrcweir 
205cdf0e10cSrcweir     //--------------------------------------------------------------------
206cdf0e10cSrcweir     void OPropertyBrowserController::impl_updateReadOnlyView_nothrow()
207cdf0e10cSrcweir     {
208cdf0e10cSrcweir         // this is a huge cudgel, admitted.
209cdf0e10cSrcweir         // The problem is that in case we were previously read-only, all our controls
210cdf0e10cSrcweir         // were created read-only, too. We cannot simply switch them to not-read-only.
211cdf0e10cSrcweir         // Even if they had an API for this, we do not know whether they were
212cdf0e10cSrcweir         // originally created read-only, or if they are read-only just because
213cdf0e10cSrcweir         // the model was.
214cdf0e10cSrcweir         impl_rebindToInspectee_nothrow( m_aInspectedObjects );
215cdf0e10cSrcweir     }
216cdf0e10cSrcweir 
217cdf0e10cSrcweir     //--------------------------------------------------------------------
218cdf0e10cSrcweir     bool OPropertyBrowserController::impl_isReadOnlyModel_throw() const
219cdf0e10cSrcweir     {
220cdf0e10cSrcweir         if ( !m_xModel.is() )
221cdf0e10cSrcweir             return false;
222cdf0e10cSrcweir 
223cdf0e10cSrcweir         return m_xModel->getIsReadOnly();
224cdf0e10cSrcweir     }
225cdf0e10cSrcweir 
226cdf0e10cSrcweir     //--------------------------------------------------------------------
227cdf0e10cSrcweir     void OPropertyBrowserController::impl_startOrStopModelListening_nothrow( bool _bDoListen ) const
228cdf0e10cSrcweir     {
229cdf0e10cSrcweir         try
230cdf0e10cSrcweir         {
231cdf0e10cSrcweir             Reference< XPropertySet > xModelProperties( m_xModel, UNO_QUERY );
232cdf0e10cSrcweir             if ( !xModelProperties.is() )
233cdf0e10cSrcweir                 // okay, so the model doesn't want to change its properties
234cdf0e10cSrcweir                 // dynamically - fine with us
235cdf0e10cSrcweir                 return;
236cdf0e10cSrcweir 
237cdf0e10cSrcweir             void (SAL_CALL XPropertySet::*pListenerOperation)( const ::rtl::OUString&, const Reference< XPropertyChangeListener >& )
238cdf0e10cSrcweir                 = _bDoListen ? &XPropertySet::addPropertyChangeListener : &XPropertySet::removePropertyChangeListener;
239cdf0e10cSrcweir 
240cdf0e10cSrcweir             (xModelProperties.get()->*pListenerOperation)(
241cdf0e10cSrcweir                 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "IsReadOnly" ) ),
242cdf0e10cSrcweir                 const_cast< OPropertyBrowserController* >( this )
243cdf0e10cSrcweir             );
244cdf0e10cSrcweir         }
245cdf0e10cSrcweir         catch( const Exception& )
246cdf0e10cSrcweir         {
247cdf0e10cSrcweir         	DBG_UNHANDLED_EXCEPTION();
248cdf0e10cSrcweir         }
249cdf0e10cSrcweir     }
250cdf0e10cSrcweir 
251cdf0e10cSrcweir     //--------------------------------------------------------------------
252cdf0e10cSrcweir     void OPropertyBrowserController::impl_bindToNewModel_nothrow( const Reference< XObjectInspectorModel >& _rxInspectorModel )
253cdf0e10cSrcweir     {
254cdf0e10cSrcweir         impl_startOrStopModelListening_nothrow( false );
255cdf0e10cSrcweir         m_xModel = _rxInspectorModel;
256cdf0e10cSrcweir         impl_startOrStopModelListening_nothrow( true );
257cdf0e10cSrcweir 
258cdf0e10cSrcweir         // initialize the view, if we already have one
259cdf0e10cSrcweir         if ( haveView() )
260cdf0e10cSrcweir             impl_initializeView_nothrow();
261cdf0e10cSrcweir 
262cdf0e10cSrcweir         // inspect again, if we already have inspectees
263cdf0e10cSrcweir         if ( !m_aInspectedObjects.empty() )
264cdf0e10cSrcweir             impl_rebindToInspectee_nothrow( m_aInspectedObjects );
265cdf0e10cSrcweir     }
266cdf0e10cSrcweir 
267cdf0e10cSrcweir     //--------------------------------------------------------------------
268cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::setInspectorModel( const Reference< XObjectInspectorModel >& _inspectorModel ) throw (RuntimeException)
269cdf0e10cSrcweir     {
270cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
271cdf0e10cSrcweir 
272cdf0e10cSrcweir         if ( m_xModel == _inspectorModel )
273cdf0e10cSrcweir             return;
274cdf0e10cSrcweir 
275cdf0e10cSrcweir         impl_bindToNewModel_nothrow( _inspectorModel );
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 
278cdf0e10cSrcweir     //--------------------------------------------------------------------
279cdf0e10cSrcweir     Reference< XObjectInspectorUI > SAL_CALL OPropertyBrowserController::getInspectorUI() throw (RuntimeException)
280cdf0e10cSrcweir     {
281cdf0e10cSrcweir         // we're derived from this interface, though we do not expose it in queryInterface and getTypes.
282cdf0e10cSrcweir         return this;
283cdf0e10cSrcweir     }
284cdf0e10cSrcweir 
285cdf0e10cSrcweir     //--------------------------------------------------------------------
286cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::inspect( const Sequence< Reference< XInterface > >& _rObjects ) throw (com::sun::star::util::VetoException, RuntimeException)
287cdf0e10cSrcweir     {
288cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
289cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
290cdf0e10cSrcweir 
291cdf0e10cSrcweir         if ( m_bSuspendingPropertyHandlers || !suspendAll_nothrow() )
292cdf0e10cSrcweir         {   // we already are trying to suspend the component (this is somewhere up the stack)
293cdf0e10cSrcweir             // OR one of our property handlers raised a veto against closing. Well, we *need* to close
294cdf0e10cSrcweir             // it in order to inspect another object.
295cdf0e10cSrcweir             throw VetoException();
296cdf0e10cSrcweir         }
297cdf0e10cSrcweir         if ( m_bBindingIntrospectee )
298cdf0e10cSrcweir             throw VetoException();
299cdf0e10cSrcweir 
300cdf0e10cSrcweir         m_bBindingIntrospectee = true;
301cdf0e10cSrcweir         impl_rebindToInspectee_nothrow( InterfaceArray( _rObjects.getConstArray(), _rObjects.getConstArray() + _rObjects.getLength() ) );
302cdf0e10cSrcweir         m_bBindingIntrospectee = false;
303cdf0e10cSrcweir 
304cdf0e10cSrcweir     }
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     //--------------------------------------------------------------------
307cdf0e10cSrcweir     Reference< XDispatch > SAL_CALL OPropertyBrowserController::queryDispatch( const URL& /*URL*/, const ::rtl::OUString& /*TargetFrameName*/, ::sal_Int32 /*SearchFlags*/ ) throw (RuntimeException)
308cdf0e10cSrcweir     {
309cdf0e10cSrcweir         // we don't have any dispatches at all, right now
310cdf0e10cSrcweir         return Reference< XDispatch >();
311cdf0e10cSrcweir     }
312cdf0e10cSrcweir 
313cdf0e10cSrcweir     //--------------------------------------------------------------------
314cdf0e10cSrcweir     Sequence< Reference< XDispatch > > SAL_CALL OPropertyBrowserController::queryDispatches( const Sequence< DispatchDescriptor >& Requests ) throw (RuntimeException)
315cdf0e10cSrcweir     {
316cdf0e10cSrcweir 	    Sequence< Reference< XDispatch > > aReturn;
317cdf0e10cSrcweir 	    sal_Int32 nLen = Requests.getLength();
318cdf0e10cSrcweir 		aReturn.realloc( nLen );
319cdf0e10cSrcweir 
320cdf0e10cSrcweir                 Reference< XDispatch >* pReturn 	= aReturn.getArray();
321cdf0e10cSrcweir 		const	Reference< XDispatch >* pReturnEnd	= aReturn.getArray() + nLen;
322cdf0e10cSrcweir 		const	DispatchDescriptor* 	pDescripts	= Requests.getConstArray();
323cdf0e10cSrcweir 
324cdf0e10cSrcweir 		for ( ; pReturn != pReturnEnd; ++ pReturn, ++pDescripts )
325cdf0e10cSrcweir 			*pReturn = queryDispatch( pDescripts->FeatureURL, pDescripts->FrameName, pDescripts->SearchFlags );
326cdf0e10cSrcweir 
327cdf0e10cSrcweir 	    return aReturn;
328cdf0e10cSrcweir     }
329cdf0e10cSrcweir 
330cdf0e10cSrcweir     //------------------------------------------------------------------------
331cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::initialize( const Sequence< Any >& _arguments ) throw (Exception, RuntimeException)
332cdf0e10cSrcweir     {
333cdf0e10cSrcweir         if ( m_bConstructed )
334cdf0e10cSrcweir             throw AlreadyInitializedException();
335cdf0e10cSrcweir 
336cdf0e10cSrcweir         StlSyntaxSequence< Any > arguments( _arguments );
337cdf0e10cSrcweir         if ( arguments.empty() )
338cdf0e10cSrcweir         {   // constructor: "createDefault()"
339cdf0e10cSrcweir             createDefault();
340cdf0e10cSrcweir             return;
341cdf0e10cSrcweir         }
342cdf0e10cSrcweir 
343cdf0e10cSrcweir         Reference< XObjectInspectorModel > xModel;
344cdf0e10cSrcweir         if ( arguments.size() == 1 )
345cdf0e10cSrcweir         {   // constructor: "createWithModel( XObjectInspectorModel )"
346cdf0e10cSrcweir             if ( !( arguments[0] >>= xModel ) )
347cdf0e10cSrcweir                 throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
348cdf0e10cSrcweir             createWithModel( xModel );
349cdf0e10cSrcweir             return;
350cdf0e10cSrcweir         }
351cdf0e10cSrcweir 
352cdf0e10cSrcweir         throw IllegalArgumentException( ::rtl::OUString(), *this, 0 );
353cdf0e10cSrcweir     }
354cdf0e10cSrcweir 
355cdf0e10cSrcweir     //------------------------------------------------------------------------
356cdf0e10cSrcweir 	void OPropertyBrowserController::createDefault()
357cdf0e10cSrcweir     {
358cdf0e10cSrcweir         m_bConstructed = true;
359cdf0e10cSrcweir     }
360cdf0e10cSrcweir 
361cdf0e10cSrcweir     //------------------------------------------------------------------------
362cdf0e10cSrcweir 	void OPropertyBrowserController::createWithModel( const Reference< XObjectInspectorModel >& _rxModel )
363cdf0e10cSrcweir     {
364cdf0e10cSrcweir         osl_incrementInterlockedCount( &m_refCount );
365cdf0e10cSrcweir         {
366cdf0e10cSrcweir             setInspectorModel( _rxModel );
367cdf0e10cSrcweir         }
368cdf0e10cSrcweir         osl_decrementInterlockedCount( &m_refCount );
369cdf0e10cSrcweir 
370cdf0e10cSrcweir         m_bConstructed = true;
371cdf0e10cSrcweir     }
372cdf0e10cSrcweir 
373cdf0e10cSrcweir     //------------------------------------------------------------------------
374cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::attachFrame( const Reference< XFrame >& _rxFrame ) throw(RuntimeException)
375cdf0e10cSrcweir 	{
376cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
377cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
378cdf0e10cSrcweir 
379cdf0e10cSrcweir 		if (_rxFrame.is() && haveView())
380cdf0e10cSrcweir 			throw RuntimeException(::rtl::OUString::createFromAscii("Unable to attach to a second frame."),*this);
381cdf0e10cSrcweir 
382cdf0e10cSrcweir 		// revoke as focus listener from the old container window
383cdf0e10cSrcweir 		stopContainerWindowListening();
384cdf0e10cSrcweir 
385cdf0e10cSrcweir 		m_xFrame = _rxFrame;
386cdf0e10cSrcweir 		if (!m_xFrame.is())
387cdf0e10cSrcweir 			return;
388cdf0e10cSrcweir 
389cdf0e10cSrcweir 		// TODO: this construction perhaps should be done outside. Don't know the exact meaning of attachFrame.
390cdf0e10cSrcweir 		// Maybe it is intended to only announce the frame to the controller, and the instance doing this
391cdf0e10cSrcweir 		// announcement is responsible for calling setComponent, too.
392cdf0e10cSrcweir 		Reference< XWindow > xContainerWindow = m_xFrame->getContainerWindow();
393cdf0e10cSrcweir 		VCLXWindow*	pContainerWindow = VCLXWindow::GetImplementation(xContainerWindow);
394cdf0e10cSrcweir 		Window* pParentWin = pContainerWindow ? pContainerWindow->GetWindow() : NULL;
395cdf0e10cSrcweir 		if (!pParentWin)
396cdf0e10cSrcweir 			throw RuntimeException(::rtl::OUString::createFromAscii("The frame is invalid. Unable to extract the container window."),*this);
397cdf0e10cSrcweir 
398cdf0e10cSrcweir 		if ( Construct( pParentWin ) )
399cdf0e10cSrcweir         {
400cdf0e10cSrcweir             try
401cdf0e10cSrcweir             {
402cdf0e10cSrcweir 			    m_xFrame->setComponent( VCLUnoHelper::GetInterface( m_pView ), this );
403cdf0e10cSrcweir             }
404cdf0e10cSrcweir             catch( const Exception& )
405cdf0e10cSrcweir             {
406cdf0e10cSrcweir             	OSL_ENSURE( sal_False, "OPropertyBrowserController::attachFrame: caught an exception!" );
407cdf0e10cSrcweir             }
408cdf0e10cSrcweir         }
409cdf0e10cSrcweir 
410cdf0e10cSrcweir 		startContainerWindowListening();
411cdf0e10cSrcweir 
412cdf0e10cSrcweir         UpdateUI();
413cdf0e10cSrcweir 	}
414cdf0e10cSrcweir 
415cdf0e10cSrcweir 	//------------------------------------------------------------------------
416cdf0e10cSrcweir 	sal_Bool SAL_CALL OPropertyBrowserController::attachModel( const Reference< XModel >& _rxModel ) throw(RuntimeException)
417cdf0e10cSrcweir 	{
418cdf0e10cSrcweir         Reference< XObjectInspectorModel > xModel( _rxModel, UNO_QUERY );
419cdf0e10cSrcweir         if ( !xModel.is() )
420cdf0e10cSrcweir             return false;
421cdf0e10cSrcweir 
422cdf0e10cSrcweir         setInspectorModel( xModel );
423cdf0e10cSrcweir         return getInspectorModel() == _rxModel;
424cdf0e10cSrcweir 	}
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	//------------------------------------------------------------------------
427cdf0e10cSrcweir     sal_Bool OPropertyBrowserController::suspendAll_nothrow()
428cdf0e10cSrcweir     {
429cdf0e10cSrcweir         // if there is a handle inside its "onInteractivePropertySelection" method,
430cdf0e10cSrcweir         // then veto
431cdf0e10cSrcweir         // Normally, we could expect every handler to do this itself, but being
432cdf0e10cSrcweir         // realistic, it's safer to handle this here in general.
433cdf0e10cSrcweir         if ( m_xInteractiveHandler.is() )
434cdf0e10cSrcweir             return sal_False;
435cdf0e10cSrcweir 
436cdf0e10cSrcweir         m_bSuspendingPropertyHandlers = true;
437cdf0e10cSrcweir         sal_Bool bHandlerVeto = !suspendPropertyHandlers_nothrow( sal_True );
438cdf0e10cSrcweir         m_bSuspendingPropertyHandlers = false;
439cdf0e10cSrcweir         if ( bHandlerVeto )
440cdf0e10cSrcweir             return sal_False;
441cdf0e10cSrcweir 
442cdf0e10cSrcweir         return sal_True;
443cdf0e10cSrcweir     }
444cdf0e10cSrcweir 
445cdf0e10cSrcweir 	//------------------------------------------------------------------------
446cdf0e10cSrcweir     sal_Bool OPropertyBrowserController::suspendPropertyHandlers_nothrow( sal_Bool _bSuspend )
447cdf0e10cSrcweir     {
448cdf0e10cSrcweir         PropertyHandlerArray aAllHandlers;  // will contain every handler exactly once
449cdf0e10cSrcweir         for (   PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.begin();
450cdf0e10cSrcweir                 handler != m_aPropertyHandlers.end();
451cdf0e10cSrcweir                 ++handler
452cdf0e10cSrcweir             )
453cdf0e10cSrcweir         {
454cdf0e10cSrcweir             if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), handler->second ) != aAllHandlers.end() )
455cdf0e10cSrcweir                 // already visited this particular handler (m_aPropertyHandlers usually contains
456cdf0e10cSrcweir                 // the same handler more than once)
457cdf0e10cSrcweir                 continue;
458cdf0e10cSrcweir             aAllHandlers.push_back( handler->second );
459cdf0e10cSrcweir         }
460cdf0e10cSrcweir 
461cdf0e10cSrcweir         for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
462cdf0e10cSrcweir               loop != aAllHandlers.end();
463cdf0e10cSrcweir               ++loop
464cdf0e10cSrcweir             )
465cdf0e10cSrcweir         {
466cdf0e10cSrcweir             try
467cdf0e10cSrcweir             {
468cdf0e10cSrcweir                 if ( !(*loop)->suspend( _bSuspend ) )
469cdf0e10cSrcweir                     if ( _bSuspend )
470cdf0e10cSrcweir                         // if we're not suspending, but reactivating, ignore the error
471cdf0e10cSrcweir                         return sal_False;
472cdf0e10cSrcweir             }
473cdf0e10cSrcweir             catch( const Exception& )
474cdf0e10cSrcweir             {
475cdf0e10cSrcweir         	    OSL_ENSURE( sal_False, "OPropertyBrowserController::suspendPropertyHandlers_nothrow: caught an exception!" );
476cdf0e10cSrcweir             }
477cdf0e10cSrcweir         }
478cdf0e10cSrcweir         return sal_True;
479cdf0e10cSrcweir     }
480cdf0e10cSrcweir 
481cdf0e10cSrcweir 	//------------------------------------------------------------------------
482cdf0e10cSrcweir 	sal_Bool SAL_CALL OPropertyBrowserController::suspend( sal_Bool _bSuspend ) throw(RuntimeException)
483cdf0e10cSrcweir 	{
484cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
485cdf0e10cSrcweir 		OSL_ENSURE( haveView(), "OPropertyBrowserController::suspend: don't have a view anymore!" );
486cdf0e10cSrcweir 
487cdf0e10cSrcweir         if ( !_bSuspend )
488cdf0e10cSrcweir         {   // this means a "suspend" is to be "revoked"
489cdf0e10cSrcweir             suspendPropertyHandlers_nothrow( sal_False );
490cdf0e10cSrcweir             // we ourself cannot revoke our suspend
491cdf0e10cSrcweir             return sal_False;
492cdf0e10cSrcweir         }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir         if ( !suspendAll_nothrow() )
495cdf0e10cSrcweir             return sal_False;
496cdf0e10cSrcweir 
497cdf0e10cSrcweir 		// commit the editor's content
498cdf0e10cSrcweir 		if ( haveView() )
499cdf0e10cSrcweir 			getPropertyBox().CommitModified();
500cdf0e10cSrcweir 
501cdf0e10cSrcweir 		// stop listening
502cdf0e10cSrcweir 		stopContainerWindowListening();
503cdf0e10cSrcweir 
504cdf0e10cSrcweir 		// outtahere
505cdf0e10cSrcweir 		return sal_True;
506cdf0e10cSrcweir 	}
507cdf0e10cSrcweir 
508cdf0e10cSrcweir 	//------------------------------------------------------------------------
509cdf0e10cSrcweir 	Any SAL_CALL OPropertyBrowserController::getViewData(  ) throw(RuntimeException)
510cdf0e10cSrcweir 	{
511cdf0e10cSrcweir         return makeAny( m_sPageSelection );
512cdf0e10cSrcweir 	}
513cdf0e10cSrcweir 
514cdf0e10cSrcweir 	//------------------------------------------------------------------------
515cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::restoreViewData( const Any& Data ) throw(RuntimeException)
516cdf0e10cSrcweir 	{
517cdf0e10cSrcweir         ::rtl::OUString sPageSelection;
518cdf0e10cSrcweir         if ( ( Data >>= sPageSelection ) && sPageSelection.getLength() )
519cdf0e10cSrcweir         {
520cdf0e10cSrcweir             m_sPageSelection = sPageSelection;
521cdf0e10cSrcweir             selectPageFromViewData();
522cdf0e10cSrcweir         }
523cdf0e10cSrcweir 	}
524cdf0e10cSrcweir 
525cdf0e10cSrcweir 	//------------------------------------------------------------------------
526cdf0e10cSrcweir 	Reference< XModel > SAL_CALL OPropertyBrowserController::getModel(  ) throw(RuntimeException)
527cdf0e10cSrcweir 	{
528cdf0e10cSrcweir 		// have no model
529cdf0e10cSrcweir 		return Reference< XModel >();
530cdf0e10cSrcweir 	}
531cdf0e10cSrcweir 
532cdf0e10cSrcweir 	//------------------------------------------------------------------------
533cdf0e10cSrcweir 	Reference< XFrame > SAL_CALL OPropertyBrowserController::getFrame(  ) throw(RuntimeException)
534cdf0e10cSrcweir 	{
535cdf0e10cSrcweir 		return m_xFrame;
536cdf0e10cSrcweir 	}
537cdf0e10cSrcweir 
538cdf0e10cSrcweir 	//------------------------------------------------------------------------
539cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::dispose(  ) throw(RuntimeException)
540cdf0e10cSrcweir 	{
541cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
542cdf0e10cSrcweir 
543cdf0e10cSrcweir         // stop inspecting the current object
544cdf0e10cSrcweir 		stopInspection( false );
545cdf0e10cSrcweir 
546cdf0e10cSrcweir 		// say our dispose listeners goodbye
547cdf0e10cSrcweir 		::com::sun::star::lang::EventObject aEvt;
548cdf0e10cSrcweir 		aEvt.Source = static_cast< ::cppu::OWeakObject* >(this);
549cdf0e10cSrcweir 		m_aDisposeListeners.disposeAndClear(aEvt);
550cdf0e10cSrcweir         m_aControlObservers.disposeAndClear(aEvt);
551cdf0e10cSrcweir 
552cdf0e10cSrcweir 		// don't delete explicitly (this is done by the frame we reside in)
553cdf0e10cSrcweir 		m_pView = NULL;
554cdf0e10cSrcweir 
555cdf0e10cSrcweir 		Reference< XComponent > xViewAsComp( m_xView, UNO_QUERY );
556cdf0e10cSrcweir 		if ( xViewAsComp.is() )
557cdf0e10cSrcweir 			xViewAsComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
558cdf0e10cSrcweir 		m_xView.clear( );
559cdf0e10cSrcweir 
560cdf0e10cSrcweir         m_aInspectedObjects.clear();
561cdf0e10cSrcweir         impl_bindToNewModel_nothrow( NULL );
562cdf0e10cSrcweir 	}
563cdf0e10cSrcweir 
564cdf0e10cSrcweir 	//------------------------------------------------------------------------
565cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::addEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
566cdf0e10cSrcweir 	{
567cdf0e10cSrcweir 		m_aDisposeListeners.addInterface(_rxListener);
568cdf0e10cSrcweir 	}
569cdf0e10cSrcweir 
570cdf0e10cSrcweir 	//------------------------------------------------------------------------
571cdf0e10cSrcweir 	void SAL_CALL OPropertyBrowserController::removeEventListener( const Reference< XEventListener >& _rxListener ) throw(RuntimeException)
572cdf0e10cSrcweir 	{
573cdf0e10cSrcweir 		m_aDisposeListeners.removeInterface(_rxListener);
574cdf0e10cSrcweir 	}
575cdf0e10cSrcweir 
576cdf0e10cSrcweir 	//------------------------------------------------------------------------
577cdf0e10cSrcweir 	::rtl::OUString SAL_CALL OPropertyBrowserController::getImplementationName(  ) throw(RuntimeException)
578cdf0e10cSrcweir 	{
579cdf0e10cSrcweir 		return getImplementationName_static();
580cdf0e10cSrcweir 	}
581cdf0e10cSrcweir 
582cdf0e10cSrcweir 	//------------------------------------------------------------------------
583cdf0e10cSrcweir 	sal_Bool SAL_CALL OPropertyBrowserController::supportsService( const ::rtl::OUString& ServiceName ) throw(RuntimeException)
584cdf0e10cSrcweir 	{
585cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aSupported(getSupportedServiceNames());
586cdf0e10cSrcweir 		const ::rtl::OUString* pArray = aSupported.getConstArray();
587cdf0e10cSrcweir 		for (sal_Int32 i = 0; i < aSupported.getLength(); ++i, ++pArray)
588cdf0e10cSrcweir 			if (pArray->equals(ServiceName))
589cdf0e10cSrcweir 				return sal_True;
590cdf0e10cSrcweir 		return sal_False;
591cdf0e10cSrcweir 	}
592cdf0e10cSrcweir 
593cdf0e10cSrcweir 	//------------------------------------------------------------------------
594cdf0e10cSrcweir 	Sequence< ::rtl::OUString > SAL_CALL OPropertyBrowserController::getSupportedServiceNames(  ) throw(RuntimeException)
595cdf0e10cSrcweir 	{
596cdf0e10cSrcweir 		return getSupportedServiceNames_static();
597cdf0e10cSrcweir 	}
598cdf0e10cSrcweir 
599cdf0e10cSrcweir 	//------------------------------------------------------------------------
600cdf0e10cSrcweir 	::rtl::OUString OPropertyBrowserController::getImplementationName_static(  ) throw(RuntimeException)
601cdf0e10cSrcweir 	{
602cdf0e10cSrcweir 		return ::rtl::OUString::createFromAscii("org.openoffice.comp.extensions.ObjectInspector");
603cdf0e10cSrcweir 	}
604cdf0e10cSrcweir 
605cdf0e10cSrcweir 	//------------------------------------------------------------------------
606cdf0e10cSrcweir 	Sequence< ::rtl::OUString > OPropertyBrowserController::getSupportedServiceNames_static(  ) throw(RuntimeException)
607cdf0e10cSrcweir 	{
608cdf0e10cSrcweir 		Sequence< ::rtl::OUString > aSupported(1);
609cdf0e10cSrcweir 		aSupported[0] = ::rtl::OUString::createFromAscii( "com.sun.star.inspection.ObjectInspector" );
610cdf0e10cSrcweir 		return aSupported;
611cdf0e10cSrcweir 	}
612cdf0e10cSrcweir 
613cdf0e10cSrcweir 	//------------------------------------------------------------------------
614cdf0e10cSrcweir 	Reference< XInterface > SAL_CALL OPropertyBrowserController::Create(const Reference< XComponentContext >& _rxContext)
615cdf0e10cSrcweir 	{
616cdf0e10cSrcweir         return *(new OPropertyBrowserController( _rxContext ) );
617cdf0e10cSrcweir 	}
618cdf0e10cSrcweir 
619cdf0e10cSrcweir 	//------------------------------------------------------------------------
620cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::focusGained( const FocusEvent& _rSource ) throw (RuntimeException)
621cdf0e10cSrcweir 	{
622cdf0e10cSrcweir 		Reference< XWindow > xSourceWindow(_rSource.Source, UNO_QUERY);
623cdf0e10cSrcweir 		Reference< XWindow > xContainerWindow;
624cdf0e10cSrcweir 		if (m_xFrame.is())
625cdf0e10cSrcweir 			xContainerWindow = m_xFrame->getContainerWindow();
626cdf0e10cSrcweir 
627cdf0e10cSrcweir 		if ( xContainerWindow.get() == xSourceWindow.get() )
628cdf0e10cSrcweir 		{	// our container window got the focus
629cdf0e10cSrcweir 			if ( haveView() )
630cdf0e10cSrcweir 				getPropertyBox().GrabFocus();
631cdf0e10cSrcweir 		}
632cdf0e10cSrcweir 	}
633cdf0e10cSrcweir 
634cdf0e10cSrcweir 	//------------------------------------------------------------------------
635cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::focusLost( const FocusEvent& /*_rSource*/ ) throw (RuntimeException)
636cdf0e10cSrcweir 	{
637cdf0e10cSrcweir 		// not interested in
638cdf0e10cSrcweir 	}
639cdf0e10cSrcweir 
640cdf0e10cSrcweir 	//------------------------------------------------------------------------
641cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::disposing( const EventObject& _rSource ) throw(RuntimeException)
642cdf0e10cSrcweir 	{
643cdf0e10cSrcweir 		if ( m_xView.is() && ( m_xView == _rSource.Source ) )
644cdf0e10cSrcweir 		{
645cdf0e10cSrcweir 			m_xView = NULL;
646cdf0e10cSrcweir 			m_pView = NULL;
647cdf0e10cSrcweir 		}
648cdf0e10cSrcweir 
649cdf0e10cSrcweir         for (   InterfaceArray::iterator loop = m_aInspectedObjects.begin();
650cdf0e10cSrcweir                 loop != m_aInspectedObjects.end();
651cdf0e10cSrcweir                 ++loop
652cdf0e10cSrcweir             )
653cdf0e10cSrcweir         {
654cdf0e10cSrcweir             if ( *loop == _rSource.Source )
655cdf0e10cSrcweir             {
656cdf0e10cSrcweir                 m_aInspectedObjects.erase( loop );
657cdf0e10cSrcweir                 break;
658cdf0e10cSrcweir             }
659cdf0e10cSrcweir         }
660cdf0e10cSrcweir 	}
661cdf0e10cSrcweir 
662cdf0e10cSrcweir 	//------------------------------------------------------------------------
663cdf0e10cSrcweir 	IMPL_LINK(OPropertyBrowserController, OnPageActivation, void*, EMPTYARG)
664cdf0e10cSrcweir 	{
665cdf0e10cSrcweir 		updateViewDataFromActivePage();
666cdf0e10cSrcweir 		return 0L;
667cdf0e10cSrcweir 	}
668cdf0e10cSrcweir 
669cdf0e10cSrcweir 	//------------------------------------------------------------------------
670cdf0e10cSrcweir 	void OPropertyBrowserController::updateViewDataFromActivePage()
671cdf0e10cSrcweir 	{
672cdf0e10cSrcweir 		if (!haveView())
673cdf0e10cSrcweir 			return;
674cdf0e10cSrcweir 
675cdf0e10cSrcweir         ::rtl::OUString sOldSelection = m_sPageSelection;
676cdf0e10cSrcweir         m_sPageSelection = ::rtl::OUString();
677cdf0e10cSrcweir 
678cdf0e10cSrcweir 		const sal_uInt16 nCurrentPage = m_pView->getActivaPage();
679cdf0e10cSrcweir 		if ( (sal_uInt16)-1 != nCurrentPage )
680cdf0e10cSrcweir         {
681cdf0e10cSrcweir             for (   HashString2Int16::const_iterator pageId = m_aPageIds.begin();
682cdf0e10cSrcweir                     pageId != m_aPageIds.end();
683cdf0e10cSrcweir                     ++pageId
684cdf0e10cSrcweir                 )
685cdf0e10cSrcweir             {
686cdf0e10cSrcweir                 if ( nCurrentPage == pageId->second )
687cdf0e10cSrcweir                 {
688cdf0e10cSrcweir 				    m_sPageSelection = pageId->first;
689cdf0e10cSrcweir                     break;
690cdf0e10cSrcweir                 }
691cdf0e10cSrcweir             }
692cdf0e10cSrcweir         }
693cdf0e10cSrcweir 
694cdf0e10cSrcweir         if ( m_sPageSelection.getLength() )
695cdf0e10cSrcweir             m_sLastValidPageSelection = m_sPageSelection;
696cdf0e10cSrcweir         else if ( sOldSelection.getLength() )
697cdf0e10cSrcweir             m_sLastValidPageSelection = sOldSelection;
698cdf0e10cSrcweir 	}
699cdf0e10cSrcweir 
700cdf0e10cSrcweir 	//------------------------------------------------------------------------
701cdf0e10cSrcweir     sal_uInt16 OPropertyBrowserController::impl_getPageIdForCategory_nothrow( const ::rtl::OUString& _rCategoryName ) const
702cdf0e10cSrcweir     {
703cdf0e10cSrcweir 		sal_uInt16 nPageId = (sal_uInt16)-1;
704cdf0e10cSrcweir         HashString2Int16::const_iterator pagePos = m_aPageIds.find( _rCategoryName );
705cdf0e10cSrcweir         if ( pagePos != m_aPageIds.end() )
706cdf0e10cSrcweir 			nPageId = pagePos->second;
707cdf0e10cSrcweir         return nPageId;
708cdf0e10cSrcweir     }
709cdf0e10cSrcweir 
710cdf0e10cSrcweir 	//------------------------------------------------------------------------
711cdf0e10cSrcweir 	void OPropertyBrowserController::selectPageFromViewData()
712cdf0e10cSrcweir 	{
713cdf0e10cSrcweir 		sal_uInt16 nNewPage = impl_getPageIdForCategory_nothrow( m_sPageSelection );
714cdf0e10cSrcweir 
715cdf0e10cSrcweir 		if ( haveView() && ( nNewPage != (sal_uInt16)-1 ) )
716cdf0e10cSrcweir 			m_pView->activatePage( nNewPage );
717cdf0e10cSrcweir 
718cdf0e10cSrcweir 		// just in case ...
719cdf0e10cSrcweir 		updateViewDataFromActivePage();
720cdf0e10cSrcweir 	}
721cdf0e10cSrcweir 
722cdf0e10cSrcweir 	//------------------------------------------------------------------------
723cdf0e10cSrcweir 	sal_Bool OPropertyBrowserController::Construct(Window* _pParentWin)
724cdf0e10cSrcweir 	{
725cdf0e10cSrcweir 		DBG_ASSERT(!haveView(), "OPropertyBrowserController::Construct: already have a view!");
726cdf0e10cSrcweir 		DBG_ASSERT(_pParentWin, "OPropertyBrowserController::Construct: invalid parent window!");
727cdf0e10cSrcweir 
728cdf0e10cSrcweir 		m_pView = new OPropertyBrowserView(m_aContext.getLegacyServiceFactory(), _pParentWin);
729cdf0e10cSrcweir 		m_pView->setPageActivationHandler(LINK(this, OPropertyBrowserController, OnPageActivation));
730cdf0e10cSrcweir 
731cdf0e10cSrcweir 		// add as dispose listener for our view. The view is disposed by the frame we're plugged into,
732cdf0e10cSrcweir 		// and this disposal _deletes_ the view, so it would be deadly if we use our m_pView member
733cdf0e10cSrcweir 		// after that
734cdf0e10cSrcweir 		m_xView = VCLUnoHelper::GetInterface(m_pView);
735cdf0e10cSrcweir 		Reference< XComponent > xViewAsComp(m_xView, UNO_QUERY);
736cdf0e10cSrcweir 		if (xViewAsComp.is())
737cdf0e10cSrcweir 			xViewAsComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
738cdf0e10cSrcweir 
739cdf0e10cSrcweir         getPropertyBox().SetLineListener(this);
740cdf0e10cSrcweir 		getPropertyBox().SetControlObserver(this);
741cdf0e10cSrcweir         impl_initializeView_nothrow();
742cdf0e10cSrcweir 
743cdf0e10cSrcweir         m_pView->Show();
744cdf0e10cSrcweir 
745cdf0e10cSrcweir 		return sal_True;
746cdf0e10cSrcweir 	}
747cdf0e10cSrcweir 
748cdf0e10cSrcweir 	//------------------------------------------------------------------------
749cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::propertyChange( const PropertyChangeEvent& _rEvent ) throw (RuntimeException)
750cdf0e10cSrcweir     {
751cdf0e10cSrcweir         if ( _rEvent.Source == m_xModel )
752cdf0e10cSrcweir         {
753cdf0e10cSrcweir             if ( _rEvent.PropertyName.equalsAscii( "IsReadOnly" ) )
754cdf0e10cSrcweir                 impl_updateReadOnlyView_nothrow();
755cdf0e10cSrcweir             return;
756cdf0e10cSrcweir         }
757cdf0e10cSrcweir 
758cdf0e10cSrcweir         if ( m_sCommittingProperty == _rEvent.PropertyName )
759cdf0e10cSrcweir             return;
760cdf0e10cSrcweir 
761cdf0e10cSrcweir         if ( !haveView() )
762cdf0e10cSrcweir             return;
763cdf0e10cSrcweir 
764cdf0e10cSrcweir         Any aNewValue( _rEvent.NewValue );
765cdf0e10cSrcweir         if ( impl_hasPropertyHandlerFor_nothrow( _rEvent.PropertyName ) )
766cdf0e10cSrcweir         {
767cdf0e10cSrcweir             // forward the new value to the property box, to reflect the change in the UI
768cdf0e10cSrcweir             aNewValue = impl_getPropertyValue_throw( _rEvent.PropertyName );
769cdf0e10cSrcweir 
770cdf0e10cSrcweir             // check whether the state is ambiguous. This is interesting in case we display the properties
771cdf0e10cSrcweir             // for multiple objects at once: In this case, we'll get a notification from one of the objects,
772cdf0e10cSrcweir             // but need to care for the "composed" value, which can be "ambiguous".
773cdf0e10cSrcweir             PropertyHandlerRef xHandler( impl_getHandlerForProperty_throw( _rEvent.PropertyName ), UNO_SET_THROW );
774cdf0e10cSrcweir             PropertyState ePropertyState( xHandler->getPropertyState( _rEvent.PropertyName ) );
775cdf0e10cSrcweir 	        bool bAmbiguousValue = ( PropertyState_AMBIGUOUS_VALUE == ePropertyState );
776cdf0e10cSrcweir 
777cdf0e10cSrcweir             getPropertyBox().SetPropertyValue( _rEvent.PropertyName, aNewValue, bAmbiguousValue );
778cdf0e10cSrcweir         }
779cdf0e10cSrcweir 
780cdf0e10cSrcweir         // if it's a actuating property, then update the UI for any dependent
781cdf0e10cSrcweir         // properties
782cdf0e10cSrcweir         if ( impl_isActuatingProperty_nothrow( _rEvent.PropertyName ) )
783cdf0e10cSrcweir             impl_broadcastPropertyChange_nothrow( _rEvent.PropertyName, aNewValue, _rEvent.OldValue, false );
784cdf0e10cSrcweir     }
785cdf0e10cSrcweir 
786cdf0e10cSrcweir 	//------------------------------------------------------------------------
787cdf0e10cSrcweir     Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::createPropertyControl( ::sal_Int16 ControlType, ::sal_Bool _CreateReadOnly ) throw (IllegalArgumentException, RuntimeException)
788cdf0e10cSrcweir     {
789cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
790cdf0e10cSrcweir 
791cdf0e10cSrcweir         Reference< XPropertyControl > xControl;
792cdf0e10cSrcweir 
793cdf0e10cSrcweir 		// default winbits: a border only
794cdf0e10cSrcweir 		WinBits nWinBits = WB_BORDER;
795cdf0e10cSrcweir 
796cdf0e10cSrcweir         // read-only-ness
797cdf0e10cSrcweir         _CreateReadOnly |= (sal_Bool)impl_isReadOnlyModel_throw();
798cdf0e10cSrcweir 		if ( _CreateReadOnly )
799cdf0e10cSrcweir 			nWinBits |= WB_READONLY;
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 		switch ( ControlType )
802cdf0e10cSrcweir 		{
803cdf0e10cSrcweir             case PropertyControlType::StringListField:
804cdf0e10cSrcweir 				xControl = new OMultilineEditControl( &getPropertyBox(), eStringList, nWinBits | WB_DROPDOWN | WB_TABSTOP );
805cdf0e10cSrcweir 				break;
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 			case PropertyControlType::MultiLineTextField:
808cdf0e10cSrcweir 				xControl = new OMultilineEditControl( &getPropertyBox(), eMultiLineText, nWinBits | WB_DROPDOWN | WB_TABSTOP );
809cdf0e10cSrcweir 				break;
810cdf0e10cSrcweir 
811cdf0e10cSrcweir             case PropertyControlType::ListBox:
812cdf0e10cSrcweir 				xControl = new OListboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
813cdf0e10cSrcweir 				break;
814cdf0e10cSrcweir 
815cdf0e10cSrcweir 			case PropertyControlType::ComboBox:
816cdf0e10cSrcweir 				xControl = new OComboboxControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN);
817cdf0e10cSrcweir 				break;
818cdf0e10cSrcweir 
819cdf0e10cSrcweir 			case PropertyControlType::TextField:
820cdf0e10cSrcweir 				xControl = new OEditControl( &getPropertyBox(), sal_False, nWinBits | WB_TABSTOP );
821cdf0e10cSrcweir 				break;
822cdf0e10cSrcweir 
823cdf0e10cSrcweir 			case PropertyControlType::CharacterField:
824cdf0e10cSrcweir 				xControl = new OEditControl( &getPropertyBox(), sal_True, nWinBits | WB_TABSTOP );
825cdf0e10cSrcweir 				break;
826cdf0e10cSrcweir 
827cdf0e10cSrcweir 			case PropertyControlType::NumericField:
828cdf0e10cSrcweir 				xControl = new ONumericControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
829cdf0e10cSrcweir 				break;
830cdf0e10cSrcweir 
831cdf0e10cSrcweir             case PropertyControlType::DateTimeField:
832cdf0e10cSrcweir 				xControl = new ODateTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP );
833cdf0e10cSrcweir 				break;
834cdf0e10cSrcweir 
835cdf0e10cSrcweir 			case PropertyControlType::DateField:
836cdf0e10cSrcweir 				xControl = new ODateControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
837cdf0e10cSrcweir 				break;
838cdf0e10cSrcweir 
839cdf0e10cSrcweir 			case PropertyControlType::TimeField:
840cdf0e10cSrcweir 				xControl = new OTimeControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_SPIN | WB_REPEAT );
841cdf0e10cSrcweir 				break;
842cdf0e10cSrcweir 
843cdf0e10cSrcweir 			case PropertyControlType::ColorListBox:
844cdf0e10cSrcweir 				xControl = new OColorControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
845cdf0e10cSrcweir 				break;
846cdf0e10cSrcweir 
847cdf0e10cSrcweir 			case PropertyControlType::HyperlinkField:
848cdf0e10cSrcweir 				xControl = new OHyperlinkControl( &getPropertyBox(), nWinBits | WB_TABSTOP | WB_DROPDOWN );
849cdf0e10cSrcweir 				break;
850cdf0e10cSrcweir 
851cdf0e10cSrcweir 			default:
852cdf0e10cSrcweir                 throw IllegalArgumentException( ::rtl::OUString(), *this, 1 );
853cdf0e10cSrcweir 		}
854cdf0e10cSrcweir 
855cdf0e10cSrcweir         return xControl;
856cdf0e10cSrcweir     }
857cdf0e10cSrcweir 
858cdf0e10cSrcweir 	//------------------------------------------------------------------------
859cdf0e10cSrcweir     void OPropertyBrowserController::impl_toggleInspecteeListening_nothrow( bool _bOn )
860cdf0e10cSrcweir     {
861cdf0e10cSrcweir         for (   InterfaceArray::const_iterator loop = m_aInspectedObjects.begin();
862cdf0e10cSrcweir                 loop != m_aInspectedObjects.end();
863cdf0e10cSrcweir                 ++loop
864cdf0e10cSrcweir             )
865cdf0e10cSrcweir         {
866cdf0e10cSrcweir             try
867cdf0e10cSrcweir             {
868cdf0e10cSrcweir                 Reference< XComponent > xComp( *loop, UNO_QUERY );
869cdf0e10cSrcweir                 if ( xComp.is() )
870cdf0e10cSrcweir                 {
871cdf0e10cSrcweir                     if ( _bOn )
872cdf0e10cSrcweir                         xComp->addEventListener( static_cast< XPropertyChangeListener* >( this ) );
873cdf0e10cSrcweir                     else
874cdf0e10cSrcweir                         xComp->removeEventListener( static_cast< XPropertyChangeListener* >( this ) );
875cdf0e10cSrcweir                 }
876cdf0e10cSrcweir             }
877cdf0e10cSrcweir             catch( const Exception& )
878cdf0e10cSrcweir             {
879cdf0e10cSrcweir                 DBG_UNHANDLED_EXCEPTION();
880cdf0e10cSrcweir             }
881cdf0e10cSrcweir         }
882cdf0e10cSrcweir     }
883cdf0e10cSrcweir 
884cdf0e10cSrcweir 	//------------------------------------------------------------------------
885cdf0e10cSrcweir 	void OPropertyBrowserController::stopInspection( bool _bCommitModified )
886cdf0e10cSrcweir 	{
887cdf0e10cSrcweir         if ( haveView() )
888cdf0e10cSrcweir         {
889cdf0e10cSrcweir 		    if ( _bCommitModified )
890cdf0e10cSrcweir 			    // commit the editor's content
891cdf0e10cSrcweir 			    getPropertyBox().CommitModified();
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 		    // hide the property box so that it does not flicker
894cdf0e10cSrcweir 		    getPropertyBox().Hide();
895cdf0e10cSrcweir 
896cdf0e10cSrcweir 		    // clear the property box
897cdf0e10cSrcweir 		    getPropertyBox().ClearAll();
898cdf0e10cSrcweir         }
899cdf0e10cSrcweir 
900cdf0e10cSrcweir 		// destroy the view first
901cdf0e10cSrcweir 		if ( haveView() )
902cdf0e10cSrcweir 		{
903cdf0e10cSrcweir 			// remove the pages
904cdf0e10cSrcweir             for (   HashString2Int16::const_iterator erase = m_aPageIds.begin();
905cdf0e10cSrcweir                     erase != m_aPageIds.end();
906cdf0e10cSrcweir                     ++erase
907cdf0e10cSrcweir                 )
908cdf0e10cSrcweir                 getPropertyBox().RemovePage( erase->second );
909cdf0e10cSrcweir             clearContainer( m_aPageIds );
910cdf0e10cSrcweir 		}
911cdf0e10cSrcweir 
912cdf0e10cSrcweir 		clearContainer( m_aProperties );
913cdf0e10cSrcweir 
914cdf0e10cSrcweir         // de-register as dispose-listener from our inspected objects
915cdf0e10cSrcweir         impl_toggleInspecteeListening_nothrow( false );
916cdf0e10cSrcweir 
917cdf0e10cSrcweir         // handlers are obsolete, so is our "composer" for their UI requests
918cdf0e10cSrcweir         if ( m_pUIRequestComposer.get() )
919cdf0e10cSrcweir             m_pUIRequestComposer->dispose();
920cdf0e10cSrcweir         m_pUIRequestComposer.reset( NULL );
921cdf0e10cSrcweir 
922cdf0e10cSrcweir         // clean up the property handlers
923cdf0e10cSrcweir         PropertyHandlerArray aAllHandlers;  // will contain every handler exactly once
924cdf0e10cSrcweir         for ( PropertyHandlerRepository::const_iterator aHandler = m_aPropertyHandlers.begin();
925cdf0e10cSrcweir               aHandler != m_aPropertyHandlers.end();
926cdf0e10cSrcweir               ++aHandler
927cdf0e10cSrcweir             )
928cdf0e10cSrcweir             if ( ::std::find( aAllHandlers.begin(), aAllHandlers.end(), aHandler->second ) == aAllHandlers.end() )
929cdf0e10cSrcweir                 aAllHandlers.push_back( aHandler->second );
930cdf0e10cSrcweir 
931cdf0e10cSrcweir         for ( PropertyHandlerArray::iterator loop = aAllHandlers.begin();
932cdf0e10cSrcweir               loop != aAllHandlers.end();
933cdf0e10cSrcweir               ++loop
934cdf0e10cSrcweir             )
935cdf0e10cSrcweir         {
936cdf0e10cSrcweir             try
937cdf0e10cSrcweir             {
938cdf0e10cSrcweir                 (*loop)->removePropertyChangeListener( this );
939cdf0e10cSrcweir                 (*loop)->dispose();
940cdf0e10cSrcweir             }
941cdf0e10cSrcweir             catch( const DisposedException& )
942cdf0e10cSrcweir             {
943cdf0e10cSrcweir             }
944cdf0e10cSrcweir             catch( const Exception& )
945cdf0e10cSrcweir             {
946cdf0e10cSrcweir             	DBG_UNHANDLED_EXCEPTION();
947cdf0e10cSrcweir             }
948cdf0e10cSrcweir         }
949cdf0e10cSrcweir 
950cdf0e10cSrcweir         clearContainer( m_aPropertyHandlers );
951cdf0e10cSrcweir         clearContainer( m_aDependencyHandlers );
952cdf0e10cSrcweir 	}
953cdf0e10cSrcweir 
954cdf0e10cSrcweir     //------------------------------------------------------------------------
955cdf0e10cSrcweir     bool OPropertyBrowserController::impl_hasPropertyHandlerFor_nothrow( const ::rtl::OUString& _rPropertyName ) const
956cdf0e10cSrcweir     {
957cdf0e10cSrcweir         PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
958cdf0e10cSrcweir         return ( handlerPos != m_aPropertyHandlers.end() );
959cdf0e10cSrcweir     }
960cdf0e10cSrcweir 
961cdf0e10cSrcweir     //------------------------------------------------------------------------
962cdf0e10cSrcweir     OPropertyBrowserController::PropertyHandlerRef OPropertyBrowserController::impl_getHandlerForProperty_throw( const ::rtl::OUString& _rPropertyName ) const
963cdf0e10cSrcweir     {
964cdf0e10cSrcweir         PropertyHandlerRepository::const_iterator handlerPos = m_aPropertyHandlers.find( _rPropertyName );
965cdf0e10cSrcweir         if ( handlerPos == m_aPropertyHandlers.end() )
966cdf0e10cSrcweir             throw RuntimeException();
967cdf0e10cSrcweir         return handlerPos->second;
968cdf0e10cSrcweir     }
969cdf0e10cSrcweir 
970cdf0e10cSrcweir     //------------------------------------------------------------------------
971cdf0e10cSrcweir     Any OPropertyBrowserController::impl_getPropertyValue_throw( const ::rtl::OUString& _rPropertyName )
972cdf0e10cSrcweir     {
973cdf0e10cSrcweir         PropertyHandlerRef handler = impl_getHandlerForProperty_throw( _rPropertyName );
974cdf0e10cSrcweir         return handler->getPropertyValue( _rPropertyName );
975cdf0e10cSrcweir     }
976cdf0e10cSrcweir 
977cdf0e10cSrcweir 	//------------------------------------------------------------------------
978cdf0e10cSrcweir 	void OPropertyBrowserController::impl_rebindToInspectee_nothrow( const InterfaceArray& _rObjects )
979cdf0e10cSrcweir 	{
980cdf0e10cSrcweir 		try
981cdf0e10cSrcweir 		{
982cdf0e10cSrcweir 			// stop inspecting the old object(s)
983cdf0e10cSrcweir 			stopInspection( true );
984cdf0e10cSrcweir 
985cdf0e10cSrcweir             // inspect the new object(s)
986cdf0e10cSrcweir             m_aInspectedObjects = _rObjects;
987cdf0e10cSrcweir 			doInspection();
988cdf0e10cSrcweir 
989cdf0e10cSrcweir             // update the user interface
990cdf0e10cSrcweir 		    UpdateUI();
991cdf0e10cSrcweir 		}
992cdf0e10cSrcweir 
993cdf0e10cSrcweir 		catch(Exception&)
994cdf0e10cSrcweir 		{
995cdf0e10cSrcweir 			DBG_ERROR("OPropertyBrowserController::impl_rebindToInspectee_nothrow: caught an exception !");
996cdf0e10cSrcweir 		}
997cdf0e10cSrcweir     }
998cdf0e10cSrcweir 
999cdf0e10cSrcweir 	//------------------------------------------------------------------------
1000cdf0e10cSrcweir 	void OPropertyBrowserController::doInspection()
1001cdf0e10cSrcweir 	{
1002cdf0e10cSrcweir 		try
1003cdf0e10cSrcweir 		{
1004cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////////////
1005cdf0e10cSrcweir 			// obtain the properties of the object
1006cdf0e10cSrcweir             ::std::vector< Property > aProperties;
1007cdf0e10cSrcweir 
1008cdf0e10cSrcweir             PropertyHandlerArray aPropertyHandlers;
1009cdf0e10cSrcweir             getPropertyHandlers( m_aInspectedObjects, aPropertyHandlers );
1010cdf0e10cSrcweir 
1011cdf0e10cSrcweir             PropertyHandlerArray::iterator aHandler( aPropertyHandlers.begin() );
1012cdf0e10cSrcweir             while ( aHandler != aPropertyHandlers.end() )
1013cdf0e10cSrcweir             {
1014cdf0e10cSrcweir                 DBG_ASSERT( aHandler->get(), "OPropertyBrowserController::doInspection: invalid handler!" );
1015cdf0e10cSrcweir 
1016cdf0e10cSrcweir                 StlSyntaxSequence< Property > aThisHandlersProperties = (*aHandler)->getSupportedProperties();
1017cdf0e10cSrcweir 
1018cdf0e10cSrcweir                 if ( aThisHandlersProperties.empty() )
1019cdf0e10cSrcweir                 {
1020cdf0e10cSrcweir                     // this handler doesn't know anything about the current inspectee -> ignore it
1021cdf0e10cSrcweir                     (*aHandler)->dispose();
1022cdf0e10cSrcweir                     aHandler = aPropertyHandlers.erase( aHandler );
1023cdf0e10cSrcweir                     continue;
1024cdf0e10cSrcweir                 }
1025cdf0e10cSrcweir 
1026cdf0e10cSrcweir                 // append these properties to our "all properties" array
1027cdf0e10cSrcweir                 aProperties.reserve( aProperties.size() + aThisHandlersProperties.size() );
1028cdf0e10cSrcweir                 for (   StlSyntaxSequence< Property >::const_iterator copyProperty = aThisHandlersProperties.begin();
1029cdf0e10cSrcweir                         copyProperty != aThisHandlersProperties.end();
1030cdf0e10cSrcweir                         ++copyProperty
1031cdf0e10cSrcweir                     )
1032cdf0e10cSrcweir                 {
1033cdf0e10cSrcweir                     ::std::vector< Property >::const_iterator previous = ::std::find_if(
1034cdf0e10cSrcweir                         aProperties.begin(),
1035cdf0e10cSrcweir                         aProperties.end(),
1036cdf0e10cSrcweir                         FindPropertyByName( copyProperty->Name )
1037cdf0e10cSrcweir                     );
1038cdf0e10cSrcweir                     if ( previous == aProperties.end() )
1039cdf0e10cSrcweir                     {
1040cdf0e10cSrcweir                         aProperties.push_back( *copyProperty );
1041cdf0e10cSrcweir                         continue;
1042cdf0e10cSrcweir                     }
1043cdf0e10cSrcweir 
1044cdf0e10cSrcweir                     // there already was another (previous) handler which supported this property.
1045cdf0e10cSrcweir                     // Don't add it to aProperties, again.
1046cdf0e10cSrcweir 
1047cdf0e10cSrcweir                     // Also, ensure that handlers which previously expressed interest in *changes*
1048cdf0e10cSrcweir                     // of this property are not notified.
1049cdf0e10cSrcweir                     // This is 'cause we have a new handler which is responsible for this property,
1050cdf0e10cSrcweir                     // which means it can give it a completely different meaning than the previous
1051cdf0e10cSrcweir                     // handler for this property is prepared for.
1052cdf0e10cSrcweir                     ::std::pair< PropertyHandlerMultiRepository::iterator, PropertyHandlerMultiRepository::iterator >
1053cdf0e10cSrcweir                         aDepHandlers = m_aDependencyHandlers.equal_range( copyProperty->Name );
1054cdf0e10cSrcweir                     m_aDependencyHandlers.erase( aDepHandlers.first, aDepHandlers.second );
1055cdf0e10cSrcweir                 }
1056cdf0e10cSrcweir 
1057cdf0e10cSrcweir                 // determine the superseded properties
1058cdf0e10cSrcweir                 StlSyntaxSequence< ::rtl::OUString > aSupersededByThisHandler = (*aHandler)->getSupersededProperties();
1059cdf0e10cSrcweir                 for (   StlSyntaxSequence< ::rtl::OUString >::const_iterator superseded = aSupersededByThisHandler.begin();
1060cdf0e10cSrcweir                         superseded != aSupersededByThisHandler.end();
1061cdf0e10cSrcweir                         ++superseded
1062cdf0e10cSrcweir                     )
1063cdf0e10cSrcweir                 {
1064cdf0e10cSrcweir                     ::std::vector< Property >::iterator existent = ::std::find_if(
1065cdf0e10cSrcweir                         aProperties.begin(),
1066cdf0e10cSrcweir                         aProperties.end(),
1067cdf0e10cSrcweir                         FindPropertyByName( *superseded )
1068cdf0e10cSrcweir                     );
1069cdf0e10cSrcweir                     if ( existent != aProperties.end() )
1070cdf0e10cSrcweir                         // one of the properties superseded by this handler was supported by a previous
1071cdf0e10cSrcweir                         // one -> erase
1072cdf0e10cSrcweir                         aProperties.erase( existent );
1073cdf0e10cSrcweir                 }
1074cdf0e10cSrcweir 
1075cdf0e10cSrcweir                 // be notified of changes which this handler is responsible for
1076cdf0e10cSrcweir                 (*aHandler)->addPropertyChangeListener( this );
1077cdf0e10cSrcweir 
1078cdf0e10cSrcweir                 // remember this handler for every of the properties which it is responsible
1079cdf0e10cSrcweir                 // for
1080cdf0e10cSrcweir                 for (   StlSyntaxSequence< Property >::const_iterator remember = aThisHandlersProperties.begin();
1081cdf0e10cSrcweir                         remember != aThisHandlersProperties.end();
1082cdf0e10cSrcweir                         ++remember
1083cdf0e10cSrcweir                     )
1084cdf0e10cSrcweir                 {
1085cdf0e10cSrcweir                     m_aPropertyHandlers[ remember->Name ] = *aHandler;
1086cdf0e10cSrcweir                     // note that this implies that if two handlers support the same property,
1087cdf0e10cSrcweir                     // the latter wins
1088cdf0e10cSrcweir                 }
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir                 // see if the handler expresses interest in any actuating properties
1091cdf0e10cSrcweir                 StlSyntaxSequence< ::rtl::OUString > aInterestingActuations = (*aHandler)->getActuatingProperties();
1092cdf0e10cSrcweir                 for (   StlSyntaxSequence< ::rtl::OUString >::const_iterator aLoop = aInterestingActuations.begin();
1093cdf0e10cSrcweir                         aLoop != aInterestingActuations.end();
1094cdf0e10cSrcweir                         ++aLoop
1095cdf0e10cSrcweir                     )
1096cdf0e10cSrcweir                 {
1097cdf0e10cSrcweir                     m_aDependencyHandlers.insert( PropertyHandlerMultiRepository::value_type(
1098cdf0e10cSrcweir                         *aLoop, *aHandler ) );
1099cdf0e10cSrcweir                 }
1100cdf0e10cSrcweir 
1101cdf0e10cSrcweir                 ++aHandler;
1102cdf0e10cSrcweir             }
1103cdf0e10cSrcweir 
1104cdf0e10cSrcweir             // create a new composer for UI requests coming from the handlers
1105cdf0e10cSrcweir             m_pUIRequestComposer.reset( new ComposedPropertyUIUpdate( getInspectorUI(), this ) );
1106cdf0e10cSrcweir 
1107cdf0e10cSrcweir             // sort the properties by relative position, as indicated by the model
1108cdf0e10cSrcweir             for (   ::std::vector< Property >::const_iterator sourceProps = aProperties.begin();
1109cdf0e10cSrcweir                     sourceProps != aProperties.end();
1110cdf0e10cSrcweir                     ++sourceProps
1111cdf0e10cSrcweir                 )
1112cdf0e10cSrcweir 			{
1113cdf0e10cSrcweir                 sal_Int32 nRelativePropertyOrder = sourceProps - aProperties.begin();
1114cdf0e10cSrcweir                 if ( m_xModel.is() )
1115cdf0e10cSrcweir                     nRelativePropertyOrder = m_xModel->getPropertyOrderIndex( sourceProps->Name );
1116cdf0e10cSrcweir                 while ( m_aProperties.find( nRelativePropertyOrder ) != m_aProperties.end() )
1117cdf0e10cSrcweir                     ++nRelativePropertyOrder;
1118cdf0e10cSrcweir 				m_aProperties[ nRelativePropertyOrder ] = *sourceProps;
1119cdf0e10cSrcweir 			}
1120cdf0e10cSrcweir 
1121cdf0e10cSrcweir             // be notified when one of our inspectees dies
1122cdf0e10cSrcweir             impl_toggleInspecteeListening_nothrow( true );
1123cdf0e10cSrcweir 		}
1124cdf0e10cSrcweir 		catch(Exception&)
1125cdf0e10cSrcweir 		{
1126cdf0e10cSrcweir 			DBG_ERROR("OPropertyBrowserController::doInspection : caught an exception !");
1127cdf0e10cSrcweir 		}
1128cdf0e10cSrcweir 	}
1129cdf0e10cSrcweir 
1130cdf0e10cSrcweir 	//------------------------------------------------------------------------
1131cdf0e10cSrcweir 	::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getMinimumSize() throw (::com::sun::star::uno::RuntimeException)
1132cdf0e10cSrcweir 	{
1133cdf0e10cSrcweir 		::com::sun::star::awt::Size aSize;
1134cdf0e10cSrcweir 		if( m_pView )
1135cdf0e10cSrcweir 			return m_pView->getMinimumSize();
1136cdf0e10cSrcweir 		else
1137cdf0e10cSrcweir 			return aSize;
1138cdf0e10cSrcweir 	}
1139cdf0e10cSrcweir 
1140cdf0e10cSrcweir 	//------------------------------------------------------------------------
1141cdf0e10cSrcweir 	::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::getPreferredSize() throw (::com::sun::star::uno::RuntimeException)
1142cdf0e10cSrcweir 	{
1143cdf0e10cSrcweir 		return getMinimumSize();
1144cdf0e10cSrcweir 	}
1145cdf0e10cSrcweir 
1146cdf0e10cSrcweir 	//------------------------------------------------------------------------
1147cdf0e10cSrcweir 	::com::sun::star::awt::Size SAL_CALL OPropertyBrowserController::calcAdjustedSize( const ::com::sun::star::awt::Size& _rNewSize ) throw (::com::sun::star::uno::RuntimeException)
1148cdf0e10cSrcweir 	{
1149cdf0e10cSrcweir 		awt::Size aMinSize = getMinimumSize( );
1150cdf0e10cSrcweir 		awt::Size aAdjustedSize( _rNewSize );
1151cdf0e10cSrcweir 		if ( aAdjustedSize.Width < aMinSize.Width )
1152cdf0e10cSrcweir 			aAdjustedSize.Width = aMinSize.Width;
1153cdf0e10cSrcweir 		if ( aAdjustedSize.Height < aMinSize.Height )
1154cdf0e10cSrcweir 			aAdjustedSize.Height = aMinSize.Height;
1155cdf0e10cSrcweir 		return aAdjustedSize;
1156cdf0e10cSrcweir 	}
1157cdf0e10cSrcweir 
1158cdf0e10cSrcweir 	//------------------------------------------------------------------------
1159cdf0e10cSrcweir     void OPropertyBrowserController::describePropertyLine( const Property& _rProperty, OLineDescriptor& _rDescriptor ) SAL_THROW((Exception))
1160cdf0e10cSrcweir     {
1161cdf0e10cSrcweir         try
1162cdf0e10cSrcweir         {
1163cdf0e10cSrcweir             PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rProperty.Name );
1164cdf0e10cSrcweir             if ( handler == m_aPropertyHandlers.end() )
1165cdf0e10cSrcweir                 throw RuntimeException();   // caught below
1166cdf0e10cSrcweir 
1167cdf0e10cSrcweir             _rDescriptor.assignFrom( handler->second->describePropertyLine( _rProperty.Name, this ) );
1168cdf0e10cSrcweir 
1169cdf0e10cSrcweir 		    //////////////////////////////////////////////////////////////////////
1170cdf0e10cSrcweir 
1171cdf0e10cSrcweir             _rDescriptor.xPropertyHandler = handler->second;
1172cdf0e10cSrcweir 		    _rDescriptor.sName = _rProperty.Name;
1173cdf0e10cSrcweir             _rDescriptor.aValue = _rDescriptor.xPropertyHandler->getPropertyValue( _rProperty.Name );
1174cdf0e10cSrcweir 
1175cdf0e10cSrcweir             if ( !_rDescriptor.DisplayName.getLength() )
1176cdf0e10cSrcweir             {
1177cdf0e10cSrcweir             #ifdef DBG_UTIL
1178cdf0e10cSrcweir                 ::rtl::OString sMessage( "OPropertyBrowserController::describePropertyLine: handler did not provide a display name for '" );
1179cdf0e10cSrcweir                 sMessage += ::rtl::OString( _rProperty.Name.getStr(), _rProperty.Name.getLength(), RTL_TEXTENCODING_ASCII_US );
1180cdf0e10cSrcweir                 sMessage += ::rtl::OString( "'!" );
1181cdf0e10cSrcweir                 DBG_ASSERT( _rDescriptor.DisplayName.getLength(), sMessage );
1182cdf0e10cSrcweir             #endif
1183cdf0e10cSrcweir 		        _rDescriptor.DisplayName = _rProperty.Name;
1184cdf0e10cSrcweir             }
1185cdf0e10cSrcweir 
1186cdf0e10cSrcweir             PropertyState   ePropertyState( _rDescriptor.xPropertyHandler->getPropertyState( _rProperty.Name ) );
1187cdf0e10cSrcweir 		    if ( PropertyState_AMBIGUOUS_VALUE == ePropertyState )
1188cdf0e10cSrcweir 		    {
1189cdf0e10cSrcweir 			    _rDescriptor.bUnknownValue = true;
1190cdf0e10cSrcweir 			    _rDescriptor.aValue.clear();
1191cdf0e10cSrcweir 		    }
1192cdf0e10cSrcweir 
1193cdf0e10cSrcweir             _rDescriptor.bReadOnly = impl_isReadOnlyModel_throw();
1194cdf0e10cSrcweir         }
1195cdf0e10cSrcweir         catch( const Exception& )
1196cdf0e10cSrcweir         {
1197cdf0e10cSrcweir             OSL_ENSURE( sal_False, "OPropertyBrowserController::describePropertyLine: caught an exception!" );
1198cdf0e10cSrcweir         }
1199cdf0e10cSrcweir     }
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir 	//------------------------------------------------------------------------
1202cdf0e10cSrcweir     void OPropertyBrowserController::impl_buildCategories_throw()
1203cdf0e10cSrcweir     {
1204cdf0e10cSrcweir         OSL_PRECOND( m_aPageIds.empty(), "OPropertyBrowserController::impl_buildCategories_throw: duplicate call!" );
1205cdf0e10cSrcweir 
1206cdf0e10cSrcweir         StlSyntaxSequence< PropertyCategoryDescriptor > aCategories;
1207cdf0e10cSrcweir         if ( m_xModel.is() )
1208cdf0e10cSrcweir             aCategories = m_xModel->describeCategories();
1209cdf0e10cSrcweir 
1210cdf0e10cSrcweir         for (   StlSyntaxSequence< PropertyCategoryDescriptor >::const_iterator category = aCategories.begin();
1211cdf0e10cSrcweir                 category != aCategories.end();
1212cdf0e10cSrcweir                 ++category
1213cdf0e10cSrcweir             )
1214cdf0e10cSrcweir         {
1215cdf0e10cSrcweir             OSL_ENSURE( m_aPageIds.find( category->ProgrammaticName ) == m_aPageIds.end(),
1216cdf0e10cSrcweir                 "OPropertyBrowserController::impl_buildCategories_throw: duplicate programmatic name!" );
1217cdf0e10cSrcweir 
1218cdf0e10cSrcweir             m_aPageIds[ category->ProgrammaticName ] =
1219cdf0e10cSrcweir                 getPropertyBox().AppendPage( category->UIName, HelpIdUrl::getHelpId( category->HelpURL ) );
1220cdf0e10cSrcweir         }
1221cdf0e10cSrcweir     }
1222cdf0e10cSrcweir 
1223cdf0e10cSrcweir 	//------------------------------------------------------------------------
1224cdf0e10cSrcweir 	void OPropertyBrowserController::UpdateUI()
1225cdf0e10cSrcweir 	{
1226cdf0e10cSrcweir 		try
1227cdf0e10cSrcweir 		{
1228cdf0e10cSrcweir             if ( !haveView() )
1229cdf0e10cSrcweir                 // too early, will return later
1230cdf0e10cSrcweir                 return;
1231cdf0e10cSrcweir 
1232cdf0e10cSrcweir 			getPropertyBox().DisableUpdate();
1233cdf0e10cSrcweir 
1234cdf0e10cSrcweir 			sal_Bool bHaveFocus = getPropertyBox().HasChildPathFocus();
1235cdf0e10cSrcweir 
1236cdf0e10cSrcweir             // create our tab pages
1237cdf0e10cSrcweir             impl_buildCategories_throw();
1238cdf0e10cSrcweir             // (and allow for pages to be actually unused)
1239cdf0e10cSrcweir             ::std::set< sal_uInt16 > aUsedPages;
1240cdf0e10cSrcweir 
1241cdf0e10cSrcweir             // when building the UI below, remember which properties are actuating,
1242cdf0e10cSrcweir             // to allow for a initial actuatinPropertyChanged call
1243cdf0e10cSrcweir             ::std::vector< ::rtl::OUString > aActuatingProperties;
1244cdf0e10cSrcweir             ::std::vector< Any > aActuatingPropertyValues;
1245cdf0e10cSrcweir 
1246cdf0e10cSrcweir             // ask the handlers to describe the property UI, and insert the resulting
1247cdf0e10cSrcweir             // entries into our list boxes
1248cdf0e10cSrcweir             OrderedPropertyMap::const_iterator property( m_aProperties.begin() );
1249cdf0e10cSrcweir             for ( ; property != m_aProperties.end(); ++property )
1250cdf0e10cSrcweir 			{
1251cdf0e10cSrcweir                 OLineDescriptor aDescriptor;
1252cdf0e10cSrcweir                 describePropertyLine( property->second, aDescriptor );
1253cdf0e10cSrcweir 
1254cdf0e10cSrcweir                 bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( property->second.Name );
1255cdf0e10cSrcweir 
1256cdf0e10cSrcweir             #if OSL_DEBUG_LEVEL > 0
1257cdf0e10cSrcweir                 if ( !aDescriptor.Category.getLength() )
1258cdf0e10cSrcweir                 {
1259cdf0e10cSrcweir                     ::rtl::OString sMessage( "OPropertyBrowserController::UpdateUI: empty category provided for property '" );
1260cdf0e10cSrcweir                     sMessage += ::rtl::OString( property->second.Name.getStr(), property->second.Name.getLength(), osl_getThreadTextEncoding() );
1261cdf0e10cSrcweir                     sMessage += "'!";
1262cdf0e10cSrcweir                     OSL_ENSURE( false, sMessage );
1263cdf0e10cSrcweir                 }
1264cdf0e10cSrcweir             #endif
1265cdf0e10cSrcweir                 // finally insert this property control
1266cdf0e10cSrcweir                 sal_uInt16 nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
1267cdf0e10cSrcweir                 if ( nTargetPageId == (sal_uInt16)-1 )
1268cdf0e10cSrcweir                 {
1269cdf0e10cSrcweir                     // this category does not yet exist. This is allowed, as an inspector model might be lazy, and not provide
1270cdf0e10cSrcweir                     // any category information of its own. In this case, we have a fallback ...
1271cdf0e10cSrcweir                     m_aPageIds[ aDescriptor.Category ] =
1272cdf0e10cSrcweir                     getPropertyBox().AppendPage( aDescriptor.Category, rtl::OString() );
1273cdf0e10cSrcweir                     nTargetPageId = impl_getPageIdForCategory_nothrow( aDescriptor.Category );
1274cdf0e10cSrcweir                 }
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir                 getPropertyBox().InsertEntry( aDescriptor, nTargetPageId );
1277cdf0e10cSrcweir                 aUsedPages.insert( nTargetPageId );
1278cdf0e10cSrcweir 
1279cdf0e10cSrcweir                 // if it's an actuating property, remember it
1280cdf0e10cSrcweir                 if ( bIsActuatingProperty )
1281cdf0e10cSrcweir                 {
1282cdf0e10cSrcweir                     aActuatingProperties.push_back( property->second.Name );
1283cdf0e10cSrcweir                     aActuatingPropertyValues.push_back( impl_getPropertyValue_throw( property->second.Name ) );
1284cdf0e10cSrcweir                 }
1285cdf0e10cSrcweir 			}
1286cdf0e10cSrcweir 
1287cdf0e10cSrcweir             // update any dependencies for the actuating properties which we encountered
1288cdf0e10cSrcweir             {
1289cdf0e10cSrcweir                 ::std::vector< ::rtl::OUString >::const_iterator aProperty = aActuatingProperties.begin();
1290cdf0e10cSrcweir                 ::std::vector< Any >::const_iterator aPropertyValue = aActuatingPropertyValues.begin();
1291cdf0e10cSrcweir                 for ( ; aProperty != aActuatingProperties.end(); ++aProperty, ++aPropertyValue )
1292cdf0e10cSrcweir                     impl_broadcastPropertyChange_nothrow( *aProperty, *aPropertyValue, *aPropertyValue, true );
1293cdf0e10cSrcweir             }
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir             // remove any unused pages (which we did not encounter properties for)
1296cdf0e10cSrcweir             HashString2Int16 aSurvivingPageIds;
1297cdf0e10cSrcweir             for (   HashString2Int16::iterator pageId = m_aPageIds.begin();
1298cdf0e10cSrcweir                     pageId != m_aPageIds.end();
1299cdf0e10cSrcweir                     ++pageId
1300cdf0e10cSrcweir                 )
1301cdf0e10cSrcweir             {
1302cdf0e10cSrcweir                 if ( aUsedPages.find( pageId->second ) == aUsedPages.end() )
1303cdf0e10cSrcweir                     getPropertyBox().RemovePage( pageId->second );
1304cdf0e10cSrcweir                 else
1305cdf0e10cSrcweir                     aSurvivingPageIds.insert( *pageId );
1306cdf0e10cSrcweir             }
1307cdf0e10cSrcweir             m_aPageIds.swap( aSurvivingPageIds );
1308cdf0e10cSrcweir 
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir             getPropertyBox().Show();
1311cdf0e10cSrcweir 			getPropertyBox().EnableUpdate();
1312cdf0e10cSrcweir 			if ( bHaveFocus )
1313cdf0e10cSrcweir 				getPropertyBox().GrabFocus();
1314cdf0e10cSrcweir 
1315cdf0e10cSrcweir 			// activate the first page
1316cdf0e10cSrcweir             if ( !m_aPageIds.empty() )
1317cdf0e10cSrcweir             {
1318cdf0e10cSrcweir                 Sequence< PropertyCategoryDescriptor > aCategories( m_xModel->describeCategories() );
1319cdf0e10cSrcweir                 if ( aCategories.getLength() )
1320cdf0e10cSrcweir 				    m_pView->activatePage( m_aPageIds[ aCategories[0].ProgrammaticName ] );
1321cdf0e10cSrcweir                 else
1322cdf0e10cSrcweir                     // allowed: if we default-created the pages ...
1323cdf0e10cSrcweir 				    m_pView->activatePage( m_aPageIds.begin()->second );
1324cdf0e10cSrcweir             }
1325cdf0e10cSrcweir 
1326cdf0e10cSrcweir             // activate the previously active page (if possible)
1327cdf0e10cSrcweir             if ( m_sLastValidPageSelection.getLength() )
1328cdf0e10cSrcweir                 m_sPageSelection = m_sLastValidPageSelection;
1329cdf0e10cSrcweir 			selectPageFromViewData();
1330cdf0e10cSrcweir 		}
1331cdf0e10cSrcweir         catch( const Exception& )
1332cdf0e10cSrcweir         {
1333cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1334cdf0e10cSrcweir         }
1335cdf0e10cSrcweir 	}
1336cdf0e10cSrcweir 
1337cdf0e10cSrcweir 	//------------------------------------------------------------------------
1338cdf0e10cSrcweir     void OPropertyBrowserController::Clicked( const ::rtl::OUString& _rName, sal_Bool _bPrimary )
1339cdf0e10cSrcweir 	{
1340cdf0e10cSrcweir 		try
1341cdf0e10cSrcweir 		{
1342cdf0e10cSrcweir             // since the browse buttons do not get the focus when clicked with the mouse,
1343cdf0e10cSrcweir             // we need to commit the changes in the current property field
1344cdf0e10cSrcweir             getPropertyBox().CommitModified();
1345cdf0e10cSrcweir 
1346cdf0e10cSrcweir             PropertyHandlerRepository::const_iterator handler = m_aPropertyHandlers.find( _rName );
1347cdf0e10cSrcweir             DBG_ASSERT( handler != m_aPropertyHandlers.end(), "OPropertyBrowserController::Clicked: a property without handler? This will crash!" );
1348cdf0e10cSrcweir 
1349cdf0e10cSrcweir             ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
1350cdf0e10cSrcweir 
1351cdf0e10cSrcweir             Any aData;
1352cdf0e10cSrcweir             m_xInteractiveHandler = handler->second;
1353cdf0e10cSrcweir             InteractiveSelectionResult eResult =
1354cdf0e10cSrcweir                 handler->second->onInteractivePropertySelection( _rName, _bPrimary, aData,
1355cdf0e10cSrcweir                     m_pUIRequestComposer->getUIForPropertyHandler( handler->second ) );
1356cdf0e10cSrcweir 
1357cdf0e10cSrcweir             switch ( eResult )
1358cdf0e10cSrcweir             {
1359cdf0e10cSrcweir             case InteractiveSelectionResult_Cancelled:
1360cdf0e10cSrcweir             case InteractiveSelectionResult_Success:
1361cdf0e10cSrcweir                 // okay, nothing to do
1362cdf0e10cSrcweir                 break;
1363cdf0e10cSrcweir             case InteractiveSelectionResult_ObtainedValue:
1364cdf0e10cSrcweir                 handler->second->setPropertyValue( _rName, aData );
1365cdf0e10cSrcweir                 break;
1366cdf0e10cSrcweir             case InteractiveSelectionResult_Pending:
1367cdf0e10cSrcweir                 // also okay, we expect that the handler has disabled the UI as necessary
1368cdf0e10cSrcweir                 break;
1369cdf0e10cSrcweir             default:
1370cdf0e10cSrcweir                 OSL_ENSURE( false, "OPropertyBrowserController::Clicked: unknown result value!" );
1371cdf0e10cSrcweir                 break;
1372cdf0e10cSrcweir             }
1373cdf0e10cSrcweir 		}
1374cdf0e10cSrcweir 		catch (Exception&)
1375cdf0e10cSrcweir 		{
1376cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1377cdf0e10cSrcweir 		}
1378cdf0e10cSrcweir         m_xInteractiveHandler = NULL;
1379cdf0e10cSrcweir 	}
1380cdf0e10cSrcweir 
1381cdf0e10cSrcweir 	//------------------------------------------------------------------------
1382cdf0e10cSrcweir     sal_Bool SAL_CALL OPropertyBrowserController::hasPropertyByName( const ::rtl::OUString& _rName ) throw (RuntimeException)
1383cdf0e10cSrcweir     {
1384cdf0e10cSrcweir         for (   OrderedPropertyMap::const_iterator search = m_aProperties.begin();
1385cdf0e10cSrcweir                 search != m_aProperties.end();
1386cdf0e10cSrcweir                 ++search
1387cdf0e10cSrcweir             )
1388cdf0e10cSrcweir             if ( search->second.Name == _rName )
1389cdf0e10cSrcweir                 return true;
1390cdf0e10cSrcweir         return false;
1391cdf0e10cSrcweir     }
1392cdf0e10cSrcweir 
1393cdf0e10cSrcweir 	//------------------------------------------------------------------------
1394cdf0e10cSrcweir     void OPropertyBrowserController::Commit( const ::rtl::OUString& rName, const Any& _rValue )
1395cdf0e10cSrcweir 	{
1396cdf0e10cSrcweir 		try
1397cdf0e10cSrcweir 		{
1398cdf0e10cSrcweir             rtl::OUString sPlcHolder = String( PcrRes( RID_EMBED_IMAGE_PLACEHOLDER ) );
1399cdf0e10cSrcweir             bool bIsPlaceHolderValue = false;
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir             if ( rName.equals( PROPERTY_IMAGE_URL ) )
1402cdf0e10cSrcweir             {
1403cdf0e10cSrcweir                 // if the prop value is the PlaceHolder
1404cdf0e10cSrcweir                 // can ignore it
1405cdf0e10cSrcweir                 rtl::OUString sVal;
1406cdf0e10cSrcweir                 _rValue >>= sVal;
1407cdf0e10cSrcweir                 if ( sVal.equals( sPlcHolder ) )
1408cdf0e10cSrcweir                     bIsPlaceHolderValue = true;
1409cdf0e10cSrcweir             }
1410cdf0e10cSrcweir             m_sCommittingProperty = rName;
1411cdf0e10cSrcweir 
1412cdf0e10cSrcweir             bool bIsActuatingProperty = impl_isActuatingProperty_nothrow( rName );
1413cdf0e10cSrcweir 
1414cdf0e10cSrcweir             Any aOldValue;
1415cdf0e10cSrcweir             if ( bIsActuatingProperty )
1416cdf0e10cSrcweir                 aOldValue = impl_getPropertyValue_throw( rName );
1417cdf0e10cSrcweir 
1418cdf0e10cSrcweir             // do we have a dedicated handler for this property, which we can delegate some tasks to?
1419cdf0e10cSrcweir             PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
1420cdf0e10cSrcweir 
1421cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////////////
1422cdf0e10cSrcweir 			// set the value ( only if it's not a placeholder )
1423cdf0e10cSrcweir             if ( !bIsPlaceHolderValue )
1424cdf0e10cSrcweir                 handler->setPropertyValue( rName, _rValue );
1425cdf0e10cSrcweir 
1426cdf0e10cSrcweir 			//////////////////////////////////////////////////////////////////////
1427cdf0e10cSrcweir             // re-retrieve the value
1428cdf0e10cSrcweir             Any aNormalizedValue = handler->getPropertyValue( rName );
1429cdf0e10cSrcweir 
1430cdf0e10cSrcweir             // care for any inter-property dependencies
1431cdf0e10cSrcweir             if ( bIsActuatingProperty )
1432cdf0e10cSrcweir                 impl_broadcastPropertyChange_nothrow( rName, aNormalizedValue, aOldValue, false );
1433cdf0e10cSrcweir 
1434cdf0e10cSrcweir             // and display it again. This ensures proper formatting
1435cdf0e10cSrcweir 			getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
1436cdf0e10cSrcweir 		}
1437cdf0e10cSrcweir 		catch(PropertyVetoException& eVetoException)
1438cdf0e10cSrcweir 		{
1439cdf0e10cSrcweir 			InfoBox(m_pView, eVetoException.Message).Execute();
1440cdf0e10cSrcweir             PropertyHandlerRef handler = impl_getHandlerForProperty_throw( rName );
1441cdf0e10cSrcweir             Any aNormalizedValue = handler->getPropertyValue( rName );
1442cdf0e10cSrcweir             getPropertyBox().SetPropertyValue( rName, aNormalizedValue, false );
1443cdf0e10cSrcweir 		}
1444cdf0e10cSrcweir 		catch(Exception&)
1445cdf0e10cSrcweir 		{
1446cdf0e10cSrcweir 			DBG_ERROR("OPropertyBrowserController::Commit : caught an exception !");
1447cdf0e10cSrcweir 		}
1448cdf0e10cSrcweir 
1449cdf0e10cSrcweir         m_sCommittingProperty = ::rtl::OUString();
1450cdf0e10cSrcweir     }
1451cdf0e10cSrcweir 
1452cdf0e10cSrcweir     //--------------------------------------------------------------------
1453cdf0e10cSrcweir     namespace
1454cdf0e10cSrcweir     {
1455cdf0e10cSrcweir     }
1456cdf0e10cSrcweir 
1457cdf0e10cSrcweir     //--------------------------------------------------------------------
1458cdf0e10cSrcweir     void OPropertyBrowserController::focusGained( const Reference< XPropertyControl >& _Control )
1459cdf0e10cSrcweir     {
1460cdf0e10cSrcweir         m_aControlObservers.notifyEach( &XPropertyControlObserver::focusGained, _Control );
1461cdf0e10cSrcweir     }
1462cdf0e10cSrcweir 
1463cdf0e10cSrcweir     //--------------------------------------------------------------------
1464cdf0e10cSrcweir     void OPropertyBrowserController::valueChanged( const Reference< XPropertyControl >& _Control )
1465cdf0e10cSrcweir     {
1466cdf0e10cSrcweir         m_aControlObservers.notifyEach( &XPropertyControlObserver::valueChanged, _Control );
1467cdf0e10cSrcweir     }
1468cdf0e10cSrcweir 
1469cdf0e10cSrcweir 	//------------------------------------------------------------------------
1470cdf0e10cSrcweir     namespace
1471cdf0e10cSrcweir     {
1472cdf0e10cSrcweir         Reference< XPropertyHandler > lcl_createHandler( const ComponentContext& _rContext, const Any& _rFactoryDescriptor )
1473cdf0e10cSrcweir         {
1474cdf0e10cSrcweir             Reference< XPropertyHandler > xHandler;
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir             ::rtl::OUString sServiceName;
1477cdf0e10cSrcweir             Reference< XSingleServiceFactory > xServiceFac;
1478cdf0e10cSrcweir             Reference< XSingleComponentFactory > xComponentFac;
1479cdf0e10cSrcweir 
1480cdf0e10cSrcweir             if ( _rFactoryDescriptor >>= sServiceName )
1481cdf0e10cSrcweir                 _rContext.createComponent( sServiceName, xHandler );
1482cdf0e10cSrcweir             else if ( _rFactoryDescriptor >>= xServiceFac )
1483cdf0e10cSrcweir                 xHandler = xHandler.query( xServiceFac->createInstance() );
1484cdf0e10cSrcweir             else if ( _rFactoryDescriptor >>= xComponentFac )
1485cdf0e10cSrcweir                 xHandler = xHandler.query( xComponentFac->createInstanceWithContext( _rContext.getUNOContext() ) );
1486cdf0e10cSrcweir             OSL_ENSURE(xHandler.is(),"lcl_createHandler: Can not create handler");
1487cdf0e10cSrcweir             return xHandler;
1488cdf0e10cSrcweir         }
1489cdf0e10cSrcweir     }
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir 	//------------------------------------------------------------------------
1492cdf0e10cSrcweir     void OPropertyBrowserController::getPropertyHandlers( const InterfaceArray& _rObjects, PropertyHandlerArray& _rHandlers )
1493cdf0e10cSrcweir     {
1494cdf0e10cSrcweir         _rHandlers.resize( 0 );
1495cdf0e10cSrcweir         if ( _rObjects.empty() )
1496cdf0e10cSrcweir             return;
1497cdf0e10cSrcweir 
1498cdf0e10cSrcweir         // create a component context for the handlers, containing some information about where
1499cdf0e10cSrcweir         // they live
1500cdf0e10cSrcweir         Reference< XComponentContext > xHandlerContext( m_aContext.getUNOContext() );
1501cdf0e10cSrcweir 
1502cdf0e10cSrcweir         // if our own creator did not pass a dialog parent window, use our own view for this
1503cdf0e10cSrcweir         Reference< XWindow > xParentWindow( m_aContext.getContextValueByAsciiName( "DialogParentWindow" ), UNO_QUERY );
1504cdf0e10cSrcweir         if ( !xParentWindow.is() )
1505cdf0e10cSrcweir         {
1506cdf0e10cSrcweir             ::cppu::ContextEntry_Init aHandlerContextInfo[] =
1507cdf0e10cSrcweir             {
1508cdf0e10cSrcweir                 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( VCLUnoHelper::GetInterface( m_pView ) ) )
1509cdf0e10cSrcweir             };
1510cdf0e10cSrcweir             xHandlerContext = ::cppu::createComponentContext(
1511cdf0e10cSrcweir                 aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
1512cdf0e10cSrcweir                 m_aContext.getUNOContext() );
1513cdf0e10cSrcweir         }
1514cdf0e10cSrcweir 
1515cdf0e10cSrcweir         Sequence< Any > aHandlerFactories;
1516cdf0e10cSrcweir         if ( m_xModel.is() )
1517cdf0e10cSrcweir             aHandlerFactories = m_xModel->getHandlerFactories();
1518cdf0e10cSrcweir 
1519cdf0e10cSrcweir         const Any* pHandlerFactory = aHandlerFactories.getConstArray();
1520cdf0e10cSrcweir         const Any* pHandlerFactoryEnd = aHandlerFactories.getConstArray() + aHandlerFactories.getLength();
1521cdf0e10cSrcweir 
1522cdf0e10cSrcweir         while ( pHandlerFactory != pHandlerFactoryEnd )
1523cdf0e10cSrcweir         {
1524cdf0e10cSrcweir             if ( _rObjects.size() == 1 )
1525cdf0e10cSrcweir             {   // we're inspecting only one object -> one handler
1526cdf0e10cSrcweir                 Reference< XPropertyHandler > xHandler( lcl_createHandler( m_aContext, *pHandlerFactory ) );
1527cdf0e10cSrcweir                 if ( xHandler.is() )
1528cdf0e10cSrcweir                 {
1529cdf0e10cSrcweir                     xHandler->inspect( _rObjects[0] );
1530cdf0e10cSrcweir                     _rHandlers.push_back( xHandler );
1531cdf0e10cSrcweir                 }
1532cdf0e10cSrcweir             }
1533cdf0e10cSrcweir             else
1534cdf0e10cSrcweir             {
1535cdf0e10cSrcweir                 // create a single handler for every single object
1536cdf0e10cSrcweir                 ::std::vector< Reference< XPropertyHandler > > aSingleHandlers( _rObjects.size() );
1537cdf0e10cSrcweir                 ::std::vector< Reference< XPropertyHandler > >::iterator pHandler = aSingleHandlers.begin();
1538cdf0e10cSrcweir 
1539cdf0e10cSrcweir                 InterfaceArray::const_iterator pObject = _rObjects.begin();
1540cdf0e10cSrcweir                 InterfaceArray::const_iterator pObjectEnd = _rObjects.end();
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir                 for ( ; pObject != pObjectEnd; ++pObject )
1543cdf0e10cSrcweir                 {
1544cdf0e10cSrcweir                     *pHandler = lcl_createHandler( m_aContext, *pHandlerFactory );
1545cdf0e10cSrcweir                     if ( pHandler->is() )
1546cdf0e10cSrcweir                     {
1547cdf0e10cSrcweir                         (*pHandler)->inspect( *pObject );
1548cdf0e10cSrcweir                         ++pHandler;
1549cdf0e10cSrcweir                     }
1550cdf0e10cSrcweir                 }
1551cdf0e10cSrcweir                 aSingleHandlers.resize( pHandler - aSingleHandlers.begin() );
1552cdf0e10cSrcweir 
1553cdf0e10cSrcweir                 // then create a handler which composes information out of those single handlers
1554cdf0e10cSrcweir                 if ( !aSingleHandlers.empty() )
1555cdf0e10cSrcweir                     _rHandlers.push_back( new PropertyComposer( aSingleHandlers ) );
1556cdf0e10cSrcweir             }
1557cdf0e10cSrcweir 
1558cdf0e10cSrcweir             ++pHandlerFactory;
1559cdf0e10cSrcweir         }
1560cdf0e10cSrcweir 
1561cdf0e10cSrcweir         // note that the handlers will not be used by our caller, if they indicate that there are no
1562cdf0e10cSrcweir         // properties they feel responsible for
1563cdf0e10cSrcweir     }
1564cdf0e10cSrcweir 
1565cdf0e10cSrcweir     //------------------------------------------------------------------------
1566cdf0e10cSrcweir     bool OPropertyBrowserController::impl_findObjectProperty_nothrow( const ::rtl::OUString& _rName, OrderedPropertyMap::const_iterator* _pProperty )
1567cdf0e10cSrcweir     {
1568cdf0e10cSrcweir         OrderedPropertyMap::const_iterator search = m_aProperties.begin();
1569cdf0e10cSrcweir         for ( ; search != m_aProperties.end(); ++search )
1570cdf0e10cSrcweir             if ( search->second.Name == _rName )
1571cdf0e10cSrcweir                 break;
1572cdf0e10cSrcweir         if ( _pProperty )
1573cdf0e10cSrcweir             *_pProperty = search;
1574cdf0e10cSrcweir         return ( search != m_aProperties.end() );
1575cdf0e10cSrcweir     }
1576cdf0e10cSrcweir 
1577cdf0e10cSrcweir 	//------------------------------------------------------------------------
1578cdf0e10cSrcweir     void OPropertyBrowserController::rebuildPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
1579cdf0e10cSrcweir     {
1580cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1581cdf0e10cSrcweir         if ( !haveView() )
1582cdf0e10cSrcweir             throw RuntimeException();
1583cdf0e10cSrcweir 
1584cdf0e10cSrcweir         OrderedPropertyMap::const_iterator propertyPos;
1585cdf0e10cSrcweir         if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
1586cdf0e10cSrcweir             return;
1587cdf0e10cSrcweir 
1588cdf0e10cSrcweir         OLineDescriptor aDescriptor;
1589cdf0e10cSrcweir         try
1590cdf0e10cSrcweir         {
1591cdf0e10cSrcweir             describePropertyLine( propertyPos->second, aDescriptor );
1592cdf0e10cSrcweir         }
1593cdf0e10cSrcweir         catch( const Exception& )
1594cdf0e10cSrcweir         {
1595cdf0e10cSrcweir         	OSL_ENSURE( sal_False, "OPropertyBrowserController::rebuildPropertyUI: caught an exception!" );
1596cdf0e10cSrcweir         }
1597cdf0e10cSrcweir 
1598cdf0e10cSrcweir         getPropertyBox().ChangeEntry( aDescriptor );
1599cdf0e10cSrcweir    }
1600cdf0e10cSrcweir 
1601cdf0e10cSrcweir 	//------------------------------------------------------------------------
1602cdf0e10cSrcweir     void OPropertyBrowserController::enablePropertyUI( const ::rtl::OUString& _rPropertyName, sal_Bool _bEnable ) throw (RuntimeException)
1603cdf0e10cSrcweir     {
1604cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1605cdf0e10cSrcweir         if ( !haveView() )
1606cdf0e10cSrcweir             throw RuntimeException();
1607cdf0e10cSrcweir 
1608cdf0e10cSrcweir         if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
1609cdf0e10cSrcweir             return;
1610cdf0e10cSrcweir 
1611cdf0e10cSrcweir         getPropertyBox().EnablePropertyLine( _rPropertyName, _bEnable );
1612cdf0e10cSrcweir     }
1613cdf0e10cSrcweir 
1614cdf0e10cSrcweir 	//------------------------------------------------------------------------
1615cdf0e10cSrcweir     void OPropertyBrowserController::enablePropertyUIElements( const ::rtl::OUString& _rPropertyName, sal_Int16 _nElements, sal_Bool _bEnable ) throw (RuntimeException)
1616cdf0e10cSrcweir     {
1617cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1618cdf0e10cSrcweir         if ( !haveView() )
1619cdf0e10cSrcweir             throw RuntimeException();
1620cdf0e10cSrcweir 
1621cdf0e10cSrcweir         if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
1622cdf0e10cSrcweir             return;
1623cdf0e10cSrcweir 
1624cdf0e10cSrcweir         getPropertyBox().EnablePropertyControls( _rPropertyName, _nElements, _bEnable );
1625cdf0e10cSrcweir     }
1626cdf0e10cSrcweir 
1627cdf0e10cSrcweir 	//------------------------------------------------------------------------
1628cdf0e10cSrcweir     void OPropertyBrowserController::showPropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
1629cdf0e10cSrcweir     {
1630cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1631cdf0e10cSrcweir         if ( !haveView() )
1632cdf0e10cSrcweir             throw RuntimeException();
1633cdf0e10cSrcweir 
1634cdf0e10cSrcweir         // look up the property in our object properties
1635cdf0e10cSrcweir         OrderedPropertyMap::const_iterator propertyPos;
1636cdf0e10cSrcweir         if ( !impl_findObjectProperty_nothrow( _rPropertyName, &propertyPos ) )
1637cdf0e10cSrcweir             return;
1638cdf0e10cSrcweir 
1639cdf0e10cSrcweir         if ( getPropertyBox().GetPropertyPos( _rPropertyName ) != LISTBOX_ENTRY_NOTFOUND )
1640cdf0e10cSrcweir         {
1641cdf0e10cSrcweir             rebuildPropertyUI( _rPropertyName );
1642cdf0e10cSrcweir             return;
1643cdf0e10cSrcweir         }
1644cdf0e10cSrcweir 
1645cdf0e10cSrcweir         OLineDescriptor aDescriptor;
1646cdf0e10cSrcweir         describePropertyLine( propertyPos->second, aDescriptor );
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir         // look for the position to insert the property
1649cdf0e10cSrcweir 
1650cdf0e10cSrcweir         // side note: The methods GetPropertyPos and InsertEntry of the OPropertyEditor work
1651cdf0e10cSrcweir         // only on the current page. This implies that it's impossible to use this method here
1652cdf0e10cSrcweir         // to show property lines which are *not* on the current page.
1653cdf0e10cSrcweir         // This is sufficient for now, but should be changed in the future.
1654cdf0e10cSrcweir 
1655cdf0e10cSrcweir         // by definition, the properties in m_aProperties are in the order in which they appear in the UI
1656cdf0e10cSrcweir         // So all we need is a predecessor of pProperty in m_aProperties
1657cdf0e10cSrcweir         sal_uInt16 nUIPos = LISTBOX_ENTRY_NOTFOUND;
1658cdf0e10cSrcweir         do
1659cdf0e10cSrcweir         {
1660cdf0e10cSrcweir             if ( propertyPos != m_aProperties.begin() )
1661cdf0e10cSrcweir                 --propertyPos;
1662cdf0e10cSrcweir             nUIPos = getPropertyBox().GetPropertyPos( propertyPos->second.Name );
1663cdf0e10cSrcweir         }
1664cdf0e10cSrcweir         while ( ( nUIPos == LISTBOX_ENTRY_NOTFOUND ) && ( propertyPos != m_aProperties.begin() ) );
1665cdf0e10cSrcweir 
1666cdf0e10cSrcweir         if ( nUIPos == LISTBOX_ENTRY_NOTFOUND )
1667cdf0e10cSrcweir             // insert at the very top
1668cdf0e10cSrcweir             nUIPos = 0;
1669cdf0e10cSrcweir         else
1670cdf0e10cSrcweir             // insert right after the predecessor we found
1671cdf0e10cSrcweir             ++nUIPos;
1672cdf0e10cSrcweir 
1673cdf0e10cSrcweir         getPropertyBox().InsertEntry(
1674cdf0e10cSrcweir             aDescriptor, impl_getPageIdForCategory_nothrow( aDescriptor.Category ), nUIPos );
1675cdf0e10cSrcweir     }
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir 	//------------------------------------------------------------------------
1678cdf0e10cSrcweir     void OPropertyBrowserController::hidePropertyUI( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
1679cdf0e10cSrcweir     {
1680cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1681cdf0e10cSrcweir         if ( !haveView() )
1682cdf0e10cSrcweir             throw RuntimeException();
1683cdf0e10cSrcweir 
1684cdf0e10cSrcweir         if ( !impl_findObjectProperty_nothrow( _rPropertyName ) )
1685cdf0e10cSrcweir             return;
1686cdf0e10cSrcweir 
1687cdf0e10cSrcweir         getPropertyBox().RemoveEntry( _rPropertyName );
1688cdf0e10cSrcweir     }
1689cdf0e10cSrcweir 
1690cdf0e10cSrcweir 	//------------------------------------------------------------------------
1691cdf0e10cSrcweir     void OPropertyBrowserController::showCategory( const ::rtl::OUString& _rCategory, sal_Bool _bShow ) throw (RuntimeException)
1692cdf0e10cSrcweir     {
1693cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1694cdf0e10cSrcweir         if ( !haveView() )
1695cdf0e10cSrcweir             throw RuntimeException();
1696cdf0e10cSrcweir 
1697cdf0e10cSrcweir         sal_uInt16 nPageId = impl_getPageIdForCategory_nothrow( _rCategory );
1698cdf0e10cSrcweir         OSL_ENSURE( nPageId != (sal_uInt16)-1, "OPropertyBrowserController::showCategory: invalid category!" );
1699cdf0e10cSrcweir 
1700cdf0e10cSrcweir         getPropertyBox().ShowPropertyPage( nPageId, _bShow );
1701cdf0e10cSrcweir     }
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 	//------------------------------------------------------------------------
1704cdf0e10cSrcweir     Reference< XPropertyControl > SAL_CALL OPropertyBrowserController::getPropertyControl( const ::rtl::OUString& _rPropertyName ) throw (RuntimeException)
1705cdf0e10cSrcweir     {
1706cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1707cdf0e10cSrcweir         if ( !haveView() )
1708cdf0e10cSrcweir             throw RuntimeException();
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir         Reference< XPropertyControl > xControl( getPropertyBox().GetPropertyControl( _rPropertyName ) );
1711cdf0e10cSrcweir         return xControl;
1712cdf0e10cSrcweir     }
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir     //--------------------------------------------------------------------
1715cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::registerControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
1716cdf0e10cSrcweir     {
1717cdf0e10cSrcweir         m_aControlObservers.addInterface( _Observer );
1718cdf0e10cSrcweir     }
1719cdf0e10cSrcweir 
1720cdf0e10cSrcweir     //--------------------------------------------------------------------
1721cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::revokeControlObserver( const Reference< XPropertyControlObserver >& _Observer ) throw (RuntimeException)
1722cdf0e10cSrcweir     {
1723cdf0e10cSrcweir         m_aControlObservers.removeInterface( _Observer );
1724cdf0e10cSrcweir     }
1725cdf0e10cSrcweir 
1726cdf0e10cSrcweir 	//------------------------------------------------------------------------
1727cdf0e10cSrcweir     void SAL_CALL OPropertyBrowserController::setHelpSectionText( const ::rtl::OUString& _rHelpText ) throw (NoSupportException, RuntimeException)
1728cdf0e10cSrcweir     {
1729cdf0e10cSrcweir         ::vos::OGuard aSolarGuard( Application::GetSolarMutex() );
1730cdf0e10cSrcweir         ::osl::MutexGuard aGuard( m_aMutex );
1731cdf0e10cSrcweir 
1732cdf0e10cSrcweir         if ( !haveView() )
1733cdf0e10cSrcweir             throw DisposedException();
1734cdf0e10cSrcweir 
1735cdf0e10cSrcweir         if ( !getPropertyBox().HasHelpSection() )
1736cdf0e10cSrcweir             throw NoSupportException();
1737cdf0e10cSrcweir 
1738cdf0e10cSrcweir         getPropertyBox().SetHelpText( _rHelpText );
1739cdf0e10cSrcweir     }
1740cdf0e10cSrcweir 
1741cdf0e10cSrcweir 	//------------------------------------------------------------------------
1742cdf0e10cSrcweir     void OPropertyBrowserController::impl_broadcastPropertyChange_nothrow( const ::rtl::OUString& _rPropertyName, const Any& _rNewValue, const Any& _rOldValue, bool _bFirstTimeInit ) const
1743cdf0e10cSrcweir     {
1744cdf0e10cSrcweir         // are there one or more handlers which are interested in the actuation?
1745cdf0e10cSrcweir         ::std::pair< PropertyHandlerMultiRepository::const_iterator, PropertyHandlerMultiRepository::const_iterator > aInterestedHandlers =
1746cdf0e10cSrcweir             m_aDependencyHandlers.equal_range( _rPropertyName );
1747cdf0e10cSrcweir         if ( aInterestedHandlers.first == aInterestedHandlers.second )
1748cdf0e10cSrcweir             // none of our handlers is interested in this
1749cdf0e10cSrcweir             return;
1750cdf0e10cSrcweir 
1751cdf0e10cSrcweir         ComposedUIAutoFireGuard aAutoFireGuard( *m_pUIRequestComposer );
1752cdf0e10cSrcweir         try
1753cdf0e10cSrcweir         {
1754cdf0e10cSrcweir             // collect the responses from all interested handlers
1755cdf0e10cSrcweir             PropertyHandlerMultiRepository::const_iterator handler = aInterestedHandlers.first;
1756cdf0e10cSrcweir             while ( handler != aInterestedHandlers.second )
1757cdf0e10cSrcweir             {
1758cdf0e10cSrcweir                 handler->second->actuatingPropertyChanged( _rPropertyName, _rNewValue, _rOldValue,
1759cdf0e10cSrcweir                     m_pUIRequestComposer->getUIForPropertyHandler( handler->second ),
1760cdf0e10cSrcweir                     _bFirstTimeInit );
1761cdf0e10cSrcweir                 ++handler;
1762cdf0e10cSrcweir             }
1763cdf0e10cSrcweir         }
1764cdf0e10cSrcweir         catch( const Exception& )
1765cdf0e10cSrcweir         {
1766cdf0e10cSrcweir             DBG_UNHANDLED_EXCEPTION();
1767cdf0e10cSrcweir         }
1768cdf0e10cSrcweir     }
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir //............................................................................
1771cdf0e10cSrcweir } // namespace pcr
1772cdf0e10cSrcweir //............................................................................
1773cdf0e10cSrcweir 
1774cdf0e10cSrcweir 
1775