LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - listsh.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 10 127 7.9 %
Date: 2015-06-13 12:38:46 Functions: 10 15 66.7 %
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/brushitem.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 <svl/srchitem.hxx>
      33             : 
      34             : #include <numrule.hxx>
      35             : #include <fmtornt.hxx>
      36             : #include "wrtsh.hxx"
      37             : #include "swmodule.hxx"
      38             : #include "frmatr.hxx"
      39             : #include "helpid.h"
      40             : #include "globals.hrc"
      41             : #include "shells.hrc"
      42             : #include "uinums.hxx"
      43             : #include "listsh.hxx"
      44             : #include "poolfmt.hxx"
      45             : #include "view.hxx"
      46             : #include "edtwin.hxx"
      47             : 
      48             : #define SwListShell
      49             : #include <sfx2/msg.hxx>
      50             : #include "swslots.hxx"
      51             : 
      52             : #include <IDocumentOutlineNodes.hxx>
      53             : 
      54        1036 : SFX_IMPL_INTERFACE(SwListShell, SwBaseShell)
      55             : 
      56          59 : void SwListShell::InitInterface_Impl()
      57             : {
      58          59 :     GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, RID_NUM_TOOLBOX);
      59          59 : }
      60             : 
      61        1989 : 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 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, true );
      74             : 
      75           0 :         if ( bMove )
      76             :         {
      77           0 :             const IDocumentOutlineNodes* pIDoc( rSh.getIDocumentOutlineNodesAccess() );
      78           0 :             const int nActLevel = pIDoc->getOutlineLevel( nActPos );
      79           0 :             sal_Int32 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_Int32 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_Int32 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( false );
     130             :     }
     131           0 : }
     132             : 
     133           0 : void SwListShell::Execute(SfxRequest &rReq)
     134             : {
     135           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     136           0 :     const sal_uInt16 nSlot = rReq.GetSlot();
     137           0 :     SwWrtShell& rSh = GetShell();
     138             : 
     139             :     // #i35572#
     140           0 :     const SwNumRule* pCurRule = rSh.GetNumRuleAtCurrCrsrPos();
     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 ); // Update status line!
     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, 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 :             bool bApi = rReq.IsAPI();
     217           0 :             bool bDelete = !rSh.IsNoNum(!bApi);
     218           0 :             if(pArgs )
     219           0 :                 bDelete = static_cast<const 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(false, "wrong dispatcher");
     227           0 :             return;
     228             :     }
     229             : }
     230             : 
     231           0 : void SwListShell::GetState(SfxItemSet &rSet)
     232             : {
     233           0 :     SfxWhichIter aIter( rSet );
     234           0 :     sal_uInt16 nWhich = aIter.FirstWhich();
     235           0 :     SwWrtShell& rSh = GetShell();
     236           0 :     sal_uInt8 nCurrentNumLevel = rSh.GetNumLevel();
     237           0 :     while ( nWhich )
     238             :     {
     239           0 :         switch( nWhich )
     240             :         {
     241             :             case FN_NUM_OR_NONUM:
     242           0 :                 rSet.Put(SfxBoolItem(nWhich, GetShell().IsNoNum(false)));
     243           0 :             break;
     244             :             case FN_NUM_BULLET_OUTLINE_UP:
     245             :             case FN_NUM_BULLET_UP:
     246           0 :                 if(!nCurrentNumLevel)
     247           0 :                     rSet.DisableItem(nWhich);
     248           0 :             break;
     249             :             case FN_NUM_BULLET_OUTLINE_DOWN :
     250             :             {
     251           0 :                 sal_uInt8 nUpper = 0;
     252           0 :                 sal_uInt8 nLower = 0;
     253           0 :                 rSh.GetCurrentOutlineLevels( nUpper, nLower );
     254           0 :                 if(nLower == (MAXLEVEL - 1))
     255           0 :                     rSet.DisableItem(nWhich);
     256             :             }
     257           0 :             break;
     258             :             case FN_NUM_BULLET_DOWN:
     259           0 :                 if(nCurrentNumLevel == (MAXLEVEL - 1))
     260           0 :                     rSet.DisableItem(nWhich);
     261           0 :             break;
     262             : 
     263             :             case FN_NUM_BULLET_NONUM:
     264           0 :                 if ( rSh.CrsrInsideInputField() )
     265             :                 {
     266           0 :                     rSet.DisableItem(nWhich);
     267             :                 }
     268           0 :                 break;
     269             :         }
     270           0 :         nWhich = aIter.NextWhich();
     271           0 :     }
     272           0 : }
     273             : 
     274         130 : SwListShell::SwListShell(SwView &_rView) :
     275         130 :     SwBaseShell(_rView)
     276             : {
     277         130 :     SetName(OUString("List"));
     278         130 :     SetHelpId(SW_LISTSHELL);
     279         307 : }
     280             : 
     281             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11