20#include <config_features.h>
35#include <rtl/math.hxx>
36#include <rtl/ustring.hxx>
39#include <document.hxx>
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>
71class OleNameOverrideContainer :
public ::cppu::WeakImplHelper< container::XNameContainer >
74 typedef std::unordered_map< OUString, uno::Reference< container::XIndexContainer > > NamedIndexToOleName;
75 NamedIndexToOleName IdToOleNameHash;
80 virtual sal_Bool SAL_CALL hasElements( )
override
82 std::unique_lock aGuard( m_aMutex );
83 return ( !IdToOleNameHash.empty() );
86 virtual uno::Any SAL_CALL getByName(
const OUString& aName )
override
88 std::unique_lock aGuard( m_aMutex );
89 auto it = IdToOleNameHash.find( aName );
90 if ( it == IdToOleNameHash.end() )
91 throw container::NoSuchElementException();
94 virtual uno::Sequence< OUString > SAL_CALL getElementNames( )
override
96 std::unique_lock aGuard( m_aMutex );
99 virtual sal_Bool SAL_CALL hasByName(
const OUString& aName )
override
101 std::unique_lock aGuard( m_aMutex );
102 return ( IdToOleNameHash.find( aName ) != IdToOleNameHash.end() );
106 virtual void SAL_CALL insertByName(
const OUString& aName,
const uno::Any& aElement )
override
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;
117 virtual void SAL_CALL removeByName(
const OUString& aName )
override
119 std::unique_lock aGuard( m_aMutex );
120 if ( IdToOleNameHash.erase( aName ) == 0 )
121 throw container::NoSuchElementException();
123 virtual void SAL_CALL replaceByName(
const OUString& aName,
const uno::Any& aElement )
override
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;
139bool readFrtHeader(
XclImpStream& rStrm, sal_uInt16 nRecordID )
141 sal_uInt16 nRt =
rStrm.ReaduInt16();
143 return nRt == nRecordID;
205 OSL_ENSURE( !
rD.
HasTable( nScTab ),
"ImportExcel8::Boundsheet - sheet exists already" );
209 if( ( nGrbit & 0x0001 ) || ( nGrbit & 0x0002 ) )
223 sal_uInt16 nLastDispl;
258 if (!readFrtHeader(
aIn, 0x0867))
275 if (!readFrtHeader(
aIn, 0x0868))
308 if ((aProt.
mnAreserved & 0x00000001) == 0x00000001)
326 if( !pShell || !xRootStrg.
is() )
342 if ( wrapper.
Read( *xXCB ) )
345 wrapper.Print( stderr );
353 uno::Reference< uno::XComponentContext > aCtx( ::comphelper::getProcessComponentContext() );
355 uno::Reference< io::XInputStream > xIn = rMedium.
GetInputStream();
362 uno::Reference< container::XNameContainer > xOleNameOverrideSink(
new OleNameOverrideContainer );
368 catch( uno::Exception& )
372 catch( uno::Exception& )
386#if HAVE_FEATURE_SCRIPTING
416 if( xRootStrg.
is() )
try
418 uno::Reference< document::XDocumentPropertiesSupplier > xDPS( pShell->
GetModel(), uno::UNO_QUERY_THROW );
419 uno::Reference< document::XDocumentProperties > xDocProps( xDPS->getDocumentProperties(), uno::UNO_SET_THROW );
422 catch( uno::Exception& )
442 pData->SetAutoOrAdvanced();
452 pData->SetAdvancedRange(
nullptr );
468 pCurrDBData(nullptr),
471 bAutoOrAdvanced(false)
485OUString CreateFromDouble(
double fVal )
487 return rtl::math::doubleToUString(fVal,
488 rtl_math_StringFormat_Automatic, rtl_math_DecimalPlaces_Max,
529 sal_Int32 nLen =
aStr.getLength();
532 if( nLen > 2 && nStart ==
'*' && nEnd ==
'*' )
537 else if( nLen > 1 && nStart ==
'*' && nEnd !=
'*' )
542 else if( nLen > 1 && nStart !=
'*' && nEnd ==
'*' )
547 else if( nLen == 2 && nStart ==
'*' && nEnd ==
'*' )
556 sal_uInt16 nCol, nFlags;
557 nCol =
rStrm.ReaduInt16();
558 nFlags =
rStrm.ReaduInt16();
566 sal_uInt16 nCntOfTop10 = nFlags >> 7;
574 aEntry.
eOp = bTopOfTop10 ?
592 for (
size_t nE = 0; nE < 2; ++nE)
596 bool bIgnore =
false;
599 nOper =
rStrm.ReaduInt8();
638 nStrLen[ nE ] =
rStrm.ReaduInt8();
643 nBoolErr =
rStrm.ReaduInt8();
644 nVal =
rStrm.ReaduInt8();
647 bIgnore = (nBoolErr != 0);
671 for (
size_t nE = 0; nE < 2; ++nE)
673 if (nStrLen[nE] &&
aEntries[nE].bDoQuery)
675 OUString
aStr =
rStrm.ReadUniString(nStrLen[nE]);
684 assert( eConn ==
SC_OR &&
"eConn should be SC_AND or SC_OR");
694 if (bSimple1 && bSimple2 && nStrLen[0] && nStrLen[1])
708 aItems.push_back(aItem1);
709 aItems.push_back(aItem2);
712 else if (nStrLen[0] &&
aEntries[0].bDoQuery)
715 OUString
aStr =
rStrm.ReadUniString(nStrLen[0]);
787 maFilters.push_back( std::make_shared<XclImpAutoFilterData>( pRoot, rRange ));
794 pData->SetAdvancedRange( &rRange );
806 for(
const auto& rFilterPtr :
maFilters )
812 for(
const auto& rFilterPtr :
maFilters )
814 if( rFilterPtr->Tab() == nTab )
815 return rFilterPtr.get();
virtual void PostDocLoad() override
ImportExcel8(XclImpRootData &rImpData, SvStream &rStrm)
ExcScenarioList maScenList
virtual void EndSheet() override
virtual ~ImportExcel8() override
ScfUInt32Vec maSheetOffsets
std::unique_ptr< ExcelToSc > pFormConv
Visible range if embedded.
virtual void PostDocLoad()
void ImportCustomToolBar(SfxObjectShell &rDocSh)
bool Read(SvStream &rS) override
SC_DLLPUBLIC bool GetAdvancedQuerySource(ScRange &rSource) const
void SetAutoFilter(bool bSet)
SC_DLLPUBLIC void SetAdvancedQuerySource(const ScRange *pSource)
SC_DLLPUBLIC void SetQueryParam(const ScQueryParam &rQueryParam)
void SetCalcAsShown(bool bVal)
void SetIterEps(double fEps)
void SetIterCount(sal_uInt16 nCount)
SC_DLLPUBLIC void UpdateChartListenerCollection()
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
SC_DLLPUBLIC void SetDocOptions(const ScDocOptions &rOpt)
SC_DLLPUBLIC bool CreateQueryParam(const ScRange &rRange, ScQueryParam &rQueryParam)
SC_DLLPUBLIC void CreateValidTabName(OUString &rName) const
SC_DLLPUBLIC void MakeTable(SCTAB nTab, bool _bNeedsNameCheck=true)
SC_DLLPUBLIC void ApplyAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, const SfxPoolItem &rAttr)
SC_DLLPUBLIC bool HasTable(SCTAB nTab) const
SC_DLLPUBLIC const SfxPoolItem * GetAttr(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt16 nWhich) const
SC_DLLPUBLIC const ScDocOptions & GetDocOptions() const
SC_DLLPUBLIC void SetVisible(SCTAB nTab, bool bVisible)
SC_DLLPUBLIC void SetAnonymousDBData(SCTAB nTab, std::unique_ptr< ScDBData > pDBData)
static SC_DLLPUBLIC const LocaleDataWrapper & getLocaleData()
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.
void AddAdvancedRange(const ScRange &rRange)
void AddExtractPos(const ScRange &rRange)
std::vector< XclImpAutoFilterSharePtr > maFilters
XclImpAutoFilterData * GetByTab(SCTAB nTab)
void Insert(RootData *pRoot, const ScRange &rRange)
XclImpAutoFilterData(RootData *pRoot, const ScRange &rRange)
void SetExtractPos(const ScAddress &rAddr)
void EnableRemoveFilter()
void SetAdvancedRange(const ScRange *pRange)
void ReadAutoFilter(XclImpStream &rStrm, svl::SharedStringPool &rPool)
void SetOleNameOverrideInfo(const css::uno::Reference< css::container::XNameContainer > &rxOverrideInfo)
Sets the container to receive overridden shape/ctrl names from the filter.
XclImpAddressConverter & GetAddressConverter() const
Returns the address converter.
XclImpWebQueryBuffer & GetWebQueryBuffer() const
Returns the web query buffer.
XclImpXFRangeBuffer & GetXFRangeBuffer() const
Returns the buffer of XF index ranges for a sheet.
ScDocumentImport & GetDocImport()
XclImpCondFormatManager & GetCondFormatManager() const
Returns the conditional formatting manager.
XclImpDocProtectBuffer & GetDocProtectBuffer() const
Returns the document protection options.
XclImpValidationManager & GetValidationManager() const
bool HasBasic() const
Returns true, if the document contains a VB project.
XclImpSst & GetSst() const
Returns the shared string table.
const XclImpRoot & GetRoot() const
Returns this root instance - for code readability in derived classes.
XclImpTabInfo & GetTabInfo() const
Returns the buffer that contains the sheet creation order.
XclImpSheetProtectBuffer & GetSheetProtectBuffer() const
Returns the sheet protection options of the current sheet.
XclImpObjectManager & GetObjectManager() const
Returns the drawing object manager.
void ReadOptions(XclImpStream &rStrm, SCTAB nTab)
void AppendEnhancedProtection(const ScEnhancedProtection &rProt, SCTAB nTab)
const XclImpString * GetString(sal_uInt32 nSstIndex) const
Returns a pointer to the string with the passed index.
This class is used to import record oriented streams.
void EnableDecryption(bool bEnable=true)
Switches usage of current decryption algorithm on/off.
void DisableDecryption()
Switches usage of current decryption algorithm off.
std::size_t Read(void *pData, std::size_t nBytes)
Reads nBytes bytes to the existing(!) buffer pData.
OUString ReadUniString(sal_uInt16 nChars, sal_uInt8 nFlags)
Reads ext.
void Ignore(std::size_t nBytes)
Seeks forward inside the current record.
static void SetToDocument(ScDocumentImport &rDoc, const ScAddress &rPos, const XclImpRoot &rRoot, const XclImpString &rString, sal_uInt16 nXFIndex)
This class represents an unformatted or formatted string and provides importing from stream.
void AppendXclTabName(const OUString &rXclTabName, SCTAB nScTab)
Appends an original Excel sheet name with corresponding Calc sheet index.
void Apply()
Inserts all web queries into the document.
void SetXF(const ScAddress &rScPos, sal_uInt16 nXFIndex)
Inserts a new XF index.
A 2D cell range address list with Excel column and row indexes.
void Read(XclImpStream &rStrm, bool bCol16Bit=true, sal_uInt16 nCountInStream=0)
SfxObjectShell * GetDocShell() const
Returns the object shell of the Calc document.
const tools::SvRef< SotStorage > & GetRootStorage() const
Returns the OLE2 root storage of the imported/exported file.
SfxMedium & GetMedium() const
Returns the medium to import from.
SCTAB GetCurrScTab() const
Returns the current Calc sheet index.
ScDocument & GetDoc() const
Returns reference to the destination document (import) or source document (export).
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)
ScXMLEditAttributeMap::Entry const aEntries[]
const sal_uInt8 EXC_AFOPER_NOTEQUAL
const sal_uInt16 EXC_AFFLAG_TOP10TOP
const sal_uInt8 EXC_AFTYPE_BOOLERR
const sal_uInt16 EXC_AFFLAG_TOP10
const sal_uInt16 EXC_AFFLAG_SIMPLE2
const sal_uInt8 EXC_AFTYPE_DOUBLE
const sal_uInt16 EXC_AFFLAG_TOP10PERC
const sal_uInt8 EXC_AFOPER_LESS
const sal_uInt8 EXC_AFOPER_GREATEREQUAL
const sal_uInt8 EXC_AFTYPE_STRING
const sal_uInt16 EXC_AFFLAG_ANDORMASK
const sal_uInt8 EXC_AFOPER_GREATER
const sal_uInt8 EXC_AFOPER_LESSEQUAL
const sal_uInt16 EXC_AFFLAG_SIMPLE1
const sal_uInt8 EXC_AFOPER_EQUAL
const sal_uInt8 EXC_AFTYPE_RK
const sal_uInt8 EXC_AFTYPE_NOTEMPTY
const sal_uInt8 EXC_AFTYPE_EMPTY
static void ExcelQueryToOooQuery(OUString &aStr, ScQueryEntry &rEntry)
constexpr OUStringLiteral STR_DB_LOCAL_NONAME
std::unique_ptr< sal_Int32[]> pData
css::uno::Sequence< typename M::key_type > mapKeysToSequence(M const &map)
std::shared_ptr< StorageBase > StorageRef
ErrCode LoadOlePropertySet(const uno::Reference< document::XDocumentProperties > &i_xDocProps, SotStorage *i_pStorage)
constexpr TypedWhichId< ScMergeFlagAttr > ATTR_MERGE_FLAG(145)
std::vector< std::unique_ptr< ExcScenario > > aEntries
void Apply(const XclImpRoot &rRoot)
std::unique_ptr< XclImpAutoFilterBuffer > pAutoFilterBuffer
ExcelToSc * pFmlaConverter
Container for the Excel EnhancedProtection feature.
sal_uInt32 mnPasswordVerifier
::std::vector< sal_uInt8 > maSecurityDescriptor
ScRangeListRef maRangeList
svl::SharedString maString
Each instance of this struct represents a single filtering criteria.
const Item & GetQueryItem() const
void SetQueryByNonEmpty()
std::vector< Item > QueryItemsType
QueryItemsType & GetQueryItems()
SC_DLLPUBLIC ScQueryEntry & AppendEntry()
A 2D cell address struct with Excel column and row indexes.
Stores global buffers and data needed for Excel import filter.
sal_Int32 SCCOLROW
a type capable of holding either SCCOL or SCROW
const sal_uInt16 EXC_ISFPROTECTION