1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 20 #include <config_features.h> 21 22 #include <avmedia/mediaplayer.hxx> 23 24 #include <basic/sberrors.hxx> 25 #include <basic/sbstar.hxx> 26 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> 37 38 #include <comphelper/processfactory.hxx> 39 #include <comphelper/propertysequence.hxx> 40 #include <comphelper/scopeguard.hxx> 41 #include <comphelper/lok.hxx> 42 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> 51 52 #include <sal/log.hxx> 53 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> 62 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/svdoutl.hxx> 79 #include <svx/svdpagv.hxx> 80 #include <svx/svdundo.hxx> 81 #include <svx/svxdlg.hxx> 82 #include <svx/svxids.hrc> 83 #include <svx/sdtfsitm.hxx> 84 #include <svx/sdmetitm.hxx> 85 #include <svx/xfillit0.hxx> 86 #include <svx/xflclit.hxx> 87 #include <svx/xlineit0.hxx> 88 #include <svx/xlnedwit.hxx> 89 #include <svx/xlnstwit.hxx> 90 #include <svx/xlnwtit.hxx> 91 #include <svx/chrtitem.hxx> 92 #include <svx/xlnclit.hxx> 93 #include <svx/xflgrit.hxx> 94 95 #include <tools/diagnose_ex.h> 96 97 #include <unotools/useroptions.hxx> 98 99 #include <vcl/abstdlg.hxx> 100 #include <vcl/graph.hxx> 101 #include <vcl/svapp.hxx> 102 #include <vcl/unohelp2.hxx> 103 #include <vcl/weld.hxx> 104 105 #include <editeng/cmapitem.hxx> 106 #include <editeng/escapementitem.hxx> 107 #include <editeng/kernitem.hxx> 108 #include <editeng/wghtitem.hxx> 109 #include <editeng/postitem.hxx> 110 #include <editeng/udlnitem.hxx> 111 #include <editeng/crossedoutitem.hxx> 112 #include <editeng/shdditem.hxx> 113 #include <editeng/numitem.hxx> 114 #include <svx/svdobj.hxx> 115 #include <svx/SvxColorChildWindow.hxx> 116 #include <editeng/outlobj.hxx> 117 #include <editeng/flstitem.hxx> 118 #include <editeng/fontitem.hxx> 119 #include <editeng/fhgtitem.hxx> 120 #include <editeng/colritem.hxx> 121 122 #include <svl/poolitem.hxx> 123 #include <svl/style.hxx> 124 #include <svl/whiter.hxx> 125 126 #include <app.hrc> 127 #include <strings.hrc> 128 129 #include <AnimationChildWindow.hxx> 130 #include <DrawDocShell.hxx> 131 #include <DrawViewShell.hxx> 132 #include <LayerTabBar.hxx> 133 #include <Outliner.hxx> 134 #include <ViewShellHint.hxx> 135 #include <ViewShellImplementation.hxx> 136 #include <Window.hxx> 137 #include <drawdoc.hxx> 138 #include <drawview.hxx> 139 #include <fuarea.hxx> 140 #include <fubullet.hxx> 141 #include <fuchar.hxx> 142 #include <fucushow.hxx> 143 #include <fuconnct.hxx> 144 #include <fucopy.hxx> 145 #include <fudspord.hxx> 146 #include <fuexecuteinteraction.hxx> 147 #include <fuexpand.hxx> 148 #include <fuinsert.hxx> 149 #include <fuinsfil.hxx> 150 #include <fuline.hxx> 151 #include <fulinend.hxx> 152 #include <fulink.hxx> 153 #include <fumeasur.hxx> 154 #include <fumorph.hxx> 155 #include <fuoaprms.hxx> 156 #include <fuolbull.hxx> 157 #include <fupage.hxx> 158 #include <fuparagr.hxx> 159 #include <fuprlout.hxx> 160 #include <fuscale.hxx> 161 #include <fusel.hxx> 162 #include <fusldlg.hxx> 163 #include <fusnapln.hxx> 164 #include <fusumry.hxx> 165 #include <futempl.hxx> 166 #include <futhes.hxx> 167 #include <futransf.hxx> 168 #include <futxtatt.hxx> 169 #include <fuvect.hxx> 170 #include <futext.hxx> 171 #include <helpids.h> 172 #include <sdabstdlg.hxx> 173 #include <sdattr.hxx> 174 #include <sdpage.hxx> 175 #include <sdresid.hxx> 176 #include <unokywds.hxx> 177 #include <slideshow.hxx> 178 #include <stlsheet.hxx> 179 #include <undolayer.hxx> 180 #include <sfx2/sidebar/Sidebar.hxx> 181 #include <sfx2/classificationhelper.hxx> 182 #include <sdmod.hxx> 183 #include <model/SlsPageEnumerationProvider.hxx> 184 #include <SlideSorter.hxx> 185 #include <SlideSorterViewShell.hxx> 186 #include <controller/SlideSorterController.hxx> 187 #include <model/SlideSorterModel.hxx> 188 #include <controller/SlsSelectionManager.hxx> 189 #include <controller/SlsInsertionIndicatorHandler.hxx> 190 #include <controller/SlsPageSelector.hxx> 191 192 #include <ViewShellBase.hxx> 193 #include <memory> 194 195 using namespace ::com::sun::star; 196 using namespace ::com::sun::star::uno; 197 198 #define MIN_ACTIONS_FOR_DIALOG 5000 ///< if there are more meta objects, we show a dialog during the break up 199 200 namespace sd { 201 202 namespace { 203 204 const SvxFieldItem* findField(editeng::Section const & rSection) 205 { 206 for (SfxPoolItem const * pPool: rSection.maAttributes) 207 { 208 if (pPool->Which() == EE_FEATURE_FIELD) 209 return static_cast<const SvxFieldItem*>(pPool); 210 } 211 return nullptr; 212 } 213 214 bool hasCustomPropertyField(std::vector<editeng::Section> const & aSections, OUString const & rName) 215 { 216 for (editeng::Section const & rSection : aSections) 217 { 218 const SvxFieldItem* pFieldItem = findField(rSection); 219 if (pFieldItem) 220 { 221 const editeng::CustomPropertyField* pCustomPropertyField = dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField()); 222 if (pCustomPropertyField && pCustomPropertyField->GetName() == rName) 223 return true; 224 } 225 } 226 return false; 227 } 228 229 OUString getWeightString(SfxItemSet const & rItemSet) 230 { 231 OUString sWeightString = "NORMAL"; 232 233 if (const SfxPoolItem* pItem = rItemSet.GetItem(EE_CHAR_WEIGHT, false)) 234 { 235 const SvxWeightItem* pWeightItem = dynamic_cast<const SvxWeightItem*>(pItem); 236 if (pWeightItem && pWeightItem->GetWeight() == WEIGHT_BOLD) 237 sWeightString = "BOLD"; 238 } 239 return sWeightString; 240 } 241 242 class ClassificationCommon 243 { 244 protected: 245 sd::DrawViewShell& m_rDrawViewShell; 246 uno::Reference<document::XDocumentProperties> m_xDocumentProperties; 247 uno::Reference<beans::XPropertyContainer> m_xPropertyContainer; 248 sfx::ClassificationKeyCreator m_aKeyCreator; 249 public: 250 ClassificationCommon(sd::DrawViewShell & rDrawViewShell) 251 : m_rDrawViewShell(rDrawViewShell) 252 , m_xDocumentProperties(SfxObjectShell::Current()->getDocProperties()) 253 , m_xPropertyContainer(m_xDocumentProperties->getUserDefinedProperties()) 254 , m_aKeyCreator(SfxClassificationHelper::getPolicyType()) 255 {} 256 }; 257 258 class ClassificationCollector : public ClassificationCommon 259 { 260 private: 261 std::vector<svx::ClassificationResult> m_aResults; 262 263 void iterateSectionsAndCollect(std::vector<editeng::Section> const & rSections, EditTextObject const & rEditText) 264 { 265 sal_Int32 nCurrentParagraph = -1; 266 OUString sBlank; 267 268 for (editeng::Section const & rSection : rSections) 269 { 270 // Insert new paragraph if needed 271 while (nCurrentParagraph < rSection.mnParagraph) 272 { 273 nCurrentParagraph++; 274 // Get Weight of current paragraph 275 OUString sWeightProperty = getWeightString(rEditText.GetParaAttribs(nCurrentParagraph)); 276 // Insert new paragraph into collection 277 m_aResults.push_back({ svx::ClassificationType::PARAGRAPH, sWeightProperty, sBlank, sBlank }); 278 } 279 280 const SvxFieldItem* pFieldItem = findField(rSection); 281 const editeng::CustomPropertyField* pCustomPropertyField = pFieldItem ? 282 dynamic_cast<const editeng::CustomPropertyField*>(pFieldItem->GetField()) : 283 nullptr; 284 if (pCustomPropertyField) 285 { 286 const OUString& aKey = pCustomPropertyField->GetName(); 287 if (m_aKeyCreator.isMarkingTextKey(aKey)) 288 { 289 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); 290 m_aResults.push_back({ svx::ClassificationType::TEXT, aValue, sBlank, sBlank }); 291 } 292 else if (m_aKeyCreator.isCategoryNameKey(aKey) || m_aKeyCreator.isCategoryIdentifierKey(aKey)) 293 { 294 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); 295 m_aResults.push_back({ svx::ClassificationType::CATEGORY, aValue, sBlank, sBlank }); 296 } 297 else if (m_aKeyCreator.isMarkingKey(aKey)) 298 { 299 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); 300 m_aResults.push_back({ svx::ClassificationType::MARKING, aValue, sBlank, sBlank }); 301 } 302 else if (m_aKeyCreator.isIntellectualPropertyPartKey(aKey)) 303 { 304 OUString aValue = svx::classification::getProperty(m_xPropertyContainer, aKey); 305 m_aResults.push_back({ svx::ClassificationType::INTELLECTUAL_PROPERTY_PART, aValue, sBlank, sBlank }); 306 } 307 } 308 } 309 } 310 311 public: 312 ClassificationCollector(sd::DrawViewShell & rDrawViewShell) 313 : ClassificationCommon(rDrawViewShell) 314 {} 315 316 std::vector<svx::ClassificationResult> const & getResults() const 317 { 318 return m_aResults; 319 } 320 321 void collect() 322 { 323 // Set to MASTER mode 324 EditMode eOldMode = m_rDrawViewShell.GetEditMode(); 325 if (eOldMode != EditMode::MasterPage) 326 m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false); 327 328 // Scoped guard to revert to the previous mode 329 comphelper::ScopeGuard const aGuard([this, eOldMode] () { 330 m_rDrawViewShell.ChangeEditMode(eOldMode, false); 331 }); 332 333 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); 334 335 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) 336 { 337 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); 338 for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) 339 { 340 SdrObject* pObject = pMasterPage->GetObj(nObject); 341 SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); 342 if (pRectObject && pRectObject->GetTextKind() == OBJ_TEXT) 343 { 344 OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); 345 if (pOutlinerParagraphObject) 346 { 347 const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject(); 348 std::vector<editeng::Section> aSections; 349 rEditText.GetAllSections(aSections); 350 351 // Search for a custom property field that has the classification category identifier key 352 if (hasCustomPropertyField(aSections, m_aKeyCreator.makeCategoryNameKey())) 353 { 354 iterateSectionsAndCollect(aSections, rEditText); 355 return; 356 } 357 } 358 } 359 } 360 } 361 } 362 }; 363 364 class ClassificationInserter : public ClassificationCommon 365 { 366 private: 367 /// Delete the previous existing classification object(s) - if they exist 368 void deleteExistingObjects() 369 { 370 OUString sKey = m_aKeyCreator.makeCategoryNameKey(); 371 372 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); 373 374 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) 375 { 376 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); 377 for (size_t nObject = 0; nObject < pMasterPage->GetObjCount(); ++nObject) 378 { 379 SdrObject* pObject = pMasterPage->GetObj(nObject); 380 SdrRectObj* pRectObject = dynamic_cast<SdrRectObj*>(pObject); 381 if (pRectObject && pRectObject->GetTextKind() == OBJ_TEXT) 382 { 383 OutlinerParaObject* pOutlinerParagraphObject = pRectObject->GetOutlinerParaObject(); 384 if (pOutlinerParagraphObject) 385 { 386 const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject(); 387 std::vector<editeng::Section> aSections; 388 rEditText.GetAllSections(aSections); 389 390 if (hasCustomPropertyField(aSections, sKey)) 391 { 392 pMasterPage->RemoveObject(pRectObject->GetOrdNum()); 393 } 394 } 395 } 396 } 397 } 398 } 399 400 void fillTheOutliner(Outliner* pOutliner, std::vector<svx::ClassificationResult> const & rResults) 401 { 402 sal_Int32 nParagraph = -1; 403 for (svx::ClassificationResult const & rResult : rResults) 404 { 405 406 ESelection aPosition(nParagraph, EE_TEXTPOS_MAX_COUNT, nParagraph, EE_TEXTPOS_MAX_COUNT); 407 408 switch (rResult.meType) 409 { 410 case svx::ClassificationType::TEXT: 411 { 412 OUString sKey = m_aKeyCreator.makeNumberedTextKey(); 413 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); 414 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); 415 } 416 break; 417 418 case svx::ClassificationType::CATEGORY: 419 { 420 OUString sKey = m_aKeyCreator.makeCategoryNameKey(); 421 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); 422 } 423 break; 424 425 case svx::ClassificationType::MARKING: 426 { 427 OUString sKey = m_aKeyCreator.makeNumberedMarkingKey(); 428 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); 429 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); 430 } 431 break; 432 433 case svx::ClassificationType::INTELLECTUAL_PROPERTY_PART: 434 { 435 OUString sKey = m_aKeyCreator.makeNumberedIntellectualPropertyPartKey(); 436 svx::classification::addOrInsertDocumentProperty(m_xPropertyContainer, sKey, rResult.msName); 437 pOutliner->QuickInsertField(SvxFieldItem(editeng::CustomPropertyField(sKey, rResult.msName), EE_FEATURE_FIELD), aPosition); 438 } 439 break; 440 441 case svx::ClassificationType::PARAGRAPH: 442 { 443 nParagraph++; 444 pOutliner->Insert(""); 445 446 SfxItemSet aItemSet(m_rDrawViewShell.GetDoc()->GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{}); 447 448 if (rResult.msName == "BOLD") 449 aItemSet.Put(SvxWeightItem(WEIGHT_BOLD, EE_CHAR_WEIGHT)); 450 else 451 aItemSet.Put(SvxWeightItem(WEIGHT_NORMAL, EE_CHAR_WEIGHT)); 452 453 SvxNumRule aDefaultNumRule(SvxNumRuleFlags::NONE, 0, false); 454 aItemSet.Put(SvxNumBulletItem(aDefaultNumRule, EE_PARA_NUMBULLET)); 455 456 pOutliner->SetParaAttribs(nParagraph, aItemSet); 457 } 458 break; 459 460 default: 461 break; 462 } 463 } 464 } 465 466 public: 467 ClassificationInserter(sd::DrawViewShell & rDrawViewShell) 468 : ClassificationCommon(rDrawViewShell) 469 { 470 } 471 472 void insert(std::vector<svx::ClassificationResult> const & rResults) 473 { 474 // Set to MASTER mode 475 EditMode eOldMode = m_rDrawViewShell.GetEditMode(); 476 if (eOldMode != EditMode::MasterPage) 477 m_rDrawViewShell.ChangeEditMode(EditMode::MasterPage, false); 478 479 // Scoped guard to revert the mode 480 comphelper::ScopeGuard const aGuard([this, eOldMode] () { 481 m_rDrawViewShell.ChangeEditMode(eOldMode, false); 482 }); 483 484 // Delete the previous existing object - if exists 485 deleteExistingObjects(); 486 487 // Clear properties 488 svx::classification::removeAllProperties(m_xPropertyContainer); 489 490 SfxClassificationHelper aHelper(m_xDocumentProperties); 491 492 // Apply properties from the BA policy 493 for (svx::ClassificationResult const & rResult : rResults) 494 { 495 if (rResult.meType == svx::ClassificationType::CATEGORY) 496 aHelper.SetBACName(rResult.msName, SfxClassificationHelper::getPolicyType()); 497 } 498 499 // Insert full text as document property 500 svx::classification::insertFullTextualRepresentationAsDocumentProperty(m_xPropertyContainer, m_aKeyCreator, rResults); 501 502 // Create the outliner from the 503 Outliner* pOutliner = m_rDrawViewShell.GetDoc()->GetInternalOutliner(); 504 OutlinerMode eOutlinerMode = pOutliner->GetMode(); 505 506 comphelper::ScopeGuard const aOutlinerGuard([pOutliner, eOutlinerMode] () { 507 pOutliner->Init(eOutlinerMode); 508 }); 509 510 pOutliner->Init(OutlinerMode::TextObject); 511 512 // Fill the outliner with the text from classification result 513 fillTheOutliner(pOutliner, rResults); 514 515 // Calculate to outliner text size 516 pOutliner->UpdateFields(); 517 pOutliner->SetUpdateMode(true); 518 Size aTextSize(pOutliner->CalcTextSize()); 519 pOutliner->SetUpdateMode(false); 520 521 // Create objects, apply the outliner and add them (objects) to all master pages 522 const sal_uInt16 nCount = m_rDrawViewShell.GetDoc()->GetMasterSdPageCount(PageKind::Standard); 523 524 for (sal_uInt16 nPageIndex = 0; nPageIndex < nCount; ++nPageIndex) 525 { 526 SdPage* pMasterPage = m_rDrawViewShell.GetDoc()->GetMasterSdPage(nPageIndex, PageKind::Standard); 527 if (!pMasterPage) 528 continue; 529 530 SdrRectObj* pObject = new SdrRectObj( 531 *m_rDrawViewShell.GetDoc(), // TTTT should be reference 532 OBJ_TEXT); 533 pObject->SetMergedItem(makeSdrTextAutoGrowWidthItem(true)); 534 pObject->SetOutlinerParaObject(pOutliner->CreateParaObject()); 535 pMasterPage->InsertObject(pObject); 536 537 // Calculate position 538 ::tools::Rectangle aRectangle(Point(), pMasterPage->GetSize()); 539 Point aPosition(aRectangle.Center().X(), aRectangle.Bottom()); 540 541 aPosition.AdjustX( -(aTextSize.Width() / 2) ); 542 aPosition.AdjustY( -(aTextSize.Height()) ); 543 544 pObject->SetLogicRect(::tools::Rectangle(aPosition, aTextSize)); 545 } 546 } 547 }; 548 549 void lcl_convertStringArguments(sal_uInt16 nSlot, std::unique_ptr<SfxItemSet>& pArgs) 550 { 551 Color aColor; 552 OUString sColor; 553 const SfxPoolItem* pItem = nullptr; 554 555 if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_LINE_WIDTH_ARG, false, &pItem)) 556 { 557 double fValue = static_cast<const SvxDoubleItem*>(pItem)->GetValue(); 558 // FIXME: different units... 559 int nPow = 100; 560 int nValue = fValue * nPow; 561 562 XLineWidthItem aItem(nValue); 563 pArgs->Put(aItem); 564 } 565 if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_COLOR_STR, false, &pItem)) 566 { 567 sColor = static_cast<const SfxStringItem*>(pItem)->GetValue(); 568 569 if (sColor == "transparent") 570 aColor = COL_TRANSPARENT; 571 else 572 aColor = Color(sColor.toInt32(16)); 573 574 switch (nSlot) 575 { 576 case SID_ATTR_LINE_COLOR: 577 { 578 XLineColorItem aLineColorItem(OUString(), aColor); 579 pArgs->Put(aLineColorItem); 580 break; 581 } 582 583 case SID_ATTR_FILL_COLOR: 584 { 585 XFillColorItem aFillColorItem(OUString(), aColor); 586 pArgs->Put(aFillColorItem); 587 break; 588 } 589 } 590 } 591 if (SfxItemState::SET == pArgs->GetItemState(SID_FILL_GRADIENT_JSON, false, &pItem)) 592 { 593 const SfxStringItem* pJSON = static_cast<const SfxStringItem*>(pItem); 594 if (pJSON) 595 { 596 XGradient aGradient = XGradient::fromJSON(pJSON->GetValue()); 597 XFillGradientItem aItem(aGradient); 598 pArgs->Put(aItem); 599 } 600 } 601 } 602 } 603 604 /** 605 * SfxRequests for temporary actions 606 */ 607 608 void DrawViewShell::FuTemporary(SfxRequest& rReq) 609 { 610 // during a native slide show nothing gets executed! 611 if(SlideShow::IsRunning( GetViewShellBase() ) && (rReq.GetSlot() != SID_NAVIGATOR)) 612 return; 613 614 DBG_ASSERT( mpDrawView, "sd::DrawViewShell::FuTemporary(), no draw view!" ); 615 if( !mpDrawView ) 616 return; 617 618 CheckLineTo (rReq); 619 620 DeactivateCurrentFunction(); 621 622 sal_uInt16 nSId = rReq.GetSlot(); 623 624 switch ( nSId ) 625 { 626 case SID_OUTLINE_TEXT_AUTOFIT: 627 { 628 SfxUndoManager* pUndoManager = GetDocSh()->GetUndoManager(); 629 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 630 if( rMarkList.GetMarkCount() == 1 ) 631 { 632 pUndoManager->EnterListAction("", "", 0, GetViewShellBase().GetViewShellId()); 633 mpDrawView->BegUndo(); 634 635 SdrObject* pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); 636 bool bSet = pObj->GetMergedItemSet().GetItem<SdrTextFitToSizeTypeItem>(SDRATTR_TEXT_FITTOSIZE)->GetValue() != drawing::TextFitToSizeType_NONE; 637 638 mpDrawView->AddUndo(GetDoc()->GetSdrUndoFactory().CreateUndoAttrObject(*pObj)); 639 640 if (!bSet) 641 { 642 //If we are turning on AutoFit we have to turn these off if already on 643 if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWHEIGHT)->GetValue()) 644 pObj->SetMergedItem(makeSdrTextAutoGrowHeightItem(false)); 645 if (pObj->GetMergedItemSet().GetItem<SdrOnOffItem>(SDRATTR_TEXT_AUTOGROWWIDTH)->GetValue()) 646 pObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(false)); 647 } 648 649 pObj->SetMergedItem(SdrTextFitToSizeTypeItem(bSet ? drawing::TextFitToSizeType_NONE : drawing::TextFitToSizeType_AUTOFIT)); 650 651 mpDrawView->EndUndo(); 652 pUndoManager->LeaveListAction(); 653 } 654 Cancel(); 655 rReq.Done(); 656 } 657 break; 658 659 // area and line attributes: shall have 660 // an own Execute method (like StateMethode) 661 case SID_ATTR_FILL_STYLE: 662 case SID_ATTR_FILL_COLOR: 663 case SID_ATTR_FILL_GRADIENT: 664 case SID_ATTR_FILL_HATCH: 665 case SID_ATTR_FILL_BITMAP: 666 case SID_ATTR_FILL_SHADOW: 667 case SID_ATTR_SHADOW_COLOR: 668 case SID_ATTR_SHADOW_TRANSPARENCE: 669 case SID_ATTR_SHADOW_XDISTANCE: 670 case SID_ATTR_SHADOW_YDISTANCE: 671 case SID_ATTR_FILL_TRANSPARENCE: 672 case SID_ATTR_FILL_FLOATTRANSPARENCE: 673 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: 684 685 case SID_ATTR_TEXT_FITTOSIZE: 686 { 687 if( rReq.GetArgs() ) 688 { 689 std::unique_ptr<SfxItemSet> pNewArgs = rReq.GetArgs()->Clone(); 690 lcl_convertStringArguments(rReq.GetSlot(), pNewArgs); 691 mpDrawView->SetAttributes(*pNewArgs); 692 rReq.Done(); 693 } 694 else 695 { 696 switch( rReq.GetSlot() ) 697 { 698 case SID_ATTR_FILL_SHADOW: 699 case SID_ATTR_SHADOW_COLOR: 700 case SID_ATTR_SHADOW_TRANSPARENCE: 701 case SID_ATTR_SHADOW_XDISTANCE: 702 case SID_ATTR_SHADOW_YDISTANCE: 703 case SID_ATTR_FILL_STYLE: 704 case SID_ATTR_FILL_COLOR: 705 case SID_ATTR_FILL_GRADIENT: 706 case SID_ATTR_FILL_HATCH: 707 case SID_ATTR_FILL_BITMAP: 708 case SID_ATTR_FILL_TRANSPARENCE: 709 case SID_ATTR_FILL_FLOATTRANSPARENCE: 710 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_AREA, SfxCallMode::ASYNCHRON ); 711 break; 712 case SID_ATTR_LINE_STYLE: 713 case SID_ATTR_LINE_DASH: 714 case SID_ATTR_LINE_WIDTH: 715 case SID_ATTR_LINE_COLOR: 716 case SID_ATTR_LINE_TRANSPARENCE: 717 case SID_ATTR_LINE_JOINT: 718 case SID_ATTR_LINE_CAP: 719 GetViewFrame()->GetDispatcher()->Execute( SID_ATTRIBUTES_LINE, SfxCallMode::ASYNCHRON ); 720 break; 721 case SID_ATTR_TEXT_FITTOSIZE: 722 GetViewFrame()->GetDispatcher()->Execute( SID_TEXTATTR_DLG, SfxCallMode::ASYNCHRON ); 723 break; 724 } 725 } 726 Cancel(); 727 } 728 break; 729 730 case SID_HYPHENATION: 731 { 732 const SfxBoolItem* pItem = rReq.GetArg<SfxBoolItem>(SID_HYPHENATION); 733 734 if( pItem ) 735 { 736 SfxItemSet aSet( GetPool(), svl::Items<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE>{} ); 737 bool bValue = pItem->GetValue(); 738 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, bValue ) ); 739 mpDrawView->SetAttributes( aSet ); 740 } 741 else // only for testing purpose 742 { 743 OSL_FAIL(" no value for hyphenation!"); 744 SfxItemSet aSet( GetPool(), svl::Items<EE_PARA_HYPHENATE, EE_PARA_HYPHENATE>{} ); 745 aSet.Put( SfxBoolItem( EE_PARA_HYPHENATE, true ) ); 746 mpDrawView->SetAttributes( aSet ); 747 } 748 rReq.Done(); 749 Cancel(); 750 } 751 break; 752 753 case SID_INSERTPAGE: 754 case SID_INSERTPAGE_QUICK: 755 { 756 SdPage* pNewPage = CreateOrDuplicatePage (rReq, mePageKind, GetActualPage()); 757 Cancel(); 758 if(HasCurrentFunction(SID_BEZIER_EDIT) ) 759 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 760 if (pNewPage != nullptr) 761 SwitchPage((pNewPage->GetPageNum()-1)/2); 762 rReq.Done (); 763 } 764 break; 765 766 case SID_DUPLICATE_PAGE: 767 { 768 DuplicateSelectedSlides(rReq); 769 Cancel(); 770 if(HasCurrentFunction(SID_BEZIER_EDIT) ) 771 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 772 rReq.Done(); 773 } 774 break; 775 776 case SID_INSERT_MASTER_PAGE: 777 { 778 // Use the API to create a new page. 779 Reference<drawing::XMasterPagesSupplier> xMasterPagesSupplier ( 780 GetDoc()->getUnoModel(), UNO_QUERY); 781 if (xMasterPagesSupplier.is()) 782 { 783 Reference<drawing::XDrawPages> xMasterPages ( 784 xMasterPagesSupplier->getMasterPages()); 785 if (xMasterPages.is()) 786 { 787 sal_uInt16 nIndex = GetCurPagePos() + 1; 788 xMasterPages->insertNewByIndex (nIndex); 789 790 // Create shapes for the default layout. 791 SdPage* pMasterPage = GetDoc()->GetMasterSdPage( 792 nIndex, PageKind::Standard); 793 pMasterPage->CreateTitleAndLayout (true,true); 794 } 795 } 796 797 Cancel(); 798 if(HasCurrentFunction(SID_BEZIER_EDIT)) 799 GetViewFrame()->GetDispatcher()->Execute( 800 SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 801 rReq.Done (); 802 } 803 break; 804 805 case SID_MODIFYPAGE: 806 { 807 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes || 808 (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage) ) 809 { 810 if ( mpDrawView->IsTextEdit() ) 811 { 812 mpDrawView->SdrEndTextEdit(); 813 } 814 sal_uInt16 nPage = maTabControl->GetCurPagePos(); 815 mpActualPage = GetDoc()->GetSdPage(nPage, mePageKind); 816 ::sd::ViewShell::mpImpl->ProcessModifyPageSlot ( 817 rReq, 818 mpActualPage, 819 mePageKind); 820 } 821 822 Cancel(); 823 rReq.Done (); 824 } 825 break; 826 827 case SID_ASSIGN_LAYOUT: 828 { 829 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes || (mePageKind==PageKind::Handout && meEditMode==EditMode::MasterPage)) 830 { 831 if ( mpDrawView->IsTextEdit() ) 832 mpDrawView->SdrEndTextEdit(); 833 834 ::sd::ViewShell::mpImpl->AssignLayout(rReq, mePageKind); 835 } 836 Cancel(); 837 rReq.Done (); 838 } 839 break; 840 841 case SID_RENAMEPAGE: 842 case SID_RENAME_MASTER_PAGE: 843 { 844 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes ) 845 { 846 if ( mpDrawView->IsTextEdit() ) 847 { 848 mpDrawView->SdrEndTextEdit(); 849 } 850 851 sal_uInt16 nPage = maTabControl->GetCurPagePos(); 852 SdPage* pCurrentPage = ( GetEditMode() == EditMode::Page ) 853 ? GetDoc()->GetSdPage( nPage, GetPageKind() ) 854 : GetDoc()->GetMasterSdPage( nPage, GetPageKind() ); 855 856 OUString aTitle = SdResId(STR_TITLE_RENAMESLIDE); 857 OUString aDescr = SdResId(STR_DESC_RENAMESLIDE); 858 const OUString& aPageName = pCurrentPage->GetName(); 859 860 if(rReq.GetArgs()) 861 { 862 OUString aName = rReq.GetArgs()->GetItem<const SfxStringItem>(SID_RENAMEPAGE)->GetValue(); 863 864 bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aName ); 865 DBG_ASSERT( bResult, "Couldn't rename slide" ); 866 } 867 else 868 { 869 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 870 ScopedVclPtr<AbstractSvxNameDialog> aNameDlg(pFact->CreateSvxNameDialog(GetFrameWeld(), aPageName, aDescr)); 871 aNameDlg->SetText( aTitle ); 872 aNameDlg->SetCheckNameHdl( LINK( this, DrawViewShell, RenameSlideHdl ), true ); 873 aNameDlg->SetEditHelpId( HID_SD_NAMEDIALOG_PAGE ); 874 875 if( aNameDlg->Execute() == RET_OK ) 876 { 877 OUString aNewName; 878 aNameDlg->GetName( aNewName ); 879 if (aNewName != aPageName) 880 { 881 bool bResult = RenameSlide( maTabControl->GetPageId(nPage), aNewName ); 882 DBG_ASSERT( bResult, "Couldn't rename slide" ); 883 } 884 } 885 } 886 } 887 Cancel(); 888 rReq.Ignore(); 889 } 890 break; 891 892 case SID_RENAMEPAGE_QUICK: 893 { 894 if (mePageKind==PageKind::Standard || mePageKind==PageKind::Notes ) 895 { 896 if ( mpDrawView->IsTextEdit() ) 897 { 898 mpDrawView->SdrEndTextEdit(); 899 } 900 901 maTabControl->StartEditMode( maTabControl->GetCurPageId() ); 902 } 903 904 Cancel(); 905 rReq.Ignore (); 906 } 907 break; 908 909 case SID_PAGESIZE : // either this (no menu entries or something else!) 910 { 911 const SfxItemSet *pArgs = rReq.GetArgs (); 912 913 if (pArgs && pArgs->Count () == 3) 914 { 915 const SfxUInt32Item* pWidth = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEWIDTH); 916 const SfxUInt32Item* pHeight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEHEIGHT); 917 const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS); 918 919 Size aSize (pWidth->GetValue (), pHeight->GetValue ()); 920 921 SetupPage (aSize, 0, 0, 0, 0, true, false, pScaleAll->GetValue ()); 922 rReq.Ignore (); 923 break; 924 } 925 #if HAVE_FEATURE_SCRIPTING 926 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS); 927 #endif 928 rReq.Ignore (); 929 break; 930 } 931 932 case SID_PAGEMARGIN : // or this (no menu entries or something else!) 933 { 934 const SfxItemSet *pArgs = rReq.GetArgs (); 935 936 if (pArgs && pArgs->Count () == 5) 937 { 938 const SfxUInt32Item* pLeft = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGELEFT); 939 const SfxUInt32Item* pRight = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGERIGHT); 940 const SfxUInt32Item* pUpper = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGETOP); 941 const SfxUInt32Item* pLower = rReq.GetArg<SfxUInt32Item>(ID_VAL_PAGEBOTTOM); 942 const SfxBoolItem* pScaleAll = rReq.GetArg<SfxBoolItem>(ID_VAL_SCALEOBJECTS); 943 944 Size aEmptySize (0, 0); 945 946 SetupPage (aEmptySize, pLeft->GetValue (), pRight->GetValue (), 947 pUpper->GetValue (), pLower->GetValue (), 948 false, true, pScaleAll->GetValue ()); 949 rReq.Ignore (); 950 break; 951 } 952 #if HAVE_FEATURE_SCRIPTING 953 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS); 954 #endif 955 rReq.Ignore (); 956 break; 957 } 958 959 case SID_ATTR_ZOOMSLIDER: 960 { 961 const SfxItemSet* pArgs = rReq.GetArgs(); 962 963 const SfxUInt16Item* pScale = (pArgs && pArgs->Count () == 1) ? 964 rReq.GetArg<SfxUInt16Item>(SID_ATTR_ZOOMSLIDER) : nullptr; 965 if (pScale && CHECK_RANGE (5, pScale->GetValue (), 3000)) 966 { 967 SetZoom (pScale->GetValue ()); 968 969 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 970 rBindings.Invalidate( SID_ATTR_ZOOM ); 971 rBindings.Invalidate( SID_ZOOM_IN ); 972 rBindings.Invalidate( SID_ZOOM_OUT ); 973 rBindings.Invalidate( SID_ATTR_ZOOMSLIDER ); 974 975 } 976 977 Cancel(); 978 rReq.Done (); 979 break; 980 } 981 982 case SID_ATTR_ZOOM: 983 { 984 const SfxItemSet* pArgs = rReq.GetArgs(); 985 mbZoomOnPage = false; 986 987 if ( pArgs ) 988 { 989 SvxZoomType eZT = pArgs->Get( SID_ATTR_ZOOM ).GetType(); 990 switch( eZT ) 991 { 992 case SvxZoomType::PERCENT: 993 SetZoom( static_cast<long>( pArgs->Get( SID_ATTR_ZOOM ).GetValue()) ); 994 break; 995 996 case SvxZoomType::OPTIMAL: 997 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_ALL, 998 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); 999 break; 1000 1001 case SvxZoomType::PAGEWIDTH: 1002 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE_WIDTH, 1003 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); 1004 break; 1005 1006 case SvxZoomType::WHOLEPAGE: 1007 GetViewFrame()->GetDispatcher()->Execute( SID_SIZE_PAGE, 1008 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD ); 1009 break; 1010 case SvxZoomType::PAGEWIDTH_NOBORDER: 1011 OSL_FAIL("sd::DrawViewShell::FuTemporary(), SvxZoomType::PAGEWIDTH_NOBORDER not handled!" ); 1012 break; 1013 } 1014 rReq.Ignore (); 1015 } 1016 else 1017 { 1018 // open zoom dialog 1019 SetCurrentFunction( FuScale::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1020 } 1021 Cancel(); 1022 } 1023 break; 1024 1025 case SID_CHANGEBEZIER: 1026 case SID_CHANGEPOLYGON: 1027 if ( mpDrawView->IsTextEdit() ) 1028 { 1029 mpDrawView->SdrEndTextEdit(); 1030 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 1031 } 1032 1033 if ( mpDrawView->IsPresObjSelected() ) 1034 { 1035 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 1036 VclMessageType::Info, VclButtonsType::Ok, 1037 SdResId(STR_ACTION_NOTPOSSIBLE))); 1038 xInfoBox->run(); 1039 } 1040 else 1041 { 1042 if( rReq.GetSlot() == SID_CHANGEBEZIER ) 1043 { 1044 weld::WaitObject aWait(GetFrameWeld()); 1045 mpDrawView->ConvertMarkedToPathObj(false); 1046 } 1047 else 1048 { 1049 if( mpDrawView->IsVectorizeAllowed() ) 1050 { 1051 SetCurrentFunction( FuVectorize::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1052 } 1053 else 1054 { 1055 weld::WaitObject aWait(GetFrameWeld()); 1056 mpDrawView->ConvertMarkedToPolyObj(); 1057 } 1058 } 1059 1060 Invalidate(SID_CHANGEBEZIER); 1061 Invalidate(SID_CHANGEPOLYGON); 1062 } 1063 Cancel(); 1064 1065 if( HasCurrentFunction(SID_BEZIER_EDIT) ) 1066 { // where applicable, activate right edit action 1067 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCH_POINTEDIT, 1068 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); 1069 } 1070 rReq.Ignore (); 1071 break; 1072 1073 case SID_CONVERT_TO_CONTOUR: 1074 if ( mpDrawView->IsTextEdit() ) 1075 { 1076 mpDrawView->SdrEndTextEdit(); 1077 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 1078 } 1079 1080 if ( mpDrawView->IsPresObjSelected() ) 1081 { 1082 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 1083 VclMessageType::Info, VclButtonsType::Ok, 1084 SdResId(STR_ACTION_NOTPOSSIBLE))); 1085 xInfoBox->run(); 1086 } 1087 else 1088 { 1089 weld::WaitObject aWait(GetFrameWeld()); 1090 mpDrawView->ConvertMarkedToPathObj(true); 1091 1092 Invalidate(SID_CONVERT_TO_CONTOUR); 1093 } 1094 Cancel(); 1095 1096 rReq.Ignore (); 1097 break; 1098 1099 case SID_CONVERT_TO_METAFILE: 1100 case SID_CONVERT_TO_BITMAP: 1101 { 1102 // End text edit mode when it is active because the metafile or 1103 // bitmap that will be created does not support it. 1104 if ( mpDrawView->IsTextEdit() ) 1105 { 1106 mpDrawView->SdrEndTextEdit(); 1107 GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON); 1108 } 1109 1110 if ( mpDrawView->IsPresObjSelected(true,true,true) ) 1111 { 1112 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 1113 VclMessageType::Info, VclButtonsType::Ok, 1114 SdResId(STR_ACTION_NOTPOSSIBLE))); 1115 xInfoBox->run(); 1116 } 1117 else 1118 { 1119 weld::WaitObject aWait(GetFrameWeld()); 1120 1121 // create SdrGrafObj from metafile/bitmap 1122 Graphic aGraphic; 1123 switch (nSId) 1124 { 1125 case SID_CONVERT_TO_METAFILE: 1126 { 1127 // switch on undo for the next operations 1128 mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_METAFILE)); 1129 GDIMetaFile aMetaFile(mpDrawView->GetMarkedObjMetaFile()); 1130 aGraphic = Graphic(aMetaFile); 1131 } 1132 break; 1133 case SID_CONVERT_TO_BITMAP: 1134 { 1135 // Disable spelling during conversion 1136 bool bOnlineSpell = GetDoc()->GetOnlineSpell(); 1137 GetDoc()->SetOnlineSpell(false); 1138 1139 // switch on undo for the next operations 1140 mpDrawView->BegUndo(SdResId(STR_UNDO_CONVERT_TO_BITMAP)); 1141 bool bDone(false); 1142 1143 // I have to get the image here directly since GetMarkedObjBitmapEx works 1144 // based on Bitmaps, but not on BitmapEx, thus throwing away the alpha 1145 // channel. Argh! GetMarkedObjBitmapEx itself is too widely used to safely 1146 // change that, e.g. in the exchange formats. For now I can only add this 1147 // exception to get good results for Svgs. This is how the code gets more 1148 // and more crowded, at last I made a remark for myself to change this 1149 // as one of the next tasks. 1150 if(1 == mpDrawView->GetMarkedObjectCount()) 1151 { 1152 const SdrGrafObj* pSdrGrafObj = dynamic_cast< const SdrGrafObj* >(mpDrawView->GetMarkedObjectByIndex(0)); 1153 1154 if(pSdrGrafObj && pSdrGrafObj->isEmbeddedVectorGraphicData()) 1155 { 1156 aGraphic = Graphic(pSdrGrafObj->GetGraphic().getVectorGraphicData()->getReplacement()); 1157 bDone = true; 1158 } 1159 } 1160 1161 if(!bDone) 1162 { 1163 aGraphic = Graphic(mpDrawView->GetMarkedObjBitmapEx()); 1164 } 1165 // Restore online spelling 1166 GetDoc()->SetOnlineSpell(bOnlineSpell); 1167 } 1168 break; 1169 } 1170 1171 // create new object 1172 SdrGrafObj* pGraphicObj = new SdrGrafObj( 1173 *GetDoc(), 1174 aGraphic); 1175 1176 // get some necessary info and ensure it 1177 const SdrMarkList& rMarkList(mpDrawView->GetMarkedObjectList()); 1178 const size_t nMarkCount(rMarkList.GetMarkCount()); 1179 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1180 OSL_ENSURE(nMarkCount, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP with empty selection (!)"); 1181 OSL_ENSURE(pPageView, "DrawViewShell::FuTemporary: SID_CONVERT_TO_BITMAP without SdrPageView (!)"); 1182 1183 // fit rectangle of new graphic object to selection's mark rect 1184 ::tools::Rectangle aAllMarkedRect; 1185 rMarkList.TakeBoundRect(pPageView, aAllMarkedRect); 1186 pGraphicObj->SetLogicRect(aAllMarkedRect); 1187 1188 // #i71540# to keep the order, it is necessary to replace the lowest object 1189 // of the selection with the new object. This also means that with multi 1190 // selection, all other objects need to be deleted first 1191 SdrMark* pFirstMark = rMarkList.GetMark(0); 1192 SdrObject* pReplacementCandidate = pFirstMark->GetMarkedSdrObj(); 1193 1194 if(nMarkCount > 1) 1195 { 1196 // take first object out of selection 1197 mpDrawView->MarkObj(pReplacementCandidate, pPageView, true, true); 1198 1199 // clear remaining selection 1200 mpDrawView->DeleteMarkedObj(); 1201 } 1202 1203 // #i124816# copy layer from lowest object which gets replaced 1204 pGraphicObj->SetLayer(pReplacementCandidate->GetLayer()); 1205 1206 // now replace lowest object with new one 1207 mpDrawView->ReplaceObjectAtView(pReplacementCandidate, *pPageView, pGraphicObj); 1208 1209 // switch off undo 1210 mpDrawView->EndUndo(); 1211 } 1212 } 1213 1214 Cancel(); 1215 1216 rReq.Done (); 1217 break; 1218 1219 case SID_REMOVE_HYPERLINK: 1220 { 1221 if (mpDrawView->IsTextEdit()) 1222 { 1223 // First make sure the field is selected 1224 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); 1225 if (pOutView) 1226 { 1227 pOutView->SelectFieldAtCursor(); 1228 URLFieldHelper::RemoveURLField(pOutView->GetEditView()); 1229 } 1230 } 1231 } 1232 Cancel(); 1233 rReq.Done (); 1234 break; 1235 1236 case SID_SET_DEFAULT: 1237 { 1238 std::unique_ptr<SfxItemSet> pSet; 1239 1240 if (mpDrawView->IsTextEdit()) 1241 { 1242 pSet.reset(new SfxItemSet( GetPool(), svl::Items<EE_ITEMS_START, EE_ITEMS_END>{} )); 1243 mpDrawView->SetAttributes( *pSet, true ); 1244 } 1245 else 1246 { 1247 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 1248 const size_t nCount = rMarkList.GetMarkCount(); 1249 1250 // For every presentation object a SfxItemSet of hard attributes 1251 // and the UserCall is stored in this list. This is because 1252 // at the following mpDrawView->SetAttributes( *pSet, sal_True ) 1253 // they get lost and have to be restored. 1254 std::vector<std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> > aAttrList; 1255 SdPage* pPresPage = static_cast<SdPage*>( mpDrawView->GetSdrPageView()->GetPage() ); 1256 1257 for ( size_t i = 0; i < nCount; ++i ) 1258 { 1259 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); 1260 1261 if( pPresPage->IsPresObj( pObj ) ) 1262 { 1263 auto pNewSet = std::make_unique<SfxItemSet>( GetDoc()->GetPool(), svl::Items<SDRATTR_TEXT_MINFRAMEHEIGHT, SDRATTR_TEXT_AUTOGROWHEIGHT>{} ); 1264 pNewSet->Put(pObj->GetMergedItemSet()); 1265 aAttrList.emplace_back(std::move(pNewSet), pObj->GetUserCall()); 1266 } 1267 } 1268 1269 pSet.reset(new SfxItemSet( GetPool() )); 1270 mpDrawView->SetAttributes( *pSet, true ); 1271 1272 sal_uLong j = 0; 1273 1274 for ( size_t i = 0; i < nCount; ++i ) 1275 { 1276 SfxStyleSheet* pSheet = nullptr; 1277 SdrObject* pObj = rMarkList.GetMark(i)->GetMarkedSdrObj(); 1278 1279 if (pObj->GetObjIdentifier() == OBJ_TITLETEXT) 1280 { 1281 pSheet = mpActualPage->GetStyleSheetForPresObj(PresObjKind::Title); 1282 if (pSheet) 1283 pObj->SetStyleSheet(pSheet, false); 1284 } 1285 else if(pObj->GetObjIdentifier() == OBJ_OUTLINETEXT) 1286 { 1287 for (sal_uInt16 nLevel = 1; nLevel < 10; nLevel++) 1288 { 1289 pSheet = mpActualPage->GetStyleSheetForPresObj( PresObjKind::Outline ); 1290 DBG_ASSERT(pSheet, "Template for outline object not found"); 1291 if (pSheet) 1292 { 1293 pObj->StartListening(*pSheet); 1294 1295 if( nLevel == 1 ) 1296 // text frame listens on StyleSheet of level1 1297 pObj->NbcSetStyleSheet(pSheet, false); 1298 } 1299 } 1300 } 1301 1302 if( pPresPage->IsPresObj( pObj ) ) 1303 { 1304 std::pair<std::unique_ptr<SfxItemSet>,SdrObjUserCall*> &rAttr = aAttrList[j++]; 1305 1306 std::unique_ptr<SfxItemSet> & pNewSet(rAttr.first); 1307 SdrObjUserCall* pUserCall = rAttr.second; 1308 1309 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_MINFRAMEHEIGHT ) == SfxItemState::SET ) 1310 { 1311 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_MINFRAMEHEIGHT)); 1312 } 1313 1314 if ( pNewSet && pNewSet->GetItemState( SDRATTR_TEXT_AUTOGROWHEIGHT ) == SfxItemState::SET ) 1315 { 1316 pObj->SetMergedItem(pNewSet->Get(SDRATTR_TEXT_AUTOGROWHEIGHT)); 1317 } 1318 1319 if( pUserCall ) 1320 pObj->SetUserCall( pUserCall ); 1321 } 1322 } 1323 } 1324 1325 pSet.reset(); 1326 Cancel(); 1327 } 1328 break; 1329 1330 case SID_DELETE_SNAPITEM: 1331 { 1332 SdrPageView* pPV; 1333 Point aMPos = GetActiveWindow()->PixelToLogic( maMousePos ); 1334 sal_uInt16 nHitLog = static_cast<sal_uInt16>(GetActiveWindow()->PixelToLogic( Size( 1335 FuPoor::HITPIX, 0 ) ).Width()); 1336 sal_uInt16 nHelpLine; 1337 1338 mbMousePosFreezed = false; 1339 1340 if( mpDrawView->PickHelpLine( aMPos, nHitLog, *GetActiveWindow(), nHelpLine, pPV) ) 1341 { 1342 pPV->DeleteHelpLine( nHelpLine ); 1343 } 1344 Cancel(); 1345 rReq.Ignore (); 1346 } 1347 break; 1348 1349 case SID_DELETE_PAGE: 1350 case SID_DELETE_MASTER_PAGE: 1351 DeleteActualPage(); 1352 Cancel(); 1353 rReq.Ignore (); 1354 break; 1355 1356 case SID_DELETE_LAYER: 1357 DeleteActualLayer(); 1358 Cancel(); 1359 rReq.Ignore (); 1360 break; 1361 1362 case SID_ORIGINAL_SIZE: 1363 mpDrawView->SetMarkedOriginalSize(); 1364 Cancel(); 1365 rReq.Done(); 1366 break; 1367 1368 case SID_DRAW_FONTWORK: 1369 case SID_DRAW_FONTWORK_VERTICAL: 1370 { 1371 svx::FontworkBar::execute(*mpView, rReq, GetViewFrame()->GetBindings()); // SJ: can be removed (I think) 1372 Cancel(); 1373 rReq.Done(); 1374 } 1375 break; 1376 1377 case SID_SAVE_GRAPHIC: 1378 { 1379 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 1380 if( rMarkList.GetMarkCount() == 1 ) 1381 { 1382 const SdrGrafObj* pObj = dynamic_cast<const SdrGrafObj*>(rMarkList.GetMark(0)->GetMarkedSdrObj()); 1383 if (pObj && pObj->GetGraphicType() == GraphicType::Bitmap) 1384 { 1385 weld::Window* pFrame = GetFrameWeld(); 1386 GraphicAttr aGraphicAttr = pObj->GetGraphicAttr(); 1387 short nState = RET_CANCEL; 1388 if (aGraphicAttr != GraphicAttr()) // the image has been modified 1389 { 1390 if (pFrame) 1391 { 1392 nState = GraphicHelper::HasToSaveTransformedImage(pFrame); 1393 } 1394 } 1395 else 1396 { 1397 nState = RET_NO; 1398 } 1399 1400 if (nState == RET_YES) 1401 { 1402 GraphicHelper::ExportGraphic(pFrame, pObj->GetTransformedGraphic(), ""); 1403 } 1404 else if (nState == RET_NO) 1405 { 1406 const GraphicObject& aGraphicObject(pObj->GetGraphicObject()); 1407 GraphicHelper::ExportGraphic(pFrame, aGraphicObject.GetGraphic(), ""); 1408 } 1409 } 1410 } 1411 Cancel(); 1412 rReq.Ignore(); 1413 } 1414 break; 1415 1416 case SID_EXTERNAL_EDIT: 1417 { 1418 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 1419 if( rMarkList.GetMarkCount() == 1 ) 1420 { 1421 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 1422 if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) 1423 { 1424 GraphicObject aGraphicObject( static_cast<SdrGrafObj*>(pObj)->GetGraphicObject() ); 1425 m_ExternalEdits.push_back( 1426 std::make_unique<SdrExternalToolEdit>( 1427 mpDrawView.get(), pObj)); 1428 m_ExternalEdits.back()->Edit( &aGraphicObject ); 1429 } 1430 } 1431 Cancel(); 1432 rReq.Ignore(); 1433 } 1434 break; 1435 1436 case SID_COMPRESS_GRAPHIC: 1437 { 1438 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 1439 if( rMarkList.GetMarkCount() == 1 ) 1440 { 1441 SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj(); 1442 1443 if( dynamic_cast< const SdrGrafObj *>( pObj ) && static_cast<SdrGrafObj*>(pObj)->GetGraphicType() == GraphicType::Bitmap ) 1444 { 1445 SdrGrafObj* pGraphicObj = static_cast<SdrGrafObj*>(pObj); 1446 CompressGraphicsDialog dialog(GetFrameWeld(), pGraphicObj, GetViewFrame()->GetBindings() ); 1447 if (dialog.run() == RET_OK) 1448 { 1449 SdrGrafObj* pNewObject = dialog.GetCompressedSdrGrafObj(); 1450 SdrPageView* pPageView = mpDrawView->GetSdrPageView(); 1451 OUString aUndoString = mpDrawView->GetDescriptionOfMarkedObjects() + " Compress"; 1452 mpDrawView->BegUndo( aUndoString ); 1453 mpDrawView->ReplaceObjectAtView( pObj, *pPageView, pNewObject ); 1454 mpDrawView->EndUndo(); 1455 } 1456 } 1457 } 1458 Cancel(); 1459 rReq.Ignore(); 1460 } 1461 break; 1462 1463 case SID_ATTRIBUTES_LINE: // BASIC 1464 { 1465 SetCurrentFunction( FuLine::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1466 if (rReq.GetArgs()) 1467 Cancel(); 1468 } 1469 break; 1470 1471 case SID_ATTRIBUTES_AREA: // BASIC 1472 { 1473 SetCurrentFunction( FuArea::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1474 if (rReq.GetArgs()) 1475 Cancel(); 1476 } 1477 break; 1478 1479 case SID_ATTR_TRANSFORM: 1480 { 1481 SetCurrentFunction( FuTransform::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1482 if (rReq.GetArgs()) 1483 { 1484 Invalidate(SID_RULER_OBJECT); 1485 Cancel(); 1486 } 1487 } 1488 break; 1489 1490 case SID_CHAR_DLG_EFFECT: 1491 case SID_CHAR_DLG: // BASIC 1492 { 1493 SetCurrentFunction( FuChar::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1494 Cancel(); 1495 } 1496 break; 1497 1498 case SID_PARA_DLG: 1499 { 1500 SetCurrentFunction( FuParagraph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1501 Cancel(); 1502 } 1503 break; 1504 1505 case FN_NUM_BULLET_ON: 1506 { 1507 // The value (sal_uInt16)0xFFFF means set bullet on/off. 1508 SfxUInt16Item aItem(FN_SVX_SET_BULLET, sal_uInt16(0xFFFF)); 1509 GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_BULLET, 1510 SfxCallMode::RECORD, { &aItem }); 1511 } 1512 break; 1513 1514 case FN_NUM_NUMBERING_ON: 1515 { 1516 // The value (sal_uInt16)0xFFFF means set bullet on/off. 1517 SfxUInt16Item aItem(FN_SVX_SET_NUMBER, sal_uInt16(0xFFFF)); 1518 GetViewFrame()->GetDispatcher()->ExecuteList(FN_SVX_SET_NUMBER, 1519 SfxCallMode::RECORD, { &aItem }); 1520 } 1521 break; 1522 1523 case SID_OUTLINE_BULLET: 1524 case FN_SVX_SET_BULLET: 1525 case FN_SVX_SET_NUMBER: 1526 { 1527 SetCurrentFunction( FuBulletAndPosition::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1528 Cancel(); 1529 } 1530 break; 1531 1532 case FN_INSERT_SOFT_HYPHEN: 1533 case FN_INSERT_HARDHYPHEN: 1534 case FN_INSERT_HARD_SPACE: 1535 case FN_INSERT_NNBSP: 1536 case SID_INSERT_RLM : 1537 case SID_INSERT_LRM : 1538 case SID_INSERT_ZWNBSP : 1539 case SID_INSERT_ZWSP: 1540 case SID_CHARMAP: 1541 { 1542 SetCurrentFunction( FuBullet::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1543 Cancel(); 1544 } 1545 break; 1546 1547 case SID_PRESENTATION_LAYOUT: 1548 { 1549 SetCurrentFunction( FuPresentationLayout::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); 1550 Cancel(); 1551 } 1552 break; 1553 1554 case SID_PASTE_SPECIAL: 1555 { 1556 SetCurrentFunction( FuInsertClipboard::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1557 Cancel(); 1558 rReq.Ignore (); 1559 } 1560 break; 1561 1562 case SID_CHANGE_PICTURE: 1563 case SID_INSERT_GRAPHIC: 1564 { 1565 SetCurrentFunction( FuInsertGraphic::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq, 1566 nSId == SID_CHANGE_PICTURE ) ); 1567 Cancel(); 1568 rReq.Ignore (); 1569 } 1570 break; 1571 1572 case SID_INSERT_AVMEDIA: 1573 { 1574 SetCurrentFunction( FuInsertAVMedia::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1575 1576 Cancel(); 1577 rReq.Ignore (); 1578 } 1579 break; 1580 1581 case SID_INSERT_OBJECT: 1582 case SID_INSERT_FLOATINGFRAME: 1583 case SID_INSERT_MATH: 1584 case SID_INSERT_DIAGRAM: 1585 case SID_ATTR_TABLE: 1586 { 1587 SetCurrentFunction( FuInsertOLE::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1588 // Set the selection tool as the old one. This in particular important for the 1589 // zoom function, in which clicking without dragging zooms as well, and that 1590 // makes exiting the object editing mode impossible. 1591 if (dynamic_cast<FuSelection*>( GetOldFunction().get() ) == nullptr) 1592 SetOldFunction( FuSelection::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1593 Cancel(); 1594 rReq.Ignore (); 1595 } 1596 break; 1597 case SID_CLASSIFICATION_APPLY: 1598 { 1599 const SfxItemSet* pArgs = rReq.GetArgs(); 1600 const SfxPoolItem* pItem = nullptr; 1601 if (pArgs && pArgs->GetItemState(nSId, false, &pItem) == SfxItemState::SET) 1602 { 1603 const OUString& rName = static_cast<const SfxStringItem*>(pItem)->GetValue(); 1604 auto eType = SfxClassificationPolicyType::IntellectualProperty; 1605 if (pArgs->GetItemState(SID_TYPE_NAME, false, &pItem) == SfxItemState::SET) 1606 { 1607 const OUString& rType = static_cast<const SfxStringItem*>(pItem)->GetValue(); 1608 eType = SfxClassificationHelper::stringToPolicyType(rType); 1609 } 1610 if (SfxViewFrame* pViewFrame = GetViewFrame()) 1611 { 1612 if (SfxObjectShell* pObjectShell = pViewFrame->GetObjectShell()) 1613 { 1614 SfxClassificationHelper aHelper(pObjectShell->getDocProperties()); 1615 aHelper.SetBACName(rName, eType); 1616 } 1617 } 1618 } 1619 else 1620 SAL_WARN("sd.ui", "missing parameter for SID_CLASSIFICATION_APPLY"); 1621 1622 Cancel(); 1623 rReq.Ignore(); 1624 } 1625 break; 1626 1627 case SID_CLASSIFICATION_DIALOG: 1628 { 1629 auto xDialog = std::make_shared<svx::ClassificationDialog>(GetFrameWeld(), false, [](){} ); 1630 ClassificationCollector aCollector(*this); 1631 aCollector.collect(); 1632 1633 xDialog->setupValues(aCollector.getResults()); 1634 1635 if (RET_OK == xDialog->run()) 1636 { 1637 ClassificationInserter aInserter(*this); 1638 aInserter.insert(xDialog->getResult()); 1639 } 1640 xDialog.reset(); 1641 1642 Cancel(); 1643 rReq.Ignore(); 1644 } 1645 break; 1646 1647 case SID_COPYOBJECTS: 1648 { 1649 if ( mpDrawView->IsPresObjSelected(false) ) 1650 { 1651 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 1652 VclMessageType::Info, VclButtonsType::Ok, 1653 SdResId(STR_ACTION_NOTPOSSIBLE))); 1654 xInfoBox->run(); 1655 } 1656 else 1657 { 1658 if ( mpDrawView->IsTextEdit() ) 1659 { 1660 mpDrawView->SdrEndTextEdit(); 1661 } 1662 1663 SetCurrentFunction( FuCopy::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1664 } 1665 Cancel(); 1666 rReq.Ignore (); 1667 } 1668 break; 1669 1670 case SID_INSERTFILE: // BASIC 1671 { 1672 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_START)); 1673 SetCurrentFunction( FuInsertFile::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1674 Broadcast (ViewShellHint(ViewShellHint::HINT_COMPLEX_MODEL_CHANGE_END)); 1675 Cancel(); 1676 rReq.Done (); 1677 } 1678 break; 1679 1680 case SID_SELECT_BACKGROUND: 1681 case SID_SAVE_BACKGROUND: 1682 case SID_ATTR_PAGE_SIZE: 1683 case SID_ATTR_PAGE: 1684 case SID_PAGESETUP: // BASIC ?? 1685 { 1686 SetCurrentFunction( FuPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1687 Cancel(); 1688 rReq.Ignore (); // we generate independent macros !! 1689 } 1690 break; 1691 1692 case SID_BEFORE_OBJ: 1693 case SID_BEHIND_OBJ: 1694 { 1695 SetCurrentFunction( FuDisplayOrder::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); 1696 rReq.Done(); 1697 // finishes itself, no Cancel() needed! 1698 } 1699 break; 1700 1701 case SID_REVERSE_ORDER: // BASIC 1702 { 1703 mpDrawView->ReverseOrderOfMarked(); 1704 Cancel(); 1705 rReq.Done (); 1706 } 1707 break; 1708 1709 case SID_ANIMATION_EFFECTS: 1710 { 1711 SetCurrentFunction( FuObjectAnimationParameters::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); 1712 Cancel(); 1713 } 1714 break; 1715 1716 case SID_EXECUTE_ANIMATION_EFFECT: 1717 { 1718 SetCurrentFunction(FuExecuteInteraction::Create(this, GetActiveWindow(), 1719 mpDrawView.get(), GetDoc(), rReq)); 1720 Cancel(); 1721 } 1722 break; 1723 1724 case SID_LINEEND_POLYGON: 1725 { 1726 SetCurrentFunction( FuLineEnd::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1727 Cancel(); 1728 } 1729 break; 1730 1731 case SID_CAPTUREPOINT: 1732 // negative value to signal call from menu 1733 maMousePos = Point(-1,-1); 1734 [[fallthrough]]; 1735 case SID_SET_SNAPITEM: 1736 { 1737 SetCurrentFunction( FuSnapLine::Create(this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq) ); 1738 Cancel(); 1739 } 1740 break; 1741 1742 case SID_MANAGE_LINKS: 1743 { 1744 SetCurrentFunction( FuLink::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1745 Cancel(); 1746 rReq.Ignore (); 1747 } 1748 break; 1749 1750 case SID_THESAURUS: 1751 { 1752 SetCurrentFunction( FuThesaurus::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1753 Cancel(); 1754 rReq.Ignore (); 1755 } 1756 break; 1757 1758 case SID_TEXTATTR_DLG: 1759 { 1760 if (mpDrawView->IsTextEdit()) 1761 mpDrawView->SdrEndTextEdit(); 1762 SetCurrentFunction( FuTextAttrDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1763 Cancel(); 1764 rReq.Ignore (); 1765 } 1766 break; 1767 1768 case SID_MEASURE_DLG: 1769 { 1770 SetCurrentFunction( FuMeasureDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1771 Cancel(); 1772 rReq.Ignore (); 1773 } 1774 break; 1775 1776 case SID_CONNECTION_DLG: 1777 { 1778 SetCurrentFunction( FuConnectionDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1779 Cancel(); 1780 rReq.Done(); 1781 } 1782 break; 1783 1784 case SID_CONNECTION_NEW_ROUTING: 1785 { 1786 SfxItemSet aDefAttr( GetPool(), svl::Items<SDRATTR_EDGELINE1DELTA, SDRATTR_EDGELINE3DELTA>{} ); 1787 GetView()->SetAttributes( aDefAttr, true ); // (ReplaceAll) 1788 1789 Cancel(); 1790 rReq.Done(); 1791 } 1792 break; 1793 1794 case SID_TWAIN_SELECT: 1795 { 1796 if( mxScannerManager.is() ) 1797 { 1798 try 1799 { 1800 const css::uno::Sequence< css::scanner::ScannerContext > 1801 aContexts( mxScannerManager->getAvailableScanners() ); 1802 1803 if( aContexts.hasElements() ) 1804 { 1805 css::scanner::ScannerContext aContext( aContexts.getConstArray()[ 0 ] ); 1806 1807 Reference<lang::XInitialization> xInit(mxScannerManager, UNO_QUERY); 1808 if (xInit.is()) 1809 { 1810 // initialize dialog 1811 weld::Window* pWindow = rReq.GetFrameWeld(); 1812 uno::Sequence<uno::Any> aSeq(comphelper::InitAnyPropertySequence( 1813 { 1814 {"ParentWindow", pWindow ? uno::Any(pWindow->GetXWindow()) : uno::Any(Reference<awt::XWindow>())} 1815 })); 1816 xInit->initialize( aSeq ); 1817 } 1818 1819 mxScannerManager->configureScannerAndScan( aContext, mxScannerListener ); 1820 } 1821 } 1822 catch(...) 1823 { 1824 } 1825 } 1826 1827 Cancel(); 1828 rReq.Done(); 1829 } 1830 break; 1831 1832 case SID_TWAIN_TRANSFER: 1833 { 1834 bool bDone = false; 1835 1836 if( mxScannerManager.is() ) 1837 { 1838 try 1839 { 1840 const css::uno::Sequence< css::scanner::ScannerContext > aContexts( mxScannerManager->getAvailableScanners() ); 1841 1842 if( aContexts.hasElements() ) 1843 { 1844 mxScannerManager->startScan( aContexts.getConstArray()[ 0 ], mxScannerListener ); 1845 bDone = true; 1846 } 1847 } 1848 catch( ... ) 1849 { 1850 } 1851 } 1852 1853 if( !bDone ) 1854 { 1855 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 1856 VclMessageType::Info, VclButtonsType::Ok, 1857 #ifndef UNX 1858 SdResId(STR_TWAIN_NO_SOURCE) 1859 #else 1860 SdResId(STR_TWAIN_NO_SOURCE_UNX) 1861 #endif 1862 )); 1863 xInfoBox->run(); 1864 1865 } 1866 else 1867 { 1868 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 1869 rBindings.Invalidate( SID_TWAIN_SELECT ); 1870 rBindings.Invalidate( SID_TWAIN_TRANSFER ); 1871 } 1872 1873 Cancel(); 1874 rReq.Done(); 1875 } 1876 break; 1877 1878 case SID_POLYGON_MORPHING: 1879 { 1880 SetCurrentFunction( FuMorph::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 1881 Cancel(); 1882 } 1883 break; 1884 1885 case SID_INSERTLAYER: 1886 { 1887 if ( mpDrawView->IsTextEdit() ) 1888 { 1889 mpDrawView->SdrEndTextEdit(); 1890 } 1891 1892 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 1893 sal_uInt16 nLayerCnt = rLayerAdmin.GetLayerCount(); 1894 sal_uInt16 nLayer = nLayerCnt - 2 + 1; 1895 OUString aLayerName = SdResId(STR_LAYER) + OUString::number(nLayer); 1896 OUString aLayerTitle, aLayerDesc; 1897 bool bIsVisible = false; 1898 bool bIsLocked = false; 1899 bool bIsPrintable = false; 1900 1901 const SfxItemSet* pArgs = rReq.GetArgs(); 1902 1903 if (! pArgs) 1904 { 1905 SfxItemSet aNewAttr( GetDoc()->GetPool(), svl::Items<ATTR_LAYER_START, ATTR_LAYER_END>{} ); 1906 1907 aNewAttr.Put( makeSdAttrLayerName( aLayerName ) ); 1908 aNewAttr.Put( makeSdAttrLayerTitle() ); 1909 aNewAttr.Put( makeSdAttrLayerDesc() ); 1910 aNewAttr.Put( makeSdAttrLayerVisible() ); 1911 aNewAttr.Put( makeSdAttrLayerPrintable() ); 1912 aNewAttr.Put( makeSdAttrLayerLocked() ); 1913 aNewAttr.Put( makeSdAttrLayerThisPage() ); 1914 1915 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 1916 vcl::Window* pWin = GetActiveWindow(); 1917 ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, true, SdResId(STR_INSERTLAYER)) ); 1918 pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_INSERTLAYER )->GetCommand() ); 1919 1920 // test for already existing names 1921 bool bLoop = true; 1922 while( bLoop && pDlg->Execute() == RET_OK ) 1923 { 1924 pDlg->GetAttr( aNewAttr ); 1925 aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); 1926 1927 if( rLayerAdmin.GetLayer( aLayerName ) 1928 || aLayerName.isEmpty() 1929 || LayerTabBar::IsLocalizedNameOfStandardLayer( aLayerName) ) 1930 { 1931 // name already exists 1932 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), 1933 VclMessageType::Warning, VclButtonsType::Ok, 1934 SdResId(STR_WARN_NAME_DUPLICATE))); 1935 xWarn->run(); 1936 } 1937 else 1938 bLoop = false; 1939 } 1940 if( bLoop ) // was canceled 1941 { 1942 pDlg.disposeAndClear(); 1943 Cancel(); 1944 rReq.Ignore (); 1945 break; 1946 } 1947 else 1948 { 1949 aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); 1950 aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); 1951 bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); 1952 bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue () ; 1953 bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue () ; 1954 } 1955 } 1956 else if (pArgs->Count () != 4) 1957 { 1958 #if HAVE_FEATURE_SCRIPTING 1959 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS); 1960 #endif 1961 Cancel(); 1962 rReq.Ignore (); 1963 break; 1964 } 1965 else 1966 { 1967 const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME); 1968 const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE); 1969 const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED); 1970 const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE); 1971 1972 aLayerName = pLayerName->GetValue (); 1973 bIsVisible = pIsVisible->GetValue (); 1974 bIsLocked = pIsLocked->GetValue (); 1975 bIsPrintable = pIsPrintable->GetValue (); 1976 } 1977 1978 OUString aPrevLayer = mpDrawView->GetActiveLayer(); 1979 SdrLayer* pLayer; 1980 sal_uInt16 nPrevLayer = 0; 1981 nLayerCnt = rLayerAdmin.GetLayerCount(); 1982 1983 for ( nLayer = 0; nLayer < nLayerCnt; nLayer++ ) 1984 { 1985 pLayer = rLayerAdmin.GetLayer(nLayer); 1986 OUString aName = pLayer->GetName(); 1987 1988 if ( aPrevLayer == aName ) 1989 { 1990 nPrevLayer = std::max(nLayer, sal_uInt16(4)); 1991 } 1992 } 1993 1994 mpDrawView->InsertNewLayer(aLayerName, nPrevLayer + 1); 1995 pLayer = rLayerAdmin.GetLayer(aLayerName); 1996 if( pLayer ) 1997 { 1998 pLayer->SetTitle( aLayerTitle ); 1999 pLayer->SetDescription( aLayerDesc ); 2000 } 2001 2002 mpDrawView->SetLayerVisible( aLayerName, bIsVisible ); 2003 mpDrawView->SetLayerLocked( aLayerName, bIsLocked); 2004 mpDrawView->SetLayerPrintable(aLayerName, bIsPrintable); 2005 2006 mpDrawView->SetActiveLayer(aLayerName); 2007 2008 ResetActualLayer(); 2009 2010 GetDoc()->SetChanged(); 2011 2012 GetViewFrame()->GetDispatcher()->Execute(SID_SWITCHLAYER, 2013 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD); 2014 2015 Cancel(); 2016 rReq.Done (); 2017 } 2018 break; 2019 2020 case SID_MODIFYLAYER: 2021 { 2022 if(!GetLayerTabControl()) // #i87182# 2023 { 2024 OSL_ENSURE(false, "No LayerTabBar (!)"); 2025 Cancel(); 2026 rReq.Ignore(); 2027 break; 2028 } 2029 2030 if ( mpDrawView->IsTextEdit() ) 2031 { 2032 mpDrawView->SdrEndTextEdit(); 2033 } 2034 2035 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 2036 sal_uInt16 nCurPage = GetLayerTabControl()->GetCurPageId(); 2037 OUString aLayerName = GetLayerTabControl()->GetLayerName(nCurPage); 2038 SdrLayer* pLayer = rLayerAdmin.GetLayer(aLayerName); 2039 2040 OUString aLayerTitle = pLayer->GetTitle(); 2041 OUString aLayerDesc = pLayer->GetDescription(); 2042 2043 OUString aOldLayerName(aLayerName); 2044 OUString aOldLayerTitle(aLayerTitle); 2045 OUString aOldLayerDesc(aLayerDesc); 2046 2047 bool bIsVisible, bIsLocked, bIsPrintable; 2048 bool bOldIsVisible = bIsVisible = mpDrawView->IsLayerVisible(aLayerName); 2049 bool bOldIsLocked = bIsLocked = mpDrawView->IsLayerLocked(aLayerName); 2050 bool bOldIsPrintable = bIsPrintable = mpDrawView->IsLayerPrintable(aLayerName); 2051 2052 const SfxItemSet* pArgs = rReq.GetArgs(); 2053 // is it allowed to delete the layer? 2054 bool bDelete = !( LayerTabBar::IsRealNameOfStandardLayer(aLayerName) ); 2055 2056 if (! pArgs) 2057 { 2058 SfxItemSet aNewAttr( GetDoc()->GetPool(), svl::Items<ATTR_LAYER_START, ATTR_LAYER_END>{} ); 2059 2060 aNewAttr.Put( makeSdAttrLayerName( aLayerName ) ); 2061 aNewAttr.Put( makeSdAttrLayerTitle( aLayerTitle ) ); 2062 aNewAttr.Put( makeSdAttrLayerDesc( aLayerDesc ) ); 2063 aNewAttr.Put( makeSdAttrLayerVisible( bIsVisible ) ); 2064 aNewAttr.Put( makeSdAttrLayerLocked( bIsLocked ) ); 2065 aNewAttr.Put( makeSdAttrLayerPrintable( bIsPrintable ) ); 2066 aNewAttr.Put( makeSdAttrLayerThisPage() ); 2067 2068 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 2069 vcl::Window* pWin = GetActiveWindow(); 2070 ScopedVclPtr<AbstractSdInsertLayerDlg> pDlg( pFact->CreateSdInsertLayerDlg(pWin ? pWin->GetFrameWeld() : nullptr, aNewAttr, bDelete, SdResId(STR_MODIFYLAYER)) ); 2071 pDlg->SetHelpId( SD_MOD()->GetSlotPool()->GetSlot( SID_MODIFYLAYER )->GetCommand() ); 2072 2073 // test for already existing names 2074 bool bLoop = true; 2075 sal_uInt16 nRet = 0; 2076 while( bLoop ) 2077 { 2078 nRet = pDlg->Execute(); 2079 if (nRet != RET_OK) 2080 break; 2081 pDlg->GetAttr( aNewAttr ); 2082 aLayerName = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_NAME)).GetValue (); 2083 if (bDelete) 2084 { 2085 if( (rLayerAdmin.GetLayer( aLayerName ) && aLayerName != aOldLayerName) 2086 || LayerTabBar::IsRealNameOfStandardLayer(aLayerName) 2087 || LayerTabBar::IsLocalizedNameOfStandardLayer(aLayerName) 2088 || aLayerName.isEmpty() ) 2089 { 2090 // name already exists 2091 std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), 2092 VclMessageType::Warning, VclButtonsType::Ok, 2093 SdResId(STR_WARN_NAME_DUPLICATE))); 2094 xWarn->run(); 2095 } 2096 else 2097 bLoop = false; 2098 } 2099 else 2100 bLoop = false; // altering name is already disabled in the dialog itself 2101 } 2102 switch (nRet) 2103 { 2104 case RET_OK : 2105 aLayerTitle = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_TITLE)).GetValue (); 2106 aLayerDesc = static_cast<const SfxStringItem &>( aNewAttr.Get (ATTR_LAYER_DESC)).GetValue (); 2107 bIsVisible = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_VISIBLE)).GetValue (); 2108 bIsLocked = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_LOCKED)).GetValue (); 2109 bIsPrintable = static_cast<const SfxBoolItem &>( aNewAttr.Get (ATTR_LAYER_PRINTABLE)).GetValue (); 2110 break; 2111 2112 default : 2113 pDlg.disposeAndClear(); 2114 rReq.Ignore (); 2115 Cancel (); 2116 return; 2117 } 2118 } 2119 else if (pArgs->Count () == 4) 2120 { 2121 const SfxStringItem* pLayerName = rReq.GetArg<SfxStringItem>(ID_VAL_LAYERNAME); 2122 const SfxBoolItem* pIsVisible = rReq.GetArg<SfxBoolItem>(ID_VAL_ISVISIBLE); 2123 const SfxBoolItem* pIsLocked = rReq.GetArg<SfxBoolItem>(ID_VAL_ISLOCKED); 2124 const SfxBoolItem* pIsPrintable = rReq.GetArg<SfxBoolItem>(ID_VAL_ISPRINTABLE); 2125 2126 aLayerName = pLayerName->GetValue (); 2127 bIsVisible = pIsVisible->GetValue (); 2128 bIsLocked = pIsLocked->GetValue (); 2129 bIsPrintable = pIsPrintable->GetValue (); 2130 } 2131 else 2132 { 2133 #if HAVE_FEATURE_SCRIPTING 2134 StarBASIC::FatalError (ERRCODE_BASIC_WRONG_ARGS); 2135 #endif 2136 Cancel (); 2137 rReq.Ignore (); 2138 break; 2139 } 2140 2141 SfxUndoManager* pManager = GetDoc()->GetDocSh()->GetUndoManager(); 2142 std::unique_ptr<SdLayerModifyUndoAction> pAction( new SdLayerModifyUndoAction( 2143 GetDoc(), 2144 pLayer, 2145 // old values 2146 aOldLayerName, 2147 aOldLayerTitle, 2148 aOldLayerDesc, 2149 bOldIsVisible, 2150 bOldIsLocked, 2151 bOldIsPrintable, 2152 // new values 2153 aLayerName, 2154 aLayerTitle, 2155 aLayerDesc, 2156 bIsVisible, 2157 bIsLocked, 2158 bIsPrintable 2159 ) ); 2160 pManager->AddUndoAction( std::move(pAction) ); 2161 2162 ModifyLayer( pLayer, aLayerName, aLayerTitle, aLayerDesc, bIsVisible, bIsLocked, bIsPrintable ); 2163 2164 Cancel(); 2165 rReq.Done (); 2166 } 2167 break; 2168 2169 case SID_RENAMELAYER: 2170 { 2171 if ( mpDrawView->IsTextEdit() ) 2172 { 2173 mpDrawView->SdrEndTextEdit(); 2174 } 2175 2176 if(GetLayerTabControl()) // #i87182# 2177 { 2178 GetLayerTabControl()->StartEditMode(GetLayerTabControl()->GetCurPageId()); 2179 } 2180 else 2181 { 2182 OSL_ENSURE(false, "No LayerTabBar (!)"); 2183 } 2184 2185 Cancel(); 2186 rReq.Ignore (); 2187 } 2188 break; 2189 2190 case SID_EDIT_HYPERLINK : 2191 { 2192 // Ensure the field is selected first 2193 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); 2194 if (pOutView) 2195 pOutView->SelectFieldAtCursor(); 2196 2197 GetViewFrame()->GetDispatcher()->Execute( SID_HYPERLINK_DIALOG ); 2198 2199 Cancel(); 2200 rReq.Done (); 2201 } 2202 break; 2203 2204 case SID_OPEN_HYPERLINK: 2205 { 2206 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); 2207 if ( pOutView ) 2208 { 2209 const SvxFieldData* pField = pOutView->GetFieldAtCursor(); 2210 if( auto pURLField = dynamic_cast< const SvxURLField *>( pField ) ) 2211 { 2212 SfxStringItem aUrl( SID_FILE_NAME, pURLField->GetURL() ); 2213 SfxStringItem aTarget( SID_TARGETNAME, pURLField->GetTargetFrame() ); 2214 2215 OUString aReferName; 2216 SfxViewFrame* pFrame = GetViewFrame(); 2217 SfxMedium* pMed = pFrame->GetObjectShell()->GetMedium(); 2218 if (pMed) 2219 aReferName = pMed->GetName(); 2220 2221 SfxFrameItem aFrm( SID_DOCFRAME, pFrame ); 2222 SfxStringItem aReferer( SID_REFERER, aReferName ); 2223 2224 SfxBoolItem aNewView( SID_OPEN_NEW_VIEW, false ); 2225 SfxBoolItem aBrowsing( SID_BROWSE, true ); 2226 2227 SfxViewFrame* pViewFrm = SfxViewFrame::Current(); 2228 if (pViewFrm) 2229 { 2230 pViewFrm->GetDispatcher()->ExecuteList(SID_OPENDOC, 2231 SfxCallMode::ASYNCHRON | SfxCallMode::RECORD, 2232 { &aUrl, &aTarget, &aFrm, &aReferer, 2233 &aNewView, &aBrowsing }); 2234 } 2235 } 2236 } 2237 Cancel(); 2238 rReq.Done (); 2239 } 2240 break; 2241 2242 case SID_COPY_HYPERLINK_LOCATION: 2243 { 2244 OutlinerView* pOutView = mpDrawView->GetTextEditOutlinerView(); 2245 if ( pOutView ) 2246 { 2247 const SvxFieldData* pField = pOutView->GetFieldAtCursor(); 2248 if (const SvxURLField* pURLField = dynamic_cast<const SvxURLField*>(pField)) 2249 { 2250 uno::Reference<datatransfer::clipboard::XClipboard> xClipboard 2251 = pOutView->GetWindow()->GetClipboard(); 2252 vcl::unohelper::TextDataObject::CopyStringTo(pURLField->GetURL(), xClipboard); 2253 } 2254 } 2255 2256 Cancel(); 2257 rReq.Done (); 2258 } 2259 break; 2260 2261 case SID_HYPERLINK_SETLINK: 2262 { 2263 const SfxItemSet* pReqArgs = rReq.GetArgs(); 2264 2265 if (pReqArgs) 2266 { 2267 const SvxHyperlinkItem* pHLItem = 2268 &pReqArgs->Get(SID_HYPERLINK_SETLINK); 2269 2270 if (pHLItem->GetInsertMode() == HLINK_FIELD) 2271 { 2272 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), 2273 pHLItem->GetTargetFrame()); 2274 } 2275 else if (pHLItem->GetInsertMode() == HLINK_BUTTON) 2276 { 2277 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(), 2278 pHLItem->GetTargetFrame(), nullptr); 2279 } 2280 else if (pHLItem->GetInsertMode() == HLINK_DEFAULT) 2281 { 2282 OutlinerView* pOlView = mpDrawView->GetTextEditOutlinerView(); 2283 2284 if (pOlView || comphelper::LibreOfficeKit::isActive()) 2285 { 2286 InsertURLField(pHLItem->GetURL(), pHLItem->GetName(), 2287 pHLItem->GetTargetFrame()); 2288 } 2289 else 2290 { 2291 InsertURLButton(pHLItem->GetURL(), pHLItem->GetName(), 2292 pHLItem->GetTargetFrame(), nullptr); 2293 } 2294 } 2295 } 2296 2297 Cancel(); 2298 rReq.Ignore (); 2299 } 2300 break; 2301 2302 case SID_HIDE_LAST_LEVEL: 2303 { 2304 ESelection aSel; 2305 // fdo#78151 editing a PresObjKind::Outline in a master page ? 2306 ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel); 2307 if (pOL) 2308 { 2309 //we are on the last paragraph 2310 aSel.Adjust(); 2311 if (aSel.nEndPara == pOL->GetParagraphCount() - 1) 2312 { 2313 sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara); 2314 //there exists a previous numbering level 2315 if (nDepth != sal_uInt16(-1) && nDepth > 0) 2316 { 2317 Paragraph* pPara = pOL->GetParagraph(aSel.nEndPara); 2318 pOL->Remove(pPara, 1); 2319 } 2320 } 2321 } 2322 Cancel(); 2323 rReq.Done (); 2324 } 2325 break; 2326 2327 case SID_SHOW_NEXT_LEVEL: 2328 { 2329 const char* const STR_PRESOBJ_MPOUTLINE_ARY[] 2330 { 2331 STR_PRESOBJ_MPOUTLINE, 2332 STR_PRESOBJ_MPOUTLLAYER2, 2333 STR_PRESOBJ_MPOUTLLAYER3, 2334 STR_PRESOBJ_MPOUTLLAYER4, 2335 STR_PRESOBJ_MPOUTLLAYER5, 2336 STR_PRESOBJ_MPOUTLLAYER6, 2337 STR_PRESOBJ_MPOUTLLAYER7, 2338 STR_PRESOBJ_MPNOTESTITLE, 2339 STR_PRESOBJ_MPNOTESTEXT, 2340 STR_PRESOBJ_NOTESTEXT 2341 }; 2342 2343 ESelection aSel; 2344 // fdo#78151 editing a PresObjKind::Outline in a master page ? 2345 ::Outliner* pOL = GetOutlinerForMasterPageOutlineTextObj(aSel); 2346 if (pOL) 2347 { 2348 //we are on the last paragraph 2349 aSel.Adjust(); 2350 if (aSel.nEndPara == pOL->GetParagraphCount() - 1) 2351 { 2352 sal_uInt16 nDepth = pOL->GetDepth(aSel.nEndPara); 2353 //there exists a previous numbering level 2354 if (nDepth < 8) 2355 { 2356 sal_uInt16 nNewDepth = nDepth+1; 2357 pOL->Insert(SdResId(STR_PRESOBJ_MPOUTLINE_ARY[nNewDepth]), EE_PARA_APPEND, nNewDepth); 2358 } 2359 } 2360 } 2361 Cancel(); 2362 rReq.Done (); 2363 } 2364 break; 2365 2366 case SID_INSERT_FLD_DATE_FIX: 2367 case SID_INSERT_FLD_DATE_VAR: 2368 case SID_INSERT_FLD_TIME_FIX: 2369 case SID_INSERT_FLD_TIME_VAR: 2370 case SID_INSERT_FLD_AUTHOR: 2371 case SID_INSERT_FLD_PAGE: 2372 case SID_INSERT_FLD_PAGE_TITLE: 2373 case SID_INSERT_FLD_PAGES: 2374 case SID_INSERT_FLD_FILE: 2375 { 2376 sal_uInt16 nMul = 1; 2377 std::unique_ptr<SvxFieldItem> pFieldItem; 2378 2379 switch( nSId ) 2380 { 2381 case SID_INSERT_FLD_DATE_FIX: 2382 pFieldItem.reset(new SvxFieldItem( 2383 SvxDateField( Date( Date::SYSTEM ), SvxDateType::Fix ), EE_FEATURE_FIELD )); 2384 break; 2385 2386 case SID_INSERT_FLD_DATE_VAR: 2387 pFieldItem.reset(new SvxFieldItem( SvxDateField(), EE_FEATURE_FIELD )); 2388 break; 2389 2390 case SID_INSERT_FLD_TIME_FIX: 2391 pFieldItem.reset(new SvxFieldItem( 2392 SvxExtTimeField( ::tools::Time( ::tools::Time::SYSTEM ), SvxTimeType::Fix ), EE_FEATURE_FIELD )); 2393 break; 2394 2395 case SID_INSERT_FLD_TIME_VAR: 2396 pFieldItem.reset(new SvxFieldItem( SvxExtTimeField(), EE_FEATURE_FIELD )); 2397 break; 2398 2399 case SID_INSERT_FLD_AUTHOR: 2400 { 2401 SvtUserOptions aUserOptions; 2402 pFieldItem.reset(new SvxFieldItem( 2403 SvxAuthorField( 2404 aUserOptions.GetFirstName(), aUserOptions.GetLastName(), aUserOptions.GetID() ), EE_FEATURE_FIELD )); 2405 } 2406 break; 2407 2408 case SID_INSERT_FLD_PAGE: 2409 { 2410 pFieldItem.reset(new SvxFieldItem( SvxPageField(), EE_FEATURE_FIELD )); 2411 nMul = 3; 2412 } 2413 break; 2414 2415 case SID_INSERT_FLD_PAGE_TITLE: 2416 { 2417 pFieldItem.reset(new SvxFieldItem( SvxPageTitleField(), EE_FEATURE_FIELD)); 2418 nMul = 3; 2419 } 2420 break; 2421 2422 case SID_INSERT_FLD_PAGES: 2423 { 2424 pFieldItem.reset(new SvxFieldItem( SvxPagesField(), EE_FEATURE_FIELD )); 2425 nMul = 3; 2426 } 2427 break; 2428 2429 case SID_INSERT_FLD_FILE: 2430 { 2431 OUString aName; 2432 if( GetDocSh()->HasName() ) 2433 aName = GetDocSh()->GetMedium()->GetName(); 2434 pFieldItem.reset(new SvxFieldItem( SvxExtFileField( aName ), EE_FEATURE_FIELD )); 2435 } 2436 break; 2437 } 2438 2439 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); 2440 2441 if( pOLV ) 2442 { 2443 const SvxFieldItem* pOldFldItem = pOLV->GetFieldAtSelection(); 2444 2445 if( pOldFldItem && ( nullptr != dynamic_cast< const SvxURLField *>( pOldFldItem->GetField() ) || 2446 nullptr != dynamic_cast< const SvxDateField *>( pOldFldItem->GetField() ) || 2447 nullptr != dynamic_cast< const SvxTimeField *>( pOldFldItem->GetField() ) || 2448 nullptr != dynamic_cast< const SvxExtTimeField *>( pOldFldItem->GetField() ) || 2449 nullptr != dynamic_cast< const SvxExtFileField *>( pOldFldItem->GetField() ) || 2450 nullptr != dynamic_cast< const SvxAuthorField *>( pOldFldItem->GetField() ) || 2451 nullptr != dynamic_cast< const SvxPageField *>( pOldFldItem->GetField() ) ) ) 2452 { 2453 // select field, then it will be deleted when inserting 2454 ESelection aSel = pOLV->GetSelection(); 2455 if( aSel.nStartPos == aSel.nEndPos ) 2456 aSel.nEndPos++; 2457 pOLV->SetSelection( aSel ); 2458 } 2459 2460 if( pFieldItem ) 2461 pOLV->InsertField( *pFieldItem ); 2462 } 2463 else 2464 { 2465 Outliner* pOutl = GetDoc()->GetInternalOutliner(); 2466 pOutl->Init( OutlinerMode::TextObject ); 2467 OutlinerMode nOutlMode = pOutl->GetMode(); 2468 pOutl->SetStyleSheet( 0, nullptr ); 2469 pOutl->QuickInsertField( *pFieldItem, ESelection() ); 2470 std::unique_ptr<OutlinerParaObject> pOutlParaObject = pOutl->CreateParaObject(); 2471 2472 SdrRectObj* pRectObj = new SdrRectObj( 2473 *GetDoc(), 2474 OBJ_TEXT); 2475 pRectObj->SetMergedItem(makeSdrTextAutoGrowWidthItem(true)); 2476 2477 pOutl->UpdateFields(); 2478 pOutl->SetUpdateMode( true ); 2479 Size aSize( pOutl->CalcTextSize() ); 2480 aSize.setWidth( aSize.Width() * nMul ); 2481 pOutl->SetUpdateMode( false ); 2482 2483 Point aPos; 2484 ::tools::Rectangle aRect( aPos, GetActiveWindow()->GetOutputSizePixel() ); 2485 aPos = aRect.Center(); 2486 aPos = GetActiveWindow()->PixelToLogic(aPos); 2487 aPos.AdjustX( -(aSize.Width() / 2) ); 2488 aPos.AdjustY( -(aSize.Height() / 2) ); 2489 2490 ::tools::Rectangle aLogicRect(aPos, aSize); 2491 pRectObj->SetLogicRect(aLogicRect); 2492 pRectObj->SetOutlinerParaObject( std::move(pOutlParaObject) ); 2493 mpDrawView->InsertObjectAtView(pRectObj, *mpDrawView->GetSdrPageView()); 2494 pOutl->Init( nOutlMode ); 2495 } 2496 2497 pFieldItem.reset(); 2498 2499 Cancel(); 2500 rReq.Ignore (); 2501 } 2502 break; 2503 2504 case SID_MODIFY_FIELD: 2505 { 2506 OutlinerView* pOLV = mpDrawView->GetTextEditOutlinerView(); 2507 2508 if( pOLV ) 2509 { 2510 const SvxFieldItem* pFldItem = pOLV->GetFieldAtSelection(); 2511 2512 if( pFldItem && (nullptr != dynamic_cast< const SvxDateField *>( pFldItem->GetField() ) || 2513 nullptr != dynamic_cast< const SvxAuthorField *>( pFldItem->GetField() ) || 2514 nullptr != dynamic_cast< const SvxExtFileField *>( pFldItem->GetField() ) || 2515 nullptr != dynamic_cast< const SvxExtTimeField *>( pFldItem->GetField() ) ) ) 2516 { 2517 // Dialog... 2518 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 2519 vcl::Window* pWin = GetActiveWindow(); 2520 ScopedVclPtr<AbstractSdModifyFieldDlg> pDlg( pFact->CreateSdModifyFieldDlg(pWin ? pWin->GetFrameWeld() : nullptr, pFldItem->GetField(), pOLV->GetAttribs() ) ); 2521 if( pDlg->Execute() == RET_OK ) 2522 { 2523 // To make a correct SetAttribs() call at the utlinerView 2524 // it is necessary to split the actions here 2525 std::unique_ptr<SvxFieldData> pField(pDlg->GetField()); 2526 ESelection aSel = pOLV->GetSelection(); 2527 bool bSelectionWasModified(false); 2528 2529 if( pField ) 2530 { 2531 SvxFieldItem aFieldItem( *pField, EE_FEATURE_FIELD ); 2532 2533 if( aSel.nStartPos == aSel.nEndPos ) 2534 { 2535 bSelectionWasModified = true; 2536 aSel.nEndPos++; 2537 pOLV->SetSelection( aSel ); 2538 } 2539 2540 pOLV->InsertField( aFieldItem ); 2541 2542 // select again for eventual SetAttribs call 2543 pOLV->SetSelection( aSel ); 2544 } 2545 2546 SfxItemSet aSet( pDlg->GetItemSet() ); 2547 2548 if( aSet.Count() ) 2549 { 2550 pOLV->SetAttribs( aSet ); 2551 2552 ::Outliner* pOutliner = pOLV->GetOutliner(); 2553 if( pOutliner ) 2554 pOutliner->UpdateFields(); 2555 } 2556 2557 if(pField) 2558 { 2559 // restore selection to original 2560 if(bSelectionWasModified) 2561 { 2562 aSel.nEndPos--; 2563 pOLV->SetSelection( aSel ); 2564 } 2565 } 2566 } 2567 } 2568 } 2569 2570 Cancel(); 2571 rReq.Ignore (); 2572 } 2573 break; 2574 2575 case SID_OPEN_XML_FILTERSETTINGS: 2576 { 2577 try 2578 { 2579 css::uno::Reference < css::ui::dialogs::XExecutableDialog > xDialog = css::ui::dialogs::XSLTFilterDialog::create( ::comphelper::getProcessComponentContext() ); 2580 xDialog->execute(); 2581 } 2582 catch( css::uno::RuntimeException& ) 2583 { 2584 DBG_UNHANDLED_EXCEPTION("sd.view"); 2585 } 2586 2587 Cancel(); 2588 rReq.Ignore (); 2589 } 2590 break; 2591 2592 case SID_GROUP: // BASIC 2593 { 2594 if ( mpDrawView->IsPresObjSelected( true, true, true ) ) 2595 { 2596 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2597 VclMessageType::Info, VclButtonsType::Ok, 2598 SdResId(STR_ACTION_NOTPOSSIBLE))); 2599 xInfoBox->run(); 2600 } 2601 else 2602 { 2603 mpDrawView->GroupMarked(); 2604 } 2605 Cancel(); 2606 rReq.Done (); 2607 } 2608 break; 2609 2610 case SID_UNGROUP: // BASIC 2611 { 2612 mpDrawView->UnGroupMarked(); 2613 Cancel(); 2614 rReq.Done (); 2615 } 2616 break; 2617 2618 case SID_NAME_GROUP: 2619 { 2620 // only allow for single object selection since the name of an object needs 2621 // to be unique 2622 if(1 == mpDrawView->GetMarkedObjectCount()) 2623 { 2624 // #i68101# 2625 SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0); 2626 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)"); 2627 OUString aName(pSelected->GetName()); 2628 2629 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 2630 ScopedVclPtr<AbstractSvxObjectNameDialog> pDlg(pFact->CreateSvxObjectNameDialog(GetFrameWeld(), aName)); 2631 2632 pDlg->SetCheckNameHdl(LINK(this, DrawViewShell, NameObjectHdl)); 2633 2634 if(RET_OK == pDlg->Execute()) 2635 { 2636 pDlg->GetName(aName); 2637 pSelected->SetName(aName); 2638 2639 SdPage* pPage = GetActualPage(); 2640 if (pPage) 2641 pPage->notifyObjectRenamed(pSelected); 2642 } 2643 } 2644 2645 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 2646 rBindings.Invalidate( SID_NAVIGATOR_STATE, true ); 2647 rBindings.Invalidate( SID_CONTEXT ); 2648 2649 Cancel(); 2650 rReq.Ignore(); 2651 break; 2652 } 2653 2654 // #i68101# 2655 case SID_OBJECT_TITLE_DESCRIPTION: 2656 { 2657 if(1 == mpDrawView->GetMarkedObjectCount()) 2658 { 2659 SdrObject* pSelected = mpDrawView->GetMarkedObjectByIndex(0); 2660 OSL_ENSURE(pSelected, "DrawViewShell::FuTemp03: nMarkCount, but no object (!)"); 2661 OUString aTitle(pSelected->GetTitle()); 2662 OUString aDescription(pSelected->GetDescription()); 2663 2664 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 2665 ScopedVclPtr<AbstractSvxObjectTitleDescDialog> pDlg(pFact->CreateSvxObjectTitleDescDialog( 2666 GetFrameWeld(), aTitle, aDescription)); 2667 2668 if(RET_OK == pDlg->Execute()) 2669 { 2670 pDlg->GetTitle(aTitle); 2671 pDlg->GetDescription(aDescription); 2672 pSelected->SetTitle(aTitle); 2673 pSelected->SetDescription(aDescription); 2674 } 2675 } 2676 2677 SfxBindings& rBindings = GetViewFrame()->GetBindings(); 2678 rBindings.Invalidate( SID_NAVIGATOR_STATE, true ); 2679 rBindings.Invalidate( SID_CONTEXT ); 2680 2681 Cancel(); 2682 rReq.Ignore(); 2683 break; 2684 } 2685 2686 case SID_ENTER_GROUP: // BASIC 2687 { 2688 mpDrawView->EnterMarkedGroup(); 2689 Cancel(); 2690 rReq.Done (); 2691 } 2692 break; 2693 2694 case SID_LEAVE_GROUP: // BASIC 2695 { 2696 mpDrawView->LeaveOneGroup(); 2697 Cancel(); 2698 rReq.Done (); 2699 } 2700 break; 2701 2702 case SID_LEAVE_ALL_GROUPS: // BASIC 2703 { 2704 mpDrawView->LeaveAllGroup(); 2705 Cancel(); 2706 rReq.Done (); 2707 } 2708 break; 2709 2710 case SID_TEXT_COMBINE: // BASIC 2711 { 2712 // End text edit to avoid conflicts 2713 if(mpDrawView->IsTextEdit()) 2714 mpDrawView->SdrEndTextEdit(); 2715 2716 if ( mpDrawView->IsPresObjSelected() ) 2717 { 2718 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2719 VclMessageType::Info, VclButtonsType::Ok, 2720 SdResId(STR_ACTION_NOTPOSSIBLE))); 2721 xInfoBox->run(); 2722 } 2723 else 2724 { 2725 weld::WaitObject aWait(GetFrameWeld()); 2726 mpDrawView->CombineMarkedTextObjects(); 2727 } 2728 Cancel(); 2729 rReq.Done (); 2730 } 2731 break; 2732 2733 case SID_COMBINE: // BASIC 2734 { 2735 // End text edit to avoid conflicts 2736 if(mpDrawView->IsTextEdit()) 2737 mpDrawView->SdrEndTextEdit(); 2738 2739 if ( mpDrawView->IsPresObjSelected() ) 2740 { 2741 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2742 VclMessageType::Info, VclButtonsType::Ok, 2743 SdResId(STR_ACTION_NOTPOSSIBLE))); 2744 xInfoBox->run(); 2745 } 2746 else 2747 { 2748 weld::WaitObject aWait(GetFrameWeld()); 2749 mpDrawView->CombineMarkedObjects(false); 2750 } 2751 Cancel(); 2752 rReq.Done (); 2753 } 2754 break; 2755 2756 case SID_DISTRIBUTE_DLG: 2757 { 2758 if ( mpDrawView->IsPresObjSelected() ) 2759 { 2760 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2761 VclMessageType::Info, VclButtonsType::Ok, 2762 SdResId(STR_ACTION_NOTPOSSIBLE))); 2763 xInfoBox->run(); 2764 } 2765 else 2766 { 2767 mpDrawView->DistributeMarkedObjects(GetFrameWeld()); 2768 } 2769 Cancel(); 2770 rReq.Done (); 2771 } 2772 break; 2773 2774 case SID_POLY_MERGE: 2775 { 2776 // End text edit to avoid conflicts 2777 if(mpDrawView->IsTextEdit()) 2778 mpDrawView->SdrEndTextEdit(); 2779 2780 if ( mpDrawView->IsPresObjSelected() ) 2781 { 2782 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2783 VclMessageType::Info, VclButtonsType::Ok, 2784 SdResId(STR_ACTION_NOTPOSSIBLE))); 2785 xInfoBox->run(); 2786 } 2787 else 2788 { 2789 weld::WaitObject aWait(GetFrameWeld()); 2790 mpDrawView->MergeMarkedObjects(SdrMergeMode::Merge); 2791 } 2792 Cancel(); 2793 rReq.Done (); 2794 } 2795 break; 2796 2797 case SID_POLY_SUBSTRACT: 2798 { 2799 // End text edit to avoid conflicts 2800 if(mpDrawView->IsTextEdit()) 2801 mpDrawView->SdrEndTextEdit(); 2802 2803 if ( mpDrawView->IsPresObjSelected() ) 2804 { 2805 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2806 VclMessageType::Info, VclButtonsType::Ok, 2807 SdResId(STR_ACTION_NOTPOSSIBLE))); 2808 xInfoBox->run(); 2809 } 2810 else 2811 { 2812 weld::WaitObject aWait(GetFrameWeld()); 2813 mpDrawView->MergeMarkedObjects(SdrMergeMode::Subtract); 2814 } 2815 Cancel(); 2816 rReq.Done (); 2817 } 2818 break; 2819 2820 case SID_POLY_INTERSECT: 2821 { 2822 // End text edit to avoid conflicts 2823 if(mpDrawView->IsTextEdit()) 2824 mpDrawView->SdrEndTextEdit(); 2825 2826 if ( mpDrawView->IsPresObjSelected() ) 2827 { 2828 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2829 VclMessageType::Info, VclButtonsType::Ok, 2830 SdResId(STR_ACTION_NOTPOSSIBLE))); 2831 xInfoBox->run(); 2832 } 2833 else 2834 { 2835 weld::WaitObject aWait(GetFrameWeld()); 2836 mpDrawView->MergeMarkedObjects(SdrMergeMode::Intersect); 2837 } 2838 Cancel(); 2839 rReq.Done (); 2840 } 2841 break; 2842 2843 case SID_EQUALIZEWIDTH: 2844 case SID_EQUALIZEHEIGHT: 2845 { 2846 // End text edit to avoid conflicts 2847 if(mpDrawView->IsTextEdit()) 2848 mpDrawView->SdrEndTextEdit(); 2849 2850 mpDrawView->EqualizeMarkedObjects(nSId == SID_EQUALIZEWIDTH); 2851 Cancel(); 2852 rReq.Done (); 2853 } 2854 break; 2855 2856 case SID_DISMANTLE: // BASIC 2857 { 2858 if ( mpDrawView->IsDismantlePossible() ) 2859 { 2860 weld::WaitObject aWait(GetFrameWeld()); 2861 mpDrawView->DismantleMarkedObjects(); 2862 } 2863 Cancel(); 2864 rReq.Done (); 2865 } 2866 break; 2867 2868 case SID_CONNECT: // BASIC 2869 { 2870 if ( mpDrawView->IsPresObjSelected() ) 2871 { 2872 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2873 VclMessageType::Info, VclButtonsType::Ok, 2874 SdResId(STR_ACTION_NOTPOSSIBLE))); 2875 xInfoBox->run(); 2876 } 2877 else 2878 { 2879 weld::WaitObject aWait(GetFrameWeld()); 2880 mpDrawView->CombineMarkedObjects(); 2881 } 2882 Cancel(); 2883 rReq.Done (); 2884 } 2885 break; 2886 2887 case SID_BREAK: // BASIC 2888 { 2889 if ( mpDrawView->IsTextEdit() ) 2890 { 2891 mpDrawView->SdrEndTextEdit(); 2892 } 2893 2894 if ( mpDrawView->IsBreak3DObjPossible() ) 2895 { 2896 weld::WaitObject aWait(GetFrameWeld()); 2897 mpDrawView->Break3DObj(); 2898 } 2899 else if ( mpDrawView->IsDismantlePossible(true) ) 2900 { 2901 weld::WaitObject aWait(GetFrameWeld()); 2902 mpDrawView->DismantleMarkedObjects(true); 2903 } 2904 else if ( mpDrawView->IsImportMtfPossible() ) 2905 { 2906 weld::WaitObject aWait(GetFrameWeld()); 2907 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 2908 const size_t nCnt=rMarkList.GetMarkCount(); 2909 2910 // determine the sum of meta objects of all selected meta files 2911 sal_uLong nCount = 0; 2912 for(size_t nm=0; nm<nCnt; ++nm) 2913 { 2914 SdrMark* pM=rMarkList.GetMark(nm); 2915 SdrObject* pObj=pM->GetMarkedSdrObj(); 2916 SdrGrafObj* pGraf= dynamic_cast< SdrGrafObj *>( pObj ); 2917 SdrOle2Obj* pOle2= dynamic_cast< SdrOle2Obj *>( pObj ); 2918 2919 if (pGraf != nullptr) 2920 { 2921 if (pGraf->HasGDIMetaFile()) 2922 { 2923 nCount += pGraf->GetGraphic().GetGDIMetaFile().GetActionSize(); 2924 } 2925 else if (pGraf->isEmbeddedVectorGraphicData()) 2926 { 2927 nCount += pGraf->getMetafileFromEmbeddedVectorGraphicData().GetActionSize(); 2928 } 2929 } 2930 2931 if(pOle2 && pOle2->GetGraphic()) 2932 { 2933 nCount += pOle2->GetGraphic()->GetGDIMetaFile().GetActionSize(); 2934 } 2935 } 2936 2937 // decide with the sum of all meta objects if we should show a dialog 2938 if(nCount < MIN_ACTIONS_FOR_DIALOG) 2939 { 2940 // nope, no dialog 2941 mpDrawView->DoImportMarkedMtf(); 2942 } 2943 else 2944 { 2945 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 2946 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateBreakDlg(GetFrameWeld(), mpDrawView.get(), GetDocSh(), nCount, static_cast<sal_uLong>(nCnt) )); 2947 pDlg->Execute(); 2948 } 2949 } 2950 2951 Cancel(); 2952 rReq.Done (); 2953 } 2954 break; 2955 2956 case SID_CONVERT_TO_3D: 2957 { 2958 if ( mpDrawView->IsPresObjSelected() ) 2959 { 2960 std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), 2961 VclMessageType::Info, VclButtonsType::Ok, 2962 SdResId(STR_ACTION_NOTPOSSIBLE))); 2963 xInfoBox->run(); 2964 } 2965 else 2966 { 2967 if (mpDrawView->IsConvertTo3DObjPossible()) 2968 { 2969 if (mpDrawView->IsTextEdit()) 2970 { 2971 mpDrawView->SdrEndTextEdit(); 2972 } 2973 2974 weld::WaitObject aWait(GetFrameWeld()); 2975 mpDrawView->ConvertMarkedObjTo3D(); 2976 } 2977 } 2978 2979 Cancel(); 2980 rReq.Done(); 2981 } 2982 break; 2983 2984 case SID_FRAME_TO_TOP: // BASIC 2985 { 2986 mpDrawView->PutMarkedToTop(); 2987 Cancel(); 2988 rReq.Done (); 2989 } 2990 break; 2991 2992 case SID_MOREFRONT: // BASIC 2993 case SID_FRAME_UP: // BASIC 2994 { 2995 mpDrawView->MovMarkedToTop(); 2996 Cancel(); 2997 rReq.Done (); 2998 } 2999 break; 3000 3001 case SID_MOREBACK: // BASIC 3002 case SID_FRAME_DOWN: // BASIC 3003 { 3004 mpDrawView->MovMarkedToBtm(); 3005 Cancel(); 3006 rReq.Done (); 3007 } 3008 break; 3009 3010 case SID_FRAME_TO_BOTTOM: // BASIC 3011 { 3012 mpDrawView->PutMarkedToBtm(); 3013 Cancel(); 3014 rReq.Done (); 3015 } 3016 break; 3017 3018 case SID_HORIZONTAL: // BASIC 3019 case SID_FLIP_HORIZONTAL: 3020 { 3021 mpDrawView->MirrorAllMarkedHorizontal(); 3022 Cancel(); 3023 rReq.Done (); 3024 } 3025 break; 3026 3027 case SID_VERTICAL: // BASIC 3028 case SID_FLIP_VERTICAL: 3029 { 3030 mpDrawView->MirrorAllMarkedVertical(); 3031 Cancel(); 3032 rReq.Done (); 3033 } 3034 break; 3035 3036 case SID_OBJECT_ALIGN_LEFT: // BASIC 3037 { 3038 mpDrawView->AlignMarkedObjects(SdrHorAlign::Left, SdrVertAlign::NONE); 3039 Cancel(); 3040 rReq.Done (); 3041 } 3042 break; 3043 3044 case SID_OBJECT_ALIGN_CENTER: // BASIC 3045 { 3046 mpDrawView->AlignMarkedObjects(SdrHorAlign::Center, SdrVertAlign::NONE); 3047 Cancel(); 3048 rReq.Done (); 3049 } 3050 break; 3051 3052 case SID_OBJECT_ALIGN_RIGHT: // BASIC 3053 { 3054 mpDrawView->AlignMarkedObjects(SdrHorAlign::Right, SdrVertAlign::NONE); 3055 Cancel(); 3056 rReq.Done (); 3057 } 3058 break; 3059 3060 case SID_OBJECT_ALIGN_UP: // BASIC 3061 { 3062 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Top); 3063 Cancel(); 3064 rReq.Done (); 3065 } 3066 break; 3067 3068 case SID_OBJECT_ALIGN_MIDDLE: // BASIC 3069 { 3070 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Center); 3071 Cancel(); 3072 rReq.Done (); 3073 } 3074 break; 3075 3076 case SID_OBJECT_ALIGN_DOWN: // BASIC 3077 { 3078 mpDrawView->AlignMarkedObjects(SdrHorAlign::NONE, SdrVertAlign::Bottom); 3079 Cancel(); 3080 rReq.Done (); 3081 } 3082 break; 3083 3084 case SID_SELECTALL: // BASIC 3085 { 3086 if( (dynamic_cast<FuSelection*>( GetOldFunction().get() ) != nullptr) && 3087 !GetView()->IsFrameDragSingles() && GetView()->HasMarkablePoints()) 3088 { 3089 if ( !mpDrawView->IsAction() ) 3090 mpDrawView->MarkAllPoints(); 3091 } 3092 else 3093 mpDrawView->SelectAll(); 3094 3095 Cancel(); 3096 rReq.Done (); 3097 } 3098 break; 3099 3100 case SID_STYLE_NEW: // BASIC ??? 3101 case SID_STYLE_APPLY: 3102 case SID_STYLE_EDIT: 3103 case SID_STYLE_DELETE: 3104 case SID_STYLE_HIDE: 3105 case SID_STYLE_SHOW: 3106 case SID_STYLE_FAMILY: 3107 case SID_STYLE_WATERCAN: 3108 case SID_STYLE_UPDATE_BY_EXAMPLE: 3109 case SID_STYLE_NEW_BY_EXAMPLE: 3110 { 3111 if( rReq.GetSlot() == SID_STYLE_EDIT && !rReq.GetArgs() ) 3112 { 3113 SfxStyleSheet* pStyleSheet = mpDrawView->GetStyleSheet(); 3114 if( pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page) 3115 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet(); 3116 3117 if( (pStyleSheet == nullptr) && GetView()->IsTextEdit() ) 3118 { 3119 GetView()->SdrEndTextEdit(); 3120 3121 pStyleSheet = mpDrawView->GetStyleSheet(); 3122 if(pStyleSheet && pStyleSheet->GetFamily() == SfxStyleFamily::Page) 3123 pStyleSheet = static_cast<SdStyleSheet*>(pStyleSheet)->GetPseudoStyleSheet(); 3124 } 3125 3126 if( pStyleSheet == nullptr ) 3127 { 3128 rReq.Ignore(); 3129 break; 3130 } 3131 3132 SfxAllItemSet aSet(GetDoc()->GetPool()); 3133 3134 SfxStringItem aStyleNameItem( SID_STYLE_EDIT, pStyleSheet->GetName() ); 3135 aSet.Put(aStyleNameItem); 3136 3137 SfxUInt16Item aStyleFamilyItem( SID_STYLE_FAMILY, static_cast<sal_uInt16>(pStyleSheet->GetFamily()) ); 3138 aSet.Put(aStyleFamilyItem); 3139 3140 rReq.SetArgs(aSet); 3141 } 3142 3143 if( rReq.GetArgs() ) 3144 { 3145 SetCurrentFunction( FuTemplate::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 3146 if( rReq.GetSlot() == SID_STYLE_APPLY ) 3147 GetViewFrame()->GetBindings().Invalidate( SID_STYLE_APPLY ); 3148 Cancel(); 3149 } 3150 else if( rReq.GetSlot() == SID_STYLE_APPLY ) 3151 GetViewFrame()->GetDispatcher()->Execute( SID_STYLE_DESIGNER, SfxCallMode::ASYNCHRON ); 3152 rReq.Ignore (); 3153 } 3154 break; 3155 3156 case SID_IMAP: 3157 { 3158 sal_uInt16 nId = SvxIMapDlgChildWindow::GetChildWindowId(); 3159 3160 GetViewFrame()->ToggleChildWindow( nId ); 3161 GetViewFrame()->GetBindings().Invalidate( SID_IMAP ); 3162 3163 if ( GetViewFrame()->HasChildWindow( nId ) 3164 && ( ( ViewShell::Implementation::GetImageMapDialog() ) != nullptr ) ) 3165 { 3166 const SdrMarkList& rMarkList = mpDrawView->GetMarkedObjectList(); 3167 3168 if ( rMarkList.GetMarkCount() == 1 ) 3169 UpdateIMapDlg( rMarkList.GetMark( 0 )->GetMarkedSdrObj() ); 3170 } 3171 3172 Cancel(); 3173 rReq.Ignore (); 3174 } 3175 break; 3176 3177 case SID_GRID_FRONT: 3178 { 3179 mpDrawView->SetGridFront( !mpDrawView->IsGridFront() ); 3180 Cancel(); 3181 rReq.Done (); 3182 } 3183 break; 3184 3185 case SID_HELPLINES_FRONT: 3186 { 3187 mpDrawView->SetHlplFront( !mpDrawView->IsHlplFront() ); 3188 Cancel(); 3189 rReq.Done (); 3190 } 3191 break; 3192 3193 case SID_FONTWORK: 3194 { 3195 if ( rReq.GetArgs() ) 3196 { 3197 GetViewFrame()->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), 3198 static_cast<const SfxBoolItem&>(rReq.GetArgs()-> 3199 Get(SID_FONTWORK)).GetValue()); 3200 } 3201 else 3202 { 3203 GetViewFrame()->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); 3204 } 3205 3206 GetViewFrame()->GetBindings().Invalidate(SID_FONTWORK); 3207 Cancel(); 3208 rReq.Ignore (); 3209 } 3210 break; 3211 3212 case SID_COLOR_CONTROL: 3213 { 3214 if ( rReq.GetArgs() ) 3215 GetViewFrame()->SetChildWindow(SvxColorChildWindow::GetChildWindowId(), 3216 static_cast<const SfxBoolItem&>(rReq.GetArgs()-> 3217 Get(SID_COLOR_CONTROL)).GetValue()); 3218 else 3219 GetViewFrame()->ToggleChildWindow(SvxColorChildWindow::GetChildWindowId() ); 3220 3221 GetViewFrame()->GetBindings().Invalidate(SID_COLOR_CONTROL); 3222 Cancel(); 3223 rReq.Ignore (); 3224 } 3225 break; 3226 3227 case SID_EXTRUSION_TOGGLE: 3228 case SID_EXTRUSION_TILT_DOWN: 3229 case SID_EXTRUSION_TILT_UP: 3230 case SID_EXTRUSION_TILT_LEFT: 3231 case SID_EXTRUSION_TILT_RIGHT: 3232 case SID_EXTRUSION_3D_COLOR: 3233 case SID_EXTRUSION_DEPTH: 3234 case SID_EXTRUSION_DIRECTION: 3235 case SID_EXTRUSION_PROJECTION: 3236 case SID_EXTRUSION_LIGHTING_DIRECTION: 3237 case SID_EXTRUSION_LIGHTING_INTENSITY: 3238 case SID_EXTRUSION_SURFACE: 3239 case SID_EXTRUSION_DEPTH_FLOATER: 3240 case SID_EXTRUSION_DIRECTION_FLOATER: 3241 case SID_EXTRUSION_LIGHTING_FLOATER: 3242 case SID_EXTRUSION_SURFACE_FLOATER: 3243 case SID_EXTRUSION_DEPTH_DIALOG: 3244 svx::ExtrusionBar::execute( mpDrawView.get(), rReq, GetViewFrame()->GetBindings() ); 3245 Cancel(); 3246 rReq.Ignore (); 3247 break; 3248 3249 case SID_FONTWORK_SHAPE: 3250 case SID_FONTWORK_SHAPE_TYPE: 3251 case SID_FONTWORK_ALIGNMENT: 3252 case SID_FONTWORK_SAME_LETTER_HEIGHTS: 3253 case SID_FONTWORK_CHARACTER_SPACING: 3254 case SID_FONTWORK_KERN_CHARACTER_PAIRS: 3255 case SID_FONTWORK_GALLERY_FLOATER: 3256 case SID_FONTWORK_CHARACTER_SPACING_FLOATER: 3257 case SID_FONTWORK_ALIGNMENT_FLOATER: 3258 case SID_FONTWORK_CHARACTER_SPACING_DIALOG: 3259 svx::FontworkBar::execute(*mpDrawView, rReq, GetViewFrame()->GetBindings()); 3260 Cancel(); 3261 rReq.Ignore (); 3262 break; 3263 3264 case SID_BMPMASK: 3265 { 3266 GetViewFrame()->ToggleChildWindow( SvxBmpMaskChildWindow::GetChildWindowId() ); 3267 GetViewFrame()->GetBindings().Invalidate( SID_BMPMASK ); 3268 3269 Cancel(); 3270 rReq.Ignore (); 3271 } 3272 break; 3273 3274 case SID_NAVIGATOR: 3275 { 3276 if ( rReq.GetArgs() ) 3277 GetViewFrame()->SetChildWindow(SID_NAVIGATOR, 3278 static_cast<const SfxBoolItem&>(rReq.GetArgs()-> 3279 Get(SID_NAVIGATOR)).GetValue()); 3280 else 3281 GetViewFrame()->ToggleChildWindow( SID_NAVIGATOR ); 3282 3283 GetViewFrame()->GetBindings().Invalidate(SID_NAVIGATOR); 3284 Cancel(); 3285 rReq.Ignore (); 3286 } 3287 break; 3288 3289 case SID_SLIDE_TRANSITIONS_PANEL: 3290 case SID_MASTER_SLIDES_PANEL: 3291 case SID_CUSTOM_ANIMATION_PANEL: 3292 case SID_GALLERY: 3293 { 3294 // First make sure that the sidebar is visible 3295 GetViewFrame()->ShowChildWindow(SID_SIDEBAR); 3296 3297 OUString panelId; 3298 if (nSId == SID_CUSTOM_ANIMATION_PANEL) 3299 panelId = "SdCustomAnimationPanel"; 3300 else if (nSId == SID_GALLERY) 3301 panelId = "GalleryPanel"; 3302 else if (nSId == SID_SLIDE_TRANSITIONS_PANEL) 3303 panelId = "SdSlideTransitionPanel"; 3304 else if (nSId == SID_MASTER_SLIDES_PANEL) 3305 panelId = "SdAllMasterPagesPanel"; 3306 3307 ::sfx2::sidebar::Sidebar::TogglePanel( 3308 panelId, 3309 GetViewFrame()->GetFrame().GetFrameInterface()); 3310 3311 Cancel(); 3312 rReq.Done(); 3313 } 3314 break; 3315 3316 case SID_ANIMATION_OBJECTS: 3317 { 3318 if ( rReq.GetArgs() ) 3319 GetViewFrame()->SetChildWindow( 3320 AnimationChildWindow::GetChildWindowId(), 3321 static_cast<const SfxBoolItem&>(rReq.GetArgs()-> 3322 Get(SID_ANIMATION_OBJECTS)).GetValue()); 3323 else 3324 GetViewFrame()->ToggleChildWindow( 3325 AnimationChildWindow::GetChildWindowId() ); 3326 3327 GetViewFrame()->GetBindings().Invalidate(SID_ANIMATION_OBJECTS); 3328 Cancel(); 3329 rReq.Ignore (); 3330 } 3331 break; 3332 3333 case SID_3D_WIN: 3334 { 3335 if ( rReq.GetArgs() ) 3336 GetViewFrame()->SetChildWindow( Svx3DChildWindow::GetChildWindowId(), 3337 static_cast<const SfxBoolItem&>(rReq.GetArgs()-> 3338 Get( SID_3D_WIN )).GetValue()); 3339 else 3340 GetViewFrame()->ToggleChildWindow( Svx3DChildWindow::GetChildWindowId() ); 3341 3342 GetViewFrame()->GetBindings().Invalidate( SID_3D_WIN ); 3343 Cancel(); 3344 rReq.Ignore (); 3345 } 3346 break; 3347 3348 case SID_CONVERT_TO_3D_LATHE_FAST: 3349 { 3350 /* The call is enough. The initialization via Start3DCreation and 3351 CreateMirrorPolygons is no longer needed if the parameter 3352 sal_True is provided. Then a tilted rotary body with an axis left 3353 besides the bounding rectangle of the selected objects is drawn 3354 immediately and without user interaction. */ 3355 mpDrawView->SdrEndTextEdit(); 3356 if(GetActiveWindow()) 3357 GetActiveWindow()->EnterWait(); 3358 mpDrawView->End3DCreation(true); 3359 Cancel(); 3360 rReq.Ignore(); 3361 if(GetActiveWindow()) 3362 GetActiveWindow()->LeaveWait(); 3363 } 3364 break; 3365 3366 case SID_PRESENTATION_DLG: 3367 { 3368 SetCurrentFunction( FuSlideShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 3369 Cancel(); 3370 } 3371 break; 3372 3373 case SID_REMOTE_DLG: 3374 { 3375 #ifdef ENABLE_SDREMOTE 3376 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 3377 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateRemoteDialog(GetFrameWeld())); 3378 pDlg->Execute(); 3379 #endif 3380 } 3381 break; 3382 3383 case SID_CUSTOMSHOW_DLG: 3384 { 3385 SetCurrentFunction( FuCustomShowDlg::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 3386 Cancel(); 3387 } 3388 break; 3389 3390 case SID_EXPAND_PAGE: 3391 { 3392 SetCurrentFunction( FuExpandPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 3393 Cancel(); 3394 } 3395 break; 3396 3397 case SID_SUMMARY_PAGE: 3398 { 3399 mpDrawView->SdrEndTextEdit(); 3400 SetCurrentFunction( FuSummaryPage::Create( this, GetActiveWindow(), mpDrawView.get(), GetDoc(), rReq ) ); 3401 Cancel(); 3402 } 3403 break; 3404 3405 #if HAVE_FEATURE_AVMEDIA 3406 case SID_AVMEDIA_PLAYER: 3407 { 3408 GetViewFrame()->ToggleChildWindow( ::avmedia::MediaPlayer::GetChildWindowId() ); 3409 GetViewFrame()->GetBindings().Invalidate( SID_AVMEDIA_PLAYER ); 3410 Cancel(); 3411 rReq.Ignore (); 3412 } 3413 break; 3414 #endif 3415 3416 case SID_PRESENTATION_MINIMIZER: 3417 { 3418 Reference<XComponentContext> xContext(::comphelper::getProcessComponentContext()); 3419 Reference<util::XURLTransformer> xParser(util::URLTransformer::create(xContext)); 3420 Reference<frame::XDispatchProvider> xProvider(GetViewShellBase().GetController()->getFrame(), UNO_QUERY); 3421 if (xProvider.is()) 3422 { 3423 util::URL aURL; 3424 aURL.Complete = "vnd.com.sun.star.comp.PresentationMinimizer:execute"; 3425 xParser->parseStrict(aURL); 3426 uno::Reference<frame::XDispatch> xDispatch(xProvider->queryDispatch(aURL, OUString(), 0)); 3427 if (xDispatch.is()) 3428 { 3429 xDispatch->dispatch(aURL, uno::Sequence< beans::PropertyValue >()); 3430 } 3431 } 3432 Cancel(); 3433 rReq.Ignore(); 3434 } 3435 break; 3436 3437 case SID_DISPLAY_MASTER_BACKGROUND: 3438 case SID_DISPLAY_MASTER_OBJECTS: 3439 { 3440 // Determine current page and toggle visibility of layers 3441 // associated with master page background or master page shapes. 3442 // FIXME: This solution is wrong, because shapes of master pages need 3443 // not be on layer "background" or "backgroundobjects". 3444 // See tdf#118613 3445 SdPage* pPage = GetActualPage(); 3446 if (pPage != nullptr 3447 && GetDoc() != nullptr) 3448 { 3449 SdrLayerIDSet aVisibleLayers = pPage->TRG_GetMasterPageVisibleLayers(); 3450 SdrLayerAdmin& rLayerAdmin = GetDoc()->GetLayerAdmin(); 3451 SdrLayerID aLayerId; 3452 if (nSId == SID_DISPLAY_MASTER_BACKGROUND) 3453 aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background); 3454 else 3455 aLayerId = rLayerAdmin.GetLayerID(sUNO_LayerName_background_objects); 3456 aVisibleLayers.Set(aLayerId, !aVisibleLayers.IsSet(aLayerId)); 3457 pPage->TRG_SetMasterPageVisibleLayers(aVisibleLayers); 3458 } 3459 Cancel(); 3460 rReq.Ignore (); 3461 } 3462 break; 3463 3464 case SID_PHOTOALBUM: 3465 { 3466 SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create(); 3467 vcl::Window* pWin = GetActiveWindow(); 3468 ScopedVclPtr<VclAbstractDialog> pDlg(pFact->CreateSdPhotoAlbumDialog( 3469 pWin ? pWin->GetFrameWeld() : nullptr, 3470 GetDoc())); 3471 3472 pDlg->Execute(); 3473 Cancel(); 3474 rReq.Ignore (); 3475 } 3476 break; 3477 3478 case SID_INSERT_QRCODE: 3479 case SID_EDIT_QRCODE: 3480 { 3481 VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); 3482 const uno::Reference<frame::XModel> xModel = GetViewShellBase().GetController()->getModel(); 3483 ScopedVclPtr<AbstractQrCodeGenDialog> pDlg(pFact->CreateQrCodeGenDialog( 3484 GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_QRCODE)); 3485 pDlg->Execute(); 3486 Cancel(); 3487 rReq.Ignore (); 3488 } 3489 break; 3490 3491 case SID_ADDITIONS_DIALOG: 3492 { 3493 VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create(); 3494 ScopedVclPtr<AbstractAdditionsDialog> pDlg( 3495 pFact->CreateAdditionsDialog(GetFrameWeld())); 3496 pDlg->Execute(); 3497 Cancel(); 3498 rReq.Ignore (); 3499 } 3500 break; 3501 3502 case SID_ATTR_GLOW_COLOR: 3503 case SID_ATTR_GLOW_RADIUS: 3504 case SID_ATTR_GLOW_TRANSPARENCY: 3505 case SID_ATTR_SOFTEDGE_RADIUS: 3506 if (const SfxItemSet* pNewArgs = rReq.GetArgs()) 3507 mpDrawView->SetAttributes(*pNewArgs); 3508 rReq.Done(); 3509 Cancel(); 3510 break; 3511 3512 default: 3513 { 3514 SAL_WARN( "sd.ui", "Slot without function" ); 3515 Cancel(); 3516 rReq.Ignore (); 3517 } 3518 break; 3519 } 3520 3521 if(HasCurrentFunction()) 3522 { 3523 GetCurrentFunction()->Activate(); 3524 } 3525 } 3526 3527 void DrawViewShell::ExecChar( SfxRequest &rReq ) 3528 { 3529 SdDrawDocument* pDoc = GetDoc(); 3530 if (!pDoc || !mpDrawView) 3531 return; 3532 3533 SfxItemSet aEditAttr( pDoc->GetPool() ); 3534 mpDrawView->GetAttributes( aEditAttr ); 3535 3536 //modified by wj for sym2_1580, if put old itemset into new set, 3537 //when mpDrawView->SetAttributes(aNewAttr) it will invalidate all the item 3538 // and use old attr to update all the attributes 3539 // SfxItemSet aNewAttr( GetPool(), 3540 // EE_ITEMS_START, EE_ITEMS_END ); 3541 // aNewAttr.Put( aEditAttr, sal_False ); 3542 SfxItemSet aNewAttr( pDoc->GetPool() ); 3543 //modified end 3544 3545 sal_uInt16 nSId = rReq.GetSlot(); 3546 3547 switch ( nSId ) 3548 { 3549 case SID_ATTR_CHAR_FONT: 3550 if( rReq.GetArgs() ) 3551 { 3552 const SvxFontItem* pItem = rReq.GetArg<SvxFontItem>(SID_ATTR_CHAR_FONT); 3553 if (pItem) 3554 { 3555 aNewAttr.Put(*pItem); 3556 } 3557 } 3558 break; 3559 case SID_ATTR_CHAR_FONTHEIGHT: 3560 if( rReq.GetArgs() ) 3561 { 3562 const SvxFontHeightItem* pItem = rReq.GetArg<SvxFontHeightItem>(SID_ATTR_CHAR_FONTHEIGHT); 3563 if (pItem) 3564 { 3565 aNewAttr.Put(*pItem); 3566 } 3567 } 3568 break; 3569 case SID_ATTR_CHAR_WEIGHT: 3570 if( rReq.GetArgs() ) 3571 { 3572 const SvxWeightItem* pItem = rReq.GetArg<SvxWeightItem>(SID_ATTR_CHAR_WEIGHT); 3573 if (pItem) 3574 { 3575 aNewAttr.Put(*pItem); 3576 } 3577 } 3578 break; 3579 case SID_ATTR_CHAR_POSTURE: 3580 if( rReq.GetArgs() ) 3581 { 3582 const SvxPostureItem* pItem = rReq.GetArg<SvxPostureItem>(SID_ATTR_CHAR_POSTURE); 3583 if (pItem) 3584 { 3585 aNewAttr.Put(*pItem); 3586 } 3587 } 3588 break; 3589 case SID_ATTR_CHAR_UNDERLINE: 3590 if( rReq.GetArgs() ) 3591 { 3592 const SvxUnderlineItem* pItem = rReq.GetArg<SvxUnderlineItem>(SID_ATTR_CHAR_UNDERLINE); 3593 if (pItem) 3594 { 3595 aNewAttr.Put(*pItem); 3596 } 3597 else 3598 { 3599 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_UNDERLINE ).GetLineStyle(); 3600 aNewAttr.Put( SvxUnderlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_UNDERLINE ) ); 3601 } 3602 } 3603 break; 3604 case SID_ATTR_CHAR_OVERLINE: 3605 if( rReq.GetArgs() ) 3606 { 3607 const SvxOverlineItem* pItem = rReq.GetArg<SvxOverlineItem>(SID_ATTR_CHAR_OVERLINE); 3608 if (pItem) 3609 { 3610 aNewAttr.Put(*pItem); 3611 } 3612 else 3613 { 3614 FontLineStyle eFU = aEditAttr.Get( EE_CHAR_OVERLINE ).GetLineStyle(); 3615 aNewAttr.Put( SvxOverlineItem( eFU != LINESTYLE_NONE ?LINESTYLE_NONE : LINESTYLE_SINGLE, EE_CHAR_OVERLINE ) ); 3616 } 3617 } 3618 break; 3619 3620 case SID_ULINE_VAL_NONE: 3621 { 3622 aNewAttr.Put(SvxUnderlineItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE)); 3623 break; 3624 } 3625 3626 case SID_ULINE_VAL_SINGLE: 3627 case SID_ULINE_VAL_DOUBLE: 3628 case SID_ULINE_VAL_DOTTED: 3629 { 3630 FontLineStyle eOld = aEditAttr.Get(EE_CHAR_UNDERLINE).GetLineStyle(); 3631 FontLineStyle eNew = eOld; 3632 3633 switch (nSId) 3634 { 3635 case SID_ULINE_VAL_SINGLE: 3636 eNew = ( eOld == LINESTYLE_SINGLE ) ? LINESTYLE_NONE : LINESTYLE_SINGLE; 3637 break; 3638 case SID_ULINE_VAL_DOUBLE: 3639 eNew = ( eOld == LINESTYLE_DOUBLE ) ? LINESTYLE_NONE : LINESTYLE_DOUBLE; 3640 break; 3641 case SID_ULINE_VAL_DOTTED: 3642 eNew = ( eOld == LINESTYLE_DOTTED ) ? LINESTYLE_NONE : LINESTYLE_DOTTED; 3643 break; 3644 } 3645 3646 SvxUnderlineItem aUnderline(eNew, EE_CHAR_UNDERLINE); 3647 aNewAttr.Put(aUnderline); 3648 } 3649 break; 3650 3651 case SID_ATTR_CHAR_SHADOWED: 3652 if( rReq.GetArgs() ) 3653 { 3654 const SvxShadowedItem* pItem = rReq.GetArg<SvxShadowedItem>(SID_ATTR_CHAR_SHADOWED); 3655 if (pItem) 3656 { 3657 aNewAttr.Put(*pItem); 3658 } 3659 } 3660 break; 3661 case SID_ATTR_CHAR_CONTOUR: 3662 if( rReq.GetArgs() ) 3663 { 3664 const SvxContourItem* pItem = rReq.GetArg<SvxContourItem>(SID_ATTR_CHAR_CONTOUR); 3665 if (pItem) 3666 { 3667 aNewAttr.Put(*pItem); 3668 } 3669 } 3670 break; 3671 3672 case SID_ATTR_CHAR_STRIKEOUT: 3673 if( rReq.GetArgs() ) 3674 { 3675 const SvxCrossedOutItem* pItem = rReq.GetArg<SvxCrossedOutItem>(SID_ATTR_CHAR_STRIKEOUT); 3676 if (pItem) 3677 { 3678 aNewAttr.Put(*pItem); 3679 } 3680 } 3681 break; 3682 case SID_ATTR_CHAR_COLOR: 3683 if( rReq.GetArgs() ) 3684 { 3685 const SvxColorItem* pItem = rReq.GetArg<SvxColorItem>(SID_ATTR_CHAR_COLOR); 3686 if (pItem) 3687 { 3688 aNewAttr.Put(*pItem); 3689 } 3690 } 3691 break; 3692 case SID_ATTR_CHAR_KERNING: 3693 if( rReq.GetArgs() ) 3694 { 3695 const SvxKerningItem* pItem = rReq.GetArg<SvxKerningItem>(SID_ATTR_CHAR_KERNING); 3696 if (pItem) 3697 { 3698 aNewAttr.Put(*pItem); 3699 } 3700 } 3701 break; 3702 case SID_ATTR_CHAR_CASEMAP: 3703 if( rReq.GetArgs() ) 3704 { 3705 const SvxCaseMapItem* pItem = rReq.GetArg<SvxCaseMapItem>(SID_ATTR_CHAR_CASEMAP); 3706 if (pItem) 3707 { 3708 aNewAttr.Put(*pItem); 3709 } 3710 } 3711 break; 3712 case SID_SET_SUB_SCRIPT: 3713 { 3714 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); 3715 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); 3716 if( eEsc == SvxEscapement::Subscript ) 3717 aItem.SetEscapement( SvxEscapement::Off ); 3718 else 3719 aItem.SetEscapement( SvxEscapement::Subscript ); 3720 aNewAttr.Put( aItem ); 3721 } 3722 break; 3723 case SID_SET_SUPER_SCRIPT: 3724 { 3725 SvxEscapementItem aItem( EE_CHAR_ESCAPEMENT ); 3726 SvxEscapement eEsc = static_cast<SvxEscapement>(aEditAttr.Get( EE_CHAR_ESCAPEMENT ).GetEnumValue()); 3727 if( eEsc == SvxEscapement::Superscript ) 3728 aItem.SetEscapement( SvxEscapement::Off ); 3729 else 3730 aItem.SetEscapement( SvxEscapement::Superscript ); 3731 aNewAttr.Put( aItem ); 3732 } 3733 break; 3734 case SID_SHRINK_FONT_SIZE: 3735 case SID_GROW_FONT_SIZE: 3736 { 3737 const SvxFontListItem* pFonts = dynamic_cast<const SvxFontListItem*>(GetDocSh()->GetItem( SID_ATTR_CHAR_FONTLIST ) ); 3738 const FontList* pFontList = pFonts ? pFonts->GetFontList() : nullptr; 3739 if( pFontList ) 3740 { 3741 FuText::ChangeFontSize( nSId == SID_GROW_FONT_SIZE, nullptr, pFontList, mpView ); 3742 GetViewFrame()->GetBindings().Invalidate( SID_ATTR_CHAR_FONTHEIGHT ); 3743 } 3744 break; 3745 } 3746 case SID_ATTR_CHAR_BACK_COLOR: 3747 if( rReq.GetArgs() ) 3748 { 3749 const SvxBackgroundColorItem* pItem = rReq.GetArg<SvxBackgroundColorItem>(SID_ATTR_CHAR_BACK_COLOR); 3750 if (pItem) 3751 { 3752 aNewAttr.Put(*pItem); 3753 } 3754 } 3755 break; 3756 default: 3757 break; 3758 } 3759 3760 mpDrawView->SetAttributes(aNewAttr); 3761 rReq.Done(); 3762 Cancel(); 3763 } 3764 3765 /** This method consists basically of three parts: 3766 1. Process the arguments of the SFX request. 3767 2. Use the model to create a new page or duplicate an existing one. 3768 3. Update the tab control and switch to the new page. 3769 */ 3770 SdPage* DrawViewShell::CreateOrDuplicatePage ( 3771 SfxRequest& rRequest, 3772 PageKind ePageKind, 3773 SdPage* pPage, 3774 const sal_Int32 nInsertPosition) 3775 { 3776 SdPage* pNewPage = nullptr; 3777 if (ePageKind == PageKind::Standard && meEditMode != EditMode::MasterPage) 3778 { 3779 if ( mpDrawView->IsTextEdit() ) 3780 { 3781 mpDrawView->SdrEndTextEdit(); 3782 } 3783 pNewPage = ViewShell::CreateOrDuplicatePage (rRequest, ePageKind, pPage, nInsertPosition); 3784 } 3785 return pNewPage; 3786 } 3787 3788 void DrawViewShell::DuplicateSelectedSlides (SfxRequest& rRequest) 3789 { 3790 // Create a list of the pages that are to be duplicated. The process of 3791 // duplication alters the selection. 3792 sal_Int32 nInsertPosition (0); 3793 ::std::vector<SdPage*> aPagesToDuplicate; 3794 sd::slidesorter::SlideSorter &mrSlideSorter = sd::slidesorter::SlideSorterViewShell::GetSlideSorter(GetViewShellBase())->GetSlideSorter(); 3795 sd::slidesorter::model::PageEnumeration aSelectedPages ( 3796 sd::slidesorter::model::PageEnumerationProvider::CreateSelectedPagesEnumeration(mrSlideSorter.GetModel())); 3797 while (aSelectedPages.HasMoreElements()) 3798 { 3799 sd::slidesorter::model::SharedPageDescriptor pDescriptor (aSelectedPages.GetNextElement()); 3800 if (pDescriptor && pDescriptor->GetPage()) 3801 { 3802 aPagesToDuplicate.push_back(pDescriptor->GetPage()); 3803 nInsertPosition = pDescriptor->GetPage()->GetPageNum()+2; 3804 } 3805 } 3806 3807 // Duplicate the pages in aPagesToDuplicate and collect the newly 3808 // created pages in aPagesToSelect. 3809 const bool bUndo (aPagesToDuplicate.size()>1 && mrSlideSorter.GetView().IsUndoEnabled()); 3810 if (bUndo) 3811 mrSlideSorter.GetView().BegUndo(SdResId(STR_INSERTPAGE)); 3812 3813 ::std::vector<SdPage*> aPagesToSelect; 3814 for(::std::vector<SdPage*>::const_iterator 3815 iPage(aPagesToDuplicate.begin()), 3816 iEnd(aPagesToDuplicate.end()); 3817 iPage!=iEnd; 3818 ++iPage, nInsertPosition+=2) 3819 { 3820 aPagesToSelect.push_back( 3821 mrSlideSorter.GetViewShell()->CreateOrDuplicatePage( 3822 rRequest, PageKind::Standard, *iPage, nInsertPosition)); 3823 } 3824 aPagesToDuplicate.clear(); 3825 3826 if (bUndo) 3827 mrSlideSorter.GetView().EndUndo(); 3828 3829 // Set the selection to the pages in aPagesToSelect. 3830 sd::slidesorter::controller::PageSelector& rSelector (mrSlideSorter.GetController().GetPageSelector()); 3831 rSelector.DeselectAllPages(); 3832 for (auto const& it: aPagesToSelect) 3833 { 3834 rSelector.SelectPage(it); 3835 } 3836 } 3837 3838 void DrawViewShell::ExecutePropPanelAttr (SfxRequest const & rReq) 3839 { 3840 if(SlideShow::IsRunning( GetViewShellBase() )) 3841 return; 3842 3843 SdDrawDocument* pDoc = GetDoc(); 3844 if (!pDoc || !mpDrawView) 3845 return; 3846 3847 sal_uInt16 nSId = rReq.GetSlot(); 3848 SfxItemSet aAttrs( pDoc->GetPool() ); 3849 3850 switch ( nSId ) 3851 { 3852 case SID_TABLE_VERT_NONE: 3853 case SID_TABLE_VERT_CENTER: 3854 case SID_TABLE_VERT_BOTTOM: 3855 SdrTextVertAdjust eTVA = SDRTEXTVERTADJUST_TOP; 3856 if (nSId == SID_TABLE_VERT_CENTER) 3857 eTVA = SDRTEXTVERTADJUST_CENTER; 3858 else if (nSId == SID_TABLE_VERT_BOTTOM) 3859 eTVA = SDRTEXTVERTADJUST_BOTTOM; 3860 3861 aAttrs.Put( SdrTextVertAdjustItem(eTVA) ); 3862 mpDrawView->SetAttributes(aAttrs); 3863 3864 break; 3865 } 3866 } 3867 3868 void DrawViewShell::GetStatePropPanelAttr(SfxItemSet& rSet) 3869 { 3870 SfxWhichIter aIter( rSet ); 3871 sal_uInt16 nWhich = aIter.FirstWhich(); 3872 3873 SdDrawDocument* pDoc = GetDoc(); 3874 if (!pDoc || !mpDrawView) 3875 return; 3876 3877 SfxItemSet aAttrs( pDoc->GetPool() ); 3878 mpDrawView->GetAttributes( aAttrs ); 3879 3880 while ( nWhich ) 3881 { 3882 sal_uInt16 nSlotId = SfxItemPool::IsWhich(nWhich) 3883 ? GetPool().GetSlotId(nWhich) 3884 : nWhich; 3885 switch ( nSlotId ) 3886 { 3887 case SID_TABLE_VERT_NONE: 3888 case SID_TABLE_VERT_CENTER: 3889 case SID_TABLE_VERT_BOTTOM: 3890 bool bContour = false; 3891 SfxItemState eConState = aAttrs.GetItemState( SDRATTR_TEXT_CONTOURFRAME ); 3892 if( eConState != SfxItemState::DONTCARE ) 3893 { 3894 bContour = aAttrs.Get( SDRATTR_TEXT_CONTOURFRAME ).GetValue(); 3895 } 3896 if (bContour) break; 3897 3898 SfxItemState eVState = aAttrs.GetItemState( SDRATTR_TEXT_VERTADJUST ); 3899 //SfxItemState eHState = aAttrs.GetItemState( SDRATTR_TEXT_HORZADJUST ); 3900 3901 //if(SfxItemState::DONTCARE != eVState && SfxItemState::DONTCARE != eHState) 3902 if(SfxItemState::DONTCARE != eVState) 3903 { 3904 SdrTextVertAdjust eTVA = aAttrs.Get(SDRATTR_TEXT_VERTADJUST).GetValue(); 3905 bool bSet = (nSlotId == SID_TABLE_VERT_NONE && eTVA == SDRTEXTVERTADJUST_TOP) || 3906 (nSlotId == SID_TABLE_VERT_CENTER && eTVA == SDRTEXTVERTADJUST_CENTER) || 3907 (nSlotId == SID_TABLE_VERT_BOTTOM && eTVA == SDRTEXTVERTADJUST_BOTTOM); 3908 rSet.Put(SfxBoolItem(nSlotId, bSet)); 3909 } 3910 else 3911 { 3912 rSet.Put(SfxBoolItem(nSlotId, false)); 3913 } 3914 break; 3915 } 3916 nWhich = aIter.NextWhich(); 3917 } 3918 } 3919 3920 } // end of namespace sd 3921 3922 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 3923
