summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@collabora.co.uk>2014-06-17 12:41:49 +0200
committerMiklos Vajna <vmiklos@collabora.co.uk>2014-06-17 12:49:55 +0200
commitd7551e32609d0e0de8ac419576ca42d65c5015be (patch)
tree1c9c7f98a35dd63ab8dc4d33a02d9fa8539ffdc9
parent5158f5e9fdffe31f54b6da9e75164a99d10ad617 (diff)
drawingML export: recognize <a:prstDash val="dash"/>
We used to write out a custom dash definition all the time, even in case it was imported from a dash preset. Recognize at least "dash", and write that on export if the parameters match. Change-Id: Ifaaec51be9ecf1e7667a8c8f85fbd4fb9636a325
-rw-r--r--oox/source/export/drawingml.cxx78
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx12
2 files changed, 54 insertions, 36 deletions
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6073fbd1f88a..6cad974774d8 100644
--- a/oox/source/export/drawingml.cxx
+++ b/oox/source/export/drawingml.cxx
@@ -627,45 +627,53 @@ void DrawingML::WriteOutline( Reference< XPropertySet > rXPropSet )
if( bDashSet && aStyleLineStyle != drawing::LineStyle_DASH ) {
// line style is a dash and it was not set by the shape style
- mpFS->startElementNS( XML_a, XML_custDash, FSEND );
-
- // Check that line-width is positive and distance between dashes\dots is positive
- if ( nLineWidth > 0 && aLineDash.Distance > 0 )
+ if (aLineDash.Dashes == 1 && aLineDash.DashLen == 564 && aLineDash.Distance == 423)
+ // That's exactly the predefined "dash" value.
+ mpFS->singleElementNS(XML_a, XML_prstDash,
+ XML_val, "dash",
+ FSEND);
+ else
{
- // Write 'dashes' first, and then 'dots'
- int i;
- if ( aLineDash.Dashes > 0 )
- {
- for( i = 0; i < aLineDash.Dashes; i ++ )
- mpFS->singleElementNS( XML_a , XML_ds,
- XML_d , write1000thOfAPercent( aLineDash.DashLen > 0 ? aLineDash.DashLen / nLineWidth * 100 : 100 ),
- XML_sp, write1000thOfAPercent( aLineDash.Distance > 0 ? aLineDash.Distance / nLineWidth * 100 : 100 ),
- FSEND );
- }
- if ( aLineDash.Dots > 0 )
+ mpFS->startElementNS( XML_a, XML_custDash, FSEND );
+
+ // Check that line-width is positive and distance between dashes\dots is positive
+ if ( nLineWidth > 0 && aLineDash.Distance > 0 )
{
- for( i = 0; i < aLineDash.Dots; i ++ )
- mpFS->singleElementNS( XML_a, XML_ds,
- XML_d , write1000thOfAPercent( aLineDash.DotLen > 0 ? aLineDash.DotLen / nLineWidth * 100 : 100 ),
- XML_sp, write1000thOfAPercent( aLineDash.Distance > 0 ? aLineDash.Distance / nLineWidth * 100 : 100 ),
- FSEND );
+ // Write 'dashes' first, and then 'dots'
+ int i;
+ if ( aLineDash.Dashes > 0 )
+ {
+ for( i = 0; i < aLineDash.Dashes; i ++ )
+ mpFS->singleElementNS( XML_a , XML_ds,
+ XML_d , write1000thOfAPercent( aLineDash.DashLen > 0 ? aLineDash.DashLen / nLineWidth * 100 : 100 ),
+ XML_sp, write1000thOfAPercent( aLineDash.Distance > 0 ? aLineDash.Distance / nLineWidth * 100 : 100 ),
+ FSEND );
+ }
+ if ( aLineDash.Dots > 0 )
+ {
+ for( i = 0; i < aLineDash.Dots; i ++ )
+ mpFS->singleElementNS( XML_a, XML_ds,
+ XML_d , write1000thOfAPercent( aLineDash.DotLen > 0 ? aLineDash.DotLen / nLineWidth * 100 : 100 ),
+ XML_sp, write1000thOfAPercent( aLineDash.Distance > 0 ? aLineDash.Distance / nLineWidth * 100 : 100 ),
+ FSEND );
+ }
}
- }
- if ( nLineWidth <= 0 )
- SAL_WARN("oox", "while writing outline - custom dash - line width was < 0 : " << nLineWidth);
- if ( aLineDash.Dashes < 0 )
- SAL_WARN("oox", "while writing outline - custom dash - number of dashes was < 0 : " << aLineDash.Dashes);
- if ( aLineDash.Dashes > 0 && aLineDash.DashLen <= 0 )
- SAL_WARN("oox", "while writing outline - custom dash - dash length was < 0 : " << aLineDash.DashLen);
- if ( aLineDash.Dots < 0 )
- SAL_WARN("oox", "while writing outline - custom dash - number of dots was < 0 : " << aLineDash.Dots);
- if ( aLineDash.Dots > 0 && aLineDash.DotLen <= 0 )
- SAL_WARN("oox", "while writing outline - custom dash - dot length was < 0 : " << aLineDash.DotLen);
- if ( aLineDash.Distance <= 0 )
- SAL_WARN("oox", "while writing outline - custom dash - distance was < 0 : " << aLineDash.Distance);
-
- mpFS->endElementNS( XML_a, XML_custDash );
+ if ( nLineWidth <= 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - line width was < 0 : " << nLineWidth);
+ if ( aLineDash.Dashes < 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - number of dashes was < 0 : " << aLineDash.Dashes);
+ if ( aLineDash.Dashes > 0 && aLineDash.DashLen <= 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - dash length was < 0 : " << aLineDash.DashLen);
+ if ( aLineDash.Dots < 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - number of dots was < 0 : " << aLineDash.Dots);
+ if ( aLineDash.Dots > 0 && aLineDash.DotLen <= 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - dot length was < 0 : " << aLineDash.DotLen);
+ if ( aLineDash.Distance <= 0 )
+ SAL_WARN("oox", "while writing outline - custom dash - distance was < 0 : " << aLineDash.Distance);
+
+ mpFS->endElementNS( XML_a, XML_custDash );
+ }
}
if( !bNoFill && nLineWidth > 1 && GETA( LineJoint ) ) {
diff --git a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
index 584547937e77..1e23de81bd5e 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx
@@ -859,7 +859,17 @@ DECLARE_OOXMLEXPORT_TEST(testLineStyle_DashType, "LineStyle_DashType.docx")
xmlDocPtr pXmlDoc = parseExport("word/document.xml");
if (!pXmlDoc)
return;
- assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash");
+
+ uno::Reference<text::XTextFramesSupplier> xTextFramesSupplier(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xIndexAccess(xTextFramesSupplier->getTextFrames(), uno::UNO_QUERY);
+ if (xIndexAccess->getCount())
+ {
+ // TODO TextBox: remove this when TextBox is enabled by default
+ // This second run is a bug, should be the first ideally
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[2]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash");
+ }
+ else
+ assertXPath(pXmlDoc, "/w:document/w:body/w:p/w:r[1]/mc:AlternateContent/mc:Choice/w:drawing/wp:anchor/a:graphic/a:graphicData/wps:wsp/wps:spPr/a:ln/a:prstDash", "val", "dash");
}
DECLARE_OOXMLEXPORT_TEST(testGradientFillPreservation, "gradient-fill-preservation.docx")