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/logfile.hxx>
31 #include <com/sun/star/rendering/XCanvas.hpp>
33 #include <tools/gen.hxx>
34 #include <vcl/canvastools.hxx>
36 #include <basegfx/range/b2drange.hxx>
37 #include <basegfx/point/b2dpoint.hxx>
38 #include <basegfx/tools/canvastools.hxx>
39 #include <canvas/canvastools.hxx>
41 #include <boost/utility.hpp>
43 #include "pointaction.hxx"
44 #include "outdevstate.hxx"
45 #include "cppcanvas/canvas.hxx"
46 #include "mtftools.hxx"
49 using namespace ::com::sun::star
;
57 class PointAction
: public Action
, private ::boost::noncopyable
60 PointAction( const ::basegfx::B2DPoint
&,
61 const CanvasSharedPtr
&,
63 PointAction( const ::basegfx::B2DPoint
&,
64 const CanvasSharedPtr
&,
68 virtual bool render( const ::basegfx::B2DHomMatrix
& rTransformation
) const;
69 virtual bool renderSubset( const ::basegfx::B2DHomMatrix
& rTransformation
,
70 const Subset
& rSubset
) const;
72 virtual ::basegfx::B2DRange
getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
) const;
73 virtual ::basegfx::B2DRange
getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
,
74 const Subset
& rSubset
) const;
76 virtual sal_Int32
getActionCount() const;
79 // default: disabled copy/assignment
80 PointAction(const PointAction
&);
81 PointAction
& operator = ( const PointAction
& );
83 ::basegfx::B2DPoint maPoint
;
84 CanvasSharedPtr mpCanvas
;
85 ::com::sun::star::rendering::RenderState maState
;
88 PointAction::PointAction( const ::basegfx::B2DPoint
& rPoint
,
89 const CanvasSharedPtr
& rCanvas
,
90 const OutDevState
& rState
) :
95 tools::initRenderState(maState
,rState
);
96 maState
.DeviceColor
= rState
.lineColor
;
99 PointAction::PointAction( const ::basegfx::B2DPoint
& rPoint
,
100 const CanvasSharedPtr
& rCanvas
,
101 const OutDevState
& rState
,
102 const ::Color
& rAltColor
) :
107 tools::initRenderState(maState
,rState
);
108 maState
.DeviceColor
= ::vcl::unotools::colorToDoubleSequence(
110 rCanvas
->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
113 bool PointAction::render( const ::basegfx::B2DHomMatrix
& rTransformation
) const
115 RTL_LOGFILE_CONTEXT( aLog
, "::cppcanvas::internal::PointAction::render()" );
116 RTL_LOGFILE_CONTEXT_TRACE1( aLog
, "::cppcanvas::internal::PointAction: 0x%X", this );
118 rendering::RenderState
aLocalState( maState
);
119 ::canvas::tools::prependToRenderState(aLocalState
, rTransformation
);
121 mpCanvas
->getUNOCanvas()->drawPoint( ::basegfx::unotools::point2DFromB2DPoint(maPoint
),
122 mpCanvas
->getViewState(),
128 bool PointAction::renderSubset( const ::basegfx::B2DHomMatrix
& rTransformation
,
129 const Subset
& rSubset
) const
131 // point only contains a single action, fail if subset
132 // requests different range
133 if( rSubset
.mnSubsetBegin
!= 0 ||
134 rSubset
.mnSubsetEnd
!= 1 )
137 return render( rTransformation
);
140 ::basegfx::B2DRange
PointAction::getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
) const
142 rendering::RenderState
aLocalState( maState
);
143 ::canvas::tools::prependToRenderState(aLocalState
, rTransformation
);
145 return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maPoint
.getX()-1,
149 mpCanvas
->getViewState(),
153 ::basegfx::B2DRange
PointAction::getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
,
154 const Subset
& rSubset
) const
156 // point only contains a single action, empty bounds
157 // if subset requests different range
158 if( rSubset
.mnSubsetBegin
!= 0 ||
159 rSubset
.mnSubsetEnd
!= 1 )
160 return ::basegfx::B2DRange();
162 return getBounds( rTransformation
);
165 sal_Int32
PointAction::getActionCount() const
171 ActionSharedPtr
PointActionFactory::createPointAction( const ::basegfx::B2DPoint
& rPoint
,
172 const CanvasSharedPtr
& rCanvas
,
173 const OutDevState
& rState
)
175 return ActionSharedPtr( new PointAction( rPoint
, rCanvas
, rState
) );
178 ActionSharedPtr
PointActionFactory::createPointAction( const ::basegfx::B2DPoint
& rPoint
,
179 const CanvasSharedPtr
& rCanvas
,
180 const OutDevState
& rState
,
181 const ::Color
& rColor
)
183 return ActionSharedPtr( new PointAction( rPoint
, rCanvas
, rState
, rColor
) );
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */