From a0b640bd1816bc464961c85eb2d1de405cd50d1c Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Thu, 24 May 2012 22:36:09 -0400 Subject: Initial skeleton code for plain text filter detection service. Right now it will always fail. Change-Id: I50011bbf7ce59c3b299d23e688dd1af87bcafeb6 --- filter/Module_filter.mk | 1 + filter/source/textfilterdetect/fdcomp.cxx | 72 ++++++++++++++ filter/source/textfilterdetect/filterdetect.cxx | 120 ++++++++++++++++++++++++ filter/source/textfilterdetect/filterdetect.hxx | 83 ++++++++++++++++ filter/source/textfilterdetect/textfd.component | 36 +++++++ 5 files changed, 312 insertions(+) create mode 100644 filter/source/textfilterdetect/fdcomp.cxx create mode 100644 filter/source/textfilterdetect/filterdetect.cxx create mode 100644 filter/source/textfilterdetect/filterdetect.hxx create mode 100644 filter/source/textfilterdetect/textfd.component (limited to 'filter') diff --git a/filter/Module_filter.mk b/filter/Module_filter.mk index 03f13e2379df..922d4f53e460 100644 --- a/filter/Module_filter.mk +++ b/filter/Module_filter.mk @@ -60,6 +60,7 @@ $(eval $(call gb_Module_add_targets,filter,\ Library_placeware \ Library_svgfilter \ Library_t602filter \ + Library_textfd \ Library_xmlfa \ Library_xmlfd \ Library_xsltdlg \ diff --git a/filter/source/textfilterdetect/fdcomp.cxx b/filter/source/textfilterdetect/fdcomp.cxx new file mode 100644 index 000000000000..6be78b323702 --- /dev/null +++ b/filter/source/textfilterdetect/fdcomp.cxx @@ -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 + * + * 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 + +#include +#include +#include + +#include + +#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 xFactory( + createSingleFactory( + reinterpret_cast(pServiceManager), + implName, + PlainTextFilterDetect_createInstance, PlainTextFilterDetect_getSupportedServiceNames())); + + if (xFactory.is()) + { + xFactory->acquire(); + pRet = xFactory.get(); + } + } + + return pRet; +} + +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/textfilterdetect/filterdetect.cxx b/filter/source/textfilterdetect/filterdetect.cxx new file mode 100644 index 000000000000..55bfd0a5b223 --- /dev/null +++ b/filter/source/textfilterdetect/filterdetect.cxx @@ -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 + * + * 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 + +using namespace ::com::sun::star; + +PlainTextFilterDetect::PlainTextFilterDetect(const uno::Reference &xMSF) : + mxMSF(xMSF) {} + +PlainTextFilterDetect::~PlainTextFilterDetect() {} + +rtl::OUString SAL_CALL PlainTextFilterDetect::detect(uno::Sequence& aArguments) throw (uno::RuntimeException) +{ + return rtl::OUString(); +} + +// XInitialization + +void SAL_CALL PlainTextFilterDetect::initialize(const uno::Sequence& aArguments) + throw (uno::Exception, uno::RuntimeException) +{ + uno::Sequence 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_TEXTENCODING_UTF8).getStr()); + } + else if (pValue[i].Name == "UserData") + { + fprintf(stdout, "PlainTextFilterDetect::initialize: user data = '%s'\n", + rtl::OUStringToOString(pValue[i].Value.get(), 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_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 PlainTextFilterDetect_getSupportedServiceNames() +{ + uno::Sequence 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 PlainTextFilterDetect_createInstance( + const uno::Reference & 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 SAL_CALL PlainTextFilterDetect::getSupportedServiceNames() + throw (uno::RuntimeException) +{ + return PlainTextFilterDetect_getSupportedServiceNames(); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/textfilterdetect/filterdetect.hxx b/filter/source/textfilterdetect/filterdetect.hxx new file mode 100644 index 000000000000..7f3ad158e2ae --- /dev/null +++ b/filter/source/textfilterdetect/filterdetect.hxx @@ -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 + * + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__ +#define __FILTER_TEXTFILTERDETECT_FILTERDETECT_HXX__ + +#include +#include +#include + +#include + +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 mxMSF; + +public: + + PlainTextFilterDetect (const com::sun::star::uno::Reference &xMSF); + virtual ~PlainTextFilterDetect(); + + // XExtendedFilterDetection + + virtual ::rtl::OUString SAL_CALL detect(com::sun::star::uno::Sequence& lDescriptor) + throw( com::sun::star::uno::RuntimeException ); + + // XInitialization + + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence& 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 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 PlainTextFilterDetect_getSupportedServiceNames(); + +com::sun::star::uno::Reference +PlainTextFilterDetect_createInstance(const com::sun::star::uno::Reference& rSMgr); + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/textfilterdetect/textfd.component b/filter/source/textfilterdetect/textfd.component new file mode 100644 index 000000000000..e1708e772e72 --- /dev/null +++ b/filter/source/textfilterdetect/textfd.component @@ -0,0 +1,36 @@ + + + + + + + + -- cgit