xref: /trunk/main/svx/source/sdr/overlay/overlayobjectcell.cxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_svx.hxx"
30 
31 #include <basegfx/numeric/ftools.hxx>
32 #include <vcl/outdev.hxx>
33 #include <vcl/hatch.hxx>
34 #include <svx/sdr/overlay/overlayobjectcell.hxx>
35 #include <basegfx/polygon/b2dpolygontools.hxx>
36 #include <basegfx/polygon/b2dpolygon.hxx>
37 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
38 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
39 #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
40 
41 using namespace ::basegfx;
42 
43 // #114409#
44 namespace sdr
45 {
46     namespace overlay
47     {
48         OverlayObjectCell::OverlayObjectCell( CellOverlayType eType, const Color& rColor, const RangeVector& rRects )
49         :   OverlayObject( rColor ),
50             mePaintType( eType ),
51             maRectangles( rRects )
52         {
53             // no AA for selection overlays
54             allowAntiAliase(false);
55         }
56 
57         OverlayObjectCell::~OverlayObjectCell()
58         {
59         }
60 
61         drawinglayer::primitive2d::Primitive2DSequence OverlayObjectCell::createOverlayObjectPrimitive2DSequence()
62         {
63             drawinglayer::primitive2d::Primitive2DSequence aRetval;
64             const sal_uInt32 nCount(maRectangles.size());
65 
66             if(nCount)
67             {
68                 const basegfx::BColor aRGBColor(getBaseColor().getBColor());
69                 aRetval.realloc(nCount);
70 
71                 // create primitives for all ranges
72                 for(sal_uInt32 a(0); a < nCount; a++)
73                 {
74                     const basegfx::B2DRange& rRange(maRectangles[a]);
75                     const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange));
76 
77                     aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
78                         new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
79                             basegfx::B2DPolyPolygon(aPolygon),
80                             aRGBColor));
81                 }
82 
83 
84                 if(mePaintType == CELL_OVERLAY_TRANSPARENT)
85                 {
86                     // embed in 50% transparent paint
87                     const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
88                         new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
89                             aRetval,
90                             0.5));
91 
92                     aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
93                 }
94                 else // CELL_OVERLAY_INVERT
95                 {
96                     // embed in invert primitive
97                     const drawinglayer::primitive2d::Primitive2DReference aInvert(
98                         new drawinglayer::primitive2d::InvertPrimitive2D(
99                             aRetval));
100 
101                     aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
102                 }
103             }
104 
105             return aRetval;
106         }
107     } // end of namespace overlay
108 } // end of namespace sdr
109 
110 //////////////////////////////////////////////////////////////////////////////
111 // eof
112