LibreOffice Module sw (master)
1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
sw
source
uibase
config
barcfg.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 <osl/diagnose.h>
21
#include <com/sun/star/uno/Sequence.hxx>
22
#include <
wrtsh.hxx
>
23
#include <
barcfg.hxx
>
24
25
using namespace
utl
;
26
using namespace
com::sun::star::uno
;
27
28
#define SEL_TYPE_TABLE_TEXT 0
29
#define SEL_TYPE_LIST_TEXT 1
30
#define SEL_TYPE_TABLE_LIST 2
31
#define SEL_TYPE_BEZIER 3
32
#define SEL_TYPE_GRAPHIC 4
33
34
SwToolbarConfigItem::SwToolbarConfigItem
(
bool
bWeb ) :
35
ConfigItem
(bWeb ? OUString(
"Office.WriterWeb/ObjectBar"
) : OUString(
"Office.Writer/ObjectBar"
),
36
ConfigItemMode
::
ReleaseTree
)
37
{
38
for
(
int
i
= 0;
i
<=
SEL_TYPE_GRAPHIC
; ++
i
)
39
aTbxIdArray
[
i
] = -1;
40
41
Sequence<OUString>
aNames =
GetPropertyNames
();
42
Sequence<Any>
aValues =
GetProperties
(aNames);
43
const
Any
*
pValues
= aValues.getConstArray();
44
OSL_ENSURE(aValues.getLength() == aNames.getLength(),
"GetProperties failed"
);
45
if
(aValues.getLength() == aNames.getLength())
46
{
47
for
(
int
nProp = 0; nProp < aNames.getLength(); nProp++)
48
{
49
if
(pValues[nProp].hasValue())
50
{
51
sal_Int32 nVal = 0;
52
pValues[nProp] >>= nVal;
53
aTbxIdArray
[nProp] = nVal;
54
}
55
}
56
}
57
}
58
59
SwToolbarConfigItem::~SwToolbarConfigItem
()
60
{
61
}
62
63
static
sal_Int32
lcl_getArrayIndex
(
SelectionType
nSelType)
64
{
65
sal_Int32 nRet = -1;
66
if
(nSelType &
SelectionType::NumberList
)
67
{
68
if
(nSelType &
SelectionType::Table
)
69
nRet =
SEL_TYPE_TABLE_LIST
;
70
else
71
nRet =
SEL_TYPE_LIST_TEXT
;
72
}
73
else
if
(nSelType &
SelectionType::Table
)
74
nRet =
SEL_TYPE_TABLE_TEXT
;
75
else
if
(nSelType &
SelectionType::Ornament
)
76
nRet =
SEL_TYPE_BEZIER
;
77
else
if
(nSelType &
SelectionType::Graphic
)
78
nRet =
SEL_TYPE_GRAPHIC
;
79
return
nRet;
80
}
81
82
void
SwToolbarConfigItem::SetTopToolbar
(
SelectionType
nSelType,
ToolbarId
eBarId)
83
{
84
sal_Int32 nProp =
lcl_getArrayIndex
(nSelType);
85
if
(nProp >= 0)
86
{
87
aTbxIdArray
[nProp] =
static_cast<
sal_Int32
>
(eBarId);
88
SetModified
();
89
}
90
}
91
92
Sequence<OUString>
SwToolbarConfigItem::GetPropertyNames
()
93
{
94
static
const
char
*
aPropNames
[] =
95
{
96
"Selection/Table"
,
// SEL_TYPE_TABLE_TEXT
97
"Selection/NumberedList"
,
// SEL_TYPE_LIST_TEXT
98
"Selection/NumberedList_InTable"
,
// SEL_TYPE_TABLE_LIST
99
"Selection/BezierObject"
,
// SEL_TYPE_BEZIER
100
"Selection/Graphic"
//SEL_TYPE_GRAPHIC
101
};
102
const
int
nCount
= 5;
103
Sequence<OUString>
aNames(nCount);
104
OUString* pNames = aNames.getArray();
105
for
(
int
i
= 0;
i
< nCount;
i
++)
106
pNames[
i
] = OUString::createFromAscii(aPropNames[
i
]);
107
return
aNames;
108
}
109
110
void
SwToolbarConfigItem::ImplCommit
()
111
{
112
Sequence<OUString>
aNames =
GetPropertyNames
();
113
114
Sequence<Any>
aValues(aNames.getLength());
115
Any
*
pValues
= aValues.getArray();
116
117
for
(
int
nProp = 0; nProp < aNames.getLength(); nProp++)
118
pValues[nProp] <<=
aTbxIdArray
[nProp];
119
PutProperties
(aNames, aValues);
120
}
121
122
void
SwToolbarConfigItem::Notify
(
const
css::uno::Sequence< OUString >& ) {}
123
124
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SEL_TYPE_LIST_TEXT
#define SEL_TYPE_LIST_TEXT
Definition:
barcfg.cxx:29
SwToolbarConfigItem::SetTopToolbar
void SetTopToolbar(SelectionType nSelType, ToolbarId eBarId)
Definition:
barcfg.cxx:82
SwToolbarConfigItem::aTbxIdArray
sal_Int32 aTbxIdArray[5]
Definition:
barcfg.hxx:29
ConfigItemMode
ConfigItemMode
utl::ConfigItem::SetModified
void SetModified()
SelectionType::Graphic
SwToolbarConfigItem::SwToolbarConfigItem
SwToolbarConfigItem(bool bWeb)
Definition:
barcfg.cxx:34
com::sun::star::uno
SelectionType::Ornament
SwToolbarConfigItem::GetPropertyNames
static css::uno::Sequence< OUString > GetPropertyNames()
Definition:
barcfg.cxx:92
Sequence< OUString >
SEL_TYPE_BEZIER
#define SEL_TYPE_BEZIER
Definition:
barcfg.cxx:31
nCount
int nCount
SelectionType::NumberList
i
int i
utl::ConfigItem::PutProperties
bool PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
RedlineType::Any
utl
SwToolbarConfigItem::Notify
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames) override
Definition:
barcfg.cxx:122
wrtsh.hxx
utl::ConfigItem::GetProperties
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
aPropNames
const PropertyStruct aPropNames[]
SEL_TYPE_TABLE_TEXT
#define SEL_TYPE_TABLE_TEXT
Definition:
barcfg.cxx:28
SelectionType
SelectionType
Definition:
wrtsh.hxx:58
ConfigItemMode::ReleaseTree
pValues
const PropertyValue * pValues
utl::ConfigItem
ToolbarId
ToolbarId
SEL_TYPE_TABLE_LIST
#define SEL_TYPE_TABLE_LIST
Definition:
barcfg.cxx:30
SEL_TYPE_GRAPHIC
#define SEL_TYPE_GRAPHIC
Definition:
barcfg.cxx:32
barcfg.hxx
lcl_getArrayIndex
static sal_Int32 lcl_getArrayIndex(SelectionType nSelType)
Definition:
barcfg.cxx:63
SwToolbarConfigItem::~SwToolbarConfigItem
virtual ~SwToolbarConfigItem() override
Definition:
barcfg.cxx:59
SwToolbarConfigItem::ImplCommit
virtual void ImplCommit() override
Definition:
barcfg.cxx:110
SelectionType::Table
Generated on Thu Jan 14 2021 06:10:59 for LibreOffice Module sw (master) by
1.8.10