LibreOffice Module sc (master) 1
defaultsoptions.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
10#include <com/sun/star/uno/Sequence.hxx>
11#include <osl/diagnose.h>
12
13#include <defaultsoptions.hxx>
14#include <globstr.hrc>
15#include <scresid.hxx>
16#include <sc.hrc>
17#include <utility>
18
19using namespace utl;
20using namespace com::sun::star::uno;
21
22
24{
26}
27
29{
30 nInitTabCount = 1;
31 aInitTabPrefix = ScResId(STR_TABLE_DEF); // Default Prefix "Sheet"
32 bJumboSheets = false;
33}
34
36{
37 return rOpt.nInitTabCount == nInitTabCount
39 && rOpt.bJumboSheets == bJumboSheets;
40}
41
43 SfxPoolItem ( SID_SCDEFAULTSOPTIONS ),
44 theOptions (std::move( aOpt ))
45{
46}
47
49{
50}
51
52bool ScTpDefaultsItem::operator==( const SfxPoolItem& rItem ) const
53{
54 assert(SfxPoolItem::operator==(rItem));
55
56 const ScTpDefaultsItem& rPItem = static_cast<const ScTpDefaultsItem&>(rItem);
57 return ( theOptions == rPItem.theOptions );
58}
59
61{
62 return new ScTpDefaultsItem( *this );
63}
64
65constexpr OUStringLiteral CFGPATH_FORMULA = u"Office.Calc/Defaults";
66
67#define SCDEFAULTSOPT_TAB_COUNT 0
68#define SCDEFAULTSOPT_TAB_PREFIX 1
69#define SCDEFAULTSOPT_JUMBO_SHEETS 2
70
72{
73 return {"Sheet/SheetCount", // SCDEFAULTSOPT_TAB_COUNT
74 "Sheet/SheetPrefix", // SCDEFAULTSOPT_TAB_PREFIX
75 "Sheet/JumboSheets"}; // SCDEFAULTSOPT_JUMBO_SHEETS
76
77}
78
81{
82 OUString aPrefix;
83
85 Sequence<Any> aValues = GetProperties(aNames);
86 const Any* pValues = aValues.getConstArray();
87 OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
88 if(aValues.getLength() != aNames.getLength())
89 return;
90
91 sal_Int32 nIntVal = 0;
92 for(int nProp = 0; nProp < aNames.getLength(); nProp++)
93 {
94 if(pValues[nProp].hasValue())
95 {
96 switch (nProp)
97 {
99 if (pValues[nProp] >>= nIntVal)
100 SetInitTabCount( static_cast<SCTAB>(nIntVal) );
101 break;
103 if (pValues[nProp] >>= aPrefix)
104 SetInitTabPrefix(aPrefix);
105 break;
107#if HAVE_FEATURE_JUMBO_SHEETS
108 {
109 bool bValue;
110 if (pValues[nProp] >>= bValue)
111 SetInitJumboSheets(bValue);
112 }
113#endif
114 break;
115 }
116 }
117 }
118}
119
121{
123 Sequence<Any> aValues(aNames.getLength());
124 Any* pValues = aValues.getArray();
125
126 for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
127 {
128 switch(nProp)
129 {
131 pValues[nProp] <<= static_cast<sal_Int32>(GetInitTabCount());
132 break;
134 pValues[nProp] <<= GetInitTabPrefix();
135 break;
137 pValues[nProp] <<= GetInitJumboSheets();
138 break;
139 }
140 }
141 PutProperties(aNames, aValues);
142}
143
145{
146 *static_cast<ScDefaultsOptions*>(this) = rNew;
147 SetModified();
148}
149
150void ScDefaultsCfg::Notify( const css::uno::Sequence< OUString >& ) {}
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
static css::uno::Sequence< OUString > GetPropertyNames()
virtual void ImplCommit() override
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
void SetOptions(const ScDefaultsOptions &rNew)
bool GetInitJumboSheets() const
void SetInitTabCount(SCTAB nTabs)
SCTAB GetInitTabCount() const
void SetInitTabPrefix(const OUString &aPrefix)
bool operator==(const ScDefaultsOptions &rOpt) const
const OUString & GetInitTabPrefix() const
virtual bool operator==(const SfxPoolItem &) const override
ScDefaultsOptions theOptions
virtual ScTpDefaultsItem * Clone(SfxItemPool *pPool=nullptr) const override
virtual ~ScTpDefaultsItem() override
ScTpDefaultsItem(ScDefaultsOptions aOpt)
static bool PutProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues, bool bAllLocales)
static css::uno::Sequence< css::uno::Any > GetProperties(css::uno::Reference< css::container::XHierarchicalNameAccess > const &xHierarchyAccess, const css::uno::Sequence< OUString > &rNames, bool bAllLocales)
constexpr OUStringLiteral CFGPATH_FORMULA
#define SCDEFAULTSOPT_TAB_PREFIX
#define SCDEFAULTSOPT_TAB_COUNT
#define SCDEFAULTSOPT_JUMBO_SHEETS
float u
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
sal_Int16 SCTAB
Definition: types.hxx:22