LibreOffice Module sc (master) 1
excimp8.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 <config_features.h>
21
22#include <excimp8.hxx>
23
24#include <scitems.hxx>
27#include <unotools/fltrcfg.hxx>
28
29#include <sfx2/docfile.hxx>
30#include <sfx2/objsh.hxx>
31#include <sfx2/docinf.hxx>
32#include <sot/storage.hxx>
34
35#include <rtl/math.hxx>
36#include <rtl/ustring.hxx>
38
39#include <document.hxx>
40#include <attrib.hxx>
41#include <dbdata.hxx>
42#include <globalnames.hxx>
43#include <docoptio.hxx>
44#include <xihelper.hxx>
45#include <xicontent.hxx>
46#include <xilink.hxx>
47#include <xiescher.hxx>
48#include <xistyle.hxx>
49#include <excdefs.hxx>
50
51#include <excform.hxx>
52#include <queryentry.hxx>
53
54#include <com/sun/star/document/XDocumentProperties.hpp>
55#include <com/sun/star/document/XDocumentPropertiesSupplier.hpp>
56#include <com/sun/star/container/XIndexContainer.hpp>
57#include <com/sun/star/container/XNameContainer.hpp>
58#include <com/sun/star/frame/XModel.hpp>
60#include "xltoolbar.hxx"
63
64using namespace com::sun::star;
65using namespace ::comphelper;
66
67//OleNameOverrideContainer
68
69namespace {
70
71class OleNameOverrideContainer : public ::cppu::WeakImplHelper< container::XNameContainer >
72{
73private:
74 typedef std::unordered_map< OUString, uno::Reference< container::XIndexContainer > > NamedIndexToOleName;
75 NamedIndexToOleName IdToOleNameHash;
76 std::mutex m_aMutex;
77public:
78 // XElementAccess
79 virtual uno::Type SAL_CALL getElementType( ) override { return cppu::UnoType<container::XIndexContainer>::get(); }
80 virtual sal_Bool SAL_CALL hasElements( ) override
81 {
82 std::unique_lock aGuard( m_aMutex );
83 return ( !IdToOleNameHash.empty() );
84 }
85 // XNameAccess
86 virtual uno::Any SAL_CALL getByName( const OUString& aName ) override
87 {
88 std::unique_lock aGuard( m_aMutex );
89 auto it = IdToOleNameHash.find( aName );
90 if ( it == IdToOleNameHash.end() )
91 throw container::NoSuchElementException();
92 return uno::Any( it->second );
93 }
94 virtual uno::Sequence< OUString > SAL_CALL getElementNames( ) override
95 {
96 std::unique_lock aGuard( m_aMutex );
97 return comphelper::mapKeysToSequence( IdToOleNameHash);
98 }
99 virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override
100 {
101 std::unique_lock aGuard( m_aMutex );
102 return ( IdToOleNameHash.find( aName ) != IdToOleNameHash.end() );
103 }
104
105 // XNameContainer
106 virtual void SAL_CALL insertByName( const OUString& aName, const uno::Any& aElement ) override
107 {
108 std::unique_lock aGuard( m_aMutex );
109 auto it = IdToOleNameHash.find( aName );
110 if ( it != IdToOleNameHash.end() )
111 throw container::ElementExistException();
112 uno::Reference< container::XIndexContainer > xElement;
113 if ( ! ( aElement >>= xElement ) )
114 throw lang::IllegalArgumentException();
115 IdToOleNameHash[ aName ] = xElement;
116 }
117 virtual void SAL_CALL removeByName( const OUString& aName ) override
118 {
119 std::unique_lock aGuard( m_aMutex );
120 if ( IdToOleNameHash.erase( aName ) == 0 )
121 throw container::NoSuchElementException();
122 }
123 virtual void SAL_CALL replaceByName( const OUString& aName, const uno::Any& aElement ) override
124 {
125 std::unique_lock aGuard( m_aMutex );
126 auto it = IdToOleNameHash.find( aName );
127 if ( it == IdToOleNameHash.end() )
128 throw container::NoSuchElementException();
129 uno::Reference< container::XIndexContainer > xElement;
130 if ( ! ( aElement >>= xElement ) )
131 throw lang::IllegalArgumentException();
132 it->second = xElement;
133 }
134};
135
139bool readFrtHeader( XclImpStream& rStrm, sal_uInt16 nRecordID )
140{
141 sal_uInt16 nRt = rStrm.ReaduInt16();
142 rStrm.Ignore(10); // grbitFrt (2 bytes) and reserved (8 bytes)
143 return nRt == nRecordID;
144}
145
146}
147
149 ImportExcel( rImpData, rStrm )
150{
151 // replace BIFF2-BIFF5 formula importer with BIFF8 formula importer
152 pFormConv.reset(new ExcelToSc8( GetRoot() ));
154}
155
157{
158}
159
161{
163 aOpt.SetIterCount( aIn.ReaduInt16() );
164 rD.SetDocOptions( aOpt );
165}
166
168{
170 aOpt.SetCalcAsShown( aIn.ReaduInt16() == 0 );
171 rD.SetDocOptions( aOpt );
172}
173
175{
177 aOpt.SetIterEps( aIn.ReadDouble() );
178 rD.SetDocOptions( aOpt );
179}
180
182{
184 aOpt.SetIter( aIn.ReaduInt16() == 1 );
185 rD.SetDocOptions( aOpt );
186}
187
189{
190 sal_uInt8 nLen;
191 sal_uInt16 nGrbit;
192
194 maSheetOffsets.push_back( aIn.ReaduInt32() );
196 nGrbit = aIn.ReaduInt16();
197 nLen = aIn.ReaduInt8();
198
199 OUString aName( aIn.ReadUniString( nLen ) );
201
202 SCTAB nScTab = nBdshtTab;
203 if( nScTab > 0 )
204 {
205 OSL_ENSURE( !rD.HasTable( nScTab ), "ImportExcel8::Boundsheet - sheet exists already" );
206 rD.MakeTable( nScTab );
207 }
208
209 if( ( nGrbit & 0x0001 ) || ( nGrbit & 0x0002 ) )
210 rD.SetVisible( nScTab, false );
211
212 if( !rD.RenameTab( nScTab, aName ) )
213 {
215 rD.RenameTab( nScTab, aName );
216 }
217
218 nBdshtTab++;
219}
220
222{
223 sal_uInt16 nLastDispl;
224
225 aIn.Ignore( 4 );
226 nLastDispl = aIn.ReaduInt16();
227
228 maScenList.nLastScenario = nLastDispl;
229}
230
232{
233 maScenList.aEntries.push_back( std::make_unique<ExcScenario>( aIn, *pExcRoot ) );
234}
235
237{
238 XclAddress aXclPos;
239 sal_uInt16 nXF;
240 sal_uInt32 nSst;
241
242 aIn >> aXclPos;
243 nXF = aIn.ReaduInt16();
244 nSst = aIn.ReaduInt32( );
245
247 if( GetAddressConverter().ConvertAddress( aScPos, aXclPos, GetCurrScTab(), true ) )
248 {
249 GetXFRangeBuffer().SetXF( aScPos, nXF );
250 const XclImpString* pXclStr = GetSst().GetString(nSst);
251 if (pXclStr)
252 XclImpStringHelper::SetToDocument(GetDocImport(), aScPos, *this, *pXclStr, nXF);
253 }
254}
255
257{
258 if (!readFrtHeader( aIn, 0x0867))
259 return;
260
261 // Feature type (isf) can be EXC_ISFPROTECTION, EXC_ISFFEC2 or
262 // EXC_ISFFACTOID.
263 sal_uInt16 nFeatureType = aIn.ReaduInt16();
264 if (nFeatureType != EXC_ISFPROTECTION)
265 // We currently only support import of enhanced protection data.
266 return;
267
268 aIn.Ignore(1); // always 1
269
271}
272
274{
275 if (!readFrtHeader( aIn, 0x0868))
276 return;
277
278 // Feature type (isf) can be EXC_ISFPROTECTION, EXC_ISFFEC2 or
279 // EXC_ISFFACTOID.
280 sal_uInt16 nFeatureType = aIn.ReaduInt16();
281 if (nFeatureType != EXC_ISFPROTECTION)
282 // We currently only support import of enhanced protection data.
283 return;
284
285 aIn.Ignore(5); // reserved1 (1 byte) and reserved2 (4 bytes)
286
287 sal_uInt16 nCref = aIn.ReaduInt16(); // number of ref elements
288 aIn.Ignore(4); // size if EXC_ISFFEC2, else 0 and to be ignored
289 aIn.Ignore(2); // reserved3 (2 bytes)
290
292 if (nCref)
293 {
294 XclRangeList aRefs;
295 aRefs.Read( aIn, true, nCref);
296 if (!aRefs.empty())
297 {
298 aProt.maRangeList = new ScRangeList;
300 }
301 }
302
303 // FeatProtection structure follows in record.
304
305 aProt.mnAreserved = aIn.ReaduInt32();
307 aProt.maTitle = aIn.ReadUniString();
308 if ((aProt.mnAreserved & 0x00000001) == 0x00000001)
309 {
310 sal_uInt32 nCbSD = aIn.ReaduInt32();
311 // TODO: could here be some sanity check applied to not allocate 4GB?
312 aProt.maSecurityDescriptor.resize( nCbSD);
313 std::size_t nRead = aIn.Read(aProt.maSecurityDescriptor.data(), nCbSD);
314 if (nRead < nCbSD)
315 aProt.maSecurityDescriptor.resize( nRead);
316 }
317
319}
320
322{
323 SfxObjectShell* pShell = GetDocShell();
325 const SvtFilterOptions& rFilterOpt = SvtFilterOptions::Get();
326 if( !pShell || !xRootStrg.is() )
327 return;
328
329 try
330 {
331 // #FIXME need to get rid of this, we can also do this from within oox
332 // via the "ooo.vba.VBAGlobals" service
333 if( ( rFilterOpt.IsLoadExcelBasicCode() ||
334 rFilterOpt.IsLoadExcelBasicStorage() ) &&
335 rFilterOpt.IsLoadExcelBasicExecutable() )
336 {
337 // see if we have the XCB stream
338 tools::SvRef<SotStorageStream> xXCB = xRootStrg->OpenSotStream( "XCB", StreamMode::STD_READ );
339 if ( xXCB.is()|| ERRCODE_NONE == xXCB->GetError() )
340 {
341 ScCTBWrapper wrapper;
342 if ( wrapper.Read( *xXCB ) )
343 {
344#ifdef DEBUG_SC_EXCEL
345 wrapper.Print( stderr );
346#endif
347 wrapper.ImportCustomToolBar( *pShell );
348 }
349 }
350 }
351 try
352 {
353 uno::Reference< uno::XComponentContext > aCtx( ::comphelper::getProcessComponentContext() );
354 SfxMedium& rMedium = GetMedium();
355 uno::Reference< io::XInputStream > xIn = rMedium.GetInputStream();
356 oox::ole::OleStorage root( aCtx, xIn, false );
357 oox::StorageRef vbaStg = root.openSubStorage( "_VBA_PROJECT_CUR", false );
358 if ( vbaStg )
359 {
360 oox::ole::VbaProject aVbaPrj( aCtx, pShell->GetModel(), u"Calc" );
361 // collect names of embedded form controls, as specified in the VBA project
362 uno::Reference< container::XNameContainer > xOleNameOverrideSink( new OleNameOverrideContainer );
363 aVbaPrj.setOleOverridesSink( xOleNameOverrideSink );
364 aVbaPrj.importVbaProject( *vbaStg );
365 GetObjectManager().SetOleNameOverrideInfo( xOleNameOverrideSink );
366 }
367 }
368 catch( uno::Exception& )
369 {
370 }
371 }
372 catch( uno::Exception& )
373 {
374 }
375}
376
378{
382}
383
385{
386#if HAVE_FEATURE_SCRIPTING
387 // reading basic has been delayed until sheet objects (codenames etc.) are read
388 if( HasBasic() )
389 ReadBasic();
390#endif
391 // #i11776# filtered ranges before outlines and hidden rows
393 pExcRoot->pAutoFilterBuffer->Apply();
394
395 GetWebQueryBuffer().Apply(); //TODO: test if extant
398
400
401 // check scenarios; Attention: This increases the table count of the document!!
402 if( !rD.IsClipboard() && !maScenList.aEntries.empty() )
403 {
404 rD.UpdateChartListenerCollection(); // references in charts must be updated
405
407 }
408
409 // read doc info (no docshell while pasting from clipboard)
410 SfxObjectShell* pShell = GetDocShell();
411 if(!pShell)
412 return;
413
414 // BIFF5+ without storage is possible
416 if( xRootStrg.is() ) try
417 {
418 uno::Reference< document::XDocumentPropertiesSupplier > xDPS( pShell->GetModel(), uno::UNO_QUERY_THROW );
419 uno::Reference< document::XDocumentProperties > xDocProps( xDPS->getDocumentProperties(), uno::UNO_SET_THROW );
420 sfx2::LoadOlePropertySet( xDocProps, xRootStrg.get() );
421 }
422 catch( uno::Exception& )
423 {
424 }
425
426 // #i45843# Pivot tables are now handled outside of PostDocLoad, so they are available
427 // when formula cells are calculated, for the GETPIVOTDATA function.
428}
429
430// autofilter
431
433{
434 // The FilterMode record exists: if either the AutoFilter
435 // record exists or an Advanced Filter is saved and stored
436 // in the sheet. Thus if the FilterMode records only exists
437 // then the latter is true...
438 if( !pExcRoot->pAutoFilterBuffer ) return;
439
441 if( pData )
442 pData->SetAutoOrAdvanced();
443}
444
446{
447 if( !pExcRoot->pAutoFilterBuffer ) return;
448
450 if( pData )
451 {
452 pData->SetAdvancedRange( nullptr );
453 pData->Activate();
454 }
455}
456
458{
459 if( !pExcRoot->pAutoFilterBuffer ) return;
460
462 if( pData )
463 pData->ReadAutoFilter(aIn, GetDoc().GetSharedStringPool());
464}
465
467 ExcRoot( pRoot ),
468 pCurrDBData(nullptr),
469 bActive( false ),
470 bCriteria( false ),
471 bAutoOrAdvanced(false)
472{
473 aParam.nCol1 = rRange.aStart.Col();
474 aParam.nRow1 = rRange.aStart.Row();
475 aParam.nTab = rRange.aStart.Tab();
476 aParam.nCol2 = rRange.aEnd.Col();
477 aParam.nRow2 = rRange.aEnd.Row();
478
479 aParam.bInplace = true;
480
481}
482
483namespace {
484
485OUString CreateFromDouble( double fVal )
486{
487 return rtl::math::doubleToUString(fVal,
488 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
489 ScGlobal::getLocaleData().getNumDecimalSep()[0], true);
490}
491
492}
493
495{
496 ScDocument& rDoc = pExcRoot->pIR->GetDoc();
497 for ( SCCOL nCol = StartCol(); nCol <= EndCol(); nCol++ )
498 {
499 ScMF nFlag = rDoc.GetAttr( nCol, StartRow(), Tab(), ATTR_MERGE_FLAG )->GetValue();
500 rDoc.ApplyAttr( nCol, StartRow(), Tab(), ScMergeFlagAttr( nFlag | ScMF::Auto) );
501 }
502}
503
505{
506 if (!pCurrDBData)
507 return;
508
509 ScRange aAdvRange;
510 bool bHasAdv = pCurrDBData->GetAdvancedQuerySource( aAdvRange );
511 if( bHasAdv )
512 pExcRoot->pIR->GetDoc().CreateQueryParam(aAdvRange, aParam);
513
515 if( bHasAdv )
516 pCurrDBData->SetAdvancedQuerySource( &aAdvRange );
517 else
518 {
519 pCurrDBData->SetAutoFilter( true );
521 }
522}
523
524static void ExcelQueryToOooQuery( OUString& aStr, ScQueryEntry& rEntry )
525{
526 if (rEntry.eOp != SC_EQUAL && rEntry.eOp != SC_NOT_EQUAL)
527 return;
528
529 sal_Int32 nLen = aStr.getLength();
530 sal_Unicode nStart = aStr[0];
531 sal_Unicode nEnd = aStr[ nLen-1 ];
532 if( nLen > 2 && nStart == '*' && nEnd == '*' )
533 {
534 aStr = aStr.copy( 1, nLen-2 );
535 rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_CONTAINS : SC_DOES_NOT_CONTAIN;
536 }
537 else if( nLen > 1 && nStart == '*' && nEnd != '*' )
538 {
539 aStr = aStr.copy( 1 );
540 rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_ENDS_WITH : SC_DOES_NOT_END_WITH;
541 }
542 else if( nLen > 1 && nStart != '*' && nEnd == '*' )
543 {
544 aStr = aStr.copy( 0, nLen-1 );
545 rEntry.eOp = ( rEntry.eOp == SC_EQUAL ) ? SC_BEGINS_WITH : SC_DOES_NOT_BEGIN_WITH;
546 }
547 else if( nLen == 2 && nStart == '*' && nEnd == '*' )
548 {
549 aStr = aStr.copy( 1 );
550 }
551}
552
554 XclImpStream& rStrm, svl::SharedStringPool& rPool )
555{
556 sal_uInt16 nCol, nFlags;
557 nCol = rStrm.ReaduInt16();
558 nFlags = rStrm.ReaduInt16();
559
561 bool bSimple1 = ::get_flag(nFlags, EXC_AFFLAG_SIMPLE1);
562 bool bSimple2 = ::get_flag(nFlags, EXC_AFFLAG_SIMPLE2);
563 bool bTop10 = ::get_flag(nFlags, EXC_AFFLAG_TOP10);
564 bool bTopOfTop10 = ::get_flag(nFlags, EXC_AFFLAG_TOP10TOP);
565 bool bPercent = ::get_flag(nFlags, EXC_AFFLAG_TOP10PERC);
566 sal_uInt16 nCntOfTop10 = nFlags >> 7;
567
568 if( bTop10 )
569 {
570 ScQueryEntry& aEntry = aParam.AppendEntry();
571 ScQueryEntry::Item& rItem = aEntry.GetQueryItem();
572 aEntry.bDoQuery = true;
573 aEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
574 aEntry.eOp = bTopOfTop10 ?
575 (bPercent ? SC_TOPPERC : SC_TOPVAL) : (bPercent ? SC_BOTPERC : SC_BOTVAL);
576 aEntry.eConnect = SC_AND;
577
579 rItem.maString = rPool.intern(OUString::number(nCntOfTop10));
580
581 rStrm.Ignore(20);
582 return;
583 }
584
585 sal_uInt8 nType, nOper, nBoolErr, nVal;
586 sal_Int32 nRK;
587 double fVal;
588
589 sal_uInt8 nStrLen[2] = { 0, 0 };
591
592 for (size_t nE = 0; nE < 2; ++nE)
593 {
594 ScQueryEntry& rEntry = aEntries[nE];
595 ScQueryEntry::Item& rItem = rEntry.GetQueryItem();
596 bool bIgnore = false;
597
598 nType = rStrm.ReaduInt8();
599 nOper = rStrm.ReaduInt8();
600 switch( nOper )
601 {
602 case EXC_AFOPER_LESS:
603 rEntry.eOp = SC_LESS;
604 break;
605 case EXC_AFOPER_EQUAL:
606 rEntry.eOp = SC_EQUAL;
607 break;
609 rEntry.eOp = SC_LESS_EQUAL;
610 break;
612 rEntry.eOp = SC_GREATER;
613 break;
615 rEntry.eOp = SC_NOT_EQUAL;
616 break;
618 rEntry.eOp = SC_GREATER_EQUAL;
619 break;
620 default:
621 rEntry.eOp = SC_EQUAL;
622 }
623
624 switch( nType )
625 {
626 case EXC_AFTYPE_RK:
627 nRK = rStrm.ReadInt32();
628 rStrm.Ignore( 4 );
629 rItem.maString = rPool.intern(
630 CreateFromDouble(XclTools::GetDoubleFromRK(nRK)));
631 break;
633 fVal = rStrm.ReadDouble();
634 rItem.maString = rPool.intern(CreateFromDouble(fVal));
635 break;
637 rStrm.Ignore( 4 );
638 nStrLen[ nE ] = rStrm.ReaduInt8();
639 rStrm.Ignore( 3 );
640 rItem.maString = svl::SharedString();
641 break;
643 nBoolErr = rStrm.ReaduInt8();
644 nVal = rStrm.ReaduInt8();
645 rStrm.Ignore( 6 );
646 rItem.maString = rPool.intern(OUString::number(nVal));
647 bIgnore = (nBoolErr != 0);
648 break;
649 case EXC_AFTYPE_EMPTY:
650 rEntry.SetQueryByEmpty();
651 break;
653 rEntry.SetQueryByNonEmpty();
654 break;
655 default:
656 rStrm.Ignore( 8 );
657 bIgnore = true;
658 }
659
660 if (!bIgnore)
661 {
662 rEntry.bDoQuery = true;
664 rEntry.nField = static_cast<SCCOLROW>(StartCol() + static_cast<SCCOL>(nCol));
665 rEntry.eConnect = nE ? eConn : SC_AND;
666 }
667 }
668
669 if (eConn == SC_AND)
670 {
671 for (size_t nE = 0; nE < 2; ++nE)
672 {
673 if (nStrLen[nE] && aEntries[nE].bDoQuery)
674 {
675 OUString aStr = rStrm.ReadUniString(nStrLen[nE]);
677 aEntries[nE].GetQueryItem().maString = rPool.intern(aStr);
679 }
680 }
681 }
682 else
683 {
684 assert( eConn == SC_OR && "eConn should be SC_AND or SC_OR");
685 // Import only when both conditions are for simple equality, else
686 // import only the 1st condition due to conflict with the ordering of
687 // conditions. #i39464#.
688 //
689 // Example: Let A1 be a condition of column A, and B1 and B2
690 // conditions of column B, connected with OR. Excel performs 'A1 AND
691 // (B1 OR B2)' in this case, but Calc would do '(A1 AND B1) OR B2'
692 // instead.
693
694 if (bSimple1 && bSimple2 && nStrLen[0] && nStrLen[1])
695 {
696 // Two simple OR'ed equal conditions. We can import this correctly.
697 ScQueryEntry& rEntry = aParam.AppendEntry();
698 rEntry.bDoQuery = true;
699 rEntry.eOp = SC_EQUAL;
700 rEntry.eConnect = SC_AND;
702 aItems.reserve(2);
703 ScQueryEntry::Item aItem1, aItem2;
704 aItem1.maString = rPool.intern(rStrm.ReadUniString(nStrLen[0]));
706 aItem2.maString = rPool.intern(rStrm.ReadUniString(nStrLen[1]));
708 aItems.push_back(aItem1);
709 aItems.push_back(aItem2);
710 rEntry.GetQueryItems().swap(aItems);
711 }
712 else if (nStrLen[0] && aEntries[0].bDoQuery)
713 {
714 // Due to conflict, we can import only the first condition.
715 OUString aStr = rStrm.ReadUniString(nStrLen[0]);
717 aEntries[0].GetQueryItem().maString = rPool.intern(aStr);
719 }
720 }
721}
722
724{
725 if (pRange)
726 {
727 aCriteriaRange = *pRange;
728 bCriteria = true;
729 }
730 else
731 bCriteria = false;
732}
733
735{
736 aParam.nDestCol = rAddr.Col();
737 aParam.nDestRow = rAddr.Row();
738 aParam.nDestTab = rAddr.Tab();
739 aParam.bInplace = false;
740 aParam.bDestPers = true;
741}
742
744{
745 // Create the ScDBData() object if the AutoFilter is activated
746 // or if we need to create the Advanced Filter.
747 if( bActive || bCriteria)
748 {
749 ScDocument& rDoc = pExcRoot->pIR->GetDoc();
751 StartCol(),StartRow(), EndCol(),EndRow() );
752 if(bCriteria)
753 {
755
758 }
759 else
761 rDoc.SetAnonymousDBData(Tab(), std::unique_ptr<ScDBData>(pCurrDBData));
762 }
763
764 if( bActive )
765 {
767 }
768}
769
771{
772 // only if this is a saved Advanced filter
773 if( !bActive && bAutoOrAdvanced )
774 {
775 ScQueryEntry& aEntry = aParam.AppendEntry();
776 aEntry.bDoQuery = true;
777 }
778
779 // TBD: force the automatic activation of the
780 // "Remove Filter" by setting a virtual mouse click
781 // inside the advanced range
782}
783
785{
786 if( !GetByTab( rRange.aStart.Tab() ) )
787 maFilters.push_back( std::make_shared<XclImpAutoFilterData>( pRoot, rRange ));
788}
789
791{
793 if( pData )
794 pData->SetAdvancedRange( &rRange );
795}
796
798{
800 if( pData )
801 pData->SetExtractPos( rRange.aStart );
802}
803
805{
806 for( const auto& rFilterPtr : maFilters )
807 rFilterPtr->Apply();
808}
809
811{
812 for( const auto& rFilterPtr : maFilters )
813 {
814 if( rFilterPtr->Tab() == nTab )
815 return rFilterPtr.get();
816 }
817 return nullptr;
818}
819
820/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
ScMF
Definition: attrib.hxx:34
Definition: root.hxx:67
RootData * pExcRoot
Definition: root.hxx:69
void FeatHdr()
Definition: excimp8.cxx:256
void AutoFilter()
Definition: excimp8.cxx:457
virtual void PostDocLoad() override
Definition: excimp8.cxx:384
void ReadBasic()
Definition: excimp8.cxx:321
void Iteration()
Definition: excimp8.cxx:181
void FilterMode()
Definition: excimp8.cxx:432
void Precision()
Definition: excimp8.cxx:167
ImportExcel8(XclImpRootData &rImpData, SvStream &rStrm)
Definition: excimp8.cxx:148
void Delta()
Definition: excimp8.cxx:174
void Scenario()
Definition: excimp8.cxx:231
void Feat()
Definition: excimp8.cxx:273
void Labelsst()
Definition: excimp8.cxx:236
void Calccount()
Definition: excimp8.cxx:160
void AutoFilterInfo()
Definition: excimp8.cxx:445
void Scenman()
Definition: excimp8.cxx:221
ExcScenarioList maScenList
Definition: excimp8.hxx:58
void Boundsheet()
Definition: excimp8.cxx:188
virtual void EndSheet() override
Definition: excimp8.cxx:377
virtual ~ImportExcel8() override
Definition: excimp8.cxx:156
virtual void EndSheet()
Definition: impop.cxx:1223
SCTAB nBdshtTab
Definition: imp_op.hxx:111
RootData * pExcRoot
Definition: imp_op.hxx:87
ScfUInt32Vec maSheetOffsets
Definition: imp_op.hxx:92
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
Definition: imp_op.hxx:95
virtual void PostDocLoad()
Definition: impop.cxx:1278
XclImpStream & aIn
Definition: imp_op.hxx:90
ScDocument & rD
Definition: imp_op.hxx:46
@ UNINITIALIZED
Definition: address.hxx:220
SCTAB Tab() const
Definition: address.hxx:283
SCROW Row() const
Definition: address.hxx:274
SCCOL Col() const
Definition: address.hxx:279
void ImportCustomToolBar(SfxObjectShell &rDocSh)
Definition: xltoolbar.cxx:416
bool Read(SvStream &rS) override
Definition: xltoolbar.cxx:368
SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange &rSource) const
Definition: dbdata.cxx:455
void SetAutoFilter(bool bSet)
Definition: dbdata.hxx:213
SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange *pSource)
Definition: dbdata.cxx:444
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
Definition: dbdata.cxx:435
void SetCalcAsShown(bool bVal)
Definition: docoptio.hxx:82
void SetIter(bool bVal)
Definition: docoptio.hxx:60
void SetIterEps(double fEps)
Definition: docoptio.hxx:64
void SetIterCount(sal_uInt16 nCount)
Definition: docoptio.hxx:62
SC_DLLPUBLIC void UpdateChartListenerCollection()
Definition: documen5.cxx:571
bool IsClipboard() const
Definition: document.hxx:1594
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:837
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
Definition: documen3.cxx:1942
SC_DLLPUBLIC bool CreateQueryParam(const ScRange &rRange, ScQueryParam &rQueryParam)
Definition: documen3.cxx:1485
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
Definition: document.cxx:375
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
Definition: document.cxx:171
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
Definition: document.cxx:4741
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
Definition: document.cxx:2502
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
Definition: document.cxx:4684
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
Definition: documen3.cxx:1936
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
Definition: document.cxx:884
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
Definition: document.cxx:302
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
Definition: global.cxx:1055
ScAddress aEnd
Definition: address.hxx:498
ScAddress aStart
Definition: address.hxx:497
css::uno::Reference< css::io::XInputStream > const & GetInputStream()
css::uno::Reference< css::frame::XModel3 > GetModel() const
SvStream & ReadDouble(double &rDouble)
SvStream & ReadInt32(sal_Int32 &rInt32)
bool IsLoadExcelBasicStorage() const
bool IsLoadExcelBasicExecutable() const
static SvtFilterOptions & Get()
bool IsLoadExcelBasicCode() const
void ConvertRangeList(ScRangeList &rScRanges, const XclRangeList &rXclRanges, SCTAB nScTab, bool bWarn)
Converts the passed Excel cell range list to a Calc cell range list.
Definition: xihelper.cxx:125
void AddAdvancedRange(const ScRange &rRange)
Definition: excimp8.cxx:790
void AddExtractPos(const ScRange &rRange)
Definition: excimp8.cxx:797
std::vector< XclImpAutoFilterSharePtr > maFilters
Definition: excimp8.hxx:112
XclImpAutoFilterData * GetByTab(SCTAB nTab)
Definition: excimp8.cxx:810
void Insert(RootData *pRoot, const ScRange &rRange)
Definition: excimp8.cxx:784
XclImpAutoFilterData(RootData *pRoot, const ScRange &rRange)
Definition: excimp8.cxx:466
void SetExtractPos(const ScAddress &rAddr)
Definition: excimp8.cxx:734
void EnableRemoveFilter()
Definition: excimp8.cxx:770
void SetAdvancedRange(const ScRange *pRange)
Definition: excimp8.cxx:723
SCROW StartRow() const
Definition: excimp8.hxx:85
void ReadAutoFilter(XclImpStream &rStrm, svl::SharedStringPool &rPool)
Definition: excimp8.cxx:553
SCTAB Tab() const
Definition: excimp8.hxx:83
ScQueryParam aParam
Definition: excimp8.hxx:66
SCCOL EndCol() const
Definition: excimp8.hxx:86
SCCOL StartCol() const
Definition: excimp8.hxx:84
ScDBData * pCurrDBData
Definition: excimp8.hxx:65
SCROW EndRow() const
Definition: excimp8.hxx:87
ScRange aCriteriaRange
Definition: excimp8.hxx:67
void Apply()
Inserts the conditional formatting into the document.
Definition: xicontent.cxx:733
void SetOleNameOverrideInfo(const css::uno::Reference< css::container::XNameContainer > &rxOverrideInfo)
Sets the container to receive overridden shape/ctrl names from the filter.
Definition: xiescher.hxx:1170
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
Definition: xiroot.cxx:123
XclImpWebQueryBuffer & GetWebQueryBuffer() const
Returns the web query buffer.
Definition: xiroot.cxx:226
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
Definition: xiroot.cxx:165
ScDocumentImport & GetDocImport()
Definition: xiroot.cxx:294
XclImpCondFormatManager & GetCondFormatManager() const
Returns the conditional formatting manager.
Definition: xiroot.cxx:207
XclImpDocProtectBuffer & GetDocProtectBuffer() const
Returns the document protection options.
Definition: xiroot.cxx:244
XclImpValidationManager & GetValidationManager() const
Definition: xiroot.cxx:213
bool HasBasic() const
Returns true, if the document contains a VB project.
Definition: xiroot.hxx:207
XclImpSst & GetSst() const
Returns the shared string table.
Definition: xiroot.cxx:139
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
Definition: xiroot.hxx:134
XclImpTabInfo & GetTabInfo() const
Returns the buffer that contains the sheet creation order.
Definition: xiroot.cxx:180
XclImpSheetProtectBuffer & GetSheetProtectBuffer() const
Returns the sheet protection options of the current sheet.
Definition: xiroot.cxx:238
XclImpObjectManager & GetObjectManager() const
Returns the drawing object manager.
Definition: xiroot.cxx:196
void ReadOptions(XclImpStream &rStrm, SCTAB nTab)
Definition: xicontent.cxx:1356
void AppendEnhancedProtection(const ScEnhancedProtection &rProt, SCTAB nTab)
Definition: xicontent.cxx:1375
const XclImpString * GetString(sal_uInt32 nSstIndex) const
Returns a pointer to the string with the passed index.
Definition: xicontent.cxx:95
This class is used to import record oriented streams.
Definition: xistream.hxx:278
void EnableDecryption(bool bEnable=true)
Switches usage of current decryption algorithm on/off.
Definition: xistream.cxx:522
void DisableDecryption()
Switches usage of current decryption algorithm off.
Definition: xistream.hxx:334
sal_uInt8 ReaduInt8()
Definition: xistream.cxx:617
sal_uInt32 ReaduInt32()
Definition: xistream.cxx:685
std::size_t Read(void *pData, std::size_t nBytes)
Reads nBytes bytes to the existing(!) buffer pData.
Definition: xistream.cxx:721
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
Definition: xistream.cxx:891
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
Definition: xistream.cxx:798
sal_uInt16 ReaduInt16()
Definition: xistream.cxx:649
double ReadDouble()
Definition: xistream.cxx:703
static void SetToDocument(ScDocumentImport &rDoc, const ScAddress &rPos, const XclImpRoot &rRoot, const XclImpString &rString, sal_uInt16 nXFIndex)
Definition: xihelper.cxx:223
This class represents an unformatted or formatted string and provides importing from stream.
Definition: xistring.hxx:31
void AppendXclTabName(const OUString &rXclTabName, SCTAB nScTab)
Appends an original Excel sheet name with corresponding Calc sheet index.
Definition: xilink.cxx:227
void Apply()
Inserts all web queries into the document.
Definition: xicontent.cxx:1100
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
Definition: xistyle.cxx:1926
A 2D cell range address list with Excel column and row indexes.
Definition: xladdress.hxx:102
void Read(XclImpStream &rStrm, bool bCol16Bit=true, sal_uInt16 nCountInStream=0)
Definition: xladdress.cxx:90
bool empty() const
Definition: xladdress.hxx:110
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
Definition: xlroot.cxx:290
const tools::SvRef< SotStorage > & GetRootStorage() const
Returns the OLE2 root storage of the imported/exported file.
Definition: xlroot.hxx:186
SfxMedium & GetMedium() const
Returns the medium to import from.
Definition: xlroot.hxx:170
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
Definition: xlroot.hxx:162
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
Definition: xlroot.cxx:285
static double GetDoubleFromRK(sal_Int32 nRKValue)
GUID of file moniker (HLINK record).
Definition: xltools.cxx:98
css::uno::Type const & get()
StorageRef openSubStorage(const OUString &rStorageName, bool bCreateMissing)
void importVbaProject(StorageBase &rVbaPrjStrg, const GraphicHelper &rGraphicHelper)
void setOleOverridesSink(css::uno::Reference< css::container::XNameContainer > const &rxOleOverridesSink)
SharedString intern(const OUString &rStr)
T * get() const
bool is() const
float u
ScXMLEditAttributeMap::Entry const aEntries[]
#define ERRCODE_NONE
const sal_uInt8 EXC_AFOPER_NOTEQUAL
Definition: excdefs.hxx:53
const sal_uInt16 EXC_AFFLAG_TOP10TOP
Definition: excdefs.hxx:34
const sal_uInt8 EXC_AFTYPE_BOOLERR
Definition: excdefs.hxx:42
const sal_uInt16 EXC_AFFLAG_TOP10
Definition: excdefs.hxx:33
const sal_uInt16 EXC_AFFLAG_SIMPLE2
Definition: excdefs.hxx:32
const sal_uInt8 EXC_AFTYPE_DOUBLE
Definition: excdefs.hxx:40
const sal_uInt16 EXC_AFFLAG_TOP10PERC
Definition: excdefs.hxx:35
const sal_uInt8 EXC_AFOPER_LESS
Definition: excdefs.hxx:49
const sal_uInt8 EXC_AFOPER_GREATEREQUAL
Definition: excdefs.hxx:54
const sal_uInt8 EXC_AFTYPE_STRING
Definition: excdefs.hxx:41
const sal_uInt16 EXC_AFFLAG_ANDORMASK
Definition: excdefs.hxx:30
const sal_uInt8 EXC_AFOPER_GREATER
Definition: excdefs.hxx:52
const sal_uInt8 EXC_AFOPER_LESSEQUAL
Definition: excdefs.hxx:51
const sal_uInt16 EXC_AFFLAG_SIMPLE1
Definition: excdefs.hxx:31
const sal_uInt8 EXC_AFOPER_EQUAL
Definition: excdefs.hxx:50
const sal_uInt8 EXC_AFTYPE_RK
Definition: excdefs.hxx:39
const sal_uInt8 EXC_AFTYPE_NOTEMPTY
Definition: excdefs.hxx:45
const sal_uInt8 EXC_AFTYPE_EMPTY
Definition: excdefs.hxx:44
static void ExcelQueryToOooQuery(OUString &aStr, ScQueryEntry &rEntry)
Definition: excimp8.cxx:524
ReturnType get_flagvalue(Type nBitField, Type nMask, ReturnType nSet, ReturnType nUnset)
Returns nSet, if at least one bit of nMask is set in nBitField, otherwise nUnset.
Definition: ftools.hxx:80
bool get_flag(Type nBitField, Type nMask)
Returns true, if at least one of the bits set in nMask is set in nBitField.
Definition: ftools.hxx:75
ScQueryConnect
Definition: global.hxx:854
@ SC_OR
Definition: global.hxx:856
@ SC_AND
Definition: global.hxx:855
@ SC_DOES_NOT_CONTAIN
Definition: global.hxx:846
@ SC_LESS_EQUAL
Definition: global.hxx:838
@ SC_LESS
Definition: global.hxx:836
@ SC_GREATER_EQUAL
Definition: global.hxx:839
@ SC_CONTAINS
Definition: global.hxx:845
@ SC_TOPPERC
Definition: global.hxx:843
@ SC_ENDS_WITH
Definition: global.hxx:849
@ SC_DOES_NOT_END_WITH
Definition: global.hxx:850
@ SC_BEGINS_WITH
Definition: global.hxx:847
@ SC_TOPVAL
Definition: global.hxx:841
@ SC_GREATER
Definition: global.hxx:837
@ SC_EQUAL
Definition: global.hxx:835
@ SC_BOTPERC
Definition: global.hxx:844
@ SC_NOT_EQUAL
Definition: global.hxx:840
@ SC_DOES_NOT_BEGIN_WITH
Definition: global.hxx:848
@ SC_BOTVAL
Definition: global.hxx:842
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
Definition: globalnames.hxx:14
std::mutex m_aMutex
OUString aName
aStr
std::unique_ptr< sal_Int32[]> pData
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
void SvStream & rStrm
std::shared_ptr< StorageBase > StorageRef
ErrCode LoadOlePropertySet(const uno::Reference< document::XDocumentProperties > &i_xDocProps, SotStorage *i_pStorage)
const char GetValue[]
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
std::vector< std::unique_ptr< ExcScenario > > aEntries
Definition: excscen.hxx:67
sal_uInt16 nLastScenario
Definition: excscen.hxx:66
void Apply(const XclImpRoot &rRoot)
Definition: exctools.cxx:233
XclImpRoot * pIR
Definition: root.hxx:59
std::unique_ptr< XclImpAutoFilterBuffer > pAutoFilterBuffer
Definition: root.hxx:53
ExcelToSc * pFmlaConverter
Definition: root.hxx:49
Container for the Excel EnhancedProtection feature.
sal_uInt32 mnPasswordVerifier
::std::vector< sal_uInt8 > maSecurityDescriptor
ScRangeListRef maRangeList
svl::SharedString maString
Definition: queryentry.hxx:49
Each instance of this struct represents a single filtering criteria.
Definition: queryentry.hxx:34
SCCOLROW nField
Definition: queryentry.hxx:61
const Item & GetQueryItem() const
Definition: queryentry.hxx:85
void SetQueryByNonEmpty()
Definition: queryentry.cxx:99
ScQueryConnect eConnect
Definition: queryentry.hxx:63
std::vector< Item > QueryItemsType
Definition: queryentry.hxx:58
ScQueryOp eOp
Definition: queryentry.hxx:62
void SetQueryByEmpty()
Definition: queryentry.cxx:77
QueryItemsType & GetQueryItems()
Definition: queryentry.hxx:75
SC_DLLPUBLIC ScQueryEntry & AppendEntry()
Definition: queryparam.cxx:126
A 2D cell address struct with Excel column and row indexes.
Definition: xladdress.hxx:30
Stores global buffers and data needed for Excel import filter.
Definition: xiroot.hxx:64
unsigned char sal_uInt8
unsigned char sal_Bool
sal_uInt16 sal_Unicode
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
Definition: types.hxx:23
sal_Int16 SCTAB
Definition: types.hxx:22
sal_Int16 SCCOL
Definition: types.hxx:21
const sal_uInt16 EXC_ISFPROTECTION
Definition: xlconst.hxx:254