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

Bakos Attila (via logerrit) logerrit at kemper.freedesktop.org
Thu Jun 11 15:30:11 UTC 2020


 sw/qa/extras/ooxmlexport/data/tdf130120.docx          |binary
 sw/qa/extras/ooxmlexport/ooxmlexport14.cxx            |    9 +++++++
 sw/source/filter/ww8/docxsdrexport.cxx                |   23 ++++++++++++++++--
 sw/source/filter/ww8/ww8graf.cxx                      |    1 
 writerfilter/source/dmapper/GraphicImport.cxx         |   14 ++++++++++
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   19 ++++++++++++++
 6 files changed, 62 insertions(+), 4 deletions(-)

New commits:
commit 24aff342ae648706b2f1ff0cdf1202e2d88067d9
Author:     Bakos Attila <bakos.attilakaroly at nisz.hu>
AuthorDate: Tue Feb 11 11:43:48 2020 +0100
Commit:     Gabor Kelemen <kelemen.gabor2 at nisz.hu>
CommitDate: Thu Jun 11 17:29:30 2020 +0200

    tdf#130120 DOCX: export o:allowincell
    
    Object anchors are set by allowincell/
    LayoutInCell attributes in table cells.
    Export it by grab bag method temporarily,
    instead of using the suggested FollowTextFlow,
    related also to the missing GUI support.
    
    Follow-up of commit 14ad64270e4fbca3c24da6f55f260b1fb229556a
    (tdf#129888 DOCX shape import: handle o:allowincell)
    
    Change-Id: If883511b6114e8f60d673ecbd3a11095fcafddc5
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88438
    Tested-by: László Németh <nemeth at numbertext.org>
    Reviewed-by: László Németh <nemeth at numbertext.org>
    (cherry picked from commit ad8857dab30e099a0cf6ec18d184a6c836b33317)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96140
    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/tdf130120.docx b/sw/qa/extras/ooxmlexport/data/tdf130120.docx
new file mode 100644
index 000000000000..5ca2adc76d60
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf130120.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index 6561bbeb6cb8..8d347be29038 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -91,6 +91,15 @@ DECLARE_OOXMLIMPORT_TEST(testTdf129888dml, "tdf129888dml.docx")
                                  text::RelOrientation::PAGE_FRAME, nValue);
 }
 
+DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf130120, "tdf130120.docx")
+{
+   //Text for exporting the allowincell attribute:
+    xmlDocPtr p_XmlDoc = parseExport("word/document.xml");
+    assertXPath(p_XmlDoc, "/w:document/w:body/w:tbl/w:tr/w:tc/w:p/w:r/mc:AlternateContent/"
+                          "mc:Choice/w:drawing/wp:anchor","layoutInCell","0");
+}
+
+
 DECLARE_OOXMLEXPORT_TEST(testTdf87569v, "tdf87569_vml.docx")
 {
     //the original tdf87569 sample has vml shapes...
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx b/sw/source/filter/ww8/docxsdrexport.cxx
index 7cacc4eb3173..1663ab98e30e 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -31,8 +31,9 @@
 #include <comphelper/sequence.hxx>
 #include <comphelper/sequenceashashmap.hxx>
 #include <sal/log.hxx>
-
+#include <frmfmt.hxx>
 #include <IDocumentDrawModelAccess.hxx>
+#include <comphelper/propertysequence.hxx>
 
 using namespace com::sun::star;
 using namespace oox;
@@ -469,7 +470,25 @@ void DocxSdrExport::startDMLAnchorInline(const SwFrameFormat* pFrameFormat, cons
         attrList->add(XML_distR, OString::number(nDistR).getStr());
         attrList->add(XML_simplePos, "0");
         attrList->add(XML_locked, "0");
-        attrList->add(XML_layoutInCell, "1");
+        bool bLclInTabCell = true;
+        if (pObj)
+        {
+            uno::Reference<drawing::XShape> xShape((const_cast<SdrObject*>(pObj)->getUnoShape()),
+                                                   uno::UNO_QUERY);
+            uno::Sequence<beans::PropertyValue> propList = lclGetProperty(xShape, "InteropGrabBag");
+            if (propList.hasElements())
+            {
+                auto pLclProp = std::find_if(
+                    std::begin(propList), std::end(propList),
+                    [](const beans::PropertyValue& rProp) { return rProp.Name == "LayoutInCell"; });
+                if (pLclProp && pLclProp != propList.end())
+                    pLclProp->Value >>= bLclInTabCell;
+            }
+        }
+        if (bLclInTabCell)
+            attrList->add(XML_layoutInCell, "1");
+        else
+            attrList->add(XML_layoutInCell, "0");
         bool bAllowOverlap = pFrameFormat->GetWrapInfluenceOnObjPos().GetAllowOverlap();
         attrList->add(XML_allowOverlap, bAllowOverlap ? "1" : "0");
         if (pObj != nullptr)
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index a49d9dea7054..c622366bd954 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -2703,7 +2703,6 @@ SwFrameFormat* SwWW8ImplReader::Read_GrafLayer( long nGrafAnchorCp )
         SdrObject::Free(pObject);
         return nullptr;
     }
-
     const bool bLayoutInTableCell =
         m_nInTable && IsObjectLayoutInTableCell( pRecord->nLayoutInTableCell );
 
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index a2c19383c95d..174674ae46a0 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -67,6 +67,8 @@
 #include "WrapPolygonHandler.hxx"
 #include "util.hxx"
 
+#include <comphelper/propertysequence.hxx>
+
 using namespace css;
 
 namespace
@@ -872,6 +874,18 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
 
                         //tdf#109411 If anchored object is in table, Word calculates its position from cell border
                         //instead of page (what is set in the sample document)
+                        if (xShapeProps)
+                        {
+                            uno::Sequence<beans::PropertyValue> aShapeGrabBag;
+                            xShapeProps->getPropertyValue("InteropGrabBag") >>= aShapeGrabBag;
+                            beans::PropertyValue aLayInCell;
+                            aLayInCell.Name = "LayoutInCell";
+                            aLayInCell.Value <<= m_pImpl->bLayoutInCell;
+                            aShapeGrabBag.realloc(1 + aShapeGrabBag.size());
+                            aShapeGrabBag[aShapeGrabBag.size() - 1] = aLayInCell;
+                            xShapeProps->setPropertyValue("InteropGrabBag",
+                                                            uno::makeAny(aShapeGrabBag));
+                        }
                         if (m_pImpl->rDomainMapper.IsInTable() && m_pImpl->bLayoutInCell &&
                             m_pImpl->nHoriRelation == text::RelOrientation::PAGE_FRAME && IsGraphic())
                         {
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 19dc3bb917e0..92d17630bf02 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -34,6 +34,9 @@
 #include "OOXMLFastContextHandler.hxx"
 #include "OOXMLFactory.hxx"
 #include "Handler.hxx"
+#include <dmapper/PropertyIds.hxx>
+#include <comphelper/propertysequence.hxx>
+#include <comphelper/sequenceashashmap.hxx>
 
 static const sal_Unicode uCR = 0xd;
 static const sal_Unicode uFtnEdnRef = 0x2;
@@ -1671,15 +1674,28 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t Element )
             //tdf#87569: Fix table layout with correcting anchoring
             //If anchored object is in table, Word calculates its position from cell border
             //instead of page (what is set in the sample document)
+            uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
+            if(xShapePropSet && bIsPicture) //TODO make grabbag for textboxes as well
+            {
+                uno::Sequence<beans::PropertyValue> aShapeGrabBag;
+                xShapePropSet->getPropertyValue("InteropGrabBag") >>= aShapeGrabBag;
+                beans::PropertyValue aLayInCell;
+                aLayInCell.Name = "LayoutInCell";
+                aLayInCell.Value <<= mbLayoutInCell;
+                aShapeGrabBag.realloc(1+aShapeGrabBag.size());
+                aShapeGrabBag[aShapeGrabBag.size() -1] = aLayInCell;
+                xShapePropSet->setPropertyValue("InteropGrabBag", uno::makeAny(aShapeGrabBag));
+            }
             if (mnTableDepth > 0 && mbLayoutInCell) //if we had a table
             {
-                uno::Reference<beans::XPropertySet> xShapePropSet(xShape, uno::UNO_QUERY);
                 sal_Int16 nCurrentHorOriRel; //A temp variable for storaging the current setting
                 xShapePropSet->getPropertyValue("HoriOrientRelation") >>= nCurrentHorOriRel;
                 //and the correction:
                 if (nCurrentHorOriRel == com::sun::star::text::RelOrientation::PAGE_FRAME)
+                {
                     xShapePropSet->setPropertyValue("HoriOrientRelation",
                                                     uno::makeAny(text::RelOrientation::FRAME));
+                }
             }
 
             // Notify the dmapper that the shape is ready to use
@@ -1755,6 +1771,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
                                                            this);
 
                     //tdf129888 store allowincell attribute of the VML shape
+                    mbLayoutInCell = true;
                     if (Attribs->hasAttribute(NMSP_vmlOffice | XML_allowincell))
                         mbLayoutInCell
                             = !(Attribs->getValue(NMSP_vmlOffice | XML_allowincell) == "f");


More information about the Libreoffice-commits mailing list