LCOV - code coverage report
Current view: top level - dbaccess/source/ui/control - ColumnControlWindow.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 59 1.7 %
Date: 2015-06-13 12:38:46 Functions: 2 16 12.5 %
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 "ColumnControlWindow.hxx"
      21             : #include "FieldControls.hxx"
      22             : #include <unotools/syslocale.hxx>
      23             : #include <connectivity/dbtools.hxx>
      24             : #include "UITools.hxx"
      25             : #include "dbu_resource.hrc"
      26             : #include <comphelper/processfactory.hxx>
      27             : #include <com/sun/star/util/NumberFormatter.hpp>
      28             : 
      29             : using namespace ::dbaui;
      30             : using namespace ::com::sun::star::uno;
      31             : using namespace ::com::sun::star::beans;
      32             : using namespace ::com::sun::star::container;
      33             : using namespace ::com::sun::star::util;
      34             : using namespace ::com::sun::star::sdbc;
      35             : using namespace ::com::sun::star::lang;
      36             : 
      37             : // OColumnControlWindow
      38           0 : OColumnControlWindow::OColumnControlWindow(vcl::Window* pParent
      39             :                                            ,const Reference<XComponentContext>& _rxContext)
      40             :             : OFieldDescControl(pParent,NULL)
      41             :             , m_xContext(_rxContext)
      42             :             , m_sTypeNames(ModuleRes(STR_TABLEDESIGN_DBFIELDTYPES))
      43           0 :             , m_bAutoIncrementEnabled(true)
      44             : {
      45             : 
      46           0 :     setRightAligned();
      47           0 :     m_aLocale = SvtSysLocale().GetLanguageTag().getLocale();
      48           0 : }
      49             : 
      50           0 : void OColumnControlWindow::ActivateAggregate( EControlType eType )
      51             : {
      52           0 :     switch(eType )
      53             :     {
      54             :         case tpFormat:
      55             :         case tpDefault:
      56             :         case tpColumnName:
      57           0 :             break;
      58             :         default:
      59           0 :             OFieldDescControl::ActivateAggregate( eType );
      60             :     }
      61           0 : }
      62             : 
      63           0 : void OColumnControlWindow::DeactivateAggregate( EControlType eType )
      64             : {
      65           0 :     switch(eType )
      66             :     {
      67             :         case tpFormat:
      68             :         case tpDefault:
      69             :         case tpColumnName:
      70           0 :             break;
      71             :         default:
      72           0 :             OFieldDescControl::DeactivateAggregate( eType );
      73             :     }
      74           0 : }
      75             : 
      76           0 : void OColumnControlWindow::CellModified(long /*nRow*/, sal_uInt16 /*nColId*/ )
      77             : {
      78           0 :     saveCurrentFieldDescData();
      79           0 : }
      80             : 
      81           0 : ::com::sun::star::lang::Locale  OColumnControlWindow::GetLocale() const
      82             : {
      83           0 :     return m_aLocale;
      84             : }
      85             : 
      86           0 : Reference< XNumberFormatter > OColumnControlWindow::GetFormatter() const
      87             : {
      88           0 :     if ( !m_xFormatter.is() )
      89             :         try
      90             :         {
      91           0 :             Reference< XNumberFormatsSupplier >  xSupplier(::dbtools::getNumberFormats(m_xConnection, true, m_xContext));
      92             : 
      93           0 :             if ( xSupplier.is() )
      94             :             {
      95             :                 // create a new formatter
      96           0 :                 m_xFormatter.set( NumberFormatter::create(m_xContext), UNO_QUERY_THROW);
      97           0 :                 m_xFormatter->attachNumberFormatsSupplier(xSupplier);
      98           0 :             }
      99             :         }
     100           0 :         catch(Exception&)
     101             :         {
     102             :         }
     103           0 :     return m_xFormatter;
     104             : }
     105             : 
     106           0 : TOTypeInfoSP OColumnControlWindow::getTypeInfo(sal_Int32 _nPos)
     107             : {
     108           0 :     return ( _nPos >= 0 && _nPos < static_cast<sal_Int32>(m_aDestTypeInfoIndex.size())) ? m_aDestTypeInfoIndex[_nPos]->second : TOTypeInfoSP();
     109             : }
     110             : 
     111           0 : const OTypeInfoMap* OColumnControlWindow::getTypeInfo() const
     112             : {
     113           0 :     return &m_aDestTypeInfo;
     114             : }
     115             : 
     116           0 : Reference< XDatabaseMetaData> OColumnControlWindow::getMetaData()
     117             : {
     118           0 :     if ( m_xConnection.is() )
     119           0 :         return m_xConnection->getMetaData();
     120           0 :     return Reference< XDatabaseMetaData>();
     121             : }
     122             : 
     123           0 : Reference< XConnection> OColumnControlWindow::getConnection()
     124             : {
     125           0 :     return m_xConnection;
     126             : }
     127             : 
     128           0 : void OColumnControlWindow::setConnection(const Reference< XConnection>& _xCon)
     129             : {
     130           0 :     m_xConnection = _xCon;
     131           0 :     m_xFormatter = NULL;
     132           0 :     m_aDestTypeInfoIndex.clear();
     133           0 :     m_aDestTypeInfo.clear();
     134             : 
     135           0 :     if ( m_xConnection.is() )
     136             :     {
     137           0 :         Init();
     138             : 
     139           0 :         ::dbaui::fillTypeInfo(m_xConnection,m_sTypeNames,m_aDestTypeInfo,m_aDestTypeInfoIndex);
     140             :         // read autoincrement value set in the datasource
     141           0 :         ::dbaui::fillAutoIncrementValue(m_xConnection,m_bAutoIncrementEnabled,m_sAutoIncrementValue);
     142             :     }
     143           0 : }
     144             : 
     145           0 : bool OColumnControlWindow::isAutoIncrementValueEnabled() const
     146             : {
     147           0 :     return m_bAutoIncrementEnabled;
     148             : }
     149             : 
     150           0 : OUString OColumnControlWindow::getAutoIncrementValue() const
     151             : {
     152           0 :     return m_sAutoIncrementValue;
     153             : }
     154             : 
     155           0 : TOTypeInfoSP OColumnControlWindow::getDefaultTyp() const
     156             : {
     157           0 :     if ( !m_pTypeInfo.get() )
     158             :     {
     159           0 :         m_pTypeInfo = TOTypeInfoSP(new OTypeInfo());
     160           0 :         m_pTypeInfo->aUIName = m_sTypeNames.getToken(TYPE_OTHER, ';');
     161             :     }
     162           0 :     return m_pTypeInfo;
     163          36 : }
     164             : 
     165             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11