[Libreoffice-commits] core.git: Branch 'distro/suse/suse-3.6' - sw/source writerfilter/source

Cédric Bosdonnat cedric.bosdonnat at free.fr
Wed Feb 20 06:53:21 PST 2013


 sw/source/core/unocore/unotext.cxx                       |    9 +
 writerfilter/source/dmapper/DomainMapperTableHandler.cxx |   46 -----
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |    9 -
 writerfilter/source/dmapper/DomainMapperTableManager.hxx |    4 
 writerfilter/source/dmapper/TablePositionHandler.cxx     |  117 ++++++++++++++-
 writerfilter/source/dmapper/TablePositionHandler.hxx     |   14 +
 writerfilter/source/ooxml/model.xml                      |    9 -
 7 files changed, 151 insertions(+), 57 deletions(-)

New commits:
commit fca2522c576a386535067ed422a90a05ca648f63
Author: Cédric Bosdonnat <cedric.bosdonnat at free.fr>
Date:   Wed Feb 20 11:04:16 2013 +0100

    n#779642: Fixed floating tables import in writerfilter
    
    (cherry picked from commit d0cde9640b52ccfbb28ed1f65bba0927afd7b69b)
    
    Conflicts:
    	sw/qa/extras/ooxmlimport/ooxmlimport.cxx
    	writerfilter/source/dmapper/DomainMapperTableManager.cxx
    	writerfilter/source/dmapper/DomainMapperTableManager.hxx
    	writerfilter/source/dmapper/TablePositionHandler.cxx
    	writerfilter/source/dmapper/TablePositionHandler.hxx
    
    Change-Id: I706d36358db98524bdf5d1caf0f0543b9170b0bc

diff --git a/sw/source/core/unocore/unotext.cxx b/sw/source/core/unocore/unotext.cxx
index ea5e83b..4f519c2 100644
--- a/sw/source/core/unocore/unotext.cxx
+++ b/sw/source/core/unocore/unotext.cxx
@@ -1603,7 +1603,14 @@ throw (lang::IllegalArgumentException, uno::RuntimeException)
         // remove the addtional paragraphs in the end
         if (pStartStartNode->GetStartNodeType() == SwTableBoxStartNode)
         {
-            SwTableNode *const pStartTableNode(pStartStartNode->FindTableNode());
+            SwTableNode * pStartTableNode(pStartStartNode->FindTableNode());
+            // Is it the same table start node than the end?
+            SwTableNode *const pEndStartTableNode(pEndStartNode->FindTableNode());
+            while (pEndStartTableNode->GetIndex() < pStartTableNode->GetIndex())
+            {
+                SwStartNode* pStartStartTableNode = pStartTableNode->StartOfSectionNode();
+                pStartTableNode = pStartStartTableNode->FindTableNode();
+            }
             const SwNodeIndex aTblIdx(  *pStartTableNode, -1 );
             SwPosition aBefore(aTblIdx);
             bParaBeforeInserted = GetDoc()->AppendTxtNode( aBefore );
diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
index f44e93c..65a26f9 100644
--- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx
@@ -720,7 +720,8 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
         uno::Reference<text::XTextRange> xStart;
         uno::Reference<text::XTextRange> xEnd;
         // If we want to make this table a floating one.
-        bool bFloating = !m_rDMapper_Impl.getTableManager().getTableVertAnchor().isEmpty();
+        uno::Sequence<beans::PropertyValue> aFrameProperties = m_rDMapper_Impl.getTableManager().getTablePosition();
+        bool bFloating = aFrameProperties.hasElements();
         // Additional checks: if we can do this.
         if (bFloating && (*m_pTableSeq)[0].getLength() > 0 && (*m_pTableSeq)[0][0].getLength() > 0)
         {
@@ -767,46 +768,11 @@ void DomainMapperTableHandler::endTable(unsigned int nestedTableLevel)
         if (xTable.is() && xStart.is() && xEnd.is())
         {
             uno::Reference<beans::XPropertySet> xTableProperties(xTable, uno::UNO_QUERY);
-            uno::Sequence< beans::PropertyValue > aFrameProperties(16);
-            beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
-            pFrameProperties[0].Name = "Width";
-            pFrameProperties[0].Value = xTableProperties->getPropertyValue("Width");
-
-            pFrameProperties[1].Name = "LeftBorderDistance";
-            pFrameProperties[1].Value <<= sal_Int32(0);
-            pFrameProperties[2].Name = "RightBorderDistance";
-            pFrameProperties[2].Value <<= sal_Int32(0);
-            pFrameProperties[3].Name = "TopBorderDistance";
-            pFrameProperties[3].Value <<= sal_Int32(0);
-            pFrameProperties[4].Name = "BottomBorderDistance";
-            pFrameProperties[4].Value <<= sal_Int32(0);
-
-            pFrameProperties[5].Name = "LeftMargin";
-            pFrameProperties[5].Value <<= sal_Int32(0);
-            pFrameProperties[6].Name = "RightMargin";
-            pFrameProperties[6].Value <<= sal_Int32(0);
-            pFrameProperties[7].Name = "TopMargin";
-            pFrameProperties[7].Value <<= sal_Int32(0);
-            pFrameProperties[8].Name = "BottomMargin";
-            pFrameProperties[8].Value <<= sal_Int32(0);
-
-            table::BorderLine2 aEmptyBorder;
-            pFrameProperties[9].Name = "TopBorder";
-            pFrameProperties[9].Value <<= aEmptyBorder;
-            pFrameProperties[10].Name = "BottomBorder";
-            pFrameProperties[10].Value <<= aEmptyBorder;
-            pFrameProperties[11].Name = "LeftBorder";
-            pFrameProperties[11].Value <<= aEmptyBorder;
-            pFrameProperties[12].Name = "RightBorder";
-            pFrameProperties[12].Value <<= aEmptyBorder;
-
-            pFrameProperties[13].Name = "HoriOrient";
-            pFrameProperties[13].Value <<= text::HoriOrientation::NONE;
-            pFrameProperties[14].Name = "HoriOrientRelation";
-            pFrameProperties[14].Value <<= text::RelOrientation::FRAME;
+            aFrameProperties.realloc(aFrameProperties.getLength() + 1);
+            aFrameProperties[aFrameProperties.getLength() - 1].Name = "Width";
+            aFrameProperties[aFrameProperties.getLength() - 1].Value = xTableProperties->getPropertyValue("Width");
+
             // A non-zero left margin would move the table out of the frame, move the frame itself instead.
-            pFrameProperties[15].Name = "HoriOrientPosition";
-            pFrameProperties[15].Value <<= xTableProperties->getPropertyValue("LeftMargin");
             xTableProperties->setPropertyValue("LeftMargin", uno::makeAny(sal_Int32(0)));
 
             uno::Reference< text::XTextContent > xFrame = m_xText->convertToTextFrame(xStart, xEnd, aFrameProperties);
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index 50f0cb0..43a8238 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -332,7 +332,7 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm)
                     {
                         TablePositionHandlerPtr pHandler( new TablePositionHandler );
                         pProperties->resolve(*pHandler);
-                        m_sTableVertAnchor = pHandler->getVertAnchor();
+                        m_aTablePosition = pHandler->getTablePosition();
                     }
                 }
                 break;
@@ -368,11 +368,6 @@ boost::shared_ptr< vector< sal_Int32 > > DomainMapperTableManager::getCurrentCel
     return m_aCellWidths.back( );
 }
 
-const rtl::OUString& DomainMapperTableManager::getTableVertAnchor() const
-{
-    return m_sTableVertAnchor;
-}
-
 void DomainMapperTableManager::startLevel( )
 {
     DomainMapperTableManager_Base_t::startLevel( );
@@ -616,8 +611,8 @@ void DomainMapperTableManager::clearData()
 {
     m_nRow = m_nCellBorderIndex = m_nHeaderRepeat = m_nTableWidth = 0;
     m_sTableStyleName = ::rtl::OUString();
-    m_sTableVertAnchor = rtl::OUString();
     m_pTableStyleTextProperies.reset();
+    m_aTablePosition = uno::Sequence<beans::PropertyValue>(0);
 }
 
 
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
index 64a06c2..34a8df5 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx
@@ -54,7 +54,7 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t
     bool            m_bOOXML;
     bool            m_bImplicitMerges;
     ::rtl::OUString m_sTableStyleName;
-    rtl::OUString m_sTableVertAnchor;
+    com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> m_aTablePosition;
     PropertyMapPtr  m_pTableStyleTextProperies;
 
     ::std::vector< IntVectorPtr >  m_aTableGrid;
@@ -91,7 +91,7 @@ public:
     IntVectorPtr getCurrentCellWidths( );
 
     const ::rtl::OUString& getTableStyleName() const { return m_sTableStyleName; }
-    const rtl::OUString& getTableVertAnchor() const;
+    const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getTablePosition() { return m_aTablePosition; }
     /// copy the text properties of the table style and its parent into pContext
     void    CopyTextProperties(PropertyMapPtr pContext, StyleSheetTablePtr pStyleSheetTable);
 
diff --git a/writerfilter/source/dmapper/TablePositionHandler.cxx b/writerfilter/source/dmapper/TablePositionHandler.cxx
index 5a3746b..46324a1 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.cxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.cxx
@@ -11,7 +11,9 @@
 #include <doctok/resourceids.hxx>
 #include <ConversionHelper.hxx>
 #include <ooxml/resourceids.hxx>
-#include <com/sun/star/text/SizeType.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
+#include <com/sun/star/text/RelOrientation.hpp>
 #include "dmapperLoggers.hxx"
 
 namespace writerfilter {
@@ -20,7 +22,13 @@ namespace dmapper {
 using namespace ::com::sun::star;
 
 TablePositionHandler::TablePositionHandler() :
-LoggedProperties(dmapper_logger, "TablePositionHandler")
+    LoggedProperties(dmapper_logger, "TablePositionHandler"),
+    m_aVertAnchor( "margin" ),
+    m_aYSpec( ),
+    m_aHorzAnchor( "text" ),
+    m_aXSpec( ),
+    m_nY( 0 ),
+    m_nX( 0 )
 {
 }
 
@@ -36,6 +44,21 @@ void TablePositionHandler::lcl_attribute(Id rName, Value& rVal)
         case NS_ooxml::LN_CT_TblPPr_vertAnchor:
             m_aVertAnchor = rVal.getString();
         break;
+        case NS_ooxml::LN_CT_TblPPr_tblpYSpec:
+            m_aYSpec = rVal.getString();
+        break;
+        case NS_ooxml::LN_CT_TblPPr_horzAnchor:
+            m_aHorzAnchor = rVal.getString();
+        break;
+        case NS_ooxml::LN_CT_TblPPr_tblpXSpec:
+            m_aXSpec = rVal.getString();
+        break;
+        case NS_ooxml::LN_CT_TblPPr_tblpY:
+            m_nY = rVal.getInt();
+        break;
+        case NS_ooxml::LN_CT_TblPPr_tblpX:
+            m_nX = rVal.getInt();
+        break;
         default:
 #ifdef DEBUG_DOMAINMAPPER
             dmapper_logger->element("unhandled");
@@ -50,9 +73,95 @@ void TablePositionHandler::lcl_sprm(Sprm& /*rSprm*/)
 }
 
 
-rtl::OUString TablePositionHandler::getVertAnchor() const
+uno::Sequence<beans::PropertyValue> TablePositionHandler::getTablePosition() const
 {
-    return m_aVertAnchor;
+    uno::Sequence< beans::PropertyValue > aFrameProperties(18);
+    beans::PropertyValue* pFrameProperties = aFrameProperties.getArray();
+
+    pFrameProperties[0].Name = "LeftBorderDistance";
+    pFrameProperties[0].Value <<= sal_Int32(0);
+    pFrameProperties[1].Name = "RightBorderDistance";
+    pFrameProperties[1].Value <<= sal_Int32(0);
+    pFrameProperties[2].Name = "TopBorderDistance";
+    pFrameProperties[2].Value <<= sal_Int32(0);
+    pFrameProperties[3].Name = "BottomBorderDistance";
+    pFrameProperties[3].Value <<= sal_Int32(0);
+
+    pFrameProperties[4].Name = "LeftMargin";
+    pFrameProperties[4].Value <<= sal_Int32(0);
+    pFrameProperties[5].Name = "RightMargin";
+    pFrameProperties[5].Value <<= sal_Int32(0);
+    pFrameProperties[6].Name = "TopMargin";
+    pFrameProperties[6].Value <<= sal_Int32(0);
+    pFrameProperties[7].Name = "BottomMargin";
+    pFrameProperties[7].Value <<= sal_Int32(0);
+
+    table::BorderLine2 aEmptyBorder;
+    pFrameProperties[8].Name = "TopBorder";
+    pFrameProperties[8].Value <<= aEmptyBorder;
+    pFrameProperties[9].Name = "BottomBorder";
+    pFrameProperties[9].Value <<= aEmptyBorder;
+    pFrameProperties[10].Name = "LeftBorder";
+    pFrameProperties[10].Value <<= aEmptyBorder;
+    pFrameProperties[11].Name = "RightBorder";
+    pFrameProperties[11].Value <<= aEmptyBorder;
+
+    // Horizontal positioning
+    sal_Int16 nHoriOrient = text::HoriOrientation::NONE;
+    if ( m_aXSpec == "center" )
+        nHoriOrient = text::HoriOrientation::CENTER;
+    else if ( m_aXSpec == "inside" )
+        nHoriOrient = text::HoriOrientation::INSIDE;
+    else if ( m_aXSpec == "left" )
+        nHoriOrient = text::HoriOrientation::LEFT;
+    else if ( m_aXSpec == "outside" )
+        nHoriOrient = text::HoriOrientation::OUTSIDE;
+    else if ( m_aXSpec == "right" )
+        nHoriOrient = text::HoriOrientation::RIGHT;
+
+    sal_Int16 nHoriOrientRelation;
+    if ( m_aHorzAnchor == "margin" )
+        nHoriOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
+    else if ( m_aHorzAnchor == "page" )
+        nHoriOrientRelation = text::RelOrientation::PAGE_FRAME;
+    else if ( m_aHorzAnchor == "text" )
+        nHoriOrientRelation = text::RelOrientation::FRAME;
+
+    pFrameProperties[12].Name = "HoriOrient";
+    pFrameProperties[12].Value <<= nHoriOrient;
+    pFrameProperties[13].Name = "HoriOrientRelation";
+    pFrameProperties[13].Value <<= nHoriOrientRelation;
+    pFrameProperties[14].Name = "HoriOrientPosition";
+    pFrameProperties[14].Value <<= m_nX;
+
+
+    // Vertical positioning
+    sal_Int16 nVertOrient = text::VertOrientation::NONE;
+    if ( m_aYSpec == "bottom" )
+        nVertOrient = text::VertOrientation::BOTTOM;
+    else if ( m_aYSpec == "center" )
+        nVertOrient = text::VertOrientation::CENTER;
+    else if ( m_aYSpec == "top" )
+        nVertOrient = text::VertOrientation::TOP;
+    // TODO There are a few cases we can't map ATM.
+
+
+    sal_Int16 nVertOrientRelation;
+    if ( m_aVertAnchor == "margin" )
+        nVertOrientRelation = text::RelOrientation::PAGE_PRINT_AREA;
+    else if ( m_aVertAnchor == "page" )
+        nVertOrientRelation = text::RelOrientation::PAGE_FRAME;
+    else if ( m_aVertAnchor == "text" )
+        nVertOrientRelation = text::RelOrientation::FRAME;
+
+    pFrameProperties[15].Name = "VertOrient";
+    pFrameProperties[15].Value <<= nVertOrient;
+    pFrameProperties[16].Name = "VertOrientRelation";
+    pFrameProperties[16].Value <<= nVertOrientRelation;
+    pFrameProperties[17].Name = "VertOrientPosition";
+    pFrameProperties[17].Value <<= m_nY;
+
+    return aFrameProperties;
 }
 
 } // namespace dmapper
diff --git a/writerfilter/source/dmapper/TablePositionHandler.hxx b/writerfilter/source/dmapper/TablePositionHandler.hxx
index ab698b8..5f77cee 100644
--- a/writerfilter/source/dmapper/TablePositionHandler.hxx
+++ b/writerfilter/source/dmapper/TablePositionHandler.hxx
@@ -12,6 +12,7 @@
 #include <WriterFilterDllApi.hxx>
 #include <resourcemodel/LoggedResources.hxx>
 #include <boost/shared_ptr.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
 
 namespace writerfilter {
     namespace dmapper {
@@ -21,6 +22,11 @@ namespace writerfilter {
             : public LoggedProperties
         {
             rtl::OUString m_aVertAnchor;
+            rtl::OUString m_aYSpec;
+            rtl::OUString m_aHorzAnchor;
+            rtl::OUString m_aXSpec;
+            sal_Int32 m_nY;
+            sal_Int32 m_nX;
 
             // Properties
             virtual void lcl_attribute(Id Name, Value & val);
@@ -30,7 +36,13 @@ namespace writerfilter {
             TablePositionHandler();
             virtual ~TablePositionHandler();
 
-            rtl::OUString getVertAnchor() const;
+            /** Compute the UNO properties for the frame containing the table based
+                on the received tokens.
+
+                Note that the properties will need to be adjusted with the table
+                properties before actually using them.
+              */
+            com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getTablePosition() const;
         };
 
         typedef boost::shared_ptr<TablePositionHandler> TablePositionHandlerPtr;
diff --git a/writerfilter/source/ooxml/model.xml b/writerfilter/source/ooxml/model.xml
index c5a7a90..94c44c0 100644
--- a/writerfilter/source/ooxml/model.xml
+++ b/writerfilter/source/ooxml/model.xml
@@ -17923,7 +17923,7 @@
           <xs:documentation>Relative Horizontal Alignment From Anchor</xs:documentation>
         </attribute>
         <attribute name="tblpX">
-          <text/>
+          <ref name="ST_SignedTwipsMeasure"/>
           <xs:documentation>Absolute Horizontal Distance From Anchor</xs:documentation>
         </attribute>
         <attribute name="tblpYSpec">
@@ -17931,7 +17931,7 @@
           <xs:documentation>Relative Vertical Alignment from Anchor</xs:documentation>
         </attribute>
         <attribute name="tblpY">
-          <text/>
+          <ref name="ST_SignedTwipsMeasure"/>
           <xs:documentation>Absolute Vertical Distance From Anchor</xs:documentation>
         </attribute>
       </define>
@@ -22801,6 +22801,11 @@
     </resource>
     <resource name="CT_TblPPr" resource="Properties" tag="table">
       <attribute name="vertAnchor" tokenid="ooxml:CT_TblPPr_vertAnchor"/>
+      <attribute name="tblpYSpec" tokenid="ooxml:CT_TblPPr_tblpYSpec"/>
+      <attribute name="horzAnchor" tokenid="ooxml:CT_TblPPr_horzAnchor"/>
+      <attribute name="tblpXSpec" tokenid="ooxml:CT_TblPPr_tblpXSpec"/>
+      <attribute name="tblpY" tokenid="ooxml:CT_TblPPr_tblpY"/>
+      <attribute name="tblpX" tokenid="ooxml:CT_TblPPr_tblpX"/>
     </resource>
     <resource name="CT_TblGridCol" resource="Value" tag="table">
       <attribute name="w" tokenid="ooxml:CT_TblGridCol_w" action="setValue"/>


More information about the Libreoffice-commits mailing list