docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / comphelper / source / misc / errcode.cxx
blob716daab1793eedd50f7af83390d149dd8906b59b
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 #include <comphelper/errcode.hxx>
21 #include <rtl/ustrbuf.hxx>
22 #include <o3tl/runtimetooustring.hxx>
24 UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OUString ErrCode::toString() const
26 std::u16string_view pWarningError;
27 if (IsWarning())
28 pWarningError = u"Warning";
29 else
30 pWarningError = u"Error";
32 std::u16string_view pArea;
33 switch (GetArea())
35 case ErrCodeArea::Io:
36 pArea = u"Io";
37 break;
38 case ErrCodeArea::Sfx:
39 pArea = u"Sfx";
40 break;
41 case ErrCodeArea::Inet:
42 pArea = u"Inet";
43 break;
44 case ErrCodeArea::Vcl:
45 pArea = u"Vcl";
46 break;
47 case ErrCodeArea::Svx:
48 pArea = u"Svx";
49 break;
50 case ErrCodeArea::So:
51 pArea = u"So";
52 break;
53 case ErrCodeArea::Sbx:
54 pArea = u"Sbx";
55 break;
56 case ErrCodeArea::Uui:
57 pArea = u"Uui";
58 break;
59 case ErrCodeArea::Sc:
60 pArea = u"Sc";
61 break;
62 case ErrCodeArea::Sd:
63 pArea = u"Sd";
64 break;
65 case ErrCodeArea::Sw:
66 pArea = u"Sw";
67 break;
70 std::u16string_view pClass;
71 switch (GetClass())
73 case ErrCodeClass::NONE:
74 pClass = u"NONE";
75 break;
76 case ErrCodeClass::Abort:
77 pClass = u"Abort";
78 break;
79 case ErrCodeClass::General:
80 pClass = u"General";
81 break;
82 case ErrCodeClass::NotExists:
83 pClass = u"NotExists";
84 break;
85 case ErrCodeClass::AlreadyExists:
86 pClass = u"AlreadyExists";
87 break;
88 case ErrCodeClass::Access:
89 pClass = u"Access";
90 break;
91 case ErrCodeClass::Path:
92 pClass = u"Path";
93 break;
94 case ErrCodeClass::Locking:
95 pClass = u"Locking";
96 break;
97 case ErrCodeClass::Parameter:
98 pClass = u"Parameter";
99 break;
100 case ErrCodeClass::Space:
101 pClass = u"Space";
102 break;
103 case ErrCodeClass::NotSupported:
104 pClass = u"NotSupported";
105 break;
106 case ErrCodeClass::Read:
107 pClass = u"Read";
108 break;
109 case ErrCodeClass::Write:
110 pClass = u"Write";
111 break;
112 case ErrCodeClass::Unknown:
113 pClass = u"Unknown";
114 break;
115 case ErrCodeClass::Version:
116 pClass = u"Version";
117 break;
118 case ErrCodeClass::Format:
119 pClass = u"Format";
120 break;
121 case ErrCodeClass::Create:
122 pClass = u"Create";
123 break;
124 case ErrCodeClass::Import:
125 pClass = u"Import";
126 break;
127 case ErrCodeClass::Export:
128 pClass = u"Export";
129 break;
130 case ErrCodeClass::So:
131 pClass = u"So";
132 break;
133 case ErrCodeClass::Sbx:
134 pClass = u"Sbx";
135 break;
136 case ErrCodeClass::Runtime:
137 pClass = u"Runtime";
138 break;
139 case ErrCodeClass::Compiler:
140 pClass = u"Compiler";
141 break;
143 return toHexString() + "(" + pWarningError + " Area:" + pArea + " Class:" + pClass
144 + " Code:" + OUString::number(GetCode()) + ")";
147 COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCode& err)
149 os << err.toString();
150 return os;
153 UNLESS_MERGELIBS(COMPHELPER_DLLPUBLIC) OUString ErrCodeMsg::toString() const
155 OUString s = mnCode.toString();
156 if (!maArg1.isEmpty())
157 s += " arg1=" + maArg1;
158 if (!maArg2.isEmpty())
159 s += " arg2=" + maArg2;
160 #ifdef LIBO_ERRMSG_USE_SOURCE_LOCATION
161 if (!moLoc)
162 s += OUString::Concat(" func=") + o3tl::runtimeToOUString(moLoc->function_name()) + " src="
163 + o3tl::runtimeToOUString(moLoc->file_name()) + ":" + OUString::number(moLoc->line());
164 #endif
165 return s;
168 COMPHELPER_DLLPUBLIC std::ostream& operator<<(std::ostream& os, const ErrCodeMsg& err)
170 os << err.toString();
171 return os;
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */