LibreOffice Module sw (master)  1
unotbl.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 <tuple>
21 #include <utility>
22 #include <memory>
23 #include <vector>
24 #include <algorithm>
25 #include <limits>
26 
28 #include <o3tl/any.hxx>
29 #include <o3tl/safeint.hxx>
30 #include <tools/UnitConversion.hxx>
31 #include <editeng/memberids.h>
32 #include <float.h>
33 #include <swtypes.hxx>
34 #include <cmdid.h>
35 #include <unocoll.hxx>
36 #include <unomid.h>
37 #include <unomap.hxx>
38 #include <unotbl.hxx>
39 #include <section.hxx>
40 #include <unocrsr.hxx>
41 #include <hints.hxx>
42 #include <swtblfmt.hxx>
43 #include <doc.hxx>
44 #include <IDocumentUndoRedo.hxx>
48 #include <IDocumentState.hxx>
50 #include <shellres.hxx>
51 #include <docary.hxx>
52 #include <ndole.hxx>
53 #include <frame.hxx>
54 #include <vcl/svapp.hxx>
55 #include <fmtfsize.hxx>
56 #include <tblafmt.hxx>
57 #include <tabcol.hxx>
58 #include <cellatr.hxx>
59 #include <fmtpdsc.hxx>
60 #include <pagedesc.hxx>
61 #include <viewsh.hxx>
62 #include <rootfrm.hxx>
63 #include <tabfrm.hxx>
64 #include <redline.hxx>
65 #include <unoport.hxx>
66 #include <unocrsrhelper.hxx>
67 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
68 #include <com/sun/star/text/WrapTextMode.hpp>
69 #include <com/sun/star/text/TextContentAnchorType.hpp>
70 #include <com/sun/star/text/TableColumnSeparator.hpp>
71 #include <com/sun/star/text/VertOrientation.hpp>
72 #include <com/sun/star/text/XTextSection.hpp>
73 #include <com/sun/star/table/TableBorder.hpp>
74 #include <com/sun/star/table/TableBorder2.hpp>
75 #include <com/sun/star/table/BorderLine2.hpp>
76 #include <com/sun/star/table/TableBorderDistances.hpp>
77 #include <com/sun/star/beans/PropertyAttribute.hpp>
78 #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
79 #include <com/sun/star/chart/ChartDataChangeEvent.hpp>
80 #include <com/sun/star/table/CellContentType.hpp>
81 #include <unotextrange.hxx>
82 #include <unotextcursor.hxx>
83 #include <unoparagraph.hxx>
84 #include <svl/numformat.hxx>
85 #include <svl/zforlist.hxx>
87 #include <editeng/shaditem.hxx>
88 #include <editeng/lrspitem.hxx>
89 #include <editeng/ulspitem.hxx>
90 #include <fmtornt.hxx>
91 #include <editeng/keepitem.hxx>
92 #include <fmtlsplt.hxx>
93 #include <swundo.hxx>
94 #include <SwStyleNameMapper.hxx>
95 #include <frmatr.hxx>
96 #include <sortopt.hxx>
97 #include <sal/log.hxx>
98 #include <editeng/frmdiritem.hxx>
100 #include <comphelper/string.hxx>
102 #include <comphelper/sequence.hxx>
104 #include <swtable.hxx>
105 #include <docsh.hxx>
106 #include <fesh.hxx>
107 #include <itabenum.hxx>
108 #include <frameformats.hxx>
109 #include <o3tl/string_view.hxx>
110 
111 using namespace ::com::sun::star;
112 using ::editeng::SvxBorderLine;
113 
114 namespace
115 {
116  template<typename Tcoretype, typename Tunotype>
117  struct FindUnoInstanceHint final : SfxHint
118  {
119  FindUnoInstanceHint(Tcoretype* pCore) : m_pCore(pCore), m_pResult(nullptr) {};
120  const Tcoretype* const m_pCore;
121  mutable rtl::Reference<Tunotype> m_pResult;
122  };
123  SwFrameFormat* lcl_EnsureCoreConnected(SwFrameFormat* pFormat, cppu::OWeakObject* pObject)
124  {
125  if(!pFormat)
126  throw uno::RuntimeException("Lost connection to core objects", pObject);
127  return pFormat;
128  }
129  SwTable* lcl_EnsureTableNotComplex(SwTable* pTable, cppu::OWeakObject* pObject)
130  {
131  if(pTable->IsTableComplex())
132  throw uno::RuntimeException("Table too complex", pObject);
133  return pTable;
134  }
135 
136  chart::ChartDataChangeEvent createChartEvent(uno::Reference<uno::XInterface> const& xSource)
137  {
138  //TODO: find appropriate settings of the Event
139  chart::ChartDataChangeEvent event;
140  event.Source = xSource;
141  event.Type = chart::ChartDataChangeType_ALL;
142  event.StartColumn = 0;
143  event.EndColumn = 1;
144  event.StartRow = 0;
145  event.EndRow = 1;
146  return event;
147  }
148 
149  void lcl_SendChartEvent(std::unique_lock<std::mutex>& rGuard,
150  uno::Reference<uno::XInterface> const& xSource,
152  {
153  if (rListeners.getLength(rGuard))
154  rListeners.notifyEach(rGuard,
155  &chart::XChartDataChangeEventListener::chartDataChanged,
156  createChartEvent(xSource));
157  }
158 }
159 
160 #define UNO_TABLE_COLUMN_SUM 10000
161 
162 
163 static bool lcl_LineToSvxLine(const table::BorderLine& rLine, SvxBorderLine& rSvxLine)
164 {
165  rSvxLine.SetColor(Color(ColorTransparency, rLine.Color));
166 
167  rSvxLine.GuessLinesWidths( SvxBorderLineStyle::NONE,
168  o3tl::toTwips(rLine.OuterLineWidth, o3tl::Length::mm100),
169  o3tl::toTwips(rLine.InnerLineWidth, o3tl::Length::mm100),
170  o3tl::toTwips(rLine.LineDistance, o3tl::Length::mm100) );
171 
172  return rLine.InnerLineWidth > 0 || rLine.OuterLineWidth > 0;
173 }
174 
178  const SfxItemPropertyMapEntry* pEntry,
179  const uno::Any& aValue)
180 {
181  // special treatment for "non-items"
182  switch(pEntry->nWID)
183  {
186  {
187  SwTable* pTable = SwTable::FindTable( pFormat );
188  UnoActionContext aAction(pFormat->GetDoc());
189  if( pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
190  {
191  pFormat->GetDoc()->SetRowsToRepeat( *pTable, aValue.get<bool>() ? 1 : 0 );
192  }
193  else
194  {
195  sal_Int32 nRepeat = 0;
196  aValue >>= nRepeat;
197  if( nRepeat >= 0 && nRepeat < SAL_MAX_UINT16 )
198  pFormat->GetDoc()->SetRowsToRepeat( *pTable, o3tl::narrowing<sal_uInt16>(nRepeat) );
199  }
200  }
201  break;
202 
204  case FN_TABLE_WIDTH:
206  {
207  SwFormatFrameSize aSz( pFormat->GetFrameSize() );
208  if(FN_TABLE_WIDTH == pEntry->nWID)
209  {
210  sal_Int32 nWidth = 0;
211  aValue >>= nWidth;
212  aSz.SetWidthPercent(0);
213  aSz.SetWidth ( o3tl::toTwips(nWidth, o3tl::Length::mm100) );
214  }
215  else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
216  {
217  sal_Int16 nSet = 0;
218  aValue >>= nSet;
219  if(nSet && nSet <=100)
220  aSz.SetWidthPercent( static_cast<sal_uInt8>(nSet) );
221  }
222  else if(FN_TABLE_IS_RELATIVE_WIDTH == pEntry->nWID)
223  {
224  if(!aValue.get<bool>())
225  aSz.SetWidthPercent(0);
226  else
227  {
228  lang::IllegalArgumentException aExcept;
229  aExcept.Message = "relative width cannot be switched on with this property";
230  throw aExcept;
231  }
232  }
233  pFormat->GetDoc()->SetAttr(aSz, *pFormat);
234  }
235  break;
236 
237  case RES_PAGEDESC:
238  {
239  OUString sPageStyle;
240  aValue >>= sPageStyle;
241  const SwPageDesc* pDesc = nullptr;
242  if (!sPageStyle.isEmpty())
243  {
245  pDesc = SwPageDesc::GetByName(*pFormat->GetDoc(), sPageStyle);
246  }
247  SwFormatPageDesc aDesc( pDesc );
248  pFormat->GetDoc()->SetAttr(aDesc, *pFormat);
249  }
250  break;
251 
252  default:
253  throw lang::IllegalArgumentException();
254  }
255 }
256 
258 {
259  switch(pEntry->nWID)
260  {
263  {
264  SwTable* pTable = SwTable::FindTable( pFormat );
265  const sal_uInt16 nRepeat = pTable->GetRowsToRepeat();
266  if(pEntry->nWID == FN_TABLE_HEADLINE_REPEAT)
267  return uno::Any(nRepeat > 0);
268  return uno::Any(sal_Int32(nRepeat));
269  }
270 
271  case FN_TABLE_WIDTH:
274  {
275  uno::Any aRet;
276  const SwFormatFrameSize& rSz = pFormat->GetFrameSize();
277  if(FN_TABLE_WIDTH == pEntry->nWID)
279  else if(FN_TABLE_RELATIVE_WIDTH == pEntry->nWID)
281  else
282  aRet <<= (0 != rSz.GetWidthPercent());
283  return aRet;
284  }
285 
286  case RES_PAGEDESC:
287  {
288  const SfxItemSet& rSet = pFormat->GetAttrSet();
289  if(const SwFormatPageDesc* pItem = rSet.GetItemIfSet(RES_PAGEDESC, false))
290  {
291  const SwPageDesc* pDsc = pItem->GetPageDesc();
292  if(pDsc)
294  }
295  return uno::Any(OUString());
296  }
297 
298  case RES_ANCHOR:
299  return uno::Any(text::TextContentAnchorType_AT_PARAGRAPH);
300 
301  case FN_UNO_ANCHOR_TYPES:
302  {
303  uno::Sequence<text::TextContentAnchorType> aTypes{text::TextContentAnchorType_AT_PARAGRAPH};
304  return uno::Any(aTypes);
305  }
306 
307  case FN_UNO_WRAP :
308  return uno::Any(text::WrapTextMode_NONE);
309 
311  return uno::Any(pFormat->GetName());
312 
315  {
316  SwTable* pTable = SwTable::FindTable( pFormat );
317  SwNode* pTableNode = pTable->GetTableNode();
318  if(FN_UNO_REDLINE_NODE_END == pEntry->nWID)
319  pTableNode = pTableNode->EndOfSectionNode();
320  for(const SwRangeRedline* pRedline : pFormat->GetDoc()->getIDocumentRedlineAccess().GetRedlineTable())
321  {
322  const SwNode& rRedPointNode = pRedline->GetNode();
323  const SwNode& rRedMarkNode = pRedline->GetNode(false);
324  if(&rRedPointNode == pTableNode || &rRedMarkNode == pTableNode)
325  {
326  const SwNode& rStartOfRedline = SwNodeIndex(rRedPointNode) <= SwNodeIndex(rRedMarkNode) ?
327  rRedPointNode : rRedMarkNode;
328  bool bIsStart = &rStartOfRedline == pTableNode;
329  return uno::Any(SwXRedlinePortion::CreateRedlineProperties(*pRedline, bIsStart));
330  }
331  }
332  }
333  }
334  return uno::Any();
335 }
336 
350 //TODO: potential for throwing proper exceptions instead of having every caller to check for errors
351 void SwXTextTable::GetCellPosition(const OUString& rCellName, sal_Int32& o_rColumn, sal_Int32& o_rRow)
352 {
353  o_rColumn = o_rRow = -1; // default return values indicating failure
354  const sal_Int32 nLen = rCellName.getLength();
355  if(!nLen)
356  {
357  SAL_WARN("sw.uno", "failed to get column or row index");
358  return;
359  }
360  sal_Int32 nRowPos = 0;
361  while (nRowPos<nLen)
362  {
363  if (rCellName[nRowPos]>='0' && rCellName[nRowPos]<='9')
364  {
365  break;
366  }
367  ++nRowPos;
368  }
369  if (nRowPos<=0 || nRowPos>=nLen)
370  return;
371 
372  sal_Int32 nColIdx = 0;
373  for (sal_Int32 i = 0; i < nRowPos; ++i)
374  {
375  nColIdx *= 52;
376  if (i < nRowPos - 1)
377  ++nColIdx;
378  const sal_Unicode cChar = rCellName[i];
379  if ('A' <= cChar && cChar <= 'Z')
380  nColIdx += cChar - 'A';
381  else if ('a' <= cChar && cChar <= 'z')
382  nColIdx += 26 + cChar - 'a';
383  else
384  {
385  nColIdx = -1; // sth failed
386  break;
387  }
388  }
389 
390  o_rColumn = nColIdx;
391  o_rRow = o3tl::toInt32(rCellName.subView(nRowPos)) - 1; // - 1 because indices ought to be 0 based
392 }
393 
403 int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 )
404 {
405  sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
406  SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
407  SwXTextTable::GetCellPosition( rCellName2, nCol2, nRow2 );
408 
409  if (nRow1 < nRow2 || (nRow1 == nRow2 && nCol1 < nCol2))
410  return -1;
411  else if (nCol1 == nCol2 && nRow1 == nRow2)
412  return 0;
413  else
414  return +1;
415 }
416 
426 int sw_CompareCellsByColFirst( const OUString &rCellName1, const OUString &rCellName2 )
427 {
428  sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
429  SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
430  SwXTextTable::GetCellPosition( rCellName2, nCol2, nRow2 );
431 
432  if (nCol1 < nCol2 || (nCol1 == nCol2 && nRow1 < nRow2))
433  return -1;
434  else if (nRow1 == nRow2 && nCol1 == nCol2)
435  return 0;
436  else
437  return +1;
438 }
439 
454  const OUString &rRange1StartCell, const OUString &rRange1EndCell,
455  const OUString &rRange2StartCell, const OUString &rRange2EndCell,
456  bool bCmpColsFirst )
457 {
458  int (*pCompareCells)( const OUString &, const OUString & ) =
460 
461  int nCmpResStartCells = pCompareCells( rRange1StartCell, rRange2StartCell );
462  if ((-1 == nCmpResStartCells ) ||
463  ( 0 == nCmpResStartCells &&
464  -1 == pCompareCells( rRange1EndCell, rRange2EndCell ) ))
465  return -1;
466  else if (0 == nCmpResStartCells &&
467  0 == pCompareCells( rRange1EndCell, rRange2EndCell ))
468  return 0;
469  else
470  return +1;
471 }
472 
479 OUString sw_GetCellName( sal_Int32 nColumn, sal_Int32 nRow )
480 {
481  if (nColumn < 0 || nRow < 0)
482  return OUString();
483  OUString sCellName;
484  sw_GetTableBoxColStr( static_cast< sal_uInt16 >(nColumn), sCellName );
485  return sCellName + OUString::number( nRow + 1 );
486 }
487 
495 static const SwTableBox* lcl_FindCornerTableBox(const SwTableLines& rTableLines, const bool i_bTopLeft)
496 {
497  const SwTableLines* pLines(&rTableLines);
498  while(true)
499  {
500  assert(!pLines->empty());
501  if(pLines->empty())
502  return nullptr;
503  const SwTableLine* pLine(i_bTopLeft ? pLines->front() : pLines->back());
504  assert(pLine);
505  const SwTableBoxes& rBoxes(pLine->GetTabBoxes());
506  assert(rBoxes.size() != 0);
507  const SwTableBox* pBox = i_bTopLeft ? rBoxes.front() : rBoxes.back();
508  assert(pBox);
509  if (pBox->GetSttNd())
510  return pBox;
511  pLines = &pBox->GetTabLines();
512  }
513 }
514 
524 void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
525 {
526  sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
527  SwXTextTable::GetCellPosition( rCell1, nCol1, nRow1 );
528  SwXTextTable::GetCellPosition( rCell2, nCol2, nRow2 );
529  if (nCol2 < nCol1 || nRow2 < nRow1)
530  {
531  rCell1 = sw_GetCellName( std::min(nCol1, nCol2), std::min(nRow1, nRow2) );
532  rCell2 = sw_GetCellName( std::max(nCol1, nCol2), std::max(nRow1, nRow2) );
533  }
534 }
535 
537 {
538  if (nTop > nBottom)
539  std::swap(nBottom, nTop);
540  if (nLeft > nRight)
541  std::swap(nLeft, nRight);
542 }
543 
544 static rtl::Reference<SwXCell> lcl_CreateXCell(SwFrameFormat* pFormat, sal_Int32 nColumn, sal_Int32 nRow)
545 {
546  const OUString sCellName = sw_GetCellName(nColumn, nRow);
547  SwTable* pTable = SwTable::FindTable(pFormat);
548  SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
549  if(!pBox)
550  return nullptr;
551  return SwXCell::CreateXCell(pFormat, pBox, pTable);
552 }
553 
554 static void lcl_InspectLines(SwTableLines& rLines, std::vector<OUString>& rAllNames)
555 {
556  for(auto pLine : rLines)
557  {
558  for(auto pBox : pLine->GetTabBoxes())
559  {
560  if(!pBox->GetName().isEmpty() && pBox->getRowSpan() > 0)
561  rAllNames.push_back(pBox->GetName());
562  SwTableLines& rBoxLines = pBox->GetTabLines();
563  if(!rBoxLines.empty())
564  lcl_InspectLines(rBoxLines, rAllNames);
565  }
566  }
567 }
568 
569 static bool lcl_FormatTable(SwFrameFormat const * pTableFormat)
570 {
571  bool bHasFrames = false;
572  SwIterator<SwFrame,SwFormat> aIter( *pTableFormat );
573  for(SwFrame* pFrame = aIter.First(); pFrame; pFrame = aIter.Next())
574  {
575  vcl::RenderContext* pRenderContext = pFrame->getRootFrame()->GetCurrShell()->GetOut();
576  // mba: no TYPEINFO for SwTabFrame
577  if(!pFrame->IsTabFrame())
578  continue;
579  DisableCallbackAction a(*pFrame->getRootFrame());
580  SwTabFrame* pTabFrame = static_cast<SwTabFrame*>(pFrame);
581  if(pTabFrame->isFrameAreaDefinitionValid())
582  pTabFrame->InvalidatePos();
583  pTabFrame->SetONECalcLowers();
584  pTabFrame->Calc(pRenderContext);
585  bHasFrames = true;
586  }
587  return bHasFrames;
588 }
589 
590 static void lcl_CursorSelect(SwPaM& rCursor, bool bExpand)
591 {
592  if(bExpand)
593  {
594  if(!rCursor.HasMark())
595  rCursor.SetMark();
596  }
597  else if(rCursor.HasMark())
598  rCursor.DeleteMark();
599 }
600 
601 static void lcl_GetTableSeparators(uno::Any& rRet, SwTable const * pTable, SwTableBox const * pBox, bool bRow)
602 {
603  SwTabCols aCols;
604  aCols.SetLeftMin ( 0 );
605  aCols.SetLeft ( 0 );
606  aCols.SetRight ( UNO_TABLE_COLUMN_SUM );
608 
609  pTable->GetTabCols( aCols, pBox, false, bRow );
610 
611  const size_t nSepCount = aCols.Count();
612  uno::Sequence< text::TableColumnSeparator> aColSeq(nSepCount);
613  text::TableColumnSeparator* pArray = aColSeq.getArray();
614  bool bError = false;
615  for(size_t i = 0; i < nSepCount; ++i)
616  {
617  pArray[i].Position = static_cast< sal_Int16 >(aCols[i]);
618  pArray[i].IsVisible = !aCols.IsHidden(i);
619  if(!bRow && !pArray[i].IsVisible)
620  {
621  bError = true;
622  break;
623  }
624  }
625  if(!bError)
626  rRet <<= aColSeq;
627 
628 }
629 
630 static void lcl_SetTableSeparators(const uno::Any& rVal, SwTable* pTable, SwTableBox const * pBox, bool bRow, SwDoc* pDoc)
631 {
632  SwTabCols aOldCols;
633 
634  aOldCols.SetLeftMin ( 0 );
635  aOldCols.SetLeft ( 0 );
636  aOldCols.SetRight ( UNO_TABLE_COLUMN_SUM );
637  aOldCols.SetRightMax( UNO_TABLE_COLUMN_SUM );
638 
639  pTable->GetTabCols( aOldCols, pBox, false, bRow );
640  const size_t nOldCount = aOldCols.Count();
641  // there is no use in setting tab cols if there is only one column
642  if( !nOldCount )
643  return;
644 
645  auto pSepSeq =
646  o3tl::tryAccess<uno::Sequence<text::TableColumnSeparator>>(rVal);
647  if(!pSepSeq || static_cast<size_t>(pSepSeq->getLength()) != nOldCount)
648  return;
649  SwTabCols aCols(aOldCols);
650  const text::TableColumnSeparator* pArray = pSepSeq->getConstArray();
651  tools::Long nLastValue = 0;
652  //sal_Int32 nTableWidth = aCols.GetRight() - aCols.GetLeft();
653  for(size_t i = 0; i < nOldCount; ++i)
654  {
655  aCols[i] = pArray[i].Position;
656  if(bool(pArray[i].IsVisible) == aCols.IsHidden(i) ||
657  (!bRow && aCols.IsHidden(i)) ||
658  aCols[i] < nLastValue ||
659  UNO_TABLE_COLUMN_SUM < aCols[i] )
660  return; // probably this should assert()
661  nLastValue = aCols[i];
662  }
663  pDoc->SetTabCols(*pTable, aCols, aOldCols, pBox, bRow );
664 }
665 
666 /* non UNO function call to set string in SwXCell */
667 void sw_setString( SwXCell &rCell, const OUString &rText,
668  bool bKeepNumberFormat = false )
669 {
670  if(rCell.IsValid())
671  {
672  SwFrameFormat* pBoxFormat = rCell.m_pBox->ClaimFrameFormat();
673  pBoxFormat->LockModify();
674  pBoxFormat->ResetFormatAttr( RES_BOXATR_FORMULA );
675  pBoxFormat->ResetFormatAttr( RES_BOXATR_VALUE );
676  if (!bKeepNumberFormat)
677  pBoxFormat->SetFormatAttr( SwTableBoxNumFormat(/*default Text*/) );
678  pBoxFormat->UnlockModify();
679  }
680  rCell.SwXText::setString(rText);
681 }
682 
683 
684 /* non UNO function call to set value in SwXCell */
685 void sw_setValue( SwXCell &rCell, double nVal )
686 {
687  if(!rCell.IsValid())
688  return;
689  // first this text (maybe) needs to be deleted
690  SwNodeOffset nNdPos = rCell.m_pBox->IsValidNumTextNd();
691  if(NODE_OFFSET_MAX != nNdPos)
692  sw_setString( rCell, OUString(), true ); // true == keep number format
693  SwDoc* pDoc = rCell.GetDoc();
694  UnoActionContext aAction(pDoc);
695  SwFrameFormat* pBoxFormat = rCell.m_pBox->ClaimFrameFormat();
697 
699  // - there is no current number format
700  // - the current number format is not a number format according to the number formatter, but rather a text format
701  const SwTableBoxNumFormat* pNumFormat = pBoxFormat->GetAttrSet().GetItemIfSet(RES_BOXATR_FORMAT);
702  if(!pNumFormat
703  || pDoc->GetNumberFormatter()->IsTextFormat(pNumFormat->GetValue()))
704  {
705  aSet.Put(SwTableBoxNumFormat(0));
706  }
707 
708  SwTableBoxValue aVal(nVal);
709  aSet.Put(aVal);
710  pDoc->SetTableBoxFormulaAttrs( *rCell.m_pBox, aSet );
711  // update table
712  SwTableFormulaUpdate aTableUpdate( SwTable::FindTable( rCell.GetFrameFormat() ));
713  pDoc->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
714 }
715 
716 
717 SwXCell::SwXCell(SwFrameFormat* pTableFormat, SwTableBox* pBx, size_t const nPos) :
718  SwXText(pTableFormat->GetDoc(), CursorType::TableText),
719  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
720  m_pBox(pBx),
721  m_pStartNode(nullptr),
722  m_pTableFormat(pTableFormat),
723  m_nFndPos(nPos)
724 {
725  StartListening(pTableFormat->GetNotifier());
726 }
727 
728 SwXCell::SwXCell(SwFrameFormat* pTableFormat, const SwStartNode& rStartNode) :
729  SwXText(pTableFormat->GetDoc(), CursorType::TableText),
730  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_CELL)),
731  m_pBox(nullptr),
732  m_pStartNode(&rStartNode),
733  m_pTableFormat(pTableFormat),
734  m_nFndPos(NOTFOUND)
735 {
736  StartListening(pTableFormat->GetNotifier());
737 }
738 
740 {
741  SolarMutexGuard aGuard;
742  EndListeningAll();
743 }
744 
745 const uno::Sequence< sal_Int8 > & SwXCell::getUnoTunnelId()
746 {
747  static const comphelper::UnoIdInit theSwXCellUnoTunnelId;
748  return theSwXCellUnoTunnelId.getSeq();
749 }
750 
751 sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
752 {
754 }
755 
756 uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes( )
757 {
759  SwXCellBaseClass::getTypes(),
761  );
762 }
763 
764 uno::Sequence< sal_Int8 > SAL_CALL SwXCell::getImplementationId( )
765 {
766  return css::uno::Sequence<sal_Int8>();
767 }
768 
769 void SAL_CALL SwXCell::acquire( ) noexcept
770 {
771  SwXCellBaseClass::acquire();
772 }
773 
774 void SAL_CALL SwXCell::release( ) noexcept
775 {
776  SolarMutexGuard aGuard;
777 
778  SwXCellBaseClass::release();
779 }
780 
782 {
783  uno::Any aRet = SwXCellBaseClass::queryInterface(aType);
784  if(aRet.getValueType() == cppu::UnoType<void>::get())
785  aRet = SwXText::queryInterface(aType);
786  return aRet;
787 }
788 
790 {
791  const SwStartNode* pSttNd = nullptr;
792 
793  if( m_pStartNode || IsValid() )
794  pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
795 
796  return pSttNd;
797 }
798 
799 uno::Reference< text::XTextCursor >
801 {
802  return createTextCursor();
803 }
804 
805 bool SwXCell::IsValid() const
806 {
807  // FIXME: this is now a const method, to make SwXText::IsValid invisible
808  // but the const_cast here are still ridiculous. TODO: find a better way.
809  SwFrameFormat* pTableFormat = m_pBox ? GetFrameFormat() : nullptr;
810  if(!pTableFormat)
811  {
812  const_cast<SwXCell*>(this)->m_pBox = nullptr;
813  }
814  else
815  {
816  SwTable* pTable = SwTable::FindTable( pTableFormat );
817  SwTableBox const*const pFoundBox =
818  const_cast<SwXCell*>(this)->FindBox(pTable, m_pBox);
819  if (!pFoundBox)
820  {
821  const_cast<SwXCell*>(this)->m_pBox = nullptr;
822  }
823  }
824  return nullptr != m_pBox;
825 }
826 
828 {
829  SolarMutexGuard aGuard;
830  if(!IsValid())
831  return OUString();
834  aFormula.PtrToBoxNm( pTable );
835  return aFormula.GetFormula();
836 }
837 
839 void SwXCell::setFormula(const OUString& rFormula)
840 {
841  SolarMutexGuard aGuard;
842  if(!IsValid())
843  return;
844  // first this text (maybe) needs to be deleted
846  if(SwNodeOffset(USHRT_MAX) == nNdPos)
847  sw_setString( *this, OUString(), true );
848  OUString sFormula(comphelper::string::stripStart(rFormula, ' '));
849  if( !sFormula.isEmpty() && '=' == sFormula[0] )
850  sFormula = sFormula.copy( 1 );
851  SwTableBoxFormula aFormula( sFormula );
852  SwDoc* pMyDoc = GetDoc();
853  UnoActionContext aAction(pMyDoc);
855  SwFrameFormat* pBoxFormat = m_pBox->GetFrameFormat();
856  const SwTableBoxNumFormat* pNumFormat =
857  pBoxFormat->GetAttrSet().GetItemIfSet(RES_BOXATR_FORMAT);
858  if(!pNumFormat
859  || pMyDoc->GetNumberFormatter()->IsTextFormat(pNumFormat->GetValue()))
860  {
861  aSet.Put(SwTableBoxNumFormat(0));
862  }
863  aSet.Put(aFormula);
865  // update table
867  pMyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
868 }
869 
871 {
872  SolarMutexGuard aGuard;
873  // #i112652# a table cell may contain NaN as a value, do not filter that
874  if(IsValid() && !getString().isEmpty())
876  return std::numeric_limits<double>::quiet_NaN();
877 }
878 
879 void SwXCell::setValue(double rValue)
880 {
881  SolarMutexGuard aGuard;
882  sw_setValue( *this, rValue );
883 }
884 
885 table::CellContentType SwXCell::getType()
886 {
887  SolarMutexGuard aGuard;
888 
889  table::CellContentType nRes = table::CellContentType_EMPTY;
890  sal_uInt32 nNdPos = m_pBox->IsFormulaOrValueBox();
891  switch (nNdPos)
892  {
893  case 0 : nRes = table::CellContentType_TEXT; break;
894  case USHRT_MAX : nRes = table::CellContentType_EMPTY; break;
895  case RES_BOXATR_VALUE : nRes = table::CellContentType_VALUE; break;
896  case RES_BOXATR_FORMULA : nRes = table::CellContentType_FORMULA; break;
897  default :
898  OSL_FAIL( "unexpected case" );
899  }
900  return nRes;
901 }
902 
903 void SwXCell::setString(const OUString& aString)
904 {
905  SolarMutexGuard aGuard;
906  sw_setString( *this, aString );
907 }
908 
909 sal_Int32 SwXCell::getError()
910 {
911  SolarMutexGuard aGuard;
912  OUString sContent = getString();
913  return sal_Int32(sContent == SwViewShell::GetShellRes()->aCalc_Error);
914 }
915 
916 uno::Reference<text::XTextCursor> SwXCell::createTextCursor()
917 {
918  SolarMutexGuard aGuard;
919  if(!m_pStartNode && !IsValid())
920  throw uno::RuntimeException();
921  const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
922  SwPosition aPos(*pSttNd);
923  rtl::Reference<SwXTextCursor> const pXCursor =
924  new SwXTextCursor(*GetDoc(), this, CursorType::TableText, aPos);
925  auto& rUnoCursor(pXCursor->GetCursor());
926  rUnoCursor.Move(fnMoveForward, GoInNode);
927  return static_cast<text::XWordCursor*>(pXCursor.get());
928 }
929 
930 uno::Reference<text::XTextCursor> SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
931 {
932  SolarMutexGuard aGuard;
933  SwUnoInternalPaM aPam(*GetDoc());
934  if((!m_pStartNode && !IsValid()) || !::sw::XTextRangeToSwPaM(aPam, xTextPosition))
935  throw uno::RuntimeException();
936  const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
937  // skip sections
938  SwStartNode* p1 = aPam.GetNode().StartOfSectionNode();
939  while(p1->IsSectionNode())
940  p1 = p1->StartOfSectionNode();
941  if( p1 != pSttNd )
942  return nullptr;
943  return static_cast<text::XWordCursor*>(
945  *aPam.GetPoint(), aPam.GetMark()));
946 }
947 
948 uno::Reference< beans::XPropertySetInfo > SwXCell::getPropertySetInfo()
949 {
950  static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
951  return xRef;
952 }
953 
954 void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
955 {
956  SolarMutexGuard aGuard;
957  if(!IsValid())
958  return;
959  // Hack to support hidden property to transfer textDirection
960  if(rPropertyName == "FRMDirection")
961  {
962  SvxFrameDirectionItem aItem(SvxFrameDirection::Environment, RES_FRAMEDIR);
963  aItem.PutValue(aValue, 0);
965  }
966  else if(rPropertyName == "TableRedlineParams")
967  {
968  // Get the table row properties
969  uno::Sequence<beans::PropertyValue> tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
970  comphelper::SequenceAsHashMap aPropMap(tableCellProperties);
971  OUString sRedlineType;
972  if(!(aPropMap.getValue("RedlineType") >>= sRedlineType))
973  throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this));
974 
975  // Create a 'Table Cell Redline' object
976  SwUnoCursorHelper::makeTableCellRedline(*m_pBox, sRedlineType, tableCellProperties);
977 
978 
979  }
980  else
981  {
982  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
983  if ( !pEntry )
984  {
985  // not a table property: ignore it, if it is a paragraph/character property
987  pEntry = rParaPropSet.getPropertyMap().getByName(rPropertyName);
988 
989  if ( pEntry )
990  return;
991  }
992 
993  if(!pEntry)
994  throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
995  if(pEntry->nWID != FN_UNO_CELL_ROW_SPAN)
996  {
997  SwFrameFormat* pBoxFormat = m_pBox->ClaimFrameFormat();
998  SwAttrSet aSet(pBoxFormat->GetAttrSet());
999  m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
1000  pBoxFormat->GetDoc()->SetAttr(aSet, *pBoxFormat);
1001  }
1002  else if(aValue.isExtractableTo(cppu::UnoType<sal_Int32>::get()))
1003  m_pBox->setRowSpan(aValue.get<sal_Int32>());
1004  }
1005 }
1006 
1007 uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
1008 {
1009  SolarMutexGuard aGuard;
1010  if(!IsValid())
1011  return uno::Any();
1012  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1013  if(!pEntry)
1014  throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
1015  switch(pEntry->nWID)
1016  {
1017  case FN_UNO_CELL_ROW_SPAN:
1018  return uno::Any(m_pBox->getRowSpan());
1019  case FN_UNO_TEXT_SECTION:
1020  {
1021  SwFrameFormat* pTableFormat = GetFrameFormat();
1022  SwTable* pTable = SwTable::FindTable(pTableFormat);
1023  SwTableNode* pTableNode = pTable->GetTableNode();
1024  SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
1025  if(!pSectionNode)
1026  return uno::Any();
1027  SwSection& rSect = pSectionNode->GetSection();
1028  return uno::Any(SwXTextSections::GetObject(*rSect.GetFormat()));
1029  }
1030  break;
1031  case FN_UNO_CELL_NAME:
1032  return uno::Any(m_pBox->GetName());
1035  {
1036  //redline can only be returned if it's a living object
1037  return SwXText::getPropertyValue(rPropertyName);
1038  }
1039  break;
1040  case FN_UNO_PARENT_TEXT:
1041  {
1042  if (!m_xParentText.is())
1043  {
1044  const SwStartNode* pSttNd = m_pBox->GetSttNd();
1045  if (!pSttNd)
1046  return uno::Any();
1047 
1048  const SwTableNode* pTableNode = pSttNd->FindTableNode();
1049  if (!pTableNode)
1050  return uno::Any();
1051 
1052  SwPosition aPos(*pTableNode);
1053  SwDoc& rDoc = aPos.GetDoc();
1054  m_xParentText = sw::CreateParentXText(rDoc, aPos);
1055  }
1056 
1057  return uno::Any(m_xParentText);
1058  }
1059  break;
1060  default:
1061  {
1062  const SwAttrSet& rSet = m_pBox->GetFrameFormat()->GetAttrSet();
1063  uno::Any aResult;
1064  m_pPropSet->getPropertyValue(rPropertyName, rSet, aResult);
1065  return aResult;
1066  }
1067  }
1068 }
1069 
1070 void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1071  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1072 
1073 void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1074  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1075 
1076 void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1077  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1078 
1079 void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1080  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1081 
1082 uno::Reference<container::XEnumeration> SwXCell::createEnumeration()
1083 {
1084  SolarMutexGuard aGuard;
1085  if(!IsValid())
1086  return uno::Reference<container::XEnumeration>();
1087  const SwStartNode* pSttNd = m_pBox->GetSttNd();
1088  SwPosition aPos(*pSttNd);
1089  auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
1090  pUnoCursor->Move(fnMoveForward, GoInNode);
1091  // remember table and start node for later travelling
1092  // (used in export of tables in tables)
1094 }
1095 
1097 {
1099 }
1100 
1102 {
1103  return true;
1104 }
1105 
1106 void SwXCell::Notify(const SfxHint& rHint)
1107 {
1108  if(rHint.GetId() == SfxHintId::Dying)
1109  {
1110  m_pTableFormat = nullptr;
1111  }
1112  else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableBox, SwXCell>*>(&rHint))
1113  {
1114  if(!pFindHint->m_pResult && pFindHint->m_pCore == GetTableBox())
1115  pFindHint->m_pResult = this;
1116  }
1117 }
1118 
1120 {
1121  if(!pTableFormat || !pBox)
1122  return nullptr;
1123  if(!pTable)
1124  pTable = SwTable::FindTable(pTableFormat);
1126  if(it == pTable->GetTabSortBoxes().end())
1127  return nullptr;
1128  size_t const nPos = it - pTable->GetTabSortBoxes().begin();
1129  FindUnoInstanceHint<SwTableBox, SwXCell> aHint{pBox};
1130  pTableFormat->GetNotifier().Broadcast(aHint);
1131  return aHint.m_pResult ? aHint.m_pResult.get() : new SwXCell(pTableFormat, pBox, nPos);
1132 }
1133 
1141 {
1142  // check if nFndPos happens to point to the right table box
1143  if( m_nFndPos < pTable->GetTabSortBoxes().size() &&
1144  pBox2 == pTable->GetTabSortBoxes()[ m_nFndPos ] )
1145  return pBox2;
1146 
1147  // if not, seek the entry (and return, if successful)
1148  SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find( pBox2 );
1149  if( it != pTable->GetTabSortBoxes().end() )
1150  {
1151  m_nFndPos = it - pTable->GetTabSortBoxes().begin();
1152  return pBox2;
1153  }
1154 
1155  // box not found: reset nFndPos pointer
1156  m_nFndPos = NOTFOUND;
1157  return nullptr;
1158 }
1159 
1161 {
1162  if(table::CellContentType_TEXT != const_cast<SwXCell*>(this)->getType())
1163  return getValue();
1164  // now we'll try to get a useful numerical value
1165  // from the text in the cell...
1166  sal_uInt32 nFIndex;
1167  SvNumberFormatter* pNumFormatter(const_cast<SvNumberFormatter*>(GetDoc()->GetNumberFormatter()));
1168  // look for SwTableBoxNumFormat value in parents as well
1169  auto pBoxFormat(GetTableBox()->GetFrameFormat());
1170  const SwTableBoxNumFormat* pNumFormat = pBoxFormat->GetAttrSet().GetItemIfSet(RES_BOXATR_FORMAT);
1171 
1172  if (pNumFormat)
1173  {
1174  // please note that the language of the numberformat
1175  // is implicitly coded into the below value as well
1176  nFIndex = pNumFormat->GetValue();
1177 
1178  // since the current value indicates a text format but the call
1179  // to 'IsNumberFormat' below won't work for text formats
1180  // we need to get rid of the part that indicates the text format.
1181  // According to ER this can be done like this:
1182  nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
1183  }
1184  else
1185  {
1186  // system language is probably not the best possible choice
1187  // but since we have to guess anyway (because the language of at
1188  // the text is NOT the one used for the number format!)
1189  // it is at least conform to what is used in
1190  // SwTableShell::Execute when
1191  // SID_ATTR_NUMBERFORMAT_VALUE is set...
1192  LanguageType eLang = LANGUAGE_SYSTEM;
1193  nFIndex = pNumFormatter->GetStandardIndex( eLang );
1194  }
1195  double fTmp;
1196  if (!const_cast<SwDoc*>(GetDoc())->IsNumberFormat(const_cast<SwXCell*>(this)->getString(), nFIndex, fTmp))
1197  return std::numeric_limits<double>::quiet_NaN();
1198  return fTmp;
1199 }
1200 
1202 {
1203  if(!m_pBox)
1204  throw uno::RuntimeException();
1205  // check if table box value item is set
1206  auto pBoxFormat(m_pBox->GetFrameFormat());
1207  const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
1208  return bIsNum ? uno::Any(getValue()) : uno::Any(const_cast<SwXCell*>(this)->getString());
1209 }
1210 
1212  { return "SwXCell"; }
1213 
1214 sal_Bool SwXCell::supportsService(const OUString& rServiceName)
1215  { return cppu::supportsService(this, rServiceName); }
1216 
1217 uno::Sequence< OUString > SwXCell::getSupportedServiceNames()
1218  { return {"com.sun.star.text.CellProperties"}; }
1219 
1221  { return "SwXTextTableRow"; }
1222 
1223 sal_Bool SwXTextTableRow::supportsService(const OUString& rServiceName)
1224  { return cppu::supportsService(this, rServiceName); }
1225 
1227  { return {"com.sun.star.text.TextTableRow"}; }
1228 
1229 
1231  m_pFormat(pFormat),
1232  m_pLine(pLn),
1233  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW))
1234 {
1236 }
1237 
1239 {
1240  SolarMutexGuard aGuard;
1241  EndListeningAll();
1242 }
1243 
1244 uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo()
1245 {
1246  static uno::Reference<beans::XPropertySetInfo> xRef = m_pPropSet->getPropertySetInfo();
1247  return xRef;
1248 }
1249 
1250 void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1251 {
1252  SolarMutexGuard aGuard;
1253  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1254  SwTable* pTable = SwTable::FindTable( pFormat );
1256  if(!pLn)
1257  return;
1258 
1259  // Check for a specific property
1260  if ( rPropertyName == "TableRedlineParams" )
1261  {
1262  // Get the table row properties
1263  uno::Sequence< beans::PropertyValue > tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
1264  comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
1265  OUString sRedlineType;
1266  if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) )
1267  {
1268  throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) );
1269  }
1270 
1271  // Create a 'Table Row Redline' object
1272  SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
1273 
1274  }
1275  else
1276  {
1277  const SfxItemPropertyMapEntry* pEntry =
1278  m_pPropSet->getPropertyMap().getByName(rPropertyName);
1279  SwDoc* pDoc = pFormat->GetDoc();
1280  if (!pEntry)
1281  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1282  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1283  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1284 
1285  switch(pEntry->nWID)
1286  {
1287  case FN_UNO_ROW_HEIGHT:
1289  {
1290  SwFormatFrameSize aFrameSize(pLn->GetFrameFormat()->GetFrameSize());
1291  if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1292  {
1293  bool bSet = *o3tl::doAccess<bool>(aValue);
1295  }
1296  else
1297  {
1298  sal_Int32 nHeight = 0;
1299  aValue >>= nHeight;
1300  Size aSz(aFrameSize.GetSize());
1301  aSz.setHeight( o3tl::toTwips(nHeight, o3tl::Length::mm100) );
1302  aFrameSize.SetSize(aSz);
1303  }
1304  pDoc->SetAttr(aFrameSize, *pLn->ClaimFrameFormat());
1305  }
1306  break;
1307 
1309  {
1310  UnoActionContext aContext(pDoc);
1311  SwTable* pTable2 = SwTable::FindTable( pFormat );
1312  lcl_SetTableSeparators(aValue, pTable2, m_pLine->GetTabBoxes()[0], true, pDoc);
1313  }
1314  break;
1315 
1316  default:
1317  {
1318  SwFrameFormat* pLnFormat = pLn->ClaimFrameFormat();
1319  SwAttrSet aSet(pLnFormat->GetAttrSet());
1320  m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1321  pDoc->SetAttr(aSet, *pLnFormat);
1322  }
1323  }
1324  }
1325 }
1326 
1327 uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName)
1328 {
1329  SolarMutexGuard aGuard;
1330  uno::Any aRet;
1331  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1332  SwTable* pTable = SwTable::FindTable( pFormat );
1334  if(pLn)
1335  {
1336  const SfxItemPropertyMapEntry* pEntry =
1337  m_pPropSet->getPropertyMap().getByName(rPropertyName);
1338  if (!pEntry)
1339  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1340 
1341  switch(pEntry->nWID)
1342  {
1343  case FN_UNO_ROW_HEIGHT:
1345  {
1346  const SwFormatFrameSize& rSize = pLn->GetFrameFormat()->GetFrameSize();
1347  if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1348  {
1349  aRet <<= SwFrameSize::Variable == rSize.GetHeightSizeType();
1350  }
1351  else
1352  aRet <<= static_cast<sal_Int32>(convertTwipToMm100(rSize.GetSize().Height()));
1353  }
1354  break;
1355 
1357  {
1358  lcl_GetTableSeparators(aRet, pTable, m_pLine->GetTabBoxes()[0], true);
1359  }
1360  break;
1361 
1362  default:
1363  {
1364  const SwAttrSet& rSet = pLn->GetFrameFormat()->GetAttrSet();
1365  m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1366  }
1367  }
1368  }
1369  return aRet;
1370 }
1371 
1372 void SwXTextTableRow::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1373  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1374 
1375 void SwXTextTableRow::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1376  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1377 
1378 void SwXTextTableRow::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1379  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1380 
1381 void SwXTextTableRow::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1382  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1383 
1385 {
1386  if(rHint.GetId() == SfxHintId::Dying)
1387  {
1388  m_pFormat = nullptr;
1389  } else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableLine, SwXTextTableRow>*>(&rHint))
1390  {
1391  if(!pFindHint->m_pCore && pFindHint->m_pCore == m_pLine)
1392  pFindHint->m_pResult = this;
1393  }
1394 }
1395 
1397 {
1398  for(const auto& pCurrentLine : pTable->GetTabLines())
1399  if(pCurrentLine == pLine)
1400  return pCurrentLine;
1401  return nullptr;
1402 }
1403 
1404 // SwXTextTableCursor
1405 
1407  { return "SwXTextTableCursor"; }
1408 
1409 sal_Bool SwXTextTableCursor::supportsService(const OUString& rServiceName)
1410  { return cppu::supportsService(this, rServiceName); }
1411 
1412 void SwXTextTableCursor::acquire() noexcept
1413 {
1414  SwXTextTableCursor_Base::acquire();
1415 }
1416 
1417 void SwXTextTableCursor::release() noexcept
1418 {
1419  SolarMutexGuard aGuard;
1420  SwXTextTableCursor_Base::release();
1421 }
1422 
1423 css::uno::Any SAL_CALL
1424 SwXTextTableCursor::queryInterface( const css::uno::Type& _rType )
1425 {
1426  css::uno::Any aReturn = SwXTextTableCursor_Base::queryInterface( _rType );
1427  if ( !aReturn.hasValue() )
1428  aReturn = OTextCursorHelper::queryInterface( _rType );
1429  return aReturn;
1430 }
1431 
1432 const SwPaM* SwXTextTableCursor::GetPaM() const { return &GetCursor(); }
1438 
1440  { return {"com.sun.star.text.TextTableCursor"}; }
1441 
1443  : m_pFrameFormat(pFrameFormat)
1444  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1445 {
1447  SwDoc* pDoc = m_pFrameFormat->GetDoc();
1448  const SwStartNode* pSttNd = pBox->GetSttNd();
1449  SwPosition aPos(*pSttNd);
1450  m_pUnoCursor = pDoc->CreateUnoCursor(aPos, true);
1452  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1453  rTableCursor.MakeBoxSels();
1454 }
1455 
1457  : m_pFrameFormat(&rTableFormat)
1458  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1459 {
1461  m_pUnoCursor = pTableSelection->GetDoc().CreateUnoCursor(*pTableSelection->GetPoint(), true);
1462  if(pTableSelection->HasMark())
1463  {
1464  m_pUnoCursor->SetMark();
1465  *m_pUnoCursor->GetMark() = *pTableSelection->GetMark();
1466  }
1467  const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
1468  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1469  for(auto pBox : rBoxes)
1470  rTableCursor.InsertBox(*pBox);
1471  rTableCursor.MakeBoxSels();
1472 }
1473 
1475 {
1476  SolarMutexGuard aGuard;
1477  SwUnoCursor& rUnoCursor = GetCursor();
1478  SwUnoTableCursor* pTableCursor = dynamic_cast<SwUnoTableCursor*>(&rUnoCursor);
1480  if(!pTableCursor)
1481  return OUString();
1482  pTableCursor->MakeBoxSels();
1483  const SwStartNode* pNode = pTableCursor->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
1484  const SwTable* pTable = SwTable::FindTable(GetFrameFormat());
1485  const SwTableBox* pEndBox = pTable->GetTableBox(pNode->GetIndex());
1486  if(pTableCursor->HasMark())
1487  {
1488  pNode = pTableCursor->GetMark()->nNode.GetNode().FindTableBoxStartNode();
1489  const SwTableBox* pStartBox = pTable->GetTableBox(pNode->GetIndex());
1490  if(pEndBox != pStartBox)
1491  {
1492  // need to switch start and end?
1493  if(*pTableCursor->GetPoint() < *pTableCursor->GetMark())
1494  std::swap(pStartBox, pEndBox);
1495  return pStartBox->GetName() + ":" + pEndBox->GetName();
1496  }
1497  }
1498  return pEndBox->GetName();
1499 }
1500 
1501 sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool bExpand)
1502 {
1503  SolarMutexGuard aGuard;
1504  SwUnoCursor& rUnoCursor = GetCursor();
1505  auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1506  lcl_CursorSelect(rTableCursor, bExpand);
1507  return rTableCursor.GotoTableBox(sCellName);
1508 }
1509 
1511 {
1512  SolarMutexGuard aGuard;
1513  SwUnoCursor& rUnoCursor = GetCursor();
1514  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1515  lcl_CursorSelect(rTableCursor, bExpand);
1516  return rTableCursor.Left(Count);
1517 }
1518 
1520 {
1521  SolarMutexGuard aGuard;
1522  SwUnoCursor& rUnoCursor = GetCursor();
1523  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1524  lcl_CursorSelect(rTableCursor, bExpand);
1525  return rTableCursor.Right(Count);
1526 }
1527 
1528 sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool bExpand)
1529 {
1530  SolarMutexGuard aGuard;
1531  SwUnoCursor& rUnoCursor = GetCursor();
1532  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1533  lcl_CursorSelect(rTableCursor, bExpand);
1534  return rTableCursor.UpDown(true, Count, nullptr, 0,
1536 }
1537 
1539 {
1540  SolarMutexGuard aGuard;
1541  SwUnoCursor& rUnoCursor = GetCursor();
1542  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1543  lcl_CursorSelect(rTableCursor, bExpand);
1544  return rTableCursor.UpDown(false, Count, nullptr, 0,
1546 }
1547 
1549 {
1550  SolarMutexGuard aGuard;
1551  SwUnoCursor& rUnoCursor = GetCursor();
1552  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1553  lcl_CursorSelect(rTableCursor, bExpand);
1554  rTableCursor.MoveTable(GotoCurrTable, fnTableStart);
1555 }
1556 
1558 {
1559  SolarMutexGuard aGuard;
1560  SwUnoCursor& rUnoCursor = GetCursor();
1561  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1562  lcl_CursorSelect(rTableCursor, bExpand);
1563  rTableCursor.MoveTable(GotoCurrTable, fnTableEnd);
1564 }
1565 
1567 {
1568  SolarMutexGuard aGuard;
1569  SwUnoCursor& rUnoCursor = GetCursor();
1570 
1571  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1572  {
1573  // HACK: remove pending actions for selecting old style tables
1574  UnoActionRemoveContext aRemoveContext(rTableCursor);
1575  }
1576  rTableCursor.MakeBoxSels();
1577  bool bResult;
1578  {
1579  UnoActionContext aContext(&rUnoCursor.GetDoc());
1580  bResult = TableMergeErr::Ok == rTableCursor.GetDoc().MergeTable(rTableCursor);
1581  }
1582  if(bResult)
1583  {
1584  size_t nCount = rTableCursor.GetSelectedBoxesCount();
1585  while (nCount--)
1586  rTableCursor.DeleteBox(nCount);
1587  }
1588  rTableCursor.MakeBoxSels();
1589  return bResult;
1590 }
1591 
1593 {
1594  SolarMutexGuard aGuard;
1595  if (Count <= 0)
1596  throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast<cppu::OWeakObject*>(this));
1597  SwUnoCursor& rUnoCursor = GetCursor();
1598  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1599  {
1600  // HACK: remove pending actions for selecting old style tables
1601  UnoActionRemoveContext aRemoveContext(rTableCursor);
1602  }
1603  rTableCursor.MakeBoxSels();
1604  bool bResult;
1605  {
1606  UnoActionContext aContext(&rUnoCursor.GetDoc());
1607  bResult = rTableCursor.GetDoc().SplitTable(rTableCursor.GetSelectedBoxes(), !Horizontal, Count);
1608  }
1609  rTableCursor.MakeBoxSels();
1610  return bResult;
1611 }
1612 
1613 uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInfo()
1614 {
1615  static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1616  return xRef;
1617 }
1618 
1619 void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1620 {
1621  SolarMutexGuard aGuard;
1622  SwUnoCursor& rUnoCursor = GetCursor();
1623  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1624  if(!pEntry)
1625  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1626  if(pEntry->nFlags & beans::PropertyAttribute::READONLY)
1627  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1628  {
1629  auto pSttNode = rUnoCursor.GetNode().StartOfSectionNode();
1630  const SwTableNode* pTableNode = pSttNode->FindTableNode();
1631  lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1632  }
1633  auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1634  rTableCursor.MakeBoxSels();
1635  SwDoc& rDoc = rUnoCursor.GetDoc();
1636  switch(pEntry->nWID)
1637  {
1639  {
1640  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1641  SwDoc::GetBoxAttr(rUnoCursor, aBrush);
1642  aBrush->PutValue(aValue, pEntry->nMemberId);
1643  rDoc.SetBoxAttr(rUnoCursor, *aBrush);
1644 
1645  }
1646  break;
1647  case RES_BOXATR_FORMAT:
1648  {
1649  SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
1650  aNumberFormat.PutValue(aValue, 0);
1651  rDoc.SetBoxAttr(rUnoCursor, aNumberFormat);
1652  }
1653  break;
1654  case FN_UNO_PARA_STYLE:
1655  SwUnoCursorHelper::SetTextFormatColl(aValue, rUnoCursor);
1656  break;
1657  default:
1658  {
1659  SfxItemSet aItemSet(rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID);
1660  SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(),
1661  aItemSet);
1662 
1664  *pEntry, aValue, rTableCursor.GetSelRing(), aItemSet))
1665  {
1666  m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
1667  }
1668  SwUnoCursorHelper::SetCursorAttr(rTableCursor.GetSelRing(),
1669  aItemSet, SetAttrMode::DEFAULT, true);
1670  }
1671  }
1672 }
1673 
1674 uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName)
1675 {
1676  SolarMutexGuard aGuard;
1677  SwUnoCursor& rUnoCursor = GetCursor();
1678  {
1679  auto pSttNode = rUnoCursor.GetNode().StartOfSectionNode();
1680  const SwTableNode* pTableNode = pSttNode->FindTableNode();
1681  lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1682  }
1683  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1684  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1685  if(!pEntry)
1686  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1687  rTableCursor.MakeBoxSels();
1688  uno::Any aResult;
1689  switch(pEntry->nWID)
1690  {
1692  {
1693  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1694  if (SwDoc::GetBoxAttr(rUnoCursor, aBrush))
1695  aBrush->QueryValue(aResult, pEntry->nMemberId);
1696  }
1697  break;
1698  case RES_BOXATR_FORMAT:
1699  // TODO: GetAttr for table selections in a Doc is missing
1700  throw uno::RuntimeException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1701  break;
1702  case FN_UNO_PARA_STYLE:
1703  {
1704  auto pFormat(SwUnoCursorHelper::GetCurTextFormatColl(rUnoCursor, false));
1705  if(pFormat)
1706  aResult <<= pFormat->GetName();
1707  }
1708  break;
1709  default:
1710  {
1713  RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER>
1714  aSet(rTableCursor.GetDoc().GetAttrPool());
1715  SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(), aSet);
1716  m_pPropSet->getPropertyValue(*pEntry, aSet, aResult);
1717  }
1718  }
1719  return aResult;
1720 }
1721 
1722 void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1723  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1724 
1725 void SwXTextTableCursor::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1726  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1727 
1728 void SwXTextTableCursor::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1729  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1730 
1731 void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1732  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1733 
1735 {
1736  if(rHint.GetId() == SfxHintId::Dying)
1737  m_pFrameFormat = nullptr;
1738 }
1739 
1740 
1741 // SwXTextTable ===========================================================
1742 
1743 namespace {
1744 
1745 class SwTableProperties_Impl
1746 {
1748 
1749 public:
1750  SwTableProperties_Impl();
1751 
1752  void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal);
1753  bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny);
1754  void AddItemToSet(SfxItemSet& rSet, std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1755  sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips = false);
1756  void ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc);
1757 };
1758 
1759 }
1760 
1761 SwTableProperties_Impl::SwTableProperties_Impl()
1762  { }
1763 
1764 void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rVal)
1765  {
1766  m_aAnyMap.SetValue(nWhichId, nMemberId, rVal);
1767  }
1768 
1769 bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny )
1770  {
1771  return m_aAnyMap.FillValue(nWhichId, nMemberId, rpAny);
1772  }
1773 
1774 void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet,
1775  std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1776  sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips)
1777 {
1778  std::vector< std::pair<sal_uInt16, const uno::Any* > > vMemberAndAny;
1779  for(sal_uInt16 nMember : vMember)
1780  {
1781  const uno::Any* pAny = nullptr;
1782  GetProperty(nWhich, nMember, pAny);
1783  if(pAny)
1784  vMemberAndAny.emplace_back(nMember, pAny);
1785  }
1786  if(!vMemberAndAny.empty())
1787  {
1788  std::unique_ptr<SfxPoolItem> aItem(aItemFactory());
1789  for(const auto& aMemberAndAny : vMemberAndAny)
1790  aItem->PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
1791  rSet.Put(*aItem);
1792  }
1793 }
1794 void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
1795 {
1801  RES_KEEP, RES_KEEP,
1802  RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT>
1803  aSet(rDoc.GetAttrPool());
1804  const uno::Any* pRepHead;
1805  const SwFrameFormat &rFrameFormat = *rTable.GetFrameFormat();
1806  if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead ))
1807  {
1808  bool bVal(pRepHead->get<bool>());
1809  const_cast<SwTable&>(rTable).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER
1810  }
1811 
1812  AddItemToSet(aSet, [&rFrameFormat]() { return rFrameFormat.makeBackgroundBrushItem(); }, RES_BACKGROUND, {
1816  MID_GRAPHIC,
1817  MID_GRAPHIC_FILTER });
1818 
1819  bool bPutBreak = true;
1820  const uno::Any* pPage;
1821  if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage))
1822  {
1823  OUString sPageStyle = pPage->get<OUString>();
1824  if(!sPageStyle.isEmpty())
1825  {
1827  const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle);
1828  if(pDesc)
1829  {
1830  SwFormatPageDesc aDesc(pDesc);
1831  const uno::Any* pPgNo;
1833  {
1834  aDesc.SetNumOffset(pPgNo->get<sal_Int16>());
1835  }
1836  aSet.Put(aDesc);
1837  bPutBreak = false;
1838  }
1839 
1840  }
1841  }
1842 
1843  if(bPutBreak)
1844  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetBreak().Clone()); }, RES_BREAK, {0});
1845  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetShadow().Clone()); }, RES_SHADOW, {0}, true);
1846  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetKeep().Clone()); }, RES_KEEP, {0});
1847  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetHoriOrient().Clone()); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
1848 
1849  const uno::Any* pSzRel(nullptr);
1850  GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel);
1851  const uno::Any* pRelWidth(nullptr);
1852  GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth);
1853  const uno::Any* pWidth(nullptr);
1854  GetProperty(FN_TABLE_WIDTH, 0xff, pWidth);
1855 
1856  bool bPutSize = pWidth != nullptr;
1858  if(pWidth)
1859  {
1860  aSz.PutValue(*pWidth, MID_FRMSIZE_WIDTH);
1861  bPutSize = true;
1862  }
1863  if(pSzRel && pSzRel->get<bool>() && pRelWidth)
1864  {
1865  aSz.PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS);
1866  bPutSize = true;
1867  }
1868  if(bPutSize)
1869  {
1870  if(!aSz.GetWidth())
1871  aSz.SetWidth(MINLAY);
1872  aSet.Put(aSz);
1873  }
1874  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetLRSpace().Clone()); }, RES_LR_SPACE, {
1877  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetULSpace().Clone()); }, RES_UL_SPACE, {
1880  const::uno::Any* pSplit(nullptr);
1881  if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit))
1882  {
1883  SwFormatLayoutSplit aSp(pSplit->get<bool>());
1884  aSet.Put(aSp);
1885  }
1886  if(aSet.Count())
1887  {
1888  rDoc.SetAttr(aSet, *rTable.GetFrameFormat());
1889  }
1890 }
1891 
1893  : public SvtListener
1894 {
1895 private:
1897 
1898 public:
1899  uno::WeakReference<uno::XInterface> m_wThis;
1900  std::mutex m_Mutex; // just for OInterfaceContainerHelper4
1903 
1905 
1906  css::uno::WeakReference<css::table::XTableRows> m_xRows;
1907  css::uno::WeakReference<css::table::XTableColumns> m_xColumns;
1908 
1911 
1912  // Descriptor-interface
1913  std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
1914  OUString m_sTableName;
1915  unsigned short m_nRows;
1916  unsigned short m_nColumns;
1917 
1918  explicit Impl(SwFrameFormat* const pFrameFormat)
1919  : m_pFrameFormat(pFrameFormat)
1920  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE))
1921  , m_bFirstRowAsLabel(false)
1922  , m_bFirstColumnAsLabel(false)
1923  , m_pTableProps(pFrameFormat ? nullptr : new SwTableProperties_Impl)
1924  , m_nRows(pFrameFormat ? 0 : 2)
1925  , m_nColumns(pFrameFormat ? 0 : 2)
1926  {
1927  if(m_pFrameFormat)
1928  StartListening(m_pFrameFormat->GetNotifier());
1929  }
1930 
1932  void SetFrameFormat(SwFrameFormat& rFrameFormat)
1933  {
1934  EndListeningAll();
1935  m_pFrameFormat = &rFrameFormat;
1936  StartListening(m_pFrameFormat->GetNotifier());
1937  }
1938 
1939  bool IsDescriptor() const { return m_pTableProps != nullptr; }
1940 
1941  // note: lock mutex before calling this to avoid concurrent update
1942  static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
1943  {
1944  sal_uInt16 const nRowCount(rThis.m_pImpl->GetRowCount());
1945  sal_uInt16 const nColCount(rThis.m_pImpl->GetColumnCount());
1946  if (!nRowCount || !nColCount)
1947  {
1948  throw uno::RuntimeException("Table too complex",
1949  static_cast<cppu::OWeakObject*>(&rThis));
1950  }
1951  return std::make_pair(nRowCount, nColCount);
1952  }
1953 
1954  sal_uInt16 GetRowCount();
1955  sal_uInt16 GetColumnCount();
1956 
1957  virtual void Notify(const SfxHint&) override;
1958 
1959 };
1960 
1961 const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
1962 {
1963  static const comphelper::UnoIdInit theSwXTextTableUnoTunnelId;
1964  return theSwXTextTableUnoTunnelId.getSeq();
1965 }
1966 
1967 sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
1968 {
1969  return comphelper::getSomethingImpl(rId, this);
1970 }
1971 
1972 
1974  : m_pImpl(new Impl(nullptr))
1975 {
1976 }
1977 
1979  : m_pImpl(new Impl(&rFrameFormat))
1980 {
1981 }
1982 
1984 {
1985 }
1986 
1987 uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat)
1988 {
1989  uno::Reference<text::XTextTable> xTable;
1990  if(pFrameFormat)
1991  xTable.set(pFrameFormat->GetXObject(), uno::UNO_QUERY); // cached?
1992  if(xTable.is())
1993  return xTable;
1994  SwXTextTable* const pNew( pFrameFormat ? new SwXTextTable(*pFrameFormat) : new SwXTextTable());
1995  xTable.set(pNew);
1996  if(pFrameFormat)
1997  pFrameFormat->SetXObject(xTable);
1998  // need a permanent Reference to initialize m_wThis
1999  pNew->m_pImpl->m_wThis = xTable;
2000  return xTable;
2001 }
2002 
2004 {
2005  return m_pImpl->GetFrameFormat();
2006 }
2007 
2008 void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC)
2009 {
2010  if (!m_pImpl->IsDescriptor() || nR <= 0 || nC <= 0 || nR >= SAL_MAX_UINT16 || nC >= SAL_MAX_UINT16)
2011  throw uno::RuntimeException();
2012  m_pImpl->m_nRows = o3tl::narrowing<sal_uInt16>(nR);
2013  m_pImpl->m_nColumns = o3tl::narrowing<sal_uInt16>(nC);
2014 }
2015 
2016 uno::Reference<table::XTableRows> SAL_CALL SwXTextTable::getRows()
2017 {
2018  SolarMutexGuard aGuard;
2019  uno::Reference<table::XTableRows> xResult(m_pImpl->m_xRows);
2020  if(xResult.is())
2021  return xResult;
2022  if(SwFrameFormat* pFormat = GetFrameFormat())
2023  m_pImpl->m_xRows = xResult = new SwXTableRows(*pFormat);
2024  if(!xResult.is())
2025  throw uno::RuntimeException();
2026  return xResult;
2027 }
2028 
2029 uno::Reference<table::XTableColumns> SAL_CALL SwXTextTable::getColumns()
2030 {
2031  SolarMutexGuard aGuard;
2032  uno::Reference<table::XTableColumns> xResult(m_pImpl->m_xColumns);
2033  if(xResult.is())
2034  return xResult;
2035  if(SwFrameFormat* pFormat = GetFrameFormat())
2036  m_pImpl->m_xColumns = xResult = new SwXTableColumns(*pFormat);
2037  if(!xResult.is())
2038  throw uno::RuntimeException();
2039  return xResult;
2040 }
2041 
2042 uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellName)
2043 {
2044  SolarMutexGuard aGuard;
2045  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2046  SwTable* pTable = SwTable::FindTable(pFormat);
2047  SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2048  if(!pBox)
2049  return nullptr;
2050  return SwXCell::CreateXCell(pFormat, pBox);
2051 }
2052 
2053 uno::Sequence<OUString> SwXTextTable::getCellNames()
2054 {
2055  SolarMutexGuard aGuard;
2056  SwFrameFormat* pFormat(GetFrameFormat());
2057  if(!pFormat)
2058  return {};
2059  SwTable* pTable = SwTable::FindTable(pFormat);
2060  // exists at the table and at all boxes
2061  SwTableLines& rTableLines = pTable->GetTabLines();
2062  std::vector<OUString> aAllNames;
2063  lcl_InspectLines(rTableLines, aAllNames);
2064  return comphelper::containerToSequence(aAllNames);
2065 }
2066 
2067 uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(const OUString& sCellName)
2068 {
2069  SolarMutexGuard aGuard;
2070  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2071  SwTable* pTable = SwTable::FindTable(pFormat);
2072  SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2073  if(!pBox || pBox->getRowSpan() == 0)
2074  throw uno::RuntimeException();
2075  return new SwXTextTableCursor(pFormat, pBox);
2076 }
2077 
2078 void SAL_CALL
2079 SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
2080 {
2081  SolarMutexGuard aGuard;
2082 
2083  // attach() must only be called once
2084  if (!m_pImpl->IsDescriptor()) /* already attached ? */
2085  throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
2086 
2087  uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
2088  SwXTextRange* pRange(comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel));
2089  OTextCursorHelper* pCursor(comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel));
2090  SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
2091  if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns)
2092  throw lang::IllegalArgumentException();
2093  SwUnoInternalPaM aPam(*pDoc);
2094  // this now needs to return TRUE
2095  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
2096  {
2097  UnoActionContext aCont(pDoc);
2098 
2100  const SwTable* pTable(nullptr);
2101  if( 0 != aPam.Start()->nContent.GetIndex() )
2102  {
2103  pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false);
2104  }
2105  //TODO: if it is the last paragraph than add another one!
2106  if(aPam.HasMark())
2107  {
2109  aPam.DeleteMark();
2110  }
2112  *aPam.GetPoint(),
2113  m_pImpl->m_nRows,
2114  m_pImpl->m_nColumns,
2115  text::HoriOrientation::FULL);
2116  if(pTable)
2117  {
2118  // here, the properties of the descriptor need to be analyzed
2119  m_pImpl->m_pTableProps->ApplyTableAttr(*pTable, *pDoc);
2120  SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
2121  lcl_FormatTable(pTableFormat);
2122 
2123  m_pImpl->SetFrameFormat(*pTableFormat);
2124 
2125  if (!m_pImpl->m_sTableName.isEmpty())
2126  {
2127  sal_uInt16 nIndex = 1;
2128  OUString sTmpNameIndex(m_pImpl->m_sTableName);
2129  while(pDoc->FindTableFormatByName(sTmpNameIndex, true) && nIndex < USHRT_MAX)
2130  {
2131  sTmpNameIndex = m_pImpl->m_sTableName + OUString::number(nIndex++);
2132  }
2133  pDoc->SetTableName( *pTableFormat, sTmpNameIndex);
2134  }
2135 
2136  const::uno::Any* pName;
2137  if (m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
2138  setName(pName->get<OUString>());
2139  m_pImpl->m_pTableProps.reset();
2140  }
2141  pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
2142  }
2143 }
2144 
2145 uno::Reference<text::XTextRange> SwXTextTable::getAnchor()
2146 {
2147  SolarMutexGuard aGuard;
2148  SwTableFormat *const pFormat = static_cast<SwTableFormat*>(
2149  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
2150  return new SwXTextRange(*pFormat);
2151 }
2152 
2154 {
2155  SolarMutexGuard aGuard;
2156  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2157  SwTable* pTable = SwTable::FindTable(pFormat);
2158  SwSelBoxes aSelBoxes;
2159  for(auto& rBox : pTable->GetTabSortBoxes() )
2160  aSelBoxes.insert(rBox);
2161  pFormat->GetDoc()->DeleteRowCol(aSelBoxes, SwDoc::RowColMode::DeleteProtected);
2162 }
2163 
2165  const uno::Reference<lang::XEventListener> & xListener)
2166 {
2167  // no need to lock here as m_pImpl is const and container threadsafe
2168  std::unique_lock aGuard(m_pImpl->m_Mutex);
2169  m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
2170 }
2171 
2173  const uno::Reference< lang::XEventListener > & xListener)
2174 {
2175  // no need to lock here as m_pImpl is const and container threadsafe
2176  std::unique_lock aGuard(m_pImpl->m_Mutex);
2177  m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
2178 }
2179 
2180 uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
2181 {
2182  SolarMutexGuard aGuard;
2183  SwFrameFormat* pFormat(GetFrameFormat());
2184  // sheet is unimportant
2185  if(nColumn >= 0 && nRow >= 0 && pFormat)
2186  {
2187  auto pXCell = lcl_CreateXCell(pFormat, nColumn, nRow);
2188  if(pXCell)
2189  return pXCell;
2190  }
2191  throw lang::IndexOutOfBoundsException();
2192 }
2193 
2194 namespace {
2195 
2196 uno::Reference<table::XCellRange> GetRangeByName(
2197  SwFrameFormat* pFormat, SwTable const * pTable,
2198  const OUString& rTLName, const OUString& rBRName,
2199  SwRangeDescriptor const & rDesc)
2200 {
2201  const SwTableBox* pTLBox = pTable->GetTableBox(rTLName);
2202  if(!pTLBox)
2203  return nullptr;
2204  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2205  SwPosition aPos(*pSttNd);
2206  // set cursor to the upper-left cell of the range
2207  auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
2208  pUnoCursor->Move(fnMoveForward, GoInNode);
2209  pUnoCursor->SetRemainInSection(false);
2210  const SwTableBox* pBRBox(pTable->GetTableBox(rBRName));
2211  if(!pBRBox)
2212  return nullptr;
2213  pUnoCursor->SetMark();
2214  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
2215  pUnoCursor->Move( fnMoveForward, GoInNode );
2216  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2217  // HACK: remove pending actions for selecting old style tables
2218  UnoActionRemoveContext aRemoveContext(rCursor);
2219  rCursor.MakeBoxSels();
2220  // pUnoCursor will be provided and will not be deleted
2221  return SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, rDesc);
2222 }
2223 
2224 } // namespace
2225 
2226 uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
2227 {
2228  SolarMutexGuard aGuard;
2229  SwFrameFormat* pFormat(GetFrameFormat());
2230  if(pFormat &&
2231  nLeft <= nRight && nTop <= nBottom &&
2232  nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
2233  {
2234  SwTable* pTable = SwTable::FindTable(pFormat);
2235  if(!pTable->IsTableComplex())
2236  {
2237  SwRangeDescriptor aDesc;
2238  aDesc.nTop = nTop;
2239  aDesc.nBottom = nBottom;
2240  aDesc.nLeft = nLeft;
2241  aDesc.nRight = nRight;
2242  const OUString sTLName = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
2243  const OUString sBRName = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
2244  // please note that according to the 'if' statement at the begin
2245  // sTLName:sBRName already denotes the normalized range string
2246  return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2247  }
2248  }
2249  throw lang::IndexOutOfBoundsException();
2250 }
2251 
2252 uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUString& sRange)
2253 {
2254  SolarMutexGuard aGuard;
2255  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2256  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2257  sal_Int32 nPos = 0;
2258  const OUString sTLName(sRange.getToken(0, ':', nPos));
2259  const OUString sBRName(sRange.getToken(0, ':', nPos));
2260  if(sTLName.isEmpty() || sBRName.isEmpty())
2261  throw uno::RuntimeException();
2262  SwRangeDescriptor aDesc;
2263  aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
2264  SwXTextTable::GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
2265  SwXTextTable::GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
2266 
2267  // we should normalize the range now (e.g. A5:C1 will become A1:C5)
2268  // since (depending on what is done later) it will be troublesome
2269  // elsewhere when the cursor in the implementation does not
2270  // point to the top-left and bottom-right cells
2271  aDesc.Normalize();
2272  return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2273 }
2274 
2275 uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
2276 {
2277  SolarMutexGuard aGuard;
2278  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2279  uno::Reference<sheet::XCellRangeData> const xAllRange(
2280  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2281  uno::UNO_QUERY_THROW);
2282  return xAllRange->getDataArray();
2283 }
2284 
2285 void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
2286 {
2287  SolarMutexGuard aGuard;
2288  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2289  uno::Reference<sheet::XCellRangeData> const xAllRange(
2290  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2291  uno::UNO_QUERY_THROW);
2292  return xAllRange->setDataArray(rArray);
2293 }
2294 
2295 uno::Sequence< uno::Sequence< double > > SwXTextTable::getData()
2296 {
2297  SolarMutexGuard aGuard;
2298  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2299  uno::Reference<chart::XChartDataArray> const xAllRange(
2300  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2301  uno::UNO_QUERY_THROW);
2302  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2303  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2304  return xAllRange->getData();
2305 }
2306 
2307 void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
2308 {
2309  SolarMutexGuard aGuard;
2310  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2311  uno::Reference<chart::XChartDataArray> const xAllRange(
2312  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2313  uno::UNO_QUERY_THROW);
2314  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2315  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2316  xAllRange->setData(rData);
2317  // this is rather inconsistent: setData on XTextTable sends events, but e.g. CellRanges do not
2318  std::unique_lock aGuard2(m_pImpl->m_Mutex);
2319  lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2320 }
2321 
2322 uno::Sequence<OUString> SwXTextTable::getRowDescriptions()
2323 {
2324  SolarMutexGuard aGuard;
2325  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2326  uno::Reference<chart::XChartDataArray> const xAllRange(
2327  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2328  uno::UNO_QUERY_THROW);
2329  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2330  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2331  return xAllRange->getRowDescriptions();
2332 }
2333 
2334 void SwXTextTable::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
2335 {
2336  SolarMutexGuard aGuard;
2337  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2338  uno::Reference<chart::XChartDataArray> const xAllRange(
2339  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2340  uno::UNO_QUERY_THROW);
2341  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2342  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2343  xAllRange->setRowDescriptions(rRowDesc);
2344 }
2345 
2346 uno::Sequence<OUString> SwXTextTable::getColumnDescriptions()
2347 {
2348  SolarMutexGuard aGuard;
2349  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2350  uno::Reference<chart::XChartDataArray> const xAllRange(
2351  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2352  uno::UNO_QUERY_THROW);
2353  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2354  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2355  return xAllRange->getColumnDescriptions();
2356 }
2357 
2358 void SwXTextTable::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
2359 {
2360  SolarMutexGuard aGuard;
2361  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2362  uno::Reference<chart::XChartDataArray> const xAllRange(
2363  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2364  uno::UNO_QUERY_THROW);
2365  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2366  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2367  return xAllRange->setColumnDescriptions(rColumnDesc);
2368 }
2369 
2371  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2372 {
2373  // no need to lock here as m_pImpl is const and container threadsafe
2374  std::unique_lock aGuard(m_pImpl->m_Mutex);
2375  m_pImpl->m_ChartListeners.addInterface(aGuard, xListener);
2376 }
2377 
2379  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2380 {
2381  // no need to lock here as m_pImpl is const and container threadsafe
2382  std::unique_lock aGuard(m_pImpl->m_Mutex);
2383  m_pImpl->m_ChartListeners.removeInterface(aGuard, xListener);
2384 }
2385 
2387 {
2388  // We use DBL_MIN because starcalc does (which uses it because chart
2389  // wants it that way!)
2390  return ( nNumber == DBL_MIN );
2391 }
2392 
2394 {
2395  // We use DBL_MIN because starcalc does (which uses it because chart
2396  // wants it that way!)
2397  return DBL_MIN;
2398 }
2399 
2400 uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor()
2401 {
2402  SolarMutexGuard aGuard;
2403 
2405 }
2406 
2407 void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2408 {
2409  SolarMutexGuard aGuard;
2410  SwSortOptions aSortOpt;
2411  SwFrameFormat* pFormat = GetFrameFormat();
2412  if(!(pFormat &&
2413  SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)))
2414  return;
2415 
2416  SwTable* pTable = SwTable::FindTable( pFormat );
2417  SwSelBoxes aBoxes;
2418  const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2419  for (size_t n = 0; n < rTBoxes.size(); ++n)
2420  {
2421  SwTableBox* pBox = rTBoxes[ n ];
2422  aBoxes.insert( pBox );
2423  }
2424  UnoActionContext aContext( pFormat->GetDoc() );
2425  pFormat->GetDoc()->SortTable(aBoxes, aSortOpt);
2426 }
2427 
2428 void SwXTextTable::autoFormat(const OUString& sAutoFormatName)
2429 {
2430  SolarMutexGuard aGuard;
2431  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2432  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2433  SwTableAutoFormatTable aAutoFormatTable;
2434  aAutoFormatTable.Load();
2435  for (size_t i = aAutoFormatTable.size(); i;)
2436  if( sAutoFormatName == aAutoFormatTable[ --i ].GetName() )
2437  {
2438  SwSelBoxes aBoxes;
2439  const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2440  for (size_t n = 0; n < rTBoxes.size(); ++n)
2441  {
2442  SwTableBox* pBox = rTBoxes[ n ];
2443  aBoxes.insert( pBox );
2444  }
2445  UnoActionContext aContext( pFormat->GetDoc() );
2446  pFormat->GetDoc()->SetTableAutoFormat( aBoxes, aAutoFormatTable[i] );
2447  break;
2448  }
2449 }
2450 
2451 uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo()
2452 {
2453  static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
2454  return xRef;
2455 }
2456 
2457 void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
2458 {
2459  SolarMutexGuard aGuard;
2460  SwFrameFormat* pFormat = GetFrameFormat();
2461  if(!aValue.hasValue())
2462  throw lang::IllegalArgumentException();
2463  const SfxItemPropertyMapEntry* pEntry =
2464  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2465  if( !pEntry )
2466  throw lang::IllegalArgumentException();
2467  if(pFormat)
2468  {
2469  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2470  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2471 
2472  if(0xBF == pEntry->nMemberId)
2473  {
2474  lcl_SetSpecialProperty(pFormat, pEntry, aValue);
2475  }
2476  else
2477  {
2478  switch(pEntry->nWID)
2479  {
2480  case FN_UNO_TABLE_NAME :
2481  {
2482  OUString sName;
2483  aValue >>= sName;
2484  setName( sName );
2485  }
2486  break;
2487 
2489  {
2490  bool bTmp = *o3tl::doAccess<bool>(aValue);
2491  if (m_pImpl->m_bFirstRowAsLabel != bTmp)
2492  {
2493  std::unique_lock aGuard2(m_pImpl->m_Mutex);
2494  lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2495  m_pImpl->m_bFirstRowAsLabel = bTmp;
2496  }
2497  }
2498  break;
2499 
2501  {
2502  bool bTmp = *o3tl::doAccess<bool>(aValue);
2503  if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
2504  {
2505  std::unique_lock aGuard2(m_pImpl->m_Mutex);
2506  lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2507  m_pImpl->m_bFirstColumnAsLabel = bTmp;
2508  }
2509  }
2510  break;
2511 
2512  case FN_UNO_TABLE_BORDER:
2513  case FN_UNO_TABLE_BORDER2:
2514  {
2515  table::TableBorder oldBorder;
2516  table::TableBorder2 aBorder;
2517  SvxBorderLine aTopLine;
2518  SvxBorderLine aBottomLine;
2519  SvxBorderLine aLeftLine;
2520  SvxBorderLine aRightLine;
2521  SvxBorderLine aHoriLine;
2522  SvxBorderLine aVertLine;
2523  if (aValue >>= oldBorder)
2524  {
2525  aBorder.IsTopLineValid = oldBorder.IsTopLineValid;
2526  aBorder.IsBottomLineValid = oldBorder.IsBottomLineValid;
2527  aBorder.IsLeftLineValid = oldBorder.IsLeftLineValid;
2528  aBorder.IsRightLineValid = oldBorder.IsRightLineValid;
2529  aBorder.IsHorizontalLineValid = oldBorder.IsHorizontalLineValid;
2530  aBorder.IsVerticalLineValid = oldBorder.IsVerticalLineValid;
2531  aBorder.Distance = oldBorder.Distance;
2532  aBorder.IsDistanceValid = oldBorder.IsDistanceValid;
2534  oldBorder.TopLine, aTopLine);
2536  oldBorder.BottomLine, aBottomLine);
2538  oldBorder.LeftLine, aLeftLine);
2540  oldBorder.RightLine, aRightLine);
2542  oldBorder.HorizontalLine, aHoriLine);
2544  oldBorder.VerticalLine, aVertLine);
2545  }
2546  else if (aValue >>= aBorder)
2547  {
2549  aBorder.TopLine, aTopLine, true);
2551  aBorder.BottomLine, aBottomLine, true);
2553  aBorder.LeftLine, aLeftLine, true);
2555  aBorder.RightLine, aRightLine, true);
2557  aBorder.HorizontalLine, aHoriLine, true);
2559  aBorder.VerticalLine, aVertLine, true);
2560  }
2561  else
2562  {
2563  break; // something else
2564  }
2565  SwDoc* pDoc = pFormat->GetDoc();
2566  if(!lcl_FormatTable(pFormat))
2567  break;
2568  SwTable* pTable = SwTable::FindTable( pFormat );
2569  SwTableLines &rLines = pTable->GetTabLines();
2570 
2571  const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2572  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2573  SwPosition aPos(*pSttNd);
2574  // set cursor to top left cell
2575  auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2576  pUnoCursor->Move( fnMoveForward, GoInNode );
2577  pUnoCursor->SetRemainInSection( false );
2578 
2579  const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2580  pUnoCursor->SetMark();
2581  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
2582  pUnoCursor->Move( fnMoveForward, GoInNode );
2583  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2584  // HACK: remove pending actions for selecting old style tables
2585  UnoActionRemoveContext aRemoveContext(rCursor);
2586  rCursor.MakeBoxSels();
2587 
2589  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
2590  aSet(pDoc->GetAttrPool());
2591 
2592  SvxBoxItem aBox( RES_BOX );
2593  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
2594 
2595  aBox.SetLine(aTopLine.isEmpty() ? nullptr : &aTopLine, SvxBoxItemLine::TOP);
2596  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::TOP, aBorder.IsTopLineValid);
2597 
2598  aBox.SetLine(aBottomLine.isEmpty() ? nullptr : &aBottomLine, SvxBoxItemLine::BOTTOM);
2599  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::BOTTOM, aBorder.IsBottomLineValid);
2600 
2601  aBox.SetLine(aLeftLine.isEmpty() ? nullptr : &aLeftLine, SvxBoxItemLine::LEFT);
2602  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::LEFT, aBorder.IsLeftLineValid);
2603 
2604  aBox.SetLine(aRightLine.isEmpty() ? nullptr : &aRightLine, SvxBoxItemLine::RIGHT);
2605  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::RIGHT, aBorder.IsRightLineValid);
2606 
2607  aBoxInfo.SetLine(aHoriLine.isEmpty() ? nullptr : &aHoriLine, SvxBoxInfoItemLine::HORI);
2608  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::HORI, aBorder.IsHorizontalLineValid);
2609 
2610  aBoxInfo.SetLine(aVertLine.isEmpty() ? nullptr : &aVertLine, SvxBoxInfoItemLine::VERT);
2611  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::VERT, aBorder.IsVerticalLineValid);
2612 
2613  aBox.SetAllDistances(o3tl::toTwips(aBorder.Distance, o3tl::Length::mm100));
2614  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::DISTANCE, aBorder.IsDistanceValid);
2615 
2616  aSet.Put(aBox);
2617  aSet.Put(aBoxInfo);
2618 
2619  pDoc->SetTabBorders(rCursor, aSet);
2620  }
2621  break;
2622 
2624  {
2625  table::TableBorderDistances aTableBorderDistances;
2626  if( !(aValue >>= aTableBorderDistances) ||
2627  (!aTableBorderDistances.IsLeftDistanceValid &&
2628  !aTableBorderDistances.IsRightDistanceValid &&
2629  !aTableBorderDistances.IsTopDistanceValid &&
2630  !aTableBorderDistances.IsBottomDistanceValid ))
2631  break;
2632 
2633  const sal_uInt16 nLeftDistance = o3tl::toTwips(aTableBorderDistances.LeftDistance, o3tl::Length::mm100);
2634  const sal_uInt16 nRightDistance = o3tl::toTwips(aTableBorderDistances.RightDistance, o3tl::Length::mm100);
2635  const sal_uInt16 nTopDistance = o3tl::toTwips(aTableBorderDistances.TopDistance, o3tl::Length::mm100);
2636  const sal_uInt16 nBottomDistance = o3tl::toTwips(aTableBorderDistances.BottomDistance, o3tl::Length::mm100);
2637  SwDoc* pDoc = pFormat->GetDoc();
2638  SwTable* pTable = SwTable::FindTable( pFormat );
2639  SwTableLines &rLines = pTable->GetTabLines();
2641  for(size_t i = 0; i < rLines.size(); ++i)
2642  {
2643  SwTableLine* pLine = rLines[i];
2644  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2645  for(size_t k = 0; k < rBoxes.size(); ++k)
2646  {
2647  SwTableBox* pBox = rBoxes[k];
2648  const SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2649  const SvxBoxItem& rBox = pBoxFormat->GetBox();
2650  if(
2651  (aTableBorderDistances.IsLeftDistanceValid && nLeftDistance != rBox.GetDistance( SvxBoxItemLine::LEFT )) ||
2652  (aTableBorderDistances.IsRightDistanceValid && nRightDistance != rBox.GetDistance( SvxBoxItemLine::RIGHT )) ||
2653  (aTableBorderDistances.IsTopDistanceValid && nTopDistance != rBox.GetDistance( SvxBoxItemLine::TOP )) ||
2654  (aTableBorderDistances.IsBottomDistanceValid && nBottomDistance != rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2655  {
2656  SvxBoxItem aSetBox( rBox );
2657  SwFrameFormat* pSetBoxFormat = pBox->ClaimFrameFormat();
2658  if( aTableBorderDistances.IsLeftDistanceValid )
2659  aSetBox.SetDistance( nLeftDistance, SvxBoxItemLine::LEFT );
2660  if( aTableBorderDistances.IsRightDistanceValid )
2661  aSetBox.SetDistance( nRightDistance, SvxBoxItemLine::RIGHT );
2662  if( aTableBorderDistances.IsTopDistanceValid )
2663  aSetBox.SetDistance( nTopDistance, SvxBoxItemLine::TOP );
2664  if( aTableBorderDistances.IsBottomDistanceValid )
2665  aSetBox.SetDistance( nBottomDistance, SvxBoxItemLine::BOTTOM );
2666  pDoc->SetAttr( aSetBox, *pSetBoxFormat );
2667  }
2668  }
2669  }
2670  pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
2671  }
2672  break;
2673 
2675  {
2676  UnoActionContext aContext(pFormat->GetDoc());
2677  SwTable* pTable = SwTable::FindTable( pFormat );
2678  lcl_SetTableSeparators(aValue, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false, pFormat->GetDoc());
2679  }
2680  break;
2681 
2682  case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:/*_readonly_*/ break;
2683 
2685  {
2686  SwTable* pTable = SwTable::FindTable(pFormat);
2687  OUString sName;
2688  if (!(aValue >>= sName))
2689  break;
2691  pTable->SetTableStyleName(sName);
2692  SwDoc* pDoc = pFormat->GetDoc();
2694  }
2695  break;
2696 
2697  default:
2698  {
2699  SwAttrSet aSet(pFormat->GetAttrSet());
2700  m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
2701  pFormat->GetDoc()->SetAttr(aSet, *pFormat);
2702  }
2703  }
2704  }
2705  }
2706  else if (m_pImpl->IsDescriptor())
2707  {
2708  m_pImpl->m_pTableProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue);
2709  }
2710  else
2711  throw uno::RuntimeException();
2712 }
2713 
2714 uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
2715 {
2716  SolarMutexGuard aGuard;
2717  uno::Any aRet;
2718  SwFrameFormat* pFormat = GetFrameFormat();
2719  const SfxItemPropertyMapEntry* pEntry =
2720  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2721 
2722  if (!pEntry)
2723  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2724 
2725  if(pFormat)
2726  {
2727  if(0xBF == pEntry->nMemberId)
2728  {
2729  aRet = lcl_GetSpecialProperty(pFormat, pEntry );
2730  }
2731  else
2732  {
2733  switch(pEntry->nWID)
2734  {
2735  case FN_UNO_TABLE_NAME:
2736  {
2737  aRet <<= getName();
2738  }
2739  break;
2740 
2741  case FN_UNO_ANCHOR_TYPES:
2742  case FN_UNO_TEXT_WRAP:
2743  case FN_UNO_ANCHOR_TYPE:
2745  aRet, u"", pEntry->nWID);
2746  break;
2747 
2749  {
2750  aRet <<= m_pImpl->m_bFirstRowAsLabel;
2751  }
2752  break;
2753 
2755  aRet <<= m_pImpl->m_bFirstColumnAsLabel;
2756  break;
2757 
2758  case FN_UNO_TABLE_BORDER:
2759  case FN_UNO_TABLE_BORDER2:
2760  {
2761  SwDoc* pDoc = pFormat->GetDoc();
2762  // tables without layout (invisible header/footer?)
2763  if(!lcl_FormatTable(pFormat))
2764  break;
2765  SwTable* pTable = SwTable::FindTable( pFormat );
2766  SwTableLines &rLines = pTable->GetTabLines();
2767 
2768  const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2769  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2770  SwPosition aPos(*pSttNd);
2771  // set cursor to top left cell
2772  auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2773  pUnoCursor->Move( fnMoveForward, GoInNode );
2774  pUnoCursor->SetRemainInSection( false );
2775 
2776  const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2777  pUnoCursor->SetMark();
2778  const SwStartNode* pLastNd = pBRBox->GetSttNd();
2779  pUnoCursor->GetPoint()->nNode = *pLastNd;
2780 
2781  pUnoCursor->Move( fnMoveForward, GoInNode );
2782  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2783  // HACK: remove pending actions for selecting old style tables
2784  UnoActionRemoveContext aRemoveContext(rCursor);
2785  rCursor.MakeBoxSels();
2786 
2788  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
2789  aSet(pDoc->GetAttrPool());
2790  aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
2791  SwDoc::GetTabBorders(rCursor, aSet);
2792  const SvxBoxInfoItem& rBoxInfoItem = aSet.Get(SID_ATTR_BORDER_INNER);
2793  const SvxBoxItem& rBox = aSet.Get(RES_BOX);
2794 
2795  if (FN_UNO_TABLE_BORDER == pEntry->nWID)
2796  {
2797  table::TableBorder aTableBorder;
2798  aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2799  aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2800  aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2801  aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2802  aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2803  aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2804  aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2805  aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2806  aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2807  aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2808  aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2809  aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2810  aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2811  aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2812  aRet <<= aTableBorder;
2813  }
2814  else
2815  {
2816  table::TableBorder2 aTableBorder;
2817  aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2818  aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2819  aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2820  aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2821  aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2822  aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2823  aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2824  aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2825  aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2826  aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2827  aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2828  aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2829  aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2830  aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2831  aRet <<= aTableBorder;
2832  }
2833  }
2834  break;
2835 
2837  {
2838  table::TableBorderDistances aTableBorderDistances( 0, true, 0, true, 0, true, 0, true ) ;
2839  SwTable* pTable = SwTable::FindTable( pFormat );
2840  const SwTableLines &rLines = pTable->GetTabLines();
2841  bool bFirst = true;
2842  sal_uInt16 nLeftDistance = 0;
2843  sal_uInt16 nRightDistance = 0;
2844  sal_uInt16 nTopDistance = 0;
2845  sal_uInt16 nBottomDistance = 0;
2846 
2847  for(size_t i = 0; i < rLines.size(); ++i)
2848  {
2849  const SwTableLine* pLine = rLines[i];
2850  const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2851  for(size_t k = 0; k < rBoxes.size(); ++k)
2852  {
2853  const SwTableBox* pBox = rBoxes[k];
2854  SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2855  const SvxBoxItem& rBox = pBoxFormat->GetBox();
2856  if( bFirst )
2857  {
2858  nLeftDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT ));
2859  nRightDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT ));
2860  nTopDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP ));
2861  nBottomDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM ));
2862  bFirst = false;
2863  }
2864  else
2865  {
2866  if( aTableBorderDistances.IsLeftDistanceValid &&
2867  nLeftDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT )))
2868  aTableBorderDistances.IsLeftDistanceValid = false;
2869  if( aTableBorderDistances.IsRightDistanceValid &&
2870  nRightDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT )))
2871  aTableBorderDistances.IsRightDistanceValid = false;
2872  if( aTableBorderDistances.IsTopDistanceValid &&
2873  nTopDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP )))
2874  aTableBorderDistances.IsTopDistanceValid = false;
2875  if( aTableBorderDistances.IsBottomDistanceValid &&
2876  nBottomDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2877  aTableBorderDistances.IsBottomDistanceValid = false;
2878  }
2879 
2880  }
2881  if( !aTableBorderDistances.IsLeftDistanceValid &&
2882  !aTableBorderDistances.IsRightDistanceValid &&
2883  !aTableBorderDistances.IsTopDistanceValid &&
2884  !aTableBorderDistances.IsBottomDistanceValid )
2885  break;
2886  }
2887  if( aTableBorderDistances.IsLeftDistanceValid)
2888  aTableBorderDistances.LeftDistance = nLeftDistance;
2889  if( aTableBorderDistances.IsRightDistanceValid)
2890  aTableBorderDistances.RightDistance = nRightDistance;
2891  if( aTableBorderDistances.IsTopDistanceValid)
2892  aTableBorderDistances.TopDistance = nTopDistance;
2893  if( aTableBorderDistances.IsBottomDistanceValid)
2894  aTableBorderDistances.BottomDistance = nBottomDistance;
2895 
2896  aRet <<= aTableBorderDistances;
2897  }
2898  break;
2899 
2901  {
2902  SwTable* pTable = SwTable::FindTable( pFormat );
2903  lcl_GetTableSeparators(aRet, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false);
2904  }
2905  break;
2906 
2908  aRet <<= sal_Int16(UNO_TABLE_COLUMN_SUM);
2909  break;
2910 
2911  case RES_ANCHOR:
2912  // AnchorType is readonly and might be void (no return value)
2913  break;
2914 
2915  case FN_UNO_TEXT_SECTION:
2916  {
2917  SwTable* pTable = SwTable::FindTable( pFormat );
2918  SwTableNode* pTableNode = pTable->GetTableNode();
2919  SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
2920  if(pSectionNode)
2921  {
2922  SwSection& rSect = pSectionNode->GetSection();
2923  uno::Reference< text::XTextSection > xSect =
2925  aRet <<= xSect;
2926  }
2927  }
2928  break;
2929 
2931  {
2932  SwTable* pTable = SwTable::FindTable(pFormat);
2933  OUString sName;
2935  aRet <<= sName;
2936  }
2937  break;
2938 
2939  default:
2940  {
2941  const SwAttrSet& rSet = pFormat->GetAttrSet();
2942  m_pImpl->m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
2943  }
2944  }
2945  }
2946  }
2947  else if (m_pImpl->IsDescriptor())
2948  {
2949  const uno::Any* pAny = nullptr;
2950  if (!m_pImpl->m_pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
2951  throw lang::IllegalArgumentException();
2952  else if(pAny)
2953  aRet = *pAny;
2954  }
2955  else
2956  throw uno::RuntimeException();
2957  return aRet;
2958 }
2959 
2960 void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2961  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2962 
2963 void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2964  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2965 
2966 void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2967  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2968 
2969 void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2970  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2971 
2973 {
2974  SolarMutexGuard aGuard;
2975  SwFrameFormat* pFormat = GetFrameFormat();
2976  if (!pFormat && !m_pImpl->IsDescriptor())
2977  throw uno::RuntimeException();
2978  if(pFormat)
2979  {
2980  return pFormat->GetName();
2981  }
2982  return m_pImpl->m_sTableName;
2983 }
2984 
2985 void SwXTextTable::setName(const OUString& rName)
2986 {
2987  SolarMutexGuard aGuard;
2988  SwFrameFormat* pFormat = GetFrameFormat();
2989  if ((!pFormat && !m_pImpl->IsDescriptor()) ||
2990  rName.isEmpty() ||
2991  rName.indexOf('.')>=0 ||
2992  rName.indexOf(' ')>=0 )
2993  throw uno::RuntimeException();
2994 
2995  if(pFormat)
2996  {
2997  const OUString aOldName( pFormat->GetName() );
2998  const SwFrameFormats* pFrameFormats = pFormat->GetDoc()->GetTableFrameFormats();
2999  for (size_t i = pFrameFormats->size(); i;)
3000  {
3001  const SwFrameFormat* pTmpFormat = (*pFrameFormats)[--i];
3002  if( !pTmpFormat->IsDefault() &&
3003  pTmpFormat->GetName() == rName &&
3004  pFormat->GetDoc()->IsUsed( *pTmpFormat ))
3005  {
3006  throw uno::RuntimeException();
3007  }
3008  }
3009 
3010  pFormat->SetName( rName );
3011 
3012  SwStartNode *pStNd;
3013  SwNodeIndex aIdx( *pFormat->GetDoc()->GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
3014  while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
3015  {
3016  ++aIdx;
3017  SwNode *const pNd = & aIdx.GetNode();
3018  if ( pNd->IsOLENode() &&
3019  aOldName == static_cast<const SwOLENode*>(pNd)->GetChartTableName() )
3020  {
3021  static_cast<SwOLENode*>(pNd)->SetChartTableName( rName );
3022 
3023  SwTable* pTable = SwTable::FindTable( pFormat );
3024  //TL_CHART2: chart needs to be notified about name changes
3025  pFormat->GetDoc()->UpdateCharts( pTable->GetFrameFormat()->GetName() );
3026  }
3027  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
3028  }
3029  pFormat->GetDoc()->getIDocumentState().SetModified();
3030  }
3031  else
3032  m_pImpl->m_sTableName = rName;
3033 }
3034 
3036 {
3037  sal_uInt16 nRet = 0;
3038  SwFrameFormat* pFormat = GetFrameFormat();
3039  if(pFormat)
3040  {
3041  SwTable* pTable = SwTable::FindTable( pFormat );
3042  if(!pTable->IsTableComplex())
3043  {
3044  nRet = pTable->GetTabLines().size();
3045  }
3046  }
3047  return nRet;
3048 }
3049 
3051 {
3052  SwFrameFormat* pFormat = GetFrameFormat();
3053  sal_uInt16 nRet = 0;
3054  if(pFormat)
3055  {
3056  SwTable* pTable = SwTable::FindTable( pFormat );
3057  if(!pTable->IsTableComplex())
3058  {
3059  SwTableLines& rLines = pTable->GetTabLines();
3060  SwTableLine* pLine = rLines.front();
3061  nRet = pLine->GetTabBoxes().size();
3062  }
3063  }
3064  return nRet;
3065 }
3066 
3068 {
3069  if(rHint.GetId() == SfxHintId::Dying)
3070  {
3071  m_pFrameFormat = nullptr;
3072  EndListeningAll();
3073  }
3074  uno::Reference<uno::XInterface> const xThis(m_wThis);
3075  if (xThis.is())
3076  { // fdo#72695: if UNO object is already dead, don't revive it with event
3077  if(!m_pFrameFormat)
3078  {
3079  lang::EventObject const ev(xThis);
3080  std::unique_lock aGuard(m_Mutex);
3081  m_EventListeners.disposeAndClear(aGuard, ev);
3082  m_ChartListeners.disposeAndClear(aGuard, ev);
3083  }
3084  else
3085  {
3086  std::unique_lock aGuard(m_Mutex);
3087  lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
3088  }
3089  }
3090 }
3091 
3093  { return "SwXTextTable"; }
3094 
3095 sal_Bool SwXTextTable::supportsService(const OUString& rServiceName)
3096  { return cppu::supportsService(this, rServiceName); }
3097 
3099 {
3100  return {
3101  "com.sun.star.document.LinkTarget",
3102  "com.sun.star.text.TextTable",
3103  "com.sun.star.text.TextContent",
3104  "com.sun.star.text.TextSortable" };
3105 }
3106 
3107 
3109  : public SvtListener
3110 {
3111 private:
3113 
3114 public:
3115  uno::WeakReference<uno::XInterface> m_wThis;
3116  std::mutex m_Mutex; // just for OInterfaceContainerHelper4
3118 
3120 
3123 
3126 
3127  Impl(sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor const& rDesc)
3128  : m_pFrameFormat(&rFrameFormat)
3129  , m_pTableCursor(pCursor)
3130  , m_RangeDescriptor(rDesc)
3131  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
3132  , m_bFirstRowAsLabel(false)
3133  , m_bFirstColumnAsLabel(false)
3134  {
3135  StartListening(rFrameFormat.GetNotifier());
3136  m_RangeDescriptor.Normalize();
3137  }
3138 
3140  {
3141  return m_pFrameFormat;
3142  }
3143 
3144  std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> GetLabelCoordinates(bool bRow);
3145 
3146  uno::Sequence<OUString> GetLabelDescriptions(SwXCellRange & rThis, bool bRow);
3147 
3148  void SetLabelDescriptions(SwXCellRange & rThis,
3149  const css::uno::Sequence<OUString>& rDesc, bool bRow);
3150 
3151  sal_Int32 GetRowCount() const;
3152  sal_Int32 GetColumnCount() const;
3153 
3154  virtual void Notify(const SfxHint& ) override;
3155 
3156 };
3157 
3158 namespace
3159 {
3160 }
3161 
3162 const uno::Sequence< sal_Int8 > & SwXCellRange::getUnoTunnelId()
3163 {
3164  static const comphelper::UnoIdInit theSwXCellRangeUnoTunnelId;
3165  return theSwXCellRangeUnoTunnelId.getSeq();
3166 }
3167 
3168 sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& rId )
3169 {
3170  return comphelper::getSomethingImpl(rId, this);
3171 }
3172 
3173 
3175  { return "SwXCellRange"; }
3176 
3177 sal_Bool SwXCellRange::supportsService(const OUString& rServiceName)
3178  { return cppu::supportsService(this, rServiceName); }
3179 
3181 {
3182  return {
3183  "com.sun.star.text.CellRange",
3184  "com.sun.star.style.CharacterProperties",
3185  "com.sun.star.style.CharacterPropertiesAsian",
3186  "com.sun.star.style.CharacterPropertiesComplex",
3187  "com.sun.star.style.ParagraphProperties",
3188  "com.sun.star.style.ParagraphPropertiesAsian",
3189  "com.sun.star.style.ParagraphPropertiesComplex" };
3190 }
3191 
3193  SwFrameFormat& rFrameFormat, SwRangeDescriptor const & rDesc)
3194  : m_pImpl(new Impl(pCursor, rFrameFormat, rDesc))
3195 {
3196 }
3197 
3199 {
3200 }
3201 
3203  sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat,
3204  SwRangeDescriptor const & rDesc)
3205 {
3206  rtl::Reference<SwXCellRange> pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
3207  // need a permanent Reference to initialize m_wThis
3208  pCellRange->m_pImpl->m_wThis = uno::Reference<table::XCellRange>(pCellRange);
3209  return pCellRange;
3210 }
3211 
3212 void SwXCellRange::SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
3213 {
3214  m_pImpl->m_bFirstRowAsLabel = bFirstRowAsLabel;
3215  m_pImpl->m_bFirstColumnAsLabel = bFirstColumnAsLabel;
3216 }
3217 
3218 std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
3219 {
3220  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3221  const sal_Int32 nRowCount(m_pImpl->GetRowCount());
3222  const sal_Int32 nColCount(m_pImpl->GetColumnCount());
3223  std::vector< uno::Reference< table::XCell > > vResult;
3224  vResult.reserve(static_cast<size_t>(nRowCount)*static_cast<size_t>(nColCount));
3225  for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
3226  for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
3227  vResult.emplace_back(lcl_CreateXCell(pFormat, m_pImpl->m_RangeDescriptor.nLeft + nCol, m_pImpl->m_RangeDescriptor.nTop + nRow));
3228  return vResult;
3229 }
3230 
3231 uno::Reference<table::XCell> SAL_CALL
3232 SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
3233 {
3234  SolarMutexGuard aGuard;
3235  uno::Reference< table::XCell > aRet;
3236  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3237  if(pFormat)
3238  {
3239  if(nColumn >= 0 && nRow >= 0 &&
3240  m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > nRow )
3241  {
3242  rtl::Reference<SwXCell> pXCell = lcl_CreateXCell(pFormat,
3243  m_pImpl->m_RangeDescriptor.nLeft + nColumn,
3244  m_pImpl->m_RangeDescriptor.nTop + nRow);
3245  if(pXCell)
3246  aRet = pXCell;
3247  }
3248  }
3249  if(!aRet.is())
3250  throw lang::IndexOutOfBoundsException();
3251  return aRet;
3252 }
3253 
3254 uno::Reference<table::XCellRange> SAL_CALL
3256  sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
3257 {
3258  SolarMutexGuard aGuard;
3259  uno::Reference< table::XCellRange > aRet;
3260  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3261  if (pFormat && m_pImpl->GetColumnCount() > nRight
3262  && m_pImpl->GetRowCount() > nBottom &&
3263  nLeft <= nRight && nTop <= nBottom
3264  && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
3265  {
3266  SwTable* pTable = SwTable::FindTable( pFormat );
3267  if(!pTable->IsTableComplex())
3268  {
3269  SwRangeDescriptor aNewDesc;
3270  aNewDesc.nTop = nTop + m_pImpl->m_RangeDescriptor.nTop;
3271  aNewDesc.nBottom = nBottom + m_pImpl->m_RangeDescriptor.nTop;
3272  aNewDesc.nLeft = nLeft + m_pImpl->m_RangeDescriptor.nLeft;
3273  aNewDesc.nRight = nRight + m_pImpl->m_RangeDescriptor.nLeft;
3274  aNewDesc.Normalize();
3275  const OUString sTLName = sw_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
3276  const OUString sBRName = sw_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
3277  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
3278  if(pTLBox)
3279  {
3280  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3281  SwPosition aPos(*pSttNd);
3282  // set cursor in the upper-left cell of the range
3283  auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
3284  pUnoCursor->Move( fnMoveForward, GoInNode );
3285  pUnoCursor->SetRemainInSection( false );
3286  const SwTableBox* pBRBox = pTable->GetTableBox( sBRName );
3287  if(pBRBox)
3288  {
3289  pUnoCursor->SetMark();
3290  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
3291  pUnoCursor->Move( fnMoveForward, GoInNode );
3292  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
3293  // HACK: remove pending actions for selecting old style tables
3294  UnoActionRemoveContext aRemoveContext(rCursor);
3295  rCursor.MakeBoxSels();
3296  // pUnoCursor will be provided and will not be deleted
3297  aRet = SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, aNewDesc).get();
3298  }
3299  }
3300  }
3301  }
3302  if(!aRet.is())
3303  throw lang::IndexOutOfBoundsException();
3304  return aRet;
3305 }
3306 
3307 uno::Reference<table::XCellRange> SAL_CALL
3308 SwXCellRange::getCellRangeByName(const OUString& rRange)
3309 {
3310  SolarMutexGuard aGuard;
3311  sal_Int32 nPos = 0;
3312  const OUString sTLName(rRange.getToken(0, ':', nPos));
3313  const OUString sBRName(rRange.getToken(0, ':', nPos));
3314  if(sTLName.isEmpty() || sBRName.isEmpty())
3315  throw uno::RuntimeException();
3316  SwRangeDescriptor aDesc;
3317  aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
3318  SwXTextTable::GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
3319  SwXTextTable::GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
3320  aDesc.Normalize();
3321  return getCellRangeByPosition(
3322  aDesc.nLeft - m_pImpl->m_RangeDescriptor.nLeft,
3323  aDesc.nTop - m_pImpl->m_RangeDescriptor.nTop,
3324  aDesc.nRight - m_pImpl->m_RangeDescriptor.nLeft,
3325  aDesc.nBottom - m_pImpl->m_RangeDescriptor.nTop);
3326 }
3327 
3328 uno::Reference< beans::XPropertySetInfo > SwXCellRange::getPropertySetInfo()
3329 {
3330  static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
3331  return xRef;
3332 }
3333 
3334 void SAL_CALL
3335 SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
3336 {
3337  SolarMutexGuard aGuard;
3338  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3339  if(!pFormat)
3340  return;
3341 
3342  const SfxItemPropertyMapEntry *const pEntry =
3343  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3344  if(!pEntry)
3345  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3346 
3347  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3348  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3349 
3350  SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3351  SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor));
3352  {
3353  // HACK: remove pending actions for selecting old style tables
3354  UnoActionRemoveContext aRemoveContext(rCursor);
3355  }
3356  rCursor.MakeBoxSels();
3357  switch(pEntry->nWID )
3358  {
3360  {
3361  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3362  SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
3363  aBrush->PutValue(aValue, pEntry->nMemberId);
3364  rDoc.SetBoxAttr(*m_pImpl->m_pTableCursor, *aBrush);
3365 
3366  }
3367  break;
3368  case RES_BOX :
3369  {
3371  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
3372  aSet(rDoc.GetAttrPool());
3373  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
3374  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::ALL, false);
3375  SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::NONE;
3376  switch(pEntry->nMemberId & ~CONVERT_TWIPS)
3377  {
3378  case LEFT_BORDER : nValid = SvxBoxInfoItemValidFlags::LEFT; break;
3379  case RIGHT_BORDER: nValid = SvxBoxInfoItemValidFlags::RIGHT; break;
3380  case TOP_BORDER : nValid = SvxBoxInfoItemValidFlags::TOP; break;
3381  case BOTTOM_BORDER: nValid = SvxBoxInfoItemValidFlags::BOTTOM; break;
3382  case LEFT_BORDER_DISTANCE :
3383  case RIGHT_BORDER_DISTANCE:
3384  case TOP_BORDER_DISTANCE :
3386  nValid = SvxBoxInfoItemValidFlags::DISTANCE;
3387  break;
3388  }
3389  aBoxInfo.SetValid(nValid);
3390 
3391  aSet.Put(aBoxInfo);
3392  SwDoc::GetTabBorders(rCursor, aSet);
3393 
3394  aSet.Put(aBoxInfo);
3395  SvxBoxItem aBoxItem(aSet.Get(RES_BOX));
3396  static_cast<SfxPoolItem&>(aBoxItem).PutValue(aValue, pEntry->nMemberId);
3397  aSet.Put(aBoxItem);
3398  rDoc.SetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3399  }
3400  break;
3401  case RES_BOXATR_FORMAT:
3402  {
3403  SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
3404  static_cast<SfxPoolItem&>(aNumberFormat).PutValue(aValue, 0);
3405  rDoc.SetBoxAttr(rCursor, aNumberFormat);
3406  }
3407  break;
3409  {
3410  bool bTmp = *o3tl::doAccess<bool>(aValue);
3411  if (m_pImpl->m_bFirstRowAsLabel != bTmp)
3412  {
3413  std::unique_lock aGuard2(m_pImpl->m_Mutex);
3414  lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
3415  m_pImpl->m_bFirstRowAsLabel = bTmp;
3416  }
3417  }
3418  break;
3420  {
3421  bool bTmp = *o3tl::doAccess<bool>(aValue);
3422  if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
3423  {
3424  std::unique_lock aGuard2(m_pImpl->m_Mutex);
3425  lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
3426  m_pImpl->m_bFirstColumnAsLabel = bTmp;
3427  }
3428  }
3429  break;
3430  case RES_VERT_ORIENT:
3431  {
3432  sal_Int16 nAlign = -1;
3433  aValue >>= nAlign;
3434  if( nAlign >= text::VertOrientation::NONE && nAlign <= text::VertOrientation::BOTTOM)
3435  rDoc.SetBoxAlign( rCursor, nAlign );
3436  }
3437  break;
3438  default:
3439  {
3440  SfxItemSet aItemSet( rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID );
3442  aItemSet);
3443 
3445  *pEntry, aValue, rCursor.GetSelRing(), aItemSet))
3446  {
3447  m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
3448  }
3450  aItemSet, SetAttrMode::DEFAULT, true);
3451  }
3452  }
3453 }
3454 
3455 uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
3456 {
3457  SolarMutexGuard aGuard;
3458  uno::Any aRet;
3459  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3460  if(pFormat)
3461  {
3462  const SfxItemPropertyMapEntry *const pEntry =
3463  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3464  if(!pEntry)
3465  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3466 
3467  switch(pEntry->nWID )
3468  {
3470  {
3471  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3472  if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush))
3473  aBrush->QueryValue(aRet, pEntry->nMemberId);
3474 
3475  }
3476  break;
3477  case RES_BOX :
3478  {
3479  SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3481  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
3482  aSet(rDoc.GetAttrPool());
3483  aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
3484  SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3485  const SvxBoxItem& rBoxItem = aSet.Get(RES_BOX);
3486  rBoxItem.QueryValue(aRet, pEntry->nMemberId);
3487  }
3488  break;
3489  case RES_BOXATR_FORMAT:
3490  OSL_FAIL("not implemented");
3491  break;
3492  case FN_UNO_PARA_STYLE:
3493  {
3494  SwFormatColl *const pTmpFormat =
3495  SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false);
3496  OUString sRet;
3497  if (pTmpFormat)
3498  sRet = pTmpFormat->GetName();
3499  aRet <<= sRet;
3500  }
3501  break;
3503  aRet <<= m_pImpl->m_bFirstRowAsLabel;
3504  break;
3506  aRet <<= m_pImpl->m_bFirstColumnAsLabel;
3507  break;
3508  case RES_VERT_ORIENT:
3509  {
3510  std::unique_ptr<SfxPoolItem> aVertOrient(
3511  std::make_unique<SwFormatVertOrient>(RES_VERT_ORIENT));
3512  if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
3513  {
3514  aVertOrient->QueryValue( aRet, pEntry->nMemberId );
3515  }
3516  }
3517  break;
3518  default:
3519  {
3523  RES_UNKNOWNATR_CONTAINER>
3524  aSet(m_pImpl->m_pTableCursor->GetDoc().GetAttrPool());
3525  // first look at the attributes of the cursor
3526  SwUnoTableCursor *const pCursor =
3527  dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor));
3528  SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet);
3529  m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
3530  }
3531  }
3532 
3533  }
3534  return aRet;
3535 }
3536 
3537 void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3538  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3539 
3540 void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3541  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3542 
3543 void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3544  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3545 
3546 void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3547  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3548 
3550 uno::Sequence<uno::Sequence<uno::Any>> SAL_CALL SwXCellRange::getDataArray()
3551 {
3552  SolarMutexGuard aGuard;
3553  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3554  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3555  if(!nRowCount || !nColCount)
3556  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3557  lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3558  uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
3559  auto vCells(GetCells());
3560  auto pCurrentCell(vCells.begin());
3561  for(auto& rRow : asNonConstRange(aRowSeq))
3562  {
3563  rRow = uno::Sequence< uno::Any >(nColCount);
3564  for(auto& rCellAny : asNonConstRange(rRow))
3565  {
3566  auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3567  if(!pCell)
3568  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3569  rCellAny = pCell->GetAny();
3570  ++pCurrentCell;
3571  }
3572  }
3573  return aRowSeq;
3574 }
3575 
3577 void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
3578 {
3579  SolarMutexGuard aGuard;
3580  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3581  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3582  if(!nRowCount || !nColCount)
3583  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3584  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3585  if(!pFormat)
3586  return;
3587  if(rArray.getLength() != nRowCount)
3588  throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this));
3589  auto vCells(GetCells());
3590  auto pCurrentCell(vCells.begin());
3591  for(const auto& rColSeq : rArray)
3592  {
3593  if(rColSeq.getLength() != nColCount)
3594  throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rColSeq.getLength()), static_cast<cppu::OWeakObject*>(this));
3595  for(const auto& aValue : rColSeq)
3596  {
3597  auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3598  if(!pCell || !pCell->GetTableBox())
3599  throw uno::RuntimeException("Box for cell missing", static_cast<cppu::OWeakObject*>(this));
3600  if(aValue.isExtractableTo(cppu::UnoType<OUString>::get()))
3601  sw_setString(*pCell, aValue.get<OUString>());
3602  else if(aValue.isExtractableTo(cppu::UnoType<double>::get()))
3603  sw_setValue(*pCell, aValue.get<double>());
3604  else
3605  sw_setString(*pCell, OUString(), true);
3606  ++pCurrentCell;
3607  }
3608  }
3609 }
3610 
3611 uno::Sequence<uno::Sequence<double>> SAL_CALL
3613 {
3614  SolarMutexGuard aGuard;
3615  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3616  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3617  if(!nRowCount || !nColCount)
3618  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3619  if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3620  {
3621  uno::Reference<chart::XChartDataArray> const xDataRange(
3622  getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3623  (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3624  nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3625  return xDataRange->getData();
3626  }
3627  uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
3628  auto vCells(GetCells());
3629  auto pCurrentCell(vCells.begin());
3630  for(auto& rRow : asNonConstRange(vRows))
3631  {
3632  rRow = uno::Sequence<double>(nColCount);
3633  for(auto& rValue : asNonConstRange(rRow))
3634  {
3635  if(!(*pCurrentCell))
3636  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3637  rValue = (*pCurrentCell)->getValue();
3638  ++pCurrentCell;
3639  }
3640  }
3641  return vRows;
3642 }
3643 
3644 void SAL_CALL
3645 SwXCellRange::setData(const uno::Sequence< uno::Sequence<double> >& rData)
3646 {
3647  SolarMutexGuard aGuard;
3648  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3649  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3650  if(!nRowCount || !nColCount)
3651  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3652  if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3653  {
3654  uno::Reference<chart::XChartDataArray> const xDataRange(
3655  getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3656  (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3657  nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3658  return xDataRange->setData(rData);
3659  }
3660  lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3661  if(rData.getLength() != nRowCount)
3662  throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this));
3663  auto vCells(GetCells());
3664  auto pCurrentCell(vCells.begin());
3665  for(const auto& rRow : rData)
3666  {
3667  if(rRow.getLength() != nColCount)
3668  throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
3669  for(const auto& rValue : rRow)
3670  {
3671  uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_SET_THROW)->setValue(rValue);
3672  ++pCurrentCell;
3673  }
3674  }
3675 }
3676 
3677 std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32>
3679 {
3680  sal_uInt32 nLeft, nTop, nRight, nBottom;
3681  nLeft = nTop = nRight = nBottom = 0;
3682  if(bRow)
3683  {
3684  nTop = m_bFirstRowAsLabel ? 1 : 0;
3685  nBottom = GetRowCount() - 1;
3686  }
3687  else
3688  {
3689  nLeft = m_bFirstColumnAsLabel ? 1 : 0;
3690  nRight = GetColumnCount() - 1;
3691  }
3692  return std::make_tuple(nLeft, nTop, nRight, nBottom);
3693 }
3694 
3695 uno::Sequence<OUString>
3697 {
3698  SolarMutexGuard aGuard;
3699  sal_uInt32 nLeft, nTop, nRight, nBottom;
3700  std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3701  if(!nRight && !nBottom)
3702  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3703  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3704  if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3705  return {}; // without labels we have no descriptions
3706  auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3707  auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3708  uno::Sequence<OUString> vResult(vCells.size());
3709  std::transform(vCells.begin(), vCells.end(), vResult.getArray(),
3710  [](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); });
3711  return vResult;
3712 }
3713 
3714 uno::Sequence<OUString> SAL_CALL SwXCellRange::getRowDescriptions()
3715 {
3716  return m_pImpl->GetLabelDescriptions(*this, true);
3717 }
3718 
3719 uno::Sequence<OUString> SAL_CALL SwXCellRange::getColumnDescriptions()
3720 {
3721  return m_pImpl->GetLabelDescriptions(*this, false);
3722 }
3723 
3725  const uno::Sequence<OUString>& rDesc, bool bRow)
3726 {
3727  SolarMutexGuard aGuard;
3728  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3729  if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3730  return; // if there are no labels we cannot set descriptions
3731  sal_uInt32 nLeft, nTop, nRight, nBottom;
3732  std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3733  if(!nRight && !nBottom)
3734  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3735  auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3736  if (!xLabelRange.is())
3737  throw uno::RuntimeException("Missing Cell Range", static_cast<cppu::OWeakObject*>(&rThis));
3738  auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3739  if (sal::static_int_cast<sal_uInt32>(rDesc.getLength()) != vCells.size())
3740  throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(&rThis));
3741  auto pDescIterator(rDesc.begin());
3742  for(auto& xCell : vCells)
3743  uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->setString(*pDescIterator++);
3744 }
3745 
3747  const uno::Sequence<OUString>& rRowDesc)
3748 {
3749  m_pImpl->SetLabelDescriptions(*this, rRowDesc, true);
3750 }
3751 
3753  const uno::Sequence<OUString>& rColumnDesc)
3754 {
3755  m_pImpl->SetLabelDescriptions(*this, rColumnDesc, false);
3756 }
3757 
3759  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3760 {
3761  // no need to lock here as m_pImpl is const and container threadsafe
3762  std::unique_lock aGuard(m_pImpl->m_Mutex);
3763  m_pImpl->m_ChartListeners.addInterface(aGuard, xListener);
3764 }
3765 
3767  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3768 {
3769  // no need to lock here as m_pImpl is const and container threadsafe
3770  std::unique_lock aGuard(m_pImpl->m_Mutex);
3771  m_pImpl->m_ChartListeners.removeInterface(aGuard, xListener);
3772 }
3773 
3775  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3776 
3778  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3779 
3780 uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor()
3781 {
3782  SolarMutexGuard aGuard;
3784 }
3785 
3786 void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
3787 {
3788  SolarMutexGuard aGuard;
3789  SwSortOptions aSortOpt;
3790  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3791  if(pFormat && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
3792  {
3793  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
3794  rTableCursor.MakeBoxSels();
3795  UnoActionContext aContext(pFormat->GetDoc());
3796  pFormat->GetDoc()->SortTable(rTableCursor.GetSelectedBoxes(), aSortOpt);
3797  }
3798 }
3799 
3801 {
3802  return m_RangeDescriptor.nRight - m_RangeDescriptor.nLeft + 1;
3803 }
3804 
3806 {
3807  return m_RangeDescriptor.nBottom - m_RangeDescriptor.nTop + 1;
3808 }
3809 
3811 {
3812  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3813  return pFormat ? &(*m_pImpl->m_pTableCursor) : nullptr;
3814 }
3815 
3817 {
3818  uno::Reference<uno::XInterface> const xThis(m_wThis);
3819  if(rHint.GetId() == SfxHintId::Dying)
3820  {
3821  m_pFrameFormat = nullptr;
3822  m_pTableCursor.reset(nullptr);
3823  }
3824  if (xThis.is())
3825  { // fdo#72695: if UNO object is already dead, don't revive it with event
3826  if(m_pFrameFormat)
3827  {
3828  std::unique_lock aGuard(m_Mutex);
3829  lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
3830  }
3831  else
3832  {
3833  std::unique_lock aGuard(m_Mutex);
3834  m_ChartListeners.disposeAndClear(aGuard, lang::EventObject(xThis));
3835  }
3836  }
3837 }
3838 
3840 {
3841 private:
3843 
3844 public:
3845  explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
3846  {
3847  StartListening(rFrameFormat.GetNotifier());
3848  }
3849  SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
3850  virtual void Notify(const SfxHint&) override;
3851 };
3852 
3853 // SwXTableRows
3854 
3856  { return "SwXTableRows"; }
3857 
3858 sal_Bool SwXTableRows::supportsService(const OUString& rServiceName)
3859  { return cppu::supportsService(this, rServiceName); }
3860 
3861 uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames()
3862  { return { "com.sun.star.text.TableRows" }; }
3863 
3864 
3866  m_pImpl(new SwXTableRows::Impl(rFrameFormat))
3867 { }
3868 
3870 { }
3871 
3873 {
3874  return m_pImpl->GetFrameFormat();
3875 }
3876 
3878 {
3879  SolarMutexGuard aGuard;
3880  SwFrameFormat* pFrameFormat = GetFrameFormat();
3881  if(!pFrameFormat)
3882  throw uno::RuntimeException();
3883  SwTable* pTable = SwTable::FindTable(pFrameFormat);
3884  return pTable->GetTabLines().size();
3885 }
3886 
3889 {
3890  SolarMutexGuard aGuard;
3891  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3892  if(nIndex < 0)
3893  throw lang::IndexOutOfBoundsException();
3894  SwTable* pTable = SwTable::FindTable( pFrameFormat );
3895  if(o3tl::make_unsigned(nIndex) >= pTable->GetTabLines().size())
3896  throw lang::IndexOutOfBoundsException();
3897  SwTableLine* pLine = pTable->GetTabLines()[nIndex];
3898  FindUnoInstanceHint<SwTableLine,SwXTextTableRow> aHint{pLine};
3899  pFrameFormat->GetNotifier().Broadcast(aHint);
3900  if(!aHint.m_pResult)
3901  aHint.m_pResult = new SwXTextTableRow(pFrameFormat, pLine);
3902  uno::Reference<beans::XPropertySet> xRet = static_cast<beans::XPropertySet*>(aHint.m_pResult.get());
3903  return uno::Any(xRet);
3904 }
3905 
3907 {
3909 }
3910 
3912 {
3913  SolarMutexGuard aGuard;
3914  SwFrameFormat* pFrameFormat = GetFrameFormat();
3915  if(!pFrameFormat)
3916  throw uno::RuntimeException();
3917  // a table always has rows
3918  return true;
3919 }
3920 
3921 void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3922 {
3923  SolarMutexGuard aGuard;
3924  if (nCount == 0)
3925  return;
3926  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3927  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3928  const size_t nRowCount = pTable->GetTabLines().size();
3929  if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nRowCount)
3930  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3931  const OUString sTLName = sw_GetCellName(0, nIndex);
3932  const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3933  bool bAppend = false;
3934  if(!pTLBox)
3935  {
3936  bAppend = true;
3937  // to append at the end the cursor must be in the last line
3938  SwTableLines& rLines = pTable->GetTabLines();
3939  SwTableLine* pLine = rLines.back();
3940  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
3941  pTLBox = rBoxes.front();
3942  }
3943  if(!pTLBox)
3944  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3945  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3946  SwPosition aPos(*pSttNd);
3947  // set cursor to the upper-left cell of the range
3948  UnoActionContext aAction(pFrameFormat->GetDoc());
3949  std::shared_ptr<SwUnoTableCursor> const pUnoCursor(
3950  std::dynamic_pointer_cast<SwUnoTableCursor>(
3951  pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true)));
3952  pUnoCursor->Move( fnMoveForward, GoInNode );
3953  {
3954  // remove actions - TODO: why?
3955  UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
3956  }
3957  pFrameFormat->GetDoc()->InsertRow(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
3958 }
3959 
3960 void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3961 {
3962  SolarMutexGuard aGuard;
3963  if (nCount == 0)
3964  return;
3965  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3966  if(nIndex < 0 || nCount <=0 )
3967  throw uno::RuntimeException();
3968  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3969  OUString sTLName = sw_GetCellName(0, nIndex);
3970  const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3971  if(!pTLBox)
3972  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3973  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3974  SwPosition aPos(*pSttNd);
3975  // set cursor to the upper-left cell of the range
3976  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
3977  pUnoCursor->Move(fnMoveForward, GoInNode);
3978  pUnoCursor->SetRemainInSection( false );
3979  const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
3980  const SwTableBox* pBLBox = pTable->GetTableBox( sBLName );
3981  if(!pBLBox)
3982  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3983  pUnoCursor->SetMark();
3984  pUnoCursor->GetPoint()->nNode = *pBLBox->GetSttNd();
3985  pUnoCursor->Move(fnMoveForward, GoInNode);
3986  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
3987  {
3988  // HACK: remove pending actions for selecting old style tables
3989  UnoActionRemoveContext aRemoveContext(rCursor);
3990  }
3991  rCursor.MakeBoxSels();
3992  { // these braces are important
3993  UnoActionContext aAction(pFrameFormat->GetDoc());
3994  pFrameFormat->GetDoc()->DeleteRow(*pUnoCursor);
3995  pUnoCursor.reset();
3996  }
3997  {
3998  // invalidate all actions - TODO: why?
3999  UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4000  }
4001 }
4002 
4004 {
4005  if(rHint.GetId() == SfxHintId::Dying)
4006  m_pFrameFormat = nullptr;
4007 }
4008 
4009 // SwXTableColumns
4010 
4012 {
4014  public:
4015  explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
4016  {
4017  StartListening(rFrameFormat.GetNotifier());
4018  }
4019  SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
4020  virtual void Notify(const SfxHint&) override;
4021 };
4022 
4024  { return "SwXTableColumns"; }
4025 
4026 sal_Bool SwXTableColumns::supportsService(const OUString& rServiceName)
4027  { return cppu::supportsService(this, rServiceName); }
4028 
4030  { return { "com.sun.star.text.TableColumns"}; }
4031 
4032 
4034  m_pImpl(new SwXTableColumns::Impl(rFrameFormat))
4035 { }
4036 
4038 { }
4039 
4041 {
4042  return m_pImpl->GetFrameFormat();
4043 }
4044 
4046 {
4047  SolarMutexGuard aGuard;
4048  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4049  SwTable* pTable = SwTable::FindTable( pFrameFormat );
4050 // if(!pTable->IsTableComplex())
4051 // throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
4052  SwTableLines& rLines = pTable->GetTabLines();
4053  SwTableLine* pLine = rLines.front();
4054  return pLine->GetTabBoxes().size();
4055 }
4056 
4058 {
4059  SolarMutexGuard aGuard;
4060  if(nIndex < 0 || getCount() <= nIndex)
4061  throw lang::IndexOutOfBoundsException();
4062  return uno::Any(uno::Reference<uno::XInterface>()); // i#21699 not supported
4063 }
4064 
4066 {
4068 }
4069 
4071 {
4072  SolarMutexGuard aGuard;
4073  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
4074  return true;
4075 }
4076 
4078 void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4079 {
4080  SolarMutexGuard aGuard;
4081  if (nCount == 0)
4082  return;
4083  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4084  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4085  SwTableLines& rLines = pTable->GetTabLines();
4086  SwTableLine* pLine = rLines.front();
4087  const size_t nColCount = pLine->GetTabBoxes().size();
4088  if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nColCount)
4089  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4090  const OUString sTLName = sw_GetCellName(nIndex, 0);
4091  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4092  bool bAppend = false;
4093  if(!pTLBox)
4094  {
4095  bAppend = true;
4096  // to append at the end the cursor must be in the last line
4097  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
4098  pTLBox = rBoxes.back();
4099  }
4100  if(!pTLBox)
4101  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4102  const SwStartNode* pSttNd = pTLBox->GetSttNd();
4103  SwPosition aPos(*pSttNd);
4104  UnoActionContext aAction(pFrameFormat->GetDoc());
4105  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4106  pUnoCursor->Move(fnMoveForward, GoInNode);
4107 
4108  {
4109  // remove actions - TODO: why?
4110  UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
4111  }
4112 
4113  pFrameFormat->GetDoc()->InsertCol(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
4114 }
4115 
4117 void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4118 {
4119  SolarMutexGuard aGuard;
4120  if (nCount == 0)
4121  return;
4122  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4123  if(nIndex < 0 || nCount <=0 )
4124  throw uno::RuntimeException();
4125  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4126  const OUString sTLName = sw_GetCellName(nIndex, 0);
4127  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4128  if(!pTLBox)
4129  throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4130  const SwStartNode* pSttNd = pTLBox->GetSttNd();
4131  SwPosition aPos(*pSttNd);
4132  // set cursor to the upper-left cell of the range
4133  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4134  pUnoCursor->Move(fnMoveForward, GoInNode);
4135  pUnoCursor->SetRemainInSection(false);
4136  const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
4137  const SwTableBox* pTRBox = pTable->GetTableBox(sTRName);
4138  if(!pTRBox)
4139  throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4140  pUnoCursor->SetMark();
4141  pUnoCursor->GetPoint()->nNode = *pTRBox->GetSttNd();
4142  pUnoCursor->Move(fnMoveForward, GoInNode);
4143  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
4144  {
4145  // HACK: remove pending actions for selecting old style tables
4146  UnoActionRemoveContext aRemoveContext(rCursor);
4147  }
4148  rCursor.MakeBoxSels();
4149  { // these braces are important
4150  UnoActionContext aAction(pFrameFormat->GetDoc());
4151  pFrameFormat->GetDoc()->DeleteCol(*pUnoCursor);
4152  pUnoCursor.reset();
4153  }
4154  {
4155  // invalidate all actions - TODO: why?
4156  UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4157  }
4158 }
4159 
4161 {
4162  if(rHint.GetId() == SfxHintId::Dying)
4163  m_pFrameFormat = nullptr;
4164 }
4165 
4166 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unotbl.cxx:1557
virtual SvxFormatBreakItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetTableBoxFormulaAttrs(SwTableBox &rBox, const SfxItemSet &rSet)
Definition: ndtbl.cxx:4168
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
bool IsTableComplex() const
Definition: swtable.cxx:1446
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:985
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:692
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:3855
Starts a section of nodes in the document model.
Definition: node.hxx:313
SwNodeOffset min(const SwNodeOffset &a, const SwNodeOffset &b)
Definition: nodeoffset.hxx:35
virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override
Definition: unotbl.cxx:3612
static uno::Any lcl_GetSpecialProperty(SwFrameFormat *pFormat, const SfxItemPropertyMapEntry *pEntry)
Definition: unotbl.cxx:257
void Normalize()
Definition: unotbl.cxx:536
#define FN_UNO_WRAP
Definition: cmdid.h:570
Base class of the Writer layout elements.
Definition: frame.hxx:314
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1728
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:1613
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
void DeleteMark()
Definition: pam.hxx:178
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:1931
SwFrameFormat * m_pFormat
Definition: unotbl.hxx:155
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1378
static css::uno::Reference< css::text::XTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:1987
void InsertBox(const SwTableBox &rTableBox)
Definition: swcrsr.cxx:2515
static css::table::BorderLine2 SvxLineToLine(const editeng::SvxBorderLine *pLine, bool bConvert)
bool IsUsed(const sw::BroadcastingModify &) const
Definition: poolfmt.cxx:86
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:224
UNOTOOLS_DLLPUBLIC css::uno::Any GetProperty(OUString const &url, OUString const &property)
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:155
SwMoveFnCollection const & fnTableEnd
Definition: paminit.cxx:53
bool hasValue()
sal_Int32 nIndex
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotbl.cxx:756
void SetLabelDescriptions(SwXCellRange &rThis, const css::uno::Sequence< OUString > &rDesc, bool bRow)
Definition: unotbl.cxx:3724
virtual const SwDoc * GetDoc() const =0
virtual const SwDoc * GetDoc() const override
Definition: unotbl.cxx:1434
const SwSelBoxes & GetSelectedBoxes() const
Definition: swcrsr.hxx:280
size_t m_nFndPos
Definition: unotbl.hxx:73
#define FN_UNO_TABLE_COLUMN_SEPARATORS
Definition: cmdid.h:549
#define PROPERTY_MAP_TEXT_TABLE_CURSOR
Definition: unomap.hxx:49
const T * GetItemIfSet(TypedWhichId< T > nWhich, bool bSrchInParent=true) const
virtual OUString SAL_CALL getFormula() override
Definition: unotbl.cxx:827
Marks a position in the document model.
Definition: pam.hxx:36
virtual void SAL_CALL attach(const css::uno::Reference< css::text::XTextRange > &xTextRange) override
Definition: unotbl.cxx:2079
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
static std::pair< sal_uInt16, sal_uInt16 > ThrowIfComplex(SwXTextTable &rThis)
Definition: unotbl.cxx:1942
static void GetTabBorders(const SwCursor &rCursor, SfxItemSet &rSet)
Definition: ndtbl1.cxx:1022
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:3849
bool IsSectionNode() const
Definition: node.hxx:654
Impl(SwFrameFormat *const pFrameFormat)
Definition: unotbl.cxx:1918
::comphelper::OInterfaceContainerHelper4< chart::XChartDataChangeEventListener > m_ChartListeners
Definition: unotbl.cxx:1902
void SetLeft(tools::Long nNew)
Definition: tabcol.hxx:83
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:1070
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:4160
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1345
virtual sal_Bool SAL_CALL goLeft(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unotbl.cxx:1510
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotbl.cxx:916
sal_Int32 getLength(std::unique_lock< std::mutex > &rGuard) const
bool IsDefault() const
Definition: format.hxx:129
constexpr auto toTwips(N number, Length from)
constexpr TypedWhichId< SwTableBoxNumFormat > RES_BOXATR_FORMAT(RES_BOXATR_BEGIN)
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:3242
CursorType
SwTableBox * m_pBox
Definition: unotbl.hxx:68
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unotbl.cxx:2164
#define FN_TABLE_HEADLINE_COUNT
Definition: cmdid.h:406
virtual const SwRootFrame * GetCurrentLayout() const =0
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2662
constexpr SwNodeOffset NODE_OFFSET_MAX(SAL_MAX_INT32)
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1119
SwDocShell * GetDocShell()
Definition: doc.hxx:1351
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1410
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unotbl.cxx:2407
virtual sal_Bool SAL_CALL isNotANumber(double nNumber) override
Definition: unotbl.cxx:2386
virtual void SAL_CALL setRowDescriptions(const css::uno::Sequence< OUString > &aRowDescriptions) override
Definition: unotbl.cxx:2334
const SwFrameFormats * GetTableFrameFormats() const
Definition: doc.hxx:810
static void FillUIName(const OUString &rName, OUString &rFillName, SwGetPoolIdFromName)
static void lcl_SetTableSeparators(const uno::Any &rVal, SwTable *pTable, SwTableBox const *pBox, bool bRow, SwDoc *pDoc)
Definition: unotbl.cxx:630
virtual void SAL_CALL insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) override
Definition: unotbl.cxx:3921
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:1674
OString sFormula
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
void DeleteRow(const SwCursor &rCursor)
Deleting Columns/Rows.
Definition: ndtbl.cxx:1820
SwNodeIndex nNode
Definition: pam.hxx:38
void SetFrameFormat(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:1932
void SetRight(tools::Long nNew)
Definition: tabcol.hxx:84
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:2451
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:1217
virtual css::table::CellContentType SAL_CALL getType() override
Definition: unotbl.cxx:885
sal_uInt16 char char * pDesc
SAL_DLLPRIVATE css::uno::WeakReference< css::uno::XInterface > const & GetXObject() const
Definition: frmfmt.hxx:170
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:1734
#define MID_FRMSIZE_REL_WIDTH
Definition: unomid.h:72
virtual bool PutValue(const css::uno::Any &rVal, sal_uInt8 nMemberId) override
virtual const SwPaM * GetPaM() const override
Definition: unotbl.cxx:1432
virtual void SetModified()=0
Must be called manually at changes of format.
unsigned short m_nRows
Definition: unotbl.cxx:1915
long Long
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:369
virtual sal_Int32 SAL_CALL getCount() override
Definition: unotbl.cxx:4045
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotbl.cxx:764
#define MINLAY
Definition: swtypes.hxx:62
const editeng::SvxBorderLine * GetVert() const
const SwPosition * GetMark() const
Definition: pam.hxx:210
SwTabFrame is one table in the document layout, containing rows (which contain cells).
Definition: tabfrm.hxx:46
static void lcl_CursorSelect(SwPaM &rCursor, bool bExpand)
Definition: unotbl.cxx:590
uno::WeakReference< uno::XInterface > m_wThis
Definition: unotbl.cxx:1899
const wchar_t *typedef int(__stdcall *DllNativeUnregProc)(int
SwTableBox * GetTableBox() const
Definition: unotbl.hxx:143
sal_Int64 n
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray() override
Definition: unotbl.cxx:2275
SvxBoxInfoItem & rBoxInfoItem
SwTableFormat * FindTableFormatByName(const OUString &rName, bool bAll=false) const
Definition: ndtbl.cxx:3944
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1090
bool Left(sal_uInt16 nCnt)
Definition: swcrsr.hxx:172
Definition: doc.hxx:187
constexpr sal_uInt16 RES_FRMATR_END(133)
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3543
#define MID_PAGEDESC_PAGENUMOFFSET
Definition: unomid.h:27
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1483
#define MID_GRAPHIC_TRANSPARENT
TElementType * Next()
Definition: calbck.hxx:364
#define FN_TABLE_RELATIVE_WIDTH
Definition: cmdid.h:479
virtual SvxShadowItem * Clone(SfxItemPool *pPool=nullptr) const override
helper class to disable creation of an action by a callback event in particular, change event from a ...
Definition: rootfrm.hxx:450
#define RIGHT_BORDER_DISTANCE
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
void InvalidatePos()
Definition: frame.hxx:1043
const ContentProperties & rData
const_iterator find(const Value &x) const
constexpr TypedWhichId< SvxFormatBreakItem > RES_BREAK(94)
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotbl.cxx:3335
SwTableLine is one table row in the document model.
Definition: swtable.hxx:357
sal_Int32 nLeft
Definition: unotbl.hxx:247
SwNode & GetNode() const
Definition: ndindex.hxx:128
SwFrameFormat * m_pTableFormat
Definition: unotbl.hxx:70
virtual ~SwXTextTable() override
Definition: unotbl.cxx:1983
virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override
Definition: unotbl.cxx:2295
sal_Int32 GetRowCount() const
Definition: unotbl.cxx:3805
#define MID_BACK_COLOR
css::uno::WeakReference< css::table::XTableColumns > m_xColumns
Definition: unotbl.cxx:1907
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:3139
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:196
SwSectionFormat * GetFormat()
Definition: section.hxx:336
virtual ~SwXTextTableRow() override
Definition: unotbl.cxx:1238
virtual sal_Int32 SAL_CALL getCount() override
Definition: unotbl.cxx:3877
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
void MakeBoxSels()
Definition: unocrsr.cxx:182
double GetValue() const
Definition: cellatr.hxx:95
::comphelper::OInterfaceContainerHelper4< css::lang::XEventListener > m_EventListeners
Definition: unotbl.cxx:1901
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:1244
virtual sal_Bool SAL_CALL gotoCellByName(const OUString &aCellName, sal_Bool bExpand) override
Definition: unotbl.cxx:1501
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotbl.cxx:3906
bool ConvertSortProperties(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor, SwSortOptions &rSortOpt)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
const editeng::SvxBorderLine * GetRight() const
SwTableLine * front() const
Definition: swtable.hxx:81
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
static SwTableLine * FindLine(SwTable *pTable, SwTableLine const *pLine)
Definition: unotbl.cxx:1396
void makeTableCellRedline(SwTableBox &rTableBox, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
virtual void SAL_CALL removeByIndex(sal_Int32 nIndex, sal_Int32 nCount) override
Definition: unotbl.cxx:4117
OUString sw_GetCellName(sal_Int32 nColumn, sal_Int32 nRow)
get cell name at a specified coordinate
Definition: unotbl.cxx:479
#define FN_UNO_CELL_NAME
Definition: cmdid.h:595
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:204
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
SfxHintId GetId() const
#define LEFT_BORDER
virtual ~SwXTableRows() override
Definition: unotbl.cxx:3869
#define PROPERTY_MAP_TEXT_TABLE
Definition: unomap.hxx:34
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotbl.cxx:1967
size_type size() const
Definition: swtable.hxx:76
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:264
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:269
const OUString & GetName() const
Definition: pagedesc.hxx:196
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
#define FN_UNO_TABLE_NAME
Definition: cmdid.h:622
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:1409
sal_uInt16 GetRowCount()
Definition: unotbl.cxx:3035
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName(const OUString &aRange) override
Definition: unotbl.cxx:3308
const SvxBoxItem & GetBox(bool=true) const
Definition: frmatr.hxx:84
uno::WeakReference< uno::XInterface > m_wThis
Definition: unotbl.cxx:3115
bool GotoCurrTable(SwPaM &rCurrentCursor, SwMoveFnCollection const &fnPosTable, bool bInReadOnly)
Definition: trvltbl.cxx:633
constexpr auto convertTwipToMm100(N n)
sal_Int32 getRowSpan() const
Definition: swtable.cxx:77
const SwSection & GetSection() const
Definition: node.hxx:549
void SetRightMax(tools::Long nNew)
Definition: tabcol.hxx:85
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:3174
const SwStartNode * m_pStartNode
Definition: unotbl.hxx:69
SwTableLine * back() const
Definition: swtable.hxx:82
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:357
double GetForcedNumericalValue() const
Definition: unotbl.cxx:1160
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:3177
#define FN_UNO_TABLE_BORDER2
Definition: cmdid.h:638
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
Definition: swtable.cxx:1955
sal_uInt16 IsFormulaOrValueBox() const
Definition: swtable.cxx:2739
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotbl.cxx:4065
uno::Sequence< OUString > GetLabelDescriptions(SwXCellRange &rThis, bool bRow)
Definition: unotbl.cxx:3696
sal_uInt16 sal_Unicode
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: unotbl.cxx:930
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
void GetTabCols(SwTabCols &rToFill, const SwTableBox *pStart, bool bHidden=false, bool bCurRowOnly=false) const
Definition: swtable.cxx:519
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:1211
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:737
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotbl.cxx:1082
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:3537
#define FN_UNO_TABLE_BORDER
Definition: cmdid.h:548
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotbl.cxx:751
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3546
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotbl.cxx:954
sal_Int32 nBottom
Definition: unotbl.hxx:248
bool UpdateTableStyleFormatting(SwTableNode *pTableNode=nullptr, bool bResetDirect=false, OUString const *pStyleName=nullptr)
Update the direct formatting according to the current table style.
Definition: fetab.cxx:1279
static SwPageDesc * GetByName(SwDoc &rDoc, std::u16string_view rName)
Definition: pagedesc.cxx:574
virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unotbl.cxx:1528
constexpr TypedWhichId< SwFormatHoriOrient > RES_HORI_ORIENT(103)
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:296
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:4023
SwIndex nContent
Definition: pam.hxx:39
void SetBoxAttr(const SwCursor &rCursor, const SfxPoolItem &rNew)
Definition: ndtbl1.cxx:1243
#define SAL_MAX_UINT16
SvxBoxInfoItemValidFlags
static bool lcl_LineToSvxLine(const table::BorderLine &rLine, SvxBorderLine &rSvxLine)
Definition: unotbl.cxx:163
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:577
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history...
Definition: docfmt.cxx:452
sal_uInt32 GetStandardIndex(LanguageType eLnge=LANGUAGE_DONTKNOW)
const OUString & GetName() const
Definition: format.hxx:131
virtual sal_Bool SAL_CALL goDown(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unotbl.cxx:1538
int nCount
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotbl.cxx:3911
virtual void SAL_CALL release() noexcept override
Definition: unotbl.cxx:774
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
void getPropertyValue(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
#define FN_UNO_PARENT_TEXT
Definition: cmdid.h:561
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) override
Definition: unotbl.cxx:2180
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:948
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
Impl(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4015
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:3842
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:1375
const SwTable & GetTable() const
Definition: node.hxx:506
SwFrameFormat * m_pFrameFormat
Definition: unotbl.hxx:195
const SvxFormatKeepItem & GetKeep(bool=true) const
Definition: frmatr.hxx:86
#define PROPERTY_MAP_TEXT_TABLE_ROW
Definition: unomap.hxx:47
sal_Int32 nRight
Definition: unotbl.hxx:249
static sal_uInt16 nCol2
Definition: srtdlg.cxx:44
SAL_DLLPRIVATE void SetXObject(css::uno::Reference< css::uno::XInterface > const &xObject)
Definition: frmfmt.hxx:172
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:191
virtual OUString GetName() const override
#define FN_UNO_TABLE_COLUMN_RELATIVE_SUM
Definition: cmdid.h:550
virtual css::uno::Reference< css::table::XTableRows > SAL_CALL getRows() override
Definition: unotbl.cxx:2016
void UpdateCharts(const OUString &rName) const
Definition: docchart.cxx:141
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:3861
static SW_DLLPUBLIC void GetCellPosition(const OUString &rCellName, sal_Int32 &o_rColumn, sal_Int32 &o_rRow)
get position of a cell with a given name
Definition: unotbl.cxx:351
bool IsHidden(size_t nPos) const
Definition: tabcol.hxx:67
size_type size() const
static bool GetBoxAttr(const SwCursor &rCursor, std::unique_ptr< SfxPoolItem > &rToFill)
Retrieves a box attribute from the given cursor.
Definition: ndtbl1.cxx:1288
const char * sName
static void lcl_InspectLines(SwTableLines &rLines, std::vector< OUString > &rAllNames)
Definition: unotbl.cxx:554
#define FN_UNO_TABLE_TEMPLATE_NAME
Definition: cmdid.h:643
void InsertRow(const SwCursor &rCursor, sal_uInt16 nCnt=1, bool bBehind=true)
Definition: ndtbl.cxx:1761
void DeleteCol(const SwCursor &rCursor)
Definition: ndtbl.cxx:1920
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:441
int sw_CompareCellsByRowFirst(const OUString &rCellName1, const OUString &rCellName2)
compare position of two cells (check rows first)
Definition: unotbl.cxx:403
Specific frame formats (frames, DrawObjects).
bool IsOLENode() const
Definition: node.hxx:662
#define FN_UNO_ROW_AUTO_HEIGHT
Definition: cmdid.h:553
#define LEFT_BORDER_DISTANCE
const css::uno::Sequence< sal_Int8 > & getSeq() const
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1731
virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override
Definition: unotbl.cxx:2322
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:4019
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
void SetBoxAlign(const SwCursor &rCursor, sal_uInt16 nAlign)
Definition: ndtbl1.cxx:1353
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:262
#define MID_FRMSIZE_WIDTH
Definition: unomid.h:74
virtual css::uno::Reference< css::text::XTextTableCursor > SAL_CALL createCursorByCellName(const OUString &aCellName) override
Definition: unotbl.cxx:2067
void EndListeningAll()
SwXTextTableCursor(SwFrameFormat *pFormat, SwTableBox const *pBox)
Definition: unotbl.cxx:1442
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:529
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:137
const editeng::SvxBorderLine * GetHori() const
OUString GetName() const
Definition: swtable.cxx:1998
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:502
#define MID_L_MARGIN
virtual SvxULSpaceItem * Clone(SfxItemPool *pPool=nullptr) const override
const editeng::SvxBorderLine * GetTop() const
virtual css::uno::Sequence< OUString > SAL_CALL getCellNames() override
Definition: unotbl.cxx:2053
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:2106
bool GetDefaultTextContentValue(css::uno::Any &rAny, std::u16string_view rPropertyName, sal_uInt16 nWID=0)
sal_uInt16 char * pName
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:3067
Style of a layout element.
Definition: frmfmt.hxx:59
virtual OUString SAL_CALL getString() override
Definition: unotext.cxx:894
static rtl::Reference< SwXCell > lcl_CreateXCell(SwFrameFormat *pFormat, sal_Int32 nColumn, sal_Int32 nRow)
Definition: unotbl.cxx:544
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
virtual void SAL_CALL removeChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &aListener) override
Definition: unotbl.cxx:3766
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:1327
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:2714
void Broadcast(const SfxHint &rHint)
static void lcl_GetTableSeparators(uno::Any &rRet, SwTable const *pTable, SwTableBox const *pBox, bool bRow)
Definition: unotbl.cxx:601
const editeng::SvxBorderLine * GetLeft() const
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
Definition: unotbl.cxx:3212
sal_Int32 nTop
Definition: unotbl.hxx:246
int i
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:959
void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
cleanup order in a range
Definition: unotbl.cxx:524
SwTableBox * FindBox(SwTable *pTable, SwTableBox *pBox)
search if a box exists in a table
Definition: unotbl.cxx:1140
uno_Any a
SwXTableColumns(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4033
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
std::tuple< sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32 > GetLabelCoordinates(bool bRow)
Definition: unotbl.cxx:3678
const SwPosition * GetPoint() const
Definition: pam.hxx:208
const SfxItemPropertySet * m_pPropSet
Definition: unotbl.cxx:3122
SwXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3192
bool empty() const
Definition: swtable.hxx:75
virtual void SAL_CALL acquire() noexcept override
Definition: unotbl.cxx:769
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
#define LANGUAGE_SYSTEM
virtual sal_Int32 SAL_CALL getError() override
Definition: unotbl.cxx:909
SwNodeOffset IsValidNumTextNd(bool bCheckAttr=true) const
Definition: swtable.cxx:2656
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:1722
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:3098
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:1226
virtual void SAL_CALL setValue(double nValue) override
Definition: unotbl.cxx:879
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unotbl.cxx:903
void SetTabBorders(const SwCursor &rCursor, const SfxItemSet &rSet)
Definition: ndtbl1.cxx:647
bool IsTextFormat(sal_uInt32 nFIndex) const
#define TOP_BORDER
TElementType * First()
Definition: calbck.hxx:356
SwNodeOffset GetIndex() const
Definition: node.hxx:292
virtual void SAL_CALL setData(const css::uno::Sequence< css::uno::Sequence< double > > &aData) override
Definition: unotbl.cxx:2307
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:1896
virtual void SAL_CALL initialize(sal_Int32 nRows, sal_Int32 nColumns) override
Definition: unotbl.cxx:2008
virtual ~SwXCellRange() override
Definition: unotbl.cxx:3198
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom) override
Definition: unotbl.cxx:3255
void SetTextFormatColl(const css::uno::Any &rAny, SwPaM &rPaM)
size_t size() const
Definition: tblafmt.cxx:916
void SetLine(const editeng::SvxBorderLine *pNew, SvxBoxInfoItemLine nLine)
virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) override
Definition: unotbl.cxx:3232
static sal_uInt16 nCol1
Definition: srtdlg.cxx:43
#define FN_UNO_RANGE_COL_LABEL
Definition: cmdid.h:546
SwFrameFormat * GetFrameFormat() const
Definition: unotbl.cxx:4040
virtual const SwStartNode * GetStartNode() const override
Definition: unotbl.cxx:789
virtual void SAL_CALL setColumnDescriptions(const css::uno::Sequence< OUString > &aColumnDescriptions) override
Definition: unotbl.cxx:3752
#define FN_TABLE_IS_RELATIVE_WIDTH
Definition: cmdid.h:481
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &rType) override
Definition: unotext.cxx:193
virtual void SAL_CALL insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) override
Definition: unotbl.cxx:4078
float u
unsigned char sal_Bool
void UnlockModify()
Definition: calbck.hxx:209
#define BOTTOM_BORDER_DISTANCE
sal_uInt16 GetColumnCount()
Definition: unotbl.cxx:3050
virtual void SAL_CALL setDataArray(const css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &aArray) override
Definition: unotbl.cxx:2285
const SfxItemPropertyMap & getPropertyMap() const
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:1073
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unotbl.cxx:2400
#define FN_UNO_TABLE_CELL_BACKGROUND
Definition: cmdid.h:551
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:394
void LockModify()
Definition: calbck.hxx:208
::comphelper::OInterfaceContainerHelper4< chart::XChartDataChangeEventListener > m_ChartListeners
Definition: unotbl.cxx:3117
std::mutex m_Mutex
Definition: unotbl.cxx:3116
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:380
SwTableLine * m_pLine
Definition: unotbl.hxx:156
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unotbl.cxx:3888
void SetLeftMin(tools::Long nNew)
Definition: tabcol.hxx:82
int sw_CompareCellsByColFirst(const OUString &rCellName1, const OUString &rCellName2)
compare position of two cells (check columns first)
Definition: unotbl.cxx:426
static::rtl::Reference< SwXCellRange > CreateXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3202
size
Marks a node in the document model.
Definition: ndindex.hxx:30
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:457
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unotbl.cxx:2172
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1997
SwXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, size_t nPos)
Definition: unotbl.cxx:717
css::uno::Type const & get()
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:1106
virtual sal_Bool SAL_CALL mergeRange() override
Definition: unotbl.cxx:1566
SwXTextTableRow(SwFrameFormat *pFormat, SwTableLine *pLine)