From 1679aca6f61f1d28b06649a55010f72e6666abc0 Mon Sep 17 00:00:00 2001 From: Luboš Luňák Date: Thu, 8 Nov 2012 14:24:29 +0100 Subject: implement inset attribute of (part of bnc#773061) Change-Id: I1ec9b5d9fed86c44dc0a412c2323033ea67985c9 --- oox/inc/oox/vml/vmlshape.hxx | 2 ++ oox/inc/oox/vml/vmltextbox.hxx | 4 ++++ oox/inc/oox/vml/vmltextboxcontext.hxx | 3 ++- oox/source/token/properties.txt | 4 ++++ oox/source/vml/vmlshape.cxx | 7 +++++++ oox/source/vml/vmlshapecontext.cxx | 4 +++- oox/source/vml/vmltextbox.cxx | 1 + oox/source/vml/vmltextboxcontext.cxx | 22 +++++++++++++++++++++- 8 files changed, 44 insertions(+), 3 deletions(-) diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index cf7100640d06..2bdf16ed9879 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -129,6 +129,8 @@ public: /** Returns the fragment path to the embedded graphic used by this shape. */ ::rtl::OUString getGraphicPath() const; + const Drawing& getDrawing() const { return mrDrawing; } + protected: /** Returns the coordinate system of this shape. */ ::com::sun::star::awt::Rectangle getCoordSystem() const; diff --git a/oox/inc/oox/vml/vmltextbox.hxx b/oox/inc/oox/vml/vmltextbox.hxx index cc2e41bdd8ef..ed716de65dfd 100644 --- a/oox/inc/oox/vml/vmltextbox.hxx +++ b/oox/inc/oox/vml/vmltextbox.hxx @@ -83,6 +83,10 @@ public: /** Returns the entire text of all text portions. */ ::rtl::OUString getText() const; + /// Text distance from the border (inset attribute of v:textbox), valid only if set. + bool borderDistanceSet; + int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom; + private: typedef ::std::vector< TextPortionModel > PortionVector; diff --git a/oox/inc/oox/vml/vmltextboxcontext.hxx b/oox/inc/oox/vml/vmltextboxcontext.hxx index 64c1c97324c2..abe6395ff6d9 100644 --- a/oox/inc/oox/vml/vmltextboxcontext.hxx +++ b/oox/inc/oox/vml/vmltextboxcontext.hxx @@ -66,7 +66,8 @@ public: explicit TextBoxContext( ::oox::core::ContextHandler2Helper& rParent, TextBox& rTextBox, - const AttributeList& rAttribs ); + const AttributeList& rAttribs, + const GraphicHelper& graphicHelper ); virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); diff --git a/oox/source/token/properties.txt b/oox/source/token/properties.txt index 4710f1483a4b..8835c2cc87f5 100644 --- a/oox/source/token/properties.txt +++ b/oox/source/token/properties.txt @@ -34,6 +34,7 @@ BorderStyle BorderTransparency BorderWidth BottomBorder +BottomBorderDistance BottomMargin BulletChar BulletColor @@ -263,6 +264,7 @@ LabelPosition LabelSeparator LayoutInfo LeftBorder +LeftBorderDistance LeftMargin LeftPageFooterContent LeftPageHeaderContent @@ -383,6 +385,7 @@ RepeatDelay Representation RightAngledAxes RightBorder +RightBorderDistance RightMargin RightPageFooterContent RightPageHeaderContent @@ -485,6 +488,7 @@ Title Toggle TokenIndex TopBorder +TopBorderDistance TopMargin Transformation TransitionDirection diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index e68bfab84b9c..5b6b6c56feb4 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -443,6 +443,13 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes { PropertySet( xShape ).setAnyProperty( PROP_FrameIsAutomaticHeight, makeAny( maTypeModel.mbAutoHeight ) ); PropertySet( xShape ).setAnyProperty( PROP_SizeType, makeAny( maTypeModel.mbAutoHeight ? SizeType::MIN : SizeType::FIX ) ); + if( getTextBox()->borderDistanceSet ) + { + PropertySet( xShape ).setAnyProperty( PROP_LeftBorderDistance, makeAny( getTextBox()->borderDistanceLeft )); + PropertySet( xShape ).setAnyProperty( PROP_TopBorderDistance, makeAny( getTextBox()->borderDistanceTop )); + PropertySet( xShape ).setAnyProperty( PROP_RightBorderDistance, makeAny( getTextBox()->borderDistanceRight )); + PropertySet( xShape ).setAnyProperty( PROP_BottomBorderDistance, makeAny( getTextBox()->borderDistanceBottom )); + } } else { diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 0ed4d8b25076..ae00af2de976 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -28,6 +28,7 @@ #include "oox/vml/vmlshapecontext.hxx" +#include "oox/core/xmlfilterbase.hxx" #include "oox/vml/vmldrawing.hxx" #include "oox/vml/vmlshape.hxx" #include "oox/vml/vmlshapecontainer.hxx" @@ -409,7 +410,8 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri // Custom shape in Writer with a textbox are transformed into a frame dynamic_cast( mrShape ).setService( "com.sun.star.text.TextFrame"); - return new TextBoxContext( *this, mrShapeModel.createTextBox(), rAttribs ); + return new TextBoxContext( *this, mrShapeModel.createTextBox(), rAttribs, + mrShape.getDrawing().getFilter().getGraphicHelper()); case VMLX_TOKEN( ClientData ): return new ClientDataContext( *this, mrShapeModel.createClientData(), rAttribs ); case VMLPPT_TOKEN( textdata ): diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 8bb1c39bbe1f..b4dc7dbdd925 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -55,6 +55,7 @@ TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& // ============================================================================ TextBox::TextBox() + : borderDistanceSet( false ) { } diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 2d70c9311622..841c1508e2ec 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -26,6 +26,7 @@ * ************************************************************************/ +#include "oox/vml/vmlformatting.hxx" #include "oox/vml/vmltextboxcontext.hxx" namespace oox { @@ -126,10 +127,29 @@ void TextPortionContext::onEndElement() // ============================================================================ -TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBox, const AttributeList& /*rAttribs*/ ) : +TextBoxContext::TextBoxContext( ContextHandler2Helper& rParent, TextBox& rTextBox, const AttributeList& rAttribs, + const GraphicHelper& graphicHelper ) : ContextHandler2( rParent ), mrTextBox( rTextBox ) { + if( rAttribs.getString( XML_insetmode ).get() != "auto" ) + { + OUString inset = rAttribs.getString( XML_inset ).get(); + OUString value; + ConversionHelper::separatePair( value, inset, inset, ',' ); + rTextBox.borderDistanceLeft = ConversionHelper::decodeMeasureToEmu( graphicHelper, + value.isEmpty() ? "0.1in" : value, 0, false, false ); + ConversionHelper::separatePair( value, inset, inset, ',' ); + rTextBox.borderDistanceTop = ConversionHelper::decodeMeasureToEmu( graphicHelper, + value.isEmpty() ? "0.05in" : value, 0, false, false ); + ConversionHelper::separatePair( value, inset, inset, ',' ); + rTextBox.borderDistanceRight = ConversionHelper::decodeMeasureToEmu( graphicHelper, + value.isEmpty() ? "0.1in" : value, 0, false, false ); + ConversionHelper::separatePair( value, inset, inset, ',' ); + rTextBox.borderDistanceBottom = ConversionHelper::decodeMeasureToEmu( graphicHelper, + value.isEmpty() ? "0.05in" : value, 0, false, false ); + rTextBox.borderDistanceSet = true; + } } ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) -- cgit v1.2.3