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 (void);
43 : SAL_DLLPRIVATE virtual ~INetURLHistory (void);
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 : SAL_DLLPRIVATE INetURLHistory (const INetURLHistory&);
55 : SAL_DLLPRIVATE INetURLHistory& operator= (const INetURLHistory&);
56 :
57 : public:
58 : /** GetOrCreate.
59 : */
60 : static INetURLHistory* GetOrCreate (void);
61 :
62 : /** QueryProtocol.
63 : */
64 6872 : bool QueryProtocol (INetProtocol eProto) const
65 : {
66 948 : return ((eProto == INET_PROT_FILE ) ||
67 948 : (eProto == INET_PROT_FTP ) ||
68 7040 : (eProto == INET_PROT_HTTP ) ||
69 6872 : (eProto == INET_PROT_HTTPS) );
70 : }
71 :
72 : /** QueryUrl.
73 : */
74 1932 : bool QueryUrl (const INetURLObject &rUrl)
75 : {
76 1932 : if (QueryProtocol (rUrl.GetProtocol()))
77 1926 : return QueryUrl_Impl (rUrl);
78 : else
79 6 : return false;
80 : }
81 :
82 950 : bool QueryUrl (const OUString &rUrl)
83 : {
84 : INetProtocol eProto =
85 950 : INetURLObject::CompareProtocolScheme (rUrl);
86 950 : if (QueryProtocol (eProto))
87 794 : return QueryUrl_Impl (INetURLObject (rUrl));
88 : else
89 156 : return false;
90 : }
91 :
92 : /** PutUrl.
93 : */
94 3990 : void PutUrl (const INetURLObject &rUrl)
95 : {
96 3990 : if (QueryProtocol (rUrl.GetProtocol()))
97 3990 : PutUrl_Impl (rUrl);
98 3990 : }
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 256 : DECL_PTRHINT (SVL_DLLPUBLIC, INetURLHistoryHint, const INetURLObject);
111 :
112 : #endif // INCLUDED_SVL_INETHIST_HXX
113 :
114 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|