blob: 2cdbc263b2be95261638a1ea3a6b04047f3de47c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
/* -*- 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 .
*/
#include <sal/config.h>
#include <osl/file.hxx>
#include <sal/log.hxx>
#include <unotools/defaultoptions.hxx>
#include <unotools/pathoptions.hxx>
#include <tools/debug.hxx>
#include <com/sun/star/uno/Any.hxx>
#include <com/sun/star/uno/Sequence.hxx>
#include <rtl/ustrbuf.hxx>
#include <officecfg/Office/Common.hxx>
namespace SvtDefaultOptions
{
OUString GetDefaultPath( SvtPathOptions::Paths nId )
{
SvtPathOptions aPathOpt;
auto seqToPath = [&aPathOpt] (const css::uno::Sequence<OUString> & rSeq)
{
// single paths
sal_Int32 nCount = rSeq.getLength();
OUStringBuffer aFullPathBuf(nCount * 40);
for ( sal_Int32 nPosition = 0; nPosition < nCount; ++nPosition )
{
aFullPathBuf.append(aPathOpt.SubstituteVariable( rSeq[ nPosition ] ));
if ( nPosition < nCount-1 )
aFullPathBuf.append(";");
}
return aFullPathBuf.makeStringAndClear();
};
OUString aRet;
switch (nId)
{
case SvtPathOptions::Paths::AddIn:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Addin::get()); break;
case SvtPathOptions::Paths::AutoCorrect:
aRet = seqToPath(officecfg::Office::Common::Path::Default::AutoCorrect::get()); break;
case SvtPathOptions::Paths::AutoText:
aRet = seqToPath(officecfg::Office::Common::Path::Default::AutoText::get()); break;
case SvtPathOptions::Paths::Backup:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Backup::get()); break;
case SvtPathOptions::Paths::Basic:
aRet = seqToPath(officecfg::Office::Common::Path::Default::Basic::get()); break;
case SvtPathOptions::Paths::Bitmap:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Bitmap::get()); break;
case SvtPathOptions::Paths::Config:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Config::get()); break;
case SvtPathOptions::Paths::Dictionary:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Dictionary::get()); break;
case SvtPathOptions::Paths::Favorites:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Favorite::get()); break;
case SvtPathOptions::Paths::Filter:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Filter::get()); break;
case SvtPathOptions::Paths::Gallery:
aRet = seqToPath(officecfg::Office::Common::Path::Default::Gallery::get()); break;
case SvtPathOptions::Paths::Graphic:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Graphic::get()); break;
case SvtPathOptions::Paths::Help:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Help::get()); break;
case SvtPathOptions::Paths::Linguistic:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Linguistic::get()); break;
case SvtPathOptions::Paths::Module:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Module::get()); break;
case SvtPathOptions::Paths::Palette:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Palette::get()); break;
case SvtPathOptions::Paths::Plugin:
aRet = seqToPath(officecfg::Office::Common::Path::Default::Plugin::get()); break;
case SvtPathOptions::Paths::Temp:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Temp::get()); break;
case SvtPathOptions::Paths::Template:
aRet = seqToPath(officecfg::Office::Common::Path::Default::Template::get()); break;
case SvtPathOptions::Paths::UserConfig:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::UserConfig::get()); break;
case SvtPathOptions::Paths::Work:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Work::get()); break;
case SvtPathOptions::Paths::Classification:
aRet = aPathOpt.SubstituteVariable(officecfg::Office::Common::Path::Default::Classification::get()); break;
default:
assert(false);
}
if ( nId == SvtPathOptions::Paths::AddIn ||
nId == SvtPathOptions::Paths::Filter ||
nId == SvtPathOptions::Paths::Help ||
nId == SvtPathOptions::Paths::Module ||
nId == SvtPathOptions::Paths::Plugin )
{
OUString aTmp;
osl::FileBase::getFileURLFromSystemPath( aRet, aTmp );
aRet = aTmp;
}
return aRet;
}
} // namespace
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|