fdo#74697 Add Bluez 5 support for impress remote.
[LibreOffice.git] / svx / source / sdr / overlay / overlayobjectlist.cxx
blob4907198d7d0c0f6176ffdfbe3b82a037a9868bde
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/sdr/overlay/overlayobjectlist.hxx>
21 #include <svx/sdr/overlay/overlaymanager.hxx>
22 #include <vcl/outdev.hxx>
23 #include <basegfx/matrix/b2dhommatrix.hxx>
24 #include <tools/gen.hxx>
26 // for SOLARIS compiler include of algorithm part of _STL is necessary to
27 // get access to basic algos like ::std::find
28 #include <algorithm>
30 #include <drawinglayer/processor2d/hittestprocessor2d.hxx>
32 //////////////////////////////////////////////////////////////////////////////
34 namespace sdr
36 namespace overlay
38 OverlayObjectList::~OverlayObjectList()
40 clear();
43 void OverlayObjectList::clear()
45 OverlayObjectVector::iterator aStart(maVector.begin());
47 for(; aStart != maVector.end(); ++aStart)
49 ::sdr::overlay::OverlayObject* pCandidate = *aStart;
51 if(pCandidate->getOverlayManager())
53 pCandidate->getOverlayManager()->remove(*pCandidate);
56 delete pCandidate;
59 maVector.clear();
62 bool OverlayObjectList::isHitLogic(const basegfx::B2DPoint& rLogicPosition, double fLogicTolerance) const
64 if(!maVector.empty())
66 OverlayObjectVector::const_iterator aStart(maVector.begin());
67 sdr::overlay::OverlayObject* pFirst = *aStart;
68 OSL_ENSURE(pFirst, "Corrupt OverlayObjectList (!)");
69 OverlayManager* pManager = pFirst->getOverlayManager();
71 if(pManager)
73 if(0.0 == fLogicTolerance)
75 const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(
76 Size(DEFAULT_VALUE_FOR_HITTEST_PIXEL, DEFAULT_VALUE_FOR_HITTEST_PIXEL)));
77 fLogicTolerance = aSizeLogic.Width();
80 const drawinglayer::geometry::ViewInformation2D aViewInformation2D(pManager->getCurrentViewInformation2D());
81 drawinglayer::processor2d::HitTestProcessor2D aHitTestProcessor2D(
82 aViewInformation2D,
83 rLogicPosition,
84 fLogicTolerance,
85 false);
87 for(; aStart != maVector.end(); ++aStart)
89 sdr::overlay::OverlayObject* pCandidate = *aStart;
90 OSL_ENSURE(pCandidate, "Corrupt OverlayObjectList (!)");
92 if(pCandidate->isHittable())
94 const drawinglayer::primitive2d::Primitive2DSequence& rSequence = pCandidate->getOverlayObjectPrimitive2DSequence();
96 if(rSequence.hasElements())
98 aHitTestProcessor2D.process(rSequence);
100 if(aHitTestProcessor2D.getHit())
102 return true;
110 return false;
113 bool OverlayObjectList::isHitPixel(const Point& rDiscretePosition, sal_uInt32 nDiscreteTolerance) const
115 if(!maVector.empty())
117 OverlayObjectVector::const_iterator aStart(maVector.begin());
118 sdr::overlay::OverlayObject* pCandidate = *aStart;
119 OverlayManager* pManager = pCandidate->getOverlayManager();
121 if(pManager)
123 const Point aPosLogic(pManager->getOutputDevice().PixelToLogic(rDiscretePosition));
124 const basegfx::B2DPoint aPosition(aPosLogic.X(), aPosLogic.Y());
126 if(nDiscreteTolerance)
128 const Size aSizeLogic(pManager->getOutputDevice().PixelToLogic(Size(nDiscreteTolerance, nDiscreteTolerance)));
129 return isHitLogic(aPosition, (double)aSizeLogic.Width());
131 else
133 return isHitLogic(aPosition);
138 return false;
141 basegfx::B2DRange OverlayObjectList::getBaseRange() const
143 basegfx::B2DRange aRetval;
145 if(!maVector.empty())
147 OverlayObjectVector::const_iterator aStart(maVector.begin());
149 for(; aStart != maVector.end(); ++aStart)
151 ::sdr::overlay::OverlayObject* pCandidate = *aStart;
152 aRetval.expand(pCandidate->getBaseRange());
156 return aRetval;
158 } // end of namespace overlay
159 } // end of namespace sdr
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */