summaryrefslogtreecommitdiff
path: root/drawinglayer/source
diff options
context:
space:
mode:
authorArmin Weiss <aw@openoffice.org>2008-03-05 07:22:35 +0000
committerArmin Weiss <aw@openoffice.org>2008-03-05 07:22:35 +0000
commitdd00bcda4b6ee482743d3085ce4f253fb2120dba (patch)
tree974a455a6d97aeccefb0dc79e4c204211a6a422f /drawinglayer/source
parent82a55e50a8fab8898ab0d59639e7ab6266eda4a2 (diff)
#i39532# prettyprinter support
Diffstat (limited to 'drawinglayer/source')
-rw-r--r--drawinglayer/source/primitive2d/chartprimitive2d.cxx88
-rw-r--r--drawinglayer/source/primitive2d/makefile.mk5
-rw-r--r--drawinglayer/source/processor2d/makefile.mk5
-rw-r--r--drawinglayer/source/processor2d/vclchartprocessor2d.cxx115
-rw-r--r--drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx17
-rw-r--r--drawinglayer/source/processor2d/vclpixelprocessor2d.cxx17
6 files changed, 238 insertions, 9 deletions
diff --git a/drawinglayer/source/primitive2d/chartprimitive2d.cxx b/drawinglayer/source/primitive2d/chartprimitive2d.cxx
new file mode 100644
index 000000000000..24225d89f7ff
--- /dev/null
+++ b/drawinglayer/source/primitive2d/chartprimitive2d.cxx
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: chartprimitive2d.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: aw $ $Date: 2008-03-05 08:22:34 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CHARTPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
+#endif
+
+#ifndef _BGFX_TOOLS_CANVASTOOLS_HXX
+#include <basegfx/tools/canvastools.hxx>
+#endif
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_PRIMITIVETYPES2D_HXX
+#include <drawinglayer/primitive2d/drawinglayer_primitivetypes2d.hxx>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace primitive2d
+ {
+ ChartPrimitive2D::ChartPrimitive2D(
+ const uno::Reference< frame::XModel >& rxChartModel,
+ const basegfx::B2DHomMatrix& rTransformation,
+ const Primitive2DSequence& rChildren)
+ : GroupPrimitive2D(rChildren),
+ mxChartModel(rxChartModel),
+ maTransformation(rTransformation)
+ {
+ }
+
+ bool ChartPrimitive2D::operator==(const BasePrimitive2D& rPrimitive) const
+ {
+ if(GroupPrimitive2D::operator==(rPrimitive))
+ {
+ const ChartPrimitive2D& rCompare = static_cast< const ChartPrimitive2D& >(rPrimitive);
+
+ return (getChartModel() == rCompare.getChartModel()
+ && getTransformation() == rCompare.getTransformation());
+ }
+
+ return false;
+ }
+
+ // provide unique ID
+ ImplPrimitrive2DIDBlock(ChartPrimitive2D, PRIMITIVE2D_ID_CHARTPRIMITIVE2D)
+
+ } // end of namespace primitive2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/drawinglayer/source/primitive2d/makefile.mk b/drawinglayer/source/primitive2d/makefile.mk
index 85def675d64d..0e6b5d258cc6 100644
--- a/drawinglayer/source/primitive2d/makefile.mk
+++ b/drawinglayer/source/primitive2d/makefile.mk
@@ -4,9 +4,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.10 $
+# $Revision: 1.11 $
#
-# last change: $Author: aw $ $Date: 2008-02-26 08:28:51 $
+# last change: $Author: aw $ $Date: 2008-03-05 08:20:32 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@@ -50,6 +50,7 @@ SLOFILES= \
$(SLO)$/baseprimitive2d.obj \
$(SLO)$/backgroundcolorprimitive2d.obj \
$(SLO)$/bitmapprimitive2d.obj \
+ $(SLO)$/chartprimitive2d.obj \
$(SLO)$/controlprimitive2d.obj \
$(SLO)$/embedded3dprimitive2d.obj \
$(SLO)$/fillbitmapprimitive2d.obj \
diff --git a/drawinglayer/source/processor2d/makefile.mk b/drawinglayer/source/processor2d/makefile.mk
index 8e0befe97fcf..a08c67d45523 100644
--- a/drawinglayer/source/processor2d/makefile.mk
+++ b/drawinglayer/source/processor2d/makefile.mk
@@ -4,9 +4,9 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.6 $
+# $Revision: 1.7 $
#
-# last change: $Author: aw $ $Date: 2008-01-30 12:25:05 $
+# last change: $Author: aw $ $Date: 2008-03-05 08:20:32 $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
@@ -51,6 +51,7 @@ SLOFILES= \
$(SLO)$/vclhelperbitmaprender.obj \
$(SLO)$/vclhelperbufferdevice.obj \
$(SLO)$/vclprocessor2d.obj \
+ $(SLO)$/vclchartprocessor2d.obj \
$(SLO)$/vclpixelprocessor2d.obj \
$(SLO)$/vclmetafileprocessor2d.obj \
$(SLO)$/contourextractor2d.obj \
diff --git a/drawinglayer/source/processor2d/vclchartprocessor2d.cxx b/drawinglayer/source/processor2d/vclchartprocessor2d.cxx
new file mode 100644
index 000000000000..c375f48133ad
--- /dev/null
+++ b/drawinglayer/source/processor2d/vclchartprocessor2d.cxx
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * $RCSfile: vclchartprocessor2d.cxx,v $
+ *
+ * $Revision: 1.1 $
+ *
+ * last change: $Author: aw $ $Date: 2008-03-05 08:22:35 $
+ *
+ * The Contents of this file are made available subject to
+ * the terms of GNU Lesser General Public License Version 2.1.
+ *
+ *
+ * GNU Lesser General Public License Version 2.1
+ * =============================================
+ * Copyright 2005 by Sun Microsystems, Inc.
+ * 901 San Antonio Road, Palo Alto, CA 94303, USA
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1, as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ ************************************************************************/
+
+#include <drawinglayer/processor2d/vclprocessor2d.hxx>
+#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
+#include <svtools/chartprettypainter.hxx>
+#include <com/sun/star/lang/XUnoTunnel.hpp>
+#include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <drawinglayer/processor2d/vclpixelprocessor2d.hxx>
+
+//////////////////////////////////////////////////////////////////////////////
+
+using namespace com::sun::star;
+
+//////////////////////////////////////////////////////////////////////////////
+
+namespace drawinglayer
+{
+ namespace processor2d
+ {
+ void VclProcessor2D::RenderChartPrimitive2D(const primitive2d::ChartPrimitive2D& rChartCandidate, bool bCalledFromPixelRenderer)
+ {
+ bool bChartRendered(false);
+
+ // code from chart PrettyPrinter
+ try
+ {
+ uno::Reference< lang::XMultiServiceFactory > xFact( rChartCandidate.getChartModel(), uno::UNO_QUERY );
+ OSL_ENSURE( xFact.is(), "Chart cannot be painted pretty!\n" );
+
+ if( xFact.is() )
+ {
+ uno::Reference< lang::XUnoTunnel > xChartRenderer( xFact->createInstance(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart2.ChartRenderer" ) ) ), uno::UNO_QUERY );
+ OSL_ENSURE( xChartRenderer.is(), "Chart cannot be painted pretty!\n" );
+
+ if( xChartRenderer.is() )
+ {
+ ChartPrettyPainter* pPrettyPainter = reinterpret_cast<ChartPrettyPainter*>(
+ xChartRenderer->getSomething( ChartPrettyPainter::getUnoTunnelId() ));
+
+ if( pPrettyPainter )
+ {
+ // create logic object range
+ basegfx::B2DRange aObjectRange(0.0, 0.0, 1.0, 1.0);
+ aObjectRange.transform(rChartCandidate.getTransformation());
+ const Rectangle aRectangle(
+ (sal_Int32)aObjectRange.getMinX(), (sal_Int32)aObjectRange.getMinY(),
+ (sal_Int32)aObjectRange.getMaxX(), (sal_Int32)aObjectRange.getMaxY());
+
+ if(bCalledFromPixelRenderer)
+ {
+ mpOutputDevice->Push(PUSH_MAPMODE);
+ mpOutputDevice->SetMapMode(static_cast< VclPixelProcessor2D* >(this)->getOriginalMapMode());
+ }
+
+ bChartRendered = pPrettyPainter->DoPaint(mpOutputDevice, aRectangle);
+
+ if(bCalledFromPixelRenderer)
+ {
+ mpOutputDevice->Pop();
+ }
+ }
+ }
+ }
+ }
+ catch( uno::Exception& e )
+ {
+ (void)e;
+ DBG_ERROR( "Chart cannot be painted pretty!" );
+ }
+
+ if(!bChartRendered)
+ {
+ // fallback to decompositopn (MetaFile)
+ process(rChartCandidate.get2DDecomposition(getViewInformation2D()));
+ }
+ }
+ } // end of namespace processor2d
+} // end of namespace drawinglayer
+
+//////////////////////////////////////////////////////////////////////////////
+// eof
diff --git a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
index 318feab3692a..dc33ee7f3a45 100644
--- a/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: vclmetafileprocessor2d.cxx,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: aw $ $Date: 2008-02-07 13:41:59 $
+ * last change: $Author: aw $ $Date: 2008-03-05 08:20:32 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -200,6 +200,13 @@
#endif
//////////////////////////////////////////////////////////////////////////////
+// for current chart PrettyPrinting support
+
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CHARTPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
+#endif
+
+//////////////////////////////////////////////////////////////////////////////
namespace drawinglayer
{
@@ -1699,6 +1706,12 @@ namespace drawinglayer
RenderPointArrayPrimitive2D(static_cast< const primitive2d::PointArrayPrimitive2D& >(rCandidate));
break;
}
+ case PRIMITIVE2D_ID_CHARTPRIMITIVE2D :
+ {
+ // point array
+ RenderChartPrimitive2D(static_cast< const primitive2d::ChartPrimitive2D& >(rCandidate), false);
+ break;
+ }
default :
{
// process recursively
diff --git a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
index 58c07967f034..8b57a1f3aabd 100644
--- a/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
+++ b/drawinglayer/source/processor2d/vclpixelprocessor2d.cxx
@@ -4,9 +4,9 @@
*
* $RCSfile: vclpixelprocessor2d.cxx,v $
*
- * $Revision: 1.10 $
+ * $Revision: 1.11 $
*
- * last change: $Author: aw $ $Date: 2008-02-07 13:41:59 $
+ * last change: $Author: aw $ $Date: 2008-03-05 08:20:32 $
*
* The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1.
@@ -113,6 +113,10 @@
#include <drawinglayer/primitive2d/pagepreviewprimitive2d.hxx>
#endif
+#ifndef INCLUDED_DRAWINGLAYER_PRIMITIVE2D_CHARTPRIMITIVE2D_HXX
+#include <drawinglayer/primitive2d/chartprimitive2d.hxx>
+#endif
+
#include <cstdio>
//////////////////////////////////////////////////////////////////////////////
@@ -122,7 +126,8 @@ namespace drawinglayer
namespace processor2d
{
VclPixelProcessor2D::VclPixelProcessor2D(const geometry::ViewInformation2D& rViewInformation, OutputDevice& rOutDev)
- : VclProcessor2D(rViewInformation, rOutDev)
+ : VclProcessor2D(rViewInformation, rOutDev),
+ maOriginalMapMode(rOutDev.GetMapMode())
{
// prepare maCurrentTransformation matrix with viewTransformation to target directly to pixels
maCurrentTransformation = rViewInformation.getViewTransformation();
@@ -423,6 +428,12 @@ namespace drawinglayer
break;
}
+ case PRIMITIVE2D_ID_CHARTPRIMITIVE2D :
+ {
+ // chart primitive
+ RenderChartPrimitive2D(static_cast< const primitive2d::ChartPrimitive2D& >(rCandidate), true);
+ break;
+ }
default :
{
// process recursively