[Libreoffice-commits] core.git: sw/qa writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Thu Feb 20 09:39:51 PST 2014


 sw/qa/extras/ooxmlimport/data/annotation-formatting.docx |binary
 sw/qa/extras/ooxmlimport/ooxmlimport.cxx                 |   12 ++++++++
 writerfilter/source/dmapper/DomainMapper_Impl.cxx        |    3 +-
 writerfilter/source/dmapper/PropertyMap.cxx              |   21 ++++++++++-----
 writerfilter/source/dmapper/PropertyMap.hxx              |    2 -
 5 files changed, 30 insertions(+), 8 deletions(-)

New commits:
commit deabda6b38417e4c7037c0d0274a4f81b338e552
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Feb 20 18:25:26 2014 +0100

    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

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 0000000..87af02b
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/annotation-formatting.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 7436e58..acfe4ea 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 d8237f3..70b7320 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 f90cb20..19d8714 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 a9279f2..8d9a32b 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
      */


More information about the Libreoffice-commits mailing list