summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2020-07-29 20:57:40 +0200
committerTomaž Vajngerl <quikee@gmail.com>2020-08-17 13:45:08 +0200
commit28beaffba6a0ecaf351c84bed41443a6721d85b6 (patch)
treeabef730bf8f67a0a62e520c488165957f3de5ad8
parentcbafdc356133fffce2cc8a0562497ffd460e1c93 (diff)
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>
-rw-r--r--include/vcl/vectorgraphicdata.hxx5
-rw-r--r--vcl/inc/impgraph.hxx1
-rw-r--r--vcl/qa/cppunit/GraphicTest.cxx8
-rw-r--r--vcl/source/gdi/impgraph.cxx20
4 files changed, 29 insertions, 5 deletions
diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx
index 8fce6666e6e8..3d30c03d683d 100644
--- a/include/vcl/vectorgraphicdata.hxx
+++ b/include/vcl/vectorgraphicdata.hxx
@@ -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; }
};
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 8b3cc14b7f2d..a65462a48819 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -38,6 +38,7 @@ struct ImpSwapInfo
bool mbIsAlpha;
sal_uInt32 mnAnimationLoopCount;
+ sal_Int32 mnPageIndex;
};
class OutputDevice;
diff --git a/vcl/qa/cppunit/GraphicTest.cxx b/vcl/qa/cppunit/GraphicTest.cxx
index 6a70ba921942..3d6d0a79b1a9 100644
--- a/vcl/qa/cppunit/GraphicTest.cxx
+++ b/vcl/qa/cppunit/GraphicTest.cxx
@@ -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));
}
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index c40a344ba1da..70609d0b31f8 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -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;