1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 /*TODO outline this implementation :-) */
30 #ifndef __FRAMEWORK_PROTOCOLS_H_
31 #define __FRAMEWORK_PROTOCOLS_H_
33 //_________________________________________________________________________________________________________________
35 //_________________________________________________________________________________________________________________
37 #include <macros/generic.hxx>
39 //_________________________________________________________________________________________________________________
41 //_________________________________________________________________________________________________________________
45 //_______________________________________________________________________
47 some protocols must be checked during loading or dispatching URLs manually
48 It can be neccessary to decide, if a URL represent a non visible content or
49 a real visible component.
52 #define SPECIALPROTOCOL_PRIVATE DECLARE_ASCII("private:" ) // indicates a loadable content in general!
53 #define SPECIALPROTOCOL_PRIVATE_OBJECT DECLARE_ASCII("private:object" ) // indicates loading of components using a model directly
54 #define SPECIALPROTOCOL_PRIVATE_STREAM DECLARE_ASCII("private:stream" ) // indicates loading of components using a stream only
55 #define SPECIALPROTOCOL_PRIVATE_FACTORY DECLARE_ASCII("private:factory") // indicates creation of empty documents
56 #define SPECIALPROTOCOL_SLOT DECLARE_ASCII("slot:" ) // internal protocol of the sfx project for generic dispatch funtionality
57 #define SPECIALPROTOCOL_UNO DECLARE_ASCII(".uno:" ) // external representation of the slot protocol using names instead of id's
58 #define SPECIALPROTOCOL_MACRO DECLARE_ASCII("macro:" ) // special sfx protocol to execute macros
59 #define SPECIALPROTOCOL_SERVICE DECLARE_ASCII("service:" ) // generic way to start uno services during dispatch
60 #define SPECIALPROTOCOL_MAILTO DECLARE_ASCII("mailto:" ) // for sending mails
61 #define SPECIALPROTOCOL_NEWS DECLARE_ASCII("news:" ) // for sending news
67 //_______________________________________________________________________
69 enums for well known protocols
86 //_______________________________________________________________________
88 it checks, if the given URL string match one of the well known protocols.
89 It returns the right enum value.
90 Protocols are defined above ...
92 static EProtocol
specifyProtocol( const ::rtl::OUString
& sURL
)
94 // because "private:" is part of e.g. "private:object" too ...
95 // we must check it before all other ones!!!
96 if (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE
,SPECIALPROTOCOL_PRIVATE
.getLength()) == 0)
99 if (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_OBJECT
,SPECIALPROTOCOL_PRIVATE_OBJECT
.getLength()) == 0)
100 return E_PRIVATE_OBJECT
;
102 if (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_STREAM
,SPECIALPROTOCOL_PRIVATE_STREAM
.getLength()) == 0)
103 return E_PRIVATE_STREAM
;
105 if (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_FACTORY
,SPECIALPROTOCOL_PRIVATE_FACTORY
.getLength()) == 0)
106 return E_PRIVATE_FACTORY
;
108 if (sURL
.compareTo(SPECIALPROTOCOL_SLOT
,SPECIALPROTOCOL_SLOT
.getLength()) == 0)
111 if (sURL
.compareTo(SPECIALPROTOCOL_UNO
,SPECIALPROTOCOL_UNO
.getLength()) == 0)
114 if (sURL
.compareTo(SPECIALPROTOCOL_MACRO
,SPECIALPROTOCOL_MACRO
.getLength()) == 0)
117 if (sURL
.compareTo(SPECIALPROTOCOL_SERVICE
,SPECIALPROTOCOL_SERVICE
.getLength()) == 0)
120 if (sURL
.compareTo(SPECIALPROTOCOL_MAILTO
,SPECIALPROTOCOL_MAILTO
.getLength()) == 0)
123 if (sURL
.compareTo(SPECIALPROTOCOL_NEWS
,SPECIALPROTOCOL_NEWS
.getLength()) == 0)
126 return E_UNKNOWN_PROTOCOL
;
129 //_______________________________________________________________________
131 it checks if given URL match the required protocol only
132 It should be used instead of specifyProtocol() if only this question
133 is interesting to perform the code. We must not check for all possible protocols here...
135 static sal_Bool
isProtocol( const ::rtl::OUString
& sURL
, EProtocol eRequired
)
139 case E_PRIVATE
: return (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE
,SPECIALPROTOCOL_PRIVATE
.getLength() ) == 0);
140 case E_PRIVATE_OBJECT
: return (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_OBJECT
,SPECIALPROTOCOL_PRIVATE_OBJECT
.getLength() ) == 0);
141 case E_PRIVATE_STREAM
: return (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_STREAM
,SPECIALPROTOCOL_PRIVATE_STREAM
.getLength() ) == 0);
142 case E_PRIVATE_FACTORY
: return (sURL
.compareTo(SPECIALPROTOCOL_PRIVATE_FACTORY
,SPECIALPROTOCOL_PRIVATE_FACTORY
.getLength()) == 0);
143 case E_SLOT
: return (sURL
.compareTo(SPECIALPROTOCOL_SLOT
,SPECIALPROTOCOL_SLOT
.getLength() ) == 0);
144 case E_UNO
: return (sURL
.compareTo(SPECIALPROTOCOL_UNO
,SPECIALPROTOCOL_UNO
.getLength() ) == 0);
145 case E_MACRO
: return (sURL
.compareTo(SPECIALPROTOCOL_MACRO
,SPECIALPROTOCOL_MACRO
.getLength() ) == 0);
146 case E_SERVICE
: return (sURL
.compareTo(SPECIALPROTOCOL_SERVICE
,SPECIALPROTOCOL_SERVICE
.getLength() ) == 0);
147 case E_MAILTO
: return (sURL
.compareTo(SPECIALPROTOCOL_MAILTO
,SPECIALPROTOCOL_MAILTO
.getLength() ) == 0);
148 case E_NEWS
: return (sURL
.compareTo(SPECIALPROTOCOL_NEWS
,SPECIALPROTOCOL_NEWS
.getLength() ) == 0);
149 default : return sal_False
;
155 } // namespace framework
157 #endif // #ifndef __FRAMEWORK_PROTOCOLS_H_