summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorGülşah Köse <gulsah.kose@collabora.com>2021-05-26 08:47:38 +0300
committerAndras Timar <andras.timar@collabora.com>2021-05-28 12:18:03 +0200
commit672044c7e5eb4d1b506593de0b843d31c9ec0780 (patch)
tree0136e535643393ece136a173b4f421ac52740a4c /editeng
parent1ecc7cd62b5fb571f6f7599ceea90aecc8a6f9f1 (diff)
Seperate SvxBackgroundColorItem from SvxColorItem
SvxBackgroundColorItem derivated from SfxPoolItem instead of SvxColorItem. Casting is common usage to control if object is this or not. When we can cast SvxBackgroundColorItem to SvxColorItem we can not seperate them anymore. eg: Char color is a SvxColorItem and char background color is a SvxBackgroundColorItem. They can be hold together and we should understand they are different types. Change-Id: I7b1879a1b00de26c0b8a2d9f8d658aa3aef75ecb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116135 Tested-by: Jenkins Reviewed-by: Gülşah Köse <gulsah.kose@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116185 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/items/textitem.cxx68
1 files changed, 57 insertions, 11 deletions
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index 53c1baaa7223..ec800e9d5eb4 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1356,26 +1356,32 @@ bool SvxContourItem::GetPresentation
// class SvxBackgroundColorItem -----------------------------------------
SvxBackgroundColorItem::SvxBackgroundColorItem( const sal_uInt16 nId ) :
- SvxColorItem( nId )
+ SfxPoolItem( nId ),
+ mColor( COL_WHITE )
{
}
+SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol, const sal_uInt16 nId ) :
+ SfxPoolItem( nId ),
+ mColor( rCol )
+{
+}
-SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol,
- const sal_uInt16 nId ) :
- SvxColorItem( rCol, nId )
+SvxBackgroundColorItem::~SvxBackgroundColorItem()
{
}
-SfxPoolItem* SvxBackgroundColorItem::Clone( SfxItemPool * ) const
+bool SvxBackgroundColorItem::operator==( const SfxPoolItem& rAttr ) const
{
- return new SvxBackgroundColorItem(*this);
+ 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 = SvxColorItem::GetValue();
+ Color aColor = SvxBackgroundColorItem::GetValue();
switch( nMemberId )
{
@@ -1396,28 +1402,68 @@ bool SvxBackgroundColorItem::QueryValue( uno::Any& rVal, sal_uInt8 nMemberId ) c
bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId )
{
nMemberId &= ~CONVERT_TWIPS;
- sal_Int32 nColor = 0;
- Color aColor = SvxColorItem::GetValue();
+ Color nColor;
+ Color aColor = SvxBackgroundColorItem::GetValue();
switch( nMemberId )
{
case MID_GRAPHIC_TRANSPARENT:
{
aColor.SetTransparency( Any2Bool( rVal ) ? 0xff : 0 );
- SvxColorItem::SetValue( aColor );
+ SvxBackgroundColorItem::SetValue( aColor );
break;
}
default:
{
if(!(rVal >>= nColor))
return false;
- SvxColorItem::SetValue( Color(nColor) );
+ 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 ),