sw/qa/extras/ooxmlexport/ooxmlexport14.cxx            |   28 ++++++-------
 sw/source/core/doc/textboxhelper.cxx                  |    4 +
 sw/source/core/unocore/unotext.cxx                    |    4 -
 sw/source/filter/ww8/docxsdrexport.cxx                |   12 +----
 writerfilter/source/dmapper/GraphicImport.cxx         |   33 ++++------------
 writerfilter/source/ooxml/OOXMLFastContextHandler.cxx |   37 ++++--------------
 writerfilter/source/ooxml/OOXMLFastContextHandler.hxx |    3 -
 7 files changed, 43 insertions(+), 78 deletions(-)

New commits:
commit 33a0d2f40cee7d1ea46af5bdcac2d0791646c064
Author:     Attila Bakos <bakos.attilakar...@nisz.hu>
AuthorDate: Thu Mar 19 14:40:36 2020 +0100
Commit:     Gabor Kelemen <kelemen.gab...@nisz.hu>
CommitDate: Fri Jun 12 10:20:20 2020 +0200

    tdf#119038 DOCX: fix FollowTextFlow handling
    
    This fix also a clean-up for the following commits:
    
    ad8857dab30e099a0cf6ec18d184a6c836b33317
    (tdf#130120 DOCX: export o:allowincell)
    14ad64270e4fbca3c24da6f55f260b1fb229556a
    (tdf#129888 DOCX shape import: handle o:allowincell)
    10f29d8bf05d44ca8bc11d34d1294ec17f8ac0f1
    (tdf#87569 tdf#109411 DOCX import: fix shape anchor in tables)
    
    where these patches ignored the option "Follow text flow"
    and there was no possibility to switch this setting on GUI.
    Now this is handled on GUI as well by replacing the
    grab-bag with UNO property "IsFollowingTextFlow".
    
    The tdf#119038 bug also fixed.
    
    Note: Unit tests for the commits mentioned above were
    modified for testing the new property, so new tests were
    not added.
    
    Change-Id: Ie35c6e280f8b33d8535ca4cd9749f110f9d592ee
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90753
    Tested-by: László Németh <nem...@numbertext.org>
    Reviewed-by: László Németh <nem...@numbertext.org>
    (cherry picked from commit 27d04f6dbf38aa28fb7215590d578c4567db5770)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96171
    Tested-by: Gabor Kelemen <kelemen.gab...@nisz.hu>
    Reviewed-by: Gabor Kelemen <kelemen.gab...@nisz.hu>

diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
index cf01b3231e37..7f1e63d39cc7 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport14.cxx
@@ -84,10 +84,10 @@ DECLARE_OOXMLIMPORT_TEST(testTdf129888vml, 
"tdf129888vml.docx")
     //to be calculated from the page frame instead of the table:
 
     uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), 
uno::UNO_QUERY);
-    sal_Int16 nValue;
-    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    bool bValue;
+    xShapeProperties->getPropertyValue("IsFollowingTextFlow") >>= bValue;
     CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf129888vml The line shape has bad place!",
-                                 text::RelOrientation::PAGE_FRAME, nValue);
+                                 false, bValue);
 }
 
 DECLARE_OOXMLIMPORT_TEST(testTdf129888dml, "tdf129888dml.docx")
@@ -98,18 +98,18 @@ DECLARE_OOXMLIMPORT_TEST(testTdf129888dml, 
"tdf129888dml.docx")
     //to be calculated from the page frame instead of the table:
 
     uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), 
uno::UNO_QUERY);
-    sal_Int16 nValue;
-    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    bool bValue;
+    xShapeProperties->getPropertyValue("IsFollowingTextFlow") >>= bValue;
     CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf129888dml The shape has bad place!",
-                                 text::RelOrientation::PAGE_FRAME, nValue);
+        false, bValue);
 }
 
 DECLARE_OOXMLEXPORT_EXPORTONLY_TEST(testTdf130120, "tdf130120.docx")
 {
-   //Text for exporting the allowincell attribute:
+    //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");
+        "mc:Choice/w:drawing/wp:anchor", "layoutInCell", "0");
 }
 
 
@@ -117,20 +117,20 @@ DECLARE_OOXMLEXPORT_TEST(testTdf87569v, 
"tdf87569_vml.docx")
 {
     //the original tdf87569 sample has vml shapes...
     uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), 
uno::UNO_QUERY);
-    sal_Int16 nValue;
-    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    bool bValue;
+    xShapeProperties->getPropertyValue("IsFollowingTextFlow") >>= bValue;
     CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_vml: The Shape is not in the 
table!",
-                                 text::RelOrientation::FRAME, nValue);
+                                 true, bValue);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf87569d, "tdf87569_drawingml.docx")
 {
     //if the original tdf87569 sample is upgraded it will have drawingml 
shapes...
     uno::Reference<beans::XPropertySet> xShapeProperties(getShape(1), 
uno::UNO_QUERY);
-    sal_Int16 nValue;
-    xShapeProperties->getPropertyValue("HoriOrientRelation") >>= nValue;
+    bool bValue;
+    xShapeProperties->getPropertyValue("IsFollowingTextFlow") >>= bValue;
     CPPUNIT_ASSERT_EQUAL_MESSAGE("tdf87569_drawingml: The Shape is not in the 
table!",
-                                 text::RelOrientation::FRAME, nValue);
+                                 true, bValue);
 }
 
 DECLARE_OOXMLEXPORT_TEST(testTdf130610, "tdf130610_bold_in_2_styles.ott")
diff --git a/sw/source/core/doc/textboxhelper.cxx 
b/sw/source/core/doc/textboxhelper.cxx
index 37939224daf6..51daa63f11a4 100644
--- a/sw/source/core/doc/textboxhelper.cxx
+++ b/sw/source/core/doc/textboxhelper.cxx
@@ -61,8 +61,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape)
         pShape->GetDoc()->GetDocShell()->GetBaseModel(), uno::UNO_QUERY);
     uno::Reference<text::XTextContentAppend> 
xTextContentAppend(xTextDocument->getText(),
                                                                 
uno::UNO_QUERY);
-    xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence<beans::PropertyValue>());
 
+    xTextContentAppend->appendTextContent(xTextFrame, 
uno::Sequence<beans::PropertyValue>());
     // Link FLY and DRAW formats, so it becomes a text box (needed for 
syncProperty calls).
     uno::Reference<text::XTextFrame> xRealTextFrame(xTextFrame, 
uno::UNO_QUERY);
     auto pTextFrame = dynamic_cast<SwXTextFrame*>(xRealTextFrame.get());
@@ -109,6 +109,8 @@ void SwTextBoxHelper::create(SwFrameFormat* pShape)
     syncProperty(pShape, RES_FRM_SIZE, MID_FRMSIZE_SIZE, 
uno::makeAny(xShape->getSize()));
 
     uno::Reference<beans::XPropertySet> xShapePropertySet(xShape, 
uno::UNO_QUERY);
+    syncProperty(pShape, RES_FOLLOW_TEXT_FLOW, MID_FOLLOW_TEXT_FLOW,
+                 
xShapePropertySet->getPropertyValue(UNO_NAME_IS_FOLLOWING_TEXT_FLOW));
     syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_ORIENT,
                  xShapePropertySet->getPropertyValue(UNO_NAME_HORI_ORIENT));
     syncProperty(pShape, RES_HORI_ORIENT, MID_HORIORIENT_RELATION,
diff --git a/sw/source/core/unocore/unotext.cxx 
b/sw/source/core/unocore/unotext.cxx
index 8bdc6d575e73..13a12215444d 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1483,8 +1483,8 @@ SwXText::insertTextContentWithProperties(
 uno::Reference< text::XTextRange > SAL_CALL
 SwXText::appendTextContent(
     const uno::Reference< text::XTextContent >& xTextContent,
-    const uno::Sequence< beans::PropertyValue >&
-        rCharacterAndParagraphProperties)
+    const uno::Sequence< beans::PropertyValue >& 
rCharacterAndParagraphProperties
+    )
 {
     // Right now this doesn't need a guard, as it's just calling the insert
     // version, that has it already.
diff --git a/sw/source/filter/ww8/docxsdrexport.cxx 
b/sw/source/filter/ww8/docxsdrexport.cxx
index 1663ab98e30e..1fb320916d7a 100644
--- a/sw/source/filter/ww8/docxsdrexport.cxx
+++ b/sw/source/filter/ww8/docxsdrexport.cxx
@@ -475,15 +475,9 @@ void DocxSdrExport::startDMLAnchorInline(const 
SwFrameFormat* pFrameFormat, cons
         {
             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;
-            }
+            uno::Reference<beans::XPropertySet> xShapeProps(xShape, 
uno::UNO_QUERY);
+            if (xShapeProps.is())
+                xShapeProps->getPropertyValue("IsFollowingTextFlow") >>= 
bLclInTabCell;
         }
         if (bLclInTabCell)
             attrList->add(XML_layoutInCell, "1");
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx 
b/writerfilter/source/dmapper/GraphicImport.cxx
index 78572a40d964..8afea80365fe 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -265,7 +265,7 @@ public:
         ,nVertOrient(  text::VertOrientation::NONE )
         ,nVertRelation( text::RelOrientation::FRAME )
         ,nWrap(text::WrapTextMode_NONE)
-        ,bLayoutInCell(false)
+        ,bLayoutInCell(true)
         ,bOpaque( !rDMapper.IsInHeaderFooter() )
         ,bContour(false)
         ,bContourOutside(true)
@@ -656,7 +656,6 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
             {
                 uno::Reference< drawing::XShape> xShape;
                 rValue.getAny( ) >>= xShape;
-
                 if ( xShape.is( ) )
                 {
                     // Is it a graphic image
@@ -841,7 +840,12 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                             eAnchorType = 
text::TextContentAnchorType_AT_CHARACTER;
 
                         xShapeProps->setPropertyValue("AnchorType", 
uno::makeAny(eAnchorType));
-
+                        if (m_pImpl->bLayoutInCell && bTextBox && 
m_pImpl->rDomainMapper.IsInTable()
+                            && m_pImpl->nHoriRelation == 
text::RelOrientation::PAGE_FRAME)
+                            m_pImpl->nHoriRelation = 
text::RelOrientation::FRAME;
+                        if(m_pImpl->rDomainMapper.IsInTable())
+                            
xShapeProps->setPropertyValue(getPropertyName(PROP_FOLLOW_TEXT_FLOW),
+                                uno::makeAny(m_pImpl->bLayoutInCell));
                         //only the position orientation is handled in 
applyPosition()
                         m_pImpl->applyPosition(xShapeProps);
 
@@ -878,25 +882,6 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
                                 xShapeProps->setPropertyValue("RotateAngle", 
uno::makeAny(nRotation));
                         }
 
-                        //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())
-                        {
-                            m_pImpl->nHoriRelation = 
text::RelOrientation::FRAME;
-                        }
 
                         m_pImpl->applyRelativePosition(xShapeProps, 
/*bRelativeOnly=*/true);
 
@@ -1366,9 +1351,9 @@ uno::Reference<text::XTextContent> 
GraphicImport::createGraphicObject(uno::Refer
                 }
                 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_SURROUND ),
                     uno::makeAny(static_cast<sal_Int32>(m_pImpl->nWrap)));
-                if( m_pImpl->rDomainMapper.IsInTable() && 
m_pImpl->bLayoutInCell )
+                if( m_pImpl->rDomainMapper.IsInTable())
                     
xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_FOLLOW_TEXT_FLOW ),
-                        uno::makeAny(true));
+                        uno::makeAny(m_pImpl->bLayoutInCell));
 
                 xGraphicObjectProperties->setPropertyValue(getPropertyName( 
PROP_SURROUND_CONTOUR ),
                     uno::makeAny(m_pImpl->bContour));
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 92d17630bf02..7cb7404b8c67 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -37,6 +37,7 @@
 #include <dmapper/PropertyIds.hxx>
 #include <comphelper/propertysequence.hxx>
 #include <comphelper/sequenceashashmap.hxx>
+#include <dmapper/PropertyIds.hxx>
 
 static const sal_Unicode uCR = 0xd;
 static const sal_Unicode uFtnEdnRef = 0x2;
@@ -70,7 +71,8 @@ OOXMLFastContextHandler::OOXMLFastContextHandler
   mpStream(nullptr),
   mnTableDepth(0),
   inPositionV(false),
-  mbLayoutInCell(true),
+  mbAllowInCell(true),
+  mbIsVMLfound(false),
   m_xContext(context),
   m_bDiscardChildren(false),
   m_bTookChoice(false)
@@ -91,7 +93,8 @@ 
OOXMLFastContextHandler::OOXMLFastContextHandler(OOXMLFastContextHandler * pCont
   mpParserState(pContext->mpParserState),
   mnTableDepth(pContext->mnTableDepth),
   inPositionV(pContext->inPositionV),
-  mbLayoutInCell(pContext->mbLayoutInCell),
+  mbAllowInCell(pContext->mbAllowInCell),
+  mbIsVMLfound(pContext->mbIsVMLfound),
   m_xContext(pContext->m_xContext),
   m_bDiscardChildren(pContext->m_bDiscardChildren),
   m_bTookChoice(pContext->m_bTookChoice)
@@ -1670,34 +1673,15 @@ void OOXMLFastContextHandlerShape::sendShape( Token_t 
Element )
 
             bool bIsPicture = Element == ( NMSP_dmlPicture | XML_pic );
 
-
             //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
+            if (mnTableDepth > 0 && xShapePropSet.is() && mbIsVMLfound) //if 
we had a table
             {
-                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));
-                }
+                
xShapePropSet->setPropertyValue(dmapper::getPropertyName(dmapper::PROP_FOLLOW_TEXT_FLOW),
+                                                uno::makeAny(mbAllowInCell));
             }
-
             // Notify the dmapper that the shape is ready to use
             if ( !bIsPicture )
             {
@@ -1748,7 +1732,7 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
     bool bGroupShape = Element == Token_t(NMSP_vml | XML_group);
     // drawingML version also counts as a group shape.
     bGroupShape |= mrShapeContext->getStartToken() == Token_t(NMSP_wpg | 
XML_wgp);
-
+    mbIsVMLfound = (getNamespace(Element) == NMSP_vmlOffice) || 
(getNamespace(Element) == NMSP_vml);
     switch (oox::getNamespace(Element))
     {
         case NMSP_doc:
@@ -1771,9 +1755,8 @@ OOXMLFastContextHandlerShape::lcl_createFastChildContext
                                                            this);
 
                     //tdf129888 store allowincell attribute of the VML shape
-                    mbLayoutInCell = true;
                     if (Attribs->hasAttribute(NMSP_vmlOffice | 
XML_allowincell))
-                        mbLayoutInCell
+                        mbAllowInCell
                             = !(Attribs->getValue(NMSP_vmlOffice | 
XML_allowincell) == "f");
 
                     if (!bGroupShape)
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx 
b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
index 0cc3fb1791a9..e2d1ae20449b 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.hxx
@@ -226,7 +226,8 @@ protected:
     const css::uno::Reference< css::uno::XComponentContext >& 
getComponentContext() const { return m_xContext;}
 
     bool inPositionV;
-    bool mbLayoutInCell; // o:allowincell
+    bool mbAllowInCell; // o:allowincell
+    bool mbIsVMLfound;
     OOXMLValue::Pointer_t mpGridAfter;
 
 private:
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to