LCOV - code coverage report
Current view: top level - dbaccess/source/ui/querydesign - TableWindowData.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 50 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 116 0.0 %

           Branch data     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 "TableWindowData.hxx"
      21                 :            : #include <tools/debug.hxx>
      22                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      23                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      24                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      25                 :            : #include <com/sun/star/sdbcx/XKeysSupplier.hpp>
      26                 :            : #include <com/sun/star/container/XNameAccess.hpp>
      27                 :            : #include <com/sun/star/container/XIndexAccess.hpp>
      28                 :            : 
      29                 :            : using namespace dbaui;
      30                 :            : using namespace ::com::sun::star::lang;
      31                 :            : using namespace ::com::sun::star::uno;
      32                 :            : using namespace ::com::sun::star::sdb;
      33                 :            : using namespace ::com::sun::star::sdbc;
      34                 :            : using namespace ::com::sun::star::sdbcx;
      35                 :            : using namespace ::com::sun::star::beans;
      36                 :            : using namespace ::com::sun::star::container;
      37                 :            : 
      38                 :            : //==================================================================
      39                 :            : // class OTableWindowData
      40                 :            : //==================================================================
      41                 :            : DBG_NAME(OTableWindowData)
      42                 :            : //------------------------------------------------------------------------------
      43                 :          0 : OTableWindowData::OTableWindowData( const Reference< XPropertySet>& _xTable
      44                 :            :                                    ,const ::rtl::OUString& _rComposedName
      45                 :            :                                    ,const ::rtl::OUString& rTableName
      46                 :            :                                    ,const ::rtl::OUString& rWinName )
      47                 :            :     :m_xTable(_xTable)
      48                 :            :     ,m_aTableName( rTableName )
      49                 :            :     ,m_aWinName( rWinName )
      50                 :            :     ,m_sComposedName(_rComposedName)
      51                 :            :     ,m_aPosition( Point(-1,-1) )
      52                 :            :     ,m_aSize( Size(-1,-1) )
      53                 :            :     ,m_bShowAll( sal_True )
      54                 :            :     ,m_bIsQuery(false)
      55         [ #  # ]:          0 :     ,m_bIsValid(true)
      56                 :            : {
      57                 :            :     DBG_CTOR(OTableWindowData,NULL);
      58         [ #  # ]:          0 :     if( m_aWinName.isEmpty() )
      59                 :          0 :         m_aWinName = m_aTableName;
      60                 :            : 
      61         [ #  # ]:          0 :     listen();
      62                 :          0 : }
      63                 :            : 
      64                 :            : //------------------------------------------------------------------------------
      65         [ #  # ]:          0 : OTableWindowData::~OTableWindowData()
      66                 :            : {
      67                 :            :     DBG_DTOR(OTableWindowData,NULL);
      68         [ #  # ]:          0 :     Reference<XComponent> xComponent( m_xTable, UNO_QUERY );
      69         [ #  # ]:          0 :     if ( xComponent.is() )
      70         [ #  # ]:          0 :         stopComponentListening( xComponent );
      71         [ #  # ]:          0 : }
      72                 :            : 
      73                 :            : //------------------------------------------------------------------------------
      74                 :          0 : sal_Bool OTableWindowData::HasPosition() const
      75                 :            : {
      76 [ #  # ][ #  # ]:          0 :     return ( (m_aPosition.X() != -1) && (m_aPosition.Y() != -1) );
      77                 :            : }
      78                 :            : 
      79                 :            : //------------------------------------------------------------------------------
      80                 :          0 : sal_Bool OTableWindowData::HasSize() const
      81                 :            : {
      82 [ #  # ][ #  # ]:          0 :     return ( (m_aSize.Width() != -1) && (m_aSize.Height() !=-1) );
      83                 :            : }
      84                 :            : // -----------------------------------------------------------------------------
      85                 :          0 : void OTableWindowData::_disposing( const ::com::sun::star::lang::EventObject& /*_rSource*/ )
      86                 :            : {
      87         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
      88                 :            :     // it doesn't matter which one was disposed
      89                 :          0 :     m_xColumns.clear();
      90                 :          0 :     m_xKeys.clear();
      91         [ #  # ]:          0 :     m_xTable.clear();
      92                 :          0 : }
      93                 :            : // -----------------------------------------------------------------------------
      94                 :          0 : bool OTableWindowData::init(const Reference< XConnection  >& _xConnection,bool _bAllowQueries)
      95                 :            : {
      96                 :            :     OSL_ENSURE(!m_xTable.is(),"We are already connected to a table!");
      97                 :            : 
      98         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
      99                 :            : 
     100         [ #  # ]:          0 :     Reference< XQueriesSupplier > xSupQueries( _xConnection, UNO_QUERY_THROW );
     101 [ #  # ][ #  # ]:          0 :     Reference< XNameAccess > xQueries( xSupQueries->getQueries(), UNO_QUERY_THROW );
                 [ #  # ]
     102 [ #  # ][ #  # ]:          0 :     bool bIsKnownQuery = _bAllowQueries && xQueries->hasByName( m_sComposedName );
         [ #  # ][ #  # ]
     103                 :            : 
     104         [ #  # ]:          0 :     Reference< XTablesSupplier > xSupTables( _xConnection, UNO_QUERY_THROW );
     105 [ #  # ][ #  # ]:          0 :     Reference< XNameAccess > xTables( xSupTables->getTables(), UNO_QUERY_THROW );
                 [ #  # ]
     106 [ #  # ][ #  # ]:          0 :     bool bIsKnownTable = xTables->hasByName( m_sComposedName );
     107                 :            : 
     108         [ #  # ]:          0 :     if ( bIsKnownQuery )
     109 [ #  # ][ #  # ]:          0 :         m_xTable.set( xQueries->getByName( m_sComposedName ), UNO_QUERY );
                 [ #  # ]
     110         [ #  # ]:          0 :     else if ( bIsKnownTable )
     111 [ #  # ][ #  # ]:          0 :         m_xTable.set( xTables->getByName( m_sComposedName ), UNO_QUERY );
                 [ #  # ]
     112                 :            :     else
     113                 :          0 :         m_bIsValid = false;
     114                 :            : 
     115                 :            :     // if we survived so far, we know whether it's a query
     116                 :          0 :     m_bIsQuery = bIsKnownQuery;
     117                 :            : 
     118         [ #  # ]:          0 :     listen();
     119                 :            : 
     120         [ #  # ]:          0 :     Reference< XIndexAccess > xColumnsAsIndex( m_xColumns,UNO_QUERY );
     121 [ #  # ][ #  # ]:          0 :     return xColumnsAsIndex.is() && ( xColumnsAsIndex->getCount() > 0 );
         [ #  # ][ #  # ]
                 [ #  # ]
     122                 :            : }
     123                 :            : // -----------------------------------------------------------------------------
     124                 :          0 : void OTableWindowData::listen()
     125                 :            : {
     126         [ #  # ]:          0 :     if ( m_xTable.is() )
     127                 :            :     {
     128                 :            :         // listen for the object being disposed
     129         [ #  # ]:          0 :         Reference<XComponent> xComponent( m_xTable, UNO_QUERY );
     130         [ #  # ]:          0 :         if ( xComponent.is() )
     131         [ #  # ]:          0 :             startComponentListening( xComponent );
     132                 :            : 
     133                 :            :         // obtain the columns
     134         [ #  # ]:          0 :         Reference< XColumnsSupplier > xColumnsSups( m_xTable, UNO_QUERY);
     135         [ #  # ]:          0 :         if ( xColumnsSups.is() )
     136 [ #  # ][ #  # ]:          0 :             m_xColumns = xColumnsSups->getColumns();
                 [ #  # ]
     137                 :            : 
     138         [ #  # ]:          0 :         Reference<XKeysSupplier> xKeySup(m_xTable,UNO_QUERY);
     139         [ #  # ]:          0 :         if ( xKeySup.is() )
     140 [ #  # ][ #  # ]:          0 :             m_xKeys = xKeySup->getKeys();
                 [ #  # ]
     141                 :            :     }
     142                 :          0 : }
     143                 :            : // -----------------------------------------------------------------------------
     144                 :            : 
     145                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10