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