Kaydet (Commit) 5ca197ce authored tarafından Muthu Subramanian's avatar Muthu Subramanian

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.
üst c75af857
...@@ -36,6 +36,8 @@ struct TextBodyProperties ...@@ -36,6 +36,8 @@ struct TextBodyProperties
OptValue< sal_Int32 > moRotation; OptValue< sal_Int32 > moRotation;
OptValue< sal_Int32 > moVert; OptValue< sal_Int32 > moVert;
boost::optional< sal_Int32 > moInsets[4]; boost::optional< sal_Int32 > moInsets[4];
boost::optional< sal_Int32 > moTextOffX;
boost::optional< sal_Int32 > moTextOffY;
::com::sun::star::drawing::TextVerticalAdjust meVA; ::com::sun::star::drawing::TextVerticalAdjust meVA;
explicit TextBodyProperties(); explicit TextBodyProperties();
......
...@@ -34,11 +34,12 @@ class Transform2DContext : public ::oox::core::ContextHandler ...@@ -34,11 +34,12 @@ class Transform2DContext : public ::oox::core::ContextHandler
{ {
public: public:
Transform2DContext( ::oox::core::ContextHandler& rParent, 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); 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: protected:
Shape& mrShape; Shape& mrShape;
bool mbtxXfrm;
}; };
// ============================================================================ // ============================================================================
......
...@@ -75,8 +75,21 @@ void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation ) ...@@ -75,8 +75,21 @@ void TextBodyProperties::pushRotationAdjustments( sal_Int32 nRotation )
for( sal_Int32 i = 0; i < n; i++ ) 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] ) 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;
} }
} }
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "oox/drawingml/transform2dcontext.hxx" #include "oox/drawingml/transform2dcontext.hxx"
#include "oox/helper/attributelist.hxx" #include "oox/helper/attributelist.hxx"
#include "oox/drawingml/shape.hxx" #include "oox/drawingml/shape.hxx"
#include "oox/drawingml/textbody.hxx"
using ::com::sun::star::awt::Point; using ::com::sun::star::awt::Point;
using ::com::sun::star::awt::Size; using ::com::sun::star::awt::Size;
...@@ -36,17 +37,45 @@ namespace drawingml { ...@@ -36,17 +37,45 @@ namespace drawingml {
// ============================================================================ // ============================================================================
/** context to import a CT_Transform2D */ /** 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 ) : ContextHandler( rParent )
, mrShape( rShape ) , mrShape( rShape )
, mbtxXfrm ( btxXfrm )
{ {
AttributeList aAttributeList( xAttribs ); AttributeList aAttributeList( xAttribs );
mrShape.setRotation( aAttributeList.getInteger( XML_rot, 0 ) ); // 60000ths of a degree Positive angles are clockwise; negative angles are counter-clockwise if( !btxXfrm )
mrShape.setFlip( aAttributeList.getBool( XML_flipH, sal_False ), aAttributeList.getBool( XML_flipV, sal_False ) ); {
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) 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 ) switch( aElementToken )
{ {
case A_TOKEN( off ): // horz/vert translation case A_TOKEN( off ): // horz/vert translation
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "oox/drawingml/drawingmltypes.hxx" #include "oox/drawingml/drawingmltypes.hxx"
#include "oox/drawingml/customshapegeometry.hxx" #include "oox/drawingml/customshapegeometry.hxx"
#include "oox/drawingml/textbodycontext.hxx" #include "oox/drawingml/textbodycontext.hxx"
#include "oox/drawingml/transform2dcontext.hxx"
using rtl::OUString; using rtl::OUString;
using namespace oox::core; using namespace oox::core;
...@@ -225,8 +226,7 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In ...@@ -225,8 +226,7 @@ Reference< XFastContextHandler > PPTShapeContext::createFastChildContext( sal_In
} }
case PPT_TOKEN( txXfrm ): case PPT_TOKEN( txXfrm ):
{ {
AttributeList aAttribs( xAttribs ); xRet = new oox::drawingml::Transform2DContext( *this, xAttribs, *mpShapePtr, true );
mpShapePtr->getTextBody()->getTextProperties().moRotation = aAttribs.getInteger( XML_rot );
break; break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment