LibreOffice Module framework (master) 1
uriabbreviation.cxx
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
21
22#include <sal/config.h>
23
24#include <tools/urlobj.hxx>
26
27// framework namespace
28namespace framework
29{
30
31// XInterface, XTypeProvider, XServiceInfo
32
34{
35 return "com.sun.star.comp.framework.UriAbbreviation";
36}
37
38sal_Bool SAL_CALL UriAbbreviation::supportsService( const OUString& sServiceName )
39{
41}
42
43css::uno::Sequence< OUString > SAL_CALL UriAbbreviation::getSupportedServiceNames()
44{
45 return { "com.sun.star.util.UriAbbreviation" };
46}
47
48UriAbbreviation::UriAbbreviation(css::uno::Reference< css::uno::XComponentContext > const & )
49{
50}
51
52// css::util::XStringAbbreviation:
53OUString SAL_CALL UriAbbreviation::abbreviateString(const css::uno::Reference< css::util::XStringWidth > & xStringWidth, ::sal_Int32 nWidth, const OUString & aString)
54{
55 OUString aResult( aString );
56 if ( xStringWidth.is() )
57 {
58 // Use INetURLObject to abbreviate URLs
59 INetURLObject aURL( aString );
60 aResult = aURL.getAbbreviated( xStringWidth, nWidth, INetURLObject::DecodeMechanism::Unambiguous );
61 }
62
63 return aResult;
64}
65
66} // namespace framework
67
68extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
70 css::uno::XComponentContext* context, css::uno::Sequence<css::uno::Any> const& )
71{
72 return cppu::acquire(new framework::UriAbbreviation(context));
73}
74
75/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr OUStringLiteral sServiceName
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL abbreviateString(const css::uno::Reference< css::util::XStringWidth > &xStringWidth, ::sal_Int32 nWidth, const OUString &aString) override
virtual sal_Bool SAL_CALL supportsService(const OUString &sServiceName) override
virtual OUString SAL_CALL getImplementationName() override
UriAbbreviation(css::uno::Reference< css::uno::XComponentContext > const &context)
URL aURL
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
unsigned char sal_Bool
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * framework_UriAbbreviation_get_implementation(css::uno::XComponentContext *context, css::uno::Sequence< css::uno::Any > const &)