diff options
author | Muthu Subramanian <sumuthu@suse.com> | 2012-09-06 12:34:14 +0530 |
---|---|---|
committer | Muthu Subramanian <sumuthu@suse.com> | 2012-09-06 12:42:06 +0530 |
commit | 5ca197ce7a2a845933e17fc90195c929cbc7e062 (patch) | |
tree | bac9d22e237acb5315ecd77da7e19d0e5cefb30c /oox | |
parent | c75af8578d921040e1baf8414edd7239969bcd45 (diff) |
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.
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/drawingml/textbodyproperties.hxx | 2 | ||||
-rw-r--r-- | oox/inc/oox/drawingml/transform2dcontext.hxx | 3 | ||||
-rw-r--r-- | oox/source/drawingml/textbodyproperties.cxx | 15 | ||||
-rw-r--r-- | oox/source/drawingml/transform2dcontext.cxx | 35 | ||||
-rw-r--r-- | oox/source/ppt/pptshapecontext.cxx | 4 |
5 files changed, 52 insertions, 7 deletions
diff --git a/oox/inc/oox/drawingml/textbodyproperties.hxx b/oox/inc/oox/drawingml/textbodyproperties.hxx index 25007be53f35..f8800be29659 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 8a8b18c32bfc..6bbbe191e77c 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 f377ee96fd0b..36f39d93953f 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 9ded1df5080e..d35c5d3c921a 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 ce09d8bcb8c9..82a7250b3352 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; } } |