xref: /AOO41X/main/svx/source/sdr/overlay/overlayobjectcell.cxx (revision f6e50924346d0b8c0b07c91832a97665dd718b0c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_svx.hxx"
26 
27 #include <basegfx/numeric/ftools.hxx>
28 #include <vcl/outdev.hxx>
29 #include <vcl/hatch.hxx>
30 #include <svx/sdr/overlay/overlayobjectcell.hxx>
31 #include <basegfx/polygon/b2dpolygontools.hxx>
32 #include <basegfx/polygon/b2dpolygon.hxx>
33 #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
34 #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
35 #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
36 
37 using namespace ::basegfx;
38 
39 // #114409#
40 namespace sdr
41 {
42     namespace overlay
43     {
OverlayObjectCell(CellOverlayType eType,const Color & rColor,const RangeVector & rRects)44         OverlayObjectCell::OverlayObjectCell( CellOverlayType eType, const Color& rColor, const RangeVector& rRects )
45         :   OverlayObject( rColor ),
46             mePaintType( eType ),
47             maRectangles( rRects )
48         {
49             // no AA for selection overlays
50             allowAntiAliase(false);
51         }
52 
~OverlayObjectCell()53         OverlayObjectCell::~OverlayObjectCell()
54         {
55         }
56 
createOverlayObjectPrimitive2DSequence()57         drawinglayer::primitive2d::Primitive2DSequence OverlayObjectCell::createOverlayObjectPrimitive2DSequence()
58         {
59             drawinglayer::primitive2d::Primitive2DSequence aRetval;
60             const sal_uInt32 nCount(maRectangles.size());
61 
62             if(nCount)
63             {
64                 const basegfx::BColor aRGBColor(getBaseColor().getBColor());
65                 aRetval.realloc(nCount);
66 
67                 // create primitives for all ranges
68                 for(sal_uInt32 a(0); a < nCount; a++)
69                 {
70                     const basegfx::B2DRange& rRange(maRectangles[a]);
71                     const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange));
72 
73                     aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
74                         new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
75                             basegfx::B2DPolyPolygon(aPolygon),
76                             aRGBColor));
77                 }
78 
79 
80                 if(mePaintType == CELL_OVERLAY_TRANSPARENT)
81                 {
82                     // embed in 50% transparent paint
83                     const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
84                         new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
85                             aRetval,
86                             0.5));
87 
88                     aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
89                 }
90                 else // CELL_OVERLAY_INVERT
91                 {
92                     // embed in invert primitive
93                     const drawinglayer::primitive2d::Primitive2DReference aInvert(
94                         new drawinglayer::primitive2d::InvertPrimitive2D(
95                             aRetval));
96 
97                     aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
98                 }
99             }
100 
101             return aRetval;
102         }
103     } // end of namespace overlay
104 } // end of namespace sdr
105 
106 //////////////////////////////////////////////////////////////////////////////
107 // eof
108