diff options
author | Miklos Vajna <vmiklos@suse.cz> | 2013-07-01 16:47:56 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@suse.cz> | 2013-07-02 11:55:43 +0200 |
commit | 5a737fca37cd5a5f90aa03a30688d447677d3b8a (patch) | |
tree | c14f1ecb1245b72aa8bd63875ba51167490b8482 /oox/source | |
parent | 6bf79576aeca243db553ed3b5eade492dc35337b (diff) |
fdo#46361 oox: handle w:jc for groupshape textboxes
Change-Id: I21391d9a9f5b5173b599006287b33fdaab3c0c75
Diffstat (limited to 'oox/source')
-rw-r--r-- | oox/source/vml/vmltextbox.cxx | 21 | ||||
-rw-r--r-- | oox/source/vml/vmltextboxcontext.cxx | 38 |
2 files changed, 47 insertions, 12 deletions
diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 27b423491a4d..3b81caf5908a 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextAppend.hpp> #include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> namespace oox { namespace vml { @@ -34,7 +35,8 @@ TextFontModel::TextFontModel() { } -TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& rText ) : +TextPortionModel::TextPortionModel( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText ) : + maParagraph( rParagraph ), maFont( rFont ), maText( rText ) { @@ -50,9 +52,9 @@ TextBox::TextBox(ShapeTypeModel& rTypeModel) { } -void TextBox::appendPortion( const TextFontModel& rFont, const OUString& rText ) +void TextBox::appendPortion( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText ) { - maPortions.push_back( TextPortionModel( rFont, rText ) ); + maPortions.push_back( TextPortionModel( rParagraph, rFont, rText ) ); } const TextFontModel* TextBox::getFirstFont() const @@ -75,6 +77,7 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const { beans::PropertyValue aPropertyValue; std::vector<beans::PropertyValue> aPropVec; + const TextParagraphModel& rParagraph = aIt->maParagraph; const TextFontModel& rFont = aIt->maFont; if (rFont.mobBold.has()) { @@ -88,6 +91,18 @@ void TextBox::convert(uno::Reference<drawing::XShape> xShape) const aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.); aPropVec.push_back(aPropertyValue); } + if (rParagraph.moParaAdjust.has()) + { + style::ParagraphAdjust eAdjust = style::ParagraphAdjust_LEFT; + if (rParagraph.moParaAdjust.get() == "center") + eAdjust = style::ParagraphAdjust_CENTER; + else if (rParagraph.moParaAdjust.get() == "right") + eAdjust = style::ParagraphAdjust_RIGHT; + + aPropertyValue.Name = "ParaAdjust"; + aPropertyValue.Value = uno::makeAny(eAdjust); + 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) diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index 4c025c9068cc..9fbf26cfeffe 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -34,10 +34,11 @@ using ::oox::core::ContextHandlerRef; // ============================================================================ TextPortionContext::TextPortionContext( ContextHandler2Helper& rParent, - TextBox& rTextBox, const TextFontModel& rParentFont, + TextBox& rTextBox, TextParagraphModel& rParagraph, const TextFontModel& rParentFont, sal_Int32 nElement, const AttributeList& rAttribs ) : ContextHandler2( rParent ), mrTextBox( rTextBox ), + maParagraph( rParagraph ), maFont( rParentFont ), mnInitialPortions( rTextBox.getPortionCount() ) { @@ -96,7 +97,7 @@ ContextHandlerRef TextPortionContext::onCreateContext( sal_Int32 nElement, const 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 ); + return new TextPortionContext( *this, mrTextBox, maParagraph, maFont, nElement, rAttribs ); } void TextPortionContext::onCharacters( const OUString& rChars ) @@ -108,10 +109,10 @@ void TextPortionContext::onCharacters( const OUString& rChars ) { case XML_span: // replace all NBSP characters with SP - mrTextBox.appendPortion( maFont, rChars.replace( 0xA0, ' ' ) ); + mrTextBox.appendPortion( maParagraph, maFont, rChars.replace( 0xA0, ' ' ) ); break; default: - mrTextBox.appendPortion( maFont, rChars ); + mrTextBox.appendPortion( maParagraph, maFont, rChars ); } } @@ -126,7 +127,7 @@ void TextPortionContext::onStartElement(const AttributeList& rAttribs) maFont.monSize = rAttribs.getInteger( OOX_TOKEN(doc, val) ); break; case OOX_TOKEN(doc, br): - mrTextBox.appendPortion( maFont, "\n" ); + mrTextBox.appendPortion( maParagraph, maFont, "\n" ); break; } } @@ -153,7 +154,7 @@ void TextPortionContext::onEndElement() meantime, the space character has to be added manually. */ if( mrTextBox.getPortionCount() == mnInitialPortions ) - mrTextBox.appendPortion( maFont, OUString( sal_Unicode( ' ' ) ) ); + mrTextBox.appendPortion( maParagraph, maFont, OUString( sal_Unicode( ' ' ) ) ); } // ============================================================================ @@ -207,22 +208,41 @@ ContextHandlerRef TextBoxContext::onCreateContext( sal_Int32 nElement, const Att 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 ); + if( nElement == XML_font ) return new TextPortionContext( *this, mrTextBox, maParagraph, 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 ); + if (nElement == OOX_TOKEN(doc, r)) + return new TextPortionContext( *this, mrTextBox, maParagraph, TextFontModel(), nElement, rAttribs ); + else + return this; + break; + case OOX_TOKEN(doc, pPr): + return this; break; } return 0; } +void TextBoxContext::onStartElement(const AttributeList& rAttribs) +{ + switch (getCurrentElement()) + { + case OOX_TOKEN(doc, jc): + maParagraph.moParaAdjust = rAttribs.getString( OOX_TOKEN(doc, val) ); + break; + } +} + void TextBoxContext::onEndElement() { if (getCurrentElement() == OOX_TOKEN(doc, p)) - mrTextBox.appendPortion( TextFontModel(), "\n" ); + { + mrTextBox.appendPortion( maParagraph, TextFontModel(), "\n" ); + maParagraph = TextParagraphModel(); + } } // ============================================================================ |