LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/uno - SwXFilterOptions.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 3 74 4.1 %
Date: 2013-07-09 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 <unotools/ucbstreamhelper.hxx>
      30             : #include <unotxdoc.hxx>
      31             : 
      32             : #include "swabstdlg.hxx"
      33             : #include "dialog.hrc"
      34             : 
      35             : using namespace ::com::sun::star;
      36             : using namespace ::com::sun::star::ui::dialogs;
      37             : using namespace ::com::sun::star::document;
      38             : using namespace ::com::sun::star::lang;
      39             : 
      40             : #define SWFILTEROPTIONSOBJ_SERVICE      "com.sun.star.ui.dialogs.FilterOptionsDialog"
      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          34 : OUString  SwXFilterOptions::getImplementationName_Static()
      54             : {
      55          34 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
      56             : }
      57             : 
      58           0 : uno::Sequence< OUString> SwXFilterOptions::getSupportedServiceNames_Static()
      59             : {
      60           0 :     OUString sService(SWFILTEROPTIONSOBJ_SERVICE);
      61           0 :     return uno::Sequence< OUString> (&sService, 1);
      62             : }
      63             : 
      64           0 : uno::Sequence< beans::PropertyValue > SwXFilterOptions::getPropertyValues() throw (uno::RuntimeException)
      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)
      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.equalsAscii( SW_PROP_NAME_STR(UNO_NAME_FILTER_NAME) ) )
      87           0 :             rProp.Value >>= sFilterName;
      88           0 :         else if ( aPropName == OUString(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)
      97             : {
      98           0 : }
      99             : 
     100           0 : sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException)
     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 :             String sTmp;
     130           0 :             aOptions.WriteUserData(sTmp);
     131           0 :             sFilterOptions = sTmp;
     132           0 :             nRet = ui::dialogs::ExecutableDialogResults::OK;
     133             :         }
     134           0 :         delete pAsciiDlg;
     135             :     }
     136             : 
     137           0 :     delete pInStream;
     138             : 
     139           0 :     return nRet;
     140             : }
     141             : 
     142           0 : void   SwXFilterOptions::setTargetDocument( const uno::Reference< XComponent >& xDoc )
     143             :     throw (IllegalArgumentException, uno::RuntimeException)
     144             : {
     145           0 :     bExport = sal_False;
     146           0 :     xModel = xDoc;
     147           0 : }
     148             : 
     149           0 : void   SwXFilterOptions::setSourceDocument( const uno::Reference<XComponent >& xDoc )
     150             :         throw (IllegalArgumentException,uno::RuntimeException)
     151             : {
     152           0 :     bExport = sal_True;
     153           0 :     xModel = xDoc;
     154           0 : }
     155             : 
     156           0 : OUString SwXFilterOptions::getImplementationName() throw(uno::RuntimeException)
     157             : {
     158           0 :     return OUString(SWFILTEROPTIONSOBJ_IMPLNAME);
     159             : }
     160             : 
     161           0 : sal_Bool SwXFilterOptions::supportsService( const OUString& rServiceName )
     162             :     throw(uno::RuntimeException)
     163             : {
     164           0 :     return rServiceName == OUString(SWFILTEROPTIONSOBJ_SERVICE);
     165             : }
     166             : 
     167           0 : uno::Sequence< OUString > SwXFilterOptions::getSupportedServiceNames()
     168             :                 throw(uno::RuntimeException)
     169             : {
     170           0 :     return SwXFilterOptions::getSupportedServiceNames_Static();
     171             : }
     172             : 
     173           0 : uno::Reference<uno::XInterface> SAL_CALL SwXFilterOptions_createInstance(
     174             :                         const uno::Reference<lang::XMultiServiceFactory>& )
     175             : {
     176           0 :     SolarMutexGuard aGuard;
     177           0 :     SwGlobals::ensure();
     178           0 :     return (::cppu::OWeakObject*) new SwXFilterOptions;
     179          99 : }
     180             : 
     181             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10