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

Generated by: LCOV version 1.10