1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
24 #include <o3tl/string_view.hxx>
26 //!! order of entries has to be the same as in
27 //!! CommandStruct SwCondCollItem::aCmds[]
29 // note: also keep this in sync with the list of conditions in xmloff/source/style/prstylecond.cxx
31 const char * const aCommandContext
[COND_COMMAND_COUNT
] =
63 sal_Int16
GetCommandContextIndex( std::u16string_view rContextName
)
66 for (sal_Int16 i
= 0; nRes
== -1 && i
< COND_COMMAND_COUNT
; ++i
)
68 if (o3tl::equalsAscii( rContextName
, aCommandContext
[i
] ))
74 OUString
GetCommandContextByIndex( sal_Int16 nIndex
)
77 if (0 <= nIndex
&& nIndex
< COND_COMMAND_COUNT
)
79 aRes
= OUString::createFromAscii( aCommandContext
[ nIndex
] );
86 const CommandStruct
SwCondCollItem::s_aCmds
[] =
88 { Master_CollCondition::PARA_IN_TABLEHEAD
, 0 },
89 { Master_CollCondition::PARA_IN_TABLEBODY
, 0 },
90 { Master_CollCondition::PARA_IN_FRAME
, 0 },
91 { Master_CollCondition::PARA_IN_SECTION
, 0 },
92 { Master_CollCondition::PARA_IN_FOOTNOTE
, 0 },
93 { Master_CollCondition::PARA_IN_ENDNOTE
, 0 },
94 { Master_CollCondition::PARA_IN_HEADER
, 0 },
95 { Master_CollCondition::PARA_IN_FOOTER
, 0 },
96 { Master_CollCondition::PARA_IN_OUTLINE
, 0 },
97 { Master_CollCondition::PARA_IN_OUTLINE
, 1 },
98 { Master_CollCondition::PARA_IN_OUTLINE
, 2 },
99 { Master_CollCondition::PARA_IN_OUTLINE
, 3 },
100 { Master_CollCondition::PARA_IN_OUTLINE
, 4 },
101 { Master_CollCondition::PARA_IN_OUTLINE
, 5 },
102 { Master_CollCondition::PARA_IN_OUTLINE
, 6 },
103 { Master_CollCondition::PARA_IN_OUTLINE
, 7 },
104 { Master_CollCondition::PARA_IN_OUTLINE
, 8 },
105 { Master_CollCondition::PARA_IN_OUTLINE
, 9 },
106 { Master_CollCondition::PARA_IN_LIST
, 0 },
107 { Master_CollCondition::PARA_IN_LIST
, 1 },
108 { Master_CollCondition::PARA_IN_LIST
, 2 },
109 { Master_CollCondition::PARA_IN_LIST
, 3 },
110 { Master_CollCondition::PARA_IN_LIST
, 4 },
111 { Master_CollCondition::PARA_IN_LIST
, 5 },
112 { Master_CollCondition::PARA_IN_LIST
, 6 },
113 { Master_CollCondition::PARA_IN_LIST
, 7 },
114 { Master_CollCondition::PARA_IN_LIST
, 8 },
115 { Master_CollCondition::PARA_IN_LIST
, 9 }
119 // Item for the transport of the condition table
120 SwCondCollItem::SwCondCollItem() :
121 SfxPoolItem(FN_COND_COLL
)
125 SwCondCollItem::~SwCondCollItem()
129 SwCondCollItem
* SwCondCollItem::Clone( SfxItemPool
* /*pPool*/ ) const
131 return new SwCondCollItem(*this);
134 bool SwCondCollItem::operator==( const SfxPoolItem
& rItem
) const
136 assert(SfxPoolItem::operator==(rItem
));
138 for(sal_uInt16 i
= 0; i
< COND_COMMAND_COUNT
; i
++)
140 static_cast<SwCondCollItem
const&>(rItem
).m_sStyles
[i
])
149 OUString
SwCondCollItem::GetStyle(sal_uInt16
const nPos
) const
151 return (nPos
< COND_COMMAND_COUNT
) ? m_sStyles
[nPos
] : OUString();
155 SwCondCollItem::SetStyle(OUString
const*const pStyle
, sal_uInt16
const nPos
)
157 if( nPos
< COND_COMMAND_COUNT
)
158 m_sStyles
[nPos
] = pStyle
? *pStyle
: OUString();
161 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */