LibreOffice Module sw (master) 1
ccoll.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 <cmdid.h>
21
22#include <ccoll.hxx>
23#include <fmtcol.hxx>
24#include <o3tl/string_view.hxx>
25
28
29// note: also keep this in sync with the list of conditions in xmloff/source/style/prstylecond.cxx
30
32{
33 "TableHeader",
34 "Table",
35 "Frame",
36 "Section",
37 "Footnote",
38 "Endnote",
39 "Header",
40 "Footer",
41 "OutlineLevel1",
42 "OutlineLevel2",
43 "OutlineLevel3",
44 "OutlineLevel4",
45 "OutlineLevel5",
46 "OutlineLevel6",
47 "OutlineLevel7",
48 "OutlineLevel8",
49 "OutlineLevel9",
50 "OutlineLevel10",
51 "NumberingLevel1",
52 "NumberingLevel2",
53 "NumberingLevel3",
54 "NumberingLevel4",
55 "NumberingLevel5",
56 "NumberingLevel6",
57 "NumberingLevel7",
58 "NumberingLevel8",
59 "NumberingLevel9",
60 "NumberingLevel10"
61};
62
63sal_Int16 GetCommandContextIndex( std::u16string_view rContextName )
64{
65 sal_Int16 nRes = -1;
66 for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
67 {
68 if (o3tl::equalsAscii( rContextName, aCommandContext[i] ))
69 nRes = i;
70 }
71 return nRes;
72}
73
74OUString GetCommandContextByIndex( sal_Int16 nIndex )
75{
76 OUString aRes;
77 if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
78 {
79 aRes = OUString::createFromAscii( aCommandContext[ nIndex ] );
80 }
81 return aRes;
82}
83
84// Globals
85
87{
116};
117
118
119// Item for the transport of the condition table
122{
123}
124
126{
127}
128
130{
131 return new SwCondCollItem(*this);
132}
133
135{
136 assert(SfxPoolItem::operator==(rItem));
137 bool bReturn = true;
138 for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
139 if (m_sStyles[i] !=
140 static_cast<SwCondCollItem const&>(rItem).m_sStyles[i])
141 {
142 bReturn = false;
143 break;
144 }
145
146 return bReturn;
147}
148
149OUString SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
150{
151 return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : OUString();
152}
153
154void
155SwCondCollItem::SetStyle(OUString const*const pStyle, sal_uInt16 const nPos)
156{
158 m_sStyles[nPos] = pStyle ? *pStyle : OUString();
159}
160
161/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString GetCommandContextByIndex(sal_Int16 nIndex)
Definition: ccoll.cxx:74
const char *const aCommandContext[COND_COMMAND_COUNT]
! order of entries has to be the same as in ! CommandStruct SwCondCollItem::aCmds[]
Definition: ccoll.cxx:31
sal_Int16 GetCommandContextIndex(std::u16string_view rContextName)
Definition: ccoll.cxx:63
#define COND_COMMAND_COUNT
Definition: ccoll.hxx:29
static const CommandStruct s_aCmds[COND_COMMAND_COUNT]
Definition: ccoll.hxx:42
virtual ~SwCondCollItem() override
Definition: ccoll.cxx:125
OUString GetStyle(sal_uInt16 nPos) const
Definition: ccoll.cxx:149
void SetStyle(const OUString *pStyle, sal_uInt16 nPos)
Definition: ccoll.cxx:155
OUString m_sStyles[COND_COMMAND_COUNT]
Definition: ccoll.hxx:44
virtual bool operator==(const SfxPoolItem &) const override
Definition: ccoll.cxx:134
virtual SwCondCollItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: ccoll.cxx:129
#define FN_COND_COLL
Definition: cmdid.h:828
sal_Int32 nIndex
sal_uInt16 nPos
int i
bool equalsAscii(std::u16string_view s1, const char *s2)