10#include <com/sun/star/document/XExtendedFilterDetection.hpp>
11#include <com/sun/star/lang/XServiceInfo.hpp>
12#include <com/sun/star/io/XInputStream.hpp>
20#include <orcus/format_detection.hpp>
26class OrcusFormatDetect :
public ::cppu::WeakImplHelper<
27 css::document::XExtendedFilterDetection,
28 css::lang::XServiceInfo >
31 explicit OrcusFormatDetect();
39 virtual OUString SAL_CALL
40 detect( css::uno::Sequence< css::beans::PropertyValue >& rMediaDescSeq )
override;
45OrcusFormatDetect::OrcusFormatDetect()
49OUString OrcusFormatDetect::getImplementationName()
51 return "com.sun.star.comp.sc.OrcusFilterDetect";
54sal_Bool OrcusFormatDetect::supportsService(
const OUString& rServiceName)
59css::uno::Sequence<OUString> OrcusFormatDetect::getSupportedServiceNames()
61 return {
"com.sun.star.frame.ExtendedTypeDetection"};
64OUString OrcusFormatDetect::detect(css::uno::Sequence<css::beans::PropertyValue>& rMediaDescSeq)
74 static const sal_Int32 nBytes = 4096;
75 css::uno::Sequence<sal_Int8>
aSeq(nBytes);
79 sal_Int32 nReadBytes = xInputStream->readBytes(aSeq, nBytes);
80 bEnd = (nReadBytes != nBytes);
81 aContent.WriteBytes(
aSeq.getConstArray(), nReadBytes);
84 std::string_view aStream(
static_cast<const char*
>(aContent.GetData()), aContent.GetSize());
85 orcus::format_t eFormat = orcus::detect(aStream);
89 case orcus::format_t::gnumeric:
90 return "Gnumeric XML";
91 case orcus::format_t::xls_xml:
92 return "calc_MS_Excel_2003_XML";
102extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
104 css::uno::Sequence<css::uno::Any>
const &)
106 return cppu::acquire(
new OrcusFormatDetect());
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * com_sun_star_comp_sc_OrcusFormatDetect_get_implementation(css::uno::XComponentContext *, css::uno::Sequence< css::uno::Any > const &)
Sequence< sal_Int8 > aSeq
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)