LibreOffice Module unotools (master)
1
unotools
source
config
defaultoptions.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
20
#include <
sal/config.h
>
21
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>
28
29
namespace
SvtDefaultOptions
30
{
31
32
OUString
GetDefaultPath
(
SvtPathOptions::Paths
nId )
33
{
34
SvtPathOptions
aPathOpt;
35
auto
seqToPath = [&aPathOpt] (
const
css::uno::Sequence<OUString> & rSeq)
36
{
37
// single paths
38
sal_Int32
nCount
= rSeq.getLength();
39
OUStringBuffer aFullPathBuf(
nCount
* 40);
40
for
( sal_Int32 nPosition = 0; nPosition <
nCount
; ++nPosition )
41
{
42
aFullPathBuf.append(aPathOpt.
SubstituteVariable
( rSeq[ nPosition ] ));
43
if
( nPosition <
nCount
-1 )
44
aFullPathBuf.append(
";"
);
45
}
46
return
aFullPathBuf.makeStringAndClear();
47
};
48
49
OUString aRet;
50
switch
(
nId
)
51
{
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
);
98
}
99
100
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
)
106
{
107
OUString aTmp;
108
osl::FileBase::getFileURLFromSystemPath( aRet, aTmp );
109
aRet = aTmp;
110
}
111
112
return
aRet;
113
}
114
115
}
// namespace
116
117
118
119
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvtPathOptions
Definition:
pathoptions.hxx:35
SvtPathOptions::SubstituteVariable
OUString SubstituteVariable(const OUString &rVar) const
Definition:
pathoptions.cxx:592
SvtPathOptions::Paths
Paths
Definition:
pathoptions.hxx:42
SvtPathOptions::Paths::Work
@ Work
SvtPathOptions::Paths::AddIn
@ AddIn
SvtPathOptions::Paths::Template
@ Template
SvtPathOptions::Paths::Palette
@ Palette
SvtPathOptions::Paths::Linguistic
@ Linguistic
SvtPathOptions::Paths::Backup
@ Backup
SvtPathOptions::Paths::Dictionary
@ Dictionary
SvtPathOptions::Paths::Plugin
@ Plugin
SvtPathOptions::Paths::UserConfig
@ UserConfig
SvtPathOptions::Paths::Gallery
@ Gallery
SvtPathOptions::Paths::Classification
@ Classification
SvtPathOptions::Paths::Help
@ Help
SvtPathOptions::Paths::Bitmap
@ Bitmap
SvtPathOptions::Paths::Basic
@ Basic
SvtPathOptions::Paths::Temp
@ Temp
SvtPathOptions::Paths::Graphic
@ Graphic
SvtPathOptions::Paths::AutoText
@ AutoText
SvtPathOptions::Paths::Filter
@ Filter
SvtPathOptions::Paths::Favorites
@ Favorites
SvtPathOptions::Paths::AutoCorrect
@ AutoCorrect
SvtPathOptions::Paths::Module
@ Module
SvtPathOptions::Paths::Config
@ Config
config.h
nCount
int nCount
defaultoptions.hxx
SvtDefaultOptions
Definition:
defaultoptions.cxx:30
SvtDefaultOptions::GetDefaultPath
OUString GetDefaultPath(SvtPathOptions::Paths nId)
Definition:
defaultoptions.cxx:32
Translate::get
OUString get(TranslateId sContextAndId, const std::locale &loc)
Definition:
resmgr.cxx:211
nId
sal_Int16 nId
pathoptions.hxx
Generated on Sun Jul 30 2023 04:29:24 for LibreOffice Module unotools (master) by
1.9.3