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/zforlist.hxx>
22 #include <svl/stritem.hxx>
23 #include <svl/whiter.hxx>
25 #include <editeng/lrspitem.hxx>
26 #include <editeng/ulspitem.hxx>
27 #include <editeng/brushitem.hxx>
28 #include <editeng/boxitem.hxx>
29 #include <editeng/shaditem.hxx>
30 #include <editeng/spltitem.hxx>
31 #include <editeng/keepitem.hxx>
32 #include <editeng/lineitem.hxx>
33 #include <editeng/colritem.hxx>
34 #include <editeng/frmdiritem.hxx>
35 #include <svx/numinf.hxx>
36 #include <svx/svddef.hxx>
37 #include <svx/svxdlg.hxx>
38 #include <sfx2/bindings.hxx>
39 #include <vcl/weld.hxx>
40 #include <sfx2/request.hxx>
41 #include <sfx2/dispatch.hxx>
42 #include <sfx2/objface.hxx>
43 #include <sfx2/viewfrm.hxx>
44 #include <vcl/EnumContext.hxx>
45 #include <o3tl/enumrange.hxx>
46 #include <comphelper/lok.hxx>
47 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
48 #include <editeng/itemtype.hxx>
49 #include <osl/diagnose.h>
50 
51 #include <fmtornt.hxx>
52 #include <fmtlsplt.hxx>
53 #include <fmtrowsplt.hxx>
54 #include <fmtfsize.hxx>
55 #include <swmodule.hxx>
56 #include <wrtsh.hxx>
57 #include <wview.hxx>
58 #include <frmatr.hxx>
59 #include <uitool.hxx>
60 #include <inputwin.hxx>
61 #include <uiitems.hxx>
62 #include <tabsh.hxx>
63 #include <swtablerep.hxx>
64 #include <tablemgr.hxx>
65 #include <cellatr.hxx>
66 #include <frmfmt.hxx>
67 #include <swundo.hxx>
68 #include <swtable.hxx>
69 #include <docsh.hxx>
70 #include <tblsel.hxx>
71 #include <viewopt.hxx>
72 
73 #include <strings.hrc>
74 #include <cmdid.h>
75 #include <unobaseclass.hxx>
76 
77 #define ShellClass_SwTableShell
78 #include <sfx2/msg.hxx>
79 #include <swslots.hxx>
80 
81 #include <swabstdlg.hxx>
82 
83 #include <memory>
84 
85 using ::editeng::SvxBorderLine;
86 using namespace ::com::sun::star;
87 
89 
90 void SwTableShell::InitInterface_Impl()
91 {
92  GetStaticInterface()->RegisterPopupMenu("table");
93  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Table_Toolbox);
94 }
95 
96 
97 const sal_uInt16 aUITableAttrRange[] =
98 {
107 // #i29550#
109 // <-- collapsing borders
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  0
123 };
124 
125 const sal_uInt16* SwuiGetUITableAttrRange()
126 {
127  return aUITableAttrRange;
128 }
129 
130 static void lcl_SetAttr( SwWrtShell &rSh, const SfxPoolItem &rItem )
131 {
132  SfxItemSet aSet( rSh.GetView().GetPool(), {{rItem.Which(), rItem.Which()}});
133  aSet.Put( rItem );
134  rSh.SetTableAttr( aSet );
135 }
136 
137 static std::shared_ptr<SwTableRep> lcl_TableParamToItemSet( SfxItemSet& rSet, SwWrtShell &rSh )
138 {
139  std::shared_ptr<SwTableRep> pRep;
140 
141  SwFrameFormat *pFormat = rSh.GetTableFormat();
142  SwTabCols aCols;
143  rSh.GetTabCols( aCols );
144 
145  //At first get the simple attributes.
146  rSet.Put( SfxStringItem( FN_PARAM_TABLE_NAME, pFormat->GetName()));
148  rSet.Put( pFormat->GetShadow() );
150  rSet.Put( pFormat->GetFrameDir() );
151 
152  SvxULSpaceItem aULSpace( pFormat->GetULSpace() );
153  rSet.Put( aULSpace );
154 
155  const sal_uInt16 nBackgroundDestination = rSh.GetViewOptions()->GetTableDest();
156  rSet.Put(SfxUInt16Item(SID_BACKGRND_DESTINATION, nBackgroundDestination ));
157  std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
158  if(rSh.GetRowBackground(aBrush))
159  {
160  aBrush->SetWhich(SID_ATTR_BRUSH_ROW);
161  rSet.Put( *aBrush );
162  }
163  else
164  rSet.InvalidateItem(SID_ATTR_BRUSH_ROW);
165  rSh.GetTabBackground(aBrush);
166  aBrush->SetWhich(SID_ATTR_BRUSH_TABLE);
167  rSet.Put( *aBrush );
168 
169  // text direction in boxes
170  std::unique_ptr<SvxFrameDirectionItem> aBoxDirection(std::make_unique<SvxFrameDirectionItem>(SvxFrameDirection::Environment, RES_FRAMEDIR));
171  if(rSh.GetBoxDirection( aBoxDirection ))
172  {
173  aBoxDirection->SetWhich(FN_TABLE_BOX_TEXTORIENTATION);
174  rSet.Put(*aBoxDirection);
175  }
176 
177  bool bSelectAll = rSh.StartsWithTable() && rSh.ExtendedSelectedAll();
178  bool bTableSel = rSh.IsTableMode() || bSelectAll;
179  if(!bTableSel)
180  {
181  rSh.StartAllAction();
182  rSh.Push();
184  }
185  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
186 
187  // Table variant: If multiple table cells are selected.
188  rSh.GetCursor(); //Thus GetCursorCnt() returns the right thing
189  aBoxInfo.SetTable ((rSh.IsTableMode() && rSh.GetCursorCnt() > 1) ||
190  !bTableSel);
191  // Always show distance field.
192  aBoxInfo.SetDist (true);
193  // Set minimum size in tables and paragraphs.
194  aBoxInfo.SetMinDist( !bTableSel || rSh.IsTableMode() ||
195  rSh.GetSelectionType() &
197  // Always set the default spacing.
198  aBoxInfo.SetDefDist (MIN_BORDER_DIST);
199  // Individual lines can have DontCare status only in tables.
200  aBoxInfo.SetValid( SvxBoxInfoItemValidFlags::DISABLE, !bTableSel || !rSh.IsTableMode() );
201 
202  rSet.Put(aBoxInfo);
203  rSh.GetTabBorders( rSet );
204 
205  //row split
206  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
207  if(pSplit)
208  rSet.Put(std::move(pSplit));
209 
210  if(!bTableSel)
211  {
212  rSh.ClearMark();
214  rSh.EndAllAction();
215  }
216 
217  SwTabCols aTabCols;
218  rSh.GetTabCols( aTabCols );
219 
220  // Pointer will be deleted after the dialogue execution.
221  pRep = std::make_shared<SwTableRep>(aTabCols);
222  pRep->SetSpace(aCols.GetRightMax());
223 
224  sal_uInt16 nPercent = 0;
225  auto nWidth = ::GetTableWidth(pFormat, aCols, &nPercent, &rSh );
226  // The table width is wrong for relative values.
227  if (nPercent)
228  nWidth = pRep->GetSpace() * nPercent / 100;
229  const sal_uInt16 nAlign = pFormat->GetHoriOrient().GetHoriOrient();
230  pRep->SetAlign(nAlign);
231  SvxLRSpaceItem aLRSpace( pFormat->GetLRSpace() );
232  SwTwips nLeft = aLRSpace.GetLeft();
233  SwTwips nRight = aLRSpace.GetRight();
234  SwTwips nDiff = pRep->GetSpace() - nRight - nLeft - nWidth;
235  if(nAlign != text::HoriOrientation::FULL && std::abs(nDiff) > 2)
236  {
237  SwTwips nLR = pRep->GetSpace() - nWidth;
238  switch ( nAlign )
239  {
240  case text::HoriOrientation::CENTER:
241  nLeft = nRight = nLR / 2;
242  break;
243  case text::HoriOrientation::LEFT:
244  nRight = nLR;
245  nLeft = 0;
246  break;
247  case text::HoriOrientation::RIGHT:
248  nLeft = nLR;
249  nRight = 0;
250  break;
251  case text::HoriOrientation::LEFT_AND_WIDTH:
252  nRight = nLR - nLeft;
253  break;
255  if(!nPercent)
256  nWidth = pRep->GetSpace() - nLeft - nRight;
257  break;
258  }
259  }
260  pRep->SetLeftSpace(nLeft);
261  pRep->SetRightSpace(nRight);
262 
263  pRep->SetWidth(nWidth);
264  pRep->SetWidthPercent(nPercent);
265  // Are individual rows / cells are selected, the column processing will be changed.
266  pRep->SetLineSelected(bTableSel && ! rSh.HasWholeTabSelection());
267  rSet.Put(SwPtrItem(FN_TABLE_REP, pRep.get()));
268  return pRep;
269 }
270 
271 void ItemSetToTableParam( const SfxItemSet& rSet,
272  SwWrtShell &rSh )
273 {
274  rSh.StartAllAction();
276  const SfxPoolItem* pItem = nullptr;
277 
278  if(SfxItemState::SET == rSet.GetItemState(SID_BACKGRND_DESTINATION, false, &pItem))
279  {
280  SwViewOption aUsrPref( *rSh.GetViewOptions() );
281  aUsrPref.SetTableDest(static_cast<sal_uInt8>(static_cast<const SfxUInt16Item*>(pItem)->GetValue()));
282  SW_MOD()->ApplyUsrPref(aUsrPref, &rSh.GetView());
283  }
284  bool bBorder = ( SfxItemState::SET == rSet.GetItemState( RES_BOX ) ||
285  SfxItemState::SET == rSet.GetItemState( SID_ATTR_BORDER_INNER ) );
286  pItem = nullptr;
287  bool bBackground = SfxItemState::SET == rSet.GetItemState( RES_BACKGROUND, false, &pItem );
288  const SfxPoolItem* pRowItem = nullptr, *pTableItem = nullptr;
289  bBackground |= SfxItemState::SET == rSet.GetItemState( SID_ATTR_BRUSH_ROW, false, &pRowItem );
290  bBackground |= SfxItemState::SET == rSet.GetItemState( SID_ATTR_BRUSH_TABLE, false, &pTableItem );
291  const SfxPoolItem* pSplit = nullptr;
292  bool bRowSplit = SfxItemState::SET == rSet.GetItemState( RES_ROW_SPLIT, false, &pSplit );
293  const SfxPoolItem* pBoxDirection = nullptr;
294  bool bBoxDirection = SfxItemState::SET == rSet.GetItemState( FN_TABLE_BOX_TEXTORIENTATION, false, &pBoxDirection );
295  if( bBackground || bBorder || bRowSplit || bBoxDirection)
296  {
297  // The border will be applied to the present selection.
298  // If there is no selection, the table will be completely selected.
299  // The background will always be applied to the current state.
300  bool bTableSel = rSh.IsTableMode();
301  rSh.StartAllAction();
302 
303  if(bBackground)
304  {
305  if(pItem)
306  rSh.SetBoxBackground( *static_cast<const SvxBrushItem*>(pItem) );
307  if(pRowItem)
308  {
309  std::unique_ptr<SvxBrushItem> aBrush(static_cast<SvxBrushItem*>(pRowItem->Clone()));
310  aBrush->SetWhich(RES_BACKGROUND);
311  rSh.SetRowBackground(*aBrush);
312  }
313  if(pTableItem)
314  {
315  std::unique_ptr<SvxBrushItem> aBrush(static_cast<SvxBrushItem*>(pTableItem->Clone()));
316  aBrush->SetWhich(RES_BACKGROUND);
317  rSh.SetTabBackground( *aBrush );
318  }
319  }
320 
321  if(bBoxDirection)
322  {
323  SvxFrameDirectionItem aDirection( SvxFrameDirection::Environment, RES_FRAMEDIR );
324  aDirection.SetValue(static_cast< const SvxFrameDirectionItem* >(pBoxDirection)->GetValue());
325  rSh.SetBoxDirection(aDirection);
326  }
327 
328  if(bBorder || bRowSplit)
329  {
330  rSh.Push();
331  if(!bTableSel)
332  {
334  }
335  if(bBorder)
336  rSh.SetTabBorders( rSet );
337 
338  if(bRowSplit)
339  {
340  rSh.SetRowSplit(*static_cast<const SwFormatRowSplit*>(pSplit));
341  }
342 
343  if(!bTableSel)
344  {
345  rSh.ClearMark();
346  }
348  }
349 
350  rSh.EndAllAction();
351  }
352 
353  SwTabCols aTabCols;
354  bool bTabCols = false;
355  SwTableRep* pRep = nullptr;
356  SwFrameFormat *pFormat = rSh.GetTableFormat();
358  if(SfxItemState::SET == rSet.GetItemState( FN_TABLE_REP, false, &pItem ))
359  {
360  pRep = static_cast<SwTableRep*>(static_cast<const SwPtrItem*>(pItem)->GetValue());
361 
362  const SwTwips nWidth = pRep->GetWidth();
363  if ( text::HoriOrientation::FULL == pRep->GetAlign() )
364  {
365  SwFormatHoriOrient aAttr( pFormat->GetHoriOrient() );
366  aAttr.SetHoriOrient( text::HoriOrientation::FULL );
367  aSet.Put( aAttr );
368  }
369  else
370  {
372  if(pRep->GetWidthPercent())
373  {
374  aSz.SetWidthPercent( static_cast<sal_uInt8>(pRep->GetWidthPercent()) );
375  }
376  aSet.Put(aSz);
377  }
378 
379  SvxLRSpaceItem aLRSpace( RES_LR_SPACE );
380  aLRSpace.SetLeft(pRep->GetLeftSpace());
381  aLRSpace.SetRight(pRep->GetRightSpace());
382  aSet.Put( aLRSpace );
383 
384  sal_Int16 eOrient = pRep->GetAlign();
385  SwFormatHoriOrient aAttr( 0, eOrient );
386  aSet.Put( aAttr );
387  // The item must only be recorded while manual alignment, so that the
388  // alignment is not overwritten by the distances while recording.
389  if(eOrient != text::HoriOrientation::NONE)
390  const_cast<SfxItemSet&>(rSet).ClearItem( SID_ATTR_LRSPACE );
391 
392  if(pRep->HasColsChanged())
393  {
394  bTabCols = true;
395  }
396  }
397 
398  if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_HEADLINE, false, &pItem))
399  rSh.SetRowsToRepeat( static_cast<const SfxUInt16Item*>(pItem)->GetValue() );
400 
401  if( SfxItemState::SET == rSet.GetItemState( FN_TABLE_SET_VERT_ALIGN, false, &pItem))
402  rSh.SetBoxAlign(static_cast<const SfxUInt16Item*>(pItem)->GetValue());
403 
404  if( SfxItemState::SET == rSet.GetItemState( FN_PARAM_TABLE_NAME, false, &pItem ))
405  rSh.SetTableName( *pFormat, static_cast<const SfxStringItem*>(pItem)->GetValue() );
406 
407  // Copy the chosen attributes in the ItemSet.
408  static const sal_uInt16 aIds[] =
409  {
410  RES_PAGEDESC,
411  RES_BREAK,
412  RES_KEEP,
414  RES_UL_SPACE,
415  RES_SHADOW,
416  RES_FRAMEDIR,
417  // #i29550#
419  // <-- collapsing borders
420  0
421  };
422  for( const sal_uInt16* pIds = aIds; *pIds; ++pIds )
423  if( SfxItemState::SET == rSet.GetItemState( *pIds, false, &pItem))
424  aSet.Put( *pItem );
425 
426  if(bTabCols)
427  {
428  rSh.GetTabCols( aTabCols );
429  bool bSingleLine = pRep->FillTabCols( aTabCols );
430  rSh.SetTabCols( aTabCols, bSingleLine );
431  }
432 
433  if( aSet.Count() )
434  rSh.SetTableAttr( aSet );
435 
437  rSh.EndAllAction();
438 }
439 
440 static void lcl_TabGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine)
441 {
442  if(pBorderLine->GetWidth() > rBorderLine.GetWidth())
443  rBorderLine.SetWidth(pBorderLine->GetWidth());
444 
445  rBorderLine.SetBorderLineStyle(pBorderLine->GetBorderLineStyle());
446  rBorderLine.SetColor(pBorderLine->GetColor());
447 }
448 
450 {
451  const SfxItemSet* pArgs = rReq.GetArgs();
452  SwWrtShell &rSh = GetShell();
453 
454  // At first the slots which doesn't need a FrameMgr.
455  bool bMore = false;
456  const SfxPoolItem* pItem = nullptr;
457  sal_uInt16 nSlot = rReq.GetSlot();
458  if(pArgs)
459  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
460  bool bCallDone = false;
461  switch ( nSlot )
462  {
463  case SID_ATTR_BORDER:
464  {
465  if(!pArgs)
466  break;
467  // Create items, because we have to rework anyway.
468  std::shared_ptr<SvxBoxItem> aBox(std::make_shared<SvxBoxItem>(RES_BOX));
469  SfxItemSet aCoreSet( GetPool(),
471  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{});
472  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
473  aCoreSet.Put(aCoreInfo);
474  rSh.GetTabBorders( aCoreSet );
475  const SvxBoxItem& rCoreBox = aCoreSet.Get(RES_BOX);
476  const SfxPoolItem *pBoxItem = nullptr;
477  if ( pArgs->GetItemState(RES_BOX, true, &pBoxItem) == SfxItemState::SET )
478  {
479  aBox.reset(static_cast<SvxBoxItem*>(pBoxItem->Clone()));
480  sal_uInt16 nDefValue = MIN_BORDER_DIST;
481  if ( !rReq.IsAPI() )
482  nDefValue = 55;
483  if (!rReq.IsAPI() || aBox->GetSmallestDistance() < MIN_BORDER_DIST)
484  {
486  aBox->SetDistance( std::max(rCoreBox.GetDistance(k), nDefValue) , k );
487  }
488  }
489  else
490  OSL_ENSURE( false, "where is BoxItem?" );
491 
492  //since the drawing layer also supports borders the which id might be a different one
493  std::shared_ptr<SvxBoxInfoItem> aInfo(std::make_shared<SvxBoxInfoItem>(SID_ATTR_BORDER_INNER));
494  if (pArgs->GetItemState(SID_ATTR_BORDER_INNER, true, &pBoxItem) == SfxItemState::SET)
495  {
496  aInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxItem->Clone()));
497  }
498  else if( pArgs->GetItemState(SDRATTR_TABLE_BORDER_INNER, true, &pBoxItem) == SfxItemState::SET )
499  {
500  aInfo.reset(static_cast<SvxBoxInfoItem*>(pBoxItem->Clone()));
501  aInfo->SetWhich(SID_ATTR_BORDER_INNER);
502  }
503 
504  aInfo->SetTable( true );
505  aInfo->SetValid( SvxBoxInfoItemValidFlags::DISABLE, false );
506 
507 // The attributes of all lines will be read and the strongest wins.
508  const SvxBorderLine* pBorderLine;
509  SvxBorderLine aBorderLine;
510  if ((pBorderLine = rCoreBox.GetTop()) != nullptr)
511  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
512  if ((pBorderLine = rCoreBox.GetBottom()) != nullptr)
513  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
514  if ((pBorderLine = rCoreBox.GetLeft()) != nullptr)
515  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
516  if ((pBorderLine = rCoreBox.GetRight()) != nullptr)
517  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
518  if ((pBorderLine = aCoreInfo.GetHori()) != nullptr)
519  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
520  if ((pBorderLine = aCoreInfo.GetVert()) != nullptr)
521  lcl_TabGetMaxLineWidth(pBorderLine, aBorderLine);
522 
523  if(aBorderLine.GetOutWidth() == 0)
524  {
525  aBorderLine.SetBorderLineStyle(SvxBorderLineStyle::SOLID);
526  aBorderLine.SetWidth( DEF_LINE_WIDTH_5 );
527  }
528 
529  if( aBox->GetTop() != nullptr )
530  {
531  aBox->SetLine(&aBorderLine, SvxBoxItemLine::TOP);
532  }
533  if( aBox->GetBottom() != nullptr )
534  {
535  aBox->SetLine(&aBorderLine, SvxBoxItemLine::BOTTOM);
536  }
537  if( aBox->GetLeft() != nullptr )
538  {
539  aBox->SetLine(&aBorderLine, SvxBoxItemLine::LEFT);
540  }
541  if( aBox->GetRight() != nullptr )
542  {
543  aBox->SetLine(&aBorderLine, SvxBoxItemLine::RIGHT);
544  }
545  if( aInfo->GetHori() != nullptr )
546  {
547  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::HORI);
548  }
549  if( aInfo->GetVert() != nullptr )
550  {
551  aInfo->SetLine(&aBorderLine, SvxBoxInfoItemLine::VERT);
552  }
553 
554  aCoreSet.Put( *aBox );
555  aCoreSet.Put( *aInfo );
556  rSh.SetTabBorders( aCoreSet );
557 
558  // we must record the "real" values because otherwise the lines can't be reconstructed on playtime
559  // the coding style of the controller (setting lines with width 0) is not transportable via Query/PutValue in
560  // the SvxBoxItem
561  rReq.AppendItem( *aBox );
562  rReq.AppendItem( *aInfo );
563  bCallDone = true;
564  break;
565  }
566  case FN_INSERT_TABLE:
567  InsertTable( rReq );
568  break;
569  case FN_FORMAT_TABLE_DLG:
570  {
571  //#127012# get the bindings before the dialog is called
572  // it might happen that this shell is removed after closing the dialog
573  SfxBindings& rBindings = GetView().GetViewFrame()->GetBindings();
574  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
575 
576  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( &rSh.GetView()) != nullptr );
577  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
578  std::shared_ptr<SwTableRep> pTableRep(::lcl_TableParamToItemSet(aCoreSet, rSh));
579 
580  aCoreSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell())));
581  rSh.GetTableAttr(aCoreSet);
582  // GetTableAttr overwrites the background!
583  std::unique_ptr<SvxBrushItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
584  if(rSh.GetBoxBackground(aBrush))
585  aCoreSet.Put( *aBrush );
586  else
587  aCoreSet.InvalidateItem( RES_BACKGROUND );
588 
590  VclPtr<SfxAbstractTabDialog> pDlg(pFact->CreateSwTableTabDlg(GetView().GetFrameWeld(), &aCoreSet, &rSh));
591 
592  if (pDlg)
593  {
594  if (pItem)
595  pDlg->SetCurPageId(OUStringToOString(static_cast<const SfxStringItem *>(pItem)->GetValue(), RTL_TEXTENCODING_UTF8));
596 
597  auto pRequest = std::make_shared<SfxRequest>(rReq);
598  rReq.Ignore(); // the 'old' request is not relevant any more
599 
600  const bool bTableMode = rSh.IsTableMode();
601  SwPaM* pCursor = bTableMode ? rSh.GetTableCrs() : rSh.GetCursor(); // tdf#142165 use table cursor if in table mode
602  auto vCursors = CopyPaMRing(*pCursor); // tdf#135636 make a copy to use at later apply
603  pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, vCursors, bTableMode](sal_Int32 nResult){
604  if (RET_OK == nResult)
605  {
606  if (!bTableMode && rSh.IsTableMode()) // tdf#140977 drop current table-cursor if setting a replacement
607  rSh.TableCursorToCursor(); // non-table one
608 
609  // tdf#135636 set the selection at dialog launch as current selection
610  rSh.SetSelection(*vCursors->front()); // UpdateCursor() will be called which in the case
611  // of a table selection should recreate a
612  // SwShellTableCursor if the selection is more than a single cell
613 
614  if (bTableMode && !rSh.IsTableMode()) // tdf#142721 ensure the new selection is a SwShellTableCursor in
615  rSh.SelTableBox(); // the case of a single cell
616 
617  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
618 
619  //to record FN_INSERT_TABLE correctly
620  pRequest->SetSlot(FN_FORMAT_TABLE_DLG);
621  pRequest->Done(*pOutSet);
622 
623  ItemSetToTableParam(*pOutSet, rSh);
624  }
625 
626  rBindings.Update(SID_RULER_BORDERS);
627  rBindings.Update(SID_ATTR_TABSTOP);
628  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
629  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
630 
631  pDlg->disposeOnce();
632  });
633  }
634  else
635  {
636  if (rReq.GetArgs())
637  ItemSetToTableParam(*rReq.GetArgs(), rSh);
638 
639  rBindings.Update(SID_RULER_BORDERS);
640  rBindings.Update(SID_ATTR_TABSTOP);
641  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
642  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
643  }
644 
645  break;
646  }
647  case SID_ATTR_BRUSH:
648  case SID_ATTR_BRUSH_ROW :
649  case SID_ATTR_BRUSH_TABLE :
650  if(rReq.GetArgs())
651  ItemSetToTableParam(*rReq.GetArgs(), rSh);
652  break;
654  {
655  SwView* pView = GetActiveView();
656  if(pView)
657  {
658  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
659  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
660  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
661  SfxItemSet aCoreSet(
662  GetPool(),
663  svl::Items<
664  SID_ATTR_NUMBERFORMAT_VALUE,
665  SID_ATTR_NUMBERFORMAT_INFO>{});
666 
667  SfxItemSet aBoxSet( *aCoreSet.GetPool(),
669  RES_BOXATR_VALUE, RES_BOXATR_VALUE>{} );
670  rSh.GetTableBoxFormulaAttrs( aBoxSet );
671 
672  SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
673  if(eState == SfxItemState::DEFAULT)
674  {
675  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
676  pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
677  }
678  else
679  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
680  aBoxSet.Get(
681  RES_BOXATR_FORMAT ).GetValue() ));
682 
683  OUString sCurText( rSh.GetTableBoxText() );
684  aCoreSet.Put( SvxNumberInfoItem( pFormatter,
685  aBoxSet.Get(
686  RES_BOXATR_VALUE).GetValue(),
687  sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
688 
691 
692  if (RET_OK == pDlg->Execute())
693  {
694  const SvxNumberInfoItem* pNumberFormatItem
695  = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
696 
697  if( pNumberFormatItem )
698  {
699  for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
700  pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
701  }
702 
703  const SfxPoolItem* pNumberFormatValueItem = nullptr;
704  if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(
705  SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatValueItem ))
706  {
707  SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
709  aBoxFormatSet.Put( SwTableBoxNumFormat(
710  static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
711  rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
712 
713  }
714  }
715  }
716  break;
717  }
718  case FN_CALC_TABLE:
719  rSh.UpdateTable();
720  bCallDone = true;
721  break;
722  case FN_TABLE_DELETE_COL:
723  if ( rSh.DeleteCol() && rSh.HasSelection() )
724  rSh.EnterStdMode();
725  bCallDone = true;
726  break;
727  case FN_END_TABLE:
729  bCallDone = true;
730  break;
731  case FN_START_TABLE:
733  bCallDone = true;
734  break;
735  case FN_GOTO_NEXT_CELL:
736  {
737  bool bAppendLine = true;
738  if( pItem )
739  bAppendLine = static_cast<const SfxBoolItem*>(pItem)->GetValue();
740  rReq.SetReturnValue( SfxBoolItem( nSlot,
741  rSh.GoNextCell( bAppendLine ) ) );
742  bCallDone = true;
743  break;
744  }
745  case FN_GOTO_PREV_CELL:
746  rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
747  bCallDone = true;
748  break;
749  case FN_TABLE_DELETE_ROW:
750  if ( rSh.DeleteRow() && rSh.HasSelection() )
751  rSh.EnterStdMode();
752  bCallDone = true;
753  break;
755  if ( rSh.IsTableMode() )
756  switch ( rSh.MergeTab() )
757  {
758  case TableMergeErr::Ok:
759  bCallDone = true;
760  [[fallthrough]];
762  break;
764  {
765  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
766  VclMessageType::Info, VclButtonsType::Ok,
767  SwResId(STR_ERR_TABLE_MERGE)));
768  xInfoBox->run();
769  break;
770  }
771  default:
772  OSL_ENSURE( false, "unknown return value MergeTab.");
773  break;
774  }
775  break;
776  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
779  {
780  bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
781  const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot;
782  if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
783  {
784  {
785  // remove actions to make a valid table selection
786  UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
787  }
788  rSh.AdjustCellWidth(bBalance, bNoShrink);
789  }
790  bCallDone = true;
791  break;
792  }
793  case SID_TABLE_MINIMAL_ROW_HEIGHT:
794  {
795  const SwFormatFrameSize aSz;
796  rSh.SetRowHeight( aSz );
797  bCallDone = true;
798  break;
799  }
801  {
802  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
803  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
804  bCallDone = true;
805  break;
806  }
808  if ( rSh.BalanceRowHeight(true) )
809  rSh.BalanceRowHeight(false);
810  bCallDone = true;
811  break;
812  case FN_TABLE_SELECT_ALL:
813  rSh.EnterStdMode();
815  rSh.SttSelect();
817  rSh.EndSelect();
818  bCallDone = true;
819  break;
820  case FN_TABLE_SELECT_COL:
821  rSh.EnterStdMode();
822  rSh.SelectTableCol();
823  bCallDone = true;
824  break;
825  case FN_TABLE_SELECT_ROW:
826  rSh.EnterStdMode();
827  rSh.SelectTableRow();
828  bCallDone = true;
829  break;
831  rSh.ProtectCells();
832  rSh.ResetSelect( nullptr, false );
833  bCallDone = true;
834  break;
836  rSh.UnProtectCells();
837  bCallDone = true;
838  break;
839  case SID_AUTOFORMAT:
840  {
843  pDlg->Execute();
844  break;
845  }
847  {
850  pDlg->Execute();
851  break;
852  }
853  case FN_NUMBER_BULLETS:
854  case FN_NUM_BULLET_ON:
855  OSL_ENSURE( false, "function may not be called now." );
856  break;
857 
858 
859  // 2015/06 The following two are deprecated but kept for ascending
860  // compatibility
861  case FN_TABLE_INSERT_COL:
862  case FN_TABLE_INSERT_ROW:
863  // fallback
868  {
869  bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
871  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
872  sal_uInt16 nCount = 0;
873  bool bAfter = true;
874  if (pItem)
875  {
876  nCount = static_cast<const SfxInt16Item* >(pItem)->GetValue();
877  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, true, &pItem))
878  bAfter = static_cast<const SfxBoolItem* >(pItem)->GetValue();
879  }
880  else if( !rReq.IsAPI() )
881  {
882  SwSelBoxes aBoxes;
883  ::GetTableSel( rSh, aBoxes );
884  if ( !aBoxes.empty() )
885  {
886  tools::Long maxX = 0;
887  tools::Long maxY = 0;
888  tools::Long minX = std::numeric_limits<tools::Long>::max();
889  tools::Long minY = std::numeric_limits<tools::Long>::max();
890  tools::Long nbBoxes = aBoxes.size();
891  for ( tools::Long i = 0; i < nbBoxes; i++ )
892  {
893  Point aCoord ( aBoxes[i]->GetCoordinates() );
894  if ( aCoord.X() < minX ) minX = aCoord.X();
895  if ( aCoord.X() > maxX ) maxX = aCoord.X();
896  if ( aCoord.Y() < minY ) minY = aCoord.Y();
897  if ( aCoord.Y() > maxY ) maxY = aCoord.Y();
898  }
899  if (bColumn)
900  nCount = maxX - minX + 1;
901  else
902  nCount = maxY - minY + 1;
903  }
904  bAfter = rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
906  || rReq.GetSlot() == FN_TABLE_INSERT_ROW
907  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
908  }
909 
910  if( nCount )
911  {
912  // i74180: Table border patch submitted by chensuchun:
913  // -->get the SvxBoxInfoItem of the table before insert
914  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
915  ::lcl_TableParamToItemSet( aCoreSet, rSh );
916  bool bSetInnerBorders = false;
917  SwUndoId nUndoId = SwUndoId::EMPTY;
918  // <--End
919 
920  if( bColumn )
921  {
923  rSh.InsertCol( nCount, bAfter );
924  bSetInnerBorders = true;
925  nUndoId = SwUndoId::TABLE_INSCOL;
926  }
927  else if ( !rSh.IsInRepeatedHeadline() )
928  {
930  rSh.InsertRow( nCount, bAfter );
931  bSetInnerBorders = true;
932  nUndoId = SwUndoId::TABLE_INSROW;
933  }
934 
935  // -->after inserting,reset the inner table borders
936  if ( bSetInnerBorders )
937  {
938  const SvxBoxInfoItem& aBoxInfo(aCoreSet.Get(SID_ATTR_BORDER_INNER));
939  SfxItemSet aSet( GetPool(), svl::Items<SID_ATTR_BORDER_INNER,
940  SID_ATTR_BORDER_INNER>{});
941  aSet.Put( aBoxInfo );
942  ItemSetToTableParam( aSet, rSh );
943  rSh.EndUndo( nUndoId );
944  }
945 
946  bCallDone = true;
947  break;
948  }
949 
951 
952  [[fallthrough]]; // on Count = 0 appears the dialog
953  }
956  {
957  const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
958  if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
959  {
962  nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
963  if( pDlg->Execute() == 1 )
964  {
965  const sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
967  SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
969  SfxViewFrame* pVFrame = GetView().GetViewFrame();
970  if( pVFrame )
971  pVFrame->GetDispatcher()->ExecuteList(nDispatchSlot,
972  SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
973  { &aCountItem, &aAfter });
974  }
975  }
976  break;
977  }
979  {
981  bool bHorizontal=true;
982  bool bProportional = false;
983  const SfxInt32Item* pSplit = rReq.GetArg<SfxInt32Item>(FN_TABLE_SPLIT_CELLS);
984  const SfxBoolItem* pHor = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
985  const SfxBoolItem* pProp = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
986  if ( pSplit )
987  {
988  nCount = pSplit->GetValue();
989  if ( pHor )
990  bHorizontal = pHor->GetValue();
991  if ( pProp )
992  bProportional = pProp->GetValue();
993  }
994  else
995  {
997  SwWrtShell* pSh = &rSh;
998  const tools::Long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
1000  if(rSh.IsSplitVerticalByDefault())
1001  pDlg->SetSplitVerticalByDefault();
1002  pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
1003  if (nResult == RET_OK)
1004  {
1005  tools::Long nCount2 = pDlg->GetCount();
1006  bool bHorizontal2 = pDlg->IsHorizontal();
1007  bool bProportional2 = pDlg->IsProportional();
1008 
1009  // tdf#60242: remember choice for next time
1010  bool bVerticalWasChecked = !pDlg->IsHorizontal();
1011  pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
1012 
1013  if ( nCount2 > 1 )
1014  pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
1015  }
1016 
1017  pDlg->disposeOnce();
1018  });
1019  }
1020 
1021  if ( nCount>1 )
1022  {
1023  rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1024  bCallDone = true;
1025  }
1026  else
1027  rReq.Ignore();
1028  break;
1029  }
1030 
1031  case FN_TABLE_SPLIT_TABLE:
1032  {
1033  const SfxUInt16Item* pType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1034  if( pType )
1035  {
1036  switch( static_cast<SplitTable_HeadlineOption>(pType->GetValue()) )
1037  {
1043  rSh.SplitTable(static_cast<SplitTable_HeadlineOption>(pType->GetValue())) ;
1044  break;
1045  default: ;//wrong parameter, do nothing
1046  }
1047  }
1048  else
1049  {
1052  pDlg->Execute();
1053  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(pDlg->GetSplitMode()) ) );
1054  bCallDone = true;
1055  }
1056  break;
1057  }
1058 
1059  case FN_TABLE_MERGE_TABLE:
1060  {
1061  bool bPrev = rSh.CanMergeTable();
1062  bool bNext = rSh.CanMergeTable( false );
1063 
1064  if( bPrev && bNext )
1065  {
1068  if( RET_OK != pDlg->Execute())
1069  bPrev = bNext = false;
1070  }
1071 
1072  if( bPrev || bNext )
1073  rSh.MergeTable( bPrev );
1074  break;
1075  }
1076 
1077  case FN_TABLE_MODE_FIX :
1078  case FN_TABLE_MODE_FIX_PROP :
1079  case FN_TABLE_MODE_VARIABLE :
1080  {
1081  rSh.SetTableChgMode( FN_TABLE_MODE_FIX == nSlot
1083  : FN_TABLE_MODE_FIX_PROP == nSlot
1086 
1087  SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1088  static sal_uInt16 aInva[] =
1092  0
1093  };
1094  rBind.Invalidate( aInva );
1095  bCallDone = true;
1096  break;
1097  }
1098  case FN_TABLE_AUTOSUM:
1099  {
1100  SfxViewFrame* pVFrame = GetView().GetViewFrame();
1101  pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::SYNCHRON);
1102  const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1103  SwInputChild* pChildWin = static_cast<SwInputChild*>(pVFrame->
1104  GetChildWindow( nId ));
1105  OUString sSum;
1106  GetShell().GetAutoSum(sSum);
1107  if( pChildWin )
1108  pChildWin->SetFormula( sSum );
1109 
1110  break;
1111  }
1113  if(0 != rSh.GetRowsToRepeat())
1114  rSh.SetRowsToRepeat( 0 );
1115  else
1117  break;
1118  case FN_TABLE_SELECT_CELL :
1119  rSh.SelectTableCell();
1120  break;
1121  case FN_TABLE_DELETE_TABLE :
1122  {
1123  rSh.StartAction();
1124  rSh.StartUndo();
1126  rSh.DeleteTable();
1127  rSh.EndUndo();
1128  rSh.EndAction();
1129  //'this' is already destroyed
1130  return;
1131  }
1133  {
1135  if (pItem2)
1136  {
1137  tools::Long nNewHeight = pItem2->GetValue();
1138  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1139  if ( pHeight )
1140  {
1141  if (pHeight->GetHeightSizeType() == SwFrameSize::Variable)
1142  pHeight->SetHeightSizeType(SwFrameSize::Minimum);
1143  pHeight->SetHeight(nNewHeight);
1144  rSh.SetRowHeight(*pHeight);
1145  }
1146  }
1147  return;
1148  }
1150  {
1152  if (pItem2)
1153  {
1154  tools::Long nNewWidth = pItem2->GetValue();
1155  SwTableFUNC aFunc( &rSh );
1156  aFunc.InitTabCols();
1157  aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth);
1158  }
1159  return;
1160  }
1161  default:
1162  bMore = true;
1163  }
1164 
1165  if ( !bMore )
1166  {
1167  if(bCallDone)
1168  rReq.Done();
1169  return;
1170  }
1171 
1172  // Now the slots which are working directly on the TableFormat.
1173  switch ( nSlot )
1174  {
1175  case SID_ATTR_ULSPACE:
1176  if(pItem)
1177  {
1178  SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem*>(pItem) );
1179  aULSpace.SetWhich( RES_UL_SPACE );
1180  ::lcl_SetAttr( rSh, aULSpace );
1181  }
1182  break;
1183 
1184  case SID_ATTR_LRSPACE:
1185  if(pItem)
1186  {
1189  SvxLRSpaceItem aLRSpace( *static_cast<const SvxLRSpaceItem*>(pItem) );
1190  aLRSpace.SetWhich( RES_LR_SPACE );
1191  aSet.Put( aLRSpace );
1192  rSh.SetTableAttr( aSet );
1193  }
1194  break;
1195  // The last case branch which needs a table manager!!
1197  {
1198  SwTableFUNC aMgr( &rSh );
1199  aMgr.ColWidthDlg(GetView().GetFrameWeld());
1200  break;
1201  }
1202  case SID_TABLE_VERT_NONE:
1203  case SID_TABLE_VERT_CENTER:
1204  case SID_TABLE_VERT_BOTTOM:
1205  {
1206  const sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1208  nSlot == SID_TABLE_VERT_CENTER ?
1209  text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1210  rSh.SetBoxAlign(nAlign);
1211  bCallDone = true;
1212  break;
1213  }
1214 
1215  case SID_ATTR_PARA_SPLIT:
1216  if ( pItem )
1217  {
1218  SwFormatLayoutSplit aSplit( static_cast<const SvxFormatSplitItem*>(pItem)->GetValue());
1220  aSet.Put(aSplit);
1221  rSh.SetTableAttr(aSet);
1222  }
1223  break;
1224 
1225  case SID_ATTR_PARA_KEEP:
1226  if ( pItem )
1227  {
1228  SvxFormatKeepItem aKeep( *static_cast<const SvxFormatKeepItem*>(pItem) );
1229  aKeep.SetWhich( RES_KEEP );
1231  aSet.Put(aKeep);
1232  rSh.SetTableAttr(aSet);
1233  }
1234  break;
1235  case FN_TABLE_ROW_SPLIT :
1236  {
1237  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1238  std::unique_ptr<SwFormatRowSplit> pSplit;
1239  if(!pBool)
1240  {
1241  pSplit = rSh.GetRowSplit();
1242  if(pSplit)
1243  pSplit->SetValue(!pSplit->GetValue());
1244  else
1245  pSplit.reset(new SwFormatRowSplit(true));
1246  }
1247  else
1248  {
1249  pSplit.reset(new SwFormatRowSplit(pBool->GetValue()));
1250  }
1251  rSh.SetRowSplit( *pSplit );
1252  break;
1253  }
1254 
1255  default:
1256  OSL_ENSURE( false, "wrong Dispatcher" );
1257  return;
1258  }
1259  if(bCallDone)
1260  rReq.Done();
1261 }
1262 
1264 {
1265  SfxWhichIter aIter( rSet );
1266  SwWrtShell &rSh = GetShell();
1267  SwFrameFormat *pFormat = rSh.GetTableFormat();
1268  // os #124829# crash report: in case of an invalid shell selection return immediately
1269  if(!pFormat)
1270  return;
1271  sal_uInt16 nSlot = aIter.FirstWhich();
1272  while ( nSlot )
1273  {
1274  switch ( nSlot )
1275  {
1276  case FN_TABLE_MERGE_CELLS:
1277  if ( !rSh.IsTableMode() )
1279  break;
1280  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1281  case FN_TABLE_ADJUST_CELLS:
1282  if ( !rSh.IsAdjustCellWidthAllowed() )
1283  rSet.DisableItem(nSlot);
1284  break;
1285 
1287  if ( !rSh.IsAdjustCellWidthAllowed(true) )
1289  break;
1290 
1292  case FN_TABLE_BALANCE_ROWS:
1293  if ( !rSh.BalanceRowHeight(true) )
1294  rSet.DisableItem(nSlot);
1295  break;
1296  case FN_OPTIMIZE_TABLE:
1297  if ( !rSh.IsTableMode() &&
1298  !rSh.IsAdjustCellWidthAllowed() &&
1299  !rSh.IsAdjustCellWidthAllowed(true) &&
1300  !rSh.BalanceRowHeight(true) )
1302  break;
1303  case SID_INSERT_DIAGRAM:
1304  {
1305  SvtModuleOptions aMOpt;
1306  if ( !aMOpt.IsMath() || rSh.IsTableComplexForChart() )
1307  rSet.DisableItem(nSlot);
1308  }
1309  break;
1310 
1311  case FN_INSERT_TABLE:
1312  if ( rSh.CursorInsideInputField() )
1313  {
1314  rSet.DisableItem( nSlot );
1315  }
1316  break;
1317 
1318  case SID_TABLE_MINIMAL_ROW_HEIGHT:
1319  {
1320  // Disable if auto height already is enabled.
1321  std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight();
1322  if ( pSz )
1323  {
1324  if ( SwFrameSize::Variable == pSz->GetHeightSizeType() )
1325  rSet.DisableItem( nSlot );
1326  }
1327  break;
1328  }
1329  case FN_TABLE_INSERT_ROW:
1332  if ( rSh.IsInRepeatedHeadline() )
1333  rSet.DisableItem( nSlot );
1334  break;
1335  case RES_LR_SPACE:
1336  rSet.Put(pFormat->GetLRSpace());
1337  break;
1338  case RES_UL_SPACE:
1339  rSet.Put(pFormat->GetULSpace());
1340  break;
1341 
1342  case SID_TABLE_VERT_NONE:
1343  case SID_TABLE_VERT_CENTER:
1344  case SID_TABLE_VERT_BOTTOM:
1345  {
1346  const sal_uInt16 nAlign = rSh.GetBoxAlign();
1347  bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1348  (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1349  (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1350  rSet.Put(SfxBoolItem(nSlot, bSet));
1351  break;
1352  }
1353 
1354  case FN_TABLE_MODE_FIX :
1355  case FN_TABLE_MODE_FIX_PROP :
1356  case FN_TABLE_MODE_VARIABLE :
1357  {
1358  TableChgMode nMode = rSh.GetTableChgMode();
1359  bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TableChgMode::FixedWidthChangeAbs) ||
1362  rSet.Put(SfxBoolItem(nSlot, bSet));
1363  }
1364  break;
1365 
1366  case SID_ATTR_PARA_SPLIT:
1367  rSet.Put( pFormat->GetKeep() );
1368  break;
1369 
1370  case SID_ATTR_PARA_KEEP:
1371  rSet.Put( pFormat->GetLayoutSplit() );
1372  break;
1373  case FN_TABLE_SPLIT_TABLE:
1374  if ( rSh.IsInHeadline() )
1375  rSet.DisableItem( nSlot );
1376  break;
1377  case FN_TABLE_MERGE_TABLE:
1378  {
1379  bool bAsk;
1380  if( !rSh.CanMergeTable( true, &bAsk ))
1381  rSet.DisableItem( nSlot );
1382  break;
1383  }
1384 
1385  case FN_TABLE_DELETE_ROW:
1386  {
1387  SwSelBoxes aBoxes;
1388  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
1389  if( ::HasProtectedCells( aBoxes ))
1390  rSet.DisableItem( nSlot );
1391  }
1392  break;
1393  case FN_TABLE_DELETE_COL:
1394  {
1395  SwSelBoxes aBoxes;
1396  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
1397  if( ::HasProtectedCells( aBoxes ))
1398  rSet.DisableItem( nSlot );
1399  }
1400  break;
1401 
1403  // disable in readonly sections, but enable in protected cells
1404  if( !rSh.CanUnProtectCells() )
1405  rSet.DisableItem( nSlot );
1406  break;
1407  case RES_ROW_SPLIT:
1408  {
1409  const SwFormatLayoutSplit& rTabSplit = pFormat->GetLayoutSplit();
1410  if ( !rTabSplit.GetValue() )
1411  {
1412  rSet.DisableItem( nSlot );
1413  }
1414  else
1415  {
1416  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
1417  if(pSplit)
1418  rSet.Put(std::move(pSplit));
1419  else
1420  rSet.InvalidateItem( nSlot );
1421  }
1422  break;
1423  }
1425  if(0 != rSh.GetRowsToRepeat())
1426  rSet.Put(SfxBoolItem(nSlot, true));
1427  else if(!rSh.GetRowSelectionFromTop())
1428  rSet.DisableItem( nSlot );
1429  else
1430  rSet.Put(SfxBoolItem(nSlot, false));
1431  break;
1432  case FN_TABLE_SELECT_CELL :
1433  if(rSh.HasBoxSelection())
1434  rSet.DisableItem( nSlot );
1435  break;
1437  {
1439  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1440  if (pHeight)
1441  {
1442  tools::Long nHeight = pHeight->GetHeight();
1443  aRowHeight.SetValue(nHeight);
1444  rSet.Put(aRowHeight);
1445 
1447  {
1448  // TODO: set correct unit
1449  MapUnit eTargetUnit = MapUnit::MapInch;
1450  OUString sHeight = GetMetricText(nHeight,
1451  MapUnit::MapTwip, eTargetUnit, nullptr);
1452 
1453  OUString sPayload = ".uno:TableRowHeight=" + sHeight;
1454 
1455  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1456  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1457  }
1458  }
1459  break;
1460  }
1462  {
1464  SwTableFUNC aFunc( &rSh );
1465  aFunc.InitTabCols();
1466  SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum());
1467  aColumnWidth.SetValue(nWidth);
1468  rSet.Put(aColumnWidth);
1469 
1471  {
1472  // TODO: set correct unit
1473  MapUnit eTargetUnit = MapUnit::MapInch;
1474  OUString sWidth = GetMetricText(nWidth,
1475  MapUnit::MapTwip, eTargetUnit, nullptr);
1476 
1477  OUString sPayload = ".uno:TableColumWidth=" + sWidth;
1478 
1479  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1480  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1481  }
1482 
1483  break;
1484  }
1485  }
1486  nSlot = aIter.NextWhich();
1487  }
1488 }
1489 
1491  SwBaseShell(_rView)
1492 {
1493  SetName("Table");
1495 }
1496 
1498 {
1499  SfxItemSet aCoreSet( GetPool(),
1501  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{} );
1502  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1503  aCoreSet.Put( aBoxInfo );
1504  GetShell().GetTabBorders( aCoreSet );
1505  rSet.Put( aCoreSet );
1506 }
1507 
1509 {
1510  SwWrtShell &rSh = GetShell();
1511  const SfxItemSet *pArgs = rReq.GetArgs();
1512  if(!pArgs)
1513  return;
1514 
1515  switch ( rReq.GetSlot() )
1516  {
1517  case SID_FRAME_LINESTYLE:
1518  case SID_FRAME_LINECOLOR:
1519  if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1520  {
1521  const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE );
1522  const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1523  rSh.SetTabLineStyle( nullptr, true, pBorderLine);
1524  }
1525  else
1526  {
1527  const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR );
1528  rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1529  }
1530 
1531  rReq.Done();
1532 
1533  break;
1534  }
1535 }
1536 
1538 {
1539  SfxItemSet aCoreSet( GetPool(),
1541  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{});
1542  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1543  aCoreSet.Put(aCoreInfo);
1544  GetShell().GetTabBorders( aCoreSet );
1545 
1546  const SvxBoxItem& rBoxItem = aCoreSet.Get( RES_BOX );
1547  const SvxBorderLine* pLine = rBoxItem.GetTop();
1548 
1549  rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1550  SvxLineItem aLine( SID_FRAME_LINESTYLE );
1551  aLine.SetLine(pLine);
1552  rSet.Put( aLine );
1553 }
1554 
1556 {
1557  const SfxItemSet* pArgs = rReq.GetArgs();
1558  SwWrtShell &rSh = GetShell();
1559 
1560  // At first the slots, which doesn't need a FrameMgr.
1561  const SfxPoolItem* pItem = nullptr;
1562  const sal_uInt16 nSlot = rReq.GetSlot();
1563  if(pArgs)
1564  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
1565 
1566  // Always acquire the language from the current cursor position.
1567  LanguageType eLang = rSh.GetCurLang();
1568  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1569  sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1570  SvNumFormatType nFormatType = SvNumFormatType::ALL;
1571  sal_uInt16 nOffset = 0;
1572 
1573  switch ( nSlot )
1574  {
1575  case FN_NUMBER_FORMAT:
1576  if( pItem )
1577  {
1578  // Determine index for string.
1579  OUString aCode( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1580  nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1581  if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1582  {
1583  // Re-enter
1584  sal_Int32 nErrPos;
1586  if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1587  nNumberFormat, eLang ))
1588  nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1589  }
1590  }
1591  break;
1592  case FN_NUMBER_STANDARD: nFormatType = SvNumFormatType::NUMBER; break;
1593  case FN_NUMBER_SCIENTIFIC: nFormatType = SvNumFormatType::SCIENTIFIC; break;
1594  case FN_NUMBER_DATE: nFormatType = SvNumFormatType::DATE; break;
1595  case FN_NUMBER_TIME: nFormatType = SvNumFormatType::TIME; break;
1596  case FN_NUMBER_CURRENCY: nFormatType = SvNumFormatType::CURRENCY; break;
1597  case FN_NUMBER_PERCENT: nFormatType = SvNumFormatType::PERCENT; break;
1598 
1599  case FN_NUMBER_TWODEC: // #.##0,00
1600  nFormatType = SvNumFormatType::NUMBER;
1601  nOffset = NF_NUMBER_1000DEC2;
1602  break;
1603 
1604  default:
1605  OSL_FAIL("wrong dispatcher");
1606  return;
1607  }
1608 
1609  if( nFormatType != SvNumFormatType::ALL )
1610  nNumberFormat = pFormatter->GetStandardFormat( nFormatType, eLang ) + nOffset;
1611 
1612  if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1613  {
1615  aBoxSet.Put( SwTableBoxNumFormat( nNumberFormat ));
1616  rSh.SetTableBoxFormulaAttrs( aBoxSet );
1617  }
1618 
1619 }
1620 
1621 /* 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
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()
SwPaM * GetCursor(bool bMakeTableCursor=true) const
Return pointer to the current shell cursor.
Definition: crsrsh.cxx:194
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:3115
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
SwView * GetActiveView()
Definition: swmodul1.cxx:116
void SetRowSplit(const SwFormatRowSplit &rSz)
Definition: fetab.cxx:733
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: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:643
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:2760
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:66
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:1537
#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: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: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:779
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
#define MIN_BORDER_DIST
Definition: swtypes.hxx:74
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:813
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:780
#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:130
#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:440
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)
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:777
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:1508
void Width(tools::Long nNew)
Definition: swrect.hxx:187
bool BalanceRowHeight(bool bTstOnly, const bool bOptimize=false)
Definition: fetab.cxx:759
void GetFrameBorderState(SfxItemSet &rSet)
Definition: tabsh.cxx:1497
void GetState(SfxItemSet &)
Definition: tabsh.cxx:1263
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:137
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
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW)
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:345
constexpr TypedWhichId< SwFormatRowSplit > RES_ROW_SPLIT(122)
constexpr TypedWhichId< SvxBoxInfoItem > SDRATTR_TABLE_BORDER_INNER(SDRATTR_TABLE_FIRST+1)
void SetTableDest(sal_uInt8 nNew)
Definition: viewopt.hxx:573
const sal_uInt16 * SwuiGetUITableAttrRange()
Definition: tabsh.cxx:125
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:136
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) 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:606
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:58
SwTableShell(SwView &rView)
Definition: tabsh.cxx:1490
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:755
int i
#define FN_INSERT_TABLE
Definition: cmdid.h:216
const SwPaM * GetTableCrs() const
Definition: crsrsh.hxx:904
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)
constexpr sal_uInt16 XATTR_FILL_FIRST(XATTRSET_LINE+1)
virtual bool IsProportional() const =0
void SetSelection(const SwPaM &rCursor)
Definition: crsrsh.cxx:3540
OUString GetTableBoxText() const
Definition: edtab.cxx:419
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
void TableCursorToCursor()
enter block mode, change normal cursor into block cursor
Definition: crsrsh.cxx:895
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:258
virtual sal_uInt16 getInsertCount() const =0
tools::Long SwTwips
Definition: swtypes.hxx:49
SwDocShell * GetDocShell()
Definition: view.cxx:1122
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:226
bool MergeTable(bool bWithPrev)
Definition: edtab.cxx:457
#define FN_NUMBER_TIME
Definition: cmdid.h:449
void SetReturnValue(const SfxPoolItem &)
void Update(sal_uInt16 nId)
void InsertTable(SfxRequest &_rRequest)
Definition: basesh.cxx:2822
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:680
#define FN_TABLE_ROW_SPLIT
Definition: cmdid.h:475
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:475
#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:271
#define FN_TABLE_UNSET_READ_ONLY_CELLS
Definition: cmdid.h:364
#define FN_END_TABLE
Definition: cmdid.h:681
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:625
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: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:938
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
constexpr sal_uInt16 XATTR_FILL_LAST(XATTR_FILLBACKGROUND)
#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:1555
#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:781
const sal_uInt16 aUITableAttrRange[]
Definition: tabsh.cxx:97
#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
OUString SwResId(std::string_view aId)
Definition: swmodule.cxx:165
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:449
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:243
void SplitTable(SplitTable_HeadlineOption eMode)
Split table at cursor position.
Definition: edtab.cxx:441
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