xref: /aoo41x/main/sw/source/ui/shells/listsh.cxx (revision 69a74367)
1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3efeef26fSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5efeef26fSAndrew Rist  * distributed with this work for additional information
6efeef26fSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7efeef26fSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist  * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist  * with the License.  You may obtain a copy of the License at
10efeef26fSAndrew Rist  *
11efeef26fSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist  *
13efeef26fSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist  * software distributed under the License is distributed on an
15efeef26fSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist  * KIND, either express or implied.  See the License for the
17efeef26fSAndrew Rist  * specific language governing permissions and limitations
18efeef26fSAndrew Rist  * under the License.
19efeef26fSAndrew Rist  *
20efeef26fSAndrew Rist  *************************************************************/
21efeef26fSAndrew Rist 
22efeef26fSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir #include "cmdid.h"
29cdf0e10cSrcweir #include "hintids.hxx"
30cdf0e10cSrcweir #include <editeng/sizeitem.hxx>
31cdf0e10cSrcweir #include <editeng/brshitem.hxx>
32cdf0e10cSrcweir #include <sfx2/app.hxx>
33cdf0e10cSrcweir #include <sfx2/request.hxx>
34cdf0e10cSrcweir #include <sfx2/objface.hxx>
35cdf0e10cSrcweir #include <sfx2/bindings.hxx>
36cdf0e10cSrcweir #include <svl/stritem.hxx>
37cdf0e10cSrcweir #include <svl/eitem.hxx>
38cdf0e10cSrcweir #include <tools/urlobj.hxx>
39cdf0e10cSrcweir #include <svl/whiter.hxx>
40cdf0e10cSrcweir #include <svl/intitem.hxx>
41cdf0e10cSrcweir #include <tools/shl.hxx>
42cdf0e10cSrcweir #include <svl/srchitem.hxx>
43cdf0e10cSrcweir 
44cdf0e10cSrcweir // --> FME 2005-01-04 #i35572#
45cdf0e10cSrcweir #include <numrule.hxx>
46cdf0e10cSrcweir // <--
47cdf0e10cSrcweir #include <fmtornt.hxx>
48cdf0e10cSrcweir #include "wrtsh.hxx"
49cdf0e10cSrcweir #include "swmodule.hxx"
50cdf0e10cSrcweir #include "frmatr.hxx"
51cdf0e10cSrcweir #include "helpid.h"
52cdf0e10cSrcweir #include "globals.hrc"
53cdf0e10cSrcweir #include "shells.hrc"
54cdf0e10cSrcweir #include "uinums.hxx"
55cdf0e10cSrcweir #include "listsh.hxx"
56cdf0e10cSrcweir #include "poolfmt.hxx"
57cdf0e10cSrcweir #include "view.hxx"
58cdf0e10cSrcweir #include "edtwin.hxx"
59cdf0e10cSrcweir 
60cdf0e10cSrcweir #define SwListShell
61cdf0e10cSrcweir #include <sfx2/msg.hxx>
62cdf0e10cSrcweir #include "swslots.hxx"
63cdf0e10cSrcweir 
64cdf0e10cSrcweir #include <IDocumentOutlineNodes.hxx>
65cdf0e10cSrcweir 
SFX_IMPL_INTERFACE(SwListShell,SwBaseShell,SW_RES (STR_SHELLNAME_LIST))66cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwListShell, SwBaseShell, SW_RES(STR_SHELLNAME_LIST))
67cdf0e10cSrcweir {
68cdf0e10cSrcweir 	SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX));
69cdf0e10cSrcweir }
70cdf0e10cSrcweir 
71cdf0e10cSrcweir 
TYPEINIT1(SwListShell,SwBaseShell)72cdf0e10cSrcweir TYPEINIT1(SwListShell,SwBaseShell)
73cdf0e10cSrcweir 
74cdf0e10cSrcweir // --> FME 2005-01-04 #i35572# Functionality of Numbering/Bullet toolbar
75cdf0e10cSrcweir // for outline numbered paragraphs should match the functions for outlines
76cdf0e10cSrcweir // available in the navigator. Therefore the code in the following
77cdf0e10cSrcweir // function is quite similar the the code in SwContentTree::ExecCommand.
78cdf0e10cSrcweir void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp )
79cdf0e10cSrcweir {
80cdf0e10cSrcweir     const sal_uInt16 nActPos = rSh.GetOutlinePos();
81cdf0e10cSrcweir     if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) )
82cdf0e10cSrcweir     {
83cdf0e10cSrcweir         rSh.Push();
84cdf0e10cSrcweir         rSh.MakeOutlineSel( nActPos, nActPos, sal_True );
85cdf0e10cSrcweir 
86cdf0e10cSrcweir         if ( bMove )
87cdf0e10cSrcweir         {
88cdf0e10cSrcweir             const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() );
89cdf0e10cSrcweir             const sal_uInt16 nActLevel = static_cast<sal_uInt16>(pIDoc->getOutlineLevel( nActPos ));
90cdf0e10cSrcweir             sal_uInt16 nActEndPos = nActPos + 1;
91cdf0e10cSrcweir             sal_Int16 nDir = 0;
92cdf0e10cSrcweir 
93cdf0e10cSrcweir             if ( !bUp )
94cdf0e10cSrcweir             {
95cdf0e10cSrcweir                 // Move down with subpoints:
96cdf0e10cSrcweir                 while ( nActEndPos < pIDoc->getOutlineNodesCount() &&
97cdf0e10cSrcweir                         pIDoc->getOutlineLevel( nActEndPos ) > nActLevel )
98cdf0e10cSrcweir                     ++nActEndPos;
99cdf0e10cSrcweir 
100cdf0e10cSrcweir                 if ( nActEndPos < pIDoc->getOutlineNodesCount() )
101cdf0e10cSrcweir                 {
102cdf0e10cSrcweir                     // The current subpoint which should be moved
103cdf0e10cSrcweir                     // starts at nActPos and ends at nActEndPos - 1
104cdf0e10cSrcweir                     --nActEndPos;
105cdf0e10cSrcweir                     sal_uInt16 nDest = nActEndPos + 2;
106cdf0e10cSrcweir                     while ( nDest < pIDoc->getOutlineNodesCount() &&
107cdf0e10cSrcweir                             pIDoc->getOutlineLevel( nDest ) > nActLevel )
108cdf0e10cSrcweir                         ++nDest;
109cdf0e10cSrcweir 
110cdf0e10cSrcweir                     nDir = nDest - 1 - nActEndPos;
111cdf0e10cSrcweir                 }
112cdf0e10cSrcweir             }
113cdf0e10cSrcweir             else
114cdf0e10cSrcweir             {
115cdf0e10cSrcweir                 // Move up with subpoints:
116cdf0e10cSrcweir                 if ( nActPos > 0 )
117cdf0e10cSrcweir                 {
118cdf0e10cSrcweir                     --nActEndPos;
119cdf0e10cSrcweir                     sal_uInt16 nDest = nActPos - 1;
120cdf0e10cSrcweir                     while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel )
121cdf0e10cSrcweir                         --nDest;
122cdf0e10cSrcweir 
123cdf0e10cSrcweir                     nDir = nDest - nActPos;
124cdf0e10cSrcweir                 }
125cdf0e10cSrcweir             }
126cdf0e10cSrcweir 
127cdf0e10cSrcweir             if ( nDir )
128cdf0e10cSrcweir             {
129cdf0e10cSrcweir                 rSh.MoveOutlinePara( nDir );
130cdf0e10cSrcweir                 rSh.GotoOutline( nActPos + nDir );
131cdf0e10cSrcweir             }
132cdf0e10cSrcweir         }
133cdf0e10cSrcweir         else
134cdf0e10cSrcweir         {
135cdf0e10cSrcweir             // Up/down with subpoints:
136cdf0e10cSrcweir             rSh.OutlineUpDown( bUp ? -1 : 1 );
137cdf0e10cSrcweir         }
138cdf0e10cSrcweir 
139cdf0e10cSrcweir         rSh.ClearMark();
140cdf0e10cSrcweir         rSh.Pop( sal_False );
141cdf0e10cSrcweir     }
142cdf0e10cSrcweir }
143cdf0e10cSrcweir // <--
144cdf0e10cSrcweir 
Execute(SfxRequest & rReq)145cdf0e10cSrcweir void SwListShell::Execute(SfxRequest &rReq)
146cdf0e10cSrcweir {
147cdf0e10cSrcweir 	const SfxItemSet* pArgs = rReq.GetArgs();
148cdf0e10cSrcweir 	sal_uInt16 nSlot = rReq.GetSlot();
149cdf0e10cSrcweir 	SwWrtShell& rSh = GetShell();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir     // --> FME 2005-01-04 #i35572#
152cdf0e10cSrcweir     const SwNumRule* pCurRule = rSh.GetCurNumRule();
153cdf0e10cSrcweir     ASSERT( pCurRule, "SwListShell::Execute without NumRule" )
154cdf0e10cSrcweir     bool bOutline = pCurRule && pCurRule->IsOutlineRule();
155cdf0e10cSrcweir     // <--
156cdf0e10cSrcweir 
157cdf0e10cSrcweir 	switch (nSlot)
158cdf0e10cSrcweir 	{
159cdf0e10cSrcweir 		case FN_NUM_BULLET_DOWN:
160cdf0e10cSrcweir         case FN_NUM_BULLET_UP:
161cdf0e10cSrcweir             {
162cdf0e10cSrcweir                 SfxViewFrame * pFrame = GetView().GetViewFrame();
163cdf0e10cSrcweir 
164cdf0e10cSrcweir                 rReq.Done();
165cdf0e10cSrcweir                 rSh.NumUpDown( ( nSlot == FN_NUM_BULLET_DOWN )
166cdf0e10cSrcweir                                ? sal_True
167cdf0e10cSrcweir                                : sal_False );
168cdf0e10cSrcweir                 pFrame->GetBindings().Invalidate( SID_TABLE_CELL );	// StatusZeile updaten!
169cdf0e10cSrcweir             }
170cdf0e10cSrcweir 			break;
171cdf0e10cSrcweir 
172cdf0e10cSrcweir 		case FN_NUM_BULLET_NEXT:
173cdf0e10cSrcweir 			rSh.GotoNextNum();
174cdf0e10cSrcweir             rReq.Done();
175cdf0e10cSrcweir 			break;
176cdf0e10cSrcweir 
177cdf0e10cSrcweir 		case FN_NUM_BULLET_NONUM:
178cdf0e10cSrcweir 			rSh.NoNum();
179cdf0e10cSrcweir             rReq.Done();
180cdf0e10cSrcweir 			break;
181cdf0e10cSrcweir 
182cdf0e10cSrcweir 		case FN_NUM_BULLET_OFF:
183cdf0e10cSrcweir         {
184cdf0e10cSrcweir             rReq.Ignore();
185cdf0e10cSrcweir             SfxRequest aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON );
186cdf0e10cSrcweir             aReq.AppendItem( SfxBoolItem( FN_PARAM_1, sal_False ) );
187cdf0e10cSrcweir             aReq.Done();
188cdf0e10cSrcweir 			rSh.DelNumRules();
189cdf0e10cSrcweir 			break;
190cdf0e10cSrcweir         }
191cdf0e10cSrcweir 
192cdf0e10cSrcweir 		case FN_NUM_BULLET_OUTLINE_DOWN:
193cdf0e10cSrcweir             if ( bOutline )
194cdf0e10cSrcweir                 lcl_OutlineUpDownWithSubPoints( rSh, false, false );
195cdf0e10cSrcweir             else
196cdf0e10cSrcweir                 rSh.MoveNumParas(sal_False, sal_False);
197cdf0e10cSrcweir             rReq.Done();
198cdf0e10cSrcweir 			break;
199cdf0e10cSrcweir 
200cdf0e10cSrcweir 		case FN_NUM_BULLET_OUTLINE_MOVEDOWN:
201cdf0e10cSrcweir             if ( bOutline )
202cdf0e10cSrcweir                 lcl_OutlineUpDownWithSubPoints( rSh, true, false );
203cdf0e10cSrcweir             else
204cdf0e10cSrcweir                 rSh.MoveNumParas(sal_True, sal_False);
205cdf0e10cSrcweir             rReq.Done();
206cdf0e10cSrcweir 			break;
207cdf0e10cSrcweir 
208cdf0e10cSrcweir 		case FN_NUM_BULLET_OUTLINE_MOVEUP:
209cdf0e10cSrcweir             if ( bOutline )
210cdf0e10cSrcweir                 lcl_OutlineUpDownWithSubPoints( rSh, true, true );
211cdf0e10cSrcweir             else
212cdf0e10cSrcweir                 rSh.MoveNumParas(sal_True, sal_True);
213cdf0e10cSrcweir             rReq.Done();
214cdf0e10cSrcweir 			break;
215cdf0e10cSrcweir 
216cdf0e10cSrcweir 		case FN_NUM_BULLET_OUTLINE_UP:
217cdf0e10cSrcweir             if ( bOutline )
218cdf0e10cSrcweir                 lcl_OutlineUpDownWithSubPoints( rSh, false, true );
219cdf0e10cSrcweir             else
220cdf0e10cSrcweir                 rSh.MoveNumParas(sal_False, sal_True);
221cdf0e10cSrcweir             rReq.Done();
222cdf0e10cSrcweir 			break;
223cdf0e10cSrcweir 
224cdf0e10cSrcweir 		case FN_NUM_BULLET_PREV:
225cdf0e10cSrcweir 			rSh.GotoPrevNum();
226cdf0e10cSrcweir             rReq.Done();
227cdf0e10cSrcweir 			break;
228cdf0e10cSrcweir 
229cdf0e10cSrcweir 		case FN_NUM_OR_NONUM:
230cdf0e10cSrcweir 		{
231cdf0e10cSrcweir 			sal_Bool bApi = rReq.IsAPI();
232cdf0e10cSrcweir 			sal_Bool bDelete = !rSh.IsNoNum(!bApi);
233cdf0e10cSrcweir 			if(pArgs )
234cdf0e10cSrcweir 				bDelete = ((SfxBoolItem &)pArgs->Get(rReq.GetSlot())).GetValue();
235cdf0e10cSrcweir 			rSh.NumOrNoNum( bDelete, !bApi );
236cdf0e10cSrcweir             rReq.AppendItem( SfxBoolItem( nSlot, bDelete ) );
237cdf0e10cSrcweir             rReq.Done();
238cdf0e10cSrcweir 		}
239cdf0e10cSrcweir 		break;
240cdf0e10cSrcweir 		default:
241cdf0e10cSrcweir 			ASSERT(!this, falscher Dispatcher);
242cdf0e10cSrcweir 			return;
243cdf0e10cSrcweir 	}
244cdf0e10cSrcweir }
245cdf0e10cSrcweir 
246cdf0e10cSrcweir 
GetState(SfxItemSet & rSet)247cdf0e10cSrcweir void SwListShell::GetState(SfxItemSet &rSet)
248cdf0e10cSrcweir {
249cdf0e10cSrcweir 	SfxWhichIter aIter( rSet );
250cdf0e10cSrcweir 	sal_uInt16 nWhich = aIter.FirstWhich();
251cdf0e10cSrcweir     SwWrtShell& rSh = GetShell();
252cdf0e10cSrcweir     sal_uInt8 nCurrentNumLevel = rSh.GetNumLevel();
253cdf0e10cSrcweir 	while ( nWhich )
254cdf0e10cSrcweir 	{
255cdf0e10cSrcweir 		switch( nWhich )
256cdf0e10cSrcweir 		{
257cdf0e10cSrcweir 			case FN_NUM_OR_NONUM:
258cdf0e10cSrcweir 				rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(sal_False)));
259cdf0e10cSrcweir 			break;
260cdf0e10cSrcweir             case FN_NUM_BULLET_OUTLINE_UP:
261cdf0e10cSrcweir             case FN_NUM_BULLET_UP:
262cdf0e10cSrcweir                 if(!nCurrentNumLevel)
263cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
264cdf0e10cSrcweir             break;
265cdf0e10cSrcweir             case FN_NUM_BULLET_OUTLINE_DOWN :
266cdf0e10cSrcweir             {
267cdf0e10cSrcweir                 sal_uInt8 nUpper = 0;
268cdf0e10cSrcweir                 sal_uInt8 nLower = 0;
269cdf0e10cSrcweir                 rSh.GetCurrentOutlineLevels( nUpper, nLower );
270cdf0e10cSrcweir                 if(nLower == (MAXLEVEL - 1))
271cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
272cdf0e10cSrcweir             }
273cdf0e10cSrcweir             break;
274cdf0e10cSrcweir             case FN_NUM_BULLET_DOWN:
275cdf0e10cSrcweir                 if(nCurrentNumLevel == (MAXLEVEL - 1))
276cdf0e10cSrcweir                     rSet.DisableItem(nWhich);
277cdf0e10cSrcweir             break;
278*69a74367SOliver-Rainer Wittmann 
279*69a74367SOliver-Rainer Wittmann             case FN_NUM_BULLET_NONUM:
280*69a74367SOliver-Rainer Wittmann                 if ( rSh.CrsrInsideInputFld() )
281*69a74367SOliver-Rainer Wittmann                 {
282*69a74367SOliver-Rainer Wittmann                     rSet.DisableItem(nWhich);
283*69a74367SOliver-Rainer Wittmann                 }
284*69a74367SOliver-Rainer Wittmann                 break;
285cdf0e10cSrcweir         }
286cdf0e10cSrcweir 		nWhich = aIter.NextWhich();
287cdf0e10cSrcweir 	}
288cdf0e10cSrcweir }
289cdf0e10cSrcweir 
290cdf0e10cSrcweir 
SwListShell(SwView & _rView)291cdf0e10cSrcweir SwListShell::SwListShell(SwView &_rView) :
292cdf0e10cSrcweir     SwBaseShell(_rView)
293cdf0e10cSrcweir {
294cdf0e10cSrcweir 	SetName(String::CreateFromAscii("List"));
295cdf0e10cSrcweir 	SetHelpId(SW_LISTSHELL);
296cdf0e10cSrcweir }
297cdf0e10cSrcweir 
298cdf0e10cSrcweir 
299