[Libreoffice-commits] core.git: Branch 'distro/nisz/libreoffice-6-4' - sw/qa sw/source writerfilter/source

Szabolcs Toth (via logerrit) logerrit at kemper.freedesktop.org
Mon Jul 27 20:34:34 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport3.cxx                                          |   14 ++++++++++
 sw/source/core/layout/anchoreddrawobject.cxx                                       |   13 ++++++---
 writerfilter/source/dmapper/GraphicImport.cxx                                      |   10 +++++++
 4 files changed, 33 insertions(+), 4 deletions(-)

New commits:
commit 10b24292a37b69e9329b03fed2f10af4a91247e0
Author:     Szabolcs Toth <szabolcs450 at gmail.com>
AuthorDate: Thu Jun 4 15:43:42 2020 +0200
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Mon Jul 27 22:34:02 2020 +0200

    tdf#132976 DOCX import: fix shape width relative to left margin
    
    using UNO API RelativeWidthRelation and the associated
    lo-ext attribute for OpenDocument export.
    
    See commit 43d7f4e3640c5e370fd1204739c2b0c7eb5f40e4
    (offapi: document the 4 new properties which are no longer read-only).
    
    Co-authored-by: Balázs Regényi
    
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95525
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit 7380905abc0833d9e4c4fe731d76174db8a8724c)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96998
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofauli at libreoffice.org>
    (cherry picked from commit 5451833f3af5582a8cab7e4b3da402f083f56908)
    
    Change-Id: I2dada8ad764a1fba33d241117cc4bc5eddae74ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99530
    Tested-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gabor2 at nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx b/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx
new file mode 100644
index 000000000000..2f1c5560c17a
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf132976_testRelativeAnchorWidthFromLeftMargin.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
index 089154675288..bd5c8605d454 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport3.cxx
@@ -1130,6 +1130,20 @@ DECLARE_OOXMLEXPORT_TEST(testShapeLineWidth, "tdf92526_ShapeLineWidth.odt")
         "/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln", "w", "0");
 }
 
+DECLARE_OOXMLEXPORT_TEST(testRelativeAnchorWidthFromLeftMargin, "tdf132976_testRelativeAnchorWidthFromLeftMargin.docx")
+{
+    // TODO: Fix export.
+    if (mbExported)
+        return;
+
+    // tdf#132976 The size of the width of this shape should come from the size of the left margin.
+    // It was set to the size of the width of the entire page before.
+    xmlDocPtr pXmlDoc = parseLayoutDump();
+    const sal_Int32 nAnchoredWidth
+        = getXPath(pXmlDoc, "//SwAnchoredDrawObject/bounds", "width").toInt32();
+    CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1133), nAnchoredWidth);
+}
+
 CPPUNIT_PLUGIN_IMPLEMENT();
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/layout/anchoreddrawobject.cxx b/sw/source/core/layout/anchoreddrawobject.cxx
index 079468fdf062..95ad5bc155b4 100644
--- a/sw/source/core/layout/anchoreddrawobject.cxx
+++ b/sw/source/core/layout/anchoreddrawobject.cxx
@@ -624,13 +624,18 @@ SwRect SwAnchoredDrawObject::GetObjBoundRect() const
         long nTargetWidth = aCurrObjRect.GetWidth( );
         if ( GetDrawObj( )->GetRelativeWidth( ) )
         {
-            tools::Rectangle aPageRect;
+            long nWidth = 0;
             if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::FRAME)
                 // Exclude margins.
-                aPageRect = GetPageFrame()->getFramePrintArea().SVRect();
+                nWidth = GetPageFrame()->getFramePrintArea().SVRect().GetWidth();
+            // Here we handle the relative size of the width of some shape.
+            // The size of the shape's width is going to be relative to the size of the left margin.
+            // E.g.: (left margin = 8 && relative size = 150%) -> width of some shape = 12.
+            else if (GetDrawObj()->GetRelativeWidthRelation() == text::RelOrientation::PAGE_LEFT)
+                nWidth = GetPageFrame()->GetLeftMargin();
             else
-                aPageRect = GetPageFrame( )->GetBoundRect( GetPageFrame()->getRootFrame()->GetCurrShell()->GetOut() ).SVRect();
-            nTargetWidth = aPageRect.GetWidth( ) * (*GetDrawObj( )->GetRelativeWidth());
+                nWidth = GetPageFrame( )->GetBoundRect( GetPageFrame()->getRootFrame()->GetCurrShell()->GetOut() ).SVRect().GetWidth();
+            nTargetWidth = nWidth * (*GetDrawObj( )->GetRelativeWidth());
         }
 
         long nTargetHeight = aCurrObjRect.GetHeight( );
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index 8afea80365fe..04b2b124aae6 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -938,6 +938,16 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                         xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::FRAME));
                     }
                     break;
+                case NS_ooxml::LN_ST_SizeRelFromH_leftMargin:
+                    if (m_xShape.is())
+                    {
+                        // Here we handle the relative size of the width of some shape.
+                        // The size of the shape's width is going to be relative to the size of the left margin.
+                        // E.g.: (left margin = 8 && relative size = 150%) -> width of some shape = 12.
+                        uno::Reference<beans::XPropertySet> xPropertySet(m_xShape, uno::UNO_QUERY);
+                        xPropertySet->setPropertyValue("RelativeWidthRelation", uno::makeAny(text::RelOrientation::PAGE_LEFT));
+                    }
+                    break;
                 case NS_ooxml::LN_ST_SizeRelFromH_page:
                     if (m_xShape.is())
                     {


More information about the Libreoffice-commits mailing list