vcl: save and load the page number when swapping the graphic
PDF vector graphic includes a page number, of the page that the graphic is rendering. This however isn't remembered when swapping out and back in the graphic, because the serialization format doesn't include it. This adds a version 2 of the serialization format, with an additional page number (page index) attribute. Also changes the GraphicTest to account for an additional 4 bytes written and the change of the checksum. Change-Id: Ic0fbfc4ad983f7880e06956da3b4664bd4b610d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100836 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
This commit is contained in:
committed by
Tomaž Vajngerl
parent
cbafdc3561
commit
28beaffba6
@@ -113,6 +113,11 @@ public:
|
||||
|
||||
sal_Int32 getPageIndex() const { return std::max(sal_Int32(0), mnPageIndex); }
|
||||
|
||||
void setPageIndex(sal_Int32 nPageIndex)
|
||||
{
|
||||
mnPageIndex = nPageIndex;
|
||||
}
|
||||
|
||||
bool isPrimitiveSequenceCreated() const { return mbSequenceCreated; }
|
||||
};
|
||||
|
||||
|
@@ -38,6 +38,7 @@ struct ImpSwapInfo
|
||||
bool mbIsAlpha;
|
||||
|
||||
sal_uInt32 mnAnimationLoopCount;
|
||||
sal_Int32 mnPageIndex;
|
||||
};
|
||||
|
||||
class OutputDevice;
|
||||
|
@@ -335,10 +335,10 @@ void GraphicTest::testSwapping()
|
||||
CPPUNIT_ASSERT_EQUAL(true, bool(xStream));
|
||||
|
||||
// Check size of the stream
|
||||
CPPUNIT_ASSERT_EQUAL(sal_uInt64(445), xStream->remainingSize());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_uInt64(449), xStream->remainingSize());
|
||||
|
||||
std::vector<unsigned char> aHash = calculateHash(xStream);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("304f17d9c56e79b95f6c337dab88709d4f9b61f0"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("878281e583487b29ae09078e8040c01791c7649a"),
|
||||
toHexString(aHash));
|
||||
}
|
||||
|
||||
@@ -407,10 +407,10 @@ void GraphicTest::testSwappingVectorGraphic()
|
||||
CPPUNIT_ASSERT_EQUAL(true, bool(xStream));
|
||||
|
||||
// Check size of the stream
|
||||
CPPUNIT_ASSERT_EQUAL(sal_uInt64(349), xStream->remainingSize());
|
||||
CPPUNIT_ASSERT_EQUAL(sal_uInt64(353), xStream->remainingSize());
|
||||
|
||||
std::vector<unsigned char> aHash = calculateHash(xStream);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("88b4c1c359e3cf7be005fbb46c93ffa6de9dcf4a"),
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("6ae83fc9c06ca253ada0b156d6e4700a4a028c34"),
|
||||
toHexString(aHash));
|
||||
}
|
||||
|
||||
|
@@ -385,6 +385,7 @@ void ImpGraphic::createSwapInfo()
|
||||
maSwapInfo.mbIsTransparent = ImplIsTransparent();
|
||||
maSwapInfo.mbIsAlpha = ImplIsAlpha();
|
||||
maSwapInfo.mnAnimationLoopCount = ImplGetAnimationLoopCount();
|
||||
maSwapInfo.mnPageIndex = getPageNumber();
|
||||
}
|
||||
|
||||
void ImpGraphic::ImplClearGraphics()
|
||||
@@ -442,6 +443,9 @@ void ImpGraphic::ImplSetPrepared(bool bAnimated, const Size* pSizeHint)
|
||||
maSwapInfo.mnAnimationLoopCount = 0;
|
||||
maSwapInfo.mbIsEPS = false;
|
||||
maSwapInfo.mbIsAnimated = bAnimated;
|
||||
|
||||
if (maVectorGraphicData)
|
||||
maSwapInfo.mnPageIndex = maVectorGraphicData->getPageIndex();
|
||||
}
|
||||
|
||||
void ImpGraphic::ImplClear()
|
||||
@@ -1137,6 +1141,7 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
|
||||
Size aSize;
|
||||
sal_uInt32 nId;
|
||||
sal_Int32 nType;
|
||||
sal_Int32 nPageIndex = -1;
|
||||
const SvStreamEndian nOldFormat = rIStm.GetEndian();
|
||||
bool bRet = false;
|
||||
|
||||
@@ -1155,6 +1160,11 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
|
||||
TypeSerializer aSerializer(rIStm);
|
||||
aSerializer.readSize(aSize);
|
||||
ReadMapMode( rIStm, aMapMode );
|
||||
|
||||
if (aCompat.GetVersion() >= 2)
|
||||
{
|
||||
rIStm.ReadInt32(nPageIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1253,6 +1263,8 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm )
|
||||
{
|
||||
ImplSetPrefMapMode( aMapMode );
|
||||
ImplSetPrefSize( aSize );
|
||||
if (maVectorGraphicData)
|
||||
maVectorGraphicData->setPageIndex(nPageIndex);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1284,7 +1296,7 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
|
||||
rOStm.WriteUInt32( GRAPHIC_FORMAT_50 );
|
||||
|
||||
// write new style header
|
||||
VersionCompat aCompat( rOStm, StreamMode::WRITE, 1 );
|
||||
VersionCompat aCompat(rOStm, StreamMode::WRITE, 2);
|
||||
|
||||
rOStm.WriteInt32( static_cast<sal_Int32>(meType) );
|
||||
|
||||
@@ -1296,6 +1308,9 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm )
|
||||
aSerializer.writeSize(aSize);
|
||||
|
||||
WriteMapMode( rOStm, aMapMode );
|
||||
|
||||
// Version 2
|
||||
rOStm.WriteInt32(getPageNumber());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1602,6 +1617,9 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const
|
||||
|
||||
sal_Int32 ImpGraphic::getPageNumber() const
|
||||
{
|
||||
if (isSwappedOut())
|
||||
return maSwapInfo.mnPageIndex;
|
||||
|
||||
if (maVectorGraphicData)
|
||||
return maVectorGraphicData->getPageIndex();
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user