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