[Libreoffice-commits] core.git: oox/source sw/qa
Miklos Vajna
vmiklos at collabora.co.uk
Tue Jun 17 03:50:44 PDT 2014
oox/source/export/drawingml.cxx | 78 +++++++++++++++-------------
sw/qa/extras/ooxmlexport/ooxmlsdrexport.cxx | 12 +++-
2 files changed, 54 insertions(+), 36 deletions(-)
New commits:
commit d7551e32609d0e0de8ac419576ca42d65c5015be
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Tue Jun 17 12:41:49 2014 +0200
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
diff --git a/oox/source/export/drawingml.cxx b/oox/source/export/drawingml.cxx
index 6073fbd..6cad974 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 5845479..1e23de8 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")
More information about the Libreoffice-commits
mailing list