bump product version to 4.1.6.2
[LibreOffice.git] / svx / source / form / fmPropBrw.cxx
blobe62eb9776fb3b6d66636ae29e1166196d1a79b07
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <sal/macros.h>
23 #include "fmhelp.hrc"
24 #include "fmprop.hrc"
25 #include "fmPropBrw.hxx"
26 #include "svx/fmresids.hrc"
27 #include "fmservs.hxx"
28 #include "fmshimp.hxx"
29 #include "fmpgeimp.hxx"
31 #include "svx/dialmgr.hxx"
32 #include "svx/fmpage.hxx"
33 #include "svx/fmshell.hxx"
34 #include "svx/sdrpagewindow.hxx"
35 #include "svx/svdpagv.hxx"
36 #include "svx/svxids.hrc"
38 #include <com/sun/star/awt/XLayoutConstrains.hpp>
39 #include <com/sun/star/awt/XControlContainer.hpp>
40 #include <com/sun/star/awt/PosSize.hpp>
41 #include <com/sun/star/beans/PropertyValue.hpp>
42 #include <com/sun/star/container/XChild.hpp>
43 #include <com/sun/star/form/XForm.hpp>
44 #include <com/sun/star/form/FormComponentType.hpp>
45 #include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp>
46 #include <com/sun/star/frame/Frame.hpp>
47 #include <com/sun/star/inspection/ObjectInspector.hpp>
48 #include <com/sun/star/inspection/ObjectInspectorModel.hpp>
49 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
50 #include <com/sun/star/inspection/DefaultHelpProvider.hpp>
52 #include <comphelper/processfactory.hxx>
53 #include <comphelper/property.hxx>
54 #include <cppuhelper/component_context.hxx>
55 #include <sfx2/bindings.hxx>
56 #include <sfx2/childwin.hxx>
57 #include <sfx2/dispatch.hxx>
58 #include <sfx2/objitem.hxx>
59 #include <sfx2/objsh.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <toolkit/unohlp.hxx>
62 #include <tools/debug.hxx>
63 #include <tools/diagnose_ex.h>
64 #include <tools/shl.hxx>
65 #include <unotools/confignode.hxx>
66 #include <vcl/stdtext.hxx>
68 #include <algorithm>
70 using namespace ::com::sun::star;
71 using namespace ::com::sun::star::uno;
72 using namespace ::com::sun::star::util;
73 using namespace ::com::sun::star::inspection;
74 using namespace ::com::sun::star::form::inspection;
75 using ::com::sun::star::awt::XWindow;
77 /*************************************************************************/
78 //========================================================================
79 //= FmPropBrwMgr
80 //========================================================================
81 //-----------------------------------------------------------------------
82 SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES)
84 //-----------------------------------------------------------------------
85 FmPropBrwMgr::FmPropBrwMgr( Window* _pParent, sal_uInt16 _nId,
86 SfxBindings* _pBindings, SfxChildWinInfo* _pInfo)
87 :SfxChildWindow(_pParent, _nId)
89 pWindow = new FmPropBrw( ::comphelper::getProcessComponentContext(), _pBindings, this, _pParent, _pInfo );
90 eChildAlignment = SFX_ALIGN_NOALIGNMENT;
91 ((SfxFloatingWindow*)pWindow)->Initialize( _pInfo );
94 //========================================================================
95 //========================================================================
96 const long STD_WIN_SIZE_X = 300;
97 const long STD_WIN_SIZE_Y = 350;
99 const long STD_MIN_SIZE_X = 250;
100 const long STD_MIN_SIZE_Y = 250;
102 using namespace ::com::sun::star::uno;
103 using namespace ::com::sun::star::lang;
104 using namespace ::com::sun::star::form;
105 using namespace ::com::sun::star::frame;
106 using namespace ::com::sun::star::beans;
107 using namespace ::com::sun::star::container;
108 using namespace ::svxform;
110 OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
112 sal_uInt16 nClassNameResourceId = 0;
114 switch ( nClassId )
116 case FormComponentType::TEXTFIELD:
118 Reference< XInterface > xIFace;
119 aUnoObj >>= xIFace;
120 nClassNameResourceId = RID_STR_PROPTITLE_EDIT;
121 if (xIFace.is())
122 { // we have a chance to check if it's a formatted field model
123 Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY);
124 if (xInfo.is() && (xInfo->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD)))
125 nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
126 else if (!xInfo.is())
128 // couldn't distinguish between formatted and edit with the service name, so try with the properties
129 Reference< XPropertySet > xProps(xIFace, UNO_QUERY);
130 if (xProps.is())
132 Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo();
133 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
134 nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
139 break;
141 case FormComponentType::COMMANDBUTTON:
142 nClassNameResourceId = RID_STR_PROPTITLE_PUSHBUTTON; break;
143 case FormComponentType::RADIOBUTTON:
144 nClassNameResourceId = RID_STR_PROPTITLE_RADIOBUTTON; break;
145 case FormComponentType::CHECKBOX:
146 nClassNameResourceId = RID_STR_PROPTITLE_CHECKBOX; break;
147 case FormComponentType::LISTBOX:
148 nClassNameResourceId = RID_STR_PROPTITLE_LISTBOX; break;
149 case FormComponentType::COMBOBOX:
150 nClassNameResourceId = RID_STR_PROPTITLE_COMBOBOX; break;
151 case FormComponentType::GROUPBOX:
152 nClassNameResourceId = RID_STR_PROPTITLE_GROUPBOX; break;
153 case FormComponentType::IMAGEBUTTON:
154 nClassNameResourceId = RID_STR_PROPTITLE_IMAGEBUTTON; break;
155 case FormComponentType::FIXEDTEXT:
156 nClassNameResourceId = RID_STR_PROPTITLE_FIXEDTEXT; break;
157 case FormComponentType::GRIDCONTROL:
158 nClassNameResourceId = RID_STR_PROPTITLE_DBGRID; break;
159 case FormComponentType::FILECONTROL:
160 nClassNameResourceId = RID_STR_PROPTITLE_FILECONTROL; break;
161 case FormComponentType::DATEFIELD:
162 nClassNameResourceId = RID_STR_PROPTITLE_DATEFIELD; break;
163 case FormComponentType::TIMEFIELD:
164 nClassNameResourceId = RID_STR_PROPTITLE_TIMEFIELD; break;
165 case FormComponentType::NUMERICFIELD:
166 nClassNameResourceId = RID_STR_PROPTITLE_NUMERICFIELD; break;
167 case FormComponentType::CURRENCYFIELD:
168 nClassNameResourceId = RID_STR_PROPTITLE_CURRENCYFIELD; break;
169 case FormComponentType::PATTERNFIELD:
170 nClassNameResourceId = RID_STR_PROPTITLE_PATTERNFIELD; break;
171 case FormComponentType::IMAGECONTROL:
172 nClassNameResourceId = RID_STR_PROPTITLE_IMAGECONTROL; break;
173 case FormComponentType::HIDDENCONTROL:
174 nClassNameResourceId = RID_STR_PROPTITLE_HIDDEN; break;
175 case FormComponentType::SCROLLBAR:
176 nClassNameResourceId = RID_STR_PROPTITLE_SCROLLBAR; break;
177 case FormComponentType::SPINBUTTON:
178 nClassNameResourceId = RID_STR_PROPTITLE_SPINBUTTON; break;
179 case FormComponentType::NAVIGATIONBAR:
180 nClassNameResourceId = RID_STR_PROPTITLE_NAVBAR; break;
181 case FormComponentType::CONTROL:
182 default:
183 nClassNameResourceId = RID_STR_CONTROL; break;
186 return OUString( String( SVX_RES( nClassNameResourceId ) ) );
189 //========================================================================
190 // class FmPropBrw
191 //========================================================================
192 DBG_NAME(FmPropBrw);
193 //------------------------------------------------------------------------
194 FmPropBrw::FmPropBrw( const Reference< XComponentContext >& _xORB, SfxBindings* _pBindings,
195 SfxChildWindow* _pMgr, Window* _pParent, const SfxChildWinInfo* _pInfo )
196 :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE) )
197 ,SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings)
198 ,m_bInitialStateChange(sal_True)
199 ,m_bInStateChange( false )
200 ,m_xORB(_xORB)
202 DBG_CTOR(FmPropBrw,NULL);
204 ::Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y);
205 SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y));
206 SetOutputSizePixel(aPropWinSize);
207 SetUniqueId(UID_FORMPROPBROWSER_FRAME);
211 // create a frame wrapper for myself
212 m_xMeAsFrame = Frame::create(m_xORB);
214 // create an intermediate window, which is to be the container window of the frame
215 // Do *not* use |this| as container window for the frame, this would result in undefined
216 // responsibility for this window (as soon as we initialize a frame with a window, the frame
217 // is responsible for it's life time, but |this| is controlled by the belonging SfxChildWindow)
218 // #i34249#
219 Window* pContainerWindow = new Window( this );
220 pContainerWindow->Show();
221 m_xFrameContainerWindow = VCLUnoHelper::GetInterface ( pContainerWindow );
223 m_xMeAsFrame->initialize( m_xFrameContainerWindow );
224 m_xMeAsFrame->setName( OUString("form property browser") );
226 catch (Exception&)
228 OSL_FAIL("FmPropBrw::FmPropBrw: could not create/initialize my frame!");
229 m_xMeAsFrame.clear();
232 if (m_xMeAsFrame.is())
233 _pMgr->SetFrame( Reference<XFrame>(m_xMeAsFrame,UNO_QUERY_THROW) );
236 if ( m_xBrowserComponentWindow.is() )
237 m_xBrowserComponentWindow->setVisible( sal_True );
239 if ( _pInfo )
240 m_sLastActivePage = _pInfo->aExtraString;
243 //------------------------------------------------------------------------
244 void FmPropBrw::Resize()
246 SfxFloatingWindow::Resize();
248 if ( m_xFrameContainerWindow.is() )
252 ::Size aOutputSize( GetOutputSizePixel() );
253 m_xFrameContainerWindow->setPosSize( 0, 0, aOutputSize.Width(), aOutputSize.Height(), awt::PosSize::POSSIZE );
255 catch( const Exception& )
257 OSL_FAIL( "FmPropBrw::Resize: caught an exception!" );
262 //------------------------------------------------------------------------
263 FmPropBrw::~FmPropBrw()
265 if (m_xBrowserController.is())
266 implDetachController();
269 // remove our own properties from the component context. We cannot ensure that the component context
270 // is freed (there might be refcount problems :-\), so at least ensure the context itself
271 // does hold the objects anymore
272 Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
273 if ( xName.is() )
275 const OUString pProps[] = { OUString( "ContextDocument" )
276 , OUString( "DialogParentWindow" )
277 , OUString( "ControlContext" )
278 , OUString( "ControlShapeAccess" ) };
279 for ( size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i )
280 xName->removeByName( pProps[i] );
283 catch (const Exception& )
285 DBG_UNHANDLED_EXCEPTION();
287 DBG_DTOR(FmPropBrw,NULL);
290 //-----------------------------------------------------------------------
291 OUString FmPropBrw::getCurrentPage() const
293 OUString sCurrentPage;
296 if ( m_xBrowserController.is() )
298 OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
301 if ( sCurrentPage.isEmpty() )
302 sCurrentPage = m_sLastActivePage;
304 catch( const Exception& )
306 OSL_FAIL( "FmPropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
308 return sCurrentPage;
311 //-----------------------------------------------------------------------
312 void FmPropBrw::implDetachController()
314 m_sLastActivePage = getCurrentPage();
316 implSetNewSelection( InterfaceBag() );
318 if ( m_xMeAsFrame.is() )
322 m_xMeAsFrame->setComponent(NULL, NULL);
324 catch( const Exception& )
326 OSL_FAIL( "FmPropBrw::implDetachController: caught an exception while resetting the component!" );
330 // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too
331 if ( m_xBrowserController.is() )
332 m_xBrowserController->attachFrame( NULL );
334 m_xBrowserController.clear();
335 m_xInspectorModel.clear();
336 m_xMeAsFrame.clear();
339 //-----------------------------------------------------------------------
340 sal_Bool FmPropBrw::Close()
342 // suspend the controller (it is allowed to veto)
343 if ( m_xMeAsFrame.is() )
347 Reference< XController > xController( m_xMeAsFrame->getController() );
348 if ( xController.is() && !xController->suspend( sal_True ) )
349 return sal_False;
351 catch( const Exception& )
353 OSL_FAIL( "FmPropBrw::Close: caught an exception while asking the controller!" );
357 implDetachController();
359 if( IsRollUp() )
360 RollDown();
362 // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this
363 // would be deadly
364 // 10/19/00 - 79321 - FS
365 SfxBindings& rBindings = SfxControllerItem::GetBindings();
367 sal_Bool bClose = SfxFloatingWindow::Close();
369 if (bClose)
371 rBindings.Invalidate(SID_FM_CTL_PROPERTIES);
372 rBindings.Invalidate(SID_FM_PROPERTIES);
375 return bClose;
378 //-----------------------------------------------------------------------
379 bool FmPropBrw::implIsReadOnlyModel() const
383 if ( m_xInspectorModel.is() )
384 return m_xInspectorModel->getIsReadOnly();
385 return false;
387 catch( const Exception& )
389 DBG_UNHANDLED_EXCEPTION();
391 return true;
394 //-----------------------------------------------------------------------
395 void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection )
397 if ( m_xBrowserController.is() )
401 Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
403 // tell it the objects to inspect
404 Sequence< Reference< XInterface > > aSelection( _rSelection.size() );
405 ::std::copy( _rSelection.begin(), _rSelection.end(), aSelection.getArray() );
407 xInspector->inspect( aSelection );
409 catch( const VetoException& )
411 return;
413 catch( const Exception& )
415 OSL_FAIL( "FmPropBrw::implSetNewSelection: caught an unexpected exception!" );
416 return;
419 // set the new title according to the selected object
420 String sTitle;
422 if ( _rSelection.empty() )
424 sTitle = String( SVX_RES( RID_STR_NO_PROPERTIES ) );
426 else if ( _rSelection.size() > 1 )
428 // no form component and (no form or no name) -> Multiselection
429 sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
430 sTitle += String( SVX_RES( RID_STR_PROPTITLE_MULTISELECT ) );
432 else
434 Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY);
435 if ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) )
437 sal_Int16 nClassID = FormComponentType::CONTROL;
438 xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID;
440 sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) );
441 sTitle += String( GetUIHeadlineName( nClassID, makeAny( xSingleSelection ) ) );
443 else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() )
444 sTitle = String( SVX_RES( RID_STR_PROPERTIES_FORM ) );
447 if ( implIsReadOnlyModel() )
448 sTitle += String( SVX_RES( RID_STR_READONLY_VIEW ) );
450 SetText( sTitle );
452 // #95343# ---------------------------------
453 Reference< ::com::sun::star::awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY );
454 if( xLayoutConstrains.is() )
456 ::Size aConstrainedSize;
457 ::com::sun::star::awt::Size aMinSize = xLayoutConstrains->getMinimumSize();
459 sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0);
460 GetBorder( nLeft, nTop, nRight, nBottom );
461 aMinSize.Width += nLeft + nRight + 8;
462 aMinSize.Height += nTop + nBottom + 8;
464 aConstrainedSize.setHeight( aMinSize.Height );
465 aConstrainedSize.setWidth( aMinSize.Width );
466 SetMinOutputSizePixel( aConstrainedSize );
467 aConstrainedSize = GetOutputSizePixel();
468 sal_Bool bResize = sal_False;
469 if( aConstrainedSize.Width() < aMinSize.Width )
471 aConstrainedSize.setWidth( aMinSize.Width );
472 bResize = sal_True;
474 if( aConstrainedSize.Height() < aMinSize.Height )
476 aConstrainedSize.setHeight( aMinSize.Height );
477 bResize = sal_True;
479 if( bResize )
480 SetOutputSizePixel( aConstrainedSize );
485 //-----------------------------------------------------------------------
486 void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
488 rInfo.bVisible = sal_False;
489 rInfo.aExtraString = getCurrentPage();
492 //-----------------------------------------------------------------------
493 IMPL_LINK( FmPropBrw, OnAsyncGetFocus, void*, /*NOTINTERESTEDIN*/ )
495 if (m_xBrowserComponentWindow.is())
496 m_xBrowserComponentWindow->setFocus();
497 return 0L;
500 //-----------------------------------------------------------------------
501 namespace
503 static bool lcl_shouldEnableHelpSection( const Reference< XComponentContext >& _rxContext )
505 const OUString sConfigName( "/org.openoffice.Office.Common/Forms/PropertyBrowser/" );
506 const OUString sPropertyName( "DirectHelp" );
508 ::utl::OConfigurationTreeRoot aConfiguration(
509 ::utl::OConfigurationTreeRoot::createWithComponentContext( _rxContext, sConfigName ) );
511 bool bEnabled = false;
512 OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled );
513 return bEnabled;
516 //-----------------------------------------------------------------------
517 void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell )
519 // the document in which we live
520 Reference< XInterface > xDocument;
521 if ( _pFormShell && _pFormShell->GetObjectShell() )
522 xDocument = _pFormShell->GetObjectShell()->GetModel();
524 // the context of the controls in our document
525 Reference< awt::XControlContainer > xControlContext;
526 if ( _pFormShell && _pFormShell->GetFormView() )
528 SdrPageView* pPageView = _pFormShell->GetFormView()->GetSdrPageView();
530 if(pPageView)
532 SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0L);
534 if(pPageWindow)
536 xControlContext = pPageWindow->GetControlContainer();
541 // the default parent window for message boxes
542 Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) );
544 // the mapping from control models to control shapes
545 Reference< XMap > xControlMap;
546 FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : NULL;
547 if ( pFormPage )
548 xControlMap = pFormPage->GetImpl().getControlToShapeMap();
550 // our own component context
552 // a ComponentContext for the
553 ::cppu::ContextEntry_Init aHandlerContextInfo[] =
555 ::cppu::ContextEntry_Init( OUString( "ContextDocument" ), makeAny( xDocument ) ),
556 ::cppu::ContextEntry_Init( OUString( "DialogParentWindow" ), makeAny( xParentWindow ) ),
557 ::cppu::ContextEntry_Init( OUString( "ControlContext" ), makeAny( xControlContext ) ),
558 ::cppu::ContextEntry_Init( OUString( "ControlShapeAccess" ), makeAny( xControlMap ) )
560 m_xInspectorContext.set(
561 ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ),
562 m_xORB ) );
564 bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
566 // an object inspector model
567 m_xInspectorModel =
568 bEnableHelpSection
569 ? DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 5 )
570 : DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext );
572 // an object inspector
573 m_xBrowserController = m_xBrowserController.query(
574 ObjectInspector::createWithModel(
575 m_xInspectorContext, m_xInspectorModel
576 ) );
578 if ( !m_xBrowserController.is() )
580 OUString sServiceName( "com.sun.star.inspection.ObjectInspector" );
581 ShowServiceNotAvailableError( GetParent(), sServiceName, sal_True );
583 else
585 m_xBrowserController->attachFrame( Reference<XFrame>(m_xMeAsFrame,UNO_QUERY_THROW) );
586 m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow();
587 DBG_ASSERT( m_xBrowserComponentWindow.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" );
590 if ( bEnableHelpSection )
592 Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW );
593 Reference< XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() );
594 Reference< XInterface > xDefaultHelpProvider( DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) );
598 //-----------------------------------------------------------------------
599 void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell )
601 // the document in which we live
602 Reference< XInterface > xDocument;
603 SfxObjectShell* pObjectShell = _pFormShell ? _pFormShell->GetObjectShell() : NULL;
604 if ( pObjectShell )
605 xDocument = pObjectShell->GetModel();
606 if ( ( xDocument == m_xLastKnownDocument ) && m_xBrowserController.is() )
607 // nothing to do
608 return;
612 // clean up any previous instances of the object inspector
613 if ( m_xMeAsFrame.is() )
614 m_xMeAsFrame->setComponent( NULL, NULL );
615 else
616 ::comphelper::disposeComponent( m_xBrowserController );
617 m_xBrowserController.clear();
618 m_xInspectorModel.clear();
619 m_xBrowserComponentWindow.clear();
621 // and create a new one
622 impl_createPropertyBrowser_throw( _pFormShell );
624 catch( const Exception& )
626 DBG_UNHANDLED_EXCEPTION();
628 m_xLastKnownDocument = xDocument;
631 //-----------------------------------------------------------------------
632 void FmPropBrw::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
634 if (!pState || SID_FM_PROPERTY_CONTROL != nSID)
635 return;
637 m_bInStateChange = true;
640 if (eState >= SFX_ITEM_AVAILABLE)
642 FmFormShell* pShell = PTR_CAST(FmFormShell,((SfxObjectItem*)pState)->GetShell());
643 InterfaceBag aSelection;
644 if ( pShell )
645 pShell->GetImpl()->getCurrentSelection( aSelection );
647 impl_ensurePropertyBrowser_nothrow( pShell );
649 // set the new object to inspect
650 implSetNewSelection( aSelection );
652 // if this is the first time we're here, some additional things need to be done ...
653 if ( m_bInitialStateChange )
655 // if we're just newly created, we want to have the focus
656 PostUserEvent( LINK( this, FmPropBrw, OnAsyncGetFocus ) );
658 // and additionally, we want to show the page which was active during
659 // our previous incarnation
660 if ( !m_sLastActivePage.isEmpty() )
664 if ( m_xBrowserController.is() )
665 m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) );
667 catch( const Exception& )
669 OSL_FAIL( "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
673 m_bInitialStateChange = sal_False;
677 else
679 implSetNewSelection( InterfaceBag() );
682 catch (Exception&)
684 OSL_FAIL("FmPropBrw::StateChanged: Exception occurred!");
686 m_bInStateChange = false;
689 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */