12#include <tokenarray.hxx>
14#include <osl/thread.hxx>
17#include <sfx2/sfxsids.hrc>
19#include <rtl/ustring.hxx>
22#include <orcus/orcus_csv.hpp>
23#include <orcus/orcus_gnumeric.hpp>
24#include <orcus/orcus_xlsx.hpp>
25#include <orcus/orcus_xls_xml.hpp>
26#include <orcus/orcus_ods.hpp>
27#include <orcus/orcus_import_ods.hpp>
28#include <orcus/stream.hpp>
29#include <com/sun/star/task/XStatusIndicator.hpp>
35uno::Reference<task::XStatusIndicator> getStatusIndicator(
const SfxMedium& rMedium)
37 uno::Reference<task::XStatusIndicator> xStatusIndicator;
41 xStatusIndicator.set(pItem->
GetValue(), uno::UNO_QUERY);
42 return xStatusIndicator;
45bool loadFileContent(
SfxMedium& rMedium, orcus::iface::import_filter&
filter)
49 static const size_t nReadBuffer = 1024 * 32;
50 OStringBuffer
aBuffer((
int(nReadBuffer)));
54 char pData[nReadBuffer];
55 nRead = pStream->
ReadBytes(pData, nReadBuffer);
57 }
while (nRead == nReadBuffer);
61 filter.read_stream(aBuffer);
63 catch (
const std::exception& e)
65 SAL_WARN(
"sc",
"Unable to load file via orcus filter! " << e.what());
78 orcus::orcus_csv
filter(&aFactory);
79 return loadFileContent(rMedium,
filter);
87 orcus::orcus_gnumeric
filter(&aFactory);
88 return loadFileContent(rMedium,
filter);
96 orcus::orcus_xls_xml
filter(&aFactory);
97 return loadFileContent(rMedium,
filter);
105 orcus::orcus_xlsx
filter(&aFactory);
106 return loadFileContent(rMedium,
filter);
114 orcus::orcus_ods
filter(&aFactory);
115 return loadFileContent(rMedium,
filter);
127 orcus::file_content content(aPath8);
130 orcus::import_ods::read_styles(content.str(), &aStyles);
132 catch (
const std::exception& e)
134 SAL_WARN(
"sc",
"Unable to load styles from xml file! " << e.what());
142 const OUString& rPath)
const
144 return std::make_unique<ScOrcusXMLContextImpl>(rDoc, rPath);
void setStatusIndicator(const css::uno::Reference< css::task::XStatusIndicator > &rIndicator)
virtual bool importXLSX(ScDocument &rDoc, SfxMedium &rMedium) const override
virtual bool importGnumeric(ScDocument &rDoc, SfxMedium &rMedium) const override
virtual std::unique_ptr< ScOrcusXMLContext > createXMLContext(ScDocument &rDoc, const OUString &rPath) const override
Create a context for XML file.
virtual bool importODS(ScDocument &rDoc, SfxMedium &rMedium) const override
virtual bool importCSV(ScDocument &rDoc, SfxMedium &rMedium) const override
virtual bool importExcel2003XML(ScDocument &rDoc, SfxMedium &rMedium) const override
virtual bool importODS_Styles(ScDocument &rDoc, OUString &aFileName) const override
Used to import just the styles from an xml file.
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
SfxItemSet & GetItemSet() const
const css::uno::Any & GetValue() const
sal_uInt64 Seek(sal_uInt64 nPos)
std::size_t ReadBytes(void *pData, std::size_t nSize)
#define SAL_WARN(area, stream)
std::unique_ptr< sal_Int32[]> pData
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
std::unique_ptr< char[]> aBuffer