Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/view/frame.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
#include <com/sun/star/uno/Reference.h>
21
#include <com/sun/star/awt/XTopWindow.hpp>
22
#include <com/sun/star/awt/XWindow.hpp>
23
#include <com/sun/star/util/XCloseable.hpp>
24
#include <com/sun/star/util/CloseVetoException.hpp>
25
#include <com/sun/star/lang/DisposedException.hpp>
26
#include <com/sun/star/container/XChild.hpp>
27
#include <com/sun/star/embed/XEmbeddedObject.hpp>
28
#include <com/sun/star/frame/XModel3.hpp>
29
30
#include <svl/intitem.hxx>
31
#include <svl/itemset.hxx>
32
#include <svl/stritem.hxx>
33
#include <tools/debug.hxx>
34
#include <tools/svborder.hxx>
35
#include <comphelper/diagnose_ex.hxx>
36
37
#include <appdata.hxx>
38
#include <sfx2/app.hxx>
39
#include <sfx2/event.hxx>
40
#include <sfx2/frame.hxx>
41
#include <sfx2/objsh.hxx>
42
#include <sfx2/dispatch.hxx>
43
#include <sfx2/docfile.hxx>
44
#include <sfx2/docfilt.hxx>
45
#include <sfx2/frmdescr.hxx>
46
#include <sfx2/sfxsids.hrc>
47
#include <sfx2/viewsh.hxx>
48
#include <sfx2/viewfrm.hxx>
49
#include "impframe.hxx"
50
#include <utility>
51
#include <workwin.hxx>
52
#include <sfx2/ipclient.hxx>
53
#include <vector>
54
55
using namespace com::sun::star;
56
57
static std::vector<SfxFrame*> gaFramesArr_Impl;
58
59
using namespace ::com::sun::star::uno;
60
using namespace ::com::sun::star::util;
61
using namespace ::com::sun::star::frame;
62
using namespace ::com::sun::star::container;
63
64
SfxPoolItem* SfxUnoAnyItem::CreateDefault()
65
0
{
66
0
    return new SfxUnoAnyItem(0, uno::Any());
67
0
}
68
69
SfxPoolItem* SfxUnoFrameItem::CreateDefault()
70
0
{
71
0
    return new SfxUnoFrameItem();
72
0
}
73
void SfxFrame::Construct_Impl()
74
4.01k
{
75
4.01k
    m_pImpl.reset(new SfxFrame_Impl);
76
4.01k
    gaFramesArr_Impl.push_back( this );
77
4.01k
}
78
79
80
SfxFrame::~SfxFrame()
81
4.01k
{
82
4.01k
    RemoveTopFrame_Impl( this );
83
4.01k
    m_pWindow.disposeAndClear();
84
85
4.01k
    auto it = std::find( gaFramesArr_Impl.begin(), gaFramesArr_Impl.end(), this );
86
4.01k
    if ( it != gaFramesArr_Impl.end() )
87
4.01k
        gaFramesArr_Impl.erase( it );
88
89
4.01k
    delete m_pImpl->pDescr;
90
4.01k
}
91
92
bool SfxFrame::DoClose()
93
4.01k
{
94
    // Actually, one more PrepareClose is still needed!
95
4.01k
    bool bRet = false;
96
4.01k
    if ( !m_pImpl->bClosing )
97
4.01k
    {
98
4.01k
        m_pImpl->bClosing = true;
99
4.01k
        CancelTransfers();
100
101
        // now close frame; it will be deleted if this call is successful, so don't use any members after that!
102
4.01k
        bRet = true;
103
4.01k
        try
104
4.01k
        {
105
4.01k
            Reference< XCloseable > xCloseable  ( m_pImpl->xFrame, UNO_QUERY );
106
4.01k
            if (xCloseable.is())
107
4.01k
                xCloseable->close(true);
108
0
            else if ( m_pImpl->xFrame.is() )
109
0
            {
110
0
                Reference < XFrame > xFrame = m_pImpl->xFrame;
111
0
                xFrame->setComponent( Reference < css::awt::XWindow >(), Reference < XController >() );
112
0
                xFrame->dispose();
113
0
            }
114
0
            else
115
0
                DoClose_Impl();
116
4.01k
        }
117
4.01k
        catch( css::util::CloseVetoException& )
118
4.01k
        {
119
0
            m_pImpl->bClosing = false;
120
0
            bRet = false;
121
0
        }
122
4.01k
        catch( css::lang::DisposedException& )
123
4.01k
        {
124
0
        }
125
4.01k
    }
126
127
4.01k
    return bRet;
128
4.01k
}
129
130
void SfxFrame::DoClose_Impl()
131
4.01k
{
132
4.01k
    SfxBindings* pBindings = nullptr;
133
4.01k
    if ( m_pImpl->pCurrentViewFrame )
134
4.01k
        pBindings = &m_pImpl->pCurrentViewFrame->GetBindings();
135
136
    // For internal tasks Controllers and Tools must be cleared
137
4.01k
    if ( m_pImpl->pWorkWin )
138
4.01k
        m_pImpl->pWorkWin->DeleteControllers_Impl();
139
140
4.01k
    if ( m_pImpl->pCurrentViewFrame )
141
4.01k
        m_pImpl->pCurrentViewFrame->Close();
142
143
4.01k
    if ( m_pImpl->bOwnsBindings )
144
4.01k
    {
145
4.01k
        delete pBindings;
146
4.01k
        pBindings = nullptr;
147
4.01k
    }
148
149
4.01k
    delete this;
150
4.01k
}
151
152
bool SfxFrame::DocIsModified_Impl()
153
0
{
154
0
    return m_pImpl->pCurrentViewFrame && m_pImpl->pCurrentViewFrame->GetObjectShell() &&
155
0
            m_pImpl->pCurrentViewFrame->GetObjectShell()->IsModified();
156
0
}
157
158
bool SfxFrame::PrepareClose_Impl( bool bUI )
159
0
{
160
0
    bool bRet = true;
161
162
    // prevent recursive calls
163
0
    if( !m_pImpl->bPrepClosing )
164
0
    {
165
0
        m_pImpl->bPrepClosing = true;
166
167
0
        SfxObjectShell* pCur = GetCurrentDocument() ;
168
0
        if( pCur )
169
0
        {
170
            // SFX components have a known behaviour
171
            // First check if this frame is the only view to its current document
172
0
            bool bOther = false;
173
0
            for ( const SfxViewFrame *pFrame = SfxViewFrame::GetFirst( pCur );
174
0
                    !bOther && pFrame; pFrame = SfxViewFrame::GetNext( *pFrame, pCur ) )
175
0
            {
176
0
                bOther = ( &pFrame->GetFrame() != this );
177
0
            }
178
179
0
            SfxGetpApp()->NotifyEvent( SfxViewEventHint(SfxEventHintId::PrepareCloseView, GlobalEventConfig::GetEventName( GlobalEventId::PREPARECLOSEVIEW ), pCur, GetController() ) );
180
181
0
            if ( bOther )
182
                // if there are other views only the current view of this frame must be asked
183
0
                bRet = GetCurrentViewFrame()->GetViewShell()->PrepareClose( bUI );
184
0
            else
185
                // otherwise ask the document
186
0
                bRet = pCur->PrepareClose( bUI );
187
0
        }
188
189
0
        m_pImpl->bPrepClosing = false;
190
0
    }
191
192
0
    if ( bRet && m_pImpl->pWorkWin )
193
        // if closing was accepted by the component the UI subframes must be asked also
194
0
        bRet = m_pImpl->pWorkWin->PrepareClose_Impl();
195
196
0
    return bRet;
197
0
}
198
199
200
bool SfxFrame::IsClosing_Impl() const
201
40.1k
{
202
40.1k
    return m_pImpl->bClosing;
203
40.1k
}
204
205
void SfxFrame::SetIsClosing_Impl()
206
4.01k
{
207
4.01k
    m_pImpl->bClosing = true;
208
4.01k
}
209
210
void SfxFrame::CancelTransfers()
211
4.01k
{
212
4.01k
    if( m_pImpl->bInCancelTransfers )
213
0
        return;
214
215
4.01k
    m_pImpl->bInCancelTransfers = true;
216
4.01k
    SfxObjectShell* pObj = GetCurrentDocument();
217
4.01k
    if( pObj ) //&& !( pObj->Get_Impl()->nLoadedFlags & SfxLoadedFlags::ALL ))
218
4.01k
    {
219
4.01k
        SfxViewFrame* pFrm;
220
4.01k
        for( pFrm = SfxViewFrame::GetFirst( pObj );
221
8.02k
             pFrm && &pFrm->GetFrame() == this;
222
4.01k
             pFrm = SfxViewFrame::GetNext( *pFrm, pObj ) ) ;
223
        // No more Frame in Document -> Cancel
224
4.01k
        if( !pFrm )
225
4.01k
        {
226
4.01k
            pObj->CancelTransfers();
227
4.01k
            GetCurrentDocument()->Broadcast( SfxHint(SfxHintId::TitleChanged) );
228
4.01k
        }
229
4.01k
    }
230
231
    //  Check if StarOne-Loader should be canceled
232
4.01k
    SfxFrameWeakRef wFrame( this );
233
4.01k
    if (wFrame.is())
234
4.01k
        m_pImpl->bInCancelTransfers = false;
235
4.01k
}
236
237
SfxViewFrame* SfxFrame::GetCurrentViewFrame() const
238
40.1k
{
239
40.1k
    return m_pImpl->pCurrentViewFrame;
240
40.1k
}
241
242
bool SfxFrame::IsAutoLoadLocked_Impl() const
243
0
{
244
    // Its own Document is locked?
245
0
    const SfxObjectShell* pObjSh = GetCurrentDocument();
246
0
    if ( !pObjSh || !pObjSh->IsAutoLoadLocked() )
247
0
        return false;
248
249
    // otherwise allow AutoLoad
250
0
    return true;
251
0
}
252
253
SfxObjectShell* SfxFrame::GetCurrentDocument() const
254
12.0k
{
255
12.0k
    return m_pImpl->pCurrentViewFrame ?
256
8.02k
            m_pImpl->pCurrentViewFrame->GetObjectShell() :
257
12.0k
            nullptr;
258
12.0k
}
259
260
void SfxFrame::SetCurrentViewFrame_Impl( SfxViewFrame *pFrame )
261
8.02k
{
262
8.02k
    m_pImpl->pCurrentViewFrame = pFrame;
263
8.02k
}
264
265
bool SfxFrame::GetHasTitle() const
266
4.01k
{
267
4.01k
    return m_pImpl->mbHasTitle;
268
4.01k
}
269
270
void SfxFrame::SetHasTitle( bool n )
271
4.01k
{
272
4.01k
    m_pImpl->mbHasTitle = n;
273
4.01k
}
274
275
void SfxFrame::GetViewData_Impl()
276
0
{
277
    // Update all modifiable data between load and unload, the
278
    // fixed data is only processed once (after PrepareForDoc_Impl in
279
    // updateDescriptor) to save time.
280
281
0
    SfxViewFrame* pViewFrame = GetCurrentViewFrame();
282
0
    if( pViewFrame && pViewFrame->GetViewShell() )
283
0
    {
284
0
        SfxItemSet *pSet = GetDescriptor()->GetArgs();
285
0
        if ( GetController().is() && pSet->GetItemState( SID_VIEW_DATA ) != SfxItemState::SET )
286
0
        {
287
0
            css::uno::Any aData = GetController()->getViewData();
288
0
            pSet->Put( SfxUnoAnyItem( SID_VIEW_DATA, aData ) );
289
0
        }
290
291
0
        if ( pViewFrame->GetCurViewId() )
292
0
            pSet->Put( SfxUInt16Item( SID_VIEW_ID, static_cast<sal_uInt16>(pViewFrame->GetCurViewId()) ) );
293
0
    }
294
0
}
295
296
void SfxFrame::UpdateDescriptor( SfxObjectShell const *pDoc )
297
4.01k
{
298
    // For PrepareForDoc_Impl frames, the descriptor of the updated
299
    // and new itemset to be initialized. All data fir restoring the view
300
    // are thus saved. If the document be replaced, GetViewData_Impl (so)
301
    // the latest information hinzugef by "added. All together then the
302
    // browser-history saved in. When you activate such frame pick entry
303
    // is complete itemsets and the descriptor in the OpenDoc sent;.
304
    // Here only the fixed properties identified "other adjustable, the
305
    // retrieved by GetViewData (saves time).
306
307
4.01k
    assert(pDoc && "NULL-Document inserted ?!");
308
309
4.01k
    const SfxMedium *pMed = pDoc->GetMedium();
310
4.01k
    GetDescriptor()->SetActualURL();
311
312
    // Mark FileOpen parameter
313
4.01k
    SfxItemSet& rItemSet = pMed->GetItemSet();
314
315
4.01k
    const std::shared_ptr<const SfxFilter>& pFilter = pMed->GetFilter();
316
4.01k
    OUString aFilter;
317
4.01k
    if ( pFilter )
318
0
        aFilter = pFilter->GetFilterName();
319
320
4.01k
    const SfxStringItem* pRefererItem = rItemSet.GetItem<SfxStringItem>(SID_REFERER, false);
321
4.01k
    const SfxStringItem* pOptionsItem = rItemSet.GetItem<SfxStringItem>(SID_FILE_FILTEROPTIONS, false);
322
4.01k
    const SfxStringItem* pTitle1Item = rItemSet.GetItem<SfxStringItem>(SID_DOCINFO_TITLE, false);
323
324
4.01k
    SfxItemSet *pSet = GetDescriptor()->GetArgs();
325
326
    // Delete all old Items
327
4.01k
    pSet->ClearItem();
328
329
4.01k
    if ( pRefererItem )
330
0
        pSet->Put( *pRefererItem );
331
4.01k
    else
332
4.01k
        pSet->Put( SfxStringItem( SID_REFERER, OUString() ) );
333
334
4.01k
    if ( pOptionsItem )
335
0
        pSet->Put( *pOptionsItem );
336
337
4.01k
    if ( pTitle1Item )
338
0
        pSet->Put( *pTitle1Item );
339
340
4.01k
    pSet->Put( SfxStringItem( SID_FILTER_NAME, aFilter ));
341
4.01k
}
342
343
344
SfxFrameDescriptor* SfxFrame::GetDescriptor() const
345
8.02k
{
346
    // Create a FrameDescriptor On Demand; if there is no TopLevel-Frame
347
    // will result in an error, as no valid link is created.
348
349
8.02k
    if ( !m_pImpl->pDescr )
350
4.01k
    {
351
4.01k
        DBG_ASSERT( true, "No TopLevel-Frame, but no Descriptor!" );
352
4.01k
        m_pImpl->pDescr = new SfxFrameDescriptor;
353
4.01k
        if ( GetCurrentDocument() )
354
0
            m_pImpl->pDescr->SetURL( GetCurrentDocument()->GetMedium()->GetOrigURL() );
355
4.01k
    }
356
8.02k
    return m_pImpl->pDescr;
357
8.02k
}
358
359
void SfxFrame::GetDefaultTargetList(TargetList& rList)
360
0
{
361
    // An empty string for 'No Target'
362
0
    rList.emplace_back( );
363
0
    rList.emplace_back( "_top" );
364
0
    rList.emplace_back( "_parent" );
365
0
    rList.emplace_back( "_blank" );
366
0
    rList.emplace_back( "_self" );
367
0
}
368
369
void SfxFrame::InsertTopFrame_Impl( SfxFrame* pFrame )
370
4.01k
{
371
4.01k
    auto& rArr = SfxGetpApp()->Get_Impl()->vTopFrames;
372
4.01k
    rArr.push_back( pFrame );
373
4.01k
}
374
375
void SfxFrame::RemoveTopFrame_Impl( SfxFrame* pFrame )
376
4.01k
{
377
4.01k
    auto& rArr = SfxGetpApp()->Get_Impl()->vTopFrames;
378
4.01k
    auto it = std::find( rArr.begin(), rArr.end(), pFrame );
379
4.01k
    if ( it != rArr.end() )
380
4.01k
        rArr.erase( it );
381
4.01k
}
382
383
SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxViewFrame const *p )
384
0
    : SfxPoolItem( nWhichId ), pFrame( p ? &p->GetFrame() : nullptr )
385
0
{
386
0
    wFrame = pFrame;
387
0
}
388
389
SfxFrameItem::SfxFrameItem( sal_uInt16 nWhichId, SfxFrame *p ):
390
0
    SfxPoolItem( nWhichId ),
391
0
    pFrame( p ), wFrame( p )
392
0
{
393
0
}
394
395
bool SfxFrameItem::operator==( const SfxPoolItem &rItem ) const
396
0
{
397
0
     return SfxPoolItem::operator==(rItem) &&
398
0
        static_cast<const SfxFrameItem&>(rItem).pFrame == pFrame &&
399
0
        static_cast<const SfxFrameItem&>(rItem).wFrame == wFrame;
400
0
}
401
402
SfxFrameItem* SfxFrameItem::Clone( SfxItemPool *) const
403
0
{
404
    // Every ::Clone implementation *needs* to also ensure that
405
    // the WhichID gets set/copied at the created Item (!)
406
0
    SfxFrameItem* pNew = new SfxFrameItem(Which(), wFrame);
407
0
    pNew->pFrame = pFrame;
408
0
    return pNew;
409
0
}
410
411
bool SfxFrameItem::QueryValue( css::uno::Any& rVal, sal_uInt8 ) const
412
0
{
413
0
    if ( wFrame )
414
0
    {
415
0
        rVal <<= wFrame->GetFrameInterface();
416
0
        return true;
417
0
    }
418
419
0
    return false;
420
0
}
421
422
bool SfxFrameItem::PutValue( const css::uno::Any& rVal, sal_uInt8 )
423
0
{
424
0
    Reference < XFrame > xFrame;
425
0
    if ( (rVal >>= xFrame) && xFrame.is() )
426
0
    {
427
0
        SfxFrame* pFr = SfxFrame::GetFirst();
428
0
        while ( pFr )
429
0
        {
430
0
            if ( pFr->GetFrameInterface() == xFrame )
431
0
            {
432
0
                wFrame = pFrame = pFr;
433
0
                return true;
434
0
            }
435
436
0
            pFr = SfxFrame::GetNext( *pFr );
437
0
        }
438
0
        return true;
439
0
    }
440
441
0
    return false;
442
0
}
443
444
445
SfxUnoAnyItem::SfxUnoAnyItem( sal_uInt16 nWhichId, const css::uno::Any& rAny )
446
39.0k
    : SfxPoolItem( nWhichId )
447
39.0k
{
448
39.0k
    aValue = rAny;
449
39.0k
}
450
451
bool SfxUnoAnyItem::operator==( const SfxPoolItem& rItem ) const
452
0
{
453
0
    assert(SfxPoolItem::operator==(rItem)); (void)rItem;
454
0
    return false;
455
0
}
456
457
SfxUnoAnyItem* SfxUnoAnyItem::Clone( SfxItemPool *) const
458
39.0k
{
459
39.0k
    return new SfxUnoAnyItem( *this );
460
39.0k
}
461
462
bool SfxUnoAnyItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
463
0
{
464
0
    rVal = aValue;
465
0
    return true;
466
0
}
467
468
bool SfxUnoAnyItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
469
0
{
470
0
    aValue = rVal;
471
0
    return true;
472
0
}
473
474
SfxUnoFrameItem::SfxUnoFrameItem()
475
0
    : SfxPoolItem( 0)
476
0
{
477
0
}
478
479
SfxUnoFrameItem::SfxUnoFrameItem( sal_uInt16 nWhichId, css::uno::Reference< css::frame::XFrame > i_xFrame )
480
0
    : SfxPoolItem( nWhichId )
481
0
    , m_xFrame(std::move( i_xFrame ))
482
0
{
483
0
}
484
485
bool SfxUnoFrameItem::operator==( const SfxPoolItem& i_rItem ) const
486
0
{
487
0
    return SfxPoolItem::operator==(i_rItem) &&
488
0
        static_cast< const SfxUnoFrameItem& >( i_rItem ).m_xFrame == m_xFrame;
489
0
}
490
491
SfxUnoFrameItem* SfxUnoFrameItem::Clone( SfxItemPool* ) const
492
0
{
493
0
    return new SfxUnoFrameItem( *this );
494
0
}
495
496
bool SfxUnoFrameItem::QueryValue( css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
497
0
{
498
0
    rVal <<= m_xFrame;
499
0
    return true;
500
0
}
501
502
bool SfxUnoFrameItem::PutValue( const css::uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
503
0
{
504
0
    return ( rVal >>= m_xFrame );
505
0
}
506
507
css::uno::Reference< css::frame::XController > SfxFrame::GetController() const
508
8.02k
{
509
8.02k
    if ( m_pImpl->pCurrentViewFrame && m_pImpl->pCurrentViewFrame->GetViewShell() )
510
8.02k
        return m_pImpl->pCurrentViewFrame->GetViewShell()->GetController();
511
0
    else
512
0
        return css::uno::Reference< css::frame::XController > ();
513
8.02k
}
514
515
const css::uno::Reference< css::frame::XFrame >&  SfxFrame::GetFrameInterface() const
516
224k
{
517
224k
    return m_pImpl->xFrame;
518
224k
}
519
520
void SfxFrame::SetFrameInterface_Impl( const css::uno::Reference< css::frame::XFrame >& rFrame )
521
8.02k
{
522
8.02k
    m_pImpl->xFrame = rFrame;
523
8.02k
    css::uno::Reference< css::frame::XDispatchRecorder > xRecorder;
524
8.02k
    if ( !rFrame.is() && GetCurrentViewFrame() )
525
4.01k
        GetCurrentViewFrame()->GetBindings().SetRecorder_Impl( xRecorder );
526
8.02k
}
527
528
void SfxFrame::Appear()
529
0
{
530
0
    if ( GetCurrentViewFrame() )
531
0
    {
532
0
        GetCurrentViewFrame()->Show();
533
0
        GetWindow().Show();
534
0
        m_pImpl->xFrame->getContainerWindow()->setVisible( true );
535
0
        Reference < css::awt::XTopWindow > xTopWindow( m_pImpl->xFrame->getContainerWindow(), UNO_QUERY );
536
0
        if ( xTopWindow.is() )
537
0
            xTopWindow->toFront();
538
0
    }
539
0
}
540
541
void SfxFrame::AppearWithUpdate()
542
0
{
543
0
    Appear();
544
0
    if ( GetCurrentViewFrame() )
545
0
        GetCurrentViewFrame()->GetDispatcher()->Update_Impl( true );
546
0
}
547
548
void SfxFrame::SetOwnsBindings_Impl( bool bSet )
549
4.01k
{
550
4.01k
    m_pImpl->bOwnsBindings = bSet;
551
4.01k
}
552
553
bool SfxFrame::OwnsBindings_Impl() const
554
8.02k
{
555
8.02k
    return m_pImpl->bOwnsBindings;
556
8.02k
}
557
558
void SfxFrame::SetToolSpaceBorderPixel_Impl( const SvBorder& rBorder )
559
0
{
560
0
    m_pImpl->aBorder = rBorder;
561
0
    SfxViewFrame *pF = GetCurrentViewFrame();
562
0
    if ( !pF )
563
0
        return;
564
565
0
    Point aPos ( rBorder.Left(), rBorder.Top() );
566
0
    Size aSize( GetWindow().GetOutputSizePixel() );
567
0
    tools::Long nDeltaX = rBorder.Left() + rBorder.Right();
568
0
    if ( aSize.Width() > nDeltaX )
569
0
        aSize.AdjustWidth( -nDeltaX );
570
0
    else
571
0
        aSize.setWidth( 0 );
572
573
0
    tools::Long nDeltaY = rBorder.Top() + rBorder.Bottom();
574
0
    if ( aSize.Height() > nDeltaY )
575
0
        aSize.AdjustHeight( -nDeltaY );
576
0
    else
577
0
        aSize.setHeight( 0 );
578
579
0
    pF->GetWindow().SetPosSizePixel( aPos, aSize );
580
0
}
581
582
tools::Rectangle SfxFrame::GetTopOuterRectPixel_Impl() const
583
8.02k
{
584
8.02k
    Size aSize( GetWindow().GetOutputSizePixel() );
585
8.02k
    return tools::Rectangle( Point(), aSize );
586
8.02k
}
587
588
SfxWorkWindow* SfxFrame::GetWorkWindow_Impl() const
589
80.2k
{
590
80.2k
    return m_pImpl->pWorkWin;
591
80.2k
}
592
593
void SfxFrame::CreateWorkWindow_Impl()
594
4.01k
{
595
4.01k
    SfxFrame* pFrame = this;
596
597
4.01k
    if ( IsInPlace() )
598
0
    {
599
        // this makes sense only for inplace activated objects
600
0
        try
601
0
        {
602
0
            Reference < XChild > xChild( GetCurrentDocument()->GetModel(), UNO_QUERY );
603
0
            if ( xChild.is() )
604
0
            {
605
0
                Reference < XModel > xParent( xChild->getParent(), UNO_QUERY );
606
0
                if ( xParent.is() )
607
0
                {
608
0
                    Reference< XController > xParentCtrler = xParent->getCurrentController();
609
0
                    if ( xParentCtrler.is() )
610
0
                    {
611
0
                        Reference < XFrame > xFrame( xParentCtrler->getFrame() );
612
0
                        SfxFrame* pFr = SfxFrame::GetFirst();
613
0
                        while ( pFr )
614
0
                        {
615
0
                            if ( pFr->GetFrameInterface() == xFrame )
616
0
                            {
617
0
                                pFrame = pFr;
618
0
                                break;
619
0
                            }
620
621
0
                            pFr = SfxFrame::GetNext( *pFr );
622
0
                        }
623
0
                    }
624
0
                }
625
0
            }
626
0
        }
627
0
        catch(Exception&)
628
0
        {
629
0
            TOOLS_WARN_EXCEPTION( "sfx.view", "SfxFrame::CreateWorkWindow_Impl: Exception caught. Please try to submit a reproducible bug!");
630
0
        }
631
0
    }
632
633
4.01k
    m_pImpl->pWorkWin = new SfxWorkWindow( &pFrame->GetWindow(), this, pFrame );
634
4.01k
}
635
636
void SfxFrame::GrabFocusOnComponent_Impl()
637
0
{
638
0
    if ( m_pImpl->bReleasingComponent )
639
0
    {
640
0
        GetWindow().GrabFocus();
641
0
        return;
642
0
    }
643
644
0
    vcl::Window* pFocusWindow = &GetWindow();
645
0
    if ( GetCurrentViewFrame() && GetCurrentViewFrame()->GetViewShell() && GetCurrentViewFrame()->GetViewShell()->GetWindow() )
646
0
        pFocusWindow = GetCurrentViewFrame()->GetViewShell()->GetWindow();
647
648
0
    if( !pFocusWindow->HasChildPathFocus() )
649
0
        pFocusWindow->GrabFocus();
650
0
}
651
652
void SfxFrame::ReleasingComponent_Impl()
653
4.01k
{
654
4.01k
    m_pImpl->bReleasingComponent = true;
655
4.01k
}
656
657
bool SfxFrame::IsInPlace() const
658
32.7k
{
659
32.7k
    return m_pImpl->bInPlace;
660
32.7k
}
661
662
void SfxFrame::Resize()
663
0
{
664
0
    if ( IsClosing_Impl() )
665
0
        return;
666
667
0
    if ( OwnsBindings_Impl() )
668
0
    {
669
0
        if ( IsInPlace() )
670
0
        {
671
0
            SetToolSpaceBorderPixel_Impl( SvBorder() );
672
0
        }
673
0
        else
674
0
        {
675
            // check for IPClient that contains UIactive object or object that is currently UI activating
676
0
            SfxWorkWindow *pWork = GetWorkWindow_Impl();
677
0
            SfxInPlaceClient* pClient = GetCurrentViewFrame()->GetViewShell() ? GetCurrentViewFrame()->GetViewShell()->GetUIActiveIPClient_Impl() : nullptr;
678
0
            if ( pClient )
679
0
            {
680
0
                SfxObjectShell* pDoc
681
0
                    = SfxObjectShell::GetShellFromComponent(pClient->GetObject()->getComponent());
682
0
                SfxViewFrame* pFrame = SfxViewFrame::GetFirst(pDoc);
683
0
                pWork = pFrame ? pFrame->GetFrame().GetWorkWindow_Impl() : nullptr;
684
0
            }
685
686
0
            if ( pWork )
687
0
            {
688
0
                pWork->ArrangeChildren_Impl();
689
0
                pWork->ShowChildren_Impl();
690
0
            }
691
692
            // problem in presence of UIActive object: when the window is resized, but the toolspace border
693
            // remains the same, setting the toolspace border at the ContainerEnvironment doesn't force a
694
            // resize on the IPEnvironment; without that no resize is called for the SfxViewFrame. So always
695
            // set the window size of the SfxViewFrame explicit.
696
0
            SetToolSpaceBorderPixel_Impl( m_pImpl->aBorder );
697
0
        }
698
0
    }
699
0
    else if ( m_pImpl->pCurrentViewFrame )
700
0
    {
701
0
        m_pImpl->pCurrentViewFrame->GetWindow().SetSizePixel( GetWindow().GetOutputSizePixel() );
702
0
    }
703
704
0
}
705
706
SfxFrame* SfxFrame::GetFirst()
707
0
{
708
0
    return gaFramesArr_Impl.empty() ? nullptr : gaFramesArr_Impl.front();
709
0
}
710
711
SfxFrame* SfxFrame::GetNext( SfxFrame& rFrame )
712
0
{
713
0
    auto it = std::find( gaFramesArr_Impl.begin(), gaFramesArr_Impl.end(), &rFrame );
714
0
    if ( it != gaFramesArr_Impl.end() && (++it) != gaFramesArr_Impl.end() )
715
0
        return *it;
716
0
    else
717
0
        return nullptr;
718
0
}
719
720
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */