diff options
author | Gülşah Köse <gulsah.kose@collabora.com> | 2021-05-28 01:23:53 +0300 |
---|---|---|
committer | Gülşah Köse <gulsah.kose@collabora.com> | 2021-05-31 11:36:18 +0200 |
commit | 936af331ba6f5073aeaa0f10f5f2af1def1d74c6 (patch) | |
tree | e145eb9a5f7b9fe05a7f7832cf6eb76388cc4662 /editeng | |
parent | 7d34a7777cfeec112ab5cdabba059d01d8876be4 (diff) |
Clean redundant SvxBackgroundColorItem and use SvxColorItem instead.
SvxBackgroundColorItem is just copied from SvxColorItem. There is
nothing special to SvxBackgroundColorItem class. SvxColorItem is a
generic item and it's used on many places related with colors. We can
use SvxColorItem for background colors too.
Change-Id: Iacea31a7557b806e95f5859ff60add9a2626ec05
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116282
Reviewed-by: Jan Holesovsky <kendy@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'editeng')
-rw-r--r-- | editeng/inc/editattr.hxx | 3 | ||||
-rw-r--r-- | editeng/source/editeng/editattr.cxx | 4 | ||||
-rw-r--r-- | editeng/source/editeng/editdbg.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/editdoc.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/editeng.cxx | 2 | ||||
-rw-r--r-- | editeng/source/editeng/eerdll.cxx | 2 | ||||
-rw-r--r-- | editeng/source/items/textitem.cxx | 122 |
7 files changed, 17 insertions, 120 deletions
diff --git a/editeng/inc/editattr.hxx b/editeng/inc/editattr.hxx index f0a6ec58da76..502a5b084605 100644 --- a/editeng/inc/editattr.hxx +++ b/editeng/inc/editattr.hxx @@ -38,7 +38,6 @@ class SvxOverlineItem; class SvxFontHeightItem; class SvxCharScaleWidthItem; class SvxColorItem; -class SvxBackgroundColorItem; class SvxAutoKernItem; class SvxKerningItem; class SvxWordLineModeItem; @@ -301,7 +300,7 @@ public: class EditCharAttribBackgroundColor final : public EditCharAttrib { public: - EditCharAttribBackgroundColor(const SvxBackgroundColorItem& rAttr, + EditCharAttribBackgroundColor(const SvxColorItem& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); virtual void SetFont(SvxFont& rFont, OutputDevice* pOutDev) override; diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx index dc5b50395441..5d7da53de477 100644 --- a/editeng/source/editeng/editattr.cxx +++ b/editeng/source/editeng/editattr.cxx @@ -219,7 +219,7 @@ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* ) EditCharAttribBackgroundColor::EditCharAttribBackgroundColor( - const SvxBackgroundColorItem& rAttr, + const SvxColorItem& rAttr, sal_Int32 _nStart, sal_Int32 _nEnd ) : EditCharAttrib( rAttr, _nStart, _nEnd ) @@ -229,7 +229,7 @@ EditCharAttribBackgroundColor::EditCharAttribBackgroundColor( void EditCharAttribBackgroundColor::SetFont( SvxFont& rFont, OutputDevice* ) { - Color aColor = static_cast<const SvxBackgroundColorItem*>(GetItem())->GetValue(); + Color aColor = static_cast<const SvxColorItem*>(GetItem())->GetValue(); rFont.SetTransparent(false); rFont.SetFillColor(aColor); } diff --git a/editeng/source/editeng/editdbg.cxx b/editeng/source/editeng/editdbg.cxx index 9a005809d617..18b5747bb5bf 100644 --- a/editeng/source/editeng/editdbg.cxx +++ b/editeng/source/editeng/editdbg.cxx @@ -180,7 +180,7 @@ static OString DbgOutItem(const SfxItemPool& rPool, const SfxPoolItem& rItem) case EE_CHAR_BKGCOLOR: { aDebStr.append("FillColor= "); - Color aColor( static_cast<const SvxBackgroundColorItem&>(rItem).GetValue() ); + Color aColor( static_cast<const SvxColorItem&>(rItem).GetValue() ); aDebStr.append(static_cast<sal_Int32>(aColor.GetRed())); aDebStr.append(", "); aDebStr.append(static_cast<sal_Int32>(aColor.GetGreen())); diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx index fcf2f7811e56..2a7f43032245 100644 --- a/editeng/source/editeng/editdoc.cxx +++ b/editeng/source/editeng/editdoc.cxx @@ -352,7 +352,7 @@ EditCharAttrib* MakeCharAttrib( SfxItemPool& rPool, const SfxPoolItem& rAttr, sa break; case EE_CHAR_BKGCOLOR: { - pNew = new EditCharAttribBackgroundColor( static_cast<const SvxBackgroundColorItem&>(rNew), nS, nE ); + pNew = new EditCharAttribBackgroundColor( static_cast<const SvxColorItem&>(rNew), nS, nE ); } break; default: diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 60165977fc32..f34c4c2f6637 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -2642,7 +2642,7 @@ void EditEngine::SetFontInfoInItemSet( SfxItemSet& rSet, const SvxFont& rFont ) rSet.Put( SvxEscapementItem( rFont.GetEscapement(), rFont.GetPropr(), EE_CHAR_ESCAPEMENT ) ); rSet.Put( SvxWeightItem( rFont.GetWeight(), EE_CHAR_WEIGHT ) ); rSet.Put( SvxColorItem( rFont.GetColor(), EE_CHAR_COLOR ) ); - rSet.Put( SvxBackgroundColorItem( rFont.GetFillColor(), EE_CHAR_BKGCOLOR ) ); + rSet.Put( SvxColorItem( rFont.GetFillColor(), EE_CHAR_BKGCOLOR ) ); rSet.Put( SvxUnderlineItem( rFont.GetUnderline(), EE_CHAR_UNDERLINE ) ); rSet.Put( SvxOverlineItem( rFont.GetOverline(), EE_CHAR_OVERLINE ) ); rSet.Put( SvxCrossedOutItem( rFont.GetStrikeout(), EE_CHAR_STRIKEOUT ) ); diff --git a/editeng/source/editeng/eerdll.cxx b/editeng/source/editeng/eerdll.cxx index a88415565f7e..bc3bb4c82b35 100644 --- a/editeng/source/editeng/eerdll.cxx +++ b/editeng/source/editeng/eerdll.cxx @@ -140,7 +140,7 @@ DefItems::DefItems() rDefItems[48] = new SvxOverlineItem( LINESTYLE_NONE, EE_CHAR_OVERLINE ); rDefItems[49] = new SvxCaseMapItem( SvxCaseMap::NotMapped, EE_CHAR_CASEMAP ); rDefItems[50] = new SfxGrabBagItem( EE_CHAR_GRABBAG ); - rDefItems[51] = new SvxBackgroundColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ); + rDefItems[51] = new SvxColorItem( COL_AUTO, EE_CHAR_BKGCOLOR ); // Features rDefItems[52] = new SfxVoidItem( EE_FEATURE_TAB ); rDefItems[53] = new SfxVoidItem( EE_FEATURE_LINEBR ); diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx index d67bd02df5c1..53f5328890b2 100644 --- a/editeng/source/items/textitem.cxx +++ b/editeng/source/items/textitem.cxx @@ -93,7 +93,6 @@ SfxPoolItem* SvxAutoKernItem::CreateDefault() {return new SvxAutoKernItem(false, SfxPoolItem* SvxWordLineModeItem::CreateDefault() {return new SvxWordLineModeItem(false, 0);} SfxPoolItem* SvxContourItem::CreateDefault() {return new SvxContourItem(false, 0);} SfxPoolItem* SvxColorItem::CreateDefault() {return new SvxColorItem(0);} -SfxPoolItem* SvxBackgroundColorItem::CreateDefault() {return new SvxBackgroundColorItem(0);} SfxPoolItem* SvxKerningItem::CreateDefault() {return new SvxKerningItem(0, 0);} SfxPoolItem* SvxCaseMapItem::CreateDefault() {return new SvxCaseMapItem(SvxCaseMap::NotMapped, 0);} SfxPoolItem* SvxEscapementItem::CreateDefault() {return new SvxEscapementItem(0);} @@ -1310,117 +1309,6 @@ bool SvxContourItem::GetPresentation return true; } -// class SvxBackgroundColorItem ----------------------------------------- - -SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId ) : - SfxPoolItem( nId ), - mColor( COL_WHITE ) -{ -} - -SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol, const sal_uInt16 nId ) : - SfxPoolItem( nId ), - mColor( rCol ) -{ -} - -SvxBackgroundColorItem::~SvxBackgroundColorItem() -{ -} - -bool SvxBackgroundColorItem::operator==( const SfxPoolItem& rAttr ) const -{ - assert(SfxPoolItem::operator==(rAttr)); - - return mColor == static_cast<const SvxBackgroundColorItem&>( rAttr ).mColor; -} - -bool SvxBackgroundColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const -{ - nMemberId &= ~CONVERT_TWIPS; - Color aColor = SvxBackgroundColorItem::GetValue(); - - switch( nMemberId ) - { - case MID_GRAPHIC_TRANSPARENT: - { - rVal <<= aColor.GetAlpha() == 0; - break; - } - default: - { - rVal <<= aColor; - break; - } - } - return true; -} - -bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) -{ - nMemberId &= ~CONVERT_TWIPS; - Color nColor; - Color aColor = SvxBackgroundColorItem::GetValue(); - - switch( nMemberId ) - { - case MID_GRAPHIC_TRANSPARENT: - { - aColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); - SvxBackgroundColorItem::SetValue( aColor ); - break; - } - default: - { - if(!(rVal >>= nColor)) - return false; - SvxBackgroundColorItem::SetValue( nColor ); - break; - } - } - return true; -} - -SvxBackgroundColorItem* SvxBackgroundColorItem::Clone( SfxItemPool * ) const -{ - return new SvxBackgroundColorItem(*this); -} - - -bool SvxBackgroundColorItem::GetPresentation -( - SfxItemPresentation /*ePres*/, - MapUnit /*eCoreUnit*/, - MapUnit /*ePresUnit*/, - OUString& rText, const IntlWrapper& /*rIntl*/ -) const -{ - rText = ::GetColorString( mColor ); - return true; -} - -void SvxBackgroundColorItem::dumpAsXml(xmlTextWriterPtr pWriter) const -{ - (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxBackgroundColorItem")); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr())); - - std::stringstream ss; - ss << mColor; - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(ss.str().c_str())); - - OUString aStr; - IntlWrapper aIntlWrapper(SvtSysLocale().GetUILanguageTag()); - GetPresentation( SfxItemPresentation::Complete, MapUnit::Map100thMM, MapUnit::Map100thMM, aStr, aIntlWrapper); - (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("presentation"), BAD_CAST(OUStringToOString(aStr, RTL_TEXTENCODING_UTF8).getStr())); - (void)xmlTextWriterEndElement(pWriter); -} - -void SvxBackgroundColorItem::SetValue( const Color& rNewCol ) -{ - mColor = rNewCol; -} - - // class SvxColorItem ---------------------------------------------------- SvxColorItem::SvxColorItem( const sal_uInt16 nId ) : SfxPoolItem( nId ), @@ -1456,6 +1344,11 @@ bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) const rVal <<= static_cast<sal_Int16>(basegfx::fround(fTransparency)); break; } + case MID_GRAPHIC_TRANSPARENT: + { + rVal <<= mColor.GetAlpha() == 0; + break; + } default: { rVal <<= mColor; @@ -1481,6 +1374,11 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ) } return bRet; } + case MID_GRAPHIC_TRANSPARENT: + { + mColor.SetAlpha( Any2Bool( rVal ) ? 0 : 255 ); + return true; + } default: { return rVal >>= mColor; |