summaryrefslogtreecommitdiff
path: root/sw/source/uibase/shells/drawsh.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sw/source/uibase/shells/drawsh.cxx')
-rw-r--r--sw/source/uibase/shells/drawsh.cxx67
1 files changed, 40 insertions, 27 deletions
diff --git a/sw/source/uibase/shells/drawsh.cxx b/sw/source/uibase/shells/drawsh.cxx
index 9f0de0c2a0f1..23c4dd61872d 100644
--- a/sw/source/uibase/shells/drawsh.cxx
+++ b/sw/source/uibase/shells/drawsh.cxx
@@ -133,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);
}
@@ -173,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)
@@ -210,7 +210,20 @@ void SwDrawShell::Execute(SfxRequest &rReq)
const sal_uLong handleNum = handleNumItem->GetValue();
const sal_uLong newPosX = newPosXTwips->GetValue();
const sal_uLong newPosY = newPosYTwips->GetValue();
- pSdrView->MoveShapeHandle(handleNum, Point(newPosX, newPosY), OrdNum ? OrdNum->GetValue() : -1);
+ 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;
@@ -278,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:
@@ -364,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;
}
@@ -374,7 +387,7 @@ void SwDrawShell::Execute(SfxRequest &rReq)
{
SwFrameFormat* pFrameFormat = ::FindFrameFormat(pObj);
if (pFrameFormat)
- SwTextBoxHelper::destroy(pFrameFormat);
+ SwTextBoxHelper::destroy(pFrameFormat, pObj);
}
break;
}
@@ -382,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)
@@ -466,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;
@@ -490,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) )
{
@@ -513,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;
}
@@ -537,8 +550,8 @@ SwDrawShell::SwDrawShell(SwView &_rView) :
SwWrtShell &rSh = GetShell();
SdrView* pDrView = rSh.GetDrawView();
- sal_uInt32 nCheckStatus = 0;
- if (pDrView && svx::checkForSelectedFontWork(pDrView, nCheckStatus))
+
+ if (pDrView && svx::checkForSelectedFontWork(pDrView))
eContext = vcl::EnumContext::Context::DrawFontwork;
SfxShell::SetContextName(vcl::EnumContext::GetContextName(eContext));
@@ -550,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();
@@ -567,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
@@ -586,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 ||