/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
class theExceptionThrower : public rtl::Static<ExceptionThrower, theExceptionThrower> {};
#if RETHROW_FAKE_EXCEPTIONS // In the native iOS / Android app, where we don't have any Java, Python, // BASIC, or other scripting, the only thing that would use the C++/UNO bridge // functionality that invokes codeSnippet() was cppu::throwException(). // // codeSnippet() is part of what corresponds to the code that uses // run-time-generated machine code on other platforms. We can't generate code // at run-time on iOS, that has been known forever. // // Instead of digging in and trying to understand what is wrong, another // solution was chosen. It turns out that the number of types of exception // objects thrown by cppu::throwException() is fairly small. During startup of // the LibreOffice code, and loading of an .odt document, only one kind of // exception is thrown this way... (The lovely // css::ucb:InteractiveAugmentedIOException.) // // So we can simply have code that checks what the type of object being thrown // is, and explicitly throws such an object then with a normal C++ throw // statement. Seems to work. template <class E> void tryThrow(css::uno::Any const& aException)
{
E aSpecificException; if (aException >>= aSpecificException) throw aSpecificException;
}
void SAL_CALL throwException( Any const & exc )
{ if (exc.getValueTypeClass() != TypeClass_EXCEPTION)
{ throw RuntimeException(
u"no UNO exception given " "(must be derived from com::sun::star::uno::Exception)!"_ustr );
}
#if RETHROW_FAKE_EXCEPTIONS
lo_mobile_throwException(exc); #else
Mapping uno2cpp(Environment(u"" UNO_LB_UNO ""_ustr), Environment::getCurrent()); if (! uno2cpp.is())
{ throw RuntimeException(
u"cannot get binary UNO to C++ mapping!"_ustr );
}
Any SAL_CALL getCaughtException()
{ // why does this differ from RETHROW_FAKE_EXCEPTIONS? #ifdefined(ANDROID) return Any(); #else
Mapping cpp2uno(Environment::getCurrent(), Environment(u"" UNO_LB_UNO ""_ustr)); if (! cpp2uno.is())
{ throw RuntimeException(
u"cannot get C++ to binary UNO mapping!"_ustr );
}
Mapping uno2cpp(Environment(u"" UNO_LB_UNO ""_ustr), Environment::getCurrent()); if (! uno2cpp.is())
{ throw RuntimeException(
u"cannot get binary UNO to C++ mapping!"_ustr );
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.