1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <rtl/ustring.hxx>
31 #include <basegfx/matrix/b2dhommatrix.hxx>
32 #include <basegfx/polygon/b2dpolypolygon.hxx>
33 #include <basegfx/tools/canvastools.hxx>
35 #include <com/sun/star/rendering/XCanvas.hpp>
37 #include <canvas/canvastools.hxx>
38 #include <cppcanvas/polypolygon.hxx>
40 #include "implfont.hxx"
41 #include "implcolor.hxx"
42 #include "implcanvas.hxx"
45 using namespace ::com::sun::star
;
52 ImplCanvas::ImplCanvas( const uno::Reference
< rendering::XCanvas
>& xCanvas
) :
57 OSL_ENSURE( mxCanvas
.is(), "Canvas::Canvas() invalid XCanvas" );
59 ::canvas::tools::initViewState( maViewState
);
62 ImplCanvas::~ImplCanvas()
66 void ImplCanvas::setTransformation( const ::basegfx::B2DHomMatrix
& rMatrix
)
68 ::canvas::tools::setViewStateTransform( maViewState
, rMatrix
);
71 ::basegfx::B2DHomMatrix
ImplCanvas::getTransformation() const
73 ::basegfx::B2DHomMatrix aMatrix
;
74 return ::canvas::tools::getViewStateTransform( aMatrix
,
78 void ImplCanvas::setClip( const ::basegfx::B2DPolyPolygon
& rClipPoly
)
80 // TODO(T3): not thread-safe. B2DPolyPolygon employs copy-on-write
81 maClipPolyPolygon
.reset( rClipPoly
);
82 maViewState
.Clip
.clear();
85 void ImplCanvas::setClip()
87 maClipPolyPolygon
.reset();
88 maViewState
.Clip
.clear();
91 ::basegfx::B2DPolyPolygon
const* ImplCanvas::getClip() const
93 return !maClipPolyPolygon
? NULL
: &(*maClipPolyPolygon
);
96 FontSharedPtr
ImplCanvas::createFont( const ::rtl::OUString
& rFontName
, const double& rCellSize
) const
98 return FontSharedPtr( new ImplFont( getUNOCanvas(), rFontName
, rCellSize
) );
101 ColorSharedPtr
ImplCanvas::createColor() const
103 return ColorSharedPtr( new ImplColor( getUNOCanvas()->getDevice() ) );
106 CanvasSharedPtr
ImplCanvas::clone() const
108 return CanvasSharedPtr( new ImplCanvas( *this ) );
111 void ImplCanvas::clear() const
113 OSL_ENSURE( mxCanvas
.is(), "ImplCanvas::clear(): Invalid XCanvas" );
117 uno::Reference
< rendering::XCanvas
> ImplCanvas::getUNOCanvas() const
119 OSL_ENSURE( mxCanvas
.is(), "ImplCanvas::getUNOCanvas(): Invalid XCanvas" );
124 rendering::ViewState
ImplCanvas::getViewState() const
126 if( maClipPolyPolygon
&& !maViewState
.Clip
.is() )
131 maViewState
.Clip
= ::basegfx::unotools::xPolyPolygonFromB2DPolyPolygon(
132 mxCanvas
->getDevice(),
133 *maClipPolyPolygon
);
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */