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 <wview.hxx>
59 #include <frmatr.hxx>
60 #include <uitool.hxx>
61 #include <inputwin.hxx>
62 #include <uiitems.hxx>
63 #include <tabsh.hxx>
64 #include <swtablerep.hxx>
65 #include <tablemgr.hxx>
66 #include <cellatr.hxx>
67 #include <frmfmt.hxx>
68 #include <swundo.hxx>
69 #include <swtable.hxx>
70 #include <docsh.hxx>
71 #include <tblsel.hxx>
72 #include <viewopt.hxx>
73 
74 #include <strings.hrc>
75 #include <cmdid.h>
76 #include <unobaseclass.hxx>
77 
78 #define ShellClass_SwTableShell
79 #include <sfx2/msg.hxx>
80 #include <swslots.hxx>
81 
82 #include <swabstdlg.hxx>
83 
84 #include <memory>
85 
86 using ::editeng::SvxBorderLine;
87 using namespace ::com::sun::star;
88 
90 
91 void SwTableShell::InitInterface_Impl()
92 {
93  GetStaticInterface()->RegisterPopupMenu("table");
94  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Table_Toolbox);
95 }
96 
97 
107 // #i29550#
109 // <-- collapsing borders
110  XATTR_FILL_FIRST, XATTR_FILL_LAST,
111  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
112  SID_RULER_BORDERS, SID_RULER_BORDERS,
113  SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE, // ??? This is very strange range
114 // SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION, // included into above
115 // 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  const SfxPoolItem* pItem = nullptr;
276 
277  if(SfxItemState::SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, false, &pItem))
278  {
279  SwViewOption aUsrPref( *rSh.GetViewOptions() );
280  aUsrPref.SetTableDest(static_cast<sal_uInt8>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()));
281  SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
282  }
283  bool bBorder = ( SfxItemState::SET == rSet.GetItemState( RES_BOX ) ||
284  SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
285  pItem = nullptr;
286  bool bBackground = SfxItemState::SET == rSet.GetItemState( RES_BACKGROUND, false, &pItem );
287  const SfxPoolItem* pRowItem = nullptr, *pTableItem = nullptr;
288  bBackground |= SfxItemState::SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, false, &pRowItem );
289  bBackground |= SfxItemState::SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, false, &pTableItem );
290  const SfxPoolItem* pSplit = nullptr;
291  bool bRowSplit = SfxItemState::SET == rSet.GetItemState( RES_ROW_SPLIT, false, &pSplit );
292  const SfxPoolItem* pBoxDirection = nullptr;
293  bool bBoxDirection = SfxItemState::SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, false, &pBoxDirection );
294  if( bBackground || bBorder || bRowSplit || bBoxDirection)
295  {
296  // The border will be applied to the present selection.
297  // If there is no selection, the table will be completely selected.
298  // The background will always be applied to the current state.
299  bool bTableSel = rSh.IsTableMode();
300  rSh.StartAllAction();
301 
302  if(bBackground)
303  {
304  if(pItem)
305  rSh.SetBoxBackground( *static_cast<const SvxBrushItem*>(pItem) );
306  if(pRowItem)
307  {
308  std::unique_ptr<SvxBrushItem> aBrush(static_cast<SvxBrushItem*>(pRowItem->Clone()));
309  aBrush->SetWhich(RES_BACKGROUND);
310  rSh.SetRowBackground(*aBrush);
311  }
312  if(pTableItem)
313  {
314  std::unique_ptr<SvxBrushItem> aBrush(static_cast<SvxBrushItem*>(pTableItem->Clone()));
315  aBrush->SetWhich(RES_BACKGROUND);
316  rSh.SetTabBackground( *aBrush );
317  }
318  }
319 
320  if(bBoxDirection)
321  {
322  SvxFrameDirectionItem aDirection( SvxFrameDirection::Environment, RES_FRAMEDIR );
323  aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
324  rSh.SetBoxDirection(aDirection);
325  }
326 
327  if(bBorder || bRowSplit)
328  {
329  rSh.Push();
330  if(!bTableSel)
331  {
333  }
334  if(bBorder)
335  rSh.SetTabBorders( rSet );
336 
337  if(bRowSplit)
338  {
339  rSh.SetRowSplit(*static_cast<const SwFormatRowSplit*>(pSplit));
340  }
341 
342  if(!bTableSel)
343  {
344  rSh.ClearMark();
345  }
347  }
348 
349  rSh.EndAllAction();
350  }
351 
352  SwTabCols aTabCols;
353  bool bTabCols = false;
354  SwTableRep* pRep = nullptr;
355  SwFrameFormat *pFormat = rSh.GetTableFormat();
357  if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
358  {
359  pRep = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>(pItem)->GetValue());
360 
361  const SwTwips nWidth = pRep->GetWidth();
362  if ( text::HoriOrientation::FULL == pRep->GetAlign() )
363  {
364  SwFormatHoriOrient aAttr( pFormat->GetHoriOrient() );
365  aAttr.SetHoriOrient( text::HoriOrientation::FULL );
366  aSet.Put( aAttr );
367  }
368  else
369  {
371  if(pRep->GetWidthPercent())
372  {
373  aSz.SetWidthPercent( static_cast<sal_uInt8>(pRep->GetWidthPercent()) );
374  }
375  aSet.Put(aSz);
376  }
377 
378  SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
379  aLRSpace.SetLeft(pRep->GetLeftSpace());
380  aLRSpace.SetRight(pRep->GetRightSpace());
381  aSet.Put( aLRSpace );
382 
383  sal_Int16 eOrient = pRep->GetAlign();
384  SwFormatHoriOrient aAttr( 0, eOrient );
385  aSet.Put( aAttr );
386  // The item must only be recorded while manual alignment, so that the
387  // alignment is not overwritten by the distances while recording.
388  if(eOrient != text::HoriOrientation::NONE)
389  const_cast<SfxItemSet&>(rSet).ClearItem( SID_ATTR_LRSPACE );
390 
391  if(pRep->HasColsChanged())
392  {
393  bTabCols = true;
394  }
395  }
396 
397  if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, false, &pItem))
398  rSh.SetRowsToRepeat( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
399 
400  if( SfxItemState::SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, false, &pItem))
401  rSh.SetBoxAlign(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
402 
403  if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, false, &pItem ))
404  rSh.SetTableName( *pFormat, static_cast<const SfxStringItem*>(pItem)->GetValue() );
405 
406  // Copy the chosen attributes in the ItemSet.
407  static const sal_uInt16 aIds[] =
408  {
409  RES_PAGEDESC,
410  RES_BREAK,
411  RES_KEEP,
413  RES_UL_SPACE,
414  RES_SHADOW,
415  RES_FRAMEDIR,
416  // #i29550#
418  // <-- collapsing borders
419  0
420  };
421  for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
422  if( SfxItemState::SET == rSet.GetItemState( *pIds, false, &pItem))
423  aSet.Put( *pItem );
424 
425  if(bTabCols)
426  {
427  rSh.GetTabCols( aTabCols );
428  bool bSingleLine = pRep->FillTabCols( aTabCols );
429  rSh.SetTabCols( aTabCols, bSingleLine );
430  }
431 
432  if( aSet.Count() )
433  rSh.SetTableAttr( aSet );
434 
436  rSh.EndAllAction();
437 }
438 
439 static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
440 {
441  if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
442  rBorderLine.SetWidth(pBorderLine->GetWidth());
443 
444  rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
445  rBorderLine.SetColor(pBorderLine->GetColor());
446 }
447 
449 {
450  const SfxItemSet* pArgs = rReq.GetArgs();
451  SwWrtShell &rSh = GetShell();
452 
453  // At first the slots which doesn't need a FrameMgr.
454  bool bMore = false;
455  const SfxPoolItem* pItem = nullptr;
456  sal_uInt16 nSlot = rReq.GetSlot();
457  if(pArgs)
458  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
459  bool bCallDone = false;
460  switch ( nSlot )
461  {
462  case SID_ATTR_BORDER:
463  {
464  if(!pArgs)
465  break;
466  // Create items, because we have to rework anyway.
467  std::shared_ptr<SvxBoxItem> aBox(std::make_shared<SvxBoxItem>(RES_BOX));
468  SfxItemSet aCoreSet( GetPool(),
470  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
471  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
472  aCoreSet.Put(aCoreInfo);
473  rSh.GetTabBorders( aCoreSet );
474  const SvxBoxItem& rCoreBox = aCoreSet.Get(RES_BOX);
475  const SfxPoolItem *pBoxItem = nullptr;
476  if ( pArgs->GetItemState(RES_BOX, true, &pBoxItem) == SfxItemState::SET )
477  {
478  aBox.reset(static_cast<SvxBoxItem*>(pBoxItem->Clone()));
479  sal_uInt16 nDefValue = MIN_BORDER_DIST;
480  if ( !rReq.IsAPI() )
481  nDefValue = 55;
482  if (!rReq.IsAPI() || aBox->GetSmallestDistance() < MIN_BORDER_DIST)
483  {
485  aBox->SetDistance( std::max(rCoreBox.GetDistance(k), nDefValue) , k );
486  }
487  }
488  else
489  OSL_ENSURE( false, "where is BoxItem?" );
490 
491  //since the drawing layer also supports borders the which id might be a different one
492  std::shared_ptr<SvxBoxInfoItem> aInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER));
493  if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, true, &pBoxItem) == SfxItemState::SET)
494  {
495  aInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxItem->Clone()));
496  }
497  else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, true, &pBoxItem) == SfxItemState::SET )
498  {
499  aInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxItem->Clone()));
500  aInfo->SetWhich(SID_ATTR_BORDER_INNER);
501  }
502 
503  aInfo->SetTable( true );
504  aInfo->SetValid( SvxBoxInfoItemValidFlags::DISABLE, false );
505 
506 // The attributes of all lines will be read and the strongest wins.
507  const SvxBorderLine* pBorderLine;
508  SvxBorderLine aBorderLine;
509  if ((pBorderLine = rCoreBox.GetTop()) != nullptr)
510  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
511  if ((pBorderLine = rCoreBox.GetBottom()) != nullptr)
512  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
513  if ((pBorderLine = rCoreBox.GetLeft()) != nullptr)
514  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
515  if ((pBorderLine = rCoreBox.GetRight()) != nullptr)
516  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
517  if ((pBorderLine = aCoreInfo.GetHori()) != nullptr)
518  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
519  if ((pBorderLine = aCoreInfo.GetVert()) != nullptr)
520  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
521 
522  if(aBorderLine.GetOutWidth() == 0)
523  {
524  aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::SOLID);
525  aBorderLine.SetWidth( DEF_LINE_WIDTH_5 );
526  }
527 
528  if( aBox->GetTop() != nullptr )
529  {
530  aBox->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
531  }
532  if( aBox->GetBottom() != nullptr )
533  {
534  aBox->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
535  }
536  if( aBox->GetLeft() != nullptr )
537  {
538  aBox->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
539  }
540  if( aBox->GetRight() != nullptr )
541  {
542  aBox->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
543  }
544  if( aInfo->GetHori() != nullptr )
545  {
546  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::HORI);
547  }
548  if( aInfo->GetVert() != nullptr )
549  {
550  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::VERT);
551  }
552 
553  aCoreSet.Put( *aBox );
554  aCoreSet.Put( *aInfo );
555  rSh.SetTabBorders( aCoreSet );
556 
557  // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
558  // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
559  // the SvxBoxItem
560  rReq.AppendItem( *aBox );
561  rReq.AppendItem( *aInfo );
562  bCallDone = true;
563  break;
564  }
565  case FN_INSERT_TABLE:
566  InsertTable( rReq );
567  break;
568  case FN_FORMAT_TABLE_DLG:
569  {
570  //#127012# get the bindings before the dialog is called
571  // it might happen that this shell is removed after closing the dialog
572  SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
573  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
574 
575  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr );
576  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
577  std::shared_ptr<SwTableRep> pTableRep(::lcl_TableParamToItemSet(aCoreSet, rSh));
578 
579  aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
580  rSh.GetTableAttr(aCoreSet);
581  // GetTableAttr overwrites the background!
582  std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
583  if(rSh.GetBoxBackground(aBrush))
584  aCoreSet.Put( *aBrush );
585  else
586  aCoreSet.InvalidateItem( RES_BACKGROUND );
587 
589  VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(GetView().GetFrameWeld(), &aCoreSet, &rSh));
590 
591  if (pDlg)
592  {
593  if (pItem)
594  pDlg->SetCurPageId(OUStringToOString(static_cast<const SfxStringItem *>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8));
595 
596  auto pRequest = std::make_shared<SfxRequest>(rReq);
597  rReq.Ignore(); // the 'old' request is not relevant any more
598 
599  const bool bTableMode = rSh.IsTableMode();
600  SwPaM* pCursor = bTableMode ? rSh.GetTableCrs() : rSh.GetCursor(); // tdf#142165 use table cursor if in table mode
601  auto vCursors = CopyPaMRing(*pCursor); // tdf#135636 make a copy to use at later apply
602  pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, vCursors, bTableMode](sal_Int32 nResult){
603  if (RET_OK == nResult)
604  {
605  if (!bTableMode && rSh.IsTableMode()) // tdf#140977 drop current table-cursor if setting a replacement
606  rSh.TableCursorToCursor(); // non-table one
607 
608  // tdf#135636 set the selection at dialog launch as current selection
609  rSh.SetSelection(*vCursors->front()); // UpdateCursor() will be called which in the case
610  // of a table selection should recreate a
611  // SwShellTableCursor if the selection is more than a single cell
612 
613  if (bTableMode && !rSh.IsTableMode()) // tdf#142721 ensure the new selection is a SwShellTableCursor in
614  rSh.SelTableBox(); // the case of a single cell
615 
616  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
617 
618  //to record FN_INSERT_TABLE correctly
619  pRequest->SetSlot(FN_FORMAT_TABLE_DLG);
620  pRequest->Done(*pOutSet);
621 
622  ItemSetToTableParam(*pOutSet, rSh);
623  }
624 
625  rBindings.Update(SID_RULER_BORDERS);
626  rBindings.Update(SID_ATTR_TABSTOP);
627  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
628  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
629 
630  pDlg->disposeOnce();
631  });
632  }
633  else
634  {
635  if (rReq.GetArgs())
636  ItemSetToTableParam(*rReq.GetArgs(), rSh);
637 
638  rBindings.Update(SID_RULER_BORDERS);
639  rBindings.Update(SID_ATTR_TABSTOP);
640  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
641  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
642  }
643 
644  break;
645  }
646  case SID_ATTR_BRUSH:
647  case SID_ATTR_BRUSH_ROW :
648  case SID_ATTR_BRUSH_TABLE :
649  if(rReq.GetArgs())
650  ItemSetToTableParam(*rReq.GetArgs(), rSh);
651  break;
653  {
654  SwView* pView = GetActiveView();
655  if(pView)
656  {
657  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
658  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
659  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
660  SfxItemSet aCoreSet(
661  GetPool(),
662  svl::Items<
663  SID_ATTR_NUMBERFORMAT_VALUE,
664  SID_ATTR_NUMBERFORMAT_INFO>);
665 
666  SfxItemSet aBoxSet( *aCoreSet.GetPool(),
668  RES_BOXATR_VALUE, RES_BOXATR_VALUE> );
669  rSh.GetTableBoxFormulaAttrs( aBoxSet );
670 
671  SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
672  if(eState == SfxItemState::DEFAULT)
673  {
674  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
675  pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
676  }
677  else
678  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
679  aBoxSet.Get(
680  RES_BOXATR_FORMAT ).GetValue() ));
681 
682  OUString sCurText( rSh.GetTableBoxText() );
683  aCoreSet.Put( SvxNumberInfoItem( pFormatter,
684  aBoxSet.Get(
685  RES_BOXATR_VALUE).GetValue(),
686  sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
687 
690 
691  if (RET_OK == pDlg->Execute())
692  {
693  const SvxNumberInfoItem* pNumberFormatItem
694  = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
695 
696  if( pNumberFormatItem )
697  {
698  for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
699  pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
700  }
701 
702  const SfxPoolItem* pNumberFormatValueItem = nullptr;
703  if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(
704  SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatValueItem ))
705  {
706  SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
707  svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT> );
708  aBoxFormatSet.Put( SwTableBoxNumFormat(
709  static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
710  rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
711 
712  }
713  }
714  }
715  break;
716  }
717  case FN_CALC_TABLE:
718  rSh.UpdateTable();
719  bCallDone = true;
720  break;
721  case FN_TABLE_DELETE_COL:
722  if ( rSh.DeleteCol() && rSh.HasSelection() )
723  rSh.EnterStdMode();
724  bCallDone = true;
725  break;
726  case FN_END_TABLE:
728  bCallDone = true;
729  break;
730  case FN_START_TABLE:
732  bCallDone = true;
733  break;
734  case FN_GOTO_NEXT_CELL:
735  {
736  bool bAppendLine = true;
737  if( pItem )
738  bAppendLine = static_cast<const SfxBoolItem*>(pItem)->GetValue();
739  rReq.SetReturnValue( SfxBoolItem( nSlot,
740  rSh.GoNextCell( bAppendLine ) ) );
741  bCallDone = true;
742  break;
743  }
744  case FN_GOTO_PREV_CELL:
745  rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
746  bCallDone = true;
747  break;
748  case FN_TABLE_DELETE_ROW:
749  if ( rSh.DeleteRow() && rSh.HasSelection() )
750  rSh.EnterStdMode();
751  bCallDone = true;
752  break;
754  if ( rSh.IsTableMode() )
755  switch ( rSh.MergeTab() )
756  {
757  case TableMergeErr::Ok:
758  bCallDone = true;
759  [[fallthrough]];
761  break;
763  {
764  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
765  VclMessageType::Info, VclButtonsType::Ok,
766  SwResId(STR_ERR_TABLE_MERGE)));
767  xInfoBox->run();
768  break;
769  }
770  default:
771  OSL_ENSURE( false, "unknown return value MergeTab.");
772  break;
773  }
774  break;
775  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
778  {
779  bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
780  const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot;
781  if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
782  {
783  {
784  // remove actions to make a valid table selection
785  UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
786  }
787  rSh.AdjustCellWidth(bBalance, bNoShrink);
788  }
789  bCallDone = true;
790  break;
791  }
792  case SID_TABLE_MINIMAL_ROW_HEIGHT:
793  {
794  const SwFormatFrameSize aSz;
795  rSh.SetRowHeight( aSz );
796  bCallDone = true;
797  break;
798  }
800  {
801  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
802  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
803  bCallDone = true;
804  break;
805  }
807  if ( rSh.BalanceRowHeight(true) )
808  rSh.BalanceRowHeight(false);
809  bCallDone = true;
810  break;
811  case FN_TABLE_SELECT_ALL:
812  rSh.EnterStdMode();
814  rSh.SttSelect();
816  rSh.EndSelect();
817  bCallDone = true;
818  break;
819  case FN_TABLE_SELECT_COL:
820  rSh.EnterStdMode();
821  rSh.SelectTableCol();
822  bCallDone = true;
823  break;
824  case FN_TABLE_SELECT_ROW:
825  rSh.EnterStdMode();
826  rSh.SelectTableRow();
827  bCallDone = true;
828  break;
830  rSh.ProtectCells();
831  rSh.ResetSelect( nullptr, false );
832  bCallDone = true;
833  break;
835  rSh.UnProtectCells();
836  bCallDone = true;
837  break;
838  case SID_AUTOFORMAT:
839  {
842  pDlg->Execute();
843  break;
844  }
846  {
849  pDlg->Execute();
850  break;
851  }
852  case FN_NUMBER_BULLETS:
853  case FN_NUM_BULLET_ON:
854  OSL_ENSURE( false, "function may not be called now." );
855  break;
856 
857 
858  // 2015/06 The following two are deprecated but kept for ascending
859  // compatibility
860  case FN_TABLE_INSERT_COL:
861  case FN_TABLE_INSERT_ROW:
862  // fallback
867  {
868  bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
870  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
871  sal_uInt16 nCount = 0;
872  bool bAfter = true;
873  if (pItem)
874  {
875  nCount = static_cast<const SfxInt16Item* >(pItem)->GetValue();
876  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, true, &pItem))
877  bAfter = static_cast<const SfxBoolItem* >(pItem)->GetValue();
878  }
879  else if( !rReq.IsAPI() )
880  {
881  SwSelBoxes aBoxes;
882  ::GetTableSel( rSh, aBoxes );
883  if ( !aBoxes.empty() )
884  {
885  tools::Long maxX = 0;
886  tools::Long maxY = 0;
887  tools::Long minX = std::numeric_limits<tools::Long>::max();
888  tools::Long minY = std::numeric_limits<tools::Long>::max();
889  tools::Long nbBoxes = aBoxes.size();
890  for ( tools::Long i = 0; i < nbBoxes; i++ )
891  {
892  Point aCoord ( aBoxes[i]->GetCoordinates() );
893  if ( aCoord.X() < minX ) minX = aCoord.X();
894  if ( aCoord.X() > maxX ) maxX = aCoord.X();
895  if ( aCoord.Y() < minY ) minY = aCoord.Y();
896  if ( aCoord.Y() > maxY ) maxY = aCoord.Y();
897  }
898  if (bColumn)
899  nCount = maxX - minX + 1;
900  else
901  nCount = maxY - minY + 1;
902  }
903  bAfter = rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
905  || rReq.GetSlot() == FN_TABLE_INSERT_ROW
906  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
907  }
908 
909  if( nCount )
910  {
911  // i74180: Table border patch submitted by chensuchun:
912  // -->get the SvxBoxInfoItem of the table before insert
913  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
914  ::lcl_TableParamToItemSet( aCoreSet, rSh );
915  bool bSetInnerBorders = false;
916  SwUndoId nUndoId = SwUndoId::EMPTY;
917  // <--End
918 
919  if( bColumn )
920  {
922  rSh.InsertCol( nCount, bAfter );
923  bSetInnerBorders = true;
924  nUndoId = SwUndoId::TABLE_INSCOL;
925  }
926  else if ( !rSh.IsInRepeatedHeadline() )
927  {
929  rSh.InsertRow( nCount, bAfter );
930  bSetInnerBorders = true;
931  nUndoId = SwUndoId::TABLE_INSROW;
932  }
933 
934  // -->after inserting,reset the inner table borders
935  if ( bSetInnerBorders )
936  {
937  const SvxBoxInfoItem& aBoxInfo(aCoreSet.Get(SID_ATTR_BORDER_INNER));
938  SfxItemSet aSet( GetPool(), svl::Items<SID_ATTR_BORDER_INNER,
939  SID_ATTR_BORDER_INNER>);
940  aSet.Put( aBoxInfo );
941  ItemSetToTableParam( aSet, rSh );
942  rSh.EndUndo( nUndoId );
943  }
944 
945  bCallDone = true;
946  break;
947  }
948 
950 
951  [[fallthrough]]; // on Count = 0 appears the dialog
952  }
955  {
956  const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
957  if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
958  {
961  nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
962  if( pDlg->Execute() == 1 )
963  {
964  const sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
966  SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
968  SfxViewFrame* pVFrame = GetView().GetViewFrame();
969  if( pVFrame )
970  pVFrame->GetDispatcher()->ExecuteList(nDispatchSlot,
971  SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
972  { &aCountItem, &aAfter });
973  }
974  }
975  break;
976  }
978  {
980  bool bHorizontal=true;
981  bool bProportional = false;
982  const SfxInt32Item* pSplit = rReq.GetArg<SfxInt32Item>(FN_TABLE_SPLIT_CELLS);
983  const SfxBoolItem* pHor = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
984  const SfxBoolItem* pProp = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
985  if ( pSplit )
986  {
987  nCount = pSplit->GetValue();
988  if ( pHor )
989  bHorizontal = pHor->GetValue();
990  if ( pProp )
991  bProportional = pProp->GetValue();
992  }
993  else
994  {
996  SwWrtShell* pSh = &rSh;
997  const tools::Long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
999  if(rSh.IsSplitVerticalByDefault())
1000  pDlg->SetSplitVerticalByDefault();
1001  pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
1002  if (nResult == RET_OK)
1003  {
1004  tools::Long nCount2 = pDlg->GetCount();
1005  bool bHorizontal2 = pDlg->IsHorizontal();
1006  bool bProportional2 = pDlg->IsProportional();
1007 
1008  // tdf#60242: remember choice for next time
1009  bool bVerticalWasChecked = !pDlg->IsHorizontal();
1010  pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
1011 
1012  if ( nCount2 > 1 )
1013  pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
1014  }
1015 
1016  pDlg->disposeOnce();
1017  });
1018  }
1019 
1020  if ( nCount>1 )
1021  {
1022  rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1023  bCallDone = true;
1024  }
1025  else
1026  rReq.Ignore();
1027  break;
1028  }
1029 
1030  case FN_TABLE_SPLIT_TABLE:
1031  {
1032  const SfxUInt16Item* pType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1033  if( pType )
1034  {
1035  switch( static_cast<SplitTable_HeadlineOption>(pType->GetValue()) )
1036  {
1042  rSh.SplitTable(static_cast<SplitTable_HeadlineOption>(pType->GetValue())) ;
1043  break;
1044  default: ;//wrong parameter, do nothing
1045  }
1046  }
1047  else
1048  {
1051  pDlg->Execute();
1052  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(pDlg->GetSplitMode()) ) );
1053  bCallDone = true;
1054  }
1055  break;
1056  }
1057 
1058  case FN_TABLE_MERGE_TABLE:
1059  {
1060  bool bPrev = rSh.CanMergeTable();
1061  bool bNext = rSh.CanMergeTable( false );
1062 
1063  if( bPrev && bNext )
1064  {
1067  if( RET_OK != pDlg->Execute())
1068  bPrev = bNext = false;
1069  }
1070 
1071  if( bPrev || bNext )
1072  rSh.MergeTable( bPrev );
1073  break;
1074  }
1075 
1076  case FN_TABLE_MODE_FIX :
1077  case FN_TABLE_MODE_FIX_PROP :
1078  case FN_TABLE_MODE_VARIABLE :
1079  {
1080  rSh.SetTableChgMode( FN_TABLE_MODE_FIX == nSlot
1082  : FN_TABLE_MODE_FIX_PROP == nSlot
1085 
1086  SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1087  static sal_uInt16 aInva[] =
1091  0
1092  };
1093  rBind.Invalidate( aInva );
1094  bCallDone = true;
1095  break;
1096  }
1097  case FN_TABLE_AUTOSUM:
1098  {
1099  SfxViewFrame* pVFrame = GetView().GetViewFrame();
1100  pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::SYNCHRON);
1101  const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1102  SwInputChild* pChildWin = static_cast<SwInputChild*>(pVFrame->
1103  GetChildWindow( nId ));
1104  OUString sSum;
1105  GetShell().GetAutoSum(sSum);
1106  if( pChildWin )
1107  pChildWin->SetFormula( sSum );
1108 
1109  break;
1110  }
1112  if(0 != rSh.GetRowsToRepeat())
1113  rSh.SetRowsToRepeat( 0 );
1114  else
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();
1125  rSh.DeleteTable();
1126  rSh.EndUndo();
1127  rSh.EndAction();
1128  //'this' is already destroyed
1129  return;
1130  }
1132  {
1134  if (pItem2)
1135  {
1136  tools::Long nNewHeight = pItem2->GetValue();
1137  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1138  if ( pHeight )
1139  {
1140  if (pHeight->GetHeightSizeType() == SwFrameSize::Variable)
1141  pHeight->SetHeightSizeType(SwFrameSize::Minimum);
1142  pHeight->SetHeight(nNewHeight);
1143  rSh.SetRowHeight(*pHeight);
1144  }
1145  }
1146  return;
1147  }
1149  {
1151  if (pItem2)
1152  {
1153  tools::Long nNewWidth = pItem2->GetValue();
1154  SwTableFUNC aFunc( &rSh );
1155  aFunc.InitTabCols();
1156  aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth);
1157  }
1158  return;
1159  }
1160  default:
1161  bMore = true;
1162  }
1163 
1164  if ( !bMore )
1165  {
1166  if(bCallDone)
1167  rReq.Done();
1168  return;
1169  }
1170 
1171  // Now the slots which are working directly on the TableFormat.
1172  switch ( nSlot )
1173  {
1174  case SID_ATTR_ULSPACE:
1175  if(pItem)
1176  {
1177  SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem*>(pItem) );
1178  aULSpace.SetWhich( RES_UL_SPACE );
1179  ::lcl_SetAttr( rSh, aULSpace );
1180  }
1181  break;
1182 
1183  case SID_ATTR_LRSPACE:
1184  if(pItem)
1185  {
1188  SvxLRSpaceItem aLRSpace( *static_cast<const SvxLRSpaceItem*>(pItem) );
1189  aLRSpace.SetWhich( RES_LR_SPACE );
1190  aSet.Put( aLRSpace );
1191  rSh.SetTableAttr( aSet );
1192  }
1193  break;
1194  // The last case branch which needs a table manager!!
1196  {
1197  SwTableFUNC aMgr( &rSh );
1198  aMgr.ColWidthDlg(GetView().GetFrameWeld());
1199  break;
1200  }
1201  case SID_TABLE_VERT_NONE:
1202  case SID_TABLE_VERT_CENTER:
1203  case SID_TABLE_VERT_BOTTOM:
1204  {
1205  const sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1207  nSlot == SID_TABLE_VERT_CENTER ?
1208  text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1209  rSh.SetBoxAlign(nAlign);
1210  bCallDone = true;
1211  break;
1212  }
1213 
1214  case SID_ATTR_PARA_SPLIT:
1215  if ( pItem )
1216  {
1217  SwFormatLayoutSplit aSplit( static_cast<const SvxFormatSplitItem*>(pItem)->GetValue());
1218  SfxItemSet aSet(GetPool(), svl::Items<RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT> );
1219  aSet.Put(aSplit);
1220  rSh.SetTableAttr(aSet);
1221  }
1222  break;
1223 
1224  case SID_ATTR_PARA_KEEP:
1225  if ( pItem )
1226  {
1227  SvxFormatKeepItem aKeep( *static_cast<const SvxFormatKeepItem*>(pItem) );
1228  aKeep.SetWhich( RES_KEEP );
1229  SfxItemSet aSet(GetPool(), svl::Items<RES_KEEP, RES_KEEP> );
1230  aSet.Put(aKeep);
1231  rSh.SetTableAttr(aSet);
1232  }
1233  break;
1234  case FN_TABLE_ROW_SPLIT :
1235  {
1236  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1237  std::unique_ptr<SwFormatRowSplit> pSplit;
1238  if(!pBool)
1239  {
1240  pSplit = rSh.GetRowSplit();
1241  if(pSplit)
1242  pSplit->SetValue(!pSplit->GetValue());
1243  else
1244  pSplit.reset(new SwFormatRowSplit(true));
1245  }
1246  else
1247  {
1248  pSplit.reset(new SwFormatRowSplit(pBool->GetValue()));
1249  }
1250  rSh.SetRowSplit( *pSplit );
1251  break;
1252  }
1253 
1254  default:
1255  OSL_ENSURE( false, "wrong Dispatcher" );
1256  return;
1257  }
1258  if(bCallDone)
1259  rReq.Done();
1260 }
1261 
1263 {
1264  SfxWhichIter aIter( rSet );
1265  SwWrtShell &rSh = GetShell();
1266  SwFrameFormat *pFormat = rSh.GetTableFormat();
1267  // os #124829# crash report: in case of an invalid shell selection return immediately
1268  if(!pFormat)
1269  return;
1270  sal_uInt16 nSlot = aIter.FirstWhich();
1271  while ( nSlot )
1272  {
1273  switch ( nSlot )
1274  {
1275  case FN_TABLE_MERGE_CELLS:
1276  if ( !rSh.IsTableMode() )
1278  break;
1279  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1280  case FN_TABLE_ADJUST_CELLS:
1281  if ( !rSh.IsAdjustCellWidthAllowed() )
1282  rSet.DisableItem(nSlot);
1283  break;
1284 
1286  if ( !rSh.IsAdjustCellWidthAllowed(true) )
1288  break;
1289 
1291  case FN_TABLE_BALANCE_ROWS:
1292  if ( !rSh.BalanceRowHeight(true) )
1293  rSet.DisableItem(nSlot);
1294  break;
1295  case FN_OPTIMIZE_TABLE:
1296  if ( !rSh.IsTableMode() &&
1297  !rSh.IsAdjustCellWidthAllowed() &&
1298  !rSh.IsAdjustCellWidthAllowed(true) &&
1299  !rSh.BalanceRowHeight(true) )
1301  break;
1302  case SID_INSERT_DIAGRAM:
1303  {
1304  SvtModuleOptions aMOpt;
1305  if ( !aMOpt.IsMath() || rSh.IsTableComplexForChart() )
1306  rSet.DisableItem(nSlot);
1307  }
1308  break;
1309 
1310  case FN_INSERT_TABLE:
1311  if ( rSh.CursorInsideInputField() )
1312  {
1313  rSet.DisableItem( nSlot );
1314  }
1315  break;
1316 
1317  case SID_TABLE_MINIMAL_ROW_HEIGHT:
1318  {
1319  // Disable if auto height already is enabled.
1320  std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight();
1321  if ( pSz )
1322  {
1323  if ( SwFrameSize::Variable == pSz->GetHeightSizeType() )
1324  rSet.DisableItem( nSlot );
1325  }
1326  break;
1327  }
1328  case FN_TABLE_INSERT_ROW:
1331  if ( rSh.IsInRepeatedHeadline() )
1332  rSet.DisableItem( nSlot );
1333  break;
1334  case RES_LR_SPACE:
1335  rSet.Put(pFormat->GetLRSpace());
1336  break;
1337  case RES_UL_SPACE:
1338  rSet.Put(pFormat->GetULSpace());
1339  break;
1340 
1341  case SID_TABLE_VERT_NONE:
1342  case SID_TABLE_VERT_CENTER:
1343  case SID_TABLE_VERT_BOTTOM:
1344  {
1345  const sal_uInt16 nAlign = rSh.GetBoxAlign();
1346  bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1347  (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1348  (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1349  rSet.Put(SfxBoolItem(nSlot, bSet));
1350  break;
1351  }
1352 
1353  case FN_TABLE_MODE_FIX :
1354  case FN_TABLE_MODE_FIX_PROP :
1355  case FN_TABLE_MODE_VARIABLE :
1356  {
1357  TableChgMode nMode = rSh.GetTableChgMode();
1358  bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TableChgMode::FixedWidthChangeAbs) ||
1361  rSet.Put(SfxBoolItem(nSlot, bSet));
1362  }
1363  break;
1364 
1365  case SID_ATTR_PARA_SPLIT:
1366  rSet.Put( pFormat->GetKeep() );
1367  break;
1368 
1369  case SID_ATTR_PARA_KEEP:
1370  rSet.Put( pFormat->GetLayoutSplit() );
1371  break;
1372  case FN_TABLE_SPLIT_TABLE:
1373  if ( rSh.IsInHeadline() )
1374  rSet.DisableItem( nSlot );
1375  break;
1376  case FN_TABLE_MERGE_TABLE:
1377  {
1378  bool bAsk;
1379  if( !rSh.CanMergeTable( true, &bAsk ))
1380  rSet.DisableItem( nSlot );
1381  break;
1382  }
1383 
1384  case FN_TABLE_DELETE_ROW:
1385  {
1386  SwSelBoxes aBoxes;
1387  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
1388  if( ::HasProtectedCells( aBoxes ))
1389  rSet.DisableItem( nSlot );
1390  }
1391  break;
1392  case FN_TABLE_DELETE_COL:
1393  {
1394  SwSelBoxes aBoxes;
1395  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
1396  if( ::HasProtectedCells( aBoxes ))
1397  rSet.DisableItem( nSlot );
1398  }
1399  break;
1400 
1402  // disable in readonly sections, but enable in protected cells
1403  if( !rSh.CanUnProtectCells() )
1404  rSet.DisableItem( nSlot );
1405  break;
1406  case RES_ROW_SPLIT:
1407  {
1408  const SwFormatLayoutSplit& rTabSplit = pFormat->GetLayoutSplit();
1409  if ( !rTabSplit.GetValue() )
1410  {
1411  rSet.DisableItem( nSlot );
1412  }
1413  else
1414  {
1415  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
1416  if(pSplit)
1417  rSet.Put(std::move(pSplit));
1418  else
1419  rSet.InvalidateItem( nSlot );
1420  }
1421  break;
1422  }
1424  if(0 != rSh.GetRowsToRepeat())
1425  rSet.Put(SfxBoolItem(nSlot, true));
1426  else if(!rSh.GetRowSelectionFromTop())
1427  rSet.DisableItem( nSlot );
1428  else
1429  rSet.Put(SfxBoolItem(nSlot, false));
1430  break;
1431  case FN_TABLE_SELECT_CELL :
1432  if(rSh.HasBoxSelection())
1433  rSet.DisableItem( nSlot );
1434  break;
1436  {
1438  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1439  if (pHeight)
1440  {
1441  tools::Long nHeight = pHeight->GetHeight();
1442  aRowHeight.SetValue(nHeight);
1443  rSet.Put(aRowHeight);
1444 
1446  {
1447  // TODO: set correct unit
1448  MapUnit eTargetUnit = MapUnit::MapInch;
1449  OUString sHeight = GetMetricText(nHeight,
1450  MapUnit::MapTwip, eTargetUnit, nullptr);
1451 
1452  OUString sPayload = ".uno:TableRowHeight=" + sHeight;
1453 
1454  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1455  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1456  }
1457  }
1458  break;
1459  }
1461  {
1463  SwTableFUNC aFunc( &rSh );
1464  aFunc.InitTabCols();
1465  SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum());
1466  aColumnWidth.SetValue(nWidth);
1467  rSet.Put(aColumnWidth);
1468 
1470  {
1471  // TODO: set correct unit
1472  MapUnit eTargetUnit = MapUnit::MapInch;
1473  OUString sWidth = GetMetricText(nWidth,
1474  MapUnit::MapTwip, eTargetUnit, nullptr);
1475 
1476  OUString sPayload = ".uno:TableColumWidth=" + sWidth;
1477 
1478  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1479  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1480  }
1481 
1482  break;
1483  }
1484  }
1485  nSlot = aIter.NextWhich();
1486  }
1487 }
1488 
1490  SwBaseShell(_rView)
1491 {
1492  SetName("Table");
1494 }
1495 
1497 {
1498  SfxItemSet aCoreSet( GetPool(),
1500  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER> );
1501  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1502  aCoreSet.Put( aBoxInfo );
1503  GetShell().GetTabBorders( aCoreSet );
1504  rSet.Put( aCoreSet );
1505 }
1506 
1508 {
1509  SwWrtShell &rSh = GetShell();
1510  const SfxItemSet *pArgs = rReq.GetArgs();
1511  if(!pArgs)
1512  return;
1513 
1514  switch ( rReq.GetSlot() )
1515  {
1516  case SID_FRAME_LINESTYLE:
1517  case SID_FRAME_LINECOLOR:
1518  if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1519  {
1520  const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE );
1521  const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1522  rSh.SetTabLineStyle( nullptr, true, pBorderLine);
1523  }
1524  else
1525  {
1526  const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR );
1527  rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1528  }
1529 
1530  rReq.Done();
1531 
1532  break;
1533  }
1534 }
1535 
1537 {
1538  SfxItemSet aCoreSet( GetPool(),
1540  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
1541  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1542  aCoreSet.Put(aCoreInfo);
1543  GetShell().GetTabBorders( aCoreSet );
1544 
1545  const SvxBoxItem& rBoxItem = aCoreSet.Get( RES_BOX );
1546  const SvxBorderLine* pLine = rBoxItem.GetTop();
1547 
1548  rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1549  SvxLineItem aLine( SID_FRAME_LINESTYLE );
1550  aLine.SetLine(pLine);
1551  rSet.Put( aLine );
1552 }
1553 
1555 {
1556  const SfxItemSet* pArgs = rReq.GetArgs();
1557  SwWrtShell &rSh = GetShell();
1558 
1559  // At first the slots, which doesn't need a FrameMgr.
1560  const SfxPoolItem* pItem = nullptr;
1561  const sal_uInt16 nSlot = rReq.GetSlot();
1562  if(pArgs)
1563  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
1564 
1565  // Always acquire the language from the current cursor position.
1566  LanguageType eLang = rSh.GetCurLang();
1567  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1568  sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1569  SvNumFormatType nFormatType = SvNumFormatType::ALL;
1570  sal_uInt16 nOffset = 0;
1571 
1572  switch ( nSlot )
1573  {
1574  case FN_NUMBER_FORMAT:
1575  if( pItem )
1576  {
1577  // Determine index for string.
1578  OUString aCode( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1579  nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1580  if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1581  {
1582  // Re-enter
1583  sal_Int32 nErrPos;
1585  if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1586  nNumberFormat, eLang ))
1587  nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1588  }
1589  }
1590  break;
1591  case FN_NUMBER_STANDARD: nFormatType = SvNumFormatType::NUMBER; break;
1592  case FN_NUMBER_SCIENTIFIC: nFormatType = SvNumFormatType::SCIENTIFIC; break;
1593  case FN_NUMBER_DATE: nFormatType = SvNumFormatType::DATE; break;
1594  case FN_NUMBER_TIME: nFormatType = SvNumFormatType::TIME; break;
1595  case FN_NUMBER_CURRENCY: nFormatType = SvNumFormatType::CURRENCY; break;
1596  case FN_NUMBER_PERCENT: nFormatType = SvNumFormatType::PERCENT; break;
1597 
1598  case FN_NUMBER_TWODEC: // #.##0,00
1599  nFormatType = SvNumFormatType::NUMBER;
1600  nOffset = NF_NUMBER_1000DEC2;
1601  break;
1602 
1603  default:
1604  OSL_FAIL("wrong dispatcher");
1605  return;
1606  }
1607 
1608  if( nFormatType != SvNumFormatType::ALL )
1609  nNumberFormat = pFormatter->GetStandardFormat( nFormatType, eLang ) + nOffset;
1610 
1611  if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1612  {
1613  SfxItemSet aBoxSet( GetPool(), svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_FORMAT> );
1614  aBoxSet.Put( SwTableBoxNumFormat( nNumberFormat ));
1615  rSh.SetTableBoxFormulaAttrs( aBoxSet );
1616  }
1617 
1618 }
1619 
1620 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool GetValue() const
#define FN_TABLE_INSERT_COL_DLG
Definition: cmdid.h:388
#define FN_TABLE_SET_READ_ONLY_CELLS
Definition: cmdid.h:363
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
SwMoveFnCollection const & fnTableEnd
Definition: paminit.cxx:53
#define FN_TABLE_INSERT_COL_BEFORE
Definition: cmdid.h:358
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, FN_PARAM_TABLE_SPACE, FN_PARAM_TABLE_SPACE >)
constexpr SwTwips MIN_BORDER_DIST
Definition: swtypes.hxx:71
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
#define FN_TABLE_OPTIMAL_HEIGHT
Definition: cmdid.h:371
#define FN_TABLE_SET_COL_WIDTH
Definition: cmdid.h:354
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:495
SwView & GetView()
Definition: basesh.hxx:59
#define SFX_IMPL_INTERFACE(Class, SuperClass)
static SfxInterface * GetStaticInterface()
void SetDefDist(sal_uInt16 nNew)
SwTwips GetLeftSpace() const
Definition: swtablerep.hxx:60
static std::shared_ptr< std::vector< std::unique_ptr< SwPaM > > > CopyPaMRing(SwPaM &rOrig)
Definition: basesh.cxx:3129
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
SwView * GetActiveView()
Definition: swmodul1.cxx:116
void SetRowSplit(const SwFormatRowSplit &rSz)
Definition: fetab.cxx:733
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:832
SwUndoId
Definition: swundo.hxx:29
std::string GetValue
void SetRowBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:770
#define FN_TABLE_SPLIT_TABLE
Definition: cmdid.h:462
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
#define SID_ATTR_TABLE_COLUMN_WIDTH
Definition: cmdid.h:430
virtual VclPtr< VclAbstractDialog > CreateTableMergeDialog(weld::Window *pParent, bool &rWithPrev)=0
virtual SfxPoolItem * Clone(SfxItemPool *pPool=nullptr) const =0
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
bool IsTableMode() const
Definition: crsrsh.hxx:642
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:930
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:372
void InsertCol(sal_uInt16 nCnt, bool bBehind)
Definition: fetab.cxx:212
SfxDispatcher * GetDispatcher()
SwWrtShell & GetShell()
Definition: basesh.cxx:2774
static SvxAbstractDialogFactory * Create()
#define FN_TABLE_INSERT_COL
Definition: cmdid.h:348
#define FN_TABLE_INSERT_ROW
Definition: cmdid.h:347
long Long
void SetTable(bool bNew)
#define MINLAY
Definition: swtypes.hxx:63
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:1752
constexpr sal_uInt16 RES_FRMATR_END(133)
void GetLineStyleState(SfxItemSet &rSet)
Definition: tabsh.cxx:1536
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:322
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:279
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:362
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
bool DeleteCol()
Definition: fetab.cxx:265
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:781
NF_NUMBER_1000DEC2
SwTwips GetRightSpace() const
Definition: swtablerep.hxx:63
void SetLine(const editeng::SvxBorderLine *pNew)
#define FN_EDIT_FORMULA
Definition: cmdid.h:77
#define FN_CALC_TABLE
Definition: cmdid.h:78
std::unique_ptr< SwFormatFrameSize > GetRowHeight() const
Pointer must be destroyed by caller != 0.
Definition: fetab.cxx:754
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
#define FN_NUMBER_FORMAT
Definition: cmdid.h:444
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
const editeng::SvxBorderLine * GetRight() const
void EndAllAction()
Definition: edws.cxx:97
SwTwips GetWidth() const
Definition: swtablerep.hxx:66
#define FN_TABLE_SELECT_ROW
Definition: cmdid.h:359
const std::vector< sal_uInt32 > & GetDelFormats() const
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:818
bool IsInRepeatedHeadline() const
Definition: fesh.hxx:719
void SetTabBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:851
Used by the UI to modify the document model.
Definition: wrtsh.hxx:93
#define FN_PARAM_TABLE_HEADLINE
Definition: cmdid.h:782
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
#define FN_TABLE_AUTOSUM
Definition: cmdid.h:432
void SelectTableRow()
Definition: select.cxx:835
bool IsTableVertical() const
Definition: fetab.cxx:2345
static void lcl_SetAttr(SwWrtShell &rSh, const SfxPoolItem &rItem)
Definition: tabsh.cxx:129
#define FN_NUMBER_BULLETS
Definition: cmdid.h:73
tools::Long ResetSelect(const Point *, bool)
Definition: select.cxx:333
static void lcl_TabGetMaxLineWidth(const SvxBorderLine *pBorderLine, SvxBorderLine &rBorderLine)
Definition: tabsh.cxx:439
const SwView & GetView() const
Definition: wrtsh.hxx:431
#define FN_GOTO_NEXT_CELL
Definition: cmdid.h:391
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
#define FN_TABLE_SELECT_ALL
Definition: cmdid.h:361
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:1137
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
#define FN_PARAM_INSERT_AFTER
Definition: cmdid.h:779
const OUString & GetName() const
Definition: format.hxx:115
int nCount
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
void ExecTableStyle(SfxRequest &rReq)
Definition: tabsh.cxx:1507
void Width(tools::Long nNew)
Definition: swrect.hxx:186
bool BalanceRowHeight(bool bTstOnly, const bool bOptimize=false)
Definition: fetab.cxx:759
void GetFrameBorderState(SfxItemSet &rSet)
Definition: tabsh.cxx:1496
void GetState(SfxItemSet &)
Definition: tabsh.cxx:1262
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:281
void InitTabCols()
Definition: tablemgr.cxx:154
#define FN_NUMBER_SCIENTIFIC
Definition: cmdid.h:447
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
#define FN_NUMBER_DATE
Definition: cmdid.h:448
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:446
void SelectTableCol()
Definition: select.cxx:844
void SetFormula(const OUString &rFormula)
Definition: inputwin.hxx:202
sal_uInt16 GetWidthPercent() const
Definition: swtablerep.hxx:69
SfxItemPool & GetPool() const
#define FN_NUMBER_PERCENT
Definition: cmdid.h:451
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:346
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:290
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
const editeng::SvxBorderLine * GetHori() const
#define FN_TABLE_INSERT_ROW_DLG
Definition: cmdid.h:389
void EndSelect()
Definition: select.cxx:425
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
bool IsMath() const
void SetTabBorders(const SfxItemSet &rSet)
Definition: fetab.cxx:783
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:806
#define FN_TABLE_MERGE_CELLS
Definition: cmdid.h:352
void SetTabCols(const SwTabCols &rNew, bool bCurRowOnly)
Definition: fetab.cxx:645
Style of a layout element.
Definition: frmfmt.hxx:59
SwTableShell(SwView &rView)
Definition: tabsh.cxx:1489
bool HasSelection() const
Definition: wrtsh.hxx:144
#define SW_MOD()
Definition: swmodule.hxx:256
bool HasBoxSelection() const
Is content of a table cell or at least a table cell completely selected?
Definition: fetab.cxx:889
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:766
int i
#define FN_INSERT_TABLE
Definition: cmdid.h:216
const SwPaM * GetTableCrs() const
Definition: crsrsh.hxx:898
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: fetab.cxx:1028
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:746
#define LANGUAGE_SYSTEM
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2240
virtual VclPtr< SvxAbstractInsRowColDlg > CreateSvxInsRowColDlg(weld::Window *pParent, bool bCol, const OString &rHelpId)=0
#define FN_TABLE_ADJUST_CELLS
Definition: cmdid.h:366
bool SelTableBox()
Definition: trvltbl.cxx:286
SfxBindings & GetBindings()
#define FN_NUMBER_CURRENCY
Definition: cmdid.h:450
virtual VclPtr< SfxAbstractDialog > CreateNumFormatDialog(weld::Widget *pParent, const SfxItemSet &rAttr)=0
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:354
const T * GetArg(sal_uInt16 nSlotId) const
tools::Long GetLeft() const
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:3538
OUString GetTableBoxText() const
Definition: edtab.cxx:420
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
NF_TEXT
SvNumFormatType
void SetBoxAlign(sal_uInt16 nOrient)
Definition: fetab.cxx:838
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2735
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
void GetTabCols(SwTabCols &rToFill) const
Info about columns and margins.
Definition: fetab.cxx:663
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:864
void DeleteEntry(sal_uInt32 nKey)
#define FN_TABLE_DELETE_COL
Definition: cmdid.h:350
sal_uInt16 GetRowSelectionFromTop() const
Definition: fetab.cxx:1081
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:463
void GetTableAttr(SfxItemSet &) const
Definition: fetab.cxx:2147
SfxViewShell * GetViewShell() const
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:259
virtual sal_uInt16 getInsertCount() const =0
tools::Long SwTwips
Definition: swtypes.hxx:52
SwDocShell * GetDocShell()
Definition: view.cxx:1127
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
#define FN_TABLE_INSERT_ROW_AFTER
Definition: cmdid.h:355
#define FN_GOTO_PREV_CELL
Definition: cmdid.h:392
#define SFX_OBJECTBAR_OBJECT
std::unique_ptr< SwFormatRowSplit > GetRowSplit() const
Definition: fetab.cxx:741
void UnProtectCells()
Refers to table selection.
Definition: fetab.cxx:950
SvNumberFormatter * GetNumberFormatter() const
SFX2_DLLPUBLIC OString GetCommand() const
#define FN_TABLE_MODE_FIX_PROP
Definition: cmdid.h:426
void StartAction()
Definition: crsrsh.cxx:227
bool MergeTable(bool bWithPrev)
Definition: edtab.cxx:458
#define FN_NUMBER_TIME
Definition: cmdid.h:449
void SetReturnValue(const SfxPoolItem &)
void Update(sal_uInt16 nId)
void InsertTable(SfxRequest &_rRequest)
Definition: basesh.cxx:2836
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:682
#define FN_TABLE_ROW_SPLIT
Definition: cmdid.h:475
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:417
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:476
#define FN_TABLE_BALANCE_ROWS
Definition: cmdid.h:418
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:345
#define GetWhich(nSlot)
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:682
void SetTableAttr(const SfxItemSet &)
Definition: fetab.cxx:2154
void SetWidthPercent(sal_uInt8 n)
Definition: fmtfsize.hxx:95
#define FN_TABLE_MERGE_TABLE
Definition: cmdid.h:474
sal_uInt16 GetCurColNum() const
Definition: tablemgr.cxx:319
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:364
#define FN_END_TABLE
Definition: cmdid.h:683
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:305
#define FN_TABLE_BOX_TEXTORIENTATION
Definition: cmdid.h:428
QPRO_FUNC_TYPE nType
#define FN_TABLE_SET_ROW_HEIGHT
Definition: cmdid.h:353
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
#define FN_TABLE_SELECT_COL
Definition: cmdid.h:360
#define DEF_LINE_WIDTH_5
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:801
bool GetRowBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:778
#define SID_ATTR_TABLE_ROW_HEIGHT
Definition: cmdid.h:429
void SetValue(sal_uInt32 nTheValue)
bool GetBoxDirection(std::unique_ptr< SvxFrameDirectionItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:830
#define FN_NUMBER_STANDARD
Definition: cmdid.h:445
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:846
sal_uInt16 GetRowsToRepeat() const
Definition: fetab.cxx:1019
#define FN_TABLE_INSERT_ROW_BEFORE
Definition: cmdid.h:357
bool IsInHeadline() const
Definition: fesh.hxx:720
#define FN_TABLE_MODE_VARIABLE
Definition: cmdid.h:427
#define FN_TABLE_SPLIT_CELLS
Definition: cmdid.h:351
TableChgMode
Definition: tblenum.hxx:46
bool IsAPI() const
bool IsAdjustCellWidthAllowed(bool bBalance=false) const
Not allowed if only empty cells are selected.
Definition: fetab.cxx:1151
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:992
void ExecNumberFormat(SfxRequest const &rReq)
Definition: tabsh.cxx:1554
#define FN_TABLE_MODE_FIX
Definition: cmdid.h:425
#define FN_TABLE_DELETE_ROW
Definition: cmdid.h:349
#define FN_PARAM_TABLE_SPACE
Definition: cmdid.h:783
#define FN_TABLE_HEADLINE_REPEAT
Definition: cmdid.h:365
#define FN_TABLE_SELECT_CELL
Definition: cmdid.h:373
void GetAutoSum(OUString &rFormula) const
Definition: fetab.cxx:2232
#define FN_OPTIMIZE_TABLE
Definition: cmdid.h:356
Frame is variable in Var-direction.
bool HasWholeTabSelection() const
Definition: fetab.cxx:871
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1432
void StartAllAction()
For all views of this document.
Definition: edws.cxx:86
void SetTabLineStyle(const Color *pColor, bool bSetLine=false, const editeng::SvxBorderLine *pBorderLine=nullptr)
Definition: fetab.cxx:791
#define FN_TABLE_SET_VERT_ALIGN
Definition: cmdid.h:424
void Ignore()
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:745
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:313
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:814
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:448
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:822
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:442
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:929