summaryrefslogtreecommitdiff
path: root/cui
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-08-11 11:51:09 +0100
committerAron Budea <aron.budea@collabora.com>2018-02-05 15:36:43 +0100
commitb0958ff8bf86b86682131b4da99da701a4a72adb (patch)
tree1a89ad3db16a9c3dc80169ce97f850029f980c7f /cui
parent81e6d59738c67e2050428bce9c0f490eebacb7f2 (diff)
Resolves: tdf#110077 move the SvxBackgroundColorItem<->SvxBrushItem conversion
into the dialog itself Reviewed-on: https://gerrit.libreoffice.org/41029 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> (cherry picked from commit 6284804c2ccb3ad8bb6e1c1dac8d622f66b8c07d) Reviewed-on: https://gerrit.libreoffice.org/41168 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com> (cherry picked from commit a407285747c65894bc858c4aa722a24e57caca31) Change-Id: I83db9f02145a4927257dd5691f82dad1a11eaea6
Diffstat (limited to 'cui')
-rw-r--r--cui/source/inc/backgrnd.hxx1
-rw-r--r--cui/source/tabpages/backgrnd.cxx104
2 files changed, 83 insertions, 22 deletions
diff --git a/cui/source/inc/backgrnd.hxx b/cui/source/inc/backgrnd.hxx
index d2663f3cd27e..cd7ab4ffec35 100644
--- a/cui/source/inc/backgrnd.hxx
+++ b/cui/source/inc/backgrnd.hxx
@@ -107,6 +107,7 @@ private:
bool bIsGraphicValid : 1;
bool bLinkOnly : 1;
bool bHighlighting : 1;
+ bool bCharBackColor : 1;
bool m_bColorSelected : 1;
Graphic aBgdGraphic;
OUString aBgdGraphicPath;
diff --git a/cui/source/tabpages/backgrnd.cxx b/cui/source/tabpages/backgrnd.cxx
index 2554da1581b7..ed04e696199c 100644
--- a/cui/source/tabpages/backgrnd.cxx
+++ b/cui/source/tabpages/backgrnd.cxx
@@ -39,6 +39,7 @@
#include <editeng/eerdll.hxx>
#include <editeng/brushitem.hxx>
+#include <editeng/colritem.hxx>
#include "backgrnd.hxx"
#include <svx/xtable.hxx>
@@ -352,6 +353,7 @@ SvxBackgroundTabPage::SvxBackgroundTabPage(vcl::Window* pParent, const SfxItemSe
, bIsGraphicValid(false)
, bLinkOnly(false)
, bHighlighting(false)
+ , bCharBackColor(false)
, m_bColorSelected(false)
, pPageImpl(new SvxBackgroundPage_Impl)
, pImportDlg(nullptr)
@@ -482,7 +484,7 @@ void SvxBackgroundTabPage::Reset( const SfxItemSet* rSet )
// get and evaluate Input-BrushItem
- const SvxBrushItem* pBgdAttr = nullptr;
+ bool bBrushItemSet = false;
sal_uInt16 nSlot = SID_ATTR_BRUSH;
const SfxPoolItem* pItem;
sal_uInt16 nDestValue = USHRT_MAX;
@@ -510,20 +512,39 @@ void SvxBackgroundTabPage::Reset( const SfxItemSet* rSet )
{
nSlot = SID_ATTR_BRUSH_CHAR;
}
+ else if( bCharBackColor )
+ {
+ nSlot = SID_ATTR_CHAR_BACK_COLOR;
+ }
+
//#111173# the destination item is missing when the parent style has been changed
if(USHRT_MAX == nDestValue && m_pTblLBox->IsVisible())
nDestValue = 0;
- sal_uInt16 nWhich = GetWhich( nSlot );
+ sal_uInt16 nWhich = GetWhich(nSlot);
+ SvxBrushItem aBgdAttr(nWhich);
- if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
- pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
+ if (rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT)
+ {
+ if (!bCharBackColor)
+ aBgdAttr = static_cast<const SvxBrushItem&>(rSet->Get(nWhich));
+ else
+ {
+ // EE_CHAR_BKGCOLOR is SvxBackgroundColorItem, but char background tabpage
+ // can only work with SvxBrushItems
+ // extract Color out of SvxBackColorItem
+ Color aBackColor = static_cast<const SvxBackgroundColorItem&>(rSet->Get(nWhich)).GetValue();
+ // make new SvxBrushItem with this Color
+ aBgdAttr = SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR);
+ }
+ bBrushItemSet = true;
+ }
m_pBtnTile->Check();
- if ( pBgdAttr )
+ if (bBrushItemSet)
{
- FillControls_Impl(*pBgdAttr, aUserData);
- aBgdColor = const_cast<SvxBrushItem*>(pBgdAttr)->GetColor();
+ FillControls_Impl(aBgdAttr, aUserData);
+ aBgdColor = aBgdAttr.GetColor();
}
else
{
@@ -558,22 +579,22 @@ void SvxBackgroundTabPage::Reset( const SfxItemSet* rSet )
nWhich = GetWhich( SID_ATTR_BRUSH );
if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
{
- pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
- pTableBck_Impl->pCellBrush = new SvxBrushItem(*pBgdAttr);
+ aBgdAttr = static_cast<const SvxBrushItem&>(rSet->Get(nWhich));
+ pTableBck_Impl->pCellBrush = new SvxBrushItem(aBgdAttr);
}
pTableBck_Impl->nCellWhich = nWhich;
if ( rSet->GetItemState( SID_ATTR_BRUSH_ROW, false ) >= SfxItemState::DEFAULT )
{
- pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( SID_ATTR_BRUSH_ROW ) ));
- pTableBck_Impl->pRowBrush = new SvxBrushItem(*pBgdAttr);
+ aBgdAttr = static_cast<const SvxBrushItem&>(rSet->Get(SID_ATTR_BRUSH_ROW));
+ pTableBck_Impl->pRowBrush = new SvxBrushItem(aBgdAttr);
}
pTableBck_Impl->nRowWhich = SID_ATTR_BRUSH_ROW;
if ( rSet->GetItemState( SID_ATTR_BRUSH_TABLE, false ) >= SfxItemState::DEFAULT )
{
- pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( SID_ATTR_BRUSH_TABLE ) ));
- pTableBck_Impl->pTableBrush = new SvxBrushItem(*pBgdAttr);
+ aBgdAttr = static_cast<const SvxBrushItem&>(rSet->Get(SID_ATTR_BRUSH_TABLE));
+ pTableBck_Impl->pTableBrush = new SvxBrushItem(aBgdAttr);
}
pTableBck_Impl->nTableWhich = SID_ATTR_BRUSH_TABLE;
@@ -585,8 +606,22 @@ void SvxBackgroundTabPage::Reset( const SfxItemSet* rSet )
nWhich = GetWhich( SID_ATTR_BRUSH_CHAR );
if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
{
- pBgdAttr = static_cast<const SvxBrushItem*>(&( rSet->Get( nWhich ) ));
- pHighlighting.reset(new SvxBrushItem(*pBgdAttr));
+ aBgdAttr = static_cast<const SvxBrushItem&>(rSet->Get(nWhich));
+ pHighlighting.reset(new SvxBrushItem(aBgdAttr));
+ }
+ }
+ else if( bCharBackColor )
+ {
+ nWhich = GetWhich(SID_ATTR_CHAR_BACK_COLOR);
+ if ( rSet->GetItemState( nWhich, false ) >= SfxItemState::DEFAULT )
+ {
+ // EE_CHAR_BKGCOLOR is SvxBackgroundColorItem, but char background tabpage
+ // can only work with SvxBrushItems
+ // extract Color out of SvxBackColorItem
+ Color aBackColor = static_cast<const SvxBackgroundColorItem&>(rSet->Get(nWhich)).GetValue();
+ // make new SvxBrushItem with this Color
+ aBgdAttr = SvxBrushItem(aBackColor, SID_ATTR_BRUSH_CHAR);
+ pHighlighting.reset(new SvxBrushItem(aBgdAttr));
}
}
}
@@ -667,6 +702,7 @@ bool SvxBackgroundTabPage::FillItemSet( SfxItemSet* rCoreSet )
return FillItemSetWithWallpaperItem( *rCoreSet, SID_VIEW_FLD_PIC );
bool bModified = false;
+ bool bCompareOldBrush = true;
sal_uInt16 nSlot = SID_ATTR_BRUSH;
if ( m_pTblLBox->IsVisible() )
@@ -688,15 +724,21 @@ bool SvxBackgroundTabPage::FillItemSet( SfxItemSet* rCoreSet )
{
nSlot = SID_ATTR_BRUSH_CHAR;
}
- sal_uInt16 nWhich = GetWhich( nSlot );
+ else if( bCharBackColor )
+ {
+ nSlot = SID_ATTR_CHAR_BACK_COLOR;
+ bCompareOldBrush = false;
+ }
- const SfxPoolItem* pOld = GetOldItem( *rCoreSet, nSlot );
- SfxItemState eOldItemState = rCoreSet->GetItemState(nSlot, false);
- const SfxItemSet& rOldSet = GetItemSet();
+ sal_uInt16 nWhich = GetWhich( nSlot );
- if ( pOld )
+ const SfxPoolItem* pOld = GetOldItem(*rCoreSet, nSlot);
+ if (pOld && bCompareOldBrush)
{
+ SfxItemState eOldItemState = rCoreSet->GetItemState(nSlot, false);
+ const SfxItemSet& rOldSet = GetItemSet();
const SvxBrushItem& rOldItem = static_cast<const SvxBrushItem&>(*pOld);
+
SvxGraphicPosition eOldPos = rOldItem.GetGraphicPos();
const bool bIsBrush = ( drawing::FillStyle_SOLID == lcl_getFillStyle(m_pLbSelect) );
@@ -797,6 +839,22 @@ bool SvxBackgroundTabPage::FillItemSet( SfxItemSet* rCoreSet )
bModified = ( bIsBrush || m_pBtnLink->IsChecked() || bIsGraphicValid );
}
}
+ else if (pOld && SID_ATTR_CHAR_BACK_COLOR == nSlot)
+ {
+ SfxItemState eOldItemState = rCoreSet->GetItemState(nSlot, false);
+ const SfxItemSet& rOldSet = GetItemSet();
+ const SvxBackgroundColorItem& rOldItem = static_cast<const SvxBackgroundColorItem&>(*pOld);
+
+ // Brush-treatment:
+ if ( rOldItem.GetValue() != aBgdColor ||
+ (SfxItemState::DEFAULT >= eOldItemState && m_bColorSelected))
+ {
+ bModified = true;
+ rCoreSet->Put(SvxBackgroundColorItem(aBgdColor, nWhich));
+ }
+ else if ( SfxItemState::DEFAULT == rOldSet.GetItemState( nWhich, false ) )
+ rCoreSet->ClearItem( nWhich );
+ }
else if ( SID_ATTR_BRUSH_CHAR == nSlot && aBgdColor != Color( COL_WHITE ) )
{
rCoreSet->Put( SvxBrushItem( aBgdColor, nWhich ) );
@@ -1549,10 +1607,12 @@ void SvxBackgroundTabPage::PageCreated(const SfxAllItemSet& aSet)
{
ShowSelector();
}
- if ( nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING )
+ if ((nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING) ||
+ (nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR))
{
m_pBackGroundColorLabelFT->SetText(CUI_RES(RID_SVXSTR_CHARNAME_HIGHLIGHTING));
- bHighlighting = true;
+ bHighlighting = bool(nFlags & SvxBackgroundTabFlags::SHOW_HIGHLIGHTING);
+ bCharBackColor = bool(nFlags & SvxBackgroundTabFlags::SHOW_CHAR_BKGCOLOR);
}
}
}