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

Generated by: LCOV version 1.10