Coverage Report

Created: 2025-07-07 10:01

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