Line data Source code
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 :
10 : #include <comphelper/expandmacro.hxx>
11 :
12 : #include <com/sun/star/uno/Reference.hxx>
13 : #include <rtl/ustring.hxx>
14 : #include <rtl/uri.hxx>
15 : #include <rtl/bootstrap.hxx>
16 :
17 : using namespace ::com::sun::star;
18 : using namespace ::com::sun::star::uno;
19 :
20 : namespace comphelper
21 : {
22 0 : rtl::OUString getExpandedFilePath(const rtl::OUString& filepath)
23 : {
24 0 : rtl::OUString aFilename = filepath;
25 :
26 0 : if( aFilename.startsWith( "vnd.sun.star.expand:" ) )
27 : {
28 : // cut protocol
29 0 : rtl::OUString aMacro( aFilename.copy( sizeof ( "vnd.sun.star.expand:" ) -1 ) );
30 :
31 : // decode uric class chars
32 0 : aMacro = rtl::Uri::decode( aMacro, rtl_UriDecodeWithCharset, RTL_TEXTENCODING_UTF8 );
33 :
34 : // expand macro string
35 0 : rtl::Bootstrap::expandMacros( aMacro);
36 :
37 0 : aFilename = aMacro;
38 : }
39 0 : return aFilename;
40 : }
41 : }
|