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

Muthu Subramanian sumuthu at kemper.freedesktop.org
Thu Aug 16 04:26:26 PDT 2012


 oox/inc/oox/drawingml/textbodyproperties.hxx       |    3 ++
 oox/source/drawingml/shape.cxx                     |    3 ++
 oox/source/drawingml/textbodyproperties.cxx        |   22 ++++++++++++++++++
 oox/source/drawingml/textbodypropertiescontext.cxx |   25 +++++----------------
 4 files changed, 34 insertions(+), 19 deletions(-)

New commits:
commit 5ac575ee3e10961177263d8900073d046af66176
Author: Muthu Subramanian <sumuthu at suse.com>
Date:   Thu Aug 16 16:57:47 2012 +0530

    n#773048: PPTX shape margins need to be rotated as well.

diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx
index ce2dcab..25007be 100644
--- a/oox/inc/oox/drawingml/textbodyproperties.hxx
+++ b/oox/inc/oox/drawingml/textbodyproperties.hxx
@@ -23,6 +23,7 @@
 #include <com/sun/star/drawing/TextVerticalAdjust.hpp>
 #include "oox/helper/helper.hxx"
 #include "oox/helper/propertymap.hxx"
+#include <boost/optional.hpp>
 
 namespace oox {
 namespace drawingml {
@@ -34,10 +35,12 @@ struct TextBodyProperties
     PropertyMap                                     maPropertyMap;
     OptValue< sal_Int32 >                           moRotation;
     OptValue< sal_Int32 >                           moVert;
+    boost::optional< sal_Int32 >                    moInsets[4];
     ::com::sun::star::drawing::TextVerticalAdjust   meVA;
 
     explicit            TextBodyProperties();
 
+    void                pushRotationAdjustments( sal_Int32 nRotation );
     void                pushVertSimulation();
 };
 
diff --git a/oox/source/drawingml/shape.cxx b/oox/source/drawingml/shape.cxx
index c796554..6d2ff4c 100644
--- a/oox/source/drawingml/shape.cxx
+++ b/oox/source/drawingml/shape.cxx
@@ -516,7 +516,10 @@ Reference< XShape > Shape::createAndInsert(
 
         // add properties from textbody to shape properties
         if( mpTextBody.get() )
+        {
+            mpTextBody->getTextProperties().pushRotationAdjustments( mnRotation );
             aShapeProps.assignUsed( mpTextBody->getTextProperties().maPropertyMap );
+        }
 
         // applying properties
         aShapeProps.assignUsed( getShapeProperties() );
diff --git a/oox/source/drawingml/textbodyproperties.cxx b/oox/source/drawingml/textbodyproperties.cxx
index 1f61392..f377ee9 100644
--- a/oox/source/drawingml/textbodyproperties.cxx
+++ b/oox/source/drawingml/textbodyproperties.cxx
@@ -58,6 +58,28 @@ void TextBodyProperties::pushVertSimulation()
     }
 }
 
+/* Push adjusted values, taking into consideration Shape Rotation */
+void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation )
+{
+    sal_Int32 nOff      = 0;
+    sal_Int32 aProps[]  = { PROP_TextLeftDistance, PROP_TextUpperDistance, PROP_TextRightDistance, PROP_TextLowerDistance };
+    sal_Int32 n         = ( sal_Int32 )( sizeof( aProps ) / sizeof( sal_Int32 ) );
+
+    switch( nRotation ) // TODO: What happens for part rotations ?
+    {
+        case (90*1*60000): nOff = 1; break;
+        case (90*2*60000): nOff = 2; break;
+        case (90*3*60000): nOff = 3; break;
+        default: break;
+    }
+
+    for( sal_Int32 i = 0; i < n; i++ )
+    {
+        if( moInsets[i] )
+            maPropertyMap[ aProps[ ( nOff++ ) % n ] ] <<= static_cast< sal_Int32 >( *moInsets[i] );
+    }
+}
+
 // ============================================================================
 
 } // namespace drawingml
diff --git a/oox/source/drawingml/textbodypropertiescontext.cxx b/oox/source/drawingml/textbodypropertiescontext.cxx
index a21591c..5bae9f0 100644
--- a/oox/source/drawingml/textbodypropertiescontext.cxx
+++ b/oox/source/drawingml/textbodypropertiescontext.cxx
@@ -53,25 +53,12 @@ TextBodyPropertiesContext::TextBodyPropertiesContext( ContextHandler& rParent,
 
     // ST_Coordinate
     OUString sValue;
-    sValue = xAttributes->getOptionalValue( XML_lIns );
-    if( !sValue.isEmpty() ) {
-    sal_Int32 nLeftInset = ( !sValue.isEmpty() ? GetCoordinate(  sValue ) : 91440 / 360 );
-    mrTextBodyProp.maPropertyMap[ PROP_TextLeftDistance ]  <<= static_cast< sal_Int32 >( nLeftInset );
-    }
-    sValue = xAttributes->getOptionalValue( XML_tIns );
-    if( !sValue.isEmpty() ) {
-    sal_Int32 nTopInset  = ( !sValue.isEmpty() ? GetCoordinate(  sValue ) : 91440 / 360 );
-    mrTextBodyProp.maPropertyMap[ PROP_TextUpperDistance ] <<= static_cast< sal_Int32 >( nTopInset );
-    }
-    sValue = xAttributes->getOptionalValue( XML_rIns );
-    if( !sValue.isEmpty() ) {
-    sal_Int32 nRightInset  = ( !sValue.isEmpty() ? GetCoordinate(  sValue ) : 91440 / 360 );
-    mrTextBodyProp.maPropertyMap[ PROP_TextRightDistance ] <<= static_cast< sal_Int32 >( nRightInset );
-    }
-    sValue = xAttributes->getOptionalValue( XML_bIns );
-    if( !sValue.isEmpty() ) {
-    sal_Int32 nBottonInset = ( !sValue.isEmpty() ? GetCoordinate(  sValue ) : 45720 / 360 );
-    mrTextBodyProp.maPropertyMap[ PROP_TextLowerDistance ] <<= static_cast< sal_Int32 >( nBottonInset );
+    sal_Int32 aIns[] = { XML_lIns, XML_tIns, XML_rIns, XML_bIns };
+    for( sal_Int32 i = 0; i < ( sal_Int32 )( sizeof( aIns ) / sizeof( sal_Int32 ) ); i++)
+    {
+        sValue = xAttributes->getOptionalValue( aIns[i] );
+        if( !sValue.isEmpty() )
+            mrTextBodyProp.moInsets[i] = GetCoordinate( sValue );
     }
 
     bool bAnchorCenter = aAttribs.getBool( XML_anchorCtr, false );


More information about the Libreoffice-commits mailing list