Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/view/drawview.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 <vcl/svapp.hxx>
21
#include <vcl/weld/MessageDialog.hxx>
22
#include <vcl/weld/weld.hxx>
23
#include <svl/style.hxx>
24
#include <editeng/outliner.hxx>
25
#include <svx/svdotext.hxx>
26
#include <svl/poolitem.hxx>
27
#include <editeng/eeitem.hxx>
28
#include <svl/whiter.hxx>
29
#include <sal/log.hxx>
30
#include <tools/debug.hxx>
31
#include <officecfg/Office/Draw.hxx>
32
33
#include <svx/svdundo.hxx>
34
#include <svx/strings.hrc>
35
#include <svx/dialmgr.hxx>
36
37
#include <strings.hrc>
38
#include <View.hxx>
39
#include <drawview.hxx>
40
#include <drawdoc.hxx>
41
#include <DrawDocShell.hxx>
42
#include <sdpage.hxx>
43
#include <ViewShellBase.hxx>
44
#include <DrawViewShell.hxx>
45
#include <pres.hxx>
46
#include <sdresid.hxx>
47
#include <unchss.hxx>
48
#include <slideshow.hxx>
49
50
#include <undo/undomanager.hxx>
51
52
using namespace ::com::sun::star;
53
54
namespace sd {
55
56
57
/**
58
 * Shows the first page of document at position 0,0. In the case
59
 * that there is no page a page is created.
60
 */
61
62
DrawView::DrawView(
63
    DrawDocShell* pDocSh,
64
    OutputDevice* pOutDev,
65
    DrawViewShell* pShell)
66
0
:   ::sd::View(*pDocSh->GetDoc(), pOutDev, pShell)
67
0
    ,mpDrawViewShell(pShell)
68
0
    ,mnPOCHSmph(0)
69
0
{
70
0
    SetCurrentObj(SdrObjKind::Rectangle);
71
0
}
72
73
DrawView::~DrawView()
74
0
{
75
0
}
76
77
/**
78
 * Virtual method from SdrView, called at selection change.
79
 */
80
81
void DrawView::MarkListHasChanged()
82
0
{
83
0
    ::sd::View::MarkListHasChanged();
84
85
0
    if (mpDrawViewShell)
86
0
        mpDrawViewShell->SelectionHasChanged();
87
0
}
88
89
/**
90
 * Virtual method from SdrView, called at model change.
91
 */
92
93
void DrawView::ModelHasChanged()
94
0
{
95
0
    ::sd::View::ModelHasChanged();
96
97
    // force framer to rerender
98
0
    SfxStyleSheetBasePool* pSSPool = mrDoc.GetStyleSheetPool();
99
0
    pSSPool->Broadcast(SfxStyleSheetPoolHint());
100
101
0
    if( mpDrawViewShell )
102
0
        mpDrawViewShell->ModelHasChanged();
103
104
0
}
105
106
/**
107
 * Redirect attributes onto title and outline text and background
108
 * rectangle of a masterpage into templates, otherwise pass on baseclass.
109
 */
110
111
bool DrawView::SetAttributes(const SfxItemSet& rSet,
112
                             bool bReplaceAll, bool bSlide, bool bMaster)
113
0
{
114
0
    bool bOk = false;
115
116
0
    if (mpDrawViewShell && bMaster)
117
0
    {
118
0
        SfxStyleSheetBasePool* pStShPool = mrDoc.GetStyleSheetPool();
119
0
        SdPage& rPage = *mpDrawViewShell->getCurrentPage();
120
0
        SdrPage& rMasterPage = rPage.TRG_GetMasterPage();
121
0
        for (const rtl::Reference<SdrObject>& pObject : rMasterPage)
122
0
            SetMasterAttributes(pObject.get(), rPage, rSet, pStShPool, bOk, bMaster, bSlide);
123
0
        return bOk;
124
0
    }
125
0
    if (mpDrawViewShell && bSlide)
126
0
    {
127
0
        SfxStyleSheetBasePool* pStShPool = mrDoc.GetStyleSheetPool();
128
0
        SdPage& rPage = *mpDrawViewShell->getCurrentPage();
129
0
        for (const rtl::Reference<SdrObject>& pObject : rPage)
130
0
            SetMasterAttributes(pObject.get(), rPage, rSet, pStShPool, bOk, bMaster, bSlide);
131
0
        return bOk;
132
0
    }
133
134
    // is there a masterpage edit?
135
0
    if ( mpDrawViewShell && (mpDrawViewShell->GetEditMode() == EditMode::MasterPage) )
136
0
    {
137
0
        SfxStyleSheetBasePool* pStShPool = mrDoc.GetStyleSheetPool();
138
0
        SdPage& rPage = *mpDrawViewShell->getCurrentPage();
139
0
        SdrTextObj* pEditObject = GetTextEditObject();
140
141
0
        if (pEditObject)
142
0
        {
143
            // Textedit
144
145
0
            SdrInventor nInv = pEditObject->GetObjInventor();
146
147
0
            if (nInv == SdrInventor::Default)
148
0
            {
149
0
                SdrObjKind eObjKind = pEditObject->GetObjIdentifier();
150
0
                PresObjKind ePresObjKind = rPage.GetPresObjKind(pEditObject);
151
152
0
                if ( ePresObjKind == PresObjKind::Title ||
153
0
                     ePresObjKind == PresObjKind::Notes )
154
0
                {
155
                    // Presentation object (except outline)
156
0
                    SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
157
0
                    DBG_ASSERT(pSheet, "StyleSheet not found");
158
159
0
                    SfxItemSet aTempSet( pSheet->GetItemSet() );
160
0
                    aTempSet.Put( rSet );
161
0
                    aTempSet.ClearInvalidItems();
162
163
                    // Undo-Action
164
0
                    mpDocSh->GetUndoManager()->AddUndoAction(
165
0
                        std::make_unique<StyleSheetUndoAction>(mrDoc, *pSheet, &aTempSet));
166
167
0
                    pSheet->GetItemSet().Put(aTempSet);
168
0
                    pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
169
0
                    bOk = true;
170
0
                }
171
0
                else if (eObjKind == SdrObjKind::OutlineText)
172
0
                {
173
                    // Presentation object outline
174
0
                    OutlinerView* pOV   = GetTextEditOutlinerView();
175
0
                    ::Outliner& rOutliner = pOV->GetOutliner();
176
177
0
                    rOutliner.SetUpdateLayout(false);
178
0
                    mpDocSh->SetWaitCursor( true );
179
180
                    // replace placeholder by template name
181
0
                    OUString aComment(SdResId(STR_UNDO_CHANGE_PRES_OBJECT));
182
0
                    aComment = aComment.replaceFirst("$", SdResId(STR_PSEUDOSHEET_OUTLINE));
183
0
                    mpDocSh->GetUndoManager()->EnterListAction( aComment, OUString(), 0, mpDrawViewShell->GetViewShellBase().GetViewShellId() );
184
185
0
                    std::vector<Paragraph*> aSelList;
186
0
                    pOV->CreateSelectionList(aSelList);
187
188
0
                    std::vector<Paragraph*>::reverse_iterator iter = aSelList.rbegin();
189
0
                    Paragraph* pPara = iter != aSelList.rend() ? *iter : nullptr;
190
191
0
                    while (pPara)
192
0
                    {
193
0
                        sal_Int32 nParaPos = rOutliner.GetAbsPos( pPara );
194
0
                        sal_Int16 nDepth = rOutliner.GetDepth( nParaPos );
195
0
                        OUString aName = rPage.GetLayoutName() + " " +
196
0
                            OUString::number((nDepth <= 0) ? 1 : nDepth + 1);
197
0
                        SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pStShPool->Find(aName, SfxStyleFamily::Page));
198
                        //We have no stylesheet if we access outline level 10
199
                        //in the master preview, there is no true style backing
200
                        //that entry
201
0
                        SAL_WARN_IF(!pSheet, "sd", "StyleSheet " << aName << " not found");
202
0
                        if (pSheet)
203
0
                        {
204
0
                            SfxItemSet aTempSet( pSheet->GetItemSet() );
205
0
                            aTempSet.Put( rSet );
206
0
                            aTempSet.ClearInvalidItems();
207
208
0
                            if( nDepth > 0 && aTempSet.GetItemState( EE_PARA_NUMBULLET ) == SfxItemState::SET )
209
0
                            {
210
                                // no SvxNumBulletItem in outline level 1 to 8!
211
0
                                aTempSet.ClearItem( EE_PARA_NUMBULLET );
212
0
                            }
213
214
                            // Undo-Action
215
0
                            mpDocSh->GetUndoManager()->AddUndoAction(
216
0
                                std::make_unique<StyleSheetUndoAction>(mrDoc, *pSheet, &aTempSet));
217
218
0
                            pSheet->GetItemSet().Put(aTempSet);
219
0
                            pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
220
221
                            // now also broadcast any child sheets
222
0
                            sal_Int16 nChild;
223
0
                            for( nChild = nDepth + 1; nChild < 9; nChild++ )
224
0
                            {
225
0
                                OUString aSheetName = rPage.GetLayoutName() + " " +
226
0
                                    OUString::number((nChild <= 0) ? 1 : nChild + 1);
227
0
                                SfxStyleSheet* pOutlSheet = static_cast< SfxStyleSheet* >(pStShPool->Find(aSheetName, SfxStyleFamily::Page));
228
229
0
                                if( pOutlSheet )
230
0
                                    pOutlSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
231
0
                            }
232
0
                        }
233
234
0
                        ++iter;
235
0
                        pPara = iter != aSelList.rend() ? *iter : nullptr;
236
237
0
                        bool bJumpToLevel1 = false;
238
0
                        if( !pPara && nDepth > 0 && rSet.GetItemState( EE_PARA_NUMBULLET ) == SfxItemState::SET )
239
0
                            bJumpToLevel1 = true;
240
241
0
                        if (bJumpToLevel1)
242
0
                        {
243
0
                            iter = aSelList.rend();
244
0
                            --iter;
245
246
0
                            if (rOutliner.GetDepth(rOutliner.GetAbsPos(*iter)) > 0)
247
0
                                pPara = rOutliner.GetParagraph( 0 );  // Put NumBulletItem in outline level 1
248
0
                        }
249
0
                    }
250
251
0
                    mpDocSh->SetWaitCursor( false );
252
0
                    pOV->GetOutliner().SetUpdateLayout(true);
253
254
0
                    mpDocSh->GetUndoManager()->LeaveListAction();
255
256
0
                    bOk = true;
257
0
                }
258
0
                else
259
0
                {
260
0
                    bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
261
0
                }
262
0
            }
263
0
        }
264
0
        else
265
0
        {
266
            // Selection
267
0
            const SdrMarkList& rList = GetMarkedObjectList();
268
0
            const size_t nMarkCount = rList.GetMarkCount();
269
0
            for (size_t nMark = 0; nMark < nMarkCount; ++nMark)
270
0
            {
271
0
                SdrObject*  pObject = rList.GetMark(nMark)->GetMarkedSdrObj();
272
0
                SetMasterAttributes(pObject, rPage, rSet, pStShPool, bOk, bMaster, bSlide);
273
0
            }
274
275
0
            if(!bOk)
276
0
                bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
277
0
        }
278
0
    }
279
0
    else    // not at masterpage
280
0
    {
281
0
        bOk = ::sd::View::SetAttributes(rSet, bReplaceAll);
282
0
    }
283
284
0
    return bOk;
285
0
}
286
287
void DrawView::SetMasterAttributes( SdrObject* pObject, const SdPage& rPage, const SfxItemSet& rSet, SfxStyleSheetBasePool* pStShPool, bool& bOk, bool bMaster, bool bSlide )
288
0
{
289
0
    SdrInventor nInv    = pObject->GetObjInventor();
290
291
0
    if (nInv != SdrInventor::Default)
292
0
        return;
293
294
0
    SdrObjKind eObjKind = pObject->GetObjIdentifier();
295
0
    PresObjKind ePresObjKind = rPage.GetPresObjKind(pObject);
296
0
    if (bSlide && eObjKind == SdrObjKind::Text)
297
0
    {
298
        // Presentation object (except outline)
299
0
        SfxStyleSheet* pSheet = rPage.GetTextStyleSheetForObject(pObject);
300
0
        assert(pSheet && "StyleSheet not found");
301
302
0
        SfxItemSet aTempSet( pSheet->GetItemSet() );
303
0
        aTempSet.Put( rSet );
304
0
        aTempSet.ClearInvalidItems();
305
306
        // Undo-Action
307
0
        mpDocSh->GetUndoManager()->AddUndoAction(
308
0
            std::make_unique<StyleSheetUndoAction>(mrDoc, *pSheet, &aTempSet));
309
310
0
        pSheet->GetItemSet().Put(aTempSet,false);
311
0
        pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
312
0
        bOk = true;
313
0
    }
314
315
0
    if (!bSlide &&
316
0
        (ePresObjKind == PresObjKind::Title ||
317
0
         ePresObjKind == PresObjKind::Notes))
318
0
    {
319
        // Presentation object (except outline)
320
0
        SfxStyleSheet* pSheet = rPage.GetStyleSheetForPresObj( ePresObjKind );
321
0
        assert(pSheet && "StyleSheet not found");
322
323
0
        SfxItemSet aTempSet( pSheet->GetItemSet() );
324
0
        aTempSet.Put( rSet );
325
0
        aTempSet.ClearInvalidItems();
326
327
        // Undo-Action
328
0
        mpDocSh->GetUndoManager()->AddUndoAction(
329
0
            std::make_unique<StyleSheetUndoAction>(mrDoc, *pSheet, &aTempSet));
330
331
0
        pSheet->GetItemSet().Put(aTempSet,false);
332
0
        pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
333
0
        bOk = true;
334
0
    }
335
0
    else if (eObjKind == SdrObjKind::OutlineText)
336
0
    {
337
        // tdf#127900: do not forget to apply master style to placeholders
338
0
        if (!rSet.HasItem(EE_PARA_NUMBULLET) || bMaster)
339
0
        {
340
            // Presentation object outline
341
0
            for (sal_uInt16 nLevel = 9; nLevel > 0; nLevel--)
342
0
            {
343
0
                OUString aName = rPage.GetLayoutName() + " " +
344
0
                    OUString::number(nLevel);
345
0
                SfxStyleSheet* pSheet = static_cast<SfxStyleSheet*>(pStShPool->
346
0
                                    Find(aName, SfxStyleFamily::Page));
347
0
                assert(pSheet && "StyleSheet not found");
348
349
0
                SfxItemSet aTempSet( pSheet->GetItemSet() );
350
351
0
                if( nLevel > 1 )
352
0
                {
353
                    // for all levels over 1, clear all items that will be
354
                    // hard set to level 1
355
0
                    SfxWhichIter aWhichIter(rSet);
356
0
                    sal_uInt16 nWhich(aWhichIter.FirstWhich());
357
0
                    while( nWhich )
358
0
                    {
359
0
                        if( SfxItemState::SET == aWhichIter.GetItemState() )
360
0
                            aTempSet.ClearItem( nWhich );
361
0
                        nWhich = aWhichIter.NextWhich();
362
0
                    }
363
364
0
                }
365
0
                else
366
0
                {
367
                    // put the items hard into level one
368
0
                    aTempSet.Put( rSet );
369
0
                }
370
371
0
                aTempSet.ClearInvalidItems();
372
373
                // Undo-Action
374
0
                mpDocSh->GetUndoManager()->AddUndoAction(
375
0
                    std::make_unique<StyleSheetUndoAction>(mrDoc, *pSheet, &aTempSet));
376
377
0
                pSheet->GetItemSet().Set(aTempSet,false);
378
0
                pSheet->Broadcast(SfxHint(SfxHintId::DataChanged));
379
0
            }
380
381
            // remove all hard set items from shape that are now set in style
382
0
            SfxWhichIter aWhichIter(rSet);
383
0
            sal_uInt16 nWhich(aWhichIter.FirstWhich());
384
0
            while( nWhich )
385
0
            {
386
0
                if( SfxItemState::SET == aWhichIter.GetItemState() )
387
0
                    pObject->ClearMergedItem( nWhich );
388
0
                nWhich = aWhichIter.NextWhich();
389
0
            }
390
0
        }
391
0
        else
392
0
            pObject->SetMergedItemSet(rSet);
393
394
0
        bOk = true;
395
0
    }
396
0
}
397
398
/**
399
 * Notify for change of site arrangement
400
 */
401
402
void DrawView::Notify(SfxBroadcaster& rBC, const SfxHint& rHint)
403
0
{
404
0
    if ( mpDrawViewShell && rHint.GetId() == SfxHintId::ThisIsAnSdrHint )
405
0
    {
406
0
        SdrHintKind eHintKind = static_cast<const SdrHint&>(rHint).GetKind();
407
408
0
        if ( mnPOCHSmph == 0 && eHintKind == SdrHintKind::PageOrderChange )
409
0
        {
410
0
            mpDrawViewShell->ResetActualPage();
411
0
            mpDrawViewShell->UpdateScrollBars();
412
0
        }
413
0
        else if ( eHintKind == SdrHintKind::LayerChange || eHintKind == SdrHintKind::LayerOrderChange )
414
0
        {
415
0
            mpDrawViewShell->ResetActualLayer();
416
0
        }
417
418
        // switch to that page when it's not a master page
419
0
        if(SdrHintKind::SwitchToPage == eHintKind)
420
0
        {
421
            // We switch page only in the current view, which triggered this event
422
            // and keep other views untouched.
423
0
            SfxViewShell* pViewShell = SfxViewShell::Current();
424
0
            if(pViewShell && pViewShell != &mpDrawViewShell->GetViewShellBase())
425
0
                return;
426
427
0
            const SdrPage* pPage = static_cast<const SdrHint&>(rHint).GetPage();
428
0
            if(pPage && !pPage->IsMasterPage())
429
0
            {
430
0
                if(mpDrawViewShell->GetActualPage() != pPage)
431
0
                {
432
0
                    sal_uInt16 nPageNum = (pPage->GetPageNum() - 1) / 2; // Sdr --> Sd
433
0
                    mpDrawViewShell->SwitchPage(nPageNum);
434
0
                }
435
0
            }
436
0
        }
437
0
    }
438
439
0
    ::sd::View::Notify(rBC, rHint);
440
0
}
441
442
/**
443
 * Lock/Unlock PageOrderChangedHint
444
 */
445
446
void DrawView::BlockPageOrderChangedHint(bool bBlock)
447
0
{
448
0
    if (bBlock)
449
0
        mnPOCHSmph++;
450
0
    else
451
0
    {
452
0
        DBG_ASSERT(mnPOCHSmph, "counter overflow");
453
0
        mnPOCHSmph--;
454
0
    }
455
0
}
456
457
/**
458
 * If presentation objects are selected, intercept stylesheet-positioning at
459
 * masterpage.
460
 */
461
462
bool DrawView::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr)
463
0
{
464
0
    bool bResult = true;
465
466
    // is there a masterpage edit?
467
0
    if (mpDrawViewShell && mpDrawViewShell->GetEditMode() == EditMode::MasterPage)
468
0
    {
469
0
        if (IsPresObjSelected(false))
470
0
        {
471
0
            std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(mpDrawViewShell->GetFrameWeld(),
472
0
                                                          VclMessageType::Info, VclButtonsType::Ok,
473
0
                                                          SdResId(STR_ACTION_NOTPOSSIBLE)));
474
0
            xInfoBox->run();
475
0
            bResult = false;
476
0
        }
477
0
        else
478
0
        {
479
0
            bResult = ::sd::View::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
480
0
        }
481
0
    }
482
0
    else
483
0
    {
484
0
        bResult = ::sd::View::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
485
0
    }
486
0
    return bResult;
487
0
}
488
489
/**
490
 * Paint-method: Redirect event to the view
491
 */
492
493
void DrawView::CompleteRedraw(OutputDevice* pOutDev, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0*/)
494
0
{
495
0
    SdDrawDocument* pDoc = GetDocSh()->GetDoc();
496
0
    if( pDoc && pDoc->GetDocumentType() == DocumentType::Impress)
497
0
    {
498
0
        rtl::Reference< sd::SlideShow > xSlideshow( SlideShow::GetSlideShow( pDoc ) );
499
0
        if(xSlideshow.is() && xSlideshow->isRunning())
500
0
        {
501
0
            OutputDevice* pShowWindow = xSlideshow->getShowWindow();
502
0
            if( (pShowWindow == pOutDev) || (xSlideshow->getAnimationMode() == ANIMATIONMODE_PREVIEW) )
503
0
            {
504
0
                if( pShowWindow == pOutDev && mpViewSh )
505
0
                    xSlideshow->paint();
506
0
                if (!xSlideshow->IsInteractiveSlideshow()) // IASS
507
0
                    return;
508
0
            }
509
0
        }
510
0
    }
511
0
    else if( pDoc && pDoc->GetDocumentType() == DocumentType::Draw)
512
0
    {
513
        // tdf#164605 & tdf#89420
514
0
        bool bShowMargin(officecfg::Office::Draw::Misc::TextObject::ShowBoundary::get());
515
0
        pDoc->SetShowMargin(bShowMargin);
516
0
    }
517
518
0
    ::sd::View::CompleteRedraw(pOutDev, rReg, pRedirector);
519
0
}
520
521
/**
522
 * Make passed region visible (scrolling if necessary)
523
 */
524
525
void DrawView::MakeVisible(const ::tools::Rectangle& rRect, vcl::Window& rWin)
526
0
{
527
0
    if (!rRect.IsEmpty() && mpDrawViewShell)
528
0
    {
529
0
        mpDrawViewShell->MakeVisible(rRect, rWin);
530
0
    }
531
0
}
532
533
/**
534
 * Hide page.
535
 */
536
537
void DrawView::HideSdrPage()
538
0
{
539
0
    if (mpDrawViewShell)
540
0
    {
541
0
        mpDrawViewShell->HidePage();
542
0
    }
543
544
0
    ::sd::View::HideSdrPage();
545
0
}
546
547
void DrawView::DeleteMarked()
548
0
{
549
0
    sd::UndoManager* pUndoManager = mrDoc.GetUndoManager();
550
0
    DBG_ASSERT( pUndoManager, "sd::DrawView::DeleteMarked(), ui action without undo manager!?" );
551
552
0
    const SdrMarkList& rMarkList = GetMarkedObjectList();
553
0
    if( pUndoManager )
554
0
    {
555
0
        OUString aUndo(SvxResId(STR_EditDelete));
556
0
        aUndo = aUndo.replaceFirst("%1", rMarkList.GetMarkDescription());
557
0
        ViewShellId nViewShellId = mpDrawViewShell ? mpDrawViewShell->GetViewShellBase().GetViewShellId() : ViewShellId(-1);
558
0
        pUndoManager->EnterListAction(aUndo, aUndo, 0, nViewShellId);
559
0
    }
560
561
0
    SdPage* pPage = nullptr;
562
0
    bool bResetLayout = false;
563
564
0
    const size_t nMarkCount = rMarkList.GetMarkCount();
565
0
    if( nMarkCount )
566
0
    {
567
0
        SdrMarkList aList( GetMarkedObjectList() );
568
0
        for (size_t nMark = 0; nMark < nMarkCount; ++nMark)
569
0
        {
570
0
            SdrObject* pObj = aList.GetMark(nMark)->GetMarkedSdrObj();
571
0
            if( pObj && !pObj->IsEmptyPresObj() && pObj->GetUserCall() )
572
0
            {
573
0
                pPage = static_cast< SdPage* >( pObj->getSdrPageFromSdrObject() );
574
0
                if (pPage)
575
0
                {
576
0
                    PresObjKind ePresObjKind(pPage->GetPresObjKind(pObj));
577
0
                    switch( ePresObjKind )
578
0
                    {
579
0
                    case PresObjKind::NONE:
580
0
                        continue; // ignore it
581
0
                    case PresObjKind::Graphic:
582
0
                    case PresObjKind::Object:
583
0
                    case PresObjKind::Chart:
584
0
                    case PresObjKind::OrgChart:
585
0
                    case PresObjKind::Table:
586
0
                    case PresObjKind::Calc:
587
0
                    case PresObjKind::Media:
588
0
                        ePresObjKind = PresObjKind::Outline;
589
0
                        break;
590
0
                    default:
591
0
                        break;
592
0
                    }
593
0
                    SdrTextObj* pTextObj = DynCastSdrTextObj( pObj );
594
0
                    bool bVertical = pTextObj && pTextObj->IsVerticalWriting();
595
0
                    ::tools::Rectangle aRect( pObj->GetLogicRect() );
596
0
                    SdrObject* pNewObj = pPage->InsertAutoLayoutShape(nullptr, ePresObjKind, bVertical, aRect, OUString(), true);
597
598
                    // pUndoManager should not be NULL (see assert above)
599
                    // but since we have defensive code
600
                    // for it earlier and later in the function
601
                    // we might as well be consistent
602
0
                    if(pUndoManager)
603
0
                    {
604
                        // Move the new PresObj to the position before the
605
                        // object it will replace.
606
0
                        pUndoManager->AddUndoAction(
607
0
                            mrDoc.GetSdrUndoFactory().CreateUndoObjectOrdNum(
608
0
                                *pNewObj,
609
0
                                pNewObj->GetOrdNum(),
610
0
                                pObj->GetOrdNum()));
611
0
                    }
612
0
                    pPage->SetObjectOrdNum( pNewObj->GetOrdNum(), pObj->GetOrdNum() );
613
614
0
                    bResetLayout = true;
615
0
                }
616
0
            }
617
0
        }
618
0
    }
619
620
0
    ::sd::View::DeleteMarked();
621
622
0
    if( pPage && bResetLayout )
623
0
        pPage->SetAutoLayout( pPage->GetAutoLayout() );
624
625
0
    if( pUndoManager )
626
0
        pUndoManager->LeaveListAction();
627
0
}
628
629
} // end of namespace sd
630
631
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */