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