1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir 28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 29*cdf0e10cSrcweir #include "precompiled_svx.hxx" 30*cdf0e10cSrcweir 31*cdf0e10cSrcweir #include "fmhelp.hrc" 32*cdf0e10cSrcweir #include "fmprop.hrc" 33*cdf0e10cSrcweir #include "fmPropBrw.hxx" 34*cdf0e10cSrcweir #include "svx/fmresids.hrc" 35*cdf0e10cSrcweir #include "fmservs.hxx" 36*cdf0e10cSrcweir #include "fmshimp.hxx" 37*cdf0e10cSrcweir #include "fmpgeimp.hxx" 38*cdf0e10cSrcweir 39*cdf0e10cSrcweir #include "svx/dialmgr.hxx" 40*cdf0e10cSrcweir #include "svx/fmpage.hxx" 41*cdf0e10cSrcweir #include "svx/fmshell.hxx" 42*cdf0e10cSrcweir #include "svx/sdrpagewindow.hxx" 43*cdf0e10cSrcweir #include "svx/svdpagv.hxx" 44*cdf0e10cSrcweir #include "svx/svxids.hrc" 45*cdf0e10cSrcweir 46*cdf0e10cSrcweir /** === begin UNO includes === **/ 47*cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 48*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 49*cdf0e10cSrcweir #include <com/sun/star/form/XForm.hpp> 50*cdf0e10cSrcweir #include <com/sun/star/form/FormComponentType.hpp> 51*cdf0e10cSrcweir #include <com/sun/star/awt/XLayoutConstrains.hpp> 52*cdf0e10cSrcweir #include <com/sun/star/awt/XControlContainer.hpp> 53*cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp> 54*cdf0e10cSrcweir #include <com/sun/star/awt/PosSize.hpp> 55*cdf0e10cSrcweir #include <com/sun/star/inspection/ObjectInspector.hpp> 56*cdf0e10cSrcweir #include <com/sun/star/inspection/ObjectInspectorModel.hpp> 57*cdf0e10cSrcweir #include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp> 58*cdf0e10cSrcweir #include <com/sun/star/inspection/XObjectInspectorUI.hpp> 59*cdf0e10cSrcweir #include <com/sun/star/inspection/DefaultHelpProvider.hpp> 60*cdf0e10cSrcweir /** === end UNO includes === **/ 61*cdf0e10cSrcweir 62*cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 63*cdf0e10cSrcweir #include <comphelper/property.hxx> 64*cdf0e10cSrcweir #include <cppuhelper/component_context.hxx> 65*cdf0e10cSrcweir #include <sfx2/bindings.hxx> 66*cdf0e10cSrcweir #include <sfx2/childwin.hxx> 67*cdf0e10cSrcweir #include <sfx2/dispatch.hxx> 68*cdf0e10cSrcweir #include <sfx2/objitem.hxx> 69*cdf0e10cSrcweir #include <sfx2/objsh.hxx> 70*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx> 71*cdf0e10cSrcweir #include <toolkit/unohlp.hxx> 72*cdf0e10cSrcweir #include <tools/debug.hxx> 73*cdf0e10cSrcweir #include <tools/diagnose_ex.h> 74*cdf0e10cSrcweir #include <tools/shl.hxx> 75*cdf0e10cSrcweir #include <unotools/confignode.hxx> 76*cdf0e10cSrcweir #include <vcl/stdtext.hxx> 77*cdf0e10cSrcweir 78*cdf0e10cSrcweir #include <algorithm> 79*cdf0e10cSrcweir 80*cdf0e10cSrcweir using namespace ::com::sun::star; 81*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 82*cdf0e10cSrcweir using namespace ::com::sun::star::util; 83*cdf0e10cSrcweir using namespace ::com::sun::star::inspection; 84*cdf0e10cSrcweir using namespace ::com::sun::star::form::inspection; 85*cdf0e10cSrcweir using ::com::sun::star::awt::XWindow; 86*cdf0e10cSrcweir 87*cdf0e10cSrcweir /*************************************************************************/ 88*cdf0e10cSrcweir //======================================================================== 89*cdf0e10cSrcweir //= FmPropBrwMgr 90*cdf0e10cSrcweir //======================================================================== 91*cdf0e10cSrcweir //----------------------------------------------------------------------- 92*cdf0e10cSrcweir SFX_IMPL_FLOATINGWINDOW(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES) 93*cdf0e10cSrcweir 94*cdf0e10cSrcweir //----------------------------------------------------------------------- 95*cdf0e10cSrcweir FmPropBrwMgr::FmPropBrwMgr( Window* _pParent, sal_uInt16 _nId, 96*cdf0e10cSrcweir SfxBindings* _pBindings, SfxChildWinInfo* _pInfo) 97*cdf0e10cSrcweir :SfxChildWindow(_pParent, _nId) 98*cdf0e10cSrcweir { 99*cdf0e10cSrcweir pWindow = new FmPropBrw( ::comphelper::getProcessServiceFactory(), _pBindings, this, _pParent, _pInfo ); 100*cdf0e10cSrcweir eChildAlignment = SFX_ALIGN_NOALIGNMENT; 101*cdf0e10cSrcweir ((SfxFloatingWindow*)pWindow)->Initialize( _pInfo ); 102*cdf0e10cSrcweir } 103*cdf0e10cSrcweir 104*cdf0e10cSrcweir //======================================================================== 105*cdf0e10cSrcweir //======================================================================== 106*cdf0e10cSrcweir const long STD_WIN_SIZE_X = 300; 107*cdf0e10cSrcweir const long STD_WIN_SIZE_Y = 350; 108*cdf0e10cSrcweir 109*cdf0e10cSrcweir const long STD_MIN_SIZE_X = 250; 110*cdf0e10cSrcweir const long STD_MIN_SIZE_Y = 250; 111*cdf0e10cSrcweir 112*cdf0e10cSrcweir const long STD_WIN_POS_X = 50; 113*cdf0e10cSrcweir const long STD_WIN_POS_Y = 50; 114*cdf0e10cSrcweir const long WIN_BORDER = 2; 115*cdf0e10cSrcweir const long MIN_WIN_SIZE_X = 50; 116*cdf0e10cSrcweir const long MIN_WIN_SIZE_Y = 50; 117*cdf0e10cSrcweir 118*cdf0e10cSrcweir using namespace ::com::sun::star::uno; 119*cdf0e10cSrcweir using namespace ::com::sun::star::lang; 120*cdf0e10cSrcweir using namespace ::com::sun::star::form; 121*cdf0e10cSrcweir using namespace ::com::sun::star::frame; 122*cdf0e10cSrcweir using namespace ::com::sun::star::beans; 123*cdf0e10cSrcweir using namespace ::com::sun::star::container; 124*cdf0e10cSrcweir using namespace ::svxform; 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir ::rtl::OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj) 127*cdf0e10cSrcweir { 128*cdf0e10cSrcweir sal_uInt16 nClassNameResourceId = 0; 129*cdf0e10cSrcweir 130*cdf0e10cSrcweir switch ( nClassId ) 131*cdf0e10cSrcweir { 132*cdf0e10cSrcweir case FormComponentType::TEXTFIELD: 133*cdf0e10cSrcweir { 134*cdf0e10cSrcweir Reference< XInterface > xIFace; 135*cdf0e10cSrcweir aUnoObj >>= xIFace; 136*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_EDIT; 137*cdf0e10cSrcweir if (xIFace.is()) 138*cdf0e10cSrcweir { // we have a chance to check if it's a formatted field model 139*cdf0e10cSrcweir Reference< XServiceInfo > xInfo(xIFace, UNO_QUERY); 140*cdf0e10cSrcweir if (xInfo.is() && (xInfo->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD))) 141*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED; 142*cdf0e10cSrcweir else if (!xInfo.is()) 143*cdf0e10cSrcweir { 144*cdf0e10cSrcweir // couldn't distinguish between formatted and edit with the service name, so try with the properties 145*cdf0e10cSrcweir Reference< XPropertySet > xProps(xIFace, UNO_QUERY); 146*cdf0e10cSrcweir if (xProps.is()) 147*cdf0e10cSrcweir { 148*cdf0e10cSrcweir Reference< XPropertySetInfo > xPropsInfo = xProps->getPropertySetInfo(); 149*cdf0e10cSrcweir if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER)) 150*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_FORMATTED; 151*cdf0e10cSrcweir } 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir } 154*cdf0e10cSrcweir } 155*cdf0e10cSrcweir break; 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir case FormComponentType::COMMANDBUTTON: 158*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_PUSHBUTTON; break; 159*cdf0e10cSrcweir case FormComponentType::RADIOBUTTON: 160*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_RADIOBUTTON; break; 161*cdf0e10cSrcweir case FormComponentType::CHECKBOX: 162*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_CHECKBOX; break; 163*cdf0e10cSrcweir case FormComponentType::LISTBOX: 164*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_LISTBOX; break; 165*cdf0e10cSrcweir case FormComponentType::COMBOBOX: 166*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_COMBOBOX; break; 167*cdf0e10cSrcweir case FormComponentType::GROUPBOX: 168*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_GROUPBOX; break; 169*cdf0e10cSrcweir case FormComponentType::IMAGEBUTTON: 170*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_IMAGEBUTTON; break; 171*cdf0e10cSrcweir case FormComponentType::FIXEDTEXT: 172*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_FIXEDTEXT; break; 173*cdf0e10cSrcweir case FormComponentType::GRIDCONTROL: 174*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_DBGRID; break; 175*cdf0e10cSrcweir case FormComponentType::FILECONTROL: 176*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_FILECONTROL; break; 177*cdf0e10cSrcweir case FormComponentType::DATEFIELD: 178*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_DATEFIELD; break; 179*cdf0e10cSrcweir case FormComponentType::TIMEFIELD: 180*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_TIMEFIELD; break; 181*cdf0e10cSrcweir case FormComponentType::NUMERICFIELD: 182*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_NUMERICFIELD; break; 183*cdf0e10cSrcweir case FormComponentType::CURRENCYFIELD: 184*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_CURRENCYFIELD; break; 185*cdf0e10cSrcweir case FormComponentType::PATTERNFIELD: 186*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_PATTERNFIELD; break; 187*cdf0e10cSrcweir case FormComponentType::IMAGECONTROL: 188*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_IMAGECONTROL; break; 189*cdf0e10cSrcweir case FormComponentType::HIDDENCONTROL: 190*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_HIDDEN; break; 191*cdf0e10cSrcweir case FormComponentType::SCROLLBAR: 192*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_SCROLLBAR; break; 193*cdf0e10cSrcweir case FormComponentType::SPINBUTTON: 194*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_SPINBUTTON; break; 195*cdf0e10cSrcweir case FormComponentType::NAVIGATIONBAR: 196*cdf0e10cSrcweir nClassNameResourceId = RID_STR_PROPTITLE_NAVBAR; break; 197*cdf0e10cSrcweir case FormComponentType::CONTROL: 198*cdf0e10cSrcweir default: 199*cdf0e10cSrcweir nClassNameResourceId = RID_STR_CONTROL; break; 200*cdf0e10cSrcweir } 201*cdf0e10cSrcweir 202*cdf0e10cSrcweir if ( !nClassNameResourceId ) 203*cdf0e10cSrcweir return ::rtl::OUString(); 204*cdf0e10cSrcweir 205*cdf0e10cSrcweir return ::rtl::OUString( String( SVX_RES( nClassNameResourceId ) ) ); 206*cdf0e10cSrcweir } 207*cdf0e10cSrcweir 208*cdf0e10cSrcweir //======================================================================== 209*cdf0e10cSrcweir // class FmPropBrw 210*cdf0e10cSrcweir //======================================================================== 211*cdf0e10cSrcweir DBG_NAME(FmPropBrw); 212*cdf0e10cSrcweir //------------------------------------------------------------------------ 213*cdf0e10cSrcweir FmPropBrw::FmPropBrw( const Reference< XMultiServiceFactory >& _xORB, SfxBindings* _pBindings, 214*cdf0e10cSrcweir SfxChildWindow* _pMgr, Window* _pParent, const SfxChildWinInfo* _pInfo ) 215*cdf0e10cSrcweir :SfxFloatingWindow(_pBindings, _pMgr, _pParent, WinBits(WB_STDMODELESS|WB_SIZEABLE|WB_3DLOOK|WB_ROLLABLE) ) 216*cdf0e10cSrcweir ,SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings) 217*cdf0e10cSrcweir ,m_bInitialStateChange(sal_True) 218*cdf0e10cSrcweir ,m_bInStateChange( false ) 219*cdf0e10cSrcweir ,m_xORB(_xORB) 220*cdf0e10cSrcweir { 221*cdf0e10cSrcweir DBG_CTOR(FmPropBrw,NULL); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir ::Size aPropWinSize(STD_WIN_SIZE_X,STD_WIN_SIZE_Y); 224*cdf0e10cSrcweir SetMinOutputSizePixel(::Size(STD_MIN_SIZE_X,STD_MIN_SIZE_Y)); 225*cdf0e10cSrcweir SetOutputSizePixel(aPropWinSize); 226*cdf0e10cSrcweir SetUniqueId(UID_FORMPROPBROWSER_FRAME); 227*cdf0e10cSrcweir 228*cdf0e10cSrcweir try 229*cdf0e10cSrcweir { 230*cdf0e10cSrcweir // create a frame wrapper for myself 231*cdf0e10cSrcweir m_xMeAsFrame = Reference< XFrame >(m_xORB->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.Frame")), UNO_QUERY); 232*cdf0e10cSrcweir if (m_xMeAsFrame.is()) 233*cdf0e10cSrcweir { 234*cdf0e10cSrcweir // create an intermediate window, which is to be the container window of the frame 235*cdf0e10cSrcweir // Do *not* use |this| as container window for the frame, this would result in undefined 236*cdf0e10cSrcweir // responsiblity for this window (as soon as we initialize a frame with a window, the frame 237*cdf0e10cSrcweir // is responsible for it's life time, but |this| is controlled by the belonging SfxChildWindow) 238*cdf0e10cSrcweir // #i34249# - 2004-09-27 - fs@openoffice.org 239*cdf0e10cSrcweir Window* pContainerWindow = new Window( this ); 240*cdf0e10cSrcweir pContainerWindow->Show(); 241*cdf0e10cSrcweir m_xFrameContainerWindow = VCLUnoHelper::GetInterface ( pContainerWindow ); 242*cdf0e10cSrcweir 243*cdf0e10cSrcweir m_xMeAsFrame->initialize( m_xFrameContainerWindow ); 244*cdf0e10cSrcweir m_xMeAsFrame->setName(::rtl::OUString::createFromAscii("form property browser")); 245*cdf0e10cSrcweir if ( _pBindings->GetDispatcher() ) 246*cdf0e10cSrcweir { 247*cdf0e10cSrcweir ::com::sun::star::uno::Reference < ::com::sun::star::frame::XFramesSupplier > 248*cdf0e10cSrcweir xSupp ( _pBindings->GetDispatcher()->GetFrame()->GetFrame().GetFrameInterface(), ::com::sun::star::uno::UNO_QUERY ); 249*cdf0e10cSrcweir // if ( xSupp.is() ) 250*cdf0e10cSrcweir // xSupp->getFrames()->append( m_xMeAsFrame ); 251*cdf0e10cSrcweir // Don't append frame to frame hierachy to prevent UI_DEACTIVATE messages 252*cdf0e10cSrcweir // #i31834# - 2004-07-27 - cd@openoffice.org 253*cdf0e10cSrcweir } 254*cdf0e10cSrcweir } 255*cdf0e10cSrcweir } 256*cdf0e10cSrcweir catch (Exception&) 257*cdf0e10cSrcweir { 258*cdf0e10cSrcweir DBG_ERROR("FmPropBrw::FmPropBrw: could not create/initialize my frame!"); 259*cdf0e10cSrcweir m_xMeAsFrame.clear(); 260*cdf0e10cSrcweir } 261*cdf0e10cSrcweir 262*cdf0e10cSrcweir if (m_xMeAsFrame.is()) 263*cdf0e10cSrcweir _pMgr->SetFrame( m_xMeAsFrame ); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir 266*cdf0e10cSrcweir if ( m_xBrowserComponentWindow.is() ) 267*cdf0e10cSrcweir m_xBrowserComponentWindow->setVisible( sal_True ); 268*cdf0e10cSrcweir 269*cdf0e10cSrcweir if ( _pInfo ) 270*cdf0e10cSrcweir m_sLastActivePage = _pInfo->aExtraString; 271*cdf0e10cSrcweir } 272*cdf0e10cSrcweir 273*cdf0e10cSrcweir //------------------------------------------------------------------------ 274*cdf0e10cSrcweir void FmPropBrw::Resize() 275*cdf0e10cSrcweir { 276*cdf0e10cSrcweir SfxFloatingWindow::Resize(); 277*cdf0e10cSrcweir 278*cdf0e10cSrcweir if ( m_xFrameContainerWindow.is() ) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir try 281*cdf0e10cSrcweir { 282*cdf0e10cSrcweir ::Size aOutputSize( GetOutputSizePixel() ); 283*cdf0e10cSrcweir m_xFrameContainerWindow->setPosSize( 0, 0, aOutputSize.Width(), aOutputSize.Height(), awt::PosSize::POSSIZE ); 284*cdf0e10cSrcweir } 285*cdf0e10cSrcweir catch( const Exception& ) 286*cdf0e10cSrcweir { 287*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::Resize: caught an exception!" ); 288*cdf0e10cSrcweir } 289*cdf0e10cSrcweir } 290*cdf0e10cSrcweir } 291*cdf0e10cSrcweir 292*cdf0e10cSrcweir //------------------------------------------------------------------------ 293*cdf0e10cSrcweir FmPropBrw::~FmPropBrw() 294*cdf0e10cSrcweir { 295*cdf0e10cSrcweir if (m_xBrowserController.is()) 296*cdf0e10cSrcweir implDetachController(); 297*cdf0e10cSrcweir try 298*cdf0e10cSrcweir { 299*cdf0e10cSrcweir // remove our own properties from the component context. We cannot ensure that the component context 300*cdf0e10cSrcweir // is freed (there might be refcount problems :-\), so at least ensure the context itself 301*cdf0e10cSrcweir // does hold the objects anymore 302*cdf0e10cSrcweir Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY); 303*cdf0e10cSrcweir if ( xName.is() ) 304*cdf0e10cSrcweir { 305*cdf0e10cSrcweir const ::rtl::OUString pProps[] = { ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ) 306*cdf0e10cSrcweir , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ) 307*cdf0e10cSrcweir , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ) 308*cdf0e10cSrcweir , ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ) }; 309*cdf0e10cSrcweir for ( size_t i = 0; i < sizeof(pProps)/sizeof(pProps[0]); ++i ) 310*cdf0e10cSrcweir xName->removeByName( pProps[i] ); 311*cdf0e10cSrcweir } 312*cdf0e10cSrcweir } 313*cdf0e10cSrcweir catch (const Exception& ) 314*cdf0e10cSrcweir { 315*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 316*cdf0e10cSrcweir } 317*cdf0e10cSrcweir DBG_DTOR(FmPropBrw,NULL); 318*cdf0e10cSrcweir } 319*cdf0e10cSrcweir 320*cdf0e10cSrcweir //----------------------------------------------------------------------- 321*cdf0e10cSrcweir ::rtl::OUString FmPropBrw::getCurrentPage() const 322*cdf0e10cSrcweir { 323*cdf0e10cSrcweir ::rtl::OUString sCurrentPage; 324*cdf0e10cSrcweir try 325*cdf0e10cSrcweir { 326*cdf0e10cSrcweir if ( m_xBrowserController.is() ) 327*cdf0e10cSrcweir { 328*cdf0e10cSrcweir OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage ); 329*cdf0e10cSrcweir } 330*cdf0e10cSrcweir 331*cdf0e10cSrcweir if ( !sCurrentPage.getLength() ) 332*cdf0e10cSrcweir sCurrentPage = m_sLastActivePage; 333*cdf0e10cSrcweir } 334*cdf0e10cSrcweir catch( const Exception& ) 335*cdf0e10cSrcweir { 336*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::getCurrentPage: caught an exception while retrieving the current page!" ); 337*cdf0e10cSrcweir } 338*cdf0e10cSrcweir return sCurrentPage; 339*cdf0e10cSrcweir } 340*cdf0e10cSrcweir 341*cdf0e10cSrcweir //----------------------------------------------------------------------- 342*cdf0e10cSrcweir void FmPropBrw::implDetachController() 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir m_sLastActivePage = getCurrentPage(); 345*cdf0e10cSrcweir 346*cdf0e10cSrcweir implSetNewSelection( InterfaceBag() ); 347*cdf0e10cSrcweir 348*cdf0e10cSrcweir if ( m_xMeAsFrame.is() ) 349*cdf0e10cSrcweir { 350*cdf0e10cSrcweir try 351*cdf0e10cSrcweir { 352*cdf0e10cSrcweir m_xMeAsFrame->setComponent(NULL, NULL); 353*cdf0e10cSrcweir } 354*cdf0e10cSrcweir catch( const Exception& ) 355*cdf0e10cSrcweir { 356*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::implDetachController: caught an exception while resetting the component!" ); 357*cdf0e10cSrcweir } 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir 360*cdf0e10cSrcweir // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too 361*cdf0e10cSrcweir // 96068 - 09.01.2002 - fs@openoffice.org 362*cdf0e10cSrcweir if ( m_xBrowserController.is() ) 363*cdf0e10cSrcweir m_xBrowserController->attachFrame( NULL ); 364*cdf0e10cSrcweir 365*cdf0e10cSrcweir m_xBrowserController.clear(); 366*cdf0e10cSrcweir m_xInspectorModel.clear(); 367*cdf0e10cSrcweir m_xMeAsFrame.clear(); 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir //----------------------------------------------------------------------- 371*cdf0e10cSrcweir sal_Bool FmPropBrw::Close() 372*cdf0e10cSrcweir { 373*cdf0e10cSrcweir // suspend the controller (it is allowed to veto) 374*cdf0e10cSrcweir if ( m_xMeAsFrame.is() ) 375*cdf0e10cSrcweir { 376*cdf0e10cSrcweir try 377*cdf0e10cSrcweir { 378*cdf0e10cSrcweir Reference< XController > xController( m_xMeAsFrame->getController() ); 379*cdf0e10cSrcweir if ( xController.is() && !xController->suspend( sal_True ) ) 380*cdf0e10cSrcweir return sal_False; 381*cdf0e10cSrcweir } 382*cdf0e10cSrcweir catch( const Exception& ) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::Close: caught an exception while asking the controller!" ); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir 388*cdf0e10cSrcweir implDetachController(); 389*cdf0e10cSrcweir 390*cdf0e10cSrcweir if( IsRollUp() ) 391*cdf0e10cSrcweir RollDown(); 392*cdf0e10cSrcweir 393*cdf0e10cSrcweir // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this 394*cdf0e10cSrcweir // would be deadly 395*cdf0e10cSrcweir // 10/19/00 - 79321 - FS 396*cdf0e10cSrcweir SfxBindings& rBindings = SfxControllerItem::GetBindings(); 397*cdf0e10cSrcweir 398*cdf0e10cSrcweir sal_Bool bClose = SfxFloatingWindow::Close(); 399*cdf0e10cSrcweir 400*cdf0e10cSrcweir if (bClose) 401*cdf0e10cSrcweir { 402*cdf0e10cSrcweir rBindings.Invalidate(SID_FM_CTL_PROPERTIES); 403*cdf0e10cSrcweir rBindings.Invalidate(SID_FM_PROPERTIES); 404*cdf0e10cSrcweir } 405*cdf0e10cSrcweir 406*cdf0e10cSrcweir return bClose; 407*cdf0e10cSrcweir } 408*cdf0e10cSrcweir 409*cdf0e10cSrcweir //----------------------------------------------------------------------- 410*cdf0e10cSrcweir bool FmPropBrw::implIsReadOnlyModel() const 411*cdf0e10cSrcweir { 412*cdf0e10cSrcweir try 413*cdf0e10cSrcweir { 414*cdf0e10cSrcweir if ( m_xInspectorModel.is() ) 415*cdf0e10cSrcweir return m_xInspectorModel->getIsReadOnly(); 416*cdf0e10cSrcweir return false; 417*cdf0e10cSrcweir } 418*cdf0e10cSrcweir catch( const Exception& ) 419*cdf0e10cSrcweir { 420*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 421*cdf0e10cSrcweir } 422*cdf0e10cSrcweir return true; 423*cdf0e10cSrcweir } 424*cdf0e10cSrcweir 425*cdf0e10cSrcweir //----------------------------------------------------------------------- 426*cdf0e10cSrcweir void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection ) 427*cdf0e10cSrcweir { 428*cdf0e10cSrcweir if ( m_xBrowserController.is() ) 429*cdf0e10cSrcweir { 430*cdf0e10cSrcweir try 431*cdf0e10cSrcweir { 432*cdf0e10cSrcweir Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW ); 433*cdf0e10cSrcweir 434*cdf0e10cSrcweir // tell it the objects to inspect 435*cdf0e10cSrcweir Sequence< Reference< XInterface > > aSelection( _rSelection.size() ); 436*cdf0e10cSrcweir ::std::copy( _rSelection.begin(), _rSelection.end(), aSelection.getArray() ); 437*cdf0e10cSrcweir 438*cdf0e10cSrcweir xInspector->inspect( aSelection ); 439*cdf0e10cSrcweir } 440*cdf0e10cSrcweir catch( const VetoException& ) 441*cdf0e10cSrcweir { 442*cdf0e10cSrcweir return; 443*cdf0e10cSrcweir } 444*cdf0e10cSrcweir catch( const Exception& ) 445*cdf0e10cSrcweir { 446*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::implSetNewSelection: caught an unexpected exception!" ); 447*cdf0e10cSrcweir return; 448*cdf0e10cSrcweir } 449*cdf0e10cSrcweir 450*cdf0e10cSrcweir // set the new title according to the selected object 451*cdf0e10cSrcweir String sTitle; 452*cdf0e10cSrcweir 453*cdf0e10cSrcweir if ( _rSelection.empty() ) 454*cdf0e10cSrcweir { 455*cdf0e10cSrcweir sTitle = String( SVX_RES( RID_STR_NO_PROPERTIES ) ); 456*cdf0e10cSrcweir } 457*cdf0e10cSrcweir else if ( _rSelection.size() > 1 ) 458*cdf0e10cSrcweir { 459*cdf0e10cSrcweir // no form component and (no form or no name) -> Multiselection 460*cdf0e10cSrcweir sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) ); 461*cdf0e10cSrcweir sTitle += String( SVX_RES( RID_STR_PROPTITLE_MULTISELECT ) ); 462*cdf0e10cSrcweir } 463*cdf0e10cSrcweir else 464*cdf0e10cSrcweir { 465*cdf0e10cSrcweir Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY); 466*cdf0e10cSrcweir if ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) ) 467*cdf0e10cSrcweir { 468*cdf0e10cSrcweir sal_Int16 nClassID = FormComponentType::CONTROL; 469*cdf0e10cSrcweir xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID; 470*cdf0e10cSrcweir 471*cdf0e10cSrcweir sTitle = String( SVX_RES( RID_STR_PROPERTIES_CONTROL ) ); 472*cdf0e10cSrcweir sTitle += String( GetUIHeadlineName( nClassID, makeAny( xSingleSelection ) ) ); 473*cdf0e10cSrcweir } 474*cdf0e10cSrcweir else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() ) 475*cdf0e10cSrcweir sTitle = String( SVX_RES( RID_STR_PROPERTIES_FORM ) ); 476*cdf0e10cSrcweir } 477*cdf0e10cSrcweir 478*cdf0e10cSrcweir if ( implIsReadOnlyModel() ) 479*cdf0e10cSrcweir sTitle += String( SVX_RES( RID_STR_READONLY_VIEW ) ); 480*cdf0e10cSrcweir 481*cdf0e10cSrcweir SetText( sTitle ); 482*cdf0e10cSrcweir 483*cdf0e10cSrcweir // #95343# --------------------------------- 484*cdf0e10cSrcweir Reference< ::com::sun::star::awt::XLayoutConstrains > xLayoutConstrains( m_xBrowserController, UNO_QUERY ); 485*cdf0e10cSrcweir if( xLayoutConstrains.is() ) 486*cdf0e10cSrcweir { 487*cdf0e10cSrcweir ::Size aConstrainedSize; 488*cdf0e10cSrcweir ::com::sun::star::awt::Size aMinSize = xLayoutConstrains->getMinimumSize(); 489*cdf0e10cSrcweir 490*cdf0e10cSrcweir sal_Int32 nLeft(0), nTop(0), nRight(0), nBottom(0); 491*cdf0e10cSrcweir GetBorder( nLeft, nTop, nRight, nBottom ); 492*cdf0e10cSrcweir aMinSize.Width += nLeft + nRight + 8; 493*cdf0e10cSrcweir aMinSize.Height += nTop + nBottom + 8; 494*cdf0e10cSrcweir 495*cdf0e10cSrcweir aConstrainedSize.setHeight( aMinSize.Height ); 496*cdf0e10cSrcweir aConstrainedSize.setWidth( aMinSize.Width ); 497*cdf0e10cSrcweir SetMinOutputSizePixel( aConstrainedSize ); 498*cdf0e10cSrcweir aConstrainedSize = GetOutputSizePixel(); 499*cdf0e10cSrcweir sal_Bool bResize = sal_False; 500*cdf0e10cSrcweir if( aConstrainedSize.Width() < aMinSize.Width ) 501*cdf0e10cSrcweir { 502*cdf0e10cSrcweir aConstrainedSize.setWidth( aMinSize.Width ); 503*cdf0e10cSrcweir bResize = sal_True; 504*cdf0e10cSrcweir } 505*cdf0e10cSrcweir if( aConstrainedSize.Height() < aMinSize.Height ) 506*cdf0e10cSrcweir { 507*cdf0e10cSrcweir aConstrainedSize.setHeight( aMinSize.Height ); 508*cdf0e10cSrcweir bResize = sal_True; 509*cdf0e10cSrcweir } 510*cdf0e10cSrcweir if( bResize ) 511*cdf0e10cSrcweir SetOutputSizePixel( aConstrainedSize ); 512*cdf0e10cSrcweir } 513*cdf0e10cSrcweir } 514*cdf0e10cSrcweir } 515*cdf0e10cSrcweir 516*cdf0e10cSrcweir //----------------------------------------------------------------------- 517*cdf0e10cSrcweir void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const 518*cdf0e10cSrcweir { 519*cdf0e10cSrcweir rInfo.bVisible = sal_False; 520*cdf0e10cSrcweir rInfo.aExtraString = getCurrentPage(); 521*cdf0e10cSrcweir } 522*cdf0e10cSrcweir 523*cdf0e10cSrcweir //----------------------------------------------------------------------- 524*cdf0e10cSrcweir IMPL_LINK( FmPropBrw, OnAsyncGetFocus, void*, /*NOTINTERESTEDIN*/ ) 525*cdf0e10cSrcweir { 526*cdf0e10cSrcweir if (m_xBrowserComponentWindow.is()) 527*cdf0e10cSrcweir m_xBrowserComponentWindow->setFocus(); 528*cdf0e10cSrcweir return 0L; 529*cdf0e10cSrcweir } 530*cdf0e10cSrcweir 531*cdf0e10cSrcweir //----------------------------------------------------------------------- 532*cdf0e10cSrcweir namespace 533*cdf0e10cSrcweir { 534*cdf0e10cSrcweir static bool lcl_shouldEnableHelpSection( const Reference< XMultiServiceFactory >& _rxFactory ) 535*cdf0e10cSrcweir { 536*cdf0e10cSrcweir const ::rtl::OUString sConfigName( RTL_CONSTASCII_USTRINGPARAM( "/org.openoffice.Office.Common/Forms/PropertyBrowser/" ) ); 537*cdf0e10cSrcweir const ::rtl::OUString sPropertyName( RTL_CONSTASCII_USTRINGPARAM( "DirectHelp" ) ); 538*cdf0e10cSrcweir 539*cdf0e10cSrcweir ::utl::OConfigurationTreeRoot aConfiguration( 540*cdf0e10cSrcweir ::utl::OConfigurationTreeRoot::createWithServiceFactory( _rxFactory, sConfigName ) ); 541*cdf0e10cSrcweir 542*cdf0e10cSrcweir bool bEnabled = false; 543*cdf0e10cSrcweir OSL_VERIFY( aConfiguration.getNodeValue( sPropertyName ) >>= bEnabled ); 544*cdf0e10cSrcweir return bEnabled; 545*cdf0e10cSrcweir } 546*cdf0e10cSrcweir } 547*cdf0e10cSrcweir //----------------------------------------------------------------------- 548*cdf0e10cSrcweir void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell ) 549*cdf0e10cSrcweir { 550*cdf0e10cSrcweir // the document in which we live 551*cdf0e10cSrcweir Reference< XInterface > xDocument; 552*cdf0e10cSrcweir if ( _pFormShell && _pFormShell->GetObjectShell() ) 553*cdf0e10cSrcweir xDocument = _pFormShell->GetObjectShell()->GetModel(); 554*cdf0e10cSrcweir 555*cdf0e10cSrcweir // the context of the controls in our document 556*cdf0e10cSrcweir Reference< awt::XControlContainer > xControlContext; 557*cdf0e10cSrcweir if ( _pFormShell && _pFormShell->GetFormView() ) 558*cdf0e10cSrcweir { 559*cdf0e10cSrcweir SdrPageView* pPageView = _pFormShell->GetFormView()->GetSdrPageView(); 560*cdf0e10cSrcweir 561*cdf0e10cSrcweir if(pPageView) 562*cdf0e10cSrcweir { 563*cdf0e10cSrcweir SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0L); 564*cdf0e10cSrcweir 565*cdf0e10cSrcweir if(pPageWindow) 566*cdf0e10cSrcweir { 567*cdf0e10cSrcweir xControlContext = pPageWindow->GetControlContainer(); 568*cdf0e10cSrcweir } 569*cdf0e10cSrcweir } 570*cdf0e10cSrcweir } 571*cdf0e10cSrcweir 572*cdf0e10cSrcweir // the default parent window for message boxes 573*cdf0e10cSrcweir Reference< XWindow > xParentWindow( VCLUnoHelper::GetInterface ( this ) ); 574*cdf0e10cSrcweir 575*cdf0e10cSrcweir // the mapping from control models to control shapes 576*cdf0e10cSrcweir Reference< XMap > xControlMap; 577*cdf0e10cSrcweir FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : NULL; 578*cdf0e10cSrcweir if ( pFormPage ) 579*cdf0e10cSrcweir xControlMap = pFormPage->GetImpl().getControlToShapeMap(); 580*cdf0e10cSrcweir 581*cdf0e10cSrcweir // our own component context 582*cdf0e10cSrcweir Reference< XPropertySet > xFactoryProperties( m_xORB, UNO_QUERY_THROW ); 583*cdf0e10cSrcweir Reference< XComponentContext > xOwnContext( 584*cdf0e10cSrcweir xFactoryProperties->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ), 585*cdf0e10cSrcweir UNO_QUERY_THROW ); 586*cdf0e10cSrcweir 587*cdf0e10cSrcweir // a ComponentContext for the 588*cdf0e10cSrcweir ::cppu::ContextEntry_Init aHandlerContextInfo[] = 589*cdf0e10cSrcweir { 590*cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ContextDocument" ) ), makeAny( xDocument ) ), 591*cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DialogParentWindow" ) ), makeAny( xParentWindow ) ), 592*cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlContext" ) ), makeAny( xControlContext ) ), 593*cdf0e10cSrcweir ::cppu::ContextEntry_Init( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ControlShapeAccess" ) ), makeAny( xControlMap ) ) 594*cdf0e10cSrcweir }; 595*cdf0e10cSrcweir m_xInspectorContext.set( 596*cdf0e10cSrcweir ::cppu::createComponentContext( aHandlerContextInfo, sizeof( aHandlerContextInfo ) / sizeof( aHandlerContextInfo[0] ), 597*cdf0e10cSrcweir xOwnContext ) ); 598*cdf0e10cSrcweir 599*cdf0e10cSrcweir bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB ); 600*cdf0e10cSrcweir 601*cdf0e10cSrcweir // an object inspector model 602*cdf0e10cSrcweir m_xInspectorModel = 603*cdf0e10cSrcweir bEnableHelpSection 604*cdf0e10cSrcweir ? DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 5 ) 605*cdf0e10cSrcweir : DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext ); 606*cdf0e10cSrcweir 607*cdf0e10cSrcweir // an object inspector 608*cdf0e10cSrcweir m_xBrowserController = m_xBrowserController.query( 609*cdf0e10cSrcweir ObjectInspector::createWithModel( 610*cdf0e10cSrcweir m_xInspectorContext, m_xInspectorModel 611*cdf0e10cSrcweir ) ); 612*cdf0e10cSrcweir 613*cdf0e10cSrcweir if ( !m_xBrowserController.is() ) 614*cdf0e10cSrcweir { 615*cdf0e10cSrcweir ::rtl::OUString sServiceName( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.inspection.ObjectInspector" ) ); 616*cdf0e10cSrcweir ShowServiceNotAvailableError( GetParent(), sServiceName, sal_True ); 617*cdf0e10cSrcweir } 618*cdf0e10cSrcweir else 619*cdf0e10cSrcweir { 620*cdf0e10cSrcweir m_xBrowserController->attachFrame( m_xMeAsFrame ); 621*cdf0e10cSrcweir m_xBrowserComponentWindow = m_xMeAsFrame->getComponentWindow(); 622*cdf0e10cSrcweir DBG_ASSERT( m_xBrowserComponentWindow.is(), "FmPropBrw::impl_createPropertyBrowser_throw: attached the controller, but have no component window!" ); 623*cdf0e10cSrcweir } 624*cdf0e10cSrcweir 625*cdf0e10cSrcweir if ( bEnableHelpSection ) 626*cdf0e10cSrcweir { 627*cdf0e10cSrcweir Reference< XObjectInspector > xInspector( m_xBrowserController, UNO_QUERY_THROW ); 628*cdf0e10cSrcweir Reference< XObjectInspectorUI > xInspectorUI( xInspector->getInspectorUI() ); 629*cdf0e10cSrcweir Reference< XInterface > xDefaultHelpProvider( DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI ) ); 630*cdf0e10cSrcweir } 631*cdf0e10cSrcweir } 632*cdf0e10cSrcweir 633*cdf0e10cSrcweir //----------------------------------------------------------------------- 634*cdf0e10cSrcweir void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell ) 635*cdf0e10cSrcweir { 636*cdf0e10cSrcweir // the document in which we live 637*cdf0e10cSrcweir Reference< XInterface > xDocument; 638*cdf0e10cSrcweir SfxObjectShell* pObjectShell = _pFormShell ? _pFormShell->GetObjectShell() : NULL; 639*cdf0e10cSrcweir if ( pObjectShell ) 640*cdf0e10cSrcweir xDocument = pObjectShell->GetModel(); 641*cdf0e10cSrcweir if ( ( xDocument == m_xLastKnownDocument ) && m_xBrowserController.is() ) 642*cdf0e10cSrcweir // nothing to do 643*cdf0e10cSrcweir return; 644*cdf0e10cSrcweir 645*cdf0e10cSrcweir try 646*cdf0e10cSrcweir { 647*cdf0e10cSrcweir // clean up any previous instances of the object inspector 648*cdf0e10cSrcweir if ( m_xMeAsFrame.is() ) 649*cdf0e10cSrcweir m_xMeAsFrame->setComponent( NULL, NULL ); 650*cdf0e10cSrcweir else 651*cdf0e10cSrcweir ::comphelper::disposeComponent( m_xBrowserController ); 652*cdf0e10cSrcweir m_xBrowserController.clear(); 653*cdf0e10cSrcweir m_xInspectorModel.clear(); 654*cdf0e10cSrcweir m_xBrowserComponentWindow.clear(); 655*cdf0e10cSrcweir 656*cdf0e10cSrcweir // and create a new one 657*cdf0e10cSrcweir impl_createPropertyBrowser_throw( _pFormShell ); 658*cdf0e10cSrcweir } 659*cdf0e10cSrcweir catch( const Exception& ) 660*cdf0e10cSrcweir { 661*cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 662*cdf0e10cSrcweir } 663*cdf0e10cSrcweir m_xLastKnownDocument = xDocument; 664*cdf0e10cSrcweir } 665*cdf0e10cSrcweir 666*cdf0e10cSrcweir //----------------------------------------------------------------------- 667*cdf0e10cSrcweir void FmPropBrw::StateChanged(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState) 668*cdf0e10cSrcweir { 669*cdf0e10cSrcweir if (!pState || SID_FM_PROPERTY_CONTROL != nSID) 670*cdf0e10cSrcweir return; 671*cdf0e10cSrcweir 672*cdf0e10cSrcweir m_bInStateChange = true; 673*cdf0e10cSrcweir try 674*cdf0e10cSrcweir { 675*cdf0e10cSrcweir if (eState >= SFX_ITEM_AVAILABLE) 676*cdf0e10cSrcweir { 677*cdf0e10cSrcweir FmFormShell* pShell = PTR_CAST(FmFormShell,((SfxObjectItem*)pState)->GetShell()); 678*cdf0e10cSrcweir InterfaceBag aSelection; 679*cdf0e10cSrcweir if ( pShell ) 680*cdf0e10cSrcweir pShell->GetImpl()->getCurrentSelection( aSelection ); 681*cdf0e10cSrcweir 682*cdf0e10cSrcweir impl_ensurePropertyBrowser_nothrow( pShell ); 683*cdf0e10cSrcweir 684*cdf0e10cSrcweir // set the new object to inspect 685*cdf0e10cSrcweir implSetNewSelection( aSelection ); 686*cdf0e10cSrcweir 687*cdf0e10cSrcweir // if this is the first time we're here, some additional things need to be done ... 688*cdf0e10cSrcweir if ( m_bInitialStateChange ) 689*cdf0e10cSrcweir { 690*cdf0e10cSrcweir // if we're just newly created, we want to have the focus 691*cdf0e10cSrcweir PostUserEvent( LINK( this, FmPropBrw, OnAsyncGetFocus ) ); 692*cdf0e10cSrcweir 693*cdf0e10cSrcweir // and additionally, we want to show the page which was active during 694*cdf0e10cSrcweir // our previous incarnation 695*cdf0e10cSrcweir if ( m_sLastActivePage.getLength() ) 696*cdf0e10cSrcweir { 697*cdf0e10cSrcweir try 698*cdf0e10cSrcweir { 699*cdf0e10cSrcweir if ( m_xBrowserController.is() ) 700*cdf0e10cSrcweir m_xBrowserController->restoreViewData( makeAny( m_sLastActivePage ) ); 701*cdf0e10cSrcweir } 702*cdf0e10cSrcweir catch( const Exception& ) 703*cdf0e10cSrcweir { 704*cdf0e10cSrcweir OSL_ENSURE( sal_False, "FmPropBrw::StateChanged: caught an exception while setting the initial page!" ); 705*cdf0e10cSrcweir } 706*cdf0e10cSrcweir } 707*cdf0e10cSrcweir 708*cdf0e10cSrcweir m_bInitialStateChange = sal_False; 709*cdf0e10cSrcweir } 710*cdf0e10cSrcweir 711*cdf0e10cSrcweir } 712*cdf0e10cSrcweir else 713*cdf0e10cSrcweir { 714*cdf0e10cSrcweir implSetNewSelection( InterfaceBag() ); 715*cdf0e10cSrcweir } 716*cdf0e10cSrcweir } 717*cdf0e10cSrcweir catch (Exception&) 718*cdf0e10cSrcweir { 719*cdf0e10cSrcweir DBG_ERROR("FmPropBrw::StateChanged: Exception occured!"); 720*cdf0e10cSrcweir } 721*cdf0e10cSrcweir m_bInStateChange = false; 722*cdf0e10cSrcweir } 723