LibreOffice Module framework (master) 1
protocols.h
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20/*TODO outline this implementation :-) */
21
22#pragma once
23
24#include <sal/config.h>
25
26#include <string_view>
27
28#include <o3tl/string_view.hxx>
29
30namespace framework{
31
38// indicates a loadable content in general!
39#define SPECIALPROTOCOL_PRIVATE "private:"
40// indicates loading of components using a model directly
41#define SPECIALPROTOCOL_PRIVATE_OBJECT u"private:object"
42// indicates loading of components using a stream only
43#define SPECIALPROTOCOL_PRIVATE_STREAM u"private:stream"
44// indicates creation of empty documents
45#define SPECIALPROTOCOL_PRIVATE_FACTORY u"private:factory"
46// internal protocol of the sfx project for generic dispatch functionality
47#define SPECIALPROTOCOL_SLOT u"slot:"
48// external representation of the slot protocol using names instead of id's
49#define SPECIALPROTOCOL_UNO u".uno:"
50// special sfx protocol to execute macros
51#define SPECIALPROTOCOL_MACRO u"macro:"
52// generic way to start uno services during dispatch
53#define SPECIALPROTOCOL_SERVICE u"service:"
54// for sending mails
55#define SPECIALPROTOCOL_MAILTO u"mailto:"
56// for sending news
57#define SPECIALPROTOCOL_NEWS u"news:"
58
60enum class EProtocol
61{
65 Slot,
66 Uno,
67 Macro,
68 Service,
69 MailTo,
70 News
71};
72
74{
75 public:
76
82 static bool isProtocol( std::u16string_view sURL, EProtocol eRequired )
83 {
84 bool bRet = false;
85 switch(eRequired)
86 {
89 break;
92 break;
95 break;
96 case EProtocol::Slot:
98 break;
99 case EProtocol::Uno:
101 break;
102 case EProtocol::Macro:
104 break;
107 break;
110 break;
111 case EProtocol::News:
113 break;
114 default:
115 bRet = false;
116 break;
117 }
118 return bRet;
119 }
120};
121
122} // namespace framework
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool isProtocol(std::u16string_view sURL, EProtocol eRequired)
it checks if given URL match the required protocol only It should be used instead of specifyProtocol(...
Definition: protocols.h:82
EProtocol
well known protocols
Definition: protocols.h:61
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept
#define SPECIALPROTOCOL_UNO
Definition: protocols.h:49
#define SPECIALPROTOCOL_PRIVATE_STREAM
Definition: protocols.h:43
#define SPECIALPROTOCOL_NEWS
Definition: protocols.h:57
#define SPECIALPROTOCOL_SLOT
Definition: protocols.h:47
#define SPECIALPROTOCOL_SERVICE
Definition: protocols.h:53
#define SPECIALPROTOCOL_MAILTO
Definition: protocols.h:55
#define SPECIALPROTOCOL_PRIVATE_FACTORY
Definition: protocols.h:45
#define SPECIALPROTOCOL_MACRO
Definition: protocols.h:51
#define SPECIALPROTOCOL_PRIVATE_OBJECT
Definition: protocols.h:41