summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-02-20 18:25:26 +0100
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-02-20 18:39:23 +0100
commitdeabda6b38417e4c7037c0d0274a4f81b338e552 (patch)
treec33273665daac1d6d34154427f219d8a2df03e58
parent6e157dc78d495d94948e33822405addb48467e74 (diff)
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
-rwxr-xr-xsw/qa/extras/ooxmlimport/data/annotation-formatting.docxbin0 -> 14298 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx12
-rw-r--r--writerfilter/source/dmapper/DomainMapper_Impl.cxx3
-rw-r--r--writerfilter/source/dmapper/PropertyMap.cxx21
-rw-r--r--writerfilter/source/dmapper/PropertyMap.hxx2
5 files changed, 30 insertions, 8 deletions
diff --git a/sw/qa/extras/ooxmlimport/data/annotation-formatting.docx b/sw/qa/extras/ooxmlimport/data/annotation-formatting.docx
new file mode 100755
index 000000000000..87af02b780e5
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/annotation-formatting.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 7436e58dd212..acfe4ea44bb8 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -13,6 +13,7 @@
#if !defined(WNT)
#include <com/sun/star/awt/XBitmap.hpp>
+#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/document/XEmbeddedObjectSupplier2.hpp>
@@ -1869,6 +1870,17 @@ DECLARE_OOXMLIMPORT_TEST(testFloatingTablesAnchor, "floating-tables-anchor.docx"
xText.set(xRange->getText(), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL(OUString("Anchor point"), xText->getString());
}
+
+DECLARE_OOXMLIMPORT_TEST(testAnnotationFormatting, "annotation-formatting.docx")
+{
+ uno::Reference<beans::XPropertySet> xTextField = getProperty< uno::Reference<beans::XPropertySet> >(getRun(getParagraph(2), 2), "TextField");
+ uno::Reference<text::XText> xText = getProperty< uno::Reference<text::XText> >(xTextField, "TextRange");
+ // Make sure we test the right annotation.
+ uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText, "days");
+ // Formatting was lost: the second text portion was NONE, not SINGLE.
+ CPPUNIT_ASSERT_EQUAL(awt::FontUnderline::SINGLE, getProperty<sal_Int16>(getRun(xParagraph, 1), "CharUnderline"));
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
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<beans::PropertyValue> 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
*/