diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-04-06 18:16:24 +0200 |
---|---|---|
committer | Tamás Zolnai <tamas.zolnai@collabora.com> | 2019-04-06 22:01:48 +0200 |
commit | 84d4125b28c384f9ac6285737a5bb9093978798e (patch) | |
tree | 43abc1d6a9042a6df8173ecab856bf72ad78cea6 | |
parent | 386c1835b22221d1eed4f3b29b874deeb24df87e (diff) |
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@collabora.com>
-rw-r--r-- | sw/source/uibase/docvw/edtwin.cxx | 2 | ||||
-rw-r--r-- | sw/source/uibase/inc/uitool.hxx | 12 | ||||
-rw-r--r-- | sw/source/uibase/shells/textsh1.cxx | 26 | ||||
-rw-r--r-- | sw/source/uibase/utlui/uitool.cxx | 34 |
4 files changed, 50 insertions, 24 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx index 846ffa63ad32..06dcaa126e8b 100644 --- a/sw/source/uibase/docvw/edtwin.cxx +++ b/sw/source/uibase/docvw/edtwin.cxx @@ -4778,7 +4778,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 66791ac0ffc9..f237c83c0952 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 dfdde52dd3e7..630a0476715a 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -1206,11 +1206,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 @@ -1218,25 +1216,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 a2a3ff3e6346..2c84af61fd53 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) |