ofz: emfio, remember where the first free object slot is

Signed-off-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Change-Id: Iadc79d94c1741167641781cdb0cc455d32385219
Reviewed-on: https://gerrit.collaboraoffice.com/c/online/+/7858
Reviewed-by: Noel Grandin <noel.grandin@collabora.com>
Tested-by: Jenkins CPCI <releng@collaboraoffice.com>
(cherry picked from commit 0066c2a9ad09f6372fd9073aecba049ebce8dc7c)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/208698
Tested-by: Jenkins
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
This commit is contained in:
Caolán McNamara
2026-07-28 10:13:24 +02:00
committed by Xisco Fauli
parent 1705455b10
commit 552712e5df
2 changed files with 16 additions and 1 deletions
+3
View File
@@ -685,6 +685,9 @@ namespace emfio
RasterOp meRasterOp;
std::vector< std::unique_ptr<GDIObj> > mvGDIObj;
/// Every slot in mvGDIObj below this index holds an object, so the first free one is here
/// or above.
std::size_t mnLowestFreeGDIObj;
Point maActPos;
WMFRasterOp mnRop;
std::vector< std::shared_ptr<SaveStruct> > mvSaveStack;
+13 -1
View File
@@ -1036,15 +1036,21 @@ namespace emfio
}
}
std::vector<std::unique_ptr<GDIObj>>::size_type nIndex;
for ( nIndex = 0; nIndex < mvGDIObj.size(); nIndex++ )
for ( nIndex = mnLowestFreeGDIObj; nIndex < mvGDIObj.size(); nIndex++ )
{
if ( !mvGDIObj[ nIndex ] )
break;
}
if ( nIndex > 0xffff ) // the same ceiling an indexed object has
{
SAL_WARN( "emfio", "too many objects" );
return;
}
if ( nIndex == mvGDIObj.size() )
ImplResizeObjectArry( mvGDIObj.size() + 16 );
mvGDIObj[ nIndex ] = std::move(pObject);
mnLowestFreeGDIObj = nIndex + 1;
}
void MtfTools::CreateObjectIndexed( sal_uInt32 nIndex, std::unique_ptr<GDIObj> pObject )
@@ -1089,6 +1095,9 @@ namespace emfio
if ( nIndex >= mvGDIObj.size() )
ImplResizeObjectArry( nIndex + 16 );
if ( !pObject && nIndex < mnLowestFreeGDIObj )
mnLowestFreeGDIObj = nIndex;
mvGDIObj[ nIndex ] = std::move(pObject);
}
@@ -1104,6 +1113,8 @@ namespace emfio
if ( nIndex < mvGDIObj.size() )
{
mvGDIObj[ nIndex ].reset();
if ( nIndex < mnLowestFreeGDIObj )
mnLowestFreeGDIObj = nIndex;
}
}
}
@@ -1174,6 +1185,7 @@ namespace emfio
mnBkMode(BackgroundMode::OPAQUE),
meLatestRasterOp(RasterOp::Invert),
meRasterOp(RasterOp::OverPaint),
mnLowestFreeGDIObj(0),
mnRop(),
meGfxMode(GraphicsMode::GM_COMPATIBLE),
meMapMode(MappingMode::MM_TEXT),