Initial skeleton code for plain text filter detection service.
Right now it will always fail. Change-Id: I50011bbf7ce59c3b299d23e688dd1af87bcafeb6
This commit is contained in:
parent
6e82a984a3
commit
a0b640bd18
@ -335,6 +335,7 @@ $(eval $(call gb_Helper_register_libraries,OOOLIBS, \
|
|||||||
swui \
|
swui \
|
||||||
t602filter \
|
t602filter \
|
||||||
textconversiondlgs \
|
textconversiondlgs \
|
||||||
|
textfd \
|
||||||
tk \
|
tk \
|
||||||
tl \
|
tl \
|
||||||
unordf \
|
unordf \
|
||||||
|
@ -60,6 +60,7 @@ $(eval $(call gb_Module_add_targets,filter,\
|
|||||||
Library_placeware \
|
Library_placeware \
|
||||||
Library_svgfilter \
|
Library_svgfilter \
|
||||||
Library_t602filter \
|
Library_t602filter \
|
||||||
|
Library_textfd \
|
||||||
Library_xmlfa \
|
Library_xmlfa \
|
||||||
Library_xmlfd \
|
Library_xmlfd \
|
||||||
Library_xsltdlg \
|
Library_xsltdlg \
|
||||||
|
72
filter/source/textfilterdetect/fdcomp.cxx
Normal file
72
filter/source/textfilterdetect/fdcomp.cxx
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License or as specified alternatively below. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* Major Contributor(s):
|
||||||
|
* Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
|
||||||
|
*
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* For minor contributions see the git repository.
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
||||||
|
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
||||||
|
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
||||||
|
* instead of those above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <osl/mutex.hxx>
|
||||||
|
#include <osl/thread.h>
|
||||||
|
#include <cppuhelper/factory.hxx>
|
||||||
|
|
||||||
|
#include <com/sun/star/lang/XSingleServiceFactory.hpp>
|
||||||
|
|
||||||
|
#include "filterdetect.hxx"
|
||||||
|
|
||||||
|
using namespace ::cppu;
|
||||||
|
using namespace com::sun::star;
|
||||||
|
using namespace ::com::sun::star::uno;
|
||||||
|
using namespace ::com::sun::star::lang;
|
||||||
|
using namespace ::com::sun::star::registry;
|
||||||
|
|
||||||
|
extern "C" {
|
||||||
|
|
||||||
|
SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory(
|
||||||
|
const sal_Char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
|
||||||
|
{
|
||||||
|
void* pRet = NULL;
|
||||||
|
rtl::OUString implName = rtl::OUString::createFromAscii(pImplName);
|
||||||
|
if (pServiceManager && implName == PlainTextFilterDetect_getImplementationName())
|
||||||
|
{
|
||||||
|
uno::Reference<lang::XSingleServiceFactory> xFactory(
|
||||||
|
createSingleFactory(
|
||||||
|
reinterpret_cast<lang::XMultiServiceFactory*>(pServiceManager),
|
||||||
|
implName,
|
||||||
|
PlainTextFilterDetect_createInstance, PlainTextFilterDetect_getSupportedServiceNames()));
|
||||||
|
|
||||||
|
if (xFactory.is())
|
||||||
|
{
|
||||||
|
xFactory->acquire();
|
||||||
|
pRet = xFactory.get();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
120
filter/source/textfilterdetect/filterdetect.cxx
Normal file
120
filter/source/textfilterdetect/filterdetect.cxx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*
|
||||||
|
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License or as specified alternatively below. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* Major Contributor(s):
|
||||||
|
* Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
|
||||||
|
*
|
||||||
|
* All Rights Reserved.
|
||||||
|
*
|
||||||
|
* For minor contributions see the git repository.
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
||||||
|
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
||||||
|
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
||||||
|
* instead of those above.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "filterdetect.hxx"
|
||||||
|
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
|
||||||
|
|
||||||
|
using namespace ::com::sun::star;
|
||||||
|
|
||||||
|
PlainTextFilterDetect::PlainTextFilterDetect(const uno::Reference<lang::XMultiServiceFactory> &xMSF) :
|
||||||
|
mxMSF(xMSF) {}
|
||||||
|
|
||||||
|
PlainTextFilterDetect::~PlainTextFilterDetect() {}
|
||||||
|
|
||||||
|
rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence<beans::PropertyValue>& aArguments) throw (uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return rtl::OUString();
|
||||||
|
}
|
||||||
|
|
||||||
|
// XInitialization
|
||||||
|
|
||||||
|
void SAL_CALL PlainTextFilterDetect::initialize(const uno::Sequence<uno::Any>& aArguments)
|
||||||
|
throw (uno::Exception, uno::RuntimeException)
|
||||||
|
{
|
||||||
|
uno::Sequence<beans::PropertyValue> aAnySeq;
|
||||||
|
sal_Int32 nLength = aArguments.getLength();
|
||||||
|
if (nLength && (aArguments[0] >>= aAnySeq))
|
||||||
|
{
|
||||||
|
const beans::PropertyValue * pValue = aAnySeq.getConstArray();
|
||||||
|
for (sal_Int32 i = 0, n = aAnySeq.getLength(); i < n; ++i)
|
||||||
|
{
|
||||||
|
if (pValue[i].Name == "Type")
|
||||||
|
{
|
||||||
|
fprintf(stdout, "PlainTextFilterDetect::initialize: type = '%s'\n",
|
||||||
|
rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
|
||||||
|
}
|
||||||
|
else if (pValue[i].Name == "UserData")
|
||||||
|
{
|
||||||
|
fprintf(stdout, "PlainTextFilterDetect::initialize: user data = '%s'\n",
|
||||||
|
rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
|
||||||
|
}
|
||||||
|
else if (pValue[i].Name == "TemplateName")
|
||||||
|
{
|
||||||
|
fprintf(stdout, "PlainTextFilterDetect::initialize: template name = '%s'\n",
|
||||||
|
rtl::OUStringToOString(pValue[i].Value.get<rtl::OUString>(), RTL_TEXTENCODING_UTF8).getStr());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rtl::OUString PlainTextFilterDetect_getImplementationName()
|
||||||
|
{
|
||||||
|
return rtl::OUString("com.sun.star.comp.filters.PlainTextFilterDetect");
|
||||||
|
}
|
||||||
|
|
||||||
|
sal_Bool PlainTextFilterDetect_supportsService(const rtl::OUString& ServiceName)
|
||||||
|
{
|
||||||
|
return ServiceName == "com.sun.star.document.ExtendedTypeDetection" ||
|
||||||
|
ServiceName == "com.sun.star.comp.filters.PlainTextFilterDetect";
|
||||||
|
}
|
||||||
|
|
||||||
|
uno::Sequence<rtl::OUString> PlainTextFilterDetect_getSupportedServiceNames()
|
||||||
|
{
|
||||||
|
uno::Sequence<rtl::OUString> aRet(2);
|
||||||
|
rtl::OUString* pArray = aRet.getArray();
|
||||||
|
pArray[0] = "com.sun.star.document.ExtendedTypeDetection";
|
||||||
|
pArray[1] = "com.sun.star.comp.filters.PlainTextFilterDetect";
|
||||||
|
return aRet;
|
||||||
|
}
|
||||||
|
|
||||||
|
uno::Reference<uno::XInterface> PlainTextFilterDetect_createInstance(
|
||||||
|
const uno::Reference<lang::XMultiServiceFactory> & rSMgr)
|
||||||
|
{
|
||||||
|
return (cppu::OWeakObject*) new PlainTextFilterDetect(rSMgr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// XServiceInfo
|
||||||
|
rtl::OUString SAL_CALL PlainTextFilterDetect::getImplementationName()
|
||||||
|
throw (uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return PlainTextFilterDetect_getImplementationName();
|
||||||
|
}
|
||||||
|
|
||||||
|
sal_Bool SAL_CALL PlainTextFilterDetect::supportsService(const rtl::OUString& rServiceName)
|
||||||
|
throw (uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return PlainTextFilterDetect_supportsService(rServiceName);
|
||||||
|
}
|
||||||
|
|
||||||
|
uno::Sequence<rtl::OUString> SAL_CALL PlainTextFilterDetect::getSupportedServiceNames()
|
||||||
|
throw (uno::RuntimeException)
|
||||||
|
{
|
||||||
|
return PlainTextFilterDetect_getSupportedServiceNames();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
83
filter/source/textfilterdetect/filterdetect.hxx
Normal file
83
filter/source/textfilterdetect/filterdetect.hxx
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||||
|
/*************************************************************************
|
||||||
|
*
|
||||||
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
|
*
|
||||||
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
||||||
|
*
|
||||||
|
* OpenOffice.org - a multi-platform office productivity suite
|
||||||
|
*
|
||||||
|
* This file is part of OpenOffice.org.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License version 3
|
||||||
|
* only, as published by the Free Software Foundation.
|
||||||
|
*
|
||||||
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License version 3 for more details
|
||||||
|
* (a copy is included in the LICENSE file that accompanied this code).
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* version 3 along with OpenOffice.org. If not, see
|
||||||
|
* <http://www.openoffice.org/license.html>
|
||||||
|
* for a copy of the LGPLv3 License.
|
||||||
|
*
|
||||||
|
************************************************************************/
|
||||||
|
|
||||||
|
#ifndef __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__
|
||||||
|
#define __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__
|
||||||
|
|
||||||
|
#include <com/sun/star/document/XExtendedFilterDetection.hpp>
|
||||||
|
#include <com/sun/star/lang/XInitialization.hpp>
|
||||||
|
#include <com/sun/star/lang/XServiceInfo.hpp>
|
||||||
|
|
||||||
|
#include <cppuhelper/implbase3.hxx>
|
||||||
|
|
||||||
|
class PlainTextFilterDetect : 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::lang::XMultiServiceFactory> mxMSF;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
PlainTextFilterDetect (const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory> &xMSF);
|
||||||
|
virtual ~PlainTextFilterDetect();
|
||||||
|
|
||||||
|
// XExtendedFilterDetection
|
||||||
|
|
||||||
|
virtual ::rtl::OUString SAL_CALL detect(com::sun::star::uno::Sequence<com::sun::star::beans::PropertyValue>& lDescriptor)
|
||||||
|
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 ::rtl::OUString SAL_CALL getImplementationName()
|
||||||
|
throw (com::sun::star::uno::RuntimeException);
|
||||||
|
|
||||||
|
virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
|
||||||
|
throw (com::sun::star::uno::RuntimeException);
|
||||||
|
|
||||||
|
virtual com::sun::star::uno::Sequence<rtl::OUString> SAL_CALL getSupportedServiceNames()
|
||||||
|
throw (com::sun::star::uno::RuntimeException);
|
||||||
|
};
|
||||||
|
|
||||||
|
rtl::OUString PlainTextFilterDetect_getImplementationName();
|
||||||
|
|
||||||
|
sal_Bool PlainTextFilterDetect_supportsService(const rtl::OUString& ServiceName);
|
||||||
|
|
||||||
|
com::sun::star::uno::Sequence<rtl::OUString> PlainTextFilterDetect_getSupportedServiceNames();
|
||||||
|
|
||||||
|
com::sun::star::uno::Reference<com::sun::star::uno::XInterface>
|
||||||
|
PlainTextFilterDetect_createInstance(const com::sun::star::uno::Reference<com::sun::star::lang::XMultiServiceFactory>& rSMgr);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
36
filter/source/textfilterdetect/textfd.component
Normal file
36
filter/source/textfilterdetect/textfd.component
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!--***********************************************************************
|
||||||
|
* Version: MPL 1.1 / GPLv3+ / LGPLv3+
|
||||||
|
*
|
||||||
|
* The contents of this file are subject to the Mozilla Public License Version
|
||||||
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License or as specified alternatively below. You may obtain a copy of
|
||||||
|
* the License at http://www.mozilla.org/MPL/
|
||||||
|
*
|
||||||
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||||
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||||
|
* for the specific language governing rights and limitations under the
|
||||||
|
* License.
|
||||||
|
*
|
||||||
|
* The Initial Developer of the Original Code is
|
||||||
|
* Kohei Yoshida <kohei.yoshida@suse.com> (Initial Developer)
|
||||||
|
* Portions created by the Initial Developer are Copyright (C) 2011 the
|
||||||
|
* Initial Developer. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Major Contributor(s):
|
||||||
|
*
|
||||||
|
* For minor contributions see the git repository.
|
||||||
|
*
|
||||||
|
* Alternatively, the contents of this file may be used under the terms of
|
||||||
|
* either the GNU General Public License Version 3 or later (the "GPLv3+"), or
|
||||||
|
* the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
|
||||||
|
* in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
|
||||||
|
* instead of those above.
|
||||||
|
**************************************************************************-->
|
||||||
|
|
||||||
|
<component loader="com.sun.star.loader.SharedLibrary"
|
||||||
|
xmlns="http://openoffice.org/2010/uno-components">
|
||||||
|
<implementation name="com.sun.star.comp.filters.PlainTextFilterDetect">
|
||||||
|
<service name="com.sun.star.document.ExtendedTypeDetection"/>
|
||||||
|
</implementation>
|
||||||
|
</component>
|
Loading…
x
Reference in New Issue
Block a user