[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - 2 commits - editeng/source include/editeng include/tools tools/source vcl/qa vcl/source
Caolán McNamara
caolanm at redhat.com
Fri Aug 28 04:29:39 PDT 2015
editeng/source/editeng/editattr.cxx | 6 --
editeng/source/items/textitem.cxx | 38 +++++-------------
include/editeng/colritem.hxx | 10 ++--
include/tools/color.hxx | 4 -
tools/source/generic/color.cxx | 2
vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-3.wmf |binary
vcl/source/filter/wmf/enhwmf.cxx | 19 ++++++---
7 files changed, 34 insertions(+), 45 deletions(-)
New commits:
commit 27f6ddefd4b845f3d51221681c864490fa9b580b
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Aug 27 12:21:37 2015 +0100
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 at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index 85676ab..66e664f 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 b55d9ad..587e253 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 bead03e..81f4ac5 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 ea92187..15ba3df 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 cbdc6e4..07d43de 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 );
commit 4970009499a5dfb634b25dc144ee35bac0cf9d31
Author: Caolán McNamara <caolanm at redhat.com>
Date: Thu Aug 27 20:20:01 2015 +0100
don't loop on overly-short nEndPos
Change-Id: I60d3388ece28a69c31a85b9e3b495cbe8a03e7dc
(cherry picked from commit 42732d255423700461f4abadfed77d89efa9cdd0)
Reviewed-on: https://gerrit.libreoffice.org/18084
Reviewed-by: Michael Meeks <michael.meeks at collabora.com>
Tested-by: Michael Meeks <michael.meeks at collabora.com>
diff --git a/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-3.wmf b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-3.wmf
new file mode 100644
index 0000000..80ad795
Binary files /dev/null and b/vcl/qa/cppunit/graphicfilter/data/wmf/fail/hang-3.wmf differ
diff --git a/vcl/source/filter/wmf/enhwmf.cxx b/vcl/source/filter/wmf/enhwmf.cxx
index 1b8dc0d..578fc0a 100644
--- a/vcl/source/filter/wmf/enhwmf.cxx
+++ b/vcl/source/filter/wmf/enhwmf.cxx
@@ -617,7 +617,7 @@ void EnhWMFReader::ReadAndDrawPolyPolygon()
bool EnhWMFReader::ReadEnhWMF()
{
sal_uInt32 nStretchBltMode = 0;
- sal_uInt32 nRecType(0), nRecSize(0), nNextPos(0),
+ sal_uInt32 nNextPos(0),
nW(0), nH(0), nColor(0), nIndex(0),
nDat32(0), nNom1(0), nDen1(0), nNom2(0), nDen2(0);
sal_Int32 nX32(0), nY32(0), nx32(0), ny32(0);
@@ -629,7 +629,8 @@ bool EnhWMFReader::ReadEnhWMF()
while( bStatus && nRecordCount-- && pWMF->good())
{
- pWMF->ReadUInt32( nRecType ).ReadUInt32( nRecSize );
+ sal_uInt32 nRecType(0), nRecSize(0);
+ pWMF->ReadUInt32(nRecType).ReadUInt32(nRecSize);
if ( !pWMF->good() || ( nRecSize < 8 ) || ( nRecSize & 3 ) ) // Parameters are always divisible by 4
{
@@ -637,14 +638,22 @@ bool EnhWMFReader::ReadEnhWMF()
break;
}
- const sal_uInt32 nMaxPossibleRecSize = nEndPos - pWMF->Tell() + 8;
+ auto nCurPos = pWMF->Tell();
+
+ if (nEndPos < nCurPos - 8)
+ {
+ bStatus = false;
+ break;
+ }
+
+ const sal_uInt32 nMaxPossibleRecSize = nEndPos - (nCurPos - 8);
if (nRecSize > nMaxPossibleRecSize)
{
bStatus = false;
break;
}
- nNextPos = pWMF->Tell() + ( nRecSize - 8 );
+ nNextPos = nCurPos + (nRecSize - 8);
if( !aBmpSaveList.empty()
&& ( nRecType != EMR_STRETCHBLT )
@@ -1407,7 +1416,7 @@ bool EnhWMFReader::ReadEnhWMF()
case EMR_EXTTEXTOUTW :
{
sal_Int32 nLeft, nTop, nRight, nBottom, ptlReferenceX, ptlReferenceY, nGfxMode, nXScale, nYScale;
- sal_uInt32 nCurPos, nOffString, nOptions, offDx;
+ sal_uInt32 nOffString, nOptions, offDx;
sal_Int32 nLen;
std::vector<long> aDX;
More information about the Libreoffice-commits
mailing list