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