diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-04 18:14:25 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2014-08-04 18:33:02 +0200 |
commit | 7803a5d726890f3724548a7ab95741a75a19dc7e (patch) | |
tree | 1f47cebdbd51f07656a339d0ee2301c4dcb96baa | |
parent | 0ee728634d29aa3e77139491d4eac2b2962ee418 (diff) |
DOCX import: handle all attributes of CT_TblLook
Change-Id: I3bbd65af4f52ce28e2962a1b3e0c7f1c348f3a01
6 files changed, 55 insertions, 23 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 33b6a95d237e..f80d6c01eea2 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -2458,7 +2458,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext ) { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); if (pProperties.get()) + { pProperties->resolve(*this); + m_pImpl->getTableManager().finishTableLook(); + } } break; default: diff --git a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx index 0b91ef6dd331..8a121fafabd1 100644 --- a/writerfilter/source/dmapper/DomainMapperTableHandler.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableHandler.cxx @@ -313,8 +313,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo sal_Int32 nTableWidth = 0; sal_Int32 nTableWidthType = text::SizeType::FIX; - uno::Sequence< beans::PropertyValue > aGrabBag( 6 ); - sal_Int32 nGrabBagSize = 0; + comphelper::SequenceAsHashMap aGrabBag; if (0 != m_rDMapper_Impl.getTableManager().getCurrentTableRealPosition()) { @@ -352,9 +351,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo aGrabBagTS[9].Name = "vertAnchor"; aGrabBagTS[9].Value = uno::makeAny( pTablePositions->getVertAnchor() ); - aGrabBag[nGrabBagSize].Name = "TablePosition"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( aGrabBagTS ); - nGrabBagSize++; + aGrabBag["TablePosition"] = uno::makeAny( aGrabBagTS ); } boost::optional<PropertyMap::Property> aTableStyleVal = m_aTableProperties->getProperty(META_PROP_TABLE_STYLE_NAME); @@ -368,9 +365,7 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo pTableStyle = dynamic_cast<TableStyleSheetEntry*>( pStyleSheet.get( ) ); m_aTableProperties->Erase( aTableStyleVal->first ); - aGrabBag[nGrabBagSize].Name = "TableStyleName"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( sTableStyleName ); - nGrabBagSize++; + aGrabBag["TableStyleName"] = uno::makeAny( sTableStyleName ); if( pStyleSheet ) { @@ -386,27 +381,19 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo TableInfo rStyleInfo; if (lcl_extractTableBorderProperty(pMergedProperties, PROP_TOP_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[nGrabBagSize].Name = "TableStyleTopBorder"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); - nGrabBagSize++; + aGrabBag["TableStyleTopBorder"] = uno::makeAny( aBorderLine ); } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_BOTTOM_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[nGrabBagSize].Name = "TableStyleBottomBorder"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); - nGrabBagSize++; + aGrabBag["TableStyleBottomBorder"] = uno::makeAny( aBorderLine ); } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_LEFT_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[nGrabBagSize].Name = "TableStyleLeftBorder"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); - nGrabBagSize++; + aGrabBag["TableStyleLeftBorder"] = uno::makeAny( aBorderLine ); } if (lcl_extractTableBorderProperty(pMergedProperties, PROP_RIGHT_BORDER, rStyleInfo, aBorderLine)) { - aGrabBag[nGrabBagSize].Name = "TableStyleRightBorder"; - aGrabBag[nGrabBagSize].Value = uno::makeAny( aBorderLine ); - nGrabBagSize++; + aGrabBag["TableStyleRightBorder"] = uno::makeAny( aBorderLine ); } #ifdef DEBUG_DOMAINMAPPER @@ -426,6 +413,15 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo } } + // This is the one preserving just all the table look attributes. + boost::optional<PropertyMap::Property> oTableLook = m_aTableProperties->getProperty(META_PROP_TABLE_LOOK); + if (oTableLook) + { + aGrabBag["TableStyleLook"] = oTableLook->second; + m_aTableProperties->Erase(oTableLook->first); + } + + // This is just the "val" attribute's numeric value. const boost::optional<PropertyMap::Property> aTblLook = m_aTableProperties->getProperty(PROP_TBL_LOOK); if(aTblLook) { @@ -442,10 +438,9 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo dmapper_logger->endElement(); #endif - if( nGrabBagSize > 0 ) + if (!aGrabBag.empty()) { - aGrabBag.realloc( nGrabBagSize ); - m_aTableProperties->Insert( PROP_TABLE_INTEROP_GRAB_BAG, uno::makeAny( aGrabBag ) ); + m_aTableProperties->Insert( PROP_TABLE_INTEROP_GRAB_BAG, uno::makeAny( aGrabBag.getAsConstPropertyValueList() ) ); } m_aTableProperties->getValue( TablePropertyMap::GAP_HALF, nGapHalf ); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index d5a36a966a27..d5b60bdad9e3 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -85,8 +85,27 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue) TablePropertyMapPtr pPropMap(new TablePropertyMap()); pPropMap->Insert(PROP_TBL_LOOK, uno::makeAny(rValue.getInt())); insertTableProps(pPropMap); + m_aTableLook["val"] = uno::makeAny(rValue.getInt()); } break; + case NS_ooxml::LN_CT_TblLook_noVBand: + m_aTableLook["noVBand"] = uno::makeAny(rValue.getInt()); + break; + case NS_ooxml::LN_CT_TblLook_noHBand: + m_aTableLook["noHBand"] = uno::makeAny(rValue.getInt()); + break; + case NS_ooxml::LN_CT_TblLook_lastColumn: + m_aTableLook["lastColumn"] = uno::makeAny(rValue.getInt()); + break; + case NS_ooxml::LN_CT_TblLook_lastRow: + m_aTableLook["lastRow"] = uno::makeAny(rValue.getInt()); + break; + case NS_ooxml::LN_CT_TblLook_firstColumn: + m_aTableLook["firstColumn"] = uno::makeAny(rValue.getInt()); + break; + case NS_ooxml::LN_CT_TblLook_firstRow: + m_aTableLook["firstRow"] = uno::makeAny(rValue.getInt()); + break; default: bRet = false; } @@ -94,6 +113,14 @@ bool DomainMapperTableManager::attribute(Id nName, Value& rValue) return bRet; } +void DomainMapperTableManager::finishTableLook() +{ + TablePropertyMapPtr pPropMap(new TablePropertyMap()); + pPropMap->Insert(META_PROP_TABLE_LOOK, uno::makeAny(m_aTableLook.getAsConstPropertyValueList())); + m_aTableLook.clear(); + insertTableProps(pPropMap); +} + bool DomainMapperTableManager::sprm(Sprm & rSprm) { #ifdef DEBUG_DOMAINMAPPER diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.hxx b/writerfilter/source/dmapper/DomainMapperTableManager.hxx index 24145bd2f8fb..3f53e93c0259 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.hxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.hxx @@ -27,6 +27,7 @@ #include "StyleSheetTable.hxx" #include <com/sun/star/text/XTextRange.hpp> #include <vector> +#include <comphelper/sequenceashashmap.hxx> namespace writerfilter { namespace dmapper { @@ -45,6 +46,8 @@ class DomainMapperTableManager : public DomainMapperTableManager_Base_t sal_Int32 m_nTableWidth; //might be set directly or has to be calculated from the column positions bool m_bOOXML; OUString m_sTableStyleName; + /// Grab-bag of table look attributes for preserving. + comphelper::SequenceAsHashMap m_aTableLook; std::vector< TablePositionHandlerPtr > m_aTablePositions; std::vector< TablePositionHandlerPtr > m_aTmpPosition; ///< Temporarily stores the position to compare it later std::vector< TablePropertyMapPtr > m_aTmpTableProperties; ///< Temporarily stores the table properties until end of row @@ -94,6 +97,8 @@ public: IntVectorPtr getCurrentCellWidths( ); const OUString& getTableStyleName() const { return m_sTableStyleName; } + /// Turn the attributes collected so far in m_aTableLook into a property and clear the container. + void finishTableLook(); const com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue> getCurrentTablePosition(); TablePositionHandler* getCurrentTableRealPosition(); diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index 496ea9d5dd85..af8b1b3a2927 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -395,6 +395,7 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_CELL_DIRECTION: sName = "CellDirection"; break; 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; } ::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 e7cb0e0c4cd6..c3cea173c289 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -367,6 +367,7 @@ enum PropertyIds ,PROP_CELL_DIRECTION ,PROP_SDT_END_BEFORE ,PROP_PARA_SDT_END_BEFORE + ,META_PROP_TABLE_LOOK }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier |