diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-07-12 00:59:24 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-07-12 03:10:21 +0200 |
commit | c19a6dfa7bd0bce580c91d4073686a631c12b255 (patch) | |
tree | a4fa4a3b459ca5a99c4b34a8b36745a4ee18b42a /drawinglayer | |
parent | 744969c4f665dcd5be7793a9b3949d4a0587a6ac (diff) |
some small improvements for the dumper
Change-Id: I0a24a0e9c4a3b818c9144bc38857b67e49483915
Diffstat (limited to 'drawinglayer')
-rw-r--r-- | drawinglayer/source/dumper/XShapeDumper.cxx | 87 |
1 files changed, 41 insertions, 46 deletions
diff --git a/drawinglayer/source/dumper/XShapeDumper.cxx b/drawinglayer/source/dumper/XShapeDumper.cxx index 1503bbe28230..d42e9441da09 100644 --- a/drawinglayer/source/dumper/XShapeDumper.cxx +++ b/drawinglayer/source/dumper/XShapeDumper.cxx @@ -53,7 +53,7 @@ namespace { // auxiliary functions void dumpGradientProperty(com::sun::star::awt::Gradient aGradient, xmlTextWriterPtr xmlWriter); void dumpPolyPolygonBezierCoords(com::sun::star::drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords, xmlTextWriterPtr xmlWriter); - void dumpPointSequenceSequence(com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence, xmlTextWriterPtr xmlWriter); + void dumpPointSequenceSequence(com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence, uno::Sequence<uno::Sequence<drawing::PolygonFlags> >*, xmlTextWriterPtr xmlWriter); // FillProperties.idl void dumpFillStyleAsAttribute(com::sun::star::drawing::FillStyle eFillStyle, xmlTextWriterPtr xmlWriter); @@ -567,44 +567,7 @@ namespace { void dumpPolyPolygonBezierCoords(drawing::PolyPolygonBezierCoords aPolyPolygonBezierCoords, xmlTextWriterPtr xmlWriter) { - // dumps first field - Coordinates - dumpPointSequenceSequence(aPolyPolygonBezierCoords.Coordinates, xmlWriter); - - // dumps second field - Flags - uno::Sequence<uno::Sequence< drawing::PolygonFlags > > polygonFlagsSequenceSequence = aPolyPolygonBezierCoords.Flags; - sal_Int32 nFlagsSequence = polygonFlagsSequenceSequence.getLength(); - for (sal_Int32 i = 0; i < nFlagsSequence; ++i) - { - uno::Sequence< drawing::PolygonFlags > polygonFlagsSequence = polygonFlagsSequenceSequence[i]; - sal_Int32 nFlags = polygonFlagsSequence.getLength(); - - xmlTextWriterStartElement(xmlWriter, BAD_CAST( "flagsSequence" )); - - for (sal_Int32 j = 0; j < nFlags; ++j) - { - xmlTextWriterStartElement(xmlWriter, BAD_CAST( "polygonFlags" )); - switch(polygonFlagsSequence[j]) - { - case drawing::PolygonFlags_NORMAL: - xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "NORMAL"); - break; - case drawing::PolygonFlags_SMOOTH: - xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "SMOOTH"); - break; - case drawing::PolygonFlags_CONTROL: - xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "CONTROL"); - break; - case drawing::PolygonFlags_SYMMETRIC: - xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "SYMMETRIC"); - break; - default: - break; - } - xmlTextWriterEndElement( xmlWriter ); - } - xmlTextWriterEndElement( xmlWriter ); - } - + dumpPointSequenceSequence(aPolyPolygonBezierCoords.Coordinates, &aPolyPolygonBezierCoords.Flags, xmlWriter); } void dumpLineStartAsElement(drawing::PolyPolygonBezierCoords aLineStart, xmlTextWriterPtr xmlWriter) @@ -687,16 +650,21 @@ namespace { } } - void dumpPointSequenceSequence(drawing::PointSequenceSequence aPointSequenceSequence, xmlTextWriterPtr xmlWriter) + void dumpPointSequenceSequence(drawing::PointSequenceSequence aPointSequenceSequence, uno::Sequence<uno::Sequence< drawing::PolygonFlags > >* pFlags, xmlTextWriterPtr xmlWriter) { // LibreOffice proudly presents - The Sequenception uno::Sequence<uno::Sequence< awt::Point > > pointSequenceSequence = aPointSequenceSequence; sal_Int32 nPointsSequence = pointSequenceSequence.getLength(); + for (sal_Int32 i = 0; i < nPointsSequence; ++i) { uno::Sequence< awt::Point > pointSequence = pointSequenceSequence[i]; sal_Int32 nPoints = pointSequence.getLength(); + uno::Sequence< drawing::PolygonFlags> flagsSequence; + if(pFlags) + flagsSequence = (*pFlags)[i]; + xmlTextWriterStartElement(xmlWriter, BAD_CAST( "pointSequence" )); for(sal_Int32 j = 0; j < nPoints; ++j) @@ -704,6 +672,28 @@ namespace { xmlTextWriterStartElement(xmlWriter, BAD_CAST( "point" )); xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionX"), "%" SAL_PRIdINT32, pointSequence[j].X); xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionY"), "%" SAL_PRIdINT32, pointSequence[j].Y); + + if(pFlags) + { + switch(flagsSequence[j]) + { + case drawing::PolygonFlags_NORMAL: + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "NORMAL"); + break; + case drawing::PolygonFlags_SMOOTH: + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "SMOOTH"); + break; + case drawing::PolygonFlags_CONTROL: + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "CONTROL"); + break; + case drawing::PolygonFlags_SYMMETRIC: + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("polygonFlags"), "%s", "SYMMETRIC"); + break; + default: + break; + } + } + xmlTextWriterEndElement( xmlWriter ); } xmlTextWriterEndElement( xmlWriter ); @@ -713,14 +703,14 @@ namespace { void dumpPolyPolygonAsElement(drawing::PointSequenceSequence aPolyPolygon, xmlTextWriterPtr xmlWriter) { xmlTextWriterStartElement(xmlWriter, BAD_CAST( "PolyPolygon" )); - dumpPointSequenceSequence(aPolyPolygon, xmlWriter); + dumpPointSequenceSequence(aPolyPolygon, NULL, xmlWriter); xmlTextWriterEndElement( xmlWriter ); } void dumpGeometryAsElement(drawing::PointSequenceSequence aGeometry, xmlTextWriterPtr xmlWriter) { xmlTextWriterStartElement(xmlWriter, BAD_CAST( "Geometry" )); - dumpPointSequenceSequence(aGeometry, xmlWriter); + dumpPointSequenceSequence(aGeometry, NULL, xmlWriter); xmlTextWriterEndElement( xmlWriter ); } @@ -1767,12 +1757,17 @@ namespace { uno::Reference< lang::XServiceInfo > xServiceInfo( xShape, uno::UNO_QUERY_THROW ); uno::Sequence< rtl::OUString > aServiceNames = xServiceInfo->getSupportedServiceNames(); - uno::Any aAny = xPropSet->getPropertyValue("Name"); - if (aAny >>= aName) + uno::Reference< beans::XPropertySetInfo> xInfo = xPropSet->getPropertySetInfo(); + if(xInfo->hasPropertyByName("Name")) { - if (!aName.isEmpty()) - xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("name"), "%s", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr()); + uno::Any aAny = xPropSet->getPropertyValue("Name"); + if (aAny >>= aName) + { + if (!aName.isEmpty()) + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("name"), "%s", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr()); + } } + try { if (xServiceInfo->supportsService("com.sun.star.drawing.Text")) |