summaryrefslogtreecommitdiff
path: root/svx
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2013-08-14 19:39:30 +0300
committerTor Lillqvist <tml@iki.fi>2013-08-14 19:41:43 +0300
commit9daf7380398fb5020a3b39f2f544e9b601eb06ee (patch)
tree9c0a1f54fd0d8c898862026a174212684874da94 /svx
parent96336caac7880de89c2c46523c2857de2c41f318 (diff)
bnc#654532: Make a regular octagon loaded from .ppt actually regular
See source code for extensive comment. Change-Id: Ic6ce18ca8aec95d2ffb480ae403a1c10cb8980e7
Diffstat (limited to 'svx')
-rw-r--r--svx/source/customshapes/EnhancedCustomShapeGeometry.cxx44
1 files changed, 43 insertions, 1 deletions
diff --git a/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx b/svx/source/customshapes/EnhancedCustomShapeGeometry.cxx
index d64ab357cf8c..5e7b43757cc6 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[] =
{