Kaydet (Commit) f3d6c44c authored tarafından Adam Kovacs's avatar Adam Kovacs Kaydeden (comit) László Németh

tdf#108064 OOXML export: keep preset dashes with any line width

Change-Id: I496e1cbac527383837a4e8fcdee42967ecf555e4
Reviewed-on: https://gerrit.libreoffice.org/59968
Tested-by: Jenkins
Reviewed-by: 's avatarLászló Németh <nemeth@numbertext.org>
üst a6a5064c
...@@ -700,35 +700,51 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet ) ...@@ -700,35 +700,51 @@ void DrawingML::WriteOutline( const Reference<XPropertySet>& rXPropSet )
if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH ) if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH )
{ {
// keep default preset linestyles (instead of custdash) // convert absolute dash/dot length to relative length
if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 0 && aLineDash.DashLen == 0 && aLineDash.Distance == 141) int relDotLen = aLineDash.DotLen / nLineWidth;
int relDashLen = aLineDash.DashLen / nLineWidth;
int relDistance = aLineDash.Distance / nLineWidth;
// keep default mso preset linestyles (instead of custdash)
if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && relDashLen == 0 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dot", FSEND);
}
else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 423 && aLineDash.Distance == 141)
{
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", FSEND);
} }
else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 4 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dash", FSEND);
} }
else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423) else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 4 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "dashDot", FSEND);
} }
else if (aLineDash.Dots == 0 && aLineDash.DotLen == 0 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDash", FSEND);
} }
else if (aLineDash.Dots == 1 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDot", FSEND);
} }
else if (aLineDash.Dots == 2 && aLineDash.DotLen == 141 && aLineDash.Dashes == 1 && aLineDash.DashLen == 1128 && aLineDash.Distance == 423) else if (aLineDash.Dots == 2 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 8 && relDistance == 3)
{ {
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDotDot", FSEND); mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "lgDashDotDot", FSEND);
} }
else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 0 && relDashLen == 0 && relDistance == 1)
{
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDot", FSEND);
}
else if (aLineDash.Dots == 0 && relDotLen == 0 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1)
{
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDash", FSEND);
}
else if (aLineDash.Dots == 1 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1)
{
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDashDot", FSEND);
}
else if (aLineDash.Dots == 2 && relDotLen == 1 && aLineDash.Dashes == 1 && relDashLen == 3 && relDistance == 1)
{
mpFS->singleElementNS(XML_a, XML_prstDash, XML_val, "sysDashDotDot", FSEND);
}
else else
{ {
mpFS->startElementNS( XML_a, XML_custDash, FSEND ); mpFS->startElementNS( XML_a, XML_custDash, FSEND );
......
...@@ -786,7 +786,7 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d ...@@ -786,7 +786,7 @@ DECLARE_OOXMLEXPORT_TEST(testShapeThemePreservation, "shape-theme-preservation.d
"/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:miter", "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:miter",
1); 1);
assertXPath(pXmlDocument, assertXPath(pXmlDocument,
"/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:custDash", "/w:document/w:body/w:p[5]/w:r/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash",
1); 1);
uno::Reference<drawing::XShape> xShape1 = getShape(1); uno::Reference<drawing::XShape> xShape1 = getShape(1);
......
...@@ -805,37 +805,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo78957, "fdo78957.docx") ...@@ -805,37 +805,14 @@ DECLARE_OOXMLEXPORT_TEST(testFdo78957, "fdo78957.docx")
DECLARE_OOXMLEXPORT_TEST(testfdo79256, "fdo79256.docx") DECLARE_OOXMLEXPORT_TEST(testfdo79256, "fdo79256.docx")
{ {
/* Corruption issue containing Line Style with Long Dashes and Dots /* corruption issue also solved by fixing tdf#108064:
* After RT checking the Dash Length value. Dash Length value should not be greater than 2147483. * since that LO keeps MSO preset dash styles during OOXML export
*/ */
xmlDocPtr pXmlDoc = parseExport("word/document.xml"); xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc) if (!pXmlDoc)
return; return;
const sal_Int32 maxLimit = 2147483; assertXPath(pXmlDoc, "/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln/a:prstDash", "val", "lgDash");
sal_Int32 d = getXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]","d").toInt32();
CPPUNIT_ASSERT(d <= maxLimit );
}
DECLARE_OOXMLEXPORT_TEST(testDashedLinePreset, "dashed_line_preset.docx")
{
/* Make sure that preset line is exported correctly as "1000th of a percent".
* This test-file has a PRESET dash-line which will be converted by LO import
* to a custom-dash (dash-dot-dot). This test-case makes sure that the exporter
* outputs the correct values.
*/
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]", "d" , "800000");
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[1]", "sp", "300000");
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[2]", "d" , "100000");
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[2]", "sp", "300000");
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[3]", "d" , "100000");
assertXPath(pXmlDoc,"/w:document/w:body/w:p[1]/w:r[1]/mc:AlternateContent[1]/mc:Choice[1]/w:drawing[1]/wp:anchor[1]/a:graphic[1]/a:graphicData[1]/wps:wsp[1]/wps:spPr[1]/a:ln[1]/a:custDash[1]/a:ds[3]", "sp", "300000");
} }
DECLARE_OOXMLEXPORT_TEST(testDashedLine_CustDash1000thOfPercent, "dashed_line_custdash_1000th_of_percent.docx") DECLARE_OOXMLEXPORT_TEST(testDashedLine_CustDash1000thOfPercent, "dashed_line_custdash_1000th_of_percent.docx")
......
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