[Libreoffice-commits] core.git: sw/qa writerfilter/source

Luboš Luňák l.lunak at collabora.com
Sun Sep 21 08:55:16 PDT 2014


 sw/qa/extras/ooxmlimport/data/bnc891663.docx  |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx      |    9 +++++++++
 writerfilter/source/dmapper/GraphicImport.cxx |    7 +++++++
 writerfilter/source/dmapper/PropertyIds.cxx   |    1 +
 writerfilter/source/dmapper/PropertyIds.hxx   |    1 +
 5 files changed, 18 insertions(+)

New commits:
commit 3891ba42a886fa85eb43da24d1badf44e765d54c
Author: Luboš Luňák <l.lunak at collabora.com>
Date:   Sun Sep 21 17:52:58 2014 +0200

    handle docx's w:anchor layoutInCell attribute (bnc#891663)
    
    Change-Id: I8268567b84aa0f6e42624bfd0f79c8c49c153edd

diff --git a/sw/qa/extras/ooxmlimport/data/bnc891663.docx b/sw/qa/extras/ooxmlimport/data/bnc891663.docx
new file mode 100644
index 0000000..d5f057e
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/bnc891663.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 1b83243..7136808 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -2364,6 +2364,15 @@ DECLARE_OOXMLIMPORT_TEST(testBnc519228OddBreaks, "bnc519228_odd-breaks.docx")
     getParagraphOfText( 1, getProperty< uno::Reference<text::XText> >(page5Style, "HeaderText"), "This is the header for odd pages");
 }
 
+DECLARE_OOXMLIMPORT_TEST(testBnc891663, "bnc891663.docx")
+{
+    // The image should be inside a cell, so the text in the following cell should be below it.
+    int imageTop = parseDump("/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds", "top").toInt32();
+    int imageHeight = parseDump("/root/page/body/tab/row[1]/cell[2]/txt[1]/anchored/fly/infos/bounds", "height").toInt32();
+    int textNextRowTop = parseDump("/root/page/body/tab/row[2]/cell[1]/txt[1]/infos/bounds", "top").toInt32();
+    CPPUNIT_ASSERT( textNextRowTop >= imageTop + imageHeight );
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/GraphicImport.cxx b/writerfilter/source/dmapper/GraphicImport.cxx
index dc9eb62..e3178c2 100644
--- a/writerfilter/source/dmapper/GraphicImport.cxx
+++ b/writerfilter/source/dmapper/GraphicImport.cxx
@@ -207,6 +207,7 @@ public:
     sal_Int16 nVertOrient;
     sal_Int16 nVertRelation;
     sal_Int32 nWrap;
+    bool      bLayoutInCell;
     bool      bOpaque;
     bool      bContour;
     bool      bContourOutside;
@@ -277,6 +278,7 @@ public:
         ,nVertOrient(  text::VertOrientation::NONE )
         ,nVertRelation( text::RelOrientation::FRAME )
         ,nWrap(0)
+        ,bLayoutInCell(false)
         ,bOpaque( true )
         ,bContour(false)
         ,bContourOutside(true)
@@ -580,6 +582,8 @@ void GraphicImport::lcl_attribute(Id nName, Value& rValue)
         break;
         case NS_ooxml::LN_CT_Anchor_locked: // 90990; - ignored
         case NS_ooxml::LN_CT_Anchor_layoutInCell: // 90991; - ignored
+            m_pImpl->bLayoutInCell = nIntValue != 0;
+        break;
         case NS_ooxml::LN_CT_Anchor_hidden: // 90992; - ignored
         break;
         case NS_ooxml::LN_CT_Anchor_allowOverlap: // 90993;
@@ -1232,6 +1236,9 @@ uno::Reference< text::XTextContent > GraphicImport::createGraphicObject( const b
                 }
                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND ),
                         uno::makeAny(m_pImpl->nWrap));
+                if( m_pImpl->bLayoutInCell && m_pImpl->nWrap != text::WrapTextMode_THROUGHT )
+                    xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_FOLLOW_TEXT_FLOW ),
+                            uno::makeAny(true));
 
                 xGraphicObjectProperties->setPropertyValue(rPropNameSupplier.GetName( PROP_SURROUND_CONTOUR ),
                     uno::makeAny(m_pImpl->bContour));
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 8ce4a73..8d21989 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -400,6 +400,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_CELL_CNF_STYLE: sName = "CellCnfStyle"; break;
             case PROP_ROW_CNF_STYLE: sName = "RowCnfStyle"; break;
             case PROP_CELL_HIDE_MARK: sName = "CellHideMark"; break;
+            case PROP_FOLLOW_TEXT_FLOW: sName = "IsFollowingTextFlow"; break;
         }
         ::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
                 m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index bfba954..4e09508 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -372,6 +372,7 @@ enum PropertyIds
         ,PROP_CELL_CNF_STYLE
         ,PROP_ROW_CNF_STYLE
         ,PROP_CELL_HIDE_MARK
+        ,PROP_FOLLOW_TEXT_FLOW
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier


More information about the Libreoffice-commits mailing list