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