merge the formfield patch from ooo-build
[ooovba.git] / svx / source / sdr / overlay / overlayobjectcell.cxx
blobcda1bbd6363716ebbeb79031a1456d77f0e52951
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: overlayobjectcell.cxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_svx.hxx"
34 #include <basegfx/numeric/ftools.hxx>
35 #include <vcl/outdev.hxx>
36 #include <vcl/hatch.hxx>
37 #include <svx/sdr/overlay/overlayobjectcell.hxx>
38 #include <basegfx/polygon/b2dpolygontools.hxx>
39 #include <basegfx/polygon/b2dpolygon.hxx>
40 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
41 #include <drawinglayer/primitive2d/unifiedalphaprimitive2d.hxx>
42 #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
44 using namespace ::basegfx;
46 // #114409#
47 namespace sdr
49 namespace overlay
51 OverlayObjectCell::OverlayObjectCell( CellOverlayType eType, const Color& rColor, const RangeVector& rRects )
52 : OverlayObject( rColor ),
53 mePaintType( eType ),
54 maRectangles( rRects )
56 // no AA for selection overlays
57 allowAntiAliase(false);
60 OverlayObjectCell::~OverlayObjectCell()
64 drawinglayer::primitive2d::Primitive2DSequence OverlayObjectCell::createOverlayObjectPrimitive2DSequence()
66 drawinglayer::primitive2d::Primitive2DSequence aRetval;
67 const sal_uInt32 nCount(maRectangles.size());
69 if(nCount)
71 const basegfx::BColor aRGBColor(getBaseColor().getBColor());
72 aRetval.realloc(nCount);
74 // create primitives for all ranges
75 for(sal_uInt32 a(0); a < nCount; a++)
77 const basegfx::B2DRange& rRange(maRectangles[a]);
78 const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange));
80 aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
81 new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
82 basegfx::B2DPolyPolygon(aPolygon),
83 aRGBColor));
87 if(mePaintType == CELL_OVERLAY_TRANSPARENT)
89 // embed in 50% transparent paint
90 const drawinglayer::primitive2d::Primitive2DReference aUnifiedAlpha(
91 new drawinglayer::primitive2d::UnifiedAlphaPrimitive2D(
92 aRetval,
93 0.5));
95 aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedAlpha, 1);
97 else // CELL_OVERLAY_INVERT
99 // embed in invert primitive
100 const drawinglayer::primitive2d::Primitive2DReference aInvert(
101 new drawinglayer::primitive2d::InvertPrimitive2D(
102 aRetval));
104 aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
108 return aRetval;
110 } // end of namespace overlay
111 } // end of namespace sdr
113 //////////////////////////////////////////////////////////////////////////////
114 // eof