[Libreoffice-commits] core.git: Branch 'libreoffice-6-2' - sw/source

Tamás Zolnai (via logerrit) logerrit at kemper.freedesktop.org
Thu Apr 18 10:29:10 UTC 2019


 sw/source/uibase/docvw/edtwin.cxx   |    2 +-
 sw/source/uibase/inc/uitool.hxx     |   12 ++++++++++++
 sw/source/uibase/shells/textsh1.cxx |   26 +++-----------------------
 sw/source/uibase/utlui/uitool.cxx   |   34 ++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+), 24 deletions(-)

New commits:
commit bb1e671f2ef54e36102bb3299b44582f46752b4a
Author:     Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Apr 6 18:16:24 2019 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Thu Apr 18 12:28:18 2019 +0200

    tdf#114801: Cannot use the highlight 'bucket' function with docx file
    
    Change-Id: I00df0022a20e83d76484d7c6e7b903ecd3c54aa0
    Reviewed-on: https://gerrit.libreoffice.org/70347
    Tested-by: Jenkins
    Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
    (cherry picked from commit 84d4125b28c384f9ac6285737a5bb9093978798e)
    Reviewed-on: https://gerrit.libreoffice.org/70454
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 4ccbd77d9c1c..0f4a669bcf05 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4750,7 +4750,7 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
                     m_pApplyTempl->nUndo =
                         std::min(m_pApplyTempl->nUndo, rSh.GetDoc()->GetIDocumentUndoRedo().GetUndoActionCount());
                     if (nId == RES_CHRATR_BACKGROUND)
-                        rSh.SetAttrItem( SvxBrushItem( m_aWaterCanTextBackColor, nId ) );
+                        ApplyCharBackground(m_aWaterCanTextBackColor, rSh);
                     else
                         rSh.SetAttrItem( SvxColorItem( m_aWaterCanTextColor, nId ) );
                     rSh.UnSetVisibleCursor();
diff --git a/sw/source/uibase/inc/uitool.hxx b/sw/source/uibase/inc/uitool.hxx
index 68def8b554bc..384005ad6c93 100644
--- a/sw/source/uibase/inc/uitool.hxx
+++ b/sw/source/uibase/inc/uitool.hxx
@@ -37,6 +37,7 @@ class SwFrameFormat;
 class SwTabCols;
 class DateTime;
 class SfxViewFrame;
+class SwEditShell;
 
 // switch a metric
 SW_DLLPUBLIC void SetMetric(MetricFormatter& rCtrl, FieldUnit eUnit);
@@ -60,6 +61,17 @@ SW_DLLPUBLIC void ConvertAttrCharToGen(SfxItemSet& rSet);
 **/
 SW_DLLPUBLIC void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet);
 
+
+/**
+* Apply characeter background on the shell. Need to use this to hide the mixed
+* charachter background and character highlighting attribute, which were
+* added for MSO compatibility where there are two kind of character background.
+*
+* @param[in]       rBackgroundColor    the color to apply on the shell
+* @param[in,out]   rShell              the shell on which we apply the new attirbute
+**/
+SW_DLLPUBLIC void ApplyCharBackground(const Color& rBackgroundColor, SwWrtShell& rShell);
+
 // SfxItemSets <-> PageDesc
 void ItemSetToPageDesc( const SfxItemSet& rSet, SwPageDesc& rPageDesc );
 void PageDescToItemSet( const SwPageDesc& rPageDesc, SfxItemSet& rSet);
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 5a77cbefec63..dde3a8a853e3 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1195,11 +1195,9 @@ void SwTextShell::Execute(SfxRequest &rReq)
             {
                 if (nSlot != SID_ATTR_CHAR_COLOR_EXT)
                 {
-                    rWrtSh.StartUndo( SwUndoId::INSATTR );
-
                     SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), svl::Items<
-                                         RES_CHRATR_BACKGROUND, RES_CHRATR_BACKGROUND,
-                                         RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG>{} );
+                                         RES_CHRATR_BACKGROUND, RES_CHRATR_BACKGROUND>{} );
+
                     rWrtSh.GetCurAttr( aCoreSet );
 
                     // Remove highlight if already set of the same color
@@ -1207,25 +1205,7 @@ void SwTextShell::Execute(SfxRequest &rReq)
                     if ( aSet == rBrushItem.GetColor() )
                         aSet = COL_TRANSPARENT;
 
-                    rWrtSh.SetAttrItem( SvxBrushItem(aSet, RES_CHRATR_BACKGROUND) );
-
-                    // Remove MS specific highlight when background is set
-                    rWrtSh.SetAttrItem( SvxBrushItem(RES_CHRATR_HIGHLIGHT) );
-
-                    // Remove shading marker
-                    const SfxPoolItem *pTmpItem;
-                    if( SfxItemState::SET == aCoreSet.GetItemState( RES_CHRATR_GRABBAG, false, &pTmpItem ) )
-                    {
-                        SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem));
-                        std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag();
-                        auto aIterator = rMap.find("CharShadingMarker");
-                        if( aIterator != rMap.end() )
-                        {
-                            aIterator->second <<= false;
-                        }
-                        rWrtSh.SetAttrItem( aGrabBag );
-                    }
-                    rWrtSh.EndUndo( SwUndoId::INSATTR );
+                    ApplyCharBackground(aSet, rWrtSh);
                 }
                 else
                     rWrtSh.SetAttrItem(
diff --git a/sw/source/uibase/utlui/uitool.cxx b/sw/source/uibase/utlui/uitool.cxx
index aa679eb392e9..93dfd441a0ec 100644
--- a/sw/source/uibase/utlui/uitool.cxx
+++ b/sw/source/uibase/utlui/uitool.cxx
@@ -74,6 +74,7 @@
 #include <docary.hxx>
 #include <charfmt.hxx>
 #include <SwStyleNameMapper.hxx>
+#include <editsh.hxx>
 // 50 cm 28350
 
 #define MAXHEIGHT 28350
@@ -177,6 +178,39 @@ void ConvertAttrGenToChar(SfxItemSet& rSet, const SfxItemSet& rOrigSet)
     rSet.ClearItem( RES_BACKGROUND );
 }
 
+void ApplyCharBackground(const Color& rBackgroundColor, SwWrtShell& rShell)
+{
+    rShell.StartUndo(SwUndoId::INSATTR);
+
+    SfxItemSet aCoreSet(rShell.GetView().GetPool(), svl::Items<
+        RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG>{});
+
+    rShell.GetCurAttr(aCoreSet);
+
+    // Set char background
+    rShell.SetAttrItem(SvxBrushItem(rBackgroundColor, RES_CHRATR_BACKGROUND));
+
+    // Highlight is an MS specific thing, so remove it at the first time when LO modifies
+    // this part of the imported document.
+    rShell.SetAttrItem(SvxBrushItem(RES_CHRATR_HIGHLIGHT));
+
+    // Remove shading marker
+    const SfxPoolItem *pTmpItem;
+    if (SfxItemState::SET == aCoreSet.GetItemState(RES_CHRATR_GRABBAG, false, &pTmpItem))
+    {
+        SfxGrabBagItem aGrabBag(*static_cast<const SfxGrabBagItem*>(pTmpItem));
+        std::map<OUString, css::uno::Any>& rMap = aGrabBag.GetGrabBag();
+        auto aIterator = rMap.find("CharShadingMarker");
+        if (aIterator != rMap.end())
+        {
+            aIterator->second <<= false;
+        }
+        rShell.SetAttrItem(aGrabBag);
+    }
+
+    rShell.EndUndo(SwUndoId::INSATTR);
+}
+
 // Fill header footer
 
 static void FillHdFt(SwFrameFormat* pFormat, const  SfxItemSet& rSet)


More information about the Libreoffice-commits mailing list