diff options
author | Armin Le Grand <alg@apache.org> | 2012-06-12 10:30:36 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2012-06-12 10:30:36 +0000 |
commit | a379ffae809a4b9f92fbde9b9699f5353f7b3472 (patch) | |
tree | 9ea63f68b1be42a97582d744b75085967d73d2fd /svtools | |
parent | 53ba60618af3977f5e5488225dcf050a517fb5b8 (diff) |
#117968# Made WMFReader thread safe (used multithreaded when SdrGrafObj is on asynchronous loading). It was not safe due to using VirtualDevices on occasions where needed (mostly Font stuff).
Notes
Notes:
merged as: 93ce5834a6651a2d3ccf6e56336b1ec48c7905f2
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/filter/wmf/winmtf.cxx | 43 | ||||
-rw-r--r-- | svtools/source/filter/wmf/winmtf.hxx | 3 | ||||
-rw-r--r-- | svtools/source/filter/wmf/winwmf.cxx | 6 |
3 files changed, 30 insertions, 22 deletions
diff --git a/svtools/source/filter/wmf/winmtf.cxx b/svtools/source/filter/wmf/winmtf.cxx index 7e8c59f0ec08..208574081432 100644 --- a/svtools/source/filter/wmf/winmtf.cxx +++ b/svtools/source/filter/wmf/winmtf.cxx @@ -29,6 +29,8 @@ #include <vcl/metaact.hxx> #include <vcl/metric.hxx> #include <rtl/tencinfo.h> +#include <vcl/svapp.hxx> +#include <vcl/virdev.hxx> // ------------------------------------------------------------------------ @@ -280,8 +282,11 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont ) Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) ); if ( rFont.lfHeight > 0 ) { - // converting the cell height into a font height + // #117968# VirtualDevice is not thread safe, but filter is used in multithreading + vos::OGuard aGuard( Application::GetSolarMutex() ); VirtualDevice aVDev; + + // converting the cell height into a font height aFont.SetSize( aFontSize ); aVDev.SetFont( aFont ); FontMetric aMetric( aVDev.GetFontMetric() ); @@ -297,7 +302,10 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont ) if ( !rFont.lfWidth ) { + // #117968# VirtualDevice is not thread safe, but filter is used in multithreading + vos::OGuard aGuard( Application::GetSolarMutex() ); VirtualDevice aVDev; + aFont.SetSize( aFontSize ); aVDev.SetFont( aFont ); FontMetric aMetric( aVDev.GetFontMetric() ); @@ -1457,13 +1465,10 @@ void WinMtfOutput::DrawPolyBezier( Polygon& rPolygon, sal_Bool bTo, sal_Bool bRe void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry, sal_Bool bRecordPath, sal_Int32 nGfxMode ) { UpdateClipRegion(); - - VirtualDevice* pVDev = NULL; - rPosition = ImplMap( rPosition ); - sal_Int32 nOldGfxMode = GetGfxMode(); SetGfxMode( GM_COMPATIBLE ); + if ( pDXArry ) { sal_Int32 i, nSum, nLen = rText.Len(); @@ -1556,20 +1561,23 @@ void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry if( mnTextAlign & ( TA_UPDATECP | TA_RIGHT_CENTER ) ) { - if ( !pVDev ) - pVDev = new VirtualDevice; + // #117968# VirtualDevice is not thread safe, but filter is used in multithreading + vos::OGuard aGuard( Application::GetSolarMutex() ); + VirtualDevice aVDev; sal_Int32 nTextWidth; - pVDev->SetMapMode( MapMode( MAP_100TH_MM ) ); - pVDev->SetFont( maFont ); + + aVDev.SetMapMode( MapMode( MAP_100TH_MM ) ); + aVDev.SetFont( maFont ); + if( pDXArry ) { sal_uInt32 nLen = rText.Len(); - nTextWidth = pVDev->GetTextWidth( rText.GetChar( (sal_uInt16)( nLen - 1 ) ) ); + nTextWidth = aVDev.GetTextWidth( rText.GetChar( (sal_uInt16)( nLen - 1 ) ) ); if( nLen > 1 ) nTextWidth += pDXArry[ nLen - 2 ]; } else - nTextWidth = pVDev->GetTextWidth( rText ); + nTextWidth = aVDev.GetTextWidth( rText ); if( mnTextAlign & TA_UPDATECP ) rPosition = maActPos; @@ -1603,19 +1611,20 @@ void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry sal_Int32* pDX = pDXArry; if ( !pDXArry ) { + // #117968# VirtualDevice is not thread safe, but filter is used in multithreading + vos::OGuard aGuard( Application::GetSolarMutex() ); + VirtualDevice aVDev; + pDX = new sal_Int32[ rText.Len() ]; - if ( !pVDev ) - pVDev = new VirtualDevice; - pVDev->SetMapMode( MAP_100TH_MM ); - pVDev->SetFont( maLatestFont ); - pVDev->GetTextArray( rText, pDX, 0, STRING_LEN ); + aVDev.SetMapMode( MAP_100TH_MM ); + aVDev.SetFont( maLatestFont ); + aVDev.GetTextArray( rText, pDX, 0, STRING_LEN ); } mpGDIMetaFile->AddAction( new MetaTextArrayAction( rPosition, rText, pDX, 0, STRING_LEN ) ); if ( !pDXArry ) // this means we have created our own array delete[] pDX; // which must be deleted } SetGfxMode( nOldGfxMode ); - delete pVDev; } //----------------------------------------------------------------------------------- diff --git a/svtools/source/filter/wmf/winmtf.hxx b/svtools/source/filter/wmf/winmtf.hxx index 211a00fe8405..a5af20f86f04 100644 --- a/svtools/source/filter/wmf/winmtf.hxx +++ b/svtools/source/filter/wmf/winmtf.hxx @@ -39,7 +39,6 @@ #include <tools/table.hxx> #include <tools/dynary.hxx> #include <vcl/graph.hxx> -#include <vcl/virdev.hxx> #include <tools/poly.hxx> #include <vcl/font.hxx> #include <vcl/bmpacc.hxx> @@ -724,8 +723,6 @@ public: class WMFReader : public WinMtf { private: - - VirtualDevice aVDev; // just for the purpose of "IsFontAvailable" sal_uInt16 nUnitsPerInch; sal_uInt32 nRecSize; diff --git a/svtools/source/filter/wmf/winwmf.cxx b/svtools/source/filter/wmf/winwmf.cxx index 5a8c86436505..5d8d0e06dcae 100644 --- a/svtools/source/filter/wmf/winwmf.cxx +++ b/svtools/source/filter/wmf/winwmf.cxx @@ -29,6 +29,7 @@ #include <rtl/crc.h> #include <rtl/tencinfo.h> #include <osl/endian.h> +#include <vcl/svapp.hxx> //====================== MS-Windows-defines =============================== @@ -872,8 +873,9 @@ void WMFReader::ReadRecordParams( sal_uInt16 nFunc ) switch( nEsc ) { case PRIVATE_ESCAPE_UNICODE : - { // we will use text instead of polygons only if we have the correct font - if ( aVDev.IsFontAvailable( pOut->GetFont().GetName() ) ) + { + // we will use text instead of polygons only if we have the correct font + if ( Application::GetDefaultDevice()->IsFontAvailable( pOut->GetFont().GetName() ) ) { Point aPt; String aString; |