1efeef26fSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file
5efeef26fSAndrew Rist * distributed with this work for additional information
6efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the
8efeef26fSAndrew Rist * "License"); you may not use this file except in compliance
9efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at
10efeef26fSAndrew Rist *
11efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12efeef26fSAndrew Rist *
13efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing,
14efeef26fSAndrew Rist * software distributed under the License is distributed on an
15efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16efeef26fSAndrew Rist * KIND, either express or implied. See the License for the
17efeef26fSAndrew Rist * specific language governing permissions and limitations
18efeef26fSAndrew Rist * under the License.
19efeef26fSAndrew Rist *
20efeef26fSAndrew Rist *************************************************************/
21efeef26fSAndrew Rist
22efeef26fSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sw.hxx"
26cdf0e10cSrcweir #include <hintids.hxx>
27cdf0e10cSrcweir
28cdf0e10cSrcweir #ifndef _ZFORLIST_HXX
29cdf0e10cSrcweir #define _ZFORLIST_DECLARE_TABLE
30cdf0e10cSrcweir #include <svl/zforlist.hxx>
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #include <svl/stritem.hxx>
33cdf0e10cSrcweir #include <svl/whiter.hxx>
34cdf0e10cSrcweir #include <unotools/moduleoptions.hxx>
35cdf0e10cSrcweir #include <svx/rulritem.hxx>
36cdf0e10cSrcweir #include <svl/srchitem.hxx>
37cdf0e10cSrcweir #include <editeng/lrspitem.hxx>
38cdf0e10cSrcweir #include <editeng/ulspitem.hxx>
39cdf0e10cSrcweir #include <editeng/brshitem.hxx>
40cdf0e10cSrcweir #include <editeng/boxitem.hxx>
41cdf0e10cSrcweir #include <editeng/shaditem.hxx>
42cdf0e10cSrcweir #include <editeng/spltitem.hxx>
43cdf0e10cSrcweir #include <editeng/langitem.hxx>
44cdf0e10cSrcweir #include <editeng/keepitem.hxx>
45cdf0e10cSrcweir #include <editeng/bolnitem.hxx>
46cdf0e10cSrcweir #include <editeng/colritem.hxx>
47cdf0e10cSrcweir #include <editeng/frmdiritem.hxx>
48cdf0e10cSrcweir #include <svx/numinf.hxx>
49cdf0e10cSrcweir #include <svx/svddef.hxx>
50cdf0e10cSrcweir #include <svx/svxdlg.hxx>
51cdf0e10cSrcweir #include <svl/zformat.hxx>
52cdf0e10cSrcweir #include <sfx2/bindings.hxx>
53cdf0e10cSrcweir #include <vcl/msgbox.hxx>
54cdf0e10cSrcweir #include <sfx2/request.hxx>
55cdf0e10cSrcweir #include <sfx2/dispatch.hxx>
56cdf0e10cSrcweir #include <sfx2/objface.hxx>
57f120fe41SAndre Fischer #include <sfx2/sidebar/EnumContext.hxx>
58cdf0e10cSrcweir
59cdf0e10cSrcweir
60cdf0e10cSrcweir #include <fmtornt.hxx>
61cdf0e10cSrcweir #include <fmtclds.hxx>
62cdf0e10cSrcweir #include <fmtlsplt.hxx>
63cdf0e10cSrcweir #include <fmtrowsplt.hxx>
64cdf0e10cSrcweir #include <fmtfsize.hxx>
65cdf0e10cSrcweir #include <swmodule.hxx>
66cdf0e10cSrcweir #include <wrtsh.hxx>
67cdf0e10cSrcweir #include <wview.hxx>
68cdf0e10cSrcweir #include <frmatr.hxx>
69cdf0e10cSrcweir #include <uitool.hxx>
70cdf0e10cSrcweir #include <inputwin.hxx>
71cdf0e10cSrcweir #include <uiitems.hxx>
72cdf0e10cSrcweir #include <usrpref.hxx>
73cdf0e10cSrcweir #include <tabsh.hxx>
74cdf0e10cSrcweir #include "swtablerep.hxx"
75cdf0e10cSrcweir #include <tablemgr.hxx>
76cdf0e10cSrcweir #include <cellatr.hxx>
77cdf0e10cSrcweir #include <frmfmt.hxx>
78cdf0e10cSrcweir #include <swundo.hxx>
79cdf0e10cSrcweir #include <swtable.hxx>
80cdf0e10cSrcweir #include <docsh.hxx>
81cdf0e10cSrcweir #include <tblsel.hxx>
82cdf0e10cSrcweir
83cdf0e10cSrcweir #include <dialog.hrc>
84cdf0e10cSrcweir
85cdf0e10cSrcweir
86cdf0e10cSrcweir
87cdf0e10cSrcweir //!!! new: insert table
88cdf0e10cSrcweir /*
89cdf0e10cSrcweir #include <svx/htmlmode.hxx>
90cdf0e10cSrcweir #include <modcfg.hxx>
91cdf0e10cSrcweir #include <tblafmt.hxx>
92cdf0e10cSrcweir #include <instable.hxx>
93cdf0e10cSrcweir */
94cdf0e10cSrcweir //!!!
95cdf0e10cSrcweir
96cdf0e10cSrcweir #ifndef _POPUP_HRC
97cdf0e10cSrcweir #include <popup.hrc>
98cdf0e10cSrcweir #endif
99cdf0e10cSrcweir #ifndef _SHELLS_HRC
100cdf0e10cSrcweir #include <shells.hrc>
101cdf0e10cSrcweir #endif
102cdf0e10cSrcweir #ifndef _TABLE_HRC
103cdf0e10cSrcweir #include <table.hrc>
104cdf0e10cSrcweir #endif
105cdf0e10cSrcweir #include <cmdid.h>
106cdf0e10cSrcweir #ifndef _GLOBALS_HRC
107cdf0e10cSrcweir #include <globals.hrc>
108cdf0e10cSrcweir #endif
109cdf0e10cSrcweir #include <helpid.h>
110cdf0e10cSrcweir #include <unobaseclass.hxx>
111cdf0e10cSrcweir
112cdf0e10cSrcweir #define SwTableShell
113cdf0e10cSrcweir #include <sfx2/msg.hxx>
114cdf0e10cSrcweir #include <swslots.hxx>
115cdf0e10cSrcweir
116cdf0e10cSrcweir #include "swabstdlg.hxx"
117cdf0e10cSrcweir #include <table.hrc>
118cdf0e10cSrcweir
119cdf0e10cSrcweir using namespace ::com::sun::star;
120cdf0e10cSrcweir
121cdf0e10cSrcweir //-----------------------------------------------------------------------------
122cdf0e10cSrcweir
SFX_IMPL_INTERFACE(SwTableShell,SwBaseShell,SW_RES (STR_SHELLNAME_TABLE))123cdf0e10cSrcweir SFX_IMPL_INTERFACE(SwTableShell, SwBaseShell, SW_RES(STR_SHELLNAME_TABLE))
124cdf0e10cSrcweir {
125cdf0e10cSrcweir SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU));
126cdf0e10cSrcweir SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_TABLE_TOOLBOX));
127cdf0e10cSrcweir }
128cdf0e10cSrcweir
129cdf0e10cSrcweir
130cdf0e10cSrcweir TYPEINIT1(SwTableShell,SwBaseShell)
131cdf0e10cSrcweir
132cdf0e10cSrcweir /************************************************************************/
133cdf0e10cSrcweir
134cdf0e10cSrcweir const sal_uInt16 __FAR_DATA aUITableAttrRange[] =
135cdf0e10cSrcweir {
136cdf0e10cSrcweir FN_PARAM_TABLE_NAME, FN_PARAM_TABLE_NAME,
137cdf0e10cSrcweir FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE,
138cdf0e10cSrcweir FN_PARAM_TABLE_SPACE, FN_PARAM_TABLE_SPACE,
139cdf0e10cSrcweir FN_TABLE_REP, FN_TABLE_REP,
140cdf0e10cSrcweir SID_RULER_BORDERS, SID_RULER_BORDERS,
141cdf0e10cSrcweir RES_LR_SPACE, RES_UL_SPACE,
142cdf0e10cSrcweir SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
143cdf0e10cSrcweir RES_BOX, RES_SHADOW,
144cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND,
145cdf0e10cSrcweir SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION,
146cdf0e10cSrcweir SID_HTML_MODE, SID_HTML_MODE,
147cdf0e10cSrcweir SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
148cdf0e10cSrcweir RES_PAGEDESC, RES_BREAK,
149cdf0e10cSrcweir RES_KEEP, RES_KEEP,
150cdf0e10cSrcweir RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT,
151cdf0e10cSrcweir FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN,
152cdf0e10cSrcweir RES_FRAMEDIR, RES_FRAMEDIR,
153cdf0e10cSrcweir RES_ROW_SPLIT, RES_ROW_SPLIT,
154cdf0e10cSrcweir FN_TABLE_BOX_TEXTDIRECTION, FN_TABLE_BOX_TEXTDIRECTION,
155cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
156cdf0e10cSrcweir RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS,
157cdf0e10cSrcweir // <-- collapsing borders
158cdf0e10cSrcweir 0
159cdf0e10cSrcweir };
160cdf0e10cSrcweir
SwuiGetUITableAttrRange()161cdf0e10cSrcweir const sal_uInt16* SwuiGetUITableAttrRange()
162cdf0e10cSrcweir {
163cdf0e10cSrcweir return aUITableAttrRange;
164cdf0e10cSrcweir }
165cdf0e10cSrcweir
lcl_SetAttr(SwWrtShell & rSh,const SfxPoolItem & rItem)166cdf0e10cSrcweir static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
167cdf0e10cSrcweir {
168cdf0e10cSrcweir SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which(), 0);
169cdf0e10cSrcweir aSet.Put( rItem );
170cdf0e10cSrcweir rSh.SetTblAttr( aSet );
171cdf0e10cSrcweir }
172cdf0e10cSrcweir
173cdf0e10cSrcweir /************************************************************************/
174cdf0e10cSrcweir
175cdf0e10cSrcweir
lcl_TableParamToItemSet(SfxItemSet & rSet,SwWrtShell & rSh)176cdf0e10cSrcweir static SwTableRep* lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
177cdf0e10cSrcweir {
178cdf0e10cSrcweir SwFrmFmt *pFmt = rSh.GetTableFmt();
179cdf0e10cSrcweir SwTabCols aCols;
180cdf0e10cSrcweir rSh.GetTabCols( aCols );
181cdf0e10cSrcweir
182cdf0e10cSrcweir //Ersteinmal die einfachen Attribute besorgen.
183cdf0e10cSrcweir rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFmt->GetName()));
184cdf0e10cSrcweir rSet.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE, rSh.GetRowsToRepeat() ) );
185cdf0e10cSrcweir rSet.Put( pFmt->GetShadow() );
186cdf0e10cSrcweir rSet.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN, rSh.GetBoxAlign()));
187cdf0e10cSrcweir rSet.Put( pFmt->GetFrmDir() );
188cdf0e10cSrcweir
189cdf0e10cSrcweir SvxULSpaceItem aULSpace( pFmt->GetULSpace() );
190cdf0e10cSrcweir rSet.Put( aULSpace );
191cdf0e10cSrcweir
192cdf0e10cSrcweir sal_uInt16 nBackgroundDestination = rSh.GetViewOptions()->GetTblDest();
193cdf0e10cSrcweir rSet.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
194cdf0e10cSrcweir SvxBrushItem aBrush( RES_BACKGROUND );
195cdf0e10cSrcweir // rSh.GetBoxBackground(aBrush);
196cdf0e10cSrcweir // rSet.Put( aBrush );
197cdf0e10cSrcweir if(rSh.GetRowBackground(aBrush))
198cdf0e10cSrcweir rSet.Put( aBrush, SID_ATTR_BRUSH_ROW );
199cdf0e10cSrcweir else
200cdf0e10cSrcweir rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
201cdf0e10cSrcweir rSh.GetTabBackground(aBrush);
202cdf0e10cSrcweir rSet.Put( aBrush, SID_ATTR_BRUSH_TABLE );
203cdf0e10cSrcweir
204cdf0e10cSrcweir // text direction in boxes
205cdf0e10cSrcweir SvxFrameDirectionItem aBoxDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
206cdf0e10cSrcweir if(rSh.GetBoxDirection( aBoxDirection ))
207cdf0e10cSrcweir rSet.Put(aBoxDirection, FN_TABLE_BOX_TEXTDIRECTION);
208cdf0e10cSrcweir
209cdf0e10cSrcweir sal_Bool bTableSel = rSh.IsTableMode();
210cdf0e10cSrcweir if(!bTableSel)
211cdf0e10cSrcweir {
212cdf0e10cSrcweir rSh.StartAllAction();
213cdf0e10cSrcweir rSh.Push();
214cdf0e10cSrcweir rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL, sal_False );
215cdf0e10cSrcweir }
216cdf0e10cSrcweir SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
217cdf0e10cSrcweir
218cdf0e10cSrcweir // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
219cdf0e10cSrcweir rSh.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert
220cdf0e10cSrcweir aBoxInfo.SetTable ((rSh.IsTableMode() && rSh.GetCrsrCnt() > 1) ||
221cdf0e10cSrcweir !bTableSel);
222cdf0e10cSrcweir // Abstandsfeld immer anzeigen
223cdf0e10cSrcweir aBoxInfo.SetDist ((sal_Bool) sal_True);
224cdf0e10cSrcweir // Minimalgroesse in Tabellen und Absaetzen setzen
225cdf0e10cSrcweir aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
226cdf0e10cSrcweir rSh.GetSelectionType() &
227cdf0e10cSrcweir (nsSelectionType::SEL_TXT | nsSelectionType::SEL_TBL));
228cdf0e10cSrcweir // Default-Abstand immer setzen
229cdf0e10cSrcweir aBoxInfo.SetDefDist (MIN_BORDER_DIST);
230cdf0e10cSrcweir // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
231cdf0e10cSrcweir aBoxInfo.SetValid( VALID_DISABLE, !bTableSel || !rSh.IsTableMode() );
232cdf0e10cSrcweir
233cdf0e10cSrcweir rSet.Put(aBoxInfo);
234cdf0e10cSrcweir rSh.GetTabBorders( rSet );
235cdf0e10cSrcweir
236cdf0e10cSrcweir //row split
237cdf0e10cSrcweir SwFmtRowSplit* pSplit = 0;
238cdf0e10cSrcweir rSh.GetRowSplit(pSplit);
239cdf0e10cSrcweir if(pSplit)
240cdf0e10cSrcweir {
241cdf0e10cSrcweir rSet.Put(*pSplit);
242cdf0e10cSrcweir delete pSplit;
243cdf0e10cSrcweir }
244cdf0e10cSrcweir
245cdf0e10cSrcweir if(!bTableSel)
246cdf0e10cSrcweir {
247cdf0e10cSrcweir rSh.ClearMark();
248cdf0e10cSrcweir rSh.Pop(sal_False);
249cdf0e10cSrcweir rSh.EndAllAction();
250cdf0e10cSrcweir }
251cdf0e10cSrcweir
252cdf0e10cSrcweir SwTabCols aTabCols;
253cdf0e10cSrcweir rSh.GetTabCols( aTabCols );
254cdf0e10cSrcweir SvxColumnItem aColItem;
255cdf0e10cSrcweir
256cdf0e10cSrcweir
257cdf0e10cSrcweir // Pointer wird nach der Dialogausfuehrung geloescht
258cdf0e10cSrcweir SwTableRep* pRep = new SwTableRep( aTabCols, rSh.IsTblComplex());
259cdf0e10cSrcweir pRep->SetSpace(aCols.GetRightMax());
260cdf0e10cSrcweir
261cdf0e10cSrcweir sal_uInt16 nPercent = 0;
262cdf0e10cSrcweir long nWidth = ::GetTableWidth(pFmt, aCols, &nPercent, &rSh );
263cdf0e10cSrcweir // Die Tabellenbreite ist fuer relative Angaben nicht korrekt
264cdf0e10cSrcweir if(nPercent)
265cdf0e10cSrcweir nWidth = pRep->GetSpace() * nPercent / 100;
266cdf0e10cSrcweir sal_uInt16 nAlign = pFmt->GetHoriOrient().GetHoriOrient();
267cdf0e10cSrcweir pRep->SetAlign(nAlign);
268cdf0e10cSrcweir SvxLRSpaceItem aLRSpace( pFmt->GetLRSpace() );
269cdf0e10cSrcweir SwTwips nLeft = aLRSpace.GetLeft();
270cdf0e10cSrcweir SwTwips nRight = aLRSpace.GetRight();
271cdf0e10cSrcweir SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
272cdf0e10cSrcweir if(nAlign != text::HoriOrientation::FULL && Abs(nDiff) > 2)
273cdf0e10cSrcweir {
274cdf0e10cSrcweir SwTwips nLR = pRep->GetSpace() - nWidth;
275cdf0e10cSrcweir switch ( nAlign )
276cdf0e10cSrcweir {
277cdf0e10cSrcweir case text::HoriOrientation::CENTER: nLeft = nRight = nLR / 2;
278cdf0e10cSrcweir break;
279cdf0e10cSrcweir case text::HoriOrientation::LEFT: nRight = nLR; nLeft = 0;
280cdf0e10cSrcweir break;
281cdf0e10cSrcweir case text::HoriOrientation::RIGHT: nLeft = nLR, nRight = 0;
282cdf0e10cSrcweir break;
283cdf0e10cSrcweir case text::HoriOrientation::LEFT_AND_WIDTH:
284cdf0e10cSrcweir nRight = nLR - nLeft;
285cdf0e10cSrcweir break;
286cdf0e10cSrcweir case text::HoriOrientation::NONE:
287cdf0e10cSrcweir if(!nPercent)
288cdf0e10cSrcweir nWidth = pRep->GetSpace() - nLeft - nRight;
289cdf0e10cSrcweir break;
290cdf0e10cSrcweir }
291cdf0e10cSrcweir }
292cdf0e10cSrcweir pRep->SetLeftSpace(nLeft);
293cdf0e10cSrcweir pRep->SetRightSpace(nRight);
294cdf0e10cSrcweir
295cdf0e10cSrcweir pRep->SetWidth(nWidth);
296cdf0e10cSrcweir pRep->SetWidthPercent(nPercent);
297cdf0e10cSrcweir // sind einzelne Zeilen/Zellen selektiert, wird die Spaltenbearbeitung veraendert
298cdf0e10cSrcweir pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
299cdf0e10cSrcweir rSet.Put(SwPtrItem(FN_TABLE_REP, pRep));
300cdf0e10cSrcweir return pRep;
301cdf0e10cSrcweir }
302cdf0e10cSrcweir
303cdf0e10cSrcweir /************************************************************************/
304cdf0e10cSrcweir
305cdf0e10cSrcweir
ItemSetToTableParam(const SfxItemSet & rSet,SwWrtShell & rSh)306cdf0e10cSrcweir void ItemSetToTableParam( const SfxItemSet& rSet,
307cdf0e10cSrcweir SwWrtShell &rSh )
308cdf0e10cSrcweir {
309cdf0e10cSrcweir rSh.StartAllAction();
310cdf0e10cSrcweir rSh.StartUndo( UNDO_TABLE_ATTR );
311cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
312cdf0e10cSrcweir
313cdf0e10cSrcweir SwViewOption aUsrPref( *rSh.GetViewOptions() );
314cdf0e10cSrcweir sal_uInt16 nBackgroundDestination = aUsrPref.GetTblDest();
315cdf0e10cSrcweir if(SFX_ITEM_SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, sal_False, &pItem))
316cdf0e10cSrcweir {
317cdf0e10cSrcweir nBackgroundDestination = ((SfxUInt16Item*)pItem)->GetValue();
318cdf0e10cSrcweir aUsrPref.SetTblDest((sal_uInt8)nBackgroundDestination);
319cdf0e10cSrcweir SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
320cdf0e10cSrcweir }
321cdf0e10cSrcweir sal_Bool bBorder = ( SFX_ITEM_SET == rSet.GetItemState( RES_BOX ) ||
322cdf0e10cSrcweir SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
323cdf0e10cSrcweir pItem = 0;
324cdf0e10cSrcweir sal_Bool bBackground = SFX_ITEM_SET == rSet.GetItemState( RES_BACKGROUND, sal_False, &pItem );
325cdf0e10cSrcweir const SfxPoolItem* pRowItem = 0, *pTableItem = 0;
326cdf0e10cSrcweir bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, sal_False, &pRowItem );
327cdf0e10cSrcweir bBackground |= SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, sal_False, &pTableItem );
328cdf0e10cSrcweir const SfxPoolItem* pSplit = 0;
329cdf0e10cSrcweir sal_Bool bRowSplit = SFX_ITEM_SET == rSet.GetItemState( RES_ROW_SPLIT, sal_False, &pSplit );
330cdf0e10cSrcweir const SfxPoolItem* pBoxDirection = 0;
331cdf0e10cSrcweir sal_Bool bBoxDirection = SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_BOX_TEXTDIRECTION, sal_False, &pBoxDirection );
332cdf0e10cSrcweir if( bBackground || bBorder || bRowSplit || bBoxDirection)
333cdf0e10cSrcweir {
334cdf0e10cSrcweir /*
335cdf0e10cSrcweir Die Umrandung wird auf die vorliegende Selektion angewendet
336cdf0e10cSrcweir Liegt keine Selektion vor, wird die Tabelle vollstaendig selektiert.
337cdf0e10cSrcweir Der Hintergrund wird immer auf den aktuellen Zustand angewendet.
338cdf0e10cSrcweir */
339cdf0e10cSrcweir
340cdf0e10cSrcweir sal_Bool bTableSel = rSh.IsTableMode();
341cdf0e10cSrcweir rSh.StartAllAction();
342cdf0e10cSrcweir
343cdf0e10cSrcweir if(bBackground)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir if(pItem)
346cdf0e10cSrcweir rSh.SetBoxBackground( *(const SvxBrushItem*)pItem );
347cdf0e10cSrcweir if(pRowItem)
348cdf0e10cSrcweir {
349cdf0e10cSrcweir SvxBrushItem aBrush(*(const SvxBrushItem*)pRowItem);
350cdf0e10cSrcweir aBrush.SetWhich(RES_BACKGROUND);
351cdf0e10cSrcweir rSh.SetRowBackground(aBrush);
352cdf0e10cSrcweir }
353cdf0e10cSrcweir if(pTableItem)
354cdf0e10cSrcweir {
355cdf0e10cSrcweir SvxBrushItem aBrush(*(const SvxBrushItem*)pTableItem);
356cdf0e10cSrcweir aBrush.SetWhich(RES_BACKGROUND);
357cdf0e10cSrcweir rSh.SetTabBackground( aBrush );
358cdf0e10cSrcweir }
359cdf0e10cSrcweir }
360cdf0e10cSrcweir
361cdf0e10cSrcweir if(bBoxDirection)
362cdf0e10cSrcweir {
363cdf0e10cSrcweir SvxFrameDirectionItem aDirection( FRMDIR_ENVIRONMENT, RES_FRAMEDIR );
364cdf0e10cSrcweir aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
365cdf0e10cSrcweir rSh.SetBoxDirection(aDirection);
366cdf0e10cSrcweir }
367cdf0e10cSrcweir
368cdf0e10cSrcweir if(bBorder || bRowSplit)
369cdf0e10cSrcweir {
370cdf0e10cSrcweir rSh.Push();
371cdf0e10cSrcweir if(!bTableSel)
372cdf0e10cSrcweir {
373cdf0e10cSrcweir rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL );
374cdf0e10cSrcweir }
375cdf0e10cSrcweir if(bBorder)
376cdf0e10cSrcweir rSh.SetTabBorders( rSet );
377cdf0e10cSrcweir
378cdf0e10cSrcweir if(bRowSplit)
379cdf0e10cSrcweir {
380cdf0e10cSrcweir rSh.SetRowSplit(*static_cast<const SwFmtRowSplit*>(pSplit));
381cdf0e10cSrcweir }
382cdf0e10cSrcweir
383cdf0e10cSrcweir if(!bTableSel)
384cdf0e10cSrcweir {
385cdf0e10cSrcweir rSh.ClearMark();
386cdf0e10cSrcweir }
387cdf0e10cSrcweir rSh.Pop(sal_False);
388cdf0e10cSrcweir }
389cdf0e10cSrcweir
390cdf0e10cSrcweir rSh.EndAllAction();
391cdf0e10cSrcweir }
392cdf0e10cSrcweir
393cdf0e10cSrcweir SwTabCols aTabCols;
394cdf0e10cSrcweir sal_Bool bTabCols = sal_False;
395cdf0e10cSrcweir sal_Bool bSingleLine = sal_False;
396cdf0e10cSrcweir SwTableRep* pRep = 0;
397cdf0e10cSrcweir SwFrmFmt *pFmt = rSh.GetTableFmt();
398cdf0e10cSrcweir SfxItemSet aSet( rSh.GetAttrPool(), RES_FRMATR_BEGIN, RES_FRMATR_END-1 );
399cdf0e10cSrcweir if(SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_REP, sal_False, &pItem ))
400cdf0e10cSrcweir {
401cdf0e10cSrcweir pRep = (SwTableRep*)((const SwPtrItem*)pItem)->GetValue();
402cdf0e10cSrcweir
403cdf0e10cSrcweir const SwTwips nWidth = pRep->GetWidth();
404cdf0e10cSrcweir if ( text::HoriOrientation::FULL == pRep->GetAlign() )
405cdf0e10cSrcweir {
406cdf0e10cSrcweir SwFmtHoriOrient aAttr( pFmt->GetHoriOrient() );
407cdf0e10cSrcweir aAttr.SetHoriOrient( text::HoriOrientation::FULL );
408cdf0e10cSrcweir aSet.Put( aAttr );
409cdf0e10cSrcweir }
410cdf0e10cSrcweir else
411cdf0e10cSrcweir {
412cdf0e10cSrcweir SwFmtFrmSize aSz( ATT_VAR_SIZE, nWidth );
413cdf0e10cSrcweir if(pRep->GetWidthPercent())
414cdf0e10cSrcweir {
415cdf0e10cSrcweir aSz.SetWidthPercent( (sal_uInt8)pRep->GetWidthPercent() );
416cdf0e10cSrcweir }
417cdf0e10cSrcweir aSet.Put(aSz);
418cdf0e10cSrcweir }
419cdf0e10cSrcweir
420cdf0e10cSrcweir SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
421cdf0e10cSrcweir aLRSpace.SetLeft(pRep->GetLeftSpace());
422cdf0e10cSrcweir aLRSpace.SetRight(pRep->GetRightSpace());
423cdf0e10cSrcweir aSet.Put( aLRSpace );
424cdf0e10cSrcweir
425cdf0e10cSrcweir sal_Int16 eOrient = pRep->GetAlign();
426cdf0e10cSrcweir SwFmtHoriOrient aAttr( 0, eOrient );
427cdf0e10cSrcweir aSet.Put( aAttr );
428cdf0e10cSrcweir // Damit beim recording die Ausrichtung nicht durch die Abstaende ueberschrieben
429cdf0e10cSrcweir // wird, darf das Item nur bei manueller Ausrichtung aufgez. werden
430cdf0e10cSrcweir if(eOrient != text::HoriOrientation::NONE)
431cdf0e10cSrcweir ((SfxItemSet&)rSet).ClearItem( SID_ATTR_LRSPACE );
432cdf0e10cSrcweir
433cdf0e10cSrcweir
434cdf0e10cSrcweir if(pRep->HasColsChanged())
435cdf0e10cSrcweir {
436cdf0e10cSrcweir bTabCols = sal_True;
437cdf0e10cSrcweir }
438cdf0e10cSrcweir }
439cdf0e10cSrcweir
440cdf0e10cSrcweir
441cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, sal_False, &pItem))
442cdf0e10cSrcweir rSh.SetRowsToRepeat( ((SfxUInt16Item*)pItem)->GetValue() );
443cdf0e10cSrcweir
444cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, sal_False, &pItem))
445cdf0e10cSrcweir rSh.SetBoxAlign(((SfxUInt16Item*)(pItem))->GetValue());
446cdf0e10cSrcweir
447cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, sal_False, &pItem ))
448cdf0e10cSrcweir rSh.SetTableName( *pFmt, ((const SfxStringItem*)pItem)->GetValue() );
449cdf0e10cSrcweir
450cdf0e10cSrcweir // kopiere die ausgesuchten Attribute in den ItemSet
451cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aIds[] =
452cdf0e10cSrcweir {
453cdf0e10cSrcweir RES_PAGEDESC,
454cdf0e10cSrcweir RES_BREAK,
455cdf0e10cSrcweir RES_KEEP,
456cdf0e10cSrcweir RES_LAYOUT_SPLIT,
457cdf0e10cSrcweir RES_UL_SPACE,
458cdf0e10cSrcweir RES_SHADOW,
459cdf0e10cSrcweir RES_FRAMEDIR,
460cdf0e10cSrcweir // --> collapsing borders FME 2005-05-27 #i29550#
461cdf0e10cSrcweir RES_COLLAPSING_BORDERS,
462cdf0e10cSrcweir // <-- collapsing borders
463cdf0e10cSrcweir 0
464cdf0e10cSrcweir };
465cdf0e10cSrcweir for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
466cdf0e10cSrcweir if( SFX_ITEM_SET == rSet.GetItemState( *pIds, sal_False, &pItem))
467cdf0e10cSrcweir aSet.Put( *pItem );
468cdf0e10cSrcweir
469cdf0e10cSrcweir if( aSet.Count() )
470cdf0e10cSrcweir rSh.SetTblAttr( aSet );
471cdf0e10cSrcweir
472cdf0e10cSrcweir if(bTabCols)
473cdf0e10cSrcweir {
474cdf0e10cSrcweir rSh.GetTabCols( aTabCols );
475cdf0e10cSrcweir bSingleLine = pRep->FillTabCols( aTabCols );
476cdf0e10cSrcweir rSh.SetTabCols( aTabCols, bSingleLine );
477cdf0e10cSrcweir }
478cdf0e10cSrcweir
479cdf0e10cSrcweir rSh.EndUndo( UNDO_TABLE_ATTR );
480cdf0e10cSrcweir rSh.EndAllAction();
481cdf0e10cSrcweir }
482cdf0e10cSrcweir
483cdf0e10cSrcweir /************************************************************************/
484cdf0e10cSrcweir
485cdf0e10cSrcweir
lcl_TabGetMaxLineWidth(const SvxBorderLine * pBorderLine,SvxBorderLine & rBorderLine)486cdf0e10cSrcweir static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
487cdf0e10cSrcweir {
488cdf0e10cSrcweir if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth())
489cdf0e10cSrcweir rBorderLine.SetInWidth(pBorderLine->GetInWidth());
490cdf0e10cSrcweir
491cdf0e10cSrcweir if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth())
492cdf0e10cSrcweir rBorderLine.SetOutWidth(pBorderLine->GetOutWidth());
493cdf0e10cSrcweir
494cdf0e10cSrcweir if(pBorderLine->GetDistance() > rBorderLine.GetDistance())
495cdf0e10cSrcweir rBorderLine.SetDistance(pBorderLine->GetDistance());
496cdf0e10cSrcweir
497cdf0e10cSrcweir rBorderLine.SetColor(pBorderLine->GetColor());
498cdf0e10cSrcweir }
499cdf0e10cSrcweir
500cdf0e10cSrcweir
Execute(SfxRequest & rReq)501cdf0e10cSrcweir void SwTableShell::Execute(SfxRequest &rReq)
502cdf0e10cSrcweir {
503cdf0e10cSrcweir sal_Bool bUseDialog = sal_True;
504cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
505cdf0e10cSrcweir SwWrtShell &rSh = GetShell();
506cdf0e10cSrcweir
507cdf0e10cSrcweir //Erstmal die Slots, die keinen FrmMgr benoetigen.
508cdf0e10cSrcweir sal_Bool bMore = sal_False;
509cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
510cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
511cdf0e10cSrcweir if(pArgs)
512cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
513cdf0e10cSrcweir sal_Bool bCallDone = sal_False;
514cdf0e10cSrcweir switch ( nSlot )
515cdf0e10cSrcweir {
516cdf0e10cSrcweir case SID_ATTR_BORDER:
517cdf0e10cSrcweir {
518cdf0e10cSrcweir /* sal_Bool bPopCrsr = sal_False;
519cdf0e10cSrcweir if ( !rReq.IsAPI() )
520cdf0e10cSrcweir {
521cdf0e10cSrcweir //Keine Tabellenselektion -> Aenderung wird auf die gesamte
522cdf0e10cSrcweir //Tabelle.
523cdf0e10cSrcweir if ( !rSh.IsTableMode() )
524cdf0e10cSrcweir {
525cdf0e10cSrcweir rSh.StartAction();
526cdf0e10cSrcweir bPopCrsr = sal_True;
527cdf0e10cSrcweir rSh.Push();
528cdf0e10cSrcweir rSh.EnterStdMode();
529cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableStart );
530cdf0e10cSrcweir rSh.SttSelect();
531cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableEnd );
532cdf0e10cSrcweir rSh.EndSelect();
533cdf0e10cSrcweir }
534cdf0e10cSrcweir }*/
535cdf0e10cSrcweir if(!pArgs)
536cdf0e10cSrcweir break;
537cdf0e10cSrcweir //Items erzeugen, weil wir sowieso nacharbeiten muessen
538cdf0e10cSrcweir SvxBoxItem aBox( RES_BOX );
539cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(),
540cdf0e10cSrcweir RES_BOX, RES_BOX,
541cdf0e10cSrcweir SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER,
542cdf0e10cSrcweir 0);
543cdf0e10cSrcweir SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
544cdf0e10cSrcweir aCoreSet.Put(aCoreInfo);
545cdf0e10cSrcweir rSh.GetTabBorders( aCoreSet );
546cdf0e10cSrcweir const SvxBoxItem& rCoreBox = (const SvxBoxItem&)
547cdf0e10cSrcweir aCoreSet.Get(RES_BOX);
548cdf0e10cSrcweir const SfxPoolItem *pBoxItem = 0;
549cdf0e10cSrcweir if ( pArgs->GetItemState(RES_BOX, sal_True, &pBoxItem) == SFX_ITEM_SET )
550cdf0e10cSrcweir {
551cdf0e10cSrcweir aBox = *(SvxBoxItem*)pBoxItem;
552cdf0e10cSrcweir if ( !rReq.IsAPI() )
553cdf0e10cSrcweir aBox.SetDistance( Max(rCoreBox.GetDistance(),sal_uInt16(55)) );
554cdf0e10cSrcweir else if ( aBox.GetDistance() < MIN_BORDER_DIST )
555cdf0e10cSrcweir aBox.SetDistance( Max(rCoreBox.GetDistance(),(sal_uInt16)MIN_BORDER_DIST) );
556cdf0e10cSrcweir }
557cdf0e10cSrcweir else
558cdf0e10cSrcweir {ASSERT( !this, "Wo ist das Box-Item?" )}
559cdf0e10cSrcweir
560cdf0e10cSrcweir //since the drawing layer also supports borders the which id might be a different one
561cdf0e10cSrcweir SvxBoxInfoItem aInfo( SID_ATTR_BORDER_INNER );
562cdf0e10cSrcweir if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET)
563cdf0e10cSrcweir aInfo = *(SvxBoxInfoItem*)pBoxItem;
564cdf0e10cSrcweir else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, sal_True, &pBoxItem) == SFX_ITEM_SET )
565cdf0e10cSrcweir {
566cdf0e10cSrcweir aInfo = *(SvxBoxInfoItem*)pBoxItem;
567cdf0e10cSrcweir aInfo.SetWhich(SID_ATTR_BORDER_INNER);
568cdf0e10cSrcweir }
569cdf0e10cSrcweir
570cdf0e10cSrcweir aInfo.SetTable( sal_True );
571cdf0e10cSrcweir aInfo.SetValid( VALID_DISABLE, sal_False );
572cdf0e10cSrcweir
573cdf0e10cSrcweir
574cdf0e10cSrcweir // Die Attribute aller Linien werden gelesen und das staerkste gewinnt
575cdf0e10cSrcweir const SvxBorderLine* pBorderLine;
576cdf0e10cSrcweir SvxBorderLine aBorderLine;
577cdf0e10cSrcweir if ((pBorderLine = rCoreBox.GetTop()) != NULL)
578cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
579cdf0e10cSrcweir if ((pBorderLine = rCoreBox.GetBottom()) != NULL)
580cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
581cdf0e10cSrcweir if ((pBorderLine = rCoreBox.GetLeft()) != NULL)
582cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
583cdf0e10cSrcweir if ((pBorderLine = rCoreBox.GetRight()) != NULL)
584cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
585cdf0e10cSrcweir if ((pBorderLine = aCoreInfo.GetHori()) != NULL)
586cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
587cdf0e10cSrcweir if ((pBorderLine = aCoreInfo.GetVert()) != NULL)
588cdf0e10cSrcweir lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
589cdf0e10cSrcweir
590cdf0e10cSrcweir if(aBorderLine.GetOutWidth() == 0)
591cdf0e10cSrcweir {
592cdf0e10cSrcweir aBorderLine.SetInWidth(0);
593cdf0e10cSrcweir aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0);
594cdf0e10cSrcweir }
595cdf0e10cSrcweir
596cdf0e10cSrcweir sal_Bool bLine = sal_False;
597cdf0e10cSrcweir if ( (pBorderLine = aBox.GetTop()) != NULL)
598cdf0e10cSrcweir aBox.SetLine(&aBorderLine, BOX_LINE_TOP), bLine |= sal_True;
599cdf0e10cSrcweir if ((pBorderLine = aBox.GetBottom()) != NULL)
600cdf0e10cSrcweir aBox.SetLine(&aBorderLine, BOX_LINE_BOTTOM), bLine |= sal_True;
601cdf0e10cSrcweir if ((pBorderLine = aBox.GetLeft()) != NULL)
602cdf0e10cSrcweir aBox.SetLine(&aBorderLine, BOX_LINE_LEFT), bLine |= sal_True;
603cdf0e10cSrcweir if ((pBorderLine = aBox.GetRight()) != NULL)
604cdf0e10cSrcweir aBox.SetLine(&aBorderLine, BOX_LINE_RIGHT), bLine |= sal_True;
605cdf0e10cSrcweir if ((pBorderLine = aInfo.GetHori()) != NULL)
606cdf0e10cSrcweir aInfo.SetLine(&aBorderLine, BOXINFO_LINE_HORI), bLine |= sal_True;
607cdf0e10cSrcweir if ((pBorderLine = aInfo.GetVert()) != NULL)
608cdf0e10cSrcweir aInfo.SetLine(&aBorderLine, BOXINFO_LINE_VERT), bLine |= sal_True;
609cdf0e10cSrcweir
610cdf0e10cSrcweir // if ( bPopCrsr && !bLine )
611cdf0e10cSrcweir // aBox.SetDistance( 0 );
612cdf0e10cSrcweir
613cdf0e10cSrcweir aCoreSet.Put( aBox );
614cdf0e10cSrcweir aCoreSet.Put( aInfo );
615cdf0e10cSrcweir rSh.SetTabBorders( aCoreSet );
616cdf0e10cSrcweir
617cdf0e10cSrcweir // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
618cdf0e10cSrcweir // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
619cdf0e10cSrcweir // the SvxBoxItem
620cdf0e10cSrcweir rReq.AppendItem( aBox );
621cdf0e10cSrcweir rReq.AppendItem( aInfo );
622cdf0e10cSrcweir bCallDone = sal_True;
623cdf0e10cSrcweir
624cdf0e10cSrcweir /* if ( bPopCrsr )
625cdf0e10cSrcweir {
626cdf0e10cSrcweir rSh.KillPams();
627cdf0e10cSrcweir rSh.Pop(sal_False);
628cdf0e10cSrcweir rSh.EndAction();
629cdf0e10cSrcweir }*/
630cdf0e10cSrcweir }
631cdf0e10cSrcweir break;
632cdf0e10cSrcweir case FN_INSERT_TABLE:
633cdf0e10cSrcweir InsertTable( rReq );
634cdf0e10cSrcweir break;
635cdf0e10cSrcweir case FN_FORMAT_TABLE_DLG:
636cdf0e10cSrcweir {
637cdf0e10cSrcweir //#127012# get the bindings before the dialog is called
638cdf0e10cSrcweir // it might happen that this shell is removed after closing the dialog
639cdf0e10cSrcweir SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
640cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
641cdf0e10cSrcweir
642cdf0e10cSrcweir FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &rSh.GetView()));
643cdf0e10cSrcweir SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
644cdf0e10cSrcweir SwTableRep* pTblRep = ::lcl_TableParamToItemSet( aCoreSet, rSh );
645cdf0e10cSrcweir SfxAbstractTabDialog * pDlg = NULL;
646cdf0e10cSrcweir if ( bUseDialog )
647cdf0e10cSrcweir {
648cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
649cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
650cdf0e10cSrcweir
651cdf0e10cSrcweir pDlg = pFact->CreateSwTableTabDlg( GetView().GetWindow(), GetPool(), &aCoreSet, &rSh, DLG_FORMAT_TABLE );
652cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
653cdf0e10cSrcweir }
654cdf0e10cSrcweir aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
655cdf0e10cSrcweir rSh.GetTblAttr(aCoreSet);
656cdf0e10cSrcweir // GetTblAttr buegelt den Background ueber!
657cdf0e10cSrcweir SvxBrushItem aBrush( RES_BACKGROUND );
658cdf0e10cSrcweir if(rSh.GetBoxBackground(aBrush))
659cdf0e10cSrcweir aCoreSet.Put( aBrush );
660cdf0e10cSrcweir else
661cdf0e10cSrcweir aCoreSet.InvalidateItem( RES_BACKGROUND );
662cdf0e10cSrcweir
663cdf0e10cSrcweir if ( (!pDlg && rReq.GetArgs()) || pDlg->Execute() == RET_OK )
664cdf0e10cSrcweir {
665cdf0e10cSrcweir const SfxItemSet* pOutSet = pDlg ? pDlg->GetOutputItemSet() : rReq.GetArgs();
666cdf0e10cSrcweir if ( pDlg )
667cdf0e10cSrcweir {
668cdf0e10cSrcweir //to record FN_INSERT_TABLE correctly
669cdf0e10cSrcweir rReq.SetSlot(FN_FORMAT_TABLE_DLG);
670cdf0e10cSrcweir rReq.Done( *pOutSet );
671cdf0e10cSrcweir }
672cdf0e10cSrcweir ItemSetToTableParam( *pOutSet, rSh );
673cdf0e10cSrcweir }
674cdf0e10cSrcweir
675cdf0e10cSrcweir delete pDlg;
676cdf0e10cSrcweir delete pTblRep;
677cdf0e10cSrcweir rBindings.Update(SID_RULER_BORDERS);
678cdf0e10cSrcweir rBindings.Update(SID_ATTR_TABSTOP);
679cdf0e10cSrcweir rBindings.Update(SID_RULER_BORDERS_VERTICAL);
680cdf0e10cSrcweir rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
681cdf0e10cSrcweir }
682cdf0e10cSrcweir break;
683cdf0e10cSrcweir case SID_ATTR_BRUSH:
684cdf0e10cSrcweir case SID_ATTR_BRUSH_ROW :
685cdf0e10cSrcweir case SID_ATTR_BRUSH_TABLE :
686cdf0e10cSrcweir if(rReq.GetArgs())
687cdf0e10cSrcweir ItemSetToTableParam(*rReq.GetArgs(), rSh);
688cdf0e10cSrcweir break;
689cdf0e10cSrcweir case FN_NUM_FORMAT_TABLE_DLG:
690cdf0e10cSrcweir {
691cdf0e10cSrcweir SwView* pView = GetActiveView();
692cdf0e10cSrcweir if(pView)
693cdf0e10cSrcweir {
694cdf0e10cSrcweir FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, pView));
695cdf0e10cSrcweir SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
696cdf0e10cSrcweir SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
697cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(),
698cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE,
699cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_INFO,
700cdf0e10cSrcweir 0 );
701cdf0e10cSrcweir
702cdf0e10cSrcweir SfxItemSet aBoxSet( *aCoreSet.GetPool(),
703cdf0e10cSrcweir RES_BOXATR_FORMAT, RES_BOXATR_FORMAT,
704cdf0e10cSrcweir RES_BOXATR_VALUE, RES_BOXATR_VALUE,
705cdf0e10cSrcweir 0 );
706cdf0e10cSrcweir rSh.GetTblBoxFormulaAttrs( aBoxSet );
707cdf0e10cSrcweir
708cdf0e10cSrcweir SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
709cdf0e10cSrcweir if(eState == SFX_ITEM_DEFAULT)
710cdf0e10cSrcweir {
711cdf0e10cSrcweir aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
712cdf0e10cSrcweir pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
713cdf0e10cSrcweir }
714cdf0e10cSrcweir else
715cdf0e10cSrcweir aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
716cdf0e10cSrcweir ((SwTblBoxNumFormat&)aBoxSet.Get(
717cdf0e10cSrcweir RES_BOXATR_FORMAT )).GetValue() ));
718cdf0e10cSrcweir
719cdf0e10cSrcweir String sCurText( rSh.GetTableBoxText() );
720cdf0e10cSrcweir aCoreSet.Put( SvxNumberInfoItem( pFormatter,
721cdf0e10cSrcweir ((SwTblBoxValue&)aBoxSet.Get(
722cdf0e10cSrcweir RES_BOXATR_VALUE)).GetValue(),
723cdf0e10cSrcweir sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
724cdf0e10cSrcweir
725cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
726cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
727cdf0e10cSrcweir
728cdf0e10cSrcweir SfxAbstractDialog* pDlg = pFact->CreateSfxDialog( GetView().GetWindow(),aCoreSet,
729cdf0e10cSrcweir pView->GetViewFrame()->GetFrame().GetFrameInterface(),
730cdf0e10cSrcweir RC_DLG_SWNUMFMTDLG );
731cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
732cdf0e10cSrcweir
733cdf0e10cSrcweir if (RET_OK == pDlg->Execute())
734cdf0e10cSrcweir {
735cdf0e10cSrcweir const SfxPoolItem* pNumberFormatItem = GetView().GetDocShell()->
736cdf0e10cSrcweir GetItem( SID_ATTR_NUMBERFORMAT_INFO );
737cdf0e10cSrcweir
738cdf0e10cSrcweir if( pNumberFormatItem && 0 != ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount() )
739cdf0e10cSrcweir {
740cdf0e10cSrcweir const sal_uInt32* pDelArr = ((SvxNumberInfoItem*)
741cdf0e10cSrcweir pNumberFormatItem)->GetDelArray();
742cdf0e10cSrcweir
743cdf0e10cSrcweir for ( sal_uInt16 i = 0; i < ((SvxNumberInfoItem*)pNumberFormatItem)->GetDelCount(); i++ )
744cdf0e10cSrcweir ((SvxNumberInfoItem*)pNumberFormatItem)->
745cdf0e10cSrcweir GetNumberFormatter()->DeleteEntry( pDelArr[i] );
746cdf0e10cSrcweir }
747cdf0e10cSrcweir
748cdf0e10cSrcweir if( SFX_ITEM_SET == pDlg->GetOutputItemSet()->GetItemState(
749cdf0e10cSrcweir SID_ATTR_NUMBERFORMAT_VALUE, sal_False, &pNumberFormatItem ))
750cdf0e10cSrcweir {
751cdf0e10cSrcweir SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
752cdf0e10cSrcweir RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
753cdf0e10cSrcweir aBoxFormatSet.Put( SwTblBoxNumFormat(
754cdf0e10cSrcweir ((SfxUInt32Item*)pNumberFormatItem)->GetValue() ));
755cdf0e10cSrcweir rSh.SetTblBoxFormulaAttrs( aBoxFormatSet );
756cdf0e10cSrcweir
757cdf0e10cSrcweir }
758cdf0e10cSrcweir }
759cdf0e10cSrcweir delete pDlg;
760cdf0e10cSrcweir }
761cdf0e10cSrcweir }
762cdf0e10cSrcweir break;
763cdf0e10cSrcweir case FN_CALC_TABLE:
764cdf0e10cSrcweir rSh.UpdateTable();
765cdf0e10cSrcweir bCallDone = sal_True;
766cdf0e10cSrcweir break;
767cdf0e10cSrcweir case FN_TABLE_OPTIMAL_HEIGHT:
768cdf0e10cSrcweir {
769cdf0e10cSrcweir const SwFmtFrmSize aSz;
770cdf0e10cSrcweir rSh.SetRowHeight( aSz );
771cdf0e10cSrcweir bCallDone = sal_True;
772cdf0e10cSrcweir }
773cdf0e10cSrcweir break;
774cdf0e10cSrcweir case FN_TABLE_DELETE_COL:
775cdf0e10cSrcweir if ( rSh.DeleteCol() && rSh.HasSelection() )
776cdf0e10cSrcweir rSh.EnterStdMode();
777cdf0e10cSrcweir bCallDone = sal_True;
778cdf0e10cSrcweir break;
779cdf0e10cSrcweir case FN_END_TABLE:
780cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableEnd );
781cdf0e10cSrcweir bCallDone = sal_True;
782cdf0e10cSrcweir break;
783cdf0e10cSrcweir case FN_START_TABLE:
784cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableStart );
785cdf0e10cSrcweir bCallDone = sal_True;
786cdf0e10cSrcweir break;
787cdf0e10cSrcweir case FN_GOTO_NEXT_CELL:
788cdf0e10cSrcweir {
789cdf0e10cSrcweir sal_Bool bAppendLine = sal_True;
790cdf0e10cSrcweir if( pItem )
791cdf0e10cSrcweir bAppendLine = ((SfxBoolItem*)pItem)->GetValue();
792cdf0e10cSrcweir rReq.SetReturnValue( SfxBoolItem( nSlot,
793cdf0e10cSrcweir rSh.GoNextCell( bAppendLine ) ) );
794cdf0e10cSrcweir bCallDone = sal_True;
795cdf0e10cSrcweir }
796cdf0e10cSrcweir break;
797cdf0e10cSrcweir case FN_GOTO_PREV_CELL:
798cdf0e10cSrcweir rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
799cdf0e10cSrcweir bCallDone = sal_True;
800cdf0e10cSrcweir break;
801cdf0e10cSrcweir case FN_TABLE_DELETE_ROW:
802cdf0e10cSrcweir if ( rSh.DeleteRow() && rSh.HasSelection() )
803cdf0e10cSrcweir rSh.EnterStdMode();
804cdf0e10cSrcweir bCallDone = sal_True;
805cdf0e10cSrcweir break;
806cdf0e10cSrcweir case FN_TABLE_MERGE_CELLS:
807cdf0e10cSrcweir if ( rSh.IsTableMode() )
808cdf0e10cSrcweir switch ( rSh.MergeTab() )
809cdf0e10cSrcweir {
810cdf0e10cSrcweir case TBLMERGE_OK:
811cdf0e10cSrcweir bCallDone = sal_True;
812cdf0e10cSrcweir //no break;
813cdf0e10cSrcweir case TBLMERGE_NOSELECTION: break;
814cdf0e10cSrcweir case TBLMERGE_TOOCOMPLEX:
815cdf0e10cSrcweir {
816cdf0e10cSrcweir InfoBox aInfoBox( GetView().GetWindow(),
817cdf0e10cSrcweir SW_RES( MSG_ERR_TABLE_MERGE ) );
818cdf0e10cSrcweir aInfoBox.Execute();
819cdf0e10cSrcweir break;
820cdf0e10cSrcweir }
821cdf0e10cSrcweir default: ASSERT( !this, "unbekannter Returnwert MergeTab.");
822cdf0e10cSrcweir }
823cdf0e10cSrcweir break;
824cdf0e10cSrcweir case FN_TABLE_ADJUST_CELLS:
825cdf0e10cSrcweir case FN_TABLE_BALANCE_CELLS:
826cdf0e10cSrcweir {
827cdf0e10cSrcweir sal_Bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
828cdf0e10cSrcweir if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
829cdf0e10cSrcweir {
830cdf0e10cSrcweir {
831cdf0e10cSrcweir // remove actions to make a valid table selection
832cdf0e10cSrcweir UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
833cdf0e10cSrcweir }
834cdf0e10cSrcweir rSh.AdjustCellWidth(bBalance);
835cdf0e10cSrcweir }
836cdf0e10cSrcweir bCallDone = sal_True;
837cdf0e10cSrcweir }
838cdf0e10cSrcweir break;
839cdf0e10cSrcweir case FN_TABLE_BALANCE_ROWS:
840cdf0e10cSrcweir if ( rSh.BalanceRowHeight(sal_True) )
841cdf0e10cSrcweir rSh.BalanceRowHeight(sal_False);
842cdf0e10cSrcweir bCallDone = sal_True;
843cdf0e10cSrcweir break;
844cdf0e10cSrcweir case FN_TABLE_SELECT_ALL:
845cdf0e10cSrcweir rSh.EnterStdMode();
846cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableStart );
847cdf0e10cSrcweir rSh.SttSelect();
848cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableEnd );
849cdf0e10cSrcweir rSh.EndSelect();
850cdf0e10cSrcweir bCallDone = sal_True;
851cdf0e10cSrcweir break;
852cdf0e10cSrcweir case FN_TABLE_SELECT_COL:
853cdf0e10cSrcweir rSh.EnterStdMode();
854cdf0e10cSrcweir rSh.SelectTableCol();
855cdf0e10cSrcweir bCallDone = sal_True;
856cdf0e10cSrcweir break;
857cdf0e10cSrcweir case FN_TABLE_SELECT_ROW:
858cdf0e10cSrcweir rSh.EnterStdMode();
859cdf0e10cSrcweir rSh.SelectTableRow();
860cdf0e10cSrcweir bCallDone = sal_True;
861cdf0e10cSrcweir break;
862cdf0e10cSrcweir case FN_TABLE_SET_READ_ONLY_CELLS:
863cdf0e10cSrcweir rSh.ProtectCells();
864cdf0e10cSrcweir rSh.ResetSelect( 0, sal_False );
865cdf0e10cSrcweir bCallDone = sal_True;
866cdf0e10cSrcweir break;
867cdf0e10cSrcweir case FN_TABLE_UNSET_READ_ONLY_CELLS:
868cdf0e10cSrcweir rSh.UnProtectCells();
869cdf0e10cSrcweir bCallDone = sal_True;
870cdf0e10cSrcweir break;
871cdf0e10cSrcweir case SID_AUTOFORMAT:
872cdf0e10cSrcweir {
873cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
874cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
875cdf0e10cSrcweir
876cdf0e10cSrcweir AbstractSwAutoFormatDlg* pDlg = pFact->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh , DLG_AUTOFMT_TABLE );
877cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
878cdf0e10cSrcweir pDlg->Execute();
879cdf0e10cSrcweir delete pDlg;
880cdf0e10cSrcweir }
881cdf0e10cSrcweir break;
882cdf0e10cSrcweir case FN_TABLE_SET_ROW_HEIGHT:
883cdf0e10cSrcweir {
884cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
885cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
886cdf0e10cSrcweir
887cdf0e10cSrcweir VclAbstractDialog* pDlg = pFact->CreateVclAbstractDialog( GetView().GetWindow(), rSh, DLG_ROW_HEIGHT );
888cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
889cdf0e10cSrcweir pDlg->Execute();
890cdf0e10cSrcweir delete pDlg;
891cdf0e10cSrcweir }
892cdf0e10cSrcweir break;
893cdf0e10cSrcweir case FN_NUMBER_BULLETS:
894cdf0e10cSrcweir case FN_NUM_BULLET_ON:
895cdf0e10cSrcweir ASSERT( !this, "Funktion darf zur Zeit nicht gerufen werden." );
896cdf0e10cSrcweir break;
897cdf0e10cSrcweir
898cdf0e10cSrcweir case FN_TABLE_INSERT_COL:
899cdf0e10cSrcweir case FN_TABLE_INSERT_ROW:
900cdf0e10cSrcweir {
901cdf0e10cSrcweir sal_Bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL;
902cdf0e10cSrcweir sal_uInt16 nCount = 0;
903cdf0e10cSrcweir sal_Bool bAfter = sal_True;
904cdf0e10cSrcweir if (pItem)
905cdf0e10cSrcweir {
906cdf0e10cSrcweir nCount = ((const SfxInt16Item* )pItem)->GetValue();
907cdf0e10cSrcweir if(SFX_ITEM_SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, sal_True, &pItem))
908cdf0e10cSrcweir bAfter = ((const SfxBoolItem* )pItem)->GetValue();
909cdf0e10cSrcweir }
910cdf0e10cSrcweir else if( !rReq.IsAPI() )
911cdf0e10cSrcweir ++nCount;
912cdf0e10cSrcweir
913cdf0e10cSrcweir if( nCount )
914cdf0e10cSrcweir {
915cdf0e10cSrcweir // i74180: Table border patch submitted by chensuchun:
916cdf0e10cSrcweir // -->get the SvxBoxInfoItem of the table before insert
917cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
918cdf0e10cSrcweir ::lcl_TableParamToItemSet( aCoreSet, rSh );
919cdf0e10cSrcweir bool bSetInnerBorders = false;
920cdf0e10cSrcweir SwUndoId nUndoId = UNDO_EMPTY;
921cdf0e10cSrcweir // <--End
922cdf0e10cSrcweir
923cdf0e10cSrcweir if( bColumn )
924cdf0e10cSrcweir {
925cdf0e10cSrcweir rSh.StartUndo( UNDO_TABLE_INSCOL );
926cdf0e10cSrcweir rSh.InsertCol( nCount, bAfter );
927cdf0e10cSrcweir bSetInnerBorders = true;
928cdf0e10cSrcweir nUndoId = UNDO_TABLE_INSCOL;
929cdf0e10cSrcweir }
930cdf0e10cSrcweir else if ( !rSh.IsInRepeatedHeadline() )
931cdf0e10cSrcweir {
932cdf0e10cSrcweir rSh.StartUndo( UNDO_TABLE_INSROW );
933cdf0e10cSrcweir rSh.InsertRow( nCount, bAfter );
934cdf0e10cSrcweir bSetInnerBorders = true;
935cdf0e10cSrcweir nUndoId = UNDO_TABLE_INSROW;
936cdf0e10cSrcweir }
937cdf0e10cSrcweir
938cdf0e10cSrcweir // -->after inserting,reset the inner table borders
939cdf0e10cSrcweir if ( bSetInnerBorders )
940cdf0e10cSrcweir {
941cdf0e10cSrcweir const SvxBoxInfoItem aBoxInfo((const SvxBoxInfoItem&)
942cdf0e10cSrcweir aCoreSet.Get(SID_ATTR_BORDER_INNER));
943cdf0e10cSrcweir SfxItemSet aSet( GetPool(), SID_ATTR_BORDER_INNER,
944cdf0e10cSrcweir SID_ATTR_BORDER_INNER, 0);
945cdf0e10cSrcweir aSet.Put( aBoxInfo );
946cdf0e10cSrcweir ItemSetToTableParam( aSet, rSh );
947cdf0e10cSrcweir rSh.EndUndo( nUndoId );
948cdf0e10cSrcweir }
949cdf0e10cSrcweir // <--
950cdf0e10cSrcweir
951cdf0e10cSrcweir bCallDone = sal_True;
952cdf0e10cSrcweir break;
953cdf0e10cSrcweir }
954cdf0e10cSrcweir
955cdf0e10cSrcweir nSlot = bColumn ? FN_TABLE_INSERT_COL_DLG : FN_TABLE_INSERT_ROW_DLG;
956cdf0e10cSrcweir }
957cdf0e10cSrcweir // kein break; bei Count = 0 kommt der Dialog
958cdf0e10cSrcweir case FN_TABLE_INSERT_COL_DLG:
959cdf0e10cSrcweir case FN_TABLE_INSERT_ROW_DLG:
960cdf0e10cSrcweir {
961cdf0e10cSrcweir const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
962cdf0e10cSrcweir if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
963cdf0e10cSrcweir {
964cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
965cdf0e10cSrcweir ::std::auto_ptr<SvxAbstractInsRowColDlg> pDlg( pFact ? pFact->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand() ) : 0);
966cdf0e10cSrcweir
967cdf0e10cSrcweir if( pDlg.get() && (pDlg->Execute() == 1) )
968cdf0e10cSrcweir {
969cdf0e10cSrcweir sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG) ? FN_TABLE_INSERT_COL : FN_TABLE_INSERT_ROW;
970cdf0e10cSrcweir SfxUInt16Item aCountItem( nDispatchSlot, static_cast< sal_uInt16 >(pDlg->getInsertCount()) );
971cdf0e10cSrcweir SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
972cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame();
973cdf0e10cSrcweir if( pVFrame )
974cdf0e10cSrcweir pVFrame->GetDispatcher()->Execute( nDispatchSlot, SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, &aCountItem, &aAfter, 0L);
975cdf0e10cSrcweir }
976cdf0e10cSrcweir }
977cdf0e10cSrcweir }
978cdf0e10cSrcweir break;
979cdf0e10cSrcweir case FN_TABLE_SPLIT_CELLS:
980cdf0e10cSrcweir {
981cdf0e10cSrcweir long nCount=0;
982cdf0e10cSrcweir sal_Bool bHorizontal=sal_True;
983cdf0e10cSrcweir sal_Bool bProportional = sal_False;
984cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pSplit, SfxInt32Item, FN_TABLE_SPLIT_CELLS, sal_False );
985cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pHor, SfxBoolItem, FN_PARAM_1, sal_False );
986cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pProp, SfxBoolItem, FN_PARAM_2, sal_False );
987cdf0e10cSrcweir if ( pSplit )
988cdf0e10cSrcweir {
989cdf0e10cSrcweir nCount = pSplit->GetValue();
990cdf0e10cSrcweir if ( pHor )
991cdf0e10cSrcweir bHorizontal = pHor->GetValue();
992cdf0e10cSrcweir if ( pProp )
993cdf0e10cSrcweir bProportional = pProp->GetValue();
994cdf0e10cSrcweir }
995cdf0e10cSrcweir else
996cdf0e10cSrcweir {
997cdf0e10cSrcweir SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
998cdf0e10cSrcweir if( pFact )
999cdf0e10cSrcweir {
1000cdf0e10cSrcweir const long nMaxVert = rSh.GetAnyCurRect( RECT_FRM ).Width() / MINLAY;
1001cdf0e10cSrcweir SvxAbstractSplittTableDialog* pDlg = pFact->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh.IsTableVertical(), nMaxVert, 99 );
1002cdf0e10cSrcweir if( pDlg && (pDlg->Execute() == RET_OK) )
1003cdf0e10cSrcweir {
1004cdf0e10cSrcweir nCount = pDlg->GetCount();
1005cdf0e10cSrcweir bHorizontal = pDlg->IsHorizontal();
1006cdf0e10cSrcweir bProportional = pDlg->IsProportional();
1007cdf0e10cSrcweir rReq.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS, nCount ) );
1008cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_1, bHorizontal ) );
1009cdf0e10cSrcweir rReq.AppendItem( SfxBoolItem( FN_PARAM_2, bProportional ) );
1010cdf0e10cSrcweir }
1011cdf0e10cSrcweir delete pDlg;
1012cdf0e10cSrcweir }
1013cdf0e10cSrcweir }
1014cdf0e10cSrcweir
1015cdf0e10cSrcweir if ( nCount>1 )
1016cdf0e10cSrcweir {
1017cdf0e10cSrcweir rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1018cdf0e10cSrcweir bCallDone = sal_True;
1019cdf0e10cSrcweir }
1020cdf0e10cSrcweir else
1021cdf0e10cSrcweir rReq.Ignore();
1022cdf0e10cSrcweir }
1023cdf0e10cSrcweir break;
1024cdf0e10cSrcweir
1025cdf0e10cSrcweir case FN_TABLE_SPLIT_TABLE:
1026cdf0e10cSrcweir {
1027cdf0e10cSrcweir SFX_REQUEST_ARG( rReq, pType, SfxUInt16Item, FN_PARAM_1, sal_False );
1028cdf0e10cSrcweir if( pType )
1029cdf0e10cSrcweir {
1030cdf0e10cSrcweir switch( pType->GetValue() )
1031cdf0e10cSrcweir {
1032cdf0e10cSrcweir case HEADLINE_NONE :
1033cdf0e10cSrcweir case HEADLINE_BORDERCOPY:
1034cdf0e10cSrcweir case HEADLINE_CNTNTCOPY:
1035cdf0e10cSrcweir case HEADLINE_BOXATTRCOPY:
1036cdf0e10cSrcweir case HEADLINE_BOXATRCOLLCOPY:
1037cdf0e10cSrcweir rSh.SplitTable(pType->GetValue()) ;
1038cdf0e10cSrcweir default: ;//wrong parameter, do nothing
1039cdf0e10cSrcweir }
1040cdf0e10cSrcweir }
1041cdf0e10cSrcweir else
1042cdf0e10cSrcweir {
1043cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1044cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
1045cdf0e10cSrcweir
1046cdf0e10cSrcweir AbstractSplitTableDialog* pDlg = pFact->CreateSplitTblDialog( GetView().GetWindow(), rSh );
1047cdf0e10cSrcweir DBG_ASSERT(pDlg, "Dialogdiet fail!");
1048cdf0e10cSrcweir pDlg->Execute();
1049cdf0e10cSrcweir rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, pDlg->GetSplitMode() ) );
1050cdf0e10cSrcweir delete pDlg;
1051cdf0e10cSrcweir bCallDone = sal_True;
1052cdf0e10cSrcweir }
1053cdf0e10cSrcweir }
1054cdf0e10cSrcweir break;
1055cdf0e10cSrcweir
1056cdf0e10cSrcweir case FN_TABLE_MERGE_TABLE:
1057cdf0e10cSrcweir {
1058cdf0e10cSrcweir sal_Bool bPrev = rSh.CanMergeTable( sal_True );
1059cdf0e10cSrcweir sal_Bool bNext = rSh.CanMergeTable( sal_False );
1060cdf0e10cSrcweir
1061cdf0e10cSrcweir if( bPrev && bNext )
1062cdf0e10cSrcweir {
1063cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
1064cdf0e10cSrcweir DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!");
1065cdf0e10cSrcweir VclAbstractDialog* pDlg = pFact->CreateSwVclDialog( DLG_MERGE_TABLE, GetView().GetWindow(), bPrev );
1066cdf0e10cSrcweir DBG_ASSERT(pDlg, "dialogdiet pDlg fail!");
1067cdf0e10cSrcweir if( RET_OK != pDlg->Execute())
1068cdf0e10cSrcweir bPrev = bNext = sal_False;
1069cdf0e10cSrcweir delete pDlg;
1070cdf0e10cSrcweir }
1071cdf0e10cSrcweir
1072cdf0e10cSrcweir if( bPrev || bNext )
1073cdf0e10cSrcweir rSh.MergeTable( bPrev );
1074cdf0e10cSrcweir }
1075cdf0e10cSrcweir break;
1076cdf0e10cSrcweir
1077cdf0e10cSrcweir case FN_TABLE_MODE_FIX :
1078cdf0e10cSrcweir case FN_TABLE_MODE_FIX_PROP :
1079cdf0e10cSrcweir case FN_TABLE_MODE_VARIABLE :
1080cdf0e10cSrcweir {
1081cdf0e10cSrcweir rSh.SetTblChgMode( ( FN_TABLE_MODE_FIX == nSlot ? TBLFIX_CHGABS
1082cdf0e10cSrcweir : FN_TABLE_MODE_FIX_PROP == nSlot
1083cdf0e10cSrcweir ? TBLFIX_CHGPROP
1084cdf0e10cSrcweir : TBLVAR_CHGABS ) );
1085cdf0e10cSrcweir
1086cdf0e10cSrcweir SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1087cdf0e10cSrcweir static sal_uInt16 __READONLY_DATA aInva[] =
1088cdf0e10cSrcweir { FN_TABLE_MODE_FIX,
1089cdf0e10cSrcweir FN_TABLE_MODE_FIX_PROP,
1090cdf0e10cSrcweir FN_TABLE_MODE_VARIABLE,
1091cdf0e10cSrcweir 0
1092cdf0e10cSrcweir };
1093cdf0e10cSrcweir rBind.Invalidate( aInva );
1094cdf0e10cSrcweir bCallDone = sal_True;
1095cdf0e10cSrcweir }
1096cdf0e10cSrcweir break;
1097cdf0e10cSrcweir case FN_TABLE_AUTOSUM:
1098cdf0e10cSrcweir {
1099cdf0e10cSrcweir SfxViewFrame* pVFrame = GetView().GetViewFrame();
1100cdf0e10cSrcweir pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SFX_CALLMODE_SYNCHRON);
1101cdf0e10cSrcweir const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1102cdf0e10cSrcweir SwInputChild* pChildWin = (SwInputChild*)pVFrame->
1103cdf0e10cSrcweir GetChildWindow( nId );
1104cdf0e10cSrcweir String sSum;
1105cdf0e10cSrcweir GetShell().GetAutoSum(sSum);
1106cdf0e10cSrcweir if( pChildWin )
1107cdf0e10cSrcweir pChildWin->SetFormula( sSum );
1108cdf0e10cSrcweir
1109cdf0e10cSrcweir }
1110cdf0e10cSrcweir break;
1111cdf0e10cSrcweir case FN_TABLE_HEADLINE_REPEAT:
1112cdf0e10cSrcweir if(0 != rSh.GetRowsToRepeat())
1113cdf0e10cSrcweir rSh.SetRowsToRepeat( 0 );
1114cdf0e10cSrcweir else
1115cdf0e10cSrcweir rSh.SetRowsToRepeat(rSh.GetRowSelectionFromTop());
1116cdf0e10cSrcweir break;
1117cdf0e10cSrcweir case FN_TABLE_SELECT_CELL :
1118cdf0e10cSrcweir rSh.SelectTableCell();
1119cdf0e10cSrcweir break;
1120cdf0e10cSrcweir case FN_TABLE_DELETE_TABLE :
1121cdf0e10cSrcweir {
1122cdf0e10cSrcweir rSh.StartAction();
1123cdf0e10cSrcweir rSh.StartUndo();
1124cdf0e10cSrcweir rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL);
1125cdf0e10cSrcweir rSh.DeleteRow();
1126cdf0e10cSrcweir rSh.EndUndo();
1127cdf0e10cSrcweir rSh.EndAction();
1128cdf0e10cSrcweir }
1129cdf0e10cSrcweir //'this' is already destroyed
1130cdf0e10cSrcweir return;
1131cdf0e10cSrcweir //break;
1132cdf0e10cSrcweir default:
1133cdf0e10cSrcweir bMore = sal_True;
1134cdf0e10cSrcweir }
1135cdf0e10cSrcweir
1136cdf0e10cSrcweir if ( !bMore )
1137cdf0e10cSrcweir {
1138cdf0e10cSrcweir if(bCallDone)
1139cdf0e10cSrcweir rReq.Done();
1140cdf0e10cSrcweir return;
1141cdf0e10cSrcweir }
1142cdf0e10cSrcweir else
1143cdf0e10cSrcweir bMore = sal_False;
1144cdf0e10cSrcweir //Jetzt die Slots, die direkt auf dem TableFmt arbeiten.
1145cdf0e10cSrcweir SwFrmFmt *pFmt = rSh.GetTableFmt();
1146cdf0e10cSrcweir switch ( nSlot )
1147cdf0e10cSrcweir {
1148cdf0e10cSrcweir case SID_ATTR_ULSPACE:
1149cdf0e10cSrcweir {
1150cdf0e10cSrcweir if(pItem)
1151cdf0e10cSrcweir {
1152cdf0e10cSrcweir SvxULSpaceItem aULSpace( *(const SvxULSpaceItem*)pItem );
1153cdf0e10cSrcweir aULSpace.SetWhich( RES_UL_SPACE );
1154cdf0e10cSrcweir ::lcl_SetAttr( rSh, aULSpace );
1155cdf0e10cSrcweir }
1156cdf0e10cSrcweir }
1157cdf0e10cSrcweir break;
1158cdf0e10cSrcweir
1159cdf0e10cSrcweir case SID_ATTR_LRSPACE:
1160cdf0e10cSrcweir {
1161cdf0e10cSrcweir if(pItem)
1162cdf0e10cSrcweir {
1163cdf0e10cSrcweir SfxItemSet aSet( GetPool(), RES_LR_SPACE, RES_LR_SPACE,
1164cdf0e10cSrcweir RES_HORI_ORIENT, RES_HORI_ORIENT, 0 );
1165cdf0e10cSrcweir SvxLRSpaceItem aLRSpace( *(const SvxLRSpaceItem*)pItem );
1166cdf0e10cSrcweir aLRSpace.SetWhich( RES_LR_SPACE );
1167cdf0e10cSrcweir aSet.Put( aLRSpace );
1168cdf0e10cSrcweir SwFmtHoriOrient aHori( pFmt->GetHoriOrient() );
1169cdf0e10cSrcweir aHori.SetHoriOrient( text::HoriOrientation::NONE );
1170cdf0e10cSrcweir aSet.Put( aLRSpace );
1171cdf0e10cSrcweir rSh.SetTblAttr( aSet );
1172cdf0e10cSrcweir }
1173cdf0e10cSrcweir }
1174cdf0e10cSrcweir break;
1175cdf0e10cSrcweir // der letzte case-Zweig der noch einen TabellenManager braucht!!
1176cdf0e10cSrcweir case FN_TABLE_SET_COL_WIDTH:
1177cdf0e10cSrcweir {
1178cdf0e10cSrcweir SwTableFUNC aMgr( &rSh, sal_False);
1179cdf0e10cSrcweir aMgr.ColWidthDlg(GetView().GetWindow());
1180cdf0e10cSrcweir }
1181cdf0e10cSrcweir break;
1182512ec161SZheng Fan case SID_TABLE_VERT_NONE:
1183512ec161SZheng Fan case SID_TABLE_VERT_CENTER:
1184512ec161SZheng Fan case SID_TABLE_VERT_BOTTOM:
1185512ec161SZheng Fan {
1186512ec161SZheng Fan sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1187512ec161SZheng Fan text::VertOrientation::NONE :
1188512ec161SZheng Fan nSlot == SID_TABLE_VERT_CENTER ?
1189512ec161SZheng Fan text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1190512ec161SZheng Fan rSh.SetBoxAlign(nAlign);
1191512ec161SZheng Fan bCallDone = sal_True;
1192512ec161SZheng Fan
1193512ec161SZheng Fan }
1194512ec161SZheng Fan break;
1195cdf0e10cSrcweir
1196cdf0e10cSrcweir case SID_ATTR_PARA_SPLIT:
1197cdf0e10cSrcweir if ( pItem )
1198cdf0e10cSrcweir {
1199cdf0e10cSrcweir SwFmtLayoutSplit aSplit( ((const SvxFmtSplitItem*)pItem)->GetValue());
1200cdf0e10cSrcweir SfxItemSet aSet(GetPool(), RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, 0 );
1201cdf0e10cSrcweir aSet.Put(aSplit);
1202cdf0e10cSrcweir rSh.SetTblAttr(aSet);
1203cdf0e10cSrcweir }
1204cdf0e10cSrcweir break;
1205cdf0e10cSrcweir
1206cdf0e10cSrcweir case SID_ATTR_PARA_KEEP:
1207cdf0e10cSrcweir if ( pItem )
1208cdf0e10cSrcweir {
1209cdf0e10cSrcweir SvxFmtKeepItem aKeep( *(const SvxFmtKeepItem*)pItem );
1210cdf0e10cSrcweir aKeep.SetWhich( RES_KEEP );
1211cdf0e10cSrcweir SfxItemSet aSet(GetPool(), RES_KEEP, RES_KEEP, 0 );
1212cdf0e10cSrcweir aSet.Put(aKeep);
1213cdf0e10cSrcweir rSh.SetTblAttr(aSet);
1214cdf0e10cSrcweir }
1215cdf0e10cSrcweir break;
1216cdf0e10cSrcweir case FN_TABLE_ROW_SPLIT :
1217cdf0e10cSrcweir {
1218cdf0e10cSrcweir const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1219cdf0e10cSrcweir SwFmtRowSplit* pSplit = 0;
1220cdf0e10cSrcweir if(!pBool)
1221cdf0e10cSrcweir {
1222cdf0e10cSrcweir rSh.GetRowSplit(pSplit);
1223cdf0e10cSrcweir if(pSplit)
1224cdf0e10cSrcweir pSplit->SetValue(!pSplit->GetValue());
1225cdf0e10cSrcweir else
1226cdf0e10cSrcweir pSplit = new SwFmtRowSplit(sal_True);
1227cdf0e10cSrcweir }
1228cdf0e10cSrcweir else
1229cdf0e10cSrcweir {
1230cdf0e10cSrcweir pSplit = new SwFmtRowSplit(pBool->GetValue());
1231cdf0e10cSrcweir }
1232cdf0e10cSrcweir rSh.SetRowSplit( *pSplit );
1233cdf0e10cSrcweir delete pSplit;
1234cdf0e10cSrcweir }
1235cdf0e10cSrcweir break;
1236cdf0e10cSrcweir
1237cdf0e10cSrcweir default:
1238cdf0e10cSrcweir ASSERT( !this, "falscher Dispatcher" );
1239cdf0e10cSrcweir return;
1240cdf0e10cSrcweir }
1241cdf0e10cSrcweir if(bCallDone)
1242cdf0e10cSrcweir rReq.Done();
1243cdf0e10cSrcweir }
1244cdf0e10cSrcweir /*--------------------------------------------------------------------
1245cdf0e10cSrcweir Beschreibung:
1246cdf0e10cSrcweir --------------------------------------------------------------------*/
1247cdf0e10cSrcweir
GetState(SfxItemSet & rSet)1248cdf0e10cSrcweir void SwTableShell::GetState(SfxItemSet &rSet)
1249cdf0e10cSrcweir {
1250cdf0e10cSrcweir SfxWhichIter aIter( rSet );
1251cdf0e10cSrcweir SwWrtShell &rSh = GetShell();
1252cdf0e10cSrcweir SwFrmFmt *pFmt = rSh.GetTableFmt();
1253cdf0e10cSrcweir // os #124829# crash report: in case of an invalid shell selection return immediately
1254cdf0e10cSrcweir if(!pFmt)
1255cdf0e10cSrcweir return;
1256cdf0e10cSrcweir sal_uInt16 nSlot = aIter.FirstWhich();
1257cdf0e10cSrcweir while ( nSlot )
1258cdf0e10cSrcweir {
1259cdf0e10cSrcweir switch ( nSlot )
1260cdf0e10cSrcweir {
1261cdf0e10cSrcweir case FN_TABLE_MERGE_CELLS:
1262cdf0e10cSrcweir if ( !rSh.IsTableMode() )
1263cdf0e10cSrcweir rSet.DisableItem(FN_TABLE_MERGE_CELLS);
1264cdf0e10cSrcweir break;
1265cdf0e10cSrcweir case FN_TABLE_ADJUST_CELLS:
1266cdf0e10cSrcweir if ( !rSh.IsAdjustCellWidthAllowed() )
1267cdf0e10cSrcweir rSet.DisableItem(FN_TABLE_ADJUST_CELLS);
1268cdf0e10cSrcweir break;
1269cdf0e10cSrcweir
1270cdf0e10cSrcweir case FN_TABLE_BALANCE_CELLS:
1271cdf0e10cSrcweir if ( !rSh.IsAdjustCellWidthAllowed(sal_True) )
1272cdf0e10cSrcweir rSet.DisableItem(FN_TABLE_BALANCE_CELLS);
1273cdf0e10cSrcweir break;
1274cdf0e10cSrcweir
1275cdf0e10cSrcweir case FN_TABLE_BALANCE_ROWS:
1276cdf0e10cSrcweir if ( !rSh.BalanceRowHeight(sal_True) )
1277cdf0e10cSrcweir rSet.DisableItem(FN_TABLE_BALANCE_ROWS);
1278cdf0e10cSrcweir break;
1279cdf0e10cSrcweir case FN_OPTIMIZE_TABLE:
1280cdf0e10cSrcweir if ( !rSh.IsTableMode() &&
1281cdf0e10cSrcweir !rSh.IsAdjustCellWidthAllowed() &&
1282cdf0e10cSrcweir !rSh.IsAdjustCellWidthAllowed(sal_True) &&
1283cdf0e10cSrcweir !rSh.BalanceRowHeight(sal_True) )
1284cdf0e10cSrcweir rSet.DisableItem(FN_OPTIMIZE_TABLE);
1285cdf0e10cSrcweir break;
1286cdf0e10cSrcweir case SID_INSERT_DIAGRAM:
1287cdf0e10cSrcweir {
1288cdf0e10cSrcweir SvtModuleOptions aMOpt;
1289cdf0e10cSrcweir if ( !aMOpt.IsMath() || rSh.IsTblComplexForChart() )
1290cdf0e10cSrcweir rSet.DisableItem(nSlot);
1291cdf0e10cSrcweir }
1292cdf0e10cSrcweir break;
1293cdf0e10cSrcweir
1294*69a74367SOliver-Rainer Wittmann case FN_INSERT_TABLE:
1295*69a74367SOliver-Rainer Wittmann if ( rSh.CrsrInsideInputFld() )
1296*69a74367SOliver-Rainer Wittmann {
1297*69a74367SOliver-Rainer Wittmann rSet.DisableItem( nSlot );
1298*69a74367SOliver-Rainer Wittmann }
1299*69a74367SOliver-Rainer Wittmann break;
1300cdf0e10cSrcweir
1301cdf0e10cSrcweir case FN_TABLE_OPTIMAL_HEIGHT:
1302cdf0e10cSrcweir {
1303cdf0e10cSrcweir //Disablen wenn bereits auto-Hoehe eingestellt ist.
1304cdf0e10cSrcweir SwFmtFrmSize *pSz;
1305cdf0e10cSrcweir rSh.GetRowHeight( pSz );
1306cdf0e10cSrcweir if ( pSz )
1307cdf0e10cSrcweir {
1308cdf0e10cSrcweir if ( ATT_VAR_SIZE == pSz->GetHeightSizeType() )
1309cdf0e10cSrcweir rSet.DisableItem( nSlot );
1310cdf0e10cSrcweir delete pSz;
1311cdf0e10cSrcweir }
1312cdf0e10cSrcweir }
1313cdf0e10cSrcweir break;
1314cdf0e10cSrcweir case FN_TABLE_INSERT_ROW:
1315cdf0e10cSrcweir case FN_TABLE_INSERT_ROW_DLG:
1316cdf0e10cSrcweir {
1317cdf0e10cSrcweir if ( rSh.IsInRepeatedHeadline() )
1318cdf0e10cSrcweir rSet.DisableItem( nSlot );
1319cdf0e10cSrcweir }
1320cdf0e10cSrcweir break;
1321cdf0e10cSrcweir case RES_LR_SPACE:
1322cdf0e10cSrcweir rSet.Put(pFmt->GetLRSpace());
1323cdf0e10cSrcweir break;
1324cdf0e10cSrcweir case RES_UL_SPACE:
1325cdf0e10cSrcweir rSet.Put(pFmt->GetULSpace());
1326cdf0e10cSrcweir break;
132723257455SOliver-Rainer Wittmann
132823257455SOliver-Rainer Wittmann case SID_TABLE_VERT_NONE:
132923257455SOliver-Rainer Wittmann case SID_TABLE_VERT_CENTER:
133023257455SOliver-Rainer Wittmann case SID_TABLE_VERT_BOTTOM:
133123257455SOliver-Rainer Wittmann {
133223257455SOliver-Rainer Wittmann sal_uInt16 nAlign = rSh.GetBoxAlign();
133323257455SOliver-Rainer Wittmann sal_Bool bSet = nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE||
1334512ec161SZheng Fan nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER ||
1335512ec161SZheng Fan nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM;
133623257455SOliver-Rainer Wittmann rSet.Put(SfxBoolItem(nSlot, bSet));
133723257455SOliver-Rainer Wittmann }
133823257455SOliver-Rainer Wittmann break;
1339cdf0e10cSrcweir
1340cdf0e10cSrcweir case FN_TABLE_MODE_FIX :
1341cdf0e10cSrcweir case FN_TABLE_MODE_FIX_PROP :
1342cdf0e10cSrcweir case FN_TABLE_MODE_VARIABLE :
1343cdf0e10cSrcweir {
1344cdf0e10cSrcweir TblChgMode nMode = rSh.GetTblChgMode();
1345cdf0e10cSrcweir sal_Bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TBLFIX_CHGABS) ||
1346cdf0e10cSrcweir (nSlot == FN_TABLE_MODE_FIX_PROP && nMode == TBLFIX_CHGPROP) ||
1347cdf0e10cSrcweir (nSlot == FN_TABLE_MODE_VARIABLE && nMode == TBLVAR_CHGABS);
1348cdf0e10cSrcweir rSet.Put(SfxBoolItem(nSlot, bSet));
1349cdf0e10cSrcweir }
1350cdf0e10cSrcweir break;
1351cdf0e10cSrcweir
1352cdf0e10cSrcweir case SID_ATTR_PARA_SPLIT:
1353cdf0e10cSrcweir rSet.Put( pFmt->GetKeep() );
1354cdf0e10cSrcweir break;
1355cdf0e10cSrcweir
1356cdf0e10cSrcweir case SID_ATTR_PARA_KEEP:
1357cdf0e10cSrcweir rSet.Put( pFmt->GetLayoutSplit() );
1358cdf0e10cSrcweir break;
1359cdf0e10cSrcweir case FN_TABLE_SPLIT_TABLE:
1360cdf0e10cSrcweir {
1361cdf0e10cSrcweir if ( rSh.IsInHeadline() )
1362cdf0e10cSrcweir rSet.DisableItem( nSlot );
1363cdf0e10cSrcweir }
1364cdf0e10cSrcweir break;
1365cdf0e10cSrcweir case FN_TABLE_MERGE_TABLE:
1366cdf0e10cSrcweir {
1367cdf0e10cSrcweir sal_Bool bAsk;
1368cdf0e10cSrcweir if( !rSh.CanMergeTable( sal_True, &bAsk ))
1369cdf0e10cSrcweir rSet.DisableItem( nSlot );
1370cdf0e10cSrcweir }
1371cdf0e10cSrcweir break;
1372cdf0e10cSrcweir
1373cdf0e10cSrcweir case FN_TABLE_DELETE_ROW:
1374cdf0e10cSrcweir {
1375cdf0e10cSrcweir SwSelBoxes aBoxes;
1376cdf0e10cSrcweir ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_ROW );
1377cdf0e10cSrcweir if( ::HasProtectedCells( aBoxes ))
1378cdf0e10cSrcweir rSet.DisableItem( nSlot );
1379cdf0e10cSrcweir }
1380cdf0e10cSrcweir break;
1381cdf0e10cSrcweir case FN_TABLE_DELETE_COL:
1382cdf0e10cSrcweir {
1383cdf0e10cSrcweir SwSelBoxes aBoxes;
1384cdf0e10cSrcweir ::GetTblSel( rSh, aBoxes, nsSwTblSearchType::TBLSEARCH_COL );
1385cdf0e10cSrcweir if( ::HasProtectedCells( aBoxes ))
1386cdf0e10cSrcweir rSet.DisableItem( nSlot );
1387cdf0e10cSrcweir }
1388cdf0e10cSrcweir break;
1389cdf0e10cSrcweir
1390cdf0e10cSrcweir case FN_TABLE_UNSET_READ_ONLY_CELLS:
1391cdf0e10cSrcweir // disable in readonly sections, but enable in protected cells
1392cdf0e10cSrcweir if( !rSh.CanUnProtectCells() )
1393cdf0e10cSrcweir rSet.DisableItem( nSlot );
1394cdf0e10cSrcweir break;
1395cdf0e10cSrcweir case RES_ROW_SPLIT:
1396cdf0e10cSrcweir {
1397cdf0e10cSrcweir const SwFmtLayoutSplit& rTabSplit = pFmt->GetLayoutSplit();
1398cdf0e10cSrcweir if ( 0 == rTabSplit.GetValue() )
1399cdf0e10cSrcweir {
1400cdf0e10cSrcweir rSet.DisableItem( nSlot );
1401cdf0e10cSrcweir }
1402cdf0e10cSrcweir else
1403cdf0e10cSrcweir {
1404cdf0e10cSrcweir SwFmtRowSplit* pSplit = 0;
1405cdf0e10cSrcweir rSh.GetRowSplit(pSplit);
1406cdf0e10cSrcweir if(pSplit)
1407cdf0e10cSrcweir rSet.Put(*pSplit);
1408cdf0e10cSrcweir else
1409cdf0e10cSrcweir rSet.InvalidateItem( nSlot );
1410cdf0e10cSrcweir delete pSplit;
1411cdf0e10cSrcweir }
1412cdf0e10cSrcweir }
1413cdf0e10cSrcweir break;
1414cdf0e10cSrcweir case FN_TABLE_HEADLINE_REPEAT:
1415cdf0e10cSrcweir if(0 != rSh.GetRowsToRepeat())
1416cdf0e10cSrcweir rSet.Put(SfxBoolItem(nSlot, sal_True));
1417cdf0e10cSrcweir else if(!rSh.GetRowSelectionFromTop())
1418cdf0e10cSrcweir rSet.DisableItem( nSlot );
1419cdf0e10cSrcweir else
1420cdf0e10cSrcweir rSet.Put(SfxBoolItem(nSlot, sal_False));
1421cdf0e10cSrcweir break;
1422cdf0e10cSrcweir case FN_TABLE_SELECT_CELL :
1423cdf0e10cSrcweir if(rSh.HasBoxSelection())
1424cdf0e10cSrcweir rSet.DisableItem( nSlot );
1425cdf0e10cSrcweir break;
1426cdf0e10cSrcweir }
1427cdf0e10cSrcweir nSlot = aIter.NextWhich();
1428cdf0e10cSrcweir }
1429cdf0e10cSrcweir }
1430cdf0e10cSrcweir
1431cdf0e10cSrcweir /*--------------------------------------------------------------------
1432cdf0e10cSrcweir Beschreibung:
1433cdf0e10cSrcweir --------------------------------------------------------------------*/
1434cdf0e10cSrcweir
SwTableShell(SwView & _rView)1435cdf0e10cSrcweir SwTableShell::SwTableShell(SwView &_rView) :
1436cdf0e10cSrcweir SwBaseShell(_rView)
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir SetName(String::CreateFromAscii("Table"));
1439cdf0e10cSrcweir SetHelpId(SW_TABSHELL);
1440f120fe41SAndre Fischer SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Table));
1441cdf0e10cSrcweir }
1442cdf0e10cSrcweir
1443cdf0e10cSrcweir /*--------------------------------------------------------------------
1444cdf0e10cSrcweir Beschreibung:
1445cdf0e10cSrcweir --------------------------------------------------------------------*/
1446cdf0e10cSrcweir
GetFrmBorderState(SfxItemSet & rSet)1447cdf0e10cSrcweir void SwTableShell::GetFrmBorderState(SfxItemSet &rSet)
1448cdf0e10cSrcweir {
1449cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(),
1450cdf0e10cSrcweir RES_BOX, RES_BOX,
1451cdf0e10cSrcweir SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0 );
1452cdf0e10cSrcweir SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1453cdf0e10cSrcweir aCoreSet.Put( aBoxInfo );
1454cdf0e10cSrcweir GetShell().GetTabBorders( aCoreSet );
1455cdf0e10cSrcweir rSet.Put( aCoreSet );
1456cdf0e10cSrcweir }
1457cdf0e10cSrcweir
1458cdf0e10cSrcweir /*--------------------------------------------------------------------
1459cdf0e10cSrcweir Beschreibung:
1460cdf0e10cSrcweir --------------------------------------------------------------------*/
1461cdf0e10cSrcweir
ExecTableStyle(SfxRequest & rReq)1462cdf0e10cSrcweir void SwTableShell::ExecTableStyle(SfxRequest& rReq)
1463cdf0e10cSrcweir {
1464cdf0e10cSrcweir SwWrtShell &rSh = GetShell();
1465cdf0e10cSrcweir const SfxItemSet *pArgs = rReq.GetArgs();
1466cdf0e10cSrcweir if(pArgs)
1467cdf0e10cSrcweir switch ( rReq.GetSlot() )
1468cdf0e10cSrcweir {
1469cdf0e10cSrcweir case SID_FRAME_LINESTYLE:
1470cdf0e10cSrcweir case SID_FRAME_LINECOLOR:
1471cdf0e10cSrcweir {
1472cdf0e10cSrcweir /* Tabellenselektion ist abgeschafft
1473cdf0e10cSrcweir sal_Bool bPopCrsr = sal_False;
1474cdf0e10cSrcweir if ( !rReq.IsAPI() )
1475cdf0e10cSrcweir {
1476cdf0e10cSrcweir //Keine Tabellenselektion -> Aenderung wird auf die gesamte
1477cdf0e10cSrcweir //Tabelle.
1478cdf0e10cSrcweir if ( !rSh.IsTableMode() )
1479cdf0e10cSrcweir {
1480cdf0e10cSrcweir bPopCrsr = sal_True;
1481cdf0e10cSrcweir rSh.Push();
1482cdf0e10cSrcweir rSh.StartAction();
1483cdf0e10cSrcweir rSh.EnterStdMode();
1484cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableStart );
1485cdf0e10cSrcweir rSh.SttSelect();
1486cdf0e10cSrcweir rSh.MoveTable( fnTableCurr, fnTableEnd );
1487cdf0e10cSrcweir rSh.EndSelect();
1488cdf0e10cSrcweir }
1489cdf0e10cSrcweir }*/
1490cdf0e10cSrcweir if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1491cdf0e10cSrcweir {
1492cdf0e10cSrcweir const SvxLineItem &rLineItem = (const SvxLineItem&)pArgs->
1493cdf0e10cSrcweir Get( SID_FRAME_LINESTYLE );
1494cdf0e10cSrcweir const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1495cdf0e10cSrcweir rSh.SetTabLineStyle( 0, sal_True, pBorderLine);
1496cdf0e10cSrcweir }
1497cdf0e10cSrcweir else
1498cdf0e10cSrcweir {
1499cdf0e10cSrcweir const SvxColorItem &rNewColorItem = (const SvxColorItem&)pArgs->
1500cdf0e10cSrcweir Get( SID_FRAME_LINECOLOR );
1501cdf0e10cSrcweir rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1502cdf0e10cSrcweir }
1503cdf0e10cSrcweir
1504cdf0e10cSrcweir rReq.Done();
1505cdf0e10cSrcweir /* if ( bPopCrsr )
1506cdf0e10cSrcweir {
1507cdf0e10cSrcweir rSh.KillPams();
1508cdf0e10cSrcweir rSh.Pop(sal_False);
1509cdf0e10cSrcweir rSh.EndAction();
1510cdf0e10cSrcweir }*/
1511cdf0e10cSrcweir break;
1512cdf0e10cSrcweir }
1513cdf0e10cSrcweir }
1514cdf0e10cSrcweir }
1515cdf0e10cSrcweir
1516cdf0e10cSrcweir
GetLineStyleState(SfxItemSet & rSet)1517cdf0e10cSrcweir void SwTableShell::GetLineStyleState(SfxItemSet &rSet)
1518cdf0e10cSrcweir {
1519cdf0e10cSrcweir SfxItemSet aCoreSet( GetPool(),
1520cdf0e10cSrcweir RES_BOX, RES_BOX,
1521cdf0e10cSrcweir SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 0);
1522cdf0e10cSrcweir SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1523cdf0e10cSrcweir aCoreSet.Put(aCoreInfo);
1524cdf0e10cSrcweir GetShell().GetTabBorders( aCoreSet );
1525cdf0e10cSrcweir
1526cdf0e10cSrcweir const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aCoreSet.Get( RES_BOX );
1527cdf0e10cSrcweir const SvxBorderLine* pLine = rBoxItem.GetTop();
1528cdf0e10cSrcweir
1529cdf0e10cSrcweir rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1530cdf0e10cSrcweir SvxLineItem aLine( SID_FRAME_LINESTYLE );
1531cdf0e10cSrcweir aLine.SetLine(pLine);
1532cdf0e10cSrcweir rSet.Put( aLine );
1533cdf0e10cSrcweir }
1534cdf0e10cSrcweir
ExecNumberFormat(SfxRequest & rReq)1535cdf0e10cSrcweir void SwTableShell::ExecNumberFormat(SfxRequest& rReq)
1536cdf0e10cSrcweir {
1537cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs();
1538cdf0e10cSrcweir SwWrtShell &rSh = GetShell();
1539cdf0e10cSrcweir
1540cdf0e10cSrcweir //Erstmal die Slots, die keinen FrmMgr benoetigen.
1541cdf0e10cSrcweir const SfxPoolItem* pItem = 0;
1542cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot();
1543cdf0e10cSrcweir if(pArgs)
1544cdf0e10cSrcweir pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem);
1545cdf0e10cSrcweir
1546cdf0e10cSrcweir // Sprache immer von Cursorposition besorgen
1547cdf0e10cSrcweir LanguageType eLang = rSh.GetCurLang();
1548cdf0e10cSrcweir SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1549cdf0e10cSrcweir sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1550cdf0e10cSrcweir sal_uInt16 nFmtType = 0, nOffset = 0;
1551cdf0e10cSrcweir
1552cdf0e10cSrcweir switch ( nSlot )
1553cdf0e10cSrcweir {
1554cdf0e10cSrcweir case FN_NUMBER_FORMAT:
1555cdf0e10cSrcweir if( pItem )
1556cdf0e10cSrcweir {
1557cdf0e10cSrcweir // Index fuer String bestimmen
1558cdf0e10cSrcweir String aCode( ((const SfxStringItem*)pItem)->GetValue() );
1559cdf0e10cSrcweir nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1560cdf0e10cSrcweir if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1561cdf0e10cSrcweir {
1562cdf0e10cSrcweir // neu eintragen
1563cdf0e10cSrcweir xub_StrLen nErrPos;
1564cdf0e10cSrcweir short nType;
1565cdf0e10cSrcweir if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1566cdf0e10cSrcweir nNumberFormat, eLang ))
1567cdf0e10cSrcweir nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1568cdf0e10cSrcweir }
1569cdf0e10cSrcweir }
1570cdf0e10cSrcweir break;
1571cdf0e10cSrcweir case FN_NUMBER_STANDARD: nFmtType = NUMBERFORMAT_NUMBER; break;
1572cdf0e10cSrcweir case FN_NUMBER_SCIENTIFIC: nFmtType = NUMBERFORMAT_SCIENTIFIC; break;
1573cdf0e10cSrcweir case FN_NUMBER_DATE: nFmtType = NUMBERFORMAT_DATE; break;
1574cdf0e10cSrcweir case FN_NUMBER_TIME: nFmtType = NUMBERFORMAT_TIME; break;
1575cdf0e10cSrcweir case FN_NUMBER_CURRENCY: nFmtType = NUMBERFORMAT_CURRENCY; break;
1576cdf0e10cSrcweir case FN_NUMBER_PERCENT: nFmtType = NUMBERFORMAT_PERCENT; break;
1577cdf0e10cSrcweir
1578cdf0e10cSrcweir case FN_NUMBER_TWODEC: // #.##0,00
1579cdf0e10cSrcweir nFmtType = NUMBERFORMAT_NUMBER;
1580cdf0e10cSrcweir nOffset = NF_NUMBER_1000DEC2;
1581cdf0e10cSrcweir break;
1582cdf0e10cSrcweir
1583cdf0e10cSrcweir default:
1584cdf0e10cSrcweir ASSERT(sal_False, falscher Dispatcher);
1585cdf0e10cSrcweir return;
1586cdf0e10cSrcweir }
1587cdf0e10cSrcweir
1588cdf0e10cSrcweir if( nFmtType )
1589cdf0e10cSrcweir nNumberFormat = pFormatter->GetStandardFormat( nFmtType, eLang ) + nOffset;
1590cdf0e10cSrcweir
1591cdf0e10cSrcweir if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1592cdf0e10cSrcweir {
1593cdf0e10cSrcweir SfxItemSet aBoxSet( GetPool(), RES_BOXATR_FORMAT, RES_BOXATR_FORMAT );
1594cdf0e10cSrcweir aBoxSet.Put( SwTblBoxNumFormat( nNumberFormat ));
1595cdf0e10cSrcweir rSh.SetTblBoxFormulaAttrs( aBoxSet );
1596cdf0e10cSrcweir }
1597cdf0e10cSrcweir
1598cdf0e10cSrcweir }
1599