LibreOffice Module sc (master)  1
externallinkbuffer.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 <externallinkbuffer.hxx>
21 
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/sheet/DDELinkInfo.hpp>
24 #include <com/sun/star/sheet/ExternalLinkType.hpp>
25 #include <com/sun/star/sheet/XDDELinks.hpp>
26 #include <com/sun/star/sheet/XDDELinkResults.hpp>
27 #include <com/sun/star/sheet/XExternalDocLinks.hpp>
28 #include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
29 #include <o3tl/safeint.hxx>
30 #include <osl/diagnose.h>
31 #include <sal/log.hxx>
32 #include <oox/core/filterbase.hxx>
35 #include <oox/token/namespaces.hxx>
36 #include <oox/token/properties.hxx>
37 #include <oox/core/relations.hxx>
38 #include <oox/token/tokens.hxx>
39 #include <addressconverter.hxx>
40 #include <biffhelper.hxx>
41 
42 namespace oox::xls {
43 
44 using namespace ::com::sun::star::sheet;
45 using namespace ::com::sun::star::uno;
46 
47 using ::oox::core::Relation;
48 using ::oox::core::Relations;
49 
50 namespace {
51 
52 const sal_uInt16 BIFF12_EXTERNALBOOK_BOOK = 0;
53 const sal_uInt16 BIFF12_EXTERNALBOOK_DDE = 1;
54 const sal_uInt16 BIFF12_EXTERNALBOOK_OLE = 2;
55 
56 const sal_uInt16 BIFF12_EXTNAME_AUTOMATIC = 0x0002;
57 const sal_uInt16 BIFF12_EXTNAME_PREFERPIC = 0x0004;
58 const sal_uInt16 BIFF12_EXTNAME_STDDOCNAME = 0x0008;
59 const sal_uInt16 BIFF12_EXTNAME_OLEOBJECT = 0x0010;
60 const sal_uInt16 BIFF12_EXTNAME_ICONIFIED = 0x0020;
61 
62 } // namespace
63 
65  mbNotify( false ),
66  mbPreferPic( false ),
67  mbStdDocName( false ),
68  mbOleObj( false ),
69  mbIconified( false )
70 {
71 }
72 
74  DefinedNameBase( rParentLink ),
75  mrParentLink( rParentLink ),
76  mbDdeLinkCreated( false )
77 {
78 }
79 
81 {
82  maModel.maName = rAttribs.getXString( XML_name, OUString() );
83  OSL_ENSURE( !maModel.maName.isEmpty(), "ExternalName::importDefinedName - empty name" );
84  // zero-based index into sheet list of externalBook
85  maModel.mnSheet = rAttribs.getInteger( XML_sheetId, -1 );
86 }
87 
89 {
90  maModel.maName = rAttribs.getXString( XML_name, OUString() );
91  OSL_ENSURE( !maModel.maName.isEmpty(), "ExternalName::importDdeItem - empty name" );
92  maExtNameModel.mbOleObj = false;
93  maExtNameModel.mbStdDocName = rAttribs.getBool( XML_ole, false );
94  maExtNameModel.mbNotify = rAttribs.getBool( XML_advise, false );
95  maExtNameModel.mbPreferPic = rAttribs.getBool( XML_preferPic, false );
96 }
97 
99 {
100  setResultSize( rAttribs.getInteger( XML_cols, 1 ), rAttribs.getInteger( XML_rows, 1 ) );
101 }
102 
104 {
105  maModel.maName = rAttribs.getXString( XML_name, OUString() );
106  OSL_ENSURE( !maModel.maName.isEmpty(), "ExternalName::importOleItem - empty name" );
107  maExtNameModel.mbOleObj = true;
108  maExtNameModel.mbNotify = rAttribs.getBool( XML_advise, false );
109  maExtNameModel.mbPreferPic = rAttribs.getBool( XML_preferPic, false );
110  maExtNameModel.mbIconified = rAttribs.getBool( XML_icon, false );
111 }
112 
114 {
115  rStrm >> maModel.maName;
116  OSL_ENSURE( !maModel.maName.isEmpty(), "ExternalName::importExternalName - empty name" );
117 }
118 
120 {
121  sal_uInt16 nFlags;
122  sal_Int32 nSheetId;
123  nFlags = rStrm.readuInt16();
124  nSheetId = rStrm.readInt32();
125  // index into sheet list of EXTSHEETNAMES (one-based in BIFF12)
126  maModel.mnSheet = nSheetId - 1;
127  // no flag for built-in names, as in OOXML...
128  maExtNameModel.mbNotify = getFlag( nFlags, BIFF12_EXTNAME_AUTOMATIC );
129  maExtNameModel.mbPreferPic = getFlag( nFlags, BIFF12_EXTNAME_PREFERPIC );
130  maExtNameModel.mbStdDocName = getFlag( nFlags, BIFF12_EXTNAME_STDDOCNAME );
131  maExtNameModel.mbOleObj = getFlag( nFlags, BIFF12_EXTNAME_OLEOBJECT );
132  maExtNameModel.mbIconified = getFlag( nFlags, BIFF12_EXTNAME_ICONIFIED );
134  "ExternalName::importExternalNameFlags - wrong OLE flag in external name" );
135 }
136 
138 {
139  sal_Int32 nRows, nCols;
140  nRows = rStrm.readInt32();
141  nCols = rStrm.readInt32();
142  setResultSize( nCols, nRows );
143 }
144 
146 {
147  appendResultValue< double >( (rStrm.readuInt8() == 0) ? 0.0 : 1.0 );
148 }
149 
151 {
152  appendResultValue( rStrm.readDouble() );
153 }
154 
156 {
158 }
159 
161 {
163 }
164 
165 bool ExternalName::getDdeItemInfo( DDEItemInfo& orItemInfo ) const
166 {
167  if( (mrParentLink.getLinkType() == ExternalLinkType::DDE) && !maModel.maName.isEmpty() )
168  {
169  orItemInfo.Item = maModel.maName;
171  return true;
172  }
173  return false;
174 }
175 
176 bool ExternalName::getDdeLinkData( OUString& orDdeServer, OUString& orDdeTopic, OUString& orDdeItem )
177 {
178  if( (mrParentLink.getLinkType() == ExternalLinkType::DDE) && !maModel.maName.isEmpty() )
179  {
180  // try to create a DDE link and to set the imported link results
181  if( !mbDdeLinkCreated ) try
182  {
183  PropertySet aDocProps( getDocument() );
184  Reference< XDDELinks > xDdeLinks( aDocProps.getAnyProperty( PROP_DDELinks ), UNO_QUERY_THROW );
185  mxDdeLink = xDdeLinks->addDDELink( mrParentLink.getClassName(), mrParentLink.getTargetUrl(), maModel.maName, css::sheet::DDELinkMode_DEFAULT );
186  mbDdeLinkCreated = true; // ignore if setting results fails
187  if( !maResults.empty() )
188  {
189  Reference< XDDELinkResults > xResults( mxDdeLink, UNO_QUERY_THROW );
190  xResults->setResults( ContainerHelper::matrixToSequenceSequence( maResults ) );
191  }
192  }
193  catch( Exception& )
194  {
195  OSL_FAIL( "ExternalName::getDdeLinkData - cannot create DDE link" );
196  }
197  // get link data from created DDE link
198  if( mxDdeLink.is() )
199  {
200  orDdeServer = mxDdeLink->getApplication();
201  orDdeTopic = mxDdeLink->getTopic();
202  orDdeItem = mxDdeLink->getItem();
203  return true;
204  }
205  }
206  return false;
207 }
208 
209 // private --------------------------------------------------------------------
210 
211 void ExternalName::setResultSize( sal_Int32 nColumns, sal_Int32 nRows )
212 {
214  "ExternalName::setResultSize - wrong link type" );
215  OSL_ENSURE( (nRows > 0) && (nColumns > 0), "ExternalName::setResultSize - invalid matrix size" );
216  const ScAddress& rMaxPos = getAddressConverter().getMaxApiAddress();
217  if( (0 < nRows) && (nRows <= rMaxPos.Row() + 1) && (0 < nColumns) && (nColumns <= rMaxPos.Col() + 1) )
218  maResults.resize( static_cast< size_t >( nColumns ), static_cast< size_t >( nRows ), Any( BiffHelper::calcDoubleFromError( BIFF_ERR_NA ) ) );
219  else
220  maResults.clear();
222 }
223 
225 {
227  mnDocLink = mnFirst = mnLast = -1;
228 }
229 
231 {
233  mnDocLink = -1;
234  mnFirst = mnLast = 0;
235 }
236 
237 void LinkSheetRange::setRange( sal_Int32 nFirst, sal_Int32 nLast )
238 {
240  mnDocLink = -1;
241  mnFirst = ::std::min( nFirst, nLast );
242  mnLast = ::std::max( nFirst, nLast );
243 }
244 
245 void LinkSheetRange::setExternalRange( sal_Int32 nDocLink, sal_Int32 nFirst, sal_Int32 nLast )
246 {
247  if( nDocLink < 0 )
248  {
249  setDeleted();
250  }
251  else
252  {
254  mnDocLink = nDocLink;
255  mnFirst = ::std::min( nFirst, nLast );
256  mnLast = ::std::max( nFirst, nLast );
257  }
258 }
259 
261  WorkbookHelper( rHelper ),
262  meLinkType( ExternalLinkType::Unknown ),
263  meFuncLibType( FUNCLIB_UNKNOWN )
264 {
265 }
266 
268 {
269  maRelId = rAttribs.getString( R_TOKEN( id ), OUString() );
270 }
271 
272 void ExternalLink::importExternalBook( const Relations& rRelations, const AttributeList& rAttribs )
273 {
274  parseExternalReference( rRelations, rAttribs.getString( R_TOKEN( id ), OUString() ) );
275 }
276 
278 {
279  insertExternalSheet( rAttribs.getXString( XML_val, OUString() ) );
280 }
281 
283 {
284  createExternalName()->importDefinedName( rAttribs );
285 }
286 
288 {
289  OUString aDdeService = rAttribs.getXString( XML_ddeService, OUString() );
290  OUString aDdeTopic = rAttribs.getXString( XML_ddeTopic, OUString() );
291  setDdeOleTargetUrl( aDdeService, aDdeTopic, ExternalLinkType::DDE );
292 }
293 
295 {
296  ExternalNameRef xExtName = createExternalName();
297  xExtName->importDdeItem( rAttribs );
298  return xExtName;
299 }
300 
301 void ExternalLink::importOleLink( const Relations& rRelations, const AttributeList& rAttribs )
302 {
303  OUString aProgId = rAttribs.getXString( XML_progId, OUString() );
304  OUString aTargetUrl = rRelations.getExternalTargetFromRelId( rAttribs.getString( R_TOKEN( id ), OUString() ) );
305  setDdeOleTargetUrl( aProgId, aTargetUrl, ExternalLinkType::OLE );
306 }
307 
309 {
310  ExternalNameRef xExtName = createExternalName();
311  xExtName->importOleItem( rAttribs );
312  return xExtName;
313 }
314 
316 {
317  rStrm >> maRelId;
318 }
319 
321 {
323 }
324 
326 {
328 }
329 
331 {
333 }
334 
335 void ExternalLink::importExternalBook( const Relations& rRelations, SequenceInputStream& rStrm )
336 {
337  switch( rStrm.readuInt16() )
338  {
339  case BIFF12_EXTERNALBOOK_BOOK:
340  parseExternalReference( rRelations, BiffHelper::readString( rStrm ) );
341  break;
342  case BIFF12_EXTERNALBOOK_DDE:
343  {
344  OUString aDdeService, aDdeTopic;
345  rStrm >> aDdeService >> aDdeTopic;
346  setDdeOleTargetUrl( aDdeService, aDdeTopic, ExternalLinkType::DDE );
347  }
348  break;
349  case BIFF12_EXTERNALBOOK_OLE:
350  {
351  OUString aTargetUrl = rRelations.getExternalTargetFromRelId( BiffHelper::readString( rStrm ) );
352  OUString aProgId = BiffHelper::readString( rStrm );
353  setDdeOleTargetUrl( aProgId, aTargetUrl, ExternalLinkType::OLE );
354  }
355  break;
356  default:
357  OSL_FAIL( "ExternalLink::importExternalBook - unknown link type" );
358  }
359 }
360 
362 {
363  // load external sheet names and create the sheet caches in the Calc document
365  "sc.filter",
366  "Invalid link type: " << meLinkType );
367  if( meLinkType == ExternalLinkType::External ) // ignore sheets of external libraries
368  for( sal_Int32 nSheet = 0, nCount = rStrm.readInt32(); !rStrm.isEof() && (nSheet < nCount); ++nSheet )
370 }
371 
373 {
374  ExternalNameRef xExtName = createExternalName();
375  xExtName->importExternalName( rStrm );
376  return xExtName;
377 }
378 
379 ExternalLinkInfo ExternalLink::getLinkInfo() const
380 {
381  ExternalLinkInfo aLinkInfo;
382  switch( meLinkType )
383  {
386  aLinkInfo.Type = css::sheet::ExternalLinkType::SELF;
387  break;
389  aLinkInfo.Type = css::sheet::ExternalLinkType::DOCUMENT;
390  aLinkInfo.Data <<= maTargetUrl;
391  break;
393  // parser will return library function names in OPCODE_BAD string tokens
394  aLinkInfo.Type = css::sheet::ExternalLinkType::SPECIAL;
395  break;
397  {
398  aLinkInfo.Type = css::sheet::ExternalLinkType::DDE;
399  DDELinkInfo aDdeLinkInfo;
400  aDdeLinkInfo.Service = maClassName;
401  aDdeLinkInfo.Topic = maTargetUrl;
402  ::std::vector< DDEItemInfo > aItemInfos;
403  DDEItemInfo aItemInfo;
404  for( const auto& rxExtName : maExtNames )
405  if( rxExtName->getDdeItemInfo( aItemInfo ) )
406  aItemInfos.push_back( aItemInfo );
407  aDdeLinkInfo.Items = ContainerHelper::vectorToSequence( aItemInfos );
408  aLinkInfo.Data <<= aDdeLinkInfo;
409  }
410  break;
411  default:
412  aLinkInfo.Type = css::sheet::ExternalLinkType::UNKNOWN;
413  }
414  return aLinkInfo;
415 }
416 
418 {
420 }
421 
423 {
424  OSL_ENSURE( meLinkType == ExternalLinkType::External, "ExternalLink::getDocumentLinkIndex - invalid link type" );
425  return mxDocLink.is() ? mxDocLink->getTokenIndex() : -1;
426 }
427 
428 sal_Int32 ExternalLink::getSheetCacheIndex( sal_Int32 nTabId ) const
429 {
430  OSL_ENSURE( meLinkType == ExternalLinkType::External, "ExternalLink::getSheetCacheIndex - invalid link type" );
431  return ContainerHelper::getVectorElement( maSheetCaches, nTabId, -1 );
432 }
433 
434 Reference< XExternalSheetCache > ExternalLink::getSheetCache( sal_Int32 nTabId ) const
435 {
436  sal_Int32 nCacheIdx = getSheetCacheIndex( nTabId );
437  if( mxDocLink.is() && (nCacheIdx >= 0) ) try
438  {
439  // existing mxDocLink implies that this is an external link
440  Reference< XExternalSheetCache > xSheetCache( mxDocLink->getByIndex( nCacheIdx ), UNO_QUERY_THROW );
441  return xSheetCache;
442  }
443  catch( Exception& )
444  {
445  }
446  return nullptr;
447 }
448 
449 void ExternalLink::getSheetRange( LinkSheetRange& orSheetRange, sal_Int32 nTabId1, sal_Int32 nTabId2 ) const
450 {
451  switch( meLinkType )
452  {
454  orSheetRange.setSameSheet();
455  break;
456 
458  orSheetRange.setRange( nTabId1, nTabId2 );
459  break;
460 
462  {
463  sal_Int32 nDocLinkIdx = getDocumentLinkIndex();
464  // BIFF12: passed indexes point into sheet list of EXTSHEETLIST
465  orSheetRange.setExternalRange( nDocLinkIdx, getSheetCacheIndex( nTabId1 ), getSheetCacheIndex( nTabId2 ) );
466  }
467  break;
468 
469  default:
470  // unsupported/unexpected link type: #REF! error
471  orSheetRange.setDeleted();
472  }
473 }
474 
476 {
477  return maExtNames.get( nIndex );
478 }
479 
480 // private --------------------------------------------------------------------
481 
482 void ExternalLink::setExternalTargetUrl( const OUString& rTargetUrl, const OUString& rTargetType )
483 {
485  if( rTargetType == CREATE_OFFICEDOC_RELATION_TYPE( "externalLinkPath" ) ||
486  rTargetType == CREATE_OFFICEDOC_RELATION_TYPE_STRICT( "externalLinkPath" ) )
487  {
488  maTargetUrl = getBaseFilter().getAbsoluteUrl( rTargetUrl );
489  if( !maTargetUrl.isEmpty() )
491  }
492  else if( rTargetType == CREATE_MSOFFICE_RELATION_TYPE( "xlExternalLinkPath/xlPathMissing" ) )
493  {
495  }
496  else if( rTargetType == CREATE_MSOFFICE_RELATION_TYPE( "xlExternalLinkPath/xlLibrary" ) )
497  {
500  }
501  SAL_WARN_IF( meLinkType == ExternalLinkType::Unknown, "sc.filter", "Empty target URL or unknown target type, URL='" << rTargetUrl << "', type='" << rTargetType << "'" );
502 
503  // create the external document link API object that will contain the sheet caches
505  {
506  PropertySet aDocProps( getDocument() );
507  Reference< XExternalDocLinks > xDocLinks( aDocProps.getAnyProperty( PROP_ExternalDocLinks ), UNO_QUERY_THROW );
508  mxDocLink = xDocLinks->addDocLink( maTargetUrl );
509  }
510  catch( Exception& )
511  {
512  }
513 }
514 
515 void ExternalLink::setDdeOleTargetUrl( const OUString& rClassName, const OUString& rTargetUrl, ExternalLinkType eLinkType )
516 {
517  maClassName = rClassName;
518  maTargetUrl = rTargetUrl;
519  meLinkType = (maClassName.isEmpty() || maTargetUrl.isEmpty()) ? ExternalLinkType::Unknown : eLinkType;
520  OSL_ENSURE( meLinkType == eLinkType, "ExternalLink::setDdeOleTargetUrl - missing classname or target" );
521 }
522 
523 void ExternalLink::parseExternalReference( const Relations& rRelations, const OUString& rRelId )
524 {
525  if( const Relation* pRelation = rRelations.getRelationFromRelId( rRelId ) )
526  setExternalTargetUrl( pRelation->maTarget, pRelation->maType );
527 }
528 
529 void ExternalLink::insertExternalSheet( const OUString& rSheetName )
530 {
531  OSL_ENSURE( !rSheetName.isEmpty(), "ExternalLink::insertExternalSheet - empty sheet name" );
532  if( mxDocLink.is() )
533  {
534  Reference< XExternalSheetCache > xSheetCache = mxDocLink->addSheetCache( rSheetName, false );
535  sal_Int32 nCacheIdx = xSheetCache.is() ? xSheetCache->getTokenIndex() : -1;
536  maSheetCaches.push_back( nCacheIdx );
537  }
538 }
539 
541 {
542  ExternalNameRef xExtName = std::make_shared<ExternalName>( *this );
543  maExtNames.push_back( xExtName );
544  return xExtName;
545 }
546 
548  mnExtRefId( -1 ),
549  mnTabId1( -1 ),
550  mnTabId2( -1 )
551 {
552 }
553 
555 {
556  mnExtRefId = rStrm.readInt32();
557  mnTabId1 = rStrm.readInt32();
558  mnTabId2 = rStrm.readInt32();
559 }
560 
562  WorkbookHelper( rHelper ),
563  mxSelfRef( std::make_shared<ExternalLink>( rHelper ) ),
564  mbUseRefSheets( false )
565 {
566  mxSelfRef->setSelfLinkType();
567 }
568 
570 {
571  ExternalLinkRef xExtLink = createExternalLink();
572  xExtLink->importExternalReference( rAttribs );
573  maExtLinks.push_back( xExtLink );
574  return xExtLink;
575 }
576 
578 {
579  mbUseRefSheets = true;
580  ExternalLinkRef xExtLink = createExternalLink();
581  xExtLink->importExternalRef( rStrm );
582  maExtLinks.push_back( xExtLink );
583  return xExtLink;
584 }
585 
587 {
588  mbUseRefSheets = true;
589  createExternalLink()->importExternalSelf( rStrm );
590 }
591 
593 {
594  mbUseRefSheets = true;
595  createExternalLink()->importExternalSame( rStrm );
596 }
597 
599 {
600  mbUseRefSheets = true;
601  createExternalLink()->importExternalAddin( rStrm );
602 }
603 
605 {
606  OSL_ENSURE( mbUseRefSheets, "ExternalLinkBuffer::importExternalSheets - missing EXTERNALREFS records" );
607  mbUseRefSheets = true;
608  OSL_ENSURE( maRefSheets.empty(), "ExternalLinkBuffer::importExternalSheets - multiple EXTERNALSHEETS records" );
609  maRefSheets.clear();
610  sal_Int32 nRefCount;
611  nRefCount = rStrm.readInt32();
612  size_t nMaxCount = getLimitedValue< size_t, sal_Int64 >( nRefCount, 0, rStrm.getRemaining() / 12 );
613  maRefSheets.reserve( nMaxCount );
614  for( size_t nRefId = 0; !rStrm.isEof() && (nRefId < nMaxCount); ++nRefId )
615  {
616  RefSheetsModel aRefSheets;
617  aRefSheets.readBiff12Data( rStrm );
618  maRefSheets.push_back( aRefSheets );
619  }
620 }
621 
622 Sequence< ExternalLinkInfo > ExternalLinkBuffer::getLinkInfos() const
623 {
624  ::std::vector< ExternalLinkInfo > aLinkInfos;
625  // add entry for implicit index 0 (self reference to this document)
626  aLinkInfos.push_back( mxSelfRef->getLinkInfo() );
627  for( const auto& rxExtLink : maExtLinks )
628  aLinkInfos.push_back( rxExtLink->getLinkInfo() );
629  return ContainerHelper::vectorToSequence( aLinkInfos );
630 }
631 
632 ExternalLinkRef ExternalLinkBuffer::getExternalLink( sal_Int32 nRefId, bool bUseRefSheets ) const
633 {
634  ExternalLinkRef xExtLink;
635  // OOXML: 0 = this document, otherwise one-based index into link list
636  if( !bUseRefSheets || !mbUseRefSheets )
637  xExtLink = (nRefId == 0) ? mxSelfRef : maLinks.get( nRefId - 1 );
638  // BIFF12: zero-based index into ref-sheets list
639  else if( const RefSheetsModel* pRefSheets = getRefSheets( nRefId ) )
640  xExtLink = maLinks.get( pRefSheets->mnExtRefId );
641  return xExtLink;
642 }
643 
645 {
646  OSL_ENSURE( mbUseRefSheets, "ExternalLinkBuffer::getSheetRange - wrong BIFF version" );
647  LinkSheetRange aSheetRange;
648  if( const ExternalLink* pExtLink = getExternalLink( nRefId ).get() )
649  if( const RefSheetsModel* pRefSheets = getRefSheets( nRefId ) )
650  pExtLink->getSheetRange( aSheetRange, pRefSheets->mnTabId1, pRefSheets->mnTabId2 );
651  return aSheetRange;
652 }
653 
654 // private --------------------------------------------------------------------
655 
657 {
658  ExternalLinkRef xExtLink = std::make_shared<ExternalLink>( *this );
659  maLinks.push_back( xExtLink );
660  return xExtLink;
661 }
662 
663 const RefSheetsModel* ExternalLinkBuffer::getRefSheets( sal_Int32 nRefId ) const
664 {
665  return ((0 <= nRefId) && (o3tl::make_unsigned( nRefId ) < maRefSheets.size())) ?
666  &maRefSheets[ static_cast< size_t >( nRefId ) ] : nullptr;
667 }
668 
669 } // namespace oox
670 
671 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Helper class to provide access to global workbook data.
void importDdeItem(const AttributeList &rAttribs)
Imports the ddeItem element describing an item of a DDE link.
css::uno::Reference< css::sheet::XDDELink > mxDdeLink
Current position in result matrix.
void importExternalSelf(SequenceInputStream &rStrm)
Imports the EXTERNALSELF record from the passed stream.
bool getDdeLinkData(OUString &orDdeServer, OUString &orDdeTopic, OUString &orDdeItem)
Returns the complete DDE link data of this DDE item.
ExternalLinkRef getExternalLink(sal_Int32 nRefId, bool bUseRefSheets=true) const
Returns the external link for the passed reference identifier.
OptValue< bool > getBool(sal_Int32 nAttrToken) const
sal_Int32 nRefCount
ExternalLinkVec maLinks
Implicit self reference at index 0.
SCROW Row() const
Definition: address.hxx:262
const sal_uInt8 BIFF_ERR_NA
Definition: biffhelper.hxx:567
static const VectorType::value_type * getVectorElement(const VectorType &rVector, sal_Int32 nIndex)
OptValue< OUString > getXString(sal_Int32 nAttrToken) const
std::shared_ptr< ExternalLink > ExternalLinkRef
OptValue< sal_Int32 > getInteger(sal_Int32 nAttrToken) const
Link refers to the current sheet.
static double calcDoubleFromError(sal_uInt8 nErrorCode)
Converts the passed BIFF error to a double containing the respective Calc error code.
Definition: biffhelper.cxx:56
sal_Int32 mnSheet
The formula string.
void appendResultValue(const Type &rValue)
Appends the passed value to the result set.
ResultMatrix maResults
Additional name data.
#define CREATE_OFFICEDOC_RELATION_TYPE(ascii)
Link refers to the current workbook.
css::uno::Any getAnyProperty(sal_Int32 nPropId) const
const ScAddress & getMaxApiAddress() const
Returns the biggest valid cell address in the own Calc document.
void importExternalNameFlags(SequenceInputStream &rStrm)
Imports the EXTERNALNAMEFLAGS record containing the settings of an external name. ...
value_type get(sal_Int32 nIndex) const
Link refers to an external add-in.
Link refers to an external spreadsheet document.
OptValue< OUString > getString(sal_Int32 nAttrToken) const
ExternalLinkVec maExtLinks
List of link structures for all kinds of links.
std::shared_ptr< T > make_shared(Args &&...args)
void importExternalName(SequenceInputStream &rStrm)
Imports the EXTERNALNAME record containing the name (only).
const ExternalLink & mrParentLink
bool mbOleObj
Name is the StdDocumentName for DDE.
bool mbIconified
Name is an OLE object.
Unknown
sal_Int32 mnTabId1
Zero-based index into list of external documents.
Base class for defined names and external names.
sal_uInt16 readuInt16()
sal_Int32 mnTabId2
Zero-based index to first sheet in external document.
int nCount
sal_Int32 mnDocLink
Link sheet range type.
::oox::core::FilterBase & getBaseFilter() const
Returns the base filter object (base class of all filters).
RefSheetsModel()
Zero-based index to last sheet in external document.
const RefSheetsModel * getRefSheets(sal_Int32 nRefId) const
Returns the specified sheet indexes for a reference identifier.
Just for round-tripping (FIXME: Functionality not actually implemented after all.) ...
bool getFlag(Type nBitField, Type nMask)
ExternalName(const ExternalLink &rParentLink)
void importOleItem(const AttributeList &rAttribs)
Imports the oleItem element describing an object of an OLE link.
#define CREATE_OFFICEDOC_RELATION_TYPE_STRICT(ascii)
void setSameSheet()
Sets this struct to "use current sheet" state.
void importExternalAddin(SequenceInputStream &rStrm)
Imports the EXTERNALADDIN record from the passed stream.
void resize(size_type nWidth, size_type nHeight)
const css::uno::Reference< css::sheet::XSpreadsheetDocument > & getDocument() const
Returns a reference to the source/target spreadsheet document model.
static OUString readString(SequenceInputStream &rStrm, bool b32BitLen=true)
Reads a BIFF12 string with leading 16-bit or 32-bit length field.
Definition: biffhelper.cxx:78
#define CREATE_MSOFFICE_RELATION_TYPE(ascii)
bool mbUseRefSheets
Sheet indexes for reference ids.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
sal_Int32 mnLast
Index of the first sheet or index of first external sheet cache.
static FunctionLibraryType getFuncLibTypeFromLibraryName(const OUString &rLibraryName)
Returns the library type associated with the passed URL of a function library (function add-in)...
ExternalLinkBuffer(const WorkbookHelper &rHelper)
void readBiff12Data(SequenceInputStream &rStrm)
sal_Int32 mnFirst
Document link token index for external links.
SCCOL Col() const
Definition: address.hxx:267
void setResultSize(sal_Int32 nColumns, sal_Int32 nRows)
Sets the size of the result matrix.
RefSheetsModelVec maRefSheets
Real external links needed for formula parser.
FunctionLibraryType
This enumeration contains constants for all known external libraries containing supported sheet funct...
void importValues(const AttributeList &rAttribs)
Imports the values element containing the size of the DDE result matrix.
ExternalLinkRef importExternalReference(const AttributeList &rAttribs)
Imports the externalReference element containing .
bool mbPreferPic
Notify application on data change.
css::uno::Sequence< css::sheet::ExternalLinkInfo > getLinkInfos() const
Returns the sequence of link infos needed by the XML formula parser.
sal_Int64 getRemaining() const
void setExternalRange(sal_Int32 nDocLink, sal_Int32 nFirst, sal_Int32 nLast)
Sets the passed external sheet cache range to the members of this struct.
void clear()
void setDeleted()
Sets this struct to deleted state.
#define SAL_WARN_IF(condition, area, stream)
ExternalNameModel maExtNameModel
External link this name belongs to.
Represents a REF entry in the BIFF12 EXTERNALSHEETS or in the BIFF8 EXTERNSHEET record.
void importDdeItemValues(SequenceInputStream &rStrm)
Imports the DDEITEMVALUES record containing the size of the DDE result matrix.
void importExternalSame(SequenceInputStream &rStrm)
Imports the EXTERNALSAME record from the passed stream.
static css::uno::Sequence< css::uno::Sequence< typename MatrixType::value_type > > matrixToSequenceSequence(const MatrixType &rMatrix)
LinkSheetRange getSheetRange(sal_Int32 nRefId) const
Returns the sheet range for the specified reference (BIFF8 only).
void importDdeItemError(SequenceInputStream &rStrm)
Imports the DDEITEM_ERROR record containing an error code in a link result.
SfxItemInfo const aItemInfos[]
Definition: docpool.cxx:92
bool empty() const
iterator begin()
void importExternalSheets(SequenceInputStream &rStrm)
Imports the EXTERNALSHEETS record from the passed stream.
static css::uno::Sequence< typename VectorType::value_type > vectorToSequence(const VectorType &rVector)
Contains indexes for a range of sheets in the spreadsheet document.
ExternalLinkRef importExternalRef(SequenceInputStream &rStrm)
Imports the EXTERNALREF record from the passed stream.
void importDdeItemString(SequenceInputStream &rStrm)
Imports the DDEITEM_STRING record containing a string in a link result.
OUString getAbsoluteUrl(const OUString &rUrl) const
bool mbDdeLinkCreated
Interface of a DDE link.
bool isEof() const
ExternalLinkRef createExternalLink()
Creates a new external link and inserts it into the list of links.
void importDdeItemBool(SequenceInputStream &rStrm)
Imports the DDEITEM_BOOL record containing a boolean value in a link result.
bool getDdeItemInfo(css::sheet::DDEItemInfo &orItemInfo) const
Returns the DDE item info needed by the XML formula parser.
void setRange(sal_Int32 nFirst, sal_Int32 nLast)
Sets the passed absolute sheet range to the members of this struct.
void importDefinedName(const AttributeList &rAttribs)
Imports the definedName element.
std::shared_ptr< ExternalName > ExternalNameRef
ResultMatrix::iterator maCurrIt
DDE/OLE link results.
void importDdeItemDouble(SequenceInputStream &rStrm)
Imports the DDEITEM_DOUBLE record containing a double value in a link result.
AddressConverter & getAddressConverter() const
Returns the converter for string to cell address/range conversion.
ExternalNameModel()
Iconified object link.