LibreOffice Module sw (master)  1
unochart.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 <algorithm>
21 #include <string_view>
22 
23 #include <com/sun/star/chart/ChartDataRowSource.hpp>
24 #include <com/sun/star/chart2/data/LabelOrigin.hpp>
25 #include <com/sun/star/embed/XEmbeddedObject.hpp>
26 #include <com/sun/star/frame/XModel.hpp>
28 #include <osl/mutex.hxx>
29 #include <vcl/svapp.hxx>
30 
31 #include "XMLRangeHelper.hxx"
32 #include <unochart.hxx>
33 #include <swtable.hxx>
34 #include <unoprnms.hxx>
35 #include <unomap.hxx>
36 #include <unocrsr.hxx>
37 #include <unotbl.hxx>
38 #include <doc.hxx>
40 #include <frmfmt.hxx>
41 #include <ndole.hxx>
42 #include <swtypes.hxx>
43 #include <strings.hrc>
45 #include <comphelper/string.hxx>
46 #include <svl/itemprop.hxx>
47 
48 using namespace ::com::sun::star;
49 
51 {
52  if (!pDoc)
53  return;
54 
55  SwOLENode *pONd;
56  SwStartNode *pStNd;
58  while( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
59  {
60  ++aIdx;
61  if (nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) &&
62  pONd->GetOLEObj().GetObject().IsChart() )
63  {
64  // Load the object and set modified
65 
66  uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
68  {
69  try
70  {
71  uno::Reference< util::XModifiable > xModif( xIP->getComponent(), uno::UNO_QUERY_THROW );
72  xModif->setModified( true );
73  }
74  catch ( uno::Exception& )
75  {
76  }
77 
78  }
79  }
80  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
81  }
82 }
83 
85  m_pDoc( pDocument )
86  , m_aUnlockTimer( "sw::SwChartLockController_Helper aUnlockTimer" )
87  , m_bIsLocked( false )
88 {
89  m_aUnlockTimer.SetTimeout( 1500 );
91 }
92 
94 {
95  if (m_pDoc) // still connected?
96  Disconnect();
97 }
98 
100 {
101  if (!m_bIsLocked)
102  LockAllCharts();
103  m_aUnlockTimer.Start(); // start or continue time of locking
104 }
105 
107 {
109  UnlockAllCharts();
110  m_pDoc = nullptr;
111 }
112 
114 {
115  if (!m_pDoc)
116  return;
117 
118  uno::Reference< frame::XModel > xRes;
119  SwOLENode *pONd;
120  SwStartNode *pStNd;
122  while( nullptr != (pStNd = aIdx.GetNode().GetStartNode()) )
123  {
124  ++aIdx;
125  if (nullptr != ( pONd = aIdx.GetNode().GetOLENode() ) &&
126  !pONd->GetChartTableName().isEmpty() /* is chart object? */)
127  {
128  uno::Reference < embed::XEmbeddedObject > xIP = pONd->GetOLEObj().GetOleRef();
130  {
131  xRes.set( xIP->getComponent(), uno::UNO_QUERY );
132  if (xRes.is())
133  {
134  if (bLock)
135  xRes->lockControllers();
136  else
137  xRes->unlockControllers();
138  }
139  }
140  }
141  aIdx.Assign( *pStNd->EndOfSectionNode(), + 1 );
142  }
143 
144  m_bIsLocked = bLock;
145 }
146 
147 IMPL_LINK_NOARG( SwChartLockController_Helper, DoUnlockAllCharts, Timer *, void )
148 {
149  UnlockAllCharts();
150 }
151 
152 static osl::Mutex & GetChartMutex()
153 {
154  static osl::Mutex aMutex;
155  return aMutex;
156 }
157 
160  const uno::Reference< uno::XInterface > &rxI )
161 {
162  lang::EventObject aEvtObj( rxI );
164  while (aIt.hasMoreElements())
165  {
166  uno::Reference< util::XModifyListener > xRef( aIt.next(), uno::UNO_QUERY );
167  if (xRef.is())
168  xRef->modified( aEvtObj );
169  }
170 }
171 
178  SwRangeDescriptor &rDesc,
179  const OUString &rCellRangeName )
180 {
181  sal_Int32 nToken = -1 == rCellRangeName.indexOf('.') ? 0 : 1;
182  OUString aCellRangeNoTableName( rCellRangeName.getToken( nToken, '.' ) );
183  OUString aTLName( aCellRangeNoTableName.getToken(0, ':') ); // name of top left cell
184  OUString aBRName( aCellRangeNoTableName.getToken(1, ':') ); // name of bottom right cell
185  if(aTLName.isEmpty() || aBRName.isEmpty())
186  return false;
187 
188  rDesc.nTop = rDesc.nLeft = rDesc.nBottom = rDesc.nRight = -1;
189  SwXTextTable::GetCellPosition( aTLName, rDesc.nLeft, rDesc.nTop );
190  SwXTextTable::GetCellPosition( aBRName, rDesc.nRight, rDesc.nBottom );
191  rDesc.Normalize();
192  OSL_ENSURE( rDesc.nTop != -1 &&
193  rDesc.nLeft != -1 &&
194  rDesc.nBottom != -1 &&
195  rDesc.nRight != -1,
196  "failed to get range descriptor" );
197  OSL_ENSURE( rDesc.nTop <= rDesc.nBottom && rDesc.nLeft <= rDesc.nRight,
198  "invalid range descriptor");
199  return true;
200 }
201 
202 static OUString GetCellRangeName( const SwFrameFormat &rTableFormat, SwUnoCursor &rTableCursor )
203 {
204  OUString aRes;
205 
207 
208  SwUnoTableCursor* pUnoTableCursor = dynamic_cast<SwUnoTableCursor*>(&rTableCursor);
209  if (!pUnoTableCursor)
210  return OUString();
211  pUnoTableCursor->MakeBoxSels();
212 
213  const SwStartNode* pStart;
214  const SwTableBox* pStartBox = nullptr;
215  const SwTableBox* pEndBox = nullptr;
216 
217  pStart = pUnoTableCursor->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
218  if (pStart)
219  {
220  const SwTable* pTable = SwTable::FindTable( &rTableFormat );
221  pEndBox = pTable->GetTableBox( pStart->GetIndex());
222  aRes = pEndBox->GetName();
223 
224  if(pUnoTableCursor->HasMark())
225  {
226  pStart = pUnoTableCursor->GetMark()->nNode.GetNode().FindTableBoxStartNode();
227  pStartBox = pTable->GetTableBox( pStart->GetIndex());
228  }
229  OSL_ENSURE( pStartBox, "start box not found" );
230  OSL_ENSURE( pEndBox, "end box not found" );
231 
232  // need to switch start and end?
233  if (*pUnoTableCursor->GetPoint() < *pUnoTableCursor->GetMark())
234  {
235  const SwTableBox* pTmpBox = pStartBox;
236  pStartBox = pEndBox;
237  pEndBox = pTmpBox;
238  }
239 
240  if (!pStartBox)
241  return aRes;
242 
243  aRes = pStartBox->GetName() + ":";
244  if (pEndBox)
245  aRes += pEndBox->GetName();
246  else
247  aRes += pStartBox->GetName();
248  }
249 
250  return aRes;
251 }
252 
253 static OUString GetRangeRepFromTableAndCells( std::u16string_view rTableName,
254  std::u16string_view rStartCell, std::u16string_view rEndCell,
255  bool bForceEndCellName )
256 {
257  OSL_ENSURE( !rTableName.empty(), "table name missing" );
258  OSL_ENSURE( !rStartCell.empty(), "cell name missing" );
259  OUString aRes = OUString::Concat(rTableName) + "." + rStartCell;
260 
261  if (!rEndCell.empty())
262  {
263  aRes += OUString::Concat(":") + rEndCell;
264  }
265  else if (bForceEndCellName)
266  {
267  aRes += OUString::Concat(":") + rStartCell;
268  }
269 
270  return aRes;
271 }
272 
274  const OUString &rRangeRepresentation,
275  OUString &rTableName,
276  OUString &rStartCell,
277  OUString &rEndCell,
278  bool bSortStartEndCells = true )
279 {
280  // parse range representation for table name and cell/range names
281  // accepted format sth like: "Table1.A2:C5" , "Table2.A2.1:B3.2"
282  OUString aTableName; // table name
283  OUString aStartCell; // name of top left cell
284  OUString aEndCell; // name of bottom right cell
285  sal_Int32 nIdx = rRangeRepresentation.indexOf( '.' );
286  if (nIdx >= 0)
287  {
288  aTableName = rRangeRepresentation.copy( 0, nIdx );
289  OUString aRange = rRangeRepresentation.copy( nIdx + 1 ); // cell range
290  sal_Int32 nPos = aRange.indexOf( ':' );
291  if (nPos >= 0) // a cell-range like "Table1.A2:D4"
292  {
293  aStartCell = aRange.copy( 0, nPos );
294  aEndCell = aRange.copy( nPos + 1 );
295 
296  // need to switch start and end cell ?
297  // (does not check for normalization here)
298  if (bSortStartEndCells && 1 == sw_CompareCellsByColFirst( aStartCell, aEndCell ))
299  {
300  OUString aTmp( aStartCell );
301  aStartCell = aEndCell;
302  aEndCell = aTmp;
303  }
304  }
305  else // a single cell like in "Table1.B3"
306  {
307  aStartCell = aEndCell = aRange;
308  }
309  }
310 
311  bool bSuccess = !aTableName.isEmpty() &&
312  !aStartCell.isEmpty() && !aEndCell.isEmpty();
313  if (bSuccess)
314  {
315  rTableName = aTableName;
316  rStartCell = aStartCell;
317  rEndCell = aEndCell;
318  }
319  return bSuccess;
320 }
321 
322 static void GetTableByName( const SwDoc &rDoc, std::u16string_view rTableName,
323  SwFrameFormat **ppTableFormat, SwTable **ppTable)
324 {
325  SwFrameFormat *pTableFormat = nullptr;
326 
327  // find frame format of table
329  const size_t nCount = rDoc.GetTableFrameFormatCount(true);
330  for (size_t i = 0; i < nCount && !pTableFormat; ++i)
331  {
332  SwFrameFormat& rTableFormat = rDoc.GetTableFrameFormat(i, true);
333  if(rTableName == rTableFormat.GetName())
334  pTableFormat = &rTableFormat;
335  }
336 
337  if (ppTableFormat)
338  *ppTableFormat = pTableFormat;
339 
340  if (ppTable)
341  *ppTable = pTableFormat ? SwTable::FindTable( pTableFormat ) : nullptr;
342 }
343 
345  const SwDoc *pDoc,
346  const OUString &rRangeRepresentation, // must be a single range (i.e. so called sub-range)
347  SwFrameFormat **ppTableFormat, // will be set to the table format of the table used in the range representation
348  std::shared_ptr<SwUnoCursor>& rpUnoCursor ) // will be set to cursor spanning the cell range (cursor will be created!)
349 {
350  OUString aTableName; // table name
351  OUString aStartCell; // name of top left cell
352  OUString aEndCell; // name of bottom right cell
353  bool bNamesFound = GetTableAndCellsFromRangeRep( rRangeRepresentation,
354  aTableName, aStartCell, aEndCell );
355 
356  if (!bNamesFound)
357  {
358  if (ppTableFormat)
359  *ppTableFormat = nullptr;
360  rpUnoCursor.reset();
361  }
362  else
363  {
364  SwFrameFormat *pTableFormat = nullptr;
365 
366  // is the correct table format already provided?
367  if (*ppTableFormat != nullptr && (*ppTableFormat)->GetName() == aTableName)
368  pTableFormat = *ppTableFormat;
369  else
370  GetTableByName( *pDoc, aTableName, &pTableFormat, nullptr );
371 
372  *ppTableFormat = pTableFormat;
373 
374  rpUnoCursor.reset(); // default result in case of failure
375 
376  SwTable *pTable = pTableFormat ? SwTable::FindTable( pTableFormat ) : nullptr;
377  // create new SwUnoCursor spanning the specified range
379  // #i80314#
380  // perform validation check. Thus, pass <true> as 2nd parameter to <SwTable::GetTableBox(..)>
381  const SwTableBox* pTLBox =
382  pTable ? pTable->GetTableBox( aStartCell, true ) : nullptr;
383  if(pTLBox)
384  {
385  const SwStartNode* pSttNd = pTLBox->GetSttNd();
386  SwPosition aPos(*pSttNd);
387 
388  // set cursor to top left box of range
389  auto pUnoCursor = pTableFormat->GetDoc()->CreateUnoCursor(aPos, true);
390  pUnoCursor->Move( fnMoveForward, GoInNode );
391  pUnoCursor->SetRemainInSection( false );
392 
393  // #i80314#
394  // perform validation check. Thus, pass <true> as 2nd parameter to <SwTable::GetTableBox(..)>
395  const SwTableBox* pBRBox = pTable->GetTableBox( aEndCell, true );
396  if(pBRBox)
397  {
398  pUnoCursor->SetMark();
399  pUnoCursor->GetPoint()->nNode = *pBRBox->GetSttNd();
400  pUnoCursor->Move( fnMoveForward, GoInNode );
401  SwUnoTableCursor& rCursor =
402  dynamic_cast<SwUnoTableCursor&>(*pUnoCursor);
403  // HACK: remove pending actions for old style tables
404  UnoActionRemoveContext aRemoveContext(rCursor);
405  rCursor.MakeBoxSels();
406  rpUnoCursor = pUnoCursor;
407  }
408  }
409  }
410 }
411 
412 static bool GetSubranges( const OUString &rRangeRepresentation,
413  uno::Sequence< OUString > &rSubRanges, bool bNormalize )
414 {
415  bool bRes = true;
416  const sal_Int32 nLen = comphelper::string::getTokenCount(rRangeRepresentation, ';');
417  uno::Sequence< OUString > aRanges( nLen );
418 
419  sal_Int32 nCnt = 0;
420  if (nLen != 0)
421  {
422  OUString *pRanges = aRanges.getArray();
423  OUString aFirstTable;
424  sal_Int32 nPos = 0;
425  for( sal_Int32 i = 0; i < nLen && bRes; ++i )
426  {
427  const OUString aRange( rRangeRepresentation.getToken( 0, ';', nPos ) );
428  if (!aRange.isEmpty())
429  {
430  pRanges[nCnt] = aRange;
431 
432  OUString aTableName, aStartCell, aEndCell;
433  if (!GetTableAndCellsFromRangeRep( aRange,
434  aTableName, aStartCell, aEndCell ))
435  bRes = false;
436 
437  if (bNormalize)
438  {
439  sw_NormalizeRange( aStartCell, aEndCell );
440  pRanges[nCnt] = GetRangeRepFromTableAndCells( aTableName,
441  aStartCell, aEndCell, true );
442  }
443 
444  // make sure to use only a single table
445  if (nCnt == 0)
446  aFirstTable = aTableName;
447  else
448  if (aFirstTable != aTableName) bRes = false;
449 
450  ++nCnt;
451  }
452  }
453  }
454  aRanges.realloc( nCnt );
455 
456  rSubRanges = aRanges;
457  return bRes;
458 }
459 
460 static void SortSubranges( uno::Sequence< OUString > &rSubRanges, bool bCmpByColumn )
461 {
462  sal_Int32 nLen = rSubRanges.getLength();
463  OUString *pSubRanges = rSubRanges.getArray();
464 
465  OUString aSmallestTableName;
466  OUString aSmallestStartCell;
467  OUString aSmallestEndCell;
468 
469  for (sal_Int32 i = 0; i < nLen; ++i)
470  {
471  sal_Int32 nIdxOfSmallest = i;
472  GetTableAndCellsFromRangeRep( pSubRanges[nIdxOfSmallest],
473  aSmallestTableName, aSmallestStartCell, aSmallestEndCell );
474  if (aSmallestEndCell.isEmpty())
475  aSmallestEndCell = aSmallestStartCell;
476 
477  for (sal_Int32 k = i+1; k < nLen; ++k)
478  {
479  // get cell names for sub range
480  OUString aTableName;
481  OUString aStartCell;
482  OUString aEndCell;
483  GetTableAndCellsFromRangeRep( pSubRanges[k],
484  aTableName, aStartCell, aEndCell );
485  if (aEndCell.isEmpty())
486  aEndCell = aStartCell;
487 
488  // compare cell ranges ( is the new one smaller? )
489  if (-1 == sw_CompareCellRanges( aStartCell, aEndCell,
490  aSmallestStartCell, aSmallestEndCell, bCmpByColumn ))
491  {
492  nIdxOfSmallest = k;
493  aSmallestTableName = aTableName;
494  aSmallestStartCell = aStartCell;
495  aSmallestEndCell = aEndCell;
496  }
497  }
498 
499  // move smallest element to the start of the not sorted area
500  const OUString aTmp( pSubRanges[ nIdxOfSmallest ] );
501  pSubRanges[ nIdxOfSmallest ] = pSubRanges[ i ];
502  pSubRanges[ i ] = aTmp;
503  }
504 }
505 
507  m_aEventListeners( GetChartMutex() ),
508  m_pDoc( &rSwDoc )
509 {
510  m_bDisposed = false;
511 }
512 
514 {
515 }
516 
517 uno::Reference< chart2::data::XDataSource > SwChartDataProvider::Impl_createDataSource(
518  const uno::Sequence< beans::PropertyValue >& rArguments, bool bTestOnly )
519 {
520  SolarMutexGuard aGuard;
521  if (m_bDisposed)
522  throw lang::DisposedException();
523 
524  uno::Reference< chart2::data::XDataSource > xRes;
525 
526  if (!m_pDoc)
527  throw uno::RuntimeException("Not connected to a document.");
528 
529  // get arguments
530  OUString aRangeRepresentation;
531  uno::Sequence< sal_Int32 > aSequenceMapping;
532  bool bFirstIsLabel = false;
533  bool bDtaSrcIsColumns = true; // true : DataSource will be sequence of columns
534  // false: DataSource will be sequence of rows
535 
536  OUString aChartOleObjectName; //work around wrong writer ranges ( see Issue 58464 )
537  sal_Int32 nArgs = rArguments.getLength();
538  OSL_ENSURE( nArgs != 0, "no properties provided" );
539  if (nArgs == 0)
540  return xRes;
541  for (const beans::PropertyValue& rArg : rArguments)
542  {
543  if ( rArg.Name == "DataRowSource" )
544  {
545  chart::ChartDataRowSource eSource;
546  if (!(rArg.Value >>= eSource))
547  {
548  sal_Int32 nTmp = 0;
549  if (!(rArg.Value >>= nTmp))
550  throw lang::IllegalArgumentException();
551  eSource = static_cast< chart::ChartDataRowSource >( nTmp );
552  }
553  bDtaSrcIsColumns = eSource == chart::ChartDataRowSource_COLUMNS;
554  }
555  else if ( rArg.Name == "FirstCellAsLabel" )
556  {
557  if (!(rArg.Value >>= bFirstIsLabel))
558  throw lang::IllegalArgumentException();
559  }
560  else if ( rArg.Name == "CellRangeRepresentation" )
561  {
562  if (!(rArg.Value >>= aRangeRepresentation))
563  throw lang::IllegalArgumentException();
564  }
565  else if ( rArg.Name == "SequenceMapping" )
566  {
567  if (!(rArg.Value >>= aSequenceMapping))
568  throw lang::IllegalArgumentException();
569  }
570  else if ( rArg.Name == "ChartOleObjectName" )
571  {
572  if (!(rArg.Value >>= aChartOleObjectName))
573  throw lang::IllegalArgumentException();
574  }
575  }
576 
577  uno::Sequence< OUString > aSubRanges;
578  // get sub-ranges and check that they all are from the very same table
579  bool bOk = GetSubranges( aRangeRepresentation, aSubRanges, true );
580 
581  if (!bOk && m_pDoc && !aChartOleObjectName.isEmpty() )
582  {
583  //try to correct the range here
584  //work around wrong writer ranges ( see Issue 58464 )
585  OUString aChartTableName;
586 
587  const SwNodes& rNodes = m_pDoc->GetNodes();
588  for( SwNodeOffset nN = rNodes.Count(); nN--; )
589  {
590  SwNode* pNode = rNodes[nN];
591  if( !pNode )
592  continue;
593  const SwOLENode* pOleNode = pNode->GetOLENode();
594  if( !pOleNode )
595  continue;
596  const SwOLEObj& rOObj = pOleNode->GetOLEObj();
597  if( aChartOleObjectName == rOObj.GetCurrentPersistName() )
598  {
599  aChartTableName = pOleNode->GetChartTableName();
600  break;
601  }
602  }
603 
604  if( !aChartTableName.isEmpty() )
605  {
606  //the wrong range is still shifted one row down
607  //thus the first row is missing and an invalid row at the end is added.
608  //Therefore we need to shift the range one row up
609  SwRangeDescriptor aDesc;
610  if (aRangeRepresentation.isEmpty())
611  return xRes; // we can't handle this thus returning an empty references
612 
613  aRangeRepresentation = aRangeRepresentation.copy( 1 ); // get rid of '.' to have only the cell range left
614  FillRangeDescriptor( aDesc, aRangeRepresentation );
615  aDesc.Normalize();
616 
617  if (aDesc.nTop <= 0) // no chance to shift the range one row up?
618  return xRes; // we can't handle this thus returning an empty references
619 
620  aDesc.nTop -= 1;
621  aDesc.nBottom -= 1;
622 
623  OUString aNewStartCell( sw_GetCellName( aDesc.nLeft, aDesc.nTop ) );
624  OUString aNewEndCell( sw_GetCellName( aDesc.nRight, aDesc.nBottom ) );
625  aRangeRepresentation = GetRangeRepFromTableAndCells(
626  aChartTableName, aNewStartCell, aNewEndCell, true );
627  bOk = GetSubranges( aRangeRepresentation, aSubRanges, true );
628  }
629  }
630  if (!bOk) // different tables used, or incorrect range specifiers
631  throw lang::IllegalArgumentException();
632 
633  SortSubranges( aSubRanges, bDtaSrcIsColumns );
634 
635  // get table format for that single table from above
636  SwFrameFormat *pTableFormat = nullptr; // pointer to table format
637  std::shared_ptr<SwUnoCursor> pUnoCursor; // here required to check if the cells in the range do actually exist
638  if (aSubRanges.hasElements())
639  GetFormatAndCreateCursorFromRangeRep( m_pDoc, aSubRanges[0], &pTableFormat, pUnoCursor );
640 
641  if (!pTableFormat || !pUnoCursor)
642  throw lang::IllegalArgumentException();
643 
644  SwTable* pTable = SwTable::FindTable(pTableFormat);
645  if (pTable->IsTableComplex())
646  return xRes; // we can't handle this thus returning an empty references
647 
648  // get a character map in the size of the table to mark
649  // all the ranges to use in
650  sal_Int32 nRows = pTable->GetTabLines().size();
651  sal_Int32 nCols = pTable->GetTabLines().front()->GetTabBoxes().size();
652  std::vector<std::vector<char>> aMap(nRows);
653  for (sal_Int32 i = 0; i < nRows; ++i)
654  aMap[i].resize(nCols);
655 
656  // iterate over subranges and mark used cells in above map
660  for (const OUString& rSubRange : std::as_const(aSubRanges))
661  {
662  OUString aTableName, aStartCell, aEndCell;
663  bool bOk2 = GetTableAndCellsFromRangeRep(
664  rSubRange, aTableName, aStartCell, aEndCell );
665  OSL_ENSURE(bOk2, "failed to get table and start/end cells");
666 
667  sal_Int32 nStartRow, nStartCol, nEndRow, nEndCol;
668  SwXTextTable::GetCellPosition(aStartCell, nStartCol, nStartRow);
669  SwXTextTable::GetCellPosition(aEndCell, nEndCol, nEndRow);
670  OSL_ENSURE( nStartRow <= nEndRow && nStartCol <= nEndCol,
671  "cell range not normalized");
672 
673  // test if the ranges span more than the available cells
674  if( nStartRow < 0 || nEndRow >= nRows ||
675  nStartCol < 0 || nEndCol >= nCols )
676  {
677  throw lang::IllegalArgumentException();
678  }
679  for (sal_Int32 k1 = nStartRow; k1 <= nEndRow; ++k1)
680  {
681  for (sal_Int32 k2 = nStartCol; k2 <= nEndCol; ++k2)
682  aMap[k1][k2] = 'x';
683  }
684  }
685 
686  // find label and data sequences to use
687 
688  sal_Int32 oi; // outer index (slower changing index)
689  sal_Int32 ii; // inner index (faster changing index)
690  sal_Int32 oiEnd = bDtaSrcIsColumns ? nCols : nRows;
691  sal_Int32 iiEnd = bDtaSrcIsColumns ? nRows : nCols;
692  std::vector<sal_Int32> aLabelIdx(oiEnd);
693  std::vector<sal_Int32> aDataStartIdx(oiEnd);
694  std::vector<sal_Int32> aDataLen(oiEnd);
695  for (oi = 0; oi < oiEnd; ++oi)
696  {
697  aLabelIdx[oi] = -1;
698  aDataStartIdx[oi] = -1;
699  aDataLen[oi] = 0;
700  }
701 
702  for (oi = 0; oi < oiEnd; ++oi)
703  {
704  ii = 0;
705  while (ii < iiEnd)
706  {
707  char &rChar = bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii];
708 
709  // label should be used but is not yet found?
710  if (rChar == 'x' && bFirstIsLabel && aLabelIdx[oi] == -1)
711  {
712  aLabelIdx[oi] = ii;
713  rChar = 'L'; // setting a different char for labels here
714  // makes the test for the data sequence below
715  // easier
716  }
717 
718  // find data sequence
719  if (rChar == 'x' && aDataStartIdx[oi] == -1)
720  {
721  aDataStartIdx[oi] = ii;
722 
723  // get length of data sequence
724  sal_Int32 nL = 0;
725  while (ii< iiEnd && 'x' == (bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]))
726  {
727  ++nL; ++ii;
728  }
729  aDataLen[oi] = nL;
730 
731  // check that there is no other separate sequence of data
732  // to be found because that is not supported
733  while (ii < iiEnd)
734  {
735  if ('x' == (bDtaSrcIsColumns ? aMap[ii][oi] : aMap[oi][ii]))
736  throw lang::IllegalArgumentException();
737  ++ii;
738  }
739  }
740  else
741  ++ii;
742  }
743  }
744 
745  // make some other consistency checks while calculating
746  // the number of XLabeledDataSequence to build:
747  // - labels should always be used or not at all
748  // - the data sequences should have equal non-zero length
749  sal_Int32 nNumLDS = 0;
750  if (oiEnd > 0)
751  {
752  sal_Int32 nFirstSeqLen = 0;
753  sal_Int32 nFirstSeqLabelIdx = -1;
754  bool bFirstFound = false;
755  for (oi = 0; oi < oiEnd; ++oi)
756  {
757  // row/col used at all?
758  if (aDataStartIdx[oi] != -1 &&
759  (!bFirstIsLabel || aLabelIdx[oi] != -1))
760  {
761  ++nNumLDS;
762  if (!bFirstFound)
763  {
764  nFirstSeqLen = aDataLen[oi];
765  nFirstSeqLabelIdx = aLabelIdx[oi];
766  bFirstFound = true;
767  }
768  else
769  {
770  if (nFirstSeqLen != aDataLen[oi] ||
771  nFirstSeqLabelIdx != aLabelIdx[oi])
772  throw lang::IllegalArgumentException();
773  }
774  }
775  }
776  }
777  if (nNumLDS == 0)
778  throw lang::IllegalArgumentException();
779 
780  // now we should have all necessary data to build a proper DataSource
781  // thus if we came this far there should be no further problem
782  if (bTestOnly)
783  return xRes; // have createDataSourcePossible return true
784 
785  // create data source from found label and data sequences
786  uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aLabelSeqs(nNumLDS);
787  uno::Reference<chart2::data::XDataSequence>* pLabelSeqs = aLabelSeqs.getArray();
788  uno::Sequence<uno::Reference<chart2::data::XDataSequence>> aDataSeqs(nNumLDS);
789  uno::Reference<chart2::data::XDataSequence>* pDataSeqs = aDataSeqs.getArray();
790  sal_Int32 nSeqsIdx = 0;
791  for (oi = 0; oi < oiEnd; ++oi)
792  {
793  // row/col not used? (see if-statement above where nNumLDS was counted)
794  if (!(aDataStartIdx[oi] != -1 &&
795  (!bFirstIsLabel || aLabelIdx[oi] != -1)))
796  continue;
797 
798  // get cell ranges for label and data
799 
800  SwRangeDescriptor aLabelDesc;
801  SwRangeDescriptor aDataDesc;
802  if (bDtaSrcIsColumns) // use columns
803  {
804  aLabelDesc.nTop = aLabelIdx[oi];
805  aLabelDesc.nLeft = oi;
806  aLabelDesc.nBottom = aLabelDesc.nTop;
807  aLabelDesc.nRight = oi;
808 
809  aDataDesc.nTop = aDataStartIdx[oi];
810  aDataDesc.nLeft = oi;
811  aDataDesc.nBottom = aDataDesc.nTop + aDataLen[oi] - 1;
812  aDataDesc.nRight = oi;
813  }
814  else // use rows
815  {
816  aLabelDesc.nTop = oi;
817  aLabelDesc.nLeft = aLabelIdx[oi];
818  aLabelDesc.nBottom = oi;
819  aLabelDesc.nRight = aLabelDesc.nLeft;
820 
821  aDataDesc.nTop = oi;
822  aDataDesc.nLeft = aDataStartIdx[oi];
823  aDataDesc.nBottom = oi;
824  aDataDesc.nRight = aDataDesc.nLeft + aDataLen[oi] - 1;
825  }
826  const OUString aBaseName = pTableFormat->GetName() + ".";
827 
828  OUString aLabelRange;
829  if (aLabelIdx[oi] != -1)
830  {
831  aLabelRange = aBaseName
832  + sw_GetCellName( aLabelDesc.nLeft, aLabelDesc.nTop )
833  + ":" + sw_GetCellName( aLabelDesc.nRight, aLabelDesc.nBottom );
834  }
835 
836  OUString aDataRange = aBaseName
837  + sw_GetCellName( aDataDesc.nLeft, aDataDesc.nTop )
838  + ":" + sw_GetCellName( aDataDesc.nRight, aDataDesc.nBottom );
839 
840  // get cursors spanning the cell ranges for label and data
841  std::shared_ptr<SwUnoCursor> pLabelUnoCursor;
842  std::shared_ptr<SwUnoCursor> pDataUnoCursor;
843  GetFormatAndCreateCursorFromRangeRep(m_pDoc, aLabelRange, &pTableFormat, pLabelUnoCursor);
844  GetFormatAndCreateCursorFromRangeRep(m_pDoc, aDataRange, &pTableFormat, pDataUnoCursor);
845 
846  // create XDataSequence's from cursors
847  if (pLabelUnoCursor)
848  pLabelSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pLabelUnoCursor);
849  OSL_ENSURE(pDataUnoCursor, "pointer to data sequence missing");
850  if (pDataUnoCursor)
851  pDataSeqs[nSeqsIdx] = new SwChartDataSequence(*this, *pTableFormat, pDataUnoCursor);
852  if (pLabelUnoCursor || pDataUnoCursor)
853  ++nSeqsIdx;
854  }
855  OSL_ENSURE(nSeqsIdx == nNumLDS, "mismatch between sequence size and num,ber of entries");
856 
857  // build data source from data and label sequences
858  uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aLDS(nNumLDS);
859  uno::Reference<chart2::data::XLabeledDataSequence>* pLDS = aLDS.getArray();
860  for (sal_Int32 i = 0; i < nNumLDS; ++i)
861  {
863  pLabeledDtaSeq->setLabel(pLabelSeqs[i]);
864  pLabeledDtaSeq->setValues(pDataSeqs[i]);
865  pLDS[i] = pLabeledDtaSeq;
866  }
867 
868  // apply 'SequenceMapping' if it was provided
869  if (aSequenceMapping.hasElements())
870  {
871  uno::Sequence<uno::Reference<chart2::data::XLabeledDataSequence>> aOld_LDS(aLDS);
872  uno::Reference<chart2::data::XLabeledDataSequence>* pOld_LDS = aOld_LDS.getArray();
873 
874  sal_Int32 nNewCnt = 0;
875  for (sal_Int32 nIdx : std::as_const(aSequenceMapping))
876  {
877  // check that index to be used is valid
878  // and has not yet been used
879  if (0 <= nIdx && nIdx < nNumLDS && pOld_LDS[nIdx].is())
880  {
881  pLDS[nNewCnt++] = pOld_LDS[nIdx];
882 
883  // mark index as being used already (avoids duplicate entries)
884  pOld_LDS[nIdx].clear();
885  }
886  }
887  // add not yet used 'old' sequences to new one
888  for (sal_Int32 i = 0; i < nNumLDS; ++i)
889  {
890  if (pOld_LDS[i].is())
891  pLDS[nNewCnt++] = pOld_LDS[i];
892  }
893  OSL_ENSURE(nNewCnt == nNumLDS, "unexpected size of resulting sequence");
894  }
895 
896  xRes = new SwChartDataSource(aLDS);
897  return xRes;
898 }
899 
901  const uno::Sequence< beans::PropertyValue >& rArguments )
902 {
903  SolarMutexGuard aGuard;
904 
905  bool bPossible = true;
906  try
907  {
908  Impl_createDataSource( rArguments, true );
909  }
910  catch (lang::IllegalArgumentException &)
911  {
912  bPossible = false;
913  }
914 
915  return bPossible;
916 }
917 
918 uno::Reference< chart2::data::XDataSource > SAL_CALL SwChartDataProvider::createDataSource(
919  const uno::Sequence< beans::PropertyValue >& rArguments )
920 {
921  SolarMutexGuard aGuard;
922  return Impl_createDataSource( rArguments );
923 }
924 
935  const OUString &rCellRangeRepresentation )
936 {
937  // check that we do not have multiple ranges
938  if (-1 == rCellRangeRepresentation.indexOf( ';' ))
939  {
940  // get current cell and table names
941  OUString aTableName, aStartCell, aEndCell;
942  GetTableAndCellsFromRangeRep( rCellRangeRepresentation,
943  aTableName, aStartCell, aEndCell, false );
944  sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
945  SwXTextTable::GetCellPosition( aStartCell, nStartCol, nStartRow );
946  SwXTextTable::GetCellPosition( aEndCell, nEndCol, nEndRow );
947 
948  // get new cell names
949  ++nStartRow;
950  ++nEndRow;
951  aStartCell = sw_GetCellName( nStartCol, nStartRow );
952  aEndCell = sw_GetCellName( nEndCol, nEndRow );
953 
954  return GetRangeRepFromTableAndCells( aTableName,
955  aStartCell, aEndCell, false );
956  }
957 
958  return OUString();
959 }
960 
961 uno::Sequence< beans::PropertyValue > SAL_CALL SwChartDataProvider::detectArguments(
962  const uno::Reference< chart2::data::XDataSource >& xDataSource )
963 {
964  SolarMutexGuard aGuard;
965  if (m_bDisposed)
966  throw lang::DisposedException();
967 
968  uno::Sequence< beans::PropertyValue > aResult;
969  if (!xDataSource.is())
970  return aResult;
971 
972  const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aDS_LDS( xDataSource->getDataSequences() );
973  const uno::Reference< chart2::data::XLabeledDataSequence > *pDS_LDS = aDS_LDS.getConstArray();
974  sal_Int32 nNumDS_LDS = aDS_LDS.getLength();
975 
976  if (nNumDS_LDS == 0)
977  {
978  OSL_FAIL( "XLabeledDataSequence in data source contains 0 entries" );
979  return aResult;
980  }
981 
982  SwFrameFormat *pTableFormat = nullptr;
983  SwTable *pTable = nullptr;
984  OUString aTableName;
985  sal_Int32 nTableRows = 0;
986  sal_Int32 nTableCols = 0;
987 
988  // data used to build 'CellRangeRepresentation' from later on
989  std::vector< std::vector< char > > aMap;
990 
991  uno::Sequence< sal_Int32 > aSequenceMapping( nNumDS_LDS );
992  sal_Int32 *pSequenceMapping = aSequenceMapping.getArray();
993 
994  OUString aCellRanges;
995  sal_Int16 nDtaSrcIsColumns = -1;// -1: don't know yet, 0: false, 1: true -2: neither
996  sal_Int32 nLabelSeqLen = -1; // used to see if labels are always used or not and have
997  // the expected size of 1 (i.e. if FirstCellAsLabel can
998  // be determined)
999  // -1: don't know yet, 0: not used, 1: always a single labe cell, ...
1000  // -2: neither/failed
1001  for (sal_Int32 nDS1 = 0; nDS1 < nNumDS_LDS; ++nDS1)
1002  {
1003  uno::Reference< chart2::data::XLabeledDataSequence > xLabeledDataSequence( pDS_LDS[nDS1] );
1004  if( !xLabeledDataSequence.is() )
1005  {
1006  OSL_FAIL("got NULL for XLabeledDataSequence from Data source");
1007  continue;
1008  }
1009  const uno::Reference< chart2::data::XDataSequence > xCurLabel = xLabeledDataSequence->getLabel();
1010  const uno::Reference< chart2::data::XDataSequence > xCurValues = xLabeledDataSequence->getValues();
1011 
1012  // get sequence lengths for label and values.
1013  // (0 length is Ok)
1014  sal_Int32 nCurLabelSeqLen = -1;
1015  sal_Int32 nCurValuesSeqLen = -1;
1016  if (xCurLabel.is())
1017  nCurLabelSeqLen = xCurLabel->getData().getLength();
1018  if (xCurValues.is())
1019  nCurValuesSeqLen = xCurValues->getData().getLength();
1020 
1021  // check for consistent use of 'first cell as label'
1022  if (nLabelSeqLen == -1) // set initial value to compare with below further on
1023  nLabelSeqLen = nCurLabelSeqLen;
1024  if (nLabelSeqLen != nCurLabelSeqLen)
1025  nLabelSeqLen = -2; // failed / no consistent use of label cells
1026 
1027  // get table and cell names for label and values data sequences
1028  // (start and end cell will be sorted, i.e. start cell <= end cell)
1029  OUString aLabelTableName, aLabelStartCell, aLabelEndCell;
1030  OUString aValuesTableName, aValuesStartCell, aValuesEndCell;
1031  OUString aLabelRange, aValuesRange;
1032  if (xCurLabel.is())
1033  aLabelRange = xCurLabel->getSourceRangeRepresentation();
1034  if (xCurValues.is())
1035  aValuesRange = xCurValues->getSourceRangeRepresentation();
1036  if ((!aLabelRange.isEmpty() && !GetTableAndCellsFromRangeRep( aLabelRange,
1037  aLabelTableName, aLabelStartCell, aLabelEndCell )) ||
1038  !GetTableAndCellsFromRangeRep( aValuesRange,
1039  aValuesTableName, aValuesStartCell, aValuesEndCell ))
1040  {
1041  return aResult; // failed -> return empty property sequence
1042  }
1043 
1044  // make sure all sequences use the same table
1045  if (aTableName.isEmpty())
1046  aTableName = aValuesTableName; // get initial value to compare with
1047  if (aTableName.isEmpty() ||
1048  aTableName != aValuesTableName ||
1049  (!aLabelTableName.isEmpty() && aTableName != aLabelTableName))
1050  {
1051  return aResult; // failed -> return empty property sequence
1052  }
1053 
1054  // try to get 'DataRowSource' value (ROWS or COLUMNS) from inspecting
1055  // first and last cell used in both sequences
1056 
1057  sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
1058  const OUString aCell( !aLabelStartCell.isEmpty() ? aLabelStartCell : aValuesStartCell );
1059  OSL_ENSURE( !aCell.isEmpty() , "start cell missing?" );
1060  SwXTextTable::GetCellPosition( aCell, nFirstCol, nFirstRow);
1061  SwXTextTable::GetCellPosition( aValuesEndCell, nLastCol, nLastRow);
1062 
1063  sal_Int16 nDirection = -1; // -1: not yet set, 0: columns, 1: rows, -2: failed
1064  if (nFirstCol == nLastCol && nFirstRow == nLastRow) // a single cell...
1065  {
1066  OSL_ENSURE( nCurLabelSeqLen == 0 && nCurValuesSeqLen == 1,
1067  "trying to determine 'DataRowSource': something's fishy... should have been a single cell");
1068  nDirection = 0; // default direction for a single cell should be 'columns'
1069  }
1070  else // more than one cell is available (in values and label together!)
1071  {
1072  if (nFirstCol == nLastCol && nFirstRow != nLastRow)
1073  nDirection = 1;
1074  else if (nFirstCol != nLastCol && nFirstRow == nLastRow)
1075  nDirection = 0;
1076  else
1077  {
1078  OSL_FAIL( "trying to determine 'DataRowSource': unexpected case found" );
1079  nDirection = -2;
1080  }
1081  }
1082  // check for consistent direction of data source
1083  if (nDtaSrcIsColumns == -1) // set initial value to compare with below
1084  nDtaSrcIsColumns = nDirection;
1085  if (nDtaSrcIsColumns != nDirection)
1086  {
1087  nDtaSrcIsColumns = -2; // failed
1088  }
1089 
1090  if (nDtaSrcIsColumns == 0 || nDtaSrcIsColumns == 1)
1091  {
1092  // build data to obtain 'SequenceMapping' later on
1093 
1094  OSL_ENSURE( nDtaSrcIsColumns == 0 || /* rows */
1095  nDtaSrcIsColumns == 1, /* columns */
1096  "unexpected value for 'nDtaSrcIsColumns'" );
1097  pSequenceMapping[nDS1] = nDtaSrcIsColumns ? nFirstCol : nFirstRow;
1098 
1099  // build data used to determine 'CellRangeRepresentation' later on
1100 
1101  GetTableByName( *m_pDoc, aTableName, &pTableFormat, &pTable );
1102  if (!pTable || pTable->IsTableComplex())
1103  return aResult; // failed -> return empty property sequence
1104  nTableRows = pTable->GetTabLines().size();
1105  nTableCols = pTable->GetTabLines().front()->GetTabBoxes().size();
1106  aMap.resize( nTableRows );
1107  for (sal_Int32 i = 0; i < nTableRows; ++i)
1108  aMap[i].resize( nTableCols );
1109 
1110  if (!aLabelStartCell.isEmpty() && !aLabelEndCell.isEmpty())
1111  {
1112  sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
1113  SwXTextTable::GetCellPosition( aLabelStartCell, nStartCol, nStartRow );
1114  SwXTextTable::GetCellPosition( aLabelEndCell, nEndCol, nEndRow );
1115  if (nStartRow < 0 || nEndRow >= nTableRows ||
1116  nStartCol < 0 || nEndCol >= nTableCols)
1117  {
1118  return aResult; // failed -> return empty property sequence
1119  }
1120  for (sal_Int32 i = nStartRow; i <= nEndRow; ++i)
1121  {
1122  for (sal_Int32 k = nStartCol; k <= nEndCol; ++k)
1123  {
1124  char &rChar = aMap[i][k];
1125  if (rChar == '\0') // check for overlapping values and/or labels
1126  rChar = 'L';
1127  else
1128  return aResult; // failed -> return empty property sequence
1129  }
1130  }
1131  }
1132  if (!aValuesStartCell.isEmpty() && !aValuesEndCell.isEmpty())
1133  {
1134  sal_Int32 nStartCol = -1, nStartRow = -1, nEndCol = -1, nEndRow = -1;
1135  SwXTextTable::GetCellPosition( aValuesStartCell, nStartCol, nStartRow );
1136  SwXTextTable::GetCellPosition( aValuesEndCell, nEndCol, nEndRow );
1137  if (nStartRow < 0 || nEndRow >= nTableRows ||
1138  nStartCol < 0 || nEndCol >= nTableCols)
1139  {
1140  return aResult; // failed -> return empty property sequence
1141  }
1142  for (sal_Int32 i = nStartRow; i <= nEndRow; ++i)
1143  {
1144  for (sal_Int32 k = nStartCol; k <= nEndCol; ++k)
1145  {
1146  char &rChar = aMap[i][k];
1147  if (rChar == '\0') // check for overlapping values and/or labels
1148  rChar = 'x';
1149  else
1150  return aResult; // failed -> return empty property sequence
1151  }
1152  }
1153  }
1154  }
1155 
1156 #if OSL_DEBUG_LEVEL > 0
1157  // do some extra sanity checking that the length of the sequences
1158  // matches their range representation
1159  {
1160  sal_Int32 nStartRow = -1, nStartCol = -1, nEndRow = -1, nEndCol = -1;
1161  if (xCurLabel.is())
1162  {
1163  SwXTextTable::GetCellPosition( aLabelStartCell, nStartCol, nStartRow);
1164  SwXTextTable::GetCellPosition( aLabelEndCell, nEndCol, nEndRow);
1165  OSL_ENSURE( (nStartCol == nEndCol && (nEndRow - nStartRow + 1) == xCurLabel->getData().getLength()) ||
1166  (nStartRow == nEndRow && (nEndCol - nStartCol + 1) == xCurLabel->getData().getLength()),
1167  "label sequence length does not match range representation!" );
1168  }
1169  if (xCurValues.is())
1170  {
1171  SwXTextTable::GetCellPosition( aValuesStartCell, nStartCol, nStartRow);
1172  SwXTextTable::GetCellPosition( aValuesEndCell, nEndCol, nEndRow);
1173  OSL_ENSURE( (nStartCol == nEndCol && (nEndRow - nStartRow + 1) == xCurValues->getData().getLength()) ||
1174  (nStartRow == nEndRow && (nEndCol - nStartCol + 1) == xCurValues->getData().getLength()),
1175  "value sequence length does not match range representation!" );
1176  }
1177  }
1178 #endif
1179  } // for
1180 
1181  // build value for 'CellRangeRepresentation'
1182 
1183  const OUString aCellRangeBase = aTableName + ".";
1184  OUString aCurRange;
1185  for (sal_Int32 i = 0; i < nTableRows; ++i)
1186  {
1187  for (sal_Int32 k = 0; k < nTableCols; ++k)
1188  {
1189  if (aMap[i][k] != '\0') // top-left cell of a sub-range found
1190  {
1191  // find rectangular sub-range to use
1192  sal_Int32 nRowIndex1 = i; // row index
1193  sal_Int32 nColIndex1 = k; // column index
1194  sal_Int32 nRowSubLen = 0;
1195  sal_Int32 nColSubLen = 0;
1196  while (nRowIndex1 < nTableRows && aMap[nRowIndex1++][k] != '\0')
1197  ++nRowSubLen;
1198  // be aware of shifted sequences!
1199  // (according to the checks done prior the length should be ok)
1200  while (nColIndex1 < nTableCols && aMap[i][nColIndex1] != '\0'
1201  && aMap[i + nRowSubLen-1][nColIndex1] != '\0')
1202  {
1203  ++nColIndex1;
1204  ++nColSubLen;
1205  }
1206  OUString aStartCell( sw_GetCellName( k, i ) );
1207  OUString aEndCell( sw_GetCellName( k + nColSubLen - 1, i + nRowSubLen - 1) );
1208  aCurRange = aCellRangeBase + aStartCell + ":" + aEndCell;
1209  if (!aCellRanges.isEmpty())
1210  aCellRanges += ";";
1211  aCellRanges += aCurRange;
1212 
1213  // clear already found sub-range from map
1214  for (sal_Int32 nRowIndex2 = 0; nRowIndex2 < nRowSubLen; ++nRowIndex2)
1215  for (sal_Int32 nColumnIndex2 = 0; nColumnIndex2 < nColSubLen; ++nColumnIndex2)
1216  aMap[i + nRowIndex2][k + nColumnIndex2] = '\0';
1217  }
1218  }
1219  }
1220  // to be nice to the user we now sort the cell ranges according to
1221  // rows or columns depending on the direction used in the data source
1222  uno::Sequence< OUString > aSortedRanges;
1223  GetSubranges( aCellRanges, aSortedRanges, false /*sub ranges should already be normalized*/ );
1224  SortSubranges( aSortedRanges, (nDtaSrcIsColumns == 1) );
1225  OUString aSortedCellRanges;
1226  for (const OUString& rSortedRange : std::as_const(aSortedRanges))
1227  {
1228  if (!aSortedCellRanges.isEmpty())
1229  aSortedCellRanges += ";";
1230  aSortedCellRanges += rSortedRange;
1231  }
1232 
1233  // build value for 'SequenceMapping'
1234 
1235  uno::Sequence< sal_Int32 > aSortedMapping( aSequenceMapping );
1236  auto [begin, end] = asNonConstRange(aSortedMapping);
1237  std::sort(begin, end);
1238  bool bNeedSequenceMapping = false;
1239  for (sal_Int32 i = 0; i < aSequenceMapping.getLength(); ++i)
1240  {
1241  auto it = std::find( std::cbegin(aSortedMapping), std::cend(aSortedMapping),
1242  aSequenceMapping[i] );
1243  aSequenceMapping[i] = std::distance(std::cbegin(aSortedMapping), it);
1244 
1245  if (i != std::as_const(aSequenceMapping)[i])
1246  bNeedSequenceMapping = true;
1247  }
1248 
1249  // check if 'SequenceMapping' is actually not required...
1250  // (don't write unnecessary properties to the XML file)
1251  if (!bNeedSequenceMapping)
1252  aSequenceMapping.realloc(0);
1253 
1254  // build resulting properties
1255 
1256  OSL_ENSURE(nLabelSeqLen >= 0 || nLabelSeqLen == -2 /*not used*/,
1257  "unexpected value for 'nLabelSeqLen'" );
1258  bool bFirstCellIsLabel = false; // default value if 'nLabelSeqLen' could not properly determined
1259  if (nLabelSeqLen > 0) // == 0 means no label sequence in use
1260  bFirstCellIsLabel = true;
1261 
1262  OSL_ENSURE( !aSortedCellRanges.isEmpty(), "CellRangeRepresentation missing" );
1263  const OUString aBrokenCellRangeForExport( GetBrokenCellRangeForExport( aSortedCellRanges ) );
1264 
1265  aResult.realloc(5);
1266  sal_Int32 nProps = 0;
1267  aResult[nProps ].Name = "FirstCellAsLabel";
1268  aResult[nProps++].Value <<= bFirstCellIsLabel;
1269  aResult[nProps ].Name = "CellRangeRepresentation";
1270  aResult[nProps++].Value <<= aSortedCellRanges;
1271  if (!aBrokenCellRangeForExport.isEmpty())
1272  {
1273  aResult[nProps ].Name = "BrokenCellRangeForExport";
1274  aResult[nProps++].Value <<= aBrokenCellRangeForExport;
1275  }
1276  if (nDtaSrcIsColumns == 0 || nDtaSrcIsColumns == 1)
1277  {
1278  chart::ChartDataRowSource eDataRowSource = (nDtaSrcIsColumns == 1) ?
1279  chart::ChartDataRowSource_COLUMNS : chart::ChartDataRowSource_ROWS;
1280  aResult[nProps ].Name = "DataRowSource";
1281  aResult[nProps++].Value <<= eDataRowSource;
1282 
1283  if (aSequenceMapping.hasElements())
1284  {
1285  aResult[nProps ].Name = "SequenceMapping";
1286  aResult[nProps++].Value <<= aSequenceMapping;
1287  }
1288  }
1289  aResult.realloc( nProps );
1290 
1291  return aResult;
1292 }
1293 
1294 uno::Reference< chart2::data::XDataSequence > SwChartDataProvider::Impl_createDataSequenceByRangeRepresentation(
1295  const OUString& rRangeRepresentation, bool bTestOnly )
1296 {
1297  if (m_bDisposed)
1298  throw lang::DisposedException();
1299 
1300  SwFrameFormat *pTableFormat = nullptr; // pointer to table format
1301  std::shared_ptr<SwUnoCursor> pUnoCursor; // pointer to new created cursor spanning the cell range
1302  GetFormatAndCreateCursorFromRangeRep( m_pDoc, rRangeRepresentation,
1303  &pTableFormat, pUnoCursor );
1304  if (!pTableFormat || !pUnoCursor)
1305  throw lang::IllegalArgumentException();
1306 
1307  // check that cursors point and mark are in a single row or column.
1308  OUString aCellRange( GetCellRangeName( *pTableFormat, *pUnoCursor ) );
1309  SwRangeDescriptor aDesc;
1310  FillRangeDescriptor( aDesc, aCellRange );
1311  if (aDesc.nTop != aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
1312  throw lang::IllegalArgumentException();
1313 
1314  OSL_ENSURE( pTableFormat && pUnoCursor, "table format or cursor missing" );
1315  uno::Reference< chart2::data::XDataSequence > xDataSeq;
1316  if (!bTestOnly)
1317  xDataSeq = new SwChartDataSequence( *this, *pTableFormat, pUnoCursor );
1318 
1319  return xDataSeq;
1320 }
1321 
1323  const OUString& rRangeRepresentation )
1324 {
1325  SolarMutexGuard aGuard;
1326 
1327  bool bPossible = true;
1328  try
1329  {
1330  Impl_createDataSequenceByRangeRepresentation( rRangeRepresentation, true );
1331  }
1332  catch (lang::IllegalArgumentException &)
1333  {
1334  bPossible = false;
1335  }
1336 
1337  return bPossible;
1338 }
1339 
1340 uno::Reference< chart2::data::XDataSequence > SAL_CALL SwChartDataProvider::createDataSequenceByRangeRepresentation(
1341  const OUString& rRangeRepresentation )
1342 {
1343  SolarMutexGuard aGuard;
1344  return Impl_createDataSequenceByRangeRepresentation( rRangeRepresentation );
1345 }
1346 
1347 uno::Reference< sheet::XRangeSelection > SAL_CALL SwChartDataProvider::getRangeSelection( )
1348 {
1349  // note: it is no error to return nothing here
1350  return uno::Reference< sheet::XRangeSelection >();
1351 }
1352 
1353 uno::Reference<css::chart2::data::XDataSequence> SAL_CALL
1355  const OUString& /*aRole*/, const OUString& /*aRangeRepresentation*/,
1356  const OUString& /*aRoleQualifier*/ )
1357 {
1358  return uno::Reference<css::chart2::data::XDataSequence>();
1359 }
1360 
1362 {
1363  bool bMustDispose( false );
1364  {
1365  osl::MutexGuard aGuard( GetChartMutex() );
1366  bMustDispose = !m_bDisposed;
1367  if (!m_bDisposed)
1368  m_bDisposed = true;
1369  }
1370  if (!bMustDispose)
1371  return;
1372 
1373  // dispose all data-sequences
1374  for (const auto& rEntry : m_aDataSequences)
1375  {
1376  DisposeAllDataSequences( rEntry.first );
1377  }
1378  // release all references to data-sequences
1379  m_aDataSequences.clear();
1380 
1381  // require listeners to release references to this object
1382  lang::EventObject aEvtObj( static_cast< chart2::data::XDataProvider * >(this) );
1384 }
1385 
1387  const uno::Reference< lang::XEventListener >& rxListener )
1388 {
1389  osl::MutexGuard aGuard( GetChartMutex() );
1390  if (!m_bDisposed && rxListener.is())
1391  m_aEventListeners.addInterface( rxListener );
1392 }
1393 
1395  const uno::Reference< lang::XEventListener >& rxListener )
1396 {
1397  osl::MutexGuard aGuard( GetChartMutex() );
1398  if (!m_bDisposed && rxListener.is())
1399  m_aEventListeners.removeInterface( rxListener );
1400 }
1401 
1403 {
1404  return "SwChartDataProvider";
1405 }
1406 
1407 sal_Bool SAL_CALL SwChartDataProvider::supportsService(const OUString& rServiceName )
1408 {
1409  return cppu::supportsService(this, rServiceName);
1410 }
1411 
1412 uno::Sequence< OUString > SAL_CALL SwChartDataProvider::getSupportedServiceNames( )
1413 {
1414  return { "com.sun.star.chart2.data.DataProvider"};
1415 }
1416 
1417 void SwChartDataProvider::AddDataSequence( const SwTable &rTable, uno::Reference< chart2::data::XDataSequence > const &rxDataSequence )
1418 {
1419  m_aDataSequences[ &rTable ].insert( rxDataSequence );
1420 }
1421 
1422 void SwChartDataProvider::RemoveDataSequence( const SwTable &rTable, uno::Reference< chart2::data::XDataSequence > const &rxDataSequence )
1423 {
1424  m_aDataSequences[ &rTable ].erase( rxDataSequence );
1425 }
1426 
1428 {
1429  OSL_ENSURE( pTable, "table pointer is NULL" );
1430  if (!pTable)
1431  return;
1432 
1433  if (!m_bDisposed)
1435 
1436  const Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
1437  for (const auto& rItem : rSet)
1438  {
1439  uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
1440  uno::Reference< util::XModifiable > xRef( xTemp, uno::UNO_QUERY );
1441  if (xRef.is())
1442  {
1443  // mark the sequence as 'dirty' and notify listeners
1444  xRef->setModified( true );
1445  }
1446  }
1447 }
1448 
1449 void SwChartDataProvider::DeleteBox( const SwTable *pTable, const SwTableBox &rBox )
1450 {
1451  OSL_ENSURE( pTable, "table pointer is NULL" );
1452  if (!pTable)
1453  return;
1454 
1455  if (!m_bDisposed)
1457 
1458  Set_DataSequenceRef_t &rSet = m_aDataSequences[ pTable ];
1459 
1460  // iterate over all data-sequences for that table...
1461  Set_DataSequenceRef_t::iterator aIt( rSet.begin() );
1462  Set_DataSequenceRef_t::iterator aEndIt( rSet.end() );
1463  Set_DataSequenceRef_t::iterator aDelIt; // iterator used for deletion when appropriate
1464  while (aIt != aEndIt)
1465  {
1466  SwChartDataSequence *pDataSeq = nullptr;
1467  bool bNowEmpty = false;
1468  bool bSeqDisposed = false;
1469 
1470  // check if weak reference is still valid...
1471  uno::Reference< chart2::data::XDataSequence > xTemp(*aIt);
1472  if (xTemp.is())
1473  {
1474  // then delete that table box (check if implementation cursor needs to be adjusted)
1475  pDataSeq = static_cast< SwChartDataSequence * >( xTemp.get() );
1476  if (pDataSeq)
1477  {
1478  try
1479  {
1480  bNowEmpty = pDataSeq->DeleteBox( rBox );
1481  }
1482  catch (const lang::DisposedException&)
1483  {
1484  bNowEmpty = true;
1485  bSeqDisposed = true;
1486  }
1487 
1488  if (bNowEmpty)
1489  aDelIt = aIt;
1490  }
1491  }
1492  ++aIt;
1493 
1494  if (bNowEmpty)
1495  {
1496  rSet.erase( aDelIt );
1497  if (pDataSeq && !bSeqDisposed)
1498  pDataSeq->dispose(); // the current way to tell chart that sth. got removed
1499  }
1500  }
1501 }
1502 
1504 {
1505  OSL_ENSURE( pTable, "table pointer is NULL" );
1506  if (!pTable)
1507  return;
1508 
1509  if (!m_bDisposed)
1511 
1516  const Set_DataSequenceRef_t aSet( m_aDataSequences[ pTable ] );
1517 
1518  for (const auto& rItem : aSet)
1519  {
1520  uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
1521  uno::Reference< lang::XComponent > xRef( xTemp, uno::UNO_QUERY );
1522  if (xRef.is())
1523  {
1524  xRef->dispose();
1525  }
1526  }
1527 }
1528 
1551  const SwTable &rTable,
1552  const SwSelBoxes& rBoxes,
1553  sal_uInt16 nLines, bool bBehind )
1554 {
1555  if (rTable.IsTableComplex())
1556  return;
1557 
1558  const size_t nBoxes = rBoxes.size();
1559  if (nBoxes < 1 || nLines < 1)
1560  return;
1561 
1562  SwTableBox* pFirstBox = rBoxes[0];
1563  SwTableBox* pLastBox = rBoxes.back();
1564 
1565  if (!(pFirstBox && pLastBox))
1566  return;
1567 
1568  sal_Int32 nFirstCol = -1, nFirstRow = -1, nLastCol = -1, nLastRow = -1;
1569  SwXTextTable::GetCellPosition( pFirstBox->GetName(), nFirstCol, nFirstRow );
1570  SwXTextTable::GetCellPosition( pLastBox->GetName(), nLastCol, nLastRow );
1571 
1572  bool bAddCols = false; // default; also to be used if nBoxes == 1 :-/
1573  if (nFirstCol == nLastCol && nFirstRow != nLastRow)
1574  bAddCols = true;
1575  if (nFirstCol != nLastCol && nFirstRow != nLastRow)
1576  return;
1577 
1578  //get range of indices in col/rows for new cells
1579  sal_Int32 nFirstNewCol = nFirstCol;
1580  sal_Int32 nFirstNewRow = bBehind ? nFirstRow + 1 : nFirstRow - nLines;
1581  if (bAddCols)
1582  {
1583  OSL_ENSURE( nFirstCol == nLastCol, "column indices seem broken" );
1584  nFirstNewCol = bBehind ? nFirstCol + 1 : nFirstCol - nLines;
1585  nFirstNewRow = nFirstRow;
1586  }
1587 
1588  // iterate over all data-sequences for the table
1589  const Set_DataSequenceRef_t &rSet = m_aDataSequences[ &rTable ];
1590  for (const auto& rItem : rSet)
1591  {
1592  uno::Reference< chart2::data::XDataSequence > xTemp(rItem); // temporary needed for g++ 3.3.5
1593  uno::Reference< chart2::data::XTextualDataSequence > xRef( xTemp, uno::UNO_QUERY );
1594  if (xRef.is())
1595  {
1596  const sal_Int32 nLen = xRef->getTextualData().getLength();
1597  if (nLen > 1) // value data-sequence ?
1598  {
1599  auto pDataSeq = comphelper::getFromUnoTunnel<SwChartDataSequence>(xRef);
1600  if (pDataSeq)
1601  {
1602  SwRangeDescriptor aDesc;
1603  pDataSeq->FillRangeDesc( aDesc );
1604 
1605  chart::ChartDataRowSource eDRSource = chart::ChartDataRowSource_COLUMNS;
1606  if (aDesc.nTop == aDesc.nBottom && aDesc.nLeft != aDesc.nRight)
1607  eDRSource = chart::ChartDataRowSource_ROWS;
1608 
1609  if (!bAddCols && eDRSource == chart::ChartDataRowSource_COLUMNS)
1610  {
1611  // add rows: extend affected columns by newly added row cells
1612  pDataSeq->ExtendTo( true, nFirstNewRow, nLines );
1613  }
1614  else if (bAddCols && eDRSource == chart::ChartDataRowSource_ROWS)
1615  {
1616  // add cols: extend affected rows by newly added column cells
1617  pDataSeq->ExtendTo( false, nFirstNewCol, nLines );
1618  }
1619  }
1620  }
1621  }
1622  }
1623 }
1624 
1625 // XRangeXMLConversion
1626 OUString SAL_CALL SwChartDataProvider::convertRangeToXML( const OUString& rRangeRepresentation )
1627 {
1628  SolarMutexGuard aGuard;
1629  if (m_bDisposed)
1630  throw lang::DisposedException();
1631 
1632  if (rRangeRepresentation.isEmpty())
1633  return OUString();
1634 
1635  OUStringBuffer aRes;
1636 
1637  // multiple ranges are delimited by a ';' like in
1638  // "Table1.A1:A4;Table1.C2:C5" the same table must be used in all ranges!
1639  SwTable* pFirstFoundTable = nullptr; // to check that only one table will be used
1640  sal_Int32 nPos = 0;
1641  do {
1642  const OUString aRange( rRangeRepresentation.getToken(0, ';', nPos) );
1643  SwFrameFormat *pTableFormat = nullptr; // pointer to table format
1644  std::shared_ptr<SwUnoCursor> pCursor;
1645  GetFormatAndCreateCursorFromRangeRep( m_pDoc, aRange, &pTableFormat, pCursor );
1646  if (!pTableFormat)
1647  throw lang::IllegalArgumentException();
1648  SwTable* pTable = SwTable::FindTable( pTableFormat );
1649  if (pTable->IsTableComplex())
1650  throw uno::RuntimeException("Table too complex.");
1651 
1652  // check that there is only one table used in all ranges
1653  if (!pFirstFoundTable)
1654  pFirstFoundTable = pTable;
1655  if (pTable != pFirstFoundTable)
1656  throw lang::IllegalArgumentException();
1657 
1658  OUString aTableName;
1659  OUString aStartCell;
1660  OUString aEndCell;
1661  if (!GetTableAndCellsFromRangeRep( aRange, aTableName, aStartCell, aEndCell ))
1662  throw lang::IllegalArgumentException();
1663 
1664  sal_Int32 nCol, nRow;
1665  SwXTextTable::GetCellPosition( aStartCell, nCol, nRow );
1666  if (nCol < 0 || nRow < 0)
1667  throw uno::RuntimeException("Cell not found.");
1668 
1671  XMLRangeHelper::CellRange aCellRange;
1672  aCellRange.aTableName = aTableName;
1673  aCellRange.aUpperLeft.nColumn = nCol;
1674  aCellRange.aUpperLeft.nRow = nRow;
1675  aCellRange.aUpperLeft.bIsEmpty = false;
1676  if (aStartCell != aEndCell && !aEndCell.isEmpty())
1677  {
1678  SwXTextTable::GetCellPosition( aEndCell, nCol, nRow );
1679  if (nCol < 0 || nRow < 0)
1680  throw uno::RuntimeException("Cell not found.");
1681 
1682  aCellRange.aLowerRight.nColumn = nCol;
1683  aCellRange.aLowerRight.nRow = nRow;
1684  aCellRange.aLowerRight.bIsEmpty = false;
1685  }
1686  OUString aTmp( XMLRangeHelper::getXMLStringFromCellRange( aCellRange ) );
1687  if (!aRes.isEmpty()) // in case of multiple ranges add delimiter
1688  aRes.append(" ");
1689  aRes.append(aTmp);
1690  }
1691  while (nPos>0);
1692 
1693  return aRes.makeStringAndClear();
1694 }
1695 
1696 OUString SAL_CALL SwChartDataProvider::convertRangeFromXML( const OUString& rXMLRange )
1697 {
1698  SolarMutexGuard aGuard;
1699  if (m_bDisposed)
1700  throw lang::DisposedException();
1701 
1702  if (rXMLRange.isEmpty())
1703  return OUString();
1704 
1705  OUStringBuffer aRes;
1706 
1707  // multiple ranges are delimited by a ' ' like in
1708  // "Table1.$A$1:.$A$4 Table1.$C$2:.$C$5" the same table must be used in all ranges!
1709  OUString aFirstFoundTable; // to check that only one table will be used
1710  sal_Int32 nPos = 0;
1711  do
1712  {
1713  OUString aRange( rXMLRange.getToken(0, ' ', nPos) );
1714 
1718 
1719  // check that there is only one table used in all ranges
1720  if (aFirstFoundTable.isEmpty())
1721  aFirstFoundTable = aCellRange.aTableName;
1722  if (aCellRange.aTableName != aFirstFoundTable)
1723  throw lang::IllegalArgumentException();
1724 
1725  OUString aTmp = aCellRange.aTableName + "." +
1726  sw_GetCellName( aCellRange.aUpperLeft.nColumn,
1727  aCellRange.aUpperLeft.nRow );
1728  // does cell range consist of more than a single cell?
1729  if (!aCellRange.aLowerRight.bIsEmpty)
1730  {
1731  aTmp += ":" + sw_GetCellName( aCellRange.aLowerRight.nColumn,
1732  aCellRange.aLowerRight.nRow );
1733  }
1734 
1735  if (!aRes.isEmpty()) // in case of multiple ranges add delimiter
1736  aRes.append(";");
1737  aRes.append(aTmp);
1738  }
1739  while (nPos>0);
1740 
1741  return aRes.makeStringAndClear();
1742 }
1743 
1745  const uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > &rLDS ) :
1746  m_aLDS( rLDS )
1747 {
1748 }
1749 
1751 {
1752 }
1753 
1754 uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > SAL_CALL SwChartDataSource::getDataSequences( )
1755 {
1756  SolarMutexGuard aGuard;
1757  return m_aLDS;
1758 }
1759 
1761 {
1762  return "SwChartDataSource";
1763 }
1764 
1765 sal_Bool SAL_CALL SwChartDataSource::supportsService(const OUString& rServiceName )
1766 {
1767  return cppu::supportsService(this, rServiceName);
1768 }
1769 
1770 uno::Sequence< OUString > SAL_CALL SwChartDataSource::getSupportedServiceNames( )
1771 {
1772  return { "com.sun.star.chart2.data.DataSource" };
1773 }
1774 
1776  SwChartDataProvider& rProvider,
1777  SwFrameFormat& rTableFormat,
1778  const std::shared_ptr<SwUnoCursor>& pTableCursor ) :
1779  m_pFormat(&rTableFormat),
1780  m_aEvtListeners( GetChartMutex() ),
1781  m_aModifyListeners( GetChartMutex() ),
1782  m_aRowLabelText( SwResId( STR_CHART2_ROW_LABEL_TEXT ) ),
1783  m_aColLabelText( SwResId( STR_CHART2_COL_LABEL_TEXT ) ),
1784  m_xDataProvider( &rProvider ),
1785  m_pTableCursor( pTableCursor ),
1786  m_pPropSet( aSwMapProvider.GetPropertySet( PROPERTY_MAP_CHART2_DATA_SEQUENCE ) )
1787 {
1788  StartListening(rTableFormat.GetNotifier());
1789  m_bDisposed = false;
1790 
1791  acquire();
1792  try
1793  {
1794  const SwTable* pTable = SwTable::FindTable( &rTableFormat );
1795  if (pTable)
1796  {
1797  uno::Reference< chart2::data::XDataSequence > xRef(this);
1798  m_xDataProvider->AddDataSequence( *pTable, xRef );
1799  m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) );
1800  }
1801  else {
1802  OSL_FAIL( "table missing" );
1803  }
1804  }
1805  catch (uno::RuntimeException &)
1806  {
1807  // TODO: shouldn't there be a call to release() here?
1808  throw;
1809  }
1810  catch (uno::Exception &)
1811  {
1812  }
1813  release();
1814 
1815 #if OSL_DEBUG_LEVEL > 0
1816  // check if it can properly convert into a SwUnoTableCursor
1817  // which is required for some functions
1818  SwUnoTableCursor* pUnoTableCursor = dynamic_cast<SwUnoTableCursor*>(&(*m_pTableCursor));
1819  OSL_ENSURE(pUnoTableCursor, "SwChartDataSequence: cursor not SwUnoTableCursor");
1820 #endif
1821 }
1822 
1825  SvtListener(),
1826  m_pFormat( rObj.m_pFormat ),
1827  m_aEvtListeners( GetChartMutex() ),
1828  m_aModifyListeners( GetChartMutex() ),
1829  m_aRole( rObj.m_aRole ),
1830  m_aRowLabelText( SwResId(STR_CHART2_ROW_LABEL_TEXT) ),
1831  m_aColLabelText( SwResId(STR_CHART2_COL_LABEL_TEXT) ),
1832  m_xDataProvider( rObj.m_xDataProvider ),
1833  m_pTableCursor( rObj.m_pTableCursor ),
1834  m_pPropSet( rObj.m_pPropSet )
1835 {
1836  if(m_pFormat)
1838  m_bDisposed = false;
1839 
1840  acquire();
1841  try
1842  {
1843  const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
1844  if (pTable)
1845  {
1846  uno::Reference< chart2::data::XDataSequence > xRef(this);
1847  m_xDataProvider->AddDataSequence( *pTable, xRef );
1848  m_xDataProvider->addEventListener( static_cast< lang::XEventListener * >(this) );
1849  }
1850  else {
1851  OSL_FAIL( "table missing" );
1852  }
1853  }
1854  catch (uno::RuntimeException &)
1855  {
1856  // TODO: shouldn't there be a call to release() here?
1857  throw;
1858  }
1859  catch (uno::Exception &)
1860  {
1861  }
1862  release();
1863 
1864 #if OSL_DEBUG_LEVEL > 0
1865  // check if it can properly convert into a SwUnoTableCursor
1866  // which is required for some functions
1867  SwUnoTableCursor* pUnoTableCursor = dynamic_cast<SwUnoTableCursor*>(&(*m_pTableCursor));
1868  OSL_ENSURE(pUnoTableCursor, "SwChartDataSequence: cursor not SwUnoTableCursor");
1869 #endif
1870 }
1871 
1873 {
1874 }
1875 
1876 const uno::Sequence< sal_Int8 > & SwChartDataSequence::getUnoTunnelId()
1877 {
1878  static const comphelper::UnoIdInit theSwChartDataSequenceUnoTunnelId;
1879  return theSwChartDataSequenceUnoTunnelId.getSeq();
1880 }
1881 
1882 sal_Int64 SAL_CALL SwChartDataSequence::getSomething( const uno::Sequence< sal_Int8 > &rId )
1883 {
1884  return comphelper::getSomethingImpl(rId, this);
1885 }
1886 
1887 
1889 {
1890  SolarMutexGuard aGuard;
1891  if (m_bDisposed)
1892  throw lang::DisposedException();
1893 
1894  OUString aRes;
1895  SwFrameFormat* pTableFormat = GetFrameFormat();
1896  if (pTableFormat)
1897  {
1898  const OUString aCellRange( GetCellRangeName( *pTableFormat, *m_pTableCursor ) );
1899  OSL_ENSURE( !aCellRange.isEmpty(), "failed to get cell range" );
1900  aRes = pTableFormat->GetName() + "." + aCellRange;
1901  }
1902  return aRes;
1903 }
1904 
1905 uno::Sequence< OUString > SAL_CALL SwChartDataSequence::generateLabel(
1906  chart2::data::LabelOrigin eLabelOrigin )
1907 {
1908  SolarMutexGuard aGuard;
1909  if (m_bDisposed)
1910  throw lang::DisposedException();
1911 
1912  uno::Sequence< OUString > aLabels;
1913 
1914  {
1915  SwRangeDescriptor aDesc;
1916  bool bOk = false;
1917  SwFrameFormat* pTableFormat = GetFrameFormat();
1918  if (!pTableFormat)
1919  throw uno::RuntimeException("No table format found.");
1920  SwTable* pTable = SwTable::FindTable( pTableFormat );
1921  if (!pTable)
1922  throw uno::RuntimeException("No table found.");
1923  if (pTable->IsTableComplex())
1924  throw uno::RuntimeException("Table too complex.");
1925 
1926  const OUString aCellRange( GetCellRangeName( *pTableFormat, *m_pTableCursor ) );
1927  OSL_ENSURE( !aCellRange.isEmpty(), "failed to get cell range" );
1928  bOk = FillRangeDescriptor( aDesc, aCellRange );
1929  OSL_ENSURE( bOk, "failed to get SwRangeDescriptor" );
1930 
1931  if (bOk)
1932  {
1933  aDesc.Normalize();
1934  sal_Int32 nColSpan = aDesc.nRight - aDesc.nLeft + 1;
1935  sal_Int32 nRowSpan = aDesc.nBottom - aDesc.nTop + 1;
1936  OSL_ENSURE( nColSpan == 1 || nRowSpan == 1,
1937  "unexpected range of selected cells" );
1938 
1939  OUString aText; // label text to be returned
1940  bool bReturnEmptyText = false;
1941  bool bUseCol = true;
1942  if (eLabelOrigin == chart2::data::LabelOrigin_COLUMN)
1943  bUseCol = true;
1944  else if (eLabelOrigin == chart2::data::LabelOrigin_ROW)
1945  bUseCol = false;
1946  else if (eLabelOrigin == chart2::data::LabelOrigin_SHORT_SIDE)
1947  {
1948  bUseCol = nColSpan < nRowSpan;
1949  bReturnEmptyText = nColSpan == nRowSpan;
1950  }
1951  else if (eLabelOrigin == chart2::data::LabelOrigin_LONG_SIDE)
1952  {
1953  bUseCol = nColSpan > nRowSpan;
1954  bReturnEmptyText = nColSpan == nRowSpan;
1955  }
1956  else {
1957  OSL_FAIL( "unexpected case" );
1958  }
1959 
1960  // build label sequence
1961 
1962  sal_Int32 nSeqLen = bUseCol ? nColSpan : nRowSpan;
1963  aLabels.realloc( nSeqLen );
1964  OUString *pLabels = aLabels.getArray();
1965  for (sal_Int32 i = 0; i < nSeqLen; ++i)
1966  {
1967  if (!bReturnEmptyText)
1968  {
1969  aText = bUseCol ? m_aColLabelText : m_aRowLabelText;
1970  sal_Int32 nCol = aDesc.nLeft;
1971  sal_Int32 nRow = aDesc.nTop;
1972  if (bUseCol)
1973  nCol = nCol + i;
1974  else
1975  nRow = nRow + i;
1976  OUString aCellName( sw_GetCellName( nCol, nRow ) );
1977 
1978  sal_Int32 nLen = aCellName.getLength();
1979  if (nLen)
1980  {
1981  const sal_Unicode *pBuf = aCellName.getStr();
1982  const sal_Unicode *pEnd = pBuf + nLen;
1983  while (pBuf < pEnd && ('0' > *pBuf || *pBuf > '9'))
1984  ++pBuf;
1985  // start of number found?
1986  if (pBuf < pEnd && ('0' <= *pBuf && *pBuf <= '9'))
1987  {
1988  OUString aRplc;
1989  OUString aNew;
1990  if (bUseCol)
1991  {
1992  aRplc = "%COLUMNLETTER";
1993  aNew = aCellName.copy(0, pBuf - aCellName.getStr());
1994  }
1995  else
1996  {
1997  aRplc = "%ROWNUMBER";
1998  aNew = OUString(pBuf, (aCellName.getStr() + nLen) - pBuf);
1999  }
2000  aText = aText.replaceFirst( aRplc, aNew );
2001  }
2002  }
2003  }
2004  pLabels[i] = aText;
2005  }
2006  }
2007  }
2008 
2009  return aLabels;
2010 }
2011 
2013  ::sal_Int32 /*nIndex*/ )
2014 {
2015  return 0;
2016 }
2017 
2018 std::vector< css::uno::Reference< css::table::XCell > > SwChartDataSequence::GetCells()
2019 {
2020  if (m_bDisposed)
2021  throw lang::DisposedException();
2022  auto pTableFormat(GetFrameFormat());
2023  if(!pTableFormat)
2024  return std::vector< css::uno::Reference< css::table::XCell > >();
2025  auto pTable(SwTable::FindTable(pTableFormat));
2026  if(pTable->IsTableComplex())
2027  return std::vector< css::uno::Reference< css::table::XCell > >();
2028  SwRangeDescriptor aDesc;
2029  if(!FillRangeDescriptor(aDesc, GetCellRangeName(*pTableFormat, *m_pTableCursor)))
2030  return std::vector< css::uno::Reference< css::table::XCell > >();
2031  return SwXCellRange::CreateXCellRange(m_pTableCursor, *pTableFormat, aDesc)->GetCells();
2032 }
2033 
2034 uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getTextualData()
2035 {
2036  SolarMutexGuard aGuard;
2037  auto vCells(GetCells());
2038  uno::Sequence< OUString > vTextData(vCells.size());
2039  std::transform(vCells.begin(),
2040  vCells.end(),
2041  vTextData.getArray(),
2042  [] (decltype(vCells)::value_type& xCell)
2043  { return static_cast<SwXCell*>(xCell.get())->getString(); });
2044  return vTextData;
2045 }
2046 
2047 uno::Sequence< uno::Any > SAL_CALL SwChartDataSequence::getData()
2048 {
2049  SolarMutexGuard aGuard;
2050  auto vCells(GetCells());
2051  uno::Sequence< uno::Any > vAnyData(vCells.size());
2052  std::transform(vCells.begin(),
2053  vCells.end(),
2054  vAnyData.getArray(),
2055  [] (decltype(vCells)::value_type& xCell)
2056  { return static_cast<SwXCell*>(xCell.get())->GetAny(); });
2057  return vAnyData;
2058 }
2059 
2060 uno::Sequence< double > SAL_CALL SwChartDataSequence::getNumericalData()
2061 {
2062  SolarMutexGuard aGuard;
2063  auto vCells(GetCells());
2064  uno::Sequence< double > vNumData(vCells.size());
2065  std::transform(vCells.begin(),
2066  vCells.end(),
2067  vNumData.getArray(),
2068  [] (decltype(vCells)::value_type& xCell)
2069  { return static_cast<SwXCell*>(xCell.get())->GetForcedNumericalValue(); });
2070  return vNumData;
2071 }
2072 
2073 uno::Reference< util::XCloneable > SAL_CALL SwChartDataSequence::createClone( )
2074 {
2075  SolarMutexGuard aGuard;
2076  if (m_bDisposed)
2077  throw lang::DisposedException();
2078  return new SwChartDataSequence( *this );
2079 }
2080 
2081 uno::Reference< beans::XPropertySetInfo > SAL_CALL SwChartDataSequence::getPropertySetInfo( )
2082 {
2083  SolarMutexGuard aGuard;
2084  if (m_bDisposed)
2085  throw lang::DisposedException();
2086 
2087  static uno::Reference< beans::XPropertySetInfo > xRes = m_pPropSet->getPropertySetInfo();
2088  return xRes;
2089 }
2090 
2092  const OUString& rPropertyName,
2093  const uno::Any& rValue )
2094 {
2095  SolarMutexGuard aGuard;
2096  if (m_bDisposed)
2097  throw lang::DisposedException();
2098 
2099  if (rPropertyName != UNO_NAME_ROLE)
2100  throw beans::UnknownPropertyException(rPropertyName);
2101 
2102  if ( !(rValue >>= m_aRole) )
2103  throw lang::IllegalArgumentException();
2104 }
2105 
2107  const OUString& rPropertyName )
2108 {
2109  SolarMutexGuard aGuard;
2110  if (m_bDisposed)
2111  throw lang::DisposedException();
2112 
2113  if (!(rPropertyName == UNO_NAME_ROLE))
2114  throw beans::UnknownPropertyException(rPropertyName);
2115 
2116  return uno::Any(m_aRole);
2117 }
2118 
2120  const OUString& /*rPropertyName*/,
2121  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
2122 {
2123  OSL_FAIL( "not implemented" );
2124 }
2125 
2127  const OUString& /*rPropertyName*/,
2128  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ )
2129 {
2130  OSL_FAIL( "not implemented" );
2131 }
2132 
2134  const OUString& /*rPropertyName*/,
2135  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ )
2136 {
2137  OSL_FAIL( "not implemented" );
2138 }
2139 
2141  const OUString& /*rPropertyName*/,
2142  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/ )
2143 {
2144  OSL_FAIL( "not implemented" );
2145 }
2146 
2148 {
2149  return "SwChartDataSequence";
2150 }
2151 
2152 sal_Bool SAL_CALL SwChartDataSequence::supportsService(const OUString& rServiceName )
2153 {
2154  return cppu::supportsService(this, rServiceName);
2155 }
2156 
2157 uno::Sequence< OUString > SAL_CALL SwChartDataSequence::getSupportedServiceNames( )
2158 {
2159  return { "com.sun.star.chart2.data.DataSequence" };
2160 }
2161 
2163 {
2164  if(rHint.GetId() == SfxHintId::Dying)
2165  m_pFormat = nullptr;
2166  if(!m_pFormat || !m_pTableCursor)
2167  {
2168  m_pFormat = nullptr;
2169  m_pTableCursor.reset(nullptr);
2170  dispose();
2171  }
2172  else if (rHint.GetId() == SfxHintId::SwLegacyModify)
2173  {
2174  setModified( true );
2175  }
2176 }
2177 
2179 {
2180  SolarMutexGuard aGuard;
2181  if (m_bDisposed)
2182  throw lang::DisposedException();
2183 
2184  return true;
2185 }
2186 
2188  sal_Bool bModified )
2189 {
2190  SolarMutexGuard aGuard;
2191  if (m_bDisposed)
2192  throw lang::DisposedException();
2193 
2194  if (bModified)
2195  LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
2196 }
2197 
2199  const uno::Reference< util::XModifyListener >& rxListener )
2200 {
2201  osl::MutexGuard aGuard( GetChartMutex() );
2202  if (!m_bDisposed && rxListener.is())
2203  m_aModifyListeners.addInterface( rxListener );
2204 }
2205 
2207  const uno::Reference< util::XModifyListener >& rxListener )
2208 {
2209  osl::MutexGuard aGuard( GetChartMutex() );
2210  if (!m_bDisposed && rxListener.is())
2211  m_aModifyListeners.removeInterface( rxListener );
2212 }
2213 
2214 void SAL_CALL SwChartDataSequence::disposing( const lang::EventObject& rSource )
2215 {
2216  if (m_bDisposed)
2217  throw lang::DisposedException();
2218  if (rSource.Source == static_cast<cppu::OWeakObject*>(m_xDataProvider.get()))
2219  {
2220  m_xDataProvider.clear();
2221  }
2222 }
2223 
2225 {
2226  bool bMustDispose( false );
2227  {
2228  osl::MutexGuard aGuard( GetChartMutex() );
2229  bMustDispose = !m_bDisposed;
2230  if (!m_bDisposed)
2231  m_bDisposed = true;
2232  }
2233  if (!bMustDispose)
2234  return;
2235 
2236  m_bDisposed = true;
2237  if (m_xDataProvider.is())
2238  {
2239  const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
2240  if (pTable)
2241  {
2242  uno::Reference< chart2::data::XDataSequence > xRef(this);
2243  m_xDataProvider->RemoveDataSequence( *pTable, xRef );
2244  }
2245  else {
2246  OSL_FAIL( "table missing" );
2247  }
2248 
2249  //#i119653# The bug is crashed for an exception thrown by
2250  //SwCharDataSequence::setModified() because
2251  //the SwCharDataSequence object has been disposed.
2252 
2253  //Actually, the former design of SwClient will disconnect itself
2254  //from the notification list in its destructor.
2255 
2256  //But the SwCharDataSequence won't be destructed but disposed in code
2257  //(the data member SwChartDataSequence::bDisposed will be set to
2258  //TRUE), the relationship between client and modification is not
2259  //released.
2260 
2261  //So any notification from modify object will lead to said
2262  //exception threw out. Recorrect the logic of code in
2263  //SwChartDataSequence::Dispose(), release the relationship
2264  //here...
2266  {
2267  EndListeningAll();
2268  m_pFormat = nullptr;
2269  m_pTableCursor.reset(nullptr);
2270  }
2271  }
2272 
2273  // require listeners to release references to this object
2274  lang::EventObject aEvtObj( static_cast< chart2::data::XDataSequence * >(this) );
2276  m_aEvtListeners.disposeAndClear( aEvtObj );
2277 }
2278 
2280  const uno::Reference< lang::XEventListener >& rxListener )
2281 {
2282  osl::MutexGuard aGuard( GetChartMutex() );
2283  if (!m_bDisposed && rxListener.is())
2284  m_aEvtListeners.addInterface( rxListener );
2285 }
2286 
2288  const uno::Reference< lang::XEventListener >& rxListener )
2289 {
2290  osl::MutexGuard aGuard( GetChartMutex() );
2291  if (!m_bDisposed && rxListener.is())
2292  m_aEvtListeners.removeInterface( rxListener );
2293 }
2294 
2296 {
2297  if (m_bDisposed)
2298  throw lang::DisposedException();
2299 
2300  // to be set if the last box of the data-sequence was removed here
2301  bool bNowEmpty = false;
2302 
2303  // if the implementation cursor gets affected (i.e. the box where it is located
2304  // in gets removed) we need to move it before that... (otherwise it does not need to change)
2305 
2306  const SwStartNode* pPointStartNode = m_pTableCursor->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
2307  const SwStartNode* pMarkStartNode = m_pTableCursor->GetMark()->nNode.GetNode().FindTableBoxStartNode();
2308 
2309  if (!m_pTableCursor->HasMark() || (pPointStartNode == rBox.GetSttNd() && pMarkStartNode == rBox.GetSttNd()))
2310  {
2311  bNowEmpty = true;
2312  }
2313  else if (pPointStartNode == rBox.GetSttNd() || pMarkStartNode == rBox.GetSttNd())
2314  {
2315  sal_Int32 nPointRow = -1, nPointCol = -1;
2316  sal_Int32 nMarkRow = -1, nMarkCol = -1;
2317  const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
2318  OUString aPointCellName( pTable->GetTableBox( pPointStartNode->GetIndex() )->GetName() );
2319  OUString aMarkCellName( pTable->GetTableBox( pMarkStartNode->GetIndex() )->GetName() );
2320 
2321  SwXTextTable::GetCellPosition( aPointCellName, nPointCol, nPointRow );
2322  SwXTextTable::GetCellPosition( aMarkCellName, nMarkCol, nMarkRow );
2323  OSL_ENSURE( nPointRow >= 0 && nPointCol >= 0, "invalid row and col" );
2324  OSL_ENSURE( nMarkRow >= 0 && nMarkCol >= 0, "invalid row and col" );
2325 
2326  // move vertical or horizontal?
2327  OSL_ENSURE( nPointRow == nMarkRow || nPointCol == nMarkCol,
2328  "row/col indices not matching" );
2329  OSL_ENSURE( nPointRow != nMarkRow || nPointCol != nMarkCol,
2330  "point and mark are identical" );
2331  bool bMoveVertical = (nPointCol == nMarkCol);
2332  bool bMoveHorizontal = (nPointRow == nMarkRow);
2333 
2334  // get movement direction
2335  bool bMoveLeft = false; // move left or right?
2336  bool bMoveUp = false; // move up or down?
2337  if (bMoveVertical)
2338  {
2339  if (pPointStartNode == rBox.GetSttNd()) // move point?
2340  bMoveUp = nPointRow > nMarkRow;
2341  else // move mark
2342  bMoveUp = nMarkRow > nPointRow;
2343  }
2344  else if (bMoveHorizontal)
2345  {
2346  if (pPointStartNode == rBox.GetSttNd()) // move point?
2347  bMoveLeft = nPointCol > nMarkCol;
2348  else // move mark
2349  bMoveLeft = nMarkCol > nPointCol;
2350  }
2351  else {
2352  OSL_FAIL( "neither vertical nor horizontal movement" );
2353  }
2354 
2355  // get new box (position) to use...
2356  sal_Int32 nRow = (pPointStartNode == rBox.GetSttNd()) ? nPointRow : nMarkRow;
2357  sal_Int32 nCol = (pPointStartNode == rBox.GetSttNd()) ? nPointCol : nMarkCol;
2358  if (bMoveVertical)
2359  nRow += bMoveUp ? -1 : +1;
2360  if (bMoveHorizontal)
2361  nCol += bMoveLeft ? -1 : +1;
2362  const OUString aNewCellName = sw_GetCellName( nCol, nRow );
2363  SwTableBox* pNewBox = const_cast<SwTableBox*>(pTable->GetTableBox( aNewCellName ));
2364 
2365  if (pNewBox) // set new position (cell range) to use
2366  {
2367  // This is how you get the first content node of a row:
2368  // First get a SwNodeIndex pointing to the node after SwStartNode of the box...
2369  SwNodeIndex aIdx( *pNewBox->GetSttNd(), +1 );
2370  // This can be a SwContentNode, but might also be a table or section node,
2371  // therefore call GoNext
2372  SwContentNode *pCNd = aIdx.GetNode().GetContentNode();
2373  if (!pCNd)
2374  pCNd = GetFrameFormat()->GetDoc()->GetNodes().GoNext( &aIdx );
2375  // and then one can e.g. create a SwPosition:
2376  SwPosition aNewPos( *pCNd ); // new position to be used with cursor
2377 
2378  // if the mark is to be changed, make sure there is one
2379  if (pMarkStartNode == rBox.GetSttNd() && !m_pTableCursor->HasMark())
2381 
2382  // set cursor to new position
2383  SwPosition *pPos = (pPointStartNode == rBox.GetSttNd()) ?
2385  if (pPos)
2386  {
2387  pPos->nNode = aNewPos.nNode;
2388  pPos->nContent = aNewPos.nContent;
2389  }
2390  else {
2391  OSL_FAIL( "neither point nor mark available for change" );
2392  }
2393  }
2394  else {
2395  OSL_FAIL( "failed to get position" );
2396  }
2397  }
2398 
2399  return bNowEmpty;
2400 }
2401 
2403 {
2404  SwFrameFormat* pTableFormat = GetFrameFormat();
2405  if(pTableFormat)
2406  {
2407  SwTable* pTable = SwTable::FindTable( pTableFormat );
2408  if(!pTable->IsTableComplex())
2409  {
2410  FillRangeDescriptor( rRangeDesc, GetCellRangeName( *pTableFormat, *m_pTableCursor ) );
2411  }
2412  }
2413 }
2414 
2429 void SwChartDataSequence::ExtendTo( bool bExtendCol,
2430  sal_Int32 nFirstNew, sal_Int32 nCount )
2431 {
2432  SwUnoTableCursor* pUnoTableCursor = dynamic_cast<SwUnoTableCursor*>(&(*m_pTableCursor));
2433  if (!pUnoTableCursor)
2434  return;
2435 
2436  const SwStartNode *pStartNd = nullptr;
2437  const SwTableBox *pStartBox = nullptr;
2438  const SwTableBox *pEndBox = nullptr;
2439 
2440  const SwTable* pTable = SwTable::FindTable( GetFrameFormat() );
2441  OSL_ENSURE( !pTable->IsTableComplex(), "table too complex" );
2442  if (nCount < 1 || nFirstNew < 0 || pTable->IsTableComplex())
2443  return;
2444 
2445  // get range descriptor (cell range) for current data-sequence
2446 
2447  pStartNd = pUnoTableCursor->GetPoint()->nNode.GetNode().FindTableBoxStartNode();
2448  pEndBox = pTable->GetTableBox( pStartNd->GetIndex() );
2449  const OUString aEndBox( pEndBox->GetName() );
2450 
2451  pStartNd = pUnoTableCursor->GetMark()->nNode.GetNode().FindTableBoxStartNode();
2452  pStartBox = pTable->GetTableBox( pStartNd->GetIndex() );
2453  const OUString aStartBox( pStartBox->GetName() );
2454 
2455  SwRangeDescriptor aDesc;
2456  // note that cell range here takes the newly added rows/cols already into account
2457  FillRangeDescriptor( aDesc, aStartBox + ":" + aEndBox );
2458 
2459  bool bChanged = false;
2460  OUString aNewStartCell;
2461  OUString aNewEndCell;
2462  if (bExtendCol && aDesc.nBottom + 1 == nFirstNew)
2463  {
2464  // new column cells adjacent to the bottom of the
2465  // current data-sequence to be added...
2466  OSL_ENSURE( aDesc.nLeft == aDesc.nRight, "data-sequence is not a column" );
2467  aNewStartCell = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
2468  aNewEndCell = sw_GetCellName(aDesc.nRight, aDesc.nBottom + nCount);
2469  bChanged = true;
2470  }
2471  else if (bExtendCol && aDesc.nTop - nCount == nFirstNew)
2472  {
2473  // new column cells adjacent to the top of the
2474  // current data-sequence to be added...
2475  OSL_ENSURE( aDesc.nLeft == aDesc.nRight, "data-sequence is not a column" );
2476  aNewStartCell = sw_GetCellName(aDesc.nLeft, aDesc.nTop - nCount);
2477  aNewEndCell = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
2478  bChanged = true;
2479  }
2480  else if (!bExtendCol && aDesc.nRight + 1 == nFirstNew)
2481  {
2482  // new row cells adjacent to the right of the
2483  // current data-sequence to be added...
2484  OSL_ENSURE( aDesc.nTop == aDesc.nBottom, "data-sequence is not a row" );
2485  aNewStartCell = sw_GetCellName(aDesc.nLeft, aDesc.nTop);
2486  aNewEndCell = sw_GetCellName(aDesc.nRight + nCount, aDesc.nBottom);
2487  bChanged = true;
2488  }
2489  else if (!bExtendCol && aDesc.nLeft - nCount == nFirstNew)
2490  {
2491  // new row cells adjacent to the left of the
2492  // current data-sequence to be added...
2493  OSL_ENSURE( aDesc.nTop == aDesc.nBottom, "data-sequence is not a row" );
2494  aNewStartCell = sw_GetCellName(aDesc.nLeft - nCount, aDesc.nTop);
2495  aNewEndCell = sw_GetCellName(aDesc.nRight, aDesc.nBottom);
2496  bChanged = true;
2497  }
2498 
2499  if (bChanged)
2500  {
2501  // move table cursor to new start and end of data-sequence
2502  const SwTableBox *pNewStartBox = pTable->GetTableBox( aNewStartCell );
2503  const SwTableBox *pNewEndBox = pTable->GetTableBox( aNewEndCell );
2504  pUnoTableCursor->SetMark();
2505  pUnoTableCursor->GetPoint()->nNode = *pNewEndBox->GetSttNd();
2506  pUnoTableCursor->GetMark()->nNode = *pNewStartBox->GetSttNd();
2507  pUnoTableCursor->Move( fnMoveForward, GoInNode );
2508  pUnoTableCursor->MakeBoxSels();
2509  }
2510 }
2511 
2513  m_aEventListeners( GetChartMutex() ),
2514  m_aModifyListeners( GetChartMutex() )
2515 {
2516  m_bDisposed = false;
2517 }
2518 
2520 {
2521 }
2522 
2523 uno::Reference< chart2::data::XDataSequence > SAL_CALL SwChartLabeledDataSequence::getValues( )
2524 {
2525  SolarMutexGuard aGuard;
2526  if (m_bDisposed)
2527  throw lang::DisposedException();
2528  return m_xData;
2529 }
2530 
2532  uno::Reference< chart2::data::XDataSequence >& rxDest,
2533  const uno::Reference< chart2::data::XDataSequence >& rxSource)
2534 {
2535  uno::Reference< util::XModifyListener > xML(this);
2536  uno::Reference< lang::XEventListener > xEL(this);
2537 
2538  // stop listening to old data-sequence
2539  uno::Reference< util::XModifyBroadcaster > xMB( rxDest, uno::UNO_QUERY );
2540  if (xMB.is())
2541  xMB->removeModifyListener( xML );
2542  uno::Reference< lang::XComponent > xC( rxDest, uno::UNO_QUERY );
2543  if (xC.is())
2544  xC->removeEventListener( xEL );
2545 
2546  rxDest = rxSource;
2547 
2548  // start listening to new data-sequence
2549  xC.set( rxDest, uno::UNO_QUERY );
2550  if (xC.is())
2551  xC->addEventListener( xEL );
2552  xMB.set( rxDest, uno::UNO_QUERY );
2553  if (xMB.is())
2554  xMB->addModifyListener( xML );
2555 }
2556 
2558  const uno::Reference< chart2::data::XDataSequence >& rxSequence )
2559 {
2560  SolarMutexGuard aGuard;
2561  if (m_bDisposed)
2562  throw lang::DisposedException();
2563 
2564  if (m_xData != rxSequence)
2565  {
2566  SetDataSequence( m_xData, rxSequence );
2567  // inform listeners of changes
2568  LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
2569  }
2570 }
2571 
2572 uno::Reference< chart2::data::XDataSequence > SAL_CALL SwChartLabeledDataSequence::getLabel( )
2573 {
2574  SolarMutexGuard aGuard;
2575  if (m_bDisposed)
2576  throw lang::DisposedException();
2577  return m_xLabels;
2578 }
2579 
2581  const uno::Reference< chart2::data::XDataSequence >& rxSequence )
2582 {
2583  SolarMutexGuard aGuard;
2584  if (m_bDisposed)
2585  throw lang::DisposedException();
2586 
2587  if (m_xLabels != rxSequence)
2588  {
2589  SetDataSequence( m_xLabels, rxSequence );
2590  // inform listeners of changes
2591  LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
2592  }
2593 }
2594 
2595 uno::Reference< util::XCloneable > SAL_CALL SwChartLabeledDataSequence::createClone( )
2596 {
2597  SolarMutexGuard aGuard;
2598  if (m_bDisposed)
2599  throw lang::DisposedException();
2600 
2601  uno::Reference< util::XCloneable > xDataCloneable( m_xData, uno::UNO_QUERY );
2602  uno::Reference< util::XCloneable > xLabelsCloneable( m_xLabels, uno::UNO_QUERY );
2604  if (xDataCloneable.is())
2605  {
2606  uno::Reference< chart2::data::XDataSequence > xDataClone( xDataCloneable->createClone(), uno::UNO_QUERY );
2607  pRes->setValues( xDataClone );
2608  }
2609 
2610  if (xLabelsCloneable.is())
2611  {
2612  uno::Reference< chart2::data::XDataSequence > xLabelsClone( xLabelsCloneable->createClone(), uno::UNO_QUERY );
2613  pRes->setLabel( xLabelsClone );
2614  }
2615  return pRes;
2616 }
2617 
2619 {
2620  return "SwChartLabeledDataSequence";
2621 }
2622 
2624  const OUString& rServiceName )
2625 {
2626  return cppu::supportsService(this, rServiceName);
2627 }
2628 
2629 uno::Sequence< OUString > SAL_CALL SwChartLabeledDataSequence::getSupportedServiceNames( )
2630 {
2631  return { "com.sun.star.chart2.data.LabeledDataSequence" };
2632 }
2633 
2635  const lang::EventObject& rSource )
2636 {
2637  osl::MutexGuard aGuard( GetChartMutex() );
2638  uno::Reference< uno::XInterface > xRef( rSource.Source );
2639  if (xRef == m_xData)
2640  m_xData.clear();
2641  if (xRef == m_xLabels)
2642  m_xLabels.clear();
2643  if (!m_xData.is() && !m_xLabels.is())
2644  dispose();
2645 }
2646 
2648  const lang::EventObject& rEvent )
2649 {
2650  if (rEvent.Source == m_xData || rEvent.Source == m_xLabels)
2651  {
2652  LaunchModifiedEvent( m_aModifyListeners, static_cast< XModifyBroadcaster * >(this) );
2653  }
2654 }
2655 
2657  const uno::Reference< util::XModifyListener >& rxListener )
2658 {
2659  osl::MutexGuard aGuard( GetChartMutex() );
2660  if (!m_bDisposed && rxListener.is())
2661  m_aModifyListeners.addInterface( rxListener );
2662 }
2663 
2665  const uno::Reference< util::XModifyListener >& rxListener )
2666 {
2667  osl::MutexGuard aGuard( GetChartMutex() );
2668  if (!m_bDisposed && rxListener.is())
2669  m_aModifyListeners.removeInterface( rxListener );
2670 }
2671 
2673 {
2674  bool bMustDispose( false );
2675  {
2676  osl::MutexGuard aGuard( GetChartMutex() );
2677  bMustDispose = !m_bDisposed;
2678  if (!m_bDisposed)
2679  m_bDisposed = true;
2680  }
2681  if (bMustDispose)
2682  {
2683  m_bDisposed = true;
2684 
2685  // require listeners to release references to this object
2686  lang::EventObject aEvtObj( static_cast< chart2::data::XLabeledDataSequence * >(this) );
2689  }
2690 }
2691 
2693  const uno::Reference< lang::XEventListener >& rxListener )
2694 {
2695  osl::MutexGuard aGuard( GetChartMutex() );
2696  if (!m_bDisposed && rxListener.is())
2697  m_aEventListeners.addInterface( rxListener );
2698 }
2699 
2701  const uno::Reference< lang::XEventListener >& rxListener )
2702 {
2703  osl::MutexGuard aGuard( GetChartMutex() );
2704  if (!m_bDisposed && rxListener.is())
2705  m_aEventListeners.removeInterface( rxListener );
2706 }
2707 
2708 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
css::uno::Reference< css::chart2::data::XDataSource > Impl_createDataSource(const css::uno::Sequence< css::beans::PropertyValue > &aArguments, bool bTestOnly=false)
Definition: unochart.cxx:517
void AddRowCols(const SwTable &rTable, const SwSelBoxes &rBoxes, sal_uInt16 nLines, bool bBehind)
SwChartDataProvider::AddRowCols tries to notify charts of added columns or rows and extends the value...
Definition: unochart.cxx:1550
bool IsTableComplex() const
Definition: swtable.cxx:1437
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:684
Starts a section of nodes in the document model.
Definition: node.hxx:313
void Normalize()
Definition: unotbl.cxx:547
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1775
OUString m_aRowLabelText
Definition: unochart.hxx:239
SwNode & GetEndOfAutotext() const
Section for all Flys/Header/Footers.
Definition: ndarr.hxx:154
const Value & back() const
virtual void SAL_CALL dispose() override
Definition: unochart.cxx:2672
static void GetTableByName(const SwDoc &rDoc, std::u16string_view rTableName, SwFrameFormat **ppTableFormat, SwTable **ppTable)
Definition: unochart.cxx:322
Marks a position in the document model.
Definition: pam.hxx:36
const SwTableBox * GetTableBox(const OUString &rName, const bool bPerformValidCheck=false) const
Definition: swtable.cxx:1336
SwOLENode * GetOLENode()
Inline methods from Node.hxx.
Definition: ndole.hxx:161
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unochart.cxx:1394
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: unochart.cxx:2073
SwChartLockController_Helper(const SwChartLockController_Helper &)=delete
virtual void SAL_CALL setLabel(const css::uno::Reference< css::chart2::data::XDataSequence > &xSequence) override
Definition: unochart.cxx:2580
SwNodeIndex nNode
Definition: pam.hxx:38
static bool GetTableAndCellsFromRangeRep(const OUString &rRangeRepresentation, OUString &rTableName, OUString &rStartCell, OUString &rEndCell, bool bSortStartEndCells=true)
Definition: unochart.cxx:273
virtual ~SwChartDataProvider() override
Definition: unochart.cxx:513
static void GetFormatAndCreateCursorFromRangeRep(const SwDoc *pDoc, const OUString &rRangeRepresentation, SwFrameFormat **ppTableFormat, std::shared_ptr< SwUnoCursor > &rpUnoCursor)
Definition: unochart.cxx:344
~SwChartLockController_Helper() COVERITY_NOEXCEPT_FALSE
Definition: unochart.cxx:93
const OUString & GetChartTableName() const
Definition: ndole.hxx:152
const SwPosition * GetMark() const
Definition: pam.hxx:210
sal_Int32 addInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:909
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unochart.cxx:2287
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unochart.cxx:1407
Definition: doc.hxx:188
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &aIdentifier) override
Definition: unochart.cxx:1882
void FillRangeDesc(SwRangeDescriptor &rRangeDesc) const
Definition: unochart.cxx:2402
virtual OUString SAL_CALL convertRangeToXML(const OUString &aRangeRepresentation) override
Definition: unochart.cxx:1626
const SwDoc * m_pDoc
Definition: unochart.hxx:129
virtual OUString SAL_CALL getSourceRangeRepresentation() override
Definition: unochart.cxx:1888
void disposeAndClear(const css::lang::EventObject &rEvt)
sal_Int32 nLeft
Definition: unotbl.hxx:247
SwNode & GetNode() const
Definition: ndindex.hxx:121
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
Definition: unochart.cxx:2700
void InvalidateTable(const SwTable *pTable)
Definition: unochart.cxx:1427
void MakeBoxSels()
Definition: unocrsr.cxx:182
::comphelper::OInterfaceContainerHelper2 m_aEventListeners
Definition: unochart.hxx:331
static osl::Mutex & GetChartMutex()
Definition: unochart.cxx:152
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unochart.cxx:2133
sal_Int32 removeInterface(const css::uno::Reference< css::uno::XInterface > &rxIFace)
void RemoveDataSequence(const SwTable &rTable, css::uno::Reference< css::chart2::data::XDataSequence > const &rxDataSequence)
Definition: unochart.cxx:1422
std::vector< css::uno::Reference< css::table::XCell > > GetCells()
Definition: unochart.cxx:2018
SwTableLine * front() const
Definition: swtable.hxx:82
bool HasWriterListeners() const
Definition: calbck.hxx:203
OUString sw_GetCellName(sal_Int32 nColumn, sal_Int32 nRow)
get cell name at a specified coordinate
Definition: unotbl.cxx:490
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:205
css::uno::Reference< css::beans::XPropertySetInfo > const & getPropertySetInfo() const
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
Definition: unochart.cxx:2126
SfxHintId GetId() const
#define PROPERTY_MAP_CHART2_DATA_SEQUENCE
Definition: unomap.hxx:116
size_type size() const
Definition: swtable.hxx:77
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unochart.cxx:2623
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unochart.cxx:2119
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
HashMap_OWString_Interface aMap
virtual css::uno::Sequence< double > SAL_CALL getNumericalData() override
Definition: unochart.cxx:2060
std::set< css::uno::WeakReference< css::chart2::data::XDataSequence >, lt_DataSequenceRef > Set_DataSequenceRef_t
Definition: unochart.hxx:117
void ExtendTo(bool bExtendCol, sal_Int32 nFirstNew, sal_Int32 nCount)
Extends the data-sequence by new cells added at the end of the direction the data-sequence points to...
Definition: unochart.cxx:2429
sal_uInt16 sal_Unicode
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: unochart.cxx:2664
sal_Int32 nBottom
Definition: unotbl.hxx:248
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unochart.cxx:1770
SwIndex nContent
Definition: pam.hxx:39
enumrange< T >::Iterator begin(enumrange< T >)
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
Definition: unochart.cxx:2140
CellRange getCellRangeFromXMLString(const OUString &rXMLString)
virtual css::uno::Sequence< css::beans::PropertyValue > SAL_CALL detectArguments(const css::uno::Reference< css::chart2::data::XDataSource > &xDataSource) override
Definition: unochart.cxx:961
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:961
const OUString & GetName() const
Definition: format.hxx:115
int nCount
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unochart.cxx:2279
void AddDataSequence(const SwTable &rTable, css::uno::Reference< css::chart2::data::XDataSequence > const &rxDataSequence)
Definition: unochart.cxx:1417
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
virtual void SAL_CALL setModified(sal_Bool bModified) override
Definition: unochart.cxx:2187
bool FillRangeDescriptor(SwRangeDescriptor &rDesc, const OUString &rCellRangeName)
rCellRangeName needs to be of one of the following formats:
Definition: unochart.cxx:177
Mutex aMutex
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unochart.cxx:2692
virtual css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > SAL_CALL getDataSequences() override
Definition: unochart.cxx:1754
virtual void SAL_CALL modified(const css::lang::EventObject &aEvent) override
Definition: unochart.cxx:2647
sal_Int32 nRight
Definition: unotbl.hxx:249
virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone() override
Definition: unochart.cxx:2595
::comphelper::OInterfaceContainerHelper2 m_aEventListeners
Definition: unochart.hxx:128
static SW_DLLPUBLIC void GetCellPosition(const OUString &rCellName, sal_Int32 &o_rColumn, sal_Int32 &o_rRow)
get position of a cell with a given name
Definition: unotbl.cxx:362
virtual void SAL_CALL dispose() override
Definition: unochart.cxx:1361
static OUString GetCellRangeName(const SwFrameFormat &rTableFormat, SwUnoCursor &rTableCursor)
Definition: unochart.cxx:202
size_type size() const
virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL getLabel() override
Definition: unochart.cxx:2572
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unochart.cxx:2081
virtual ~SwChartLabeledDataSequence() override
Definition: unochart.cxx:2519
const OUString & GetCurrentPersistName() const
Definition: ndole.hxx:69
sal_Int32 getTokenCount(std::string_view rIn, char cTok)
virtual OUString SAL_CALL getImplementationName() override
Definition: unochart.cxx:2147
const css::uno::Sequence< sal_Int8 > & getSeq() const
void EndListeningAll()
OUString GetName() const
Definition: swtable.cxx:1858
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:504
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:1966
virtual ~SwChartDataSource() override
Definition: unochart.cxx:1750
Style of a layout element.
Definition: frmfmt.hxx:59
virtual OUString SAL_CALL convertRangeFromXML(const OUString &aXMLRange) override
Definition: unochart.cxx:1696
::comphelper::OInterfaceContainerHelper2 m_aEvtListeners
Definition: unochart.hxx:235
virtual sal_Bool SAL_CALL createDataSequenceByRangeRepresentationPossible(const OUString &aRangeRepresentation) override
Definition: unochart.cxx:1322
SwFrameFormat * m_pFormat
Definition: unochart.hxx:234
sal_Int32 nTop
Definition: unotbl.hxx:246
int i
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:961
void sw_NormalizeRange(OUString &rCell1, OUString &rCell2)
cleanup order in a range
Definition: unotbl.cxx:535
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: unochart.cxx:2214
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:133
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: unochart.cxx:2656
const SwPosition * GetPoint() const
Definition: pam.hxx:208
SwChartDataSource(const SwChartDataSource &)=delete
rtl::Reference< SwChartDataProvider > m_xDataProvider
Definition: unochart.hxx:242
sw::UnoCursorPointer m_pTableCursor
Definition: unochart.hxx:244
css::uno::Reference< css::chart2::data::XDataSequence > Impl_createDataSequenceByRangeRepresentation(const OUString &aRangeRepresentation, bool bTestOnly=false)
Definition: unochart.cxx:1294
void DisposeAllDataSequences(const SwTable *pTable)
Definition: unochart.cxx:1503
virtual sal_Bool SAL_CALL isModified() override
Definition: unochart.cxx:2178
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
Definition: unochart.cxx:1386
OUString m_aRole
#define UNO_NAME_ROLE
Definition: unoprnms.hxx:779
css::uno::Reference< css::chart2::data::XDataSequence > m_xLabels
Definition: unochart.hxx:335
SwContentNode * GetContentNode()
Definition: node.hxx:617
SwNodeOffset GetIndex() const
Definition: node.hxx:292
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:206
virtual void SAL_CALL dispose() override
Definition: unochart.cxx:2224
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: unochart.cxx:2106
SwFrameFormat * GetFrameFormat() const
Definition: unochart.hxx:309
bool DeleteBox(const SwTableBox &rBox)
Definition: unochart.cxx:2295
virtual void Start(bool bStartTimer=true) override
::comphelper::OInterfaceContainerHelper2 m_aModifyListeners
Definition: unochart.hxx:236
virtual SwChartLockController_Helper & GetChartControllerHelper()=0
returns chart controller helper that is used to lock/unlock all charts when relevant parts of tables ...
unsigned char sal_Bool
int sw_CompareCellsByColFirst(const OUString &rCellName1, const OUString &rCellName2)
compare position of two cells (check columns first)
Definition: unotbl.cxx:437
static::rtl::Reference< SwXCellRange > CreateXCellRange(const sw::UnoCursorPointer &pCursor, SwFrameFormat &rFrameFormat, SwRangeDescriptor const &rDesc)
Definition: unotbl.cxx:3208
virtual void SAL_CALL setValues(const css::uno::Reference< css::chart2::data::XDataSequence > &xSequence) override
Definition: unochart.cxx:2557
Marks a node in the document model.
Definition: ndindex.hxx:32
virtual ~SwChartDataSequence() override
Definition: unochart.cxx:1872
css::uno::Reference< css::chart2::data::XDataSequence > m_xData
Definition: unochart.hxx:334
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:123
bool StartListening(SvtBroadcaster &rBroadcaster)
SwStartNode * GetStartNode()
Definition: node.hxx:593
virtual void Notify(const SfxHint &rHint) override
Definition: unochart.cxx:2162
virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL getValues() override
Definition: unochart.cxx:2523
void SetTimeout(sal_uInt64 nTimeoutMs)
IDocumentChartDataProviderAccess const & getIDocumentChartDataProviderAccess() const
Definition: doc.cxx:227
SwTableLines & GetTabLines()
Definition: swtable.hxx:202
enumrange< T >::Iterator end(enumrange< T >)
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
virtual OUString SAL_CALL getImplementationName() override
Definition: unochart.cxx:2618
const SfxItemPropertySet * m_pPropSet
Definition: unochart.hxx:246
int sw_CompareCellRanges(const OUString &rRange1StartCell, const OUString &rRange1EndCell, const OUString &rRange2StartCell, const OUString &rRange2EndCell, bool bCmpColsFirst)
compare position of two cell ranges
Definition: unotbl.cxx:464
OUString getXMLStringFromCellRange(const CellRange &rRange)
virtual sal_Bool SAL_CALL createDataSourcePossible(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: unochart.cxx:900
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unochart.cxx:2157
::comphelper::OInterfaceContainerHelper2 m_aModifyListeners
Definition: unochart.hxx:332
std::unique_ptr< uint8_t[]> pLabels
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:102
cppu::WeakImplHelper< css::chart2::data::XDataSequence, css::chart2::data::XTextualDataSequence, css::chart2::data::XNumericalDataSequence, css::util::XCloneable, css::beans::XPropertySet, css::lang::XServiceInfo, css::lang::XUnoTunnel, css::util::XModifiable, css::lang::XEventListener, css::lang::XComponent > SwChartDataSequenceBaseClass
Definition: unochart.hxx:228
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unochart.cxx:1412
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unochart.cxx:1876
DefTokenId nToken
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:368
static bool GetSubranges(const OUString &rRangeRepresentation, uno::Sequence< OUString > &rSubRanges, bool bNormalize)
Definition: unochart.cxx:412
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:459
void Stop()
void LockUnlockAllCharts(bool bLock)
Definition: unochart.cxx:113
void reset(std::shared_ptr< SwUnoCursor > pNew)
Definition: unocrsr.hxx:157
sal_Int64 getSomethingImpl(const css::uno::Sequence< sal_Int8 > &rId, T *pThis, FallbackToGetSomethingOf< Base >={})
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
virtual OUString SAL_CALL getImplementationName() override
Definition: unochart.cxx:1760
IMPL_LINK_NOARG(SwChartLockController_Helper, DoUnlockAllCharts, Timer *, void)
Definition: unochart.cxx:147
if(aStr!=aBuf) UpdateName_Impl(m_xFollowLb.get()
SwNodes & GetNodes()
Definition: doc.hxx:409
virtual css::uno::Sequence< OUString > SAL_CALL getTextualData() override
Definition: unochart.cxx:2034
Map_Set_DataSequenceRef_t m_aDataSequences
Definition: unochart.hxx:126
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:406
css::chart2::data::DataSequenceRole m_aRole
Definition: unochart.hxx:237
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
void SetInvokeHandler(const Link< Timer *, void > &rLink)
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
Definition: unochart.cxx:2634
size_t GetTableFrameFormatCount(bool bUsed) const
Definition: docfmt.cxx:771
virtual css::uno::Sequence< css::uno::Any > SAL_CALL getData() override
Definition: unochart.cxx:2047
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unochart.cxx:2629
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unochart.cxx:2152
bool IsChart() const
virtual css::uno::Sequence< OUString > SAL_CALL generateLabel(css::chart2::data::LabelOrigin eLabelOrigin) override
Definition: unochart.cxx:1905
const SwStartNode * FindTableBoxStartNode() const
Definition: node.hxx:198
SwFrameFormat & GetTableFrameFormat(size_t nFormat, bool bUsed) const
Definition: docfmt.cxx:788
SwNodeOffset Count() const
Definition: ndarr.hxx:140
static void SortSubranges(uno::Sequence< OUString > &rSubRanges, bool bCmpByColumn)
Definition: unochart.cxx:460
static OUString GetBrokenCellRangeForExport(const OUString &rCellRangeRepresentation)
Fix for #i79009 we need to return a property that has the same value as the property 'CellRangeRepres...
Definition: unochart.cxx:934
css::uno::XInterface * next()
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByValueArray(const OUString &aRole, const OUString &aRangeRepresentation, const OUString &aRoleQualifier) override
Definition: unochart.cxx:1354
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
OUString getString(const Any &_rAny)
OUString m_aColLabelText
Definition: unochart.hxx:240
void DeleteBox(const SwTable *pTable, const SwTableBox &rBox)
Definition: unochart.cxx:1449
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: unochart.cxx:2091
virtual css::uno::Reference< css::sheet::XRangeSelection > SAL_CALL getRangeSelection() override
Definition: unochart.cxx:1347
virtual void SAL_CALL addModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: unochart.cxx:2198
SwChartDataSequence(const SwChartDataSequence &rObj)
Definition: unochart.cxx:1823
void SetDataSequence(css::uno::Reference< css::chart2::data::XDataSequence > &rxDest, const css::uno::Reference< css::chart2::data::XDataSequence > &rxSource)
Definition: unochart.cxx:2531
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1293
virtual OUString SAL_CALL getImplementationName() override
Definition: unochart.cxx:1402
static void LaunchModifiedEvent(::comphelper::OInterfaceContainerHelper2 &rICH, const uno::Reference< uno::XInterface > &rxI)
Definition: unochart.cxx:158
static OUString GetRangeRepFromTableAndCells(std::u16string_view rTableName, std::u16string_view rStartCell, std::u16string_view rEndCell, bool bForceEndCellName)
Definition: unochart.cxx:253
virtual ::sal_Int32 SAL_CALL getNumberFormatKeyByIndex(::sal_Int32 nIndex) override
Definition: unochart.cxx:2012
virtual css::uno::Reference< css::chart2::data::XDataSequence > SAL_CALL createDataSequenceByRangeRepresentation(const OUString &aRangeRepresentation) override
Definition: unochart.cxx:1340
sal_uInt16 nPos
css::uno::Sequence< css::uno::Reference< css::chart2::data::XLabeledDataSequence > > m_aLDS
Definition: unochart.hxx:197
virtual css::uno::Reference< css::chart2::data::XDataSource > SAL_CALL createDataSource(const css::uno::Sequence< css::beans::PropertyValue > &aArguments) override
Definition: unochart.cxx:918
SwChartDataProvider(const SwChartDataProvider &)=delete
static void DoUpdateAllCharts(SwDoc *pDoc)
Definition: unochart.cxx:50
virtual void SAL_CALL removeModifyListener(const css::uno::Reference< css::util::XModifyListener > &aListener) override
Definition: unochart.cxx:2206
Base class of the Writer document model elements.
Definition: node.hxx:81
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
Definition: unochart.cxx:1765