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 #include <swmodule.hxx>
22 #include <view.hxx>
23 #include <wrtsh.hxx>
24 #include <globals.hrc>
25 
26 #include <sfx2/styfitem.hxx>
27 
28 #include <uitool.hxx>
29 #include <ccoll.hxx>
30 #include <fmtcol.hxx>
31 #include <hintids.hxx>
32 #include <docsh.hxx>
33 #include <docstyle.hxx>
34 #include <hints.hxx>
35 
36 #include <vcl/svapp.hxx>
37 
38 #include <unomid.h>
39 
42 
43 // note: also keep this in sync with the list of conditions in xmloff/source/style/prstylecond.cxx
44 
45 const char * const aCommandContext[COND_COMMAND_COUNT] =
46 {
47  "TableHeader",
48  "Table",
49  "Frame",
50  "Section",
51  "Footnote",
52  "Endnote",
53  "Header",
54  "Footer",
55  "OutlineLevel1",
56  "OutlineLevel2",
57  "OutlineLevel3",
58  "OutlineLevel4",
59  "OutlineLevel5",
60  "OutlineLevel6",
61  "OutlineLevel7",
62  "OutlineLevel8",
63  "OutlineLevel9",
64  "OutlineLevel10",
65  "NumberingLevel1",
66  "NumberingLevel2",
67  "NumberingLevel3",
68  "NumberingLevel4",
69  "NumberingLevel5",
70  "NumberingLevel6",
71  "NumberingLevel7",
72  "NumberingLevel8",
73  "NumberingLevel9",
74  "NumberingLevel10"
75 };
76 
77 sal_Int16 GetCommandContextIndex( const OUString &rContextName )
78 {
79  sal_Int16 nRes = -1;
80  for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
81  {
82  if (rContextName.equalsAscii( aCommandContext[i] ))
83  nRes = i;
84  }
85  return nRes;
86 }
87 
88 OUString GetCommandContextByIndex( sal_Int16 nIndex )
89 {
90  OUString aRes;
91  if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
92  {
93  aRes = OUString::createFromAscii( aCommandContext[ nIndex ] );
94  }
95  return aRes;
96 }
97 
98 // Globals
99 
101 {
130 };
131 
132 
133 // Item for the transport of the condition table
136 {
137 }
138 
140 {
141 }
142 
144 {
145  return new SwCondCollItem(*this);
146 }
147 
148 bool SwCondCollItem::operator==( const SfxPoolItem& rItem) const
149 {
150  assert(SfxPoolItem::operator==(rItem));
151  bool bReturn = true;
152  for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
153  if (m_sStyles[i] !=
154  static_cast<SwCondCollItem const&>(rItem).m_sStyles[i])
155  {
156  bReturn = false;
157  break;
158  }
159 
160  return bReturn;
161 }
162 
163 OUString SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
164 {
165  return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : OUString();
166 }
167 
168 void
169 SwCondCollItem::SetStyle(OUString const*const pStyle, sal_uInt16 const nPos)
170 {
171  if( nPos < COND_COMMAND_COUNT )
172  m_sStyles[nPos] = pStyle ? *pStyle : OUString();
173 }
174 
175 /* 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:771
virtual bool operator==(const SfxPoolItem &) const override
Definition: ccoll.cxx:148
const char *const aCommandContext[COND_COMMAND_COUNT]
! order of entries has to be the same as in ! CommandStruct SwCondCollItem::aCmds[] ...
Definition: ccoll.cxx:45
OUString GetCommandContextByIndex(sal_Int16 nIndex)
Definition: ccoll.cxx:88
int i
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const override
Definition: ccoll.cxx:143
#define COND_COMMAND_COUNT
Definition: ccoll.hxx:29
OUString m_sStyles[COND_COMMAND_COUNT]
Definition: ccoll.hxx:44
virtual ~SwCondCollItem() override
Definition: ccoll.cxx:139
sal_Int16 GetCommandContextIndex(const OUString &rContextName)
Definition: ccoll.cxx:77
OUString GetStyle(sal_uInt16 nPos) const
Definition: ccoll.cxx:163
void SetStyle(const OUString *pStyle, sal_uInt16 nPos)
Definition: ccoll.cxx:169