sw/qa/extras/ww8export/ww8export.cxx |   11 +++++++++++
 sw/source/filter/ww8/ww8graf.cxx     |    7 ++++++-
 2 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit b4c55cb614ae1601d7cae4bc87aca3d5396c1598
Author:     Justin Luth <jl...@mail.com>
AuthorDate: Tue Jul 19 14:46:18 2022 -0400
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Wed Jul 20 14:39:24 2022 +0200

    tdf#139759 doc import: import comment highlight/shade
    
    Round-tripping depends on earlier commits for this bug.
    
    These two attributes are SvxColorItems in EditEng,
    but SvxBrushItems in Writer. So direct mapping doesn't work.
    
    Although it might be a highlight, LO doesn't have such a silly
    duplicate thing in the editeng code. So just map this as
    the same thing used for normal char background.
    
    As of LO 7.x, we default to exporting as char background anyway,
    so highlight is on the way out in LO.
    
    P.S. Highlight is one of 17-ish colors. It is the background
    button in the Char panel in MS Word. Background is on Word's
    Para panel (even though it is a character property),
    and so it can fairly easily be removed in MS Word.
    
    Change-Id: Id25879d90ba4a0eeff2d6afed030fc029d1c1039
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/137239
    Reviewed-by: Justin Luth <jl...@mail.com>
    Tested-by: Justin Luth <jl...@mail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/qa/extras/ww8export/ww8export.cxx 
b/sw/qa/extras/ww8export/ww8export.cxx
index 8351541224bc..998b67971e3f 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -29,6 +29,8 @@
 #include <com/sun/star/table/TableBorder2.hpp>
 #include <com/sun/star/text/GraphicCrop.hpp>
 #include <com/sun/star/text/XFormField.hpp>
+#include <com/sun/star/text/XTextField.hpp>
+#include <com/sun/star/text/XTextFieldsSupplier.hpp>
 #include <com/sun/star/text/XTextFramesSupplier.hpp>
 #include <com/sun/star/text/XTextTablesSupplier.hpp>
 #include <com/sun/star/view/DocumentZoomType.hpp>
@@ -1455,6 +1457,15 @@ DECLARE_WW8EXPORT_TEST(testCommentExport, 
"comment-export.odt")
             CPPUNIT_ASSERT_EQUAL(sNames[aTextPortions[i].nAnnotationID], 
xBookmark->getName());
         }
     }
+
+    // tdf#139759 import character highlight and shade for comment text
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    auto xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
+    uno::Reference<text::XText> xText = 
getProperty<uno::Reference<text::XText>>(xField, "TextRange");
+    uno::Reference<text::XTextRange> xParagraph = getParagraphOfText(1, xText);
+    CPPUNIT_ASSERT_EQUAL(COL_WHITE, getProperty<Color>(getRun(xParagraph, 1), 
"CharBackColor"));
 }
 
 #if HAVE_MORE_FONTS
diff --git a/sw/source/filter/ww8/ww8graf.cxx b/sw/source/filter/ww8/ww8graf.cxx
index c10c302cf6c4..01df3d3ea58f 100644
--- a/sw/source/filter/ww8/ww8graf.cxx
+++ b/sw/source/filter/ww8/ww8graf.cxx
@@ -732,7 +732,12 @@ void SwWW8ImplReader::InsertAttrsAsDrawingAttrs(WW8_CP 
nStartCp, WW8_CP nEndCp,
                         nWhich >= RES_FLTRATTR_END )
                     {
                         sal_uInt16 nSlotId = 
m_rDoc.GetAttrPool().GetSlotId(nWhich);
-                        if (
+                        if (nWhich == RES_CHRATR_BACKGROUND || nWhich == 
RES_CHRATR_HIGHLIGHT)
+                        {
+                            Color aColor(static_cast<const 
SvxBrushItem*>(pItem)->GetColor());
+                            pS->Put(SvxColorItem(aColor, EE_CHAR_BKGCOLOR));
+                        }
+                        else if (
                             nSlotId && nWhich != nSlotId &&
                             0 != (nWhich = pEditPool->GetWhich(nSlotId)) &&
                             nWhich != nSlotId

Reply via email to