LibreOffice Module sw (master)  1
tabsh.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <hintids.hxx>
21 #include <svl/numformat.hxx>
22 #include <svl/zforlist.hxx>
23 #include <svl/stritem.hxx>
24 #include <svl/whiter.hxx>
26 #include <editeng/lrspitem.hxx>
27 #include <editeng/ulspitem.hxx>
28 #include <editeng/brushitem.hxx>
29 #include <editeng/boxitem.hxx>
30 #include <editeng/shaditem.hxx>
31 #include <editeng/spltitem.hxx>
32 #include <editeng/keepitem.hxx>
33 #include <editeng/lineitem.hxx>
34 #include <editeng/colritem.hxx>
35 #include <editeng/frmdiritem.hxx>
36 #include <svx/numinf.hxx>
37 #include <svx/svddef.hxx>
38 #include <svx/svxdlg.hxx>
39 #include <sfx2/bindings.hxx>
40 #include <vcl/weld.hxx>
41 #include <sfx2/request.hxx>
42 #include <sfx2/dispatch.hxx>
43 #include <sfx2/objface.hxx>
44 #include <sfx2/viewfrm.hxx>
45 #include <vcl/EnumContext.hxx>
46 #include <o3tl/enumrange.hxx>
47 #include <comphelper/lok.hxx>
48 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
49 #include <editeng/itemtype.hxx>
50 #include <osl/diagnose.h>
51 
52 #include <fmtornt.hxx>
53 #include <fmtlsplt.hxx>
54 #include <fmtrowsplt.hxx>
55 #include <fmtfsize.hxx>
56 #include <swmodule.hxx>
57 #include <wrtsh.hxx>
58 #include <rootfrm.hxx>
59 #include <wview.hxx>
60 #include <frmatr.hxx>
61 #include <uitool.hxx>
62 #include <inputwin.hxx>
63 #include <uiitems.hxx>
64 #include <tabsh.hxx>
65 #include <swtablerep.hxx>
66 #include <tablemgr.hxx>
67 #include <cellatr.hxx>
68 #include <frmfmt.hxx>
69 #include <swundo.hxx>
70 #include <swtable.hxx>
71 #include <docsh.hxx>
72 #include <tblsel.hxx>
73 #include <viewopt.hxx>
74 
75 #include <strings.hrc>
76 #include <cmdid.h>
77 #include <unobaseclass.hxx>
78 
79 #define ShellClass_SwTableShell
80 #include <sfx2/msg.hxx>
81 #include <swslots.hxx>
82 
83 #include <swabstdlg.hxx>
84 
85 #include <memory>
86 
87 using ::editeng::SvxBorderLine;
88 using namespace ::com::sun::star;
89 
91 
92 void SwTableShell::InitInterface_Impl()
93 {
94  GetStaticInterface()->RegisterPopupMenu("table");
95  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Table_Toolbox);
96 }
97 
98 
108 // #i29550#
110 // <-- collapsing borders
111  XATTR_FILL_FIRST, XATTR_FILL_LAST,
112  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
113  SID_RULER_BORDERS, SID_RULER_BORDERS,
114  SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE, // ??? This is very strange range
115 // SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION, // included into above
116 // SID_HTML_MODE, SID_HTML_MODE, // included into above
122 >);
123 
125 {
126  return aUITableAttrRange;
127 }
128 
129 static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
130 {
131  SfxItemSet aSet( rSh.GetView().GetPool(), rItem.Which(), rItem.Which());
132  aSet.Put( rItem );
133  rSh.SetTableAttr( aSet );
134 }
135 
136 static std::shared_ptr<SwTableRep> lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
137 {
138  std::shared_ptr<SwTableRep> pRep;
139 
140  SwFrameFormat *pFormat = rSh.GetTableFormat();
141  SwTabCols aCols;
142  rSh.GetTabCols( aCols );
143 
144  //At first get the simple attributes.
145  rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFormat->GetName()));
147  rSet.Put( pFormat->GetShadow() );
149  rSet.Put( pFormat->GetFrameDir() );
150 
151  SvxULSpaceItem aULSpace( pFormat->GetULSpace() );
152  rSet.Put( aULSpace );
153 
154  const sal_uInt16 nBackgroundDestination = rSh.GetViewOptions()->GetTableDest();
155  rSet.Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
156  std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
157  if(rSh.GetRowBackground(aBrush))
158  {
159  aBrush->SetWhich(SID_ATTR_BRUSH_ROW);
160  rSet.Put( *aBrush );
161  }
162  else
163  rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
164  rSh.GetTabBackground(aBrush);
165  aBrush->SetWhich(SID_ATTR_BRUSH_TABLE);
166  rSet.Put( *aBrush );
167 
168  // text direction in boxes
169  std::unique_ptr<SvxFrameDirectionItem> aBoxDirection(std::make_unique<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR));
170  if(rSh.GetBoxDirection( aBoxDirection ))
171  {
172  aBoxDirection->SetWhich(FN_TABLE_BOX_TEXTORIENTATION);
173  rSet.Put(*aBoxDirection);
174  }
175 
176  bool bSelectAll = rSh.StartsWithTable() && rSh.ExtendedSelectedAll();
177  bool bTableSel = rSh.IsTableMode() || bSelectAll;
178  if(!bTableSel)
179  {
180  rSh.StartAllAction();
181  rSh.Push();
183  }
184  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
185 
186  // Table variant: If multiple table cells are selected.
187  rSh.GetCursor(); //Thus GetCursorCnt() returns the right thing
188  aBoxInfo.SetTable ((rSh.IsTableMode() && rSh.GetCursorCnt() > 1) ||
189  !bTableSel);
190  // Always show distance field.
191  aBoxInfo.SetDist (true);
192  // Set minimum size in tables and paragraphs.
193  aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
194  rSh.GetSelectionType() &
196  // Always set the default spacing.
197  aBoxInfo.SetDefDist (MIN_BORDER_DIST);
198  // Individual lines can have DontCare status only in tables.
199  aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE, !bTableSel || !rSh.IsTableMode() );
200 
201  rSet.Put(aBoxInfo);
202  rSh.GetTabBorders( rSet );
203 
204  //row split
205  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
206  if(pSplit)
207  rSet.Put(std::move(pSplit));
208 
209  if(!bTableSel)
210  {
211  rSh.ClearMark();
213  rSh.EndAllAction();
214  }
215 
216  SwTabCols aTabCols;
217  rSh.GetTabCols( aTabCols );
218 
219  // Pointer will be deleted after the dialogue execution.
220  pRep = std::make_shared<SwTableRep>(aTabCols);
221  pRep->SetSpace(aCols.GetRightMax());
222 
223  sal_uInt16 nPercent = 0;
224  auto nWidth = ::GetTableWidth(pFormat, aCols, &nPercent, &rSh );
225  // The table width is wrong for relative values.
226  if (nPercent)
227  nWidth = pRep->GetSpace() * nPercent / 100;
228  const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient();
229  pRep->SetAlign(nAlign);
230  SvxLRSpaceItem aLRSpace( pFormat->GetLRSpace() );
231  SwTwips nLeft = aLRSpace.GetLeft();
232  SwTwips nRight = aLRSpace.GetRight();
233  SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
234  if(nAlign != text::HoriOrientation::FULL && std::abs(nDiff) > 2)
235  {
236  SwTwips nLR = pRep->GetSpace() - nWidth;
237  switch ( nAlign )
238  {
239  case text::HoriOrientation::CENTER:
240  nLeft = nRight = nLR / 2;
241  break;
242  case text::HoriOrientation::LEFT:
243  nRight = nLR;
244  nLeft = 0;
245  break;
246  case text::HoriOrientation::RIGHT:
247  nLeft = nLR;
248  nRight = 0;
249  break;
250  case text::HoriOrientation::LEFT_AND_WIDTH:
251  nRight = nLR - nLeft;
252  break;
254  if(!nPercent)
255  nWidth = pRep->GetSpace() - nLeft - nRight;
256  break;
257  }
258  }
259  pRep->SetLeftSpace(nLeft);
260  pRep->SetRightSpace(nRight);
261 
262  pRep->SetWidth(nWidth);
263  pRep->SetWidthPercent(nPercent);
264  // Are individual rows / cells are selected, the column processing will be changed.
265  pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
266  rSet.Put(SwPtrItem(FN_TABLE_REP, pRep.get()));
267  return pRep;
268 }
269 
270 void ItemSetToTableParam( const SfxItemSet& rSet,
271  SwWrtShell &rSh )
272 {
273  rSh.StartAllAction();
275 
276  if(const SfxUInt16Item* pDestItem = rSet.GetItemIfSet(SID_BACKGRND_DESTINATION, false))
277  {
278  SwViewOption aUsrPref( *rSh.GetViewOptions() );
279  aUsrPref.SetTableDest(static_cast<sal_uInt8>(pDestItem->GetValue()));
280  SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
281  }
282  bool bBorder = ( SfxItemState::SET == rSet.GetItemState( RES_BOX ) ||
283  SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
284  const SvxBrushItem* pBackgroundItem = rSet.GetItemIfSet( RES_BACKGROUND, false );
285  const SvxBrushItem* pRowItem = rSet.GetItemIfSet( SID_ATTR_BRUSH_ROW, false );
286  const SvxBrushItem* pTableItem = rSet.GetItemIfSet( SID_ATTR_BRUSH_TABLE, false );
287  bool bBackground = pBackgroundItem || pRowItem || pTableItem;
288  const SwFormatRowSplit* pSplit = rSet.GetItemIfSet( RES_ROW_SPLIT, false );
289  bool bRowSplit = pSplit != nullptr;
290  const SvxFrameDirectionItem* pBoxDirection = rSet.GetItemIfSet( FN_TABLE_BOX_TEXTORIENTATION, false );
291  bool bBoxDirection = pBoxDirection != nullptr;
292  if( bBackground || bBorder || bRowSplit || bBoxDirection)
293  {
294  // The border will be applied to the present selection.
295  // If there is no selection, the table will be completely selected.
296  // The background will always be applied to the current state.
297  bool bTableSel = rSh.IsTableMode();
298  rSh.StartAllAction();
299 
300  if(bBackground)
301  {
302  if(pBackgroundItem)
303  rSh.SetBoxBackground( *pBackgroundItem );
304  if(pRowItem)
305  {
306  std::unique_ptr<SvxBrushItem> aBrush(pRowItem->Clone());
307  aBrush->SetWhich(RES_BACKGROUND);
308  rSh.SetRowBackground(*aBrush);
309  }
310  if(pTableItem)
311  {
312  std::unique_ptr<SvxBrushItem> aBrush(pTableItem->Clone());
313  aBrush->SetWhich(RES_BACKGROUND);
314  rSh.SetTabBackground( *aBrush );
315  }
316  }
317 
318  if(bBoxDirection)
319  {
320  SvxFrameDirectionItem aDirection( SvxFrameDirection::Environment, RES_FRAMEDIR );
321  aDirection.SetValue(pBoxDirection->GetValue());
322  rSh.SetBoxDirection(aDirection);
323  }
324 
325  if(bBorder || bRowSplit)
326  {
327  rSh.Push();
328  if(!bTableSel)
329  {
331  }
332  if(bBorder)
333  rSh.SetTabBorders( rSet );
334 
335  if(bRowSplit)
336  {
337  rSh.SetRowSplit(*pSplit);
338  }
339 
340  if(!bTableSel)
341  {
342  rSh.ClearMark();
343  }
345  }
346 
347  rSh.EndAllAction();
348  }
349 
350  SwTabCols aTabCols;
351  bool bTabCols = false;
352  SwTableRep* pRep = nullptr;
353  SwFrameFormat *pFormat = rSh.GetTableFormat();
355  if(const SwPtrItem* pRepItem = rSet.GetItemIfSet( FN_TABLE_REP, false ))
356  {
357  pRep = static_cast<SwTableRep*>(pRepItem->GetValue());
358 
359  const SwTwips nWidth = pRep->GetWidth();
360  if ( text::HoriOrientation::FULL == pRep->GetAlign() )
361  {
362  SwFormatHoriOrient aAttr( pFormat->GetHoriOrient() );
363  aAttr.SetHoriOrient( text::HoriOrientation::FULL );
364  aSet.Put( aAttr );
365  }
366  else
367  {
369  if(pRep->GetWidthPercent())
370  {
371  aSz.SetWidthPercent( static_cast<sal_uInt8>(pRep->GetWidthPercent()) );
372  }
373  aSet.Put(aSz);
374  }
375 
376  SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
377  aLRSpace.SetLeft(pRep->GetLeftSpace());
378  aLRSpace.SetRight(pRep->GetRightSpace());
379  aSet.Put( aLRSpace );
380 
381  sal_Int16 eOrient = pRep->GetAlign();
382  SwFormatHoriOrient aAttr( 0, eOrient );
383  aSet.Put( aAttr );
384  // The item must only be recorded while manual alignment, so that the
385  // alignment is not overwritten by the distances while recording.
386  if(eOrient != text::HoriOrientation::NONE)
387  const_cast<SfxItemSet&>(rSet).ClearItem( SID_ATTR_LRSPACE );
388 
389  if(pRep->HasColsChanged())
390  {
391  bTabCols = true;
392  }
393  }
394 
395  if( const SfxUInt16Item* pHeadlineItem = rSet.GetItemIfSet( FN_PARAM_TABLE_HEADLINE, false ))
396  rSh.SetRowsToRepeat( pHeadlineItem->GetValue() );
397 
398  if( const SfxUInt16Item* pAlignItem = rSet.GetItemIfSet( FN_TABLE_SET_VERT_ALIGN, false ))
399  rSh.SetBoxAlign(pAlignItem->GetValue());
400 
401  if( const SfxStringItem* pNameItem = rSet.GetItemIfSet( FN_PARAM_TABLE_NAME, false ))
402  rSh.SetTableName( *pFormat, pNameItem->GetValue() );
403 
404  // Copy the chosen attributes in the ItemSet.
405  static const sal_uInt16 aIds[] =
406  {
407  RES_PAGEDESC,
408  RES_BREAK,
409  RES_KEEP,
411  RES_UL_SPACE,
412  RES_SHADOW,
413  RES_FRAMEDIR,
414  // #i29550#
416  // <-- collapsing borders
417  0
418  };
419  const SfxPoolItem* pItem = nullptr;
420  for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
421  if( SfxItemState::SET == rSet.GetItemState( *pIds, false, &pItem))
422  aSet.Put( *pItem );
423 
424  if(bTabCols)
425  {
426  rSh.GetTabCols( aTabCols );
427  bool bSingleLine = pRep->FillTabCols( aTabCols );
428  rSh.SetTabCols( aTabCols, bSingleLine );
429  }
430 
431  if( aSet.Count() )
432  rSh.SetTableAttr( aSet );
433 
435  rSh.EndAllAction();
436 }
437 
438 static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
439 {
440  if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
441  rBorderLine.SetWidth(pBorderLine->GetWidth());
442 
443  rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
444  rBorderLine.SetColor(pBorderLine->GetColor());
445 }
446 
447 static bool lcl_BoxesInDeletedRows(SwWrtShell &rSh, const SwSelBoxes& rBoxes)
448 {
449  // cursor and selection are there only in deleted rows in Show Changes mode
450  if ( rSh.GetLayout()->IsHideRedlines() )
451  return false;
452 
453  // not selected or all selected rows are deleted
454  bool bRet = true;
455  SwRedlineTable::size_type nRedlinePos = 0;
456  if ( rBoxes.empty() )
457  bRet = rSh.GetCursor()->GetNode().GetTableBox()->GetUpper()->IsDeleted(nRedlinePos);
458  else
459  {
460  tools::Long nBoxes = rBoxes.size();
461  SwTableLine* pPrevLine = nullptr;
462  for ( tools::Long i = 0; i < nBoxes; i++ )
463  {
464  SwTableLine* pLine = rBoxes[i]->GetUpper();
465  if ( pLine != pPrevLine )
466  bRet &= pLine->IsDeleted(nRedlinePos);
467  pPrevLine = pLine;
468  }
469  }
470 
471  return bRet;
472 }
473 
475 {
476  // cursor and selection are there only in deleted table in Show Changes mode
477  if ( rSh.GetLayout()->IsHideRedlines() )
478  return false;
479 
480  SwTableNode* pTableNd = rSh.GetCursor()->GetPoint()->nNode.GetNode().FindTableNode();
481  return pTableNd && pTableNd->GetTable().IsDeleted();
482 }
483 
485 {
486  const SfxItemSet* pArgs = rReq.GetArgs();
487  SwWrtShell &rSh = GetShell();
488 
489  // At first the slots which doesn't need a FrameMgr.
490  bool bMore = false;
491  const SfxPoolItem* pItem = nullptr;
492  sal_uInt16 nSlot = rReq.GetSlot();
493  if(pArgs)
494  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
495  bool bCallDone = false;
496  switch ( nSlot )
497  {
498  case SID_ATTR_BORDER:
499  {
500  if(!pArgs)
501  break;
502  // Create items, because we have to rework anyway.
503  std::shared_ptr<SvxBoxItem> aBox(std::make_shared<SvxBoxItem>(RES_BOX));
505  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
506  aCoreSet( GetPool() );
507  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
508  aCoreSet.Put(aCoreInfo);
509  rSh.GetTabBorders( aCoreSet );
510  const SvxBoxItem& rCoreBox = aCoreSet.Get(RES_BOX);
511  const SvxBoxItem *pBoxItem = pArgs->GetItemIfSet(RES_BOX);
512  if ( pBoxItem )
513  {
514  aBox.reset(pBoxItem->Clone());
515  sal_uInt16 nDefValue = MIN_BORDER_DIST;
516  if ( !rReq.IsAPI() )
517  nDefValue = 55;
518  if (!rReq.IsAPI() || aBox->GetSmallestDistance() < MIN_BORDER_DIST)
519  {
521  aBox->SetDistance( std::max(rCoreBox.GetDistance(k), nDefValue) , k );
522  }
523  }
524  else
525  OSL_ENSURE( false, "where is BoxItem?" );
526 
527  //since the drawing layer also supports borders the which id might be a different one
528  std::shared_ptr<SvxBoxInfoItem> aInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER));
529  if (const SvxBoxInfoItem* pBoxInfoItem = pArgs->GetItemIfSet(SID_ATTR_BORDER_INNER))
530  {
531  aInfo.reset(pBoxInfoItem->Clone());
532  }
533  else if( const SvxBoxInfoItem* pBoxInfoInnerItem = pArgs->GetItemIfSet(SDRATTR_TABLE_BORDER_INNER))
534  {
535  aInfo.reset(pBoxInfoInnerItem->Clone());
536  aInfo->SetWhich(SID_ATTR_BORDER_INNER);
537  }
538 
539  aInfo->SetTable( true );
540  aInfo->SetValid( SvxBoxInfoItemValidFlags::DISABLE, false );
541 
542 // The attributes of all lines will be read and the strongest wins.
543  const SvxBorderLine* pBorderLine;
544  SvxBorderLine aBorderLine;
545  if ((pBorderLine = rCoreBox.GetTop()) != nullptr)
546  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
547  if ((pBorderLine = rCoreBox.GetBottom()) != nullptr)
548  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
549  if ((pBorderLine = rCoreBox.GetLeft()) != nullptr)
550  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
551  if ((pBorderLine = rCoreBox.GetRight()) != nullptr)
552  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
553  if ((pBorderLine = aCoreInfo.GetHori()) != nullptr)
554  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
555  if ((pBorderLine = aCoreInfo.GetVert()) != nullptr)
556  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
557 
558  if(aBorderLine.GetOutWidth() == 0)
559  {
560  aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::SOLID);
561  aBorderLine.SetWidth( SvxBorderLineWidth::VeryThin );
562  }
563 
564  if( aBox->GetTop() != nullptr )
565  {
566  aBox->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
567  }
568  if( aBox->GetBottom() != nullptr )
569  {
570  aBox->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
571  }
572  if( aBox->GetLeft() != nullptr )
573  {
574  aBox->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
575  }
576  if( aBox->GetRight() != nullptr )
577  {
578  aBox->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
579  }
580  if( aInfo->GetHori() != nullptr )
581  {
582  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::HORI);
583  }
584  if( aInfo->GetVert() != nullptr )
585  {
586  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::VERT);
587  }
588 
589  aCoreSet.Put( *aBox );
590  aCoreSet.Put( *aInfo );
591  rSh.SetTabBorders( aCoreSet );
592 
593  // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
594  // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
595  // the SvxBoxItem
596  rReq.AppendItem( *aBox );
597  rReq.AppendItem( *aInfo );
598  bCallDone = true;
599  break;
600  }
601  case FN_INSERT_TABLE:
602  InsertTable( rReq );
603  break;
604  case FN_FORMAT_TABLE_DLG:
605  {
606  //#127012# get the bindings before the dialog is called
607  // it might happen that this shell is removed after closing the dialog
608  SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
609  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
610 
611  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr );
612  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
613  std::shared_ptr<SwTableRep> pTableRep(::lcl_TableParamToItemSet(aCoreSet, rSh));
614 
615  aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
616  rSh.GetTableAttr(aCoreSet);
617  // GetTableAttr overwrites the background!
618  std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
619  if(rSh.GetBoxBackground(aBrush))
620  aCoreSet.Put( *aBrush );
621  else
622  aCoreSet.InvalidateItem( RES_BACKGROUND );
623 
625  VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(GetView().GetFrameWeld(), &aCoreSet, &rSh));
626 
627  if (pDlg)
628  {
629  if (pItem)
630  pDlg->SetCurPageId(OUStringToOString(static_cast<const SfxStringItem *>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8));
631 
632  auto pRequest = std::make_shared<SfxRequest>(rReq);
633  rReq.Ignore(); // the 'old' request is not relevant any more
634 
635  const bool bTableMode = rSh.IsTableMode();
636  SwPaM* pCursor = bTableMode ? rSh.GetTableCrs() : rSh.GetCursor(); // tdf#142165 use table cursor if in table mode
637  auto vCursors = CopyPaMRing(*pCursor); // tdf#135636 make a copy to use at later apply
638  pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, vCursors, bTableMode](sal_Int32 nResult){
639  if (RET_OK == nResult)
640  {
641  if (!bTableMode && rSh.IsTableMode()) // tdf#140977 drop current table-cursor if setting a replacement
642  rSh.TableCursorToCursor(); // non-table one
643 
644  // tdf#135636 set the selection at dialog launch as current selection
645  rSh.SetSelection(*vCursors->front()); // UpdateCursor() will be called which in the case
646  // of a table selection should recreate a
647  // SwShellTableCursor if the selection is more than a single cell
648 
649  if (bTableMode && !rSh.IsTableMode()) // tdf#142721 ensure the new selection is a SwShellTableCursor in
650  rSh.SelTableBox(); // the case of a single cell
651 
652  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
653 
654  //to record FN_INSERT_TABLE correctly
655  pRequest->SetSlot(FN_FORMAT_TABLE_DLG);
656  pRequest->Done(*pOutSet);
657 
658  ItemSetToTableParam(*pOutSet, rSh);
659  }
660 
661  rBindings.Update(SID_RULER_BORDERS);
662  rBindings.Update(SID_ATTR_TABSTOP);
663  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
664  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
665 
666  pDlg->disposeOnce();
667  });
668  }
669  else
670  {
671  if (rReq.GetArgs())
672  ItemSetToTableParam(*rReq.GetArgs(), rSh);
673 
674  rBindings.Update(SID_RULER_BORDERS);
675  rBindings.Update(SID_ATTR_TABSTOP);
676  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
677  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
678  }
679 
680  break;
681  }
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;
689  {
690  SwView* pView = GetActiveView();
691  if(pView)
692  {
693  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
694  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
695  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
697  aCoreSet( GetPool() );
698 
700  RES_BOXATR_VALUE, RES_BOXATR_VALUE>
701  aBoxSet( *aCoreSet.GetPool() );
702  rSh.GetTableBoxFormulaAttrs( aBoxSet );
703 
704  SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
705  if(eState == SfxItemState::DEFAULT)
706  {
707  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
708  pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
709  }
710  else
711  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
712  aBoxSet.Get(
713  RES_BOXATR_FORMAT ).GetValue() ));
714 
715  OUString sCurText( rSh.GetTableBoxText() );
716  aCoreSet.Put( SvxNumberInfoItem( pFormatter,
717  aBoxSet.Get(
718  RES_BOXATR_VALUE).GetValue(),
719  sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
720 
723 
724  if (RET_OK == pDlg->Execute())
725  {
726  const SvxNumberInfoItem* pNumberFormatItem
727  = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
728 
729  if( pNumberFormatItem )
730  {
731  for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
732  pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
733  }
734 
735  const SfxUInt32Item* pNumberFormatValueItem =
736  pDlg->GetOutputItemSet()->GetItemIfSet(
737  SID_ATTR_NUMBERFORMAT_VALUE, false);
738  if( pNumberFormatValueItem )
739  {
741  aBoxFormatSet( *aCoreSet.GetPool() );
742  aBoxFormatSet.Put( SwTableBoxNumFormat(
743  pNumberFormatValueItem->GetValue() ));
744  rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
745 
746  }
747  }
748  }
749  break;
750  }
751  case FN_CALC_TABLE:
752  rSh.UpdateTable();
753  bCallDone = true;
754  break;
755  case FN_TABLE_DELETE_COL:
756  if ( rSh.DeleteCol() && rSh.HasSelection() )
757  rSh.EnterStdMode();
758  bCallDone = true;
759  break;
760  case FN_END_TABLE:
762  bCallDone = true;
763  break;
764  case FN_START_TABLE:
766  bCallDone = true;
767  break;
768  case FN_GOTO_NEXT_CELL:
769  {
770  bool bAppendLine = true;
771  if( pItem )
772  bAppendLine = static_cast<const SfxBoolItem*>(pItem)->GetValue();
773  rReq.SetReturnValue( SfxBoolItem( nSlot,
774  rSh.GoNextCell( bAppendLine ) ) );
775  bCallDone = true;
776  break;
777  }
778  case FN_GOTO_PREV_CELL:
779  rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
780  bCallDone = true;
781  break;
782  case FN_TABLE_DELETE_ROW:
783  if ( rSh.DeleteRow() && rSh.HasSelection() )
784  rSh.EnterStdMode();
785  bCallDone = true;
786  break;
788  if ( rSh.IsTableMode() )
789  switch ( rSh.MergeTab() )
790  {
791  case TableMergeErr::Ok:
792  bCallDone = true;
793  [[fallthrough]];
795  break;
797  {
798  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
799  VclMessageType::Info, VclButtonsType::Ok,
800  SwResId(STR_ERR_TABLE_MERGE)));
801  xInfoBox->run();
802  break;
803  }
804  default:
805  OSL_ENSURE( false, "unknown return value MergeTab.");
806  break;
807  }
808  break;
809  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
812  {
813  bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
814  const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot;
815  if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
816  {
817  {
818  // remove actions to make a valid table selection
819  UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
820  }
821  rSh.AdjustCellWidth(bBalance, bNoShrink);
822  }
823  bCallDone = true;
824  break;
825  }
826  case SID_TABLE_MINIMAL_ROW_HEIGHT:
827  {
828  const SwFormatFrameSize aSz;
829  rSh.SetRowHeight( aSz );
830  bCallDone = true;
831  break;
832  }
834  {
835  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
836  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
837  bCallDone = true;
838  break;
839  }
841  if ( rSh.BalanceRowHeight(true) )
842  rSh.BalanceRowHeight(false);
843  bCallDone = true;
844  break;
845  case FN_TABLE_SELECT_ALL:
846  rSh.EnterStdMode();
848  rSh.SttSelect();
850  rSh.EndSelect();
851  bCallDone = true;
852  break;
853  case FN_TABLE_SELECT_COL:
854  rSh.EnterStdMode();
855  rSh.SelectTableCol();
856  bCallDone = true;
857  break;
858  case FN_TABLE_SELECT_ROW:
859  rSh.EnterStdMode();
860  rSh.SelectTableRow();
861  bCallDone = true;
862  break;
864  rSh.ProtectCells();
865  rSh.ResetSelect( nullptr, false );
866  bCallDone = true;
867  break;
869  rSh.UnProtectCells();
870  bCallDone = true;
871  break;
872  case SID_AUTOFORMAT:
873  {
876  pDlg->Execute();
877  break;
878  }
880  {
883  pDlg->Execute();
884  break;
885  }
886  case FN_NUMBER_BULLETS:
887  case FN_NUM_BULLET_ON:
888  OSL_ENSURE( false, "function may not be called now." );
889  break;
890 
891 
892  // 2015/06 The following two are deprecated but kept for ascending
893  // compatibility
894  case FN_TABLE_INSERT_COL:
895  case FN_TABLE_INSERT_ROW:
896  // fallback
901  {
902  bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
904  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
905  sal_uInt16 nCount = 0;
906  bool bAfter = true;
907  if (pItem)
908  {
909  nCount = static_cast<const SfxInt16Item* >(pItem)->GetValue();
910  if(const SfxBoolItem* pAfterItem = pArgs->GetItemIfSet(FN_PARAM_INSERT_AFTER))
911  bAfter = pAfterItem->GetValue();
912  }
913  else if( !rReq.IsAPI() )
914  {
915  SwSelBoxes aBoxes;
916  ::GetTableSel( rSh, aBoxes );
917  if ( !aBoxes.empty() )
918  {
919  tools::Long maxX = 0;
920  tools::Long maxY = 0;
921  tools::Long minX = std::numeric_limits<tools::Long>::max();
922  tools::Long minY = std::numeric_limits<tools::Long>::max();
923  tools::Long nbBoxes = aBoxes.size();
924  for ( tools::Long i = 0; i < nbBoxes; i++ )
925  {
926  Point aCoord ( aBoxes[i]->GetCoordinates() );
927  if ( aCoord.X() < minX ) minX = aCoord.X();
928  if ( aCoord.X() > maxX ) maxX = aCoord.X();
929  if ( aCoord.Y() < minY ) minY = aCoord.Y();
930  if ( aCoord.Y() > maxY ) maxY = aCoord.Y();
931  }
932  if (bColumn)
933  nCount = maxX - minX + 1;
934  else
935  nCount = maxY - minY + 1;
936  }
937  bAfter = rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
939  || rReq.GetSlot() == FN_TABLE_INSERT_ROW
940  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
941  }
942 
943  if( nCount )
944  {
945  // i74180: Table border patch submitted by chensuchun:
946  // -->get the SvxBoxInfoItem of the table before insert
947  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
948  ::lcl_TableParamToItemSet( aCoreSet, rSh );
949  bool bSetInnerBorders = false;
950  SwUndoId nUndoId = SwUndoId::EMPTY;
951  // <--End
952 
953  if( bColumn )
954  {
956  rSh.InsertCol( nCount, bAfter );
957  bSetInnerBorders = true;
958  nUndoId = SwUndoId::TABLE_INSCOL;
959  }
960  else if ( !rSh.IsInRepeatedHeadline() )
961  {
963  rSh.InsertRow( nCount, bAfter );
964  bSetInnerBorders = true;
965  nUndoId = SwUndoId::TABLE_INSROW;
966  }
967 
968  // -->after inserting,reset the inner table borders
969  if ( bSetInnerBorders )
970  {
971  const SvxBoxInfoItem& aBoxInfo(aCoreSet.Get(SID_ATTR_BORDER_INNER));
973  aSet.Put( aBoxInfo );
974  ItemSetToTableParam( aSet, rSh );
975  rSh.EndUndo( nUndoId );
976  }
977 
978  bCallDone = true;
979  break;
980  }
981 
983 
984  [[fallthrough]]; // on Count = 0 appears the dialog
985  }
988  {
989  const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
990  if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
991  {
994  nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
995  if( pDlg->Execute() == 1 )
996  {
997  const sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
999  SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
1000  SfxBoolItem aAfter( FN_PARAM_INSERT_AFTER, !pDlg->isInsertBefore() );
1001  SfxViewFrame* pVFrame = GetView().GetViewFrame();
1002  if( pVFrame )
1003  pVFrame->GetDispatcher()->ExecuteList(nDispatchSlot,
1004  SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
1005  { &aCountItem, &aAfter });
1006  }
1007  }
1008  break;
1009  }
1010  case FN_TABLE_SPLIT_CELLS:
1011  {
1012  tools::Long nCount=0;
1013  bool bHorizontal=true;
1014  bool bProportional = false;
1015  const SfxInt32Item* pSplit = rReq.GetArg<SfxInt32Item>(FN_TABLE_SPLIT_CELLS);
1016  const SfxBoolItem* pHor = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
1017  const SfxBoolItem* pProp = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
1018  if ( pSplit )
1019  {
1020  nCount = pSplit->GetValue();
1021  if ( pHor )
1022  bHorizontal = pHor->GetValue();
1023  if ( pProp )
1024  bProportional = pProp->GetValue();
1025  }
1026  else
1027  {
1029  SwWrtShell* pSh = &rSh;
1030  const tools::Long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
1032  if(rSh.IsSplitVerticalByDefault())
1033  pDlg->SetSplitVerticalByDefault();
1034  pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
1035  if (nResult == RET_OK)
1036  {
1037  tools::Long nCount2 = pDlg->GetCount();
1038  bool bHorizontal2 = pDlg->IsHorizontal();
1039  bool bProportional2 = pDlg->IsProportional();
1040 
1041  // tdf#60242: remember choice for next time
1042  bool bVerticalWasChecked = !pDlg->IsHorizontal();
1043  pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
1044 
1045  if ( nCount2 > 1 )
1046  pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
1047  }
1048 
1049  pDlg->disposeOnce();
1050  });
1051  }
1052 
1053  if ( nCount>1 )
1054  {
1055  rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1056  bCallDone = true;
1057  }
1058  else
1059  rReq.Ignore();
1060  break;
1061  }
1062 
1063  case FN_TABLE_SPLIT_TABLE:
1064  {
1065  const SfxUInt16Item* pType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1066  if( pType )
1067  {
1068  switch( static_cast<SplitTable_HeadlineOption>(pType->GetValue()) )
1069  {
1075  rSh.SplitTable(static_cast<SplitTable_HeadlineOption>(pType->GetValue())) ;
1076  break;
1077  default: ;//wrong parameter, do nothing
1078  }
1079  }
1080  else
1081  {
1084  pDlg->Execute();
1085  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(pDlg->GetSplitMode()) ) );
1086  bCallDone = true;
1087  }
1088  break;
1089  }
1090 
1091  case FN_TABLE_MERGE_TABLE:
1092  {
1093  bool bPrev = rSh.CanMergeTable();
1094  bool bNext = rSh.CanMergeTable( false );
1095 
1096  if( bPrev && bNext )
1097  {
1100  if( RET_OK != pDlg->Execute())
1101  bPrev = bNext = false;
1102  }
1103 
1104  if( bPrev || bNext )
1105  rSh.MergeTable( bPrev );
1106  break;
1107  }
1108 
1109  case FN_TABLE_MODE_FIX :
1110  case FN_TABLE_MODE_FIX_PROP :
1111  case FN_TABLE_MODE_VARIABLE :
1112  {
1113  rSh.SetTableChgMode( FN_TABLE_MODE_FIX == nSlot
1115  : FN_TABLE_MODE_FIX_PROP == nSlot
1118 
1119  SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1120  static sal_uInt16 aInva[] =
1124  0
1125  };
1126  rBind.Invalidate( aInva );
1127  bCallDone = true;
1128  break;
1129  }
1130  case FN_TABLE_AUTOSUM:
1131  {
1132  SfxViewFrame* pVFrame = GetView().GetViewFrame();
1133  pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::SYNCHRON);
1134  const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1135  SwInputChild* pChildWin = static_cast<SwInputChild*>(pVFrame->
1136  GetChildWindow( nId ));
1137  OUString sSum;
1138  GetShell().GetAutoSum(sSum);
1139  if( pChildWin )
1140  pChildWin->SetFormula( sSum );
1141 
1142  break;
1143  }
1145  if(0 != rSh.GetRowsToRepeat())
1146  rSh.SetRowsToRepeat( 0 );
1147  else
1149  break;
1150  case FN_TABLE_SELECT_CELL :
1151  rSh.SelectTableCell();
1152  break;
1153  case FN_TABLE_DELETE_TABLE :
1154  {
1155  rSh.StartAction();
1156  rSh.StartUndo();
1158  rSh.DeleteTable();
1159  rSh.EndUndo();
1160  rSh.EndAction();
1161  //'this' is already destroyed
1162  return;
1163  }
1165  {
1167  if (pItem2)
1168  {
1169  tools::Long nNewHeight = pItem2->GetValue();
1170  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1171  if ( pHeight )
1172  {
1173  if (pHeight->GetHeightSizeType() == SwFrameSize::Variable)
1174  pHeight->SetHeightSizeType(SwFrameSize::Minimum);
1175  pHeight->SetHeight(nNewHeight);
1176  rSh.SetRowHeight(*pHeight);
1177  }
1178  }
1179  return;
1180  }
1182  {
1184  if (pItem2)
1185  {
1186  tools::Long nNewWidth = pItem2->GetValue();
1187  SwTableFUNC aFunc( &rSh );
1188  aFunc.InitTabCols();
1189  aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth);
1190  }
1191  return;
1192  }
1193  default:
1194  bMore = true;
1195  }
1196 
1197  if ( !bMore )
1198  {
1199  if(bCallDone)
1200  rReq.Done();
1201  return;
1202  }
1203 
1204  // Now the slots which are working directly on the TableFormat.
1205  switch ( nSlot )
1206  {
1207  case SID_ATTR_ULSPACE:
1208  if(pItem)
1209  {
1210  SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem*>(pItem) );
1211  aULSpace.SetWhich( RES_UL_SPACE );
1212  ::lcl_SetAttr( rSh, aULSpace );
1213  }
1214  break;
1215 
1216  case SID_ATTR_LRSPACE:
1217  if(pItem)
1218  {
1220  RES_HORI_ORIENT, RES_HORI_ORIENT> aSet( GetPool() );
1221  SvxLRSpaceItem aLRSpace( *static_cast<const SvxLRSpaceItem*>(pItem) );
1222  aLRSpace.SetWhich( RES_LR_SPACE );
1223  aSet.Put( aLRSpace );
1224  rSh.SetTableAttr( aSet );
1225  }
1226  break;
1227  // The last case branch which needs a table manager!!
1229  {
1230  SwTableFUNC aMgr( &rSh );
1231  aMgr.ColWidthDlg(GetView().GetFrameWeld());
1232  break;
1233  }
1234  case SID_TABLE_VERT_NONE:
1235  case SID_TABLE_VERT_CENTER:
1236  case SID_TABLE_VERT_BOTTOM:
1237  {
1238  const sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1240  nSlot == SID_TABLE_VERT_CENTER ?
1241  text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1242  rSh.SetBoxAlign(nAlign);
1243  bCallDone = true;
1244  break;
1245  }
1246 
1247  case SID_ATTR_PARA_SPLIT:
1248  if ( pItem )
1249  {
1250  SwFormatLayoutSplit aSplit( static_cast<const SvxFormatSplitItem*>(pItem)->GetValue());
1252  aSet.Put(aSplit);
1253  rSh.SetTableAttr(aSet);
1254  }
1255  break;
1256 
1257  case SID_ATTR_PARA_KEEP:
1258  if ( pItem )
1259  {
1260  SvxFormatKeepItem aKeep( *static_cast<const SvxFormatKeepItem*>(pItem) );
1261  aKeep.SetWhich( RES_KEEP );
1263  aSet.Put(aKeep);
1264  rSh.SetTableAttr(aSet);
1265  }
1266  break;
1267  case FN_TABLE_ROW_SPLIT :
1268  {
1269  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1270  std::unique_ptr<SwFormatRowSplit> pSplit;
1271  if(!pBool)
1272  {
1273  pSplit = rSh.GetRowSplit();
1274  if(pSplit)
1275  pSplit->SetValue(!pSplit->GetValue());
1276  else
1277  pSplit.reset(new SwFormatRowSplit(true));
1278  }
1279  else
1280  {
1281  pSplit.reset(new SwFormatRowSplit(pBool->GetValue()));
1282  }
1283  rSh.SetRowSplit( *pSplit );
1284  break;
1285  }
1286 
1287  default:
1288  OSL_ENSURE( false, "wrong Dispatcher" );
1289  return;
1290  }
1291  if(bCallDone)
1292  rReq.Done();
1293 }
1294 
1296 {
1297  SfxWhichIter aIter( rSet );
1298  SwWrtShell &rSh = GetShell();
1299  SwFrameFormat *pFormat = rSh.GetTableFormat();
1300  // os #124829# crash report: in case of an invalid shell selection return immediately
1301  if(!pFormat)
1302  return;
1303  sal_uInt16 nSlot = aIter.FirstWhich();
1304  while ( nSlot )
1305  {
1306  switch ( nSlot )
1307  {
1308  case FN_TABLE_MERGE_CELLS:
1309  if ( !rSh.IsTableMode() )
1311  break;
1312  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1313  case FN_TABLE_ADJUST_CELLS:
1314  if ( !rSh.IsAdjustCellWidthAllowed() )
1315  rSet.DisableItem(nSlot);
1316  break;
1317 
1319  if ( !rSh.IsAdjustCellWidthAllowed(true) )
1321  break;
1322 
1324  case FN_TABLE_BALANCE_ROWS:
1325  if ( !rSh.BalanceRowHeight(true) )
1326  rSet.DisableItem(nSlot);
1327  break;
1328  case FN_OPTIMIZE_TABLE:
1329  if ( !rSh.IsTableMode() &&
1330  !rSh.IsAdjustCellWidthAllowed() &&
1331  !rSh.IsAdjustCellWidthAllowed(true) &&
1332  !rSh.BalanceRowHeight(true) )
1334  break;
1335  case SID_INSERT_DIAGRAM:
1336  {
1337  SvtModuleOptions aMOpt;
1338  if ( !aMOpt.IsMath() || rSh.IsTableComplexForChart() )
1339  rSet.DisableItem(nSlot);
1340  }
1341  break;
1342 
1343  case FN_INSERT_TABLE:
1344  if ( rSh.CursorInsideInputField() )
1345  {
1346  rSet.DisableItem( nSlot );
1347  }
1348  break;
1349 
1350  case SID_TABLE_MINIMAL_ROW_HEIGHT:
1351  {
1352  // Disable if auto height already is enabled.
1353  std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight();
1354  if ( pSz )
1355  {
1356  if ( SwFrameSize::Variable == pSz->GetHeightSizeType() )
1357  rSet.DisableItem( nSlot );
1358  }
1359  break;
1360  }
1361  case FN_TABLE_INSERT_ROW:
1364  if ( rSh.IsInRepeatedHeadline() )
1365  rSet.DisableItem( nSlot );
1366  break;
1367  case RES_LR_SPACE:
1368  rSet.Put(pFormat->GetLRSpace());
1369  break;
1370  case RES_UL_SPACE:
1371  rSet.Put(pFormat->GetULSpace());
1372  break;
1373 
1374  case SID_TABLE_VERT_NONE:
1375  case SID_TABLE_VERT_CENTER:
1376  case SID_TABLE_VERT_BOTTOM:
1377  {
1378  const sal_uInt16 nAlign = rSh.GetBoxAlign();
1379  bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1380  (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1381  (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1382  rSet.Put(SfxBoolItem(nSlot, bSet));
1383  break;
1384  }
1385 
1386  case FN_TABLE_MODE_FIX :
1387  case FN_TABLE_MODE_FIX_PROP :
1388  case FN_TABLE_MODE_VARIABLE :
1389  {
1390  TableChgMode nMode = rSh.GetTableChgMode();
1391  bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TableChgMode::FixedWidthChangeAbs) ||
1394  rSet.Put(SfxBoolItem(nSlot, bSet));
1395  }
1396  break;
1397 
1398  case SID_ATTR_PARA_SPLIT:
1399  rSet.Put( pFormat->GetKeep() );
1400  break;
1401 
1402  case SID_ATTR_PARA_KEEP:
1403  rSet.Put( pFormat->GetLayoutSplit() );
1404  break;
1405  case FN_TABLE_SPLIT_TABLE:
1406  if ( rSh.IsInHeadline() )
1407  rSet.DisableItem( nSlot );
1408  break;
1409  case FN_TABLE_MERGE_TABLE:
1410  {
1411  bool bAsk;
1412  if( !rSh.CanMergeTable( true, &bAsk ))
1413  rSet.DisableItem( nSlot );
1414  break;
1415  }
1416 
1417  case FN_TABLE_DELETE_ROW:
1418  {
1419  SwSelBoxes aBoxes;
1420  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
1421  if( ::HasProtectedCells( aBoxes ) || lcl_BoxesInDeletedRows( rSh, aBoxes ) )
1422  rSet.DisableItem( nSlot );
1423  }
1424  break;
1425  case FN_TABLE_DELETE_COL:
1426  {
1427  SwSelBoxes aBoxes;
1428  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
1429  if( ::HasProtectedCells( aBoxes ) || lcl_CursorInDeletedTable( rSh ) )
1430  rSet.DisableItem( nSlot );
1431  }
1432  break;
1433  case FN_TABLE_DELETE_TABLE:
1434  if( lcl_CursorInDeletedTable( rSh ) )
1435  rSet.DisableItem( nSlot );
1436  break;
1437 
1439  // disable in readonly sections, but enable in protected cells
1440  if( !rSh.CanUnProtectCells() )
1441  rSet.DisableItem( nSlot );
1442  break;
1443  case RES_ROW_SPLIT:
1444  {
1445  const SwFormatLayoutSplit& rTabSplit = pFormat->GetLayoutSplit();
1446  if ( !rTabSplit.GetValue() )
1447  {
1448  rSet.DisableItem( nSlot );
1449  }
1450  else
1451  {
1452  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
1453  if(pSplit)
1454  rSet.Put(std::move(pSplit));
1455  else
1456  rSet.InvalidateItem( nSlot );
1457  }
1458  break;
1459  }
1461  if(0 != rSh.GetRowsToRepeat())
1462  rSet.Put(SfxBoolItem(nSlot, true));
1463  else if(!rSh.GetRowSelectionFromTop())
1464  rSet.DisableItem( nSlot );
1465  else
1466  rSet.Put(SfxBoolItem(nSlot, false));
1467  break;
1468  case FN_TABLE_SELECT_CELL :
1469  if(rSh.HasBoxSelection())
1470  rSet.DisableItem( nSlot );
1471  break;
1473  {
1475  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1476  if (pHeight)
1477  {
1478  tools::Long nHeight = pHeight->GetHeight();
1479  aRowHeight.SetValue(nHeight);
1480  rSet.Put(aRowHeight);
1481 
1483  {
1484  // TODO: set correct unit
1485  MapUnit eTargetUnit = MapUnit::MapInch;
1486  OUString sHeight = GetMetricText(nHeight,
1487  MapUnit::MapTwip, eTargetUnit, nullptr);
1488 
1489  OUString sPayload = ".uno:TableRowHeight=" + sHeight;
1490 
1491  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1492  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1493  }
1494  }
1495  break;
1496  }
1498  {
1500  SwTableFUNC aFunc( &rSh );
1501  aFunc.InitTabCols();
1502  SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum());
1503  aColumnWidth.SetValue(nWidth);
1504  rSet.Put(aColumnWidth);
1505 
1507  {
1508  // TODO: set correct unit
1509  MapUnit eTargetUnit = MapUnit::MapInch;
1510  OUString sWidth = GetMetricText(nWidth,
1511  MapUnit::MapTwip, eTargetUnit, nullptr);
1512 
1513  OUString sPayload = ".uno:TableColumWidth=" + sWidth;
1514 
1515  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1516  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1517  }
1518 
1519  break;
1520  }
1521  }
1522  nSlot = aIter.NextWhich();
1523  }
1524 }
1525 
1527  SwBaseShell(_rView)
1528 {
1529  SetName("Table");
1531 }
1532 
1534 {
1536  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> aCoreSet( GetPool() );
1537  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1538  aCoreSet.Put( aBoxInfo );
1539  GetShell().GetTabBorders( aCoreSet );
1540  rSet.Put( aCoreSet );
1541 }
1542 
1544 {
1545  SwWrtShell &rSh = GetShell();
1546  const SfxItemSet *pArgs = rReq.GetArgs();
1547  if(!pArgs)
1548  return;
1549 
1550  switch ( rReq.GetSlot() )
1551  {
1552  case SID_FRAME_LINESTYLE:
1553  case SID_FRAME_LINECOLOR:
1554  if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1555  {
1556  const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE );
1557  const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1558  rSh.SetTabLineStyle( nullptr, true, pBorderLine);
1559  }
1560  else
1561  {
1562  const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR );
1563  rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1564  }
1565 
1566  rReq.Done();
1567 
1568  break;
1569  }
1570 }
1571 
1573 {
1575  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> aCoreSet( GetPool() );
1576  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1577  aCoreSet.Put(aCoreInfo);
1578  GetShell().GetTabBorders( aCoreSet );
1579 
1580  const SvxBoxItem& rBoxItem = aCoreSet.Get( RES_BOX );
1581  const SvxBorderLine* pLine = rBoxItem.GetTop();
1582 
1583  rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1584  SvxLineItem aLine( SID_FRAME_LINESTYLE );
1585  aLine.SetLine(pLine);
1586  rSet.Put( aLine );
1587 }
1588 
1590 {
1591  const SfxItemSet* pArgs = rReq.GetArgs();
1592  SwWrtShell &rSh = GetShell();
1593 
1594  // At first the slots, which doesn't need a FrameMgr.
1595  const SfxPoolItem* pItem = nullptr;
1596  const sal_uInt16 nSlot = rReq.GetSlot();
1597  if(pArgs)
1598  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
1599 
1600  // Always acquire the language from the current cursor position.
1601  LanguageType eLang = rSh.GetCurLang();
1602  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1603  sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1604  SvNumFormatType nFormatType = SvNumFormatType::ALL;
1605  sal_uInt16 nOffset = 0;
1606 
1607  switch ( nSlot )
1608  {
1609  case FN_NUMBER_FORMAT:
1610  if( pItem )
1611  {
1612  // Determine index for string.
1613  OUString aCode( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1614  nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1615  if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1616  {
1617  // Re-enter
1618  sal_Int32 nErrPos;
1620  if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1621  nNumberFormat, eLang ))
1622  nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1623  }
1624  }
1625  break;
1626  case FN_NUMBER_STANDARD: nFormatType = SvNumFormatType::NUMBER; break;
1627  case FN_NUMBER_SCIENTIFIC: nFormatType = SvNumFormatType::SCIENTIFIC; break;
1628  case FN_NUMBER_DATE: nFormatType = SvNumFormatType::DATE; break;
1629  case FN_NUMBER_TIME: nFormatType = SvNumFormatType::TIME; break;
1630  case FN_NUMBER_CURRENCY: nFormatType = SvNumFormatType::CURRENCY; break;
1631  case FN_NUMBER_PERCENT: nFormatType = SvNumFormatType::PERCENT; break;
1632 
1633  case FN_NUMBER_TWODEC: // #.##0,00
1634  nFormatType = SvNumFormatType::NUMBER;
1635  nOffset = NF_NUMBER_1000DEC2;
1636  break;
1637 
1638  default:
1639  OSL_FAIL("wrong dispatcher");
1640  return;
1641  }
1642 
1643  if( nFormatType != SvNumFormatType::ALL )
1644  nNumberFormat = pFormatter->GetStandardFormat( nFormatType, eLang ) + nOffset;
1645 
1646  if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1647  {
1649  aBoxSet.Put( SwTableBoxNumFormat( nNumberFormat ));
1650  rSh.SetTableBoxFormulaAttrs( aBoxSet );
1651  }
1652 
1653 }
1654 
1655 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool GetValue() const
#define FN_TABLE_INSERT_COL_DLG
Definition: cmdid.h:400
#define FN_TABLE_SET_READ_ONLY_CELLS
Definition: cmdid.h:375
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
sal_Int32 GetValue() const
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
const SfxPoolItem * ExecuteList(sal_uInt16 nSlot, SfxCallMode nCall, std::initializer_list< SfxPoolItem const * > args, std::initializer_list< SfxPoolItem const * > internalargs=std::initializer_list< SfxPoolItem const * >())
FieldUnit
static const sal_Int16 VeryThin
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:224
SwMoveFnCollection const & fnTableEnd
Definition: paminit.cxx:53
#define FN_TABLE_INSERT_COL_BEFORE
Definition: cmdid.h:370
constexpr SwTwips MIN_BORDER_DIST
Definition: swtypes.hxx:70
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
#define FN_TABLE_OPTIMAL_HEIGHT
Definition: cmdid.h:383
#define FN_TABLE_SET_COL_WIDTH
Definition: cmdid.h:366
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
const SwFormatLayoutSplit & GetLayoutSplit(bool=true) const
Definition: fmtlsplt.hxx:46
void SplitTab(bool bVert, sal_uInt16 nCnt, bool bSameHeight)
Split cell vertically or horizontally.
Definition: fetab.cxx:543
SwView & GetView()
Definition: basesh.hxx:59
#define SFX_IMPL_INTERFACE(Class, SuperClass)
static SfxInterface * GetStaticInterface()
void SetDefDist(sal_uInt16 nNew)
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
Definition: node.cxx:754
SwTwips GetLeftSpace() const
Definition: swtablerep.hxx:60
static std::shared_ptr< std::vector< std::unique_ptr< SwPaM > > > CopyPaMRing(SwPaM &rOrig)
Definition: basesh.cxx:3175
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
SwView * GetActiveView()
Definition: swmodul1.cxx:116
void SetRowSplit(const SwFormatRowSplit &rSz)
Definition: fetab.cxx:781
static constexpr auto Items
SwTwips GetColWidth(sal_uInt16 nNum) const
Definition: tablemgr.cxx:58
SwTwips GetTableWidth(SwFrameFormat const *pFormat, SwTabCols const &rCols, sal_uInt16 *pPercent, SwWrtShell *pSh)
Definition: uitool.cxx:821
SwUndoId
Definition: swundo.hxx:29
std::string GetValue
void SetRowBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:818
#define FN_TABLE_SPLIT_TABLE
Definition: cmdid.h:474
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
#define SID_ATTR_TABLE_COLUMN_WIDTH
Definition: cmdid.h:442
virtual VclPtr< VclAbstractDialog > CreateTableMergeDialog(weld::Window *pParent, bool &rWithPrev)=0
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
SwNodeIndex nNode
Definition: pam.hxx:38
bool IsTableMode() const
Definition: crsrsh.hxx:648
void SetMinDist(bool bNew)
void ProtectCells()
If a table selection exists it is destroyed in case cursor is not allowed in readonly.
Definition: fetab.cxx:978
const SwRect & GetAnyCurRect(CurRectType eType, const Point *pPt=nullptr, const css::uno::Reference< css::embed::XEmbeddedObject > &=css::uno::Reference< css::embed::XEmbeddedObject >()) const
Definition: fews.cxx:90
#define FN_TABLE_DELETE_TABLE
Definition: cmdid.h:384
void InsertCol(sal_uInt16 nCnt, bool bBehind)
Definition: fetab.cxx:212
SfxDispatcher * GetDispatcher()
SwWrtShell & GetShell()
Definition: basesh.cxx:2820
static SvxAbstractDialogFactory * Create()
#define FN_TABLE_INSERT_COL
Definition: cmdid.h:360
#define FN_TABLE_INSERT_ROW
Definition: cmdid.h:359
long Long
void SetTable(bool bNew)
#define MINLAY
Definition: swtypes.hxx:62
const editeng::SvxBorderLine * GetVert() const
const SvxFrameDirectionItem & GetFrameDir(bool=true) const
Definition: frmatr.hxx:94
void DeleteTable()
Definition: fetab.cxx:310
virtual void SetSplitVerticalByDefault()=0
tools::Long GetRightMax() const
Definition: tabcol.hxx:80
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1993
constexpr sal_uInt16 RES_FRMATR_END(133)
void GetLineStyleState(SfxItemSet &rSet)
Definition: tabsh.cxx:1572
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:334
sal_uInt16 GetValue() const
void InvalidateItem(sal_uInt16 nWhich)
sal_Int16 nId
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
bool FillTabCols(SwTabCols &rTabCol) const
Definition: swtablerep.cxx:60
sal_uInt16 FirstWhich()
TableChgMode GetTableChgMode() const
Definition: edtab.cxx:278
SwUndoId EndUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Closes parenthesis of nUndoId, not used by UI.
Definition: edws.cxx:234
#define FN_TABLE_INSERT_COL_AFTER
Definition: cmdid.h:374
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
SwTableLine is one table row in the document model.
Definition: swtable.hxx:357
bool DeleteCol()
Definition: fetab.cxx:265
SwNode & GetNode() const
Definition: ndindex.hxx:128
bool HasProtectedCells(const SwSelBoxes &rBoxes)
Definition: tblsel.cxx:856
virtual VclPtr< SfxAbstractTabDialog > CreateSwTableTabDlg(weld::Window *pParent, const SfxItemSet *pItemSet, SwWrtShell *pSh)=0
void EnterStdMode()
Definition: select.cxx:551
void Done(bool bRemove=false)
#define FN_PARAM_TABLE_NAME
Definition: cmdid.h:796
NF_NUMBER_1000DEC2
SwTwips GetRightSpace() const
Definition: swtablerep.hxx:63
void SetLine(const editeng::SvxBorderLine *pNew)
#define FN_EDIT_FORMULA
Definition: cmdid.h:84
#define FN_CALC_TABLE
Definition: cmdid.h:85
std::unique_ptr< SwFormatFrameSize > GetRowHeight() const
Pointer must be destroyed by caller != 0.
Definition: fetab.cxx:802
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
#define FN_NUMBER_FORMAT
Definition: cmdid.h:456
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
bool HasColsChanged() const
Definition: swtablerep.hxx:78
void InsertRow(sal_uInt16 nCnt, bool bBehind)
Definition: fetab.cxx:173
virtual SvxBrushItem * Clone(SfxItemPool *pPool=nullptr) const override
const editeng::SvxBorderLine * GetRight() const
SwNodeOffset abs(const SwNodeOffset &a)
Definition: nodeoffset.hxx:34
void EndAllAction()
Definition: edws.cxx:97
SwTwips GetWidth() const
Definition: swtablerep.hxx:66
#define FN_TABLE_SELECT_ROW
Definition: cmdid.h:371
const std::vector< sal_uInt32 > & GetDelFormats() const
static bool lcl_CursorInDeletedTable(SwWrtShell &rSh)
Definition: tabsh.cxx:474
Value in Var-direction gives minimum (can be exceeded but not be less).
bool GoNextCell(bool bAppendLine=true)
set cursor into next/previous cell
Definition: trvltbl.cxx:39
sal_uInt16 NextWhich()
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
virtual VclPtr< VclAbstractDialog > CreateSwTableHeightDialog(weld::Window *pParent, SwWrtShell &rSh)=0
virtual bool IsHorizontal() const =0
bool GotoCurrTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:633
LanguageType GetCurLang() const
Definition: edattr.cxx:802
bool IsInRepeatedHeadline() const
Definition: fesh.hxx:722
void SetTabBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:899
Used by the UI to modify the document model.
Definition: wrtsh.hxx:96
#define FN_PARAM_TABLE_HEADLINE
Definition: cmdid.h:797
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
#define FN_TABLE_AUTOSUM
Definition: cmdid.h:444
void SelectTableRow()
Definition: select.cxx:835
bool IsTableVertical() const
Definition: fetab.cxx:2393
static void lcl_SetAttr(SwWrtShell &rSh, const SfxPoolItem &rItem)
Definition: tabsh.cxx:129
#define FN_NUMBER_BULLETS
Definition: cmdid.h:80
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:333
static void lcl_TabGetMaxLineWidth(const SvxBorderLine *pBorderLine, SvxBorderLine &rBorderLine)
Definition: tabsh.cxx:438
const SwView & GetView() const
Definition: wrtsh.hxx:437
#define FN_GOTO_NEXT_CELL
Definition: cmdid.h:403
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
#define FN_TABLE_SELECT_ALL
Definition: cmdid.h:373
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW, bool bReplaceBooleanEquivalent=true)
sal_uInt16 GetAlign() const
Definition: swtablerep.hxx:72
void AdjustCellWidth(const bool bBalance, const bool bNoShrink)
Definition: fetab.cxx:1185
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
#define FN_PARAM_INSERT_AFTER
Definition: cmdid.h:794
const OUString & GetName() const
Definition: format.hxx:131
int nCount
virtual void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
void ExecTableStyle(SfxRequest &rReq)
Definition: tabsh.cxx:1543
void Width(tools::Long nNew)
Definition: swrect.hxx:189
bool BalanceRowHeight(bool bTstOnly, const bool bOptimize=false)
Definition: fetab.cxx:807
void GetFrameBorderState(SfxItemSet &rSet)
Definition: tabsh.cxx:1533
const SwTable & GetTable() const
Definition: node.hxx:506
void GetState(SfxItemSet &)
Definition: tabsh.cxx:1295
virtual VclPtr< AbstractSwAutoFormatDlg > CreateSwAutoFormatDlg(weld::Window *pParent, SwWrtShell *pShell, bool bSetAutoFormat=true, const SwTableAutoFormat *pSelFormat=nullptr)=0
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:86
SwDoc * GetDoc() const
Definition: viewsh.hxx:282
void InitTabCols()
Definition: tablemgr.cxx:154
#define FN_NUMBER_SCIENTIFIC
Definition: cmdid.h:459
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define FN_NUMBER_DATE
Definition: cmdid.h:460
static std::shared_ptr< SwTableRep > lcl_TableParamToItemSet(SfxItemSet &rSet, SwWrtShell &rSh)
Definition: tabsh.cxx:136
size_type size() const
#define FN_NUMBER_TWODEC
Definition: cmdid.h:458
void SelectTableCol()
Definition: select.cxx:844
void SetFormula(const OUString &rFormula)
Definition: inputwin.hxx:202
sal_uInt16 GetWidthPercent() const
Definition: swtablerep.hxx:69
bool IsDeleted(SwRedlineTable::size_type &rRedlinePos) const
Definition: swtable.cxx:1755
SfxItemPool & GetPool() const
#define FN_NUMBER_PERCENT
Definition: cmdid.h:463
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:345
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
constexpr TypedWhichId< SvxBoxInfoItem > SDRATTR_TABLE_BORDER_INNER(SDRATTR_TABLE_FIRST+1)
const WhichRangesContainer & SwuiGetUITableAttrRange()
Definition: tabsh.cxx:124
void SetTableDest(sal_uInt8 nNew)
Definition: viewopt.hxx:573
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:19
void SetTableChgMode(TableChgMode eMode)
Definition: edtab.cxx:289
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const editeng::SvxBorderLine * GetHori() const
#define FN_TABLE_INSERT_ROW_DLG
Definition: cmdid.h:401
void EndSelect()
Definition: select.cxx:425
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:617
bool IsMath() const
void SetTabBorders(const SfxItemSet &rSet)
Definition: fetab.cxx:831
bool ExtendedSelectedAll()
If ExtendedSelectAll() was called and selection didn't change since then.
Definition: crsrsh.cxx:607
const editeng::SvxBorderLine * GetTop() const
void SetBoxBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:854
bool IsDeleted() const
Definition: swtable.cxx:1590
#define FN_TABLE_MERGE_CELLS
Definition: cmdid.h:364
void SetTabCols(const SwTabCols &rNew, bool bCurRowOnly)
Definition: fetab.cxx:693
Style of a layout element.
Definition: frmfmt.hxx:59
SwTableShell(SwView &rView)
Definition: tabsh.cxx:1526
bool HasSelection() const
Definition: wrtsh.hxx:147
#define SW_MOD()
Definition: swmodule.hxx:255
bool HasBoxSelection() const
Is content of a table cell or at least a table cell completely selected?
Definition: fetab.cxx:937
const editeng::SvxBorderLine * GetLeft() const
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
SW_DLLPUBLIC FieldUnit GetDfltMetric(bool bWeb)
Definition: uitool.cxx:755
int i
#define FN_INSERT_TABLE
Definition: cmdid.h:228
const SwPaM * GetTableCrs() const
Definition: crsrsh.hxx:913
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: fetab.cxx:1076
const SwPosition * GetPoint() const
Definition: pam.hxx:208
css::drawing::Direction3D aDirection
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
void SetRowHeight(const SwFormatFrameSize &rSz)
Definition: fetab.cxx:794
#define LANGUAGE_SYSTEM
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2248
virtual VclPtr< SvxAbstractInsRowColDlg > CreateSvxInsRowColDlg(weld::Window *pParent, bool bCol, const OString &rHelpId)=0
#define FN_TABLE_ADJUST_CELLS
Definition: cmdid.h:378
const WhichRangesContainer aUITableAttrRange(svl::Items< RES_LR_SPACE, RES_UL_SPACE, RES_PAGEDESC, RES_BREAK, RES_BACKGROUND, RES_BACKGROUND, RES_BOX, RES_SHADOW, RES_KEEP, RES_KEEP, RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT, RES_FRAMEDIR, RES_FRAMEDIR, RES_ROW_SPLIT, RES_ROW_SPLIT, RES_COLLAPSING_BORDERS, RES_COLLAPSING_BORDERS, XATTR_FILL_FIRST, XATTR_FILL_LAST, SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW, SID_RULER_BORDERS, SID_RULER_BORDERS, SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE, FN_TABLE_REP, FN_TABLE_REP, FN_TABLE_SET_VERT_ALIGN, FN_TABLE_SET_VERT_ALIGN, FN_TABLE_BOX_TEXTORIENTATION, FN_TABLE_BOX_TEXTORIENTATION, FN_PARAM_TABLE_NAME, FN_PARAM_TABLE_NAME, FN_PARAM_TABLE_HEADLINE, FN_PARAM_TABLE_HEADLINE >)
bool SelTableBox()
Definition: trvltbl.cxx:286
SfxBindings & GetBindings()
#define FN_NUMBER_CURRENCY
Definition: cmdid.h:462
virtual VclPtr< SfxAbstractDialog > CreateNumFormatDialog(weld::Widget *pParent, const SfxItemSet &rAttr)=0
vector_type::size_type size_type
Definition: docary.hxx:222
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
const T * GetArg(sal_uInt16 nSlotId) const
tools::Long GetLeft() const
static bool lcl_BoxesInDeletedRows(SwWrtShell &rSh, const SwSelBoxes &rBoxes)
Definition: tabsh.cxx:447
OUString GetMetricText(tools::Long nVal, MapUnit eSrcUnit, MapUnit eDestUnit, const IntlWrapper *pIntl)
SwUndoId StartUndo(SwUndoId eUndoId=SwUndoId::EMPTY, const SwRewriter *pRewriter=nullptr)
Undo: set up Undo parenthesis, return nUndoId of this parenthesis.
Definition: edws.cxx:223
constexpr TypedWhichId< SfxBoolItem > RES_COLLAPSING_BORDERS(124)
virtual bool IsProportional() const =0
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3547
OUString GetTableBoxText() const
Definition: edtab.cxx:418
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
NF_TEXT
SvNumFormatType
void SetBoxAlign(sal_uInt16 nOrient)
Definition: fetab.cxx:886
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2745
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
virtual SvxBoxItem * Clone(SfxItemPool *pPool=nullptr) const override
void GetTabCols(SwTabCols &rToFill) const
Info about columns and margins.
Definition: fetab.cxx:711
sal_uInt32 GetEntryKey(std::u16string_view sStr, LanguageType eLnge=LANGUAGE_DONTKNOW)
void SetName(const OUString &rName)
bool empty() const
void SttSelect()
Definition: select.cxx:385
void GetTabBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
Definition: fetab.cxx:912
void DeleteEntry(sal_uInt32 nKey)
#define FN_TABLE_DELETE_COL
Definition: cmdid.h:362
sal_uInt16 GetRowSelectionFromTop() const
Definition: fetab.cxx:1129
SfxItemPool * GetPool() const
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
Definition: crsrsh.cxx:896
TableMergeErr MergeTab()
Merge selected parts of table.
Definition: fetab.cxx:511
void GetTableAttr(SfxItemSet &) const
Definition: fetab.cxx:2195
SfxViewShell * GetViewShell() const
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:258
virtual sal_uInt16 getInsertCount() const =0
tools::Long SwTwips
Definition: swtypes.hxx:51
SwDocShell * GetDocShell()
Definition: view.cxx:1132
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
#define FN_TABLE_INSERT_ROW_AFTER
Definition: cmdid.h:367
#define FN_GOTO_PREV_CELL
Definition: cmdid.h:404
#define SFX_OBJECTBAR_OBJECT
std::unique_ptr< SwFormatRowSplit > GetRowSplit() const
Definition: fetab.cxx:789
void UnProtectCells()
Refers to table selection.
Definition: fetab.cxx:998
SvNumberFormatter * GetNumberFormatter() const
SFX2_DLLPUBLIC OString GetCommand() const
#define FN_TABLE_MODE_FIX_PROP
Definition: cmdid.h:438
void StartAction()
Definition: crsrsh.cxx:227
bool MergeTable(bool bWithPrev)
Definition: edtab.cxx:456
#define FN_NUMBER_TIME
Definition: cmdid.h:461
void SetReturnValue(const SfxPoolItem &)
void Update(sal_uInt16 nId)
void InsertTable(SfxRequest &_rRequest)
Definition: basesh.cxx:2882
sal_uInt8 GetTableDest() const
Definition: viewopt.hxx:548
virtual tools::Long GetCount() const =0
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
sal_uInt16 GetSlot() const
static const OUString & GetContextName(const Context eContext)
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
#define FN_START_TABLE
Definition: cmdid.h:697
#define FN_TABLE_ROW_SPLIT
Definition: cmdid.h:487
SwCursor * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:195
const editeng::SvxBorderLine * GetLine() const
#define FN_TABLE_BALANCE_CELLS
Definition: cmdid.h:429
SfxItemState
void DisableItem(sal_uInt16 nWhich)
constexpr TypedWhichId< SvxBrushItem > RES_BACKGROUND(105)
bool CanMergeTable(bool bWithPrev=true, bool *pChkNxtPrv=nullptr) const
Merge tables.
Definition: edtab.cxx:474
#define FN_TABLE_BALANCE_ROWS
Definition: cmdid.h:430
SwMoveFnCollection const & fnTableStart
Definition: paminit.cxx:52
virtual bool isInsertBefore() const =0
void SetLeft(const tools::Long nL, const sal_uInt16 nProp=100)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
bool GoPrevCell()
Definition: trvltbl.cxx:101
#define FN_TABLE_REP
Definition: cmdid.h:357
#define GetWhich(nSlot)
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:428
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:682
void SetTableAttr(const SfxItemSet &)
Definition: fetab.cxx:2202
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
#define FN_TABLE_MERGE_TABLE
Definition: cmdid.h:486
sal_uInt16 GetCurColNum() const
Definition: tablemgr.cxx:320
void SetSplitVerticalByDefault(bool value)
Definition: select.cxx:372
void ItemSetToTableParam(const SfxItemSet &rSet, SwWrtShell &rSh)
Definition: tabsh.cxx:270
#define FN_TABLE_UNSET_READ_ONLY_CELLS
Definition: cmdid.h:376
#define FN_END_TABLE
Definition: cmdid.h:698
void ColWidthDlg(weld::Window *pParent)
Definition: tablemgr.cxx:49
bool IsSplitVerticalByDefault() const
Definition: select.cxx:367
sal_uInt32 GetStandardFormat(SvNumFormatType eType, LanguageType eLnge=LANGUAGE_DONTKNOW)
bool StartsWithTable()
If document body starts with a table.
Definition: crsrsh.cxx:626
RET_OK
SvxBoxItemLine
void SelectTableCell()
Definition: select.cxx:853
bool GetTableBoxFormulaAttrs(SfxItemSet &rSet) const
Definition: edtab.cxx:304
#define FN_TABLE_BOX_TEXTORIENTATION
Definition: cmdid.h:440
QPRO_FUNC_TYPE nType
#define FN_TABLE_SET_ROW_HEIGHT
Definition: cmdid.h:365
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
#define FN_TABLE_SELECT_COL
Definition: cmdid.h:372
bool IsHideRedlines() const
Replacement for sw::DocumentRedlineManager::GetRedlineFlags() (this is layout-level redline hiding)...
Definition: rootfrm.hxx:421
SvxBoxItem & rBoxItem
virtual VclPtr< AbstractSplitTableDialog > CreateSplitTableDialog(weld::Window *pParent, SwWrtShell &rSh)=0
void ClearMark()
Definition: crsrsh.cxx:939
constexpr TypedWhichId< SvxBoxItem > RES_BOX(106)
void GetTabBorders(SfxItemSet &rSet) const
Definition: fetab.cxx:849
bool GetRowBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:826
#define SID_ATTR_TABLE_ROW_HEIGHT
Definition: cmdid.h:441
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:358
void SetValue(sal_uInt32 nTheValue)
bool GetBoxDirection(std::unique_ptr< SvxFrameDirectionItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:878
#define FN_NUMBER_STANDARD
Definition: cmdid.h:457
sal_uInt32 GetValue() const
void SetValid(SvxBoxInfoItemValidFlags nValid, bool bValid=true)
void SetTableName(SwFrameFormat &rTableFormat, const OUString &rNewName)
change table name
Definition: editsh.cxx:404
MapUnit
void AppendItem(const SfxPoolItem &)
bool IsTableComplexForChart()
Definition: trvltbl.cxx:726
sal_uInt16 GetBoxAlign() const
USHRT_MAX if ambiguous.
Definition: fetab.cxx:894
sal_uInt16 GetRowsToRepeat() const
Definition: fetab.cxx:1067
#define FN_TABLE_INSERT_ROW_BEFORE
Definition: cmdid.h:369
bool IsInHeadline() const
Definition: fesh.hxx:723
#define FN_TABLE_MODE_VARIABLE
Definition: cmdid.h:439
#define FN_TABLE_SPLIT_CELLS
Definition: cmdid.h:363
TableChgMode
Definition: tblenum.hxx:47
bool IsAPI() const
bool IsAdjustCellWidthAllowed(bool bBalance=false) const
Not allowed if only empty cells are selected.
Definition: fetab.cxx:1199
const SfxPoolItem * Execute(sal_uInt16 nSlot, SfxCallMode nCall=SfxCallMode::SLOT, const SfxPoolItem **pArgs=nullptr, sal_uInt16 nModi=0, const SfxPoolItem **pInternalArgs=nullptr)
bool CanUnProtectCells() const
Definition: fetab.cxx:1040
void ExecNumberFormat(SfxRequest const &rReq)
Definition: tabsh.cxx:1589
#define FN_TABLE_MODE_FIX
Definition: cmdid.h:437
#define FN_TABLE_DELETE_ROW
Definition: cmdid.h:361
#define FN_TABLE_HEADLINE_REPEAT
Definition: cmdid.h:377
#define FN_TABLE_SELECT_CELL
Definition: cmdid.h:385
void GetAutoSum(OUString &rFormula) const
Definition: fetab.cxx:2280
#define FN_OPTIMIZE_TABLE
Definition: cmdid.h:368
Frame is variable in Var-direction.
bool HasWholeTabSelection() const
Definition: fetab.cxx:919
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1675
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2172
SwTableLine * GetUpper()
Definition: swtable.hxx:453
void SetTabLineStyle(const Color *pColor, bool bSetLine=false, const editeng::SvxBorderLine *pBorderLine=nullptr)
Definition: fetab.cxx:839
#define FN_TABLE_SET_VERT_ALIGN
Definition: cmdid.h:436
void Ignore()
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:757
bool DeleteRow(bool bCompleteTable=false)
Definition: fetab.cxx:315
void SetContextName(const OUString &rsContextName)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
const editeng::SvxBorderLine * GetBottom() const
#define FN_NUM_FORMAT_TABLE_DLG
Definition: cmdid.h:325
virtual VclPtr< SvxAbstractSplitTableDialog > CreateSvxSplitTableDialog(weld::Window *pParent, bool bIsTableVertical, tools::Long nMaxVertical)=0
constexpr TypedWhichId< SvxULSpaceItem > RES_UL_SPACE(92)
bool GetBoxBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:862
sal_uInt16 Which() const
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, bool bMobile=false)
constexpr TypedWhichId< SvxShadowItem > RES_SHADOW(107)
void Execute(SfxRequest &)
Definition: tabsh.cxx:484
Definition: view.hxx:144
void SetColWidth(sal_uInt16 nNum, SwTwips nWidth)
Definition: tablemgr.cxx:117
const Color & GetValue() const
void SetBoxDirection(const SvxFrameDirectionItem &rNew)
Definition: fetab.cxx:870
void SetDist(bool bNew)
Rect of current frame.
void EndAction(const bool bIdleEnd=false)
Definition: crsrsh.cxx:244
void SplitTable(SplitTable_HeadlineOption eMode)
Split table at cursor position.
Definition: edtab.cxx:440
const SvxLRSpaceItem & GetLRSpace(bool=true) const
Definition: frmatr.hxx:74
const SvxShadowItem & GetShadow(bool=true) const
Definition: frmatr.hxx:88
bool CursorInsideInputField() const
Definition: crstrvl.cxx:995