LibreOffice Module sw (master)  1
overlayrangesoutline.cxx
Go to the documentation of this file.
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 #include "overlayrangesoutline.hxx"
26 
27 namespace
28 {
29  // combine ranges geometrically to a single, ORed polygon
30  basegfx::B2DPolyPolygon impCombineRangesToPolyPolygon(const std::vector< basegfx::B2DRange >& rRanges)
31  {
32  const sal_uInt32 nCount(rRanges.size());
34 
35  for(sal_uInt32 a(0); a < nCount; a++)
36  {
37  const basegfx::B2DPolygon aDiscretePolygon(basegfx::utils::createPolygonFromRect(rRanges[a]));
38 
39  if(0 == a)
40  {
41  aRetval.append(aDiscretePolygon);
42  }
43  else
44  {
45  aRetval = basegfx::utils::solvePolygonOperationOr(aRetval, basegfx::B2DPolyPolygon(aDiscretePolygon));
46  }
47  }
48 
49  return aRetval;
50  }
51 }
52 
53 namespace sw
54 {
55  namespace overlay
56  {
58  {
60  const sal_uInt32 nCount(getRanges().size());
61 
62  if( nCount )
63  {
64  const basegfx::BColor aRGBColor(getBaseColor().getBColor());
65  const basegfx::B2DPolyPolygon aPolyPolygon(impCombineRangesToPolyPolygon(getRanges()));
68  aPolyPolygon,
69  aRGBColor));
70 
71  aRetval.resize(1);
72  aRetval[0] = aOutline;
73  }
74 
75  return aRetval;
76  }
77 
79  const Color& rColor,
80  const std::vector< basegfx::B2DRange >& rRanges )
81  : sdr::overlay::OverlayObject(rColor)
82  , maRanges(rRanges)
83  {
84  // no AA for highlight overlays
85  allowAntiAliase(false);
86  }
87 
89  {
90  if( getOverlayManager() )
91  {
92  getOverlayManager()->remove(*this);
93  }
94  }
95 
96  void OverlayRangesOutline::setRanges(const std::vector< basegfx::B2DRange >& rNew)
97  {
98  if(rNew != maRanges)
99  {
100  maRanges = rNew;
101  objectChange();
102  }
103  }
104  } // end of namespace overlay
105 } // end of namespace sdr
106 
107 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
B2DPolyPolygon solvePolygonOperationOr(const B2DPolyPolygon &rCandidateA, const B2DPolyPolygon &rCandidateB)
const std::vector< basegfx::B2DRange > & getRanges() const
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
OverlayManager * getOverlayManager() const
std::vector< basegfx::B2DRange > maRanges
void remove(OverlayObject &rOverlayObject)
OverlayRangesOutline(const Color &rColor, const std::vector< basegfx::B2DRange > &rRanges)
B2DPolygon createPolygonFromRect(const B2DRectangle &rRect, double fRadiusX, double fRadiusY)
size
void setRanges(const std::vector< basegfx::B2DRange > &rNew)
void allowAntiAliase(bool bNew)
const Color & getBaseColor() const
css::uno::Reference< css::graphic::XPrimitive2D > Primitive2DReference
virtual drawinglayer::primitive2d::Primitive2DContainer createOverlayObjectPrimitive2DSequence() override