LCOV - code coverage report
Current view: top level - libreoffice/sw/source/ui/shells - listsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 9 123 7.3 %
Date: 2012-12-27 Functions: 8 13 61.5 %
Legend: Lines: hit not hit

          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 "hintids.hxx"
      22             : #include <editeng/sizeitem.hxx>
      23             : #include <editeng/brshitem.hxx>
      24             : #include <sfx2/app.hxx>
      25             : #include <sfx2/request.hxx>
      26             : #include <sfx2/objface.hxx>
      27             : #include <sfx2/bindings.hxx>
      28             : #include <svl/stritem.hxx>
      29             : #include <svl/eitem.hxx>
      30             : #include <svl/whiter.hxx>
      31             : #include <svl/intitem.hxx>
      32             : #include <tools/shl.hxx>
      33             : #include <svl/srchitem.hxx>
      34             : 
      35             : #include <numrule.hxx>
      36             : #include <fmtornt.hxx>
      37             : #include "wrtsh.hxx"
      38             : #include "swmodule.hxx"
      39             : #include "frmatr.hxx"
      40             : #include "helpid.h"
      41             : #include "globals.hrc"
      42             : #include "shells.hrc"
      43             : #include "uinums.hxx"
      44             : #include "listsh.hxx"
      45             : #include "poolfmt.hxx"
      46             : #include "view.hxx"
      47             : #include "edtwin.hxx"
      48             : 
      49             : #define SwListShell
      50             : #include <sfx2/msg.hxx>
      51             : #include "swslots.hxx"
      52             : 
      53             : #include <IDocumentOutlineNodes.hxx>
      54             : 
      55         160 : SFX_IMPL_INTERFACE(SwListShell, SwBaseShell, SW_RES(STR_SHELLNAME_LIST))
      56             : {
      57          10 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_NUM_TOOLBOX));
      58          10 : }
      59             : 
      60             : 
      61          90 : TYPEINIT1(SwListShell,SwBaseShell)
      62             : 
      63             : // #i35572# Functionality of Numbering/Bullet toolbar
      64             : // for outline numbered paragraphs should match the functions for outlines
      65             : // available in the navigator. Therefore the code in the following
      66             : // function is quite similar the the code in SwContentTree::ExecCommand.
      67           0 : static void lcl_OutlineUpDownWithSubPoints( SwWrtShell& rSh, bool bMove, bool bUp )
      68             : {
      69           0 :     const sal_uInt16 nActPos = rSh.GetOutlinePos();
      70           0 :     if ( nActPos < USHRT_MAX && rSh.IsOutlineMovable( nActPos ) )
      71             :     {
      72           0 :         rSh.Push();
      73           0 :         rSh.MakeOutlineSel( nActPos, nActPos, sal_True );
      74             : 
      75           0 :         if ( bMove )
      76             :         {
      77           0 :             const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() );
      78           0 :             const sal_uInt16 nActLevel = static_cast<sal_uInt16>(pIDoc->getOutlineLevel( nActPos ));
      79           0 :             sal_uInt16 nActEndPos = nActPos + 1;
      80           0 :             sal_Int16 nDir = 0;
      81             : 
      82           0 :             if ( !bUp )
      83             :             {
      84             :                 // Move down with subpoints:
      85           0 :                 while ( nActEndPos < pIDoc->getOutlineNodesCount() &&
      86           0 :                         pIDoc->getOutlineLevel( nActEndPos ) > nActLevel )
      87           0 :                     ++nActEndPos;
      88             : 
      89           0 :                 if ( nActEndPos < pIDoc->getOutlineNodesCount() )
      90             :                 {
      91             :                     // The current subpoint which should be moved
      92             :                     // starts at nActPos and ends at nActEndPos - 1
      93           0 :                     --nActEndPos;
      94           0 :                     sal_uInt16 nDest = nActEndPos + 2;
      95           0 :                     while ( nDest < pIDoc->getOutlineNodesCount() &&
      96           0 :                             pIDoc->getOutlineLevel( nDest ) > nActLevel )
      97           0 :                         ++nDest;
      98             : 
      99           0 :                     nDir = nDest - 1 - nActEndPos;
     100             :                 }
     101             :             }
     102             :             else
     103             :             {
     104             :                 // Move up with subpoints:
     105           0 :                 if ( nActPos > 0 )
     106             :                 {
     107           0 :                     --nActEndPos;
     108           0 :                     sal_uInt16 nDest = nActPos - 1;
     109           0 :                     while ( nDest > 0 && pIDoc->getOutlineLevel( nDest ) > nActLevel )
     110           0 :                         --nDest;
     111             : 
     112           0 :                     nDir = nDest - nActPos;
     113             :                 }
     114             :             }
     115             : 
     116           0 :             if ( nDir )
     117             :             {
     118           0 :                 rSh.MoveOutlinePara( nDir );
     119           0 :                 rSh.GotoOutline( nActPos + nDir );
     120             :             }
     121             :         }
     122             :         else
     123             :         {
     124             :             // Up/down with subpoints:
     125           0 :             rSh.OutlineUpDown( bUp ? -1 : 1 );
     126             :         }
     127             : 
     128           0 :         rSh.ClearMark();
     129           0 :         rSh.Pop( sal_False );
     130             :     }
     131           0 : }
     132             : 
     133           0 : void SwListShell::Execute(SfxRequest &rReq)
     134             : {
     135           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     136           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     137           0 :     SwWrtShell& rSh = GetShell();
     138             : 
     139             :     // #i35572#
     140           0 :     const SwNumRule* pCurRule = rSh.GetCurNumRule();
     141             :     OSL_ENSURE( pCurRule, "SwListShell::Execute without NumRule" );
     142           0 :     bool bOutline = pCurRule && pCurRule->IsOutlineRule();
     143             : 
     144           0 :     switch (nSlot)
     145             :     {
     146             :         case FN_NUM_BULLET_DOWN:
     147             :         case FN_NUM_BULLET_UP:
     148             :             {
     149           0 :                 SfxViewFrame * pFrame = GetView().GetViewFrame();
     150             : 
     151           0 :                 rReq.Done();
     152           0 :                 rSh.NumUpDown( nSlot == FN_NUM_BULLET_DOWN );
     153           0 :                 pFrame->GetBindings().Invalidate( SID_TABLE_CELL ); // StatusZeile updaten!
     154             :             }
     155           0 :             break;
     156             : 
     157             :         case FN_NUM_BULLET_NEXT:
     158           0 :             rSh.GotoNextNum();
     159           0 :             rReq.Done();
     160           0 :             break;
     161             : 
     162             :         case FN_NUM_BULLET_NONUM:
     163           0 :             rSh.NoNum();
     164           0 :             rReq.Done();
     165           0 :             break;
     166             : 
     167             :         case FN_NUM_BULLET_OFF:
     168             :         {
     169           0 :             rReq.Ignore();
     170           0 :             SfxRequest aReq( GetView().GetViewFrame(), FN_NUM_BULLET_ON );
     171           0 :             aReq.AppendItem( SfxBoolItem( FN_PARAM_1, sal_False ) );
     172           0 :             aReq.Done();
     173           0 :             rSh.DelNumRules();
     174           0 :             break;
     175             :         }
     176             : 
     177             :         case FN_NUM_BULLET_OUTLINE_DOWN:
     178           0 :             if ( bOutline )
     179           0 :                 lcl_OutlineUpDownWithSubPoints( rSh, false, false );
     180             :             else
     181           0 :                 rSh.MoveNumParas(false, false);
     182           0 :             rReq.Done();
     183           0 :             break;
     184             : 
     185             :         case FN_NUM_BULLET_OUTLINE_MOVEDOWN:
     186           0 :             if ( bOutline )
     187           0 :                 lcl_OutlineUpDownWithSubPoints( rSh, true, false );
     188             :             else
     189           0 :                 rSh.MoveNumParas(true, false);
     190           0 :             rReq.Done();
     191           0 :             break;
     192             : 
     193             :         case FN_NUM_BULLET_OUTLINE_MOVEUP:
     194           0 :             if ( bOutline )
     195           0 :                 lcl_OutlineUpDownWithSubPoints( rSh, true, true );
     196             :             else
     197           0 :                 rSh.MoveNumParas(true, true);
     198           0 :             rReq.Done();
     199           0 :             break;
     200             : 
     201             :         case FN_NUM_BULLET_OUTLINE_UP:
     202           0 :             if ( bOutline )
     203           0 :                 lcl_OutlineUpDownWithSubPoints( rSh, false, true );
     204             :             else
     205           0 :                 rSh.MoveNumParas(false, true);
     206           0 :             rReq.Done();
     207           0 :             break;
     208             : 
     209             :         case FN_NUM_BULLET_PREV:
     210           0 :             rSh.GotoPrevNum();
     211           0 :             rReq.Done();
     212           0 :             break;
     213             : 
     214             :         case FN_NUM_OR_NONUM:
     215             :         {
     216           0 :             sal_Bool bApi = rReq.IsAPI();
     217           0 :             sal_Bool bDelete = !rSh.IsNoNum(!bApi);
     218           0 :             if(pArgs )
     219           0 :                 bDelete = ((SfxBoolItem &)pArgs->Get(rReq.GetSlot())).GetValue();
     220           0 :             rSh.NumOrNoNum( bDelete, !bApi );
     221           0 :             rReq.AppendItem( SfxBoolItem( nSlot, bDelete ) );
     222           0 :             rReq.Done();
     223             :         }
     224           0 :         break;
     225             :         default:
     226             :             OSL_ENSURE(!this, "wrong dispatcher");
     227           0 :             return;
     228             :     }
     229             : }
     230             : 
     231             : 
     232           0 : void SwListShell::GetState(SfxItemSet &rSet)
     233             : {
     234           0 :     SfxWhichIter aIter( rSet );
     235           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     236           0 :     SwWrtShell& rSh = GetShell();
     237           0 :     sal_uInt8 nCurrentNumLevel = rSh.GetNumLevel();
     238           0 :     while ( nWhich )
     239             :     {
     240           0 :         switch( nWhich )
     241             :         {
     242             :             case FN_NUM_OR_NONUM:
     243           0 :                 rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(sal_False)));
     244           0 :             break;
     245             :             case FN_NUM_BULLET_OUTLINE_UP:
     246             :             case FN_NUM_BULLET_UP:
     247           0 :                 if(!nCurrentNumLevel)
     248           0 :                     rSet.DisableItem(nWhich);
     249           0 :             break;
     250             :             case FN_NUM_BULLET_OUTLINE_DOWN :
     251             :             {
     252           0 :                 sal_uInt8 nUpper = 0;
     253           0 :                 sal_uInt8 nLower = 0;
     254           0 :                 rSh.GetCurrentOutlineLevels( nUpper, nLower );
     255           0 :                 if(nLower == (MAXLEVEL - 1))
     256           0 :                     rSet.DisableItem(nWhich);
     257             :             }
     258           0 :             break;
     259             :             case FN_NUM_BULLET_DOWN:
     260           0 :                 if(nCurrentNumLevel == (MAXLEVEL - 1))
     261           0 :                     rSet.DisableItem(nWhich);
     262           0 :             break;
     263             :         }
     264           0 :         nWhich = aIter.NextWhich();
     265           0 :     }
     266           0 : }
     267             : 
     268             : 
     269           7 : SwListShell::SwListShell(SwView &_rView) :
     270           7 :     SwBaseShell(_rView)
     271             : {
     272           7 :     SetName(rtl::OUString("List"));
     273           7 :     SetHelpId(SW_LISTSHELL);
     274           7 : }
     275             : 
     276             : 
     277             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10