[Libreoffice-commits] .: oox/inc oox/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Sep 6 00:07:03 PDT 2012


 oox/inc/oox/drawingml/textbodyproperties.hxx |    2 +
 oox/inc/oox/drawingml/transform2dcontext.hxx |    3 +-
 oox/source/drawingml/textbodyproperties.cxx  |   15 ++++++++++-
 oox/source/drawingml/transform2dcontext.cxx  |   35 ++++++++++++++++++++++++---
 oox/source/ppt/pptshapecontext.cxx           |    4 +--
 5 files changed, 52 insertions(+), 7 deletions(-)

New commits:
commit 5ca197ce7a2a845933e17fc90195c929cbc7e062
Author: Muthu Subramanian <sumuthu at suse.com>
Date:   Thu Sep 6 12:34:14 2012 +0530

    n#771549: Import text offsets in shapes.
    
    * Also fixed a bug where the (offset) increment was conditional.
    * Reusing Transform2D for <txXfrm> as well.
    * This is a kind of hack where the margins are adjusted
      for the give offset values.

diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx
index 25007be..f8800be 100644
--- a/oox/inc/oox/drawingml/textbodyproperties.hxx
+++ b/oox/inc/oox/drawingml/textbodyproperties.hxx
@@ -36,6 +36,8 @@ struct TextBodyProperties
     OptValue< sal_Int32 >                           moRotation;
     OptValue< sal_Int32 >                           moVert;
     boost::optional< sal_Int32 >                    moInsets[4];
+    boost::optional< sal_Int32 >                    moTextOffX;
+    boost::optional< sal_Int32 >                    moTextOffY;
     ::com::sun::star::drawing::TextVerticalAdjust   meVA;
 
     explicit            TextBodyProperties();
diff --git a/oox/inc/oox/drawingml/transform2dcontext.hxx b/oox/inc/oox/drawingml/transform2dcontext.hxx
index 8a8b18c..6bbbe19 100644
--- a/oox/inc/oox/drawingml/transform2dcontext.hxx
+++ b/oox/inc/oox/drawingml/transform2dcontext.hxx
@@ -34,11 +34,12 @@ class Transform2DContext : public ::oox::core::ContextHandler
 {
 public:
     Transform2DContext( ::oox::core::ContextHandler& rParent,
-        const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape ) throw();
+        const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& xAttributes, Shape& rShape, bool btxXfrm = false ) throw();
     virtual ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext( ::sal_Int32 Element, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XFastAttributeList >& Attribs ) throw (::com::sun::star::xml::sax::SAXException, ::com::sun::star::uno::RuntimeException);
 
 protected:
     Shape&              mrShape;
+    bool                mbtxXfrm;
 };
 
 // ============================================================================
diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx
index f377ee9..36f39d9 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -75,8 +75,21 @@ void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation )
 
     for( sal_Int32 i = 0; i < n; i++ )
     {
+        sal_Int32 nVal = 0;
+
+        // Hack for n#760986
+        // TODO: Preferred method would be to have a textbox on top
+        // of the shape and the place it according to the (off,ext)
+        if( nOff == 0 && moTextOffX ) nVal = *moTextOffX;
+        if( nOff == 1 && moTextOffY ) nVal = *moTextOffY;
+        if( nVal < 0 ) nVal = 0;
+
         if( moInsets[i] )
-            maPropertyMap[ aProps[ ( nOff++ ) % n ] ] <<= static_cast< sal_Int32 >( *moInsets[i] );
+            maPropertyMap[ aProps[ nOff ] ] <<= static_cast< sal_Int32 >( *moInsets[i] + nVal );
+        else if( nVal )
+            maPropertyMap[ aProps[ nOff ] ] <<= static_cast< sal_Int32 >( nVal );
+
+        nOff = (nOff+1) % n;
     }
 }
 
diff --git a/oox/source/drawingml/transform2dcontext.cxx b/oox/source/drawingml/transform2dcontext.cxx
index 9ded1df..d35c5d3 100644
--- a/oox/source/drawingml/transform2dcontext.cxx
+++ b/oox/source/drawingml/transform2dcontext.cxx
@@ -20,6 +20,7 @@
 #include "oox/drawingml/transform2dcontext.hxx"
 #include "oox/helper/attributelist.hxx"
 #include "oox/drawingml/shape.hxx"
+#include "oox/drawingml/textbody.hxx"
 
 using ::com::sun::star::awt::Point;
 using ::com::sun::star::awt::Size;
@@ -36,17 +37,45 @@ namespace drawingml {
 // ============================================================================
 
 /** context to import a CT_Transform2D */
-Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape ) throw()
+Transform2DContext::Transform2DContext( ContextHandler& rParent, const Reference< XFastAttributeList >& xAttribs, Shape& rShape, bool btxXfrm ) throw()
 : ContextHandler( rParent )
 , mrShape( rShape )
+, mbtxXfrm ( btxXfrm )
 {
     AttributeList aAttributeList( xAttribs );
-    mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
-    mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
+    if( !btxXfrm )
+    {
+        mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise
+        mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) );
+    }
+    else
+    {
+        mrShape.getTextBody()->getTextProperties().moRotation = aAttributeList.getInteger( XML_rot );
+    }
 }
 
 Reference< XFastContextHandler > Transform2DContext::createFastChildContext( sal_Int32 aElementToken, const Reference< XFastAttributeList >& xAttribs ) throw (SAXException, RuntimeException)
 {
+    if( mbtxXfrm )
+    {
+        switch( aElementToken )
+        {
+            case A_TOKEN( off ):
+                {
+                    OUString sXValue = xAttribs->getOptionalValue( XML_x );
+                    OUString sYValue = xAttribs->getOptionalValue( XML_y );
+                    if( !sXValue.isEmpty() )
+                        mrShape.getTextBody()->getTextProperties().moTextOffX = GetCoordinate( sXValue.toInt32() - mrShape.getPosition().X );
+                    if( !sYValue.isEmpty() )
+                        mrShape.getTextBody()->getTextProperties().moTextOffY = GetCoordinate( sYValue.toInt32() - mrShape.getPosition().Y );
+                }
+                break;
+            case A_TOKEN( ext ):
+                break;
+        }
+        return 0;
+    }
+
     switch( aElementToken )
     {
     case A_TOKEN( off ):        // horz/vert translation
diff --git a/oox/source/ppt/pptshapecontext.cxx b/oox/source/ppt/pptshapecontext.cxx
index ce09d8b..82a7250 100644
--- a/oox/source/ppt/pptshapecontext.cxx
+++ b/oox/source/ppt/pptshapecontext.cxx
@@ -34,6 +34,7 @@
 #include "oox/drawingml/drawingmltypes.hxx"
 #include "oox/drawingml/customshapegeometry.hxx"
 #include "oox/drawingml/textbodycontext.hxx"
+#include "oox/drawingml/transform2dcontext.hxx"
 
 using rtl::OUString;
 using namespace oox::core;
@@ -225,8 +226,7 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
         }
         case PPT_TOKEN( txXfrm ):
         {
-            AttributeList aAttribs( xAttribs );
-            mpShapePtr->getTextBody()->getTextProperties().moRotation = aAttribs.getInteger( XML_rot );
+            xRet = new oox::drawingml::Transform2DContext( *this, xAttribs, *mpShapePtr, true );
             break;
         }
     }


More information about the Libreoffice-commits mailing list