LibreOffice Module sw (master)  1
unotbl.cxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
11  * Licensed to the Apache Software Foundation (ASF) under one or more
12  * contributor license agreements. See the NOTICE file distributed
13  * with this work for additional information regarding copyright
14  * ownership. The ASF licenses this file to you under the Apache
15  * License, Version 2.0 (the "License"); you may not use this file
16  * except in compliance with the License. You may obtain a copy of
17  * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18  */
19 
20 #include <tuple>
21 #include <utility>
22 #include <memory>
23 #include <vector>
24 #include <algorithm>
25 #include <limits>
26 
28 #include <o3tl/any.hxx>
29 #include <o3tl/safeint.hxx>
30 #include <editeng/memberids.h>
31 #include <float.h>
32 #include <swtypes.hxx>
33 #include <cmdid.h>
34 #include <unocoll.hxx>
35 #include <unomid.h>
36 #include <unomap.hxx>
37 #include <unotbl.hxx>
38 #include <section.hxx>
39 #include <unocrsr.hxx>
40 #include <hints.hxx>
41 #include <swtblfmt.hxx>
42 #include <doc.hxx>
43 #include <IDocumentUndoRedo.hxx>
47 #include <IDocumentState.hxx>
49 #include <shellres.hxx>
50 #include <docary.hxx>
51 #include <ndole.hxx>
52 #include <frame.hxx>
53 #include <vcl/svapp.hxx>
54 #include <fmtfsize.hxx>
55 #include <tblafmt.hxx>
56 #include <tabcol.hxx>
57 #include <cellatr.hxx>
58 #include <fmtpdsc.hxx>
59 #include <pagedesc.hxx>
60 #include <viewsh.hxx>
61 #include <rootfrm.hxx>
62 #include <tabfrm.hxx>
63 #include <redline.hxx>
64 #include <unoport.hxx>
65 #include <unocrsrhelper.hxx>
66 #include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
67 #include <com/sun/star/text/WrapTextMode.hpp>
68 #include <com/sun/star/text/TextContentAnchorType.hpp>
69 #include <com/sun/star/text/TableColumnSeparator.hpp>
70 #include <com/sun/star/text/VertOrientation.hpp>
71 #include <com/sun/star/text/XTextSection.hpp>
72 #include <com/sun/star/table/TableBorder.hpp>
73 #include <com/sun/star/table/TableBorder2.hpp>
74 #include <com/sun/star/table/BorderLine2.hpp>
75 #include <com/sun/star/table/TableBorderDistances.hpp>
76 #include <com/sun/star/beans/PropertyAttribute.hpp>
77 #include <com/sun/star/chart/XChartDataChangeEventListener.hpp>
78 #include <com/sun/star/chart/ChartDataChangeEvent.hpp>
79 #include <com/sun/star/table/CellContentType.hpp>
80 #include <unotextrange.hxx>
81 #include <unotextcursor.hxx>
82 #include <unoparagraph.hxx>
83 #include <svl/zforlist.hxx>
85 #include <editeng/shaditem.hxx>
86 #include <editeng/lrspitem.hxx>
87 #include <editeng/ulspitem.hxx>
88 #include <fmtornt.hxx>
89 #include <editeng/keepitem.hxx>
90 #include <fmtlsplt.hxx>
91 #include <swundo.hxx>
92 #include <osl/mutex.hxx>
93 #include <SwStyleNameMapper.hxx>
94 #include <frmatr.hxx>
95 #include <sortopt.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 SfxItemPropertyMapEntry* 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, o3tl::narrowing<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();
706  SfxItemSet aSet(pDoc->GetAttrPool(), svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_VALUE>);
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 const uno::Sequence< sal_Int8 > & SwXCell::getUnoTunnelId()
756 {
757  static const UnoTunnelIdInit theSwXCellUnoTunnelId;
758  return theSwXCellUnoTunnelId.getSeq();
759 }
760 
761 sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
762 {
763  if( isUnoTunnelId<SwXCell>(rId) )
764  {
765  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
766  }
767  else
768  return SwXText::getSomething(rId);
769 }
770 
771 uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes( )
772 {
774  SwXCellBaseClass::getTypes(),
776  );
777 }
778 
779 uno::Sequence< sal_Int8 > SAL_CALL SwXCell::getImplementationId( )
780 {
781  return css::uno::Sequence<sal_Int8>();
782 }
783 
784 void SAL_CALL SwXCell::acquire( ) noexcept
785 {
786  SwXCellBaseClass::acquire();
787 }
788 
789 void SAL_CALL SwXCell::release( ) noexcept
790 {
791  SolarMutexGuard aGuard;
792 
793  SwXCellBaseClass::release();
794 }
795 
797 {
798  uno::Any aRet = SwXCellBaseClass::queryInterface(aType);
799  if(aRet.getValueType() == cppu::UnoType<void>::get())
800  aRet = SwXText::queryInterface(aType);
801  return aRet;
802 }
803 
805 {
806  const SwStartNode* pSttNd = nullptr;
807 
808  if( m_pStartNode || IsValid() )
809  pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
810 
811  return pSttNd;
812 }
813 
814 uno::Reference< text::XTextCursor >
816 {
817  return createTextCursor();
818 }
819 
820 bool SwXCell::IsValid() const
821 {
822  // FIXME: this is now a const method, to make SwXText::IsValid invisible
823  // but the const_cast here are still ridiculous. TODO: find a better way.
824  SwFrameFormat* pTableFormat = m_pBox ? GetFrameFormat() : nullptr;
825  if(!pTableFormat)
826  {
827  const_cast<SwXCell*>(this)->m_pBox = nullptr;
828  }
829  else
830  {
831  SwTable* pTable = SwTable::FindTable( pTableFormat );
832  SwTableBox const*const pFoundBox =
833  const_cast<SwXCell*>(this)->FindBox(pTable, m_pBox);
834  if (!pFoundBox)
835  {
836  const_cast<SwXCell*>(this)->m_pBox = nullptr;
837  }
838  }
839  return nullptr != m_pBox;
840 }
841 
843 {
844  SolarMutexGuard aGuard;
845  if(!IsValid())
846  return OUString();
849  aFormula.PtrToBoxNm( pTable );
850  return aFormula.GetFormula();
851 }
852 
854 void SwXCell::setFormula(const OUString& rFormula)
855 {
856  SolarMutexGuard aGuard;
857  if(!IsValid())
858  return;
859  // first this text (maybe) needs to be deleted
860  sal_uInt32 nNdPos = m_pBox->IsValidNumTextNd();
861  if(USHRT_MAX == nNdPos)
862  sw_setString( *this, OUString(), true );
863  OUString sFormula(comphelper::string::stripStart(rFormula, ' '));
864  if( !sFormula.isEmpty() && '=' == sFormula[0] )
865  sFormula = sFormula.copy( 1 );
866  SwTableBoxFormula aFormula( sFormula );
867  SwDoc* pMyDoc = GetDoc();
868  UnoActionContext aAction(pMyDoc);
869  SfxItemSet aSet(pMyDoc->GetAttrPool(), svl::Items<RES_BOXATR_FORMAT, RES_BOXATR_FORMULA>);
870  const SfxPoolItem* pItem;
871  SwFrameFormat* pBoxFormat = m_pBox->GetFrameFormat();
872  if(SfxItemState::SET != pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem)
873  || pMyDoc->GetNumberFormatter()->IsTextFormat(static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue()))
874  {
875  aSet.Put(SwTableBoxNumFormat(0));
876  }
877  aSet.Put(aFormula);
879  // update table
881  pMyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
882 }
883 
885 {
886  SolarMutexGuard aGuard;
887  // #i112652# a table cell may contain NaN as a value, do not filter that
888  if(IsValid() && !getString().isEmpty())
890  return std::numeric_limits<double>::quiet_NaN();
891 }
892 
893 void SwXCell::setValue(double rValue)
894 {
895  SolarMutexGuard aGuard;
896  sw_setValue( *this, rValue );
897 }
898 
899 table::CellContentType SwXCell::getType()
900 {
901  SolarMutexGuard aGuard;
902 
903  table::CellContentType nRes = table::CellContentType_EMPTY;
904  sal_uInt32 nNdPos = m_pBox->IsFormulaOrValueBox();
905  switch (nNdPos)
906  {
907  case 0 : nRes = table::CellContentType_TEXT; break;
908  case USHRT_MAX : nRes = table::CellContentType_EMPTY; break;
909  case RES_BOXATR_VALUE : nRes = table::CellContentType_VALUE; break;
910  case RES_BOXATR_FORMULA : nRes = table::CellContentType_FORMULA; break;
911  default :
912  OSL_FAIL( "unexpected case" );
913  }
914  return nRes;
915 }
916 
917 void SwXCell::setString(const OUString& aString)
918 {
919  SolarMutexGuard aGuard;
920  sw_setString( *this, aString );
921 }
922 
923 sal_Int32 SwXCell::getError()
924 {
925  SolarMutexGuard aGuard;
926  OUString sContent = getString();
927  return sal_Int32(sContent == SwViewShell::GetShellRes()->aCalc_Error);
928 }
929 
930 uno::Reference<text::XTextCursor> SwXCell::createTextCursor()
931 {
932  SolarMutexGuard aGuard;
933  if(!m_pStartNode && !IsValid())
934  throw uno::RuntimeException();
935  const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
936  SwPosition aPos(*pSttNd);
937  rtl::Reference<SwXTextCursor> const pXCursor =
938  new SwXTextCursor(*GetDoc(), this, CursorType::TableText, aPos);
939  auto& rUnoCursor(pXCursor->GetCursor());
940  rUnoCursor.Move(fnMoveForward, GoInNode);
941  return static_cast<text::XWordCursor*>(pXCursor.get());
942 }
943 
944 uno::Reference<text::XTextCursor> SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
945 {
946  SolarMutexGuard aGuard;
947  SwUnoInternalPaM aPam(*GetDoc());
948  if((!m_pStartNode && !IsValid()) || !::sw::XTextRangeToSwPaM(aPam, xTextPosition))
949  throw uno::RuntimeException();
950  const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
951  // skip sections
952  SwStartNode* p1 = aPam.GetNode().StartOfSectionNode();
953  while(p1->IsSectionNode())
954  p1 = p1->StartOfSectionNode();
955  if( p1 != pSttNd )
956  return nullptr;
957  return static_cast<text::XWordCursor*>(
959  *aPam.GetPoint(), aPam.GetMark()));
960 }
961 
962 uno::Reference< beans::XPropertySetInfo > SwXCell::getPropertySetInfo()
963 {
964  static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
965  return xRef;
966 }
967 
968 void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
969 {
970  SolarMutexGuard aGuard;
971  if(!IsValid())
972  return;
973  // Hack to support hidden property to transfer textDirection
974  if(rPropertyName == "FRMDirection")
975  {
976  SvxFrameDirectionItem aItem(SvxFrameDirection::Environment, RES_FRAMEDIR);
977  aItem.PutValue(aValue, 0);
979  }
980  else if(rPropertyName == "TableRedlineParams")
981  {
982  // Get the table row properties
983  uno::Sequence<beans::PropertyValue> tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
984  comphelper::SequenceAsHashMap aPropMap(tableCellProperties);
985  OUString sRedlineType;
986  if(!(aPropMap.getValue("RedlineType") >>= sRedlineType))
987  throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this));
988 
989  // Create a 'Table Cell Redline' object
990  SwUnoCursorHelper::makeTableCellRedline(*m_pBox, sRedlineType, tableCellProperties);
991 
992 
993  }
994  else
995  {
996  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
997  if ( !pEntry )
998  {
999  // not a table property: ignore it, if it is a paragraph/character property
1001  pEntry = rParaPropSet.getPropertyMap().getByName(rPropertyName);
1002 
1003  if ( pEntry )
1004  return;
1005  }
1006 
1007  if(!pEntry)
1008  throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
1009  if(pEntry->nWID != FN_UNO_CELL_ROW_SPAN)
1010  {
1011  SwFrameFormat* pBoxFormat = m_pBox->ClaimFrameFormat();
1012  SwAttrSet aSet(pBoxFormat->GetAttrSet());
1013  m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
1014  pBoxFormat->GetDoc()->SetAttr(aSet, *pBoxFormat);
1015  }
1016  else if(aValue.isExtractableTo(cppu::UnoType<sal_Int32>::get()))
1017  m_pBox->setRowSpan(aValue.get<sal_Int32>());
1018  }
1019 }
1020 
1021 uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
1022 {
1023  SolarMutexGuard aGuard;
1024  if(!IsValid())
1025  return uno::Any();
1026  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1027  if(!pEntry)
1028  throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
1029  switch(pEntry->nWID)
1030  {
1031  case FN_UNO_CELL_ROW_SPAN:
1032  return uno::makeAny(m_pBox->getRowSpan());
1033  case FN_UNO_TEXT_SECTION:
1034  {
1035  SwFrameFormat* pTableFormat = GetFrameFormat();
1036  SwTable* pTable = SwTable::FindTable(pTableFormat);
1037  SwTableNode* pTableNode = pTable->GetTableNode();
1038  SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
1039  if(!pSectionNode)
1040  return uno::Any();
1041  SwSection& rSect = pSectionNode->GetSection();
1042  return uno::makeAny(SwXTextSections::GetObject(*rSect.GetFormat()));
1043  }
1044  break;
1045  case FN_UNO_CELL_NAME:
1046  return uno::makeAny(m_pBox->GetName());
1049  {
1050  //redline can only be returned if it's a living object
1051  return SwXText::getPropertyValue(rPropertyName);
1052  }
1053  break;
1054  case FN_UNO_PARENT_TEXT:
1055  {
1056  if (!m_xParentText.is())
1057  {
1058  const SwStartNode* pSttNd = m_pBox->GetSttNd();
1059  if (!pSttNd)
1060  return uno::Any();
1061 
1062  const SwTableNode* pTableNode = pSttNd->FindTableNode();
1063  if (!pTableNode)
1064  return uno::Any();
1065 
1066  SwPosition aPos(*pTableNode);
1067  SwDoc& rDoc = aPos.GetDoc();
1068  m_xParentText = sw::CreateParentXText(rDoc, aPos);
1069  }
1070 
1071  return uno::makeAny(m_xParentText);
1072  }
1073  break;
1074  default:
1075  {
1076  const SwAttrSet& rSet = m_pBox->GetFrameFormat()->GetAttrSet();
1077  uno::Any aResult;
1078  m_pPropSet->getPropertyValue(rPropertyName, rSet, aResult);
1079  return aResult;
1080  }
1081  }
1082 }
1083 
1084 void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1085  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1086 
1087 void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1088  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1089 
1090 void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1091  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1092 
1093 void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1094  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1095 
1096 uno::Reference<container::XEnumeration> SwXCell::createEnumeration()
1097 {
1098  SolarMutexGuard aGuard;
1099  if(!IsValid())
1100  return uno::Reference<container::XEnumeration>();
1101  const SwStartNode* pSttNd = m_pBox->GetSttNd();
1102  SwPosition aPos(*pSttNd);
1103  auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
1104  pUnoCursor->Move(fnMoveForward, GoInNode);
1105  // remember table and start node for later travelling
1106  // (used in export of tables in tables)
1108 }
1109 
1111 {
1113 }
1114 
1116 {
1117  return true;
1118 }
1119 
1120 void SwXCell::Notify(const SfxHint& rHint)
1121 {
1122  if(rHint.GetId() == SfxHintId::Dying)
1123  {
1124  m_pTableFormat = nullptr;
1125  }
1126  else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableBox, SwXCell>*>(&rHint))
1127  {
1128  if(!pFindHint->m_pResult && pFindHint->m_pCore == GetTableBox())
1129  pFindHint->m_pResult = this;
1130  }
1131 }
1132 
1134 {
1135  if(!pTableFormat || !pBox)
1136  return nullptr;
1137  if(!pTable)
1138  pTable = SwTable::FindTable(pTableFormat);
1140  if(it == pTable->GetTabSortBoxes().end())
1141  return nullptr;
1142  size_t const nPos = it - pTable->GetTabSortBoxes().begin();
1143  FindUnoInstanceHint<SwTableBox, SwXCell> aHint{pBox};
1144  pTableFormat->GetNotifier().Broadcast(aHint);
1145  return aHint.m_pResult ? aHint.m_pResult.get() : new SwXCell(pTableFormat, pBox, nPos);
1146 }
1147 
1155 {
1156  // check if nFndPos happens to point to the right table box
1157  if( m_nFndPos < pTable->GetTabSortBoxes().size() &&
1158  pBox2 == pTable->GetTabSortBoxes()[ m_nFndPos ] )
1159  return pBox2;
1160 
1161  // if not, seek the entry (and return, if successful)
1162  SwTableSortBoxes::const_iterator it = pTable->GetTabSortBoxes().find( pBox2 );
1163  if( it != pTable->GetTabSortBoxes().end() )
1164  {
1165  m_nFndPos = it - pTable->GetTabSortBoxes().begin();
1166  return pBox2;
1167  }
1168 
1169  // box not found: reset nFndPos pointer
1170  m_nFndPos = NOTFOUND;
1171  return nullptr;
1172 }
1173 
1175 {
1176  if(table::CellContentType_TEXT != const_cast<SwXCell*>(this)->getType())
1177  return getValue();
1178  // now we'll try to get a useful numerical value
1179  // from the text in the cell...
1180  sal_uInt32 nFIndex;
1181  SvNumberFormatter* pNumFormatter(const_cast<SvNumberFormatter*>(GetDoc()->GetNumberFormatter()));
1182  // look for SwTableBoxNumFormat value in parents as well
1183  const SfxPoolItem* pItem;
1184  auto pBoxFormat(GetTableBox()->GetFrameFormat());
1185  SfxItemState eState = pBoxFormat->GetAttrSet().GetItemState(RES_BOXATR_FORMAT, true, &pItem);
1186 
1187  if (eState == SfxItemState::SET)
1188  {
1189  // please note that the language of the numberformat
1190  // is implicitly coded into the below value as well
1191  nFIndex = static_cast<const SwTableBoxNumFormat*>(pItem)->GetValue();
1192 
1193  // since the current value indicates a text format but the call
1194  // to 'IsNumberFormat' below won't work for text formats
1195  // we need to get rid of the part that indicates the text format.
1196  // According to ER this can be done like this:
1197  nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
1198  }
1199  else
1200  {
1201  // system language is probably not the best possible choice
1202  // but since we have to guess anyway (because the language of at
1203  // the text is NOT the one used for the number format!)
1204  // it is at least conform to what is used in
1205  // SwTableShell::Execute when
1206  // SID_ATTR_NUMBERFORMAT_VALUE is set...
1207  LanguageType eLang = LANGUAGE_SYSTEM;
1208  nFIndex = pNumFormatter->GetStandardIndex( eLang );
1209  }
1210  double fTmp;
1211  if (!const_cast<SwDoc*>(GetDoc())->IsNumberFormat(const_cast<SwXCell*>(this)->getString(), nFIndex, fTmp))
1212  return std::numeric_limits<double>::quiet_NaN();
1213  return fTmp;
1214 }
1215 
1217 {
1218  if(!m_pBox)
1219  throw uno::RuntimeException();
1220  // check if table box value item is set
1221  auto pBoxFormat(m_pBox->GetFrameFormat());
1222  const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
1223  return bIsNum ? uno::makeAny(getValue()) : uno::makeAny(const_cast<SwXCell*>(this)->getString());
1224 }
1225 
1227  { return "SwXCell"; }
1228 
1229 sal_Bool SwXCell::supportsService(const OUString& rServiceName)
1230  { return cppu::supportsService(this, rServiceName); }
1231 
1232 uno::Sequence< OUString > SwXCell::getSupportedServiceNames()
1233  { return {"com.sun.star.text.CellProperties"}; }
1234 
1236  { return "SwXTextTableRow"; }
1237 
1238 sal_Bool SwXTextTableRow::supportsService(const OUString& rServiceName)
1239  { return cppu::supportsService(this, rServiceName); }
1240 
1242  { return {"com.sun.star.text.TextTableRow"}; }
1243 
1244 
1246  m_pFormat(pFormat),
1247  m_pLine(pLn),
1248  m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW))
1249 {
1251 }
1252 
1254 {
1255  SolarMutexGuard aGuard;
1256  EndListeningAll();
1257 }
1258 
1259 uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo()
1260 {
1261  static uno::Reference<beans::XPropertySetInfo> xRef = m_pPropSet->getPropertySetInfo();
1262  return xRef;
1263 }
1264 
1265 void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1266 {
1267  SolarMutexGuard aGuard;
1268  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1269  SwTable* pTable = SwTable::FindTable( pFormat );
1271  if(!pLn)
1272  return;
1273 
1274  // Check for a specific property
1275  if ( rPropertyName == "TableRedlineParams" )
1276  {
1277  // Get the table row properties
1278  uno::Sequence< beans::PropertyValue > tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
1279  comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
1280  OUString sRedlineType;
1281  if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) )
1282  {
1283  throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) );
1284  }
1285 
1286  // Create a 'Table Row Redline' object
1287  SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
1288 
1289  }
1290  else
1291  {
1292  const SfxItemPropertyMapEntry* pEntry =
1293  m_pPropSet->getPropertyMap().getByName(rPropertyName);
1294  SwDoc* pDoc = pFormat->GetDoc();
1295  if (!pEntry)
1296  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1297  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1298  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1299 
1300  switch(pEntry->nWID)
1301  {
1302  case FN_UNO_ROW_HEIGHT:
1304  {
1305  SwFormatFrameSize aFrameSize(pLn->GetFrameFormat()->GetFrameSize());
1306  if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1307  {
1308  bool bSet = *o3tl::doAccess<bool>(aValue);
1310  }
1311  else
1312  {
1313  sal_Int32 nHeight = 0;
1314  aValue >>= nHeight;
1315  Size aSz(aFrameSize.GetSize());
1316  aSz.setHeight( convertMm100ToTwip(nHeight) );
1317  aFrameSize.SetSize(aSz);
1318  }
1319  pDoc->SetAttr(aFrameSize, *pLn->ClaimFrameFormat());
1320  }
1321  break;
1322 
1324  {
1325  UnoActionContext aContext(pDoc);
1326  SwTable* pTable2 = SwTable::FindTable( pFormat );
1327  lcl_SetTableSeparators(aValue, pTable2, m_pLine->GetTabBoxes()[0], true, pDoc);
1328  }
1329  break;
1330 
1331  default:
1332  {
1333  SwFrameFormat* pLnFormat = pLn->ClaimFrameFormat();
1334  SwAttrSet aSet(pLnFormat->GetAttrSet());
1335  m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1336  pDoc->SetAttr(aSet, *pLnFormat);
1337  }
1338  }
1339  }
1340 }
1341 
1342 uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName)
1343 {
1344  SolarMutexGuard aGuard;
1345  uno::Any aRet;
1346  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1347  SwTable* pTable = SwTable::FindTable( pFormat );
1349  if(pLn)
1350  {
1351  const SfxItemPropertyMapEntry* pEntry =
1352  m_pPropSet->getPropertyMap().getByName(rPropertyName);
1353  if (!pEntry)
1354  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1355 
1356  switch(pEntry->nWID)
1357  {
1358  case FN_UNO_ROW_HEIGHT:
1360  {
1361  const SwFormatFrameSize& rSize = pLn->GetFrameFormat()->GetFrameSize();
1362  if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1363  {
1364  aRet <<= SwFrameSize::Variable == rSize.GetHeightSizeType();
1365  }
1366  else
1367  aRet <<= static_cast<sal_Int32>(convertTwipToMm100(rSize.GetSize().Height()));
1368  }
1369  break;
1370 
1372  {
1373  lcl_GetTableSeparators(aRet, pTable, m_pLine->GetTabBoxes()[0], true);
1374  }
1375  break;
1376 
1377  default:
1378  {
1379  const SwAttrSet& rSet = pLn->GetFrameFormat()->GetAttrSet();
1380  m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1381  }
1382  }
1383  }
1384  return aRet;
1385 }
1386 
1387 void SwXTextTableRow::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1388  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1389 
1390 void SwXTextTableRow::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1391  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1392 
1393 void SwXTextTableRow::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1394  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1395 
1396 void SwXTextTableRow::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1397  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1398 
1400 {
1401  if(rHint.GetId() == SfxHintId::Dying)
1402  {
1403  m_pFormat = nullptr;
1404  } else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableLine, SwXTextTableRow>*>(&rHint))
1405  {
1406  if(!pFindHint->m_pCore && pFindHint->m_pCore == m_pLine)
1407  pFindHint->m_pResult = this;
1408  }
1409 }
1410 
1412 {
1413  for(const auto& pCurrentLine : pTable->GetTabLines())
1414  if(pCurrentLine == pLine)
1415  return pCurrentLine;
1416  return nullptr;
1417 }
1418 
1419 // SwXTextTableCursor
1420 
1422  { return "SwXTextTableCursor"; }
1423 
1424 sal_Bool SwXTextTableCursor::supportsService(const OUString& rServiceName)
1425  { return cppu::supportsService(this, rServiceName); }
1426 
1427 void SwXTextTableCursor::acquire() noexcept
1428 {
1429  SwXTextTableCursor_Base::acquire();
1430 }
1431 
1432 void SwXTextTableCursor::release() noexcept
1433 {
1434  SolarMutexGuard aGuard;
1435  SwXTextTableCursor_Base::release();
1436 }
1437 
1438 css::uno::Any SAL_CALL
1439 SwXTextTableCursor::queryInterface( const css::uno::Type& _rType )
1440 {
1441  css::uno::Any aReturn = SwXTextTableCursor_Base::queryInterface( _rType );
1442  if ( !aReturn.hasValue() )
1443  aReturn = OTextCursorHelper::queryInterface( _rType );
1444  return aReturn;
1445 }
1446 
1447 const SwPaM* SwXTextTableCursor::GetPaM() const { return &GetCursor(); }
1453 
1455  { return {"com.sun.star.text.TextTableCursor"}; }
1456 
1458  : m_pFrameFormat(pFrameFormat)
1459  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1460 {
1462  SwDoc* pDoc = m_pFrameFormat->GetDoc();
1463  const SwStartNode* pSttNd = pBox->GetSttNd();
1464  SwPosition aPos(*pSttNd);
1465  m_pUnoCursor = pDoc->CreateUnoCursor(aPos, true);
1467  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1468  rTableCursor.MakeBoxSels();
1469 }
1470 
1472  : m_pFrameFormat(&rTableFormat)
1473  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1474 {
1476  m_pUnoCursor = pTableSelection->GetDoc().CreateUnoCursor(*pTableSelection->GetPoint(), true);
1477  if(pTableSelection->HasMark())
1478  {
1479  m_pUnoCursor->SetMark();
1480  *m_pUnoCursor->GetMark() = *pTableSelection->GetMark();
1481  }
1482  const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
1483  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1484  for(auto pBox : rBoxes)
1485  rTableCursor.InsertBox(*pBox);
1486  rTableCursor.MakeBoxSels();
1487 }
1488 
1490 {
1491  SolarMutexGuard aGuard;
1492  SwUnoCursor& rUnoCursor = GetCursor();
1493  SwUnoTableCursor* pTableCursor = dynamic_cast<SwUnoTableCursor*>(&rUnoCursor);
1495  if(!pTableCursor)
1496  return OUString();
1497  pTableCursor->MakeBoxSels();
1498  const SwStartNode* pNode = pTableCursor->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
1499  const SwTable* pTable = SwTable::FindTable(GetFrameFormat());
1500  const SwTableBox* pEndBox = pTable->GetTableBox(pNode->GetIndex());
1501  if(pTableCursor->HasMark())
1502  {
1503  pNode = pTableCursor->GetMark()->nNode.GetNode().FindTableBoxStartNode();
1504  const SwTableBox* pStartBox = pTable->GetTableBox(pNode->GetIndex());
1505  if(pEndBox != pStartBox)
1506  {
1507  // need to switch start and end?
1508  if(*pTableCursor->GetPoint() < *pTableCursor->GetMark())
1509  std::swap(pStartBox, pEndBox);
1510  return pStartBox->GetName() + ":" + pEndBox->GetName();
1511  }
1512  }
1513  return pEndBox->GetName();
1514 }
1515 
1516 sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool bExpand)
1517 {
1518  SolarMutexGuard aGuard;
1519  SwUnoCursor& rUnoCursor = GetCursor();
1520  auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1521  lcl_CursorSelect(rTableCursor, bExpand);
1522  return rTableCursor.GotoTableBox(sCellName);
1523 }
1524 
1526 {
1527  SolarMutexGuard aGuard;
1528  SwUnoCursor& rUnoCursor = GetCursor();
1529  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1530  lcl_CursorSelect(rTableCursor, bExpand);
1531  return rTableCursor.Left(Count);
1532 }
1533 
1535 {
1536  SolarMutexGuard aGuard;
1537  SwUnoCursor& rUnoCursor = GetCursor();
1538  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1539  lcl_CursorSelect(rTableCursor, bExpand);
1540  return rTableCursor.Right(Count);
1541 }
1542 
1543 sal_Bool SwXTextTableCursor::goUp(sal_Int16 Count, sal_Bool bExpand)
1544 {
1545  SolarMutexGuard aGuard;
1546  SwUnoCursor& rUnoCursor = GetCursor();
1547  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1548  lcl_CursorSelect(rTableCursor, bExpand);
1549  return rTableCursor.UpDown(true, Count, nullptr, 0,
1551 }
1552 
1554 {
1555  SolarMutexGuard aGuard;
1556  SwUnoCursor& rUnoCursor = GetCursor();
1557  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1558  lcl_CursorSelect(rTableCursor, bExpand);
1559  return rTableCursor.UpDown(false, Count, nullptr, 0,
1561 }
1562 
1564 {
1565  SolarMutexGuard aGuard;
1566  SwUnoCursor& rUnoCursor = GetCursor();
1567  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1568  lcl_CursorSelect(rTableCursor, bExpand);
1569  rTableCursor.MoveTable(GotoCurrTable, fnTableStart);
1570 }
1571 
1573 {
1574  SolarMutexGuard aGuard;
1575  SwUnoCursor& rUnoCursor = GetCursor();
1576  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1577  lcl_CursorSelect(rTableCursor, bExpand);
1578  rTableCursor.MoveTable(GotoCurrTable, fnTableEnd);
1579 }
1580 
1582 {
1583  SolarMutexGuard aGuard;
1584  SwUnoCursor& rUnoCursor = GetCursor();
1585 
1586  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1587  {
1588  // HACK: remove pending actions for selecting old style tables
1589  UnoActionRemoveContext aRemoveContext(rTableCursor);
1590  }
1591  rTableCursor.MakeBoxSels();
1592  bool bResult;
1593  {
1594  UnoActionContext aContext(&rUnoCursor.GetDoc());
1595  bResult = TableMergeErr::Ok == rTableCursor.GetDoc().MergeTable(rTableCursor);
1596  }
1597  if(bResult)
1598  {
1599  size_t nCount = rTableCursor.GetSelectedBoxesCount();
1600  while (nCount--)
1601  rTableCursor.DeleteBox(nCount);
1602  }
1603  rTableCursor.MakeBoxSels();
1604  return bResult;
1605 }
1606 
1608 {
1609  SolarMutexGuard aGuard;
1610  if (Count <= 0)
1611  throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast<cppu::OWeakObject*>(this));
1612  SwUnoCursor& rUnoCursor = GetCursor();
1613  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1614  {
1615  // HACK: remove pending actions for selecting old style tables
1616  UnoActionRemoveContext aRemoveContext(rTableCursor);
1617  }
1618  rTableCursor.MakeBoxSels();
1619  bool bResult;
1620  {
1621  UnoActionContext aContext(&rUnoCursor.GetDoc());
1622  bResult = rTableCursor.GetDoc().SplitTable(rTableCursor.GetSelectedBoxes(), !Horizontal, Count);
1623  }
1624  rTableCursor.MakeBoxSels();
1625  return bResult;
1626 }
1627 
1628 uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInfo()
1629 {
1630  static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1631  return xRef;
1632 }
1633 
1634 void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1635 {
1636  SolarMutexGuard aGuard;
1637  SwUnoCursor& rUnoCursor = GetCursor();
1638  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1639  if(!pEntry)
1640  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1641  if(pEntry->nFlags & beans::PropertyAttribute::READONLY)
1642  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1643  {
1644  auto pSttNode = rUnoCursor.GetNode().StartOfSectionNode();
1645  const SwTableNode* pTableNode = pSttNode->FindTableNode();
1646  lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1647  }
1648  auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1649  rTableCursor.MakeBoxSels();
1650  SwDoc& rDoc = rUnoCursor.GetDoc();
1651  switch(pEntry->nWID)
1652  {
1654  {
1655  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1656  SwDoc::GetBoxAttr(rUnoCursor, aBrush);
1657  aBrush->PutValue(aValue, pEntry->nMemberId);
1658  rDoc.SetBoxAttr(rUnoCursor, *aBrush);
1659 
1660  }
1661  break;
1662  case RES_BOXATR_FORMAT:
1663  {
1664  SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
1665  aNumberFormat.PutValue(aValue, 0);
1666  rDoc.SetBoxAttr(rUnoCursor, aNumberFormat);
1667  }
1668  break;
1669  case FN_UNO_PARA_STYLE:
1670  SwUnoCursorHelper::SetTextFormatColl(aValue, rUnoCursor);
1671  break;
1672  default:
1673  {
1674  SfxItemSet aItemSet(rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID);
1675  SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(),
1676  aItemSet);
1677 
1679  *pEntry, aValue, rTableCursor.GetSelRing(), aItemSet))
1680  {
1681  m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
1682  }
1683  SwUnoCursorHelper::SetCursorAttr(rTableCursor.GetSelRing(),
1684  aItemSet, SetAttrMode::DEFAULT, true);
1685  }
1686  }
1687 }
1688 
1689 uno::Any SwXTextTableCursor::getPropertyValue(const OUString& rPropertyName)
1690 {
1691  SolarMutexGuard aGuard;
1692  SwUnoCursor& rUnoCursor = GetCursor();
1693  {
1694  auto pSttNode = rUnoCursor.GetNode().StartOfSectionNode();
1695  const SwTableNode* pTableNode = pSttNode->FindTableNode();
1696  lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1697  }
1698  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1699  auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1700  if(!pEntry)
1701  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1702  rTableCursor.MakeBoxSels();
1703  uno::Any aResult;
1704  switch(pEntry->nWID)
1705  {
1707  {
1708  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1709  if (SwDoc::GetBoxAttr(rUnoCursor, aBrush))
1710  aBrush->QueryValue(aResult, pEntry->nMemberId);
1711  }
1712  break;
1713  case RES_BOXATR_FORMAT:
1714  // TODO: GetAttr for table selections in a Doc is missing
1715  throw uno::RuntimeException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1716  break;
1717  case FN_UNO_PARA_STYLE:
1718  {
1719  auto pFormat(SwUnoCursorHelper::GetCurTextFormatColl(rUnoCursor, false));
1720  if(pFormat)
1721  aResult <<= pFormat->GetName();
1722  }
1723  break;
1724  default:
1725  {
1726  SfxItemSet aSet(rTableCursor.GetDoc().GetAttrPool(),
1728  RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER>);
1729  SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(), aSet);
1730  m_pPropSet->getPropertyValue(*pEntry, aSet, aResult);
1731  }
1732  }
1733  return aResult;
1734 }
1735 
1736 void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1737  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1738 
1739 void SwXTextTableCursor::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1740  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1741 
1742 void SwXTextTableCursor::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1743  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1744 
1745 void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1746  { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1747 
1749 {
1750  if(rHint.GetId() == SfxHintId::Dying)
1751  m_pFrameFormat = nullptr;
1752 }
1753 
1754 
1755 // SwXTextTable ===========================================================
1756 
1757 namespace {
1758 
1759 class SwTableProperties_Impl
1760 {
1762 
1763 public:
1764  SwTableProperties_Impl();
1765 
1766  void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal);
1767  bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny);
1768  void AddItemToSet(SfxItemSet& rSet, std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1769  sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips = false);
1770  void ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc);
1771 };
1772 
1773 }
1774 
1775 SwTableProperties_Impl::SwTableProperties_Impl()
1776  { }
1777 
1778 void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rVal)
1779  {
1780  m_aAnyMap.SetValue(nWhichId, nMemberId, rVal);
1781  }
1782 
1783 bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny )
1784  {
1785  return m_aAnyMap.FillValue(nWhichId, nMemberId, rpAny);
1786  }
1787 
1788 void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet,
1789  std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1790  sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips)
1791 {
1792  std::vector< std::pair<sal_uInt16, const uno::Any* > > vMemberAndAny;
1793  for(sal_uInt16 nMember : vMember)
1794  {
1795  const uno::Any* pAny = nullptr;
1796  GetProperty(nWhich, nMember, pAny);
1797  if(pAny)
1798  vMemberAndAny.emplace_back(nMember, pAny);
1799  }
1800  if(!vMemberAndAny.empty())
1801  {
1802  std::unique_ptr<SfxPoolItem> aItem(aItemFactory());
1803  for(const auto& aMemberAndAny : vMemberAndAny)
1804  aItem->PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
1805  rSet.Put(*aItem);
1806  }
1807 }
1808 void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
1809 {
1810  SfxItemSet aSet(
1811  rDoc.GetAttrPool(),
1812  svl::Items<
1817  RES_KEEP, RES_KEEP,
1818  RES_LAYOUT_SPLIT, RES_LAYOUT_SPLIT>);
1819  const uno::Any* pRepHead;
1820  const SwFrameFormat &rFrameFormat = *rTable.GetFrameFormat();
1821  if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead ))
1822  {
1823  bool bVal(pRepHead->get<bool>());
1824  const_cast<SwTable&>(rTable).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER
1825  }
1826 
1827  AddItemToSet(aSet, [&rFrameFormat]() { return rFrameFormat.makeBackgroundBrushItem(); }, RES_BACKGROUND, {
1831  MID_GRAPHIC,
1832  MID_GRAPHIC_FILTER });
1833 
1834  bool bPutBreak = true;
1835  const uno::Any* pPage;
1836  if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage))
1837  {
1838  OUString sPageStyle = pPage->get<OUString>();
1839  if(!sPageStyle.isEmpty())
1840  {
1842  const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle);
1843  if(pDesc)
1844  {
1845  SwFormatPageDesc aDesc(pDesc);
1846  const uno::Any* pPgNo;
1848  {
1849  aDesc.SetNumOffset(pPgNo->get<sal_Int16>());
1850  }
1851  aSet.Put(aDesc);
1852  bPutBreak = false;
1853  }
1854 
1855  }
1856  }
1857 
1858  if(bPutBreak)
1859  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetBreak().Clone()); }, RES_BREAK, {0});
1860  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetShadow().Clone()); }, RES_SHADOW, {0}, true);
1861  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetKeep().Clone()); }, RES_KEEP, {0});
1862  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetHoriOrient().Clone()); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
1863 
1864  const uno::Any* pSzRel(nullptr);
1865  GetProperty(FN_TABLE_IS_RELATIVE_WIDTH, 0xff, pSzRel);
1866  const uno::Any* pRelWidth(nullptr);
1867  GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth);
1868  const uno::Any* pWidth(nullptr);
1869  GetProperty(FN_TABLE_WIDTH, 0xff, pWidth);
1870 
1871  bool bPutSize = pWidth != nullptr;
1873  if(pWidth)
1874  {
1875  aSz.PutValue(*pWidth, MID_FRMSIZE_WIDTH);
1876  bPutSize = true;
1877  }
1878  if(pSzRel && pSzRel->get<bool>() && pRelWidth)
1879  {
1880  aSz.PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS);
1881  bPutSize = true;
1882  }
1883  if(bPutSize)
1884  {
1885  if(!aSz.GetWidth())
1886  aSz.SetWidth(MINLAY);
1887  aSet.Put(aSz);
1888  }
1889  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetLRSpace().Clone()); }, RES_LR_SPACE, {
1892  AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetULSpace().Clone()); }, RES_UL_SPACE, {
1895  const::uno::Any* pSplit(nullptr);
1896  if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit))
1897  {
1898  SwFormatLayoutSplit aSp(pSplit->get<bool>());
1899  aSet.Put(aSp);
1900  }
1901  if(aSet.Count())
1902  {
1903  rDoc.SetAttr(aSet, *rTable.GetFrameFormat());
1904  }
1905 }
1906 
1908  : public SvtListener
1909 {
1910 private:
1912  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
1913 
1914 public:
1915  uno::WeakReference<uno::XInterface> m_wThis;
1917 
1919 
1920  css::uno::WeakReference<css::table::XTableRows> m_xRows;
1921  css::uno::WeakReference<css::table::XTableColumns> m_xColumns;
1922 
1925 
1926  // Descriptor-interface
1927  std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
1928  OUString m_sTableName;
1929  unsigned short m_nRows;
1930  unsigned short m_nColumns;
1931 
1932  explicit Impl(SwFrameFormat* const pFrameFormat)
1933  : m_pFrameFormat(pFrameFormat)
1934  , m_Listeners(m_Mutex)
1935  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE))
1936  , m_bFirstRowAsLabel(false)
1937  , m_bFirstColumnAsLabel(false)
1938  , m_pTableProps(pFrameFormat ? nullptr : new SwTableProperties_Impl)
1939  , m_nRows(pFrameFormat ? 0 : 2)
1940  , m_nColumns(pFrameFormat ? 0 : 2)
1941  {
1942  if(m_pFrameFormat)
1943  StartListening(m_pFrameFormat->GetNotifier());
1944  }
1945 
1947  void SetFrameFormat(SwFrameFormat& rFrameFormat)
1948  {
1949  EndListeningAll();
1950  m_pFrameFormat = &rFrameFormat;
1951  StartListening(m_pFrameFormat->GetNotifier());
1952  }
1953 
1954  bool IsDescriptor() const { return m_pTableProps != nullptr; }
1955 
1956  // note: lock mutex before calling this to avoid concurrent update
1957  static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
1958  {
1959  sal_uInt16 const nRowCount(rThis.m_pImpl->GetRowCount());
1960  sal_uInt16 const nColCount(rThis.m_pImpl->GetColumnCount());
1961  if (!nRowCount || !nColCount)
1962  {
1963  throw uno::RuntimeException("Table too complex",
1964  static_cast<cppu::OWeakObject*>(&rThis));
1965  }
1966  return std::make_pair(nRowCount, nColCount);
1967  }
1968 
1969  sal_uInt16 GetRowCount();
1970  sal_uInt16 GetColumnCount();
1971 
1972  virtual void Notify(const SfxHint&) override;
1973 
1974 };
1975 
1976 const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
1977 {
1978  static const UnoTunnelIdInit theSwXTextTableUnoTunnelId;
1979  return theSwXTextTableUnoTunnelId.getSeq();
1980 }
1981 
1982 sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
1983 {
1984  if(isUnoTunnelId<SwXTextTable>(rId))
1985  {
1986  return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this));
1987  }
1988  return 0;
1989 }
1990 
1991 
1993  : m_pImpl(new Impl(nullptr))
1994 {
1995 }
1996 
1998  : m_pImpl(new Impl(&rFrameFormat))
1999 {
2000 }
2001 
2003 {
2004 }
2005 
2006 uno::Reference<text::XTextTable> SwXTextTable::CreateXTextTable(SwFrameFormat* const pFrameFormat)
2007 {
2008  uno::Reference<text::XTextTable> xTable;
2009  if(pFrameFormat)
2010  xTable.set(pFrameFormat->GetXObject(), uno::UNO_QUERY); // cached?
2011  if(xTable.is())
2012  return xTable;
2013  SwXTextTable* const pNew( pFrameFormat ? new SwXTextTable(*pFrameFormat) : new SwXTextTable());
2014  xTable.set(pNew);
2015  if(pFrameFormat)
2016  pFrameFormat->SetXObject(xTable);
2017  // need a permanent Reference to initialize m_wThis
2018  pNew->m_pImpl->m_wThis = xTable;
2019  return xTable;
2020 }
2021 
2023 {
2024  return m_pImpl->GetFrameFormat();
2025 }
2026 
2027 void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC)
2028 {
2029  if (!m_pImpl->IsDescriptor() || nR <= 0 || nC <= 0 || nR >= SAL_MAX_UINT16 || nC >= SAL_MAX_UINT16)
2030  throw uno::RuntimeException();
2031  m_pImpl->m_nRows = o3tl::narrowing<sal_uInt16>(nR);
2032  m_pImpl->m_nColumns = o3tl::narrowing<sal_uInt16>(nC);
2033 }
2034 
2035 uno::Reference<table::XTableRows> SAL_CALL SwXTextTable::getRows()
2036 {
2037  SolarMutexGuard aGuard;
2038  uno::Reference<table::XTableRows> xResult(m_pImpl->m_xRows);
2039  if(xResult.is())
2040  return xResult;
2041  if(SwFrameFormat* pFormat = GetFrameFormat())
2042  m_pImpl->m_xRows = xResult = new SwXTableRows(*pFormat);
2043  if(!xResult.is())
2044  throw uno::RuntimeException();
2045  return xResult;
2046 }
2047 
2048 uno::Reference<table::XTableColumns> SAL_CALL SwXTextTable::getColumns()
2049 {
2050  SolarMutexGuard aGuard;
2051  uno::Reference<table::XTableColumns> xResult(m_pImpl->m_xColumns);
2052  if(xResult.is())
2053  return xResult;
2054  if(SwFrameFormat* pFormat = GetFrameFormat())
2055  m_pImpl->m_xColumns = xResult = new SwXTableColumns(*pFormat);
2056  if(!xResult.is())
2057  throw uno::RuntimeException();
2058  return xResult;
2059 }
2060 
2061 uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellName)
2062 {
2063  SolarMutexGuard aGuard;
2064  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2065  SwTable* pTable = SwTable::FindTable(pFormat);
2066  SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2067  if(!pBox)
2068  return nullptr;
2069  return SwXCell::CreateXCell(pFormat, pBox);
2070 }
2071 
2072 uno::Sequence<OUString> SwXTextTable::getCellNames()
2073 {
2074  SolarMutexGuard aGuard;
2075  SwFrameFormat* pFormat(GetFrameFormat());
2076  if(!pFormat)
2077  return {};
2078  SwTable* pTable = SwTable::FindTable(pFormat);
2079  // exists at the table and at all boxes
2080  SwTableLines& rTableLines = pTable->GetTabLines();
2081  std::vector<OUString> aAllNames;
2082  lcl_InspectLines(rTableLines, aAllNames);
2083  return comphelper::containerToSequence(aAllNames);
2084 }
2085 
2086 uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(const OUString& sCellName)
2087 {
2088  SolarMutexGuard aGuard;
2089  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2090  SwTable* pTable = SwTable::FindTable(pFormat);
2091  SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2092  if(!pBox || pBox->getRowSpan() == 0)
2093  throw uno::RuntimeException();
2094  return new SwXTextTableCursor(pFormat, pBox);
2095 }
2096 
2097 void SAL_CALL
2098 SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
2099 {
2100  SolarMutexGuard aGuard;
2101 
2102  // attach() must only be called once
2103  if (!m_pImpl->IsDescriptor()) /* already attached ? */
2104  throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
2105 
2106  uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
2107  SwXTextRange* pRange(nullptr);
2108  OTextCursorHelper* pCursor(nullptr);
2109  if(xRangeTunnel.is())
2110  {
2111  pRange = reinterpret_cast<SwXTextRange*>(
2112  sal::static_int_cast<sal_IntPtr>(xRangeTunnel->getSomething(SwXTextRange::getUnoTunnelId())));
2113  pCursor = reinterpret_cast<OTextCursorHelper*>(
2114  sal::static_int_cast<sal_IntPtr>(xRangeTunnel->getSomething(OTextCursorHelper::getUnoTunnelId())));
2115  }
2116  SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
2117  if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns)
2118  throw lang::IllegalArgumentException();
2119  SwUnoInternalPaM aPam(*pDoc);
2120  // this now needs to return TRUE
2121  ::sw::XTextRangeToSwPaM(aPam, xTextRange);
2122  {
2123  UnoActionContext aCont(pDoc);
2124 
2126  const SwTable* pTable(nullptr);
2127  if( 0 != aPam.Start()->nContent.GetIndex() )
2128  {
2129  pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false);
2130  }
2131  //TODO: if it is the last paragraph than add another one!
2132  if(aPam.HasMark())
2133  {
2135  aPam.DeleteMark();
2136  }
2138  *aPam.GetPoint(),
2139  m_pImpl->m_nRows,
2140  m_pImpl->m_nColumns,
2141  text::HoriOrientation::FULL);
2142  if(pTable)
2143  {
2144  // here, the properties of the descriptor need to be analyzed
2145  m_pImpl->m_pTableProps->ApplyTableAttr(*pTable, *pDoc);
2146  SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
2147  lcl_FormatTable(pTableFormat);
2148 
2149  m_pImpl->SetFrameFormat(*pTableFormat);
2150 
2151  if (!m_pImpl->m_sTableName.isEmpty())
2152  {
2153  sal_uInt16 nIndex = 1;
2154  OUString sTmpNameIndex(m_pImpl->m_sTableName);
2155  while(pDoc->FindTableFormatByName(sTmpNameIndex, true) && nIndex < USHRT_MAX)
2156  {
2157  sTmpNameIndex = m_pImpl->m_sTableName + OUString::number(nIndex++);
2158  }
2159  pDoc->SetTableName( *pTableFormat, sTmpNameIndex);
2160  }
2161 
2162  const::uno::Any* pName;
2163  if (m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
2164  setName(pName->get<OUString>());
2165  m_pImpl->m_pTableProps.reset();
2166  }
2167  pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
2168  }
2169 }
2170 
2171 uno::Reference<text::XTextRange> SwXTextTable::getAnchor()
2172 {
2173  SolarMutexGuard aGuard;
2174  SwTableFormat *const pFormat = static_cast<SwTableFormat*>(
2175  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
2176  return new SwXTextRange(*pFormat);
2177 }
2178 
2180 {
2181  SolarMutexGuard aGuard;
2182  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2183  SwTable* pTable = SwTable::FindTable(pFormat);
2184  SwSelBoxes aSelBoxes;
2185  for(auto& rBox : pTable->GetTabSortBoxes() )
2186  aSelBoxes.insert(rBox);
2187  pFormat->GetDoc()->DeleteRowCol(aSelBoxes, SwDoc::RowColMode::DeleteProtected);
2188 }
2189 
2191  const uno::Reference<lang::XEventListener> & xListener)
2192 {
2193  // no need to lock here as m_pImpl is const and container threadsafe
2194  m_pImpl->m_Listeners.addInterface(
2196 }
2197 
2199  const uno::Reference< lang::XEventListener > & xListener)
2200 {
2201  // no need to lock here as m_pImpl is const and container threadsafe
2202  m_pImpl->m_Listeners.removeInterface(
2204 }
2205 
2206 uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
2207 {
2208  SolarMutexGuard aGuard;
2209  SwFrameFormat* pFormat(GetFrameFormat());
2210  // sheet is unimportant
2211  if(nColumn >= 0 && nRow >= 0 && pFormat)
2212  {
2213  auto pXCell = lcl_CreateXCell(pFormat, nColumn, nRow);
2214  if(pXCell)
2215  return pXCell;
2216  }
2217  throw lang::IndexOutOfBoundsException();
2218 }
2219 
2220 namespace {
2221 
2222 uno::Reference<table::XCellRange> GetRangeByName(
2223  SwFrameFormat* pFormat, SwTable const * pTable,
2224  const OUString& rTLName, const OUString& rBRName,
2225  SwRangeDescriptor const & rDesc)
2226 {
2227  const SwTableBox* pTLBox = pTable->GetTableBox(rTLName);
2228  if(!pTLBox)
2229  return nullptr;
2230  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2231  SwPosition aPos(*pSttNd);
2232  // set cursor to the upper-left cell of the range
2233  auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
2234  pUnoCursor->Move(fnMoveForward, GoInNode);
2235  pUnoCursor->SetRemainInSection(false);
2236  const SwTableBox* pBRBox(pTable->GetTableBox(rBRName));
2237  if(!pBRBox)
2238  return nullptr;
2239  pUnoCursor->SetMark();
2240  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
2241  pUnoCursor->Move( fnMoveForward, GoInNode );
2242  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2243  // HACK: remove pending actions for selecting old style tables
2244  UnoActionRemoveContext aRemoveContext(rCursor);
2245  rCursor.MakeBoxSels();
2246  // pUnoCursor will be provided and will not be deleted
2247  return SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, rDesc);
2248 }
2249 
2250 } // namespace
2251 
2252 uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
2253 {
2254  SolarMutexGuard aGuard;
2255  SwFrameFormat* pFormat(GetFrameFormat());
2256  if(pFormat &&
2257  nLeft <= nRight && nTop <= nBottom &&
2258  nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
2259  {
2260  SwTable* pTable = SwTable::FindTable(pFormat);
2261  if(!pTable->IsTableComplex())
2262  {
2263  SwRangeDescriptor aDesc;
2264  aDesc.nTop = nTop;
2265  aDesc.nBottom = nBottom;
2266  aDesc.nLeft = nLeft;
2267  aDesc.nRight = nRight;
2268  const OUString sTLName = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
2269  const OUString sBRName = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
2270  // please note that according to the 'if' statement at the begin
2271  // sTLName:sBRName already denotes the normalized range string
2272  return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2273  }
2274  }
2275  throw lang::IndexOutOfBoundsException();
2276 }
2277 
2278 uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUString& sRange)
2279 {
2280  SolarMutexGuard aGuard;
2281  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2282  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2283  sal_Int32 nPos = 0;
2284  const OUString sTLName(sRange.getToken(0, ':', nPos));
2285  const OUString sBRName(sRange.getToken(0, ':', nPos));
2286  if(sTLName.isEmpty() || sBRName.isEmpty())
2287  throw uno::RuntimeException();
2288  SwRangeDescriptor aDesc;
2289  aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
2290  SwXTextTable::GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
2291  SwXTextTable::GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
2292 
2293  // we should normalize the range now (e.g. A5:C1 will become A1:C5)
2294  // since (depending on what is done later) it will be troublesome
2295  // elsewhere when the cursor in the implementation does not
2296  // point to the top-left and bottom-right cells
2297  aDesc.Normalize();
2298  return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2299 }
2300 
2301 uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
2302 {
2303  SolarMutexGuard aGuard;
2304  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2305  uno::Reference<sheet::XCellRangeData> const xAllRange(
2306  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2307  uno::UNO_QUERY_THROW);
2308  return xAllRange->getDataArray();
2309 }
2310 
2311 void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
2312 {
2313  SolarMutexGuard aGuard;
2314  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2315  uno::Reference<sheet::XCellRangeData> const xAllRange(
2316  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2317  uno::UNO_QUERY_THROW);
2318  return xAllRange->setDataArray(rArray);
2319 }
2320 
2321 uno::Sequence< uno::Sequence< double > > SwXTextTable::getData()
2322 {
2323  SolarMutexGuard aGuard;
2324  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2325  uno::Reference<chart::XChartDataArray> const xAllRange(
2326  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2327  uno::UNO_QUERY_THROW);
2328  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2329  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2330  return xAllRange->getData();
2331 }
2332 
2333 void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
2334 {
2335  SolarMutexGuard aGuard;
2336  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2337  uno::Reference<chart::XChartDataArray> const xAllRange(
2338  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2339  uno::UNO_QUERY_THROW);
2340  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2341  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2342  xAllRange->setData(rData);
2343  // this is rather inconsistent: setData on XTextTable sends events, but e.g. CellRanges do not
2344  lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
2345 }
2346 
2347 uno::Sequence<OUString> SwXTextTable::getRowDescriptions()
2348 {
2349  SolarMutexGuard aGuard;
2350  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2351  uno::Reference<chart::XChartDataArray> const xAllRange(
2352  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2353  uno::UNO_QUERY_THROW);
2354  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2355  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2356  return xAllRange->getRowDescriptions();
2357 }
2358 
2359 void SwXTextTable::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
2360 {
2361  SolarMutexGuard aGuard;
2362  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2363  uno::Reference<chart::XChartDataArray> const xAllRange(
2364  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2365  uno::UNO_QUERY_THROW);
2366  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2367  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2368  xAllRange->setRowDescriptions(rRowDesc);
2369 }
2370 
2371 uno::Sequence<OUString> SwXTextTable::getColumnDescriptions()
2372 {
2373  SolarMutexGuard aGuard;
2374  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2375  uno::Reference<chart::XChartDataArray> const xAllRange(
2376  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2377  uno::UNO_QUERY_THROW);
2378  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2379  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2380  return xAllRange->getColumnDescriptions();
2381 }
2382 
2383 void SwXTextTable::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
2384 {
2385  SolarMutexGuard aGuard;
2386  std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2387  uno::Reference<chart::XChartDataArray> const xAllRange(
2388  getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2389  uno::UNO_QUERY_THROW);
2390  static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2391  m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2392  return xAllRange->setColumnDescriptions(rColumnDesc);
2393 }
2394 
2396  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2397 {
2398  // no need to lock here as m_pImpl is const and container threadsafe
2399  m_pImpl->m_Listeners.addInterface(
2401 }
2402 
2404  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2405 {
2406  // no need to lock here as m_pImpl is const and container threadsafe
2407  m_pImpl->m_Listeners.removeInterface(
2409 }
2410 
2412 {
2413  // We use DBL_MIN because starcalc does (which uses it because chart
2414  // wants it that way!)
2415  return ( nNumber == DBL_MIN );
2416 }
2417 
2419 {
2420  // We use DBL_MIN because starcalc does (which uses it because chart
2421  // wants it that way!)
2422  return DBL_MIN;
2423 }
2424 
2425 uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor()
2426 {
2427  SolarMutexGuard aGuard;
2428 
2430 }
2431 
2432 void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2433 {
2434  SolarMutexGuard aGuard;
2435  SwSortOptions aSortOpt;
2436  SwFrameFormat* pFormat = GetFrameFormat();
2437  if(!(pFormat &&
2438  SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)))
2439  return;
2440 
2441  SwTable* pTable = SwTable::FindTable( pFormat );
2442  SwSelBoxes aBoxes;
2443  const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2444  for (size_t n = 0; n < rTBoxes.size(); ++n)
2445  {
2446  SwTableBox* pBox = rTBoxes[ n ];
2447  aBoxes.insert( pBox );
2448  }
2449  UnoActionContext aContext( pFormat->GetDoc() );
2450  pFormat->GetDoc()->SortTable(aBoxes, aSortOpt);
2451 }
2452 
2453 void SwXTextTable::autoFormat(const OUString& sAutoFormatName)
2454 {
2455  SolarMutexGuard aGuard;
2456  SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2457  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2458  SwTableAutoFormatTable aAutoFormatTable;
2459  aAutoFormatTable.Load();
2460  for (size_t i = aAutoFormatTable.size(); i;)
2461  if( sAutoFormatName == aAutoFormatTable[ --i ].GetName() )
2462  {
2463  SwSelBoxes aBoxes;
2464  const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2465  for (size_t n = 0; n < rTBoxes.size(); ++n)
2466  {
2467  SwTableBox* pBox = rTBoxes[ n ];
2468  aBoxes.insert( pBox );
2469  }
2470  UnoActionContext aContext( pFormat->GetDoc() );
2471  pFormat->GetDoc()->SetTableAutoFormat( aBoxes, aAutoFormatTable[i] );
2472  break;
2473  }
2474 }
2475 
2476 uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo()
2477 {
2478  static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
2479  return xRef;
2480 }
2481 
2482 void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
2483 {
2484  SolarMutexGuard aGuard;
2485  SwFrameFormat* pFormat = GetFrameFormat();
2486  if(!aValue.hasValue())
2487  throw lang::IllegalArgumentException();
2488  const SfxItemPropertyMapEntry* pEntry =
2489  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2490  if( !pEntry )
2491  throw lang::IllegalArgumentException();
2492  if(pFormat)
2493  {
2494  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2495  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2496 
2497  if(0xBF == pEntry->nMemberId)
2498  {
2499  lcl_SetSpecialProperty(pFormat, pEntry, aValue);
2500  }
2501  else
2502  {
2503  switch(pEntry->nWID)
2504  {
2505  case FN_UNO_TABLE_NAME :
2506  {
2507  OUString sName;
2508  aValue >>= sName;
2509  setName( sName );
2510  }
2511  break;
2512 
2514  {
2515  bool bTmp = *o3tl::doAccess<bool>(aValue);
2516  if (m_pImpl->m_bFirstRowAsLabel != bTmp)
2517  {
2518  lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
2519  m_pImpl->m_bFirstRowAsLabel = bTmp;
2520  }
2521  }
2522  break;
2523 
2525  {
2526  bool bTmp = *o3tl::doAccess<bool>(aValue);
2527  if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
2528  {
2529  lcl_SendChartEvent(*this, m_pImpl->m_Listeners);
2530  m_pImpl->m_bFirstColumnAsLabel = bTmp;
2531  }
2532  }
2533  break;
2534 
2535  case FN_UNO_TABLE_BORDER:
2536  case FN_UNO_TABLE_BORDER2:
2537  {
2538  table::TableBorder oldBorder;
2539  table::TableBorder2 aBorder;
2540  SvxBorderLine aTopLine;
2541  SvxBorderLine aBottomLine;
2542  SvxBorderLine aLeftLine;
2543  SvxBorderLine aRightLine;
2544  SvxBorderLine aHoriLine;
2545  SvxBorderLine aVertLine;
2546  if (aValue >>= oldBorder)
2547  {
2548  aBorder.IsTopLineValid = oldBorder.IsTopLineValid;
2549  aBorder.IsBottomLineValid = oldBorder.IsBottomLineValid;
2550  aBorder.IsLeftLineValid = oldBorder.IsLeftLineValid;
2551  aBorder.IsRightLineValid = oldBorder.IsRightLineValid;
2552  aBorder.IsHorizontalLineValid = oldBorder.IsHorizontalLineValid;
2553  aBorder.IsVerticalLineValid = oldBorder.IsVerticalLineValid;
2554  aBorder.Distance = oldBorder.Distance;
2555  aBorder.IsDistanceValid = oldBorder.IsDistanceValid;
2557  oldBorder.TopLine, aTopLine);
2559  oldBorder.BottomLine, aBottomLine);
2561  oldBorder.LeftLine, aLeftLine);
2563  oldBorder.RightLine, aRightLine);
2565  oldBorder.HorizontalLine, aHoriLine);
2567  oldBorder.VerticalLine, aVertLine);
2568  }
2569  else if (aValue >>= aBorder)
2570  {
2572  aBorder.TopLine, aTopLine, true);
2574  aBorder.BottomLine, aBottomLine, true);
2576  aBorder.LeftLine, aLeftLine, true);
2578  aBorder.RightLine, aRightLine, true);
2580  aBorder.HorizontalLine, aHoriLine, true);
2582  aBorder.VerticalLine, aVertLine, true);
2583  }
2584  else
2585  {
2586  break; // something else
2587  }
2588  SwDoc* pDoc = pFormat->GetDoc();
2589  if(!lcl_FormatTable(pFormat))
2590  break;
2591  SwTable* pTable = SwTable::FindTable( pFormat );
2592  SwTableLines &rLines = pTable->GetTabLines();
2593 
2594  const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2595  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2596  SwPosition aPos(*pSttNd);
2597  // set cursor to top left cell
2598  auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2599  pUnoCursor->Move( fnMoveForward, GoInNode );
2600  pUnoCursor->SetRemainInSection( false );
2601 
2602  const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2603  pUnoCursor->SetMark();
2604  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
2605  pUnoCursor->Move( fnMoveForward, GoInNode );
2606  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2607  // HACK: remove pending actions for selecting old style tables
2608  UnoActionRemoveContext aRemoveContext(rCursor);
2609  rCursor.MakeBoxSels();
2610 
2611  SfxItemSet aSet(pDoc->GetAttrPool(),
2613  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
2614 
2615  SvxBoxItem aBox( RES_BOX );
2616  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
2617 
2618  aBox.SetLine(aTopLine.isEmpty() ? nullptr : &aTopLine, SvxBoxItemLine::TOP);
2619  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::TOP, aBorder.IsTopLineValid);
2620 
2621  aBox.SetLine(aBottomLine.isEmpty() ? nullptr : &aBottomLine, SvxBoxItemLine::BOTTOM);
2622  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::BOTTOM, aBorder.IsBottomLineValid);
2623 
2624  aBox.SetLine(aLeftLine.isEmpty() ? nullptr : &aLeftLine, SvxBoxItemLine::LEFT);
2625  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::LEFT, aBorder.IsLeftLineValid);
2626 
2627  aBox.SetLine(aRightLine.isEmpty() ? nullptr : &aRightLine, SvxBoxItemLine::RIGHT);
2628  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::RIGHT, aBorder.IsRightLineValid);
2629 
2630  aBoxInfo.SetLine(aHoriLine.isEmpty() ? nullptr : &aHoriLine, SvxBoxInfoItemLine::HORI);
2631  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::HORI, aBorder.IsHorizontalLineValid);
2632 
2633  aBoxInfo.SetLine(aVertLine.isEmpty() ? nullptr : &aVertLine, SvxBoxInfoItemLine::VERT);
2634  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::VERT, aBorder.IsVerticalLineValid);
2635 
2636  aBox.SetAllDistances(o3tl::narrowing<sal_uInt16>(convertMm100ToTwip(aBorder.Distance)));
2637  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::DISTANCE, aBorder.IsDistanceValid);
2638 
2639  aSet.Put(aBox);
2640  aSet.Put(aBoxInfo);
2641 
2642  pDoc->SetTabBorders(rCursor, aSet);
2643  }
2644  break;
2645 
2647  {
2648  table::TableBorderDistances aTableBorderDistances;
2649  if( !(aValue >>= aTableBorderDistances) ||
2650  (!aTableBorderDistances.IsLeftDistanceValid &&
2651  !aTableBorderDistances.IsRightDistanceValid &&
2652  !aTableBorderDistances.IsTopDistanceValid &&
2653  !aTableBorderDistances.IsBottomDistanceValid ))
2654  break;
2655 
2656  const sal_uInt16 nLeftDistance = convertMm100ToTwip(aTableBorderDistances.LeftDistance);
2657  const sal_uInt16 nRightDistance = convertMm100ToTwip(aTableBorderDistances.RightDistance);
2658  const sal_uInt16 nTopDistance = convertMm100ToTwip(aTableBorderDistances.TopDistance);
2659  const sal_uInt16 nBottomDistance = convertMm100ToTwip(aTableBorderDistances.BottomDistance);
2660  SwDoc* pDoc = pFormat->GetDoc();
2661  SwTable* pTable = SwTable::FindTable( pFormat );
2662  SwTableLines &rLines = pTable->GetTabLines();
2664  for(size_t i = 0; i < rLines.size(); ++i)
2665  {
2666  SwTableLine* pLine = rLines[i];
2667  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2668  for(size_t k = 0; k < rBoxes.size(); ++k)
2669  {
2670  SwTableBox* pBox = rBoxes[k];
2671  const SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2672  const SvxBoxItem& rBox = pBoxFormat->GetBox();
2673  if(
2674  (aTableBorderDistances.IsLeftDistanceValid && nLeftDistance != rBox.GetDistance( SvxBoxItemLine::LEFT )) ||
2675  (aTableBorderDistances.IsRightDistanceValid && nRightDistance != rBox.GetDistance( SvxBoxItemLine::RIGHT )) ||
2676  (aTableBorderDistances.IsTopDistanceValid && nTopDistance != rBox.GetDistance( SvxBoxItemLine::TOP )) ||
2677  (aTableBorderDistances.IsBottomDistanceValid && nBottomDistance != rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2678  {
2679  SvxBoxItem aSetBox( rBox );
2680  SwFrameFormat* pSetBoxFormat = pBox->ClaimFrameFormat();
2681  if( aTableBorderDistances.IsLeftDistanceValid )
2682  aSetBox.SetDistance( nLeftDistance, SvxBoxItemLine::LEFT );
2683  if( aTableBorderDistances.IsRightDistanceValid )
2684  aSetBox.SetDistance( nRightDistance, SvxBoxItemLine::RIGHT );
2685  if( aTableBorderDistances.IsTopDistanceValid )
2686  aSetBox.SetDistance( nTopDistance, SvxBoxItemLine::TOP );
2687  if( aTableBorderDistances.IsBottomDistanceValid )
2688  aSetBox.SetDistance( nBottomDistance, SvxBoxItemLine::BOTTOM );
2689  pDoc->SetAttr( aSetBox, *pSetBoxFormat );
2690  }
2691  }
2692  }
2693  pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
2694  }
2695  break;
2696 
2698  {
2699  UnoActionContext aContext(pFormat->GetDoc());
2700  SwTable* pTable = SwTable::FindTable( pFormat );
2701  lcl_SetTableSeparators(aValue, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false, pFormat->GetDoc());
2702  }
2703  break;
2704 
2705  case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:/*_readonly_*/ break;
2706 
2708  {
2709  SwTable* pTable = SwTable::FindTable(pFormat);
2710  OUString sName;
2711  if (!(aValue >>= sName))
2712  break;
2714  pTable->SetTableStyleName(sName);
2715  SwDoc* pDoc = pFormat->GetDoc();
2717  }
2718  break;
2719 
2720  default:
2721  {
2722  SwAttrSet aSet(pFormat->GetAttrSet());
2723  m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
2724  pFormat->GetDoc()->SetAttr(aSet, *pFormat);
2725  }
2726  }
2727  }
2728  }
2729  else if (m_pImpl->IsDescriptor())
2730  {
2731  m_pImpl->m_pTableProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue);
2732  }
2733  else
2734  throw uno::RuntimeException();
2735 }
2736 
2737 uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
2738 {
2739  SolarMutexGuard aGuard;
2740  uno::Any aRet;
2741  SwFrameFormat* pFormat = GetFrameFormat();
2742  const SfxItemPropertyMapEntry* pEntry =
2743  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2744 
2745  if (!pEntry)
2746  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2747 
2748  if(pFormat)
2749  {
2750  if(0xBF == pEntry->nMemberId)
2751  {
2752  aRet = lcl_GetSpecialProperty(pFormat, pEntry );
2753  }
2754  else
2755  {
2756  switch(pEntry->nWID)
2757  {
2758  case FN_UNO_TABLE_NAME:
2759  {
2760  aRet <<= getName();
2761  }
2762  break;
2763 
2764  case FN_UNO_ANCHOR_TYPES:
2765  case FN_UNO_TEXT_WRAP:
2766  case FN_UNO_ANCHOR_TYPE:
2768  aRet, u"", pEntry->nWID);
2769  break;
2770 
2772  {
2773  aRet <<= m_pImpl->m_bFirstRowAsLabel;
2774  }
2775  break;
2776 
2778  aRet <<= m_pImpl->m_bFirstColumnAsLabel;
2779  break;
2780 
2781  case FN_UNO_TABLE_BORDER:
2782  case FN_UNO_TABLE_BORDER2:
2783  {
2784  SwDoc* pDoc = pFormat->GetDoc();
2785  // tables without layout (invisible header/footer?)
2786  if(!lcl_FormatTable(pFormat))
2787  break;
2788  SwTable* pTable = SwTable::FindTable( pFormat );
2789  SwTableLines &rLines = pTable->GetTabLines();
2790 
2791  const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2792  const SwStartNode* pSttNd = pTLBox->GetSttNd();
2793  SwPosition aPos(*pSttNd);
2794  // set cursor to top left cell
2795  auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2796  pUnoCursor->Move( fnMoveForward, GoInNode );
2797  pUnoCursor->SetRemainInSection( false );
2798 
2799  const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2800  pUnoCursor->SetMark();
2801  const SwStartNode* pLastNd = pBRBox->GetSttNd();
2802  pUnoCursor->GetPoint()->nNode = *pLastNd;
2803 
2804  pUnoCursor->Move( fnMoveForward, GoInNode );
2805  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2806  // HACK: remove pending actions for selecting old style tables
2807  UnoActionRemoveContext aRemoveContext(rCursor);
2808  rCursor.MakeBoxSels();
2809 
2810  SfxItemSet aSet(pDoc->GetAttrPool(),
2812  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
2813  aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
2814  SwDoc::GetTabBorders(rCursor, aSet);
2815  const SvxBoxInfoItem& rBoxInfoItem = aSet.Get(SID_ATTR_BORDER_INNER);
2816  const SvxBoxItem& rBox = aSet.Get(RES_BOX);
2817 
2818  if (FN_UNO_TABLE_BORDER == pEntry->nWID)
2819  {
2820  table::TableBorder aTableBorder;
2821  aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2822  aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2823  aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2824  aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2825  aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2826  aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2827  aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2828  aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2829  aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2830  aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2831  aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2832  aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2833  aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2834  aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2835  aRet <<= aTableBorder;
2836  }
2837  else
2838  {
2839  table::TableBorder2 aTableBorder;
2840  aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2841  aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2842  aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2843  aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2844  aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2845  aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2846  aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2847  aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2848  aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2849  aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2850  aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2851  aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2852  aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2853  aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2854  aRet <<= aTableBorder;
2855  }
2856  }
2857  break;
2858 
2860  {
2861  table::TableBorderDistances aTableBorderDistances( 0, true, 0, true, 0, true, 0, true ) ;
2862  SwTable* pTable = SwTable::FindTable( pFormat );
2863  const SwTableLines &rLines = pTable->GetTabLines();
2864  bool bFirst = true;
2865  sal_uInt16 nLeftDistance = 0;
2866  sal_uInt16 nRightDistance = 0;
2867  sal_uInt16 nTopDistance = 0;
2868  sal_uInt16 nBottomDistance = 0;
2869 
2870  for(size_t i = 0; i < rLines.size(); ++i)
2871  {
2872  const SwTableLine* pLine = rLines[i];
2873  const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2874  for(size_t k = 0; k < rBoxes.size(); ++k)
2875  {
2876  const SwTableBox* pBox = rBoxes[k];
2877  SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2878  const SvxBoxItem& rBox = pBoxFormat->GetBox();
2879  if( bFirst )
2880  {
2881  nLeftDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT ));
2882  nRightDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT ));
2883  nTopDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP ));
2884  nBottomDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM ));
2885  bFirst = false;
2886  }
2887  else
2888  {
2889  if( aTableBorderDistances.IsLeftDistanceValid &&
2890  nLeftDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT )))
2891  aTableBorderDistances.IsLeftDistanceValid = false;
2892  if( aTableBorderDistances.IsRightDistanceValid &&
2893  nRightDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT )))
2894  aTableBorderDistances.IsRightDistanceValid = false;
2895  if( aTableBorderDistances.IsTopDistanceValid &&
2896  nTopDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP )))
2897  aTableBorderDistances.IsTopDistanceValid = false;
2898  if( aTableBorderDistances.IsBottomDistanceValid &&
2899  nBottomDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2900  aTableBorderDistances.IsBottomDistanceValid = false;
2901  }
2902 
2903  }
2904  if( !aTableBorderDistances.IsLeftDistanceValid &&
2905  !aTableBorderDistances.IsRightDistanceValid &&
2906  !aTableBorderDistances.IsTopDistanceValid &&
2907  !aTableBorderDistances.IsBottomDistanceValid )
2908  break;
2909  }
2910  if( aTableBorderDistances.IsLeftDistanceValid)
2911  aTableBorderDistances.LeftDistance = nLeftDistance;
2912  if( aTableBorderDistances.IsRightDistanceValid)
2913  aTableBorderDistances.RightDistance = nRightDistance;
2914  if( aTableBorderDistances.IsTopDistanceValid)
2915  aTableBorderDistances.TopDistance = nTopDistance;
2916  if( aTableBorderDistances.IsBottomDistanceValid)
2917  aTableBorderDistances.BottomDistance = nBottomDistance;
2918 
2919  aRet <<= aTableBorderDistances;
2920  }
2921  break;
2922 
2924  {
2925  SwTable* pTable = SwTable::FindTable( pFormat );
2926  lcl_GetTableSeparators(aRet, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false);
2927  }
2928  break;
2929 
2931  aRet <<= sal_Int16(UNO_TABLE_COLUMN_SUM);
2932  break;
2933 
2934  case RES_ANCHOR:
2935  // AnchorType is readonly and might be void (no return value)
2936  break;
2937 
2938  case FN_UNO_TEXT_SECTION:
2939  {
2940  SwTable* pTable = SwTable::FindTable( pFormat );
2941  SwTableNode* pTableNode = pTable->GetTableNode();
2942  SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
2943  if(pSectionNode)
2944  {
2945  SwSection& rSect = pSectionNode->GetSection();
2946  uno::Reference< text::XTextSection > xSect =
2948  aRet <<= xSect;
2949  }
2950  }
2951  break;
2952 
2954  {
2955  SwTable* pTable = SwTable::FindTable(pFormat);
2956  OUString sName;
2958  aRet <<= sName;
2959  }
2960  break;
2961 
2962  default:
2963  {
2964  const SwAttrSet& rSet = pFormat->GetAttrSet();
2965  m_pImpl->m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
2966  }
2967  }
2968  }
2969  }
2970  else if (m_pImpl->IsDescriptor())
2971  {
2972  const uno::Any* pAny = nullptr;
2973  if (!m_pImpl->m_pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
2974  throw lang::IllegalArgumentException();
2975  else if(pAny)
2976  aRet = *pAny;
2977  }
2978  else
2979  throw uno::RuntimeException();
2980  return aRet;
2981 }
2982 
2983 void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2984  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2985 
2986 void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2987  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2988 
2989 void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2990  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2991 
2992 void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2993  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2994 
2996 {
2997  SolarMutexGuard aGuard;
2998  SwFrameFormat* pFormat = GetFrameFormat();
2999  if (!pFormat && !m_pImpl->IsDescriptor())
3000  throw uno::RuntimeException();
3001  if(pFormat)
3002  {
3003  return pFormat->GetName();
3004  }
3005  return m_pImpl->m_sTableName;
3006 }
3007 
3008 void SwXTextTable::setName(const OUString& rName)
3009 {
3010  SolarMutexGuard aGuard;
3011  SwFrameFormat* pFormat = GetFrameFormat();
3012  if ((!pFormat && !m_pImpl->IsDescriptor()) ||
3013  rName.isEmpty() ||
3014  rName.indexOf('.')>=0 ||
3015  rName.indexOf(' ')>=0 )
3016  throw uno::RuntimeException();
3017 
3018  if(pFormat)
3019  {
3020  const OUString aOldName( pFormat->GetName() );
3021  const SwFrameFormats* pFrameFormats = pFormat->GetDoc()->GetTableFrameFormats();
3022  for (size_t i = pFrameFormats->size(); i;)
3023  {
3024  const SwFrameFormat* pTmpFormat = (*pFrameFormats)[--i];
3025  if( !pTmpFormat->IsDefault() &&
3026  pTmpFormat->GetName() == rName &&
3027  pFormat->GetDoc()->IsUsed( *pTmpFormat ))
3028  {
3029  throw uno::RuntimeException();
3030  }
3031  }
3032 
3033  pFormat->SetName( rName );
3034 
3035  SwStartNode *pStNd;
3036  SwNodeIndex aIdx( *pFormat->GetDoc()->GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
3037  while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
3038  {
3039  ++aIdx;
3040  SwNode *const pNd = & aIdx.GetNode();
3041  if ( pNd->IsOLENode() &&
3042  aOldName == static_cast<const SwOLENode*>(pNd)->GetChartTableName() )
3043  {
3044  static_cast<SwOLENode*>(pNd)->SetChartTableName( rName );
3045 
3046  SwTable* pTable = SwTable::FindTable( pFormat );
3047  //TL_CHART2: chart needs to be notified about name changes
3048  pFormat->GetDoc()->UpdateCharts( pTable->GetFrameFormat()->GetName() );
3049  }
3050  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
3051  }
3052  pFormat->GetDoc()->getIDocumentState().SetModified();
3053  }
3054  else
3055  m_pImpl->m_sTableName = rName;
3056 }
3057 
3059 {
3060  sal_uInt16 nRet = 0;
3061  SwFrameFormat* pFormat = GetFrameFormat();
3062  if(pFormat)
3063  {
3064  SwTable* pTable = SwTable::FindTable( pFormat );
3065  if(!pTable->IsTableComplex())
3066  {
3067  nRet = pTable->GetTabLines().size();
3068  }
3069  }
3070  return nRet;
3071 }
3072 
3074 {
3075  SwFrameFormat* pFormat = GetFrameFormat();
3076  sal_uInt16 nRet = 0;
3077  if(pFormat)
3078  {
3079  SwTable* pTable = SwTable::FindTable( pFormat );
3080  if(!pTable->IsTableComplex())
3081  {
3082  SwTableLines& rLines = pTable->GetTabLines();
3083  SwTableLine* pLine = rLines.front();
3084  nRet = pLine->GetTabBoxes().size();
3085  }
3086  }
3087  return nRet;
3088 }
3089 
3091 {
3092  if(rHint.GetId() == SfxHintId::Dying)
3093  {
3094  m_pFrameFormat = nullptr;
3095  EndListeningAll();
3096  }
3097  uno::Reference<uno::XInterface> const xThis(m_wThis);
3098  if (xThis.is())
3099  { // fdo#72695: if UNO object is already dead, don't revive it with event
3100  if(!m_pFrameFormat)
3101  {
3102  lang::EventObject const ev(xThis);
3103  m_Listeners.disposeAndClear(ev);
3104  }
3105  else
3106  {
3107  lcl_SendChartEvent(xThis, m_Listeners);
3108  }
3109  }
3110 }
3111 
3113  { return "SwXTextTable"; }
3114 
3115 sal_Bool SwXTextTable::supportsService(const OUString& rServiceName)
3116  { return cppu::supportsService(this, rServiceName); }
3117 
3119 {
3120  return {
3121  "com.sun.star.document.LinkTarget",
3122  "com.sun.star.text.TextTable",
3123  "com.sun.star.text.TextContent",
3124  "com.sun.star.text.TextSortable" };
3125 }
3126 
3127 
3129  : public SvtListener
3130 {
3131 private:
3132  ::osl::Mutex m_Mutex; // just for OInterfaceContainerHelper2
3134 
3135 public:
3136  uno::WeakReference<uno::XInterface> m_wThis;
3138 
3140 
3143 
3146 
3147  Impl(sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor const& rDesc)
3148  : m_pFrameFormat(&rFrameFormat)
3149  , m_ChartListeners(m_Mutex)
3150  , m_pTableCursor(pCursor)
3151  , m_RangeDescriptor(rDesc)
3152  , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
3153  , m_bFirstRowAsLabel(false)
3154  , m_bFirstColumnAsLabel(false)
3155  {
3156  StartListening(rFrameFormat.GetNotifier());
3157  m_RangeDescriptor.Normalize();
3158  }
3159 
3161  {
3162  return m_pFrameFormat;
3163  }
3164 
3165  std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> GetLabelCoordinates(bool bRow);
3166 
3167  uno::Sequence<OUString> GetLabelDescriptions(SwXCellRange & rThis, bool bRow);
3168 
3169  void SetLabelDescriptions(SwXCellRange & rThis,
3170  const css::uno::Sequence<OUString>& rDesc, bool bRow);
3171 
3172  sal_Int32 GetRowCount() const;
3173  sal_Int32 GetColumnCount() const;
3174 
3175  virtual void Notify(const SfxHint& ) override;
3176 
3177 };
3178 
3179 namespace
3180 {
3181 }
3182 
3183 const uno::Sequence< sal_Int8 > & SwXCellRange::getUnoTunnelId()
3184 {
3185  static const UnoTunnelIdInit theSwXCellRangeUnoTunnelId;
3186  return theSwXCellRangeUnoTunnelId.getSeq();
3187 }
3188 
3189 sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& rId )
3190 {
3191  if( isUnoTunnelId<SwXCellRange>(rId) )
3192  {
3193  return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) );
3194  }
3195  return 0;
3196 }
3197 
3198 
3200  { return "SwXCellRange"; }
3201 
3202 sal_Bool SwXCellRange::supportsService(const OUString& rServiceName)
3203  { return cppu::supportsService(this, rServiceName); }
3204 
3206 {
3207  return {
3208  "com.sun.star.text.CellRange",
3209  "com.sun.star.style.CharacterProperties",
3210  "com.sun.star.style.CharacterPropertiesAsian",
3211  "com.sun.star.style.CharacterPropertiesComplex",
3212  "com.sun.star.style.ParagraphProperties",
3213  "com.sun.star.style.ParagraphPropertiesAsian",
3214  "com.sun.star.style.ParagraphPropertiesComplex" };
3215 }
3216 
3218  SwFrameFormat& rFrameFormat, SwRangeDescriptor const & rDesc)
3219  : m_pImpl(new Impl(pCursor, rFrameFormat, rDesc))
3220 {
3221 }
3222 
3224 {
3225 }
3226 
3228  sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat,
3229  SwRangeDescriptor const & rDesc)
3230 {
3231  rtl::Reference<SwXCellRange> pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
3232  // need a permanent Reference to initialize m_wThis
3233  pCellRange->m_pImpl->m_wThis = uno::Reference<table::XCellRange>(pCellRange);
3234  return pCellRange;
3235 }
3236 
3237 void SwXCellRange::SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
3238 {
3239  m_pImpl->m_bFirstRowAsLabel = bFirstRowAsLabel;
3240  m_pImpl->m_bFirstColumnAsLabel = bFirstColumnAsLabel;
3241 }
3242 
3243 std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
3244 {
3245  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3246  const sal_Int32 nRowCount(m_pImpl->GetRowCount());
3247  const sal_Int32 nColCount(m_pImpl->GetColumnCount());
3248  std::vector< uno::Reference< table::XCell > > vResult;
3249  vResult.reserve(static_cast<size_t>(nRowCount)*static_cast<size_t>(nColCount));
3250  for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
3251  for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
3252  vResult.emplace_back(lcl_CreateXCell(pFormat, m_pImpl->m_RangeDescriptor.nLeft + nCol, m_pImpl->m_RangeDescriptor.nTop + nRow));
3253  return vResult;
3254 }
3255 
3256 uno::Reference<table::XCell> SAL_CALL
3257 SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
3258 {
3259  SolarMutexGuard aGuard;
3260  uno::Reference< table::XCell > aRet;
3261  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3262  if(pFormat)
3263  {
3264  if(nColumn >= 0 && nRow >= 0 &&
3265  m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > nRow )
3266  {
3267  rtl::Reference<SwXCell> pXCell = lcl_CreateXCell(pFormat,
3268  m_pImpl->m_RangeDescriptor.nLeft + nColumn,
3269  m_pImpl->m_RangeDescriptor.nTop + nRow);
3270  if(pXCell)
3271  aRet = pXCell;
3272  }
3273  }
3274  if(!aRet.is())
3275  throw lang::IndexOutOfBoundsException();
3276  return aRet;
3277 }
3278 
3279 uno::Reference<table::XCellRange> SAL_CALL
3281  sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
3282 {
3283  SolarMutexGuard aGuard;
3284  uno::Reference< table::XCellRange > aRet;
3285  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3286  if (pFormat && m_pImpl->GetColumnCount() > nRight
3287  && m_pImpl->GetRowCount() > nBottom &&
3288  nLeft <= nRight && nTop <= nBottom
3289  && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
3290  {
3291  SwTable* pTable = SwTable::FindTable( pFormat );
3292  if(!pTable->IsTableComplex())
3293  {
3294  SwRangeDescriptor aNewDesc;
3295  aNewDesc.nTop = nTop + m_pImpl->m_RangeDescriptor.nTop;
3296  aNewDesc.nBottom = nBottom + m_pImpl->m_RangeDescriptor.nTop;
3297  aNewDesc.nLeft = nLeft + m_pImpl->m_RangeDescriptor.nLeft;
3298  aNewDesc.nRight = nRight + m_pImpl->m_RangeDescriptor.nLeft;
3299  aNewDesc.Normalize();
3300  const OUString sTLName = sw_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
3301  const OUString sBRName = sw_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
3302  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
3303  if(pTLBox)
3304  {
3305  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3306  SwPosition aPos(*pSttNd);
3307  // set cursor in the upper-left cell of the range
3308  auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
3309  pUnoCursor->Move( fnMoveForward, GoInNode );
3310  pUnoCursor->SetRemainInSection( false );
3311  const SwTableBox* pBRBox = pTable->GetTableBox( sBRName );
3312  if(pBRBox)
3313  {
3314  pUnoCursor->SetMark();
3315  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
3316  pUnoCursor->Move( fnMoveForward, GoInNode );
3317  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
3318  // HACK: remove pending actions for selecting old style tables
3319  UnoActionRemoveContext aRemoveContext(rCursor);
3320  rCursor.MakeBoxSels();
3321  // pUnoCursor will be provided and will not be deleted
3322  aRet = SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, aNewDesc).get();
3323  }
3324  }
3325  }
3326  }
3327  if(!aRet.is())
3328  throw lang::IndexOutOfBoundsException();
3329  return aRet;
3330 }
3331 
3332 uno::Reference<table::XCellRange> SAL_CALL
3333 SwXCellRange::getCellRangeByName(const OUString& rRange)
3334 {
3335  SolarMutexGuard aGuard;
3336  sal_Int32 nPos = 0;
3337  const OUString sTLName(rRange.getToken(0, ':', nPos));
3338  const OUString sBRName(rRange.getToken(0, ':', nPos));
3339  if(sTLName.isEmpty() || sBRName.isEmpty())
3340  throw uno::RuntimeException();
3341  SwRangeDescriptor aDesc;
3342  aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
3343  SwXTextTable::GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
3344  SwXTextTable::GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
3345  aDesc.Normalize();
3346  return getCellRangeByPosition(
3347  aDesc.nLeft - m_pImpl->m_RangeDescriptor.nLeft,
3348  aDesc.nTop - m_pImpl->m_RangeDescriptor.nTop,
3349  aDesc.nRight - m_pImpl->m_RangeDescriptor.nLeft,
3350  aDesc.nBottom - m_pImpl->m_RangeDescriptor.nTop);
3351 }
3352 
3353 uno::Reference< beans::XPropertySetInfo > SwXCellRange::getPropertySetInfo()
3354 {
3355  static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
3356  return xRef;
3357 }
3358 
3359 void SAL_CALL
3360 SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
3361 {
3362  SolarMutexGuard aGuard;
3363  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3364  if(!pFormat)
3365  return;
3366 
3367  const SfxItemPropertyMapEntry *const pEntry =
3368  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3369  if(!pEntry)
3370  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3371 
3372  if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3373  throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3374 
3375  SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3376  SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor));
3377  {
3378  // HACK: remove pending actions for selecting old style tables
3379  UnoActionRemoveContext aRemoveContext(rCursor);
3380  }
3381  rCursor.MakeBoxSels();
3382  switch(pEntry->nWID )
3383  {
3385  {
3386  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3387  SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
3388  aBrush->PutValue(aValue, pEntry->nMemberId);
3389  rDoc.SetBoxAttr(*m_pImpl->m_pTableCursor, *aBrush);
3390 
3391  }
3392  break;
3393  case RES_BOX :
3394  {
3395  SfxItemSet aSet(rDoc.GetAttrPool(),
3397  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
3398  SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
3399  aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::ALL, false);
3400  SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::NONE;
3401  switch(pEntry->nMemberId & ~CONVERT_TWIPS)
3402  {
3403  case LEFT_BORDER : nValid = SvxBoxInfoItemValidFlags::LEFT; break;
3404  case RIGHT_BORDER: nValid = SvxBoxInfoItemValidFlags::RIGHT; break;
3405  case TOP_BORDER : nValid = SvxBoxInfoItemValidFlags::TOP; break;
3406  case BOTTOM_BORDER: nValid = SvxBoxInfoItemValidFlags::BOTTOM; break;
3407  case LEFT_BORDER_DISTANCE :
3408  case RIGHT_BORDER_DISTANCE:
3409  case TOP_BORDER_DISTANCE :
3411  nValid = SvxBoxInfoItemValidFlags::DISTANCE;
3412  break;
3413  }
3414  aBoxInfo.SetValid(nValid);
3415 
3416  aSet.Put(aBoxInfo);
3417  SwDoc::GetTabBorders(rCursor, aSet);
3418 
3419  aSet.Put(aBoxInfo);
3420  SvxBoxItem aBoxItem(aSet.Get(RES_BOX));
3421  static_cast<SfxPoolItem&>(aBoxItem).PutValue(aValue, pEntry->nMemberId);
3422  aSet.Put(aBoxItem);
3423  rDoc.SetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3424  }
3425  break;
3426  case RES_BOXATR_FORMAT:
3427  {
3428  SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
3429  static_cast<SfxPoolItem&>(aNumberFormat).PutValue(aValue, 0);
3430  rDoc.SetBoxAttr(rCursor, aNumberFormat);
3431  }
3432  break;
3434  {
3435  bool bTmp = *o3tl::doAccess<bool>(aValue);
3436  if (m_pImpl->m_bFirstRowAsLabel != bTmp)
3437  {
3438  lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
3439  m_pImpl->m_bFirstRowAsLabel = bTmp;
3440  }
3441  }
3442  break;
3444  {
3445  bool bTmp = *o3tl::doAccess<bool>(aValue);
3446  if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
3447  {
3448  lcl_SendChartEvent(*this, m_pImpl->m_ChartListeners);
3449  m_pImpl->m_bFirstColumnAsLabel = bTmp;
3450  }
3451  }
3452  break;
3453  case RES_VERT_ORIENT:
3454  {
3455  sal_Int16 nAlign = -1;
3456  aValue >>= nAlign;
3457  if( nAlign >= text::VertOrientation::NONE && nAlign <= text::VertOrientation::BOTTOM)
3458  rDoc.SetBoxAlign( rCursor, nAlign );
3459  }
3460  break;
3461  default:
3462  {
3463  SfxItemSet aItemSet( rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID );
3465  aItemSet);
3466 
3468  *pEntry, aValue, rCursor.GetSelRing(), aItemSet))
3469  {
3470  m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
3471  }
3473  aItemSet, SetAttrMode::DEFAULT, true);
3474  }
3475  }
3476 }
3477 
3478 uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
3479 {
3480  SolarMutexGuard aGuard;
3481  uno::Any aRet;
3482  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3483  if(pFormat)
3484  {
3485  const SfxItemPropertyMapEntry *const pEntry =
3486  m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3487  if(!pEntry)
3488  throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3489 
3490  switch(pEntry->nWID )
3491  {
3493  {
3494  std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3495  if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush))
3496  aBrush->QueryValue(aRet, pEntry->nMemberId);
3497 
3498  }
3499  break;
3500  case RES_BOX :
3501  {
3502  SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3503  SfxItemSet aSet(rDoc.GetAttrPool(),
3505  SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>);
3506  aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
3507  SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3508  const SvxBoxItem& rBoxItem = aSet.Get(RES_BOX);
3509  rBoxItem.QueryValue(aRet, pEntry->nMemberId);
3510  }
3511  break;
3512  case RES_BOXATR_FORMAT:
3513  OSL_FAIL("not implemented");
3514  break;
3515  case FN_UNO_PARA_STYLE:
3516  {
3517  SwFormatColl *const pTmpFormat =
3518  SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false);
3519  OUString sRet;
3520  if (pTmpFormat)
3521  sRet = pTmpFormat->GetName();
3522  aRet <<= sRet;
3523  }
3524  break;
3526  aRet <<= m_pImpl->m_bFirstRowAsLabel;
3527  break;
3529  aRet <<= m_pImpl->m_bFirstColumnAsLabel;
3530  break;
3531  case RES_VERT_ORIENT:
3532  {
3533  std::unique_ptr<SfxPoolItem> aVertOrient(
3534  std::make_unique<SwFormatVertOrient>(RES_VERT_ORIENT));
3535  if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
3536  {
3537  aVertOrient->QueryValue( aRet, pEntry->nMemberId );
3538  }
3539  }
3540  break;
3541  default:
3542  {
3543  SfxItemSet aSet(
3544  m_pImpl->m_pTableCursor->GetDoc().GetAttrPool(),
3545  svl::Items<
3548  RES_UNKNOWNATR_CONTAINER>);
3549  // first look at the attributes of the cursor
3550  SwUnoTableCursor *const pCursor =
3551  dynamic_cast<SwUnoTableCursor*>(&(*m_pImpl->m_pTableCursor));
3552  SwUnoCursorHelper::GetCursorAttr(pCursor->GetSelRing(), aSet);
3553  m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
3554  }
3555  }
3556 
3557  }
3558  return aRet;
3559 }
3560 
3561 void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3562  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3563 
3564 void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3565  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3566 
3567 void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3568  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3569 
3570 void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3571  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3572 
3574 uno::Sequence<uno::Sequence<uno::Any>> SAL_CALL SwXCellRange::getDataArray()
3575 {
3576  SolarMutexGuard aGuard;
3577  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3578  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3579  if(!nRowCount || !nColCount)
3580  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3581  lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3582  uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
3583  auto vCells(GetCells());
3584  auto pCurrentCell(vCells.begin());
3585  for(auto& rRow : aRowSeq)
3586  {
3587  rRow = uno::Sequence< uno::Any >(nColCount);
3588  for(auto& rCellAny : rRow)
3589  {
3590  auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3591  if(!pCell)
3592  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3593  rCellAny = pCell->GetAny();
3594  ++pCurrentCell;
3595  }
3596  }
3597  return aRowSeq;
3598 }
3599 
3601 void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
3602 {
3603  SolarMutexGuard aGuard;
3604  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3605  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3606  if(!nRowCount || !nColCount)
3607  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3608  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3609  if(!pFormat)
3610  return;
3611  if(rArray.getLength() != nRowCount)
3612  throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this));
3613  auto vCells(GetCells());
3614  auto pCurrentCell(vCells.begin());
3615  for(const auto& rColSeq : rArray)
3616  {
3617  if(rColSeq.getLength() != nColCount)
3618  throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rColSeq.getLength()), static_cast<cppu::OWeakObject*>(this));
3619  for(const auto& aValue : rColSeq)
3620  {
3621  auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3622  if(!pCell || !pCell->GetTableBox())
3623  throw uno::RuntimeException("Box for cell missing", static_cast<cppu::OWeakObject*>(this));
3624  if(aValue.isExtractableTo(cppu::UnoType<OUString>::get()))
3625  sw_setString(*pCell, aValue.get<OUString>());
3626  else if(aValue.isExtractableTo(cppu::UnoType<double>::get()))
3627  sw_setValue(*pCell, aValue.get<double>());
3628  else
3629  sw_setString(*pCell, OUString(), true);
3630  ++pCurrentCell;
3631  }
3632  }
3633 }
3634 
3635 uno::Sequence<uno::Sequence<double>> SAL_CALL
3637 {
3638  SolarMutexGuard aGuard;
3639  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3640  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3641  if(!nRowCount || !nColCount)
3642  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3643  if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3644  {
3645  uno::Reference<chart::XChartDataArray> const xDataRange(
3646  getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3647  (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3648  nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3649  return xDataRange->getData();
3650  }
3651  uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
3652  auto vCells(GetCells());
3653  auto pCurrentCell(vCells.begin());
3654  for(auto& rRow : vRows)
3655  {
3656  rRow = uno::Sequence<double>(nColCount);
3657  for(auto& rValue : rRow)
3658  {
3659  if(!(*pCurrentCell))
3660  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3661  rValue = (*pCurrentCell)->getValue();
3662  ++pCurrentCell;
3663  }
3664  }
3665  return vRows;
3666 }
3667 
3668 void SAL_CALL
3669 SwXCellRange::setData(const uno::Sequence< uno::Sequence<double> >& rData)
3670 {
3671  SolarMutexGuard aGuard;
3672  const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3673  const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3674  if(!nRowCount || !nColCount)
3675  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3676  if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3677  {
3678  uno::Reference<chart::XChartDataArray> const xDataRange(
3679  getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3680  (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3681  nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3682  return xDataRange->setData(rData);
3683  }
3684  lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3685  if(rData.getLength() != nRowCount)
3686  throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this));
3687  auto vCells(GetCells());
3688  auto pCurrentCell(vCells.begin());
3689  for(const auto& rRow : rData)
3690  {
3691  if(rRow.getLength() != nColCount)
3692  throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
3693  for(const auto& rValue : rRow)
3694  {
3695  uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_SET_THROW)->setValue(rValue);
3696  ++pCurrentCell;
3697  }
3698  }
3699 }
3700 
3701 std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32>
3703 {
3704  sal_uInt32 nLeft, nTop, nRight, nBottom;
3705  nLeft = nTop = nRight = nBottom = 0;
3706  if(bRow)
3707  {
3708  nTop = m_bFirstRowAsLabel ? 1 : 0;
3709  nBottom = GetRowCount() - 1;
3710  }
3711  else
3712  {
3713  nLeft = m_bFirstColumnAsLabel ? 1 : 0;
3714  nRight = GetColumnCount() - 1;
3715  }
3716  return std::make_tuple(nLeft, nTop, nRight, nBottom);
3717 }
3718 
3719 uno::Sequence<OUString>
3721 {
3722  SolarMutexGuard aGuard;
3723  sal_uInt32 nLeft, nTop, nRight, nBottom;
3724  std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3725  if(!nRight && !nBottom)
3726  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3727  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3728  if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3729  return {}; // without labels we have no descriptions
3730  auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3731  auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3732  uno::Sequence<OUString> vResult(vCells.size());
3733  std::transform(vCells.begin(), vCells.end(), vResult.begin(),
3734  [](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); });
3735  return vResult;
3736 }
3737 
3738 uno::Sequence<OUString> SAL_CALL SwXCellRange::getRowDescriptions()
3739 {
3740  return m_pImpl->GetLabelDescriptions(*this, true);
3741 }
3742 
3743 uno::Sequence<OUString> SAL_CALL SwXCellRange::getColumnDescriptions()
3744 {
3745  return m_pImpl->GetLabelDescriptions(*this, false);
3746 }
3747 
3749  const uno::Sequence<OUString>& rDesc, bool bRow)
3750 {
3751  SolarMutexGuard aGuard;
3752  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3753  if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3754  return; // if there are no labels we cannot set descriptions
3755  sal_uInt32 nLeft, nTop, nRight, nBottom;
3756  std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3757  if(!nRight && !nBottom)
3758  throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3759  auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3760  if (!xLabelRange.is())
3761  throw uno::RuntimeException("Missing Cell Range", static_cast<cppu::OWeakObject*>(&rThis));
3762  auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3763  if (sal::static_int_cast<sal_uInt32>(rDesc.getLength()) != vCells.size())
3764  throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(&rThis));
3765  auto pDescIterator(rDesc.begin());
3766  for(auto& xCell : vCells)
3767  uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->setString(*pDescIterator++);
3768 }
3769 
3771  const uno::Sequence<OUString>& rRowDesc)
3772 {
3773  m_pImpl->SetLabelDescriptions(*this, rRowDesc, true);
3774 }
3775 
3777  const uno::Sequence<OUString>& rColumnDesc)
3778 {
3779  m_pImpl->SetLabelDescriptions(*this, rColumnDesc, false);
3780 }
3781 
3783  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3784 {
3785  // no need to lock here as m_pImpl is const and container threadsafe
3786  m_pImpl->m_ChartListeners.addInterface(xListener);
3787 }
3788 
3790  const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3791 {
3792  // no need to lock here as m_pImpl is const and container threadsafe
3793  m_pImpl->m_ChartListeners.removeInterface(xListener);
3794 }
3795 
3797  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3798 
3800  { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3801 
3802 uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor()
3803 {
3804  SolarMutexGuard aGuard;
3806 }
3807 
3808 void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
3809 {
3810  SolarMutexGuard aGuard;
3811  SwSortOptions aSortOpt;
3812  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3813  if(pFormat && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
3814  {
3815  SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
3816  rTableCursor.MakeBoxSels();
3817  UnoActionContext aContext(pFormat->GetDoc());
3818  pFormat->GetDoc()->SortTable(rTableCursor.GetSelectedBoxes(), aSortOpt);
3819  }
3820 }
3821 
3823 {
3824  return m_RangeDescriptor.nRight - m_RangeDescriptor.nLeft + 1;
3825 }
3826 
3828 {
3829  return m_RangeDescriptor.nBottom - m_RangeDescriptor.nTop + 1;
3830 }
3831 
3833 {
3834  SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3835  return pFormat ? &(*m_pImpl->m_pTableCursor) : nullptr;
3836 }
3837 
3839 {
3840  uno::Reference<uno::XInterface> const xThis(m_wThis);
3841  if(rHint.GetId() == SfxHintId::Dying)
3842  {
3843  m_pFrameFormat = nullptr;
3844  m_pTableCursor.reset(nullptr);
3845  }
3846  if (xThis.is())
3847  { // fdo#72695: if UNO object is already dead, don't revive it with event
3848  if(m_pFrameFormat)
3849  lcl_SendChartEvent(xThis, m_ChartListeners);
3850  else
3851  m_ChartListeners.disposeAndClear(lang::EventObject(xThis));
3852  }
3853 }
3854 
3856 {
3857 private:
3859 
3860 public:
3861  explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
3862  {
3863  StartListening(rFrameFormat.GetNotifier());
3864  }
3865  SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
3866  virtual void Notify(const SfxHint&) override;
3867 };
3868 
3869 // SwXTableRows
3870 
3872  { return "SwXTableRows"; }
3873 
3874 sal_Bool SwXTableRows::supportsService(const OUString& rServiceName)
3875  { return cppu::supportsService(this, rServiceName); }
3876 
3877 uno::Sequence< OUString > SwXTableRows::getSupportedServiceNames()
3878  { return { "com.sun.star.text.TableRows" }; }
3879 
3880 
3882  m_pImpl(new SwXTableRows::Impl(rFrameFormat))
3883 { }
3884 
3886 { }
3887 
3889 {
3890  return m_pImpl->GetFrameFormat();
3891 }
3892 
3894 {
3895  SolarMutexGuard aGuard;
3896  SwFrameFormat* pFrameFormat = GetFrameFormat();
3897  if(!pFrameFormat)
3898  throw uno::RuntimeException();
3899  SwTable* pTable = SwTable::FindTable(pFrameFormat);
3900  return pTable->GetTabLines().size();
3901 }
3902 
3905 {
3906  SolarMutexGuard aGuard;
3907  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3908  if(nIndex < 0)
3909  throw lang::IndexOutOfBoundsException();
3910  SwTable* pTable = SwTable::FindTable( pFrameFormat );
3911  if(o3tl::make_unsigned(nIndex) >= pTable->GetTabLines().size())
3912  throw lang::IndexOutOfBoundsException();
3913  SwTableLine* pLine = pTable->GetTabLines()[nIndex];
3914  FindUnoInstanceHint<SwTableLine,SwXTextTableRow> aHint{pLine};
3915  pFrameFormat->GetNotifier().Broadcast(aHint);
3916  if(!aHint.m_pResult)
3917  aHint.m_pResult = new SwXTextTableRow(pFrameFormat, pLine);
3918  uno::Reference<beans::XPropertySet> xRet = static_cast<beans::XPropertySet*>(aHint.m_pResult.get());
3919  return uno::makeAny(xRet);
3920 }
3921 
3923 {
3925 }
3926 
3928 {
3929  SolarMutexGuard aGuard;
3930  SwFrameFormat* pFrameFormat = GetFrameFormat();
3931  if(!pFrameFormat)
3932  throw uno::RuntimeException();
3933  // a table always has rows
3934  return true;
3935 }
3936 
3937 void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3938 {
3939  SolarMutexGuard aGuard;
3940  if (nCount == 0)
3941  return;
3942  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3943  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3944  const size_t nRowCount = pTable->GetTabLines().size();
3945  if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nRowCount)
3946  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3947  const OUString sTLName = sw_GetCellName(0, nIndex);
3948  const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3949  bool bAppend = false;
3950  if(!pTLBox)
3951  {
3952  bAppend = true;
3953  // to append at the end the cursor must be in the last line
3954  SwTableLines& rLines = pTable->GetTabLines();
3955  SwTableLine* pLine = rLines.back();
3956  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
3957  pTLBox = rBoxes.front();
3958  }
3959  if(!pTLBox)
3960  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3961  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3962  SwPosition aPos(*pSttNd);
3963  // set cursor to the upper-left cell of the range
3964  UnoActionContext aAction(pFrameFormat->GetDoc());
3965  std::shared_ptr<SwUnoTableCursor> const pUnoCursor(
3966  std::dynamic_pointer_cast<SwUnoTableCursor>(
3967  pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true)));
3968  pUnoCursor->Move( fnMoveForward, GoInNode );
3969  {
3970  // remove actions - TODO: why?
3971  UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
3972  }
3973  pFrameFormat->GetDoc()->InsertRow(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
3974 }
3975 
3976 void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3977 {
3978  SolarMutexGuard aGuard;
3979  if (nCount == 0)
3980  return;
3981  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3982  if(nIndex < 0 || nCount <=0 )
3983  throw uno::RuntimeException();
3984  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3985  OUString sTLName = sw_GetCellName(0, nIndex);
3986  const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3987  if(!pTLBox)
3988  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3989  const SwStartNode* pSttNd = pTLBox->GetSttNd();
3990  SwPosition aPos(*pSttNd);
3991  // set cursor to the upper-left cell of the range
3992  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
3993  pUnoCursor->Move(fnMoveForward, GoInNode);
3994  pUnoCursor->SetRemainInSection( false );
3995  const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
3996  const SwTableBox* pBLBox = pTable->GetTableBox( sBLName );
3997  if(!pBLBox)
3998  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3999  pUnoCursor->SetMark();
4000  pUnoCursor->GetPoint()->nNode = *pBLBox->GetSttNd();
4001  pUnoCursor->Move(fnMoveForward, GoInNode);
4002  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
4003  {
4004  // HACK: remove pending actions for selecting old style tables
4005  UnoActionRemoveContext aRemoveContext(rCursor);
4006  }
4007  rCursor.MakeBoxSels();
4008  { // these braces are important
4009  UnoActionContext aAction(pFrameFormat->GetDoc());
4010  pFrameFormat->GetDoc()->DeleteRow(*pUnoCursor);
4011  pUnoCursor.reset();
4012  }
4013  {
4014  // invalidate all actions - TODO: why?
4015  UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4016  }
4017 }
4018 
4020 {
4021  if(rHint.GetId() == SfxHintId::Dying)
4022  m_pFrameFormat = nullptr;
4023 }
4024 
4025 // SwXTableColumns
4026 
4028 {
4030  public:
4031  explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
4032  {
4033  StartListening(rFrameFormat.GetNotifier());
4034  }
4035  SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
4036  virtual void Notify(const SfxHint&) override;
4037 };
4038 
4040  { return "SwXTableColumns"; }
4041 
4042 sal_Bool SwXTableColumns::supportsService(const OUString& rServiceName)
4043  { return cppu::supportsService(this, rServiceName); }
4044 
4046  { return { "com.sun.star.text.TableColumns"}; }
4047 
4048 
4050  m_pImpl(new SwXTableColumns::Impl(rFrameFormat))
4051 { }
4052 
4054 { }
4055 
4057 {
4058  return m_pImpl->GetFrameFormat();
4059 }
4060 
4062 {
4063  SolarMutexGuard aGuard;
4064  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4065  SwTable* pTable = SwTable::FindTable( pFrameFormat );
4066 // if(!pTable->IsTableComplex())
4067 // throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
4068  SwTableLines& rLines = pTable->GetTabLines();
4069  SwTableLine* pLine = rLines.front();
4070  return pLine->GetTabBoxes().size();
4071 }
4072 
4074 {
4075  SolarMutexGuard aGuard;
4076  if(nIndex < 0 || getCount() <= nIndex)
4077  throw lang::IndexOutOfBoundsException();
4078  return uno::makeAny(uno::Reference<uno::XInterface>()); // i#21699 not supported
4079 }
4080 
4082 {
4084 }
4085 
4087 {
4088  SolarMutexGuard aGuard;
4089  lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
4090  return true;
4091 }
4092 
4094 void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4095 {
4096  SolarMutexGuard aGuard;
4097  if (nCount == 0)
4098  return;
4099  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4100  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4101  SwTableLines& rLines = pTable->GetTabLines();
4102  SwTableLine* pLine = rLines.front();
4103  const size_t nColCount = pLine->GetTabBoxes().size();
4104  if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nColCount)
4105  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4106  const OUString sTLName = sw_GetCellName(nIndex, 0);
4107  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4108  bool bAppend = false;
4109  if(!pTLBox)
4110  {
4111  bAppend = true;
4112  // to append at the end the cursor must be in the last line
4113  SwTableBoxes& rBoxes = pLine->GetTabBoxes();
4114  pTLBox = rBoxes.back();
4115  }
4116  if(!pTLBox)
4117  throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4118  const SwStartNode* pSttNd = pTLBox->GetSttNd();
4119  SwPosition aPos(*pSttNd);
4120  UnoActionContext aAction(pFrameFormat->GetDoc());
4121  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4122  pUnoCursor->Move(fnMoveForward, GoInNode);
4123 
4124  {
4125  // remove actions - TODO: why?
4126  UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
4127  }
4128 
4129  pFrameFormat->GetDoc()->InsertCol(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
4130 }
4131 
4133 void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4134 {
4135  SolarMutexGuard aGuard;
4136  if (nCount == 0)
4137  return;
4138  SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4139  if(nIndex < 0 || nCount <=0 )
4140  throw uno::RuntimeException();
4141  SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4142  const OUString sTLName = sw_GetCellName(nIndex, 0);
4143  const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4144  if(!pTLBox)
4145  throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4146  const SwStartNode* pSttNd = pTLBox->GetSttNd();
4147  SwPosition aPos(*pSttNd);
4148  // set cursor to the upper-left cell of the range
4149  auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4150  pUnoCursor->Move(fnMoveForward, GoInNode);
4151  pUnoCursor->SetRemainInSection(false);
4152  const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
4153  const SwTableBox* pTRBox = pTable->GetTableBox(sTRName);
4154  if(!pTRBox)
4155  throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4156  pUnoCursor->SetMark();
4157  pUnoCursor->GetPoint()->nNode = *pTRBox->GetSttNd();
4158  pUnoCursor->Move(fnMoveForward, GoInNode);
4159  SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
4160  {
4161  // HACK: remove pending actions for selecting old style tables
4162  UnoActionRemoveContext aRemoveContext(rCursor);
4163  }
4164  rCursor.MakeBoxSels();
4165  { // these braces are important
4166  UnoActionContext aAction(pFrameFormat->GetDoc());
4167  pFrameFormat->GetDoc()->DeleteCol(*pUnoCursor);
4168  pUnoCursor.reset();
4169  }
4170  {
4171  // invalidate all actions - TODO: why?
4172  UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4173  }
4174 }
4175 
4177 {
4178  if(rHint.GetId() == SfxHintId::Dying)
4179  m_pFrameFormat = nullptr;
4180 }
4181 
4182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL gotoEnd(sal_Bool bExpand) override
Definition: unotbl.cxx:1572
virtual SvxFormatBreakItem * Clone(SfxItemPool *pPool=nullptr) const override
void SetTableBoxFormulaAttrs(SwTableBox &rBox, const SfxItemSet &rSet)
Definition: ndtbl.cxx:4176
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:683
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:3871
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:3636
static uno::Any lcl_GetSpecialProperty(SwFrameFormat *pFormat, const SfxItemPropertyMapEntry *pEntry)
Definition: unotbl.cxx:266
void Normalize()
Definition: unotbl.cxx:546
#define FN_UNO_WRAP
Definition: cmdid.h:558
Base class of the Writer layout elements.
Definition: frame.hxx:313
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1742
constexpr TypedWhichId< SvxFrameDirectionItem > RES_FRAMEDIR(120)
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:1628
constexpr TypedWhichId< SvXMLAttrContainerItem > RES_UNKNOWNATR_CONTAINER(RES_UNKNOWNATR_BEGIN)
void DeleteMark()
Definition: pam.hxx:177
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:1946
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:1393
static css::uno::Reference< css::text::XTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:2006
sal_uLong GetIndex() const
Definition: node.hxx:291
void InsertBox(const SwTableBox &rTableBox)
Definition: swcrsr.cxx:2515
static css::table::BorderLine2 SvxLineToLine(const editeng::SvxBorderLine *pLine, bool bConvert)
bool IsUsed(const sw::BroadcastingModify &) const
Definition: poolfmt.cxx:86
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx: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:771
void SetLabelDescriptions(SwXCellRange &rThis, const css::uno::Sequence< OUString > &rDesc, bool bRow)
Definition: unotbl.cxx:3748
virtual const SwDoc * GetDoc() const =0
virtual const SwDoc * GetDoc() const override
Definition: unotbl.cxx:1449
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:537
#define PROPERTY_MAP_TEXT_TABLE_CURSOR
Definition: unomap.hxx:49
virtual OUString SAL_CALL getFormula() override
Definition: unotbl.cxx:842
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:2098
void setPropertyValue(const SfxItemPropertyMapEntry &rEntry, const css::uno::Any &aVal, SfxItemSet &rSet) const
static std::pair< sal_uInt16, sal_uInt16 > ThrowIfComplex(SwXTextTable &rThis)
Definition: unotbl.cxx:1957
static void GetTabBorders(const SwCursor &rCursor, SfxItemSet &rSet)
Definition: ndtbl1.cxx:956
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:3865
bool IsSectionNode() const
Definition: node.hxx:645
Impl(SwFrameFormat *const pFrameFormat)
Definition: unotbl.cxx:1932
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:1084
Pagedescriptor Client of SwPageDesc that is "described" by the attribute.
Definition: fmtpdsc.hxx:35
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:4176
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:1525
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotbl.cxx:930
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:3191
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:2190
#define FN_TABLE_HEADLINE_COUNT
Definition: cmdid.h:394
virtual const SwRootFrame * GetCurrentLayout() const =0
static constexpr auto Items
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2546
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:1133
SwDocShell * GetDocShell()
Definition: doc.hxx:1352
std::string GetValue
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1411
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unotbl.cxx:2432
virtual sal_Bool SAL_CALL isNotANumber(double nNumber) override
Definition: unotbl.cxx:2411
virtual void SAL_CALL setRowDescriptions(const css::uno::Sequence< OUString > &aRowDescriptions) override
Definition: unotbl.cxx:2359
const SwFrameFormats * GetTableFrameFormats() const
Definition: doc.hxx:811
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:3937
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:1689
constexpr TypedWhichId< SvxFormatKeepItem > RES_KEEP(110)
void DeleteRow(const SwCursor &rCursor)
Deleting Columns/Rows.
Definition: ndtbl.cxx:1830
SwNodeIndex nNode
Definition: pam.hxx:37
void SetFrameFormat(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:1947
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:2476
::osl::Mutex m_Mutex
Definition: unotbl.cxx:1912
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:1232
virtual css::table::CellContentType SAL_CALL getType() override
Definition: unotbl.cxx:899
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:1748
#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:1447
virtual void SetModified()=0
Must be called manually at changes of format.
sal_uIntPtr sal_uLong
unsigned short m_nRows
Definition: unotbl.cxx:1929
long Long
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:369
virtual sal_Int32 SAL_CALL getCount() override
Definition: unotbl.cxx:4061
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotbl.cxx:779
#define MINLAY
Definition: swtypes.hxx:62
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:46
static void lcl_CursorSelect(SwPaM &rCursor, bool bExpand)
Definition: unotbl.cxx:600
uno::WeakReference< uno::XInterface > m_wThis
Definition: unotbl.cxx:1915
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:2301
SvxBoxInfoItem & rBoxInfoItem
SwTableFormat * FindTableFormatByName(const OUString &rName, bool bAll=false) const
Definition: ndtbl.cxx:3948
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1061
bool Left(sal_uInt16 nCnt)
Definition: swcrsr.hxx:172
Definition: doc.hxx:188
constexpr sal_uInt16 RES_FRMATR_END(133)
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3567
#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:467
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:451
#define RIGHT_BORDER_DISTANCE
sal_uInt16 GetDistance(SvxBoxItemLine nLine) const
void InvalidatePos()
Definition: frame.hxx:1040
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:3360
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:2002
virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override
Definition: unotbl.cxx:2321
sal_Int32 GetRowCount() const
Definition: unotbl.cxx:3827
#define MID_BACK_COLOR
css::uno::WeakReference< css::table::XTableColumns > m_xColumns
Definition: unotbl.cxx:1921
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:3160
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:195
SwSectionFormat * GetFormat()
Definition: section.hxx:336
virtual ~SwXTextTableRow() override
Definition: unotbl.cxx:1253
virtual sal_Int32 SAL_CALL getCount() override
Definition: unotbl.cxx:3893
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:1259
virtual sal_Bool SAL_CALL gotoCellByName(const OUString &aCellName, sal_Bool bExpand) override
Definition: unotbl.cxx:1516
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:3922
bool ConvertSortProperties(const css::uno::Sequence< css::beans::PropertyValue > &rDescriptor, SwSortOptions &rSortOpt)
constexpr TypedWhichId< SwTableBoxValue > RES_BOXATR_VALUE(152)
const editeng::SvxBorderLine * GetRight() const
SwTableLine * front() const
Definition: swtable.hxx:80
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
static SwTableLine * FindLine(SwTable *pTable, SwTableLine const *pLine)
Definition: unotbl.cxx:1411
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:4133
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:583
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:3885
#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:1982
size_type size() const
Definition: swtable.hxx:75
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotext.cxx:263
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:269
const OUString & GetName() const
Definition: pagedesc.hxx:196
constexpr TypedWhichId< SwFormatLayoutSplit > RES_LAYOUT_SPLIT(113)
const SfxItemPropertyMapEntry * getByName(std::u16string_view rName) const
#define FN_UNO_TABLE_NAME
Definition: cmdid.h:609
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:1424
sal_uInt16 GetRowCount()
Definition: unotbl.cxx:3058
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName(const OUString &aRange) override
Definition: unotbl.cxx:3333
const SvxBoxItem & GetBox(bool=true) const
Definition: frmatr.hxx:84
uno::WeakReference< uno::XInterface > m_wThis
Definition: unotbl.cxx:3136
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:542
void SetRightMax(tools::Long nNew)
Definition: tabcol.hxx:85
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:3199
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:1174
css::uno::Any const & rValue
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:3202
#define FN_UNO_TABLE_BORDER2
Definition: cmdid.h:625
constexpr TypedWhichId< SwFormatVertOrient > RES_VERT_ORIENT(102)
void sw_GetTableBoxColStr(sal_uInt16 nCol, OUString &rNm)
Definition: swtable.cxx:1718
sal_uInt16 IsFormulaOrValueBox() const
Definition: swtable.cxx:2502
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotbl.cxx:4081
uno::Sequence< OUString > GetLabelDescriptions(SwXCellRange &rThis, bool bRow)
Definition: unotbl.cxx:3720
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:944
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:767
void GetTabCols(SwTabCols &rToFill, const SwTableBox *pStart, bool bHidden=false, bool bCurRowOnly=false) const
Definition: swtable.cxx:510
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:1226
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:742
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotbl.cxx:1096
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:3561
#define FN_UNO_TABLE_BORDER
Definition: cmdid.h:536
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotbl.cxx:761
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3570
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotbl.cxx:968
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:1231
static SwPageDesc * GetByName(SwDoc &rDoc, std::u16string_view rName)
Definition: pagedesc.cxx:575
virtual sal_Bool SAL_CALL goUp(sal_Int16 nCount, sal_Bool bExpand) override
Definition: unotbl.cxx:1543
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:4039
SwIndex nContent
Definition: pam.hxx:38
void SetBoxAttr(const SwCursor &rCursor, const SfxPoolItem &rNew)
Definition: ndtbl1.cxx:1177
#define SAL_MAX_UINT16
SvxBoxInfoItemValidFlags
static bool lcl_LineToSvxLine(const table::BorderLine &rLine, SvxBorderLine &rSvxLine)
Definition: unotbl.cxx:172
#define FN_UNO_TEXT_WRAP
Definition: cmdid.h:565
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:1553
int nCount
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotbl.cxx:3927
virtual void SAL_CALL release() noexcept override
Definition: unotbl.cxx:789
virtual void UpdateTableFields(SfxPoolItem *pHt)=0
void getPropertyValue(const SfxItemPropertyMapEntry &rEntry, const SfxItemSet &rSet, css::uno::Any &rAny) const
#define FN_UNO_PARENT_TEXT
Definition: cmdid.h:549
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:2206
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:962
virtual void SetName(const OUString &rNewName, bool bBroadcast=false) override
Definition: atrfrm.cxx:2560
Impl(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4031
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:3858
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:1390
const SwTable & GetTable() const
Definition: node.hxx:499
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
#define FN_UNO_TABLE_COLUMN_RELATIVE_SUM
Definition: cmdid.h:538
virtual css::uno::Reference< css::table::XTableRows > SAL_CALL getRows() override
Definition: unotbl.cxx:2035
void UpdateCharts(const OUString &rName) const
Definition: docchart.cxx:120
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:3877
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
static bool GetBoxAttr(const SwCursor &rCursor, std::unique_ptr< SfxPoolItem > &rToFill)
Retrieves a box attribute from the given cursor.
Definition: ndtbl1.cxx:1222
sal_uLong IsValidNumTextNd(bool bCheckAttr=true) const
Definition: swtable.cxx:2420
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:630
void InsertRow(const SwCursor &rCursor, sal_uInt16 nCnt=1, bool bBehind=true)
Definition: ndtbl.cxx:1771
void DeleteCol(const SwCursor &rCursor)
Definition: ndtbl.cxx:1930
::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:653
#define FN_UNO_ROW_AUTO_HEIGHT
Definition: cmdid.h:541
#define LEFT_BORDER_DISTANCE
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1745
virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override
Definition: unotbl.cxx:2347
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:4035
virtual bool QueryValue(css::uno::Any &rVal, sal_uInt8 nMemberId=0) const override
void SetBoxAlign(const SwCursor &rCursor, sal_uInt16 nAlign)
Definition: ndtbl1.cxx:1285
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:2086
void EndListeningAll()
SwXTextTableCursor(SwFrameFormat *pFormat, SwTableBox const *pBox)
Definition: unotbl.cxx:1457
#define FN_UNO_PAGE_STYLE
Definition: cmdid.h:517
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:1761
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:2072
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1869
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:3090
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:3789
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:1342
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:2737
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:3237
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:1154
uno_Any a
SwXTableColumns(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4049
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
std::tuple< sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32 > GetLabelCoordinates(bool bRow)
Definition: unotbl.cxx:3702
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:3142
SwXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3217
bool empty() const
Definition: swtable.hxx:74
virtual void SAL_CALL acquire() noexcept override
Definition: unotbl.cxx:784
const SwFormatHoriOrient & GetHoriOrient(bool=true) const
Definition: fmtornt.hxx:108
#define LANGUAGE_SYSTEM
virtual sal_Int32 SAL_CALL getError() override
Definition: unotbl.cxx:923
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:1736
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:3118
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:1241
virtual void SAL_CALL setValue(double nValue) override
Definition: unotbl.cxx:893
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unotbl.cxx:917
void SetTabBorders(const SwCursor &rCursor, const SfxItemSet &rSet)
Definition: ndtbl1.cxx:594
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:2333
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:1911
virtual void SAL_CALL initialize(sal_Int32 nRows, sal_Int32 nColumns) override
Definition: unotbl.cxx:2027
virtual ~SwXCellRange() override
Definition: unotbl.cxx:3223
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:3280
void SetTextFormatColl(const css::uno::Any &rAny, SwPaM &rPaM)
size_t size() const
Definition: tblafmt.cxx:921
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:3257
static sal_uInt16 nCol1
Definition: srtdlg.cxx:43
#define FN_UNO_RANGE_COL_LABEL
Definition: cmdid.h:534
SwFrameFormat * GetFrameFormat() const
Definition: unotbl.cxx:4056
virtual const SwStartNode * GetStartNode() const override
Definition: unotbl.cxx:804
virtual void SAL_CALL setColumnDescriptions(const css::uno::Sequence< OUString > &aColumnDescriptions) override
Definition: unotbl.cxx:3776
#define FN_TABLE_IS_RELATIVE_WIDTH
Definition: cmdid.h:469
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:4094
float u
unsigned char sal_Bool
void UnlockModify()
Definition: calbck.hxx:204
#define BOTTOM_BORDER_DISTANCE
sal_uInt16 GetColumnCount()
Definition: unotbl.cxx:3073
virtual void SAL_CALL setDataArray(const css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &aArray) override
Definition: unotbl.cxx:2311
const SfxItemPropertyMap & getPropertyMap() const
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:1087
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unotbl.cxx:2425
#define FN_UNO_TABLE_CELL_BACKGROUND
Definition: cmdid.h:539
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
SwTableLine * m_pLine
Definition: unotbl.hxx:156
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override
Definition: unotbl.cxx:3904
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:3227
size
Marks a node in the document model.
Definition: ndindex.hxx:31
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:434
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unotbl.cxx:2198
bool UpDown(bool bUp, sal_uInt16 nCnt, Point const *pPt, tools::Long nUpDownX, SwRootFrame &rLayout)
Definition: swcrsr.cxx:1997
SwXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, size_t nPos)
Definition: unotbl.cxx:727
css::uno::Type const & get()
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:1120
virtual sal_Bool SAL_CALL mergeRange() override
Definition: unotbl.cxx:1581
SwXTextTableRow(SwFrameFormat *pFormat, SwTableLine *pLine)
Definition: unotbl.cxx:1245
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
#define SV_COUNTRY_LANGUAGE_OFFSET
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:3115
#define MID_GRAPHIC_POSITION
virtual sal_Bool SAL_CALL supportsServ