summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-08-27 12:21:37 +0100
committerMichael Meeks <michael.meeks@collabora.com>2015-08-28 11:29:29 +0000
commit27f6ddefd4b845f3d51221681c864490fa9b580b (patch)
tree4e88097c4d2efe0fb5659b95adf898ba543d1c60
parent4970009499a5dfb634b25dc144ee35bac0cf9d31 (diff)
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 (cherry picked from commit 3bc69b1d0d8620afd89a993b5f6bc46a2ff5267f) Change-Id: I18b5105dd8e060b9e49dda6026e26d3a0f00d8f5 Reviewed-on: https://gerrit.libreoffice.org/18074 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--editeng/source/editeng/editattr.cxx6
-rw-r--r--editeng/source/items/textitem.cxx38
-rw-r--r--include/editeng/colritem.hxx10
-rw-r--r--include/tools/color.hxx4
-rw-r--r--tools/source/generic/color.cxx2
5 files changed, 20 insertions, 40 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index 85676abb035e..66e664f0d1a8 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -221,7 +221,6 @@ void EditCharAttribColor::SetFont( SvxFont& rFont, OutputDevice* )
{
Color aColor = static_cast<const SvxColorItem*>(GetItem())->GetValue();
rFont.SetColor( aColor);
- //fprintf(stderr, "Called SetFont with Color %d\n", aColor.GetColor());
}
// class EditCharAttribBackgroundColor
@@ -238,14 +237,11 @@ EditCharAttribBackgroundColor::EditCharAttribBackgroundColor(
void EditCharAttribBackgroundColor::SetFont( SvxFont& rFont, OutputDevice* )
{
Color aColor = static_cast<const SvxBackgroundColorItem*>(GetItem())->GetValue();
- rFont.SetFillColor( aColor);
rFont.SetTransparent(false);
-
+ rFont.SetFillColor(aColor);
}
-
// class EditCharAttribLanguage
-
EditCharAttribLanguage::EditCharAttribLanguage( const SvxLanguageItem& rAttr, sal_uInt16 _nStart, sal_uInt16 _nEnd )
: EditCharAttrib( rAttr, _nStart, _nEnd )
{
diff --git a/editeng/source/items/textitem.cxx b/editeng/source/items/textitem.cxx
index b55d9ad6e5c8..587e25374877 100644
--- a/editeng/source/items/textitem.cxx
+++ b/editeng/source/items/textitem.cxx
@@ -1809,9 +1809,12 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const Color& rCol,
{
}
-SvxBackgroundColorItem:: SvxBackgroundColorItem( SvStream& rStrm, const sal_uInt16 Id ) :
- SvxColorItem( rStrm, Id )
+SvxBackgroundColorItem::SvxBackgroundColorItem(SvStream& rStrm, const sal_uInt16 nId)
+ : SvxColorItem(nId)
{
+ Color aColor;
+ aColor.Read(rStrm);
+ SetValue(aColor);
}
SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy ) :
@@ -1821,9 +1824,14 @@ SvxBackgroundColorItem::SvxBackgroundColorItem( const SvxBackgroundColorItem& rC
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
{
@@ -1877,23 +1885,18 @@ bool SvxBackgroundColorItem::PutValue( const uno::Any& rVal, sal_uInt8 nMemberId
}
// class SvxColorItem ----------------------------------------------------
-
SvxColorItem::SvxColorItem( const sal_uInt16 nId ) :
SfxPoolItem( nId ),
mColor( COL_BLACK )
{
}
-
-
SvxColorItem::SvxColorItem( const Color& rCol, const sal_uInt16 nId ) :
SfxPoolItem( nId ),
mColor( rCol )
{
}
-
-
SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
SfxPoolItem( nId )
{
@@ -1902,21 +1905,16 @@ SvxColorItem::SvxColorItem( SvStream &rStrm, const sal_uInt16 nId ) :
mColor = aColor;
}
-
-
SvxColorItem::SvxColorItem( const SvxColorItem &rCopy ) :
SfxPoolItem( rCopy ),
mColor( rCopy.mColor )
{
}
-
-
SvxColorItem::~SvxColorItem()
{
}
-
sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
{
DBG_ASSERT( SOFFICE_FILEFORMAT_31==nFFVer ||
@@ -1926,8 +1924,6 @@ sal_uInt16 SvxColorItem::GetVersion( sal_uInt16 nFFVer ) const
return SOFFICE_FILEFORMAT_50 >= nFFVer ? VERSION_USEAUTOCOLOR : 0;
}
-
-
bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
{
DBG_ASSERT( SfxPoolItem::operator==(rAttr), "unequal types" );
@@ -1935,16 +1931,12 @@ bool SvxColorItem::operator==( const SfxPoolItem& rAttr ) const
return mColor == static_cast<const SvxColorItem&>( rAttr ).mColor;
}
-
-
bool SvxColorItem::QueryValue( uno::Any& rVal, sal_uInt8 /*nMemberId*/ ) const
{
rVal <<= (sal_Int32)(mColor.GetColor());
return true;
}
-
-
bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
{
sal_Int32 nColor = 0;
@@ -1955,15 +1947,11 @@ bool SvxColorItem::PutValue( const uno::Any& rVal, sal_uInt8 /*nMemberId*/ )
return true;
}
-
-
SfxPoolItem* SvxColorItem::Clone( SfxItemPool * ) const
{
return new SvxColorItem( *this );
}
-
-
SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
{
if( VERSION_USEAUTOCOLOR == nItemVersion &&
@@ -1974,15 +1962,11 @@ SvStream& SvxColorItem::Store( SvStream& rStrm , sal_uInt16 nItemVersion ) const
return rStrm;
}
-
-
SfxPoolItem* SvxColorItem::Create(SvStream& rStrm, sal_uInt16 /*nVer*/ ) const
{
return new SvxColorItem( rStrm, Which() );
}
-
-
bool SvxColorItem::GetPresentation
(
SfxItemPresentation /*ePres*/,
diff --git a/include/editeng/colritem.hxx b/include/editeng/colritem.hxx
index bead03e14e45..81f4ac5d321a 100644
--- a/include/editeng/colritem.hxx
+++ b/include/editeng/colritem.hxx
@@ -91,11 +91,11 @@ class EDITENG_DLLPUBLIC SvxBackgroundColorItem : public SvxColorItem
SvxBackgroundColorItem( SvStream& rStrm, const sal_uInt16 nId );
SvxBackgroundColorItem( const SvxBackgroundColorItem& rCopy );
- virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const SAL_OVERRIDE;
- virtual SfxPoolItem* Create(SvStream &, sal_uInt16) const SAL_OVERRIDE;
-
- virtual bool QueryValue(com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0) const SAL_OVERRIDE;
- virtual bool PutValue(const com::sun::star::uno::Any& rVal, sal_uInt8 nMemberId = 0) 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 bool QueryValue(css::uno::Any& rVal, sal_uInt8 nMemberId = 0) const SAL_OVERRIDE;
+ virtual bool PutValue(const css::uno::Any& rVal, sal_uInt8 nMemberId) SAL_OVERRIDE;
};
#endif
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index ea921878e48c..15ba3df1dc6d 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -156,8 +156,8 @@ public:
bool operator!=( const Color& rColor ) const
{ return !(Color::operator==( rColor )); }
- SvStream& Read( SvStream& rIStm, bool bNewFormat = true );
- SvStream& Write( SvStream& rOStm, bool bNewFormat = true );
+ SvStream& Read(SvStream& rIStream, bool bNewFormat = true);
+ SvStream& Write(SvStream& rOStream, bool bNewFormat = true) const;
TOOLS_DLLPUBLIC friend SvStream& ReadColor( SvStream& rIStream, Color& rColor );
TOOLS_DLLPUBLIC friend SvStream& WriteColor( SvStream& rOStream, const Color& rColor );
diff --git a/tools/source/generic/color.cxx b/tools/source/generic/color.cxx
index cbdc6e4c8112..07d43dec803d 100644
--- a/tools/source/generic/color.cxx
+++ b/tools/source/generic/color.cxx
@@ -222,7 +222,7 @@ SvStream& Color::Read( SvStream& rIStm, bool bNewFormat )
return rIStm;
}
-SvStream& Color::Write( SvStream& rOStm, bool bNewFormat )
+SvStream& Color::Write( SvStream& rOStm, bool bNewFormat ) const
{
if ( bNewFormat )
rOStm.WriteUInt32( mnColor );