diff options
author | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-11 22:25:42 +0200 |
---|---|---|
committer | Bartosz Kosiorek <gang65@poczta.onet.pl> | 2021-06-11 12:31:59 +0200 |
commit | cabb9f5c8e22a23a453559636d9c9b3c2b0a5984 (patch) | |
tree | 7c008d7f21e06e5653e394dd3b118c2955ac865c /emfio/source | |
parent | 2e415a90958bb00f460dccb303bc22853244292b (diff) |
WMF/EMF tdf#59814 tdf#142567 Fix RestoreDC record
With previous implementation, the RestoreDC index argument was skipped,
and always the last entry was taken.
With this commit the support for reading SaveDC by specific index
was added. The SaveDC/RestoreDC index support was added for
both EMF and WMF, according to [MS-WMF] and [MS-EMF] documentation.
Change-Id: I9b8a1a41462ae01de25ac3c85e453bcd80e05537
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117033
Tested-by: Jenkins
Reviewed-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'emfio/source')
-rw-r--r-- | emfio/source/reader/emfreader.cxx | 6 | ||||
-rw-r--r-- | emfio/source/reader/mtftools.cxx | 21 | ||||
-rw-r--r-- | emfio/source/reader/wmfreader.cxx | 5 |
3 files changed, 27 insertions, 5 deletions
diff --git a/emfio/source/reader/emfreader.cxx b/emfio/source/reader/emfreader.cxx index 064a8b0334c9..ac56c64db026 100644 --- a/emfio/source/reader/emfreader.cxx +++ b/emfio/source/reader/emfreader.cxx @@ -1098,7 +1098,11 @@ namespace emfio case EMR_RESTOREDC : { - Pop(); + sal_Int32 nSavedDC; + mpInputStream->ReadInt32( nSavedDC ); + SAL_INFO( "emfio", "\t\t SavedDC Index: " << nSavedDC ); + if ( nSavedDC < 0 ) // For EMF values above -1 is ignored + Pop( nSavedDC ); } break; diff --git a/emfio/source/reader/mtftools.cxx b/emfio/source/reader/mtftools.cxx index 866f6996d9e3..e4d2ed462bdb 100644 --- a/emfio/source/reader/mtftools.cxx +++ b/emfio/source/reader/mtftools.cxx @@ -2452,15 +2452,29 @@ namespace emfio SAL_INFO("emfio", "\t\t WinExt: " << mnWinExtX << " x " << mnWinExtY); SAL_INFO("emfio", "\t\t DevOrg: " << mnDevOrgX << ", " << mnDevOrgY); SAL_INFO("emfio", "\t\t DevWidth/Height: " << mnDevWidth << " x " << mnDevHeight); + SAL_INFO("emfio", "\t\t LineStyle: " << maLineStyle.aLineColor << " FillStyle: " << maFillStyle.aFillColor ); mvSaveStack.push_back( pSave ); } - void MtfTools::Pop() + void MtfTools::Pop( const sal_Int32 nSavedDC ) { - // Get the latest data from the stack - if( mvSaveStack.empty() ) + if ( nSavedDC == 0 ) return; + sal_Int32 aIndex; + if ( nSavedDC < 0 ) // WMF/EMF, if negative, nSavedDC represents an instance relative to the current state. + aIndex = static_cast< sal_Int32 >( mvSaveStack.size() ) + nSavedDC; + else + aIndex = nSavedDC; // WMF, if positive, nSavedDC represents a specific instance of the state to be restored. + if( aIndex < 0 ) + { + mvSaveStack.clear(); + return; + } + if( mvSaveStack.empty() || ( aIndex >= static_cast< sal_Int32 >( mvSaveStack.size() ) ) ) + return; + + mvSaveStack.resize( aIndex + 1 ); // Backup the current data on the stack std::shared_ptr<SaveStruct>& pSave( mvSaveStack.back() ); @@ -2508,6 +2522,7 @@ namespace emfio SAL_INFO("emfio", "\t\t WinExt: " << mnWinExtX << " x " << mnWinExtY); SAL_INFO("emfio", "\t\t DevOrg: " << mnDevOrgX << ", " << mnDevOrgY); SAL_INFO("emfio", "\t\t DevWidth/Height: " << mnDevWidth << " x " << mnDevHeight); + SAL_INFO("emfio", "\t\t LineStyle: " << maLineStyle.aLineColor << " FillStyle: " << maFillStyle.aFillColor ); mvSaveStack.pop_back(); } diff --git a/emfio/source/reader/wmfreader.cxx b/emfio/source/reader/wmfreader.cxx index 64dbf6658854..38f6252afa59 100644 --- a/emfio/source/reader/wmfreader.cxx +++ b/emfio/source/reader/wmfreader.cxx @@ -600,7 +600,10 @@ namespace emfio case W_META_RESTOREDC: { - Pop(); + sal_Int16 nSavedDC; + mpInputStream->ReadInt16( nSavedDC ); + SAL_INFO( "emfio", "\t\t SavedDC: " << nSavedDC ); + Pop( nSavedDC ); } break; |