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