Coverage Report

Created: 2025-12-31 10:39

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