src/lib/Fill.cpp           |   28 +++++++++++++++++++++++++---
 src/lib/Fill.h             |   13 ++++++++-----
 src/lib/FillType.h         |    8 +++++++-
 src/lib/MSPUBCollector.cpp |    8 ++++++--
 src/lib/MSPUBParser.cpp    |   15 +++++++++++++--
 src/lib/ShapeInfo.h        |    3 ++-
 6 files changed, 61 insertions(+), 14 deletions(-)

New commits:
commit c51d3825ee97cd563a4791f2b1b43e40c5272a7f
Author: Fridrich Å trba <fridrich.st...@bluewin.ch>
Date:   Thu Apr 4 15:05:16 2013 +0200

    Astyle stuff (astyle -b -k3 -y -n -s2 -r \*.cpp \*.h)

diff --git a/src/lib/Fill.cpp b/src/lib/Fill.cpp
index 66d55de..aeaeb37 100644
--- a/src/lib/Fill.cpp
+++ b/src/lib/Fill.cpp
@@ -54,11 +54,11 @@ WPXPropertyListVector 
ImgFill::getProperties(WPXPropertyList *out) const
       out->insert("style:repeat", "stretch");
     }
     if (m_rotation != 0)
-       {
-         WPXString sValue;
-         sValue.sprintf("%d", m_rotation);
-         out->insert("libwpg:rotate", sValue);
-       }
+    {
+      WPXString sValue;
+      sValue.sprintf("%d", m_rotation);
+      out->insert("libwpg:rotate", sValue);
+    }
   }
   return WPXPropertyListVector();
 }
@@ -133,19 +133,19 @@ WPXPropertyListVector 
GradientFill::getProperties(WPXPropertyList *out) const
   out->insert("draw:angle", -m_angle); // draw:angle is clockwise in odf format
   switch (m_type)
   {
-         case 4:
-         case 7:
-                 out->insert("libmspub:shade", "normal");
-                 break;
-         case 5:
-                 out->insert("libmspub:shade", "center");
-                 break;
-         case 6:
-                 out->insert("libmspub:shade", "shape");
-                 break;
-         default:
-                 out->insert("libmspub:shade", "normal");
-                 break;
+  case 4:
+  case 7:
+    out->insert("libmspub:shade", "normal");
+    break;
+  case 5:
+    out->insert("libmspub:shade", "center");
+    break;
+  case 6:
+    out->insert("libmspub:shade", "shape");
+    break;
+  default:
+    out->insert("libmspub:shade", "normal");
+    break;
   }
   for (unsigned i = 0; i < m_stops.size(); ++i)
   {
diff --git a/src/lib/FillType.h b/src/lib/FillType.h
index 7b1f4cb..8978ebd 100644
--- a/src/lib/FillType.h
+++ b/src/lib/FillType.h
@@ -34,10 +34,10 @@ namespace libmspub
 enum FillType
 {
   SOLID,
-  GRADIENT = 0x07,       // msofillShadeScale Similar to msofillShade, but the 
fillAngle
-                         // is additionally scaled by the aspect ratio of
-                         // the shape. If shape is square, it is the
-                         // same as msofillShade
+  GRADIENT = 0x07, // msofillShadeScale Similar to msofillShade, but the 
fillAngle
+                   // is additionally scaled by the aspect ratio of
+                   // the shape. If shape is square, it is the
+                   // same as msofillShade
   GRADIENTCENTER = 0x06, // msofillShadeShape  Shade from shape outline to end 
point
   GRADIENTSHAPE = 0x05,  // msofillShadeCenter Shade from bounding rectangle 
to end point
   GRADIENTNORMAL = 0x04, // msofillShade       Shade from start to end points
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index bbe229a..82b7cca 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -348,9 +348,9 @@ void 
libmspub::MSPUBCollector::setupShapeStructures(ShapeGroupElement &elt)
     if (ptr_info->m_imgIndex.is_initialized())
     {
       unsigned index = ptr_info->m_imgIndex.get();
-         int rot = 0;
-         if (ptr_info->m_innerRotation.is_initialized())
-                 rot = ptr_info->m_innerRotation.get();
+      int rot = 0;
+      if (ptr_info->m_innerRotation.is_initialized())
+        rot = ptr_info->m_innerRotation.get();
       if (index - 1 < m_images.size())
       {
         ptr_info->m_fill = boost::shared_ptr<const Fill>(new ImgFill(index, 
this, false, rot));
@@ -424,7 +424,7 @@ boost::function<void(void)> 
libmspub::MSPUBCollector::paintShape(const ShapeInfo
   {
     type = info.m_type.get_value_or(RECTANGLE);
   }
-  
+
   if (hasFill)
   {
     double x, y, height, width;
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index cdbc155..584c227 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -1894,13 +1894,13 @@ boost::shared_ptr<libmspub::Fill> 
libmspub::MSPUBParser::getNewFill(const std::m
   case TEXTURE:
   case BITMAP:
   {
-       // in the case the shape is rotated we must rotate the image too
+    // in the case the shape is rotated we must rotate the image too
     int rotation = 0;
     const int *ptr_rotation = (const int *)getIfExists_const(foptProperties, 
FIELDID_ROTATION);
     if (ptr_rotation)
     {
-       rotation = (int)doubleModulo(toFixedPoint(*ptr_rotation), 360);
-       MSPUB_DEBUG_MSG(("Rotation value %d\n", rotation));
+      rotation = (int)doubleModulo(toFixedPoint(*ptr_rotation), 360);
+      MSPUB_DEBUG_MSG(("Rotation value %d\n", rotation));
     }
     const unsigned *ptr_bgPxId = getIfExists_const(foptProperties, 
FIELDID_BG_PXID);
     if (ptr_bgPxId && *ptr_bgPxId <= m_escherDelayIndices.size() && 
m_escherDelayIndices[*ptr_bgPxId - 1] >= 0)
commit deb3a0df5b0aa85676bb20bf6ce026d0dc7101af
Author: Franz Schmid <fr...@linux-hp-i7.site>
Date:   Wed Apr 3 21:14:47 2013 +0200

    Added parsing of more gradient types and report rotation for images.

diff --git a/src/lib/Fill.cpp b/src/lib/Fill.cpp
index cade9b8..66d55de 100644
--- a/src/lib/Fill.cpp
+++ b/src/lib/Fill.cpp
@@ -36,7 +36,7 @@ Fill::Fill(const MSPUBCollector *owner) : m_owner(owner)
 {
 }
 
-ImgFill::ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool 
isTexture) : Fill(owner), m_imgIndex(imgIndex), m_isTexture(isTexture)
+ImgFill::ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool 
isTexture, int rot) : Fill(owner), m_imgIndex(imgIndex), 
m_isTexture(isTexture), m_rotation(rot)
 {
 }
 
@@ -53,11 +53,17 @@ WPXPropertyListVector 
ImgFill::getProperties(WPXPropertyList *out) const
     {
       out->insert("style:repeat", "stretch");
     }
+    if (m_rotation != 0)
+       {
+         WPXString sValue;
+         sValue.sprintf("%d", m_rotation);
+         out->insert("libwpg:rotate", sValue);
+       }
   }
   return WPXPropertyListVector();
 }
 
-PatternFill::PatternFill(unsigned imgIndex, const MSPUBCollector *owner, 
ColorReference fg, ColorReference bg) : ImgFill(imgIndex, owner, true), 
m_fg(fg), m_bg(bg)
+PatternFill::PatternFill(unsigned imgIndex, const MSPUBCollector *owner, 
ColorReference fg, ColorReference bg) : ImgFill(imgIndex, owner, true, 0), 
m_fg(fg), m_bg(bg)
 {
 }
 
@@ -110,7 +116,7 @@ WPXPropertyListVector 
SolidFill::getProperties(WPXPropertyList *out) const
   return WPXPropertyListVector();
 }
 
-GradientFill::GradientFill(const MSPUBCollector *owner, double angle) : 
Fill(owner), m_stops(), m_angle(angle)
+GradientFill::GradientFill(const MSPUBCollector *owner, double angle, int 
type) : Fill(owner), m_stops(), m_angle(angle), m_type(type)
 {
 }
 
@@ -125,6 +131,22 @@ WPXPropertyListVector 
GradientFill::getProperties(WPXPropertyList *out) const
   out->insert("draw:fill", "gradient");
   out->insert("svg:fill-rule", "nonzero");
   out->insert("draw:angle", -m_angle); // draw:angle is clockwise in odf format
+  switch (m_type)
+  {
+         case 4:
+         case 7:
+                 out->insert("libmspub:shade", "normal");
+                 break;
+         case 5:
+                 out->insert("libmspub:shade", "center");
+                 break;
+         case 6:
+                 out->insert("libmspub:shade", "shape");
+                 break;
+         default:
+                 out->insert("libmspub:shade", "normal");
+                 break;
+  }
   for (unsigned i = 0; i < m_stops.size(); ++i)
   {
     Color c = 
m_stops[i].m_colorReference.getFinalColor(m_owner->m_paletteColors);
diff --git a/src/lib/Fill.h b/src/lib/Fill.h
index dc6bc31..e226a65 100644
--- a/src/lib/Fill.h
+++ b/src/lib/Fill.h
@@ -59,11 +59,13 @@ protected:
   unsigned m_imgIndex;
 private:
   bool m_isTexture;
+protected:
+  int m_rotation;
 public:
-  ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture);
+  ImgFill(unsigned imgIndex, const MSPUBCollector *owner, bool isTexture, int 
rotation);
   virtual WPXPropertyListVector getProperties(WPXPropertyList *out) const;
 private:
-  ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false) { }
+  ImgFill(const ImgFill &) : Fill(NULL), m_imgIndex(0), m_isTexture(false), 
m_rotation(0) { }
   ImgFill &operator=(const ImgFill &);
 };
 
@@ -75,7 +77,7 @@ public:
   PatternFill(unsigned imgIndex, const MSPUBCollector *owner, ColorReference 
fg, ColorReference bg);
   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
 private:
-  PatternFill(const PatternFill &) : ImgFill(0, NULL, true), m_fg(0x08000000), 
m_bg(0x08000000) { }
+  PatternFill(const PatternFill &) : ImgFill(0, NULL, true, 0), 
m_fg(0x08000000), m_bg(0x08000000) { }
   PatternFill &operator=(const ImgFill &);
 };
 
@@ -102,12 +104,13 @@ class GradientFill : public Fill
   };
   std::vector<StopInfo> m_stops;
   double m_angle;
+  int m_type;
 public:
-  GradientFill(const MSPUBCollector *owner, double angle = 0);
+  GradientFill(const MSPUBCollector *owner, double angle = 0, int type = 7);
   void addColor(ColorReference c, unsigned offsetPercent, double opacity);
   WPXPropertyListVector getProperties(WPXPropertyList *out) const;
 private:
-  GradientFill(const GradientFill &) : Fill(NULL), m_stops(), m_angle(0) { }
+  GradientFill(const GradientFill &) : Fill(NULL), m_stops(), m_angle(0), 
m_type(7) { }
   GradientFill &operator=(const GradientFill &);
 };
 }
diff --git a/src/lib/FillType.h b/src/lib/FillType.h
index 5d8181f..7b1f4cb 100644
--- a/src/lib/FillType.h
+++ b/src/lib/FillType.h
@@ -34,7 +34,13 @@ namespace libmspub
 enum FillType
 {
   SOLID,
-  GRADIENT = 0x07,
+  GRADIENT = 0x07,       // msofillShadeScale Similar to msofillShade, but the 
fillAngle
+                         // is additionally scaled by the aspect ratio of
+                         // the shape. If shape is square, it is the
+                         // same as msofillShade
+  GRADIENTCENTER = 0x06, // msofillShadeShape  Shade from shape outline to end 
point
+  GRADIENTSHAPE = 0x05,  // msofillShadeCenter Shade from bounding rectangle 
to end point
+  GRADIENTNORMAL = 0x04, // msofillShade       Shade from start to end points
   BITMAP = 0x03,
   TEXTURE = 0x02,
   PATTERN = 0x01
diff --git a/src/lib/MSPUBCollector.cpp b/src/lib/MSPUBCollector.cpp
index bceb8f4..bbe229a 100644
--- a/src/lib/MSPUBCollector.cpp
+++ b/src/lib/MSPUBCollector.cpp
@@ -348,9 +348,12 @@ void 
libmspub::MSPUBCollector::setupShapeStructures(ShapeGroupElement &elt)
     if (ptr_info->m_imgIndex.is_initialized())
     {
       unsigned index = ptr_info->m_imgIndex.get();
+         int rot = 0;
+         if (ptr_info->m_innerRotation.is_initialized())
+                 rot = ptr_info->m_innerRotation.get();
       if (index - 1 < m_images.size())
       {
-        ptr_info->m_fill = boost::shared_ptr<const Fill>(new ImgFill(index, 
this, false));
+        ptr_info->m_fill = boost::shared_ptr<const Fill>(new ImgFill(index, 
this, false, rot));
       }
     }
     elt.setShapeInfo(*ptr_info);
@@ -1032,6 +1035,7 @@ libmspub::MSPUBCollector::~MSPUBCollector()
 void libmspub::MSPUBCollector::setShapeRotation(unsigned seqNum, double 
rotation)
 {
   m_shapeInfosBySeqNum[seqNum].m_rotation = rotation;
+  m_shapeInfosBySeqNum[seqNum].m_innerRotation = (int)rotation;
 }
 
 void libmspub::MSPUBCollector::setShapeFlip(unsigned seqNum, bool 
flipVertical, bool flipHorizontal)
diff --git a/src/lib/MSPUBParser.cpp b/src/lib/MSPUBParser.cpp
index 414a946..cdbc155 100644
--- a/src/lib/MSPUBParser.cpp
+++ b/src/lib/MSPUBParser.cpp
@@ -1832,6 +1832,9 @@ boost::shared_ptr<libmspub::Fill> 
libmspub::MSPUBParser::getNewFill(const std::m
     }
     return boost::shared_ptr<Fill>();
   }
+  case GRADIENTCENTER:
+  case GRADIENTSHAPE:
+  case GRADIENTNORMAL:
   case GRADIENT: //FIXME: The handling of multi-color gradients here is quite 
bad.
   {
     int angle;
@@ -1863,7 +1866,7 @@ boost::shared_ptr<libmspub::Fill> 
libmspub::MSPUBParser::getNewFill(const std::m
       break;
     }
 
-    boost::shared_ptr<GradientFill> ret(new GradientFill(m_collector, angle));
+    boost::shared_ptr<GradientFill> ret(new GradientFill(m_collector, angle, 
(int)fillType));
     if (fillFocus ==  0)
     {
       ret->addColor(firstColor, 0, ptr_fillOpacity ? 
(double)(*ptr_fillOpacity) / 0xFFFF : 1);
@@ -1891,10 +1894,18 @@ boost::shared_ptr<libmspub::Fill> 
libmspub::MSPUBParser::getNewFill(const std::m
   case TEXTURE:
   case BITMAP:
   {
+       // in the case the shape is rotated we must rotate the image too
+    int rotation = 0;
+    const int *ptr_rotation = (const int *)getIfExists_const(foptProperties, 
FIELDID_ROTATION);
+    if (ptr_rotation)
+    {
+       rotation = (int)doubleModulo(toFixedPoint(*ptr_rotation), 360);
+       MSPUB_DEBUG_MSG(("Rotation value %d\n", rotation));
+    }
     const unsigned *ptr_bgPxId = getIfExists_const(foptProperties, 
FIELDID_BG_PXID);
     if (ptr_bgPxId && *ptr_bgPxId <= m_escherDelayIndices.size() && 
m_escherDelayIndices[*ptr_bgPxId - 1] >= 0)
     {
-      return boost::shared_ptr<Fill>(new 
ImgFill(m_escherDelayIndices[*ptr_bgPxId - 1], m_collector, fillType == 
TEXTURE));
+      return boost::shared_ptr<Fill>(new 
ImgFill(m_escherDelayIndices[*ptr_bgPxId - 1], m_collector, fillType == 
TEXTURE, rotation));
     }
     return boost::shared_ptr<Fill>();
   }
diff --git a/src/lib/ShapeInfo.h b/src/lib/ShapeInfo.h
index a0d193a..8f33247 100644
--- a/src/lib/ShapeInfo.h
+++ b/src/lib/ShapeInfo.h
@@ -79,6 +79,7 @@ struct ShapeInfo
   boost::optional<VerticalAlign> m_verticalAlign;
   boost::optional<ColorReference> m_pictureRecolor;
   boost::optional<Shadow> m_shadow;
+  boost::optional<int> m_innerRotation;
   ShapeInfo() : m_type(), m_cropType(), m_imgIndex(), m_borderImgIndex(),
     m_coordinates(), m_lines(), m_pageSeqNum(),
     m_textId(), m_adjustValuesByIndex(), m_adjustValues(),
@@ -87,7 +88,7 @@ struct ShapeInfo
     m_lineBackColor(), m_dash(), m_tableInfo(),
     m_tableCellTextEnds(), m_numColumns(),
     m_columnSpacing(0), m_beginArrow(), m_endArrow(),
-    m_verticalAlign(), m_pictureRecolor(), m_shadow()
+    m_verticalAlign(), m_pictureRecolor(), m_shadow(), m_innerRotation()
   {
   }
   boost::shared_ptr<const CustomShape> getCustomShape() const
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to