diff options
Diffstat (limited to 'sw/source/uibase/shells/drawsh.cxx')
-rw-r--r-- | sw/source/uibase/shells/drawsh.cxx | 87 |
1 files changed, 62 insertions, 25 deletions
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx index 09b6bdbb3a0d..23c4dd61872d 100644 --- a/sw/source/uibase/shells/drawsh.cxx +++ b/sw/source/uibase/shells/drawsh.cxx @@ -42,6 +42,7 @@ #include <svx/svdundo.hxx> #include <svx/xbtmpit.hxx> #include <svx/sdasitm.hxx> +#include <osl/diagnose.h> #include <swundo.hxx> #include <wrtsh.hxx> @@ -132,29 +133,29 @@ void SwDrawShell::InsertPictureFromFile(SdrObject& rObject) if (SdrGrafObj* pSdrGrafObj = dynamic_cast<SdrGrafObj*>(&rObject)) { - SdrGrafObj* pNewGrafObj(pSdrGrafObj->CloneSdrObject(pSdrGrafObj->getSdrModelFromSdrObject())); + rtl::Reference<SdrGrafObj> pNewGrafObj = SdrObject::Clone(*pSdrGrafObj, pSdrGrafObj->getSdrModelFromSdrObject()); pNewGrafObj->SetGraphic(aGraphic); // #i123922# for handling MasterObject and virtual ones correctly, SW // wants us to call ReplaceObject at the page, but that also // triggers the same assertion (I tried it), so stay at the view method - pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj); + pSdrView->ReplaceObjectAtView(&rObject, *pSdrView->GetSdrPageView(), pNewGrafObj.get()); // set in all cases - the Clone() will have copied an existing link (!) pNewGrafObj->SetGraphicLink( bAsLink ? aDlg.GetPath() : OUString()); - pResult = pNewGrafObj; + pResult = pNewGrafObj.get(); } else // if(rObject.IsClosedObj() && !dynamic_cast< SdrOle2Obj* >(&rObject)) { pSdrView->AddUndo(std::make_unique<SdrUndoAttrObj>(rObject)); - SfxItemSet aSet(pSdrView->GetModel()->GetItemPool(), svl::Items<XATTR_FILLSTYLE, XATTR_FILLBITMAP>{}); + SfxItemSetFixed<XATTR_FILLSTYLE, XATTR_FILLBITMAP> aSet(pSdrView->GetModel().GetItemPool()); aSet.Put(XFillStyleItem(drawing::FillStyle_BITMAP)); - aSet.Put(XFillBitmapItem(OUString(), aGraphic)); + aSet.Put(XFillBitmapItem(OUString(), std::move(aGraphic))); rObject.SetMergedItemSetAndBroadcast(aSet); } @@ -172,11 +173,11 @@ void SwDrawShell::Execute(SfxRequest &rReq) SwWrtShell &rSh = GetShell(); SdrView *pSdrView = rSh.GetDrawView(); const SfxItemSet *pArgs = rReq.GetArgs(); - SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); + SfxBindings &rBnd = GetView().GetViewFrame().GetBindings(); sal_uInt16 nSlotId = rReq.GetSlot(); - bool bChanged = pSdrView->GetModel()->IsChanged(); + bool bChanged = pSdrView->GetModel().IsChanged(); - pSdrView->GetModel()->SetChanged(false); + pSdrView->GetModel().SetChanged(false); const SfxPoolItem* pItem; if(pArgs) @@ -197,7 +198,35 @@ void SwDrawShell::Execute(SfxRequest &rReq) GetView().FlipDrawRotate(); } break; + case SID_MOVE_SHAPE_HANDLE: + { + if (pArgs && pArgs->Count() >= 3) + { + const SfxUInt32Item* handleNumItem = rReq.GetArg<SfxUInt32Item>(FN_PARAM_1); + const SfxUInt32Item* newPosXTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_2); + const SfxUInt32Item* newPosYTwips = rReq.GetArg<SfxUInt32Item>(FN_PARAM_3); + const SfxInt32Item* OrdNum = rReq.GetArg<SfxInt32Item>(FN_PARAM_4); + + const sal_uLong handleNum = handleNumItem->GetValue(); + const sal_uLong newPosX = newPosXTwips->GetValue(); + const sal_uLong newPosY = newPosYTwips->GetValue(); + const Point mPoint(newPosX, newPosY); + const SdrHdl* handle = pSdrView->GetHdlList().GetHdl(handleNum); + if (!handle) + { + break; + } + if (handle->GetKind() == SdrHdlKind::Anchor || handle->GetKind() == SdrHdlKind::Anchor_TR) + { + rSh.FindAnchorPos(mPoint, /*bMoveIt=*/true); + pSdrView->ModelHasChanged(); + } + else + pSdrView->MoveShapeHandle(handleNum, mPoint, OrdNum ? OrdNum->GetValue() : -1); + } + } + break; case SID_BEZIER_EDIT: if (GetView().IsDrawRotate()) { @@ -262,15 +291,15 @@ void SwDrawShell::Execute(SfxRequest &rReq) { FieldUnit eMetric = ::GetDfltMetric( dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr ); SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)) ); - SfxViewFrame* pVFrame = GetView().GetViewFrame(); + SfxViewFrame& rVFrame = GetView().GetViewFrame(); if (pArgs) { - pVFrame->SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), + rVFrame.SetChildWindow(SvxFontWorkChildWindow::GetChildWindowId(), static_cast<const SfxBoolItem&>((pArgs->Get(SID_FONTWORK))).GetValue()); } else - pVFrame->ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); - pVFrame->GetBindings().Invalidate(SID_FONTWORK); + rVFrame.ToggleChildWindow( SvxFontWorkChildWindow::GetChildWindowId() ); + rVFrame.GetBindings().Invalidate(SID_FONTWORK); } break; case FN_FORMAT_FOOTNOTE_DLG: @@ -348,7 +377,7 @@ void SwDrawShell::Execute(SfxRequest &rReq) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); if (pFrameFormat) - SwTextBoxHelper::create(pFrameFormat, pObj->HasText()); + SwTextBoxHelper::create(pFrameFormat, pObj, pObj->HasText()); } break; } @@ -358,7 +387,7 @@ void SwDrawShell::Execute(SfxRequest &rReq) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); if (pFrameFormat) - SwTextBoxHelper::destroy(pFrameFormat); + SwTextBoxHelper::destroy(pFrameFormat, pObj); } break; } @@ -366,10 +395,10 @@ void SwDrawShell::Execute(SfxRequest &rReq) OSL_ENSURE(false, "wrong dispatcher"); return; } - if (pSdrView->GetModel()->IsChanged()) + if (pSdrView->GetModel().IsChanged()) rSh.SetModified(); else if (bChanged) - pSdrView->GetModel()->SetChanged(); + pSdrView->GetModel().SetChanged(); } void SwDrawShell::GetState(SfxItemSet& rSet) @@ -450,7 +479,7 @@ void SwDrawShell::GetState(SfxItemSet& rSet) else { const sal_uInt16 nId = SvxFontWorkChildWindow::GetChildWindowId(); - rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame()->HasChildWindow(nId))); + rSet.Put(SfxBoolItem( nWhich , GetView().GetViewFrame().HasChildWindow(nId))); } } break; @@ -474,7 +503,7 @@ void SwDrawShell::GetState(SfxItemSet& rSet) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); // Allow creating a TextBox only in case this is a draw format without a TextBox so far. - if (pFrameFormat && pFrameFormat->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT)) + if (pFrameFormat && pFrameFormat->Which() == RES_DRAWFRMFMT && !SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT, pObj)) { if (SdrObjCustomShape* pCustomShape = dynamic_cast<SdrObjCustomShape*>( pObj) ) { @@ -497,7 +526,7 @@ void SwDrawShell::GetState(SfxItemSet& rSet) { SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj); // Allow removing a TextBox only in case it has one. - if (pFrameFormat && SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT)) + if (pFrameFormat && SwTextBoxHelper::isTextBox(pFrameFormat, RES_DRAWFRMFMT, pObj)) bDisable = false; } @@ -517,7 +546,15 @@ SwDrawShell::SwDrawShell(SwView &_rView) : { SetName("Draw"); - SfxShell::SetContextName(vcl::EnumContext::GetContextName(vcl::EnumContext::Context::Draw)); + vcl::EnumContext::Context eContext = vcl::EnumContext::Context::Draw; + + SwWrtShell &rSh = GetShell(); + SdrView* pDrView = rSh.GetDrawView(); + + if (pDrView && svx::checkForSelectedFontWork(pDrView)) + eContext = vcl::EnumContext::Context::DrawFontwork; + + SfxShell::SetContextName(vcl::EnumContext::GetContextName(eContext)); } // Edit SfxRequests for FontWork @@ -526,8 +563,8 @@ void SwDrawShell::ExecFormText(SfxRequest const & rReq) { SwWrtShell &rSh = GetShell(); SdrView* pDrView = rSh.GetDrawView(); - bool bChanged = pDrView->GetModel()->IsChanged(); - pDrView->GetModel()->SetChanged(false); + bool bChanged = pDrView->GetModel().IsChanged(); + pDrView->GetModel().SetChanged(false); const SdrMarkList& rMarkList = pDrView->GetMarkedObjectList(); @@ -543,11 +580,11 @@ void SwDrawShell::ExecFormText(SfxRequest const & rReq) pDrView->SetAttributes(rSet); } - if (pDrView->GetModel()->IsChanged()) + if (pDrView->GetModel().IsChanged()) rSh.SetModified(); else if (bChanged) - pDrView->GetModel()->SetChanged(); + pDrView->GetModel().SetChanged(); } //Return status values for FontWork @@ -562,7 +599,7 @@ void SwDrawShell::GetFormTextState(SfxItemSet& rSet) if ( rMarkList.GetMarkCount() == 1 ) pObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); - const SdrTextObj* pTextObj = dynamic_cast< const SdrTextObj* >(pObj); + const SdrTextObj* pTextObj = DynCastSdrTextObj(pObj); const bool bDeactivate( !pObj || !pTextObj || |