Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / sw / source / uibase / chrdlg / ccoll.cxx
blob547566c427a0067d94d6acb66ebdf9f01d206d1a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
20 #include <cmdid.h>
22 #include <ccoll.hxx>
23 #include <fmtcol.hxx>
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] =
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"
63 sal_Int16 GetCommandContextIndex( std::u16string_view rContextName )
65 sal_Int16 nRes = -1;
66 for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
68 if (o3tl::equalsAscii( rContextName, aCommandContext[i] ))
69 nRes = i;
71 return nRes;
74 OUString GetCommandContextByIndex( sal_Int16 nIndex )
76 OUString aRes;
77 if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
79 aRes = OUString::createFromAscii( aCommandContext[ nIndex ] );
81 return aRes;
84 // Globals
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));
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])
142 bReturn = false;
143 break;
146 return bReturn;
149 OUString SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
151 return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : OUString();
154 void
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: */