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