2004-03-18 09:41:15 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* $RCSfile: pointaction.cxx,v $
|
|
|
|
* $Revision: 1.11 $
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
2008-04-11 09:15:40 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2004-03-18 09:41:15 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 11:50:33 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_cppcanvas.hxx"
|
|
|
|
|
2004-11-26 19:56:08 +00:00
|
|
|
#include <rtl/logfile.hxx>
|
2005-03-10 12:25:52 +00:00
|
|
|
#include <com/sun/star/rendering/XCanvas.hpp>
|
2004-03-18 09:41:15 +00:00
|
|
|
|
|
|
|
#include <tools/gen.hxx>
|
|
|
|
#include <vcl/canvastools.hxx>
|
|
|
|
|
2005-04-18 09:00:40 +00:00
|
|
|
#include <basegfx/range/b2drange.hxx>
|
2007-01-22 10:52:02 +00:00
|
|
|
#include <basegfx/point/b2dpoint.hxx>
|
2004-03-18 09:41:15 +00:00
|
|
|
#include <basegfx/tools/canvastools.hxx>
|
|
|
|
#include <canvas/canvastools.hxx>
|
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
#include <boost/utility.hpp>
|
|
|
|
|
2005-11-02 12:41:31 +00:00
|
|
|
#include "pointaction.hxx"
|
|
|
|
#include "outdevstate.hxx"
|
|
|
|
#include "cppcanvas/canvas.hxx"
|
|
|
|
#include "mtftools.hxx"
|
2004-03-18 09:41:15 +00:00
|
|
|
|
|
|
|
|
|
|
|
using namespace ::com::sun::star;
|
|
|
|
|
|
|
|
namespace cppcanvas
|
|
|
|
{
|
|
|
|
namespace internal
|
|
|
|
{
|
2005-03-30 07:31:08 +00:00
|
|
|
namespace
|
2004-03-18 09:41:15 +00:00
|
|
|
{
|
2005-03-30 07:31:08 +00:00
|
|
|
class PointAction : public Action, private ::boost::noncopyable
|
|
|
|
{
|
|
|
|
public:
|
2007-01-22 10:52:02 +00:00
|
|
|
PointAction( const ::basegfx::B2DPoint&,
|
2005-03-30 07:31:08 +00:00
|
|
|
const CanvasSharedPtr&,
|
|
|
|
const OutDevState& );
|
2007-01-22 10:52:02 +00:00
|
|
|
PointAction( const ::basegfx::B2DPoint&,
|
2005-03-30 07:31:08 +00:00
|
|
|
const CanvasSharedPtr&,
|
|
|
|
const OutDevState&,
|
|
|
|
const ::Color& );
|
2004-03-18 09:41:15 +00:00
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation ) const;
|
|
|
|
virtual bool render( const ::basegfx::B2DHomMatrix& rTransformation,
|
|
|
|
const Subset& rSubset ) const;
|
2004-03-18 09:41:15 +00:00
|
|
|
|
2005-04-18 09:00:40 +00:00
|
|
|
virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const;
|
|
|
|
virtual ::basegfx::B2DRange getBounds( const ::basegfx::B2DHomMatrix& rTransformation,
|
|
|
|
const Subset& rSubset ) const;
|
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
virtual sal_Int32 getActionCount() const;
|
2004-03-18 09:41:15 +00:00
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
private:
|
|
|
|
// default: disabled copy/assignment
|
|
|
|
PointAction(const PointAction&);
|
|
|
|
PointAction& operator = ( const PointAction& );
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
::basegfx::B2DPoint maPoint;
|
2005-03-30 07:31:08 +00:00
|
|
|
CanvasSharedPtr mpCanvas;
|
|
|
|
::com::sun::star::rendering::RenderState maState;
|
|
|
|
};
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
|
|
|
|
const CanvasSharedPtr& rCanvas,
|
|
|
|
const OutDevState& rState ) :
|
2005-03-30 07:31:08 +00:00
|
|
|
maPoint( rPoint ),
|
|
|
|
mpCanvas( rCanvas ),
|
|
|
|
maState()
|
|
|
|
{
|
|
|
|
tools::initRenderState(maState,rState);
|
|
|
|
maState.DeviceColor = rState.lineColor;
|
|
|
|
}
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
PointAction::PointAction( const ::basegfx::B2DPoint& rPoint,
|
|
|
|
const CanvasSharedPtr& rCanvas,
|
|
|
|
const OutDevState& rState,
|
|
|
|
const ::Color& rAltColor ) :
|
2005-03-30 07:31:08 +00:00
|
|
|
maPoint( rPoint ),
|
|
|
|
mpCanvas( rCanvas ),
|
|
|
|
maState()
|
|
|
|
{
|
|
|
|
tools::initRenderState(maState,rState);
|
|
|
|
maState.DeviceColor = ::vcl::unotools::colorToDoubleSequence( rCanvas->getUNOCanvas()->getDevice(),
|
|
|
|
rAltColor );
|
|
|
|
}
|
2004-11-26 19:56:08 +00:00
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
bool PointAction::render( const ::basegfx::B2DHomMatrix& rTransformation ) const
|
|
|
|
{
|
|
|
|
RTL_LOGFILE_CONTEXT( aLog, "::cppcanvas::internal::PointAction::render()" );
|
|
|
|
RTL_LOGFILE_CONTEXT_TRACE1( aLog, "::cppcanvas::internal::PointAction: 0x%X", this );
|
2004-11-26 19:56:08 +00:00
|
|
|
|
2005-03-30 07:31:08 +00:00
|
|
|
rendering::RenderState aLocalState( maState );
|
|
|
|
::canvas::tools::prependToRenderState(aLocalState, rTransformation);
|
2004-03-18 09:41:15 +00:00
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
mpCanvas->getUNOCanvas()->drawPoint( ::basegfx::unotools::point2DFromB2DPoint(maPoint),
|
2005-03-30 07:31:08 +00:00
|
|
|
mpCanvas->getViewState(),
|
|
|
|
aLocalState );
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PointAction::render( 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 );
|
|
|
|
}
|
2005-04-18 09:00:40 +00:00
|
|
|
|
|
|
|
::basegfx::B2DRange PointAction::getBounds( const ::basegfx::B2DHomMatrix& rTransformation ) const
|
|
|
|
{
|
|
|
|
rendering::RenderState aLocalState( maState );
|
|
|
|
::canvas::tools::prependToRenderState(aLocalState, rTransformation);
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
return tools::calcDevicePixelBounds( ::basegfx::B2DRange( maPoint.getX()-1,
|
|
|
|
maPoint.getY()-1,
|
|
|
|
maPoint.getX()+1,
|
|
|
|
maPoint.getY()+1 ),
|
2005-04-18 09:00:40 +00:00
|
|
|
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 );
|
|
|
|
}
|
2005-03-30 07:31:08 +00:00
|
|
|
|
|
|
|
sal_Int32 PointAction::getActionCount() const
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2004-03-18 09:41:15 +00:00
|
|
|
}
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
|
|
|
|
const CanvasSharedPtr& rCanvas,
|
|
|
|
const OutDevState& rState )
|
2005-03-30 07:31:08 +00:00
|
|
|
{
|
|
|
|
return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState ) );
|
|
|
|
}
|
|
|
|
|
2007-01-22 10:52:02 +00:00
|
|
|
ActionSharedPtr PointActionFactory::createPointAction( const ::basegfx::B2DPoint& rPoint,
|
|
|
|
const CanvasSharedPtr& rCanvas,
|
|
|
|
const OutDevState& rState,
|
|
|
|
const ::Color& rColor )
|
2005-03-30 07:31:08 +00:00
|
|
|
{
|
|
|
|
return ActionSharedPtr( new PointAction( rPoint, rCanvas, rState, rColor ) );
|
|
|
|
}
|
2004-03-18 09:41:15 +00:00
|
|
|
}
|
|
|
|
}
|