Coverage Report

Created: 2025-07-07 10:01

/src/libreoffice/sd/source/ui/view/drviews1.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
#include <DrawViewShell.hxx>
21
#include <ViewShellImplementation.hxx>
22
23
#include <DrawController.hxx>
24
#include <com/sun/star/embed/XEmbeddedObject.hpp>
25
26
#include <comphelper/scopeguard.hxx>
27
#include <rtl/ref.hxx>
28
29
#include <svx/svxids.hrc>
30
#include <svx/svdpagv.hxx>
31
#include <sfx2/viewfrm.hxx>
32
#include <sfx2/bindings.hxx>
33
#include <svx/svdoole2.hxx>
34
#include <sfx2/dispatch.hxx>
35
#include <sfx2/module.hxx>
36
#include <sfx2/notebookbar/SfxNotebookBar.hxx>
37
#include <svx/svdopage.hxx>
38
#include <svx/fmshell.hxx>
39
#include <tools/debug.hxx>
40
#include <comphelper/diagnose_ex.hxx>
41
#include <vcl/graphicfilter.hxx>
42
43
#include <view/viewoverlaymanager.hxx>
44
45
#include <app.hrc>
46
47
#include <fupoor.hxx>
48
#include <unokywds.hxx>
49
#include <sdpage.hxx>
50
#include <FrameView.hxx>
51
#include <Window.hxx>
52
#include <drawview.hxx>
53
#include <drawdoc.hxx>
54
#include <DrawDocShell.hxx>
55
#include <Ruler.hxx>
56
#include <Client.hxx>
57
#include <slideshow.hxx>
58
#include <AnimationChildWindow.hxx>
59
#include <ToolBarManager.hxx>
60
#include <FormShellManager.hxx>
61
#include <ViewShellBase.hxx>
62
#include <LayerTabBar.hxx>
63
#include <ViewShellManager.hxx>
64
#include <ViewShellHint.hxx>
65
#include <SlideSorter.hxx>
66
#include <SlideSorterViewShell.hxx>
67
#include <controller/SlideSorterController.hxx>
68
#include <controller/SlsPageSelector.hxx>
69
70
#include <comphelper/lok.hxx>
71
#include <LibreOfficeKit/LibreOfficeKitEnums.h>
72
#include <vcl/uitest/logger.hxx>
73
#include <vcl/uitest/eventdescription.hxx>
74
#include <titledockwin.hxx>
75
#include <strings.hrc>
76
#include <sdresid.hxx>
77
78
using namespace com::sun::star;
79
80
namespace sd {
81
82
void DrawViewShell::Activate(bool bIsMDIActivate)
83
0
{
84
0
    ViewShell::Activate(bIsMDIActivate);
85
86
    // tdf#150773: do not grab focus on loading
87
0
    if (mbFirstTimeActivation)
88
0
        mbFirstTimeActivation = false;
89
0
    else
90
0
    {
91
92
        // When the mode is switched to normal the main view shell grabs focus.
93
        // This is done for getting cut/copy/paste commands on slides in the left
94
        // pane (slide sorter view shell) to work properly.
95
0
        SfxShell* pTopViewShell = GetViewShellBase().GetViewShellManager()->GetTopViewShell();
96
0
        if (pTopViewShell == this)
97
0
        {
98
0
            GetActiveWindow()->GrabFocus();
99
0
        }
100
0
    }
101
0
}
102
103
void DrawViewShell::UIActivating( SfxInPlaceClient* pCli )
104
0
{
105
0
    ViewShell::UIActivating(pCli);
106
107
    // Disable own controls
108
0
    maTabControl->Disable();
109
0
    if (GetLayerTabControl() != nullptr)
110
0
        GetLayerTabControl()->Disable();
111
0
}
112
113
void DrawViewShell::UIDeactivated( SfxInPlaceClient* pCli )
114
0
{
115
    // Enable own controls
116
0
    maTabControl->Enable();
117
0
    if (GetLayerTabControl() != nullptr)
118
0
        GetLayerTabControl()->Enable();
119
120
0
    ViewShell::UIDeactivated(pCli);
121
0
}
122
123
void DrawViewShell::Deactivate(bool bIsMDIActivate)
124
0
{
125
    // Temporarily disable context broadcasting while the Deactivate()
126
    // call is forwarded to our base class.
127
0
    const bool bIsContextBroadcasterEnabled (SfxShell::SetContextBroadcasterEnabled(false));
128
129
0
    ViewShell::Deactivate(bIsMDIActivate);
130
131
0
    SfxShell::SetContextBroadcasterEnabled(bIsContextBroadcasterEnabled);
132
0
}
133
134
namespace
135
{
136
    class LockUI
137
    {
138
    private:
139
        void Lock(bool bLock);
140
        SfxViewFrame *mpFrame;
141
    public:
142
0
        explicit LockUI(SfxViewFrame *pFrame) : mpFrame(pFrame) { Lock(true); }
143
0
        ~LockUI() { Lock(false); }
144
145
    };
146
147
    void LockUI::Lock(bool bLock)
148
0
    {
149
0
        if (!mpFrame)
150
0
            return;
151
0
        mpFrame->Enable( !bLock );
152
0
    }
153
}
154
155
/**
156
 * Called, if state of selection of view is changed
157
 */
158
159
void DrawViewShell::SelectionHasChanged()
160
0
{
161
0
    Invalidate();
162
163
    //Update3DWindow(); // 3D-Controller
164
0
    SfxBoolItem aItem( SID_3D_STATE, true );
165
0
    GetViewFrame()->GetDispatcher()->ExecuteList(
166
0
        SID_3D_STATE, SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, { &aItem });
167
168
0
    SdrOle2Obj* pOleObj = nullptr;
169
170
0
    const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
171
0
    if ( rMarkList.GetMarkCount() != 0 )
172
0
    {
173
0
        if (rMarkList.GetMarkCount() == 1)
174
0
        {
175
0
            SdrMark* pMark = rMarkList.GetMark(0);
176
0
            SdrObject* pObj = pMark->GetMarkedSdrObj();
177
178
0
            SdrInventor nInv        = pObj->GetObjInventor();
179
0
            SdrObjKind  nSdrObjKind = pObj->GetObjIdentifier();
180
181
0
            if (nInv == SdrInventor::Default && nSdrObjKind == SdrObjKind::OLE2)
182
0
            {
183
0
                pOleObj = static_cast<SdrOle2Obj*>(pObj);
184
0
                UpdateIMapDlg( pObj );
185
0
            }
186
0
            else if (nSdrObjKind == SdrObjKind::Graphic)
187
0
                UpdateIMapDlg( pObj );
188
0
        }
189
0
    }
190
191
0
    ViewShellBase& rBase = GetViewShellBase();
192
0
    rBase.SetVerbs( uno::Sequence< embed::VerbDescriptor >() );
193
194
0
    try
195
0
    {
196
0
        if (pOleObj)
197
0
        {
198
0
            if (const auto& xObj = pOleObj->GetObjRef())
199
0
                rBase.SetVerbs(xObj->getSupportedVerbs());
200
0
        }
201
0
        else if (auto* pIPClient = rBase.GetIPClient();
202
0
                 pIPClient && pIPClient->IsObjectInPlaceActive())
203
0
        {
204
            // as appropriate take ole-objects into account and deactivate
205
206
            // this means we recently deselected an inplace active ole object so
207
            // we need to deselect it now
208
209
            //#i47279# disable frame until after object has completed unload
210
0
            LockUI aUILock(GetViewFrame());
211
0
            pIPClient->DeactivateObject();
212
            //HMHmpDrView->ShowMarkHdl();
213
0
        }
214
0
    }
215
0
    catch( css::uno::Exception& )
216
0
    {
217
0
        TOOLS_WARN_EXCEPTION( "sd", "sd::DrawViewShell::SelectionHasChanged()" );
218
0
    }
219
220
0
    if( HasCurrentFunction() )
221
0
    {
222
0
        GetCurrentFunction()->SelectionHasChanged();
223
0
    }
224
0
    else
225
0
    {
226
0
        GetViewShellBase().GetToolBarManager()->SelectionHasChanged(*this,*mpDrawView);
227
0
    }
228
229
    // Invalidate for every subshell
230
0
    GetViewShellBase().GetViewShellManager()->InvalidateAllSubShells(this);
231
232
0
    mpDrawView->UpdateSelectionClipboard();
233
234
0
    GetViewShellBase().GetDrawController()->FireSelectionChangeListener();
235
0
}
236
237
namespace {
238
239
void collectUIInformation(const OUString& aZoom)
240
0
{
241
0
    EventDescription aDescription;
242
0
    aDescription.aID = "impress_win";
243
0
    aDescription.aParameters = {{"ZOOM", aZoom}};
244
0
    aDescription.aAction = "SET";
245
0
    aDescription.aKeyWord = "ImpressWindowUIObject";
246
0
    aDescription.aParent = "MainWindow";
247
248
0
    UITestLogger::getInstance().logEvent(aDescription);
249
0
}
250
251
}
252
253
/**
254
 * set zoom factor
255
 */
256
void DrawViewShell::SetZoom( ::tools::Long nZoom )
257
0
{
258
    // Make sure that the zoom factor will not be recalculated on
259
    // following window resizings.
260
0
    mbZoomOnPage = false;
261
0
    ViewShell::SetZoom( nZoom );
262
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
263
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
264
0
    mpViewOverlayManager->onZoomChanged();
265
0
    collectUIInformation(OUString::number(nZoom));
266
0
}
267
268
/**
269
 * Set zoom rectangle for active window
270
 */
271
272
void DrawViewShell::SetZoomRect( const ::tools::Rectangle& rZoomRect )
273
0
{
274
0
    ViewShell::SetZoomRect( rZoomRect );
275
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
276
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
277
0
    mpViewOverlayManager->onZoomChanged();
278
0
}
279
280
/**
281
 * PrepareClose, as appropriate end text input, so other viewshells
282
 * discover a refreshed text object.
283
 */
284
285
bool DrawViewShell::PrepareClose( bool bUI )
286
0
{
287
0
    if ( !ViewShell::PrepareClose(bUI) )
288
0
        return false;
289
290
0
    if( HasCurrentFunction() )
291
0
    {
292
0
        sal_uInt16 nID = GetCurrentFunction()->GetSlotID();
293
0
        if (nID == SID_TEXTEDIT || nID == SID_ATTR_CHAR)
294
0
        {
295
0
            mpDrawView->SdrEndTextEdit();
296
0
        }
297
0
    }
298
299
0
    return true;
300
0
}
301
302
303
/**
304
 * Set status (enabled/disabled) of menu SfxSlots
305
 */
306
307
void DrawViewShell::ChangeEditMode(EditMode eEMode, bool bIsLayerModeActive)
308
0
{
309
0
    if (meEditMode == eEMode && mbIsLayerModeActive == bIsLayerModeActive)
310
0
        return;
311
312
0
    ViewShellManager::UpdateLock aLock (GetViewShellBase().GetViewShellManager());
313
314
0
    sal_uInt16 nActualPageId = maTabControl->GetPageId(0);
315
316
0
    if (mePageKind == PageKind::Handout)
317
0
    {
318
        // at handouts only allow MasterPage
319
0
        eEMode = EditMode::MasterPage;
320
0
    }
321
322
0
    GetViewShellBase().GetDrawController()->FireChangeEditMode (eEMode == EditMode::MasterPage);
323
0
    GetViewShellBase().GetDrawController()->FireChangeLayerMode (bIsLayerModeActive);
324
325
0
    if ( mpDrawView->IsTextEdit() )
326
0
    {
327
        // This exits the text edit mode when going in and out of window focus, which is not needed
328
        // Let's keep this call as comment for now as it probably just needs a better conditional.
329
        // mpDrawView->SdrEndTextEdit();
330
0
    }
331
332
0
    LayerTabBar* pLayerBar = GetLayerTabControl();
333
0
    if (pLayerBar != nullptr)
334
0
        pLayerBar->EndEditMode();
335
0
    maTabControl->EndEditMode();
336
337
0
    GetViewShellBase().GetDrawController()->BroadcastContextChange();
338
339
0
    meEditMode = eEMode;
340
341
0
    if(pLayerBar)
342
0
    {
343
        // #i87182# only switch activation mode of LayerTabBar when there is one,
344
        // else it will not get initialized with the current set of Layers as needed
345
0
        mbIsLayerModeActive = bIsLayerModeActive;
346
0
    }
347
348
    // Determine whether to show the master view toolbar.  The master
349
    // page mode has to be active and the shell must not be a handout
350
    // view.
351
0
    bool bShowMasterViewToolbar (meEditMode == EditMode::MasterPage
352
0
         && GetShellType() != ViewShell::ST_HANDOUT);
353
0
    bool bShowPresentationToolbar (meEditMode != EditMode::MasterPage
354
0
         && GetShellType() != ViewShell::ST_HANDOUT
355
0
         && GetShellType() != ViewShell::ST_DRAW);
356
357
    // If the master view toolbar is not shown we hide it before
358
    // switching the edit mode.
359
0
    if (::sd::ViewShell::mpImpl->mbIsInitialized
360
0
        && IsMainViewShell())
361
0
    {
362
0
        if ( !bShowMasterViewToolbar )
363
0
            GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::ToolBarGroup::MasterMode);
364
0
        if ( !bShowPresentationToolbar )
365
0
            GetViewShellBase().GetToolBarManager()->ResetToolBars(ToolBarManager::ToolBarGroup::CommonTask);
366
0
    }
367
368
0
    ConfigureAppBackgroundColor();
369
370
    // tdf#87638 - change slide pane title according to the edit mode
371
0
    auto setLeftPaneTitleIfPaneExists
372
0
        = [pViewShell = GetViewFrame()](sal_uInt16 nId, TranslateId aId)
373
0
    {
374
0
        if (auto* pChildWindow = pViewShell->GetChildWindow(nId))
375
0
            if (auto* pTitledDockingWindow
376
0
                = static_cast<TitledDockingWindow*>(pChildWindow->GetWindow()))
377
0
                pTitledDockingWindow->SetTitle(SdResId(aId));
378
0
    };
379
380
0
    if (meEditMode == EditMode::Page)
381
0
    {
382
        /******************************************************************
383
        * PAGEMODE
384
        ******************************************************************/
385
386
0
        maTabControl->Clear();
387
388
        // tdf#87638 - change slide pane title according to the edit mode
389
0
        setLeftPaneTitleIfPaneExists(SID_LEFT_PANE_DRAW, STR_LEFT_PANE_DRAW_TITLE);
390
0
        setLeftPaneTitleIfPaneExists(SID_LEFT_PANE_IMPRESS, STR_LEFT_PANE_IMPRESS_TITLE);
391
392
0
        SdPage* pPage;
393
0
        sal_uInt16 nPageCnt = GetDoc()->GetSdPageCount(mePageKind);
394
395
0
        for (sal_uInt16 i = 0; i < nPageCnt; i++)
396
0
        {
397
0
            pPage = GetDoc()->GetSdPage(i, mePageKind);
398
0
            OUString aPageName = pPage->GetName();
399
0
            maTabControl->InsertPage(pPage->getPageId(), aPageName);
400
401
0
            if ( !comphelper::LibreOfficeKit::isActive() && pPage->IsSelected() )
402
0
            {
403
0
                nActualPageId = pPage->getPageId();
404
0
            }
405
0
        }
406
407
0
        maTabControl->SetCurPageId(nActualPageId);
408
409
0
        SwitchPage(maTabControl->GetPagePos(nActualPageId));
410
411
        //tdf#102343 re-enable common undo on switch back from master mode
412
0
        mpDrawView->GetModel().SetDisableTextEditUsesCommonUndoManager(false);
413
0
    }
414
0
    else
415
0
    {
416
        /******************************************************************
417
        * MASTERPAGE
418
        ******************************************************************/
419
0
        GetViewFrame()->SetChildWindow(
420
0
            AnimationChildWindow::GetChildWindowId(), false );
421
422
        // tdf#87638 - change slide pane title according to the edit mode
423
0
        setLeftPaneTitleIfPaneExists(SID_LEFT_PANE_DRAW, STR_LEFT_PANE_DRAW_TITLE_MASTER);
424
0
        setLeftPaneTitleIfPaneExists(SID_LEFT_PANE_IMPRESS, STR_LEFT_PANE_IMPRESS_TITLE_MASTER);
425
426
0
        if (!mpActualPage)
427
0
        {
428
            // as long as there is no mpActualPage, take first
429
0
            mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
430
0
        }
431
432
0
        maTabControl->Clear();
433
0
        sal_uInt16 nActualMasterPageId = maTabControl->GetPageId(0);
434
0
        sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
435
436
0
        for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
437
0
        {
438
0
            SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
439
0
            OUString aLayoutName = pMaster->GetLayoutName();
440
0
            sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
441
0
            if (nPos != -1)
442
0
                aLayoutName = aLayoutName.copy(0, nPos);
443
444
0
            maTabControl->InsertPage(pMaster->getPageId(), aLayoutName);
445
446
0
            if (&(mpActualPage->TRG_GetMasterPage()) == pMaster)
447
0
            {
448
0
                nActualMasterPageId = pMaster->getPageId();
449
0
            }
450
0
        }
451
452
0
        maTabControl->SetCurPageId(nActualMasterPageId);
453
0
        SwitchPage(maTabControl->GetPagePos(nActualMasterPageId));
454
455
        //tdf#102343 changing attributes of textboxes in master typically
456
        //changes the stylesheet they are linked to, so if the common
457
        //undo manager is in use, those stylesheet changes are thrown
458
        //away at present
459
0
        mpDrawView->GetModel().SetDisableTextEditUsesCommonUndoManager(true);
460
0
    }
461
462
    // If the master view toolbar is to be shown we turn it on after the
463
    // edit mode has been changed.
464
0
    if (::sd::ViewShell::mpImpl->mbIsInitialized && !sfx2::SfxNotebookBar::IsActive()
465
0
        && IsMainViewShell())
466
0
    {
467
0
        if (bShowMasterViewToolbar)
468
0
            GetViewShellBase().GetToolBarManager()->SetToolBar(
469
0
                ToolBarManager::ToolBarGroup::MasterMode,
470
0
                ToolBarManager::msMasterViewToolBar);
471
0
        if (bShowPresentationToolbar)
472
0
            GetViewShellBase().GetToolBarManager()->SetToolBar(
473
0
                ToolBarManager::ToolBarGroup::CommonTask,
474
0
                ToolBarManager::msCommonTaskToolBar);
475
0
    }
476
477
0
    if ( ! mbIsLayerModeActive)
478
0
    {
479
0
        maTabControl->Show();
480
        // Set the tab control only for draw pages.  For master page
481
        // this has been done already above.
482
0
        if (meEditMode == EditMode::Page)
483
0
            maTabControl->SetCurPageId (nActualPageId);
484
0
    }
485
486
0
    ResetActualLayer();
487
488
0
    Invalidate( SID_PAGEMODE );
489
0
    Invalidate( SID_LAYERMODE );
490
0
    Invalidate( SID_MASTERPAGE );
491
0
    Invalidate( SID_DELETE_MASTER_PAGE );
492
0
    Invalidate( SID_DELETE_PAGE );
493
0
    Invalidate( SID_SLIDE_MASTER_MODE );
494
0
    Invalidate( SID_NOTES_MASTER_MODE );
495
0
    Invalidate( SID_HANDOUT_MASTER_MODE );
496
0
    InvalidateWindows();
497
498
0
    if (sfx2::SfxNotebookBar::IsActive())
499
0
        UIFeatureChanged();
500
501
0
    SetContextName(GetSidebarContextName());
502
503
0
}
504
505
/**
506
 * Generate horizontal ruler
507
 */
508
509
VclPtr<SvxRuler> DrawViewShell::CreateHRuler (::sd::Window* pWin)
510
0
{
511
0
    VclPtr<Ruler> pRuler;
512
0
    WinBits  aWBits;
513
0
    SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT;
514
515
0
    aWBits  = WB_HSCROLL | WB_3DLOOK | WB_BORDER | WB_EXTRAFIELD;
516
0
    nFlags |= SvxRulerSupportFlags::SET_NULLOFFSET |
517
0
              SvxRulerSupportFlags::TABS |
518
0
              SvxRulerSupportFlags::PARAGRAPH_MARGINS; // new
519
520
0
    pRuler = VclPtr<Ruler>::Create(*this, GetParentWindow(), pWin, nFlags,
521
0
        GetViewFrame()->GetBindings(), aWBits);
522
523
    // Metric ...
524
0
    sal_uInt16 nMetric = static_cast<sal_uInt16>(GetDoc()->GetUIUnit());
525
526
0
    if( nMetric == 0xffff )
527
0
        nMetric = static_cast<sal_uInt16>(GetViewShellBase().GetViewFrame().GetDispatcher()->GetModule()->GetFieldUnit());
528
529
0
    pRuler->SetUnit( FieldUnit( nMetric ) );
530
531
    // ... and also set DefTab at the ruler
532
0
    pRuler->SetDefTabDist( GetDoc()->GetDefaultTabulator() ); // new
533
534
0
    Fraction aUIScale(pWin->GetMapMode().GetScaleX());
535
0
    aUIScale *= GetDoc()->GetUIScale();
536
0
    pRuler->SetZoom(aUIScale);
537
538
0
    return pRuler;
539
0
}
540
541
/**
542
 * Generate vertical ruler
543
 */
544
545
VclPtr<SvxRuler> DrawViewShell::CreateVRuler(::sd::Window* pWin)
546
0
{
547
0
    VclPtr<SvxRuler> pRuler;
548
0
    WinBits  aWBits = WB_VSCROLL | WB_3DLOOK | WB_BORDER;
549
0
    SvxRulerSupportFlags nFlags = SvxRulerSupportFlags::OBJECT;
550
551
0
    pRuler = VclPtr<Ruler>::Create(*this, GetParentWindow(), pWin, nFlags,
552
0
        GetViewFrame()->GetBindings(), aWBits);
553
554
    // Metric same as HRuler, use document setting
555
0
    sal_uInt16 nMetric = static_cast<sal_uInt16>(GetDoc()->GetUIUnit());
556
557
0
    if( nMetric == 0xffff )
558
0
        nMetric = static_cast<sal_uInt16>(GetViewShellBase().GetViewFrame().GetDispatcher()->GetModule()->GetFieldUnit());
559
560
0
    pRuler->SetUnit( FieldUnit( nMetric ) );
561
562
0
    Fraction aUIScale(pWin->GetMapMode().GetScaleY());
563
0
    aUIScale *= GetDoc()->GetUIScale();
564
0
    pRuler->SetZoom(aUIScale);
565
566
0
    return pRuler;
567
0
}
568
569
/**
570
 * Refresh horizontal ruler
571
 */
572
573
void DrawViewShell::UpdateHRuler()
574
0
{
575
0
    Invalidate( SID_ATTR_LONG_LRSPACE );
576
0
    Invalidate( SID_RULER_PAGE_POS );
577
0
    Invalidate( SID_RULER_OBJECT );
578
0
    Invalidate( SID_RULER_TEXT_RIGHT_TO_LEFT );
579
580
0
    if (mpHorizontalRuler)
581
0
        mpHorizontalRuler->ForceUpdate();
582
0
}
583
584
/**
585
 * Refresh vertical ruler
586
 */
587
588
void DrawViewShell::UpdateVRuler()
589
0
{
590
0
    Invalidate( SID_ATTR_LONG_LRSPACE );
591
0
    Invalidate( SID_RULER_PAGE_POS );
592
0
    Invalidate( SID_RULER_OBJECT );
593
594
0
    if (mpVerticalRuler)
595
0
        mpVerticalRuler->ForceUpdate();
596
0
}
597
598
/**
599
 * Refresh TabControl on splitter change
600
 */
601
602
IMPL_LINK( DrawViewShell, TabSplitHdl, TabBar *, pTab, void )
603
0
{
604
0
    const ::tools::Long nMax = maViewSize.Width() - maScrBarWH.Width()
605
0
        - maTabControl->GetPosPixel().X() ;
606
607
0
    Size aTabSize = maTabControl->GetSizePixel();
608
0
    aTabSize.setWidth( std::min(pTab->GetSplitSize(), static_cast<::tools::Long>(nMax-1)) );
609
610
0
    maTabControl->SetSizePixel(aTabSize);
611
612
0
    if(GetLayerTabControl()) // #i87182#
613
0
    {
614
0
        GetLayerTabControl()->SetSizePixel(aTabSize);
615
0
    }
616
617
0
    Point aPos = maTabControl->GetPosPixel();
618
0
    aPos.AdjustX(aTabSize.Width() );
619
620
0
    Size aScrSize(nMax - aTabSize.Width(), maScrBarWH.Height());
621
0
    mpHorizontalScrollBar->SetPosSizePixel(aPos, aScrSize);
622
0
}
623
624
/// inherited from sd::ViewShell
625
SdPage* DrawViewShell::getCurrentPage() const
626
0
{
627
0
    const sal_uInt16 nPageCount = (meEditMode == EditMode::Page)?
628
0
                                    GetDoc()->GetSdPageCount(mePageKind):
629
0
                                    GetDoc()->GetMasterSdPageCount(mePageKind);
630
631
0
    sal_uInt16 nCurrentPage = maTabControl->GetCurPagePos();
632
0
    DBG_ASSERT((nCurrentPage<nPageCount), "sd::DrawViewShell::getCurrentPage(), illegal page index!");
633
0
    if (nCurrentPage >= nPageCount)
634
0
        nCurrentPage = 0; // play safe here
635
636
0
    if (meEditMode == EditMode::Page)
637
0
    {
638
0
        return GetDoc()->GetSdPage(nCurrentPage, mePageKind);
639
0
    }
640
0
    else // EditMode::MasterPage
641
0
    {
642
0
        return GetDoc()->GetMasterSdPage(nCurrentPage, mePageKind);
643
0
    }
644
0
}
645
646
/**
647
 * Select new refreshed page, in case of a page order change (eg. by undo)
648
 */
649
650
void DrawViewShell::ResetActualPage()
651
0
{
652
0
    if (!GetDoc())
653
0
        return;
654
655
0
    sal_uInt16 nCurrentPageId = maTabControl->GetCurPageId();
656
0
    sal_uInt16 nNewPageId;
657
0
    sal_uInt16 nCurrentPageNum = maTabControl->GetPagePos(nCurrentPageId);
658
0
    sal_uInt16 nPageCount   = (meEditMode == EditMode::Page)?GetDoc()->GetSdPageCount(mePageKind):GetDoc()->GetMasterSdPageCount(mePageKind);
659
660
0
    if (nCurrentPageNum >= nPageCount)
661
0
        nCurrentPageNum = nPageCount - 1;
662
663
0
    if (meEditMode == EditMode::Page)
664
0
    {
665
666
        // Update for TabControl
667
0
        maTabControl->Clear();
668
669
0
        SdPage* pPage = nullptr;
670
671
0
        for (sal_uInt16 i = 0; i < nPageCount; i++)
672
0
        {
673
0
            pPage = GetDoc()->GetSdPage(i, mePageKind);
674
0
            OUString aPageName = pPage->GetName();
675
0
            maTabControl->InsertPage(pPage->getPageId(), aPageName);
676
677
0
            if (nCurrentPageId == pPage->getPageId())
678
0
            {
679
0
                nCurrentPageNum = i;
680
0
                GetDoc()->SetSelected(pPage, true);
681
0
            }
682
0
            else
683
0
                GetDoc()->SetSelected(pPage, false);
684
0
        }
685
686
0
        nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
687
0
        maTabControl->SetCurPageId(nNewPageId);
688
0
    }
689
0
    else // EditMode::MasterPage
690
0
    {
691
0
        maTabControl->Clear();
692
693
0
        sal_uInt16 nMasterPageCnt = GetDoc()->GetMasterSdPageCount(mePageKind);
694
0
        for (sal_uInt16 i = 0; i < nMasterPageCnt; i++)
695
0
        {
696
0
            SdPage* pMaster = GetDoc()->GetMasterSdPage(i, mePageKind);
697
0
            OUString aLayoutName = pMaster->GetLayoutName();
698
0
            sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
699
0
            if (nPos != -1)
700
0
                aLayoutName = aLayoutName.copy(0, nPos);
701
0
            maTabControl->InsertPage(pMaster->getPageId(), aLayoutName);
702
703
0
            if (pMaster->getPageId() == nCurrentPageId)
704
0
                nCurrentPageNum = i;
705
0
        }
706
707
0
        nNewPageId = maTabControl->GetPageId(nCurrentPageNum);
708
0
        maTabControl->SetCurPageId(nNewPageId);
709
0
        SwitchPage(nCurrentPageNum);
710
0
    }
711
712
0
    bool bAllowChangeFocus = nNewPageId != nCurrentPageId;
713
0
    SfxBoolItem aI(SID_SWITCHPAGE, bAllowChangeFocus);
714
0
    GetViewFrame()->GetDispatcher()->ExecuteList(SID_SWITCHPAGE,
715
0
                SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
716
0
                { &aI });
717
0
}
718
719
/**
720
 * Apply "Verb" on OLE-object.
721
 */
722
ErrCode DrawViewShell::DoVerb(sal_Int32 nVerb)
723
0
{
724
0
    const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
725
0
    if ( rMarkList.GetMarkCount() != 0 )
726
0
    {
727
0
        if (rMarkList.GetMarkCount() == 1)
728
0
        {
729
0
            SdrMark* pMark = rMarkList.GetMark(0);
730
0
            SdrObject* pObj = pMark->GetMarkedSdrObj();
731
732
0
            SdrInventor nInv        = pObj->GetObjInventor();
733
0
            SdrObjKind  nSdrObjKind = pObj->GetObjIdentifier();
734
735
0
            if (nInv == SdrInventor::Default && nSdrObjKind == SdrObjKind::OLE2)
736
0
            {
737
0
                ActivateObject( static_cast<SdrOle2Obj*>(pObj), nVerb);
738
0
            }
739
0
        }
740
0
    }
741
742
0
    return ERRCODE_NONE;
743
0
}
744
745
/**
746
 * Activate OLE-object
747
 */
748
bool DrawViewShell::ActivateObject(SdrOle2Obj* pObj, sal_Int32 nVerb)
749
0
{
750
0
    bool bActivated = false;
751
752
0
    if ( !GetDocSh()->IsUIActive() )
753
0
    {
754
0
        ToolBarManager::UpdateLock aLock (GetViewShellBase().GetToolBarManager());
755
756
0
        bActivated = ViewShell::ActivateObject(pObj, nVerb);
757
0
    }
758
759
0
    return bActivated;
760
0
}
761
762
/**
763
 * Mark the desired page as selected (1), deselected (0), toggle (2).
764
 * nPage refers to the page in question.
765
 */
766
bool DrawViewShell::SelectPage(sal_uInt16 nPage, sal_uInt16 nSelect)
767
0
{
768
0
    SdPage* pPage = GetDoc()->GetSdPage(nPage, PageKind::Standard);
769
0
    if (!pPage)
770
0
        return false;
771
772
    //page selector marks pages as selected in view
773
0
    sd::slidesorter::SlideSorterViewShell* pSlideSorterVS
774
0
        = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
775
776
0
    if (nSelect == 1 || (/*Toggle*/ nSelect > 1 && !pPage->IsSelected()))
777
0
    {
778
0
        GetDoc()->SetSelected(pPage, true); // Select.
779
0
        if (pSlideSorterVS)
780
0
            pSlideSorterVS->GetSlideSorter().GetController().GetPageSelector().SelectPage(nPage);
781
0
    }
782
0
    else
783
0
    {
784
0
        GetDoc()->SetSelected(pPage, false); // Deselect.
785
0
        if (pSlideSorterVS)
786
0
            pSlideSorterVS->GetSlideSorter().GetController().GetPageSelector().DeselectPage(nPage);
787
0
    }
788
789
0
    return true;
790
0
}
791
792
bool DrawViewShell::IsSelected(sal_uInt16 nPage)
793
0
{
794
0
    slidesorter::SlideSorterViewShell* pVShell
795
0
        = slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
796
0
    if (pVShell != nullptr)
797
0
        return pVShell->GetSlideSorter().GetController().GetPageSelector().IsPageSelected(nPage);
798
799
0
    return false;
800
0
}
801
802
/**
803
 * Switch to desired page.
804
 * nSelectPage refers to the current EditMode
805
 * bAllowChangeFocus set to false when slide is inserted before current page
806
 *                   and we need to only update the current page number,
807
 *                   do not disturb editing in that case
808
 * bUpdateScrollbars set to false when the scrollbars are going to be updated by
809
 *                   some other mechanism. (e.g. if the page switch happened as
810
 *                   a result of a scroll)
811
 */
812
bool DrawViewShell::SwitchPage(sal_uInt16 nSelectedPage, bool bAllowChangeFocus,
813
                               bool bUpdateScrollbars)
814
0
{
815
    /** Under some circumstances there are nested calls to SwitchPage() and
816
        may crash the application (activation of form controls when the
817
        shell of the edit view is not on top of the shell stack, see issue
818
        83888 for details.)  Therefore the nested calls are ignored (they
819
        would jump to the wrong page anyway.)
820
    */
821
822
0
    if (mbIsInSwitchPage)
823
0
        return false;
824
0
    mbIsInSwitchPage = true;
825
0
    comphelper::ScopeGuard aGuard(
826
0
            [this] () { this->mbIsInSwitchPage = false; } );
827
828
0
    if (GetActiveWindow()->IsInPaint())
829
0
    {
830
        // Switching the current page while a Paint is being executed is
831
        // dangerous.  So, post it for later execution and return.
832
0
        maAsynchronousSwitchPageCall.Post(
833
0
            [this, nSelectedPage] () { this->SwitchPage(nSelectedPage); } );
834
0
        return false;
835
0
    }
836
837
0
    bool bOK = false;
838
839
    // With the current implementation of FuSlideShow there is a problem
840
    // when it displays the show in a window: when the show is stopped it
841
    // returns at one point in time SDRPAGE_NOTFOUND as current page index.
842
    // Because FuSlideShow is currently being rewritten this bug is fixed
843
    // here.
844
    // This is not as bad a hack as it may look because making SwitchPage()
845
    // more robust with respect to invalid page numbers is a good thing
846
    // anyway.
847
0
    if (nSelectedPage == SDRPAGE_NOTFOUND)
848
0
    {
849
0
        nSelectedPage = 0;
850
0
    }
851
0
    else
852
0
    {
853
        // Make sure that the given page index points to an existing page.  Move
854
        // the index into the valid range if necessary.
855
0
        sal_uInt16 nPageCount = (meEditMode == EditMode::Page)
856
0
            ? GetDoc()->GetSdPageCount(mePageKind)
857
0
            : GetDoc()->GetMasterSdPageCount(mePageKind);
858
0
        if (nSelectedPage >= nPageCount)
859
0
            nSelectedPage = nPageCount-1;
860
0
    }
861
862
0
    if (IsSwitchPageAllowed())
863
0
    {
864
0
        ModifyGuard aGuard2( GetDoc() );
865
866
0
        bOK = true;
867
868
0
        if (mpActualPage)
869
0
        {
870
0
            SdPage* pNewPage = nullptr;
871
872
0
            if (meEditMode == EditMode::MasterPage)
873
0
            {
874
0
                if( GetDoc()->GetMasterSdPageCount(mePageKind) > nSelectedPage )
875
0
                    pNewPage = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
876
877
0
                if( pNewPage )
878
0
                {
879
0
                    SdrPageView* pPV = mpDrawView->GetSdrPageView();
880
0
                    OUString sPageText(pNewPage->GetLayoutName());
881
0
                    sal_Int32 nPos = sPageText.indexOf(SD_LT_SEPARATOR);
882
0
                    if (nPos != -1)
883
0
                        sPageText = sPageText.copy(0, nPos);
884
0
                    if (pPV
885
0
                        && pNewPage == dynamic_cast< SdPage* >( pPV->GetPage() )
886
0
                        && sPageText == maTabControl->GetPageText(maTabControl->GetPageId(nSelectedPage)))
887
0
                    {
888
                        // this slide is already visible
889
0
                        return true;
890
0
                    }
891
0
                }
892
0
            }
893
0
            else
894
0
            {
895
0
                OSL_ASSERT(mpFrameView!=nullptr);
896
0
                mpFrameView->SetSelectedPage(nSelectedPage);
897
898
0
                if (GetDoc()->GetSdPageCount(mePageKind) > nSelectedPage)
899
0
                    pNewPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
900
901
0
                if (mpActualPage == pNewPage)
902
0
                {
903
0
                    SdrPageView* pPV = mpDrawView->GetSdrPageView();
904
905
0
                    SdPage* pCurrentPage = pPV ? dynamic_cast<SdPage*>(pPV->GetPage()) : nullptr;
906
0
                    if (pCurrentPage
907
0
                        && pNewPage == pCurrentPage
908
0
                        && maTabControl->GetPageText(maTabControl->GetPageId(nSelectedPage)) == pNewPage->GetName())
909
0
                    {
910
                        // this slide is already visible
911
0
                        return true;
912
0
                    }
913
0
                }
914
0
            }
915
0
        }
916
917
0
        if (bAllowChangeFocus)
918
0
            mpDrawView->SdrEndTextEdit();
919
920
0
        mpActualPage = nullptr;
921
922
0
        if (meEditMode == EditMode::Page)
923
0
        {
924
0
            mpActualPage = GetDoc()->GetSdPage(nSelectedPage, mePageKind);
925
0
        }
926
0
        else
927
0
        {
928
0
            SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
929
930
            // does the selected page fit to the masterpage?
931
0
            sal_uInt16 nPageCount = GetDoc()->GetSdPageCount(mePageKind);
932
0
            for (sal_uInt16 i = 0; i < nPageCount; i++)
933
0
            {
934
0
                SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
935
0
                if(pPage && pPage->IsSelected() && pMaster == &(pPage->TRG_GetMasterPage()))
936
0
                {
937
0
                    mpActualPage = pPage;
938
0
                    break;
939
0
                }
940
0
            }
941
942
0
            if (!mpActualPage)
943
0
            {
944
                // take the first page, that fits to the masterpage
945
0
                for (sal_uInt16 i = 0; i < nPageCount; i++)
946
0
                {
947
0
                    SdPage* pPage = GetDoc()->GetSdPage(i, mePageKind);
948
0
                    if(pPage && pMaster == &(pPage->TRG_GetMasterPage()))
949
0
                    {
950
0
                        mpActualPage = pPage;
951
0
                        break;
952
0
                    }
953
0
                }
954
0
            }
955
0
        }
956
957
0
        for (sal_uInt16 i = 0; i < GetDoc()->GetSdPageCount(mePageKind); i++)
958
0
        {
959
            // deselect all pages
960
0
            GetDoc()->SetSelected( GetDoc()->GetSdPage(i, mePageKind), false);
961
0
        }
962
963
0
        if (!mpActualPage)
964
0
        {
965
            // as far as there is no mpActualPage, take the first
966
0
            mpActualPage = GetDoc()->GetSdPage(0, mePageKind);
967
0
        }
968
969
        // also select this page (mpActualPage always points at a drawing page,
970
        // never at a masterpage)
971
0
        GetDoc()->SetSelected(mpActualPage, true);
972
973
0
        if (comphelper::LibreOfficeKit::isActive())
974
0
        {
975
            // notify LibreOfficeKit about changed page
976
0
            OString aPayload = OString::number(nSelectedPage);
977
0
            if (SfxViewShell* pViewShell = GetViewShell())
978
0
                pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload);
979
0
        }
980
981
0
        rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( GetDoc() ) );
982
0
        if( !xSlideshow.is() || !xSlideshow->isRunning() || ( xSlideshow->getAnimationMode() != ANIMATIONMODE_SHOW ) )
983
0
        {
984
            // tighten VisArea, to possibly deactivate objects
985
            // !!! only if we are not in presentation mode (#96279) !!!
986
0
            OSL_ASSERT (GetViewShell()!=nullptr);
987
0
            GetViewShell()->DisconnectAllClients();
988
0
            VisAreaChanged(::tools::Rectangle(Point(), Size(1, 1)));
989
0
        }
990
991
        // Try to prefetch all graphics for the active page. This will be done
992
        // in threads to be more efficient than loading them on-demand one by one.
993
0
        std::vector<Graphic*> graphics;
994
0
        mpActualPage->getGraphicsForPrefetch(graphics);
995
0
        if(graphics.size() > 1) // threading does not help with loading just one
996
0
            GraphicFilter::GetGraphicFilter().MakeGraphicsAvailableThreaded(graphics);
997
998
0
        if (meEditMode == EditMode::Page)
999
0
        {
1000
            /**********************************************************************
1001
            * PAGEMODE
1002
            **********************************************************************/
1003
0
            GetDoc()->SetSelected(mpActualPage, true);
1004
1005
0
            SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1006
1007
0
            if (pPageView)
1008
0
            {
1009
0
                mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1010
0
                mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1011
0
                mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1012
1013
0
                if (mePageKind == PageKind::Notes)
1014
0
                {
1015
0
                    mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1016
0
                }
1017
0
                else if (mePageKind == PageKind::Handout)
1018
0
                {
1019
0
                    mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1020
0
                }
1021
0
                else
1022
0
                {
1023
0
                    mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1024
0
                }
1025
0
            }
1026
1027
0
            mpDrawView->HideSdrPage();
1028
0
            maTabControl->SetCurPageId(maTabControl->GetPageId(nSelectedPage));
1029
0
            mpDrawView->ShowSdrPage(mpActualPage);
1030
0
            GetViewShellBase().GetDrawController()->FireSwitchCurrentPage(mpActualPage);
1031
1032
0
            SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1033
1034
0
            if (pNewPageView)
1035
0
            {
1036
0
                pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1037
0
                pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1038
0
                pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1039
1040
0
                if (mePageKind == PageKind::Notes)
1041
0
                {
1042
0
                    pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1043
0
                }
1044
0
                else if (mePageKind == PageKind::Handout)
1045
0
                {
1046
0
                    pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1047
0
                }
1048
0
                else
1049
0
                {
1050
0
                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1051
0
                }
1052
0
            }
1053
1054
0
            OUString aPageName = mpActualPage->GetName();
1055
1056
0
            if (maTabControl->GetPageText(maTabControl->GetPageId(nSelectedPage)) != aPageName)
1057
0
            {
1058
0
                maTabControl->SetPageText(maTabControl->GetPageId(nSelectedPage), aPageName);
1059
0
            }
1060
0
        }
1061
0
        else
1062
0
        {
1063
            /**********************************************************************
1064
            * MASTERPAGE
1065
            **********************************************************************/
1066
0
            SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1067
1068
0
            if (pPageView)
1069
0
            {
1070
0
                mpFrameView->SetVisibleLayers( pPageView->GetVisibleLayers() );
1071
0
                mpFrameView->SetPrintableLayers( pPageView->GetPrintableLayers() );
1072
0
                mpFrameView->SetLockedLayers( pPageView->GetLockedLayers() );
1073
1074
0
                if (mePageKind == PageKind::Notes)
1075
0
                {
1076
0
                    mpFrameView->SetNotesHelpLines( pPageView->GetHelpLines() );
1077
0
                }
1078
0
                else if (mePageKind == PageKind::Handout)
1079
0
                {
1080
0
                    mpFrameView->SetHandoutHelpLines( pPageView->GetHelpLines() );
1081
0
                }
1082
0
                else
1083
0
                {
1084
0
                    mpFrameView->SetStandardHelpLines( pPageView->GetHelpLines() );
1085
0
                }
1086
0
            }
1087
1088
0
            mpDrawView->HideSdrPage();
1089
0
            maTabControl->SetCurPageId(maTabControl->GetPageId(nSelectedPage));
1090
1091
0
            SdPage* pMaster = GetDoc()->GetMasterSdPage(nSelectedPage, mePageKind);
1092
1093
0
            if( !pMaster )              // if this page should not exist
1094
0
                pMaster = GetDoc()->GetMasterSdPage(0, mePageKind);
1095
1096
0
            sal_uInt16 nNum = pMaster->GetPageNum();
1097
0
            mpDrawView->ShowSdrPage(mpDrawView->GetModel().GetMasterPage(nNum));
1098
1099
0
            GetViewShellBase().GetDrawController()->FireSwitchCurrentPage(pMaster);
1100
1101
0
            SdrPageView* pNewPageView = mpDrawView->GetSdrPageView();
1102
1103
0
            if (pNewPageView)
1104
0
            {
1105
0
                pNewPageView->SetVisibleLayers( mpFrameView->GetVisibleLayers() );
1106
0
                pNewPageView->SetPrintableLayers( mpFrameView->GetPrintableLayers() );
1107
0
                pNewPageView->SetLockedLayers( mpFrameView->GetLockedLayers() );
1108
1109
0
                if (mePageKind == PageKind::Notes)
1110
0
                {
1111
0
                    pNewPageView->SetHelpLines( mpFrameView->GetNotesHelpLines() );
1112
0
                }
1113
0
                else if (mePageKind == PageKind::Handout)
1114
0
                {
1115
0
                    pNewPageView->SetHelpLines( mpFrameView->GetHandoutHelpLines() );
1116
0
                }
1117
0
                else
1118
0
                {
1119
0
                    pNewPageView->SetHelpLines( mpFrameView->GetStandardHelpLines() );
1120
0
                }
1121
0
            }
1122
1123
0
            OUString aLayoutName(pMaster->GetLayoutName());
1124
0
            sal_Int32 nPos = aLayoutName.indexOf(SD_LT_SEPARATOR);
1125
0
            if (nPos != -1)
1126
0
                aLayoutName = aLayoutName.copy(0, nPos);
1127
1128
0
            if (maTabControl->GetPageText(maTabControl->GetPageId(nSelectedPage)) != aLayoutName)
1129
0
            {
1130
0
                maTabControl->SetPageText(maTabControl->GetPageId(nSelectedPage), aLayoutName);
1131
0
            }
1132
1133
0
            if( mePageKind == PageKind::Handout )
1134
0
            {
1135
                // set pages for all available handout presentation objects
1136
0
                sd::ShapeList& rShapeList = pMaster->GetPresentationShapeList();
1137
0
                SdrObject* pObj = nullptr;
1138
0
                rShapeList.seekShape(0);
1139
1140
0
                while( (pObj = rShapeList.getNextShape()) )
1141
0
                {
1142
0
                    if( pMaster->GetPresObjKind(pObj) == PresObjKind::Handout )
1143
0
                    {
1144
                        // #i105146# We want no content to be displayed for PageKind::Handout,
1145
                        // so just never set a page as content
1146
0
                        static_cast<SdrPageObj*>(pObj)->SetReferencedPage(nullptr);
1147
0
                    }
1148
0
                }
1149
0
            }
1150
0
        }
1151
1152
0
        Size aVisSizePixel = GetActiveWindow()->GetOutputSizePixel();
1153
0
        ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
1154
0
        VisAreaChanged(aVisAreaWin);
1155
0
        mpDrawView->VisAreaChanged(GetActiveWindow()->GetOutDev());
1156
1157
        // so navigator (and effect window) notice that
1158
0
        SfxBindings& rBindings = GetViewFrame()->GetBindings();
1159
0
        rBindings.Invalidate(SID_NAVIGATOR_STATE, true);
1160
0
        rBindings.Invalidate(SID_NAVIGATOR_PAGENAME, true);
1161
0
        rBindings.Invalidate(SID_STATUS_PAGE, true);
1162
0
        rBindings.Invalidate(SID_DELETE_MASTER_PAGE, true);
1163
0
        rBindings.Invalidate(SID_DELETE_PAGE, true);
1164
0
        rBindings.Invalidate(SID_ASSIGN_LAYOUT, true);
1165
0
        rBindings.Invalidate(SID_INSERTPAGE, true);
1166
0
        UpdatePreview( mpActualPage );
1167
1168
0
        mpDrawView->AdjustMarkHdl();
1169
1170
0
        if(bUpdateScrollbars)
1171
0
            UpdateScrollBars();
1172
0
    }
1173
1174
0
    return bOK;
1175
0
}
1176
1177
/**
1178
 * Check if page change is allowed
1179
 */
1180
1181
bool DrawViewShell::IsSwitchPageAllowed() const
1182
0
{
1183
0
    bool bOK = true;
1184
1185
0
    FmFormShell* pFormShell = GetViewShellBase().GetFormShellManager()->GetFormShell();
1186
0
    if (pFormShell != nullptr && !pFormShell->PrepareClose(false))
1187
0
        bOK = false;
1188
1189
0
    return bOK;
1190
0
}
1191
1192
/**
1193
 * Select new refreshed page, in case of a page order change (eg. by undo)
1194
 */
1195
1196
void DrawViewShell::ResetActualLayer()
1197
0
{
1198
0
    LayerTabBar* pLayerBar = GetLayerTabControl();
1199
0
    if (pLayerBar == nullptr)
1200
0
        return;
1201
1202
    // remember old tab count and current tab id
1203
    // this is needed when one layer is renamed to
1204
    // restore current tab
1205
0
    sal_uInt16 nOldLayerCnt = pLayerBar->GetPageCount(); // actually it is tab count
1206
0
    sal_uInt16 nOldLayerPos = pLayerBar->GetCurPageId(); // actually it is a tab nId
1207
1208
    /**
1209
     * Update for LayerTab
1210
     */
1211
0
    pLayerBar->Clear();
1212
1213
0
    OUString aName; // a real layer name
1214
0
    OUString aActiveLayer = mpDrawView->GetActiveLayer();
1215
0
    sal_uInt16 nActiveLayerPos = SDRLAYERPOS_NOTFOUND;
1216
0
    SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1217
0
    sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
1218
1219
0
    for ( sal_uInt16 nLayerPos = 0; nLayerPos < nLayerCnt; nLayerPos++ )
1220
0
    {
1221
0
        aName = rLayerAdmin.GetLayer(nLayerPos)->GetName();
1222
1223
0
        if ( aName == aActiveLayer )
1224
0
        {
1225
0
            nActiveLayerPos = nLayerPos;
1226
0
        }
1227
1228
0
        if ( aName != sUNO_LayerName_background ) // layer "background" has never a tab
1229
0
        {
1230
0
            if (meEditMode == EditMode::MasterPage)
1231
0
            {
1232
                // don't show page layer onto the masterpage
1233
0
                if (aName != sUNO_LayerName_layout   &&
1234
0
                    aName != sUNO_LayerName_controls &&
1235
0
                    aName != sUNO_LayerName_measurelines)
1236
0
                {
1237
0
                    TabBarPageBits nBits = TabBarPageBits::NONE;
1238
0
                    SdrPageView* pPV = mpDrawView->GetSdrPageView();
1239
0
                    if (pPV)
1240
0
                    {
1241
0
                        if (!pPV->IsLayerVisible(aName))
1242
0
                        {
1243
0
                            nBits |= TabBarPageBits::Blue;
1244
0
                        }
1245
0
                        if (pPV->IsLayerLocked(aName))
1246
0
                        {
1247
0
                            nBits |= TabBarPageBits::Italic;
1248
0
                        }
1249
0
                        if (!pPV->IsLayerPrintable(aName))
1250
0
                        {
1251
0
                            nBits |= TabBarPageBits::Underline;
1252
0
                        }
1253
0
                    }
1254
1255
0
                    pLayerBar->InsertPage(nLayerPos+1, aName, nBits); // why +1? It is a nId, not a position. Position is APPEND.
1256
0
                }
1257
0
            }
1258
0
            else
1259
0
            {
1260
                // don't show masterpage layer onto the page
1261
0
                if (aName != sUNO_LayerName_background_objects)
1262
0
                {
1263
0
                    TabBarPageBits nBits = TabBarPageBits::NONE;
1264
0
                    if (!mpDrawView->GetSdrPageView()->IsLayerVisible(aName))
1265
0
                    {
1266
0
                        nBits = TabBarPageBits::Blue;
1267
0
                    }
1268
0
                    if (mpDrawView->GetSdrPageView()->IsLayerLocked(aName))
1269
0
                    {
1270
0
                        nBits |= TabBarPageBits::Italic;
1271
0
                    }
1272
0
                    if (!mpDrawView->GetSdrPageView()->IsLayerPrintable(aName))
1273
0
                    {
1274
0
                        nBits |= TabBarPageBits::Underline;
1275
0
                    }
1276
1277
0
                    pLayerBar->InsertPage(nLayerPos+1, aName, nBits);// why +1?
1278
0
                }
1279
0
            }
1280
0
        }
1281
0
    }
1282
1283
0
    if ( nActiveLayerPos == SDRLAYERPOS_NOTFOUND )
1284
0
    {
1285
0
        if( nOldLayerCnt == pLayerBar->GetPageCount() )
1286
0
        {
1287
0
            nActiveLayerPos = nOldLayerPos - 1;
1288
0
        }
1289
0
        else
1290
0
        {
1291
0
            nActiveLayerPos = ( meEditMode == EditMode::MasterPage ) ? 2 : 0;
1292
0
        }
1293
1294
0
        mpDrawView->SetActiveLayer( pLayerBar->GetLayerName(nActiveLayerPos + 1) );// why +1?
1295
0
    }
1296
1297
0
    pLayerBar->SetCurPageId(nActiveLayerPos + 1);
1298
0
    GetViewFrame()->GetBindings().Invalidate( SID_TOGGLELAYERVISIBILITY );
1299
0
    GetViewFrame()->GetBindings().Invalidate( SID_MODIFYLAYER );
1300
0
    GetViewFrame()->GetBindings().Invalidate( SID_DELETE_LAYER );
1301
0
}
1302
1303
/**
1304
 * AcceptDrop
1305
 */
1306
1307
sal_Int8 DrawViewShell::AcceptDrop (
1308
    const AcceptDropEvent& rEvt,
1309
    DropTargetHelper& rTargetHelper,
1310
    ::sd::Window* /*pTargetWindow*/,
1311
    sal_uInt16 /*nPage*/,
1312
    SdrLayerID nLayer )
1313
0
{
1314
0
    if( SlideShow::IsRunning( GetViewShellBase() ) && !SlideShow::IsInteractiveSlideshow( &GetViewShellBase() ) ) // IASS
1315
0
        return DND_ACTION_NONE;
1316
1317
0
    return mpDrawView->AcceptDrop( rEvt, rTargetHelper, nLayer );
1318
0
}
1319
1320
/**
1321
 * ExecuteDrop
1322
 */
1323
1324
sal_Int8 DrawViewShell::ExecuteDrop (
1325
    const ExecuteDropEvent& rEvt,
1326
    DropTargetHelper& /*rTargetHelper*/,
1327
    ::sd::Window* pTargetWindow,
1328
    sal_uInt16 nPage,
1329
    SdrLayerID nLayer)
1330
0
{
1331
0
    if( nPage != SDRPAGE_NOTFOUND )
1332
0
        nPage = GetDoc()->GetSdPage( nPage, mePageKind )->GetPageNum();
1333
1334
0
    if( SlideShow::IsRunning( GetViewShellBase() ) && !SlideShow::IsInteractiveSlideshow( &GetViewShellBase() )) // IASS
1335
0
        return DND_ACTION_NONE;
1336
1337
0
    Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
1338
0
    sal_Int8 nResult (mpDrawView->ExecuteDrop( rEvt, pTargetWindow, nPage, nLayer ));
1339
0
    Broadcast(ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
1340
1341
0
    return nResult;
1342
0
}
1343
1344
} // end of namespace sd
1345
1346
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */