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 #ifndef INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX
25 #define INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX
26 
27 #include <boost/shared_ptr.hpp>
28 #include <vector>
29 #include <utility>
30 
31 namespace rtl {
32     class OUString;
33 }
34 namespace basegfx {
35     class B2DRange;
36 }
37 
38 /* Definition of HyperlinkArea interface */
39 
40 namespace slideshow
41 {
42     namespace internal
43     {
44         /** HyperlinkArea interface
45 
46             Implementers of this interface provide information for
47             hyperlink sensitive areas.
48          */
49         class HyperlinkArea
50         {
51         public:
52             typedef std::pair< ::basegfx::B2DRange,
53                                ::rtl::OUString >    HyperlinkRegion;
54 
55             typedef std::vector<HyperlinkRegion>    HyperlinkRegions;
56 
57             /** Request hyperlink-sensitive areas.
58 
59 				@return a vector of hyperlink-sensitive areas, plus
60 				the URI associated to them.
61              */
62             virtual HyperlinkRegions getHyperlinkRegions() const = 0;
63 
64             /** Retrieve priority of link area
65 
66                 @return the priority of the link area. Link areas with
67                 higher priority will receive hyperlink clicks in favor
68                 of areas with less priority, if they cover the same
69                 place on screen.
70              */
71             virtual double getHyperlinkPriority() const = 0;
72 
73             /** Functor struct, for area ordering
74 
75             	This defines a strict weak ordering of areas, sort key
76             	is the object ptr value. Most typical use is for
77             	associative containers holding areas.
78              */
79             struct lessThanArea
80             {
81                 // make functor adaptable (to boost::bind)
82                 typedef bool result_type;
83 
operator ()slideshow::internal::HyperlinkArea::lessThanArea84                 bool operator()(const boost::shared_ptr< HyperlinkArea >& rLHS,
85                                 const boost::shared_ptr< HyperlinkArea >& rRHS) const
86                 {
87                     const double nPrioL( rLHS->getHyperlinkPriority() );
88                     const double nPrioR( rRHS->getHyperlinkPriority() );
89 
90                     // if prios are equal, tie-break on ptr value
91                     return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
92                 }
93             };
94        };
95 
96         typedef boost::shared_ptr< HyperlinkArea > HyperlinkAreaSharedPtr;
97     }
98 }
99 
100 #endif /* INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX */
101