Line data Source code
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 : #include "helpid.h"
26 :
27 : #include <sfx2/styfitem.hxx>
28 :
29 : #include "uitool.hxx"
30 : #include "ccoll.hxx"
31 : #include "fmtcol.hxx"
32 : #include "hintids.hxx"
33 : #include "docsh.hxx"
34 : #include "docstyle.hxx"
35 : #include "hints.hxx"
36 :
37 : #include "chrdlg.hrc"
38 : #include <vcl/svapp.hxx>
39 :
40 : #include <unomid.h>
41 :
42 : // ******************************************************************
43 :
44 : //!! order of entries has to be the same as in
45 : //!! CommandStruct SwCondCollItem::aCmds[]
46 :
47 : const char *aCommandContext[COND_COMMAND_COUNT] =
48 : {
49 : "TableHeader",
50 : "Table",
51 : "Frame",
52 : "Section",
53 : "Footnote",
54 : "Endnote",
55 : "Header",
56 : "Footer",
57 : "OutlineLevel1",
58 : "OutlineLevel2",
59 : "OutlineLevel3",
60 : "OutlineLevel4",
61 : "OutlineLevel5",
62 : "OutlineLevel6",
63 : "OutlineLevel7",
64 : "OutlineLevel8",
65 : "OutlineLevel9",
66 : "OutlineLevel10",
67 : "NumberingLevel1",
68 : "NumberingLevel2",
69 : "NumberingLevel3",
70 : "NumberingLevel4",
71 : "NumberingLevel5",
72 : "NumberingLevel6",
73 : "NumberingLevel7",
74 : "NumberingLevel8",
75 : "NumberingLevel9",
76 : "NumberingLevel10"
77 : };
78 :
79 0 : sal_Int16 GetCommandContextIndex( const OUString &rContextName )
80 : {
81 0 : sal_Int16 nRes = -1;
82 0 : for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
83 : {
84 0 : if (rContextName.equalsAscii( aCommandContext[i] ))
85 0 : nRes = i;
86 : }
87 0 : return nRes;
88 : }
89 :
90 0 : OUString GetCommandContextByIndex( sal_Int16 nIndex )
91 : {
92 0 : OUString aRes;
93 0 : if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
94 : {
95 0 : aRes = OUString::createFromAscii( aCommandContext[ nIndex ] );
96 : }
97 0 : return aRes;
98 : }
99 :
100 : // Globals ******************************************************************
101 :
102 : const CommandStruct SwCondCollItem::aCmds[] =
103 : {
104 : { PARA_IN_TABLEHEAD, 0 },
105 : { PARA_IN_TABLEBODY, 0 },
106 : { PARA_IN_FRAME, 0 },
107 : { PARA_IN_SECTION, 0 },
108 : { PARA_IN_FOOTENOTE, 0 },
109 : { PARA_IN_ENDNOTE, 0 },
110 : { PARA_IN_HEADER, 0 },
111 : { PARA_IN_FOOTER, 0 },
112 : { PARA_IN_OUTLINE, 0 },
113 : { PARA_IN_OUTLINE, 1 },
114 : { PARA_IN_OUTLINE, 2 },
115 : { PARA_IN_OUTLINE, 3 },
116 : { PARA_IN_OUTLINE, 4 },
117 : { PARA_IN_OUTLINE, 5 },
118 : { PARA_IN_OUTLINE, 6 },
119 : { PARA_IN_OUTLINE, 7 },
120 : { PARA_IN_OUTLINE, 8 },
121 : { PARA_IN_OUTLINE, 9 },
122 : { PARA_IN_LIST, 0 },
123 : { PARA_IN_LIST, 1 },
124 : { PARA_IN_LIST, 2 },
125 : { PARA_IN_LIST, 3 },
126 : { PARA_IN_LIST, 4 },
127 : { PARA_IN_LIST, 5 },
128 : { PARA_IN_LIST, 6 },
129 : { PARA_IN_LIST, 7 },
130 : { PARA_IN_LIST, 8 },
131 : { PARA_IN_LIST, 9 }
132 : };
133 :
134 0 : TYPEINIT1_AUTOFACTORY(SwCondCollItem, SfxPoolItem)
135 :
136 : /****************************************************************************
137 : Item for the transport of the condition table
138 : ****************************************************************************/
139 :
140 0 : SwCondCollItem::SwCondCollItem(sal_uInt16 _nWhich ) :
141 0 : SfxPoolItem(_nWhich)
142 : {
143 :
144 0 : }
145 :
146 0 : SwCondCollItem::~SwCondCollItem()
147 : {
148 0 : }
149 :
150 0 : SfxPoolItem* SwCondCollItem::Clone( SfxItemPool * /*pPool*/ ) const
151 : {
152 0 : return new SwCondCollItem(*this);
153 : }
154 :
155 0 : bool SwCondCollItem::operator==( const SfxPoolItem& rItem) const
156 : {
157 : OSL_ENSURE( SfxPoolItem::operator==(rItem), "different types" );
158 0 : sal_Bool bReturn = sal_True;
159 0 : for(sal_uInt16 i = 0; i < COND_COMMAND_COUNT; i++)
160 0 : if (m_sStyles[i] !=
161 0 : static_cast<SwCondCollItem const&>(rItem).m_sStyles[i])
162 : {
163 0 : bReturn = sal_False;
164 0 : break;
165 : }
166 :
167 0 : return bReturn;
168 : }
169 :
170 0 : OUString SwCondCollItem::GetStyle(sal_uInt16 const nPos) const
171 : {
172 0 : return (nPos < COND_COMMAND_COUNT) ? m_sStyles[nPos] : OUString();
173 : }
174 :
175 : void
176 0 : SwCondCollItem::SetStyle(OUString const*const pStyle, sal_uInt16 const nPos)
177 : {
178 0 : if( nPos < COND_COMMAND_COUNT )
179 0 : m_sStyles[nPos] = (pStyle) ? *pStyle : OUString();
180 0 : }
181 :
182 0 : const CommandStruct* SwCondCollItem::GetCmds()
183 : {
184 0 : return aCmds;
185 0 : }
186 :
187 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|