LCOV - code coverage report
Current view: top level - svx/source/form - fmtools.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 58 195 29.7 %
Date: 2012-08-25 Functions: 11 22 50.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 48 402 11.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "fmprop.hrc"
      31                 :            : #include "fmservs.hxx"
      32                 :            : #include "svx/fmtools.hxx"
      33                 :            : #include "svx/dbtoolsclient.hxx"
      34                 :            : #include "svx/fmglob.hxx"
      35                 :            : 
      36                 :            : #include <com/sun/star/awt/LineEndFormat.hpp>
      37                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      38                 :            : #include <com/sun/star/beans/XIntrospection.hpp>
      39                 :            : #include <com/sun/star/container/XChild.hpp>
      40                 :            : #include <com/sun/star/form/XForm.hpp>
      41                 :            : #include <com/sun/star/form/XFormComponent.hpp>
      42                 :            : #include <com/sun/star/form/XGridColumnFactory.hpp>
      43                 :            : #include <com/sun/star/io/XActiveDataSink.hpp>
      44                 :            : #include <com/sun/star/io/XActiveDataSource.hpp>
      45                 :            : #include <com/sun/star/io/XObjectInputStream.hpp>
      46                 :            : #include <com/sun/star/io/XObjectOutputStream.hpp>
      47                 :            : #include <com/sun/star/io/XPersistObject.hpp>
      48                 :            : #include <com/sun/star/lang/Locale.hpp>
      49                 :            : #include <com/sun/star/lang/XServiceInfo.hpp>
      50                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      51                 :            : #include <com/sun/star/sdb/ErrorCondition.hpp>
      52                 :            : #include <com/sun/star/sdb/SQLContext.hpp>
      53                 :            : #include <com/sun/star/sdb/XCompletedConnection.hpp>
      54                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      55                 :            : #include <com/sun/star/sdb/XResultSetAccess.hpp>
      56                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      57                 :            : #include <com/sun/star/sdbc/XDataSource.hpp>
      58                 :            : #include <com/sun/star/sdbcx/Privilege.hpp>
      59                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      60                 :            : #include <com/sun/star/task/XInteractionHandler.hpp>
      61                 :            : #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
      62                 :            : #include <com/sun/star/uno/XNamingService.hpp>
      63                 :            : #include <com/sun/star/util/Language.hpp>
      64                 :            : #include <com/sun/star/util/NumberFormat.hpp>
      65                 :            : #include <com/sun/star/util/XCloneable.hpp>
      66                 :            : #include <com/sun/star/util/XNumberFormatTypes.hpp>
      67                 :            : #include <com/sun/star/util/XNumberFormats.hpp>
      68                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      69                 :            : #include <com/sun/star/util/XNumberFormatter.hpp>
      70                 :            : 
      71                 :            : #include <basic/sbxvar.hxx>
      72                 :            : #include <svl/eitem.hxx>
      73                 :            : #include <svl/stritem.hxx>
      74                 :            : #include <comphelper/container.hxx>
      75                 :            : #include <comphelper/extract.hxx>
      76                 :            : #include <comphelper/processfactory.hxx>
      77                 :            : #include <comphelper/property.hxx>
      78                 :            : #include <comphelper/sequence.hxx>
      79                 :            : #include <comphelper/types.hxx>
      80                 :            : #include <comphelper/uno3.hxx>
      81                 :            : #include <connectivity/dbexception.hxx>
      82                 :            : #include <connectivity/dbtools.hxx>
      83                 :            : #include <cppuhelper/servicefactory.hxx>
      84                 :            : #include <cppuhelper/typeprovider.hxx>
      85                 :            : #include <rtl/logfile.hxx>
      86                 :            : #include <rtl/math.hxx>
      87                 :            : #include <sfx2/bindings.hxx>
      88                 :            : #include <toolkit/unohlp.hxx>
      89                 :            : #include <tools/debug.hxx>
      90                 :            : #include <vcl/stdtext.hxx>
      91                 :            : #include <vcl/svapp.hxx>
      92                 :            : 
      93                 :            : #include <algorithm>
      94                 :            : 
      95                 :            : using namespace ::com::sun::star::uno;
      96                 :            : using namespace ::com::sun::star::util;
      97                 :            : using namespace ::com::sun::star::lang;
      98                 :            : using namespace ::com::sun::star::frame;
      99                 :            : using namespace ::com::sun::star::awt;
     100                 :            : using namespace ::com::sun::star::beans;
     101                 :            : using namespace ::com::sun::star::container;
     102                 :            : using namespace ::com::sun::star::ui::dialogs;
     103                 :            : using namespace ::com::sun::star::sdbc;
     104                 :            : using namespace ::com::sun::star::sdbcx;
     105                 :            : using namespace ::com::sun::star::sdb;
     106                 :            : using namespace ::com::sun::star::task;
     107                 :            : using namespace ::com::sun::star::form;
     108                 :            : using namespace ::svxform;
     109                 :            : using namespace ::connectivity::simple;
     110                 :            : 
     111                 :            : //  ------------------------------------------------------------------------------
     112                 :            : namespace
     113                 :            : {
     114                 :          0 :     static bool lcl_shouldDisplayError( const Any& _rError )
     115                 :            :     {
     116         [ #  # ]:          0 :         SQLException aError;
     117 [ #  # ][ #  # ]:          0 :         if ( !( _rError >>= aError ) )
     118                 :          0 :             return true;
     119                 :            : 
     120         [ #  # ]:          0 :         if ( aError.Message.indexOfAsciiL( RTL_CONSTASCII_STRINGPARAM( "[OOoBase]" ) ) != 0 )
     121                 :            :             // it is an exception *not* thrown by an OOo Base core component
     122                 :          0 :             return true;
     123                 :            : 
     124                 :            :         // the only exception we do not display ATM is a RowSetVetoException, which
     125                 :            :         // has been raised because an XRowSetApprovalListener vetoed a change
     126         [ #  # ]:          0 :         if ( aError.ErrorCode + ErrorCondition::ROW_SET_OPERATION_VETOED == 0 )
     127                 :          0 :             return false;
     128                 :            : 
     129                 :            :         // everything else is to be displayed
     130         [ #  # ]:          0 :         return true;
     131                 :            :     }
     132                 :            : }
     133                 :            : 
     134                 :            : //  ------------------------------------------------------------------------------
     135                 :          0 : void displayException(const Any& _rExcept, Window* _pParent)
     136                 :            : {
     137                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::displayException" );
     138                 :            :     // check whether we need to display it
     139         [ #  # ]:          0 :     if ( !lcl_shouldDisplayError( _rExcept ) )
     140                 :          0 :         return;
     141                 :            : 
     142                 :            :     try
     143                 :            :     {
     144                 :            :         // the parent window
     145 [ #  # ][ #  # ]:          0 :         Window* pParentWindow = _pParent ? _pParent : GetpApp()->GetDefDialogParent();
                 [ #  # ]
     146         [ #  # ]:          0 :         Reference< XWindow > xParentWindow = VCLUnoHelper::GetInterface(pParentWindow);
     147                 :            : 
     148         [ #  # ]:          0 :         Sequence< Any > aArgs(2);
     149 [ #  # ][ #  # ]:          0 :         aArgs[0] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SQLException")), 0, _rExcept, PropertyState_DIRECT_VALUE);
                 [ #  # ]
     150 [ #  # ][ #  # ]:          0 :         aArgs[1] <<= PropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParentWindow")), 0, makeAny(xParentWindow), PropertyState_DIRECT_VALUE);
         [ #  # ][ #  # ]
     151                 :            : 
     152 [ #  # ][ #  # ]:          0 :         static ::rtl::OUString s_sDialogServiceName( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.sdb.ErrorMessageDialog") );
         [ #  # ][ #  # ]
     153                 :            :         Reference< XExecutableDialog > xErrorDialog(
     154 [ #  # ][ #  # ]:          0 :             ::comphelper::getProcessServiceFactory()->createInstanceWithArguments(s_sDialogServiceName, aArgs), UNO_QUERY);
         [ #  # ][ #  # ]
     155         [ #  # ]:          0 :         if (xErrorDialog.is())
     156 [ #  # ][ #  # ]:          0 :             xErrorDialog->execute();
     157                 :            :         else
     158 [ #  # ][ #  # ]:          0 :             ShowServiceNotAvailableError(pParentWindow, s_sDialogServiceName, sal_True);
         [ #  # ][ #  # ]
                 [ #  # ]
     159                 :            :     }
     160                 :          0 :     catch(Exception&)
     161                 :            :     {
     162                 :            :         OSL_FAIL("displayException: could not display the error message!");
     163                 :            :     }
     164                 :            : }
     165                 :            : 
     166                 :            : //  ------------------------------------------------------------------------------
     167                 :          0 : void displayException(const ::com::sun::star::sdbc::SQLException& _rExcept, Window* _pParent)
     168                 :            : {
     169         [ #  # ]:          0 :     displayException(makeAny(_rExcept), _pParent);
     170                 :          0 : }
     171                 :            : 
     172                 :            : //  ------------------------------------------------------------------------------
     173                 :          0 : void displayException(const ::com::sun::star::sdbc::SQLWarning& _rExcept, Window* _pParent)
     174                 :            : {
     175         [ #  # ]:          0 :     displayException(makeAny(_rExcept), _pParent);
     176                 :          0 : }
     177                 :            : 
     178                 :            : //  ------------------------------------------------------------------------------
     179                 :          0 : void displayException(const ::com::sun::star::sdb::SQLContext& _rExcept, Window* _pParent)
     180                 :            : {
     181         [ #  # ]:          0 :     displayException(makeAny(_rExcept), _pParent);
     182                 :          0 : }
     183                 :            : 
     184                 :            : //  ------------------------------------------------------------------------------
     185                 :          0 : void displayException(const ::com::sun::star::sdb::SQLErrorEvent& _rEvent, Window* _pParent)
     186                 :            : {
     187                 :          0 :     displayException(_rEvent.Reason, _pParent);
     188                 :          0 : }
     189                 :            : 
     190                 :            : //------------------------------------------------------------------------------
     191                 :        567 : sal_Int32 getElementPos(const Reference< ::com::sun::star::container::XIndexAccess>& xCont, const Reference< XInterface >& xElement)
     192                 :            : {
     193                 :        567 :     sal_Int32 nIndex = -1;
     194         [ -  + ]:        567 :     if (!xCont.is())
     195                 :          0 :         return nIndex;
     196                 :            : 
     197                 :            : 
     198         [ +  - ]:        567 :     Reference< XInterface > xNormalized( xElement, UNO_QUERY );
     199                 :            :     DBG_ASSERT( xNormalized.is(), "getElementPos: invalid element!" );
     200         [ +  - ]:        567 :     if ( xNormalized.is() )
     201                 :            :     {
     202                 :            :         // Feststellen an welcher Position sich das Kind befindet
     203 [ +  - ][ +  - ]:        567 :         nIndex = xCont->getCount();
     204         [ +  - ]:       2501 :         while (nIndex--)
     205                 :            :         {
     206                 :            :             try
     207                 :            :             {
     208 [ +  - ][ +  - ]:       2501 :                 Reference< XInterface > xCurrent(xCont->getByIndex( nIndex ),UNO_QUERY);
                 [ +  - ]
     209                 :            :                 DBG_ASSERT( xCurrent.get() == Reference< XInterface >( xCurrent, UNO_QUERY ).get(),
     210                 :            :                     "getElementPos: container element not normalized!" );
     211 [ +  - ][ +  + ]:       2501 :                 if ( xNormalized.get() == xCurrent.get() )
                 [ +  - ]
     212 [ +  + ][ #  # ]:       2501 :                     break;
     213                 :            :             }
     214         [ #  # ]:          0 :             catch(Exception&)
     215                 :            :             {
     216                 :            :                 OSL_FAIL( "getElementPos: caught an exception!" );
     217                 :            :             }
     218                 :            : 
     219                 :            :         }
     220                 :            :     }
     221                 :        567 :     return nIndex;
     222                 :            : }
     223                 :            : 
     224                 :            : //------------------------------------------------------------------
     225                 :          0 : ::rtl::OUString getLabelName(const Reference< ::com::sun::star::beans::XPropertySet>& xControlModel)
     226                 :            : {
     227                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getLabelName" );
     228         [ #  # ]:          0 :     if (!xControlModel.is())
     229                 :          0 :         return ::rtl::OUString();
     230                 :            : 
     231 [ #  # ][ #  # ]:          0 :     if (::comphelper::hasProperty(FM_PROP_CONTROLLABEL, xControlModel))
     232                 :            :     {
     233                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet> xLabelSet;
     234 [ #  # ][ #  # ]:          0 :         xControlModel->getPropertyValue(FM_PROP_CONTROLLABEL) >>= xLabelSet;
         [ #  # ][ #  # ]
     235 [ #  # ][ #  # ]:          0 :         if (xLabelSet.is() && ::comphelper::hasProperty(FM_PROP_LABEL, xLabelSet))
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     236                 :            :         {
     237 [ #  # ][ #  # ]:          0 :             Any aLabel( xLabelSet->getPropertyValue(FM_PROP_LABEL) );
                 [ #  # ]
     238 [ #  # ][ #  # ]:          0 :             if ((aLabel.getValueTypeClass() == TypeClass_STRING) && !::comphelper::getString(aLabel).isEmpty())
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
     239 [ #  # ][ #  # ]:          0 :                 return ::comphelper::getString(aLabel);
     240         [ #  # ]:          0 :         }
     241                 :            :     }
     242                 :            : 
     243 [ #  # ][ #  # ]:          0 :     return ::comphelper::getString(xControlModel->getPropertyValue(FM_PROP_CONTROLSOURCE));
     244                 :            : }
     245                 :            : 
     246                 :            : //========================================================================
     247                 :            : // = CursorWrapper
     248                 :            : //------------------------------------------------------------------------
     249                 :          2 : CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor, sal_Bool bUseCloned)
     250                 :            : {
     251 [ +  - ][ +  - ]:          2 :     ImplConstruct(Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY), bUseCloned);
     252                 :          2 : }
     253                 :            : 
     254                 :            : //------------------------------------------------------------------------
     255                 :          2 : CursorWrapper::CursorWrapper(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
     256                 :            : {
     257         [ +  - ]:          2 :     ImplConstruct(_rxCursor, bUseCloned);
     258                 :          2 : }
     259                 :            : 
     260                 :            : //------------------------------------------------------------------------
     261                 :          4 : void CursorWrapper::ImplConstruct(const Reference< ::com::sun::star::sdbc::XResultSet>& _rxCursor, sal_Bool bUseCloned)
     262                 :            : {
     263         [ -  + ]:          4 :     if (bUseCloned)
     264                 :            :     {
     265         [ #  # ]:          0 :         Reference< ::com::sun::star::sdb::XResultSetAccess> xAccess(_rxCursor, UNO_QUERY);
     266                 :            :         try
     267                 :            :         {
     268 [ #  # ][ #  # ]:          0 :             m_xMoveOperations = xAccess.is() ? xAccess->createResultSet() : Reference< ::com::sun::star::sdbc::XResultSet>();
         [ #  # ][ #  # ]
                 [ #  # ]
     269                 :            :         }
     270         [ #  # ]:          0 :         catch(Exception&)
     271                 :            :         {
     272                 :          0 :         }
     273                 :            :     }
     274                 :            :     else
     275                 :          4 :         m_xMoveOperations   = _rxCursor;
     276                 :            : 
     277         [ +  - ]:          4 :     m_xBookmarkOperations   = m_xBookmarkOperations.query( m_xMoveOperations );
     278         [ +  - ]:          4 :     m_xColumnsSupplier      = m_xColumnsSupplier.query( m_xMoveOperations );
     279         [ +  - ]:          4 :     m_xPropertyAccess       = m_xPropertyAccess.query( m_xMoveOperations );
     280                 :            : 
     281 [ +  - ][ +  - ]:          4 :     if ( !m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is() || !m_xPropertyAccess.is() )
         [ -  + ][ -  + ]
                 [ +  - ]
     282                 :            :     {   // all or nothing !!
     283                 :          0 :         m_xMoveOperations = NULL;
     284                 :          0 :         m_xBookmarkOperations = NULL;
     285                 :          0 :         m_xColumnsSupplier = NULL;
     286                 :            :     }
     287                 :            :     else
     288                 :          4 :         m_xGeneric = m_xMoveOperations.get();
     289                 :          4 : }
     290                 :            : 
     291                 :            : //------------------------------------------------------------------------
     292                 :          0 : const CursorWrapper& CursorWrapper::operator=(const Reference< ::com::sun::star::sdbc::XRowSet>& _rxCursor)
     293                 :            : {
     294         [ #  # ]:          0 :     m_xMoveOperations = Reference< ::com::sun::star::sdbc::XResultSet>(_rxCursor, UNO_QUERY);
     295         [ #  # ]:          0 :     m_xBookmarkOperations = Reference< ::com::sun::star::sdbcx::XRowLocate>(_rxCursor, UNO_QUERY);
     296         [ #  # ]:          0 :     m_xColumnsSupplier = Reference< ::com::sun::star::sdbcx::XColumnsSupplier>(_rxCursor, UNO_QUERY);
     297 [ #  # ][ #  # ]:          0 :     if (!m_xMoveOperations.is() || !m_xBookmarkOperations.is() || !m_xColumnsSupplier.is())
         [ #  # ][ #  # ]
     298                 :            :     {   // all or nothing !!
     299                 :          0 :         m_xMoveOperations = NULL;
     300                 :          0 :         m_xBookmarkOperations = NULL;
     301                 :          0 :         m_xColumnsSupplier = NULL;
     302                 :            :     }
     303                 :          0 :     return *this;
     304                 :            : }
     305                 :            : 
     306                 :            : //------------------------------------------------------------------------------
     307                 :          2 : FmXDisposeListener::~FmXDisposeListener()
     308                 :            : {
     309                 :          2 :     setAdapter(NULL);
     310         [ -  + ]:          2 : }
     311                 :            : 
     312                 :            : //------------------------------------------------------------------------------
     313                 :          6 : void FmXDisposeListener::setAdapter(FmXDisposeMultiplexer* pAdapter)
     314                 :            : {
     315         [ +  + ]:          6 :     if (m_pAdapter)
     316                 :            :     {
     317         [ +  - ]:          2 :         ::osl::MutexGuard aGuard(m_rMutex);
     318                 :          2 :         m_pAdapter->release();
     319         [ +  - ]:          2 :         m_pAdapter = NULL;
     320                 :            :     }
     321                 :            : 
     322         [ +  + ]:          6 :     if (pAdapter)
     323                 :            :     {
     324         [ +  - ]:          2 :         ::osl::MutexGuard aGuard(m_rMutex);
     325                 :          2 :         m_pAdapter = pAdapter;
     326         [ +  - ]:          2 :         m_pAdapter->acquire();
     327                 :            :     }
     328                 :          6 : }
     329                 :            : 
     330                 :            : //==============================================================================
     331                 :            : DBG_NAME(FmXDisposeMultiplexer);
     332                 :            : //------------------------------------------------------------------------------
     333                 :          2 : FmXDisposeMultiplexer::FmXDisposeMultiplexer(FmXDisposeListener* _pListener, const Reference< ::com::sun::star::lang::XComponent>& _rxObject, sal_Int16 _nId)
     334                 :            :     :m_xObject(_rxObject)
     335                 :            :     ,m_pListener(_pListener)
     336                 :          2 :     ,m_nId(_nId)
     337                 :            : {
     338                 :            :     DBG_CTOR(FmXDisposeMultiplexer, NULL);
     339         [ +  - ]:          2 :     m_pListener->setAdapter(this);
     340                 :            : 
     341         [ +  - ]:          2 :     if (m_xObject.is())
     342 [ +  - ][ +  - ]:          2 :         m_xObject->addEventListener(this);
                 [ +  - ]
     343                 :          2 : }
     344                 :            : 
     345                 :            : //------------------------------------------------------------------------------
     346                 :          2 : FmXDisposeMultiplexer::~FmXDisposeMultiplexer()
     347                 :            : {
     348                 :            :     DBG_DTOR(FmXDisposeMultiplexer, NULL);
     349         [ -  + ]:          4 : }
     350                 :            : 
     351                 :            : // ::com::sun::star::lang::XEventListener
     352                 :            : //------------------------------------------------------------------
     353                 :          2 : void FmXDisposeMultiplexer::disposing(const ::com::sun::star::lang::EventObject& _Source) throw( RuntimeException )
     354                 :            : {
     355         [ +  - ]:          2 :     Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
     356                 :            : 
     357         [ +  - ]:          2 :     if (m_pListener)
     358                 :            :     {
     359         [ +  - ]:          2 :         m_pListener->disposing(_Source, m_nId);
     360         [ +  - ]:          2 :         m_pListener->setAdapter(NULL);
     361                 :          2 :         m_pListener = NULL;
     362                 :            :     }
     363         [ +  - ]:          2 :     m_xObject = NULL;
     364                 :          2 : }
     365                 :            : 
     366                 :            : //------------------------------------------------------------------
     367                 :          2 : void FmXDisposeMultiplexer::dispose()
     368                 :            : {
     369         [ -  + ]:          2 :     if (m_xObject.is())
     370                 :            :     {
     371         [ #  # ]:          0 :         Reference< ::com::sun::star::lang::XEventListener> xPreventDelete(this);
     372                 :            : 
     373 [ #  # ][ #  # ]:          0 :         m_xObject->removeEventListener(this);
                 [ #  # ]
     374         [ #  # ]:          0 :         m_xObject = NULL;
     375                 :            : 
     376         [ #  # ]:          0 :         m_pListener->setAdapter(NULL);
     377                 :          0 :         m_pListener = NULL;
     378                 :            :     }
     379                 :          2 : }
     380                 :            : 
     381                 :            : //==============================================================================
     382                 :            : //------------------------------------------------------------------------------
     383                 :          0 : sal_Int16 getControlTypeByObject(const Reference< ::com::sun::star::lang::XServiceInfo>& _rxObject)
     384                 :            : {
     385                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::getControlTypeByObject" );
     386                 :            :     // ask for the persistent service name
     387         [ #  # ]:          0 :     Reference< ::com::sun::star::io::XPersistObject> xPersistence(_rxObject, UNO_QUERY);
     388                 :            :     DBG_ASSERT(xPersistence.is(), "::getControlTypeByObject : argument shold be an ::com::sun::star::io::XPersistObject !");
     389         [ #  # ]:          0 :     if (!xPersistence.is())
     390                 :          0 :         return OBJ_FM_CONTROL;
     391                 :            : 
     392 [ #  # ][ #  # ]:          0 :     ::rtl::OUString sPersistentServiceName = xPersistence->getServiceName();
     393 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_EDIT))   // 5.0-Name
     394                 :            :     {
     395                 :            :         // may be a simple edit field or a formatted field, dependent of the supported services
     396 [ #  # ][ #  # ]:          0 :         if (_rxObject->supportsService(FM_SUN_COMPONENT_FORMATTEDFIELD))
         [ #  # ][ #  # ]
     397                 :          0 :             return OBJ_FM_FORMATTEDFIELD;
     398                 :          0 :         return OBJ_FM_EDIT;
     399                 :            :     }
     400 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_TEXTFIELD))
     401                 :          0 :         return OBJ_FM_EDIT;
     402 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_COMMANDBUTTON))
     403                 :          0 :         return OBJ_FM_BUTTON;
     404 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_FIXEDTEXT))
     405                 :          0 :         return OBJ_FM_FIXEDTEXT;
     406 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_LISTBOX))
     407                 :          0 :         return OBJ_FM_LISTBOX;
     408 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_CHECKBOX))
     409                 :          0 :         return OBJ_FM_CHECKBOX;
     410 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_RADIOBUTTON))
     411                 :          0 :         return OBJ_FM_RADIOBUTTON;
     412 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_GROUPBOX))
     413                 :          0 :         return OBJ_FM_GROUPBOX;
     414 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_COMBOBOX))
     415                 :          0 :         return OBJ_FM_COMBOBOX;
     416 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_GRID))   // 5.0-Name
     417                 :          0 :         return OBJ_FM_GRID;
     418 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_GRIDCONTROL))
     419                 :          0 :         return OBJ_FM_GRID;
     420 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_IMAGEBUTTON))
     421                 :          0 :         return OBJ_FM_IMAGEBUTTON;
     422 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_FILECONTROL))
     423                 :          0 :         return OBJ_FM_FILECONTROL;
     424 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_DATEFIELD))
     425                 :          0 :         return OBJ_FM_DATEFIELD;
     426 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_TIMEFIELD))
     427                 :          0 :         return OBJ_FM_TIMEFIELD;
     428 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_NUMERICFIELD))
     429                 :          0 :         return OBJ_FM_NUMERICFIELD;
     430 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_CURRENCYFIELD))
     431                 :          0 :         return OBJ_FM_CURRENCYFIELD;
     432 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_PATTERNFIELD))
     433                 :          0 :         return OBJ_FM_PATTERNFIELD;
     434 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_HIDDEN)) // 5.0-Name
     435                 :          0 :         return OBJ_FM_HIDDEN;
     436 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_HIDDENCONTROL))
     437                 :          0 :         return OBJ_FM_HIDDEN;
     438 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_IMAGECONTROL))
     439                 :          0 :         return OBJ_FM_IMAGECONTROL;
     440 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_COMPONENT_FORMATTEDFIELD))
     441                 :            :     {
     442                 :            :         OSL_FAIL("::getControlTypeByObject : suspicious persistent service name (formatted field) !");
     443                 :            :             // objects with that service name should exist as they aren't compatible with older versions
     444                 :          0 :         return OBJ_FM_FORMATTEDFIELD;
     445                 :            :     }
     446 [ #  # ][ #  # ]:          0 :     if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SCROLLBAR ) )
     447                 :          0 :         return OBJ_FM_SCROLLBAR;
     448 [ #  # ][ #  # ]:          0 :     if ( sPersistentServiceName.equals( FM_SUN_COMPONENT_SPINBUTTON) )
     449                 :          0 :         return OBJ_FM_SPINBUTTON;
     450 [ #  # ][ #  # ]:          0 :     if (sPersistentServiceName.equals(FM_SUN_COMPONENT_NAVIGATIONBAR))
     451                 :          0 :         return OBJ_FM_NAVIGATIONBAR;
     452                 :            : 
     453                 :            :     OSL_FAIL("::getControlTypeByObject : unknown object type !");
     454                 :          0 :     return OBJ_FM_CONTROL;
     455                 :            : }
     456                 :            : 
     457                 :            : //------------------------------------------------------------------------------
     458                 :          0 : sal_Bool isRowSetAlive(const Reference< XInterface >& _rxRowSet)
     459                 :            : {
     460                 :            :     RTL_LOGFILE_CONTEXT_AUTHOR( aLogger, "svx", "Ocke.Janssen@sun.com", "fmtools::isRowSetAlive" );
     461                 :          0 :     sal_Bool bIsAlive = sal_False;
     462         [ #  # ]:          0 :     Reference< ::com::sun::star::sdbcx::XColumnsSupplier> xSupplyCols(_rxRowSet, UNO_QUERY);
     463                 :          0 :     Reference< ::com::sun::star::container::XIndexAccess> xCols;
     464         [ #  # ]:          0 :     if (xSupplyCols.is())
     465 [ #  # ][ #  # ]:          0 :         xCols = Reference< ::com::sun::star::container::XIndexAccess>(xSupplyCols->getColumns(), UNO_QUERY);
         [ #  # ][ #  # ]
     466 [ #  # ][ #  # ]:          0 :     if (xCols.is() && (xCols->getCount() > 0))
         [ #  # ][ #  # ]
                 [ #  # ]
     467                 :          0 :         bIsAlive = sal_True;
     468                 :            : 
     469                 :          0 :     return bIsAlive;
     470                 :            : }
     471                 :            : 
     472                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10