writerfilter/source/dmapper/CellColorHandler.cxx | 84 +++++++++++++++++ writerfilter/source/dmapper/CellColorHandler.hxx | 10 ++ writerfilter/source/dmapper/StyleSheetTable.cxx | 56 ++++++++++- writerfilter/source/dmapper/TablePropertiesHandler.cxx | 23 ++++ 4 files changed, 168 insertions(+), 5 deletions(-)
New commits: commit ad206808e98076c6b2612c293770af60dc0ade19 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 25 16:32:21 2013 +0200 writerfilter: save table styles' tcPr to InteropGrabBag Change-Id: I8602f6225cc44df445f1b4af1c48b87fade25458 diff --git a/writerfilter/source/dmapper/CellColorHandler.cxx b/writerfilter/source/dmapper/CellColorHandler.cxx index d9acbd6..1a360f1 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 27f18fd..7904a9d 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 10ef553..3a5127f 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 5f1c37b..e2b5c3b 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()); } } commit 3c38e8f8ac99fe3a28e41751eb48d4cff764389f Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Oct 25 15:30:53 2013 +0200 writerfilter: store some of the values directly in TablePropertiesHandler During table style import, TablePropertiesHandler may decide to not handle an sprm, then the caller will try the next handler. When we do this, instead of just returning, still store the values in InteropGrabBag (if necessary), as they logically belong here. Change-Id: Idd052854cbef8046f0a24556cfe1536d2646f94e diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index f53e129..10ef553 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -487,6 +487,14 @@ void StyleSheetTable::lcl_attribute(Id Name, Value & val) } break; case NS_ooxml::LN_CT_Style_customStyle: + if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE) + { + TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get()); + beans::PropertyValue aValue; + aValue.Name = "customStyle"; + aValue.Value = uno::makeAny(sal_Bool(nIntValue != 0)); + pTableEntry->AppendInteropGrabBag(aValue); + } break; case NS_ooxml::LN_CT_Style_styleId: m_pImpl->m_pCurrentEntry->sStyleIdentifierI = sValue; @@ -560,6 +568,14 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) break; case NS_ooxml::LN_CT_Style_basedOn: m_pImpl->m_pCurrentEntry->sBaseStyleIdentifier = 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 = "basedOn"; + aValue.Value = uno::makeAny(sStringValue); + pTableEntry->AppendInteropGrabBag(aValue); + } break; case NS_ooxml::LN_CT_Style_next: m_pImpl->m_pCurrentEntry->sNextStyleIdentifier = sStringValue; @@ -568,18 +584,37 @@ void StyleSheetTable::lcl_sprm(Sprm & rSprm) case NS_ooxml::LN_CT_Style_link: case NS_ooxml::LN_CT_Style_autoRedefine: case NS_ooxml::LN_CT_Style_hidden: - case NS_ooxml::LN_CT_Style_uiPriority: case NS_ooxml::LN_CT_Style_semiHidden: case NS_ooxml::LN_CT_Style_unhideWhenUsed: - case NS_ooxml::LN_CT_Style_qFormat: case NS_ooxml::LN_CT_Style_locked: 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_rsid: case NS_ooxml::LN_CT_Style_trPr: case NS_ooxml::LN_CT_Style_tcPr: break; + case NS_ooxml::LN_CT_Style_rsid: + case NS_ooxml::LN_CT_Style_qFormat: + case NS_ooxml::LN_CT_Style_uiPriority: + if(m_pImpl->m_pCurrentEntry->nStyleTypeCode == STYLE_TYPE_TABLE) + { + TableStyleSheetEntry* pTableEntry = static_cast<TableStyleSheetEntry *>(m_pImpl->m_pCurrentEntry.get()); + beans::PropertyValue aValue; + if (nSprmId == NS_ooxml::LN_CT_Style_rsid) + { + aValue.Name = "rsid"; + aValue.Value = uno::makeAny(nIntValue); + } + else if (nSprmId == NS_ooxml::LN_CT_Style_qFormat) + aValue.Name = "qFormat"; + else + { + aValue.Name = "uiPriority"; + aValue.Value = uno::makeAny(nIntValue); + } + pTableEntry->AppendInteropGrabBag(aValue); + } + break; case NS_ooxml::LN_CT_Style_tblPr: //contains table properties case NS_ooxml::LN_CT_Style_tblStylePr: //contains to table properties case NS_ooxml::LN_CT_TblPrBase_tblInd: //table properties - at least width value and type diff --git a/writerfilter/source/dmapper/TablePropertiesHandler.cxx b/writerfilter/source/dmapper/TablePropertiesHandler.cxx index 3749a87..5f1c37b 100644 --- a/writerfilter/source/dmapper/TablePropertiesHandler.cxx +++ b/writerfilter/source/dmapper/TablePropertiesHandler.cxx @@ -278,7 +278,24 @@ namespace dmapper { } } break; - default: bRet = false; + default: + // Not handled here, give the next handler a chance. + bRet = false; + // However, these logically belong here, so save the value if necessary. + switch (nSprmId) + { + case NS_ooxml::LN_CT_TblPrBase_tblStyleRowBandSize: + case NS_ooxml::LN_CT_TblPrBase_tblStyleColBandSize: + if (m_pCurrentInteropGrabBag) + { + beans::PropertyValue aValue; + aValue.Name = (nSprmId == NS_ooxml::LN_CT_TblPrBase_tblStyleRowBandSize ? OUString("tblStyleRowBandSize") : OUString("tblStyleColBandSize")); + aValue.Value = uno::makeAny(nIntValue); + m_pCurrentInteropGrabBag->push_back(aValue); + } + break; + } + break; } #ifdef DEBUG_DOMAINMAPPER _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits