diff options
author | Attila Bakos (NISZ) <bakos.attilakaroly@nisz.hu> | 2020-09-30 11:24:14 +0200 |
---|---|---|
committer | László Németh <nemeth@numbertext.org> | 2020-10-14 08:56:02 +0200 |
commit | 726c911b90b9a3170fa6b3a34bb952a8d2dbe148 (patch) | |
tree | 91543b2ec8d32767485cfe15e0aac2d8895e1abd /sw/source | |
parent | 16e88bd68c523117fee9070c986151a781c0e7bf (diff) |
tdf#137025 sw: apply textbox padding set in Text
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 <nemeth@numbertext.org>
Reviewed-by: László Németh <nemeth@numbertext.org>
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/textboxhelper.cxx | 34 | ||||
-rw-r--r-- | sw/source/uibase/shells/drawdlg.cxx | 8 |
2 files changed, 42 insertions, 0 deletions
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<drawing::XShape> 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<drawing::XShape> xShape(pObj->getUnoShape(), uno::UNO_QUERY); + if (!xShape) + return; + uno::Reference<beans::XPropertySet> 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 <svx/xflftrit.hxx> #include <svx/xfltrit.hxx> #include <comphelper/lok.hxx> +#include <textboxhelper.hxx> 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(); } |