diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/inc/oox/vml/vmlshape.hxx | 2 | ||||
-rw-r--r-- | oox/inc/oox/vml/vmltextbox.hxx | 11 | ||||
-rw-r--r-- | oox/inc/oox/vml/vmltextboxcontext.hxx | 1 | ||||
-rw-r--r-- | oox/source/vml/vmlshape.cxx | 15 | ||||
-rw-r--r-- | oox/source/vml/vmlshapecontext.cxx | 11 | ||||
-rw-r--r-- | oox/source/vml/vmltextbox.cxx | 36 | ||||
-rw-r--r-- | oox/source/vml/vmltextboxcontext.cxx | 45 |
7 files changed, 109 insertions, 12 deletions
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx index 87b51d1cedac..35d3a8524ee7 100644 --- a/oox/inc/oox/vml/vmlshape.hxx +++ b/oox/inc/oox/vml/vmlshape.hxx @@ -202,7 +202,7 @@ struct ShapeModel ~ShapeModel(); /** Creates and returns a new shape textbox structure. */ - TextBox& createTextBox(); + TextBox& createTextBox(ShapeTypeModel& rModel); /** Creates and returns a new shape client data structure. */ ClientData& createClientData(); }; diff --git a/oox/inc/oox/vml/vmltextbox.hxx b/oox/inc/oox/vml/vmltextbox.hxx index af69e779e601..49814439a91f 100644 --- a/oox/inc/oox/vml/vmltextbox.hxx +++ b/oox/inc/oox/vml/vmltextbox.hxx @@ -24,10 +24,17 @@ #include <rtl/ustring.hxx> #include "oox/helper/helper.hxx" #include "oox/dllapi.h" +#include <com/sun/star/uno/Reference.h> + +namespace com { namespace sun { namespace star { + namespace drawing { class XShape; } +} } } namespace oox { namespace vml { +class ShapeTypeModel; + // ============================================================================ /** Font settings for a text portion in a textbox. */ @@ -62,7 +69,7 @@ struct TextPortionModel class OOX_DLLPUBLIC TextBox { public: - explicit TextBox(); + explicit TextBox(ShapeTypeModel& rTypeModel); /** Appends a new text portion to the textbox. */ void appendPortion( const TextFontModel& rFont, const ::rtl::OUString& rText ); @@ -73,7 +80,9 @@ public: const TextFontModel* getFirstFont() const; /** Returns the entire text of all text portions. */ ::rtl::OUString getText() const; + void convert(com::sun::star::uno::Reference<com::sun::star::drawing::XShape> xShape) const; + ShapeTypeModel& mrTypeModel; /// Text distance from the border (inset attribute of v:textbox), valid only if set. bool borderDistanceSet; int borderDistanceLeft, borderDistanceTop, borderDistanceRight, borderDistanceBottom; diff --git a/oox/inc/oox/vml/vmltextboxcontext.hxx b/oox/inc/oox/vml/vmltextboxcontext.hxx index 4fd35d187f2f..a644026f7b4d 100644 --- a/oox/inc/oox/vml/vmltextboxcontext.hxx +++ b/oox/inc/oox/vml/vmltextboxcontext.hxx @@ -41,6 +41,7 @@ public: virtual ::oox::core::ContextHandlerRef onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ); virtual void onCharacters( const ::rtl::OUString& rChars ); + virtual void onStartElement(const AttributeList& rAttribs); virtual void onEndElement(); private: diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index a70f51fd9844..1b0caf9224b1 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -233,9 +233,9 @@ ShapeModel::~ShapeModel() { } -TextBox& ShapeModel::createTextBox() +TextBox& ShapeModel::createTextBox(ShapeTypeModel& rModel) { - mxTextBox.reset( new TextBox ); + mxTextBox.reset( new TextBox(rModel) ); return *mxTextBox; } @@ -486,6 +486,9 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes PropertySet( xShape ).setAnyProperty(PROP_RelativeHeight, makeAny( nHeight ) ); } } + + if (getTextBox()) + getTextBox()->convert(xShape); } // Import Legacy Fragments (if any) @@ -522,8 +525,9 @@ Reference< XShape > SimpleShape::createPictureObject( const Reference< XShapes > { aPropSet.setProperty( PROP_GraphicURL, aGraphicUrl ); } - // If the shape has an absolute position, set the properties accordingly. - if ( maTypeModel.maPosition == "absolute" ) + uno::Reference< lang::XServiceInfo > xServiceInfo(rxShapes, uno::UNO_QUERY); + // If the shape has an absolute position, set the properties accordingly, unless we're inside a group shape. + if ( maTypeModel.maPosition == "absolute" && !xServiceInfo->supportsService("com.sun.star.drawing.GroupShape")) { aPropSet.setProperty(PROP_HoriOrientPosition, rShapeRect.X); aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y); @@ -866,6 +870,9 @@ Reference< XShape > GroupShape::implConvertAndInsert( const Reference< XShapes > catch( Exception& ) { } + // Make sure group shapes are inline as well, unless there is an explicit different style. + PropertySet aPropertySet(xGroupShape); + lcl_SetAnchorType(aPropertySet, maTypeModel); return xGroupShape; } diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index 394c963abd32..f734999f5f18 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -404,10 +404,13 @@ ContextHandlerRef ShapeContext::onCreateContext( sal_Int32 nElement, const Attri if( isRootElement() ) switch( nElement ) { case VML_TOKEN( textbox ): - // Custom shape in Writer with a textbox are transformed into a frame - dynamic_cast<SimpleShape&>( mrShape ).setService( - "com.sun.star.text.TextFrame"); - return new TextBoxContext( *this, mrShapeModel.createTextBox(), rAttribs, + if (getParentElement() != VML_TOKEN( group )) + { + // Custom shape in Writer with a textbox are transformed into a frame + dynamic_cast<SimpleShape&>( mrShape ).setService( + "com.sun.star.text.TextFrame"); + } + return new TextBoxContext( *this, mrShapeModel.createTextBox(mrShape.getTypeModel()), rAttribs, mrShape.getDrawing().getFilter().getGraphicHelper()); case VMLX_TOKEN( ClientData ): return new ClientDataContext( *this, mrShapeModel.createClientData(), rAttribs ); diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 03c4eff90e9d..4af0a9d67cc0 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -20,12 +20,15 @@ #include "oox/vml/vmltextbox.hxx" #include <rtl/ustrbuf.hxx> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/text/XTextAppend.hpp> namespace oox { namespace vml { using ::rtl::OUString; using ::rtl::OUStringBuffer; +using namespace com::sun::star; TextFontModel::TextFontModel() { @@ -37,8 +40,9 @@ TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& { } -TextBox::TextBox() - : borderDistanceSet( false ) +TextBox::TextBox(ShapeTypeModel& rTypeModel) + : mrTypeModel(rTypeModel), + borderDistanceSet( false ) { } @@ -60,6 +64,34 @@ OUString TextBox::getText() const return aBuffer.makeStringAndClear(); } +void TextBox::convert(uno::Reference<drawing::XShape> xShape) const +{ + uno::Reference<text::XTextAppend> xTextAppend(xShape, uno::UNO_QUERY); + for (PortionVector::const_iterator aIt = maPortions.begin(), aEnd = maPortions.end(); aIt != aEnd; ++aIt) + { + beans::PropertyValue aPropertyValue; + std::vector<beans::PropertyValue> aPropVec; + const TextFontModel& rFont = aIt->maFont; + if (rFont.mobBold.has()) + { + aPropertyValue.Name = "CharWeight"; + aPropertyValue.Value = uno::makeAny(rFont.mobBold.get() ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL); + aPropVec.push_back(aPropertyValue); + } + if (rFont.monSize.has()) + { + aPropertyValue.Name = "CharHeight"; + aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.); + aPropVec.push_back(aPropertyValue); + } + uno::Sequence<beans::PropertyValue> aPropSeq(aPropVec.size()); + beans::PropertyValue* pValues = aPropSeq.getArray(); + for (std::vector<beans::PropertyValue>::iterator i = aPropVec.begin(); i != aPropVec.end(); ++i) + *pValues++ = *i; + xTextAppend->appendTextPortion(aIt->maText, aPropSeq); + } +} + } // namespace vml } // namespace oox diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 2724a1f70d10..3755cc7efd5b 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -19,6 +19,8 @@ #include "oox/vml/vmlformatting.hxx" #include "oox/vml/vmltextboxcontext.hxx" +#include "oox/vml/vmlshape.hxx" +#include <com/sun/star/drawing/XShape.hpp> namespace oox { namespace vml { @@ -68,7 +70,22 @@ TextPortionContext::TextPortionContext( ContextHandler2Helper& rParent, OSL_ENSURE( !maFont.mobStrikeout, "TextPortionContext::TextPortionContext - nested <s> elements" ); maFont.mobStrikeout = true; break; + case OOX_TOKEN(dml, blip): + { + OptValue<OUString> oRelId = rAttribs.getString(R_TOKEN(embed)); + if (oRelId.has()) + mrTextBox.mrTypeModel.moGraphicPath = getFragmentPathFromRelId(oRelId.get()); + } + break; + case VML_TOKEN(imagedata): + { + OptValue<OUString> oRelId = rAttribs.getString(R_TOKEN(id)); + if (oRelId.has()) + mrTextBox.mrTypeModel.moGraphicPath = getFragmentPathFromRelId(oRelId.get()); + } + break; case XML_span: + case OOX_TOKEN(doc, r): break; default: OSL_ENSURE( false, "TextPortionContext::TextPortionContext - unknown element" ); @@ -78,11 +95,16 @@ TextPortionContext::TextPortionContext( ContextHandler2Helper& rParent, ContextHandlerRef TextPortionContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs ) { OSL_ENSURE( nElement != XML_font, "TextPortionContext::onCreateContext - nested <font> elements" ); + if (getNamespace(getCurrentElement()) == NMSP_doc) + return this; return new TextPortionContext( *this, mrTextBox, maFont, nElement, rAttribs ); } void TextPortionContext::onCharacters( const OUString& rChars ) { + if (getNamespace(getCurrentElement()) == NMSP_doc && getCurrentElement() != OOX_TOKEN(doc, t)) + return; + switch( getCurrentElement() ) { case XML_span: @@ -94,8 +116,24 @@ void TextPortionContext::onCharacters( const OUString& rChars ) } } +void TextPortionContext::onStartElement(const AttributeList& rAttribs) +{ + switch (getCurrentElement()) + { + case OOX_TOKEN(doc, b): + maFont.mobBold = true; + break; + case OOX_TOKEN(doc, sz): + maFont.monSize = rAttribs.getInteger( OOX_TOKEN(doc, val) ); + break; + } +} + void TextPortionContext::onEndElement() { + if (getNamespace(getCurrentElement()) == NMSP_doc && getCurrentElement() != OOX_TOKEN(doc, t)) + return; + /* A child element without own child elements may contain a single space character, for example: @@ -149,10 +187,17 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att { case VML_TOKEN( textbox ): if( nElement == XML_div ) return this; + else if (nElement == OOX_TOKEN(doc, txbxContent)) return this; break; case XML_div: if( nElement == XML_font ) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs ); break; + case OOX_TOKEN(doc, txbxContent): + if (nElement == OOX_TOKEN(doc, p)) return this; + break; + case OOX_TOKEN(doc, p): + if (nElement == OOX_TOKEN(doc, r)) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs ); + break; } return 0; } |