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

Miklos Vajna vmiklos at collabora.co.uk
Wed Aug 6 05:53:28 PDT 2014


 sw/source/filter/ww8/docxattributeoutput.cxx      |    3 +
 writerfilter/source/dmapper/DomainMapper.cxx      |   59 ++++++++++++++++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.hxx |    2 
 writerfilter/source/dmapper/PropertyIds.cxx       |    2 
 writerfilter/source/dmapper/PropertyIds.hxx       |    2 
 writerfilter/source/dmapper/PropertyMap.cxx       |   53 ++++++++++++++++++-
 writerfilter/source/dmapper/PropertyMap.hxx       |    1 
 7 files changed, 117 insertions(+), 5 deletions(-)

New commits:
commit 942f1ed93c4e26e883b7d1d3ee6b729ef72cec67
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Aug 6 13:20:19 2014 +0200

    DOCX import: handle <w:cnfStyle> cell property
    
    Change-Id: I849daf0ddee370775fda73e04739e69acbc64246

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 051b6c1..6ab6bde 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3290,6 +3290,9 @@ void DocxAttributeOutput::TableBackgrounds( ww8::WW8TableNodeInfoInner::Pointer_
 
         for( aGrabBagElement = aGrabBag.begin(); aGrabBagElement != aGrabBag.end(); ++aGrabBagElement )
         {
+            if (!aGrabBagElement->second.has<OUString>())
+                continue;
+
             OString sValue = OUStringToOString( aGrabBagElement->second.get<OUString>(), RTL_TEXTENCODING_UTF8 );
             if( aGrabBagElement->first == "themeFill")
                 AddToAttrList( aAttrList, FSNS( XML_w, XML_themeFill ), sValue.getStr() );
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c89395f..7864dd9 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2504,6 +2504,18 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
         }
     }
     break;
+    case NS_ooxml::LN_CT_TcPrBase_cnfStyle:
+    {
+        m_pImpl->enableInteropGrabBag("cnfStyle");
+        resourcemodel::resolveSprmProps(*this, rSprm);
+
+        TablePropertyMapPtr pPropMap(new TablePropertyMap());
+        pPropMap->Insert(PROP_CELL_CNF_STYLE, uno::makeAny(uno::makeAny(m_pImpl->m_aInteropGrabBag.getAsConstList())), true, CELL_GRAB_BAG);
+        m_pImpl->getTableManager().cellProps(pPropMap);
+
+        m_pImpl->disableInteropGrabBag();
+    }
+    break;
     case NS_ooxml::LN_CT_PPrBase_cnfStyle:
     {
         m_pImpl->enableInteropGrabBag("cnfStyle");
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 6d236c1..c12e97a 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -397,6 +397,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break;
             case META_PROP_TABLE_LOOK: sName = "TableStyleLook"; break;
             case PROP_PARA_CNF_STYLE: sName = "ParaCnfStyle"; break;
+            case PROP_CELL_CNF_STYLE: sName = "CellCnfStyle"; 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 5814c34..0ff6ee3 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -369,6 +369,7 @@ enum PropertyIds
         ,PROP_PARA_SDT_END_BEFORE
         ,META_PROP_TABLE_LOOK
         ,PROP_PARA_CNF_STYLE
+        ,PROP_CELL_CNF_STYLE
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index ab1d48d..62c5ba6 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -66,30 +66,50 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
     {
         size_t nCharGrabBag = 0;
         size_t nParaGrabBag = 0;
+        size_t nCellGrabBag = 0;
+        size_t nCellGrabBagSaved = 0; // How many entries do we save from the returned sequence.
         for (MapIterator i = m_vMap.begin(); i != m_vMap.end(); ++i)
         {
             if ( i->second.getGrabBagType() == CHAR_GRAB_BAG )
                 nCharGrabBag++;
             else if ( i->second.getGrabBagType() == PARA_GRAB_BAG )
                 nParaGrabBag++;
+            else if ( i->second.getGrabBagType() == CELL_GRAB_BAG )
+            {
+                nCellGrabBag++;
+                nCellGrabBagSaved++;
+            }
+            else if ( i->first == PROP_CELL_INTEROP_GRAB_BAG)
+            {
+                uno::Sequence<beans::PropertyValue> aSeq;
+                i->second.getValue() >>= aSeq;
+                nCellGrabBag += aSeq.getLength();
+                nCellGrabBagSaved++;
+            }
         }
 
         // In case there are properties to be grab-bagged and we can have a char grab-bag, allocate one slot for it.
         size_t nCharGrabBagSize = 0;
         if (bCharGrabBag)
             nCharGrabBagSize = nCharGrabBag ? 1 : 0;
+        size_t nParaGrabBagSize = nParaGrabBag ? 1 : 0;
+        size_t nCellGrabBagSize = nCellGrabBag ? 1 : 0;
 
         // If there are any grab bag properties, we need one slot for them.
         m_aValues.realloc( m_vMap.size() - nCharGrabBag + nCharGrabBagSize
-                                  - nParaGrabBag + (nParaGrabBag ? 1 : 0));
+                                  - nParaGrabBag + nParaGrabBagSize
+                                  - nCellGrabBagSaved + nCellGrabBagSize);
         ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray();
         uno::Sequence<beans::PropertyValue> aCharGrabBagValues(nCharGrabBag);
         uno::Sequence<beans::PropertyValue> aParaGrabBagValues(nParaGrabBag);
+        uno::Sequence<beans::PropertyValue> aCellGrabBagValues(nCellGrabBag);
         beans::PropertyValue* pCharGrabBagValues = aCharGrabBagValues.getArray();
         beans::PropertyValue* pParaGrabBagValues = aParaGrabBagValues.getArray();
+        beans::PropertyValue* pCellGrabBagValues = aCellGrabBagValues.getArray();
         //style names have to be the first elements within the property sequence
         //otherwise they will overwrite 'hard' attributes
         sal_Int32 nValue = 0;
+        sal_Int32 nCellGrabBagValue = 0;
         sal_Int32 nParaGrabBagValue = 0;
         sal_Int32 nCharGrabBagValue = 0;
         PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
@@ -135,11 +155,30 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
                     pParaGrabBagValues[nParaGrabBagValue].Value = aMapIter->second.getValue();
                     ++nParaGrabBagValue;
                 }
+                else if ( aMapIter->second.getGrabBagType() == CELL_GRAB_BAG )
+                {
+                    pCellGrabBagValues[nCellGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first );
+                    pCellGrabBagValues[nCellGrabBagValue].Value = aMapIter->second.getValue();
+                    ++nCellGrabBagValue;
+                }
                 else
                 {
-                    pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first );
-                    pValues[nValue].Value = aMapIter->second.getValue();
-                    ++nValue;
+                    if (aMapIter->first == PROP_CELL_INTEROP_GRAB_BAG)
+                    {
+                        uno::Sequence<beans::PropertyValue> aSeq;
+                        aMapIter->second.getValue() >>= aSeq;
+                        for (sal_Int32 i = 0; i < aSeq.getLength(); ++i)
+                        {
+                            pCellGrabBagValues[nCellGrabBagValue] = aSeq[i];
+                            ++nCellGrabBagValue;
+                        }
+                    }
+                    else
+                    {
+                        pValues[nValue].Name = rPropNameSupplier.GetName( aMapIter->first );
+                        pValues[nValue].Value = aMapIter->second.getValue();
+                        ++nValue;
+                    }
                 }
             }
         }
@@ -155,6 +194,12 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharG
             pValues[nValue].Value = uno::makeAny(aParaGrabBagValues);
             ++nValue;
         }
+        if (nCellGrabBag)
+        {
+            pValues[nValue].Name = "CellInteropGrabBag";
+            pValues[nValue].Value = uno::makeAny(aCellGrabBagValues);
+            ++nValue;
+        }
     }
     return m_aValues;
 }
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index c9f78aa..53f306e 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -68,6 +68,7 @@ enum BorderPosition
 enum GrabBagType
 {
     NO_GRAB_BAG,
+    CELL_GRAB_BAG,
     PARA_GRAB_BAG,
     CHAR_GRAB_BAG
 };
commit 5e2081fb7c49edd46f2981fbc230982e6a8b87b5
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Aug 6 12:18:59 2014 +0200

    DOCX import: handle <w:cnfStyle> paragraph property
    
    Change-Id: I47d9dab17d4891d05cf7497e53026bc801f2726b

diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 90dbf14..c89395f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -971,6 +971,45 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
         case NS_ooxml::LN_CT_PTab_relativeTo:
         case NS_ooxml::LN_CT_PTab_alignment:
             break;
+        case NS_ooxml::LN_CT_Cnf_lastRowLastColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRowLastColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_lastRowFirstColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRowFirstColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_firstRowLastColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRowLastColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_oddHBand:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "oddHBand", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_firstRowFirstColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRowFirstColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_evenVBand:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "evenVBand", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_evenHBand:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "evenHBand", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_lastColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_firstColumn:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstColumn", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_oddVBand:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "oddVBand", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_lastRow:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "lastRow", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_firstRow:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "firstRow", OUString::number(nIntValue));
+            break;
+        case NS_ooxml::LN_CT_Cnf_val:
+            m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "val", sStringValue);
+            break;
         default:
             {
 #if OSL_DEBUG_LEVEL > 0
@@ -2465,6 +2504,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
         }
     }
     break;
+    case NS_ooxml::LN_CT_PPrBase_cnfStyle:
+    {
+        m_pImpl->enableInteropGrabBag("cnfStyle");
+        resourcemodel::resolveSprmProps(*this, rSprm);
+        rContext->Insert(PROP_PARA_CNF_STYLE, uno::makeAny(m_pImpl->m_aInteropGrabBag.getAsConstList()), true, PARA_GRAB_BAG);
+        m_pImpl->disableInteropGrabBag();
+    }
+    break;
     default:
         {
 #ifdef DEBUG_DOMAINMAPPER
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index e0d8259..98d6b0c 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -809,7 +809,7 @@ public:
     OUString m_aInteropGrabBagName;
 
     /// A toplevel dmapper grabbag, like 'pPr'.
-    std::vector<css::beans::PropertyValue> m_aInteropGrabBag;
+    comphelper::SequenceAsVector<css::beans::PropertyValue> m_aInteropGrabBag;
 
     /// A sub-grabbag of m_aInteropGrabBag, like 'spacing'.
     std::vector<css::beans::PropertyValue> m_aSubInteropGrabBag;
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index af8b1b3..6d236c1 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -396,6 +396,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_SDT_END_BEFORE: sName = "SdtEndBefore"; break;
             case PROP_PARA_SDT_END_BEFORE: sName = "ParaSdtEndBefore"; break;
             case META_PROP_TABLE_LOOK: sName = "TableStyleLook"; break;
+            case PROP_PARA_CNF_STYLE: sName = "ParaCnfStyle"; 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 c3cea17..5814c34 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -368,6 +368,7 @@ enum PropertyIds
         ,PROP_SDT_END_BEFORE
         ,PROP_PARA_SDT_END_BEFORE
         ,META_PROP_TABLE_LOOK
+        ,PROP_PARA_CNF_STYLE
     };
 struct PropertyNameSupplier_Impl;
 class PropertyNameSupplier


More information about the Libreoffice-commits mailing list