1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: fmPropBrw.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
36 #include "fmPropBrw.hxx"
37 #include "fmresids.hrc"
38 #include "fmservs.hxx"
39 #include "fmshimp.hxx"
40 #include "fmpgeimp.hxx"
42 #include "svx/dialmgr.hxx"
43 #include "svx/fmpage.hxx"
44 #include "svx/fmshell.hxx"
45 #include "svx/sdrpagewindow.hxx"
46 #include "svx/svdpagv.hxx"
47 #include "svx/svxids.hrc"
49 /** === begin UNO includes === **/
50 #include <com/sun/star/beans/PropertyValue.hpp>
51 #include <com/sun/star/awt/PosSize.hpp>
52 #include <com/sun/star/form/XForm.hpp>
53 #include <com/sun/star/form/FormComponentType.hpp>
54 #include <com/sun/star/awt/XLayoutConstrains.hpp>
55 #include <com/sun/star/awt/XControlContainer.hpp>
56 #include <com/sun/star/container/XChild.hpp>
57 #include <com/sun/star/awt/PosSize.hpp>
58 #include <com/sun/star/inspection/ObjectInspector.hpp>
59 #include <com/sun/star/inspection/ObjectInspectorModel.hpp>
60 #include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp>
61 #include <com/sun/star/inspection/XObjectInspectorUI.hpp>
62 #include <com/sun/star/inspection/DefaultHelpProvider.hpp>
63 /** === end UNO includes === **/
65 #include <comphelper/processfactory.hxx>
66 #include <comphelper/property.hxx>
67 #include <cppuhelper/component_context.hxx>
68 #include <sfx2/bindings.hxx>
69 #include <sfx2/childwin.hxx>
70 #include <sfx2/dispatch.hxx>
71 #include <sfx2/objitem.hxx>
72 #include <sfx2/objsh.hxx>
73 #include <sfx2/viewfrm.hxx>
74 #include <toolkit/unohlp.hxx>
75 #include <tools/debug.hxx>
76 #include <tools/diagnose_ex.h>
77 #include <tools/shl.hxx>
78 #include <unotools/confignode.hxx>
79 #include <vcl/stdtext.hxx>
83 using namespace ::com::sun::star
;
84 using namespace ::com::sun::star::uno
;
85 using namespace ::com::sun::star::util
;
86 using namespace ::com::sun::star::inspection
;
87 using namespace ::com::sun::star::form::inspection
;
88 using ::com::sun::star::awt::XWindow
;
90 /*************************************************************************/
91 //========================================================================
93 //========================================================================
94 //-----------------------------------------------------------------------
95 SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr
, SID_FM_SHOW_PROPERTIES
)
97 //-----------------------------------------------------------------------
98 FmPropBrwMgr::FmPropBrwMgr( Window
* _pParent
, sal_uInt16 _nId
,
99 SfxBindings
* _pBindings
, SfxChildWinInfo
* _pInfo
)
100 :SfxChildWindow(_pParent
, _nId
)
102 pWindow
= new FmPropBrw( ::comphelper::getProcessServiceFactory(), _pBindings
, this, _pParent
, _pInfo
);
103 eChildAlignment
= SFX_ALIGN_NOALIGNMENT
;
104 ((SfxFloatingWindow
*)pWindow
)->Initialize( _pInfo
);
107 //========================================================================
108 //========================================================================
109 const long STD_WIN_SIZE_X
= 300;
110 const long STD_WIN_SIZE_Y
= 350;
112 const long STD_MIN_SIZE_X
= 250;
113 const long STD_MIN_SIZE_Y
= 250;
115 const long STD_WIN_POS_X
= 50;
116 const long STD_WIN_POS_Y
= 50;
117 const long WIN_BORDER
= 2;
118 const long MIN_WIN_SIZE_X
= 50;
119 const long MIN_WIN_SIZE_Y
= 50;
121 using namespace ::com::sun::star::uno
;
122 using namespace ::com::sun::star::lang
;
123 using namespace ::com::sun::star::form
;
124 using namespace ::com::sun::star::frame
;
125 using namespace ::com::sun::star::beans
;
126 using namespace ::com::sun::star::container
;
127 using namespace ::svxform
;
129 ::rtl::OUString
GetUIHeadlineName(sal_Int16 nClassId
, const Any
& aUnoObj
)
131 sal_uInt16 nClassNameResourceId
= 0;
135 case FormComponentType::TEXTFIELD
:
137 Reference
< XInterface
> xIFace
;
139 nClassNameResourceId
= RID_STR_PROPTITLE_EDIT
;
141 { // we have a chance to check if it's a formatted field model
142 Reference
< XServiceInfo
> xInfo(xIFace
, UNO_QUERY
);
143 if (xInfo
.is() && (xInfo
->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD
)))
144 nClassNameResourceId
= RID_STR_PROPTITLE_FORMATTED
;
145 else if (!xInfo
.is())
147 // couldn't distinguish between formatted and edit with the service name, so try with the properties
148 Reference
< XPropertySet
> xProps(xIFace
, UNO_QUERY
);
151 Reference
< XPropertySetInfo
> xPropsInfo
= xProps
->getPropertySetInfo();
152 if (xPropsInfo
.is() && xPropsInfo
->hasPropertyByName(FM_PROP_FORMATSSUPPLIER
))
153 nClassNameResourceId
= RID_STR_PROPTITLE_FORMATTED
;
160 case FormComponentType::COMMANDBUTTON
:
161 nClassNameResourceId
= RID_STR_PROPTITLE_PUSHBUTTON
; break;
162 case FormComponentType::RADIOBUTTON
:
163 nClassNameResourceId
= RID_STR_PROPTITLE_RADIOBUTTON
; break;
164 case FormComponentType::CHECKBOX
:
165 nClassNameResourceId
= RID_STR_PROPTITLE_CHECKBOX
; break;
166 case FormComponentType::LISTBOX
:
167 nClassNameResourceId
= RID_STR_PROPTITLE_LISTBOX
; break;
168 case FormComponentType::COMBOBOX
:
169 nClassNameResourceId
= RID_STR_PROPTITLE_COMBOBOX
; break;
170 case FormComponentType::GROUPBOX
:
171 nClassNameResourceId
= RID_STR_PROPTITLE_GROUPBOX
; break;
172 case FormComponentType::IMAGEBUTTON
:
173 nClassNameResourceId
= RID_STR_PROPTITLE_IMAGEBUTTON
; break;
174 case FormComponentType::FIXEDTEXT
:
175 nClassNameResourceId
= RID_STR_PROPTITLE_FIXEDTEXT
; break;
176 case FormComponentType::GRIDCONTROL
:
177 nClassNameResourceId
= RID_STR_PROPTITLE_DBGRID
; break;
178 case FormComponentType::FILECONTROL
:
179 nClassNameResourceId
= RID_STR_PROPTITLE_FILECONTROL
; break;
180 case FormComponentType::DATEFIELD
:
181 nClassNameResourceId
= RID_STR_PROPTITLE_DATEFIELD
; break;
182 case FormComponentType::TIMEFIELD
:
183 nClassNameResourceId
= RID_STR_PROPTITLE_TIMEFIELD
; break;
184 case FormComponentType::NUMERICFIELD
:
185 nClassNameResourceId
= RID_STR_PROPTITLE_NUMERICFIELD
; break;
186 case FormComponentType::CURRENCYFIELD
:
187 nClassNameResourceId
= RID_STR_PROPTITLE_CURRENCYFIELD
; break;
188 case FormComponentType::PATTERNFIELD
:
189 nClassNameResourceId
= RID_STR_PROPTITLE_PATTERNFIELD
; break;
190 case FormComponentType::IMAGECONTROL
:
191 nClassNameResourceId
= RID_STR_PROPTITLE_IMAGECONTROL
; break;
192 case FormComponentType::HIDDENCONTROL
:
193 nClassNameResourceId
= RID_STR_PROPTITLE_HIDDEN
; break;
194 case FormComponentType::SCROLLBAR
:
195 nClassNameResourceId
= RID_STR_PROPTITLE_SCROLLBAR
; break;
196 case FormComponentType::SPINBUTTON
:
197 nClassNameResourceId
= RID_STR_PROPTITLE_SPINBUTTON
; break;
198 case FormComponentType::NAVIGATIONBAR
:
199 nClassNameResourceId
= RID_STR_PROPTITLE_NAVBAR
; break;
200 case FormComponentType::CONTROL
:
202 nClassNameResourceId
= RID_STR_CONTROL
; break;
205 if ( !nClassNameResourceId
)
206 return ::rtl::OUString();
208 return ::rtl::OUString( String( SVX_RES( nClassNameResourceId
) ) );
211 //========================================================================
213 //========================================================================
215 //------------------------------------------------------------------------
216 FmPropBrw::FmPropBrw( const Reference
< XMultiServiceFactory
>& _xORB
, SfxBindings
* _pBindings
,
217 SfxChildWindow
* _pMgr
, Window
* _pParent
, const SfxChildWinInfo
* _pInfo
)
218 :SfxFloatingWindow(_pBindings
, _pMgr
, _pParent
, WinBits(WB_STDMODELESS
|WB_SIZEABLE
|WB_3DLOOK
|WB_ROLLABLE
) )
219 ,SfxControllerItem(SID_FM_PROPERTY_CONTROL
, *_pBindings
)
220 ,m_bInitialStateChange(sal_True
)
221 ,m_bInStateChange( false )
224 DBG_CTOR(FmPropBrw
,NULL
);
226 ::Size
aPropWinSize(STD_WIN_SIZE_X
,STD_WIN_SIZE_Y
);
227 SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X
,STD_MIN_SIZE_Y
));
228 SetOutputSizePixel(aPropWinSize
);
229 SetUniqueId(UID_FORMPROPBROWSER_FRAME
);
233 // create a frame wrapper for myself
234 m_xMeAsFrame
= Reference
< XFrame
>(m_xORB
->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")), UNO_QUERY
);
235 if (m_xMeAsFrame
.is())
237 // create an intermediate window, which is to be the container window of the frame
238 // Do *not* use |this| as container window for the frame, this would result in undefined
239 // responsiblity for this window (as soon as we initialize a frame with a window, the frame
240 // is responsible for it's life time, but |this| is controlled by the belonging SfxChildWindow)
241 // #i34249# - 2004-09-27 - fs@openoffice.org
242 Window
* pContainerWindow
= new Window( this );
243 pContainerWindow
->Show();
244 m_xFrameContainerWindow
= VCLUnoHelper::GetInterface ( pContainerWindow
);
246 m_xMeAsFrame
->initialize( m_xFrameContainerWindow
);
247 m_xMeAsFrame
->setName(::rtl::OUString::createFromAscii("form property browser"));
248 if ( _pBindings
->GetDispatcher() )
250 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFramesSupplier
>
251 xSupp ( _pBindings
->GetDispatcher()->GetFrame()->GetFrame()->GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY
);
253 // xSupp->getFrames()->append( m_xMeAsFrame );
254 // Don't append frame to frame hierachy to prevent UI_DEACTIVATE messages
255 // #i31834# - 2004-07-27 - cd@openoffice.org
261 DBG_ERROR("FmPropBrw::FmPropBrw: could not create/initialize my frame!");
262 m_xMeAsFrame
.clear();
265 if (m_xMeAsFrame
.is())
266 _pMgr
->SetFrame( m_xMeAsFrame
);
269 if ( m_xBrowserComponentWindow
.is() )
270 m_xBrowserComponentWindow
->setVisible( sal_True
);
273 m_sLastActivePage
= _pInfo
->aExtraString
;
276 //------------------------------------------------------------------------
277 void FmPropBrw::Resize()
279 SfxFloatingWindow::Resize();
281 if ( m_xFrameContainerWindow
.is() )
285 ::Size
aOutputSize( GetOutputSizePixel() );
286 m_xFrameContainerWindow
->setPosSize( 0, 0, aOutputSize
.Width(), aOutputSize
.Height(), awt::PosSize::POSSIZE
);
288 catch( const Exception
& )
290 OSL_ENSURE( sal_False
, "FmPropBrw::Resize: caught an exception!" );
295 //------------------------------------------------------------------------
296 FmPropBrw::~FmPropBrw()
298 if (m_xBrowserController
.is())
299 implDetachController();
302 // remove our own properties from the component context. We cannot ensure that the component context
303 // is freed (there might be refcount problems :-\), so at least ensure the context itself
304 // does hold the objects anymore
305 Reference
<XNameContainer
> xName(m_xInspectorContext
,uno::UNO_QUERY
);
308 const ::rtl::OUString pProps
[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) )
309 , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) )
310 , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) )
311 , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ) };
312 for ( size_t i
= 0; i
< sizeof(pProps
)/sizeof(pProps
[0]); ++i
)
313 xName
->removeByName( pProps
[i
] );
316 catch (const Exception
& )
318 DBG_UNHANDLED_EXCEPTION();
320 DBG_DTOR(FmPropBrw
,NULL
);
323 //-----------------------------------------------------------------------
324 ::rtl::OUString
FmPropBrw::getCurrentPage() const
326 ::rtl::OUString sCurrentPage
;
329 if ( m_xBrowserController
.is() )
331 OSL_VERIFY( m_xBrowserController
->getViewData() >>= sCurrentPage
);
334 if ( !sCurrentPage
.getLength() )
335 sCurrentPage
= m_sLastActivePage
;
337 catch( const Exception
& )
339 OSL_ENSURE( sal_False
, "FmPropBrw::getCurrentPage: caught an exception while retrieving the current page!" );
344 //-----------------------------------------------------------------------
345 void FmPropBrw::implDetachController()
347 m_sLastActivePage
= getCurrentPage();
349 implSetNewSelection( InterfaceBag() );
351 if ( m_xMeAsFrame
.is() )
355 m_xMeAsFrame
->setComponent(NULL
, NULL
);
357 catch( const Exception
& )
359 OSL_ENSURE( sal_False
, "FmPropBrw::implDetachController: caught an exception while resetting the component!" );
363 // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too
364 // 96068 - 09.01.2002 - fs@openoffice.org
365 if ( m_xBrowserController
.is() )
366 m_xBrowserController
->attachFrame( NULL
);
368 m_xBrowserController
.clear();
369 m_xInspectorModel
.clear();
370 m_xMeAsFrame
.clear();
373 //-----------------------------------------------------------------------
374 sal_Bool
FmPropBrw::Close()
376 // suspend the controller (it is allowed to veto)
377 if ( m_xMeAsFrame
.is() )
381 Reference
< XController
> xController( m_xMeAsFrame
->getController() );
382 if ( xController
.is() && !xController
->suspend( sal_True
) )
385 catch( const Exception
& )
387 OSL_ENSURE( sal_False
, "FmPropBrw::Close: caught an exception while asking the controller!" );
391 implDetachController();
396 // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this
398 // 10/19/00 - 79321 - FS
399 SfxBindings
& rBindings
= SfxControllerItem::GetBindings();
401 sal_Bool bClose
= SfxFloatingWindow::Close();
405 rBindings
.Invalidate(SID_FM_CTL_PROPERTIES
);
406 rBindings
.Invalidate(SID_FM_PROPERTIES
);
412 //-----------------------------------------------------------------------
413 bool FmPropBrw::implIsReadOnlyModel() const
417 if ( m_xInspectorModel
.is() )
418 return m_xInspectorModel
->getIsReadOnly();
421 catch( const Exception
& )
423 DBG_UNHANDLED_EXCEPTION();
428 //-----------------------------------------------------------------------
429 void FmPropBrw::implSetNewSelection( const InterfaceBag
& _rSelection
)
431 if ( m_xBrowserController
.is() )
435 Reference
< XObjectInspector
> xInspector( m_xBrowserController
, UNO_QUERY_THROW
);
437 // tell it the objects to inspect
438 Sequence
< Reference
< XInterface
> > aSelection( _rSelection
.size() );
439 ::std::copy( _rSelection
.begin(), _rSelection
.end(), aSelection
.getArray() );
441 xInspector
->inspect( aSelection
);
443 catch( const VetoException
& )
447 catch( const Exception
& )
449 OSL_ENSURE( sal_False
, "FmPropBrw::implSetNewSelection: caught an unexpected exception!" );
453 // set the new title according to the selected object
456 if ( _rSelection
.empty() )
458 sTitle
= String( SVX_RES( RID_STR_NO_PROPERTIES
) );
460 else if ( _rSelection
.size() > 1 )
462 // no form component and (no form or no name) -> Multiselection
463 sTitle
= String( SVX_RES( RID_STR_PROPERTIES_CONTROL
) );
464 sTitle
+= String( SVX_RES( RID_STR_PROPTITLE_MULTISELECT
) );
468 Reference
< XPropertySet
> xSingleSelection( *_rSelection
.begin(), UNO_QUERY
);
469 if ( ::comphelper::hasProperty( FM_PROP_CLASSID
, xSingleSelection
) )
471 sal_Int16 nClassID
= FormComponentType::CONTROL
;
472 xSingleSelection
->getPropertyValue( FM_PROP_CLASSID
) >>= nClassID
;
474 sTitle
= String( SVX_RES( RID_STR_PROPERTIES_CONTROL
) );
475 sTitle
+= String( GetUIHeadlineName( nClassID
, makeAny( xSingleSelection
) ) );
477 else if ( Reference
< XForm
>( xSingleSelection
, UNO_QUERY
).is() )
478 sTitle
= String( SVX_RES( RID_STR_PROPERTIES_FORM
) );
481 if ( implIsReadOnlyModel() )
482 sTitle
+= String( SVX_RES( RID_STR_READONLY_VIEW
) );
486 // #95343# ---------------------------------
487 Reference
< ::com::sun::star::awt::XLayoutConstrains
> xLayoutConstrains( m_xBrowserController
, UNO_QUERY
);
488 if( xLayoutConstrains
.is() )
490 ::Size aConstrainedSize
;
491 ::com::sun::star::awt::Size aMinSize
= xLayoutConstrains
->getMinimumSize();
493 sal_Int32
nLeft(0), nTop(0), nRight(0), nBottom(0);
494 GetBorder( nLeft
, nTop
, nRight
, nBottom
);
495 aMinSize
.Width
+= nLeft
+ nRight
+ 8;
496 aMinSize
.Height
+= nTop
+ nBottom
+ 8;
498 aConstrainedSize
.setHeight( aMinSize
.Height
);
499 aConstrainedSize
.setWidth( aMinSize
.Width
);
500 SetMinOutputSizePixel( aConstrainedSize
);
501 aConstrainedSize
= GetOutputSizePixel();
502 sal_Bool bResize
= sal_False
;
503 if( aConstrainedSize
.Width() < aMinSize
.Width
)
505 aConstrainedSize
.setWidth( aMinSize
.Width
);
508 if( aConstrainedSize
.Height() < aMinSize
.Height
)
510 aConstrainedSize
.setHeight( aMinSize
.Height
);
514 SetOutputSizePixel( aConstrainedSize
);
519 //-----------------------------------------------------------------------
520 void FmPropBrw::FillInfo( SfxChildWinInfo
& rInfo
) const
522 rInfo
.bVisible
= sal_False
;
523 rInfo
.aExtraString
= getCurrentPage();
526 //-----------------------------------------------------------------------
527 IMPL_LINK( FmPropBrw
, OnAsyncGetFocus
, void*, /*NOTINTERESTEDIN*/ )
529 if (m_xBrowserComponentWindow
.is())
530 m_xBrowserComponentWindow
->setFocus();
534 //-----------------------------------------------------------------------
537 static bool lcl_shouldEnableHelpSection( const Reference
< XMultiServiceFactory
>& _rxFactory
)
539 const ::rtl::OUString
sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Forms/PropertyBrowser/" ) );
540 const ::rtl::OUString
sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) );
542 ::utl::OConfigurationTreeRoot
aConfiguration(
543 ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory
, sConfigName
) );
545 bool bEnabled
= false;
546 OSL_VERIFY( aConfiguration
.getNodeValue( sPropertyName
) >>= bEnabled
);
550 //-----------------------------------------------------------------------
551 void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell
* _pFormShell
)
553 // the document in which we live
554 Reference
< XInterface
> xDocument
;
555 if ( _pFormShell
&& _pFormShell
->GetObjectShell() )
556 xDocument
= _pFormShell
->GetObjectShell()->GetModel();
558 // the context of the controls in our document
559 Reference
< awt::XControlContainer
> xControlContext
;
560 if ( _pFormShell
&& _pFormShell
->GetFormView() )
562 SdrPageView
* pPageView
= _pFormShell
->GetFormView()->GetSdrPageView();
566 SdrPageWindow
* pPageWindow
= pPageView
->GetPageWindow(0L);
570 xControlContext
= pPageWindow
->GetControlContainer();
575 // the default parent window for message boxes
576 Reference
< XWindow
> xParentWindow( VCLUnoHelper::GetInterface ( this ) );
578 // the mapping from control models to control shapes
579 Reference
< XMap
> xControlMap
;
580 FmFormPage
* pFormPage
= _pFormShell
? _pFormShell
->GetCurPage() : NULL
;
582 xControlMap
= pFormPage
->GetImpl().getControlToShapeMap();
584 // our own component context
585 Reference
< XPropertySet
> xFactoryProperties( m_xORB
, UNO_QUERY_THROW
);
586 Reference
< XComponentContext
> xOwnContext(
587 xFactoryProperties
->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ),
590 // a ComponentContext for the
591 ::cppu::ContextEntry_Init aHandlerContextInfo
[] =
593 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( xDocument
) ),
594 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( xParentWindow
) ),
595 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext
) ),
596 ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap
) )
598 m_xInspectorContext
.set(
599 ::cppu::createComponentContext( aHandlerContextInfo
, sizeof( aHandlerContextInfo
) / sizeof( aHandlerContextInfo
[0] ),
602 bool bEnableHelpSection
= lcl_shouldEnableHelpSection( m_xORB
);
604 // an object inspector model
607 ? DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext
, 3, 5 )
608 : DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext
);
610 // an object inspector
611 m_xBrowserController
= m_xBrowserController
.query(
612 ObjectInspector::createWithModel(
613 m_xInspectorContext
, m_xInspectorModel
616 if ( !m_xBrowserController
.is() )
618 ::rtl::OUString
sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) );
619 ShowServiceNotAvailableError( GetParent(), sServiceName
, sal_True
);
623 m_xBrowserController
->attachFrame( m_xMeAsFrame
);
624 m_xBrowserComponentWindow
= m_xMeAsFrame
->getComponentWindow();
625 DBG_ASSERT( m_xBrowserComponentWindow
.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" );
628 if ( bEnableHelpSection
)
630 Reference
< XObjectInspector
> xInspector( m_xBrowserController
, UNO_QUERY_THROW
);
631 Reference
< XObjectInspectorUI
> xInspectorUI( xInspector
->getInspectorUI() );
632 Reference
< XInterface
> xDefaultHelpProvider( DefaultHelpProvider::create( m_xInspectorContext
, xInspectorUI
) );
636 //-----------------------------------------------------------------------
637 void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell
* _pFormShell
)
639 // the document in which we live
640 Reference
< XInterface
> xDocument
;
641 SfxObjectShell
* pObjectShell
= _pFormShell
? _pFormShell
->GetObjectShell() : NULL
;
643 xDocument
= pObjectShell
->GetModel();
644 if ( ( xDocument
== m_xLastKnownDocument
) && m_xBrowserController
.is() )
650 // clean up any previous instances of the object inspector
651 if ( m_xMeAsFrame
.is() )
652 m_xMeAsFrame
->setComponent( NULL
, NULL
);
654 ::comphelper::disposeComponent( m_xBrowserController
);
655 m_xBrowserController
.clear();
656 m_xInspectorModel
.clear();
657 m_xBrowserComponentWindow
.clear();
659 // and create a new one
660 impl_createPropertyBrowser_throw( _pFormShell
);
662 catch( const Exception
& )
664 DBG_UNHANDLED_EXCEPTION();
666 m_xLastKnownDocument
= xDocument
;
669 //-----------------------------------------------------------------------
670 void FmPropBrw::StateChanged(sal_uInt16 nSID
, SfxItemState eState
, const SfxPoolItem
* pState
)
672 if (!pState
|| SID_FM_PROPERTY_CONTROL
!= nSID
)
675 m_bInStateChange
= true;
678 if (eState
>= SFX_ITEM_AVAILABLE
)
680 FmFormShell
* pShell
= PTR_CAST(FmFormShell
,((SfxObjectItem
*)pState
)->GetShell());
681 InterfaceBag aSelection
;
683 pShell
->GetImpl()->getCurrentSelection( aSelection
);
685 impl_ensurePropertyBrowser_nothrow( pShell
);
687 // set the new object to inspect
688 implSetNewSelection( aSelection
);
690 // if this is the first time we're here, some additional things need to be done ...
691 if ( m_bInitialStateChange
)
693 // if we're just newly created, we want to have the focus
694 PostUserEvent( LINK( this, FmPropBrw
, OnAsyncGetFocus
) );
696 // and additionally, we want to show the page which was active during
697 // our previous incarnation
698 if ( m_sLastActivePage
.getLength() )
702 if ( m_xBrowserController
.is() )
703 m_xBrowserController
->restoreViewData( makeAny( m_sLastActivePage
) );
705 catch( const Exception
& )
707 OSL_ENSURE( sal_False
, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" );
711 m_bInitialStateChange
= sal_False
;
717 implSetNewSelection( InterfaceBag() );
722 DBG_ERROR("FmPropBrw::StateChanged: Exception occured!");
724 m_bInStateChange
= false;