[Libreoffice-commits] core.git: 3 commits - include/editeng oox/source sw/qa sw/source
Zolnai Tamás
tamas.zolnai at collabora.com
Fri Feb 21 13:21:11 PST 2014
include/editeng/unotext.hxx | 2
oox/source/drawingml/textparagraph.cxx | 2
oox/source/drawingml/textparagraphproperties.cxx | 4
oox/source/drawingml/textparagraphpropertiescontext.cxx | 68 ++++++++-
sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx |binary
sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 72 ++++++++-
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 2
sw/source/filter/ww8/docxattributeoutput.cxx | 2
sw/source/filter/ww8/ww8atr.cxx | 75 ++++------
9 files changed, 163 insertions(+), 64 deletions(-)
New commits:
commit 27a03eb3ba2064cdcf14fc61bfd83facd1ef4282
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Fri Feb 21 22:19:10 2014 +0100
WW export: make line spacing export clearer
see also: SvxLineSpacingItem::PutValue
Move para spacing test from import to export and
remove a test case which tests a part of the same thing.
Change-Id: I96da9f6ac7851bd74e34ab4a6d2a2f3499549a87
diff --git a/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx b/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx
old mode 100755
new mode 100644
index 1cb48d3..a8fc82b
Binary files a/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx and b/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
index ceea5c2..4793249 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx
@@ -2335,18 +2335,6 @@ DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeRelsize, "dml-groupshape-relsize.docx"
assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/wp14:sizeRelH", "relativeFrom", "margin");
}
-DECLARE_OOXMLEXPORT_TEST(testDmlGroupshapeParaspacing, "dml-groupshape-paraspacing.docx")
-{
- xmlDocPtr pXmlDoc = parseExport("word/document.xml");
- if (!pXmlDoc)
- return;
- // Paragraph spacing of shape text in groupshapes was left, the w:spacing element was missing in pPr.
- assertXPath(pXmlDoc,
- "/w:document/w:body/w:p/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wpg:wgp/wps:wsp[1]/wps:txbx/w:txbxContent/w:p/w:pPr/w:spacing",
- "before",
- "240");
-}
-
DECLARE_OOXMLEXPORT_TEST(testTrackChangesDeletedParagraphMark, "testTrackChangesDeletedParagraphMark.docx")
{
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
@@ -3371,6 +3359,66 @@ DECLARE_OOXMLEXPORT_TEST(testDMLGradientFillTheme, "dml-gradientfill-theme.docx"
"/w:document/w:body/w:p[2]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:style/a:fillRef/a:schemeClr",
"val", "accent1");
}
+
+DECLARE_OOXMLEXPORT_TEST(testDMLGroupShapeParaSpacing, "dml-groupshape-paraspacing.docx")
+{
+ // Paragraph spacing (top/bottom margin and line 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();
diff --git a/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx b/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx
deleted file mode 100644
index ccfa043..0000000
Binary files a/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx and /dev/null differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 354e301..21e64fd 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -1893,66 +1893,6 @@ 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();
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index defb8ff..a949fbc 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -4552,63 +4552,56 @@ void AttributeOutputBase::ParaLineSpacing( const SvxLineSpacingItem& rSpacing )
{
default:
break;
- case SVX_LINE_SPACE_AUTO:
- nSpace = (short)( ( 240L * rSpacing.GetPropLineSpace() ) / 100L );
- nMulti = 1;
+ case SVX_LINE_SPACE_FIX: // Fix
+ nSpace = -(short)rSpacing.GetLineHeight();
+ break;
+ case SVX_LINE_SPACE_MIN: // At least
+ nSpace = (short)rSpacing.GetLineHeight();
break;
- case SVX_LINE_SPACE_FIX:
- case SVX_LINE_SPACE_MIN:
+ case SVX_LINE_SPACE_AUTO:
{
- switch ( rSpacing.GetInterLineSpaceRule() )
+ if( rSpacing.GetInterLineSpaceRule() == SVX_INTER_LINE_SPACE_FIX ) // Leading
{
- case SVX_INTER_LINE_SPACE_FIX: // unser Durchschuss
+ // gibt es aber nicht in WW - also wie kommt man an
+ // die MaxLineHeight heran?
+ nSpace = (short)rSpacing.GetInterLineSpace();
+ sal_uInt16 nScript =
+ i18n::ScriptType::LATIN;
+ const SwAttrSet *pSet = 0;
+ if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwFmt ) )
{
- // gibt es aber nicht in WW - also wie kommt man an
- // die MaxLineHeight heran?
- nSpace = (short)rSpacing.GetInterLineSpace();
- sal_uInt16 nScript =
- i18n::ScriptType::LATIN;
- const SwAttrSet *pSet = 0;
- if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwFmt ) )
- {
- const SwFmt *pFmt = (const SwFmt*)( GetExport().pOutFmtNode );
- pSet = &pFmt->GetAttrSet();
- }
- else if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtNode ) )
- {
- const SwTxtNode* pNd = (const SwTxtNode*)GetExport().pOutFmtNode;
- pSet = &pNd->GetSwAttrSet();
- if ( g_pBreakIt->GetBreakIter().is() )
- {
- nScript = g_pBreakIt->GetBreakIter()->
- getScriptType(pNd->GetTxt(), 0);
- }
- }
- OSL_ENSURE( pSet, "No attrset for lineheight :-(" );
- if ( pSet )
+ const SwFmt *pFmt = (const SwFmt*)( GetExport().pOutFmtNode );
+ pSet = &pFmt->GetAttrSet();
+ }
+ else if ( GetExport().pOutFmtNode && GetExport().pOutFmtNode->ISA( SwTxtNode ) )
+ {
+ const SwTxtNode* pNd = (const SwTxtNode*)GetExport().pOutFmtNode;
+ pSet = &pNd->GetSwAttrSet();
+ if ( g_pBreakIt->GetBreakIter().is() )
{
- nSpace = nSpace + (short)( AttrSetToLineHeight( *GetExport().pDoc,
- *pSet, *Application::GetDefaultDevice(), nScript ) );
+ nScript = g_pBreakIt->GetBreakIter()->
+ getScriptType(pNd->GetTxt(), 0);
}
}
- break;
- case SVX_INTER_LINE_SPACE_PROP:
+ OSL_ENSURE( pSet, "No attrset for lineheight :-(" );
+ if ( pSet )
+ {
+ nSpace = nSpace + (short)( AttrSetToLineHeight( *GetExport().pDoc,
+ *pSet, *Application::GetDefaultDevice(), nScript ) );
+ }
+ }
+ else // Proportional
+ {
nSpace = (short)( ( 240L * rSpacing.GetPropLineSpace() ) / 100L );
nMulti = 1;
break;
- default: // z.B. Minimum oder FIX?
- if ( SVX_LINE_SPACE_FIX == rSpacing.GetLineSpaceRule() )
- nSpace = -(short)rSpacing.GetLineHeight();
- else
- nSpace = (short)rSpacing.GetLineHeight();
- break;
}
}
break;
}
// if nSpace is negative, it is a fixed size in 1/20 of a point
// if nSpace is positive and nMulti is 1, it is 1/240 of a single line height
- // otherwise, I have no clue what the heck it is
+ // otherwise, it is a minimum size in 1/20 of a point
ParaLineSpacing_Impl( nSpace, nMulti );
}
commit d99c0e1481c2420e538fde62247747cf7ea32db4
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Fri Feb 21 17:03:06 2014 +0100
DOCX export: remove some extra pPr tag
StartParagraphProperties and EndParagraphProperties
contains these lines.
Change-Id: I05cceb64cfa8c2b1673d44009ef1914fcf7f3e6d
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 8087ca7..b1e4a01 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -3509,11 +3509,9 @@ void DocxAttributeOutput::WriteOutliner(const OutlinerParaObject& rParaObj)
StartParagraph(ww8::WW8TableNodeInfo::Pointer_t());
// Write paragraph properties.
- m_pSerializer->startElementNS(XML_w, XML_pPr, FSEND);
StartParagraphProperties();
aAttrIter.OutParaAttr(false);
EndParagraphProperties(0, 0, 0, 0);
- m_pSerializer->endElementNS(XML_w, XML_pPr);
do {
const sal_Int32 nNextAttr = std::min(aAttrIter.WhereNext(), nEnd);
commit 12f22bd7811d75eacc36f8ee8bc448bdbccb0b65
Author: Zolnai Tamás <tamas.zolnai at collabora.com>
Date: Fri Feb 21 21:49:56 2014 +0100
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
diff --git a/include/editeng/unotext.hxx b/include/editeng/unotext.hxx
index 99d8572..df97163 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 7010847..0ac8b05 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 585695d..65dd0aa 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 36860f0..99a0c0c 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 0000000..ccfa043
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index 5f41a1d..354e301 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();
More information about the Libreoffice-commits
mailing list