Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/3058

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/58/3058/1

fdo#59273 import w:tblLayout of DOCX tables

Also add missing <w:tblLayout w:type=fixed/> to the bnc#780645 testcase
to avoid breaking the build.

(cherry picked from commits 7329df74df134a77d078f47d5c8b70d54c5d1edb and
4821d894f849a4939bbe6fb0a9a5ddd9e10b0467)

Conflicts:
        writerfilter/source/dmapper/DomainMapperTableManager.cxx
        writerfilter/source/dmapper/DomainMapperTableManager.hxx

Change-Id: I9af50a4c176168e2794eaa9b0e8eaeb6b9d06b13
---
A sw/qa/extras/ooxmlimport/data/fdo59273.docx
M sw/qa/extras/ooxmlimport/data/n780645.docx
M sw/qa/extras/ooxmlimport/ooxmlimport.cxx
M writerfilter/source/dmapper/DomainMapperTableManager.cxx
M writerfilter/source/dmapper/DomainMapperTableManager.hxx
M writerfilter/source/dmapper/TablePropertiesHandler.cxx
M writerfilter/source/ooxml/model.xml
7 files changed, 45 insertions(+), 11 deletions(-)



diff --git a/sw/qa/extras/ooxmlimport/data/fdo59273.docx 
b/sw/qa/extras/ooxmlimport/data/fdo59273.docx
new file mode 100644
index 0000000..fcdfd77
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/fdo59273.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/data/n780645.docx b/sw/qa/extras/ooxmlimport/data/n780645.docx
index 12ffa38..35ad11f 100755
--- a/sw/qa/extras/ooxmlimport/data/n780645.docx
+++ b/sw/qa/extras/ooxmlimport/data/n780645.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 51ce241..aeda333 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -115,6 +115,7 @@
     void testFdo59638();
     void testFdo61343();
     void testFdo60922();
+    void testFdo59273();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -182,6 +183,7 @@
         {"fdo59638.docx", &Test::testFdo59638},
         {"fdo61343.docx", &Test::testFdo61343},
         {"fdo60922.docx", &Test::testFdo60922},
+        {"fdo59273.docx", &Test::testFdo59273},
     };
     for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i)
     {
@@ -1140,6 +1142,16 @@
     CPPUNIT_ASSERT_EQUAL(sal_Int32(100), getProperty<sal_Int32>(getRun(getParagraph(1), 1), 
"CharEscapementHeight"));
 }
 
+void Test::testFdo59273()
+{
+    uno::Reference<text::XTextTablesSupplier> xTablesSupplier(mxComponent, uno::UNO_QUERY);
+    uno::Reference<container::XIndexAccess> xTables(xTablesSupplier->getTextTables( ), 
uno::UNO_QUERY);
+    uno::Reference<text::XTextTable> xTextTable(xTables->getByIndex(0), uno::UNO_QUERY);
+    uno::Reference<table::XTableRows> xTableRows(xTextTable->getRows(), uno::UNO_QUERY);
+    // Was 9997, so the 4th column had ~zero width
+    CPPUNIT_ASSERT_EQUAL(sal_Int16(7498), getProperty< uno::Sequence<text::TableColumnSeparator> 
(xTableRows->getByIndex(0), "TableColumnSeparators")[2].Position);
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx 
b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index d81aea7..0298690 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -51,6 +51,7 @@
     m_nTableWidth(0),
     m_bOOXML( bOOXML ),
     m_bPushCurrentWidth(false),
+    m_nLayoutType(0),
     m_pTablePropsHandler( new TablePropertiesHandler( bOOXML ) )
 {
     m_pTablePropsHandler->SetTableManager( this );
@@ -395,6 +396,7 @@
     m_aTablePositions.push_back( pNewPositionHandler );
     m_nCell.push_back( 0 );
     m_nTableWidth = 0;
+    m_nLayoutType = 0;
 
     // And push it back to the right level.
     if (oCurrentWidth)
@@ -408,6 +410,7 @@
     m_aCellWidths.pop_back( );
     m_nCell.pop_back( );
     m_nTableWidth = 0;
+    m_nLayoutType = 0;
 
 
     DomainMapperTableManager_Base_t::endLevel( );
@@ -548,12 +551,13 @@
 #endif
         insertRowProps(pPropMap);
     }
-    else if (pCellWidths->size() > 0)
+    else if (pCellWidths->size() > 0 && m_nLayoutType == 
NS_ooxml::LN_Value_wordprocessingml_ST_TblLayout_fixed)
     {
         // If we're here, then the number of cells does not equal to the amount
         // defined by the grid, even after taking care of
         // gridSpan/gridBefore/gridAfter. Handle this by ignoring the grid and
-        // providing the separators based on the provided cell widths.
+        // providing the separators based on the provided cell widths, as long
+        // as we have a fixed layout.
         uno::Sequence< text::TableColumnSeparator > aSeparators(pCellWidths->size() - 1);
         text::TableColumnSeparator* pSeparators = aSeparators.getArray();
         sal_Int16 nSum = 0;
@@ -593,7 +597,7 @@
 
 void DomainMapperTableManager::clearData()
 {
-    m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
+    m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = m_nLayoutType = 0;
     m_sTableStyleName = OUString();
     m_pTableStyleTextProperies.reset();
 }
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx 
b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index d3164ea..0488de4 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -54,6 +54,8 @@
     bool            m_bPushCurrentWidth;
     /// Individual table cell width values, used only in case the number of cells doesn't match 
the table grid.
     ::std::vector< IntVectorPtr >  m_aCellWidths;
+    /// Table layout algorithm, IOW if we should consider fixed column width or not.
+    sal_uInt32 m_nLayoutType;
 
     TablePropertiesHandler   *m_pTablePropsHandler;
     PropertyMapPtr            m_pStyleProps;
@@ -119,6 +121,11 @@
            DomainMapperTableManager_Base_t::insertTableProps( pProps );
     };
 
+    void SetLayoutType(sal_uInt32 nLayoutType)
+    {
+        m_nLayoutType = nLayoutType;
+    }
+
 };
 
 }}
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx 
b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index b1d560c..92c5bbb 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -24,6 +24,7 @@
 #include "MeasureHandler.hxx"
 #include "TablePropertiesHandler.hxx"
 #include "TDefTableHandler.hxx"
+#include "DomainMapperTableManager.hxx"
 
 #include <ooxml/resourceids.hxx>
 #include <doctok/sprmids.hxx>
@@ -155,6 +156,13 @@
                 }
             }
             break;
+            case NS_ooxml::LN_CT_TblPrBase_tblLayout:
+            {
+                DomainMapperTableManager* pManager = 
dynamic_cast<DomainMapperTableManager*>(m_pTableManager);
+                if (pManager)
+                    pManager->SetLayoutType(static_cast<sal_uInt32>(nIntValue));
+            }
+            break;
             case NS_ooxml::LN_CT_TcPrBase_tcBorders ://cell borders
             //contains CT_TcBorders_left, right, top, bottom
             {
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index 27c46a4..1886188 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -17882,7 +17882,7 @@
           <xs:documentation>Revision Identifier for Table Row Properties</xs:documentation>
         </attribute>
       </define>
-      <define name="ST_TblLayoutType">
+      <define name="ST_TblLayout">
         <list>
           <xs:documentation>Table Layout Type</xs:documentation>
           <choice>
@@ -17893,9 +17893,9 @@
           </choice>
         </list>
       </define>
-      <define name="CT_TblLayoutType">
+      <define name="CT_TblLayout">
         <attribute name="type">
-          <text/>
+          <ref name="ST_TblLayout"/>
           <xs:documentation>Table Layout Setting</xs:documentation>
         </attribute>
       </define>
@@ -18095,7 +18095,7 @@
         </optional>
         <optional>
           <element name="tblLayout">
-            <ref name="CT_TblLayoutType"/>
+            <ref name="CT_TblLayout"/>
           </element>
         </optional>
         <optional>
@@ -18150,7 +18150,7 @@
         </optional>
         <optional>
           <element name="tblLayout">
-            <ref name="CT_TblLayoutType"/>
+            <ref name="CT_TblLayout"/>
           </element>
         </optional>
         <optional>
@@ -22943,9 +22943,12 @@
       <action name="end" action="sendTableProperties"/>
       <action name="end" action="endRow"/>
     </resource>
-    <resource name="ST_TblLayoutType" resource="List" generated="yes">
-      <value name="fixed" 
tokenid="ooxml:Value_wordprocessingml_ST_TblLayoutType_fixed">fixed</value>
-      <value name="autofit" 
tokenid="ooxml:Value_wordprocessingml_ST_TblLayoutType_autofit">autofit</value>
+    <resource name="ST_TblLayout" resource="List">
+      <value tokenid="ooxml:Value_wordprocessingml_ST_TblLayout_fixed">fixed</value>
+      <value tokenid="ooxml:Value_wordprocessingml_ST_TblLayout_autofit">autofit</value>
+    </resource>
+    <resource name="CT_TblLayout" resource="Value" tag="table">
+      <attribute name="type" tokenid="ooxml:CT_TblLayout_type" action="setValue"/>
     </resource>
     <resource name="ST_TblOverlap" resource="List">
       <value tokenid="ooxml:Value_ST_TblOverlap_never">never</value>

-- 
To view, visit https://gerrit.libreoffice.org/3058
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I9af50a4c176168e2794eaa9b0e8eaeb6b9d06b13
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Miklos Vajna <vmiklos@suse.cz>


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.