[Libreoffice-commits] core.git: svx/source

Tor Lillqvist tml at iki.fi
Wed Aug 14 09:42:57 PDT 2013


 svx/source/customshapes/EnhancedCustomShapeGeometry.cxx |   44 +++++++++++++++-
 1 file changed, 43 insertions(+), 1 deletion(-)

New commits:
commit 9daf7380398fb5020a3b39f2f544e9b601eb06ee
Author: Tor Lillqvist <tml at iki.fi>
Date:   Wed Aug 14 19:39:30 2013 +0300

    bnc#654532: Make a regular octagon loaded from .ppt actually regular
    
    See source code for extensive comment.
    
    Change-Id: Ic6ce18ca8aec95d2ffb480ae403a1c10cb8980e7

diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
index d64ab35..5e7b437 100644
--- a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
+++ b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
@@ -18,6 +18,7 @@
  */
 
 #include <limits>
+#include <cmath>
 
 #include "svx/EnhancedCustomShapeGeometry.hxx"
 #include <com/sun/star/drawing/EnhancedCustomShapeGluePointType.hpp>
@@ -387,6 +388,47 @@ static const mso_CustomShape msoTrapezoid =
     (SvxMSDffHandle*)mso_sptTrapezoidHandle, SAL_N_ELEMENTS( mso_sptTrapezoidHandle )        // handles
 };
 
+// The side of the enclosing square for the regular (all sides the
+// same, all angles the same) octagon described below is 21600. Let's
+// call that 'a'.
+
+// The "adjustment1" is the horizontal (or vertical) distance from a
+// side of the square to the nearest vertex. Let's call that 'd'.
+
+// Let's call the side of the regular octagon 'b'.
+
+// We know a. We want d. d=(a-b)/2
+
+// Pythagoras says that b^2 = 2d^2
+
+// Solving for b, we get b = (sqrt(2)-1)a
+
+
+//     !------------a=21600-------!
+//
+//     !--d--!
+//           x--------------x
+//          /                \
+//         /                  \
+//        /                    \
+//       /                      \
+//      /                        \
+//     x                          x
+//     !                          !
+//     !                          !
+//     !                          !
+//     !                          !
+//     !                          !
+//     !                          !
+//     x                          x
+//      \                        /
+//       \                      /
+//        \                    /
+//         \                  /
+//          \                /
+//           x--------------x
+//
+
 static const SvxMSDffVertPair mso_sptOctagonVert[] =        // adjustment1 : 0 - 10800
 {
     { 0 MSO_I, 0 }, { 2 MSO_I, 0 }, { 21600, 1 MSO_I }, { 21600, 3 MSO_I },
@@ -410,7 +452,7 @@ static const SvxMSDffCalculationData mso_sptOctagonCalc[] =
 };
 static const sal_Int32 mso_sptOctagonDefault[] =
 {
-    1, 5000
+    1, static_cast<sal_Int32>((21600 - ((M_SQRT2-1)*21600)) / 2)
 };
 static const SvxMSDffTextRectangles mso_sptOctagonTextRect[] =
 {


More information about the Libreoffice-commits mailing list