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