LCOV - code coverage report
Current view: top level - svtools/source/uno - addrtempuno.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 71 1.4 %
Date: 2014-11-03 Functions: 2 16 12.5 %
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 <svtools/addresstemplate.hxx>
      21             : #include <svtools/genericunodialog.hxx>
      22             : #include <cppuhelper/typeprovider.hxx>
      23             : #include <comphelper/extract.hxx>
      24             : #include <comphelper/property.hxx>
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <com/sun/star/sdbc/XDataSource.hpp>
      27             : #include <rtl/ref.hxx>
      28             : 
      29             : using namespace svt;
      30             : 
      31             : namespace {
      32             : 
      33             : #define UNODIALOG_PROPERTY_ID_ALIASES       100
      34             : #define UNODIALOG_PROPERTY_ALIASES          "FieldMapping"
      35             : 
      36             :     using namespace com::sun::star::uno;
      37             :     using namespace com::sun::star::lang;
      38             :     using namespace com::sun::star::util;
      39             :     using namespace com::sun::star::beans;
      40             :     using namespace com::sun::star::sdbc;
      41             : 
      42             :     typedef OGenericUnoDialog OAddressBookSourceDialogUnoBase;
      43           0 :     class OAddressBookSourceDialogUno
      44             :             :public OAddressBookSourceDialogUnoBase
      45             :             ,public ::comphelper::OPropertyArrayUsageHelper< OAddressBookSourceDialogUno >
      46             :     {
      47             :     private:
      48             :         Sequence< AliasProgrammaticPair >   m_aAliases;
      49             :         Reference< XDataSource >            m_xDataSource;
      50             :         OUString                     m_sDataSourceName;
      51             :         OUString                     m_sTable;
      52             : 
      53             :     public:
      54             :         OAddressBookSourceDialogUno(const Reference< XComponentContext >& _rxORB);
      55             : 
      56             :         // XTypeProvider
      57             :         virtual Sequence<sal_Int8> SAL_CALL getImplementationId(  ) throw(RuntimeException, std::exception) SAL_OVERRIDE;
      58             : 
      59             :         // XServiceInfo
      60             :         virtual OUString SAL_CALL getImplementationName() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      61             :         virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      62             : 
      63             :         // XPropertySet
      64             :         virtual Reference< XPropertySetInfo>  SAL_CALL getPropertySetInfo() throw(RuntimeException, std::exception) SAL_OVERRIDE;
      65             :         virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper() SAL_OVERRIDE;
      66             : 
      67             :         // OPropertyArrayUsageHelper
      68             :         virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const SAL_OVERRIDE;
      69             : 
      70             :         virtual void SAL_CALL initialize(const Sequence< Any >& aArguments) throw(Exception, RuntimeException, std::exception) SAL_OVERRIDE;
      71             : 
      72             :     protected:
      73             :     // OGenericUnoDialog overridables
      74             :         virtual Dialog* createDialog(vcl::Window* _pParent) SAL_OVERRIDE;
      75             : 
      76             :         virtual void implInitialize(const com::sun::star::uno::Any& _rValue) SAL_OVERRIDE;
      77             : 
      78             :         virtual void executedDialog(sal_Int16 _nExecutionResult) SAL_OVERRIDE;
      79             :     };
      80             : 
      81             : 
      82           0 :     OAddressBookSourceDialogUno::OAddressBookSourceDialogUno(const Reference< XComponentContext >& _rxORB)
      83           0 :         :OGenericUnoDialog(_rxORB)
      84             :     {
      85             :         registerProperty(OUString(UNODIALOG_PROPERTY_ALIASES), UNODIALOG_PROPERTY_ID_ALIASES, PropertyAttribute::READONLY,
      86           0 :             &m_aAliases, getCppuType(&m_aAliases));
      87           0 :     }
      88             : 
      89             : 
      90           0 :     Sequence<sal_Int8> SAL_CALL OAddressBookSourceDialogUno::getImplementationId(  ) throw(RuntimeException, std::exception)
      91             :     {
      92           0 :         return css::uno::Sequence<sal_Int8>();
      93             :     }
      94             : 
      95             : 
      96           0 :     OUString SAL_CALL OAddressBookSourceDialogUno::getImplementationName() throw(RuntimeException, std::exception)
      97             :     {
      98           0 :         return OUString( "com.sun.star.comp.svtools.OAddressBookSourceDialogUno" );
      99             :     }
     100             : 
     101             : 
     102           0 :     ::comphelper::StringSequence SAL_CALL OAddressBookSourceDialogUno::getSupportedServiceNames() throw(RuntimeException, std::exception)
     103             :     {
     104           0 :         ::comphelper::StringSequence aSupported(1);
     105           0 :         aSupported.getArray()[0] = "com.sun.star.ui.AddressBookSourceDialog";
     106           0 :         return aSupported;
     107             :     }
     108             : 
     109             : 
     110           0 :     Reference<XPropertySetInfo>  SAL_CALL OAddressBookSourceDialogUno::getPropertySetInfo() throw(RuntimeException, std::exception)
     111             :     {
     112           0 :         Reference<XPropertySetInfo>  xInfo( createPropertySetInfo( getInfoHelper() ) );
     113           0 :         return xInfo;
     114             :     }
     115             : 
     116             : 
     117           0 :     ::cppu::IPropertyArrayHelper& OAddressBookSourceDialogUno::getInfoHelper()
     118             :     {
     119           0 :         return *getArrayHelper();
     120             :     }
     121             : 
     122             : 
     123           0 :     ::cppu::IPropertyArrayHelper* OAddressBookSourceDialogUno::createArrayHelper( ) const
     124             :     {
     125           0 :         Sequence< Property > aProps;
     126           0 :         describeProperties(aProps);
     127           0 :         return new ::cppu::OPropertyArrayHelper(aProps);
     128             :     }
     129             : 
     130             : 
     131           0 :     void OAddressBookSourceDialogUno::executedDialog(sal_Int16 _nExecutionResult)
     132             :     {
     133           0 :         OAddressBookSourceDialogUnoBase::executedDialog(_nExecutionResult);
     134             : 
     135           0 :         if ( _nExecutionResult )
     136           0 :             if ( m_pDialog )
     137           0 :                 static_cast< AddressBookSourceDialog* >( m_pDialog )->getFieldMapping( m_aAliases );
     138           0 :     }
     139             : 
     140           0 :     void SAL_CALL OAddressBookSourceDialogUno::initialize(const Sequence< Any >& rArguments) throw(Exception, RuntimeException, std::exception)
     141             :     {
     142           0 :         if( rArguments.getLength() == 5 )
     143             :         {
     144           0 :             Reference<com::sun::star::awt::XWindow> xParentWindow;
     145           0 :             Reference<com::sun::star::beans::XPropertySet> xDataSource;
     146           0 :             OUString sDataSourceName;
     147           0 :             OUString sCommand;
     148           0 :             OUString sTitle;
     149           0 :             if ( (rArguments[0] >>= xParentWindow)
     150           0 :                && (rArguments[1] >>= xDataSource)
     151           0 :                && (rArguments[2] >>= sDataSourceName)
     152           0 :                && (rArguments[3] >>= sCommand)
     153           0 :                && (rArguments[4] >>= sTitle) )
     154             :             {
     155             : 
     156             :                 // convert the parameters for creating the dialog to PropertyValues
     157           0 :                 Sequence< Any > aArguments(5);
     158           0 :                 Any* pArguments = aArguments.getArray();
     159             :                 // the parent window
     160           0 :                 *pArguments++ <<= PropertyValue(OUString( "ParentWindow" ), -1, makeAny( xParentWindow ), PropertyState_DIRECT_VALUE);
     161             :                 // the data source to use
     162           0 :                 *pArguments++ <<= PropertyValue(OUString( "DataSource" ), -1, makeAny( xDataSource ), PropertyState_DIRECT_VALUE);
     163           0 :                 *pArguments++ <<= PropertyValue(OUString( "DataSourceName" ), -1, makeAny( sDataSourceName ), PropertyState_DIRECT_VALUE);
     164             :                 // the table to use
     165           0 :                 *pArguments++ <<= PropertyValue(OUString( "Command" ), -1, makeAny( sCommand ), PropertyState_DIRECT_VALUE);
     166             :                 // the title
     167           0 :                 *pArguments++ <<= PropertyValue(OUString( "Title" ), -1, makeAny( sTitle ), PropertyState_DIRECT_VALUE);
     168           0 :                 OGenericUnoDialog::initialize(aArguments);
     169           0 :                 return;
     170           0 :             }
     171             :         }
     172           0 :         OGenericUnoDialog::initialize(rArguments);
     173             :     }
     174             : 
     175           0 :     void OAddressBookSourceDialogUno::implInitialize(const com::sun::star::uno::Any& _rValue)
     176             :     {
     177           0 :         PropertyValue aVal;
     178           0 :         if (_rValue >>= aVal)
     179             :         {
     180           0 :             if (aVal.Name.equalsAscii("DataSource"))
     181             :             {
     182             : #if OSL_DEBUG_LEVEL > 0
     183             :                 bool bSuccess =
     184             : #endif
     185           0 :                 aVal.Value >>= m_xDataSource;
     186             :                 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSource!" );
     187           0 :                 return;
     188             :             }
     189             : 
     190           0 :             if (aVal.Name.equalsAscii("DataSourceName"))
     191             :             {
     192             : #if OSL_DEBUG_LEVEL > 0
     193             :                 bool bSuccess =
     194             : #endif
     195           0 :                 aVal.Value >>= m_sDataSourceName;
     196             :                 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for DataSourceName!" );
     197           0 :                 return;
     198             :             }
     199             : 
     200           0 :             if (aVal.Name.equalsAscii("Command"))
     201             :             {
     202             : #if OSL_DEBUG_LEVEL > 0
     203             :                 bool bSuccess =
     204             : #endif
     205           0 :                 aVal.Value >>= m_sTable;
     206             :                 OSL_ENSURE( bSuccess, "OAddressBookSourceDialogUno::implInitialize: invalid type for Command!" );
     207           0 :                 return;
     208             :             }
     209             :         }
     210             : 
     211           0 :         OAddressBookSourceDialogUnoBase::implInitialize( _rValue );
     212             :     }
     213             : 
     214             : 
     215           0 :     Dialog* OAddressBookSourceDialogUno::createDialog(vcl::Window* _pParent)
     216             :     {
     217           0 :         if ( m_xDataSource.is() && !m_sTable.isEmpty() )
     218           0 :             return new AddressBookSourceDialog(_pParent, m_aContext, m_xDataSource, m_sDataSourceName, m_sTable, m_aAliases );
     219             :         else
     220           0 :             return new AddressBookSourceDialog( _pParent, m_aContext );
     221             :     }
     222             : 
     223             : }
     224             : 
     225             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     226           0 : com_sun_star_comp_svtools_OAddressBookSourceDialogUno_get_implementation(
     227             :     css::uno::XComponentContext * context,
     228             :     css::uno::Sequence<css::uno::Any> const &)
     229             : {
     230           0 :     return cppu::acquire(new OAddressBookSourceDialogUno(context));
     231        1227 : }
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10