1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX
29 #define INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX
30 
31 #include <boost/shared_ptr.hpp>
32 #include <vector>
33 #include <utility>
34 
35 namespace rtl {
36     class OUString;
37 }
38 namespace basegfx {
39     class B2DRange;
40 }
41 
42 /* Definition of HyperlinkArea interface */
43 
44 namespace slideshow
45 {
46     namespace internal
47     {
48         /** HyperlinkArea interface
49 
50             Implementers of this interface provide information for
51             hyperlink sensitive areas.
52          */
53         class HyperlinkArea
54         {
55         public:
56             typedef std::pair< ::basegfx::B2DRange,
57                                ::rtl::OUString >    HyperlinkRegion;
58 
59             typedef std::vector<HyperlinkRegion>    HyperlinkRegions;
60 
61             /** Request hyperlink-sensitive areas.
62 
63 				@return a vector of hyperlink-sensitive areas, plus
64 				the URI associated to them.
65              */
66             virtual HyperlinkRegions getHyperlinkRegions() const = 0;
67 
68             /** Retrieve priority of link area
69 
70                 @return the priority of the link area. Link areas with
71                 higher priority will receive hyperlink clicks in favor
72                 of areas with less priority, if they cover the same
73                 place on screen.
74              */
75             virtual double getHyperlinkPriority() const = 0;
76 
77             /** Functor struct, for area ordering
78 
79             	This defines a strict weak ordering of areas, sort key
80             	is the object ptr value. Most typical use is for
81             	associative containers holding areas.
82              */
83             struct lessThanArea
84             {
85                 // make functor adaptable (to boost::bind)
86                 typedef bool result_type;
87 
88                 bool operator()(const boost::shared_ptr< HyperlinkArea >& rLHS,
89                                 const boost::shared_ptr< HyperlinkArea >& rRHS) const
90                 {
91                     const double nPrioL( rLHS->getHyperlinkPriority() );
92                     const double nPrioR( rRHS->getHyperlinkPriority() );
93 
94                     // if prios are equal, tie-break on ptr value
95                     return nPrioL == nPrioR ? rLHS.get() < rRHS.get() : nPrioL < nPrioR;
96                 }
97             };
98        };
99 
100         typedef boost::shared_ptr< HyperlinkArea > HyperlinkAreaSharedPtr;
101     }
102 }
103 
104 #endif /* INCLUDED_SLIDESHOW_HYPERLINKAREA_HXX */
105