Kaydet (Commit) 12f22bd7 authored tarafından Zolnai Tamás's avatar Zolnai Tamás

drawingML import: paragraph spacing inside group shape

unotext: a conversion was missing during the corresponding
SvxLineSpacingItem was filled with "ParaLineSpacing" UNO property.

Change-Id: I02559ed7e8b46150a88eed2bf20afdf084aec47b
üst a14f55e0
......@@ -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 },\
......
......@@ -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 );
}
......
......@@ -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 );
......
......@@ -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;
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment