summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2015-03-18 10:25:05 +0100
committerZolnai Tamás <zolnaitamas2000@gmail.com>2015-03-21 16:19:08 +0100
commitf880962f5bf26bfaef06bd3f9e67e2d901a2e74c (patch)
tree21791df62dd1dd2c149f1dcc6462dddd2dc143c5
parentdba637ad230d132be0c8f69a630d0dfdfafc105f (diff)
Char highlight: ODT filters
Export merges the two background attribute. Change-Id: I882321fbd5a7d24991fb01b8dc9d2cc0bd294051
-rw-r--r--include/xmloff/txtprmap.hxx2
-rw-r--r--sw/qa/extras/globalfilter/data/char_highlight.docxbin4091 -> 13213 bytes
-rw-r--r--sw/qa/extras/globalfilter/globalfilter.cxx33
-rw-r--r--xmloff/source/text/txtexppr.cxx19
-rw-r--r--xmloff/source/text/txtprmap.cxx8
5 files changed, 52 insertions, 10 deletions
diff --git a/include/xmloff/txtprmap.hxx b/include/xmloff/txtprmap.hxx
index a08915f92597..2562abb5f1ef 100644
--- a/include/xmloff/txtprmap.hxx
+++ b/include/xmloff/txtprmap.hxx
@@ -196,6 +196,8 @@
#define CTF_CHARBOTTOMBORDER (XML_TEXT_CTF_START + 167)
#define CTF_RELWIDTHREL (XML_TEXT_CTF_START + 168)
#define CTF_RELHEIGHTREL (XML_TEXT_CTF_START + 169)
+#define CTF_CHAR_BACKGROUND (XML_TEXT_CTF_START + 170)
+#define CTF_CHAR_HIGHLIGHT (XML_TEXT_CTF_START + 171)
enum class TextPropMap {
diff --git a/sw/qa/extras/globalfilter/data/char_highlight.docx b/sw/qa/extras/globalfilter/data/char_highlight.docx
index 841fc3e3a8e9..e601bac111a2 100644
--- a/sw/qa/extras/globalfilter/data/char_highlight.docx
+++ b/sw/qa/extras/globalfilter/data/char_highlight.docx
Binary files differ
diff --git a/sw/qa/extras/globalfilter/globalfilter.cxx b/sw/qa/extras/globalfilter/globalfilter.cxx
index 6c3e94eeb260..71d2adaa5aa7 100644
--- a/sw/qa/extras/globalfilter/globalfilter.cxx
+++ b/sw/qa/extras/globalfilter/globalfilter.cxx
@@ -355,10 +355,10 @@ void Test::testGraphicShape()
void Test::testCharHighlight()
{
// MS Word has two kind of character backgrounds called character shading and highlighting
- // Now we support these two background attributes colors both in import and export code
+ // MS filters handle these attributes separately, but ODF export merges them into one background attribute
const char* aFilterNames[] = {
-// "writer8",
+ "writer8",
"Rich Text Format",
"MS Word 97",
"Office Open XML Text",
@@ -412,20 +412,37 @@ void Test::testCharHighlight()
case 15: nHighlightColor = 0x808080; break; //dark gray
case 16: nHighlightColor = 0xC0C0C0; break; //light gray
}
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight"));
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor"));
+
+ if( strcmp(aFilterNames[nFilter], "writer8") == 0 )
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharBackColor"));
+ }
+ else // MS filters
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nHighlightColor, getProperty<sal_Int32>(xRun,"CharHighlight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor"));
+ }
}
// Only highlight
{
- const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY);
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighlight"));
- CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor"));
+ const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY);
+ if( strcmp(aFilterNames[nFilter], "writer8") == 0 )
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharBackColor"));
+ }
+ else
+ {
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0xff0000), getProperty<sal_Int32>(xRun,"CharHighlight"));
+ CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor"));
+ }
}
// Only background
{
- const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY);
+ const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,19), uno::UNO_QUERY);
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighlight"));
CPPUNIT_ASSERT_EQUAL_MESSAGE(sFailedMessage.getStr(), sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor"));
}
diff --git a/xmloff/source/text/txtexppr.cxx b/xmloff/source/text/txtexppr.cxx
index 7e3cfc48d3de..1300c3b3f0e8 100644
--- a/xmloff/source/text/txtexppr.cxx
+++ b/xmloff/source/text/txtexppr.cxx
@@ -27,6 +27,7 @@
#include <com/sun/star/awt/FontUnderline.hpp>
#include <com/sun/star/text/XChapterNumberingSupplier.hpp>
#include <tools/debug.hxx>
+#include <tools/color.hxx>
#include <xmloff/txtprmap.hxx>
#include <xmloff/xmlexp.hxx>
#include <xmloff/maptype.hxx>
@@ -658,6 +659,10 @@ void XMLTextExportPropertySetMapper::ContextFilter(
XMLPropertyState* pRepeatOffsetX = NULL;
XMLPropertyState* pRepeatOffsetY = NULL;
+ // character background and highlight
+ XMLPropertyState* pCharBackground = NULL;
+ XMLPropertyState* pCharHighlight = NULL;
+
bool bNeedsAnchor = false;
for( ::std::vector< XMLPropertyState >::iterator aIter = rProperties.begin();
@@ -816,6 +821,9 @@ void XMLTextExportPropertySetMapper::ContextFilter(
propertyState->mnIndex = -1;
}
break;
+
+ case CTF_CHAR_BACKGROUND: pCharBackground = propertyState; break;
+ case CTF_CHAR_HIGHLIGHT: pCharHighlight = propertyState; break;
}
}
@@ -1118,6 +1126,17 @@ void XMLTextExportPropertySetMapper::ContextFilter(
if( pClipState != NULL && pClip11State != NULL )
pClip11State->mnIndex = -1;
+ // When both background attributes are available export the visible one
+ if( pCharHighlight && pCharBackground )
+ {
+ sal_uInt32 nColor = COL_TRANSPARENT;
+ pCharHighlight->maValue >>= nColor;
+ if( nColor == COL_TRANSPARENT )
+ pCharHighlight->mnIndex = -1;
+ else
+ pCharBackground->mnIndex = -1;
+ }
+
SvXMLExportPropertyMapper::ContextFilter(bEnableFoFontFamily, rProperties, rPropSet);
}
diff --git a/xmloff/source/text/txtprmap.cxx b/xmloff/source/text/txtprmap.cxx
index 3806625b83e1..19979c9f23ee 100644
--- a/xmloff/source/text/txtprmap.cxx
+++ b/xmloff/source/text/txtprmap.cxx
@@ -191,7 +191,7 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
// RES_CHRATR_NOLINEBREAK
// TODO: not used?
// RES_CHRATR_BACKGROUND
- MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, CTF_CHAR_BACKGROUND ),
MT_E( "CharBackTransparent", FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
MT_E( "CharBackColor", FO, TEXT_BACKGROUND_COLOR, XML_TYPE_COLOR|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_OLDTEXTBACKGROUND ),
// RES_CHRATR_CJK_FONT
@@ -291,6 +291,8 @@ XMLPropertyMapEntry aXMLParaPropMap[] =
// RES_CHRATR_SHADOW
MAP_EXT( "CharShadowFormat", XML_NAMESPACE_LO_EXT, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ),
MAP_EXT_I( "CharShadowFormat", XML_NAMESPACE_STYLE, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ),
+ // RES_CHRATR_HIGHLIGHT
+ MT_E( "CharHighlight", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY| MID_FLAG_NO_PROPERTY_IMPORT, CTF_CHAR_HIGHLIGHT ),
// RES_TXTATR_INETFMT
// TODO
// RES_TXTATR_REFMARK
@@ -531,7 +533,7 @@ XMLPropertyMapEntry aXMLTextPropMap[] =
// RES_CHRATR_NOLINEBREAK
// TODO: not used?
// RES_CHRATR_BACKGROUND
- MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, 0 ),
+ MT_E( "CharBackColor", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY, CTF_CHAR_BACKGROUND ),
MT_E( "CharBackTransparent", FO, BACKGROUND_COLOR, XML_TYPE_ISTRANSPARENT|MID_FLAG_MERGE_ATTRIBUTE, 0 ),
{ "CharShadingValue", sizeof("CharShadingValue")-1, XML_NAMESPACE_LO_EXT, XML_CHAR_SHADING_VALUE, XML_TYPE_NUMBER|XML_TYPE_PROP_TEXT, 0, SvtSaveOptions::ODFVER_012_EXT_COMPAT, false },
MT_E( "CharBackColor", FO, TEXT_BACKGROUND_COLOR, XML_TYPE_COLOR|MID_FLAG_SPECIAL_ITEM_EXPORT, CTF_OLDTEXTBACKGROUND ),
@@ -634,6 +636,8 @@ XMLPropertyMapEntry aXMLTextPropMap[] =
// RES_CHRATR_SHADOW
MAP_EXT( "CharShadowFormat", XML_NAMESPACE_LO_EXT, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ),
MAP_EXT_I( "CharShadowFormat", XML_NAMESPACE_STYLE, XML_SHADOW, XML_TYPE_TEXT_SHADOW|XML_TYPE_PROP_TEXT, 0 ),
+ // RES_CHRATR_HIGHLIGHT
+ MT_E( "CharHighlight", FO, BACKGROUND_COLOR, XML_TYPE_COLORTRANSPARENT|MID_FLAG_MULTI_PROPERTY|MID_FLAG_NO_PROPERTY_IMPORT, CTF_CHAR_HIGHLIGHT ),
// RES_TXTATR_INETFMT
MT_E( "HyperLinkURL", TEXT, XMLNS, XML_TYPE_STRING|MID_FLAG_NO_PROPERTY_IMPORT, CTF_HYPERLINK_URL ),
// RES_TXTATR_REFMARK