diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-21 22:19:10 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-02-21 22:19:10 +0100 |
commit | 27a03eb3ba2064cdcf14fc61bfd83facd1ef4282 (patch) | |
tree | 6cba3dada428eaa847c58625aaadb9eb22cdd0b5 | |
parent | d99c0e1481c2420e538fde62247747cf7ea32db4 (diff) |
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
-rw-r--r--[-rwxr-xr-x] | sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx | bin | 13586 -> 17128 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 72 | ||||
-rw-r--r-- | sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx | bin | 17136 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 60 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 75 |
5 files changed, 94 insertions, 113 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx b/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx Binary files differindex 1cb48d3c2d61..a8fc82bd56d7 100755..100644 --- a/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx +++ b/sw/qa/extras/ooxmlexport/data/dml-groupshape-paraspacing.docx diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index ceea5c2547ad..47932492986a 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 Binary files differdeleted file mode 100644 index ccfa043b491f..000000000000 --- a/sw/qa/extras/ooxmlimport/data/dml-groupshape-para-spacing.docx +++ /dev/null diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 354e3013cbe5..21e64fd4abca 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 defb8ffe0192..a949fbcc10d8 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 ); } |