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