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