LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/dbaccess/source/ui/uno - unosqlmessage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 39 59 66.1 %
Date: 2013-07-09 Functions: 13 16 81.2 %
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 "sqlmessage.hxx"
      22             : #include "unosqlmessage.hxx"
      23             : #include "dbu_reghelper.hxx"
      24             : #include "dbustrings.hrc"
      25             : #include <comphelper/processfactory.hxx>
      26             : #include <cppuhelper/typeprovider.hxx>
      27             : #include <connectivity/dbexception.hxx>
      28             : 
      29             : using namespace dbaui;
      30             : using namespace dbtools;
      31             : 
      32             : using namespace ::com::sun::star::sdbc;
      33             : using namespace ::com::sun::star::sdb;
      34             : 
      35           4 : extern "C" void SAL_CALL createRegistryInfo_OSQLMessageDialog()
      36             : {
      37           4 :     static OMultiInstanceAutoRegistration< OSQLMessageDialog > aAutoRegistration;
      38           4 : }
      39             : 
      40             : //.........................................................................
      41             : namespace dbaui
      42             : {
      43             : //.........................................................................
      44             : 
      45             :     using namespace ::com::sun::star::uno;
      46             :     using namespace ::com::sun::star::lang;
      47             :     using namespace ::com::sun::star::beans;
      48             : 
      49             : //=========================================================================
      50             : //-------------------------------------------------------------------------
      51           2 : OSQLMessageDialog::OSQLMessageDialog(const Reference< XComponentContext >& _rxORB)
      52           2 :     :OSQLMessageDialogBase(_rxORB)
      53             : {
      54             :     registerMayBeVoidProperty(PROPERTY_SQLEXCEPTION, PROPERTY_ID_SQLEXCEPTION, PropertyAttribute::TRANSIENT | PropertyAttribute::MAYBEVOID,
      55           2 :         &m_aException, ::getCppuType(static_cast<SQLException*>(NULL)));
      56             :     registerProperty( PROPERTY_HELP_URL, PROPERTY_ID_HELP_URL, PropertyAttribute::TRANSIENT,
      57           2 :         &m_sHelpURL, ::getCppuType( &m_sHelpURL ) );
      58           2 : }
      59             : 
      60             : //-------------------------------------------------------------------------
      61           0 : Sequence<sal_Int8> SAL_CALL OSQLMessageDialog::getImplementationId(  ) throw(RuntimeException)
      62             : {
      63           0 :     static ::cppu::OImplementationId aId;
      64           0 :     return aId.getImplementationId();
      65             : }
      66             : 
      67             : //-------------------------------------------------------------------------
      68           2 : Reference< XInterface > SAL_CALL OSQLMessageDialog::Create(const Reference< XMultiServiceFactory >& _rxFactory)
      69             : {
      70           2 :     return *(new OSQLMessageDialog( comphelper::getComponentContext(_rxFactory) ));
      71             : }
      72             : 
      73             : //-------------------------------------------------------------------------
      74           0 : OUString SAL_CALL OSQLMessageDialog::getImplementationName() throw(RuntimeException)
      75             : {
      76           0 :     return getImplementationName_Static();
      77             : }
      78             : 
      79             : //-------------------------------------------------------------------------
      80           8 : OUString OSQLMessageDialog::getImplementationName_Static() throw(RuntimeException)
      81             : {
      82           8 :     return OUString("org.openoffice.comp.dbu.OSQLMessageDialog");
      83             : }
      84             : 
      85             : //-------------------------------------------------------------------------
      86           1 : ::comphelper::StringSequence SAL_CALL OSQLMessageDialog::getSupportedServiceNames() throw(RuntimeException)
      87             : {
      88           1 :     return getSupportedServiceNames_Static();
      89             : }
      90             : 
      91             : //-------------------------------------------------------------------------
      92           5 : ::comphelper::StringSequence OSQLMessageDialog::getSupportedServiceNames_Static() throw(RuntimeException)
      93             : {
      94           5 :     ::comphelper::StringSequence aSupported(1);
      95           5 :     aSupported.getArray()[0] = "com.sun.star.sdb.ErrorMessageDialog";
      96           5 :     return aSupported;
      97             : }
      98             : 
      99             : //-------------------------------------------------------------------------
     100           1 : void OSQLMessageDialog::initialize(Sequence<Any> const & args) throw (com::sun::star::uno::Exception, com::sun::star::uno::RuntimeException)
     101             : {
     102           1 :   OUString title;
     103           2 :   Reference< com::sun::star::awt::XWindow > parentWindow;
     104           2 :   com::sun::star::uno::Any sqlException;
     105             : 
     106           1 :   if ((args.getLength() == 3) && (args[0] >>= title) && (args[1] >>= parentWindow) && (args[2] >>= sqlException)) {
     107           0 :     Sequence<Any> s(3);
     108           0 :     s[0] <<= PropertyValue( "Title", -1, makeAny(title), PropertyState_DIRECT_VALUE);
     109           0 :     s[1] <<= PropertyValue( "ParentWindow", -1, makeAny(parentWindow), PropertyState_DIRECT_VALUE);
     110           0 :     s[2] <<= PropertyValue( "SQLException", -1, sqlException, PropertyState_DIRECT_VALUE);
     111           0 :     OGenericUnoDialog::initialize(s);
     112             :   } else {
     113           1 :     OGenericUnoDialog::initialize(args);
     114           1 :   }
     115           1 : }
     116             : 
     117             : //-------------------------------------------------------------------------
     118           5 : sal_Bool SAL_CALL OSQLMessageDialog::convertFastPropertyValue( Any& _rConvertedValue, Any& _rOldValue, sal_Int32 _nHandle, const Any& _rValue) throw(IllegalArgumentException)
     119             : {
     120           5 :     switch (_nHandle)
     121             :     {
     122             :         case PROPERTY_ID_SQLEXCEPTION:
     123             :         {
     124           0 :             SQLExceptionInfo aInfo(_rValue);
     125           0 :             if (!aInfo.isValid())
     126           0 :                 throw IllegalArgumentException();
     127             : 
     128           0 :             _rOldValue = m_aException;
     129           0 :             _rConvertedValue = aInfo.get();
     130             : 
     131           0 :             return sal_True;
     132             :                 // always assume "modified", don't bother with with comparing the two values
     133             :         }
     134             :         default:
     135           5 :             return OSQLMessageDialogBase::convertFastPropertyValue(_rConvertedValue, _rOldValue, _nHandle, _rValue);
     136             :     }
     137             : }
     138             : 
     139             : //-------------------------------------------------------------------------
     140           6 : Reference<XPropertySetInfo>  SAL_CALL OSQLMessageDialog::getPropertySetInfo() throw(RuntimeException)
     141             : {
     142           6 :     Reference<XPropertySetInfo>  xInfo( createPropertySetInfo( getInfoHelper() ) );
     143           6 :     return xInfo;
     144             : }
     145             : 
     146             : //-------------------------------------------------------------------------
     147          43 : ::cppu::IPropertyArrayHelper& OSQLMessageDialog::getInfoHelper()
     148             : {
     149          43 :     return *const_cast<OSQLMessageDialog*>(this)->getArrayHelper();
     150             : }
     151             : 
     152             : //------------------------------------------------------------------------------
     153           1 : ::cppu::IPropertyArrayHelper* OSQLMessageDialog::createArrayHelper( ) const
     154             : {
     155           1 :     Sequence< Property > aProps;
     156           1 :     describeProperties(aProps);
     157           1 :     return new ::cppu::OPropertyArrayHelper(aProps);
     158             : }
     159             : 
     160             : //------------------------------------------------------------------------------
     161           0 : Dialog* OSQLMessageDialog::createDialog(Window* _pParent)
     162             : {
     163           0 :     if ( m_aException.hasValue() )
     164           0 :         return new OSQLMessageBox( _pParent, SQLExceptionInfo( m_aException ), WB_OK | WB_DEF_OK, m_sHelpURL );
     165             : 
     166             :     OSL_FAIL("OSQLMessageDialog::createDialog : You should use the SQLException property to specify the error to display!");
     167           0 :     return new OSQLMessageBox(_pParent, SQLException());
     168             : }
     169             : 
     170             : //.........................................................................
     171          12 : }   // namespace dbaui
     172             : //.........................................................................
     173             : 
     174             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10