Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include <basegfx/numeric/ftools.hxx>
22 : #include <vcl/outdev.hxx>
23 : #include <vcl/hatch.hxx>
24 : #include <svx/sdr/overlay/overlayobjectcell.hxx>
25 : #include <basegfx/polygon/b2dpolygontools.hxx>
26 : #include <basegfx/polygon/b2dpolygon.hxx>
27 : #include <drawinglayer/primitive2d/polypolygonprimitive2d.hxx>
28 : #include <drawinglayer/primitive2d/unifiedtransparenceprimitive2d.hxx>
29 : #include <drawinglayer/primitive2d/invertprimitive2d.hxx>
30 :
31 : using namespace ::basegfx;
32 :
33 : // #114409#
34 : namespace sdr
35 : {
36 : namespace overlay
37 : {
38 0 : OverlayObjectCell::OverlayObjectCell( CellOverlayType eType, const Color& rColor, const RangeVector& rRects )
39 : : OverlayObject( rColor ),
40 : mePaintType( eType ),
41 0 : maRectangles( rRects )
42 : {
43 : // no AA for selection overlays
44 0 : allowAntiAliase(false);
45 0 : }
46 :
47 0 : OverlayObjectCell::~OverlayObjectCell()
48 : {
49 0 : }
50 :
51 0 : drawinglayer::primitive2d::Primitive2DSequence OverlayObjectCell::createOverlayObjectPrimitive2DSequence()
52 : {
53 0 : drawinglayer::primitive2d::Primitive2DSequence aRetval;
54 0 : const sal_uInt32 nCount(maRectangles.size());
55 :
56 0 : if(nCount)
57 : {
58 0 : const basegfx::BColor aRGBColor(getBaseColor().getBColor());
59 0 : aRetval.realloc(nCount);
60 :
61 : // create primitives for all ranges
62 0 : for(sal_uInt32 a(0); a < nCount; a++)
63 : {
64 0 : const basegfx::B2DRange& rRange(maRectangles[a]);
65 0 : const basegfx::B2DPolygon aPolygon(basegfx::tools::createPolygonFromRect(rRange));
66 :
67 0 : aRetval[a] = drawinglayer::primitive2d::Primitive2DReference(
68 : new drawinglayer::primitive2d::PolyPolygonColorPrimitive2D(
69 : basegfx::B2DPolyPolygon(aPolygon),
70 0 : aRGBColor));
71 0 : }
72 :
73 :
74 0 : if(mePaintType == CELL_OVERLAY_TRANSPARENT)
75 : {
76 : // embed in 50% transparent paint
77 : const drawinglayer::primitive2d::Primitive2DReference aUnifiedTransparence(
78 : new drawinglayer::primitive2d::UnifiedTransparencePrimitive2D(
79 : aRetval,
80 0 : 0.5));
81 :
82 0 : aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aUnifiedTransparence, 1);
83 : }
84 : else // CELL_OVERLAY_INVERT
85 : {
86 : // embed in invert primitive
87 : const drawinglayer::primitive2d::Primitive2DReference aInvert(
88 : new drawinglayer::primitive2d::InvertPrimitive2D(
89 0 : aRetval));
90 :
91 0 : aRetval = drawinglayer::primitive2d::Primitive2DSequence(&aInvert, 1);
92 0 : }
93 : }
94 :
95 0 : return aRetval;
96 : }
97 : } // end of namespace overlay
98 651 : } // end of namespace sdr
99 :
100 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|