Kaydet (Commit) 41297571 authored tarafından David Tardon's avatar David Tardon

integrate Apple Keynote import filter

Change-Id: Icc36b761da9262a99af730cfe71f576bcaab3ee1
Reviewed-on: https://gerrit.libreoffice.org/6488Tested-by: 's avatarLibreOffice gerrit bot <gerrit@libreoffice.org>
Reviewed-by: 's avatarDavid Tardon <dtardon@redhat.com>
Tested-by: 's avatarDavid Tardon <dtardon@redhat.com>
üst 2c3d6481
......@@ -180,6 +180,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,impress, \
placeware \
PresenterScreen \
PresentationMinimizer \
wpftimpress \
))
$(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,onlineupdate, \
......
......@@ -581,6 +581,7 @@ $(call filter_Configuration_add_ui_filters,fcfg_langpack,filter/source/config/fr
# fcfg_impress
$(call filter_Configuration_add_types,fcfg_langpack,fcfg_impress_types.xcu,filter/source/config/fragments/types,\
draw_StarOffice_XML_Draw \
impress_AppleKeynote \
impress_MS_PowerPoint_97 \
impress_MS_PowerPoint_97_AutoPlay \
impress_MS_PowerPoint_97_Vorlage \
......@@ -600,6 +601,7 @@ $(call filter_Configuration_add_types,fcfg_langpack,fcfg_impress_types.xcu,filte
)
$(call filter_Configuration_add_filters,fcfg_langpack,fcfg_impress_filters.xcu,filter/source/config/fragments/filters,\
AppleKeynote \
MS_PowerPoint_97 \
MS_PowerPoint_97_AutoPlay \
MS_PowerPoint_97_Vorlage \
......
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<node oor:name="Apple Keynote" oor:op="replace">
<prop oor:name="Flags">
<value>IMPORT ALIEN USESOPTIONS 3RDPARTYFILTER PREFERRED</value>
</prop>
<prop oor:name="FilterService">
<value>org.libreoffice.comp.Impress.KeynoteImportFilter</value>
</prop>
<prop oor:name="UIName">
<value xml:lang="x-default">Apple Keynote 5</value>
</prop>
<prop oor:name="FileFormatVersion">
<value>0</value>
</prop>
<prop oor:name="Type">
<value>impress_AppleKeynote</value>
</prop>
<prop oor:name="DocumentService">
<value>com.sun.star.presentation.PresentationDocument</value>
</prop>
</node>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<node oor:name="impress_AppleKeynote" oor:op="replace">
<prop oor:name="DetectService">
<value>org.libreoffice.comp.Impress.KeynoteImportFilter</value>
</prop>
<prop oor:name="Extensions">
<value>key</value>
</prop>
<prop oor:name="MediaType">
<value>application/x-iwork-keynote-sffkey</value>
</prop>
<prop oor:name="Preferred">
<value>true</value>
</prop>
<prop oor:name="PreferredFilter">
<value>Apple Keynote</value>
</prop>
<prop oor:name="UIName">
<value>Apple Keynote</value>
</prop>
</node>
......@@ -118,6 +118,7 @@ $(eval $(call gb_Rdb_add_components,services,\
writerfilter/util/writerfilter \
writerperfect/util/wpftwriter \
writerperfect/util/wpftdraw \
writerperfect/source/impress/wpftimpress \
$(if $(filter MACOSX,$(OS)), \
$(if $(filter-out X86_64,$(CPUNAME)), \
avmedia/source/quicktime/avmediaQuickTime \
......
# -*- Mode: makefile-gmake; tab-width: 4; indent-tabs-mode: t -*-
#
# This file is part of the LibreOffice project.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
#
# This file incorporates work covered by the following license notice:
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed
# with this work for additional information regarding copyright
# ownership. The ASF licenses this file to you under the Apache
# License, Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a copy of
# the License at http://www.apache.org/licenses/LICENSE-2.0 .
#
$(eval $(call gb_Library_Library,wpftimpress))
$(eval $(call gb_Library_set_componentfile,wpftimpress,writerperfect/source/impress/wpftimpress))
$(eval $(call gb_Library_set_include,wpftimpress,\
$$(INCLUDE) \
-I$(SRCDIR)/writerperfect/source \
))
$(eval $(call gb_Library_use_sdk_api,wpftimpress))
$(eval $(call gb_Library_use_libraries,wpftimpress,\
comphelper \
cppu \
cppuhelper \
sal \
sot \
tl \
utl \
xo \
$(gb_UWINAPI) \
))
$(eval $(call gb_Library_use_static_libraries,wpftimpress,\
writerperfect \
))
$(eval $(call gb_Library_use_externals,wpftimpress,\
etonyek \
odfgen \
wpd \
wpg \
zlib \
libxml2 \
))
$(eval $(call gb_Library_add_exception_objects,wpftimpress,\
writerperfect/source/impress/KeynoteImportFilter \
writerperfect/source/impress/wpftimpress_genericfilter \
))
# vim: set noet sw=4 ts=4:
......@@ -45,6 +45,10 @@ endif
endif
endif
$(eval $(call gb_Module_add_targets,writerperfect,\
Library_wpftimpress \
))
ifneq (,$(SYSTEM_WPD))
ifneq (,$(SYSTEM_WPG))
ifneq (,$(SYSTEM_ODFGEN))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* KeynoteImportFilter: Sets up the filter, and calls OdpExporter
* to do the actual filtering
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <osl/diagnose.h>
#include <rtl/tencinfo.h>
#include <com/sun/star/io/XInputStream.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/InputSource.hpp>
#include <com/sun/star/xml/sax/XParser.hpp>
#include <com/sun/star/io/XSeekable.hpp>
#include <com/sun/star/uno/Reference.h>
#include <xmloff/attrlist.hxx>
#include <libetonyek/libetonyek.h>
#include <libodfgen/libodfgen.hxx>
#include "common/DocumentHandler.hxx"
#include "common/WPXSvStream.hxx"
#include "KeynoteImportFilter.hxx"
#include <iostream>
using namespace ::com::sun::star::uno;
using com::sun::star::uno::Reference;
using com::sun::star::io::XInputStream;
using com::sun::star::io::XSeekable;
using com::sun::star::uno::Sequence;
using com::sun::star::uno::Any;
using com::sun::star::uno::UNO_QUERY;
using com::sun::star::uno::XInterface;
using com::sun::star::uno::Exception;
using com::sun::star::uno::RuntimeException;
using com::sun::star::beans::PropertyValue;
using com::sun::star::document::XFilter;
using com::sun::star::document::XExtendedFilterDetection;
using com::sun::star::document::XImporter;
using com::sun::star::xml::sax::InputSource;
using com::sun::star::xml::sax::XAttributeList;
using com::sun::star::xml::sax::XDocumentHandler;
using com::sun::star::xml::sax::XParser;
sal_Bool SAL_CALL KeynoteImportFilter::filter( const Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::filter");
sal_Int32 nLength = aDescriptor.getLength();
const PropertyValue *pValue = aDescriptor.getConstArray();
Reference < XInputStream > xInputStream;
for ( sal_Int32 i = 0 ; i < nLength; i++)
{
if ( pValue[i].Name == "InputStream" )
pValue[i].Value >>= xInputStream;
}
if ( !xInputStream.is() )
{
OSL_ASSERT( 0 );
return sal_False;
}
// An XML import service: what we push sax messages to..
Reference < XDocumentHandler > xInternalHandler(
mxContext->getServiceManager()->createInstanceWithContext(
"com.sun.star.comp.Draw.XMLOasisImporter", mxContext),
css::uno::UNO_QUERY_THROW);
// The XImporter sets up an empty target document for XDocumentHandler to write to..
Reference < XImporter > xImporter(xInternalHandler, UNO_QUERY);
xImporter->setTargetDocument( mxDoc );
// OO Graphics Handler: abstract class to handle document SAX messages, concrete implementation here
// writes to in-memory target doc
DocumentHandler xHandler(xInternalHandler);
WPXSvInputStream input( xInputStream );
OdpGenerator exporter(&xHandler, ODF_FLAT_XML);
bool tmpParseResult = libetonyek::KEYDocument::parse(&input, &exporter);
return tmpParseResult;
}
void SAL_CALL KeynoteImportFilter::cancel( )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::cancel");
}
// XImporter
void SAL_CALL KeynoteImportFilter::setTargetDocument( const Reference< ::com::sun::star::lang::XComponent >& xDoc )
throw (::com::sun::star::lang::IllegalArgumentException, RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::setTargetDocument");
mxDoc = xDoc;
}
// XExtendedFilterDetection
OUString SAL_CALL KeynoteImportFilter::detect( com::sun::star::uno::Sequence< PropertyValue >& Descriptor )
throw( com::sun::star::uno::RuntimeException )
{
SAL_INFO("writerperfect", "KeynoteImportFilter::detect");
OUString sTypeName;
sal_Int32 nLength = Descriptor.getLength();
sal_Int32 location = nLength;
const PropertyValue *pValue = Descriptor.getConstArray();
Reference < XInputStream > xInputStream;
for ( sal_Int32 i = 0 ; i < nLength; i++)
{
if ( pValue[i].Name == "TypeName" )
location=i;
else if ( pValue[i].Name == "InputStream" )
pValue[i].Value >>= xInputStream;
}
if (!xInputStream.is())
return OUString();
WPXSvInputStream input( xInputStream );
if (libetonyek::KEYDocument::isSupported(&input))
sTypeName = "impress_AppleKeynote";
if (!sTypeName.isEmpty())
{
if ( location == nLength )
{
Descriptor.realloc(nLength+1);
Descriptor[location].Name = "TypeName";
}
Descriptor[location].Value <<=sTypeName;
}
return sTypeName;
}
// XInitialization
void SAL_CALL KeynoteImportFilter::initialize( const Sequence< Any >& aArguments )
throw (Exception, RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::initialize");
Sequence < PropertyValue > aAnySeq;
sal_Int32 nLength = aArguments.getLength();
if ( nLength && ( aArguments[0] >>= aAnySeq ) )
{
const PropertyValue *pValue = aAnySeq.getConstArray();
nLength = aAnySeq.getLength();
for ( sal_Int32 i = 0 ; i < nLength; i++)
{
if ( pValue[i].Name == "Type" )
{
pValue[i].Value >>= msFilterName;
break;
}
}
}
}
OUString KeynoteImportFilter_getImplementationName ()
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter_getImplementationName");
return OUString ( "org.libreoffice.comp.Impress.KeynoteImportFilter" );
}
#define SERVICE_NAME1 "com.sun.star.document.ImportFilter"
#define SERVICE_NAME2 "com.sun.star.document.ExtendedTypeDetection"
sal_Bool SAL_CALL KeynoteImportFilter_supportsService( const OUString &ServiceName )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter_supportsService");
return ( ServiceName == SERVICE_NAME1 || ServiceName == SERVICE_NAME2 );
}
Sequence< OUString > SAL_CALL KeynoteImportFilter_getSupportedServiceNames( )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter_getSupportedServiceNames");
Sequence < OUString > aRet(2);
OUString *pArray = aRet.getArray();
pArray[0] = OUString ( SERVICE_NAME1 );
pArray[1] = OUString ( SERVICE_NAME2 );
return aRet;
}
#undef SERVICE_NAME2
#undef SERVICE_NAME1
Reference< XInterface > SAL_CALL KeynoteImportFilter_createInstance( const Reference< XComponentContext > & rContext)
throw( Exception )
{
SAL_INFO("writerperfect", "KeynoteImportFilter_createInstance");
return (cppu::OWeakObject *) new KeynoteImportFilter( rContext );
}
// XServiceInfo
OUString SAL_CALL KeynoteImportFilter::getImplementationName( )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::getImplementationName");
return KeynoteImportFilter_getImplementationName();
}
sal_Bool SAL_CALL KeynoteImportFilter::supportsService( const OUString &rServiceName )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::supportsService");
return KeynoteImportFilter_supportsService( rServiceName );
}
Sequence< OUString > SAL_CALL KeynoteImportFilter::getSupportedServiceNames( )
throw (RuntimeException)
{
SAL_INFO("writerperfect", "KeynoteImportFilter::getSupportedServiceNames");
return KeynoteImportFilter_getSupportedServiceNames();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#ifndef INCLUDED_WRITERPERFECT_SOURCE_IMPRESS_KEYNOTEIMPORTFILTER_HXX
#define INCLUDED_WRITERPERFECT_SOURCE_IMPRESS_KEYNOTEIMPORTFILTER_HXX
#include <com/sun/star/document/XFilter.hpp>
#include <com/sun/star/document/XImporter.hpp>
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
#include <com/sun/star/lang/XInitialization.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <cppuhelper/implbase5.hxx>
#include <stdio.h>
/* This component will be instantiated for both import or export. Whether it calls
* setSourceDocument or setTargetDocument determines which Impl function the filter
* member calls */
class KeynoteImportFilter : public cppu::WeakImplHelper5
<
com::sun::star::document::XFilter,
com::sun::star::document::XImporter,
com::sun::star::document::XExtendedFilterDetection,
com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo
>
{
protected:
// oo.org declares
::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > mxContext;
::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent > mxDoc;
OUString msFilterName;
::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XDocumentHandler > mxHandler;
public:
KeynoteImportFilter( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &rxContext)
: mxContext( rxContext ) {}
virtual ~KeynoteImportFilter() {}
// XFilter
virtual sal_Bool SAL_CALL filter( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aDescriptor )
throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL cancel( )
throw (::com::sun::star::uno::RuntimeException);
// XImporter
virtual void SAL_CALL setTargetDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
throw (::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException);
//XExtendedFilterDetection
virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
throw( com::sun::star::uno::RuntimeException );
// XInitialization
virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments )
throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
// XServiceInfo
virtual OUString SAL_CALL getImplementationName( )
throw (::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL supportsService( const OUString &ServiceName )
throw (::com::sun::star::uno::RuntimeException);
virtual ::com::sun::star::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( )
throw (::com::sun::star::uno::RuntimeException);
};
OUString KeynoteImportFilter_getImplementationName()
throw ( ::com::sun::star::uno::RuntimeException );
sal_Bool SAL_CALL KeynoteImportFilter_supportsService( const OUString &ServiceName )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Sequence< OUString > SAL_CALL KeynoteImportFilter_getSupportedServiceNames( )
throw ( ::com::sun::star::uno::RuntimeException );
::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
SAL_CALL KeynoteImportFilter_createInstance( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rContext)
throw ( ::com::sun::star::uno::Exception );
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<?xml version="1.0" encoding="UTF-8"?>
<!--
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
-->
<component loader="com.sun.star.loader.SharedLibrary" prefix="wpftimpress"
xmlns="http://openoffice.org/2010/uno-components">
<implementation name="org.libreoffice.comp.Impress.KeynoteImportFilter">
<service name="com.sun.star.document.ImportFilter"/>
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
</component>
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
/* genericfilter: mostly generic code for registering the filter */
#include "sal/config.h"
#include "cppuhelper/factory.hxx"
#include "cppuhelper/implementationentry.hxx"
#include "sal/types.h"
#include "KeynoteImportFilter.hxx"
namespace {
static cppu::ImplementationEntry const services[] = {
{ &KeynoteImportFilter_createInstance, &KeynoteImportFilter_getImplementationName,
&KeynoteImportFilter_getSupportedServiceNames,
&cppu::createSingleComponentFactory, 0, 0 },
{ 0, 0, 0, 0, 0, 0 } };
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL wpftimpress_component_getFactory(
char const * pImplName, void * pServiceManager, void * pRegistryKey)
{
return cppu::component_getFactoryHelper(
pImplName, pServiceManager, pRegistryKey, services);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment