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