diff options
author | Artur Dorda <artur.dorda+libo@gmail.com> | 2012-06-01 19:54:53 +0200 |
---|---|---|
committer | Artur Dorda <artur.dorda+libo@gmail.com> | 2012-08-15 13:42:10 +0200 |
commit | 0e38825ddf1939a1d6ec2e0db5c5c1f4e73d1798 (patch) | |
tree | 69a3e3008dcfd0efd34a515a30dbb7b5046e73db /chart2 | |
parent | use a namespace for xfrm transformation element, fixes part of fdo#41992 (diff) | |
download | core-0e38825ddf1939a1d6ec2e0db5c5c1f4e73d1798.tar.gz core-0e38825ddf1939a1d6ec2e0db5c5c1f4e73d1798.zip |
Working version of XShapeDumper
Change-Id: I4f4d37abdb1865d0bc05f01518d854872235121f
Diffstat (limited to 'chart2')
-rw-r--r-- | chart2/source/view/main/ChartView.cxx | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/chart2/source/view/main/ChartView.cxx b/chart2/source/view/main/ChartView.cxx index 5c23d0274039..e9cd734032a8 100644 --- a/chart2/source/view/main/ChartView.cxx +++ b/chart2/source/view/main/ChartView.cxx @@ -3012,6 +3012,106 @@ uno::Sequence< ::rtl::OUString > ChartView::getAvailableServiceNames() throw (un return aServiceNames; } +/* ---------------------- + goes to drawinglayer/XShapeDumper.cxx + ---------------------- +namespace { + +#define DEBUG_DUMPER 0 + +int writeCallback(void* pContext, const char* sBuffer, int nLen) +{ + rtl::OStringBuffer* pBuffer = static_cast<rtl::OStringBuffer*>(pContext); + pBuffer->append(sBuffer); + return nLen; +} + +int closeCallback(void* ) +{ + return 0; +} + +void dumpPositionAsAttribute(const awt::Point& rPoint, xmlTextWriterPtr xmlWriter) +{ + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionX"), "%" SAL_PRIdINT32, rPoint.X); + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("positionY"), "%" SAL_PRIdINT32, rPoint.Y); +} + +void dumpSizeAsAttribute(const awt::Size& rSize, xmlTextWriterPtr xmlWriter) +{ + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("sizeX"), "%" SAL_PRIdINT32, rSize.Width); + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("sizeY"), "%" SAL_PRIdINT32, rSize.Height); +} + +void dumpShapeDescriptorAsAttribute( uno::Reference< drawing::XShapeDescriptor > xDescr, xmlTextWriterPtr xmlWriter ) +{ + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST("type"), "%s", rtl::OUStringToOString(xDescr->getShapeType(), RTL_TEXTENCODING_UTF8).getStr()); +} + +void dumpXShapes( uno::Reference< drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter ); + +void dumpXShape( uno::Reference< drawing::XShape > xShape, xmlTextWriterPtr xmlWriter ) +{ + xmlTextWriterStartElement( xmlWriter, BAD_CAST( "XShape" ) ); + + dumpPositionAsAttribute(xShape->getPosition(), xmlWriter); + dumpSizeAsAttribute(xShape->getSize(), xmlWriter); + uno::Reference< drawing::XShapeDescriptor > xDescr(xShape, uno::UNO_QUERY_THROW); + dumpShapeDescriptorAsAttribute(xDescr, xmlWriter); + + uno::Reference< lang::XServiceInfo > xServiceInfo( xShape, uno::UNO_QUERY_THROW ); + uno::Sequence< rtl::OUString > aServiceNames = xServiceInfo->getSupportedServiceNames(); + + uno::Reference< beans::XPropertySet > xPropSet(xShape, uno::UNO_QUERY_THROW); + uno::Any aAny = xPropSet->getPropertyValue("Name"); + rtl::OUString aName; + if (aAny >>= aName) + { + if (!aName.isEmpty()) + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("name"), "%s", rtl::OUStringToOString(aName, RTL_TEXTENCODING_UTF8).getStr()); + } + if (xServiceInfo->supportsService("com.sun.star.drawing.Text")) + { + uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY_THROW); + rtl::OUString aText = xText->getString(); + if(!aText.isEmpty()) + xmlTextWriterWriteFormatAttribute( xmlWriter, BAD_CAST("text"), "%s", rtl::OUStringToOString(aText, RTL_TEXTENCODING_UTF8).getStr()); + } + else if(xServiceInfo->supportsService("com.sun.star.drawing.GroupShape")) + { + uno::Reference< drawing::XShapes > xShapes(xShape, uno::UNO_QUERY_THROW); + dumpXShapes(xShapes, xmlWriter); + } +#if DEBUG_DUMPER + sal_Int32 nServices = aServiceNames.getLength(); + for (sal_Int32 i = 0; i < nServices; ++i) + { + xmlTextWriterStartElement(xmlWriter, BAD_CAST( "ServiceName" )); + xmlTextWriterWriteFormatAttribute(xmlWriter, BAD_CAST( "name" ), "%s", rtl::OUStringToOString(aServiceNames[i], RTL_TEXTENCODING_UTF8).getStr()); + xmlTextWriterEndElement( xmlWriter ); + } +#endif + + xmlTextWriterEndElement( xmlWriter ); +} + +void dumpXShapes( uno::Reference< drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter ) +{ + xmlTextWriterStartElement( xmlWriter, BAD_CAST( "XShapes" ) ); + uno::Reference< container::XIndexAccess > xIA( xShapes, uno::UNO_QUERY_THROW); + sal_Int32 nLength = xIA->getCount(); + for (sal_Int32 i = 0; i < nLength; ++i) + { + uno::Reference< drawing::XShape > xShape( xIA->getByIndex( i ), uno::UNO_QUERY_THROW ); + dumpXShape( xShape, xmlWriter ); + } + + xmlTextWriterEndElement( xmlWriter ); +} + +} +*/ + rtl::OUString ChartView::dump() throw (uno::RuntimeException) { impl_updateView(); |