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