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 : #ifndef INCLUDED_SVL_INETHIST_HXX
20 : #define INCLUDED_SVL_INETHIST_HXX
21 :
22 : #include <svl/SfxBroadcaster.hxx>
23 : #include <svl/hint.hxx>
24 : #include <svl/svldllapi.h>
25 : #include <tools/urlobj.hxx>
26 :
27 : class INetURLHistory_Impl;
28 : class SVL_DLLPUBLIC INetURLHistory : public SfxBroadcaster
29 : {
30 : struct SAL_DLLPRIVATE StaticInstance
31 : {
32 : INetURLHistory * operator()();
33 : };
34 : friend INetURLHistory * StaticInstance::operator()();
35 :
36 : /** Representation.
37 : */
38 : INetURLHistory_Impl *m_pImpl;
39 :
40 : /** Construction/Destruction.
41 : */
42 : SAL_DLLPRIVATE INetURLHistory();
43 : SAL_DLLPRIVATE virtual ~INetURLHistory();
44 :
45 : /** Implementation.
46 : */
47 : SAL_DLLPRIVATE static void NormalizeUrl_Impl (INetURLObject &rUrl);
48 :
49 : void PutUrl_Impl (const INetURLObject &rUrl);
50 : bool QueryUrl_Impl (const INetURLObject &rUrl);
51 :
52 : /** Not implemented.
53 : */
54 : INetURLHistory (const INetURLHistory&) SAL_DELETED_FUNCTION;
55 : INetURLHistory& operator= (const INetURLHistory&) SAL_DELETED_FUNCTION;
56 :
57 : public:
58 : /** GetOrCreate.
59 : */
60 : static INetURLHistory* GetOrCreate();
61 :
62 : /** QueryProtocol.
63 : */
64 4278 : bool QueryProtocol (INetProtocol eProto) const
65 : {
66 634 : return ((eProto == INetProtocol::File ) ||
67 634 : (eProto == INetProtocol::Ftp ) ||
68 4383 : (eProto == INetProtocol::Http ) ||
69 4278 : (eProto == INetProtocol::Https) );
70 : }
71 :
72 : /** QueryUrl.
73 : */
74 1201 : bool QueryUrl (const INetURLObject &rUrl)
75 : {
76 1201 : if (QueryProtocol (rUrl.GetProtocol()))
77 1198 : return QueryUrl_Impl (rUrl);
78 : else
79 3 : return false;
80 : }
81 :
82 635 : bool QueryUrl (const OUString &rUrl)
83 : {
84 : INetProtocol eProto =
85 635 : INetURLObject::CompareProtocolScheme (rUrl);
86 635 : if (QueryProtocol (eProto))
87 536 : return QueryUrl_Impl (INetURLObject (rUrl));
88 : else
89 99 : return false;
90 : }
91 :
92 : /** PutUrl.
93 : */
94 2442 : void PutUrl (const INetURLObject &rUrl)
95 : {
96 2442 : if (QueryProtocol (rUrl.GetProtocol()))
97 2442 : PutUrl_Impl (rUrl);
98 2442 : }
99 :
100 : void PutUrl (const OUString &rUrl)
101 : {
102 : INetProtocol eProto =
103 : INetURLObject::CompareProtocolScheme (rUrl);
104 : if (QueryProtocol (eProto))
105 : PutUrl_Impl (INetURLObject (rUrl));
106 : }
107 : };
108 :
109 : // broadcasted from PutUrl().
110 : class SVL_DLLPUBLIC INetURLHistoryHint: public SfxHint
111 : {
112 : const INetURLObject* pObj;
113 : public:
114 2442 : explicit INetURLHistoryHint( const INetURLObject* Object ) : pObj(Object) {}
115 2442 : virtual ~INetURLHistoryHint() {}
116 145 : const INetURLObject* GetObject() const { return pObj; }
117 : };
118 :
119 : #endif // INCLUDED_SVL_INETHIST_HXX
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|