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 +-- oox/source/ppt/slidefragmenthandler.cxx | 4 ++- 6 files changed, 55 insertions(+), 8 deletions(-)
New commits: commit 67e59a990a84729a651be3efb32bba3b3ab2e298 Author: Muthu Subramanian <[email protected]> Date: Tue Jul 10 19:39:36 2012 +0530 Crash fix. Though getTheme() is not supposed to be returning NULL. It seems like doing that sometimes. diff --git a/oox/source/ppt/slidefragmenthandler.cxx b/oox/source/ppt/slidefragmenthandler.cxx index 49736dd..6e6ba26 100644 --- a/oox/source/ppt/slidefragmenthandler.cxx +++ b/oox/source/ppt/slidefragmenthandler.cxx @@ -174,7 +174,9 @@ SlideFragmentHandler::~SlideFragmentHandler() throw() case PPT_TOKEN( bgRef ): // a:CT_StyleMatrixReference { - const FillProperties *pFillProperties = mpSlidePersistPtr->getTheme()->getFillStyle( rAttribs.getInteger( XML_idx, -1 ) ); + const FillProperties *pFillProperties = NULL; + if( mpSlidePersistPtr->getTheme() ) + pFillProperties = mpSlidePersistPtr->getTheme()->getFillStyle( rAttribs.getInteger( XML_idx, -1 ) ); FillPropertiesPtr pFillPropertiesPtr( pFillProperties ? new FillProperties( *pFillProperties ) : new FillProperties() ); ContextHandlerRef ret = new ColorContext( *this, mpSlidePersistPtr->getBackgroundColor() ); mpSlidePersistPtr->setBackgroundProperties( pFillPropertiesPtr ); commit c689856e3c608f436f399b134802a2c7a91ae342 Author: Muthu Subramanian <[email protected]> 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 addad6e..ff691da 100644 --- a/oox/inc/oox/drawingml/textbodyproperties.hxx +++ b/oox/inc/oox/drawingml/textbodyproperties.hxx @@ -45,6 +45,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 a5481fc..aca925d 100644 --- a/oox/inc/oox/drawingml/transform2dcontext.hxx +++ b/oox/inc/oox/drawingml/transform2dcontext.hxx @@ -43,11 +43,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 8438ed5..77d7be9 100644 --- a/oox/source/drawingml/textbodyproperties.cxx +++ b/oox/source/drawingml/textbodyproperties.cxx @@ -84,8 +84,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 1d45018..53d27eb 100644 --- a/oox/source/drawingml/transform2dcontext.cxx +++ b/oox/source/drawingml/transform2dcontext.cxx @@ -29,6 +29,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; @@ -45,17 +46,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 c301f23..336f980 100644 --- a/oox/source/ppt/pptshapecontext.cxx +++ b/oox/source/ppt/pptshapecontext.cxx @@ -43,6 +43,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; @@ -234,8 +235,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; } } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
