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