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