Author: hdu
Date: Fri Apr 26 13:39:22 2013
New Revision: 1476190

URL: http://svn.apache.org/r1476190
Log:
fix narrowing conversions in PictReaderShape*

Modified:
    openoffice/trunk/main/filter/source/graphicfilter/ipict/shape.cxx

Modified: openoffice/trunk/main/filter/source/graphicfilter/ipict/shape.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/filter/source/graphicfilter/ipict/shape.cxx?rev=1476190&r1=1476189&r2=1476190&view=diff
==============================================================================
--- openoffice/trunk/main/filter/source/graphicfilter/ipict/shape.cxx (original)
+++ openoffice/trunk/main/filter/source/graphicfilter/ipict/shape.cxx Fri Apr 
26 13:39:22 2013
@@ -40,6 +40,9 @@ Here, we choose:
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include "shape.hxx"
 
+// a local helper to initialize double[2] arrays with long values
+#define L2D_ARY(l1,l2) { static_cast<double>(l1), static_cast<double>(l2) }
+
 namespace PictReaderShapePrivate {
   /** returns an inside rectangle knowing the penSize in order to obtain the 
``correct'' position
       when we draw a frame in wide length*/
@@ -133,8 +136,8 @@ namespace PictReaderShape {
   void drawRectangle(VirtualDevice *dev, bool drawFrame, Rectangle const 
&orig, Size const &pSize) {
     int penSize=(pSize.Width()+pSize.Height())/2;
     Rectangle rect = PictReaderShapePrivate::contractRectangle(drawFrame, 
orig, pSize);
-    double const X[2] = { rect.Left(), rect.Right() };
-    double const Y[2] = { rect.Top(), rect.Bottom() };
+    double const X[2] = L2D_ARY( rect.Left(), rect.Right() );
+    double const Y[2] = L2D_ARY( rect.Top(), rect.Bottom() );
 
     using namespace basegfx;
     B2DPolygon poly;
@@ -153,8 +156,8 @@ namespace PictReaderShape {
     int penSize=(pSize.Width()+pSize.Height())/2;
     Rectangle oval = PictReaderShapePrivate::contractRectangle(drawFrame, 
orig, pSize);
     using namespace basegfx;
-    double const X[2] = { oval.Left(), oval.Right() };
-    double const Y[2] = { oval.Top(), oval.Bottom() };
+    double const X[2] = L2D_ARY( oval.Left(), oval.Right() );
+    double const Y[2] = L2D_ARY( oval.Top(), oval.Bottom() );
     B2DPoint center(0.5*(X[1]+X[0]), 0.5*(Y[1]+Y[0]));
     B2DPolygon poly = tools::createPolygonFromEllipse(center, 0.5*(X[1]-X[0]), 
0.5*(Y[1]-Y[0]));
     if (drawFrame)
@@ -173,8 +176,8 @@ namespace PictReaderShape {
     // pict angle are CW with 0 at twelve oclock ( with Y-axis inverted)...
     double angl1 = angle1-PI2;
     double angl2 = angle2-PI2;
-    double const X[2] = { arc.Left(), arc.Right() };
-    double const Y[2] = { arc.Top(), arc.Bottom() };
+    double const X[2] = L2D_ARY( arc.Left(), arc.Right() );
+    double const Y[2] = L2D_ARY( arc.Top(), arc.Bottom() );
     B2DPoint center(0.5*(X[1]+X[0]), 0.5*(Y[1]+Y[0]));
     
     // We must have angl1 between 0 and F_2PI
@@ -204,8 +207,8 @@ namespace PictReaderShape {
     Rectangle oval = PictReaderShapePrivate::contractRectangle(drawFrame, 
orig, pSize);
     int ovalW=ovalSize.Width(), ovalH=ovalSize.Height();
     using namespace basegfx;
-    double const X[2] = { oval.Left(), oval.Right() };
-    double const Y[2] = { oval.Top(), oval.Bottom() };
+    double const X[2] = L2D_ARY( oval.Left(), oval.Right() );
+    double const Y[2] = L2D_ARY( oval.Top(), oval.Bottom() );
     double width = X[1] - X[0];
     double height = Y[1] - Y[0];
     if (ovalW > width) ovalW = static_cast< int >( width );
@@ -258,5 +261,5 @@ namespace PictReaderShape {
       dev->DrawPolygon(poly);
   }
 
-
 }
+


Reply via email to