/* -*- 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 .
*/
// Check whether aCommand contains an absolute URI reference:
css::uno::Reference< css::uri::XUriReference > uri(
css::uri::UriReferenceFactory::create(m_xContext)->parse(aCommand)); if (uri.is() && uri->isAbsolute())
{ // It seems to be a URL... // We need to re-encode file urls because osl_getFileURLFromSystemPath converts // to UTF-8 before encoding non ascii characters, which is not what other apps // expect.
OUString aURL = css::uri::ExternalUriReferenceTranslator::create(
m_xContext)->translateToExternal(aCommand); if ( aURL.isEmpty() && !aCommand.isEmpty() )
{ throw RuntimeException( "Cannot translate URI reference to external format: "
+ aCommand,
getXWeak());
}
//TODO: Using open(1) with an argument that syntactically is an absolute // URI reference does not necessarily give expected results: // 1 If the given URI reference matches a supported scheme (e.g., // "mailto:foo"): // 1.1 If it matches an existing pathname (relative to CWD): Results // in "mailto:foo?\n[0]\tcancel\n[1]\tOpen the file\tmailto:foo\n[2]\t // Open the URL\tmailto:foo\n\nWhich did you mean? Cancelled." on // stderr and SystemShellExecuteException. // 1.2 If it does not match an existing pathname (relative to CWD): // Results in the corresponding application being opened with the given // document (e.g., Mail with a New Message). // 2 If the given URI reference does not match a supported scheme // (e.g., "foo:bar"): // 2.1 If it matches an existing pathname (relative to CWD) pointing to // an executable: Results in execution of that executable. // 2.2 If it matches an existing pathname (relative to CWD) pointing to // a non-executable regular file: Results in opening it in TextEdit. // 2.3 If it matches an existing pathname (relative to CWD) pointing to // a directory: Results in opening it in Finder. // 2.4 If it does not match an existing pathname (relative to CWD): // Results in "The file /.../foo:bar does not exits." (where "/..." is // the CWD) on stderr and SystemShellExecuteException.
aBuffer.append("open"); if (dir) {
aBuffer.append(" -R");
}
aBuffer.append(" --"); #else // Just use xdg-open on non-Mac
aBuffer.append("xdg-open"); #endif
aBuffer.append(" ");
escapeForShell(aBuffer, OUStringToOString(aURL, osl_getThreadTextEncoding()));
css::uno::Reference< css::uri::XUriReference > uri(
css::uri::UriReferenceFactory::create(m_xContext)->parse(aCommand)); if (!uri.is() || !uri->isAbsolute()) throw SystemShellExecuteException("Emscripten can just open absolute URIs.", static_cast<XSystemShellExecute*>(this), 42); if (!aParameter.isEmpty()) throw SystemShellExecuteException("Emscripten can't process parameters; encode in URI.", static_cast<XSystemShellExecute*>(this), 42);
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 und die Messung sind noch experimentell.