1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 /*TODO outline this implementation :-) */
22 #ifndef __FRAMEWORK_PROTOCOLS_H_
23 #define __FRAMEWORK_PROTOCOLS_H_
25 #include <rtl/ustring.hxx>
29 //_______________________________________________________________________
31 some protocols must be checked during loading or dispatching URLs manually
32 It can be neccessary to decide, if a URL represent a non visible content or
33 a real visible component.
36 // indicates a loadable content in general!
37 #define SPECIALPROTOCOL_PRIVATE "private:"
38 // indicates loading of components using a model directly
39 #define SPECIALPROTOCOL_PRIVATE_OBJECT "private:object"
40 // indicates loading of components using a stream only
41 #define SPECIALPROTOCOL_PRIVATE_STREAM "private:stream"
42 // indicates creation of empty documents
43 #define SPECIALPROTOCOL_PRIVATE_FACTORY "private:factory"
44 // internal protocol of the sfx project for generic dispatch funtionality
45 #define SPECIALPROTOCOL_SLOT "slot:"
46 // external representation of the slot protocol using names instead of id's
47 #define SPECIALPROTOCOL_UNO ".uno:"
48 // special sfx protocol to execute macros
49 #define SPECIALPROTOCOL_MACRO "macro:"
50 // generic way to start uno services during dispatch
51 #define SPECIALPROTOCOL_SERVICE "service:"
53 #define SPECIALPROTOCOL_MAILTO "mailto:"
55 #define SPECIALPROTOCOL_NEWS "news:"
61 //_______________________________________________________________________
63 enums for well known protocols
80 //_______________________________________________________________________
82 it checks, if the given URL string match one of the well known protocols.
83 It returns the right enum value.
84 Protocols are defined above ...
86 static EProtocol
specifyProtocol( const OUString
& sURL
)
88 // because "private:" is part of e.g. "private:object" too ...
89 // we must check it before all other ones!!!
90 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE
)))
93 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_OBJECT
)))
94 return E_PRIVATE_OBJECT
;
96 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_STREAM
)))
97 return E_PRIVATE_STREAM
;
99 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_FACTORY
)))
100 return E_PRIVATE_FACTORY
;
102 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_SLOT
)))
105 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_UNO
)))
108 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_MACRO
)))
111 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_SERVICE
)))
114 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_MAILTO
)))
117 if (sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_NEWS
)))
120 return E_UNKNOWN_PROTOCOL
;
123 //_______________________________________________________________________
125 it checks if given URL match the required protocol only
126 It should be used instead of specifyProtocol() if only this question
127 is interesting to perform the code. We must not check for all possible protocols here...
129 static sal_Bool
isProtocol( const OUString
& sURL
, EProtocol eRequired
)
131 sal_Bool bRet
= sal_False
;
135 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE
));
137 case E_PRIVATE_OBJECT
:
138 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_OBJECT
));
140 case E_PRIVATE_STREAM
:
141 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_STREAM
));
143 case E_PRIVATE_FACTORY
:
144 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_PRIVATE_FACTORY
));
147 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_SLOT
));
150 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_UNO
));
153 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_MACRO
));
156 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_SERVICE
));
159 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_MAILTO
));
162 bRet
= sURL
.matchAsciiL(RTL_CONSTASCII_STRINGPARAM(SPECIALPROTOCOL_NEWS
));
172 } // namespace framework
174 #endif // #ifndef __FRAMEWORK_PROTOCOLS_H_
176 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */