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 
50 #include <fmtornt.hxx>
51 #include <fmtlsplt.hxx>
52 #include <fmtrowsplt.hxx>
53 #include <fmtfsize.hxx>
54 #include <swmodule.hxx>
55 #include <wrtsh.hxx>
56 #include <wview.hxx>
57 #include <frmatr.hxx>
58 #include <uitool.hxx>
59 #include <inputwin.hxx>
60 #include <uiitems.hxx>
61 #include <tabsh.hxx>
62 #include <swtablerep.hxx>
63 #include <tablemgr.hxx>
64 #include <cellatr.hxx>
65 #include <frmfmt.hxx>
66 #include <swundo.hxx>
67 #include <swtable.hxx>
68 #include <docsh.hxx>
69 #include <tblsel.hxx>
70 #include <viewopt.hxx>
71 
72 #include <strings.hrc>
73 #include <cmdid.h>
74 #include <unobaseclass.hxx>
75 
76 #define ShellClass_SwTableShell
77 #include <sfx2/msg.hxx>
78 #include <swslots.hxx>
79 
80 #include <swabstdlg.hxx>
81 
82 #include <memory>
83 
84 using ::editeng::SvxBorderLine;
85 using namespace ::com::sun::star;
86 
88 
89 void SwTableShell::InitInterface_Impl()
90 {
91  GetStaticInterface()->RegisterPopupMenu("table");
92  GetStaticInterface()->RegisterObjectBar(SFX_OBJECTBAR_OBJECT, SfxVisibilityFlags::Invisible, ToolbarId::Table_Toolbox);
93 }
94 
95 
96 const sal_uInt16 aUITableAttrRange[] =
97 {
103  SID_RULER_BORDERS, SID_RULER_BORDERS,
105  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_SHADOW,
108  SID_BACKGRND_DESTINATION, SID_BACKGRND_DESTINATION,
109  SID_HTML_MODE, SID_HTML_MODE,
110  SID_ATTR_BRUSH_ROW, SID_ATTR_BRUSH_TABLE,
118 // #i29550#
120 // <-- collapsing borders
121  0
122 };
123 
124 const sal_uInt16* SwuiGetUITableAttrRange()
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  auto xPaM(std::make_shared<SwPaM>(*rSh.GetCursor(), nullptr)); // tdf#135636 make a copy to use at later apply
600  pDlg->StartExecuteAsync([pDlg, pRequest, pTableRep, &rBindings, &rSh, xPaM](sal_Int32 nResult){
601  if (RET_OK == nResult)
602  {
603  rSh.SetSelection(*xPaM); // tdf#135636 set the table selected at dialog launch as current selection
604 
605  const SfxItemSet* pOutSet = pDlg->GetOutputItemSet();
606 
607  //to record FN_INSERT_TABLE correctly
608  pRequest->SetSlot(FN_FORMAT_TABLE_DLG);
609  pRequest->Done(*pOutSet);
610 
611  ItemSetToTableParam(*pOutSet, rSh);
612  }
613 
614  rBindings.Update(SID_RULER_BORDERS);
615  rBindings.Update(SID_ATTR_TABSTOP);
616  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
617  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
618 
619  pDlg->disposeOnce();
620  });
621  }
622  else
623  {
624  if (rReq.GetArgs())
625  ItemSetToTableParam(*rReq.GetArgs(), rSh);
626 
627  rBindings.Update(SID_RULER_BORDERS);
628  rBindings.Update(SID_ATTR_TABSTOP);
629  rBindings.Update(SID_RULER_BORDERS_VERTICAL);
630  rBindings.Update(SID_ATTR_TABSTOP_VERTICAL);
631  }
632 
633  break;
634  }
635  case SID_ATTR_BRUSH:
636  case SID_ATTR_BRUSH_ROW :
637  case SID_ATTR_BRUSH_TABLE :
638  if(rReq.GetArgs())
639  ItemSetToTableParam(*rReq.GetArgs(), rSh);
640  break;
642  {
643  SwView* pView = GetActiveView();
644  if(pView)
645  {
646  FieldUnit eMetric = ::GetDfltMetric(dynamic_cast<SwWebView*>( pView) != nullptr );
647  SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric)));
648  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
649  SfxItemSet aCoreSet(
650  GetPool(),
651  svl::Items<
652  SID_ATTR_NUMBERFORMAT_VALUE,
653  SID_ATTR_NUMBERFORMAT_INFO>{});
654 
655  SfxItemSet aBoxSet( *aCoreSet.GetPool(),
657  RES_BOXATR_VALUE, RES_BOXATR_VALUE>{} );
658  rSh.GetTableBoxFormulaAttrs( aBoxSet );
659 
660  SfxItemState eState = aBoxSet.GetItemState(RES_BOXATR_FORMAT);
661  if(eState == SfxItemState::DEFAULT)
662  {
663  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
664  pFormatter->GetFormatIndex(NF_TEXT, LANGUAGE_SYSTEM)));
665  }
666  else
667  aCoreSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE,
668  aBoxSet.Get(
669  RES_BOXATR_FORMAT ).GetValue() ));
670 
671  OUString sCurText( rSh.GetTableBoxText() );
672  aCoreSet.Put( SvxNumberInfoItem( pFormatter,
673  aBoxSet.Get(
674  RES_BOXATR_VALUE).GetValue(),
675  sCurText, SID_ATTR_NUMBERFORMAT_INFO ));
676 
679 
680  if (RET_OK == pDlg->Execute())
681  {
682  const SvxNumberInfoItem* pNumberFormatItem
683  = GetView().GetDocShell()->GetItem( SID_ATTR_NUMBERFORMAT_INFO );
684 
685  if( pNumberFormatItem )
686  {
687  for ( sal_uInt32 key : pNumberFormatItem->GetDelFormats() )
688  pNumberFormatItem->GetNumberFormatter()->DeleteEntry( key );
689  }
690 
691  const SfxPoolItem* pNumberFormatValueItem = nullptr;
692  if( SfxItemState::SET == pDlg->GetOutputItemSet()->GetItemState(
693  SID_ATTR_NUMBERFORMAT_VALUE, false, &pNumberFormatValueItem ))
694  {
695  SfxItemSet aBoxFormatSet( *aCoreSet.GetPool(),
697  aBoxFormatSet.Put( SwTableBoxNumFormat(
698  static_cast<const SfxUInt32Item*>(pNumberFormatValueItem)->GetValue() ));
699  rSh.SetTableBoxFormulaAttrs( aBoxFormatSet );
700 
701  }
702  }
703  }
704  break;
705  }
706  case FN_CALC_TABLE:
707  rSh.UpdateTable();
708  bCallDone = true;
709  break;
710  case FN_TABLE_DELETE_COL:
711  if ( rSh.DeleteCol() && rSh.HasSelection() )
712  rSh.EnterStdMode();
713  bCallDone = true;
714  break;
715  case FN_END_TABLE:
717  bCallDone = true;
718  break;
719  case FN_START_TABLE:
721  bCallDone = true;
722  break;
723  case FN_GOTO_NEXT_CELL:
724  {
725  bool bAppendLine = true;
726  if( pItem )
727  bAppendLine = static_cast<const SfxBoolItem*>(pItem)->GetValue();
728  rReq.SetReturnValue( SfxBoolItem( nSlot,
729  rSh.GoNextCell( bAppendLine ) ) );
730  bCallDone = true;
731  break;
732  }
733  case FN_GOTO_PREV_CELL:
734  rReq.SetReturnValue( SfxBoolItem( nSlot, rSh.GoPrevCell() ) );
735  bCallDone = true;
736  break;
737  case FN_TABLE_DELETE_ROW:
738  if ( rSh.DeleteRow() && rSh.HasSelection() )
739  rSh.EnterStdMode();
740  bCallDone = true;
741  break;
743  if ( rSh.IsTableMode() )
744  switch ( rSh.MergeTab() )
745  {
746  case TableMergeErr::Ok:
747  bCallDone = true;
748  [[fallthrough]];
750  break;
752  {
753  std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetView().GetFrameWeld(),
754  VclMessageType::Info, VclButtonsType::Ok,
755  SwResId(STR_ERR_TABLE_MERGE)));
756  xInfoBox->run();
757  break;
758  }
759  default:
760  OSL_ENSURE( false, "unknown return value MergeTab.");
761  break;
762  }
763  break;
764  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
767  {
768  bool bBalance = (FN_TABLE_BALANCE_CELLS == nSlot);
769  const bool bNoShrink = FN_TABLE_ADJUST_CELLS == nSlot;
770  if ( rSh.IsAdjustCellWidthAllowed(bBalance) )
771  {
772  {
773  // remove actions to make a valid table selection
774  UnoActionRemoveContext aRemoveContext(rSh.GetDoc());
775  }
776  rSh.AdjustCellWidth(bBalance, bNoShrink);
777  }
778  bCallDone = true;
779  break;
780  }
781  case SID_TABLE_MINIMAL_ROW_HEIGHT:
782  {
783  const SwFormatFrameSize aSz;
784  rSh.SetRowHeight( aSz );
785  bCallDone = true;
786  break;
787  }
789  {
790  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/true);
791  rSh.BalanceRowHeight(/*bTstOnly=*/false, /*bOptimize=*/false);
792  bCallDone = true;
793  break;
794  }
796  if ( rSh.BalanceRowHeight(true) )
797  rSh.BalanceRowHeight(false);
798  bCallDone = true;
799  break;
800  case FN_TABLE_SELECT_ALL:
801  rSh.EnterStdMode();
803  rSh.SttSelect();
805  rSh.EndSelect();
806  bCallDone = true;
807  break;
808  case FN_TABLE_SELECT_COL:
809  rSh.EnterStdMode();
810  rSh.SelectTableCol();
811  bCallDone = true;
812  break;
813  case FN_TABLE_SELECT_ROW:
814  rSh.EnterStdMode();
815  rSh.SelectTableRow();
816  bCallDone = true;
817  break;
819  rSh.ProtectCells();
820  rSh.ResetSelect( nullptr, false );
821  bCallDone = true;
822  break;
824  rSh.UnProtectCells();
825  bCallDone = true;
826  break;
827  case SID_AUTOFORMAT:
828  {
831  pDlg->Execute();
832  break;
833  }
835  {
838  pDlg->Execute();
839  break;
840  }
841  case FN_NUMBER_BULLETS:
842  case FN_NUM_BULLET_ON:
843  OSL_ENSURE( false, "function may not be called now." );
844  break;
845 
846 
847  // 2015/06 The following two are deprecated but kept for ascending
848  // compatibility
849  case FN_TABLE_INSERT_COL:
850  case FN_TABLE_INSERT_ROW:
851  // fallback
856  {
857  bool bColumn = rReq.GetSlot() == FN_TABLE_INSERT_COL_BEFORE
859  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
860  sal_uInt16 nCount = 0;
861  bool bAfter = true;
862  if (pItem)
863  {
864  nCount = static_cast<const SfxInt16Item* >(pItem)->GetValue();
865  if(SfxItemState::SET == pArgs->GetItemState(FN_PARAM_INSERT_AFTER, true, &pItem))
866  bAfter = static_cast<const SfxBoolItem* >(pItem)->GetValue();
867  }
868  else if( !rReq.IsAPI() )
869  {
870  SwSelBoxes aBoxes;
871  ::GetTableSel( rSh, aBoxes );
872  if ( !aBoxes.empty() )
873  {
874  tools::Long maxX = 0;
875  tools::Long maxY = 0;
876  tools::Long minX = std::numeric_limits<tools::Long>::max();
877  tools::Long minY = std::numeric_limits<tools::Long>::max();
878  tools::Long nbBoxes = aBoxes.size();
879  for ( tools::Long i = 0; i < nbBoxes; i++ )
880  {
881  Point aCoord ( aBoxes[i]->GetCoordinates() );
882  if ( aCoord.X() < minX ) minX = aCoord.X();
883  if ( aCoord.X() > maxX ) maxX = aCoord.X();
884  if ( aCoord.Y() < minY ) minY = aCoord.Y();
885  if ( aCoord.Y() > maxY ) maxY = aCoord.Y();
886  }
887  if (bColumn)
888  nCount = maxX - minX + 1;
889  else
890  nCount = maxY - minY + 1;
891  }
892  bAfter = rReq.GetSlot() == FN_TABLE_INSERT_COL_AFTER
894  || rReq.GetSlot() == FN_TABLE_INSERT_ROW
895  || rReq.GetSlot() == FN_TABLE_INSERT_COL;
896  }
897 
898  if( nCount )
899  {
900  // i74180: Table border patch submitted by chensuchun:
901  // -->get the SvxBoxInfoItem of the table before insert
902  SfxItemSet aCoreSet( GetPool(), aUITableAttrRange);
903  ::lcl_TableParamToItemSet( aCoreSet, rSh );
904  bool bSetInnerBorders = false;
905  SwUndoId nUndoId = SwUndoId::EMPTY;
906  // <--End
907 
908  if( bColumn )
909  {
911  rSh.InsertCol( nCount, bAfter );
912  bSetInnerBorders = true;
913  nUndoId = SwUndoId::TABLE_INSCOL;
914  }
915  else if ( !rSh.IsInRepeatedHeadline() )
916  {
918  rSh.InsertRow( nCount, bAfter );
919  bSetInnerBorders = true;
920  nUndoId = SwUndoId::TABLE_INSROW;
921  }
922 
923  // -->after inserting,reset the inner table borders
924  if ( bSetInnerBorders )
925  {
926  const SvxBoxInfoItem& aBoxInfo(aCoreSet.Get(SID_ATTR_BORDER_INNER));
927  SfxItemSet aSet( GetPool(), svl::Items<SID_ATTR_BORDER_INNER,
928  SID_ATTR_BORDER_INNER>{});
929  aSet.Put( aBoxInfo );
930  ItemSetToTableParam( aSet, rSh );
931  rSh.EndUndo( nUndoId );
932  }
933 
934  bCallDone = true;
935  break;
936  }
937 
939 
940  [[fallthrough]]; // on Count = 0 appears the dialog
941  }
944  {
945  const SfxSlot* pSlot = GetStaticInterface()->GetSlot(nSlot);
946  if ( FN_TABLE_INSERT_ROW_DLG != nSlot || !rSh.IsInRepeatedHeadline())
947  {
950  nSlot == FN_TABLE_INSERT_COL_DLG, pSlot->GetCommand()));
951  if( pDlg->Execute() == 1 )
952  {
953  const sal_uInt16 nDispatchSlot = (nSlot == FN_TABLE_INSERT_COL_DLG)
955  SfxUInt16Item aCountItem( nDispatchSlot, pDlg->getInsertCount() );
957  SfxViewFrame* pVFrame = GetView().GetViewFrame();
958  if( pVFrame )
959  pVFrame->GetDispatcher()->ExecuteList(nDispatchSlot,
960  SfxCallMode::SYNCHRON|SfxCallMode::RECORD,
961  { &aCountItem, &aAfter });
962  }
963  }
964  break;
965  }
967  {
969  bool bHorizontal=true;
970  bool bProportional = false;
971  const SfxInt32Item* pSplit = rReq.GetArg<SfxInt32Item>(FN_TABLE_SPLIT_CELLS);
972  const SfxBoolItem* pHor = rReq.GetArg<SfxBoolItem>(FN_PARAM_1);
973  const SfxBoolItem* pProp = rReq.GetArg<SfxBoolItem>(FN_PARAM_2);
974  if ( pSplit )
975  {
976  nCount = pSplit->GetValue();
977  if ( pHor )
978  bHorizontal = pHor->GetValue();
979  if ( pProp )
980  bProportional = pProp->GetValue();
981  }
982  else
983  {
985  SwWrtShell* pSh = &rSh;
986  const tools::Long nMaxVert = rSh.GetAnyCurRect( CurRectType::Frame ).Width() / MINLAY;
988  if(rSh.IsSplitVerticalByDefault())
990  pDlg->StartExecuteAsync([pDlg, pSh](int nResult) {
991  if (nResult == RET_OK)
992  {
993  tools::Long nCount2 = pDlg->GetCount();
994  bool bHorizontal2 = pDlg->IsHorizontal();
995  bool bProportional2 = pDlg->IsProportional();
996 
997  // tdf#60242: remember choice for next time
998  bool bVerticalWasChecked = !pDlg->IsHorizontal();
999  pSh->SetSplitVerticalByDefault(bVerticalWasChecked);
1000 
1001  if ( nCount2 > 1 )
1002  pSh->SplitTab(!bHorizontal2, static_cast< sal_uInt16 >( nCount2-1 ), bProportional2 );
1003  }
1004 
1005  pDlg->disposeOnce();
1006  });
1007  }
1008 
1009  if ( nCount>1 )
1010  {
1011  rSh.SplitTab(!bHorizontal, static_cast< sal_uInt16 >( nCount-1 ), bProportional );
1012  bCallDone = true;
1013  }
1014  else
1015  rReq.Ignore();
1016  break;
1017  }
1018 
1019  case FN_TABLE_SPLIT_TABLE:
1020  {
1021  const SfxUInt16Item* pType = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
1022  if( pType )
1023  {
1024  switch( static_cast<SplitTable_HeadlineOption>(pType->GetValue()) )
1025  {
1031  rSh.SplitTable(static_cast<SplitTable_HeadlineOption>(pType->GetValue())) ;
1032  break;
1033  default: ;//wrong parameter, do nothing
1034  }
1035  }
1036  else
1037  {
1040  pDlg->Execute();
1041  rReq.AppendItem( SfxUInt16Item( FN_PARAM_1, static_cast<sal_uInt16>(pDlg->GetSplitMode()) ) );
1042  bCallDone = true;
1043  }
1044  break;
1045  }
1046 
1047  case FN_TABLE_MERGE_TABLE:
1048  {
1049  bool bPrev = rSh.CanMergeTable();
1050  bool bNext = rSh.CanMergeTable( false );
1051 
1052  if( bPrev && bNext )
1053  {
1056  if( RET_OK != pDlg->Execute())
1057  bPrev = bNext = false;
1058  }
1059 
1060  if( bPrev || bNext )
1061  rSh.MergeTable( bPrev );
1062  break;
1063  }
1064 
1065  case FN_TABLE_MODE_FIX :
1066  case FN_TABLE_MODE_FIX_PROP :
1067  case FN_TABLE_MODE_VARIABLE :
1068  {
1069  rSh.SetTableChgMode( FN_TABLE_MODE_FIX == nSlot
1071  : FN_TABLE_MODE_FIX_PROP == nSlot
1074 
1075  SfxBindings& rBind = GetView().GetViewFrame()->GetBindings();
1076  static sal_uInt16 aInva[] =
1080  0
1081  };
1082  rBind.Invalidate( aInva );
1083  bCallDone = true;
1084  break;
1085  }
1086  case FN_TABLE_AUTOSUM:
1087  {
1088  SfxViewFrame* pVFrame = GetView().GetViewFrame();
1089  pVFrame->GetDispatcher()->Execute(FN_EDIT_FORMULA, SfxCallMode::SYNCHRON);
1090  const sal_uInt16 nId = SwInputChild::GetChildWindowId();
1091  SwInputChild* pChildWin = static_cast<SwInputChild*>(pVFrame->
1092  GetChildWindow( nId ));
1093  OUString sSum;
1094  GetShell().GetAutoSum(sSum);
1095  if( pChildWin )
1096  pChildWin->SetFormula( sSum );
1097 
1098  break;
1099  }
1101  if(0 != rSh.GetRowsToRepeat())
1102  rSh.SetRowsToRepeat( 0 );
1103  else
1105  break;
1106  case FN_TABLE_SELECT_CELL :
1107  rSh.SelectTableCell();
1108  break;
1109  case FN_TABLE_DELETE_TABLE :
1110  {
1111  rSh.StartAction();
1112  rSh.StartUndo();
1114  rSh.DeleteTable();
1115  rSh.EndUndo();
1116  rSh.EndAction();
1117  //'this' is already destroyed
1118  return;
1119  }
1121  {
1123  if (pItem2)
1124  {
1125  tools::Long nNewHeight = pItem2->GetValue();
1126  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1127  if ( pHeight )
1128  {
1129  if (pHeight->GetHeightSizeType() == SwFrameSize::Variable)
1130  pHeight->SetHeightSizeType(SwFrameSize::Minimum);
1131  pHeight->SetHeight(nNewHeight);
1132  rSh.SetRowHeight(*pHeight);
1133  }
1134  }
1135  return;
1136  }
1138  {
1140  if (pItem2)
1141  {
1142  tools::Long nNewWidth = pItem2->GetValue();
1143  SwTableFUNC aFunc( &rSh );
1144  aFunc.InitTabCols();
1145  aFunc.SetColWidth(aFunc.GetCurColNum(), nNewWidth);
1146  }
1147  return;
1148  }
1149  default:
1150  bMore = true;
1151  }
1152 
1153  if ( !bMore )
1154  {
1155  if(bCallDone)
1156  rReq.Done();
1157  return;
1158  }
1159 
1160  // Now the slots which are working directly on the TableFormat.
1161  switch ( nSlot )
1162  {
1163  case SID_ATTR_ULSPACE:
1164  if(pItem)
1165  {
1166  SvxULSpaceItem aULSpace( *static_cast<const SvxULSpaceItem*>(pItem) );
1167  aULSpace.SetWhich( RES_UL_SPACE );
1168  ::lcl_SetAttr( rSh, aULSpace );
1169  }
1170  break;
1171 
1172  case SID_ATTR_LRSPACE:
1173  if(pItem)
1174  {
1177  SvxLRSpaceItem aLRSpace( *static_cast<const SvxLRSpaceItem*>(pItem) );
1178  aLRSpace.SetWhich( RES_LR_SPACE );
1179  aSet.Put( aLRSpace );
1180  rSh.SetTableAttr( aSet );
1181  }
1182  break;
1183  // The last case branch which needs a table manager!!
1185  {
1186  SwTableFUNC aMgr( &rSh );
1187  aMgr.ColWidthDlg(GetView().GetFrameWeld());
1188  break;
1189  }
1190  case SID_TABLE_VERT_NONE:
1191  case SID_TABLE_VERT_CENTER:
1192  case SID_TABLE_VERT_BOTTOM:
1193  {
1194  const sal_uInt16 nAlign = nSlot == SID_TABLE_VERT_NONE ?
1196  nSlot == SID_TABLE_VERT_CENTER ?
1197  text::VertOrientation::CENTER : text::VertOrientation::BOTTOM;
1198  rSh.SetBoxAlign(nAlign);
1199  bCallDone = true;
1200  break;
1201  }
1202 
1203  case SID_ATTR_PARA_SPLIT:
1204  if ( pItem )
1205  {
1206  SwFormatLayoutSplit aSplit( static_cast<const SvxFormatSplitItem*>(pItem)->GetValue());
1208  aSet.Put(aSplit);
1209  rSh.SetTableAttr(aSet);
1210  }
1211  break;
1212 
1213  case SID_ATTR_PARA_KEEP:
1214  if ( pItem )
1215  {
1216  SvxFormatKeepItem aKeep( *static_cast<const SvxFormatKeepItem*>(pItem) );
1217  aKeep.SetWhich( RES_KEEP );
1219  aSet.Put(aKeep);
1220  rSh.SetTableAttr(aSet);
1221  }
1222  break;
1223  case FN_TABLE_ROW_SPLIT :
1224  {
1225  const SfxBoolItem* pBool = static_cast<const SfxBoolItem*>(pItem);
1226  std::unique_ptr<SwFormatRowSplit> pSplit;
1227  if(!pBool)
1228  {
1229  pSplit = rSh.GetRowSplit();
1230  if(pSplit)
1231  pSplit->SetValue(!pSplit->GetValue());
1232  else
1233  pSplit.reset(new SwFormatRowSplit(true));
1234  }
1235  else
1236  {
1237  pSplit.reset(new SwFormatRowSplit(pBool->GetValue()));
1238  }
1239  rSh.SetRowSplit( *pSplit );
1240  break;
1241  }
1242 
1243  default:
1244  OSL_ENSURE( false, "wrong Dispatcher" );
1245  return;
1246  }
1247  if(bCallDone)
1248  rReq.Done();
1249 }
1250 
1252 {
1253  SfxWhichIter aIter( rSet );
1254  SwWrtShell &rSh = GetShell();
1255  SwFrameFormat *pFormat = rSh.GetTableFormat();
1256  // os #124829# crash report: in case of an invalid shell selection return immediately
1257  if(!pFormat)
1258  return;
1259  sal_uInt16 nSlot = aIter.FirstWhich();
1260  while ( nSlot )
1261  {
1262  switch ( nSlot )
1263  {
1264  case FN_TABLE_MERGE_CELLS:
1265  if ( !rSh.IsTableMode() )
1267  break;
1268  case SID_TABLE_MINIMAL_COLUMN_WIDTH:
1269  case FN_TABLE_ADJUST_CELLS:
1270  if ( !rSh.IsAdjustCellWidthAllowed() )
1271  rSet.DisableItem(nSlot);
1272  break;
1273 
1275  if ( !rSh.IsAdjustCellWidthAllowed(true) )
1277  break;
1278 
1280  case FN_TABLE_BALANCE_ROWS:
1281  if ( !rSh.BalanceRowHeight(true) )
1282  rSet.DisableItem(nSlot);
1283  break;
1284  case FN_OPTIMIZE_TABLE:
1285  if ( !rSh.IsTableMode() &&
1286  !rSh.IsAdjustCellWidthAllowed() &&
1287  !rSh.IsAdjustCellWidthAllowed(true) &&
1288  !rSh.BalanceRowHeight(true) )
1290  break;
1291  case SID_INSERT_DIAGRAM:
1292  {
1293  SvtModuleOptions aMOpt;
1294  if ( !aMOpt.IsMath() || rSh.IsTableComplexForChart() )
1295  rSet.DisableItem(nSlot);
1296  }
1297  break;
1298 
1299  case FN_INSERT_TABLE:
1300  if ( rSh.CursorInsideInputField() )
1301  {
1302  rSet.DisableItem( nSlot );
1303  }
1304  break;
1305 
1306  case SID_TABLE_MINIMAL_ROW_HEIGHT:
1307  {
1308  // Disable if auto height already is enabled.
1309  std::unique_ptr<SwFormatFrameSize> pSz = rSh.GetRowHeight();
1310  if ( pSz )
1311  {
1312  if ( SwFrameSize::Variable == pSz->GetHeightSizeType() )
1313  rSet.DisableItem( nSlot );
1314  }
1315  break;
1316  }
1317  case FN_TABLE_INSERT_ROW:
1320  if ( rSh.IsInRepeatedHeadline() )
1321  rSet.DisableItem( nSlot );
1322  break;
1323  case RES_LR_SPACE:
1324  rSet.Put(pFormat->GetLRSpace());
1325  break;
1326  case RES_UL_SPACE:
1327  rSet.Put(pFormat->GetULSpace());
1328  break;
1329 
1330  case SID_TABLE_VERT_NONE:
1331  case SID_TABLE_VERT_CENTER:
1332  case SID_TABLE_VERT_BOTTOM:
1333  {
1334  const sal_uInt16 nAlign = rSh.GetBoxAlign();
1335  bool bSet = (nSlot == SID_TABLE_VERT_NONE && nAlign == text::VertOrientation::NONE) ||
1336  (nSlot == SID_TABLE_VERT_CENTER && nAlign == text::VertOrientation::CENTER) ||
1337  (nSlot == SID_TABLE_VERT_BOTTOM && nAlign == text::VertOrientation::BOTTOM);
1338  rSet.Put(SfxBoolItem(nSlot, bSet));
1339  break;
1340  }
1341 
1342  case FN_TABLE_MODE_FIX :
1343  case FN_TABLE_MODE_FIX_PROP :
1344  case FN_TABLE_MODE_VARIABLE :
1345  {
1346  TableChgMode nMode = rSh.GetTableChgMode();
1347  bool bSet = (nSlot == FN_TABLE_MODE_FIX && nMode == TableChgMode::FixedWidthChangeAbs) ||
1350  rSet.Put(SfxBoolItem(nSlot, bSet));
1351  }
1352  break;
1353 
1354  case SID_ATTR_PARA_SPLIT:
1355  rSet.Put( pFormat->GetKeep() );
1356  break;
1357 
1358  case SID_ATTR_PARA_KEEP:
1359  rSet.Put( pFormat->GetLayoutSplit() );
1360  break;
1361  case FN_TABLE_SPLIT_TABLE:
1362  if ( rSh.IsInHeadline() )
1363  rSet.DisableItem( nSlot );
1364  break;
1365  case FN_TABLE_MERGE_TABLE:
1366  {
1367  bool bAsk;
1368  if( !rSh.CanMergeTable( true, &bAsk ))
1369  rSet.DisableItem( nSlot );
1370  break;
1371  }
1372 
1373  case FN_TABLE_DELETE_ROW:
1374  {
1375  SwSelBoxes aBoxes;
1376  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Row );
1377  if( ::HasProtectedCells( aBoxes ))
1378  rSet.DisableItem( nSlot );
1379  }
1380  break;
1381  case FN_TABLE_DELETE_COL:
1382  {
1383  SwSelBoxes aBoxes;
1384  ::GetTableSel( rSh, aBoxes, SwTableSearchType::Col );
1385  if( ::HasProtectedCells( aBoxes ))
1386  rSet.DisableItem( nSlot );
1387  }
1388  break;
1389 
1391  // disable in readonly sections, but enable in protected cells
1392  if( !rSh.CanUnProtectCells() )
1393  rSet.DisableItem( nSlot );
1394  break;
1395  case RES_ROW_SPLIT:
1396  {
1397  const SwFormatLayoutSplit& rTabSplit = pFormat->GetLayoutSplit();
1398  if ( !rTabSplit.GetValue() )
1399  {
1400  rSet.DisableItem( nSlot );
1401  }
1402  else
1403  {
1404  std::unique_ptr<SwFormatRowSplit> pSplit = rSh.GetRowSplit();
1405  if(pSplit)
1406  rSet.Put(std::move(pSplit));
1407  else
1408  rSet.InvalidateItem( nSlot );
1409  }
1410  break;
1411  }
1413  if(0 != rSh.GetRowsToRepeat())
1414  rSet.Put(SfxBoolItem(nSlot, true));
1415  else if(!rSh.GetRowSelectionFromTop())
1416  rSet.DisableItem( nSlot );
1417  else
1418  rSet.Put(SfxBoolItem(nSlot, false));
1419  break;
1420  case FN_TABLE_SELECT_CELL :
1421  if(rSh.HasBoxSelection())
1422  rSet.DisableItem( nSlot );
1423  break;
1425  {
1427  std::unique_ptr<SwFormatFrameSize> pHeight = rSh.GetRowHeight();
1428  if (pHeight)
1429  {
1430  tools::Long nHeight = pHeight->GetHeight();
1431  aRowHeight.SetValue(nHeight);
1432  rSet.Put(aRowHeight);
1433 
1435  {
1436  // TODO: set correct unit
1437  MapUnit eTargetUnit = MapUnit::MapInch;
1438  OUString sHeight = GetMetricText(nHeight,
1439  MapUnit::MapTwip, eTargetUnit, nullptr);
1440 
1441  OUString sPayload = ".uno:TableRowHeight=" + sHeight;
1442 
1443  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1444  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1445  }
1446  }
1447  break;
1448  }
1450  {
1452  SwTableFUNC aFunc( &rSh );
1453  aFunc.InitTabCols();
1454  SwTwips nWidth = aFunc.GetColWidth(aFunc.GetCurColNum());
1455  aColumnWidth.SetValue(nWidth);
1456  rSet.Put(aColumnWidth);
1457 
1459  {
1460  // TODO: set correct unit
1461  MapUnit eTargetUnit = MapUnit::MapInch;
1462  OUString sWidth = GetMetricText(nWidth,
1463  MapUnit::MapTwip, eTargetUnit, nullptr);
1464 
1465  OUString sPayload = ".uno:TableColumWidth=" + sWidth;
1466 
1467  GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED,
1468  OUStringToOString(sPayload, RTL_TEXTENCODING_ASCII_US).getStr());
1469  }
1470 
1471  break;
1472  }
1473  }
1474  nSlot = aIter.NextWhich();
1475  }
1476 }
1477 
1479  SwBaseShell(_rView)
1480 {
1481  SetName("Table");
1483 }
1484 
1486 {
1487  SfxItemSet aCoreSet( GetPool(),
1489  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{} );
1490  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
1491  aCoreSet.Put( aBoxInfo );
1492  GetShell().GetTabBorders( aCoreSet );
1493  rSet.Put( aCoreSet );
1494 }
1495 
1497 {
1498  SwWrtShell &rSh = GetShell();
1499  const SfxItemSet *pArgs = rReq.GetArgs();
1500  if(!pArgs)
1501  return;
1502 
1503  switch ( rReq.GetSlot() )
1504  {
1505  case SID_FRAME_LINESTYLE:
1506  case SID_FRAME_LINECOLOR:
1507  if ( rReq.GetSlot() == SID_FRAME_LINESTYLE )
1508  {
1509  const SvxLineItem &rLineItem = pArgs->Get( SID_FRAME_LINESTYLE );
1510  const SvxBorderLine* pBorderLine = rLineItem.GetLine();
1511  rSh.SetTabLineStyle( nullptr, true, pBorderLine);
1512  }
1513  else
1514  {
1515  const SvxColorItem &rNewColorItem = pArgs->Get( SID_FRAME_LINECOLOR );
1516  rSh.SetTabLineStyle( &rNewColorItem.GetValue() );
1517  }
1518 
1519  rReq.Done();
1520 
1521  break;
1522  }
1523 }
1524 
1526 {
1527  SfxItemSet aCoreSet( GetPool(),
1529  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>{});
1530  SvxBoxInfoItem aCoreInfo( SID_ATTR_BORDER_INNER );
1531  aCoreSet.Put(aCoreInfo);
1532  GetShell().GetTabBorders( aCoreSet );
1533 
1534  const SvxBoxItem& rBoxItem = aCoreSet.Get( RES_BOX );
1535  const SvxBorderLine* pLine = rBoxItem.GetTop();
1536 
1537  rSet.Put( SvxColorItem( pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR ) );
1538  SvxLineItem aLine( SID_FRAME_LINESTYLE );
1539  aLine.SetLine(pLine);
1540  rSet.Put( aLine );
1541 }
1542 
1544 {
1545  const SfxItemSet* pArgs = rReq.GetArgs();
1546  SwWrtShell &rSh = GetShell();
1547 
1548  // At first the slots, which doesn't need a FrameMgr.
1549  const SfxPoolItem* pItem = nullptr;
1550  const sal_uInt16 nSlot = rReq.GetSlot();
1551  if(pArgs)
1552  pArgs->GetItemState(GetPool().GetWhich(nSlot), false, &pItem);
1553 
1554  // Always acquire the language from the current cursor position.
1555  LanguageType eLang = rSh.GetCurLang();
1556  SvNumberFormatter* pFormatter = rSh.GetNumberFormatter();
1557  sal_uInt32 nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1558  SvNumFormatType nFormatType = SvNumFormatType::ALL;
1559  sal_uInt16 nOffset = 0;
1560 
1561  switch ( nSlot )
1562  {
1563  case FN_NUMBER_FORMAT:
1564  if( pItem )
1565  {
1566  // Determine index for string.
1567  OUString aCode( static_cast<const SfxStringItem*>(pItem)->GetValue() );
1568  nNumberFormat = pFormatter->GetEntryKey( aCode, eLang );
1569  if( NUMBERFORMAT_ENTRY_NOT_FOUND == nNumberFormat )
1570  {
1571  // Re-enter
1572  sal_Int32 nErrPos;
1574  if( !pFormatter->PutEntry( aCode, nErrPos, nType,
1575  nNumberFormat, eLang ))
1576  nNumberFormat = NUMBERFORMAT_ENTRY_NOT_FOUND;
1577  }
1578  }
1579  break;
1580  case FN_NUMBER_STANDARD: nFormatType = SvNumFormatType::NUMBER; break;
1581  case FN_NUMBER_SCIENTIFIC: nFormatType = SvNumFormatType::SCIENTIFIC; break;
1582  case FN_NUMBER_DATE: nFormatType = SvNumFormatType::DATE; break;
1583  case FN_NUMBER_TIME: nFormatType = SvNumFormatType::TIME; break;
1584  case FN_NUMBER_CURRENCY: nFormatType = SvNumFormatType::CURRENCY; break;
1585  case FN_NUMBER_PERCENT: nFormatType = SvNumFormatType::PERCENT; break;
1586 
1587  case FN_NUMBER_TWODEC: // #.##0,00
1588  nFormatType = SvNumFormatType::NUMBER;
1589  nOffset = NF_NUMBER_1000DEC2;
1590  break;
1591 
1592  default:
1593  OSL_FAIL("wrong dispatcher");
1594  return;
1595  }
1596 
1597  if( nFormatType != SvNumFormatType::ALL )
1598  nNumberFormat = pFormatter->GetStandardFormat( nFormatType, eLang ) + nOffset;
1599 
1600  if( NUMBERFORMAT_ENTRY_NOT_FOUND != nNumberFormat )
1601  {
1603  aBoxSet.Put( SwTableBoxNumFormat( nNumberFormat ));
1604  rSh.SetTableBoxFormulaAttrs( aBoxSet );
1605  }
1606 
1607 }
1608 
1609 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
bool GetValue() const
#define FN_TABLE_INSERT_COL_DLG
Definition: cmdid.h:386
#define FN_TABLE_SET_READ_ONLY_CELLS
Definition: cmdid.h:361
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:356
void SetRight(const tools::Long nR, const sal_uInt16 nProp=100)
#define FN_TABLE_OPTIMAL_HEIGHT
Definition: cmdid.h:369
#define FN_TABLE_SET_COL_WIDTH
Definition: cmdid.h:352
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:465
SwView & GetView()
Definition: basesh.hxx:57
#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:190
void SetDefDist(sal_uInt16 nNew)
SwTwips GetLeftSpace() const
Definition: swtablerep.hxx:61
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
SwView * GetActiveView()
Definition: swmodul1.cxx:116
void SetRowSplit(const SwFormatRowSplit &rSz)
Definition: fetab.cxx:703
SwTwips GetColWidth(sal_uInt16 nNum) const
Definition: tablemgr.cxx:59
SwTwips GetTableWidth(SwFrameFormat const *pFormat, SwTabCols const &rCols, sal_uInt16 *pPercent, SwWrtShell *pSh)
Definition: uitool.cxx:752
SwUndoId
Definition: swundo.hxx:29
std::string GetValue
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(150)
void SetRowBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:740
#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:900
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:89
#define FN_TABLE_DELETE_TABLE
Definition: cmdid.h:370
void InsertCol(sal_uInt16 nCnt, bool bBehind)
Definition: fetab.cxx:209
SfxDispatcher * GetDispatcher()
SwWrtShell & GetShell()
Definition: basesh.cxx:2687
static SvxAbstractDialogFactory * Create()
#define FN_TABLE_INSERT_COL
Definition: cmdid.h:346
#define FN_TABLE_INSERT_ROW
Definition: cmdid.h:345
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:308
virtual void SetSplitVerticalByDefault()=0
tools::Long GetRightMax() const
Definition: tabcol.hxx:80
bool Pop(SwCursorShell::PopMode=SwCursorShell::PopMode::DeleteStack)
Definition: wrtsh1.cxx:1715
void GetLineStyleState(SfxItemSet &rSet)
Definition: tabsh.cxx:1525
#define FN_FORMAT_TABLE_DLG
Definition: cmdid.h:320
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:61
sal_uInt16 FirstWhich()
TableChgMode GetTableChgMode() const
Definition: edtab.cxx:276
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:360
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
bool DeleteCol()
Definition: fetab.cxx:262
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:550
void Done(bool bRemove=false)
#define FN_PARAM_TABLE_NAME
Definition: cmdid.h:778
NF_NUMBER_1000DEC2
SwTwips GetRightSpace() const
Definition: swtablerep.hxx:64
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:724
const SfxItemSet * GetArgs() const
void Invalidate(sal_uInt16 nId)
#define FN_NUMBER_FORMAT
Definition: cmdid.h:444
bool HasColsChanged() const
Definition: swtablerep.hxx:79
void InsertRow(sal_uInt16 nCnt, bool bBehind)
Definition: fetab.cxx:170
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:67
#define FN_TABLE_SELECT_ROW
Definition: cmdid.h:357
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:38
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:632
LanguageType GetCurLang() const
Definition: edattr.cxx:814
bool IsInRepeatedHeadline() const
Definition: fesh.hxx:720
void SetTabBackground(const SvxBrushItem &rNew)
Definition: fetab.cxx:821
Used by the UI to modify the document model.
Definition: wrtsh.hxx:90
#define FN_PARAM_TABLE_HEADLINE
Definition: cmdid.h:779
#define FN_TABLE_AUTOSUM
Definition: cmdid.h:432
void SelectTableRow()
Definition: select.cxx:836
bool IsTableVertical() const
Definition: fetab.cxx:2315
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:332
static void lcl_TabGetMaxLineWidth(const SvxBorderLine *pBorderLine, SvxBorderLine &rBorderLine)
Definition: tabsh.cxx:439
const SwView & GetView() const
Definition: wrtsh.hxx:428
#define FN_GOTO_NEXT_CELL
Definition: cmdid.h:389
void SetHoriOrient(sal_Int16 eNew)
Definition: fmtornt.hxx:89
#define FN_TABLE_SELECT_ALL
Definition: cmdid.h:359
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
sal_uInt16 GetAlign() const
Definition: swtablerep.hxx:73
void AdjustCellWidth(const bool bBalance, const bool bNoShrink)
Definition: fetab.cxx:1107
constexpr sal_uInt32 NUMBERFORMAT_ENTRY_NOT_FOUND
#define FN_PARAM_INSERT_AFTER
Definition: cmdid.h:776
const OUString & GetName() const
Definition: format.hxx:111
int nCount
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
void ExecTableStyle(SfxRequest &rReq)
Definition: tabsh.cxx:1496
void Width(tools::Long nNew)
Definition: swrect.hxx:187
bool BalanceRowHeight(bool bTstOnly, const bool bOptimize=false)
Definition: fetab.cxx:729
void GetFrameBorderState(SfxItemSet &rSet)
Definition: tabsh.cxx:1485
void GetState(SfxItemSet &)
Definition: tabsh.cxx:1251
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:155
#define FN_NUMBER_SCIENTIFIC
Definition: cmdid.h:447
#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:845
void SetFormula(const OUString &rFormula)
Definition: inputwin.hxx:191
bool PutEntry(OUString &rString, sal_Int32 &nCheckPos, SvNumFormatType &nType, sal_uInt32 &nKey, LanguageType eLnge=LANGUAGE_DONTKNOW)
sal_uInt16 GetWidthPercent() const
Definition: swtablerep.hxx:70
SfxItemPool & GetPool() const
#define FN_NUMBER_PERCENT
Definition: cmdid.h:451
void SetTableBoxFormulaAttrs(const SfxItemSet &rSet)
Definition: edtab.cxx:343
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:559
const sal_uInt16 * SwuiGetUITableAttrRange()
Definition: tabsh.cxx:124
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: dialoghelp.cxx:20
void SetTableChgMode(TableChgMode eMode)
Definition: edtab.cxx:287
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
#define FN_TABLE_INSERT_ROW_DLG
Definition: cmdid.h:387
void EndSelect()
Definition: select.cxx:424
const SfxItemPool & GetAttrPool() const
Definition: viewsh.hxx:612
bool IsMath() const
void SetTabBorders(const SfxItemSet &rSet)
Definition: fetab.cxx:753
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:776
#define FN_TABLE_MERGE_CELLS
Definition: cmdid.h:350
void SetTabCols(const SwTabCols &rNew, bool bCurRowOnly)
Definition: fetab.cxx:615
Style of a layout element.
Definition: frmfmt.hxx:58
SwTableShell(SwView &rView)
Definition: tabsh.cxx:1478
bool HasSelection() const
Definition: wrtsh.hxx:141
#define SW_MOD()
Definition: swmodule.hxx:255
bool HasBoxSelection() const
Is content of a table cell or at least a table cell completely selected?
Definition: fetab.cxx:859
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:686
int i
#define FN_INSERT_TABLE
Definition: cmdid.h:214
void GetTableSel(const SwCursorShell &rShell, SwSelBoxes &rBoxes, const SwTableSearchType eSearchType)
Definition: tblsel.cxx:149
void SetRowsToRepeat(sal_uInt16 nNumOfRows)
Definition: fetab.cxx:998
css::drawing::Direction3D aDirection
const SfxSlot * GetSlot(sal_uInt16 nSlotId) const
void EndAction(const bool bIdleEnd=false, const bool DoSetPosX=false)
Definition: crsrsh.cxx:239
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
void SetRowHeight(const SwFormatFrameSize &rSz)
Definition: fetab.cxx:716
#define LANGUAGE_SYSTEM
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2237
virtual VclPtr< SvxAbstractInsRowColDlg > CreateSvxInsRowColDlg(weld::Window *pParent, bool bCol, const OString &rHelpId)=0
#define FN_TABLE_ADJUST_CELLS
Definition: cmdid.h:364
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:345
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:3502
OUString GetTableBoxText() const
Definition: edtab.cxx:417
sal_Int16 GetHoriOrient() const
Definition: fmtornt.hxx:87
NF_TEXT
SvNumFormatType
void SetBoxAlign(sal_uInt16 nOrient)
Definition: fetab.cxx:808
sal_uInt16 GetCursorCnt(bool bAll=true) const
Get the number of elements in the ring of cursors.
Definition: crsrsh.cxx:2723
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
void GetTabCols(SwTabCols &rToFill) const
Info about columns and margins.
Definition: fetab.cxx:633
OUString SwResId(const char *pId)
Definition: swmodule.cxx:165
void SetName(const OUString &rName)
bool empty() const
void SttSelect()
Definition: select.cxx:384
void GetTabBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
Definition: fetab.cxx:834
void DeleteEntry(sal_uInt32 nKey)
#define FN_TABLE_DELETE_COL
Definition: cmdid.h:348
sal_uInt16 GetRowSelectionFromTop() const
Definition: fetab.cxx:1051
TableMergeErr MergeTab()
Merge selected parts of table.
Definition: fetab.cxx:433
void GetTableAttr(SfxItemSet &) const
Definition: fetab.cxx:2117
SfxViewShell * GetViewShell() const
void UpdateTable()
update fields of a listing
Definition: edtab.cxx:256
virtual sal_uInt16 getInsertCount() const =0
tools::Long SwTwips
Definition: swtypes.hxx:49
SwDocShell * GetDocShell()
Definition: view.cxx:1109
SwFrameFormat * GetTableFormat()
Definition: edws.cxx:183
#define FN_TABLE_INSERT_ROW_AFTER
Definition: cmdid.h:353
#define FN_GOTO_PREV_CELL
Definition: cmdid.h:390
#define SFX_OBJECTBAR_OBJECT
std::unique_ptr< SwFormatRowSplit > GetRowSplit() const
Definition: fetab.cxx:711
void UnProtectCells()
Refers to table selection.
Definition: fetab.cxx:920
SvNumberFormatter * GetNumberFormatter() const
SFX2_DLLPUBLIC OString GetCommand() const
#define FN_TABLE_MODE_FIX_PROP
Definition: cmdid.h:426
void StartAction()
Definition: crsrsh.cxx:222
bool MergeTable(bool bWithPrev)
Definition: edtab.cxx:455
#define FN_NUMBER_TIME
Definition: cmdid.h:449
OString OUStringToOString(const OUString &str, ConnectionSettings const *settings)
void SetReturnValue(const SfxPoolItem &)
void Update(sal_uInt16 nId)
void InsertTable(SfxRequest &_rRequest)
Definition: basesh.cxx:2749
constexpr sal_uInt16 RES_FRMATR_END(131)
sal_uInt8 GetTableDest() const
Definition: viewopt.hxx:534
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:473
#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:100
#define FN_TABLE_REP
Definition: cmdid.h:343
#define GetWhich(nSlot)
const SwViewOption * GetViewOptions() const
Definition: viewsh.hxx:423
bool MoveTable(SwWhichTable, SwMoveFnCollection const &)
Definition: trvltbl.cxx:681
void SetTableAttr(const SfxItemSet &)
Definition: fetab.cxx:2124
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:320
void SetSplitVerticalByDefault(bool value)
Definition: select.cxx:371
void ItemSetToTableParam(const SfxItemSet &rSet, SwWrtShell &rSh)
Definition: tabsh.cxx:270
#define FN_TABLE_UNSET_READ_ONLY_CELLS
Definition: cmdid.h:362
#define FN_END_TABLE
Definition: cmdid.h:681
void ColWidthDlg(weld::Window *pParent)
Definition: tablemgr.cxx:50
bool IsSplitVerticalByDefault() const
Definition: select.cxx:366
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:854
bool GetTableBoxFormulaAttrs(SfxItemSet &rSet) const
Definition: edtab.cxx:302
#define FN_TABLE_BOX_TEXTORIENTATION
Definition: cmdid.h:428
QPRO_FUNC_TYPE nType
#define FN_TABLE_SET_ROW_HEIGHT
Definition: cmdid.h:351
constexpr TypedWhichId< SvxLRSpaceItem > RES_LR_SPACE(91)
#define FN_TABLE_SELECT_COL
Definition: cmdid.h:358
#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:771
bool GetRowBackground(std::unique_ptr< SvxBrushItem > &rToFill) const
FALSE ambiguous.
Definition: fetab.cxx:748
sal_uInt32 GetEntryKey(const OUString &sStr, LanguageType eLnge=LANGUAGE_DONTKNOW)
#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:800
#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:403
MapUnit
void AppendItem(const SfxPoolItem &)
bool IsTableComplexForChart()
Definition: trvltbl.cxx:725
sal_uInt16 GetBoxAlign() const
USHRT_MAX if ambiguous.
Definition: fetab.cxx:816
sal_uInt16 GetRowsToRepeat() const
Definition: fetab.cxx:989
#define FN_TABLE_INSERT_ROW_BEFORE
Definition: cmdid.h:355
bool IsInHeadline() const
Definition: fesh.hxx:721
#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:349
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:1121
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:962
void ExecNumberFormat(SfxRequest const &rReq)
Definition: tabsh.cxx:1543
#define FN_TABLE_MODE_FIX
Definition: cmdid.h:425
#define FN_TABLE_DELETE_ROW
Definition: cmdid.h:347
#define FN_PARAM_TABLE_SPACE
Definition: cmdid.h:780
const sal_uInt16 aUITableAttrRange[]
Definition: tabsh.cxx:96
#define FN_TABLE_HEADLINE_REPEAT
Definition: cmdid.h:363
#define FN_TABLE_SELECT_CELL
Definition: cmdid.h:371
void GetAutoSum(OUString &rFormula) const
Definition: fetab.cxx:2202
#define FN_OPTIMIZE_TABLE
Definition: cmdid.h:354
Frame is variable in Var-direction.
bool HasWholeTabSelection() const
Definition: fetab.cxx:841
SelectionType GetSelectionType() const
Definition: wrtsh1.cxx:1395
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:761
#define FN_TABLE_SET_VERT_ALIGN
Definition: cmdid.h:424
void Ignore()
SvNumberFormatter * GetNumberFormatter()
Query NumberFormatter from document.
Definition: editsh.cxx:744
bool DeleteRow(bool bCompleteTable=false)
Definition: fetab.cxx:313
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:311
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:784
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:118
const Color & GetValue() const
void SetBoxDirection(const SvxFrameDirectionItem &rNew)
Definition: fetab.cxx:792
void SetDist(bool bNew)
Rect of current frame.
void SplitTable(SplitTable_HeadlineOption eMode)
Split table at cursor position.
Definition: edtab.cxx:439
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:925