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

Generated by: LCOV version 1.10