Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/svx/source/form/fmPropBrw.cxx
Line
Count
Source
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
21
#include <sal/macros.h>
22
23
#include <fmprop.hxx>
24
#include <fmPropBrw.hxx>
25
#include <svx/strings.hrc>
26
#include <fmservs.hxx>
27
#include <fmshimp.hxx>
28
#include <fmpgeimp.hxx>
29
30
#include <svx/dialmgr.hxx>
31
#include <svx/fmpage.hxx>
32
#include <svx/fmshell.hxx>
33
#include <svx/fmview.hxx>
34
#include <svx/sdrpagewindow.hxx>
35
#include <svx/svdpagv.hxx>
36
#include <svx/svxids.hrc>
37
38
#include <com/sun/star/awt/XControlContainer.hpp>
39
#include <com/sun/star/beans/XPropertySet.hpp>
40
#include <com/sun/star/form/XForm.hpp>
41
#include <com/sun/star/form/FormComponentType.hpp>
42
#include <com/sun/star/form/inspection/DefaultFormComponentInspectorModel.hpp>
43
#include <com/sun/star/frame/Frame.hpp>
44
#include <com/sun/star/frame/XModel3.hpp>
45
#include <com/sun/star/inspection/ObjectInspector.hpp>
46
#include <com/sun/star/inspection/XObjectInspectorUI.hpp>
47
#include <com/sun/star/inspection/DefaultHelpProvider.hpp>
48
#include <com/sun/star/lang/XServiceInfo.hpp>
49
#include <com/sun/star/util/VetoException.hpp>
50
51
#include <comphelper/processfactory.hxx>
52
#include <comphelper/property.hxx>
53
#include <comphelper/sequence.hxx>
54
#include <comphelper/types.hxx>
55
#include <cppuhelper/component_context.hxx>
56
#include <o3tl/deleter.hxx>
57
#include <sfx2/bindings.hxx>
58
#include <sfx2/childwin.hxx>
59
#include <sfx2/objitem.hxx>
60
#include <sfx2/objsh.hxx>
61
#include <comphelper/diagnose_ex.hxx>
62
#include <unotools/confignode.hxx>
63
#include <vcl/stdtext.hxx>
64
#include <vcl/svapp.hxx>
65
#include <vcl/weld/Builder.hxx>
66
#include <vcl/weld/Dialog.hxx>
67
#include <vcl/weld/TransportAsXWindow.hxx>
68
#include <toolkit/controls/unocontrolcontainer.hxx>
69
70
using namespace ::com::sun::star;
71
using namespace ::com::sun::star::beans;
72
using namespace ::com::sun::star::container;
73
using namespace ::com::sun::star::form;
74
using namespace ::com::sun::star::form::inspection;
75
using namespace ::com::sun::star::frame;
76
using namespace ::com::sun::star::inspection;
77
using namespace ::com::sun::star::lang;
78
using namespace ::com::sun::star::uno;
79
using namespace ::com::sun::star::util;
80
using namespace ::svxform;
81
using ::com::sun::star::awt::XWindow;
82
83
//= FmPropBrwMgr
84
SFX_IMPL_MODELESSDIALOGCONTOLLER(FmPropBrwMgr, SID_FM_SHOW_PROPERTIES)
85
86
FmPropBrwMgr::FmPropBrwMgr( vcl::Window* _pParent, sal_uInt16 _nId,
87
                            SfxBindings* _pBindings, const SfxChildWinInfo* _pInfo)
88
0
              :SfxChildWindow(_pParent, _nId)
89
0
{
90
0
    std::shared_ptr<FmPropBrw> xControl(new FmPropBrw(::comphelper::getProcessComponentContext(), _pBindings,
91
0
                                                         this, _pParent->GetFrameWeld(), _pInfo), o3tl::default_delete<FmPropBrw>());
92
0
    SetController(std::move(xControl));
93
0
    static_cast<FmPropBrw*>(GetController().get())->Initialize( _pInfo );
94
0
}
95
96
static OUString GetUIHeadlineName(sal_Int16 nClassId, const Any& aUnoObj)
97
0
{
98
0
    TranslateId pClassNameResourceId;
99
100
0
    switch ( nClassId )
101
0
    {
102
0
        case FormComponentType::TEXTFIELD:
103
0
        {
104
0
            Reference< XInterface >  xIFace;
105
0
            aUnoObj >>= xIFace;
106
0
            pClassNameResourceId = RID_STR_PROPTITLE_EDIT;
107
0
            if (xIFace.is())
108
0
            {   // we have a chance to check if it's a formatted field model
109
0
                Reference< XServiceInfo >  xInfo(xIFace, UNO_QUERY);
110
0
                if (xInfo.is() && (xInfo->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD)))
111
0
                    pClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
112
0
                else if (!xInfo.is())
113
0
                {
114
                    // couldn't distinguish between formatted and edit with the service name, so try with the properties
115
0
                    Reference< XPropertySet >  xProps(xIFace, UNO_QUERY);
116
0
                    if (xProps.is())
117
0
                    {
118
0
                        Reference< XPropertySetInfo >  xPropsInfo = xProps->getPropertySetInfo();
119
0
                        if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
120
0
                            pClassNameResourceId = RID_STR_PROPTITLE_FORMATTED;
121
0
                    }
122
0
                }
123
0
            }
124
0
        }
125
0
        break;
126
127
0
        case FormComponentType::COMMANDBUTTON:
128
0
            pClassNameResourceId = RID_STR_PROPTITLE_PUSHBUTTON; break;
129
0
        case FormComponentType::RADIOBUTTON:
130
0
            pClassNameResourceId = RID_STR_PROPTITLE_RADIOBUTTON; break;
131
0
        case FormComponentType::CHECKBOX:
132
0
            pClassNameResourceId = RID_STR_PROPTITLE_CHECKBOX; break;
133
0
        case FormComponentType::LISTBOX:
134
0
            pClassNameResourceId = RID_STR_PROPTITLE_LISTBOX; break;
135
0
        case FormComponentType::COMBOBOX:
136
0
            pClassNameResourceId = RID_STR_PROPTITLE_COMBOBOX; break;
137
0
        case FormComponentType::GROUPBOX:
138
0
            pClassNameResourceId = RID_STR_PROPTITLE_GROUPBOX; break;
139
0
        case FormComponentType::IMAGEBUTTON:
140
0
            pClassNameResourceId = RID_STR_PROPTITLE_IMAGEBUTTON; break;
141
0
        case FormComponentType::FIXEDTEXT:
142
0
            pClassNameResourceId = RID_STR_PROPTITLE_FIXEDTEXT; break;
143
0
        case FormComponentType::GRIDCONTROL:
144
0
            pClassNameResourceId = RID_STR_PROPTITLE_DBGRID; break;
145
0
        case FormComponentType::FILECONTROL:
146
0
            pClassNameResourceId = RID_STR_PROPTITLE_FILECONTROL; break;
147
0
        case FormComponentType::DATEFIELD:
148
0
            pClassNameResourceId = RID_STR_PROPTITLE_DATEFIELD; break;
149
0
        case FormComponentType::TIMEFIELD:
150
0
            pClassNameResourceId = RID_STR_PROPTITLE_TIMEFIELD; break;
151
0
        case FormComponentType::NUMERICFIELD:
152
0
            pClassNameResourceId = RID_STR_PROPTITLE_NUMERICFIELD; break;
153
0
        case FormComponentType::CURRENCYFIELD:
154
0
            pClassNameResourceId = RID_STR_PROPTITLE_CURRENCYFIELD; break;
155
0
        case FormComponentType::PATTERNFIELD:
156
0
            pClassNameResourceId = RID_STR_PROPTITLE_PATTERNFIELD; break;
157
0
        case FormComponentType::IMAGECONTROL:
158
0
            pClassNameResourceId = RID_STR_PROPTITLE_IMAGECONTROL; break;
159
0
        case FormComponentType::HIDDENCONTROL:
160
0
            pClassNameResourceId = RID_STR_PROPTITLE_HIDDEN; break;
161
0
        case FormComponentType::SCROLLBAR:
162
0
            pClassNameResourceId = RID_STR_PROPTITLE_SCROLLBAR; break;
163
0
        case FormComponentType::SPINBUTTON:
164
0
            pClassNameResourceId = RID_STR_PROPTITLE_SPINBUTTON; break;
165
0
        case FormComponentType::NAVIGATIONBAR:
166
0
            pClassNameResourceId = RID_STR_PROPTITLE_NAVBAR; break;
167
0
        case FormComponentType::CONTROL:
168
0
        default:
169
0
            pClassNameResourceId = RID_STR_CONTROL; break;
170
0
    }
171
172
0
    return SvxResId(pClassNameResourceId);
173
0
}
174
175
FmPropBrw::FmPropBrw(const Reference< XComponentContext >& _xORB, SfxBindings* _pBindings,
176
                     SfxChildWindow* _pMgr, weld::Window* _pParent, const SfxChildWinInfo* _pInfo)
177
0
    : SfxModelessDialogController(_pBindings, _pMgr, _pParent, u"svx/ui/formpropertydialog.ui"_ustr, u"FormPropertyDialog"_ustr)
178
0
    , SfxControllerItem(SID_FM_PROPERTY_CONTROL, *_pBindings)
179
0
    , m_bInitialStateChange(true)
180
0
    , m_pParent(_pParent)
181
0
    , m_nAsyncGetFocusId(nullptr)
182
0
    , m_xContainer(m_xBuilder->weld_container(u"container"_ustr))
183
0
    , m_xORB(_xORB)
184
0
{
185
0
    m_xContainer->set_size_request(m_xContainer->get_approximate_digit_width() * 72, m_xContainer->get_text_height() * 20);
186
187
0
    try
188
0
    {
189
        // create a frame wrapper for myself
190
0
        m_xMeAsFrame = Frame::create(m_xORB);
191
192
        // transport the container area of this dialog to be the container window of the frame
193
0
        css::uno::Reference<css::awt::XWindow> xFrameContainerWindow(new weld::TransportAsXWindow(m_xContainer.get()));
194
0
        m_xMeAsFrame->initialize(xFrameContainerWindow);
195
0
        m_xMeAsFrame->setName(u"form property browser"_ustr);
196
0
    }
197
0
    catch (const Exception&)
198
0
    {
199
0
        OSL_FAIL("FmPropBrw::FmPropBrw: could not create/initialize my frame!");
200
0
        m_xMeAsFrame.clear();
201
0
    }
202
203
0
    if ( _pInfo )
204
0
        m_sLastActivePage = _pInfo->aExtraString;
205
0
}
206
207
FmPropBrw::~FmPropBrw()
208
0
{
209
0
    if (m_nAsyncGetFocusId)
210
0
    {
211
0
        Application::RemoveUserEvent(m_nAsyncGetFocusId);
212
0
        m_nAsyncGetFocusId = nullptr;
213
0
    }
214
215
0
    if (m_xBrowserController.is())
216
0
        implDetachController();
217
0
    try
218
0
    {
219
        // remove our own properties from the component context. We cannot ensure that the component context
220
        // is freed (there might be refcount problems :-\), so at least ensure the context itself
221
        // does hold the objects anymore
222
0
        Reference<XNameContainer> xName(m_xInspectorContext,uno::UNO_QUERY);
223
0
        if ( xName.is() )
224
0
        {
225
0
            const OUString pProps[] = { u"ContextDocument"_ustr
226
0
                                             , u"DialogParentWindow"_ustr
227
0
                                             , u"ControlContext"_ustr
228
0
                                             , u"ControlShapeAccess"_ustr };
229
0
            for (const auto & i : pProps)
230
0
                xName->removeByName( i );
231
0
        }
232
0
    }
233
0
    catch (const Exception& )
234
0
    {
235
0
        DBG_UNHANDLED_EXCEPTION("svx");
236
0
    }
237
0
    ::SfxControllerItem::dispose();
238
0
}
239
240
OUString FmPropBrw::getCurrentPage() const
241
0
{
242
0
    OUString sCurrentPage;
243
0
    try
244
0
    {
245
0
        if ( m_xBrowserController.is() )
246
0
        {
247
0
            OSL_VERIFY( m_xBrowserController->getViewData() >>= sCurrentPage );
248
0
        }
249
250
0
        if ( sCurrentPage.isEmpty() )
251
0
            sCurrentPage = m_sLastActivePage;
252
0
    }
253
0
    catch( const Exception& )
254
0
    {
255
0
        TOOLS_WARN_EXCEPTION("svx.form", "caught an exception while retrieving the current page!");
256
0
    }
257
0
    return sCurrentPage;
258
0
}
259
260
void FmPropBrw::implDetachController()
261
0
{
262
0
    m_sLastActivePage = getCurrentPage();
263
264
0
    implSetNewSelection( InterfaceBag() );
265
266
0
    if ( m_xMeAsFrame.is() )
267
0
    {
268
0
        try
269
0
        {
270
0
            m_xMeAsFrame->setComponent(nullptr, nullptr);
271
0
        }
272
0
        catch( const Exception& )
273
0
        {
274
0
            TOOLS_WARN_EXCEPTION("svx.form", "caught an exception while resetting the component!");
275
0
        }
276
0
    }
277
278
    // we attached a frame to the controller manually, so we need to manually tell it that it's detached, too
279
0
    if ( m_xBrowserController.is() )
280
0
    {
281
0
        m_xBrowserController->attachFrame( nullptr );
282
0
    }
283
284
0
    m_xBrowserController.clear();
285
0
    m_xInspectorModel.clear();
286
0
    m_xMeAsFrame.clear();
287
0
}
288
289
void FmPropBrw::Close()
290
0
{
291
    // suspend the controller (it is allowed to veto)
292
0
    if ( m_xMeAsFrame.is() )
293
0
    {
294
0
        try
295
0
        {
296
0
            Reference< XController > xController( m_xMeAsFrame->getController() );
297
0
            if ( xController.is() && !xController->suspend( true ) )
298
0
                return;
299
0
        }
300
0
        catch( const Exception& )
301
0
        {
302
0
            TOOLS_WARN_EXCEPTION("svx.form", "caught an exception while asking the controller!");
303
0
        }
304
0
    }
305
306
0
    implDetachController();
307
308
    // remember our bindings: while we're closed, we're deleted, too, so accessing the bindings after this
309
    // would be deadly
310
    // 10/19/00 - 79321 - FS
311
0
    SfxBindings& rBindings = SfxControllerItem::GetBindings();
312
313
0
    SfxModelessDialogController::Close();
314
315
0
    rBindings.Invalidate(SID_FM_CTL_PROPERTIES);
316
0
    rBindings.Invalidate(SID_FM_PROPERTIES);
317
0
}
318
319
bool FmPropBrw::implIsReadOnlyModel() const
320
0
{
321
0
    try
322
0
    {
323
0
        if ( m_xInspectorModel.is() )
324
0
            return m_xInspectorModel->getIsReadOnly();
325
0
        return false;
326
0
    }
327
0
    catch( const Exception& )
328
0
    {
329
0
        DBG_UNHANDLED_EXCEPTION("svx");
330
0
    }
331
0
    return true;
332
0
}
333
334
335
void FmPropBrw::implSetNewSelection( const InterfaceBag& _rSelection )
336
0
{
337
0
    if ( !m_xBrowserController.is() )
338
0
        return;
339
340
0
    try
341
0
    {
342
        // tell it the objects to inspect
343
0
        m_xBrowserController->inspect(comphelper::containerToSequence(_rSelection));
344
0
    }
345
0
    catch( const VetoException& )
346
0
    {
347
0
        return;
348
0
    }
349
0
    catch( const Exception& )
350
0
    {
351
0
        TOOLS_WARN_EXCEPTION("svx.form", "");
352
0
        return;
353
0
    }
354
355
    // set the new title according to the selected object
356
0
    OUString sTitle;
357
358
0
    if ( _rSelection.empty() )
359
0
    {
360
0
        sTitle = SvxResId(RID_STR_NO_PROPERTIES);
361
0
    }
362
0
    else if ( _rSelection.size() > 1 )
363
0
    {
364
        // no form component and (no form or no name) -> Multiselection
365
0
        sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) +
366
0
            SvxResId(RID_STR_PROPTITLE_MULTISELECT);
367
0
    }
368
0
    else
369
0
    {
370
0
        Reference< XPropertySet > xSingleSelection( *_rSelection.begin(), UNO_QUERY);
371
0
        if  ( ::comphelper::hasProperty( FM_PROP_CLASSID, xSingleSelection ) )
372
0
        {
373
0
            sal_Int16 nClassID = FormComponentType::CONTROL;
374
0
            xSingleSelection->getPropertyValue( FM_PROP_CLASSID ) >>= nClassID;
375
376
0
            sTitle = SvxResId(RID_STR_PROPERTIES_CONTROL) +
377
0
                GetUIHeadlineName(nClassID, Any(xSingleSelection));
378
0
        }
379
0
        else if ( Reference< XForm >( xSingleSelection, UNO_QUERY ).is() )
380
0
            sTitle = SvxResId(RID_STR_PROPERTIES_FORM);
381
0
    }
382
383
0
    if ( implIsReadOnlyModel() )
384
0
        sTitle += SvxResId(RID_STR_READONLY_VIEW);
385
386
0
    m_xDialog->set_title(sTitle);
387
0
}
388
389
void FmPropBrw::FillInfo( SfxChildWinInfo& rInfo ) const
390
0
{
391
0
    rInfo.bVisible = false;
392
0
    rInfo.aExtraString = getCurrentPage();
393
0
}
394
395
IMPL_LINK_NOARG( FmPropBrw, OnAsyncGetFocus, void*, void )
396
0
{
397
0
    m_xDialog->child_grab_focus();
398
0
    m_nAsyncGetFocusId = nullptr;
399
0
}
400
401
namespace
402
{
403
    bool lcl_shouldEnableHelpSection( const Reference< XComponentContext >& _rxContext )
404
0
    {
405
0
        ::utl::OConfigurationTreeRoot aConfiguration(
406
0
            ::utl::OConfigurationTreeRoot::createWithComponentContext(
407
0
                _rxContext,
408
0
                u"/org.openoffice.Office.Common/Forms/PropertyBrowser/"_ustr ) );
409
410
0
        bool bEnabled = false;
411
0
        OSL_VERIFY( aConfiguration.getNodeValue( u"DirectHelp"_ustr ) >>= bEnabled );
412
0
        return bEnabled;
413
0
    }
414
}
415
416
void FmPropBrw::impl_createPropertyBrowser_throw( FmFormShell* _pFormShell )
417
0
{
418
    // the document in which we live
419
0
    Reference< XInterface > xDocument;
420
0
    if ( _pFormShell && _pFormShell->GetObjectShell() )
421
0
        xDocument = _pFormShell->GetObjectShell()->GetModel();
422
423
    // the context of the controls in our document
424
0
    rtl::Reference< UnoControlContainer > xControlContext;
425
0
    if ( _pFormShell && _pFormShell->GetFormView() )
426
0
    {
427
0
        SdrPageView* pPageView = _pFormShell->GetFormView()->GetSdrPageView();
428
429
0
        if(pPageView)
430
0
        {
431
0
            SdrPageWindow* pPageWindow = pPageView->GetPageWindow(0);
432
433
0
            if(pPageWindow)
434
0
            {
435
0
                xControlContext = pPageWindow->GetControlContainer();
436
0
            }
437
0
        }
438
0
    }
439
440
    // the default parent window for message boxes
441
0
    Reference< XWindow > xParentWindow(m_xDialog->GetXWindow());
442
443
    // the mapping from control models to control shapes
444
0
    Reference< XMap > xControlMap;
445
0
    FmFormPage* pFormPage = _pFormShell ? _pFormShell->GetCurPage() : nullptr;
446
0
    if ( pFormPage )
447
0
        xControlMap = pFormPage->GetImpl().getControlToShapeMap();
448
449
    // our own component context
450
451
    // a ComponentContext for the
452
0
    ::cppu::ContextEntry_Init aHandlerContextInfo[] =
453
0
    {
454
0
        ::cppu::ContextEntry_Init( u"ContextDocument"_ustr, Any( xDocument ) ),
455
0
        ::cppu::ContextEntry_Init( u"DialogParentWindow"_ustr, Any( xParentWindow ) ),
456
0
        ::cppu::ContextEntry_Init( u"ControlContext"_ustr, Any( Reference<awt::XControlContainer>(xControlContext) ) ),
457
0
        ::cppu::ContextEntry_Init( u"ControlShapeAccess"_ustr, Any( xControlMap ) )
458
0
    };
459
0
    m_xInspectorContext.set(
460
0
        ::cppu::createComponentContext( aHandlerContextInfo, SAL_N_ELEMENTS( aHandlerContextInfo ),
461
0
        m_xORB ) );
462
463
0
    bool bEnableHelpSection = lcl_shouldEnableHelpSection( m_xORB );
464
465
    // an object inspector model
466
0
    m_xInspectorModel =
467
0
            bEnableHelpSection
468
0
        ?   DefaultFormComponentInspectorModel::createWithHelpSection( m_xInspectorContext, 3, 5 )
469
0
        :   DefaultFormComponentInspectorModel::createDefault( m_xInspectorContext );
470
471
    // an object inspector
472
0
    m_xBrowserController =
473
0
        ObjectInspector::createWithModel(
474
0
            m_xInspectorContext, m_xInspectorModel
475
0
        );
476
477
0
    if ( !m_xBrowserController.is() )
478
0
    {
479
0
        ShowServiceNotAvailableError(m_pParent, u"com.sun.star.inspection.ObjectInspector", true);
480
0
    }
481
0
    else
482
0
    {
483
0
        m_xBrowserController->attachFrame(m_xMeAsFrame);
484
0
    }
485
486
0
    if ( bEnableHelpSection )
487
0
    {
488
0
        Reference<XObjectInspectorUI> xInspectorUI = m_xBrowserController->getInspectorUI();
489
0
        DefaultHelpProvider::create( m_xInspectorContext, xInspectorUI );
490
0
    }
491
0
}
492
493
494
void FmPropBrw::impl_ensurePropertyBrowser_nothrow( FmFormShell* _pFormShell )
495
0
{
496
    // the document in which we live
497
0
    Reference< XInterface > xDocument;
498
0
    SfxObjectShell* pObjectShell = _pFormShell ? _pFormShell->GetObjectShell() : nullptr;
499
0
    if ( pObjectShell )
500
0
        xDocument = pObjectShell->GetModel();
501
0
    if ( ( xDocument == m_xLastKnownDocument ) && m_xBrowserController.is() )
502
        // nothing to do
503
0
        return;
504
505
0
    try
506
0
    {
507
        // clean up any previous instances of the object inspector
508
0
        if ( m_xMeAsFrame.is() )
509
0
            m_xMeAsFrame->setComponent( nullptr, nullptr );
510
0
        else
511
0
            ::comphelper::disposeComponent( m_xBrowserController );
512
0
        m_xBrowserController.clear();
513
0
        m_xInspectorModel.clear();
514
515
        // and create a new one
516
0
        impl_createPropertyBrowser_throw( _pFormShell );
517
0
    }
518
0
    catch( const Exception& )
519
0
    {
520
0
        DBG_UNHANDLED_EXCEPTION("svx");
521
0
    }
522
0
    m_xLastKnownDocument = std::move(xDocument);
523
0
}
524
525
526
void FmPropBrw::StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState)
527
0
{
528
0
    if (!pState  || SID_FM_PROPERTY_CONTROL != nSID)
529
0
        return;
530
531
0
    try
532
0
    {
533
0
        if (eState >= SfxItemState::DEFAULT)
534
0
        {
535
0
            FmFormShell* pShell = dynamic_cast<FmFormShell*>( static_cast<const SfxObjectItem*>(pState)->GetShell() );
536
0
            InterfaceBag aSelection;
537
0
            if ( pShell )
538
0
                aSelection = pShell->GetImpl()->getCurrentSelection_Lock();
539
540
0
            impl_ensurePropertyBrowser_nothrow( pShell );
541
542
            // set the new object to inspect
543
0
            implSetNewSelection( aSelection );
544
545
            // if this is the first time we're here, some additional things need to be done ...
546
0
            if ( m_bInitialStateChange )
547
0
            {
548
                // if we're just newly created, we want to have the focus
549
0
                m_nAsyncGetFocusId = Application::PostUserEvent(LINK(this, FmPropBrw, OnAsyncGetFocus));
550
551
                // and additionally, we want to show the page which was active during
552
                // our previous incarnation
553
0
                if ( !m_sLastActivePage.isEmpty() )
554
0
                {
555
0
                    try
556
0
                    {
557
0
                        if ( m_xBrowserController.is() )
558
0
                            m_xBrowserController->restoreViewData( Any( m_sLastActivePage ) );
559
0
                    }
560
0
                    catch( const Exception& )
561
0
                    {
562
0
                        TOOLS_WARN_EXCEPTION("svx.form",
563
0
                                             "caught an exception while setting the initial page!");
564
0
                    }
565
0
                }
566
567
0
                m_bInitialStateChange = false;
568
0
            }
569
570
0
        }
571
0
        else
572
0
        {
573
0
            implSetNewSelection( InterfaceBag() );
574
0
        }
575
0
    }
576
0
    catch (Exception&)
577
0
    {
578
0
        TOOLS_WARN_EXCEPTION("svx.form", "");
579
0
    }
580
0
}
581
582
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */