Update ooo320-m1
[ooovba.git] / sw / source / ui / chrdlg / ccoll.cxx
blob6045cf87b5779ec045f7ebf4db9b0e72693175f9
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ccoll.cxx,v $
10 * $Revision: 1.15 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
36 #include "cmdid.h"
37 #include <tools/list.hxx>
38 #include "swmodule.hxx"
39 #include "view.hxx"
40 #include "wrtsh.hxx"
41 #include "globals.hrc"
42 #include "helpid.h"
45 #include <sfx2/styfitem.hxx>
47 #include "uitool.hxx"
48 #include "ccoll.hxx"
49 #include "fmtcol.hxx"
50 #include "hintids.hxx"
51 #include "docsh.hxx"
52 #include "docstyle.hxx"
53 #include "hints.hxx"
55 #include "chrdlg.hrc"
56 #include "ccoll.hrc"
57 #include <vcl/svapp.hxx>
59 #include <unomid.h>
61 // ******************************************************************
63 //!! order of entries has to be the same as in
64 //!! CommandStruct SwCondCollItem::aCmds[]
66 const char *aCommandContext[COND_COMMAND_COUNT] =
68 "TableHeader",
69 "Table",
70 "Frame",
71 "Section",
72 "Footnote",
73 "Endnote",
74 "Header",
75 "Footer",
76 "OutlineLevel1",
77 "OutlineLevel2",
78 "OutlineLevel3",
79 "OutlineLevel4",
80 "OutlineLevel5",
81 "OutlineLevel6",
82 "OutlineLevel7",
83 "OutlineLevel8",
84 "OutlineLevel9",
85 "OutlineLevel10",
86 "NumberingLevel1",
87 "NumberingLevel2",
88 "NumberingLevel3",
89 "NumberingLevel4",
90 "NumberingLevel5",
91 "NumberingLevel6",
92 "NumberingLevel7",
93 "NumberingLevel8",
94 "NumberingLevel9",
95 "NumberingLevel10"
98 sal_Int16 GetCommandContextIndex( const rtl::OUString &rContextName )
100 sal_Int16 nRes = -1;
101 for (sal_Int16 i = 0; nRes == -1 && i < COND_COMMAND_COUNT; ++i)
103 if (rContextName.equalsAscii( aCommandContext[i] ))
104 nRes = i;
106 return nRes;
109 rtl::OUString GetCommandContextByIndex( sal_Int16 nIndex )
111 rtl::OUString aRes;
112 if (0 <= nIndex && nIndex < COND_COMMAND_COUNT)
114 aRes = C2U( aCommandContext[ nIndex ] );
116 return aRes;
119 // Globals ******************************************************************
122 CommandStruct SwCondCollItem::aCmds[] =
124 { PARA_IN_TABLEHEAD, 0 },
125 { PARA_IN_TABLEBODY, 0 },
126 { PARA_IN_FRAME, 0 },
127 { PARA_IN_SECTION, 0 },
128 { PARA_IN_FOOTENOTE, 0 },
129 { PARA_IN_ENDNOTE, 0 },
130 { PARA_IN_HEADER, 0 },
131 { PARA_IN_FOOTER, 0 },
132 { PARA_IN_OUTLINE, 0 },
133 { PARA_IN_OUTLINE, 1 },
134 { PARA_IN_OUTLINE, 2 },
135 { PARA_IN_OUTLINE, 3 },
136 { PARA_IN_OUTLINE, 4 },
137 { PARA_IN_OUTLINE, 5 },
138 { PARA_IN_OUTLINE, 6 },
139 { PARA_IN_OUTLINE, 7 },
140 { PARA_IN_OUTLINE, 8 },
141 { PARA_IN_OUTLINE, 9 },
142 { PARA_IN_LIST, 0 },
143 { PARA_IN_LIST, 1 },
144 { PARA_IN_LIST, 2 },
145 { PARA_IN_LIST, 3 },
146 { PARA_IN_LIST, 4 },
147 { PARA_IN_LIST, 5 },
148 { PARA_IN_LIST, 6 },
149 { PARA_IN_LIST, 7 },
150 { PARA_IN_LIST, 8 },
151 { PARA_IN_LIST, 9 }
155 TYPEINIT1_AUTOFACTORY(SwCondCollItem, SfxPoolItem)
157 /****************************************************************************
158 Item fuer den Transport der Bedingungstabelle
159 ****************************************************************************/
162 SwCondCollItem::SwCondCollItem(USHORT _nWhich ) :
163 SfxPoolItem(_nWhich)
167 /****************************************************************************
169 ****************************************************************************/
172 SwCondCollItem::~SwCondCollItem()
176 /****************************************************************************
178 ****************************************************************************/
181 SfxPoolItem* SwCondCollItem::Clone( SfxItemPool * /*pPool*/ ) const
183 return new SwCondCollItem(*this);
186 /****************************************************************************
188 ****************************************************************************/
191 int SwCondCollItem::operator==( const SfxPoolItem& rItem) const
193 DBG_ASSERT( SfxPoolItem::operator==(rItem), "unterschiedliche Typen" );
194 BOOL bReturn = TRUE;
195 for(USHORT i = 0; i < COND_COMMAND_COUNT; i++)
196 if(sStyles[i] != ((SwCondCollItem&)rItem).sStyles[i])
198 bReturn = FALSE;
199 break;
202 return bReturn;
205 /****************************************************************************
207 ****************************************************************************/
210 const String& SwCondCollItem::GetStyle(USHORT nPos) const
212 #ifndef IRIX
213 return nPos < COND_COMMAND_COUNT ? sStyles[nPos] : aEmptyStr;
214 #else
215 return nPos < COND_COMMAND_COUNT ? (String)sStyles[nPos] : aEmptyStr;
216 #endif
219 /****************************************************************************
221 ****************************************************************************/
224 void SwCondCollItem::SetStyle(const String* pStyle, USHORT nPos)
226 if( nPos < COND_COMMAND_COUNT )
227 #ifndef IRIX
228 sStyles[nPos] = pStyle ? *pStyle : aEmptyStr;
229 #else
230 sStyles[nPos] = pStyle ? (String)*pStyle : aEmptyStr;
231 #endif
235 /****************************************************************************
237 ****************************************************************************/
240 const CommandStruct* SwCondCollItem::GetCmds()
242 return aCmds;