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