LCOV - code coverage report
Current view: top level - svx/source/fmcomp - gridcell.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 474 2302 20.6 %
Date: 2012-08-25 Functions: 74 406 18.2 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 464 4667 9.9 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include <sal/macros.h>
      31                 :            : #include "fmprop.hrc"
      32                 :            : #include "svx/fmresids.hrc"
      33                 :            : #include "svx/fmtools.hxx"
      34                 :            : #include "gridcell.hxx"
      35                 :            : #include "gridcols.hxx"
      36                 :            : #include "sdbdatacolumn.hxx"
      37                 :            : 
      38                 :            : #include <com/sun/star/awt/LineEndFormat.hpp>
      39                 :            : #include <com/sun/star/awt/MouseWheelBehavior.hpp>
      40                 :            : #include <com/sun/star/awt/VisualEffect.hpp>
      41                 :            : #include <com/sun/star/container/XChild.hpp>
      42                 :            : #include <com/sun/star/container/XNamed.hpp>
      43                 :            : #include <com/sun/star/form/FormComponentType.hpp>
      44                 :            : #include <com/sun/star/form/XBoundComponent.hpp>
      45                 :            : #include <com/sun/star/script/XEventAttacherManager.hpp>
      46                 :            : #include <com/sun/star/sdb/XSQLQueryComposerFactory.hpp>
      47                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      48                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      49                 :            : #include <com/sun/star/sdbc/ColumnValue.hpp>
      50                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      51                 :            : #include <com/sun/star/sdbc/XStatement.hpp>
      52                 :            : #include <com/sun/star/util/NumberFormat.hpp>
      53                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      54                 :            : #include <com/sun/star/util/XNumberFormatter.hpp>
      55                 :            : 
      56                 :            : #include <comphelper/extract.hxx>
      57                 :            : #include <comphelper/numbers.hxx>
      58                 :            : #include <comphelper/property.hxx>
      59                 :            : #include <comphelper/servicehelper.hxx>
      60                 :            : #include <comphelper/string.hxx>
      61                 :            : #include <connectivity/formattedcolumnvalue.hxx>
      62                 :            : #include <cppuhelper/typeprovider.hxx>
      63                 :            : #include <i18npool/lang.h>
      64                 :            : 
      65                 :            : #include <rtl/math.hxx>
      66                 :            : #include <svtools/calendar.hxx>
      67                 :            : #include <svtools/fmtfield.hxx>
      68                 :            : #include <svl/numuno.hxx>
      69                 :            : #include <svtools/svmedit.hxx>
      70                 :            : #include <svx/dialmgr.hxx>
      71                 :            : #include <toolkit/helper/vclunohelper.hxx>
      72                 :            : #include <tools/diagnose_ex.h>
      73                 :            : #include <tools/shl.hxx>
      74                 :            : #include <vcl/longcurr.hxx>
      75                 :            : 
      76                 :            : #include <math.h>
      77                 :            : #include <stdio.h>
      78                 :            : 
      79                 :            : using namespace ::connectivity;
      80                 :            : using namespace ::connectivity::simple;
      81                 :            : using namespace ::svxform;
      82                 :            : using namespace ::comphelper;
      83                 :            : using namespace ::svt;
      84                 :            : using namespace ::com::sun::star;
      85                 :            : using namespace ::com::sun::star::uno;
      86                 :            : using namespace ::com::sun::star::sdbc;
      87                 :            : using namespace ::com::sun::star::sdbcx;
      88                 :            : using namespace ::com::sun::star::sdb;
      89                 :            : using namespace ::com::sun::star::beans;
      90                 :            : using namespace ::com::sun::star::form;
      91                 :            : 
      92                 :            : using ::com::sun::star::util::XNumberFormatter;
      93                 :            : namespace MouseWheelBehavior = ::com::sun::star::awt::MouseWheelBehavior;
      94                 :            : 
      95                 :            : const char INVALIDTEXT[] = "###";
      96                 :            : const char OBJECTTEXT[] = "<OBJECT>";
      97                 :            : 
      98                 :            : //==================================================================
      99                 :            : //= helper
     100                 :            : //==================================================================
     101                 :            : namespace
     102                 :            : {
     103                 :          0 :     static LineEnd getModelLineEndSetting( const Reference< XPropertySet >& _rxModel )
     104                 :            :     {
     105                 :          0 :         LineEnd eFormat = LINEEND_LF;
     106                 :            : 
     107                 :            :         try
     108                 :            :         {
     109                 :          0 :             sal_Int16 nLineEndFormat = awt::LineEndFormat::LINE_FEED;
     110                 :            : 
     111                 :          0 :             Reference< XPropertySetInfo > xPSI;
     112         [ #  # ]:          0 :             if ( _rxModel.is() )
     113 [ #  # ][ #  # ]:          0 :                 xPSI = _rxModel->getPropertySetInfo();
                 [ #  # ]
     114                 :            : 
     115                 :            :             OSL_ENSURE( xPSI.is(), "getModelLineEndSetting: invalid column model!" );
     116 [ #  # ][ #  # ]:          0 :             if ( xPSI.is() && xPSI->hasPropertyByName( FM_PROP_LINEENDFORMAT ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     117                 :            :             {
     118 [ #  # ][ #  # ]:          0 :                 OSL_VERIFY( _rxModel->getPropertyValue( FM_PROP_LINEENDFORMAT ) >>= nLineEndFormat );
                 [ #  # ]
     119                 :            : 
     120   [ #  #  #  # ]:          0 :                 switch ( nLineEndFormat )
     121                 :            :                 {
     122                 :          0 :                 case awt::LineEndFormat::CARRIAGE_RETURN:            eFormat = LINEEND_CR; break;
     123                 :          0 :                 case awt::LineEndFormat::LINE_FEED:                  eFormat = LINEEND_LF; break;
     124                 :          0 :                 case awt::LineEndFormat::CARRIAGE_RETURN_LINE_FEED:  eFormat = LINEEND_CRLF; break;
     125                 :            :                 default:
     126                 :            :                     OSL_FAIL( "getModelLineEndSetting: what's this?" );
     127                 :            :                 }
     128         [ #  # ]:          0 :             }
     129                 :            :         }
     130                 :          0 :         catch( const Exception& )
     131                 :            :         {
     132                 :            :             OSL_FAIL( "getModelLineEndSetting: caught an exception!" );
     133                 :            :         }
     134                 :          0 :         return eFormat;
     135                 :            :     }
     136                 :            : }
     137                 :            : 
     138                 :            : //==================================================================
     139                 :            : //= DbGridColumn
     140                 :            : //==================================================================
     141                 :            : //------------------------------------------------------------------------------
     142                 :        150 : CellControllerRef DbGridColumn::s_xEmptyController;
     143                 :            : 
     144                 :            : //------------------------------------------------------------------------------
     145                 :         62 : void DbGridColumn::CreateControl(sal_Int32 _nFieldPos, const Reference< ::com::sun::star::beans::XPropertySet >& xField, sal_Int32 nTypeId)
     146                 :            : {
     147         [ +  - ]:         62 :     Clear();
     148                 :            : 
     149                 :         62 :     m_nTypeId = (sal_Int16)nTypeId;
     150 [ +  - ][ +  - ]:         62 :     if (xField != m_xField)
     151                 :            :     {
     152                 :            :         // Grundeinstellung
     153         [ +  - ]:         62 :         m_xField = xField;
     154 [ +  - ][ +  - ]:         62 :         xField->getPropertyValue(FM_PROP_FORMATKEY) >>= m_nFormatKey;
                 [ +  - ]
     155                 :         62 :         m_nFieldPos   = (sal_Int16)_nFieldPos;
     156 [ +  - ][ +  - ]:         62 :         m_bReadOnly   = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISREADONLY));
         [ +  - ][ +  - ]
     157 [ +  - ][ +  - ]:         62 :         m_bAutoValue  = ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_AUTOINCREMENT));
         [ +  - ][ +  - ]
     158 [ +  - ][ +  - ]:         62 :         m_nFieldType  = (sal_Int16)::comphelper::getINT32(xField->getPropertyValue(FM_PROP_FIELDTYPE));
         [ +  - ][ +  - ]
     159                 :            : 
     160      [ -  -  + ]:         62 :         switch (m_nFieldType)
     161                 :            :         {
     162                 :            :             case DataType::DATE:
     163                 :            :             case DataType::TIME:
     164                 :            :             case DataType::TIMESTAMP:
     165                 :          0 :                 m_bDateTime = sal_True;
     166                 :            : 
     167                 :            :             case DataType::BIT:
     168                 :            :             case DataType::BOOLEAN:
     169                 :            :             case DataType::TINYINT:
     170                 :            :             case DataType::SMALLINT:
     171                 :            :             case DataType::INTEGER:
     172                 :            :             case DataType::BIGINT:
     173                 :            :             case DataType::FLOAT:
     174                 :            :             case DataType::REAL:
     175                 :            :             case DataType::DOUBLE:
     176                 :            :             case DataType::NUMERIC:
     177                 :            :             case DataType::DECIMAL:
     178                 :          0 :                 m_nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
     179                 :          0 :                 m_bNumeric = sal_True;
     180                 :          0 :                 break;
     181                 :            :             default:
     182                 :         62 :                 m_nAlign = ::com::sun::star::awt::TextAlign::LEFT;
     183                 :         62 :                 break;
     184                 :            :         }
     185                 :            :     }
     186                 :            : 
     187                 :         62 :     DbCellControl* pCellControl = NULL;
     188         [ -  + ]:         62 :     if (m_rParent.IsFilterMode())
     189                 :            :     {
     190 [ #  # ][ #  # ]:          0 :         pCellControl = new DbFilterField(m_rParent.getServiceManager(),*this);
                 [ #  # ]
     191                 :            :     }
     192                 :            :     else
     193                 :            :     {
     194                 :            : 
     195   [ -  -  -  -  :         62 :         switch (nTypeId)
          -  -  -  +  -  
                   +  - ]
     196                 :            :         {
     197 [ #  # ][ #  # ]:          0 :             case TYPE_CHECKBOX: pCellControl = new DbCheckBox(*this);   break;
     198 [ #  # ][ #  # ]:          0 :             case TYPE_COMBOBOX: pCellControl = new DbComboBox(*this); break;
     199 [ #  # ][ #  # ]:          0 :             case TYPE_CURRENCYFIELD: pCellControl = new DbCurrencyField(*this); break;
     200 [ #  # ][ #  # ]:          0 :             case TYPE_DATEFIELD: pCellControl = new DbDateField(*this); break;
     201 [ #  # ][ #  # ]:          0 :             case TYPE_LISTBOX: pCellControl = new DbListBox(*this); break;
     202 [ #  # ][ #  # ]:          0 :             case TYPE_NUMERICFIELD: pCellControl = new DbNumericField(*this); break;
     203 [ #  # ][ #  # ]:          0 :             case TYPE_PATTERNFIELD: pCellControl = new DbPatternField( *this, ::comphelper::ComponentContext( m_rParent.getServiceManager() ) ); break;
         [ #  # ][ #  # ]
                 [ #  # ]
     204 [ +  - ][ +  - ]:         34 :             case TYPE_TEXTFIELD: pCellControl = new DbTextField(*this); break;
     205 [ #  # ][ #  # ]:          0 :             case TYPE_TIMEFIELD: pCellControl = new DbTimeField(*this); break;
     206 [ +  - ][ +  - ]:         28 :             case TYPE_FORMATTEDFIELD: pCellControl = new DbFormattedField(*this); break;
     207                 :            :             default:
     208                 :            :                 OSL_FAIL("DbGridColumn::CreateControl: Unknown Column");
     209                 :         62 :                 return;
     210                 :            :         }
     211                 :            : 
     212                 :            :     }
     213                 :         62 :     Reference< XRowSet >  xCur;
     214         [ +  - ]:         62 :     if (m_rParent.getDataSource())
     215 [ +  - ][ +  - ]:         62 :         xCur = Reference< XRowSet > ((Reference< XInterface >)*m_rParent.getDataSource(), UNO_QUERY);
     216                 :            :         // TODO : the cursor wrapper should use an XRowSet interface, too
     217                 :            : 
     218         [ +  - ]:         62 :     pCellControl->Init( m_rParent.GetDataWindow(), xCur );
     219                 :            : 
     220                 :            :     // now create the control wrapper
     221         [ -  + ]:         62 :     if (m_rParent.IsFilterMode())
     222         [ #  # ]:          0 :         m_pCell = new FmXFilterCell(this, pCellControl);
     223                 :            :     else
     224                 :            :     {
     225   [ -  -  -  + ]:         62 :         switch (nTypeId)
     226                 :            :         {
     227         [ #  # ]:          0 :             case TYPE_CHECKBOX: m_pCell = new FmXCheckBoxCell( this, *pCellControl );  break;
     228         [ #  # ]:          0 :             case TYPE_LISTBOX: m_pCell = new FmXListBoxCell( this, *pCellControl );    break;
     229         [ #  # ]:          0 :             case TYPE_COMBOBOX: m_pCell = new FmXComboBoxCell( this, *pCellControl );    break;
     230                 :            :             default:
     231         [ +  - ]:         62 :                 m_pCell = new FmXEditCell( this, *pCellControl );
     232                 :            :         }
     233                 :            :     }
     234                 :         62 :     m_pCell->acquire();
     235         [ +  - ]:         62 :     m_pCell->init();
     236                 :            : 
     237         [ +  - ]:         62 :     impl_toggleScriptManager_nothrow( true );
     238                 :            : 
     239                 :            :     // only if we use have a bound field, we use a a controller for displaying the
     240                 :            :     // window in the grid
     241         [ +  - ]:         62 :     if (m_xField.is())
     242 [ +  - ][ +  - ]:         62 :         m_xController = pCellControl->CreateController();
                 [ +  - ]
     243                 :            : }
     244                 :            : 
     245                 :            : //------------------------------------------------------------------------------
     246                 :        124 : void DbGridColumn::impl_toggleScriptManager_nothrow( bool _bAttach )
     247                 :            : {
     248                 :            :     try
     249                 :            :     {
     250         [ +  - ]:        124 :         Reference< container::XChild > xChild( m_xModel, UNO_QUERY_THROW );
     251 [ +  - ][ +  - ]:        124 :         Reference< script::XEventAttacherManager > xManager( xChild->getParent(), UNO_QUERY_THROW );
                 [ +  - ]
     252 [ +  - ][ +  - ]:        124 :         Reference< container::XIndexAccess > xContainer( xChild->getParent(), UNO_QUERY_THROW );
                 [ +  - ]
     253                 :            : 
     254         [ +  - ]:        124 :         sal_Int32 nIndexInParent( getElementPos( xContainer, m_xModel ) );
     255                 :            : 
     256 [ +  - ][ +  - ]:        124 :         Reference< XInterface > xCellInterface( *m_pCell, UNO_QUERY );
     257         [ +  + ]:        124 :         if ( _bAttach )
     258 [ +  - ][ +  - ]:         62 :             xManager->attach( nIndexInParent, xCellInterface, makeAny( xCellInterface ) );
                 [ +  - ]
     259                 :            :         else
     260 [ +  - ][ +  - ]:        124 :             xManager->detach( nIndexInParent, xCellInterface );
                 [ #  # ]
     261                 :            :     }
     262                 :          0 :     catch( const Exception& )
     263                 :            :     {
     264                 :            :         DBG_UNHANDLED_EXCEPTION();
     265                 :            :     }
     266                 :        124 : }
     267                 :            : 
     268                 :            : //------------------------------------------------------------------------------
     269                 :          0 : void DbGridColumn::UpdateFromField(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter)
     270                 :            : {
     271 [ #  # ][ #  # ]:          0 :     if (m_pCell && m_pCell->ISA(FmXFilterCell))
                 [ #  # ]
     272 [ #  # ][ #  # ]:          0 :         PTR_CAST(FmXFilterCell, m_pCell)->Update();
     273 [ #  # ][ #  # ]:          0 :     else if (pRow && pRow->IsValid() && m_nFieldPos >= 0 && m_pCell && pRow->HasField(m_nFieldPos))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     274                 :            :     {
     275 [ #  # ][ #  # ]:          0 :         PTR_CAST(FmXDataCell, m_pCell)->UpdateFromField( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
     276                 :            :     }
     277                 :          0 : }
     278                 :            : 
     279                 :            : //------------------------------------------------------------------------------
     280                 :          0 : sal_Bool DbGridColumn::Commit()
     281                 :            : {
     282                 :          0 :     sal_Bool bResult = sal_True;
     283 [ #  # ][ #  # ]:          0 :     if (!m_bInSave && m_pCell)
     284                 :            :     {
     285                 :          0 :         m_bInSave = sal_True;
     286                 :          0 :         bResult = m_pCell->Commit();
     287                 :            : 
     288                 :            :         // store the data into the model
     289 [ #  # ][ #  # ]:          0 :         FmXDataCell* pDataCell = PTR_CAST(FmXDataCell, m_pCell);
     290 [ #  # ][ #  # ]:          0 :         if (bResult && pDataCell)
     291                 :            :         {
     292         [ #  # ]:          0 :             Reference< ::com::sun::star::form::XBoundComponent >  xComp(m_xModel, UNO_QUERY);
     293         [ #  # ]:          0 :             if (xComp.is())
     294 [ #  # ][ #  # ]:          0 :                 bResult = xComp->commit();
     295                 :            :         }
     296                 :          0 :         m_bInSave = sal_False;
     297                 :            :     }
     298                 :          0 :     return bResult;
     299                 :            : }
     300                 :            : 
     301                 :            : //------------------------------------------------------------------------------
     302         [ +  - ]:        138 : DbGridColumn::~DbGridColumn()
     303                 :            : {
     304         [ +  - ]:        138 :     Clear();
     305                 :        138 : }
     306                 :            : 
     307                 :            : //------------------------------------------------------------------------------
     308                 :        200 : void DbGridColumn::setModel(::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >  _xModel)
     309                 :            : {
     310         [ -  + ]:        200 :     if ( m_pCell )
     311                 :          0 :         impl_toggleScriptManager_nothrow( false );
     312                 :            : 
     313                 :        200 :     m_xModel = _xModel;
     314                 :            : 
     315         [ -  + ]:        200 :     if ( m_pCell )
     316                 :          0 :         impl_toggleScriptManager_nothrow( true );
     317                 :        200 : }
     318                 :            : 
     319                 :            : //------------------------------------------------------------------------------
     320                 :        324 : void DbGridColumn::Clear()
     321                 :            : {
     322         [ +  + ]:        324 :     if ( m_pCell )
     323                 :            :     {
     324                 :         62 :         impl_toggleScriptManager_nothrow( false );
     325                 :            : 
     326                 :         62 :         m_pCell->dispose();
     327                 :         62 :         m_pCell->release();
     328                 :         62 :         m_pCell = NULL;
     329                 :            :     }
     330                 :            : 
     331                 :        324 :     m_xController = NULL;
     332                 :        324 :     m_xField = NULL;
     333                 :            : 
     334                 :        324 :     m_nFormatKey = 0;
     335                 :        324 :     m_nFieldPos = -1;
     336                 :        324 :     m_bReadOnly = sal_True;
     337                 :        324 :     m_bAutoValue = sal_False;
     338                 :        324 :     m_nFieldType = DataType::OTHER;
     339                 :        324 : }
     340                 :            : 
     341                 :            : //------------------------------------------------------------------------------
     342                 :         62 : sal_Int16 DbGridColumn::SetAlignment(sal_Int16 _nAlign)
     343                 :            : {
     344         [ -  + ]:         62 :     if (_nAlign == -1)
     345                 :            :     {   // 'Standard'
     346         [ #  # ]:          0 :         if (m_xField.is())
     347                 :            :         {
     348                 :          0 :             sal_Int32 nType = 0;
     349 [ #  # ][ #  # ]:          0 :             m_xField->getPropertyValue(FM_PROP_FIELDTYPE) >>= nType;
                 [ #  # ]
     350                 :            : 
     351      [ #  #  # ]:          0 :             switch (nType)
     352                 :            :             {
     353                 :            :                 case DataType::NUMERIC:
     354                 :            :                 case DataType::DECIMAL:
     355                 :            :                 case DataType::DOUBLE:
     356                 :            :                 case DataType::REAL:
     357                 :            :                 case DataType::BIGINT:
     358                 :            :                 case DataType::INTEGER:
     359                 :            :                 case DataType::SMALLINT:
     360                 :            :                 case DataType::TINYINT:
     361                 :            :                 case DataType::DATE:
     362                 :            :                 case DataType::TIME:
     363                 :            :                 case DataType::TIMESTAMP:
     364                 :          0 :                     _nAlign = ::com::sun::star::awt::TextAlign::RIGHT;
     365                 :          0 :                     break;
     366                 :            :                 case DataType::BIT:
     367                 :            :                 case DataType::BOOLEAN:
     368                 :          0 :                     _nAlign = ::com::sun::star::awt::TextAlign::CENTER;
     369                 :          0 :                     break;
     370                 :            :                 default:
     371                 :          0 :                     _nAlign = ::com::sun::star::awt::TextAlign::LEFT;
     372                 :          0 :                     break;
     373                 :            :             }
     374                 :            :         }
     375                 :            :         else
     376                 :          0 :             _nAlign = ::com::sun::star::awt::TextAlign::LEFT;
     377                 :            :     }
     378                 :            : 
     379                 :         62 :     m_nAlign = _nAlign;
     380 [ -  + ][ #  # ]:         62 :     if (m_pCell && m_pCell->isAlignedController())
                 [ -  + ]
     381                 :          0 :         m_pCell->AlignControl(m_nAlign);
     382                 :            : 
     383                 :         62 :     return m_nAlign;
     384                 :            : }
     385                 :            : 
     386                 :            : //------------------------------------------------------------------------------
     387                 :         62 : sal_Int16 DbGridColumn::SetAlignmentFromModel(sal_Int16 nStandardAlign)
     388                 :            : {
     389 [ +  - ][ +  - ]:         62 :     Any aAlign( m_xModel->getPropertyValue(FM_PROP_ALIGN));
                 [ +  - ]
     390         [ +  - ]:         62 :     if (aAlign.hasValue())
     391                 :            :     {
     392                 :         62 :         sal_Int16 nTest = sal_Int16();
     393         [ +  - ]:         62 :         if (aAlign >>= nTest)
     394                 :         62 :             nStandardAlign = nTest;
     395                 :            :     }
     396         [ +  - ]:         62 :     return SetAlignment(nStandardAlign);
     397                 :            : }
     398                 :            : 
     399                 :            : //------------------------------------------------------------------------------
     400                 :          0 : void DbGridColumn::setLock(sal_Bool _bLock)
     401                 :            : {
     402         [ #  # ]:          0 :     if (m_bLocked == _bLock)
     403                 :          0 :         return;
     404                 :          0 :     m_bLocked = _bLock;
     405                 :            : 
     406                 :            :     // is the column we represent active ?
     407         [ #  # ]:          0 :     if (m_bHidden)
     408                 :          0 :         return;     // no, it isn't (or at least it shouldn't be ...)
     409                 :            : 
     410         [ #  # ]:          0 :     if (m_rParent.GetCurColumnId() == m_nId)
     411                 :            :     {
     412                 :          0 :         m_rParent.DeactivateCell();
     413                 :          0 :         m_rParent.ActivateCell(m_rParent.GetCurRow(), m_rParent.GetCurColumnId());
     414                 :            :     }
     415                 :            : }
     416                 :            : 
     417                 :            : //------------------------------------------------------------------------------
     418                 :          0 : String DbGridColumn::GetCellText(const DbGridRow* pRow, const Reference< XNumberFormatter >& xFormatter) const
     419                 :            : {
     420                 :          0 :     String aText;
     421 [ #  # ][ #  # ]:          0 :     if (m_pCell && m_pCell->ISA(FmXFilterCell))
         [ #  # ][ #  # ]
     422                 :          0 :         return aText;
     423                 :            : 
     424 [ #  # ][ #  # ]:          0 :     if (!pRow || !pRow->IsValid())
                 [ #  # ]
     425         [ #  # ]:          0 :         aText = rtl::OUString(INVALIDTEXT);
     426         [ #  # ]:          0 :     else if (pRow->HasField(m_nFieldPos))
     427                 :            :     {
     428 [ #  # ][ #  # ]:          0 :         aText = GetCellText( pRow->GetField( m_nFieldPos ).getColumn(), xFormatter );
         [ #  # ][ #  # ]
     429                 :            :     }
     430                 :          0 :     return aText;
     431                 :            : }
     432                 :            : 
     433                 :            : //------------------------------------------------------------------------------
     434                 :          0 : String DbGridColumn::GetCellText(const Reference< ::com::sun::star::sdb::XColumn >& xField, const Reference< XNumberFormatter >& xFormatter) const
     435                 :            : {
     436                 :          0 :     String aText;
     437         [ #  # ]:          0 :     if (xField.is())
     438                 :            :     {
     439 [ #  # ][ #  # ]:          0 :         FmXTextCell* pTextCell = PTR_CAST(FmXTextCell, m_pCell);
                 [ #  # ]
     440         [ #  # ]:          0 :         if (pTextCell)
     441 [ #  # ][ #  # ]:          0 :             aText = pTextCell->GetText(xField, xFormatter);
                 [ #  # ]
     442         [ #  # ]:          0 :         else if (m_bObject)
     443         [ #  # ]:          0 :             aText = rtl::OUString(OBJECTTEXT);
     444                 :            :     }
     445                 :          0 :     return aText;
     446                 :            : }
     447                 :            : 
     448                 :            : //------------------------------------------------------------------------------
     449                 :          0 : Reference< ::com::sun::star::sdb::XColumn >  DbGridColumn::GetCurrentFieldValue() const
     450                 :            : {
     451                 :          0 :     Reference< ::com::sun::star::sdb::XColumn >  xField;
     452                 :          0 :     const DbGridRowRef xRow = m_rParent.GetCurrentRow();
     453 [ #  # ][ #  # ]:          0 :     if (xRow.Is() && xRow->HasField(m_nFieldPos))
                 [ #  # ]
     454                 :            :     {
     455 [ #  # ][ #  # ]:          0 :         xField = xRow->GetField(m_nFieldPos).getColumn();
     456                 :            :     }
     457         [ #  # ]:          0 :     return xField;
     458                 :            : }
     459                 :            : 
     460                 :            : //------------------------------------------------------------------------------
     461                 :        112 : void DbGridColumn::Paint(OutputDevice& rDev,
     462                 :            :                          const Rectangle& rRect,
     463                 :            :                          const DbGridRow* pRow,
     464                 :            :                          const Reference< XNumberFormatter >& xFormatter)
     465                 :            : {
     466                 :        112 :     bool bEnabled = ( rDev.GetOutDevType() != OUTDEV_WINDOW )
     467 [ +  - ][ +  - ]:        112 :                 ||  ( static_cast< Window& >( rDev ).IsEnabled() );
     468                 :            : 
     469 [ +  - ][ +  - ]:        112 :     FmXDataCell* pDataCell = PTR_CAST(FmXDataCell, m_pCell);
     470         [ +  - ]:        112 :     if (pDataCell)
     471                 :            :     {
     472 [ +  - ][ -  + ]:        112 :         if (!pRow || !pRow->IsValid())
                 [ -  + ]
     473                 :            :         {
     474                 :          0 :             sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
     475         [ #  # ]:          0 :             if ( !bEnabled )
     476                 :          0 :                 nStyle |= TEXT_DRAW_DISABLE;
     477                 :            : 
     478 [ #  # ][ #  # ]:          0 :             rDev.DrawText(rRect, rtl::OUString(INVALIDTEXT), nStyle);
                 [ #  # ]
     479                 :            :         }
     480 [ -  + ][ #  # ]:        112 :         else if (m_bAutoValue && pRow->IsNew())
                 [ -  + ]
     481                 :            :         {
     482 [ #  # ][ #  # ]:          0 :             static String aAutoText(SVX_RES(RID_STR_AUTOFIELD));
         [ #  # ][ #  # ]
                 [ #  # ]
     483                 :          0 :             sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER;
     484         [ #  # ]:          0 :             if ( !bEnabled )
     485                 :          0 :                 nStyle |= TEXT_DRAW_DISABLE;
     486                 :            : 
     487      [ #  #  # ]:          0 :             switch (GetAlignment())
     488                 :            :             {
     489                 :            :                 case ::com::sun::star::awt::TextAlign::RIGHT:
     490                 :          0 :                     nStyle |= TEXT_DRAW_RIGHT;
     491                 :          0 :                     break;
     492                 :            :                 case ::com::sun::star::awt::TextAlign::CENTER:
     493                 :          0 :                     nStyle |= TEXT_DRAW_CENTER;
     494                 :          0 :                     break;
     495                 :            :                 default:
     496                 :          0 :                     nStyle |= TEXT_DRAW_LEFT;
     497                 :            :             }
     498                 :            : 
     499                 :          0 :             rDev.DrawText(rRect, aAutoText , nStyle);
     500                 :            :         }
     501         [ +  - ]:        112 :         else if (pRow->HasField(m_nFieldPos))
     502                 :            :         {
     503                 :        112 :             pDataCell->PaintFieldToCell(rDev, rRect, pRow->GetField( m_nFieldPos ).getColumn(), xFormatter);
     504                 :            :         }
     505                 :            :     }
     506         [ #  # ]:          0 :     else if (!m_pCell)
     507                 :            :     {
     508 [ #  # ][ #  # ]:          0 :         if (!pRow || !pRow->IsValid())
                 [ #  # ]
     509                 :            :         {
     510                 :          0 :             sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
     511         [ #  # ]:          0 :             if ( !bEnabled )
     512                 :          0 :                 nStyle |= TEXT_DRAW_DISABLE;
     513                 :            : 
     514 [ #  # ][ #  # ]:          0 :             rDev.DrawText(rRect, rtl::OUString(INVALIDTEXT), nStyle);
                 [ #  # ]
     515                 :            :         }
     516 [ #  # ][ #  # ]:          0 :         else if (pRow->HasField(m_nFieldPos) && m_bObject)
                 [ #  # ]
     517                 :            :         {
     518                 :          0 :             sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_CENTER;
     519         [ #  # ]:          0 :             if ( !bEnabled )
     520                 :          0 :                 nStyle |= TEXT_DRAW_DISABLE;
     521 [ #  # ][ #  # ]:          0 :             rDev.DrawText(rRect, rtl::OUString(OBJECTTEXT), nStyle);
                 [ #  # ]
     522                 :            :         }
     523                 :            :     }
     524         [ #  # ]:          0 :     else if ( m_pCell->ISA( FmXFilterCell ) )
     525                 :          0 :         static_cast< FmXFilterCell* >( m_pCell )->PaintCell( rDev, rRect );
     526                 :        112 : }
     527                 :            : 
     528                 :            : //------------------------------------------------------------------------------
     529                 :        280 : void DbGridColumn::ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
     530                 :            : {
     531         [ -  + ]:        280 :     if ( m_pCell )
     532                 :          0 :         m_pCell->ImplInitWindow( rParent, _eInitWhat );
     533                 :        280 : }
     534                 :            : 
     535                 :            : //==============================================================================
     536                 :            : //= cell controls
     537                 :            : //==============================================================================
     538         [ -  + ]:         56 : TYPEINIT0( DbCellControl )
     539 [ -  + ][ -  + ]:         56 : TYPEINIT1( DbLimitedLengthField, DbCellControl )
     540 [ +  - ][ #  # ]:        164 : TYPEINIT1( DbTextField, DbLimitedLengthField )
     541 [ -  + ][ -  + ]:         84 : TYPEINIT1( DbFormattedField, DbLimitedLengthField )
     542 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbCheckBox, DbCellControl )
     543 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbComboBox, DbCellControl )
     544 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbListBox, DbCellControl )
     545 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbPatternField, DbCellControl )
     546 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbSpinField, DbCellControl )
     547 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbDateField, DbSpinField )
     548 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbTimeField, DbSpinField )
     549 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbCurrencyField, DbSpinField )
     550 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbNumericField, DbSpinField )
     551 [ #  # ][ #  # ]:          0 : TYPEINIT1( DbFilterField, DbCellControl )
     552                 :            : 
     553                 :            : //------------------------------------------------------------------------------
     554                 :         62 : DbCellControl::DbCellControl( DbGridColumn& _rColumn, sal_Bool /*_bText*/ )
     555                 :            :     :OPropertyChangeListener(m_aMutex)
     556                 :            :     ,m_pFieldChangeBroadcaster(NULL)
     557                 :            :     ,m_bTransparent( sal_False )
     558                 :            :     ,m_bAlignedController( sal_True )
     559                 :            :     ,m_bAccessingValueProperty( sal_False )
     560                 :            :     ,m_rColumn( _rColumn )
     561                 :            :     ,m_pPainter( NULL )
     562 [ +  - ][ +  - ]:         62 :     ,m_pWindow( NULL )
     563                 :            : {
     564         [ +  - ]:         62 :     Reference< XPropertySet > xColModelProps( _rColumn.getModel(), UNO_QUERY );
     565         [ +  - ]:         62 :     if ( xColModelProps.is() )
     566                 :            :     {
     567                 :            :         // if our model's format key changes we want to propagate the new value to our windows
     568 [ +  - ][ +  - ]:         62 :         m_pModelChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, Reference< ::com::sun::star::beans::XPropertySet > (_rColumn.getModel(), UNO_QUERY));
     569                 :         62 :         m_pModelChangeBroadcaster->acquire();
     570                 :            : 
     571                 :            :         // be listener for some common properties
     572 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_READONLY, sal_False );
     573 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_ENABLED, sal_False );
     574                 :            : 
     575                 :            :         // add as listener for all know "value" properties
     576 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_VALUE, sal_False );
     577 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_STATE, sal_False );
     578 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_TEXT, sal_False );
     579 [ +  - ][ +  - ]:         62 :         implDoPropertyListening( FM_PROP_EFFECTIVE_VALUE, sal_False );
     580                 :            : 
     581                 :            :         // be listener at the bound field as well
     582                 :            :         try
     583                 :            :         {
     584 [ +  - ][ +  - ]:         62 :             Reference< XPropertySetInfo > xPSI( xColModelProps->getPropertySetInfo(), UNO_SET_THROW );
                 [ +  - ]
     585 [ +  - ][ +  - ]:         62 :             if ( xPSI->hasPropertyByName( FM_PROP_BOUNDFIELD ) )
         [ +  - ][ +  - ]
     586                 :            :             {
     587                 :         62 :                 Reference< XPropertySet > xField;
     588 [ +  - ][ +  - ]:         62 :                 xColModelProps->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
         [ +  - ][ +  - ]
     589         [ +  - ]:         62 :                 if ( xField.is() )
     590                 :            :                 {
     591         [ +  - ]:         62 :                     m_pFieldChangeBroadcaster = new ::comphelper::OPropertyChangeMultiplexer(this, xField);
     592                 :         62 :                     m_pFieldChangeBroadcaster->acquire();
     593 [ +  - ][ +  - ]:         62 :                     m_pFieldChangeBroadcaster->addProperty( FM_PROP_ISREADONLY );
     594                 :         62 :                 }
     595         [ #  # ]:         62 :             }
     596                 :            :         }
     597         [ #  # ]:          0 :         catch( const Exception& )
     598                 :            :         {
     599                 :            :             OSL_FAIL( "DbCellControl::doPropertyListening: caught an exception!" );
     600                 :            :         }
     601                 :         62 :     }
     602                 :         62 : }
     603                 :            : 
     604                 :            : //------------------------------------------------------------------------------
     605                 :        462 : void DbCellControl::implDoPropertyListening( const ::rtl::OUString& _rPropertyName, sal_Bool _bWarnIfNotExistent )
     606                 :            : {
     607                 :            :     try
     608                 :            :     {
     609         [ +  - ]:        462 :         Reference< XPropertySet > xColModelProps( m_rColumn.getModel(), UNO_QUERY );
     610                 :        462 :         Reference< XPropertySetInfo > xPSI;
     611         [ +  - ]:        462 :         if ( xColModelProps.is() )
     612 [ +  - ][ +  - ]:        462 :             xPSI = xColModelProps->getPropertySetInfo();
                 [ +  - ]
     613                 :            : 
     614                 :            :         DBG_ASSERT( !_bWarnIfNotExistent || ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) ),
     615                 :            :             "DbCellControl::doPropertyListening: no property set info or non-existent property!" );
     616                 :            :         (void)_bWarnIfNotExistent;
     617                 :            : 
     618 [ +  - ][ +  - ]:        462 :         if ( xPSI.is() && xPSI->hasPropertyByName( _rPropertyName ) )
         [ +  - ][ +  + ]
                 [ +  + ]
     619 [ +  - ][ #  # ]:        462 :             m_pModelChangeBroadcaster->addProperty( _rPropertyName );
     620                 :            :     }
     621                 :          0 :     catch( const Exception& )
     622                 :            :     {
     623                 :            :         OSL_FAIL( "DbCellControl::doPropertyListening: caught an exception!" );
     624                 :            :     }
     625                 :        462 : }
     626                 :            : 
     627                 :            : //------------------------------------------------------------------------------
     628                 :         90 : void DbCellControl::doPropertyListening( const ::rtl::OUString& _rPropertyName )
     629                 :            : {
     630                 :         90 :     implDoPropertyListening( _rPropertyName );
     631                 :         90 : }
     632                 :            : //------------------------------------------------------------------------------
     633                 :        124 : void lcl_clearBroadCaster(::comphelper::OPropertyChangeMultiplexer*& _pBroadcaster)
     634                 :            : {
     635         [ +  - ]:        124 :     if ( _pBroadcaster )
     636                 :            :     {
     637                 :        124 :         _pBroadcaster->dispose();
     638                 :        124 :         _pBroadcaster->release();
     639                 :        124 :         _pBroadcaster = NULL;
     640                 :            :         // no delete, this is done implicitly
     641                 :            :     }
     642                 :        124 : }
     643                 :            : //------------------------------------------------------------------------------
     644 [ +  - ][ +  - ]:         62 : DbCellControl::~DbCellControl()
                 [ +  - ]
     645                 :            : {
     646         [ +  - ]:         62 :     lcl_clearBroadCaster(m_pModelChangeBroadcaster);
     647         [ +  - ]:         62 :     lcl_clearBroadCaster(m_pFieldChangeBroadcaster);
     648                 :            : 
     649 [ +  - ][ +  - ]:         62 :     delete m_pWindow;
     650 [ +  - ][ +  - ]:         62 :     delete m_pPainter;
     651         [ -  + ]:         62 : }
     652                 :            : 
     653                 :            : //------------------------------------------------------------------------------
     654                 :          0 : void DbCellControl::implValuePropertyChanged( )
     655                 :            : {
     656                 :            :     OSL_ENSURE( !isValuePropertyLocked(),
     657                 :            :         "DbCellControl::implValuePropertyChanged: not to be called with the value property locked!" );
     658                 :            : 
     659         [ #  # ]:          0 :     if ( m_pWindow )
     660                 :            :     {
     661         [ #  # ]:          0 :         if ( m_rColumn.getModel().is() )
     662         [ #  # ]:          0 :             updateFromModel( m_rColumn.getModel() );
     663                 :            :     }
     664                 :          0 : }
     665                 :            : 
     666                 :            : //------------------------------------------------------------------------------
     667                 :          0 : void DbCellControl::implAdjustGenericFieldSetting( const Reference< XPropertySet >& /*_rxModel*/ )
     668                 :            : {
     669                 :            :     // nothing to to here
     670                 :          0 : }
     671                 :            : 
     672                 :            : //------------------------------------------------------------------------------
     673                 :          0 : void DbCellControl::_propertyChanged(const PropertyChangeEvent& _rEvent) throw(RuntimeException)
     674                 :            : {
     675         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     676                 :            : 
     677         [ #  # ]:          0 :     Reference< XPropertySet > xSourceProps( _rEvent.Source, UNO_QUERY );
     678                 :            : 
     679 [ #  # ][ #  #  :          0 :     if  (   _rEvent.PropertyName.equals( FM_PROP_VALUE )
          #  #  #  #  #  
              # ][ #  # ]
           [ #  #  #  # ]
     680 [ #  # ][ #  # ]:          0 :         ||  _rEvent.PropertyName.equals( FM_PROP_STATE )
                 [ #  # ]
     681 [ #  # ][ #  # ]:          0 :         ||  _rEvent.PropertyName.equals( FM_PROP_TEXT )
                 [ #  # ]
     682 [ #  # ][ #  # ]:          0 :         ||  _rEvent.PropertyName.equals( FM_PROP_EFFECTIVE_VALUE )
                 [ #  # ]
     683                 :            :         )
     684                 :            :     {   // it was one of the known "value" properties
     685         [ #  # ]:          0 :         if ( !isValuePropertyLocked() )
     686                 :            :         {
     687         [ #  # ]:          0 :             implValuePropertyChanged( );
     688                 :            :         }
     689                 :            :     }
     690 [ #  # ][ #  # ]:          0 :     else if ( _rEvent.PropertyName.equals( FM_PROP_READONLY ) )
     691                 :            :     {
     692         [ #  # ]:          0 :         implAdjustReadOnly( xSourceProps, true);
     693                 :            :     }
     694 [ #  # ][ #  # ]:          0 :     else if ( _rEvent.PropertyName.equals( FM_PROP_ISREADONLY ) )
     695                 :            :     {
     696                 :          0 :         sal_Bool bReadOnly = sal_True;
     697                 :          0 :         _rEvent.NewValue >>= bReadOnly;
     698                 :          0 :         m_rColumn.SetReadOnly(bReadOnly);
     699         [ #  # ]:          0 :         implAdjustReadOnly( xSourceProps, false);
     700                 :            :     }
     701 [ #  # ][ #  # ]:          0 :     else if ( _rEvent.PropertyName.equals( FM_PROP_ENABLED ) )
     702                 :            :     {
     703         [ #  # ]:          0 :         implAdjustEnabled( xSourceProps );
     704                 :            :     }
     705                 :            :     else
     706 [ #  # ][ #  # ]:          0 :         implAdjustGenericFieldSetting( xSourceProps );
     707                 :          0 : }
     708                 :            : 
     709                 :            : //------------------------------------------------------------------------------
     710                 :          0 : sal_Bool DbCellControl::Commit()
     711                 :            : {
     712                 :            :     // lock the listening for value property changes
     713                 :          0 :     lockValueProperty();
     714                 :            :     // commit the content of the control into the model's value property
     715                 :          0 :     sal_Bool bReturn = sal_False;
     716                 :            :     try
     717                 :            :     {
     718         [ #  # ]:          0 :         bReturn = commitControl();
     719                 :            :     }
     720                 :          0 :     catch( const Exception& )
     721                 :            :     {
     722                 :            :         DBG_UNHANDLED_EXCEPTION();
     723                 :            :     }
     724                 :            :     // unlock the listening for value property changes
     725                 :          0 :     unlockValueProperty();
     726                 :            :     // outta here
     727         [ #  # ]:          0 :     return bReturn;
     728                 :            : }
     729                 :            : 
     730                 :            : //------------------------------------------------------------------------------
     731                 :         62 : void DbCellControl::ImplInitWindow( Window& rParent, const InitWindowFacet _eInitWhat )
     732                 :            : {
     733                 :         62 :     Window* pWindows[] = { m_pPainter, m_pWindow };
     734                 :            : 
     735         [ +  - ]:         62 :     if ( ( _eInitWhat & InitWritingMode ) != 0 )
     736                 :            :     {
     737         [ +  + ]:        186 :         for ( size_t i=0; i < sizeof( pWindows ) / sizeof( pWindows[0] ); ++i )
     738                 :            :         {
     739         [ +  - ]:        124 :             if ( pWindows[i] )
     740         [ +  - ]:        124 :                 pWindows[i]->EnableRTL( rParent.IsRTLEnabled() );
     741                 :            :         }
     742                 :            :     }
     743                 :            : 
     744         [ +  - ]:         62 :     if ( ( _eInitWhat & InitFont ) != 0 )
     745                 :            :     {
     746         [ +  + ]:        186 :         for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
     747                 :            :         {
     748         [ -  + ]:        124 :             if ( !pWindows[i] )
     749                 :          0 :                 continue;
     750                 :            : 
     751 [ +  - ][ +  - ]:        124 :             pWindows[i]->SetZoom( rParent.GetZoom() );
     752                 :            : 
     753                 :        124 :             const StyleSettings& rStyleSettings = pWindows[i]->GetSettings().GetStyleSettings();
     754         [ +  - ]:        124 :             Font aFont = rStyleSettings.GetFieldFont();
     755         [ +  - ]:        124 :             aFont.SetTransparent( isTransparent() );
     756                 :            : 
     757 [ +  - ][ -  + ]:        124 :             if ( rParent.IsControlFont() )
     758                 :            :             {
     759 [ #  # ][ #  # ]:          0 :                 pWindows[i]->SetControlFont( rParent.GetControlFont() );
                 [ #  # ]
     760 [ #  # ][ #  # ]:          0 :                 aFont.Merge( rParent.GetControlFont() );
                 [ #  # ]
     761                 :            :             }
     762                 :            :             else
     763         [ +  - ]:        124 :                 pWindows[i]->SetControlFont();
     764                 :            : 
     765         [ +  - ]:        124 :             pWindows[i]->SetZoomedPointFont( aFont );
     766         [ +  - ]:        124 :         }
     767                 :            :     }
     768                 :            : 
     769 [ -  + ][ #  # ]:         62 :     if  (   ( ( _eInitWhat & InitFont ) != 0 )
     770                 :            :         ||  ( ( _eInitWhat & InitForeground ) != 0 )
     771                 :            :         )
     772                 :            :     {
     773 [ +  - ][ -  + ]:         62 :         Color aTextColor( rParent.IsControlForeground() ? rParent.GetControlForeground() : rParent.GetTextColor() );
                 [ #  # ]
     774                 :            : 
     775                 :         62 :         sal_Bool bTextLineColor = rParent.IsTextLineColor();
     776                 :         62 :         Color aTextLineColor( rParent.GetTextLineColor() );
     777                 :            : 
     778         [ +  + ]:        186 :         for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
     779                 :            :         {
     780         [ +  - ]:        124 :             if ( pWindows[i] )
     781                 :            :             {
     782         [ +  - ]:        124 :                 pWindows[i]->SetTextColor(aTextColor);
     783 [ +  - ][ -  + ]:        124 :                 if (rParent.IsControlForeground())
     784         [ #  # ]:          0 :                     pWindows[i]->SetControlForeground(aTextColor);
     785                 :            : 
     786         [ -  + ]:        124 :                 if (bTextLineColor)
     787         [ #  # ]:          0 :                     pWindows[i]->SetTextLineColor();
     788                 :            :                 else
     789         [ +  - ]:        124 :                     pWindows[i]->SetTextLineColor(aTextLineColor);
     790                 :            :             }
     791                 :            :         }
     792                 :            :     }
     793                 :            : 
     794         [ +  - ]:         62 :     if ( ( _eInitWhat & InitBackground ) != 0 )
     795                 :            :     {
     796 [ +  - ][ -  + ]:         62 :         if (rParent.IsControlBackground())
     797                 :            :         {
     798         [ #  # ]:          0 :             Color aColor( rParent.GetControlBackground());
     799         [ #  # ]:          0 :             for (size_t i=0; i < sizeof(pWindows)/sizeof(pWindows[0]); ++i)
     800                 :            :             {
     801         [ #  # ]:          0 :                 if ( pWindows[i] )
     802                 :            :                 {
     803         [ #  # ]:          0 :                     if ( isTransparent() )
     804         [ #  # ]:          0 :                         pWindows[i]->SetBackground();
     805                 :            :                     else
     806                 :            :                     {
     807 [ #  # ][ #  # ]:          0 :                         pWindows[i]->SetBackground(aColor);
                 [ #  # ]
     808         [ #  # ]:          0 :                         pWindows[i]->SetControlBackground(aColor);
     809                 :            :                     }
     810         [ #  # ]:          0 :                     pWindows[i]->SetFillColor(aColor);
     811                 :            :                 }
     812                 :            :             }
     813                 :            :         }
     814                 :            :         else
     815                 :            :         {
     816         [ +  - ]:         62 :             if (m_pPainter)
     817                 :            :             {
     818         [ -  + ]:         62 :                 if ( isTransparent() )
     819         [ #  # ]:          0 :                     m_pPainter->SetBackground();
     820                 :            :                 else
     821         [ +  - ]:         62 :                     m_pPainter->SetBackground(rParent.GetBackground());
     822         [ +  - ]:         62 :                 m_pPainter->SetFillColor(rParent.GetFillColor());
     823                 :            :             }
     824                 :            : 
     825         [ +  - ]:         62 :             if (m_pWindow)
     826                 :            :             {
     827         [ -  + ]:         62 :                 if ( isTransparent() )
     828         [ #  # ]:          0 :                     m_pWindow->SetBackground(rParent.GetBackground());
     829                 :            :                 else
     830         [ +  - ]:         62 :                     m_pWindow->SetFillColor(rParent.GetFillColor());
     831                 :            :             }
     832                 :            :         }
     833                 :            :     }
     834                 :         62 : }
     835                 :            : 
     836                 :            : //------------------------------------------------------------------------------
     837                 :         62 : void DbCellControl::implAdjustReadOnly( const Reference< XPropertySet >& _rxModel,bool i_bReadOnly )
     838                 :            : {
     839                 :            :     DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustReadOnly: not to be called without window!" );
     840                 :            :     DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustReadOnly: invalid model!" );
     841 [ +  - ][ +  - ]:         62 :     if ( m_pWindow && _rxModel.is() )
                 [ +  - ]
     842                 :            :     {
     843         [ -  + ]:         62 :         Edit* pEditWindow = dynamic_cast< Edit* >( m_pWindow );
     844         [ +  - ]:         62 :         if ( pEditWindow )
     845                 :            :         {
     846                 :         62 :             sal_Bool bReadOnly = m_rColumn.IsReadOnly();
     847         [ +  - ]:         62 :             if ( !bReadOnly )
     848                 :            :             {
     849 [ +  - ][ +  - ]:         62 :                 _rxModel->getPropertyValue( i_bReadOnly ? FM_PROP_READONLY : FM_PROP_ISREADONLY) >>= bReadOnly;
         [ +  - ][ #  # ]
                 [ +  - ]
     850                 :            :             }
     851         [ +  - ]:         62 :             static_cast< Edit* >( m_pWindow )->SetReadOnly( bReadOnly );
     852                 :            :         }
     853                 :            :     }
     854                 :         62 : }
     855                 :            : 
     856                 :            : //------------------------------------------------------------------------------
     857                 :         62 : void DbCellControl::implAdjustEnabled( const Reference< XPropertySet >& _rxModel )
     858                 :            : {
     859                 :            :     DBG_ASSERT( m_pWindow, "DbCellControl::implAdjustEnabled: not to be called without window!" );
     860                 :            :     DBG_ASSERT( _rxModel.is(), "DbCellControl::implAdjustEnabled: invalid model!" );
     861 [ +  - ][ +  - ]:         62 :     if ( m_pWindow && _rxModel.is() )
                 [ +  - ]
     862                 :            :     {
     863                 :         62 :         sal_Bool bEnable = sal_True;
     864 [ +  - ][ +  - ]:         62 :         _rxModel->getPropertyValue( FM_PROP_ENABLED ) >>= bEnable;
                 [ +  - ]
     865         [ +  - ]:         62 :         m_pWindow->Enable( bEnable );
     866                 :            :     }
     867                 :         62 : }
     868                 :            : 
     869                 :            : //------------------------------------------------------------------------------
     870                 :         62 : void DbCellControl::Init( Window& rParent, const Reference< XRowSet >& _rxCursor )
     871                 :            : {
     872                 :         62 :     ImplInitWindow( rParent, InitAll );
     873                 :            : 
     874         [ +  - ]:         62 :     if ( m_pWindow )
     875                 :            :     {
     876                 :            :         // align the control
     877         [ +  - ]:         62 :         if ( isAlignedController() )
     878                 :         62 :             AlignControl( m_rColumn.GetAlignment() );
     879                 :            : 
     880                 :            :         try
     881                 :            :         {
     882                 :            :             // some other common properties
     883         [ +  - ]:         62 :             Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
     884 [ +  - ][ +  - ]:         62 :             Reference< XPropertySetInfo > xModelPSI( xModel->getPropertySetInfo(), UNO_SET_THROW );
                 [ +  - ]
     885                 :            : 
     886 [ +  - ][ +  - ]:         62 :             if ( xModelPSI->hasPropertyByName( FM_PROP_READONLY ) )
         [ +  - ][ +  - ]
     887                 :            :             {
     888         [ +  - ]:         62 :                 implAdjustReadOnly( xModel,true );
     889                 :            :             }
     890                 :            : 
     891 [ +  - ][ +  - ]:         62 :             if ( xModelPSI->hasPropertyByName( FM_PROP_ENABLED ) )
         [ +  - ][ +  - ]
     892                 :            :             {
     893         [ +  - ]:         62 :                 implAdjustEnabled( xModel );
     894                 :            :             }
     895                 :            : 
     896 [ +  - ][ +  - ]:         62 :             if ( xModelPSI->hasPropertyByName( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) )
         [ +  - ][ +  + ]
     897                 :            :             {
     898                 :         28 :                 sal_Int16 nWheelBehavior = MouseWheelBehavior::SCROLL_FOCUS_ONLY;
     899 [ +  - ][ +  - ]:         28 :                 OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MOUSE_WHEEL_BEHAVIOR ) >>= nWheelBehavior );
                 [ +  - ]
     900                 :         28 :                 sal_uInt16 nVclSetting = MOUSE_WHEEL_FOCUS_ONLY;
     901   [ +  -  -  - ]:         28 :                 switch ( nWheelBehavior )
     902                 :            :                 {
     903                 :         28 :                 case MouseWheelBehavior::SCROLL_DISABLED:   nVclSetting = MOUSE_WHEEL_DISABLE; break;
     904                 :          0 :                 case MouseWheelBehavior::SCROLL_FOCUS_ONLY: nVclSetting = MOUSE_WHEEL_FOCUS_ONLY; break;
     905                 :          0 :                 case MouseWheelBehavior::SCROLL_ALWAYS:     nVclSetting = MOUSE_WHEEL_ALWAYS; break;
     906                 :            :                 default:
     907                 :            :                     OSL_FAIL( "DbCellControl::Init: invalid MouseWheelBehavior!" );
     908                 :          0 :                     break;
     909                 :            :                 }
     910                 :            : 
     911         [ +  - ]:         28 :                 AllSettings aSettings = m_pWindow->GetSettings();
     912         [ +  - ]:         28 :                 MouseSettings aMouseSettings = aSettings.GetMouseSettings();
     913         [ +  - ]:         28 :                 aMouseSettings.SetWheelBehavior( nVclSetting );
     914         [ +  - ]:         28 :                 aSettings.SetMouseSettings( aMouseSettings );
     915 [ +  - ][ +  - ]:         28 :                 m_pWindow->SetSettings( aSettings, sal_True );
                 [ +  - ]
     916         [ #  # ]:         62 :             }
     917                 :            :         }
     918                 :          0 :         catch( const Exception& )
     919                 :            :         {
     920                 :            :             DBG_UNHANDLED_EXCEPTION();
     921                 :            :         }
     922                 :            :     }
     923                 :         62 :     m_xCursor = _rxCursor;
     924                 :         62 : }
     925                 :            : 
     926                 :            : //------------------------------------------------------------------------------
     927                 :          0 : void DbCellControl::SetTextLineColor()
     928                 :            : {
     929         [ #  # ]:          0 :     if (m_pWindow)
     930                 :          0 :         m_pWindow->SetTextLineColor();
     931         [ #  # ]:          0 :     if (m_pPainter)
     932                 :          0 :         m_pPainter->SetTextLineColor();
     933                 :          0 : }
     934                 :            : 
     935                 :            : //------------------------------------------------------------------------------
     936                 :          0 : void DbCellControl::SetTextLineColor(const Color& _rColor)
     937                 :            : {
     938         [ #  # ]:          0 :     if (m_pWindow)
     939                 :          0 :         m_pWindow->SetTextLineColor(_rColor);
     940         [ #  # ]:          0 :     if (m_pPainter)
     941                 :          0 :         m_pPainter->SetTextLineColor(_rColor);
     942                 :          0 : }
     943                 :            : 
     944                 :            : namespace
     945                 :            : {
     946                 :        124 :     static void lcl_implAlign( Window* _pWindow, WinBits _nAlignmentBit )
     947                 :            :     {
     948                 :        124 :         WinBits nStyle = _pWindow->GetStyle();
     949                 :        124 :         nStyle &= ~(WB_LEFT | WB_RIGHT | WB_CENTER);
     950                 :        124 :         _pWindow->SetStyle( nStyle | _nAlignmentBit );
     951                 :        124 :     }
     952                 :            : }
     953                 :            : 
     954                 :            : //------------------------------------------------------------------------------
     955                 :         62 : void DbCellControl::AlignControl(sal_Int16 nAlignment)
     956                 :            : {
     957                 :         62 :     WinBits nAlignmentBit = 0;
     958      [ -  -  + ]:         62 :     switch (nAlignment)
     959                 :            :     {
     960                 :            :         case ::com::sun::star::awt::TextAlign::RIGHT:
     961                 :          0 :             nAlignmentBit = WB_RIGHT;
     962                 :          0 :             break;
     963                 :            :         case ::com::sun::star::awt::TextAlign::CENTER:
     964                 :          0 :             nAlignmentBit = WB_CENTER;
     965                 :          0 :             break;
     966                 :            :         default:
     967                 :         62 :             nAlignmentBit = WB_LEFT;
     968                 :         62 :             break;
     969                 :            :     }
     970                 :         62 :     lcl_implAlign( m_pWindow, nAlignmentBit );
     971         [ +  - ]:         62 :     if ( m_pPainter )
     972                 :         62 :         lcl_implAlign( m_pPainter, nAlignmentBit );
     973                 :         62 : }
     974                 :            : 
     975                 :            : //------------------------------------------------------------------------------
     976                 :         48 : void DbCellControl::PaintCell( OutputDevice& _rDev, const Rectangle& _rRect )
     977                 :            : {
     978         [ +  - ]:         48 :     if ( m_pPainter->GetParent() == &_rDev )
     979                 :            :     {
     980         [ +  - ]:         48 :         m_pPainter->SetPaintTransparent( sal_True );
     981         [ +  - ]:         48 :         m_pPainter->SetBackground( );
     982         [ +  - ]:         48 :         m_pPainter->SetControlBackground( _rDev.GetFillColor() );
     983         [ +  - ]:         48 :         m_pPainter->SetControlForeground( _rDev.GetTextColor() );
     984         [ +  - ]:         48 :         m_pPainter->SetTextColor( _rDev.GetTextColor() );
     985         [ +  - ]:         48 :         m_pPainter->SetTextFillColor( _rDev.GetTextColor() );
     986                 :            : 
     987         [ +  - ]:         48 :         Font aFont( _rDev.GetFont() );
     988         [ +  - ]:         48 :         aFont.SetTransparent( sal_True );
     989         [ +  - ]:         48 :         m_pPainter->SetFont( aFont );
     990                 :            : 
     991 [ +  - ][ +  - ]:         48 :         m_pPainter->SetPosSizePixel( _rRect.TopLeft(), _rRect.GetSize() );
     992         [ +  - ]:         48 :         m_pPainter->Show();
     993         [ +  - ]:         48 :         m_pPainter->Update();
     994         [ +  - ]:         48 :         m_pPainter->SetParentUpdateMode( sal_False );
     995         [ +  - ]:         48 :         m_pPainter->Hide();
     996 [ +  - ][ +  - ]:         48 :         m_pPainter->SetParentUpdateMode( sal_True );
     997                 :            :     }
     998                 :            :     else
     999         [ #  # ]:          0 :         m_pPainter->Draw( &_rDev, _rRect.TopLeft(), _rRect.GetSize(), 0 );
    1000                 :         48 : }
    1001                 :            : 
    1002                 :            : //------------------------------------------------------------------------------
    1003                 :         48 : void DbCellControl::PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
    1004                 :            : {
    1005         [ +  - ]:         48 :     m_pPainter->SetText( GetFormatText( _rxField, _rxFormatter ) );
    1006                 :         48 :     PaintCell( _rDev, _rRect );
    1007                 :         48 : }
    1008                 :            : 
    1009                 :            : //------------------------------------------------------------------------------
    1010                 :          0 : double DbCellControl::GetValue(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
    1011                 :            : {
    1012                 :          0 :     double fValue = 0;
    1013         [ #  # ]:          0 :     if (m_rColumn.IsNumeric())
    1014                 :            :     {
    1015                 :            :         try
    1016                 :            :         {
    1017 [ #  # ][ #  # ]:          0 :             fValue = _rxField->getDouble();
    1018                 :            :         }
    1019         [ #  # ]:          0 :         catch(const Exception&) { }
    1020                 :            :     }
    1021                 :            :     else
    1022                 :            :     {
    1023                 :          0 :         sal_Bool bSuccess = sal_False;
    1024                 :            :         try
    1025                 :            :         {
    1026 [ #  # ][ #  # ]:          0 :             fValue = _rxField->getDouble();
    1027                 :          0 :             bSuccess = sal_True;
    1028                 :            :         }
    1029                 :          0 :         catch(const Exception&) { }
    1030         [ #  # ]:          0 :         if (!bSuccess)
    1031                 :            :         {
    1032                 :            :             try
    1033                 :            :             {
    1034 [ #  # ][ #  # ]:          0 :                 fValue = xFormatter->convertStringToNumber(m_rColumn.GetKey(), _rxField->getString());
         [ #  # ][ #  # ]
                 [ #  # ]
    1035                 :            :             }
    1036                 :          0 :             catch(const Exception&) { }
    1037                 :            :         }
    1038                 :            :     }
    1039         [ #  # ]:          0 :     return fValue;
    1040                 :            : }
    1041                 :            : 
    1042                 :            : //------------------------------------------------------------------------------
    1043                 :          0 : void DbCellControl::invalidatedController()
    1044                 :            : {
    1045         [ #  # ]:          0 :     m_rColumn.GetParent().refreshController(m_rColumn.GetId(), DbGridControl::GrantControlAccess());
    1046                 :          0 : }
    1047                 :            : 
    1048                 :            : /*************************************************************************/
    1049                 :            : // CellModels
    1050                 :            : /*************************************************************************/
    1051                 :            : 
    1052                 :            : //==============================================================================
    1053                 :            : //= DbLimitedLengthField
    1054                 :            : //==============================================================================
    1055                 :            : //------------------------------------------------------------------------------
    1056                 :         62 : DbLimitedLengthField::DbLimitedLengthField( DbGridColumn& _rColumn )
    1057                 :         62 :     :DbCellControl( _rColumn )
    1058                 :            : {
    1059 [ +  - ][ +  - ]:         62 :     doPropertyListening( FM_PROP_MAXTEXTLEN );
    1060                 :         62 : }
    1061                 :            : 
    1062                 :            : //------------------------------------------------------------------------------
    1063                 :         62 : void DbLimitedLengthField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    1064                 :            : {
    1065                 :            :     DBG_ASSERT( m_pWindow, "DbLimitedLengthField::implAdjustGenericFieldSetting: not to be called without window!" );
    1066                 :            :     DBG_ASSERT( _rxModel.is(), "DbLimitedLengthField::implAdjustGenericFieldSetting: invalid model!" );
    1067 [ +  - ][ +  - ]:         62 :     if ( m_pWindow && _rxModel.is() )
                 [ +  - ]
    1068                 :            :     {
    1069                 :         62 :         sal_Int16 nMaxLen = 0;
    1070 [ +  - ][ +  - ]:         62 :         _rxModel->getPropertyValue( FM_PROP_MAXTEXTLEN ) >>= nMaxLen;
                 [ +  - ]
    1071         [ +  - ]:         62 :         implSetMaxTextLen( nMaxLen );
    1072                 :            :     }
    1073                 :         62 : }
    1074                 :            : 
    1075                 :            : //------------------------------------------------------------------------------
    1076                 :         28 : void DbLimitedLengthField::implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen )
    1077                 :            : {
    1078         [ +  - ]:         28 :     dynamic_cast< Edit* >( m_pWindow )->SetMaxTextLen( _nMaxLen );
    1079         [ +  - ]:         28 :     if ( m_pPainter )
    1080         [ +  - ]:         28 :         dynamic_cast< Edit* >( m_pPainter )->SetMaxTextLen( _nMaxLen );
    1081                 :         28 : }
    1082                 :            : 
    1083                 :            : //==============================================================================
    1084                 :            : //= DbTextField
    1085                 :            : //==============================================================================
    1086                 :            : //------------------------------------------------------------------------------
    1087                 :         34 : DbTextField::DbTextField(DbGridColumn& _rColumn)
    1088                 :            :             :DbLimitedLengthField(_rColumn)
    1089                 :            :             ,m_pEdit( NULL )
    1090                 :            :             ,m_pPainterImplementation( NULL )
    1091                 :            :             ,m_nKeyType(::com::sun::star::util::NumberFormat::TEXT)
    1092                 :         34 :             ,m_bIsSimpleEdit( sal_True )
    1093                 :            : {
    1094                 :         34 : }
    1095                 :            : 
    1096                 :            : //------------------------------------------------------------------------------
    1097                 :         34 : DbTextField::~DbTextField( )
    1098                 :            : {
    1099 [ +  - ][ +  - ]:         34 :     DELETEZ( m_pPainterImplementation );
    1100 [ +  - ][ +  - ]:         34 :     DELETEZ( m_pEdit );
    1101         [ -  + ]:         68 : }
    1102                 :            : 
    1103                 :            : //------------------------------------------------------------------------------
    1104                 :         34 : void DbTextField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
    1105                 :            : {
    1106         [ +  - ]:         34 :     sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
    1107                 :            : 
    1108                 :         34 :     Reference< XPropertySet > xModel( m_rColumn.getModel() );
    1109                 :            : 
    1110                 :         34 :     WinBits nStyle = WB_LEFT;
    1111      [ -  -  + ]:         34 :     switch (nAlignment)
    1112                 :            :     {
    1113                 :            :     case awt::TextAlign::RIGHT:
    1114                 :          0 :         nStyle = WB_RIGHT;
    1115                 :          0 :         break;
    1116                 :            : 
    1117                 :            :     case awt::TextAlign::CENTER:
    1118                 :          0 :         nStyle = WB_CENTER;
    1119                 :          0 :         break;
    1120                 :            :     }
    1121                 :            : 
    1122                 :            :     // is this a multi-line field?
    1123                 :         34 :     sal_Bool bIsMultiLine = sal_False;
    1124                 :            :     try
    1125                 :            :     {
    1126         [ +  - ]:         34 :         if ( xModel.is() )
    1127                 :            :         {
    1128 [ +  - ][ +  - ]:         34 :             OSL_VERIFY( xModel->getPropertyValue( FM_PROP_MULTILINE ) >>= bIsMultiLine );
         [ +  - ][ #  # ]
    1129                 :            :         }
    1130                 :            :     }
    1131         [ #  # ]:          0 :     catch( const Exception& )
    1132                 :            :     {
    1133                 :            :         OSL_FAIL( "DbTextField::Init: caught an exception while determining the multi-line capabilities!" );
    1134                 :            :     }
    1135                 :            : 
    1136                 :         34 :     m_bIsSimpleEdit = !bIsMultiLine;
    1137         [ +  - ]:         34 :     if ( bIsMultiLine )
    1138                 :            :     {
    1139 [ +  - ][ +  - ]:         34 :         m_pWindow = new MultiLineTextCell( &rParent, nStyle );
    1140 [ +  - ][ +  - ]:         34 :         m_pEdit = new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pWindow ) );
    1141                 :            : 
    1142 [ +  - ][ +  - ]:         34 :         m_pPainter = new MultiLineTextCell( &rParent, nStyle );
    1143 [ +  - ][ +  - ]:         34 :         m_pPainterImplementation = new MultiLineEditImplementation( *static_cast< MultiLineTextCell* >( m_pPainter ) );
    1144                 :            :     }
    1145                 :            :     else
    1146                 :            :     {
    1147 [ #  # ][ #  # ]:          0 :         m_pWindow = new Edit( &rParent, nStyle );
    1148 [ #  # ][ #  # ]:          0 :         m_pEdit = new EditImplementation( *static_cast< Edit* >( m_pWindow ) );
    1149                 :            : 
    1150 [ #  # ][ #  # ]:          0 :         m_pPainter = new Edit( &rParent, nStyle );
    1151 [ #  # ][ #  # ]:          0 :         m_pPainterImplementation = new EditImplementation( *static_cast< Edit* >( m_pPainter ) );
    1152                 :            :     }
    1153                 :            : 
    1154         [ +  - ]:         34 :     if ( WB_LEFT == nStyle )
    1155                 :            :     {
    1156                 :            :         // this is so that when getting the focus, the selection is oriented left-to-right
    1157         [ +  - ]:         34 :         AllSettings aSettings = m_pWindow->GetSettings();
    1158         [ +  - ]:         34 :         StyleSettings aStyleSettings = aSettings.GetStyleSettings();
    1159                 :            :         aStyleSettings.SetSelectionOptions(
    1160         [ +  - ]:         34 :             aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
    1161         [ +  - ]:         34 :         aSettings.SetStyleSettings(aStyleSettings);
    1162 [ +  - ][ +  - ]:         34 :         m_pWindow->SetSettings(aSettings);
                 [ +  - ]
    1163                 :            :     }
    1164                 :            : 
    1165         [ +  - ]:         34 :     implAdjustGenericFieldSetting( xModel );
    1166                 :            : 
    1167 [ +  - ][ +  - ]:         34 :     if (m_rColumn.GetParent().getNumberFormatter().is() && m_rColumn.GetKey())
                 [ +  - ]
    1168 [ +  - ][ +  - ]:         34 :         m_nKeyType  = comphelper::getNumberFormatType(m_rColumn.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn.GetKey());
         [ +  - ][ +  - ]
                 [ +  - ]
    1169                 :            : 
    1170         [ +  - ]:         34 :     DbLimitedLengthField::Init( rParent, xCursor );
    1171                 :         34 : }
    1172                 :            : 
    1173                 :            : //------------------------------------------------------------------------------
    1174                 :         34 : CellControllerRef DbTextField::CreateController() const
    1175                 :            : {
    1176         [ +  - ]:         34 :     return new EditCellController( m_pEdit );
    1177                 :            : }
    1178                 :            : 
    1179                 :            : //------------------------------------------------------------------------------
    1180                 :         48 : void DbTextField::PaintFieldToCell( OutputDevice& _rDev, const Rectangle& _rRect, const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
    1181                 :            : {
    1182         [ +  - ]:         48 :     if ( m_pPainterImplementation )
    1183         [ +  - ]:         48 :         m_pPainterImplementation->SetText( GetFormatText( _rxField, _rxFormatter, NULL ) );
    1184                 :            : 
    1185                 :         48 :     DbLimitedLengthField::PaintFieldToCell( _rDev, _rRect, _rxField, _rxFormatter );
    1186                 :         48 : }
    1187                 :            : 
    1188                 :            : //------------------------------------------------------------------------------
    1189                 :         96 : String DbTextField::GetFormatText(const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/)
    1190                 :            : {
    1191                 :         96 :     ::rtl::OUString aString;
    1192         [ +  - ]:         96 :     if ( _rxField.is() )
    1193                 :            :         try
    1194                 :            :         {
    1195         [ +  - ]:         96 :             aString = getFormattedValue( _rxField, xFormatter, m_rColumn.GetParent().getNullDate(), m_rColumn.GetKey(), m_nKeyType);
    1196                 :            :         }
    1197         [ #  # ]:          0 :         catch( const Exception& )
    1198                 :            :         {
    1199                 :            :             DBG_UNHANDLED_EXCEPTION();
    1200                 :            :         }
    1201                 :            : 
    1202 [ +  - ][ #  # ]:         96 :     return aString;
    1203                 :            : }
    1204                 :            : 
    1205                 :            : //------------------------------------------------------------------------------
    1206                 :          0 : void DbTextField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
    1207                 :            : {
    1208         [ #  # ]:          0 :     m_pEdit->SetText( GetFormatText( _rxField, xFormatter ) );
    1209         [ #  # ]:          0 :     m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    1210                 :          0 : }
    1211                 :            : 
    1212                 :            : //------------------------------------------------------------------------------
    1213                 :          0 : void DbTextField::updateFromModel( Reference< XPropertySet > _rxModel )
    1214                 :            : {
    1215                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTextField::updateFromModel: invalid call!" );
    1216                 :            : 
    1217                 :          0 :     ::rtl::OUString sText;
    1218 [ #  # ][ #  # ]:          0 :     _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
                 [ #  # ]
    1219                 :            : 
    1220         [ #  # ]:          0 :     xub_StrLen nMaxTextLen = m_pEdit->GetMaxTextLen();
    1221 [ #  # ][ #  # ]:          0 :     if ( EDIT_NOLIMIT != nMaxTextLen && sText.getLength() > nMaxTextLen )
                 [ #  # ]
    1222                 :            :     {
    1223                 :          0 :         sal_Int32 nDiff = sText.getLength() - nMaxTextLen;
    1224                 :          0 :         sText = sText.replaceAt(sText.getLength() - nDiff,nDiff,::rtl::OUString());
    1225                 :            :     }
    1226                 :            : 
    1227                 :            : 
    1228 [ #  # ][ #  # ]:          0 :     m_pEdit->SetText( sText );
                 [ #  # ]
    1229         [ #  # ]:          0 :     m_pEdit->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    1230                 :          0 : }
    1231                 :            : 
    1232                 :            : //------------------------------------------------------------------------------
    1233                 :          0 : sal_Bool DbTextField::commitControl()
    1234                 :            : {
    1235 [ #  # ][ #  # ]:          0 :     ::rtl::OUString aText( m_pEdit->GetText( getModelLineEndSetting( m_rColumn.getModel() ) ) );
         [ #  # ][ #  # ]
    1236                 :            :     // we have to check if the length before we can decide if the value was modified
    1237         [ #  # ]:          0 :     xub_StrLen nMaxTextLen = m_pEdit->GetMaxTextLen();
    1238         [ #  # ]:          0 :     if ( EDIT_NOLIMIT != nMaxTextLen )
    1239                 :            :     {
    1240                 :          0 :         ::rtl::OUString sOldValue;
    1241 [ #  # ][ #  # ]:          0 :         m_rColumn.getModel()->getPropertyValue( FM_PROP_TEXT ) >>= sOldValue;
                 [ #  # ]
    1242                 :            :         // if the new value didn't change we must set the old long value again
    1243 [ #  # ][ #  # ]:          0 :         if ( sOldValue.getLength() > nMaxTextLen && sOldValue.compareTo(aText,nMaxTextLen) == 0 )
                 [ #  # ]
    1244                 :          0 :             aText = sOldValue;
    1245                 :            :     }
    1246 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue( FM_PROP_TEXT, makeAny( aText ) );
         [ #  # ][ #  # ]
    1247                 :          0 :     return sal_True;
    1248                 :            : }
    1249                 :            : 
    1250                 :            : //------------------------------------------------------------------------------
    1251                 :         34 : void DbTextField::implSetEffectiveMaxTextLen( sal_Int16 _nMaxLen )
    1252                 :            : {
    1253         [ +  - ]:         34 :     if ( m_pEdit )
    1254                 :         34 :         m_pEdit->SetMaxTextLen( _nMaxLen );
    1255         [ +  - ]:         34 :     if ( m_pPainterImplementation )
    1256                 :         34 :         m_pPainterImplementation->SetMaxTextLen( _nMaxLen );
    1257                 :         34 : }
    1258                 :            : 
    1259                 :            : //==============================================================================
    1260                 :            : //= DbFormattedField
    1261                 :            : //==============================================================================
    1262                 :            : DBG_NAME(DbFormattedField);
    1263                 :            : //------------------------------------------------------------------------------
    1264                 :         28 : DbFormattedField::DbFormattedField(DbGridColumn& _rColumn)
    1265                 :            :     :DbLimitedLengthField(_rColumn)
    1266                 :         28 :     ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED)
    1267                 :            : {
    1268                 :            :     DBG_CTOR(DbFormattedField,NULL);
    1269                 :            : 
    1270                 :            :     // if our model's format key changes we want to propagate the new value to our windows
    1271 [ +  - ][ +  - ]:         28 :     doPropertyListening( FM_PROP_FORMATKEY );
    1272                 :         28 : }
    1273                 :            : 
    1274                 :            : //------------------------------------------------------------------------------
    1275                 :         28 : DbFormattedField::~DbFormattedField()
    1276                 :            : {
    1277                 :            :     DBG_DTOR(DbFormattedField,NULL);
    1278         [ -  + ]:         56 : }
    1279                 :            : 
    1280                 :            : //------------------------------------------------------------------------------
    1281                 :         28 : void DbFormattedField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
    1282                 :            : {
    1283         [ +  - ]:         28 :     sal_Int16 nAlignment = m_rColumn.SetAlignmentFromModel(-1);
    1284                 :            : 
    1285                 :         28 :     Reference< ::com::sun::star::beans::XPropertySet >  xUnoModel = m_rColumn.getModel();
    1286                 :            : 
    1287      [ -  -  + ]:         28 :     switch (nAlignment)
    1288                 :            :     {
    1289                 :            :         case ::com::sun::star::awt::TextAlign::RIGHT:
    1290 [ #  # ][ #  # ]:          0 :             m_pWindow  = new FormattedField( &rParent, WB_RIGHT );
    1291 [ #  # ][ #  # ]:          0 :             m_pPainter = new FormattedField( &rParent, WB_RIGHT );
    1292                 :            :             break;
    1293                 :            : 
    1294                 :            :         case ::com::sun::star::awt::TextAlign::CENTER:
    1295 [ #  # ][ #  # ]:          0 :             m_pWindow  = new FormattedField( &rParent, WB_CENTER );
    1296 [ #  # ][ #  # ]:          0 :             m_pPainter  = new FormattedField( &rParent, WB_CENTER );
    1297                 :            :             break;
    1298                 :            :         default:
    1299 [ +  - ][ +  - ]:         28 :             m_pWindow  = new FormattedField( &rParent, WB_LEFT );
    1300 [ +  - ][ +  - ]:         28 :             m_pPainter  = new FormattedField( &rParent, WB_LEFT );
    1301                 :            : 
    1302                 :            :             // Alles nur damit die Selektion bei Focuserhalt von rechts nach links geht
    1303         [ +  - ]:         28 :             AllSettings aSettings = m_pWindow->GetSettings();
    1304         [ +  - ]:         28 :             StyleSettings aStyleSettings = aSettings.GetStyleSettings();
    1305                 :            :             aStyleSettings.SetSelectionOptions(
    1306         [ +  - ]:         28 :                 aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
    1307         [ +  - ]:         28 :             aSettings.SetStyleSettings(aStyleSettings);
    1308 [ +  - ][ +  - ]:         28 :             m_pWindow->SetSettings(aSettings);
                 [ +  - ]
    1309                 :            :     }
    1310                 :            : 
    1311         [ +  - ]:         28 :     implAdjustGenericFieldSetting( xUnoModel );
    1312                 :            : 
    1313                 :         28 :     static_cast< FormattedField* >( m_pWindow )->SetStrictFormat( sal_False );
    1314                 :         28 :     static_cast< FormattedField* >( m_pPainter )->SetStrictFormat( sal_False );
    1315                 :            :         // wenn man _irgendeine_ Formatierung zulaesst, kann man da sowieso keine Eingabe-Ueberpruefung
    1316                 :            :         // machen (das FormattedField unterstuetzt das sowieso nicht, nur abgeleitete Klassen)
    1317                 :            : 
    1318                 :            :     // von dem Uno-Model den Formatter besorgen
    1319                 :            :     // (Ich koennte theoretisch auch ueber den ::com::sun::star::util::NumberFormatter gehen, den mir der Cursor bestimmt
    1320                 :            :     // liefern wuerde. Das Problem dabei ist, dass ich mich eigentlich nicht darauf verlassen
    1321                 :            :     // kann, dass die beiden Formatter die selben sind, sauber ist das Ganze, wenn ich ueber das
    1322                 :            :     // UNO-Model gehe.)
    1323                 :         28 :     sal_Int32 nFormatKey = -1;
    1324                 :            : 
    1325                 :            :     // mal sehen, ob das Model einen hat ...
    1326                 :            :     DBG_ASSERT(::comphelper::hasProperty(FM_PROP_FORMATSSUPPLIER, xUnoModel), "DbFormattedField::Init : invalid UNO model !");
    1327 [ +  - ][ +  - ]:         28 :     Any aSupplier( xUnoModel->getPropertyValue(FM_PROP_FORMATSSUPPLIER));
                 [ +  - ]
    1328         [ +  - ]:         28 :     if (aSupplier.hasValue())
    1329                 :            :     {
    1330         [ +  - ]:         28 :         ::cppu::extractInterface(m_xSupplier, aSupplier);
    1331         [ +  - ]:         28 :         if (m_xSupplier.is())
    1332                 :            :         {
    1333                 :            :             // wenn wir den Supplier vom Model nehmen, dann auch den Key
    1334 [ +  - ][ +  - ]:         28 :             Any aFmtKey( xUnoModel->getPropertyValue(FM_PROP_FORMATKEY));
                 [ +  - ]
    1335         [ +  - ]:         28 :             if (aFmtKey.hasValue())
    1336                 :            :             {
    1337                 :            :                 DBG_ASSERT(aFmtKey.getValueType().getTypeClass() == TypeClass_LONG, "DbFormattedField::Init : invalid format key property (no sal_Int32) !");
    1338         [ +  - ]:         28 :                 nFormatKey = ::comphelper::getINT32(aFmtKey);
    1339                 :            :             }
    1340                 :            :             else
    1341                 :            :             {
    1342                 :            :                 DBG_WARNING("DbFormattedField::Init : my uno-model has no format-key, but a formats supplier !");
    1343                 :            :                 // the OFormattedModel which we usually are working with ensures that the model has a format key
    1344                 :            :                 // as soon as the form is loaded. Unfortunally this method here is called from within loaded, too.
    1345                 :            :                 // So if our LoadListener is called before the LoadListener of the model, this "else case" is
    1346                 :            :                 // allowed.
    1347                 :            :                 // Of course our property listener for the FormatKey property will notify us if the prop is changed,
    1348                 :            :                 // so this here isn't really bad ....
    1349                 :          0 :                 nFormatKey = 0;
    1350                 :         28 :             }
    1351                 :            :         }
    1352                 :            :     }
    1353                 :            : 
    1354                 :            :     // nein ? vielleicht die ::com::sun::star::form::component::Form hinter dem Cursor ?
    1355         [ -  + ]:         28 :     if (!m_xSupplier.is())
    1356                 :            :     {
    1357         [ #  # ]:          0 :         Reference< XRowSet >  xCursorForm(xCursor, UNO_QUERY);
    1358         [ #  # ]:          0 :         if (xCursorForm.is())
    1359                 :            :         {   // wenn wir vom Cursor den Formatter nehmen, dann auch den Key vom Feld, an das wir gebunden sind
    1360 [ #  # ][ #  # ]:          0 :             m_xSupplier = getNumberFormats(getRowSetConnection(xCursorForm), sal_False);
                 [ #  # ]
    1361                 :            : 
    1362         [ #  # ]:          0 :             if (m_rColumn.GetField().is())
    1363 [ #  # ][ #  # ]:          0 :                 nFormatKey = ::comphelper::getINT32(m_rColumn.GetField()->getPropertyValue(FM_PROP_FORMATKEY));
         [ #  # ][ #  # ]
    1364                 :          0 :         }
    1365                 :            :     }
    1366                 :            : 
    1367                 :         28 :     SvNumberFormatter* pFormatterUsed = NULL;
    1368         [ +  - ]:         28 :     if (m_xSupplier.is())
    1369                 :            :     {
    1370         [ +  - ]:         28 :         SvNumberFormatsSupplierObj* pImplmentation = SvNumberFormatsSupplierObj::getImplementation(m_xSupplier);
    1371         [ +  - ]:         28 :         if (pImplmentation)
    1372         [ +  - ]:         28 :             pFormatterUsed = pImplmentation->GetNumberFormatter();
    1373                 :            :         else
    1374                 :            :             // alles hingfaellig : der Supplier ist vom falschen Typ, dann koennen wir uns auch nicht darauf verlassen, dass
    1375                 :            :             // ein Standard-Formatter den (eventuell nicht-Standard-)Key kennt.
    1376                 :          0 :             nFormatKey = -1;
    1377                 :            :     }
    1378                 :            : 
    1379                 :            :     // einen Standard-Formatter ...
    1380         [ -  + ]:         28 :     if (pFormatterUsed == NULL)
    1381                 :            :     {
    1382         [ #  # ]:          0 :         pFormatterUsed = ((FormattedField*)m_pWindow)->StandardFormatter();
    1383                 :            :         DBG_ASSERT(pFormatterUsed != NULL, "DbFormattedField::Init : no standard formatter given by the numeric field !");
    1384                 :            :     }
    1385                 :            :     // ... und einen Standard-Key
    1386         [ -  + ]:         28 :     if (nFormatKey == -1)
    1387                 :          0 :         nFormatKey = 0;
    1388                 :            : 
    1389 [ +  - ][ +  - ]:         28 :     m_nKeyType  = comphelper::getNumberFormatType(m_xSupplier->getNumberFormats(), nFormatKey);
                 [ +  - ]
    1390                 :            : 
    1391         [ +  - ]:         28 :     ((FormattedField*)m_pWindow)->SetFormatter(pFormatterUsed);
    1392         [ +  - ]:         28 :     ((FormattedField*)m_pPainter)->SetFormatter(pFormatterUsed);
    1393                 :            : 
    1394         [ +  - ]:         28 :     ((FormattedField*)m_pWindow)->SetFormatKey(nFormatKey);
    1395         [ +  - ]:         28 :     ((FormattedField*)m_pPainter)->SetFormatKey(nFormatKey);
    1396                 :            : 
    1397                 :         28 :     ((FormattedField*)m_pWindow)->TreatAsNumber(m_rColumn.IsNumeric());
    1398                 :         28 :     ((FormattedField*)m_pPainter)->TreatAsNumber(m_rColumn.IsNumeric());
    1399                 :            : 
    1400                 :            :     // Min- und Max-Werte
    1401         [ -  + ]:         28 :     if (m_rColumn.IsNumeric())
    1402                 :            :     {
    1403                 :          0 :         sal_Bool bClearMin = sal_True;
    1404 [ #  # ][ #  # ]:          0 :         if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MIN, xUnoModel))
                 [ #  # ]
    1405                 :            :         {
    1406 [ #  # ][ #  # ]:          0 :             Any aMin( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MIN));
                 [ #  # ]
    1407         [ #  # ]:          0 :             if (aMin.getValueType().getTypeClass() != TypeClass_VOID)
    1408                 :            :             {
    1409                 :            :                 DBG_ASSERT(aMin.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid min value !");
    1410         [ #  # ]:          0 :                 double dMin = ::comphelper::getDouble(aMin);
    1411         [ #  # ]:          0 :                 ((FormattedField*)m_pWindow)->SetMinValue(dMin);
    1412         [ #  # ]:          0 :                 ((FormattedField*)m_pPainter)->SetMinValue(dMin);
    1413                 :          0 :                 bClearMin = sal_False;
    1414                 :          0 :             }
    1415                 :            :         }
    1416         [ #  # ]:          0 :         if (bClearMin)
    1417                 :            :         {
    1418                 :          0 :             ((FormattedField*)m_pWindow)->ClearMinValue();
    1419                 :          0 :             ((FormattedField*)m_pPainter)->ClearMinValue();
    1420                 :            :         }
    1421                 :          0 :         sal_Bool bClearMax = sal_True;
    1422 [ #  # ][ #  # ]:          0 :         if (::comphelper::hasProperty(FM_PROP_EFFECTIVE_MAX, xUnoModel))
                 [ #  # ]
    1423                 :            :         {
    1424 [ #  # ][ #  # ]:          0 :             Any aMin( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_MAX));
                 [ #  # ]
    1425         [ #  # ]:          0 :             if (aMin.getValueType().getTypeClass() != TypeClass_VOID)
    1426                 :            :             {
    1427                 :            :                 DBG_ASSERT(aMin.getValueType().getTypeClass() == TypeClass_DOUBLE, "DbFormattedField::Init : the model has an invalid max value !");
    1428         [ #  # ]:          0 :                 double dMin = ::comphelper::getDouble(aMin);
    1429         [ #  # ]:          0 :                 ((FormattedField*)m_pWindow)->SetMaxValue(dMin);
    1430         [ #  # ]:          0 :                 ((FormattedField*)m_pPainter)->SetMaxValue(dMin);
    1431                 :          0 :                 bClearMax = sal_False;
    1432                 :          0 :             }
    1433                 :            :         }
    1434         [ #  # ]:          0 :         if (bClearMax)
    1435                 :            :         {
    1436                 :          0 :             ((FormattedField*)m_pWindow)->ClearMaxValue();
    1437                 :          0 :             ((FormattedField*)m_pPainter)->ClearMaxValue();
    1438                 :            :         }
    1439                 :            :     }
    1440                 :            : 
    1441                 :            :     // den Default-Wert
    1442 [ +  - ][ +  - ]:         28 :     Any aDefault( xUnoModel->getPropertyValue(FM_PROP_EFFECTIVE_DEFAULT));
                 [ +  - ]
    1443         [ -  + ]:         28 :     if (aDefault.hasValue())
    1444                 :            :     {   // das Ding kann ein double oder ein String sein
    1445      [ #  #  # ]:          0 :         switch (aDefault.getValueType().getTypeClass())
    1446                 :            :         {
    1447                 :            :             case TypeClass_DOUBLE:
    1448         [ #  # ]:          0 :                 if (m_rColumn.IsNumeric())
    1449                 :            :                 {
    1450         [ #  # ]:          0 :                     ((FormattedField*)m_pWindow)->SetDefaultValue(::comphelper::getDouble(aDefault));
    1451         [ #  # ]:          0 :                     ((FormattedField*)m_pPainter)->SetDefaultValue(::comphelper::getDouble(aDefault));
    1452                 :            :                 }
    1453                 :            :                 else
    1454                 :            :                 {
    1455         [ #  # ]:          0 :                     String sConverted;
    1456                 :            :                     Color* pDummy;
    1457 [ #  # ][ #  # ]:          0 :                     pFormatterUsed->GetOutputString(::comphelper::getDouble(aDefault), 0, sConverted, &pDummy);
    1458         [ #  # ]:          0 :                     ((FormattedField*)m_pWindow)->SetDefaultText(sConverted);
    1459 [ #  # ][ #  # ]:          0 :                     ((FormattedField*)m_pPainter)->SetDefaultText(sConverted);
    1460                 :            :                 }
    1461                 :          0 :                 break;
    1462                 :            :             case TypeClass_STRING:
    1463                 :            :             {
    1464 [ #  # ][ #  # ]:          0 :                 String sDefault( ::comphelper::getString(aDefault) );
    1465         [ #  # ]:          0 :                 if (m_rColumn.IsNumeric())
    1466                 :            :                 {
    1467                 :            :                     double dVal;
    1468                 :          0 :                     sal_uInt32 nTestFormat(0);
    1469 [ #  # ][ #  # ]:          0 :                     if (pFormatterUsed->IsNumberFormat(sDefault, nTestFormat, dVal))
    1470                 :            :                     {
    1471                 :          0 :                         ((FormattedField*)m_pWindow)->SetDefaultValue(dVal);
    1472                 :          0 :                         ((FormattedField*)m_pPainter)->SetDefaultValue(dVal);
    1473                 :            :                     }
    1474                 :            :                 }
    1475                 :            :                 else
    1476                 :            :                 {
    1477         [ #  # ]:          0 :                     ((FormattedField*)m_pWindow)->SetDefaultText(sDefault);
    1478         [ #  # ]:          0 :                     ((FormattedField*)m_pPainter)->SetDefaultText(sDefault);
    1479         [ #  # ]:          0 :                 }
    1480                 :            :             }
    1481                 :            :             default:
    1482                 :            :                 OSL_FAIL( "DbFormattedField::Init: unexpected value type!" );
    1483                 :          0 :                 break;
    1484                 :            :         }
    1485                 :            :     }
    1486         [ +  - ]:         28 :     DbLimitedLengthField::Init( rParent, xCursor );
    1487                 :         28 : }
    1488                 :            : 
    1489                 :            : //------------------------------------------------------------------------------
    1490                 :         28 : CellControllerRef DbFormattedField::CreateController() const
    1491                 :            : {
    1492         [ +  - ]:         28 :     return new ::svt::FormattedFieldCellController( static_cast< FormattedField* >( m_pWindow ) );
    1493                 :            : }
    1494                 :            : 
    1495                 :            : //------------------------------------------------------------------------------
    1496                 :          0 : void DbFormattedField::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw( RuntimeException )
    1497                 :            : {
    1498         [ #  # ]:          0 :     if (_rEvent.PropertyName.compareTo(FM_PROP_FORMATKEY) == COMPARE_EQUAL)
    1499                 :            :     {
    1500         [ #  # ]:          0 :         sal_Int32 nNewKey = _rEvent.NewValue.hasValue() ? ::comphelper::getINT32(_rEvent.NewValue) : 0;
    1501         [ #  # ]:          0 :         m_nKeyType = comphelper::getNumberFormatType(m_xSupplier->getNumberFormats(), nNewKey);
    1502                 :            : 
    1503                 :            :         DBG_ASSERT(m_pWindow && m_pPainter, "DbFormattedField::_propertyChanged : where are my windows ?");
    1504         [ #  # ]:          0 :         if (m_pWindow)
    1505                 :          0 :             static_cast< FormattedField* >( m_pWindow )->SetFormatKey( nNewKey );
    1506         [ #  # ]:          0 :         if (m_pPainter)
    1507                 :          0 :             static_cast< FormattedField* >( m_pPainter )->SetFormatKey( nNewKey );
    1508                 :            :     }
    1509                 :            :     else
    1510                 :            :     {
    1511                 :          0 :         DbLimitedLengthField::_propertyChanged( _rEvent );
    1512                 :            :     }
    1513                 :          0 : }
    1514                 :            : 
    1515                 :            : //------------------------------------------------------------------------------
    1516                 :         64 : String DbFormattedField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** ppColor)
    1517                 :            : {
    1518                 :            :     // defaultmaessig keine Farb-Angabe
    1519         [ +  - ]:         64 :     if (ppColor != NULL)
    1520                 :         64 :         *ppColor = NULL;
    1521                 :            : 
    1522                 :            :     // NULL-Wert -> leerer Text
    1523         [ -  + ]:         64 :     if (!_rxField.is())
    1524         [ #  # ]:          0 :         return String();
    1525                 :            : 
    1526         [ +  - ]:         64 :     String aText;
    1527                 :            :     try
    1528                 :            :     {
    1529         [ -  + ]:         64 :         if (m_rColumn.IsNumeric())
    1530                 :            :         {
    1531                 :            :             // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
    1532                 :            :             // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
    1533                 :            :             // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
    1534                 :            :             // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
    1535                 :            :             // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
    1536         [ #  # ]:          0 :             double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
    1537 [ #  # ][ #  # ]:          0 :             if (_rxField->wasNull())
                 [ #  # ]
    1538         [ #  # ]:          0 :                 return aText;
    1539         [ #  # ]:          0 :             ((FormattedField*)m_pPainter)->SetValue(dValue);
    1540                 :            :         }
    1541                 :            :         else
    1542                 :            :         {
    1543                 :            :             // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
    1544                 :            :             // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
    1545 [ +  - ][ +  - ]:         64 :             aText = _rxField->getString();
         [ +  - ][ #  # ]
    1546 [ +  - ][ +  + ]:         64 :             if (_rxField->wasNull())
                 [ +  - ]
    1547         [ +  - ]:         32 :                 return aText;
    1548         [ +  - ]:         32 :             ((FormattedField*)m_pPainter)->SetTextFormatted(aText);
    1549                 :            :         }
    1550                 :            :     }
    1551         [ #  # ]:          0 :     catch( const Exception& )
    1552                 :            :     {
    1553                 :            :         DBG_UNHANDLED_EXCEPTION();
    1554                 :            :     }
    1555                 :            : 
    1556 [ +  - ][ +  - ]:         32 :     aText = m_pPainter->GetText();
                 [ +  - ]
    1557         [ +  - ]:         32 :     if (ppColor != NULL)
    1558                 :         32 :         *ppColor = ((FormattedField*)m_pPainter)->GetLastOutputColor();
    1559                 :            : 
    1560 [ +  - ][ +  - ]:         64 :     return aText;
    1561                 :            : }
    1562                 :            : 
    1563                 :            : //------------------------------------------------------------------------------
    1564                 :          0 : void DbFormattedField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
    1565                 :            : {
    1566                 :            :     try
    1567                 :            :     {
    1568                 :          0 :         FormattedField* pFormattedWindow = static_cast<FormattedField*>(m_pWindow);
    1569         [ #  # ]:          0 :         if (!_rxField.is())
    1570                 :            :         {   // NULL-Wert -> leerer Text
    1571 [ #  # ][ #  # ]:          0 :             m_pWindow->SetText(String());
                 [ #  # ]
    1572                 :            :         }
    1573         [ #  # ]:          0 :         else if (m_rColumn.IsNumeric())
    1574                 :            :         {
    1575                 :            :             // das IsNumeric an der Column sagt nichts aus ueber die Klasse des benutzen Formates, sondern
    1576                 :            :             // ueber die des an die Column gebundenen Feldes. Wenn man also eine FormattedField-Spalte an
    1577                 :            :             // ein double-Feld bindet und als Text formatiert, liefert m_rColumn.IsNumeric() sal_True. Das heisst
    1578                 :            :             // also einfach, dass ich den Inhalt der Variant mittels getDouble abfragen kann, und dann kann
    1579                 :            :             // ich den Rest (die Formatierung) dem FormattedField ueberlassen.
    1580         [ #  # ]:          0 :             double dValue = getValue( _rxField, m_rColumn.GetParent().getNullDate() );
    1581 [ #  # ][ #  # ]:          0 :             if (_rxField->wasNull())
                 [ #  # ]
    1582 [ #  # ][ #  # ]:          0 :                 m_pWindow->SetText(String());
                 [ #  # ]
    1583                 :            :             else
    1584         [ #  # ]:          0 :                 pFormattedWindow->SetValue(dValue);
    1585                 :            :         }
    1586                 :            :         else
    1587                 :            :         {
    1588                 :            :             // Hier kann ich nicht mit einem double arbeiten, da das Feld mir keines liefern kann.
    1589                 :            :             // Also einfach den Text vom ::com::sun::star::util::NumberFormatter in die richtige ::com::sun::star::form::component::Form brinden lassen.
    1590 [ #  # ][ #  # ]:          0 :             String sText( _rxField->getString());
                 [ #  # ]
    1591                 :            : 
    1592         [ #  # ]:          0 :             pFormattedWindow->SetTextFormatted( sText );
    1593 [ #  # ][ #  # ]:          0 :             pFormattedWindow->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
                 [ #  # ]
    1594                 :            :         }
    1595                 :            :     }
    1596                 :          0 :     catch( const Exception& )
    1597                 :            :     {
    1598                 :            :         DBG_UNHANDLED_EXCEPTION();
    1599                 :            :     }
    1600                 :          0 : }
    1601                 :            : 
    1602                 :            : //------------------------------------------------------------------------------
    1603                 :          0 : void DbFormattedField::updateFromModel( Reference< XPropertySet > _rxModel )
    1604                 :            : {
    1605                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFormattedField::updateFromModel: invalid call!" );
    1606                 :            : 
    1607                 :          0 :     FormattedField* pFormattedWindow = static_cast< FormattedField* >( m_pWindow );
    1608                 :            : 
    1609                 :          0 :     ::rtl::OUString sText;
    1610 [ #  # ][ #  # ]:          0 :     Any aValue = _rxModel->getPropertyValue( FM_PROP_EFFECTIVE_VALUE );
                 [ #  # ]
    1611         [ #  # ]:          0 :     if ( aValue >>= sText )
    1612                 :            :     {   // our effective value is transfered as string
    1613 [ #  # ][ #  # ]:          0 :         pFormattedWindow->SetTextFormatted( sText );
                 [ #  # ]
    1614         [ #  # ]:          0 :         pFormattedWindow->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    1615                 :            :     }
    1616                 :            :     else
    1617                 :            :     {
    1618                 :          0 :         double dValue = 0;
    1619                 :          0 :         aValue >>= dValue;
    1620         [ #  # ]:          0 :         pFormattedWindow->SetValue(dValue);
    1621                 :          0 :     }
    1622                 :          0 : }
    1623                 :            : 
    1624                 :            : //------------------------------------------------------------------------------
    1625                 :          0 : sal_Bool DbFormattedField::commitControl()
    1626                 :            : {
    1627                 :          0 :     Any aNewVal;
    1628                 :          0 :     FormattedField& rField = *(FormattedField*)m_pWindow;
    1629                 :            :     DBG_ASSERT(&rField == m_pWindow, "DbFormattedField::commitControl : can't work with a window other than my own !");
    1630         [ #  # ]:          0 :     if (m_rColumn.IsNumeric())
    1631                 :            :     {
    1632 [ #  # ][ #  # ]:          0 :         if (rField.GetText().Len() != 0)
                 [ #  # ]
    1633 [ #  # ][ #  # ]:          0 :             aNewVal <<= rField.GetValue();
    1634                 :            :         // ein LeerString wird erst mal standardmaessig als void weitergereicht
    1635                 :            :     }
    1636                 :            :     else
    1637 [ #  # ][ #  # ]:          0 :         aNewVal <<= ::rtl::OUString(rField.GetTextValue());
         [ #  # ][ #  # ]
    1638                 :            : 
    1639 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_EFFECTIVE_VALUE, aNewVal);
                 [ #  # ]
    1640                 :          0 :     return sal_True;
    1641                 :            : }
    1642                 :            : 
    1643                 :            : //==============================================================================
    1644                 :            : //= DbCheckBox
    1645                 :            : //==============================================================================
    1646                 :            : //------------------------------------------------------------------------------
    1647                 :          0 : DbCheckBox::DbCheckBox( DbGridColumn& _rColumn )
    1648                 :          0 :     :DbCellControl( _rColumn, sal_True )
    1649                 :            : {
    1650                 :          0 :     setAlignedController( sal_False );
    1651                 :          0 : }
    1652                 :            : 
    1653                 :            : namespace
    1654                 :            : {
    1655                 :          0 :     void setCheckBoxStyle( Window* _pWindow, bool bMono )
    1656                 :            :     {
    1657         [ #  # ]:          0 :         AllSettings aSettings = _pWindow->GetSettings();
    1658         [ #  # ]:          0 :         StyleSettings aStyleSettings = aSettings.GetStyleSettings();
    1659         [ #  # ]:          0 :         if( bMono )
    1660         [ #  # ]:          0 :             aStyleSettings.SetOptions( aStyleSettings.GetOptions() | STYLE_OPTION_MONO );
    1661                 :            :         else
    1662         [ #  # ]:          0 :             aStyleSettings.SetOptions( aStyleSettings.GetOptions() & (~STYLE_OPTION_MONO) );
    1663         [ #  # ]:          0 :         aSettings.SetStyleSettings( aStyleSettings );
    1664 [ #  # ][ #  # ]:          0 :         _pWindow->SetSettings( aSettings );
                 [ #  # ]
    1665                 :          0 :     }
    1666                 :            : }
    1667                 :            : 
    1668                 :            : //------------------------------------------------------------------------------
    1669                 :          0 : void DbCheckBox::Init( Window& rParent, const Reference< XRowSet >& xCursor )
    1670                 :            : {
    1671                 :          0 :     setTransparent( sal_True );
    1672                 :            : 
    1673         [ #  # ]:          0 :     m_pWindow  = new CheckBoxControl( &rParent );
    1674         [ #  # ]:          0 :     m_pPainter = new CheckBoxControl( &rParent );
    1675                 :            : 
    1676                 :          0 :     m_pWindow->SetPaintTransparent( sal_True );
    1677                 :          0 :     m_pPainter->SetPaintTransparent( sal_True );
    1678                 :            : 
    1679                 :          0 :     m_pPainter->SetBackground();
    1680                 :            : 
    1681                 :            :     try
    1682                 :            :     {
    1683         [ #  # ]:          0 :         Reference< XPropertySet > xModel( m_rColumn.getModel(), UNO_SET_THROW );
    1684                 :            : 
    1685                 :          0 :         sal_Int16 nStyle = awt::VisualEffect::LOOK3D;
    1686 [ #  # ][ #  # ]:          0 :         OSL_VERIFY( xModel->getPropertyValue( FM_PROP_VISUALEFFECT ) >>= nStyle );
                 [ #  # ]
    1687                 :            : 
    1688         [ #  # ]:          0 :         setCheckBoxStyle( m_pWindow, nStyle == awt::VisualEffect::FLAT );
    1689         [ #  # ]:          0 :         setCheckBoxStyle( m_pPainter, nStyle == awt::VisualEffect::FLAT );
    1690                 :            : 
    1691                 :          0 :         sal_Bool bTristate = sal_True;
    1692 [ #  # ][ #  # ]:          0 :         OSL_VERIFY( xModel->getPropertyValue( FM_PROP_TRISTATE ) >>= bTristate );
                 [ #  # ]
    1693         [ #  # ]:          0 :         static_cast< CheckBoxControl* >( m_pWindow )->GetBox().EnableTriState( bTristate );
    1694 [ #  # ][ #  # ]:          0 :         static_cast< CheckBoxControl* >( m_pPainter )->GetBox().EnableTriState( bTristate );
    1695                 :            :     }
    1696                 :          0 :     catch( const Exception& )
    1697                 :            :     {
    1698                 :            :         DBG_UNHANDLED_EXCEPTION();
    1699                 :            :     }
    1700                 :            : 
    1701                 :          0 :     DbCellControl::Init( rParent, xCursor );
    1702                 :          0 : }
    1703                 :            : 
    1704                 :            : //------------------------------------------------------------------------------
    1705                 :          0 : CellControllerRef DbCheckBox::CreateController() const
    1706                 :            : {
    1707         [ #  # ]:          0 :     return new CheckBoxCellController((CheckBoxControl*)m_pWindow);
    1708                 :            : }
    1709                 :            : //------------------------------------------------------------------------------
    1710                 :          0 : static void lcl_setCheckBoxState(   const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
    1711                 :            :                         CheckBoxControl* _pCheckBoxControl )
    1712                 :            : {
    1713                 :          0 :     TriState eState = STATE_DONTKNOW;
    1714         [ #  # ]:          0 :     if (_rxField.is())
    1715                 :            :     {
    1716                 :            :         try
    1717                 :            :         {
    1718 [ #  # ][ #  # ]:          0 :             sal_Bool bValue = _rxField->getBoolean();
    1719 [ #  # ][ #  # ]:          0 :             if (!_rxField->wasNull())
                 [ #  # ]
    1720         [ #  # ]:          0 :                 eState = bValue ? STATE_CHECK : STATE_NOCHECK;
    1721                 :            :         }
    1722                 :          0 :         catch( const Exception& )
    1723                 :            :         {
    1724                 :            :             DBG_UNHANDLED_EXCEPTION();
    1725                 :            :         }
    1726                 :            :     }
    1727                 :          0 :     _pCheckBoxControl->GetBox().SetState(eState);
    1728         [ #  # ]:          0 : }
    1729                 :            : 
    1730                 :            : //------------------------------------------------------------------------------
    1731                 :          0 : void DbCheckBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
    1732                 :            : {
    1733                 :          0 :     lcl_setCheckBoxState( _rxField, static_cast<CheckBoxControl*>(m_pWindow) );
    1734                 :          0 : }
    1735                 :            : 
    1736                 :            : //------------------------------------------------------------------------------
    1737                 :          0 : void DbCheckBox::PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
    1738                 :            :                           const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
    1739                 :            :                           const Reference< XNumberFormatter >& xFormatter)
    1740                 :            : {
    1741                 :          0 :     lcl_setCheckBoxState( _rxField, static_cast<CheckBoxControl*>(m_pPainter) );
    1742                 :          0 :     DbCellControl::PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
    1743                 :          0 : }
    1744                 :            : 
    1745                 :            : //------------------------------------------------------------------------------
    1746                 :          0 : void DbCheckBox::updateFromModel( Reference< XPropertySet > _rxModel )
    1747                 :            : {
    1748                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCheckBox::updateFromModel: invalid call!" );
    1749                 :            : 
    1750                 :          0 :     sal_Int16 nState = STATE_DONTKNOW;
    1751 [ #  # ][ #  # ]:          0 :     _rxModel->getPropertyValue( FM_PROP_STATE ) >>= nState;
                 [ #  # ]
    1752         [ #  # ]:          0 :     static_cast< CheckBoxControl* >( m_pWindow )->GetBox().SetState( static_cast< TriState >( nState ) );
    1753                 :          0 : }
    1754                 :            : 
    1755                 :            : //------------------------------------------------------------------------------
    1756                 :          0 : sal_Bool DbCheckBox::commitControl()
    1757                 :            : {
    1758                 :            : #if OSL_DEBUG_LEVEL > 0
    1759                 :            :     Any aVal = makeAny( (sal_Int16)( static_cast< CheckBoxControl* >( m_pWindow )->GetBox().GetState() ) );
    1760                 :            : #endif
    1761                 :          0 :     m_rColumn.getModel()->setPropertyValue( FM_PROP_STATE,
    1762 [ #  # ][ #  # ]:          0 :                     makeAny( (sal_Int16)( static_cast< CheckBoxControl* >( m_pWindow )->GetBox().GetState() ) ) );
                 [ #  # ]
    1763                 :          0 :     return sal_True;
    1764                 :            : }
    1765                 :            : 
    1766                 :            : //------------------------------------------------------------------------------
    1767                 :          0 : XubString DbCheckBox::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    1768                 :            : {
    1769                 :          0 :     return XubString();
    1770                 :            : }
    1771                 :            : 
    1772                 :            : //==============================================================================
    1773                 :            : //= DbPatternField
    1774                 :            : //------------------------------------------------------------------------------
    1775                 :          0 : DbPatternField::DbPatternField( DbGridColumn& _rColumn, const ::comphelper::ComponentContext& _rContext )
    1776                 :            :     :DbCellControl( _rColumn )
    1777         [ #  # ]:          0 :     ,m_aContext( _rContext )
    1778                 :            : {
    1779 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_LITERALMASK );
    1780 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_EDITMASK );
    1781 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRICTFORMAT );
    1782                 :          0 : }
    1783                 :            : 
    1784                 :            : //------------------------------------------------------------------------------
    1785                 :          0 : void DbPatternField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    1786                 :            : {
    1787                 :            :     DBG_ASSERT( m_pWindow, "DbPatternField::implAdjustGenericFieldSetting: not to be called without window!" );
    1788                 :            :     DBG_ASSERT( _rxModel.is(), "DbPatternField::implAdjustGenericFieldSetting: invalid model!" );
    1789 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    1790                 :            :     {
    1791                 :          0 :         ::rtl::OUString aLitMask;
    1792                 :          0 :         ::rtl::OUString aEditMask;
    1793                 :          0 :         sal_Bool bStrict = sal_False;
    1794                 :            : 
    1795 [ #  # ][ #  # ]:          0 :         _rxModel->getPropertyValue( FM_PROP_LITERALMASK ) >>= aLitMask;
                 [ #  # ]
    1796 [ #  # ][ #  # ]:          0 :         _rxModel->getPropertyValue( FM_PROP_EDITMASK ) >>= aEditMask;
                 [ #  # ]
    1797 [ #  # ][ #  # ]:          0 :         _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) >>= bStrict;
                 [ #  # ]
    1798                 :            : 
    1799         [ #  # ]:          0 :         rtl::OString aAsciiEditMask(rtl::OUStringToOString(aEditMask, RTL_TEXTENCODING_ASCII_US));
    1800                 :            : 
    1801 [ #  # ][ #  # ]:          0 :         static_cast< PatternField* >( m_pWindow )->SetMask( aAsciiEditMask, aLitMask );
                 [ #  # ]
    1802 [ #  # ][ #  # ]:          0 :         static_cast< PatternField* >( m_pPainter )->SetMask( aAsciiEditMask, aLitMask );
                 [ #  # ]
    1803         [ #  # ]:          0 :         static_cast< PatternField* >( m_pWindow )->SetStrictFormat( bStrict );
    1804         [ #  # ]:          0 :         static_cast< PatternField* >( m_pPainter )->SetStrictFormat( bStrict );
    1805                 :            :     }
    1806                 :          0 : }
    1807                 :            : 
    1808                 :            : //------------------------------------------------------------------------------
    1809                 :          0 : void DbPatternField::Init( Window& rParent, const Reference< XRowSet >& xCursor)
    1810                 :            : {
    1811         [ #  # ]:          0 :     m_rColumn.SetAlignmentFromModel(-1);
    1812                 :            : 
    1813 [ #  # ][ #  # ]:          0 :     m_pWindow = new PatternField( &rParent, 0 );
    1814 [ #  # ][ #  # ]:          0 :     m_pPainter= new PatternField( &rParent, 0 );
    1815                 :            : 
    1816                 :          0 :     Reference< XPropertySet >   xModel( m_rColumn.getModel() );
    1817         [ #  # ]:          0 :     implAdjustGenericFieldSetting( xModel );
    1818                 :            : 
    1819         [ #  # ]:          0 :     DbCellControl::Init( rParent, xCursor );
    1820                 :          0 : }
    1821                 :            : 
    1822                 :            : //------------------------------------------------------------------------------
    1823                 :          0 : CellControllerRef DbPatternField::CreateController() const
    1824                 :            : {
    1825         [ #  # ]:          0 :     return new SpinCellController( static_cast< PatternField* >( m_pWindow ) );
    1826                 :            : }
    1827                 :            : 
    1828                 :            : //------------------------------------------------------------------------------
    1829                 :          0 : String DbPatternField::impl_formatText( const String& _rText )
    1830                 :            : {
    1831                 :          0 :     m_pPainter->SetText( _rText );
    1832                 :          0 :     static_cast< PatternField* >( m_pPainter )->ReformatAll();
    1833                 :          0 :     return m_pPainter->GetText();
    1834                 :            : }
    1835                 :            : 
    1836                 :            : //------------------------------------------------------------------------------
    1837                 :          0 : String DbPatternField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    1838                 :            : {
    1839         [ #  # ]:          0 :     bool bIsForPaint = _rxField != m_rColumn.GetField();
    1840                 :            :     SAL_WNODEPRECATED_DECLARATIONS_PUSH
    1841         [ #  # ]:          0 :     ::std::auto_ptr< ::dbtools::FormattedColumnValue >& rpFormatter = bIsForPaint ? m_pPaintFormatter : m_pValueFormatter;
    1842                 :            :     SAL_WNODEPRECATED_DECLARATIONS_POP
    1843                 :            : 
    1844         [ #  # ]:          0 :     if ( !rpFormatter.get() )
    1845                 :            :     {
    1846         [ #  # ]:          0 :         DBToolsObjectFactory aFactory;
    1847                 :            :         rpFormatter = aFactory.createFormattedColumnValue(
    1848 [ #  # ][ #  # ]:          0 :             m_aContext, getCursor(), Reference< XPropertySet >( _rxField, UNO_QUERY ) );
                 [ #  # ]
    1849         [ #  # ]:          0 :         OSL_ENSURE( rpFormatter.get(), "DbPatternField::Init: no value formatter!" );
    1850                 :            :     }
    1851                 :            :     else
    1852                 :            :         OSL_ENSURE( rpFormatter->getColumn() == _rxField, "DbPatternField::GetFormatText: my value formatter is working for another field ...!" );
    1853                 :            :         // re-creating the value formatter here everytime would be quite expensive ...
    1854                 :            : 
    1855         [ #  # ]:          0 :     String sText;
    1856         [ #  # ]:          0 :     if ( rpFormatter.get() )
    1857 [ #  # ][ #  # ]:          0 :         sText = rpFormatter->getFormattedValue();
    1858                 :            : 
    1859 [ #  # ][ #  # ]:          0 :     return impl_formatText( sText );
    1860                 :            : }
    1861                 :            : 
    1862                 :            : //------------------------------------------------------------------------------
    1863                 :          0 : void DbPatternField::UpdateFromField( const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
    1864                 :            : {
    1865         [ #  # ]:          0 :     static_cast< Edit* >( m_pWindow )->SetText( GetFormatText( _rxField, _rxFormatter ) );
    1866         [ #  # ]:          0 :     static_cast< Edit* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    1867                 :          0 : }
    1868                 :            : 
    1869                 :            : //------------------------------------------------------------------------------
    1870                 :          0 : void DbPatternField::updateFromModel( Reference< XPropertySet > _rxModel )
    1871                 :            : {
    1872                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbPatternField::updateFromModel: invalid call!" );
    1873                 :            : 
    1874                 :          0 :     ::rtl::OUString sText;
    1875 [ #  # ][ #  # ]:          0 :     _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
                 [ #  # ]
    1876                 :            : 
    1877 [ #  # ][ #  # ]:          0 :     static_cast< Edit* >( m_pWindow )->SetText( impl_formatText( sText ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1878         [ #  # ]:          0 :     static_cast< Edit* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    1879                 :          0 : }
    1880                 :            : 
    1881                 :            : //------------------------------------------------------------------------------
    1882                 :          0 : sal_Bool DbPatternField::commitControl()
    1883                 :            : {
    1884         [ #  # ]:          0 :     String aText(m_pWindow->GetText());
    1885 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(::rtl::OUString(aText)));
         [ #  # ][ #  # ]
                 [ #  # ]
    1886         [ #  # ]:          0 :     return sal_True;
    1887                 :            : }
    1888                 :            : 
    1889                 :            : //==============================================================================
    1890                 :            : //= DbSpinField
    1891                 :            : //==============================================================================
    1892                 :            : //------------------------------------------------------------------------------
    1893                 :          0 : DbSpinField::DbSpinField( DbGridColumn& _rColumn, sal_Int16 _nStandardAlign )
    1894                 :            :     :DbCellControl( _rColumn )
    1895                 :          0 :     ,m_nStandardAlign( _nStandardAlign )
    1896                 :            : {
    1897                 :          0 : }
    1898                 :            : 
    1899                 :            : //------------------------------------------------------------------------------
    1900                 :          0 : void DbSpinField::Init( Window& _rParent, const Reference< XRowSet >& _rxCursor )
    1901                 :            : {
    1902         [ #  # ]:          0 :     m_rColumn.SetAlignmentFromModel( m_nStandardAlign );
    1903                 :            : 
    1904                 :          0 :     Reference< XPropertySet > xModel( m_rColumn.getModel() );
    1905                 :            : 
    1906                 :            :     // determine the WinBits for the field
    1907                 :          0 :     WinBits nFieldStyle = 0;
    1908 [ #  # ][ #  # ]:          0 :     if ( ::comphelper::getBOOL( xModel->getPropertyValue( FM_PROP_SPIN ) ) )
         [ #  # ][ #  # ]
                 [ #  # ]
    1909                 :          0 :         nFieldStyle = WB_REPEAT | WB_SPIN;
    1910                 :            :     // create the fields
    1911         [ #  # ]:          0 :     m_pWindow = createField( &_rParent, nFieldStyle, xModel );
    1912         [ #  # ]:          0 :     m_pPainter = createField( &_rParent, nFieldStyle, xModel );
    1913                 :            : 
    1914                 :            :     // adjust all other settings which depend on the property values
    1915         [ #  # ]:          0 :     implAdjustGenericFieldSetting( xModel );
    1916                 :            : 
    1917                 :            :     // call the base class
    1918         [ #  # ]:          0 :     DbCellControl::Init( _rParent, _rxCursor );
    1919                 :          0 : }
    1920                 :            : 
    1921                 :            : //------------------------------------------------------------------------------
    1922                 :          0 : CellControllerRef DbSpinField::CreateController() const
    1923                 :            : {
    1924         [ #  # ]:          0 :     return new SpinCellController( static_cast< SpinField* >( m_pWindow ) );
    1925                 :            : }
    1926                 :            : 
    1927                 :            : //==============================================================================
    1928                 :            : //= DbNumericField
    1929                 :            : //==============================================================================
    1930                 :            : //------------------------------------------------------------------------------
    1931                 :          0 : DbNumericField::DbNumericField( DbGridColumn& _rColumn )
    1932                 :          0 :     :DbSpinField( _rColumn )
    1933                 :            : {
    1934 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DECIMAL_ACCURACY );
    1935 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUEMIN );
    1936 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUEMAX );
    1937 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUESTEP );
    1938 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRICTFORMAT );
    1939 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_SHOWTHOUSANDSEP );
    1940                 :          0 : }
    1941                 :            : 
    1942                 :            : //------------------------------------------------------------------------------
    1943                 :          0 : void DbNumericField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    1944                 :            : {
    1945                 :            :     DBG_ASSERT( m_pWindow, "DbNumericField::implAdjustGenericFieldSetting: not to be called without window!" );
    1946                 :            :     DBG_ASSERT( _rxModel.is(), "DbNumericField::implAdjustGenericFieldSetting: invalid model!" );
    1947 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    1948                 :            :     {
    1949 [ #  # ][ #  # ]:          0 :         sal_Int32   nMin        = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
         [ #  # ][ #  # ]
    1950 [ #  # ][ #  # ]:          0 :         sal_Int32   nMax        = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
         [ #  # ][ #  # ]
    1951 [ #  # ][ #  # ]:          0 :         sal_Int32   nStep       = (sal_Int32)getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
         [ #  # ][ #  # ]
    1952 [ #  # ][ #  # ]:          0 :         sal_Bool    bStrict     = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
         [ #  # ][ #  # ]
    1953 [ #  # ][ #  # ]:          0 :         sal_Int16   nScale      = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
         [ #  # ][ #  # ]
    1954 [ #  # ][ #  # ]:          0 :         sal_Bool    bThousand   = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
         [ #  # ][ #  # ]
    1955                 :            : 
    1956         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetMinValue(nMin);
    1957         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetMaxValue(nMax);
    1958                 :          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetSpinSize(nStep);
    1959                 :          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetStrictFormat(bStrict);
    1960                 :            : 
    1961         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pPainter )->SetMinValue(nMin);
    1962         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pPainter )->SetMaxValue(nMax);
    1963                 :          0 :         static_cast< DoubleNumericField* >( m_pPainter )->SetStrictFormat(bStrict);
    1964                 :            : 
    1965                 :            : 
    1966                 :            :         // dem Field und dem Painter einen Formatter spendieren
    1967                 :            :         // zuerst testen, ob ich von dem Service hinter einer Connection bekommen kann
    1968                 :          0 :         Reference< ::com::sun::star::util::XNumberFormatsSupplier >  xSupplier;
    1969                 :          0 :         Reference< XRowSet > xForm;
    1970         [ #  # ]:          0 :         if ( m_rColumn.GetParent().getDataSource() )
    1971 [ #  # ][ #  # ]:          0 :             xForm = Reference< XRowSet >( ( Reference< XInterface > )*m_rColumn.GetParent().getDataSource(), UNO_QUERY );
    1972         [ #  # ]:          0 :         if ( xForm.is() )
    1973 [ #  # ][ #  # ]:          0 :             xSupplier = getNumberFormats( getRowSetConnection( xForm ), sal_True );
                 [ #  # ]
    1974                 :          0 :         SvNumberFormatter* pFormatterUsed = NULL;
    1975         [ #  # ]:          0 :         if ( xSupplier.is() )
    1976                 :            :         {
    1977         [ #  # ]:          0 :             SvNumberFormatsSupplierObj* pImplmentation = SvNumberFormatsSupplierObj::getImplementation( xSupplier );
    1978 [ #  # ][ #  # ]:          0 :             pFormatterUsed = pImplmentation ? pImplmentation->GetNumberFormatter() : NULL;
    1979                 :            :         }
    1980         [ #  # ]:          0 :         if ( NULL == pFormatterUsed )
    1981                 :            :         {   // der Cursor fuehrte nicht zum Erfolg -> Standard
    1982         [ #  # ]:          0 :             pFormatterUsed = static_cast< DoubleNumericField* >( m_pWindow )->StandardFormatter();
    1983                 :            :             DBG_ASSERT( pFormatterUsed != NULL, "DbNumericField::implAdjustGenericFieldSetting: no standard formatter given by the numeric field !" );
    1984                 :            :         }
    1985         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetFormatter( pFormatterUsed );
    1986         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pPainter )->SetFormatter( pFormatterUsed );
    1987                 :            : 
    1988                 :            :         // und dann ein Format generieren, dass die gewuenschten Nachkommastellen usw. hat
    1989         [ #  # ]:          0 :         String sFormatString;
    1990 [ #  # ][ #  # ]:          0 :         LanguageType aAppLanguage = Application::GetSettings().GetUILanguage();
    1991         [ #  # ]:          0 :         pFormatterUsed->GenerateFormat( sFormatString, 0, aAppLanguage, bThousand, sal_False, nScale );
    1992                 :            : 
    1993         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetFormat( sFormatString, aAppLanguage );
    1994 [ #  # ][ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pPainter )->SetFormat( sFormatString, aAppLanguage );
    1995                 :            :     }
    1996                 :          0 : }
    1997                 :            : 
    1998                 :            : //------------------------------------------------------------------------------
    1999                 :          0 : SpinField* DbNumericField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/  )
    2000                 :            : {
    2001         [ #  # ]:          0 :     return new DoubleNumericField( _pParent, _nFieldStyle );
    2002                 :            : }
    2003                 :            : 
    2004                 :            : namespace
    2005                 :            : {
    2006                 :            :     //--------------------------------------------------------------------------
    2007                 :          0 :     static String lcl_setFormattedNumeric_nothrow( DoubleNumericField& _rField, const DbCellControl& _rControl,
    2008                 :            :         const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
    2009                 :            :     {
    2010                 :          0 :         String sValue;
    2011         [ #  # ]:          0 :         if ( _rxField.is() )
    2012                 :            :         {
    2013                 :            :             try
    2014                 :            :             {
    2015         [ #  # ]:          0 :                 double fValue = _rControl.GetValue( _rxField, _rxFormatter );
    2016 [ #  # ][ #  # ]:          0 :                 if ( !_rxField->wasNull() )
                 [ #  # ]
    2017                 :            :                 {
    2018         [ #  # ]:          0 :                     _rField.SetValue( fValue );
    2019 [ #  # ][ #  # ]:          0 :                     sValue = _rField.GetText();
         [ #  # ][ #  # ]
    2020                 :            :                 }
    2021                 :            :             }
    2022         [ #  # ]:          0 :             catch( const Exception& )
    2023                 :            :             {
    2024                 :            :                 DBG_UNHANDLED_EXCEPTION();
    2025                 :            :             }
    2026                 :            :         }
    2027                 :          0 :         return sValue;
    2028                 :            :     }
    2029                 :            : }
    2030                 :            : 
    2031                 :            : //------------------------------------------------------------------------------
    2032                 :          0 : String DbNumericField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
    2033                 :            : {
    2034         [ #  # ]:          0 :     return lcl_setFormattedNumeric_nothrow( *dynamic_cast< DoubleNumericField* >( m_pPainter ), *this, _rxField, _rxFormatter );
    2035                 :            : }
    2036                 :            : 
    2037                 :            : //------------------------------------------------------------------------------
    2038                 :          0 : void DbNumericField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
    2039                 :            : {
    2040         [ #  # ]:          0 :     lcl_setFormattedNumeric_nothrow( *dynamic_cast< DoubleNumericField* >( m_pWindow ), *this, _rxField, _rxFormatter );
    2041                 :          0 : }
    2042                 :            : 
    2043                 :            : //------------------------------------------------------------------------------
    2044                 :          0 : void DbNumericField::updateFromModel( Reference< XPropertySet > _rxModel )
    2045                 :            : {
    2046                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbNumericField::updateFromModel: invalid call!" );
    2047                 :            : 
    2048                 :          0 :     double dValue = 0;
    2049 [ #  # ][ #  # ]:          0 :     if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
         [ #  # ][ #  # ]
    2050         [ #  # ]:          0 :         static_cast< DoubleNumericField* >( m_pWindow )->SetValue( dValue );
    2051                 :            :     else
    2052 [ #  # ][ #  # ]:          0 :         m_pWindow->SetText( String() );
                 [ #  # ]
    2053                 :          0 : }
    2054                 :            : 
    2055                 :            : //------------------------------------------------------------------------------
    2056                 :          0 : sal_Bool DbNumericField::commitControl()
    2057                 :            : {
    2058         [ #  # ]:          0 :     String aText( m_pWindow->GetText());
    2059                 :          0 :     Any aVal;
    2060                 :            : 
    2061         [ #  # ]:          0 :     if (aText.Len() != 0)   // nicht null
    2062                 :            :     {
    2063         [ #  # ]:          0 :         double fValue = ((DoubleNumericField*)m_pWindow)->GetValue();
    2064         [ #  # ]:          0 :         aVal <<= (double)fValue;
    2065                 :            :     }
    2066 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
                 [ #  # ]
    2067         [ #  # ]:          0 :     return sal_True;
    2068                 :            : }
    2069                 :            : 
    2070                 :            : //==============================================================================
    2071                 :            : //= DbCurrencyField
    2072                 :            : //==============================================================================
    2073                 :            : //------------------------------------------------------------------------------
    2074                 :          0 : DbCurrencyField::DbCurrencyField(DbGridColumn& _rColumn)
    2075                 :            :     :DbSpinField( _rColumn )
    2076                 :          0 :     ,m_nScale( 0 )
    2077                 :            : {
    2078 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DECIMAL_ACCURACY );
    2079 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUEMIN );
    2080 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUEMAX );
    2081 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_VALUESTEP );
    2082 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRICTFORMAT );
    2083 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_SHOWTHOUSANDSEP );
    2084 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_CURRENCYSYMBOL );
    2085                 :          0 : }
    2086                 :            : 
    2087                 :            : //------------------------------------------------------------------------------
    2088                 :          0 : void DbCurrencyField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    2089                 :            : {
    2090                 :            :     DBG_ASSERT( m_pWindow, "DbCurrencyField::implAdjustGenericFieldSetting: not to be called without window!" );
    2091                 :            :     DBG_ASSERT( _rxModel.is(), "DbCurrencyField::implAdjustGenericFieldSetting: invalid model!" );
    2092 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    2093                 :            :     {
    2094 [ #  # ][ #  # ]:          0 :         m_nScale                = getINT16( _rxModel->getPropertyValue( FM_PROP_DECIMAL_ACCURACY ) );
         [ #  # ][ #  # ]
    2095 [ #  # ][ #  # ]:          0 :         double  nMin            = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMIN ) );
         [ #  # ][ #  # ]
    2096 [ #  # ][ #  # ]:          0 :         double  nMax            = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUEMAX ) );
         [ #  # ][ #  # ]
    2097 [ #  # ][ #  # ]:          0 :         double  nStep           = getDouble( _rxModel->getPropertyValue( FM_PROP_VALUESTEP ) );
         [ #  # ][ #  # ]
    2098 [ #  # ][ #  # ]:          0 :         sal_Bool    bStrict     = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
         [ #  # ][ #  # ]
    2099 [ #  # ][ #  # ]:          0 :         sal_Bool    bThousand   = getBOOL( _rxModel->getPropertyValue( FM_PROP_SHOWTHOUSANDSEP ) );
         [ #  # ][ #  # ]
    2100 [ #  # ][ #  # ]:          0 :         ::rtl::OUString aStr( getString( _rxModel->getPropertyValue(FM_PROP_CURRENCYSYMBOL ) ) );
         [ #  # ][ #  # ]
    2101                 :            : 
    2102         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetUseThousandSep( bThousand );
    2103         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetDecimalDigits( m_nScale );
    2104 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetCurrencySymbol( aStr );
                 [ #  # ]
    2105 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetFirst( nMin );
    2106 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetLast( nMax );
    2107 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetMin( nMin );
    2108 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetMax( nMax );
    2109 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetSpinSize( nStep );
    2110         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetStrictFormat( bStrict );
    2111                 :            : 
    2112         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetUseThousandSep( bThousand );
    2113         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetDecimalDigits( m_nScale );
    2114 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetCurrencySymbol( aStr );
                 [ #  # ]
    2115 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetFirst( nMin );
    2116 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetLast( nMax );
    2117 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetMin( nMin );
    2118 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetMax( nMax );
    2119         [ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pPainter )->SetStrictFormat( bStrict );
    2120                 :            :     }
    2121                 :          0 : }
    2122                 :            : 
    2123                 :            : //------------------------------------------------------------------------------
    2124                 :          0 : SpinField* DbCurrencyField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/  )
    2125                 :            : {
    2126         [ #  # ]:          0 :     return new LongCurrencyField( _pParent, _nFieldStyle );
    2127                 :            : }
    2128                 :            : 
    2129                 :            : //------------------------------------------------------------------------------
    2130                 :          0 : double DbCurrencyField::GetCurrency(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter) const
    2131                 :            : {
    2132                 :          0 :     double fValue = GetValue(_rxField, xFormatter);
    2133         [ #  # ]:          0 :     if (m_nScale)
    2134                 :            :     {
    2135                 :            :         // OSL_TRACE("double = %.64f ",fValue);
    2136                 :          0 :         fValue = ::rtl::math::pow10Exp(fValue, m_nScale);
    2137                 :          0 :         fValue = ::rtl::math::round(fValue, 0);
    2138                 :            :     }
    2139                 :          0 :     return fValue;
    2140                 :            : }
    2141                 :            : 
    2142                 :            : namespace
    2143                 :            : {
    2144                 :            :     //--------------------------------------------------------------------------
    2145                 :          0 :     static String lcl_setFormattedCurrency_nothrow( LongCurrencyField& _rField, const DbCurrencyField& _rControl,
    2146                 :            :         const Reference< XColumn >& _rxField, const Reference< XNumberFormatter >& _rxFormatter )
    2147                 :            :     {
    2148                 :          0 :         String sValue;
    2149         [ #  # ]:          0 :         if ( _rxField.is() )
    2150                 :            :         {
    2151                 :            :             try
    2152                 :            :             {
    2153         [ #  # ]:          0 :                 double fValue = _rControl.GetCurrency( _rxField, _rxFormatter );
    2154 [ #  # ][ #  # ]:          0 :                 if ( !_rxField->wasNull() )
                 [ #  # ]
    2155                 :            :                 {
    2156 [ #  # ][ #  # ]:          0 :                     _rField.SetValue( fValue );
    2157         [ #  # ]:          0 :                     BigInt aValue = _rField.GetCorrectedValue();
    2158 [ #  # ][ #  # ]:          0 :                     sValue = aValue.GetString();
    2159 [ #  # ][ #  # ]:          0 :                     sValue = _rField.GetText();
         [ #  # ][ #  # ]
    2160                 :            :                 }
    2161                 :            :             }
    2162         [ #  # ]:          0 :             catch( const Exception& )
    2163                 :            :             {
    2164                 :            :                 DBG_UNHANDLED_EXCEPTION();
    2165                 :            :             }
    2166                 :            :         }
    2167                 :          0 :         return sValue;
    2168                 :            :     }
    2169                 :            : }
    2170                 :            : 
    2171                 :            : //------------------------------------------------------------------------------
    2172                 :          0 : String DbCurrencyField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter, Color** /*ppColor*/)
    2173                 :            : {
    2174         [ #  # ]:          0 :     return lcl_setFormattedCurrency_nothrow( *dynamic_cast< LongCurrencyField* >( m_pPainter ), *this, _rxField, _rxFormatter );
    2175                 :            : }
    2176                 :            : 
    2177                 :            : //------------------------------------------------------------------------------
    2178                 :          0 : void DbCurrencyField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& _rxFormatter)
    2179                 :            : {
    2180         [ #  # ]:          0 :     lcl_setFormattedCurrency_nothrow( *dynamic_cast< LongCurrencyField* >( m_pWindow ), *this, _rxField, _rxFormatter );
    2181                 :          0 : }
    2182                 :            : 
    2183                 :            : //------------------------------------------------------------------------------
    2184                 :          0 : void DbCurrencyField::updateFromModel( Reference< XPropertySet > _rxModel )
    2185                 :            : {
    2186                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbCurrencyField::updateFromModel: invalid call!" );
    2187                 :            : 
    2188                 :          0 :     double dValue = 0;
    2189 [ #  # ][ #  # ]:          0 :     if ( _rxModel->getPropertyValue( FM_PROP_VALUE ) >>= dValue )
         [ #  # ][ #  # ]
    2190                 :            :     {
    2191         [ #  # ]:          0 :         if ( m_nScale )
    2192                 :            :         {
    2193                 :          0 :             dValue = ::rtl::math::pow10Exp( dValue, m_nScale );
    2194                 :          0 :             dValue = ::rtl::math::round(dValue, 0);
    2195                 :            :         }
    2196                 :            : 
    2197 [ #  # ][ #  # ]:          0 :         static_cast< LongCurrencyField* >( m_pWindow )->SetValue( dValue );
    2198                 :            :     }
    2199                 :            :     else
    2200 [ #  # ][ #  # ]:          0 :         m_pWindow->SetText( String() );
                 [ #  # ]
    2201                 :          0 : }
    2202                 :            : 
    2203                 :            : //------------------------------------------------------------------------------
    2204                 :          0 : sal_Bool DbCurrencyField::commitControl()
    2205                 :            : {
    2206         [ #  # ]:          0 :     String aText( m_pWindow->GetText());
    2207                 :          0 :     Any aVal;
    2208         [ #  # ]:          0 :     if (aText.Len() != 0)   // nicht null
    2209                 :            :     {
    2210 [ #  # ][ #  # ]:          0 :         double fValue = ((LongCurrencyField*)m_pWindow)->GetValue();
    2211         [ #  # ]:          0 :         if (m_nScale)
    2212                 :            :         {
    2213                 :          0 :             fValue /= ::rtl::math::pow10Exp(1.0, m_nScale);
    2214                 :            :             //fValue = ::rtl::math::round(fValue, m_nScale);
    2215                 :            :         }
    2216         [ #  # ]:          0 :         aVal <<= (double)fValue;
    2217                 :            :     }
    2218 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_VALUE, aVal);
                 [ #  # ]
    2219         [ #  # ]:          0 :     return sal_True;
    2220                 :            : }
    2221                 :            : 
    2222                 :            : //==============================================================================
    2223                 :            : //= DbDateField
    2224                 :            : //==============================================================================
    2225                 :            : //------------------------------------------------------------------------------
    2226                 :          0 : DbDateField::DbDateField( DbGridColumn& _rColumn )
    2227                 :          0 :     :DbSpinField( _rColumn )
    2228                 :            : {
    2229 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DATEFORMAT );
    2230 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DATEMIN );
    2231 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DATEMAX );
    2232 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRICTFORMAT );
    2233 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_DATE_SHOW_CENTURY );
    2234                 :          0 : }
    2235                 :            : 
    2236                 :            : //------------------------------------------------------------------------------
    2237                 :          0 : SpinField* DbDateField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& _rxModel  )
    2238                 :            : {
    2239                 :            :     // check if there is a DropDown property set to TRUE
    2240 [ #  # ][ #  # ]:          0 :     sal_Bool bDropDown =    !hasProperty( FM_PROP_DROPDOWN, _rxModel )
         [ #  # ][ #  # ]
    2241 [ #  # ][ #  # ]:          0 :                         ||  getBOOL( _rxModel->getPropertyValue( FM_PROP_DROPDOWN ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2242         [ #  # ]:          0 :     if ( bDropDown )
    2243                 :          0 :         _nFieldStyle |= WB_DROPDOWN;
    2244                 :            : 
    2245         [ #  # ]:          0 :     CalendarField* pField = new CalendarField( _pParent, _nFieldStyle );
    2246                 :            : 
    2247                 :          0 :     pField->EnableToday();
    2248                 :          0 :     pField->EnableNone();
    2249                 :            : 
    2250                 :          0 :     return pField;
    2251                 :            : }
    2252                 :            : 
    2253                 :            : //------------------------------------------------------------------------------
    2254                 :          0 : void DbDateField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    2255                 :            : {
    2256                 :            :     DBG_ASSERT( m_pWindow, "DbDateField::implAdjustGenericFieldSetting: not to be called without window!" );
    2257                 :            :     DBG_ASSERT( _rxModel.is(), "DbDateField::implAdjustGenericFieldSetting: invalid model!" );
    2258 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    2259                 :            :     {
    2260 [ #  # ][ #  # ]:          0 :         sal_Int16   nFormat     = getINT16( _rxModel->getPropertyValue( FM_PROP_DATEFORMAT ) );
         [ #  # ][ #  # ]
    2261 [ #  # ][ #  # ]:          0 :         sal_Int32   nMin        = getINT32( _rxModel->getPropertyValue( FM_PROP_DATEMIN ) );
         [ #  # ][ #  # ]
    2262 [ #  # ][ #  # ]:          0 :         sal_Int32   nMax        = getINT32( _rxModel->getPropertyValue( FM_PROP_DATEMAX ) );
         [ #  # ][ #  # ]
    2263 [ #  # ][ #  # ]:          0 :         sal_Bool    bStrict     = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
         [ #  # ][ #  # ]
    2264                 :            : 
    2265 [ #  # ][ #  # ]:          0 :         Any  aCentury = _rxModel->getPropertyValue( FM_PROP_DATE_SHOW_CENTURY );
                 [ #  # ]
    2266         [ #  # ]:          0 :         if ( aCentury.getValueType().getTypeClass() != TypeClass_VOID )
    2267                 :            :         {
    2268         [ #  # ]:          0 :             sal_Bool bShowDateCentury = getBOOL( aCentury );
    2269                 :            : 
    2270         [ #  # ]:          0 :             static_cast<DateField*>( m_pWindow )->SetShowDateCentury( bShowDateCentury );
    2271         [ #  # ]:          0 :             static_cast<DateField*>( m_pPainter )->SetShowDateCentury( bShowDateCentury );
    2272                 :            :         }
    2273                 :            : 
    2274         [ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetExtDateFormat( (ExtDateFieldFormat)nFormat );
    2275         [ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetMin( nMin );
    2276         [ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetMax( nMax );
    2277         [ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetStrictFormat( bStrict );
    2278                 :          0 :         static_cast< DateField* >( m_pWindow )->EnableEmptyFieldValue( sal_True );
    2279                 :            : 
    2280         [ #  # ]:          0 :         static_cast< DateField* >( m_pPainter )->SetExtDateFormat( (ExtDateFieldFormat)nFormat );
    2281         [ #  # ]:          0 :         static_cast< DateField* >( m_pPainter )->SetMin( nMin );
    2282         [ #  # ]:          0 :         static_cast< DateField* >( m_pPainter )->SetMax( nMax );
    2283         [ #  # ]:          0 :         static_cast< DateField* >( m_pPainter )->SetStrictFormat( bStrict );
    2284                 :          0 :         static_cast< DateField* >( m_pPainter )->EnableEmptyFieldValue( sal_True );
    2285                 :            :     }
    2286                 :          0 : }
    2287                 :            : 
    2288                 :            : namespace
    2289                 :            : {
    2290                 :            :     //--------------------------------------------------------------------------
    2291                 :          0 :     static String lcl_setFormattedDate_nothrow( DateField& _rField, const Reference< XColumn >& _rxField )
    2292                 :            :     {
    2293                 :          0 :         String sDate;
    2294         [ #  # ]:          0 :         if ( _rxField.is() )
    2295                 :            :         {
    2296                 :            :             try
    2297                 :            :             {
    2298 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::util::Date aValue = _rxField->getDate();
    2299 [ #  # ][ #  # ]:          0 :                 if ( _rxField->wasNull() )
                 [ #  # ]
    2300         [ #  # ]:          0 :                     _rField.SetText( sDate );
    2301                 :            :                 else
    2302                 :            :                 {
    2303         [ #  # ]:          0 :                     _rField.SetDate( ::Date( aValue.Day, aValue.Month, aValue.Year ) );
    2304 [ #  # ][ #  # ]:          0 :                     sDate = _rField.GetText();
         [ #  # ][ #  # ]
    2305                 :            :                 }
    2306                 :            :             }
    2307         [ #  # ]:          0 :             catch( const Exception& )
    2308                 :            :             {
    2309                 :            :                 DBG_UNHANDLED_EXCEPTION();
    2310                 :            :             }
    2311                 :            :         }
    2312                 :          0 :         return sDate;
    2313                 :            :     }
    2314                 :            : }
    2315                 :            : //------------------------------------------------------------------------------
    2316                 :          0 : String DbDateField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    2317                 :            : {
    2318         [ #  # ]:          0 :      return lcl_setFormattedDate_nothrow( *dynamic_cast< DateField* >( m_pPainter ), _rxField );
    2319                 :            : }
    2320                 :            : 
    2321                 :            : //------------------------------------------------------------------------------
    2322                 :          0 : void DbDateField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
    2323                 :            : {
    2324         [ #  # ]:          0 :     lcl_setFormattedDate_nothrow( *dynamic_cast< DateField* >( m_pWindow ), _rxField );
    2325                 :          0 : }
    2326                 :            : 
    2327                 :            : //------------------------------------------------------------------------------
    2328                 :          0 : void DbDateField::updateFromModel( Reference< XPropertySet > _rxModel )
    2329                 :            : {
    2330                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbDateField::updateFromModel: invalid call!" );
    2331                 :            : 
    2332                 :          0 :     sal_Int32 nDate = 0;
    2333 [ #  # ][ #  # ]:          0 :     if ( _rxModel->getPropertyValue( FM_PROP_DATE ) >>= nDate )
         [ #  # ][ #  # ]
    2334         [ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetDate( ::Date( nDate ) );
    2335                 :            :     else
    2336 [ #  # ][ #  # ]:          0 :         static_cast< DateField* >( m_pWindow )->SetText( String() );
                 [ #  # ]
    2337                 :          0 : }
    2338                 :            : 
    2339                 :            : //------------------------------------------------------------------------------
    2340                 :          0 : sal_Bool DbDateField::commitControl()
    2341                 :            : {
    2342         [ #  # ]:          0 :     String aText( m_pWindow->GetText());
    2343                 :          0 :     Any aVal;
    2344         [ #  # ]:          0 :     if (aText.Len() != 0)
    2345 [ #  # ][ #  # ]:          0 :         aVal <<= (sal_Int32)static_cast<DateField*>(m_pWindow)->GetDate().GetDate();
    2346                 :            :     else
    2347                 :          0 :         aVal.clear();
    2348                 :            : 
    2349 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_DATE, aVal);
                 [ #  # ]
    2350         [ #  # ]:          0 :     return sal_True;
    2351                 :            : }
    2352                 :            : 
    2353                 :            : //==============================================================================
    2354                 :            : //= DbTimeField
    2355                 :            : //==============================================================================
    2356                 :            : //------------------------------------------------------------------------------
    2357                 :          0 : DbTimeField::DbTimeField( DbGridColumn& _rColumn )
    2358                 :          0 :     :DbSpinField( _rColumn, ::com::sun::star::awt::TextAlign::LEFT )
    2359                 :            : {
    2360 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_TIMEFORMAT );
    2361 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_TIMEMIN );
    2362 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_TIMEMAX );
    2363 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRICTFORMAT );
    2364                 :          0 : }
    2365                 :            : 
    2366                 :            : //------------------------------------------------------------------------------
    2367                 :          0 : SpinField* DbTimeField::createField( Window* _pParent, WinBits _nFieldStyle, const Reference< XPropertySet >& /*_rxModel*/ )
    2368                 :            : {
    2369         [ #  # ]:          0 :     return new TimeField( _pParent, _nFieldStyle );
    2370                 :            : }
    2371                 :            : 
    2372                 :            : //------------------------------------------------------------------------------
    2373                 :          0 : void DbTimeField::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    2374                 :            : {
    2375                 :            :     DBG_ASSERT( m_pWindow, "DbTimeField::implAdjustGenericFieldSetting: not to be called without window!" );
    2376                 :            :     DBG_ASSERT( _rxModel.is(), "DbTimeField::implAdjustGenericFieldSetting: invalid model!" );
    2377 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    2378                 :            :     {
    2379 [ #  # ][ #  # ]:          0 :         sal_Int16   nFormat     = getINT16( _rxModel->getPropertyValue( FM_PROP_TIMEFORMAT ) );
    2380 [ #  # ][ #  # ]:          0 :         sal_Int32   nMin        = getINT32( _rxModel->getPropertyValue( FM_PROP_TIMEMIN ) );
    2381 [ #  # ][ #  # ]:          0 :         sal_Int32   nMax        = getINT32( _rxModel->getPropertyValue( FM_PROP_TIMEMAX ) );
    2382 [ #  # ][ #  # ]:          0 :         sal_Bool    bStrict     = getBOOL( _rxModel->getPropertyValue( FM_PROP_STRICTFORMAT ) );
    2383                 :            : 
    2384                 :          0 :         static_cast< TimeField* >( m_pWindow )->SetExtFormat( (ExtTimeFieldFormat)nFormat );
    2385         [ #  # ]:          0 :         static_cast< TimeField* >( m_pWindow )->SetMin( nMin );
    2386         [ #  # ]:          0 :         static_cast< TimeField* >( m_pWindow )->SetMax( nMax );
    2387                 :          0 :         static_cast< TimeField* >( m_pWindow )->SetStrictFormat( bStrict );
    2388                 :          0 :         static_cast< TimeField* >( m_pWindow )->EnableEmptyFieldValue( sal_True );
    2389                 :            : 
    2390                 :          0 :         static_cast< TimeField* >( m_pPainter )->SetExtFormat( (ExtTimeFieldFormat)nFormat );
    2391         [ #  # ]:          0 :         static_cast< TimeField* >( m_pPainter )->SetMin( nMin );
    2392         [ #  # ]:          0 :         static_cast< TimeField* >( m_pPainter )->SetMax( nMax );
    2393                 :          0 :         static_cast< TimeField* >( m_pPainter )->SetStrictFormat( bStrict );
    2394                 :          0 :         static_cast< TimeField* >( m_pPainter )->EnableEmptyFieldValue( sal_True );
    2395                 :            :     }
    2396                 :          0 : }
    2397                 :            : 
    2398                 :            : namespace
    2399                 :            : {
    2400                 :            :     //--------------------------------------------------------------------------
    2401                 :          0 :     static String lcl_setFormattedTime_nothrow( TimeField& _rField, const Reference< XColumn >& _rxField )
    2402                 :            :     {
    2403                 :          0 :         String sTime;
    2404         [ #  # ]:          0 :         if ( _rxField.is() )
    2405                 :            :         {
    2406                 :            :             try
    2407                 :            :             {
    2408 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::util::Time aValue = _rxField->getTime();
    2409 [ #  # ][ #  # ]:          0 :                 if ( _rxField->wasNull() )
                 [ #  # ]
    2410         [ #  # ]:          0 :                     _rField.SetText( sTime );
    2411                 :            :                 else
    2412                 :            :                 {
    2413 [ #  # ][ #  # ]:          0 :                     _rField.SetTime( ::Time( aValue.Hours, aValue.Minutes, aValue.Seconds, aValue.HundredthSeconds ) );
    2414 [ #  # ][ #  # ]:          0 :                     sTime = _rField.GetText();
         [ #  # ][ #  # ]
    2415                 :            :                 }
    2416                 :            :             }
    2417         [ #  # ]:          0 :             catch( const Exception& )
    2418                 :            :             {
    2419                 :            :                 DBG_UNHANDLED_EXCEPTION();
    2420                 :            :             }
    2421                 :            :         }
    2422                 :          0 :         return sTime;
    2423                 :            :     }
    2424                 :            : }
    2425                 :            : //------------------------------------------------------------------------------
    2426                 :          0 : String DbTimeField::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< ::com::sun::star::util::XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    2427                 :            : {
    2428                 :          0 :     return lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pPainter ), _rxField );
    2429                 :            : }
    2430                 :            : 
    2431                 :            : //------------------------------------------------------------------------------
    2432                 :          0 : void DbTimeField::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/)
    2433                 :            : {
    2434                 :          0 :     lcl_setFormattedTime_nothrow( *static_cast< TimeField* >( m_pWindow ), _rxField );
    2435                 :          0 : }
    2436                 :            : 
    2437                 :            : //------------------------------------------------------------------------------
    2438                 :          0 : void DbTimeField::updateFromModel( Reference< XPropertySet > _rxModel )
    2439                 :            : {
    2440                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbTimeField::updateFromModel: invalid call!" );
    2441                 :            : 
    2442                 :          0 :     sal_Int32 nTime = 0;
    2443 [ #  # ][ #  # ]:          0 :     if ( _rxModel->getPropertyValue( FM_PROP_DATE ) >>= nTime )
         [ #  # ][ #  # ]
    2444         [ #  # ]:          0 :         static_cast< TimeField* >( m_pWindow )->SetTime( ::Time( nTime ) );
    2445                 :            :     else
    2446 [ #  # ][ #  # ]:          0 :         static_cast< TimeField* >( m_pWindow )->SetText( String() );
                 [ #  # ]
    2447                 :          0 : }
    2448                 :            : 
    2449                 :            : //------------------------------------------------------------------------------
    2450                 :          0 : sal_Bool DbTimeField::commitControl()
    2451                 :            : {
    2452         [ #  # ]:          0 :     String aText( m_pWindow->GetText());
    2453                 :          0 :     Any aVal;
    2454         [ #  # ]:          0 :     if (aText.Len() != 0)
    2455 [ #  # ][ #  # ]:          0 :         aVal <<= (sal_Int32)static_cast<TimeField*>(m_pWindow)->GetTime().GetTime();
    2456                 :            :     else
    2457                 :          0 :         aVal.clear();
    2458                 :            : 
    2459 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_TIME, aVal);
                 [ #  # ]
    2460         [ #  # ]:          0 :     return sal_True;
    2461                 :            : }
    2462                 :            : 
    2463                 :            : //==============================================================================
    2464                 :            : //= DbComboBox
    2465                 :            : //==============================================================================
    2466                 :            : //------------------------------------------------------------------------------
    2467                 :          0 : DbComboBox::DbComboBox(DbGridColumn& _rColumn)
    2468                 :            :            :DbCellControl(_rColumn)
    2469                 :          0 :            ,m_nKeyType(::com::sun::star::util::NumberFormat::UNDEFINED)
    2470                 :            : {
    2471                 :          0 :     setAlignedController( sal_False );
    2472                 :            : 
    2473 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRINGITEMLIST );
    2474 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_LINECOUNT );
    2475                 :          0 : }
    2476                 :            : 
    2477                 :            : //------------------------------------------------------------------------------
    2478                 :          0 : void DbComboBox::_propertyChanged( const PropertyChangeEvent& _rEvent ) throw( RuntimeException )
    2479                 :            : {
    2480         [ #  # ]:          0 :     if ( _rEvent.PropertyName.equals( FM_PROP_STRINGITEMLIST ) )
    2481                 :            :     {
    2482                 :          0 :         SetList(_rEvent.NewValue);
    2483                 :            :     }
    2484                 :            :     else
    2485                 :            :     {
    2486                 :          0 :         DbCellControl::_propertyChanged( _rEvent ) ;
    2487                 :            :     }
    2488                 :          0 : }
    2489                 :            : 
    2490                 :            : //------------------------------------------------------------------------------
    2491                 :          0 : void DbComboBox::SetList(const Any& rItems)
    2492                 :            : {
    2493                 :          0 :     ComboBoxControl* pField = (ComboBoxControl*)m_pWindow;
    2494         [ #  # ]:          0 :     pField->Clear();
    2495                 :            : 
    2496         [ #  # ]:          0 :     ::comphelper::StringSequence aTest;
    2497 [ #  # ][ #  # ]:          0 :     if (rItems >>= aTest)
    2498                 :            :     {
    2499                 :          0 :         const ::rtl::OUString* pStrings = aTest.getConstArray();
    2500                 :          0 :         sal_Int32 nItems = aTest.getLength();
    2501         [ #  # ]:          0 :         for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
    2502 [ #  # ][ #  # ]:          0 :              pField->InsertEntry(*pStrings, LISTBOX_APPEND);
                 [ #  # ]
    2503                 :            : 
    2504                 :            :         // tell the grid control that this controller is invalid and has to be re-initialized
    2505         [ #  # ]:          0 :         invalidatedController();
    2506         [ #  # ]:          0 :     }
    2507                 :          0 : }
    2508                 :            : 
    2509                 :            : //------------------------------------------------------------------------------
    2510                 :          0 : void DbComboBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    2511                 :            : {
    2512                 :            :     DBG_ASSERT( m_pWindow, "DbComboBox::implAdjustGenericFieldSetting: not to be called without window!" );
    2513                 :            :     DBG_ASSERT( _rxModel.is(), "DbComboBox::implAdjustGenericFieldSetting: invalid model!" );
    2514 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    2515                 :            :     {
    2516 [ #  # ][ #  # ]:          0 :         sal_Int16  nLines = getINT16( _rxModel->getPropertyValue( FM_PROP_LINECOUNT ) );
    2517                 :          0 :         static_cast< ComboBoxControl* >( m_pWindow )->SetDropDownLineCount( nLines );
    2518                 :            :     }
    2519                 :          0 : }
    2520                 :            : 
    2521                 :            : //------------------------------------------------------------------------------
    2522                 :          0 : void DbComboBox::Init( Window& rParent, const Reference< XRowSet >& xCursor )
    2523                 :            : {
    2524         [ #  # ]:          0 :     m_rColumn.SetAlignmentFromModel(::com::sun::star::awt::TextAlign::LEFT);
    2525                 :            : 
    2526 [ #  # ][ #  # ]:          0 :     m_pWindow = new ComboBoxControl( &rParent );
    2527                 :            : 
    2528                 :            :     // selection von rechts nach links
    2529         [ #  # ]:          0 :     AllSettings     aSettings = m_pWindow->GetSettings();
    2530         [ #  # ]:          0 :     StyleSettings   aStyleSettings = aSettings.GetStyleSettings();
    2531                 :            :     aStyleSettings.SetSelectionOptions(
    2532         [ #  # ]:          0 :         aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
    2533         [ #  # ]:          0 :     aSettings.SetStyleSettings(aStyleSettings);
    2534         [ #  # ]:          0 :     m_pWindow->SetSettings(aSettings, sal_True);
    2535                 :            : 
    2536                 :            :     // some initial properties
    2537                 :          0 :     Reference< XPropertySet >   xModel(m_rColumn.getModel());
    2538 [ #  # ][ #  # ]:          0 :     SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
         [ #  # ][ #  # ]
    2539         [ #  # ]:          0 :     implAdjustGenericFieldSetting( xModel );
    2540                 :            : 
    2541         [ #  # ]:          0 :     if (m_rColumn.GetParent().getNumberFormatter().is())
    2542 [ #  # ][ #  # ]:          0 :         m_nKeyType  = comphelper::getNumberFormatType(m_rColumn.GetParent().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(), m_rColumn.GetKey());
         [ #  # ][ #  # ]
                 [ #  # ]
    2543                 :            : 
    2544 [ #  # ][ #  # ]:          0 :     DbCellControl::Init( rParent, xCursor );
                 [ #  # ]
    2545                 :          0 : }
    2546                 :            : 
    2547                 :            : //------------------------------------------------------------------------------
    2548                 :          0 : CellControllerRef DbComboBox::CreateController() const
    2549                 :            : {
    2550         [ #  # ]:          0 :     return new ComboBoxCellController((ComboBoxControl*)m_pWindow);
    2551                 :            : }
    2552                 :            : 
    2553                 :            : //------------------------------------------------------------------------------
    2554                 :          0 : String DbComboBox::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter, Color** /*ppColor*/)
    2555                 :            : {
    2556                 :          0 :     ::rtl::OUString aString;
    2557         [ #  # ]:          0 :     if (_rxField.is())
    2558                 :            :         try
    2559                 :            :         {
    2560         [ #  # ]:          0 :             aString = getFormattedValue( _rxField, xFormatter, m_rColumn.GetParent().getNullDate(), m_rColumn.GetKey(), m_nKeyType );
    2561                 :            :         }
    2562         [ #  # ]:          0 :         catch( const Exception& )
    2563                 :            :         {
    2564                 :            :             DBG_UNHANDLED_EXCEPTION();
    2565                 :            :         }
    2566 [ #  # ][ #  # ]:          0 :     return aString;
    2567                 :            : }
    2568                 :            : 
    2569                 :            : //------------------------------------------------------------------------------
    2570                 :          0 : void DbComboBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
    2571                 :            : {
    2572         [ #  # ]:          0 :     m_pWindow->SetText(GetFormatText(_rxField, xFormatter));
    2573                 :          0 : }
    2574                 :            : 
    2575                 :            : //------------------------------------------------------------------------------
    2576                 :          0 : void DbComboBox::updateFromModel( Reference< XPropertySet > _rxModel )
    2577                 :            : {
    2578                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbComboBox::updateFromModel: invalid call!" );
    2579                 :            : 
    2580                 :          0 :     ::rtl::OUString sText;
    2581 [ #  # ][ #  # ]:          0 :     _rxModel->getPropertyValue( FM_PROP_TEXT ) >>= sText;
                 [ #  # ]
    2582                 :            : 
    2583 [ #  # ][ #  # ]:          0 :     static_cast< ComboBox* >( m_pWindow )->SetText( sText );
                 [ #  # ]
    2584         [ #  # ]:          0 :     static_cast< ComboBox* >( m_pWindow )->SetSelection( Selection( SELECTION_MAX, SELECTION_MIN ) );
    2585                 :          0 : }
    2586                 :            : 
    2587                 :            : //------------------------------------------------------------------------------
    2588                 :          0 : sal_Bool DbComboBox::commitControl()
    2589                 :            : {
    2590         [ #  # ]:          0 :     String aText( m_pWindow->GetText());
    2591 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_TEXT, makeAny(::rtl::OUString(aText)));
         [ #  # ][ #  # ]
                 [ #  # ]
    2592         [ #  # ]:          0 :     return sal_True;
    2593                 :            : }
    2594                 :            : 
    2595                 :            : //------------------------------------------------------------------------------
    2596                 :          0 : DbListBox::DbListBox(DbGridColumn& _rColumn)
    2597                 :            :           :DbCellControl(_rColumn)
    2598         [ #  # ]:          0 :           ,m_bBound(sal_False)
    2599                 :            : {
    2600                 :          0 :     setAlignedController( sal_False );
    2601                 :            : 
    2602 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_STRINGITEMLIST );
    2603 [ #  # ][ #  # ]:          0 :     doPropertyListening( FM_PROP_LINECOUNT );
    2604                 :          0 : }
    2605                 :            : 
    2606                 :            : //------------------------------------------------------------------------------
    2607                 :          0 : void DbListBox::_propertyChanged( const ::com::sun::star::beans::PropertyChangeEvent& _rEvent ) throw( RuntimeException )
    2608                 :            : {
    2609         [ #  # ]:          0 :     if ( _rEvent.PropertyName.equals( FM_PROP_STRINGITEMLIST ) )
    2610                 :            :     {
    2611                 :          0 :         SetList(_rEvent.NewValue);
    2612                 :            :     }
    2613                 :            :     else
    2614                 :            :     {
    2615                 :          0 :         DbCellControl::_propertyChanged( _rEvent ) ;
    2616                 :            :     }
    2617                 :          0 : }
    2618                 :            : 
    2619                 :            : //------------------------------------------------------------------------------
    2620                 :          0 : void DbListBox::SetList(const Any& rItems)
    2621                 :            : {
    2622                 :          0 :     ListBoxControl* pField = (ListBoxControl*)m_pWindow;
    2623                 :            : 
    2624         [ #  # ]:          0 :     pField->Clear();
    2625                 :          0 :     m_bBound = sal_False;
    2626                 :            : 
    2627         [ #  # ]:          0 :     ::comphelper::StringSequence aTest;
    2628 [ #  # ][ #  # ]:          0 :     if (rItems >>= aTest)
    2629                 :            :     {
    2630                 :          0 :         const ::rtl::OUString* pStrings = aTest.getConstArray();
    2631                 :          0 :         sal_Int32 nItems = aTest.getLength();
    2632         [ #  # ]:          0 :         if (nItems)
    2633                 :            :         {
    2634         [ #  # ]:          0 :             for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
    2635 [ #  # ][ #  # ]:          0 :                  pField->InsertEntry(*pStrings, LISTBOX_APPEND);
                 [ #  # ]
    2636                 :            : 
    2637 [ #  # ][ #  # ]:          0 :             m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
         [ #  # ][ #  # ]
    2638                 :          0 :             m_bBound = m_aValueList.getLength() > 0;
    2639                 :            : 
    2640                 :            :             // tell the grid control that this controller is invalid and has to be re-initialized
    2641         [ #  # ]:          0 :             invalidatedController();
    2642                 :            :         }
    2643         [ #  # ]:          0 :     }
    2644                 :          0 : }
    2645                 :            : 
    2646                 :            : //------------------------------------------------------------------------------
    2647                 :          0 : void DbListBox::Init( Window& rParent, const Reference< XRowSet >& xCursor)
    2648                 :            : {
    2649         [ #  # ]:          0 :     m_rColumn.SetAlignment(::com::sun::star::awt::TextAlign::LEFT);
    2650                 :            : 
    2651 [ #  # ][ #  # ]:          0 :     m_pWindow = new ListBoxControl( &rParent );
    2652                 :            : 
    2653                 :            :     // some initial properties
    2654                 :          0 :     Reference< XPropertySet > xModel( m_rColumn.getModel() );
    2655 [ #  # ][ #  # ]:          0 :     SetList( xModel->getPropertyValue( FM_PROP_STRINGITEMLIST ) );
         [ #  # ][ #  # ]
    2656         [ #  # ]:          0 :     implAdjustGenericFieldSetting( xModel );
    2657                 :            : 
    2658         [ #  # ]:          0 :     DbCellControl::Init( rParent, xCursor );
    2659                 :          0 : }
    2660                 :            : 
    2661                 :            : //------------------------------------------------------------------------------
    2662                 :          0 : void DbListBox::implAdjustGenericFieldSetting( const Reference< XPropertySet >& _rxModel )
    2663                 :            : {
    2664                 :            :     DBG_ASSERT( m_pWindow, "DbListBox::implAdjustGenericFieldSetting: not to be called without window!" );
    2665                 :            :     DBG_ASSERT( _rxModel.is(), "DbListBox::implAdjustGenericFieldSetting: invalid model!" );
    2666 [ #  # ][ #  # ]:          0 :     if ( m_pWindow && _rxModel.is() )
                 [ #  # ]
    2667                 :            :     {
    2668 [ #  # ][ #  # ]:          0 :         sal_Int16  nLines   = getINT16( _rxModel->getPropertyValue( FM_PROP_LINECOUNT ) );
    2669                 :          0 :         static_cast< ListBoxControl* >( m_pWindow )->SetDropDownLineCount( nLines );
    2670                 :            :     }
    2671                 :          0 : }
    2672                 :            : 
    2673                 :            : //------------------------------------------------------------------------------
    2674                 :          0 : CellControllerRef DbListBox::CreateController() const
    2675                 :            : {
    2676         [ #  # ]:          0 :     return new ListBoxCellController((ListBoxControl*)m_pWindow);
    2677                 :            : }
    2678                 :            : 
    2679                 :            : //------------------------------------------------------------------------------
    2680                 :          0 : String DbListBox::GetFormatText(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    2681                 :            : {
    2682                 :          0 :     String sText;
    2683         [ #  # ]:          0 :     if ( _rxField.is() )
    2684                 :            :     {
    2685                 :            :         try
    2686                 :            :         {
    2687 [ #  # ][ #  # ]:          0 :             sText = _rxField->getString();
                 [ #  # ]
    2688         [ #  # ]:          0 :             if ( m_bBound )
    2689                 :            :             {
    2690 [ #  # ][ #  # ]:          0 :                 Sequence< sal_Int16 > aPosSeq = ::comphelper::findValue( m_aValueList, sText, sal_True );
    2691         [ #  # ]:          0 :                 if ( aPosSeq.getLength() )
    2692 [ #  # ][ #  # ]:          0 :                     sText = static_cast<ListBox*>(m_pWindow)->GetEntry(aPosSeq.getConstArray()[0]);
                 [ #  # ]
    2693                 :            :                 else
    2694 [ #  # ][ #  # ]:          0 :                     sText = String();
         [ #  # ][ #  # ]
                 [ #  # ]
    2695                 :            :             }
    2696                 :            :         }
    2697         [ #  # ]:          0 :         catch( const Exception& )
    2698                 :            :         {
    2699                 :            :             DBG_UNHANDLED_EXCEPTION();
    2700                 :            :         }
    2701                 :            :     }
    2702                 :          0 :     return sText;
    2703                 :            : }
    2704                 :            : 
    2705                 :            : //------------------------------------------------------------------------------
    2706                 :          0 : void DbListBox::UpdateFromField(const Reference< ::com::sun::star::sdb::XColumn >& _rxField, const Reference< XNumberFormatter >& xFormatter)
    2707                 :            : {
    2708         [ #  # ]:          0 :     String sFormattedText( GetFormatText( _rxField, xFormatter ) );
    2709         [ #  # ]:          0 :     if ( sFormattedText.Len() )
    2710         [ #  # ]:          0 :         static_cast< ListBox* >( m_pWindow )->SelectEntry( sFormattedText );
    2711                 :            :     else
    2712 [ #  # ][ #  # ]:          0 :         static_cast< ListBox* >( m_pWindow )->SetNoSelection();
    2713                 :          0 : }
    2714                 :            : 
    2715                 :            : //------------------------------------------------------------------------------
    2716                 :          0 : void DbListBox::updateFromModel( Reference< XPropertySet > _rxModel )
    2717                 :            : {
    2718                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbListBox::updateFromModel: invalid call!" );
    2719                 :            : 
    2720         [ #  # ]:          0 :     Sequence< sal_Int16 > aSelection;
    2721 [ #  # ][ #  # ]:          0 :     _rxModel->getPropertyValue( FM_PROP_SELECT_SEQ );
                 [ #  # ]
    2722                 :            : 
    2723                 :          0 :     sal_Int16 nSelection = -1;
    2724         [ #  # ]:          0 :     if ( aSelection.getLength() > 0 )
    2725         [ #  # ]:          0 :         nSelection = aSelection[ 0 ];
    2726                 :            : 
    2727                 :          0 :     ListBox* pListBox = static_cast< ListBox* >( m_pWindow );
    2728                 :            : 
    2729 [ #  # ][ #  # ]:          0 :     if ( ( nSelection >= 0 ) && ( nSelection < pListBox->GetEntryCount() ) )
         [ #  # ][ #  # ]
    2730         [ #  # ]:          0 :         pListBox->SelectEntryPos( nSelection );
    2731                 :            :     else
    2732 [ #  # ][ #  # ]:          0 :         pListBox->SetNoSelection( );
    2733                 :          0 : }
    2734                 :            : 
    2735                 :            : //------------------------------------------------------------------------------
    2736                 :          0 : sal_Bool DbListBox::commitControl()
    2737                 :            : {
    2738                 :          0 :     Any aVal;
    2739         [ #  # ]:          0 :     Sequence<sal_Int16> aSelectSeq;
    2740 [ #  # ][ #  # ]:          0 :     if (static_cast<ListBox*>(m_pWindow)->GetSelectEntryCount())
    2741                 :            :     {
    2742         [ #  # ]:          0 :         aSelectSeq.realloc(1);
    2743 [ #  # ][ #  # ]:          0 :         *(sal_Int16 *)aSelectSeq.getArray() = (sal_Int16)static_cast<ListBox*>(m_pWindow)->GetSelectEntryPos();
    2744                 :            :     }
    2745         [ #  # ]:          0 :     aVal <<= aSelectSeq;
    2746 [ #  # ][ #  # ]:          0 :     m_rColumn.getModel()->setPropertyValue(FM_PROP_SELECT_SEQ, aVal);
                 [ #  # ]
    2747         [ #  # ]:          0 :     return sal_True;
    2748                 :            : }
    2749                 :            : 
    2750                 :            : 
    2751                 :            : DBG_NAME(DbFilterField);
    2752                 :            : /*************************************************************************/
    2753                 :          0 : DbFilterField::DbFilterField(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,DbGridColumn& _rColumn)
    2754                 :            :               :DbCellControl(_rColumn)
    2755                 :            :               ,OSQLParserClient(_rxORB)
    2756                 :            :               ,m_nControlClass(::com::sun::star::form::FormComponentType::TEXTFIELD)
    2757                 :            :               ,m_bFilterList(sal_False)
    2758                 :            :               ,m_bFilterListFilled(sal_False)
    2759 [ #  # ][ #  # ]:          0 :               ,m_bBound(sal_False)
         [ #  # ][ #  # ]
    2760                 :            : {
    2761                 :            :     DBG_CTOR(DbFilterField,NULL);
    2762                 :            : 
    2763                 :          0 :     setAlignedController( sal_False );
    2764                 :          0 : }
    2765                 :            : 
    2766                 :            : //------------------------------------------------------------------------------
    2767 [ #  # ][ #  # ]:          0 : DbFilterField::~DbFilterField()
                 [ #  # ]
    2768                 :            : {
    2769         [ #  # ]:          0 :     if (m_nControlClass == ::com::sun::star::form::FormComponentType::CHECKBOX)
    2770         [ #  # ]:          0 :         ((CheckBoxControl*)m_pWindow)->SetClickHdl( Link() );
    2771                 :            : 
    2772                 :            :     DBG_DTOR(DbFilterField,NULL);
    2773         [ #  # ]:          0 : }
    2774                 :            : 
    2775                 :            : //------------------------------------------------------------------------------
    2776                 :          0 : void DbFilterField::PaintCell(OutputDevice& rDev, const Rectangle& rRect)
    2777                 :            : {
    2778                 :            :     static sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER | TEXT_DRAW_LEFT;
    2779      [ #  #  # ]:          0 :     switch (m_nControlClass)
    2780                 :            :     {
    2781                 :            :         case FormComponentType::CHECKBOX:
    2782                 :          0 :             DbCellControl::PaintCell( rDev, rRect );
    2783                 :          0 :             break;
    2784                 :            :         case FormComponentType::LISTBOX:
    2785         [ #  # ]:          0 :             rDev.DrawText(rRect, static_cast<ListBox*>(m_pWindow)->GetSelectEntry(), nStyle);
    2786                 :          0 :             break;
    2787                 :            :         default:
    2788                 :          0 :             rDev.DrawText(rRect, m_aText, nStyle);
    2789                 :            :     }
    2790                 :          0 : }
    2791                 :            : 
    2792                 :            : //------------------------------------------------------------------------------
    2793                 :          0 : void DbFilterField::SetList(const Any& rItems, sal_Bool bComboBox)
    2794                 :            : {
    2795         [ #  # ]:          0 :     ::comphelper::StringSequence aTest;
    2796         [ #  # ]:          0 :     rItems >>= aTest;
    2797                 :          0 :     const ::rtl::OUString* pStrings = aTest.getConstArray();
    2798                 :          0 :     sal_Int32 nItems = aTest.getLength();
    2799         [ #  # ]:          0 :     if (nItems)
    2800                 :            :     {
    2801         [ #  # ]:          0 :         if (bComboBox)
    2802                 :            :         {
    2803                 :          0 :             ComboBox* pField = (ComboBox*)m_pWindow;
    2804         [ #  # ]:          0 :             for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
    2805 [ #  # ][ #  # ]:          0 :                 pField->InsertEntry(*pStrings, LISTBOX_APPEND);
                 [ #  # ]
    2806                 :            :         }
    2807                 :            :         else
    2808                 :            :         {
    2809                 :          0 :             ListBox* pField = (ListBox*)m_pWindow;
    2810         [ #  # ]:          0 :             for (sal_Int32 i = 0; i < nItems; ++i, ++pStrings )
    2811 [ #  # ][ #  # ]:          0 :                 pField->InsertEntry(*pStrings, LISTBOX_APPEND);
                 [ #  # ]
    2812                 :            : 
    2813 [ #  # ][ #  # ]:          0 :             m_rColumn.getModel()->getPropertyValue(FM_PROP_VALUE_SEQ) >>= m_aValueList;
         [ #  # ][ #  # ]
    2814                 :          0 :             m_bBound = m_aValueList.getLength() > 0;
    2815                 :            :         }
    2816         [ #  # ]:          0 :     }
    2817                 :          0 : }
    2818                 :            : 
    2819                 :            : //------------------------------------------------------------------------------
    2820                 :          0 : void DbFilterField::CreateControl(Window* pParent, const Reference< ::com::sun::star::beans::XPropertySet >& xModel)
    2821                 :            : {
    2822   [ #  #  #  # ]:          0 :     switch (m_nControlClass)
    2823                 :            :     {
    2824                 :            :         case ::com::sun::star::form::FormComponentType::CHECKBOX:
    2825         [ #  # ]:          0 :             m_pWindow = new CheckBoxControl(pParent);
    2826                 :          0 :             m_pWindow->SetPaintTransparent( sal_True );
    2827                 :          0 :             ((CheckBoxControl*)m_pWindow)->SetClickHdl( LINK( this, DbFilterField, OnClick ) );
    2828                 :            : 
    2829         [ #  # ]:          0 :             m_pPainter = new CheckBoxControl(pParent);
    2830                 :          0 :             m_pPainter->SetPaintTransparent( sal_True );
    2831                 :          0 :             m_pPainter->SetBackground();
    2832                 :          0 :             break;
    2833                 :            :         case ::com::sun::star::form::FormComponentType::LISTBOX:
    2834                 :            :         {
    2835 [ #  # ][ #  # ]:          0 :             m_pWindow = new ListBoxControl(pParent);
    2836 [ #  # ][ #  # ]:          0 :             sal_Int16  nLines       = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_LINECOUNT));
         [ #  # ][ #  # ]
    2837 [ #  # ][ #  # ]:          0 :             Any  aItems      = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
                 [ #  # ]
    2838         [ #  # ]:          0 :             SetList(aItems, m_nControlClass == ::com::sun::star::form::FormComponentType::COMBOBOX);
    2839         [ #  # ]:          0 :             static_cast<ListBox*>(m_pWindow)->SetDropDownLineCount(nLines);
    2840                 :          0 :         }   break;
    2841                 :            :         case ::com::sun::star::form::FormComponentType::COMBOBOX:
    2842                 :            :         {
    2843 [ #  # ][ #  # ]:          0 :             m_pWindow = new ComboBoxControl(pParent);
    2844                 :            : 
    2845         [ #  # ]:          0 :             AllSettings     aSettings = m_pWindow->GetSettings();
    2846         [ #  # ]:          0 :             StyleSettings   aStyleSettings = aSettings.GetStyleSettings();
    2847                 :            :             aStyleSettings.SetSelectionOptions(
    2848         [ #  # ]:          0 :                            aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
    2849         [ #  # ]:          0 :             aSettings.SetStyleSettings(aStyleSettings);
    2850         [ #  # ]:          0 :             m_pWindow->SetSettings(aSettings, sal_True);
    2851                 :            : 
    2852         [ #  # ]:          0 :             if (!m_bFilterList)
    2853                 :            :             {
    2854 [ #  # ][ #  # ]:          0 :                 sal_Int16  nLines       = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_LINECOUNT));
         [ #  # ][ #  # ]
    2855 [ #  # ][ #  # ]:          0 :                 Any  aItems      = xModel->getPropertyValue(FM_PROP_STRINGITEMLIST);
                 [ #  # ]
    2856         [ #  # ]:          0 :                 SetList(aItems, m_nControlClass == ::com::sun::star::form::FormComponentType::COMBOBOX);
    2857         [ #  # ]:          0 :                 ((ComboBox*)m_pWindow)->SetDropDownLineCount(nLines);
    2858                 :            :             }
    2859                 :            :             else
    2860 [ #  # ][ #  # ]:          0 :                 ((ComboBox*)m_pWindow)->SetDropDownLineCount(5);
                 [ #  # ]
    2861                 :            : 
    2862                 :          0 :         }   break;
    2863                 :            :         default:
    2864                 :            :         {
    2865 [ #  # ][ #  # ]:          0 :             m_pWindow  = new Edit(pParent, WB_LEFT);
    2866         [ #  # ]:          0 :             AllSettings     aSettings = m_pWindow->GetSettings();
    2867         [ #  # ]:          0 :             StyleSettings   aStyleSettings = aSettings.GetStyleSettings();
    2868                 :            :             aStyleSettings.SetSelectionOptions(
    2869         [ #  # ]:          0 :                            aStyleSettings.GetSelectionOptions() | SELECTION_OPTION_SHOWFIRST);
    2870         [ #  # ]:          0 :             aSettings.SetStyleSettings(aStyleSettings);
    2871 [ #  # ][ #  # ]:          0 :             m_pWindow->SetSettings(aSettings, sal_True);
                 [ #  # ]
    2872                 :            :         }
    2873                 :            :     }
    2874                 :          0 : }
    2875                 :            : 
    2876                 :            : //------------------------------------------------------------------------------
    2877                 :          0 : void DbFilterField::Init( Window& rParent, const Reference< XRowSet >& xCursor )
    2878                 :            : {
    2879                 :          0 :     Reference< ::com::sun::star::beans::XPropertySet >  xModel(m_rColumn.getModel());
    2880         [ #  # ]:          0 :     m_rColumn.SetAlignment(::com::sun::star::awt::TextAlign::LEFT);
    2881                 :            : 
    2882         [ #  # ]:          0 :     if (xModel.is())
    2883                 :            :     {
    2884 [ #  # ][ #  # ]:          0 :         m_bFilterList = ::comphelper::hasProperty(FM_PROP_FILTERPROPOSAL, xModel) && ::comphelper::getBOOL(xModel->getPropertyValue(FM_PROP_FILTERPROPOSAL));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
    2885         [ #  # ]:          0 :         if (m_bFilterList)
    2886                 :          0 :             m_nControlClass = ::com::sun::star::form::FormComponentType::COMBOBOX;
    2887                 :            :         else
    2888                 :            :         {
    2889 [ #  # ][ #  # ]:          0 :             sal_Int16 nClassId = ::comphelper::getINT16(xModel->getPropertyValue(FM_PROP_CLASSID));
         [ #  # ][ #  # ]
    2890         [ #  # ]:          0 :             switch (nClassId)
    2891                 :            :             {
    2892                 :            :                 case FormComponentType::CHECKBOX:
    2893                 :            :                 case FormComponentType::LISTBOX:
    2894                 :            :                 case FormComponentType::COMBOBOX:
    2895                 :          0 :                     m_nControlClass = nClassId;
    2896                 :          0 :                     break;
    2897                 :            :                 default:
    2898         [ #  # ]:          0 :                     if (m_bFilterList)
    2899                 :          0 :                         m_nControlClass = FormComponentType::COMBOBOX;
    2900                 :            :                     else
    2901                 :          0 :                         m_nControlClass = FormComponentType::TEXTFIELD;
    2902                 :            :             }
    2903                 :            :         }
    2904                 :            :     }
    2905                 :            : 
    2906         [ #  # ]:          0 :     CreateControl( &rParent, xModel );
    2907         [ #  # ]:          0 :     DbCellControl::Init( rParent, xCursor );
    2908                 :            : 
    2909                 :            :     // filter cells are never readonly
    2910         [ #  # ]:          0 :     Edit* pAsEdit = dynamic_cast< Edit* >( m_pWindow );
    2911         [ #  # ]:          0 :     if ( pAsEdit )
    2912         [ #  # ]:          0 :         pAsEdit->SetReadOnly( sal_False );
    2913                 :          0 : }
    2914                 :            : 
    2915                 :            : //------------------------------------------------------------------------------
    2916                 :          0 : CellControllerRef DbFilterField::CreateController() const
    2917                 :            : {
    2918                 :          0 :     CellControllerRef xController;
    2919   [ #  #  #  # ]:          0 :     switch (m_nControlClass)
    2920                 :            :     {
    2921                 :            :         case ::com::sun::star::form::FormComponentType::CHECKBOX:
    2922 [ #  # ][ #  # ]:          0 :             xController = new CheckBoxCellController((CheckBoxControl*)m_pWindow);
                 [ #  # ]
    2923                 :          0 :             break;
    2924                 :            :         case ::com::sun::star::form::FormComponentType::LISTBOX:
    2925 [ #  # ][ #  # ]:          0 :             xController = new ListBoxCellController((ListBoxControl*)m_pWindow);
                 [ #  # ]
    2926                 :          0 :             break;
    2927                 :            :         case ::com::sun::star::form::FormComponentType::COMBOBOX:
    2928 [ #  # ][ #  # ]:          0 :             xController = new ComboBoxCellController((ComboBoxControl*)m_pWindow);
                 [ #  # ]
    2929                 :          0 :             break;
    2930                 :            :         default:
    2931         [ #  # ]:          0 :             if (m_bFilterList)
    2932 [ #  # ][ #  # ]:          0 :                 xController = new ComboBoxCellController((ComboBoxControl*)m_pWindow);
                 [ #  # ]
    2933                 :            :             else
    2934 [ #  # ][ #  # ]:          0 :                 xController = new EditCellController((Edit*)m_pWindow);
                 [ #  # ]
    2935                 :            :     }
    2936                 :          0 :     return xController;
    2937                 :            : }
    2938                 :            : 
    2939                 :            : //------------------------------------------------------------------------------
    2940                 :          0 : void DbFilterField::updateFromModel( Reference< XPropertySet > _rxModel )
    2941                 :            : {
    2942                 :            :     OSL_ENSURE( _rxModel.is() && m_pWindow, "DbFilterField::updateFromModel: invalid call!" );
    2943                 :            :     (void)_rxModel;
    2944                 :            : 
    2945                 :            :     OSL_FAIL( "DbListBox::updateFromModel: not implemented yet (how the hell did you reach this?)!" );
    2946                 :            :     // TODO: implement this.
    2947                 :            :     // remember: updateFromModel should be some kind of opposite of commitControl
    2948                 :          0 : }
    2949                 :            : 
    2950                 :            : //------------------------------------------------------------------------------
    2951                 :          0 : sal_Bool DbFilterField::commitControl()
    2952                 :            : {
    2953         [ #  # ]:          0 :     String aText(m_aText);
    2954      [ #  #  # ]:          0 :     switch (m_nControlClass)
    2955                 :            :     {
    2956                 :            :         case ::com::sun::star::form::FormComponentType::CHECKBOX:
    2957                 :          0 :             return sal_True;
    2958                 :            :         case ::com::sun::star::form::FormComponentType::LISTBOX:
    2959         [ #  # ]:          0 :             aText.Erase();
    2960 [ #  # ][ #  # ]:          0 :             if (static_cast<ListBox*>(m_pWindow)->GetSelectEntryCount())
    2961                 :            :             {
    2962         [ #  # ]:          0 :                 sal_Int16 nPos = (sal_Int16)static_cast<ListBox*>(m_pWindow)->GetSelectEntryPos();
    2963 [ #  # ][ #  # ]:          0 :                 if ( ( nPos >= 0 ) && ( nPos < m_aValueList.getLength() ) )
                 [ #  # ]
    2964         [ #  # ]:          0 :                     aText = m_aValueList.getConstArray()[nPos];
    2965                 :            :             }
    2966                 :            : 
    2967 [ #  # ][ #  # ]:          0 :             if (m_aText != aText)
    2968                 :            :             {
    2969         [ #  # ]:          0 :                 m_aText = aText;
    2970         [ #  # ]:          0 :                 m_aCommitLink.Call(this);
    2971                 :            :             }
    2972                 :          0 :             return sal_True;
    2973                 :            :         default:
    2974 [ #  # ][ #  # ]:          0 :             aText = m_pWindow->GetText();
                 [ #  # ]
    2975                 :            :     }
    2976                 :            : 
    2977 [ #  # ][ #  # ]:          0 :     if (m_aText != aText)
    2978                 :            :     {
    2979                 :            :         // check the text with the SQL-Parser
    2980 [ #  # ][ #  # ]:          0 :         String aNewText(comphelper::string::stripEnd(aText, ' '));
                 [ #  # ]
    2981         [ #  # ]:          0 :         if (aNewText.Len() != 0)
    2982                 :            :         {
    2983                 :          0 :             ::rtl::OUString aErrorMsg;
    2984                 :          0 :             Reference< XNumberFormatter >  xNumberFormatter(m_rColumn.GetParent().getNumberFormatter());
    2985                 :            : 
    2986 [ #  # ][ #  # ]:          0 :             ::rtl::Reference< ISQLParseNode > xParseNode = predicateTree(aErrorMsg, aNewText,xNumberFormatter, m_rColumn.GetField());
    2987         [ #  # ]:          0 :             if (xParseNode.is())
    2988                 :            :             {
    2989                 :          0 :                 ::rtl::OUString aPreparedText;
    2990                 :            : 
    2991 [ #  # ][ #  # ]:          0 :                 ::com::sun::star::lang::Locale aAppLocale = Application::GetSettings().GetUILocale();
    2992                 :            : 
    2993                 :            :                 Reference< XRowSet > xDataSourceRowSet(
    2994         [ #  # ]:          0 :                     (Reference< XInterface >)*m_rColumn.GetParent().getDataSource(), UNO_QUERY);
    2995         [ #  # ]:          0 :                 Reference< XConnection >  xConnection(getRowSetConnection(xDataSourceRowSet));
    2996                 :            : 
    2997                 :          0 :                 xParseNode->parseNodeToPredicateStr(aPreparedText,
    2998                 :            :                                                     xConnection,
    2999                 :            :                                                     xNumberFormatter,
    3000                 :          0 :                                                     m_rColumn.GetField(),aAppLocale,'.',
    3001   [ #  #  #  # ]:          0 :                                                     getParseContext());
    3002         [ #  # ]:          0 :                 m_aText = aPreparedText;
    3003                 :            :             }
    3004                 :            :             else
    3005                 :            :             {
    3006                 :            :                 // display the error and return sal_False
    3007 [ #  # ][ #  # ]:          0 :                 String aTitle( SVX_RES(RID_STR_SYNTAXERROR) );
    3008                 :            : 
    3009         [ #  # ]:          0 :                 SQLException aError;
    3010                 :          0 :                 aError.Message = aErrorMsg;
    3011 [ #  # ][ #  # ]:          0 :                 displayException(aError, m_pWindow->GetParent());
    3012                 :            :                     // TODO: transport the title
    3013                 :            : 
    3014 [ #  # ][ #  # ]:          0 :                 return sal_False;
    3015 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
    3016                 :            :         }
    3017                 :            :         else
    3018         [ #  # ]:          0 :             m_aText = aText;
    3019                 :            : 
    3020         [ #  # ]:          0 :         m_pWindow->SetText(m_aText);
    3021 [ #  # ][ #  # ]:          0 :         m_aCommitLink.Call(this);
                 [ #  # ]
    3022                 :            :     }
    3023         [ #  # ]:          0 :     return sal_True;
    3024                 :            : }
    3025                 :            : 
    3026                 :            : //------------------------------------------------------------------------------
    3027                 :          0 : void DbFilterField::SetText(const String& rText)
    3028                 :            : {
    3029                 :          0 :     m_aText = rText;
    3030      [ #  #  # ]:          0 :     switch (m_nControlClass)
    3031                 :            :     {
    3032                 :            :         case ::com::sun::star::form::FormComponentType::CHECKBOX:
    3033                 :            :         {
    3034                 :            :             TriState eState;
    3035         [ #  # ]:          0 :             if (rText.EqualsAscii("1"))
    3036                 :          0 :                 eState = STATE_CHECK;
    3037         [ #  # ]:          0 :             else if (rText.EqualsAscii("0"))
    3038                 :          0 :                 eState = STATE_NOCHECK;
    3039                 :            :             else
    3040                 :          0 :                 eState = STATE_DONTKNOW;
    3041                 :            : 
    3042                 :          0 :             ((CheckBoxControl*)m_pWindow)->GetBox().SetState(eState);
    3043                 :          0 :             ((CheckBoxControl*)m_pPainter)->GetBox().SetState(eState);
    3044                 :          0 :         }   break;
    3045                 :            :         case ::com::sun::star::form::FormComponentType::LISTBOX:
    3046                 :            :         {
    3047         [ #  # ]:          0 :             String aText;
    3048 [ #  # ][ #  # ]:          0 :             Sequence<sal_Int16> aPosSeq = ::comphelper::findValue(m_aValueList, m_aText, sal_True);
    3049         [ #  # ]:          0 :             if (aPosSeq.getLength())
    3050         [ #  # ]:          0 :                 static_cast<ListBox*>(m_pWindow)->SelectEntryPos(aPosSeq.getConstArray()[0], sal_True);
    3051                 :            :             else
    3052 [ #  # ][ #  # ]:          0 :                 static_cast<ListBox*>(m_pWindow)->SetNoSelection();
                 [ #  # ]
    3053                 :          0 :         }   break;
    3054                 :            :         default:
    3055                 :          0 :             m_pWindow->SetText(m_aText);
    3056                 :            :     }
    3057                 :            : 
    3058                 :            :     // now force a repaint on the window
    3059                 :          0 :     m_rColumn.GetParent().RowModified(0,m_rColumn.GetId());
    3060                 :          0 : }
    3061                 :            : 
    3062                 :            : //------------------------------------------------------------------------------
    3063                 :          0 : void DbFilterField::Update()
    3064                 :            : {
    3065                 :            :     // should we fill the combobox with a filter proposal?
    3066 [ #  # ][ #  # ]:          0 :     if (m_bFilterList && !m_bFilterListFilled)
    3067                 :            :     {
    3068                 :          0 :         m_bFilterListFilled = sal_True;
    3069                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet >  xField = m_rColumn.GetField();
    3070         [ #  # ]:          0 :         if (!xField.is())
    3071                 :            :             return;
    3072                 :            : 
    3073                 :          0 :         ::rtl::OUString aName;
    3074 [ #  # ][ #  # ]:          0 :         xField->getPropertyValue(FM_PROP_NAME) >>= aName;
                 [ #  # ]
    3075                 :            : 
    3076                 :            :         // the columnmodel
    3077         [ #  # ]:          0 :         Reference< ::com::sun::star::container::XChild >  xModelAsChild(m_rColumn.getModel(), UNO_QUERY);
    3078                 :            :         // the grid model
    3079 [ #  # ][ #  # ]:          0 :         xModelAsChild = Reference< ::com::sun::star::container::XChild > (xModelAsChild->getParent(),UNO_QUERY);
         [ #  # ][ #  # ]
    3080 [ #  # ][ #  # ]:          0 :         Reference< XRowSet >  xForm(xModelAsChild->getParent(), UNO_QUERY);
                 [ #  # ]
    3081         [ #  # ]:          0 :         if (!xForm.is())
    3082                 :            :             return;
    3083                 :            : 
    3084         [ #  # ]:          0 :         Reference<XPropertySet> xFormProp(xForm,UNO_QUERY);
    3085                 :          0 :         Reference< XTablesSupplier > xSupTab;
    3086 [ #  # ][ #  # ]:          0 :         xFormProp->getPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SingleSelectQueryComposer"))) >>= xSupTab;
         [ #  # ][ #  # ]
    3087                 :            : 
    3088         [ #  # ]:          0 :         Reference< XConnection >  xConnection(getRowSetConnection(xForm));
    3089         [ #  # ]:          0 :         if (!xSupTab.is())
    3090                 :            :             return;
    3091                 :            : 
    3092                 :            :         // search the field
    3093         [ #  # ]:          0 :         Reference< XColumnsSupplier > xSupCol(xSupTab,UNO_QUERY);
    3094 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::container::XNameAccess >    xFieldNames = xSupCol->getColumns();
    3095 [ #  # ][ #  # ]:          0 :         if (!xFieldNames->hasByName(aName))
                 [ #  # ]
    3096                 :            :             return;
    3097                 :            : 
    3098 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::container::XNameAccess >    xTablesNames = xSupTab->getTables();
    3099 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::beans::XPropertySet >       xComposerFieldAsSet(xFieldNames->getByName(aName),UNO_QUERY);
                 [ #  # ]
    3100                 :            : 
    3101 [ #  # ][ #  # ]:          0 :         if (xComposerFieldAsSet.is() && ::comphelper::hasProperty(FM_PROP_TABLENAME, xComposerFieldAsSet) &&
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    3102 [ #  # ][ #  # ]:          0 :             ::comphelper::hasProperty(FM_PROP_FIELDSOURCE, xComposerFieldAsSet))
         [ #  # ][ #  # ]
    3103                 :            :         {
    3104                 :          0 :             ::rtl::OUString aFieldName;
    3105                 :          0 :             ::rtl::OUString aTableName;
    3106 [ #  # ][ #  # ]:          0 :             xComposerFieldAsSet->getPropertyValue(FM_PROP_FIELDSOURCE)  >>= aFieldName;
                 [ #  # ]
    3107 [ #  # ][ #  # ]:          0 :             xComposerFieldAsSet->getPropertyValue(FM_PROP_TABLENAME)    >>= aTableName;
                 [ #  # ]
    3108                 :            : 
    3109                 :            :             // no possibility to create a select statement
    3110                 :            :             // looking for the complete table name
    3111 [ #  # ][ #  # ]:          0 :             if (!xTablesNames->hasByName(aTableName))
                 [ #  # ]
    3112                 :            :                 return;
    3113                 :            : 
    3114                 :            :             // ein Statement aufbauen und abschicken als query
    3115                 :            :             // Access to the connection
    3116                 :          0 :             Reference< XStatement >  xStatement;
    3117                 :          0 :             Reference< XResultSet >  xListCursor;
    3118                 :          0 :             Reference< ::com::sun::star::sdb::XColumn >  xDataField;
    3119                 :            : 
    3120                 :            :             try
    3121                 :            :             {
    3122 [ #  # ][ #  # ]:          0 :                 Reference< XDatabaseMetaData >  xMeta = xConnection->getMetaData();
    3123                 :            : 
    3124 [ #  # ][ #  # ]:          0 :                 String aQuote( xMeta->getIdentifierQuoteString());
                 [ #  # ]
    3125         [ #  # ]:          0 :                 String aStatement;
    3126         [ #  # ]:          0 :                 aStatement.AssignAscii("SELECT DISTINCT ");
    3127                 :            : 
    3128 [ #  # ][ #  # ]:          0 :                 aStatement += String(quoteName(aQuote, aName));
         [ #  # ][ #  # ]
                 [ #  # ]
    3129 [ #  # ][ #  # ]:          0 :                 if (!aFieldName.isEmpty() && aName != aFieldName)
                 [ #  # ]
    3130                 :            :                 {
    3131         [ #  # ]:          0 :                     aStatement.AppendAscii(" AS ");
    3132 [ #  # ][ #  # ]:          0 :                     aStatement += quoteName(aQuote, aFieldName).getStr();
                 [ #  # ]
    3133                 :            :                 }
    3134                 :            : 
    3135         [ #  # ]:          0 :                 aStatement.AppendAscii(" FROM ");
    3136                 :            : 
    3137 [ #  # ][ #  # ]:          0 :                 Reference< XPropertySet > xTableNameAccess( xTablesNames->getByName(aTableName), UNO_QUERY_THROW );
                 [ #  # ]
    3138 [ #  # ][ #  # ]:          0 :                 aStatement += composeTableNameForSelect( xConnection, xTableNameAccess ).getStr();
    3139                 :            : 
    3140 [ #  # ][ #  # ]:          0 :                 xStatement = xConnection->createStatement();
                 [ #  # ]
    3141         [ #  # ]:          0 :                 Reference< ::com::sun::star::beans::XPropertySet >  xStatementProps(xStatement, UNO_QUERY);
    3142 [ #  # ][ #  # ]:          0 :                 xStatementProps->setPropertyValue(FM_PROP_ESCAPE_PROCESSING, makeAny((sal_Bool)sal_True));
         [ #  # ][ #  # ]
    3143                 :            : 
    3144 [ #  # ][ #  # ]:          0 :                 xListCursor = xStatement->executeQuery(aStatement);
         [ #  # ][ #  # ]
    3145                 :            : 
    3146         [ #  # ]:          0 :                 Reference< ::com::sun::star::sdbcx::XColumnsSupplier >  xSupplyCols(xListCursor, UNO_QUERY);
    3147 [ #  # ][ #  # ]:          0 :                 Reference< ::com::sun::star::container::XIndexAccess >  xFields(xSupplyCols->getColumns(), UNO_QUERY);
                 [ #  # ]
    3148 [ #  # ][ #  # ]:          0 :                 ::cppu::extractInterface(xDataField, xFields->getByIndex(0));
                 [ #  # ]
    3149         [ #  # ]:          0 :                 if (!xDataField.is())
    3150 [ #  # ][ #  # ]:          0 :                     return;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3151                 :            :             }
    3152   [ #  #  #  # ]:          0 :             catch(const Exception&)
    3153                 :            :             {
    3154         [ #  # ]:          0 :                 ::comphelper::disposeComponent(xStatement);
    3155                 :            :                 return;
    3156                 :            :             }
    3157                 :            : 
    3158                 :          0 :             sal_Int16 i = 0;
    3159         [ #  # ]:          0 :             ::std::vector< ::rtl::OUString >   aStringList;
    3160         [ #  # ]:          0 :             aStringList.reserve(16);
    3161                 :          0 :             ::rtl::OUString aStr;
    3162                 :          0 :             com::sun::star::util::Date aNullDate = m_rColumn.GetParent().getNullDate();
    3163                 :          0 :             sal_Int32 nFormatKey = m_rColumn.GetKey();
    3164                 :          0 :             Reference< XNumberFormatter >  xFormatter = m_rColumn.GetParent().getNumberFormatter();
    3165 [ #  # ][ #  # ]:          0 :             sal_Int16 nKeyType = ::comphelper::getNumberFormatType(xFormatter->getNumberFormatsSupplier()->getNumberFormats(), nFormatKey);
         [ #  # ][ #  # ]
                 [ #  # ]
    3166                 :            : 
    3167 [ #  # ][ #  # ]:          0 :             while (!xListCursor->isAfterLast() && i++ < SHRT_MAX) // max anzahl eintraege
         [ #  # ][ #  # ]
                 [ #  # ]
    3168                 :            :             {
    3169         [ #  # ]:          0 :                 aStr = getFormattedValue(xDataField, xFormatter, aNullDate, nFormatKey, nKeyType);
    3170         [ #  # ]:          0 :                 aStringList.push_back(aStr);
    3171 [ #  # ][ #  # ]:          0 :                 xListCursor->next();
    3172                 :            :             }
    3173                 :            : 
    3174                 :            :             // filling the entries for the combobox
    3175 [ #  # ][ #  # ]:          0 :             for (::std::vector< ::rtl::OUString >::const_iterator iter = aStringList.begin();
                 [ #  # ]
    3176                 :          0 :                  iter != aStringList.end(); ++iter)
    3177 [ #  # ][ #  # ]:          0 :                 ((ComboBox*)m_pWindow)->InsertEntry(*iter, LISTBOX_APPEND);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    3178 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3179                 :            :     }
    3180                 :            : }
    3181                 :            : 
    3182                 :            : //------------------------------------------------------------------------------
    3183                 :          0 : XubString DbFilterField::GetFormatText(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/, Color** /*ppColor*/)
    3184                 :            : {
    3185                 :          0 :     return XubString();
    3186                 :            : }
    3187                 :            : 
    3188                 :            : //------------------------------------------------------------------
    3189                 :          0 : void DbFilterField::UpdateFromField(const Reference< XColumn >& /*_rxField*/, const Reference< XNumberFormatter >& /*xFormatter*/)
    3190                 :            : {
    3191                 :            :     OSL_FAIL( "DbFilterField::UpdateFromField: cannot update a filter control from a field!" );
    3192                 :          0 : }
    3193                 :            : 
    3194                 :            : //------------------------------------------------------------------
    3195                 :          0 : IMPL_LINK_NOARG(DbFilterField, OnClick)
    3196                 :            : {
    3197                 :          0 :     TriState eState = ((CheckBoxControl*)m_pWindow)->GetBox().GetState();
    3198         [ #  # ]:          0 :     String aText;
    3199                 :            : 
    3200   [ #  #  #  # ]:          0 :     switch (eState)
    3201                 :            :     {
    3202                 :            :         case STATE_CHECK:
    3203         [ #  # ]:          0 :             aText.AssignAscii("1");
    3204                 :          0 :             break;
    3205                 :            :         case STATE_NOCHECK:
    3206         [ #  # ]:          0 :             aText.AssignAscii("0");
    3207                 :          0 :             break;
    3208                 :            :         case STATE_DONTKNOW:
    3209 [ #  # ][ #  # ]:          0 :             aText = String();
                 [ #  # ]
    3210                 :          0 :             break;
    3211                 :            :     }
    3212                 :            : 
    3213 [ #  # ][ #  # ]:          0 :     if (m_aText != aText)
    3214                 :            :     {
    3215         [ #  # ]:          0 :         m_aText = aText;
    3216         [ #  # ]:          0 :         m_aCommitLink.Call(this);
    3217                 :            :     }
    3218         [ #  # ]:          0 :     return 1;
    3219                 :            : }
    3220                 :            : 
    3221                 :            : /*************************************************************************/
    3222         [ #  # ]:          0 : TYPEINIT0(FmXGridCell);
    3223                 :            : 
    3224                 :            : 
    3225                 :            : DBG_NAME(FmXGridCell);
    3226                 :            : //-----------------------------------------------------------------------------
    3227                 :         62 : FmXGridCell::FmXGridCell( DbGridColumn* pColumn, DbCellControl* _pControl )
    3228                 :            :             :OComponentHelper(m_aMutex)
    3229                 :            :             ,m_pColumn(pColumn)
    3230                 :            :             ,m_pCellControl( _pControl )
    3231                 :            :             ,m_aWindowListeners( m_aMutex )
    3232                 :            :             ,m_aFocusListeners( m_aMutex )
    3233                 :            :             ,m_aKeyListeners( m_aMutex )
    3234                 :            :             ,m_aMouseListeners( m_aMutex )
    3235 [ +  - ][ +  - ]:         62 :             ,m_aMouseMotionListeners( m_aMutex )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3236                 :            : {
    3237                 :            :     DBG_CTOR(FmXGridCell,NULL);
    3238                 :         62 : }
    3239                 :            : 
    3240                 :            : //-----------------------------------------------------------------------------
    3241                 :         62 : void FmXGridCell::init()
    3242                 :            : {
    3243                 :         62 :     Window* pEventWindow( getEventWindow() );
    3244         [ +  - ]:         62 :     if ( pEventWindow )
    3245         [ +  - ]:         62 :         pEventWindow->AddEventListener( LINK( this, FmXGridCell, OnWindowEvent ) );
    3246                 :         62 : }
    3247                 :            : 
    3248                 :            : //-----------------------------------------------------------------------------
    3249                 :         62 : Window* FmXGridCell::getEventWindow() const
    3250                 :            : {
    3251         [ +  - ]:         62 :     if ( m_pCellControl )
    3252                 :         62 :         return &m_pCellControl->GetWindow();
    3253                 :         62 :     return NULL;
    3254                 :            : }
    3255                 :            : 
    3256                 :            : //-----------------------------------------------------------------------------
    3257 [ +  - ][ +  - ]:         62 : FmXGridCell::~FmXGridCell()
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
    3258                 :            : {
    3259         [ -  + ]:         62 :     if (!OComponentHelper::rBHelper.bDisposed)
    3260                 :            :     {
    3261                 :          0 :         acquire();
    3262         [ #  # ]:          0 :         dispose();
    3263                 :            :     }
    3264                 :            : 
    3265                 :            :     DBG_DTOR(FmXGridCell,NULL);
    3266         [ -  + ]:         62 : }
    3267                 :            : 
    3268                 :            : //------------------------------------------------------------------
    3269                 :          0 : void FmXGridCell::SetTextLineColor()
    3270                 :            : {
    3271         [ #  # ]:          0 :     if (m_pCellControl)
    3272                 :          0 :         m_pCellControl->SetTextLineColor();
    3273                 :          0 : }
    3274                 :            : 
    3275                 :            : //------------------------------------------------------------------
    3276                 :          0 : void FmXGridCell::SetTextLineColor(const Color& _rColor)
    3277                 :            : {
    3278         [ #  # ]:          0 :     if (m_pCellControl)
    3279                 :          0 :         m_pCellControl->SetTextLineColor(_rColor);
    3280                 :          0 : }
    3281                 :            : 
    3282                 :            : // XTypeProvider
    3283                 :            : //------------------------------------------------------------------
    3284                 :          0 : Sequence< Type > SAL_CALL FmXGridCell::getTypes( ) throw (RuntimeException)
    3285                 :            : {
    3286                 :            :     Sequence< uno::Type > aTypes = ::comphelper::concatSequences(
    3287                 :            :         ::cppu::OComponentHelper::getTypes(),
    3288                 :            :         FmXGridCell_Base::getTypes()
    3289 [ #  # ][ #  # ]:          0 :     );
         [ #  # ][ #  # ]
    3290         [ #  # ]:          0 :     if ( m_pCellControl )
    3291                 :            :         aTypes = ::comphelper::concatSequences(
    3292                 :            :             aTypes,
    3293                 :            :             FmXGridCell_WindowBase::getTypes()
    3294 [ #  # ][ #  # ]:          0 :         );
         [ #  # ][ #  # ]
                 [ #  # ]
    3295                 :          0 :     return aTypes;
    3296                 :            : }
    3297                 :            : 
    3298                 :            : //------------------------------------------------------------------
    3299                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXGridCell )
    3300                 :            : 
    3301                 :            : // OComponentHelper
    3302                 :            : //-----------------------------------------------------------------------------
    3303                 :         62 : void FmXGridCell::disposing()
    3304                 :            : {
    3305 [ +  - ][ +  - ]:         62 :     lang::EventObject aEvent( *this );
    3306         [ +  - ]:         62 :     m_aWindowListeners.disposeAndClear( aEvent );
    3307         [ +  - ]:         62 :     m_aFocusListeners.disposeAndClear( aEvent );
    3308         [ +  - ]:         62 :     m_aKeyListeners.disposeAndClear( aEvent );
    3309         [ +  - ]:         62 :     m_aMouseListeners.disposeAndClear( aEvent );
    3310         [ +  - ]:         62 :     m_aMouseMotionListeners.disposeAndClear( aEvent );
    3311                 :            : 
    3312         [ +  - ]:         62 :     OComponentHelper::disposing();
    3313                 :         62 :     m_pColumn = NULL;
    3314 [ +  - ][ +  - ]:         62 :     DELETEZ(m_pCellControl);
                 [ +  - ]
    3315                 :         62 : }
    3316                 :            : 
    3317                 :            : //------------------------------------------------------------------
    3318                 :        248 : Any SAL_CALL FmXGridCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    3319                 :            : {
    3320                 :        248 :     Any aReturn = OComponentHelper::queryAggregation( _rType );
    3321                 :            : 
    3322         [ -  + ]:        248 :     if ( !aReturn.hasValue() )
    3323         [ #  # ]:          0 :         aReturn = FmXGridCell_Base::queryInterface( _rType );
    3324                 :            : 
    3325 [ -  + ][ #  # ]:        248 :     if ( !aReturn.hasValue() && ( m_pCellControl != NULL ) )
                 [ -  + ]
    3326         [ #  # ]:          0 :         aReturn = FmXGridCell_WindowBase::queryInterface( _rType );
    3327                 :            : 
    3328                 :        248 :     return aReturn;
    3329                 :            : }
    3330                 :            : 
    3331                 :            : // ::com::sun::star::awt::XControl
    3332                 :            : //-----------------------------------------------------------------------------
    3333                 :          0 : Reference< XInterface >  FmXGridCell::getContext() throw( RuntimeException )
    3334                 :            : {
    3335                 :          0 :     return Reference< XInterface > ();
    3336                 :            : }
    3337                 :            : 
    3338                 :            : //-----------------------------------------------------------------------------
    3339                 :          0 : Reference< ::com::sun::star::awt::XControlModel >  FmXGridCell::getModel() throw( ::com::sun::star::uno::RuntimeException )
    3340                 :            : {
    3341                 :          0 :     return Reference< ::com::sun::star::awt::XControlModel > (m_pColumn->getModel(), UNO_QUERY);
    3342                 :            : }
    3343                 :            : 
    3344                 :            : // ::com::sun::star::form::XBoundControl
    3345                 :            : //------------------------------------------------------------------
    3346                 :          0 : sal_Bool FmXGridCell::getLock() throw( RuntimeException )
    3347                 :            : {
    3348                 :          0 :     return m_pColumn->isLocked();
    3349                 :            : }
    3350                 :            : 
    3351                 :            : //------------------------------------------------------------------
    3352                 :          0 : void FmXGridCell::setLock(sal_Bool _bLock) throw( RuntimeException )
    3353                 :            : {
    3354         [ #  # ]:          0 :     if (getLock() == _bLock)
    3355                 :          0 :         return;
    3356                 :            :     else
    3357                 :            :     {
    3358         [ #  # ]:          0 :         ::osl::MutexGuard aGuard(m_aMutex);
    3359 [ #  # ][ #  # ]:          0 :         m_pColumn->setLock(_bLock);
    3360                 :            :     }
    3361                 :            : }
    3362                 :            : 
    3363                 :            : //------------------------------------------------------------------
    3364                 :          0 : void SAL_CALL FmXGridCell::setPosSize( ::sal_Int32 _XX, ::sal_Int32 _Y, ::sal_Int32 _Width, ::sal_Int32 _Height, ::sal_Int16 _Flags ) throw (RuntimeException)
    3365                 :            : {
    3366                 :            :     OSL_FAIL( "FmXGridCell::setPosSize: not implemented" );
    3367                 :            :     (void)_XX;
    3368                 :            :     (void)_Y;
    3369                 :            :     (void)_Width;
    3370                 :            :     (void)_Height;
    3371                 :            :     (void)_Flags;
    3372                 :            :     // not allowed to tamper with this for a grid cell
    3373                 :          0 : }
    3374                 :            : 
    3375                 :            : //------------------------------------------------------------------
    3376                 :          0 : awt::Rectangle SAL_CALL FmXGridCell::getPosSize(  ) throw (RuntimeException)
    3377                 :            : {
    3378                 :            :     OSL_FAIL( "FmXGridCell::getPosSize: not implemented" );
    3379                 :          0 :     return awt::Rectangle();
    3380                 :            : }
    3381                 :            : 
    3382                 :            : //------------------------------------------------------------------
    3383                 :          0 : void SAL_CALL FmXGridCell::setVisible( ::sal_Bool _Visible ) throw (RuntimeException)
    3384                 :            : {
    3385                 :            :     OSL_FAIL( "FmXGridCell::setVisible: not implemented" );
    3386                 :            :     (void)_Visible;
    3387                 :            :     // not allowed to tamper with this for a grid cell
    3388                 :          0 : }
    3389                 :            : 
    3390                 :            : //------------------------------------------------------------------
    3391                 :          0 : void SAL_CALL FmXGridCell::setEnable( ::sal_Bool _Enable ) throw (RuntimeException)
    3392                 :            : {
    3393                 :            :     OSL_FAIL( "FmXGridCell::setEnable: not implemented" );
    3394                 :            :     (void)_Enable;
    3395                 :            :     // not allowed to tamper with this for a grid cell
    3396                 :          0 : }
    3397                 :            : 
    3398                 :            : //------------------------------------------------------------------
    3399                 :          0 : void SAL_CALL FmXGridCell::setFocus(  ) throw (RuntimeException)
    3400                 :            : {
    3401                 :            :     OSL_FAIL( "FmXGridCell::setFocus: not implemented" );
    3402                 :            :     // not allowed to tamper with this for a grid cell
    3403                 :          0 : }
    3404                 :            : 
    3405                 :            : //------------------------------------------------------------------
    3406                 :          0 : void SAL_CALL FmXGridCell::addWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException)
    3407                 :            : {
    3408                 :          0 :     m_aWindowListeners.addInterface( _rxListener );
    3409                 :          0 : }
    3410                 :            : 
    3411                 :            : //------------------------------------------------------------------
    3412                 :          0 : void SAL_CALL FmXGridCell::removeWindowListener( const Reference< awt::XWindowListener >& _rxListener ) throw (RuntimeException)
    3413                 :            : {
    3414                 :          0 :     m_aWindowListeners.removeInterface( _rxListener );
    3415                 :          0 : }
    3416                 :            : 
    3417                 :            : //------------------------------------------------------------------
    3418                 :          0 : void SAL_CALL FmXGridCell::addFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException)
    3419                 :            : {
    3420                 :          0 :     m_aFocusListeners.addInterface( _rxListener );
    3421                 :          0 : }
    3422                 :            : 
    3423                 :            : //------------------------------------------------------------------
    3424                 :          0 : void SAL_CALL FmXGridCell::removeFocusListener( const Reference< awt::XFocusListener >& _rxListener ) throw (RuntimeException)
    3425                 :            : {
    3426                 :          0 :     m_aFocusListeners.removeInterface( _rxListener );
    3427                 :          0 : }
    3428                 :            : 
    3429                 :            : //------------------------------------------------------------------
    3430                 :          0 : void SAL_CALL FmXGridCell::addKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException)
    3431                 :            : {
    3432                 :          0 :     m_aKeyListeners.addInterface( _rxListener );
    3433                 :          0 : }
    3434                 :            : 
    3435                 :            : //------------------------------------------------------------------
    3436                 :          0 : void SAL_CALL FmXGridCell::removeKeyListener( const Reference< awt::XKeyListener >& _rxListener ) throw (RuntimeException)
    3437                 :            : {
    3438                 :          0 :     m_aKeyListeners.removeInterface( _rxListener );
    3439                 :          0 : }
    3440                 :            : 
    3441                 :            : //------------------------------------------------------------------
    3442                 :          0 : void SAL_CALL FmXGridCell::addMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException)
    3443                 :            : {
    3444                 :          0 :     m_aMouseListeners.addInterface( _rxListener );
    3445                 :          0 : }
    3446                 :            : 
    3447                 :            : //------------------------------------------------------------------
    3448                 :          0 : void SAL_CALL FmXGridCell::removeMouseListener( const Reference< awt::XMouseListener >& _rxListener ) throw (RuntimeException)
    3449                 :            : {
    3450                 :          0 :     m_aMouseListeners.removeInterface( _rxListener );
    3451                 :          0 : }
    3452                 :            : 
    3453                 :            : //------------------------------------------------------------------
    3454                 :          0 : void SAL_CALL FmXGridCell::addMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException)
    3455                 :            : {
    3456                 :          0 :     m_aMouseMotionListeners.addInterface( _rxListener );
    3457                 :          0 : }
    3458                 :            : 
    3459                 :            : //------------------------------------------------------------------
    3460                 :          0 : void SAL_CALL FmXGridCell::removeMouseMotionListener( const Reference< awt::XMouseMotionListener >& _rxListener ) throw (RuntimeException)
    3461                 :            : {
    3462                 :          0 :     m_aMouseMotionListeners.removeInterface( _rxListener );
    3463                 :          0 : }
    3464                 :            : 
    3465                 :            : //------------------------------------------------------------------
    3466                 :          0 : void SAL_CALL FmXGridCell::addPaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException)
    3467                 :            : {
    3468                 :            :     OSL_FAIL( "FmXGridCell::addPaintListener: not implemented" );
    3469                 :            :     (void)_rxListener;
    3470                 :          0 : }
    3471                 :            : 
    3472                 :            : //------------------------------------------------------------------
    3473                 :          0 : void SAL_CALL FmXGridCell::removePaintListener( const Reference< awt::XPaintListener >& _rxListener ) throw (RuntimeException)
    3474                 :            : {
    3475                 :            :     OSL_FAIL( "FmXGridCell::removePaintListener: not implemented" );
    3476                 :            :     (void)_rxListener;
    3477                 :          0 : }
    3478                 :            : 
    3479                 :            : //------------------------------------------------------------------
    3480                 :         62 : IMPL_LINK( FmXGridCell, OnWindowEvent, VclWindowEvent*, _pEvent )
    3481                 :            : {
    3482 [ -  + ][ #  # ]:         62 :     ENSURE_OR_THROW( _pEvent, "illegal event pointer" );
         [ #  # ][ #  # ]
    3483 [ -  + ][ #  # ]:         62 :     ENSURE_OR_THROW( _pEvent->GetWindow(), "illegal window" );
         [ #  # ][ #  # ]
    3484                 :         62 :     onWindowEvent( _pEvent->GetId(), *_pEvent->GetWindow(), _pEvent->GetData() );
    3485                 :         62 :     return 1L;
    3486                 :            : }
    3487                 :            : 
    3488                 :            : //------------------------------------------------------------------------------
    3489                 :          0 : void FmXGridCell::onFocusGained( const awt::FocusEvent& _rEvent )
    3490                 :            : {
    3491                 :          0 :     m_aFocusListeners.notifyEach( &awt::XFocusListener::focusGained, _rEvent );
    3492                 :          0 : }
    3493                 :            : 
    3494                 :            : //------------------------------------------------------------------------------
    3495                 :          0 : void FmXGridCell::onFocusLost( const awt::FocusEvent& _rEvent )
    3496                 :            : {
    3497                 :          0 :     m_aFocusListeners.notifyEach( &awt::XFocusListener::focusLost, _rEvent );
    3498                 :          0 : }
    3499                 :            : 
    3500                 :            : //------------------------------------------------------------------------------
    3501                 :         62 : void FmXGridCell::onWindowEvent( const sal_uIntPtr _nEventId, const Window& _rWindow, const void* _pEventData )
    3502                 :            : {
    3503   [ -  -  -  -  :         62 :     switch ( _nEventId )
                      + ]
    3504                 :            :     {
    3505                 :            :     case VCLEVENT_CONTROL_GETFOCUS:
    3506                 :            :     case VCLEVENT_WINDOW_GETFOCUS:
    3507                 :            :     case VCLEVENT_CONTROL_LOSEFOCUS:
    3508                 :            :     case VCLEVENT_WINDOW_LOSEFOCUS:
    3509                 :            :     {
    3510 [ #  # ][ #  # ]:          0 :         if  (   (   _rWindow.IsCompoundControl()
           [ #  #  #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3511                 :            :                 &&  (   _nEventId == VCLEVENT_CONTROL_GETFOCUS
    3512                 :            :                     ||  _nEventId == VCLEVENT_CONTROL_LOSEFOCUS
    3513                 :            :                     )
    3514                 :            :                 )
    3515                 :          0 :             ||  (   !_rWindow.IsCompoundControl()
    3516                 :            :                 &&  (   _nEventId == VCLEVENT_WINDOW_GETFOCUS
    3517                 :            :                     ||  _nEventId == VCLEVENT_WINDOW_LOSEFOCUS
    3518                 :            :                     )
    3519                 :            :                 )
    3520                 :            :             )
    3521                 :            :         {
    3522 [ #  # ][ #  # ]:          0 :             if ( !m_aFocusListeners.getLength() )
    3523                 :            :                 break;
    3524                 :            : 
    3525 [ #  # ][ #  # ]:          0 :             bool bFocusGained = ( _nEventId == VCLEVENT_CONTROL_GETFOCUS ) || ( _nEventId == VCLEVENT_WINDOW_GETFOCUS );
    3526                 :            : 
    3527         [ #  # ]:          0 :             awt::FocusEvent aEvent;
    3528 [ #  # ][ #  # ]:          0 :             aEvent.Source = *this;
    3529         [ #  # ]:          0 :             aEvent.FocusFlags = _rWindow.GetGetFocusFlags();
    3530                 :          0 :             aEvent.Temporary = sal_False;
    3531                 :            : 
    3532         [ #  # ]:          0 :             if ( bFocusGained )
    3533         [ #  # ]:          0 :                 onFocusGained( aEvent );
    3534                 :            :             else
    3535 [ #  # ][ #  # ]:          0 :                 onFocusLost( aEvent );
    3536                 :            :         }
    3537                 :            :     }
    3538                 :          0 :     break;
    3539                 :            :     case VCLEVENT_WINDOW_MOUSEBUTTONDOWN:
    3540                 :            :     case VCLEVENT_WINDOW_MOUSEBUTTONUP:
    3541                 :            :     {
    3542 [ #  # ][ #  # ]:          0 :         if ( !m_aMouseListeners.getLength() )
    3543                 :            :             break;
    3544                 :            : 
    3545                 :          0 :         const bool bButtonDown = ( _nEventId == VCLEVENT_WINDOW_MOUSEBUTTONDOWN );
    3546                 :            : 
    3547 [ #  # ][ #  # ]:          0 :         awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( *static_cast< const ::MouseEvent* >( _pEventData ), *this ) );
    3548 [ #  # ][ #  # ]:          0 :         m_aMouseListeners.notifyEach( bButtonDown ? &awt::XMouseListener::mousePressed : &awt::XMouseListener::mouseReleased, aEvent );
                 [ #  # ]
    3549                 :            :     }
    3550                 :          0 :     break;
    3551                 :            :     case VCLEVENT_WINDOW_MOUSEMOVE:
    3552                 :            :     {
    3553                 :          0 :         const MouseEvent& rMouseEvent = *static_cast< const ::MouseEvent* >( _pEventData );
    3554 [ #  # ][ #  # ]:          0 :         if ( rMouseEvent.IsEnterWindow() || rMouseEvent.IsLeaveWindow() )
                 [ #  # ]
    3555                 :            :         {
    3556         [ #  # ]:          0 :             if ( m_aMouseListeners.getLength() != 0 )
    3557                 :            :             {
    3558 [ #  # ][ #  # ]:          0 :                 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
    3559 [ #  # ][ #  # ]:          0 :                 m_aMouseListeners.notifyEach( rMouseEvent.IsEnterWindow() ? &awt::XMouseListener::mouseEntered: &awt::XMouseListener::mouseExited, aEvent );
                 [ #  # ]
    3560                 :            :             }
    3561                 :            :         }
    3562 [ #  # ][ #  # ]:          0 :         else if ( !rMouseEvent.IsEnterWindow() && !rMouseEvent.IsLeaveWindow() )
                 [ #  # ]
    3563                 :            :         {
    3564         [ #  # ]:          0 :             if ( m_aMouseMotionListeners.getLength() != 0 )
    3565                 :            :             {
    3566 [ #  # ][ #  # ]:          0 :                 awt::MouseEvent aEvent( VCLUnoHelper::createMouseEvent( rMouseEvent, *this ) );
    3567                 :          0 :                 aEvent.ClickCount = 0;
    3568                 :          0 :                 const bool bSimpleMove = ( ( rMouseEvent.GetMode() & MOUSE_SIMPLEMOVE ) != 0 );
    3569 [ #  # ][ #  # ]:          0 :                 m_aMouseMotionListeners.notifyEach( bSimpleMove ? &awt::XMouseMotionListener::mouseMoved: &awt::XMouseMotionListener::mouseDragged, aEvent );
                 [ #  # ]
    3570                 :            :             }
    3571                 :            :         }
    3572                 :            :     }
    3573                 :          0 :     break;
    3574                 :            :     case VCLEVENT_WINDOW_KEYINPUT:
    3575                 :            :     case VCLEVENT_WINDOW_KEYUP:
    3576                 :            :     {
    3577 [ #  # ][ #  # ]:          0 :         if ( !m_aKeyListeners.getLength() )
    3578                 :            :             break;
    3579                 :            : 
    3580                 :          0 :         const bool bKeyPressed = ( _nEventId == VCLEVENT_WINDOW_KEYINPUT );
    3581 [ #  # ][ #  # ]:          0 :         awt::KeyEvent aEvent( VCLUnoHelper::createKeyEvent( *static_cast< const ::KeyEvent* >( _pEventData ), *this ) );
    3582 [ #  # ][ #  # ]:          0 :         m_aKeyListeners.notifyEach( bKeyPressed ? &awt::XKeyListener::keyPressed: &awt::XKeyListener::keyReleased, aEvent );
                 [ #  # ]
    3583                 :            :     }
    3584                 :          0 :     break;
    3585                 :            :     }
    3586                 :         62 : }
    3587                 :            : 
    3588                 :            : /*************************************************************************/
    3589 [ +  - ][ #  # ]:        336 : TYPEINIT1(FmXDataCell, FmXGridCell);
    3590                 :            : //------------------------------------------------------------------------------
    3591                 :         48 : void FmXDataCell::PaintFieldToCell(OutputDevice& rDev, const Rectangle& rRect,
    3592                 :            :                         const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
    3593                 :            :                         const Reference< XNumberFormatter >& xFormatter)
    3594                 :            : {
    3595                 :         48 :     m_pCellControl->PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
    3596                 :         48 : }
    3597                 :            : 
    3598                 :            : //------------------------------------------------------------------------------
    3599                 :          0 : void FmXDataCell::UpdateFromColumn()
    3600                 :            : {
    3601         [ #  # ]:          0 :     Reference< ::com::sun::star::sdb::XColumn >  xField(m_pColumn->GetCurrentFieldValue());
    3602         [ #  # ]:          0 :     if (xField.is())
    3603         [ #  # ]:          0 :         m_pCellControl->UpdateFromField(xField, m_pColumn->GetParent().getNumberFormatter());
    3604                 :          0 : }
    3605                 :            : 
    3606                 :            : /*************************************************************************/
    3607 [ -  + ][ +  - ]:        336 : TYPEINIT1(FmXTextCell, FmXDataCell);
    3608                 :            : 
    3609                 :         62 : FmXTextCell::FmXTextCell( DbGridColumn* pColumn, DbCellControl& _rControl )
    3610                 :            :     :FmXDataCell( pColumn, _rControl )
    3611                 :         62 :     ,m_bFastPaint( sal_True )
    3612                 :            : {
    3613                 :         62 : }
    3614                 :            : 
    3615                 :            : //------------------------------------------------------------------------------
    3616                 :        112 : void FmXTextCell::PaintFieldToCell(OutputDevice& rDev,
    3617                 :            :                         const Rectangle& rRect,
    3618                 :            :                         const Reference< ::com::sun::star::sdb::XColumn >& _rxField,
    3619                 :            :                         const Reference< XNumberFormatter >& xFormatter)
    3620                 :            : {
    3621         [ +  + ]:        112 :     if ( !m_bFastPaint )
    3622                 :            :     {
    3623         [ +  - ]:         48 :         FmXDataCell::PaintFieldToCell( rDev, rRect, _rxField, xFormatter );
    3624                 :        112 :         return;
    3625                 :            :     }
    3626                 :            : 
    3627                 :         64 :     sal_uInt16 nStyle = TEXT_DRAW_CLIP | TEXT_DRAW_VCENTER;
    3628 [ +  - ][ +  - ]:         64 :     if ( ( rDev.GetOutDevType() == OUTDEV_WINDOW ) && !static_cast< Window& >( rDev ).IsEnabled() )
         [ -  + ][ -  + ]
    3629                 :          0 :         nStyle |= TEXT_DRAW_DISABLE;
    3630                 :            : 
    3631      [ -  -  + ]:         64 :     switch (m_pColumn->GetAlignment())
    3632                 :            :     {
    3633                 :            :         case ::com::sun::star::awt::TextAlign::RIGHT:
    3634                 :          0 :             nStyle |= TEXT_DRAW_RIGHT;
    3635                 :          0 :             break;
    3636                 :            :         case ::com::sun::star::awt::TextAlign::CENTER:
    3637                 :          0 :             nStyle |= TEXT_DRAW_CENTER;
    3638                 :          0 :             break;
    3639                 :            :         default:
    3640                 :         64 :             nStyle |= TEXT_DRAW_LEFT;
    3641                 :            :     }
    3642                 :            : 
    3643                 :         64 :     Color* pColor = NULL;
    3644         [ +  - ]:         64 :     String aText = GetText(_rxField, xFormatter, &pColor);
    3645         [ -  + ]:         64 :     if (pColor != NULL)
    3646                 :            :     {
    3647                 :          0 :         Color aOldTextColor( rDev.GetTextColor() );
    3648         [ #  # ]:          0 :         rDev.SetTextColor( *pColor );
    3649         [ #  # ]:          0 :         rDev.DrawText(rRect, aText, nStyle);
    3650         [ #  # ]:          0 :         rDev.SetTextColor( aOldTextColor );
    3651                 :            :     }
    3652                 :            :     else
    3653 [ +  - ][ +  - ]:        112 :         rDev.DrawText(rRect, aText, nStyle);
    3654                 :            : }
    3655                 :            : 
    3656                 :            : 
    3657                 :            : /*************************************************************************/
    3658                 :            : 
    3659                 :            : DBG_NAME(FmXEditCell);
    3660                 :            : //------------------------------------------------------------------------------
    3661                 :         62 : FmXEditCell::FmXEditCell( DbGridColumn* pColumn, DbCellControl& _rControl )
    3662                 :            :             :FmXTextCell( pColumn, _rControl )
    3663                 :            :             ,m_aTextListeners(m_aMutex)
    3664                 :            :             ,m_aChangeListeners( m_aMutex )
    3665                 :            :             ,m_pEditImplementation( NULL )
    3666 [ +  - ][ +  - ]:         62 :             ,m_bOwnEditImplementation( false )
    3667                 :            : {
    3668                 :            :     DBG_CTOR(FmXEditCell,NULL);
    3669                 :            : 
    3670 [ +  - ][ +  - ]:         62 :     DbTextField* pTextField = PTR_CAST( DbTextField, &_rControl );
                 [ +  + ]
    3671         [ +  + ]:         62 :     if ( pTextField )
    3672                 :            :     {
    3673                 :            : 
    3674                 :         34 :         m_pEditImplementation = pTextField->GetEditImplementation();
    3675         [ +  - ]:         34 :         if ( !pTextField->IsSimpleEdit() )
    3676                 :         34 :             m_bFastPaint = sal_False;
    3677                 :            :     }
    3678                 :            :     else
    3679                 :            :     {
    3680 [ +  - ][ +  - ]:         28 :         m_pEditImplementation = new EditImplementation( static_cast< Edit& >( _rControl.GetWindow() ) );
                 [ +  - ]
    3681                 :         28 :         m_bOwnEditImplementation = true;
    3682                 :            :     }
    3683                 :         62 : }
    3684                 :            : 
    3685                 :            : //------------------------------------------------------------------
    3686 [ +  - ][ +  - ]:         62 : FmXEditCell::~FmXEditCell()
    3687                 :            : {
    3688         [ -  + ]:         62 :     if (!OComponentHelper::rBHelper.bDisposed)
    3689                 :            :     {
    3690                 :          0 :         acquire();
    3691         [ #  # ]:          0 :         dispose();
    3692                 :            :     }
    3693                 :            : 
    3694                 :            : 
    3695                 :            :     DBG_DTOR(FmXEditCell,NULL);
    3696         [ -  + ]:        124 : }
    3697                 :            : 
    3698                 :            : // OComponentHelper
    3699                 :            : //-----------------------------------------------------------------------------
    3700                 :         62 : void FmXEditCell::disposing()
    3701                 :            : {
    3702 [ +  - ][ +  - ]:         62 :     ::com::sun::star::lang::EventObject aEvt(*this);
    3703         [ +  - ]:         62 :     m_aTextListeners.disposeAndClear(aEvt);
    3704         [ +  - ]:         62 :     m_aChangeListeners.disposeAndClear(aEvt);
    3705                 :            : 
    3706 [ +  - ][ +  - ]:         62 :     m_pEditImplementation->SetModifyHdl( Link() );
    3707         [ +  + ]:         62 :     if ( m_bOwnEditImplementation )
    3708 [ +  - ][ +  - ]:         28 :         delete m_pEditImplementation;
    3709                 :         62 :     m_pEditImplementation = NULL;
    3710                 :            : 
    3711 [ +  - ][ +  - ]:         62 :     FmXDataCell::disposing();
    3712                 :         62 : }
    3713                 :            : 
    3714                 :            : //------------------------------------------------------------------
    3715                 :        248 : Any SAL_CALL FmXEditCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    3716                 :            : {
    3717                 :        248 :     Any aReturn = FmXTextCell::queryAggregation( _rType );
    3718                 :            : 
    3719         [ -  + ]:        248 :     if ( !aReturn.hasValue() )
    3720         [ #  # ]:          0 :         aReturn = FmXEditCell_Base::queryInterface( _rType );
    3721                 :            : 
    3722                 :        248 :     return aReturn;
    3723                 :            : }
    3724                 :            : 
    3725                 :            : //-------------------------------------------------------------------------
    3726                 :          0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXEditCell::getTypes(  ) throw(RuntimeException)
    3727                 :            : {
    3728                 :            :     return ::comphelper::concatSequences(
    3729                 :            :         FmXTextCell::getTypes(),
    3730                 :            :         FmXEditCell_Base::getTypes()
    3731 [ #  # ][ #  # ]:          0 :     );
                 [ #  # ]
    3732                 :            : }
    3733                 :            : 
    3734                 :            : //------------------------------------------------------------------------------
    3735                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXEditCell )
    3736                 :            : 
    3737                 :            : // ::com::sun::star::awt::XTextComponent
    3738                 :            : //------------------------------------------------------------------------------
    3739                 :          0 : void SAL_CALL FmXEditCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
    3740                 :            : {
    3741                 :          0 :     m_aTextListeners.addInterface( l );
    3742                 :          0 : }
    3743                 :            : 
    3744                 :            : //------------------------------------------------------------------------------
    3745                 :          0 : void SAL_CALL FmXEditCell::removeTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
    3746                 :            : {
    3747                 :          0 :     m_aTextListeners.removeInterface( l );
    3748                 :          0 : }
    3749                 :            : 
    3750                 :            : //------------------------------------------------------------------------------
    3751                 :          0 : void SAL_CALL FmXEditCell::setText( const ::rtl::OUString& aText ) throw( RuntimeException )
    3752                 :            : {
    3753         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3754                 :            : 
    3755         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3756                 :            :     {
    3757 [ #  # ][ #  # ]:          0 :         m_pEditImplementation->SetText( aText );
                 [ #  # ]
    3758                 :            : 
    3759                 :            :         // In JAVA wird auch ein textChanged ausgeloest, in VCL nicht.
    3760                 :            :         // ::com::sun::star::awt::Toolkit soll JAVA-komform sein...
    3761         [ #  # ]:          0 :         onTextChanged();
    3762         [ #  # ]:          0 :     }
    3763                 :          0 : }
    3764                 :            : 
    3765                 :            : //------------------------------------------------------------------------------
    3766                 :          0 : void SAL_CALL FmXEditCell::insertText(const ::com::sun::star::awt::Selection& rSel, const ::rtl::OUString& aText) throw(RuntimeException)
    3767                 :            : {
    3768         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3769                 :            : 
    3770         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3771                 :            :     {
    3772         [ #  # ]:          0 :         m_pEditImplementation->SetSelection( Selection( rSel.Min, rSel.Max ) );
    3773 [ #  # ][ #  # ]:          0 :         m_pEditImplementation->ReplaceSelected( aText );
                 [ #  # ]
    3774         [ #  # ]:          0 :     }
    3775                 :          0 : }
    3776                 :            : 
    3777                 :            : //------------------------------------------------------------------------------
    3778                 :          0 : ::rtl::OUString SAL_CALL FmXEditCell::getText() throw( RuntimeException )
    3779                 :            : {
    3780         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3781                 :            : 
    3782                 :          0 :     ::rtl::OUString aText;
    3783         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3784                 :            :     {
    3785 [ #  # ][ #  # ]:          0 :         if ( m_pEditImplementation->GetControl().IsVisible() && m_pColumn->GetParent().getDisplaySynchron())
         [ #  # ][ #  # ]
                 [ #  # ]
    3786                 :            :         {
    3787                 :            :             // if the display isn't sync with the cursor we can't ask the edit field
    3788 [ #  # ][ #  # ]:          0 :             LineEnd eLineEndFormat = m_pColumn ? getModelLineEndSetting( m_pColumn->getModel() ) : LINEEND_LF;
    3789 [ #  # ][ #  # ]:          0 :             aText = m_pEditImplementation->GetText( eLineEndFormat );
                 [ #  # ]
    3790                 :            :         }
    3791                 :            :         else
    3792                 :            :         {
    3793         [ #  # ]:          0 :             Reference< ::com::sun::star::sdb::XColumn >  xField(m_pColumn->GetCurrentFieldValue());
    3794         [ #  # ]:          0 :             if (xField.is())
    3795 [ #  # ][ #  # ]:          0 :                 aText = GetText(xField, m_pColumn->GetParent().getNumberFormatter());
                 [ #  # ]
    3796                 :            :         }
    3797                 :            :     }
    3798         [ #  # ]:          0 :     return aText;
    3799                 :            : }
    3800                 :            : 
    3801                 :            : //------------------------------------------------------------------------------
    3802                 :          0 : ::rtl::OUString SAL_CALL FmXEditCell::getSelectedText( void ) throw( RuntimeException )
    3803                 :            : {
    3804         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3805                 :            : 
    3806                 :          0 :     ::rtl::OUString aText;
    3807         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3808                 :            :     {
    3809 [ #  # ][ #  # ]:          0 :         LineEnd eLineEndFormat = m_pColumn ? getModelLineEndSetting( m_pColumn->getModel() ) : LINEEND_LF;
    3810 [ #  # ][ #  # ]:          0 :         aText = m_pEditImplementation->GetSelected( eLineEndFormat );
                 [ #  # ]
    3811                 :            :     }
    3812         [ #  # ]:          0 :     return aText;
    3813                 :            : }
    3814                 :            : 
    3815                 :            : //------------------------------------------------------------------------------
    3816                 :          0 : void SAL_CALL FmXEditCell::setSelection( const ::com::sun::star::awt::Selection& aSelection ) throw( RuntimeException )
    3817                 :            : {
    3818         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3819                 :            : 
    3820         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3821 [ #  # ][ #  # ]:          0 :         m_pEditImplementation->SetSelection( Selection( aSelection.Min, aSelection.Max ) );
    3822                 :          0 : }
    3823                 :            : 
    3824                 :            : //------------------------------------------------------------------------------
    3825                 :          0 : ::com::sun::star::awt::Selection SAL_CALL FmXEditCell::getSelection( void ) throw( RuntimeException )
    3826                 :            : {
    3827         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3828                 :            : 
    3829                 :          0 :     Selection aSel;
    3830         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3831         [ #  # ]:          0 :         aSel = m_pEditImplementation->GetSelection();
    3832                 :            : 
    3833         [ #  # ]:          0 :     return ::com::sun::star::awt::Selection(aSel.Min(), aSel.Max());
    3834                 :            : }
    3835                 :            : 
    3836                 :            : //------------------------------------------------------------------------------
    3837                 :          0 : sal_Bool SAL_CALL FmXEditCell::isEditable( void ) throw( RuntimeException )
    3838                 :            : {
    3839         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3840                 :            : 
    3841 [ #  # ][ #  # ]:          0 :     return ( m_pEditImplementation && !m_pEditImplementation->IsReadOnly() && m_pEditImplementation->GetControl().IsEnabled() ) ? sal_True : sal_False;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    3842                 :            : }
    3843                 :            : 
    3844                 :            : //------------------------------------------------------------------------------
    3845                 :          0 : void SAL_CALL FmXEditCell::setEditable( sal_Bool bEditable ) throw( RuntimeException )
    3846                 :            : {
    3847         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3848                 :            : 
    3849         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3850 [ #  # ][ #  # ]:          0 :         m_pEditImplementation->SetReadOnly( !bEditable );
    3851                 :          0 : }
    3852                 :            : 
    3853                 :            : //------------------------------------------------------------------------------
    3854                 :          0 : sal_Int16 SAL_CALL FmXEditCell::getMaxTextLen() throw( RuntimeException )
    3855                 :            : {
    3856         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3857                 :            : 
    3858 [ #  # ][ #  # ]:          0 :     return m_pEditImplementation ? m_pEditImplementation->GetMaxTextLen() : 0;
                 [ #  # ]
    3859                 :            : }
    3860                 :            : 
    3861                 :            : //------------------------------------------------------------------------------
    3862                 :          0 : void SAL_CALL FmXEditCell::setMaxTextLen( sal_Int16 nLen ) throw( RuntimeException )
    3863                 :            : {
    3864         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    3865                 :            : 
    3866         [ #  # ]:          0 :     if ( m_pEditImplementation )
    3867 [ #  # ][ #  # ]:          0 :         m_pEditImplementation->SetMaxTextLen( nLen );
    3868                 :          0 : }
    3869                 :            : 
    3870                 :            : //------------------------------------------------------------------------------
    3871                 :          0 : void SAL_CALL FmXEditCell::addChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException)
    3872                 :            : {
    3873                 :          0 :     m_aChangeListeners.addInterface( _Listener );
    3874                 :          0 : }
    3875                 :            : 
    3876                 :            : //------------------------------------------------------------------------------
    3877                 :          0 : void SAL_CALL FmXEditCell::removeChangeListener( const Reference< form::XChangeListener >& _Listener ) throw (RuntimeException)
    3878                 :            : {
    3879                 :          0 :     m_aChangeListeners.removeInterface( _Listener );
    3880                 :          0 : }
    3881                 :            : 
    3882                 :            : //------------------------------------------------------------------------------
    3883                 :          0 : void FmXEditCell::onTextChanged()
    3884                 :            : {
    3885         [ #  # ]:          0 :     ::com::sun::star::awt::TextEvent aEvent;
    3886 [ #  # ][ #  # ]:          0 :     aEvent.Source = *this;
    3887 [ #  # ][ #  # ]:          0 :     m_aTextListeners.notifyEach( &awt::XTextListener::textChanged, aEvent );
    3888                 :          0 : }
    3889                 :            : 
    3890                 :            : //------------------------------------------------------------------------------
    3891                 :          0 : void FmXEditCell::onFocusGained( const awt::FocusEvent& _rEvent )
    3892                 :            : {
    3893                 :          0 :     FmXTextCell::onFocusGained( _rEvent );
    3894                 :          0 :     m_sValueOnEnter = getText();
    3895                 :          0 : }
    3896                 :            : 
    3897                 :            : //------------------------------------------------------------------------------
    3898                 :          0 : void FmXEditCell::onFocusLost( const awt::FocusEvent& _rEvent )
    3899                 :            : {
    3900                 :          0 :     FmXTextCell::onFocusLost( _rEvent );
    3901                 :            : 
    3902         [ #  # ]:          0 :     if ( getText() != m_sValueOnEnter )
    3903                 :            :     {
    3904 [ #  # ][ #  # ]:          0 :         lang::EventObject aEvent( *this );
    3905 [ #  # ][ #  # ]:          0 :         m_aChangeListeners.notifyEach( &XChangeListener::changed, aEvent );
    3906                 :            :     }
    3907                 :          0 : }
    3908                 :            : 
    3909                 :            : //------------------------------------------------------------------------------
    3910                 :         62 : void FmXEditCell::onWindowEvent( const sal_uIntPtr _nEventId, const Window& _rWindow, const void* _pEventData )
    3911                 :            : {
    3912         [ -  + ]:         62 :     switch ( _nEventId )
    3913                 :            :     {
    3914                 :            :     case VCLEVENT_EDIT_MODIFY:
    3915                 :            :     {
    3916 [ #  # ][ #  # ]:          0 :         if ( m_pEditImplementation && m_aTextListeners.getLength() )
                 [ #  # ]
    3917                 :          0 :             onTextChanged();
    3918                 :         62 :         return;
    3919                 :            :     }
    3920                 :            :     }
    3921                 :            : 
    3922                 :         62 :     FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
    3923                 :            : }
    3924                 :            : 
    3925                 :            : /*************************************************************************/
    3926                 :            : DBG_NAME(FmXCheckBoxCell);
    3927                 :            : //------------------------------------------------------------------------------
    3928                 :          0 : FmXCheckBoxCell::FmXCheckBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
    3929                 :            :                 :FmXDataCell( pColumn, _rControl )
    3930                 :            :                 ,m_aItemListeners(m_aMutex)
    3931                 :            :                 ,m_aActionListeners( m_aMutex )
    3932 [ #  # ][ #  # ]:          0 :                 ,m_pBox( & static_cast< CheckBoxControl& >( _rControl.GetWindow() ).GetBox() )
                 [ #  # ]
    3933                 :            : {
    3934                 :            :     DBG_CTOR(FmXCheckBoxCell,NULL);
    3935                 :          0 : }
    3936                 :            : 
    3937                 :            : //------------------------------------------------------------------
    3938 [ #  # ][ #  # ]:          0 : FmXCheckBoxCell::~FmXCheckBoxCell()
    3939                 :            : {
    3940         [ #  # ]:          0 :     if (!OComponentHelper::rBHelper.bDisposed)
    3941                 :            :     {
    3942                 :          0 :         acquire();
    3943         [ #  # ]:          0 :         dispose();
    3944                 :            :     }
    3945                 :            : 
    3946                 :            :     DBG_DTOR(FmXCheckBoxCell,NULL);
    3947         [ #  # ]:          0 : }
    3948                 :            : 
    3949                 :            : // OComponentHelper
    3950                 :            : //-----------------------------------------------------------------------------
    3951                 :          0 : void FmXCheckBoxCell::disposing()
    3952                 :            : {
    3953 [ #  # ][ #  # ]:          0 :     ::com::sun::star::lang::EventObject aEvt(*this);
    3954         [ #  # ]:          0 :     m_aItemListeners.disposeAndClear(aEvt);
    3955         [ #  # ]:          0 :     m_aActionListeners.disposeAndClear(aEvt);
    3956                 :            : 
    3957 [ #  # ][ #  # ]:          0 :     static_cast< CheckBoxControl& >( m_pCellControl->GetWindow() ).SetClickHdl(Link());
    3958                 :          0 :     m_pBox = NULL;
    3959                 :            : 
    3960 [ #  # ][ #  # ]:          0 :     FmXDataCell::disposing();
    3961                 :          0 : }
    3962                 :            : 
    3963                 :            : //------------------------------------------------------------------
    3964                 :          0 : Any SAL_CALL FmXCheckBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    3965                 :            : {
    3966                 :          0 :     Any aReturn = FmXDataCell::queryAggregation( _rType );
    3967                 :            : 
    3968         [ #  # ]:          0 :     if ( !aReturn.hasValue() )
    3969         [ #  # ]:          0 :         aReturn = FmXCheckBoxCell_Base::queryInterface( _rType );
    3970                 :            : 
    3971                 :          0 :     return aReturn;
    3972                 :            : }
    3973                 :            : 
    3974                 :            : //-------------------------------------------------------------------------
    3975                 :          0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXCheckBoxCell::getTypes(  ) throw(RuntimeException)
    3976                 :            : {
    3977                 :            :     return ::comphelper::concatSequences(
    3978                 :            :         FmXDataCell::getTypes(),
    3979                 :            :         FmXCheckBoxCell_Base::getTypes()
    3980 [ #  # ][ #  # ]:          0 :     );
                 [ #  # ]
    3981                 :            : }
    3982                 :            : 
    3983                 :            : //------------------------------------------------------------------------------
    3984                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXCheckBoxCell )
    3985                 :            : 
    3986                 :            : //------------------------------------------------------------------
    3987                 :          0 : void SAL_CALL FmXCheckBoxCell::addItemListener( const Reference< ::com::sun::star::awt::XItemListener >& l ) throw( RuntimeException )
    3988                 :            : {
    3989                 :          0 :     m_aItemListeners.addInterface( l );
    3990                 :          0 : }
    3991                 :            : 
    3992                 :            : //------------------------------------------------------------------
    3993                 :          0 : void SAL_CALL FmXCheckBoxCell::removeItemListener( const Reference< ::com::sun::star::awt::XItemListener >& l ) throw( RuntimeException )
    3994                 :            : {
    3995                 :          0 :     m_aItemListeners.removeInterface( l );
    3996                 :          0 : }
    3997                 :            : 
    3998                 :            : //------------------------------------------------------------------
    3999                 :          0 : void SAL_CALL FmXCheckBoxCell::setState( short n ) throw( RuntimeException )
    4000                 :            : {
    4001         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4002                 :            : 
    4003         [ #  # ]:          0 :     if (m_pBox)
    4004                 :            :     {
    4005         [ #  # ]:          0 :         UpdateFromColumn();
    4006         [ #  # ]:          0 :         m_pBox->SetState( (TriState)n );
    4007         [ #  # ]:          0 :     }
    4008                 :          0 : }
    4009                 :            : 
    4010                 :            : //------------------------------------------------------------------
    4011                 :          0 : short SAL_CALL FmXCheckBoxCell::getState() throw( RuntimeException )
    4012                 :            : {
    4013         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4014                 :            : 
    4015         [ #  # ]:          0 :     if (m_pBox)
    4016                 :            :     {
    4017         [ #  # ]:          0 :         UpdateFromColumn();
    4018                 :          0 :         return (short)m_pBox->GetState();
    4019                 :            :     }
    4020         [ #  # ]:          0 :     return STATE_DONTKNOW;
    4021                 :            : }
    4022                 :            : 
    4023                 :            : //------------------------------------------------------------------
    4024                 :          0 : void SAL_CALL FmXCheckBoxCell::enableTriState( sal_Bool b ) throw( RuntimeException )
    4025                 :            : {
    4026         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4027                 :            : 
    4028         [ #  # ]:          0 :     if (m_pBox)
    4029 [ #  # ][ #  # ]:          0 :         m_pBox->EnableTriState( b );
    4030                 :          0 : }
    4031                 :            : 
    4032                 :            : //------------------------------------------------------------------
    4033                 :          0 : void SAL_CALL FmXCheckBoxCell::addActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException)
    4034                 :            : {
    4035                 :          0 :     m_aActionListeners.addInterface( _Listener );
    4036                 :          0 : }
    4037                 :            : 
    4038                 :            : //------------------------------------------------------------------
    4039                 :          0 : void SAL_CALL FmXCheckBoxCell::removeActionListener( const Reference< awt::XActionListener >& _Listener ) throw (RuntimeException)
    4040                 :            : {
    4041                 :          0 :     m_aActionListeners.removeInterface( _Listener );
    4042                 :          0 : }
    4043                 :            : 
    4044                 :            : //------------------------------------------------------------------
    4045                 :          0 : void SAL_CALL FmXCheckBoxCell::setLabel( const ::rtl::OUString& _Label ) throw (RuntimeException)
    4046                 :            : {
    4047         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    4048         [ #  # ]:          0 :     if ( m_pColumn )
    4049                 :            :     {
    4050                 :          0 :         DbGridControl& rGrid( m_pColumn->GetParent() );
    4051 [ #  # ][ #  # ]:          0 :         rGrid.SetColumnTitle( rGrid.GetColumnId( m_pColumn->GetFieldPos() ), _Label );
         [ #  # ][ #  # ]
    4052         [ #  # ]:          0 :     }
    4053                 :          0 : }
    4054                 :            : 
    4055                 :            : //------------------------------------------------------------------
    4056                 :          0 : void SAL_CALL FmXCheckBoxCell::setActionCommand( const ::rtl::OUString& _Command ) throw (RuntimeException)
    4057                 :            : {
    4058                 :          0 :     m_aActionCommand = _Command;
    4059                 :          0 : }
    4060                 :            : 
    4061                 :            : //------------------------------------------------------------------
    4062                 :          0 : Window* FmXCheckBoxCell::getEventWindow() const
    4063                 :            : {
    4064                 :          0 :     return m_pBox;
    4065                 :            : }
    4066                 :            : 
    4067                 :            : //------------------------------------------------------------------
    4068                 :          0 : void FmXCheckBoxCell::onWindowEvent( const sal_uIntPtr _nEventId, const Window& _rWindow, const void* _pEventData )
    4069                 :            : {
    4070         [ #  # ]:          0 :     switch ( _nEventId )
    4071                 :            :     {
    4072                 :            :     case VCLEVENT_CHECKBOX_TOGGLE:
    4073                 :            :     {
    4074                 :            :         // check boxes are to be committed immediately (this holds for ordinary check box controls in
    4075                 :            :         // documents, and this must hold for check boxes in grid columns, too
    4076                 :            :         // 91210 - 22.08.2001 - frank.schoenheit@sun.com
    4077         [ #  # ]:          0 :         m_pCellControl->Commit();
    4078                 :            : 
    4079         [ #  # ]:          0 :         Reference< XWindow > xKeepAlive( this );
    4080 [ #  # ][ #  # ]:          0 :         if ( m_aItemListeners.getLength() && m_pBox )
         [ #  # ][ #  # ]
    4081                 :            :         {
    4082         [ #  # ]:          0 :             awt::ItemEvent aEvent;
    4083 [ #  # ][ #  # ]:          0 :             aEvent.Source = *this;
    4084                 :          0 :             aEvent.Highlighted = sal_False;
    4085                 :          0 :             aEvent.Selected = m_pBox->GetState();
    4086 [ #  # ][ #  # ]:          0 :             m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
    4087                 :            :         }
    4088 [ #  # ][ #  # ]:          0 :         if ( m_aActionListeners.getLength() )
    4089                 :            :         {
    4090         [ #  # ]:          0 :             awt::ActionEvent aEvent;
    4091 [ #  # ][ #  # ]:          0 :             aEvent.Source = *this;
    4092                 :          0 :             aEvent.ActionCommand = m_aActionCommand;
    4093 [ #  # ][ #  # ]:          0 :             m_aActionListeners.notifyEach( &awt::XActionListener::actionPerformed, aEvent );
    4094                 :          0 :         }
    4095                 :            :     }
    4096                 :          0 :     break;
    4097                 :            : 
    4098                 :            :     default:
    4099                 :          0 :         FmXDataCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
    4100                 :          0 :         break;
    4101                 :            :     }
    4102                 :          0 : }
    4103                 :            : 
    4104                 :            : /*************************************************************************/
    4105                 :            : 
    4106                 :            : DBG_NAME(FmXListBoxCell);
    4107                 :            : //------------------------------------------------------------------------------
    4108                 :          0 : FmXListBoxCell::FmXListBoxCell(DbGridColumn* pColumn, DbCellControl& _rControl)
    4109                 :            :                :FmXTextCell( pColumn, _rControl )
    4110                 :            :                ,m_aItemListeners(m_aMutex)
    4111                 :            :                ,m_aActionListeners(m_aMutex)
    4112 [ #  # ][ #  # ]:          0 :                ,m_pBox( &static_cast< ListBox& >( _rControl.GetWindow() ) )
                 [ #  # ]
    4113                 :            : {
    4114                 :            :     DBG_CTOR(FmXListBoxCell,NULL);
    4115                 :            : 
    4116         [ #  # ]:          0 :     m_pBox->SetDoubleClickHdl( LINK( this, FmXListBoxCell, OnDoubleClick ) );
    4117                 :          0 : }
    4118                 :            : 
    4119                 :            : //------------------------------------------------------------------
    4120 [ #  # ][ #  # ]:          0 : FmXListBoxCell::~FmXListBoxCell()
    4121                 :            : {
    4122         [ #  # ]:          0 :     if (!OComponentHelper::rBHelper.bDisposed)
    4123                 :            :     {
    4124                 :          0 :         acquire();
    4125         [ #  # ]:          0 :         dispose();
    4126                 :            :     }
    4127                 :            : 
    4128                 :            :     DBG_DTOR(FmXListBoxCell,NULL);
    4129         [ #  # ]:          0 : }
    4130                 :            : 
    4131                 :            : // OComponentHelper
    4132                 :            : //-----------------------------------------------------------------------------
    4133                 :          0 : void FmXListBoxCell::disposing()
    4134                 :            : {
    4135 [ #  # ][ #  # ]:          0 :     ::com::sun::star::lang::EventObject aEvt(*this);
    4136         [ #  # ]:          0 :     m_aItemListeners.disposeAndClear(aEvt);
    4137         [ #  # ]:          0 :     m_aActionListeners.disposeAndClear(aEvt);
    4138                 :            : 
    4139         [ #  # ]:          0 :     m_pBox->SetSelectHdl( Link() );
    4140         [ #  # ]:          0 :     m_pBox->SetDoubleClickHdl( Link() );
    4141                 :          0 :     m_pBox = NULL;
    4142                 :            : 
    4143 [ #  # ][ #  # ]:          0 :     FmXTextCell::disposing();
    4144                 :          0 : }
    4145                 :            : 
    4146                 :            : //------------------------------------------------------------------
    4147                 :          0 : Any SAL_CALL FmXListBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    4148                 :            : {
    4149                 :          0 :     Any aReturn = FmXTextCell::queryAggregation(_rType);
    4150                 :            : 
    4151         [ #  # ]:          0 :     if ( !aReturn.hasValue() )
    4152         [ #  # ]:          0 :         aReturn = FmXListBoxCell_Base::queryInterface( _rType );
    4153                 :            : 
    4154                 :          0 :     return aReturn;
    4155                 :            : }
    4156                 :            : 
    4157                 :            : //-------------------------------------------------------------------------
    4158                 :          0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXListBoxCell::getTypes(  ) throw(RuntimeException)
    4159                 :            : {
    4160                 :            :     return ::comphelper::concatSequences(
    4161                 :            :         FmXTextCell::getTypes(),
    4162                 :            :         FmXListBoxCell_Base::getTypes()
    4163 [ #  # ][ #  # ]:          0 :     );
                 [ #  # ]
    4164                 :            : }
    4165                 :            : 
    4166                 :            : //------------------------------------------------------------------------------
    4167                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXListBoxCell )
    4168                 :            : 
    4169                 :            : //------------------------------------------------------------------
    4170                 :          0 : void SAL_CALL FmXListBoxCell::addItemListener(const Reference< ::com::sun::star::awt::XItemListener >& l) throw( RuntimeException )
    4171                 :            : {
    4172                 :          0 :     m_aItemListeners.addInterface( l );
    4173                 :          0 : }
    4174                 :            : 
    4175                 :            : //------------------------------------------------------------------
    4176                 :          0 : void SAL_CALL FmXListBoxCell::removeItemListener(const Reference< ::com::sun::star::awt::XItemListener >& l) throw( RuntimeException )
    4177                 :            : {
    4178                 :          0 :     m_aItemListeners.removeInterface( l );
    4179                 :          0 : }
    4180                 :            : 
    4181                 :            : //------------------------------------------------------------------
    4182                 :          0 : void SAL_CALL FmXListBoxCell::addActionListener(const Reference< ::com::sun::star::awt::XActionListener >& l) throw( RuntimeException )
    4183                 :            : {
    4184                 :          0 :     m_aActionListeners.addInterface( l );
    4185                 :          0 : }
    4186                 :            : 
    4187                 :            : //------------------------------------------------------------------
    4188                 :          0 : void SAL_CALL FmXListBoxCell::removeActionListener(const Reference< ::com::sun::star::awt::XActionListener >& l) throw( RuntimeException )
    4189                 :            : {
    4190                 :          0 :     m_aActionListeners.removeInterface( l );
    4191                 :          0 : }
    4192                 :            : 
    4193                 :            : //------------------------------------------------------------------
    4194                 :          0 : void SAL_CALL FmXListBoxCell::addItem(const ::rtl::OUString& aItem, sal_Int16 nPos) throw( RuntimeException )
    4195                 :            : {
    4196         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4197         [ #  # ]:          0 :     if (m_pBox)
    4198 [ #  # ][ #  # ]:          0 :         m_pBox->InsertEntry( aItem, nPos );
         [ #  # ][ #  # ]
    4199                 :          0 : }
    4200                 :            : 
    4201                 :            : //------------------------------------------------------------------
    4202                 :          0 : void SAL_CALL FmXListBoxCell::addItems(const ::comphelper::StringSequence& aItems, sal_Int16 nPos) throw( RuntimeException )
    4203                 :            : {
    4204         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4205         [ #  # ]:          0 :     if (m_pBox)
    4206                 :            :     {
    4207                 :          0 :         sal_uInt16 nP = nPos;
    4208         [ #  # ]:          0 :         for ( sal_uInt16 n = 0; n < aItems.getLength(); n++ )
    4209                 :            :         {
    4210 [ #  # ][ #  # ]:          0 :             m_pBox->InsertEntry( aItems.getConstArray()[n], nP );
                 [ #  # ]
    4211         [ #  # ]:          0 :             if ( nPos != -1 )    // Nicht wenn 0xFFFF, weil LIST_APPEND
    4212                 :          0 :                 nP++;
    4213                 :            :         }
    4214         [ #  # ]:          0 :     }
    4215                 :          0 : }
    4216                 :            : 
    4217                 :            : //------------------------------------------------------------------
    4218                 :          0 : void SAL_CALL FmXListBoxCell::removeItems(sal_Int16 nPos, sal_Int16 nCount) throw( RuntimeException )
    4219                 :            : {
    4220         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4221         [ #  # ]:          0 :     if ( m_pBox )
    4222                 :            :     {
    4223         [ #  # ]:          0 :         for ( sal_uInt16 n = nCount; n; )
    4224         [ #  # ]:          0 :             m_pBox->RemoveEntry( nPos + (--n) );
    4225         [ #  # ]:          0 :     }
    4226                 :          0 : }
    4227                 :            : 
    4228                 :            : //------------------------------------------------------------------
    4229                 :          0 : sal_Int16 SAL_CALL FmXListBoxCell::getItemCount() throw( RuntimeException )
    4230                 :            : {
    4231         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4232 [ #  # ][ #  # ]:          0 :     return m_pBox ? m_pBox->GetEntryCount() : 0;
                 [ #  # ]
    4233                 :            : }
    4234                 :            : 
    4235                 :            : //------------------------------------------------------------------
    4236                 :          0 : ::rtl::OUString SAL_CALL FmXListBoxCell::getItem(sal_Int16 nPos) throw( RuntimeException )
    4237                 :            : {
    4238         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4239         [ #  # ]:          0 :     String aItem;
    4240         [ #  # ]:          0 :     if (m_pBox)
    4241 [ #  # ][ #  # ]:          0 :         aItem = m_pBox->GetEntry( nPos );
                 [ #  # ]
    4242 [ #  # ][ #  # ]:          0 :     return aItem;
                 [ #  # ]
    4243                 :            : }
    4244                 :            : //------------------------------------------------------------------
    4245                 :          0 : ::comphelper::StringSequence SAL_CALL FmXListBoxCell::getItems() throw( RuntimeException )
    4246                 :            : {
    4247         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4248                 :            : 
    4249         [ #  # ]:          0 :     ::comphelper::StringSequence aSeq;
    4250         [ #  # ]:          0 :     if (m_pBox)
    4251                 :            :     {
    4252         [ #  # ]:          0 :         sal_uInt16 nEntries = m_pBox ->GetEntryCount();
    4253 [ #  # ][ #  # ]:          0 :         aSeq = ::comphelper::StringSequence( nEntries );
                 [ #  # ]
    4254         [ #  # ]:          0 :         for ( sal_uInt16 n = nEntries; n; )
    4255                 :            :         {
    4256                 :          0 :             --n;
    4257 [ #  # ][ #  # ]:          0 :             aSeq.getArray()[n] = m_pBox ->GetEntry( n );
         [ #  # ][ #  # ]
    4258                 :            :         }
    4259                 :            :     }
    4260         [ #  # ]:          0 :     return aSeq;
    4261                 :            : }
    4262                 :            : 
    4263                 :            : //------------------------------------------------------------------
    4264                 :          0 : sal_Int16 SAL_CALL FmXListBoxCell::getSelectedItemPos() throw( RuntimeException )
    4265                 :            : {
    4266         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4267         [ #  # ]:          0 :     if (m_pBox)
    4268                 :            :     {
    4269         [ #  # ]:          0 :         UpdateFromColumn();
    4270         [ #  # ]:          0 :         return m_pBox->GetSelectEntryPos();
    4271                 :            :     }
    4272         [ #  # ]:          0 :     return 0;
    4273                 :            : }
    4274                 :            : 
    4275                 :            : //------------------------------------------------------------------
    4276                 :          0 : Sequence< sal_Int16 > SAL_CALL FmXListBoxCell::getSelectedItemsPos() throw( RuntimeException )
    4277                 :            : {
    4278         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4279         [ #  # ]:          0 :     Sequence<sal_Int16> aSeq;
    4280                 :            : 
    4281         [ #  # ]:          0 :     if (m_pBox)
    4282                 :            :     {
    4283         [ #  # ]:          0 :         UpdateFromColumn();
    4284         [ #  # ]:          0 :         sal_uInt16 nSelEntries = m_pBox->GetSelectEntryCount();
    4285 [ #  # ][ #  # ]:          0 :         aSeq = Sequence<sal_Int16>( nSelEntries );
                 [ #  # ]
    4286         [ #  # ]:          0 :         for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
    4287 [ #  # ][ #  # ]:          0 :             aSeq.getArray()[n] = m_pBox->GetSelectEntryPos( n );
    4288                 :            :     }
    4289         [ #  # ]:          0 :     return aSeq;
    4290                 :            : }
    4291                 :            : //------------------------------------------------------------------
    4292                 :          0 : ::rtl::OUString SAL_CALL FmXListBoxCell::getSelectedItem() throw( RuntimeException )
    4293                 :            : {
    4294         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4295                 :            : 
    4296         [ #  # ]:          0 :     String aItem;
    4297         [ #  # ]:          0 :     if (m_pBox)
    4298                 :            :     {
    4299         [ #  # ]:          0 :         UpdateFromColumn();
    4300 [ #  # ][ #  # ]:          0 :         aItem = m_pBox->GetSelectEntry();
                 [ #  # ]
    4301                 :            :     }
    4302                 :            : 
    4303 [ #  # ][ #  # ]:          0 :     return aItem;
                 [ #  # ]
    4304                 :            : }
    4305                 :            : 
    4306                 :            : //------------------------------------------------------------------
    4307                 :          0 : ::comphelper::StringSequence SAL_CALL FmXListBoxCell::getSelectedItems() throw( RuntimeException )
    4308                 :            : {
    4309         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4310                 :            : 
    4311         [ #  # ]:          0 :     ::comphelper::StringSequence aSeq;
    4312                 :            : 
    4313         [ #  # ]:          0 :     if (m_pBox)
    4314                 :            :     {
    4315         [ #  # ]:          0 :         UpdateFromColumn();
    4316         [ #  # ]:          0 :         sal_uInt16 nSelEntries = m_pBox->GetSelectEntryCount();
    4317 [ #  # ][ #  # ]:          0 :         aSeq = ::comphelper::StringSequence( nSelEntries );
                 [ #  # ]
    4318         [ #  # ]:          0 :         for ( sal_uInt16 n = 0; n < nSelEntries; n++ )
    4319 [ #  # ][ #  # ]:          0 :             aSeq.getArray()[n] = m_pBox->GetSelectEntry( n );
         [ #  # ][ #  # ]
    4320                 :            :     }
    4321         [ #  # ]:          0 :     return aSeq;
    4322                 :            : }
    4323                 :            : 
    4324                 :            : //------------------------------------------------------------------
    4325                 :          0 : void SAL_CALL FmXListBoxCell::selectItemPos(sal_Int16 nPos, sal_Bool bSelect) throw( RuntimeException )
    4326                 :            : {
    4327         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4328                 :            : 
    4329         [ #  # ]:          0 :     if (m_pBox)
    4330 [ #  # ][ #  # ]:          0 :         m_pBox->SelectEntryPos( nPos, bSelect );
    4331                 :          0 : }
    4332                 :            : 
    4333                 :            : //------------------------------------------------------------------
    4334                 :          0 : void SAL_CALL FmXListBoxCell::selectItemsPos(const Sequence< sal_Int16 >& aPositions, sal_Bool bSelect) throw( RuntimeException )
    4335                 :            : {
    4336         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4337                 :            : 
    4338         [ #  # ]:          0 :     if (m_pBox)
    4339                 :            :     {
    4340         [ #  # ]:          0 :         for ( sal_uInt16 n = (sal_uInt16)aPositions.getLength(); n; )
    4341         [ #  # ]:          0 :             m_pBox->SelectEntryPos( (sal_uInt16) aPositions.getConstArray()[--n], bSelect );
    4342         [ #  # ]:          0 :     }
    4343                 :          0 : }
    4344                 :            : 
    4345                 :            : //------------------------------------------------------------------
    4346                 :          0 : void SAL_CALL FmXListBoxCell::selectItem(const ::rtl::OUString& aItem, sal_Bool bSelect) throw( RuntimeException )
    4347                 :            : {
    4348         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4349                 :            : 
    4350         [ #  # ]:          0 :     if (m_pBox)
    4351 [ #  # ][ #  # ]:          0 :         m_pBox->SelectEntry( aItem, bSelect );
         [ #  # ][ #  # ]
    4352                 :          0 : }
    4353                 :            : 
    4354                 :            : //------------------------------------------------------------------
    4355                 :          0 : sal_Bool SAL_CALL FmXListBoxCell::isMutipleMode() throw( RuntimeException )
    4356                 :            : {
    4357         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4358                 :            : 
    4359                 :          0 :     sal_Bool bMulti = sal_False;
    4360         [ #  # ]:          0 :     if (m_pBox)
    4361         [ #  # ]:          0 :         bMulti = m_pBox->IsMultiSelectionEnabled();
    4362         [ #  # ]:          0 :     return bMulti;
    4363                 :            : }
    4364                 :            : 
    4365                 :            : //------------------------------------------------------------------
    4366                 :          0 : void SAL_CALL FmXListBoxCell::setMultipleMode(sal_Bool bMulti) throw( RuntimeException )
    4367                 :            : {
    4368         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4369                 :            : 
    4370         [ #  # ]:          0 :     if (m_pBox)
    4371 [ #  # ][ #  # ]:          0 :         m_pBox->EnableMultiSelection( bMulti );
    4372                 :          0 : }
    4373                 :            : 
    4374                 :            : //------------------------------------------------------------------
    4375                 :          0 : sal_Int16 SAL_CALL FmXListBoxCell::getDropDownLineCount() throw( RuntimeException )
    4376                 :            : {
    4377         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4378                 :            : 
    4379                 :          0 :     sal_Int16 nLines = 0;
    4380         [ #  # ]:          0 :     if (m_pBox)
    4381         [ #  # ]:          0 :         nLines = m_pBox->GetDropDownLineCount();
    4382                 :            : 
    4383         [ #  # ]:          0 :     return nLines;
    4384                 :            : }
    4385                 :            : 
    4386                 :            : //------------------------------------------------------------------
    4387                 :          0 : void SAL_CALL FmXListBoxCell::setDropDownLineCount(sal_Int16 nLines) throw( RuntimeException )
    4388                 :            : {
    4389         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4390                 :            : 
    4391         [ #  # ]:          0 :     if (m_pBox)
    4392 [ #  # ][ #  # ]:          0 :         m_pBox->SetDropDownLineCount( nLines );
    4393                 :          0 : }
    4394                 :            : 
    4395                 :            : //------------------------------------------------------------------
    4396                 :          0 : void SAL_CALL FmXListBoxCell::makeVisible(sal_Int16 nEntry) throw( RuntimeException )
    4397                 :            : {
    4398         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4399                 :            : 
    4400         [ #  # ]:          0 :     if (m_pBox)
    4401 [ #  # ][ #  # ]:          0 :         m_pBox->SetTopEntry( nEntry );
    4402                 :          0 : }
    4403                 :            : 
    4404                 :            : //------------------------------------------------------------------
    4405                 :          0 : void FmXListBoxCell::onWindowEvent( const sal_uIntPtr _nEventId, const Window& _rWindow, const void* _pEventData )
    4406                 :            : {
    4407 [ #  # ][ #  # ]:          0 :     if  (   ( &_rWindow == m_pBox )
    4408                 :            :         &&  ( _nEventId == VCLEVENT_LISTBOX_SELECT )
    4409                 :            :         )
    4410                 :            :     {
    4411         [ #  # ]:          0 :         OnDoubleClick( NULL );
    4412                 :            : 
    4413         [ #  # ]:          0 :         ::com::sun::star::awt::ItemEvent aEvent;
    4414 [ #  # ][ #  # ]:          0 :         aEvent.Source = *this;
    4415                 :          0 :         aEvent.Highlighted = sal_False;
    4416                 :            : 
    4417                 :            :         // Bei Mehrfachselektion 0xFFFF, sonst die ID
    4418         [ #  # ]:          0 :         aEvent.Selected = (m_pBox->GetSelectEntryCount() == 1 )
    4419 [ #  # ][ #  # ]:          0 :             ? m_pBox->GetSelectEntryPos() : 0xFFFF;
    4420                 :            : 
    4421         [ #  # ]:          0 :         m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
    4422         [ #  # ]:          0 :         return;
    4423                 :            :     }
    4424                 :            : 
    4425                 :          0 :     FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
    4426                 :            : }
    4427                 :            : 
    4428                 :            : 
    4429                 :            : //------------------------------------------------------------------
    4430                 :          0 : IMPL_LINK_NOARG(FmXListBoxCell, OnDoubleClick)
    4431                 :            : {
    4432         [ #  # ]:          0 :     if (m_pBox)
    4433                 :            :     {
    4434         [ #  # ]:          0 :         ::cppu::OInterfaceIteratorHelper aIt( m_aActionListeners );
    4435                 :            : 
    4436         [ #  # ]:          0 :         ::com::sun::star::awt::ActionEvent aEvent;
    4437 [ #  # ][ #  # ]:          0 :         aEvent.Source = *this;
    4438 [ #  # ][ #  # ]:          0 :         aEvent.ActionCommand = m_pBox->GetSelectEntry();
                 [ #  # ]
    4439                 :            : 
    4440         [ #  # ]:          0 :         while( aIt.hasMoreElements() )
    4441 [ #  # ][ #  # ]:          0 :             ((::com::sun::star::awt::XActionListener *)aIt.next())->actionPerformed( aEvent );
         [ #  # ][ #  # ]
    4442                 :            :     }
    4443                 :          0 :     return 1;
    4444                 :            : }
    4445                 :            : 
    4446                 :            : 
    4447                 :            : /*************************************************************************/
    4448                 :            : 
    4449                 :            : DBG_NAME( FmXComboBoxCell );
    4450                 :            : 
    4451                 :            : //------------------------------------------------------------------------------
    4452                 :          0 : FmXComboBoxCell::FmXComboBoxCell( DbGridColumn* pColumn, DbCellControl& _rControl )
    4453                 :            :     :FmXTextCell( pColumn, _rControl )
    4454                 :            :     ,m_aItemListeners( m_aMutex )
    4455                 :            :     ,m_aActionListeners( m_aMutex )
    4456 [ #  # ][ #  # ]:          0 :     ,m_pComboBox( &static_cast< ComboBox& >( _rControl.GetWindow() ) )
                 [ #  # ]
    4457                 :            : {
    4458                 :            :     DBG_CTOR( FmXComboBoxCell, NULL );
    4459                 :          0 : }
    4460                 :            : 
    4461                 :            : //------------------------------------------------------------------------------
    4462 [ #  # ][ #  # ]:          0 : FmXComboBoxCell::~FmXComboBoxCell()
    4463                 :            : {
    4464         [ #  # ]:          0 :     if ( !OComponentHelper::rBHelper.bDisposed )
    4465                 :            :     {
    4466                 :          0 :         acquire();
    4467         [ #  # ]:          0 :         dispose();
    4468                 :            :     }
    4469                 :            : 
    4470                 :            :     DBG_DTOR( FmXComboBoxCell, NULL );
    4471         [ #  # ]:          0 : }
    4472                 :            : 
    4473                 :            : //-----------------------------------------------------------------------------
    4474                 :          0 : void FmXComboBoxCell::disposing()
    4475                 :            : {
    4476 [ #  # ][ #  # ]:          0 :     ::com::sun::star::lang::EventObject aEvt(*this);
    4477         [ #  # ]:          0 :     m_aItemListeners.disposeAndClear(aEvt);
    4478         [ #  # ]:          0 :     m_aActionListeners.disposeAndClear(aEvt);
    4479                 :            : 
    4480 [ #  # ][ #  # ]:          0 :     FmXTextCell::disposing();
    4481                 :          0 : }
    4482                 :            : 
    4483                 :            : //------------------------------------------------------------------
    4484                 :          0 : Any SAL_CALL FmXComboBoxCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    4485                 :            : {
    4486                 :          0 :     Any aReturn = FmXTextCell::queryAggregation(_rType);
    4487                 :            : 
    4488         [ #  # ]:          0 :     if ( !aReturn.hasValue() )
    4489         [ #  # ]:          0 :         aReturn = FmXComboBoxCell_Base::queryInterface( _rType );
    4490                 :            : 
    4491                 :          0 :     return aReturn;
    4492                 :            : }
    4493                 :            : 
    4494                 :            : //-------------------------------------------------------------------------
    4495                 :          0 : Sequence< Type > SAL_CALL FmXComboBoxCell::getTypes(  ) throw(RuntimeException)
    4496                 :            : {
    4497                 :            :     return ::comphelper::concatSequences(
    4498                 :            :         FmXTextCell::getTypes(),
    4499                 :            :         FmXComboBoxCell_Base::getTypes()
    4500 [ #  # ][ #  # ]:          0 :     );
                 [ #  # ]
    4501                 :            : }
    4502                 :            : 
    4503                 :            : //------------------------------------------------------------------------------
    4504                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXComboBoxCell )
    4505                 :            : 
    4506                 :            : //------------------------------------------------------------------
    4507                 :          0 : void SAL_CALL FmXComboBoxCell::addItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException )
    4508                 :            : {
    4509                 :          0 :     m_aItemListeners.addInterface( l );
    4510                 :          0 : }
    4511                 :            : 
    4512                 :            : //------------------------------------------------------------------
    4513                 :          0 : void SAL_CALL FmXComboBoxCell::removeItemListener(const Reference< awt::XItemListener >& l) throw( RuntimeException )
    4514                 :            : {
    4515                 :          0 :     m_aItemListeners.removeInterface( l );
    4516                 :          0 : }
    4517                 :            : 
    4518                 :            : //------------------------------------------------------------------
    4519                 :          0 : void SAL_CALL FmXComboBoxCell::addActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException )
    4520                 :            : {
    4521                 :          0 :     m_aActionListeners.addInterface( l );
    4522                 :          0 : }
    4523                 :            : 
    4524                 :            : //------------------------------------------------------------------
    4525                 :          0 : void SAL_CALL FmXComboBoxCell::removeActionListener(const Reference< awt::XActionListener >& l) throw( RuntimeException )
    4526                 :            : {
    4527                 :          0 :     m_aActionListeners.removeInterface( l );
    4528                 :          0 : }
    4529                 :            : 
    4530                 :            : //------------------------------------------------------------------
    4531                 :          0 : void SAL_CALL FmXComboBoxCell::addItem( const ::rtl::OUString& _Item, sal_Int16 _Pos ) throw( RuntimeException )
    4532                 :            : {
    4533         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4534         [ #  # ]:          0 :     if ( m_pComboBox )
    4535 [ #  # ][ #  # ]:          0 :         m_pComboBox->InsertEntry( _Item, _Pos );
         [ #  # ][ #  # ]
    4536                 :          0 : }
    4537                 :            : 
    4538                 :            : //------------------------------------------------------------------
    4539                 :          0 : void SAL_CALL FmXComboBoxCell::addItems( const Sequence< ::rtl::OUString >& _Items, sal_Int16 _Pos ) throw( RuntimeException )
    4540                 :            : {
    4541         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4542         [ #  # ]:          0 :     if ( m_pComboBox )
    4543                 :            :     {
    4544                 :          0 :         sal_uInt16 nP = _Pos;
    4545         [ #  # ]:          0 :         for ( sal_uInt16 n = 0; n < _Items.getLength(); n++ )
    4546                 :            :         {
    4547 [ #  # ][ #  # ]:          0 :             m_pComboBox->InsertEntry( _Items.getConstArray()[n], nP );
                 [ #  # ]
    4548         [ #  # ]:          0 :             if ( _Pos != -1 )
    4549                 :          0 :                 nP++;
    4550                 :            :         }
    4551         [ #  # ]:          0 :     }
    4552                 :          0 : }
    4553                 :            : 
    4554                 :            : //------------------------------------------------------------------
    4555                 :          0 : void SAL_CALL FmXComboBoxCell::removeItems( sal_Int16 _Pos, sal_Int16 _Count ) throw( RuntimeException )
    4556                 :            : {
    4557         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4558         [ #  # ]:          0 :     if ( m_pComboBox )
    4559                 :            :     {
    4560         [ #  # ]:          0 :         for ( sal_uInt16 n = _Count; n; )
    4561         [ #  # ]:          0 :             m_pComboBox->RemoveEntry( _Pos + (--n) );
    4562         [ #  # ]:          0 :     }
    4563                 :          0 : }
    4564                 :            : 
    4565                 :            : //------------------------------------------------------------------
    4566                 :          0 : sal_Int16 SAL_CALL FmXComboBoxCell::getItemCount() throw( RuntimeException )
    4567                 :            : {
    4568         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4569 [ #  # ][ #  # ]:          0 :     return m_pComboBox ? m_pComboBox->GetEntryCount() : 0;
                 [ #  # ]
    4570                 :            : }
    4571                 :            : 
    4572                 :            : //------------------------------------------------------------------
    4573                 :          0 : ::rtl::OUString SAL_CALL FmXComboBoxCell::getItem( sal_Int16 _Pos ) throw( RuntimeException )
    4574                 :            : {
    4575         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4576         [ #  # ]:          0 :     String sItem;
    4577         [ #  # ]:          0 :     if ( m_pComboBox )
    4578 [ #  # ][ #  # ]:          0 :         sItem = m_pComboBox->GetEntry( _Pos );
                 [ #  # ]
    4579 [ #  # ][ #  # ]:          0 :     return sItem;
                 [ #  # ]
    4580                 :            : }
    4581                 :            : //------------------------------------------------------------------
    4582                 :          0 : Sequence< ::rtl::OUString > SAL_CALL FmXComboBoxCell::getItems() throw( RuntimeException )
    4583                 :            : {
    4584         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4585                 :            : 
    4586         [ #  # ]:          0 :     Sequence< ::rtl::OUString > aItems;
    4587         [ #  # ]:          0 :     if ( m_pComboBox )
    4588                 :            :     {
    4589         [ #  # ]:          0 :         sal_uInt16 nEntries = m_pComboBox->GetEntryCount();
    4590         [ #  # ]:          0 :         aItems.realloc( nEntries );
    4591         [ #  # ]:          0 :         ::rtl::OUString* pItem = aItems.getArray();
    4592         [ #  # ]:          0 :         for ( sal_uInt16 n=0; n<nEntries; ++n, ++pItem )
    4593 [ #  # ][ #  # ]:          0 :             *pItem = m_pComboBox->GetEntry( n );
                 [ #  # ]
    4594                 :            :     }
    4595         [ #  # ]:          0 :     return aItems;
    4596                 :            : }
    4597                 :            : 
    4598                 :            : //------------------------------------------------------------------
    4599                 :          0 : sal_Int16 SAL_CALL FmXComboBoxCell::getDropDownLineCount() throw( RuntimeException )
    4600                 :            : {
    4601         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4602                 :            : 
    4603                 :          0 :     sal_Int16 nLines = 0;
    4604         [ #  # ]:          0 :     if ( m_pComboBox )
    4605         [ #  # ]:          0 :         nLines = m_pComboBox->GetDropDownLineCount();
    4606                 :            : 
    4607         [ #  # ]:          0 :     return nLines;
    4608                 :            : }
    4609                 :            : 
    4610                 :            : //------------------------------------------------------------------
    4611                 :          0 : void SAL_CALL FmXComboBoxCell::setDropDownLineCount(sal_Int16 nLines) throw( RuntimeException )
    4612                 :            : {
    4613         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4614         [ #  # ]:          0 :     if ( m_pComboBox )
    4615 [ #  # ][ #  # ]:          0 :         m_pComboBox->SetDropDownLineCount( nLines );
    4616                 :          0 : }
    4617                 :            : 
    4618                 :            : //------------------------------------------------------------------------------
    4619                 :          0 : void FmXComboBoxCell::onWindowEvent( const sal_uIntPtr _nEventId, const Window& _rWindow, const void* _pEventData )
    4620                 :            : {
    4621                 :            : 
    4622         [ #  # ]:          0 :     switch ( _nEventId )
    4623                 :            :     {
    4624                 :            :     case VCLEVENT_COMBOBOX_SELECT:
    4625                 :            :     {
    4626         [ #  # ]:          0 :         awt::ItemEvent aEvent;
    4627 [ #  # ][ #  # ]:          0 :         aEvent.Source = *this;
    4628                 :          0 :         aEvent.Highlighted = sal_False;
    4629                 :            : 
    4630                 :            :         // Bei Mehrfachselektion 0xFFFF, sonst die ID
    4631         [ #  # ]:          0 :         aEvent.Selected =   ( m_pComboBox->GetSelectEntryCount() == 1 )
    4632         [ #  # ]:          0 :                         ?   m_pComboBox->GetSelectEntryPos()
    4633         [ #  # ]:          0 :                         :   0xFFFF;
    4634 [ #  # ][ #  # ]:          0 :         m_aItemListeners.notifyEach( &awt::XItemListener::itemStateChanged, aEvent );
    4635                 :            :     }
    4636                 :          0 :     break;
    4637                 :            : 
    4638                 :            :     default:
    4639                 :          0 :         FmXTextCell::onWindowEvent( _nEventId, _rWindow, _pEventData );
    4640                 :          0 :         break;
    4641                 :            :     }
    4642                 :          0 : }
    4643                 :            : 
    4644                 :            : /*************************************************************************/
    4645 [ #  # ][ #  # ]:          0 : TYPEINIT1(FmXFilterCell, FmXGridCell);
    4646                 :            : 
    4647                 :            : //------------------------------------------------------------------------------
    4648                 :          0 : Reference< XInterface >  FmXFilterCell_CreateInstance(const Reference< ::com::sun::star::lang::XMultiServiceFactory >& /*_rxFactory*/)
    4649                 :            : {
    4650         [ #  # ]:          0 :     return *new FmXFilterCell();
    4651                 :            : }
    4652                 :            : 
    4653                 :            : DBG_NAME(FmXFilterCell);
    4654                 :            : //------------------------------------------------------------------------------
    4655                 :          0 : FmXFilterCell::FmXFilterCell(DbGridColumn* pColumn, DbCellControl* pControl )
    4656                 :            :               :FmXGridCell( pColumn, pControl )
    4657         [ #  # ]:          0 :               ,m_aTextListeners(m_aMutex)
    4658                 :            : {
    4659                 :            :     DBG_CTOR(FmXFilterCell,NULL);
    4660                 :            : 
    4661                 :            :     DBG_ASSERT( m_pCellControl->ISA( DbFilterField ), "FmXFilterCell::FmXFilterCell: invalid cell control!" );
    4662         [ #  # ]:          0 :     static_cast< DbFilterField* >( m_pCellControl )->SetCommitHdl( LINK( this, FmXFilterCell, OnCommit ) );
    4663                 :          0 : }
    4664                 :            : 
    4665                 :            : //------------------------------------------------------------------
    4666         [ #  # ]:          0 : FmXFilterCell::~FmXFilterCell()
    4667                 :            : {
    4668         [ #  # ]:          0 :     if (!OComponentHelper::rBHelper.bDisposed)
    4669                 :            :     {
    4670                 :          0 :         acquire();
    4671         [ #  # ]:          0 :         dispose();
    4672                 :            :     }
    4673                 :            : 
    4674                 :            :     DBG_DTOR(FmXFilterCell,NULL);
    4675         [ #  # ]:          0 : }
    4676                 :            : 
    4677                 :            : // XUnoTunnel
    4678                 :            : //------------------------------------------------------------------------------
    4679                 :          0 : sal_Int64 SAL_CALL FmXFilterCell::getSomething( const Sequence< sal_Int8 >& _rIdentifier ) throw(RuntimeException)
    4680                 :            : {
    4681                 :          0 :     sal_Int64 nReturn(0);
    4682                 :            : 
    4683   [ #  #  #  # ]:          0 :     if  (   (_rIdentifier.getLength() == 16)
                 [ #  # ]
    4684                 :          0 :         &&  (0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), _rIdentifier.getConstArray(), 16 ))
    4685                 :            :         )
    4686                 :            :     {
    4687                 :          0 :         nReturn = reinterpret_cast<sal_Int64>(this);
    4688                 :            :     }
    4689                 :            : 
    4690                 :          0 :     return nReturn;
    4691                 :            : }
    4692                 :            : 
    4693                 :            : namespace
    4694                 :            : {
    4695                 :            :     class theFmXFilterCellUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theFmXFilterCellUnoTunnelId > {};
    4696                 :            : }
    4697                 :            : 
    4698                 :          0 : const Sequence<sal_Int8>& FmXFilterCell::getUnoTunnelId()
    4699                 :            : {
    4700                 :          0 :     return theFmXFilterCellUnoTunnelId::get().getSeq();
    4701                 :            : }
    4702                 :            : 
    4703                 :            : //------------------------------------------------------------------------------
    4704                 :          0 : void FmXFilterCell::PaintCell( OutputDevice& rDev, const Rectangle& rRect )
    4705                 :            : {
    4706                 :          0 :     static_cast< DbFilterField* >( m_pCellControl )->PaintCell( rDev, rRect );
    4707                 :          0 : }
    4708                 :            : 
    4709                 :            : // OComponentHelper
    4710                 :            : //-----------------------------------------------------------------------------
    4711                 :          0 : void FmXFilterCell::disposing()
    4712                 :            : {
    4713 [ #  # ][ #  # ]:          0 :     ::com::sun::star::lang::EventObject aEvt(*this);
    4714         [ #  # ]:          0 :     m_aTextListeners.disposeAndClear(aEvt);
    4715                 :            : 
    4716         [ #  # ]:          0 :     ((DbFilterField*)m_pCellControl)->SetCommitHdl(Link());
    4717                 :            : 
    4718 [ #  # ][ #  # ]:          0 :     FmXGridCell::disposing();
    4719                 :          0 : }
    4720                 :            : 
    4721                 :            : //------------------------------------------------------------------
    4722                 :          0 : Any SAL_CALL FmXFilterCell::queryAggregation( const ::com::sun::star::uno::Type& _rType ) throw(RuntimeException)
    4723                 :            : {
    4724                 :          0 :     Any aReturn = FmXGridCell::queryAggregation(_rType);
    4725                 :            : 
    4726         [ #  # ]:          0 :     if ( !aReturn.hasValue() )
    4727         [ #  # ]:          0 :         aReturn = FmXFilterCell_Base::queryInterface( _rType );
    4728                 :            : 
    4729                 :          0 :     return aReturn;
    4730                 :            : }
    4731                 :            : 
    4732                 :            : //-------------------------------------------------------------------------
    4733                 :          0 : Sequence< ::com::sun::star::uno::Type > SAL_CALL FmXFilterCell::getTypes(  ) throw(RuntimeException)
    4734                 :            : {
    4735                 :            :     return ::comphelper::concatSequences(
    4736                 :            :         FmXGridCell::getTypes(),
    4737                 :            :         FmXFilterCell_Base::getTypes()
    4738 [ #  # ][ #  # ]:          0 :     );
                 [ #  # ]
    4739                 :            : }
    4740                 :            : 
    4741                 :            : //------------------------------------------------------------------------------
    4742                 :          0 : IMPLEMENT_GET_IMPLEMENTATION_ID( FmXFilterCell )
    4743                 :            : 
    4744                 :            : // ::com::sun::star::awt::XTextComponent
    4745                 :            : //------------------------------------------------------------------------------
    4746                 :          0 : void SAL_CALL FmXFilterCell::addTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
    4747                 :            : {
    4748                 :          0 :     m_aTextListeners.addInterface( l );
    4749                 :          0 : }
    4750                 :            : 
    4751                 :            : //------------------------------------------------------------------------------
    4752                 :          0 : void SAL_CALL FmXFilterCell::removeTextListener(const Reference< ::com::sun::star::awt::XTextListener >& l) throw( RuntimeException )
    4753                 :            : {
    4754                 :          0 :     m_aTextListeners.removeInterface( l );
    4755                 :          0 : }
    4756                 :            : 
    4757                 :            : //------------------------------------------------------------------------------
    4758                 :          0 : void SAL_CALL FmXFilterCell::setText( const ::rtl::OUString& aText ) throw( RuntimeException )
    4759                 :            : {
    4760         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4761 [ #  # ][ #  # ]:          0 :     ((DbFilterField*)m_pCellControl)->SetText(aText);
         [ #  # ][ #  # ]
    4762                 :          0 : }
    4763                 :            : 
    4764                 :            : //------------------------------------------------------------------------------
    4765                 :          0 : void SAL_CALL FmXFilterCell::insertText( const ::com::sun::star::awt::Selection& /*rSel*/, const ::rtl::OUString& /*aText*/ ) throw( RuntimeException )
    4766                 :            : {
    4767                 :          0 : }
    4768                 :            : 
    4769                 :            : //------------------------------------------------------------------------------
    4770                 :          0 : ::rtl::OUString SAL_CALL FmXFilterCell::getText() throw( RuntimeException )
    4771                 :            : {
    4772         [ #  # ]:          0 :     ::osl::MutexGuard aGuard( m_aMutex );
    4773 [ #  # ][ #  # ]:          0 :     return ((DbFilterField*)m_pCellControl)->GetText();
    4774                 :            : }
    4775                 :            : 
    4776                 :            : //------------------------------------------------------------------------------
    4777                 :          0 : ::rtl::OUString SAL_CALL FmXFilterCell::getSelectedText( void ) throw( RuntimeException )
    4778                 :            : {
    4779                 :          0 :     return getText();
    4780                 :            : }
    4781                 :            : 
    4782                 :            : //------------------------------------------------------------------------------
    4783                 :          0 : void SAL_CALL FmXFilterCell::setSelection( const ::com::sun::star::awt::Selection& /*aSelection*/ ) throw( RuntimeException )
    4784                 :            : {
    4785                 :          0 : }
    4786                 :            : 
    4787                 :            : //------------------------------------------------------------------------------
    4788                 :          0 : ::com::sun::star::awt::Selection SAL_CALL FmXFilterCell::getSelection( void ) throw( RuntimeException )
    4789                 :            : {
    4790                 :          0 :     return ::com::sun::star::awt::Selection();
    4791                 :            : }
    4792                 :            : 
    4793                 :            : //------------------------------------------------------------------------------
    4794                 :          0 : sal_Bool SAL_CALL FmXFilterCell::isEditable( void ) throw( RuntimeException )
    4795                 :            : {
    4796                 :          0 :     return sal_True;
    4797                 :            : }
    4798                 :            : 
    4799                 :            : //------------------------------------------------------------------------------
    4800                 :          0 : void SAL_CALL FmXFilterCell::setEditable( sal_Bool /*bEditable*/ ) throw( RuntimeException )
    4801                 :            : {
    4802                 :          0 : }
    4803                 :            : 
    4804                 :            : //------------------------------------------------------------------------------
    4805                 :          0 : sal_Int16 SAL_CALL FmXFilterCell::getMaxTextLen() throw( RuntimeException )
    4806                 :            : {
    4807                 :          0 :     return 0;
    4808                 :            : }
    4809                 :            : 
    4810                 :            : //------------------------------------------------------------------------------
    4811                 :          0 : void SAL_CALL FmXFilterCell::setMaxTextLen( sal_Int16 /*nLen*/ ) throw( RuntimeException )
    4812                 :            : {
    4813                 :          0 : }
    4814                 :            : 
    4815                 :            : //------------------------------------------------------------------------------
    4816                 :          0 : IMPL_LINK_NOARG(FmXFilterCell, OnCommit)
    4817                 :            : {
    4818         [ #  # ]:          0 :     ::cppu::OInterfaceIteratorHelper aIt( m_aTextListeners );
    4819         [ #  # ]:          0 :     ::com::sun::star::awt::TextEvent aEvt;
    4820 [ #  # ][ #  # ]:          0 :     aEvt.Source = *this;
    4821         [ #  # ]:          0 :     while( aIt.hasMoreElements() )
    4822 [ #  # ][ #  # ]:          0 :         ((::com::sun::star::awt::XTextListener *)aIt.next())->textChanged( aEvt );
    4823 [ #  # ][ #  # ]:          0 :     return 1;
    4824 [ +  - ][ +  - ]:        450 : }
    4825                 :            : 
    4826                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10