summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/editeng/unotext.hxx2
-rw-r--r--oox/source/drawingml/textparagraph.cxx2
-rw-r--r--oox/source/drawingml/textparagraphproperties.cxx4
-rw-r--r--oox/source/drawingml/textparagraphpropertiescontext.cxx68
-rw-r--r--sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docxbin0 -> 17136 bytes
-rw-r--r--sw/qa/extras/ooxmlimport/ooxmlimport.cxx62
6 files changed, 129 insertions, 9 deletions
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 99d85727a7f2..df971635cd1e 100644
--- a/include/editeng/unotext.hxx
+++ b/include/editeng/unotext.hxx
@@ -136,7 +136,7 @@ class SvxItemPropertySet;
{OUString(UNO_NAME_EDIT_PARA_IS_HYPHEN), EE_PARA_HYPHENATE, ::getBooleanCppuType(), 0, 0 }, \
{OUString(UNO_NAME_EDIT_PARA_LASTLINEADJ), EE_PARA_JUST, ::getCppuType((const sal_Int16*)0), 0, MID_LAST_LINE_ADJUST }, \
{OUString(UNO_NAME_EDIT_PARA_LMARGIN), EE_PARA_LRSPACE, ::getCppuType((const sal_Int32*)0), 0, MID_TXT_LMARGIN|SFX_METRIC_ITEM }, \
- {OUString(UNO_NAME_EDIT_PARA_LINESPACING), EE_PARA_SBL, ::getCppuType((const ::com::sun::star::style::LineSpacing*)0), 0, 0 }, \
+ {OUString(UNO_NAME_EDIT_PARA_LINESPACING), EE_PARA_SBL, ::getCppuType((const ::com::sun::star::style::LineSpacing*)0), 0, CONVERT_TWIPS}, \
{OUString(UNO_NAME_EDIT_PARA_RMARGIN), EE_PARA_LRSPACE, ::getCppuType((const sal_Int32*)0), 0, MID_R_MARGIN|SFX_METRIC_ITEM }, \
{OUString(UNO_NAME_EDIT_PARA_TAPSTOPS), EE_PARA_TABS, ::getCppuType((const ::com::sun::star::uno::Sequence< ::com::sun::star::style::TabStop >*)0), 0, 0 }, \
{OUString(UNO_NAME_EDIT_PARA_TMARGIN), EE_PARA_ULSPACE, ::getCppuType((const sal_Int32*)0), 0, MID_UP_MARGIN|SFX_METRIC_ITEM },\
diff --git a/oox/source/drawingml/textparagraph.cxx b/oox/source/drawingml/textparagraph.cxx
index 70108470df06..0ac8b05b38a2 100644
--- a/oox/source/drawingml/textparagraph.cxx
+++ b/oox/source/drawingml/textparagraph.cxx
@@ -114,7 +114,7 @@ void TextParagraph::insertAt(
&& (*maRuns.begin())->getTextCharacterProperties().maCharColor.isUsed() )
aioBulletList[ PROP_BulletColor ] <<= (*maRuns.begin())->getTextCharacterProperties().maCharColor.getColor( rFilterBase.getGraphicHelper() );
- float fCharacterSize = nCharHeight > 0 ? GetFontHeight ( nCharHeight ) : pTextParagraphStyle->getCharHeightPoints( 18 );
+ float fCharacterSize = nCharHeight > 0 ? GetFontHeight ( nCharHeight ) : pTextParagraphStyle->getCharHeightPoints( 12 );
aParaProp.pushToPropSet( &rFilterBase, xProps, aioBulletList, &pTextParagraphStyle->getBulletList(), sal_True, fCharacterSize, true );
}
diff --git a/oox/source/drawingml/textparagraphproperties.cxx b/oox/source/drawingml/textparagraphproperties.cxx
index 585695deb042..65dd0aa130b6 100644
--- a/oox/source/drawingml/textparagraphproperties.cxx
+++ b/oox/source/drawingml/textparagraphproperties.cxx
@@ -400,9 +400,9 @@ void TextParagraphProperties::pushToPropSet( const ::oox::core::XmlFilterBase* p
maBulletList.pushToPropMap( pFilterBase, rioBulletMap );
if ( maParaTopMargin.bHasValue || bPushDefaultValues )
- aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) );
+ aPropSet.setProperty( PROP_ParaTopMargin, maParaTopMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 12.0 ) ) );
if ( maParaBottomMargin.bHasValue || bPushDefaultValues )
- aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 18.0 ) ) );
+ aPropSet.setProperty( PROP_ParaBottomMargin, maParaBottomMargin.toMargin( fCharacterSize != 0.0 ? fCharacterSize : getCharHeightPoints ( 12.0 ) ) );
if ( nNumberingType == NumberingType::BITMAP )
{
fCharacterSize = getCharHeightPoints( fCharacterSize );
diff --git a/oox/source/drawingml/textparagraphpropertiescontext.cxx b/oox/source/drawingml/textparagraphpropertiescontext.cxx
index 36860f08c02c..99a0c0c18ee4 100644
--- a/oox/source/drawingml/textparagraphpropertiescontext.cxx
+++ b/oox/source/drawingml/textparagraphpropertiescontext.cxx
@@ -263,12 +263,70 @@ ContextHandlerRef TextParagraphPropertiesContext::onCreateContext( sal_Int32 aEl
break;
case OOX_TOKEN( doc, spacing ):
{
- OptValue<OUString> oBefore = rAttribs.getString(OOX_TOKEN(doc, before));
- if (oBefore.has())
+ // Spacing before
+ if( !rAttribs.getBool(OOX_TOKEN(doc, beforeAutospacing), false) )
{
- TextSpacing& rSpacing = mrTextParagraphProperties.getParaTopMargin();
- rSpacing.nValue = TWIPS_TO_MM(oBefore.get().toInt32());
- rSpacing.bHasValue = true;
+ OptValue<sal_Int32> oBefore = rAttribs.getInteger(OOX_TOKEN(doc, before));
+ if (oBefore.has())
+ {
+ TextSpacing& rSpacing = mrTextParagraphProperties.getParaTopMargin();
+ rSpacing.nUnit = TextSpacing::POINTS;
+ rSpacing.nValue = TWIPS_TO_MM(oBefore.get());
+ rSpacing.bHasValue = true;
+ }
+ else
+ {
+ OptValue<sal_Int32> oBeforeLines = rAttribs.getInteger(OOX_TOKEN(doc, beforeLines));
+ if (oBeforeLines.has())
+ {
+ TextSpacing& rSpacing = mrTextParagraphProperties.getParaTopMargin();
+ rSpacing.nUnit = TextSpacing::PERCENT;
+ rSpacing.nValue = oBeforeLines.get() * MAX_PERCENT / 100;
+ rSpacing.bHasValue = true;
+ }
+ }
+ }
+
+ // Spacing after
+ if( !rAttribs.getBool(OOX_TOKEN(doc, afterAutospacing), false) )
+ {
+ OptValue<sal_Int32> oAfter = rAttribs.getInteger(OOX_TOKEN(doc, after));
+ if (oAfter.has())
+ {
+ TextSpacing& rSpacing = mrTextParagraphProperties.getParaBottomMargin();
+ rSpacing.nUnit = TextSpacing::POINTS;
+ rSpacing.nValue = TWIPS_TO_MM(oAfter.get());
+ rSpacing.bHasValue = true;
+ }
+ else
+ {
+ OptValue<sal_Int32> oAfterLines = rAttribs.getInteger(OOX_TOKEN(doc, afterLines));
+ if (oAfterLines.has())
+ {
+ TextSpacing& rSpacing = mrTextParagraphProperties.getParaBottomMargin();
+ rSpacing.nUnit = TextSpacing::PERCENT;
+ rSpacing.nValue = oAfterLines.get() * MAX_PERCENT / 100;
+ rSpacing.bHasValue = true;
+ }
+ }
+ }
+
+ // Line spacing
+ OptValue<OUString> oLineRule = rAttribs.getString(OOX_TOKEN(doc, lineRule));
+ OptValue<sal_Int32> oLineSpacing = rAttribs.getInteger(OOX_TOKEN(doc, line));
+ if (oLineSpacing.has())
+ {
+ if( !oLineRule.has() || oLineRule.get() == "auto" )
+ {
+ maLineSpacing.nUnit = TextSpacing::PERCENT;
+ maLineSpacing.nValue = oLineSpacing.get() * MAX_PERCENT / 240;
+ }
+ else
+ {
+ maLineSpacing.nUnit = TextSpacing::POINTS;
+ maLineSpacing.nValue = TWIPS_TO_MM(oLineSpacing.get());
+ }
+ maLineSpacing.bHasValue = true;
}
}
break;
diff --git a/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx b/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx
new file mode 100644
index 000000000000..ccfa043b491f
--- /dev/null
+++ b/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5f41a1d9330f..354e3013cbe5 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -40,6 +40,8 @@
#include <com/sun/star/text/XTextViewCursorSupplier.hpp>
#include <com/sun/star/style/BreakType.hpp>
#include <com/sun/star/style/ParagraphAdjust.hpp>
+#include <com/sun/star/style/LineSpacing.hpp>
+#include <com/sun/star/style/LineSpacingMode.hpp>
#include <com/sun/star/table/ShadowFormat.hpp>
#include <com/sun/star/view/XSelectionSupplier.hpp>
#include <com/sun/star/view/XFormLayerAccess.hpp>
@@ -1891,6 +1893,66 @@ DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeRunFonts, "dml-groupshape-runfonts.doc
CPPUNIT_ASSERT_EQUAL(OUString("Arial Unicode MS"), getProperty<OUString>(xRun, "CharFontNameComplex"));
CPPUNIT_ASSERT_EQUAL(OUString("MS Mincho"), getProperty<OUString>(xRun, "CharFontNameAsian"));
}
+
+DECLARE_OOXMLIMPORT_TEST(testDMLGroupShapeParaSpacing, "dml-groupshape-para-spacing.docx")
+{
+ // Paragraph spacing 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();
+
+ // 1st paragraph has 1.5x line spacing but it has no spacing before/after.
+ uno::Reference<text::XTextRange> xRun = getRun(getParagraphOfText(1, xText),1);
+ ::com::sun::star::style::LineSpacing aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::PROP), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(150), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 2nd paragraph has double line spacing but it has no spacing before/after.
+ xRun.set(getRun(getParagraphOfText(2, xText),1));
+ aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::PROP), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(200), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 3rd paragraph has 24 pt line spacing but it has no spacing before/after.
+ xRun.set(getRun(getParagraphOfText(3, xText),1));
+ aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::MINIMUM), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(847), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 4th paragraph has 1.75x line spacing but it has no spacing before/after.
+ xRun.set(getRun(getParagraphOfText(4, xText),1));
+ aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::PROP), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(175), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 5th paragraph has margins which are defined by w:beforeLines and w:afterLines.
+ xRun.set(getRun(getParagraphOfText(5, xText),1));
+ aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::PROP), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(741), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 6th paragraph has margins which are defined by w:before and w:after.
+ xRun.set(getRun(getParagraphOfText(6, xText),1));
+ aLineSpacing = getProperty<::com::sun::star::style::LineSpacing>(xRun, "ParaLineSpacing");
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(::com::sun::star::style::LineSpacingMode::PROP), aLineSpacing.Mode);
+ CPPUNIT_ASSERT_EQUAL(sal_Int16(100), aLineSpacing.Height);
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(423), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(635), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+
+ // 7th paragraph has auto paragraph margins a:afterAutospacing and a:beforeAutospacing, which means margins must be ignored.
+ xRun.set(getRun(getParagraphOfText(7, xText),1));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaTopMargin"));
+ CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xRun, "ParaBottomMargin"));
+}
#endif
CPPUNIT_PLUGIN_IMPLEMENT();