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