LCOV - code coverage report
Current view: top level - sw/source/ui/shells - txtnum.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 96 0.0 %
Date: 2012-08-25 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 244 0.0 %

           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 <hintids.hxx>
      30                 :            : #include <vcl/msgbox.hxx>
      31                 :            : #include <sfx2/request.hxx>
      32                 :            : #include <svl/eitem.hxx>
      33                 :            : #include <svl/stritem.hxx>
      34                 :            : #include <editeng/numitem.hxx>
      35                 :            : #include <editeng/brshitem.hxx>
      36                 :            : #include <numrule.hxx>
      37                 :            : 
      38                 :            : #include "cmdid.h"
      39                 :            : #include "wrtsh.hxx"
      40                 :            : #include "view.hxx"
      41                 :            : #include "viewopt.hxx"
      42                 :            : #include "wdocsh.hxx"
      43                 :            : #include "textsh.hxx"
      44                 :            : #include "uiitems.hxx"
      45                 :            : #include "swabstdlg.hxx"
      46                 :            : #include <globals.hrc>
      47                 :            : #include <sfx2/tabdlg.hxx>
      48                 :            : 
      49                 :          0 : void SwTextShell::ExecEnterNum(SfxRequest &rReq)
      50                 :            : {
      51                 :            :     //wg. Aufzeichnung schon vor dem evtl. Shellwechsel
      52   [ #  #  #  # ]:          0 :     switch(rReq.GetSlot())
      53                 :            :     {
      54                 :            :     case FN_NUM_NUMBERING_ON:
      55                 :            :     {
      56                 :          0 :         SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False );
      57                 :          0 :         sal_Bool bMode = !GetShell().HasNumber(); // #i29560#
      58         [ #  # ]:          0 :         if ( pItem )
      59                 :          0 :             bMode = pItem->GetValue();
      60                 :            :         else
      61         [ #  # ]:          0 :             rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
      62                 :            : 
      63         [ #  # ]:          0 :         if ( bMode != (GetShell().HasNumber()) ) // #i29560#
      64                 :            :         {
      65                 :          0 :             rReq.Done();
      66         [ #  # ]:          0 :             if( bMode )
      67                 :          0 :                 GetShell().NumOn();
      68                 :            :             else
      69                 :          0 :                 GetShell().NumOrBulletOff(); // #i29560#
      70                 :            :         }
      71                 :            :     }
      72                 :          0 :     break;
      73                 :            :     case FN_NUM_BULLET_ON:
      74                 :            :     {
      75                 :          0 :         SFX_REQUEST_ARG( rReq, pItem, SfxBoolItem, FN_PARAM_1 , sal_False );
      76                 :          0 :         sal_Bool bMode = !GetShell().HasBullet(); // #i29560#
      77         [ #  # ]:          0 :         if ( pItem )
      78                 :          0 :             bMode = pItem->GetValue();
      79                 :            :         else
      80         [ #  # ]:          0 :             rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bMode ) );
      81                 :            : 
      82         [ #  # ]:          0 :         if ( bMode != (GetShell().HasBullet()) ) // #i29560#
      83                 :            :         {
      84                 :          0 :             rReq.Done();
      85         [ #  # ]:          0 :             if( bMode )
      86                 :          0 :                 GetShell().BulletOn();
      87                 :            :             else
      88                 :          0 :                 GetShell().NumOrBulletOff(); // #i29560#
      89                 :            :         }
      90                 :            :     }
      91                 :          0 :     break;
      92                 :            :     case FN_NUMBER_BULLETS:
      93                 :            :     {
      94                 :          0 :         SfxItemSet aSet(GetPool(),
      95                 :            :                 SID_HTML_MODE, SID_HTML_MODE,
      96                 :            :                 SID_ATTR_NUMBERING_RULE, SID_PARAM_CUR_NUM_LEVEL,
      97         [ #  # ]:          0 :                 0 );
      98         [ #  # ]:          0 :         SwDocShell* pDocSh = GetView().GetDocShell();
      99 [ #  # ][ #  # ]:          0 :         sal_Bool bHtml = 0 != PTR_CAST(SwWebDocShell, pDocSh);
         [ #  # ][ #  # ]
                 [ #  # ]
     100 [ #  # ][ #  # ]:          0 :         const SwNumRule* pCurRule = GetShell().GetCurNumRule();
     101         [ #  # ]:          0 :         if( pCurRule )
     102                 :            :         {
     103         [ #  # ]:          0 :             SvxNumRule aRule = pCurRule->MakeSvxNumRule();
     104                 :            : 
     105                 :            :             //convert type of linked bitmaps from SVX_NUM_BITMAP to (SVX_NUM_BITMAP|LINK_TOKEN)
     106         [ #  # ]:          0 :             for(sal_uInt16 i = 0; i < aRule.GetLevelCount(); i++)
     107                 :            :             {
     108 [ #  # ][ #  # ]:          0 :                 SvxNumberFormat aFmt(aRule.GetLevel(i));
     109         [ #  # ]:          0 :                 if(SVX_NUM_BITMAP == aFmt.GetNumberingType())
     110                 :            :                 {
     111                 :          0 :                     const SvxBrushItem* pBrush = aFmt.GetBrush();
     112                 :            :                     const String* pLinkStr;
     113   [ #  #  #  # ]:          0 :                     if(pBrush &&
         [ #  # ][ #  # ]
     114                 :            :                         0 != (pLinkStr = pBrush->GetGraphicLink()) &&
     115                 :          0 :                             pLinkStr->Len())
     116                 :          0 :                         aFmt.SetNumberingType(SvxExtNumType(SVX_NUM_BITMAP|LINK_TOKEN));
     117 [ #  # ][ #  # ]:          0 :                     aRule.SetLevel(i, aFmt, aRule.Get(i) != 0);
     118                 :            :                 }
     119         [ #  # ]:          0 :             }
     120         [ #  # ]:          0 :             if(bHtml)
     121                 :          0 :                 aRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, sal_False);
     122                 :            : 
     123 [ #  # ][ #  # ]:          0 :             aSet.Put(SvxNumBulletItem(aRule));
                 [ #  # ]
     124                 :            :             OSL_ENSURE( GetShell().GetNumLevel() < MAXLEVEL,
     125                 :            :                     "<SwTextShell::ExecEnterNum()> - numbered node without valid list level. Serious defect -> please inform OD." );
     126 [ #  # ][ #  # ]:          0 :             sal_uInt16 nLevel = GetShell().GetNumLevel();
     127         [ #  # ]:          0 :             if( nLevel < MAXLEVEL )
     128                 :            :             {
     129                 :          0 :                 nLevel = 1<<nLevel;
     130 [ #  # ][ #  # ]:          0 :                 aSet.Put( SfxUInt16Item( SID_PARAM_CUR_NUM_LEVEL, nLevel ));
                 [ #  # ]
     131         [ #  # ]:          0 :             }
     132                 :            :         }
     133                 :            :         else
     134                 :            :         {
     135         [ #  # ]:          0 :             SwNumRule aRule( GetShell().GetUniqueNumRuleName(),
     136                 :            :                              // #i89178#
     137 [ #  # ][ #  # ]:          0 :                              numfunc::GetDefaultPositionAndSpaceMode() );
         [ #  # ][ #  # ]
     138         [ #  # ]:          0 :             SvxNumRule aSvxRule = aRule.MakeSvxNumRule();
     139 [ #  # ][ #  # ]:          0 :             const bool bRightToLeft = GetShell().IsInRightToLeftText( 0 );
     140                 :            : 
     141 [ #  # ][ #  # ]:          0 :             if( bHtml || bRightToLeft )
     142                 :            :             {
     143         [ #  # ]:          0 :                 for( sal_uInt8 n = 0; n < MAXLEVEL; ++n )
     144                 :            :                 {
     145 [ #  # ][ #  # ]:          0 :                     SvxNumberFormat aFmt( aSvxRule.GetLevel( n ) );
     146 [ #  # ][ #  # ]:          0 :                     if ( n && bHtml )
     147                 :            :                     {
     148                 :            :                         // 1/2" fuer HTML
     149                 :          0 :                         aFmt.SetLSpace(720);
     150                 :          0 :                         aFmt.SetAbsLSpace(n * 720);
     151                 :            :                     }
     152                 :            :                     // #i38904#  Default alignment for
     153                 :            :                     // numbering/bullet should be rtl in rtl paragraph:
     154         [ #  # ]:          0 :                     if ( bRightToLeft )
     155                 :            :                     {
     156                 :          0 :                         aFmt.SetNumAdjust( SVX_ADJUST_RIGHT );
     157                 :            :                     }
     158         [ #  # ]:          0 :                     aSvxRule.SetLevel( n, aFmt, sal_False );
     159         [ #  # ]:          0 :                 }
     160                 :          0 :                 aSvxRule.SetFeatureFlag(NUM_ENABLE_EMBEDDED_BMP, sal_False);
     161                 :            :             }
     162 [ #  # ][ #  # ]:          0 :             aSet.Put(SvxNumBulletItem(aSvxRule));
         [ #  # ][ #  # ]
                 [ #  # ]
     163                 :            :         }
     164                 :            : 
     165 [ #  # ][ #  # ]:          0 :         aSet.Put( SfxBoolItem( SID_PARAM_NUM_PRESET,sal_False ));
                 [ #  # ]
     166                 :            : 
     167                 :            :         // vor dem Dialog wird der HtmlMode an der DocShell versenkt
     168 [ #  # ][ #  # ]:          0 :         pDocSh->PutItem(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(pDocSh)));
         [ #  # ][ #  # ]
     169                 :            : 
     170         [ #  # ]:          0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     171                 :            :         OSL_ENSURE(pFact, "Dialogdiet fail!");
     172                 :            :         SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_SVXTEST_NUM_BULLET,
     173 [ #  # ][ #  # ]:          0 :                                                         GetView().GetWindow(), &aSet, GetShell());
     174                 :            :         OSL_ENSURE(pDlg, "Dialogdiet fail!");
     175         [ #  # ]:          0 :         sal_uInt16 nRet = pDlg->Execute();
     176                 :            :         const SfxPoolItem* pItem;
     177         [ #  # ]:          0 :         if( RET_OK == nRet )
     178                 :            :         {
     179 [ #  # ][ #  # ]:          0 :             if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
                 [ #  # ]
     180                 :            :             {
     181         [ #  # ]:          0 :                 rReq.AppendItem(*pItem);
     182         [ #  # ]:          0 :                 rReq.Done();
     183                 :          0 :                 SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
     184         [ #  # ]:          0 :                 pSetRule->UnLinkGraphics();
     185                 :            :                 SwNumRule aSetRule( pCurRule
     186                 :          0 :                                         ? pCurRule->GetName()
     187         [ #  # ]:          0 :                                         : GetShell().GetUniqueNumRuleName(),
     188                 :            :                                     // #i89178#
     189         [ #  # ]:          0 :                                     numfunc::GetDefaultPositionAndSpaceMode() );
           [ #  #  #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     190 [ #  # ][ #  # ]:          0 :                 aSetRule.SetSvxRule( *pSetRule, GetShell().GetDoc());
     191                 :          0 :                 aSetRule.SetAutoRule( sal_True );
     192                 :            :                 // No start of new list, if an existing list style is edited.
     193                 :            :                 // Otherwise start a new list.
     194                 :          0 :                 const bool bCreateList = (pCurRule == 0);
     195 [ #  # ][ #  # ]:          0 :                 GetShell().SetCurNumRule( aSetRule, bCreateList );
         [ #  # ][ #  # ]
                 [ #  # ]
     196                 :            :             }
     197                 :            :             // wenn der Dialog mit OK verlassen wurde, aber nichts ausgewaehlt
     198                 :            :             // wurde dann muss die Numerierung zumindest eingeschaltet werden,
     199                 :            :             // wenn sie das noch nicht ist
     200 [ #  # ][ #  # ]:          0 :             else if( !pCurRule && SFX_ITEM_SET == aSet.GetItemState( SID_ATTR_NUMBERING_RULE, sal_False, &pItem ))
         [ #  # ][ #  # ]
     201                 :            :             {
     202         [ #  # ]:          0 :                 rReq.AppendItem( *pItem );
     203         [ #  # ]:          0 :                 rReq.Done();
     204                 :          0 :                 SvxNumRule* pSetRule = ((SvxNumBulletItem*)pItem)->GetNumRule();
     205         [ #  # ]:          0 :                 SwNumRule aSetRule( GetShell().GetUniqueNumRuleName(),
     206                 :            :                                     // #i89178#
     207 [ #  # ][ #  # ]:          0 :                                     numfunc::GetDefaultPositionAndSpaceMode() );
         [ #  # ][ #  # ]
     208 [ #  # ][ #  # ]:          0 :                 aSetRule.SetSvxRule(*pSetRule, GetShell().GetDoc());
     209                 :          0 :                 aSetRule.SetAutoRule( sal_True );
     210                 :            :                 // start new list
     211 [ #  # ][ #  # ]:          0 :                 GetShell().SetCurNumRule( aSetRule, true );
         [ #  # ][ #  # ]
                 [ #  # ]
     212                 :            :             }
     213                 :            :         }
     214         [ #  # ]:          0 :         else if(RET_USER == nRet)
     215 [ #  # ][ #  # ]:          0 :             GetShell().DelNumRules();
     216                 :            : 
     217 [ #  # ][ #  # ]:          0 :         delete pDlg;
                 [ #  # ]
     218                 :            :     }
     219                 :          0 :     break;
     220                 :            :     default:
     221                 :            :         OSL_FAIL("wrong dispatcher");
     222                 :          0 :         return;
     223                 :            :     }
     224                 :            : }
     225                 :            : 
     226                 :            : 
     227                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10