[Libreoffice-commits] .: writerperfect/source

Fridrich Strba fridrich at kemper.freedesktop.org
Tue Jan 17 03:59:17 PST 2012


 writerperfect/source/filter/OdgGenerator.cxx |   43 +++++++++++++++++++++++++--
 1 file changed, 41 insertions(+), 2 deletions(-)

New commits:
commit b350765be4852b8d2dc914a6048a5d273447480a
Author: Fridrich Å trba <fridrich.strba at bluewin.ch>
Date:   Mon Jan 16 17:32:23 2012 +0100

    Implementing text rotations

diff --git a/writerperfect/source/filter/OdgGenerator.cxx b/writerperfect/source/filter/OdgGenerator.cxx
index 5681ed5..79722e8 100644
--- a/writerperfect/source/filter/OdgGenerator.cxx
+++ b/writerperfect/source/filter/OdgGenerator.cxx
@@ -1371,10 +1371,27 @@ void OdgGenerator::startTextObject(const WPXPropertyList &propList, const WPXPro
     pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill", "none");
     pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill-color", "#ffffff");
 
+    double x = 0.0;
+    double y = 0.0;
+    double height = 0.0;
+    double width = 0.0;
     if (propList["svg:x"])
-        pDrawFrameOpenElement->addAttribute("svg:x", propList["svg:x"]->getStr());
+        x = propList["svg:x"]->getDouble();
     if (propList["svg:y"])
-        pDrawFrameOpenElement->addAttribute("svg:y", propList["svg:y"]->getStr());
+        y = propList["svg:y"]->getDouble();
+    if (propList["svg:width"])
+        width = propList["svg:width"]->getDouble();
+    if (propList["svg:height"])
+        height = propList["svg:height"]->getDouble();
+
+    double angle(propList["libwpg:rotate"] ? - M_PI * propList["libwpg:rotate"]->getDouble() / 180.0 : 0.0);
+    if (angle != 0.0)
+    {
+        double deltax((width*cos(angle)+height*sin(angle)-width)/2.0);
+        double deltay((-width*sin(angle)+height*cos(angle)-height)/2.0);
+        x -= deltax;
+        y -= deltay;
+    }
 
     if (!propList["svg:width"] && !propList["svg:height"])
     {
@@ -1452,6 +1469,28 @@ void OdgGenerator::startTextObject(const WPXPropertyList &propList, const WPXPro
         pDrawFrameOpenElement->addAttribute("draw:opacity", propList["draw:opacity"]->getStr());
         pStyleGraphicPropertiesOpenElement->addAttribute("draw:opacity", propList["draw:opacity"]->getStr());
     }
+
+    WPXProperty *svg_x = WPXPropertyFactory::newInchProp(x);
+    WPXProperty *svg_y = WPXPropertyFactory::newInchProp(y);
+    if (angle != 0.0)
+    {
+        WPXProperty *libwpg_rotate = WPXPropertyFactory::newDoubleProp(angle);
+        sValue.sprintf("rotate (%s) translate(%s, %s)",
+                       libwpg_rotate->getStr().cstr(),
+                       svg_x->getStr().cstr(),
+                       svg_y->getStr().cstr());
+        delete libwpg_rotate;
+        pDrawFrameOpenElement->addAttribute("draw:transform", sValue);
+    }
+    else
+    {
+        if (propList["svg:x"])
+            pDrawFrameOpenElement->addAttribute("svg:x", svg_x->getStr());
+        if (propList["svg:y"])
+            pDrawFrameOpenElement->addAttribute("svg:y", svg_y->getStr());
+    }
+    delete svg_x;
+    delete svg_y;
     mpImpl->mBodyElements.push_back(pDrawFrameOpenElement);
     mpImpl->mBodyElements.push_back(new TagOpenElement("draw:text-box"));
     mpImpl->mGraphicsAutomaticStyles.push_back(pStyleGraphicPropertiesOpenElement);


More information about the Libreoffice-commits mailing list