Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "cmdid.h"
30 : : #include "hintids.hxx"
31 : : #include <editeng/sizeitem.hxx>
32 : : #include <editeng/brshitem.hxx>
33 : : #include <sfx2/app.hxx>
34 : : #include <sfx2/request.hxx>
35 : : #include <sfx2/objface.hxx>
36 : : #include <sfx2/bindings.hxx>
37 : : #include <svl/stritem.hxx>
38 : : #include <svl/eitem.hxx>
39 : : #include <svl/whiter.hxx>
40 : : #include <svl/intitem.hxx>
41 : : #include <tools/shl.hxx>
42 : : #include <svl/srchitem.hxx>
43 : :
44 : : #include <numrule.hxx>
45 : : #include <fmtornt.hxx>
46 : : #include "wrtsh.hxx"
47 : : #include "swmodule.hxx"
48 : : #include "frmatr.hxx"
49 : : #include "helpid.h"
50 : : #include "globals.hrc"
51 : : #include "shells.hrc"
52 : : #include "uinums.hxx"
53 : : #include "listsh.hxx"
54 : : #include "poolfmt.hxx"
55 : : #include "view.hxx"
56 : : #include "edtwin.hxx"
57 : :
58 : : #define SwListShell
59 : : #include <sfx2/msg.hxx>
60 : : #include "swslots.hxx"
61 : :
62 : : #include <IDocumentOutlineNodes.hxx>
63 : :
64 [ + + ][ + - ]: 334 : SFX_IMPL_INTERFACE(SwListShell, SwBaseShell, SW_RES(STR_SHELLNAME_LIST))
[ + - ][ + - ]
65 : : {
66 [ + - ][ + - ]: 73 : SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX));
67 : 73 : }
68 : :
69 : :
70 [ - + ][ - + ]: 189 : TYPEINIT1(SwListShell,SwBaseShell)
71 : :
72 : : // #i35572# Functionality of Numbering/Bullet toolbar
73 : : // for outline numbered paragraphs should match the functions for outlines
74 : : // available in the navigator. Therefore the code in the following
75 : : // function is quite similar the the code in SwContentTree::ExecCommand.
76 : 0 : void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp )
77 : : {
78 : 0 : const sal_uInt16 nActPos = rSh.GetOutlinePos();
79 [ # # ][ # # ]: 0 : if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) )
[ # # ]
80 : : {
81 : 0 : rSh.Push();
82 : 0 : rSh.MakeOutlineSel( nActPos, nActPos, sal_True );
83 : :
84 [ # # ]: 0 : if ( bMove )
85 : : {
86 : 0 : const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() );
87 : 0 : const sal_uInt16 nActLevel = static_cast<sal_uInt16>(pIDoc->getOutlineLevel( nActPos ));
88 : 0 : sal_uInt16 nActEndPos = nActPos + 1;
89 : 0 : sal_Int16 nDir = 0;
90 : :
91 [ # # ]: 0 : if ( !bUp )
92 : : {
93 : : // Move down with subpoints:
94 [ # # # # ]: 0 : while ( nActEndPos < pIDoc->getOutlineNodesCount() &&
[ # # ]
95 : 0 : pIDoc->getOutlineLevel( nActEndPos ) > nActLevel )
96 : 0 : ++nActEndPos;
97 : :
98 [ # # ]: 0 : if ( nActEndPos < pIDoc->getOutlineNodesCount() )
99 : : {
100 : : // The current subpoint which should be moved
101 : : // starts at nActPos and ends at nActEndPos - 1
102 : 0 : --nActEndPos;
103 : 0 : sal_uInt16 nDest = nActEndPos + 2;
104 [ # # # # ]: 0 : while ( nDest < pIDoc->getOutlineNodesCount() &&
[ # # ]
105 : 0 : pIDoc->getOutlineLevel( nDest ) > nActLevel )
106 : 0 : ++nDest;
107 : :
108 : 0 : nDir = nDest - 1 - nActEndPos;
109 : : }
110 : : }
111 : : else
112 : : {
113 : : // Move up with subpoints:
114 [ # # ]: 0 : if ( nActPos > 0 )
115 : : {
116 : 0 : --nActEndPos;
117 : 0 : sal_uInt16 nDest = nActPos - 1;
118 [ # # ][ # # ]: 0 : while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel )
[ # # ]
119 : 0 : --nDest;
120 : :
121 : 0 : nDir = nDest - nActPos;
122 : : }
123 : : }
124 : :
125 [ # # ]: 0 : if ( nDir )
126 : : {
127 : 0 : rSh.MoveOutlinePara( nDir );
128 : 0 : rSh.GotoOutline( nActPos + nDir );
129 : : }
130 : : }
131 : : else
132 : : {
133 : : // Up/down with subpoints:
134 [ # # ]: 0 : rSh.OutlineUpDown( bUp ? -1 : 1 );
135 : : }
136 : :
137 : 0 : rSh.ClearMark();
138 : 0 : rSh.Pop( sal_False );
139 : : }
140 : 0 : }
141 : :
142 : 0 : void SwListShell::Execute(SfxRequest &rReq)
143 : : {
144 : 0 : const SfxItemSet* pArgs = rReq.GetArgs();
145 : 0 : sal_uInt16 nSlot = rReq.GetSlot();
146 : 0 : SwWrtShell& rSh = GetShell();
147 : :
148 : : // #i35572#
149 : 0 : const SwNumRule* pCurRule = rSh.GetCurNumRule();
150 : : OSL_ENSURE( pCurRule, "SwListShell::Execute without NumRule" );
151 [ # # ][ # # ]: 0 : bool bOutline = pCurRule && pCurRule->IsOutlineRule();
152 : :
153 [ # # # # : 0 : switch (nSlot)
# # # # #
# # ]
154 : : {
155 : : case FN_NUM_BULLET_DOWN:
156 : : case FN_NUM_BULLET_UP:
157 : : {
158 : 0 : SfxViewFrame * pFrame = GetView().GetViewFrame();
159 : :
160 : 0 : rReq.Done();
161 : : rSh.NumUpDown( ( nSlot == FN_NUM_BULLET_DOWN )
162 : : ? sal_True
163 [ # # ]: 0 : : sal_False );
164 : 0 : pFrame->GetBindings().Invalidate( SID_TABLE_CELL ); // StatusZeile updaten!
165 : : }
166 : 0 : break;
167 : :
168 : : case FN_NUM_BULLET_NEXT:
169 : 0 : rSh.GotoNextNum();
170 : 0 : rReq.Done();
171 : 0 : break;
172 : :
173 : : case FN_NUM_BULLET_NONUM:
174 : 0 : rSh.NoNum();
175 : 0 : rReq.Done();
176 : 0 : break;
177 : :
178 : : case FN_NUM_BULLET_OFF:
179 : : {
180 [ # # ]: 0 : rReq.Ignore();
181 [ # # ]: 0 : SfxRequest aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON );
182 [ # # ][ # # ]: 0 : aReq.AppendItem( SfxBoolItem( FN_PARAM_1, sal_False ) );
[ # # ]
183 [ # # ]: 0 : aReq.Done();
184 [ # # ]: 0 : rSh.DelNumRules();
185 [ # # ]: 0 : break;
186 : : }
187 : :
188 : : case FN_NUM_BULLET_OUTLINE_DOWN:
189 [ # # ]: 0 : if ( bOutline )
190 : 0 : lcl_OutlineUpDownWithSubPoints( rSh, false, false );
191 : : else
192 : 0 : rSh.MoveNumParas(sal_False, sal_False);
193 : 0 : rReq.Done();
194 : 0 : break;
195 : :
196 : : case FN_NUM_BULLET_OUTLINE_MOVEDOWN:
197 [ # # ]: 0 : if ( bOutline )
198 : 0 : lcl_OutlineUpDownWithSubPoints( rSh, true, false );
199 : : else
200 : 0 : rSh.MoveNumParas(sal_True, sal_False);
201 : 0 : rReq.Done();
202 : 0 : break;
203 : :
204 : : case FN_NUM_BULLET_OUTLINE_MOVEUP:
205 [ # # ]: 0 : if ( bOutline )
206 : 0 : lcl_OutlineUpDownWithSubPoints( rSh, true, true );
207 : : else
208 : 0 : rSh.MoveNumParas(sal_True, sal_True);
209 : 0 : rReq.Done();
210 : 0 : break;
211 : :
212 : : case FN_NUM_BULLET_OUTLINE_UP:
213 [ # # ]: 0 : if ( bOutline )
214 : 0 : lcl_OutlineUpDownWithSubPoints( rSh, false, true );
215 : : else
216 : 0 : rSh.MoveNumParas(sal_False, sal_True);
217 : 0 : rReq.Done();
218 : 0 : break;
219 : :
220 : : case FN_NUM_BULLET_PREV:
221 : 0 : rSh.GotoPrevNum();
222 : 0 : rReq.Done();
223 : 0 : break;
224 : :
225 : : case FN_NUM_OR_NONUM:
226 : : {
227 : 0 : sal_Bool bApi = rReq.IsAPI();
228 : 0 : sal_Bool bDelete = !rSh.IsNoNum(!bApi);
229 [ # # ]: 0 : if(pArgs )
230 : 0 : bDelete = ((SfxBoolItem &)pArgs->Get(rReq.GetSlot())).GetValue();
231 : 0 : rSh.NumOrNoNum( bDelete, !bApi );
232 [ # # ]: 0 : rReq.AppendItem( SfxBoolItem( nSlot, bDelete ) );
233 : 0 : rReq.Done();
234 : : }
235 : 0 : break;
236 : : default:
237 : : OSL_ENSURE(!this, "wrong dispatcher");
238 : 0 : return;
239 : : }
240 : : }
241 : :
242 : :
243 : 0 : void SwListShell::GetState(SfxItemSet &rSet)
244 : : {
245 [ # # ]: 0 : SfxWhichIter aIter( rSet );
246 [ # # ]: 0 : sal_uInt16 nWhich = aIter.FirstWhich();
247 [ # # ]: 0 : SwWrtShell& rSh = GetShell();
248 [ # # ]: 0 : sal_uInt8 nCurrentNumLevel = rSh.GetNumLevel();
249 [ # # ]: 0 : while ( nWhich )
250 : : {
251 [ # # # # : 0 : switch( nWhich )
# ]
252 : : {
253 : : case FN_NUM_OR_NONUM:
254 [ # # ][ # # ]: 0 : rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(sal_False)));
[ # # ][ # # ]
[ # # ]
255 : 0 : break;
256 : : case FN_NUM_BULLET_OUTLINE_UP:
257 : : case FN_NUM_BULLET_UP:
258 [ # # ]: 0 : if(!nCurrentNumLevel)
259 [ # # ]: 0 : rSet.DisableItem(nWhich);
260 : 0 : break;
261 : : case FN_NUM_BULLET_OUTLINE_DOWN :
262 : : {
263 : 0 : sal_uInt8 nUpper = 0;
264 : 0 : sal_uInt8 nLower = 0;
265 [ # # ]: 0 : rSh.GetCurrentOutlineLevels( nUpper, nLower );
266 [ # # ]: 0 : if(nLower == (MAXLEVEL - 1))
267 [ # # ]: 0 : rSet.DisableItem(nWhich);
268 : : }
269 : 0 : break;
270 : : case FN_NUM_BULLET_DOWN:
271 [ # # ]: 0 : if(nCurrentNumLevel == (MAXLEVEL - 1))
272 [ # # ]: 0 : rSet.DisableItem(nWhich);
273 : 0 : break;
274 : : }
275 [ # # ]: 0 : nWhich = aIter.NextWhich();
276 [ # # ]: 0 : }
277 : 0 : }
278 : :
279 : :
280 : 18 : SwListShell::SwListShell(SwView &_rView) :
281 : 18 : SwBaseShell(_rView)
282 : : {
283 [ + - ][ + - ]: 18 : SetName(rtl::OUString("List"));
[ + - ]
284 [ + - ]: 18 : SetHelpId(SW_LISTSHELL);
285 : 18 : }
286 : :
287 : :
288 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|