LCOV - code coverage report
Current view: top level - sw/source/core/uibase/uno - SwXFilterOptions.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 3 72 4.2 %
Date: 2014-04-11 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             : 
      36             : using namespace ::com::sun::star;
      37             : using namespace ::com::sun::star::ui::dialogs;
      38             : using namespace ::com::sun::star::document;
      39             : using namespace ::com::sun::star::lang;
      40             : 
      41             : #define SWFILTEROPTIONSOBJ_IMPLNAME     "com.sun.star.comp.Writer.FilterOptionsDialog"
      42             : #define FILTER_OPTIONS_NAME             "FilterOptions"
      43             : 
      44           0 : SwXFilterOptions::SwXFilterOptions() :
      45           0 :     bExport( sal_False )
      46             : {
      47           0 : }
      48             : 
      49           0 : SwXFilterOptions::~SwXFilterOptions()
      50             : {
      51           0 : }
      52             : 
      53          39 : OUString  SwXFilterOptions::getImplementationName_Static()
      54             : {
      55          39 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
      56             : }
      57             : 
      58           0 : uno::Sequence< OUString> SwXFilterOptions::getSupportedServiceNames_Static()
      59             : {
      60           0 :     OUString sService("com.sun.star.ui.dialogs.FilterOptionsDialog");
      61           0 :     return uno::Sequence< OUString> (&sService, 1);
      62             : }
      63             : 
      64           0 : uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException, std::exception)
      65             : {
      66           0 :     uno::Sequence<beans::PropertyValue> aRet(1);
      67           0 :     beans::PropertyValue* pArray = aRet.getArray();
      68             : 
      69           0 :     pArray[0].Name = OUString( FILTER_OPTIONS_NAME );
      70           0 :     pArray[0].Value <<= sFilterOptions;
      71             : 
      72           0 :     return aRet;
      73             : }
      74             : 
      75           0 : void   SwXFilterOptions::setPropertyValues( const uno::Sequence<beans::PropertyValue >& aProps )
      76             :     throw (beans::UnknownPropertyException, beans::PropertyVetoException,
      77             :        IllegalArgumentException, WrappedTargetException, uno::RuntimeException, std::exception)
      78             : {
      79           0 :     const beans::PropertyValue* pPropArray = aProps.getConstArray();
      80           0 :     long nPropCount = aProps.getLength();
      81           0 :     for (long i = 0; i < nPropCount; i++)
      82             :     {
      83           0 :         const beans::PropertyValue& rProp = pPropArray[i];
      84           0 :         OUString aPropName = rProp.Name;
      85             : 
      86           0 :         if ( aPropName == UNO_NAME_FILTER_NAME )
      87           0 :             rProp.Value >>= sFilterName;
      88           0 :         else if ( aPropName == FILTER_OPTIONS_NAME )
      89           0 :             rProp.Value >>= sFilterOptions;
      90           0 :         else if ( aPropName == "InputStream" )
      91           0 :             rProp.Value >>= xInputStream;
      92           0 :     }
      93           0 : }
      94             : 
      95           0 : void   SwXFilterOptions::setTitle( const OUString& /*rTitle*/ )
      96             :     throw (uno::RuntimeException, std::exception)
      97             : {
      98           0 : }
      99             : 
     100           0 : sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException, std::exception)
     101             : {
     102           0 :     sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
     103             : 
     104           0 :     SvStream* pInStream = NULL;
     105           0 :     if ( xInputStream.is() )
     106           0 :         pInStream = utl::UcbStreamHelper::CreateStream( xInputStream );
     107             : 
     108           0 :     uno::Reference< XUnoTunnel > xTunnel(xModel, uno::UNO_QUERY);
     109           0 :     SwDocShell* pDocShell = 0;
     110           0 :     if(xTunnel.is())
     111             :     {
     112             :         SwXTextDocument* pXDoc = reinterpret_cast< SwXTextDocument * >(
     113           0 :                 sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething(SwXTextDocument::getUnoTunnelId())));
     114           0 :         pDocShell = pXDoc ? pXDoc->GetDocShell() : 0;
     115             :     }
     116           0 :     if(pDocShell)
     117             :     {
     118             : 
     119           0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     120             :         OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
     121             : 
     122             :         AbstractSwAsciiFilterDlg* pAsciiDlg = pFact->CreateSwAsciiFilterDlg(NULL, *pDocShell,
     123           0 :             pInStream);
     124             :         OSL_ENSURE(pAsciiDlg, "Dialogdiet fail!");
     125           0 :         if(RET_OK == pAsciiDlg->Execute())
     126             :         {
     127           0 :             SwAsciiOptions aOptions;
     128           0 :             pAsciiDlg->FillOptions( aOptions );
     129           0 :             aOptions.WriteUserData(sFilterOptions);
     130           0 :             nRet = ui::dialogs::ExecutableDialogResults::OK;
     131             :         }
     132           0 :         delete pAsciiDlg;
     133             :     }
     134             : 
     135           0 :     delete pInStream;
     136             : 
     137           0 :     return nRet;
     138             : }
     139             : 
     140           0 : void   SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
     141             :     throw (IllegalArgumentException, uno::RuntimeException, std::exception)
     142             : {
     143           0 :     bExport = sal_False;
     144           0 :     xModel = xDoc;
     145           0 : }
     146             : 
     147           0 : void   SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
     148             :         throw (IllegalArgumentException,uno::RuntimeException, std::exception)
     149             : {
     150           0 :     bExport = sal_True;
     151           0 :     xModel = xDoc;
     152           0 : }
     153             : 
     154           0 : OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException, std::exception)
     155             : {
     156           0 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
     157             : }
     158             : 
     159           0 : sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
     160             :     throw(uno::RuntimeException, std::exception)
     161             : {
     162           0 :     return cppu::supportsService(this, rServiceName);
     163             : }
     164             : 
     165           0 : uno::Sequence< OUString > SwXFilterOptions::getSupportedServiceNames()
     166             :                 throw(uno::RuntimeException, std::exception)
     167             : {
     168           0 :     return SwXFilterOptions::getSupportedServiceNames_Static();
     169             : }
     170             : 
     171           0 : uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
     172             :                         const uno::Reference<lang::XMultiServiceFactory>& )
     173             : {
     174           0 :     SolarMutexGuard aGuard;
     175           0 :     SwGlobals::ensure();
     176           0 :     return (::cppu::OWeakObject*) new SwXFilterOptions;
     177         111 : }
     178             : 
     179             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10