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

Generated by: LCOV version 1.10