diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-10-25 16:32:21 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-10-25 16:57:08 +0200 |
commit | ad206808e98076c6b2612c293770af60dc0ade19 (patch) | |
tree | a0218a82750e422fb3c1de581c74cbeea718b42f | |
parent | 3c38e8f8ac99fe3a28e41751eb48d4cff764389f (diff) |
writerfilter: save table styles' tcPr to InteropGrabBag
Change-Id: I8602f6225cc44df445f1b4af1c48b87fade25458
-rw-r--r-- | writerfilter/source/dmapper/CellColorHandler.cxx | 84 | ||||
-rw-r--r-- | writerfilter/source/dmapper/CellColorHandler.hxx | 10 | ||||
-rw-r--r-- | writerfilter/source/dmapper/StyleSheetTable.cxx | 15 | ||||
-rw-r--r-- | writerfilter/source/dmapper/TablePropertiesHandler.cxx | 4 |
4 files changed, 112 insertions, 1 deletions
diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index d9acbd6c2700..1a360f164a3f 100644 --- a/writerfilter/source/dmapper/CellColorHandler.cxx +++ b/writerfilter/source/dmapper/CellColorHandler.cxx @@ -47,6 +47,56 @@ CellColorHandler::~CellColorHandler() { } +// ST_Shd strings are converted to integers by the tokenizer, store strings in +// the InteropGrabBag +uno::Any lcl_ConvertShd(sal_Int32 nIntValue) +{ + OUString aRet; + // This should be in sync with the ST_Shd list in ooxml's model.xml. + switch (nIntValue) + { + case 0: aRet = "clear"; break; + case 1: aRet = "solid"; break; + case 2: aRet = "pct5"; break; + case 3: aRet = "pct10"; break; + case 4: aRet = "pct20"; break; + case 5: aRet = "pct25"; break; + case 6: aRet = "pct30"; break; + case 7: aRet = "pct40"; break; + case 8: aRet = "pct50"; break; + case 9: aRet = "pct60"; break; + case 10: aRet = "pct70"; break; + case 11: aRet = "pct75"; break; + case 12: aRet = "pct80"; break; + case 13: aRet = "pct90"; break; + case 14: aRet = "horzStripe"; break; + case 15: aRet = "vertStripe"; break; + case 17: aRet = "reverseDiagStripe"; break; + case 16: aRet = "diagStripe"; break; + case 18: aRet = "horzCross"; break; + case 19: aRet = "diagCross"; break; + case 20: aRet = "thinHorzStripe"; break; + case 21: aRet = "thinVertStripe"; break; + case 23: aRet = "thinReverseDiagStripe"; break; + case 22: aRet = "thinDiagStripe"; break; + case 24: aRet = "thinHorzCross"; break; + case 25: aRet = "thinDiagCross"; break; + case 37: aRet = "pct12"; break; + case 38: aRet = "pct15"; break; + case 43: aRet = "pct35"; break; + case 44: aRet = "pct37"; break; + case 46: aRet = "pct45"; break; + case 49: aRet = "pct55"; break; + case 51: aRet = "pct62"; break; + case 52: aRet = "pct65"; break; + case 57: aRet = "pct85"; break; + case 58: aRet = "pct87"; break; + case 60: aRet = "pct95"; break; + case 65535: aRet = "nil"; break; + } + return uno::makeAny(aRet); +} + void CellColorHandler::lcl_attribute(Id rName, Value & rVal) { sal_Int32 nIntValue = rVal.getInt(); @@ -60,17 +110,20 @@ void CellColorHandler::lcl_attribute(Id rName, Value & rVal) break; case NS_ooxml::LN_CT_Shd_val: { + createGrabBag("val", lcl_ConvertShd(nIntValue)); //might be clear, pct5...90, some hatch types //TODO: The values need symbolic names! m_nShadingPattern = nIntValue; //clear == 0, solid: 1, pct5: 2, pct50:8, pct95: x3c, horzStripe:0x0e, thinVertStripe: 0x15 } break; case NS_ooxml::LN_CT_Shd_fill: + createGrabBag("fill", uno::makeAny(nIntValue)); if( nIntValue == OOXML_COLOR_AUTO ) nIntValue = 0xffffff; //fill color auto means white m_nFillColor = nIntValue; break; case NS_ooxml::LN_CT_Shd_color: + createGrabBag("color", uno::makeAny(nIntValue)); if( nIntValue == OOXML_COLOR_AUTO ) nIntValue = 0; //shading color auto means black //color of the shading @@ -271,6 +324,37 @@ TablePropertyMapPtr CellColorHandler::getProperties() : PROP_CHAR_BACK_COLOR, uno::makeAny( nApplyColor )); return pPropertyMap; } + +void CellColorHandler::createGrabBag(OUString aName, uno::Any aAny) +{ + if (m_aInteropGrabBagName.isEmpty()) + return; + + beans::PropertyValue aValue; + aValue.Name = aName; + aValue.Value = aAny; + m_aInteropGrabBag.push_back(aValue); +} + +void CellColorHandler::enableInteropGrabBag(OUString aName) +{ + m_aInteropGrabBagName = aName; +} + +beans::PropertyValue CellColorHandler::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/CellColorHandler.hxx b/writerfilter/source/dmapper/CellColorHandler.hxx index 27f18fd0bbe5..7904a9deccdf 100644 --- a/writerfilter/source/dmapper/CellColorHandler.hxx +++ b/writerfilter/source/dmapper/CellColorHandler.hxx @@ -23,6 +23,8 @@ #include <resourcemodel/LoggedResources.hxx> #include <boost/shared_ptr.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + namespace writerfilter { namespace dmapper { @@ -37,10 +39,15 @@ private: sal_Int32 m_nFillColor; OutputFormat m_OutputFormat; + 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, uno::Any aValue); + public: CellColorHandler( ); virtual ~CellColorHandler(); @@ -48,6 +55,9 @@ public: ::boost::shared_ptr<TablePropertyMap> getProperties(); void setOutputFormat( OutputFormat format ) { m_OutputFormat = format; } + + void enableInteropGrabBag(OUString aName); + beans::PropertyValue getInteropGrabBag(); }; typedef boost::shared_ptr< CellColorHandler > CellColorHandlerPtr; }} diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 10ef55375085..3a5127faaa23 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -590,8 +590,21 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) case NS_ooxml::LN_CT_Style_personal: case NS_ooxml::LN_CT_Style_personalCompose: case NS_ooxml::LN_CT_Style_personalReply: - case NS_ooxml::LN_CT_Style_trPr: + break; case NS_ooxml::LN_CT_Style_tcPr: + { + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if( pProperties.get() && m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE) + { + TblStylePrHandlerPtr pTblStylePrHandler(new TblStylePrHandler(m_pImpl->m_rDMapper)); + pProperties->resolve(*pTblStylePrHandler); + StyleSheetEntry* pEntry = m_pImpl->m_pCurrentEntry.get(); + TableStyleSheetEntry* pTableEntry = dynamic_cast<TableStyleSheetEntry*>(pEntry); + pTableEntry->AppendInteropGrabBag(pTblStylePrHandler->getInteropGrabBag("tcPr")); + } + } + break; + case NS_ooxml::LN_CT_Style_trPr: break; case NS_ooxml::LN_CT_Style_rsid: case NS_ooxml::LN_CT_Style_qFormat: diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx index 5f1c37bb4e6e..e2b5c3b3e74e 100644 --- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx +++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx @@ -228,7 +228,11 @@ namespace dmapper { if( pProperties.get()) { CellColorHandlerPtr pCellColorHandler( new CellColorHandler ); + if (m_pCurrentInteropGrabBag) + pCellColorHandler->enableInteropGrabBag("shd"); pProperties->resolve( *pCellColorHandler ); + if (m_pCurrentInteropGrabBag) + m_pCurrentInteropGrabBag->push_back(pCellColorHandler->getInteropGrabBag()); cellProps( pCellColorHandler->getProperties()); } } |