Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/outlnvsh.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 <OutlineViewShell.hxx>
21
#include <Outliner.hxx>
22
23
#include <helpids.h>
24
#include <app.hrc>
25
#include <svx/hyperdlg.hxx>
26
#include <svx/zoomslideritem.hxx>
27
#include <svx/svdundo.hxx>
28
29
#include <sfx2/infobar.hxx>
30
#include <sfx2/objface.hxx>
31
#include <sfx2/zoomitem.hxx>
32
#include <editeng/editview.hxx>
33
#include <editeng/eeitem.hxx>
34
#include <editeng/flditem.hxx>
35
#include <editeng/editund2.hxx>
36
#include <sfx2/shell.hxx>
37
#include <sfx2/request.hxx>
38
#include <svx/hlnkitem.hxx>
39
#include <svx/svdotext.hxx>
40
#include <svx/svdoutl.hxx>
41
#include <sfx2/dispatch.hxx>
42
#include <sfx2/viewfrm.hxx>
43
#include <tools/debug.hxx>
44
#include <vcl/commandevent.hxx>
45
#include <vcl/settings.hxx>
46
47
#include <sal/log.hxx>
48
#include <svl/stritem.hxx>
49
#include <svl/whiter.hxx>
50
#include <editeng/editstat.hxx>
51
#include <svl/itempool.hxx>
52
#include <sfx2/tplpitem.hxx>
53
#include <sfx2/sidebar/SidebarChildWindow.hxx>
54
#include <vcl/EnumContext.hxx>
55
#include <sot/formats.hxx>
56
#include <com/sun/star/linguistic2/XThesaurus.hpp>
57
#include <editeng/unolingu.hxx>
58
#include <editeng/outlobj.hxx>
59
#include <svl/cjkoptions.hxx>
60
#include <svtools/cliplistener.hxx>
61
#include <svl/srchitem.hxx>
62
#include <editeng/editobj.hxx>
63
#include <fubullet.hxx>
64
65
#include <strings.hrc>
66
67
#include <Window.hxx>
68
#include <drawdoc.hxx>
69
#include <sdresid.hxx>
70
#include <sdpage.hxx>
71
#include <fuoltext.hxx>
72
#include <FrameView.hxx>
73
#include <zoomlist.hxx>
74
#include <stlsheet.hxx>
75
#include <SdUnoOutlineView.hxx>
76
#include <SpellDialogChildWindow.hxx>
77
78
#include <AccessibleOutlineView.hxx>
79
#include <ViewShellBase.hxx>
80
#include <DrawController.hxx>
81
#include <DrawDocShell.hxx>
82
#include <OutlineView.hxx>
83
#include <framework/FrameworkHelper.hxx>
84
#include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
85
86
#include <memory>
87
88
#define ShellClass_OutlineViewShell
89
using namespace sd;
90
#include <sdslots.hxx>
91
92
using namespace ::com::sun::star;
93
using namespace ::com::sun::star::uno;
94
using namespace ::com::sun::star::linguistic2;
95
96
namespace sd {
97
98
0
#define MIN_ZOOM           10      // minimum zoom factor
99
0
#define MAX_ZOOM         1000      // maximum zoom factor
100
101
/**
102
 * Declare SFX-Slotmap and standard interface
103
 */
104
SFX_IMPL_INTERFACE(OutlineViewShell, SfxShell)
105
106
void OutlineViewShell::InitInterface_Impl()
107
6
{
108
6
    GetStaticInterface()->RegisterPopupMenu(u"outline"_ustr);
109
110
6
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_TOOLS, SfxVisibilityFlags::Standard | SfxVisibilityFlags::FullScreen | SfxVisibilityFlags::Server,
111
6
                                            ToolbarId::Outline_Toolbox);
112
6
    GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_APPLICATION, SfxVisibilityFlags::Standard | SfxVisibilityFlags::Client | SfxVisibilityFlags::Viewer | SfxVisibilityFlags::ReadonlyDoc,
113
6
                                            ToolbarId::Draw_Viewer_Toolbox);
114
115
6
    GetStaticInterface()->RegisterChildWindow(SfxInfoBarContainerChild::GetChildWindowId());
116
6
    GetStaticInterface()->RegisterChildWindow(SvxHlinkDlgWrapper::GetChildWindowId());
117
6
    GetStaticInterface()->RegisterChildWindow(::sd::SpellDialogChildWindow::GetChildWindowId());
118
6
    GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
119
6
    GetStaticInterface()->RegisterChildWindow(sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
120
6
    GetStaticInterface()->RegisterChildWindow(DevelopmentToolChildWindow::GetChildWindowId());
121
6
}
122
123
124
/**
125
 * common initialization part of both constructors
126
 */
127
void OutlineViewShell::Construct()
128
0
{
129
0
    bool bModified = GetDoc()->IsChanged();
130
131
0
    meShellType = ST_OUTLINE;
132
0
    Size aSize(29700, 21000);
133
0
    Point aWinPos (0, 0);
134
0
    Point aViewOrigin(0, 0);
135
0
    GetActiveWindow()->SetMinZoomAutoCalc(false);
136
0
    GetActiveWindow()->SetMinZoom( MIN_ZOOM );
137
0
    GetActiveWindow()->SetMaxZoom( MAX_ZOOM );
138
0
    InitWindows(aViewOrigin, aSize, aWinPos);
139
0
    pOlView.reset( new OutlineView(*GetDocSh(), GetActiveWindow(), *this) );
140
0
    mpView = pOlView.get();            // Pointer of base class ViewShell
141
142
0
    SetPool( &GetDoc()->GetPool() );
143
144
0
    SetZoom(69);
145
146
    // Apply settings of FrameView
147
0
    ReadFrameViewData(mpFrameView);
148
149
0
    ::Outliner& rOutl = pOlView->GetOutliner();
150
0
    rOutl.SetUpdateLayout(true);
151
152
0
    if (!bModified)
153
0
    {
154
0
        rOutl.ClearModifyFlag();
155
0
    }
156
157
0
    pLastPage = GetActualPage();
158
159
0
    SetName( u"OutlineViewShell"_ustr );
160
161
0
    GetActiveWindow()->SetHelpId( HID_SDOUTLINEVIEWSHELL );
162
0
}
163
164
Reference<drawing::XDrawSubController> OutlineViewShell::CreateSubController()
165
0
{
166
0
    Reference<drawing::XDrawSubController> xSubController;
167
168
0
    if (IsMainViewShell())
169
0
    {
170
        // Create uno sub controller for the main view shell.
171
0
        xSubController.set( new SdUnoOutlineView(*this) );
172
0
    }
173
174
0
    return xSubController;
175
0
}
176
177
/**
178
 * Default constructor, windows must not center themselves automatically
179
 */
180
OutlineViewShell::OutlineViewShell (
181
    ViewShellBase& rViewShellBase,
182
    vcl::Window* pParentWindow,
183
    FrameView* pFrameViewArgument)
184
0
    : ViewShell(pParentWindow, rViewShellBase),
185
0
      pLastPage( nullptr ),
186
0
      bPastePossible(false),
187
0
      mbInitialized(false)
188
189
0
{
190
0
    if (pFrameViewArgument != nullptr)
191
0
        mpFrameView = pFrameViewArgument;
192
0
    else
193
0
        mpFrameView = new FrameView(GetDoc());
194
195
0
    mpFrameView->Connect();
196
197
0
    Construct();
198
199
0
    SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::OutlineText));
200
201
0
    m_StrOldPageName.clear();
202
203
0
    doShow();
204
0
}
205
206
OutlineViewShell::~OutlineViewShell()
207
0
{
208
0
    DisposeFunctions();
209
210
0
    pOlView.reset();
211
212
0
    mpFrameView->Disconnect();
213
214
0
    if ( mxClipEvtLstnr.is() )
215
0
    {
216
0
        mxClipEvtLstnr->RemoveListener( GetActiveWindow() );
217
0
        mxClipEvtLstnr->ClearCallbackLink();     // prevent callback if another thread is waiting
218
0
    }
219
0
}
220
221
void OutlineViewShell::Shutdown()
222
0
{
223
0
    ViewShell::Shutdown();
224
225
0
    PrepareClose();
226
0
}
227
228
/**
229
 * Paint method: the event gets forwarded from pWindow to the Viewshell
230
 * and the current function
231
 */
232
void OutlineViewShell::Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin)
233
0
{
234
0
    if (pOlView)
235
0
    {
236
0
        pOlView->Paint(rRect, pWin);
237
0
    }
238
0
}
239
240
void OutlineViewShell::ArrangeGUIElements ()
241
0
{
242
    // Retrieve the current size (thickness) of the scroll bars.  That is
243
    // the width of the vertical and the height of the horizontal scroll
244
    // bar.
245
0
    int nScrollBarSize =
246
0
        GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
247
0
    maScrBarWH = Size (nScrollBarSize, nScrollBarSize);
248
249
0
    ViewShell::ArrangeGUIElements ();
250
251
0
    ::sd::Window* pWindow = mpContentWindow.get();
252
0
    if (pWindow == nullptr)
253
0
        return;
254
255
0
    pWindow->SetMinZoomAutoCalc(false);
256
257
    // change OutputArea of the OutlinerView
258
0
    OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
259
260
0
    ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
261
262
0
    aWin = pWindow->PixelToLogic(aWin);
263
0
    pOutlinerView->SetOutputArea(aWin);
264
265
0
    ::tools::Rectangle aVis = pOutlinerView->GetVisArea();
266
267
0
    ::tools::Rectangle aText(Point(0,0),
268
0
                             Size(pOlView->GetPaperWidth(),
269
0
                                  pOlView->GetOutliner().GetTextHeight()));
270
0
    if (aWin.GetHeight() > aText.Bottom())
271
0
        aText.SetBottom( aWin.GetHeight() );
272
273
0
    if (!aWin.IsEmpty())            // not when opening
274
0
    {
275
0
        InitWindows(Point(0,0), aText.GetSize(), aVis.TopLeft());
276
0
        UpdateScrollBars();
277
0
    }
278
0
}
279
280
/**
281
 * Handle SfxRequest for the Controller
282
 */
283
void OutlineViewShell::ExecCtrl(SfxRequest &rReq)
284
0
{
285
0
    sal_uInt16 nSlot = rReq.GetSlot();
286
0
    switch ( nSlot )
287
0
    {
288
0
        case SID_MAIL_SCROLLBODY_PAGEDOWN:
289
0
        {
290
0
            ExecReq( rReq );
291
0
            break;
292
0
        }
293
294
0
        case SID_OPT_LOCALE_CHANGED:
295
0
        {
296
0
            pOlView->GetOutliner().UpdateFields();
297
0
            UpdatePreview( GetActualPage() );
298
0
            rReq.Done();
299
0
            break;
300
0
        }
301
302
0
        default:
303
0
        break;
304
0
    }
305
0
}
306
307
/**
308
 * Activate(): during the first invocation the fields get updated
309
 */
310
void OutlineViewShell::Activate( bool bIsMDIActivate )
311
0
{
312
0
    if ( ! mbInitialized)
313
0
    {
314
0
        mbInitialized = true;
315
0
        SfxRequest aRequest (SID_EDIT_OUTLINER, SfxCallMode::SLOT, GetDoc()->GetItemPool());
316
0
        FuPermanent (aRequest);
317
0
    }
318
319
0
    ViewShell::Activate( bIsMDIActivate );
320
0
    BroadcastContextForActivation(true);
321
322
0
    pOlView->SetLinks();
323
0
    pOlView->ConnectToApplication();
324
325
0
    if( bIsMDIActivate )
326
0
    {
327
0
        OutlinerView* pOutlinerView = pOlView->GetViewByWindow( GetActiveWindow() );
328
0
        ::Outliner& rOutl = pOutlinerView->GetOutliner();
329
0
        rOutl.UpdateFields();
330
0
    }
331
0
}
332
333
void OutlineViewShell::Deactivate( bool bIsMDIActivate )
334
0
{
335
0
    pOlView->DisconnectFromApplication();
336
337
    // Links must be kept also on deactivated viewshell, to allow drag'n'drop
338
    // to function properly
339
0
    ViewShell::Deactivate( bIsMDIActivate );
340
0
}
341
342
/**
343
 * Set status of Controller-SfxSlots
344
 */
345
void OutlineViewShell::GetCtrlState(SfxItemSet &rSet)
346
0
{
347
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
348
0
    {
349
0
        SvxHyperlinkItem aHLinkItem;
350
351
0
        OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
352
0
        if (pOLV)
353
0
        {
354
0
            const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
355
0
            if (pFieldItem)
356
0
            {
357
0
                ESelection aSel = pOLV->GetSelection();
358
0
                if (abs(aSel.end.nIndex - aSel.start.nIndex) == 1)
359
0
                {
360
0
                    const SvxFieldData* pField = pFieldItem->GetField();
361
0
                    if ( auto pUrlField = dynamic_cast< const SvxURLField *>( pField ) )
362
0
                    {
363
0
                        aHLinkItem.SetName(pUrlField->GetRepresentation());
364
0
                        aHLinkItem.SetURL(pUrlField->GetURL());
365
0
                        aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
366
0
                    }
367
0
                }
368
0
            }
369
0
        }
370
0
        rSet.Put(aHLinkItem);
371
0
    }
372
0
    rSet.Put( SfxBoolItem( SID_READONLY_MODE, GetDocSh()->IsReadOnly() ) );
373
374
0
    if ( SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN) )
375
0
        rSet.Put( SfxBoolItem( SID_MAIL_SCROLLBODY_PAGEDOWN, true ) );
376
377
0
    if ( !(SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH) ||
378
0
         SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH) ||
379
0
         SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA) ||
380
0
         SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_KATAKANA)) )
381
0
        return;
382
383
0
    if( !SvtCJKOptions::IsChangeCaseMapEnabled() )
384
0
    {
385
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, false );
386
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, false );
387
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, false );
388
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, false );
389
0
        rSet.DisableItem( SID_TRANSLITERATE_HALFWIDTH );
390
0
        rSet.DisableItem( SID_TRANSLITERATE_FULLWIDTH );
391
0
        rSet.DisableItem( SID_TRANSLITERATE_HIRAGANA );
392
0
        rSet.DisableItem( SID_TRANSLITERATE_KATAKANA );
393
0
    }
394
0
    else
395
0
    {
396
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HALFWIDTH, true );
397
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_FULLWIDTH, true );
398
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_HIRAGANA, true );
399
0
        GetViewFrame()->GetBindings().SetVisibleState( SID_TRANSLITERATE_KATAKANA, true );
400
0
    }
401
0
}
402
403
/**
404
 * SfxRequests for support functions
405
 */
406
void OutlineViewShell::FuSupport(SfxRequest &rReq)
407
0
{
408
0
    if( rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
409
0
        GetDocSh()->SetStyleFamily(static_cast<SfxStyleFamily>(rReq.GetArgs()->Get( SID_STYLE_FAMILY ).GetValue()));
410
411
0
    bool bPreviewState = false;
412
0
    sal_uInt16 nSlot = rReq.GetSlot();
413
414
0
    std::unique_ptr<OutlineViewModelChangeGuard, o3tl::default_delete<OutlineViewModelChangeGuard>> aGuard;
415
0
    if( pOlView && (
416
0
        (nSlot == SID_TRANSLITERATE_SENTENCE_CASE) ||
417
0
        (nSlot == SID_TRANSLITERATE_TITLE_CASE) ||
418
0
        (nSlot == SID_TRANSLITERATE_TOGGLE_CASE) ||
419
0
        (nSlot == SID_TRANSLITERATE_UPPER) ||
420
0
        (nSlot == SID_TRANSLITERATE_LOWER) ||
421
0
        (nSlot == SID_TRANSLITERATE_HALFWIDTH) ||
422
0
        (nSlot == SID_TRANSLITERATE_FULLWIDTH) ||
423
0
        (nSlot == SID_TRANSLITERATE_HIRAGANA) ||
424
0
        (nSlot == SID_TRANSLITERATE_KATAKANA) ||
425
0
        (nSlot == SID_CUT) ||
426
0
        (nSlot == SID_PASTE) ||
427
0
        (nSlot == SID_PASTE_UNFORMATTED) ||
428
0
        (nSlot == SID_DELETE)))
429
0
    {
430
0
        aGuard.reset( new OutlineViewModelChangeGuard( *pOlView ) );
431
0
    }
432
433
0
    switch ( nSlot )
434
0
    {
435
0
        case SID_CUT:
436
0
        {
437
0
            if(HasCurrentFunction())
438
0
            {
439
0
                GetCurrentFunction()->DoCut();
440
0
            }
441
0
            else if (pOlView)
442
0
            {
443
0
                pOlView->DoCut();
444
0
            }
445
0
            rReq.Done();
446
0
            bPreviewState = true;
447
0
        }
448
0
        break;
449
450
0
        case SID_COPY:
451
0
        {
452
0
            if(HasCurrentFunction())
453
0
            {
454
0
                GetCurrentFunction()->DoCopy();
455
0
            }
456
0
            else if (pOlView)
457
0
            {
458
0
                pOlView->DoCopy();
459
0
            }
460
0
            rReq.Done();
461
0
            bPreviewState = true;
462
0
        }
463
0
        break;
464
465
0
        case SID_PASTE:
466
0
        {
467
0
            OutlineViewPageChangesGuard aGuard2(pOlView.get());
468
469
0
            if(HasCurrentFunction())
470
0
            {
471
0
                GetCurrentFunction()->DoPaste();
472
0
            }
473
0
            else if (pOlView)
474
0
            {
475
0
                pOlView->DoPaste();
476
0
            }
477
0
            rReq.Done();
478
0
            bPreviewState = true;
479
0
        }
480
0
        break;
481
482
0
        case SID_PASTE_UNFORMATTED:
483
0
        {
484
0
            OutlineViewPageChangesGuard aGuard2(pOlView.get());
485
486
0
            if(HasCurrentFunction())
487
0
            {
488
0
                GetCurrentFunction()->DoPasteUnformatted();
489
0
            }
490
0
            else if(pOlView)
491
0
            {
492
0
                TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
493
0
                if (aDataHelper.GetTransferable().is())
494
0
                {
495
0
                    sal_Int8 nAction = DND_ACTION_COPY;
496
0
                    pOlView->InsertData( aDataHelper,
497
0
                                         GetActiveWindow()->PixelToLogic( ::tools::Rectangle( Point(), GetActiveWindow()->GetOutputSizePixel() ).Center() ),
498
0
                                         nAction, false, SotClipboardFormatId::STRING);
499
0
                }
500
0
            }
501
502
0
            rReq.Ignore ();
503
0
        }
504
0
        break;
505
0
        case SID_DELETE:
506
0
        {
507
0
            if( pOlView )
508
0
            {
509
0
                OutlinerView* pOutlView = pOlView->GetViewByWindow(GetActiveWindow());
510
0
                if (pOutlView)
511
0
                {
512
0
                    OutlineViewPageChangesGuard aGuard2(pOlView.get());
513
514
0
                    vcl::KeyCode aKCode(KEY_DELETE);
515
0
                    KeyEvent aKEvt( 0, aKCode );
516
0
                    pOutlView->PostKeyEvent(aKEvt);
517
518
0
                    rtl::Reference<FuPoor> xFunc( GetCurrentFunction() );
519
0
                    FuOutlineText* pFuOutlineText = dynamic_cast< FuOutlineText* >( xFunc.get() );
520
0
                    if( pFuOutlineText )
521
0
                        pFuOutlineText->UpdateForKeyPress (aKEvt);
522
0
                }
523
0
            }
524
0
            rReq.Done();
525
0
            bPreviewState = true;
526
0
        }
527
0
        break;
528
529
0
        case SID_DRAWINGMODE:
530
0
        case SID_SLIDE_MASTER_MODE:
531
0
        case SID_NOTES_MODE:
532
0
        case SID_NOTES_MASTER_MODE:
533
0
        case SID_HANDOUT_MASTER_MODE:
534
0
        case SID_SLIDE_SORTER_MODE:
535
0
        case SID_OUTLINE_MODE:
536
0
            framework::FrameworkHelper::Instance(GetViewShellBase())->HandleModeChangeSlot(
537
0
                nSlot,
538
0
                rReq);
539
0
            rReq.Done();
540
0
            break;
541
542
0
        case SID_RULER:
543
0
            SetRuler( !HasRuler() );
544
0
            Invalidate( SID_RULER );
545
0
            rReq.Done();
546
0
        break;
547
548
0
        case SID_ZOOM_PREV:
549
0
        {
550
0
            if (mpZoomList->IsPreviousPossible())
551
0
            {
552
0
                SetZoomRect(mpZoomList->GetPreviousZoomRect());
553
0
            }
554
0
            rReq.Done ();
555
0
        }
556
0
        break;
557
558
0
        case SID_ZOOM_NEXT:
559
0
        {
560
0
            if (mpZoomList->IsNextPossible())
561
0
            {
562
0
                SetZoomRect(mpZoomList->GetNextZoomRect());
563
0
            }
564
0
            rReq.Done ();
565
0
        }
566
0
        break;
567
568
0
        case SID_AUTOSPELL_CHECK:
569
0
        {
570
0
            GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
571
0
            rReq.Done ();
572
0
        }
573
0
        break;
574
575
0
        case SID_TRANSLITERATE_SENTENCE_CASE:
576
0
        case SID_TRANSLITERATE_TITLE_CASE:
577
0
        case SID_TRANSLITERATE_TOGGLE_CASE:
578
0
        case SID_TRANSLITERATE_UPPER:
579
0
        case SID_TRANSLITERATE_LOWER:
580
0
        case SID_TRANSLITERATE_HALFWIDTH:
581
0
        case SID_TRANSLITERATE_FULLWIDTH:
582
0
        case SID_TRANSLITERATE_HIRAGANA:
583
0
        case SID_TRANSLITERATE_KATAKANA:
584
0
        {
585
0
            OutlinerView* pOLV = pOlView ? pOlView->GetViewByWindow( GetActiveWindow() ) : nullptr;
586
0
            if( pOLV )
587
0
            {
588
0
                TransliterationFlags nType = TransliterationFlags::NONE;
589
590
0
                switch( nSlot )
591
0
                {
592
0
                    case SID_TRANSLITERATE_SENTENCE_CASE:
593
0
                        nType = TransliterationFlags::SENTENCE_CASE;
594
0
                        break;
595
0
                    case SID_TRANSLITERATE_TITLE_CASE:
596
0
                        nType = TransliterationFlags::TITLE_CASE;
597
0
                        break;
598
0
                    case SID_TRANSLITERATE_TOGGLE_CASE:
599
0
                        nType = TransliterationFlags::TOGGLE_CASE;
600
0
                        break;
601
0
                    case SID_TRANSLITERATE_UPPER:
602
0
                        nType = TransliterationFlags::LOWERCASE_UPPERCASE;
603
0
                        break;
604
0
                    case SID_TRANSLITERATE_LOWER:
605
0
                        nType = TransliterationFlags::UPPERCASE_LOWERCASE;
606
0
                        break;
607
0
                    case SID_TRANSLITERATE_HALFWIDTH:
608
0
                        nType = TransliterationFlags::FULLWIDTH_HALFWIDTH;
609
0
                        break;
610
0
                    case SID_TRANSLITERATE_FULLWIDTH:
611
0
                        nType = TransliterationFlags::HALFWIDTH_FULLWIDTH;
612
0
                        break;
613
0
                    case SID_TRANSLITERATE_HIRAGANA:
614
0
                        nType = TransliterationFlags::KATAKANA_HIRAGANA;
615
0
                        break;
616
0
                    case SID_TRANSLITERATE_KATAKANA:
617
0
                        nType = TransliterationFlags::HIRAGANA_KATAKANA;
618
0
                        break;
619
0
                }
620
621
0
                pOLV->TransliterateText( nType );
622
0
            }
623
624
0
            rReq.Done();
625
0
            bPreviewState = true;
626
0
        }
627
0
        break;
628
629
        // added Undo/Redo handling
630
0
        case SID_UNDO :
631
0
        {
632
0
            OutlineViewPageChangesGuard aGuard2(pOlView.get());
633
0
            ImpSidUndo(rReq);
634
0
        }
635
0
        break;
636
0
        case SID_REDO :
637
0
        {
638
0
            OutlineViewPageChangesGuard aGuard2(pOlView.get());
639
0
            ImpSidRedo(rReq);
640
0
        }
641
0
        break;
642
643
0
        default:
644
0
        break;
645
0
    }
646
647
0
    if( bPreviewState )
648
0
        Invalidate( SID_PREVIEW_STATE );
649
650
0
    Invalidate(SID_CUT);
651
0
    Invalidate(SID_COPY);
652
0
    Invalidate(SID_PASTE);
653
0
}
654
655
/**
656
 * SfxRequests for permanent functions
657
 */
658
void OutlineViewShell::FuPermanent(SfxRequest &rReq)
659
0
{
660
0
    if(HasCurrentFunction())
661
0
    {
662
0
        DeactivateCurrentFunction(true);
663
0
    }
664
665
0
    switch ( rReq.GetSlot() )
666
0
    {
667
0
        case SID_EDIT_OUTLINER:
668
0
        {
669
0
            ::Outliner& rOutl = pOlView->GetOutliner();
670
0
            rOutl.GetUndoManager().Clear();
671
0
            rOutl.UpdateFields();
672
673
0
            SetCurrentFunction( FuOutlineText::Create(*this,GetActiveWindow(),pOlView.get(),*GetDoc(),rReq) );
674
675
0
            rReq.Done();
676
0
        }
677
0
        break;
678
679
0
      default:
680
0
      break;
681
0
    }
682
683
0
    if(HasOldFunction())
684
0
    {
685
0
        GetOldFunction()->Deactivate();
686
0
        SetOldFunction(nullptr);
687
0
    }
688
689
0
    if(HasCurrentFunction())
690
0
    {
691
0
        GetCurrentFunction()->Activate();
692
0
        SetOldFunction(GetCurrentFunction());
693
0
    }
694
0
}
695
696
IMPL_LINK( OutlineViewShell, ClipboardChanged, TransferableDataHelper*, pDataHelper, void )
697
0
{
698
0
    bPastePossible = pDataHelper->GetFormatCount() != 0 &&
699
0
                     ( pDataHelper->HasFormat( SotClipboardFormatId::STRING ) ||
700
0
                       pDataHelper->HasFormat( SotClipboardFormatId::RTF ) ||
701
0
                       pDataHelper->HasFormat( SotClipboardFormatId::RICHTEXT ) ||
702
0
                       pDataHelper->HasFormat( SotClipboardFormatId::HTML ) );
703
704
0
    SfxBindings& rBindings = GetViewFrame()->GetBindings();
705
0
    rBindings.Invalidate( SID_PASTE );
706
0
    rBindings.Invalidate( SID_PASTE_SPECIAL );
707
0
    rBindings.Invalidate( SID_PASTE_UNFORMATTED );
708
0
    rBindings.Invalidate( SID_CLIPBOARD_FORMAT_ITEMS );
709
0
}
710
711
/**
712
 * Set Status (Enabled/Disabled) of Menu-SfxSlots
713
 */
714
void OutlineViewShell::GetMenuState( SfxItemSet &rSet )
715
0
{
716
0
    ViewShell::GetMenuState(rSet);
717
718
0
    rSet.Put(SfxBoolItem(SID_SLIDE_SORTER_MODE, false));
719
0
    rSet.Put(SfxBoolItem(SID_DRAWINGMODE, false));
720
0
    rSet.Put(SfxBoolItem(SID_SLIDE_MASTER_MODE, false));
721
0
    rSet.Put(SfxBoolItem(SID_OUTLINE_MODE, true));
722
0
    rSet.Put(SfxBoolItem(SID_NOTES_MODE, false));
723
0
    rSet.Put(SfxBoolItem(SID_NOTES_MASTER_MODE, false));
724
0
    rSet.Put(SfxBoolItem(SID_HANDOUT_MASTER_MODE, false));
725
726
0
    if (!mpZoomList->IsNextPossible())
727
0
    {
728
0
       rSet.DisableItem(SID_ZOOM_NEXT);
729
0
    }
730
0
    if (!mpZoomList->IsPreviousPossible())
731
0
    {
732
0
       rSet.DisableItem(SID_ZOOM_PREV);
733
0
    }
734
735
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ZOOM_IN ) ||
736
0
        SfxItemState::DEFAULT == rSet.GetItemState( SID_ZOOM_OUT ) )
737
0
    {
738
0
        if( GetActiveWindow()->GetZoom() <= GetActiveWindow()->GetMinZoom() || GetDocSh()->IsUIActive() )
739
0
            rSet.DisableItem( SID_ZOOM_OUT );
740
0
        if( GetActiveWindow()->GetZoom() >= GetActiveWindow()->GetMaxZoom() || GetDocSh()->IsUIActive() )
741
0
            rSet.DisableItem( SID_ZOOM_IN );
742
0
    }
743
744
0
    ::Outliner& rOutl = pOlView->GetOutliner();
745
746
    // allow 'Select All'?
747
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_SELECTALL ) )
748
0
    {
749
0
        sal_Int32 nParaCount = rOutl.GetParagraphCount();
750
0
        bool bDisable = nParaCount == 0;
751
0
        if (!bDisable && nParaCount == 1)
752
0
        {
753
0
            OUString aTest = rOutl.GetText(rOutl.GetParagraph(0));
754
0
            if (aTest.isEmpty())
755
0
            {
756
0
                bDisable = true;
757
0
            }
758
0
        }
759
0
        if (bDisable)
760
0
            rSet.DisableItem(SID_SELECTALL);
761
0
    }
762
763
    // set status of Ruler
764
0
    rSet.Put( SfxBoolItem( SID_RULER, HasRuler() ) );
765
766
    // Enable formatting?
767
0
    rSet.Put( SfxBoolItem( SID_OUTLINE_FORMAT, !rOutl.IsFlatMode() ) );
768
769
0
    if( rOutl.IsFlatMode() )
770
0
        rSet.DisableItem( SID_COLORVIEW );
771
0
    else
772
0
    {
773
        // Enable color view?
774
0
        EEControlBits nCntrl = rOutl.GetControlWord();
775
0
        bool bNoColor = false;
776
0
        if (nCntrl & EEControlBits::NOCOLORS)
777
0
            bNoColor = true;
778
779
0
        rSet.Put( SfxBoolItem( SID_COLORVIEW, bNoColor ) );
780
0
    }
781
782
    // Buttons of toolbar
783
    // first the selection dependent ones: COLLAPSE, EXPAND
784
0
    bool bDisableCollapse = true;
785
0
    bool bDisableExpand   = true;
786
0
    bool bUnique          = true;
787
0
    OutlinerView* pOutlinerView = pOlView->GetViewByWindow(GetActiveWindow());
788
789
0
    std::vector<Paragraph*> aSelList;
790
0
    pOutlinerView->CreateSelectionList(aSelList);
791
792
0
    if (!aSelList.empty())
793
0
    {
794
0
        sal_Int16 nTmpDepth = rOutl.GetDepth( rOutl.GetAbsPos( aSelList.front() ) );
795
0
        bool bPage = ::Outliner::HasParaFlag( aSelList.front(), ParaFlag::ISPAGE );
796
797
0
        for (const Paragraph* pPara : aSelList)
798
0
        {
799
0
            sal_Int16 nDepth = rOutl.GetDepth( rOutl.GetAbsPos( pPara ) );
800
801
0
            if( nDepth != nTmpDepth || bPage != ::Outliner::HasParaFlag( pPara, ParaFlag::ISPAGE ))
802
0
                bUnique = false;
803
804
0
            if (rOutl.HasChildren(pPara))
805
0
            {
806
0
                if (!rOutl.IsExpanded(pPara))
807
0
                    bDisableExpand = false;
808
0
                else
809
0
                    bDisableCollapse = false;
810
0
            }
811
0
        }
812
0
    }
813
814
0
    if (bDisableExpand)
815
0
        rSet.DisableItem(SID_OUTLINE_EXPAND);
816
0
    if (bDisableCollapse)
817
0
        rSet.DisableItem(SID_OUTLINE_COLLAPSE);
818
819
    // does the selection provide a unique presentation layout?
820
    // if not, the templates must not be edited
821
0
    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT>(*rSet.GetPool()));
822
0
    GetStatusBarState(aSet);
823
0
    OUString aTest = aSet.Get(SID_STATUS_LAYOUT).GetValue();
824
0
    if (aTest.isEmpty())
825
0
    {
826
0
        bUnique = false;
827
0
    }
828
829
0
    if (!bUnique)
830
0
        rSet.DisableItem( SID_PRESENTATIONOBJECT );
831
832
    // now the selection independent ones: COLLAPSE_ALL, EXPAND_ALL
833
0
    bool bDisableCollapseAll = true;
834
0
    bool bDisableExpandAll   = true;
835
836
    // does the selection contain something collapsible/expandable?
837
0
    if (!bDisableCollapse)
838
0
        bDisableCollapseAll = false;
839
0
    if (!bDisableExpand)
840
0
        bDisableExpandAll = false;
841
842
    // otherwise look through all paragraphs
843
0
    if (bDisableCollapseAll || bDisableExpandAll)
844
0
    {
845
0
        sal_Int32 nParaPos = 0;
846
0
        Paragraph* pPara = rOutl.GetParagraph( nParaPos );
847
0
        while (pPara && (bDisableCollapseAll || bDisableExpandAll))
848
0
        {
849
0
            if (!rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
850
0
                bDisableExpandAll = false;
851
852
0
            if (rOutl.IsExpanded(pPara) && rOutl.HasChildren(pPara))
853
0
                bDisableCollapseAll = false;
854
855
0
            pPara = rOutl.GetParagraph( ++nParaPos );
856
0
        }
857
0
    }
858
859
0
    if (bDisableExpandAll)
860
0
        rSet.DisableItem(SID_OUTLINE_EXPAND_ALL);
861
0
    if (bDisableCollapseAll)
862
0
        rSet.DisableItem(SID_OUTLINE_COLLAPSE_ALL);
863
864
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_PASTE)
865
0
        || SfxItemState::DEFAULT == rSet.GetItemState(SID_PASTE_UNFORMATTED))
866
0
    {
867
0
        if ( !mxClipEvtLstnr.is() )
868
0
        {
869
            // create listener
870
0
            mxClipEvtLstnr = new TransferableClipboardListener( LINK( this, OutlineViewShell, ClipboardChanged ) );
871
0
            mxClipEvtLstnr->AddListener( GetActiveWindow() );
872
873
            // get initial state
874
0
            TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( GetActiveWindow() ) );
875
0
            bPastePossible = ( aDataHelper.GetFormatCount() != 0 &&
876
0
                                ( aDataHelper.HasFormat( SotClipboardFormatId::STRING ) ||
877
0
                                  aDataHelper.HasFormat( SotClipboardFormatId::RTF ) ||
878
0
                                  aDataHelper.HasFormat( SotClipboardFormatId::RICHTEXT ) ||
879
0
                                  aDataHelper.HasFormat( SotClipboardFormatId::HTML ) ) );
880
0
        }
881
882
0
        if( !bPastePossible )
883
0
        {
884
0
            rSet.DisableItem( SID_PASTE );
885
0
            rSet.DisableItem(SID_PASTE_UNFORMATTED);
886
0
        }
887
0
    }
888
889
0
    if (!pOlView->GetViewByWindow(GetActiveWindow())->HasSelection()
890
0
        || GetObjectShell()->isContentExtractionLocked())
891
0
    {
892
0
        rSet.DisableItem(SID_CUT);
893
0
        rSet.DisableItem(SID_COPY);
894
0
    }
895
896
0
    if (pOlView->GetOutliner().IsModified())
897
0
    {
898
0
        GetDoc()->SetChanged();
899
0
    }
900
901
    // the status has to be set here because of overriding
902
0
    if( !GetDocSh()->IsModified() )
903
0
    {
904
0
        rSet.DisableItem( SID_SAVEDOC );
905
0
    }
906
907
0
    if ( GetDocSh()->IsReadOnly() )
908
0
    {
909
0
        rSet.DisableItem( SID_AUTOSPELL_CHECK );
910
0
    }
911
0
    else
912
0
    {
913
0
        if (GetDoc()->GetOnlineSpell())
914
0
        {
915
0
            rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, true));
916
0
        }
917
0
        else
918
0
        {
919
0
            rSet.Put(SfxBoolItem(SID_AUTOSPELL_CHECK, false));
920
0
        }
921
0
    }
922
923
    // field commands
924
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_MODIFY_FIELD ) )
925
0
    {
926
0
        const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
927
928
0
        if( !( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
929
0
                            nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ||
930
0
                            nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
931
0
                            nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) ) )
932
0
        {
933
0
            rSet.DisableItem( SID_MODIFY_FIELD );
934
0
        }
935
0
    }
936
937
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_EXPAND_PAGE))
938
0
    {
939
0
        bool bDisable = true;
940
0
        sal_uInt16 i = 0;
941
0
        sal_uInt16 nCount = GetDoc()->GetSdPageCount(PageKind::Standard);
942
0
        pOlView->SetSelectedPages();
943
944
0
        while (i < nCount && bDisable)
945
0
        {
946
0
            SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
947
948
0
            if (pPage->IsSelected())
949
0
            {
950
0
                SdrObject* pObj = pPage->GetPresObj(PresObjKind::Outline);
951
952
0
                if (pObj!=nullptr )
953
0
                {
954
0
                    if( !pObj->IsEmptyPresObj() )
955
0
                    {
956
0
                        bDisable = false;
957
0
                    }
958
0
                    else
959
0
                    {
960
                        // check if the object is in edit, then if it's temporarily not empty
961
0
                        SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
962
0
                        if( pTextObj )
963
0
                        {
964
0
                            if( pTextObj->CanCreateEditOutlinerParaObject() )
965
0
                            {
966
0
                                bDisable = false;
967
0
                            }
968
0
                        }
969
0
                    }
970
0
                }
971
0
            }
972
973
0
            i++;
974
0
        }
975
976
0
        if (bDisable)
977
0
        {
978
0
            rSet.DisableItem(SID_EXPAND_PAGE);
979
0
        }
980
0
    }
981
982
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_SUMMARY_PAGE))
983
0
    {
984
0
        bool bDisable = true;
985
0
        sal_uInt16 i = 0;
986
0
        sal_uInt16 nCount = GetDoc()->GetSdPageCount(PageKind::Standard);
987
0
        pOlView->SetSelectedPages();
988
989
0
        while (i < nCount && bDisable)
990
0
        {
991
0
            SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
992
993
0
            if (pPage->IsSelected())
994
0
            {
995
0
                SdrObject* pObj = pPage->GetPresObj(PresObjKind::Title);
996
997
0
                if (pObj && !pObj->IsEmptyPresObj())
998
0
                {
999
0
                    bDisable = false;
1000
0
                }
1001
0
            }
1002
1003
0
            i++;
1004
0
        }
1005
1006
0
        if (bDisable)
1007
0
        {
1008
0
            rSet.DisableItem(SID_SUMMARY_PAGE);
1009
0
        }
1010
0
    }
1011
1012
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_THESAURUS ) )
1013
0
    {
1014
0
        if ( !pOlView->IsTextEdit() )
1015
0
        {
1016
0
            rSet.DisableItem( SID_THESAURUS );
1017
0
        }
1018
0
        else
1019
0
        {
1020
0
            LanguageType            eLang = GetDoc()->GetLanguage( EE_CHAR_LANGUAGE );
1021
0
            Reference< XThesaurus > xThesaurus( LinguMgr::GetThesaurus() );
1022
1023
0
            if (!xThesaurus.is() || eLang == LANGUAGE_NONE || !xThesaurus->hasLocale( LanguageTag::convertToLocale( eLang)))
1024
0
                rSet.DisableItem( SID_THESAURUS );
1025
0
        }
1026
0
    }
1027
1028
    // is starting the presentation possible?
1029
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_PRESENTATION ) )
1030
0
    {
1031
0
        bool bDisable = true;
1032
0
        sal_uInt16 nCount = GetDoc()->GetSdPageCount( PageKind::Standard );
1033
1034
0
        for( sal_uInt16 i = 0; i < nCount && bDisable; i++ )
1035
0
        {
1036
0
            SdPage* pPage = GetDoc()->GetSdPage(i, PageKind::Standard);
1037
1038
0
            if( !pPage->IsExcluded() )
1039
0
                bDisable = false;
1040
0
        }
1041
0
        if( bDisable || GetDocSh()->IsPreview())
1042
0
        {
1043
0
            rSet.DisableItem( SID_PRESENTATION );
1044
0
        }
1045
0
    }
1046
1047
0
    FuBullet::GetSlotState( rSet, this, GetViewFrame() );
1048
1049
0
}
1050
1051
/**
1052
 * gets invoked when ScrollBar is used
1053
 */
1054
void OutlineViewShell::VirtHScrollHdl(ScrollAdaptor* pHScroll)
1055
0
{
1056
0
    ::tools::Long   nThumb = pHScroll->GetThumbPos();
1057
0
    ::tools::Long   nRange = pHScroll->GetRange().Len();
1058
0
    double fX     = static_cast<double>(nThumb) / nRange;
1059
1060
0
    Window*       pWin          = mpContentWindow.get();
1061
0
    OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1062
0
    ::tools::Long          nViewWidth    = pWin->PixelToLogic(
1063
0
        pWin->GetSizePixel()).Width();
1064
0
    ::tools::Long          nTextWidth    = pOlView->GetPaperWidth();
1065
0
    nViewWidth                  = std::max(nViewWidth, nTextWidth);
1066
0
    ::tools::Long          nCurrentPos   = pOutlinerView->GetVisArea().Left();
1067
0
    ::tools::Long          nTargetPos    = static_cast<::tools::Long>(fX * nViewWidth);
1068
0
    ::tools::Long          nDelta        = nTargetPos - nCurrentPos;
1069
1070
0
    pOutlinerView->HideCursor();
1071
0
    pOutlinerView->Scroll(-nDelta, 0);
1072
0
    pOutlinerView->ShowCursor(false);
1073
0
}
1074
1075
void OutlineViewShell::VirtVScrollHdl(ScrollAdaptor* pVScroll)
1076
0
{
1077
0
    ::tools::Long nThumb = pVScroll->GetThumbPos();
1078
0
    ::tools::Long nRange = pVScroll->GetRange().Len();
1079
0
    double fY = static_cast<double>(nThumb) / nRange;
1080
1081
0
    Window*       pWin          = mpContentWindow.get();
1082
0
    OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWin);
1083
0
    ::tools::Long          nViewHeight   = pWin->PixelToLogic(
1084
0
        pWin->GetSizePixel()).Height();
1085
0
    ::tools::Long          nTextHeight   = pOlView->GetOutliner().GetTextHeight();
1086
0
    nViewHeight                += nTextHeight;
1087
0
    ::tools::Long          nCurrentPos   = pOutlinerView->GetVisArea().Top();
1088
0
    ::tools::Long          nTargetPos    = static_cast<::tools::Long>(fY * nViewHeight);
1089
0
    ::tools::Long          nDelta        = nTargetPos - nCurrentPos;
1090
1091
0
    pOutlinerView->HideCursor();
1092
0
    pOutlinerView->Scroll(0, -nDelta);
1093
0
    pOutlinerView->ShowCursor(false);
1094
0
}
1095
1096
/**
1097
 * PrepareClose, gets called when the Shell shall be destroyed.
1098
 * Forwards the invocation to the View
1099
 */
1100
bool OutlineViewShell::PrepareClose( bool bUI )
1101
0
{
1102
0
    if( !ViewShell::PrepareClose(bUI) )
1103
0
        return false;
1104
1105
0
    if (pOlView)
1106
0
        pOlView->PrepareClose();
1107
0
    return true;
1108
0
}
1109
1110
/**
1111
 * Zoom with zoom factor. Inform OutlinerView
1112
 */
1113
void OutlineViewShell::SetZoom(::tools::Long nZoom)
1114
0
{
1115
0
    ViewShell::SetZoom(nZoom);
1116
1117
0
    ::sd::Window* pWindow = mpContentWindow.get();
1118
0
    if (pWindow)
1119
0
    {
1120
        // change OutputArea of OutlinerView
1121
0
        OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1122
0
        ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1123
0
        aWin = pWindow->PixelToLogic(aWin);
1124
0
        pOutlinerView->SetOutputArea(aWin);
1125
0
    }
1126
1127
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1128
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1129
0
}
1130
1131
/**
1132
 * Zoom with zoom rectangle. Inform OutlinerView
1133
 */
1134
void OutlineViewShell::SetZoomRect(const ::tools::Rectangle& rZoomRect)
1135
0
{
1136
0
    ViewShell::SetZoomRect(rZoomRect);
1137
1138
0
    ::sd::Window* pWindow = mpContentWindow.get();
1139
0
    if (pWindow)
1140
0
    {
1141
        // change OutputArea of OutlinerView
1142
0
        OutlinerView* pOutlinerView = pOlView->GetViewByWindow(pWindow);
1143
0
        ::tools::Rectangle aWin(Point(0,0), pWindow->GetOutputSizePixel());
1144
0
        aWin = pWindow->PixelToLogic(aWin);
1145
0
        pOutlinerView->SetOutputArea(aWin);
1146
0
    }
1147
1148
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOM );
1149
0
    GetViewFrame()->GetBindings().Invalidate( SID_ATTR_ZOOMSLIDER );
1150
0
}
1151
1152
/**
1153
 * Before saving: Update Model of the Drawing Engine, then forward the
1154
 * invocation to the ObjectShell.
1155
 */
1156
void OutlineViewShell::Execute(SfxRequest& rReq)
1157
0
{
1158
0
    bool bForwardCall = true;
1159
1160
0
    switch(rReq.GetSlot())
1161
0
    {
1162
0
        case SID_SAVEDOC:
1163
0
        case SID_SAVEASDOC:
1164
0
            PrepareClose();
1165
0
            break;
1166
1167
0
        case SID_SEARCH_ITEM:
1168
            // Forward this request to the common (old) code of the
1169
            // document shell.
1170
0
            GetDocSh()->Execute (rReq);
1171
0
            bForwardCall = false;
1172
0
            break;
1173
1174
0
        case SID_SPELL_DIALOG:
1175
0
        {
1176
0
            SfxViewFrame* pViewFrame = GetViewFrame();
1177
0
            if (rReq.GetArgs() != nullptr)
1178
0
                pViewFrame->SetChildWindow (SID_SPELL_DIALOG,
1179
0
                    static_cast<const SfxBoolItem&>(rReq.GetArgs()->
1180
0
                        Get(SID_SPELL_DIALOG)).GetValue());
1181
0
            else
1182
0
                pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
1183
1184
0
            pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
1185
0
            rReq.Done ();
1186
1187
0
            bForwardCall = false;
1188
0
        }
1189
0
        break;
1190
1191
0
        default:
1192
0
            SAL_WARN("sd", "OutlineViewShell::Execute(): can not handle slot " << rReq.GetSlot());
1193
0
            break;
1194
1195
0
    }
1196
1197
0
    if (bForwardCall)
1198
0
        static_cast<DrawDocShell*>(GetViewFrame()->GetObjectShell())->ExecuteSlot( rReq );
1199
0
}
1200
1201
/**
1202
 * Read FrameViews data and set actual views data
1203
 */
1204
void OutlineViewShell::ReadFrameViewData(FrameView* pView)
1205
0
{
1206
0
    ::Outliner& rOutl = pOlView->GetOutliner();
1207
1208
0
    rOutl.SetFlatMode( pView->IsNoAttribs() );
1209
1210
0
    EEControlBits nCntrl = rOutl.GetControlWord();
1211
1212
0
    if ( pView->IsNoColors() )
1213
0
        rOutl.SetControlWord(nCntrl | EEControlBits::NOCOLORS);
1214
0
    else
1215
0
        rOutl.SetControlWord(nCntrl & ~EEControlBits::NOCOLORS);
1216
1217
0
    sal_uInt16 nPage = mpFrameView->GetSelectedPage();
1218
0
    pLastPage = GetDoc()->GetSdPage( nPage, PageKind::Standard );
1219
0
    pOlView->SetActualPage(pLastPage);
1220
0
}
1221
1222
/**
1223
 * Write actual views data to FrameView
1224
 */
1225
void OutlineViewShell::WriteFrameViewData()
1226
0
{
1227
0
    ::Outliner& rOutl = pOlView->GetOutliner();
1228
1229
0
    EEControlBits nCntrl = rOutl.GetControlWord();
1230
0
    bool bNoColor = false;
1231
0
    if (nCntrl & EEControlBits::NOCOLORS)
1232
0
        bNoColor = true;
1233
0
    mpFrameView->SetNoColors(bNoColor);
1234
0
    mpFrameView->SetNoAttribs( rOutl.IsFlatMode() );
1235
0
    SdPage* pActualPage = pOlView->GetActualPage();
1236
0
    DBG_ASSERT(pActualPage, "No current page");
1237
0
    if( pActualPage )
1238
0
        mpFrameView->SetSelectedPage((pActualPage->GetPageNum() - 1) / 2);
1239
0
}
1240
1241
/**
1242
 * Handle SfxRequests for the StatusBar
1243
 */
1244
void OutlineViewShell::ExecStatusBar(SfxRequest&)
1245
0
{
1246
0
}
1247
1248
void OutlineViewShell::GetStatusBarState(SfxItemSet& rSet)
1249
0
{
1250
    // Zoom-Item
1251
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOM ) )
1252
0
    {
1253
0
        sal_uInt16 nZoom = static_cast<sal_uInt16>(GetActiveWindow()->GetZoom());
1254
1255
0
        std::unique_ptr<SvxZoomItem> pZoomItem(new SvxZoomItem( SvxZoomType::PERCENT, nZoom ));
1256
1257
        // limit area
1258
0
        SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
1259
0
        nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
1260
0
        nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
1261
0
        nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
1262
1263
0
        pZoomItem->SetValueSet( nZoomValues );
1264
0
        rSet.Put( std::move(pZoomItem) );
1265
0
    }
1266
1267
0
    if( SfxItemState::DEFAULT == rSet.GetItemState( SID_ATTR_ZOOMSLIDER ) )
1268
0
    {
1269
0
        if (GetDocSh()->IsUIActive() || !GetActiveWindow() )
1270
0
        {
1271
0
            rSet.DisableItem( SID_ATTR_ZOOMSLIDER );
1272
0
        }
1273
0
        else
1274
0
        {
1275
0
            sd::Window * pActiveWindow = GetActiveWindow();
1276
0
            SvxZoomSliderItem aZoomItem( static_cast<sal_uInt16>(pActiveWindow->GetZoom()), static_cast<sal_uInt16>(pActiveWindow->GetMinZoom()), static_cast<sal_uInt16>(pActiveWindow->GetMaxZoom()) ) ;
1277
0
            aZoomItem.AddSnappingPoint(100);
1278
0
            rSet.Put( aZoomItem );
1279
0
        }
1280
0
    }
1281
1282
    // page view and layout
1283
1284
0
    sal_uInt16  nPageCount = GetDoc()->GetSdPageCount( PageKind::Standard );
1285
0
    OUString  aPageStr, aLayoutStr;
1286
1287
0
    ::sd::Window*   pWin        = GetActiveWindow();
1288
0
    OutlinerView*   pActiveView = pOlView->GetViewByWindow( pWin );
1289
1290
0
    std::vector<Paragraph*> aSelList;
1291
0
    pActiveView->CreateSelectionList(aSelList);
1292
1293
0
    Paragraph *pFirstPara = nullptr;
1294
0
    Paragraph *pLastPara = nullptr;
1295
1296
0
    if (!aSelList.empty())
1297
0
    {
1298
0
        pFirstPara = *(aSelList.begin());
1299
0
        pLastPara = *(aSelList.rbegin());
1300
0
    }
1301
1302
0
    if( !::Outliner::HasParaFlag(pFirstPara,ParaFlag::ISPAGE) )
1303
0
        pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1304
1305
0
    if( !::Outliner::HasParaFlag(pLastPara, ParaFlag::ISPAGE) )
1306
0
        pLastPara = pOlView->GetPrevTitle( pLastPara );
1307
1308
    // only one page selected?
1309
0
    if( pFirstPara == pLastPara )
1310
0
    {
1311
        // how many pages are we before the selected page?
1312
0
        sal_uLong nPos = 0;
1313
0
        while( pFirstPara )
1314
0
        {
1315
0
            pFirstPara = pOlView->GetPrevTitle( pFirstPara );
1316
0
            if( pFirstPara )
1317
0
                nPos++;
1318
0
        }
1319
1320
0
        if( nPos >= GetDoc()->GetSdPageCount( PageKind::Standard ) )
1321
0
            nPos = 0;
1322
1323
0
        SdPage* pPage = GetDoc()->GetSdPage( static_cast<sal_uInt16>(nPos), PageKind::Standard );
1324
1325
0
        if (GetDoc()->GetDocumentType() == DocumentType::Draw)
1326
0
            aPageStr = SdResId(STR_SD_PAGE_COUNT_DRAW);
1327
0
        else
1328
0
            aPageStr = SdResId(STR_SD_PAGE_COUNT);
1329
1330
0
        aPageStr = aPageStr.replaceFirst("%1", OUString::number(static_cast<sal_Int32>(nPos + 1)));
1331
0
        aPageStr = aPageStr.replaceFirst("%2", OUString::number(nPageCount));
1332
1333
0
        aLayoutStr = pPage->GetLayoutName();
1334
0
        sal_Int32 nIndex = aLayoutStr.indexOf(SD_LT_SEPARATOR);
1335
0
        if (nIndex != -1)
1336
0
            aLayoutStr = aLayoutStr.copy(0, nIndex);
1337
        //Now, CurrentPage property change is already sent for DrawView and OutlineView, so it is not necessary to send again here
1338
0
        if(m_StrOldPageName!=aPageStr)
1339
0
        {
1340
0
            GetViewShellBase().GetDrawController()->fireSwitchCurrentPage(nPos);
1341
0
            m_StrOldPageName = aPageStr;
1342
0
        }
1343
0
    }
1344
0
    rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
1345
0
    rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
1346
0
}
1347
1348
void OutlineViewShell::Command( const CommandEvent& rCEvt, ::sd::Window* pWin )
1349
0
{
1350
0
    if ( rCEvt.GetCommand() == CommandEventId::ContextMenu )
1351
0
    {
1352
0
        GetActiveWindow()->ReleaseMouse();
1353
1354
0
        OutlinerView* pOLV = pOlView->GetViewByWindow(GetActiveWindow());
1355
0
        Point aPos(rCEvt.GetMousePosPixel());
1356
1357
0
        bool bUsedSpellPopup = false;
1358
0
        if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
1359
0
        {
1360
            // Popup for Online-Spelling now handled by DrawDocShell
1361
0
            Link<SpellCallbackInfo&,void> aLink = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
1362
1363
0
            bUsedSpellPopup = pOLV->ExecuteSpellPopup(aPos, aLink);
1364
0
            pOLV->GetEditView().Invalidate();
1365
0
        }
1366
0
        if (!bUsedSpellPopup)
1367
0
        {
1368
0
           GetViewFrame()->GetDispatcher()->ExecutePopup(u"outline"_ustr);
1369
0
        }
1370
0
    }
1371
0
    else
1372
0
    {
1373
0
        ViewShell::Command( rCEvt, pWin );
1374
1375
        // if necessary communicate the new context to the Preview
1376
0
        Invalidate( SID_PREVIEW_STATE );
1377
1378
0
    }
1379
0
}
1380
1381
bool OutlineViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
1382
0
{
1383
0
    bool bReturn = false;
1384
0
    OutlineViewPageChangesGuard aGuard(pOlView.get());
1385
1386
0
    if (pWin == nullptr && HasCurrentFunction())
1387
0
    {
1388
0
        bReturn = GetCurrentFunction()->KeyInput(rKEvt);
1389
0
    }
1390
1391
    // no, forward to base class
1392
0
    else
1393
0
    {
1394
0
        bReturn = ViewShell::KeyInput(rKEvt, pWin);
1395
0
    }
1396
1397
0
    Invalidate(SID_STYLE_EDIT);
1398
0
    Invalidate(SID_STYLE_NEW);
1399
0
    Invalidate(SID_STYLE_DELETE);
1400
0
    Invalidate(SID_STYLE_HIDE);
1401
0
    Invalidate(SID_STYLE_SHOW);
1402
0
    Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1403
0
    Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1404
0
    Invalidate(SID_STYLE_WATERCAN);
1405
0
    Invalidate(SID_STYLE_FAMILY5);
1406
1407
    // check and distinguish cursor movements- or input-keys
1408
0
    vcl::KeyCode aKeyGroup( rKEvt.GetKeyCode().GetGroup() );
1409
0
    if( (aKeyGroup != KEYGROUP_CURSOR && aKeyGroup != KEYGROUP_FKEYS) ||
1410
0
        (GetActualPage() != pLastPage) )
1411
0
    {
1412
0
        Invalidate( SID_PREVIEW_STATE );
1413
0
    }
1414
1415
0
    return bReturn;
1416
0
}
1417
1418
/**
1419
 * Status of Attribute-Items
1420
 */
1421
void OutlineViewShell::GetAttrState( SfxItemSet& rSet )
1422
0
{
1423
0
    SfxWhichIter  aIter( rSet );
1424
0
    sal_uInt16        nWhich = aIter.FirstWhich();
1425
0
    SfxAllItemSet aAllSet( *rSet.GetPool() );
1426
1427
0
    while ( nWhich )
1428
0
    {
1429
0
        sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
1430
0
            ? GetPool().GetSlotId(nWhich)
1431
0
            : nWhich;
1432
1433
0
        switch ( nSlotId )
1434
0
        {
1435
0
            case SID_STYLE_FAMILY2:
1436
0
            case SID_STYLE_FAMILY3:
1437
0
            {
1438
0
                rSet.DisableItem( nWhich );
1439
0
            }
1440
0
            break;
1441
1442
0
            case SID_STYLE_FAMILY5:
1443
0
            {
1444
0
                SfxStyleSheet* pStyleSheet = pOlView->GetViewByWindow(GetActiveWindow())->GetStyleSheet();
1445
1446
0
                if( pStyleSheet )
1447
0
                {
1448
0
                    pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
1449
1450
0
                    if (pStyleSheet)
1451
0
                    {
1452
0
                        SfxTemplateItem aItem( nWhich, pStyleSheet->GetName() );
1453
0
                        aAllSet.Put( aItem );
1454
0
                    }
1455
0
                }
1456
1457
0
                if( !pStyleSheet )
1458
0
                {
1459
0
                    SfxTemplateItem aItem( nWhich, OUString() );
1460
0
                    aAllSet.Put( aItem );
1461
                    // rSet.DisableItem( nWhich );
1462
0
                }
1463
0
            }
1464
0
            break;
1465
1466
0
            case SID_STYLE_EDIT:
1467
0
            {
1468
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
1469
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
1470
0
                if (pFamilyItem && static_cast<SfxStyleFamily>(pFamilyItem->GetValue()) == SfxStyleFamily::Pseudo)
1471
0
                {
1472
0
                    SfxItemSet aSet(SfxItemSet::makeFixedSfxItemSet<SID_STATUS_LAYOUT, SID_STATUS_LAYOUT>(*rSet.GetPool()));
1473
0
                    GetStatusBarState(aSet);
1474
0
                    OUString aRealStyle = aSet.Get(SID_STATUS_LAYOUT).GetValue();
1475
0
                    if (aRealStyle.isEmpty())
1476
0
                    {
1477
                        // no unique layout name found
1478
0
                        rSet.DisableItem(nWhich);
1479
0
                    }
1480
0
                }
1481
0
            }
1482
0
            break;
1483
1484
0
            case SID_STYLE_UPDATE_BY_EXAMPLE:
1485
0
            {
1486
0
                ::sd::Window*     pActWin = GetActiveWindow();
1487
0
                OutlinerView* pOV = pOlView->GetViewByWindow(pActWin);
1488
0
                ESelection aESel(pOV->GetSelection());
1489
1490
0
                if (aESel.HasRange())
1491
                    // spanned selection, i.e. StyleSheet and/or
1492
                    // attribution not necessarily unique
1493
0
                    rSet.DisableItem(nWhich);
1494
0
            }
1495
0
            break;
1496
1497
0
            case SID_STYLE_NEW:
1498
0
            case SID_STYLE_DELETE:
1499
0
            case SID_STYLE_HIDE:
1500
0
            case SID_STYLE_SHOW:
1501
0
            case SID_STYLE_NEW_BY_EXAMPLE:
1502
0
            case SID_STYLE_WATERCAN:
1503
0
            {
1504
0
                rSet.DisableItem(nWhich);
1505
0
            }
1506
0
            break;
1507
0
        }
1508
1509
0
        nWhich = aIter.NextWhich();
1510
0
    }
1511
1512
0
    rSet.Put( aAllSet, false );
1513
0
}
1514
1515
void OutlineViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
1516
0
{
1517
    // first the base classes
1518
0
    ViewShell::MouseButtonUp(rMEvt, pWin);
1519
1520
0
    Invalidate(SID_STYLE_EDIT);
1521
0
    Invalidate(SID_STYLE_NEW);
1522
0
    Invalidate(SID_STYLE_DELETE);
1523
0
    Invalidate(SID_STYLE_HIDE);
1524
0
    Invalidate(SID_STYLE_SHOW);
1525
0
    Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1526
0
    Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1527
0
    Invalidate(SID_STYLE_WATERCAN);
1528
0
    Invalidate(SID_STYLE_FAMILY5);
1529
1530
    // if necessary communicate the new context to the Preview
1531
0
    if( GetActualPage() != pLastPage )
1532
0
        Invalidate( SID_PREVIEW_STATE );
1533
0
}
1534
1535
SdPage* OutlineViewShell::getCurrentPage() const
1536
0
{
1537
    // since there are no master pages in outline view, we can
1538
    // for now use the GetActualPage method
1539
0
    return const_cast<OutlineViewShell*>(this)->GetActualPage();
1540
0
}
1541
1542
/**
1543
 * Returns the first selected page.
1544
 * If nothing is selected, the first page is returned.
1545
 */
1546
SdPage* OutlineViewShell::GetActualPage()
1547
0
{
1548
0
    return pOlView->GetActualPage();
1549
0
}
1550
1551
void OutlineViewShell::UpdatePreview( SdPage* pPage )
1552
0
{
1553
0
    const bool bNewPage = pPage != pLastPage;
1554
0
    pLastPage = pPage;
1555
0
    if (bNewPage)
1556
0
    {
1557
0
        OutlineViewPageChangesGuard aGuard(pOlView.get());
1558
0
        SetCurrentPage(pPage);
1559
0
    }
1560
0
}
1561
1562
void OutlineViewShell::UpdateTitleObject( SdPage* pPage, Paragraph const * pPara )
1563
0
{
1564
0
    DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateTitleObject(), pPage == 0?" );
1565
0
    DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateTitleObject(), pPara == 0?" );
1566
1567
0
    if( !pPage || !pPara )
1568
0
        return;
1569
1570
0
    ::Outliner&         rOutliner = pOlView->GetOutliner();
1571
0
    SdrTextObj*         pTO  = OutlineView::GetTitleTextObject( pPage );
1572
1573
0
    OUString aTest = rOutliner.GetText(pPara);
1574
0
    bool    bText = !aTest.isEmpty();
1575
1576
0
    if( bText )
1577
0
    {
1578
0
        bool    bNewObject = false;
1579
        // create a title object if we don't have one but have text
1580
0
        if( !pTO )
1581
0
        {
1582
0
            DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1583
0
            pTO = OutlineView::CreateTitleTextObject(pPage);
1584
0
            bNewObject = true;
1585
0
        }
1586
1587
        // if we have a title object and a text, set the text
1588
0
        std::optional<OutlinerParaObject> pOPO;
1589
0
        if (pTO)
1590
0
            pOPO = rOutliner.CreateParaObject(rOutliner.GetAbsPos(pPara), 1);
1591
0
        if (pOPO)
1592
0
        {
1593
0
            pOPO->SetOutlinerMode( OutlinerMode::TitleObject );
1594
0
            assert(pTO);
1595
0
            pOPO->SetVertical( pTO->IsVerticalWriting() );
1596
0
            if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1597
0
            {
1598
                // do nothing, same text already set
1599
0
            }
1600
0
            else
1601
0
            {
1602
0
                DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1603
0
                if( !bNewObject && pOlView->isRecordingUndo() )
1604
0
                    pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1605
1606
0
                pTO->SetOutlinerParaObject( std::move(pOPO) );
1607
0
                pTO->SetEmptyPresObj( false );
1608
0
                pTO->ActionChanged();
1609
0
            }
1610
0
        }
1611
0
    }
1612
0
    else if( pTO )
1613
0
    {
1614
        // no text but object available?
1615
        // outline object available, but we have no text
1616
0
        if(pPage->IsPresObj(pTO))
1617
0
        {
1618
            // if it is not already empty
1619
0
            if( !pTO->IsEmptyPresObj() )
1620
0
            {
1621
0
                DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1622
1623
                // make it empty
1624
0
                if( pOlView->isRecordingUndo() )
1625
0
                    pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1626
0
                pPage->RestoreDefaultText( pTO, pTO->GetCustomPromptText() );
1627
0
                pTO->SetEmptyPresObj(true);
1628
0
                pTO->ActionChanged();
1629
0
            }
1630
0
        }
1631
0
        else
1632
0
        {
1633
0
            DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateTitleObject(), no undo for model change!?" );
1634
            // outline object is not part of the layout, delete it
1635
0
            if( pOlView->isRecordingUndo() )
1636
0
                pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1637
0
            pPage->RemoveObject(pTO->GetOrdNum());
1638
0
        }
1639
0
    }
1640
0
}
1641
1642
void OutlineViewShell::UpdateOutlineObject( SdPage* pPage, Paragraph* pPara )
1643
0
{
1644
0
    DBG_ASSERT( pPage, "sd::OutlineViewShell::UpdateOutlineObject(), pPage == 0?" );
1645
0
    DBG_ASSERT( pPara, "sd::OutlineViewShell::UpdateOutlineObject(), pPara == 0?" );
1646
1647
0
    if( !pPage || !pPara )
1648
0
        return;
1649
1650
0
    ::Outliner&         rOutliner = pOlView->GetOutliner();
1651
0
    std::optional<OutlinerParaObject> pOPO;
1652
0
    SdrTextObj*         pTO  = nullptr;
1653
1654
0
    OutlinerMode eOutlinerMode = OutlinerMode::TitleObject;
1655
0
    pTO = static_cast<SdrTextObj*>(pPage->GetPresObj( PresObjKind::Text ));
1656
0
    if( !pTO )
1657
0
    {
1658
0
        eOutlinerMode = OutlinerMode::OutlineObject;
1659
0
        pTO = OutlineView::GetOutlineTextObject( pPage );
1660
0
    }
1661
1662
    // how many paragraphs in the outline?
1663
0
    sal_Int32 nTitlePara     = rOutliner.GetAbsPos( pPara );
1664
0
    sal_Int32 nPara          = nTitlePara + 1;
1665
0
    sal_Int32 nParasInLayout = 0;
1666
0
    pPara = rOutliner.GetParagraph( nPara );
1667
0
    while( pPara && !::Outliner::HasParaFlag(pPara, ParaFlag::ISPAGE) )
1668
0
    {
1669
0
        nParasInLayout++;
1670
0
        pPara = rOutliner.GetParagraph( ++nPara );
1671
0
    }
1672
0
    if( nParasInLayout )
1673
0
    {
1674
        // create an OutlinerParaObject
1675
0
        pOPO  = rOutliner.CreateParaObject( nTitlePara + 1, nParasInLayout );
1676
0
    }
1677
1678
0
    if( pOPO )
1679
0
    {
1680
0
        DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1681
0
        bool bNewObject = false;
1682
1683
        // do we need an outline text object?
1684
0
        if( !pTO )
1685
0
        {
1686
0
            pTO = OutlineView::CreateOutlineTextObject( pPage );
1687
0
            bNewObject = true;
1688
0
        }
1689
1690
        // page object, outline text in Outliner:
1691
        // apply text
1692
0
        if( pTO )
1693
0
        {
1694
0
            pOPO->SetVertical( pTO->IsVerticalWriting() );
1695
0
            pOPO->SetOutlinerMode( eOutlinerMode );
1696
0
            if( pTO->GetOutlinerParaObject() && (pOPO->GetTextObject() == pTO->GetOutlinerParaObject()->GetTextObject()) )
1697
0
            {
1698
                // do nothing, same text already set
1699
0
            }
1700
0
            else
1701
0
            {
1702
0
                if( !bNewObject && pOlView->isRecordingUndo() )
1703
0
                    pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1704
1705
0
                pTO->SetOutlinerParaObject( std::move(pOPO) );
1706
0
                pTO->SetEmptyPresObj( false );
1707
0
                pTO->ActionChanged();
1708
0
            }
1709
0
        }
1710
0
    }
1711
0
    else if( pTO )
1712
0
    {
1713
        // page object but no outline text:
1714
        // if the object is in the outline of the page -> default text
1715
1716
        // otherwise delete object
1717
0
        if( pPage->IsPresObj(pTO) )
1718
0
        {
1719
0
            if( !pTO->IsEmptyPresObj() )
1720
0
            {
1721
0
                DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1722
1723
                // delete old OutlinerParaObject, too
1724
0
                if( pOlView->isRecordingUndo() )
1725
0
                    pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoObjectSetText(*pTO,0));
1726
0
                pPage->RestoreDefaultText( pTO, pTO->GetCustomPromptText() );
1727
0
                pTO->SetEmptyPresObj(true);
1728
0
                pTO->ActionChanged();
1729
0
            }
1730
0
        }
1731
0
        else
1732
0
        {
1733
0
            DBG_ASSERT( pOlView->isRecordingUndo(), "sd::OutlineViewShell::UpdateOutlineObject(), no undo for model change!?" );
1734
0
            if( pOlView->isRecordingUndo() )
1735
0
                pOlView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoRemoveObject(*pTO));
1736
0
            pPage->RemoveObject(pTO->GetOrdNum());
1737
0
        }
1738
0
    }
1739
0
}
1740
1741
/**
1742
 * Fill Outliner from Stream
1743
 */
1744
ErrCode OutlineViewShell::ReadRtf(SvStream& rInput)
1745
0
{
1746
0
    ErrCode bRet = ERRCODE_NONE;
1747
1748
0
    ::Outliner& rOutl = pOlView->GetOutliner();
1749
1750
0
    OutlineViewPageChangesGuard aGuard( pOlView.get() );
1751
0
    OutlineViewModelChangeGuard aGuard2( *pOlView );
1752
1753
0
    bRet = rOutl.Read( rInput, OUString(), EETextFormat::Rtf, GetDocSh()->GetHeaderAttributes() );
1754
1755
0
    SdPage* pPage = GetDoc()->GetSdPage( GetDoc()->GetSdPageCount(PageKind::Standard) - 1, PageKind::Standard );
1756
0
    SfxStyleSheet* pTitleSheet = pPage->GetStyleSheetForPresObj( PresObjKind::Title );
1757
0
    SfxStyleSheet* pOutlSheet = pPage->GetStyleSheetForPresObj( PresObjKind::Outline );
1758
1759
0
    sal_Int32 nParaCount = rOutl.GetParagraphCount();
1760
0
    if ( nParaCount > 0 )
1761
0
    {
1762
0
        for ( sal_Int32 nPara = 0; nPara < nParaCount; nPara++ )
1763
0
        {
1764
0
            pOlView->UpdateParagraph( nPara );
1765
1766
0
            sal_Int16 nDepth = rOutl.GetDepth( nPara );
1767
1768
0
            if( (nDepth == 0) || !nPara )
1769
0
            {
1770
0
                Paragraph* pPara = rOutl.GetParagraph( nPara );
1771
0
                rOutl.SetDepth(pPara, -1);
1772
0
                rOutl.SetParaFlag(pPara, ParaFlag::ISPAGE);
1773
1774
0
                rOutl.SetStyleSheet( nPara, pTitleSheet );
1775
1776
0
                if( nPara ) // first slide already exists
1777
0
                    pOlView->InsertSlideForParagraph( pPara );
1778
0
            }
1779
0
            else
1780
0
            {
1781
0
                rOutl.SetDepth( rOutl.GetParagraph( nPara ), nDepth - 1 );
1782
0
                OUString aStyleSheetName = pOutlSheet->GetName();
1783
0
                if (!aStyleSheetName.isEmpty())
1784
0
                    aStyleSheetName = aStyleSheetName.copy(0, aStyleSheetName.getLength() - 1);
1785
0
                aStyleSheetName += OUString::number( nDepth );
1786
0
                SfxStyleSheetBasePool* pStylePool = GetDoc()->GetStyleSheetPool();
1787
0
                SfxStyleSheet* pStyle = static_cast<SfxStyleSheet*>( pStylePool->Find( aStyleSheetName, pOutlSheet->GetFamily() ) );
1788
0
                DBG_ASSERT( pStyle, "AutoStyleSheetName - Style not found!" );
1789
0
                if ( pStyle )
1790
0
                    rOutl.SetStyleSheet( nPara, pStyle );
1791
0
            }
1792
0
        }
1793
0
    }
1794
1795
0
    rOutl.GetUndoManager().Clear();
1796
1797
0
    return bRet;
1798
0
}
1799
1800
void OutlineViewShell::WriteUserDataSequence ( css::uno::Sequence < css::beans::PropertyValue >& rSequence )
1801
0
{
1802
0
    WriteFrameViewData();
1803
1804
0
    ViewShell::WriteUserDataSequence( rSequence );
1805
0
}
1806
1807
void OutlineViewShell::ReadUserDataSequence ( const css::uno::Sequence < css::beans::PropertyValue >& rSequence )
1808
0
{
1809
0
    WriteFrameViewData();
1810
1811
0
    ViewShell::ReadUserDataSequence( rSequence );
1812
1813
0
    ReadFrameViewData( mpFrameView );
1814
0
}
1815
1816
void OutlineViewShell::VisAreaChanged(const ::tools::Rectangle& rRect)
1817
0
{
1818
0
    ViewShell::VisAreaChanged( rRect );
1819
1820
0
    GetViewShellBase().GetDrawController()->FireVisAreaChanged(rRect);
1821
0
}
1822
1823
/** If there is a valid controller then create a new instance of
1824
    <type>AccessibleDrawDocumentView</type>.  Otherwise return an empty
1825
    reference.
1826
*/
1827
rtl::Reference<comphelper::OAccessible>
1828
OutlineViewShell::CreateAccessibleDocumentView(::sd::Window* pWindow)
1829
0
{
1830
0
    OSL_ASSERT (GetViewShell()!=nullptr);
1831
0
    if (GetViewShell()->GetController() != nullptr)
1832
0
    {
1833
0
        rtl::Reference<::accessibility::AccessibleOutlineView> pDocumentView =
1834
0
            new ::accessibility::AccessibleOutlineView (
1835
0
                pWindow,
1836
0
                this,
1837
0
                GetViewShell()->GetController(),
1838
0
                pWindow->GetAccessibleParent());
1839
0
        pDocumentView->Init();
1840
0
        return pDocumentView;
1841
0
    }
1842
1843
0
    SAL_WARN("sd", "OutlineViewShell::CreateAccessibleDocumentView: no controller");
1844
0
    return {};
1845
0
}
1846
1847
void OutlineViewShell::GetState (SfxItemSet& rSet)
1848
0
{
1849
    // Iterate over all requested items in the set.
1850
0
    SfxWhichIter aIter( rSet );
1851
0
    sal_uInt16 nWhich = aIter.FirstWhich();
1852
0
    while (nWhich)
1853
0
    {
1854
0
        switch (nWhich)
1855
0
        {
1856
0
            case SID_SEARCH_ITEM:
1857
0
            case SID_SEARCH_OPTIONS:
1858
                // Call common (old) implementation in the document shell.
1859
0
                GetDocSh()->GetState (rSet);
1860
0
                break;
1861
0
            default:
1862
0
                SAL_WARN("sd", "OutlineViewShell::GetState(): can not handle which id " << nWhich);
1863
0
                break;
1864
0
        }
1865
0
        nWhich = aIter.NextWhich();
1866
0
    }
1867
0
}
1868
1869
void OutlineViewShell::SetCurrentPage (SdPage* pPage)
1870
0
{
1871
    // Adapt the selection of the model.
1872
0
    for (sal_uInt16 i=0; i<GetDoc()->GetSdPageCount(PageKind::Standard); i++)
1873
0
        GetDoc()->SetSelected(
1874
0
            GetDoc()->GetSdPage(i, PageKind::Standard),
1875
0
            false);
1876
0
    GetDoc()->SetSelected (pPage, true);
1877
1878
0
    DrawController& rController(*GetViewShellBase().GetDrawController());
1879
0
    rController.FireSelectionChangeListener();
1880
0
    rController.FireSwitchCurrentPage (pPage);
1881
1882
0
    pOlView->SetActualPage(pPage);
1883
0
}
1884
1885
} // end of namespace sd
1886
1887
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */