sw/qa/uitest/data/tdf142847.fodt | 49 ++++++++++++++++++++++++++++++++ sw/qa/uitest/writer_tests5/tdf142847.py | 39 +++++++++++++++++++++++++ sw/source/core/doc/docfmt.cxx | 10 ++++++ sw/source/core/doc/textboxhelper.cxx | 10 +++++- sw/source/core/text/porfly.cxx | 3 + 5 files changed, 109 insertions(+), 2 deletions(-)
New commits: commit 6df1ea43d565035fd2edf71b7ab7103beeaffb55 Author: Attila Bakos (NISZ) <bakos.attilakar...@nisz.hu> AuthorDate: Fri Jul 2 11:29:58 2021 +0200 Commit: Tünde Tóth <toth.tu...@nisz.hu> CommitDate: Thu Oct 21 10:51:28 2021 +0200 tdf#142847 sw: fix textbox layout at wrap setting Setting wrap spacing of a textbox via its Wrap->Edit... dialog window, the textbox had fallen apart, if it was anchored as character. Change-Id: I6c48c7a631a93a874129f64e1bdc6b3e2051e64f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118281 Tested-by: László Németh <nem...@numbertext.org> Reviewed-by: László Németh <nem...@numbertext.org> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123959 Tested-by: Tünde Tóth <toth.tu...@nisz.hu> Reviewed-by: Tünde Tóth <toth.tu...@nisz.hu> diff --git a/sw/qa/uitest/data/tdf142847.fodt b/sw/qa/uitest/data/tdf142847.fodt new file mode 100644 index 000000000000..5ceed7151808 --- /dev/null +++ b/sw/qa/uitest/data/tdf142847.fodt @@ -0,0 +1,49 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<office:document xmlns:meta="urn:oasis:names:tc:opendocument:xmlns:meta:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:ooo="http://openoffice.org/2004/office" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:dr3d="urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:chart="urn:oasis:names:tc:opendocument:xmlns:chart:1.0" xmlns:rpt="http://openoffice.org/2005/report" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" xmlns:ooow="http://openoffice.org/200 4/writer" xmlns:oooc="http://openoffice.org/2004/calc" xmlns:of="urn:oasis:names:tc:opendocument:xmlns:of:1.2" xmlns:tableooo="http://openoffice.org/2009/table" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:drawooo="http://openoffice.org/2010/draw" xmlns:loext="urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0" xmlns:field="urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0" xmlns:math="http://www.w3.org/1998/Math/MathML" xmlns:form="urn:oasis:names:tc:opendocument:xmlns:form:1.0" xmlns:script="urn:oasis:names:tc:opendocument:xmlns:script:1.0" xmlns:dom="http://www.w3.org/2001/xml-events" xmlns:xforms="http://www.w3.org/2002/xforms" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:formx="urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:grddl="http://www.w3.org/2003/g/data-view#" xmlns :css3t="http://www.w3.org/TR/css3-text/" xmlns:officeooo="http://openoffice.org/2009/office" office:version="1.3" office:mimetype="application/vnd.oasis.opendocument.text"> + <office:meta><dc:date>2021-08-25T15:50:24.334000000</dc:date><meta:editing-duration>PT5M16S</meta:editing-duration><meta:editing-cycles>4</meta:editing-cycles><meta:generator>LibreOffice/7.1.1.2$Windows_X86_64 LibreOffice_project/fe0b08f4af1bacafe4c7ecc87ce55bb426164676</meta:generator><meta:document-statistic meta:table-count="0" meta:image-count="0" meta:object-count="0" meta:page-count="1" meta:paragraph-count="1" meta:word-count="298" meta:character-count="795" meta:non-whitespace-character-count="480"/></office:meta> + <office:font-face-decls> + <style:font-face style:name="Lucida Sans1" svg:font-family="'Lucida Sans'" style:font-family-generic="swiss"/> + <style:font-face style:name="Liberation Mono" svg:font-family="'Liberation Mono'" style:font-family-generic="modern" style:font-pitch="fixed"/> + <style:font-face style:name="NSimSun" svg:font-family="NSimSun" style:font-family-generic="modern" style:font-pitch="fixed"/> + <style:font-face style:name="Liberation Serif" svg:font-family="'Liberation Serif'" style:font-family-generic="roman" style:font-pitch="variable"/> + <style:font-face style:name="Liberation Sans" svg:font-family="'Liberation Sans'" style:font-family-generic="swiss" style:font-pitch="variable"/> + <style:font-face style:name="Lucida Sans" svg:font-family="'Lucida Sans'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Microsoft YaHei" svg:font-family="'Microsoft YaHei'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Segoe UI" svg:font-family="'Segoe UI'" style:font-family-generic="system" style:font-pitch="variable"/> + <style:font-face style:name="Tahoma" svg:font-family="Tahoma" style:font-family-generic="system" style:font-pitch="variable"/> + </office:font-face-decls> + <office:automatic-styles> + <style:style style:name="P1" style:family="paragraph" style:parent-style-name="Standard"> + <style:text-properties officeooo:rsid="000eedc1" officeooo:paragraph-rsid="000eedc1"/> + </style:style> + <style:style style:name="gr1" style:family="graphic" style:parent-style-name="Frame"> + <style:graphic-properties draw:textarea-horizontal-align="justify" draw:textarea-vertical-align="middle" draw:auto-grow-height="false" fo:min-height="1.132cm" fo:min-width="2.106cm" style:run-through="foreground" style:wrap="parallel" style:number-wrapped-paragraphs="no-limit" style:wrap-contour="false" style:vertical-pos="middle" style:vertical-rel="baseline" style:horizontal-pos="from-left" style:horizontal-rel="paragraph" draw:wrap-influence-on-position="once-concurrent" loext:allow-overlap="true" style:flow-with-text="false"/> + </style:style> + <style:page-layout style:name="pm1"> + <style:page-layout-properties fo:page-width="21.001cm" fo:page-height="29.7cm" style:num-format="1" style:print-orientation="portrait" fo:margin-top="2cm" fo:margin-bottom="2cm" fo:margin-left="2cm" fo:margin-right="2cm" style:writing-mode="lr-tb" style:layout-grid-color="#c0c0c0" style:layout-grid-lines="20" style:layout-grid-base-height="0.706cm" style:layout-grid-ruby-height="0.353cm" style:layout-grid-mode="none" style:layout-grid-ruby-below="false" style:layout-grid-print="false" style:layout-grid-display="false" style:footnote-max-height="0cm"> + <style:footnote-sep style:width="0.018cm" style:distance-before-sep="0.101cm" style:distance-after-sep="0.101cm" style:line-style="solid" style:adjustment="left" style:rel-width="25%" style:color="#000000"/> + </style:page-layout-properties> + <style:header-style/> + <style:footer-style/> + </style:page-layout> + </office:automatic-styles> + <office:master-styles> + <style:master-page style:name="Standard" style:page-layout-name="pm1"/> + </office:master-styles> + <office:body> + <office:text> + <text:sequence-decls> + <text:sequence-decl text:display-outline-level="0" text:name="Illustration"/> + <text:sequence-decl text:display-outline-level="0" text:name="Table"/> + <text:sequence-decl text:display-outline-level="0" text:name="Text"/> + <text:sequence-decl text:display-outline-level="0" text:name="Drawing"/> + <text:sequence-decl text:display-outline-level="0" text:name="Figure"/> + </text:sequence-decls> + <text:p text:style-name="Standard">Xx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x xxxx x x x x x xxxxxxx xxxx Xx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x<draw:custom-shape text:anchor-type="as-char" draw:z-index="0" draw:name="Shape1" draw:style-name="gr1" svg:width="4.211cm" svg:height="2.262cm"> + <text:p text:style-name="Frame_20_contents"/> + <draw:enhanced-geometry svg:viewBox="0 0 21600 21600" draw:glue-points="10800 0 0 10800 10800 21600 21600 10800" draw:text-areas="5400 5400 16200 16200" draw:type="diamond" draw:enhanced-path="M 10800 0 L 21600 10800 10800 21600 0 10800 10800 0 Z N"/> + </draw:custom-shape> xxxx x x x x x xxxxxx xxxxxXx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x xxxx x x x x x xxxxxx xxxxxXx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x xxxx x x x x x xxxxx xxxx xxXx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x xxxx x x x x x xxxx xxxx xxxXx xx x xx x x xx xxxx x <text:s/>x x xx x x xx x x x xxxxx xx x x x xx <text:s/>xx <text:s/>x xx x x x x x x x x x x xx x x x x xxxx x x x x x xxxxx xxxxxx</text:p> + </office:text> + </office:body> +</office:document> \ No newline at end of file diff --git a/sw/qa/uitest/writer_tests5/tdf142847.py b/sw/qa/uitest/writer_tests5/tdf142847.py new file mode 100644 index 000000000000..bddc64e0e13c --- /dev/null +++ b/sw/qa/uitest/writer_tests5/tdf142847.py @@ -0,0 +1,39 @@ +# -*- tab-width: 4; indent-tabs-mode: nil; py-indent-offset: 4 -*- +# +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +from uitest.framework import UITestCase +import org.libreoffice.unotest +from uitest.uihelper.common import get_url_for_data_file +from libreoffice.uno.propertyvalue import mkPropertyValues + +class tdf142847(UITestCase): + def test_tdf142847(self): + # load the sample file + with self.ui_test.load_file(get_url_for_data_file("tdf142847.fodt")): + xWriterDoc = self.xUITest.getTopFocusWindow() + xWriterEdit = xWriterDoc.getChild("writer_edit") + document = self.ui_test.get_component() + + # get the shape + shape = document.DrawPage.getByIndex(0) + + # select the shape. + self.xUITest.executeCommand(".uno:JumpToNextFrame") + self.ui_test.wait_until_child_is_available('metricfield') + + # set the wrap spacing of the shape + with self.ui_test.execute_dialog_through_command(".uno:TextWrap") as wrap_dialog: + for i in range(90): + wrap_dialog.getChild('left').executeAction("UP", tuple()) + + # get the textbox + frame = shape.getText() + + # without the fix, this will fail. + # the textbox has fallen apart. + self.assertGreater(frame.getPropertyValue("HoriOrientPosition"), shape.getPropertyValue("LeftMargin")) + +# vim: set shiftwidth=4 softtabstop=4 expandtab: diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index a27aad094ce2..b1c63c4dfc63 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -73,6 +73,7 @@ #include <swmodule.hxx> #include <modcfg.hxx> #include <frameformats.hxx> +#include <textboxhelper.hxx> #include <memory> using namespace ::com::sun::star::i18n; @@ -475,6 +476,15 @@ void SwDoc::SetAttr( const SfxItemSet& rSet, SwFormat& rFormat ) { rFormat.SetFormatAttr( rSet ); } + + // If the format is a shape, and it has a textbox, sync. + auto pShapeFormat = dynamic_cast<SwFrameFormat*>(&rFormat); + if (pShapeFormat && SwTextBoxHelper::isTextBox(pShapeFormat, RES_DRAWFRMFMT)) + { + SwTextBoxHelper::syncFlyFrameAttr(*pShapeFormat, rSet); + SwTextBoxHelper::changeAnchor(pShapeFormat); + } + getIDocumentState().SetModified(); } diff --git a/sw/source/core/doc/textboxhelper.cxx b/sw/source/core/doc/textboxhelper.cxx index e5ade0b38125..c2745b271599 100644 --- a/sw/source/core/doc/textboxhelper.cxx +++ b/sw/source/core/doc/textboxhelper.cxx @@ -42,6 +42,8 @@ #include <drawdoc.hxx> #include <IDocumentUndoRedo.hxx> #include <DocumentDrawModelManager.hxx> +#include <IDocumentDrawModelAccess.hxx> +#include <frmatr.hxx> #include <com/sun/star/document/XActionLockable.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> @@ -1016,6 +1018,9 @@ void SwTextBoxHelper::updateTextBoxMargin(SdrObject* pObj) syncProperty(pParentFormat, RES_FRM_SIZE, MID_FRMSIZE_WIDTH_TYPE, uno::Any(bIsAutoWrap ? text::SizeType::FIX : text::SizeType::MIN)); + + changeAnchor(pParentFormat); + DoTextBoxZOrderCorrection(pParentFormat); } bool SwTextBoxHelper::setWrapThrough(SwFrameFormat* pShape) @@ -1168,8 +1173,11 @@ bool SwTextBoxHelper::doTextBoxPositioning(SwFrameFormat* pShape) { tools::Rectangle aRect(getTextRectangle(pShape, false)); + auto nLeftSpace = pShape->GetLRSpace().GetLeft(); + SwFormatHoriOrient aNewHOri(pFormat->GetHoriOrient()); - aNewHOri.SetPos(aRect.getX()); + + aNewHOri.SetPos(aRect.Left() + nLeftSpace); SwFormatVertOrient aNewVOri(pFormat->GetVertOrient()); aNewVOri.SetPos(aRect.getY() + pShape->GetVertOrient().GetPos()); diff --git a/sw/source/core/text/porfly.cxx b/sw/source/core/text/porfly.cxx index 9c7b1d52f56f..77062850dc3f 100644 --- a/sw/source/core/text/porfly.cxx +++ b/sw/source/core/text/porfly.cxx @@ -26,6 +26,7 @@ #include <frmfmt.hxx> #include <viewsh.hxx> #include <textboxhelper.hxx> +#include <frmatr.hxx> #include <sal/log.hxx> #include <fmtanchr.hxx> @@ -396,7 +397,7 @@ void SwFlyCntPortion::SetBase( const SwTextFrame& rFrame, const Point &rBase, SwFormatAnchor aNewTxBxAnchor(pTextBox->GetAnchor()); aNewTxBxAnchor.SetAnchor(aPos); - aHori.SetPos(nXoffs); + aHori.SetPos(nXoffs + pShape->GetLRSpace().GetLeft()); pTextBox->LockModify(); pTextBox->SetFormatAttr(aNewTxBxAnchor);