docthemes: Save themes def. to a file when added to ColorSets
[LibreOffice.git] / sw / source / uibase / chrdlg / ccoll.cxx
blob3bd7ab0b98d661f279d537f59b6873e04b31a9f5
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 constexpr OUString aCommandContext[COND_COMMAND_COUNT] =
33 u"TableHeader"_ustr,
34 u"Table"_ustr,
35 u"Frame"_ustr,
36 u"Section"_ustr,
37 u"Footnote"_ustr,
38 u"Endnote"_ustr,
39 u"Header"_ustr,
40 u"Footer"_ustr,
41 u"OutlineLevel1"_ustr,
42 u"OutlineLevel2"_ustr,
43 u"OutlineLevel3"_ustr,
44 u"OutlineLevel4"_ustr,
45 u"OutlineLevel5"_ustr,
46 u"OutlineLevel6"_ustr,
47 u"OutlineLevel7"_ustr,
48 u"OutlineLevel8"_ustr,
49 u"OutlineLevel9"_ustr,
50 u"OutlineLevel10"_ustr,
51 u"NumberingLevel1"_ustr,
52 u"NumberingLevel2"_ustr,
53 u"NumberingLevel3"_ustr,
54 u"NumberingLevel4"_ustr,
55 u"NumberingLevel5"_ustr,
56 u"NumberingLevel6"_ustr,
57 u"NumberingLevel7"_ustr,
58 u"NumberingLevel8"_ustr,
59 u"NumberingLevel9"_ustr,
60 u"NumberingLevel10"_ustr
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 (aCommandContext[i] == rContextName)
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 = 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: */