summaryrefslogtreecommitdiffstats
path: root/drawinglayer
diff options
context:
space:
mode:
authorArtur Dorda <artur.dorda+libo@gmail.com>2012-06-01 19:54:53 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-07-12 03:10:00 +0200
commitea18a422cd2ec0bc3a8e8e569576c09828e45d39 (patch)
tree7bd84fd9a3abeaea4bf1dd911fa922b2ae40eb67 /drawinglayer
parentUnfinished dumper code (diff)
downloadcore-ea18a422cd2ec0bc3a8e8e569576c09828e45d39.tar.gz
core-ea18a422cd2ec0bc3a8e8e569576c09828e45d39.zip
Working version of XShapeDumper
Change-Id: I4f4d37abdb1865d0bc05f01518d854872235121f
Diffstat (limited to 'drawinglayer')
-rw-r--r--drawinglayer/Library_drawinglayer.mk6
-rw-r--r--drawinglayer/Package_inc.mk2
-rw-r--r--drawinglayer/inc/drawinglayer/ChartViewDumper.hxx50
-rw-r--r--drawinglayer/source/dumper/ChartViewDumper.cxx159
4 files changed, 6 insertions, 211 deletions
diff --git a/drawinglayer/Library_drawinglayer.mk b/drawinglayer/Library_drawinglayer.mk
index 37e0cdd9e7b6..202211858278 100644
--- a/drawinglayer/Library_drawinglayer.mk
+++ b/drawinglayer/Library_drawinglayer.mk
@@ -40,6 +40,10 @@ $(eval $(call gb_Library_add_defs,drawinglayer,\
$(eval $(call gb_Library_use_sdk_api,drawinglayer))
+$(eval $(call gb_Library_use_externals,drawinglayer,\
+ libxml2 \
+))
+
$(eval $(call gb_Library_use_libraries,drawinglayer,\
basegfx \
canvastools \
@@ -172,7 +176,7 @@ $(eval $(call gb_Library_add_exception_objects,drawinglayer,\
drawinglayer/source/processor3d/zbufferprocessor3d \
drawinglayer/source/texture/texture3d \
drawinglayer/source/texture/texture \
- drawinglayer/source/dumper/ChartViewDumper \
+ drawinglayer/source/dumper/XShapeDumper \
))
# vim: set noet sw=4 ts=4:
diff --git a/drawinglayer/Package_inc.mk b/drawinglayer/Package_inc.mk
index 51c52ce838ea..7d41e6c2b5d8 100644
--- a/drawinglayer/Package_inc.mk
+++ b/drawinglayer/Package_inc.mk
@@ -137,6 +137,6 @@ $(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/processor3d/
$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/processor3d/zbufferprocessor3d.hxx,drawinglayer/processor3d/zbufferprocessor3d.hxx))
$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/texture/texture3d.hxx,drawinglayer/texture/texture3d.hxx))
$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/texture/texture.hxx,drawinglayer/texture/texture.hxx))
-$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/ChartViewDumper.hxx,drawinglayer/ChartViewDumper.hxx))
+$(eval $(call gb_Package_add_file,drawinglayer_inc,inc/drawinglayer/XShapeDumper.hxx,drawinglayer/XShapeDumper.hxx))
# vim: set noet sw=4 ts=4:
diff --git a/drawinglayer/inc/drawinglayer/ChartViewDumper.hxx b/drawinglayer/inc/drawinglayer/ChartViewDumper.hxx
deleted file mode 100644
index b7f355213a28..000000000000
--- a/drawinglayer/inc/drawinglayer/ChartViewDumper.hxx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Artur Dorda <artur.dorda+libo@gmail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <libxml/xmlwriter.h>
-#include <com/sun/star/drawing/XShapes.hpp>
-#include <com/sun/star/drawing/XShape.hpp>
-
-#ifndef ChartViewDumper_hxx
-#define ChartViewDumper_hxx
-
-class ChartViewDumper
-{
-
-public:
- ChartViewDumper();
- int writeCallback(void* pContext, const char* sBuffer, int nLen);
- void dumpPositionAsAttribute(const com::sun::star::awt::Point& rPoint, xmlTextWriterPtr xmlWriter);
- void dumpSizeAsAttribute(const com::sun::star::awt::Size& rSize, xmlTextWriterPtr xmlWriter);
- void dumpShapeDescriptorAsAttribute( com::sun::star::uno::Reference< com::sun::star::drawing::XShapeDescriptor > xDescr, xmlTextWriterPtr xmlWriter );
- void dumpXShape(com::sun::star::uno::Reference< com::sun::star::drawing::XShape > xShape, xmlTextWriterPtr xmlWriter);
- void dumpXShapes( com::sun::star::uno::Reference< com::sun::star::drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter );
- rtl::OUString dump();
-
-};
-#endif
diff --git a/drawinglayer/source/dumper/ChartViewDumper.cxx b/drawinglayer/source/dumper/ChartViewDumper.cxx
deleted file mode 100644
index 5d3c03761242..000000000000
--- a/drawinglayer/source/dumper/ChartViewDumper.cxx
+++ /dev/null
@@ -1,159 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * Version: MPL 1.1 / GPLv3+ / LGPLv3+
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License or as specified alternatively below. You may obtain a copy of
- * the License at http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * Major Contributor(s):
- * Copyright (C) 2012 Artur Dorda <artur.dorda+libo@gmail.com> (initial developer)
- *
- * All Rights Reserved.
- *
- * For minor contributions see the git repository.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
- * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
- * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
- * instead of those above.
- */
-
-#include <drawinglayer/ChartViewDumper.hxx>
-#include <com/sun/star/drawing/XShapes.hpp>
-#include <com/sun/star/drawing/XShape.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <com/sun/star/beans/XPropertySet.hpp>
-#include <com/sun/star/text/XText.hpp>
-#include <rtl/strbuf.hxx>
-
-
-#define DEBUG_DUMPER 0
-
-using namespace com::sun::star;
-//class ChartViewDumper
-namespace
-{
- void dumpXShapes( uno::Reference< drawing::XShapes > xShapes, xmlTextWriterPtr xmlWriter );
-
- 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 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 dump() throw (uno::RuntimeException)
- {
- impl_updateView();
- uno::Reference<drawing::XShapes> xPageShapes( ShapeFactory(m_xShapeFactory)
- .getOrCreateChartRootShape( m_xDrawPage ) );
-
- if (!xPageShapes.is())
- return rtl::OUString();
-
- rtl::OStringBuffer aString;
- xmlOutputBufferPtr xmlOutBuffer = xmlOutputBufferCreateIO( writeCallback, closeCallback, &aString, NULL );
- xmlTextWriterPtr xmlWriter = xmlNewTextWriter( xmlOutBuffer );
- xmlTextWriterSetIndent( xmlWriter, 1 );
-
- xmlTextWriterStartDocument( xmlWriter, NULL, NULL, NULL );
-
- dumpXShapes( xPageShapes, xmlWriter );
-
- xmlTextWriterEndDocument( xmlWriter );
- xmlFreeTextWriter( xmlWriter );
-
- return OStringToOUString(aString.makeStringAndClear(), RTL_TEXTENCODING_UTF8);
- }
-
-} //end of namespace