summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorMaxim Monastirsky <momonasmon@gmail.com>2017-01-18 00:13:27 +0200
committerMaxim Monastirsky <momonasmon@gmail.com>2017-01-18 23:38:47 +0200
commitba19b9fd5763c305569ce6ae4120c9e17de6afd4 (patch)
tree4bab145e140938bda121504be888013b97d9de0f /sw
parent79d2cb796a04a8cd1005313019802e63e2ec7ede (diff)
sw: Unify char highlight handlers
SID_ATTR_CHAR_COLOR_BACKGROUND code was mostly a copy-paste of SID_ATTR_CHAR_COLOR_BACKGROUND_EXT. Change-Id: I713bfd72a2f51f2d0ff10b36e9e0a9150b13a640
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/docvw/edtwin.cxx2
-rw-r--r--sw/source/uibase/shells/textsh1.cxx74
2 files changed, 15 insertions, 61 deletions
diff --git a/sw/source/uibase/docvw/edtwin.cxx b/sw/source/uibase/docvw/edtwin.cxx
index 60ab0004de08..eac6d39cfc43 100644
--- a/sw/source/uibase/docvw/edtwin.cxx
+++ b/sw/source/uibase/docvw/edtwin.cxx
@@ -4823,11 +4823,9 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
switch( m_pApplyTempl->nColor )
{
case SID_ATTR_CHAR_COLOR_EXT:
- case SID_ATTR_CHAR_COLOR2:
nId = RES_CHRATR_COLOR;
break;
case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
- case SID_ATTR_CHAR_COLOR_BACKGROUND:
nId = RES_CHRATR_BACKGROUND;
break;
}
diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx
index 081b3c347002..350a7f14cbb0 100644
--- a/sw/source/uibase/shells/textsh1.cxx
+++ b/sw/source/uibase/shells/textsh1.cxx
@@ -1192,73 +1192,21 @@ void SwTextShell::Execute(SfxRequest &rReq)
}
break;
case SID_ATTR_CHAR_COLOR_BACKGROUND:
- {
- Color aSet;
- if(pItem)
- aSet = static_cast<const SvxColorItem*>(pItem)->GetValue();
- else
- aSet = COL_TRANSPARENT;
-
- SwEditWin& rEdtWin = GetView().GetEditWin();
- rEdtWin.SetWaterCanTextBackColor(aSet);
- SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
-
- if(!pApply && (rWrtSh.HasSelection() || rReq.IsAPI()))
- {
- rWrtSh.StartUndo( UNDO_INSATTR );
- SvxBrushItem aBrushItem(RES_CHRATR_BACKGROUND);
- aBrushItem.SetColor(aSet);
- rWrtSh.SetAttrItem( aBrushItem );
-
- // Remove MS specific highlight when background is set
- rWrtSh.SetAttrItem( SvxBrushItem(RES_CHRATR_HIGHLIGHT) );
-
- // Remove shading marker
- SfxItemSet aCoreSet( rWrtSh.GetView().GetPool(), RES_CHRATR_GRABBAG, RES_CHRATR_GRABBAG );
- rWrtSh.GetCurAttr( aCoreSet );
-
- 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 = uno::makeAny(false);
- }
- rWrtSh.SetAttrItem( aGrabBag );
- }
- rWrtSh.EndUndo( UNDO_INSATTR );
- }
- else if(!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
- {
- GetView().GetViewFrame()->GetDispatcher()->Execute(SID_ATTR_CHAR_COLOR_BACKGROUND_EXT);
- }
-
- rReq.Done();
- }
- break;
case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
case SID_ATTR_CHAR_COLOR_EXT:
{
+ Color aSet = pItem ? static_cast<const SvxColorItem*>(pItem)->GetValue() : COL_TRANSPARENT;
SwEditWin& rEdtWin = GetView().GetEditWin();
- if (pItem)
- {
- // The reason we need this argument here is that when a toolbar is closed
- // and reopened, its color resets, while SwEditWin still holds the old one.
- Color aSet = static_cast<const SvxColorItem*>(pItem)->GetValue();
- if( nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
- rEdtWin.SetWaterCanTextBackColor(aSet);
- else
- rEdtWin.SetWaterCanTextColor(aSet);
- }
+ if (nSlot != SID_ATTR_CHAR_COLOR_EXT)
+ rEdtWin.SetWaterCanTextBackColor(aSet);
+ else if (pItem)
+ rEdtWin.SetWaterCanTextColor(aSet);
SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
SwApplyTemplate aTempl;
- if ( rWrtSh.HasSelection() )
+ if (!pApply && (rWrtSh.HasSelection() || rReq.IsAPI()))
{
- if(nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
+ if (nSlot != SID_ATTR_CHAR_COLOR_EXT)
{
rWrtSh.StartUndo( UNDO_INSATTR );
rWrtSh.SetAttrItem(
@@ -1289,6 +1237,14 @@ void SwTextShell::Execute(SfxRequest &rReq)
rWrtSh.SetAttrItem(
SvxColorItem( rEdtWin.GetWaterCanTextColor(), RES_CHRATR_COLOR) );
}
+ else if (nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND)
+ {
+ if (!pApply || pApply->nColor != SID_ATTR_CHAR_COLOR_BACKGROUND_EXT)
+ {
+ aTempl.nColor = SID_ATTR_CHAR_COLOR_BACKGROUND_EXT;
+ rEdtWin.SetApplyTemplate(aTempl);
+ }
+ }
else
{
if(!pApply || pApply->nColor != nSlot)