include/vcl/vectorgraphicdata.hxx | 5 +++++ vcl/inc/impgraph.hxx | 1 + vcl/qa/cppunit/GraphicTest.cxx | 8 ++++---- vcl/source/gdi/impgraph.cxx | 20 +++++++++++++++++++- 4 files changed, 29 insertions(+), 5 deletions(-)
New commits: commit d6b4a0a9a3fed1ba07125d7e9517f0a663fc4018 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Wed Jul 29 20:57:40 2020 +0200 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Wed Aug 19 10:36:09 2020 +0200 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. Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100836 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> (cherry picked from commit 28beaffba6a0ecaf351c84bed41443a6721d85b6) Change-Id: Ic0fbfc4ad983f7880e06956da3b4664bd4b610d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100883 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> diff --git a/include/vcl/vectorgraphicdata.hxx b/include/vcl/vectorgraphicdata.hxx index 600d477024d0..e81fd9d204fa 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 ca7a53e948d7..9915c4fb260b 100644 --- a/vcl/inc/impgraph.hxx +++ b/vcl/inc/impgraph.hxx @@ -39,6 +39,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 1630a599f7fd..7038ae4c6a11 100644 --- a/vcl/qa/cppunit/GraphicTest.cxx +++ b/vcl/qa/cppunit/GraphicTest.cxx @@ -318,10 +318,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)); } @@ -390,10 +390,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 bbce763e5728..dc0122de050d 100644 --- a/vcl/source/gdi/impgraph.cxx +++ b/vcl/source/gdi/impgraph.cxx @@ -348,6 +348,7 @@ void ImpGraphic::ImplCreateSwapInfo() maSwapInfo.mbIsTransparent = ImplIsTransparent(); maSwapInfo.mbIsAlpha = ImplIsAlpha(); maSwapInfo.mnAnimationLoopCount = ImplGetAnimationLoopCount(); + maSwapInfo.mnPageIndex = getPageNumber(); } } @@ -430,6 +431,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() @@ -1126,6 +1130,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; @@ -1144,6 +1149,11 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm ) TypeSerializer aSerializer(rIStm); aSerializer.readSize(aSize); ReadMapMode( rIStm, aMapMode ); + + if (pCompat->GetVersion() >= 2) + { + rIStm.ReadInt32(nPageIndex); + } } else { @@ -1242,6 +1252,8 @@ bool ImpGraphic::ImplReadEmbedded( SvStream& rIStm ) { ImplSetPrefMapMode( aMapMode ); ImplSetPrefSize( aSize ); + if (maVectorGraphicData) + maVectorGraphicData->setPageIndex(nPageIndex); } } else @@ -1274,7 +1286,7 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) rOStm.WriteUInt32( GRAPHIC_FORMAT_50 ); // write new style header - std::unique_ptr<VersionCompat> pCompat( new VersionCompat( rOStm, StreamMode::WRITE, 1 ) ); + std::unique_ptr<VersionCompat> pCompat( new VersionCompat( rOStm, StreamMode::WRITE, 2 ) ); rOStm.WriteInt32( static_cast<sal_Int32>(meType) ); @@ -1286,6 +1298,9 @@ bool ImpGraphic::ImplWriteEmbedded( SvStream& rOStm ) aSerializer.writeSize(aSize); WriteMapMode( rOStm, aMapMode ); + + // Version 2 + rOStm.WriteInt32(getPageNumber()); } else { @@ -1636,6 +1651,9 @@ bool ImpGraphic::ImplExportNative( SvStream& rOStm ) const sal_Int32 ImpGraphic::getPageNumber() const { + if (ImplIsSwapOut()) + return maSwapInfo.mnPageIndex; + if (maVectorGraphicData) return maVectorGraphicData->getPageIndex(); return -1; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits