incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1349265 - in /incubator/ooo/trunk/main/svtools/source/filter/wmf: winmtf.cxx winmtf.hxx winwmf.cxx
Date Tue, 12 Jun 2012 11:30:37 GMT
Author: alg
Date: Tue Jun 12 11:30:36 2012
New Revision: 1349265

URL: http://svn.apache.org/viewvc?rev=1349265&view=rev
Log:
#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).

Modified:
    incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.cxx
    incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.hxx
    incubator/ooo/trunk/main/svtools/source/filter/wmf/winwmf.cxx

Modified: incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.cxx?rev=1349265&r1=1349264&r2=1349265&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.cxx (original)
+++ incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.cxx Tue Jun 12 11:30:36 2012
@@ -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( LOGFON
 	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,8 +302,11 @@ WinMtfFontStyle::WinMtfFontStyle( LOGFON
 	
 	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 );
+	
+        aFont.SetSize( aFontSize );
 		aVDev.SetFont( aFont );
 		FontMetric aMetric( aVDev.GetFontMetric() );
 		aFontSize.Width() = aMetric.GetWidth();
@@ -1456,15 +1464,12 @@ void WinMtfOutput::DrawPolyBezier( Polyg
 
 void WinMtfOutput::DrawText( Point& rPosition, String& rText, sal_Int32* pDXArry,
sal_Bool bRecordPath, sal_Int32 nGfxMode )
 {
-	UpdateClipRegion();
-
-	VirtualDevice* pVDev = NULL;
-
+    UpdateClipRegion();
 	rPosition = ImplMap( rPosition );
-
 	sal_Int32 nOldGfxMode = GetGfxMode();
 	SetGfxMode( GM_COMPATIBLE );
-	if ( pDXArry )
+
+    if ( pDXArry )
 	{
 		sal_Int32 i, nSum, nLen = rText.Len();
 
@@ -1556,20 +1561,23 @@ void WinMtfOutput::DrawText( Point& rPos
 
 	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 );
-		if( pDXArry )
+		
+        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& rPos
 		sal_Int32* pDX = pDXArry;		
 		if ( !pDXArry )
 		{
-			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 );
+            // #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() ];
+			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;
 }
 
 //-----------------------------------------------------------------------------------

Modified: incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.hxx?rev=1349265&r1=1349264&r2=1349265&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.hxx (original)
+++ incubator/ooo/trunk/main/svtools/source/filter/wmf/winmtf.hxx Tue Jun 12 11:30:36 2012
@@ -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;
 

Modified: incubator/ooo/trunk/main/svtools/source/filter/wmf/winwmf.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svtools/source/filter/wmf/winwmf.cxx?rev=1349265&r1=1349264&r2=1349265&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svtools/source/filter/wmf/winwmf.cxx (original)
+++ incubator/ooo/trunk/main/svtools/source/filter/wmf/winwmf.cxx Tue Jun 12 11:30:36 2012
@@ -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_uI
 							        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;



Mime
View raw message