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