LCOV - code coverage report
Current view: top level - svx/source/unodialogs/textconversiondlgs - chinese_translation_unodialog.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 109 0.0 %
Date: 2015-06-13 12:38:46 Functions: 0 24 0.0 %
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             : 
      21             : #include "chinese_translation_unodialog.hxx"
      22             : #include "chinese_translationdialog.hxx"
      23             : #include <osl/mutex.hxx>
      24             : #include <vcl/svapp.hxx>
      25             : #include <toolkit/awt/vclxwindow.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <cppuhelper/supportsservice.hxx>
      28             : #include <cppuhelper/typeprovider.hxx>
      29             : #include <com/sun/star/beans/PropertyValue.hpp>
      30             : #include <com/sun/star/frame/XDesktop.hpp>
      31             : #include <com/sun/star/frame/XDispatch.hpp>
      32             : #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
      33             : 
      34             : namespace textconversiondlgs
      35             : {
      36             : using namespace ::com::sun::star;
      37             : 
      38           0 : ChineseTranslation_UnoDialog::ChineseTranslation_UnoDialog( const uno::Reference< uno::XComponentContext >& xContext )
      39             :                     : m_xCC( xContext )
      40             :                     , m_xParentWindow( 0 )
      41             :                     , m_pDialog( 0 )
      42             :                     , m_bDisposed(false)
      43             :                     , m_bInDispose(false)
      44             :                     , m_aContainerMutex()
      45           0 :                     , m_aDisposeEventListeners(m_aContainerMutex)
      46             : {
      47           0 : }
      48             : 
      49           0 : ChineseTranslation_UnoDialog::~ChineseTranslation_UnoDialog()
      50             : {
      51           0 :     SolarMutexGuard aSolarGuard;
      52           0 :     impl_DeleteDialog();
      53           0 : }
      54             : 
      55           0 : void ChineseTranslation_UnoDialog::impl_DeleteDialog()
      56             : {
      57           0 :     if( m_pDialog )
      58             :     {
      59           0 :         if(m_pDialog->IsInExecute())
      60           0 :             m_pDialog->EndDialog(RET_CANCEL);
      61           0 :         m_pDialog.disposeAndClear();
      62             :     }
      63           0 : }
      64             : 
      65             : // lang::XServiceInfo
      66           0 : OUString SAL_CALL ChineseTranslation_UnoDialog::getImplementationName() throw( uno::RuntimeException, std::exception )
      67             : {
      68           0 :     return getImplementationName_Static();
      69             : }
      70             : 
      71           0 : OUString ChineseTranslation_UnoDialog::getImplementationName_Static()
      72             : {
      73           0 :     return OUString("com.sun.star.comp.linguistic2.ChineseTranslationDialog");
      74             : }
      75             : 
      76           0 : sal_Bool SAL_CALL ChineseTranslation_UnoDialog::supportsService( const OUString& ServiceName ) throw( uno::RuntimeException, std::exception )
      77             : {
      78           0 :     return cppu::supportsService(this, ServiceName);
      79             : }
      80             : 
      81           0 : uno::Sequence< OUString > SAL_CALL ChineseTranslation_UnoDialog::getSupportedServiceNames() throw( uno::RuntimeException, std::exception )
      82             : {
      83           0 :     return getSupportedServiceNames_Static();
      84             : }
      85             : 
      86           0 : uno::Sequence< OUString > ChineseTranslation_UnoDialog::getSupportedServiceNames_Static()
      87             : {
      88           0 :     uno::Sequence< OUString > aSNS( 1 );
      89           0 :     aSNS[ 0 ] = "com.sun.star.linguistic2.ChineseTranslationDialog";
      90           0 :     return aSNS;
      91             : }
      92             : 
      93             : // ui::dialogs::XExecutableDialog
      94           0 : void SAL_CALL ChineseTranslation_UnoDialog::setTitle( const OUString& ) throw(uno::RuntimeException, std::exception)
      95             : {
      96             :     //not implemented - fell free to do so, if you do need this
      97           0 : }
      98             : 
      99             : 
     100           0 : void SAL_CALL ChineseTranslation_UnoDialog::initialize( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException, std::exception)
     101             : {
     102           0 :     SolarMutexGuard aSolarGuard;
     103           0 :     if( m_bDisposed || m_bInDispose )
     104           0 :         return;
     105             : 
     106           0 :     const uno::Any* pArguments = aArguments.getConstArray();
     107           0 :     for(sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments)
     108             :     {
     109           0 :         beans::PropertyValue aProperty;
     110           0 :         if(*pArguments >>= aProperty)
     111             :         {
     112           0 :             if( aProperty.Name == "ParentWindow" )
     113             :             {
     114           0 :                 aProperty.Value >>= m_xParentWindow;
     115             :             }
     116             :         }
     117           0 :     }
     118             : }
     119             : 
     120             : 
     121           0 : sal_Int16 SAL_CALL ChineseTranslation_UnoDialog::execute() throw(uno::RuntimeException, std::exception)
     122             : {
     123           0 :     sal_Int16 nRet = ui::dialogs::ExecutableDialogResults::CANCEL;
     124             :     {
     125           0 :         SolarMutexGuard aSolarGuard;
     126           0 :         if( m_bDisposed || m_bInDispose )
     127           0 :             return nRet;
     128             : 
     129           0 :         if( !m_pDialog )
     130             :         {
     131           0 :             vcl::Window* pParent = NULL;
     132           0 :             if( m_xParentWindow.is() )
     133             :             {
     134           0 :                 VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParentWindow);
     135           0 :                 if (pImplementation)
     136           0 :                     pParent = pImplementation->GetWindow();
     137             :             }
     138           0 :             uno::Reference< XComponent > xComp( this );
     139           0 :             m_pDialog = VclPtr<ChineseTranslationDialog>::Create( pParent );
     140             :         }
     141           0 :         if( !m_pDialog )
     142           0 :             return nRet;
     143           0 :         nRet = m_pDialog->Execute();
     144           0 :         if(nRet==RET_OK)
     145           0 :            nRet=ui::dialogs::ExecutableDialogResults::OK;
     146             :     }
     147           0 :     return nRet;
     148             : }
     149             : 
     150             : 
     151             : // lang::XComponent
     152             : 
     153           0 : void SAL_CALL ChineseTranslation_UnoDialog::dispose() throw (uno::RuntimeException, std::exception)
     154             : {
     155           0 :     lang::EventObject aEvt;
     156             :     {
     157           0 :         SolarMutexGuard aSolarGuard;
     158           0 :         if( m_bDisposed || m_bInDispose )
     159           0 :             return;
     160           0 :         m_bInDispose = true;
     161             : 
     162           0 :         impl_DeleteDialog();
     163           0 :         m_xParentWindow = 0;
     164           0 :         m_bDisposed = true;
     165             : 
     166           0 :         aEvt.Source = static_cast< XComponent * >( this );
     167             :     }
     168           0 :     if( m_aDisposeEventListeners.getLength() )
     169           0 :         m_aDisposeEventListeners.disposeAndClear( aEvt );
     170             : }
     171             : 
     172           0 : void SAL_CALL ChineseTranslation_UnoDialog::addEventListener( const uno::Reference< lang::XEventListener > & xListener ) throw (uno::RuntimeException, std::exception)
     173             : {
     174           0 :     SolarMutexGuard aSolarGuard;
     175           0 :     if( m_bDisposed || m_bInDispose )
     176           0 :         return;
     177           0 :     m_aDisposeEventListeners.addInterface( xListener );
     178             : }
     179             : 
     180           0 : void SAL_CALL ChineseTranslation_UnoDialog::removeEventListener( const uno::Reference< lang::XEventListener > & xListener ) throw (uno::RuntimeException, std::exception)
     181             : {
     182           0 :     SolarMutexGuard aSolarGuard;
     183           0 :     if( m_bDisposed || m_bInDispose )
     184           0 :         return;
     185           0 :     m_aDisposeEventListeners.removeInterface( xListener );
     186             : }
     187             : 
     188             : 
     189             : // XPropertySet
     190             : 
     191           0 : uno::Reference< beans::XPropertySetInfo > SAL_CALL ChineseTranslation_UnoDialog::getPropertySetInfo(  ) throw (uno::RuntimeException, std::exception)
     192             : {
     193           0 :     return 0;
     194             : }
     195           0 : void SAL_CALL ChineseTranslation_UnoDialog::setPropertyValue( const OUString&, const uno::Any& ) throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     196             : {
     197             :     //only read only properties
     198           0 :     throw beans::PropertyVetoException();
     199             : }
     200           0 : uno::Any SAL_CALL ChineseTranslation_UnoDialog::getPropertyValue( const OUString& rPropertyName ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     201             : {
     202           0 :     uno::Any aRet;
     203             : 
     204           0 :     bool bDirectionToSimplified = true;
     205           0 :     bool bUseCharacterVariants = false;
     206           0 :     bool bTranslateCommonTerms = false;
     207             : 
     208             :     {
     209           0 :         SolarMutexGuard aSolarGuard;
     210           0 :         if( m_bDisposed || m_bInDispose || !m_pDialog )
     211           0 :             return aRet;
     212           0 :         m_pDialog->getSettings( bDirectionToSimplified, bTranslateCommonTerms );
     213             :     }
     214             : 
     215           0 :     if( rPropertyName == "IsDirectionToSimplified" )
     216             :     {
     217           0 :         aRet <<= bDirectionToSimplified;
     218             :     }
     219           0 :     else if( rPropertyName == "IsUseCharacterVariants" )
     220             :     {
     221           0 :         aRet <<= bUseCharacterVariants;
     222             :     }
     223           0 :     else if( rPropertyName == "IsTranslateCommonTerms" )
     224             :     {
     225           0 :         aRet <<= bTranslateCommonTerms;
     226             :     }
     227             :     else
     228             :     {
     229           0 :         throw beans::UnknownPropertyException();
     230             :     }
     231           0 :     return aRet;
     232             : 
     233             : }
     234           0 : void SAL_CALL ChineseTranslation_UnoDialog::addPropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     235             : {
     236             :     //only not bound properties -> ignore listener
     237           0 : }
     238           0 : void SAL_CALL ChineseTranslation_UnoDialog::removePropertyChangeListener( const OUString& , const uno::Reference< beans::XPropertyChangeListener >&  ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     239             : {
     240             :     //only not bound properties -> ignore listener
     241           0 : }
     242           0 : void SAL_CALL ChineseTranslation_UnoDialog::addVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     243             : {
     244             :     //only not bound properties -> ignore listener
     245           0 : }
     246           0 : void SAL_CALL ChineseTranslation_UnoDialog::removeVetoableChangeListener( const OUString& , const uno::Reference< beans::XVetoableChangeListener >&  ) throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException, std::exception)
     247             : {
     248             :     //only not bound properties -> ignore listener
     249           0 : }
     250             : 
     251             : 
     252           0 : } //end namespace
     253             : 
     254             : 
     255             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11