summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-06-12 10:30:36 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-04-01 15:29:18 +0100
commit93ce5834a6651a2d3ccf6e56336b1ec48c7905f2 (patch)
tree55b8106b1b3cd0206153bbe66e5d6d0f9438b22a /vcl
parent0a40cec9fb760d6d66480d2ba41151d65cf8675b (diff)
Resolves: #i117968# 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). Extends fix of 6280a1e3104826ccdcd71c422b149e249783d5da for fdo#36991 (cherry picked from commit a379ffae809a4b9f92fbde9b9699f5353f7b3472) Conflicts: svtools/source/filter/wmf/winmtf.cxx svtools/source/filter/wmf/winmtf.hxx svtools/source/filter/wmf/winwmf.cxx Change-Id: Ifd1d23217c0fbe22edbd1b1995286846e19030de
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/filter/wmf/winmtf.cxx40
-rw-r--r--vcl/source/filter/wmf/winmtf.hxx2
-rw-r--r--vcl/source/filter/wmf/winwmf.cxx6
3 files changed, 27 insertions, 21 deletions
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 424004febdf4..5e8f5f29a43b 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -27,6 +27,8 @@
#include <vcl/svapp.hxx>
#include <rtl/strbuf.hxx>
#include <rtl/tencinfo.h>
+#include <vcl/svapp.hxx>
+#include <vcl/virdev.hxx>
// ------------------------------------------------------------------------
@@ -232,8 +234,11 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont )
Size aFontSize( Size( rFont.lfWidth, rFont.lfHeight ) );
if ( rFont.lfHeight > 0 )
{
- // converting the cell height into a font height
+ // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
+ SolarMutexGuard aGuard;
VirtualDevice aVDev;
+
+ // converting the cell height into a font height
aFont.SetSize( aFontSize );
aVDev.SetFont( aFont );
FontMetric aMetric( aVDev.GetFontMetric() );
@@ -249,7 +254,10 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFONTW& rFont )
if ( !rFont.lfWidth )
{
+ // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
+ SolarMutexGuard aGuard;
VirtualDevice aVDev;
+
aFont.SetSize( aFontSize );
aVDev.SetFont( aFont );
FontMetric aMetric( aVDev.GetFontMetric() );
@@ -1500,13 +1508,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();
@@ -1600,20 +1605,22 @@ void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry
if( mnTextAlign & ( TA_UPDATECP | TA_RIGHT_CENTER ) )
{
- if ( !pVDev )
- pVDev = new VirtualDevice;
+ // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
+ SolarMutexGuard aGuard;
+ 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( rtl::OUString(rText.GetChar( (sal_uInt16)( nLen - 1 ) )) );
+ nTextWidth = aVDev.GetTextWidth( rtl::OUString(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;
@@ -1647,21 +1654,20 @@ void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry
sal_Int32* pDX = pDXArry;
if ( !pDXArry )
{
+ // #i117968# VirtualDevice is not thread safe, but filter is used in multithreading
SolarMutexGuard aGuard;
+ 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/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index b524d0a6499a..bec5d8ae3c7b 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -27,7 +27,6 @@
#include <sot/object.hxx>
#include <boost/shared_ptr.hpp>
#include <vcl/graph.hxx>
-#include <vcl/virdev.hxx>
#include <basegfx/tools/b2dclipstate.hxx>
#include <vcl/font.hxx>
#include <vcl/bmpacc.hxx>
@@ -847,7 +846,6 @@ class WMFReader : public WinMtf
{
private:
- VirtualDevice aVDev; // just for the purpose of "IsFontAvailable"
sal_uInt16 nUnitsPerInch;
sal_uInt32 nRecSize;
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index a181fdfad4aa..133df403bc31 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -25,6 +25,7 @@
#include <rtl/crc.h>
#include <rtl/tencinfo.h>
#include <osl/endian.h>
+#include <vcl/svapp.hxx>
//====================== MS-Windows-defines ===============================
@@ -917,8 +918,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;