xref: /aoo4110/main/svl/inc/svl/inethist.hxx (revision b1cdbd2c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 #ifndef _INETHIST_HXX
24 #define _INETHIST_HXX
25 
26 #include "svl/svldllapi.h"
27 #include <tools/solar.h>
28 #include <tools/string.hxx>
29 #include <tools/urlobj.hxx>
30 #include <svl/brdcst.hxx>
31 #include <svl/hint.hxx>
32 
33 /*========================================================================
34  *
35  * INetURLHistory interface.
36  *
37  *=======================================================================*/
38 class INetURLHistory_Impl;
39 class INetURLHistory : public SfxBroadcaster
40 {
41 	struct StaticInstance
42 	{
43 		INetURLHistory * operator()();
44 	};
45 	friend INetURLHistory * StaticInstance::operator()();
46 
47 	/** Representation.
48 	*/
49 	INetURLHistory_Impl *m_pImpl;
50 
51 	/** Construction/Destruction.
52 	*/
53 	INetURLHistory (void);
54 	virtual ~INetURLHistory (void);
55 
56 	/** Implementation.
57 	*/
58 	static void NormalizeUrl_Impl (INetURLObject &rUrl);
59 
60 	SVL_DLLPUBLIC void PutUrl_Impl   (const INetURLObject &rUrl);
61 	SVL_DLLPUBLIC sal_Bool QueryUrl_Impl (const INetURLObject &rUrl);
62 
63 	/** Not implemented.
64 	*/
65 	INetURLHistory (const INetURLHistory&);
66 	INetURLHistory& operator= (const INetURLHistory&);
67 
68 public:
69 	/** GetOrCreate.
70 	*/
71 	SVL_DLLPUBLIC static INetURLHistory* GetOrCreate (void);
72 
73 	/** QueryProtocol.
74 	*/
QueryProtocol(INetProtocol eProto) const75 	sal_Bool QueryProtocol (INetProtocol eProto) const
76 	{
77 		return ((eProto == INET_PROT_FILE ) ||
78 				(eProto == INET_PROT_FTP  ) ||
79 				(eProto == INET_PROT_HTTP ) ||
80 				(eProto == INET_PROT_HTTPS)    );
81 	}
82 
83 	/** QueryUrl.
84 	*/
QueryUrl(const INetURLObject & rUrl)85 	sal_Bool QueryUrl (const INetURLObject &rUrl)
86 	{
87 		if (QueryProtocol (rUrl.GetProtocol()))
88 			return QueryUrl_Impl (rUrl);
89 		else
90 			return sal_False;
91 	}
92 
QueryUrl(const String & rUrl)93 	sal_Bool QueryUrl (const String &rUrl)
94 	{
95 		INetProtocol eProto =
96 			INetURLObject::CompareProtocolScheme (rUrl);
97 		if (QueryProtocol (eProto))
98 			return QueryUrl_Impl (INetURLObject (rUrl));
99 		else
100 			return sal_False;
101 	}
102 
103 	/** PutUrl.
104 	*/
PutUrl(const INetURLObject & rUrl)105 	void PutUrl (const INetURLObject &rUrl)
106 	{
107 		if (QueryProtocol (rUrl.GetProtocol()))
108 			PutUrl_Impl (rUrl);
109 	}
110 
PutUrl(const String & rUrl)111 	void PutUrl (const String &rUrl)
112 	{
113 		INetProtocol eProto =
114 			INetURLObject::CompareProtocolScheme (rUrl);
115 		if (QueryProtocol (eProto))
116 			PutUrl_Impl (INetURLObject (rUrl));
117 	}
118 };
119 
120 /*========================================================================
121  *
122  * INetURLHistoryHint (broadcasted from PutUrl()).
123  *
124  *=======================================================================*/
125 DECL_PTRHINT (SVL_DLLPUBLIC, INetURLHistoryHint, const INetURLObject);
126 
127 #endif /* _INETHIST_HXX */
128 
129