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