summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/oox/vml/vmltextbox.hxx11
-rw-r--r--include/oox/vml/vmltextboxcontext.hxx4
-rw-r--r--oox/source/vml/vmltextbox.cxx21
-rw-r--r--oox/source/vml/vmltextboxcontext.cxx38
4 files changed, 60 insertions, 14 deletions
diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx
index 4975e6bb26b6..fc97dc78413b 100644
--- a/include/oox/vml/vmltextbox.hxx
+++ b/include/oox/vml/vmltextbox.hxx
@@ -37,6 +37,12 @@ struct ShapeTypeModel;
// ============================================================================
+/// A text paragraph in a textbox.
+struct TextParagraphModel
+{
+ OptValue<OUString> moParaAdjust; ///< Paragraph adjust (left, center, right, etc.)
+};
+
/** Font settings for a text portion in a textbox. */
struct OOX_DLLPUBLIC TextFontModel
{
@@ -57,10 +63,11 @@ struct OOX_DLLPUBLIC TextFontModel
/** A text portion in a textbox with the same formatting for all characters. */
struct TextPortionModel
{
+ TextParagraphModel maParagraph;
TextFontModel maFont;
OUString maText;
- explicit TextPortionModel( const TextFontModel& rFont, const OUString& rText );
+ explicit TextPortionModel( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
};
// ============================================================================
@@ -72,7 +79,7 @@ public:
explicit TextBox(ShapeTypeModel& rTypeModel);
/** Appends a new text portion to the textbox. */
- void appendPortion( const TextFontModel& rFont, const OUString& rText );
+ void appendPortion( const TextParagraphModel& rParagraph, const TextFontModel& rFont, const OUString& rText );
/** Returns the current number of text portions. */
inline size_t getPortionCount() const { return maPortions.size(); }
diff --git a/include/oox/vml/vmltextboxcontext.hxx b/include/oox/vml/vmltextboxcontext.hxx
index 1a44e41ee4b1..150297f6bdf1 100644
--- a/include/oox/vml/vmltextboxcontext.hxx
+++ b/include/oox/vml/vmltextboxcontext.hxx
@@ -36,6 +36,7 @@ public:
explicit TextPortionContext(
::oox::core::ContextHandler2Helper& rParent,
TextBox& rTextBox,
+ TextParagraphModel& rParagraph,
const TextFontModel& rParentFont,
sal_Int32 nElement,
const AttributeList& rAttribs );
@@ -48,6 +49,7 @@ public:
private:
TextBox& mrTextBox;
+ TextParagraphModel maParagraph;
TextFontModel maFont;
size_t mnInitialPortions;
};
@@ -65,10 +67,12 @@ public:
virtual ::oox::core::ContextHandlerRef
onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs );
+ virtual void onStartElement(const AttributeList& rAttribs) SAL_OVERRIDE;
virtual void onEndElement();
private:
TextBox& mrTextBox;
+ TextParagraphModel maParagraph;
};
// ============================================================================
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();
+ }
}
// ============================================================================