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(const OUString& rCellName, 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 = rCellName.getLength();
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 (rCellName[nRowPos]>='0' && rCellName[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 = rCellName[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(rCellName.subView(nRowPos)) - 1; // - 1 because indices ought to be 0 based
393}
394
404int sw_CompareCellsByRowFirst( const OUString &rCellName1, const OUString &rCellName2 )
405{
406 sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
407 SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
408 SwXTextTable::GetCellPosition( rCellName2, 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( const OUString &rCellName1, const OUString &rCellName2 )
428{
429 sal_Int32 nCol1 = -1, nRow1 = -1, nCol2 = -1, nRow2 = -1;
430 SwXTextTable::GetCellPosition( rCellName1, nCol1, nRow1 );
431 SwXTextTable::GetCellPosition( rCellName2, 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 const OUString &rRange1StartCell, const OUString &rRange1EndCell,
456 const OUString &rRange2StartCell, const OUString &rRange2EndCell,
457 bool bCmpColsFirst )
458{
459 int (*pCompareCells)( const OUString &, const OUString & ) =
461
462 int nCmpResStartCells = pCompareCells( rRange1StartCell, rRange2StartCell );
463 if ((-1 == nCmpResStartCells ) ||
464 ( 0 == nCmpResStartCells &&
465 -1 == pCompareCells( rRange1EndCell, rRange2EndCell ) ))
466 return -1;
467 else if (0 == nCmpResStartCells &&
468 0 == pCompareCells( rRange1EndCell, rRange2EndCell ))
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
746const uno::Sequence< sal_Int8 > & SwXCell::getUnoTunnelId()
747{
748 static const comphelper::UnoIdInit theSwXCellUnoTunnelId;
749 return theSwXCellUnoTunnelId.getSeq();
750}
751
752sal_Int64 SAL_CALL SwXCell::getSomething( const uno::Sequence< sal_Int8 >& rId )
753{
755}
756
757uno::Sequence< uno::Type > SAL_CALL SwXCell::getTypes( )
758{
760 SwXCellBaseClass::getTypes(),
762 );
763}
764
765uno::Sequence< sal_Int8 > SAL_CALL SwXCell::getImplementationId( )
766{
767 return css::uno::Sequence<sal_Int8>();
768}
769
770void SAL_CALL SwXCell::acquire( ) noexcept
771{
772 SwXCellBaseClass::acquire();
773}
774
775void SAL_CALL SwXCell::release( ) noexcept
776{
777 SolarMutexGuard aGuard;
778
779 SwXCellBaseClass::release();
780}
781
783{
784 uno::Any aRet = SwXCellBaseClass::queryInterface(aType);
785 if(aRet.getValueType() == cppu::UnoType<void>::get())
786 aRet = SwXText::queryInterface(aType);
787 return aRet;
788}
789
791{
792 const SwStartNode* pSttNd = nullptr;
793
794 if( m_pStartNode || IsValid() )
796
797 return pSttNd;
798}
799
800uno::Reference< text::XTextCursor >
802{
803 return createTextCursor();
804}
805
807{
808 // FIXME: this is now a const method, to make SwXText::IsValid invisible
809 // but the const_cast here are still ridiculous. TODO: find a better way.
810 SwFrameFormat* pTableFormat = m_pBox ? GetFrameFormat() : nullptr;
811 if(!pTableFormat)
812 {
813 const_cast<SwXCell*>(this)->m_pBox = nullptr;
814 }
815 else
816 {
817 SwTable* pTable = SwTable::FindTable( pTableFormat );
818 SwTableBox const*const pFoundBox =
819 const_cast<SwXCell*>(this)->FindBox(pTable, m_pBox);
820 if (!pFoundBox)
821 {
822 const_cast<SwXCell*>(this)->m_pBox = nullptr;
823 }
824 }
825 return nullptr != m_pBox;
826}
827
829{
830 SolarMutexGuard aGuard;
831 if(!IsValid())
832 return OUString();
835 aFormula.PtrToBoxNm( pTable );
836 return aFormula.GetFormula();
837}
838
840void SwXCell::setFormula(const OUString& rFormula)
841{
842 SolarMutexGuard aGuard;
843 if(!IsValid())
844 return;
845 // first this text (maybe) needs to be deleted
847 if(SwNodeOffset(USHRT_MAX) == nNdPos)
848 sw_setString( *this, OUString(), true );
849 OUString sFormula(comphelper::string::stripStart(rFormula, ' '));
850 if( !sFormula.isEmpty() && '=' == sFormula[0] )
851 sFormula = sFormula.copy( 1 );
852 SwTableBoxFormula aFormula( sFormula );
853 SwDoc* pMyDoc = GetDoc();
854 UnoActionContext aAction(pMyDoc);
856 SwFrameFormat* pBoxFormat = m_pBox->GetFrameFormat();
857 const SwTableBoxNumFormat* pNumFormat =
859 if(!pNumFormat
860 || pMyDoc->GetNumberFormatter()->IsTextFormat(pNumFormat->GetValue()))
861 {
862 aSet.Put(SwTableBoxNumFormat(0));
863 }
864 aSet.Put(aFormula);
866 // update table
868 pMyDoc->getIDocumentFieldsAccess().UpdateTableFields( &aTableUpdate );
869}
870
872{
873 SolarMutexGuard aGuard;
874 // #i112652# a table cell may contain NaN as a value, do not filter that
875 if(IsValid() && !getString().isEmpty())
877 return std::numeric_limits<double>::quiet_NaN();
878}
879
880void SwXCell::setValue(double rValue)
881{
882 SolarMutexGuard aGuard;
883 sw_setValue( *this, rValue );
884}
885
886table::CellContentType SwXCell::getType()
887{
888 SolarMutexGuard aGuard;
889
890 table::CellContentType nRes = table::CellContentType_EMPTY;
891 sal_uInt32 nNdPos = m_pBox->IsFormulaOrValueBox();
892 switch (nNdPos)
893 {
894 case 0 : nRes = table::CellContentType_TEXT; break;
895 case USHRT_MAX : nRes = table::CellContentType_EMPTY; break;
896 case RES_BOXATR_VALUE : nRes = table::CellContentType_VALUE; break;
897 case RES_BOXATR_FORMULA : nRes = table::CellContentType_FORMULA; break;
898 default :
899 OSL_FAIL( "unexpected case" );
900 }
901 return nRes;
902}
903
904void SwXCell::setString(const OUString& aString)
905{
906 SolarMutexGuard aGuard;
907 sw_setString( *this, aString );
908}
909
911{
912 SolarMutexGuard aGuard;
913 OUString sContent = getString();
914 return sal_Int32(sContent == SwViewShell::GetShellRes()->aCalc_Error);
915}
916
917uno::Reference<text::XTextCursor> SwXCell::createTextCursor()
918{
919 SolarMutexGuard aGuard;
920 if(!m_pStartNode && !IsValid())
921 throw uno::RuntimeException();
922 const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
923 SwPosition aPos(*pSttNd);
924 rtl::Reference<SwXTextCursor> const pXCursor =
925 new SwXTextCursor(*GetDoc(), this, CursorType::TableText, aPos);
926 auto& rUnoCursor(pXCursor->GetCursor());
927 rUnoCursor.Move(fnMoveForward, GoInNode);
928 return static_cast<text::XWordCursor*>(pXCursor.get());
929}
930
931uno::Reference<text::XTextCursor> SwXCell::createTextCursorByRange(const uno::Reference< text::XTextRange > & xTextPosition)
932{
933 SolarMutexGuard aGuard;
934 SwUnoInternalPaM aPam(*GetDoc());
935 if((!m_pStartNode && !IsValid()) || !::sw::XTextRangeToSwPaM(aPam, xTextPosition))
936 throw uno::RuntimeException();
937 const SwStartNode* pSttNd = m_pStartNode ? m_pStartNode : m_pBox->GetSttNd();
938 // skip sections
940 while(p1->IsSectionNode())
941 p1 = p1->StartOfSectionNode();
942 if( p1 != pSttNd )
943 return nullptr;
944 return static_cast<text::XWordCursor*>(
946 *aPam.GetPoint(), aPam.GetMark()));
947}
948
949uno::Reference< beans::XPropertySetInfo > SwXCell::getPropertySetInfo()
950{
951 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
952 return xRef;
953}
954
955void SwXCell::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
956{
957 SolarMutexGuard aGuard;
958 if(!IsValid())
959 return;
960 // Hack to support hidden property to transfer textDirection
961 if(rPropertyName == "FRMDirection")
962 {
963 SvxFrameDirectionItem aItem(SvxFrameDirection::Environment, RES_FRAMEDIR);
964 aItem.PutValue(aValue, 0);
966 }
967 else if(rPropertyName == "TableRedlineParams")
968 {
969 // Get the table row properties
970 uno::Sequence<beans::PropertyValue> tableCellProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
971 comphelper::SequenceAsHashMap aPropMap(tableCellProperties);
972 OUString sRedlineType;
973 if(!(aPropMap.getValue("RedlineType") >>= sRedlineType))
974 throw beans::UnknownPropertyException("No redline type property: ", static_cast<cppu::OWeakObject*>(this));
975
976 // Create a 'Table Cell Redline' object
977 SwUnoCursorHelper::makeTableCellRedline(*m_pBox, sRedlineType, tableCellProperties);
978
979
980 }
981 else if (rPropertyName == "VerticalMerge")
982 {
983 //Hack to allow clearing of numbering from the paragraphs in the merged cells.
984 SwNodeIndex aIdx(*GetStartNode(), 1);
985 const SwNode* pEndNd = aIdx.GetNode().EndOfSectionNode();
986 while (&aIdx.GetNode() != pEndNd)
987 {
988 SwTextNode* pNd = aIdx.GetNode().GetTextNode();
989 if (pNd)
990 pNd->SetCountedInList(false);
991 ++aIdx;
992 }
993 }
994 else
995 {
996 auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
997 if ( !pEntry )
998 {
999 // not a table property: ignore it, if it is a paragraph/character property
1001 pEntry = rParaPropSet.getPropertyMap().getByName(rPropertyName);
1002
1003 if ( pEntry )
1004 return;
1005 }
1006
1007 if(!pEntry)
1008 throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
1009 if(pEntry->nWID != FN_UNO_CELL_ROW_SPAN)
1010 {
1011 SwFrameFormat* pBoxFormat = m_pBox->ClaimFrameFormat();
1012 SwAttrSet aSet(pBoxFormat->GetAttrSet());
1013 m_pPropSet->setPropertyValue(rPropertyName, aValue, aSet);
1014 pBoxFormat->GetDoc()->SetAttr(aSet, *pBoxFormat);
1015 }
1016 else if(aValue.isExtractableTo(cppu::UnoType<sal_Int32>::get()))
1017 m_pBox->setRowSpan(aValue.get<sal_Int32>());
1018 }
1019}
1020
1021uno::Any SwXCell::getPropertyValue(const OUString& rPropertyName)
1022{
1023 SolarMutexGuard aGuard;
1024 if(!IsValid())
1025 return uno::Any();
1026 auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1027 if(!pEntry)
1028 throw beans::UnknownPropertyException(rPropertyName, static_cast<cppu::OWeakObject*>(this));
1029 switch(pEntry->nWID)
1030 {
1032 return uno::Any(m_pBox->getRowSpan());
1034 {
1035 SwFrameFormat* pTableFormat = GetFrameFormat();
1036 SwTable* pTable = SwTable::FindTable(pTableFormat);
1037 SwTableNode* pTableNode = pTable->GetTableNode();
1038 SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
1039 if(!pSectionNode)
1040 return uno::Any();
1041 SwSection& rSect = pSectionNode->GetSection();
1043 }
1044 break;
1045 case FN_UNO_CELL_NAME:
1046 return uno::Any(m_pBox->GetName());
1049 {
1050 //redline can only be returned if it's a living object
1051 return SwXText::getPropertyValue(rPropertyName);
1052 }
1053 break;
1054 case FN_UNO_PARENT_TEXT:
1055 {
1056 if (!m_xParentText.is())
1057 {
1058 const SwStartNode* pSttNd = m_pBox->GetSttNd();
1059 if (!pSttNd)
1060 return uno::Any();
1061
1062 const SwTableNode* pTableNode = pSttNd->FindTableNode();
1063 if (!pTableNode)
1064 return uno::Any();
1065
1066 SwPosition aPos(*pTableNode);
1067 SwDoc& rDoc = aPos.GetDoc();
1069 }
1070
1071 return uno::Any(m_xParentText);
1072 }
1073 break;
1074 default:
1075 {
1077 uno::Any aResult;
1078 m_pPropSet->getPropertyValue(rPropertyName, rSet, aResult);
1079 return aResult;
1080 }
1081 }
1082}
1083
1084void SwXCell::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1085 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1086
1087void SwXCell::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1088 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1089
1090void SwXCell::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1091 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1092
1093void SwXCell::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1094 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1095
1096uno::Reference<container::XEnumeration> SwXCell::createEnumeration()
1097{
1098 SolarMutexGuard aGuard;
1099 if(!IsValid())
1100 return uno::Reference<container::XEnumeration>();
1101 const SwStartNode* pSttNd = m_pBox->GetSttNd();
1102 SwPosition aPos(*pSttNd);
1103 auto pUnoCursor(GetDoc()->CreateUnoCursor(aPos));
1104 pUnoCursor->Move(fnMoveForward, GoInNode);
1105 // remember table and start node for later travelling
1106 // (used in export of tables in tables)
1108}
1109
1111{
1113}
1114
1116{
1117 return true;
1118}
1119
1120void SwXCell::Notify(const SfxHint& rHint)
1121{
1122 if(rHint.GetId() == SfxHintId::Dying)
1123 {
1124 m_pTableFormat = nullptr;
1125 }
1126 else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableBox, SwXCell>*>(&rHint))
1127 {
1128 if(!pFindHint->m_pResult && pFindHint->m_pCore == GetTableBox())
1129 pFindHint->m_pResult = this;
1130 }
1131}
1132
1134{
1135 if(!pTableFormat || !pBox)
1136 return nullptr;
1137 if(!pTable)
1138 pTable = SwTable::FindTable(pTableFormat);
1140 if(it == pTable->GetTabSortBoxes().end())
1141 return nullptr;
1142 size_t const nPos = it - pTable->GetTabSortBoxes().begin();
1143 FindUnoInstanceHint<SwTableBox, SwXCell> aHint{pBox};
1144 pTableFormat->GetNotifier().Broadcast(aHint);
1145 return aHint.m_pResult ? aHint.m_pResult.get() : new SwXCell(pTableFormat, pBox, nPos);
1146}
1147
1155{
1156 // check if nFndPos happens to point to the right table box
1157 if( m_nFndPos < pTable->GetTabSortBoxes().size() &&
1158 pBox2 == pTable->GetTabSortBoxes()[ m_nFndPos ] )
1159 return pBox2;
1160
1161 // if not, seek the entry (and return, if successful)
1163 if( it != pTable->GetTabSortBoxes().end() )
1164 {
1165 m_nFndPos = it - pTable->GetTabSortBoxes().begin();
1166 return pBox2;
1167 }
1168
1169 // box not found: reset nFndPos pointer
1171 return nullptr;
1172}
1173
1175{
1176 if(table::CellContentType_TEXT != const_cast<SwXCell*>(this)->getType())
1177 return getValue();
1178 // now we'll try to get a useful numerical value
1179 // from the text in the cell...
1180 sal_uInt32 nFIndex;
1181 SvNumberFormatter* pNumFormatter(const_cast<SvNumberFormatter*>(GetDoc()->GetNumberFormatter()));
1182 // look for SwTableBoxNumFormat value in parents as well
1183 auto pBoxFormat(GetTableBox()->GetFrameFormat());
1184 const SwTableBoxNumFormat* pNumFormat = pBoxFormat->GetAttrSet().GetItemIfSet(RES_BOXATR_FORMAT);
1185
1186 if (pNumFormat)
1187 {
1188 // please note that the language of the numberformat
1189 // is implicitly coded into the below value as well
1190 nFIndex = pNumFormat->GetValue();
1191
1192 // since the current value indicates a text format but the call
1193 // to 'IsNumberFormat' below won't work for text formats
1194 // we need to get rid of the part that indicates the text format.
1195 // According to ER this can be done like this:
1196 nFIndex -= (nFIndex % SV_COUNTRY_LANGUAGE_OFFSET);
1197 }
1198 else
1199 {
1200 // system language is probably not the best possible choice
1201 // but since we have to guess anyway (because the language of at
1202 // the text is NOT the one used for the number format!)
1203 // it is at least conform to what is used in
1204 // SwTableShell::Execute when
1205 // SID_ATTR_NUMBERFORMAT_VALUE is set...
1207 nFIndex = pNumFormatter->GetStandardIndex( eLang );
1208 }
1209 double fTmp;
1210 if (!const_cast<SwDoc*>(GetDoc())->IsNumberFormat(const_cast<SwXCell*>(this)->getString(), nFIndex, fTmp))
1211 return std::numeric_limits<double>::quiet_NaN();
1212 return fTmp;
1213}
1214
1216{
1217 if(!m_pBox)
1218 throw uno::RuntimeException();
1219 // check if table box value item is set
1220 auto pBoxFormat(m_pBox->GetFrameFormat());
1221 const bool bIsNum = pBoxFormat->GetItemState(RES_BOXATR_VALUE, false) == SfxItemState::SET;
1222 return bIsNum ? uno::Any(getValue()) : uno::Any(const_cast<SwXCell*>(this)->getString());
1223}
1224
1226 { return "SwXCell"; }
1227
1228sal_Bool SwXCell::supportsService(const OUString& rServiceName)
1229 { return cppu::supportsService(this, rServiceName); }
1230
1231uno::Sequence< OUString > SwXCell::getSupportedServiceNames()
1232 { return {"com.sun.star.text.CellProperties"}; }
1233
1235 { return "SwXTextTableRow"; }
1236
1237sal_Bool SwXTextTableRow::supportsService(const OUString& rServiceName)
1238 { return cppu::supportsService(this, rServiceName); }
1239
1241 { return {"com.sun.star.text.TextTableRow"}; }
1242
1243
1245 m_pFormat(pFormat),
1246 m_pLine(pLn),
1247 m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_ROW))
1248{
1250}
1251
1253{
1254 SolarMutexGuard aGuard;
1256}
1257
1258uno::Reference< beans::XPropertySetInfo > SwXTextTableRow::getPropertySetInfo()
1259{
1260 static uno::Reference<beans::XPropertySetInfo> xRef = m_pPropSet->getPropertySetInfo();
1261 return xRef;
1262}
1263
1264void SwXTextTableRow::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1265{
1266 SolarMutexGuard aGuard;
1267 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1268 SwTable* pTable = SwTable::FindTable( pFormat );
1270 if(!pLn)
1271 return;
1272
1273 // Check for a specific property
1274 if ( rPropertyName == "TableRedlineParams" )
1275 {
1276 // Get the table row properties
1277 uno::Sequence< beans::PropertyValue > tableRowProperties = aValue.get< uno::Sequence< beans::PropertyValue > >();
1278 comphelper::SequenceAsHashMap aPropMap( tableRowProperties );
1279 OUString sRedlineType;
1280 if( !(aPropMap.getValue("RedlineType") >>= sRedlineType) )
1281 {
1282 throw beans::UnknownPropertyException("No redline type property: ", static_cast < cppu::OWeakObject * > ( this ) );
1283 }
1284
1285 // Create a 'Table Row Redline' object
1286 SwUnoCursorHelper::makeTableRowRedline( *pLn, sRedlineType, tableRowProperties);
1287
1288 }
1289 else
1290 {
1291 const SfxItemPropertyMapEntry* pEntry =
1292 m_pPropSet->getPropertyMap().getByName(rPropertyName);
1293 SwDoc* pDoc = pFormat->GetDoc();
1294 if (!pEntry)
1295 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1296 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
1297 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1298
1299 switch(pEntry->nWID)
1300 {
1301 case FN_UNO_ROW_HEIGHT:
1303 {
1304 SwFormatFrameSize aFrameSize(pLn->GetFrameFormat()->GetFrameSize());
1305 if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1306 {
1307 bool bSet = *o3tl::doAccess<bool>(aValue);
1309 }
1310 else
1311 {
1312 sal_Int32 nHeight = 0;
1313 aValue >>= nHeight;
1314 Size aSz(aFrameSize.GetSize());
1316 aFrameSize.SetSize(aSz);
1317 }
1318 pDoc->SetAttr(aFrameSize, *pLn->ClaimFrameFormat());
1319 }
1320 break;
1321
1323 {
1324 UnoActionContext aContext(pDoc);
1325 SwTable* pTable2 = SwTable::FindTable( pFormat );
1326 lcl_SetTableSeparators(aValue, pTable2, m_pLine->GetTabBoxes()[0], true, pDoc);
1327 }
1328 break;
1329
1330 default:
1331 {
1332 SwFrameFormat* pLnFormat = pLn->ClaimFrameFormat();
1333 SwAttrSet aSet(pLnFormat->GetAttrSet());
1334 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
1335 pDoc->SetAttr(aSet, *pLnFormat);
1336 }
1337 }
1338 }
1339}
1340
1341uno::Any SwXTextTableRow::getPropertyValue(const OUString& rPropertyName)
1342{
1343 SolarMutexGuard aGuard;
1344 uno::Any aRet;
1345 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
1346 SwTable* pTable = SwTable::FindTable( pFormat );
1348 if(pLn)
1349 {
1350 const SfxItemPropertyMapEntry* pEntry =
1351 m_pPropSet->getPropertyMap().getByName(rPropertyName);
1352 if (!pEntry)
1353 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
1354
1355 switch(pEntry->nWID)
1356 {
1357 case FN_UNO_ROW_HEIGHT:
1359 {
1360 const SwFormatFrameSize& rSize = pLn->GetFrameFormat()->GetFrameSize();
1361 if(FN_UNO_ROW_AUTO_HEIGHT== pEntry->nWID)
1362 {
1363 aRet <<= SwFrameSize::Variable == rSize.GetHeightSizeType();
1364 }
1365 else
1366 aRet <<= static_cast<sal_Int32>(convertTwipToMm100(rSize.GetSize().Height()));
1367 }
1368 break;
1369
1371 {
1372 lcl_GetTableSeparators(aRet, pTable, m_pLine->GetTabBoxes()[0], true);
1373 }
1374 break;
1375
1376 default:
1377 {
1378 const SwAttrSet& rSet = pLn->GetFrameFormat()->GetAttrSet();
1379 m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
1380 }
1381 }
1382 }
1383 return aRet;
1384}
1385
1386void SwXTextTableRow::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1387 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1388
1389void SwXTextTableRow::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1390 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1391
1392void SwXTextTableRow::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1393 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1394
1395void SwXTextTableRow::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1396 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1397
1399{
1400 if(rHint.GetId() == SfxHintId::Dying)
1401 {
1402 m_pFormat = nullptr;
1403 } else if(auto pFindHint = dynamic_cast<const FindUnoInstanceHint<SwTableLine, SwXTextTableRow>*>(&rHint))
1404 {
1405 if(!pFindHint->m_pCore && pFindHint->m_pCore == m_pLine)
1406 pFindHint->m_pResult = this;
1407 }
1408}
1409
1411{
1412 for(const auto& pCurrentLine : pTable->GetTabLines())
1413 if(pCurrentLine == pLine)
1414 return pCurrentLine;
1415 return nullptr;
1416}
1417
1418// SwXTextTableCursor
1419
1421 { return "SwXTextTableCursor"; }
1422
1424 { return cppu::supportsService(this, rServiceName); }
1425
1426void SwXTextTableCursor::acquire() noexcept
1427{
1428 SwXTextTableCursor_Base::acquire();
1429}
1430
1431void SwXTextTableCursor::release() noexcept
1432{
1433 SolarMutexGuard aGuard;
1434 SwXTextTableCursor_Base::release();
1435}
1436
1437css::uno::Any SAL_CALL
1438SwXTextTableCursor::queryInterface( const css::uno::Type& _rType )
1439{
1440 css::uno::Any aReturn = SwXTextTableCursor_Base::queryInterface( _rType );
1441 if ( !aReturn.hasValue() )
1442 aReturn = OTextCursorHelper::queryInterface( _rType );
1443 return aReturn;
1444}
1445
1446const SwPaM* SwXTextTableCursor::GetPaM() const { return &GetCursor(); }
1452
1454 { return {"com.sun.star.text.TextTableCursor"}; }
1455
1457 : m_pFrameFormat(pFrameFormat)
1458 , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1459{
1461 SwDoc* pDoc = m_pFrameFormat->GetDoc();
1462 const SwStartNode* pSttNd = pBox->GetSttNd();
1463 SwPosition aPos(*pSttNd);
1464 m_pUnoCursor = pDoc->CreateUnoCursor(aPos, true);
1466 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1467 rTableCursor.MakeBoxSels();
1468}
1469
1471 : m_pFrameFormat(&rTableFormat)
1472 , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_TABLE_CURSOR))
1473{
1475 m_pUnoCursor = pTableSelection->GetDoc().CreateUnoCursor(*pTableSelection->GetPoint(), true);
1476 if(pTableSelection->HasMark())
1477 {
1479 *m_pUnoCursor->GetMark() = *pTableSelection->GetMark();
1480 }
1481 const SwSelBoxes& rBoxes = pTableSelection->GetSelectedBoxes();
1482 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pUnoCursor);
1483 for(auto pBox : rBoxes)
1484 rTableCursor.InsertBox(*pBox);
1485 rTableCursor.MakeBoxSels();
1486}
1487
1489{
1490 SolarMutexGuard aGuard;
1491 SwUnoCursor& rUnoCursor = GetCursor();
1492 SwUnoTableCursor* pTableCursor = dynamic_cast<SwUnoTableCursor*>(&rUnoCursor);
1494 if(!pTableCursor)
1495 return OUString();
1496 pTableCursor->MakeBoxSels();
1497 const SwStartNode* pNode = pTableCursor->GetPoint()->GetNode().FindTableBoxStartNode();
1498 const SwTable* pTable = SwTable::FindTable(GetFrameFormat());
1499 const SwTableBox* pEndBox = pTable->GetTableBox(pNode->GetIndex());
1500 if(pTableCursor->HasMark())
1501 {
1502 pNode = pTableCursor->GetMark()->GetNode().FindTableBoxStartNode();
1503 const SwTableBox* pStartBox = pTable->GetTableBox(pNode->GetIndex());
1504 if(pEndBox != pStartBox)
1505 {
1506 // need to switch start and end?
1507 if(*pTableCursor->GetPoint() < *pTableCursor->GetMark())
1508 std::swap(pStartBox, pEndBox);
1509 return pStartBox->GetName() + ":" + pEndBox->GetName();
1510 }
1511 }
1512 return pEndBox->GetName();
1513}
1514
1515sal_Bool SwXTextTableCursor::gotoCellByName(const OUString& sCellName, sal_Bool bExpand)
1516{
1517 SolarMutexGuard aGuard;
1518 SwUnoCursor& rUnoCursor = GetCursor();
1519 auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1520 lcl_CursorSelect(rTableCursor, bExpand);
1521 return rTableCursor.GotoTableBox(sCellName);
1522}
1523
1525{
1526 SolarMutexGuard aGuard;
1527 SwUnoCursor& rUnoCursor = GetCursor();
1528 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1529 lcl_CursorSelect(rTableCursor, bExpand);
1530 return rTableCursor.Left(Count);
1531}
1532
1534{
1535 SolarMutexGuard aGuard;
1536 SwUnoCursor& rUnoCursor = GetCursor();
1537 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1538 lcl_CursorSelect(rTableCursor, bExpand);
1539 return rTableCursor.Right(Count);
1540}
1541
1543{
1544 SolarMutexGuard aGuard;
1545 SwUnoCursor& rUnoCursor = GetCursor();
1546 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1547 lcl_CursorSelect(rTableCursor, bExpand);
1548 return rTableCursor.UpDown(true, Count, nullptr, 0,
1550}
1551
1553{
1554 SolarMutexGuard aGuard;
1555 SwUnoCursor& rUnoCursor = GetCursor();
1556 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1557 lcl_CursorSelect(rTableCursor, bExpand);
1558 return rTableCursor.UpDown(false, Count, nullptr, 0,
1560}
1561
1563{
1564 SolarMutexGuard aGuard;
1565 SwUnoCursor& rUnoCursor = GetCursor();
1566 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1567 lcl_CursorSelect(rTableCursor, bExpand);
1568 rTableCursor.MoveTable(GotoCurrTable, fnTableStart);
1569}
1570
1572{
1573 SolarMutexGuard aGuard;
1574 SwUnoCursor& rUnoCursor = GetCursor();
1575 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1576 lcl_CursorSelect(rTableCursor, bExpand);
1577 rTableCursor.MoveTable(GotoCurrTable, fnTableEnd);
1578}
1579
1581{
1582 SolarMutexGuard aGuard;
1583 SwUnoCursor& rUnoCursor = GetCursor();
1584
1585 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1586 {
1587 // HACK: remove pending actions for selecting old style tables
1588 UnoActionRemoveContext aRemoveContext(rTableCursor);
1589 }
1590 rTableCursor.MakeBoxSels();
1591 bool bResult;
1592 {
1593 UnoActionContext aContext(&rUnoCursor.GetDoc());
1594 bResult = TableMergeErr::Ok == rTableCursor.GetDoc().MergeTable(rTableCursor);
1595 }
1596 if(bResult)
1597 {
1598 size_t nCount = rTableCursor.GetSelectedBoxesCount();
1599 while (nCount--)
1600 rTableCursor.DeleteBox(nCount);
1601 }
1602 rTableCursor.MakeBoxSels();
1603 return bResult;
1604}
1605
1607{
1608 SolarMutexGuard aGuard;
1609 if (Count <= 0)
1610 throw uno::RuntimeException("Illegal first argument: needs to be > 0", static_cast<cppu::OWeakObject*>(this));
1611 SwUnoCursor& rUnoCursor = GetCursor();
1612 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1613 {
1614 // HACK: remove pending actions for selecting old style tables
1615 UnoActionRemoveContext aRemoveContext(rTableCursor);
1616 }
1617 rTableCursor.MakeBoxSels();
1618 bool bResult;
1619 {
1620 UnoActionContext aContext(&rUnoCursor.GetDoc());
1621 bResult = rTableCursor.GetDoc().SplitTable(rTableCursor.GetSelectedBoxes(), !Horizontal, Count);
1622 }
1623 rTableCursor.MakeBoxSels();
1624 return bResult;
1625}
1626
1627uno::Reference< beans::XPropertySetInfo > SwXTextTableCursor::getPropertySetInfo()
1628{
1629 static uno::Reference< beans::XPropertySetInfo > xRef = m_pPropSet->getPropertySetInfo();
1630 return xRef;
1631}
1632
1633void SwXTextTableCursor::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
1634{
1635 SolarMutexGuard aGuard;
1636 SwUnoCursor& rUnoCursor = GetCursor();
1637 auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1638 if(!pEntry)
1639 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1640 if(pEntry->nFlags & beans::PropertyAttribute::READONLY)
1641 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1642 {
1643 auto pSttNode = rUnoCursor.GetPointNode().StartOfSectionNode();
1644 const SwTableNode* pTableNode = pSttNode->FindTableNode();
1645 lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1646 }
1647 auto& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1648 rTableCursor.MakeBoxSels();
1649 SwDoc& rDoc = rUnoCursor.GetDoc();
1650 switch(pEntry->nWID)
1651 {
1653 {
1654 std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1655 SwDoc::GetBoxAttr(rUnoCursor, aBrush);
1656 aBrush->PutValue(aValue, pEntry->nMemberId);
1657 rDoc.SetBoxAttr(rUnoCursor, *aBrush);
1658
1659 }
1660 break;
1661 case RES_BOXATR_FORMAT:
1662 {
1663 SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
1664 aNumberFormat.PutValue(aValue, 0);
1665 rDoc.SetBoxAttr(rUnoCursor, aNumberFormat);
1666 }
1667 break;
1668 case FN_UNO_PARA_STYLE:
1669 SwUnoCursorHelper::SetTextFormatColl(aValue, rUnoCursor);
1670 break;
1671 default:
1672 {
1673 SfxItemSet aItemSet(rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID);
1674 SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(),
1675 aItemSet);
1676
1678 *pEntry, aValue, rTableCursor.GetSelRing(), aItemSet))
1679 {
1680 m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
1681 }
1682 SwUnoCursorHelper::SetCursorAttr(rTableCursor.GetSelRing(),
1683 aItemSet, SetAttrMode::DEFAULT, true);
1684 }
1685 }
1686}
1687
1689{
1690 SolarMutexGuard aGuard;
1691 SwUnoCursor& rUnoCursor = GetCursor();
1692 {
1693 auto pSttNode = rUnoCursor.GetPointNode().StartOfSectionNode();
1694 const SwTableNode* pTableNode = pSttNode->FindTableNode();
1695 lcl_FormatTable(pTableNode->GetTable().GetFrameFormat());
1696 }
1697 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(rUnoCursor);
1698 auto pEntry(m_pPropSet->getPropertyMap().getByName(rPropertyName));
1699 if(!pEntry)
1700 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1701 rTableCursor.MakeBoxSels();
1702 uno::Any aResult;
1703 switch(pEntry->nWID)
1704 {
1706 {
1707 std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
1708 if (SwDoc::GetBoxAttr(rUnoCursor, aBrush))
1709 aBrush->QueryValue(aResult, pEntry->nMemberId);
1710 }
1711 break;
1712 case RES_BOXATR_FORMAT:
1713 // TODO: GetAttr for table selections in a Doc is missing
1714 throw uno::RuntimeException("Unknown property: " + rPropertyName, static_cast<cppu::OWeakObject*>(this));
1715 break;
1716 case FN_UNO_PARA_STYLE:
1717 {
1718 auto pFormat(SwUnoCursorHelper::GetCurTextFormatColl(rUnoCursor, false));
1719 if(pFormat)
1720 aResult <<= pFormat->GetName();
1721 }
1722 break;
1723 default:
1724 {
1728 aSet(rTableCursor.GetDoc().GetAttrPool());
1729 SwUnoCursorHelper::GetCursorAttr(rTableCursor.GetSelRing(), aSet);
1730 m_pPropSet->getPropertyValue(*pEntry, aSet, aResult);
1731 }
1732 }
1733 return aResult;
1734}
1735
1736void SwXTextTableCursor::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1737 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1738
1739void SwXTextTableCursor::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
1740 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1741
1742void SwXTextTableCursor::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1743 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1744
1745void SwXTextTableCursor::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
1746 { throw uno::RuntimeException("not implemented", static_cast<cppu::OWeakObject*>(this)); };
1747
1749{
1750 if(rHint.GetId() == SfxHintId::Dying)
1751 m_pFrameFormat = nullptr;
1752}
1753
1754
1755// SwXTextTable ===========================================================
1756
1757namespace {
1758
1759class SwTableProperties_Impl
1760{
1762
1763public:
1764 SwTableProperties_Impl();
1765
1766 void SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& aVal);
1767 bool GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny);
1768 void AddItemToSet(SfxItemSet& rSet, std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1769 sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips = false);
1770 void ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc);
1771};
1772
1773}
1774
1775SwTableProperties_Impl::SwTableProperties_Impl()
1776 { }
1777
1778void SwTableProperties_Impl::SetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any& rVal)
1779 {
1780 m_aAnyMap.SetValue(nWhichId, nMemberId, rVal);
1781 }
1782
1783bool SwTableProperties_Impl::GetProperty(sal_uInt16 nWhichId, sal_uInt16 nMemberId, const uno::Any*& rpAny )
1784 {
1785 return m_aAnyMap.FillValue(nWhichId, nMemberId, rpAny);
1786 }
1787
1788void SwTableProperties_Impl::AddItemToSet(SfxItemSet& rSet,
1789 std::function<std::unique_ptr<SfxPoolItem>()> aItemFactory,
1790 sal_uInt16 nWhich, std::initializer_list<sal_uInt16> vMember, bool bAddTwips)
1791{
1792 std::vector< std::pair<sal_uInt16, const uno::Any* > > vMemberAndAny;
1793 for(sal_uInt16 nMember : vMember)
1794 {
1795 const uno::Any* pAny = nullptr;
1796 GetProperty(nWhich, nMember, pAny);
1797 if(pAny)
1798 vMemberAndAny.emplace_back(nMember, pAny);
1799 }
1800 if(!vMemberAndAny.empty())
1801 {
1802 std::unique_ptr<SfxPoolItem> aItem(aItemFactory());
1803 for(const auto& aMemberAndAny : vMemberAndAny)
1804 aItem->PutValue(*aMemberAndAny.second, aMemberAndAny.first | (bAddTwips ? CONVERT_TWIPS : 0) );
1805 rSet.Put(std::move(aItem));
1806 }
1807}
1808void SwTableProperties_Impl::ApplyTableAttr(const SwTable& rTable, SwDoc& rDoc)
1809{
1817 aSet(rDoc.GetAttrPool());
1818 const uno::Any* pRepHead;
1819 const SwFrameFormat &rFrameFormat = *rTable.GetFrameFormat();
1820 if(GetProperty(FN_TABLE_HEADLINE_REPEAT, 0xff, pRepHead ))
1821 {
1822 bool bVal(pRepHead->get<bool>());
1823 const_cast<SwTable&>(rTable).SetRowsToRepeat( bVal ? 1 : 0 ); // TODO: MULTIHEADER
1824 }
1825
1826 AddItemToSet(aSet, [&rFrameFormat]() { return rFrameFormat.makeBackgroundBrushItem(); }, RES_BACKGROUND, {
1832
1833 bool bPutBreak = true;
1834 const uno::Any* pPage;
1835 if(GetProperty(FN_UNO_PAGE_STYLE, 0, pPage) || GetProperty(RES_PAGEDESC, 0xff, pPage))
1836 {
1837 OUString sPageStyle = pPage->get<OUString>();
1838 if(!sPageStyle.isEmpty())
1839 {
1841 const SwPageDesc* pDesc = SwPageDesc::GetByName(rDoc, sPageStyle);
1842 if(pDesc)
1843 {
1844 SwFormatPageDesc aDesc(pDesc);
1845 const uno::Any* pPgNo;
1847 {
1848 aDesc.SetNumOffset(pPgNo->get<sal_Int16>());
1849 }
1850 aSet.Put(aDesc);
1851 bPutBreak = false;
1852 }
1853
1854 }
1855 }
1856
1857 if(bPutBreak)
1858 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetBreak().Clone()); }, RES_BREAK, {0});
1859 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetShadow().Clone()); }, RES_SHADOW, {0}, true);
1860 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetKeep().Clone()); }, RES_KEEP, {0});
1861 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetHoriOrient().Clone()); }, RES_HORI_ORIENT, {MID_HORIORIENT_ORIENT}, true);
1862
1863 const uno::Any* pSzRel(nullptr);
1865 const uno::Any* pRelWidth(nullptr);
1866 GetProperty(FN_TABLE_RELATIVE_WIDTH, 0xff, pRelWidth);
1867 const uno::Any* pWidth(nullptr);
1868 GetProperty(FN_TABLE_WIDTH, 0xff, pWidth);
1869
1870 bool bPutSize = pWidth != nullptr;
1872 if(pWidth)
1873 {
1874 aSz.PutValue(*pWidth, MID_FRMSIZE_WIDTH);
1875 bPutSize = true;
1876 }
1877 if(pSzRel && pSzRel->get<bool>() && pRelWidth)
1878 {
1879 aSz.PutValue(*pRelWidth, MID_FRMSIZE_REL_WIDTH|CONVERT_TWIPS);
1880 bPutSize = true;
1881 }
1882 if(bPutSize)
1883 {
1884 if(!aSz.GetWidth())
1885 aSz.SetWidth(MINLAY);
1886 aSet.Put(aSz);
1887 }
1888 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetLRSpace().Clone()); }, RES_LR_SPACE, {
1891 AddItemToSet(aSet, [&rFrameFormat]() { return std::unique_ptr<SfxPoolItem>(rFrameFormat.GetULSpace().Clone()); }, RES_UL_SPACE, {
1894 const::uno::Any* pSplit(nullptr);
1895 if(GetProperty(RES_LAYOUT_SPLIT, 0, pSplit))
1896 {
1897 SwFormatLayoutSplit aSp(pSplit->get<bool>());
1898 aSet.Put(aSp);
1899 }
1900 if(aSet.Count())
1901 {
1902 rDoc.SetAttr(aSet, *rTable.GetFrameFormat());
1903 }
1904}
1905
1907 : public SvtListener
1908{
1909private:
1911
1912public:
1914 std::mutex m_Mutex; // just for OInterfaceContainerHelper4
1917
1919
1920 css::uno::WeakReference<css::table::XTableRows> m_xRows;
1921 css::uno::WeakReference<css::table::XTableColumns> m_xColumns;
1922
1925
1926 // Descriptor-interface
1927 std::unique_ptr<SwTableProperties_Impl> m_pTableProps;
1929 unsigned short m_nRows;
1930 unsigned short m_nColumns;
1931
1932 explicit Impl(SwFrameFormat* const pFrameFormat)
1933 : m_pFrameFormat(pFrameFormat)
1935 , m_bFirstRowAsLabel(false)
1936 , m_bFirstColumnAsLabel(false)
1937 , m_pTableProps(pFrameFormat ? nullptr : new SwTableProperties_Impl)
1938 , m_nRows(pFrameFormat ? 0 : 2)
1939 , m_nColumns(pFrameFormat ? 0 : 2)
1940 {
1941 if(m_pFrameFormat)
1943 }
1944
1946 void SetFrameFormat(SwFrameFormat& rFrameFormat)
1947 {
1949 m_pFrameFormat = &rFrameFormat;
1951 }
1952
1953 bool IsDescriptor() const { return m_pTableProps != nullptr; }
1954
1955 // note: lock mutex before calling this to avoid concurrent update
1956 static std::pair<sal_uInt16, sal_uInt16> ThrowIfComplex(SwXTextTable &rThis)
1957 {
1958 sal_uInt16 const nRowCount(rThis.m_pImpl->GetRowCount());
1959 sal_uInt16 const nColCount(rThis.m_pImpl->GetColumnCount());
1960 if (!nRowCount || !nColCount)
1961 {
1962 throw uno::RuntimeException("Table too complex",
1963 static_cast<cppu::OWeakObject*>(&rThis));
1964 }
1965 return std::make_pair(nRowCount, nColCount);
1966 }
1967
1968 sal_uInt16 GetRowCount();
1969 sal_uInt16 GetColumnCount();
1970
1971 virtual void Notify(const SfxHint&) override;
1972
1973};
1974
1975const uno::Sequence< sal_Int8 > & SwXTextTable::getUnoTunnelId()
1976{
1977 static const comphelper::UnoIdInit theSwXTextTableUnoTunnelId;
1978 return theSwXTextTableUnoTunnelId.getSeq();
1979}
1980
1981sal_Int64 SAL_CALL SwXTextTable::getSomething( const uno::Sequence< sal_Int8 >& rId )
1982{
1983 return comphelper::getSomethingImpl(rId, this);
1984}
1985
1986
1988 : m_pImpl(new Impl(nullptr))
1989{
1990}
1991
1993 : m_pImpl(new Impl(&rFrameFormat))
1994{
1995}
1996
1998{
1999}
2000
2002{
2004 if(pFrameFormat)
2005 xTable = dynamic_cast<SwXTextTable*>(pFrameFormat->GetXObject().get().get()); // cached?
2006 if(xTable.is())
2007 return xTable;
2008 xTable = pFrameFormat ? new SwXTextTable(*pFrameFormat) : new SwXTextTable();
2009 if(pFrameFormat)
2010 pFrameFormat->SetXObject(static_cast<cppu::OWeakObject*>(xTable.get()));
2011 // need a permanent Reference to initialize m_wThis
2012 xTable->m_pImpl->m_wThis = xTable.get();
2013 return xTable;
2014}
2015
2017{
2018 return m_pImpl->GetFrameFormat();
2019}
2020
2021void SwXTextTable::initialize(sal_Int32 nR, sal_Int32 nC)
2022{
2023 if (!m_pImpl->IsDescriptor() || nR <= 0 || nC <= 0 || nR >= SAL_MAX_UINT16 || nC >= SAL_MAX_UINT16)
2024 throw uno::RuntimeException();
2025 m_pImpl->m_nRows = o3tl::narrowing<sal_uInt16>(nR);
2026 m_pImpl->m_nColumns = o3tl::narrowing<sal_uInt16>(nC);
2027}
2028
2029uno::Reference<table::XTableRows> SAL_CALL SwXTextTable::getRows()
2030{
2031 SolarMutexGuard aGuard;
2032 uno::Reference<table::XTableRows> xResult(m_pImpl->m_xRows);
2033 if(xResult.is())
2034 return xResult;
2035 if(SwFrameFormat* pFormat = GetFrameFormat())
2036 m_pImpl->m_xRows = xResult = new SwXTableRows(*pFormat);
2037 if(!xResult.is())
2038 throw uno::RuntimeException();
2039 return xResult;
2040}
2041
2042uno::Reference<table::XTableColumns> SAL_CALL SwXTextTable::getColumns()
2043{
2044 SolarMutexGuard aGuard;
2045 uno::Reference<table::XTableColumns> xResult(m_pImpl->m_xColumns);
2046 if(xResult.is())
2047 return xResult;
2048 if(SwFrameFormat* pFormat = GetFrameFormat())
2049 m_pImpl->m_xColumns = xResult = new SwXTableColumns(*pFormat);
2050 if(!xResult.is())
2051 throw uno::RuntimeException();
2052 return xResult;
2053}
2054
2055uno::Reference<table::XCell> SwXTextTable::getCellByName(const OUString& sCellName)
2056{
2057 SolarMutexGuard aGuard;
2058 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2059 SwTable* pTable = SwTable::FindTable(pFormat);
2060 SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2061 if(!pBox)
2062 return nullptr;
2063 return SwXCell::CreateXCell(pFormat, pBox);
2064}
2065
2066uno::Sequence<OUString> SwXTextTable::getCellNames()
2067{
2068 SolarMutexGuard aGuard;
2069 SwFrameFormat* pFormat(GetFrameFormat());
2070 if(!pFormat)
2071 return {};
2072 SwTable* pTable = SwTable::FindTable(pFormat);
2073 // exists at the table and at all boxes
2074 SwTableLines& rTableLines = pTable->GetTabLines();
2075 std::vector<OUString> aAllNames;
2076 lcl_InspectLines(rTableLines, aAllNames);
2077 return comphelper::containerToSequence(aAllNames);
2078}
2079
2080uno::Reference<text::XTextTableCursor> SwXTextTable::createCursorByCellName(const OUString& sCellName)
2081{
2082 SolarMutexGuard aGuard;
2083 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2084 SwTable* pTable = SwTable::FindTable(pFormat);
2085 SwTableBox* pBox = const_cast<SwTableBox*>(pTable->GetTableBox(sCellName));
2086 if(!pBox || pBox->getRowSpan() == 0)
2087 throw uno::RuntimeException();
2088 return new SwXTextTableCursor(pFormat, pBox);
2089}
2090
2091void SAL_CALL
2092SwXTextTable::attach(const uno::Reference<text::XTextRange> & xTextRange)
2093{
2094 SolarMutexGuard aGuard;
2095
2096 // attach() must only be called once
2097 if (!m_pImpl->IsDescriptor()) /* already attached ? */
2098 throw uno::RuntimeException("SwXTextTable: already attached to range.", static_cast<cppu::OWeakObject*>(this));
2099
2100 uno::Reference<XUnoTunnel> xRangeTunnel(xTextRange, uno::UNO_QUERY);
2101 SwXTextRange* pRange(comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel));
2102 OTextCursorHelper* pCursor(comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel));
2103 SwDoc* pDoc = pRange ? &pRange->GetDoc() : pCursor ? pCursor->GetDoc() : nullptr;
2104 if (!pDoc || !m_pImpl->m_nRows || !m_pImpl->m_nColumns)
2105 throw lang::IllegalArgumentException();
2106 SwUnoInternalPaM aPam(*pDoc);
2107 // this now needs to return TRUE
2108 ::sw::XTextRangeToSwPaM(aPam, xTextRange);
2109 {
2110 UnoActionContext aCont(pDoc);
2111
2113 const SwTable* pTable(nullptr);
2114 if( 0 != aPam.Start()->GetContentIndex() )
2115 {
2116 pDoc->getIDocumentContentOperations().SplitNode(*aPam.Start(), false);
2117 }
2118 //TODO: if it is the last paragraph than add another one!
2119 if(aPam.HasMark())
2120 {
2122 aPam.DeleteMark();
2123 }
2125 *aPam.GetPoint(),
2126 m_pImpl->m_nRows,
2127 m_pImpl->m_nColumns,
2128 text::HoriOrientation::FULL);
2129 if(pTable)
2130 {
2131 // here, the properties of the descriptor need to be analyzed
2132 m_pImpl->m_pTableProps->ApplyTableAttr(*pTable, *pDoc);
2133 SwFrameFormat* pTableFormat(pTable->GetFrameFormat());
2134 lcl_FormatTable(pTableFormat);
2135
2136 m_pImpl->SetFrameFormat(*pTableFormat);
2137
2138 if (!m_pImpl->m_sTableName.isEmpty())
2139 {
2140 sal_uInt16 nIndex = 1;
2141 OUString sTmpNameIndex(m_pImpl->m_sTableName);
2142 while(pDoc->FindTableFormatByName(sTmpNameIndex, true) && nIndex < USHRT_MAX)
2143 {
2144 sTmpNameIndex = m_pImpl->m_sTableName + OUString::number(nIndex++);
2145 }
2146 pDoc->SetTableName( *pTableFormat, sTmpNameIndex);
2147 }
2148
2149 const::uno::Any* pName;
2150 if (m_pImpl->m_pTableProps->GetProperty(FN_UNO_TABLE_NAME, 0, pName))
2151 setName(pName->get<OUString>());
2152 m_pImpl->m_pTableProps.reset();
2153 }
2154 pDoc->GetIDocumentUndoRedo().EndUndo( SwUndoId::END, nullptr );
2155 }
2156}
2157
2158uno::Reference<text::XTextRange> SwXTextTable::getAnchor()
2159{
2160 SolarMutexGuard aGuard;
2161 SwTableFormat *const pFormat = static_cast<SwTableFormat*>(
2162 lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
2163 return new SwXTextRange(*pFormat);
2164}
2165
2167{
2168 SolarMutexGuard aGuard;
2169 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2170 SwTable* pTable = SwTable::FindTable(pFormat);
2171 SwSelBoxes aSelBoxes;
2172 for(auto& rBox : pTable->GetTabSortBoxes() )
2173 aSelBoxes.insert(rBox);
2175}
2176
2178 const uno::Reference<lang::XEventListener> & xListener)
2179{
2180 // no need to lock here as m_pImpl is const and container threadsafe
2181 std::unique_lock aGuard(m_pImpl->m_Mutex);
2182 m_pImpl->m_EventListeners.addInterface(aGuard, xListener);
2183}
2184
2186 const uno::Reference< lang::XEventListener > & xListener)
2187{
2188 // no need to lock here as m_pImpl is const and container threadsafe
2189 std::unique_lock aGuard(m_pImpl->m_Mutex);
2190 m_pImpl->m_EventListeners.removeInterface(aGuard, xListener);
2191}
2192
2193uno::Reference<table::XCell> SwXTextTable::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
2194{
2195 SolarMutexGuard aGuard;
2196 SwFrameFormat* pFormat(GetFrameFormat());
2197 // sheet is unimportant
2198 if(nColumn >= 0 && nRow >= 0 && pFormat)
2199 {
2200 auto pXCell = lcl_CreateXCell(pFormat, nColumn, nRow);
2201 if(pXCell)
2202 return pXCell;
2203 }
2204 throw lang::IndexOutOfBoundsException();
2205}
2206
2207namespace {
2208
2209uno::Reference<table::XCellRange> GetRangeByName(
2210 SwFrameFormat* pFormat, SwTable const * pTable,
2211 const OUString& rTLName, const OUString& rBRName,
2212 SwRangeDescriptor const & rDesc)
2213{
2214 const SwTableBox* pTLBox = pTable->GetTableBox(rTLName);
2215 if(!pTLBox)
2216 return nullptr;
2217 const SwStartNode* pSttNd = pTLBox->GetSttNd();
2218 SwPosition aPos(*pSttNd);
2219 // set cursor to the upper-left cell of the range
2220 auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
2221 pUnoCursor->Move(fnMoveForward, GoInNode);
2222 pUnoCursor->SetRemainInSection(false);
2223 const SwTableBox* pBRBox(pTable->GetTableBox(rBRName));
2224 if(!pBRBox)
2225 return nullptr;
2226 pUnoCursor->SetMark();
2227 pUnoCursor->GetPoint()->Assign( *pBRBox->GetSttNd() );
2228 pUnoCursor->Move( fnMoveForward, GoInNode );
2229 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2230 // HACK: remove pending actions for selecting old style tables
2231 UnoActionRemoveContext aRemoveContext(rCursor);
2232 rCursor.MakeBoxSels();
2233 // pUnoCursor will be provided and will not be deleted
2234 return SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, rDesc);
2235}
2236
2237} // namespace
2238
2239uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByPosition(sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
2240{
2241 SolarMutexGuard aGuard;
2242 SwFrameFormat* pFormat(GetFrameFormat());
2243 if(pFormat &&
2244 nLeft <= nRight && nTop <= nBottom &&
2245 nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
2246 {
2247 SwTable* pTable = SwTable::FindTable(pFormat);
2248 if(!pTable->IsTableComplex())
2249 {
2250 SwRangeDescriptor aDesc;
2251 aDesc.nTop = nTop;
2252 aDesc.nBottom = nBottom;
2253 aDesc.nLeft = nLeft;
2254 aDesc.nRight = nRight;
2255 const OUString sTLName = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
2256 const OUString sBRName = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
2257 // please note that according to the 'if' statement at the begin
2258 // sTLName:sBRName already denotes the normalized range string
2259 return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2260 }
2261 }
2262 throw lang::IndexOutOfBoundsException();
2263}
2264
2265uno::Reference<table::XCellRange> SwXTextTable::getCellRangeByName(const OUString& sRange)
2266{
2267 SolarMutexGuard aGuard;
2268 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2269 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2270 sal_Int32 nPos = 0;
2271 const OUString sTLName(sRange.getToken(0, ':', nPos));
2272 const OUString sBRName(sRange.getToken(0, ':', nPos));
2273 if(sTLName.isEmpty() || sBRName.isEmpty())
2274 throw uno::RuntimeException();
2275 SwRangeDescriptor aDesc;
2276 aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
2277 SwXTextTable::GetCellPosition(sTLName, aDesc.nLeft, aDesc.nTop );
2278 SwXTextTable::GetCellPosition(sBRName, aDesc.nRight, aDesc.nBottom );
2279
2280 // we should normalize the range now (e.g. A5:C1 will become A1:C5)
2281 // since (depending on what is done later) it will be troublesome
2282 // elsewhere when the cursor in the implementation does not
2283 // point to the top-left and bottom-right cells
2284 aDesc.Normalize();
2285 return GetRangeByName(pFormat, pTable, sTLName, sBRName, aDesc);
2286}
2287
2288uno::Sequence< uno::Sequence< uno::Any > > SAL_CALL SwXTextTable::getDataArray()
2289{
2290 SolarMutexGuard aGuard;
2291 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2292 uno::Reference<sheet::XCellRangeData> const xAllRange(
2293 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2294 uno::UNO_QUERY_THROW);
2295 return xAllRange->getDataArray();
2296}
2297
2298void SAL_CALL SwXTextTable::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
2299{
2300 SolarMutexGuard aGuard;
2301 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2302 uno::Reference<sheet::XCellRangeData> const xAllRange(
2303 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2304 uno::UNO_QUERY_THROW);
2305 return xAllRange->setDataArray(rArray);
2306}
2307
2308uno::Sequence< uno::Sequence< double > > SwXTextTable::getData()
2309{
2310 SolarMutexGuard aGuard;
2311 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2312 uno::Reference<chart::XChartDataArray> const xAllRange(
2313 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2314 uno::UNO_QUERY_THROW);
2315 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2316 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2317 return xAllRange->getData();
2318}
2319
2320void SwXTextTable::setData(const uno::Sequence< uno::Sequence< double > >& rData)
2321{
2322 SolarMutexGuard aGuard;
2323 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2324 uno::Reference<chart::XChartDataArray> const xAllRange(
2325 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2326 uno::UNO_QUERY_THROW);
2327 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2328 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2329 xAllRange->setData(rData);
2330 // this is rather inconsistent: setData on XTextTable sends events, but e.g. CellRanges do not
2331 std::unique_lock aGuard2(m_pImpl->m_Mutex);
2332 lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2333}
2334
2335uno::Sequence<OUString> SwXTextTable::getRowDescriptions()
2336{
2337 SolarMutexGuard aGuard;
2338 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2339 uno::Reference<chart::XChartDataArray> const xAllRange(
2340 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2341 uno::UNO_QUERY_THROW);
2342 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2343 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2344 return xAllRange->getRowDescriptions();
2345}
2346
2347void SwXTextTable::setRowDescriptions(const uno::Sequence<OUString>& rRowDesc)
2348{
2349 SolarMutexGuard aGuard;
2350 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2351 uno::Reference<chart::XChartDataArray> const xAllRange(
2352 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2353 uno::UNO_QUERY_THROW);
2354 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2355 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2356 xAllRange->setRowDescriptions(rRowDesc);
2357}
2358
2360{
2361 SolarMutexGuard aGuard;
2362 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2363 uno::Reference<chart::XChartDataArray> const xAllRange(
2364 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2365 uno::UNO_QUERY_THROW);
2366 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2367 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2368 return xAllRange->getColumnDescriptions();
2369}
2370
2371void SwXTextTable::setColumnDescriptions(const uno::Sequence<OUString>& rColumnDesc)
2372{
2373 SolarMutexGuard aGuard;
2374 std::pair<sal_uInt16, sal_uInt16> const RowsAndColumns(SwXTextTable::Impl::ThrowIfComplex(*this));
2375 uno::Reference<chart::XChartDataArray> const xAllRange(
2376 getCellRangeByPosition(0, 0, RowsAndColumns.second-1, RowsAndColumns.first-1),
2377 uno::UNO_QUERY_THROW);
2378 static_cast<SwXCellRange*>(xAllRange.get())->SetLabels(
2379 m_pImpl->m_bFirstRowAsLabel, m_pImpl->m_bFirstColumnAsLabel);
2380 return xAllRange->setColumnDescriptions(rColumnDesc);
2381}
2382
2384 const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2385{
2386 // no need to lock here as m_pImpl is const and container threadsafe
2387 std::unique_lock aGuard(m_pImpl->m_Mutex);
2388 m_pImpl->m_ChartListeners.addInterface(aGuard, xListener);
2389}
2390
2392 const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
2393{
2394 // no need to lock here as m_pImpl is const and container threadsafe
2395 std::unique_lock aGuard(m_pImpl->m_Mutex);
2396 m_pImpl->m_ChartListeners.removeInterface(aGuard, xListener);
2397}
2398
2400{
2401 // We use DBL_MIN because starcalc does (which uses it because chart
2402 // wants it that way!)
2403 return ( nNumber == DBL_MIN );
2404}
2405
2407{
2408 // We use DBL_MIN because starcalc does (which uses it because chart
2409 // wants it that way!)
2410 return DBL_MIN;
2411}
2412
2413uno::Sequence< beans::PropertyValue > SwXTextTable::createSortDescriptor()
2414{
2415 SolarMutexGuard aGuard;
2416
2418}
2419
2420void SwXTextTable::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
2421{
2422 SolarMutexGuard aGuard;
2423 SwSortOptions aSortOpt;
2424 SwFrameFormat* pFormat = GetFrameFormat();
2425 if(!(pFormat &&
2426 SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt)))
2427 return;
2428
2429 SwTable* pTable = SwTable::FindTable( pFormat );
2430 SwSelBoxes aBoxes;
2431 const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2432 for (size_t n = 0; n < rTBoxes.size(); ++n)
2433 {
2434 SwTableBox* pBox = rTBoxes[ n ];
2435 aBoxes.insert( pBox );
2436 }
2437 UnoActionContext aContext( pFormat->GetDoc() );
2438 pFormat->GetDoc()->SortTable(aBoxes, aSortOpt);
2439}
2440
2441void SwXTextTable::autoFormat(const OUString& sAutoFormatName)
2442{
2443 SolarMutexGuard aGuard;
2444 SwFrameFormat* pFormat = lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
2445 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFormat), static_cast<cppu::OWeakObject*>(this));
2446 SwTableAutoFormatTable aAutoFormatTable;
2447 aAutoFormatTable.Load();
2448 for (size_t i = aAutoFormatTable.size(); i;)
2449 if( sAutoFormatName == aAutoFormatTable[ --i ].GetName() )
2450 {
2451 SwSelBoxes aBoxes;
2452 const SwTableSortBoxes& rTBoxes = pTable->GetTabSortBoxes();
2453 for (size_t n = 0; n < rTBoxes.size(); ++n)
2454 {
2455 SwTableBox* pBox = rTBoxes[ n ];
2456 aBoxes.insert( pBox );
2457 }
2458 UnoActionContext aContext( pFormat->GetDoc() );
2459 pFormat->GetDoc()->SetTableAutoFormat( aBoxes, aAutoFormatTable[i] );
2460 break;
2461 }
2462}
2463
2464uno::Reference< beans::XPropertySetInfo > SwXTextTable::getPropertySetInfo()
2465{
2466 static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
2467 return xRef;
2468}
2469
2470void SwXTextTable::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
2471{
2472 SolarMutexGuard aGuard;
2473 SwFrameFormat* pFormat = GetFrameFormat();
2474 if(!aValue.hasValue())
2475 throw lang::IllegalArgumentException();
2476 const SfxItemPropertyMapEntry* pEntry =
2477 m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2478 if( !pEntry )
2479 throw lang::IllegalArgumentException();
2480 if(pFormat)
2481 {
2482 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
2483 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2484
2485 if(0xBF == pEntry->nMemberId)
2486 {
2487 lcl_SetSpecialProperty(pFormat, pEntry, aValue);
2488 }
2489 else
2490 {
2491 switch(pEntry->nWID)
2492 {
2493 case FN_UNO_TABLE_NAME :
2494 {
2495 OUString sName;
2496 aValue >>= sName;
2497 setName( sName );
2498 }
2499 break;
2500
2502 {
2503 bool bTmp = *o3tl::doAccess<bool>(aValue);
2504 if (m_pImpl->m_bFirstRowAsLabel != bTmp)
2505 {
2506 std::unique_lock aGuard2(m_pImpl->m_Mutex);
2507 lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2508 m_pImpl->m_bFirstRowAsLabel = bTmp;
2509 }
2510 }
2511 break;
2512
2514 {
2515 bool bTmp = *o3tl::doAccess<bool>(aValue);
2516 if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
2517 {
2518 std::unique_lock aGuard2(m_pImpl->m_Mutex);
2519 lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
2520 m_pImpl->m_bFirstColumnAsLabel = bTmp;
2521 }
2522 }
2523 break;
2524
2527 {
2528 table::TableBorder oldBorder;
2529 table::TableBorder2 aBorder;
2530 SvxBorderLine aTopLine;
2531 SvxBorderLine aBottomLine;
2532 SvxBorderLine aLeftLine;
2533 SvxBorderLine aRightLine;
2534 SvxBorderLine aHoriLine;
2535 SvxBorderLine aVertLine;
2536 if (aValue >>= oldBorder)
2537 {
2538 aBorder.IsTopLineValid = oldBorder.IsTopLineValid;
2539 aBorder.IsBottomLineValid = oldBorder.IsBottomLineValid;
2540 aBorder.IsLeftLineValid = oldBorder.IsLeftLineValid;
2541 aBorder.IsRightLineValid = oldBorder.IsRightLineValid;
2542 aBorder.IsHorizontalLineValid = oldBorder.IsHorizontalLineValid;
2543 aBorder.IsVerticalLineValid = oldBorder.IsVerticalLineValid;
2544 aBorder.Distance = oldBorder.Distance;
2545 aBorder.IsDistanceValid = oldBorder.IsDistanceValid;
2547 oldBorder.TopLine, aTopLine);
2549 oldBorder.BottomLine, aBottomLine);
2551 oldBorder.LeftLine, aLeftLine);
2553 oldBorder.RightLine, aRightLine);
2555 oldBorder.HorizontalLine, aHoriLine);
2557 oldBorder.VerticalLine, aVertLine);
2558 }
2559 else if (aValue >>= aBorder)
2560 {
2562 aBorder.TopLine, aTopLine, true);
2564 aBorder.BottomLine, aBottomLine, true);
2566 aBorder.LeftLine, aLeftLine, true);
2568 aBorder.RightLine, aRightLine, true);
2570 aBorder.HorizontalLine, aHoriLine, true);
2572 aBorder.VerticalLine, aVertLine, true);
2573 }
2574 else
2575 {
2576 break; // something else
2577 }
2578 SwDoc* pDoc = pFormat->GetDoc();
2579 if(!lcl_FormatTable(pFormat))
2580 break;
2581 SwTable* pTable = SwTable::FindTable( pFormat );
2582 SwTableLines &rLines = pTable->GetTabLines();
2583
2584 const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2585 const SwStartNode* pSttNd = pTLBox->GetSttNd();
2586 SwPosition aPos(*pSttNd);
2587 // set cursor to top left cell
2588 auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2589 pUnoCursor->Move( fnMoveForward, GoInNode );
2590 pUnoCursor->SetRemainInSection( false );
2591
2592 const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2593 pUnoCursor->SetMark();
2594 pUnoCursor->GetPoint()->Assign( *pBRBox->GetSttNd() );
2595 pUnoCursor->Move( fnMoveForward, GoInNode );
2596 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2597 // HACK: remove pending actions for selecting old style tables
2598 UnoActionRemoveContext aRemoveContext(rCursor);
2599 rCursor.MakeBoxSels();
2600
2602 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
2603 aSet(pDoc->GetAttrPool());
2604
2605 SvxBoxItem aBox( RES_BOX );
2606 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
2607
2608 aBox.SetLine(aTopLine.isEmpty() ? nullptr : &aTopLine, SvxBoxItemLine::TOP);
2609 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::TOP, aBorder.IsTopLineValid);
2610
2611 aBox.SetLine(aBottomLine.isEmpty() ? nullptr : &aBottomLine, SvxBoxItemLine::BOTTOM);
2612 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::BOTTOM, aBorder.IsBottomLineValid);
2613
2614 aBox.SetLine(aLeftLine.isEmpty() ? nullptr : &aLeftLine, SvxBoxItemLine::LEFT);
2615 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::LEFT, aBorder.IsLeftLineValid);
2616
2617 aBox.SetLine(aRightLine.isEmpty() ? nullptr : &aRightLine, SvxBoxItemLine::RIGHT);
2618 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::RIGHT, aBorder.IsRightLineValid);
2619
2620 aBoxInfo.SetLine(aHoriLine.isEmpty() ? nullptr : &aHoriLine, SvxBoxInfoItemLine::HORI);
2621 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::HORI, aBorder.IsHorizontalLineValid);
2622
2623 aBoxInfo.SetLine(aVertLine.isEmpty() ? nullptr : &aVertLine, SvxBoxInfoItemLine::VERT);
2624 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::VERT, aBorder.IsVerticalLineValid);
2625
2626 aBox.SetAllDistances(o3tl::toTwips(aBorder.Distance, o3tl::Length::mm100));
2627 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::DISTANCE, aBorder.IsDistanceValid);
2628
2629 aSet.Put(aBox);
2630 aSet.Put(aBoxInfo);
2631
2632 pDoc->SetTabBorders(rCursor, aSet);
2633 }
2634 break;
2635
2637 {
2638 table::TableBorderDistances aTableBorderDistances;
2639 if( !(aValue >>= aTableBorderDistances) ||
2640 (!aTableBorderDistances.IsLeftDistanceValid &&
2641 !aTableBorderDistances.IsRightDistanceValid &&
2642 !aTableBorderDistances.IsTopDistanceValid &&
2643 !aTableBorderDistances.IsBottomDistanceValid ))
2644 break;
2645
2646 const sal_uInt16 nLeftDistance = o3tl::toTwips(aTableBorderDistances.LeftDistance, o3tl::Length::mm100);
2647 const sal_uInt16 nRightDistance = o3tl::toTwips(aTableBorderDistances.RightDistance, o3tl::Length::mm100);
2648 const sal_uInt16 nTopDistance = o3tl::toTwips(aTableBorderDistances.TopDistance, o3tl::Length::mm100);
2649 const sal_uInt16 nBottomDistance = o3tl::toTwips(aTableBorderDistances.BottomDistance, o3tl::Length::mm100);
2650 SwDoc* pDoc = pFormat->GetDoc();
2651 SwTable* pTable = SwTable::FindTable( pFormat );
2652 SwTableLines &rLines = pTable->GetTabLines();
2654 for(size_t i = 0; i < rLines.size(); ++i)
2655 {
2656 SwTableLine* pLine = rLines[i];
2657 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2658 for(size_t k = 0; k < rBoxes.size(); ++k)
2659 {
2660 SwTableBox* pBox = rBoxes[k];
2661 const SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2662 const SvxBoxItem& rBox = pBoxFormat->GetBox();
2663 if(
2664 (aTableBorderDistances.IsLeftDistanceValid && nLeftDistance != rBox.GetDistance( SvxBoxItemLine::LEFT )) ||
2665 (aTableBorderDistances.IsRightDistanceValid && nRightDistance != rBox.GetDistance( SvxBoxItemLine::RIGHT )) ||
2666 (aTableBorderDistances.IsTopDistanceValid && nTopDistance != rBox.GetDistance( SvxBoxItemLine::TOP )) ||
2667 (aTableBorderDistances.IsBottomDistanceValid && nBottomDistance != rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2668 {
2669 SvxBoxItem aSetBox( rBox );
2670 SwFrameFormat* pSetBoxFormat = pBox->ClaimFrameFormat();
2671 if( aTableBorderDistances.IsLeftDistanceValid )
2672 aSetBox.SetDistance( nLeftDistance, SvxBoxItemLine::LEFT );
2673 if( aTableBorderDistances.IsRightDistanceValid )
2674 aSetBox.SetDistance( nRightDistance, SvxBoxItemLine::RIGHT );
2675 if( aTableBorderDistances.IsTopDistanceValid )
2676 aSetBox.SetDistance( nTopDistance, SvxBoxItemLine::TOP );
2677 if( aTableBorderDistances.IsBottomDistanceValid )
2678 aSetBox.SetDistance( nBottomDistance, SvxBoxItemLine::BOTTOM );
2679 pDoc->SetAttr( aSetBox, *pSetBoxFormat );
2680 }
2681 }
2682 }
2683 pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::END, nullptr);
2684 }
2685 break;
2686
2688 {
2689 UnoActionContext aContext(pFormat->GetDoc());
2690 SwTable* pTable = SwTable::FindTable( pFormat );
2691 lcl_SetTableSeparators(aValue, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false, pFormat->GetDoc());
2692 }
2693 break;
2694
2695 case FN_UNO_TABLE_COLUMN_RELATIVE_SUM:/*_readonly_*/ break;
2696
2698 {
2699 SwTable* pTable = SwTable::FindTable(pFormat);
2700 OUString sName;
2701 if (!(aValue >>= sName))
2702 break;
2704 pTable->SetTableStyleName(sName);
2705 SwDoc* pDoc = pFormat->GetDoc();
2707 }
2708 break;
2709
2710 default:
2711 {
2712 SwAttrSet aSet(pFormat->GetAttrSet());
2713 m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aSet);
2714 pFormat->GetDoc()->SetAttr(aSet, *pFormat);
2715 }
2716 }
2717 }
2718 }
2719 else if (m_pImpl->IsDescriptor())
2720 {
2721 m_pImpl->m_pTableProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue);
2722 }
2723 else
2724 throw uno::RuntimeException();
2725}
2726
2727uno::Any SwXTextTable::getPropertyValue(const OUString& rPropertyName)
2728{
2729 SolarMutexGuard aGuard;
2730 uno::Any aRet;
2731 SwFrameFormat* pFormat = GetFrameFormat();
2732 const SfxItemPropertyMapEntry* pEntry =
2733 m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
2734
2735 if (!pEntry)
2736 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
2737
2738 if(pFormat)
2739 {
2740 if(0xBF == pEntry->nMemberId)
2741 {
2742 aRet = lcl_GetSpecialProperty(pFormat, pEntry );
2743 }
2744 else
2745 {
2746 switch(pEntry->nWID)
2747 {
2748 case FN_UNO_TABLE_NAME:
2749 {
2750 aRet <<= getName();
2751 }
2752 break;
2753
2755 case FN_UNO_TEXT_WRAP:
2756 case FN_UNO_ANCHOR_TYPE:
2758 aRet, u"", pEntry->nWID);
2759 break;
2760
2762 {
2763 aRet <<= m_pImpl->m_bFirstRowAsLabel;
2764 }
2765 break;
2766
2768 aRet <<= m_pImpl->m_bFirstColumnAsLabel;
2769 break;
2770
2773 {
2774 SwDoc* pDoc = pFormat->GetDoc();
2775 // tables without layout (invisible header/footer?)
2776 if(!lcl_FormatTable(pFormat))
2777 break;
2778 SwTable* pTable = SwTable::FindTable( pFormat );
2779 SwTableLines &rLines = pTable->GetTabLines();
2780
2781 const SwTableBox* pTLBox = lcl_FindCornerTableBox(rLines, true);
2782 const SwStartNode* pSttNd = pTLBox->GetSttNd();
2783 SwPosition aPos(*pSttNd);
2784 // set cursor to top left cell
2785 auto pUnoCursor(pDoc->CreateUnoCursor(aPos, true));
2786 pUnoCursor->Move( fnMoveForward, GoInNode );
2787 pUnoCursor->SetRemainInSection( false );
2788
2789 const SwTableBox* pBRBox = lcl_FindCornerTableBox(rLines, false);
2790 pUnoCursor->SetMark();
2791 const SwStartNode* pLastNd = pBRBox->GetSttNd();
2792 pUnoCursor->GetPoint()->Assign( *pLastNd );
2793
2794 pUnoCursor->Move( fnMoveForward, GoInNode );
2795 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
2796 // HACK: remove pending actions for selecting old style tables
2797 UnoActionRemoveContext aRemoveContext(rCursor);
2798 rCursor.MakeBoxSels();
2799
2801 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
2802 aSet(pDoc->GetAttrPool());
2803 aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
2804 SwDoc::GetTabBorders(rCursor, aSet);
2805 const SvxBoxInfoItem& rBoxInfoItem = aSet.Get(SID_ATTR_BORDER_INNER);
2806 const SvxBoxItem& rBox = aSet.Get(RES_BOX);
2807
2808 if (FN_UNO_TABLE_BORDER == pEntry->nWID)
2809 {
2810 table::TableBorder aTableBorder;
2811 aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2812 aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2813 aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2814 aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2815 aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2816 aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2817 aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2818 aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2819 aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2820 aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2821 aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2822 aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2823 aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2824 aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2825 aRet <<= aTableBorder;
2826 }
2827 else
2828 {
2829 table::TableBorder2 aTableBorder;
2830 aTableBorder.TopLine = SvxBoxItem::SvxLineToLine(rBox.GetTop(), true);
2831 aTableBorder.IsTopLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::TOP);
2832 aTableBorder.BottomLine = SvxBoxItem::SvxLineToLine(rBox.GetBottom(), true);
2833 aTableBorder.IsBottomLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::BOTTOM);
2834 aTableBorder.LeftLine = SvxBoxItem::SvxLineToLine(rBox.GetLeft(), true);
2835 aTableBorder.IsLeftLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::LEFT);
2836 aTableBorder.RightLine = SvxBoxItem::SvxLineToLine(rBox.GetRight(), true);
2837 aTableBorder.IsRightLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::RIGHT );
2838 aTableBorder.HorizontalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetHori(), true);
2839 aTableBorder.IsHorizontalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::HORI);
2840 aTableBorder.VerticalLine = SvxBoxItem::SvxLineToLine(rBoxInfoItem.GetVert(), true);
2841 aTableBorder.IsVerticalLineValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::VERT);
2842 aTableBorder.Distance = convertTwipToMm100(rBox.GetSmallestDistance());
2843 aTableBorder.IsDistanceValid = rBoxInfoItem.IsValid(SvxBoxInfoItemValidFlags::DISTANCE);
2844 aRet <<= aTableBorder;
2845 }
2846 }
2847 break;
2848
2850 {
2851 table::TableBorderDistances aTableBorderDistances( 0, true, 0, true, 0, true, 0, true ) ;
2852 SwTable* pTable = SwTable::FindTable( pFormat );
2853 const SwTableLines &rLines = pTable->GetTabLines();
2854 bool bFirst = true;
2855 sal_uInt16 nLeftDistance = 0;
2856 sal_uInt16 nRightDistance = 0;
2857 sal_uInt16 nTopDistance = 0;
2858 sal_uInt16 nBottomDistance = 0;
2859
2860 for(size_t i = 0; i < rLines.size(); ++i)
2861 {
2862 const SwTableLine* pLine = rLines[i];
2863 const SwTableBoxes& rBoxes = pLine->GetTabBoxes();
2864 for(size_t k = 0; k < rBoxes.size(); ++k)
2865 {
2866 const SwTableBox* pBox = rBoxes[k];
2867 SwFrameFormat* pBoxFormat = pBox->GetFrameFormat();
2868 const SvxBoxItem& rBox = pBoxFormat->GetBox();
2869 if( bFirst )
2870 {
2871 nLeftDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT ));
2872 nRightDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT ));
2873 nTopDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP ));
2874 nBottomDistance = convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM ));
2875 bFirst = false;
2876 }
2877 else
2878 {
2879 if( aTableBorderDistances.IsLeftDistanceValid &&
2880 nLeftDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::LEFT )))
2881 aTableBorderDistances.IsLeftDistanceValid = false;
2882 if( aTableBorderDistances.IsRightDistanceValid &&
2883 nRightDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::RIGHT )))
2884 aTableBorderDistances.IsRightDistanceValid = false;
2885 if( aTableBorderDistances.IsTopDistanceValid &&
2886 nTopDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::TOP )))
2887 aTableBorderDistances.IsTopDistanceValid = false;
2888 if( aTableBorderDistances.IsBottomDistanceValid &&
2889 nBottomDistance != convertTwipToMm100( rBox.GetDistance( SvxBoxItemLine::BOTTOM )))
2890 aTableBorderDistances.IsBottomDistanceValid = false;
2891 }
2892
2893 }
2894 if( !aTableBorderDistances.IsLeftDistanceValid &&
2895 !aTableBorderDistances.IsRightDistanceValid &&
2896 !aTableBorderDistances.IsTopDistanceValid &&
2897 !aTableBorderDistances.IsBottomDistanceValid )
2898 break;
2899 }
2900 if( aTableBorderDistances.IsLeftDistanceValid)
2901 aTableBorderDistances.LeftDistance = nLeftDistance;
2902 if( aTableBorderDistances.IsRightDistanceValid)
2903 aTableBorderDistances.RightDistance = nRightDistance;
2904 if( aTableBorderDistances.IsTopDistanceValid)
2905 aTableBorderDistances.TopDistance = nTopDistance;
2906 if( aTableBorderDistances.IsBottomDistanceValid)
2907 aTableBorderDistances.BottomDistance = nBottomDistance;
2908
2909 aRet <<= aTableBorderDistances;
2910 }
2911 break;
2912
2914 {
2915 SwTable* pTable = SwTable::FindTable( pFormat );
2916 lcl_GetTableSeparators(aRet, pTable, pTable->GetTabLines()[0]->GetTabBoxes()[0], false);
2917 }
2918 break;
2919
2921 aRet <<= sal_Int16(UNO_TABLE_COLUMN_SUM);
2922 break;
2923
2924 case RES_ANCHOR:
2925 // AnchorType is readonly and might be void (no return value)
2926 break;
2927
2929 {
2930 SwTable* pTable = SwTable::FindTable( pFormat );
2931 SwTableNode* pTableNode = pTable->GetTableNode();
2932 SwSectionNode* pSectionNode = pTableNode->FindSectionNode();
2933 if(pSectionNode)
2934 {
2935 SwSection& rSect = pSectionNode->GetSection();
2936 uno::Reference< text::XTextSection > xSect =
2938 aRet <<= xSect;
2939 }
2940 }
2941 break;
2942
2944 {
2945 SwTable* pTable = SwTable::FindTable(pFormat);
2946 OUString sName;
2948 aRet <<= sName;
2949 }
2950 break;
2951
2952 default:
2953 {
2954 const SwAttrSet& rSet = pFormat->GetAttrSet();
2955 m_pImpl->m_pPropSet->getPropertyValue(*pEntry, rSet, aRet);
2956 }
2957 }
2958 }
2959 }
2960 else if (m_pImpl->IsDescriptor())
2961 {
2962 const uno::Any* pAny = nullptr;
2963 if (!m_pImpl->m_pTableProps->GetProperty(pEntry->nWID, pEntry->nMemberId, pAny))
2964 throw lang::IllegalArgumentException();
2965 else if(pAny)
2966 aRet = *pAny;
2967 }
2968 else
2969 throw uno::RuntimeException();
2970 return aRet;
2971}
2972
2973void SwXTextTable::addPropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2974 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2975
2976void SwXTextTable::removePropertyChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*xListener*/)
2977 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2978
2979void SwXTextTable::addVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2980 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2981
2982void SwXTextTable::removeVetoableChangeListener(const OUString& /*rPropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*xListener*/)
2983 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
2984
2986{
2987 SolarMutexGuard aGuard;
2988 SwFrameFormat* pFormat = GetFrameFormat();
2989 if (!pFormat && !m_pImpl->IsDescriptor())
2990 throw uno::RuntimeException();
2991 if(pFormat)
2992 {
2993 return pFormat->GetName();
2994 }
2995 return m_pImpl->m_sTableName;
2996}
2997
2998void SwXTextTable::setName(const OUString& rName)
2999{
3000 SolarMutexGuard aGuard;
3001 SwFrameFormat* pFormat = GetFrameFormat();
3002 if ((!pFormat && !m_pImpl->IsDescriptor()) ||
3003 rName.isEmpty() ||
3004 rName.indexOf('.')>=0 ||
3005 rName.indexOf(' ')>=0 )
3006 throw uno::RuntimeException();
3007
3008 if(pFormat)
3009 {
3010 const OUString aOldName( pFormat->GetName() );
3011 const SwFrameFormats* pFrameFormats = pFormat->GetDoc()->GetTableFrameFormats();
3012 for (size_t i = pFrameFormats->size(); i;)
3013 {
3014 const SwFrameFormat* pTmpFormat = (*pFrameFormats)[--i];
3015 if( !pTmpFormat->IsDefault() &&
3016 pTmpFormat->GetName() == rName &&
3017 pFormat->GetDoc()->IsUsed( *pTmpFormat ))
3018 {
3019 throw uno::RuntimeException();
3020 }
3021 }
3022
3023 pFormat->SetFormatName( rName );
3024
3025 SwStartNode *pStNd;
3026 SwNodeIndex aIdx( *pFormat->GetDoc()->GetNodes().GetEndOfAutotext().StartOfSectionNode(), 1 );
3027 while ( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
3028 {
3029 ++aIdx;
3030 SwNode *const pNd = & aIdx.GetNode();
3031 if ( pNd->IsOLENode() &&
3032 aOldName == static_cast<const SwOLENode*>(pNd)->GetChartTableName() )
3033 {
3034 static_cast<SwOLENode*>(pNd)->SetChartTableName( rName );
3035
3036 SwTable* pTable = SwTable::FindTable( pFormat );
3037 //TL_CHART2: chart needs to be notified about name changes
3038 pFormat->GetDoc()->UpdateCharts( pTable->GetFrameFormat()->GetName() );
3039 }
3040 aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
3041 }
3042 pFormat->GetDoc()->getIDocumentState().SetModified();
3043 }
3044 else
3045 m_pImpl->m_sTableName = rName;
3046}
3047
3049{
3050 sal_uInt16 nRet = 0;
3051 SwFrameFormat* pFormat = GetFrameFormat();
3052 if(pFormat)
3053 {
3054 SwTable* pTable = SwTable::FindTable( pFormat );
3055 if(!pTable->IsTableComplex())
3056 {
3057 nRet = pTable->GetTabLines().size();
3058 }
3059 }
3060 return nRet;
3061}
3062
3064{
3065 SwFrameFormat* pFormat = GetFrameFormat();
3066 sal_uInt16 nRet = 0;
3067 if(pFormat)
3068 {
3069 SwTable* pTable = SwTable::FindTable( pFormat );
3070 if(!pTable->IsTableComplex())
3071 {
3072 SwTableLines& rLines = pTable->GetTabLines();
3073 SwTableLine* pLine = rLines.front();
3074 nRet = pLine->GetTabBoxes().size();
3075 }
3076 }
3077 return nRet;
3078}
3079
3081{
3082 if(rHint.GetId() == SfxHintId::Dying)
3083 {
3084 m_pFrameFormat = nullptr;
3085 EndListeningAll();
3086 }
3087 uno::Reference<uno::XInterface> const xThis(m_wThis);
3088 if (xThis.is())
3089 { // fdo#72695: if UNO object is already dead, don't revive it with event
3090 if(!m_pFrameFormat)
3091 {
3092 lang::EventObject const ev(xThis);
3093 std::unique_lock aGuard(m_Mutex);
3094 m_EventListeners.disposeAndClear(aGuard, ev);
3095 m_ChartListeners.disposeAndClear(aGuard, ev);
3096 }
3097 else
3098 {
3099 std::unique_lock aGuard(m_Mutex);
3100 lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
3101 }
3102 }
3103}
3104
3106 { return "SwXTextTable"; }
3107
3108sal_Bool SwXTextTable::supportsService(const OUString& rServiceName)
3109 { return cppu::supportsService(this, rServiceName); }
3110
3112{
3113 return {
3114 "com.sun.star.document.LinkTarget",
3115 "com.sun.star.text.TextTable",
3116 "com.sun.star.text.TextContent",
3117 "com.sun.star.text.TextSortable" };
3118}
3119
3120
3122 : public SvtListener
3123{
3124private:
3126
3127public:
3128 uno::WeakReference<uno::XInterface> m_wThis;
3129 std::mutex m_Mutex; // just for OInterfaceContainerHelper4
3131
3133
3136
3139
3140 Impl(sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat, SwRangeDescriptor const& rDesc)
3141 : m_pFrameFormat(&rFrameFormat)
3142 , m_pTableCursor(pCursor)
3143 , m_RangeDescriptor(rDesc)
3144 , m_pPropSet(aSwMapProvider.GetPropertySet(PROPERTY_MAP_TABLE_RANGE))
3145 , m_bFirstRowAsLabel(false)
3146 , m_bFirstColumnAsLabel(false)
3147 {
3148 StartListening(rFrameFormat.GetNotifier());
3149 m_RangeDescriptor.Normalize();
3150 }
3151
3153 {
3154 return m_pFrameFormat;
3155 }
3156
3157 std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32> GetLabelCoordinates(bool bRow);
3158
3159 uno::Sequence<OUString> GetLabelDescriptions(SwXCellRange & rThis, bool bRow);
3160
3161 void SetLabelDescriptions(SwXCellRange & rThis,
3162 const css::uno::Sequence<OUString>& rDesc, bool bRow);
3163
3164 sal_Int32 GetRowCount() const;
3165 sal_Int32 GetColumnCount() const;
3166
3167 virtual void Notify(const SfxHint& ) override;
3168
3169};
3170
3171namespace
3172{
3173}
3174
3175const uno::Sequence< sal_Int8 > & SwXCellRange::getUnoTunnelId()
3176{
3177 static const comphelper::UnoIdInit theSwXCellRangeUnoTunnelId;
3178 return theSwXCellRangeUnoTunnelId.getSeq();
3179}
3180
3181sal_Int64 SAL_CALL SwXCellRange::getSomething( const uno::Sequence< sal_Int8 >& rId )
3182{
3183 return comphelper::getSomethingImpl(rId, this);
3184}
3185
3186
3188 { return "SwXCellRange"; }
3189
3190sal_Bool SwXCellRange::supportsService(const OUString& rServiceName)
3191 { return cppu::supportsService(this, rServiceName); }
3192
3194{
3195 return {
3196 "com.sun.star.text.CellRange",
3197 "com.sun.star.style.CharacterProperties",
3198 "com.sun.star.style.CharacterPropertiesAsian",
3199 "com.sun.star.style.CharacterPropertiesComplex",
3200 "com.sun.star.style.ParagraphProperties",
3201 "com.sun.star.style.ParagraphPropertiesAsian",
3202 "com.sun.star.style.ParagraphPropertiesComplex" };
3203}
3204
3206 SwFrameFormat& rFrameFormat, SwRangeDescriptor const & rDesc)
3207 : m_pImpl(new Impl(pCursor, rFrameFormat, rDesc))
3208{
3209}
3210
3212{
3213}
3214
3216 sw::UnoCursorPointer const& pCursor, SwFrameFormat& rFrameFormat,
3217 SwRangeDescriptor const & rDesc)
3218{
3219 rtl::Reference<SwXCellRange> pCellRange(new SwXCellRange(pCursor, rFrameFormat, rDesc));
3220 // need a permanent Reference to initialize m_wThis
3221 pCellRange->m_pImpl->m_wThis = uno::Reference<table::XCellRange>(pCellRange);
3222 return pCellRange;
3223}
3224
3225void SwXCellRange::SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
3226{
3227 m_pImpl->m_bFirstRowAsLabel = bFirstRowAsLabel;
3228 m_pImpl->m_bFirstColumnAsLabel = bFirstColumnAsLabel;
3229}
3230
3231std::vector< uno::Reference< table::XCell > > SwXCellRange::GetCells()
3232{
3233 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3234 const sal_Int32 nRowCount(m_pImpl->GetRowCount());
3235 const sal_Int32 nColCount(m_pImpl->GetColumnCount());
3236 std::vector< uno::Reference< table::XCell > > vResult;
3237 vResult.reserve(static_cast<size_t>(nRowCount)*static_cast<size_t>(nColCount));
3238 for(sal_Int32 nRow = 0; nRow < nRowCount; ++nRow)
3239 for(sal_Int32 nCol = 0; nCol < nColCount; ++nCol)
3240 vResult.emplace_back(lcl_CreateXCell(pFormat, m_pImpl->m_RangeDescriptor.nLeft + nCol, m_pImpl->m_RangeDescriptor.nTop + nRow));
3241 return vResult;
3242}
3243
3244uno::Reference<table::XCell> SAL_CALL
3245SwXCellRange::getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow)
3246{
3247 SolarMutexGuard aGuard;
3248 uno::Reference< table::XCell > aRet;
3249 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3250 if(pFormat)
3251 {
3252 if(nColumn >= 0 && nRow >= 0 &&
3253 m_pImpl->GetColumnCount() > nColumn && m_pImpl->GetRowCount() > nRow )
3254 {
3256 m_pImpl->m_RangeDescriptor.nLeft + nColumn,
3257 m_pImpl->m_RangeDescriptor.nTop + nRow);
3258 if(pXCell)
3259 aRet = pXCell;
3260 }
3261 }
3262 if(!aRet.is())
3263 throw lang::IndexOutOfBoundsException();
3264 return aRet;
3265}
3266
3267uno::Reference<table::XCellRange> SAL_CALL
3269 sal_Int32 nLeft, sal_Int32 nTop, sal_Int32 nRight, sal_Int32 nBottom)
3270{
3271 SolarMutexGuard aGuard;
3272 uno::Reference< table::XCellRange > aRet;
3273 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3274 if (pFormat && m_pImpl->GetColumnCount() > nRight
3275 && m_pImpl->GetRowCount() > nBottom &&
3276 nLeft <= nRight && nTop <= nBottom
3277 && nLeft >= 0 && nRight >= 0 && nTop >= 0 && nBottom >= 0 )
3278 {
3279 SwTable* pTable = SwTable::FindTable( pFormat );
3280 if(!pTable->IsTableComplex())
3281 {
3282 SwRangeDescriptor aNewDesc;
3283 aNewDesc.nTop = nTop + m_pImpl->m_RangeDescriptor.nTop;
3284 aNewDesc.nBottom = nBottom + m_pImpl->m_RangeDescriptor.nTop;
3285 aNewDesc.nLeft = nLeft + m_pImpl->m_RangeDescriptor.nLeft;
3286 aNewDesc.nRight = nRight + m_pImpl->m_RangeDescriptor.nLeft;
3287 aNewDesc.Normalize();
3288 const OUString sTLName = sw_GetCellName(aNewDesc.nLeft, aNewDesc.nTop);
3289 const OUString sBRName = sw_GetCellName(aNewDesc.nRight, aNewDesc.nBottom);
3290 const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
3291 if(pTLBox)
3292 {
3293 const SwStartNode* pSttNd = pTLBox->GetSttNd();
3294 SwPosition aPos(*pSttNd);
3295 // set cursor in the upper-left cell of the range
3296 auto pUnoCursor(pFormat->GetDoc()->CreateUnoCursor(aPos, true));
3297 pUnoCursor->Move( fnMoveForward, GoInNode );
3298 pUnoCursor->SetRemainInSection( false );
3299 const SwTableBox* pBRBox = pTable->GetTableBox( sBRName );
3300 if(pBRBox)
3301 {
3302 pUnoCursor->SetMark();
3303 pUnoCursor->GetPoint()->Assign( *pBRBox->GetSttNd() );
3304 pUnoCursor->Move( fnMoveForward, GoInNode );
3305 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
3306 // HACK: remove pending actions for selecting old style tables
3307 UnoActionRemoveContext aRemoveContext(rCursor);
3308 rCursor.MakeBoxSels();
3309 // pUnoCursor will be provided and will not be deleted
3310 aRet = SwXCellRange::CreateXCellRange(pUnoCursor, *pFormat, aNewDesc).get();
3311 }
3312 }
3313 }
3314 }
3315 if(!aRet.is())
3316 throw lang::IndexOutOfBoundsException();
3317 return aRet;
3318}
3319
3320uno::Reference<table::XCellRange> SAL_CALL
3322{
3323 SolarMutexGuard aGuard;
3324 sal_Int32 nPos = 0;
3325 const OUString sTLName(rRange.getToken(0, ':', nPos));
3326 const OUString sBRName(rRange.getToken(0, ':', nPos));
3327 if(sTLName.isEmpty() || sBRName.isEmpty())
3328 throw uno::RuntimeException();
3329 SwRangeDescriptor aDesc;
3330 aDesc.nTop = aDesc.nLeft = aDesc.nBottom = aDesc.nRight = -1;
3331 SwXTextTable::GetCellPosition( sTLName, aDesc.nLeft, aDesc.nTop );
3332 SwXTextTable::GetCellPosition( sBRName, aDesc.nRight, aDesc.nBottom );
3333 aDesc.Normalize();
3335 aDesc.nLeft - m_pImpl->m_RangeDescriptor.nLeft,
3336 aDesc.nTop - m_pImpl->m_RangeDescriptor.nTop,
3337 aDesc.nRight - m_pImpl->m_RangeDescriptor.nLeft,
3338 aDesc.nBottom - m_pImpl->m_RangeDescriptor.nTop);
3339}
3340
3341uno::Reference< beans::XPropertySetInfo > SwXCellRange::getPropertySetInfo()
3342{
3343 static uno::Reference<beans::XPropertySetInfo> xRef = m_pImpl->m_pPropSet->getPropertySetInfo();
3344 return xRef;
3345}
3346
3347void SAL_CALL
3348SwXCellRange::setPropertyValue(const OUString& rPropertyName, const uno::Any& aValue)
3349{
3350 SolarMutexGuard aGuard;
3351 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3352 if(!pFormat)
3353 return;
3354
3355 const SfxItemPropertyMapEntry *const pEntry =
3356 m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3357 if(!pEntry)
3358 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3359
3360 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY)
3361 throw beans::PropertyVetoException("Property is read-only: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3362
3363 SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3364 SwUnoTableCursor& rCursor(dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor));
3365 {
3366 // HACK: remove pending actions for selecting old style tables
3367 UnoActionRemoveContext aRemoveContext(rCursor);
3368 }
3369 rCursor.MakeBoxSels();
3370 switch(pEntry->nWID )
3371 {
3373 {
3374 std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3375 SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush);
3376 aBrush->PutValue(aValue, pEntry->nMemberId);
3377 rDoc.SetBoxAttr(*m_pImpl->m_pTableCursor, *aBrush);
3378
3379 }
3380 break;
3381 case RES_BOX :
3382 {
3384 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
3385 aSet(rDoc.GetAttrPool());
3386 SvxBoxInfoItem aBoxInfo( SID_ATTR_BORDER_INNER );
3387 aBoxInfo.SetValid(SvxBoxInfoItemValidFlags::ALL, false);
3388 SvxBoxInfoItemValidFlags nValid = SvxBoxInfoItemValidFlags::NONE;
3389 switch(pEntry->nMemberId & ~CONVERT_TWIPS)
3390 {
3391 case LEFT_BORDER : nValid = SvxBoxInfoItemValidFlags::LEFT; break;
3392 case RIGHT_BORDER: nValid = SvxBoxInfoItemValidFlags::RIGHT; break;
3393 case TOP_BORDER : nValid = SvxBoxInfoItemValidFlags::TOP; break;
3394 case BOTTOM_BORDER: nValid = SvxBoxInfoItemValidFlags::BOTTOM; break;
3397 case TOP_BORDER_DISTANCE :
3399 nValid = SvxBoxInfoItemValidFlags::DISTANCE;
3400 break;
3401 }
3402 aBoxInfo.SetValid(nValid);
3403
3404 aSet.Put(aBoxInfo);
3405 SwDoc::GetTabBorders(rCursor, aSet);
3406
3407 aSet.Put(aBoxInfo);
3408 SvxBoxItem aBoxItem(aSet.Get(RES_BOX));
3409 static_cast<SfxPoolItem&>(aBoxItem).PutValue(aValue, pEntry->nMemberId);
3410 aSet.Put(aBoxItem);
3411 rDoc.SetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3412 }
3413 break;
3414 case RES_BOXATR_FORMAT:
3415 {
3416 SfxUInt32Item aNumberFormat(RES_BOXATR_FORMAT);
3417 static_cast<SfxPoolItem&>(aNumberFormat).PutValue(aValue, 0);
3418 rDoc.SetBoxAttr(rCursor, aNumberFormat);
3419 }
3420 break;
3422 {
3423 bool bTmp = *o3tl::doAccess<bool>(aValue);
3424 if (m_pImpl->m_bFirstRowAsLabel != bTmp)
3425 {
3426 std::unique_lock aGuard2(m_pImpl->m_Mutex);
3427 lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
3428 m_pImpl->m_bFirstRowAsLabel = bTmp;
3429 }
3430 }
3431 break;
3433 {
3434 bool bTmp = *o3tl::doAccess<bool>(aValue);
3435 if (m_pImpl->m_bFirstColumnAsLabel != bTmp)
3436 {
3437 std::unique_lock aGuard2(m_pImpl->m_Mutex);
3438 lcl_SendChartEvent(aGuard2, *this, m_pImpl->m_ChartListeners);
3439 m_pImpl->m_bFirstColumnAsLabel = bTmp;
3440 }
3441 }
3442 break;
3443 case RES_VERT_ORIENT:
3444 {
3445 sal_Int16 nAlign = -1;
3446 aValue >>= nAlign;
3447 if( nAlign >= text::VertOrientation::NONE && nAlign <= text::VertOrientation::BOTTOM)
3448 rDoc.SetBoxAlign( rCursor, nAlign );
3449 }
3450 break;
3451 default:
3452 {
3453 SfxItemSet aItemSet( rDoc.GetAttrPool(), pEntry->nWID, pEntry->nWID );
3455 aItemSet);
3456
3458 *pEntry, aValue, rCursor.GetSelRing(), aItemSet))
3459 {
3460 m_pImpl->m_pPropSet->setPropertyValue(*pEntry, aValue, aItemSet);
3461 }
3463 aItemSet, SetAttrMode::DEFAULT, true);
3464 }
3465 }
3466}
3467
3468uno::Any SAL_CALL SwXCellRange::getPropertyValue(const OUString& rPropertyName)
3469{
3470 SolarMutexGuard aGuard;
3471 uno::Any aRet;
3472 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3473 if(pFormat)
3474 {
3475 const SfxItemPropertyMapEntry *const pEntry =
3476 m_pImpl->m_pPropSet->getPropertyMap().getByName(rPropertyName);
3477 if(!pEntry)
3478 throw beans::UnknownPropertyException("Unknown property: " + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) );
3479
3480 switch(pEntry->nWID )
3481 {
3483 {
3484 std::unique_ptr<SfxPoolItem> aBrush(std::make_unique<SvxBrushItem>(RES_BACKGROUND));
3485 if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aBrush))
3486 aBrush->QueryValue(aRet, pEntry->nMemberId);
3487
3488 }
3489 break;
3490 case RES_BOX :
3491 {
3492 SwDoc& rDoc = m_pImpl->m_pTableCursor->GetDoc();
3494 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER>
3495 aSet(rDoc.GetAttrPool());
3496 aSet.Put(SvxBoxInfoItem( SID_ATTR_BORDER_INNER ));
3497 SwDoc::GetTabBorders(*m_pImpl->m_pTableCursor, aSet);
3498 const SvxBoxItem& rBoxItem = aSet.Get(RES_BOX);
3499 rBoxItem.QueryValue(aRet, pEntry->nMemberId);
3500 }
3501 break;
3502 case RES_BOXATR_FORMAT:
3503 OSL_FAIL("not implemented");
3504 break;
3505 case FN_UNO_PARA_STYLE:
3506 {
3507 SwFormatColl *const pTmpFormat =
3508 SwUnoCursorHelper::GetCurTextFormatColl(*m_pImpl->m_pTableCursor, false);
3509 OUString sRet;
3510 if (pTmpFormat)
3511 sRet = pTmpFormat->GetName();
3512 aRet <<= sRet;
3513 }
3514 break;
3516 aRet <<= m_pImpl->m_bFirstRowAsLabel;
3517 break;
3519 aRet <<= m_pImpl->m_bFirstColumnAsLabel;
3520 break;
3521 case RES_VERT_ORIENT:
3522 {
3523 std::unique_ptr<SfxPoolItem> aVertOrient(
3524 std::make_unique<SwFormatVertOrient>(RES_VERT_ORIENT));
3525 if (SwDoc::GetBoxAttr(*m_pImpl->m_pTableCursor, aVertOrient))
3526 {
3527 aVertOrient->QueryValue( aRet, pEntry->nMemberId );
3528 }
3529 }
3530 break;
3531 default:
3532 {
3537 aSet(m_pImpl->m_pTableCursor->GetDoc().GetAttrPool());
3538 // first look at the attributes of the cursor
3539 SwUnoTableCursor& rCursor =
3540 dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
3542 m_pImpl->m_pPropSet->getPropertyValue(*pEntry, aSet, aRet);
3543 }
3544 }
3545
3546 }
3547 return aRet;
3548}
3549
3550void SwXCellRange::addPropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3551 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3552
3553void SwXCellRange::removePropertyChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/)
3554 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3555
3556void SwXCellRange::addVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3557 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3558
3559void SwXCellRange::removeVetoableChangeListener(const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/)
3560 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3561
3563uno::Sequence<uno::Sequence<uno::Any>> SAL_CALL SwXCellRange::getDataArray()
3564{
3565 SolarMutexGuard aGuard;
3566 const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3567 const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3568 if(!nRowCount || !nColCount)
3569 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3570 lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3571 uno::Sequence< uno::Sequence< uno::Any > > aRowSeq(nRowCount);
3572 auto vCells(GetCells());
3573 auto pCurrentCell(vCells.begin());
3574 for(auto& rRow : asNonConstRange(aRowSeq))
3575 {
3576 rRow = uno::Sequence< uno::Any >(nColCount);
3577 for(auto& rCellAny : asNonConstRange(rRow))
3578 {
3579 auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3580 if(!pCell)
3581 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3582 rCellAny = pCell->GetAny();
3583 ++pCurrentCell;
3584 }
3585 }
3586 return aRowSeq;
3587}
3588
3590void SAL_CALL SwXCellRange::setDataArray(const uno::Sequence< uno::Sequence< uno::Any > >& rArray)
3591{
3592 SolarMutexGuard aGuard;
3593 const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3594 const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3595 if(!nRowCount || !nColCount)
3596 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3597 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3598 if(!pFormat)
3599 return;
3600 if(rArray.getLength() != nRowCount)
3601 throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rArray.getLength()), static_cast<cppu::OWeakObject*>(this));
3602 auto vCells(GetCells());
3603 auto pCurrentCell(vCells.begin());
3604 for(const auto& rColSeq : rArray)
3605 {
3606 if(rColSeq.getLength() != nColCount)
3607 throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rColSeq.getLength()), static_cast<cppu::OWeakObject*>(this));
3608 for(const auto& aValue : rColSeq)
3609 {
3610 auto pCell(static_cast<SwXCell*>(pCurrentCell->get()));
3611 if(!pCell || !pCell->GetTableBox())
3612 throw uno::RuntimeException("Box for cell missing", static_cast<cppu::OWeakObject*>(this));
3613 if(aValue.isExtractableTo(cppu::UnoType<OUString>::get()))
3614 sw_setString(*pCell, aValue.get<OUString>());
3615 else if(aValue.isExtractableTo(cppu::UnoType<double>::get()))
3616 sw_setValue(*pCell, aValue.get<double>());
3617 else
3618 sw_setString(*pCell, OUString(), true);
3619 ++pCurrentCell;
3620 }
3621 }
3622}
3623
3624uno::Sequence<uno::Sequence<double>> SAL_CALL
3626{
3627 SolarMutexGuard aGuard;
3628 const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3629 const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3630 if(!nRowCount || !nColCount)
3631 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3632 if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3633 {
3634 uno::Reference<chart::XChartDataArray> const xDataRange(
3635 getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3636 (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3637 nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3638 return xDataRange->getData();
3639 }
3640 uno::Sequence< uno::Sequence< double > > vRows(nRowCount);
3641 auto vCells(GetCells());
3642 auto pCurrentCell(vCells.begin());
3643 for(auto& rRow : asNonConstRange(vRows))
3644 {
3645 rRow = uno::Sequence<double>(nColCount);
3646 for(auto& rValue : asNonConstRange(rRow))
3647 {
3648 if(!(*pCurrentCell))
3649 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3650 rValue = (*pCurrentCell)->getValue();
3651 ++pCurrentCell;
3652 }
3653 }
3654 return vRows;
3655}
3656
3657void SAL_CALL
3658SwXCellRange::setData(const uno::Sequence< uno::Sequence<double> >& rData)
3659{
3660 SolarMutexGuard aGuard;
3661 const sal_Int32 nRowCount = m_pImpl->GetRowCount();
3662 const sal_Int32 nColCount = m_pImpl->GetColumnCount();
3663 if(!nRowCount || !nColCount)
3664 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
3665 if (m_pImpl->m_bFirstColumnAsLabel || m_pImpl->m_bFirstRowAsLabel)
3666 {
3667 uno::Reference<chart::XChartDataArray> const xDataRange(
3668 getCellRangeByPosition((m_pImpl->m_bFirstColumnAsLabel) ? 1 : 0,
3669 (m_pImpl->m_bFirstRowAsLabel) ? 1 : 0,
3670 nColCount-1, nRowCount-1), uno::UNO_QUERY_THROW);
3671 return xDataRange->setData(rData);
3672 }
3673 lcl_EnsureCoreConnected(m_pImpl->GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
3674 if(rData.getLength() != nRowCount)
3675 throw uno::RuntimeException("Row count mismatch. expected: " + OUString::number(nRowCount) + " got: " + OUString::number(rData.getLength()), static_cast<cppu::OWeakObject*>(this));
3676 auto vCells(GetCells());
3677 auto pCurrentCell(vCells.begin());
3678 for(const auto& rRow : rData)
3679 {
3680 if(rRow.getLength() != nColCount)
3681 throw uno::RuntimeException("Column count mismatch. expected: " + OUString::number(nColCount) + " got: " + OUString::number(rRow.getLength()), static_cast<cppu::OWeakObject*>(this));
3682 for(const auto& rValue : rRow)
3683 {
3684 uno::Reference<table::XCell>(*pCurrentCell, uno::UNO_SET_THROW)->setValue(rValue);
3685 ++pCurrentCell;
3686 }
3687 }
3688}
3689
3690std::tuple<sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32>
3692{
3693 sal_uInt32 nLeft, nTop, nRight, nBottom;
3694 nLeft = nTop = nRight = nBottom = 0;
3695 if(bRow)
3696 {
3697 nTop = m_bFirstRowAsLabel ? 1 : 0;
3698 nBottom = GetRowCount() - 1;
3699 }
3700 else
3701 {
3702 nLeft = m_bFirstColumnAsLabel ? 1 : 0;
3703 nRight = GetColumnCount() - 1;
3704 }
3705 return std::make_tuple(nLeft, nTop, nRight, nBottom);
3706}
3707
3708uno::Sequence<OUString>
3710{
3711 SolarMutexGuard aGuard;
3712 sal_uInt32 nLeft, nTop, nRight, nBottom;
3713 std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3714 if(!nRight && !nBottom)
3715 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3716 lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3717 if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3718 return {}; // without labels we have no descriptions
3719 auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3720 auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3721 uno::Sequence<OUString> vResult(vCells.size());
3722 std::transform(vCells.begin(), vCells.end(), vResult.getArray(),
3723 [](uno::Reference<table::XCell> xCell) -> OUString { return uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->getString(); });
3724 return vResult;
3725}
3726
3727uno::Sequence<OUString> SAL_CALL SwXCellRange::getRowDescriptions()
3728{
3729 return m_pImpl->GetLabelDescriptions(*this, true);
3730}
3731
3732uno::Sequence<OUString> SAL_CALL SwXCellRange::getColumnDescriptions()
3733{
3734 return m_pImpl->GetLabelDescriptions(*this, false);
3735}
3736
3738 const uno::Sequence<OUString>& rDesc, bool bRow)
3739{
3740 SolarMutexGuard aGuard;
3741 lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(&rThis));
3742 if (!(bRow ? m_bFirstColumnAsLabel : m_bFirstRowAsLabel))
3743 return; // if there are no labels we cannot set descriptions
3744 sal_uInt32 nLeft, nTop, nRight, nBottom;
3745 std::tie(nLeft, nTop, nRight, nBottom) = GetLabelCoordinates(bRow);
3746 if(!nRight && !nBottom)
3747 throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(&rThis));
3748 auto xLabelRange(rThis.getCellRangeByPosition(nLeft, nTop, nRight, nBottom));
3749 if (!xLabelRange.is())
3750 throw uno::RuntimeException("Missing Cell Range", static_cast<cppu::OWeakObject*>(&rThis));
3751 auto vCells(static_cast<SwXCellRange*>(xLabelRange.get())->GetCells());
3752 if (sal::static_int_cast<sal_uInt32>(rDesc.getLength()) != vCells.size())
3753 throw uno::RuntimeException("Too few or too many descriptions", static_cast<cppu::OWeakObject*>(&rThis));
3754 auto pDescIterator(rDesc.begin());
3755 for(auto& xCell : vCells)
3756 uno::Reference<text::XText>(xCell, uno::UNO_QUERY_THROW)->setString(*pDescIterator++);
3757}
3758
3760 const uno::Sequence<OUString>& rRowDesc)
3761{
3762 m_pImpl->SetLabelDescriptions(*this, rRowDesc, true);
3763}
3764
3766 const uno::Sequence<OUString>& rColumnDesc)
3767{
3768 m_pImpl->SetLabelDescriptions(*this, rColumnDesc, false);
3769}
3770
3772 const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3773{
3774 // no need to lock here as m_pImpl is const and container threadsafe
3775 std::unique_lock aGuard(m_pImpl->m_Mutex);
3776 m_pImpl->m_ChartListeners.addInterface(aGuard, xListener);
3777}
3778
3780 const uno::Reference<chart::XChartDataChangeEventListener> & xListener)
3781{
3782 // no need to lock here as m_pImpl is const and container threadsafe
3783 std::unique_lock aGuard(m_pImpl->m_Mutex);
3784 m_pImpl->m_ChartListeners.removeInterface(aGuard, xListener);
3785}
3786
3788 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3789
3791 { throw uno::RuntimeException("Not implemented", static_cast<cppu::OWeakObject*>(this)); }
3792
3793uno::Sequence< beans::PropertyValue > SwXCellRange::createSortDescriptor()
3794{
3795 SolarMutexGuard aGuard;
3797}
3798
3799void SAL_CALL SwXCellRange::sort(const uno::Sequence< beans::PropertyValue >& rDescriptor)
3800{
3801 SolarMutexGuard aGuard;
3802 SwSortOptions aSortOpt;
3803 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3804 if(pFormat && SwUnoCursorHelper::ConvertSortProperties(rDescriptor, aSortOpt))
3805 {
3806 SwUnoTableCursor& rTableCursor = dynamic_cast<SwUnoTableCursor&>(*m_pImpl->m_pTableCursor);
3807 rTableCursor.MakeBoxSels();
3808 UnoActionContext aContext(pFormat->GetDoc());
3809 pFormat->GetDoc()->SortTable(rTableCursor.GetSelectedBoxes(), aSortOpt);
3810 }
3811}
3812
3814{
3815 return m_RangeDescriptor.nRight - m_RangeDescriptor.nLeft + 1;
3816}
3817
3819{
3820 return m_RangeDescriptor.nBottom - m_RangeDescriptor.nTop + 1;
3821}
3822
3824{
3825 SwFrameFormat *const pFormat = m_pImpl->GetFrameFormat();
3826 return pFormat ? &(*m_pImpl->m_pTableCursor) : nullptr;
3827}
3828
3830{
3831 uno::Reference<uno::XInterface> const xThis(m_wThis);
3832 if(rHint.GetId() == SfxHintId::Dying)
3833 {
3834 m_pFrameFormat = nullptr;
3835 m_pTableCursor.reset(nullptr);
3836 }
3837 if (xThis.is())
3838 { // fdo#72695: if UNO object is already dead, don't revive it with event
3839 if(m_pFrameFormat)
3840 {
3841 std::unique_lock aGuard(m_Mutex);
3842 lcl_SendChartEvent(aGuard, xThis, m_ChartListeners);
3843 }
3844 else
3845 {
3846 std::unique_lock aGuard(m_Mutex);
3847 m_ChartListeners.disposeAndClear(aGuard, lang::EventObject(xThis));
3848 }
3849 }
3850}
3851
3853{
3854private:
3856
3857public:
3858 explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
3859 {
3860 StartListening(rFrameFormat.GetNotifier());
3861 }
3862 SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
3863 virtual void Notify(const SfxHint&) override;
3864};
3865
3866// SwXTableRows
3867
3869 { return "SwXTableRows"; }
3870
3871sal_Bool SwXTableRows::supportsService(const OUString& rServiceName)
3872 { return cppu::supportsService(this, rServiceName); }
3873
3875 { return { "com.sun.star.text.TableRows" }; }
3876
3877
3879 m_pImpl(new SwXTableRows::Impl(rFrameFormat))
3880{ }
3881
3883{ }
3884
3886{
3887 return m_pImpl->GetFrameFormat();
3888}
3889
3891{
3892 SolarMutexGuard aGuard;
3893 SwFrameFormat* pFrameFormat = GetFrameFormat();
3894 if(!pFrameFormat)
3895 throw uno::RuntimeException();
3896 SwTable* pTable = SwTable::FindTable(pFrameFormat);
3897 return pTable->GetTabLines().size();
3898}
3899
3902{
3903 SolarMutexGuard aGuard;
3904 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3905 if(nIndex < 0)
3906 throw lang::IndexOutOfBoundsException();
3907 SwTable* pTable = SwTable::FindTable( pFrameFormat );
3908 if(o3tl::make_unsigned(nIndex) >= pTable->GetTabLines().size())
3909 throw lang::IndexOutOfBoundsException();
3910 SwTableLine* pLine = pTable->GetTabLines()[nIndex];
3911 FindUnoInstanceHint<SwTableLine,SwXTextTableRow> aHint{pLine};
3912 pFrameFormat->GetNotifier().Broadcast(aHint);
3913 if(!aHint.m_pResult)
3914 aHint.m_pResult = new SwXTextTableRow(pFrameFormat, pLine);
3915 uno::Reference<beans::XPropertySet> xRet = static_cast<beans::XPropertySet*>(aHint.m_pResult.get());
3916 return uno::Any(xRet);
3917}
3918
3920{
3922}
3923
3925{
3926 SolarMutexGuard aGuard;
3927 SwFrameFormat* pFrameFormat = GetFrameFormat();
3928 if(!pFrameFormat)
3929 throw uno::RuntimeException();
3930 // a table always has rows
3931 return true;
3932}
3933
3934void SwXTableRows::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3935{
3936 SolarMutexGuard aGuard;
3937 if (nCount == 0)
3938 return;
3939 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3940 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3941 const size_t nRowCount = pTable->GetTabLines().size();
3942 if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nRowCount)
3943 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3944 const OUString sTLName = sw_GetCellName(0, nIndex);
3945 const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3946 bool bAppend = false;
3947 if(!pTLBox)
3948 {
3949 bAppend = true;
3950 // to append at the end the cursor must be in the last line
3951 SwTableLines& rLines = pTable->GetTabLines();
3952 SwTableLine* pLine = rLines.back();
3953 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
3954 pTLBox = rBoxes.front();
3955 }
3956 if(!pTLBox)
3957 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3958 const SwStartNode* pSttNd = pTLBox->GetSttNd();
3959 SwPosition aPos(*pSttNd);
3960 // set cursor to the upper-left cell of the range
3961 UnoActionContext aAction(pFrameFormat->GetDoc());
3962 std::shared_ptr<SwUnoTableCursor> const pUnoCursor(
3963 std::dynamic_pointer_cast<SwUnoTableCursor>(
3964 pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true)));
3965 pUnoCursor->Move( fnMoveForward, GoInNode );
3966 {
3967 // remove actions - TODO: why?
3968 UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
3969 }
3970 pFrameFormat->GetDoc()->InsertRow(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
3971}
3972
3973void SwXTableRows::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
3974{
3975 SolarMutexGuard aGuard;
3976 if (nCount == 0)
3977 return;
3978 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
3979 if(nIndex < 0 || nCount <=0 )
3980 throw uno::RuntimeException();
3981 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
3982 OUString sTLName = sw_GetCellName(0, nIndex);
3983 const SwTableBox* pTLBox = pTable->GetTableBox(sTLName);
3984 if(!pTLBox)
3985 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3986 const SwStartNode* pSttNd = pTLBox->GetSttNd();
3987 SwPosition aPos(*pSttNd);
3988 // set cursor to the upper-left cell of the range
3989 auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
3990 pUnoCursor->Move(fnMoveForward, GoInNode);
3991 pUnoCursor->SetRemainInSection( false );
3992 const OUString sBLName = sw_GetCellName(0, nIndex + nCount - 1);
3993 const SwTableBox* pBLBox = pTable->GetTableBox( sBLName );
3994 if(!pBLBox)
3995 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
3996 pUnoCursor->SetMark();
3997 pUnoCursor->GetPoint()->Assign( *pBLBox->GetSttNd() );
3998 pUnoCursor->Move(fnMoveForward, GoInNode);
3999 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
4000 {
4001 // HACK: remove pending actions for selecting old style tables
4002 UnoActionRemoveContext aRemoveContext(rCursor);
4003 }
4004 rCursor.MakeBoxSels();
4005 { // these braces are important
4006 UnoActionContext aAction(pFrameFormat->GetDoc());
4007 pFrameFormat->GetDoc()->DeleteRow(*pUnoCursor);
4008 pUnoCursor.reset();
4009 }
4010 {
4011 // invalidate all actions - TODO: why?
4012 UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4013 }
4014}
4015
4017{
4018 if(rHint.GetId() == SfxHintId::Dying)
4019 m_pFrameFormat = nullptr;
4020}
4021
4022// SwXTableColumns
4023
4025{
4027 public:
4028 explicit Impl(SwFrameFormat& rFrameFormat) : m_pFrameFormat(&rFrameFormat)
4029 {
4030 StartListening(rFrameFormat.GetNotifier());
4031 }
4032 SwFrameFormat* GetFrameFormat() { return m_pFrameFormat; }
4033 virtual void Notify(const SfxHint&) override;
4034};
4035
4037 { return "SwXTableColumns"; }
4038
4039sal_Bool SwXTableColumns::supportsService(const OUString& rServiceName)
4040 { return cppu::supportsService(this, rServiceName); }
4041
4043 { return { "com.sun.star.text.TableColumns"}; }
4044
4045
4047 m_pImpl(new SwXTableColumns::Impl(rFrameFormat))
4048{ }
4049
4051{ }
4052
4054{
4055 return m_pImpl->GetFrameFormat();
4056}
4057
4059{
4060 SolarMutexGuard aGuard;
4061 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4062 SwTable* pTable = SwTable::FindTable( pFrameFormat );
4063// if(!pTable->IsTableComplex())
4064// throw uno::RuntimeException("Table too complex", static_cast<cppu::OWeakObject*>(this));
4065 SwTableLines& rLines = pTable->GetTabLines();
4066 SwTableLine* pLine = rLines.front();
4067 return pLine->GetTabBoxes().size();
4068}
4069
4071{
4072 SolarMutexGuard aGuard;
4073 if(nIndex < 0 || getCount() <= nIndex)
4074 throw lang::IndexOutOfBoundsException();
4075 return uno::Any(uno::Reference<uno::XInterface>()); // i#21699 not supported
4076}
4077
4079{
4081}
4082
4084{
4085 SolarMutexGuard aGuard;
4086 lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this));
4087 return true;
4088}
4089
4091void SwXTableColumns::insertByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4092{
4093 SolarMutexGuard aGuard;
4094 if (nCount == 0)
4095 return;
4096 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4097 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4098 SwTableLines& rLines = pTable->GetTabLines();
4099 SwTableLine* pLine = rLines.front();
4100 const size_t nColCount = pLine->GetTabBoxes().size();
4101 if (nCount <= 0 || 0 > nIndex || o3tl::make_unsigned(nIndex) > nColCount)
4102 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4103 const OUString sTLName = sw_GetCellName(nIndex, 0);
4104 const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4105 bool bAppend = false;
4106 if(!pTLBox)
4107 {
4108 bAppend = true;
4109 // to append at the end the cursor must be in the last line
4110 SwTableBoxes& rBoxes = pLine->GetTabBoxes();
4111 pTLBox = rBoxes.back();
4112 }
4113 if(!pTLBox)
4114 throw uno::RuntimeException("Illegal arguments", static_cast<cppu::OWeakObject*>(this));
4115 const SwStartNode* pSttNd = pTLBox->GetSttNd();
4116 SwPosition aPos(*pSttNd);
4117 UnoActionContext aAction(pFrameFormat->GetDoc());
4118 auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4119 pUnoCursor->Move(fnMoveForward, GoInNode);
4120
4121 {
4122 // remove actions - TODO: why?
4123 UnoActionRemoveContext aRemoveContext(&pUnoCursor->GetDoc());
4124 }
4125
4126 pFrameFormat->GetDoc()->InsertCol(*pUnoCursor, o3tl::narrowing<sal_uInt16>(nCount), bAppend);
4127}
4128
4130void SwXTableColumns::removeByIndex(sal_Int32 nIndex, sal_Int32 nCount)
4131{
4132 SolarMutexGuard aGuard;
4133 if (nCount == 0)
4134 return;
4135 SwFrameFormat* pFrameFormat(lcl_EnsureCoreConnected(GetFrameFormat(), static_cast<cppu::OWeakObject*>(this)));
4136 if(nIndex < 0 || nCount <=0 )
4137 throw uno::RuntimeException();
4138 SwTable* pTable = lcl_EnsureTableNotComplex(SwTable::FindTable(pFrameFormat), static_cast<cppu::OWeakObject*>(this));
4139 const OUString sTLName = sw_GetCellName(nIndex, 0);
4140 const SwTableBox* pTLBox = pTable->GetTableBox( sTLName );
4141 if(!pTLBox)
4142 throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4143 const SwStartNode* pSttNd = pTLBox->GetSttNd();
4144 SwPosition aPos(*pSttNd);
4145 // set cursor to the upper-left cell of the range
4146 auto pUnoCursor(pFrameFormat->GetDoc()->CreateUnoCursor(aPos, true));
4147 pUnoCursor->Move(fnMoveForward, GoInNode);
4148 pUnoCursor->SetRemainInSection(false);
4149 const OUString sTRName = sw_GetCellName(nIndex + nCount - 1, 0);
4150 const SwTableBox* pTRBox = pTable->GetTableBox(sTRName);
4151 if(!pTRBox)
4152 throw uno::RuntimeException("Cell not found", static_cast<cppu::OWeakObject*>(this));
4153 pUnoCursor->SetMark();
4154 pUnoCursor->GetPoint()->Assign( *pTRBox->GetSttNd() );
4155 pUnoCursor->Move(fnMoveForward, GoInNode);
4156 SwUnoTableCursor& rCursor = dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
4157 {
4158 // HACK: remove pending actions for selecting old style tables
4159 UnoActionRemoveContext aRemoveContext(rCursor);
4160 }
4161 rCursor.MakeBoxSels();
4162 { // these braces are important
4163 UnoActionContext aAction(pFrameFormat->GetDoc());
4164 pFrameFormat->GetDoc()->DeleteCol(*pUnoCursor);
4165 pUnoCursor.reset();
4166 }
4167 {
4168 // invalidate all actions - TODO: why?
4169 UnoActionRemoveContext aRemoveContext(pFrameFormat->GetDoc());
4170 }
4171}
4172
4174{
4175 if(rHint.GetId() == SfxHintId::Dying)
4176 m_pFrameFormat = nullptr;
4177}
4178
4179/* 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:451
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.
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
virtual const SwDoc * GetDoc() const =0
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 Broadcast(const SfxHint &rHint)
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:1984
SwFEShell * GetFEShell()
For Core - it knows the DocShell but not the WrtShell!
Definition: docsh.cxx:1225
Definition: doc.hxx:192
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:1690
void UpdateCharts(const OUString &rName) const
Definition: docchart.cxx:141
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:395
TableMergeErr MergeTable(SwPaM &rPam)
Definition: ndtbl.cxx:2209
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:1907
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:341
void SetAttr(const SfxPoolItem &, SwFormat &)
Set attribute in given format.1y If Undo is enabled, the old values is added to the Undo history.
Definition: docfmt.cxx:451
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:316
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:145
SwNodes & GetNodes()
Definition: doc.hxx:413
IDocumentFieldsAccess const & getIDocumentFieldsAccess() const
Definition: doc.cxx:358
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:336
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:406
bool IsNumberFormat(const OUString &rString, sal_uInt32 &F_Index, double &fOutNumber)
Definition: ndtbl.cxx:4016
SwTableFormat * FindTableFormatByName(const OUString &rName, bool bAll=false) const
Definition: ndtbl.cxx:3947
void SetTabCols(const SwTabCols &rNew, bool bCurRowOnly, const SwCellFrame *pBoxFrame)
Definition: ndtbl.cxx:2704
void SetTableBoxFormulaAttrs(SwTableBox &rBox, const SfxItemSet &rSet)
Definition: ndtbl.cxx:4171
void InsertRow(const SwCursor &rCursor, sal_uInt16 nCnt=1, bool bBehind=true)
Definition: ndtbl.cxx:1748
bool SplitTable(const SwSelBoxes &rBoxes, bool bVert, sal_uInt16 nCnt, bool bSameHeight=false)
Split up/merge Boxes in the Table.
Definition: ndtbl.cxx:2143
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1774
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:1931
const SwAttrPool & GetAttrPool() const
Definition: doc.hxx:1322
void DeleteRow(const SwCursor &rCursor)
Deleting Columns/Rows.
Definition: ndtbl.cxx:1807
void SetRowsToRepeat(SwTable &rTable, sal_uInt16 nSet)
Definition: ndtbl.cxx:2906
void SetBoxAttr(const SwCursor &rCursor, const SfxPoolItem &rNew)
Definition: ndtbl1.cxx:1276
const SwFrameFormats * GetTableFrameFormats() const
Definition: doc.hxx:815
SvNumberFormatter * GetNumberFormatter(bool bCreate=true)
Definition: doc.hxx:1414
SwDocShell * GetDocShell()
Definition: doc.hxx:1355
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:3721
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:1310
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:620
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:108
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:449
const SvxULSpaceItem & GetULSpace(bool=true) const
Definition: frmatr.hxx:76
std::unique_ptr< SvxBrushItem > makeBackgroundBrushItem(bool=true) const
Definition: format.cxx:738
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:2568
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:1798
void InvalidatePos()
Definition: frame.hxx:1043
TElementType * Next()
Definition: calbck.hxx:364
TElementType * First()
Definition: calbck.hxx:356
void LockModify()
Definition: calbck.hxx:208
void UnlockModify()
Definition: calbck.hxx:209
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:84
SwStartNode * GetStartNode()
Definition: node.hxx:619
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:876
SwNodeOffset GetIndex() const
Definition: node.hxx:296
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:202
bool IsSectionNode() const
Definition: node.hxx:672
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:370
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:981
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:137
bool IsOLENode() const
Definition: node.hxx:680
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:710
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:158
const OUString & GetChartTableName() const
Definition: ndole.hxx:155
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:612
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:638
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
const SwSection & GetSection() const
Definition: node.hxx:567
SwSectionFormat * GetFormat()
Definition: section.hxx:337
Starts a section of nodes in the document model.
Definition: node.hxx:325
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:419
SwNodeOffset IsValidNumTextNd(bool bCheckAttr=true) const
Definition: swtable.cxx:2653
sal_uInt16 IsFormulaOrValueBox() const
Definition: swtable.cxx:2736
sal_Int32 getRowSpan() const
Definition: swtable.hxx:514
void setRowSpan(sal_Int32 nNewRowSpan)
Definition: swtable.cxx:77
OUString GetName() const
Definition: swtable.cxx:1996
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:457
SwTableLines & GetTabLines()
Definition: swtable.hxx:450
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:471
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1901
void DeleteBox(size_t nPos)
Definition: swcrsr.cxx:2512
const SwSelBoxes & GetSelectedBoxes() const
Definition: swcrsr.hxx:280
size_t GetSelectedBoxesCount() const
Definition: swcrsr.hxx:279
void InsertBox(const SwTableBox &rTableBox)
Definition: swcrsr.cxx:2505
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:358
SwFrameFormat * GetFrameFormat()
Definition: swtable.hxx:380
SwFrameFormat * ClaimFrameFormat()
Definition: swtable.cxx:1478
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:368
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:521
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTableNode * GetTableNode() const
Definition: swtable.cxx:2111
const OUString & GetTableStyleName() const
Return the table style name of this table.
Definition: swtable.hxx:191
SwTableLines & GetTabLines()
Definition: swtable.hxx:201
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:204
bool IsTableComplex() const
Definition: swtable.cxx:1441
void SetTableStyleName(const OUString &rName)
Set the new table style name for this table.
Definition: swtable.hxx:194
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:2104
sal_uInt16 GetRowsToRepeat() const
Definition: swtable.hxx:196
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:262
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:86
void SetCountedInList(bool bCounted)
Definition: ndtxt.cxx:4316
const SfxItemPropertySet * GetPropertySet(sal_uInt16 PropertyId)
Definition: unomap1.cxx:1066
SwCursor & GetSelRing()
Definition: unocrsr.hxx:101
void MakeBoxSels()
Definition: unocrsr.cxx:184
static ShellResource * GetShellRes()
Definition: viewsh.cxx:2662
void SetLabelDescriptions(SwXCellRange &rThis, const css::uno::Sequence< OUString > &rDesc, bool bRow)
Definition: unotbl.cxx:3737
::comphelper::OInterfaceContainerHelper4< chart::XChartDataChangeEventListener > m_ChartListeners
Definition: unotbl.cxx:3130
std::tuple< sal_uInt32, sal_uInt32, sal_uInt32, sal_uInt32 > GetLabelCoordinates(bool bRow)
Definition: unotbl.cxx:3691
const SfxItemPropertySet * m_pPropSet
Definition: unotbl.cxx:3135
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:3125
Impl(sw::UnoCursorPointer const &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3140
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:3152
bool m_bFirstColumnAsLabel
Definition: unotbl.cxx:3138
sal_Int32 GetRowCount() const
Definition: unotbl.cxx:3818
sal_Int32 GetColumnCount() const
Definition: unotbl.cxx:3813
uno::WeakReference< uno::XInterface > m_wThis
Definition: unotbl.cxx:3128
sw::UnoCursorPointer m_pTableCursor
Definition: unotbl.cxx:3132
uno::Sequence< OUString > GetLabelDescriptions(SwXCellRange &rThis, bool bRow)
Definition: unotbl.cxx:3709
SwRangeDescriptor m_RangeDescriptor
Definition: unotbl.cxx:3134
std::mutex m_Mutex
Definition: unotbl.cxx:3129
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:3829
virtual void SAL_CALL sort(const css::uno::Sequence< css::beans::PropertyValue > &xDescriptor) override
Definition: unotbl.cxx:3799
::sw::UnoImplPtr< Impl > m_pImpl
Definition: unotbl.hxx:369
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:3187
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotbl.cxx:3181
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:3193
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:3190
virtual css::uno::Sequence< OUString > SAL_CALL getColumnDescriptions() override
Definition: unotbl.cxx:3732
virtual void SAL_CALL setRowDescriptions(const css::uno::Sequence< OUString > &aRowDescriptions) override
Definition: unotbl.cxx:3759
virtual css::uno::Sequence< css::uno::Sequence< double > > SAL_CALL getData() override
Definition: unotbl.cxx:3625
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL createSortDescriptor() override
Definition: unotbl.cxx:3793
virtual void SAL_CALL setColumnDescriptions(const css::uno::Sequence< OUString > &aColumnDescriptions) override
Definition: unotbl.cxx:3765
virtual css::uno::Reference< css::table::XCell > SAL_CALL getCellByPosition(sal_Int32 nColumn, sal_Int32 nRow) override
Definition: unotbl.cxx:3245
virtual double SAL_CALL getNotANumber() override
Definition: unotbl.cxx:3790
std::vector< css::uno::Reference< css::table::XCell > > GetCells()
Definition: unotbl.cxx:3231
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:3553
static ::rtl::Reference< SwXCellRange > CreateXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3215
virtual ~SwXCellRange() override
Definition: unotbl.cxx:3211
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:3341
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:3268
void SetLabels(bool bFirstRowAsLabel, bool bFirstColumnAsLabel)
Definition: unotbl.cxx:3225
virtual sal_Bool SAL_CALL isNotANumber(double nNumber) override
Definition: unotbl.cxx:3787
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unotbl.cxx:3550
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotbl.cxx:3348
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:3468
const SwUnoCursor * GetTableCursor() const
Definition: unotbl.cxx:3823
SwXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3205
virtual css::uno::Reference< css::table::XCellRange > SAL_CALL getCellRangeByName(const OUString &aRange) override
Definition: unotbl.cxx:3321
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3556
virtual void SAL_CALL setDataArray(const css::uno::Sequence< css::uno::Sequence< css::uno::Any > > &aArray) override
Definition: unotbl.cxx:3590
virtual void SAL_CALL removeChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &aListener) override
Definition: unotbl.cxx:3779
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unotbl.cxx:3175
virtual void SAL_CALL addChartDataChangeEventListener(const css::uno::Reference< css::chart::XChartDataChangeEventListener > &aListener) override
Definition: unotbl.cxx:3771
virtual void SAL_CALL setData(const css::uno::Sequence< css::uno::Sequence< double > > &aData) override
Definition: unotbl.cxx:3658
virtual css::uno::Sequence< css::uno::Sequence< css::uno::Any > > SAL_CALL getDataArray() override
Definition: unotbl.cxx:3563
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:3559
virtual css::uno::Sequence< OUString > SAL_CALL getRowDescriptions() override
Definition: unotbl.cxx:3727
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unotbl.cxx:752
virtual double SAL_CALL getValue() override
Definition: unotbl.cxx:871
virtual sal_Int32 SAL_CALL getError() override
Definition: unotbl.cxx:910
virtual const SwStartNode * GetStartNode() const override
Definition: unotbl.cxx:790
css::uno::Reference< css::text::XText > m_xParentText
Definition: unotbl.hxx:74
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unotbl.cxx:949
virtual void SAL_CALL acquire() noexcept override
Definition: unotbl.cxx:770
double GetForcedNumericalValue() const
Definition: unotbl.cxx:1174
virtual css::uno::Sequence< css::uno::Type > SAL_CALL getTypes() override
Definition: unotbl.cxx:757
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor() override
Definition: unotbl.cxx:801
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:1225
css::uno::Any GetAny() const
Definition: unotbl.cxx:1215
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unotbl.cxx:1110
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unotbl.cxx:746
virtual css::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId() override
Definition: unotbl.cxx:765
SwTableBox * FindBox(SwTable *pTable, SwTableBox *pBox)
search if a box exists in a table
Definition: unotbl.cxx:1154
virtual void SAL_CALL setString(const OUString &aString) override
Definition: unotbl.cxx:904
friend void sw_setValue(SwXCell &rCell, double nVal)
Definition: unotbl.cxx:686
bool IsValid() const
Definition: unotbl.cxx:806
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:1084
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unotbl.cxx:955
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1093
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursor() override
Definition: unotbl.cxx:917
SwTableBox * GetTableBox() const
Definition: unotbl.hxx:143
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:1120
size_t m_nFndPos
Definition: unotbl.hxx:73
virtual void SAL_CALL setValue(double nValue) override
Definition: unotbl.cxx:880
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unotbl.cxx:1087
virtual OUString SAL_CALL getFormula() override
Definition: unotbl.cxx:828
const SwStartNode * m_pStartNode
Definition: unotbl.hxx:69
SwFrameFormat * m_pTableFormat
Definition: unotbl.hxx:70
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unotbl.cxx:1231
virtual void SAL_CALL setFormula(const OUString &aFormula) override
Definition: unotbl.cxx:840
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:1115
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unotbl.cxx:1021
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unotbl.cxx:1096
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unotbl.cxx:1090
SwFrameFormat * GetFrameFormat() const
Definition: unotbl.hxx:146
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1133
virtual void SAL_CALL release() noexcept override
Definition: unotbl.cxx:775
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
Definition: unotbl.cxx:782
static size_t const NOTFOUND
Definition: unotbl.hxx:75
const SfxItemPropertySet * m_pPropSet
Definition: unotbl.hxx:67
virtual css::uno::Reference< css::text::XTextCursor > SAL_CALL createTextCursorByRange(const css::uno::Reference< css::text::XTextRange > &aTextPosition) override
Definition: unotbl.cxx:931
SwTableBox * m_pBox
Definition: unotbl.hxx:68
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unotbl.cxx:1228
SwXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, size_t nPos)
Definition: unotbl.cxx:718
virtual css::table::CellContentType SAL_CALL getType() override
Definition: unotbl.cxx:886
static css::uno::Sequence< css::beans::PropertyValue > CreateRedlineProperties(SwRangeRedline const &rRedline, bool const bIsStart)
Definition: unoredline.cxx:284
SwFrameFormat * GetFrameFormat()
Definition: unotbl.cxx:4032
Impl(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4028
SwFrameFormat * m_pFrameFormat
Definition: unotbl.cxx:4026
virtual void Notify(const SfxHint &) override
Definition: unotbl.cxx:4173
virtual ~SwXTableColumns() override
Definition: unotbl.cxx:4050
virtual OUString SAL_CALL getImplementationName() override
Definition: unotbl.cxx:4036
virtual sal_Bool SAL_CALL hasElements() override
Definition: unotbl.cxx:4083
virtual sal_Int32 SAL_CALL getCount() override
Definition: unotbl.cxx:4058
SwXTableColumns(SwFrameFormat &rFrameFormat)
Definition: unotbl.cxx:4046
virtual void SAL_CALL insertByIndex(sal_Int32 nIndex, sal_Int32 nCount) override
Definition: unotbl.cxx:4091
::sw::UnoImplPtr< Impl > m_pImpl
Definition: