diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-06 13:20:19 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-06 14:52:57 +0200 |
commit | 942f1ed93c4e26e883b7d1d3ee6b729ef72cec67 (patch) | |
tree | 73da13b01d41bba0f58f48230a3967b215da98b7 | |
parent | 5e2081fb7c49edd46f2981fbc230982e6a8b87b5 (diff) |
DOCX import: handle <w:cnfStyle> cell property
Change-Id: I849daf0ddee370775fda73e04739e69acbc64246
-rw-r--r-- | sw/source/filter/ww8/docxattributeoutput.cxx | 3 | ||||
-rw-r--r-- | writerfilter/source/dmapper/DomainMapper.cxx | 12 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.cxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyIds.hxx | 1 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.cxx | 53 | ||||
-rw-r--r-- | writerfilter/source/dmapper/PropertyMap.hxx | 1 |
6 files changed, 67 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 051b6c18eee8..6ab6bde1ef78 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 c89395f672d4..7864dd9acdd0 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 6d236c155be7..c12e97a64370 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 5814c34f295d..0ff6ee3ccab8 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 ab1d48d52ebc..62c5ba64dd09 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 c9f78aadfb89..53f306ec0c2b 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 }; |