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

Zolnai Tamás zolnaitamas2000 at gmail.com
Sun Sep 29 02:28:39 PDT 2013


 offapi/com/sun/star/style/CharacterProperties.idl |    6 ++
 sw/inc/charatr.hxx                                |    4 +
 sw/inc/format.hxx                                 |    1 
 sw/inc/hintids.hxx                                |    2 
 sw/inc/swatrset.hxx                               |    1 
 sw/inc/unoprnms.hxx                               |    1 
 sw/qa/extras/ooxmlexport/data/char_highlight.docx |binary
 sw/qa/extras/ooxmlexport/ooxmlexport.cxx          |   49 ++++++++++++++++++++++
 sw/source/core/bastyp/init.cxx                    |    2 
 sw/source/core/doc/dbgoutsw.cxx                   |    1 
 sw/source/core/inc/swfntcch.hxx                   |    2 
 sw/source/core/inc/swfont.hxx                     |   10 ++++
 sw/source/core/text/atrhndl.hxx                   |    2 
 sw/source/core/text/atrstck.cxx                   |   15 ++++--
 sw/source/core/text/inftxt.cxx                    |   13 ++++-
 sw/source/core/txtnode/swfont.cxx                 |   11 ++++
 sw/source/core/unocore/unomap.cxx                 |    4 +
 sw/source/core/unocore/unoprnms.cxx               |    2 
 sw/source/filter/html/css1atr.cxx                 |    2 
 sw/source/filter/html/htmlatr.cxx                 |    2 
 sw/source/filter/ww8/attributeoutputbase.hxx      |    3 +
 sw/source/filter/ww8/docxattributeoutput.cxx      |   34 +++++++++++++++
 sw/source/filter/ww8/docxattributeoutput.hxx      |   11 ++++
 sw/source/filter/ww8/rtfattributeoutput.hxx       |    3 +
 sw/source/filter/ww8/ww8atr.cxx                   |    3 +
 sw/source/filter/ww8/ww8attributeoutput.hxx       |    3 +
 writerfilter/source/dmapper/DomainMapper.cxx      |    4 -
 writerfilter/source/dmapper/PropertyIds.cxx       |    1 
 writerfilter/source/dmapper/PropertyIds.hxx       |    1 
 29 files changed, 173 insertions(+), 20 deletions(-)

New commits:
commit 8b949134441056a1455d67ddfdd7e0bc5f2ee682
Author: Zolnai Tamás <zolnaitamas2000 at gmail.com>
Date:   Sun Sep 29 10:24:53 2013 +0200

    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

diff --git a/offapi/com/sun/star/style/CharacterProperties.idl b/offapi/com/sun/star/style/CharacterProperties.idl
index c4f5452..ae8313d 100644
--- a/offapi/com/sun/star/style/CharacterProperties.idl
+++ b/offapi/com/sun/star/style/CharacterProperties.idl
@@ -435,6 +435,12 @@ published service CharacterProperties
     **/
     [optional, property] com::sun::star::table::ShadowFormat CharShadowFormat;
 
+    /** Determines the color of the highlight.
+     *
+     *  @since LibreOffice 4.2
+    **/
+    [optional, property] com::sun::star::util::Color CharHighLight;
+
 };
 
 }; }; }; };
diff --git a/sw/inc/charatr.hxx b/sw/inc/charatr.hxx
index b0a77c2..e248205 100644
--- a/sw/inc/charatr.hxx
+++ b/sw/inc/charatr.hxx
@@ -87,6 +87,8 @@ inline const SvxBlinkItem  &SwAttrSet::GetBlink(sal_Bool bInP) const
     {   return (const SvxBlinkItem&)Get( RES_CHRATR_BLINK,bInP); }
 inline const SvxBrushItem &SwAttrSet::GetChrBackground( sal_Bool bInP ) const
     {   return (const SvxBrushItem&)Get( RES_CHRATR_BACKGROUND, bInP ); }
+inline const SvxBrushItem &SwAttrSet::GetChrHighLight( sal_Bool bInP ) const
+    {   return (const SvxBrushItem&)Get( RES_CHRATR_HIGHLIGHT, bInP ); }
 inline const SvxEmphasisMarkItem &SwAttrSet::GetEmphasisMark( sal_Bool bInP ) const
     {   return (const SvxEmphasisMarkItem&)Get( RES_CHRATR_EMPHASIS_MARK, bInP ); }
 inline const SvxTwoLinesItem    &SwAttrSet::Get2Lines( sal_Bool bInP ) const
@@ -152,6 +154,8 @@ inline const SvxBlinkItem           &SwFmt::GetBlink(sal_Bool bInP) const
     {   return aSet.GetBlink(bInP); }
 inline const SvxBrushItem           &SwFmt::GetChrBackground(sal_Bool bInP) const
     {   return aSet.GetChrBackground(bInP); }
+inline const SvxBrushItem &SwFmt::GetChrHighLight(sal_Bool bInP) const
+    {   return aSet.GetChrHighLight(bInP); }
 inline const SvxEmphasisMarkItem   &SwFmt::GetEmphasisMark( sal_Bool bInP ) const
     {   return aSet.GetEmphasisMark(bInP); }
 inline const SvxTwoLinesItem       &SwFmt::Get2Lines( sal_Bool bInP ) const
diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index a058dc6..88c5402 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -190,6 +190,7 @@ public:
     inline const SvxNoHyphenItem     &GetNoHyphenHere( sal_Bool = sal_True ) const;
     inline const SvxBlinkItem        &GetBlink( sal_Bool = sal_True ) const;
     inline const SvxBrushItem        &GetChrBackground( sal_Bool = sal_True ) const;
+    inline const SvxBrushItem        &GetChrHighLight( sal_Bool = sal_True ) const;
 
     inline const SvxFontItem         &GetCJKFont( sal_Bool = sal_True ) const;
     inline const SvxFontHeightItem   &GetCJKSize( sal_Bool = sal_True ) const;
diff --git a/sw/inc/hintids.hxx b/sw/inc/hintids.hxx
index 231551a..97ee553 100644
--- a/sw/inc/hintids.hxx
+++ b/sw/inc/hintids.hxx
@@ -90,7 +90,7 @@ RES_CHRATR_BEGIN = HINT_BEGIN,
     RES_CHRATR_RSID,                        // 39
     RES_CHRATR_BOX,                         // 40
     RES_CHRATR_SHADOW,                      // 41
-    RES_CHRATR_DUMMY1,                      // 42
+    RES_CHRATR_HIGHLIGHT,                   // 42
     RES_CHRATR_DUMMY2,                      // 43
     RES_CHRATR_DUMMY3,                      // 44
 RES_CHRATR_END
diff --git a/sw/inc/swatrset.hxx b/sw/inc/swatrset.hxx
index 0b35135..8c1c87b 100644
--- a/sw/inc/swatrset.hxx
+++ b/sw/inc/swatrset.hxx
@@ -232,6 +232,7 @@ public:
     inline const SvxNoHyphenItem      &GetNoHyphenHere( sal_Bool = sal_True ) const;
     inline const SvxBlinkItem         &GetBlink( sal_Bool = sal_True ) const;
     inline const SvxBrushItem         &GetChrBackground( sal_Bool = sal_True ) const;
+    inline const SvxBrushItem         &GetChrHighLight( sal_Bool = sal_True ) const;
     inline const SvxFontItem          &GetCJKFont( sal_Bool = sal_True ) const;
     inline const SvxFontHeightItem    &GetCJKSize( sal_Bool = sal_True ) const;
     inline const SvxLanguageItem      &GetCJKLanguage( sal_Bool = sal_True ) const;
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index ebc95c7..32f635e 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -840,6 +840,7 @@ enum SwPropNameIds
 
 /* 0774 */  UNO_NAME_DOC_INTEROP_GRAB_BAG,
 /* 0775 */  UNO_NAME_FRAME_INTEROP_GRAB_BAG,
+/* 0776 */  UNO_NAME_CHAR_HIGHLIGHT,
 
             SW_PROPNAME_END
 
diff --git a/sw/qa/extras/ooxmlexport/data/char_highlight.docx b/sw/qa/extras/ooxmlexport/data/char_highlight.docx
new file mode 100644
index 0000000..841fc3e
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/char_highlight.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index cc4131e..45e50b1 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -121,6 +121,7 @@ public:
     void testStyleInheritance();
     void testSmartart();
     void testFdo69636();
+    void testCharHighLight();
 
     CPPUNIT_TEST_SUITE(Test);
 #if !defined(MACOSX) && !defined(WNT)
@@ -239,6 +240,7 @@ void Test::run()
         {"style-inheritance.docx", &Test::testStyleInheritance},
         {"smartart.docx", &Test::testSmartart},
         {"fdo69636.docx", &Test::testFdo69636},
+        {"char_highlight.docx", &Test::testCharHighLight},
     };
     // Don't test the first import of these, for some reason those tests fail
     const char* aBlacklist[] = {
@@ -1492,6 +1494,53 @@ void Test::testFdo69636()
     CPPUNIT_ASSERT(getXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/w:pict/v:rect/v:textbox", "style").match("mso-layout-flow-alt:bottom-to-top"));
 }
 
+void Test::testCharHighLight()
+{
+    const uno::Reference< text::XTextRange > xPara = getParagraph(1);
+    // Both highlight and background
+    const sal_Int32 nBackColor(0x4F81BD);
+    for( int nRun = 1; nRun <= 16; ++nRun )
+    {
+        const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,nRun), uno::UNO_QUERY);
+        sal_Int32 nHighLightColor = 0;
+        switch( nRun )
+        {
+            case 1: nHighLightColor = 0x000000; break; //black
+            case 2: nHighLightColor = 0x0000ff; break; //blue
+            case 3: nHighLightColor = 0x00ffff; break; //cyan
+            case 4: nHighLightColor = 0x00ff00; break; //green
+            case 5: nHighLightColor = 0xff00ff; break; //magenta
+            case 6: nHighLightColor = 0xff0000; break; //red
+            case 7: nHighLightColor = 0xffff00; break; //yellow
+            case 8: nHighLightColor = 0xffffff; break; //white
+            case 9: nHighLightColor = 0x000080;  break;//dark blue
+            case 10: nHighLightColor = 0x008080; break; //dark cyan
+            case 11: nHighLightColor = 0x008000; break; //dark green
+            case 12: nHighLightColor = 0x800080; break; //dark magenta
+            case 13: nHighLightColor = 0x800000; break; //dark red
+            case 14: nHighLightColor = 0x808000; break; //dark yellow
+            case 15: nHighLightColor = 0x808080; break; //dark gray
+            case 16: nHighLightColor = 0xC0C0C0; break; //light gray
+        }
+        CPPUNIT_ASSERT_EQUAL(nHighLightColor, getProperty<sal_Int32>(xRun,"CharHighLight"));
+        CPPUNIT_ASSERT_EQUAL(nBackColor, getProperty<sal_Int32>(xRun,"CharBackColor"));
+    }
+
+    // Only highlight
+    {
+        const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,17), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(0xC0C0C0), getProperty<sal_Int32>(xRun,"CharHighLight"));
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharBackColor"));
+    }
+
+    // Only background
+    {
+        const uno::Reference<beans::XPropertySet> xRun(getRun(xPara,18), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(COL_TRANSPARENT), getProperty<sal_Int32>(xRun,"CharHighLight"));
+        CPPUNIT_ASSERT_EQUAL(sal_Int32(0x0000ff), getProperty<sal_Int32>(xRun,"CharBackColor"));
+    }
+}
+
 CPPUNIT_TEST_SUITE_REGISTRATION(Test);
 
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/core/bastyp/init.cxx b/sw/source/core/bastyp/init.cxx
index 30fc9f0..4a0ca16 100644
--- a/sw/source/core/bastyp/init.cxx
+++ b/sw/source/core/bastyp/init.cxx
@@ -496,9 +496,9 @@ void _InitCore()
     aAttrTab[ RES_CHRATR_OVERLINE- POOLATTR_BEGIN ] =       new SvxOverlineItem( UNDERLINE_NONE, RES_CHRATR_OVERLINE );
     aAttrTab[ RES_CHRATR_BOX - POOLATTR_BEGIN ] =           new SvxBoxItem( RES_CHRATR_BOX );
     aAttrTab[ RES_CHRATR_SHADOW - POOLATTR_BEGIN ] =        new SvxShadowItem( RES_CHRATR_SHADOW );
+    aAttrTab[ RES_CHRATR_HIGHLIGHT - POOLATTR_BEGIN ] =     new SvxBrushItem( RES_CHRATR_HIGHLIGHT );
 
 // CharakterAttr - Dummies
-    aAttrTab[ RES_CHRATR_DUMMY1 - POOLATTR_BEGIN ] =        new SfxBoolItem( RES_CHRATR_DUMMY1 );
     aAttrTab[ RES_CHRATR_DUMMY2 - POOLATTR_BEGIN ] =        new SfxBoolItem( RES_CHRATR_DUMMY2 );
     aAttrTab[ RES_CHRATR_DUMMY3 - POOLATTR_BEGIN ] =        new SfxBoolItem( RES_CHRATR_DUMMY3 );
 
diff --git a/sw/source/core/doc/dbgoutsw.cxx b/sw/source/core/doc/dbgoutsw.cxx
index 2a97182..cf5ab8b 100644
--- a/sw/source/core/doc/dbgoutsw.cxx
+++ b/sw/source/core/doc/dbgoutsw.cxx
@@ -144,6 +144,7 @@ map<sal_uInt16,String,CompareUShort> & GetItemWhichMap()
         aItemWhichMap[RES_CHRATR_NOHYPHEN] = String("CHRATR_NOHYPHEN", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_CHRATR_NOLINEBREAK] = String("CHRATR_NOLINEBREAK", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_CHRATR_BACKGROUND] = String("CHRATR_BACKGROUND", RTL_TEXTENCODING_ASCII_US);
+        aItemWhichMap[RES_CHRATR_HIGHLIGHT] = String("CHRATR_HIGHLIGHT", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_CHRATR_CJK_FONT] = String("CHRATR_CJK_FONT", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_CHRATR_CJK_FONTSIZE] = String("CHRATR_CJK_FONTSIZE", RTL_TEXTENCODING_ASCII_US);
         aItemWhichMap[RES_CHRATR_CJK_LANGUAGE] = String("CHRATR_CJK_LANGUAGE", RTL_TEXTENCODING_ASCII_US);
diff --git a/sw/source/core/inc/swfntcch.hxx b/sw/source/core/inc/swfntcch.hxx
index 041757a..e4d44e3 100644
--- a/sw/source/core/inc/swfntcch.hxx
+++ b/sw/source/core/inc/swfntcch.hxx
@@ -21,7 +21,7 @@
 
 #include <tools/mempool.hxx>
 
-#define NUM_DEFAULT_VALUES 38
+#define NUM_DEFAULT_VALUES 39
 
 #include "swcache.hxx"
 #include "swfont.hxx"
diff --git a/sw/source/core/inc/swfont.hxx b/sw/source/core/inc/swfont.hxx
index f347d20..b6c0e2b 100644
--- a/sw/source/core/inc/swfont.hxx
+++ b/sw/source/core/inc/swfont.hxx
@@ -127,6 +127,7 @@ class SwFont
                                 // CTL == Complex text layout ( Hebrew, Arabic )
     SwSubFont   aSub[SW_SCRIPTS]; // Latin-, CJK- and CTL-font
     Color*      pBackColor;     // background color (i.e. at character styles)
+    Color       m_aHighLightColor;   // highlight color
     Color       aUnderColor;    // color of the underlining
     Color       aOverColor;     // color of the overlining
 
@@ -182,6 +183,8 @@ public:
     // set background color
     void SetBackColor( Color* pNewColor );
     inline const Color* GetBackColor() const{ return pBackColor; }
+    void SetHighLightColor( const Color& aNewColor );
+    const Color& GetHighLightColor() const { return m_aHighLightColor; }
 
     inline void ChkMagic( ViewShell *pSh, sal_uInt8 nWhich )
         { if( !aSub[ nWhich ].pMagic ) GoMagic( pSh, nWhich ); }
@@ -1000,6 +1003,13 @@ inline void SwFont::SetShadowLocation( const SvxShadowLocation aLocation )
     aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
 }
 
+inline void SwFont::SetHighLightColor( const Color& aNewColor )
+{
+    m_aHighLightColor = aNewColor;
+    bFntChg = sal_True;
+    aSub[SW_LATIN].pMagic = aSub[SW_CJK].pMagic = aSub[SW_CTL].pMagic = 0;
+}
+
 /*************************************************************************
  *                      class SwUnderlineFont
  *
diff --git a/sw/source/core/text/atrhndl.hxx b/sw/source/core/text/atrhndl.hxx
index 393174b..1cddbe9 100644
--- a/sw/source/core/text/atrhndl.hxx
+++ b/sw/source/core/text/atrhndl.hxx
@@ -21,7 +21,7 @@
 #define _ATRHNDL_HXX
 
 #define INITIAL_NUM_ATTR 3
-#define NUM_ATTRIBUTE_STACKS 42
+#define NUM_ATTRIBUTE_STACKS 43
 
 #include <txatbase.hxx>
 #include <swfntcch.hxx>
diff --git a/sw/source/core/text/atrstck.cxx b/sw/source/core/text/atrstck.cxx
index 0e3df3c..ad1c2a9 100644
--- a/sw/source/core/text/atrstck.cxx
+++ b/sw/source/core/text/atrstck.cxx
@@ -115,17 +115,17 @@ const sal_uInt8 StackPos[ static_cast<sal_uInt16>(RES_TXTATR_WITHEND_END) -
      0, // RES_CHRATR_RSID,                      // 39
     36, // RES_CHRATR_BOX,                       // 40
     37, // RES_CHRATR_SHADOW,                    // 41
-     0, // RES_CHRATR_DUMMY1,                    // 42
+    38, // RES_CHRATR_HIGHLIGHT,                 // 42
      0, // RES_CHRATR_DUMMY2,                    // 43
      0, // RES_CHRATR_DUMMY3,                    // 44
-    38, // RES_TXTATR_REFMARK,                   // 45
-    39, // RES_TXTATR_TOXMARK,                   // 46
-    40, // RES_TXTATR_META,                      // 47
-    40, // RES_TXTATR_METAFIELD,                 // 48
+    39, // RES_TXTATR_REFMARK,                   // 45
+    40, // RES_TXTATR_TOXMARK,                   // 46
+    41, // RES_TXTATR_META,                      // 47
+    41, // RES_TXTATR_METAFIELD,                 // 48
      0, // RES_TXTATR_AUTOFMT,                   // 49
      0, // RES_TXTATR_INETFMT                    // 50
      0, // RES_TXTATR_CHARFMT,                   // 51
-    41, // RES_TXTATR_CJK_RUBY,                  // 52
+    42, // RES_TXTATR_CJK_RUBY,                  // 52
      0, // RES_TXTATR_UNKNOWN_CONTAINER,         // 53
      0, // RES_TXTATR_DUMMY5                     // 54
 };
@@ -797,6 +797,9 @@ void SwAttrHandler::FontChg(const SfxPoolItem& rItem, SwFont& rFnt, sal_Bool bPu
         case RES_CHRATR_BACKGROUND :
             rFnt.SetBackColor(new Color( ((SvxBrushItem&)rItem).GetColor() ) );
             break;
+        case RES_CHRATR_HIGHLIGHT :
+            rFnt.SetHighLightColor( ((SvxBrushItem&)rItem).GetColor() );
+            break;
         case RES_CHRATR_CJK_FONT :
             rFnt.SetName( ((SvxFontItem&)rItem).GetFamilyName(), SW_CJK );
             rFnt.SetStyleName( ((SvxFontItem&)rItem).GetStyleName(), SW_CJK );
diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index e680672..2de233c 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1171,9 +1171,6 @@ void SwTxtPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
             }
         }
     }
-    if( !m_pFnt->GetBackColor() ) return;
-
-    OSL_ENSURE( m_pFnt->GetBackColor(), "DrawBackBrush: Lost Color" );
 
     SwRect aIntersect;
     CalcRect( rPor, 0, &aIntersect, true );
@@ -1187,7 +1184,15 @@ void SwTxtPaintInfo::DrawBackBrush( const SwLinePortion &rPor ) const
 
         pTmpOut->Push( PUSH_LINECOLOR | PUSH_FILLCOLOR );
 
-        pTmpOut->SetFillColor( *m_pFnt->GetBackColor() );
+        if( m_pFnt->GetHighLightColor() != COL_TRANSPARENT )
+        {
+            pTmpOut->SetFillColor( m_pFnt->GetHighLightColor() );
+        }
+        else
+        {
+            if( !m_pFnt->GetBackColor() ) return;
+            pTmpOut->SetFillColor( *m_pFnt->GetBackColor() );
+        }
         pTmpOut->SetLineColor();
 
         DrawRect( aIntersect, sal_True, sal_False );
diff --git a/sw/source/core/txtnode/swfont.cxx b/sw/source/core/txtnode/swfont.cxx
index bd78bb5..275e2a5 100644
--- a/sw/source/core/txtnode/swfont.cxx
+++ b/sw/source/core/txtnode/swfont.cxx
@@ -665,6 +665,9 @@ void SwFont::SetDiffFnt( const SfxItemSet *pAttrSet,
         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BACKGROUND,
             sal_True, &pItem ))
             pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
+        if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
+            sal_True, &pItem ))
+            SetHighLightColor(((SvxBrushItem*)pItem)->GetColor());
         if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
             sal_True, &pItem ))
         {
@@ -712,6 +715,7 @@ SwFont::SwFont( const SwFont &rFont )
     aSub[SW_CTL] = rFont.aSub[SW_CTL];
     nActual = rFont.nActual;
     pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
+    m_aHighLightColor = rFont.m_aHighLightColor;
     m_aTopBorder = rFont.m_aTopBorder;
     m_aBottomBorder = rFont.m_aBottomBorder;
     m_aRightBorder = rFont.m_aRightBorder;
@@ -843,7 +847,11 @@ SwFont::SwFont( const SwAttrSet* pAttrSet,
         pBackColor = new Color( ((SvxBrushItem*)pItem)->GetColor() );
     else
         pBackColor = NULL;
-
+    if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_HIGHLIGHT,
+        sal_True, &pItem ))
+        SetHighLightColor(((SvxBrushItem*)pItem)->GetColor());
+    else
+        SetHighLightColor(COL_TRANSPARENT);
     if( SFX_ITEM_SET == pAttrSet->GetItemState( RES_CHRATR_BOX,
         sal_True, &pItem ))
     {
@@ -923,6 +931,7 @@ SwFont& SwFont::operator=( const SwFont &rFont )
     nActual = rFont.nActual;
     delete pBackColor;
     pBackColor = rFont.pBackColor ? new Color( *rFont.pBackColor ) : NULL;
+    m_aHighLightColor = rFont.m_aHighLightColor;
     m_aTopBorder = rFont.m_aTopBorder;
     m_aBottomBorder = rFont.m_aBottomBorder;
     m_aRightBorder = rFont.m_aRightBorder;
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 1c1a135..7df9865 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -152,6 +152,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
         { SW_PROP_NMID(UNO_NAME_PARA_HYPHENATION_MAX_HYPHENS),        RES_PARATR_HYPHENZONE,         CPPU_E2T(CPPUTYPE_INT16),         PropertyAttribute::MAYBEVOID, MID_HYPHEN_MAX_HYPHENS                 }, \
         { SW_PROP_NMID(UNO_NAME_CHAR_AUTO_KERNING),                   RES_CHRATR_AUTOKERN,           CPPU_E2T(CPPUTYPE_BOOLEAN),       PropertyAttribute::MAYBEVOID, 0                                      }, \
         { SW_PROP_NMID(UNO_NAME_CHAR_BACK_COLOR),                     RES_CHRATR_BACKGROUND,         CPPU_E2T(CPPUTYPE_INT32),         PropertyAttribute::MAYBEVOID, MID_BACK_COLOR                         }, \
+        { SW_PROP_NMID(UNO_NAME_CHAR_HIGHLIGHT),                      RES_CHRATR_HIGHLIGHT,          CPPU_E2T(CPPUTYPE_INT32), PropertyAttribute::MAYBEVOID, MID_BACK_COLOR                         }, \
         { SW_PROP_NMID(UNO_NAME_PARA_BACK_COLOR),                     RES_BACKGROUND,                CPPU_E2T(CPPUTYPE_INT32),         PropertyAttribute::MAYBEVOID, MID_BACK_COLOR                         }, \
         { SW_PROP_NMID(UNO_NAME_CHAR_CASE_MAP),                       RES_CHRATR_CASEMAP,            CPPU_E2T(CPPUTYPE_INT16),         PropertyAttribute::MAYBEVOID, 0                                      }, \
         { SW_PROP_NMID(UNO_NAME_CHAR_COLOR),                          RES_CHRATR_COLOR,              CPPU_E2T(CPPUTYPE_INT32),         PropertyAttribute::MAYBEVOID, 0                                      }, \
@@ -386,6 +387,7 @@ SwUnoPropertyMapProvider::~SwUnoPropertyMapProvider()
                     { SW_PROP_NMID(UNO_NAME_CHAR_AUTO_KERNING), RES_CHRATR_AUTOKERN  ,  CPPU_E2T(CPPUTYPE_BOOLEAN)  ,       PROPERTY_NONE,     0},\
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_TRANSPARENT), RES_CHRATR_BACKGROUND, CPPU_E2T(CPPUTYPE_BOOLEAN),          PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT       },\
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_COLOR), RES_CHRATR_BACKGROUND,    CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE ,MID_BACK_COLOR        },\
+                    { SW_PROP_NMID(UNO_NAME_CHAR_HIGHLIGHT), RES_CHRATR_HIGHLIGHT, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE ,MID_BACK_COLOR },\
                     { SW_PROP_NMID(UNO_NAME_PARA_BACK_COLOR), RES_BACKGROUND,       CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE ,MID_BACK_COLOR        },\
                     { SW_PROP_NMID(UNO_NAME_PARA_BACK_TRANSPARENT), RES_BACKGROUND,         CPPU_E2T(CPPUTYPE_BOOLEAN),         PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT       },\
                     { SW_PROP_NMID(UNO_NAME_PARA_GRAPHIC_URL), RES_BACKGROUND,      CPPU_E2T(CPPUTYPE_OUSTRING), PROPERTY_NONE ,MID_GRAPHIC_URL    },\
@@ -561,6 +563,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_CHAR_AUTO_KERNING), RES_CHRATR_AUTOKERN  ,  CPPU_E2T(CPPUTYPE_BOOLEAN)  ,       PROPERTY_NONE,     0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_TRANSPARENT), RES_CHRATR_BACKGROUND,  CPPU_E2T(CPPUTYPE_BOOLEAN),         PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT       },
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_COLOR), RES_CHRATR_BACKGROUND,    CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE ,MID_BACK_COLOR        },
+                    { SW_PROP_NMID(UNO_NAME_CHAR_HIGHLIGHT), RES_CHRATR_HIGHLIGHT, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_BACK_COLOR },
                     { SW_PROP_NMID(UNO_NAME_CHAR_CASE_MAP), RES_CHRATR_CASEMAP,     CPPU_E2T(CPPUTYPE_INT16),           PROPERTY_NONE, 0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_COLOR), RES_CHRATR_COLOR,      CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE, 0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_STRIKEOUT), RES_CHRATR_CROSSEDOUT,  CPPU_E2T(CPPUTYPE_INT16),                  PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},
@@ -619,6 +622,7 @@ const SfxItemPropertyMapEntry* SwUnoPropertyMapProvider::GetPropertyMapEntries(s
                     { SW_PROP_NMID(UNO_NAME_CHAR_AUTO_KERNING), RES_CHRATR_AUTOKERN  ,  CPPU_E2T(CPPUTYPE_BOOLEAN)  ,       PROPERTY_NONE,     0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_TRANSPARENT), RES_CHRATR_BACKGROUND,  CPPU_E2T(CPPUTYPE_BOOLEAN),         PROPERTY_NONE ,MID_GRAPHIC_TRANSPARENT       },
                     { SW_PROP_NMID(UNO_NAME_CHAR_BACK_COLOR), RES_CHRATR_BACKGROUND,    CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE ,MID_BACK_COLOR        },
+                    { SW_PROP_NMID(UNO_NAME_CHAR_HIGHLIGHT), RES_CHRATR_HIGHLIGHT, CPPU_E2T(CPPUTYPE_INT32), PROPERTY_NONE, MID_BACK_COLOR },
                     { SW_PROP_NMID(UNO_NAME_CHAR_CASE_MAP), RES_CHRATR_CASEMAP,     CPPU_E2T(CPPUTYPE_INT16),           PROPERTY_NONE, 0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_COLOR), RES_CHRATR_COLOR,      CPPU_E2T(CPPUTYPE_INT32),           PROPERTY_NONE, 0},
                     { SW_PROP_NMID(UNO_NAME_CHAR_STRIKEOUT), RES_CHRATR_CROSSEDOUT,  CPPU_E2T(CPPUTYPE_INT16),                  PropertyAttribute::MAYBEVOID, MID_CROSS_OUT},
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index 2324bd5..ff4d840 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -807,7 +807,7 @@ const SwPropNameTab aPropNameTab = {
 /* 0773 UNO_NAME_SHADOW_TRANSPARENCE */                {MAP_CHAR_LEN("ShadowTransparence")},
 /* 0774 UNO_NAME_DOC_INTEROP_GRAB_BAG */               {MAP_CHAR_LEN("InteropGrabBag")},
 /* 0775 UNO_NAME_FRAME_INTEROP_GRAB_BAG */             {MAP_CHAR_LEN("FrameInteropGrabBag")},
-
+/* 0776 UNO_NAME_CHAR_HIGHLIGHT */                     {MAP_CHAR_LEN("CharHighLight")},
 
 // new items in this array must match enum SwPropNameIds
 };
diff --git a/sw/source/filter/html/css1atr.cxx b/sw/source/filter/html/css1atr.cxx
index 7e82dab..ef3e6c5 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 4ec590c..eb56c84 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 134de6b..4c94fb2 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 1eb94a1..1bb10ee 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 5abb063..50db15b 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 de1ae97..affda61 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 1c5abd5..1fd8304 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 3c37de5..cd198ab 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& );
 
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 031993f..1dfb58d 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -2011,8 +2011,8 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
     case NS_sprm::LN_CHighlight:
         {
             sal_Int32 nColor = 0;
-            if(true ==( mbIsHighlightSet = getColorFromIndex(nIntValue, nColor)))
-                rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( nColor ));
+            if( (mbIsHighlightSet = getColorFromIndex(nIntValue, nColor)) )
+                rContext->Insert(PROP_CHAR_HIGHLIGHT, uno::makeAny( nColor ));
             else if (mnBackgroundColor)
                 rContext->Insert(PROP_CHAR_BACK_COLOR, uno::makeAny( mnBackgroundColor ));
         }
diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx
index 598f97e..f72b4d6 100644
--- a/writerfilter/source/dmapper/PropertyIds.cxx
+++ b/writerfilter/source/dmapper/PropertyIds.cxx
@@ -114,6 +114,7 @@ const OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const
             case PROP_CHAR_TOP_BORDER_DISTANCE: sName = "CharTopBorderDistance";break;
             case PROP_CHAR_BOTTOM_BORDER_DISTANCE: sName = "CharBottomBorderDistance"; break;
             case PROP_CHAR_SHADOW_FORMAT: sName = "CharShadowFormat"; break;
+            case PROP_CHAR_HIGHLIGHT: sName = "CharHighLight"; break;
 
             case PROP_PARA_STYLE_NAME:      sName = "ParaStyleName"; break;
             case PROP_PARA_ADJUST:     sName = "ParaAdjust"; break;
diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx
index 059fc5e..d6c25ff 100644
--- a/writerfilter/source/dmapper/PropertyIds.hxx
+++ b/writerfilter/source/dmapper/PropertyIds.hxx
@@ -91,6 +91,7 @@ enum PropertyIds
         ,PROP_CHAR_HEIGHT_ASIAN
         ,PROP_CHAR_HEIGHT_COMPLEX
         ,PROP_CHAR_HIDDEN
+        ,PROP_CHAR_HIGHLIGHT
         ,PROP_CHAR_LOCALE
         ,PROP_CHAR_LOCALE_ASIAN
         ,PROP_CHAR_LOCALE_COMPLEX


More information about the Libreoffice-commits mailing list