LCOV - code coverage report
Current view: top level - sd/source/filter/html - HtmlOptionsDialog.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 65 1.5 %
Date: 2015-06-13 12:38:46 Functions: 2 17 11.8 %
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 <osl/file.hxx>
      21             : #include <osl/module.hxx>
      22             : #include <com/sun/star/frame/XModel.hpp>
      23             : #include <com/sun/star/document/XViewDataSupplier.hpp>
      24             : #include <com/sun/star/container/XIndexAccess.hpp>
      25             : #include <com/sun/star/lang/XMultiServiceFactory.hpp>
      26             : #include <com/sun/star/lang/XServiceInfo.hpp>
      27             : #include <com/sun/star/uno/Sequence.h>
      28             : #include <com/sun/star/uno/Any.h>
      29             : #include <com/sun/star/lang/XInitialization.hpp>
      30             : #include <com/sun/star/beans/XPropertyAccess.hpp>
      31             : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      32             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      33             : #include <com/sun/star/document/XExporter.hpp>
      34             : #include <cppuhelper/implbase5.hxx>
      35             : #include <cppuhelper/supportsservice.hxx>
      36             : #include <vcl/svapp.hxx>
      37             : 
      38             : #include <facreg.hxx>
      39             : 
      40             : using namespace com::sun::star::uno;
      41             : using namespace com::sun::star::lang;
      42             : using namespace com::sun::star::document;
      43             : using namespace com::sun::star::beans;
      44             : using namespace com::sun::star::container;
      45             : using namespace com::sun::star::frame;
      46             : using namespace com::sun::star::ui::dialogs;
      47             : 
      48             : #include "pres.hxx"
      49             : #include "sdabstdlg.hxx"
      50             : #include <boost/scoped_ptr.hpp>
      51             : 
      52             : class SdHtmlOptionsDialog : public cppu::WeakImplHelper5
      53             : <
      54             :     XExporter,
      55             :     XExecutableDialog,
      56             :     XPropertyAccess,
      57             :     XInitialization,
      58             :     XServiceInfo
      59             : >
      60             : {
      61             :     Sequence< PropertyValue > maMediaDescriptor;
      62             :     Sequence< PropertyValue > maFilterDataSequence;
      63             :     OUString aDialogTitle;
      64             :     DocumentType meDocType;
      65             : 
      66             : public:
      67             : 
      68             :     SdHtmlOptionsDialog();
      69             :     virtual ~SdHtmlOptionsDialog();
      70             : 
      71             :     // XInterface
      72             :     virtual void SAL_CALL acquire() throw() SAL_OVERRIDE;
      73             :     virtual void SAL_CALL release() throw() SAL_OVERRIDE;
      74             : 
      75             :     // XInitialization
      76             :     virtual void SAL_CALL initialize( const Sequence< Any > & aArguments ) throw ( Exception, RuntimeException, std::exception ) SAL_OVERRIDE;
      77             : 
      78             :     // XServiceInfo
      79             :     virtual OUString SAL_CALL getImplementationName() throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
      80             :     virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
      81             :     virtual Sequence< OUString > SAL_CALL getSupportedServiceNames() throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
      82             : 
      83             :     // XPropertyAccess
      84             :     virtual Sequence< PropertyValue > SAL_CALL getPropertyValues() throw ( RuntimeException, std::exception ) SAL_OVERRIDE;
      85             :     virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > & aProps )
      86             :         throw ( ::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException,
      87             :                 ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException,
      88             :                 ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      89             : 
      90             :     // XExecuteDialog
      91             :     virtual sal_Int16 SAL_CALL execute()
      92             :         throw ( com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      93             :     virtual void SAL_CALL setTitle( const OUString& aTitle )
      94             :         throw ( ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      95             : 
      96             :     // XExporter
      97             :     virtual void SAL_CALL setSourceDocument( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& xDoc )
      98             :         throw ( ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::uno::RuntimeException, std::exception ) SAL_OVERRIDE;
      99             : 
     100             : };
     101             : 
     102             : // - SdHtmlOptionsDialog -
     103           0 : SdHtmlOptionsDialog::SdHtmlOptionsDialog() :
     104           0 :     meDocType   ( DOCUMENT_TYPE_DRAW )
     105             : {
     106           0 : }
     107             : 
     108           0 : SdHtmlOptionsDialog::~SdHtmlOptionsDialog()
     109             : {
     110           0 : }
     111             : 
     112           0 : void SAL_CALL SdHtmlOptionsDialog::acquire() throw()
     113             : {
     114           0 :     OWeakObject::acquire();
     115           0 : }
     116             : 
     117           0 : void SAL_CALL SdHtmlOptionsDialog::release() throw()
     118             : {
     119           0 :     OWeakObject::release();
     120           0 : }
     121             : 
     122             : // XInitialization
     123           0 : void SAL_CALL SdHtmlOptionsDialog::initialize( const Sequence< Any > & )
     124             :     throw ( Exception, RuntimeException, std::exception )
     125             : {
     126           0 : }
     127             : 
     128             : // XServiceInfo
     129           0 : OUString SAL_CALL SdHtmlOptionsDialog::getImplementationName()
     130             :     throw( RuntimeException, std::exception )
     131             : {
     132           0 :     return OUString( "com.sun.star.comp.draw.SdHtmlOptionsDialog" );
     133             : }
     134             : 
     135           0 : sal_Bool SAL_CALL SdHtmlOptionsDialog::supportsService( const OUString& rServiceName )
     136             :     throw( RuntimeException, std::exception )
     137             : {
     138           0 :     return cppu::supportsService(this, rServiceName);
     139             : }
     140             : 
     141           0 : Sequence< OUString > SAL_CALL SdHtmlOptionsDialog::getSupportedServiceNames()
     142             :     throw ( RuntimeException, std::exception )
     143             : {
     144           0 :     Sequence< OUString > aRet(1);
     145           0 :     aRet[0] = "com.sun.star.ui.dialog.FilterOptionsDialog";
     146           0 :     return aRet;
     147             : }
     148             : 
     149             : // XPropertyAccess
     150           0 : Sequence< PropertyValue > SdHtmlOptionsDialog::getPropertyValues()
     151             :         throw ( RuntimeException, std::exception )
     152             : {
     153             :     sal_Int32 i, nCount;
     154           0 :     for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
     155             :     {
     156           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
     157           0 :             break;
     158             :     }
     159           0 :     if ( i == nCount )
     160           0 :         maMediaDescriptor.realloc( ++nCount );
     161             : 
     162             :     // the "FilterData" Property is an Any that will contain our PropertySequence of Values
     163           0 :     maMediaDescriptor[ i ].Name = "FilterData";
     164           0 :     maMediaDescriptor[ i ].Value <<= maFilterDataSequence;
     165           0 :     return maMediaDescriptor;
     166             : }
     167             : 
     168           0 : void SdHtmlOptionsDialog::setPropertyValues( const Sequence< PropertyValue > & aProps )
     169             :         throw ( UnknownPropertyException, PropertyVetoException,
     170             :                 IllegalArgumentException, WrappedTargetException,
     171             :                 RuntimeException, std::exception )
     172             : {
     173           0 :     maMediaDescriptor = aProps;
     174             : 
     175             :     sal_Int32 i, nCount;
     176           0 :     for ( i = 0, nCount = maMediaDescriptor.getLength(); i < nCount; i++ )
     177             :     {
     178           0 :         if ( maMediaDescriptor[ i ].Name == "FilterData" )
     179             :         {
     180           0 :             maMediaDescriptor[ i ].Value >>= maFilterDataSequence;
     181           0 :             break;
     182             :         }
     183             :     }
     184           0 : }
     185             : 
     186             : // XExecutableDialog
     187           0 : void SdHtmlOptionsDialog::setTitle( const OUString& aTitle )
     188             :     throw ( RuntimeException, std::exception )
     189             : {
     190           0 :     aDialogTitle = aTitle;
     191           0 : }
     192             : 
     193           0 : sal_Int16 SdHtmlOptionsDialog::execute()
     194             :     throw ( RuntimeException, std::exception )
     195             : {
     196           0 :     sal_Int16 nRet = ExecutableDialogResults::CANCEL;
     197             : 
     198           0 :     SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
     199           0 :     if( pFact )
     200             :     {
     201           0 :         boost::scoped_ptr<AbstractSdPublishingDlg> pDlg(pFact->CreateSdPublishingDlg( Application::GetDefDialogParent(), meDocType ));
     202           0 :         if( pDlg )
     203             :         {
     204           0 :             if( pDlg->Execute() )
     205             :             {
     206           0 :                 pDlg->GetParameterSequence( maFilterDataSequence );
     207           0 :                 nRet = ExecutableDialogResults::OK;
     208             :             }
     209             :             else
     210             :             {
     211           0 :                 nRet = ExecutableDialogResults::CANCEL;
     212             :             }
     213           0 :         }
     214             :     }
     215           0 :     return nRet;
     216             : }
     217             : 
     218             : // XEmporter
     219           0 : void SdHtmlOptionsDialog::setSourceDocument( const Reference< XComponent >& xDoc )
     220             :         throw ( IllegalArgumentException, RuntimeException, std::exception )
     221             : {
     222             :     // try to set the corresponding metric unit
     223           0 :     Reference< XServiceInfo > xServiceInfo(xDoc, UNO_QUERY);
     224           0 :     if ( xServiceInfo.is() )
     225             :     {
     226           0 :         if ( xServiceInfo->supportsService( "com.sun.star.presentation.PresentationDocument" ) )
     227             :         {
     228           0 :             meDocType = DOCUMENT_TYPE_IMPRESS;
     229           0 :             return;
     230             :         }
     231           0 :         else if ( xServiceInfo->supportsService( "com.sun.star.drawing.DrawingDocument" ) )
     232             :         {
     233           0 :             meDocType = DOCUMENT_TYPE_DRAW;
     234           0 :             return;
     235             :         }
     236             :     }
     237           0 :     throw IllegalArgumentException();
     238             : }
     239             : 
     240             : 
     241             : extern "C" SAL_DLLPUBLIC_EXPORT ::com::sun::star::uno::XInterface* SAL_CALL
     242           0 : com_sun_star_comp_draw_SdHtmlOptionsDialog_get_implementation(::com::sun::star::uno::XComponentContext*,
     243             :                                                               ::com::sun::star::uno::Sequence<css::uno::Any> const &)
     244             : {
     245           0 :     return cppu::acquire(new SdHtmlOptionsDialog());
     246          66 : }
     247             : 
     248             : 
     249             : 
     250             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11