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