LCOV - code coverage report
Current view: top level - libreoffice/dbaccess/source/ui/uno - ColumnPeer.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 69 0.0 %
Date: 2012-12-27 Functions: 0 6 0.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 "ColumnPeer.hxx"
      21             : #include "ColumnControlWindow.hxx"
      22             : #include <vcl/svapp.hxx>
      23             : #include "dbustrings.hrc"
      24             : #include "FieldDescriptions.hxx"
      25             : 
      26             : //.........................................................................
      27             : namespace dbaui
      28             : {
      29             : //.........................................................................
      30             : using namespace ::com::sun::star::awt;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::beans;
      33             : using namespace ::com::sun::star::lang;
      34             : using namespace ::com::sun::star::sdbc;
      35             : 
      36           0 : OColumnPeer::OColumnPeer(Window* _pParent,const Reference<XComponentContext>& _rxContext)
      37           0 :     :m_pActFieldDescr(NULL)
      38             : {
      39           0 :     osl_atomic_increment( &m_refCount );
      40             :     {
      41           0 :         OColumnControlWindow* pFieldControl = new OColumnControlWindow(_pParent, _rxContext);
      42           0 :         pFieldControl->SetComponentInterface(this);
      43           0 :         pFieldControl->Show();
      44             :     }
      45           0 :     osl_atomic_decrement( &m_refCount );
      46           0 : }
      47             : // -----------------------------------------------------------------------------
      48           0 : void OColumnPeer::setEditWidth(sal_Int32 _nWidth)
      49             : {
      50           0 :     SolarMutexGuard aGuard;
      51             : 
      52           0 :     OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
      53           0 :     if ( pFieldControl )
      54             :     {
      55           0 :         pFieldControl->setEditWidth(_nWidth);
      56           0 :     }
      57           0 : }
      58             : // -----------------------------------------------------------------------------
      59           0 : void OColumnPeer::setColumn(const Reference< XPropertySet>& _xColumn)
      60             : {
      61           0 :     SolarMutexGuard aGuard;
      62             : 
      63           0 :     OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
      64           0 :     if ( pFieldControl )
      65             :     {
      66           0 :         if ( m_pActFieldDescr )
      67             :         {
      68           0 :             delete m_pActFieldDescr;
      69           0 :             m_pActFieldDescr = NULL;
      70             :         }
      71           0 :         if ( _xColumn.is() )
      72             :         {
      73           0 :             sal_Int32 nType         = 0;
      74           0 :             sal_Int32 nScale        = 0;
      75           0 :             sal_Int32 nPrecision    = 0;
      76           0 :             sal_Bool bAutoIncrement = sal_False;
      77           0 :             ::rtl::OUString sTypeName;
      78             : 
      79             :             try
      80             :             {
      81             :                 // get the properties from the column
      82           0 :                 _xColumn->getPropertyValue(PROPERTY_TYPENAME)       >>= sTypeName;
      83           0 :                 _xColumn->getPropertyValue(PROPERTY_TYPE)           >>= nType;
      84           0 :                 _xColumn->getPropertyValue(PROPERTY_SCALE)          >>= nScale;
      85           0 :                 _xColumn->getPropertyValue(PROPERTY_PRECISION)      >>= nPrecision;
      86           0 :                 _xColumn->getPropertyValue(PROPERTY_ISAUTOINCREMENT)    >>= bAutoIncrement;
      87             :             }
      88           0 :             catch(const Exception&)
      89             :             {
      90             :             }
      91             : 
      92           0 :             m_pActFieldDescr = new OFieldDescription(_xColumn,sal_True);
      93             :             // search for type
      94           0 :             ::rtl::OUString sCreateParam(RTL_CONSTASCII_USTRINGPARAM("x"));
      95             :             sal_Bool bForce;
      96           0 :             TOTypeInfoSP pTypeInfo = ::dbaui::getTypeInfoFromType(*pFieldControl->getTypeInfo(),nType,sTypeName,sCreateParam,nPrecision,nScale,bAutoIncrement,bForce);
      97           0 :             if ( !pTypeInfo.get() )
      98           0 :                 pTypeInfo = pFieldControl->getDefaultTyp();
      99             : 
     100           0 :             m_pActFieldDescr->FillFromTypeInfo(pTypeInfo,sal_True,sal_False);
     101           0 :             m_xColumn = _xColumn;
     102             :         }
     103           0 :         pFieldControl->DisplayData(m_pActFieldDescr);
     104           0 :     }
     105           0 : }
     106             : // -----------------------------------------------------------------------------
     107           0 : void OColumnPeer::setConnection(const Reference< XConnection>& _xCon)
     108             : {
     109           0 :     SolarMutexGuard aGuard;
     110           0 :     OColumnControlWindow* pFieldControl = static_cast<OColumnControlWindow*>( GetWindow() );
     111           0 :     if ( pFieldControl )
     112           0 :         pFieldControl->setConnection(_xCon);
     113           0 : }
     114             : //------------------------------------------------------------------------------
     115           0 : void OColumnPeer::setProperty( const ::rtl::OUString& _rPropertyName, const Any& Value) throw( RuntimeException )
     116             : {
     117           0 :     SolarMutexGuard aGuard;
     118             : 
     119           0 :     if (_rPropertyName.equalsAsciiL(PROPERTY_COLUMN.ascii, PROPERTY_COLUMN.length) )
     120             :     {
     121           0 :         Reference<XPropertySet> xProp(Value,UNO_QUERY);
     122           0 :         setColumn(xProp);
     123             :     }
     124           0 :     else if (_rPropertyName.equalsAsciiL(PROPERTY_ACTIVE_CONNECTION.ascii, PROPERTY_ACTIVE_CONNECTION.length) )
     125             :     {
     126           0 :         Reference<XConnection> xCon(Value,UNO_QUERY);
     127           0 :         setConnection(xCon);
     128             :     }
     129             :     else
     130           0 :         VCLXWindow::setProperty(_rPropertyName,Value);
     131           0 : }
     132             : // -----------------------------------------------------------------------------
     133           0 : Any OColumnPeer::getProperty( const ::rtl::OUString& _rPropertyName ) throw( RuntimeException )
     134             : {
     135           0 :     Any aProp;
     136           0 :     OFieldDescControl* pFieldControl = static_cast<OFieldDescControl*>( GetWindow() );
     137           0 :     if (pFieldControl && _rPropertyName.equalsAsciiL(PROPERTY_COLUMN.ascii, PROPERTY_COLUMN.length))
     138             :     {
     139           0 :         aProp <<= m_xColumn;
     140             :     }
     141           0 :     else if (pFieldControl && _rPropertyName.equalsAsciiL(PROPERTY_ACTIVE_CONNECTION.ascii, PROPERTY_ACTIVE_CONNECTION.length))
     142             :     {
     143           0 :         aProp <<= pFieldControl->getConnection();
     144             :     }
     145             :     else
     146           0 :         aProp = VCLXWindow::getProperty(_rPropertyName);
     147           0 :     return aProp;
     148             : }
     149             : //.........................................................................
     150             : }   // namespace dbaui
     151             : //.........................................................................
     152             : 
     153             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10