tdf#113187 exclude angle conversion from count of maGuideList

The ooxml import uses the special viewBox value '0 0 0 0' to indicate
that the point coordinates are relative to shape size and not to
viewBox and need special treatment. To detect this case the number of
guides in maGuideList was used. But that number might be larger than
the guides in ooxml because each arcTo command introduces two
additional guides for the conversion from 1/60000 degree in ooxml to
degree in LibreOffice.

The patch excludes these guides from count. Thus now a path which has
no references in its points will get a viewBox with non-zero width
and height in all cases and is rendered now.

Change-Id: I410638a1fe02f692fd46313c88b5ea518f1d094f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/142050
Tested-by: Jenkins
Reviewed-by: Regina Henschel <rb.henschel@t-online.de>
diff --git a/oox/inc/drawingml/customshapeproperties.hxx b/oox/inc/drawingml/customshapeproperties.hxx
index c009a0f..61a151d 100644
--- a/oox/inc/drawingml/customshapeproperties.hxx
+++ b/oox/inc/drawingml/customshapeproperties.hxx
@@ -123,6 +123,7 @@ public:
    static sal_Int32 GetCustomShapeGuideValue( const std::vector< CustomShapeGuide >& rGuideList, std::u16string_view rFormulaName );

    sal_Int32 getArcNum() { return mnArcNum++; }
    sal_Int32 countArcTo() { return mnArcNum; }

    /**
       Returns whether or not the current CustomShapeProperties
diff --git a/oox/qa/unit/data/tdf113187_arcTo_withoutReferences.pptx b/oox/qa/unit/data/tdf113187_arcTo_withoutReferences.pptx
new file mode 100644
index 0000000..1862c02
--- /dev/null
+++ b/oox/qa/unit/data/tdf113187_arcTo_withoutReferences.pptx
Binary files differ
diff --git a/oox/qa/unit/drawingml.cxx b/oox/qa/unit/drawingml.cxx
index 95e5936..6150e44 100644
--- a/oox/qa/unit/drawingml.cxx
+++ b/oox/qa/unit/drawingml.cxx
@@ -529,6 +529,26 @@ CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTextRot)
    }
}

CPPUNIT_TEST_FIXTURE(OoxDrawingmlTest, testTdf113187ConstantArcTo)
{
    loadFromURL(u"tdf113187_arcTo_withoutReferences.pptx");

    // Get ViewBox of shape
    uno::Reference<drawing::XDrawPagesSupplier> xDrawPagesSupplier(mxComponent, uno::UNO_QUERY);
    uno::Reference<drawing::XDrawPage> xDrawPage(xDrawPagesSupplier->getDrawPages()->getByIndex(0),
                                                 uno::UNO_QUERY);
    uno::Reference<drawing::XShape> xShape(xDrawPage->getByIndex(0), uno::UNO_QUERY);
    uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY);
    uno::Sequence<beans::PropertyValue> aGeoPropSeq;
    xShapeProps->getPropertyValue("CustomShapeGeometry") >>= aGeoPropSeq;
    comphelper::SequenceAsHashMap aGeoPropMap(aGeoPropSeq);

    // Without the fix width and height of the ViewBox were 0 and thus the shape was not shown.
    auto aViewBox = aGeoPropMap["ViewBox"].get<css::awt::Rectangle>();
    CPPUNIT_ASSERT_EQUAL(sal_Int32(3600000), aViewBox.Width);
    CPPUNIT_ASSERT_EQUAL(sal_Int32(3600000), aViewBox.Height);
}

CPPUNIT_PLUGIN_IMPLEMENT();

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/oox/source/drawingml/customshapeproperties.cxx b/oox/source/drawingml/customshapeproperties.cxx
index ef16419..9cdbb4ee 100644
--- a/oox/source/drawingml/customshapeproperties.cxx
+++ b/oox/source/drawingml/customshapeproperties.cxx
@@ -198,7 +198,9 @@ void CustomShapeProperties::pushToPropSet(
        // This size specifically affects scaling.
        // Note 2: Width and Height are set to 0 to force scaling to 1.
        awt::Rectangle aViewBox( 0, 0, aSize.Width, aSize.Height );
        if( !maGuideList.empty() )
        // tdf#113187 Each ArcTo introduces two additional equations for converting start and swing
        // angles. They do not count for test for use of standard ooxml coordinates
        if (maGuideList.size() - 2 * countArcTo() > 0)
            aViewBox = awt::Rectangle( 0, 0, 0, 0 );
        aPropertyMap.setProperty( PROP_ViewBox, aViewBox);