[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - sw/qa sw/source writerfilter/source

nrbrtx at gmail.com nrbrtx at gmail.com
Fri Aug 8 12:31:20 PDT 2014


 sw/qa/extras/rtfexport/data/fdo79599.rtf       |   38 ++++++++++++++++
 sw/qa/extras/rtfexport/rtfexport.cxx           |    9 +++
 sw/qa/extras/rtfimport/data/fdo79599.rtf       |   38 ++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport.cxx           |   57 ++++++++++++++++++++++++-
 sw/source/filter/ww8/rtfattributeoutput.cxx    |    2 
 writerfilter/source/dmapper/DomainMapper.cxx   |    2 
 writerfilter/source/rtftok/rtfdocumentimpl.cxx |    2 
 7 files changed, 144 insertions(+), 4 deletions(-)

New commits:
commit 22731ba9e15978ab1d1ed98a29d88431cf674257
Author: nrbrtx at gmail.com <nrbrtx at gmail.com>
Date:   Tue Jun 10 12:26:26 2014 +0400

    fdo#79599: use \highlightN instead of \chcbpatN in RTF import and export
    
    Reviewed on:
    	https://gerrit.libreoffice.org/9776
    
    (cherry picked from commit 7eafd8ccac56d7503b4287dfa3acac2cf0560b20)
    
    Conflicts:
    	sw/qa/extras/rtfexport/rtfexport.cxx
    
    Change-Id: I98ef606fb73368a3c275819cb83b936e2162769d
    Reviewed-on: https://gerrit.libreoffice.org/10813
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/qa/extras/rtfexport/data/fdo79599.rtf b/sw/qa/extras/rtfexport/data/fdo79599.rtf
new file mode 100755
index 0000000..f908709
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo79599.rtf
@@ -0,0 +1,38 @@
+{\rtf1\deff0
+{\fonttbl
+{\f000 Courier New;}
+}
+{\colortbl;
+\red0\green0\blue0;
+\red255\green255\blue0;
+\red0\green255\blue0;
+\red0\green255\blue255;
+\red255\green0\blue255;
+\red0\green0\blue255;
+\red255\green0\blue0;
+\red0\green0\blue128;
+\red0\green128\blue128;
+\red0\green128\blue0;
+\red128\green0\blue128;
+\red128\green0\blue0;
+\red128\green128\blue0;
+\red128\green128\blue128;
+\red192\green192\blue192;
+}
+\highlight0 Should be ignored\par
+\highlight2 #FFFF00 = Yellow\par
+\highlight3 #00FF00 = Green\par
+\highlight4 #00FFFF = Cyan\par
+\highlight5 #FF00FF = Magenta\par
+\highlight6 #0000FF = Blue\par
+\highlight7 #FF0000 = Red\par
+\highlight8 #000080 = Dark blue\par
+\highlight9 #008080 = Dark cyan\par
+\highlight10 #008000 = Dark green\par
+\highlight11 #800080 = Dark magenta\par
+\highlight12 #800000 = Dark red\par
+\highlight13 #808000 = Dark yellow\par
+\highlight14 #808080 = Dark gray\par
+\highlight15 #C0C0C0 = Light gray\par
+\highlight1 #000000 = Black\par
+}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index e4ed685..0617258 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -650,6 +650,15 @@ DECLARE_RTFEXPORT_TEST(testFdo80167, "fdo80167.rtf")
     CPPUNIT_ASSERT_EQUAL(2, getPages());
 }
 
+DECLARE_RTFEXPORT_TEST(testFdo79599, "fdo79599.rtf")
+{
+    // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007)
+
+    // test \highlight11 = dark magenta
+    uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(11),1), uno::UNO_QUERY);
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(xRun, "CharBackColor"));
+}
+
 #endif
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/qa/extras/rtfimport/data/fdo79599.rtf b/sw/qa/extras/rtfimport/data/fdo79599.rtf
new file mode 100755
index 0000000..f908709
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/fdo79599.rtf
@@ -0,0 +1,38 @@
+{\rtf1\deff0
+{\fonttbl
+{\f000 Courier New;}
+}
+{\colortbl;
+\red0\green0\blue0;
+\red255\green255\blue0;
+\red0\green255\blue0;
+\red0\green255\blue255;
+\red255\green0\blue255;
+\red0\green0\blue255;
+\red255\green0\blue0;
+\red0\green0\blue128;
+\red0\green128\blue128;
+\red0\green128\blue0;
+\red128\green0\blue128;
+\red128\green0\blue0;
+\red128\green128\blue0;
+\red128\green128\blue128;
+\red192\green192\blue192;
+}
+\highlight0 Should be ignored\par
+\highlight2 #FFFF00 = Yellow\par
+\highlight3 #00FF00 = Green\par
+\highlight4 #00FFFF = Cyan\par
+\highlight5 #FF00FF = Magenta\par
+\highlight6 #0000FF = Blue\par
+\highlight7 #FF0000 = Red\par
+\highlight8 #000080 = Dark blue\par
+\highlight9 #008080 = Dark cyan\par
+\highlight10 #008000 = Dark green\par
+\highlight11 #800080 = Dark magenta\par
+\highlight12 #800000 = Dark red\par
+\highlight13 #808000 = Dark yellow\par
+\highlight14 #808080 = Dark gray\par
+\highlight15 #C0C0C0 = Light gray\par
+\highlight1 #000000 = Black\par
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 21458df..ff2cd1a 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -544,6 +544,59 @@ DECLARE_RTFIMPORT_TEST(testFdo50539, "fdo50539.rtf")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor"));
 }
 
+DECLARE_RTFIMPORT_TEST(testFdo79599, "fdo79599.rtf")
+{
+    // test for \highlightNN, document has full \colortbl (produced in MS Word 2003 or 2007)
+
+    // ignore \highlight0
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), getProperty<sal_Int32>(getRun(getParagraph(1), 1), "CharBackColor"));
+
+    // test \highlight2 = yellow
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFF00), getProperty<sal_uInt32>(getRun(getParagraph(2), 1), "CharBackColor"));
+
+    // test \highlight3 = green
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FF00), getProperty<sal_uInt32>(getRun(getParagraph(3), 1), "CharBackColor"));
+
+    // test \highlight4 = cyan
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x00FFFF), getProperty<sal_uInt32>(getRun(getParagraph(4), 1), "CharBackColor"));
+
+    // test \highlight5 = magenta
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF00FF), getProperty<sal_uInt32>(getRun(getParagraph(5), 1), "CharBackColor"));
+
+    // test \highlight6 = blue
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x0000FF), getProperty<sal_uInt32>(getRun(getParagraph(6), 1), "CharBackColor"));
+
+    // test \highlight7 = red
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFF0000), getProperty<sal_uInt32>(getRun(getParagraph(7), 1), "CharBackColor"));
+
+    // test \highlight8 = dark blue
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000080), getProperty<sal_uInt32>(getRun(getParagraph(8), 1), "CharBackColor"));
+
+    // test \highlight9 = dark cyan
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008080), getProperty<sal_uInt32>(getRun(getParagraph(9), 1), "CharBackColor"));
+
+    // test \highlight10 = dark green
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x008000), getProperty<sal_uInt32>(getRun(getParagraph(10), 1), "CharBackColor"));
+
+    // test \highlight11 = dark magenta
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800080), getProperty<sal_uInt32>(getRun(getParagraph(11), 1), "CharBackColor"));
+
+    // test \highlight12 = dark red
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x800000), getProperty<sal_uInt32>(getRun(getParagraph(12), 1), "CharBackColor"));
+
+    // test \highlight13 = dark yellow
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808000), getProperty<sal_uInt32>(getRun(getParagraph(13), 1), "CharBackColor"));
+
+    // test \highlight14 = dark gray
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x808080), getProperty<sal_uInt32>(getRun(getParagraph(14), 1), "CharBackColor"));
+
+    // test \highlight15 = light gray
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xC0C0C0), getProperty<sal_uInt32>(getRun(getParagraph(15), 1), "CharBackColor"));
+
+    // test \highlight1 = black
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0x000000), getProperty<sal_uInt32>(getRun(getParagraph(16), 1), "CharBackColor"));
+}
+
 DECLARE_RTFIMPORT_TEST(testFdo50665, "fdo50665.rtf")
 {
     // Access the second run, which is a textfield
@@ -1091,8 +1144,8 @@ DECLARE_RTFIMPORT_TEST(testFdo61909, "fdo61909.rtf")
     uno::Reference<text::XTextRange> xTextRange = getRun(getParagraph(1), 1);
     // Was the Writer default font.
     CPPUNIT_ASSERT_EQUAL(OUString("Courier New"), getProperty<OUString>(xTextRange, "CharFontName"));
-    // Was 0x008000.
-    CPPUNIT_ASSERT_EQUAL(COL_AUTO, getProperty<sal_uInt32>(xTextRange, "CharBackColor"));
+    // It is white (0xFFFFFF) in document
+    CPPUNIT_ASSERT_EQUAL(sal_uInt32(0xFFFFFF), getProperty<sal_uInt32>(xTextRange, "CharBackColor"));
 }
 
 DECLARE_RTFIMPORT_TEST(testFdo62288, "fdo62288.rtf")
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 9f14309..51f9033 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2244,7 +2244,7 @@ void RtfAttributeOutput::CharBackground(const SvxBrushItem& rBrush)
 {
     if (!rBrush.GetColor().GetTransparency())
     {
-        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CHCBPAT);
+        m_aStyles.append(OOO_STRING_SVTOOLS_RTF_HIGHLIGHT);
         m_aStyles.append((sal_Int32)m_rExport.GetColor(rBrush.GetColor()));
     }
 }
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 35ad80e..d97f471 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1336,6 +1336,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
                 rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( nColor ));
             else if (mnBackgroundColor)
                 rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( mnBackgroundColor ));
+            else
+                rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( nIntValue ));
         }
         break;
     case NS_ooxml::LN_EG_RPrBase_em:
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 1917276..37afecc 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -3743,7 +3743,7 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
     break;
     case RTF_HIGHLIGHT:
     {
-        RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
+        RTFValue::Pointer_t pValue(new RTFValue(nParam ? getColorTable(nParam) : COL_AUTO));
         m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_highlight, pValue);
     }
     break;


More information about the Libreoffice-commits mailing list