1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <com/sun/star/rendering/XCanvas.hpp>
23 #include <sal/types.h>
24 #include <vcl/canvastools.hxx>
26 #include <basegfx/range/b2drange.hxx>
27 #include <basegfx/point/b2dpoint.hxx>
28 #include <basegfx/tools/canvastools.hxx>
29 #include <canvas/canvastools.hxx>
31 #include <boost/utility.hpp>
33 #include "pointaction.hxx"
34 #include "outdevstate.hxx"
35 #include "cppcanvas/canvas.hxx"
36 #include "mtftools.hxx"
39 using namespace ::com::sun::star
;
47 class PointAction
: public Action
, private ::boost::noncopyable
50 PointAction( const ::basegfx::B2DPoint
&,
51 const CanvasSharedPtr
&,
53 PointAction( const ::basegfx::B2DPoint
&,
54 const CanvasSharedPtr
&,
58 virtual bool render( const ::basegfx::B2DHomMatrix
& rTransformation
) const;
59 virtual bool renderSubset( const ::basegfx::B2DHomMatrix
& rTransformation
,
60 const Subset
& rSubset
) const;
62 virtual ::basegfx::B2DRange
getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
) const;
63 virtual ::basegfx::B2DRange
getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
,
64 const Subset
& rSubset
) const;
66 virtual sal_Int32
getActionCount() const;
69 // default: disabled copy/assignment
70 PointAction(const PointAction
&);
71 PointAction
& operator = ( const PointAction
& );
73 ::basegfx::B2DPoint maPoint
;
74 CanvasSharedPtr mpCanvas
;
75 ::com::sun::star::rendering::RenderState maState
;
78 PointAction::PointAction( const ::basegfx::B2DPoint
& rPoint
,
79 const CanvasSharedPtr
& rCanvas
,
80 const OutDevState
& rState
) :
85 tools::initRenderState(maState
,rState
);
86 maState
.DeviceColor
= rState
.lineColor
;
89 PointAction::PointAction( const ::basegfx::B2DPoint
& rPoint
,
90 const CanvasSharedPtr
& rCanvas
,
91 const OutDevState
& rState
,
92 const ::Color
& rAltColor
) :
97 tools::initRenderState(maState
,rState
);
98 maState
.DeviceColor
= ::vcl::unotools::colorToDoubleSequence(
100 rCanvas
->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
103 bool PointAction::render( const ::basegfx::B2DHomMatrix
& rTransformation
) const
105 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PointAction::render()" );
106 SAL_INFO( "cppcanvas.emf", "::cppcanvas::internal::PointAction: 0x" << std::hex
<< this );
108 rendering::RenderState
aLocalState( maState
);
109 ::canvas::tools::prependToRenderState(aLocalState
, rTransformation
);
111 mpCanvas
->getUNOCanvas()->drawPoint( ::basegfx::unotools::point2DFromB2DPoint(maPoint
),
112 mpCanvas
->getViewState(),
118 bool PointAction::renderSubset( const ::basegfx::B2DHomMatrix
& rTransformation
,
119 const Subset
& rSubset
) const
121 // point only contains a single action, fail if subset
122 // requests different range
123 if( rSubset
.mnSubsetBegin
!= 0 ||
124 rSubset
.mnSubsetEnd
!= 1 )
127 return render( rTransformation
);
130 ::basegfx::B2DRange
PointAction::getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
) const
132 rendering::RenderState
aLocalState( maState
);
133 ::canvas::tools::prependToRenderState(aLocalState
, rTransformation
);
135 return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maPoint
.getX()-1,
139 mpCanvas
->getViewState(),
143 ::basegfx::B2DRange
PointAction::getBounds( const ::basegfx::B2DHomMatrix
& rTransformation
,
144 const Subset
& rSubset
) const
146 // point only contains a single action, empty bounds
147 // if subset requests different range
148 if( rSubset
.mnSubsetBegin
!= 0 ||
149 rSubset
.mnSubsetEnd
!= 1 )
150 return ::basegfx::B2DRange();
152 return getBounds( rTransformation
);
155 sal_Int32
PointAction::getActionCount() const
161 ActionSharedPtr
PointActionFactory::createPointAction( const ::basegfx::B2DPoint
& rPoint
,
162 const CanvasSharedPtr
& rCanvas
,
163 const OutDevState
& rState
)
165 return ActionSharedPtr( new PointAction( rPoint
, rCanvas
, rState
) );
168 ActionSharedPtr
PointActionFactory::createPointAction( const ::basegfx::B2DPoint
& rPoint
,
169 const CanvasSharedPtr
& rCanvas
,
170 const OutDevState
& rState
,
171 const ::Color
& rColor
)
173 return ActionSharedPtr( new PointAction( rPoint
, rCanvas
, rState
, rColor
) );
178 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */