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

Generated by: LCOV version 1.11