make sure to not divide by zero when computing miter limit
[LibreOffice.git] / framework / inc / protocols.h
blob30d87cc593368435c636ad4c07fe684626acc234
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
24 #include <sal/config.h>
26 #include <string_view>
28 #include <o3tl/string_view.hxx>
29 #include <rtl/ustring.hxx>
31 namespace framework{
33 /**
34 some protocols must be checked during loading or dispatching URLs manually
35 It can be necessary to decide, if a URL represent a non visible content or
36 a real visible component.
39 // indicates a loadable content in general!
40 #define SPECIALPROTOCOL_PRIVATE "private:"
41 // indicates loading of components using a model directly
42 #define SPECIALPROTOCOL_PRIVATE_OBJECT u"private:object"
43 // indicates loading of components using a stream only
44 #define SPECIALPROTOCOL_PRIVATE_STREAM u"private:stream"
45 // indicates creation of empty documents
46 #define SPECIALPROTOCOL_PRIVATE_FACTORY u"private:factory"
47 // internal protocol of the sfx project for generic dispatch functionality
48 #define SPECIALPROTOCOL_SLOT u"slot:"
49 // external representation of the slot protocol using names instead of id's
50 #define SPECIALPROTOCOL_UNO u".uno:"
51 // special sfx protocol to execute macros
52 #define SPECIALPROTOCOL_MACRO u"macro:"
53 // generic way to start uno services during dispatch
54 #define SPECIALPROTOCOL_SERVICE u"service:"
55 // for sending mails
56 #define SPECIALPROTOCOL_MAILTO u"mailto:"
57 // for sending news
58 #define SPECIALPROTOCOL_NEWS u"news:"
60 /** well known protocols */
61 enum class EProtocol
63 PrivateObject,
64 PrivateStream,
65 PrivateFactory,
66 Slot,
67 Uno,
68 Macro,
69 Service,
70 MailTo,
71 News
74 class ProtocolCheck
76 public:
78 /**
79 it checks if given URL match the required protocol only
80 It should be used instead of specifyProtocol() if only this question
81 is interesting to perform the code. We must not check for all possible protocols here...
83 static bool isProtocol( std::u16string_view sURL, EProtocol eRequired )
85 bool bRet = false;
86 switch(eRequired)
88 case EProtocol::PrivateObject:
89 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_OBJECT);
90 break;
91 case EProtocol::PrivateStream:
92 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_STREAM);
93 break;
94 case EProtocol::PrivateFactory:
95 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_PRIVATE_FACTORY);
96 break;
97 case EProtocol::Slot:
98 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SLOT);
99 break;
100 case EProtocol::Uno:
101 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_UNO);
102 break;
103 case EProtocol::Macro:
104 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MACRO);
105 break;
106 case EProtocol::Service:
107 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_SERVICE);
108 break;
109 case EProtocol::MailTo:
110 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_MAILTO);
111 break;
112 case EProtocol::News:
113 bRet = o3tl::starts_with(sURL, SPECIALPROTOCOL_NEWS);
114 break;
115 default:
116 bRet = false;
117 break;
119 return bRet;
123 } // namespace framework
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */