android: Update app-specific/MIME type icons
[LibreOffice.git] / sd / source / ui / view / drviews2.cxx
blob7dc9e98a167f3f2fa2071736c00c9b44260089d0
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 <config_features.h>
22 #include <avmedia/mediaplayer.hxx>
24 #include <basic/sberrors.hxx>
25 #include <basic/sbstar.hxx>
27 #include <com/sun/star/drawing/XMasterPagesSupplier.hpp>
28 #include <com/sun/star/drawing/XDrawPages.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
31 #include <com/sun/star/ui/dialogs/XSLTFilterDialog.hpp>
32 #include <com/sun/star/frame/XDispatchProvider.hpp>
33 #include <com/sun/star/util/URLTransformer.hpp>
34 #include <com/sun/star/util/XURLTransformer.hpp>
35 #include <com/sun/star/scanner/XScannerManager2.hpp>
36 #include <com/sun/star/document/XDocumentProperties.hpp>
38 #include <comphelper/processfactory.hxx>
39 #include <comphelper/propertysequence.hxx>
40 #include <comphelper/scopeguard.hxx>
41 #include <comphelper/lok.hxx>
43 #include <editeng/contouritem.hxx>
44 #include <editeng/editdata.hxx>
45 #include <editeng/eeitem.hxx>
46 #include <editeng/flditem.hxx>
47 #include <editeng/section.hxx>
48 #include <editeng/editobj.hxx>
49 #include <editeng/CustomPropertyField.hxx>
50 #include <editeng/urlfieldhelper.hxx>
52 #include <sal/log.hxx>
54 #include <sfx2/bindings.hxx>
55 #include <sfx2/dispatch.hxx>
56 #include <sfx2/docfile.hxx>
57 #include <sfx2/msgpool.hxx>
58 #include <sfx2/msg.hxx>
59 #include <sfx2/request.hxx>
60 #include <sfx2/viewfrm.hxx>
61 #include <sfx2/zoomitem.hxx>
63 #include <svx/compressgraphicdialog.hxx>
64 #include <svx/ClassificationDialog.hxx>
65 #include <svx/ClassificationCommon.hxx>
66 #include <svx/bmpmask.hxx>
67 #include <svx/extedit.hxx>
68 #include <svx/extrusionbar.hxx>
69 #include <svx/f3dchild.hxx>
70 #include <svx/fontwork.hxx>
71 #include <svx/fontworkbar.hxx>
72 #include <svx/graphichelper.hxx>
73 #include <svx/hlnkitem.hxx>
74 #include <svx/imapdlg.hxx>
75 #include <svx/sdtagitm.hxx>
76 #include <svx/svdograf.hxx>
77 #include <svx/svdoole2.hxx>
78 #include <svx/svdpagv.hxx>
79 #include <svx/svdundo.hxx>
80 #include <svx/svxdlg.hxx>
81 #include <svx/svxids.hrc>
82 #include <svx/sdtfsitm.hxx>
83 #include <svx/sdmetitm.hxx>
84 #include <svx/zoomslideritem.hxx>
85 #include <svx/xflclit.hxx>
86 #include <svx/xlnwtit.hxx>
87 #include <svx/chrtitem.hxx>
88 #include <svx/xlnclit.hxx>
89 #include <svx/xflgrit.hxx>
91 #include <comphelper/diagnose_ex.hxx>
92 #include <tools/UnitConversion.hxx>
94 #include <unotools/useroptions.hxx>
96 #include <vcl/abstdlg.hxx>
97 #include <vcl/graph.hxx>
98 #include <vcl/svapp.hxx>
99 #include <vcl/unohelp2.hxx>
100 #include <vcl/weld.hxx>
102 #include <editeng/cmapitem.hxx>
103 #include <editeng/escapementitem.hxx>
104 #include <editeng/kernitem.hxx>
105 #include <editeng/wghtitem.hxx>
106 #include <editeng/postitem.hxx>
107 #include <editeng/udlnitem.hxx>
108 #include <editeng/crossedoutitem.hxx>
109 #include <editeng/shdditem.hxx>
110 #include <editeng/numitem.hxx>
111 #include <svx/svdobj.hxx>
112 #include <svx/SvxColorChildWindow.hxx>
113 #include <editeng/outlobj.hxx>
114 #include <editeng/flstitem.hxx>
115 #include <editeng/fontitem.hxx>
116 #include <editeng/fhgtitem.hxx>
117 #include <editeng/colritem.hxx>
119 #include <svl/poolitem.hxx>
120 #include <svl/style.hxx>
121 #include <svl/whiter.hxx>
123 #include <app.hrc>
124 #include <strings.hrc>
126 #include <AnimationChildWindow.hxx>
127 #include <DrawDocShell.hxx>
128 #include <DrawViewShell.hxx>
129 #include <LayerTabBar.hxx>
130 #include <Outliner.hxx>
131 #include <ViewShellHint.hxx>
132 #include <ViewShellImplementation.hxx>
133 #include <Window.hxx>
134 #include <drawdoc.hxx>
135 #include <drawview.hxx>
136 #include <fuarea.hxx>
137 #include <fubullet.hxx>
138 #include <fuchar.hxx>
139 #include <fucushow.hxx>
140 #include <fuconnct.hxx>
141 #include <fucopy.hxx>
142 #include <fudspord.hxx>
143 #include <fuexecuteinteraction.hxx>
144 #include <fuexpand.hxx>
145 #include <fuinsert.hxx>
146 #include <fuinsfil.hxx>
147 #include <fuline.hxx>
148 #include <fulinend.hxx>
149 #include <fulink.hxx>
150 #include <fumeasur.hxx>
151 #include <fumorph.hxx>
152 #include <fuoaprms.hxx>
153 #include <fuolbull.hxx>
154 #include <fupage.hxx>
155 #include <fuparagr.hxx>
156 #include <fuprlout.hxx>
157 #include <fuscale.hxx>
158 #include <fusel.hxx>
159 #include <fusldlg.hxx>
160 #include <fusnapln.hxx>
161 #include <fusumry.hxx>
162 #include <futempl.hxx>
163 #include <futhes.hxx>
164 #include <futransf.hxx>
165 #include <futxtatt.hxx>
166 #include <fuvect.hxx>
167 #include <futext.hxx>
168 #include <helpids.h>
169 #include <sdabstdlg.hxx>
170 #include <sdattr.hxx>
171 #include <sdpage.hxx>
172 #include <sdresid.hxx>
173 #include <unokywds.hxx>
174 #include <slideshow.hxx>
175 #include <stlsheet.hxx>
176 #include <undolayer.hxx>
177 #include <sfx2/sidebar/Sidebar.hxx>
178 #include <sfx2/classificationhelper.hxx>
179 #include <sdmod.hxx>
180 #include <model/SlsPageDescriptor.hxx>
181 #include <model/SlsPageEnumerationProvider.hxx>
182 #include <SlideSorter.hxx>
183 #include <view/SlideSorterView.hxx>
184 #include <SlideSorterViewShell.hxx>
185 #include <controller/SlideSorterController.hxx>
186 #include <controller/SlsPageSelector.hxx>
187 #include <tools/GraphicSizeCheck.hxx>
189 #include <ViewShellBase.hxx>
190 #include <memory>
192 using namespace ::com::sun::star;
193 using namespace ::com::sun::star::uno;
195 #define MIN_ACTIONS_FOR_DIALOG 5000 ///< if there are more meta objects, we show a dialog during the break up
197 namespace sd {
199 namespace {
201 const SvxFieldItem* findField(editeng::Section const & rSection)
203 for (SfxPoolItem const * pPool: rSection.maAttributes)
205 if (pPool->Which() == EE_FEATURE_FIELD)
206 return static_cast<const SvxFieldItem*>(pPool);
208 return nullptr;
211 bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, std::u16string_view rName)
213 for (editeng::Section const & rSection : aSections)
215 const SvxFieldItem* pFieldItem = findField(rSection);
216 if (pFieldItem)
218 const editeng::CustomPropertyField* pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField());
219 if (pCustomPropertyField && pCustomPropertyField->GetName() == rName)
220 return true;
223 return false;
226 OUString getWeightString(SfxItemSet const & rItemSet)
228 OUString sWeightString = "NORMAL";
230 if (const SfxPoolItem* pItem = rItemSet.GetItem(EE_CHAR_WEIGHT, false))
232 const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem);
233 if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD)
234 sWeightString = "BOLD";
236 return sWeightString;
239 class ClassificationCommon
241 protected:
242 sd::DrawViewShell& m_rDrawViewShell;
243 uno::Reference<document::XDocumentProperties> m_xDocumentProperties;
244 uno::Reference<beans::XPropertyContainer> m_xPropertyContainer;
245 sfx::ClassificationKeyCreator m_aKeyCreator;
246 public:
247 ClassificationCommon(sd::DrawViewShell& rDrawViewShell, const css::uno::Reference<css::document::XDocumentProperties>& rDocProps)
248 : m_rDrawViewShell(rDrawViewShell)
249 , m_xDocumentProperties(rDocProps)
250 , m_xPropertyContainer(m_xDocumentProperties->getUserDefinedProperties())
251 , m_aKeyCreator(SfxClassificationHelper::getPolicyType())
255 class ClassificationCollector : public ClassificationCommon
257 private:
258 std::vector<svx::ClassificationResult> m_aResults;
260 void iterateSectionsAndCollect(std::vector<editeng::Section> const & rSections, EditTextObject const & rEditText)
262 sal_Int32 nCurrentParagraph = -1;
263 OUString sBlank;
265 for (editeng::Section const & rSection : rSections)
267 // Insert new paragraph if needed
268 while (nCurrentParagraph < rSection.mnParagraph)
270 nCurrentParagraph++;
271 // Get Weight of current paragraph
272 OUString sWeightProperty = getWeightString(rEditText.GetParaAttribs(nCurrentParagraph));
273 // Insert new paragraph into collection
274 m_aResults.push_back({ svx::ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank });
277 const SvxFieldItem* pFieldItem = findField(rSection);
278 const editeng::CustomPropertyField* pCustomPropertyField = pFieldItem ?
279 dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField()) :
280 nullptr;
281 if (pCustomPropertyField)
283 const OUString& aKey = pCustomPropertyField->GetName();
284 if (m_aKeyCreator.isMarkingTextKey(aKey))
286 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey);
287 m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank });
289 else if (m_aKeyCreator.isCategoryNameKey(aKey) || m_aKeyCreator.isCategoryIdentifierKey(aKey))
291 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey);
292 m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank });
294 else if (m_aKeyCreator.isMarkingKey(aKey))
296 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey);
297 m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank });
299 else if (m_aKeyCreator.isIntellectualPropertyPartKey(aKey))
301 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey);
302 m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank });
308 public:
309 ClassificationCollector(sd::DrawViewShell & rDrawViewShell, const css::uno::Reference<css::document::XDocumentProperties>& rDocProps)
310 : ClassificationCommon(rDrawViewShell, rDocProps)
313 std::vector<svx::ClassificationResult> const & getResults() const
315 return m_aResults;
318 void collect()
320 // Set to MASTER mode
321 EditMode eOldMode = m_rDrawViewShell.GetEditMode();
322 if (eOldMode != EditMode::MasterPage)
323 m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false);
325 // Scoped guard to revert to the previous mode
326 comphelper::ScopeGuard const aGuard([this, eOldMode] () {
327 m_rDrawViewShell.ChangeEditMode(eOldMode, false);
330 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard);
332 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex)
334 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard);
335 for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject)
337 SdrObject* pObject = pMasterPage->GetObj(nObject);
338 SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject);
339 if (pRectObject && pRectObject->GetTextKind() == SdrObjKind::Text)
341 OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject();
342 if (pOutlinerParagraphObject)
344 const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject();
345 std::vector<editeng::Section> aSections;
346 rEditText.GetAllSections(aSections);
348 // Search for a custom property field that has the classification category identifier key
349 if (hasCustomPropertyField(aSections, m_aKeyCreator.makeCategoryNameKey()))
351 iterateSectionsAndCollect(aSections, rEditText);
352 return;
361 class ClassificationInserter : public ClassificationCommon
363 private:
364 /// Delete the previous existing classification object(s) - if they exist
365 void deleteExistingObjects()
367 OUString sKey = m_aKeyCreator.makeCategoryNameKey();
369 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard);
371 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex)
373 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard);
374 for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject)
376 SdrObject* pObject = pMasterPage->GetObj(nObject);
377 SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject);
378 if (pRectObject && pRectObject->GetTextKind() == SdrObjKind::Text)
380 OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject();
381 if (pOutlinerParagraphObject)
383 const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject();
384 std::vector<editeng::Section> aSections;
385 rEditText.GetAllSections(aSections);
387 if (hasCustomPropertyField(aSections, sKey))
389 pMasterPage->RemoveObject(pRectObject->GetOrdNum());
397 void fillTheOutliner(Outliner* pOutliner, std::vector<svx::ClassificationResult> const & rResults)
399 sal_Int32 nParagraph = -1;
400 for (svx::ClassificationResult const & rResult : rResults)
403 ESelection aPosition(nParagraph, EE_TEXTPOS_MAX_COUNT, nParagraph, EE_TEXTPOS_MAX_COUNT);
405 switch (rResult.meType)
407 case svx::ClassificationType::TEXT:
409 OUString sKey = m_aKeyCreator.makeNumberedTextKey();
410 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName);
411 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
413 break;
415 case svx::ClassificationType::CATEGORY:
417 OUString sKey = m_aKeyCreator.makeCategoryNameKey();
418 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
420 break;
422 case svx::ClassificationType::MARKING:
424 OUString sKey = m_aKeyCreator.makeNumberedMarkingKey();
425 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName);
426 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
428 break;
430 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART:
432 OUString sKey = m_aKeyCreator.makeNumberedIntellectualPropertyPartKey();
433 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName);
434 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition);
436 break;
438 case svx::ClassificationType::PARAGRAPH:
440 nParagraph++;
441 pOutliner->Insert("");
443 SfxItemSetFixed<EE_ITEMS_START, EE_ITEMS_END> aItemSet(m_rDrawViewShell.GetDoc()->GetPool());
445 if (rResult.msName == "BOLD")
446 aItemSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT));
447 else
448 aItemSet.Put(SvxWeightItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT));
450 SvxNumRule aDefaultNumRule(SvxNumRuleFlags::NONE, 0, false);
451 aItemSet.Put(SvxNumBulletItem(std::move(aDefaultNumRule), EE_PARA_NUMBULLET));
453 pOutliner->SetParaAttribs(nParagraph, aItemSet);
455 break;
457 default:
458 break;
463 public:
464 ClassificationInserter(sd::DrawViewShell & rDrawViewShell, const css::uno::Reference<css::document::XDocumentProperties>& rDocProps)
465 : ClassificationCommon(rDrawViewShell, rDocProps)
469 void insert(std::vector<svx::ClassificationResult> const & rResults)
471 // Set to MASTER mode
472 EditMode eOldMode = m_rDrawViewShell.GetEditMode();
473 if (eOldMode != EditMode::MasterPage)
474 m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false);
476 // Scoped guard to revert the mode
477 comphelper::ScopeGuard const aGuard([this, eOldMode] () {
478 m_rDrawViewShell.ChangeEditMode(eOldMode, false);
481 // Delete the previous existing object - if exists
482 deleteExistingObjects();
484 // Clear properties
485 svx::classification::removeAllProperties(m_xPropertyContainer);
487 SfxClassificationHelper aHelper(m_xDocumentProperties);
489 // Apply properties from the BA policy
490 for (svx::ClassificationResult const & rResult : rResults)
492 if (rResult.meType == svx::ClassificationType::CATEGORY)
493 aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType());
496 // Insert full text as document property
497 svx::classification::insertFullTextualRepresentationAsDocumentProperty(m_xPropertyContainer, m_aKeyCreator, rResults);
499 // Create the outliner from the
500 Outliner* pOutliner = m_rDrawViewShell.GetDoc()->GetInternalOutliner();
501 OutlinerMode eOutlinerMode = pOutliner->GetOutlinerMode();
503 comphelper::ScopeGuard const aOutlinerGuard([pOutliner, eOutlinerMode] () {
504 pOutliner->Init(eOutlinerMode);
507 pOutliner->Init(OutlinerMode::TextObject);
509 // Fill the outliner with the text from classification result
510 fillTheOutliner(pOutliner, rResults);
512 // Calculate to outliner text size
513 pOutliner->UpdateFields();
514 pOutliner->SetUpdateLayout(true);
515 Size aTextSize(pOutliner->CalcTextSize());
516 pOutliner->SetUpdateLayout(false);
518 // Create objects, apply the outliner and add them (objects) to all master pages
519 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard);
521 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex)
523 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard);
524 if (!pMasterPage)
525 continue;
527 rtl::Reference<SdrRectObj> pObject = new SdrRectObj(
528 *m_rDrawViewShell.GetDoc(), // TTTT should be reference
529 SdrObjKind::Text);
530 pObject->SetMergedItem(makeSdrTextAutoGrowWidthItem(true));
531 pObject->SetOutlinerParaObject(pOutliner->CreateParaObject());
532 pMasterPage->InsertObject(pObject.get());
534 // Calculate position
535 ::tools::Rectangle aRectangle(Point(), pMasterPage->GetSize());
536 Point aPosition(aRectangle.Center().X(), aRectangle.Bottom());
538 aPosition.AdjustX( -(aTextSize.Width() / 2) );
539 aPosition.AdjustY( -(aTextSize.Height()) );
541 pObject->SetLogicRect(::tools::Rectangle(aPosition, aTextSize));
546 void lcl_convertStringArguments(sal_uInt16 nSlot, const std::unique_ptr<SfxItemSet>& pArgs)
548 const SfxPoolItem* pItem = nullptr;
550 if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LINE_WIDTH_ARG, false, &pItem))
552 double fValue = static_cast<const SvxDoubleItem*>(pItem)->GetValue();
553 // FIXME: different units...
554 int nPow = 100;
555 int nValue = fValue * nPow;
557 XLineWidthItem aItem(nValue);
558 pArgs->Put(aItem);
560 if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem))
562 const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem);
563 if (pJSON)
565 basegfx::BGradient aGradient = basegfx::BGradient::fromJSON(pJSON->GetValue());
566 XFillGradientItem aItem(aGradient);
567 pArgs->Put(aItem);
571 if (nSlot == SID_ATTR_FILL_COLOR)
573 // Merge the color parameters to the color itself.
574 const XFillColorItem* pColorItem = static_cast<const XFillColorItem*>(pArgs->GetItem(SID_ATTR_FILL_COLOR));
575 if (pColorItem)
577 XFillColorItem aColorItem(*pColorItem);
578 model::ComplexColor aComplexColor = aColorItem.getComplexColor();
580 if (pArgs->GetItemState(SID_ATTR_COLOR_THEME_INDEX, false, &pItem) == SfxItemState::SET)
582 auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
583 aComplexColor.setSchemeColor(model::convertToThemeColorType(pIntItem->GetValue()));
585 if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_MOD, false, &pItem) == SfxItemState::SET)
587 auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
588 aComplexColor.addTransformation({model::TransformationType::LumMod, pIntItem->GetValue()});
590 if (pArgs->GetItemState(SID_ATTR_COLOR_LUM_OFF, false, &pItem) == SfxItemState::SET)
592 auto pIntItem = static_cast<const SfxInt16Item*>(pItem);
593 aComplexColor.addTransformation({model::TransformationType::LumOff, pIntItem->GetValue()});
595 aColorItem.setComplexColor(aComplexColor);
596 pArgs->Put(aColorItem);
603 * SfxRequests for temporary actions
606 void DrawViewShell::FuTemporary(SfxRequest& rReq)
608 // during a native slide show nothing gets executed!
609 if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR))
610 return;
612 DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" );
613 if( !mpDrawView )
614 return;
616 CheckLineTo (rReq);
618 DeactivateCurrentFunction();
620 sal_uInt16 nSId = rReq.GetSlot();
622 switch ( nSId )
624 case SID_OUTLINE_TEXT_AUTOFIT:
626 SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager();
627 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
628 if( rMarkList.GetMarkCount() == 1 )
630 pUndoManager->EnterListAction("", "", 0, GetViewShellBase().GetViewShellId());
631 mpDrawView->BegUndo();
633 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj();
634 bool bSet = pObj->GetMergedItemSet().GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue() != drawing::TextFitToSizeType_NONE;
636 mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj));
638 if (!bSet)
640 //If we are turning on AutoFit we have to turn these off if already on
641 if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWHEIGHT)->GetValue())
642 pObj->SetMergedItem(makeSdrTextAutoGrowHeightItem(false));
643 if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWWIDTH)->GetValue())
644 pObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(false));
647 pObj->SetMergedItem(SdrTextFitToSizeTypeItem(bSet ? drawing::TextFitToSizeType_NONE : drawing::TextFitToSizeType_AUTOFIT));
649 mpDrawView->EndUndo();
650 pUndoManager->LeaveListAction();
652 Cancel();
653 rReq.Done();
655 break;
657 // area and line attributes: shall have
658 // an own Execute method (like StateMethode)
659 case SID_ATTR_FILL_STYLE:
660 case SID_ATTR_FILL_COLOR:
661 case SID_ATTR_FILL_GRADIENT:
662 case SID_ATTR_FILL_HATCH:
663 case SID_ATTR_FILL_BITMAP:
664 case SID_ATTR_FILL_SHADOW:
665 case SID_ATTR_SHADOW_COLOR:
666 case SID_ATTR_SHADOW_TRANSPARENCE:
667 case SID_ATTR_SHADOW_BLUR:
668 case SID_ATTR_SHADOW_XDISTANCE:
669 case SID_ATTR_SHADOW_YDISTANCE:
670 case SID_ATTR_FILL_USE_SLIDE_BACKGROUND:
671 case SID_ATTR_FILL_TRANSPARENCE:
672 case SID_ATTR_FILL_FLOATTRANSPARENCE:
674 case SID_ATTR_LINE_STYLE:
675 case SID_ATTR_LINE_DASH:
676 case SID_ATTR_LINE_WIDTH:
677 case SID_ATTR_LINE_COLOR:
678 case SID_ATTR_LINEEND_STYLE:
679 case SID_ATTR_LINE_START:
680 case SID_ATTR_LINE_END:
681 case SID_ATTR_LINE_TRANSPARENCE:
682 case SID_ATTR_LINE_JOINT:
683 case SID_ATTR_LINE_CAP:
685 case SID_ATTR_TEXT_FITTOSIZE:
687 if( rReq.GetArgs() )
689 std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone();
690 lcl_convertStringArguments(rReq.GetSlot(), pNewArgs);
691 mpDrawView->SetAttributes(*pNewArgs);
692 rReq.Done();
694 else
696 switch( rReq.GetSlot() )
698 case SID_ATTR_FILL_SHADOW:
699 case SID_ATTR_SHADOW_COLOR:
700 case SID_ATTR_SHADOW_TRANSPARENCE:
701 case SID_ATTR_SHADOW_BLUR:
702 case SID_ATTR_SHADOW_XDISTANCE:
703 case SID_ATTR_SHADOW_YDISTANCE:
704 case SID_ATTR_FILL_STYLE:
705 case SID_ATTR_FILL_COLOR:
706 case SID_ATTR_FILL_GRADIENT:
707 case SID_ATTR_FILL_HATCH:
708 case SID_ATTR_FILL_BITMAP:
709 case SID_ATTR_FILL_USE_SLIDE_BACKGROUND:
710 case SID_ATTR_FILL_TRANSPARENCE:
711 case SID_ATTR_FILL_FLOATTRANSPARENCE:
712 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SfxCallMode::ASYNCHRON );
713 break;
714 case SID_ATTR_LINE_STYLE:
715 case SID_ATTR_LINE_DASH:
716 case SID_ATTR_LINE_WIDTH:
717 case SID_ATTR_LINE_COLOR:
718 case SID_ATTR_LINE_TRANSPARENCE:
719 case SID_ATTR_LINE_JOINT:
720 case SID_ATTR_LINE_CAP:
721 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SfxCallMode::ASYNCHRON );
722 break;
723 case SID_ATTR_TEXT_FITTOSIZE:
724 GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SfxCallMode::ASYNCHRON );
725 break;
728 Cancel();
730 break;
732 case SID_HYPHENATION:
734 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_HYPHENATION);
736 if( pItem )
738 SfxItemSetFixed<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE> aSet( GetPool() );
739 bool bValue = pItem->GetValue();
740 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) );
741 mpDrawView->SetAttributes( aSet );
743 else // only for testing purpose
745 OSL_FAIL(" no value for hyphenation!");
746 SfxItemSetFixed<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE> aSet( GetPool() );
747 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, true ) );
748 mpDrawView->SetAttributes( aSet );
750 rReq.Done();
751 Cancel();
753 break;
755 case SID_INSERTPAGE:
756 case SID_INSERTPAGE_QUICK:
758 SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
759 Cancel();
760 if(HasCurrentFunction(SID_BEZIER_EDIT) )
761 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
762 if (pNewPage != nullptr)
763 SwitchPage((pNewPage->GetPageNum()-1)/2);
764 rReq.Done ();
766 break;
768 case SID_DUPLICATE_PAGE:
770 auto slideSorter = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase());
771 SdPage* pNewPage = nullptr;
772 if(slideSorter)
773 DuplicateSelectedSlides(rReq);
774 else
775 pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage());
776 Cancel();
777 if(HasCurrentFunction(SID_BEZIER_EDIT) )
778 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
779 if(!slideSorter && pNewPage != nullptr)
780 SwitchPage((pNewPage->GetPageNum()-1)/2);
781 rReq.Done();
783 break;
785 case SID_INSERT_MASTER_PAGE:
787 // Use the API to create a new page.
788 Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier (
789 GetDoc()->getUnoModel(), UNO_QUERY);
790 if (xMasterPagesSupplier.is())
792 Reference<drawing::XDrawPages> xMasterPages (
793 xMasterPagesSupplier->getMasterPages());
794 if (xMasterPages.is())
796 sal_uInt16 nIndex = GetCurPagePos() + 1;
797 xMasterPages->insertNewByIndex (nIndex);
799 // Create shapes for the default layout.
800 SdPage* pMasterPage = GetDoc()->GetMasterSdPage(
801 nIndex, PageKind::Standard);
802 pMasterPage->CreateTitleAndLayout (true,true);
806 Cancel();
807 if(HasCurrentFunction(SID_BEZIER_EDIT))
808 GetViewFrame()->GetDispatcher()->Execute(
809 SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
810 rReq.Done ();
812 break;
814 case SID_MODIFYPAGE:
816 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes ||
817 (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage) )
819 if ( mpDrawView->IsTextEdit() )
821 mpDrawView->SdrEndTextEdit();
823 sal_uInt16 nPage = maTabControl->GetCurPagePos();
824 mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind);
825 ::sd::ViewShell::mpImpl->ProcessModifyPageSlot (
826 rReq,
827 mpActualPage,
828 mePageKind);
831 Cancel();
832 rReq.Done ();
834 break;
836 case SID_ASSIGN_LAYOUT:
838 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes || (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage))
840 if ( mpDrawView->IsTextEdit() )
841 mpDrawView->SdrEndTextEdit();
843 ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind);
845 Cancel();
846 rReq.Done ();
848 break;
850 case SID_RENAMEPAGE:
851 case SID_RENAME_MASTER_PAGE:
853 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes )
855 if ( mpDrawView->IsTextEdit() )
857 mpDrawView->SdrEndTextEdit();
860 sal_uInt16 nPage = maTabControl->GetCurPagePos();
861 SdPage* pCurrentPage = ( GetEditMode() == EditMode::Page )
862 ? GetDoc()->GetSdPage( nPage, GetPageKind() )
863 : GetDoc()->GetMasterSdPage( nPage, GetPageKind() );
865 OUString aTitle = SdResId(STR_TITLE_RENAMESLIDE);
866 OUString aDescr = SdResId(STR_DESC_RENAMESLIDE);
867 const OUString& aPageName = pCurrentPage->GetName();
869 if(rReq.GetArgs())
871 OUString aName = rReq.GetArgs()->GetItem<const SfxStringItem>(SID_RENAMEPAGE)->GetValue();
873 bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aName );
874 DBG_ASSERT( bResult, "Couldn't rename slide" );
876 else
878 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
879 ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aPageName, aDescr));
880 aNameDlg->SetText( aTitle );
881 aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true );
882 aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE );
884 if( aNameDlg->Execute() == RET_OK )
886 OUString aNewName;
887 aNameDlg->GetName( aNewName );
888 if (aNewName != aPageName)
890 bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aNewName );
891 DBG_ASSERT( bResult, "Couldn't rename slide" );
896 Cancel();
897 rReq.Ignore();
899 break;
901 case SID_RENAMEPAGE_QUICK:
903 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes )
905 if ( mpDrawView->IsTextEdit() )
907 mpDrawView->SdrEndTextEdit();
910 maTabControl->StartEditMode( maTabControl->GetCurPageId() );
913 Cancel();
914 rReq.Ignore ();
916 break;
918 case SID_PAGESIZE : // either this (no menu entries or something else!)
920 const SfxItemSet *pArgs = rReq.GetArgs ();
922 if (pArgs && pArgs->Count () == 3)
924 const SfxUInt32Item* pWidth = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEWIDTH);
925 const SfxUInt32Item* pHeight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEHEIGHT);
926 const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS);
928 Size aSize (pWidth->GetValue (), pHeight->GetValue ());
930 SetupPage (aSize, 0, 0, 0, 0, true, false, pScaleAll->GetValue ());
931 rReq.Ignore ();
932 break;
934 #if HAVE_FEATURE_SCRIPTING
935 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS);
936 #endif
937 rReq.Ignore ();
938 break;
941 case SID_PAGEMARGIN : // or this (no menu entries or something else!)
943 const SfxItemSet *pArgs = rReq.GetArgs ();
945 if (pArgs && pArgs->Count () == 5)
947 const SfxUInt32Item* pLeft = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGELEFT);
948 const SfxUInt32Item* pRight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGERIGHT);
949 const SfxUInt32Item* pUpper = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGETOP);
950 const SfxUInt32Item* pLower = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEBOTTOM);
951 const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS);
953 Size aEmptySize (0, 0);
955 SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (),
956 pUpper->GetValue (), pLower->GetValue (),
957 false, true, pScaleAll->GetValue ());
958 rReq.Ignore ();
959 break;
961 #if HAVE_FEATURE_SCRIPTING
962 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS);
963 #endif
964 rReq.Ignore ();
965 break;
968 case SID_ATTR_ZOOMSLIDER:
970 const SfxItemSet* pArgs = rReq.GetArgs();
972 const SfxUInt16Item* pScale = (pArgs && pArgs->Count () == 1) ?
973 rReq.GetArg(SID_ATTR_ZOOMSLIDER) : nullptr;
974 if (pScale && CHECK_RANGE (5, pScale->GetValue (), 3000))
976 SetZoom (pScale->GetValue ());
978 SfxBindings& rBindings = GetViewFrame()->GetBindings();
979 rBindings.Invalidate( SID_ATTR_ZOOM );
980 rBindings.Invalidate( SID_ZOOM_IN );
981 rBindings.Invalidate( SID_ZOOM_OUT );
982 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER );
986 Cancel();
987 rReq.Done ();
988 break;
991 case SID_ATTR_ZOOM:
993 const SfxItemSet* pArgs = rReq.GetArgs();
994 mbZoomOnPage = false;
996 if ( pArgs )
998 SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOM ).GetType();
999 switch( eZT )
1001 case SvxZoomType::PERCENT:
1002 SetZoom( static_cast<::tools::Long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) );
1003 break;
1005 case SvxZoomType::OPTIMAL:
1006 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL,
1007 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
1008 break;
1010 case SvxZoomType::PAGEWIDTH:
1011 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH,
1012 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
1013 break;
1015 case SvxZoomType::WHOLEPAGE:
1016 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE,
1017 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD );
1018 break;
1019 case SvxZoomType::PAGEWIDTH_NOBORDER:
1020 OSL_FAIL("sd::DrawViewShell::FuTemporary(), SvxZoomType::PAGEWIDTH_NOBORDER not handled!" );
1021 break;
1023 rReq.Ignore ();
1025 else
1027 // open zoom dialog
1028 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1030 Cancel();
1032 break;
1034 case SID_CHANGEBEZIER:
1035 case SID_CHANGEPOLYGON:
1036 if ( mpDrawView->IsTextEdit() )
1038 mpDrawView->SdrEndTextEdit();
1039 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
1042 if ( mpDrawView->IsPresObjSelected() )
1044 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1045 VclMessageType::Info, VclButtonsType::Ok,
1046 SdResId(STR_ACTION_NOTPOSSIBLE)));
1047 xInfoBox->run();
1049 else
1051 if( rReq.GetSlot() == SID_CHANGEBEZIER )
1053 weld::WaitObject aWait(GetFrameWeld());
1054 mpDrawView->ConvertMarkedToPathObj(false);
1056 else
1058 if( mpDrawView->IsVectorizeAllowed() )
1060 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1062 else
1064 weld::WaitObject aWait(GetFrameWeld());
1065 mpDrawView->ConvertMarkedToPolyObj();
1069 Invalidate(SID_CHANGEBEZIER);
1070 Invalidate(SID_CHANGEPOLYGON);
1072 Cancel();
1074 if( HasCurrentFunction(SID_BEZIER_EDIT) )
1075 { // where applicable, activate right edit action
1076 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT,
1077 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
1079 rReq.Ignore ();
1080 break;
1082 case SID_CONVERT_TO_CONTOUR:
1083 if ( mpDrawView->IsTextEdit() )
1085 mpDrawView->SdrEndTextEdit();
1086 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
1089 if ( mpDrawView->IsPresObjSelected() )
1091 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1092 VclMessageType::Info, VclButtonsType::Ok,
1093 SdResId(STR_ACTION_NOTPOSSIBLE)));
1094 xInfoBox->run();
1096 else
1098 weld::WaitObject aWait(GetFrameWeld());
1099 mpDrawView->ConvertMarkedToPathObj(true);
1101 Invalidate(SID_CONVERT_TO_CONTOUR);
1103 Cancel();
1105 rReq.Ignore ();
1106 break;
1108 case SID_CONVERT_TO_METAFILE:
1109 case SID_CONVERT_TO_BITMAP:
1111 // End text edit mode when it is active because the metafile or
1112 // bitmap that will be created does not support it.
1113 if ( mpDrawView->IsTextEdit() )
1115 mpDrawView->SdrEndTextEdit();
1116 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
1119 if ( mpDrawView->IsPresObjSelected(true,true,true) )
1121 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1122 VclMessageType::Info, VclButtonsType::Ok,
1123 SdResId(STR_ACTION_NOTPOSSIBLE)));
1124 xInfoBox->run();
1126 else
1128 weld::WaitObject aWait(GetFrameWeld());
1130 // create SdrGrafObj from metafile/bitmap
1131 Graphic aGraphic;
1132 switch (nSId)
1134 case SID_CONVERT_TO_METAFILE:
1136 // switch on undo for the next operations
1137 mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_METAFILE));
1138 GDIMetaFile aMetaFile(mpDrawView->GetMarkedObjMetaFile());
1139 aGraphic = Graphic(aMetaFile);
1141 break;
1142 case SID_CONVERT_TO_BITMAP:
1144 // Disable spelling during conversion
1145 bool bOnlineSpell = GetDoc()->GetOnlineSpell();
1146 GetDoc()->SetOnlineSpell(false);
1148 // switch on undo for the next operations
1149 mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_BITMAP));
1150 bool bDone(false);
1152 // I have to get the image here directly since GetMarkedObjBitmapEx works
1153 // based on Bitmaps, but not on BitmapEx, thus throwing away the alpha
1154 // channel. Argh! GetMarkedObjBitmapEx itself is too widely used to safely
1155 // change that, e.g. in the exchange formats. For now I can only add this
1156 // exception to get good results for Svgs. This is how the code gets more
1157 // and more crowded, at last I made a remark for myself to change this
1158 // as one of the next tasks.
1159 if(1 == mpDrawView->GetMarkedObjectCount())
1161 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0));
1163 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData())
1165 aGraphic = Graphic(pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement());
1166 bDone = true;
1170 if(!bDone)
1172 aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx());
1174 // Restore online spelling
1175 GetDoc()->SetOnlineSpell(bOnlineSpell);
1177 break;
1180 // create new object
1181 rtl::Reference<SdrGrafObj> pGraphicObj = new SdrGrafObj(
1182 *GetDoc(),
1183 aGraphic);
1185 // get some necessary info and ensure it
1186 const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList());
1187 const size_t nMarkCount(rMarkList.GetMarkCount());
1188 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1189 OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)");
1190 OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)");
1192 // fit rectangle of new graphic object to selection's mark rect
1193 ::tools::Rectangle aAllMarkedRect;
1194 rMarkList.TakeBoundRect(pPageView, aAllMarkedRect);
1195 pGraphicObj->SetLogicRect(aAllMarkedRect);
1197 // #i71540# to keep the order, it is necessary to replace the lowest object
1198 // of the selection with the new object. This also means that with multi
1199 // selection, all other objects need to be deleted first
1200 SdrMark* pFirstMark = rMarkList.GetMark(0);
1201 SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj();
1203 if(nMarkCount > 1)
1205 // take first object out of selection
1206 mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true);
1208 // clear remaining selection
1209 mpDrawView->DeleteMarkedObj();
1212 // #i124816# copy layer from lowest object which gets replaced
1213 pGraphicObj->SetLayer(pReplacementCandidate->GetLayer());
1215 // now replace lowest object with new one
1216 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj.get());
1218 // switch off undo
1219 mpDrawView->EndUndo();
1223 Cancel();
1225 rReq.Done ();
1226 break;
1228 case SID_REMOVE_HYPERLINK:
1230 if (mpDrawView->IsTextEdit())
1232 // First make sure the field is selected
1233 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
1234 if (pOutView)
1236 pOutView->SelectFieldAtCursor();
1237 URLFieldHelper::RemoveURLField(pOutView->GetEditView());
1241 Cancel();
1242 rReq.Done ();
1243 break;
1245 case SID_SET_DEFAULT:
1247 std::optional<SfxItemSet> pSet;
1249 if (mpDrawView->IsTextEdit())
1251 pSet.emplace( GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END> );
1252 mpDrawView->SetAttributes( *pSet, true );
1254 else
1256 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1257 const size_t nCount = rMarkList.GetMarkCount();
1259 // For every presentation object a SfxItemSet of hard attributes
1260 // and the UserCall is stored in this list. This is because
1261 // at the following mpDrawView->SetAttributes( *pSet, sal_True )
1262 // they get lost and have to be restored.
1263 std::vector<std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> > aAttrList;
1264 SdPage* pPresPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() );
1266 for ( size_t i = 0; i < nCount; ++i )
1268 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1270 if( pPresPage->IsPresObj( pObj ) )
1272 auto pNewSet = std::make_unique<SfxItemSetFixed<SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT>>( GetDoc()->GetPool() );
1273 pNewSet->Put(pObj->GetMergedItemSet());
1274 aAttrList.emplace_back(std::move(pNewSet), pObj->GetUserCall());
1278 pSet.emplace( GetPool() );
1279 mpDrawView->SetAttributes( *pSet, true );
1281 sal_uLong j = 0;
1283 for ( size_t i = 0; i < nCount; ++i )
1285 SfxStyleSheet* pSheet = nullptr;
1286 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj();
1288 if (pObj->GetObjIdentifier() == SdrObjKind::TitleText)
1290 pSheet = mpActualPage->GetStyleSheetForPresObj(PresObjKind::Title);
1291 if (pSheet)
1292 pObj->SetStyleSheet(pSheet, false);
1294 else if(pObj->GetObjIdentifier() == SdrObjKind::OutlineText)
1296 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++)
1298 pSheet = mpActualPage->GetStyleSheetForPresObj( PresObjKind::Outline );
1299 DBG_ASSERT(pSheet, "Template for outline object not found");
1300 if (pSheet)
1302 pObj->StartListening(*pSheet);
1304 if( nLevel == 1 )
1305 // text frame listens on StyleSheet of level1
1306 pObj->NbcSetStyleSheet(pSheet, false);
1311 if( pPresPage->IsPresObj( pObj ) )
1313 std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> &rAttr = aAttrList[j++];
1315 std::unique_ptr<SfxItemSet> & pNewSet(rAttr.first);
1316 SdrObjUserCall* pUserCall = rAttr.second;
1318 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SfxItemState::SET )
1320 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT));
1323 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SfxItemState::SET )
1325 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT));
1328 if( pUserCall )
1329 pObj->SetUserCall( pUserCall );
1334 pSet.reset();
1335 Cancel();
1337 break;
1339 case SID_DELETE_SNAPITEM:
1341 SdrPageView* pPV;
1342 Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos );
1343 sal_uInt16 nHitLog = static_cast<sal_uInt16>(GetActiveWindow()->PixelToLogic( Size(
1344 FuPoor::HITPIX, 0 ) ).Width());
1345 sal_uInt16 nHelpLine;
1347 if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow()->GetOutDev(), nHelpLine, pPV) )
1349 pPV->DeleteHelpLine( nHelpLine );
1351 Cancel();
1352 rReq.Ignore ();
1354 break;
1356 case SID_DELETE_PAGE:
1357 case SID_DELETE_MASTER_PAGE:
1358 DeleteActualPage();
1359 Cancel();
1360 rReq.Ignore ();
1361 break;
1363 case SID_DELETE_LAYER:
1364 DeleteActualLayer();
1365 Cancel();
1366 rReq.Ignore ();
1367 break;
1369 case SID_ORIGINAL_SIZE:
1370 mpDrawView->SetMarkedOriginalSize();
1371 Cancel();
1372 rReq.Done();
1373 break;
1375 case SID_DRAW_FONTWORK:
1376 case SID_DRAW_FONTWORK_VERTICAL:
1378 svx::FontworkBar::execute(*mpView, rReq, GetViewFrame()->GetBindings()); // SJ: can be removed (I think)
1379 Cancel();
1380 rReq.Done();
1382 break;
1384 case SID_SAVE_GRAPHIC:
1386 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1387 if( rMarkList.GetMarkCount() == 1 )
1389 const SdrGrafObj* pObj = dynamic_cast<const SdrGrafObj*>(rMarkList.GetMark(0)->GetMarkedSdrObj());
1390 if (pObj && pObj->GetGraphicType() == GraphicType::Bitmap)
1392 weld::Window* pFrame = GetFrameWeld();
1393 GraphicAttr aGraphicAttr = pObj->GetGraphicAttr();
1394 short nState = RET_CANCEL;
1395 if (aGraphicAttr != GraphicAttr()) // the image has been modified
1397 if (pFrame)
1399 nState = GraphicHelper::HasToSaveTransformedImage(pFrame);
1402 else
1404 nState = RET_NO;
1407 if (nState == RET_YES)
1409 GraphicHelper::ExportGraphic(pFrame, pObj->GetTransformedGraphic(), "");
1411 else if (nState == RET_NO)
1413 const GraphicObject& aGraphicObject(pObj->GetGraphicObject());
1414 GraphicHelper::ExportGraphic(pFrame, aGraphicObject.GetGraphic(), "");
1418 Cancel();
1419 rReq.Ignore();
1421 break;
1423 case SID_EXTERNAL_EDIT:
1425 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1426 if( rMarkList.GetMarkCount() == 1 )
1428 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1429 if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj ) )
1430 if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap )
1432 GraphicObject aGraphicObject( pGraphicObj->GetGraphicObject() );
1433 m_ExternalEdits.push_back(
1434 std::make_unique<SdrExternalToolEdit>(
1435 mpDrawView.get(), pGraphicObj));
1436 m_ExternalEdits.back()->Edit( &aGraphicObject );
1439 Cancel();
1440 rReq.Ignore();
1442 break;
1444 case SID_COMPRESS_GRAPHIC:
1446 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
1447 if( rMarkList.GetMarkCount() == 1 )
1449 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
1451 if( auto pGraphicObj = dynamic_cast<SdrGrafObj*>( pObj ) )
1452 if( pGraphicObj->GetGraphicType() == GraphicType::Bitmap )
1454 CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() );
1455 if (dialog.run() == RET_OK)
1457 rtl::Reference<SdrGrafObj> pNewObject = dialog.GetCompressedSdrGrafObj();
1458 SdrPageView* pPageView = mpDrawView->GetSdrPageView();
1459 OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress";
1460 mpDrawView->BegUndo( aUndoString );
1461 mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject.get() );
1462 mpDrawView->EndUndo();
1466 Cancel();
1467 rReq.Ignore();
1469 break;
1471 case SID_GRAPHIC_SIZE_CHECK:
1473 sd::GraphicSizeCheckGUIResult aResult(GetDoc());
1474 svx::GenericCheckDialog aDialog(GetFrameWeld(), aResult);
1475 aDialog.run();
1477 Cancel();
1478 rReq.Ignore();
1480 break;
1482 case SID_ATTRIBUTES_LINE: // BASIC
1484 SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1485 if (rReq.GetArgs())
1486 Cancel();
1488 break;
1490 case SID_ATTRIBUTES_AREA: // BASIC
1492 SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1493 if (rReq.GetArgs())
1494 Cancel();
1496 break;
1498 case SID_ATTR_TRANSFORM:
1500 SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1501 // tdf#138963 conditions tested for here must be the same as those
1502 // of the early returns from FuTransform::DoExecute
1503 if (rReq.GetArgs() || !mpDrawView->AreObjectsMarked())
1505 Invalidate(SID_RULER_OBJECT);
1506 Cancel();
1509 break;
1510 case SID_MOVE_SHAPE_HANDLE:
1512 const SfxItemSet *pArgs = rReq.GetArgs ();
1513 if (pArgs && pArgs->Count () >= 3)
1515 const SfxUInt32Item* handleNumItem = rReq.GetArg<SfxUInt32Item>(FN_PARAM_1);
1516 const SfxUInt32Item* newPosXTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2);
1517 const SfxUInt32Item* newPosYTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_3);
1518 const SfxInt32Item* OrdNum = rReq.GetArg<SfxInt32Item>(FN_PARAM_4);
1520 const sal_uLong handleNum = handleNumItem->GetValue();
1521 const sal_uLong newPosX = convertTwipToMm100(newPosXTwips->GetValue());
1522 const sal_uLong newPosY = convertTwipToMm100(newPosYTwips->GetValue());
1524 mpDrawView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), OrdNum ? OrdNum->GetValue() : -1);
1525 Cancel();
1527 break;
1529 case SID_CHAR_DLG_EFFECT:
1530 case SID_CHAR_DLG: // BASIC
1532 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1533 Cancel();
1535 break;
1537 case SID_PARA_DLG:
1539 SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1540 Cancel();
1542 break;
1544 case FN_NUM_BULLET_ON:
1546 // The value (sal_uInt16)0xFFFF means set bullet on/off.
1547 SfxUInt16Item aItem(FN_SVX_SET_BULLET, sal_uInt16(0xFFFF));
1548 GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_BULLET,
1549 SfxCallMode::RECORD, { &aItem });
1551 break;
1553 case FN_NUM_NUMBERING_ON:
1555 // The value (sal_uInt16)0xFFFF means set bullet on/off.
1556 SfxUInt16Item aItem(FN_SVX_SET_NUMBER, sal_uInt16(0xFFFF));
1557 GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_NUMBER,
1558 SfxCallMode::RECORD, { &aItem });
1560 break;
1562 case SID_OUTLINE_BULLET:
1563 case FN_SVX_SET_BULLET:
1564 case FN_SVX_SET_NUMBER:
1566 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1567 Cancel();
1569 break;
1571 case FN_INSERT_SOFT_HYPHEN:
1572 case FN_INSERT_HARDHYPHEN:
1573 case FN_INSERT_HARD_SPACE:
1574 case FN_INSERT_NNBSP:
1575 case SID_INSERT_RLM :
1576 case SID_INSERT_LRM :
1577 case SID_INSERT_WJ :
1578 case SID_INSERT_ZWSP:
1579 case SID_CHARMAP:
1581 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1582 Cancel();
1584 break;
1586 case SID_PRESENTATION_LAYOUT:
1588 SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
1589 Cancel();
1591 break;
1593 case SID_PASTE_SPECIAL:
1595 SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1596 Cancel();
1597 rReq.Ignore ();
1599 break;
1601 case SID_CHANGE_PICTURE:
1602 case SID_INSERT_GRAPHIC:
1604 SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq,
1605 nSId == SID_CHANGE_PICTURE ) );
1606 Cancel();
1607 rReq.Ignore ();
1609 break;
1611 case SID_INSERT_AVMEDIA:
1613 SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1615 Cancel();
1616 rReq.Ignore ();
1618 break;
1620 case SID_INSERT_OBJECT:
1621 case SID_INSERT_FLOATINGFRAME:
1622 case SID_INSERT_MATH:
1623 case SID_INSERT_DIAGRAM:
1624 case SID_ATTR_TABLE:
1626 SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1627 // Set the selection tool as the old one. This in particular important for the
1628 // zoom function, in which clicking without dragging zooms as well, and that
1629 // makes exiting the object editing mode impossible.
1630 if (dynamic_cast<FuSelection*>( GetOldFunction().get() ) == nullptr)
1631 SetOldFunction( FuSelection::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1632 Cancel();
1633 rReq.Ignore ();
1635 break;
1636 case SID_CLASSIFICATION_APPLY:
1638 const SfxItemSet* pArgs = rReq.GetArgs();
1639 const SfxPoolItem* pItem = nullptr;
1640 if (pArgs && pArgs->GetItemState(nSId, false, &pItem) == SfxItemState::SET)
1642 const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue();
1643 auto eType = SfxClassificationPolicyType::IntellectualProperty;
1644 if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET)
1646 const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue();
1647 eType = SfxClassificationHelper::stringToPolicyType(rType);
1649 if (SfxViewFrame* pViewFrame = GetViewFrame())
1651 if (SfxObjectShell* pObjectShell = pViewFrame->GetObjectShell())
1653 SfxClassificationHelper aHelper(pObjectShell->getDocProperties());
1654 aHelper.SetBACName(rName, eType);
1658 else
1659 SAL_WARN("sd.ui", "missing parameter for SID_CLASSIFICATION_APPLY");
1661 Cancel();
1662 rReq.Ignore();
1664 break;
1666 case SID_CLASSIFICATION_DIALOG:
1668 if (SfxObjectShell* pObjShell = SfxObjectShell::Current())
1670 css::uno::Reference<css::document::XDocumentProperties> xDocProps(pObjShell->getDocProperties());
1671 auto xDialog = std::make_shared<svx::ClassificationDialog>(GetFrameWeld(), xDocProps, false, [](){} );
1672 ClassificationCollector aCollector(*this, xDocProps);
1673 aCollector.collect();
1675 xDialog->setupValues(std::vector(aCollector.getResults()));
1677 if (RET_OK == xDialog->run())
1679 ClassificationInserter aInserter(*this, xDocProps);
1680 aInserter.insert(xDialog->getResult());
1682 xDialog.reset();
1685 Cancel();
1686 rReq.Ignore();
1688 break;
1690 case SID_COPYOBJECTS:
1692 if ( mpDrawView->IsPresObjSelected(false) )
1694 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1695 VclMessageType::Info, VclButtonsType::Ok,
1696 SdResId(STR_ACTION_NOTPOSSIBLE)));
1697 xInfoBox->run();
1699 else
1701 if ( mpDrawView->IsTextEdit() )
1703 mpDrawView->SdrEndTextEdit();
1706 SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1708 Cancel();
1709 rReq.Ignore ();
1711 break;
1713 case SID_INSERTFILE: // BASIC
1715 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START));
1716 SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1717 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END));
1718 Cancel();
1719 rReq.Done ();
1721 break;
1723 case SID_SELECT_BACKGROUND:
1724 case SID_SAVE_BACKGROUND:
1725 case SID_ATTR_PAGE_SIZE:
1726 case SID_ATTR_PAGE:
1727 case SID_PAGESETUP: // BASIC ??
1729 SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1730 Cancel();
1731 rReq.Ignore (); // we generate independent macros !!
1733 break;
1735 case SID_BEFORE_OBJ:
1736 case SID_BEHIND_OBJ:
1738 SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
1739 rReq.Done();
1740 // finishes itself, no Cancel() needed!
1742 break;
1744 case SID_REVERSE_ORDER: // BASIC
1746 mpDrawView->ReverseOrderOfMarked();
1747 Cancel();
1748 rReq.Done ();
1750 break;
1752 case SID_ANIMATION_EFFECTS:
1754 SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
1755 Cancel();
1757 break;
1759 case SID_EXECUTE_ANIMATION_EFFECT:
1761 SetCurrentFunction(FuExecuteInteraction::Create(this, GetActiveWindow(),
1762 mpDrawView.get(), GetDoc(), rReq));
1763 Cancel();
1765 break;
1767 case SID_LINEEND_POLYGON:
1769 SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1770 Cancel();
1772 break;
1774 case SID_CAPTUREPOINT:
1775 // negative value to signal call from menu
1776 maMousePos = Point(-1,-1);
1777 [[fallthrough]];
1778 case SID_SET_SNAPITEM:
1780 SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) );
1781 Cancel();
1783 break;
1785 case SID_MANAGE_LINKS:
1787 SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1788 Cancel();
1789 rReq.Ignore ();
1791 break;
1793 case SID_THESAURUS:
1795 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1796 Cancel();
1797 rReq.Ignore ();
1799 break;
1801 case SID_TEXTATTR_DLG:
1803 if (mpDrawView->IsTextEdit())
1804 mpDrawView->SdrEndTextEdit();
1805 SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1806 Cancel();
1807 rReq.Ignore ();
1809 break;
1811 case SID_MEASURE_DLG:
1813 SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1814 Cancel();
1815 rReq.Ignore ();
1817 break;
1819 case SID_CONNECTION_DLG:
1821 SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1822 Cancel();
1823 rReq.Done();
1825 break;
1827 case SID_CONNECTION_NEW_ROUTING:
1829 SfxItemSetFixed<SDRATTR_EDGELINE1DELTA, SDRATTR_EDGELINE3DELTA> aDefAttr( GetPool() );
1830 GetView()->SetAttributes( aDefAttr, true ); // (ReplaceAll)
1832 Cancel();
1833 rReq.Done();
1835 break;
1837 case SID_TWAIN_SELECT:
1839 if( mxScannerManager.is() )
1843 const css::uno::Sequence< css::scanner::ScannerContext >
1844 aContexts( mxScannerManager->getAvailableScanners() );
1846 if( aContexts.hasElements() )
1848 css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] );
1850 Reference<lang::XInitialization> xInit(mxScannerManager, UNO_QUERY);
1851 if (xInit.is())
1853 // initialize dialog
1854 weld::Window* pWindow = rReq.GetFrameWeld();
1855 uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence(
1857 {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference<awt::XWindow>())}
1858 }));
1859 xInit->initialize( aSeq );
1862 mxScannerManager->configureScannerAndScan( aContext, mxScannerListener );
1865 catch(...)
1870 Cancel();
1871 rReq.Done();
1873 break;
1875 case SID_TWAIN_TRANSFER:
1877 bool bDone = false;
1879 if( mxScannerManager.is() )
1883 const css::uno::Sequence< css::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() );
1885 if( aContexts.hasElements() )
1887 mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener );
1888 bDone = true;
1891 catch( ... )
1896 if( !bDone )
1898 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
1899 VclMessageType::Info, VclButtonsType::Ok,
1900 #ifndef UNX
1901 SdResId(STR_TWAIN_NO_SOURCE)
1902 #else
1903 SdResId(STR_TWAIN_NO_SOURCE_UNX)
1904 #endif
1906 xInfoBox->run();
1909 else
1911 SfxBindings& rBindings = GetViewFrame()->GetBindings();
1912 rBindings.Invalidate( SID_TWAIN_SELECT );
1913 rBindings.Invalidate( SID_TWAIN_TRANSFER );
1916 Cancel();
1917 rReq.Done();
1919 break;
1921 case SID_POLYGON_MORPHING:
1923 SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
1924 Cancel();
1926 break;
1928 case SID_INSERTLAYER:
1930 if ( mpDrawView->IsTextEdit() )
1932 mpDrawView->SdrEndTextEdit();
1935 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
1936 sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount();
1937 sal_uInt16 nLayer = nLayerCnt - 2 + 1;
1938 OUString aLayerName = SdResId(STR_LAYER) + OUString::number(nLayer);
1939 OUString aLayerTitle, aLayerDesc;
1940 bool bIsVisible = false;
1941 bool bIsLocked = false;
1942 bool bIsPrintable = false;
1944 const SfxItemSet* pArgs = rReq.GetArgs();
1946 if (! pArgs)
1948 SfxItemSetFixed<ATTR_LAYER_START, ATTR_LAYER_END> aNewAttr( GetDoc()->GetPool() );
1950 aNewAttr.Put( makeSdAttrLayerName( aLayerName ) );
1951 aNewAttr.Put( makeSdAttrLayerTitle() );
1952 aNewAttr.Put( makeSdAttrLayerDesc() );
1953 aNewAttr.Put( makeSdAttrLayerVisible() );
1954 aNewAttr.Put( makeSdAttrLayerPrintable() );
1955 aNewAttr.Put( makeSdAttrLayerLocked() );
1956 aNewAttr.Put( makeSdAttrLayerThisPage() );
1958 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
1959 vcl::Window* pWin = GetActiveWindow();
1960 ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, true, SdResId(STR_INSERTLAYER)) );
1961 pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() );
1963 // test for already existing names
1964 bool bLoop = true;
1965 while( bLoop && pDlg->Execute() == RET_OK )
1967 pDlg->GetAttr( aNewAttr );
1968 aLayerName = aNewAttr.Get(ATTR_LAYER_NAME).GetValue ();
1970 if( rLayerAdmin.GetLayer( aLayerName )
1971 || aLayerName.isEmpty()
1972 || LayerTabBar::IsLocalizedNameOfStandardLayer( aLayerName) )
1974 // name already exists
1975 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(),
1976 VclMessageType::Warning, VclButtonsType::Ok,
1977 SdResId(STR_WARN_NAME_DUPLICATE)));
1978 xWarn->run();
1980 else
1981 bLoop = false;
1983 if( bLoop ) // was canceled
1985 pDlg.disposeAndClear();
1986 Cancel();
1987 rReq.Ignore ();
1988 break;
1990 else
1992 aLayerTitle = aNewAttr.Get(ATTR_LAYER_TITLE).GetValue();
1993 aLayerDesc = aNewAttr.Get(ATTR_LAYER_DESC).GetValue ();
1994 bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
1995 bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ;
1996 bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ;
1999 else if (pArgs->Count () != 4)
2001 #if HAVE_FEATURE_SCRIPTING
2002 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS);
2003 #endif
2004 Cancel();
2005 rReq.Ignore ();
2006 break;
2008 else
2010 const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME);
2011 const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE);
2012 const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED);
2013 const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE);
2015 aLayerName = pLayerName->GetValue ();
2016 bIsVisible = pIsVisible->GetValue ();
2017 bIsLocked = pIsLocked->GetValue ();
2018 bIsPrintable = pIsPrintable->GetValue ();
2021 OUString aPrevLayer = mpDrawView->GetActiveLayer();
2022 SdrLayer* pLayer;
2023 sal_uInt16 nPrevLayer = 0;
2024 nLayerCnt = rLayerAdmin.GetLayerCount();
2026 for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ )
2028 pLayer = rLayerAdmin.GetLayer(nLayer);
2029 OUString aName = pLayer->GetName();
2031 if ( aPrevLayer == aName )
2033 nPrevLayer = std::max(nLayer, sal_uInt16(4));
2037 mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1);
2038 pLayer = rLayerAdmin.GetLayer(aLayerName);
2039 if( pLayer )
2041 pLayer->SetTitle( aLayerTitle );
2042 pLayer->SetDescription( aLayerDesc );
2045 mpDrawView->SetLayerVisible( aLayerName, bIsVisible );
2046 mpDrawView->SetLayerLocked( aLayerName, bIsLocked);
2047 mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable);
2049 mpDrawView->SetActiveLayer(aLayerName);
2051 ResetActualLayer();
2053 GetDoc()->SetChanged();
2055 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER,
2056 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD);
2058 Cancel();
2059 rReq.Done ();
2061 break;
2063 case SID_MODIFYLAYER:
2065 if(!GetLayerTabControl()) // #i87182#
2067 OSL_ENSURE(false, "No LayerTabBar (!)");
2068 Cancel();
2069 rReq.Ignore();
2070 break;
2073 if ( mpDrawView->IsTextEdit() )
2075 mpDrawView->SdrEndTextEdit();
2078 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
2079 sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId();
2080 OUString aLayerName = GetLayerTabControl()->GetLayerName(nCurPage);
2081 SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName);
2083 OUString aLayerTitle = pLayer->GetTitle();
2084 OUString aLayerDesc = pLayer->GetDescription();
2086 OUString aOldLayerName(aLayerName);
2087 OUString aOldLayerTitle(aLayerTitle);
2088 OUString aOldLayerDesc(aLayerDesc);
2090 bool bIsVisible, bIsLocked, bIsPrintable;
2091 bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName);
2092 bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName);
2093 bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName);
2095 const SfxItemSet* pArgs = rReq.GetArgs();
2096 // is it allowed to delete the layer?
2097 bool bDelete = !( LayerTabBar::IsRealNameOfStandardLayer(aLayerName) );
2099 if (! pArgs)
2101 SfxItemSetFixed<ATTR_LAYER_START, ATTR_LAYER_END> aNewAttr( GetDoc()->GetPool() );
2103 aNewAttr.Put( makeSdAttrLayerName( aLayerName ) );
2104 aNewAttr.Put( makeSdAttrLayerTitle( aLayerTitle ) );
2105 aNewAttr.Put( makeSdAttrLayerDesc( aLayerDesc ) );
2106 aNewAttr.Put( makeSdAttrLayerVisible( bIsVisible ) );
2107 aNewAttr.Put( makeSdAttrLayerLocked( bIsLocked ) );
2108 aNewAttr.Put( makeSdAttrLayerPrintable( bIsPrintable ) );
2109 aNewAttr.Put( makeSdAttrLayerThisPage() );
2111 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
2112 vcl::Window* pWin = GetActiveWindow();
2113 ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, bDelete, SdResId(STR_MODIFYLAYER)) );
2114 pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() );
2116 // test for already existing names
2117 bool bLoop = true;
2118 sal_uInt16 nRet = 0;
2119 while( bLoop )
2121 nRet = pDlg->Execute();
2122 if (nRet != RET_OK)
2123 break;
2124 pDlg->GetAttr( aNewAttr );
2125 aLayerName = aNewAttr.Get(ATTR_LAYER_NAME).GetValue ();
2126 if (bDelete)
2128 if( (rLayerAdmin.GetLayer( aLayerName ) && aLayerName != aOldLayerName)
2129 || LayerTabBar::IsRealNameOfStandardLayer(aLayerName)
2130 || LayerTabBar::IsLocalizedNameOfStandardLayer(aLayerName)
2131 || aLayerName.isEmpty() )
2133 // name already exists
2134 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(),
2135 VclMessageType::Warning, VclButtonsType::Ok,
2136 SdResId(STR_WARN_NAME_DUPLICATE)));
2137 xWarn->run();
2139 else
2140 bLoop = false;
2142 else
2143 bLoop = false; // altering name is already disabled in the dialog itself
2145 switch (nRet)
2147 case RET_OK :
2148 aLayerTitle = aNewAttr.Get(ATTR_LAYER_TITLE).GetValue ();
2149 aLayerDesc = aNewAttr.Get(ATTR_LAYER_DESC).GetValue ();
2150 bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue ();
2151 bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue ();
2152 bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue ();
2153 break;
2155 default :
2156 pDlg.disposeAndClear();
2157 rReq.Ignore ();
2158 Cancel ();
2159 return;
2162 else if (pArgs->Count () == 4)
2164 const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME);
2165 const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE);
2166 const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED);
2167 const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE);
2169 aLayerName = pLayerName->GetValue ();
2170 bIsVisible = pIsVisible->GetValue ();
2171 bIsLocked = pIsLocked->GetValue ();
2172 bIsPrintable = pIsPrintable->GetValue ();
2174 else
2176 #if HAVE_FEATURE_SCRIPTING
2177 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS);
2178 #endif
2179 Cancel ();
2180 rReq.Ignore ();
2181 break;
2184 SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager();
2185 std::unique_ptr<SdLayerModifyUndoAction> pAction( new SdLayerModifyUndoAction(
2186 GetDoc(),
2187 pLayer,
2188 // old values
2189 aOldLayerName,
2190 aOldLayerTitle,
2191 aOldLayerDesc,
2192 bOldIsVisible,
2193 bOldIsLocked,
2194 bOldIsPrintable,
2195 // new values
2196 aLayerName,
2197 aLayerTitle,
2198 aLayerDesc,
2199 bIsVisible,
2200 bIsLocked,
2201 bIsPrintable
2202 ) );
2203 pManager->AddUndoAction( std::move(pAction) );
2205 ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable );
2207 Cancel();
2208 rReq.Done ();
2210 break;
2212 case SID_TOGGLELAYERVISIBILITY:
2214 // tdf#113439; duplicates LayerTabBar::MouseButtonDown()
2215 sal_uInt16 aTabId = GetLayerTabControl()->GetCurPageId();
2216 OUString aName( GetLayerTabControl()->GetLayerName(aTabId) );
2218 SdrPageView* pPV = mpDrawView->GetSdrPageView();
2219 bool bVisible = !pPV->IsLayerVisible(aName);
2221 pPV->SetLayerVisible(aName, bVisible);
2223 ResetActualLayer();
2224 GetDoc()->SetChanged();
2226 Cancel();
2227 rReq.Ignore ();
2229 break;
2231 case SID_RENAMELAYER:
2233 if ( mpDrawView->IsTextEdit() )
2235 mpDrawView->SdrEndTextEdit();
2238 if(GetLayerTabControl()) // #i87182#
2240 GetLayerTabControl()->StartEditMode(GetLayerTabControl()->GetCurPageId());
2242 else
2244 OSL_ENSURE(false, "No LayerTabBar (!)");
2247 Cancel();
2248 rReq.Ignore ();
2250 break;
2252 case SID_EDIT_HYPERLINK :
2254 // Ensure the field is selected first
2255 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
2256 if (pOutView)
2257 pOutView->SelectFieldAtCursor();
2259 GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG );
2261 Cancel();
2262 rReq.Done ();
2264 break;
2266 case SID_OPEN_HYPERLINK:
2268 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
2269 if ( pOutView )
2271 const SvxFieldData* pField = pOutView->GetFieldAtCursor();
2272 if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) )
2274 SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() );
2275 SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() );
2277 OUString aReferName;
2278 SfxViewFrame* pFrame = GetViewFrame();
2279 SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium();
2280 if (pMed)
2281 aReferName = pMed->GetName();
2283 SfxFrameItem aFrm( SID_DOCFRAME, pFrame );
2284 SfxStringItem aReferer( SID_REFERER, aReferName );
2286 SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false );
2287 SfxBoolItem aBrowsing( SID_BROWSE, true );
2289 if (SfxViewFrame* pViewFrm = SfxViewFrame::Current())
2291 pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC,
2292 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD,
2293 { &aUrl, &aTarget, &aFrm, &aReferer,
2294 &aNewView, &aBrowsing });
2298 Cancel();
2299 rReq.Done ();
2301 break;
2303 case SID_COPY_HYPERLINK_LOCATION:
2305 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView();
2306 if ( pOutView )
2308 const SvxFieldData* pField = pOutView->GetFieldAtCursor();
2309 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField))
2311 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard
2312 = pOutView->GetWindow()->GetClipboard();
2314 vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard, SfxViewShell::Current());
2318 Cancel();
2319 rReq.Done ();
2321 break;
2323 case SID_HYPERLINK_SETLINK:
2325 const SfxItemSet* pReqArgs = rReq.GetArgs();
2327 if (pReqArgs)
2329 const SvxHyperlinkItem* pHLItem =
2330 &pReqArgs->Get(SID_HYPERLINK_SETLINK);
2332 if (pHLItem->GetInsertMode() == HLINK_FIELD)
2334 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
2335 pHLItem->GetTargetFrame());
2337 else if (pHLItem->GetInsertMode() == HLINK_BUTTON)
2339 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
2340 pHLItem->GetTargetFrame(), nullptr);
2342 else if (pHLItem->GetInsertMode() == HLINK_DEFAULT)
2344 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView();
2346 if (pOlView || comphelper::LibreOfficeKit::isActive())
2348 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(),
2349 pHLItem->GetTargetFrame());
2351 else
2353 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(),
2354 pHLItem->GetTargetFrame(), nullptr);
2359 Cancel();
2360 rReq.Ignore ();
2362 break;
2364 case SID_HIDE_LAST_LEVEL:
2366 ESelection aSel;
2367 // fdo#78151 editing a PresObjKind::Outline in a master page ?
2368 ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel);
2369 if (pOL)
2371 //we are on the last paragraph
2372 aSel.Adjust();
2373 if (aSel.nEndPara == pOL->GetParagraphCount() - 1)
2375 sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara);
2376 //there exists a previous numbering level
2377 if (nDepth != sal_uInt16(-1) && nDepth > 0)
2379 Paragraph* pPara = pOL->GetParagraph(aSel.nEndPara);
2380 pOL->Remove(pPara, 1);
2384 Cancel();
2385 rReq.Done ();
2387 break;
2389 case SID_SHOW_NEXT_LEVEL:
2391 const TranslateId STR_PRESOBJ_MPOUTLINE_ARY[]
2393 STR_PRESOBJ_MPOUTLINE,
2394 STR_PRESOBJ_MPOUTLLAYER2,
2395 STR_PRESOBJ_MPOUTLLAYER3,
2396 STR_PRESOBJ_MPOUTLLAYER4,
2397 STR_PRESOBJ_MPOUTLLAYER5,
2398 STR_PRESOBJ_MPOUTLLAYER6,
2399 STR_PRESOBJ_MPOUTLLAYER7,
2400 STR_PRESOBJ_MPNOTESTITLE,
2401 STR_PRESOBJ_MPNOTESTEXT,
2402 STR_PRESOBJ_NOTESTEXT
2405 ESelection aSel;
2406 // fdo#78151 editing a PresObjKind::Outline in a master page ?
2407 ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel);
2408 if (pOL)
2410 //we are on the last paragraph
2411 aSel.Adjust();
2412 if (aSel.nEndPara == pOL->GetParagraphCount() - 1)
2414 sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara);
2415 //there exists a previous numbering level
2416 if (nDepth < 8)
2418 sal_uInt16 nNewDepth = nDepth+1;
2419 pOL->Insert(SdResId(STR_PRESOBJ_MPOUTLINE_ARY[nNewDepth]), EE_PARA_APPEND, nNewDepth);
2423 Cancel();
2424 rReq.Done ();
2426 break;
2428 case SID_INSERT_FLD_DATE_FIX:
2429 case SID_INSERT_FLD_DATE_VAR:
2430 case SID_INSERT_FLD_TIME_FIX:
2431 case SID_INSERT_FLD_TIME_VAR:
2432 case SID_INSERT_FLD_AUTHOR:
2433 case SID_INSERT_FLD_PAGE:
2434 case SID_INSERT_FLD_PAGE_TITLE:
2435 case SID_INSERT_FLD_PAGES:
2436 case SID_INSERT_FLD_FILE:
2438 sal_uInt16 nMul = 1;
2439 std::unique_ptr<SvxFieldItem> pFieldItem;
2441 switch( nSId )
2443 case SID_INSERT_FLD_DATE_FIX:
2444 pFieldItem.reset(new SvxFieldItem(
2445 SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD ));
2446 break;
2448 case SID_INSERT_FLD_DATE_VAR:
2449 pFieldItem.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD ));
2450 break;
2452 case SID_INSERT_FLD_TIME_FIX:
2453 pFieldItem.reset(new SvxFieldItem(
2454 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM ), SvxTimeType::Fix ), EE_FEATURE_FIELD ));
2455 break;
2457 case SID_INSERT_FLD_TIME_VAR:
2458 pFieldItem.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD ));
2459 break;
2461 case SID_INSERT_FLD_AUTHOR:
2463 SvtUserOptions aUserOptions;
2464 pFieldItem.reset(new SvxFieldItem(
2465 SvxAuthorField(
2466 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD ));
2468 break;
2470 case SID_INSERT_FLD_PAGE:
2472 pFieldItem.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD ));
2473 nMul = 3;
2475 break;
2477 case SID_INSERT_FLD_PAGE_TITLE:
2479 pFieldItem.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD));
2480 nMul = 3;
2482 break;
2484 case SID_INSERT_FLD_PAGES:
2486 pFieldItem.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD ));
2487 nMul = 3;
2489 break;
2491 case SID_INSERT_FLD_FILE:
2493 OUString aName;
2494 if( GetDocSh()->HasName() )
2495 aName = GetDocSh()->GetMedium()->GetName();
2496 pFieldItem.reset(new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD ));
2498 break;
2501 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
2503 if( pOLV )
2505 const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection();
2507 if( pOldFldItem && ( nullptr != dynamic_cast< const SvxURLField *>( pOldFldItem->GetField() ) ||
2508 nullptr != dynamic_cast< const SvxDateField *>( pOldFldItem->GetField() ) ||
2509 nullptr != dynamic_cast< const SvxTimeField *>( pOldFldItem->GetField() ) ||
2510 nullptr != dynamic_cast< const SvxExtTimeField *>( pOldFldItem->GetField() ) ||
2511 nullptr != dynamic_cast< const SvxExtFileField *>( pOldFldItem->GetField() ) ||
2512 nullptr != dynamic_cast< const SvxAuthorField *>( pOldFldItem->GetField() ) ||
2513 nullptr != dynamic_cast< const SvxPageField *>( pOldFldItem->GetField() ) ) )
2515 // select field, then it will be deleted when inserting
2516 ESelection aSel = pOLV->GetSelection();
2517 if( aSel.nStartPos == aSel.nEndPos )
2518 aSel.nEndPos++;
2519 pOLV->SetSelection( aSel );
2522 if( pFieldItem )
2523 pOLV->InsertField( *pFieldItem );
2525 else
2527 Outliner* pOutl = GetDoc()->GetInternalOutliner();
2528 pOutl->Init( OutlinerMode::TextObject );
2529 OutlinerMode nOutlMode = pOutl->GetOutlinerMode();
2530 pOutl->SetStyleSheet( 0, nullptr );
2531 pOutl->QuickInsertField( *pFieldItem, ESelection() );
2532 std::optional<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject();
2534 rtl::Reference<SdrRectObj> pRectObj = new SdrRectObj(
2535 *GetDoc(),
2536 SdrObjKind::Text);
2537 pRectObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(true));
2539 pOutl->UpdateFields();
2540 pOutl->SetUpdateLayout( true );
2541 Size aSize( pOutl->CalcTextSize() );
2542 aSize.setWidth( aSize.Width() * nMul );
2543 pOutl->SetUpdateLayout( false );
2545 Point aPos;
2546 ::tools::Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() );
2547 aPos = aRect.Center();
2548 aPos = GetActiveWindow()->PixelToLogic(aPos);
2549 aPos.AdjustX( -(aSize.Width() / 2) );
2550 aPos.AdjustY( -(aSize.Height() / 2) );
2552 ::tools::Rectangle aLogicRect(aPos, aSize);
2553 pRectObj->SetLogicRect(aLogicRect);
2554 pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) );
2555 mpDrawView->InsertObjectAtView(pRectObj.get(), *mpDrawView->GetSdrPageView());
2556 pOutl->Init( nOutlMode );
2559 pFieldItem.reset();
2561 Cancel();
2562 rReq.Ignore ();
2564 break;
2566 case SID_MODIFY_FIELD:
2568 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView();
2570 if( pOLV )
2572 const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection();
2574 if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) ||
2575 nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) ||
2576 nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) ||
2577 nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) )
2579 // Dialog...
2580 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
2581 vcl::Window* pWin = GetActiveWindow();
2582 ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg( pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOLV->GetAttribs() ) );
2583 if( pDlg->Execute() == RET_OK )
2585 // To make a correct SetAttribs() call at the utlinerView
2586 // it is necessary to split the actions here
2587 std::unique_ptr<SvxFieldData> pField(pDlg->GetField());
2588 ESelection aSel = pOLV->GetSelection();
2589 bool bSelectionWasModified(false);
2591 if( pField )
2593 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD );
2595 if( aSel.nStartPos == aSel.nEndPos )
2597 bSelectionWasModified = true;
2598 aSel.nEndPos++;
2599 pOLV->SetSelection( aSel );
2602 pOLV->InsertField( aFieldItem );
2604 // select again for eventual SetAttribs call
2605 pOLV->SetSelection( aSel );
2608 SfxItemSet aSet( pDlg->GetItemSet() );
2610 if( aSet.Count() )
2612 pOLV->SetAttribs( aSet );
2614 ::Outliner* pOutliner = pOLV->GetOutliner();
2615 if( pOutliner )
2616 pOutliner->UpdateFields();
2619 if(pField)
2621 // restore selection to original
2622 if(bSelectionWasModified)
2624 aSel.nEndPos--;
2625 pOLV->SetSelection( aSel );
2632 Cancel();
2633 rReq.Ignore ();
2635 break;
2637 case SID_OPEN_XML_FILTERSETTINGS:
2641 css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() );
2642 xDialog->execute();
2644 catch( css::uno::RuntimeException& )
2646 DBG_UNHANDLED_EXCEPTION("sd.view");
2649 Cancel();
2650 rReq.Ignore ();
2652 break;
2654 case SID_GROUP: // BASIC
2656 if ( mpDrawView->IsPresObjSelected( true, true, true ) )
2658 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2659 VclMessageType::Info, VclButtonsType::Ok,
2660 SdResId(STR_ACTION_NOTPOSSIBLE)));
2661 xInfoBox->run();
2663 else
2665 mpDrawView->GroupMarked();
2667 Cancel();
2668 rReq.Done ();
2670 break;
2672 case SID_UNGROUP: // BASIC
2674 mpDrawView->UnGroupMarked();
2675 Cancel();
2676 rReq.Done ();
2678 break;
2680 case SID_NAME_GROUP:
2682 // only allow for single object selection since the name of an object needs
2683 // to be unique
2684 if(1 == mpDrawView->GetMarkedObjectCount())
2686 // #i68101#
2687 SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0);
2688 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
2689 OUString aName(pSelected->GetName());
2691 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2692 ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetFrameWeld(), aName));
2694 pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl));
2696 if(RET_OK == pDlg->Execute())
2698 pDlg->GetName(aName);
2699 pSelected->SetName(aName);
2701 SdPage* pPage = GetActualPage();
2702 if (pPage)
2703 pPage->notifyObjectRenamed(pSelected);
2707 SfxBindings& rBindings = GetViewFrame()->GetBindings();
2708 rBindings.Invalidate( SID_NAVIGATOR_STATE, true );
2709 rBindings.Invalidate( SID_CONTEXT );
2711 Cancel();
2712 rReq.Ignore();
2713 break;
2716 // #i68101#
2717 case SID_OBJECT_TITLE_DESCRIPTION:
2719 if(1 == mpDrawView->GetMarkedObjectCount())
2721 SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0);
2722 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)");
2723 OUString aTitle(pSelected->GetTitle());
2724 OUString aDescription(pSelected->GetDescription());
2725 bool isDecorative(pSelected->IsDecorative());
2727 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
2728 ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog(
2729 GetFrameWeld(), aTitle, aDescription, isDecorative));
2731 if(RET_OK == pDlg->Execute())
2733 pDlg->GetTitle(aTitle);
2734 pDlg->GetDescription(aDescription);
2735 pDlg->IsDecorative(isDecorative);
2736 pSelected->SetTitle(aTitle);
2737 pSelected->SetDescription(aDescription);
2738 pSelected->SetDecorative(isDecorative);
2742 SfxBindings& rBindings = GetViewFrame()->GetBindings();
2743 rBindings.Invalidate( SID_NAVIGATOR_STATE, true );
2744 rBindings.Invalidate( SID_CONTEXT );
2746 Cancel();
2747 rReq.Ignore();
2748 break;
2751 case SID_ENTER_GROUP: // BASIC
2753 mpDrawView->EnterMarkedGroup();
2754 Cancel();
2755 rReq.Done ();
2757 break;
2759 case SID_LEAVE_GROUP: // BASIC
2761 mpDrawView->LeaveOneGroup();
2762 Cancel();
2763 rReq.Done ();
2765 break;
2767 case SID_LEAVE_ALL_GROUPS: // BASIC
2769 mpDrawView->LeaveAllGroup();
2770 Cancel();
2771 rReq.Done ();
2773 break;
2775 case SID_TEXT_COMBINE: // BASIC
2777 // End text edit to avoid conflicts
2778 if(mpDrawView->IsTextEdit())
2779 mpDrawView->SdrEndTextEdit();
2781 if ( mpDrawView->IsPresObjSelected() )
2783 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2784 VclMessageType::Info, VclButtonsType::Ok,
2785 SdResId(STR_ACTION_NOTPOSSIBLE)));
2786 xInfoBox->run();
2788 else
2790 weld::WaitObject aWait(GetFrameWeld());
2791 mpDrawView->CombineMarkedTextObjects();
2793 Cancel();
2794 rReq.Done ();
2796 break;
2798 case SID_COMBINE: // BASIC
2800 // End text edit to avoid conflicts
2801 if(mpDrawView->IsTextEdit())
2802 mpDrawView->SdrEndTextEdit();
2804 if ( mpDrawView->IsPresObjSelected() )
2806 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2807 VclMessageType::Info, VclButtonsType::Ok,
2808 SdResId(STR_ACTION_NOTPOSSIBLE)));
2809 xInfoBox->run();
2811 else
2813 weld::WaitObject aWait(GetFrameWeld());
2814 mpDrawView->CombineMarkedObjects(false);
2816 Cancel();
2817 rReq.Done ();
2819 break;
2821 case SID_DISTRIBUTE_HLEFT:
2822 case SID_DISTRIBUTE_HCENTER:
2823 case SID_DISTRIBUTE_HDISTANCE:
2824 case SID_DISTRIBUTE_HRIGHT:
2825 case SID_DISTRIBUTE_VTOP:
2826 case SID_DISTRIBUTE_VCENTER:
2827 case SID_DISTRIBUTE_VDISTANCE:
2828 case SID_DISTRIBUTE_VBOTTOM:
2830 if ( mpDrawView->IsPresObjSelected() )
2832 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2833 VclMessageType::Info, VclButtonsType::Ok,
2834 SdResId(STR_ACTION_NOTPOSSIBLE)));
2835 xInfoBox->run();
2837 else
2839 mpDrawView->DistributeMarkedObjects(nSId);
2841 Cancel();
2842 rReq.Done ();
2844 break;
2845 case SID_POLY_MERGE:
2847 // End text edit to avoid conflicts
2848 if(mpDrawView->IsTextEdit())
2849 mpDrawView->SdrEndTextEdit();
2851 if ( mpDrawView->IsPresObjSelected() )
2853 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2854 VclMessageType::Info, VclButtonsType::Ok,
2855 SdResId(STR_ACTION_NOTPOSSIBLE)));
2856 xInfoBox->run();
2858 else
2860 weld::WaitObject aWait(GetFrameWeld());
2861 mpDrawView->MergeMarkedObjects(SdrMergeMode::Merge);
2863 Cancel();
2864 rReq.Done ();
2866 break;
2868 case SID_POLY_SUBSTRACT:
2870 // End text edit to avoid conflicts
2871 if(mpDrawView->IsTextEdit())
2872 mpDrawView->SdrEndTextEdit();
2874 if ( mpDrawView->IsPresObjSelected() )
2876 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2877 VclMessageType::Info, VclButtonsType::Ok,
2878 SdResId(STR_ACTION_NOTPOSSIBLE)));
2879 xInfoBox->run();
2881 else
2883 weld::WaitObject aWait(GetFrameWeld());
2884 mpDrawView->MergeMarkedObjects(SdrMergeMode::Subtract);
2886 Cancel();
2887 rReq.Done ();
2889 break;
2891 case SID_POLY_INTERSECT:
2893 // End text edit to avoid conflicts
2894 if(mpDrawView->IsTextEdit())
2895 mpDrawView->SdrEndTextEdit();
2897 if ( mpDrawView->IsPresObjSelected() )
2899 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2900 VclMessageType::Info, VclButtonsType::Ok,
2901 SdResId(STR_ACTION_NOTPOSSIBLE)));
2902 xInfoBox->run();
2904 else
2906 weld::WaitObject aWait(GetFrameWeld());
2907 mpDrawView->MergeMarkedObjects(SdrMergeMode::Intersect);
2909 Cancel();
2910 rReq.Done ();
2912 break;
2914 case SID_EQUALIZEWIDTH:
2915 case SID_EQUALIZEHEIGHT:
2917 // End text edit to avoid conflicts
2918 if(mpDrawView->IsTextEdit())
2919 mpDrawView->SdrEndTextEdit();
2921 mpDrawView->EqualizeMarkedObjects(nSId == SID_EQUALIZEWIDTH);
2922 Cancel();
2923 rReq.Done ();
2925 break;
2927 case SID_DISMANTLE: // BASIC
2929 if ( mpDrawView->IsDismantlePossible() )
2931 weld::WaitObject aWait(GetFrameWeld());
2932 mpDrawView->DismantleMarkedObjects();
2934 Cancel();
2935 rReq.Done ();
2937 break;
2939 case SID_CONNECT: // BASIC
2941 if ( mpDrawView->IsPresObjSelected() )
2943 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
2944 VclMessageType::Info, VclButtonsType::Ok,
2945 SdResId(STR_ACTION_NOTPOSSIBLE)));
2946 xInfoBox->run();
2948 else
2950 weld::WaitObject aWait(GetFrameWeld());
2951 mpDrawView->CombineMarkedObjects();
2953 Cancel();
2954 rReq.Done ();
2956 break;
2958 case SID_BREAK: // BASIC
2960 if ( mpDrawView->IsTextEdit() )
2962 mpDrawView->SdrEndTextEdit();
2965 if ( mpDrawView->IsBreak3DObjPossible() )
2967 weld::WaitObject aWait(GetFrameWeld());
2968 mpDrawView->Break3DObj();
2970 else if ( mpDrawView->IsDismantlePossible(true) )
2972 weld::WaitObject aWait(GetFrameWeld());
2973 mpDrawView->DismantleMarkedObjects(true);
2975 else if ( mpDrawView->IsImportMtfPossible() )
2977 weld::WaitObject aWait(GetFrameWeld());
2978 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
2979 const size_t nCnt=rMarkList.GetMarkCount();
2981 // determine the sum of meta objects of all selected meta files
2982 sal_uLong nCount = 0;
2983 for(size_t nm=0; nm<nCnt; ++nm)
2985 SdrMark* pM=rMarkList.GetMark(nm);
2986 SdrObject* pObj=pM->GetMarkedSdrObj();
2987 SdrGrafObj* pGraf= dynamic_cast< SdrGrafObj *>( pObj );
2988 SdrOle2Obj* pOle2= dynamic_cast< SdrOle2Obj *>( pObj );
2990 if (pGraf != nullptr)
2992 if (pGraf->HasGDIMetaFile())
2994 nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionSize();
2996 else if (pGraf->isEmbeddedVectorGraphicData())
2998 nCount += pGraf->getMetafileFromEmbeddedVectorGraphicData().GetActionSize();
3002 if(pOle2 && pOle2->GetGraphic())
3004 nCount += pOle2->GetGraphic()->GetGDIMetaFile().GetActionSize();
3008 // decide with the sum of all meta objects if we should show a dialog
3009 if(nCount < MIN_ACTIONS_FOR_DIALOG)
3011 // nope, no dialog
3012 mpDrawView->DoImportMarkedMtf();
3014 else
3016 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
3017 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) ));
3018 pDlg->Execute();
3022 Cancel();
3023 rReq.Done ();
3025 break;
3027 case SID_CONVERT_TO_3D:
3029 if ( mpDrawView->IsPresObjSelected() )
3031 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
3032 VclMessageType::Info, VclButtonsType::Ok,
3033 SdResId(STR_ACTION_NOTPOSSIBLE)));
3034 xInfoBox->run();
3036 else
3038 if (mpDrawView->IsConvertTo3DObjPossible())
3040 if (mpDrawView->IsTextEdit())
3042 mpDrawView->SdrEndTextEdit();
3045 weld::WaitObject aWait(GetFrameWeld());
3046 mpDrawView->ConvertMarkedObjTo3D();
3050 Cancel();
3051 rReq.Done();
3053 break;
3055 case SID_FRAME_TO_TOP: // BASIC
3057 mpDrawView->PutMarkedToTop();
3058 Cancel();
3059 rReq.Done ();
3061 break;
3063 case SID_MOREFRONT: // BASIC
3064 case SID_FRAME_UP: // BASIC
3066 mpDrawView->MovMarkedToTop();
3067 Cancel();
3068 rReq.Done ();
3070 break;
3072 case SID_MOREBACK: // BASIC
3073 case SID_FRAME_DOWN: // BASIC
3075 mpDrawView->MovMarkedToBtm();
3076 Cancel();
3077 rReq.Done ();
3079 break;
3081 case SID_FRAME_TO_BOTTOM: // BASIC
3083 mpDrawView->PutMarkedToBtm();
3084 Cancel();
3085 rReq.Done ();
3087 break;
3089 case SID_HORIZONTAL: // BASIC
3090 case SID_FLIP_HORIZONTAL:
3092 mpDrawView->MirrorAllMarkedHorizontal();
3093 Cancel();
3094 rReq.Done ();
3096 break;
3098 case SID_VERTICAL: // BASIC
3099 case SID_FLIP_VERTICAL:
3101 mpDrawView->MirrorAllMarkedVertical();
3102 Cancel();
3103 rReq.Done ();
3105 break;
3107 case SID_OBJECT_ALIGN_LEFT: // BASIC
3109 mpDrawView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE);
3110 Cancel();
3111 rReq.Done ();
3113 break;
3115 case SID_OBJECT_ALIGN_CENTER: // BASIC
3117 mpDrawView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE);
3118 Cancel();
3119 rReq.Done ();
3121 break;
3123 case SID_OBJECT_ALIGN_RIGHT: // BASIC
3125 mpDrawView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE);
3126 Cancel();
3127 rReq.Done ();
3129 break;
3131 case SID_OBJECT_ALIGN_UP: // BASIC
3133 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top);
3134 Cancel();
3135 rReq.Done ();
3137 break;
3139 case SID_OBJECT_ALIGN_MIDDLE: // BASIC
3141 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center);
3142 Cancel();
3143 rReq.Done ();
3145 break;
3147 case SID_OBJECT_ALIGN_DOWN: // BASIC
3149 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom);
3150 Cancel();
3151 rReq.Done ();
3153 break;
3155 case SID_SELECTALL: // BASIC
3157 if( (dynamic_cast<FuSelection*>( GetOldFunction().get() ) != nullptr) &&
3158 !GetView()->IsFrameDragSingles() && GetView()->HasMarkablePoints())
3160 if ( !mpDrawView->IsAction() )
3161 mpDrawView->MarkAllPoints();
3163 else
3164 mpDrawView->SelectAll();
3166 FreshNavigatrTree();
3168 Cancel();
3169 rReq.Done ();
3171 break;
3173 case SID_STYLE_NEW: // BASIC ???
3174 case SID_STYLE_APPLY:
3175 case SID_STYLE_EDIT:
3176 case SID_STYLE_DELETE:
3177 case SID_STYLE_HIDE:
3178 case SID_STYLE_SHOW:
3179 case SID_STYLE_FAMILY:
3180 case SID_STYLE_WATERCAN:
3181 case SID_STYLE_UPDATE_BY_EXAMPLE:
3182 case SID_STYLE_NEW_BY_EXAMPLE:
3184 if( rReq.GetSlot() == SID_STYLE_EDIT && !rReq.GetArgs() )
3186 SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet();
3187 if( pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page)
3188 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
3190 if( (pStyleSheet == nullptr) && GetView()->IsTextEdit() )
3192 GetView()->SdrEndTextEdit();
3194 pStyleSheet = mpDrawView->GetStyleSheet();
3195 if(pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page)
3196 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet();
3199 if( pStyleSheet == nullptr )
3201 rReq.Ignore();
3202 break;
3205 SfxAllItemSet aSet(GetDoc()->GetPool());
3207 SfxStringItem aStyleNameItem( SID_STYLE_EDIT, pStyleSheet->GetName() );
3208 aSet.Put(aStyleNameItem);
3210 SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILY, static_cast<sal_uInt16>(pStyleSheet->GetFamily()) );
3211 aSet.Put(aStyleFamilyItem);
3213 rReq.SetArgs(aSet);
3216 if( rReq.GetArgs() )
3218 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
3219 if( rReq.GetSlot() == SID_STYLE_APPLY )
3220 GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY );
3221 Cancel();
3223 else if( rReq.GetSlot() == SID_STYLE_APPLY )
3224 GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON );
3225 rReq.Ignore ();
3227 break;
3229 case SID_IMAP:
3231 sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId();
3233 GetViewFrame()->ToggleChildWindow( nId );
3234 GetViewFrame()->GetBindings().Invalidate( SID_IMAP );
3236 if ( GetViewFrame()->HasChildWindow( nId )
3237 && ( ( ViewShell::Implementation::GetImageMapDialog() ) != nullptr ) )
3239 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList();
3241 if ( rMarkList.GetMarkCount() == 1 )
3242 UpdateIMapDlg( rMarkList.GetMark( 0 )->GetMarkedSdrObj() );
3245 Cancel();
3246 rReq.Ignore ();
3248 break;
3250 case SID_GRID_FRONT:
3252 mpDrawView->SetGridFront( !mpDrawView->IsGridFront() );
3253 Cancel();
3254 rReq.Done ();
3256 break;
3258 case SID_HELPLINES_FRONT:
3260 mpDrawView->SetHlplFront( !mpDrawView->IsHlplFront() );
3261 Cancel();
3262 rReq.Done ();
3264 break;
3266 case SID_FONTWORK:
3268 if ( rReq.GetArgs() )
3270 GetViewFrame()->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(),
3271 static_cast<const SfxBoolItem&>(rReq.GetArgs()->
3272 Get(SID_FONTWORK)).GetValue());
3274 else
3276 GetViewFrame()->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() );
3279 GetViewFrame()->GetBindings().Invalidate(SID_FONTWORK);
3280 Cancel();
3281 rReq.Ignore ();
3283 break;
3285 case SID_COLOR_CONTROL:
3287 if ( rReq.GetArgs() )
3288 GetViewFrame()->SetChildWindow(SvxColorChildWindow::GetChildWindowId(),
3289 rReq.GetArgs()->Get(SID_COLOR_CONTROL).GetValue());
3290 else
3291 GetViewFrame()->ToggleChildWindow(SvxColorChildWindow::GetChildWindowId() );
3293 GetViewFrame()->GetBindings().Invalidate(SID_COLOR_CONTROL);
3294 Cancel();
3295 rReq.Ignore ();
3297 break;
3299 case SID_EXTRUSION_TOGGLE:
3300 case SID_EXTRUSION_TILT_DOWN:
3301 case SID_EXTRUSION_TILT_UP:
3302 case SID_EXTRUSION_TILT_LEFT:
3303 case SID_EXTRUSION_TILT_RIGHT:
3304 case SID_EXTRUSION_3D_COLOR:
3305 case SID_EXTRUSION_DEPTH:
3306 case SID_EXTRUSION_DIRECTION:
3307 case SID_EXTRUSION_PROJECTION:
3308 case SID_EXTRUSION_LIGHTING_DIRECTION:
3309 case SID_EXTRUSION_LIGHTING_INTENSITY:
3310 case SID_EXTRUSION_SURFACE:
3311 case SID_EXTRUSION_DEPTH_FLOATER:
3312 case SID_EXTRUSION_DIRECTION_FLOATER:
3313 case SID_EXTRUSION_LIGHTING_FLOATER:
3314 case SID_EXTRUSION_SURFACE_FLOATER:
3315 case SID_EXTRUSION_DEPTH_DIALOG:
3316 svx::ExtrusionBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() );
3317 Cancel();
3318 rReq.Ignore ();
3319 break;
3321 case SID_FONTWORK_SHAPE:
3322 case SID_FONTWORK_SHAPE_TYPE:
3323 case SID_FONTWORK_ALIGNMENT:
3324 case SID_FONTWORK_SAME_LETTER_HEIGHTS:
3325 case SID_FONTWORK_CHARACTER_SPACING:
3326 case SID_FONTWORK_KERN_CHARACTER_PAIRS:
3327 case SID_FONTWORK_GALLERY_FLOATER:
3328 case SID_FONTWORK_CHARACTER_SPACING_FLOATER:
3329 case SID_FONTWORK_ALIGNMENT_FLOATER:
3330 case SID_FONTWORK_CHARACTER_SPACING_DIALOG:
3331 svx::FontworkBar::execute(*mpDrawView, rReq, GetViewFrame()->GetBindings());
3332 Cancel();
3333 rReq.Ignore ();
3334 break;
3336 case SID_BMPMASK:
3338 GetViewFrame()->ToggleChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() );
3339 GetViewFrame()->GetBindings().Invalidate( SID_BMPMASK );
3341 Cancel();
3342 rReq.Ignore ();
3344 break;
3346 case SID_NAVIGATOR:
3348 if (comphelper::LibreOfficeKit::isActive())
3350 GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
3351 OUString panelId = "SdNavigatorPanel";
3352 ::sfx2::sidebar::Sidebar::TogglePanel(
3353 panelId, GetViewFrame()->GetFrame().GetFrameInterface());
3355 Cancel();
3356 rReq.Done();
3357 } else {
3358 if ( rReq.GetArgs() )
3359 GetViewFrame()->SetChildWindow(SID_NAVIGATOR,
3360 static_cast<const SfxBoolItem&>(rReq.GetArgs()->
3361 Get(SID_NAVIGATOR)).GetValue());
3362 else
3363 GetViewFrame()->ToggleChildWindow( SID_NAVIGATOR );
3365 GetViewFrame()->GetBindings().Invalidate(SID_NAVIGATOR);
3366 Cancel();
3367 rReq.Ignore ();
3370 break;
3372 case SID_SLIDE_TRANSITIONS_PANEL:
3373 case SID_MASTER_SLIDES_PANEL:
3374 case SID_CUSTOM_ANIMATION_PANEL:
3375 case SID_GALLERY:
3377 // First make sure that the sidebar is visible
3378 GetViewFrame()->ShowChildWindow(SID_SIDEBAR);
3380 OUString panelId;
3381 if (nSId == SID_CUSTOM_ANIMATION_PANEL)
3382 panelId = "SdCustomAnimationPanel";
3383 else if (nSId == SID_GALLERY)
3384 panelId = "GalleryPanel";
3385 else if (nSId == SID_SLIDE_TRANSITIONS_PANEL)
3386 panelId = "SdSlideTransitionPanel";
3387 else if (nSId == SID_MASTER_SLIDES_PANEL)
3388 panelId = "SdAllMasterPagesPanel";
3390 ::sfx2::sidebar::Sidebar::TogglePanel(
3391 panelId,
3392 GetViewFrame()->GetFrame().GetFrameInterface());
3394 Cancel();
3395 rReq.Done();
3397 break;
3399 case SID_ANIMATION_OBJECTS:
3401 if ( rReq.GetArgs() )
3402 GetViewFrame()->SetChildWindow(
3403 AnimationChildWindow::GetChildWindowId(),
3404 static_cast<const SfxBoolItem&>(rReq.GetArgs()->
3405 Get(SID_ANIMATION_OBJECTS)).GetValue());
3406 else
3407 GetViewFrame()->ToggleChildWindow(
3408 AnimationChildWindow::GetChildWindowId() );
3410 GetViewFrame()->GetBindings().Invalidate(SID_ANIMATION_OBJECTS);
3411 Cancel();
3412 rReq.Ignore ();
3414 break;
3416 case SID_3D_WIN:
3418 if ( rReq.GetArgs() )
3419 GetViewFrame()->SetChildWindow( Svx3DChildWindow::GetChildWindowId(),
3420 static_cast<const SfxBoolItem&>(rReq.GetArgs()->
3421 Get( SID_3D_WIN )).GetValue());
3422 else
3423 GetViewFrame()->ToggleChildWindow( Svx3DChildWindow::GetChildWindowId() );
3425 GetViewFrame()->GetBindings().Invalidate( SID_3D_WIN );
3426 Cancel();
3427 rReq.Ignore ();
3429 break;
3431 case SID_CONVERT_TO_3D_LATHE_FAST:
3433 /* The call is enough. The initialization via Start3DCreation and
3434 CreateMirrorPolygons is no longer needed if the parameter
3435 sal_True is provided. Then a tilted rotary body with an axis left
3436 besides the bounding rectangle of the selected objects is drawn
3437 immediately and without user interaction. */
3438 mpDrawView->SdrEndTextEdit();
3439 if(GetActiveWindow())
3440 GetActiveWindow()->EnterWait();
3441 mpDrawView->End3DCreation(true);
3442 Cancel();
3443 rReq.Ignore();
3444 if(GetActiveWindow())
3445 GetActiveWindow()->LeaveWait();
3447 break;
3449 case SID_PRESENTATION_DLG:
3451 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
3452 Cancel();
3454 break;
3456 case SID_REMOTE_DLG:
3458 #ifdef ENABLE_SDREMOTE
3459 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
3460 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetFrameWeld()));
3461 pDlg->Execute();
3462 #endif
3464 break;
3466 case SID_CUSTOMSHOW_DLG:
3468 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
3469 Cancel();
3471 break;
3473 case SID_EXPAND_PAGE:
3475 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
3476 Cancel();
3478 break;
3480 case SID_SUMMARY_PAGE:
3482 mpDrawView->SdrEndTextEdit();
3483 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) );
3484 Cancel();
3486 break;
3488 #if HAVE_FEATURE_AVMEDIA
3489 case SID_AVMEDIA_PLAYER:
3491 GetViewFrame()->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() );
3492 GetViewFrame()->GetBindings().Invalidate( SID_AVMEDIA_PLAYER );
3493 Cancel();
3494 rReq.Ignore ();
3496 break;
3497 #endif
3499 case SID_PRESENTATION_MINIMIZER:
3501 Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext());
3502 Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext));
3503 Reference<frame::XDispatchProvider> xProvider(GetViewShellBase().GetController()->getFrame(), UNO_QUERY);
3504 if (xProvider.is())
3506 util::URL aURL;
3507 aURL.Complete = "vnd.com.sun.star.comp.PresentationMinimizer:execute";
3508 xParser->parseStrict(aURL);
3509 uno::Reference<frame::XDispatch> xDispatch(xProvider->queryDispatch(aURL, OUString(), 0));
3510 if (xDispatch.is())
3512 xDispatch->dispatch(aURL, uno::Sequence< beans::PropertyValue >());
3515 Cancel();
3516 rReq.Ignore();
3518 break;
3520 case SID_DISPLAY_MASTER_BACKGROUND:
3521 case SID_DISPLAY_MASTER_OBJECTS:
3523 // Determine current page and toggle visibility of layers
3524 // associated with master page background or master page shapes.
3525 // FIXME: This solution is wrong, because shapes of master pages need
3526 // not be on layer "background" or "backgroundobjects".
3527 // See tdf#118613
3528 SdPage* pPage = GetActualPage();
3529 if (pPage != nullptr
3530 && GetDoc() != nullptr)
3532 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers();
3533 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin();
3534 SdrLayerID aLayerId;
3535 if (nSId == SID_DISPLAY_MASTER_BACKGROUND)
3536 aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background);
3537 else
3538 aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects);
3539 aVisibleLayers.Set(aLayerId, !aVisibleLayers.IsSet(aLayerId));
3540 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers);
3542 Cancel();
3543 rReq.Done(); // Mark task as done to auto-update the state of each buttons tdf#132816
3545 break;
3547 case SID_PHOTOALBUM:
3549 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
3550 vcl::Window* pWin = GetActiveWindow();
3551 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog(
3552 pWin ? pWin->GetFrameWeld() : nullptr,
3553 GetDoc()));
3555 pDlg->Execute();
3556 Cancel();
3557 rReq.Ignore ();
3559 break;
3561 case SID_INSERT_QRCODE:
3562 case SID_EDIT_QRCODE:
3564 VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
3565 const uno::Reference<frame::XModel> xModel = GetViewShellBase().GetController()->getModel();
3566 ScopedVclPtr<AbstractQrCodeGenDialog> pDlg(pFact->CreateQrCodeGenDialog(
3567 GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE));
3568 pDlg->Execute();
3569 Cancel();
3570 rReq.Ignore ();
3572 break;
3574 case SID_ADDITIONS_DIALOG:
3576 OUString sAdditionsTag = "";
3578 const SfxStringItem* pStringArg = rReq.GetArg<SfxStringItem>(FN_PARAM_ADDITIONS_TAG);
3579 if (pStringArg)
3580 sAdditionsTag = pStringArg->GetValue();
3582 VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
3583 ScopedVclPtr<AbstractAdditionsDialog> pDlg(
3584 pFact->CreateAdditionsDialog(GetFrameWeld(), sAdditionsTag));
3585 pDlg->Execute();
3586 Cancel();
3587 rReq.Ignore ();
3589 break;
3591 case SID_ATTR_GLOW_COLOR:
3592 case SID_ATTR_GLOW_RADIUS:
3593 case SID_ATTR_GLOW_TRANSPARENCY:
3594 case SID_ATTR_SOFTEDGE_RADIUS:
3595 case SID_ATTR_TEXTCOLUMNS_NUMBER:
3596 case SID_ATTR_TEXTCOLUMNS_SPACING:
3597 if (const SfxItemSet* pNewArgs = rReq.GetArgs())
3598 mpDrawView->SetAttributes(*pNewArgs);
3599 rReq.Done();
3600 Cancel();
3601 break;
3603 default:
3605 SAL_WARN( "sd.ui", "Slot without function" );
3606 Cancel();
3607 rReq.Ignore ();
3609 break;
3612 if(HasCurrentFunction())
3614 GetCurrentFunction()->Activate();
3618 void DrawViewShell::ExecChar( SfxRequest &rReq )
3620 SdDrawDocument* pDoc = GetDoc();
3621 if (!pDoc || !mpDrawView)
3622 return;
3624 SfxItemSet aEditAttr( pDoc->GetPool() );
3625 mpDrawView->GetAttributes( aEditAttr );
3627 //modified by wj for sym2_1580, if put old itemset into new set,
3628 //when mpDrawView->SetAttributes(aNewAttr) it will invalidate all the item
3629 // and use old attr to update all the attributes
3630 // SfxItemSet aNewAttr( GetPool(),
3631 // EE_ITEMS_START, EE_ITEMS_END );
3632 // aNewAttr.Put( aEditAttr, sal_False );
3633 SfxItemSet aNewAttr( pDoc->GetPool() );
3634 //modified end
3636 sal_uInt16 nSId = rReq.GetSlot();
3638 switch ( nSId )
3640 case SID_ATTR_CHAR_FONT:
3641 if( rReq.GetArgs() )
3643 const SvxFontItem* pItem = rReq.GetArg<SvxFontItem>(SID_ATTR_CHAR_FONT);
3644 if (pItem)
3646 aNewAttr.Put(*pItem);
3649 break;
3650 case SID_ATTR_CHAR_FONTHEIGHT:
3651 if( rReq.GetArgs() )
3653 const SvxFontHeightItem* pItem = rReq.GetArg<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT);
3654 if (pItem)
3656 aNewAttr.Put(*pItem);
3659 break;
3660 case SID_ATTR_CHAR_WEIGHT:
3661 if( rReq.GetArgs() )
3663 const SvxWeightItem* pItem = rReq.GetArg<SvxWeightItem>(SID_ATTR_CHAR_WEIGHT);
3664 if (pItem)
3666 aNewAttr.Put(*pItem);
3669 break;
3670 case SID_ATTR_CHAR_POSTURE:
3671 if( rReq.GetArgs() )
3673 const SvxPostureItem* pItem = rReq.GetArg<SvxPostureItem>(SID_ATTR_CHAR_POSTURE);
3674 if (pItem)
3676 aNewAttr.Put(*pItem);
3679 break;
3680 case SID_ATTR_CHAR_UNDERLINE:
3681 if( rReq.GetArgs() )
3683 const SvxUnderlineItem* pItem = rReq.GetArg<SvxUnderlineItem>(SID_ATTR_CHAR_UNDERLINE);
3684 if (pItem)
3686 aNewAttr.Put(*pItem);
3688 else
3690 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle();
3691 aNewAttr.Put( SvxUnderlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ) );
3694 break;
3695 case SID_ATTR_CHAR_OVERLINE:
3696 if( rReq.GetArgs() )
3698 const SvxOverlineItem* pItem = rReq.GetArg<SvxOverlineItem>(SID_ATTR_CHAR_OVERLINE);
3699 if (pItem)
3701 aNewAttr.Put(*pItem);
3703 else
3705 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle();
3706 aNewAttr.Put( SvxOverlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE ) );
3709 break;
3711 case SID_ULINE_VAL_NONE:
3713 aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE));
3714 break;
3717 case SID_ULINE_VAL_SINGLE:
3718 case SID_ULINE_VAL_DOUBLE:
3719 case SID_ULINE_VAL_DOTTED:
3721 FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle();
3722 FontLineStyle eNew = eOld;
3724 switch (nSId)
3726 case SID_ULINE_VAL_SINGLE:
3727 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE;
3728 break;
3729 case SID_ULINE_VAL_DOUBLE:
3730 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE;
3731 break;
3732 case SID_ULINE_VAL_DOTTED:
3733 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED;
3734 break;
3737 SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE);
3738 aNewAttr.Put(aUnderline);
3740 break;
3742 case SID_ATTR_CHAR_SHADOWED:
3743 if( rReq.GetArgs() )
3745 const SvxShadowedItem* pItem = rReq.GetArg<SvxShadowedItem>(SID_ATTR_CHAR_SHADOWED);
3746 if (pItem)
3748 aNewAttr.Put(*pItem);
3751 break;
3752 case SID_ATTR_CHAR_CONTOUR:
3753 if( rReq.GetArgs() )
3755 const SvxContourItem* pItem = rReq.GetArg<SvxContourItem>(SID_ATTR_CHAR_CONTOUR);
3756 if (pItem)
3758 aNewAttr.Put(*pItem);
3761 break;
3763 case SID_ATTR_CHAR_STRIKEOUT:
3764 if( rReq.GetArgs() )
3766 const SvxCrossedOutItem* pItem = rReq.GetArg<SvxCrossedOutItem>(SID_ATTR_CHAR_STRIKEOUT);
3767 if (pItem)
3769 aNewAttr.Put(*pItem);
3772 break;
3773 case SID_ATTR_CHAR_COLOR:
3774 if( rReq.GetArgs() )
3776 const SvxColorItem* pItem = rReq.GetArg<SvxColorItem>(SID_ATTR_CHAR_COLOR);
3777 if (pItem)
3779 aNewAttr.Put(*pItem);
3782 break;
3783 case SID_ATTR_CHAR_KERNING:
3784 if( rReq.GetArgs() )
3786 const SvxKerningItem* pItem = rReq.GetArg<SvxKerningItem>(SID_ATTR_CHAR_KERNING);
3787 if (pItem)
3789 aNewAttr.Put(*pItem);
3792 break;
3793 case SID_ATTR_CHAR_CASEMAP:
3794 if( rReq.GetArgs() )
3796 const SvxCaseMapItem* pItem = rReq.GetArg<SvxCaseMapItem>(SID_ATTR_CHAR_CASEMAP);
3797 if (pItem)
3799 aNewAttr.Put(*pItem);
3802 break;
3803 case SID_SET_SUB_SCRIPT:
3805 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
3806 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
3807 if( eEsc == SvxEscapement::Subscript )
3808 aItem.SetEscapement( SvxEscapement::Off );
3809 else
3810 aItem.SetEscapement( SvxEscapement::Subscript );
3811 aNewAttr.Put( aItem );
3813 break;
3814 case SID_SET_SUPER_SCRIPT:
3816 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT );
3817 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue());
3818 if( eEsc == SvxEscapement::Superscript )
3819 aItem.SetEscapement( SvxEscapement::Off );
3820 else
3821 aItem.SetEscapement( SvxEscapement::Superscript );
3822 aNewAttr.Put( aItem );
3824 break;
3825 case SID_SHRINK_FONT_SIZE:
3826 case SID_GROW_FONT_SIZE:
3828 const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ) );
3829 const FontList* pFontList = pFonts ? pFonts->GetFontList() : nullptr;
3830 if( pFontList )
3832 FuText::ChangeFontSize( nSId == SID_GROW_FONT_SIZE, nullptr, pFontList, mpView );
3833 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT );
3835 break;
3837 case SID_ATTR_CHAR_BACK_COLOR:
3838 if( rReq.GetArgs() )
3840 const SvxColorItem* pItem = rReq.GetArg<SvxColorItem>(SID_ATTR_CHAR_BACK_COLOR);
3841 if (pItem)
3843 aNewAttr.Put(*pItem);
3846 break;
3847 default:
3848 break;
3851 mpDrawView->SetAttributes(aNewAttr);
3852 rReq.Done();
3853 Cancel();
3856 /** This method consists basically of three parts:
3857 1. Process the arguments of the SFX request.
3858 2. Use the model to create a new page or duplicate an existing one.
3859 3. Update the tab control and switch to the new page.
3861 SdPage* DrawViewShell::CreateOrDuplicatePage (
3862 SfxRequest& rRequest,
3863 PageKind ePageKind,
3864 SdPage* pPage,
3865 const sal_Int32 nInsertPosition)
3867 SdPage* pNewPage = nullptr;
3868 if (ePageKind == PageKind::Standard && meEditMode != EditMode::MasterPage)
3870 if ( mpDrawView->IsTextEdit() )
3872 mpDrawView->SdrEndTextEdit();
3874 pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition);
3876 return pNewPage;
3879 void DrawViewShell::DuplicateSelectedSlides (SfxRequest& rRequest)
3881 // Create a list of the pages that are to be duplicated. The process of
3882 // duplication alters the selection.
3883 sal_Int32 nInsertPosition (0);
3884 ::std::vector<SdPage*> aPagesToDuplicate;
3885 sd::slidesorter::SlideSorter &mrSlideSorter = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase())->GetSlideSorter();
3886 sd::slidesorter::model::PageEnumeration aSelectedPages (
3887 sd::slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel()));
3888 while (aSelectedPages.HasMoreElements())
3890 sd::slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement());
3891 if (pDescriptor && pDescriptor->GetPage())
3893 aPagesToDuplicate.push_back(pDescriptor->GetPage());
3894 nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2;
3898 // Duplicate the pages in aPagesToDuplicate and collect the newly
3899 // created pages in aPagesToSelect.
3900 const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled());
3901 if (bUndo)
3902 mrSlideSorter.GetView().BegUndo(SdResId(STR_INSERTPAGE));
3904 ::std::vector<SdPage*> aPagesToSelect;
3905 for(::std::vector<SdPage*>::const_iterator
3906 iPage(aPagesToDuplicate.begin()),
3907 iEnd(aPagesToDuplicate.end());
3908 iPage!=iEnd;
3909 ++iPage, nInsertPosition+=2)
3911 aPagesToSelect.push_back(
3912 mrSlideSorter.GetViewShell()->CreateOrDuplicatePage(
3913 rRequest, PageKind::Standard, *iPage, nInsertPosition));
3915 aPagesToDuplicate.clear();
3917 if (bUndo)
3918 mrSlideSorter.GetView().EndUndo();
3920 // Set the selection to the pages in aPagesToSelect.
3921 sd::slidesorter::controller::PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector());
3922 rSelector.DeselectAllPages();
3923 for (auto const& it: aPagesToSelect)
3925 rSelector.SelectPage(it);
3929 void DrawViewShell::ExecutePropPanelAttr (SfxRequest const & rReq)
3931 if(SlideShow::IsRunning( GetViewShellBase() ))
3932 return;
3934 SdDrawDocument* pDoc = GetDoc();
3935 if (!pDoc || !mpDrawView)
3936 return;
3938 sal_uInt16 nSId = rReq.GetSlot();
3939 SfxItemSet aAttrs( pDoc->GetPool() );
3941 switch ( nSId )
3943 case SID_TABLE_VERT_NONE:
3944 case SID_TABLE_VERT_CENTER:
3945 case SID_TABLE_VERT_BOTTOM:
3946 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP;
3947 if (nSId == SID_TABLE_VERT_CENTER)
3948 eTVA = SDRTEXTVERTADJUST_CENTER;
3949 else if (nSId == SID_TABLE_VERT_BOTTOM)
3950 eTVA = SDRTEXTVERTADJUST_BOTTOM;
3952 aAttrs.Put( SdrTextVertAdjustItem(eTVA) );
3953 mpDrawView->SetAttributes(aAttrs);
3955 break;
3959 void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet)
3961 SfxWhichIter aIter( rSet );
3962 sal_uInt16 nWhich = aIter.FirstWhich();
3964 SdDrawDocument* pDoc = GetDoc();
3965 if (!pDoc || !mpDrawView)
3966 return;
3968 SfxItemSet aAttrs( pDoc->GetPool() );
3969 mpDrawView->GetAttributes( aAttrs );
3971 while ( nWhich )
3973 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich)
3974 ? GetPool().GetSlotId(nWhich)
3975 : nWhich;
3976 switch ( nSlotId )
3978 case SID_TABLE_VERT_NONE:
3979 case SID_TABLE_VERT_CENTER:
3980 case SID_TABLE_VERT_BOTTOM:
3981 bool bContour = false;
3982 SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME );
3983 if( eConState != SfxItemState::DONTCARE )
3985 bContour = aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue();
3987 if (bContour) break;
3989 SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST );
3990 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST );
3992 //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState)
3993 if(SfxItemState::DONTCARE != eVState)
3995 SdrTextVertAdjust eTVA = aAttrs.Get(SDRATTR_TEXT_VERTADJUST).GetValue();
3996 bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) ||
3997 (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) ||
3998 (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM);
3999 rSet.Put(SfxBoolItem(nSlotId, bSet));
4001 else
4003 rSet.Put(SfxBoolItem(nSlotId, false));
4005 break;
4007 nWhich = aIter.NextWhich();
4011 } // end of namespace sd
4013 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */