merge the formfield patch from ooo-build
[ooovba.git] / framework / inc / protocols.h
blob129fdf742d7b40f2d6ee79943b1c81954691d620
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: protocols.h,v $
10 * $Revision: 1.7 $
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 //_________________________________________________________________________________________________________________
37 // includes
38 //_________________________________________________________________________________________________________________
40 #include <macros/generic.hxx>
42 //_________________________________________________________________________________________________________________
43 // namespace
44 //_________________________________________________________________________________________________________________
46 namespace framework{
48 //_______________________________________________________________________
49 /**
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
66 class ProtocolCheck
68 public:
70 //_______________________________________________________________________
71 /**
72 enums for well known protocols
74 enum EProtocol
76 E_UNKNOWN_PROTOCOL ,
77 E_PRIVATE ,
78 E_PRIVATE_OBJECT ,
79 E_PRIVATE_STREAM ,
80 E_PRIVATE_FACTORY ,
81 E_SLOT ,
82 E_UNO ,
83 E_MACRO ,
84 E_SERVICE ,
85 E_MAILTO ,
86 E_NEWS
89 //_______________________________________________________________________
90 /**
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)
100 return E_PRIVATE;
101 else
102 if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_OBJECT,SPECIALPROTOCOL_PRIVATE_OBJECT.getLength()) == 0)
103 return E_PRIVATE_OBJECT;
104 else
105 if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_STREAM,SPECIALPROTOCOL_PRIVATE_STREAM.getLength()) == 0)
106 return E_PRIVATE_STREAM;
107 else
108 if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_FACTORY,SPECIALPROTOCOL_PRIVATE_FACTORY.getLength()) == 0)
109 return E_PRIVATE_FACTORY;
110 else
111 if (sURL.compareTo(SPECIALPROTOCOL_SLOT,SPECIALPROTOCOL_SLOT.getLength()) == 0)
112 return E_SLOT;
113 else
114 if (sURL.compareTo(SPECIALPROTOCOL_UNO,SPECIALPROTOCOL_UNO.getLength()) == 0)
115 return E_UNO;
116 else
117 if (sURL.compareTo(SPECIALPROTOCOL_MACRO,SPECIALPROTOCOL_MACRO.getLength()) == 0)
118 return E_MACRO;
119 else
120 if (sURL.compareTo(SPECIALPROTOCOL_SERVICE,SPECIALPROTOCOL_SERVICE.getLength()) == 0)
121 return E_SERVICE;
122 else
123 if (sURL.compareTo(SPECIALPROTOCOL_MAILTO,SPECIALPROTOCOL_MAILTO.getLength()) == 0)
124 return E_MAILTO;
125 else
126 if (sURL.compareTo(SPECIALPROTOCOL_NEWS,SPECIALPROTOCOL_NEWS.getLength()) == 0)
127 return E_NEWS;
128 else
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 )
140 switch(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;
154 return sal_False;
158 } // namespace framework
160 #endif // #ifndef __FRAMEWORK_PROTOCOLS_H_