Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
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.
15 : : *
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).
21 : : *
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.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <rtl/logfile.hxx>
31 : : #include <com/sun/star/rendering/XCanvas.hpp>
32 : :
33 : : #include <tools/gen.hxx>
34 : : #include <vcl/canvastools.hxx>
35 : :
36 : : #include <basegfx/range/b2drange.hxx>
37 : : #include <basegfx/point/b2dpoint.hxx>
38 : : #include <basegfx/tools/canvastools.hxx>
39 : : #include <canvas/canvastools.hxx>
40 : :
41 : : #include <boost/utility.hpp>
42 : :
43 : : #include "pointaction.hxx"
44 : : #include "outdevstate.hxx"
45 : : #include "cppcanvas/canvas.hxx"
46 : : #include "mtftools.hxx"
47 : :
48 : :
49 : : using namespace ::com::sun::star;
50 : :
51 : : namespace cppcanvas
52 : : {
53 : : namespace internal
54 : : {
55 : : namespace
56 : : {
57 [ # # ][ # # ]: 0 : class PointAction : public Action, private ::boost::noncopyable
[ # # ]
58 : : {
59 : : public:
60 : : PointAction( const ::basegfx::B2DPoint&,
61 : : const CanvasSharedPtr&,
62 : : const OutDevState& );
63 : : PointAction( const ::basegfx::B2DPoint&,
64 : : const CanvasSharedPtr&,
65 : : const OutDevState&,
66 : : const ::Color& );
67 : :
68 : : virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
69 : : virtual bool renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
70 : : const Subset& rSubset ) const;
71 : :
72 : : virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
73 : : virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
74 : : const Subset& rSubset ) const;
75 : :
76 : : virtual sal_Int32 getActionCount() const;
77 : :
78 : : private:
79 : : // default: disabled copy/assignment
80 : : PointAction(const PointAction&);
81 : : PointAction& operator = ( const PointAction& );
82 : :
83 : : ::basegfx::B2DPoint maPoint;
84 : : CanvasSharedPtr mpCanvas;
85 : : ::com::sun::star::rendering::RenderState maState;
86 : : };
87 : :
88 : 0 : PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
89 : : const CanvasSharedPtr& rCanvas,
90 : : const OutDevState& rState ) :
91 : : maPoint( rPoint ),
92 : : mpCanvas( rCanvas ),
93 [ # # ][ # # ]: 0 : maState()
94 : : {
95 [ # # ]: 0 : tools::initRenderState(maState,rState);
96 [ # # ]: 0 : maState.DeviceColor = rState.lineColor;
97 : 0 : }
98 : :
99 : 0 : PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
100 : : const CanvasSharedPtr& rCanvas,
101 : : const OutDevState& rState,
102 : : const ::Color& rAltColor ) :
103 : : maPoint( rPoint ),
104 : : mpCanvas( rCanvas ),
105 [ # # ][ # # ]: 0 : maState()
106 : : {
107 [ # # ]: 0 : tools::initRenderState(maState,rState);
108 : : maState.DeviceColor = ::vcl::unotools::colorToDoubleSequence(
109 : : rAltColor,
110 [ # # ][ # # ]: 0 : rCanvas->getUNOCanvas()->getDevice()->getDeviceColorSpace() );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
111 : 0 : }
112 : :
113 : 0 : bool PointAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
114 : : {
115 : : RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::PointAction::render()" );
116 : : RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::PointAction: 0x%X", this );
117 : :
118 [ # # ]: 0 : rendering::RenderState aLocalState( maState );
119 [ # # ]: 0 : ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
120 : :
121 [ # # ][ # # ]: 0 : mpCanvas->getUNOCanvas()->drawPoint( ::basegfx::unotools::point2DFromB2DPoint(maPoint),
122 : 0 : mpCanvas->getViewState(),
123 [ # # ][ # # ]: 0 : aLocalState );
[ # # ][ # # ]
124 : :
125 [ # # ]: 0 : return true;
126 : : }
127 : :
128 : 0 : bool PointAction::renderSubset( const ::basegfx::B2DHomMatrix& rTransformation,
129 : : const Subset& rSubset ) const
130 : : {
131 : : // point only contains a single action, fail if subset
132 : : // requests different range
133 [ # # ][ # # ]: 0 : if( rSubset.mnSubsetBegin != 0 ||
134 : : rSubset.mnSubsetEnd != 1 )
135 : 0 : return false;
136 : :
137 : 0 : return render( rTransformation );
138 : : }
139 : :
140 : 0 : ::basegfx::B2DRange PointAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
141 : : {
142 [ # # ]: 0 : rendering::RenderState aLocalState( maState );
143 [ # # ]: 0 : ::canvas::tools::prependToRenderState(aLocalState, rTransformation);
144 : :
145 : 0 : return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maPoint.getX()-1,
146 : 0 : maPoint.getY()-1,
147 : 0 : maPoint.getX()+1,
148 : 0 : maPoint.getY()+1 ),
149 : 0 : mpCanvas->getViewState(),
150 [ # # ][ # # ]: 0 : aLocalState );
[ # # ]
[ # # # # ]
151 : : }
152 : :
153 : 0 : ::basegfx::B2DRange PointAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
154 : : const Subset& rSubset ) const
155 : : {
156 : : // point only contains a single action, empty bounds
157 : : // if subset requests different range
158 [ # # ][ # # ]: 0 : if( rSubset.mnSubsetBegin != 0 ||
159 : : rSubset.mnSubsetEnd != 1 )
160 : 0 : return ::basegfx::B2DRange();
161 : :
162 : 0 : return getBounds( rTransformation );
163 : : }
164 : :
165 : 0 : sal_Int32 PointAction::getActionCount() const
166 : : {
167 : 0 : return 1;
168 : : }
169 : : }
170 : :
171 : 0 : ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
172 : : const CanvasSharedPtr& rCanvas,
173 : : const OutDevState& rState )
174 : : {
175 [ # # ]: 0 : return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState ) );
176 : : }
177 : :
178 : 0 : ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
179 : : const CanvasSharedPtr& rCanvas,
180 : : const OutDevState& rState,
181 : : const ::Color& rColor )
182 : : {
183 [ # # ]: 0 : return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState, rColor ) );
184 : : }
185 : : }
186 : : }
187 : :
188 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|