[Libreoffice-commits] core.git: writerfilter/source

Miklos Vajna vmiklos at collabora.co.uk
Mon Feb 23 03:39:43 PST 2015


 writerfilter/source/filter/WriterFilterDetection.cxx |  118 ++++++++++---------
 writerfilter/source/filter/WriterFilterDetection.hxx |   64 ----------
 2 files changed, 65 insertions(+), 117 deletions(-)

New commits:
commit daa20dcadfcfc7a8d16cddc7f5a08bf3e0a5c644
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Feb 23 12:38:51 2015 +0100

    writerfilter: clean up WriterFilterDetection
    
    Change-Id: I496fd710897c55b1185783e071077fa8d8509783

diff --git a/writerfilter/source/filter/WriterFilterDetection.cxx b/writerfilter/source/filter/WriterFilterDetection.cxx
index f7db967..c38126b 100644
--- a/writerfilter/source/filter/WriterFilterDetection.cxx
+++ b/writerfilter/source/filter/WriterFilterDetection.cxx
@@ -17,120 +17,132 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <com/sun/star/document/XExtendedFilterDetection.hpp>
+#include <com/sun/star/io/XInputStream.hpp>
+#include <com/sun/star/lang/XServiceInfo.hpp>
+#include <comphelper/storagehelper.hxx>
+#include <cppuhelper/implbase.hxx>
 #include <cppuhelper/implementationentry.hxx>
 #include <cppuhelper/supportsservice.hxx>
-#include <WriterFilterDetection.hxx>
-#include <comphelper/storagehelper.hxx>
-#include <com/sun/star/io/XInputStream.hpp>
-#include <osl/diagnose.h>
 #include <sot/storage.hxx>
 #include <unotools/ucbstreamhelper.hxx>
 
 using namespace ::com::sun::star;
 
-WriterFilterDetection::WriterFilterDetection(
-    const uno::Reference< uno::XComponentContext >& rxContext) :
-    m_xContext( rxContext )
+/// File format detection service for DOCX.
+class WriterFilterDetection : public cppu::WeakImplHelper
+    <
+    document::XExtendedFilterDetection,
+    lang::XServiceInfo
+    >
 {
-}
+    uno::Reference<uno::XComponentContext> m_xContext;
 
+public:
+    WriterFilterDetection(const uno::Reference<uno::XComponentContext>& rxContext);
+    virtual ~WriterFilterDetection();
 
-WriterFilterDetection::~WriterFilterDetection()
-{
-}
+    //XExtendedFilterDetection
+    virtual OUString SAL_CALL detect(uno::Sequence<beans::PropertyValue>& Descriptor) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+    // XServiceInfo
+    virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+    virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+};
 
+bool SAL_CALL WriterFilterDetection_supportsService(const OUString& ServiceName) throw (uno::RuntimeException);
 
-OUString WriterFilterDetection_getImplementationName () throw (uno::RuntimeException)
+uno::Sequence<OUString> SAL_CALL WriterFilterDetection_getSupportedServiceNames() throw (uno::RuntimeException);
+
+WriterFilterDetection::WriterFilterDetection(const uno::Reference<uno::XComponentContext>& rxContext)
+    : m_xContext(rxContext)
 {
-   return OUString ( "com.sun.star.comp.Writer.WriterFilterDetector"  );
 }
 
+WriterFilterDetection::~WriterFilterDetection()
+{
+}
 
-
-OUString WriterFilterDetection::detect( uno::Sequence< beans::PropertyValue >& rDescriptor )
-   throw( uno::RuntimeException, std::exception )
+OUString WriterFilterDetection::detect(uno::Sequence<beans::PropertyValue>& rDescriptor) throw (uno::RuntimeException, std::exception)
 {
     OUString sTypeName;
     bool bWord = false;
     sal_Int32 nPropertyCount = rDescriptor.getLength();
     const beans::PropertyValue* pValues = rDescriptor.getConstArray();
     OUString sURL;
-    uno::Reference < io::XStream > xStream;
-    uno::Reference < io::XInputStream > xInputStream;
-    for( sal_Int32 nProperty = 0; nProperty < nPropertyCount; ++nProperty )
+    uno::Reference<io::XStream> xStream;
+    uno::Reference<io::XInputStream> xInputStream;
+    for (sal_Int32 nProperty = 0; nProperty < nPropertyCount; ++nProperty)
     {
-        if ( pValues[nProperty].Name == "TypeName" )
+        if (pValues[nProperty].Name == "TypeName")
             rDescriptor[nProperty].Value >>= sTypeName;
-        else if ( pValues[nProperty].Name == "URL" )
+        else if (pValues[nProperty].Name == "URL")
             pValues[nProperty].Value >>= sURL;
-        else if ( pValues[nProperty].Name == "Stream" )
+        else if (pValues[nProperty].Name == "Stream")
             pValues[nProperty].Value >>= xStream;
-        else if ( pValues[nProperty].Name == "InputStream" )
+        else if (pValues[nProperty].Name == "InputStream")
             pValues[nProperty].Value >>= xInputStream;
     }
     try
     {
-        uno::Reference< embed::XStorage > xDocStorage;
-        if ( sURL == "private:stream" )
-            xDocStorage = comphelper::OStorageHelper::GetStorageFromInputStream( xInputStream );
+        uno::Reference<embed::XStorage> xDocStorage;
+        if (sURL == "private:stream")
+            xDocStorage = comphelper::OStorageHelper::GetStorageFromInputStream(xInputStream);
         else
-            xDocStorage = comphelper::OStorageHelper::GetStorageFromURL( sURL, embed::ElementModes::READ );
-        if( xDocStorage.is() )
+            xDocStorage = comphelper::OStorageHelper::GetStorageFromURL(sURL, embed::ElementModes::READ);
+        if (xDocStorage.is())
         {
-            uno::Sequence< OUString > aNames = xDocStorage->getElementNames();
+            uno::Sequence<OUString> aNames = xDocStorage->getElementNames();
             const OUString* pNames = aNames.getConstArray();
-            for(sal_Int32 nName = 0; nName < aNames.getLength(); ++nName)
+            for (sal_Int32 nName = 0; nName < aNames.getLength(); ++nName)
             {
-                if ( pNames[nName] == "word" )
+                if (pNames[nName] == "word")
                 {
                     bWord = true;
-                    if( sTypeName.isEmpty() )
+                    if (sTypeName.isEmpty())
                         sTypeName = "writer_MS_Word_2007";
                     break;
                 }
             }
         }
     }
-    catch(const uno::Exception&)
+    catch (const uno::Exception&)
     {
-        OSL_FAIL("exception while opening storage");
+        SAL_WARN("writerfilter", "exception while opening storage");
     }
-    if( !bWord )
+    if (!bWord)
         sTypeName.clear();
-   return sTypeName;
+    return sTypeName;
 }
 
-
-uno::Sequence< OUString > WriterFilterDetection_getSupportedServiceNames(  ) throw (uno::RuntimeException)
+uno::Sequence<OUString> WriterFilterDetection_getSupportedServiceNames() throw (uno::RuntimeException)
 {
-   uno::Sequence < OUString > aRet(1);
-   OUString* pArray = aRet.getArray();
-   pArray[0] = "com.sun.star.document.ExtendedTypeDetection";
-   return aRet;
+    uno::Sequence<OUString> aRet =
+    {
+        OUString("com.sun.star.document.ExtendedTypeDetection")
+    };
+    return aRet;
 }
 
-OUString WriterFilterDetection::getImplementationName(  ) throw (uno::RuntimeException, std::exception)
+OUString WriterFilterDetection::getImplementationName() throw (uno::RuntimeException, std::exception)
 {
-   return WriterFilterDetection_getImplementationName();
+    return OUString("com.sun.star.comp.Writer.WriterFilterDetector");
 }
 
-
-sal_Bool WriterFilterDetection::supportsService( const OUString& rServiceName ) throw (uno::RuntimeException, std::exception)
+sal_Bool WriterFilterDetection::supportsService(const OUString& rServiceName) throw (uno::RuntimeException, std::exception)
 {
-    return cppu::supportsService( this, rServiceName );
+    return cppu::supportsService(this, rServiceName);
 }
 
-
-uno::Sequence< OUString > WriterFilterDetection::getSupportedServiceNames(  ) throw (uno::RuntimeException, std::exception)
+uno::Sequence<OUString> WriterFilterDetection::getSupportedServiceNames() throw (uno::RuntimeException, std::exception)
 {
     return WriterFilterDetection_getSupportedServiceNames();
 }
 
-extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
-com_sun_star_comp_Writer_WriterFilterDetector_get_implementation( ::com::sun::star::uno::XComponentContext* component,
-        ::com::sun::star::uno::Sequence<css::uno::Any> const &)
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_comp_Writer_WriterFilterDetector_get_implementation(uno::XComponentContext* pComp, uno::Sequence<css::uno::Any> const&)
 {
-    return cppu::acquire(new WriterFilterDetection(component));
+    return cppu::acquire(new WriterFilterDetection(pComp));
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/filter/WriterFilterDetection.hxx b/writerfilter/source/filter/WriterFilterDetection.hxx
deleted file mode 100644
index 9b2ebac..0000000
--- a/writerfilter/source/filter/WriterFilterDetection.hxx
+++ /dev/null
@@ -1,64 +0,0 @@
-/* -*- 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_WRITERFILTER_SOURCE_FILTER_WRITERFILTERDETECTION_HXX
-#define INCLUDED_WRITERFILTER_SOURCE_FILTER_WRITERFILTERDETECTION_HXX
-
-#include <com/sun/star/document/XExtendedFilterDetection.hpp>
-#include <com/sun/star/lang/XServiceInfo.hpp>
-#include <cppuhelper/implbase2.hxx>
-
-/// File format detection service for DOC (unused) / DOCX.
-class WriterFilterDetection : public cppu::WeakImplHelper2
-<
-    com::sun::star::document::XExtendedFilterDetection,
-    com::sun::star::lang::XServiceInfo
->
-{
-    ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
-
-public:
-    WriterFilterDetection(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& rxContext);
-    virtual ~WriterFilterDetection();
-
-    //XExtendedFilterDetection
-    virtual OUString SAL_CALL detect( com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& Descriptor )
-        throw( 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 WriterFilterDetection_getImplementationName()
-    throw ( ::com::sun::star::uno::RuntimeException );
-
-bool SAL_CALL WriterFilterDetection_supportsService( const OUString& ServiceName )
-    throw ( ::com::sun::star::uno::RuntimeException );
-
-::com::sun::star::uno::Sequence< OUString > SAL_CALL WriterFilterDetection_getSupportedServiceNames(  )
-    throw ( ::com::sun::star::uno::RuntimeException );
-
-#endif
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list