Index: sc/source/core/data/drwlayer.cxx
===================================================================
RCS file: /cvs/sc/sc/source/core/data/drwlayer.cxx,v
retrieving revision 1.51
diff -u -p -r1.51 drwlayer.cxx
--- sc/source/core/data/drwlayer.cxx	6 Jul 2007 12:33:05 -0000	1.51
+++ sc/source/core/data/drwlayer.cxx	19 Nov 2007 03:21:21 -0000
@@ -118,6 +118,10 @@
 #include "scmod.hxx"
 #include "chartarr.hxx"
 
+#ifndef _SV_FIELD_HXX //autogen
+#include <vcl/field.hxx>
+#endif
+
 #define DET_ARROW_OFFSET	1000
 
 //	Abstand zur naechsten Zelle beim Loeschen (bShrink), damit der Anker
@@ -230,16 +234,26 @@ __EXPORT ScTabSizeChangedHint::~ScTabSiz
 
 #define MAXMM	10000000
 
+inline long TwipsToHmm (long nVal)
+{
+	return static_cast< long >( MetricField::ConvertDoubleValue (static_cast<sal_Int64>(nVal), 0, 0, 
+			FUNIT_TWIP, FUNIT_100TH_MM) );
+}
+
+inline long HmmToTwips (long nVal)
+{
+	return static_cast< long > ( MetricField::ConvertDoubleValue (static_cast<sal_Int64>(nVal), 0, 0, 
+			FUNIT_100TH_MM, FUNIT_TWIP) );
+}
+
 inline void TwipsToMM( long& nVal )
 {
-	nVal = (long) ( nVal * HMM_PER_TWIPS );
+	nVal = TwipsToHmm (nVal);
 }
 
 inline void ReverseTwipsToMM( long& nVal )
 {
-	//	reverse the effect of TwipsToMM - round up here (add 1)
-
-	nVal = ((long) ( nVal / HMM_PER_TWIPS )) + 1;
+	nVal = HmmToTwips (nVal);
 }
 
 void lcl_TwipsToMM( Point& rPoint )
@@ -670,8 +684,8 @@ void ScDrawLayer::RecalcPos( SdrObject* 
 
 		//	Berechnung und Werte wie in detfunc.cxx
 
-		Size aSize( (long) ( pDoc->GetColWidth(nCol, nTab) * HMM_PER_TWIPS ),
-					(long) ( pDoc->GetRowHeight(nRow, nTab) * HMM_PER_TWIPS ) );
+		Size aSize( (long) ( TwipsToHmm( pDoc->GetColWidth(nCol, nTab) ) ),
+					(long) ( TwipsToHmm( pDoc->GetRowHeight(nRow, nTab) ) ) );
 		Rectangle aRect( aPos, aSize );
 		aRect.Left()	-= 250;
 		aRect.Right()	+= 250;
@@ -842,16 +856,16 @@ BOOL ScDrawLayer::GetPrintArea( ScRange&
 		SCCOL nEndCol = rRange.aEnd.Col();
 		for (i=nStartCol; i<=nEndCol; i++)
 			nEndX += pDoc->GetColWidth(i,nTab);
-		nStartX = (long)(nStartX * HMM_PER_TWIPS);
-		nEndX   = (long)(nEndX   * HMM_PER_TWIPS);
+		nStartX = TwipsToHmm( nStartX );
+		nEndX   = TwipsToHmm( nEndX );
 	}
 	if (!bSetVer)
 	{
 		nStartY = pDoc->FastGetRowHeight( 0, rRange.aStart.Row()-1, nTab);
         nEndY = nStartY + pDoc->FastGetRowHeight( rRange.aStart.Row(),
                 rRange.aEnd.Row(), nTab);
-		nStartY = (long)(nStartY * HMM_PER_TWIPS);
-		nEndY   = (long)(nEndY   * HMM_PER_TWIPS);
+		nStartY = TwipsToHmm( nStartY );
+		nEndY   = TwipsToHmm( nEndY );
 	}
 
 	if ( bNegativePage )
@@ -909,8 +923,8 @@ BOOL ScDrawLayer::GetPrintArea( ScRange&
 
 		if (bSetHor)
 		{
-			nStartX = (long) (nStartX / HMM_PER_TWIPS);
-			nEndX = (long) (nEndX / HMM_PER_TWIPS);
+			nStartX = HmmToTwips( nStartX );
+			nEndX = HmmToTwips( nEndX );
 			long nWidth;
 	        SCCOL i;
 
@@ -927,8 +941,8 @@ BOOL ScDrawLayer::GetPrintArea( ScRange&
 
 		if (bSetVer)
 		{
-			nStartY = (long) (nStartY / HMM_PER_TWIPS);
-			nEndY = (long) (nEndY / HMM_PER_TWIPS);
+			nStartY = HmmToTwips( nStartY );
+			nEndY = HmmToTwips( nEndY );
             SCROW nRow = pDoc->FastGetRowForHeight( nTab, nStartY);
 			rRange.aStart.SetRow( nRow>0 ? (nRow-1) : 0);
             nRow = pDoc->FastGetRowForHeight( nTab, nEndY);
