summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-01-26 11:33:11 +0100
committerAndras Timar <andras.timar@collabora.com>2014-01-26 23:03:47 +0000
commitc6020d169c857d4250f966150f2d48d0735e2c75 (patch)
tree4f63e525a2e7570432c64e2c417267d48846910f
parentcc28ad9eb681e2eb0253910cc30afbf55ea5622b (diff)
RTF import: fix handling of font color from paragraph style
Conflicts: sw/qa/extras/rtfimport/rtfimport.cxx Change-Id: I6bbad2d69863020ea870be800f49e13e763b80bf Reviewed-on: https://gerrit.libreoffice.org/7667 Reviewed-by: Andras Timar <andras.timar@collabora.com> Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--sw/qa/extras/rtfimport/data/char-color.rtf29
-rw-r--r--sw/qa/extras/rtfimport/rtfimport.cxx6
-rw-r--r--writerfilter/source/rtftok/rtfdocumentimpl.cxx4
3 files changed, 38 insertions, 1 deletions
diff --git a/sw/qa/extras/rtfimport/data/char-color.rtf b/sw/qa/extras/rtfimport/data/char-color.rtf
new file mode 100644
index 000000000000..a6483be2096e
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/char-color.rtf
@@ -0,0 +1,29 @@
+{\rtf1\adeflang1025\ansi\ansicpg1252\uc1\adeff31507\deff0\stshfdbch31506\stshfloch31506\stshfhich31506\stshfbi31507\deflang1033\deflangfe1033\themelang1033\themelangfe0\themelangcs0
+{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;
+\red255\green255\blue255;\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;
+\caccentone\ctint255\cshade191\red54\green95\blue145;}
+{\*\defchp \f31506\fs22 }
+{\*\defpap \ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 }
+\noqfpromote
+{\stylesheet
+{\ql \li0\ri0\sa200\sl276\slmult1
+\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext0 \sqformat \spriority0 Normal;}
+{
+\s1\ql \li0\ri0\sb480\sl276\slmult1\keep\keepn\widctlpar\wrapdefault\aspalpha\aspnum\faauto\outlinelevel0\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \ab\af31503\afs28\alang1025 \ltrch\fcs0
+\b\fs28\cf17\lang1033\langfe1033\loch\f31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033 \sbasedon0 \snext0 \slink15 \sqformat \spriority9 \styrsid13382095 heading 1;}
+{\*\cs10 \additive \ssemihidden \sunhideused \spriority1
+Default Paragraph Font;}
+{\*\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tblind0\tblindtype3\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
+\ql \li0\ri0\sa200\sl276\slmult1\widctlpar\wrapdefault\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \rtlch\fcs1 \af31507\afs22\alang1025 \ltrch\fcs0 \f31506\fs22\lang1033\langfe1033\cgrid\langnp1033\langfenp1033 \snext11 \ssemihidden \sunhideused
+Normal Table;}
+{\*\cs15 \additive \rtlch\fcs1 \ab\af31503\afs28 \ltrch\fcs0 \b\fs28\cf17\loch\f31502\hich\af31502\dbch\af31501 \sbasedon10 \slink1 \slocked \spriority9 \styrsid13382095 Heading 1 Char;}
+{\*\cs16 \additive \rtlch\fcs1 \ai\af0 \ltrch\fcs0 \i
+\sbasedon10 \sqformat \spriority20 \styrsid13382095 Emphasis;}
+}
+\pard\plain \ltrpar\s1\ql \li0\ri0\sb480\sl276\slmult1\keep\keepn\widctlpar\wrapdefault\aspalpha\aspnum\faauto\outlinelevel0\adjustright\rin0\lin0\itap0\pararsid13382095 \rtlch\fcs1 \ab\af31503\afs28\alang1025 \ltrch\fcs0
+\b\fs28\cf17\lang1033\langfe1033\loch\af31502\hich\af31502\dbch\af31501\cgrid\langnp1033\langfenp1033
+{\rtlch\fcs1 \af31503 \ltrch\fcs0 \insrsid13382095 \hich\af31502\dbch\af31501\loch\f31502 Foo}
+{\rtlch\fcs1
+\af31503 \ltrch\fcs0 \insrsid14181417
+\par }
+}
diff --git a/sw/qa/extras/rtfimport/rtfimport.cxx b/sw/qa/extras/rtfimport/rtfimport.cxx
index 2c2e48691ec8..42ee83c727c4 100644
--- a/sw/qa/extras/rtfimport/rtfimport.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport.cxx
@@ -1405,6 +1405,12 @@ DECLARE_RTFIMPORT_TEST(testBackground, "background.rtf")
CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(getShape(2), "Opaque")));
}
+DECLARE_RTFIMPORT_TEST(testCharColor, "char-color.rtf")
+{
+ // This was -1: character color wasn't set.
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0x365F91), getProperty<sal_Int32>(getParagraph(1), "CharColor"));
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index fb8fca216481..72f2c8cc55d0 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2982,9 +2982,11 @@ int RTFDocumentImpl::dispatchValue(RTFKeyword nKeyword, int nParam)
break;
case RTF_CF:
{
+ RTFSprms aAttributes;
// NS_sprm::LN_CIco won't work, that would be an index in a static table
RTFValue::Pointer_t pValue(new RTFValue(getColorTable(nParam)));
- m_aStates.top().aCharacterAttributes.set(NS_ooxml::LN_CT_Color_val, pValue);
+ aAttributes.set(NS_ooxml::LN_CT_Color_val, pValue);
+ m_aStates.top().aCharacterSprms.set(NS_ooxml::LN_EG_RPrBase_color, RTFValue::Pointer_t(new RTFValue(aAttributes)));
}
break;
case RTF_S: