Kaydet (Commit) ba19b9fd authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

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
üst 79d2cb79
...@@ -4823,11 +4823,9 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt) ...@@ -4823,11 +4823,9 @@ void SwEditWin::MouseButtonUp(const MouseEvent& rMEvt)
switch( m_pApplyTempl->nColor ) switch( m_pApplyTempl->nColor )
{ {
case SID_ATTR_CHAR_COLOR_EXT: case SID_ATTR_CHAR_COLOR_EXT:
case SID_ATTR_CHAR_COLOR2:
nId = RES_CHRATR_COLOR; nId = RES_CHRATR_COLOR;
break; break;
case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT: case SID_ATTR_CHAR_COLOR_BACKGROUND_EXT:
case SID_ATTR_CHAR_COLOR_BACKGROUND:
nId = RES_CHRATR_BACKGROUND; nId = RES_CHRATR_BACKGROUND;
break; break;
} }
......
...@@ -1192,73 +1192,21 @@ void SwTextShell::Execute(SfxRequest &rReq) ...@@ -1192,73 +1192,21 @@ void SwTextShell::Execute(SfxRequest &rReq)
} }
break; break;
case SID_ATTR_CHAR_COLOR_BACKGROUND: 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_BACKGROUND_EXT:
case SID_ATTR_CHAR_COLOR_EXT: case SID_ATTR_CHAR_COLOR_EXT:
{ {
Color aSet = pItem ? static_cast<const SvxColorItem*>(pItem)->GetValue() : COL_TRANSPARENT;
SwEditWin& rEdtWin = GetView().GetEditWin(); SwEditWin& rEdtWin = GetView().GetEditWin();
if (pItem) if (nSlot != SID_ATTR_CHAR_COLOR_EXT)
{ rEdtWin.SetWaterCanTextBackColor(aSet);
// The reason we need this argument here is that when a toolbar is closed else if (pItem)
// and reopened, its color resets, while SwEditWin still holds the old one. rEdtWin.SetWaterCanTextColor(aSet);
Color aSet = static_cast<const SvxColorItem*>(pItem)->GetValue();
if( nSlot == SID_ATTR_CHAR_COLOR_BACKGROUND_EXT )
rEdtWin.SetWaterCanTextBackColor(aSet);
else
rEdtWin.SetWaterCanTextColor(aSet);
}
SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate(); SwApplyTemplate* pApply = rEdtWin.GetApplyTemplate();
SwApplyTemplate aTempl; 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.StartUndo( UNDO_INSATTR );
rWrtSh.SetAttrItem( rWrtSh.SetAttrItem(
...@@ -1289,6 +1237,14 @@ void SwTextShell::Execute(SfxRequest &rReq) ...@@ -1289,6 +1237,14 @@ void SwTextShell::Execute(SfxRequest &rReq)
rWrtSh.SetAttrItem( rWrtSh.SetAttrItem(
SvxColorItem( rEdtWin.GetWaterCanTextColor(), RES_CHRATR_COLOR) ); 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 else
{ {
if(!pApply || pApply->nColor != nSlot) if(!pApply || pApply->nColor != nSlot)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment