summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuthu Subramanian <sumuthu@suse.com>2012-08-16 16:57:47 +0530
committerMuthu Subramanian <sumuthu@suse.com>2012-08-16 16:59:35 +0530
commit5ac575ee3e10961177263d8900073d046af66176 (patch)
tree1bed36c4dbda37f605c2827c9f92c43e16eef5bd
parent919ec40f18dee709c0305cedafae3b9bfffb1270 (diff)
n#773048: PPTX shape margins need to be rotated as well.
-rw-r--r--oox/inc/oox/drawingml/textbodyproperties.hxx3
-rw-r--r--oox/source/drawingml/shape.cxx3
-rw-r--r--oox/source/drawingml/textbodyproperties.cxx22
-rw-r--r--oox/source/drawingml/textbodypropertiescontext.cxx25
4 files changed, 34 insertions, 19 deletions
diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx
index ce2dcab563b5..25007be53f35 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 c796554bd085..6d2ff4c72518 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 1f61392d2196..f377ee96fd0b 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 a21591c42d59..5bae9f00ab1f 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 );