Coverage Report

Created: 2026-03-31 11:00

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