From 726c911b90b9a3170fa6b3a34bb952a8d2dbe148 Mon Sep 17 00:00:00 2001 From: "Attila Bakos (NISZ)" Date: Wed, 30 Sep 2020 11:24:14 +0200 Subject: tdf#137025 sw: apply textbox padding set in Text MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit dialog window using Spacing to Borders in Format->Text Box and Shape->Text attributes... on the selected text box. There are two types of text boxes in sw, the older editeng one, what worked fine, and the newer one, the shape + text frame one, where modifying Spacing to Borders had no effect. This has been fixed by copying the modified shape attributes to the associated text frame. Change-Id: I8da0b414fd4771fa86851d9a6affbd9502894ebf Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103674 Tested-by: László Németh Reviewed-by: László Németh --- sw/source/core/doc/textboxhelper.cxx | 34 ++++++++++++++++++++++++++++++++++ sw/source/uibase/shells/drawdlg.cxx | 8 ++++++++ 2 files changed, 42 insertions(+) (limited to 'sw/source') diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index 15d80ea1ca93..94f43c61af02 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -210,6 +210,17 @@ bool SwTextBoxHelper::isTextBox(const SwFrameFormat* pFormat, sal_uInt16 nType) return pOtherFormat->GetAttrSet().HasItem(RES_CNTNT) && pOtherFormat->GetContent() == rContent; } +bool SwTextBoxHelper::hasTextFrame(const SdrObject* pObj) +{ + if (!pObj) + return false; + + uno::Reference xShape(pObj->getWeakUnoShape(), uno::UNO_QUERY); + if (!xShape) + return false; + return SwTextBoxHelper::getOtherTextBoxFormat(xShape); +} + sal_Int32 SwTextBoxHelper::getCount(SdrPage const* pPage) { sal_Int32 nRet = 0; @@ -809,4 +820,27 @@ void SwTextBoxHelper::syncFlyFrameAttr(SwFrameFormat& rShape, SfxItemSet const& pFormat->GetDoc()->SetFlyFrameAttr(*pFormat, aTextBoxSet); } +void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj) +{ + if (!pObj) + return; + uno::Reference xShape(pObj->getUnoShape(), uno::UNO_QUERY); + if (!xShape) + return; + uno::Reference const xPropertySet(xShape, uno::UNO_QUERY); + + auto pParentFormat = getOtherTextBoxFormat(getOtherTextBoxFormat(xShape), RES_FLYFRMFMT); + if (!pParentFormat) + return; + + syncProperty(pParentFormat, UNO_NAME_TEXT_LEFTDIST, + xPropertySet->getPropertyValue(UNO_NAME_TEXT_LEFTDIST)); + syncProperty(pParentFormat, UNO_NAME_TEXT_RIGHTDIST, + xPropertySet->getPropertyValue(UNO_NAME_TEXT_RIGHTDIST)); + syncProperty(pParentFormat, UNO_NAME_TEXT_UPPERDIST, + xPropertySet->getPropertyValue(UNO_NAME_TEXT_UPPERDIST)); + syncProperty(pParentFormat, UNO_NAME_TEXT_LOWERDIST, + xPropertySet->getPropertyValue(UNO_NAME_TEXT_LOWERDIST)); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/shells/drawdlg.cxx b/sw/source/uibase/shells/drawdlg.cxx index b08cde80068d..114b7f33b055 100644 --- a/sw/source/uibase/shells/drawdlg.cxx +++ b/sw/source/uibase/shells/drawdlg.cxx @@ -39,6 +39,7 @@ #include #include #include +#include using namespace com::sun::star::drawing; @@ -69,6 +70,13 @@ void SwDrawShell::ExecDrawDlg(SfxRequest& rReq) { pSh->StartAction(); pView->SetAttributes(*pDlg->GetOutputItemSet()); + auto vMarkedObjs = pView->GetMarkedObjects(); + for (auto pObj : vMarkedObjs) + { + // If the shape has textframe, set its params as well. + if (SwTextBoxHelper::hasTextFrame(pObj)) + SwTextBoxHelper::updateTextBoxMargin(pObj); + } rReq.Done(*(pDlg->GetOutputItemSet())); pSh->EndAction(); } -- cgit