11#include <com/sun/star/beans/NamedValue.hpp>
12#include <com/sun/star/beans/PropertyValue.hpp>
13#include <com/sun/star/io/XInputStream.hpp>
14#include <com/sun/star/uno/Reference.h>
15#include <com/sun/star/ucb/XContent.hpp>
19#include <libetonyek/libetonyek.h>
36 return libetonyek::EtonyekDocument::parse(&rInput, &rGenerator);
41 if (libetonyek::EtonyekDocument::isSupported(&rInput))
43 rTypeName =
"impress_Keynote_Document";
54 sal_Int32
nLength = Descriptor.getLength();
55 sal_Int32 nNewLength =
nLength + 2;
56 sal_Int32 nComponentDataLocation = -1;
57 sal_Int32 nTypeNameLocation = -1;
58 sal_Int32 nUCBContentLocation = -1;
59 bool bIsPackage =
false;
60 bool bUCBContentChanged =
false;
61 const beans::PropertyValue* pValue = Descriptor.getConstArray();
62 css::uno::Reference<com::sun::star::io::XInputStream> xInputStream;
63 css::uno::Reference<ucb::XContent> xContent;
64 css::uno::Sequence<beans::NamedValue> lComponentDataNV;
65 css::uno::Sequence<beans::PropertyValue> lComponentDataPV;
66 bool bComponentDataNV =
true;
70 if (pValue[
i].
Name ==
"TypeName")
72 nTypeNameLocation =
i;
75 if (pValue[
i].
Name ==
"ComponentData")
77 bComponentDataNV = pValue[
i].Value >>= lComponentDataNV;
78 if (!bComponentDataNV)
79 pValue[
i].Value >>= lComponentDataPV;
80 nComponentDataLocation =
i;
83 else if (pValue[
i].
Name ==
"InputStream")
85 pValue[
i].Value >>= xInputStream;
87 else if (pValue[
i].
Name ==
"UCBContent")
89 pValue[
i].Value >>= xContent;
90 nUCBContentLocation =
i;
96 if (!xInputStream.is())
99 std::unique_ptr<librevenge::RVNGInputStream> input
100 = std::make_unique<WPXSvInputStream>(xInputStream);
123 input = std::make_unique<writerperfect::DirectoryStream>(xContent);
133 libetonyek::EtonyekDocument::Type
type = libetonyek::EtonyekDocument::TYPE_UNKNOWN;
134 const libetonyek::EtonyekDocument::Confidence confidence
135 = libetonyek::EtonyekDocument::isSupported(input.get(), &
type);
136 if ((libetonyek::EtonyekDocument::CONFIDENCE_NONE == confidence)
137 || (libetonyek::EtonyekDocument::TYPE_KEYNOTE !=
type))
140 if (confidence == libetonyek::EtonyekDocument::CONFIDENCE_SUPPORTED_PART)
145 std::unique_ptr<writerperfect::DirectoryStream> xDir
147 auto pDir = xDir.get();
148 input = std::move(xDir);
151 if (libetonyek::EtonyekDocument::CONFIDENCE_EXCELLENT
152 == libetonyek::EtonyekDocument::isSupported(input.get()))
154 xContent = pDir->getContent();
155 bUCBContentChanged =
true;
168 if (!bIsPackage && (nComponentDataLocation == -1))
172 Descriptor.realloc(nNewLength);
173 auto pDescriptor = Descriptor.getArray();
175 if (nTypeNameLocation == -1)
179 pDescriptor[nTypeNameLocation].Name =
"TypeName";
182 if (bIsPackage && (nComponentDataLocation == -1))
185 nComponentDataLocation =
nLength++;
186 pDescriptor[nComponentDataLocation].Name =
"ComponentData";
191 if (bComponentDataNV)
193 const sal_Int32 nCDSize = lComponentDataNV.getLength();
194 lComponentDataNV.realloc(nCDSize + 1);
195 beans::NamedValue aValue;
196 aValue.Name =
"IsPackage";
197 aValue.Value <<=
true;
198 lComponentDataNV.getArray()[nCDSize] = aValue;
199 pDescriptor[nComponentDataLocation].Value <<= lComponentDataNV;
203 const sal_Int32 nCDSize = lComponentDataPV.getLength();
204 lComponentDataPV.realloc(nCDSize + 1);
205 beans::PropertyValue aProp;
206 aProp.Name =
"IsPackage";
207 aProp.Value <<=
true;
209 aProp.State = beans::PropertyState_DIRECT_VALUE;
210 lComponentDataPV.getArray()[nCDSize] = aProp;
211 pDescriptor[nComponentDataLocation].Value <<= lComponentDataPV;
215 if (bUCBContentChanged)
216 pDescriptor[nUCBContentLocation].Value <<= xContent;
218 static constexpr OUStringLiteral sTypeName(
u"impress_AppleKeynote");
219 pDescriptor[nTypeNameLocation].Value <<= OUString(sTypeName);
227 return "org.libreoffice.comp.Impress.KeynoteImportFilter";
237 return {
"com.sun.star.document.ImportFilter",
"com.sun.star.document.ExtendedTypeDetection" };
240extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
242 css::uno::XComponentContext*
const context,
const css::uno::Sequence<css::uno::Any>&)
SAL_DLLPUBLIC_EXPORT css::uno::XInterface * org_libreoffice_comp_Impress_KeynoteImportFilter_get_implementation(css::uno::XComponentContext *const context, const css::uno::Sequence< css::uno::Any > &)
virtual bool doDetectFormat(librevenge::RVNGInputStream &rInput, OUString &rTypeName) override
virtual OUString SAL_CALL getImplementationName() override
virtual bool doImportDocument(weld::Window *pParent, librevenge::RVNGInputStream &rInput, OdpGenerator &rGenerator, utl::MediaDescriptor &) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual OUString SAL_CALL detect(css::uno::Sequence< css::beans::PropertyValue > &Descriptor) override
static std::unique_ptr< DirectoryStream > createForParent(const css::uno::Reference< css::ucb::XContent > &xContent)
Reference< XComponentContext > getProcessComponentContext()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
UNOTOOLS_DLLPUBLIC css::uno::Reference< css::ucb::XCommandEnvironment > getDefaultCommandEnvironment()