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