1*228b4580SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*228b4580SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*228b4580SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*228b4580SAndrew Rist * distributed with this work for additional information 6*228b4580SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*228b4580SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*228b4580SAndrew Rist * "License"); you may not use this file except in compliance 9*228b4580SAndrew Rist * with the License. You may obtain a copy of the License at 10*228b4580SAndrew Rist * 11*228b4580SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*228b4580SAndrew Rist * 13*228b4580SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*228b4580SAndrew Rist * software distributed under the License is distributed on an 15*228b4580SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*228b4580SAndrew Rist * KIND, either express or implied. See the License for the 17*228b4580SAndrew Rist * specific language governing permissions and limitations 18*228b4580SAndrew Rist * under the License. 19*228b4580SAndrew Rist * 20*228b4580SAndrew Rist *************************************************************/ 21*228b4580SAndrew Rist 22*228b4580SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir /*TODO outline this implementation :-) */ 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef __FRAMEWORK_PROTOCOLS_H_ 27cdf0e10cSrcweir #define __FRAMEWORK_PROTOCOLS_H_ 28cdf0e10cSrcweir 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir // includes 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir 33cdf0e10cSrcweir #include <macros/generic.hxx> 34cdf0e10cSrcweir 35cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 36cdf0e10cSrcweir // namespace 37cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 38cdf0e10cSrcweir 39cdf0e10cSrcweir namespace framework{ 40cdf0e10cSrcweir 41cdf0e10cSrcweir //_______________________________________________________________________ 42cdf0e10cSrcweir /** 43cdf0e10cSrcweir some protocols must be checked during loading or dispatching URLs manually 44cdf0e10cSrcweir It can be neccessary to decide, if a URL represent a non visible content or 45cdf0e10cSrcweir a real visible component. 46cdf0e10cSrcweir */ 47cdf0e10cSrcweir 48cdf0e10cSrcweir #define SPECIALPROTOCOL_PRIVATE DECLARE_ASCII("private:" ) // indicates a loadable content in general! 49cdf0e10cSrcweir #define SPECIALPROTOCOL_PRIVATE_OBJECT DECLARE_ASCII("private:object" ) // indicates loading of components using a model directly 50cdf0e10cSrcweir #define SPECIALPROTOCOL_PRIVATE_STREAM DECLARE_ASCII("private:stream" ) // indicates loading of components using a stream only 51cdf0e10cSrcweir #define SPECIALPROTOCOL_PRIVATE_FACTORY DECLARE_ASCII("private:factory") // indicates creation of empty documents 52cdf0e10cSrcweir #define SPECIALPROTOCOL_SLOT DECLARE_ASCII("slot:" ) // internal protocol of the sfx project for generic dispatch funtionality 53cdf0e10cSrcweir #define SPECIALPROTOCOL_UNO DECLARE_ASCII(".uno:" ) // external representation of the slot protocol using names instead of id's 54cdf0e10cSrcweir #define SPECIALPROTOCOL_MACRO DECLARE_ASCII("macro:" ) // special sfx protocol to execute macros 55cdf0e10cSrcweir #define SPECIALPROTOCOL_SERVICE DECLARE_ASCII("service:" ) // generic way to start uno services during dispatch 56cdf0e10cSrcweir #define SPECIALPROTOCOL_MAILTO DECLARE_ASCII("mailto:" ) // for sending mails 57cdf0e10cSrcweir #define SPECIALPROTOCOL_NEWS DECLARE_ASCII("news:" ) // for sending news 58cdf0e10cSrcweir 59cdf0e10cSrcweir class ProtocolCheck 60cdf0e10cSrcweir { 61cdf0e10cSrcweir public: 62cdf0e10cSrcweir 63cdf0e10cSrcweir //_______________________________________________________________________ 64cdf0e10cSrcweir /** 65cdf0e10cSrcweir enums for well known protocols 66cdf0e10cSrcweir */ 67cdf0e10cSrcweir enum EProtocol 68cdf0e10cSrcweir { 69cdf0e10cSrcweir E_UNKNOWN_PROTOCOL , 70cdf0e10cSrcweir E_PRIVATE , 71cdf0e10cSrcweir E_PRIVATE_OBJECT , 72cdf0e10cSrcweir E_PRIVATE_STREAM , 73cdf0e10cSrcweir E_PRIVATE_FACTORY , 74cdf0e10cSrcweir E_SLOT , 75cdf0e10cSrcweir E_UNO , 76cdf0e10cSrcweir E_MACRO , 77cdf0e10cSrcweir E_SERVICE , 78cdf0e10cSrcweir E_MAILTO , 79cdf0e10cSrcweir E_NEWS 80cdf0e10cSrcweir }; 81cdf0e10cSrcweir 82cdf0e10cSrcweir //_______________________________________________________________________ 83cdf0e10cSrcweir /** 84cdf0e10cSrcweir it checks, if the given URL string match one of the well known protocols. 85cdf0e10cSrcweir It returns the right enum value. 86cdf0e10cSrcweir Protocols are defined above ... 87cdf0e10cSrcweir */ specifyProtocol(const::rtl::OUString & sURL)88cdf0e10cSrcweir static EProtocol specifyProtocol( const ::rtl::OUString& sURL ) 89cdf0e10cSrcweir { 90cdf0e10cSrcweir // because "private:" is part of e.g. "private:object" too ... 91cdf0e10cSrcweir // we must check it before all other ones!!! 92cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE,SPECIALPROTOCOL_PRIVATE.getLength()) == 0) 93cdf0e10cSrcweir return E_PRIVATE; 94cdf0e10cSrcweir else 95cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_OBJECT,SPECIALPROTOCOL_PRIVATE_OBJECT.getLength()) == 0) 96cdf0e10cSrcweir return E_PRIVATE_OBJECT; 97cdf0e10cSrcweir else 98cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_STREAM,SPECIALPROTOCOL_PRIVATE_STREAM.getLength()) == 0) 99cdf0e10cSrcweir return E_PRIVATE_STREAM; 100cdf0e10cSrcweir else 101cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_FACTORY,SPECIALPROTOCOL_PRIVATE_FACTORY.getLength()) == 0) 102cdf0e10cSrcweir return E_PRIVATE_FACTORY; 103cdf0e10cSrcweir else 104cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_SLOT,SPECIALPROTOCOL_SLOT.getLength()) == 0) 105cdf0e10cSrcweir return E_SLOT; 106cdf0e10cSrcweir else 107cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_UNO,SPECIALPROTOCOL_UNO.getLength()) == 0) 108cdf0e10cSrcweir return E_UNO; 109cdf0e10cSrcweir else 110cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_MACRO,SPECIALPROTOCOL_MACRO.getLength()) == 0) 111cdf0e10cSrcweir return E_MACRO; 112cdf0e10cSrcweir else 113cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_SERVICE,SPECIALPROTOCOL_SERVICE.getLength()) == 0) 114cdf0e10cSrcweir return E_SERVICE; 115cdf0e10cSrcweir else 116cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_MAILTO,SPECIALPROTOCOL_MAILTO.getLength()) == 0) 117cdf0e10cSrcweir return E_MAILTO; 118cdf0e10cSrcweir else 119cdf0e10cSrcweir if (sURL.compareTo(SPECIALPROTOCOL_NEWS,SPECIALPROTOCOL_NEWS.getLength()) == 0) 120cdf0e10cSrcweir return E_NEWS; 121cdf0e10cSrcweir else 122cdf0e10cSrcweir return E_UNKNOWN_PROTOCOL; 123cdf0e10cSrcweir } 124cdf0e10cSrcweir 125cdf0e10cSrcweir //_______________________________________________________________________ 126cdf0e10cSrcweir /** 127cdf0e10cSrcweir it checks if given URL match the required protocol only 128cdf0e10cSrcweir It should be used instead of specifyProtocol() if only this question 129cdf0e10cSrcweir is interesting to perform the code. We must not check for all possible protocols here... 130cdf0e10cSrcweir */ isProtocol(const::rtl::OUString & sURL,EProtocol eRequired)131cdf0e10cSrcweir static sal_Bool isProtocol( const ::rtl::OUString& sURL, EProtocol eRequired ) 132cdf0e10cSrcweir { 133cdf0e10cSrcweir switch(eRequired) 134cdf0e10cSrcweir { 135cdf0e10cSrcweir case E_PRIVATE : return (sURL.compareTo(SPECIALPROTOCOL_PRIVATE ,SPECIALPROTOCOL_PRIVATE.getLength() ) == 0); 136cdf0e10cSrcweir case E_PRIVATE_OBJECT : return (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_OBJECT ,SPECIALPROTOCOL_PRIVATE_OBJECT.getLength() ) == 0); 137cdf0e10cSrcweir case E_PRIVATE_STREAM : return (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_STREAM ,SPECIALPROTOCOL_PRIVATE_STREAM.getLength() ) == 0); 138cdf0e10cSrcweir case E_PRIVATE_FACTORY : return (sURL.compareTo(SPECIALPROTOCOL_PRIVATE_FACTORY,SPECIALPROTOCOL_PRIVATE_FACTORY.getLength()) == 0); 139cdf0e10cSrcweir case E_SLOT : return (sURL.compareTo(SPECIALPROTOCOL_SLOT ,SPECIALPROTOCOL_SLOT.getLength() ) == 0); 140cdf0e10cSrcweir case E_UNO : return (sURL.compareTo(SPECIALPROTOCOL_UNO ,SPECIALPROTOCOL_UNO.getLength() ) == 0); 141cdf0e10cSrcweir case E_MACRO : return (sURL.compareTo(SPECIALPROTOCOL_MACRO ,SPECIALPROTOCOL_MACRO.getLength() ) == 0); 142cdf0e10cSrcweir case E_SERVICE : return (sURL.compareTo(SPECIALPROTOCOL_SERVICE ,SPECIALPROTOCOL_SERVICE.getLength() ) == 0); 143cdf0e10cSrcweir case E_MAILTO : return (sURL.compareTo(SPECIALPROTOCOL_MAILTO ,SPECIALPROTOCOL_MAILTO.getLength() ) == 0); 144cdf0e10cSrcweir case E_NEWS : return (sURL.compareTo(SPECIALPROTOCOL_NEWS ,SPECIALPROTOCOL_NEWS.getLength() ) == 0); 145cdf0e10cSrcweir default : return sal_False; 146cdf0e10cSrcweir } 147cdf0e10cSrcweir return sal_False; 148cdf0e10cSrcweir } 149cdf0e10cSrcweir }; 150cdf0e10cSrcweir 151cdf0e10cSrcweir } // namespace framework 152cdf0e10cSrcweir 153cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_PROTOCOLS_H_ 154