Kaydet (Commit) 670dcdd8 authored tarafından Caolán McNamara's avatar Caolán McNamara Kaydeden (comit) Andras Timar

don't write SvxBackgroundColorItem via inherited SvxColorItem::Store

SvxBackgroundColorItem inherits from SvxColorItem and for backwards
compatibility with the StarOffice 5 binary file format (yes, really)
writes/reads only rgb and not the transparency value, so copying and pasting
text from a sidebar comment in writer to itself or another one results in a
black character background as the default COL_AUTO turns into black

Change-Id: I18b5105dd8e060b9e49dda6026e26d3a0f00d8f5
(cherry picked from commit 3bc69b1d)

this farcical staroffice 5.0 related junk can at least be const

Change-Id: I096d98f6e0cb61cacd9cd82a623f832b88ded1e6
(cherry picked from commit 1e8b7cdb)
Reviewed-on: https://gerrit.libreoffice.org/18087Reviewed-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
Tested-by: 's avatarMichael Meeks <michael.meeks@collabora.com>
üst 4c427575
...@@ -221,7 +221,6 @@ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* ) ...@@ -221,7 +221,6 @@ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* )
{ {
Color aColor = static_cast<const SvxColorItem*>(GetItem())->GetValue(); Color aColor = static_cast<const SvxColorItem*>(GetItem())->GetValue();
rFont.SetColor( aColor); rFont.SetColor( aColor);
//fprintf(stderr, "Called SetFont with Color %d\n", aColor.GetColor());
} }
// class EditCharAttribBackgroundColor // class EditCharAttribBackgroundColor
...@@ -238,14 +237,11 @@ EditCharAttribBackgroundColor::EditCharAttribBackgroundColor( ...@@ -238,14 +237,11 @@ EditCharAttribBackgroundColor::EditCharAttribBackgroundColor(
void EditCharAttribBackgroundColor::SetFont( SvxFont& rFont, OutputDevice* ) void EditCharAttribBackgroundColor::SetFont( SvxFont& rFont, OutputDevice* )
{ {
Color aColor = static_cast<const SvxBackgroundColorItem*>(GetItem())->GetValue(); Color aColor = static_cast<const SvxBackgroundColorItem*>(GetItem())->GetValue();
rFont.SetFillColor( aColor);
rFont.SetTransparent(false); rFont.SetTransparent(false);
rFont.SetFillColor(aColor);
} }
// class EditCharAttribLanguage // class EditCharAttribLanguage
EditCharAttribLanguage::EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 _nStart, sal_uInt16 _nEnd ) EditCharAttribLanguage::EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 _nStart, sal_uInt16 _nEnd )
: EditCharAttrib( rAttr, _nStart, _nEnd ) : EditCharAttrib( rAttr, _nStart, _nEnd )
{ {
......
...@@ -1850,9 +1850,12 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol, ...@@ -1850,9 +1850,12 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol,
{ {
} }
SvxBackgroundColorItem:: SvxBackgroundColorItem( SvStream& rStrm, const sal_uInt16 Id ) : SvxBackgroundColorItem::SvxBackgroundColorItem(SvStream& rStrm, const sal_uInt16 nId)
SvxColorItem( rStrm, Id ) : SvxColorItem(nId)
{ {
Color aColor;
aColor.Read(rStrm);
SetValue(aColor);
} }
SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy ) : SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy ) :
...@@ -1862,9 +1865,14 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rC ...@@ -1862,9 +1865,14 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rC
SfxPoolItem* SvxBackgroundColorItem::Clone( SfxItemPool * ) const SfxPoolItem* SvxBackgroundColorItem::Clone( SfxItemPool * ) const
{ {
return new SvxBackgroundColorItem( *this ); return new SvxBackgroundColorItem(*this);
} }
SvStream& SvxBackgroundColorItem::Store(SvStream& rStrm, sal_uInt16) const
{
GetValue().Write(rStrm);
return rStrm;
}
SfxPoolItem* SvxBackgroundColorItem::Create(SvStream& rStrm, sal_uInt16 ) const SfxPoolItem* SvxBackgroundColorItem::Create(SvStream& rStrm, sal_uInt16 ) const
{ {
...@@ -1918,23 +1926,18 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId ...@@ -1918,23 +1926,18 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId
} }
// class SvxColorItem ---------------------------------------------------- // class SvxColorItem ----------------------------------------------------
SvxColorItem::SvxColorItem( const sal_uInt16 nId ) : SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
SfxPoolItem( nId ), SfxPoolItem( nId ),
mColor( COL_BLACK ) mColor( COL_BLACK )
{ {
} }
SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) : SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
SfxPoolItem( nId ), SfxPoolItem( nId ),
mColor( rCol ) mColor( rCol )
{ {
} }
SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) : SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
SfxPoolItem( nId ) SfxPoolItem( nId )
{ {
...@@ -1943,21 +1946,16 @@ SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) : ...@@ -1943,21 +1946,16 @@ SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
mColor = aColor; mColor = aColor;
} }
SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) : SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) :
SfxPoolItem( rCopy ), SfxPoolItem( rCopy ),
mColor( rCopy.mColor ) mColor( rCopy.mColor )
{ {
} }
SvxColorItem::~SvxColorItem() SvxColorItem::~SvxColorItem()
{ {
} }
sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
{ {
DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer || DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
...@@ -1967,8 +1965,6 @@ sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const ...@@ -1967,8 +1965,6 @@ sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
return SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0; return SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0;
} }
bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
{ {
DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" ); DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
...@@ -1976,16 +1972,12 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const ...@@ -1976,16 +1972,12 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
return mColor == static_cast<const SvxColorItem&>( rAttr ).mColor; return mColor == static_cast<const SvxColorItem&>( rAttr ).mColor;
} }
bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{ {
rVal <<= (sal_Int32)(mColor.GetColor()); rVal <<= (sal_Int32)(mColor.GetColor());
return true; return true;
} }
bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{ {
sal_Int32 nColor = 0; sal_Int32 nColor = 0;
...@@ -1996,15 +1988,11 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) ...@@ -1996,15 +1988,11 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
return true; return true;
} }
SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
{ {
return new SvxColorItem( *this ); return new SvxColorItem( *this );
} }
SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
{ {
if( VERSION_USEAUTOCOLOR == nItemVersion && if( VERSION_USEAUTOCOLOR == nItemVersion &&
...@@ -2015,15 +2003,11 @@ SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const ...@@ -2015,15 +2003,11 @@ SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
return rStrm; return rStrm;
} }
SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, sal_uInt16 /*nVer*/ ) const SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, sal_uInt16 /*nVer*/ ) const
{ {
return new SvxColorItem( rStrm, Which() ); return new SvxColorItem( rStrm, Which() );
} }
bool SvxColorItem::GetPresentation bool SvxColorItem::GetPresentation
( (
SfxItemPresentation /*ePres*/, SfxItemPresentation /*ePres*/,
......
...@@ -82,6 +82,7 @@ class EDITENG_DLLPUBLIC SvxBackgroundColorItem : public SvxColorItem ...@@ -82,6 +82,7 @@ class EDITENG_DLLPUBLIC SvxBackgroundColorItem : public SvxColorItem
SvxBackgroundColorItem(const SvxBackgroundColorItem& rCopy); SvxBackgroundColorItem(const SvxBackgroundColorItem& rCopy);
virtual SfxPoolItem* Clone(SfxItemPool* pPool = 0) const SAL_OVERRIDE; virtual SfxPoolItem* Clone(SfxItemPool* pPool = 0) const SAL_OVERRIDE;
virtual SvStream& Store(SvStream& rStream, sal_uInt16 nVersion) const SAL_OVERRIDE;
virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const SAL_OVERRIDE; virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const SAL_OVERRIDE; virtual bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const SAL_OVERRIDE;
virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId = 0) SAL_OVERRIDE; virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId = 0) SAL_OVERRIDE;
......
...@@ -201,7 +201,7 @@ public: ...@@ -201,7 +201,7 @@ public:
} }
SvStream& Read(SvStream& rIStream, bool bNewFormat = true); SvStream& Read(SvStream& rIStream, bool bNewFormat = true);
SvStream& Write(SvStream& rOStream, bool bNewFormat = true); SvStream& Write(SvStream& rOStream, bool bNewFormat = true) const;
TOOLS_DLLPUBLIC friend SvStream& ReadColor(SvStream& rIStream, Color& rColor); TOOLS_DLLPUBLIC friend SvStream& ReadColor(SvStream& rIStream, Color& rColor);
TOOLS_DLLPUBLIC friend SvStream& WriteColor(SvStream& rOStream, const Color& rColor); TOOLS_DLLPUBLIC friend SvStream& WriteColor(SvStream& rOStream, const Color& rColor);
......
...@@ -255,7 +255,7 @@ SvStream& Color::Read( SvStream& rIStm, bool bNewFormat ) ...@@ -255,7 +255,7 @@ SvStream& Color::Read( SvStream& rIStm, bool bNewFormat )
return rIStm; return rIStm;
} }
SvStream& Color::Write( SvStream& rOStm, bool bNewFormat ) SvStream& Color::Write( SvStream& rOStm, bool bNewFormat ) const
{ {
if ( bNewFormat ) if ( bNewFormat )
rOStm.WriteUInt32( mnColor ); rOStm.WriteUInt32( mnColor );
......
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