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