sw/CppunitTest_sw_uibase_shells.mk | 3 ++ sw/qa/uibase/shells/shells.cxx | 52 +++++++++++++++++++++++++++++++++++ sw/source/uibase/shells/drwtxtex.cxx | 18 ++++-------- 3 files changed, 61 insertions(+), 12 deletions(-)
New commits: commit 21b531f5dc2452a0bd42273ce0aa1d7809a4ebec Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Fri Feb 7 17:54:50 2020 +0100 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Thu Feb 20 20:07:58 2020 +0100 tdf#130482 sw: fix text alignment in shape text Regression from commit a3c7a8282ddd08c7ed4a15d23089d09e418f8fae (jsdialogs: apply .uno:Color and CharBackColor to floating text frames, 2019-11-08), the problem was that the original code populated aNewAttr, while SetAttrToMarked() was only invoked in case there were arguments. Fix this by making pNewAttrs a copy, so lcl_convertStringArguments() can work on it in place, and then restore the old code that copied from pNewAttrs to aNewAttr. This fixes the no-arguments case and keeps the lcl_convertStringArguments() case working. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88227 Reviewed-by: Miklos Vajna <vmik...@collabora.com> Tested-by: Jenkins (cherry picked from commit b03504bf054bd4094b985ef8ebb9ac55fa69a487) Change-Id: If7bf2d7b21e48d513a512ec6127b61ee74635ef5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88296 Tested-by: Jenkins Reviewed-by: Xisco FaulĂ <xiscofa...@libreoffice.org> (cherry picked from commit 942c0d71a91839fc1762c7e93417e7bb703ea3cf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88303 Reviewed-by: Michael Stahl <michael.st...@cib.de> Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/sw/CppunitTest_sw_uibase_shells.mk b/sw/CppunitTest_sw_uibase_shells.mk index a4bb21c3d67e..9734b395bca6 100644 --- a/sw/CppunitTest_sw_uibase_shells.mk +++ b/sw/CppunitTest_sw_uibase_shells.mk @@ -21,9 +21,12 @@ $(eval $(call gb_CppunitTest_use_libraries,sw_uibase_shells, \ comphelper \ cppu \ cppuhelper \ + editeng \ sal \ sfx \ svl \ + svx \ + svxcore \ sw \ test \ unotest \ diff --git a/sw/qa/uibase/shells/shells.cxx b/sw/qa/uibase/shells/shells.cxx index 8701db9a052e..05b5c6b5e27b 100644 --- a/sw/qa/uibase/shells/shells.cxx +++ b/sw/qa/uibase/shells/shells.cxx @@ -13,12 +13,22 @@ #include <sfx2/viewfrm.hxx> #include <vcl/GraphicObject.hxx> #include <vcl/gdimtf.hxx> +#include <svx/svdpage.hxx> +#include <svx/svdview.hxx> +#include <editeng/eeitem.hxx> +#include <editeng/adjustitem.hxx> +#include <editeng/outlobj.hxx> +#include <editeng/editobj.hxx> +#include <editeng/editids.hrc> +#include <svx/sdtaitm.hxx> #include <IDocumentContentOperations.hxx> #include <cmdid.h> #include <fmtanchr.hxx> #include <view.hxx> #include <wrtsh.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <drawdoc.hxx> static char const DATA_DIRECTORY[] = "/sw/qa/uibase/shells/data/"; @@ -69,6 +79,48 @@ CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testTdf130179) CPPUNIT_ASSERT(!pItem); } +CPPUNIT_TEST_FIXTURE(SwUibaseShellsTest, testShapeTextAlignment) +{ +// FIXME find out why this fails on macOS +#ifndef MACOSX + // Create a document with a rectangle in it. + SwDoc* pDoc = createDoc(); + SwWrtShell* pWrtShell = pDoc->GetDocShell()->GetWrtShell(); + Point aStartPos(1000, 1000); + pWrtShell->BeginCreate(static_cast<sal_uInt16>(OBJ_RECT), aStartPos); + Point aMovePos(2000, 2000); + pWrtShell->MoveCreate(aMovePos); + pWrtShell->EndCreate(SdrCreateCmd::ForceEnd); + + // Start shape text edit. + SwView* pView = pDoc->GetDocShell()->GetView(); + // Select the shape. + pView->GetViewFrame()->GetDispatcher()->Execute(FN_CNTNT_TO_NEXT_FRAME, SfxCallMode::SYNCHRON); + pView->StopShellTimer(); + // Start the actual text edit. + SdrPage* pPage = pWrtShell->GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()->GetPage(0); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), pPage->GetObjCount()); + SdrObject* pObject = pPage->GetObj(0); + pView->EnterShapeDrawTextMode(pObject); + pView->AttrChangedNotify(nullptr); + + // Change paragraph adjustment to center. + pView->GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_PARA_ADJUST_CENTER, + SfxCallMode::SYNCHRON); + + // End shape text edit. + pWrtShell->EndTextEdit(); + + const OutlinerParaObject* pOutliner = pObject->GetOutlinerParaObject(); + // Without the accompanying fix in place, this test would have failed, because the shape had no + // text or text formatting. In other words the paragraph adjustment command was ignored. + CPPUNIT_ASSERT(pOutliner); + const SfxItemSet& rParaAttribs = pOutliner->GetTextObject().GetParaAttribs(0); + SvxAdjust eAdjust = rParaAttribs.GetItem(EE_PARA_JUST)->GetAdjust(); + CPPUNIT_ASSERT_EQUAL(SvxAdjust::Center, eAdjust); +#endif +} + CPPUNIT_PLUGIN_IMPLEMENT(); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/uibase/shells/drwtxtex.cxx b/sw/source/uibase/shells/drwtxtex.cxx index fae34754fe5a..60bdf16380be 100644 --- a/sw/source/uibase/shells/drwtxtex.cxx +++ b/sw/source/uibase/shells/drwtxtex.cxx @@ -152,7 +152,7 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) const sal_uInt16 nSlot = rReq.GetSlot(); const sal_uInt16 nWhich = GetPool().GetWhich(nSlot); - const SfxItemSet *pNewAttrs = rReq.GetArgs(); + std::unique_ptr<SfxItemSet> pNewAttrs(rReq.GetArgs() ? rReq.GetArgs()->Clone() : nullptr); bool bRestoreSelection = false; ESelection aOldSelection; @@ -650,21 +650,15 @@ void SwDrawTextShell::Execute( SfxRequest &rReq ) assert(false && "wrong dispatcher"); return; } - - std::unique_ptr<SfxItemSet> pNewArgs = pNewAttrs ? pNewAttrs->Clone() : nullptr; - if (pNewArgs) + if (nEEWhich && pNewAttrs) { - lcl_convertStringArguments(nSlot, pNewArgs); + lcl_convertStringArguments(nSlot, pNewAttrs); - if (nEEWhich) - { - std::unique_ptr<SfxPoolItem> pNewItem(pNewArgs->Get(nWhich).CloneSetWhich(nEEWhich)); - pNewArgs->Put(*pNewItem); - } - - SetAttrToMarked(*pNewArgs); + aNewAttr.Put(pNewAttrs->Get(nWhich).CloneSetWhich(nEEWhich)); } + SetAttrToMarked(aNewAttr); + GetView().GetViewFrame()->GetBindings().InvalidateAll(false); if (IsTextEdit() && pOLV->GetOutliner()->IsModified()) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits