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