LCOV - code coverage report
Current view: top level - sw/source/uibase/uno - SwXFilterOptions.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 3 71 4.2 %
Date: 2014-11-03 Functions: 3 17 17.6 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include <SwXFilterOptions.hxx>
      21             : #include <shellio.hxx>
      22             : #include <swdll.hxx>
      23             : #include <unoprnms.hxx>
      24             : #include <osl/mutex.hxx>
      25             : #include <vcl/svapp.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <com/sun/star/lang/XUnoTunnel.hpp>
      28             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      29             : #include <cppuhelper/supportsservice.hxx>
      30             : #include <unotools/ucbstreamhelper.hxx>
      31             : #include <unotxdoc.hxx>
      32             : 
      33             : #include "swabstdlg.hxx"
      34             : #include "dialog.hrc"
      35             : #include <boost/scoped_ptr.hpp>
      36             : 
      37             : using namespace ::com::sun::star;
      38             : using namespace ::com::sun::star::ui::dialogs;
      39             : using namespace ::com::sun::star::document;
      40             : using namespace ::com::sun::star::lang;
      41             : 
      42             : #define SWFILTEROPTIONSOBJ_IMPLNAME     "com.sun.star.comp.Writer.FilterOptionsDialog"
      43             : #define FILTER_OPTIONS_NAME             "FilterOptions"
      44             : 
      45           0 : SwXFilterOptions::SwXFilterOptions() :
      46           0 :     bExport( false )
      47             : {
      48           0 : }
      49             : 
      50           0 : SwXFilterOptions::~SwXFilterOptions()
      51             : {
      52           0 : }
      53             : 
      54          92 : OUString  SwXFilterOptions::getImplementationName_Static()
      55             : {
      56          92 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
      57             : }
      58             : 
      59           0 : uno::Sequence< OUString> SwXFilterOptions::getSupportedServiceNames_Static()
      60             : {
      61           0 :     OUString sService("com.sun.star.ui.dialogs.FilterOptionsDialog");
      62           0 :     return uno::Sequence< OUString> (&sService, 1);
      63             : }
      64             : 
      65           0 : uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException, std::exception)
      66             : {
      67           0 :     uno::Sequence<beans::PropertyValue> aRet(1);
      68           0 :     beans::PropertyValue* pArray = aRet.getArray();
      69             : 
      70           0 :     pArray[0].Name = OUString( FILTER_OPTIONS_NAME );
      71           0 :     pArray[0].Value <<= sFilterOptions;
      72             : 
      73           0 :     return aRet;
      74             : }
      75             : 
      76           0 : void   SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
      77             :     throw (beans::UnknownPropertyException, beans::PropertyVetoException,
      78             :        IllegalArgumentException, WrappedTargetException, uno::RuntimeException, std::exception)
      79             : {
      80           0 :     const beans::PropertyValue* pPropArray = aProps.getConstArray();
      81           0 :     long nPropCount = aProps.getLength();
      82           0 :     for (long i = 0; i < nPropCount; i++)
      83             :     {
      84           0 :         const beans::PropertyValue& rProp = pPropArray[i];
      85           0 :         OUString aPropName = rProp.Name;
      86             : 
      87           0 :         if ( aPropName == UNO_NAME_FILTER_NAME )
      88           0 :             rProp.Value >>= sFilterName;
      89           0 :         else if ( aPropName == FILTER_OPTIONS_NAME )
      90           0 :             rProp.Value >>= sFilterOptions;
      91           0 :         else if ( aPropName == "InputStream" )
      92           0 :             rProp.Value >>= xInputStream;
      93           0 :     }
      94           0 : }
      95             : 
      96           0 : void   SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
      97             :     throw (uno::RuntimeException, std::exception)
      98             : {
      99           0 : }
     100             : 
     101           0 : sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException, std::exception)
     102             : {
     103           0 :     sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
     104             : 
     105           0 :     boost::scoped_ptr<SvStream> pInStream;
     106           0 :     if ( xInputStream.is() )
     107           0 :         pInStream.reset(utl::UcbStreamHelper::CreateStream( xInputStream ));
     108             : 
     109           0 :     uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
     110           0 :     SwDocShell* pDocShell = 0;
     111           0 :     if(xTunnel.is())
     112             :     {
     113             :         SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
     114           0 :                 sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
     115           0 :         pDocShell = pXDoc ? pXDoc->GetDocShell() : 0;
     116             :     }
     117           0 :     if(pDocShell)
     118             :     {
     119             : 
     120           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     121             :         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     122             : 
     123             :         boost::scoped_ptr<AbstractSwAsciiFilterDlg> pAsciiDlg(pFact->CreateSwAsciiFilterDlg(NULL, *pDocShell,
     124           0 :             pInStream.get()));
     125             :         OSL_ENSURE(pAsciiDlg, "Dialog creation failed!");
     126           0 :         if(RET_OK == pAsciiDlg->Execute())
     127             :         {
     128           0 :             SwAsciiOptions aOptions;
     129           0 :             pAsciiDlg->FillOptions( aOptions );
     130           0 :             aOptions.WriteUserData(sFilterOptions);
     131           0 :             nRet = ui::dialogs::ExecutableDialogResults::OK;
     132           0 :         }
     133             :     }
     134             : 
     135           0 :     return nRet;
     136             : }
     137             : 
     138           0 : void   SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
     139             :     throw (IllegalArgumentException, uno::RuntimeException, std::exception)
     140             : {
     141           0 :     bExport = false;
     142           0 :     xModel = xDoc;
     143           0 : }
     144             : 
     145           0 : void   SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
     146             :         throw (IllegalArgumentException,uno::RuntimeException, std::exception)
     147             : {
     148           0 :     bExport = true;
     149           0 :     xModel = xDoc;
     150           0 : }
     151             : 
     152           0 : OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException, std::exception)
     153             : {
     154           0 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
     155             : }
     156             : 
     157           0 : sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
     158             :     throw(uno::RuntimeException, std::exception)
     159             : {
     160           0 :     return cppu::supportsService(this, rServiceName);
     161             : }
     162             : 
     163           0 : uno::Sequence< OUString > SwXFilterOptions::getSupportedServiceNames()
     164             :                 throw(uno::RuntimeException, std::exception)
     165             : {
     166           0 :     return SwXFilterOptions::getSupportedServiceNames_Static();
     167             : }
     168             : 
     169           0 : uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
     170             :                         const uno::Reference<lang::XMultiServiceFactory>& )
     171             : {
     172           0 :     SolarMutexGuard aGuard;
     173           0 :     SwGlobals::ensure();
     174           0 :     return (::cppu::OWeakObject*) new SwXFilterOptions;
     175         270 : }
     176             : 
     177             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10