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/NotesPanelViewShell.cxx
Line
Count
Source
1
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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
10
#include <NotesPanelViewShell.hxx>
11
#include <NotesPanelView.hxx>
12
#include <sal/log.hxx>
13
14
#include <DrawController.hxx>
15
#include <DrawDocShell.hxx>
16
#include <DrawViewShell.hxx>
17
#include <FrameView.hxx>
18
#include <SpellDialogChildWindow.hxx>
19
#include <ViewShellBase.hxx>
20
#include <Window.hxx>
21
#include <app.hrc>
22
#include <com/sun/star/linguistic2/XThesaurus.hpp>
23
#include <drawdoc.hxx>
24
#include <editeng/editobj.hxx>
25
#include <editeng/editstat.hxx>
26
#include <editeng/editund2.hxx>
27
#include <editeng/eeitem.hxx>
28
#include <editeng/flditem.hxx>
29
#include <editeng/outlobj.hxx>
30
#include <editeng/unolingu.hxx>
31
#include <framework/FrameworkHelper.hxx>
32
#include <fubullet.hxx>
33
#include <fuinsert.hxx>
34
#include <fuchar.hxx>
35
#include <fucushow.hxx>
36
#include <fuexpand.hxx>
37
#include <fuinsfil.hxx>
38
#include <fuolbull.hxx>
39
#include <fuoltext.hxx>
40
#include <fuprobjs.hxx>
41
#include <fuscale.hxx>
42
#include <fusldlg.hxx>
43
#include <fusumry.hxx>
44
#include <futempl.hxx>
45
#include <futhes.hxx>
46
#include <memory>
47
#include <sdabstdlg.hxx>
48
#include <sdmod.hxx>
49
#include <sdpage.hxx>
50
#include <sdresid.hxx>
51
#include <sfx2/bindings.hxx>
52
#include <sfx2/devtools/DevelopmentToolChildWindow.hxx>
53
#include <sfx2/dispatch.hxx>
54
#include <sfx2/docfile.hxx>
55
#include <sfx2/infobar.hxx>
56
#include <sfx2/objface.hxx>
57
#include <sfx2/request.hxx>
58
#include <sfx2/sidebar/SidebarChildWindow.hxx>
59
#include <sfx2/tplpitem.hxx>
60
#include <sfx2/viewfrm.hxx>
61
#include <sfx2/zoomitem.hxx>
62
#include <slideshow.hxx>
63
#include <sot/formats.hxx>
64
#include <stlsheet.hxx>
65
#include <strings.hrc>
66
#include <svl/cjkoptions.hxx>
67
#include <svl/srchitem.hxx>
68
#include <svl/stritem.hxx>
69
#include <svl/whiter.hxx>
70
#include <svtools/cliplistener.hxx>
71
#include <svx/hlnkitem.hxx>
72
#include <svx/hyperdlg.hxx>
73
#include <svx/svdoutl.hxx>
74
#include <svx/svxids.hrc>
75
#include <svx/zoomslideritem.hxx>
76
#include <unotools/useroptions.hxx>
77
#include <vcl/EnumContext.hxx>
78
#include <vcl/commandevent.hxx>
79
#include <zoomlist.hxx>
80
81
#include <TextObjectBar.hxx>
82
83
#define ShellClass_NotesPanelViewShell
84
using namespace sd;
85
#include <sdslots.hxx>
86
87
namespace sd
88
{
89
0
#define MIN_ZOOM 10 // minimum zoom factor
90
0
#define MAX_ZOOM 1000 // maximum zoom factor
91
92
/**
93
 * Declare SFX-Slotmap and standard interface
94
 */
95
SFX_IMPL_INTERFACE(NotesPanelViewShell, SfxShell)
96
97
void NotesPanelViewShell::InitInterface_Impl()
98
0
{
99
0
    GetStaticInterface()->RegisterPopupMenu(u"drawtext"_ustr);
100
101
0
    GetStaticInterface()->RegisterChildWindow(SvxHlinkDlgWrapper::GetChildWindowId());
102
0
    GetStaticInterface()->RegisterChildWindow(::sd::SpellDialogChildWindow::GetChildWindowId());
103
0
    GetStaticInterface()->RegisterChildWindow(SID_SEARCH_DLG);
104
0
    GetStaticInterface()->RegisterChildWindow(
105
0
        sfx2::sidebar::SidebarChildWindow::GetChildWindowId());
106
0
    GetStaticInterface()->RegisterChildWindow(DevelopmentToolChildWindow::GetChildWindowId());
107
0
}
108
109
/**
110
 * Default constructor, windows must not center themselves automatically
111
 */
112
NotesPanelViewShell::NotesPanelViewShell(ViewShellBase& rViewShellBase, vcl::Window* pParentWindow,
113
                                         FrameView* pFrameViewArgument)
114
0
    : ViewShell(pParentWindow, rViewShellBase)
115
0
{
116
0
    if (pFrameViewArgument != nullptr)
117
0
        mpFrameView = pFrameViewArgument;
118
0
    else
119
0
        mpFrameView = new FrameView(GetDoc());
120
121
0
    mpFrameView->Connect();
122
123
0
    Construct();
124
125
0
    SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::DrawText));
126
127
0
    doShow();
128
0
    mpHorizontalScrollBar->Hide();
129
0
}
130
131
NotesPanelViewShell::~NotesPanelViewShell()
132
0
{
133
0
    DisposeFunctions();
134
0
    mpFrameView->Disconnect();
135
    // if ( mxClipEvtLstnr.is() )
136
    // {
137
    //     mxClipEvtLstnr->RemoveListener( GetActiveWindow() );
138
    //     mxClipEvtLstnr->ClearCallbackLink();     // prevent callback if another thread is waiting
139
    // }
140
0
}
141
142
void NotesPanelViewShell::Construct()
143
0
{
144
0
    meShellType = ST_NOTESPANEL;
145
146
0
    Size aSize(29700, 21000);
147
0
    Point aWinPos(0, 0);
148
0
    Point aViewOrigin(0, 0);
149
0
    GetActiveWindow()->SetMinZoomAutoCalc(false);
150
0
    GetActiveWindow()->SetMinZoom(MIN_ZOOM);
151
0
    GetActiveWindow()->SetMaxZoom(MAX_ZOOM);
152
0
    InitWindows(aViewOrigin, aSize, aWinPos);
153
154
0
    mpNotesPanelView = std::make_unique<NotesPanelView>(*GetDocSh(), GetActiveWindow(), *this);
155
0
    mpView = mpNotesPanelView.get();
156
157
0
    SetPool(&GetDoc()->GetPool());
158
0
    SetZoom(70);
159
160
    // Apply settings of FrameView
161
0
    ReadFrameViewData(mpFrameView);
162
163
0
    SetName(u"NotesPanelViewShell"_ustr);
164
    // TODO: Help ID
165
    // GetActiveWindow()->SetHelpId(HID_SDNOTESPANEL);
166
0
}
167
168
void NotesPanelViewShell::Paint(const ::tools::Rectangle& rRect, ::sd::Window* pWin)
169
0
{
170
0
    if (mpNotesPanelView)
171
0
        mpNotesPanelView->Paint(rRect, pWin);
172
0
}
173
174
bool NotesPanelViewShell::PrepareClose(bool bUI)
175
0
{
176
0
    if (!ViewShell::PrepareClose(bUI))
177
0
        return false;
178
179
0
    return true;
180
0
}
181
182
void NotesPanelViewShell::VirtHScrollHdl(ScrollAdaptor* /*pHScroll*/)
183
0
{
184
    // no horizontal scroll
185
0
    return;
186
0
}
187
188
void NotesPanelViewShell::UpdateScrollBars()
189
0
{
190
0
    if (!mpVerticalScrollBar)
191
0
        return;
192
193
0
    OutlinerView* pOutlinerView = mpNotesPanelView->GetOutlinerView();
194
0
    const SdOutliner& rOutliner = mpNotesPanelView->GetOutliner();
195
196
0
    int nVUpper = rOutliner.GetTextHeight();
197
0
    int nVCurrentDocPos = pOutlinerView->GetVisArea().Top();
198
0
    const Size aOut(pOutlinerView->GetOutputArea().GetSize());
199
0
    int nVStepIncrement = aOut.Height() * 2 / 10;
200
0
    int nVPageIncrement = aOut.Height() * 8 / 10;
201
0
    int nVPageSize = aOut.Height();
202
203
0
    nVPageSize = std::min(nVPageSize, nVUpper);
204
205
0
    mpVerticalScrollBar->SetRange({ 0, nVUpper });
206
0
    mpVerticalScrollBar->SetVisibleSize(nVPageSize);
207
0
    mpVerticalScrollBar->SetThumbPos(nVCurrentDocPos);
208
0
    mpVerticalScrollBar->SetLineSize(nVStepIncrement);
209
0
    mpVerticalScrollBar->SetPageSize(nVPageIncrement);
210
211
    // TODO: This is a workaround for the view going blank when overflow the current view with text.
212
    // The extra faulty draw call still happens.. Should get rid of that before removing this.
213
0
    VirtVScrollHdl(mpVerticalScrollBar);
214
0
}
215
216
void NotesPanelViewShell::VirtVScrollHdl(ScrollAdaptor* /*pVScroll*/)
217
0
{
218
0
    OutlinerView* pOutlinerView = mpNotesPanelView->GetOutlinerView();
219
220
0
    if (pOutlinerView)
221
0
    {
222
0
        pOutlinerView->SetVisArea({ Point(0, mpVerticalScrollBar->GetThumbPos()),
223
0
                                    pOutlinerView->GetVisArea().GetSize() });
224
0
        pOutlinerView->GetEditView().Invalidate();
225
226
0
        auto currentDocPos = pOutlinerView->GetVisArea().Top();
227
0
        auto nDiff = currentDocPos - mpVerticalScrollBar->GetThumbPos();
228
0
        pOutlinerView->Scroll(0, nDiff);
229
0
    }
230
0
}
231
232
void NotesPanelViewShell::VisAreaChanged(const ::tools::Rectangle& rRect)
233
0
{
234
0
    ViewShell::VisAreaChanged(rRect);
235
0
    GetViewShellBase().GetDrawController()->FireVisAreaChanged(rRect);
236
0
}
237
238
0
void NotesPanelViewShell::onGrabFocus() { mpNotesPanelView->onGrabFocus(); }
239
240
0
void NotesPanelViewShell::onLoseFocus() { mpNotesPanelView->onLoseFocus(); }
241
242
void NotesPanelViewShell::ArrangeGUIElements()
243
0
{
244
    // Retrieve the current size (thickness) of the scroll bars.  That is
245
    // the width of the vertical and the height of the horizontal scroll
246
    // bar.
247
0
    int nScrollBarSize = GetParentWindow()->GetSettings().GetStyleSettings().GetScrollBarSize();
248
0
    maScrBarWH = Size(nScrollBarSize, nScrollBarSize);
249
250
0
    ViewShell::ArrangeGUIElements();
251
252
0
    ::sd::Window* pWindow = mpContentWindow.get();
253
0
    if (pWindow == nullptr)
254
0
        return;
255
256
0
    pWindow->SetMinZoomAutoCalc(false);
257
0
    mpNotesPanelView->onResize();
258
0
}
259
260
0
SdPage* NotesPanelViewShell::GetActualPage() { return getCurrentPage(); }
261
262
SdPage* NotesPanelViewShell::getCurrentPage() const
263
0
{
264
0
    SdPage* pCurrentPage = nullptr;
265
266
0
    std::shared_ptr<ViewShell> pMainViewShell = GetViewShellBase().GetMainViewShell();
267
0
    if (pMainViewShell)
268
0
        pCurrentPage = pMainViewShell->GetActualPage();
269
270
0
    if (!pCurrentPage)
271
0
        return nullptr;
272
273
0
    switch (pCurrentPage->GetPageKind())
274
0
    {
275
0
        case PageKind::Standard:
276
0
            return GetDoc()->GetSdPage((pCurrentPage->GetPageNum() - 1) >> 1, PageKind::Notes);
277
0
        case PageKind::Notes:
278
0
            return pCurrentPage;
279
0
        case PageKind::Handout:
280
0
        default:
281
0
            return nullptr;
282
0
    }
283
0
}
284
285
css::uno::Reference<css::drawing::XDrawSubController> NotesPanelViewShell::CreateSubController()
286
0
{
287
    // SubController appears is only relevant for MainViewShell
288
    // NotesPanel isn't meant as a MainViewShell
289
0
    return {};
290
0
}
291
292
void NotesPanelViewShell::ReadFrameViewData(FrameView* /*pView*/)
293
0
{
294
0
    DrawController& rController(*GetViewShellBase().GetDrawController());
295
0
    rController.FireSelectionChangeListener();
296
0
}
297
298
0
void NotesPanelViewShell::WriteFrameViewData() {}
299
300
/**
301
 * Activate(): during the first invocation the fields get updated
302
 */
303
void NotesPanelViewShell::Activate(bool bIsMDIActivate)
304
0
{
305
0
    if (!mbInitialized)
306
0
    {
307
0
        mbInitialized = true;
308
0
        SfxRequest aRequest(SID_EDIT_OUTLINER, SfxCallMode::SLOT, GetDoc()->GetItemPool());
309
0
        FuPermanent(aRequest);
310
0
    }
311
312
0
    ViewShell::Activate(bIsMDIActivate);
313
314
0
    if (bIsMDIActivate)
315
0
    {
316
0
        OutlinerView* pOutlinerView = mpNotesPanelView->GetOutlinerView();
317
0
        ::Outliner& rOutl = pOutlinerView->GetOutliner();
318
0
        rOutl.UpdateFields();
319
0
    }
320
0
}
321
322
/**
323
 * SfxRequests for permanent functions
324
 */
325
void NotesPanelViewShell::FuPermanent(SfxRequest& rReq)
326
0
{
327
0
    if (HasCurrentFunction())
328
0
    {
329
0
        DeactivateCurrentFunction(true);
330
0
    }
331
332
0
    switch (rReq.GetSlot())
333
0
    {
334
0
        case SID_EDIT_OUTLINER:
335
0
        {
336
0
            ::Outliner& rOutl = mpNotesPanelView->GetOutliner();
337
0
            rOutl.GetUndoManager().Clear();
338
0
            rOutl.UpdateFields();
339
340
0
            SetCurrentFunction(FuNotesPane::Create(*this, GetActiveWindow(), mpNotesPanelView.get(),
341
0
                                                   *GetDoc(), rReq));
342
343
0
            rReq.Done();
344
0
        }
345
0
        break;
346
347
0
        default:
348
0
            break;
349
0
    }
350
351
0
    if (HasOldFunction())
352
0
    {
353
0
        GetOldFunction()->Deactivate();
354
0
        SetOldFunction(nullptr);
355
0
    }
356
357
0
    if (HasCurrentFunction())
358
0
    {
359
0
        GetCurrentFunction()->Activate();
360
0
        SetOldFunction(GetCurrentFunction());
361
0
    }
362
0
}
363
364
/**
365
 * Zoom with zoom factor. Inform OutlinerView
366
 */
367
void NotesPanelViewShell::SetZoom(::tools::Long nZoom)
368
0
{
369
0
    ViewShell::SetZoom(nZoom);
370
371
0
    ::sd::Window* pWindow = mpContentWindow.get();
372
0
    if (pWindow)
373
0
        mpNotesPanelView->onResize();
374
375
0
    GetViewFrame()->GetBindings().Invalidate(SID_ATTR_ZOOM);
376
0
    GetViewFrame()->GetBindings().Invalidate(SID_ATTR_ZOOMSLIDER);
377
0
}
378
379
/**
380
 * Zoom with zoom rectangle. Inform OutlinerView
381
 */
382
void NotesPanelViewShell::SetZoomRect(const ::tools::Rectangle& rZoomRect)
383
0
{
384
0
    ViewShell::SetZoomRect(rZoomRect);
385
386
0
    ::sd::Window* pWindow = mpContentWindow.get();
387
0
    if (pWindow)
388
0
        mpNotesPanelView->onResize();
389
390
0
    GetViewFrame()->GetBindings().Invalidate(SID_ATTR_ZOOM);
391
0
    GetViewFrame()->GetBindings().Invalidate(SID_ATTR_ZOOMSLIDER);
392
0
}
393
394
void NotesPanelViewShell::ExecCtrl(SfxRequest& rReq)
395
0
{
396
0
    sal_uInt16 nSlot = rReq.GetSlot();
397
0
    switch (nSlot)
398
0
    {
399
0
        case SID_MAIL_SCROLLBODY_PAGEDOWN:
400
0
        {
401
0
            ExecReq(rReq);
402
0
            break;
403
0
        }
404
405
0
        case SID_OPT_LOCALE_CHANGED:
406
0
        {
407
0
            mpNotesPanelView->GetOutliner().UpdateFields();
408
0
            rReq.Done();
409
0
            break;
410
0
        }
411
412
0
        default:
413
0
            break;
414
0
    }
415
0
}
416
417
void NotesPanelViewShell::GetCtrlState(SfxItemSet& rSet)
418
0
{
419
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_HYPERLINK_GETLINK))
420
0
    {
421
0
        SvxHyperlinkItem aHLinkItem;
422
423
0
        OutlinerView* pOLV = mpNotesPanelView->GetOutlinerView();
424
0
        if (pOLV)
425
0
        {
426
0
            const SvxFieldItem* pFieldItem = pOLV->GetFieldAtSelection();
427
0
            if (pFieldItem)
428
0
            {
429
0
                ESelection aSel = pOLV->GetSelection();
430
0
                if (abs(aSel.end.nIndex - aSel.start.nIndex) == 1)
431
0
                {
432
0
                    const SvxFieldData* pField = pFieldItem->GetField();
433
0
                    if (auto pUrlField = dynamic_cast<const SvxURLField*>(pField))
434
0
                    {
435
0
                        aHLinkItem.SetName(pUrlField->GetRepresentation());
436
0
                        aHLinkItem.SetURL(pUrlField->GetURL());
437
0
                        aHLinkItem.SetTargetFrame(pUrlField->GetTargetFrame());
438
0
                    }
439
0
                }
440
0
            }
441
0
        }
442
0
        rSet.Put(aHLinkItem);
443
0
    }
444
0
    rSet.Put(SfxBoolItem(SID_READONLY_MODE, GetDocSh()->IsReadOnly()));
445
446
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_MAIL_SCROLLBODY_PAGEDOWN))
447
0
        rSet.Put(SfxBoolItem(SID_MAIL_SCROLLBODY_PAGEDOWN, true));
448
449
0
    if (!(SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HALFWIDTH)
450
0
          || SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_FULLWIDTH)
451
0
          || SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_HIRAGANA)
452
0
          || SfxItemState::DEFAULT == rSet.GetItemState(SID_TRANSLITERATE_KATAKANA)))
453
0
        return;
454
455
0
    if (!SvtCJKOptions::IsChangeCaseMapEnabled())
456
0
    {
457
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_HALFWIDTH, false);
458
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_FULLWIDTH, false);
459
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_HIRAGANA, false);
460
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_KATAKANA, false);
461
0
        rSet.DisableItem(SID_TRANSLITERATE_HALFWIDTH);
462
0
        rSet.DisableItem(SID_TRANSLITERATE_FULLWIDTH);
463
0
        rSet.DisableItem(SID_TRANSLITERATE_HIRAGANA);
464
0
        rSet.DisableItem(SID_TRANSLITERATE_KATAKANA);
465
0
    }
466
0
    else
467
0
    {
468
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_HALFWIDTH, true);
469
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_FULLWIDTH, true);
470
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_HIRAGANA, true);
471
0
        GetViewFrame()->GetBindings().SetVisibleState(SID_TRANSLITERATE_KATAKANA, true);
472
0
    }
473
0
}
474
475
void NotesPanelViewShell::GetAttrState(SfxItemSet& rSet)
476
0
{
477
0
    SfxWhichIter aIter(rSet);
478
0
    sal_uInt16 nWhich = aIter.FirstWhich();
479
0
    SfxAllItemSet aAllSet(*rSet.GetPool());
480
481
0
    while (nWhich)
482
0
    {
483
0
        sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) ? GetPool().GetSlotId(nWhich) : nWhich;
484
485
0
        switch (nSlotId)
486
0
        {
487
0
            case SID_STYLE_FAMILY2:
488
0
            case SID_STYLE_FAMILY3:
489
0
            {
490
0
                rSet.DisableItem(nWhich);
491
0
            }
492
0
            break;
493
494
0
            case SID_STYLE_FAMILY5:
495
0
            {
496
0
                SfxStyleSheet* pStyleSheet = mpNotesPanelView->GetOutlinerView()->GetStyleSheet();
497
498
0
                if (pStyleSheet)
499
0
                {
500
0
                    pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
501
502
0
                    if (pStyleSheet)
503
0
                    {
504
0
                        SfxTemplateItem aItem(nWhich, pStyleSheet->GetName());
505
0
                        aAllSet.Put(aItem);
506
0
                    }
507
0
                }
508
509
0
                if (!pStyleSheet)
510
0
                {
511
0
                    SfxTemplateItem aItem(nWhich, OUString());
512
0
                    aAllSet.Put(aItem);
513
0
                }
514
0
            }
515
0
            break;
516
517
0
            case SID_STYLE_EDIT:
518
0
            {
519
0
                std::unique_ptr<SfxUInt16Item> pFamilyItem;
520
0
                GetViewFrame()->GetBindings().QueryState(SID_STYLE_FAMILY, pFamilyItem);
521
0
                if (pFamilyItem
522
0
                    && static_cast<SfxStyleFamily>(pFamilyItem->GetValue())
523
0
                           == SfxStyleFamily::Pseudo)
524
0
                {
525
0
                    rSet.DisableItem(nWhich);
526
0
                }
527
0
            }
528
0
            break;
529
530
0
            case SID_STYLE_UPDATE_BY_EXAMPLE:
531
0
            {
532
0
                OutlinerView* pOV = mpNotesPanelView->GetOutlinerView();
533
0
                ESelection aESel(pOV->GetSelection());
534
535
0
                if (aESel.HasRange())
536
                    // spanned selection, i.e. StyleSheet and/or
537
                    // attribution not necessarily unique
538
0
                    rSet.DisableItem(nWhich);
539
0
            }
540
0
            break;
541
542
0
            case SID_STYLE_NEW:
543
0
            case SID_STYLE_DELETE:
544
0
            case SID_STYLE_HIDE:
545
0
            case SID_STYLE_SHOW:
546
0
            case SID_STYLE_NEW_BY_EXAMPLE:
547
0
            case SID_STYLE_WATERCAN:
548
0
            {
549
0
                rSet.DisableItem(nWhich);
550
0
            }
551
0
            break;
552
0
            case FN_NUM_BULLET_ON:
553
0
            case FN_NUM_NUMBERING_ON:
554
0
            {
555
0
                bool bIsBullet = false;
556
0
                bool bIsNumbering = false;
557
0
                OutlinerView* pOlView = mpNotesPanelView->GetTextEditOutlinerView();
558
0
                if (pOlView)
559
0
                {
560
0
                    pOlView->IsBulletOrNumbering(bIsBullet, bIsNumbering);
561
0
                }
562
0
                rSet.Put(SfxBoolItem(FN_NUM_BULLET_ON, bIsBullet));
563
0
                rSet.Put(SfxBoolItem(FN_NUM_NUMBERING_ON, bIsNumbering));
564
0
            }
565
0
            break;
566
567
0
            default:
568
0
                break;
569
0
        }
570
571
0
        nWhich = aIter.NextWhich();
572
0
    }
573
574
0
    rSet.Put(aAllSet, false);
575
0
    TextObjectBar::GetAttrStateImpl(*this, mpView, rSet, nullptr);
576
0
}
577
578
void NotesPanelViewShell::GetState(SfxItemSet& rSet)
579
0
{
580
    // Iterate over all requested items in the set.
581
0
    SfxWhichIter aIter(rSet);
582
0
    sal_uInt16 nWhich = aIter.FirstWhich();
583
0
    while (nWhich)
584
0
    {
585
0
        switch (nWhich)
586
0
        {
587
0
            case FID_SEARCH_NOW:
588
0
            case SID_SEARCH_ITEM:
589
0
            case SID_SEARCH_OPTIONS:
590
                // Call common (old) implementation in the document shell.
591
0
                GetDocSh()->GetState(rSet);
592
0
                break;
593
0
            default:
594
0
                SAL_WARN("sd",
595
0
                         "NotesPanelViewShell::GetState(): can not handle which id " << nWhich);
596
0
                break;
597
0
        }
598
0
        nWhich = aIter.NextWhich();
599
0
    }
600
0
}
601
602
void NotesPanelViewShell::GetCharState(SfxItemSet& rSet)
603
0
{
604
0
    TextObjectBar::GetCharStateImpl(*this, mpView, rSet);
605
0
}
606
607
0
void NotesPanelViewShell::ExecStatusBar(SfxRequest& /*rReq*/) {}
608
609
void NotesPanelViewShell::GetStatusBarState(SfxItemSet& rSet)
610
0
{
611
    // Zoom-Item
612
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_ATTR_ZOOM))
613
0
    {
614
0
        sal_uInt16 nZoom = static_cast<sal_uInt16>(GetActiveWindow()->GetZoom());
615
616
0
        std::unique_ptr<SvxZoomItem> pZoomItem(new SvxZoomItem(SvxZoomType::PERCENT, nZoom));
617
618
        // limit area
619
0
        SvxZoomEnableFlags nZoomValues = SvxZoomEnableFlags::ALL;
620
0
        nZoomValues &= ~SvxZoomEnableFlags::OPTIMAL;
621
0
        nZoomValues &= ~SvxZoomEnableFlags::WHOLEPAGE;
622
0
        nZoomValues &= ~SvxZoomEnableFlags::PAGEWIDTH;
623
624
0
        pZoomItem->SetValueSet(nZoomValues);
625
0
        rSet.Put(std::move(pZoomItem));
626
0
    }
627
628
0
    if (SfxItemState::DEFAULT == rSet.GetItemState(SID_ATTR_ZOOMSLIDER))
629
0
    {
630
0
        if (GetDocSh()->IsUIActive() || !GetActiveWindow())
631
0
        {
632
0
            rSet.DisableItem(SID_ATTR_ZOOMSLIDER);
633
0
        }
634
0
        else
635
0
        {
636
0
            sd::Window* pActiveWindow = GetActiveWindow();
637
0
            SvxZoomSliderItem aZoomItem(static_cast<sal_uInt16>(pActiveWindow->GetZoom()),
638
0
                                        static_cast<sal_uInt16>(pActiveWindow->GetMinZoom()),
639
0
                                        static_cast<sal_uInt16>(pActiveWindow->GetMaxZoom()));
640
0
            aZoomItem.AddSnappingPoint(100);
641
0
            rSet.Put(aZoomItem);
642
0
        }
643
0
    }
644
645
    // TODO: page view and layout strings
646
    // rSet.Put( SfxStringItem( SID_STATUS_PAGE, aPageStr ) );
647
    // rSet.Put( SfxStringItem( SID_STATUS_LAYOUT, aLayoutStr ) );
648
0
}
649
650
void NotesPanelViewShell::FuTemporary(SfxRequest& rReq)
651
0
{
652
0
    DeactivateCurrentFunction();
653
654
0
    OutlinerView* pOutlinerView = mpNotesPanelView->GetOutlinerView();
655
0
    sal_uInt16 nSId = rReq.GetSlot();
656
657
0
    switch (nSId)
658
0
    {
659
0
        case SID_ATTR_ZOOM:
660
0
        {
661
0
            const SfxItemSet* pArgs = rReq.GetArgs();
662
663
0
            if (pArgs)
664
0
            {
665
0
                SvxZoomType eZT = pArgs->Get(SID_ATTR_ZOOM).GetType();
666
0
                switch (eZT)
667
0
                {
668
0
                    case SvxZoomType::PERCENT:
669
0
                        SetZoom(static_cast<::tools::Long>(pArgs->Get(SID_ATTR_ZOOM).GetValue()));
670
0
                        Invalidate(SID_ATTR_ZOOM);
671
0
                        Invalidate(SID_ATTR_ZOOMSLIDER);
672
0
                        break;
673
0
                    default:
674
0
                        break;
675
0
                }
676
0
                rReq.Done();
677
0
            }
678
0
            else
679
0
            {
680
                // open the zoom dialog here
681
0
                SetCurrentFunction(FuScale::Create(*this, GetActiveWindow(), mpNotesPanelView.get(),
682
0
                                                   *GetDoc(), rReq));
683
0
            }
684
0
            Cancel();
685
0
        }
686
0
        break;
687
688
0
        case SID_ATTR_ZOOMSLIDER:
689
0
        {
690
0
            const SfxItemSet* pArgs = rReq.GetArgs();
691
692
0
            const SfxUInt16Item* pScale
693
0
                = (pArgs && pArgs->Count() == 1) ? rReq.GetArg(SID_ATTR_ZOOMSLIDER) : nullptr;
694
0
            if (pScale && CHECK_RANGE(5, pScale->GetValue(), 3000))
695
0
            {
696
0
                SetZoom(pScale->GetValue());
697
698
0
                SfxBindings& rBindings = GetViewFrame()->GetBindings();
699
0
                rBindings.Invalidate(SID_ATTR_ZOOM);
700
0
                rBindings.Invalidate(SID_ZOOM_IN);
701
0
                rBindings.Invalidate(SID_ZOOM_OUT);
702
0
                rBindings.Invalidate(SID_ATTR_ZOOMSLIDER);
703
0
            }
704
705
0
            Cancel();
706
0
            rReq.Done();
707
0
            break;
708
0
        }
709
710
0
        case SID_ZOOM_IN:
711
0
        {
712
0
            SetZoom(std::min<::tools::Long>(GetActiveWindow()->GetZoom() * 2,
713
0
                                            GetActiveWindow()->GetMaxZoom()));
714
0
            ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic(
715
0
                ::tools::Rectangle(Point(0, 0), GetActiveWindow()->GetOutputSizePixel()));
716
0
            mpZoomList->InsertZoomRect(aVisAreaWin);
717
0
            Invalidate(SID_ATTR_ZOOM);
718
0
            Invalidate(SID_ZOOM_IN);
719
0
            Invalidate(SID_ZOOM_OUT);
720
0
            Invalidate(SID_ATTR_ZOOMSLIDER);
721
0
            Cancel();
722
0
            rReq.Done();
723
0
        }
724
0
        break;
725
726
0
        case SID_SIZE_REAL:
727
0
        {
728
0
            SetZoom(100);
729
0
            ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic(
730
0
                ::tools::Rectangle(Point(0, 0), GetActiveWindow()->GetOutputSizePixel()));
731
0
            mpZoomList->InsertZoomRect(aVisAreaWin);
732
0
            Invalidate(SID_ATTR_ZOOM);
733
0
            Invalidate(SID_ATTR_ZOOMSLIDER);
734
0
            Cancel();
735
0
            rReq.Done();
736
0
        }
737
0
        break;
738
739
0
        case SID_ZOOM_OUT:
740
0
        {
741
0
            SetZoom(std::max<::tools::Long>(GetActiveWindow()->GetZoom() / 2,
742
0
                                            GetActiveWindow()->GetMinZoom()));
743
0
            ::tools::Rectangle aVisAreaWin = GetActiveWindow()->PixelToLogic(
744
0
                ::tools::Rectangle(Point(0, 0), GetActiveWindow()->GetOutputSizePixel()));
745
0
            mpZoomList->InsertZoomRect(aVisAreaWin);
746
0
            Invalidate(SID_ATTR_ZOOM);
747
0
            Invalidate(SID_ZOOM_OUT);
748
0
            Invalidate(SID_ZOOM_IN);
749
0
            Invalidate(SID_ATTR_ZOOMSLIDER);
750
0
            Cancel();
751
0
            rReq.Done();
752
0
        }
753
0
        break;
754
755
0
        case SID_SELECTALL:
756
0
        {
757
0
            ::Outliner& rOutl = mpNotesPanelView->GetOutliner();
758
0
            sal_Int32 nParaCount = rOutl.GetParagraphCount();
759
0
            if (nParaCount > 0)
760
0
            {
761
0
                pOutlinerView->SelectRange(0, nParaCount);
762
0
            }
763
0
            Cancel();
764
0
        }
765
0
        break;
766
767
0
        case SID_PRESENTATION:
768
0
        case SID_PRESENTATION_CURRENT_SLIDE:
769
0
        case SID_REHEARSE_TIMINGS:
770
0
        {
771
0
            slideshowhelp::ShowSlideShow(rReq, *GetDoc());
772
0
            Cancel();
773
0
            rReq.Done();
774
0
        }
775
0
        break;
776
777
0
        case SID_STYLE_EDIT:
778
0
        case SID_STYLE_UPDATE_BY_EXAMPLE:
779
0
        {
780
0
            if (rReq.GetArgs())
781
0
            {
782
0
                SetCurrentFunction(FuTemplate::Create(*this, GetActiveWindow(),
783
0
                                                      mpNotesPanelView.get(), *GetDoc(), rReq));
784
0
                Cancel();
785
0
            }
786
787
0
            rReq.Ignore();
788
0
        }
789
0
        break;
790
791
0
        case SID_PRESENTATION_DLG:
792
0
        {
793
0
            SetCurrentFunction(FuSlideShowDlg::Create(*this, GetActiveWindow(),
794
0
                                                      mpNotesPanelView.get(), *GetDoc(), rReq));
795
0
            Cancel();
796
0
        }
797
0
        break;
798
799
0
        case SID_REMOTE_DLG:
800
0
        {
801
#ifdef ENABLE_SDREMOTE
802
            SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
803
            ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetFrameWeld()));
804
            pDlg->Execute();
805
#endif
806
0
        }
807
0
        break;
808
809
0
        case SID_CUSTOMSHOW_DLG:
810
0
        {
811
0
            SetCurrentFunction(FuCustomShowDlg::Create(*this, GetActiveWindow(),
812
0
                                                       mpNotesPanelView.get(), *GetDoc(), rReq));
813
0
            Cancel();
814
0
        }
815
0
        break;
816
817
0
        case SID_PHOTOALBUM:
818
0
        {
819
0
            SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
820
0
            vcl::Window* pWin = GetActiveWindow();
821
0
            ScopedVclPtr<VclAbstractDialog> pDlg(
822
0
                pFact->CreateSdPhotoAlbumDialog(pWin ? pWin->GetFrameWeld() : nullptr, *GetDoc()));
823
824
0
            pDlg->Execute();
825
826
0
            Cancel();
827
0
            rReq.Ignore();
828
0
        }
829
0
        break;
830
831
0
        case SID_PASTE_SPECIAL:
832
0
        {
833
0
            SetCurrentFunction(FuInsertClipboard::Create(*this, GetActiveWindow(),
834
0
                                                         mpNotesPanelView.get(), *GetDoc(), rReq));
835
0
            Cancel();
836
0
            rReq.Ignore();
837
0
        }
838
0
        break;
839
0
    }
840
841
0
    if (HasCurrentFunction())
842
0
        GetCurrentFunction()->Activate();
843
844
0
    Invalidate(SID_CUT);
845
0
    Invalidate(SID_COPY);
846
0
    Invalidate(SID_PASTE);
847
0
    Invalidate(SID_PASTE_UNFORMATTED);
848
0
}
849
850
void NotesPanelViewShell::FuTemporaryModify(SfxRequest& rReq)
851
0
{
852
0
    DeactivateCurrentFunction();
853
854
0
    OutlinerView* pOutlinerView = mpNotesPanelView->GetOutlinerView();
855
856
0
    sal_uInt16 nSId = rReq.GetSlot();
857
0
    switch (nSId)
858
0
    {
859
0
        case SID_HYPERLINK_SETLINK:
860
0
        {
861
0
            const SfxItemSet* pReqArgs = rReq.GetArgs();
862
863
0
            if (pReqArgs)
864
0
            {
865
0
                const SvxHyperlinkItem* pHLItem = &pReqArgs->Get(SID_HYPERLINK_SETLINK);
866
867
0
                SvxFieldItem aURLItem(
868
0
                    SvxURLField(pHLItem->GetURL(), pHLItem->GetName(), SvxURLFormat::Repr),
869
0
                    EE_FEATURE_FIELD);
870
0
                ESelection aSel(pOutlinerView->GetSelection());
871
0
                pOutlinerView->InsertField(aURLItem);
872
0
                if (aSel.start.nIndex <= aSel.end.nIndex)
873
0
                    aSel.end.nIndex = aSel.start.nIndex + 1;
874
0
                else
875
0
                    aSel.start.nIndex = aSel.end.nIndex + 1;
876
0
                pOutlinerView->SetSelection(aSel);
877
0
            }
878
879
0
            Cancel();
880
0
            rReq.Ignore();
881
0
        }
882
0
        break;
883
884
0
        case FN_INSERT_SOFT_HYPHEN:
885
0
        case FN_INSERT_HARDHYPHEN:
886
0
        case FN_INSERT_HARD_SPACE:
887
0
        case FN_INSERT_NNBSP:
888
0
        case SID_INSERT_RLM:
889
0
        case SID_INSERT_LRM:
890
0
        case SID_INSERT_WJ:
891
0
        case SID_INSERT_ZWSP:
892
0
        case SID_CHARMAP:
893
0
        {
894
0
            SetCurrentFunction(FuBullet::Create(*this, GetActiveWindow(), mpNotesPanelView.get(),
895
0
                                                *GetDoc(), rReq));
896
0
            Cancel();
897
0
        }
898
0
        break;
899
900
0
        case FN_NUM_BULLET_ON:
901
0
        {
902
            // The value (sal_uInt16)0xFFFF means set bullet on/off.
903
0
            SfxUInt16Item aItem(FN_SVX_SET_BULLET, sal_uInt16(0xFFFF));
904
0
            GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_BULLET, SfxCallMode::RECORD,
905
0
                                                         { &aItem });
906
0
        }
907
0
        break;
908
909
0
        case FN_NUM_NUMBERING_ON:
910
0
        {
911
            // The value (sal_uInt16)0xFFFF means set bullet on/off.
912
0
            SfxUInt16Item aItem(FN_SVX_SET_NUMBER, sal_uInt16(0xFFFF));
913
0
            GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_NUMBER, SfxCallMode::RECORD,
914
0
                                                         { &aItem });
915
0
        }
916
0
        break;
917
918
0
        case SID_OUTLINE_BULLET:
919
0
        case FN_SVX_SET_BULLET:
920
0
        case FN_SVX_SET_NUMBER:
921
0
        {
922
0
            SetCurrentFunction(FuBulletAndPosition::Create(
923
0
                *this, GetActiveWindow(), mpNotesPanelView.get(), *GetDoc(), rReq));
924
0
            Cancel();
925
0
            SfxBindings& rBindings = GetViewFrame()->GetBindings();
926
0
            rBindings.Invalidate(FN_NUM_BULLET_ON);
927
0
            rBindings.Invalidate(FN_NUM_NUMBERING_ON);
928
0
        }
929
0
        break;
930
931
0
        case SID_THESAURUS:
932
0
        {
933
0
            SetCurrentFunction(FuThesaurus::Create(*this, GetActiveWindow(), mpNotesPanelView.get(),
934
0
                                                   *GetDoc(), rReq));
935
0
            Cancel();
936
0
            rReq.Ignore();
937
0
        }
938
0
        break;
939
940
0
        case SID_CHAR_DLG_EFFECT:
941
0
        case SID_CHAR_DLG:
942
0
        {
943
0
            SetCurrentFunction(
944
0
                FuChar::Create(*this, GetActiveWindow(), mpNotesPanelView.get(), *GetDoc(), rReq));
945
0
            Cancel();
946
0
        }
947
0
        break;
948
949
0
        case SID_INSERTFILE:
950
0
        {
951
0
            SetCurrentFunction(FuInsertFile::Create(*this, GetActiveWindow(),
952
0
                                                    mpNotesPanelView.get(), *GetDoc(), rReq));
953
0
            Cancel();
954
0
        }
955
0
        break;
956
957
0
        case SID_PRESENTATIONOBJECT:
958
0
        {
959
0
            SetCurrentFunction(FuPresentationObjects::Create(
960
0
                *this, GetActiveWindow(), mpNotesPanelView.get(), *GetDoc(), rReq));
961
0
            Cancel();
962
0
        }
963
0
        break;
964
965
0
        case SID_SET_DEFAULT:
966
0
        {
967
0
            pOutlinerView->RemoveAttribs(true); // sal_True = also paragraph attributes
968
0
            Cancel();
969
0
            rReq.Done();
970
0
        }
971
0
        break;
972
973
0
        case SID_SUMMARY_PAGE:
974
0
        {
975
0
            SetCurrentFunction(FuSummaryPage::Create(*this, GetActiveWindow(),
976
0
                                                     mpNotesPanelView.get(), *GetDoc(), rReq));
977
0
            Cancel();
978
0
        }
979
0
        break;
980
981
0
        case SID_EXPAND_PAGE:
982
0
        {
983
0
            SetCurrentFunction(FuExpandPage::Create(*this, GetActiveWindow(),
984
0
                                                    mpNotesPanelView.get(), *GetDoc(), rReq));
985
0
            Cancel();
986
0
        }
987
0
        break;
988
989
0
        case SID_INSERT_FLD_DATE_FIX:
990
0
        case SID_INSERT_FLD_DATE_VAR:
991
0
        case SID_INSERT_FLD_TIME_FIX:
992
0
        case SID_INSERT_FLD_TIME_VAR:
993
0
        case SID_INSERT_FLD_AUTHOR:
994
0
        case SID_INSERT_FLD_PAGE:
995
0
        case SID_INSERT_FLD_PAGE_TITLE:
996
0
        case SID_INSERT_FLD_PAGES:
997
0
        case SID_INSERT_FLD_FILE:
998
0
        {
999
0
            std::unique_ptr<SvxFieldItem> pFieldItem;
1000
1001
0
            switch (nSId)
1002
0
            {
1003
0
                case SID_INSERT_FLD_DATE_FIX:
1004
0
                    pFieldItem.reset(new SvxFieldItem(
1005
0
                        SvxDateField(Date(Date::SYSTEM), SvxDateType::Fix), EE_FEATURE_FIELD));
1006
0
                    break;
1007
1008
0
                case SID_INSERT_FLD_DATE_VAR:
1009
0
                    pFieldItem.reset(new SvxFieldItem(SvxDateField(), EE_FEATURE_FIELD));
1010
0
                    break;
1011
1012
0
                case SID_INSERT_FLD_TIME_FIX:
1013
0
                    pFieldItem.reset(new SvxFieldItem(
1014
0
                        SvxExtTimeField(::tools::Time(::tools::Time::SYSTEM), SvxTimeType::Fix),
1015
0
                        EE_FEATURE_FIELD));
1016
0
                    break;
1017
1018
0
                case SID_INSERT_FLD_TIME_VAR:
1019
0
                    pFieldItem.reset(new SvxFieldItem(SvxExtTimeField(), EE_FEATURE_FIELD));
1020
0
                    break;
1021
1022
0
                case SID_INSERT_FLD_AUTHOR:
1023
0
                {
1024
0
                    SvtUserOptions aUserOptions;
1025
0
                    pFieldItem.reset(new SvxFieldItem(SvxAuthorField(aUserOptions.GetFirstName(),
1026
0
                                                                     aUserOptions.GetLastName(),
1027
0
                                                                     aUserOptions.GetID()),
1028
0
                                                      EE_FEATURE_FIELD));
1029
0
                }
1030
0
                break;
1031
1032
0
                case SID_INSERT_FLD_PAGE:
1033
0
                    pFieldItem.reset(new SvxFieldItem(SvxPageField(), EE_FEATURE_FIELD));
1034
0
                    break;
1035
1036
0
                case SID_INSERT_FLD_PAGE_TITLE:
1037
0
                    pFieldItem.reset(new SvxFieldItem(SvxPageTitleField(), EE_FEATURE_FIELD));
1038
0
                    break;
1039
1040
0
                case SID_INSERT_FLD_PAGES:
1041
0
                    pFieldItem.reset(new SvxFieldItem(SvxPagesField(), EE_FEATURE_FIELD));
1042
0
                    break;
1043
1044
0
                case SID_INSERT_FLD_FILE:
1045
0
                {
1046
0
                    OUString aName;
1047
0
                    if (GetDocSh()->HasName())
1048
0
                        aName = GetDocSh()->GetMedium()->GetName();
1049
0
                    pFieldItem.reset(new SvxFieldItem(SvxExtFileField(aName), EE_FEATURE_FIELD));
1050
0
                }
1051
0
                break;
1052
0
            }
1053
1054
0
            const SvxFieldItem* pOldFldItem = pOutlinerView->GetFieldAtSelection();
1055
1056
0
            if (pOldFldItem
1057
0
                && (nullptr != dynamic_cast<const SvxURLField*>(pOldFldItem->GetField())
1058
0
                    || nullptr != dynamic_cast<const SvxDateField*>(pOldFldItem->GetField())
1059
0
                    || nullptr != dynamic_cast<const SvxTimeField*>(pOldFldItem->GetField())
1060
0
                    || nullptr != dynamic_cast<const SvxExtTimeField*>(pOldFldItem->GetField())
1061
0
                    || nullptr != dynamic_cast<const SvxExtFileField*>(pOldFldItem->GetField())
1062
0
                    || nullptr != dynamic_cast<const SvxAuthorField*>(pOldFldItem->GetField())
1063
0
                    || nullptr != dynamic_cast<const SvxPageField*>(pOldFldItem->GetField())
1064
0
                    || nullptr != dynamic_cast<const SvxPagesField*>(pOldFldItem->GetField())))
1065
0
            {
1066
                // select field, so it gets deleted on Insert
1067
0
                ESelection aSel = pOutlinerView->GetSelection();
1068
0
                if (aSel.start.nIndex == aSel.end.nIndex)
1069
0
                    aSel.end.nIndex++;
1070
0
                pOutlinerView->SetSelection(aSel);
1071
0
            }
1072
1073
0
            if (pFieldItem)
1074
0
                pOutlinerView->InsertField(*pFieldItem);
1075
1076
0
            pFieldItem.reset();
1077
1078
0
            Cancel();
1079
0
            rReq.Ignore();
1080
0
        }
1081
0
        break;
1082
1083
0
        case SID_MODIFY_FIELD:
1084
0
        {
1085
0
            const SvxFieldItem* pFldItem = pOutlinerView->GetFieldAtSelection();
1086
1087
0
            if (pFldItem
1088
0
                && (nullptr != dynamic_cast<const SvxDateField*>(pFldItem->GetField())
1089
0
                    || nullptr != dynamic_cast<const SvxAuthorField*>(pFldItem->GetField())
1090
0
                    || nullptr != dynamic_cast<const SvxExtFileField*>(pFldItem->GetField())
1091
0
                    || nullptr != dynamic_cast<const SvxExtTimeField*>(pFldItem->GetField())))
1092
0
            {
1093
                // Dialog...
1094
0
                SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
1095
0
                vcl::Window* pWin = GetActiveWindow();
1096
0
                ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg(pFact->CreateSdModifyFieldDlg(
1097
0
                    pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(),
1098
0
                    pOutlinerView->GetAttribs()));
1099
0
                if (pDlg->Execute() == RET_OK)
1100
0
                {
1101
0
                    std::unique_ptr<SvxFieldData> pField(pDlg->GetField());
1102
0
                    if (pField)
1103
0
                    {
1104
0
                        SvxFieldItem aFieldItem(*pField, EE_FEATURE_FIELD);
1105
                        //pOLV->DeleteSelected(); <-- unfortunately missing!
1106
                        // select field, so it gets deleted on Insert
1107
0
                        ESelection aSel = pOutlinerView->GetSelection();
1108
0
                        bool bSel = true;
1109
0
                        if (aSel.start.nIndex == aSel.end.nIndex)
1110
0
                        {
1111
0
                            bSel = false;
1112
0
                            aSel.end.nIndex++;
1113
0
                        }
1114
0
                        pOutlinerView->SetSelection(aSel);
1115
1116
0
                        pOutlinerView->InsertField(aFieldItem);
1117
1118
                        // reset selection to original state
1119
0
                        if (!bSel)
1120
0
                            aSel.end.nIndex--;
1121
0
                        pOutlinerView->SetSelection(aSel);
1122
1123
0
                        pField.reset();
1124
0
                    }
1125
1126
0
                    SfxItemSet aSet(pDlg->GetItemSet());
1127
0
                    if (aSet.Count())
1128
0
                    {
1129
0
                        pOutlinerView->SetAttribs(aSet);
1130
1131
0
                        ::Outliner& rOutliner = pOutlinerView->GetOutliner();
1132
0
                        rOutliner.UpdateFields();
1133
0
                    }
1134
0
                }
1135
0
            }
1136
1137
0
            Cancel();
1138
0
            rReq.Ignore();
1139
0
        }
1140
0
        break;
1141
0
    }
1142
1143
0
    if (HasCurrentFunction())
1144
0
        GetCurrentFunction()->Activate();
1145
1146
0
    Invalidate(SID_CUT);
1147
0
    Invalidate(SID_COPY);
1148
0
    Invalidate(SID_PASTE);
1149
0
    Invalidate(SID_PASTE_UNFORMATTED);
1150
0
}
1151
1152
void NotesPanelViewShell::FuSupport(SfxRequest& rReq)
1153
0
{
1154
0
    if (rReq.GetSlot() == SID_STYLE_FAMILY && rReq.GetArgs())
1155
0
        GetDocSh()->SetStyleFamily(
1156
0
            static_cast<SfxStyleFamily>(rReq.GetArgs()->Get(SID_STYLE_FAMILY).GetValue()));
1157
1158
0
    bool bPreviewState = false;
1159
0
    sal_uInt16 nSlot = rReq.GetSlot();
1160
1161
0
    switch (nSlot)
1162
0
    {
1163
0
        case SID_CUT:
1164
0
        {
1165
0
            if (HasCurrentFunction())
1166
0
            {
1167
0
                GetCurrentFunction()->DoCut();
1168
0
            }
1169
0
            else if (mpNotesPanelView)
1170
0
            {
1171
0
                mpNotesPanelView->DoCut();
1172
0
            }
1173
0
            rReq.Done();
1174
0
            bPreviewState = true;
1175
0
        }
1176
0
        break;
1177
1178
0
        case SID_COPY:
1179
0
        {
1180
0
            if (HasCurrentFunction())
1181
0
            {
1182
0
                GetCurrentFunction()->DoCopy();
1183
0
            }
1184
0
            else if (mpNotesPanelView)
1185
0
            {
1186
0
                mpNotesPanelView->DoCopy();
1187
0
            }
1188
0
            rReq.Done();
1189
0
            bPreviewState = true;
1190
0
        }
1191
0
        break;
1192
1193
0
        case SID_PASTE:
1194
0
        {
1195
0
            if (HasCurrentFunction())
1196
0
            {
1197
0
                GetCurrentFunction()->DoPaste();
1198
0
            }
1199
0
            else if (mpNotesPanelView)
1200
0
            {
1201
0
                mpNotesPanelView->DoPaste();
1202
0
            }
1203
0
            rReq.Done();
1204
0
            bPreviewState = true;
1205
0
        }
1206
0
        break;
1207
1208
0
        case SID_PASTE_UNFORMATTED:
1209
0
        {
1210
0
            if (HasCurrentFunction())
1211
0
            {
1212
0
                GetCurrentFunction()->DoPasteUnformatted();
1213
0
            }
1214
0
            else if (mpNotesPanelView)
1215
0
            {
1216
0
                TransferableDataHelper aDataHelper(
1217
0
                    TransferableDataHelper::CreateFromSystemClipboard(GetActiveWindow()));
1218
0
                if (aDataHelper.GetTransferable().is())
1219
0
                {
1220
0
                    sal_Int8 nAction = DND_ACTION_COPY;
1221
0
                    mpNotesPanelView->InsertData(
1222
0
                        aDataHelper,
1223
0
                        GetActiveWindow()->PixelToLogic(
1224
0
                            ::tools::Rectangle(Point(), GetActiveWindow()->GetOutputSizePixel())
1225
0
                                .Center()),
1226
0
                        nAction, false, SotClipboardFormatId::STRING);
1227
0
                }
1228
0
            }
1229
1230
0
            rReq.Ignore();
1231
0
        }
1232
0
        break;
1233
0
        case SID_DELETE:
1234
0
        {
1235
0
            if (mpNotesPanelView)
1236
0
            {
1237
0
                OutlinerView* pOutlView = mpNotesPanelView->GetOutlinerView();
1238
0
                if (pOutlView)
1239
0
                {
1240
0
                    vcl::KeyCode aKCode(KEY_DELETE);
1241
0
                    KeyEvent aKEvt(0, aKCode);
1242
0
                    pOutlView->PostKeyEvent(aKEvt);
1243
1244
0
                    rtl::Reference<FuPoor> xFunc(GetCurrentFunction());
1245
0
                    FuOutlineText* pFuOutlineText = dynamic_cast<FuOutlineText*>(xFunc.get());
1246
0
                    if (pFuOutlineText)
1247
0
                        pFuOutlineText->UpdateForKeyPress(aKEvt);
1248
0
                }
1249
0
            }
1250
0
            rReq.Done();
1251
0
            bPreviewState = true;
1252
0
        }
1253
0
        break;
1254
1255
0
        case SID_DRAWINGMODE:
1256
0
        case SID_SLIDE_MASTER_MODE:
1257
0
        case SID_NOTES_MODE:
1258
0
        case SID_NOTES_MASTER_MODE:
1259
0
        case SID_HANDOUT_MASTER_MODE:
1260
0
        case SID_SLIDE_SORTER_MODE:
1261
0
        case SID_OUTLINE_MODE:
1262
0
            framework::FrameworkHelper::Instance(GetViewShellBase())
1263
0
                ->HandleModeChangeSlot(nSlot, rReq);
1264
0
            rReq.Done();
1265
0
            break;
1266
1267
0
        case SID_RULER:
1268
0
            SetRuler(!HasRuler());
1269
0
            Invalidate(SID_RULER);
1270
0
            rReq.Done();
1271
0
            break;
1272
1273
0
        case SID_ZOOM_PREV:
1274
0
        {
1275
0
            if (mpZoomList->IsPreviousPossible())
1276
0
            {
1277
0
                SetZoomRect(mpZoomList->GetPreviousZoomRect());
1278
0
            }
1279
0
            rReq.Done();
1280
0
        }
1281
0
        break;
1282
1283
0
        case SID_ZOOM_NEXT:
1284
0
        {
1285
0
            if (mpZoomList->IsNextPossible())
1286
0
            {
1287
0
                SetZoomRect(mpZoomList->GetNextZoomRect());
1288
0
            }
1289
0
            rReq.Done();
1290
0
        }
1291
0
        break;
1292
1293
0
        case SID_AUTOSPELL_CHECK:
1294
0
        {
1295
0
            GetDoc()->SetOnlineSpell(!GetDoc()->GetOnlineSpell());
1296
0
            rReq.Done();
1297
0
        }
1298
0
        break;
1299
1300
0
        case SID_TRANSLITERATE_SENTENCE_CASE:
1301
0
        case SID_TRANSLITERATE_TITLE_CASE:
1302
0
        case SID_TRANSLITERATE_TOGGLE_CASE:
1303
0
        case SID_TRANSLITERATE_UPPER:
1304
0
        case SID_TRANSLITERATE_LOWER:
1305
0
        case SID_TRANSLITERATE_HALFWIDTH:
1306
0
        case SID_TRANSLITERATE_FULLWIDTH:
1307
0
        case SID_TRANSLITERATE_HIRAGANA:
1308
0
        case SID_TRANSLITERATE_KATAKANA:
1309
0
        {
1310
0
            OutlinerView* pOLV = mpNotesPanelView ? mpNotesPanelView->GetOutlinerView() : nullptr;
1311
0
            if (pOLV)
1312
0
            {
1313
0
                TransliterationFlags nType = TransliterationFlags::NONE;
1314
1315
0
                switch (nSlot)
1316
0
                {
1317
0
                    case SID_TRANSLITERATE_SENTENCE_CASE:
1318
0
                        nType = TransliterationFlags::SENTENCE_CASE;
1319
0
                        break;
1320
0
                    case SID_TRANSLITERATE_TITLE_CASE:
1321
0
                        nType = TransliterationFlags::TITLE_CASE;
1322
0
                        break;
1323
0
                    case SID_TRANSLITERATE_TOGGLE_CASE:
1324
0
                        nType = TransliterationFlags::TOGGLE_CASE;
1325
0
                        break;
1326
0
                    case SID_TRANSLITERATE_UPPER:
1327
0
                        nType = TransliterationFlags::LOWERCASE_UPPERCASE;
1328
0
                        break;
1329
0
                    case SID_TRANSLITERATE_LOWER:
1330
0
                        nType = TransliterationFlags::UPPERCASE_LOWERCASE;
1331
0
                        break;
1332
0
                    case SID_TRANSLITERATE_HALFWIDTH:
1333
0
                        nType = TransliterationFlags::FULLWIDTH_HALFWIDTH;
1334
0
                        break;
1335
0
                    case SID_TRANSLITERATE_FULLWIDTH:
1336
0
                        nType = TransliterationFlags::HALFWIDTH_FULLWIDTH;
1337
0
                        break;
1338
0
                    case SID_TRANSLITERATE_HIRAGANA:
1339
0
                        nType = TransliterationFlags::KATAKANA_HIRAGANA;
1340
0
                        break;
1341
0
                    case SID_TRANSLITERATE_KATAKANA:
1342
0
                        nType = TransliterationFlags::HIRAGANA_KATAKANA;
1343
0
                        break;
1344
0
                }
1345
1346
0
                pOLV->TransliterateText(nType);
1347
0
            }
1348
1349
0
            rReq.Done();
1350
0
            bPreviewState = true;
1351
0
        }
1352
0
        break;
1353
1354
        // added Undo/Redo handling
1355
0
        case SID_UNDO:
1356
0
        {
1357
0
            ImpSidUndo(rReq);
1358
0
        }
1359
0
        break;
1360
0
        case SID_REDO:
1361
0
        {
1362
0
            ImpSidRedo(rReq);
1363
0
        }
1364
0
        break;
1365
1366
0
        default:
1367
0
            break;
1368
0
    }
1369
1370
0
    if (bPreviewState)
1371
0
        Invalidate(SID_PREVIEW_STATE);
1372
1373
0
    Invalidate(SID_CUT);
1374
0
    Invalidate(SID_COPY);
1375
0
    Invalidate(SID_PASTE);
1376
0
}
1377
1378
void NotesPanelViewShell::Execute(SfxRequest& rReq)
1379
0
{
1380
0
    switch (rReq.GetSlot())
1381
0
    {
1382
0
        case FID_SEARCH_NOW:
1383
0
        {
1384
0
            const SfxItemSet* pReqArgs = rReq.GetArgs();
1385
1386
0
            sd::View* pView = nullptr;
1387
0
            if (auto pMainViewSh = GetViewShellBase().GetMainViewShell())
1388
0
                pView = pMainViewSh->GetView();
1389
1390
0
            if (pReqArgs)
1391
0
            {
1392
0
                if (pView)
1393
0
                {
1394
0
                    rtl::Reference<FuSearch>& xFuSearch
1395
0
                        = pView->getSearchContext().getFunctionSearch();
1396
1397
0
                    if (!xFuSearch.is())
1398
0
                    {
1399
0
                        xFuSearch = rtl::Reference<FuSearch>(FuSearch::createPtr(
1400
0
                            *this, this->GetActiveWindow(), pView, *GetDoc(), rReq));
1401
1402
0
                        pView->getSearchContext().setSearchFunction(xFuSearch);
1403
0
                    }
1404
1405
0
                    if (xFuSearch.is())
1406
0
                    {
1407
0
                        const SvxSearchItem& rSearchItem = pReqArgs->Get(SID_SEARCH_ITEM);
1408
1409
0
                        SdModule::get()->SetSearchItem(
1410
0
                            std::unique_ptr<SvxSearchItem>(rSearchItem.Clone()));
1411
0
                        xFuSearch->SearchAndReplace(&rSearchItem);
1412
0
                    }
1413
0
                }
1414
0
            }
1415
0
            rReq.Done();
1416
0
        }
1417
0
        break;
1418
1419
0
        case SID_SEARCH_ITEM:
1420
            // Forward this request to the common (old) code of the
1421
            // document shell.
1422
0
            GetDocSh()->Execute(rReq);
1423
0
            break;
1424
1425
0
        case SID_SPELL_DIALOG:
1426
0
        {
1427
0
            SfxViewFrame* pViewFrame = GetViewFrame();
1428
0
            if (rReq.GetArgs() != nullptr)
1429
0
                pViewFrame->SetChildWindow(
1430
0
                    SID_SPELL_DIALOG,
1431
0
                    static_cast<const SfxBoolItem&>(rReq.GetArgs()->Get(SID_SPELL_DIALOG))
1432
0
                        .GetValue());
1433
0
            else
1434
0
                pViewFrame->ToggleChildWindow(SID_SPELL_DIALOG);
1435
1436
0
            pViewFrame->GetBindings().Invalidate(SID_SPELL_DIALOG);
1437
0
            rReq.Done();
1438
0
        }
1439
0
        break;
1440
1441
0
        default:
1442
0
            break;
1443
0
    }
1444
0
}
1445
1446
void NotesPanelViewShell::MouseButtonUp(const MouseEvent& rMEvt, ::sd::Window* pWin)
1447
0
{
1448
    // first the base classes
1449
0
    ViewShell::MouseButtonUp(rMEvt, pWin);
1450
1451
0
    Invalidate(SID_STYLE_EDIT);
1452
0
    Invalidate(SID_STYLE_NEW);
1453
0
    Invalidate(SID_STYLE_DELETE);
1454
0
    Invalidate(SID_STYLE_HIDE);
1455
0
    Invalidate(SID_STYLE_SHOW);
1456
0
    Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1457
0
    Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1458
0
    Invalidate(SID_STYLE_WATERCAN);
1459
0
    Invalidate(SID_STYLE_FAMILY5);
1460
0
}
1461
1462
void NotesPanelViewShell::Command(const CommandEvent& rCEvt, ::sd::Window* pWin)
1463
0
{
1464
0
    if (rCEvt.GetCommand() == CommandEventId::ContextMenu)
1465
0
    {
1466
0
        GetActiveWindow()->ReleaseMouse();
1467
1468
0
        OutlinerView* pOLV = mpNotesPanelView->GetOutlinerView();
1469
0
        Point aPos(rCEvt.GetMousePosPixel());
1470
1471
0
        bool bUsedSpellPopup = false;
1472
0
        if (pOLV && pOLV->IsWrongSpelledWordAtPos(aPos))
1473
0
        {
1474
            // Popup for Online-Spelling now handled by DrawDocShell
1475
0
            Link<SpellCallbackInfo&, void> aLink
1476
0
                = LINK(GetDocSh(), DrawDocShell, OnlineSpellCallback);
1477
1478
0
            bUsedSpellPopup = pOLV->ExecuteSpellPopup(aPos, aLink);
1479
0
            pOLV->GetEditView().Invalidate();
1480
0
        }
1481
0
        if (!bUsedSpellPopup)
1482
0
        {
1483
0
            GetViewFrame()->GetDispatcher()->ExecutePopup(u"drawtext"_ustr);
1484
0
        }
1485
0
    }
1486
0
    else
1487
0
    {
1488
0
        ViewShell::Command(rCEvt, pWin);
1489
0
    }
1490
0
}
1491
1492
bool NotesPanelViewShell::KeyInput(const KeyEvent& rKEvt, ::sd::Window* pWin)
1493
0
{
1494
0
    bool bReturn = false;
1495
1496
0
    if (HasCurrentFunction())
1497
0
    {
1498
0
        bReturn = GetCurrentFunction()->KeyInput(rKEvt);
1499
0
    }
1500
0
    else
1501
0
    {
1502
0
        bReturn = ViewShell::KeyInput(rKEvt, pWin);
1503
0
    }
1504
1505
0
    Invalidate(SID_STYLE_EDIT);
1506
0
    Invalidate(SID_STYLE_NEW);
1507
0
    Invalidate(SID_STYLE_DELETE);
1508
0
    Invalidate(SID_STYLE_HIDE);
1509
0
    Invalidate(SID_STYLE_SHOW);
1510
0
    Invalidate(SID_STYLE_UPDATE_BY_EXAMPLE);
1511
0
    Invalidate(SID_STYLE_NEW_BY_EXAMPLE);
1512
0
    Invalidate(SID_STYLE_WATERCAN);
1513
0
    Invalidate(SID_STYLE_FAMILY5);
1514
1515
0
    return bReturn;
1516
0
}
1517
1518
// FuNotesPane
1519
rtl::Reference<FuPoor> FuNotesPane::Create(ViewShell& rViewSh, ::sd::Window* pWin,
1520
                                           ::sd::SimpleOutlinerView* pView, SdDrawDocument& rDoc,
1521
                                           SfxRequest& rReq)
1522
0
{
1523
0
    rtl::Reference<FuPoor> xFunc(new FuNotesPane(rViewSh, pWin, pView, rDoc, rReq));
1524
0
    xFunc->DoExecute(rReq);
1525
0
    return xFunc;
1526
0
}
1527
1528
bool FuNotesPane::KeyInput(const KeyEvent& rKEvt)
1529
0
{
1530
0
    sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
1531
0
    switch (nCode)
1532
0
    {
1533
0
        case KEY_PAGEUP:
1534
0
        case KEY_PAGEDOWN:
1535
0
        {
1536
            // do not consume the input and let Accelerators handle Ctrl+PgUp/PgDown
1537
0
            if (rKEvt.GetKeyCode().IsMod1())
1538
0
                return false;
1539
0
            break;
1540
0
        }
1541
0
        default:
1542
0
            break;
1543
0
    }
1544
0
    return FuSimpleOutlinerText::KeyInput(rKEvt);
1545
0
}
1546
1547
FuNotesPane::FuNotesPane(ViewShell& rViewShell, ::sd::Window* pWin, ::sd::SimpleOutlinerView* pView,
1548
                         SdDrawDocument& rDoc, SfxRequest& rReq)
1549
0
    : sd::FuSimpleOutlinerText(rViewShell, pWin, pView, rDoc, rReq)
1550
0
{
1551
0
}
1552
1553
} // end of namespace sd
1554
1555
/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */