summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThorsten Behrens <thb@documentfoundation.org>2013-10-29 19:08:11 +0100
committerThorsten Behrens <thb@documentfoundation.org>2013-11-16 01:36:30 +0100
commitc60e7256120ecf1698b505787581e2ac594b2e37 (patch)
tree81ea735a9eacbbf3de2f39e59ff7db2930d0e949
parent5d7c894678f3ba8999017e4ed66ba81a5314b15b (diff)
Die, wrapper code, die.
Change-Id: I987703958621abb38d877b3089aaaa7d0f97f5e9
-rw-r--r--cppcanvas/CppunitTest_cppcanvas_test.mk60
-rw-r--r--cppcanvas/Library_cppcanvas.mk74
-rw-r--r--cppcanvas/Library_mtfrenderer.mk42
-rw-r--r--cppcanvas/Makefile14
-rw-r--r--cppcanvas/Module_cppcanvas.mk34
-rw-r--r--cppcanvas/README5
-rw-r--r--cppcanvas/qa/unit/test.cxx93
-rw-r--r--cppcanvas/source/inc/action.hxx156
-rw-r--r--cppcanvas/source/inc/canvasgraphichelper.hxx78
-rw-r--r--cppcanvas/source/inc/implrenderer.hxx342
-rw-r--r--cppcanvas/source/inc/outdevstate.hxx126
-rw-r--r--cppcanvas/source/inc/tools.hxx50
-rw-r--r--cppcanvas/source/mtfrenderer/bitmapaction.cxx229
-rw-r--r--cppcanvas/source/mtfrenderer/bitmapaction.hxx75
-rw-r--r--cppcanvas/source/mtfrenderer/cachedprimitivebase.cxx84
-rw-r--r--cppcanvas/source/mtfrenderer/cachedprimitivebase.hxx89
-rw-r--r--cppcanvas/source/mtfrenderer/emfplus.cxx1940
-rw-r--r--cppcanvas/source/mtfrenderer/implrenderer.cxx3104
-rw-r--r--cppcanvas/source/mtfrenderer/lineaction.cxx158
-rw-r--r--cppcanvas/source/mtfrenderer/lineaction.hxx67
-rw-r--r--cppcanvas/source/mtfrenderer/mtftools.cxx621
-rw-r--r--cppcanvas/source/mtfrenderer/mtftools.hxx207
-rw-r--r--cppcanvas/source/mtfrenderer/pointaction.cxx178
-rw-r--r--cppcanvas/source/mtfrenderer/pointaction.hxx72
-rw-r--r--cppcanvas/source/mtfrenderer/polypolyaction.cxx514
-rw-r--r--cppcanvas/source/mtfrenderer/polypolyaction.hxx95
-rw-r--r--cppcanvas/source/mtfrenderer/textaction.cxx2283
-rw-r--r--cppcanvas/source/mtfrenderer/textaction.hxx95
-rw-r--r--cppcanvas/source/mtfrenderer/transparencygroupaction.cxx499
-rw-r--r--cppcanvas/source/mtfrenderer/transparencygroupaction.hxx106
-rw-r--r--cppcanvas/source/tools/canvasgraphichelper.cxx131
-rw-r--r--cppcanvas/source/tools/tools.cxx54
-rw-r--r--cppcanvas/source/uno/mtfrenderer.component15
-rw-r--r--cppcanvas/source/uno/uno_mtfrenderer.cxx58
-rw-r--r--cppcanvas/source/uno/uno_mtfrenderer.hxx44
-rw-r--r--cppcanvas/source/wrapper/basegfxfactory.cxx131
-rw-r--r--cppcanvas/source/wrapper/implbitmap.cxx118
-rw-r--r--cppcanvas/source/wrapper/implbitmap.hxx72
-rw-r--r--cppcanvas/source/wrapper/implbitmapcanvas.cxx65
-rw-r--r--cppcanvas/source/wrapper/implbitmapcanvas.hxx64
-rw-r--r--cppcanvas/source/wrapper/implcanvas.cxx133
-rw-r--r--cppcanvas/source/wrapper/implcanvas.hxx94
-rw-r--r--cppcanvas/source/wrapper/implcolor.cxx60
-rw-r--r--cppcanvas/source/wrapper/implcolor.hxx56
-rw-r--r--cppcanvas/source/wrapper/implcustomsprite.cxx74
-rw-r--r--cppcanvas/source/wrapper/implcustomsprite.hxx63
-rw-r--r--cppcanvas/source/wrapper/implfont.cxx83
-rw-r--r--cppcanvas/source/wrapper/implfont.hxx69
-rw-r--r--cppcanvas/source/wrapper/implpolypolygon.cxx193
-rw-r--r--cppcanvas/source/wrapper/implpolypolygon.hxx87
-rw-r--r--cppcanvas/source/wrapper/implsprite.cxx202
-rw-r--r--cppcanvas/source/wrapper/implsprite.hxx78
-rw-r--r--cppcanvas/source/wrapper/implspritecanvas.cxx138
-rw-r--r--cppcanvas/source/wrapper/implspritecanvas.hxx94
-rw-r--r--cppcanvas/source/wrapper/vclfactory.cxx113
-rw-r--r--vcl/source/gdi/gdimtf.cxx3
56 files changed, 3 insertions, 13779 deletions
diff --git a/cppcanvas/CppunitTest_cppcanvas_test.mk b/cppcanvas/CppunitTest_cppcanvas_test.mk
deleted file mode 100644
index 8112fd3d193d..000000000000
--- a/cppcanvas/CppunitTest_cppcanvas_test.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#*************************************************************************
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-#*************************************************************************
-
-$(eval $(call gb_CppunitTest_CppunitTest,cppcanvas_test))
-
-$(eval $(call gb_CppunitTest_add_exception_objects,cppcanvas_test, \
- cppcanvas/qa/unit/test \
-))
-
-$(eval $(call gb_CppunitTest_unset_headless,cppcanvas_test))
-
-$(eval $(call gb_CppunitTest_use_external,cppcanvas_test,boost_headers))
-
-$(eval $(call gb_CppunitTest_use_libraries,cppcanvas_test, \
- cppcanvas \
- basegfx \
- canvastools \
- comphelper \
- cppu \
- cppuhelper \
- i18nlangtag \
- sal \
- svt \
- test \
- tl \
- vcl \
- $(gb_UWINAPI) \
-))
-
-$(eval $(call gb_CppunitTest_use_api,cppcanvas_test,\
- offapi \
- udkapi \
-))
-
-$(eval $(call gb_CppunitTest_use_ure,cppcanvas_test))
-
-$(eval $(call gb_CppunitTest_use_components,cppcanvas_test,\
- canvas/source/cairo/cairocanvas \
- canvas/source/factory/canvasfactory \
- configmgr/source/configmgr \
- fileaccess/source/fileacc \
- i18npool/util/i18npool \
- linguistic/source/lng \
- package/util/package2 \
- sax/source/expatwrap/expwrap \
- ucb/source/core/ucb1 \
- unoxml/source/service/unoxml \
-))
-
-$(eval $(call gb_CppunitTest_use_configuration,cppcanvas_test))
-
-# vim: set noet sw=4 ts=4:
diff --git a/cppcanvas/Library_cppcanvas.mk b/cppcanvas/Library_cppcanvas.mk
deleted file mode 100644
index 7f69cf95d597..000000000000
--- a/cppcanvas/Library_cppcanvas.mk
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$(eval $(call gb_Library_Library,cppcanvas))
-
-$(eval $(call gb_Library_set_include,cppcanvas,\
- -I$(SRCDIR)/cppcanvas/source/inc \
- $$(INCLUDE) \
-))
-
-$(eval $(call gb_Library_use_sdk_api,cppcanvas))
-$(eval $(call gb_Library_add_defs,cppcanvas,\
- -DCPPCANVAS_DLLIMPLEMENTATION \
-))
-
-$(eval $(call gb_Library_use_external,cppcanvas,boost_headers))
-
-$(eval $(call gb_Library_use_libraries,cppcanvas,\
- basegfx \
- canvastools \
- comphelper \
- cppu \
- cppuhelper \
- i18nlangtag \
- sal \
- svt \
- tl \
- vcl \
- $(gb_UWINAPI) \
-))
-
-$(eval $(call gb_Library_add_exception_objects,cppcanvas,\
- cppcanvas/source/mtfrenderer/bitmapaction \
- cppcanvas/source/mtfrenderer/cachedprimitivebase \
- cppcanvas/source/mtfrenderer/emfplus \
- cppcanvas/source/mtfrenderer/implrenderer \
- cppcanvas/source/mtfrenderer/lineaction \
- cppcanvas/source/mtfrenderer/mtftools \
- cppcanvas/source/mtfrenderer/pointaction \
- cppcanvas/source/mtfrenderer/polypolyaction \
- cppcanvas/source/mtfrenderer/textaction \
- cppcanvas/source/mtfrenderer/transparencygroupaction \
- cppcanvas/source/tools/canvasgraphichelper \
- cppcanvas/source/tools/tools \
- cppcanvas/source/wrapper/basegfxfactory \
- cppcanvas/source/wrapper/implbitmap \
- cppcanvas/source/wrapper/implbitmapcanvas \
- cppcanvas/source/wrapper/implcanvas \
- cppcanvas/source/wrapper/implcolor \
- cppcanvas/source/wrapper/implcustomsprite \
- cppcanvas/source/wrapper/implfont \
- cppcanvas/source/wrapper/implpolypolygon \
- cppcanvas/source/wrapper/implsprite \
- cppcanvas/source/wrapper/implspritecanvas \
- cppcanvas/source/wrapper/vclfactory \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/cppcanvas/Library_mtfrenderer.mk b/cppcanvas/Library_mtfrenderer.mk
deleted file mode 100644
index 4a33ac0c6eda..000000000000
--- a/cppcanvas/Library_mtfrenderer.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$(eval $(call gb_Library_Library,mtfrenderer))
-
-$(eval $(call gb_Library_set_componentfile,mtfrenderer,cppcanvas/source/uno/mtfrenderer))
-
-$(eval $(call gb_Library_use_external,mtfrenderer,boost_headers))
-
-$(eval $(call gb_Library_use_libraries,mtfrenderer,\
- sal \
- cppu \
- cppuhelper \
- comphelper \
- cppcanvas \
- basegfx \
- $(gb_UWINAPI) \
-))
-
-$(eval $(call gb_Library_use_sdk_api,mtfrenderer))
-
-$(eval $(call gb_Library_add_exception_objects,mtfrenderer,\
- cppcanvas/source/uno/uno_mtfrenderer \
-))
-
-# vim: set noet sw=4 ts=4:
diff --git a/cppcanvas/Makefile b/cppcanvas/Makefile
deleted file mode 100644
index 0997e628485b..000000000000
--- a/cppcanvas/Makefile
+++ /dev/null
@@ -1,14 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-
-module_directory:=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))
-
-include $(module_directory)/../solenv/gbuild/partial_build.mk
-
-# vim: set noet sw=4 ts=4:
diff --git a/cppcanvas/Module_cppcanvas.mk b/cppcanvas/Module_cppcanvas.mk
deleted file mode 100644
index 9894f9c83eca..000000000000
--- a/cppcanvas/Module_cppcanvas.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
-#
-# This file is part of the LibreOffice project.
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-#
-# This file incorporates work covered by the following license notice:
-#
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed
-# with this work for additional information regarding copyright
-# ownership. The ASF licenses this file to you under the Apache
-# License, Version 2.0 (the "License"); you may not use this file
-# except in compliance with the License. You may obtain a copy of
-# the License at http://www.apache.org/licenses/LICENSE-2.0 .
-#
-
-$(eval $(call gb_Module_Module,cppcanvas))
-
-$(eval $(call gb_Module_add_targets,cppcanvas,\
- Library_cppcanvas \
- Library_mtfrenderer \
-))
-
-# FIXME: should generalize these ...
-ifeq ($(ENABLE_CAIRO_CANVAS),TRUE)
-$(eval $(call gb_Module_add_check_targets,cppcanvas,\
- CppunitTest_cppcanvas_test \
-))
-endif
-
-# vim: set noet sw=4 ts=4:
diff --git a/cppcanvas/README b/cppcanvas/README
deleted file mode 100644
index 1e9083101434..000000000000
--- a/cppcanvas/README
+++ /dev/null
@@ -1,5 +0,0 @@
-Helper C++ classes for [[canvas]], plus a GDIMetaFile-to-XCanvas converter.
-
-== EMF+ ==
-
-For cppcanvas/source/mtfrenderer, see the README in vcl (the EMF+ part).
diff --git a/cppcanvas/qa/unit/test.cxx b/cppcanvas/qa/unit/test.cxx
deleted file mode 100644
index af652a3cf727..000000000000
--- a/cppcanvas/qa/unit/test.cxx
+++ /dev/null
@@ -1,93 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include <test/bootstrapfixture.hxx>
-
-#include <osl/file.hxx>
-#include <osl/process.h>
-#include <vcl/svapp.hxx>
-#include <vcl/wrkwin.hxx>
-#include <vcl/canvastools.hxx>
-
-#include <comphelper/processfactory.hxx>
-#include <com/sun/star/lang/XInitialization.hpp>
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-
-#include <com/sun/star/rendering/XBitmap.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/XBitmapCanvas.hpp>
-
-using namespace ::com::sun::star;
-
-class CanvasTest : public test::BootstrapFixture
-{
-public:
- CanvasTest() : BootstrapFixture(true, false) {}
-
- void testComposite();
-
- CPPUNIT_TEST_SUITE(CanvasTest);
- CPPUNIT_TEST(testComposite);
- CPPUNIT_TEST_SUITE_END();
-};
-
-void CanvasTest::testComposite()
-{
-#ifdef LINUX
- Window* pWin = new WorkWindow( (Window *)NULL );
- CPPUNIT_ASSERT( pWin != NULL );
-
- uno::Reference<rendering::XCanvas> xCanvas = pWin->GetCanvas ();
- if( !xCanvas.is() )
- return; // can't get a canvas working at all - truly headless ?
-
- // a huge canvas ...
- Size aSize (1, 1);
- uno::Reference<rendering::XBitmap> xBitmap;
- xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap(
- vcl::unotools::integerSize2DFromSize( aSize ) );
- CPPUNIT_ASSERT( xBitmap.is() );
-
- uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
- CPPUNIT_ASSERT( xBitmapCanvas.is() );
-
- BitmapEx aBitmapEx;
- {
- // clear the canvas and basic sanity check ...
- xBitmapCanvas->clear();
- CPPUNIT_ASSERT( aBitmapEx.Create( xBitmapCanvas, aSize ) );
- CPPUNIT_ASSERT( aBitmapEx.IsAlpha() );
- CPPUNIT_ASSERT( aBitmapEx.GetAlpha() );
- }
-
- {
- // render something
- rendering::RenderState aDefaultState;
- uno::Sequence< double > aRedTransparent( 4 );
- aRedTransparent[0] = 1.0; // R
- aRedTransparent[1] = 0.0; // G
- aRedTransparent[2] = 0.0; // B
- aRedTransparent[3] = 0.5; // A
- aDefaultState.DeviceColor = aRedTransparent;
-#if 0
- // words fail me to describe the sheer beauty of allocating an UNO
- // object to represent a polygon, and manually handling the ViewState
- // and there being no public helper for this - to render ... a rectangle.
- XCachedPrimitive fillPolyPolygon( [in] XPolyPolygon2D xPolyPolygon, [in] ViewState aViewState, [in] RenderState aRenderState )
-#endif
- }
-
-#endif
-}
-
-CPPUNIT_TEST_SUITE_REGISTRATION(CanvasTest);
-
-CPPUNIT_PLUGIN_IMPLEMENT();
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/inc/action.hxx b/cppcanvas/source/inc/action.hxx
deleted file mode 100644
index 3beaa8ce2b05..000000000000
--- a/cppcanvas/source/inc/action.hxx
+++ /dev/null
@@ -1,156 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_ACTION_HXX
-#define _CPPCANVAS_ACTION_HXX
-
-#include <sal/types.h>
-
-#include <boost/shared_ptr.hpp>
-
-namespace basegfx
-{
- class B2DHomMatrix;
- class B2DRange;
-}
-
-
-/* Definition of Action interface */
-
-namespace cppcanvas
-{
- namespace internal
- {
- /** Interface for internal render actions
-
- This interface is implemented by all objects generated
- from the metafile renderer, and corresponds roughly to the
- VCL meta action.
- */
- class Action
- {
- public:
- /** Used for rendering action subsets
-
- There are several cases where an Action might have
- subsettable content, e.g. text, or referenced
- metafiles, like the transparent action.
-
- Generally, at the metafile renderer, all actions are
- 'flattened' out, i.e. a meta action rendering the
- string "Hello" counts five indices, and a transparent
- action containing a metafile with 100 actions counts
- at least 100 indices (contained transparency or text
- actions recursively add to this value). From the
- outside, the subset to render is referenced via this
- flat index range
- */
- struct Subset
- {
- /** Denotes start of the subset.
-
- The index given here specifies the first subaction
- to render.
- */
- sal_Int32 mnSubsetBegin;
-
- /** Denotes end of the subset
-
- The index given here specifies the first subaction
- <em>not<em> to render, i.e. one action behind the
- subset to be rendered
- */
- sal_Int32 mnSubsetEnd;
- };
-
- virtual ~Action() {}
-
- /** Render this action to the associated canvas
-
- @param rTransformation
- Transformation matrix to apply before rendering
-
- @return true, if rendering was successful. If
- rendering failed, false is returned.
- */
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
-
- /** Render the given part of the action to the associated
- canvas.
-
- @param rTransformation
- Transformation matrix to apply before rendering
-
- @param rSubset
- Subset of the action to render. See Subset description
- for index semantics.
-
- @return true, if rendering was successful. If the
- specified subset is invalid for this action, or if
- rendering failed for other reasons, false is returned.
- */
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const = 0;
-
- /** Query bounds of this action on the associated canvas
-
- @param rTransformation
- Transformation matrix to apply
-
- @return the bounds for this action in device
- coordinate space.
- */
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
-
- /** Query bounds for the given part of the action on the
- associated canvas.
-
- @param rTransformation
- Transformation matrix to apply.
-
- @param rSubset
- Subset of the action to query. See Subset description
- for index semantics.
-
- @return the bounds for the given subset in device
- coordinate space.
- */
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const = 0;
-
- /** Query action count.
-
- This method returns the number of subset actions
- contained in this action. The render( Subset ) method
- must accept subset ranges up to the value returned
- here.
-
- @return the number of subset actions
- */
- virtual sal_Int32 getActionCount() const = 0;
- };
-
- typedef ::boost::shared_ptr< Action > ActionSharedPtr;
-
- }
-}
-
-#endif /* _CPPCANVAS_ACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/inc/canvasgraphichelper.hxx b/cppcanvas/source/inc/canvasgraphichelper.hxx
deleted file mode 100644
index f0ab8bce88c3..000000000000
--- a/cppcanvas/source/inc/canvasgraphichelper.hxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_CANVASGRAPHICHELPER_HXX
-#define _CPPCANVAS_CANVASGRAPHICHELPER_HXX
-
-#include <com/sun/star/rendering/RenderState.hpp>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-
-#include <cppcanvas/canvasgraphic.hxx>
-
-#include <boost/optional.hpp>
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- class XGraphicDevice;
-} } } }
-
-
-/* Definition of CanvasGraphicHelper class */
-
-namespace cppcanvas
-{
-
- namespace internal
- {
-
- class CanvasGraphicHelper : public virtual CanvasGraphic
- {
- public:
- CanvasGraphicHelper( const CanvasSharedPtr& rParentCanvas );
-
- // CanvasGraphic implementation
- virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix );
- virtual ::basegfx::B2DHomMatrix getTransformation() const;
- virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly );
- virtual void setClip();
- virtual ::basegfx::B2DPolyPolygon const* getClip() const;
- virtual void setCompositeOp( CompositeOp aOp );
- virtual CompositeOp getCompositeOp() const;
-
- protected:
- // for our clients
- // ===============
- CanvasSharedPtr getCanvas() const;
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice > getGraphicDevice() const;
- const ::com::sun::star::rendering::RenderState& getRenderState() const;
-
- private:
- mutable ::com::sun::star::rendering::RenderState maRenderState;
-
- boost::optional<basegfx::B2DPolyPolygon> maClipPolyPolygon;
- CanvasSharedPtr mpCanvas;
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice > mxGraphicDevice;
- };
-
- }
-}
-
-#endif /* _CPPCANVAS_CANVASGRAPHICHELPER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/inc/implrenderer.hxx b/cppcanvas/source/inc/implrenderer.hxx
deleted file mode 100644
index c70bf548dbd5..000000000000
--- a/cppcanvas/source/inc/implrenderer.hxx
+++ /dev/null
@@ -1,342 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLRENDERER_HXX
-#define _CPPCANVAS_IMPLRENDERER_HXX
-
-#include <sal/types.h>
-
-#include <boost/shared_ptr.hpp>
-#include <cppcanvas/renderer.hxx>
-#include <cppcanvas/canvas.hxx>
-
-#include <canvasgraphichelper.hxx>
-#include <action.hxx>
-#include <outdevstate.hxx>
-
-#include <vector>
-#include <map>
-
-class GDIMetaFile;
-class VirtualDevice;
-class Gradient;
-class Rectangle;
-class Font;
-class PolyPolygon;
-class Point;
-class MetaCommentAction;
-
-namespace basegfx {
- class B2DPolyPolygon;
- class B2DPolygon;
-}
-
-namespace cppcanvas
-{
-
- namespace internal
- {
- struct OutDevState;
- struct ActionFactoryParameters;
- struct XForm;
-
- struct EMFPObject
- {
- virtual ~EMFPObject() {}
- };
-
- // state stack of OutputDevice, to correctly handle
- // push/pop actions
- class VectorOfOutDevStates
- {
- public:
- OutDevState& getState();
- const OutDevState& getState() const;
- void pushState(sal_uInt16 nFlags);
- void popState();
- void clearStateStack();
- private:
- ::std::vector< OutDevState > m_aStates;
- };
-
- // EMF+
- // TODO: replace?
- struct XForm
- {
- float eM11;
- float eM12;
- float eM21;
- float eM22;
- float eDx;
- float eDy;
- XForm()
- {
- SetIdentity ();
- };
-
- void SetIdentity ()
- {
- eM11 = eM22 = 1.0f;
- eDx = eDy = eM12 = eM21 = 0.0f;
- }
-
- void Set (float m11, float m12, float dx, float m21, float m22, float dy)
- {
- eM11 = m11;
- eM12 = m12;
- eDx = dx;
- eM21 = m21;
- eM22 = m22;
- eDy = dy;
- }
-
- void Set (XForm f)
- {
- eM11 = f.eM11;
- eM12 = f.eM12;
- eM21 = f.eM21;
- eM22 = f.eM22;
- eDx = f.eDx;
- eDy = f.eDy;
- }
-
- void Multiply (float m11, float m12, float dx, float m21, float m22, float dy)
- {
- eM11 = eM11*m11 + eM12*m21;
- eM12 = eM11*m12 + eM12*m22;
- eM21 = eM21*m11 + eM22*m21;
- eM22 = eM21*m12 + eM22*m22;
- eDx *= eDx*m11 + eDy*m21 + dx;
- eDy *= eDx*m12 + eDy*m22 + dy;
- }
-
- void Multiply (XForm f)
- {
- eM11 = eM11*f.eM11 + eM12*f.eM21;
- eM12 = eM11*f.eM12 + eM12*f.eM22;
- eM21 = eM21*f.eM11 + eM22*f.eM21;
- eM22 = eM21*f.eM12 + eM22*f.eM22;
- eDx *= eDx*f.eM11 + eDy*f.eM21 + f.eDx;
- eDy *= eDx*f.eM12 + eDy*f.eM22 + f.eDy;
- }
-
-#ifdef OSL_BIGENDIAN
-// currently unused
-static float GetSwapFloat( SvStream& rSt )
-{
- float fTmp;
- sal_Int8* pPtr = (sal_Int8*)&fTmp;
- rSt >> pPtr[3] >> pPtr[2] >> pPtr[1] >> pPtr[0]; // Little Endian <-> Big Endian switch
- return fTmp;
-}
-#endif
-
- friend SvStream& operator>>( SvStream& rIn, XForm& rXForm )
- {
- if ( sizeof( float ) != 4 )
- {
- OSL_FAIL( "EnhWMFReader::sizeof( float ) != 4" );
- rXForm = XForm();
- }
- else
- {
-#ifdef OSL_BIGENDIAN
- rXForm.eM11 = GetSwapFloat( rIn );
- rXForm.eM12 = GetSwapFloat( rIn );
- rXForm.eM21 = GetSwapFloat( rIn );
- rXForm.eM22 = GetSwapFloat( rIn );
- rXForm.eDx = GetSwapFloat( rIn );
- rXForm.eDy = GetSwapFloat( rIn );
-#else
- rIn >> rXForm.eM11 >> rXForm.eM12 >> rXForm.eM21 >> rXForm.eM22
- >> rXForm.eDx >> rXForm.eDy;
-#endif
- }
- return rIn;
- }
- };
-
- // EMF+
- typedef struct {
- XForm aWorldTransform;
- OutDevState aDevState;
- } EmfPlusGraphicState;
-
- typedef ::std::map<int,EmfPlusGraphicState> GraphicStateMap;
-
- class ImplRenderer : public virtual Renderer, protected CanvasGraphicHelper
- {
- public:
- ImplRenderer( const CanvasSharedPtr& rCanvas,
- const GDIMetaFile& rMtf,
- const Parameters& rParms );
-
- virtual ~ImplRenderer();
-
- virtual bool draw() const;
- virtual bool drawSubset( sal_Int32 nStartIndex,
- sal_Int32 nEndIndex ) const;
- virtual ::basegfx::B2DRange getSubsetArea( sal_Int32 nStartIndex,
- sal_Int32 nEndIndex ) const;
-
-
- // element of the Renderer's action vector. Need to be
- // public, since some functors need it, too.
- struct MtfAction
- {
- MtfAction( const ActionSharedPtr& rAction,
- sal_Int32 nOrigIndex ) :
- mpAction( rAction ),
- mnOrigIndex( nOrigIndex )
- {
- }
-
- ActionSharedPtr mpAction;
- sal_Int32 mnOrigIndex;
- };
-
- // prefetched and prepared canvas actions
- // (externally not visible)
- typedef ::std::vector< MtfAction > ActionVector;
-
- /* EMF+ */
- void ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed = false);
- void ReadPoint (SvStream& s, float& x, float& y, sal_uInt32 flags);
- void MapToDevice (double &x, double &y);
- ::basegfx::B2DPoint Map (double ix, double iy);
- ::basegfx::B2DSize MapSize (double iwidth, double iheight);
- void GraphicStatePush (GraphicStateMap& map, sal_Int32 index, OutDevState& rState);
- void GraphicStatePop (GraphicStateMap& map, sal_Int32 index, OutDevState& rState);
-
- private:
- // default: disabled copy/assignment
- ImplRenderer(const ImplRenderer&);
- ImplRenderer& operator=( const ImplRenderer& );
-
- void updateClipping( const ::basegfx::B2DPolyPolygon& rClipPoly,
- const ActionFactoryParameters& rParms,
- bool bIntersect );
-
- void updateClipping( const ::Rectangle& rClipRect,
- const ActionFactoryParameters& rParms,
- bool bIntersect );
-
- ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvasFont > createFont( double& o_rFontRotation,
- const ::Font& rFont,
- const ActionFactoryParameters& rParms ) const;
- bool createActions( GDIMetaFile& rMtf,
- const ActionFactoryParameters& rParms,
- bool bSubsettableActions );
- bool createFillAndStroke( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const ActionFactoryParameters& rParms );
- bool createFillAndStroke( const ::basegfx::B2DPolygon& rPoly,
- const ActionFactoryParameters& rParms );
- void skipContent( GDIMetaFile& rMtf,
- const char* pCommentString,
- sal_Int32& io_rCurrActionIndex ) const;
-
- bool isActionContained( GDIMetaFile& rMtf,
- const char* pCommentString,
- sal_uInt16 nType ) const;
-
- void createGradientAction( const ::PolyPolygon& rPoly,
- const ::Gradient& rGradient,
- const ActionFactoryParameters& rParms,
- bool bIsPolygonRectangle,
- bool bSubsettableActions );
-
- void createTextAction( const ::Point& rStartPoint,
- const OUString rString,
- int nIndex,
- int nLength,
- const sal_Int32* pCharWidths,
- const ActionFactoryParameters& rParms,
- bool bSubsettable );
-
- bool getSubsetIndices( sal_Int32& io_rStartIndex,
- sal_Int32& io_rEndIndex,
- ActionVector::const_iterator& o_rRangeBegin,
- ActionVector::const_iterator& o_rRangeEnd ) const;
-
- void processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, sal_Bool bUseWholeStream = sal_False);
-
- /* EMF+ */
- void processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms, OutDevState& rState, const CanvasSharedPtr& rCanvas );
- double setFont( sal_uInt8 objectId, const ActionFactoryParameters& rParms, OutDevState& rState );
- void EMFPPlusDrawPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms, OutDevState& rState, const CanvasSharedPtr& rCanvas, sal_uInt32 penIndex);
- void EMFPPlusFillPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms, OutDevState& rState, const CanvasSharedPtr& rCanvas, bool isColor, sal_uInt32 brushIndexOrColor);
-
- ActionVector maActions;
-
- /* EMF+ */
- XForm aBaseTransform;
- XForm aWorldTransform;
- EMFPObject* aObjects [256];
- float fPageScale;
- sal_Int32 nOriginX;
- sal_Int32 nOriginY;
- sal_Int32 nHDPI;
- sal_Int32 nVDPI;
- /* EMF+ emf header info */
- sal_Int32 nFrameLeft;
- sal_Int32 nFrameTop;
- sal_Int32 nFrameRight;
- sal_Int32 nFrameBottom;
- sal_Int32 nPixX;
- sal_Int32 nPixY;
- sal_Int32 nMmX;
- sal_Int32 nMmY;
- /* multipart object data */
- bool mbMultipart;
- sal_uInt16 mMFlags;
- SvMemoryStream mMStream;
- /* emf+ graphic state stack */
- GraphicStateMap mGSStack;
- GraphicStateMap mGSContainerStack;
- };
-
-
- /// Common parameters when creating actions
- struct ActionFactoryParameters
- {
- ActionFactoryParameters( VectorOfOutDevStates& rStates,
- const CanvasSharedPtr& rCanvas,
- ::VirtualDevice& rVDev,
- const Renderer::Parameters& rParms,
- sal_Int32& io_rCurrActionIndex ) :
- mrStates(rStates),
- mrCanvas(rCanvas),
- mrVDev(rVDev),
- mrParms(rParms),
- mrCurrActionIndex(io_rCurrActionIndex)
- {}
-
- VectorOfOutDevStates& mrStates;
- const CanvasSharedPtr& mrCanvas;
- ::VirtualDevice& mrVDev;
- const Renderer::Parameters& mrParms;
- sal_Int32& mrCurrActionIndex;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLRENDERER_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/inc/outdevstate.hxx b/cppcanvas/source/inc/outdevstate.hxx
deleted file mode 100644
index 26e10263a369..000000000000
--- a/cppcanvas/source/inc/outdevstate.hxx
+++ /dev/null
@@ -1,126 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_OUTDEVSTATE_HXX
-#define _CPPCANVAS_OUTDEVSTATE_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <com/sun/star/rendering/StringContext.hpp>
-#include <com/sun/star/rendering/RenderState.hpp>
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#include <com/sun/star/rendering/XCanvasFont.hpp>
-#include <com/sun/star/rendering/TextDirection.hpp>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <vcl/fntstyle.hxx>
-#include <vcl/vclenum.hxx>
-#include <vcl/outdev.hxx>
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState
- {
- OutDevState() :
- clip(),
- clipRect(),
- xClipPoly(),
-
- lineColor(),
- fillColor(),
- textColor(),
- textFillColor(),
- textLineColor(),
-
- xFont(),
- transform(),
- mapModeTransform(),
- fontRotation(0.0),
-
- textEmphasisMarkStyle(EMPHASISMARK_NONE),
- pushFlags(PUSH_ALL),
- textDirection(::com::sun::star::rendering::TextDirection::WEAK_LEFT_TO_RIGHT),
- textAlignment(0), // TODO(Q2): Synchronize with implrenderer
- // and possibly new rendering::TextAlignment
- textReliefStyle(RELIEF_NONE),
- textOverlineStyle(UNDERLINE_NONE),
- textUnderlineStyle(UNDERLINE_NONE),
- textStrikeoutStyle(STRIKEOUT_NONE),
- textReferencePoint(ALIGN_BASELINE),
-
- isTextOutlineModeSet( false ),
- isTextEffectShadowSet( false ),
- isTextWordUnderlineSet( false ),
-
- isLineColorSet( false ),
- isFillColorSet( false ),
- isTextFillColorSet( false ),
- isTextLineColorSet( false )
- {
- }
-
- ::basegfx::B2DPolyPolygon clip;
- ::Rectangle clipRect;
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > xClipPoly;
-
- ::com::sun::star::uno::Sequence< double > lineColor;
- ::com::sun::star::uno::Sequence< double > fillColor;
- ::com::sun::star::uno::Sequence< double > textColor;
- ::com::sun::star::uno::Sequence< double > textFillColor;
- ::com::sun::star::uno::Sequence< double > textLineColor;
-
- /** Current font.
-
- @attention Beware, this member can be NULL, and
- nevertheless text output is generated.
- */
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > xFont;
- ::basegfx::B2DHomMatrix transform;
- ::basegfx::B2DHomMatrix mapModeTransform;
- double fontRotation;
-
- sal_uInt16 textEmphasisMarkStyle;
- sal_uInt16 pushFlags;
- sal_Int8 textDirection;
- sal_Int8 textAlignment;
- sal_Int8 textReliefStyle;
- sal_Int8 textOverlineStyle;
- sal_Int8 textUnderlineStyle;
- sal_Int8 textStrikeoutStyle;
- TextAlign textReferencePoint;
-
- bool isTextOutlineModeSet;
- bool isTextEffectShadowSet;
- bool isTextWordUnderlineSet;
-
- bool isLineColorSet;
- bool isFillColorSet;
- bool isTextFillColorSet;
- bool isTextLineColorSet;
- };
- }
-}
-
-#endif /* _CPPCANVAS_OUTDEVSTATE_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/inc/tools.hxx b/cppcanvas/source/inc/tools.hxx
deleted file mode 100644
index f1d60ed8b159..000000000000
--- a/cppcanvas/source/inc/tools.hxx
+++ /dev/null
@@ -1,50 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_TOOLS_HXX
-#define _CPPCANVAS_TOOLS_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <cppcanvas/color.hxx>
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- class XGraphicDevice;
-} } } }
-
-
-namespace cppcanvas
-{
- namespace tools
- {
- ::com::sun::star::uno::Sequence< double >
- intSRGBAToDoubleSequence( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >&,
- Color::IntSRGBA );
-
- Color::IntSRGBA doubleSequenceToIntSRGBA( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice,
- const ::com::sun::star::uno::Sequence< double >& rColor );
- }
-}
-
-#endif /* _CPPCANVAS_TOOLS_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/bitmapaction.cxx b/cppcanvas/source/mtfrenderer/bitmapaction.cxx
deleted file mode 100644
index d3b61fa1d4a4..000000000000
--- a/cppcanvas/source/mtfrenderer/bitmapaction.cxx
+++ /dev/null
@@ -1,229 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <com/sun/star/rendering/XBitmap.hpp>
-#include <com/sun/star/rendering/RepaintResult.hpp>
-#include <com/sun/star/rendering/XCachedPrimitive.hpp>
-#include <vcl/bitmapex.hxx>
-#include <tools/gen.hxx>
-#include <vcl/canvastools.hxx>
-#include <canvas/canvastools.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <boost/utility.hpp>
-#include "cachedprimitivebase.hxx"
-#include "bitmapaction.hxx"
-#include "outdevstate.hxx"
-#include "mtftools.hxx"
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- namespace
- {
-
- class BitmapAction : public CachedPrimitiveBase
- {
- public:
- BitmapAction( const ::BitmapEx&,
- const ::basegfx::B2DPoint& rDstPoint,
- const CanvasSharedPtr&,
- const OutDevState& );
- BitmapAction( const ::BitmapEx&,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- using Action::render;
- virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const;
-
- uno::Reference< rendering::XBitmap > mxBitmap;
- CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- };
-
-
- BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
- const ::basegfx::B2DPoint& rDstPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- CachedPrimitiveBase( rCanvas, true ),
- mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
- rBmpEx ) ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
-
- // Setup transformation such that the next render call is
- // moved rPoint away.
- const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createTranslateB2DHomMatrix(rDstPoint));
- ::canvas::tools::appendToRenderState( maState,
- aLocalTransformation );
-
- // correct clip (which is relative to original transform)
- tools::modifyClip( maState,
- rState,
- rCanvas,
- rDstPoint,
- NULL,
- NULL );
- }
-
- BitmapAction::BitmapAction( const ::BitmapEx& rBmpEx,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- CachedPrimitiveBase( rCanvas, true ),
- mxBitmap( ::vcl::unotools::xBitmapFromBitmapEx( rCanvas->getUNOCanvas()->getDevice(),
- rBmpEx ) ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
-
- // Setup transformation such that the next render call is
- // moved rPoint away, and scaled according to the ratio
- // given by src and dst size.
- const ::Size aBmpSize( rBmpEx.GetSizePixel() );
-
- const ::basegfx::B2DVector aScale( rDstSize.getX() / aBmpSize.Width(),
- rDstSize.getY() / aBmpSize.Height() );
- const basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createScaleTranslateB2DHomMatrix(
- aScale, rDstPoint));
- ::canvas::tools::appendToRenderState( maState, aLocalTransformation );
-
- // correct clip (which is relative to original transform)
- tools::modifyClip( maState,
- rState,
- rCanvas,
- rDstPoint,
- &aScale,
- NULL );
- }
-
- bool BitmapAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::BitmapAction::renderPrimitive()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::BitmapAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- rCachedPrimitive = mpCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
- mpCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- bool BitmapAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // bitmap only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return CachedPrimitiveBase::render( rTransformation );
- }
-
- ::basegfx::B2DRange BitmapAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- const geometry::IntegerSize2D aSize( mxBitmap->getSize() );
-
- return tools::calcDevicePixelBounds( ::basegfx::B2DRange( 0,0,
- aSize.Width,
- aSize.Height ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange BitmapAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // bitmap only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 BitmapAction::getActionCount() const
- {
- return 1;
- }
- }
-
- ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx& rBmpEx,
- const ::basegfx::B2DPoint& rDstPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- return ActionSharedPtr( new BitmapAction(rBmpEx,
- rDstPoint,
- rCanvas,
- rState ) );
- }
-
- ActionSharedPtr BitmapActionFactory::createBitmapAction( const ::BitmapEx& rBmpEx,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- return ActionSharedPtr( new BitmapAction(rBmpEx,
- rDstPoint,
- rDstSize,
- rCanvas,
- rState ) );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/bitmapaction.hxx b/cppcanvas/source/mtfrenderer/bitmapaction.hxx
deleted file mode 100644
index f96074795f37..000000000000
--- a/cppcanvas/source/mtfrenderer/bitmapaction.hxx
+++ /dev/null
@@ -1,75 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_BITMAPACTION_HXX
-#define _CPPCANVAS_BITMAPACTION_HXX
-
-#include <cppcanvas/canvas.hxx>
-#include <action.hxx>
-
-namespace basegfx {
- class B2DPoint;
- class B2DVector;
-}
-class BitmapEx;
-
-/* Definition of internal::BitmapActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- /** Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class BitmapActionFactory
- {
- public:
- /// Unscaled bitmap action, only references destination point
- static ActionSharedPtr createBitmapAction( const ::BitmapEx&,
- const ::basegfx::B2DPoint& rDstPoint,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- /// Scaled bitmap action, dest point and dest size
- static ActionSharedPtr createBitmapAction( const ::BitmapEx&,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- private:
- // static factory, disable big four
- BitmapActionFactory();
- ~BitmapActionFactory();
- BitmapActionFactory(const BitmapActionFactory&);
- BitmapActionFactory& operator=( const BitmapActionFactory& );
- };
- }
-}
-
-#endif /*_CPPCANVAS_BITMAPACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/cachedprimitivebase.cxx b/cppcanvas/source/mtfrenderer/cachedprimitivebase.cxx
deleted file mode 100644
index 02de8589db73..000000000000
--- a/cppcanvas/source/mtfrenderer/cachedprimitivebase.cxx
+++ /dev/null
@@ -1,84 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-
-#include <com/sun/star/rendering/RepaintResult.hpp>
-
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <canvas/canvastools.hxx>
-#include <cppcanvas/canvas.hxx>
-
-#include "cachedprimitivebase.hxx"
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- CachedPrimitiveBase::CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
- bool bOnlyRedrawWithSameTransform ) :
- mpCanvas( rCanvas ),
- mxCachedPrimitive(),
- maLastTransformation(),
- mbOnlyRedrawWithSameTransform( bOnlyRedrawWithSameTransform )
- {
- // TODO(F2): also store last view transform, and refuse to
- // redraw if changed.
- }
-
- bool CachedPrimitiveBase::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::CachedPrimitiveBase::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::CachedPrimitiveBase: 0x" << std::hex << this );
-
- const rendering::ViewState& rViewState( mpCanvas->getViewState() );
- ::basegfx::B2DHomMatrix aTotalTransform;
-
- ::canvas::tools::getViewStateTransform( aTotalTransform,
- rViewState );
- aTotalTransform *= rTransformation;
-
- // can we use the cached primitive? For that, it must be
- // present in the first place, and, if
- // mbOnlyRedrawWithSameTransform is true, the overall
- // transformation must be the same.
- if( mxCachedPrimitive.is() &&
- (!mbOnlyRedrawWithSameTransform ||
- maLastTransformation == aTotalTransform) )
- {
- if( mxCachedPrimitive->redraw( rViewState ) ==
- rendering::RepaintResult::REDRAWN )
- {
- // cached repaint succeeded, done.
- return true;
- }
- }
-
- maLastTransformation = aTotalTransform;
-
- // delegate rendering to derived classes
- return renderPrimitive( mxCachedPrimitive,
- rTransformation );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/cachedprimitivebase.hxx b/cppcanvas/source/mtfrenderer/cachedprimitivebase.hxx
deleted file mode 100644
index e7b4248473eb..000000000000
--- a/cppcanvas/source/mtfrenderer/cachedprimitivebase.hxx
+++ /dev/null
@@ -1,89 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_CACHEDPRIMITIVEBASE_HXX
-#define _CPPCANVAS_CACHEDPRIMITIVEBASE_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/rendering/XCanvas.hpp>
-
-#include <cppcanvas/canvas.hxx>
-#include <boost/utility.hpp>
-
-#include "action.hxx"
-
-namespace basegfx { class B2DHomMatrix; }
-
-
-/* Definition of internal::CachedPrimitiveBase class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- /** Base class providing cached re-rendering, if XCanvas
- returns XCachedPrimitive
-
- Derive from this class and implement private render()
- method to perform the actual primitive rendering. Return
- cached primitive into given reference. Next time this
- class' public render() method gets called, the cached
- representation is taken.
- */
- class CachedPrimitiveBase : public Action,
- private ::boost::noncopyable
- {
- public:
- /** Constructor
-
- @param rCanvas
- Canvas on which this primitive is to appear
-
- @param bOnlyRedrawWithSameTransform
- When true, this class only reuses the cached
- primitive, if the overall transformation stays the
- same. Otherwise, repaints are always performed via the
- cached primitive.
- */
- CachedPrimitiveBase( const CanvasSharedPtr& rCanvas,
- bool bOnlyRedrawWithSameTransform );
- virtual ~CachedPrimitiveBase() {}
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
-
- protected:
- using Action::render;
-
- private:
- virtual bool renderPrimitive( ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const = 0;
-
- CanvasSharedPtr mpCanvas;
- mutable ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCachedPrimitive > mxCachedPrimitive;
- mutable ::basegfx::B2DHomMatrix maLastTransformation;
- const bool mbOnlyRedrawWithSameTransform;
- };
- }
-}
-
-#endif /*_CPPCANVAS_CACHEDPRIMITIVEBASE_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
deleted file mode 100644
index 5685c49322d6..000000000000
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ /dev/null
@@ -1,1940 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <tools/stream.hxx>
-#include <vcl/metaact.hxx>
-#include <vcl/graphicfilter.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/tools/gradienttools.hxx>
-#include <basegfx/tools/tools.hxx>
-#include <basegfx/numeric/ftools.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <vcl/canvastools.hxx>
-#include <rtl/ustring.hxx>
-#include <sal/alloca.h>
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/TexturingMode.hpp>
-
-#include <bitmapaction.hxx>
-#include <implrenderer.hxx>
-#include <outdevstate.hxx>
-#include <polypolyaction.hxx>
-#include <textaction.hxx>
-#include <stdio.h>
-
-#define EmfPlusRecordTypeHeader 16385
-#define EmfPlusRecordTypeEndOfFile 16386
-#define EmfPlusRecordTypeGetDC 16388
-#define EmfPlusRecordTypeObject 16392
-#define EmfPlusRecordTypeFillRects 16394
-#define EmfPlusRecordTypeFillPolygon 16396
-#define EmfPlusRecordTypeDrawLines 16397
-#define EmfPlusRecordTypeFillEllipse 16398
-#define EmfPlusRecordTypeDrawEllipse 16399
-#define EmfPlusRecordTypeFillPie 16400
-#define EmfPlusRecordTypeFillPath 16404
-#define EmfPlusRecordTypeDrawPath 16405
-#define EmfPlusRecordTypeDrawImage 16410
-#define EmfPlusRecordTypeDrawImagePoints 16411
-#define EmfPlusRecordTypeDrawString 16412
-#define EmfPlusRecordTypeSetRenderingOrigin 16413
-#define EmfPlusRecordTypeSetAntiAliasMode 16414
-#define EmfPlusRecordTypeSetTextRenderingHint 16415
-#define EmfPlusRecordTypeSetInterpolationMode 16417
-#define EmfPlusRecordTypeSetPixelOffsetMode 16418
-#define EmfPlusRecordTypeSetCompositingQuality 16420
-#define EmfPlusRecordTypeSave 16421
-#define EmfPlusRecordTypeRestore 16422
-#define EmfPlusRecordTypeBeginContainerNoParams 16424
-#define EmfPlusRecordTypeEndContainer 16425
-#define EmfPlusRecordTypeSetWorldTransform 16426
-#define EmfPlusRecordTypeResetWorldTransform 16427
-#define EmfPlusRecordTypeMultiplyWorldTransform 16428
-#define EmfPlusRecordTypeSetPageTransform 16432
-#define EmfPlusRecordTypeSetClipRect 16434
-#define EmfPlusRecordTypeSetClipPath 16435
-#define EmfPlusRecordTypeSetClipRegion 16436
-#define EmfPlusRecordTypeDrawDriverString 16438
-
-#define EmfPlusObjectTypeBrush 0x100
-#define EmfPlusObjectTypePen 0x200
-#define EmfPlusObjectTypePath 0x300
-#define EmfPlusObjectTypeRegion 0x400
-#define EmfPlusObjectTypeImage 0x500
-#define EmfPlusObjectTypeFont 0x600
-
-#define EmfPlusRegionInitialStateInfinite 0x10000003
-
-using namespace ::com::sun::star;
-using namespace ::basegfx;
-
-namespace cppcanvas
-{
- namespace internal
- {
-
-#if OSL_DEBUG_LEVEL > 1
- void dumpWords (SvStream& s, int i)
- {
- sal_uInt32 pos = s.Tell ();
- sal_Int16 data;
- SAL_INFO ("cppcanvas.emf", "EMF+ dumping words");
- for (; i > 0; i --) {
- s >> data;
- SAL_INFO ("cppcanvas.emf", "EMF+\tdata: " << std::hex << data << std::dec);
- }
- SAL_INFO ("cppcanvas.emf", "EMF+ end dumping words");
- s.Seek (pos);
- }
-#endif
-
- struct EMFPPath : public EMFPObject
- {
- ::basegfx::B2DPolyPolygon aPolygon;
- sal_Int32 nPoints;
- float* pPoints;
- sal_uInt8* pPointTypes;
-
- public:
- EMFPPath (sal_Int32 _nPoints, bool bLines = false)
- {
- if( _nPoints<0 || sal_uInt32(_nPoints)>SAL_MAX_INT32/(2*sizeof(float)) )
- _nPoints = SAL_MAX_INT32/(2*sizeof(float));
- nPoints = _nPoints;
- pPoints = new float [nPoints*2];
- if (!bLines)
- pPointTypes = new sal_uInt8 [_nPoints];
- else
- pPointTypes = NULL;
- }
-
- ~EMFPPath ()
- {
- delete [] pPoints;
- delete [] pPointTypes;
- }
-
- // TODO: remove rR argument when debug code is not longer needed
- void Read (SvStream& s, sal_uInt32 pathFlags, ImplRenderer& rR)
- {
- for (int i = 0; i < nPoints; i ++) {
- if (pathFlags & 0x4000) {
- // points are stored in short 16bit integer format
- sal_uInt16 x, y;
-
- s >> x >> y;
- SAL_INFO ("cppcanvas.emf", "EMF+\tpoint [x,y]: " << x << "," << y);
- pPoints [i*2] = x;
- pPoints [i*2 + 1] = y;
- } else {
- // points are stored in Single (float) format
- s >> pPoints [i*2] >> pPoints [i*2 + 1];
- SAL_INFO ("cppcanvas.emf", "EMF+\tpoint [x,y]: " << pPoints [i*2] << "," << pPoints [i*2 + 1]);
- }
- }
-
- if (pPointTypes)
- for (int i = 0; i < nPoints; i ++) {
- s >> pPointTypes [i];
- SAL_INFO ("cppcanvas.emf", "EMF+\tpoint type: " << (int)pPointTypes [i]);
- }
-
- aPolygon.clear ();
-
-#if OSL_DEBUG_LEVEL > 1
- const ::basegfx::B2DRectangle aBounds (::basegfx::tools::getRange (GetPolygon (rR)));
-
- SAL_INFO ("cppcanvas.emf",
- "EMF+\tpolygon bounding box: " << aBounds.getMinX () << "," << aBounds.getMinY () << aBounds.getWidth () << "x" << aBounds.getHeight () << " (mapped)");
-#else
- (void) rR; // avoid warnings
-#endif
- }
-
- ::basegfx::B2DPolyPolygon& GetPolygon (ImplRenderer& rR, bool bMapIt = true)
- {
- ::basegfx::B2DPolygon polygon;
-
- aPolygon.clear ();
-
- int last_normal = 0, p = 0;
- ::basegfx::B2DPoint prev, mapped;
- bool hasPrev = false;
- for (int i = 0; i < nPoints; i ++) {
- if (p && pPointTypes && (pPointTypes [i] == 0)) {
- aPolygon.append (polygon);
- last_normal = i;
- p = 0;
- polygon.clear ();
- }
-
- if (bMapIt)
- mapped = rR.Map (pPoints [i*2], pPoints [i*2 + 1]);
- else
- mapped = ::basegfx::B2DPoint (pPoints [i*2], pPoints [i*2 + 1]);
- if (pPointTypes) {
- if ((pPointTypes [i] & 0x07) == 3) {
- if (((i - last_normal )% 3) == 1) {
- polygon.setNextControlPoint (p - 1, mapped);
- SAL_INFO ("cppcanvas.emf", "polygon append next: " << p - 1 << " mapped: " << mapped.getX () << "," << mapped.getY ());
- continue;
- } else if (((i - last_normal) % 3) == 2) {
- prev = mapped;
- hasPrev = true;
- continue;
- }
- } else
- last_normal = i;
- }
- polygon.append (mapped);
- SAL_INFO ("cppcanvas.emf", "polygon append point: " << pPoints [i*2] << "," << pPoints [i*2 + 1] << " mapped: " << mapped.getX () << ":" << mapped.getY ());
- if (hasPrev) {
- polygon.setPrevControlPoint (p, prev);
- SAL_INFO ("cppcanvas.emf", "polygon append prev: " << p << " mapped: " << prev.getX () << "," << prev.getY ());
- hasPrev = false;
- }
- p ++;
- if (pPointTypes && (pPointTypes [i] & 0x80)) { // closed polygon
- polygon.setClosed (true);
- aPolygon.append (polygon);
- SAL_INFO ("cppcanvas.emf", "close polygon");
- last_normal = i + 1;
- p = 0;
- polygon.clear ();
- }
- }
-
- if (polygon.count ()) {
- aPolygon.append (polygon);
-
-#if OSL_DEBUG_LEVEL > 1
- for (unsigned int i=0; i<aPolygon.count(); i++) {
- polygon = aPolygon.getB2DPolygon(i);
- SAL_INFO ("cppcanvas.emf", "polygon: " << i);
- for (unsigned int j=0; j<polygon.count(); j++) {
- ::basegfx::B2DPoint point = polygon.getB2DPoint(j);
- SAL_INFO ("cppcanvas.emf", "point: " << point.getX() << "," << point.getY());
- if (polygon.isPrevControlPointUsed(j)) {
- point = polygon.getPrevControlPoint(j);
- SAL_INFO ("cppcanvas.emf", "prev: " << point.getX() << "," << point.getY());
- }
- if (polygon.isNextControlPointUsed(j)) {
- point = polygon.getNextControlPoint(j);
- SAL_INFO ("cppcanvas.emf", "next: " << point.getX() << "," << point.getY());
- }
- }
- }
-#endif
- }
-
- return aPolygon;
- }
- };
-
- struct EMFPRegion : public EMFPObject
- {
- sal_Int32 parts;
- sal_Int32 *combineMode;
- sal_Int32 initialState;
- EMFPPath *initialPath;
- float ix, iy, iw, ih;
-
- EMFPRegion ()
- {
- combineMode = NULL;
- initialPath = NULL;
- }
-
- ~EMFPRegion ()
- {
- if (combineMode) {
- delete [] combineMode;
- combineMode = NULL;
- }
- if (initialPath) {
- delete initialPath;
- initialPath = NULL;
- }
- }
-
- void Read (SvStream& s)
- {
- sal_uInt32 header;
-
- s >> header >> parts;
-
- SAL_INFO ("cppcanvas.emf", "EMF+\tregion");
- SAL_INFO ("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " parts: " << parts << std::dec );
-
- if (parts) {
- if( parts<0 || sal_uInt32(parts)>SAL_MAX_INT32/sizeof(sal_Int32) )
- parts = SAL_MAX_INT32/sizeof(sal_Int32);
-
- combineMode = new sal_Int32 [parts];
-
- for (int i = 0; i < parts; i ++) {
- s >> combineMode [i];
- SAL_INFO ("cppcanvas.emf", "EMF+\tcombine mode [" << i << "]: 0x" << std::hex << combineMode [i] << std::dec);
- }
- }
-
- s >> initialState;
- SAL_INFO ("cppcanvas.emf", "EMF+\tinitial state: 0x" << std::hex << initialState << std::dec);
- }
- };
-
- struct EMFPBrush : public EMFPObject
- {
- ::Color solidColor;
- sal_uInt32 type;
- sal_uInt32 additionalFlags;
-
- /* linear gradient */
- sal_Int32 wrapMode;
- float areaX, areaY, areaWidth, areaHeight;
- ::Color secondColor; // first color is stored in solidColor;
- XForm transformation;
- bool hasTransformation;
- sal_Int32 blendPoints;
- float* blendPositions;
- float* blendFactors;
- sal_Int32 colorblendPoints;
- float* colorblendPositions;
- ::Color* colorblendColors;
- sal_Int32 surroundColorsNumber;
- ::Color* surroundColors;
- EMFPPath *path;
-
- public:
- EMFPBrush ()
- {
- blendPositions = NULL;
- colorblendPositions = NULL;
- colorblendColors = NULL;
- surroundColors = NULL;
- path = NULL;
- hasTransformation = false;
- }
-
- ~EMFPBrush ()
- {
- if (blendPositions != NULL) {
- delete[] blendPositions;
- blendPositions = NULL;
- }
- if (colorblendPositions != NULL) {
- delete[] colorblendPositions;
- colorblendPositions = NULL;
- }
- if (colorblendColors != NULL) {
- delete[] colorblendColors;
- colorblendColors = NULL;
- }
- if (surroundColors != NULL) {
- delete[] surroundColors;
- surroundColors = NULL;
- }
- if (path) {
- delete path;
- path = NULL;
- }
- }
-
- sal_uInt32 GetType() const { return type; }
- const ::Color& GetColor() const { return solidColor; }
-
- void Read (SvStream& s, ImplRenderer& rR)
- {
- sal_uInt32 header;
-
- s >> header >> type;
-
- SAL_INFO ("cppcanvas.emf", "EMF+\tbrush");
- SAL_INFO ("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " type: " << type << std::dec);
-
- switch (type) {
- case 0:
- {
- sal_uInt32 color;
-
- s >> color;
- solidColor = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO ("cppcanvas.emf", "EMF+\tsolid color: 0x" << std::hex << color << std::dec);
-
- break;
- }
- // path gradient
- case 3:
- {
- s >> additionalFlags >> wrapMode;
-
- SAL_INFO ("cppcanvas.emf", "EMF+\tpath gradient, additional flags: 0x" << std::hex << additionalFlags << std::dec);
-
- sal_uInt32 color;
-
- s >> color;
- solidColor = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO("cppcanvas.emf", "EMF+\tcenter color: 0x" << std::hex << color << std::dec);
-
- s >> areaX >> areaY;
- SAL_INFO("cppcanvas.emf", "EMF+\tcenter point: " << areaX << "," << areaY);
-
- s >> surroundColorsNumber;
- SAL_INFO("cppcanvas.emf", "EMF+\tsurround colors: " << surroundColorsNumber);
-
- if( surroundColorsNumber<0 || sal_uInt32(surroundColorsNumber)>SAL_MAX_INT32/sizeof(::Color) )
- surroundColorsNumber = SAL_MAX_INT32/sizeof(::Color);
-
- surroundColors = new ::Color [surroundColorsNumber];
- for (int i = 0; i < surroundColorsNumber; i++) {
- s >> color;
- surroundColors[i] = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- if (i == 0)
- secondColor = surroundColors [0];
- SAL_INFO("cppcanvas.emf", "EMF+\tsurround color[" << i << "]: 0x" << std::hex << color << std::dec);
- }
-
- if (additionalFlags & 0x01) {
- sal_Int32 pathLength;
-
- s >> pathLength;
- SAL_INFO("cppcanvas.emf", "EMF+\tpath length: " << pathLength);
-
- sal_uInt32 pos = s.Tell ();
-#if OSL_DEBUG_LEVEL > 1
- dumpWords (s, 32);
-#endif
-
- sal_uInt32 pathHeader;
- sal_Int32 pathPoints, pathFlags;
- s >> pathHeader >> pathPoints >> pathFlags;
-
- SAL_INFO("cppcanvas.emf", "EMF+\tpath (brush path gradient)");
- SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << pathHeader << " points: " << std::dec << pathPoints << " additional flags: 0x" << std::hex << pathFlags << std::dec );
-
- path = new EMFPPath (pathPoints);
- path->Read (s, pathFlags, rR);
-
- s.Seek (pos + pathLength);
-
- const ::basegfx::B2DRectangle aBounds (::basegfx::tools::getRange (path->GetPolygon (rR, false)));
- areaWidth = aBounds.getWidth ();
- areaHeight = aBounds.getHeight ();
-
- SAL_INFO("cppcanvas.emf", "EMF+\tpolygon bounding box: " << aBounds.getMinX () << "," << aBounds.getMinY () << " " << aBounds.getWidth () << "x" << aBounds.getHeight ());
-
-
- if (additionalFlags & 0x02) {
- SAL_INFO("cppcanvas.emf", "EMF+\tuse transformation");
- s >> transformation;
- hasTransformation = true;
- SAL_INFO("cppcanvas.emf",
- "EMF+\tm11: " << transformation.eM11 << " m12: " << transformation.eM12 <<
- "\nEMF+\tm21: " << transformation.eM21 << " m22: " << transformation.eM22 <<
- "\nEMF+\tdx: " << transformation.eDx << " dy: " << transformation.eDy);
-
- }
- if (additionalFlags & 0x08) {
- s >> blendPoints;
- SAL_INFO("cppcanvas.emf", "EMF+\tuse blend, points: " << blendPoints);
- if( blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32/(2*sizeof(float)) )
- blendPoints = SAL_MAX_INT32/(2*sizeof(float));
- blendPositions = new float [2*blendPoints];
- blendFactors = blendPositions + blendPoints;
- for (int i=0; i < blendPoints; i ++) {
- s >> blendPositions [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions [i]);
- }
- for (int i=0; i < blendPoints; i ++) {
- s >> blendFactors [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tfactor[" << i << "]: " << blendFactors [i]);
- }
- }
-
- if (additionalFlags & 0x04) {
- s >> colorblendPoints;
- SAL_INFO("cppcanvas.emf", "EMF+\tuse color blend, points: " << colorblendPoints);
- if( colorblendPoints<0 || sal_uInt32(colorblendPoints)>SAL_MAX_INT32/sizeof(float) )
- colorblendPoints = SAL_MAX_INT32/sizeof(float);
- if( sal_uInt32(colorblendPoints)>SAL_MAX_INT32/sizeof(::Color) )
- colorblendPoints = SAL_MAX_INT32/sizeof(::Color);
- colorblendPositions = new float [colorblendPoints];
- colorblendColors = new ::Color [colorblendPoints];
- for (int i=0; i < colorblendPoints; i ++) {
- s >> colorblendPositions [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions [i]);
- }
- for (int i=0; i < colorblendPoints; i ++) {
- s >> color;
- colorblendColors [i] = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO("cppcanvas.emf", "EMF+\tcolor[" << i << "]: 0x" << std::hex << color << std::dec);
- }
- }
- } else {
-#if OSL_DEBUG_LEVEL > 1
- dumpWords (s, 1024);
-#endif
- }
- break;
- }
- // linear gradient
- case 4:
- {
- s >> additionalFlags >> wrapMode;
-
- SAL_INFO("cppcanvas.emf", "EMF+\tlinear gradient, additional flags: 0x" << std::hex << additionalFlags << std::dec);
-
- s >> areaX >> areaY >> areaWidth >> areaHeight;
-
- SAL_INFO("cppcanvas.emf", "EMF+\tarea: " << areaX << "," << areaY << " - " << areaWidth << "x" << areaHeight);
-
- sal_uInt32 color;
-
- s >> color;
- solidColor = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO("cppcanvas.emf", "EMF+\tfirst color: 0x" << std::hex << color << std::dec);
-
- s >> color;
- secondColor = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO("cppcanvas.emf", "EMF+\tsecond color: 0x" << std::hex << color << std::dec);
-
- // repeated colors, unknown meaning, see http://www.aces.uiuc.edu/~jhtodd/Metafile/MetafileRecords/ObjectBrush.html
- s >> color;
- s >> color;
-
- if (additionalFlags & 0x02) {
- SAL_INFO("cppcanvas.emf", "EMF+\tuse transformation");
- s >> transformation;
- hasTransformation = true;
- SAL_INFO("cppcanvas.emf",
- "EMF+\tm11: " << transformation.eM11 << " m12: " << transformation.eM12 <<
- "\nEMF+\tm21: " << transformation.eM21 << " m22: " << transformation.eM22 <<
- "\nEMF+\tdx: " << transformation.eDx << " dy: " << transformation.eDy);
- }
- if (additionalFlags & 0x08) {
- s >> blendPoints;
- SAL_INFO("cppcanvas.emf", "EMF+\tuse blend, points: " << blendPoints);
- if( blendPoints<0 || sal_uInt32(blendPoints)>SAL_MAX_INT32/(2*sizeof(float)) )
- blendPoints = SAL_MAX_INT32/(2*sizeof(float));
- blendPositions = new float [2*blendPoints];
- blendFactors = blendPositions + blendPoints;
- for (int i=0; i < blendPoints; i ++) {
- s >> blendPositions [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << blendPositions [i]);
- }
- for (int i=0; i < blendPoints; i ++) {
- s >> blendFactors [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tfactor[" << i << "]: " << blendFactors [i]);
- }
- }
-
- if (additionalFlags & 0x04) {
- s >> colorblendPoints;
- SAL_INFO("cppcanvas.emf", "EMF+\tuse color blend, points: " << colorblendPoints);
- if( colorblendPoints<0 || sal_uInt32(colorblendPoints)>SAL_MAX_INT32/sizeof(float) )
- colorblendPoints = SAL_MAX_INT32/sizeof(float);
- if( sal_uInt32(colorblendPoints)>SAL_MAX_INT32/sizeof(::Color) )
- colorblendPoints = sal_uInt32(SAL_MAX_INT32)/sizeof(::Color);
- colorblendPositions = new float [colorblendPoints];
- colorblendColors = new ::Color [colorblendPoints];
- for (int i=0; i < colorblendPoints; i ++) {
- s >> colorblendPositions [i];
- SAL_INFO("cppcanvas.emf", "EMF+\tposition[" << i << "]: " << colorblendPositions [i]);
- }
- for (int i=0; i < colorblendPoints; i ++) {
- s >> color;
- colorblendColors [i] = ::Color (0xff - (color >> 24), (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff);
- SAL_INFO("cppcanvas.emf", "EMF+\tcolor[" << i << "]: 0x" << std::hex << color << std::dec);
- }
- }
-
- break;
- }
- default:
- SAL_INFO("cppcanvas.emf", "EMF+\tunhandled brush type: " << std::hex << type << std::dec);
- }
- }
- };
-
- struct EMFPPen : public EMFPBrush
- {
- XForm transformation;
- float width;
- sal_Int32 startCap;
- sal_Int32 endCap;
- sal_Int32 lineJoin;
- float mitterLimit;
- sal_Int32 dashStyle;
- sal_Int32 dashCap;
- float dashOffset;
- sal_Int32 dashPatternLen;
- float *dashPattern;
- sal_Int32 alignment;
- sal_Int32 compoundArrayLen;
- float *compoundArray;
- sal_Int32 customStartCapLen;
- sal_uInt8 *customStartCap;
- sal_Int32 customEndCapLen;
- sal_uInt8 *customEndCap;
-
- public:
- EMFPPen () : EMFPBrush ()
- {
- dashPattern = NULL;
- compoundArray = NULL;
- customStartCap = NULL;
- customEndCap = NULL;
- }
-
- ~EMFPPen ()
- {
- delete[] dashPattern;
- delete[] compoundArray;
- delete[] customStartCap;
- delete[] customEndCap;
- }
-
- void SetStrokeAttributes (rendering::StrokeAttributes& rStrokeAttributes, ImplRenderer& rR, const OutDevState& rState)
- {
-#if OSL_DEBUG_LEVEL > 1
- if (width == 0.0) {
- SAL_INFO ("cppcanvas.emf", "TODO: pen with zero width - using minimal which might not be correct\n");
- }
-#endif
- rStrokeAttributes.StrokeWidth = (rState.mapModeTransform * rR.MapSize (width == 0.0 ? 0.05 : width, 0)).getX ();
- }
-
- void Read (SvStream& s, ImplRenderer& rR, sal_Int32, sal_Int32 )
- {
- sal_uInt32 header, unknown, penFlags, unknown2;
- int i;
-
- s >> header >> unknown >> penFlags >> unknown2 >> width;
-
- SAL_INFO("cppcanvas.emf", "EMF+\tpen");
- SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " unknown: 0x" << unknown <<
- " additional flags: 0x" << penFlags << " unknown: 0x" << unknown2 << " width: " << std::dec << width );
-
- if (penFlags & 1)
- s >> transformation;
-
- if (penFlags & 2)
- s >> startCap;
- else
- startCap = 0;
-
- if (penFlags & 4)
- s >> endCap;
- else
- endCap = 0;
-
- if (penFlags & 8)
- s >> lineJoin;
- else
- lineJoin = 0;
-
- if (penFlags & 16)
- s >> mitterLimit;
- else
- mitterLimit = 0;
-
- if (penFlags & 32)
- s >> dashStyle;
- else
- dashStyle = 0;
-
- if (penFlags & 64)
- s >> dashCap;
- else
- dashCap = 0;
-
- if (penFlags & 128)
- s >> dashOffset;
- else
- dashOffset = 0;
-
- if (penFlags & 256) {
- s >> dashPatternLen;
- if( dashPatternLen<0 || sal_uInt32(dashPatternLen)>SAL_MAX_INT32/sizeof(float) )
- dashPatternLen = SAL_MAX_INT32/sizeof(float);
- dashPattern = new float [dashPatternLen];
- for (i = 0; i < dashPatternLen; i++)
- s >> dashPattern [i];
- } else
- dashPatternLen = 0;
-
- if (penFlags & 512)
- s >> alignment;
- else
- alignment = 0;
-
- if (penFlags & 1024) {
- s >> compoundArrayLen;
- if( compoundArrayLen<0 || sal_uInt32(compoundArrayLen)>SAL_MAX_INT32/sizeof(float) )
- compoundArrayLen = SAL_MAX_INT32/sizeof(float);
- compoundArray = new float [compoundArrayLen];
- for (i = 0; i < compoundArrayLen; i++)
- s >> compoundArray [i];
- } else
- compoundArrayLen = 0;
-
- if (penFlags & 2048) {
- s >> customStartCapLen;
- if( customStartCapLen<0 )
- customStartCapLen=0;
- customStartCap = new sal_uInt8 [customStartCapLen];
- for (i = 0; i < customStartCapLen; i++)
- s >> customStartCap [i];
- } else
- customStartCapLen = 0;
-
- if (penFlags & 4096) {
- s >> customEndCapLen;
- if( customEndCapLen<0 )
- customEndCapLen=0;
- customEndCap = new sal_uInt8 [customEndCapLen];
- for (i = 0; i < customEndCapLen; i++)
- s >> customEndCap [i];
- } else
- customEndCapLen = 0;
-
- EMFPBrush::Read (s, rR);
- }
- };
-
- struct EMFPImage : public EMFPObject
- {
- sal_uInt32 type;
- sal_Int32 width;
- sal_Int32 height;
- sal_Int32 stride;
- sal_Int32 pixelFormat;
- Graphic graphic;
-
-
- void Read (SvMemoryStream &s, sal_uInt32 dataSize, sal_Bool bUseWholeStream)
- {
- sal_uInt32 header, unknown;
-
- s >> header >> type;
-
- SAL_INFO("cppcanvas.emf", "EMF+\timage\nEMF+\theader: 0x" << std::hex << header << " type: " << type << std::dec );
-
- if (type == 1) { // bitmap
- s >> width >> height >> stride >> pixelFormat >> unknown;
- SAL_INFO("cppcanvas.emf", "EMF+\tbitmap width: " << width << " height: " << height << " stride: " << "pixelFormat: 0x" << std::hex << pixelFormat << std::dec);
- if (width == 0) { // non native formats
- GraphicFilter filter;
-
- filter.ImportGraphic (graphic, OUString(), s);
- SAL_INFO("cppcanvas.emf", "EMF+\tbitmap width: " << graphic.GetBitmap().GetSizePixel().Width() << " height: " << graphic.GetBitmap().GetSizePixel().Height());
- }
-
- } else if (type == 2) {
- sal_Int32 mfType, mfSize;
-
- s >> mfType >> mfSize;
- SAL_INFO("cppcanvas.emf", "EMF+\tmetafile type: " << mfType << " dataSize: " << mfSize << " real size calculated from record dataSize: " << dataSize - 16);
-
- GraphicFilter filter;
- // workaround buggy metafiles, which have wrong mfSize set (n#705956 for example)
- SvMemoryStream mfStream (((char *)s.GetData()) + s.Tell(), bUseWholeStream ? s.remainingSize() : dataSize - 16, STREAM_READ);
-
- filter.ImportGraphic (graphic, OUString(), mfStream);
-
- // debug code - write the stream to debug file /tmp/emf-stream.emf
-#if OSL_DEBUG_LEVEL > 1
- mfStream.Seek(0);
- static sal_Int32 emfp_debug_stream_number = 0;
- OUString emfp_debug_filename("/tmp/emf-embedded-stream");
- emfp_debug_filename += OUString::number(emfp_debug_stream_number++);
- emfp_debug_filename += OUString(".emf");
-
- SvFileStream file( emfp_debug_filename, STREAM_WRITE | STREAM_TRUNC );
-
- mfStream >> file;
- file.Flush();
- file.Close();
-#endif
- }
- }
- };
-
- struct EMFPFont : public EMFPObject
- {
- sal_uInt32 version;
- float emSize;
- sal_uInt32 sizeUnit;
- sal_Int32 fontFlags;
- OUString family;
-
- void Read (SvMemoryStream &s)
- {
- sal_uInt32 header;
- sal_uInt32 reserved;
- sal_uInt32 length;
-
- s >> header >> emSize >> sizeUnit >> fontFlags >> reserved >> length;
-
- OSL_ASSERT( ( header >> 12 ) == 0xdbc01 );
-
- SAL_INFO("cppcanvas.emf", "EMF+\tfont\n"
- << "EMF+\theader: 0x" << std::hex << (header >> 12) << " version: 0x" << (header & 0x1fff) << " size: " << std::dec << emSize << " unit: 0x" << std::hex << sizeUnit << std::dec);
- SAL_INFO("cppcanvas.emf", "EMF+\tflags: 0x" << std::hex << fontFlags << " reserved: 0x" << reserved << " length: 0x" << std::hex << length << std::dec);
-
- if( length > 0 && length < 0x4000 ) {
- sal_Unicode *chars = (sal_Unicode *) alloca( sizeof( sal_Unicode ) * length );
-
- for( sal_uInt32 i = 0; i < length; i++ )
- s >> chars[ i ];
-
- family = OUString( chars, length );
- SAL_INFO("cppcanvas.emf", "EMF+\tfamily: " << OUStringToOString( family, RTL_TEXTENCODING_UTF8).getStr()); // TODO: can we just use family?
- }
- }
- };
-
- void ImplRenderer::ReadRectangle (SvStream& s, float& x, float& y, float &width, float& height, bool bCompressed)
- {
- if (bCompressed) {
- sal_Int16 ix, iy, iw, ih;
-
- s >> ix >> iy >> iw >> ih;
-
- x = ix;
- y = iy;
- width = iw;
- height = ih;
- } else
- s >> x >> y >> width >> height;
- }
-
- void ImplRenderer::ReadPoint (SvStream& s, float& x, float& y, sal_uInt32 flags)
- {
- if (flags & 0x4000) {
- sal_Int16 ix, iy;
-
- s >> ix >> iy;
-
- x = ix;
- y = iy;
- } else
- s >> x >> y;
- }
-
- void ImplRenderer::MapToDevice (double& x, double& y)
- {
- // TODO: other units
- x = 100*nMmX*x/nPixX;
- y = 100*nMmY*y/nPixY;
- }
-
- ::basegfx::B2DPoint ImplRenderer::Map (double ix, double iy)
- {
- double x, y;
-
- x = ix*aWorldTransform.eM11 + iy*aWorldTransform.eM21 + aWorldTransform.eDx;
- y = ix*aWorldTransform.eM12 + iy*aWorldTransform.eM22 + aWorldTransform.eDy;
-
- MapToDevice (x, y);
-
- x -= nFrameLeft;
- y -= nFrameTop;
-
- x *= aBaseTransform.eM11;
- y *= aBaseTransform.eM22;
-
- return ::basegfx::B2DPoint (x, y);
- }
-
- ::basegfx::B2DSize ImplRenderer::MapSize (double iwidth, double iheight)
- {
- double w, h;
-
- w = iwidth*aWorldTransform.eM11 + iheight*aWorldTransform.eM21;
- h = iwidth*aWorldTransform.eM12 + iheight*aWorldTransform.eM22;
-
- MapToDevice (w, h);
-
- w *= aBaseTransform.eM11;
- h *= aBaseTransform.eM22;
-
- return ::basegfx::B2DSize (w, h);
- }
-
-#define COLOR(x) \
- ::vcl::unotools::colorToDoubleSequence( ::Color (0xff - (x >> 24), \
- (x >> 16) & 0xff, \
- (x >> 8) & 0xff, \
- x & 0xff), \
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace());
-
- void ImplRenderer::EMFPPlusFillPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms,
- OutDevState& rState, const CanvasSharedPtr& rCanvas, bool isColor, sal_uInt32 brushIndexOrColor)
- {
- ::basegfx::B2DPolyPolygon localPolygon (polygon);
-
- SAL_INFO("cppcanvas.emf", "EMF+\tfill polygon");
-
- localPolygon.transform( rState.mapModeTransform );
-
- ActionSharedPtr pPolyAction;
-
- if (isColor) {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tcolor fill:0x" << std::hex << brushIndexOrColor << std::dec);
- rState.isFillColorSet = true;
- rState.isLineColorSet = false;
-
- rState.fillColor = COLOR(brushIndexOrColor);
-
- pPolyAction = ActionSharedPtr ( internal::PolyPolyActionFactory::createPolyPolyAction( localPolygon, rParms.mrCanvas, rState ) );
-
- } else {
- rState.isFillColorSet = true;
- // extract UseBrush
- EMFPBrush* brush = (EMFPBrush*) aObjects [brushIndexOrColor & 0xff];
- SAL_INFO("cppcanvas.emf", "EMF+\tbrush fill slot: " << brushIndexOrColor << " (type: " << brush->GetType () << ")");
-
- // give up in case something wrong happened
- if( !brush )
- return;
-
- rState.isFillColorSet = false;
- rState.isLineColorSet = false;
-
- if (brush->type == 3 || brush->type == 4) {
-
- if (brush->type == 3 && !(brush->additionalFlags & 0x1))
- return; // we are unable to parse these brushes yet
-
- ::basegfx::B2DHomMatrix aTextureTransformation;
- ::basegfx::B2DHomMatrix aWorldTransformation;
- ::basegfx::B2DHomMatrix aBaseTransformation;
- rendering::Texture aTexture;
-
- aWorldTransformation.set (0, 0, aWorldTransform.eM11);
- aWorldTransformation.set (0, 1, aWorldTransform.eM21);
- aWorldTransformation.set (0, 2, aWorldTransform.eDx);
- aWorldTransformation.set (1, 0, aWorldTransform.eM12);
- aWorldTransformation.set (1, 1, aWorldTransform.eM22);
- aWorldTransformation.set (1, 2, aWorldTransform.eDy);
-
- aBaseTransformation.set (0, 0, aBaseTransform.eM11);
- aBaseTransformation.set (0, 1, aBaseTransform.eM21);
- aBaseTransformation.set (0, 2, aBaseTransform.eDx);
- aBaseTransformation.set (1, 0, aBaseTransform.eM12);
- aBaseTransformation.set (1, 1, aBaseTransform.eM22);
- aBaseTransformation.set (1, 2, aBaseTransform.eDy);
-
- if (brush->type == 4) {
- aTextureTransformation.scale (brush->areaWidth, brush->areaHeight);
- aTextureTransformation.translate (brush->areaX, brush->areaY);
- } else {
- aTextureTransformation.translate (-0.5, -0.5);
- aTextureTransformation.scale (brush->areaWidth, brush->areaHeight);
- aTextureTransformation.translate (brush->areaX,brush->areaY);
- }
-
- if (brush->hasTransformation) {
- ::basegfx::B2DHomMatrix aTransformation;
-
- aTransformation.set (0, 0, brush->transformation.eM11);
- aTransformation.set (0, 1, brush->transformation.eM21);
- aTransformation.set (0, 2, brush->transformation.eDx);
- aTransformation.set (1, 0, brush->transformation.eM12);
- aTransformation.set (1, 1, brush->transformation.eM22);
- aTransformation.set (1, 2, brush->transformation.eDy);
-
- aTextureTransformation *= aTransformation;
- }
-
- aTextureTransformation *= aWorldTransformation;
- aTextureTransformation.scale (100.0*nMmX/nPixX, 100.0*nMmY/nPixY);
- aTextureTransformation.translate (-nFrameLeft, -nFrameTop);
- aTextureTransformation *= rState.mapModeTransform;
- aTextureTransformation *= aBaseTransformation;
-
- aTexture.RepeatModeX = rendering::TexturingMode::CLAMP;
- aTexture.RepeatModeY = rendering::TexturingMode::CLAMP;
- aTexture.Alpha = 1.0;
-
- basegfx::ODFGradientInfo aGradInfo;
- OUString aGradientService;
-
- const uno::Sequence< double > aStartColor(
- ::vcl::unotools::colorToDoubleSequence( brush->solidColor,
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() ) );
- const uno::Sequence< double > aEndColor(
- ::vcl::unotools::colorToDoubleSequence( brush->secondColor,
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() ) );
- uno::Sequence< uno::Sequence < double > > aColors (2);
- uno::Sequence< double > aStops (2);
-
- if (brush->blendPositions) {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tuse blend");
- aColors.realloc (brush->blendPoints);
- aStops.realloc (brush->blendPoints);
- int length = aStartColor.getLength ();
- uno::Sequence< double > aColor (length);
-
- OSL_ASSERT (length == aEndColor.getLength());
-
- for (int i = 0; i < brush->blendPoints; i++) {
- aStops[i] = brush->blendPositions [i];
-
- for (int j = 0; j < length; j++) {
- if (brush->type == 4) {
- aColor [j] = aStartColor [j]*(1 - brush->blendFactors[i]) + aEndColor [j]*brush->blendFactors[i];
- } else
- aColor [j] = aStartColor [j]*brush->blendFactors[i] + aEndColor [j]*(1 - brush->blendFactors[i]);
- }
-
- aColors[i] = aColor;
- }
- } else if (brush->colorblendPositions) {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tuse color blend");
- aColors.realloc (brush->colorblendPoints);
- aStops.realloc (brush->colorblendPoints);
-
- for (int i = 0; i < brush->colorblendPoints; i++) {
- aStops[i] = brush->colorblendPositions [i];
- aColors[(brush->type == 4) ? i : brush->colorblendPoints - 1 - i] = ::vcl::unotools::colorToDoubleSequence( brush->colorblendColors [i],
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
- }
- } else {
- aStops[0] = 0.0;
- aStops[1] = 1.0;
-
- if (brush->type == 4) {
- aColors[0] = aStartColor;
- aColors[1] = aEndColor;
- } else {
- aColors[1] = aStartColor;
- aColors[0] = aEndColor;
- }
- }
-
- SAL_INFO("cppcanvas.emf", "EMF+\t\tset gradient");
- basegfx::B2DRange aBoundsRectangle (0, 0, 1, 1);
- if (brush->type == 4) {
- aGradientService = "LinearGradient";
- aGradInfo = basegfx::tools::createLinearODFGradientInfo(
- aBoundsRectangle,
- aStops.getLength(),
- 0,
- 0);
-
- } else {
- aGradientService = "EllipticalGradient";
- aGradInfo = basegfx::tools::createEllipticalODFGradientInfo(
- aBoundsRectangle,
- ::basegfx::B2DVector( 0, 0 ),
- aStops.getLength(),
- 0,
- 0);
- }
-
- uno::Reference< lang::XMultiServiceFactory > xFactory(
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getParametricPolyPolygonFactory() );
-
- if( xFactory.is() ) {
- uno::Sequence<uno::Any> args( 3 );
- beans::PropertyValue aProp;
- aProp.Name = "Colors";
- aProp.Value <<= aColors;
- args[0] <<= aProp;
- aProp.Name = "Stops";
- aProp.Value <<= aStops;
- args[1] <<= aProp;
- aProp.Name = "AspectRatio";
- aProp.Value <<= static_cast<sal_Int32>(1);
- args[2] <<= aProp;
-
- aTexture.Gradient.set(
- xFactory->createInstanceWithArguments( aGradientService,
- args ),
- uno::UNO_QUERY);
- }
-
- ::basegfx::unotools::affineMatrixFromHomMatrix( aTexture.AffineTransform,
- aTextureTransformation );
-
- if( aTexture.Gradient.is() )
- pPolyAction =
- ActionSharedPtr ( internal::PolyPolyActionFactory::createPolyPolyAction( localPolygon,
- rParms.mrCanvas,
- rState,
- aTexture ) );
- }
- }
-
- if( pPolyAction )
- {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tadd poly action");
-
- maActions.push_back(
- MtfAction(
- pPolyAction,
- rParms.mrCurrActionIndex ) );
-
- rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
- }
- }
-
- void ImplRenderer::EMFPPlusDrawPolygon (::basegfx::B2DPolyPolygon& polygon, const ActionFactoryParameters& rParms,
- OutDevState& rState, const CanvasSharedPtr& rCanvas, sal_uInt32 penIndex)
- {
- EMFPPen* pen = (EMFPPen*) aObjects [penIndex & 0xff];
-
- SAL_WARN_IF( !pen, "cppcanvas.emf", "emf+ missing pen" );
-
- if (pen)
- {
- rState.isFillColorSet = false;
- rState.isLineColorSet = true;
- rState.lineColor = ::vcl::unotools::colorToDoubleSequence (pen->GetColor (),
- rCanvas->getUNOCanvas ()->getDevice()->getDeviceColorSpace());
-
- polygon.transform( rState.mapModeTransform );
- rendering::StrokeAttributes aStrokeAttributes;
-
- pen->SetStrokeAttributes (aStrokeAttributes, *this, rState);
-
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- polygon, rParms.mrCanvas, rState, aStrokeAttributes ) );
-
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- rParms.mrCurrActionIndex ) );
-
- rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
- }
- }
- }
-
- void ImplRenderer::processObjectRecord(SvMemoryStream& rObjectStream, sal_uInt16 flags, sal_uInt32 dataSize, sal_Bool bUseWholeStream)
- {
- sal_uInt32 index;
-
- SAL_INFO("cppcanvas.emf", "EMF+ Object slot: " << (flags & 0xff) << " flags: " << (flags & 0xff00));
-
- index = flags & 0xff;
- if (aObjects [index] != NULL) {
- delete aObjects [index];
- aObjects [index] = NULL;
- }
-
- switch (flags & 0x7f00) {
- case EmfPlusObjectTypeBrush:
- {
- EMFPBrush *brush;
- aObjects [index] = brush = new EMFPBrush ();
- brush->Read (rObjectStream, *this);
-
- break;
- }
- case EmfPlusObjectTypePen:
- {
- EMFPPen *pen;
- aObjects [index] = pen = new EMFPPen ();
- pen->Read (rObjectStream, *this, nHDPI, nVDPI);
-
- break;
- }
- case EmfPlusObjectTypePath:
- sal_uInt32 header, pathFlags;
- sal_Int32 points;
-
- rObjectStream >> header >> points >> pathFlags;
-
- SAL_INFO("cppcanvas.emf", "EMF+\tpath");
- SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " points: " << std::dec << points << " additional flags: 0x" << std::hex << pathFlags << std::dec);
-
- EMFPPath *path;
- aObjects [index] = path = new EMFPPath (points);
- path->Read (rObjectStream, pathFlags, *this);
-
- break;
- case EmfPlusObjectTypeRegion: {
- EMFPRegion *region;
-
- aObjects [index] = region = new EMFPRegion ();
- region->Read (rObjectStream);
-
- break;
- }
- case EmfPlusObjectTypeImage:
- {
- EMFPImage *image;
- aObjects [index] = image = new EMFPImage ();
- image->Read (rObjectStream, dataSize, bUseWholeStream);
-
- break;
- }
- case EmfPlusObjectTypeFont:
- {
- EMFPFont *font;
- aObjects [index] = font = new EMFPFont ();
- font->Read (rObjectStream);
-
- break;
- }
- default:
- SAL_INFO("cppcanvas.emf", "EMF+\tObject unhandled flags: 0x" << std::hex << (flags & 0xff00) << std::dec);
- break;
- }
- }
-
- double ImplRenderer::setFont (sal_uInt8 objectId, const ActionFactoryParameters& rParms, OutDevState& rState)
- {
- EMFPFont *font = (EMFPFont*) aObjects[ objectId ];
-
- rendering::FontRequest aFontRequest;
- aFontRequest.FontDescription.FamilyName = font->family;
- double cellSize = font->emSize;
- aFontRequest.CellSize = (rState.mapModeTransform*MapSize( cellSize, 0 )).getX();
- rState.xFont = rParms.mrCanvas->getUNOCanvas()->createFont( aFontRequest,
- uno::Sequence< beans::PropertyValue >(),
- geometry::Matrix2D() );
-
- return cellSize;
- }
-
- void ImplRenderer::GraphicStatePush(GraphicStateMap& map, sal_Int32 index, OutDevState& rState)
- {
- GraphicStateMap::iterator iter = map.find( index );
-
- if ( iter != map.end() )
- {
- EmfPlusGraphicState state = iter->second;
- map.erase( iter );
-
- SAL_INFO("cppcanvas.emf", "stack index: " << index << " found and erased");
- }
-
- EmfPlusGraphicState state;
-
- state.aWorldTransform = aWorldTransform;
- state.aDevState = rState;
-
- map[ index ] = state;
- }
-
- void ImplRenderer::GraphicStatePop(GraphicStateMap& map, sal_Int32 index, OutDevState& rState)
- {
- GraphicStateMap::iterator iter = map.find( index );
-
- if ( iter != map.end() )
- {
- SAL_INFO("cppcanvas.emf", "stack index: " << index << " found");
-
- EmfPlusGraphicState state = iter->second;
-
- aWorldTransform = state.aWorldTransform;
- rState.clip = state.aDevState.clip;
- rState.clipRect = state.aDevState.clipRect;
- rState.xClipPoly = state.aDevState.xClipPoly;
- }
- }
-
- void ImplRenderer::processEMFPlus( MetaCommentAction* pAct, const ActionFactoryParameters& rFactoryParms,
- OutDevState& rState, const CanvasSharedPtr& rCanvas )
- {
- sal_uInt32 length = pAct->GetDataSize ();
- SvMemoryStream rMF ((void*) pAct->GetData (), length, STREAM_READ);
-
-#if OSL_DEBUG_LEVEL > 2
- SAL_INFO("cppcanvas.emf", "EMF+\tDump of EMF+ record");
- dumpWords(rMF, length);
-#endif
- length -= 4;
-
- while (length > 0) {
- sal_uInt16 type, flags;
- sal_uInt32 size, dataSize;
- sal_uInt32 next;
-
- rMF >> type >> flags >> size >> dataSize;
-
- next = rMF.Tell() + ( size - 12 );
-
- if (size < 12) {
- SAL_INFO("cppcanvas.emf", "Size field is less than 12 bytes");
- }
-
- SAL_INFO("cppcanvas.emf", "EMF+ record size: " << size << " type: " << type << " flags: " << flags << " data size: " << dataSize);
-
- if (type == EmfPlusRecordTypeObject && ((mbMultipart && (flags & 0x7fff) == (mMFlags & 0x7fff)) || (flags & 0x8000))) {
- if (!mbMultipart) {
- mbMultipart = true;
- mMFlags = flags;
- mMStream.Seek(0);
- }
-
- // 1st 4 bytes are unknown
- mMStream.Write (((const char *)rMF.GetData()) + rMF.Tell() + 4, dataSize - 4);
- SAL_INFO("cppcanvas.emf", "EMF+ read next object part size: " << size << " type: " << type << " flags: " << flags << " data size: " << dataSize);
- } else {
- if (mbMultipart) {
- SAL_INFO("cppcanvas.emf", "EMF+ multipart record flags: " << mMFlags);
- mMStream.Seek (0);
- processObjectRecord (mMStream, mMFlags, dataSize, sal_True);
- }
- mbMultipart = false;
- }
-
- if (type != EmfPlusRecordTypeObject || !(flags & 0x8000))
- {
- switch (type) {
- case EmfPlusRecordTypeHeader:
- sal_uInt32 header, version;
-
- rMF >> header >> version >> nHDPI >> nVDPI;
-
- SAL_INFO("cppcanvas.emf", "EMF+ Header");
- SAL_INFO("cppcanvas.emf", "EMF+\theader: 0x" << std::hex << header << " version: " << std::dec << version << " horizontal DPI: " << nHDPI << " vertical DPI: " << nVDPI << " dual: " << (flags & 1));
-
- break;
- case EmfPlusRecordTypeEndOfFile:
- SAL_INFO("cppcanvas.emf", "EMF+ EndOfFile");
- break;
- case EmfPlusRecordTypeGetDC:
- SAL_INFO("cppcanvas.emf", "EMF+ GetDC");
- SAL_INFO("cppcanvas.emf", "EMF+\talready used in svtools wmf/emf filter parser");
- break;
- case EmfPlusRecordTypeObject:
- processObjectRecord (rMF, flags, dataSize);
- break;
- case EmfPlusRecordTypeFillPie:
- {
- sal_uInt32 brushIndexOrColor;
- float startAngle, sweepAngle;
-
- rMF >> brushIndexOrColor >> startAngle >> sweepAngle;
-
- SAL_INFO("cppcanvas.emf", "EMF+ FillPie colorOrIndex: " << brushIndexOrColor << " startAngle: " << startAngle << " sweepAngle: " << sweepAngle);
-
- float dx, dy, dw, dh;
-
- ReadRectangle (rMF, dx, dy, dw, dh, flags & 0x4000);
-
- SAL_INFO("cppcanvas.emf", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh);
-
- startAngle = 2*M_PI*startAngle/360;
- sweepAngle = 2*M_PI*sweepAngle/360;
-
- B2DPoint mappedCenter (Map (dx + dw/2, dy + dh/2));
- B2DSize mappedSize( MapSize (dw/2, dh/2));
-
- float endAngle = startAngle + sweepAngle;
- startAngle = fmodf(startAngle, static_cast<float>(M_PI*2));
- if (startAngle < 0)
- startAngle += static_cast<float>(M_PI*2);
- endAngle = fmodf(endAngle, static_cast<float>(M_PI*2));
- if (endAngle < 0)
- endAngle += static_cast<float>(M_PI*2);
-
- if (sweepAngle < 0)
- std::swap (endAngle, startAngle);
-
- SAL_INFO("cppcanvas.emf", "EMF+ adjusted angles: start " <<
- (360.0*startAngle/M_PI) << ", end: " << (360.0*endAngle/M_PI));
-
- B2DPolygon polygon = tools::createPolygonFromEllipseSegment (mappedCenter, mappedSize.getX (), mappedSize.getY (), startAngle, endAngle);
- polygon.append (mappedCenter);
- polygon.setClosed (true);
-
- B2DPolyPolygon polyPolygon (polygon);
- EMFPPlusFillPolygon (polyPolygon, rFactoryParms, rState, rCanvas, flags & 0x8000, brushIndexOrColor);
- }
- break;
- case EmfPlusRecordTypeFillPath:
- {
- sal_uInt32 index = flags & 0xff;
- sal_uInt32 brushIndexOrColor;
-
- rMF >> brushIndexOrColor;
-
- SAL_INFO("cppcanvas.emf", "EMF+ FillPath slot: " << index);
-
- EMFPPlusFillPolygon (((EMFPPath*) aObjects [index])->GetPolygon (*this), rFactoryParms, rState, rCanvas, flags & 0x8000, brushIndexOrColor);
- }
- break;
- case EmfPlusRecordTypeDrawEllipse:
- case EmfPlusRecordTypeFillEllipse:
- {
- // Intentionally very bogus initial value to avoid MSVC complaining about potentially uninitialized local
- // variable. As long as the code stays as intended, this variable will be assigned a (real) value in the case
- // when it is later used.
- sal_uInt32 brushIndexOrColor = 1234567;
-
- if ( type == EmfPlusRecordTypeFillEllipse )
- rMF >> brushIndexOrColor;
-
- SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeFillEllipse ? "Fill" : "Draw") << "Ellipse slot: " << (flags & 0xff));
-
- float dx, dy, dw, dh;
-
- ReadRectangle (rMF, dx, dy, dw, dh, flags & 0x4000);
-
- SAL_INFO("cppcanvas.emf", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh);
-
- B2DPoint mappedCenter (Map (dx + dw/2, dy + dh/2));
- B2DSize mappedSize( MapSize (dw/2, dh/2));
-
- ::basegfx::B2DPolyPolygon polyPolygon( ::basegfx::B2DPolygon( ::basegfx::tools::createPolygonFromEllipse( mappedCenter, mappedSize.getX (), mappedSize.getY () ) ) );
-
- if ( type == EmfPlusRecordTypeFillEllipse )
- EMFPPlusFillPolygon( polyPolygon,
- rFactoryParms, rState, rCanvas, flags & 0x8000, brushIndexOrColor );
- else
- EMFPPlusDrawPolygon( polyPolygon,
- rFactoryParms, rState, rCanvas, flags & 0xff );
- }
- break;
- case EmfPlusRecordTypeFillRects:
- {
- SAL_INFO("cppcanvas.emf", "EMF+ FillRects");
-
- sal_uInt32 brushIndexOrColor;
- sal_Int32 rectangles;
- bool isColor = (flags & 0x8000);
- ::basegfx::B2DPolygon polygon;
-
- rMF >> brushIndexOrColor >> rectangles;
-
- SAL_INFO("cppcanvas.emf", "EMF+\t" << ((flags & 0x8000) ? "color" : "brush index") << ": 0x" << std::hex << brushIndexOrColor << std::dec);
-
- for (int i=0; i < rectangles; i++) {
- if (flags & 0x4000) {
- /* 16bit integers */
- sal_Int16 x, y, width, height;
-
- rMF >> x >> y >> width >> height;
-
- polygon.append (Map (x, y));
- polygon.append (Map (x + width, y));
- polygon.append (Map (x + width, y + height));
- polygon.append (Map (x, y + height));
-
- SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << "," << " " << width << "x" << height);
- } else {
- /* Single's */
- float x, y, width, height;
-
- rMF >> x >> y >> width >> height;
-
- polygon.append (Map (x, y));
- polygon.append (Map (x + width, y));
- polygon.append (Map (x + width, y + height));
- polygon.append (Map (x, y + height));
-
- SAL_INFO("cppcanvas.emf", "EMF+\trectangle: " << x << "," << " " << width << "x" << height);
- }
-
- ::basegfx::B2DPolyPolygon polyPolygon (polygon);
-
- EMFPPlusFillPolygon (polyPolygon, rFactoryParms, rState, rCanvas, isColor, brushIndexOrColor);
- }
- break;
- }
- case EmfPlusRecordTypeFillPolygon:
- {
- sal_uInt8 index = flags & 0xff;
- sal_uInt32 brushIndexOrColor;
- sal_Int32 points;
-
- rMF >> brushIndexOrColor;
- rMF >> points;
-
- SAL_INFO("cppcanvas.emf", "EMF+ FillPolygon in slot: " << +index << " points: " << points);
- SAL_INFO("cppcanvas.emf", "EMF+\t: " << ((flags & 0x8000) ? "color" : "brush index") << " 0x" << std::hex << brushIndexOrColor << std::dec);
-
- EMFPPath path (points, true);
- path.Read (rMF, flags, *this);
-
- EMFPPlusFillPolygon (path.GetPolygon (*this), rFactoryParms, rState, rCanvas, flags & 0x8000, brushIndexOrColor);
-
- break;
- }
- case EmfPlusRecordTypeDrawLines:
- {
- sal_uInt32 points;
-
- rMF >> points;
-
- SAL_INFO("cppcanvas.emf", "EMF+ DrawLines in slot: " << (flags && 0xff) << " points: " << points);
-
- EMFPPath path (points, true);
- path.Read (rMF, flags, *this);
-
- EMFPPlusDrawPolygon (path.GetPolygon (*this), rFactoryParms, rState, rCanvas, flags);
-
- break;
- }
- case EmfPlusRecordTypeDrawPath:
- {
- sal_uInt32 penIndex;
-
- rMF >> penIndex;
-
- SAL_INFO("cppcanvas.emf", "EMF+ DrawPath");
- SAL_INFO("cppcanvas.emf", "EMF+\tpen: " << penIndex);
-
- EMFPPath* path = (EMFPPath*) aObjects [flags & 0xff];
- SAL_WARN_IF( !path, "cppcanvas.emf", "EmfPlusRecordTypeDrawPath missing path" );
-
- EMFPPlusDrawPolygon (path->GetPolygon (*this), rFactoryParms, rState, rCanvas, penIndex);
-
- break;
- }
- case EmfPlusRecordTypeDrawImage:
- case EmfPlusRecordTypeDrawImagePoints:
- {
- sal_uInt32 attrIndex;
- sal_Int32 sourceUnit;
-
- rMF >> attrIndex >> sourceUnit;
-
- SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << "attributes index: " << attrIndex << "source unit: " << sourceUnit);
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO: use image attributes");
-
- if (sourceUnit == 2 && aObjects [flags & 0xff]) { // we handle only GraphicsUnit.Pixel now
- EMFPImage& image = *(EMFPImage *) aObjects [flags & 0xff];
- float sx, sy, sw, sh;
- sal_Int32 aCount;
-
- ReadRectangle (rMF, sx, sy, sw, sh);
-
- SAL_INFO("cppcanvas.emf", "EMF+ " << (type == EmfPlusRecordTypeDrawImagePoints ? "DrawImagePoints" : "DrawImage") << " source rectangle: " << sx << "," << sy << " " << sw << "x" << sh);
-
- ::basegfx::B2DPoint aDstPoint;
- ::basegfx::B2DSize aDstSize;
- bool bValid = false;
-
- if (type == EmfPlusRecordTypeDrawImagePoints) {
- rMF >> aCount;
-
- if( aCount == 3) { // TODO: now that we now that this value is count we should support it better
- float x1, y1, x2, y2, x3, y3;
-
- ReadPoint (rMF, x1, y1, flags);
- ReadPoint (rMF, x2, y2, flags);
- ReadPoint (rMF, x3, y3, flags);
-
- SAL_INFO("cppcanvas.emf", "EMF+ destination points: " << x1 << "," << y1 << " " << x2 << "," << y2 << " " << x3 << "," << y3);
- SAL_INFO("cppcanvas.emf", "EMF+ destination rectangle: " << x1 << "," << y1 << " " << x2 - x1 << "x" << y3 - y1);
-
- aDstPoint = Map (x1, y1);
- aDstSize = MapSize(x2 - x1, y3 - y1);
-
- bValid = true;
- }
- } else if (type == EmfPlusRecordTypeDrawImage) {
- float dx, dy, dw, dh;
-
- ReadRectangle (rMF, dx, dy, dw, dh, flags & 0x4000);
-
- SAL_INFO("cppcanvas.emf", "EMF+ destination rectangle: " << dx << "," << dy << " " << dw << "x" << dh);
-
- aDstPoint = Map (dx, dy);
- aDstSize = MapSize(dw, dh);
-
- bValid = true;
- }
-
- if (bValid) {
- BitmapEx aBmp( image.graphic.GetBitmapEx () );
-
- Size aSize( aBmp.GetSizePixel() );
- SAL_INFO("cppcanvas.emf", "EMF+ bitmap size: " << aSize.Width() << "x" << aSize.Height());
- if( aSize.Width() > 0 && aSize.Height() > 0 ) {
- ActionSharedPtr pBmpAction (
- internal::BitmapActionFactory::createBitmapAction (
- aBmp,
- rState.mapModeTransform * aDstPoint,
- rState.mapModeTransform * aDstSize,
- rCanvas,
- rState));
-
- if( pBmpAction ) {
- maActions.push_back( MtfAction( pBmpAction,
- rFactoryParms.mrCurrActionIndex ) );
-
- rFactoryParms.mrCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+ warning: empty bitmap");
- }
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+ DrawImage(Points) TODO (fixme)");
- }
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+ DrawImage(Points) TODO (fixme) - possibly unsupported source units for crop rectangle");
- }
- break;
- }
- case EmfPlusRecordTypeDrawString:
- {
- SAL_INFO("cppcanvas.emf", "EMF+ DrawString");
-
- sal_uInt32 brushId;
- sal_uInt32 formatId;
- sal_uInt32 stringLength;
-
- rMF >> brushId >> formatId >> stringLength;
- SAL_INFO("cppcanvas.emf", "EMF+ DrawString brushId: " << brushId << " formatId: " << formatId << " length: " << stringLength);
-
- if (flags & 0x8000) {
- float lx, ly, lw, lh;
-
- rMF >> lx >> ly >> lw >> lh;
-
- SAL_INFO("cppcanvas.emf", "EMF+ DrawString layoutRect: " << lx << "," << ly << " - " << lw << "x" << lh);
-
- OUString text = read_uInt16s_ToOUString(rMF, stringLength);
-
- double cellSize = setFont (flags & 0xff, rFactoryParms, rState);
- rState.textColor = COLOR( brushId );
-
- ::basegfx::B2DPoint point( Map( lx + 0.15*cellSize, ly + cellSize ) );
-
- ActionSharedPtr pTextAction(
- TextActionFactory::createTextAction(
- // position is just rough guess for now
- // we should calculate it exactly from layoutRect or font
- ::vcl::unotools::pointFromB2DPoint ( point ),
- ::Size(),
- ::Color(),
- ::Size(),
- ::Color(),
- text,
- 0,
- stringLength,
- NULL,
- rFactoryParms.mrVDev,
- rFactoryParms.mrCanvas,
- rState,
- rFactoryParms.mrParms,
- false ) );
- if( pTextAction )
- {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tadd text action");
-
- maActions.push_back(
- MtfAction(
- pTextAction,
- rFactoryParms.mrCurrActionIndex ) );
-
- rFactoryParms.mrCurrActionIndex += pTextAction->getActionCount()-1;
- }
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+ DrawString TODO - drawing with brush not yet supported");
- }
- }
- break;
- case EmfPlusRecordTypeSetPageTransform:
- rMF >> fPageScale;
-
- SAL_INFO("cppcanvas.emf", "EMF+ SetPageTransform");
- SAL_INFO("cppcanvas.emf", "EMF+\tscale: " << fPageScale << " unit: " << flags);
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSetRenderingOrigin:
- rMF >> nOriginX >> nOriginY;
- SAL_INFO("cppcanvas.emf", "EMF+ SetRenderingOrigin");
- SAL_INFO("cppcanvas.emf", "EMF+\torigin [x,y]: " << nOriginX << "," << nOriginY);
- break;
- case EmfPlusRecordTypeSetTextRenderingHint:
- SAL_INFO("cppcanvas.emf", "EMF+ SetTextRenderingHint");
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSetAntiAliasMode:
- SAL_INFO("cppcanvas.emf", "EMF+ SetAntiAliasMode");
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSetInterpolationMode:
- SAL_INFO("cppcanvas.emf", "EMF+ InterpolationMode");
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSetPixelOffsetMode:
- SAL_INFO("cppcanvas.emf", "EMF+ SetPixelOffsetMode");
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSetCompositingQuality:
- SAL_INFO("cppcanvas.emf", "EMF+ SetCompositingQuality");
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- break;
- case EmfPlusRecordTypeSave:
- {
- sal_uInt32 stackIndex;
-
- rMF >> stackIndex;
-
- SAL_INFO("cppcanvas.emf", "EMF+ Save stack index: " << stackIndex);
-
- GraphicStatePush( mGSStack, stackIndex, rState );
-
- break;
- }
- case EmfPlusRecordTypeRestore:
- {
- sal_uInt32 stackIndex;
-
- rMF >> stackIndex;
-
- SAL_INFO("cppcanvas.emf", "EMF+ Restore stack index: " << stackIndex);
-
- GraphicStatePop( mGSStack, stackIndex, rState );
-
- break;
- }
- case EmfPlusRecordTypeBeginContainerNoParams:
- {
- sal_uInt32 stackIndex;
-
- rMF >> stackIndex;
-
- SAL_INFO("cppcanvas.emf", "EMF+ Begin Container No Params stack index: " << stackIndex);
-
- GraphicStatePush( mGSContainerStack, stackIndex, rState );
- }
- break;
- case EmfPlusRecordTypeEndContainer:
- {
- sal_uInt32 stackIndex;
-
- rMF >> stackIndex;
-
- SAL_INFO("cppcanvas.emf", "EMF+ End Container stack index: " << stackIndex);
-
- GraphicStatePop( mGSContainerStack, stackIndex, rState );
- }
- break;
- case EmfPlusRecordTypeSetWorldTransform: {
- SAL_INFO("cppcanvas.emf", "EMF+ SetWorldTransform");
- XForm transform;
- rMF >> transform;
- aWorldTransform.Set (transform);
- SAL_INFO("cppcanvas.emf",
- "EMF+\tm11: " << aWorldTransform.eM11 << "\tm12: " << aWorldTransform.eM12 <<
- "\tm21: " << aWorldTransform.eM21 << "\tm22: " << aWorldTransform.eM22 <<
- "\tdx: " << aWorldTransform.eDx << "\tdy: " << aWorldTransform.eDy);
- break;
- }
- case EmfPlusRecordTypeResetWorldTransform:
- SAL_INFO("cppcanvas.emf", "EMF+ ResetWorldTransform");
- aWorldTransform.SetIdentity ();
- break;
- case EmfPlusRecordTypeMultiplyWorldTransform: {
- SAL_INFO("cppcanvas.emf", "EMF+ MultiplyWorldTransform");
- XForm transform;
- rMF >> transform;
-
- SAL_INFO("cppcanvas.emf",
- "EMF+\tmatrix m11: " << transform.eM11 << "m12: " << transform.eM12 <<
- "EMF+\tm21: " << transform.eM21 << "m22: " << transform.eM22 <<
- "EMF+\tdx: " << transform.eDx << "dy: " << transform.eDy);
-
- if (flags & 0x2000) // post multiply
- aWorldTransform.Multiply (transform);
- else { // pre multiply
- transform.Multiply (aWorldTransform);
- aWorldTransform.Set (transform);
- }
- SAL_INFO("cppcanvas.emf",
- "EMF+\tm11: " << aWorldTransform.eM11 << "m12: " << aWorldTransform.eM12 <<
- "EMF+\tm21: " << aWorldTransform.eM21 << "m22: " << aWorldTransform.eM22 <<
- "EMF+\tdx: " << aWorldTransform.eDx << "dy: " << aWorldTransform.eDy);
- break;
- }
- case EmfPlusRecordTypeSetClipRect:
- {
- int combineMode = (flags >> 8) & 0xf;
-
- SAL_INFO("cppcanvas.emf", "EMF+ SetClipRect combine mode: " << combineMode);
-#if OSL_DEBUG_LEVEL > 1
- if (combineMode > 1) {
- SAL_INFO ("cppcanvas.emf", "EMF+ TODO combine mode > 1");
- }
-#endif
-
- float dx, dy, dw, dh;
-
- ReadRectangle (rMF, dx, dy, dw, dh, false);
-
- SAL_INFO("cppcanvas.emf", "EMF+ RectData: " << dx << "," << dy << " " << dw << "x" << dh);
-
- B2DPoint mappedPoint (Map (dx, dy));
- B2DSize mappedSize( MapSize (dw, dh));
-
- ::basegfx::B2DPolyPolygon polyPolygon( ::basegfx::B2DPolygon( ::basegfx::tools::createPolygonFromRect( ::basegfx::B2DRectangle( mappedPoint.getX(), mappedPoint.getY(),
- mappedPoint.getX() + mappedSize.getX(),
- mappedPoint.getY() + mappedSize.getY() ) ) ) );
- polyPolygon.transform(rState.mapModeTransform);
-
- updateClipping (polyPolygon, rFactoryParms, combineMode == 1);
-
- break;
- }
- case EmfPlusRecordTypeSetClipPath:
- {
- int combineMode = (flags >> 8) & 0xf;
-
- SAL_INFO("cppcanvas.emf", "EMF+ SetClipPath combine mode: " << combineMode);
- SAL_INFO("cppcanvas.emf", "EMF+\tpath in slot: " << (flags & 0xff));
-
- EMFPPath& path = *(EMFPPath*) aObjects [flags & 0xff];
- ::basegfx::B2DPolyPolygon& clipPoly (path.GetPolygon (*this));
-
- clipPoly.transform (rState.mapModeTransform);
- updateClipping (clipPoly, rFactoryParms, combineMode == 1);
-
- break;
- }
- case EmfPlusRecordTypeSetClipRegion: {
- int combineMode = (flags >> 8) & 0xf;
-
- SAL_INFO("cppcanvas.emf", "EMF+ SetClipRegion");
- SAL_INFO("cppcanvas.emf", "EMF+\tregion in slot: " << (flags & 0xff) << " combine mode: " << combineMode);
- EMFPRegion *region = (EMFPRegion*)aObjects [flags & 0xff];
-
- // reset clip
- if (region && region->parts == 0 && region->initialState == EmfPlusRegionInitialStateInfinite) {
- updateClipping (::basegfx::B2DPolyPolygon (), rFactoryParms, combineMode == 1);
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- }
- break;
- }
- case EmfPlusRecordTypeDrawDriverString: {
- SAL_INFO("cppcanvas.emf", "EMF+ DrawDriverString, flags: 0x" << std::hex << flags << std::dec);
- sal_uInt32 brushIndexOrColor;
- sal_uInt32 optionFlags;
- sal_uInt32 hasMatrix;
- sal_uInt32 glyphsCount;
-
- rMF >> brushIndexOrColor >> optionFlags >> hasMatrix >> glyphsCount;
-
- SAL_INFO("cppcanvas.emf", "EMF+\t: " << ((flags & 0x8000) ? "color" : "brush index") << " 0x" << std::hex << brushIndexOrColor << std::dec);
- SAL_INFO("cppcanvas.emf", "EMF+\toption flags: 0x" << std::hex << optionFlags << std::dec);
- SAL_INFO("cppcanvas.emf", "EMF+\thas matrix: " << hasMatrix);
- SAL_INFO("cppcanvas.emf", "EMF+\tglyphs: " << glyphsCount);
-
- if( ( optionFlags & 1 ) && glyphsCount > 0 ) {
- float *charsPosX = new float[glyphsCount];
- float *charsPosY = new float[glyphsCount];
-
- OUString text = read_uInt16s_ToOUString(rMF, glyphsCount);
-
- for( sal_uInt32 i=0; i<glyphsCount; i++) {
- rMF >> charsPosX[i] >> charsPosY[i];
- SAL_INFO("cppcanvas.emf", "EMF+\tglyphPosition[" << i << "]: " << charsPosX[i] << "," << charsPosY[i]);
- }
-
- XForm transform;
- if( hasMatrix ) {
- rMF >> transform;
- SAL_INFO("cppcanvas.emf", "EMF+\tmatrix: " << transform.eM11 << ", " << transform.eM12 << ", " << transform.eM21 << ", " << transform.eM22 << ", " << transform.eDx << ", " << transform.eDy);
- }
-
- // add the text action
- setFont (flags & 0xff, rFactoryParms, rState);
-
- if( flags & 0x8000 )
- rState.textColor = COLOR( brushIndexOrColor );
-
- ::basegfx::B2DPoint point( Map( charsPosX[0], charsPosY[0] ) );
-
- ActionSharedPtr pTextAction(
- TextActionFactory::createTextAction(
- ::vcl::unotools::pointFromB2DPoint ( point ),
- ::Size(),
- ::Color(),
- ::Size(),
- ::Color(),
- text,
- 0,
- glyphsCount,
- NULL,
- rFactoryParms.mrVDev,
- rFactoryParms.mrCanvas,
- rState,
- rFactoryParms.mrParms,
- false ) );
-
- if( pTextAction )
- {
- SAL_INFO("cppcanvas.emf", "EMF+\t\tadd text action");
-
- maActions.push_back(
- MtfAction(
- pTextAction,
- rFactoryParms.mrCurrActionIndex ) );
-
- rFactoryParms.mrCurrActionIndex += pTextAction->getActionCount()-1;
- }
-
- delete[] charsPosX;
- delete[] charsPosY;
- } else {
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO: fonts (non-unicode glyphs chars)");
- }
-
- break;
- }
- default:
- SAL_INFO("cppcanvas.emf", "EMF+ unhandled record type: " << type);
- SAL_INFO("cppcanvas.emf", "EMF+\tTODO");
- }
- }
-
- rMF.Seek (next);
-
- if (size <= length)
- {
- length -= size;
- }
- else
- {
- SAL_WARN("cppcanvas.emf", "ImplRenderer::processEMFPlus: "
- "size " << size << " > length " << length);
-#if OSL_DEBUG_LEVEL > 1
- dumpWords(rMF, length);
-#endif
- length = 0;
- }
- }
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/implrenderer.cxx b/cppcanvas/source/mtfrenderer/implrenderer.cxx
deleted file mode 100644
index a8145bb9d2f6..000000000000
--- a/cppcanvas/source/mtfrenderer/implrenderer.cxx
+++ /dev/null
@@ -1,3104 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <canvas/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <canvas/verbosetrace.hxx>
-#include <osl/mutex.hxx>
-#include <vcl/svapp.hxx>
-#include <comphelper/sequence.hxx>
-#include <comphelper/anytostring.hxx>
-#include <cppuhelper/exc_hlp.hxx>
-#include <cppcanvas/canvas.hxx>
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <com/sun/star/rendering/TexturingMode.hpp>
-#include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/geometry/RealPoint2D.hpp>
-#include <com/sun/star/rendering/PanoseProportion.hpp>
-#include <com/sun/star/rendering/ViewState.hpp>
-#include <com/sun/star/rendering/RenderState.hpp>
-#include <com/sun/star/rendering/XCanvasFont.hpp>
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/PathCapType.hpp>
-#include <com/sun/star/rendering/PathJoinType.hpp>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/tools/gradienttools.hxx>
-#include <basegfx/numeric/ftools.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/tuple/b2dtuple.hxx>
-#include <basegfx/polygon/b2dpolygonclipper.hxx>
-#include <basegfx/polygon/b2dpolypolygoncutter.hxx>
-#include <canvas/canvastools.hxx>
-#include <vcl/canvastools.hxx>
-#include <vcl/salbtype.hxx>
-#include <vcl/gdimtf.hxx>
-#include <vcl/metaact.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/metric.hxx>
-#include <vcl/graphictools.hxx>
-#include <tools/poly.hxx>
-#include <i18nlangtag/languagetag.hxx>
-#include <implrenderer.hxx>
-#include <tools.hxx>
-#include <outdevstate.hxx>
-#include <action.hxx>
-#include <bitmapaction.hxx>
-#include <lineaction.hxx>
-#include <pointaction.hxx>
-#include <polypolyaction.hxx>
-#include <textaction.hxx>
-#include <transparencygroupaction.hxx>
-#include <vector>
-#include <algorithm>
-#include <iterator>
-#include <boost/scoped_array.hpp>
-#include "mtftools.hxx"
-#include "outdevstate.hxx"
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-
-using namespace ::com::sun::star;
-
-
-// free support functions
-// ======================
-namespace
-{
- template < class MetaActionType > void setStateColor( MetaActionType* pAct,
- bool& rIsColorSet,
- uno::Sequence< double >& rColorSequence,
- const cppcanvas::CanvasSharedPtr& rCanvas )
- {
- // set rIsColorSet and check for true at the same time
- if( (rIsColorSet=pAct->IsSetting()) != false )
- {
- ::Color aColor( pAct->GetColor() );
-
- // force alpha part of color to
- // opaque. transparent painting is done
- // explicitly via META_TRANSPARENT_ACTION
- aColor.SetTransparency(0);
- //aColor.SetTransparency(128);
-
- rColorSequence = ::vcl::unotools::colorToDoubleSequence(
- aColor,
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
- }
- }
-
- void setupStrokeAttributes( rendering::StrokeAttributes& o_rStrokeAttributes,
- const ::cppcanvas::internal::ActionFactoryParameters& rParms,
- const LineInfo& rLineInfo )
- {
- const ::basegfx::B2DSize aWidth( rLineInfo.GetWidth(), 0 );
- o_rStrokeAttributes.StrokeWidth =
- (rParms.mrStates.getState().mapModeTransform * aWidth).getX();
-
- // setup reasonable defaults
- o_rStrokeAttributes.MiterLimit = 15.0; // 1.0 was no good default; GDI+'s limit is 10.0, our's is 15.0
- o_rStrokeAttributes.StartCapType = rendering::PathCapType::BUTT;
- o_rStrokeAttributes.EndCapType = rendering::PathCapType::BUTT;
-
- switch(rLineInfo.GetLineJoin())
- {
- default: // B2DLINEJOIN_NONE, B2DLINEJOIN_MIDDLE
- o_rStrokeAttributes.JoinType = rendering::PathJoinType::NONE;
- break;
- case basegfx::B2DLINEJOIN_BEVEL:
- o_rStrokeAttributes.JoinType = rendering::PathJoinType::BEVEL;
- break;
- case basegfx::B2DLINEJOIN_MITER:
- o_rStrokeAttributes.JoinType = rendering::PathJoinType::MITER;
- break;
- case basegfx::B2DLINEJOIN_ROUND:
- o_rStrokeAttributes.JoinType = rendering::PathJoinType::ROUND;
- break;
- }
-
- switch(rLineInfo.GetLineCap())
- {
- default: /* com::sun::star::drawing::LineCap_BUTT */
- {
- o_rStrokeAttributes.StartCapType = rendering::PathCapType::BUTT;
- o_rStrokeAttributes.EndCapType = rendering::PathCapType::BUTT;
- break;
- }
- case com::sun::star::drawing::LineCap_ROUND:
- {
- o_rStrokeAttributes.StartCapType = rendering::PathCapType::ROUND;
- o_rStrokeAttributes.EndCapType = rendering::PathCapType::ROUND;
- break;
- }
- case com::sun::star::drawing::LineCap_SQUARE:
- {
- o_rStrokeAttributes.StartCapType = rendering::PathCapType::SQUARE;
- o_rStrokeAttributes.EndCapType = rendering::PathCapType::SQUARE;
- break;
- }
- }
-
- if( LINE_DASH == rLineInfo.GetStyle() )
- {
- const ::cppcanvas::internal::OutDevState& rState( rParms.mrStates.getState() );
-
- // TODO(F1): Interpret OutDev::GetRefPoint() for the start of the dashing.
-
- // interpret dash info only if explicitly enabled as
- // style
- const ::basegfx::B2DSize aDistance( rLineInfo.GetDistance(), 0 );
- const double nDistance( (rState.mapModeTransform * aDistance).getX() );
-
- const ::basegfx::B2DSize aDashLen( rLineInfo.GetDashLen(), 0 );
- const double nDashLen( (rState.mapModeTransform * aDashLen).getX() );
-
- const ::basegfx::B2DSize aDotLen( rLineInfo.GetDotLen(), 0 );
- const double nDotLen( (rState.mapModeTransform * aDotLen).getX() );
-
- const sal_Int32 nNumArryEntries( 2*rLineInfo.GetDashCount() +
- 2*rLineInfo.GetDotCount() );
-
- o_rStrokeAttributes.DashArray.realloc( nNumArryEntries );
- double* pDashArray = o_rStrokeAttributes.DashArray.getArray();
-
-
- // iteratively fill dash array, first with dashs, then
- // with dots.
- // ===================================================
-
- sal_Int32 nCurrEntry=0;
-
- for( sal_Int32 i=0; i<rLineInfo.GetDashCount(); ++i )
- {
- pDashArray[nCurrEntry++] = nDashLen;
- pDashArray[nCurrEntry++] = nDistance;
- }
- for( sal_Int32 i=0; i<rLineInfo.GetDotCount(); ++i )
- {
- pDashArray[nCurrEntry++] = nDotLen;
- pDashArray[nCurrEntry++] = nDistance;
- }
- }
- }
-
-
- /** Create masked BitmapEx, where the white areas of rBitmap are
- transparent, and the other appear in rMaskColor.
- */
- BitmapEx createMaskBmpEx( const Bitmap& rBitmap,
- const ::Color& rMaskColor )
- {
- const ::Color aWhite( COL_WHITE );
- BitmapPalette aBiLevelPalette(2);
- aBiLevelPalette[0] = aWhite;
- aBiLevelPalette[1] = rMaskColor;
-
- Bitmap aMask( rBitmap.CreateMask( aWhite ));
- Bitmap aSolid( rBitmap.GetSizePixel(),
- 1,
- &aBiLevelPalette );
- aSolid.Erase( rMaskColor );
-
- return BitmapEx( aSolid, aMask );
- }
-
- OUString convertToLocalizedNumerals(const OUString& rStr,
- LanguageType eTextLanguage)
- {
- OUStringBuffer aBuf(rStr);
- for (sal_Int32 i = 0; i < aBuf.getLength(); ++i)
- {
- sal_Unicode nChar = aBuf[i];
- if (nChar >= '0' && nChar <= '9')
- aBuf[i] = GetLocalizedChar(nChar, eTextLanguage);
- }
- return aBuf.makeStringAndClear();
- }
-}
-
-namespace cppcanvas
-{
- namespace internal
- {
- // state stack manipulators
- // ------------------------
- void VectorOfOutDevStates::clearStateStack()
- {
- m_aStates.clear();
- const OutDevState aDefaultState;
- m_aStates.push_back(aDefaultState);
- }
-
- OutDevState& VectorOfOutDevStates::getState()
- {
- return m_aStates.back();
- }
-
- const OutDevState& VectorOfOutDevStates::getState() const
- {
- return m_aStates.back();
- }
-
- void VectorOfOutDevStates::pushState(sal_uInt16 nFlags)
- {
- m_aStates.push_back( getState() );
- getState().pushFlags = nFlags;
- }
-
- void VectorOfOutDevStates::popState()
- {
- if( getState().pushFlags != PUSH_ALL )
- {
- // a state is pushed which is incomplete, i.e. does not
- // restore everything to the previous stack level when
- // popped.
- // That means, we take the old state, and restore every
- // OutDevState member whose flag is set, from the new to the
- // old state. Then the new state gets overwritten by the
- // calculated state
-
- // preset to-be-calculated new state with old state
- OutDevState aCalculatedNewState( getState() );
-
- // selectively copy to-be-restored content over saved old
- // state
- m_aStates.pop_back();
-
- const OutDevState& rNewState( getState() );
-
- if( (aCalculatedNewState.pushFlags & PUSH_LINECOLOR) )
- {
- aCalculatedNewState.lineColor = rNewState.lineColor;
- aCalculatedNewState.isLineColorSet = rNewState.isLineColorSet;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_FILLCOLOR) )
- {
- aCalculatedNewState.fillColor = rNewState.fillColor;
- aCalculatedNewState.isFillColorSet = rNewState.isFillColorSet;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_FONT) )
- {
- aCalculatedNewState.xFont = rNewState.xFont;
- aCalculatedNewState.fontRotation = rNewState.fontRotation;
- aCalculatedNewState.textReliefStyle = rNewState.textReliefStyle;
- aCalculatedNewState.textOverlineStyle = rNewState.textOverlineStyle;
- aCalculatedNewState.textUnderlineStyle = rNewState.textUnderlineStyle;
- aCalculatedNewState.textStrikeoutStyle = rNewState.textStrikeoutStyle;
- aCalculatedNewState.textEmphasisMarkStyle = rNewState.textEmphasisMarkStyle;
- aCalculatedNewState.isTextEffectShadowSet = rNewState.isTextEffectShadowSet;
- aCalculatedNewState.isTextWordUnderlineSet = rNewState.isTextWordUnderlineSet;
- aCalculatedNewState.isTextOutlineModeSet = rNewState.isTextOutlineModeSet;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_TEXTCOLOR) )
- {
- aCalculatedNewState.textColor = rNewState.textColor;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_MAPMODE) )
- {
- aCalculatedNewState.mapModeTransform = rNewState.mapModeTransform;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_CLIPREGION) )
- {
- aCalculatedNewState.clip = rNewState.clip;
- aCalculatedNewState.clipRect = rNewState.clipRect;
- aCalculatedNewState.xClipPoly = rNewState.xClipPoly;
- }
-
- // TODO(F2): Raster ops NYI
- // if( (aCalculatedNewState.pushFlags & PUSH_RASTEROP) )
- // {
- // }
-
- if( (aCalculatedNewState.pushFlags & PUSH_TEXTFILLCOLOR) )
- {
- aCalculatedNewState.textFillColor = rNewState.textFillColor;
- aCalculatedNewState.isTextFillColorSet = rNewState.isTextFillColorSet;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_TEXTALIGN) )
- {
- aCalculatedNewState.textReferencePoint = rNewState.textReferencePoint;
- }
-
- // TODO(F1): Refpoint handling NYI
- // if( (aCalculatedNewState.pushFlags & PUSH_REFPOINT) )
- // {
- // }
-
- if( (aCalculatedNewState.pushFlags & PUSH_TEXTLINECOLOR) )
- {
- aCalculatedNewState.textLineColor = rNewState.textLineColor;
- aCalculatedNewState.isTextLineColorSet = rNewState.isTextLineColorSet;
- }
-
- if( (aCalculatedNewState.pushFlags & PUSH_TEXTLAYOUTMODE) )
- {
- aCalculatedNewState.textAlignment = rNewState.textAlignment;
- aCalculatedNewState.textDirection = rNewState.textDirection;
- }
-
- // TODO(F2): Text language handling NYI
- // if( (aCalculatedNewState.pushFlags & PUSH_TEXTLANGUAGE) )
- // {
- // }
-
- // always copy push mode
- aCalculatedNewState.pushFlags = rNewState.pushFlags;
-
- // flush to stack
- getState() = aCalculatedNewState;
- }
- else
- {
- m_aStates.pop_back();
- }
- }
-
- bool ImplRenderer::createFillAndStroke( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const ActionFactoryParameters& rParms )
- {
- const OutDevState& rState( rParms.mrStates.getState() );
- if( (!rState.isLineColorSet &&
- !rState.isFillColorSet) ||
- (rState.lineColor.getLength() == 0 &&
- rState.fillColor.getLength() == 0) )
- {
- return false;
- }
-
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- rPolyPoly, rParms.mrCanvas, rState ) );
-
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- rParms.mrCurrActionIndex ) );
-
- rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
- }
-
- return true;
- }
-
- bool ImplRenderer::createFillAndStroke( const ::basegfx::B2DPolygon& rPoly,
- const ActionFactoryParameters& rParms )
- {
- return createFillAndStroke( ::basegfx::B2DPolyPolygon( rPoly ),
- rParms );
- }
-
- void ImplRenderer::skipContent( GDIMetaFile& rMtf,
- const char* pCommentString,
- sal_Int32& io_rCurrActionIndex ) const
- {
- ENSURE_OR_THROW( pCommentString,
- "ImplRenderer::skipContent(): NULL string given" );
-
- MetaAction* pCurrAct;
- while( (pCurrAct=rMtf.NextAction()) != NULL )
- {
- // increment action index, we've skipped an action.
- ++io_rCurrActionIndex;
-
- if( pCurrAct->GetType() == META_COMMENT_ACTION &&
- static_cast<MetaCommentAction*>(pCurrAct)->GetComment().equalsIgnoreAsciiCase(
- pCommentString) )
- {
- // requested comment found, done
- return;
- }
- }
-
- // EOF
- return;
- }
-
- bool ImplRenderer::isActionContained( GDIMetaFile& rMtf,
- const char* pCommentString,
- sal_uInt16 nType ) const
- {
- ENSURE_OR_THROW( pCommentString,
- "ImplRenderer::isActionContained(): NULL string given" );
-
- bool bRet( false );
-
- // at least _one_ call to GDIMetaFile::NextAction() is
- // executed
- sal_uIntPtr nPos( 1 );
-
- MetaAction* pCurrAct;
- while( (pCurrAct=rMtf.NextAction()) != NULL )
- {
- if( pCurrAct->GetType() == nType )
- {
- bRet = true; // action type found
- break;
- }
-
- if( pCurrAct->GetType() == META_COMMENT_ACTION &&
- static_cast<MetaCommentAction*>(pCurrAct)->GetComment().equalsIgnoreAsciiCase(
- pCommentString) )
- {
- // delimiting end comment found, done
- bRet = false; // not yet found
- break;
- }
-
- ++nPos;
- }
-
- // rewind metafile to previous position (this method must
- // not change the current metaaction)
- while( nPos-- )
- rMtf.WindPrev();
-
- if( !pCurrAct )
- {
- // EOF, and not yet found
- bRet = false;
- }
-
- return bRet;
- }
-
- void ImplRenderer::createGradientAction( const ::PolyPolygon& rPoly,
- const ::Gradient& rGradient,
- const ActionFactoryParameters& rParms,
- bool bIsPolygonRectangle,
- bool bSubsettableActions )
- {
- DBG_TESTSOLARMUTEX();
-
- ::basegfx::B2DPolyPolygon aDevicePoly( rPoly.getB2DPolyPolygon() );
- aDevicePoly.transform( rParms.mrStates.getState().mapModeTransform );
-
- // decide, whether this gradient can be rendered natively
- // by the canvas, or must be emulated via VCL gradient
- // action extraction.
- const sal_uInt16 nSteps( rGradient.GetSteps() );
-
- if( // step count is infinite, can use native canvas
- // gradients here
- nSteps == 0 ||
- // step count is sufficiently high, such that no
- // discernible difference should be visible.
- nSteps > 64 )
- {
- uno::Reference< lang::XMultiServiceFactory> xFactory(
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getParametricPolyPolygonFactory() );
-
- if( xFactory.is() )
- {
- rendering::Texture aTexture;
-
- aTexture.RepeatModeX = rendering::TexturingMode::CLAMP;
- aTexture.RepeatModeY = rendering::TexturingMode::CLAMP;
- aTexture.Alpha = 1.0;
-
-
- // setup start/end color values
- // ----------------------------
-
- // scale color coefficients with gradient intensities
- const sal_uInt16 nStartIntensity( rGradient.GetStartIntensity() );
- ::Color aVCLStartColor( rGradient.GetStartColor() );
- aVCLStartColor.SetRed( (sal_uInt8)(aVCLStartColor.GetRed() * nStartIntensity / 100) );
- aVCLStartColor.SetGreen( (sal_uInt8)(aVCLStartColor.GetGreen() * nStartIntensity / 100) );
- aVCLStartColor.SetBlue( (sal_uInt8)(aVCLStartColor.GetBlue() * nStartIntensity / 100) );
-
- const sal_uInt16 nEndIntensity( rGradient.GetEndIntensity() );
- ::Color aVCLEndColor( rGradient.GetEndColor() );
- aVCLEndColor.SetRed( (sal_uInt8)(aVCLEndColor.GetRed() * nEndIntensity / 100) );
- aVCLEndColor.SetGreen( (sal_uInt8)(aVCLEndColor.GetGreen() * nEndIntensity / 100) );
- aVCLEndColor.SetBlue( (sal_uInt8)(aVCLEndColor.GetBlue() * nEndIntensity / 100) );
-
- uno::Reference<rendering::XColorSpace> xColorSpace(
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace());
- const uno::Sequence< double > aStartColor(
- ::vcl::unotools::colorToDoubleSequence( aVCLStartColor,
- xColorSpace ));
- const uno::Sequence< double > aEndColor(
- ::vcl::unotools::colorToDoubleSequence( aVCLEndColor,
- xColorSpace ));
-
- uno::Sequence< uno::Sequence < double > > aColors(2);
- uno::Sequence< double > aStops(2);
-
- if( rGradient.GetStyle() == GradientStyle_AXIAL )
- {
- aStops.realloc(3);
- aColors.realloc(3);
-
- aStops[0] = 0.0;
- aStops[1] = 0.5;
- aStops[2] = 1.0;
-
- aColors[0] = aEndColor;
- aColors[1] = aStartColor;
- aColors[2] = aEndColor;
- }
- else
- {
- aStops[0] = 0.0;
- aStops[1] = 1.0;
-
- aColors[0] = aStartColor;
- aColors[1] = aEndColor;
- }
-
- const ::basegfx::B2DRectangle aBounds(
- ::basegfx::tools::getRange(aDevicePoly) );
- const ::basegfx::B2DVector aOffset(
- rGradient.GetOfsX() / 100.0,
- rGradient.GetOfsY() / 100.0);
- double fRotation( rGradient.GetAngle() * M_PI / 1800.0 );
- const double fBorder( rGradient.GetBorder() / 100.0 );
-
- basegfx::B2DHomMatrix aRot90;
- aRot90.rotate(M_PI_2);
-
- basegfx::ODFGradientInfo aGradInfo;
- OUString aGradientService;
- switch( rGradient.GetStyle() )
- {
- case GradientStyle_LINEAR:
- aGradInfo = basegfx::tools::createLinearODFGradientInfo(
- aBounds,
- nSteps,
- fBorder,
- fRotation);
- // map ODF to svg gradient orientation - x
- // instead of y direction
- aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aRot90);
- aGradientService = "LinearGradient";
- break;
-
- case GradientStyle_AXIAL:
- {
- // Adapt the border so that it is suitable
- // for the axial gradient. An axial
- // gradient consists of two linear
- // gradients. Each of those covers half
- // of the total size. In order to
- // compensate for the condensed display of
- // the linear gradients, we have to
- // enlarge the area taken up by the actual
- // gradient (1-fBorder). After that we
- // have to turn the result back into a
- // border value, hence the second (left
- // most 1-...
- const double fAxialBorder (1-2*(1-fBorder));
- aGradInfo = basegfx::tools::createAxialODFGradientInfo(
- aBounds,
- nSteps,
- fAxialBorder,
- fRotation);
- // map ODF to svg gradient orientation - x
- // instead of y direction
- aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aRot90);
-
- // map ODF axial gradient to 3-stop linear
- // gradient - shift left by 0.5
- basegfx::B2DHomMatrix aShift;
-
- aShift.translate(-0.5,0);
- aGradInfo.setTextureTransform(aGradInfo.getTextureTransform() * aShift);
- aGradientService = "LinearGradient";
- break;
- }
-
- case GradientStyle_RADIAL:
- aGradInfo = basegfx::tools::createRadialODFGradientInfo(
- aBounds,
- aOffset,
- nSteps,
- fBorder);
- aGradientService = "EllipticalGradient";
- break;
-
- case GradientStyle_ELLIPTICAL:
- aGradInfo = basegfx::tools::createEllipticalODFGradientInfo(
- aBounds,
- aOffset,
- nSteps,
- fBorder,
- fRotation);
- aGradientService = "EllipticalGradient";
- break;
-
- case GradientStyle_SQUARE:
- aGradInfo = basegfx::tools::createSquareODFGradientInfo(
- aBounds,
- aOffset,
- nSteps,
- fBorder,
- fRotation);
- aGradientService = "RectangularGradient";
- break;
-
- case GradientStyle_RECT:
- aGradInfo = basegfx::tools::createRectangularODFGradientInfo(
- aBounds,
- aOffset,
- nSteps,
- fBorder,
- fRotation);
- aGradientService = "RectangularGradient";
- break;
-
- default:
- ENSURE_OR_THROW( false,
- "ImplRenderer::createGradientAction(): Unexpected gradient type" );
- break;
- }
-
- ::basegfx::unotools::affineMatrixFromHomMatrix( aTexture.AffineTransform,
- aGradInfo.getTextureTransform() );
-
- uno::Sequence<uno::Any> args(3);
- beans::PropertyValue aProp;
- aProp.Name = "Colors";
- aProp.Value <<= aColors;
- args[0] <<= aProp;
- aProp.Name = "Stops";
- aProp.Value <<= aStops;
- args[1] <<= aProp;
- aProp.Name = "AspectRatio";
- aProp.Value <<= aGradInfo.getAspectRatio();
- args[2] <<= aProp;
-
- aTexture.Gradient.set(
- xFactory->createInstanceWithArguments(aGradientService,
- args),
- uno::UNO_QUERY);
- if( aTexture.Gradient.is() )
- {
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- aDevicePoly,
- rParms.mrCanvas,
- rParms.mrStates.getState(),
- aTexture ) );
-
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- rParms.mrCurrActionIndex ) );
-
- rParms.mrCurrActionIndex += pPolyAction->getActionCount()-1;
- }
-
- // done, using native gradients
- return;
- }
- }
- }
-
- // cannot currently use native canvas gradients, as a
- // finite step size is given (this funny feature is not
- // supported by the XCanvas API)
- rParms.mrStates.pushState(PUSH_ALL);
-
- if( !bIsPolygonRectangle )
- {
- // only clip, if given polygon is not a rectangle in
- // the first place (the gradient is always limited to
- // the given bound rect)
- updateClipping(
- aDevicePoly,
- rParms,
- true );
- }
-
- GDIMetaFile aTmpMtf;
- rParms.mrVDev.AddGradientActions( rPoly.GetBoundRect(),
- rGradient,
- aTmpMtf );
-
- createActions( aTmpMtf, rParms, bSubsettableActions );
-
- rParms.mrStates.popState();
- }
-
- uno::Reference< rendering::XCanvasFont > ImplRenderer::createFont( double& o_rFontRotation,
- const ::Font& rFont,
- const ActionFactoryParameters& rParms ) const
- {
- rendering::FontRequest aFontRequest;
-
- if( rParms.mrParms.maFontName.is_initialized() )
- aFontRequest.FontDescription.FamilyName = *rParms.mrParms.maFontName;
- else
- aFontRequest.FontDescription.FamilyName = rFont.GetName();
-
- aFontRequest.FontDescription.StyleName = rFont.GetStyleName();
-
- aFontRequest.FontDescription.IsSymbolFont = (rFont.GetCharSet() == RTL_TEXTENCODING_SYMBOL) ? util::TriState_YES : util::TriState_NO;
- aFontRequest.FontDescription.IsVertical = rFont.IsVertical() ? util::TriState_YES : util::TriState_NO;
-
- // TODO(F2): improve vclenum->panose conversion
- aFontRequest.FontDescription.FontDescription.Weight =
- rParms.mrParms.maFontWeight.is_initialized() ?
- *rParms.mrParms.maFontWeight :
- ::canvas::tools::numeric_cast<sal_Int8>( ::basegfx::fround( rFont.GetWeight() ) );
- aFontRequest.FontDescription.FontDescription.Letterform =
- rParms.mrParms.maFontLetterForm.is_initialized() ?
- *rParms.mrParms.maFontLetterForm :
- (rFont.GetItalic() == ITALIC_NONE) ? 0 : 9;
- aFontRequest.FontDescription.FontDescription.Proportion =
- rParms.mrParms.maFontProportion.is_initialized() ?
- *rParms.mrParms.maFontProportion :
- (rFont.GetPitch() == PITCH_FIXED)
- ? rendering::PanoseProportion::MONO_SPACED
- : rendering::PanoseProportion::ANYTHING;
-
- LanguageType aLang = rFont.GetLanguage();
- aFontRequest.Locale = LanguageTag::convertToLocale( aLang, false);
-
- // setup state-local text transformation,
- // if the font be rotated
- const short nFontAngle( rFont.GetOrientation() );
- if( nFontAngle != 0 )
- {
- // set to unity transform rotated by font angle
- const double nAngle( nFontAngle * (F_PI / 1800.0) );
- o_rFontRotation = -nAngle;
- }
- else
- {
- o_rFontRotation = 0.0;
- }
-
- geometry::Matrix2D aFontMatrix;
- ::canvas::tools::setIdentityMatrix2D( aFontMatrix );
-
- // TODO(F2): use correct scale direction, font
- // height might be width or anything else
-
- // TODO(Q3): This code smells of programming by
- // coincidence (the next two if statements)
- const ::Size rFontSizeLog( rFont.GetSize() );
- const sal_Int32 nFontWidthLog = rFontSizeLog.Width();
- if( nFontWidthLog != 0 )
- {
- ::Font aTestFont = rFont;
- aTestFont.SetWidth( 0 );
- sal_Int32 nNormalWidth = rParms.mrVDev.GetFontMetric( aTestFont ).GetWidth();
- if( nNormalWidth != nFontWidthLog )
- if( nNormalWidth )
- aFontMatrix.m00 = (double)nFontWidthLog / nNormalWidth;
- }
-
- // #i52608# apply map mode scale also to font matrix - an
- // anisotrophic mapmode must be reflected in an
- // anisotrophic font matrix scale.
- const OutDevState& rState( rParms.mrStates.getState() );
- if( !::basegfx::fTools::equal(
- rState.mapModeTransform.get(0,0),
- rState.mapModeTransform.get(1,1)) )
- {
- const double nScaleX( rState.mapModeTransform.get(0,0) );
- const double nScaleY( rState.mapModeTransform.get(1,1) );
-
- // note: no reason to check for division by zero, we
- // always have the value closer (or equal) to zero as
- // the nominator.
- if( fabs(nScaleX) < fabs(nScaleY) )
- aFontMatrix.m00 *= nScaleX / nScaleY;
- else
- aFontMatrix.m11 *= nScaleY / nScaleX;
- }
- aFontRequest.CellSize = (rState.mapModeTransform * ::vcl::unotools::b2DSizeFromSize(rFontSizeLog)).getY();
-
- return rParms.mrCanvas->getUNOCanvas()->createFont( aFontRequest,
- uno::Sequence< beans::PropertyValue >(),
- aFontMatrix );
- }
-
- // create text effects such as shadow/relief/embossed
- void ImplRenderer::createTextAction( const ::Point& rStartPoint,
- const OUString rString,
- int nIndex,
- int nLength,
- const sal_Int32* pCharWidths,
- const ActionFactoryParameters& rParms,
- bool bSubsettableActions )
- {
- ENSURE_OR_THROW( nIndex >= 0 && nLength <= rString.getLength() + nIndex,
- "ImplRenderer::createTextWithEffectsAction(): Invalid text index" );
-
- if( !nLength )
- return; // zero-length text, no visible output
-
- const OutDevState& rState( rParms.mrStates.getState() );
-
- // TODO(F2): implement all text effects
- // if( rState.textAlignment ); // TODO(F2): NYI
-
- ::Color aShadowColor( COL_AUTO );
- ::Color aReliefColor( COL_AUTO );
- ::Size aShadowOffset;
- ::Size aReliefOffset;
-
- uno::Reference<rendering::XColorSpace> xColorSpace(
- rParms.mrCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
-
- if( rState.isTextEffectShadowSet )
- {
- // calculate shadow offset (similar to outdev3.cxx)
- // TODO(F3): better match with outdev3.cxx
- sal_Int32 nShadowOffset = static_cast<sal_Int32>(1.5 + ((rParms.mrVDev.GetFont().GetHeight()-24.0)/24.0));
- if( nShadowOffset < 1 )
- nShadowOffset = 1;
-
- aShadowOffset.setWidth( nShadowOffset );
- aShadowOffset.setHeight( nShadowOffset );
-
- // determine shadow color (from outdev3.cxx)
- ::Color aTextColor = ::vcl::unotools::doubleSequenceToColor(
- rState.textColor, xColorSpace );
- bool bIsDark = (aTextColor.GetColor() == COL_BLACK)
- || (aTextColor.GetLuminance() < 8);
-
- aShadowColor = bIsDark ? COL_LIGHTGRAY : COL_BLACK;
- aShadowColor.SetTransparency( aTextColor.GetTransparency() );
- }
-
- if( rState.textReliefStyle )
- {
- // calculate relief offset (similar to outdev3.cxx)
- sal_Int32 nReliefOffset = rParms.mrVDev.PixelToLogic( Size( 1, 1 ) ).Height();
- nReliefOffset += nReliefOffset/2;
- if( nReliefOffset < 1 )
- nReliefOffset = 1;
-
- if( rState.textReliefStyle == RELIEF_ENGRAVED )
- nReliefOffset = -nReliefOffset;
-
- aReliefOffset.setWidth( nReliefOffset );
- aReliefOffset.setHeight( nReliefOffset );
-
- // determine relief color (from outdev3.cxx)
- ::Color aTextColor = ::vcl::unotools::doubleSequenceToColor(
- rState.textColor, xColorSpace );
-
- aReliefColor = ::Color( COL_LIGHTGRAY );
-
- // we don't have a automatic color, so black is always
- // drawn on white (literally copied from
- // vcl/source/gdi/outdev3.cxx)
- if( aTextColor.GetColor() == COL_BLACK )
- {
- aTextColor = ::Color( COL_WHITE );
- rParms.mrStates.getState().textColor =
- ::vcl::unotools::colorToDoubleSequence(
- aTextColor, xColorSpace );
- }
-
- if( aTextColor.GetColor() == COL_WHITE )
- aReliefColor = ::Color( COL_BLACK );
- aReliefColor.SetTransparency( aTextColor.GetTransparency() );
- }
-
- // create the actual text action
- ActionSharedPtr pTextAction(
- TextActionFactory::createTextAction(
- rStartPoint,
- aReliefOffset,
- aReliefColor,
- aShadowOffset,
- aShadowColor,
- rString,
- nIndex,
- nLength,
- pCharWidths,
- rParms.mrVDev,
- rParms.mrCanvas,
- rState,
- rParms.mrParms,
- bSubsettableActions ) );
-
- ActionSharedPtr pStrikeoutTextAction;
-
- if ( rState.textStrikeoutStyle == STRIKEOUT_X || rState.textStrikeoutStyle == STRIKEOUT_SLASH )
- {
- long nWidth = rParms.mrVDev.GetTextWidth( rString,nIndex,nLength );
-
- sal_Unicode pChars[4];
- if ( rState.textStrikeoutStyle == STRIKEOUT_X )
- pChars[0] = 'X';
- else
- pChars[0] = '/';
- pChars[3]=pChars[2]=pChars[1]=pChars[0];
-
- long nStrikeoutWidth = (rParms.mrVDev.GetTextWidth(
- OUString(pChars, SAL_N_ELEMENTS(pChars))) + 2) / 4;
-
- if( nStrikeoutWidth <= 0 )
- nStrikeoutWidth = 1;
-
- long nMaxWidth = nStrikeoutWidth/2;
- if ( nMaxWidth < 2 )
- nMaxWidth = 2;
- nMaxWidth += nWidth + 1;
-
- long nFullStrikeoutWidth = 0;
- OUString aStrikeoutText;
- while( (nFullStrikeoutWidth+=nStrikeoutWidth ) < nMaxWidth+1 )
- aStrikeoutText += OUString(pChars[0]);
-
- sal_Int32 nLen = aStrikeoutText.getLength();
-
- if( nLen )
- {
- long nInterval = ( nWidth - nStrikeoutWidth * nLen ) / nLen;
- nStrikeoutWidth += nInterval;
- sal_Int32* pStrikeoutCharWidths = new sal_Int32[nLen];
-
- for ( int i = 0;i<nLen; i++)
- {
- pStrikeoutCharWidths[i] = nStrikeoutWidth;
- }
-
- for ( int i = 1;i< nLen; i++ )
- {
- pStrikeoutCharWidths[ i ] += pStrikeoutCharWidths[ i-1 ];
- }
-
- sal_Int32 nStartPos = 0;
-
- pStrikeoutTextAction =
- TextActionFactory::createTextAction(
- rStartPoint,
- aReliefOffset,
- aReliefColor,
- aShadowOffset,
- aShadowColor,
- aStrikeoutText,
- nStartPos,
- aStrikeoutText.getLength(),
- pStrikeoutCharWidths,
- rParms.mrVDev,
- rParms.mrCanvas,
- rState,
- rParms.mrParms,
- bSubsettableActions ) ;
- }
- }
-
- if( pTextAction )
- {
- maActions.push_back(
- MtfAction(
- pTextAction,
- rParms.mrCurrActionIndex ) );
-
- if ( pStrikeoutTextAction )
- {
- maActions.push_back(
- MtfAction(
- pStrikeoutTextAction,
- rParms.mrCurrActionIndex ) );
- }
-
- rParms.mrCurrActionIndex += pTextAction->getActionCount()-1;
- }
- }
-
- void ImplRenderer::updateClipping( const ::basegfx::B2DPolyPolygon& rClipPoly,
- const ActionFactoryParameters& rParms,
- bool bIntersect )
- {
- ::cppcanvas::internal::OutDevState& rState( rParms.mrStates.getState() );
- ::basegfx::B2DPolyPolygon aClipPoly( rClipPoly );
-
- const bool bEmptyClipRect( rState.clipRect.IsEmpty() );
- const bool bEmptyClipPoly( rState.clip.count() == 0 );
-
- ENSURE_OR_THROW( bEmptyClipPoly || bEmptyClipRect,
- "ImplRenderer::updateClipping(): Clip rect and polygon are both set!" );
-
- if( !bIntersect ||
- (bEmptyClipRect && bEmptyClipPoly) )
- {
- rState.clip = rClipPoly;
- }
- else
- {
- if( !bEmptyClipRect )
- {
- // TODO(P3): Use Liang-Barsky polygon clip here,
- // after all, one object is just a rectangle!
-
- // convert rect to polygon beforehand, must revert
- // to general polygon clipping here.
- rState.clip = ::basegfx::B2DPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- // #121100# VCL rectangular clips always
- // include one more pixel to the right
- // and the bottom
- ::basegfx::B2DRectangle( rState.clipRect.Left(),
- rState.clipRect.Top(),
- rState.clipRect.Right()+1,
- rState.clipRect.Bottom()+1 ) ) );
- }
-
- // AW: Simplified
- rState.clip = basegfx::tools::clipPolyPolygonOnPolyPolygon(
- aClipPoly, rState.clip, true, false);
- }
-
- // by now, our clip resides in the OutDevState::clip
- // poly-polygon.
- rState.clipRect.SetEmpty();
-
- if( rState.clip.count() == 0 )
- {
- if( rState.clipRect.IsEmpty() )
- {
- rState.xClipPoly.clear();
- }
- else
- {
- rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rParms.mrCanvas->getUNOCanvas()->getDevice(),
- ::basegfx::B2DPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- // #121100# VCL rectangular clips
- // always include one more pixel to
- // the right and the bottom
- ::basegfx::B2DRectangle( rState.clipRect.Left(),
- rState.clipRect.Top(),
- rState.clipRect.Right()+1,
- rState.clipRect.Bottom()+1 ) ) ) );
- }
- }
- else
- {
- rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rParms.mrCanvas->getUNOCanvas()->getDevice(),
- rState.clip );
- }
- }
-
- void ImplRenderer::updateClipping( const ::Rectangle& rClipRect,
- const ActionFactoryParameters& rParms,
- bool bIntersect )
- {
- ::cppcanvas::internal::OutDevState& rState( rParms.mrStates.getState() );
-
- const bool bEmptyClipRect( rState.clipRect.IsEmpty() );
- const bool bEmptyClipPoly( rState.clip.count() == 0 );
-
- ENSURE_OR_THROW( bEmptyClipPoly || bEmptyClipRect,
- "ImplRenderer::updateClipping(): Clip rect and polygon are both set!" );
-
- if( !bIntersect ||
- (bEmptyClipRect && bEmptyClipPoly) )
- {
- rState.clipRect = rClipRect;
- rState.clip.clear();
- }
- else if( bEmptyClipPoly )
- {
- rState.clipRect.Intersection( rClipRect );
- rState.clip.clear();
- }
- else
- {
- // TODO(P3): Handle a fourth case here, when all clip
- // polygons are rectangular, once B2DMultiRange's
- // sweep line implementation is done.
-
- // general case: convert to polygon and clip
- // -----------------------------------------
-
- // convert rect to polygon beforehand, must revert
- // to general polygon clipping here.
- ::basegfx::B2DPolyPolygon aClipPoly(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( rClipRect.Left(),
- rClipRect.Top(),
- rClipRect.Right(),
- rClipRect.Bottom() ) ) );
-
- rState.clipRect.SetEmpty();
-
- // AW: Simplified
- rState.clip = basegfx::tools::clipPolyPolygonOnPolyPolygon(
- aClipPoly, rState.clip, true, false);
- }
-
- if( rState.clip.count() == 0 )
- {
- if( rState.clipRect.IsEmpty() )
- {
- rState.xClipPoly.clear();
- }
- else
- {
- rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rParms.mrCanvas->getUNOCanvas()->getDevice(),
- ::basegfx::B2DPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- // #121100# VCL rectangular clips
- // always include one more pixel to
- // the right and the bottom
- ::basegfx::B2DRectangle( rState.clipRect.Left(),
- rState.clipRect.Top(),
- rState.clipRect.Right()+1,
- rState.clipRect.Bottom()+1 ) ) ) );
- }
- }
- else
- {
- rState.xClipPoly = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rParms.mrCanvas->getUNOCanvas()->getDevice(),
- rState.clip );
- }
- }
-
- bool ImplRenderer::createActions( GDIMetaFile& rMtf,
- const ActionFactoryParameters& rFactoryParms,
- bool bSubsettableActions )
- {
- /* TODO(P2): interpret mtf-comments
- ================================
-
- - gradient fillings (do that via comments)
-
- - think about mapping. _If_ we do everything in logical
- coordinates (which would solve the probs for stroke
- widths and text offsets), then we would have to
- recalc scaling for every drawing operation. This is
- because the outdev map mode might change at any time.
- Also keep in mind, that, although we've double precision
- float arithmetic now, different offsets might still
- generate different roundings (aka
- 'OutputDevice::SetPixelOffset())
-
- */
-
- // alias common parameters
- VectorOfOutDevStates& rStates(rFactoryParms.mrStates);
- const CanvasSharedPtr& rCanvas(rFactoryParms.mrCanvas);
- ::VirtualDevice& rVDev(rFactoryParms.mrVDev);
- const Parameters& rParms(rFactoryParms.mrParms);
- sal_Int32& io_rCurrActionIndex(rFactoryParms.mrCurrActionIndex);
-
-
- // Loop over every metaaction
- // ==========================
- MetaAction* pCurrAct;
-
- // TODO(P1): think about caching
- for( pCurrAct=rMtf.FirstAction();
- pCurrAct;
- pCurrAct = rMtf.NextAction() )
- {
- // execute every action, to keep VDev state up-to-date
- // currently used only for
- // - the map mode
- // - the line/fill color when processing a META_TRANSPARENT_ACTION
- // - SetFont to process font metric specific actions
- pCurrAct->Execute( &rVDev );
-
- SAL_INFO("cppcanvas.emf", "MTF\trecord type: 0x" << pCurrAct->GetType() << " (" << pCurrAct->GetType() << ")");
-
- switch( pCurrAct->GetType() )
- {
- // ------------------------------------------------------------
-
- // In the first part of this monster-switch, we
- // handle all state-changing meta actions. These
- // are all handled locally.
-
- // ------------------------------------------------------------
-
- case META_PUSH_ACTION:
- {
- MetaPushAction* pPushAction = static_cast<MetaPushAction*>(pCurrAct);
- rStates.pushState(pPushAction->GetFlags());
- }
- break;
-
- case META_POP_ACTION:
- rStates.popState();
- break;
-
- case META_TEXTLANGUAGE_ACTION:
- // FALLTHROUGH intended
- case META_REFPOINT_ACTION:
- // handled via pCurrAct->Execute( &rVDev )
- break;
-
- case META_MAPMODE_ACTION:
- // modify current mapModeTransformation
- // transformation, such that subsequent
- // coordinates map correctly
- tools::calcLogic2PixelAffineTransform( rStates.getState().mapModeTransform,
- rVDev );
- break;
-
- // monitor clip regions, to assemble clip polygon on our own
- case META_CLIPREGION_ACTION:
- {
- MetaClipRegionAction* pClipAction = static_cast<MetaClipRegionAction*>(pCurrAct);
-
- if( !pClipAction->IsClipping() )
- {
- // clear clipping
- rStates.getState().clip.clear();
- }
- else
- {
- if( !pClipAction->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
- {
- VERBOSE_TRACE( "ImplRenderer::createActions(): non-polygonal clip "
- "region encountered, falling back to bounding box!" );
-
- // #121806# explicitly kept integer
- Rectangle aClipRect(
- rVDev.LogicToPixel(
- pClipAction->GetRegion().GetBoundRect() ) );
-
- // intersect current clip with given rect
- updateClipping(
- aClipRect,
- rFactoryParms,
- false );
- }
- else
- {
- // set new clip polygon (don't intersect
- // with old one, just set it)
-
- // #121806# explicitly kept integer
- basegfx::B2DPolyPolygon aPolyPolygon(pClipAction->GetRegion().GetAsB2DPolyPolygon());
-
- aPolyPolygon.transform(rVDev.GetViewTransformation());
- updateClipping(
- aPolyPolygon,
- rFactoryParms,
- false );
- }
- }
-
- break;
- }
-
- case META_ISECTRECTCLIPREGION_ACTION:
- {
- MetaISectRectClipRegionAction* pClipAction = static_cast<MetaISectRectClipRegionAction*>(pCurrAct);
-
- // #121806# explicitly kept integer
- Rectangle aClipRect(
- rVDev.LogicToPixel( pClipAction->GetRect() ) );
-
- // intersect current clip with given rect
- updateClipping(
- aClipRect,
- rFactoryParms,
- true );
-
- break;
- }
-
- case META_ISECTREGIONCLIPREGION_ACTION:
- {
- MetaISectRegionClipRegionAction* pClipAction = static_cast<MetaISectRegionClipRegionAction*>(pCurrAct);
-
- if( !pClipAction->GetRegion().HasPolyPolygonOrB2DPolyPolygon() )
- {
- VERBOSE_TRACE( "ImplRenderer::createActions(): non-polygonal clip "
- "region encountered, falling back to bounding box!" );
-
- // #121806# explicitly kept integer
- Rectangle aClipRect(
- rVDev.LogicToPixel( pClipAction->GetRegion().GetBoundRect() ) );
-
- // intersect current clip with given rect
- updateClipping(
- aClipRect,
- rFactoryParms,
- true );
- }
- else
- {
- // intersect current clip with given clip polygon
-
- // #121806# explicitly kept integer
- basegfx::B2DPolyPolygon aPolyPolygon(pClipAction->GetRegion().GetAsB2DPolyPolygon());
-
- aPolyPolygon.transform(rVDev.GetViewTransformation());
- updateClipping(
- aPolyPolygon,
- rFactoryParms,
- true );
- }
-
- break;
- }
-
- case META_MOVECLIPREGION_ACTION:
- // TODO(F2): NYI
- break;
-
- case META_LINECOLOR_ACTION:
- if( !rParms.maLineColor.is_initialized() )
- {
- setStateColor( static_cast<MetaLineColorAction*>(pCurrAct),
- rStates.getState().isLineColorSet,
- rStates.getState().lineColor,
- rCanvas );
- }
- else
- {
- // #120994# Do switch on/off LineColor, even when a overriding one is set
- bool bSetting(static_cast<MetaLineColorAction*>(pCurrAct)->IsSetting());
-
- rStates.getState().isLineColorSet = bSetting;
- }
- break;
-
- case META_FILLCOLOR_ACTION:
- if( !rParms.maFillColor.is_initialized() )
- {
- setStateColor( static_cast<MetaFillColorAction*>(pCurrAct),
- rStates.getState().isFillColorSet,
- rStates.getState().fillColor,
- rCanvas );
- }
- else
- {
- // #120994# Do switch on/off FillColor, even when a overriding one is set
- bool bSetting(static_cast<MetaFillColorAction*>(pCurrAct)->IsSetting());
-
- rStates.getState().isFillColorSet = bSetting;
- }
- break;
-
- case META_TEXTCOLOR_ACTION:
- {
- if( !rParms.maTextColor.is_initialized() )
- {
- // Text color is set unconditionally, thus, no
- // use of setStateColor here
- ::Color aColor( static_cast<MetaTextColorAction*>(pCurrAct)->GetColor() );
-
- // force alpha part of color to
- // opaque. transparent painting is done
- // explicitly via META_TRANSPARENT_ACTION
- aColor.SetTransparency(0);
-
- rStates.getState().textColor =
- ::vcl::unotools::colorToDoubleSequence(
- aColor,
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
- }
- }
- break;
-
- case META_TEXTFILLCOLOR_ACTION:
- if( !rParms.maTextColor.is_initialized() )
- {
- setStateColor( static_cast<MetaTextFillColorAction*>(pCurrAct),
- rStates.getState().isTextFillColorSet,
- rStates.getState().textFillColor,
- rCanvas );
- }
- else
- {
- // #120994# Do switch on/off TextFillColor, even when a overriding one is set
- bool bSetting(static_cast<MetaTextFillColorAction*>(pCurrAct)->IsSetting());
-
- rStates.getState().isTextFillColorSet = bSetting;
- }
- break;
-
- case META_TEXTLINECOLOR_ACTION:
- if( !rParms.maTextColor.is_initialized() )
- {
- setStateColor( static_cast<MetaTextLineColorAction*>(pCurrAct),
- rStates.getState().isTextLineColorSet,
- rStates.getState().textLineColor,
- rCanvas );
- }
- else
- {
- // #120994# Do switch on/off TextLineColor, even when a overriding one is set
- bool bSetting(static_cast<MetaTextLineColorAction*>(pCurrAct)->IsSetting());
-
- rStates.getState().isTextLineColorSet = bSetting;
- }
- break;
-
- case META_TEXTALIGN_ACTION:
- {
- ::cppcanvas::internal::OutDevState& rState = rStates.getState();
- const TextAlign eTextAlign( static_cast<MetaTextAlignAction*>(pCurrAct)->GetTextAlign() );
-
- rState.textReferencePoint = eTextAlign;
- }
- break;
-
- case META_FONT_ACTION:
- {
- ::cppcanvas::internal::OutDevState& rState = rStates.getState();
- const ::Font& rFont( static_cast<MetaFontAction*>(pCurrAct)->GetFont() );
-
- rState.xFont = createFont( rState.fontRotation,
- rFont,
- rFactoryParms );
-
- // TODO(Q2): define and use appropriate enumeration types
- rState.textReliefStyle = (sal_Int8)rFont.GetRelief();
- rState.textOverlineStyle = (sal_Int8)rFont.GetOverline();
- rState.textUnderlineStyle = rParms.maFontUnderline.is_initialized() ?
- (*rParms.maFontUnderline ? (sal_Int8)UNDERLINE_SINGLE : (sal_Int8)UNDERLINE_NONE) :
- (sal_Int8)rFont.GetUnderline();
- rState.textStrikeoutStyle = (sal_Int8)rFont.GetStrikeout();
- rState.textEmphasisMarkStyle = (sal_Int8)rFont.GetEmphasisMark();
- rState.isTextEffectShadowSet = (rFont.IsShadow() != sal_False);
- rState.isTextWordUnderlineSet = (rFont.IsWordLineMode() != sal_False);
- rState.isTextOutlineModeSet = (rFont.IsOutline() != sal_False);
- }
- break;
-
- case META_RASTEROP_ACTION:
- // TODO(F2): NYI
- break;
-
- case META_LAYOUTMODE_ACTION:
- {
- // TODO(F2): A lot is missing here
- int nLayoutMode = static_cast<MetaLayoutModeAction*>(pCurrAct)->GetLayoutMode();
- ::cppcanvas::internal::OutDevState& rState = rStates.getState();
- switch( nLayoutMode & (TEXT_LAYOUT_BIDI_RTL|TEXT_LAYOUT_BIDI_STRONG) )
- {
- case TEXT_LAYOUT_BIDI_LTR:
- rState.textDirection = rendering::TextDirection::WEAK_LEFT_TO_RIGHT;
- break;
-
- case (TEXT_LAYOUT_BIDI_LTR | TEXT_LAYOUT_BIDI_STRONG):
- rState.textDirection = rendering::TextDirection::STRONG_LEFT_TO_RIGHT;
- break;
-
- case TEXT_LAYOUT_BIDI_RTL:
- rState.textDirection = rendering::TextDirection::WEAK_RIGHT_TO_LEFT;
- break;
-
- case (TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_BIDI_STRONG):
- rState.textDirection = rendering::TextDirection::STRONG_RIGHT_TO_LEFT;
- break;
- }
-
- rState.textAlignment = 0; // TODO(F2): rendering::TextAlignment::LEFT_ALIGNED;
- if( (nLayoutMode & (TEXT_LAYOUT_BIDI_RTL | TEXT_LAYOUT_TEXTORIGIN_RIGHT) )
- && !(nLayoutMode & TEXT_LAYOUT_TEXTORIGIN_LEFT ) )
- {
- rState.textAlignment = 1; // TODO(F2): rendering::TextAlignment::RIGHT_ALIGNED;
- }
- }
- break;
-
- // ------------------------------------------------------------
-
- // In the second part of this monster-switch, we
- // handle all recursing meta actions. These are the
- // ones generating a metafile by themselves, which is
- // then processed by recursively calling this method.
-
- // ------------------------------------------------------------
-
- case META_GRADIENT_ACTION:
- {
- MetaGradientAction* pGradAct = static_cast<MetaGradientAction*>(pCurrAct);
- createGradientAction( ::Polygon( pGradAct->GetRect() ),
- pGradAct->GetGradient(),
- rFactoryParms,
- true,
- bSubsettableActions );
- }
- break;
-
- case META_HATCH_ACTION:
- {
- // TODO(F2): use native Canvas hatches here
- GDIMetaFile aTmpMtf;
-
- rVDev.AddHatchActions( static_cast<MetaHatchAction*>(pCurrAct)->GetPolyPolygon(),
- static_cast<MetaHatchAction*>(pCurrAct)->GetHatch(),
- aTmpMtf );
- createActions( aTmpMtf, rFactoryParms,
- bSubsettableActions );
- }
- break;
-
- case META_EPS_ACTION:
- {
- MetaEPSAction* pAct = static_cast<MetaEPSAction*>(pCurrAct);
- const GDIMetaFile& rSubstitute = pAct->GetSubstitute();
-
- // #121806# explicitly kept integer
- const Size aMtfSize( rSubstitute.GetPrefSize() );
- const Size aMtfSizePixPre( rVDev.LogicToPixel( aMtfSize,
- rSubstitute.GetPrefMapMode() ) );
-
- // #i44110# correct null-sized output - there
- // are metafiles which have zero size in at
- // least one dimension
- const Size aMtfSizePix( ::std::max( aMtfSizePixPre.Width(), 1L ),
- ::std::max( aMtfSizePixPre.Height(), 1L ) );
-
- // Setup local transform, such that the
- // metafile renders itself into the given
- // output rectangle
- rStates.pushState(PUSH_ALL);
-
- rVDev.Push();
- rVDev.SetMapMode( rSubstitute.GetPrefMapMode() );
-
- const ::Point& rPos( rVDev.LogicToPixel( pAct->GetPoint() ) );
- const ::Size& rSize( rVDev.LogicToPixel( pAct->GetSize() ) );
-
- rStates.getState().transform.translate( rPos.X(),
- rPos.Y() );
- rStates.getState().transform.scale( (double)rSize.Width() / aMtfSizePix.Width(),
- (double)rSize.Height() / aMtfSizePix.Height() );
-
- createActions( const_cast<GDIMetaFile&>(pAct->GetSubstitute()),
- rFactoryParms,
- bSubsettableActions );
-
- rVDev.Pop();
- rStates.popState();
- }
- break;
-
- // handle metafile comments, to retrieve
- // meta-information for gradients, fills and
- // strokes. May skip actions, and may recurse.
- case META_COMMENT_ACTION:
- {
- MetaCommentAction* pAct = static_cast<MetaCommentAction*>(pCurrAct);
-
- // Handle gradients
- if (pAct->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_BEGIN")))
- {
- MetaGradientExAction* pGradAction = NULL;
- bool bDone( false );
- while( !bDone &&
- (pCurrAct=rMtf.NextAction()) != NULL )
- {
- switch( pCurrAct->GetType() )
- {
- // extract gradient info
- case META_GRADIENTEX_ACTION:
- pGradAction = static_cast<MetaGradientExAction*>(pCurrAct);
- break;
-
- // skip broken-down rendering, output gradient when sequence is ended
- case META_COMMENT_ACTION:
- if( static_cast<MetaCommentAction*>(pCurrAct)->GetComment().equalsIgnoreAsciiCaseL(RTL_CONSTASCII_STRINGPARAM("XGRAD_SEQ_END")) )
- {
- bDone = true;
-
- if( pGradAction )
- {
- createGradientAction( pGradAction->GetPolyPolygon(),
- pGradAction->GetGradient(),
- rFactoryParms,
- false,
- bSubsettableActions );
- }
- }
- break;
- }
- }
- }
- // TODO(P2): Handle drawing layer strokes, via
- // XPATHSTROKE_SEQ_BEGIN comment
-
- // Handle drawing layer fills
- else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("XPATHFILL_SEQ_BEGIN")) )
- {
- const sal_uInt8* pData = pAct->GetData();
- if ( pData )
- {
- SvMemoryStream aMemStm( (void*)pData, pAct->GetDataSize(), STREAM_READ );
-
- SvtGraphicFill aFill;
- aMemStm >> aFill;
-
- // TODO(P2): Also handle gradients and
- // hatches like this
-
- // only evaluate comment for pure
- // bitmap fills. If a transparency
- // gradient is involved (denoted by
- // the FloatTransparent action), take
- // the normal meta actions.
- if( aFill.getFillType() == SvtGraphicFill::fillTexture &&
- !isActionContained( rMtf,
- "XPATHFILL_SEQ_END",
- META_FLOATTRANSPARENT_ACTION ) )
- {
- rendering::Texture aTexture;
-
- // TODO(F1): the SvtGraphicFill
- // can also transport metafiles
- // here, handle that case, too
- Graphic aGraphic;
- aFill.getGraphic( aGraphic );
-
- BitmapEx aBmpEx( aGraphic.GetBitmapEx() );
- const ::Size aBmpSize( aBmpEx.GetSizePixel() );
-
- ::SvtGraphicFill::Transform aTransform;
- aFill.getTransform( aTransform );
-
- ::basegfx::B2DHomMatrix aMatrix;
-
- // convert to basegfx matrix
- aMatrix.set(0,0, aTransform.matrix[ 0 ] );
- aMatrix.set(0,1, aTransform.matrix[ 1 ] );
- aMatrix.set(0,2, aTransform.matrix[ 2 ] );
- aMatrix.set(1,0, aTransform.matrix[ 3 ] );
- aMatrix.set(1,1, aTransform.matrix[ 4 ] );
- aMatrix.set(1,2, aTransform.matrix[ 5 ] );
-
- ::basegfx::B2DHomMatrix aScale;
- aScale.scale( aBmpSize.Width(),
- aBmpSize.Height() );
-
- // post-multiply with the bitmap
- // size (XCanvas' texture assumes
- // the given bitmap to be
- // normalized to [0,1]x[0,1]
- // rectangle)
- aMatrix = aMatrix * aScale;
-
- // pre-multiply with the
- // logic-to-pixel scale factor
- // (the metafile comment works in
- // logical coordinates).
- ::basegfx::B2DHomMatrix aLogic2PixelTransform;
- aMatrix *= tools::calcLogic2PixelLinearTransform( aLogic2PixelTransform,
- rVDev );
-
- ::basegfx::unotools::affineMatrixFromHomMatrix(
- aTexture.AffineTransform,
- aMatrix );
-
- aTexture.Alpha = 1.0 - aFill.getTransparency();
- aTexture.Bitmap =
- ::vcl::unotools::xBitmapFromBitmapEx(
- rCanvas->getUNOCanvas()->getDevice(),
- aBmpEx );
- if( aFill.isTiling() )
- {
- aTexture.RepeatModeX = rendering::TexturingMode::REPEAT;
- aTexture.RepeatModeY = rendering::TexturingMode::REPEAT;
- }
- else
- {
- aTexture.RepeatModeX = rendering::TexturingMode::NONE;
- aTexture.RepeatModeY = rendering::TexturingMode::NONE;
- }
-
- ::PolyPolygon aPath;
- aFill.getPath( aPath );
-
- ::basegfx::B2DPolyPolygon aPoly( aPath.getB2DPolyPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- aPoly,
- rCanvas,
- rStates.getState(),
- aTexture ) );
-
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pPolyAction->getActionCount()-1;
- }
-
- // skip broken-down render output
- skipContent( rMtf,
- "XPATHFILL_SEQ_END",
- io_rCurrActionIndex );
- }
- }
- }
- // Handle drawing layer fills
- else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EMF_PLUS")) ) {
- static int count = -1, limit = 0x7fffffff;
- if (count == -1) {
- count = 0;
- if (char *env = getenv ("EMF_PLUS_LIMIT")) {
- limit = atoi (env);
- SAL_INFO ("cppcanvas.emf", "EMF+ records limit: " << limit);
- }
- }
- SAL_INFO ("cppcanvas.emf", "EMF+ passed to canvas mtf renderer, size: " << pAct->GetDataSize ());
- if (count < limit)
- processEMFPlus( pAct, rFactoryParms, rStates.getState(), rCanvas );
- count ++;
- } else if( pAct->GetComment().equalsL(RTL_CONSTASCII_STRINGPARAM("EMF_PLUS_HEADER_INFO")) ) {
- SAL_INFO ("cppcanvas.emf", "EMF+ passed to canvas mtf renderer - header info, size: " << pAct->GetDataSize ());
-
- SvMemoryStream rMF ((void*) pAct->GetData (), pAct->GetDataSize (), STREAM_READ);
-
- rMF >> nFrameLeft >> nFrameTop >> nFrameRight >> nFrameBottom;
- SAL_INFO ("cppcanvas.emf", "EMF+ picture frame: " << nFrameLeft << "," << nFrameTop << " - " << nFrameRight << "," << nFrameBottom);
- rMF >> nPixX >> nPixY >> nMmX >> nMmY;
- SAL_INFO ("cppcanvas.emf", "EMF+ ref device pixel size: " << nPixX << "x" << nPixY << " mm size: " << nMmX << "x" << nMmY);
-
- rMF >> aBaseTransform;
- //aWorldTransform.Set (aBaseTransform);
- }
- }
- break;
-
- // ------------------------------------------------------------
-
- // In the third part of this monster-switch, we
- // handle all 'acting' meta actions. These are all
- // processed by constructing function objects for
- // them, which will later ease caching.
-
- // ------------------------------------------------------------
-
- case META_POINT_ACTION:
- {
- const OutDevState& rState( rStates.getState() );
- if( rState.lineColor.getLength() )
- {
- ActionSharedPtr pPointAction(
- internal::PointActionFactory::createPointAction(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint(
- static_cast<MetaPointAction*>(pCurrAct)->GetPoint() ),
- rCanvas,
- rState ) );
-
- if( pPointAction )
- {
- maActions.push_back(
- MtfAction(
- pPointAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pPointAction->getActionCount()-1;
- }
- }
- }
- break;
-
- case META_PIXEL_ACTION:
- {
- const OutDevState& rState( rStates.getState() );
- if( rState.lineColor.getLength() )
- {
- ActionSharedPtr pPointAction(
- internal::PointActionFactory::createPointAction(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint(
- static_cast<MetaPixelAction*>(pCurrAct)->GetPoint() ),
- rCanvas,
- rState,
- static_cast<MetaPixelAction*>(pCurrAct)->GetColor() ) );
-
- if( pPointAction )
- {
- maActions.push_back(
- MtfAction(
- pPointAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pPointAction->getActionCount()-1;
- }
- }
- }
- break;
-
- case META_LINE_ACTION:
- {
- const OutDevState& rState( rStates.getState() );
- if( rState.lineColor.getLength() )
- {
- MetaLineAction* pLineAct = static_cast<MetaLineAction*>(pCurrAct);
-
- const LineInfo& rLineInfo( pLineAct->GetLineInfo() );
-
- const ::basegfx::B2DPoint aStartPoint(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint( pLineAct->GetStartPoint() ));
- const ::basegfx::B2DPoint aEndPoint(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint( pLineAct->GetEndPoint() ));
-
- ActionSharedPtr pLineAction;
-
- if( rLineInfo.IsDefault() )
- {
- // plain hair line
- pLineAction =
- internal::LineActionFactory::createLineAction(
- aStartPoint,
- aEndPoint,
- rCanvas,
- rState );
-
- if( pLineAction )
- {
- maActions.push_back(
- MtfAction(
- pLineAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pLineAction->getActionCount()-1;
- }
- }
- else if( LINE_NONE != rLineInfo.GetStyle() )
- {
- // 'thick' line
- rendering::StrokeAttributes aStrokeAttributes;
-
- setupStrokeAttributes( aStrokeAttributes,
- rFactoryParms,
- rLineInfo );
-
- // XCanvas can only stroke polygons,
- // not simple lines - thus, handle
- // this case via the polypolygon
- // action
- ::basegfx::B2DPolygon aPoly;
- aPoly.append( aStartPoint );
- aPoly.append( aEndPoint );
- pLineAction =
- internal::PolyPolyActionFactory::createPolyPolyAction(
- ::basegfx::B2DPolyPolygon( aPoly ),
- rCanvas, rState, aStrokeAttributes );
-
- if( pLineAction )
- {
- maActions.push_back(
- MtfAction(
- pLineAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pLineAction->getActionCount()-1;
- }
- }
- // else: line style is default
- // (i.e. invisible), don't generate action
- }
- }
- break;
-
- case META_RECT_ACTION:
- {
- const Rectangle& rRect(
- static_cast<MetaRectAction*>(pCurrAct)->GetRect() );
-
- if( rRect.IsEmpty() )
- break;
-
- const OutDevState& rState( rStates.getState() );
- const ::basegfx::B2DPoint aTopLeftPixel(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint( rRect.TopLeft() ) );
- const ::basegfx::B2DPoint aBottomRightPixel(
- rState.mapModeTransform * ::vcl::unotools::b2DPointFromPoint( rRect.BottomRight() ) +
- // #121100# OutputDevice::DrawRect() fills
- // rectangles Apple-like, i.e. with one
- // additional pixel to the right and bottom.
- ::basegfx::B2DPoint(1,1) );
-
- createFillAndStroke( ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRange( aTopLeftPixel,
- aBottomRightPixel )),
- rFactoryParms );
- break;
- }
-
- case META_ROUNDRECT_ACTION:
- {
- const Rectangle& rRect(
- static_cast<MetaRoundRectAction*>(pCurrAct)->GetRect());
-
- if( rRect.IsEmpty() )
- break;
-
- ::basegfx::B2DPolygon aPoly(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRange(
- ::vcl::unotools::b2DPointFromPoint( rRect.TopLeft() ),
- ::vcl::unotools::b2DPointFromPoint( rRect.BottomRight() ) +
- ::basegfx::B2DPoint(1,1) ),
- ( (double) static_cast<MetaRoundRectAction*>(pCurrAct)->GetHorzRound() ) / rRect.GetWidth(),
- ( (double) static_cast<MetaRoundRectAction*>(pCurrAct)->GetVertRound() ) / rRect.GetHeight() ) );
- aPoly.transform( rStates.getState().mapModeTransform );
-
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_ELLIPSE_ACTION:
- {
- const Rectangle& rRect(
- static_cast<MetaEllipseAction*>(pCurrAct)->GetRect() );
-
- if( rRect.IsEmpty() )
- break;
-
- const ::basegfx::B2DRange aRange(
- ::vcl::unotools::b2DPointFromPoint( rRect.TopLeft() ),
- ::vcl::unotools::b2DPointFromPoint( rRect.BottomRight() ) +
- ::basegfx::B2DPoint(1,1) );
-
- ::basegfx::B2DPolygon aPoly(
- ::basegfx::tools::createPolygonFromEllipse(
- aRange.getCenter(),
- aRange.getWidth(),
- aRange.getHeight() ));
- aPoly.transform( rStates.getState().mapModeTransform );
-
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_ARC_ACTION:
- {
- // TODO(F1): Missing basegfx functionality. Mind empty rects!
- const Polygon aToolsPoly( static_cast<MetaArcAction*>(pCurrAct)->GetRect(),
- static_cast<MetaArcAction*>(pCurrAct)->GetStartPoint(),
- static_cast<MetaArcAction*>(pCurrAct)->GetEndPoint(), POLY_ARC );
- ::basegfx::B2DPolygon aPoly( aToolsPoly.getB2DPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
-
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_PIE_ACTION:
- {
- // TODO(F1): Missing basegfx functionality. Mind empty rects!
- const Polygon aToolsPoly( static_cast<MetaPieAction*>(pCurrAct)->GetRect(),
- static_cast<MetaPieAction*>(pCurrAct)->GetStartPoint(),
- static_cast<MetaPieAction*>(pCurrAct)->GetEndPoint(), POLY_PIE );
- ::basegfx::B2DPolygon aPoly( aToolsPoly.getB2DPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
-
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_CHORD_ACTION:
- {
- // TODO(F1): Missing basegfx functionality. Mind empty rects!
- const Polygon aToolsPoly( static_cast<MetaChordAction*>(pCurrAct)->GetRect(),
- static_cast<MetaChordAction*>(pCurrAct)->GetStartPoint(),
- static_cast<MetaChordAction*>(pCurrAct)->GetEndPoint(), POLY_CHORD );
- ::basegfx::B2DPolygon aPoly( aToolsPoly.getB2DPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
-
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_POLYLINE_ACTION:
- {
- const OutDevState& rState( rStates.getState() );
- if( rState.lineColor.getLength() ||
- rState.fillColor.getLength() )
- {
- MetaPolyLineAction* pPolyLineAct = static_cast<MetaPolyLineAction*>(pCurrAct);
-
- const LineInfo& rLineInfo( pPolyLineAct->GetLineInfo() );
- ::basegfx::B2DPolygon aPoly( pPolyLineAct->GetPolygon().getB2DPolygon() );
- aPoly.transform( rState.mapModeTransform );
-
- ActionSharedPtr pLineAction;
-
- if( rLineInfo.IsDefault() )
- {
- // plain hair line polygon
- pLineAction =
- internal::PolyPolyActionFactory::createLinePolyPolyAction(
- ::basegfx::B2DPolyPolygon(aPoly),
- rCanvas,
- rState );
-
- if( pLineAction )
- {
- maActions.push_back(
- MtfAction(
- pLineAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pLineAction->getActionCount()-1;
- }
- }
- else if( LINE_NONE != rLineInfo.GetStyle() )
- {
- // 'thick' line polygon
- rendering::StrokeAttributes aStrokeAttributes;
-
- setupStrokeAttributes( aStrokeAttributes,
- rFactoryParms,
- rLineInfo );
-
- pLineAction =
- internal::PolyPolyActionFactory::createPolyPolyAction(
- ::basegfx::B2DPolyPolygon(aPoly),
- rCanvas,
- rState,
- aStrokeAttributes ) ;
-
- if( pLineAction )
- {
- maActions.push_back(
- MtfAction(
- pLineAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pLineAction->getActionCount()-1;
- }
- }
- // else: line style is default
- // (i.e. invisible), don't generate action
- }
- }
- break;
-
- case META_POLYGON_ACTION:
- {
- ::basegfx::B2DPolygon aPoly( static_cast<MetaPolygonAction*>(pCurrAct)->GetPolygon().getB2DPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_POLYPOLYGON_ACTION:
- {
- ::basegfx::B2DPolyPolygon aPoly( static_cast<MetaPolyPolygonAction*>(pCurrAct)->GetPolyPolygon().getB2DPolyPolygon() );
- aPoly.transform( rStates.getState().mapModeTransform );
- createFillAndStroke( aPoly,
- rFactoryParms );
- }
- break;
-
- case META_BMP_ACTION:
- {
- MetaBmpAction* pAct = static_cast<MetaBmpAction*>(pCurrAct);
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- pAct->GetBitmap(),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_BMPSCALE_ACTION:
- {
- MetaBmpScaleAction* pAct = static_cast<MetaBmpScaleAction*>(pCurrAct);
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- pAct->GetBitmap(),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_BMPSCALEPART_ACTION:
- {
- MetaBmpScalePartAction* pAct = static_cast<MetaBmpScalePartAction*>(pCurrAct);
-
- // crop bitmap to given source rectangle (no
- // need to copy and convert the whole bitmap)
- Bitmap aBmp( pAct->GetBitmap() );
- const Rectangle aCropRect( pAct->GetSrcPoint(),
- pAct->GetSrcSize() );
- aBmp.Crop( aCropRect );
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- aBmp,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetDestPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetDestSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_BMPEX_ACTION:
- {
- MetaBmpExAction* pAct = static_cast<MetaBmpExAction*>(pCurrAct);
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- pAct->GetBitmapEx(),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_BMPEXSCALE_ACTION:
- {
- MetaBmpExScaleAction* pAct = static_cast<MetaBmpExScaleAction*>(pCurrAct);
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- pAct->GetBitmapEx(),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_BMPEXSCALEPART_ACTION:
- {
- MetaBmpExScalePartAction* pAct = static_cast<MetaBmpExScalePartAction*>(pCurrAct);
-
- // crop bitmap to given source rectangle (no
- // need to copy and convert the whole bitmap)
- BitmapEx aBmp( pAct->GetBitmapEx() );
- const Rectangle aCropRect( pAct->GetSrcPoint(),
- pAct->GetSrcSize() );
- aBmp.Crop( aCropRect );
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- aBmp,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetDestPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetDestSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_MASK_ACTION:
- {
- MetaMaskAction* pAct = static_cast<MetaMaskAction*>(pCurrAct);
-
- // create masked BitmapEx right here, as the
- // canvas does not provide equivalent
- // functionality
- BitmapEx aBmp( createMaskBmpEx( pAct->GetBitmap(),
- pAct->GetColor() ));
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- aBmp,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_MASKSCALE_ACTION:
- {
- MetaMaskScaleAction* pAct = static_cast<MetaMaskScaleAction*>(pCurrAct);
-
- // create masked BitmapEx right here, as the
- // canvas does not provide equivalent
- // functionality
- BitmapEx aBmp( createMaskBmpEx( pAct->GetBitmap(),
- pAct->GetColor() ));
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- aBmp,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_MASKSCALEPART_ACTION:
- {
- MetaMaskScalePartAction* pAct = static_cast<MetaMaskScalePartAction*>(pCurrAct);
-
- // create masked BitmapEx right here, as the
- // canvas does not provide equivalent
- // functionality
- BitmapEx aBmp( createMaskBmpEx( pAct->GetBitmap(),
- pAct->GetColor() ));
-
- // crop bitmap to given source rectangle (no
- // need to copy and convert the whole bitmap)
- const Rectangle aCropRect( pAct->GetSrcPoint(),
- pAct->GetSrcSize() );
- aBmp.Crop( aCropRect );
-
- ActionSharedPtr pBmpAction(
- internal::BitmapActionFactory::createBitmapAction(
- aBmp,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetDestPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetDestSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pBmpAction )
- {
- maActions.push_back(
- MtfAction(
- pBmpAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pBmpAction->getActionCount()-1;
- }
- }
- break;
-
- case META_GRADIENTEX_ACTION:
- // TODO(F1): use native Canvas gradients here
- // action is ignored here, because redundant to META_GRADIENT_ACTION
- break;
-
- case META_WALLPAPER_ACTION:
- // TODO(F2): NYI
- break;
-
- case META_TRANSPARENT_ACTION:
- {
- const OutDevState& rState( rStates.getState() );
- if( rState.lineColor.getLength() ||
- rState.fillColor.getLength() )
- {
- MetaTransparentAction* pAct = static_cast<MetaTransparentAction*>(pCurrAct);
- ::basegfx::B2DPolyPolygon aPoly( pAct->GetPolyPolygon().getB2DPolyPolygon() );
- aPoly.transform( rState.mapModeTransform );
-
- ActionSharedPtr pPolyAction(
- internal::PolyPolyActionFactory::createPolyPolyAction(
- aPoly,
- rCanvas,
- rState,
- pAct->GetTransparence() ) );
-
- if( pPolyAction )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pPolyAction->getActionCount()-1;
- }
- }
- }
- break;
-
- case META_FLOATTRANSPARENT_ACTION:
- {
- MetaFloatTransparentAction* pAct = static_cast<MetaFloatTransparentAction*>(pCurrAct);
-
- internal::MtfAutoPtr pMtf(
- new ::GDIMetaFile( pAct->GetGDIMetaFile() ) );
-
- // TODO(P2): Use native canvas gradients here (saves a lot of UNO calls)
- internal::GradientAutoPtr pGradient(
- new Gradient( pAct->GetGradient() ) );
-
- DBG_TESTSOLARMUTEX();
-
- ActionSharedPtr pFloatTransAction(
- internal::TransparencyGroupActionFactory::createTransparencyGroupAction(
- pMtf,
- pGradient,
- rParms,
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DPointFromPoint( pAct->GetPoint() ),
- rStates.getState().mapModeTransform *
- ::vcl::unotools::b2DSizeFromSize( pAct->GetSize() ),
- rCanvas,
- rStates.getState() ) );
-
- if( pFloatTransAction )
- {
- maActions.push_back(
- MtfAction(
- pFloatTransAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pFloatTransAction->getActionCount()-1;
- }
- }
- break;
-
- case META_TEXT_ACTION:
- {
- MetaTextAction* pAct = static_cast<MetaTextAction*>(pCurrAct);
- OUString sText = pAct->GetText();
-
- if (rVDev.GetDigitLanguage())
- sText = convertToLocalizedNumerals(sText, rVDev.GetDigitLanguage());
-
- createTextAction(
- pAct->GetPoint(),
- sText,
- pAct->GetIndex(),
- pAct->GetLen() == (sal_uInt16)STRING_LEN ? pAct->GetText().getLength() - pAct->GetIndex() : pAct->GetLen(),
- NULL,
- rFactoryParms,
- bSubsettableActions );
- }
- break;
-
- case META_TEXTARRAY_ACTION:
- {
- MetaTextArrayAction* pAct = static_cast<MetaTextArrayAction*>(pCurrAct);
- OUString sText = pAct->GetText();
-
- if (rVDev.GetDigitLanguage())
- sText = convertToLocalizedNumerals(sText, rVDev.GetDigitLanguage());
-
- createTextAction(
- pAct->GetPoint(),
- sText,
- pAct->GetIndex(),
- pAct->GetLen() == (sal_uInt16)STRING_LEN ? pAct->GetText().getLength() - pAct->GetIndex() : pAct->GetLen(),
- pAct->GetDXArray(),
- rFactoryParms,
- bSubsettableActions );
- }
- break;
-
- case META_TEXTLINE_ACTION:
- {
- MetaTextLineAction* pAct = static_cast<MetaTextLineAction*>(pCurrAct);
-
- const OutDevState& rState( rStates.getState() );
- const ::Size aBaselineOffset( tools::getBaselineOffset( rState,
- rVDev ) );
- const ::basegfx::B2DSize aSize( rState.mapModeTransform *
- ::basegfx::B2DSize(pAct->GetWidth(),
- 0 ));
-
- ActionSharedPtr pPolyAction(
- PolyPolyActionFactory::createPolyPolyAction(
- tools::createTextLinesPolyPolygon(
- rState.mapModeTransform *
- ::basegfx::B2DPoint(
- ::vcl::unotools::b2DPointFromPoint(pAct->GetStartPoint()) +
- ::vcl::unotools::b2DSizeFromSize(aBaselineOffset)),
- aSize.getX(),
- tools::createTextLineInfo( rVDev,
- rState )),
- rCanvas,
- rState ) );
-
- if( pPolyAction.get() )
- {
- maActions.push_back(
- MtfAction(
- pPolyAction,
- io_rCurrActionIndex ) );
-
- io_rCurrActionIndex += pPolyAction->getActionCount()-1;
- }
- }
- break;
-
- case META_TEXTRECT_ACTION:
- {
- MetaTextRectAction* pAct = static_cast<MetaTextRectAction*>(pCurrAct);
-
- rStates.pushState(PUSH_ALL);
-
- // use the VDev to break up the text rect
- // action into readily formatted lines
- GDIMetaFile aTmpMtf;
- rVDev.AddTextRectActions( pAct->GetRect(),
- pAct->GetText(),
- pAct->GetStyle(),
- aTmpMtf );
-
- createActions( aTmpMtf,
- rFactoryParms,
- bSubsettableActions );
-
- rStates.popState();
-
- break;
- }
-
- case META_STRETCHTEXT_ACTION:
- {
- MetaStretchTextAction* pAct = static_cast<MetaStretchTextAction*>(pCurrAct);
- OUString sText = pAct->GetText();
-
- if (rVDev.GetDigitLanguage())
- sText = convertToLocalizedNumerals(sText, rVDev.GetDigitLanguage());
-
- const sal_uInt16 nLen( pAct->GetLen() == (sal_uInt16)STRING_LEN ?
- pAct->GetText().getLength() - pAct->GetIndex() : pAct->GetLen() );
-
- // #i70897# Nothing to do, actually...
- if( nLen == 0 )
- break;
-
- // have to fit the text into the given
- // width. This is achieved by internally
- // generating a DX array, and uniformly
- // distributing the excess/insufficient width
- // to every logical character.
- ::boost::scoped_array< sal_Int32 > pDXArray( new sal_Int32[nLen] );
-
- rVDev.GetTextArray( pAct->GetText(), pDXArray.get(),
- pAct->GetIndex(), pAct->GetLen() );
-
- const sal_Int32 nWidthDifference( pAct->GetWidth() - pDXArray[ nLen-1 ] );
-
- // Last entry of pDXArray contains total width of the text
- sal_Int32* p=pDXArray.get();
- for( sal_uInt16 i=1; i<=nLen; ++i )
- {
- // calc ratio for every array entry, to
- // distribute rounding errors 'evenly'
- // across the characters. Note that each
- // entry represents the 'end' position of
- // the corresponding character, thus, we
- // let i run from 1 to nLen.
- *p++ += (sal_Int32)i*nWidthDifference/nLen;
- }
-
- createTextAction(
- pAct->GetPoint(),
- sText,
- pAct->GetIndex(),
- pAct->GetLen() == (sal_uInt16)STRING_LEN ? pAct->GetText().getLength() - pAct->GetIndex() : pAct->GetLen(),
- pDXArray.get(),
- rFactoryParms,
- bSubsettableActions );
- }
- break;
-
- default:
- SAL_WARN( "cppcanvas.emf", "Unknown meta action type encountered" );
- break;
- }
-
- // increment action index (each mtf action counts _at
- // least_ one. Some count for more, therefore,
- // io_rCurrActionIndex is sometimes incremented by
- // pAct->getActionCount()-1 above, the -1 being the
- // correction for the unconditional increment here).
- ++io_rCurrActionIndex;
- }
-
- return true;
- }
-
-
- namespace
- {
- class ActionRenderer
- {
- public:
- ActionRenderer( const ::basegfx::B2DHomMatrix& rTransformation ) :
- maTransformation( rTransformation ),
- mbRet( true )
- {
- }
-
- bool result() const
- {
- return mbRet;
- }
-
- void operator()( const ::cppcanvas::internal::ImplRenderer::MtfAction& rAction )
- {
- // ANDing the result. We want to fail if at least
- // one action failed.
- mbRet &= rAction.mpAction->render( maTransformation );
- }
-
- void operator()( const ::cppcanvas::internal::ImplRenderer::MtfAction& rAction,
- const Action::Subset& rSubset )
- {
- // ANDing the result. We want to fail if at least
- // one action failed.
- mbRet &= rAction.mpAction->renderSubset( maTransformation,
- rSubset );
- }
-
- private:
- ::basegfx::B2DHomMatrix maTransformation;
- bool mbRet;
- };
-
- class AreaQuery
- {
- public:
- AreaQuery( const ::basegfx::B2DHomMatrix& rTransformation ) :
- maTransformation( rTransformation ),
- maBounds()
- {
- }
-
- bool result() const
- {
- return true; // nothing can fail here
- }
-
- void operator()( const ::cppcanvas::internal::ImplRenderer::MtfAction& rAction )
- {
- maBounds.expand( rAction.mpAction->getBounds( maTransformation ) );
- }
-
- void operator()( const ::cppcanvas::internal::ImplRenderer::MtfAction& rAction,
- const Action::Subset& rSubset )
- {
- maBounds.expand( rAction.mpAction->getBounds( maTransformation,
- rSubset ) );
- }
-
- ::basegfx::B2DRange getBounds() const
- {
- return maBounds;
- }
-
- private:
- ::basegfx::B2DHomMatrix maTransformation;
- ::basegfx::B2DRange maBounds;
- };
-
- // Doing that via inline class. Compilers tend to not inline free
- // functions.
- struct UpperBoundActionIndexComparator
- {
- bool operator()( const ::cppcanvas::internal::ImplRenderer::MtfAction& rLHS,
- const ::cppcanvas::internal::ImplRenderer::MtfAction& rRHS )
- {
- const sal_Int32 nLHSCount( rLHS.mpAction ?
- rLHS.mpAction->getActionCount() : 0 );
- const sal_Int32 nRHSCount( rRHS.mpAction ?
- rRHS.mpAction->getActionCount() : 0 );
-
- // compare end of action range, to have an action selected
- // by lower_bound even if the requested index points in
- // the middle of the action's range
- return rLHS.mnOrigIndex + nLHSCount < rRHS.mnOrigIndex + nRHSCount;
- }
- };
-
- /** Algorithm to apply given functor to a subset range
-
- @tpl Functor
-
- Functor to call for each element of the subset
- range. Must provide the following method signatures:
- bool result() (returning false if operation failed)
-
- */
- template< typename Functor > bool
- forSubsetRange( Functor& rFunctor,
- ImplRenderer::ActionVector::const_iterator aRangeBegin,
- ImplRenderer::ActionVector::const_iterator aRangeEnd,
- sal_Int32 nStartIndex,
- sal_Int32 nEndIndex,
- const ImplRenderer::ActionVector::const_iterator& rEnd )
- {
- if( aRangeBegin == aRangeEnd )
- {
- // only a single action. Setup subset, and call functor
- Action::Subset aSubset;
- aSubset.mnSubsetBegin = ::std::max( sal_Int32( 0 ),
- nStartIndex - aRangeBegin->mnOrigIndex );
- aSubset.mnSubsetEnd = ::std::min( aRangeBegin->mpAction->getActionCount(),
- nEndIndex - aRangeBegin->mnOrigIndex );
-
- ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0,
- "ImplRenderer::forSubsetRange(): Invalid indices" );
-
- rFunctor( *aRangeBegin, aSubset );
- }
- else
- {
- // more than one action.
-
- // render partial first, full intermediate, and
- // partial last action
- Action::Subset aSubset;
- aSubset.mnSubsetBegin = ::std::max( sal_Int32( 0 ),
- nStartIndex - aRangeBegin->mnOrigIndex );
- aSubset.mnSubsetEnd = aRangeBegin->mpAction->getActionCount();
-
- ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0,
- "ImplRenderer::forSubsetRange(): Invalid indices" );
-
- rFunctor( *aRangeBegin, aSubset );
-
- // first action rendered, skip to next
- ++aRangeBegin;
-
- // render full middle actions
- while( aRangeBegin != aRangeEnd )
- rFunctor( *aRangeBegin++ );
-
- if( aRangeEnd == rEnd ||
- aRangeEnd->mnOrigIndex > nEndIndex )
- {
- // aRangeEnd denotes end of action vector,
- //
- // or
- //
- // nEndIndex references something _after_
- // aRangeBegin, but _before_ aRangeEnd
- //
- // either way: no partial action left
- return rFunctor.result();
- }
-
- aSubset.mnSubsetBegin = 0;
- aSubset.mnSubsetEnd = nEndIndex - aRangeEnd->mnOrigIndex;
-
- ENSURE_OR_RETURN_FALSE( aSubset.mnSubsetBegin >= 0 && aSubset.mnSubsetEnd >= 0,
- "ImplRenderer::forSubsetRange(): Invalid indices" );
-
- rFunctor( *aRangeEnd, aSubset );
- }
-
- return rFunctor.result();
- }
- }
-
- bool ImplRenderer::getSubsetIndices( sal_Int32& io_rStartIndex,
- sal_Int32& io_rEndIndex,
- ActionVector::const_iterator& o_rRangeBegin,
- ActionVector::const_iterator& o_rRangeEnd ) const
- {
- ENSURE_OR_RETURN_FALSE( io_rStartIndex<=io_rEndIndex,
- "ImplRenderer::getSubsetIndices(): invalid action range" );
-
- ENSURE_OR_RETURN_FALSE( !maActions.empty(),
- "ImplRenderer::getSubsetIndices(): no actions to render" );
-
- const sal_Int32 nMinActionIndex( maActions.front().mnOrigIndex );
- const sal_Int32 nMaxActionIndex( maActions.back().mnOrigIndex +
- maActions.back().mpAction->getActionCount() );
-
- // clip given range to permissible values (there might be
- // ranges before and behind the valid indices)
- io_rStartIndex = ::std::max( nMinActionIndex,
- io_rStartIndex );
- io_rEndIndex = ::std::min( nMaxActionIndex,
- io_rEndIndex );
-
- if( io_rStartIndex == io_rEndIndex ||
- io_rStartIndex > io_rEndIndex )
- {
- // empty range, don't render anything. The second
- // condition e.g. happens if the requested range lies
- // fully before or behind the valid action indices.
- return false;
- }
-
-
- const ActionVector::const_iterator aBegin( maActions.begin() );
- const ActionVector::const_iterator aEnd( maActions.end() );
-
-
- // find start and end action
- // =========================
- o_rRangeBegin = ::std::lower_bound( aBegin, aEnd,
- MtfAction( ActionSharedPtr(), io_rStartIndex ),
- UpperBoundActionIndexComparator() );
- o_rRangeEnd = ::std::lower_bound( aBegin, aEnd,
- MtfAction( ActionSharedPtr(), io_rEndIndex ),
- UpperBoundActionIndexComparator() );
- return true;
- }
-
-
- // Public methods
- // ====================================================================
-
- ImplRenderer::ImplRenderer( const CanvasSharedPtr& rCanvas,
- const GDIMetaFile& rMtf,
- const Parameters& rParams ) :
- CanvasGraphicHelper( rCanvas ),
- maActions()
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::ImplRenderer::ImplRenderer(mtf)" );
-
- OSL_ENSURE( rCanvas.get() != NULL && rCanvas->getUNOCanvas().is(),
- "ImplRenderer::ImplRenderer(): Invalid canvas" );
- OSL_ENSURE( rCanvas->getUNOCanvas()->getDevice().is(),
- "ImplRenderer::ImplRenderer(): Invalid graphic device" );
-
- // make sure canvas and graphic device are valid; action
- // creation don't check that every time
- if( rCanvas.get() == NULL ||
- !rCanvas->getUNOCanvas().is() ||
- !rCanvas->getUNOCanvas()->getDevice().is() )
- {
- // leave actions empty
- return;
- }
-
- VectorOfOutDevStates aStateStack;
-
- VirtualDevice aVDev;
- aVDev.EnableOutput( sal_False );
-
- // Setup VDev for state tracking and mapping
- // =========================================
-
- aVDev.SetMapMode( rMtf.GetPrefMapMode() );
-
- const Size aMtfSize( rMtf.GetPrefSize() );
- const Size aMtfSizePixPre( aVDev.LogicToPixel( aMtfSize,
- rMtf.GetPrefMapMode() ) );
-
- // #i44110# correct null-sized output - there are shapes
- // which have zero size in at least one dimension
- const Size aMtfSizePix( ::std::max( aMtfSizePixPre.Width(), 1L ),
- ::std::max( aMtfSizePixPre.Height(), 1L ) );
-
- sal_Int32 nCurrActions(0);
- ActionFactoryParameters aParms(aStateStack,
- rCanvas,
- aVDev,
- rParams,
- nCurrActions );
-
- // init state stack
- aStateStack.clearStateStack();
-
- // Setup local state, such that the metafile renders
- // itself into a one-by-one square at the origin for
- // identity view and render transformations
- aStateStack.getState().transform.scale( 1.0 / aMtfSizePix.Width(),
- 1.0 / aMtfSizePix.Height() );
-
- tools::calcLogic2PixelAffineTransform( aStateStack.getState().mapModeTransform,
- aVDev );
-
- ColorSharedPtr pColor( getCanvas()->createColor() );
-
- {
- ::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
- // setup default text color to black
- rState.textColor =
- rState.textFillColor =
- rState.textLineColor = pColor->getDeviceColor( 0x000000FF );
- }
-
- // apply overrides from the Parameters struct
- if( rParams.maFillColor.is_initialized() )
- {
- ::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
- rState.isFillColorSet = true;
- rState.fillColor = pColor->getDeviceColor( *rParams.maFillColor );
- }
- if( rParams.maLineColor.is_initialized() )
- {
- ::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
- rState.isLineColorSet = true;
- rState.lineColor = pColor->getDeviceColor( *rParams.maLineColor );
- }
- if( rParams.maTextColor.is_initialized() )
- {
- ::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
- rState.isTextFillColorSet = true;
- rState.isTextLineColorSet = true;
- rState.textColor =
- rState.textFillColor =
- rState.textLineColor = pColor->getDeviceColor( *rParams.maTextColor );
- }
- if( rParams.maFontName.is_initialized() ||
- rParams.maFontWeight.is_initialized() ||
- rParams.maFontLetterForm.is_initialized() ||
- rParams.maFontUnderline.is_initialized() ||
- rParams.maFontProportion.is_initialized() )
- {
- ::cppcanvas::internal::OutDevState& rState = aStateStack.getState();
-
- rState.xFont = createFont( rState.fontRotation,
- ::Font(), // default font
- aParms );
- }
-
- /* EMF+ */
- memset (aObjects, 0, sizeof (aObjects));
- mbMultipart = false;
-
- createActions( const_cast<GDIMetaFile&>(rMtf), // HACK(Q2):
- // we're
- // changing
- // the
- // current
- // action
- // in
- // createActions!
- aParms,
- true // TODO(P1): make subsettability configurable
- );
- }
-
- ImplRenderer::~ImplRenderer()
- {
- // don't leak EMFPObjects
- for(unsigned int i=0; i<SAL_N_ELEMENTS(aObjects); ++i)
- delete aObjects[i];
- }
-
- bool ImplRenderer::drawSubset( sal_Int32 nStartIndex,
- sal_Int32 nEndIndex ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::ImplRenderer::drawSubset()" );
-
- ActionVector::const_iterator aRangeBegin;
- ActionVector::const_iterator aRangeEnd;
-
- try
- {
- if( !getSubsetIndices( nStartIndex, nEndIndex,
- aRangeBegin, aRangeEnd ) )
- return true; // nothing to render (but _that_ was successful)
-
- // now, aRangeBegin references the action in which the
- // subset rendering must start, and aRangeEnd references
- // the action in which the subset rendering must end (it
- // might also end right at the start of the referenced
- // action, such that zero of that action needs to be
- // rendered).
-
-
- // render subset of actions
- // ========================
-
- ::basegfx::B2DHomMatrix aMatrix;
- ::canvas::tools::getRenderStateTransform( aMatrix,
- getRenderState() );
-
- ActionRenderer aRenderer( aMatrix );
-
- return forSubsetRange( aRenderer,
- aRangeBegin,
- aRangeEnd,
- nStartIndex,
- nEndIndex,
- maActions.end() );
- }
- catch( uno::Exception& )
- {
- SAL_WARN("cppcanvas.emf", "" << OUStringToOString(
- comphelper::anyToString( cppu::getCaughtException() ),
- RTL_TEXTENCODING_UTF8 ).getStr() );
-
- // convert error to return value
- return false;
- }
- }
-
- ::basegfx::B2DRange ImplRenderer::getSubsetArea( sal_Int32 nStartIndex,
- sal_Int32 nEndIndex ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::ImplRenderer::getSubsetArea()" );
-
- ActionVector::const_iterator aRangeBegin;
- ActionVector::const_iterator aRangeEnd;
-
- if( !getSubsetIndices( nStartIndex, nEndIndex,
- aRangeBegin, aRangeEnd ) )
- return ::basegfx::B2DRange(); // nothing to render -> empty range
-
- // now, aRangeBegin references the action in which the
- // subset querying must start, and aRangeEnd references
- // the action in which the subset querying must end (it
- // might also end right at the start of the referenced
- // action, such that zero of that action needs to be
- // queried).
-
-
- // query bounds for subset of actions
- // ==================================
-
- ::basegfx::B2DHomMatrix aMatrix;
- ::canvas::tools::getRenderStateTransform( aMatrix,
- getRenderState() );
-
- AreaQuery aQuery( aMatrix );
- forSubsetRange( aQuery,
- aRangeBegin,
- aRangeEnd,
- nStartIndex,
- nEndIndex,
- maActions.end() );
-
- return aQuery.getBounds();
- }
-
- bool ImplRenderer::draw() const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::ImplRenderer::draw()" );
-
- ::basegfx::B2DHomMatrix aMatrix;
- ::canvas::tools::getRenderStateTransform( aMatrix,
- getRenderState() );
-
- try
- {
- return ::std::for_each( maActions.begin(), maActions.end(), ActionRenderer( aMatrix ) ).result();
- }
- catch( uno::Exception& )
- {
- SAL_WARN( "cppcanvas.emf", "" << OUStringToOString(
- comphelper::anyToString( cppu::getCaughtException() ),
- RTL_TEXTENCODING_UTF8 ).getStr() );
-
- return false;
- }
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/lineaction.cxx b/cppcanvas/source/mtfrenderer/lineaction.cxx
deleted file mode 100644
index 6553f34657a1..000000000000
--- a/cppcanvas/source/mtfrenderer/lineaction.cxx
+++ /dev/null
@@ -1,158 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <lineaction.hxx>
-#include <outdevstate.hxx>
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-
-#include <tools/gen.hxx>
-#include <vcl/canvastools.hxx>
-
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <canvas/canvastools.hxx>
-
-#include <boost/utility.hpp>
-
-#include <cppcanvas/canvas.hxx>
-
-#include <mtftools.hxx>
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- namespace
- {
- class LineAction : public Action, private ::boost::noncopyable
- {
- public:
- LineAction( const ::basegfx::B2DPoint&,
- const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- ::basegfx::B2DPoint maStartPoint;
- ::basegfx::B2DPoint maEndPoint;
- CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- };
-
- LineAction::LineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DPoint& rEndPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- maStartPoint( rStartPoint ),
- maEndPoint( rEndPoint ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
- maState.DeviceColor = rState.lineColor;
- }
-
- bool LineAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::LineAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::LineAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- mpCanvas->getUNOCanvas()->drawLine( ::basegfx::unotools::point2DFromB2DPoint(maStartPoint),
- ::basegfx::unotools::point2DFromB2DPoint(maEndPoint),
- mpCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- bool LineAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // line only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return render( rTransformation );
- }
-
- ::basegfx::B2DRange LineAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maStartPoint,
- maEndPoint ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange LineAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // line only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 LineAction::getActionCount() const
- {
- return 1;
- }
- }
-
- ActionSharedPtr LineActionFactory::createLineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DPoint& rEndPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- return ActionSharedPtr( new LineAction( rStartPoint,
- rEndPoint,
- rCanvas,
- rState) );
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/lineaction.hxx b/cppcanvas/source/mtfrenderer/lineaction.hxx
deleted file mode 100644
index 101c598c32a1..000000000000
--- a/cppcanvas/source/mtfrenderer/lineaction.hxx
+++ /dev/null
@@ -1,67 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_LINEACTION_HXX
-#define _CPPCANVAS_LINEACTION_HXX
-
-#include <action.hxx>
-#include <cppcanvas/canvas.hxx>
-
-namespace basegfx {
- class B2DPoint;
-}
-
-
-/* Definition of internal::LineActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- /** Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class LineActionFactory
- {
- public:
- /// Plain hair line from point 1 to point 2
- static ActionSharedPtr createLineAction( const ::basegfx::B2DPoint&,
- const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- private:
- // static factory, disable big four
- LineActionFactory();
- ~LineActionFactory();
- LineActionFactory(const LineActionFactory&);
- LineActionFactory& operator=( const LineActionFactory& );
- };
- }
-}
-
-#endif /* _CPPCANVAS_LINEACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/mtftools.cxx b/cppcanvas/source/mtfrenderer/mtftools.cxx
deleted file mode 100644
index f34487b56b6f..000000000000
--- a/cppcanvas/source/mtfrenderer/mtftools.cxx
+++ /dev/null
@@ -1,621 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <canvas/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <canvas/verbosetrace.hxx>
-#include <com/sun/star/rendering/RenderState.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <basegfx/numeric/ftools.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/vector/b2dvector.hxx>
-#include <canvas/canvastools.hxx>
-#include <vcl/gdimtf.hxx>
-#include <vcl/metaact.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/metric.hxx>
-#include <tools/poly.hxx>
-#include "mtftools.hxx"
-#include "outdevstate.hxx"
-#include "polypolyaction.hxx"
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace tools
- {
- void initRenderState( rendering::RenderState& renderState,
- const ::cppcanvas::internal::OutDevState& outdevState )
- {
- ::canvas::tools::initRenderState( renderState );
- ::canvas::tools::setRenderStateTransform( renderState,
- outdevState.transform );
- renderState.Clip = outdevState.xClipPoly;
- }
-
- ::Size getBaselineOffset( const ::cppcanvas::internal::OutDevState& outdevState,
- const VirtualDevice& rVDev )
- {
- const ::FontMetric& aMetric = rVDev.GetFontMetric();
-
- // calc offset for text output, the XCanvas always renders
- // baseline offset.
- switch( outdevState.textReferencePoint )
- {
- case ALIGN_TOP:
- return ::Size( 0,
- aMetric.GetIntLeading() + aMetric.GetAscent() );
-
- default:
- ENSURE_OR_THROW( false,
- "tools::getBaselineOffset(): Unexpected TextAlign value" );
- // FALLTHROUGH intended (to calm compiler warning - case won't happen)
- case ALIGN_BASELINE:
- return ::Size( 0, 0 );
-
- case ALIGN_BOTTOM:
- return ::Size( 0,
- -aMetric.GetDescent() );
-
- }
- }
-
- ::basegfx::B2DHomMatrix& calcLogic2PixelLinearTransform( ::basegfx::B2DHomMatrix& o_rMatrix,
- const VirtualDevice& rVDev )
- {
- // select size value in the middle of the available range,
- // to have headroom both when map mode scales up, and when
- // it scales down.
- const ::Size aSizeLogic( 0x00010000L,
- 0x00010000L );
-
- const ::Size aSizePixel( rVDev.LogicToPixel( aSizeLogic ) );
-
- o_rMatrix = basegfx::tools::createScaleB2DHomMatrix(
- aSizePixel.Width() / (double)aSizeLogic.Width(),
- aSizePixel.Height() / (double)aSizeLogic.Height() );
-
- return o_rMatrix;
- }
-
- ::basegfx::B2DHomMatrix& calcLogic2PixelAffineTransform( ::basegfx::B2DHomMatrix& o_rMatrix,
- const VirtualDevice& rVDev )
- {
- // retrieves scale
- calcLogic2PixelLinearTransform(o_rMatrix, rVDev);
-
- // translate according to curr map mode/pref map mode offset
- const ::Point aEmptyPoint;
- const ::Point& rTranslatedPoint(
- rVDev.LogicToPixel( aEmptyPoint ));
-
- o_rMatrix.translate(rTranslatedPoint.X(),
- rTranslatedPoint.Y());
-
- return o_rMatrix;
- }
-
- bool modifyClip( rendering::RenderState& o_rRenderState,
- const struct ::cppcanvas::internal::OutDevState& rOutdevState,
- const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2DPoint& rOffset,
- const ::basegfx::B2DVector* pScaling,
- const double* pRotation )
- {
- const bool bOffsetting( !rOffset.equalZero() );
- const bool bScaling( pScaling &&
- pScaling->getX() != 1.0 &&
- pScaling->getY() != 1.0 );
- const bool bRotation( pRotation &&
- *pRotation != 0.0 );
-
- if( !bOffsetting && !bScaling && !bRotation )
- return false; // nothing to do
-
- if( rOutdevState.clip.count() )
- {
- // general polygon case
-
- ::basegfx::B2DPolyPolygon aLocalClip( rOutdevState.clip );
- ::basegfx::B2DHomMatrix aTransform;
-
- if( bOffsetting )
- aTransform.translate( -rOffset.getX(),
- -rOffset.getY() );
- if( bScaling )
- aTransform.scale( 1.0/pScaling->getX(), 1.0/pScaling->getY() );
-
- if( bRotation )
- aTransform.rotate( - *pRotation );
-
- aLocalClip.transform( aTransform );
-
- o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- aLocalClip );
-
- return true;
- }
- else if( !rOutdevState.clipRect.IsEmpty() )
- {
- // simple rect case
-
- const ::Rectangle aLocalClipRect( rOutdevState.clipRect );
-
- if( bRotation )
- {
- // rotation involved - convert to polygon first,
- // then transform that
- ::basegfx::B2DPolygon aLocalClip(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle(
- (double)(aLocalClipRect.Left()),
- (double)(aLocalClipRect.Top()),
- (double)(aLocalClipRect.Right()),
- (double)(aLocalClipRect.Bottom()) ) ) );
- ::basegfx::B2DHomMatrix aTransform;
-
- if( bOffsetting )
- aTransform.translate( -rOffset.getX(),
- -rOffset.getY() );
- if( bScaling )
- aTransform.scale( 1.0/pScaling->getX(), 1.0/pScaling->getY() );
-
- aTransform.rotate( - *pRotation );
-
- aLocalClip.transform( aTransform );
-
- o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- ::basegfx::B2DPolyPolygon( aLocalClip ) );
- }
- else if( bScaling )
- {
- // scale and offset - do it on the fly, have to
- // convert to float anyway.
- o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- ::basegfx::B2DPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle(
- (double)(aLocalClipRect.Left() - rOffset.getX())/pScaling->getX(),
- (double)(aLocalClipRect.Top() - rOffset.getY())/pScaling->getY(),
- (double)(aLocalClipRect.Right() - rOffset.getX())/pScaling->getX(),
- (double)(aLocalClipRect.Bottom() - rOffset.getY())/pScaling->getY() ) ) ) );
- }
- else
- {
- // offset only - do it on the fly, have to convert
- // to float anyway.
- o_rRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- ::basegfx::B2DPolyPolygon(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( aLocalClipRect.Left() - rOffset.getX(),
- aLocalClipRect.Top() - rOffset.getY(),
- aLocalClipRect.Right() - rOffset.getX(),
- aLocalClipRect.Bottom() - rOffset.getY() ) ) ) );
- }
-
- return true;
- }
-
- // empty clip, nothing to do
- return false;
- }
-
- // create overline/underline/strikeout line info struct
- TextLineInfo createTextLineInfo( const ::VirtualDevice& rVDev,
- const ::cppcanvas::internal::OutDevState& rState )
- {
- const sal_Bool bOldMode( rVDev.IsMapModeEnabled() );
-
- // #i68512# Force metric regeneration with mapmode enabled
- // (prolly OutDev bug)
- rVDev.GetFontMetric();
-
- // will restore map mode below
- const_cast< ::VirtualDevice& >(rVDev).EnableMapMode( sal_False );
-
- const ::FontMetric aMetric = rVDev.GetFontMetric();
-
- TextLineInfo aTextInfo(
- (aMetric.GetDescent() + 2) / 4.0,
- ((aMetric.GetIntLeading() + 1.5) / 3.0),
- (aMetric.GetIntLeading() / 2.0) - aMetric.GetAscent(),
- aMetric.GetDescent() / 2.0,
- (aMetric.GetIntLeading() - aMetric.GetAscent()) / 3.0,
- rState.textOverlineStyle,
- rState.textUnderlineStyle,
- rState.textStrikeoutStyle );
-
- const_cast< ::VirtualDevice& >(rVDev).EnableMapMode( bOldMode );
-
- return aTextInfo;
- }
-
- namespace
- {
- void appendRect( ::basegfx::B2DPolyPolygon& o_rPoly,
- const ::basegfx::B2DPoint& rStartPos,
- const double nX1,
- const double nY1,
- const double nX2,
- const double nY2 )
- {
- const double x( rStartPos.getX() );
- const double y( rStartPos.getY() );
-
- o_rPoly.append(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( x + nX1, y + nY1, x + nX2, y + nY2 ) ) );
- }
-
- void appendRect( ::basegfx::B2DPolyPolygon& o_rPoly,
- const double nX1,
- const double nY1,
- const double nX2,
- const double nY2 )
- {
- o_rPoly.append(
- ::basegfx::tools::createPolygonFromRect(
- ::basegfx::B2DRectangle( nX1, nY1, nX2, nY2 ) ) );
- }
-
- void appendDashes( ::basegfx::B2DPolyPolygon& o_rPoly,
- const double nX,
- const double nY,
- const double nLineWidth,
- const double nLineHeight,
- const double nDashWidth,
- const double nDashSkip )
- {
- const sal_Int32 nNumLoops(
- static_cast< sal_Int32 >(
- ::std::max( 1.0,
- nLineWidth / nDashSkip ) + .5) );
-
- double x = nX;
- for( sal_Int32 i=0; i<nNumLoops; ++i )
- {
- appendRect( o_rPoly,
- x, nY,
- x + nDashWidth, nY + nLineHeight );
-
- x += nDashSkip;
- }
- }
- }
-
- // create line actions for text such as underline and
- // strikeout
- ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const ::basegfx::B2DPoint rStartPos,
- const double& rLineWidth,
- const TextLineInfo& rTextLineInfo )
- {
- // fill the polypolygon with all text lines
- ::basegfx::B2DPolyPolygon aTextLinesPolyPoly;
-
- switch( rTextLineInfo.mnOverlineStyle )
- {
- case UNDERLINE_NONE: // nothing to do
- // FALLTHROUGH intended
- case UNDERLINE_DONTKNOW:
- break;
-
- case UNDERLINE_SMALLWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_WAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
- break;
-
- case UNDERLINE_BOLDDOTTED: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASH: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDLONGDASH: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASHDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASHDOTDOT:// TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight );
- break;
-
- case UNDERLINE_DOUBLEWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight * 2.0 ,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset - rTextLineInfo.mnOverlineHeight );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight,
- rLineWidth,
- rTextLineInfo.mnOverlineOffset + rTextLineInfo.mnOverlineHeight * 2.0 );
- break;
-
- case UNDERLINE_DASHDOTDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DOTTED:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineHeight,
- rTextLineInfo.mnOverlineHeight,
- 2*rTextLineInfo.mnOverlineHeight );
- break;
-
- case UNDERLINE_DASHDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DASH:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineHeight,
- 3*rTextLineInfo.mnOverlineHeight,
- 6*rTextLineInfo.mnOverlineHeight );
- break;
-
- case UNDERLINE_LONGDASH:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnOverlineOffset,
- rLineWidth,
- rTextLineInfo.mnOverlineHeight,
- 6*rTextLineInfo.mnOverlineHeight,
- 12*rTextLineInfo.mnOverlineHeight );
- break;
-
- default:
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected overline case" );
- }
-
- switch( rTextLineInfo.mnUnderlineStyle )
- {
- case UNDERLINE_NONE: // nothing to do
- // FALLTHROUGH intended
- case UNDERLINE_DONTKNOW:
- break;
-
- case UNDERLINE_SMALLWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_WAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + rTextLineInfo.mnLineHeight );
- break;
-
- case UNDERLINE_BOLDDOTTED: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASH: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDLONGDASH: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASHDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDDASHDOTDOT:// TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLDWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight );
- break;
-
- case UNDERLINE_DOUBLEWAVE: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset - rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnUnderlineOffset + 2*rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnUnderlineOffset + 3*rTextLineInfo.mnLineHeight );
- break;
-
- case UNDERLINE_DASHDOTDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DOTTED:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnLineHeight,
- rTextLineInfo.mnLineHeight,
- 2*rTextLineInfo.mnLineHeight );
- break;
-
- case UNDERLINE_DASHDOT: // TODO(F3): NYI
- // FALLTHROUGH intended
- case UNDERLINE_DASH:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnLineHeight,
- 3*rTextLineInfo.mnLineHeight,
- 6*rTextLineInfo.mnLineHeight );
- break;
-
- case UNDERLINE_LONGDASH:
- appendDashes(
- aTextLinesPolyPoly,
- rStartPos.getX(),
- rStartPos.getY() + rTextLineInfo.mnUnderlineOffset,
- rLineWidth,
- rTextLineInfo.mnLineHeight,
- 6*rTextLineInfo.mnLineHeight,
- 12*rTextLineInfo.mnLineHeight );
- break;
-
- default:
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected underline case" );
- }
-
- switch( rTextLineInfo.mnStrikeoutStyle )
- {
- case STRIKEOUT_NONE: // nothing to do
- // FALLTHROUGH intended
- case STRIKEOUT_DONTKNOW:
- break;
-
- case STRIKEOUT_SLASH: // TODO(Q1): we should handle this in the text layer
- // FALLTHROUGH intended
- case STRIKEOUT_X:
- break;
-
- case STRIKEOUT_SINGLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + rTextLineInfo.mnLineHeight );
- break;
-
- case STRIKEOUT_BOLD:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight );
- break;
-
- case STRIKEOUT_DOUBLE:
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset - rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset );
-
- appendRect(
- aTextLinesPolyPoly,
- rStartPos,
- 0,
- rTextLineInfo.mnStrikeoutOffset + 2*rTextLineInfo.mnLineHeight,
- rLineWidth,
- rTextLineInfo.mnStrikeoutOffset + 3*rTextLineInfo.mnLineHeight );
- break;
-
- default:
- ENSURE_OR_THROW( false,
- "::cppcanvas::internal::createTextLinesPolyPolygon(): Unexpected strikeout case" );
- }
-
- return aTextLinesPolyPoly;
- }
-
- ::basegfx::B2DRange calcDevicePixelBounds( const ::basegfx::B2DRange& rBounds,
- const rendering::ViewState& viewState,
- const rendering::RenderState& renderState )
- {
- ::basegfx::B2DHomMatrix aTransform;
- ::canvas::tools::mergeViewAndRenderTransform( aTransform,
- viewState,
- renderState );
-
- ::basegfx::B2DRange aTransformedBounds;
- return ::canvas::tools::calcTransformedRectBounds( aTransformedBounds,
- rBounds,
- aTransform );
- }
-
- // create line actions for text such as underline and
- // strikeout
- ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const double& rStartOffset,
- const double& rLineWidth,
- const TextLineInfo& rTextLineInfo )
- {
- return createTextLinesPolyPolygon(
- ::basegfx::B2DPoint( rStartOffset,
- 0.0 ),
- rLineWidth,
- rTextLineInfo );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/mtftools.hxx b/cppcanvas/source/mtfrenderer/mtftools.hxx
deleted file mode 100644
index 323b11e432e7..000000000000
--- a/cppcanvas/source/mtfrenderer/mtftools.hxx
+++ /dev/null
@@ -1,207 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_RENDERER_MTFTOOLS_HXX
-#define _CPPCANVAS_RENDERER_MTFTOOLS_HXX
-
-#include <action.hxx>
-#include <cppcanvas/canvas.hxx>
-
-
-class VirtualDevice;
-class Size;
-
-namespace basegfx
-{
- class B2DVector;
- class B2DPoint;
-}
-namespace com { namespace sun { namespace star { namespace rendering
-{
- struct RenderState;
-} } } }
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
- }
-
- namespace tools
- {
- /** Init render state from OutDevState
-
- This method initializes the given render state object,
- sets up the transformation and the clip from the
- OutDevState.
- */
- void initRenderState( ::com::sun::star::rendering::RenderState& renderState,
- const ::cppcanvas::internal::OutDevState& outdevState );
-
- /** Calc output offset relative to baseline
-
- The XCanvas API always renders text relative to its
- baseline. This method calculates an offset in logical
- coordinates, depending on the OutDevState's
- textReferencePoint and the font currently set, to offset
- the text from the baseline.
-
- @param outdevState
- State to take textReferencePoint from
-
- @param rVDev
- VDev to obtain font metrics from.
- */
- ::Size getBaselineOffset( const ::cppcanvas::internal::OutDevState& outdevState,
- const VirtualDevice& rVDev );
-
- /** Construct a matrix that converts from logical to pixel
- coordinate system.
-
- This method calculates a matrix that approximates the
- VirtualDevice's LogicToPixel conversion (disregarding any
- offset components, thus the 'linear' in the method name -
- the returned matrix is guaranteed to be linear).
-
- @param o_rMatrix
- This matrix will receive the calculated transform, and is
- also returned from this method.
-
- @return the calculated transformation matrix.
- */
- ::basegfx::B2DHomMatrix& calcLogic2PixelLinearTransform( ::basegfx::B2DHomMatrix& o_rMatrix,
- const VirtualDevice& rVDev );
-
- /** Construct a matrix that converts from logical to pixel
- coordinate system.
-
- This method calculates a matrix that approximates the
- VirtualDevice's LogicToPixel conversion.
-
- @param o_rMatrix
- This matrix will receive the calculated transform, and is
- also returned from this method.
-
- @return the calculated transformation matrix.
- */
- ::basegfx::B2DHomMatrix& calcLogic2PixelAffineTransform( ::basegfx::B2DHomMatrix& o_rMatrix,
- const VirtualDevice& rVDev );
-
- /** This method modifies the clip, to cancel the given
- transformation.
-
- As the clip is relative to the render state
- transformation, offsetting or scaling the render state
- must modify the clip, to keep it at the same position
- relative to the primitive at hand
-
- @param o_rRenderState
- Render state to change the clip in
-
- @param rOutdevState
- Input state. Is used to retrieve the original clip from
-
- @param rOffset
- The clip is offsetted by the negative of this value.
-
- @param pScaling
- The clip is inversely scaled by this value (if given)
-
- @param pRotation
- The clip is inversely rotated by this value (if given)
-
- @return true, if the clip has changed, false if not
- */
- bool modifyClip( ::com::sun::star::rendering::RenderState& o_rRenderState,
- const struct ::cppcanvas::internal::OutDevState& rOutdevState,
- const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2DPoint& rOffset,
- const ::basegfx::B2DVector* pScaling,
- const double* pRotation );
-
- struct TextLineInfo
- {
- TextLineInfo( const double& rLineHeight,
- const double& rOverlineHeight,
- const double& rOverlineOffset,
- const double& rUnderlineOffset,
- const double& rStrikeoutOffset,
- sal_Int8 nOverlineStyle,
- sal_Int8 nUnderlineStyle,
- sal_Int8 nStrikeoutStyle ) :
- mnLineHeight( rLineHeight ),
- mnOverlineHeight( rOverlineHeight ),
- mnOverlineOffset( rOverlineOffset ),
- mnUnderlineOffset( rUnderlineOffset ),
- mnStrikeoutOffset( rStrikeoutOffset ),
- mnOverlineStyle( nOverlineStyle ),
- mnUnderlineStyle( nUnderlineStyle ),
- mnStrikeoutStyle( nStrikeoutStyle )
- {
- }
-
- double mnLineHeight;
- double mnOverlineHeight;
- double mnOverlineOffset;
- double mnUnderlineOffset;
- double mnStrikeoutOffset;
- sal_Int8 mnOverlineStyle;
- sal_Int8 mnUnderlineStyle;
- sal_Int8 mnStrikeoutStyle;
- };
-
- /** Transform given bounds to device coordinate system.
- */
- ::basegfx::B2DRange calcDevicePixelBounds( const ::basegfx::B2DRange& rBounds,
- const ::com::sun::star::rendering::ViewState& viewState,
- const ::com::sun::star::rendering::RenderState& renderState );
-
- /** Generate text underline/strikeout info struct from OutDev
- state.
- */
- TextLineInfo createTextLineInfo( const ::VirtualDevice& rVDev,
- const ::cppcanvas::internal::OutDevState& rState );
-
- /** Create a poly-polygon representing the given combination
- of overline, strikeout and underline.
-
- @param rStartOffset
- Offset in X direction, where the underline starts
-
- @param rLineWidth
- Width of the line of text to overline/strikeout/underline
-
- @param rTextLineInfo
- Common info needed for overline/strikeout/underline generation
- */
- ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const double& rStartOffset,
- const double& rLineWidth,
- const TextLineInfo& rTextLineInfo );
-
- ::basegfx::B2DPolyPolygon createTextLinesPolyPolygon( const ::basegfx::B2DPoint rStartPos,
- const double& rLineWidth,
- const TextLineInfo& rTextLineInfo );
- }
-}
-
-#endif /* _CPPCANVAS_RENDERER_MTFTOOLS_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/pointaction.cxx b/cppcanvas/source/mtfrenderer/pointaction.cxx
deleted file mode 100644
index 3349e57996b5..000000000000
--- a/cppcanvas/source/mtfrenderer/pointaction.cxx
+++ /dev/null
@@ -1,178 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-
-#include <sal/types.h>
-#include <vcl/canvastools.hxx>
-
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <canvas/canvastools.hxx>
-
-#include <boost/utility.hpp>
-
-#include "pointaction.hxx"
-#include "outdevstate.hxx"
-#include "cppcanvas/canvas.hxx"
-#include "mtftools.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- namespace
- {
- class PointAction : public Action, private ::boost::noncopyable
- {
- public:
- PointAction( const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState& );
- PointAction( const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState&,
- const ::Color& );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- // default: disabled copy/assignment
- PointAction(const PointAction&);
- PointAction& operator = ( const PointAction& );
-
- ::basegfx::B2DPoint maPoint;
- CanvasSharedPtr mpCanvas;
- ::com::sun::star::rendering::RenderState maState;
- };
-
- PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- maPoint( rPoint ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
- maState.DeviceColor = rState.lineColor;
- }
-
- PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::Color& rAltColor ) :
- maPoint( rPoint ),
- mpCanvas( rCanvas ),
- maState()
- {
- tools::initRenderState(maState,rState);
- maState.DeviceColor = ::vcl::unotools::colorToDoubleSequence(
- rAltColor,
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
- }
-
- bool PointAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PointAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PointAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- mpCanvas->getUNOCanvas()->drawPoint( ::basegfx::unotools::point2DFromB2DPoint(maPoint),
- mpCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- bool PointAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // point only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return render( rTransformation );
- }
-
- ::basegfx::B2DRange PointAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maPoint.getX()-1,
- maPoint.getY()-1,
- maPoint.getX()+1,
- maPoint.getY()+1 ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange PointAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // point only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 PointAction::getActionCount() const
- {
- return 1;
- }
- }
-
- ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState ) );
- }
-
- ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::Color& rColor )
- {
- return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState, rColor ) );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/pointaction.hxx b/cppcanvas/source/mtfrenderer/pointaction.hxx
deleted file mode 100644
index 1487cfe65b9a..000000000000
--- a/cppcanvas/source/mtfrenderer/pointaction.hxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_POINTACTION_HXX
-#define _CPPCANVAS_POINTACTION_HXX
-
-#include <action.hxx>
-#include <cppcanvas/canvas.hxx>
-
-class Color;
-namespace basegfx {
- class B2DPoint;
-}
-
-/* Definition of internal::PointActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- /** Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class PointActionFactory
- {
- public:
- /// Point in current color
- static ActionSharedPtr createPointAction( const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- /// Point in given color
- static ActionSharedPtr createPointAction( const ::basegfx::B2DPoint&,
- const CanvasSharedPtr&,
- const OutDevState&,
- const ::Color& );
-
- private:
- // static factory, disable big four
- PointActionFactory();
- ~PointActionFactory();
- PointActionFactory(const PointActionFactory&);
- PointActionFactory& operator=( const PointActionFactory& );
- };
- }
-}
-
-#endif /* _CPPCANVAS_POINTACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/polypolyaction.cxx b/cppcanvas/source/mtfrenderer/polypolyaction.cxx
deleted file mode 100644
index af08d65435b1..000000000000
--- a/cppcanvas/source/mtfrenderer/polypolyaction.cxx
+++ /dev/null
@@ -1,514 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/TexturingMode.hpp>
-
-#include <sal/types.h>
-#include <vcl/canvastools.hxx>
-
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <canvas/canvastools.hxx>
-
-#include <boost/utility.hpp>
-
-#include "cachedprimitivebase.hxx"
-#include "polypolyaction.hxx"
-#include "outdevstate.hxx"
-#include "mtftools.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- namespace
- {
- class PolyPolyAction : public CachedPrimitiveBase
- {
- public:
- PolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState&,
- bool bFill,
- bool bStroke );
- PolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState&,
- bool bFill,
- bool bStroke,
- int nTransparency );
-
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- using Action::render;
- virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const;
-
- const uno::Reference< rendering::XPolyPolygon2D > mxPolyPoly;
- const ::basegfx::B2DRange maBounds;
- const CanvasSharedPtr mpCanvas;
-
- // stroke color is now implicit: the maState.DeviceColor member
- rendering::RenderState maState;
-
- uno::Sequence< double > maFillColor;
- };
-
- PolyPolyAction::PolyPolyAction( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- bool bFill,
- bool bStroke ) :
- CachedPrimitiveBase( rCanvas, false ),
- mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
- maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
- mpCanvas( rCanvas ),
- maState(),
- maFillColor()
- {
- tools::initRenderState(maState,rState);
-
- if( bFill )
- maFillColor = rState.fillColor;
-
- if( bStroke )
- maState.DeviceColor = rState.lineColor;
- }
-
- PolyPolyAction::PolyPolyAction( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- bool bFill,
- bool bStroke,
- int nTransparency ) :
- CachedPrimitiveBase( rCanvas, false ),
- mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
- maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
- mpCanvas( rCanvas ),
- maState(),
- maFillColor()
- {
- tools::initRenderState(maState,rState);
-
- if( bFill )
- {
- maFillColor = rState.fillColor;
-
- if( maFillColor.getLength() < 4 )
- maFillColor.realloc( 4 );
-
- // TODO(F1): Color management
- // adapt fill color transparency
- maFillColor[3] = 1.0 - nTransparency / 100.0;
- }
-
- if( bStroke )
- {
- maState.DeviceColor = rState.lineColor;
-
- if( maState.DeviceColor.getLength() < 4 )
- maState.DeviceColor.realloc( 4 );
-
- // TODO(F1): Color management
- // adapt fill color transparency
- maState.DeviceColor[3] = 1.0 - nTransparency / 100.0;
- }
- }
-
- bool PolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- if( maFillColor.getLength() )
- {
- // TODO(E3): Use DBO's finalizer here,
- // fillPolyPolygon() might throw
- const uno::Sequence< double > aTmpColor( aLocalState.DeviceColor );
- aLocalState.DeviceColor = maFillColor;
-
- rCachedPrimitive = mpCanvas->getUNOCanvas()->fillPolyPolygon( mxPolyPoly,
- mpCanvas->getViewState(),
- aLocalState );
-
- aLocalState.DeviceColor = aTmpColor;
- }
-
- if( aLocalState.DeviceColor.getLength() )
- {
- rCachedPrimitive = mpCanvas->getUNOCanvas()->drawPolyPolygon( mxPolyPoly,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- return true;
- }
-
- bool PolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return CachedPrimitiveBase::render( rTransformation );
- }
-
- ::basegfx::B2DRange PolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds(
- maBounds,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange PolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 PolyPolyAction::getActionCount() const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
- return 1;
- }
-
-
- // -------------------------------------------------------------------------------
-
- class TexturedPolyPolyAction : public CachedPrimitiveBase
- {
- public:
- TexturedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::Texture& rTexture );
-
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- using Action::render;
- virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const;
-
- const uno::Reference< rendering::XPolyPolygon2D > mxPolyPoly;
- const ::basegfx::B2DRectangle maBounds;
- const CanvasSharedPtr mpCanvas;
-
- // stroke color is now implicit: the maState.DeviceColor member
- rendering::RenderState maState;
- const rendering::Texture maTexture;
- };
-
- TexturedPolyPolyAction::TexturedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::Texture& rTexture ) :
- CachedPrimitiveBase( rCanvas, true ),
- mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
- maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
- mpCanvas( rCanvas ),
- maState(),
- maTexture( rTexture )
- {
- tools::initRenderState(maState,rState);
- }
-
- bool TexturedPolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- uno::Sequence< rendering::Texture > aSeq(1);
- aSeq[0] = maTexture;
-
- rCachedPrimitive = mpCanvas->getUNOCanvas()->fillTexturedPolyPolygon( mxPolyPoly,
- mpCanvas->getViewState(),
- aLocalState,
- aSeq );
- return true;
- }
-
- bool TexturedPolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return CachedPrimitiveBase::render( rTransformation );
- }
-
- ::basegfx::B2DRange TexturedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds(
- maBounds,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange TexturedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 TexturedPolyPolyAction::getActionCount() const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
- return 1;
- }
-
- // -------------------------------------------------------------------------------
-
- class StrokedPolyPolyAction : public CachedPrimitiveBase
- {
- public:
- StrokedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::StrokeAttributes& rStrokeAttributes );
-
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- using Action::render;
- virtual bool renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const;
-
- const uno::Reference< rendering::XPolyPolygon2D > mxPolyPoly;
- const ::basegfx::B2DRectangle maBounds;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- const rendering::StrokeAttributes maStrokeAttributes;
- };
-
- StrokedPolyPolyAction::StrokedPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPolyPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::StrokeAttributes& rStrokeAttributes ) :
- CachedPrimitiveBase( rCanvas, false ),
- mxPolyPoly( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( rCanvas->getUNOCanvas()->getDevice(), rPolyPoly) ),
- maBounds( ::basegfx::tools::getRange(rPolyPoly) ),
- mpCanvas( rCanvas ),
- maState(),
- maStrokeAttributes( rStrokeAttributes )
- {
- tools::initRenderState(maState,rState);
- maState.DeviceColor = rState.lineColor;
- }
-
- bool StrokedPolyPolyAction::renderPrimitive( uno::Reference< rendering::XCachedPrimitive >& rCachedPrimitive,
- const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction::renderPrimitive()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PolyPolyAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- rCachedPrimitive = mpCanvas->getUNOCanvas()->strokePolyPolygon( mxPolyPoly,
- mpCanvas->getViewState(),
- aLocalState,
- maStrokeAttributes );
- return true;
- }
-
- bool StrokedPolyPolyAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, fail if subset
- // requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return false;
-
- return CachedPrimitiveBase::render( rTransformation );
- }
-
- ::basegfx::B2DRange StrokedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds(
- maBounds,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange StrokedPolyPolyAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
-
- // polygon only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 StrokedPolyPolyAction::getActionCount() const
- {
- // TODO(F1): Split up poly-polygon into polygons, or even
- // line segments, when subsets are requested.
- return 1;
- }
- }
-
- ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- OSL_ENSURE( rState.isLineColorSet || rState.isFillColorSet,
- "PolyPolyActionFactory::createPolyPolyAction() with empty line and fill color" );
- return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
- rState.isFillColorSet,
- rState.isLineColorSet ) );
- }
-
- ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::Texture& rTexture )
- {
- return ActionSharedPtr( new TexturedPolyPolyAction( rPoly, rCanvas, rState, rTexture ) );
- }
-
- ActionSharedPtr PolyPolyActionFactory::createLinePolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- OSL_ENSURE( rState.isLineColorSet,
- "PolyPolyActionFactory::createLinePolyPolyAction() called with empty line color" );
-
- return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
- false,
- rState.isLineColorSet ) );
- }
-
- ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const rendering::StrokeAttributes& rStrokeAttributes )
- {
- OSL_ENSURE( rState.isLineColorSet,
- "PolyPolyActionFactory::createPolyPolyAction() for strokes called with empty line color" );
- return ActionSharedPtr( new StrokedPolyPolyAction( rPoly, rCanvas, rState, rStrokeAttributes ) );
- }
-
- ActionSharedPtr PolyPolyActionFactory::createPolyPolyAction( const ::basegfx::B2DPolyPolygon& rPoly,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- int nTransparency )
- {
- OSL_ENSURE( rState.isLineColorSet || rState.isFillColorSet,
- "PolyPolyActionFactory::createPolyPolyAction() with empty line and fill color" );
- return ActionSharedPtr( new PolyPolyAction( rPoly, rCanvas, rState,
- rState.isFillColorSet,
- rState.isLineColorSet,
- nTransparency ) );
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/polypolyaction.hxx b/cppcanvas/source/mtfrenderer/polypolyaction.hxx
deleted file mode 100644
index 47c4e91c204c..000000000000
--- a/cppcanvas/source/mtfrenderer/polypolyaction.hxx
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_POLYPOLYACTION_HXX
-#define _CPPCANVAS_POLYPOLYACTION_HXX
-
-#include <action.hxx>
-#include <cppcanvas/canvas.hxx>
-
-
-namespace basegfx {
- class B2DPolyPolygon;
-}
-namespace com { namespace sun { namespace star { namespace rendering
-{
- struct Texture;
- struct StrokeAttributes;
-} } } }
-
-
-/* Definition of internal::PolyPolyActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- /** Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class PolyPolyActionFactory
- {
- public:
- /// Create polygon, fill/stroke according to state
- static ActionSharedPtr createPolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- /// Create texture-filled polygon
- static ActionSharedPtr createPolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState&,
- const ::com::sun::star::rendering::Texture& );
-
- /// Create line polygon (always stroked, not filled)
- static ActionSharedPtr createLinePolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState& );
-
- /// Create stroked polygon
- static ActionSharedPtr createPolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState&,
- const ::com::sun::star::rendering::StrokeAttributes& );
-
- /// For transparent painting of the given polygon (normally, we take the colors always opaque)
- static ActionSharedPtr createPolyPolyAction( const ::basegfx::B2DPolyPolygon&,
- const CanvasSharedPtr&,
- const OutDevState&,
- int nTransparency );
-
- private:
- // static factory, disable big four
- PolyPolyActionFactory();
- ~PolyPolyActionFactory();
- PolyPolyActionFactory(const PolyPolyActionFactory&);
- PolyPolyActionFactory& operator=( const PolyPolyActionFactory& );
- };
- }
-}
-
-#endif /* _CPPCANVAS_POLYPOLYACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/textaction.cxx b/cppcanvas/source/mtfrenderer/textaction.cxx
deleted file mode 100644
index 927d34424cb1..000000000000
--- a/cppcanvas/source/mtfrenderer/textaction.cxx
+++ /dev/null
@@ -1,2283 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <canvas/debug.hxx>
-#include <tools/diagnose_ex.h>
-#include <canvas/verbosetrace.hxx>
-
-#include <com/sun/star/rendering/PathCapType.hpp>
-#include <com/sun/star/rendering/PathJoinType.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/XCanvasFont.hpp>
-
-#include <basegfx/numeric/ftools.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/range/b2drectangle.hxx>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/polygon/b2dpolypolygontools.hxx>
-#include <basegfx/polygon/b2dpolygontools.hxx>
-#include <basegfx/matrix/b2dhommatrixtools.hxx>
-
-#include <tools/gen.hxx>
-#include <vcl/canvastools.hxx>
-#include <vcl/virdev.hxx>
-
-#include <basegfx/tools/canvastools.hxx>
-#include <canvas/canvastools.hxx>
-
-#include <boost/scoped_array.hpp>
-#include <boost/bind.hpp>
-#include <boost/utility.hpp>
-
-#include "textaction.hxx"
-#include "outdevstate.hxx"
-#include "mtftools.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- namespace
- {
- void init( rendering::RenderState& o_rRenderState,
- const ::basegfx::B2DPoint& rStartPoint,
- const OutDevState& rState,
- const CanvasSharedPtr& rCanvas )
- {
- tools::initRenderState(o_rRenderState,rState);
-
- // #i36950# Offset clip back to origin (as it's also moved
- // by rStartPoint)
- // #i53964# Also take VCL font rotation into account,
- // since this, opposed to the FontMatrix rotation
- // elsewhere, _does_ get incorporated into the render
- // state transform.
- tools::modifyClip( o_rRenderState,
- rState,
- rCanvas,
- rStartPoint,
- NULL,
- &rState.fontRotation );
-
- basegfx::B2DHomMatrix aLocalTransformation(basegfx::tools::createRotateB2DHomMatrix(rState.fontRotation));
- aLocalTransformation.translate( rStartPoint.getX(),
- rStartPoint.getY() );
- ::canvas::tools::appendToRenderState( o_rRenderState,
- aLocalTransformation );
-
- o_rRenderState.DeviceColor = rState.textColor;
- }
-
- void init( rendering::RenderState& o_rRenderState,
- const ::basegfx::B2DPoint& rStartPoint,
- const OutDevState& rState,
- const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2DHomMatrix& rTextTransform )
- {
- init( o_rRenderState, rStartPoint, rState, rCanvas );
-
- // TODO(F2): Also inversely-transform clip with
- // rTextTransform (which is actually rather hard, as the
- // text transform is _prepended_ to the render state)!
-
- // prepend extra font transform to render state
- // (prepend it, because it's interpreted in the unit
- // rect coordinate space)
- ::canvas::tools::prependToRenderState( o_rRenderState,
- rTextTransform );
- }
-
- void init( rendering::RenderState& o_rRenderState,
- uno::Reference< rendering::XCanvasFont >& o_rFont,
- const ::basegfx::B2DPoint& rStartPoint,
- const OutDevState& rState,
- const CanvasSharedPtr& rCanvas )
- {
- // ensure that o_rFont is valid. It is possible that
- // text actions are generated without previously
- // setting a font. Then, just take a default font
- if( !o_rFont.is() )
- {
- // Use completely default FontRequest
- const rendering::FontRequest aFontRequest;
-
- geometry::Matrix2D aFontMatrix;
- ::canvas::tools::setIdentityMatrix2D( aFontMatrix );
-
- o_rFont = rCanvas->getUNOCanvas()->createFont(
- aFontRequest,
- uno::Sequence< beans::PropertyValue >(),
- aFontMatrix );
- }
-
- init( o_rRenderState,
- rStartPoint,
- rState,
- rCanvas );
- }
-
- void init( rendering::RenderState& o_rRenderState,
- uno::Reference< rendering::XCanvasFont >& o_rFont,
- const ::basegfx::B2DPoint& rStartPoint,
- const OutDevState& rState,
- const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2DHomMatrix& rTextTransform )
- {
- init( o_rRenderState, o_rFont, rStartPoint, rState, rCanvas );
-
- // TODO(F2): Also inversely-transform clip with
- // rTextTransform (which is actually rather hard, as the
- // text transform is _prepended_ to the render state)!
-
- // prepend extra font transform to render state
- // (prepend it, because it's interpreted in the unit
- // rect coordinate space)
- ::canvas::tools::prependToRenderState( o_rRenderState,
- rTextTransform );
- }
-
- ::basegfx::B2DPolyPolygon textLinesFromLogicalOffsets( const uno::Sequence< double >& rOffsets,
- const tools::TextLineInfo& rTextLineInfo )
- {
- return tools::createTextLinesPolyPolygon(
- 0.0,
- // extract character cell furthest to the right
- *(::std::max_element(
- rOffsets.getConstArray(),
- rOffsets.getConstArray() + rOffsets.getLength() )),
- rTextLineInfo );
- }
-
- uno::Sequence< double > setupDXArray( const sal_Int32* pCharWidths,
- sal_Int32 nLen,
- const OutDevState& rState )
- {
- // convert character widths from logical units
- uno::Sequence< double > aCharWidthSeq( nLen );
- double* pOutputWidths( aCharWidthSeq.getArray() );
-
- // #143885# maintain (nearly) full precision of DX
- // array, by circumventing integer-based
- // OutDev-mapping
- const double nScale( rState.mapModeTransform.get(0,0) );
- for( int i = 0; i < nLen; ++i )
- {
- // TODO(F2): use correct scale direction
- *pOutputWidths++ = *pCharWidths++ * nScale;
- }
-
- return aCharWidthSeq;
- }
-
- uno::Sequence< double > setupDXArray( const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- VirtualDevice& rVDev,
- const OutDevState& rState )
- {
- // no external DX array given, create one from given
- // string
- ::boost::scoped_array< sal_Int32 > pCharWidths( new sal_Int32[nLen] );
-
- rVDev.GetTextArray( rText, pCharWidths.get(),
- static_cast<sal_uInt16>(nStartPos),
- static_cast<sal_uInt16>(nLen) );
-
- return setupDXArray( pCharWidths.get(), nLen, rState );
- }
-
- ::basegfx::B2DPoint adaptStartPoint( const ::basegfx::B2DPoint& rStartPoint,
- const OutDevState& rState,
- const uno::Sequence< double >& rOffsets )
- {
- ::basegfx::B2DPoint aLocalPoint( rStartPoint );
-
- if( rState.textAlignment )
- {
- // text origin is right, not left. Modify start point
- // accordingly, because XCanvas::drawTextLayout()
- // always aligns left!
-
- const double nOffset( rOffsets[ rOffsets.getLength()-1 ] );
-
- // correct start point for rotated text: rotate around
- // former start point
- aLocalPoint.setX( aLocalPoint.getX() + cos( rState.fontRotation )*nOffset );
- aLocalPoint.setY( aLocalPoint.getY() + sin( rState.fontRotation )*nOffset );
- }
-
- return aLocalPoint;
- }
-
- /** Perform common setup for array text actions
-
- This method creates the XTextLayout object and
- initializes it, e.g. with the logical advancements.
- */
- void initArrayAction( rendering::RenderState& o_rRenderState,
- uno::Reference< rendering::XTextLayout >& o_rTextLayout,
- const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix* pTextTransform )
- {
- ENSURE_OR_THROW( rOffsets.getLength(),
- "::cppcanvas::internal::initArrayAction(): zero-length DX array" );
-
- const ::basegfx::B2DPoint aLocalStartPoint(
- adaptStartPoint( rStartPoint, rState, rOffsets ) );
-
- uno::Reference< rendering::XCanvasFont > xFont( rState.xFont );
-
- if( pTextTransform )
- init( o_rRenderState, xFont, aLocalStartPoint, rState, rCanvas, *pTextTransform );
- else
- init( o_rRenderState, xFont, aLocalStartPoint, rState, rCanvas );
-
- o_rTextLayout = xFont->createTextLayout(
- rendering::StringContext( rText, nStartPos, nLen ),
- rState.textDirection,
- 0 );
-
- ENSURE_OR_THROW( o_rTextLayout.is(),
- "::cppcanvas::internal::initArrayAction(): Invalid font" );
-
- o_rTextLayout->applyLogicalAdvancements( rOffsets );
- }
-
- double getLineWidth( ::VirtualDevice& rVDev,
- const OutDevState& rState,
- const rendering::StringContext& rStringContext )
- {
- // TODO(F2): use correct scale direction
- const ::basegfx::B2DSize aSize( rVDev.GetTextWidth( rStringContext.Text,
- static_cast<sal_uInt16>(rStringContext.StartPosition),
- static_cast<sal_uInt16>(rStringContext.Length) ),
- 0 );
-
- return (rState.mapModeTransform * aSize).getX();
- }
-
- uno::Sequence< double >
- calcSubsetOffsets( rendering::RenderState& io_rRenderState,
- double& o_rMinPos,
- double& o_rMaxPos,
- const uno::Reference< rendering::XTextLayout >& rOrigTextLayout,
- const ::cppcanvas::internal::Action::Subset& rSubset )
- {
- ENSURE_OR_THROW( rSubset.mnSubsetEnd > rSubset.mnSubsetBegin,
- "::cppcanvas::internal::calcSubsetOffsets(): invalid subset range range" );
-
- uno::Sequence< double > aOrigOffsets( rOrigTextLayout->queryLogicalAdvancements() );
- const double* pOffsets( aOrigOffsets.getConstArray() );
-
- ENSURE_OR_THROW( aOrigOffsets.getLength() >= rSubset.mnSubsetEnd,
- "::cppcanvas::internal::calcSubsetOffsets(): invalid subset range range" );
-
- // TODO(F3): It currently seems that for RTL text, the
- // DX offsets are nevertheless increasing in logical
- // text order (I'd expect they are decreasing,
- // mimicking the fact that the text is output
- // right-to-left). This breaks text effects for ALL
- // RTL languages.
-
- // determine leftmost position in given subset range -
- // as the DX array contains the output positions
- // starting with the second character (the first is
- // assumed to have output position 0), correct begin
- // iterator.
- const double nMinPos( rSubset.mnSubsetBegin <= 0 ? 0 :
- *(::std::min_element( pOffsets+rSubset.mnSubsetBegin-1,
- pOffsets+rSubset.mnSubsetEnd )) );
-
- // determine rightmost position in given subset range
- // - as the DX array contains the output positions
- // starting with the second character (the first is
- // assumed to have output position 0), correct begin
- // iterator.
- const double nMaxPos(
- *(::std::max_element( pOffsets + (rSubset.mnSubsetBegin <= 0 ?
- 0 : rSubset.mnSubsetBegin-1),
- pOffsets + rSubset.mnSubsetEnd )) );
-
-
- // adapt render state, to move text output to given offset
- // -------------------------------------------------------
-
- // TODO(F1): Strictly speaking, we also have to adapt
- // the clip here, which normally should _not_ move
- // with the output offset. Neglected for now, as it
- // does not matter for drawing layer output
-
- if( rSubset.mnSubsetBegin > 0 )
- {
- ::basegfx::B2DHomMatrix aTranslation;
- if( rOrigTextLayout->getFont()->getFontRequest().FontDescription.IsVertical )
- {
- // vertical text -> offset in y direction
- aTranslation.translate( 0.0, nMinPos );
- }
- else
- {
- // horizontal text -> offset in x direction
- aTranslation.translate( nMinPos, 0.0 );
- }
-
- ::canvas::tools::appendToRenderState( io_rRenderState,
- aTranslation );
- }
-
-
- // reduce DX array to given substring
- // ----------------------------------
-
- const sal_Int32 nNewElements( rSubset.mnSubsetEnd - rSubset.mnSubsetBegin );
- uno::Sequence< double > aAdaptedOffsets( nNewElements );
- double* pAdaptedOffsets( aAdaptedOffsets.getArray() );
-
- // move to new output position (subtract nMinPos,
- // which is the new '0' position), copy only the range
- // as given by rSubset.
- ::std::transform( pOffsets + rSubset.mnSubsetBegin,
- pOffsets + rSubset.mnSubsetEnd,
- pAdaptedOffsets,
- ::boost::bind( ::std::minus<double>(),
- _1,
- nMinPos ) );
-
- o_rMinPos = nMinPos;
- o_rMaxPos = nMaxPos;
-
- return aAdaptedOffsets;
- }
-
- uno::Reference< rendering::XTextLayout >
- createSubsetLayout( const rendering::StringContext& rOrigContext,
- const ::cppcanvas::internal::Action::Subset& rSubset,
- const uno::Reference< rendering::XTextLayout >& rOrigTextLayout )
- {
- // create temporary new text layout with subset string
- // ---------------------------------------------------
-
- const sal_Int32 nNewStartPos( rOrigContext.StartPosition + ::std::min(
- rSubset.mnSubsetBegin, rOrigContext.Length-1 ) );
- const sal_Int32 nNewLength( ::std::max(
- ::std::min(
- rSubset.mnSubsetEnd - rSubset.mnSubsetBegin,
- rOrigContext.Length ),
- sal_Int32( 0 ) ) );
-
- const rendering::StringContext aContext( rOrigContext.Text,
- nNewStartPos,
- nNewLength );
-
- uno::Reference< rendering::XTextLayout > xTextLayout(
- rOrigTextLayout->getFont()->createTextLayout( aContext,
- rOrigTextLayout->getMainTextDirection(),
- 0 ),
- uno::UNO_QUERY_THROW );
-
- return xTextLayout;
- }
-
- /** Setup subset text layout
-
- @param io_rTextLayout
- Must contain original (full set) text layout on input,
- will contain subsetted text layout (or empty
- reference, for empty subsets) on output.
-
- @param io_rRenderState
- Must contain original render state on input, will
- contain shifted render state concatenated with
- rTransformation on output.
-
- @param rTransformation
- Additional transformation, to be prepended to render
- state
-
- @param rSubset
- Subset to prepare
- */
- void createSubsetLayout( uno::Reference< rendering::XTextLayout >& io_rTextLayout,
- rendering::RenderState& io_rRenderState,
- double& o_rMinPos,
- double& o_rMaxPos,
- const ::basegfx::B2DHomMatrix& rTransformation,
- const Action::Subset& rSubset )
- {
- ::canvas::tools::prependToRenderState(io_rRenderState, rTransformation);
-
- if( rSubset.mnSubsetBegin == rSubset.mnSubsetEnd )
- {
- // empty range, empty layout
- io_rTextLayout.clear();
-
- return;
- }
-
- ENSURE_OR_THROW( io_rTextLayout.is(),
- "createSubsetLayout(): Invalid input layout" );
-
- const rendering::StringContext& rOrigContext( io_rTextLayout->getText() );
-
- if( rSubset.mnSubsetBegin == 0 &&
- rSubset.mnSubsetEnd == rOrigContext.Length )
- {
- // full range, no need for subsetting
- return;
- }
-
- uno::Reference< rendering::XTextLayout > xTextLayout(
- createSubsetLayout( rOrigContext, rSubset, io_rTextLayout ) );
-
- if( xTextLayout.is() )
- {
- xTextLayout->applyLogicalAdvancements(
- calcSubsetOffsets( io_rRenderState,
- o_rMinPos,
- o_rMaxPos,
- io_rTextLayout,
- rSubset ) );
- }
-
- io_rTextLayout = xTextLayout;
- }
-
-
- /** Interface for renderEffectText functor below.
-
- This is interface is used from the renderEffectText()
- method below, to call the client implementation.
- */
- class TextRenderer
- {
- public:
- virtual ~TextRenderer() {}
-
- /// Render text with given RenderState
- virtual bool operator()( const rendering::RenderState& rRenderState ) const = 0;
- };
-
- /** Render effect text.
-
- @param rRenderer
- Functor object, will be called to render the actual
- part of the text effect (the text itself and the means
- to render it are unknown to this method)
- */
- bool renderEffectText( const TextRenderer& rRenderer,
- const rendering::RenderState& rRenderState,
- const rendering::ViewState& /*rViewState*/,
- const uno::Reference< rendering::XCanvas >& xCanvas,
- const ::Color& rShadowColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rReliefOffset )
- {
- ::Color aEmptyColor( COL_AUTO );
- uno::Reference<rendering::XColorSpace> xColorSpace(
- xCanvas->getDevice()->getDeviceColorSpace() );
-
- // draw shadow text, if enabled
- if( rShadowColor != aEmptyColor )
- {
- rendering::RenderState aShadowState( rRenderState );
- ::basegfx::B2DHomMatrix aTranslate;
-
- aTranslate.translate( rShadowOffset.getX(),
- rShadowOffset.getY() );
-
- ::canvas::tools::appendToRenderState(aShadowState, aTranslate);
-
- aShadowState.DeviceColor =
- ::vcl::unotools::colorToDoubleSequence( rShadowColor,
- xColorSpace );
-
- rRenderer( aShadowState );
- }
-
- // draw relief text, if enabled
- if( rReliefColor != aEmptyColor )
- {
- rendering::RenderState aReliefState( rRenderState );
- ::basegfx::B2DHomMatrix aTranslate;
-
- aTranslate.translate( rReliefOffset.getX(),
- rReliefOffset.getY() );
-
- ::canvas::tools::appendToRenderState(aReliefState, aTranslate);
-
- aReliefState.DeviceColor =
- ::vcl::unotools::colorToDoubleSequence( rReliefColor,
- xColorSpace );
-
- rRenderer( aReliefState );
- }
-
- // draw normal text
- rRenderer( rRenderState );
-
- return true;
- }
-
-
- ::basegfx::B2DRange calcEffectTextBounds( const ::basegfx::B2DRange& rTextBounds,
- const ::basegfx::B2DRange& rLineBounds,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::basegfx::B2DSize& rShadowOffset,
- const rendering::RenderState& rRenderState,
- const rendering::ViewState& rViewState )
- {
- ::basegfx::B2DRange aBounds( rTextBounds );
-
- // add extends of text lines
- aBounds.expand( rLineBounds );
-
- // TODO(Q3): Provide this functionality at the B2DRange
- ::basegfx::B2DRange aTotalBounds( aBounds );
- aTotalBounds.expand(
- ::basegfx::B2DRange( aBounds.getMinX() + rReliefOffset.getX(),
- aBounds.getMinY() + rReliefOffset.getY(),
- aBounds.getMaxX() + rReliefOffset.getX(),
- aBounds.getMaxY() + rReliefOffset.getY() ) );
- aTotalBounds.expand(
- ::basegfx::B2DRange( aBounds.getMinX() + rShadowOffset.getX(),
- aBounds.getMinY() + rShadowOffset.getY(),
- aBounds.getMaxX() + rShadowOffset.getX(),
- aBounds.getMaxY() + rShadowOffset.getY() ) );
-
- return tools::calcDevicePixelBounds( aTotalBounds,
- rViewState,
- rRenderState );
- }
-
- void initEffectLinePolyPolygon( ::basegfx::B2DSize& o_rOverallSize,
- uno::Reference< rendering::XPolyPolygon2D >& o_rTextLines,
- const CanvasSharedPtr& rCanvas,
- const uno::Sequence< double >& rOffsets,
- const tools::TextLineInfo rLineInfo )
- {
- const ::basegfx::B2DPolyPolygon aPoly(
- textLinesFromLogicalOffsets(
- rOffsets,
- rLineInfo ) );
-
- o_rOverallSize = ::basegfx::tools::getRange( aPoly ).getRange();
-
- o_rTextLines = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- aPoly );
- }
-
- void initEffectLinePolyPolygon( ::basegfx::B2DSize& o_rOverallSize,
- uno::Reference< rendering::XPolyPolygon2D >& o_rTextLines,
- const CanvasSharedPtr& rCanvas,
- double nLineWidth,
- const tools::TextLineInfo rLineInfo )
- {
- const ::basegfx::B2DPolyPolygon aPoly(
- tools::createTextLinesPolyPolygon( 0.0, nLineWidth,
- rLineInfo ) );
-
- o_rOverallSize = ::basegfx::tools::getRange( aPoly ).getRange();
-
- o_rTextLines = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- aPoly );
- }
-
-
- // -------------------------------------------------------------------------
-
- class TextAction : public Action, private ::boost::noncopyable
- {
- public:
- TextAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
-
- TextAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- // TODO(P2): This is potentially a real mass object
- // (every character might be a separate TextAction),
- // thus, make it as lightweight as possible. For
- // example, share common RenderState among several
- // TextActions, maybe using maOffsets for the
- // translation.
-
- uno::Reference< rendering::XCanvasFont > mxFont;
- const rendering::StringContext maStringContext;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- const sal_Int8 maTextDirection;
- };
-
- TextAction::TextAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxFont( rState.xFont ),
- maStringContext( rString, nStartPos, nLen ),
- mpCanvas( rCanvas ),
- maState(),
- maTextDirection( rState.textDirection )
- {
- init( maState, mxFont,
- rStartPoint,
- rState, rCanvas );
-
- ENSURE_OR_THROW( mxFont.is(),
- "::cppcanvas::internal::TextAction(): Invalid font" );
- }
-
- TextAction::TextAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform ) :
- mxFont( rState.xFont ),
- maStringContext( rString, nStartPos, nLen ),
- mpCanvas( rCanvas ),
- maState(),
- maTextDirection( rState.textDirection )
- {
- init( maState, mxFont,
- rStartPoint,
- rState, rCanvas, rTextTransform );
-
- ENSURE_OR_THROW( mxFont.is(),
- "::cppcanvas::internal::TextAction(): Invalid font" );
- }
-
- bool TextAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- mpCanvas->getUNOCanvas()->drawText( maStringContext, mxFont,
- mpCanvas->getViewState(), aLocalState, maTextDirection );
-
- return true;
- }
-
- bool TextAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& /*rSubset*/ ) const
- {
- SAL_WARN( "cppcanvas.emf", "TextAction::renderSubset(): Subset not supported by this object" );
-
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // _subsettable_ text
- return render( rTransformation );
- }
-
- ::basegfx::B2DRange TextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- // create XTextLayout, to have the
- // XTextLayout::queryTextBounds() method available
- uno::Reference< rendering::XTextLayout > xTextLayout(
- mxFont->createTextLayout(
- maStringContext,
- maTextDirection,
- 0 ) );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- xTextLayout->queryTextBounds() ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange TextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& /*rSubset*/ ) const
- {
- SAL_WARN( "cppcanvas.emf", "TextAction::getBounds(): Subset not supported by this object" );
-
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // _subsettable_ text
- return getBounds( rTransformation );
- }
-
- sal_Int32 TextAction::getActionCount() const
- {
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // _subsettable_ text
- return 1;
- }
-
-
- // -------------------------------------------------------------------------
-
- class EffectTextAction :
- public Action,
- public TextRenderer,
- private ::boost::noncopyable
- {
- public:
- EffectTextAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
-
- EffectTextAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- /// Interface TextRenderer
- virtual bool operator()( const rendering::RenderState& rRenderState ) const;
-
- // TODO(P2): This is potentially a real mass object
- // (every character might be a separate TextAction),
- // thus, make it as lightweight as possible. For
- // example, share common RenderState among several
- // TextActions, maybe using maOffsets for the
- // translation.
-
- uno::Reference< rendering::XCanvasFont > mxFont;
- const rendering::StringContext maStringContext;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- const tools::TextLineInfo maTextLineInfo;
- ::basegfx::B2DSize maLinesOverallSize;
- const double mnLineWidth;
- uno::Reference< rendering::XPolyPolygon2D > mxTextLines;
- const ::basegfx::B2DSize maReliefOffset;
- const ::Color maReliefColor;
- const ::basegfx::B2DSize maShadowOffset;
- const ::Color maShadowColor;
- const sal_Int8 maTextDirection;
- };
-
- EffectTextAction::EffectTextAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxFont( rState.xFont ),
- maStringContext( rText, nStartPos, nLen ),
- mpCanvas( rCanvas ),
- maState(),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- mnLineWidth( getLineWidth( rVDev, rState, maStringContext ) ),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor ),
- maTextDirection( rState.textDirection )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- mnLineWidth,
- maTextLineInfo );
-
- init( maState, mxFont,
- rStartPoint,
- rState, rCanvas );
-
- ENSURE_OR_THROW( mxFont.is() && mxTextLines.is(),
- "::cppcanvas::internal::EffectTextAction(): Invalid font or lines" );
- }
-
- EffectTextAction::EffectTextAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform ) :
- mxFont( rState.xFont ),
- maStringContext( rText, nStartPos, nLen ),
- mpCanvas( rCanvas ),
- maState(),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- mnLineWidth( getLineWidth( rVDev, rState, maStringContext ) ),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor ),
- maTextDirection( rState.textDirection )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- mnLineWidth,
- maTextLineInfo );
-
- init( maState, mxFont,
- rStartPoint,
- rState, rCanvas, rTextTransform );
-
- ENSURE_OR_THROW( mxFont.is() && mxTextLines.is(),
- "::cppcanvas::internal::EffectTextAction(): Invalid font or lines" );
- }
-
- bool EffectTextAction::operator()( const rendering::RenderState& rRenderState ) const
- {
- const rendering::ViewState& rViewState( mpCanvas->getViewState() );
- const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
-
- rCanvas->fillPolyPolygon( mxTextLines,
- rViewState,
- rRenderState );
-
- rCanvas->drawText( maStringContext, mxFont,
- rViewState,
- rRenderState,
- maTextDirection );
-
- return true;
- }
-
- bool EffectTextAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return renderEffectText( *this,
- aLocalState,
- mpCanvas->getViewState(),
- mpCanvas->getUNOCanvas(),
- maShadowColor,
- maShadowOffset,
- maReliefColor,
- maReliefOffset );
- }
-
- bool EffectTextAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& /*rSubset*/ ) const
- {
- SAL_WARN( "cppcanvas.emf", "EffectTextAction::renderSubset(): Subset not supported by this object" );
-
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // subsettable text
- return render( rTransformation );
- }
-
- ::basegfx::B2DRange EffectTextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- // create XTextLayout, to have the
- // XTextLayout::queryTextBounds() method available
- uno::Reference< rendering::XTextLayout > xTextLayout(
- mxFont->createTextLayout(
- maStringContext,
- maTextDirection,
- 0 ) );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return calcEffectTextBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- xTextLayout->queryTextBounds() ),
- ::basegfx::B2DRange( 0,0,
- maLinesOverallSize.getX(),
- maLinesOverallSize.getY() ),
- maReliefOffset,
- maShadowOffset,
- aLocalState,
- mpCanvas->getViewState() );
- }
-
- ::basegfx::B2DRange EffectTextAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& /*rSubset*/ ) const
- {
- SAL_WARN( "cppcanvas.emf", "EffectTextAction::getBounds(): Subset not supported by this object" );
-
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // _subsettable_ text
- return getBounds( rTransformation );
- }
-
- sal_Int32 EffectTextAction::getActionCount() const
- {
- // TODO(P1): Retrieve necessary font metric info for
- // TextAction from XCanvas. Currently, the
- // TextActionFactory does not generate this object for
- // subsettable text
- return 1;
- }
-
-
- // -------------------------------------------------------------------------
-
- class TextArrayAction : public Action, private ::boost::noncopyable
- {
- public:
- TextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
-
- TextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- // TODO(P2): This is potentially a real mass object
- // (every character might be a separate TextAction),
- // thus, make it as lightweight as possible. For
- // example, share common RenderState among several
- // TextActions, maybe using maOffsets for the
- // translation.
-
- uno::Reference< rendering::XTextLayout > mxTextLayout;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- };
-
- TextArrayAction::TextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxTextLayout(),
- mpCanvas( rCanvas ),
- maState()
- {
- initArrayAction( maState,
- mxTextLayout,
- rStartPoint,
- rString,
- nStartPos,
- nLen,
- rOffsets,
- rCanvas,
- rState, NULL );
- }
-
- TextArrayAction::TextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const OUString& rString,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform ) :
- mxTextLayout(),
- mpCanvas( rCanvas ),
- maState()
- {
- initArrayAction( maState,
- mxTextLayout,
- rStartPoint,
- rString,
- nStartPos,
- nLen,
- rOffsets,
- rCanvas,
- rState,
- &rTextTransform );
- }
-
- bool TextArrayAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- mpCanvas->getUNOCanvas()->drawTextLayout( mxTextLayout,
- mpCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- bool TextArrayAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction::renderSubset()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- uno::Reference< rendering::XTextLayout > xTextLayout( mxTextLayout );
-
- double nDummy0, nDummy1;
- createSubsetLayout( xTextLayout,
- aLocalState,
- nDummy0,
- nDummy1,
- rTransformation,
- rSubset );
-
- if( !xTextLayout.is() )
- return true; // empty layout, render nothing
-
- mpCanvas->getUNOCanvas()->drawTextLayout( xTextLayout,
- mpCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- ::basegfx::B2DRange TextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- mxTextLayout->queryTextBounds() ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange TextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction::getBounds( subset )" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- uno::Reference< rendering::XTextLayout > xTextLayout( mxTextLayout );
-
- double nDummy0, nDummy1;
- createSubsetLayout( xTextLayout,
- aLocalState,
- nDummy0,
- nDummy1,
- rTransformation,
- rSubset );
-
- if( !xTextLayout.is() )
- return ::basegfx::B2DRange(); // empty layout, empty bounds
-
- return tools::calcDevicePixelBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- xTextLayout->queryTextBounds() ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- sal_Int32 TextArrayAction::getActionCount() const
- {
- const rendering::StringContext& rOrigContext( mxTextLayout->getText() );
-
- return rOrigContext.Length;
- }
-
-
- // -------------------------------------------------------------------------
-
- class EffectTextArrayAction :
- public Action,
- public TextRenderer,
- private ::boost::noncopyable
- {
- public:
- EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
- EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- // TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const;
-
- // TODO(P2): This is potentially a real mass object
- // (every character might be a separate TextAction),
- // thus, make it as lightweight as possible. For
- // example, share common RenderState among several
- // TextActions, maybe using maOffsets for the
- // translation.
-
- uno::Reference< rendering::XTextLayout > mxTextLayout;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- const tools::TextLineInfo maTextLineInfo;
- ::basegfx::B2DSize maLinesOverallSize;
- uno::Reference< rendering::XPolyPolygon2D > mxTextLines;
- const ::basegfx::B2DSize maReliefOffset;
- const ::Color maReliefColor;
- const ::basegfx::B2DSize maShadowOffset;
- const ::Color maShadowColor;
- };
-
- EffectTextArrayAction::EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxTextLayout(),
- mpCanvas( rCanvas ),
- maState(),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- rOffsets,
- maTextLineInfo );
-
- initArrayAction( maState,
- mxTextLayout,
- rStartPoint,
- rText,
- nStartPos,
- nLen,
- rOffsets,
- rCanvas,
- rState, NULL );
- }
-
- EffectTextArrayAction::EffectTextArrayAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform ) :
- mxTextLayout(),
- mpCanvas( rCanvas ),
- maState(),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- rOffsets,
- maTextLineInfo );
-
- initArrayAction( maState,
- mxTextLayout,
- rStartPoint,
- rText,
- nStartPos,
- nLen,
- rOffsets,
- rCanvas,
- rState,
- &rTextTransform );
- }
-
- bool EffectTextArrayAction::operator()( const rendering::RenderState& rRenderState ) const
- {
- const rendering::ViewState& rViewState( mpCanvas->getViewState() );
- const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
-
- rCanvas->fillPolyPolygon( mxTextLines,
- rViewState,
- rRenderState );
-
- rCanvas->drawTextLayout( mxTextLayout,
- rViewState,
- rRenderState );
-
- return true;
- }
-
- bool EffectTextArrayAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return renderEffectText( *this,
- aLocalState,
- mpCanvas->getViewState(),
- mpCanvas->getUNOCanvas(),
- maShadowColor,
- maShadowOffset,
- maReliefColor,
- maReliefOffset );
- }
-
- class EffectTextArrayRenderHelper : public TextRenderer
- {
- public:
- EffectTextArrayRenderHelper( const uno::Reference< rendering::XCanvas >& rCanvas,
- const uno::Reference< rendering::XTextLayout >& rTextLayout,
- const uno::Reference< rendering::XPolyPolygon2D >& rLinePolygon,
- const rendering::ViewState& rViewState ) :
- mrCanvas( rCanvas ),
- mrTextLayout( rTextLayout ),
- mrLinePolygon( rLinePolygon ),
- mrViewState( rViewState )
- {
- }
-
- // TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const
- {
- mrCanvas->fillPolyPolygon( mrLinePolygon,
- mrViewState,
- rRenderState );
-
- mrCanvas->drawTextLayout( mrTextLayout,
- mrViewState,
- rRenderState );
-
- return true;
- }
-
- private:
- const uno::Reference< rendering::XCanvas >& mrCanvas;
- const uno::Reference< rendering::XTextLayout >& mrTextLayout;
- const uno::Reference< rendering::XPolyPolygon2D >& mrLinePolygon;
- const rendering::ViewState& mrViewState;
- };
-
- bool EffectTextArrayAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction::renderSubset()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- uno::Reference< rendering::XTextLayout > xTextLayout( mxTextLayout );
- const geometry::RealRectangle2D aTextBounds( mxTextLayout->queryTextBounds() );
-
- double nMinPos(0.0);
- double nMaxPos(aTextBounds.X2 - aTextBounds.X1);
-
- createSubsetLayout( xTextLayout,
- aLocalState,
- nMinPos,
- nMaxPos,
- rTransformation,
- rSubset );
-
- if( !xTextLayout.is() )
- return true; // empty layout, render nothing
-
-
- // create and setup local line polygon
- // ===================================
-
- uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
- const rendering::ViewState& rViewState( mpCanvas->getViewState() );
-
- uno::Reference< rendering::XPolyPolygon2D > xTextLines(
- ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- xCanvas->getDevice(),
- tools::createTextLinesPolyPolygon(
- 0.0, nMaxPos - nMinPos,
- maTextLineInfo ) ) );
-
-
- // render everything
- // =================
-
- return renderEffectText(
- EffectTextArrayRenderHelper( xCanvas,
- xTextLayout,
- xTextLines,
- rViewState ),
- aLocalState,
- rViewState,
- xCanvas,
- maShadowColor,
- maShadowOffset,
- maReliefColor,
- maReliefOffset );
- }
-
- ::basegfx::B2DRange EffectTextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return calcEffectTextBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- mxTextLayout->queryTextBounds() ),
- ::basegfx::B2DRange( 0,0,
- maLinesOverallSize.getX(),
- maLinesOverallSize.getY() ),
- maReliefOffset,
- maShadowOffset,
- aLocalState,
- mpCanvas->getViewState() );
- }
-
- ::basegfx::B2DRange EffectTextArrayAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction::getBounds( subset )" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- uno::Reference< rendering::XTextLayout > xTextLayout( mxTextLayout );
- const geometry::RealRectangle2D aTextBounds( mxTextLayout->queryTextBounds() );
-
- double nMinPos(0.0);
- double nMaxPos(aTextBounds.X2 - aTextBounds.X1);
-
- createSubsetLayout( xTextLayout,
- aLocalState,
- nMinPos,
- nMaxPos,
- rTransformation,
- rSubset );
-
- if( !xTextLayout.is() )
- return ::basegfx::B2DRange(); // empty layout, empty bounds
-
-
- // create and setup local line polygon
- // ===================================
-
- const ::basegfx::B2DPolyPolygon aPoly(
- tools::createTextLinesPolyPolygon(
- 0.0, nMaxPos - nMinPos,
- maTextLineInfo ) );
-
- return calcEffectTextBounds( ::basegfx::unotools::b2DRectangleFromRealRectangle2D(
- xTextLayout->queryTextBounds() ),
- ::basegfx::tools::getRange( aPoly ),
- maReliefOffset,
- maShadowOffset,
- aLocalState,
- mpCanvas->getViewState() );
- }
-
- sal_Int32 EffectTextArrayAction::getActionCount() const
- {
- const rendering::StringContext& rOrigContext( mxTextLayout->getText() );
-
- return rOrigContext.Length;
- }
-
-
- // -------------------------------------------------------------------------
-
- class OutlineAction :
- public Action,
- public TextRenderer,
- private ::boost::noncopyable
- {
- public:
- OutlineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const ::basegfx::B2DRectangle& rOutlineBounds,
- const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly,
- const ::std::vector< sal_Int32 >& rPolygonGlyphMap,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
- OutlineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const ::basegfx::B2DRectangle& rOutlineBounds,
- const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly,
- const ::std::vector< sal_Int32 >& rPolygonGlyphMap,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- // TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const;
-
- // TODO(P2): This is potentially a real mass object
- // (every character might be a separate TextAction),
- // thus, make it as lightweight as possible. For
- // example, share common RenderState among several
- // TextActions, maybe using maOffsets for the
- // translation.
-
- uno::Reference< rendering::XPolyPolygon2D > mxTextPoly;
-
- /** This vector denotes the index of the start polygon
- for the respective glyph sequence.
-
- To get a polygon index range for a given character
- index i, take [ maPolygonGlyphMap[i],
- maPolygonGlyphMap[i+1] ). Note that this is wrong
- for BiDi
- */
- const ::std::vector< sal_Int32 > maPolygonGlyphMap;
- const uno::Sequence< double > maOffsets;
- const CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- double mnOutlineWidth;
- const uno::Sequence< double > maFillColor;
- const tools::TextLineInfo maTextLineInfo;
- ::basegfx::B2DSize maLinesOverallSize;
- const ::basegfx::B2DRectangle maOutlineBounds;
- uno::Reference< rendering::XPolyPolygon2D > mxTextLines;
- const ::basegfx::B2DSize maReliefOffset;
- const ::Color maReliefColor;
- const ::basegfx::B2DSize maShadowOffset;
- const ::Color maShadowColor;
- };
-
- double calcOutlineWidth( const OutDevState& rState,
- VirtualDevice& rVDev )
- {
- const ::basegfx::B2DSize aFontSize( 0,
- rVDev.GetFont().GetHeight() / 64.0 );
-
- const double nOutlineWidth(
- (rState.mapModeTransform * aFontSize).getY() );
-
- return nOutlineWidth < 1.0 ? 1.0 : nOutlineWidth;
- }
-
- OutlineAction::OutlineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const ::basegfx::B2DRectangle& rOutlineBounds,
- const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly,
- const ::std::vector< sal_Int32 >& rPolygonGlyphMap,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mxTextPoly( rTextPoly ),
- maPolygonGlyphMap( rPolygonGlyphMap ),
- maOffsets( rOffsets ),
- mpCanvas( rCanvas ),
- maState(),
- mnOutlineWidth( calcOutlineWidth(rState,rVDev) ),
- maFillColor(
- ::vcl::unotools::colorToDoubleSequence(
- ::Color( COL_WHITE ),
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() )),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- maOutlineBounds( rOutlineBounds ),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- rOffsets,
- maTextLineInfo );
-
- init( maState,
- rStartPoint,
- rState,
- rCanvas );
- }
-
- OutlineAction::OutlineAction( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const ::basegfx::B2DRectangle& rOutlineBounds,
- const uno::Reference< rendering::XPolyPolygon2D >& rTextPoly,
- const ::std::vector< sal_Int32 >& rPolygonGlyphMap,
- const uno::Sequence< double >& rOffsets,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const ::basegfx::B2DHomMatrix& rTextTransform ) :
- mxTextPoly( rTextPoly ),
- maPolygonGlyphMap( rPolygonGlyphMap ),
- maOffsets( rOffsets ),
- mpCanvas( rCanvas ),
- maState(),
- mnOutlineWidth( calcOutlineWidth(rState,rVDev) ),
- maFillColor(
- ::vcl::unotools::colorToDoubleSequence(
- ::Color( COL_WHITE ),
- rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() )),
- maTextLineInfo( tools::createTextLineInfo( rVDev, rState ) ),
- maLinesOverallSize(),
- maOutlineBounds( rOutlineBounds ),
- mxTextLines(),
- maReliefOffset( rReliefOffset ),
- maReliefColor( rReliefColor ),
- maShadowOffset( rShadowOffset ),
- maShadowColor( rShadowColor )
- {
- initEffectLinePolyPolygon( maLinesOverallSize,
- mxTextLines,
- rCanvas,
- rOffsets,
- maTextLineInfo );
-
- init( maState,
- rStartPoint,
- rState,
- rCanvas,
- rTextTransform );
- }
-
- bool OutlineAction::operator()( const rendering::RenderState& rRenderState ) const
- {
- const rendering::ViewState& rViewState( mpCanvas->getViewState() );
- const uno::Reference< rendering::XCanvas >& rCanvas( mpCanvas->getUNOCanvas() );
-
- rendering::StrokeAttributes aStrokeAttributes;
-
- aStrokeAttributes.StrokeWidth = mnOutlineWidth;
- aStrokeAttributes.MiterLimit = 1.0;
- aStrokeAttributes.StartCapType = rendering::PathCapType::BUTT;
- aStrokeAttributes.EndCapType = rendering::PathCapType::BUTT;
- aStrokeAttributes.JoinType = rendering::PathJoinType::MITER;
-
- rendering::RenderState aLocalState( rRenderState );
- aLocalState.DeviceColor = maFillColor;
-
- // TODO(P1): implement caching
-
- // background of text
- rCanvas->fillPolyPolygon( mxTextPoly,
- rViewState,
- aLocalState );
-
- // border line of text
- rCanvas->strokePolyPolygon( mxTextPoly,
- rViewState,
- rRenderState,
- aStrokeAttributes );
-
- // underlines/strikethrough - background
- rCanvas->fillPolyPolygon( mxTextLines,
- rViewState,
- aLocalState );
- // underlines/strikethrough - border
- rCanvas->strokePolyPolygon( mxTextLines,
- rViewState,
- rRenderState,
- aStrokeAttributes );
-
- return true;
- }
-
- bool OutlineAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction::render()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::EffectTextArrayAction: 0x" << std::hex << this );
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return renderEffectText( *this,
- aLocalState,
- mpCanvas->getViewState(),
- mpCanvas->getUNOCanvas(),
- maShadowColor,
- maShadowOffset,
- maReliefColor,
- maReliefOffset );
- }
-
- class OutlineTextArrayRenderHelper : public TextRenderer
- {
- public:
- OutlineTextArrayRenderHelper( const uno::Reference< rendering::XCanvas >& rCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& rTextPolygon,
- const uno::Reference< rendering::XPolyPolygon2D >& rLinePolygon,
- const rendering::ViewState& rViewState,
- double nOutlineWidth ) :
- maFillColor(
- ::vcl::unotools::colorToDoubleSequence(
- ::Color( COL_WHITE ),
- rCanvas->getDevice()->getDeviceColorSpace() )),
- mnOutlineWidth( nOutlineWidth ),
- mrCanvas( rCanvas ),
- mrTextPolygon( rTextPolygon ),
- mrLinePolygon( rLinePolygon ),
- mrViewState( rViewState )
- {
- }
-
- // TextRenderer interface
- virtual bool operator()( const rendering::RenderState& rRenderState ) const
- {
- rendering::StrokeAttributes aStrokeAttributes;
-
- aStrokeAttributes.StrokeWidth = mnOutlineWidth;
- aStrokeAttributes.MiterLimit = 1.0;
- aStrokeAttributes.StartCapType = rendering::PathCapType::BUTT;
- aStrokeAttributes.EndCapType = rendering::PathCapType::BUTT;
- aStrokeAttributes.JoinType = rendering::PathJoinType::MITER;
-
- rendering::RenderState aLocalState( rRenderState );
- aLocalState.DeviceColor = maFillColor;
-
- // TODO(P1): implement caching
-
- // background of text
- mrCanvas->fillPolyPolygon( mrTextPolygon,
- mrViewState,
- aLocalState );
-
- // border line of text
- mrCanvas->strokePolyPolygon( mrTextPolygon,
- mrViewState,
- rRenderState,
- aStrokeAttributes );
-
- // underlines/strikethrough - background
- mrCanvas->fillPolyPolygon( mrLinePolygon,
- mrViewState,
- aLocalState );
- // underlines/strikethrough - border
- mrCanvas->strokePolyPolygon( mrLinePolygon,
- mrViewState,
- rRenderState,
- aStrokeAttributes );
-
- return true;
- }
-
- private:
- const uno::Sequence< double > maFillColor;
- double mnOutlineWidth;
- const uno::Reference< rendering::XCanvas >& mrCanvas;
- const uno::Reference< rendering::XPolyPolygon2D >& mrTextPolygon;
- const uno::Reference< rendering::XPolyPolygon2D >& mrLinePolygon;
- const rendering::ViewState& mrViewState;
- };
-
- bool OutlineAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::OutlineAction::renderSubset()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::OutlineAction: 0x" << std::hex << this );
-
- if( rSubset.mnSubsetBegin == rSubset.mnSubsetEnd )
- return true; // empty range, render nothing
-
-#if 1
- // TODO(F3): Subsetting NYI for outline text!
- return render( rTransformation );
-#else
- const rendering::StringContext rOrigContext( mxTextLayout->getText() );
-
- if( rSubset.mnSubsetBegin == 0 &&
- rSubset.mnSubsetEnd == rOrigContext.Length )
- {
- // full range, no need for subsetting
- return render( rTransformation );
- }
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
-
- // create and setup local Text polygon
- // ===================================
-
- uno::Reference< rendering::XPolyPolygon2D > xTextPolygon();
-
- // TODO(P3): Provide an API method for that!
-
- if( !xTextLayout.is() )
- return false;
-
- // render everything
- // =================
-
- return renderEffectText(
- OutlineTextArrayRenderHelper(
- xCanvas,
- mnOutlineWidth,
- xTextLayout,
- xTextLines,
- rViewState ),
- aLocalState,
- rViewState,
- xCanvas,
- maShadowColor,
- maShadowOffset,
- maReliefColor,
- maReliefOffset );
-#endif
- }
-
- ::basegfx::B2DRange OutlineAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return calcEffectTextBounds( maOutlineBounds,
- ::basegfx::B2DRange( 0,0,
- maLinesOverallSize.getX(),
- maLinesOverallSize.getY() ),
- maReliefOffset,
- maShadowOffset,
- aLocalState,
- mpCanvas->getViewState() );
- }
-
- ::basegfx::B2DRange OutlineAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& /*rSubset*/ ) const
- {
- SAL_WARN( "cppcanvas.emf", "OutlineAction::getBounds(): Subset not yet supported by this object" );
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 OutlineAction::getActionCount() const
- {
- // TODO(F3): Subsetting NYI for outline text!
- return maOffsets.getLength();
- }
-
-
- // ======================================================================
- //
- // Action factory methods
- //
- // ======================================================================
-
- /** Create an outline action
-
- This method extracts the polygonal outline from the
- text, and creates a properly setup OutlineAction from
- it.
- */
- ActionSharedPtr createOutline( const ::basegfx::B2DPoint& rStartPoint,
- const ::basegfx::B2DSize& rReliefOffset,
- const ::Color& rReliefColor,
- const ::basegfx::B2DSize& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const sal_Int32* pDXArray,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const Renderer::Parameters& rParms )
- {
- // operate on raw DX array here (in logical coordinate
- // system), to have a higher resolution
- // PolyPolygon. That polygon is then converted to
- // device coordinate system.
-
- // #i68512# Temporarily switch off font rotation
- // (which is already contained in the render state
- // transformation matrix - otherwise, glyph polygons
- // will be rotated twice)
- const ::Font aOrigFont( rVDev.GetFont() );
- ::Font aUnrotatedFont( aOrigFont );
- aUnrotatedFont.SetOrientation(0);
- rVDev.SetFont( aUnrotatedFont );
-
- // TODO(F3): Don't understand parameter semantics of
- // GetTextOutlines()
- ::basegfx::B2DPolyPolygon aResultingPolyPolygon;
- PolyPolyVector aVCLPolyPolyVector;
- const bool bHaveOutlines( rVDev.GetTextOutlines( aVCLPolyPolyVector, rText,
- static_cast<sal_uInt16>(nStartPos),
- static_cast<sal_uInt16>(nStartPos),
- static_cast<sal_uInt16>(nLen),
- sal_True, 0, pDXArray ) );
- rVDev.SetFont(aOrigFont);
-
- if( !bHaveOutlines )
- return ActionSharedPtr();
-
- ::std::vector< sal_Int32 > aPolygonGlyphMap;
-
- // first glyph starts at polygon index 0
- aPolygonGlyphMap.push_back( 0 );
-
- // remove offsetting from mapmode transformation
- // (outline polygons must stay at origin, only need to
- // be scaled)
- ::basegfx::B2DHomMatrix aMapModeTransform(
- rState.mapModeTransform );
- aMapModeTransform.set(0,2, 0.0);
- aMapModeTransform.set(1,2, 0.0);
-
- PolyPolyVector::const_iterator aIter( aVCLPolyPolyVector.begin() );
- const PolyPolyVector::const_iterator aEnd( aVCLPolyPolyVector.end() );
- for( ; aIter!= aEnd; ++aIter )
- {
- ::basegfx::B2DPolyPolygon aPolyPolygon;
-
- aPolyPolygon = aIter->getB2DPolyPolygon();
- aPolyPolygon.transform( aMapModeTransform );
-
- // append result to collecting polypoly
- for( sal_uInt32 i=0; i<aPolyPolygon.count(); ++i )
- {
- // #i47795# Ensure closed polygons (since
- // FreeType returns the glyph outlines
- // open)
- const ::basegfx::B2DPolygon& rPoly( aPolyPolygon.getB2DPolygon( i ) );
- const sal_uInt32 nCount( rPoly.count() );
- if( nCount<3 ||
- rPoly.isClosed() )
- {
- // polygon either degenerate, or
- // already closed.
- aResultingPolyPolygon.append( rPoly );
- }
- else
- {
- ::basegfx::B2DPolygon aPoly(rPoly);
- aPoly.setClosed(true);
-
- aResultingPolyPolygon.append( aPoly );
- }
- }
-
- // TODO(F3): Depending on the semantics of
- // GetTextOutlines(), this here is wrong!
-
- // calc next glyph index
- aPolygonGlyphMap.push_back( aResultingPolyPolygon.count() );
- }
-
- const uno::Sequence< double > aCharWidthSeq(
- pDXArray ?
- setupDXArray( pDXArray, nLen, rState ) :
- setupDXArray( rText,
- nStartPos,
- nLen,
- rVDev,
- rState ));
- const uno::Reference< rendering::XPolyPolygon2D > xTextPoly(
- ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- rCanvas->getUNOCanvas()->getDevice(),
- aResultingPolyPolygon ) );
-
- if( rParms.maTextTransformation.is_initialized() )
- {
- return ActionSharedPtr(
- new OutlineAction(
- rStartPoint,
- rReliefOffset,
- rReliefColor,
- rShadowOffset,
- rShadowColor,
- ::basegfx::tools::getRange(aResultingPolyPolygon),
- xTextPoly,
- aPolygonGlyphMap,
- aCharWidthSeq,
- rVDev,
- rCanvas,
- rState,
- *rParms.maTextTransformation ) );
- }
- else
- {
- return ActionSharedPtr(
- new OutlineAction(
- rStartPoint,
- rReliefOffset,
- rReliefColor,
- rShadowOffset,
- rShadowColor,
- ::basegfx::tools::getRange(aResultingPolyPolygon),
- xTextPoly,
- aPolygonGlyphMap,
- aCharWidthSeq,
- rVDev,
- rCanvas,
- rState ) );
- }
- }
-
- } // namespace
-
-
- // ---------------------------------------------------------------------------------
-
- ActionSharedPtr TextActionFactory::createTextAction( const ::Point& rStartPoint,
- const ::Size& rReliefOffset,
- const ::Color& rReliefColor,
- const ::Size& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const sal_Int32* pDXArray,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const Renderer::Parameters& rParms,
- bool bSubsettable )
- {
- const ::Size aBaselineOffset( tools::getBaselineOffset( rState,
- rVDev ) );
- // #143885# maintain (nearly) full precision positioning,
- // by circumventing integer-based OutDev-mapping
- const ::basegfx::B2DPoint aStartPoint(
- rState.mapModeTransform *
- ::basegfx::B2DPoint(rStartPoint.X() + aBaselineOffset.Width(),
- rStartPoint.Y() + aBaselineOffset.Height()) );
-
- const ::basegfx::B2DSize aReliefOffset(
- rState.mapModeTransform * ::vcl::unotools::b2DSizeFromSize( rReliefOffset ) );
- const ::basegfx::B2DSize aShadowOffset(
- rState.mapModeTransform * ::vcl::unotools::b2DSizeFromSize( rShadowOffset ) );
-
- if( rState.isTextOutlineModeSet )
- {
- return createOutline(
- aStartPoint,
- aReliefOffset,
- rReliefColor,
- aShadowOffset,
- rShadowColor,
- rText,
- nStartPos,
- nLen,
- pDXArray,
- rVDev,
- rCanvas,
- rState,
- rParms );
- }
-
- // convert DX array to device coordinate system (and
- // create it in the first place, if pDXArray is NULL)
- const uno::Sequence< double > aCharWidths(
- pDXArray ?
- setupDXArray( pDXArray, nLen, rState ) :
- setupDXArray( rText,
- nStartPos,
- nLen,
- rVDev,
- rState ));
-
- // determine type of text action to create
- // =======================================
-
- const ::Color aEmptyColor( COL_AUTO );
-
- // no DX array, and no need to subset - no need to store
- // DX array, then.
- if( !pDXArray && !bSubsettable )
- {
- // effects, or not?
- if( !rState.textOverlineStyle &&
- !rState.textUnderlineStyle &&
- !rState.textStrikeoutStyle &&
- rReliefColor == aEmptyColor &&
- rShadowColor == aEmptyColor )
- {
- // nope
- if( rParms.maTextTransformation.is_initialized() )
- {
- return ActionSharedPtr( new TextAction(
- aStartPoint,
- rText,
- nStartPos,
- nLen,
- rCanvas,
- rState,
- *rParms.maTextTransformation ) );
- }
- else
- {
- return ActionSharedPtr( new TextAction(
- aStartPoint,
- rText,
- nStartPos,
- nLen,
- rCanvas,
- rState ) );
- }
- }
- else
- {
- // at least one of the effects requested
- if( rParms.maTextTransformation.is_initialized() )
- return ActionSharedPtr( new EffectTextAction(
- aStartPoint,
- aReliefOffset,
- rReliefColor,
- aShadowOffset,
- rShadowColor,
- rText,
- nStartPos,
- nLen,
- rVDev,
- rCanvas,
- rState,
- *rParms.maTextTransformation ) );
- else
- return ActionSharedPtr( new EffectTextAction(
- aStartPoint,
- aReliefOffset,
- rReliefColor,
- aShadowOffset,
- rShadowColor,
- rText,
- nStartPos,
- nLen,
- rVDev,
- rCanvas,
- rState ) );
- }
- }
- else
- {
- // DX array necessary - any effects?
- if( !rState.textOverlineStyle &&
- !rState.textUnderlineStyle &&
- !rState.textStrikeoutStyle &&
- rReliefColor == aEmptyColor &&
- rShadowColor == aEmptyColor )
- {
- // nope
- if( rParms.maTextTransformation.is_initialized() )
- return ActionSharedPtr( new TextArrayAction(
- aStartPoint,
- rText,
- nStartPos,
- nLen,
- aCharWidths,
- rCanvas,
- rState,
- *rParms.maTextTransformation ) );
- else
- return ActionSharedPtr( new TextArrayAction(
- aStartPoint,
- rText,
- nStartPos,
- nLen,
- aCharWidths,
- rCanvas,
- rState ) );
- }
- else
- {
- // at least one of the effects requested
- if( rParms.maTextTransformation.is_initialized() )
- return ActionSharedPtr( new EffectTextArrayAction(
- aStartPoint,
- aReliefOffset,
- rReliefColor,
- aShadowOffset,
- rShadowColor,
- rText,
- nStartPos,
- nLen,
- aCharWidths,
- rVDev,
- rCanvas,
- rState,
- *rParms.maTextTransformation ) );
- else
- return ActionSharedPtr( new EffectTextArrayAction(
- aStartPoint,
- aReliefOffset,
- rReliefColor,
- aShadowOffset,
- rShadowColor,
- rText,
- nStartPos,
- nLen,
- aCharWidths,
- rVDev,
- rCanvas,
- rState ) );
- }
- }
-#if defined(__GNUC__)
- return ActionSharedPtr();
-#endif
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/textaction.hxx b/cppcanvas/source/mtfrenderer/textaction.hxx
deleted file mode 100644
index f40f03ee6787..000000000000
--- a/cppcanvas/source/mtfrenderer/textaction.hxx
+++ /dev/null
@@ -1,95 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_TEXTACTION_HXX
-#define _CPPCANVAS_TEXTACTION_HXX
-
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <action.hxx>
-#include <cppcanvas/canvas.hxx>
-#include <cppcanvas/renderer.hxx>
-#include <tools/poly.hxx>
-
-class VirtualDevice;
-class Point;
-class Size;
-class Color;
-
-
-/* Definition of internal::TextActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- /** Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class TextActionFactory
- {
- public:
- /** Create text action, optionally shadow/relief effect
-
- Note that this method accepts all coordinates in
- logical coordinates.
-
- @param pDXArray
- Pointer to array of logical character offsets (or NULL)
-
- @param bSubsettable
- When this parameter is set to true, the generated
- action might consume slightly more memory, but is
- subsettable (Action::render( Subset ) works on
- characters)
- */
- static ActionSharedPtr createTextAction( const ::Point& rStartPoint,
- const ::Size& rReliefOffset,
- const ::Color& rReliefColor,
- const ::Size& rShadowOffset,
- const ::Color& rShadowColor,
- const OUString& rText,
- sal_Int32 nStartPos,
- sal_Int32 nLen,
- const sal_Int32* pDXArray,
- VirtualDevice& rVDev,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState,
- const Renderer::Parameters& rParms,
- bool bSubsettable );
-
- private:
- // static factory, disable big four
- TextActionFactory();
- ~TextActionFactory();
- TextActionFactory(const TextActionFactory&);
- TextActionFactory& operator=( const TextActionFactory& );
- };
- }
-}
-
-#endif /* _CPPCANVAS_TEXTACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx
deleted file mode 100644
index 8254320de978..000000000000
--- a/cppcanvas/source/mtfrenderer/transparencygroupaction.cxx
+++ /dev/null
@@ -1,499 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <tools/gen.hxx>
-
-#include <canvas/debug.hxx>
-#include <canvas/verbosetrace.hxx>
-#include <canvas/canvastools.hxx>
-
-#include <com/sun/star/rendering/XBitmap.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-
-#include <rtl/math.hxx>
-
-#include <vcl/metaact.hxx>
-#include <vcl/bitmapex.hxx>
-#include <vcl/canvastools.hxx>
-#include <vcl/svapp.hxx>
-#include <vcl/outdev.hxx>
-#include <vcl/virdev.hxx>
-#include <vcl/gdimtf.hxx>
-#include <vcl/gradient.hxx>
-
-#include <basegfx/range/b2drange.hxx>
-#include <basegfx/point/b2dpoint.hxx>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/numeric/ftools.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/tuple/b2dtuple.hxx>
-#include <basegfx/tools/canvastools.hxx>
-
-#include <boost/utility.hpp>
-
-#include "transparencygroupaction.hxx"
-#include "outdevstate.hxx"
-#include "mtftools.hxx"
-#include "cppcanvas/vclfactory.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- // free support functions
- // ======================
- namespace
- {
- class TransparencyGroupAction : public Action, private ::boost::noncopyable
- {
- public:
- /** Create new transparency group action.
-
- @param rGroupMtf
- Metafile that groups all actions to be rendered
- transparent.
-
- @param rAlphaGradient
- VCL gradient, to be rendered into the action's alpha
- channel.
-
- @param rParms
- Render parameters
-
- @param rDstPoint
- Left, top edge of destination, in current state
- coordinate system
-
- @param rDstSize
- Size of the transparency group object, in current
- state coordinate system.
- */
- TransparencyGroupAction( MtfAutoPtr& rGroupMtf,
- GradientAutoPtr& rAlphaGradient,
- const Renderer::Parameters& rParms,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
-
- virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
- virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const;
-
- virtual sal_Int32 getActionCount() const;
-
- private:
- MtfAutoPtr mpGroupMtf;
- GradientAutoPtr mpAlphaGradient;
-
- const Renderer::Parameters maParms;
-
- const ::basegfx::B2DSize maDstSize;
-
- mutable uno::Reference< rendering::XBitmap > mxBufferBitmap; // contains last rendered version
- mutable ::basegfx::B2DHomMatrix maLastTransformation; // contains last active transformation
- mutable Subset maLastSubset; // contains last effective subset
-
- // transformation for
- // mxBufferBitmap content
- CanvasSharedPtr mpCanvas;
- rendering::RenderState maState;
- const double mnAlpha;
- };
-
-
- /** Setup transformation such that the next render call is
- moved rPoint away, and scaled according to the ratio
- given by src and dst size.
- */
- void implSetupTransform( rendering::RenderState& rRenderState,
- const ::basegfx::B2DPoint& rDstPoint )
- {
- ::basegfx::B2DHomMatrix aLocalTransformation;
-
- aLocalTransformation.translate( rDstPoint.getX(),
- rDstPoint.getY() );
- ::canvas::tools::appendToRenderState( rRenderState,
- aLocalTransformation );
- }
-
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- TransparencyGroupAction::TransparencyGroupAction( MtfAutoPtr& rGroupMtf,
- GradientAutoPtr& rAlphaGradient,
- const Renderer::Parameters& rParms,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState ) :
- mpGroupMtf( rGroupMtf ),
- mpAlphaGradient( rAlphaGradient ),
- maParms( rParms ),
- maDstSize( rDstSize ),
- mxBufferBitmap(),
- maLastTransformation(),
- mpCanvas( rCanvas ),
- maState(),
- mnAlpha( 1.0 )
- {
- tools::initRenderState(maState,rState);
- implSetupTransform( maState, rDstPoint );
-
- // correct clip (which is relative to original transform)
- tools::modifyClip( maState,
- rState,
- rCanvas,
- rDstPoint,
- NULL,
- NULL );
-
- maLastSubset.mnSubsetBegin = 0;
- maLastSubset.mnSubsetEnd = -1;
- }
- SAL_WNODEPRECATED_DECLARATIONS_POP
-
- // TODO(P3): The whole float transparency handling is a mess,
- // this should be refactored. What's more, the old idea of
- // having only internal 'metaactions', and not the original
- // GDIMetaFile now looks a lot less attractive. Try to move
- // into the direction of having a direct GDIMetaFile2XCanvas
- // renderer, and maybe a separate metafile XCanvas
- // implementation.
- bool TransparencyGroupAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TransparencyGroupAction::renderSubset()" );
- SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::TransparencyGroupAction: 0x" << std::hex << this );
-
- // determine overall transformation matrix (render, view,
- // and passed transformation)
- ::basegfx::B2DHomMatrix aTransform;
- ::canvas::tools::getRenderStateTransform( aTransform, maState );
- aTransform = rTransformation * aTransform;
-
- ::basegfx::B2DHomMatrix aTotalTransform;
- ::canvas::tools::getViewStateTransform( aTotalTransform, mpCanvas->getViewState() );
- aTotalTransform = aTotalTransform * aTransform;
-
- // since pure translational changes to the transformation
- // does not matter, remove them before comparing
- aTotalTransform.set( 0, 2, 0.0 );
- aTotalTransform.set( 1, 2, 0.0 );
-
- // determine total scaling factor of the
- // transformation matrix - need to make the bitmap
- // large enough
- ::basegfx::B2DTuple aScale;
- ::basegfx::B2DTuple aTranslate;
- double nRotate;
- double nShearX;
- if( !aTotalTransform.decompose( aScale,
- aTranslate,
- nRotate,
- nShearX ) )
- {
- SAL_WARN( "cppcanvas.emf", "TransparencyGroupAction::renderSubset(): non-decomposable transformation" );
- return false;
- }
-
- // if there's no buffer bitmap, or as soon as the
- // total transformation changes, we've got to
- // re-render the bitmap
- if( !mxBufferBitmap.is() ||
- aTotalTransform != maLastTransformation ||
- rSubset.mnSubsetBegin != maLastSubset.mnSubsetBegin ||
- rSubset.mnSubsetEnd != maLastSubset.mnSubsetEnd )
- {
- DBG_TESTSOLARMUTEX();
-
- // output size of metafile
- ::Size aOutputSizePixel( ::basegfx::fround( aScale.getX() * maDstSize.getX() ),
- ::basegfx::fround( aScale.getY() * maDstSize.getY() ) );
-
- // pixel size of cache bitmap: round up to nearest int
- ::Size aBitmapSizePixel( static_cast<sal_Int32>( aScale.getX() * maDstSize.getX() )+1,
- static_cast<sal_Int32>( aScale.getY() * maDstSize.getY() )+1 );
-
- ::Point aEmptyPoint;
-
- // render our content into an appropriately sized
- // VirtualDevice with alpha channel
- VirtualDevice aVDev(
- *::Application::GetDefaultDevice(), 0, 0 );
- aVDev.SetOutputSizePixel( aBitmapSizePixel );
- aVDev.SetMapMode();
-
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != -1 )
- {
- // true subset - extract referenced
- // metaactions from mpGroupMtf
- GDIMetaFile aMtf;
- MetaAction* pCurrAct;
- int nCurrActionIndex;
-
- // extract subset actions
- for( nCurrActionIndex=0,
- pCurrAct=mpGroupMtf->FirstAction();
- pCurrAct;
- ++nCurrActionIndex, pCurrAct = mpGroupMtf->NextAction() )
- {
- switch( pCurrAct->GetType() )
- {
- case META_PUSH_ACTION:
- case META_POP_ACTION:
- case META_CLIPREGION_ACTION:
- case META_ISECTRECTCLIPREGION_ACTION:
- case META_ISECTREGIONCLIPREGION_ACTION:
- case META_MOVECLIPREGION_ACTION:
- case META_LINECOLOR_ACTION:
- case META_FILLCOLOR_ACTION:
- case META_TEXTCOLOR_ACTION:
- case META_TEXTFILLCOLOR_ACTION:
- case META_TEXTLINECOLOR_ACTION:
- case META_TEXTALIGN_ACTION:
- case META_FONT_ACTION:
- case META_RASTEROP_ACTION:
- case META_REFPOINT_ACTION:
- case META_LAYOUTMODE_ACTION:
- // state-changing action - copy as-is
- aMtf.AddAction( pCurrAct->Clone() );
- break;
-
- case META_GRADIENT_ACTION:
- case META_HATCH_ACTION:
- case META_EPS_ACTION:
- case META_COMMENT_ACTION:
- case META_POINT_ACTION:
- case META_PIXEL_ACTION:
- case META_LINE_ACTION:
- case META_RECT_ACTION:
- case META_ROUNDRECT_ACTION:
- case META_ELLIPSE_ACTION:
- case META_ARC_ACTION:
- case META_PIE_ACTION:
- case META_CHORD_ACTION:
- case META_POLYLINE_ACTION:
- case META_POLYGON_ACTION:
- case META_POLYPOLYGON_ACTION:
- case META_BMP_ACTION:
- case META_BMPSCALE_ACTION:
- case META_BMPSCALEPART_ACTION:
- case META_BMPEX_ACTION:
- case META_BMPEXSCALE_ACTION:
- case META_BMPEXSCALEPART_ACTION:
- case META_MASK_ACTION:
- case META_MASKSCALE_ACTION:
- case META_MASKSCALEPART_ACTION:
- case META_GRADIENTEX_ACTION:
- case META_WALLPAPER_ACTION:
- case META_TRANSPARENT_ACTION:
- case META_FLOATTRANSPARENT_ACTION:
- case META_TEXT_ACTION:
- case META_TEXTARRAY_ACTION:
- case META_TEXTLINE_ACTION:
- case META_TEXTRECT_ACTION:
- case META_STRETCHTEXT_ACTION:
- // output-generating action - only
- // copy, if we're within the
- // requested subset
- if( rSubset.mnSubsetBegin <= nCurrActionIndex &&
- rSubset.mnSubsetEnd > nCurrActionIndex )
- {
- aMtf.AddAction( pCurrAct->Clone() );
- }
- break;
-
- default:
- SAL_WARN( "cppcanvas.emf", "Unknown meta action type encountered" );
- break;
- }
- }
-
- aVDev.DrawTransparent( aMtf,
- aEmptyPoint,
- aOutputSizePixel,
- *mpAlphaGradient );
- }
- else
- {
- // no subsetting - render whole mtf
- aVDev.DrawTransparent( *mpGroupMtf,
- aEmptyPoint,
- aOutputSizePixel,
- *mpAlphaGradient );
- }
-
-
- // update buffered bitmap and transformation
- BitmapSharedPtr aBmp( VCLFactory::getInstance().createBitmap(
- mpCanvas,
- aVDev.GetBitmapEx(
- aEmptyPoint,
- aBitmapSizePixel ) ) );
- mxBufferBitmap = aBmp->getUNOBitmap();
- maLastTransformation = aTotalTransform;
- maLastSubset = rSubset;
- }
-
- // determine target transformation (we can't simply pass
- // aTotalTransform as assembled above, since we must take
- // the canvas' view state as is, it might contain clipping
- // (which, in turn, is relative to the view
- // transformation))
-
- // given that aTotalTransform is the identity
- // transformation, we could simply render our bitmap
- // as-is. Now, since the mxBufferBitmap content already
- // accounts for scale changes in the overall
- // transformation, we must factor this out
- // before. Generally, the transformation matrix should be
- // structured like this:
- // Translation*Rotation*Shear*Scale. Thus, to neutralize
- // the contained scaling, we've got to right-multiply with
- // the inverse.
- ::basegfx::B2DHomMatrix aScaleCorrection;
- aScaleCorrection.scale( 1/aScale.getX(), 1/aScale.getY() );
- aTransform = aTransform * aScaleCorrection;
-
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::setRenderStateTransform(aLocalState, aTransform);
-
-#if OSL_DEBUG_LEVEL > 2
- aLocalState.Clip.clear();
- aLocalState.DeviceColor =
- ::vcl::unotools::colorToDoubleSequence(
- ::Color( 0x80FF0000 ),
- mpCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
-
- if( maState.Clip.is() )
- mpCanvas->getUNOCanvas()->fillPolyPolygon( maState.Clip,
- mpCanvas->getViewState(),
- aLocalState );
-
- aLocalState.DeviceColor = maState.DeviceColor;
-#endif
-
- if( ::rtl::math::approxEqual(mnAlpha, 1.0) )
- {
- // no further alpha changes necessary -> draw directly
- mpCanvas->getUNOCanvas()->drawBitmap( mxBufferBitmap,
- mpCanvas->getViewState(),
- aLocalState );
- }
- else
- {
- // add alpha modulation value to DeviceColor
- uno::Sequence<rendering::ARGBColor> aCols(1);
- aCols[0] = rendering::ARGBColor( mnAlpha, 1.0, 1.0, 1.0);
- aLocalState.DeviceColor =
- mpCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(
- aCols);
-
- mpCanvas->getUNOCanvas()->drawBitmapModulated( mxBufferBitmap,
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- return true;
- }
-
- // TODO(P3): The whole float transparency handling is a mess,
- // this should be refactored. What's more, the old idea of
- // having only internal 'metaactions', and not the original
- // GDIMetaFile now looks a lot less attractive. Try to move
- // into the direction of having a direct GDIMetaFile2XCanvas
- // renderer, and maybe a separate metafile XCanvas
- // implementation.
- bool TransparencyGroupAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- Subset aSubset;
-
- aSubset.mnSubsetBegin = 0;
- aSubset.mnSubsetEnd = -1;
-
- return renderSubset( rTransformation, aSubset );
- }
-
- ::basegfx::B2DRange TransparencyGroupAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
- {
- rendering::RenderState aLocalState( maState );
- ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
-
- return tools::calcDevicePixelBounds(
- ::basegfx::B2DRange( 0,0,
- maDstSize.getX(),
- maDstSize.getY() ),
- mpCanvas->getViewState(),
- aLocalState );
- }
-
- ::basegfx::B2DRange TransparencyGroupAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
- const Subset& rSubset ) const
- {
- // TODO(F3): Currently, the bounds for
- // TransparencyGroupAction subsets equal those of the
- // full set, although this action is able to render
- // true subsets.
-
- // polygon only contains a single action, empty bounds
- // if subset requests different range
- if( rSubset.mnSubsetBegin != 0 ||
- rSubset.mnSubsetEnd != 1 )
- return ::basegfx::B2DRange();
-
- return getBounds( rTransformation );
- }
-
- sal_Int32 TransparencyGroupAction::getActionCount() const
- {
- return mpGroupMtf.get() ? mpGroupMtf->GetActionSize() : 0;
- }
-
- }
-
- SAL_WNODEPRECATED_DECLARATIONS_PUSH
- ActionSharedPtr TransparencyGroupActionFactory::createTransparencyGroupAction( MtfAutoPtr& rGroupMtf,
- GradientAutoPtr& rAlphaGradient,
- const Renderer::Parameters& rParms,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState )
- {
- return ActionSharedPtr( new TransparencyGroupAction(rGroupMtf,
- rAlphaGradient,
- rParms,
- rDstPoint,
- rDstSize,
- rCanvas,
- rState ) );
- }
- SAL_WNODEPRECATED_DECLARATIONS_POP
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx b/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx
deleted file mode 100644
index dbe58b382bcb..000000000000
--- a/cppcanvas/source/mtfrenderer/transparencygroupaction.hxx
+++ /dev/null
@@ -1,106 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_TRANSPARENCYGROUPACTION_HXX
-#define _CPPCANVAS_TRANSPARENCYGROUPACTION_HXX
-
-#include <cppcanvas/canvas.hxx>
-#include <cppcanvas/renderer.hxx>
-#include <action.hxx>
-
-#include <memory> // auto_ptr
-
-namespace basegfx {
- class B2DPoint;
- class B2DVector;
-}
-
-class GDIMetaFile;
-class Gradient;
-
-
-/* Definition of internal::TransparencyGroupActionFactory class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- struct OutDevState;
-
- typedef ::std::auto_ptr< GDIMetaFile > MtfAutoPtr;
- typedef ::std::auto_ptr< Gradient > GradientAutoPtr;
-
- /** Transparency group action.
-
- This action groups a bunch of other actions, to be
- rendered with the given transparency setting against the
- background.
-
- Creates encapsulated converters between GDIMetaFile and
- XCanvas. The Canvas argument is deliberately placed at the
- constructor, to force reconstruction of this object for a
- new canvas. This considerably eases internal state
- handling, since a lot of the internal state (e.g. fonts,
- text layout) is Canvas-dependent.
- */
- class TransparencyGroupActionFactory
- {
- public:
- /** Create new transparency group action.
-
- @param rGroupMtf
- Metafile that groups all actions to be rendered
- transparent.
-
- @param rAlphaGradient
- VCL gradient, to be rendered into the action's alpha
- channel.
-
- @param rParms
- Render parameters
-
- @param rDstPoint
- Left, top edge of destination, in current state
- coordinate system
-
- @param rDstSize
- Size of the transparency group object, in current
- state coordinate system.
- */
- static ActionSharedPtr createTransparencyGroupAction( MtfAutoPtr& rGroupMtf,
- GradientAutoPtr& rAlphaGradient,
- const Renderer::Parameters& rParms,
- const ::basegfx::B2DPoint& rDstPoint,
- const ::basegfx::B2DVector& rDstSize,
- const CanvasSharedPtr& rCanvas,
- const OutDevState& rState );
-
- private:
- // static factory, disable big four
- TransparencyGroupActionFactory();
- ~TransparencyGroupActionFactory();
- TransparencyGroupActionFactory(const TransparencyGroupActionFactory&);
- TransparencyGroupActionFactory& operator=( const TransparencyGroupActionFactory& );
- };
- }
-}
-
-#endif /*_CPPCANVAS_TRANSPARENCYGROUPACTION_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/tools/canvasgraphichelper.cxx b/cppcanvas/source/tools/canvasgraphichelper.cxx
deleted file mode 100644
index 562be9715d58..000000000000
--- a/cppcanvas/source/tools/canvasgraphichelper.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <canvasgraphichelper.hxx>
-
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-
-#include <canvas/canvastools.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-
-#include <cppcanvas/polypolygon.hxx>
-#include "tools.hxx"
-
-
-using namespace ::com::sun::star;
-
-/* Implementation of CanvasGraphicHelper class */
-
-namespace cppcanvas
-{
-
- namespace internal
- {
- CanvasGraphicHelper::CanvasGraphicHelper( const CanvasSharedPtr& rParentCanvas ) :
- maClipPolyPolygon(),
- mpCanvas( rParentCanvas ),
- mxGraphicDevice()
- {
- OSL_ENSURE( mpCanvas.get() != NULL &&
- mpCanvas->getUNOCanvas().is(),
- "CanvasGraphicHelper::CanvasGraphicHelper: no valid canvas" );
-
- if( mpCanvas.get() != NULL &&
- mpCanvas->getUNOCanvas().is() )
- {
- mxGraphicDevice = mpCanvas->getUNOCanvas()->getDevice();
- }
-
- ::canvas::tools::initRenderState( maRenderState );
- }
-
- void CanvasGraphicHelper::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
- {
- ::canvas::tools::setRenderStateTransform( maRenderState, rMatrix );
- }
-
- ::basegfx::B2DHomMatrix CanvasGraphicHelper::getTransformation() const
- {
- ::basegfx::B2DHomMatrix aMatrix;
- return ::canvas::tools::getRenderStateTransform( aMatrix,
- maRenderState );
- }
-
- void CanvasGraphicHelper::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
- {
- // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
- maClipPolyPolygon.reset( rClipPoly );
- maRenderState.Clip.clear();
- }
-
- void CanvasGraphicHelper::setClip()
- {
- maClipPolyPolygon.reset();
- maRenderState.Clip.clear();
- }
-
- ::basegfx::B2DPolyPolygon const* CanvasGraphicHelper::getClip() const
- {
- return !maClipPolyPolygon ? NULL : &(*maClipPolyPolygon);
- }
-
- const rendering::RenderState& CanvasGraphicHelper::getRenderState() const
- {
- if( maClipPolyPolygon && !maRenderState.Clip.is() )
- {
- uno::Reference< rendering::XCanvas > xCanvas( mpCanvas->getUNOCanvas() );
- if( !xCanvas.is() )
- return maRenderState;
-
- maRenderState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- xCanvas->getDevice(),
- *maClipPolyPolygon );
- }
-
- return maRenderState;
- }
-
- void CanvasGraphicHelper::setCompositeOp( CompositeOp aOp )
- {
- maRenderState.CompositeOperation = (sal_Int8)aOp;
- }
-
- CanvasGraphic::CompositeOp CanvasGraphicHelper::getCompositeOp() const
- {
- return static_cast<CompositeOp>(maRenderState.CompositeOperation);
- }
-
- CanvasSharedPtr CanvasGraphicHelper::getCanvas() const
- {
- return mpCanvas;
- }
-
- uno::Reference< rendering::XGraphicDevice > CanvasGraphicHelper::getGraphicDevice() const
- {
- return mxGraphicDevice;
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/tools/tools.cxx b/cppcanvas/source/tools/tools.cxx
deleted file mode 100644
index db4dd13c2f59..000000000000
--- a/cppcanvas/source/tools/tools.cxx
+++ /dev/null
@@ -1,54 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <tools.hxx>
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace tools
- {
- uno::Sequence< double > intSRGBAToDoubleSequence( const uno::Reference< rendering::XGraphicDevice >&,
- Color::IntSRGBA aColor )
- {
- uno::Sequence< double > aRes( 4 );
-
- aRes[0] = getRed(aColor) / 255.0;
- aRes[1] = getGreen(aColor) / 255.0;
- aRes[2] = getBlue(aColor) / 255.0;
- aRes[3] = getAlpha(aColor) / 255.0;
-
- return aRes;
- }
-
- Color::IntSRGBA doubleSequenceToIntSRGBA( const uno::Reference< rendering::XGraphicDevice >&,
- const uno::Sequence< double >& rColor )
- {
- return makeColor( static_cast<sal_uInt8>( 255*rColor[0] + .5 ),
- static_cast<sal_uInt8>( 255*rColor[1] + .5 ),
- static_cast<sal_uInt8>( 255*rColor[2] + .5 ),
- static_cast<sal_uInt8>( 255*rColor[3] + .5 ) );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/uno/mtfrenderer.component b/cppcanvas/source/uno/mtfrenderer.component
deleted file mode 100644
index 29ab06557db8..000000000000
--- a/cppcanvas/source/uno/mtfrenderer.component
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
--->
-<component loader="com.sun.star.loader.SharedLibrary" prefix="mtfrenderer"
- xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.rendering.MtfRenderer">
- <service name="com.sun.star.rendering.MtfRenderer"/>
- </implementation>
-</component>
diff --git a/cppcanvas/source/uno/uno_mtfrenderer.cxx b/cppcanvas/source/uno/uno_mtfrenderer.cxx
deleted file mode 100644
index 63271d7940df..000000000000
--- a/cppcanvas/source/uno/uno_mtfrenderer.cxx
+++ /dev/null
@@ -1,58 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "uno_mtfrenderer.hxx"
-#include <cppcanvas/vclfactory.hxx>
-#include <comphelper/servicedecl.hxx>
-#include <cppuhelper/factory.hxx>
-
-using namespace ::com::sun::star;
-
-void MtfRenderer::setMetafile (const uno::Sequence< sal_Int8 >& /*rMtf*/) throw (uno::RuntimeException)
-{
- // printf ("MtfRenderer::setMetafile unimplemented, use fast property set or implement me\n");
-}
-
-void MtfRenderer::draw (double fScaleX, double fScaleY) throw (uno::RuntimeException)
-{
- if (mpMetafile && mxCanvas.get()) {
- cppcanvas::VCLFactory& factory = cppcanvas::VCLFactory::getInstance();
- cppcanvas::BitmapCanvasSharedPtr canvas = factory.createCanvas (mxCanvas);
- cppcanvas::RendererSharedPtr renderer = factory.createRenderer (canvas, *mpMetafile, cppcanvas::Renderer::Parameters ());
- ::basegfx::B2DHomMatrix aMatrix;
- aMatrix.scale( fScaleX, fScaleY );
- canvas->setTransformation( aMatrix );
- renderer->draw ();
- }
-}
-
-void MtfRenderer::setFastPropertyValue( sal_Int32 nHandle, const uno::Any& aAny) throw (uno::RuntimeException)
-{
- if (nHandle == 0) {
- mpMetafile = (GDIMetaFile*) *reinterpret_cast<const sal_Int64*>(aAny.getValue());
- }
-}
-
-MtfRenderer::MtfRenderer (uno::Sequence<uno::Any> const& aArgs, uno::Reference<uno::XComponentContext> const&) : MtfRendererBase (m_aMutex), mpMetafile (NULL)
-{
- if( aArgs.getLength() == 1 ) {
- aArgs[0] >>= mxCanvas;
- }
-}
-
-namespace sdecl = comphelper::service_decl;
- const sdecl::ServiceDecl MtfRendererDecl(
- sdecl::class_<MtfRenderer, sdecl::with_args<true> >(),
- "com.sun.star.comp.rendering.MtfRenderer",
- "com.sun.star.rendering.MtfRenderer" );
-
-// The C shared lib entry points
-COMPHELPER_SERVICEDECL_EXPORTS1(mtfrenderer, MtfRendererDecl)
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/uno/uno_mtfrenderer.hxx b/cppcanvas/source/uno/uno_mtfrenderer.hxx
deleted file mode 100644
index afd9e82a8676..000000000000
--- a/cppcanvas/source/uno/uno_mtfrenderer.hxx
+++ /dev/null
@@ -1,44 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#ifndef _UNO_MTF_RENDERER_HXX_
-#define _UNO_MTF_RENDERER_HXX_
-#include <com/sun/star/rendering/MtfRenderer.hpp>
-#include <com/sun/star/rendering/XBitmapCanvas.hpp>
-#include <com/sun/star/uno/XComponentContext.hpp>
-#include <com/sun/star/beans/XFastPropertySet.hpp>
-#include <cppuhelper/compbase2.hxx>
-#include <cppuhelper/basemutex.hxx>
-#include <vcl/gdimtf.hxx>
-
-typedef cppu::WeakComponentImplHelper2<com::sun::star::rendering::XMtfRenderer, com::sun::star::beans::XFastPropertySet> MtfRendererBase;
-
-class MtfRenderer : private cppu::BaseMutex, public MtfRendererBase
-{
-public:
- MtfRenderer (com::sun::star::uno::Sequence<com::sun::star::uno::Any> const& args,
- com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> const&);
-
- // XMtfRenderer iface
- void SAL_CALL setMetafile (const ::com::sun::star::uno::Sequence< sal_Int8 >& rMtf) throw (::com::sun::star::uno::RuntimeException);
- void SAL_CALL draw (double fScaleX, double fScaleY) throw (::com::sun::star::uno::RuntimeException);
-
- // XFastPropertySet
- // setFastPropertyValue (0, GDIMetaFile*) is used to speedup the rendering
- virtual ::com::sun::star::uno::Any SAL_CALL getFastPropertyValue(sal_Int32 /*nHandle*/) throw (::com::sun::star::uno::RuntimeException) { return ::com::sun::star::uno::Any(); }
- virtual void SAL_CALL setFastPropertyValue(sal_Int32 nHandle, const ::com::sun::star::uno::Any&) throw (::com::sun::star::uno::RuntimeException);
-
-private:
- GDIMetaFile* mpMetafile;
- com::sun::star::uno::Reference<com::sun::star::rendering::XBitmapCanvas> mxCanvas;
-};
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/basegfxfactory.cxx b/cppcanvas/source/wrapper/basegfxfactory.cxx
deleted file mode 100644
index 96020de28a95..000000000000
--- a/cppcanvas/source/wrapper/basegfxfactory.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <rtl/instance.hxx>
-#include <osl/getglobalmutex.hxx>
-#include <osl/diagnose.h>
-
-#include <com/sun/star/rendering/InterpolationMode.hpp>
-
-#include <basegfx/polygon/b2dpolygon.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/tools/canvastools.hxx>
-
-#include <cppcanvas/basegfxfactory.hxx>
-
-#include <com/sun/star/rendering/RenderState.hpp>
-#include <com/sun/star/rendering/StringContext.hpp>
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/XCanvasFont.hpp>
-
-#include <cppcanvas/text.hxx>
-#include <canvasgraphichelper.hxx>
-
-#include "implpolypolygon.hxx"
-#include "implbitmap.hxx"
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- /* Singleton handling */
- struct InitInstance2
- {
- BaseGfxFactory* operator()()
- {
- return new BaseGfxFactory();
- }
- };
-
- BaseGfxFactory& BaseGfxFactory::getInstance()
- {
- return *rtl_Instance< BaseGfxFactory, InitInstance2, ::osl::MutexGuard,
- ::osl::GetGlobalMutex >::create(
- InitInstance2(), ::osl::GetGlobalMutex());
- }
-
- BaseGfxFactory::BaseGfxFactory()
- {
- }
-
- PolyPolygonSharedPtr BaseGfxFactory::createPolyPolygon( const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2DPolygon& rPoly ) const
- {
- OSL_ENSURE( rCanvas.get() != NULL &&
- rCanvas->getUNOCanvas().is(),
- "BaseGfxFactory::createPolyPolygon(): Invalid canvas" );
-
- if( rCanvas.get() == NULL )
- return PolyPolygonSharedPtr();
-
- uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
- if( !xCanvas.is() )
- return PolyPolygonSharedPtr();
-
- return PolyPolygonSharedPtr(
- new internal::ImplPolyPolygon( rCanvas,
- ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
- xCanvas->getDevice(),
- rPoly) ) );
- }
-
- BitmapSharedPtr BaseGfxFactory::createBitmap( const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2ISize& rSize ) const
- {
- OSL_ENSURE( rCanvas.get() != NULL &&
- rCanvas->getUNOCanvas().is(),
- "BaseGfxFactory::createBitmap(): Invalid canvas" );
-
- if( rCanvas.get() == NULL )
- return BitmapSharedPtr();
-
- uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
- if( !xCanvas.is() )
- return BitmapSharedPtr();
-
- return BitmapSharedPtr(
- new internal::ImplBitmap( rCanvas,
- xCanvas->getDevice()->createCompatibleBitmap(
- ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
- }
-
- BitmapSharedPtr BaseGfxFactory::createAlphaBitmap( const CanvasSharedPtr& rCanvas,
- const ::basegfx::B2ISize& rSize ) const
- {
- OSL_ENSURE( rCanvas.get() != NULL &&
- rCanvas->getUNOCanvas().is(),
- "BaseGfxFactory::createBitmap(): Invalid canvas" );
-
- if( rCanvas.get() == NULL )
- return BitmapSharedPtr();
-
- uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
- if( !xCanvas.is() )
- return BitmapSharedPtr();
-
- return BitmapSharedPtr(
- new internal::ImplBitmap( rCanvas,
- xCanvas->getDevice()->createCompatibleAlphaBitmap(
- ::basegfx::unotools::integerSize2DFromB2ISize(rSize) ) ) );
- }
-
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implbitmap.cxx b/cppcanvas/source/wrapper/implbitmap.cxx
deleted file mode 100644
index a95a36f250ea..000000000000
--- a/cppcanvas/source/wrapper/implbitmap.cxx
+++ /dev/null
@@ -1,118 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include "implbitmap.hxx"
-#include "implbitmapcanvas.hxx"
-
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <canvas/canvastools.hxx>
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
-
- namespace internal
- {
-
- ImplBitmap::ImplBitmap( const CanvasSharedPtr& rParentCanvas,
- const uno::Reference< rendering::XBitmap >& rBitmap ) :
- CanvasGraphicHelper( rParentCanvas ),
- mxBitmap( rBitmap ),
- mpBitmapCanvas()
- {
- OSL_ENSURE( mxBitmap.is(), "ImplBitmap::ImplBitmap: no valid bitmap" );
-
- uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( rBitmap,
- uno::UNO_QUERY );
- if( xBitmapCanvas.is() )
- mpBitmapCanvas.reset( new ImplBitmapCanvas(
- uno::Reference< rendering::XBitmapCanvas >(rBitmap,
- uno::UNO_QUERY) ) );
- }
-
- ImplBitmap::~ImplBitmap()
- {
- }
-
- bool ImplBitmap::draw() const
- {
- CanvasSharedPtr pCanvas( getCanvas() );
-
- OSL_ENSURE( pCanvas.get() != NULL &&
- pCanvas->getUNOCanvas().is(),
- "ImplBitmap::draw: invalid canvas" );
-
- if( pCanvas.get() == NULL ||
- !pCanvas->getUNOCanvas().is() )
- {
- return false;
- }
-
- // TODO(P1): implement caching
- pCanvas->getUNOCanvas()->drawBitmap( mxBitmap,
- pCanvas->getViewState(),
- getRenderState() );
-
- return true;
- }
-
- bool ImplBitmap::drawAlphaModulated( double nAlphaModulation ) const
- {
- CanvasSharedPtr pCanvas( getCanvas() );
-
- OSL_ENSURE( pCanvas.get() != NULL &&
- pCanvas->getUNOCanvas().is(),
- "ImplBitmap::drawAlphaModulated(): invalid canvas" );
-
- if( pCanvas.get() == NULL ||
- !pCanvas->getUNOCanvas().is() )
- {
- return false;
- }
-
- rendering::RenderState aLocalState( getRenderState() );
- uno::Sequence<rendering::ARGBColor> aCol(1);
- aCol[0] = rendering::ARGBColor( nAlphaModulation, 1.0, 1.0, 1.0 );
- aLocalState.DeviceColor =
- pCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace()->convertFromARGB(aCol);
-
- // TODO(P1): implement caching
- pCanvas->getUNOCanvas()->drawBitmapModulated( mxBitmap,
- pCanvas->getViewState(),
- aLocalState );
-
- return true;
- }
-
- BitmapCanvasSharedPtr ImplBitmap::getBitmapCanvas() const
- {
- return mpBitmapCanvas;
- }
-
- uno::Reference< rendering::XBitmap > ImplBitmap::getUNOBitmap() const
- {
- return mxBitmap;
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implbitmap.hxx b/cppcanvas/source/wrapper/implbitmap.hxx
deleted file mode 100644
index d080e3c0e589..000000000000
--- a/cppcanvas/source/wrapper/implbitmap.hxx
+++ /dev/null
@@ -1,72 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLBITMAP_HXX
-#define _CPPCANVAS_IMPLBITMAP_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/rendering/XBitmap.hpp>
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-
-#include <cppcanvas/bitmap.hxx>
-#include <canvasgraphichelper.hxx>
-
-
-/*Definition of ImplBitmap */
-
-namespace cppcanvas
-{
-
- namespace internal
- {
- // share partial CanvasGraphic implementation from CanvasGraphicHelper
- class ImplBitmap : public virtual ::cppcanvas::Bitmap, protected CanvasGraphicHelper
- {
- public:
-
- ImplBitmap( const CanvasSharedPtr& rParentCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap >& rBitmap );
-
- virtual ~ImplBitmap();
-
- // CanvasGraphic implementation (that was not already implemented by CanvasGraphicHelper)
- virtual bool draw() const;
- virtual bool drawAlphaModulated( double nAlphaModulation ) const;
-
- virtual BitmapCanvasSharedPtr getBitmapCanvas() const;
-
- // Bitmap implementation
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmap > getUNOBitmap() const;
-
- private:
- // default: disabled copy/assignment
- ImplBitmap(const ImplBitmap&);
- ImplBitmap& operator=( const ImplBitmap& );
-
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > mxBitmap;
- BitmapCanvasSharedPtr mpBitmapCanvas;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLBITMAP_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implbitmapcanvas.cxx b/cppcanvas/source/wrapper/implbitmapcanvas.cxx
deleted file mode 100644
index 35f335b4e63d..000000000000
--- a/cppcanvas/source/wrapper/implbitmapcanvas.cxx
+++ /dev/null
@@ -1,65 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/XBitmapCanvas.hpp>
-
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/tools/canvastools.hxx>
-
-#include "implbitmapcanvas.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- ImplBitmapCanvas::ImplBitmapCanvas( const uno::Reference< rendering::XBitmapCanvas >& rCanvas ) :
- ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
- uno::UNO_QUERY) ),
- mxBitmapCanvas( rCanvas ),
- mxBitmap( rCanvas,
- uno::UNO_QUERY )
- {
- OSL_ENSURE( mxBitmapCanvas.is(), "ImplBitmapCanvas::ImplBitmapCanvas(): Invalid canvas" );
- OSL_ENSURE( mxBitmap.is(), "ImplBitmapCanvas::ImplBitmapCanvas(): Invalid bitmap" );
- }
-
- ImplBitmapCanvas::~ImplBitmapCanvas()
- {
- }
-
- ::basegfx::B2ISize ImplBitmapCanvas::getSize() const
- {
- OSL_ENSURE( mxBitmap.is(), "ImplBitmapCanvas::getSize(): Invalid canvas" );
- return ::basegfx::unotools::b2ISizeFromIntegerSize2D( mxBitmap->getSize() );
- }
-
- CanvasSharedPtr ImplBitmapCanvas::clone() const
- {
- return BitmapCanvasSharedPtr( new ImplBitmapCanvas( *this ) );
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implbitmapcanvas.hxx b/cppcanvas/source/wrapper/implbitmapcanvas.hxx
deleted file mode 100644
index 705125360e03..000000000000
--- a/cppcanvas/source/wrapper/implbitmapcanvas.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLBITMAPCANVAS_HXX
-#define _CPPCANVAS_IMPLBITMAPCANVAS_HXX
-
-#include <com/sun/star/rendering/XBitmapCanvas.hpp>
-#include <com/sun/star/rendering/XBitmap.hpp>
-
-#include <boost/shared_ptr.hpp>
-#include <basegfx/vector/b2dsize.hxx>
-#include <cppcanvas/bitmapcanvas.hxx>
-
-#include <implcanvas.hxx>
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- // share Canvas implementation from ImplCanvas
- class ImplBitmapCanvas : public virtual BitmapCanvas, protected virtual ImplCanvas
- {
- public:
- ImplBitmapCanvas( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XBitmapCanvas >& rCanvas );
- virtual ~ImplBitmapCanvas();
-
- virtual ::basegfx::B2ISize getSize() const;
-
- virtual CanvasSharedPtr clone() const;
-
- // take compiler-provided default copy constructor
- //ImplBitmapCanvas(const ImplBitmapCanvas&);
-
- private:
- // default: disabled assignment
- ImplBitmapCanvas& operator=( const ImplBitmapCanvas& );
-
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmapCanvas > mxBitmapCanvas;
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XBitmap > mxBitmap;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLBITMAPCANVAS_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcanvas.cxx b/cppcanvas/source/wrapper/implcanvas.cxx
deleted file mode 100644
index 70a4c3f24f42..000000000000
--- a/cppcanvas/source/wrapper/implcanvas.cxx
+++ /dev/null
@@ -1,133 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <rtl/ustring.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <basegfx/tools/canvastools.hxx>
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-
-#include <canvas/canvastools.hxx>
-#include <cppcanvas/polypolygon.hxx>
-
-#include "implfont.hxx"
-#include "implcolor.hxx"
-#include "implcanvas.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
-
- ImplCanvas::ImplCanvas( const uno::Reference< rendering::XCanvas >& xCanvas ) :
- maViewState(),
- maClipPolyPolygon(),
- mxCanvas( xCanvas )
- {
- OSL_ENSURE( mxCanvas.is(), "Canvas::Canvas() invalid XCanvas" );
-
- ::canvas::tools::initViewState( maViewState );
- }
-
- ImplCanvas::~ImplCanvas()
- {
- }
-
- void ImplCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
- {
- ::canvas::tools::setViewStateTransform( maViewState, rMatrix );
- }
-
- ::basegfx::B2DHomMatrix ImplCanvas::getTransformation() const
- {
- ::basegfx::B2DHomMatrix aMatrix;
- return ::canvas::tools::getViewStateTransform( aMatrix,
- maViewState );
- }
-
- void ImplCanvas::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
- {
- // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
- maClipPolyPolygon.reset( rClipPoly );
- maViewState.Clip.clear();
- }
-
- void ImplCanvas::setClip()
- {
- maClipPolyPolygon.reset();
- maViewState.Clip.clear();
- }
-
- ::basegfx::B2DPolyPolygon const* ImplCanvas::getClip() const
- {
- return !maClipPolyPolygon ? NULL : &(*maClipPolyPolygon);
- }
-
- FontSharedPtr ImplCanvas::createFont( const OUString& rFontName, const double& rCellSize ) const
- {
- return FontSharedPtr( new ImplFont( getUNOCanvas(), rFontName, rCellSize ) );
- }
-
- ColorSharedPtr ImplCanvas::createColor() const
- {
- return ColorSharedPtr( new ImplColor( getUNOCanvas()->getDevice() ) );
- }
-
- CanvasSharedPtr ImplCanvas::clone() const
- {
- return CanvasSharedPtr( new ImplCanvas( *this ) );
- }
-
- void ImplCanvas::clear() const
- {
- OSL_ENSURE( mxCanvas.is(), "ImplCanvas::clear(): Invalid XCanvas" );
- mxCanvas->clear();
- }
-
- uno::Reference< rendering::XCanvas > ImplCanvas::getUNOCanvas() const
- {
- OSL_ENSURE( mxCanvas.is(), "ImplCanvas::getUNOCanvas(): Invalid XCanvas" );
-
- return mxCanvas;
- }
-
- rendering::ViewState ImplCanvas::getViewState() const
- {
- if( maClipPolyPolygon && !maViewState.Clip.is() )
- {
- if( !mxCanvas.is() )
- return maViewState;
-
- maViewState.Clip = ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- mxCanvas->getDevice(),
- *maClipPolyPolygon );
- }
-
- return maViewState;
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcanvas.hxx b/cppcanvas/source/wrapper/implcanvas.hxx
deleted file mode 100644
index cda88f564664..000000000000
--- a/cppcanvas/source/wrapper/implcanvas.hxx
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLCANVAS_HXX
-#define _CPPCANVAS_IMPLCANVAS_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/rendering/ViewState.hpp>
-#include <cppcanvas/canvas.hxx>
-
-#include <boost/optional.hpp>
-
-
-namespace basegfx
-{
- class B2DHomMatrix;
- class B2DPolyPolygon;
-}
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- class XCanvas;
-} } } }
-
-
-/* Definition of ImplCanvas */
-
-namespace cppcanvas
-{
-
- namespace internal
- {
-
- class ImplCanvas : public virtual Canvas
- {
- public:
- ImplCanvas( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvas >& rCanvas );
- virtual ~ImplCanvas();
-
- virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix );
- virtual ::basegfx::B2DHomMatrix getTransformation() const;
-
- virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly );
- virtual void setClip();
- virtual ::basegfx::B2DPolyPolygon const* getClip() const;
-
- virtual FontSharedPtr createFont( const OUString& rFontName, const double& rCellSize ) const;
-
- virtual ColorSharedPtr createColor() const;
-
- virtual CanvasSharedPtr clone() const;
-
- virtual void clear() const;
-
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvas > getUNOCanvas() const;
-
- virtual ::com::sun::star::rendering::ViewState getViewState() const;
-
- // take compiler-provided default copy constructor
- //ImplCanvas(const ImplCanvas&);
-
- private:
- // default: disabled assignment
- ImplCanvas& operator=( const ImplCanvas& );
-
- mutable ::com::sun::star::rendering::ViewState maViewState;
- boost::optional<basegfx::B2DPolyPolygon> maClipPolyPolygon;
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxCanvas;
- };
-
- }
-}
-
-#endif /* _CPPCANVAS_IMPLCANVAS_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcolor.cxx b/cppcanvas/source/wrapper/implcolor.cxx
deleted file mode 100644
index d98ffd2ac139..000000000000
--- a/cppcanvas/source/wrapper/implcolor.cxx
+++ /dev/null
@@ -1,60 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <implcolor.hxx>
-#include <tools.hxx>
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
-
- ImplColor::ImplColor( const uno::Reference< rendering::XGraphicDevice >& rDevice ) :
- mxDevice( rDevice )
- {
- OSL_ENSURE( mxDevice.is(), "ImplColor::ImplColor(): Invalid graphic device" );
- }
-
- ImplColor::~ImplColor()
- {
- }
-
- Color::IntSRGBA ImplColor::getIntSRGBA( uno::Sequence< double >& rDeviceColor ) const
- {
- OSL_ENSURE( mxDevice.is(), "ImplColor::getIntSRGBA(): Invalid graphic device" );
-
- // TODO(F1): Color space handling
- return tools::doubleSequenceToIntSRGBA( mxDevice, rDeviceColor );
- }
-
- uno::Sequence< double > ImplColor::getDeviceColor( Color::IntSRGBA aSRGBA ) const
- {
- OSL_ENSURE( mxDevice.is(), "ImplColor::getDeviceColor(): Invalid graphic device" );
-
- // TODO(F1): Color space handling
- return tools::intSRGBAToDoubleSequence( mxDevice, aSRGBA );
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcolor.hxx b/cppcanvas/source/wrapper/implcolor.hxx
deleted file mode 100644
index 8bb5ed601800..000000000000
--- a/cppcanvas/source/wrapper/implcolor.hxx
+++ /dev/null
@@ -1,56 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLCOLOR_HXX
-#define _CPPCANVAS_IMPLCOLOR_HXX
-
-#include <com/sun/star/uno/Sequence.hxx>
-
-#include <boost/shared_ptr.hpp>
-
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <cppcanvas/color.hxx>
-
-
-/* Definition of Color class */
-
-namespace cppcanvas
-{
- namespace internal
- {
- class ImplColor : public Color
- {
- public:
- ImplColor( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XGraphicDevice >& rDevice );
- virtual ~ImplColor();
-
- virtual IntSRGBA getIntSRGBA( ::com::sun::star::uno::Sequence< double >& rDeviceColor ) const;
- virtual ::com::sun::star::uno::Sequence< double > getDeviceColor( IntSRGBA aSRGBA ) const;
-
- private:
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice > mxDevice;
- };
-
- }
-}
-
-#endif /* _CPPCANVAS_IMPLCOLOR_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcustomsprite.cxx b/cppcanvas/source/wrapper/implcustomsprite.cxx
deleted file mode 100644
index 24aa95a47621..000000000000
--- a/cppcanvas/source/wrapper/implcustomsprite.cxx
+++ /dev/null
@@ -1,74 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-
-#include "implcustomsprite.hxx"
-#include "implcanvas.hxx"
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- ImplCustomSprite::ImplCustomSprite( const uno::Reference< rendering::XSpriteCanvas >& rParentCanvas,
- const uno::Reference< rendering::XCustomSprite >& rSprite,
- const ImplSpriteCanvas::TransformationArbiterSharedPtr& rTransformArbiter ) :
- ImplSprite( rParentCanvas,
- uno::Reference< rendering::XSprite >(rSprite,
- uno::UNO_QUERY),
- rTransformArbiter ),
- mpLastCanvas(),
- mxCustomSprite( rSprite )
- {
- OSL_ENSURE( rParentCanvas.is(), "ImplCustomSprite::ImplCustomSprite(): Invalid canvas" );
- OSL_ENSURE( mxCustomSprite.is(), "ImplCustomSprite::ImplCustomSprite(): Invalid sprite" );
- }
-
- ImplCustomSprite::~ImplCustomSprite()
- {
- }
-
- CanvasSharedPtr ImplCustomSprite::getContentCanvas() const
- {
- OSL_ENSURE( mxCustomSprite.is(), "ImplCustomSprite::getContentCanvas(): Invalid sprite" );
-
- if( !mxCustomSprite.is() )
- return CanvasSharedPtr();
-
- uno::Reference< rendering::XCanvas > xCanvas( mxCustomSprite->getContentCanvas() );
-
- if( !xCanvas.is() )
- return CanvasSharedPtr();
-
- // cache content canvas C++ wrapper
- if( mpLastCanvas.get() == NULL ||
- mpLastCanvas->getUNOCanvas() != xCanvas )
- {
- mpLastCanvas = CanvasSharedPtr( new ImplCanvas( xCanvas ) );
- }
-
- return mpLastCanvas;
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implcustomsprite.hxx b/cppcanvas/source/wrapper/implcustomsprite.hxx
deleted file mode 100644
index 0c4bf3d8d3af..000000000000
--- a/cppcanvas/source/wrapper/implcustomsprite.hxx
+++ /dev/null
@@ -1,63 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLCUSTOMSPRITE_HXX
-#define _CPPCANVAS_IMPLCUSTOMSPRITE_HXX
-
-#include <sal/types.h>
-
-#include <boost/shared_ptr.hpp>
-#include <cppcanvas/canvas.hxx>
-#include <cppcanvas/customsprite.hxx>
-
-#include <implsprite.hxx>
-#include <implspritecanvas.hxx>
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- // share Sprite implementation of ImplSprite
- class ImplCustomSprite : public virtual CustomSprite, protected virtual ImplSprite
- {
- public:
- ImplCustomSprite( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSpriteCanvas >& rParentCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCustomSprite >& rSprite,
- const ImplSpriteCanvas::TransformationArbiterSharedPtr& rTransformArbiter );
- virtual ~ImplCustomSprite();
-
- virtual CanvasSharedPtr getContentCanvas() const;
-
- private:
- // default: disabled copy/assignment
- ImplCustomSprite(const ImplCustomSprite&);
- ImplCustomSprite& operator=( const ImplCustomSprite& );
-
- mutable CanvasSharedPtr mpLastCanvas;
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCustomSprite > mxCustomSprite;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLCUSTOMSPRITE_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implfont.cxx b/cppcanvas/source/wrapper/implfont.cxx
deleted file mode 100644
index e62cfa543227..000000000000
--- a/cppcanvas/source/wrapper/implfont.cxx
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <implfont.hxx>
-#include <canvas/canvastools.hxx>
-
-
-using namespace ::com::sun::star;
-
-/* Definition of Font class */
-
-namespace cppcanvas
-{
- namespace internal
- {
-
- ImplFont::ImplFont( const uno::Reference< rendering::XCanvas >& rCanvas,
- const OUString& rFontName,
- const double& rCellSize ) :
- mxCanvas( rCanvas ),
- mxFont( NULL )
- {
- OSL_ENSURE( mxCanvas.is(), "ImplFont::ImplFont(): Invalid Canvas" );
-
- rendering::FontRequest aFontRequest;
- aFontRequest.FontDescription.FamilyName = rFontName;
- aFontRequest.CellSize = rCellSize;
-
- geometry::Matrix2D aFontMatrix;
- ::canvas::tools::setIdentityMatrix2D( aFontMatrix );
-
- mxFont = mxCanvas->createFont( aFontRequest,
- uno::Sequence< beans::PropertyValue >(),
- aFontMatrix );
- }
-
-
- ImplFont::~ImplFont()
- {
- }
-
- OUString ImplFont::getName() const
- {
- OSL_ENSURE( mxFont.is(), "ImplFont::getName(): Invalid Font" );
-
- return mxFont->getFontRequest().FontDescription.FamilyName;
- }
-
- double ImplFont::getCellSize() const
- {
- OSL_ENSURE( mxFont.is(), "ImplFont::getCellSize(): Invalid Font" );
-
- return mxFont->getFontRequest().CellSize;
- }
-
- uno::Reference< rendering::XCanvasFont > ImplFont::getUNOFont() const
- {
- OSL_ENSURE( mxFont.is(), "ImplFont::getUNOFont(): Invalid Font" );
-
- return mxFont;
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implfont.hxx b/cppcanvas/source/wrapper/implfont.hxx
deleted file mode 100644
index 8dd46adb94d9..000000000000
--- a/cppcanvas/source/wrapper/implfont.hxx
+++ /dev/null
@@ -1,69 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLFONT_HXX
-#define _CPPCANVAS_IMPLFONT_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-
-#include <boost/shared_ptr.hpp>
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <cppcanvas/font.hxx>
-
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- class XCanvasFont;
-} } } }
-
-/* Definition of Font class */
-
-namespace cppcanvas
-{
-
- namespace internal
- {
-
- class ImplFont : public Font
- {
- public:
- ImplFont( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvas >& rCanvas,
- const OUString& rFontName,
- const double& rCellSize );
-
- virtual ~ImplFont();
-
- virtual OUString getName() const;
- virtual double getCellSize() const;
-
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XCanvasFont > getUNOFont() const;
-
- private:
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvas > mxCanvas;
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XCanvasFont > mxFont;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLFONT_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implpolypolygon.cxx b/cppcanvas/source/wrapper/implpolypolygon.cxx
deleted file mode 100644
index f390ed6c0115..000000000000
--- a/cppcanvas/source/wrapper/implpolypolygon.cxx
+++ /dev/null
@@ -1,193 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <rtl/math.hxx>
-
-#include <com/sun/star/rendering/XCanvas.hpp>
-#include <com/sun/star/rendering/PathJoinType.hpp>
-#include <com/sun/star/rendering/PathCapType.hpp>
-
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/tools/canvastools.hxx>
-
-#include "implpolypolygon.hxx"
-#include "tools.hxx"
-
-
-using namespace ::com::sun::star;
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- ImplPolyPolygon::ImplPolyPolygon( const CanvasSharedPtr& rParentCanvas,
- const uno::Reference< rendering::XPolyPolygon2D >& rPolyPoly ) :
- CanvasGraphicHelper( rParentCanvas ),
- mxPolyPoly( rPolyPoly ),
- maStrokeAttributes(1.0,
- 10.0,
- uno::Sequence< double >(),
- uno::Sequence< double >(),
- rendering::PathCapType::ROUND,
- rendering::PathCapType::ROUND,
- rendering::PathJoinType::ROUND ),
- maFillColor(),
- maStrokeColor(),
- mbFillColorSet( false ),
- mbStrokeColorSet( false )
- {
- OSL_ENSURE( mxPolyPoly.is(), "PolyPolygonImpl::PolyPolygonImpl: no valid polygon" );
- }
-
- ImplPolyPolygon::~ImplPolyPolygon()
- {
- }
-
- void ImplPolyPolygon::addPolygon( const ::basegfx::B2DPolygon& rPoly )
- {
- OSL_ENSURE( mxPolyPoly.is(),
- "ImplPolyPolygon::addPolygon(): Invalid polygon" );
-
- if( !mxPolyPoly.is() )
- return;
-
- uno::Reference< rendering::XGraphicDevice > xDevice( getGraphicDevice() );
-
- OSL_ENSURE( xDevice.is(),
- "ImplPolyPolygon::addPolygon(): Invalid graphic device" );
-
- if( !xDevice.is() )
- return;
-
- mxPolyPoly->addPolyPolygon( geometry::RealPoint2D(0.0, 0.0),
- ::basegfx::unotools::xPolyPolygonFromB2DPolygon(
- xDevice,
- rPoly) );
- }
-
- void ImplPolyPolygon::addPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly )
- {
- OSL_ENSURE( mxPolyPoly.is(),
- "ImplPolyPolygon::addPolyPolygon(): Invalid polygon" );
-
- if( !mxPolyPoly.is() )
- return;
-
- uno::Reference< rendering::XGraphicDevice > xDevice( getGraphicDevice() );
-
- OSL_ENSURE( xDevice.is(),
- "ImplPolyPolygon::addPolyPolygon(): Invalid graphic device" );
-
- if( !xDevice.is() )
- return;
-
- mxPolyPoly->addPolyPolygon( geometry::RealPoint2D(0.0, 0.0),
- ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
- xDevice,
- rPoly) );
- }
-
- void ImplPolyPolygon::setRGBAFillColor( Color::IntSRGBA aColor )
- {
- maFillColor = tools::intSRGBAToDoubleSequence( getGraphicDevice(),
- aColor );
- mbFillColorSet = true;
- }
-
- void ImplPolyPolygon::setRGBALineColor( Color::IntSRGBA aColor )
- {
- maStrokeColor = tools::intSRGBAToDoubleSequence( getGraphicDevice(),
- aColor );
- mbStrokeColorSet = true;
- }
-
- Color::IntSRGBA ImplPolyPolygon::getRGBAFillColor() const
- {
- return tools::doubleSequenceToIntSRGBA( getGraphicDevice(),
- maFillColor );
- }
-
- Color::IntSRGBA ImplPolyPolygon::getRGBALineColor() const
- {
- return tools::doubleSequenceToIntSRGBA( getGraphicDevice(),
- maStrokeColor );
- }
-
- void ImplPolyPolygon::setStrokeWidth( const double& rStrokeWidth )
- {
- maStrokeAttributes.StrokeWidth = rStrokeWidth;
- }
-
- double ImplPolyPolygon::getStrokeWidth() const
- {
- return maStrokeAttributes.StrokeWidth;
- }
-
- bool ImplPolyPolygon::draw() const
- {
- CanvasSharedPtr pCanvas( getCanvas() );
-
- OSL_ENSURE( pCanvas.get() != NULL &&
- pCanvas->getUNOCanvas().is(),
- "ImplBitmap::draw: invalid canvas" );
-
- if( pCanvas.get() == NULL ||
- !pCanvas->getUNOCanvas().is() )
- return false;
-
- if( mbFillColorSet )
- {
- rendering::RenderState aLocalState( getRenderState() );
- aLocalState.DeviceColor = maFillColor;
-
- pCanvas->getUNOCanvas()->fillPolyPolygon( mxPolyPoly,
- pCanvas->getViewState(),
- aLocalState );
- }
-
- if( mbStrokeColorSet )
- {
- rendering::RenderState aLocalState( getRenderState() );
- aLocalState.DeviceColor = maStrokeColor;
-
- if( ::rtl::math::approxEqual(maStrokeAttributes.StrokeWidth, 1.0) )
- pCanvas->getUNOCanvas()->drawPolyPolygon( mxPolyPoly,
- pCanvas->getViewState(),
- aLocalState );
- else
- pCanvas->getUNOCanvas()->strokePolyPolygon( mxPolyPoly,
- pCanvas->getViewState(),
- aLocalState,
- maStrokeAttributes );
- }
-
- return true;
- }
-
- uno::Reference< rendering::XPolyPolygon2D > ImplPolyPolygon::getUNOPolyPolygon() const
- {
- return mxPolyPoly;
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implpolypolygon.hxx b/cppcanvas/source/wrapper/implpolypolygon.hxx
deleted file mode 100644
index 1503ed05818f..000000000000
--- a/cppcanvas/source/wrapper/implpolypolygon.hxx
+++ /dev/null
@@ -1,87 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CANVAS_IMPLPOLYPOLYGON_HXX
-#define _CANVAS_IMPLPOLYPOLYGON_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/rendering/XPolyPolygon2D.hpp>
-#include <com/sun/star/rendering/XGraphicDevice.hpp>
-#include <com/sun/star/rendering/StrokeAttributes.hpp>
-
-#include <cppcanvas/polypolygon.hxx>
-#include <canvasgraphichelper.hxx>
-
-namespace com { namespace sun { namespace star { namespace rendering
-{
- struct RealPoint2D;
-} } } }
-
-
-namespace cppcanvas
-{
- namespace internal
- {
-
- class ImplPolyPolygon : public virtual ::cppcanvas::PolyPolygon, protected CanvasGraphicHelper
- {
- public:
- ImplPolyPolygon( const CanvasSharedPtr& rParentCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D >& rPolyPoly );
-
- virtual ~ImplPolyPolygon();
-
- virtual void addPolygon( const ::basegfx::B2DPolygon& rPoly );
- virtual void addPolyPolygon( const ::basegfx::B2DPolyPolygon& rPoly );
-
- virtual void setRGBAFillColor( Color::IntSRGBA );
- virtual void setRGBALineColor( Color::IntSRGBA );
- virtual Color::IntSRGBA getRGBAFillColor() const;
- virtual Color::IntSRGBA getRGBALineColor() const;
-
- virtual void setStrokeWidth( const double& rStrokeWidth );
- virtual double getStrokeWidth() const;
-
- virtual bool draw() const;
-
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XPolyPolygon2D > getUNOPolyPolygon() const;
-
- private:
- // default: disabled copy/assignment
- ImplPolyPolygon(const ImplPolyPolygon&);
- ImplPolyPolygon& operator= ( const ImplPolyPolygon& );
-
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XPolyPolygon2D > mxPolyPoly;
-
- ::com::sun::star::rendering::StrokeAttributes maStrokeAttributes;
-
- ::com::sun::star::uno::Sequence< double > maFillColor;
- ::com::sun::star::uno::Sequence< double > maStrokeColor;
- bool mbFillColorSet;
- bool mbStrokeColorSet;
- };
-
- }
-}
-
-#endif /* _CANVAS_IMPLPOLYPOLYGON_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implsprite.cxx b/cppcanvas/source/wrapper/implsprite.cxx
deleted file mode 100644
index 5f58ba210e30..000000000000
--- a/cppcanvas/source/wrapper/implsprite.cxx
+++ /dev/null
@@ -1,202 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-
-#include <com/sun/star/rendering/XSprite.hpp>
-#include <com/sun/star/rendering/XAnimatedSprite.hpp>
-
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <canvas/canvastools.hxx>
-
-#include "implsprite.hxx"
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
-
- ImplSprite::ImplSprite( const uno::Reference< rendering::XSpriteCanvas >& rParentCanvas,
- const uno::Reference< rendering::XSprite >& rSprite,
- const ImplSpriteCanvas::TransformationArbiterSharedPtr& rTransformArbiter ) :
- mxGraphicDevice(),
- mxSprite( rSprite ),
- mxAnimatedSprite(),
- mpTransformArbiter( rTransformArbiter )
- {
- // Avoiding ternary operator in initializer list (Solaris
- // compiler bug, when function call and temporary is
- // involved)
- if( rParentCanvas.is() )
- mxGraphicDevice = rParentCanvas->getDevice();
-
- OSL_ENSURE( rParentCanvas.is() , "ImplSprite::ImplSprite(): Invalid canvas");
- OSL_ENSURE( mxGraphicDevice.is(), "ImplSprite::ImplSprite(): Invalid graphic device");
- OSL_ENSURE( mxSprite.is(), "ImplSprite::ImplSprite(): Invalid sprite");
- OSL_ENSURE( mpTransformArbiter.get(), "ImplSprite::ImplSprite(): Invalid transformation arbiter");
- }
-
- ImplSprite::~ImplSprite()
- {
- // hide the sprite on the canvas. If we don't hide the
- // sprite, it will stay on the canvas forever, since the
- // canvas naturally keeps a list of visible sprites
- // (otherwise, it wouldn't be able to paint them
- // autonomously)
- if( mxSprite.is() )
- mxSprite->hide();
- }
-
- void ImplSprite::setAlpha( const double& rAlpha )
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::setAlpha(): Invalid sprite");
-
- if( mxSprite.is() )
- mxSprite->setAlpha( rAlpha );
- }
-
- void ImplSprite::movePixel( const ::basegfx::B2DPoint& rNewPos )
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::movePixel(): Invalid sprite");
-
- if( mxSprite.is() )
- {
- rendering::ViewState aViewState;
- rendering::RenderState aRenderState;
-
- ::canvas::tools::initViewState( aViewState );
- ::canvas::tools::initRenderState( aRenderState );
-
- mxSprite->move( ::basegfx::unotools::point2DFromB2DPoint( rNewPos ),
- aViewState,
- aRenderState );
- }
- }
-
- void ImplSprite::move( const ::basegfx::B2DPoint& rNewPos )
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::move(): Invalid sprite");
-
- if( mxSprite.is() )
- {
- rendering::ViewState aViewState;
- rendering::RenderState aRenderState;
-
- ::canvas::tools::initViewState( aViewState );
- ::canvas::tools::initRenderState( aRenderState );
-
- ::canvas::tools::setViewStateTransform( aViewState,
- mpTransformArbiter->getTransformation() );
-
- mxSprite->move( ::basegfx::unotools::point2DFromB2DPoint( rNewPos ),
- aViewState,
- aRenderState );
- }
- }
-
- void ImplSprite::transform( const ::basegfx::B2DHomMatrix& rMatrix )
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::transform(): Invalid sprite");
-
- if( mxSprite.is() )
- {
- geometry::AffineMatrix2D aMatrix;
-
- mxSprite->transform( ::basegfx::unotools::affineMatrixFromHomMatrix( aMatrix,
- rMatrix ) );
- }
- }
-
- void ImplSprite::setClipPixel( const ::basegfx::B2DPolyPolygon& rClipPoly )
- {
- OSL_ENSURE( mxGraphicDevice.is(), "ImplSprite::setClip(): Invalid canvas");
- OSL_ENSURE( mxSprite.is(), "ImplSprite::transform(): Invalid sprite");
-
- if( mxSprite.is() && mxGraphicDevice.is() )
- mxSprite->clip( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( mxGraphicDevice,
- rClipPoly ) );
- }
-
- void ImplSprite::setClip( const ::basegfx::B2DPolyPolygon& rClipPoly )
- {
- OSL_ENSURE( mxGraphicDevice.is(), "ImplSprite::setClip(): Invalid canvas");
- OSL_ENSURE( mxSprite.is(), "ImplSprite::transform(): Invalid sprite");
-
- if( mxSprite.is() && mxGraphicDevice.is() )
- {
- ::basegfx::B2DPolyPolygon aTransformedClipPoly( rClipPoly );
-
- // extract linear part of canvas view transformation (linear means:
- // without translational components)
- ::basegfx::B2DHomMatrix aViewTransform( mpTransformArbiter->getTransformation() );
- aViewTransform.set( 0, 2, 0.0 );
- aViewTransform.set( 1, 2, 0.0 );
-
- // transform polygon from view to device coordinate space
- aTransformedClipPoly.transform( aViewTransform );
-
- mxSprite->clip( ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon( mxGraphicDevice,
- aTransformedClipPoly ) );
- }
- }
-
- void ImplSprite::setClip()
- {
- OSL_ENSURE( mxGraphicDevice.is(), "ImplSprite::setClip(): Invalid canvas");
- OSL_ENSURE( mxSprite.is(), "ImplSprite::setClip(): Invalid sprite");
-
- if( mxSprite.is() && mxGraphicDevice.is() )
- mxSprite->clip( uno::Reference< rendering::XPolyPolygon2D >() );
- }
-
- void ImplSprite::show()
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::show(): Invalid sprite");
-
- if( mxSprite.is() )
- mxSprite->show();
- }
-
- void ImplSprite::hide()
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::hide(): Invalid sprite");
-
- if( mxSprite.is() )
- mxSprite->hide();
- }
-
- void ImplSprite::setPriority( double fPriority )
- {
- OSL_ENSURE( mxSprite.is(), "ImplSprite::setPriority(): Invalid sprite");
-
- if( mxSprite.is() )
- mxSprite->setPriority(fPriority);
- }
-
- uno::Reference< rendering::XSprite > ImplSprite::getUNOSprite() const
- {
- return mxSprite;
- }
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implsprite.hxx b/cppcanvas/source/wrapper/implsprite.hxx
deleted file mode 100644
index 73dd7e49d2f1..000000000000
--- a/cppcanvas/source/wrapper/implsprite.hxx
+++ /dev/null
@@ -1,78 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLSPRITE_HXX
-#define _CPPCANVAS_IMPLSPRITE_HXX
-
-#include <com/sun/star/uno/Reference.hxx>
-#include <com/sun/star/rendering/XSpriteCanvas.hpp>
-#include <com/sun/star/rendering/XSprite.hpp>
-
-#include <boost/shared_ptr.hpp>
-#include <cppcanvas/sprite.hxx>
-
-#include <implspritecanvas.hxx>
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- class ImplSprite : public virtual Sprite
- {
- public:
- ImplSprite( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSpriteCanvas >& rParentCanvas,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSprite >& rSprite,
- const ImplSpriteCanvas::TransformationArbiterSharedPtr& rTransformArbiter );
- virtual ~ImplSprite();
-
- virtual void setAlpha( const double& rAlpha );
- virtual void movePixel( const ::basegfx::B2DPoint& rNewPos );
- virtual void move( const ::basegfx::B2DPoint& rNewPos );
- virtual void transform( const ::basegfx::B2DHomMatrix& rMatrix );
- virtual void setClipPixel( const ::basegfx::B2DPolyPolygon& rClipPoly );
- virtual void setClip( const ::basegfx::B2DPolyPolygon& rClipPoly );
- virtual void setClip();
-
- virtual void show();
- virtual void hide();
-
- virtual void setPriority( double fPriority );
-
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSprite > getUNOSprite() const;
-
- private:
- // default: disabled copy/assignment
- ImplSprite(const ImplSprite&);
- ImplSprite& operator=( const ImplSprite& );
-
- ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XGraphicDevice > mxGraphicDevice;
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSprite > mxSprite;
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XAnimatedSprite > mxAnimatedSprite;
- ImplSpriteCanvas::TransformationArbiterSharedPtr mpTransformArbiter;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLSPRITE_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implspritecanvas.cxx b/cppcanvas/source/wrapper/implspritecanvas.cxx
deleted file mode 100644
index 78701786fe15..000000000000
--- a/cppcanvas/source/wrapper/implspritecanvas.cxx
+++ /dev/null
@@ -1,138 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <basegfx/matrix/b2dhommatrix.hxx>
-#include <basegfx/tools/canvastools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-#include <com/sun/star/rendering/InterpolationMode.hpp>
-
-#include <implspritecanvas.hxx>
-#include <implcustomsprite.hxx>
-
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- namespace internal
- {
- ImplSpriteCanvas::TransformationArbiter::TransformationArbiter() :
- maTransformation()
- {
- }
-
- void ImplSpriteCanvas::TransformationArbiter::setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform )
- {
- maTransformation = rViewTransform;
- }
-
- ::basegfx::B2DHomMatrix ImplSpriteCanvas::TransformationArbiter::getTransformation() const
- {
- return maTransformation;
- }
-
-
- ImplSpriteCanvas::ImplSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& rCanvas ) :
- ImplCanvas( uno::Reference< rendering::XCanvas >(rCanvas,
- uno::UNO_QUERY) ),
- mxSpriteCanvas( rCanvas ),
- mpTransformArbiter( new TransformationArbiter() )
- {
- OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas(): Invalid canvas" );
- }
-
- ImplSpriteCanvas::ImplSpriteCanvas(const ImplSpriteCanvas& rOrig) :
- Canvas(),
- SpriteCanvas(),
- ImplCanvas( rOrig ),
- mxSpriteCanvas( rOrig.getUNOSpriteCanvas() ),
- mpTransformArbiter( new TransformationArbiter() )
- {
- OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::ImplSpriteCanvas( const ImplSpriteCanvas& ): Invalid canvas" );
-
- mpTransformArbiter->setTransformation( getTransformation() );
- }
-
- ImplSpriteCanvas::~ImplSpriteCanvas()
- {
- }
-
- void ImplSpriteCanvas::setTransformation( const ::basegfx::B2DHomMatrix& rMatrix )
- {
- mpTransformArbiter->setTransformation( rMatrix );
-
- ImplCanvas::setTransformation( rMatrix );
- }
-
- bool ImplSpriteCanvas::updateScreen( bool bUpdateAll ) const
- {
- OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::updateScreen(): Invalid canvas" );
-
- if( !mxSpriteCanvas.is() )
- return false;
-
- return mxSpriteCanvas->updateScreen( bUpdateAll );
- }
-
- CustomSpriteSharedPtr ImplSpriteCanvas::createCustomSprite( const ::basegfx::B2DSize& rSize ) const
- {
- OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
-
- if( !mxSpriteCanvas.is() )
- return CustomSpriteSharedPtr();
-
- return CustomSpriteSharedPtr(
- new ImplCustomSprite( mxSpriteCanvas,
- mxSpriteCanvas->createCustomSprite( ::basegfx::unotools::size2DFromB2DSize(rSize) ),
- mpTransformArbiter ) );
- }
-
- SpriteSharedPtr ImplSpriteCanvas::createClonedSprite( const SpriteSharedPtr& rSprite ) const
- {
- OSL_ENSURE( mxSpriteCanvas.is(), "ImplSpriteCanvas::createCustomSprite(): Invalid canvas" );
- OSL_ENSURE( rSprite.get() != NULL && rSprite->getUNOSprite().is(),
- "ImplSpriteCanvas::createCustomSprite(): Invalid sprite" );
-
- if( !mxSpriteCanvas.is() ||
- rSprite.get() == NULL ||
- !rSprite->getUNOSprite().is() )
- {
- return SpriteSharedPtr();
- }
-
- return SpriteSharedPtr(
- new ImplSprite( mxSpriteCanvas,
- mxSpriteCanvas->createClonedSprite( rSprite->getUNOSprite() ),
- mpTransformArbiter ) );
- }
-
- CanvasSharedPtr ImplSpriteCanvas::clone() const
- {
- return SpriteCanvasSharedPtr( new ImplSpriteCanvas( *this ) );
- }
-
- uno::Reference< rendering::XSpriteCanvas > ImplSpriteCanvas::getUNOSpriteCanvas() const
- {
- return mxSpriteCanvas;
- }
-
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/implspritecanvas.hxx b/cppcanvas/source/wrapper/implspritecanvas.hxx
deleted file mode 100644
index 1999c5630ff0..000000000000
--- a/cppcanvas/source/wrapper/implspritecanvas.hxx
+++ /dev/null
@@ -1,94 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#ifndef _CPPCANVAS_IMPLSPRITECANVAS_HXX
-#define _CPPCANVAS_IMPLSPRITECANVAS_HXX
-
-#include <com/sun/star/rendering/XSpriteCanvas.hpp>
-#include <basegfx/vector/b2dsize.hxx>
-#include <basegfx/matrix/b2dhommatrix.hxx>
-
-#include <boost/shared_ptr.hpp>
-
-
-#include <cppcanvas/spritecanvas.hxx>
-
-#include <implcanvas.hxx>
-
-
-namespace cppcanvas
-{
- namespace internal
- {
- class ImplSpriteCanvas : public virtual SpriteCanvas, protected virtual ImplCanvas
- {
- public:
- ImplSpriteCanvas( const ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSpriteCanvas >& rCanvas );
- ImplSpriteCanvas(const ImplSpriteCanvas&);
-
- virtual ~ImplSpriteCanvas();
-
- virtual void setTransformation( const ::basegfx::B2DHomMatrix& rMatrix );
-
- virtual bool updateScreen( bool bUpdateAll ) const;
-
- virtual CustomSpriteSharedPtr createCustomSprite( const ::basegfx::B2DSize& ) const;
- virtual SpriteSharedPtr createClonedSprite( const SpriteSharedPtr& ) const;
-
- virtual CanvasSharedPtr clone() const;
-
- virtual ::com::sun::star::uno::Reference<
- ::com::sun::star::rendering::XSpriteCanvas > getUNOSpriteCanvas() const;
-
- /** This class passes the view transformation
- to child sprites
-
- This helper class is necessary, because the
- ImplSpriteCanvas object cannot hand out shared ptrs of
- itself, but has somehow pass an object to child
- sprites those can query for the canvas' view transform.
- */
- class TransformationArbiter
- {
- public:
- TransformationArbiter();
-
- void setTransformation( const ::basegfx::B2DHomMatrix& rViewTransform );
- ::basegfx::B2DHomMatrix getTransformation() const;
-
- private:
- ::basegfx::B2DHomMatrix maTransformation;
- };
-
- typedef ::boost::shared_ptr< TransformationArbiter > TransformationArbiterSharedPtr;
-
- private:
- // default: disabled assignment
- ImplSpriteCanvas& operator=( const ImplSpriteCanvas& );
-
- const ::com::sun::star::uno::Reference< ::com::sun::star::rendering::XSpriteCanvas > mxSpriteCanvas;
- TransformationArbiterSharedPtr mpTransformArbiter;
- };
- }
-}
-
-#endif /* _CPPCANVAS_IMPLSPRITECANVAS_HXX */
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/cppcanvas/source/wrapper/vclfactory.cxx b/cppcanvas/source/wrapper/vclfactory.cxx
deleted file mode 100644
index a24025e34f4e..000000000000
--- a/cppcanvas/source/wrapper/vclfactory.cxx
+++ /dev/null
@@ -1,113 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- *
- * This file incorporates work covered by the following license notice:
- *
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed
- * with this work for additional information regarding copyright
- * ownership. The ASF licenses this file to you under the Apache
- * License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.apache.org/licenses/LICENSE-2.0 .
- */
-
-#include <rtl/instance.hxx>
-#include <osl/getglobalmutex.hxx>
-#include <osl/diagnose.h>
-#include <com/sun/star/rendering/InterpolationMode.hpp>
-#include <vcl/window.hxx>
-#include <vcl/graph.hxx>
-#include <vcl/canvastools.hxx>
-#include <basegfx/polygon/b2dpolypolygon.hxx>
-
-#include <cppcanvas/vclfactory.hxx>
-
-#include <implbitmapcanvas.hxx>
-#include <implspritecanvas.hxx>
-#include <implpolypolygon.hxx>
-#include <implbitmap.hxx>
-#include <implrenderer.hxx>
-#include <implsprite.hxx>
-
-using namespace ::com::sun::star;
-
-namespace cppcanvas
-{
- /* Singleton handling */
- struct InitInstance
- {
- VCLFactory* operator()()
- {
- return new VCLFactory();
- }
- };
-
- VCLFactory& VCLFactory::getInstance()
- {
- return *rtl_Instance< VCLFactory, InitInstance, ::osl::MutexGuard,
- ::osl::GetGlobalMutex >::create(
- InitInstance(), ::osl::GetGlobalMutex());
- }
-
- VCLFactory::VCLFactory()
- {
- }
-
- BitmapCanvasSharedPtr VCLFactory::createCanvas( const uno::Reference< rendering::XBitmapCanvas >& xCanvas )
- {
- return BitmapCanvasSharedPtr(
- new internal::ImplBitmapCanvas( xCanvas ) );
- }
-
- SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const ::Window& rVCLWindow ) const
- {
- return SpriteCanvasSharedPtr(
- new internal::ImplSpriteCanvas(
- uno::Reference< rendering::XSpriteCanvas >(
- rVCLWindow.GetSpriteCanvas(),
- uno::UNO_QUERY) ) );
- }
-
- SpriteCanvasSharedPtr VCLFactory::createSpriteCanvas( const uno::Reference< rendering::XSpriteCanvas >& xCanvas ) const
- {
- return SpriteCanvasSharedPtr(
- new internal::ImplSpriteCanvas( xCanvas ) );
- }
-
- BitmapSharedPtr VCLFactory::createBitmap( const CanvasSharedPtr& rCanvas,
- const ::BitmapEx& rBmpEx ) const
- {
- OSL_ENSURE( rCanvas.get() != NULL &&
- rCanvas->getUNOCanvas().is(),
- "VCLFactory::createBitmap(): Invalid canvas" );
-
- if( rCanvas.get() == NULL )
- return BitmapSharedPtr();
-
- uno::Reference< rendering::XCanvas > xCanvas( rCanvas->getUNOCanvas() );
- if( !xCanvas.is() )
- return BitmapSharedPtr();
-
- return BitmapSharedPtr( new internal::ImplBitmap( rCanvas,
- ::vcl::unotools::xBitmapFromBitmapEx(
- xCanvas->getDevice(),
- rBmpEx) ) );
- }
-
- RendererSharedPtr VCLFactory::createRenderer( const CanvasSharedPtr& rCanvas,
- const ::GDIMetaFile& rMtf,
- const Renderer::Parameters& rParms ) const
- {
- return RendererSharedPtr( new internal::ImplRenderer( rCanvas,
- rMtf,
- rParms ) );
- }
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/gdi/gdimtf.cxx b/vcl/source/gdi/gdimtf.cxx
index 6261850a0517..2904322cced2 100644
--- a/vcl/source/gdi/gdimtf.cxx
+++ b/vcl/source/gdi/gdimtf.cxx
@@ -416,6 +416,8 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
uno::Reference<rendering::XBitmap> xBitmap = xCanvas->getDevice ()->createCompatibleAlphaBitmap (vcl::unotools::integerSize2DFromSize( aSize));
if( xBitmap.is () )
{
+#if 0
+ // TODO-NYI
uno::Reference< rendering::XBitmapCanvas > xBitmapCanvas( xBitmap, uno::UNO_QUERY );
if( xBitmapCanvas.is() )
{
@@ -442,6 +444,7 @@ bool GDIMetaFile::ImplPlayWithRenderer( OutputDevice* pOut, const Point& rPos, S
return true;
}
}
+#endif
}
}
catch (const uno::RuntimeException& )