LCOV - code coverage report
Current view: top level - dbaccess/source/ui/uno - textconnectionsettings_uno.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 13 86 15.1 %
Date: 2014-11-03 Functions: 9 29 31.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             : #include "textconnectionsettings.hxx"
      21             : #include "uiservices.hxx"
      22             : #include "dbu_reghelper.hxx"
      23             : #include "moduledbu.hxx"
      24             : #include "apitools.hxx"
      25             : #include "unoadmin.hxx"
      26             : #include "dbustrings.hrc"
      27             : #include "propertystorage.hxx"
      28             : 
      29             : #include <com/sun/star/beans/XPropertySetInfo.hpp>
      30             : #include <com/sun/star/beans/PropertyAttribute.hpp>
      31             : #include <com/sun/star/sdb/XTextConnectionSettings.hpp>
      32             : 
      33             : #include <comphelper/processfactory.hxx>
      34             : #include <svtools/genericunodialog.hxx>
      35             : #include <cppuhelper/implbase1.hxx>
      36             : 
      37             : namespace dbaui
      38             : {
      39             : 
      40             :     using ::com::sun::star::uno::Reference;
      41             :     using ::com::sun::star::uno::XInterface;
      42             :     using ::com::sun::star::uno::UNO_QUERY;
      43             :     using ::com::sun::star::uno::UNO_QUERY_THROW;
      44             :     using ::com::sun::star::uno::Exception;
      45             :     using ::com::sun::star::uno::RuntimeException;
      46             :     using ::com::sun::star::uno::Any;
      47             :     using ::com::sun::star::uno::makeAny;
      48             :     using ::com::sun::star::uno::XComponentContext;
      49             :     using ::com::sun::star::beans::XPropertySetInfo;
      50             :     using ::com::sun::star::uno::Sequence;
      51             :     using ::com::sun::star::beans::Property;
      52             :     using ::com::sun::star::lang::IllegalArgumentException;
      53             : 
      54             :     namespace PropertyAttribute = ::com::sun::star::beans::PropertyAttribute;
      55             : 
      56             :     // OTextConnectionSettingsDialog
      57             : 
      58             :     class OTextConnectionSettingsDialog;
      59             :     typedef ::cppu::ImplInheritanceHelper1  <   ODatabaseAdministrationDialog
      60             :                                             ,   ::com::sun::star::sdb::XTextConnectionSettings
      61             :                                             >   OTextConnectionSettingsDialog_BASE;
      62             :     typedef ::comphelper::OPropertyArrayUsageHelper< OTextConnectionSettingsDialog >    OTextConnectionSettingsDialog_PBASE;
      63             : 
      64             :     class OTextConnectionSettingsDialog
      65             :             :public OTextConnectionSettingsDialog_BASE
      66             :             ,public OTextConnectionSettingsDialog_PBASE
      67             :             ,public ::cppu::WeakImplHelper1< com::sun::star::sdb::XTextConnectionSettings >
      68             :     {
      69             :         OModuleClient   m_aModuleClient;
      70             :         PropertyValues  m_aPropertyValues;
      71             : 
      72             :     protected:
      73             :         OTextConnectionSettingsDialog( const Reference<XComponentContext>& _rContext );
      74             :         virtual ~OTextConnectionSettingsDialog();
      75             : 
      76             :     public:
      77             :         virtual css::uno::Sequence<sal_Int8> SAL_CALL getImplementationId()
      78             :             throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      79             : 
      80             :         DECLARE_SERVICE_INFO_STATIC( );
      81             :         DECLARE_PROPERTYCONTAINER_DEFAULTS( );
      82             : 
      83             :         virtual void SAL_CALL setFastPropertyValue_NoBroadcast( sal_Int32 nHandle, const Any& rValue ) throw(Exception, std::exception) SAL_OVERRIDE;
      84             :         virtual sal_Bool SAL_CALL convertFastPropertyValue( Any& rConvertedValue, Any& rOldValue, sal_Int32 nHandle, const Any& rValue) throw(IllegalArgumentException) SAL_OVERRIDE;
      85             :         virtual void SAL_CALL getFastPropertyValue( Any& rValue, sal_Int32 nHandle ) const SAL_OVERRIDE;
      86             : 
      87             :         // Overrides to resolve inheritance ambiguity
      88           0 :         virtual void SAL_CALL setPropertyValue(const OUString& p1, const css::uno::Any& p2) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      89           0 :             { ODatabaseAdministrationDialog::setPropertyValue(p1, p2); }
      90           0 :         virtual css::uno::Any SAL_CALL getPropertyValue(const OUString& p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      91           0 :             { return ODatabaseAdministrationDialog::getPropertyValue(p1); }
      92           0 :         virtual void SAL_CALL addPropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      93           0 :             { ODatabaseAdministrationDialog::addPropertyChangeListener(p1, p2); }
      94           0 :         virtual void SAL_CALL removePropertyChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XPropertyChangeListener>& p2) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      95           0 :             { ODatabaseAdministrationDialog::removePropertyChangeListener(p1, p2); }
      96           0 :         virtual void SAL_CALL addVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      97           0 :             { ODatabaseAdministrationDialog::addVetoableChangeListener(p1, p2); }
      98           0 :         virtual void SAL_CALL removeVetoableChangeListener(const OUString& p1, const css::uno::Reference<css::beans::XVetoableChangeListener>& p2) throw (css::beans::UnknownPropertyException, css::uno::RuntimeException, std::exception) SAL_OVERRIDE
      99           0 :             { ODatabaseAdministrationDialog::removeVetoableChangeListener(p1, p2); }
     100           0 :         virtual void SAL_CALL setTitle(const OUString& p1) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     101           0 :             { ODatabaseAdministrationDialog::setTitle(p1); }
     102           0 :         virtual sal_Int16 SAL_CALL execute() throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     103           0 :             { return ODatabaseAdministrationDialog::execute(); }
     104             : 
     105             :     protected:
     106             :         // OGenericUnoDialog overridables
     107             :         virtual Dialog* createDialog( vcl::Window* _pParent ) SAL_OVERRIDE;
     108             :         virtual void implInitialize( const com::sun::star::uno::Any& _rValue ) SAL_OVERRIDE;
     109             :     protected:
     110             :         using OTextConnectionSettingsDialog_BASE::getFastPropertyValue;
     111             :     };
     112             : 
     113             :     // OTextConnectionSettingsDialog
     114           2 :     OTextConnectionSettingsDialog::OTextConnectionSettingsDialog( const Reference<XComponentContext>& _rContext )
     115           2 :         :OTextConnectionSettingsDialog_BASE( _rContext )
     116             :     {
     117           2 :         TextConnectionSettingsDialog::bindItemStorages( *m_pDatasourceItems, m_aPropertyValues );
     118           2 :     }
     119             : 
     120           4 :     OTextConnectionSettingsDialog::~OTextConnectionSettingsDialog()
     121             :     {
     122           4 :     }
     123             : 
     124             :     css::uno::Sequence<sal_Int8>
     125           0 :     OTextConnectionSettingsDialog::getImplementationId()
     126             :         throw (css::uno::RuntimeException, std::exception)
     127             :     {
     128           0 :         return css::uno::Sequence<sal_Int8>();
     129             :     }
     130             : 
     131          48 :     IMPLEMENT_SERVICE_INFO_IMPLNAME_STATIC(OTextConnectionSettingsDialog, "com.sun.star.comp.dbaccess.OTextConnectionSettingsDialog")
     132           0 :     IMPLEMENT_SERVICE_INFO_SUPPORTS(OTextConnectionSettingsDialog)
     133          24 :     IMPLEMENT_SERVICE_INFO_GETSUPPORTED1_STATIC(OTextConnectionSettingsDialog, "com.sun.star.sdb.TextConnectionSettings")
     134             : 
     135             :     ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >
     136           2 :         SAL_CALL OTextConnectionSettingsDialog::Create(const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB)
     137             :     {
     138           2 :         return static_cast< XServiceInfo* >(new OTextConnectionSettingsDialog( comphelper::getComponentContext(_rxORB)));
     139             :     }
     140             : 
     141           0 :     Reference< XPropertySetInfo >  SAL_CALL OTextConnectionSettingsDialog::getPropertySetInfo() throw(RuntimeException, std::exception)
     142             :     {
     143           0 :         return createPropertySetInfo( getInfoHelper() );
     144             :     }
     145             : 
     146           0 :     ::cppu::IPropertyArrayHelper& OTextConnectionSettingsDialog::getInfoHelper()
     147             :     {
     148           0 :         return *getArrayHelper();
     149             :     }
     150             : 
     151           0 :     ::cppu::IPropertyArrayHelper* OTextConnectionSettingsDialog::createArrayHelper( ) const
     152             :     {
     153           0 :         Sequence< Property > aProps;
     154           0 :         describeProperties( aProps );
     155             : 
     156             :         // in addition to the properties registered by the base class, we have
     157             :         // more properties which are not even handled by the PropertyContainer implementation,
     158             :         // but whose values are stored in our item set
     159           0 :         sal_Int32 nProp = aProps.getLength();
     160           0 :         aProps.realloc( nProp + 6 );
     161             : 
     162           0 :         aProps[ nProp++ ] = Property(
     163             :             OUString( "HeaderLine" ),
     164             :             PROPERTY_ID_HEADER_LINE,
     165           0 :             ::cppu::UnoType< sal_Bool >::get(),
     166             :             PropertyAttribute::TRANSIENT
     167           0 :         );
     168             : 
     169           0 :         aProps[ nProp++ ] = Property(
     170             :             OUString( "FieldDelimiter" ),
     171             :             PROPERTY_ID_FIELD_DELIMITER,
     172           0 :             ::cppu::UnoType< OUString >::get(),
     173             :             PropertyAttribute::TRANSIENT
     174           0 :         );
     175             : 
     176           0 :         aProps[ nProp++ ] = Property(
     177             :             OUString( "StringDelimiter" ),
     178             :             PROPERTY_ID_STRING_DELIMITER,
     179           0 :             ::cppu::UnoType< OUString >::get(),
     180             :             PropertyAttribute::TRANSIENT
     181           0 :         );
     182             : 
     183           0 :         aProps[ nProp++ ] = Property(
     184             :             OUString( "DecimalDelimiter" ),
     185             :             PROPERTY_ID_DECIMAL_DELIMITER,
     186           0 :             ::cppu::UnoType< OUString >::get(),
     187             :             PropertyAttribute::TRANSIENT
     188           0 :         );
     189             : 
     190           0 :         aProps[ nProp++ ] = Property(
     191             :             OUString( "ThousandDelimiter" ),
     192             :             PROPERTY_ID_THOUSAND_DELIMITER,
     193           0 :             ::cppu::UnoType< OUString >::get(),
     194             :             PropertyAttribute::TRANSIENT
     195           0 :         );
     196             : 
     197           0 :         aProps[ nProp++ ] = Property(
     198             :             OUString( "CharSet" ),
     199             :             PROPERTY_ID_ENCODING,
     200           0 :             ::cppu::UnoType< OUString >::get(),
     201             :             PropertyAttribute::TRANSIENT
     202           0 :         );
     203             : 
     204           0 :         return new ::cppu::OPropertyArrayHelper( aProps );
     205             :     }
     206             : 
     207           0 :     Dialog* OTextConnectionSettingsDialog::createDialog(vcl::Window* _pParent)
     208             :     {
     209           0 :         return new TextConnectionSettingsDialog( _pParent, *m_pDatasourceItems );
     210             :     }
     211             : 
     212           0 :     void OTextConnectionSettingsDialog::implInitialize(const Any& _rValue)
     213             :     {
     214           0 :         OTextConnectionSettingsDialog_BASE::implInitialize( _rValue );
     215           0 :     }
     216             : 
     217           0 :     void SAL_CALL OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( sal_Int32 _nHandle, const Any& _rValue ) throw(Exception, std::exception)
     218             :     {
     219           0 :         PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
     220           0 :         if ( pos != m_aPropertyValues.end() )
     221             :         {
     222           0 :             pos->second->setPropertyValue( _rValue );
     223             :         }
     224             :         else
     225             :         {
     226           0 :             OTextConnectionSettingsDialog::setFastPropertyValue_NoBroadcast( _nHandle, _rValue );
     227             :         }
     228           0 :     }
     229             : 
     230           0 :     sal_Bool SAL_CALL OTextConnectionSettingsDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
     231             :     {
     232           0 :         bool bModified = false;
     233             : 
     234           0 :         PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
     235           0 :         if ( pos != m_aPropertyValues.end() )
     236             :         {
     237             :             // we're lazy here ...
     238           0 :             _rConvertedValue = _rValue;
     239           0 :             pos->second->getPropertyValue( _rOldValue );
     240           0 :             bModified = true;
     241             :         }
     242             :         else
     243             :         {
     244           0 :             bModified = OTextConnectionSettingsDialog::convertFastPropertyValue( _rConvertedValue, _rOldValue, _nHandle, _rValue );
     245             :         }
     246             : 
     247           0 :         return bModified;
     248             :     }
     249             : 
     250           0 :     void SAL_CALL OTextConnectionSettingsDialog::getFastPropertyValue( Any& _rValue, sal_Int32 _nHandle ) const
     251             :     {
     252           0 :         PropertyValues::const_iterator pos = m_aPropertyValues.find( _nHandle );
     253           0 :         if ( pos != m_aPropertyValues.end() )
     254             :         {
     255           0 :             pos->second->getPropertyValue( _rValue );
     256             :         }
     257             :         else
     258             :         {
     259           0 :             OTextConnectionSettingsDialog::getFastPropertyValue( _rValue, _nHandle );
     260             :         }
     261           0 :     }
     262             : 
     263             : } // namespace dbaui
     264             : 
     265          24 : extern "C" void SAL_CALL createRegistryInfo_OTextConnectionSettingsDialog()
     266             : {
     267          24 :     static ::dbaui::OMultiInstanceAutoRegistration< ::dbaui::OTextConnectionSettingsDialog > aAutoRegistration;
     268          96 : }
     269             : 
     270             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10