LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - tabsh.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 70 785 8.9 %
Date: 2013-07-09 Functions: 13 23 56.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 <hintids.hxx>
      21             : #include <svl/zforlist.hxx>
      22             : #include <svl/stritem.hxx>
      23             : #include <svl/whiter.hxx>
      24             : #include <unotools/moduleoptions.hxx>
      25             : #include <svx/rulritem.hxx>
      26             : #include <svl/srchitem.hxx>
      27             : #include <editeng/lrspitem.hxx>
      28             : #include <editeng/ulspitem.hxx>
      29             : #include <editeng/brushitem.hxx>
      30             : #include <editeng/boxitem.hxx>
      31             : #include <editeng/shaditem.hxx>
      32             : #include <editeng/spltitem.hxx>
      33             : #include <editeng/langitem.hxx>
      34             : #include <editeng/keepitem.hxx>
      35             : #include <editeng/lineitem.hxx>
      36             : #include <editeng/colritem.hxx>
      37             : #include <editeng/frmdiritem.hxx>
      38             : #include <svx/numinf.hxx>
      39             : #include <svx/svddef.hxx>
      40             : #include <svx/svxdlg.hxx>
      41             : #include <svl/zformat.hxx>
      42             : #include <sfx2/bindings.hxx>
      43             : #include <vcl/msgbox.hxx>
      44             : #include <sfx2/request.hxx>
      45             : #include <sfx2/dispatch.hxx>
      46             : #include <sfx2/objface.hxx>
      47             : #include <sfx2/sidebar/EnumContext.hxx>
      48             : 
      49             : #include <fmtornt.hxx>
      50             : #include <fmtclds.hxx>
      51             : #include <fmtlsplt.hxx>
      52             : #include <fmtrowsplt.hxx>
      53             : #include <fmtfsize.hxx>
      54             : #include <swmodule.hxx>
      55             : #include <wrtsh.hxx>
      56             : #include <wview.hxx>
      57             : #include <frmatr.hxx>
      58             : #include <uitool.hxx>
      59             : #include <inputwin.hxx>
      60             : #include <uiitems.hxx>
      61             : #include <usrpref.hxx>
      62             : #include <tabsh.hxx>
      63             : #include "swtablerep.hxx"
      64             : #include <tablemgr.hxx>
      65             : #include <cellatr.hxx>
      66             : #include <frmfmt.hxx>
      67             : #include <swundo.hxx>
      68             : #include <swtable.hxx>
      69             : #include <docsh.hxx>
      70             : #include <tblsel.hxx>
      71             : 
      72             : #include <dialog.hrc>
      73             : #include <popup.hrc>
      74             : #include <shells.hrc>
      75             : #include <cmdid.h>
      76             : #include <globals.hrc>
      77             : #include <helpid.h>
      78             : #include <unobaseclass.hxx>
      79             : 
      80             : #define SwTableShell
      81             : #include <sfx2/msg.hxx>
      82             : #include <swslots.hxx>
      83             : 
      84             : #include "swabstdlg.hxx"
      85             : #include <table.hrc>
      86             : 
      87             : using ::editeng::SvxBorderLine;
      88             : using namespace ::com::sun::star;
      89             : 
      90        1050 : SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell, SW_RES(STR_SHELLNAME_TABLE))
      91             : {
      92          33 :     SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU));
      93          33 :     SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX));
      94          33 : }
      95             : 
      96         444 : TYPEINIT1(SwTableShell,SwBaseShell)
      97             : 
      98             : const sal_uInt16 aUITableAttrRange[] =
      99             : {
     100             :     FN_PARAM_TABLE_NAME,            FN_PARAM_TABLE_NAME,
     101             :     FN_PARAM_TABLE_HEADLINE,        FN_PARAM_TABLE_HEADLINE,
     102             :     FN_PARAM_TABLE_SPACE,           FN_PARAM_TABLE_SPACE,
     103             :     FN_TABLE_REP,                   FN_TABLE_REP,
     104             :     SID_RULER_BORDERS,              SID_RULER_BORDERS,
     105             :     RES_LR_SPACE,                   RES_UL_SPACE,
     106             :     SID_ATTR_BORDER_INNER,          SID_ATTR_BORDER_SHADOW,
     107             :     RES_BOX,                        RES_SHADOW,
     108             :     RES_BACKGROUND,                 RES_BACKGROUND,
     109             :     SID_BACKGRND_DESTINATION,       SID_BACKGRND_DESTINATION,
     110             :     SID_HTML_MODE,                  SID_HTML_MODE,
     111             :     SID_ATTR_BRUSH_ROW,             SID_ATTR_BRUSH_TABLE,
     112             :     RES_PAGEDESC,                   RES_BREAK,
     113             :     RES_KEEP,                       RES_KEEP,
     114             :     RES_LAYOUT_SPLIT,               RES_LAYOUT_SPLIT,
     115             :     FN_TABLE_SET_VERT_ALIGN,        FN_TABLE_SET_VERT_ALIGN,
     116             :     RES_FRAMEDIR,                   RES_FRAMEDIR,
     117             :     RES_ROW_SPLIT,                  RES_ROW_SPLIT,
     118             :     FN_TABLE_BOX_TEXTORIENTATION,   FN_TABLE_BOX_TEXTORIENTATION,
     119             : // #i29550#
     120             :     RES_COLLAPSING_BORDERS,         RES_COLLAPSING_BORDERS,
     121             : // <-- collapsing borders
     122             :     0
     123             : };
     124             : 
     125           0 : const sal_uInt16* SwuiGetUITableAttrRange()
     126             : {
     127           0 :     return aUITableAttrRange;
     128             : }
     129             : 
     130           0 : static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
     131             : {
     132           0 :     SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which(), 0);
     133           0 :     aSet.Put( rItem );
     134           0 :     rSh.SetTblAttr( aSet );
     135           0 : }
     136             : 
     137           0 : static SwTableRep*  lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
     138             : {
     139           0 :     SwFrmFmt *pFmt = rSh.GetTableFmt();
     140           0 :     SwTabCols aCols;
     141           0 :     rSh.GetTabCols( aCols );
     142             : 
     143             :     //At first get the simple attributes.
     144           0 :     rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFmt->GetName()));
     145           0 :     rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
     146           0 :     rSet.Put( pFmt->GetShadow() );
     147           0 :     rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
     148           0 :     rSet.Put( pFmt->GetFrmDir() );
     149             : 
     150           0 :     SvxULSpaceItem aULSpace( pFmt->GetULSpace() );
     151           0 :     rSet.Put( aULSpace );
     152             : 
     153           0 :     sal_uInt16  nBackgroundDestination = rSh.GetViewOptions()->GetTblDest();
     154           0 :     rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
     155           0 :     SvxBrushItem aBrush( RES_BACKGROUND );
     156           0 :     if(rSh.GetRowBackground(aBrush))
     157           0 :         rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
     158             :     else
     159           0 :         rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
     160           0 :     rSh.GetTabBackground(aBrush);
     161           0 :     rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
     162             : 
     163             :     // text direction in boxes
     164           0 :     SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
     165           0 :     if(rSh.GetBoxDirection( aBoxDirection ))
     166           0 :         rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTORIENTATION);
     167             : 
     168           0 :     sal_Bool bTableSel = rSh.IsTableMode();
     169           0 :     if(!bTableSel)
     170             :     {
     171           0 :         rSh.StartAllAction();
     172           0 :         rSh.Push();
     173           0 :         rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL, sal_False );
     174             :     }
     175           0 :     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
     176             : 
     177             :         // Table variant: If multiple table cells are selected.
     178           0 :     rSh.GetCrsr();                  //Thus GetCrsrCnt() returns the right thing
     179           0 :     aBoxInfo.SetTable          ((rSh.IsTableMode() && rSh.GetCrsrCnt() > 1) ||
     180           0 :                                     !bTableSel);
     181             :         // Always show distance field.
     182           0 :     aBoxInfo.SetDist           ((sal_Bool) sal_True);
     183             :         // Set minimum size in tables and paragraphs.
     184           0 :     aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
     185           0 :                             rSh.GetSelectionType() &
     186           0 :                             (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
     187             :         // Always set the default spacing.
     188           0 :     aBoxInfo.SetDefDist        (MIN_BORDER_DIST);
     189             :         // Individual lines can have DontCare status only in tables.
     190           0 :     aBoxInfo.SetValid( VALID_DISABLE, !bTableSel || !rSh.IsTableMode() );
     191             : 
     192           0 :     rSet.Put(aBoxInfo);
     193           0 :     rSh.GetTabBorders( rSet );
     194             : 
     195             :     //row split
     196           0 :     SwFmtRowSplit* pSplit = 0;
     197           0 :     rSh.GetRowSplit(pSplit);
     198           0 :     if(pSplit)
     199             :     {
     200           0 :         rSet.Put(*pSplit);
     201           0 :         delete pSplit;
     202             :     }
     203             : 
     204           0 :     if(!bTableSel)
     205             :     {
     206           0 :         rSh.ClearMark();
     207           0 :         rSh.Pop(sal_False);
     208           0 :         rSh.EndAllAction();
     209             :     }
     210             : 
     211           0 :     SwTabCols aTabCols;
     212           0 :     rSh.GetTabCols( aTabCols );
     213           0 :     SvxColumnItem aColItem;
     214             : 
     215             :     // Pointer will be deleted after the dialogue execution.
     216           0 :     SwTableRep* pRep = new SwTableRep( aTabCols );
     217           0 :     pRep->SetSpace(aCols.GetRightMax());
     218             : 
     219           0 :     sal_uInt16 nPercent = 0;
     220           0 :     long nWidth = ::GetTableWidth(pFmt, aCols, &nPercent, &rSh );
     221             :     // The table width is wrong for relative values.
     222           0 :     if(nPercent)
     223           0 :         nWidth = pRep->GetSpace() * nPercent / 100;
     224           0 :     sal_uInt16 nAlign = pFmt->GetHoriOrient().GetHoriOrient();
     225           0 :     pRep->SetAlign(nAlign);
     226           0 :     SvxLRSpaceItem aLRSpace( pFmt->GetLRSpace() );
     227           0 :     SwTwips nLeft = aLRSpace.GetLeft();
     228           0 :     SwTwips nRight = aLRSpace.GetRight();
     229           0 :     SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
     230           0 :     if(nAlign != text::HoriOrientation::FULL && std::abs(nDiff) > 2)
     231             :     {
     232           0 :         SwTwips nLR = pRep->GetSpace() - nWidth;
     233           0 :         switch ( nAlign )
     234             :         {
     235           0 :             case text::HoriOrientation::CENTER: nLeft = nRight = nLR / 2;
     236           0 :             break;
     237           0 :             case text::HoriOrientation::LEFT: nRight = nLR; nLeft = 0;
     238           0 :             break;
     239           0 :             case text::HoriOrientation::RIGHT: nLeft = nLR, nRight = 0;
     240           0 :             break;
     241             :             case text::HoriOrientation::LEFT_AND_WIDTH:
     242           0 :                 nRight = nLR - nLeft;
     243           0 :             break;
     244             :             case text::HoriOrientation::NONE:
     245           0 :                 if(!nPercent)
     246           0 :                     nWidth = pRep->GetSpace() - nLeft - nRight;
     247           0 :             break;
     248             :         }
     249             :     }
     250           0 :     pRep->SetLeftSpace(nLeft);
     251           0 :     pRep->SetRightSpace(nRight);
     252             : 
     253           0 :     pRep->SetWidth(nWidth);
     254           0 :     pRep->SetWidthPercent(nPercent);
     255             :     // Are individual rows / cells are selected, the column processing will be changed.
     256           0 :     pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
     257           0 :     rSet.Put(SwPtrItem(FN_TABLE_REP, pRep));
     258           0 :     return pRep;
     259             : }
     260             : 
     261           0 : void ItemSetToTableParam( const SfxItemSet& rSet,
     262             :                                 SwWrtShell &rSh )
     263             : {
     264           0 :     rSh.StartAllAction();
     265           0 :     rSh.StartUndo( UNDO_TABLE_ATTR );
     266           0 :     const SfxPoolItem* pItem = 0;
     267             : 
     268           0 :     SwViewOption aUsrPref( *rSh.GetViewOptions() );
     269           0 :     sal_uInt16 nBackgroundDestination = aUsrPref.GetTblDest();
     270           0 :     if(SFX_ITEM_SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, sal_False, &pItem))
     271             :     {
     272           0 :         nBackgroundDestination = ((SfxUInt16Item*)pItem)->GetValue();
     273           0 :         aUsrPref.SetTblDest((sal_uInt8)nBackgroundDestination);
     274           0 :         SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
     275             :     }
     276           0 :     bool bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
     277           0 :             SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
     278           0 :     pItem = 0;
     279           0 :     sal_Bool bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, sal_False, &pItem );
     280           0 :     const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
     281           0 :     bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False, &pRowItem );
     282           0 :     bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False, &pTableItem );
     283           0 :     const SfxPoolItem* pSplit = 0;
     284           0 :     bool bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pSplit );
     285           0 :     const SfxPoolItem* pBoxDirection = 0;
     286           0 :     bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, sal_False, &pBoxDirection );
     287           0 :     if( bBackground || bBorder || bRowSplit || bBoxDirection)
     288             :     {
     289             :         // The border will be applied to the present selection.
     290             :         // If there is no selection, the table will be completely selected.
     291             :         // The background will always be applied to the current state.
     292           0 :         sal_Bool bTableSel = rSh.IsTableMode();
     293           0 :         rSh.StartAllAction();
     294             : 
     295           0 :         if(bBackground)
     296             :         {
     297           0 :             if(pItem)
     298           0 :                 rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
     299           0 :             if(pRowItem)
     300             :             {
     301           0 :                 SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
     302           0 :                 aBrush.SetWhich(RES_BACKGROUND);
     303           0 :                 rSh.SetRowBackground(aBrush);
     304             :             }
     305           0 :             if(pTableItem)
     306             :             {
     307           0 :                 SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
     308           0 :                 aBrush.SetWhich(RES_BACKGROUND);
     309           0 :                 rSh.SetTabBackground( aBrush );
     310             :             }
     311             :         }
     312             : 
     313           0 :         if(bBoxDirection)
     314             :         {
     315           0 :             SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
     316           0 :             aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
     317           0 :             rSh.SetBoxDirection(aDirection);
     318             :         }
     319             : 
     320           0 :         if(bBorder || bRowSplit)
     321             :         {
     322           0 :             rSh.Push();
     323           0 :             if(!bTableSel)
     324             :             {
     325           0 :                 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
     326             :             }
     327           0 :             if(bBorder)
     328           0 :                 rSh.SetTabBorders( rSet );
     329             : 
     330           0 :             if(bRowSplit)
     331             :             {
     332           0 :                 rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pSplit));
     333             :             }
     334             : 
     335           0 :             if(!bTableSel)
     336             :             {
     337           0 :                 rSh.ClearMark();
     338             :             }
     339           0 :             rSh.Pop(sal_False);
     340             :         }
     341             : 
     342           0 :         rSh.EndAllAction();
     343             :     }
     344             : 
     345           0 :     SwTabCols aTabCols;
     346           0 :     bool bTabCols = false;
     347           0 :     sal_Bool bSingleLine = sal_False;
     348           0 :     SwTableRep* pRep = 0;
     349           0 :     SwFrmFmt *pFmt = rSh.GetTableFmt();
     350           0 :     SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
     351           0 :     if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem ))
     352             :     {
     353           0 :         pRep = (SwTableRep*)((const SwPtrItem*)pItem)->GetValue();
     354             : 
     355           0 :         const SwTwips nWidth = pRep->GetWidth();
     356           0 :         if ( text::HoriOrientation::FULL == pRep->GetAlign() )
     357             :         {
     358           0 :             SwFmtHoriOrient aAttr( pFmt->GetHoriOrient() );
     359           0 :             aAttr.SetHoriOrient( text::HoriOrientation::FULL );
     360           0 :             aSet.Put( aAttr );
     361             :         }
     362             :         else
     363             :         {
     364           0 :             SwFmtFrmSize aSz( ATT_VAR_SIZE, nWidth );
     365           0 :             if(pRep->GetWidthPercent())
     366             :             {
     367           0 :                 aSz.SetWidthPercent( (sal_uInt8)pRep->GetWidthPercent() );
     368             :             }
     369           0 :             aSet.Put(aSz);
     370             :         }
     371             : 
     372           0 :         SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
     373           0 :         aLRSpace.SetLeft(pRep->GetLeftSpace());
     374           0 :         aLRSpace.SetRight(pRep->GetRightSpace());
     375           0 :         aSet.Put( aLRSpace );
     376             : 
     377           0 :         sal_Int16 eOrient = pRep->GetAlign();
     378           0 :         SwFmtHoriOrient aAttr( 0, eOrient );
     379           0 :         aSet.Put( aAttr );
     380             :     // The item must only be recorded while manual alignment, so that the
     381             :     // alignment is not overwritten by the distances while recording.
     382           0 :         if(eOrient != text::HoriOrientation::NONE)
     383           0 :             ((SfxItemSet&)rSet).ClearItem( SID_ATTR_LRSPACE );
     384             : 
     385             : 
     386           0 :         if(pRep->HasColsChanged())
     387             :         {
     388           0 :             bTabCols = true;
     389           0 :         }
     390             :     }
     391             : 
     392             : 
     393           0 :     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, sal_False, &pItem))
     394           0 :         rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
     395             : 
     396           0 :     if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, sal_False, &pItem))
     397           0 :         rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
     398             : 
     399           0 :     if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, sal_False, &pItem ))
     400           0 :         rSh.SetTableName( *pFmt, ((const SfxStringItem*)pItem)->GetValue() );
     401             : 
     402             :     // Copy the chosen attributes in the ItemSet.
     403             :     static sal_uInt16 aIds[] =
     404             :         {
     405             :             RES_PAGEDESC,
     406             :             RES_BREAK,
     407             :             RES_KEEP,
     408             :             RES_LAYOUT_SPLIT,
     409             :             RES_UL_SPACE,
     410             :             RES_SHADOW,
     411             :             RES_FRAMEDIR,
     412             :             // #i29550#
     413             :             RES_COLLAPSING_BORDERS,
     414             :             // <-- collapsing borders
     415             :             0
     416             :         };
     417           0 :     for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
     418           0 :         if( SFX_ITEM_SET == rSet.GetItemState( *pIds, sal_False, &pItem))
     419           0 :             aSet.Put( *pItem );
     420             : 
     421           0 :     if( aSet.Count() )
     422           0 :         rSh.SetTblAttr( aSet );
     423             : 
     424           0 :     if(bTabCols)
     425             :     {
     426           0 :         rSh.GetTabCols( aTabCols );
     427           0 :         bSingleLine = pRep->FillTabCols( aTabCols );
     428           0 :         rSh.SetTabCols( aTabCols, bSingleLine );
     429             :     }
     430             : 
     431           0 :     rSh.EndUndo( UNDO_TABLE_ATTR );
     432           0 :     rSh.EndAllAction();
     433           0 : }
     434             : 
     435           0 : static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
     436             : {
     437           0 :     if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
     438           0 :         rBorderLine.SetWidth(pBorderLine->GetWidth());
     439             : 
     440           0 :     rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
     441           0 :     rBorderLine.SetColor(pBorderLine->GetColor());
     442           0 : }
     443             : 
     444           0 : void SwTableShell::Execute(SfxRequest &rReq)
     445             : {
     446           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     447           0 :     SwWrtShell &rSh = GetShell();
     448             : 
     449             :     // At first the slots which doesn't need a FrmMgr.
     450           0 :     bool bMore = false;
     451           0 :     const SfxPoolItem* pItem = 0;
     452           0 :     sal_uInt16 nSlot = rReq.GetSlot();
     453           0 :     if(pArgs)
     454           0 :         pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
     455           0 :     bool bCallDone = false;
     456           0 :     switch ( nSlot )
     457             :     {
     458             :         case SID_ATTR_BORDER:
     459             :         {
     460           0 :             if(!pArgs)
     461           0 :                 break;
     462             :             // Create items, because we have to rework anyway.
     463           0 :             SvxBoxItem     aBox( RES_BOX );
     464           0 :             SfxItemSet aCoreSet( GetPool(),
     465             :                             RES_BOX, RES_BOX,
     466             :                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
     467           0 :                             0);
     468           0 :             SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
     469           0 :             aCoreSet.Put(aCoreInfo);
     470           0 :             rSh.GetTabBorders( aCoreSet );
     471             :             const SvxBoxItem& rCoreBox = (const SvxBoxItem&)
     472           0 :                                                     aCoreSet.Get(RES_BOX);
     473           0 :             const SfxPoolItem *pBoxItem = 0;
     474           0 :             if ( pArgs->GetItemState(RES_BOX, sal_True, &pBoxItem) == SFX_ITEM_SET )
     475             :             {
     476           0 :                 aBox = *(SvxBoxItem*)pBoxItem;
     477           0 :                 if ( !rReq.IsAPI() )
     478           0 :                     aBox.SetDistance( std::max(rCoreBox.GetDistance(),sal_uInt16(55)) );
     479           0 :                 else if ( aBox.GetDistance() < MIN_BORDER_DIST )
     480           0 :                     aBox.SetDistance( std::max(rCoreBox.GetDistance(),(sal_uInt16)MIN_BORDER_DIST)  );
     481             :             }
     482             :             else
     483             :                 OSL_ENSURE( !this, "where is BoxItem?" );
     484             : 
     485             :             //since the drawing layer also supports borders the which id might be a different one
     486           0 :             SvxBoxInfoItem aInfo( SID_ATTR_BORDER_INNER );
     487           0 :             if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET)
     488           0 :                 aInfo = *(SvxBoxInfoItem*)pBoxItem;
     489           0 :             else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET )
     490             :             {
     491           0 :                 aInfo = *(SvxBoxInfoItem*)pBoxItem;
     492           0 :                 aInfo.SetWhich(SID_ATTR_BORDER_INNER);
     493             :             }
     494             : 
     495           0 :             aInfo.SetTable( sal_True );
     496           0 :             aInfo.SetValid( VALID_DISABLE, sal_False );
     497             : 
     498             : 
     499             : // The attributes of all lines will be read and the strongest wins.
     500             :             const SvxBorderLine* pBorderLine;
     501           0 :             SvxBorderLine aBorderLine;
     502           0 :             if ((pBorderLine = rCoreBox.GetTop()) != NULL)
     503           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     504           0 :             if ((pBorderLine = rCoreBox.GetBottom()) != NULL)
     505           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     506           0 :             if ((pBorderLine = rCoreBox.GetLeft()) != NULL)
     507           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     508           0 :             if ((pBorderLine = rCoreBox.GetRight()) != NULL)
     509           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     510           0 :             if ((pBorderLine = aCoreInfo.GetHori()) != NULL)
     511           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     512           0 :             if ((pBorderLine = aCoreInfo.GetVert()) != NULL)
     513           0 :                 lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
     514             : 
     515           0 :             if(aBorderLine.GetOutWidth() == 0)
     516             :             {
     517           0 :                 aBorderLine.SetBorderLineStyle(table::BorderLineStyle::SOLID);
     518           0 :                 aBorderLine.SetWidth( DEF_LINE_WIDTH_0 );
     519             :             }
     520             : 
     521           0 :             sal_Bool bLine = sal_False;
     522           0 :             if ( (pBorderLine = aBox.GetTop()) != NULL)
     523           0 :                 aBox.SetLine(&aBorderLine, BOX_LINE_TOP), bLine |= sal_True;
     524           0 :             if ((pBorderLine = aBox.GetBottom()) != NULL)
     525           0 :                 aBox.SetLine(&aBorderLine, BOX_LINE_BOTTOM), bLine |= sal_True;
     526           0 :             if ((pBorderLine = aBox.GetLeft()) != NULL)
     527           0 :                 aBox.SetLine(&aBorderLine, BOX_LINE_LEFT), bLine |= sal_True;
     528           0 :             if ((pBorderLine = aBox.GetRight()) != NULL)
     529           0 :                 aBox.SetLine(&aBorderLine, BOX_LINE_RIGHT), bLine |= sal_True;
     530           0 :             if ((pBorderLine = aInfo.GetHori()) != NULL)
     531           0 :                 aInfo.SetLine(&aBorderLine, BOXINFO_LINE_HORI), bLine |= sal_True;
     532           0 :             if ((pBorderLine = aInfo.GetVert()) != NULL)
     533           0 :                 aInfo.SetLine(&aBorderLine, BOXINFO_LINE_VERT), bLine |= sal_True;
     534             : 
     535           0 :             aCoreSet.Put( aBox  );
     536           0 :             aCoreSet.Put( aInfo );
     537           0 :             rSh.SetTabBorders( aCoreSet );
     538             : 
     539             :             // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
     540             :             // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
     541             :             // the SvxBoxItem
     542           0 :             rReq.AppendItem( aBox );
     543           0 :             rReq.AppendItem( aInfo );
     544           0 :             bCallDone = true;
     545             : 
     546             :         }
     547           0 :         break;
     548             :         case FN_INSERT_TABLE:
     549           0 :             InsertTable( rReq );
     550           0 :         break;
     551             :         case FN_FORMAT_TABLE_DLG:
     552             :         {
     553             :             //#127012# get the bindings before the dialog is called
     554             :             // it might happen that this shell is removed after closing the dialog
     555           0 :             SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
     556           0 :             SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
     557             : 
     558           0 :             FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
     559           0 :             SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
     560           0 :             SwTableRep* pTblRep = ::lcl_TableParamToItemSet( aCoreSet, rSh );
     561           0 :             SfxAbstractTabDialog * pDlg = NULL;
     562             :             {
     563           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     564             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     565             : 
     566           0 :                 pDlg = pFact->CreateSwTableTabDlg(GetView().GetWindow(), GetPool(), &aCoreSet, &rSh);
     567             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     568             : 
     569           0 :                 if (pItem)
     570           0 :                     pDlg->SetCurPageId(OUStringToOString(((SfxStringItem *)pItem)->GetValue(), RTL_TEXTENCODING_UTF8));
     571             :             }
     572           0 :             aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
     573           0 :             rSh.GetTblAttr(aCoreSet);
     574             :             // GetTblAttr overwrites the background!
     575           0 :             SvxBrushItem aBrush( RES_BACKGROUND );
     576           0 :             if(rSh.GetBoxBackground(aBrush))
     577           0 :                 aCoreSet.Put( aBrush );
     578             :             else
     579           0 :                 aCoreSet.InvalidateItem( RES_BACKGROUND );
     580             : 
     581           0 :             if ( (!pDlg && rReq.GetArgs()) || pDlg->Execute() == RET_OK )
     582             :             {
     583           0 :                 const SfxItemSet* pOutSet = pDlg ? pDlg->GetOutputItemSet() : rReq.GetArgs();
     584           0 :                 if ( pDlg )
     585             :                 {
     586             :                     //to record FN_INSERT_TABLE correctly
     587           0 :                     rReq.SetSlot(FN_FORMAT_TABLE_DLG);
     588           0 :                     rReq.Done( *pOutSet );
     589             :                 }
     590           0 :                 ItemSetToTableParam( *pOutSet, rSh );
     591             :             }
     592             : 
     593           0 :             delete pDlg;
     594           0 :             delete pTblRep;
     595           0 :             rBindings.Update(SID_RULER_BORDERS);
     596           0 :             rBindings.Update(SID_ATTR_TABSTOP);
     597           0 :             rBindings.Update(SID_RULER_BORDERS_VERTICAL);
     598           0 :             rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
     599             :         }
     600           0 :         break;
     601             :         case SID_ATTR_BRUSH:
     602             :         case SID_ATTR_BRUSH_ROW :
     603             :         case SID_ATTR_BRUSH_TABLE :
     604           0 :             if(rReq.GetArgs())
     605           0 :                 ItemSetToTableParam(*rReq.GetArgs(), rSh);
     606           0 :         break;
     607             :         case FN_NUM_FORMAT_TABLE_DLG:
     608             :         {
     609           0 :             SwView* pView = GetActiveView();
     610           0 :             if(pView)
     611             :             {
     612           0 :                 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
     613           0 :                 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
     614           0 :                 SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
     615           0 :                 SfxItemSet aCoreSet( GetPool(),
     616             :                                  SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
     617             :                                  SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
     618           0 :                                  0 );
     619             : 
     620           0 :                 SfxItemSet aBoxSet( *aCoreSet.GetPool(),
     621             :                                     RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
     622             :                                     RES_BOXATR_VALUE, RES_BOXATR_VALUE,
     623           0 :                                     0 );
     624           0 :                 rSh.GetTblBoxFormulaAttrs( aBoxSet );
     625             : 
     626           0 :                 SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
     627           0 :                 if(eState == SFX_ITEM_DEFAULT)
     628             :                 {
     629             :                     aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
     630           0 :                     pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
     631             :                 }
     632             :                 else
     633             :                     aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
     634             :                                     ((SwTblBoxNumFormat&)aBoxSet.Get(
     635           0 :                                     RES_BOXATR_FORMAT )).GetValue() ));
     636             : 
     637           0 :                 String sCurText( rSh.GetTableBoxText() );
     638             :                 aCoreSet.Put( SvxNumberInfoItem( pFormatter,
     639             :                                     ((SwTblBoxValue&)aBoxSet.Get(
     640           0 :                                         RES_BOXATR_VALUE)).GetValue(),
     641           0 :                                     sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
     642             : 
     643           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     644             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     645             : 
     646           0 :                 SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(),aCoreSet,
     647           0 :                     pView->GetViewFrame()->GetFrame().GetFrameInterface(),
     648           0 :                     RC_DLG_SWNUMFMTDLG );
     649             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     650             : 
     651           0 :                 if (RET_OK == pDlg->Execute())
     652             :                 {
     653           0 :                     const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
     654           0 :                                     GetItem( SID_ATTR_NUMBERFORMAT_INFO );
     655             : 
     656           0 :                     if( pNumberFormatItem && 0 != ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount() )
     657             :                     {
     658             :                         const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)
     659           0 :                                                         pNumberFormatItem)->GetDelArray();
     660             : 
     661           0 :                         for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount(); i++ )
     662             :                             ((SvxNumberInfoItem*)pNumberFormatItem)->
     663           0 :                             GetNumberFormatter()->DeleteEntry( pDelArr[i] );
     664             :                     }
     665             : 
     666           0 :                     if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState(
     667           0 :                         SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pNumberFormatItem ))
     668             :                     {
     669           0 :                         SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
     670           0 :                                     RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
     671             :                         aBoxFormatSet.Put( SwTblBoxNumFormat(
     672           0 :                                 ((SfxUInt32Item*)pNumberFormatItem)->GetValue() ));
     673           0 :                         rSh.SetTblBoxFormulaAttrs( aBoxFormatSet );
     674             : 
     675             :                     }
     676             :                 }
     677           0 :                 delete pDlg;
     678             :             }
     679             :         }
     680           0 :         break;
     681             :         case FN_CALC_TABLE:
     682           0 :             rSh.UpdateTable();
     683           0 :             bCallDone = true;
     684           0 :         break;
     685             :         case FN_TABLE_OPTIMAL_HEIGHT:
     686             :         {
     687           0 :             const SwFmtFrmSize aSz;
     688           0 :             rSh.SetRowHeight( aSz );
     689           0 :             bCallDone = true;
     690             :         }
     691           0 :         break;
     692             :         case FN_TABLE_DELETE_COL:
     693           0 :             if ( rSh.DeleteCol() && rSh.HasSelection() )
     694           0 :                 rSh.EnterStdMode();
     695           0 :             bCallDone = true;
     696           0 :         break;
     697             :         case FN_END_TABLE:
     698           0 :             rSh.MoveTable( fnTableCurr, fnTableEnd );
     699           0 :             bCallDone = true;
     700           0 :         break;
     701             :         case FN_START_TABLE:
     702           0 :             rSh.MoveTable( fnTableCurr, fnTableStart );
     703           0 :             bCallDone = true;
     704           0 :         break;
     705             :         case FN_GOTO_NEXT_CELL:
     706             :         {
     707           0 :             sal_Bool bAppendLine = sal_True;
     708           0 :             if( pItem )
     709           0 :                 bAppendLine = ((SfxBoolItem*)pItem)->GetValue();
     710             :             rReq.SetReturnValue( SfxBoolItem( nSlot,
     711           0 :                                     rSh.GoNextCell( bAppendLine ) ) );
     712           0 :             bCallDone = true;
     713             :         }
     714           0 :         break;
     715             :         case FN_GOTO_PREV_CELL:
     716           0 :             rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
     717           0 :             bCallDone = true;
     718           0 :         break;
     719             :         case FN_TABLE_DELETE_ROW:
     720           0 :             if ( rSh.DeleteRow() && rSh.HasSelection() )
     721           0 :                 rSh.EnterStdMode();
     722           0 :             bCallDone = true;
     723           0 :         break;
     724             :         case FN_TABLE_MERGE_CELLS:
     725           0 :             if ( rSh.IsTableMode() )
     726           0 :                 switch ( rSh.MergeTab() )
     727             :                 {
     728             :                     case TBLMERGE_OK:
     729           0 :                          bCallDone = true;
     730             :                     //no break;
     731           0 :                     case TBLMERGE_NOSELECTION:  break;
     732             :                     case TBLMERGE_TOOCOMPLEX:
     733             :                     {
     734           0 :                         InfoBox aInfoBox( GetView().GetWindow(),
     735           0 :                                     SW_RES( MSG_ERR_TABLE_MERGE ) );
     736           0 :                         aInfoBox.Execute();
     737           0 :                         break;
     738             :                     }
     739             :                     default: OSL_ENSURE( !this, "unknown return value MergeTab.");
     740             :                 }
     741           0 :         break;
     742             :         case FN_TABLE_ADJUST_CELLS:
     743             :         case FN_TABLE_BALANCE_CELLS:
     744             :         {
     745           0 :             sal_Bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
     746           0 :             if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
     747             :             {
     748             :                 {
     749             :                     // remove actions to make a valid table selection
     750           0 :                     UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
     751             :                 }
     752           0 :                 rSh.AdjustCellWidth(bBalance);
     753             :             }
     754           0 :             bCallDone = true;
     755             :         }
     756           0 :         break;
     757             :         case FN_TABLE_BALANCE_ROWS:
     758           0 :             if ( rSh.BalanceRowHeight(sal_True) )
     759           0 :                 rSh.BalanceRowHeight(sal_False);
     760           0 :             bCallDone = true;
     761           0 :         break;
     762             :         case FN_TABLE_SELECT_ALL:
     763           0 :             rSh.EnterStdMode();
     764           0 :             rSh.MoveTable( fnTableCurr, fnTableStart );
     765           0 :             rSh.SttSelect();
     766           0 :             rSh.MoveTable( fnTableCurr, fnTableEnd );
     767           0 :             rSh.EndSelect();
     768           0 :             bCallDone = true;
     769           0 :         break;
     770             :         case FN_TABLE_SELECT_COL:
     771           0 :             rSh.EnterStdMode();
     772           0 :             rSh.SelectTableCol();
     773           0 :             bCallDone = true;
     774           0 :         break;
     775             :         case FN_TABLE_SELECT_ROW:
     776           0 :             rSh.EnterStdMode();
     777           0 :             rSh.SelectTableRow();
     778           0 :             bCallDone = true;
     779           0 :         break;
     780             :         case FN_TABLE_SET_READ_ONLY_CELLS:
     781           0 :             rSh.ProtectCells();
     782           0 :             rSh.ResetSelect( 0, sal_False );
     783           0 :             bCallDone = true;
     784           0 :         break;
     785             :         case FN_TABLE_UNSET_READ_ONLY_CELLS:
     786           0 :             rSh.UnProtectCells();
     787           0 :             bCallDone = true;
     788           0 :         break;
     789             :         case SID_AUTOFORMAT:
     790             :         {
     791           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     792             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     793             : 
     794           0 :             AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh);
     795             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     796           0 :             pDlg->Execute();
     797           0 :             delete pDlg;
     798             :         }
     799           0 :         break;
     800             :         case FN_TABLE_SET_ROW_HEIGHT:
     801             :         {
     802           0 :             SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     803             :             OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     804             : 
     805           0 :             VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_ROW_HEIGHT );
     806             :             OSL_ENSURE(pDlg, "Dialogdiet fail!");
     807           0 :             pDlg->Execute();
     808           0 :             delete pDlg;
     809             :         }
     810           0 :         break;
     811             :         case FN_NUMBER_BULLETS:
     812             :         case FN_NUM_BULLET_ON:
     813             :             OSL_ENSURE( !this, "function may not be called now." );
     814           0 :         break;
     815             : 
     816             :         case FN_TABLE_INSERT_COL:
     817             :         case FN_TABLE_INSERT_ROW:
     818             :         {
     819           0 :             bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL;
     820           0 :             sal_uInt16 nCount = 0;
     821           0 :             sal_Bool bAfter = sal_True;
     822           0 :             if (pItem)
     823             :             {
     824           0 :                 nCount = ((const SfxInt16Item* )pItem)->GetValue();
     825           0 :                 if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, sal_True, &pItem))
     826           0 :                     bAfter = ((const SfxBoolItem* )pItem)->GetValue();
     827             :             }
     828           0 :             else if( !rReq.IsAPI() )
     829           0 :                 ++nCount;
     830             : 
     831           0 :             if( nCount )
     832             :             {
     833             :                 // i74180: Table border patch submitted by chensuchun:
     834             :                 // -->get the SvxBoxInfoItem of the table before insert
     835           0 :                 SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
     836           0 :                 ::lcl_TableParamToItemSet( aCoreSet, rSh );
     837           0 :                 bool bSetInnerBorders = false;
     838           0 :                 SwUndoId nUndoId = UNDO_EMPTY;
     839             :                 // <--End
     840             : 
     841           0 :                 if( bColumn )
     842             :                 {
     843           0 :                     rSh.StartUndo( UNDO_TABLE_INSCOL );
     844           0 :                     rSh.InsertCol( nCount, bAfter );
     845           0 :                     bSetInnerBorders = true;
     846           0 :                     nUndoId = UNDO_TABLE_INSCOL;
     847             :                 }
     848           0 :                 else if ( !rSh.IsInRepeatedHeadline() )
     849             :                 {
     850           0 :                     rSh.StartUndo( UNDO_TABLE_INSROW );
     851           0 :                     rSh.InsertRow( nCount, bAfter );
     852           0 :                     bSetInnerBorders = true;
     853           0 :                     nUndoId = UNDO_TABLE_INSROW;
     854             :                 }
     855             : 
     856             :                 // -->after inserting,reset the inner table borders
     857           0 :                 if ( bSetInnerBorders )
     858             :                 {
     859             :                     const SvxBoxInfoItem aBoxInfo((const SvxBoxInfoItem&)
     860           0 :                         aCoreSet.Get(SID_ATTR_BORDER_INNER));
     861           0 :                     SfxItemSet aSet( GetPool(), SID_ATTR_BORDER_INNER,
     862           0 :                                                 SID_ATTR_BORDER_INNER, 0);
     863           0 :                     aSet.Put( aBoxInfo );
     864           0 :                     ItemSetToTableParam( aSet, rSh );
     865           0 :                     rSh.EndUndo( nUndoId );
     866             :                 }
     867             : 
     868           0 :                 bCallDone = true;
     869           0 :                 break;
     870             :             }
     871             : 
     872           0 :             nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG;
     873             :         }
     874             :         // No break;  on Count = 0 appears the dialog
     875             :         case FN_TABLE_INSERT_COL_DLG:
     876             :         case FN_TABLE_INSERT_ROW_DLG:
     877             :         {
     878           0 :             const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
     879           0 :             if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
     880             :             {
     881           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     882           0 :                 ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand() ) : 0);
     883             : 
     884           0 :                 if( pDlg.get() && (pDlg->Execute() == 1) )
     885             :                 {
     886           0 :                     sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW;
     887           0 :                     SfxUInt16Item aCountItem( nDispatchSlot, static_cast< sal_uInt16 >(pDlg->getInsertCount()) );
     888           0 :                     SfxBoolItem  aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
     889           0 :                        SfxViewFrame* pVFrame = GetView().GetViewFrame();
     890           0 :                        if( pVFrame )
     891           0 :                         pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L);
     892           0 :                 }
     893             :             }
     894             :         }
     895           0 :         break;
     896             :         case FN_TABLE_SPLIT_CELLS:
     897             :         {
     898           0 :             long nCount=0;
     899           0 :             sal_Bool bHorizontal=sal_True;
     900           0 :             sal_Bool bProportional = sal_False;
     901           0 :             SFX_REQUEST_ARG( rReq, pSplit, SfxInt32Item, FN_TABLE_SPLIT_CELLS, sal_False );
     902           0 :             SFX_REQUEST_ARG( rReq, pHor, SfxBoolItem, FN_PARAM_1, sal_False );
     903           0 :             SFX_REQUEST_ARG( rReq, pProp, SfxBoolItem, FN_PARAM_2, sal_False );
     904           0 :             if ( pSplit )
     905             :             {
     906           0 :                 nCount = pSplit->GetValue();
     907           0 :                 if ( pHor )
     908           0 :                     bHorizontal = pHor->GetValue();
     909           0 :                 if ( pProp )
     910           0 :                     bProportional = pProp->GetValue();
     911             :             }
     912             :             else
     913             :             {
     914           0 :                 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     915           0 :                 if( pFact )
     916             :                 {
     917           0 :                     const long nMaxVert = rSh.GetAnyCurRect( RECT_FRM ).Width() / MINLAY;
     918           0 :                     SvxAbstractSplittTableDialog* pDlg = pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert, 99 );
     919           0 :                     if( pDlg && (pDlg->Execute() == RET_OK) )
     920             :                     {
     921           0 :                         nCount = pDlg->GetCount();
     922           0 :                         bHorizontal = pDlg->IsHorizontal();
     923           0 :                         bProportional = pDlg->IsProportional();
     924           0 :                         rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
     925           0 :                         rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
     926           0 :                         rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );
     927             :                     }
     928           0 :                     delete pDlg;
     929             :                 }
     930             :             }
     931             : 
     932           0 :             if ( nCount>1 )
     933             :             {
     934           0 :                 rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
     935           0 :                 bCallDone = true;
     936             :             }
     937             :             else
     938           0 :                 rReq.Ignore();
     939             :         }
     940           0 :         break;
     941             : 
     942             :         case FN_TABLE_SPLIT_TABLE:
     943             :         {
     944           0 :             SFX_REQUEST_ARG( rReq, pType, SfxUInt16Item, FN_PARAM_1, sal_False );
     945           0 :             if( pType )
     946             :             {
     947           0 :                 switch( pType->GetValue() )
     948             :                 {
     949             :                     case HEADLINE_NONE    :
     950             :                     case HEADLINE_BORDERCOPY:
     951             :                     case HEADLINE_CNTNTCOPY:
     952             :                     case HEADLINE_BOXATTRCOPY:
     953             :                     case HEADLINE_BOXATRCOLLCOPY:
     954           0 :                         rSh.SplitTable(pType->GetValue()) ;
     955             :                     default: ;//wrong parameter, do nothing
     956             :                 }
     957             :             }
     958             :             else
     959             :             {
     960           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     961             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     962             : 
     963           0 :                 AbstractSplitTableDialog* pDlg = pFact->CreateSplitTblDialog( GetView().GetWindow(), rSh );
     964             :                 OSL_ENSURE(pDlg, "Dialogdiet fail!");
     965           0 :                 pDlg->Execute();
     966           0 :                 rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, pDlg->GetSplitMode() ) );
     967           0 :                 delete pDlg;
     968           0 :                 bCallDone = true;
     969             :             }
     970             :         }
     971           0 :         break;
     972             : 
     973             :         case FN_TABLE_MERGE_TABLE:
     974             :         {
     975           0 :             sal_Bool bPrev = rSh.CanMergeTable( sal_True );
     976           0 :             sal_Bool bNext = rSh.CanMergeTable( sal_False );
     977             : 
     978           0 :             if( bPrev && bNext )
     979             :             {
     980           0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     981             :                 OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     982           0 :                 VclAbstractDialog* pDlg = pFact->CreateTblMergeDialog(GetView().GetWindow(), bPrev);
     983             :                 OSL_ENSURE(pDlg, "dialogdiet pDlg fail!");
     984           0 :                 if( RET_OK != pDlg->Execute())
     985           0 :                     bPrev = bNext = sal_False;
     986           0 :                 delete pDlg;
     987             :             }
     988             : 
     989           0 :             if( bPrev || bNext )
     990           0 :                 rSh.MergeTable( bPrev );
     991             :         }
     992           0 :         break;
     993             : 
     994             :         case FN_TABLE_MODE_FIX       :
     995             :         case FN_TABLE_MODE_FIX_PROP  :
     996             :         case FN_TABLE_MODE_VARIABLE  :
     997             :         {
     998             :             rSh.SetTblChgMode( ( FN_TABLE_MODE_FIX == nSlot ? TBLFIX_CHGABS
     999             :                                     : FN_TABLE_MODE_FIX_PROP == nSlot
    1000             :                                         ? TBLFIX_CHGPROP
    1001           0 :                                         : TBLVAR_CHGABS ) );
    1002             : 
    1003           0 :             SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
    1004             :             static sal_uInt16 aInva[] =
    1005             :                             {   FN_TABLE_MODE_FIX,
    1006             :                                 FN_TABLE_MODE_FIX_PROP,
    1007             :                                 FN_TABLE_MODE_VARIABLE,
    1008             :                                 0
    1009             :                             };
    1010           0 :             rBind.Invalidate( aInva );
    1011           0 :             bCallDone = true;
    1012             :         }
    1013           0 :         break;
    1014             :         case FN_TABLE_AUTOSUM:
    1015             :         {
    1016           0 :             SfxViewFrame* pVFrame = GetView().GetViewFrame();
    1017           0 :             pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SFX_CALLMODE_SYNCHRON);
    1018           0 :             const sal_uInt16 nId = SwInputChild::GetChildWindowId();
    1019             :             SwInputChild* pChildWin = (SwInputChild*)pVFrame->
    1020           0 :                                                 GetChildWindow( nId );
    1021           0 :             String sSum;
    1022           0 :             GetShell().GetAutoSum(sSum);
    1023           0 :             if( pChildWin )
    1024           0 :                 pChildWin->SetFormula( sSum );
    1025             : 
    1026             :         }
    1027           0 :         break;
    1028             :         case FN_TABLE_HEADLINE_REPEAT:
    1029           0 :             if(0 != rSh.GetRowsToRepeat())
    1030           0 :                 rSh.SetRowsToRepeat( 0 );
    1031             :             else
    1032           0 :                 rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop());
    1033           0 :         break;
    1034             :         case FN_TABLE_SELECT_CELL   :
    1035           0 :             rSh.SelectTableCell();
    1036           0 :         break;
    1037             :         case FN_TABLE_DELETE_TABLE  :
    1038             :         {
    1039           0 :             rSh.StartAction();
    1040           0 :             rSh.StartUndo();
    1041           0 :             rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
    1042           0 :             rSh.DeleteRow();
    1043           0 :             rSh.EndUndo();
    1044           0 :             rSh.EndAction();
    1045             :         }
    1046             :         //'this' is already destroyed
    1047           0 :         return;
    1048             :         //break;
    1049             :         default:
    1050           0 :             bMore = true;
    1051             :     }
    1052             : 
    1053           0 :     if ( !bMore )
    1054             :     {
    1055           0 :         if(bCallDone)
    1056           0 :             rReq.Done();
    1057           0 :         return;
    1058             :     }
    1059             :     else
    1060           0 :         bMore = false;
    1061             :     // Now the slots which are working directly on the TableFmt.
    1062           0 :     SwFrmFmt *pFmt = rSh.GetTableFmt();
    1063           0 :     switch ( nSlot )
    1064             :     {
    1065             :         case SID_ATTR_ULSPACE:
    1066             :         {
    1067           0 :             if(pItem)
    1068             :             {
    1069           0 :                 SvxULSpaceItem aULSpace( *(const SvxULSpaceItem*)pItem );
    1070           0 :                 aULSpace.SetWhich( RES_UL_SPACE );
    1071           0 :                 ::lcl_SetAttr( rSh, aULSpace );
    1072             :             }
    1073             :         }
    1074           0 :             break;
    1075             : 
    1076             :         case SID_ATTR_LRSPACE:
    1077             :         {
    1078           0 :             if(pItem)
    1079             :             {
    1080           0 :                 SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE,
    1081           0 :                                             RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
    1082           0 :                 SvxLRSpaceItem aLRSpace( *(const SvxLRSpaceItem*)pItem );
    1083           0 :                 aLRSpace.SetWhich( RES_LR_SPACE );
    1084           0 :                 aSet.Put( aLRSpace );
    1085           0 :                 SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
    1086           0 :                 aHori.SetHoriOrient( text::HoriOrientation::NONE );
    1087           0 :                 aSet.Put( aLRSpace );
    1088           0 :                 rSh.SetTblAttr( aSet );
    1089             :             }
    1090             :         }
    1091           0 :         break;
    1092             : // The last case branch which needs a table manager!!
    1093             :         case FN_TABLE_SET_COL_WIDTH:
    1094             :         {
    1095           0 :             SwTableFUNC aMgr( &rSh, sal_False);
    1096           0 :             aMgr.ColWidthDlg(GetView().GetWindow());
    1097             :         }
    1098           0 :         break;
    1099             :         case SID_TABLE_VERT_NONE:
    1100             :         case SID_TABLE_VERT_CENTER:
    1101             :         case SID_TABLE_VERT_BOTTOM:
    1102             :         {
    1103             :                 sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
    1104             :                                 text::VertOrientation::NONE :
    1105             :                                     nSlot == SID_TABLE_VERT_CENTER ?
    1106           0 :                                         text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
    1107           0 :             rSh.SetBoxAlign(nAlign);
    1108           0 :             bCallDone = true;
    1109             :         }
    1110           0 :         break;
    1111             : 
    1112             :         case SID_ATTR_PARA_SPLIT:
    1113           0 :             if ( pItem )
    1114             :             {
    1115           0 :                 SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue());
    1116           0 :                 SfxItemSet aSet(GetPool(),  RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 );
    1117           0 :                 aSet.Put(aSplit);
    1118           0 :                 rSh.SetTblAttr(aSet);
    1119             :             }
    1120           0 :         break;
    1121             : 
    1122             :         case SID_ATTR_PARA_KEEP:
    1123           0 :             if ( pItem )
    1124             :             {
    1125           0 :                 SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem );
    1126           0 :                 aKeep.SetWhich( RES_KEEP );
    1127           0 :                 SfxItemSet aSet(GetPool(),  RES_KEEP, RES_KEEP, 0 );
    1128           0 :                 aSet.Put(aKeep);
    1129           0 :                 rSh.SetTblAttr(aSet);
    1130             :             }
    1131           0 :         break;
    1132             :         case FN_TABLE_ROW_SPLIT :
    1133             :         {
    1134           0 :             const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
    1135           0 :             SwFmtRowSplit* pSplit = 0;
    1136           0 :             if(!pBool)
    1137             :             {
    1138           0 :                 rSh.GetRowSplit(pSplit);
    1139           0 :                 if(pSplit)
    1140           0 :                     pSplit->SetValue(!pSplit->GetValue());
    1141             :                 else
    1142           0 :                    pSplit = new SwFmtRowSplit(sal_True);
    1143             :             }
    1144             :             else
    1145             :             {
    1146           0 :                 pSplit = new SwFmtRowSplit(pBool->GetValue());
    1147             :             }
    1148           0 :             rSh.SetRowSplit( *pSplit );
    1149           0 :             delete pSplit;
    1150             :         }
    1151           0 :         break;
    1152             : 
    1153             :         default:
    1154             :             OSL_ENSURE( !this, "wrong Dispatcher" );
    1155           0 :             return;
    1156             :     }
    1157           0 :     if(bCallDone)
    1158           0 :         rReq.Done();
    1159             : }
    1160             : 
    1161          18 : void SwTableShell::GetState(SfxItemSet &rSet)
    1162             : {
    1163          18 :     SfxWhichIter aIter( rSet );
    1164          18 :     SwWrtShell &rSh = GetShell();
    1165          18 :     SwFrmFmt *pFmt = rSh.GetTableFmt();
    1166             :     // os #124829# crash report: in case of an invalid shell selection return immediately
    1167          18 :     if(!pFmt)
    1168          18 :         return;
    1169          18 :     sal_uInt16 nSlot = aIter.FirstWhich();
    1170          70 :     while ( nSlot )
    1171             :     {
    1172          34 :         switch ( nSlot )
    1173             :         {
    1174             :             case FN_TABLE_MERGE_CELLS:
    1175           4 :                 if ( !rSh.IsTableMode() )
    1176           1 :                     rSet.DisableItem(FN_TABLE_MERGE_CELLS);
    1177           4 :             break;
    1178             :             case FN_TABLE_ADJUST_CELLS:
    1179           0 :                 if ( !rSh.IsAdjustCellWidthAllowed() )
    1180           0 :                     rSet.DisableItem(FN_TABLE_ADJUST_CELLS);
    1181           0 :             break;
    1182             : 
    1183             :             case FN_TABLE_BALANCE_CELLS:
    1184           0 :                 if ( !rSh.IsAdjustCellWidthAllowed(sal_True) )
    1185           0 :                     rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
    1186           0 :             break;
    1187             : 
    1188             :             case FN_TABLE_BALANCE_ROWS:
    1189           0 :                 if ( !rSh.BalanceRowHeight(sal_True) )
    1190           0 :                     rSet.DisableItem(FN_TABLE_BALANCE_ROWS);
    1191           0 :             break;
    1192             :             case FN_OPTIMIZE_TABLE:
    1193           9 :                 if ( !rSh.IsTableMode() &&
    1194           2 :                         !rSh.IsAdjustCellWidthAllowed() &&
    1195           6 :                         !rSh.IsAdjustCellWidthAllowed(sal_True) &&
    1196           1 :                         !rSh.BalanceRowHeight(sal_True) )
    1197           1 :                     rSet.DisableItem(FN_OPTIMIZE_TABLE);
    1198           4 :             break;
    1199             :             case SID_INSERT_DIAGRAM:
    1200             :                 {
    1201           0 :                     SvtModuleOptions aMOpt;
    1202           0 :                     if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() )
    1203           0 :                         rSet.DisableItem(nSlot);
    1204             :                 }
    1205           0 :                 break;
    1206             : 
    1207             :             case FN_INSERT_TABLE:
    1208             :                 // Put any value, so that the controller remains enabled.
    1209             :                 // Instead "Insert:Table" appears "Format:Table".
    1210           2 :                 break;
    1211             : 
    1212             :             case FN_TABLE_OPTIMAL_HEIGHT:
    1213             :             {
    1214             :                 // Disable if auto height already is enabled.
    1215             :                 SwFmtFrmSize *pSz;
    1216           0 :                 rSh.GetRowHeight( pSz );
    1217           0 :                 if ( pSz )
    1218             :                 {
    1219           0 :                     if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() )
    1220           0 :                         rSet.DisableItem( nSlot );
    1221           0 :                     delete pSz;
    1222             :                 }
    1223             :             }
    1224           0 :             break;
    1225             :             case FN_TABLE_INSERT_ROW:
    1226             :             case FN_TABLE_INSERT_ROW_DLG:
    1227             :             {
    1228           4 :                 if ( rSh.IsInRepeatedHeadline() )
    1229           0 :                     rSet.DisableItem( nSlot );
    1230             :             }
    1231           4 :             break;
    1232             :             case RES_LR_SPACE:
    1233           0 :                 rSet.Put(pFmt->GetLRSpace());
    1234           0 :             break;
    1235             :             case RES_UL_SPACE:
    1236           0 :                 rSet.Put(pFmt->GetULSpace());
    1237           0 :             break;
    1238             : 
    1239             :             case SID_TABLE_VERT_NONE:
    1240             :             case SID_TABLE_VERT_CENTER:
    1241             :             case SID_TABLE_VERT_BOTTOM:
    1242             :             {
    1243          12 :                 sal_uInt16 nAlign = rSh.GetBoxAlign();
    1244          24 :                 sal_Bool bSet = nSlot == (SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
    1245          16 :                             (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
    1246          16 :                             (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
    1247          12 :                 rSet.Put(SfxBoolItem(nSlot, bSet));
    1248             :             }
    1249          12 :             break;
    1250             : 
    1251             :             case FN_TABLE_MODE_FIX       :
    1252             :             case FN_TABLE_MODE_FIX_PROP  :
    1253             :             case FN_TABLE_MODE_VARIABLE  :
    1254             :                 {
    1255           0 :                     TblChgMode nMode = rSh.GetTblChgMode();
    1256           0 :                     sal_Bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS) ||
    1257           0 :                             (nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP) ||
    1258           0 :                             (nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS);
    1259           0 :                     rSet.Put(SfxBoolItem(nSlot, bSet));
    1260             :                 }
    1261           0 :             break;
    1262             : 
    1263             :             case SID_ATTR_PARA_SPLIT:
    1264           0 :                 rSet.Put( pFmt->GetKeep() );
    1265           0 :             break;
    1266             : 
    1267             :             case SID_ATTR_PARA_KEEP:
    1268           0 :                 rSet.Put( pFmt->GetLayoutSplit() );
    1269           0 :             break;
    1270             :             case FN_TABLE_SPLIT_TABLE:
    1271             :             {
    1272           0 :                 if ( rSh.IsInHeadline() )
    1273           0 :                     rSet.DisableItem( nSlot );
    1274             :             }
    1275           0 :             break;
    1276             :             case FN_TABLE_MERGE_TABLE:
    1277             :             {
    1278             :                 sal_Bool bAsk;
    1279           0 :                 if( !rSh.CanMergeTable( sal_True, &bAsk ))
    1280           0 :                     rSet.DisableItem( nSlot );
    1281             :             }
    1282           0 :             break;
    1283             : 
    1284             :             case FN_TABLE_DELETE_ROW:
    1285             :                 {
    1286           4 :                     SwSelBoxes aBoxes;
    1287           4 :                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
    1288           4 :                     if( ::HasProtectedCells( aBoxes ))
    1289           0 :                         rSet.DisableItem( nSlot );
    1290             :                 }
    1291           4 :                 break;
    1292             :             case FN_TABLE_DELETE_COL:
    1293             :                 {
    1294           4 :                     SwSelBoxes aBoxes;
    1295           4 :                     ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
    1296           4 :                     if( ::HasProtectedCells( aBoxes ))
    1297           0 :                         rSet.DisableItem( nSlot );
    1298             :                 }
    1299           4 :                 break;
    1300             : 
    1301             :             case FN_TABLE_UNSET_READ_ONLY_CELLS:
    1302             :                 // disable in readonly sections, but enable in protected cells
    1303           0 :                 if( !rSh.CanUnProtectCells() )
    1304           0 :                     rSet.DisableItem( nSlot );
    1305           0 :                 break;
    1306             :             case RES_ROW_SPLIT:
    1307             :             {
    1308           0 :                 const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit();
    1309           0 :                 if ( 0 == rTabSplit.GetValue() )
    1310             :                 {
    1311           0 :                     rSet.DisableItem( nSlot );
    1312             :                 }
    1313             :                 else
    1314             :                 {
    1315           0 :                     SwFmtRowSplit* pSplit = 0;
    1316           0 :                     rSh.GetRowSplit(pSplit);
    1317           0 :                     if(pSplit)
    1318           0 :                         rSet.Put(*pSplit);
    1319             :                     else
    1320           0 :                         rSet.InvalidateItem( nSlot );
    1321           0 :                     delete pSplit;
    1322             :                 }
    1323             :             }
    1324           0 :             break;
    1325             :             case FN_TABLE_HEADLINE_REPEAT:
    1326           0 :                 if(0 != rSh.GetRowsToRepeat())
    1327           0 :                     rSet.Put(SfxBoolItem(nSlot, sal_True));
    1328           0 :                 else if(!rSh.GetRowSelectionFromTop())
    1329           0 :                     rSet.DisableItem( nSlot );
    1330             :                 else
    1331           0 :                     rSet.Put(SfxBoolItem(nSlot, sal_False));
    1332           0 :             break;
    1333             :             case FN_TABLE_SELECT_CELL   :
    1334           0 :                 if(rSh.HasBoxSelection())
    1335           0 :                     rSet.DisableItem( nSlot );
    1336           0 :             break;
    1337             :         }
    1338          34 :     nSlot = aIter.NextWhich();
    1339          18 :     }
    1340             : }
    1341             : 
    1342          40 : SwTableShell::SwTableShell(SwView &_rView) :
    1343          40 :     SwBaseShell(_rView)
    1344             : {
    1345          40 :     SetName(OUString("Table"));
    1346          40 :     SetHelpId(SW_TABSHELL);
    1347          40 :     SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
    1348          40 : }
    1349             : 
    1350           4 : void SwTableShell::GetFrmBorderState(SfxItemSet &rSet)
    1351             : {
    1352           4 :     SfxItemSet aCoreSet( GetPool(),
    1353             :                          RES_BOX, RES_BOX,
    1354           4 :                          SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
    1355           8 :     SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
    1356           4 :     aCoreSet.Put( aBoxInfo );
    1357           4 :     GetShell().GetTabBorders( aCoreSet );
    1358           8 :     rSet.Put( aCoreSet );
    1359           4 : }
    1360             : 
    1361           0 : void SwTableShell::ExecTableStyle(SfxRequest& rReq)
    1362             : {
    1363           0 :     SwWrtShell &rSh = GetShell();
    1364           0 :     const SfxItemSet *pArgs = rReq.GetArgs();
    1365           0 :     if(pArgs)
    1366           0 :         switch ( rReq.GetSlot() )
    1367             :         {
    1368             :             case SID_FRAME_LINESTYLE:
    1369             :             case SID_FRAME_LINECOLOR:
    1370             :             {
    1371           0 :                 if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
    1372             :                 {
    1373             :                     const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs->
    1374           0 :                                                             Get( SID_FRAME_LINESTYLE );
    1375           0 :                     const SvxBorderLine* pBorderLine = rLineItem.GetLine();
    1376           0 :                     rSh.SetTabLineStyle( 0, sal_True, pBorderLine);
    1377             :                 }
    1378             :                 else
    1379             :                 {
    1380             :                     const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs->
    1381           0 :                                                             Get( SID_FRAME_LINECOLOR );
    1382           0 :                     rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
    1383             :                 }
    1384             : 
    1385           0 :                 rReq.Done();
    1386             : 
    1387           0 :                 break;
    1388             :             }
    1389             :         }
    1390           0 : }
    1391             : 
    1392           6 : void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
    1393             : {
    1394           6 :     SfxItemSet aCoreSet( GetPool(),
    1395             :                             RES_BOX, RES_BOX,
    1396           6 :                             SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0);
    1397          12 :     SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
    1398           6 :     aCoreSet.Put(aCoreInfo);
    1399           6 :     GetShell().GetTabBorders( aCoreSet );
    1400             : 
    1401           6 :     const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX );
    1402           6 :     const SvxBorderLine* pLine = rBoxItem.GetTop();
    1403             : 
    1404           6 :     rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
    1405          12 :     SvxLineItem aLine( SID_FRAME_LINESTYLE );
    1406           6 :     aLine.SetLine(pLine);
    1407          12 :     rSet.Put( aLine );
    1408           6 : }
    1409             : 
    1410           0 : void SwTableShell::ExecNumberFormat(SfxRequest& rReq)
    1411             : {
    1412           0 :     const SfxItemSet* pArgs = rReq.GetArgs();
    1413           0 :     SwWrtShell &rSh = GetShell();
    1414             : 
    1415             :     // At first the slots, which doesn't need a FrmMgr.
    1416           0 :     const SfxPoolItem* pItem = 0;
    1417           0 :     sal_uInt16 nSlot = rReq.GetSlot();
    1418           0 :     if(pArgs)
    1419           0 :         pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
    1420             : 
    1421             :     // Always aquire the language from the current cursor position.
    1422           0 :     LanguageType eLang = rSh.GetCurLang();
    1423           0 :     SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
    1424           0 :     sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
    1425           0 :     sal_uInt16 nFmtType = 0, nOffset = 0;
    1426             : 
    1427           0 :     switch ( nSlot )
    1428             :     {
    1429             :     case FN_NUMBER_FORMAT:
    1430           0 :         if( pItem )
    1431             :         {
    1432             :             // Determine index for string.
    1433           0 :             OUString aCode( ((const SfxStringItem*)pItem)->GetValue() );
    1434           0 :             nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
    1435           0 :             if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
    1436             :             {
    1437             :                 // Re-enter
    1438             :                 sal_Int32 nErrPos;
    1439             :                 short nType;
    1440           0 :                 if( !pFormatter->PutEntry( aCode, nErrPos, nType,
    1441           0 :                                             nNumberFormat, eLang ))
    1442           0 :                     nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
    1443           0 :             }
    1444             :         }
    1445           0 :         break;
    1446           0 :     case FN_NUMBER_STANDARD:        nFmtType = NUMBERFORMAT_NUMBER; break;
    1447           0 :     case FN_NUMBER_SCIENTIFIC:      nFmtType = NUMBERFORMAT_SCIENTIFIC; break;
    1448           0 :     case FN_NUMBER_DATE:            nFmtType = NUMBERFORMAT_DATE; break;
    1449           0 :     case FN_NUMBER_TIME:            nFmtType = NUMBERFORMAT_TIME; break;
    1450           0 :     case FN_NUMBER_CURRENCY:        nFmtType = NUMBERFORMAT_CURRENCY; break;
    1451           0 :     case FN_NUMBER_PERCENT:         nFmtType = NUMBERFORMAT_PERCENT; break;
    1452             : 
    1453             :     case FN_NUMBER_TWODEC:          // #.##0,00
    1454           0 :         nFmtType = NUMBERFORMAT_NUMBER;
    1455           0 :         nOffset = NF_NUMBER_1000DEC2;
    1456           0 :         break;
    1457             : 
    1458             :     default:
    1459             :         OSL_FAIL("wrong dispatcher");
    1460           0 :         return;
    1461             :     }
    1462             : 
    1463           0 :     if( nFmtType )
    1464           0 :         nNumberFormat = pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset;
    1465             : 
    1466           0 :     if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
    1467             :     {
    1468           0 :         SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
    1469           0 :         aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat ));
    1470           0 :         rSh.SetTblBoxFormulaAttrs( aBoxSet );
    1471             :     }
    1472             : 
    1473          99 : }
    1474             : 
    1475             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10