Kaydet (Commit) 84d4125b authored tarafından Tamás Zolnai's avatar Tamás Zolnai

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: 's avatarTamás Zolnai <tamas.zolnai@collabora.com>
üst 386c1835
......@@ -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();
......
......@@ -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);
......
......@@ -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(
......
......@@ -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)
......
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