Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / unotools / source / config / defaultoptions.cxx
blob127cc685801d3cafe24dffa581b04a7689c93e65
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 <sal/config.h>
22 #include <osl/file.hxx>
23 #include <unotools/defaultoptions.hxx>
24 #include <unotools/pathoptions.hxx>
25 #include <com/sun/star/uno/Sequence.hxx>
26 #include <rtl/ustrbuf.hxx>
27 #include <officecfg/Office/Common.hxx>
29 namespace SvtDefaultOptions
32 OUString GetDefaultPath( SvtPathOptions::Paths nId )
34 SvtPathOptions aPathOpt;
35 auto seqToPath = [&aPathOpt] (const css::uno::Sequence<OUString> & rSeq)
37 // single paths
38 sal_Int32 nCount = rSeq.getLength();
39 OUStringBuffer aFullPathBuf(nCount * 40);
40 for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
42 aFullPathBuf.append(aPathOpt.SubstituteVariable( rSeq[ nPosition ] ));
43 if ( nPosition < nCount-1 )
44 aFullPathBuf.append(";");
46 return aFullPathBuf.makeStringAndClear();
49 OUString aRet;
50 switch (nId)
52 case SvtPathOptions::Paths::AddIn:
53 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Addin::get()); break;
54 case SvtPathOptions::Paths::AutoCorrect:
55 aRet = seqToPath(officecfg::Office::Common::Path::Default::AutoCorrect::get()); break;
56 case SvtPathOptions::Paths::AutoText:
57 aRet = seqToPath(officecfg::Office::Common::Path::Default::AutoText::get()); break;
58 case SvtPathOptions::Paths::Backup:
59 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Backup::get()); break;
60 case SvtPathOptions::Paths::Basic:
61 aRet = seqToPath(officecfg::Office::Common::Path::Default::Basic::get()); break;
62 case SvtPathOptions::Paths::Bitmap:
63 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Bitmap::get()); break;
64 case SvtPathOptions::Paths::Config:
65 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Config::get()); break;
66 case SvtPathOptions::Paths::Dictionary:
67 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Dictionary::get()); break;
68 case SvtPathOptions::Paths::Favorites:
69 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Favorite::get()); break;
70 case SvtPathOptions::Paths::Filter:
71 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Filter::get()); break;
72 case SvtPathOptions::Paths::Gallery:
73 aRet = seqToPath(officecfg::Office::Common::Path::Default::Gallery::get()); break;
74 case SvtPathOptions::Paths::Graphic:
75 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Graphic::get()); break;
76 case SvtPathOptions::Paths::Help:
77 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Help::get()); break;
78 case SvtPathOptions::Paths::Linguistic:
79 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Linguistic::get()); break;
80 case SvtPathOptions::Paths::Module:
81 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Module::get()); break;
82 case SvtPathOptions::Paths::Palette:
83 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Palette::get()); break;
84 case SvtPathOptions::Paths::Plugin:
85 aRet = seqToPath(officecfg::Office::Common::Path::Default::Plugin::get()); break;
86 case SvtPathOptions::Paths::Temp:
87 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Temp::get()); break;
88 case SvtPathOptions::Paths::Template:
89 aRet = seqToPath(officecfg::Office::Common::Path::Default::Template::get()); break;
90 case SvtPathOptions::Paths::UserConfig:
91 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::UserConfig::get()); break;
92 case SvtPathOptions::Paths::Work:
93 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Work::get()); break;
94 case SvtPathOptions::Paths::Classification:
95 aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Classification::get()); break;
96 default:
97 assert(false);
101 if ( nId == SvtPathOptions::Paths::AddIn ||
102 nId == SvtPathOptions::Paths::Filter ||
103 nId == SvtPathOptions::Paths::Help ||
104 nId == SvtPathOptions::Paths::Module ||
105 nId == SvtPathOptions::Paths::Plugin )
107 OUString aTmp;
108 osl::FileBase::getFileURLFromSystemPath( aRet, aTmp );
109 aRet = aTmp;
112 return aRet;
115 } // namespace
119 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */