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

Generated by: LCOV version 1.11