summaryrefslogtreecommitdiff
path: root/sw/source/filter
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2013-09-29 10:24:53 +0200
committerZolnai Tamás <zolnaitamas2000@gmail.com>2013-09-29 11:27:34 +0200
commit8b949134441056a1455d67ddfdd7e0bc5f2ee682 (patch)
treeba258b0f7df5b3ae7b5fbc4cf484cebcf51f389a /sw/source/filter
parent1b0f6be2d06154f6ecab2f6ee930fa3c5a62f01d (diff)
fdo#65403, fdo#65404 DOCX export/import of character highlight
Steps -Add a new character attribute (RES_CHRATR_HIGHLIGHT) -Get this character attribute via SwFont class just like background -If has highlight, then paint that, otherwise paint background -Extend UNO API -Implement DOCX export and import filter Note: By now character highlight can't be set via UI. It's a next step to add a highlight option. Change-Id: I7f81e173744bf256891487f898d06dbf372a2f88
Diffstat (limited to 'sw/source/filter')
-rw-r--r--sw/source/filter/html/css1atr.cxx2
-rw-r--r--sw/source/filter/html/htmlatr.cxx2
-rw-r--r--sw/source/filter/ww8/attributeoutputbase.hxx3
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx34
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx11
-rw-r--r--sw/source/filter/ww8/rtfattributeoutput.hxx3
-rw-r--r--sw/source/filter/ww8/ww8atr.cxx3
-rw-r--r--sw/source/filter/ww8/ww8attributeoutput.hxx3
8 files changed, 59 insertions, 2 deletions
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 7e82dabe024c..ef3e6c5c108c 100644
--- a/sw/source/filter/html/css1atr.cxx
+++ b/sw/source/filter/html/css1atr.cxx
@@ -3651,7 +3651,7 @@ SwAttrFnTab aCSS1AttrFnTab = {
/* RES_CHRATR_RSID */ 0,
/* RES_CHRATR_BOX */ OutCSS1_SvxBox,
/* RES_CHRATR_SHADOW */ 0,
-/* RES_CHRATR_DUMMY1 */ 0,
+/* RES_CHRATR_HIGHLIGHT */ 0,
/* RES_CHRATR_DUMMY2 */ 0,
/* RES_CHRATR_DUMMY3 */ 0,
diff --git a/sw/source/filter/html/htmlatr.cxx b/sw/source/filter/html/htmlatr.cxx
index 4ec590c0048c..eb56c845b488 100644
--- a/sw/source/filter/html/htmlatr.cxx
+++ b/sw/source/filter/html/htmlatr.cxx
@@ -3276,7 +3276,7 @@ SwAttrFnTab aHTMLAttrFnTab = {
/* RES_CHRATR_RSID */ 0,
/* RES_CHRATR_BOX */ OutHTML_CSS1Attr,
/* RES_CHRATR_SHADOW */ 0,
-/* RES_CHRATR_DUMMY1 */ 0,
+/* RES_CHRATR_HIGHLGHT */ 0,
/* RES_CHRATR_DUMMY2 */ 0,
/* RES_CHRATR_DUMMY3 */ 0,
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 134de6b6b806..4c94fb2acfe4 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -443,6 +443,9 @@ protected:
void FormatCharBorder( const SvxBoxItem& rBox );
virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow ) = 0;
+ /// Sfx item RES_CHRATR_HIGHLIGHT
+ virtual void CharHighLight( const SvxBrushItem& ) = 0;
+
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& ) = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 1eb94a147798..1bb10ee9ce56 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3804,6 +3804,30 @@ void DocxAttributeOutput::EmbedFontStyle( const OUString& name, int tag, FontFam
FSEND );
}
+OString DocxAttributeOutput::TransHighLightColor( const Color& rColor )
+{
+ switch (rColor.GetColor())
+ {
+ case 0x000000: return OString("black"); break;
+ case 0x0000ff: return OString("blue"); break;
+ case 0x00ffff: return OString("cyan"); break;
+ case 0x00ff00: return OString("green"); break;
+ case 0xff00ff: return OString("magenta"); break;
+ case 0xff0000: return OString("red"); break;
+ case 0xffff00: return OString("yellow"); break;
+ case 0xffffff: return OString("white"); break;
+ case 0x000080: return OString("darkBlue"); break;
+ case 0x008080: return OString("darkCyan"); break;
+ case 0x008000: return OString("darkGreen"); break;
+ case 0x800080: return OString("darkMagenta"); break;
+ case 0x800000: return OString("darkRed"); break;
+ case 0x808000: return OString("darkYellow"); break;
+ case 0x808080: return OString("darkGray"); break;
+ case 0xC0C0C0: return OString("lightGray"); break;
+ default: return OString(); break;
+ }
+}
+
void DocxAttributeOutput::NumberingDefinition( sal_uInt16 nId, const SwNumRule &rRule )
{
// nId is the same both for abstract numbering definition as well as the
@@ -4389,6 +4413,16 @@ void DocxAttributeOutput::CharBorder(
impl_borderLine( m_pSerializer, XML_bdr, pAllBorder, nDist, bShadow );
}
+void DocxAttributeOutput::CharHighLight( const SvxBrushItem& rHighLight )
+{
+ const OString sColor = TransHighLightColor( rHighLight.GetColor() );
+ if ( !sColor.isEmpty() )
+ {
+ m_pSerializer->singleElementNS( XML_w, XML_highlight,
+ FSNS( XML_w, XML_val ), sColor.getStr(), FSEND );
+ }
+}
+
void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink )
{
const SwTxtINetFmt* pINetFmt = rLink.GetTxtINetFmt();
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 5abb0632074b..50db15b6c75c 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -376,6 +376,14 @@ private:
void EmbedFontStyle( const OUString& name, int tag, FontFamily family, FontItalic italic, FontWeight weight,
FontPitch pitch, rtl_TextEncoding encoding );
+ /**
+ * Translate a color object to the corresponding HighLightColorValues enumaration item
+ *
+ * @param[in] rColor a color object to translate
+ * @return color name (e.g. "red"), if color is inside the enumeration's range
+ * empty string, otherwise
+ **/
+ OString TransHighLightColor( const Color& rColor );
protected:
/// Output frames - the implementation.
@@ -480,6 +488,9 @@ protected:
/// Sfx item RES_CHRATR_BOX
virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow );
+ /// Sfx item RES_CHRATR_HIGHLIGHT
+ virtual void CharHighLight( const SvxBrushItem& rHighLight );
+
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index de1ae971a181..affda614c1aa 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -315,6 +315,9 @@ protected:
/// Sfx item RES_CHRATR_BOX
virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow );
+ /// Sfx item RES_CHRATR_HIGHLIGHT
+ virtual void CharHighLight( const SvxBrushItem& ){};
+
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 1c5abd500c5a..1fd830484cef 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -5152,6 +5152,9 @@ void AttributeOutputBase::OutputItem( const SfxPoolItem& rHt )
case RES_CHRATR_BOX:
FormatCharBorder( static_cast< const SvxBoxItem& >( rHt ) );
break;
+ case RES_CHRATR_HIGHLIGHT:
+ CharHighLight( static_cast< const SvxBrushItem& >( rHt ) );
+ break;
case RES_TXTATR_INETFMT:
TextINetFormat( static_cast< const SwFmtINetFmt& >( rHt ) );
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 3c37de5aa86e..cd198abffebe 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -296,6 +296,9 @@ protected:
/// Sfx item RES_CHRATR_BOX
virtual void CharBorder( const ::editeng::SvxBorderLine* pAllBorder, const sal_uInt16 nDist, const bool bShadow );
+ /// Sfx item RES_CHRATR_HIGHLIGHT
+ virtual void CharHighLight( const SvxBrushItem& ){};
+
/// Sfx item RES_TXTATR_INETFMT
virtual void TextINetFormat( const SwFmtINetFmt& );