Kaydet (Commit) f82f7bf3 authored tarafından Maxim Monastirsky's avatar Maxim Monastirsky

Introduce centralized detection for storage-based files

This will allow us to get rid of the duplicated code,
and simplify the type detectors.

Also this commit fixes fdo#46310 and fdo#74978.

Change-Id: I08e958ab10d05e1036cdc2bed5ce14bf73b6245c
Reviewed-on: https://gerrit.libreoffice.org/9221Reviewed-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
Tested-by: 's avatarMaxim Monastirsky <momonasmon@gmail.com>
üst b44ca2f4
......@@ -327,6 +327,7 @@ $(eval $(call gb_Helper_register_libraries_for_install,OOOLIBS,ooo, \
sot \
spell \
$(if $(ENABLE_HEADLESS),,spl) \
storagefd \
$(if $(DISABLE_SCRIPTING),,stringresource) \
svgio \
svl \
......
# -*- 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/.
#
#*************************************************************************
$(eval $(call gb_Library_Library,storagefd))
$(eval $(call gb_Library_set_componentfile,storagefd,filter/source/storagefilterdetect/storagefd))
$(eval $(call gb_Library_use_external,storagefd,boost_headers))
$(eval $(call gb_Library_use_sdk_api,storagefd))
$(eval $(call gb_Library_use_libraries,storagefd,\
comphelper \
cppuhelper \
cppu \
sal \
sfx \
tl \
utl \
$(gb_UWINAPI) \
))
$(eval $(call gb_Library_add_exception_objects,storagefd,\
filter/source/storagefilterdetect/fdcomp \
filter/source/storagefilterdetect/filterdetect \
))
# vim: set noet sw=4 ts=4:
......@@ -50,6 +50,7 @@ $(eval $(call gb_Module_add_targets,filter,\
Library_odfflatxml \
Library_pdffilter \
Library_placeware \
Library_storagefd \
Library_svgfilter \
Library_graphicfilter \
Library_t602filter \
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc8" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/scalc*</value></prop>
<prop oor:name="Extensions"><value>ods</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.spreadsheet</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc8_template" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>ots</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.spreadsheet-template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc_StarOffice_XML_Calc" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxc</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.calc</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="calc_StarOffice_XML_Calc_Template" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.calc.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>stc</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.calc.template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="chart8" oor:op="replace">
<prop oor:name="DetectService"/>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/schart*</value></prop>
<prop oor:name="Extensions"><value>odc</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.chart</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="chart_StarOffice_XML_Chart" oor:op="replace" oor:finalized="true" oor:mandatory="true">
<prop oor:name="DetectService"/>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxs</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.chart</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="draw8" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/sdraw*</value></prop>
<prop oor:name="Extensions"><value>odg</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.graphics</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="draw8_template" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>otg</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.graphics-template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="draw_StarOffice_XML_Draw" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxd</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.draw</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="draw_StarOffice_XML_Draw_Template" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>std</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.draw.template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="impress8" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/simpress*</value></prop>
<prop oor:name="Extensions"><value>odp</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.presentation</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="impress8_template" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>otp</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.presentation-template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="impress_StarOffice_XML_Impress" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxi</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.impress</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="impress_StarOffice_XML_Impress_Template" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.draw.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sti</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.impress.template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="math8" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.math.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/smath*</value></prop>
<prop oor:name="Extensions"><value>odf</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.formula</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="math_StarOffice_XML_Math" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.comp.math.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxm</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.math</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer8" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/swriter</value></prop>
<prop oor:name="Extensions"><value>odt</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.text</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer8_template" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>ott</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.text-template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer_StarOffice_XML_Writer" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxw</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.writer</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer_StarOffice_XML_Writer_Template" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>stw</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.writer.template</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer_globaldocument_StarOffice_XML_Writer_GlobalDocument" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>sxg</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.writer.global</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writer_web_StarOffice_XML_Writer_Web_Template" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>stw</value></prop>
<prop oor:name="MediaType"><value>application/vnd.sun.xml.writer.web</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writerglobal8" oor:op="replace" >
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"><value>private:factory/swriter/GlobalDocument*</value></prop>
<prop oor:name="Extensions"><value>odm</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.text-master</value></prop>
......
......@@ -16,7 +16,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
-->
<node oor:name="writerweb8_writer_template" oor:op="replace">
<prop oor:name="DetectService"><value>com.sun.star.text.FormatDetector</value></prop>
<prop oor:name="DetectService"><value>com.sun.star.comp.filters.StorageFilterDetect</value></prop>
<prop oor:name="URLPattern"/>
<prop oor:name="Extensions"><value>oth</value></prop>
<prop oor:name="MediaType"><value>application/vnd.oasis.opendocument.text-web</value></prop>
......
/* -*- 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/.
*/
#include <sal/config.h>
#include <cppuhelper/factory.hxx>
#include <cppuhelper/implementationentry.hxx>
#include <sal/types.h>
#include "filterdetect.hxx"
namespace {
static cppu::ImplementationEntry const services[] = {
{ &StorageFilterDetect_createInstance, &StorageFilterDetect_getImplementationName,
&StorageFilterDetect_getSupportedServiceNames,
&cppu::createSingleComponentFactory, 0, 0 },
{ 0, 0, 0, 0, 0, 0 }
};
}
extern "C" SAL_DLLPUBLIC_EXPORT void * SAL_CALL storagefd_component_getFactory(
char const * pImplName, void * pServiceManager, void * pRegistryKey)
{
return cppu::component_getFactoryHelper(
pImplName, pServiceManager, pRegistryKey, services);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- 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 .
*/
#ifndef INCLUDED_FILTER_SOURCE_STORAGEFILTERDETECT_FILTERDETECT_HXX
#define INCLUDED_FILTER_SOURCE_STORAGEFILTERDETECT_FILTERDETECT_HXX
#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 <cppuhelper/implbase3.hxx>
class StorageFilterDetect : public cppu::WeakImplHelper3<
com::sun::star::document::XExtendedFilterDetection,
com::sun::star::lang::XInitialization,
com::sun::star::lang::XServiceInfo>
{
com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext> mxCxt;
public:
StorageFilterDetect (const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& xCxt);
virtual ~StorageFilterDetect();
// XExtendedFilterDetection
virtual OUString SAL_CALL detect(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& rDescriptor)
throw( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
// 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, std::exception) SAL_OVERRIDE;
// XServiceInfo
virtual OUString SAL_CALL getImplementationName()
throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName)
throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
virtual com::sun::star::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
throw (com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
};
OUString StorageFilterDetect_getImplementationName();
sal_Bool StorageFilterDetect_supportsService(const OUString& ServiceName);
com::sun::star::uno::Sequence<OUString> StorageFilterDetect_getSupportedServiceNames();
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
StorageFilterDetect_createInstance(const com::sun::star::uno::Reference<com::sun::star::uno::XComponentContext>& rCxt);
#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" environment="@CPPU_ENV@"
prefix="storagefd" xmlns="http://openoffice.org/2010/uno-components">
<implementation name="com.sun.star.comp.filters.StorageFilterDetect">
<service name="com.sun.star.document.ExtendedTypeDetection"/>
</implementation>
</component>
......@@ -33,6 +33,7 @@ $(eval $(call gb_Rdb_add_components,services,\
filter/source/odfflatxml/odfflatxml \
filter/source/pdf/pdffilter \
filter/source/placeware/placeware \
filter/source/storagefilterdetect/storagefd \
filter/source/svg/svgfilter \
filter/source/t602/t602filter \
filter/source/textfilterdetect/textfd \
......
......@@ -82,6 +82,7 @@ gb_EXTRAMERGEDLIBS := \
$(if $(filter-out ANDROID IOS,$(OS)),scn) \
sd \
$(call gb_Helper_optional,DBCONNECTIVITY,sdbc2) \
storagefd \
spell \
svgfilter \
swd \
......
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