1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: tabsh.cxx,v $
10 * $Revision: 1.46.212.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
33 #include <hintids.hxx>
36 #define _ZFORLIST_DECLARE_TABLE
37 #include <svtools/zforlist.hxx>
39 #include <svtools/stritem.hxx>
40 #include <svtools/whiter.hxx>
41 #include <svtools/moduleoptions.hxx>
42 #include <svx/rulritem.hxx>
43 #include <svx/srchitem.hxx>
44 #include <svx/lrspitem.hxx>
45 #include <svx/ulspitem.hxx>
46 #include <svx/brshitem.hxx>
47 #include <svx/boxitem.hxx>
48 #include <svx/shaditem.hxx>
49 #include <svx/spltitem.hxx>
50 #include <svx/langitem.hxx>
51 #include <svx/keepitem.hxx>
52 #include <svx/bolnitem.hxx>
53 #include <svx/colritem.hxx>
54 #include <svx/frmdiritem.hxx>
55 #include <svx/numinf.hxx>
56 #include <svx/svddef.hxx>
57 #include <svx/svxdlg.hxx>
58 #include <svtools/zformat.hxx>
59 #include <sfx2/bindings.hxx>
60 #include <vcl/msgbox.hxx>
61 #include <sfx2/request.hxx>
62 #include <sfx2/dispatch.hxx>
63 #include <sfx2/objface.hxx>
66 #include <fmtornt.hxx>
67 #include <fmtclds.hxx>
68 #include <fmtlsplt.hxx>
69 #include <fmtrowsplt.hxx>
70 #include <fmtfsize.hxx>
71 #include <swmodule.hxx>
76 #include <inputwin.hxx>
77 #include <uiitems.hxx>
78 #include <usrpref.hxx>
80 #include "swtablerep.hxx"
81 #include <tablemgr.hxx>
82 #include <cellatr.hxx>
85 #include <swtable.hxx>
93 //!!! new: insert table
95 #include <svx/htmlmode.hxx>
97 #include <tblafmt.hxx>
98 #include <instable.hxx>
106 #include <shells.hrc>
115 #include <globals.hrc>
120 #include <unoobj.hxx>
123 #include <sfx2/msg.hxx>
124 #include <swslots.hxx>
126 #include "swabstdlg.hxx"
129 using namespace ::com::sun::star
;
131 //-----------------------------------------------------------------------------
133 SFX_IMPL_INTERFACE(SwTableShell
, SwBaseShell
, SW_RES(STR_SHELLNAME_TABLE
))
135 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_TAB_POPUPMENU
));
136 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT
, SW_RES(RID_TABLE_TOOLBOX
));
140 TYPEINIT1(SwTableShell
,SwBaseShell
)
142 /************************************************************************/
144 const USHORT __FAR_DATA aUITableAttrRange
[] =
146 FN_PARAM_TABLE_NAME
, FN_PARAM_TABLE_NAME
,
147 FN_PARAM_TABLE_HEADLINE
, FN_PARAM_TABLE_HEADLINE
,
148 FN_PARAM_TABLE_SPACE
, FN_PARAM_TABLE_SPACE
,
149 FN_TABLE_REP
, FN_TABLE_REP
,
150 SID_RULER_BORDERS
, SID_RULER_BORDERS
,
151 RES_LR_SPACE
, RES_UL_SPACE
,
152 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_SHADOW
,
154 RES_BACKGROUND
, RES_BACKGROUND
,
155 SID_BACKGRND_DESTINATION
, SID_BACKGRND_DESTINATION
,
156 SID_HTML_MODE
, SID_HTML_MODE
,
157 SID_ATTR_BRUSH_ROW
, SID_ATTR_BRUSH_TABLE
,
158 RES_PAGEDESC
, RES_BREAK
,
160 RES_LAYOUT_SPLIT
, RES_LAYOUT_SPLIT
,
161 FN_TABLE_SET_VERT_ALIGN
, FN_TABLE_SET_VERT_ALIGN
,
162 RES_FRAMEDIR
, RES_FRAMEDIR
,
163 RES_ROW_SPLIT
, RES_ROW_SPLIT
,
164 FN_TABLE_BOX_TEXTDIRECTION
, FN_TABLE_BOX_TEXTDIRECTION
,
165 // --> collapsing borders FME 2005-05-27 #i29550#
166 RES_COLLAPSING_BORDERS
, RES_COLLAPSING_BORDERS
,
167 // <-- collapsing borders
171 const USHORT
* SwuiGetUITableAttrRange()
173 return aUITableAttrRange
;
176 static void lcl_SetAttr( SwWrtShell
&rSh
, const SfxPoolItem
&rItem
)
178 SfxItemSet
aSet( rSh
.GetView().GetPool(), rItem
.Which(), rItem
.Which(), 0);
180 rSh
.SetTblAttr( aSet
);
183 /************************************************************************/
186 static SwTableRep
* lcl_TableParamToItemSet( SfxItemSet
& rSet
, SwWrtShell
&rSh
)
188 SwFrmFmt
*pFmt
= rSh
.GetTableFmt();
190 rSh
.GetTabCols( aCols
);
192 //Ersteinmal die einfachen Attribute besorgen.
193 rSet
.Put( SfxStringItem( FN_PARAM_TABLE_NAME
, pFmt
->GetName()));
194 rSet
.Put( SfxUInt16Item( FN_PARAM_TABLE_HEADLINE
, rSh
.GetRowsToRepeat() ) );
195 rSet
.Put( pFmt
->GetShadow() );
196 rSet
.Put(SfxUInt16Item(FN_TABLE_SET_VERT_ALIGN
, rSh
.GetBoxAlign()));
197 rSet
.Put( pFmt
->GetFrmDir() );
199 SvxULSpaceItem
aULSpace( pFmt
->GetULSpace() );
200 rSet
.Put( aULSpace
);
202 USHORT nBackgroundDestination
= rSh
.GetViewOptions()->GetTblDest();
203 rSet
.Put(SwBackgroundDestinationItem(SID_BACKGRND_DESTINATION
, nBackgroundDestination
));
204 SvxBrushItem
aBrush( RES_BACKGROUND
);
205 // rSh.GetBoxBackground(aBrush);
206 // rSet.Put( aBrush );
207 if(rSh
.GetRowBackground(aBrush
))
208 rSet
.Put( aBrush
, SID_ATTR_BRUSH_ROW
);
210 rSet
.InvalidateItem(SID_ATTR_BRUSH_ROW
);
211 rSh
.GetTabBackground(aBrush
);
212 rSet
.Put( aBrush
, SID_ATTR_BRUSH_TABLE
);
214 // text direction in boxes
215 SvxFrameDirectionItem
aBoxDirection( FRMDIR_ENVIRONMENT
, RES_FRAMEDIR
);
216 if(rSh
.GetBoxDirection( aBoxDirection
))
217 rSet
.Put(aBoxDirection
, FN_TABLE_BOX_TEXTDIRECTION
);
219 BOOL bTableSel
= rSh
.IsTableMode();
222 rSh
.StartAllAction();
224 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL
, FALSE
);
226 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
228 // Tabellenvariante, wenn mehrere Tabellenzellen selektiert
229 rSh
.GetCrsr(); //Damit GetCrsrCnt() auch das Richtige liefert
230 aBoxInfo
.SetTable (rSh
.IsTableMode() && rSh
.GetCrsrCnt() > 1 ||
232 // Abstandsfeld immer anzeigen
233 aBoxInfo
.SetDist ((BOOL
) TRUE
);
234 // Minimalgroesse in Tabellen und Absaetzen setzen
235 aBoxInfo
.SetMinDist( !bTableSel
|| rSh
.IsTableMode() ||
236 rSh
.GetSelectionType() &
237 (nsSelectionType::SEL_TXT
| nsSelectionType::SEL_TBL
));
238 // Default-Abstand immer setzen
239 aBoxInfo
.SetDefDist (MIN_BORDER_DIST
);
240 // Einzelne Linien koennen nur in Tabellen DontCare-Status haben
241 aBoxInfo
.SetValid( VALID_DISABLE
, !bTableSel
|| !rSh
.IsTableMode() );
244 rSh
.GetTabBorders( rSet
);
247 SwFmtRowSplit
* pSplit
= 0;
248 rSh
.GetRowSplit(pSplit
);
263 rSh
.GetTabCols( aTabCols
);
264 SvxColumnItem aColItem
;
267 // Pointer wird nach der Dialogausfuehrung geloescht
268 SwTableRep
* pRep
= new SwTableRep( aTabCols
, rSh
.IsTblComplex());
269 pRep
->SetSpace(aCols
.GetRightMax());
272 long nWidth
= ::GetTableWidth(pFmt
, aCols
, &nPercent
, &rSh
);
273 // Die Tabellenbreite ist fuer relative Angaben nicht korrekt
275 nWidth
= pRep
->GetSpace() * nPercent
/ 100;
276 USHORT nAlign
= pFmt
->GetHoriOrient().GetHoriOrient();
277 pRep
->SetAlign(nAlign
);
278 SvxLRSpaceItem
aLRSpace( pFmt
->GetLRSpace() );
279 SwTwips nLeft
= aLRSpace
.GetLeft();
280 SwTwips nRight
= aLRSpace
.GetRight();
281 SwTwips nDiff
= pRep
->GetSpace() - nRight
- nLeft
- nWidth
;
282 if(nAlign
!= text::HoriOrientation::FULL
&& Abs(nDiff
) > 2)
284 SwTwips nLR
= pRep
->GetSpace() - nWidth
;
287 case text::HoriOrientation::CENTER
: nLeft
= nRight
= nLR
/ 2;
289 case text::HoriOrientation::LEFT
: nRight
= nLR
; nLeft
= 0;
291 case text::HoriOrientation::RIGHT
: nLeft
= nLR
, nRight
= 0;
293 case text::HoriOrientation::LEFT_AND_WIDTH
:
294 nRight
= nLR
- nLeft
;
296 case text::HoriOrientation::NONE
:
298 nWidth
= pRep
->GetSpace() - nLeft
- nRight
;
302 pRep
->SetLeftSpace(nLeft
);
303 pRep
->SetRightSpace(nRight
);
305 pRep
->SetWidth(nWidth
);
306 pRep
->SetWidthPercent(nPercent
);
307 // sind einzelne Zeilen/Zellen selektiert, wird die Spaltenbearbeitung veraendert
308 pRep
->SetLineSelected(bTableSel
&& ! rSh
.HasWholeTabSelection());
309 rSet
.Put(SwPtrItem(FN_TABLE_REP
, pRep
));
313 /************************************************************************/
316 void ItemSetToTableParam( const SfxItemSet
& rSet
,
319 rSh
.StartAllAction();
320 rSh
.StartUndo( UNDO_TABLE_ATTR
);
321 const SfxPoolItem
* pItem
= 0;
323 SwViewOption
aUsrPref( *rSh
.GetViewOptions() );
324 USHORT nBackgroundDestination
= aUsrPref
.GetTblDest();
325 if(SFX_ITEM_SET
== rSet
.GetItemState(SID_BACKGRND_DESTINATION
, FALSE
, &pItem
))
327 nBackgroundDestination
= ((SfxUInt16Item
*)pItem
)->GetValue();
328 aUsrPref
.SetTblDest((BYTE
)nBackgroundDestination
);
329 SW_MOD()->ApplyUsrPref(aUsrPref
, &rSh
.GetView());
331 BOOL bBorder
= ( SFX_ITEM_SET
== rSet
.GetItemState( RES_BOX
) ||
332 SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_BORDER_INNER
) );
334 BOOL bBackground
= SFX_ITEM_SET
== rSet
.GetItemState( RES_BACKGROUND
, FALSE
, &pItem
);
335 const SfxPoolItem
* pRowItem
= 0, *pTableItem
= 0;
336 bBackground
|= SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_BRUSH_ROW
, FALSE
, &pRowItem
);
337 bBackground
|= SFX_ITEM_SET
== rSet
.GetItemState( SID_ATTR_BRUSH_TABLE
, FALSE
, &pTableItem
);
338 const SfxPoolItem
* pSplit
= 0;
339 BOOL bRowSplit
= SFX_ITEM_SET
== rSet
.GetItemState( RES_ROW_SPLIT
, FALSE
, &pSplit
);
340 const SfxPoolItem
* pBoxDirection
= 0;
341 BOOL bBoxDirection
= SFX_ITEM_SET
== rSet
.GetItemState( FN_TABLE_BOX_TEXTDIRECTION
, FALSE
, &pBoxDirection
);
342 if( bBackground
|| bBorder
|| bRowSplit
|| bBoxDirection
)
345 Die Umrandung wird auf die vorliegende Selektion angewendet
346 Liegt keine Selektion vor, wird die Tabelle vollstaendig selektiert.
347 Der Hintergrund wird immer auf den aktuellen Zustand angewendet.
350 BOOL bTableSel
= rSh
.IsTableMode();
351 rSh
.StartAllAction();
356 rSh
.SetBoxBackground( *(const SvxBrushItem
*)pItem
);
359 SvxBrushItem
aBrush(*(const SvxBrushItem
*)pRowItem
);
360 aBrush
.SetWhich(RES_BACKGROUND
);
361 rSh
.SetRowBackground(aBrush
);
365 SvxBrushItem
aBrush(*(const SvxBrushItem
*)pTableItem
);
366 aBrush
.SetWhich(RES_BACKGROUND
);
367 rSh
.SetTabBackground( aBrush
);
373 SvxFrameDirectionItem
aDirection( FRMDIR_ENVIRONMENT
, RES_FRAMEDIR
);
374 aDirection
.SetValue(static_cast< const SvxFrameDirectionItem
* >(pBoxDirection
)->GetValue());
375 rSh
.SetBoxDirection(aDirection
);
378 if(bBorder
|| bRowSplit
)
383 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_TABLE_SELECT_ALL
);
386 rSh
.SetTabBorders( rSet
);
390 rSh
.SetRowSplit(*static_cast<const SwFmtRowSplit
*>(pSplit
));
404 BOOL bTabCols
= FALSE
;
405 BOOL bSingleLine
= FALSE
;
406 SwTableRep
* pRep
= 0;
407 SwFrmFmt
*pFmt
= rSh
.GetTableFmt();
408 SfxItemSet
aSet( rSh
.GetAttrPool(), RES_FRMATR_BEGIN
, RES_FRMATR_END
-1 );
409 if(SFX_ITEM_SET
== rSet
.GetItemState( FN_TABLE_REP
, FALSE
, &pItem
))
411 pRep
= (SwTableRep
*)((const SwPtrItem
*)pItem
)->GetValue();
413 const SwTwips nWidth
= pRep
->GetWidth();
414 if ( text::HoriOrientation::FULL
== pRep
->GetAlign() )
416 SwFmtHoriOrient
aAttr( pFmt
->GetHoriOrient() );
417 aAttr
.SetHoriOrient( text::HoriOrientation::FULL
);
422 SwFmtFrmSize
aSz( ATT_VAR_SIZE
, nWidth
);
423 if(pRep
->GetWidthPercent())
425 aSz
.SetWidthPercent( (BYTE
)pRep
->GetWidthPercent() );
430 SvxLRSpaceItem
aLRSpace( RES_LR_SPACE
);
431 aLRSpace
.SetLeft(pRep
->GetLeftSpace());
432 aLRSpace
.SetRight(pRep
->GetRightSpace());
433 aSet
.Put( aLRSpace
);
435 sal_Int16 eOrient
= pRep
->GetAlign();
436 SwFmtHoriOrient
aAttr( 0, eOrient
);
438 // Damit beim recording die Ausrichtung nicht durch die Abstaende ueberschrieben
439 // wird, darf das Item nur bei manueller Ausrichtung aufgez. werden
440 if(eOrient
!= text::HoriOrientation::NONE
)
441 ((SfxItemSet
&)rSet
).ClearItem( SID_ATTR_LRSPACE
);
444 if(pRep
->HasColsChanged())
451 if( SFX_ITEM_SET
== rSet
.GetItemState( FN_PARAM_TABLE_HEADLINE
, FALSE
, &pItem
))
452 rSh
.SetRowsToRepeat( ((SfxUInt16Item
*)pItem
)->GetValue() );
454 if( SFX_ITEM_SET
== rSet
.GetItemState( FN_TABLE_SET_VERT_ALIGN
, FALSE
, &pItem
))
455 rSh
.SetBoxAlign(((SfxUInt16Item
*)(pItem
))->GetValue());
457 if( SFX_ITEM_SET
== rSet
.GetItemState( FN_PARAM_TABLE_NAME
, FALSE
, &pItem
))
458 rSh
.SetTableName( *pFmt
, ((const SfxStringItem
*)pItem
)->GetValue() );
460 // kopiere die ausgesuchten Attribute in den ItemSet
461 static USHORT __READONLY_DATA aIds
[] =
470 // --> collapsing borders FME 2005-05-27 #i29550#
471 RES_COLLAPSING_BORDERS
,
472 // <-- collapsing borders
475 for( const USHORT
* pIds
= aIds
; *pIds
; ++pIds
)
476 if( SFX_ITEM_SET
== rSet
.GetItemState( *pIds
, FALSE
, &pItem
))
480 rSh
.SetTblAttr( aSet
);
484 rSh
.GetTabCols( aTabCols
);
485 bSingleLine
= pRep
->FillTabCols( aTabCols
);
486 rSh
.SetTabCols( aTabCols
, bSingleLine
);
489 rSh
.EndUndo( UNDO_TABLE_ATTR
);
493 /************************************************************************/
496 static void lcl_TabGetMaxLineWidth(const SvxBorderLine
* pBorderLine
, SvxBorderLine
& rBorderLine
)
498 if(pBorderLine
->GetInWidth() > rBorderLine
.GetInWidth())
499 rBorderLine
.SetInWidth(pBorderLine
->GetInWidth());
501 if(pBorderLine
->GetOutWidth() > rBorderLine
.GetOutWidth())
502 rBorderLine
.SetOutWidth(pBorderLine
->GetOutWidth());
504 if(pBorderLine
->GetDistance() > rBorderLine
.GetDistance())
505 rBorderLine
.SetDistance(pBorderLine
->GetDistance());
507 rBorderLine
.SetColor(pBorderLine
->GetColor());
511 void SwTableShell::Execute(SfxRequest
&rReq
)
513 BOOL bUseDialog
= TRUE
;
514 const SfxItemSet
* pArgs
= rReq
.GetArgs();
515 SwWrtShell
&rSh
= GetShell();
517 //Erstmal die Slots, die keinen FrmMgr benoetigen.
519 const SfxPoolItem
* pItem
= 0;
520 USHORT nSlot
= rReq
.GetSlot();
522 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), FALSE
, &pItem
);
523 BOOL bCallDone
= FALSE
;
526 case SID_ATTR_BORDER
:
528 /* BOOL bPopCrsr = FALSE;
531 //Keine Tabellenselektion -> Aenderung wird auf die gesamte
533 if ( !rSh.IsTableMode() )
539 rSh.MoveTable( fnTableCurr, fnTableStart );
541 rSh.MoveTable( fnTableCurr, fnTableEnd );
547 //Items erzeugen, weil wir sowieso nacharbeiten muessen
548 SvxBoxItem
aBox( RES_BOX
);
549 SfxItemSet
aCoreSet( GetPool(),
551 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
,
553 SvxBoxInfoItem
aCoreInfo( SID_ATTR_BORDER_INNER
);
554 aCoreSet
.Put(aCoreInfo
);
555 rSh
.GetTabBorders( aCoreSet
);
556 const SvxBoxItem
& rCoreBox
= (const SvxBoxItem
&)
557 aCoreSet
.Get(RES_BOX
);
558 const SfxPoolItem
*pBoxItem
= 0;
559 if ( pArgs
->GetItemState(RES_BOX
, TRUE
, &pBoxItem
) == SFX_ITEM_SET
)
561 aBox
= *(SvxBoxItem
*)pBoxItem
;
563 aBox
.SetDistance( Max(rCoreBox
.GetDistance(),USHORT(55)) );
564 else if ( aBox
.GetDistance() < MIN_BORDER_DIST
)
565 aBox
.SetDistance( Max(rCoreBox
.GetDistance(),(USHORT
)MIN_BORDER_DIST
) );
568 {ASSERT( !this, "Wo ist das Box-Item?" )}
570 //since the drawing layer also supports borders the which id might be a different one
571 SvxBoxInfoItem
aInfo( SID_ATTR_BORDER_INNER
);
572 if (pArgs
->GetItemState(SID_ATTR_BORDER_INNER
, TRUE
, &pBoxItem
) == SFX_ITEM_SET
)
573 aInfo
= *(SvxBoxInfoItem
*)pBoxItem
;
574 else if( pArgs
->GetItemState(SDRATTR_TABLE_BORDER_INNER
, TRUE
, &pBoxItem
) == SFX_ITEM_SET
)
576 aInfo
= *(SvxBoxInfoItem
*)pBoxItem
;
577 aInfo
.SetWhich(SID_ATTR_BORDER_INNER
);
580 aInfo
.SetTable( TRUE
);
581 aInfo
.SetValid( VALID_DISABLE
, FALSE
);
584 // Die Attribute aller Linien werden gelesen und das staerkste gewinnt
585 const SvxBorderLine
* pBorderLine
;
586 SvxBorderLine aBorderLine
;
587 if ((pBorderLine
= rCoreBox
.GetTop()) != NULL
)
588 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
589 if ((pBorderLine
= rCoreBox
.GetBottom()) != NULL
)
590 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
591 if ((pBorderLine
= rCoreBox
.GetLeft()) != NULL
)
592 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
593 if ((pBorderLine
= rCoreBox
.GetRight()) != NULL
)
594 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
595 if ((pBorderLine
= aCoreInfo
.GetHori()) != NULL
)
596 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
597 if ((pBorderLine
= aCoreInfo
.GetVert()) != NULL
)
598 lcl_TabGetMaxLineWidth(pBorderLine
, aBorderLine
);
600 if(aBorderLine
.GetOutWidth() == 0)
602 aBorderLine
.SetInWidth(0);
603 aBorderLine
.SetOutWidth(DEF_LINE_WIDTH_0
);
607 if ( (pBorderLine
= aBox
.GetTop()) != NULL
)
608 aBox
.SetLine(&aBorderLine
, BOX_LINE_TOP
), bLine
|= TRUE
;
609 if ((pBorderLine
= aBox
.GetBottom()) != NULL
)
610 aBox
.SetLine(&aBorderLine
, BOX_LINE_BOTTOM
), bLine
|= TRUE
;
611 if ((pBorderLine
= aBox
.GetLeft()) != NULL
)
612 aBox
.SetLine(&aBorderLine
, BOX_LINE_LEFT
), bLine
|= TRUE
;
613 if ((pBorderLine
= aBox
.GetRight()) != NULL
)
614 aBox
.SetLine(&aBorderLine
, BOX_LINE_RIGHT
), bLine
|= TRUE
;
615 if ((pBorderLine
= aInfo
.GetHori()) != NULL
)
616 aInfo
.SetLine(&aBorderLine
, BOXINFO_LINE_HORI
), bLine
|= TRUE
;
617 if ((pBorderLine
= aInfo
.GetVert()) != NULL
)
618 aInfo
.SetLine(&aBorderLine
, BOXINFO_LINE_VERT
), bLine
|= TRUE
;
620 // if ( bPopCrsr && !bLine )
621 // aBox.SetDistance( 0 );
623 aCoreSet
.Put( aBox
);
624 aCoreSet
.Put( aInfo
);
625 rSh
.SetTabBorders( aCoreSet
);
627 // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
628 // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
630 rReq
.AppendItem( aBox
);
631 rReq
.AppendItem( aInfo
);
642 case FN_INSERT_TABLE
:
645 case FN_FORMAT_TABLE_DLG
:
647 //#127012# get the bindings before the dialog is called
648 // it might happen that this shell is removed after closing the dialog
649 SfxBindings
& rBindings
= GetView().GetViewFrame()->GetBindings();
650 SfxItemSet
aCoreSet( GetPool(), aUITableAttrRange
);
652 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, &rSh
.GetView()));
653 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)));
654 SwTableRep
* pTblRep
= ::lcl_TableParamToItemSet( aCoreSet
, rSh
);
655 SfxAbstractTabDialog
* pDlg
= NULL
;
658 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
659 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
661 pDlg
= pFact
->CreateSwTableTabDlg( GetView().GetWindow(), GetPool(), &aCoreSet
, &rSh
, DLG_FORMAT_TABLE
);
662 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
664 aCoreSet
.Put(SfxUInt16Item(SID_HTML_MODE
, ::GetHtmlMode(GetView().GetDocShell())));
665 rSh
.GetTblAttr(aCoreSet
);
666 // GetTblAttr buegelt den Background ueber!
667 SvxBrushItem
aBrush( RES_BACKGROUND
);
668 if(rSh
.GetBoxBackground(aBrush
))
669 aCoreSet
.Put( aBrush
);
671 aCoreSet
.InvalidateItem( RES_BACKGROUND
);
673 if ( !pDlg
&& rReq
.GetArgs() || pDlg
->Execute() == RET_OK
)
675 const SfxItemSet
* pOutSet
= pDlg
? pDlg
->GetOutputItemSet() : rReq
.GetArgs();
678 //to record FN_INSERT_TABLE correctly
679 rReq
.SetSlot(FN_FORMAT_TABLE_DLG
);
680 rReq
.Done( *pOutSet
);
682 ItemSetToTableParam( *pOutSet
, rSh
);
687 rBindings
.Update(SID_RULER_BORDERS
);
688 rBindings
.Update(SID_ATTR_TABSTOP
);
689 rBindings
.Update(SID_RULER_BORDERS_VERTICAL
);
690 rBindings
.Update(SID_ATTR_TABSTOP_VERTICAL
);
694 case SID_ATTR_BRUSH_ROW
:
695 case SID_ATTR_BRUSH_TABLE
:
697 ItemSetToTableParam(*rReq
.GetArgs(), rSh
);
699 case FN_NUM_FORMAT_TABLE_DLG
:
701 SwView
* pView
= GetActiveView();
704 FieldUnit eMetric
= ::GetDfltMetric(0 != PTR_CAST(SwWebView
, pView
));
705 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC
, static_cast< UINT16
>(eMetric
)));
706 SvNumberFormatter
* pFormatter
= rSh
.GetNumberFormatter();
707 SfxItemSet
aCoreSet( GetPool(),
708 SID_ATTR_NUMBERFORMAT_VALUE
, SID_ATTR_NUMBERFORMAT_VALUE
,
709 SID_ATTR_NUMBERFORMAT_INFO
, SID_ATTR_NUMBERFORMAT_INFO
,
712 SfxItemSet
aBoxSet( *aCoreSet
.GetPool(),
713 RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
,
714 RES_BOXATR_VALUE
, RES_BOXATR_VALUE
,
716 rSh
.GetTblBoxFormulaAttrs( aBoxSet
);
718 SfxItemState eState
= aBoxSet
.GetItemState(RES_BOXATR_FORMAT
);
719 if(eState
== SFX_ITEM_DEFAULT
)
721 aCoreSet
.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE
,
722 pFormatter
->GetFormatIndex(NF_TEXT
, LANGUAGE_SYSTEM
)));
725 aCoreSet
.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE
,
726 ((SwTblBoxNumFormat
&)aBoxSet
.Get(
727 RES_BOXATR_FORMAT
)).GetValue() ));
729 String
sCurText( rSh
.GetTableBoxText() );
730 aCoreSet
.Put( SvxNumberInfoItem( pFormatter
,
731 ((SwTblBoxValue
&)aBoxSet
.Get(
732 RES_BOXATR_VALUE
)).GetValue(),
733 sCurText
, SID_ATTR_NUMBERFORMAT_INFO
));
735 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
736 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
738 SfxAbstractDialog
* pDlg
= pFact
->CreateSfxDialog( GetView().GetWindow(),aCoreSet
,
739 pView
->GetViewFrame()->GetFrame()->GetFrameInterface(),
740 RC_DLG_SWNUMFMTDLG
);
741 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
743 if (RET_OK
== pDlg
->Execute())
745 const SfxPoolItem
* pNumberFormatItem
= GetView().GetDocShell()->
746 GetItem( SID_ATTR_NUMBERFORMAT_INFO
);
748 if( pNumberFormatItem
&& 0 != ((SvxNumberInfoItem
*)pNumberFormatItem
)->GetDelCount() )
750 const sal_uInt32
* pDelArr
= ((SvxNumberInfoItem
*)
751 pNumberFormatItem
)->GetDelArray();
753 for ( USHORT i
= 0; i
< ((SvxNumberInfoItem
*)pNumberFormatItem
)->GetDelCount(); i
++ )
754 ((SvxNumberInfoItem
*)pNumberFormatItem
)->
755 GetNumberFormatter()->DeleteEntry( pDelArr
[i
] );
758 if( SFX_ITEM_SET
== pDlg
->GetOutputItemSet()->GetItemState(
759 SID_ATTR_NUMBERFORMAT_VALUE
, FALSE
, &pNumberFormatItem
))
761 SfxItemSet
aBoxFormatSet( *aCoreSet
.GetPool(),
762 RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
);
763 aBoxFormatSet
.Put( SwTblBoxNumFormat(
764 ((SfxUInt32Item
*)pNumberFormatItem
)->GetValue() ));
765 rSh
.SetTblBoxFormulaAttrs( aBoxFormatSet
);
777 case FN_TABLE_OPTIMAL_HEIGHT
:
779 const SwFmtFrmSize aSz
;
780 rSh
.SetRowHeight( aSz
);
784 case FN_TABLE_DELETE_COL
:
785 if ( rSh
.DeleteCol() && rSh
.HasSelection() )
790 rSh
.MoveTable( fnTableCurr
, fnTableEnd
);
794 rSh
.MoveTable( fnTableCurr
, fnTableStart
);
797 case FN_GOTO_NEXT_CELL
:
799 BOOL bAppendLine
= TRUE
;
801 bAppendLine
= ((SfxBoolItem
*)pItem
)->GetValue();
802 rReq
.SetReturnValue( SfxBoolItem( nSlot
,
803 rSh
.GoNextCell( bAppendLine
) ) );
807 case FN_GOTO_PREV_CELL
:
808 rReq
.SetReturnValue( SfxBoolItem( nSlot
, rSh
.GoPrevCell() ) );
811 case FN_TABLE_DELETE_ROW
:
812 if ( rSh
.DeleteRow() && rSh
.HasSelection() )
816 case FN_TABLE_MERGE_CELLS
:
817 if ( rSh
.IsTableMode() )
818 switch ( rSh
.MergeTab() )
823 case TBLMERGE_NOSELECTION
: break;
824 case TBLMERGE_TOOCOMPLEX
:
826 InfoBox
aInfoBox( GetView().GetWindow(),
827 SW_RES( MSG_ERR_TABLE_MERGE
) );
831 default: ASSERT( !this, "unbekannter Returnwert MergeTab.");
834 case FN_TABLE_ADJUST_CELLS
:
835 case FN_TABLE_BALANCE_CELLS
:
837 BOOL bBalance
= (FN_TABLE_BALANCE_CELLS
== nSlot
);
838 if ( rSh
.IsAdjustCellWidthAllowed(bBalance
) )
841 // remove actions to make a valid table selection
842 UnoActionRemoveContext
aRemoveContext(rSh
.GetDoc());
844 rSh
.AdjustCellWidth(bBalance
);
849 case FN_TABLE_BALANCE_ROWS
:
850 if ( rSh
.BalanceRowHeight(TRUE
) )
851 rSh
.BalanceRowHeight(FALSE
);
854 case FN_TABLE_SELECT_ALL
:
856 rSh
.MoveTable( fnTableCurr
, fnTableStart
);
858 rSh
.MoveTable( fnTableCurr
, fnTableEnd
);
862 case FN_TABLE_SELECT_COL
:
864 rSh
.SelectTableCol();
867 case FN_TABLE_SELECT_ROW
:
869 rSh
.SelectTableRow();
872 case FN_TABLE_SET_READ_ONLY_CELLS
:
874 rSh
.ResetSelect( 0, FALSE
);
877 case FN_TABLE_UNSET_READ_ONLY_CELLS
:
878 rSh
.UnProtectCells();
883 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
884 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
886 AbstractSwAutoFormatDlg
* pDlg
= pFact
->CreateSwAutoFormatDlg(&GetView().GetViewFrame()->GetWindow(), &rSh
, DLG_AUTOFMT_TABLE
);
887 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
892 case FN_TABLE_SET_ROW_HEIGHT
:
894 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
895 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
897 VclAbstractDialog
* pDlg
= pFact
->CreateVclAbstractDialog( GetView().GetWindow(), rSh
, DLG_ROW_HEIGHT
);
898 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
903 case FN_NUMBER_BULLETS
:
904 case FN_NUM_BULLET_ON
:
905 ASSERT( !this, "Funktion darf zur Zeit nicht gerufen werden." );
908 case FN_TABLE_INSERT_COL
:
909 case FN_TABLE_INSERT_ROW
:
911 BOOL bColumn
= rReq
.GetSlot() == FN_TABLE_INSERT_COL
;
916 nCount
= ((const SfxInt16Item
* )pItem
)->GetValue();
917 if(SFX_ITEM_SET
== pArgs
->GetItemState(FN_PARAM_INSERT_AFTER
, TRUE
, &pItem
))
918 bAfter
= ((const SfxBoolItem
* )pItem
)->GetValue();
920 else if( !rReq
.IsAPI() )
925 // i74180: Table border patch submitted by chensuchun:
926 // -->get the SvxBoxInfoItem of the table before insert
927 SfxItemSet
aCoreSet( GetPool(), aUITableAttrRange
);
928 ::lcl_TableParamToItemSet( aCoreSet
, rSh
);
929 bool bSetInnerBorders
= false;
930 SwUndoId nUndoId
= UNDO_EMPTY
;
935 rSh
.StartUndo( UNDO_TABLE_INSCOL
);
936 rSh
.InsertCol( nCount
, bAfter
);
937 bSetInnerBorders
= true;
938 nUndoId
= UNDO_TABLE_INSCOL
;
940 else if ( !rSh
.IsInRepeatedHeadline() )
942 rSh
.StartUndo( UNDO_TABLE_INSROW
);
943 rSh
.InsertRow( nCount
, bAfter
);
944 bSetInnerBorders
= true;
945 nUndoId
= UNDO_TABLE_INSROW
;
948 // -->after inserting,reset the inner table borders
949 if ( bSetInnerBorders
)
951 const SvxBoxInfoItem
aBoxInfo((const SvxBoxInfoItem
&)
952 aCoreSet
.Get(SID_ATTR_BORDER_INNER
));
953 SfxItemSet
aSet( GetPool(), SID_ATTR_BORDER_INNER
,
954 SID_ATTR_BORDER_INNER
, 0);
955 aSet
.Put( aBoxInfo
);
956 ItemSetToTableParam( aSet
, rSh
);
957 rSh
.EndUndo( nUndoId
);
965 nSlot
= bColumn
? FN_TABLE_INSERT_COL_DLG
: FN_TABLE_INSERT_ROW_DLG
;
967 // kein break; bei Count = 0 kommt der Dialog
968 case FN_TABLE_INSERT_COL_DLG
:
969 case FN_TABLE_INSERT_ROW_DLG
:
971 if ( FN_TABLE_INSERT_ROW_DLG
!= nSlot
|| !rSh
.IsInRepeatedHeadline())
973 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
974 ::std::auto_ptr
<SvxAbstractInsRowColDlg
> pDlg( pFact
? pFact
->CreateSvxInsRowColDlg( GetView().GetWindow(), nSlot
== FN_TABLE_INSERT_COL_DLG
, nSlot
) : 0);
976 if( pDlg
.get() && (pDlg
->Execute() == 1) )
978 USHORT nDispatchSlot
= (nSlot
== FN_TABLE_INSERT_COL_DLG
) ? FN_TABLE_INSERT_COL
: FN_TABLE_INSERT_ROW
;
979 SfxUInt16Item
aCountItem( nDispatchSlot
, static_cast< UINT16
>(pDlg
->getInsertCount()) );
980 SfxBoolItem
aAfter( FN_PARAM_INSERT_AFTER
, !pDlg
->isInsertBefore() );
981 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
983 pVFrame
->GetDispatcher()->Execute( nDispatchSlot
, SFX_CALLMODE_SYNCHRON
|SFX_CALLMODE_RECORD
, &aCountItem
, &aAfter
, 0L);
988 case FN_TABLE_SPLIT_CELLS
:
991 BOOL bHorizontal
=TRUE
;
992 BOOL bProportional
= FALSE
;
993 SFX_REQUEST_ARG( rReq
, pSplit
, SfxInt32Item
, FN_TABLE_SPLIT_CELLS
, sal_False
);
994 SFX_REQUEST_ARG( rReq
, pHor
, SfxBoolItem
, FN_PARAM_1
, sal_False
);
995 SFX_REQUEST_ARG( rReq
, pProp
, SfxBoolItem
, FN_PARAM_2
, sal_False
);
998 nCount
= pSplit
->GetValue();
1000 bHorizontal
= pHor
->GetValue();
1002 bProportional
= pProp
->GetValue();
1006 SvxAbstractDialogFactory
* pFact
= SvxAbstractDialogFactory::Create();
1009 const long nMaxVert
= rSh
.GetAnyCurRect( RECT_FRM
).Width() / MINLAY
;
1010 SvxAbstractSplittTableDialog
* pDlg
= pFact
->CreateSvxSplittTableDialog( GetView().GetWindow(), rSh
.IsTableVertical(), nMaxVert
, 99 );
1011 if( pDlg
&& (pDlg
->Execute() == RET_OK
) )
1013 nCount
= pDlg
->GetCount();
1014 bHorizontal
= pDlg
->IsHorizontal();
1015 bProportional
= pDlg
->IsProportional();
1016 rReq
.AppendItem( SfxInt32Item( FN_TABLE_SPLIT_CELLS
, nCount
) );
1017 rReq
.AppendItem( SfxBoolItem( FN_PARAM_1
, bHorizontal
) );
1018 rReq
.AppendItem( SfxBoolItem( FN_PARAM_2
, bProportional
) );
1026 rSh
.SplitTab(!bHorizontal
, static_cast< USHORT
>( nCount
-1 ), bProportional
);
1034 case FN_TABLE_SPLIT_TABLE
:
1036 SFX_REQUEST_ARG( rReq
, pType
, SfxUInt16Item
, FN_PARAM_1
, sal_False
);
1039 switch( pType
->GetValue() )
1041 case HEADLINE_NONE
:
1042 case HEADLINE_BORDERCOPY
:
1043 case HEADLINE_CNTNTCOPY
:
1044 case HEADLINE_BOXATTRCOPY
:
1045 case HEADLINE_BOXATRCOLLCOPY
:
1046 rSh
.SplitTable(pType
->GetValue()) ;
1047 default: ;//wrong parameter, do nothing
1052 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1053 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
1055 AbstractSplitTableDialog
* pDlg
= pFact
->CreateSplitTblDialog( GetView().GetWindow(), rSh
);
1056 DBG_ASSERT(pDlg
, "Dialogdiet fail!");
1058 rReq
.AppendItem( SfxUInt16Item( FN_PARAM_1
, pDlg
->GetSplitMode() ) );
1060 bCallDone
= sal_True
;
1065 case FN_TABLE_MERGE_TABLE
:
1067 BOOL bPrev
= rSh
.CanMergeTable( TRUE
);
1068 BOOL bNext
= rSh
.CanMergeTable( FALSE
);
1070 if( bPrev
&& bNext
)
1072 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
1073 DBG_ASSERT(pFact
, "SwAbstractDialogFactory fail!");
1074 VclAbstractDialog
* pDlg
= pFact
->CreateSwVclDialog( DLG_MERGE_TABLE
, GetView().GetWindow(), bPrev
);
1075 DBG_ASSERT(pDlg
, "dialogdiet pDlg fail!");
1076 if( RET_OK
!= pDlg
->Execute())
1077 bPrev
= bNext
= FALSE
;
1081 if( bPrev
|| bNext
)
1082 rSh
.MergeTable( bPrev
);
1086 case FN_TABLE_MODE_FIX
:
1087 case FN_TABLE_MODE_FIX_PROP
:
1088 case FN_TABLE_MODE_VARIABLE
:
1090 rSh
.SetTblChgMode( ( FN_TABLE_MODE_FIX
== nSlot
? TBLFIX_CHGABS
1091 : FN_TABLE_MODE_FIX_PROP
== nSlot
1093 : TBLVAR_CHGABS
) );
1095 SfxBindings
& rBind
= GetView().GetViewFrame()->GetBindings();
1096 static USHORT __READONLY_DATA aInva
[] =
1097 { FN_TABLE_MODE_FIX
,
1098 FN_TABLE_MODE_FIX_PROP
,
1099 FN_TABLE_MODE_VARIABLE
,
1102 rBind
.Invalidate( aInva
);
1106 case FN_TABLE_AUTOSUM
:
1108 SfxViewFrame
* pVFrame
= GetView().GetViewFrame();
1109 pVFrame
->GetDispatcher()->Execute(FN_EDIT_FORMULA
, SFX_CALLMODE_SYNCHRON
);
1110 const USHORT nId
= SwInputChild::GetChildWindowId();
1111 SwInputChild
* pChildWin
= (SwInputChild
*)pVFrame
->
1112 GetChildWindow( nId
);
1114 GetShell().GetAutoSum(sSum
);
1116 pChildWin
->SetFormula( sSum
);
1120 case FN_TABLE_HEADLINE_REPEAT
:
1121 if(0 != rSh
.GetRowsToRepeat())
1122 rSh
.SetRowsToRepeat( 0 );
1124 rSh
.SetRowsToRepeat(rSh
.GetRowSelectionFromTop());
1126 case FN_TABLE_SELECT_CELL
:
1127 rSh
.SelectTableCell();
1129 case FN_TABLE_DELETE_TABLE
:
1133 rSh
.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_TABLE_SELECT_ALL
);
1138 //'this' is already destroyed
1153 //Jetzt die Slots, die direkt auf dem TableFmt arbeiten.
1154 SwFrmFmt
*pFmt
= rSh
.GetTableFmt();
1157 case SID_ATTR_ULSPACE
:
1161 SvxULSpaceItem
aULSpace( *(const SvxULSpaceItem
*)pItem
);
1162 aULSpace
.SetWhich( RES_UL_SPACE
);
1163 ::lcl_SetAttr( rSh
, aULSpace
);
1168 case SID_ATTR_LRSPACE
:
1172 SfxItemSet
aSet( GetPool(), RES_LR_SPACE
, RES_LR_SPACE
,
1173 RES_HORI_ORIENT
, RES_HORI_ORIENT
, 0 );
1174 SvxLRSpaceItem
aLRSpace( *(const SvxLRSpaceItem
*)pItem
);
1175 aLRSpace
.SetWhich( RES_LR_SPACE
);
1176 aSet
.Put( aLRSpace
);
1177 SwFmtHoriOrient
aHori( pFmt
->GetHoriOrient() );
1178 aHori
.SetHoriOrient( text::HoriOrientation::NONE
);
1179 aSet
.Put( aLRSpace
);
1180 rSh
.SetTblAttr( aSet
);
1184 // der letzte case-Zweig der noch einen TabellenManager braucht!!
1185 case FN_TABLE_SET_COL_WIDTH
:
1187 SwTableFUNC
aMgr( &rSh
, FALSE
);
1188 aMgr
.ColWidthDlg(GetView().GetWindow());
1191 case FN_TABLE_VERT_NONE
:
1192 case FN_TABLE_VERT_CENTER
:
1193 case FN_TABLE_VERT_BOTTOM
:
1195 USHORT nAlign
= nSlot
== FN_TABLE_VERT_NONE
?
1196 text::VertOrientation::NONE
:
1197 nSlot
== FN_TABLE_VERT_CENTER
?
1198 text::VertOrientation::CENTER
: text::VertOrientation::BOTTOM
;
1199 rSh
.SetBoxAlign(nAlign
);
1204 case SID_ATTR_PARA_SPLIT
:
1207 SwFmtLayoutSplit
aSplit( ((const SvxFmtSplitItem
*)pItem
)->GetValue());
1208 SfxItemSet
aSet(GetPool(), RES_LAYOUT_SPLIT
, RES_LAYOUT_SPLIT
, 0 );
1210 rSh
.SetTblAttr(aSet
);
1214 case SID_ATTR_PARA_KEEP
:
1217 SvxFmtKeepItem
aKeep( *(const SvxFmtKeepItem
*)pItem
);
1218 aKeep
.SetWhich( RES_KEEP
);
1219 SfxItemSet
aSet(GetPool(), RES_KEEP
, RES_KEEP
, 0 );
1221 rSh
.SetTblAttr(aSet
);
1224 case FN_TABLE_ROW_SPLIT
:
1226 const SfxBoolItem
* pBool
= static_cast<const SfxBoolItem
*>(pItem
);
1227 SwFmtRowSplit
* pSplit
= 0;
1230 rSh
.GetRowSplit(pSplit
);
1232 pSplit
->SetValue(!pSplit
->GetValue());
1234 pSplit
= new SwFmtRowSplit(TRUE
);
1238 pSplit
= new SwFmtRowSplit(pBool
->GetValue());
1240 rSh
.SetRowSplit( *pSplit
);
1246 ASSERT( !this, "falscher Dispatcher" );
1252 /*--------------------------------------------------------------------
1254 --------------------------------------------------------------------*/
1256 void SwTableShell::GetState(SfxItemSet
&rSet
)
1258 SfxWhichIter
aIter( rSet
);
1259 SwWrtShell
&rSh
= GetShell();
1260 SwFrmFmt
*pFmt
= rSh
.GetTableFmt();
1261 // os #124829# crash report: in case of an invalid shell selection return immediately
1264 USHORT nSlot
= aIter
.FirstWhich();
1269 case FN_TABLE_MERGE_CELLS
:
1270 if ( !rSh
.IsTableMode() )
1271 rSet
.DisableItem(FN_TABLE_MERGE_CELLS
);
1273 case FN_TABLE_ADJUST_CELLS
:
1274 if ( !rSh
.IsAdjustCellWidthAllowed() )
1275 rSet
.DisableItem(FN_TABLE_ADJUST_CELLS
);
1278 case FN_TABLE_BALANCE_CELLS
:
1279 if ( !rSh
.IsAdjustCellWidthAllowed(TRUE
) )
1280 rSet
.DisableItem(FN_TABLE_BALANCE_CELLS
);
1283 case FN_TABLE_BALANCE_ROWS
:
1284 if ( !rSh
.BalanceRowHeight(TRUE
) )
1285 rSet
.DisableItem(FN_TABLE_BALANCE_ROWS
);
1287 case FN_OPTIMIZE_TABLE
:
1288 if ( !rSh
.IsTableMode() &&
1289 !rSh
.IsAdjustCellWidthAllowed() &&
1290 !rSh
.IsAdjustCellWidthAllowed(TRUE
) &&
1291 !rSh
.BalanceRowHeight(TRUE
) )
1292 rSet
.DisableItem(FN_OPTIMIZE_TABLE
);
1294 case SID_INSERT_DIAGRAM
:
1296 SvtModuleOptions aMOpt
;
1297 if ( !aMOpt
.IsMath() || rSh
.IsTblComplexForChart() )
1298 rSet
.DisableItem(nSlot
);
1302 case FN_INSERT_TABLE
:
1303 // Irgendeinen Wert "putten", damit Controller enabled bleibt.
1304 // Statt "Insert:Table" erscheint dann "Format:Table".
1305 // rSet.Put(SfxUInt16Item(nSlot, 1));
1308 case FN_TABLE_OPTIMAL_HEIGHT
:
1310 //Disablen wenn bereits auto-Hoehe eingestellt ist.
1312 rSh
.GetRowHeight( pSz
);
1315 if ( ATT_VAR_SIZE
== pSz
->GetHeightSizeType() )
1316 rSet
.DisableItem( nSlot
);
1321 case FN_TABLE_INSERT_ROW
:
1322 case FN_TABLE_INSERT_ROW_DLG
:
1324 if ( rSh
.IsInRepeatedHeadline() )
1325 rSet
.DisableItem( nSlot
);
1329 rSet
.Put(pFmt
->GetLRSpace());
1332 rSet
.Put(pFmt
->GetULSpace());
1334 case FN_TABLE_VERT_NONE
:
1335 case FN_TABLE_VERT_CENTER
:
1336 case FN_TABLE_VERT_BOTTOM
:
1338 USHORT nAlign
= rSh
.GetBoxAlign();
1339 BOOL bSet
= nSlot
== FN_TABLE_VERT_NONE
&& nAlign
== text::VertOrientation::NONE
||
1340 nSlot
== FN_TABLE_VERT_CENTER
&& nAlign
== text::VertOrientation::CENTER
||
1341 nSlot
== FN_TABLE_VERT_BOTTOM
&& nAlign
== text::VertOrientation::BOTTOM
;
1342 rSet
.Put(SfxBoolItem(nSlot
, bSet
));
1346 case FN_TABLE_MODE_FIX
:
1347 case FN_TABLE_MODE_FIX_PROP
:
1348 case FN_TABLE_MODE_VARIABLE
:
1350 TblChgMode nMode
= rSh
.GetTblChgMode();
1351 BOOL bSet
= nSlot
== FN_TABLE_MODE_FIX
&& nMode
== TBLFIX_CHGABS
||
1352 nSlot
== FN_TABLE_MODE_FIX_PROP
&& nMode
== TBLFIX_CHGPROP
||
1353 nSlot
== FN_TABLE_MODE_VARIABLE
&& nMode
== TBLVAR_CHGABS
;
1354 rSet
.Put(SfxBoolItem(nSlot
, bSet
));
1358 case SID_ATTR_PARA_SPLIT
:
1359 rSet
.Put( pFmt
->GetKeep() );
1362 case SID_ATTR_PARA_KEEP
:
1363 rSet
.Put( pFmt
->GetLayoutSplit() );
1365 case FN_TABLE_SPLIT_TABLE
:
1367 if ( rSh
.IsInHeadline() )
1368 rSet
.DisableItem( nSlot
);
1371 case FN_TABLE_MERGE_TABLE
:
1374 if( !rSh
.CanMergeTable( TRUE
, &bAsk
))
1375 rSet
.DisableItem( nSlot
);
1379 case FN_TABLE_DELETE_ROW
:
1382 ::GetTblSel( rSh
, aBoxes
, nsSwTblSearchType::TBLSEARCH_ROW
);
1383 if( ::HasProtectedCells( aBoxes
))
1384 rSet
.DisableItem( nSlot
);
1387 case FN_TABLE_DELETE_COL
:
1390 ::GetTblSel( rSh
, aBoxes
, nsSwTblSearchType::TBLSEARCH_COL
);
1391 if( ::HasProtectedCells( aBoxes
))
1392 rSet
.DisableItem( nSlot
);
1396 case FN_TABLE_UNSET_READ_ONLY_CELLS
:
1397 // disable in readonly sections, but enable in protected cells
1398 if( !rSh
.CanUnProtectCells() )
1399 rSet
.DisableItem( nSlot
);
1403 const SwFmtLayoutSplit
& rTabSplit
= pFmt
->GetLayoutSplit();
1404 if ( 0 == rTabSplit
.GetValue() )
1406 rSet
.DisableItem( nSlot
);
1410 SwFmtRowSplit
* pSplit
= 0;
1411 rSh
.GetRowSplit(pSplit
);
1415 rSet
.InvalidateItem( nSlot
);
1420 case FN_TABLE_HEADLINE_REPEAT
:
1421 if(0 != rSh
.GetRowsToRepeat())
1422 rSet
.Put(SfxBoolItem(nSlot
, sal_True
));
1423 else if(!rSh
.GetRowSelectionFromTop())
1424 rSet
.DisableItem( nSlot
);
1426 rSet
.Put(SfxBoolItem(nSlot
, sal_False
));
1428 case FN_TABLE_SELECT_CELL
:
1429 if(rSh
.HasBoxSelection())
1430 rSet
.DisableItem( nSlot
);
1433 nSlot
= aIter
.NextWhich();
1437 /*--------------------------------------------------------------------
1439 --------------------------------------------------------------------*/
1441 SwTableShell::SwTableShell(SwView
&_rView
) :
1444 SetName(String::CreateFromAscii("Table"));
1445 SetHelpId(SW_TABSHELL
);
1448 /*--------------------------------------------------------------------
1450 --------------------------------------------------------------------*/
1452 void SwTableShell::GetFrmBorderState(SfxItemSet
&rSet
)
1454 SfxItemSet
aCoreSet( GetPool(),
1456 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
, 0 );
1457 SvxBoxInfoItem
aBoxInfo( SID_ATTR_BORDER_INNER
);
1458 aCoreSet
.Put( aBoxInfo
);
1459 GetShell().GetTabBorders( aCoreSet
);
1460 rSet
.Put( aCoreSet
);
1463 /*--------------------------------------------------------------------
1465 --------------------------------------------------------------------*/
1467 void SwTableShell::ExecTableStyle(SfxRequest
& rReq
)
1469 SwWrtShell
&rSh
= GetShell();
1470 const SfxItemSet
*pArgs
= rReq
.GetArgs();
1472 switch ( rReq
.GetSlot() )
1474 case SID_FRAME_LINESTYLE
:
1475 case SID_FRAME_LINECOLOR
:
1477 /* Tabellenselektion ist abgeschafft
1478 BOOL bPopCrsr = FALSE;
1479 if ( !rReq.IsAPI() )
1481 //Keine Tabellenselektion -> Aenderung wird auf die gesamte
1483 if ( !rSh.IsTableMode() )
1489 rSh.MoveTable( fnTableCurr, fnTableStart );
1491 rSh.MoveTable( fnTableCurr, fnTableEnd );
1495 if ( rReq
.GetSlot() == SID_FRAME_LINESTYLE
)
1497 const SvxLineItem
&rLineItem
= (const SvxLineItem
&)pArgs
->
1498 Get( SID_FRAME_LINESTYLE
);
1499 const SvxBorderLine
* pBorderLine
= rLineItem
.GetLine();
1500 rSh
.SetTabLineStyle( 0, TRUE
, pBorderLine
);
1504 const SvxColorItem
&rNewColorItem
= (const SvxColorItem
&)pArgs
->
1505 Get( SID_FRAME_LINECOLOR
);
1506 rSh
.SetTabLineStyle( &rNewColorItem
.GetValue() );
1522 void SwTableShell::GetLineStyleState(SfxItemSet
&rSet
)
1524 SfxItemSet
aCoreSet( GetPool(),
1526 SID_ATTR_BORDER_INNER
, SID_ATTR_BORDER_INNER
, 0);
1527 SvxBoxInfoItem
aCoreInfo( SID_ATTR_BORDER_INNER
);
1528 aCoreSet
.Put(aCoreInfo
);
1529 GetShell().GetTabBorders( aCoreSet
);
1531 const SvxBoxItem
& rBoxItem
= (const SvxBoxItem
&)aCoreSet
.Get( RES_BOX
);
1532 const SvxBorderLine
* pLine
= rBoxItem
.GetTop();
1534 rSet
.Put( SvxColorItem( pLine
? pLine
->GetColor() : Color(), SID_FRAME_LINECOLOR
) );
1535 SvxLineItem
aLine( SID_FRAME_LINESTYLE
);
1536 aLine
.SetLine(pLine
);
1540 void SwTableShell::ExecNumberFormat(SfxRequest
& rReq
)
1542 const SfxItemSet
* pArgs
= rReq
.GetArgs();
1543 SwWrtShell
&rSh
= GetShell();
1545 //Erstmal die Slots, die keinen FrmMgr benoetigen.
1546 const SfxPoolItem
* pItem
= 0;
1547 USHORT nSlot
= rReq
.GetSlot();
1549 pArgs
->GetItemState(GetPool().GetWhich(nSlot
), FALSE
, &pItem
);
1551 // Sprache immer von Cursorposition besorgen
1552 LanguageType eLang
= rSh
.GetCurLang();
1553 SvNumberFormatter
* pFormatter
= rSh
.GetNumberFormatter();
1554 sal_uInt32 nNumberFormat
= NUMBERFORMAT_ENTRY_NOT_FOUND
;
1555 USHORT nFmtType
= 0, nOffset
= 0;
1559 case FN_NUMBER_FORMAT
:
1562 // Index fuer String bestimmen
1563 String
aCode( ((const SfxStringItem
*)pItem
)->GetValue() );
1564 nNumberFormat
= pFormatter
->GetEntryKey( aCode
, eLang
);
1565 if( NUMBERFORMAT_ENTRY_NOT_FOUND
== nNumberFormat
)
1570 if( !pFormatter
->PutEntry( aCode
, nErrPos
, nType
,
1571 nNumberFormat
, eLang
))
1572 nNumberFormat
= NUMBERFORMAT_ENTRY_NOT_FOUND
;
1576 case FN_NUMBER_STANDARD
: nFmtType
= NUMBERFORMAT_NUMBER
; break;
1577 case FN_NUMBER_SCIENTIFIC
: nFmtType
= NUMBERFORMAT_SCIENTIFIC
; break;
1578 case FN_NUMBER_DATE
: nFmtType
= NUMBERFORMAT_DATE
; break;
1579 case FN_NUMBER_TIME
: nFmtType
= NUMBERFORMAT_TIME
; break;
1580 case FN_NUMBER_CURRENCY
: nFmtType
= NUMBERFORMAT_CURRENCY
; break;
1581 case FN_NUMBER_PERCENT
: nFmtType
= NUMBERFORMAT_PERCENT
; break;
1583 case FN_NUMBER_TWODEC
: // #.##0,00
1584 nFmtType
= NUMBERFORMAT_NUMBER
;
1585 nOffset
= NF_NUMBER_1000DEC2
;
1589 ASSERT(FALSE
, falscher Dispatcher
);
1594 nNumberFormat
= pFormatter
->GetStandardFormat( nFmtType
, eLang
) + nOffset
;
1596 if( NUMBERFORMAT_ENTRY_NOT_FOUND
!= nNumberFormat
)
1598 SfxItemSet
aBoxSet( GetPool(), RES_BOXATR_FORMAT
, RES_BOXATR_FORMAT
);
1599 aBoxSet
.Put( SwTblBoxNumFormat( nNumberFormat
));
1600 rSh
.SetTblBoxFormulaAttrs( aBoxSet
);