Bump version to 21.06.18.1
[LibreOffice.git] / sd / source / ui / view / sdview.cxx
blob7f30d85f2c77d8af84ecaf1fe03859b5b25becc7
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
21 #include <com/sun/star/embed/XEmbeddedObject.hpp>
22 #include <com/sun/star/linguistic2/XSpellChecker1.hpp>
24 #include <View.hxx>
25 #include <editeng/outlobj.hxx>
26 #include <editeng/unolingu.hxx>
27 #include <svx/obj3d.hxx>
28 #include <svx/fmview.hxx>
29 #include <editeng/outliner.hxx>
30 #include <svx/svdograf.hxx>
31 #include <svx/svdoole2.hxx>
32 #include <svx/svdundo.hxx>
34 #include <vcl/settings.hxx>
36 #include <sfx2/dispatch.hxx>
37 #include <svx/svdpagv.hxx>
38 #include <svx/svdoutl.hxx>
39 #include <svx/sdr/contact/displayinfo.hxx>
41 #include <svx/svdetc.hxx>
42 #include <editeng/editstat.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <toolkit/helper/vclunohelper.hxx>
46 #include <svx/xfillit0.hxx>
48 #include <app.hrc>
49 #include <strings.hrc>
50 #include <Window.hxx>
51 #include <Client.hxx>
52 #include <drawdoc.hxx>
53 #include <DrawDocShell.hxx>
54 #include <sdmod.hxx>
55 #include <sdpage.hxx>
56 #include <sdresid.hxx>
57 #include <unokywds.hxx>
58 #include <ViewClipboard.hxx>
59 #include <undo/undomanager.hxx>
60 #include <svx/sdr/contact/viewobjectcontact.hxx>
61 #include <svx/sdr/contact/viewcontact.hxx>
62 #include <svx/svdotable.hxx>
63 #include <EventMultiplexer.hxx>
64 #include <ViewShellBase.hxx>
65 #include <ViewShell.hxx>
67 #include <basegfx/polygon/b2dpolygontools.hxx>
68 #include <basegfx/color/bcolor.hxx>
69 #include <drawinglayer/primitive2d/polygonprimitive2d.hxx>
70 #include <drawinglayer/primitive2d/textlayoutdevice.hxx>
71 #include <svx/sdr/contact/objectcontact.hxx>
72 #include <svx/sdr/table/tablecontroller.hxx>
73 #include <basegfx/matrix/b2dhommatrix.hxx>
74 #include <drawinglayer/primitive2d/textprimitive2d.hxx>
75 #include <svx/unoapi.hxx>
76 #include <basegfx/matrix/b2dhommatrixtools.hxx>
77 #include <comphelper/lok.hxx>
78 #include <sfx2/lokhelper.hxx>
79 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
80 #include <DrawController.hxx>
82 #include <undo/undomanager.hxx>
84 #include <memory>
85 #include <numeric>
87 using namespace com::sun::star;
88 using namespace com::sun::star::uno;
89 using namespace sdr::table;
90 namespace sd {
92 View::View(
93 SdDrawDocument& rDrawDoc,
94 OutputDevice* pOutDev,
95 ViewShell* pViewShell)
96 : FmFormView(rDrawDoc, pOutDev),
97 mrDoc(rDrawDoc),
98 mpDocSh(rDrawDoc.GetDocSh()),
99 mpViewSh(pViewShell),
100 mpDropMarkerObj(nullptr),
101 mnDragSrcPgNum(SDRPAGE_NOTFOUND),
102 mnAction(DND_ACTION_NONE),
103 maDropErrorIdle("sd View DropError"),
104 maDropInsertFileIdle("sd View DropInsertFile"),
105 mnLockRedrawSmph(0),
106 mbIsDropAllowed(true),
107 maSmartTags(*this),
108 mpClipboard (new ViewClipboard (*this))
110 // #i73602# Use default from the configuration
111 SetBufferedOverlayAllowed(getOptionsDrawinglayer().IsOverlayBuffer_DrawImpress());
113 // #i74769#, #i75172# Use default from the configuration
114 SetBufferedOutputAllowed(getOptionsDrawinglayer().IsPaintBuffer_DrawImpress());
116 EnableExtendedKeyInputDispatcher(false);
117 EnableExtendedMouseEventDispatcher(false);
119 SetUseIncompatiblePathCreateInterface(false);
121 SetMinMoveDistancePixel(2);
122 SetHitTolerancePixel(2);
123 SetMeasureLayer(sUNO_LayerName_measurelines);
125 // Timer for delayed drop (has to be for MAC)
126 maDropErrorIdle.SetInvokeHandler( LINK(this, View, DropErrorHdl) );
127 maDropInsertFileIdle.SetInvokeHandler( LINK(this, View, DropInsertFileHdl) );
130 void View::ImplClearDrawDropMarker()
132 mpDropMarker.reset();
135 View::~View()
137 maSmartTags.Dispose();
139 // release content of selection clipboard, if we own the content
140 UpdateSelectionClipboard( true );
142 maDropErrorIdle.Stop();
143 maDropInsertFileIdle.Stop();
145 ImplClearDrawDropMarker();
147 while(PaintWindowCount())
149 // remove all registered OutDevs
150 DeleteWindowFromPaintView(GetFirstOutputDevice() /*GetWin(0)*/);
154 namespace {
156 class ViewRedirector : public sdr::contact::ViewObjectContactRedirector
158 public:
159 ViewRedirector();
161 // all default implementations just call the same methods at the original. To do something
162 // different, override the method and at least do what the method does.
163 virtual drawinglayer::primitive2d::Primitive2DContainer createRedirectedPrimitive2DSequence(
164 const sdr::contact::ViewObjectContact& rOriginal,
165 const sdr::contact::DisplayInfo& rDisplayInfo) override;
170 ViewRedirector::ViewRedirector()
174 drawinglayer::primitive2d::Primitive2DContainer ViewRedirector::createRedirectedPrimitive2DSequence(
175 const sdr::contact::ViewObjectContact& rOriginal,
176 const sdr::contact::DisplayInfo& rDisplayInfo)
178 SdrObject* pObject = rOriginal.GetViewContact().TryToGetSdrObject();
179 drawinglayer::primitive2d::Primitive2DContainer xRetval;
181 if(pObject && pObject->getSdrPageFromSdrObject())
183 const bool bDoCreateGeometry(pObject->getSdrPageFromSdrObject()->checkVisibility( rOriginal, rDisplayInfo, true ));
185 if(!bDoCreateGeometry &&
186 (( pObject->GetObjInventor() != SdrInventor::Default ) || ( pObject->GetObjIdentifier() != OBJ_PAGE )) )
187 return xRetval;
189 PresObjKind eKind(PresObjKind::NONE);
190 const bool bSubContentProcessing(rDisplayInfo.GetSubContentActive());
191 const bool bIsMasterPageObject(pObject->getSdrPageFromSdrObject()->IsMasterPage());
192 const bool bIsPrinting(rOriginal.GetObjectContact().isOutputToPrinter());
193 const SdrPageView* pPageView = rOriginal.GetObjectContact().TryToGetSdrPageView();
194 const SdrPage* pVisualizedPage = GetSdrPageFromXDrawPage(rOriginal.GetObjectContact().getViewInformation2D().getVisualizedPage());
195 const SdPage* pObjectsSdPage = dynamic_cast< SdPage* >(pObject->getSdrPageFromSdrObject());
196 const bool bIsInsidePageObj(pPageView && pPageView->GetPage() != pVisualizedPage);
198 // check if we need to draw a placeholder border. Never do it for
199 // objects inside a SdrPageObj and never when printing
200 if(!bIsInsidePageObj && !bIsPrinting)
202 bool bCreateOutline(false);
204 if( pObject->IsEmptyPresObj() && dynamic_cast< SdrTextObj *>( pObject ) != nullptr )
206 if( !bSubContentProcessing || !pObject->IsNotVisibleAsMaster() )
208 eKind = pObjectsSdPage ? pObjectsSdPage->GetPresObjKind(pObject) : PresObjKind::NONE;
209 bCreateOutline = true;
212 else if( ( pObject->GetObjInventor() == SdrInventor::Default ) && ( pObject->GetObjIdentifier() == OBJ_TEXT ) )
214 if( pObjectsSdPage )
216 eKind = pObjectsSdPage->GetPresObjKind(pObject);
218 if((eKind == PresObjKind::Footer) || (eKind == PresObjKind::Header) || (eKind == PresObjKind::DateTime) || (eKind == PresObjKind::SlideNumber) )
220 if( !bSubContentProcessing )
222 // only draw a boundary for header&footer objects on the masterpage itself
223 bCreateOutline = true;
228 else if( ( pObject->GetObjInventor() == SdrInventor::Default ) && ( pObject->GetObjIdentifier() == OBJ_PAGE ) )
230 // only for handout page, else this frame will be created for each
231 // page preview object in SlideSorter and PagePane
232 if(pObjectsSdPage && PageKind::Handout == pObjectsSdPage->GetPageKind())
234 bCreateOutline = true;
238 if(bCreateOutline)
240 // empty presentation objects get a gray frame
241 const svtools::ColorConfig aColorConfig;
242 const svtools::ColorConfigValue aColor( aColorConfig.GetColorValue( svtools::OBJECTBOUNDARIES ) );
244 if( aColor.bIsVisible )
246 // get basic object transformation
247 const basegfx::BColor aRGBColor(aColor.nColor.getBColor());
248 basegfx::B2DHomMatrix aObjectMatrix;
249 basegfx::B2DPolyPolygon aObjectPolyPolygon;
250 pObject->TRGetBaseGeometry(aObjectMatrix, aObjectPolyPolygon);
252 // create dashed border
254 // create object polygon
255 basegfx::B2DPolygon aPolygon(basegfx::utils::createUnitPolygon());
256 aPolygon.transform(aObjectMatrix);
258 // create line and stroke attribute
259 ::std::vector< double > aDotDashArray;
261 aDotDashArray.push_back(160.0);
262 aDotDashArray.push_back(80.0);
264 const double fFullDotDashLen(::std::accumulate(aDotDashArray.begin(), aDotDashArray.end(), 0.0));
265 const drawinglayer::attribute::LineAttribute aLine(aRGBColor);
266 const drawinglayer::attribute::StrokeAttribute aStroke(aDotDashArray, fFullDotDashLen);
268 // create primitive and add
269 const drawinglayer::primitive2d::Primitive2DReference xRef(new drawinglayer::primitive2d::PolygonStrokePrimitive2D(
270 aPolygon,
271 aLine,
272 aStroke));
273 xRetval.push_back(xRef);
276 // now paint the placeholder description, but only when masterpage
277 // is displayed as page directly (MasterPage view)
278 if(!bSubContentProcessing && bIsMasterPageObject)
280 OUString aObjectString;
282 switch( eKind )
284 case PresObjKind::Title:
286 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PageKind::Standard)
288 static OUString aTitleAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_TITLE));
289 aObjectString = aTitleAreaStr;
292 break;
294 case PresObjKind::Outline:
296 static OUString aOutlineAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_OUTLINE));
297 aObjectString = aOutlineAreaStr;
298 break;
300 case PresObjKind::Footer:
302 static OUString aFooterAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_FOOTER));
303 aObjectString = aFooterAreaStr;
304 break;
306 case PresObjKind::Header:
308 static OUString aHeaderAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_HEADER));
309 aObjectString = aHeaderAreaStr;
310 break;
312 case PresObjKind::DateTime:
314 static OUString aDateTimeStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_DATETIME));
315 aObjectString = aDateTimeStr;
316 break;
318 case PresObjKind::Notes:
320 static OUString aDateTimeStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_NOTES));
321 aObjectString = aDateTimeStr;
322 break;
324 case PresObjKind::SlideNumber:
326 if(pObjectsSdPage && pObjectsSdPage->GetPageKind() == PageKind::Standard)
328 static OUString aSlideAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_SLIDE));
329 aObjectString = aSlideAreaStr;
331 else
333 static OUString aNumberAreaStr(SdResId(STR_PLACEHOLDER_DESCRIPTION_NUMBER));
334 aObjectString = aNumberAreaStr;
336 break;
338 default:
340 break;
344 if( !aObjectString.isEmpty() )
346 // decompose object matrix to be able to place text correctly
347 basegfx::B2DTuple aScale;
348 basegfx::B2DTuple aTranslate;
349 double fRotate, fShearX;
350 aObjectMatrix.decompose(aScale, aTranslate, fRotate, fShearX);
352 // create font
353 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >( pObject );
354 const SdrTextVertAdjust eTVA(pTextObj ? pTextObj->GetTextVerticalAdjust() : SDRTEXTVERTADJUST_CENTER);
355 vcl::Font aScaledVclFont;
357 // use a text size factor to get more reliable text sizes from the text layouter
358 // (and from vcl), tipp from HDU
359 static const sal_uInt32 nTextSizeFactor(100);
361 // use a factor to get more linear text size calculations
362 aScaledVclFont.SetFontHeight( 500 * nTextSizeFactor );
364 // get basic geometry and get text size
365 drawinglayer::primitive2d::TextLayouterDevice aTextLayouter;
366 aTextLayouter.setFont(aScaledVclFont);
367 const sal_Int32 nTextLength(aObjectString.getLength());
369 // do not forget to use the factor again to get the width for the 500
370 const double fTextWidth(aTextLayouter.getTextWidth(aObjectString, 0, nTextLength) * (1.0 / nTextSizeFactor));
371 const double fTextHeight(aTextLayouter.getTextHeight() * (1.0 / nTextSizeFactor));
373 // calculate text primitive position. If text is at bottom, use top for
374 // the extra text and vice versa
375 const double fHorDist(125);
376 const double fVerDist(125);
377 const double fPosX((aTranslate.getX() + aScale.getX()) - fTextWidth - fHorDist);
378 const double fPosY((SDRTEXTVERTADJUST_BOTTOM == eTVA)
379 ? aTranslate.getY() - fVerDist + fTextHeight
380 : (aTranslate.getY() + aScale.getY()) - fVerDist);
382 // get font attributes; use normally scaled font
383 vcl::Font aVclFont;
384 basegfx::B2DVector aTextSizeAttribute;
386 aVclFont.SetFontHeight( 500 );
388 const drawinglayer::attribute::FontAttribute aFontAttribute(
389 drawinglayer::primitive2d::getFontAttributeFromVclFont(
390 aTextSizeAttribute,
391 aVclFont,
392 false,
393 false));
395 // fill text matrix
396 const basegfx::B2DHomMatrix aTextMatrix(basegfx::utils::createScaleShearXRotateTranslateB2DHomMatrix(
397 aTextSizeAttribute.getX(), aTextSizeAttribute.getY(),
398 fShearX,
399 fRotate,
400 fPosX, fPosY));
402 // create DXTextArray (can be empty one)
403 const ::std::vector< double > aDXArray{};
405 // create locale; this may need some more information in the future
406 const css::lang::Locale aLocale;
408 // create primitive and add
409 const drawinglayer::primitive2d::Primitive2DReference xRef(
410 new drawinglayer::primitive2d::TextSimplePortionPrimitive2D(
411 aTextMatrix,
412 aObjectString,
414 nTextLength,
415 aDXArray,
416 aFontAttribute,
417 aLocale,
418 aRGBColor));
419 xRetval.push_back(xRef);
426 if(bDoCreateGeometry)
428 xRetval.append(
429 sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(
430 rOriginal,
431 rDisplayInfo));
434 else
436 // not a SdrObject visualisation (maybe e.g. page) or no page
437 xRetval = sdr::contact::ViewObjectContactRedirector::createRedirectedPrimitive2DSequence(rOriginal, rDisplayInfo);
440 return xRetval;
444 * The event will be forwarded to the View
446 void View::CompleteRedraw(OutputDevice* pOutDev, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector /*=0*/)
448 // execute ??
449 if (mnLockRedrawSmph != 0)
450 return;
452 SdrPageView* pPgView = GetSdrPageView();
454 if (pPgView)
456 SdPage* pPage = static_cast<SdPage*>( pPgView->GetPage() );
457 if( pPage )
459 SdrOutliner& rOutl = mrDoc.GetDrawOutliner();
460 bool bScreenDisplay(true);
462 // #i75566# printing; suppress AutoColor BackgroundColor generation
463 // for visibility reasons by giving GetPageBackgroundColor()
464 // the needed hint
465 // #i75566# PDF export; suppress AutoColor BackgroundColor generation (see printing)
466 if (pOutDev && ((OUTDEV_PRINTER == pOutDev->GetOutDevType())
467 || (OUTDEV_PDF == pOutDev->GetOutDevType())))
468 bScreenDisplay = false;
470 // #i75566# Name change GetBackgroundColor -> GetPageBackgroundColor and
471 // hint value if screen display. Only then the AutoColor mechanisms shall be applied
472 rOutl.SetBackgroundColor( pPage->GetPageBackgroundColor(pPgView, bScreenDisplay) );
476 ViewRedirector aViewRedirector;
477 FmFormView::CompleteRedraw(pOutDev, rReg, pRedirector ? pRedirector : &aViewRedirector);
480 void View::MarkListHasChanged()
482 FmFormView::MarkListHasChanged();
484 if( GetMarkedObjectCount() > 0 )
485 maSmartTags.deselect();
488 bool View::SetAttributes(const SfxItemSet& rSet, bool bReplaceAll, bool /*bSlide*/, bool /*bMaster*/)
490 bool bOk = FmFormView::SetAttributes(rSet, bReplaceAll);
491 return bOk;
494 void View::GetAttributes( SfxItemSet& rTargetSet, bool bOnlyHardAttr ) const
496 FmFormView::GetAttributes( rTargetSet, bOnlyHardAttr );
500 * Is a presentation object selected?
502 bool View::IsPresObjSelected(bool bOnPage, bool bOnMasterPage, bool bCheckPresObjListOnly, bool bCheckLayoutOnly) const
504 SdrMarkList* pMarkList;
506 if (mnDragSrcPgNum != SDRPAGE_NOTFOUND &&
507 mnDragSrcPgNum != GetSdrPageView()->GetPage()->GetPageNum())
509 /* Drag&Drop is in progress
510 Source and destination page are different:
511 we use the saved mark list */
512 pMarkList = mpDragSrcMarkList.get();
514 else
516 // We use the current mark list
517 pMarkList = new SdrMarkList(GetMarkedObjectList());
520 SdrMark* pMark;
521 SdPage* pPage;
523 bool bSelected = false;
524 bool bMasterPage = false;
526 for (size_t nMark = pMarkList->GetMarkCount(); nMark && !bSelected; )
528 --nMark;
529 // Backwards through mark list
530 pMark = pMarkList->GetMark(nMark);
531 SdrObject* pObj = pMark->GetMarkedSdrObj();
533 if ( pObj && ( bCheckPresObjListOnly || pObj->IsEmptyPresObj() || pObj->GetUserCall() ) )
535 pPage = static_cast<SdPage*>( pObj->getSdrPageFromSdrObject() );
536 bMasterPage = pPage && pPage->IsMasterPage();
538 if ( (bMasterPage && bOnMasterPage) || (!bMasterPage && bOnPage) )
540 if ( pPage && pPage->IsPresObj(pObj) )
542 if( bCheckLayoutOnly )
544 PresObjKind eKind = pPage->GetPresObjKind(pObj);
546 if((eKind != PresObjKind::Footer) && (eKind != PresObjKind::Header) && (eKind != PresObjKind::DateTime) && (eKind != PresObjKind::SlideNumber) )
547 bSelected = true;
549 else
551 bSelected = true;
558 if (pMarkList != mpDragSrcMarkList.get())
560 delete pMarkList;
563 return bSelected;
566 void View::SelectAll()
568 if ( IsTextEdit() )
570 OutlinerView* pOLV = GetTextEditOutlinerView();
571 const ::Outliner* pOutliner = GetTextEditOutliner();
572 pOLV->SelectRange( 0, pOutliner->GetParagraphCount() );
574 else
576 MarkAll();
580 bool View::SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr)
582 // forward to SdrView
583 FmFormView::SetStyleSheet(pStyleSheet, bDontRemoveHardAttr);
584 return true;
588 * Start text input
590 static void SetSpellOptions( const SdDrawDocument& rDoc, EEControlBits& rCntrl )
592 bool bOnlineSpell = rDoc.GetOnlineSpell();
594 if( bOnlineSpell )
595 rCntrl |= EEControlBits::ONLINESPELLING;
596 else
597 rCntrl &= ~EEControlBits::ONLINESPELLING;
600 void OutlinerMasterViewFilter::Start(SdrOutliner *pOutl)
602 m_pOutl = pOutl;
603 OutlinerView* pOutlView = m_pOutl->GetView(0);
604 m_bReadOnly = pOutlView->IsReadOnly();
605 pOutlView->SetReadOnly(true);
608 void OutlinerMasterViewFilter::End()
610 if (m_pOutl)
612 OutlinerView* pOutlView = m_pOutl->GetView(0);
613 pOutlView->SetReadOnly(m_bReadOnly);
614 m_pOutl = nullptr;
618 SfxViewShell* View::GetSfxViewShell() const
620 SfxViewShell* pRet = nullptr;
622 if (mpViewSh)
623 pRet = &mpViewSh->GetViewShellBase();
625 return pRet;
628 // Create a new view-local UndoManager manager for Impress/Draw
629 std::unique_ptr<SdrUndoManager> View::createLocalTextUndoManager()
631 std::unique_ptr<SdrUndoManager> pUndoManager(new sd::UndoManager);
632 pUndoManager->SetDocShell(mpDocSh);
633 return pUndoManager;
636 bool View::SdrBeginTextEdit(
637 SdrObject* pObj, SdrPageView* pPV, vcl::Window* pWin,
638 bool bIsNewObj,
639 SdrOutliner* pOutl, OutlinerView* pGivenOutlinerView,
640 bool bDontDeleteOutliner, bool bOnlyOneView, bool bGrabFocus )
642 SdrPage* pPage = pObj ? pObj->getSdrPageFromSdrObject() : nullptr;
643 bool bMasterPage = pPage && pPage->IsMasterPage();
645 GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
646 EventMultiplexerEventId::BeginTextEdit, static_cast<void*>(pObj) );
648 if( pOutl==nullptr && pObj )
649 pOutl = SdrMakeOutliner(OutlinerMode::TextObject, pObj->getSdrModelFromSdrObject()).release();
651 // make draw&impress specific initialisations
652 if( pOutl )
654 pOutl->SetStyleSheetPool(static_cast<SfxStyleSheetPool*>( mrDoc.GetStyleSheetPool() ));
655 pOutl->SetCalcFieldValueHdl(LINK(SD_MOD(), SdModule, CalcFieldValueHdl));
656 EEControlBits nCntrl = pOutl->GetControlWord();
657 nCntrl |= EEControlBits::ALLOWBIGOBJS;
658 nCntrl |= EEControlBits::MARKFIELDS;
659 nCntrl |= EEControlBits::AUTOCORRECT;
661 nCntrl &= ~EEControlBits::ULSPACESUMMATION;
662 if ( mrDoc.IsSummationOfParagraphs() )
663 nCntrl |= EEControlBits::ULSPACESUMMATION;
665 SetSpellOptions( mrDoc, nCntrl );
667 pOutl->SetControlWord(nCntrl);
669 Reference< linguistic2::XSpellChecker1 > xSpellChecker( LinguMgr::GetSpellChecker() );
670 if ( xSpellChecker.is() )
671 pOutl->SetSpeller( xSpellChecker );
673 Reference< linguistic2::XHyphenator > xHyphenator( LinguMgr::GetHyphenator() );
674 if( xHyphenator.is() )
675 pOutl->SetHyphenator( xHyphenator );
677 pOutl->SetDefaultLanguage( Application::GetSettings().GetLanguageTag().getLanguageType() );
680 bool bReturn = FmFormView::SdrBeginTextEdit(
681 pObj, pPV, pWin, bIsNewObj, pOutl,
682 pGivenOutlinerView, bDontDeleteOutliner,
683 bOnlyOneView, bGrabFocus);
685 if ( mpViewSh )
687 mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
689 if (pObj && pObj->GetObjIdentifier() == OBJ_TABLE)
690 mpViewSh->UpdateScrollBars();
692 if (comphelper::LibreOfficeKit::isActive())
694 if (OutlinerView* pView = GetTextEditOutlinerView())
696 ::tools::Rectangle aRectangle = pView->GetOutputArea();
697 if (pWin && pWin->GetMapMode().GetMapUnit() == MapUnit::Map100thMM)
698 aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip));
699 OString sRectangle = aRectangle.toString();
700 SfxLokHelper::notifyOtherViews(&mpViewSh->GetViewShellBase(), LOK_CALLBACK_VIEW_LOCK, "rectangle", sRectangle);
705 if (::Outliner* pOL = bReturn ? GetTextEditOutliner() : nullptr)
707 if (pObj)
709 if( pObj->GetObjInventor() == SdrInventor::Default && pObj->GetObjIdentifier() == OBJ_TABLE )
711 Color aBackground = GetTextEditBackgroundColor(*this);
712 pOL->SetBackgroundColor( aBackground );
714 else
716 pObj->setSuitableOutlinerBg(*pOL);
720 pOL->SetParaInsertedHdl(LINK(this, View, OnParagraphInsertedHdl));
721 pOL->SetParaRemovingHdl(LINK(this, View, OnParagraphRemovingHdl));
724 if (bMasterPage && bReturn && pOutl)
726 const SdrTextObj* pTextObj = pOutl->GetTextObj();
727 const SdPage* pSdPage = pTextObj ? static_cast<const SdPage*>(pTextObj->getSdrPageFromSdrObject()) : nullptr;
728 const PresObjKind eKind = pSdPage ? pSdPage->GetPresObjKind(const_cast<SdrTextObj*>(pTextObj)) : PresObjKind::NONE;
729 switch (eKind)
731 case PresObjKind::Title:
732 case PresObjKind::Outline:
733 case PresObjKind::Text:
734 maMasterViewFilter.Start(pOutl);
735 break;
736 default:
737 break;
741 return bReturn;
744 /** ends current text editing */
745 SdrEndTextEditKind View::SdrEndTextEdit(bool bDontDeleteReally)
747 maMasterViewFilter.End();
749 ::tools::WeakReference<SdrTextObj> xObj( GetTextEditObject() );
751 bool bDefaultTextRestored = RestoreDefaultText( xObj.get() );
753 SdrEndTextEditKind eKind = FmFormView::SdrEndTextEdit(bDontDeleteReally);
755 if( bDefaultTextRestored )
757 if( xObj.is() && !xObj->IsEmptyPresObj() )
759 xObj->SetEmptyPresObj( true );
761 else
763 eKind = SdrEndTextEditKind::Unchanged;
766 else if( xObj.is() && xObj->IsEmptyPresObj() )
768 SdrTextObj* pObj = xObj.get();
769 if( pObj && pObj->HasText() )
771 SdrPage* pPage = pObj->getSdrPageFromSdrObject();
772 if( !pPage || !pPage->IsMasterPage() )
773 pObj->SetEmptyPresObj( false );
777 GetViewShell()->GetViewShellBase().GetEventMultiplexer()->MultiplexEvent(
778 EventMultiplexerEventId::EndTextEdit,
779 static_cast<void*>(xObj.get()) );
781 if( xObj.is() )
783 if ( mpViewSh )
785 mpViewSh->GetViewShellBase().GetDrawController().FireSelectionChangeListener();
787 if (comphelper::LibreOfficeKit::isActive())
788 SfxLokHelper::notifyOtherViews(&mpViewSh->GetViewShellBase(), LOK_CALLBACK_VIEW_LOCK, "rectangle", "EMPTY");
792 SdPage* pPage = dynamic_cast< SdPage* >( xObj->getSdrPageFromSdrObject() );
793 if( pPage )
794 pPage->onEndTextEdit( xObj.get() );
797 return eKind;
800 /** restores the default text if the given text object is currently in edit mode and
801 no text has been entered already. Is only useful just before text edit ends. */
802 bool View::RestoreDefaultText( SdrTextObj* pTextObj )
804 bool bRestored = false;
806 if( pTextObj && (pTextObj == GetTextEditObject()) )
808 if( !pTextObj->HasText() )
810 SdPage* pPage = dynamic_cast< SdPage* >( pTextObj->getSdrPageFromSdrObject() );
812 if(pPage)
814 bRestored = pPage->RestoreDefaultText( pTextObj );
815 if( bRestored )
817 SdrOutliner* pOutliner = GetTextEditOutliner();
818 pTextObj->SetTextEditOutliner( pOutliner );
819 OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
820 if (pOutliner)
821 pOutliner->SetText(*pParaObj);
827 return bRestored;
831 * Sets the original size of the marked objects.
833 void View::SetMarkedOriginalSize()
835 std::unique_ptr<SdrUndoGroup> pUndoGroup(new SdrUndoGroup(mrDoc));
836 const size_t nCount = GetMarkedObjectCount();
837 bool bOK = false;
839 for( size_t i = 0; i < nCount; ++i )
841 SdrObject* pObj = GetMarkedObjectByIndex(i);
843 if( pObj->GetObjInventor() == SdrInventor::Default )
845 if( pObj->GetObjIdentifier() == OBJ_OLE2 )
847 uno::Reference < embed::XEmbeddedObject > xObj = static_cast<SdrOle2Obj*>(pObj)->GetObjRef();
848 if( xObj.is() )
850 // TODO/LEAN: working with VisualArea can switch object to running state
852 sal_Int64 nAspect = static_cast<SdrOle2Obj*>(pObj)->GetAspect();
853 Size aOleSize;
855 if ( nAspect == embed::Aspects::MSOLE_ICON )
857 MapMode aMap100( MapUnit::Map100thMM );
858 aOleSize = static_cast<SdrOle2Obj*>(pObj)->GetOrigObjSize( &aMap100 );
859 bOK = true;
861 else
863 MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
866 awt::Size aSz = xObj->getVisualAreaSize( nAspect );
867 aOleSize = OutputDevice::LogicToLogic(Size(aSz.Width, aSz.Height), MapMode(aUnit), MapMode(MapUnit::Map100thMM));
868 bOK = true;
870 catch( embed::NoVisualAreaSizeException& )
874 if ( bOK )
876 ::tools::Rectangle aDrawRect( pObj->GetLogicRect() );
878 pUndoGroup->AddAction( mrDoc.GetSdrUndoFactory().CreateUndoGeoObject( *pObj ) );
879 pObj->Resize( aDrawRect.TopLeft(), Fraction( aOleSize.Width(), aDrawRect.GetWidth() ),
880 Fraction( aOleSize.Height(), aDrawRect.GetHeight() ) );
884 else if( pObj->GetObjIdentifier() == OBJ_GRAF )
886 const SdrGrafObj* pSdrGrafObj = static_cast< const SdrGrafObj* >(pObj);
887 const Size aSize = pSdrGrafObj->getOriginalSize( );
888 pUndoGroup->AddAction( GetModel()->GetSdrUndoFactory().CreateUndoGeoObject(*pObj ) );
889 ::tools::Rectangle aRect( pObj->GetLogicRect() );
890 aRect.SetSize( aSize );
891 pObj->SetLogicRect( aRect );
892 bOK = true;
897 if( bOK )
899 pUndoGroup->SetComment(SdResId(STR_UNDO_ORIGINALSIZE));
900 mpDocSh->GetUndoManager()->AddUndoAction(std::move(pUndoGroup));
905 * Connect OLE object to client.
907 void View::DoConnect(SdrOle2Obj* pObj)
909 if (!mpViewSh)
910 return;
912 uno::Reference < embed::XEmbeddedObject > xObj( pObj->GetObjRef() );
913 if( !xObj.is() )
914 return;
916 ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
917 SfxInPlaceClient* pSdClient = mpViewSh-> GetViewShellBase().FindIPClient( xObj, pWindow );
918 if ( pSdClient )
919 return;
921 pSdClient = new Client(pObj, mpViewSh, pWindow);
922 ::tools::Rectangle aRect = pObj->GetLogicRect();
924 // TODO/LEAN: working with visual area can switch object to running state
925 Size aDrawSize = aRect.GetSize();
927 MapMode aMapMode( mrDoc.GetScaleUnit() );
928 Size aObjAreaSize = pObj->GetOrigObjSize( &aMapMode );
930 Fraction aScaleWidth (aDrawSize.Width(), aObjAreaSize.Width() );
931 Fraction aScaleHeight(aDrawSize.Height(), aObjAreaSize.Height() );
932 aScaleWidth.ReduceInaccurate(10); // compatible to SdrOle2Obj
933 aScaleHeight.ReduceInaccurate(10);
934 pSdClient->SetSizeScale(aScaleWidth, aScaleHeight);
936 // visible area is only changed in-place!
937 // the object area must be set after the scaling, since it triggers resize
938 aRect.SetSize(aObjAreaSize);
939 pSdClient->SetObjArea(aRect);
943 bool View::IsMorphingAllowed() const
945 const SdrMarkList& rMarkList = GetMarkedObjectList();
946 bool bRet = false;
948 if ( rMarkList.GetMarkCount() == 2 )
950 const SdrObject* pObj1 = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
951 const SdrObject* pObj2 = rMarkList.GetMark( 1 )->GetMarkedSdrObj();
952 const sal_uInt16 nKind1 = pObj1->GetObjIdentifier();
953 const sal_uInt16 nKind2 = pObj2->GetObjIdentifier();
955 if ( ( nKind1 != OBJ_TEXT && nKind2 != OBJ_TEXT ) &&
956 ( nKind1 != OBJ_TITLETEXT && nKind2 != OBJ_TITLETEXT ) &&
957 ( nKind1 != OBJ_OUTLINETEXT && nKind2 != OBJ_OUTLINETEXT ) &&
958 ( nKind1 != OBJ_GRUP && nKind2 != OBJ_GRUP ) &&
959 ( nKind1 != OBJ_LINE && nKind2 != OBJ_LINE ) &&
960 ( nKind1 != OBJ_PLIN && nKind2 != OBJ_PLIN ) &&
961 ( nKind1 != OBJ_PATHLINE && nKind2 != OBJ_PATHLINE ) &&
962 ( nKind1 != OBJ_FREELINE && nKind2 != OBJ_FREELINE ) &&
963 ( nKind1 != OBJ_PATHPLIN && nKind2 != OBJ_PATHPLIN ) &&
964 ( nKind1 != OBJ_MEASURE && nKind2 != OBJ_MEASURE ) &&
965 ( nKind1 != OBJ_EDGE && nKind2 != OBJ_EDGE ) &&
966 ( nKind1 != OBJ_GRAF && nKind2 != OBJ_GRAF ) &&
967 ( nKind1 != OBJ_OLE2 && nKind2 != OBJ_OLE2 ) &&
968 ( nKind1 != OBJ_CAPTION && nKind2 != OBJ_CAPTION ) &&
969 dynamic_cast< const E3dObject *>( pObj1 ) == nullptr && dynamic_cast< const E3dObject *>( pObj2 ) == nullptr )
971 SfxItemSet aSet1( mrDoc.GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLSTYLE>{} );
972 SfxItemSet aSet2( mrDoc.GetPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLSTYLE>{} );
974 aSet1.Put(pObj1->GetMergedItemSet());
975 aSet2.Put(pObj2->GetMergedItemSet());
977 const drawing::FillStyle eFillStyle1 = aSet1.Get( XATTR_FILLSTYLE ).GetValue();
978 const drawing::FillStyle eFillStyle2 = aSet2.Get( XATTR_FILLSTYLE ).GetValue();
980 if( ( eFillStyle1 == drawing::FillStyle_NONE || eFillStyle1 == drawing::FillStyle_SOLID ) &&
981 ( eFillStyle2 == drawing::FillStyle_NONE || eFillStyle2 == drawing::FillStyle_SOLID ) )
982 bRet = true;
986 return bRet;
989 bool View::IsVectorizeAllowed() const
991 const SdrMarkList& rMarkList = GetMarkedObjectList();
992 bool bRet = false;
994 if( rMarkList.GetMarkCount() == 1 )
996 const SdrGrafObj* pObj = dynamic_cast< const SdrGrafObj* >(rMarkList.GetMark( 0 )->GetMarkedSdrObj());
998 if(pObj)
1000 if(GraphicType::Bitmap == pObj->GetGraphicType() && !pObj->isEmbeddedVectorGraphicData())
1002 bRet = true;
1007 return bRet;
1010 void View::onAccessibilityOptionsChanged()
1012 if( !mpViewSh )
1013 return;
1015 ::sd::Window* pWindow = mpViewSh->GetActiveWindow();
1016 if( !pWindow )
1017 return;
1019 const StyleSettings& rStyleSettings = pWindow->GetSettings().GetStyleSettings();
1021 SvtAccessibilityOptions& aAccOptions = getAccessibilityOptions();
1023 if( mpViewSh->GetViewFrame() && mpViewSh->GetViewFrame()->GetDispatcher() )
1025 sal_uInt16 nOutputSlot, nPreviewSlot;
1027 if( rStyleSettings.GetHighContrastMode() )
1029 nOutputSlot = SID_OUTPUT_QUALITY_CONTRAST;
1031 else
1033 nOutputSlot = SID_OUTPUT_QUALITY_COLOR;
1036 if( rStyleSettings.GetHighContrastMode() && aAccOptions.GetIsForPagePreviews() )
1038 nPreviewSlot = SID_PREVIEW_QUALITY_CONTRAST;
1040 else
1042 nPreviewSlot = SID_PREVIEW_QUALITY_COLOR;
1045 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nOutputSlot, SfxCallMode::ASYNCHRON );
1046 mpViewSh->GetViewFrame()->GetDispatcher()->Execute( nPreviewSlot, SfxCallMode::ASYNCHRON );
1049 mpViewSh->Invalidate();
1052 IMPL_LINK( View, OnParagraphInsertedHdl, ::Outliner::ParagraphHdlParam, aParam, void )
1054 SdrObject* pObj = GetTextEditObject();
1056 if( aParam.pPara && pObj )
1058 SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() );
1059 if( pPage )
1060 pPage->onParagraphInserted( aParam.pOutliner, aParam.pPara, pObj );
1065 * Handler for the deletion of the pages (paragraphs).
1067 IMPL_LINK( View, OnParagraphRemovingHdl, ::Outliner::ParagraphHdlParam, aParam, void )
1069 SdrObject* pObj = GetTextEditObject();
1071 if( aParam.pPara && pObj )
1073 SdPage* pPage = dynamic_cast< SdPage* >( pObj->getSdrPageFromSdrObject() );
1074 if( pPage )
1075 pPage->onParagraphRemoving( aParam.pOutliner, aParam.pPara, pObj );
1079 bool View::isRecordingUndo() const
1081 if( mrDoc.IsUndoEnabled() )
1083 sd::UndoManager* pUndoManager = mrDoc.GetUndoManager();
1084 return pUndoManager && pUndoManager->IsInListAction();
1086 else
1088 return false;
1092 void View::AddCustomHdl()
1094 maSmartTags.addCustomHandles( maHdlList );
1097 void View::updateHandles()
1099 AdjustMarkHdl();
1102 SdrViewContext View::GetContext() const
1104 SdrViewContext eContext = SdrViewContext::Standard;
1105 if( maSmartTags.getContext( eContext ) )
1106 return eContext;
1107 else
1108 return FmFormView::GetContext();
1111 bool View::HasMarkablePoints() const
1113 if( maSmartTags.HasMarkablePoints() )
1114 return true;
1115 else
1116 return FmFormView::HasMarkablePoints();
1119 sal_Int32 View::GetMarkablePointCount() const
1121 sal_Int32 nCount = FmFormView::GetMarkablePointCount();
1122 nCount += maSmartTags.GetMarkablePointCount();
1123 return nCount;
1126 bool View::HasMarkedPoints() const
1128 if( maSmartTags.HasMarkedPoints() )
1129 return true;
1130 else
1131 return FmFormView::HasMarkedPoints();
1134 bool View::MarkPoint(SdrHdl& rHdl, bool bUnmark )
1136 if( maSmartTags.MarkPoint( rHdl, bUnmark ) )
1137 return true;
1138 else
1139 return FmFormView::MarkPoint( rHdl, bUnmark );
1142 bool View::MarkPoints(const ::tools::Rectangle* pRect, bool bUnmark)
1144 if( maSmartTags.MarkPoints( pRect, bUnmark ) )
1145 return true;
1146 else
1147 return FmFormView::MarkPoints( pRect, bUnmark );
1150 void View::CheckPossibilities()
1152 FmFormView::CheckPossibilities();
1153 maSmartTags.CheckPossibilities();
1156 void View::OnBeginPasteOrDrop( PasteOrDropInfos* pInfo )
1158 SdrOutliner* pOutliner = GetTextEditOutliner();
1159 if (!pOutliner)
1160 return;
1162 // Turn character attributes of the paragraph of the insert position into
1163 // character-level attributes, so they are not lost when OnEndPasteOrDrop()
1164 // sets the paragraph stylesheet.
1165 SfxItemSet aSet(pOutliner->GetParaAttribs(pInfo->nStartPara));
1166 pOutliner->SetCharAttribs(pInfo->nStartPara, aSet);
1169 /** this is called after a paste or drop operation, make sure that the newly inserted paragraphs
1170 get the correct style sheet. */
1171 void View::OnEndPasteOrDrop( PasteOrDropInfos* pInfo )
1173 /* Style Sheet handling */
1174 SdrTextObj* pTextObj = GetTextEditObject();
1175 SdrOutliner* pOutliner = GetTextEditOutliner();
1176 if( !pOutliner || !pTextObj || !pTextObj->getSdrPageFromSdrObject() )
1177 return;
1179 SdPage* pPage = static_cast< SdPage* >( pTextObj->getSdrPageFromSdrObject() );
1180 const PresObjKind eKind = pPage->GetPresObjKind(pTextObj);
1182 // outline kinds are taken care of in Outliner::ImplSetLevelDependentStyleSheet
1183 if( eKind == PresObjKind::Outline )
1184 return;
1186 SfxStyleSheet* pStyleSheet = nullptr;
1187 if( eKind != PresObjKind::NONE )
1188 pStyleSheet = pPage->GetStyleSheetForPresObj(eKind);
1189 else
1190 pStyleSheet = pTextObj->GetStyleSheet();
1191 // just put the object style on each new paragraph
1192 for ( sal_Int32 nPara = pInfo->nStartPara; nPara <= pInfo->nEndPara; nPara++ )
1194 pOutliner->SetStyleSheet( nPara, pStyleSheet );
1198 bool View::ShouldToggleOn(
1199 const bool bBulletOnOffMode,
1200 const bool bNormalBullet)
1202 // If setting bullets/numbering by the dialog, always should toggle on.
1203 if (!bBulletOnOffMode)
1204 return true;
1205 SdrModel* pSdrModel = GetModel();
1206 if (!pSdrModel)
1207 return false;
1209 bool bToggleOn = false;
1210 std::unique_ptr<SdrOutliner> pOutliner(SdrMakeOutliner(OutlinerMode::TextObject, *pSdrModel));
1211 const size_t nMarkCount = GetMarkedObjectCount();
1212 for (size_t nIndex = 0; nIndex < nMarkCount && !bToggleOn; ++nIndex)
1214 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
1215 if (!pTextObj || pTextObj->IsTextEditActive())
1216 continue;
1217 if( dynamic_cast< const SdrTableObj *>( pTextObj ) != nullptr)
1219 SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
1220 if (!pTableObj)
1221 continue;
1222 CellPos aStart, aEnd;
1223 SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
1224 if (pTableController)
1226 pTableController->getSelectedCells(aStart, aEnd);
1228 else
1230 aStart = SdrTableObj::getFirstCell();
1231 aEnd = pTableObj->getLastCell();
1233 sal_Int32 nColCount = pTableObj->getColumnCount();
1234 for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow && !bToggleOn; nRow++)
1236 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol && !bToggleOn; nCol++)
1238 sal_Int32 nCellIndex = nRow * nColCount + nCol;
1239 SdrText* pText = pTableObj->getText(nCellIndex);
1240 if (!pText || !pText->GetOutlinerParaObject())
1241 continue;
1242 pOutliner->SetText(*(pText->GetOutlinerParaObject()));
1243 sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
1244 bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1);
1245 pOutliner->Clear();
1249 else
1251 OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
1252 if (!pParaObj)
1253 continue;
1254 pOutliner->SetText(*pParaObj);
1255 sal_Int16 nStatus = pOutliner->GetBulletsNumberingStatus();
1256 bToggleOn = (bNormalBullet && nStatus != 0) || (!bNormalBullet && nStatus != 1);
1257 pOutliner->Clear();
1260 return bToggleOn;
1263 void View::ChangeMarkedObjectsBulletsNumbering(
1264 const bool bToggle,
1265 const bool bHandleBullets,
1266 const SvxNumRule* pNumRule )
1268 SdrModel* pSdrModel = GetModel();
1269 vcl::Window* pWindow = dynamic_cast< vcl::Window* >(GetFirstOutputDevice());
1270 if (!pSdrModel || !pWindow)
1271 return;
1273 const bool bUndoEnabled = pSdrModel->IsUndoEnabled();
1274 std::unique_ptr<SdrUndoGroup> pUndoGroup(bUndoEnabled ? new SdrUndoGroup(*pSdrModel) : nullptr);
1276 const bool bToggleOn = ShouldToggleOn( bToggle, bHandleBullets );
1278 std::unique_ptr<SdrOutliner> pOutliner(SdrMakeOutliner(OutlinerMode::TextObject, *pSdrModel));
1279 std::unique_ptr<OutlinerView> pOutlinerView(new OutlinerView(pOutliner.get(), pWindow));
1281 const size_t nMarkCount = GetMarkedObjectCount();
1282 for (size_t nIndex = 0; nIndex < nMarkCount; ++nIndex)
1284 SdrTextObj* pTextObj = dynamic_cast< SdrTextObj* >(GetMarkedObjectByIndex(nIndex));
1285 if (!pTextObj || pTextObj->IsTextEditActive())
1286 continue;
1287 if( dynamic_cast< SdrTableObj *>( pTextObj ) != nullptr)
1289 SdrTableObj* pTableObj = dynamic_cast< SdrTableObj* >(pTextObj);
1290 if (!pTableObj)
1291 continue;
1292 CellPos aStart, aEnd;
1293 SvxTableController* pTableController = dynamic_cast< SvxTableController* >(getSelectionController().get());
1294 if (pTableController)
1296 pTableController->getSelectedCells(aStart, aEnd);
1298 else
1300 aStart = SdrTableObj::getFirstCell();
1301 aEnd = pTableObj->getLastCell();
1303 sal_Int32 nColCount = pTableObj->getColumnCount();
1304 for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++)
1306 for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++)
1308 sal_Int32 nCellIndex = nRow * nColCount + nCol;
1309 SdrText* pText = pTableObj->getText(nCellIndex);
1310 if (!pText || !pText->GetOutlinerParaObject())
1311 continue;
1313 pOutliner->SetText(*(pText->GetOutlinerParaObject()));
1314 if (bUndoEnabled)
1316 pUndoGroup->AddAction(pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, nCellIndex));
1318 if ( !bToggleOn )
1320 pOutlinerView->SwitchOffBulletsNumbering();
1322 else
1324 pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
1326 sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
1327 pText->SetOutlinerParaObject(pOutliner->CreateParaObject(0, static_cast<sal_uInt16>(nParaCount)));
1328 pOutliner->Clear();
1331 // Broadcast the object change event.
1332 if (!pTextObj->AdjustTextFrameWidthAndHeight())
1334 pTextObj->SetChanged();
1335 pTextObj->BroadcastObjectChange();
1338 else
1340 OutlinerParaObject* pParaObj = pTextObj->GetOutlinerParaObject();
1341 if (!pParaObj)
1342 continue;
1343 pOutliner->SetText(*pParaObj);
1344 if (bUndoEnabled)
1346 pUndoGroup->AddAction(
1347 pSdrModel->GetSdrUndoFactory().CreateUndoObjectSetText(*pTextObj, 0));
1349 if ( !bToggleOn )
1351 pOutlinerView->SwitchOffBulletsNumbering();
1353 else
1355 pOutlinerView->ApplyBulletsNumbering( bHandleBullets, pNumRule, bToggle );
1357 sal_uInt32 nParaCount = pOutliner->GetParagraphCount();
1358 pTextObj->SetOutlinerParaObject(pOutliner->CreateParaObject(0, static_cast<sal_uInt16>(nParaCount)));
1359 pOutliner->Clear();
1363 if ( bUndoEnabled && pUndoGroup->GetActionCount() > 0 )
1365 pSdrModel->BegUndo();
1366 pSdrModel->AddUndo(std::move(pUndoGroup));
1367 pSdrModel->EndUndo();
1371 } // end of namespace sd
1373 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */