diff options
-rw-r--r-- | include/oox/drawingml/textparagraphproperties.hxx | 4 | ||||
-rw-r--r-- | oox/source/drawingml/textbodycontext.cxx | 1 | ||||
-rw-r--r-- | oox/source/drawingml/textparagraphpropertiescontext.cxx | 21 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/dml-groupshape-paraadjust.docx | bin | 0 -> 17764 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 20 |
5 files changed, 46 insertions, 0 deletions
diff --git a/include/oox/drawingml/textparagraphproperties.hxx b/include/oox/drawingml/textparagraphproperties.hxx index 8014929fc584..2ed69f95c014 100644 --- a/include/oox/drawingml/textparagraphproperties.hxx +++ b/include/oox/drawingml/textparagraphproperties.hxx @@ -94,6 +94,9 @@ public: boost::optional< sal_Int32 >& getParaLeftMargin(){ return moParaLeftMargin; } boost::optional< sal_Int32 >& getFirstLineIndentation(){ return moFirstLineIndentation; } + boost::optional< sal_Int16 >& getParaAdjust() { return moParaAdjust; } + void setParaAdjust( sal_Int16 nParaAdjust ) { moParaAdjust = nParaAdjust; } + void apply( const TextParagraphProperties& rSourceProps ); void pushToPropSet( const ::oox::core::XmlFilterBase* pFilterBase, const ::com::sun::star::uno::Reference < ::com::sun::star::beans::XPropertySet > & xPropSet, @@ -118,6 +121,7 @@ protected: TextSpacing maParaBottomMargin; boost::optional< sal_Int32 > moParaLeftMargin; boost::optional< sal_Int32 > moFirstLineIndentation; + boost::optional< sal_Int16 > moParaAdjust; sal_Int16 mnLevel; }; diff --git a/oox/source/drawingml/textbodycontext.cxx b/oox/source/drawingml/textbodycontext.cxx index b9921e093a33..48cf3ec5e72b 100644 --- a/oox/source/drawingml/textbodycontext.cxx +++ b/oox/source/drawingml/textbodycontext.cxx @@ -83,6 +83,7 @@ ContextHandlerRef TextParagraphContext::onCreateContext( sal_Int32 aElementToken return new TextFieldContext( *this, rAttribs, *pField ); } case A_TOKEN( pPr ): + case OOX_TOKEN( doc, pPr ): return new TextParagraphPropertiesContext( *this, rAttribs, mrParagraph.getProperties() ); case A_TOKEN( endParaRPr ): return new TextCharacterPropertiesContext( *this, rAttribs, mrParagraph.getEndProperties() ); diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx index 4ec6b655fbeb..aca1d787ba92 100644 --- a/oox/source/drawingml/textparagraphpropertiescontext.cxx +++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx @@ -21,6 +21,7 @@ #include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/awt/FontDescriptor.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> #include "oox/drawingml/colorchoicecontext.hxx" #include "oox/drawingml/textcharacterpropertiescontext.hxx" @@ -153,6 +154,9 @@ TextParagraphPropertiesContext::~TextParagraphPropertiesContext() sal_Int16 nLevel = mrTextParagraphProperties.getLevel(); rPropertyMap[ PROP_NumberingLevel ] <<= nLevel; rPropertyMap[ PROP_NumberingIsNumber ] <<= sal_True; + + if( mrTextParagraphProperties.getParaAdjust() ) + rPropertyMap[ PROP_ParaAdjust ] <<= mrTextParagraphProperties.getParaAdjust().get(); } // -------------------------------------------------------------------- @@ -238,6 +242,23 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl return new TextTabStopListContext( *this, maTabList ); case A_TOKEN( defRPr ): // CT_TextCharacterProperties return new TextCharacterPropertiesContext( *this, rAttribs, mrTextParagraphProperties.getTextCharacterProperties() ); + case OOX_TOKEN( doc, jc ): + { + OptValue< OUString > oParaAdjust = rAttribs.getString( OOX_TOKEN(doc, val) ); + if( oParaAdjust.has() && !oParaAdjust.get().isEmpty() ) + { + const OUString& sParaAdjust = oParaAdjust.get(); + if( sParaAdjust == "left" ) + mrTextParagraphProperties.setParaAdjust(ParagraphAdjust_LEFT); + else if ( sParaAdjust == "right" ) + mrTextParagraphProperties.setParaAdjust(ParagraphAdjust_RIGHT); + else if ( sParaAdjust == "center" ) + mrTextParagraphProperties.setParaAdjust(ParagraphAdjust_CENTER); + else if ( sParaAdjust == "both" ) + mrTextParagraphProperties.setParaAdjust(ParagraphAdjust_BLOCK); + } + } + break; } return this; } diff --git a/sw/qa/extras/ooxmlimport/data/dml-groupshape-paraadjust.docx b/sw/qa/extras/ooxmlimport/data/dml-groupshape-paraadjust.docx Binary files differnew file mode 100644 index 000000000000..fc098955246e --- /dev/null +++ b/sw/qa/extras/ooxmlimport/data/dml-groupshape-paraadjust.docx diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index d1035eb1217a..3fbf9ee32a22 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -48,6 +48,7 @@ #include <com/sun/star/xml/dom/XDocument.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/style/CaseMap.hpp> +#include <com/sun/star/style/ParagraphAdjust.hpp> #include <vcl/svapp.hxx> #include <unotools/fltrcfg.hxx> #include <comphelper/sequenceashashmap.hxx> @@ -1788,6 +1789,25 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeCapitalization, "dml-groupshape-capita // 5th line has no capitalization CPPUNIT_ASSERT_EQUAL(style::CaseMap::NONE, getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), "CharCaseMap")); } + +DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaAdjust, "dml-groupshape-paraadjust.docx") +{ + // Paragraph adjustment inside a group shape was not imported + uno::Reference<container::XIndexAccess> xGroup(getShape(1), uno::UNO_QUERY); + uno::Reference<text::XText> xText = uno::Reference<text::XTextRange>(xGroup->getByIndex(1), uno::UNO_QUERY)->getText(); + // 2nd line is adjusted to the right + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_RIGHT), getProperty<sal_Int16>(getRun(getParagraphOfText(2, xText), 1), "ParaAdjust")); + // 3rd line has no adjustment + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(3, xText), 1), "ParaAdjust")); + // 4th line is adjusted to center + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_CENTER), getProperty<sal_Int16>(getRun(getParagraphOfText(4, xText), 1), "ParaAdjust")); + // 5th line has no adjustment + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(5, xText), 1), "ParaAdjust")); + // 6th line is justified + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_BLOCK), getProperty<sal_Int16>(getRun(getParagraphOfText(6, xText), 1), "ParaAdjust")); + // 7th line has no adjustment + CPPUNIT_ASSERT_EQUAL(sal_Int16(style::ParagraphAdjust_LEFT), getProperty<sal_Int16>(getRun(getParagraphOfText(7, xText), 1), "ParaAdjust")); +} #endif CPPUNIT_PLUGIN_IMPLEMENT(); |