1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: listsh.cxx,v $
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 "hintids.hxx"
37 #include <svx/sizeitem.hxx>
38 #include <svx/brshitem.hxx>
39 #include <sfx2/app.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/objface.hxx>
42 #include <sfx2/bindings.hxx>
43 #include <svtools/stritem.hxx>
44 #include <svtools/eitem.hxx>
45 #include <tools/urlobj.hxx>
46 #include <svtools/whiter.hxx>
47 #include <svtools/intitem.hxx>
48 #include <tools/shl.hxx>
49 #include <svx/srchitem.hxx>
51 // --> FME 2005-01-04 #i35572#
52 #include <numrule.hxx>
54 #include <fmtornt.hxx>
56 #include "swmodule.hxx"
59 #include "globals.hrc"
63 #include "poolfmt.hxx"
68 #include <sfx2/msg.hxx>
69 #include "swslots.hxx"
71 #include <IDocumentOutlineNodes.hxx>
73 SFX_IMPL_INTERFACE(SwListShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_LIST
))
75 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_NUM_TOOLBOX
));
79 TYPEINIT1(SwListShell
,SwBaseShell
)
81 // --> FME 2005-01-04 #i35572# Functionality of Numbering/Bullet toolbar
82 // for outline numbered paragraphs should match the functions for outlines
83 // available in the navigator. Therefore the code in the following
84 // function is quite similar the the code in SwContentTree::ExecCommand.
85 void lcl_OutlineUpDownWithSubPoints( SwWrtShell
& rSh
, bool bMove
, bool bUp
)
87 const sal_uInt16 nActPos
= rSh
.GetOutlinePos();
88 if ( nActPos
< USHRT_MAX
&& rSh
.IsOutlineMovable( nActPos
) )
91 rSh
.MakeOutlineSel( nActPos
, nActPos
, TRUE
);
95 const IDocumentOutlineNodes
* pIDoc( rSh
.getIDocumentOutlineNodesAccess() );
96 const sal_uInt16 nActLevel
= static_cast<sal_uInt16
>(pIDoc
->getOutlineLevel( nActPos
));
97 sal_uInt16 nActEndPos
= nActPos
+ 1;
102 // Move down with subpoints:
103 while ( nActEndPos
< pIDoc
->getOutlineNodesCount() &&
104 pIDoc
->getOutlineLevel( nActEndPos
) > nActLevel
)
107 if ( nActEndPos
< pIDoc
->getOutlineNodesCount() )
109 // The current subpoint which should be moved
110 // starts at nActPos and ends at nActEndPos - 1
112 sal_uInt16 nDest
= nActEndPos
+ 2;
113 while ( nDest
< pIDoc
->getOutlineNodesCount() &&
114 pIDoc
->getOutlineLevel( nDest
) > nActLevel
)
117 nDir
= nDest
- 1 - nActEndPos
;
122 // Move up with subpoints:
126 sal_uInt16 nDest
= nActPos
- 1;
127 while ( nDest
> 0 && pIDoc
->getOutlineLevel( nDest
) > nActLevel
)
130 nDir
= nDest
- nActPos
;
136 rSh
.MoveOutlinePara( nDir
);
137 rSh
.GotoOutline( nActPos
+ nDir
);
142 // Up/down with subpoints:
143 rSh
.OutlineUpDown( bUp
? -1 : 1 );
147 rSh
.Pop( sal_False
);
152 void SwListShell::Execute(SfxRequest
&rReq
)
154 const SfxItemSet
* pArgs
= rReq
.GetArgs();
155 USHORT nSlot
= rReq
.GetSlot();
156 SwWrtShell
& rSh
= GetShell();
158 // --> FME 2005-01-04 #i35572#
159 const SwNumRule
* pCurRule
= rSh
.GetCurNumRule();
160 ASSERT( pCurRule
, "SwListShell::Execute without NumRule" )
161 bool bOutline
= pCurRule
&& pCurRule
->IsOutlineRule();
166 case FN_NUM_BULLET_DOWN
:
167 case FN_NUM_BULLET_UP
:
169 SfxViewFrame
* pFrame
= GetView().GetViewFrame();
172 rSh
.NumUpDown( ( nSlot
== FN_NUM_BULLET_DOWN
)
175 pFrame
->GetBindings().Invalidate( SID_TABLE_CELL
); // StatusZeile updaten!
179 case FN_NUM_BULLET_NEXT
:
184 case FN_NUM_BULLET_NONUM
:
189 case FN_NUM_BULLET_OFF
:
192 SfxRequest
aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON
);
193 aReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, FALSE
) );
199 case FN_NUM_BULLET_OUTLINE_DOWN
:
201 lcl_OutlineUpDownWithSubPoints( rSh
, false, false );
203 rSh
.MoveNumParas(FALSE
, FALSE
);
207 case FN_NUM_BULLET_OUTLINE_MOVEDOWN
:
209 lcl_OutlineUpDownWithSubPoints( rSh
, true, false );
211 rSh
.MoveNumParas(TRUE
, FALSE
);
215 case FN_NUM_BULLET_OUTLINE_MOVEUP
:
217 lcl_OutlineUpDownWithSubPoints( rSh
, true, true );
219 rSh
.MoveNumParas(TRUE
, TRUE
);
223 case FN_NUM_BULLET_OUTLINE_UP
:
225 lcl_OutlineUpDownWithSubPoints( rSh
, false, true );
227 rSh
.MoveNumParas(FALSE
, TRUE
);
231 case FN_NUM_BULLET_PREV
:
236 case FN_NUM_OR_NONUM
:
238 BOOL bApi
= rReq
.IsAPI();
239 BOOL bDelete
= !rSh
.IsNoNum(!bApi
);
241 bDelete
= ((SfxBoolItem
&)pArgs
->Get(rReq
.GetSlot())).GetValue();
242 rSh
.NumOrNoNum( bDelete
, !bApi
);
243 rReq
.AppendItem( SfxBoolItem( nSlot
, bDelete
) );
248 ASSERT(!this, falscher Dispatcher
);
254 void SwListShell::GetState(SfxItemSet
&rSet
)
256 SfxWhichIter
aIter( rSet
);
257 USHORT nWhich
= aIter
.FirstWhich();
258 SwWrtShell
& rSh
= GetShell();
259 BYTE nCurrentNumLevel
= rSh
.GetNumLevel();
264 case FN_NUM_OR_NONUM
:
265 rSet
.Put(SfxBoolItem(nWhich
, GetShell().IsNoNum(FALSE
)));
267 case FN_NUM_BULLET_OUTLINE_UP
:
268 case FN_NUM_BULLET_UP
:
269 if(!nCurrentNumLevel
)
270 rSet
.DisableItem(nWhich
);
272 case FN_NUM_BULLET_OUTLINE_DOWN
:
274 sal_uInt8 nUpper
= 0;
275 sal_uInt8 nLower
= 0;
276 rSh
.GetCurrentOutlineLevels( nUpper
, nLower
);
277 if(nLower
== (MAXLEVEL
- 1))
278 rSet
.DisableItem(nWhich
);
281 case FN_NUM_BULLET_DOWN
:
282 if(nCurrentNumLevel
== (MAXLEVEL
- 1))
283 rSet
.DisableItem(nWhich
);
286 nWhich
= aIter
.NextWhich();
291 SwListShell::SwListShell(SwView
&_rView
) :
294 SetName(String::CreateFromAscii("List"));
295 SetHelpId(SW_LISTSHELL
);