From deabda6b38417e4c7037c0d0274a4f81b338e552 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 20 Feb 2014 18:25:26 +0100 Subject: DOCX import: fix missing underline in comment text Regression from fb5ee5c9953635a423d3102b901e409d15800096 (sw: Add support for different grab bags at PropertyMap., 2013-11-29), PropertyMap::GetPropertyValues() assumed all XTextRange implementations support the new property, which is not true for at least editeng. Change-Id: Ib5657be522d30f203cecbbbae74d6594cef984fb --- writerfilter/source/dmapper/DomainMapper_Impl.cxx | 3 ++- writerfilter/source/dmapper/PropertyMap.cxx | 21 +++++++++++++++------ writerfilter/source/dmapper/PropertyMap.hxx | 2 +- 3 files changed, 18 insertions(+), 8 deletions(-) (limited to 'writerfilter') diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index d8237f302385..70b73201b713 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -1120,7 +1120,8 @@ void DomainMapper_Impl::appendTextPortion( const OUString& rString, PropertyMapP { try { - uno::Sequence< beans::PropertyValue > pValues = pPropertyMap->GetPropertyValues(); + // If we are in comments, then disable CharGrabBag, comment text doesn't support that. + uno::Sequence< beans::PropertyValue > pValues = pPropertyMap->GetPropertyValues(/*bCharGrabBag=*/!m_bIsInComments); sal_Int32 len = pValues.getLength(); if (m_bStartTOC || m_bStartIndex) diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index f90cb204ada1..19d8714168ae 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -60,7 +60,7 @@ PropertyMap::~PropertyMap() } -uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() +uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues(bool bCharGrabBag) { if(!m_aValues.getLength() && size()) { @@ -73,8 +73,14 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() else if ( i->second.getGrabBagType() == PARA_GRAB_BAG ) nParaGrabBag++; } + + // 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; + // If there are any grab bag properties, we need one slot for them. - m_aValues.realloc( size() - nCharGrabBag + (nCharGrabBag ? 1 : 0) + m_aValues.realloc( size() - nCharGrabBag + nCharGrabBagSize - nParaGrabBag + (nParaGrabBag ? 1 : 0)); ::com::sun::star::beans::PropertyValue* pValues = m_aValues.getArray(); uno::Sequence aCharGrabBagValues(nCharGrabBag); @@ -116,9 +122,12 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() { if ( aMapIter->second.getGrabBagType() == CHAR_GRAB_BAG ) { - pCharGrabBagValues[nCharGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first ); - pCharGrabBagValues[nCharGrabBagValue].Value = aMapIter->second.getValue(); - ++nCharGrabBagValue; + if (bCharGrabBag) + { + pCharGrabBagValues[nCharGrabBagValue].Name = rPropNameSupplier.GetName( aMapIter->first ); + pCharGrabBagValues[nCharGrabBagValue].Value = aMapIter->second.getValue(); + ++nCharGrabBagValue; + } } else if ( aMapIter->second.getGrabBagType() == PARA_GRAB_BAG ) { @@ -134,7 +143,7 @@ uno::Sequence< beans::PropertyValue > PropertyMap::GetPropertyValues() } } } - if (nCharGrabBag) + if (nCharGrabBag && bCharGrabBag) { pValues[nValue].Name = "CharInteropGrabBag"; pValues[nValue].Value = uno::makeAny(aCharGrabBagValues); diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index a9279f2307ab..8d9a32bd684b 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -112,7 +112,7 @@ public: PropertyMap(); virtual ~PropertyMap(); - ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetPropertyValues(); + ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > GetPropertyValues(bool bCharGrabBag = true); bool hasEmptyPropertyValues() const {return !m_aValues.getLength();} /** Add property, usually overwrites already available attributes. It shouldn't overwrite in case of default attributes */ -- cgit