[Libreoffice-commits] core.git: sw/source
Tamás Zolnai (via logerrit)
logerrit at kemper.freedesktop.org
Sat Apr 6 20:02: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 84d4125b28c384f9ac6285737a5bb9093978798e
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
AuthorDate: Sat Apr 6 18:16:24 2019 +0200
Commit: Tamás Zolnai <tamas.zolnai at collabora.com>
CommitDate: Sat Apr 6 22:01:48 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>
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)
More information about the Libreoffice-commits
mailing list