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

Miklos Vajna vmiklos at collabora.co.uk
Thu Oct 24 05:55:50 PDT 2013


 writerfilter/source/dmapper/CellMarginHandler.cxx      |   54 +++++++++++++++++
 writerfilter/source/dmapper/CellMarginHandler.hxx      |   13 +++-
 writerfilter/source/dmapper/MeasureHandler.cxx         |    7 ++
 writerfilter/source/dmapper/StyleSheetTable.cxx        |   26 +++++++-
 writerfilter/source/dmapper/TablePropertiesHandler.cxx |    4 +
 5 files changed, 102 insertions(+), 2 deletions(-)

New commits:
commit d5c420b32dd104fe4105d1ca004eb8206fdba0d8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 24 14:49:47 2013 +0200

    writerfilter: save styleId / name / isDefault for table styles
    
    Change-Id: Ib422584d2f6cbb8bfd88dd67aef96b8b062c3d38

diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx
index 1dfac15..f53e129 100644
--- a/writerfilter/source/dmapper/StyleSheetTable.cxx
+++ b/writerfilter/source/dmapper/StyleSheetTable.cxx
@@ -176,7 +176,7 @@ PropertyMapPtr TableStyleSheetEntry::GetProperties( sal_Int32 nMask, StyleSheetE
 beans::PropertyValue TableStyleSheetEntry::GetInteropGrabBag()
 {
     beans::PropertyValue aRet;
-    aRet.Name = sStyleName;
+    aRet.Name = sStyleIdentifierI;
 
     uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
     beans::PropertyValue* pSeq = aSeq.getArray();
@@ -477,12 +477,28 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val)
         break;
         case NS_ooxml::LN_CT_Style_default:
             m_pImpl->m_pCurrentEntry->bIsDefaultStyle = (nIntValue != 0);
+            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+            {
+                TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
+                beans::PropertyValue aValue;
+                aValue.Name = "default";
+                aValue.Value = uno::makeAny(sal_Bool(pTableEntry->bIsDefaultStyle));
+                pTableEntry->AppendInteropGrabBag(aValue);
+            }
         break;
         case NS_ooxml::LN_CT_Style_customStyle:
         break;
         case NS_ooxml::LN_CT_Style_styleId:
             m_pImpl->m_pCurrentEntry->sStyleIdentifierI = sValue;
             m_pImpl->m_pCurrentEntry->sStyleIdentifierD = sValue;
+            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+            {
+                TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
+                beans::PropertyValue aValue;
+                aValue.Name = "styleId";
+                aValue.Value = uno::makeAny(sValue);
+                pTableEntry->AppendInteropGrabBag(aValue);
+            }
         break;
         case NS_ooxml::LN_CT_TblWidth_w:
             dynamic_cast< StyleSheetPropertyMap* >( m_pImpl->m_pCurrentEntry->pProperties.get() )->SetCT_TblWidth_w( nIntValue );
@@ -533,6 +549,14 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm)
             //this is only a UI name!
             m_pImpl->m_pCurrentEntry->sStyleName = sStringValue;
             m_pImpl->m_pCurrentEntry->sStyleName1 = sStringValue;
+            if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE)
+            {
+                TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get());
+                beans::PropertyValue aValue;
+                aValue.Name = "name";
+                aValue.Value = uno::makeAny(sStringValue);
+                pTableEntry->AppendInteropGrabBag(aValue);
+            }
             break;
         case NS_ooxml::LN_CT_Style_basedOn:
             m_pImpl->m_pCurrentEntry->sBaseStyleIdentifier = sStringValue;
commit 0ed8f752b4566ac427c0a48e14904907a7dac839
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Oct 24 14:34:10 2013 +0200

    writerfilter: implement CellMarginHandler::getInteropGrabBag
    
    This allows roundtrip of the whole tblCellMar XML fragment.
    
    Change-Id: I41c5afd6b1cfa7322f5f1bd8c44ed6bffe10eb41

diff --git a/writerfilter/source/dmapper/CellMarginHandler.cxx b/writerfilter/source/dmapper/CellMarginHandler.cxx
index 6119831..a74e02b 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.cxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.cxx
@@ -32,6 +32,8 @@ using namespace ::writerfilter;
 CellMarginHandler::CellMarginHandler() :
 LoggedProperties(dmapper_logger, "CellMarginHandler"),
 m_nValue( 0 ),
+m_nWidth( 0 ),
+m_nType( 0 ),
 m_nLeftMargin( 0 ),
 m_bLeftMarginValid( false ),
 m_nRightMargin( 0 ),
@@ -55,16 +57,42 @@ void CellMarginHandler::lcl_attribute(Id rName, Value & rVal)
     switch( rName )
     {
         case NS_ooxml::LN_CT_TblWidth_w:
+            m_nWidth = nIntValue;
             m_nValue = ConversionHelper::convertTwipToMM100( nIntValue );
         break;
         case NS_ooxml::LN_CT_TblWidth_type:
             OSL_ENSURE( NS_ooxml::LN_Value_ST_TblWidth_dxa == sal::static_int_cast<Id>(nIntValue), "cell margins work for absolute values, only");
+            m_nType = nIntValue;
         break;
         default:
             OSL_FAIL( "unknown attribute");
     }
 }
 
+void CellMarginHandler::createGrabBag(OUString aName)
+{
+    if (m_aInteropGrabBagName.isEmpty())
+        return;
+
+    beans::PropertyValue aRet;
+    aRet.Name = aName;
+
+    uno::Sequence<beans::PropertyValue> aSeq(2);
+    aSeq[0].Name = "w";
+    aSeq[0].Value = uno::makeAny(m_nWidth);
+    aSeq[1].Name = "type";
+    switch (m_nType)
+    {
+        case NS_ooxml::LN_Value_ST_TblWidth_nil: aSeq[1].Value = uno::makeAny(OUString("nil")); break;
+        case NS_ooxml::LN_Value_ST_TblWidth_pct: aSeq[1].Value = uno::makeAny(OUString("pct")); break;
+        case NS_ooxml::LN_Value_ST_TblWidth_dxa: aSeq[1].Value = uno::makeAny(OUString("dxa")); break;
+        case NS_ooxml::LN_Value_ST_TblWidth_auto: aSeq[1].Value = uno::makeAny(OUString("auto")); break;
+    }
+
+    aRet.Value = uno::makeAny(aSeq);
+    m_aInteropGrabBag.push_back(aRet);
+}
+
 void CellMarginHandler::lcl_sprm(Sprm & rSprm)
 {
     writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps();
@@ -78,6 +106,7 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
             case NS_ooxml::LN_CT_TcMar_top:
                 m_nTopMargin = m_nValue;
                 m_bTopMarginValid = true;
+                createGrabBag("top");
             break;
             case NS_ooxml::LN_CT_TblCellMar_start:
                 if( rtl )
@@ -90,16 +119,19 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                     m_nLeftMargin = m_nValue;
                     m_bLeftMarginValid = true;
                 }
+                createGrabBag("start");
             break;
             case NS_ooxml::LN_CT_TblCellMar_left:
             case NS_ooxml::LN_CT_TcMar_left:
                 m_nLeftMargin = m_nValue;
                 m_bLeftMarginValid = true;
+                createGrabBag("left");
             break;
             case NS_ooxml::LN_CT_TblCellMar_bottom:
             case NS_ooxml::LN_CT_TcMar_bottom:
                 m_nBottomMargin = m_nValue;
                 m_bBottomMarginValid = true;
+                createGrabBag("bottom");
             break;
             case NS_ooxml::LN_CT_TblCellMar_end:
                 if( rtl )
@@ -112,11 +144,13 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
                     m_nRightMargin = m_nValue;
                     m_bRightMarginValid = true;
                 }
+                createGrabBag("end");
             break;
             case NS_ooxml::LN_CT_TblCellMar_right:
             case NS_ooxml::LN_CT_TcMar_right:
                 m_nRightMargin = m_nValue;
                 m_bRightMarginValid = true;
+                createGrabBag("right");
             break;
             default:
                 OSL_FAIL( "unknown sprm");
@@ -124,6 +158,26 @@ void CellMarginHandler::lcl_sprm(Sprm & rSprm)
     }
     m_nValue = 0;
 }
+
+void CellMarginHandler::enableInteropGrabBag(OUString aName)
+{
+    m_aInteropGrabBagName = aName;
+}
+
+beans::PropertyValue CellMarginHandler::getInteropGrabBag()
+{
+    beans::PropertyValue aRet;
+    aRet.Name = m_aInteropGrabBagName;
+
+    uno::Sequence<beans::PropertyValue> aSeq(m_aInteropGrabBag.size());
+    beans::PropertyValue* pSeq = aSeq.getArray();
+    for (std::vector<beans::PropertyValue>::iterator i = m_aInteropGrabBag.begin(); i != m_aInteropGrabBag.end(); ++i)
+        *pSeq++ = *i;
+
+    aRet.Value = uno::makeAny(aSeq);
+    return aRet;
+}
+
 } //namespace dmapper
 } //namespace writerfilter
 
diff --git a/writerfilter/source/dmapper/CellMarginHandler.hxx b/writerfilter/source/dmapper/CellMarginHandler.hxx
index 17b770f..abde168 100644
--- a/writerfilter/source/dmapper/CellMarginHandler.hxx
+++ b/writerfilter/source/dmapper/CellMarginHandler.hxx
@@ -22,6 +22,7 @@
 #include <WriterFilterDllApi.hxx>
 #include <resourcemodel/LoggedResources.hxx>
 #include <boost/shared_ptr.hpp>
+#include <com/sun/star/beans/PropertyValue.hpp>
 
 namespace writerfilter {
 namespace dmapper
@@ -30,12 +31,19 @@ class TablePropertyMap;
 class WRITERFILTER_DLLPRIVATE CellMarginHandler : public LoggedProperties
 {
 private:
-    sal_Int32   m_nValue;
+    sal_Int32   m_nValue; ///< Converted value.
+    sal_Int32   m_nWidth; ///< Original value.
+    sal_Int32   m_nType; ///< Unit of the value (dxa, etc).
+
+    OUString m_aInteropGrabBagName;
+    std::vector<beans::PropertyValue> m_aInteropGrabBag;
 
     // Properties
     virtual void lcl_attribute(Id Name, Value & val);
     virtual void lcl_sprm(Sprm & sprm);
 
+    void createGrabBag(OUString aName);
+
 public:
     sal_Int32   m_nLeftMargin;
     bool        m_bLeftMarginValid;
@@ -52,6 +60,9 @@ public:
 
     ::boost::shared_ptr<TablePropertyMap>            getProperties();
 
+    void enableInteropGrabBag(OUString aName);
+    beans::PropertyValue getInteropGrabBag();
+
 };
 typedef boost::shared_ptr< CellMarginHandler >          CellMarginHandlerPtr;
 }}
diff --git a/writerfilter/source/dmapper/MeasureHandler.cxx b/writerfilter/source/dmapper/MeasureHandler.cxx
index 57ffec5..0875a89 100644
--- a/writerfilter/source/dmapper/MeasureHandler.cxx
+++ b/writerfilter/source/dmapper/MeasureHandler.cxx
@@ -84,6 +84,13 @@ void MeasureHandler::lcl_attribute(Id rName, Value & rVal)
         case NS_rtf::LN_preferredWidth:
         case NS_ooxml::LN_CT_TblWidth_w:// = 90667;
             m_nMeasureValue = nIntValue;
+            if (!m_aInteropGrabBagName.isEmpty())
+            {
+                beans::PropertyValue aValue;
+                aValue.Name = "w";
+                aValue.Value = uno::makeAny(nIntValue);
+                m_aInteropGrabBag.push_back(aValue);
+            }
         break;
         case NS_ooxml::LN_CT_Height_val: // 90665 -- a string value
         {
diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
index cf3a15a..3749a87 100644
--- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx
+++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx
@@ -242,7 +242,11 @@ namespace dmapper {
                 if( pProperties.get())
                 {
                     CellMarginHandlerPtr pCellMarginHandler( new CellMarginHandler );
+                    if (m_pCurrentInteropGrabBag)
+                        pCellMarginHandler->enableInteropGrabBag("tblCellMar");
                     pProperties->resolve( *pCellMarginHandler );
+                    if (m_pCurrentInteropGrabBag)
+                        m_pCurrentInteropGrabBag->push_back(pCellMarginHandler->getInteropGrabBag());
                     TablePropertyMapPtr pMarginProps( new TablePropertyMap );
                     if( pCellMarginHandler->m_bTopMarginValid )
                         pMarginProps->setValue( TablePropertyMap::CELL_MAR_TOP, pCellMarginHandler->m_nTopMargin );


More information about the Libreoffice-commits mailing list