LCOV - code coverage report
Current view: top level - svx/source/fmcomp - fmgridcl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 111 1010 11.0 %
Date: 2012-08-25 Functions: 12 51 23.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 124 2539 4.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                 :            : #include "svx/fmgridif.hxx"
      30                 :            : #include "fmitems.hxx"
      31                 :            : #include "fmprop.hrc"
      32                 :            : #include "svx/fmtools.hxx"
      33                 :            : #include "svx/fmresids.hrc"
      34                 :            : #include "fmservs.hxx"
      35                 :            : #include "fmurl.hxx"
      36                 :            : #include "formcontrolfactory.hxx"
      37                 :            : #include "gridcell.hxx"
      38                 :            : #include "gridcols.hxx"
      39                 :            : #include "svx/dbaexchange.hxx"
      40                 :            : #include "svx/dialmgr.hxx"
      41                 :            : #include "svx/dialogs.hrc"
      42                 :            : #include "svx/fmgridcl.hxx"
      43                 :            : #include "svx/svxdlg.hxx"
      44                 :            : #include "svx/svxids.hrc"
      45                 :            : #include "trace.hxx"
      46                 :            : 
      47                 :            : #include <com/sun/star/form/XConfirmDeleteListener.hpp>
      48                 :            : #include <com/sun/star/form/XFormComponent.hpp>
      49                 :            : #include <com/sun/star/form/XGridColumnFactory.hpp>
      50                 :            : #include <com/sun/star/io/XPersistObject.hpp>
      51                 :            : #include <com/sun/star/sdb/CommandType.hpp>
      52                 :            : #include <com/sun/star/sdb/RowChangeAction.hpp>
      53                 :            : #include <com/sun/star/sdb/XQueriesSupplier.hpp>
      54                 :            : #include <com/sun/star/sdbc/DataType.hpp>
      55                 :            : #include <com/sun/star/sdbc/XPreparedStatement.hpp>
      56                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      57                 :            : #include <com/sun/star/sdbcx/XDeleteRows.hpp>
      58                 :            : #include <com/sun/star/sdbcx/XTablesSupplier.hpp>
      59                 :            : #include <com/sun/star/uno/XNamingService.hpp>
      60                 :            : #include <com/sun/star/util/XNumberFormats.hpp>
      61                 :            : #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
      62                 :            : #include <com/sun/star/util/URLTransformer.hpp>
      63                 :            : #include <com/sun/star/util/XURLTransformer.hpp>
      64                 :            : #include <com/sun/star/view/XSelectionSupplier.hpp>
      65                 :            : #include <comphelper/extract.hxx>
      66                 :            : #include <comphelper/numbers.hxx>
      67                 :            : #include <comphelper/processfactory.hxx>
      68                 :            : #include <comphelper/property.hxx>
      69                 :            : #include <comphelper/string.hxx>
      70                 :            : #include <connectivity/dbtools.hxx>
      71                 :            : #include <sfx2/dispatch.hxx>
      72                 :            : #include <sfx2/viewfrm.hxx>
      73                 :            : #include <svl/eitem.hxx>
      74                 :            : #include <svtools/fmtfield.hxx>
      75                 :            : #include <svl/numuno.hxx>
      76                 :            : #include <tools/multisel.hxx>
      77                 :            : #include <tools/shl.hxx>
      78                 :            : #include <tools/diagnose_ex.h>
      79                 :            : #include <vcl/help.hxx>
      80                 :            : #include <vcl/image.hxx>
      81                 :            : #include <vcl/longcurr.hxx>
      82                 :            : #include <vcl/menu.hxx>
      83                 :            : 
      84                 :            : #include <math.h>
      85                 :            : 
      86                 :            : using namespace ::com::sun::star::uno;
      87                 :            : using namespace ::com::sun::star::view;
      88                 :            : using namespace ::com::sun::star::beans;
      89                 :            : using namespace ::com::sun::star::lang;
      90                 :            : using namespace ::com::sun::star::sdbcx;
      91                 :            : using namespace ::com::sun::star::sdbc;
      92                 :            : using namespace ::com::sun::star::sdb;
      93                 :            : using namespace ::com::sun::star::form;
      94                 :            : using namespace ::com::sun::star::util;
      95                 :            : using namespace ::com::sun::star::container;
      96                 :            : using namespace ::cppu;
      97                 :            : using namespace ::svxform;
      98                 :            : using namespace ::svx;
      99                 :            : 
     100                 :            : //==============================================================================
     101                 :            : //------------------------------------------------------------------------------
     102                 :          0 : ::rtl::OUString FieldServiceFromId(sal_Int32 nID)
     103                 :            : {
     104   [ #  #  #  #  :          0 :     switch (nID)
          #  #  #  #  #  
                   #  # ]
     105                 :            :     {
     106                 :          0 :         case SID_FM_EDIT            : return FM_COL_TEXTFIELD;
     107                 :          0 :         case SID_FM_COMBOBOX        : return FM_COL_COMBOBOX;
     108                 :          0 :         case SID_FM_LISTBOX         : return FM_COL_LISTBOX;
     109                 :          0 :         case SID_FM_CHECKBOX        : return FM_COL_CHECKBOX;
     110                 :          0 :         case SID_FM_DATEFIELD       : return FM_COL_DATEFIELD;
     111                 :          0 :         case SID_FM_TIMEFIELD       : return FM_COL_TIMEFIELD;
     112                 :          0 :         case SID_FM_NUMERICFIELD    : return FM_COL_NUMERICFIELD;
     113                 :          0 :         case SID_FM_CURRENCYFIELD   : return FM_COL_CURRENCYFIELD;
     114                 :          0 :         case SID_FM_PATTERNFIELD    : return FM_COL_PATTERNFIELD;
     115                 :          0 :         case SID_FM_FORMATTEDFIELD  : return FM_COL_FORMATTEDFIELD;
     116                 :            :     }
     117                 :          0 :     return ::rtl::OUString();
     118                 :            : }
     119                 :            : 
     120                 :            : //==============================================================================
     121                 :         80 : struct FmGridHeaderData
     122                 :            : {
     123                 :            :     ODataAccessDescriptor   aDropData;
     124                 :            :     Point                   aDropPosPixel;
     125                 :            :     sal_Int8                nDropAction;
     126                 :            :     Reference< XInterface > xDroppedStatement;
     127                 :            :     Reference< XInterface > xDroppedResultSet;
     128                 :            : };
     129                 :            : 
     130                 :            : //==============================================================================
     131                 :            : //------------------------------------------------------------------------------
     132                 :            : const sal_Int16 nChangeTypeOffset = 1000;
     133                 :          0 : void SetMenuItem(const ImageList& rList, sal_uInt16 nID, Menu* pMenu, Menu& rNewMenu, sal_Bool bDesignMode = sal_True, sal_Int16 nOffset = nChangeTypeOffset)
     134                 :            : {
     135         [ #  # ]:          0 :     pMenu->SetItemImage(nID, rList.GetImage(nID));
     136                 :          0 :     pMenu->EnableItem(nID, bDesignMode);
     137         [ #  # ]:          0 :     rNewMenu.InsertItem(nID + nOffset, pMenu->GetItemText(nID));
     138         [ #  # ]:          0 :     rNewMenu.SetItemImage(nID + nOffset, rList.GetImage(nID));
     139         [ #  # ]:          0 :     rNewMenu.SetHelpId(nID + nOffset, pMenu->GetHelpId(nID));
     140                 :          0 :     rNewMenu.EnableItem(nID + nOffset, bDesignMode);
     141                 :          0 : }
     142                 :            : 
     143                 :            : //------------------------------------------------------------------------------
     144                 :         40 : FmGridHeader::FmGridHeader( BrowseBox* pParent, WinBits nWinBits)
     145                 :            :         :EditBrowserHeader(pParent, nWinBits)
     146                 :            :         ,DropTargetHelper(this)
     147 [ +  - ][ +  - ]:         40 :         ,m_pImpl(new FmGridHeaderData)
                 [ +  - ]
     148                 :            : {
     149                 :         40 : }
     150                 :            : 
     151                 :            : //------------------------------------------------------------------------------
     152         [ +  - ]:         40 : FmGridHeader::~FmGridHeader()
     153                 :            : {
     154 [ +  - ][ +  - ]:         40 :     delete m_pImpl;
     155         [ -  + ]:         40 : }
     156                 :            : 
     157                 :            : //------------------------------------------------------------------------------
     158                 :          0 : sal_uInt16 FmGridHeader::GetModelColumnPos(sal_uInt16 nId) const
     159                 :            : {
     160                 :          0 :     return static_cast<FmGridControl*>(GetParent())->GetModelColumnPos(nId);
     161                 :            : }
     162                 :            : //---------------------------------------------------------------------------------------
     163                 :          0 : void FmGridHeader::notifyColumnSelect(sal_uInt16 nColumnId)
     164                 :            : {
     165         [ #  # ]:          0 :     sal_uInt16 nPos = GetModelColumnPos(nColumnId);
     166 [ #  # ][ #  # ]:          0 :     Reference< XIndexAccess >  xColumns(((FmGridControl*)GetParent())->GetPeer()->getColumns(), UNO_QUERY);
                 [ #  # ]
     167 [ #  # ][ #  # ]:          0 :     if ( nPos < xColumns->getCount() )
                 [ #  # ]
     168                 :            :     {
     169         [ #  # ]:          0 :         Reference< XSelectionSupplier >  xSelSupplier(xColumns, UNO_QUERY);
     170         [ #  # ]:          0 :         if ( xSelSupplier.is() )
     171                 :            :         {
     172                 :          0 :             Reference< XPropertySet >  xColumn;
     173 [ #  # ][ #  # ]:          0 :             xColumns->getByIndex(nPos) >>= xColumn;
                 [ #  # ]
     174 [ #  # ][ #  # ]:          0 :             xSelSupplier->select(makeAny(xColumn));
                 [ #  # ]
     175                 :          0 :         }
     176                 :          0 :     }
     177                 :          0 : }
     178                 :            : //------------------------------------------------------------------------------
     179                 :          0 : void FmGridHeader::Select()
     180                 :            : {
     181                 :          0 :     EditBrowserHeader::Select();
     182                 :          0 :     notifyColumnSelect(GetCurItemId());
     183                 :          0 : }
     184                 :            : 
     185                 :            : //------------------------------------------------------------------------------
     186                 :          0 : void FmGridHeader::RequestHelp( const HelpEvent& rHEvt )
     187                 :            : {
     188         [ #  # ]:          0 :     sal_uInt16 nItemId = GetItemId( ScreenToOutputPixel( rHEvt.GetMousePosPixel() ) );
     189         [ #  # ]:          0 :     if ( nItemId )
     190                 :            :     {
     191         [ #  # ]:          0 :         if ( rHEvt.GetMode() & (HELPMODE_QUICK | HELPMODE_BALLOON) )
     192                 :            :         {
     193         [ #  # ]:          0 :             Rectangle aItemRect = GetItemRect( nItemId );
     194         [ #  # ]:          0 :             Point aPt = OutputToScreenPixel( aItemRect.TopLeft() );
     195                 :          0 :             aItemRect.Left()   = aPt.X();
     196                 :          0 :             aItemRect.Top()    = aPt.Y();
     197 [ #  # ][ #  # ]:          0 :             aPt = OutputToScreenPixel( aItemRect.BottomRight() );
     198                 :          0 :             aItemRect.Right()  = aPt.X();
     199                 :          0 :             aItemRect.Bottom() = aPt.Y();
     200                 :            : 
     201         [ #  # ]:          0 :             sal_uInt16 nPos = GetModelColumnPos(nItemId);
     202 [ #  # ][ #  # ]:          0 :             Reference< ::com::sun::star::container::XIndexContainer >  xColumns(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     203                 :            :             try
     204                 :            :             {
     205 [ #  # ][ #  # ]:          0 :                 Reference< ::com::sun::star::beans::XPropertySet >  xColumn(xColumns->getByIndex(nPos),UNO_QUERY);
                 [ #  # ]
     206                 :          0 :                 ::rtl::OUString aHelpText;
     207 [ #  # ][ #  # ]:          0 :                 xColumn->getPropertyValue(FM_PROP_HELPTEXT) >>= aHelpText;
                 [ #  # ]
     208         [ #  # ]:          0 :                 if ( aHelpText.isEmpty() )
     209 [ #  # ][ #  # ]:          0 :                     xColumn->getPropertyValue(FM_PROP_DESCRIPTION) >>= aHelpText;
                 [ #  # ]
     210         [ #  # ]:          0 :                 if ( !aHelpText.isEmpty() )
     211                 :            :                 {
     212         [ #  # ]:          0 :                     if ( rHEvt.GetMode() & HELPMODE_BALLOON )
     213 [ #  # ][ #  # ]:          0 :                         Help::ShowBalloon( this, aItemRect.Center(), aItemRect, aHelpText );
         [ #  # ][ #  # ]
     214                 :            :                     else
     215 [ #  # ][ #  # ]:          0 :                         Help::ShowQuickHelp( this, aItemRect, aHelpText );
                 [ #  # ]
     216                 :            :                     return;
     217 [ #  # ][ #  # ]:          0 :                 }
                 [ #  # ]
     218                 :            :             }
     219         [ #  # ]:          0 :             catch(Exception&)
     220                 :            :             {
     221                 :            :                 return;
     222         [ #  # ]:          0 :             }
     223                 :            :         }
     224                 :            :     }
     225                 :          0 :     EditBrowserHeader::RequestHelp( rHEvt );
     226                 :            : }
     227                 :            : 
     228                 :            : //------------------------------------------------------------------------------
     229                 :          0 : sal_Int8 FmGridHeader::AcceptDrop( const AcceptDropEvent& rEvt )
     230                 :            : {
     231                 :            :     // drop allowed in design mode only
     232         [ #  # ]:          0 :     if (!static_cast<FmGridControl*>(GetParent())->IsDesignMode())
     233                 :          0 :         return DND_ACTION_NONE;
     234                 :            : 
     235                 :            :     // search for recognized formats
     236                 :          0 :     const DataFlavorExVector& rFlavors = GetDataFlavorExVector();
     237         [ #  # ]:          0 :     if (OColumnTransferable::canExtractColumnDescriptor(rFlavors, CTF_COLUMN_DESCRIPTOR | CTF_FIELD_DESCRIPTOR))
     238                 :          0 :         return rEvt.mnAction;
     239                 :            : 
     240                 :          0 :     return DND_ACTION_NONE;
     241                 :            : }
     242                 :            : 
     243                 :            : //------------------------------------------------------------------------------
     244                 :          0 : sal_Int8 FmGridHeader::ExecuteDrop( const ExecuteDropEvent& _rEvt )
     245                 :            : {
     246 [ #  # ][ #  # ]:          0 :     if (!static_cast<FmGridControl*>(GetParent())->IsDesignMode())
     247                 :          0 :         return DND_ACTION_NONE;
     248                 :            : 
     249         [ #  # ]:          0 :     TransferableDataHelper aDroppedData(_rEvt.maDropEvent.Transferable);
     250                 :            : 
     251                 :            :     // check the formats
     252         [ #  # ]:          0 :     sal_Bool bColumnDescriptor  = OColumnTransferable::canExtractColumnDescriptor(aDroppedData.GetDataFlavorExVector(), CTF_COLUMN_DESCRIPTOR);
     253         [ #  # ]:          0 :     sal_Bool bFieldDescriptor   = OColumnTransferable::canExtractColumnDescriptor(aDroppedData.GetDataFlavorExVector(), CTF_FIELD_DESCRIPTOR);
     254 [ #  # ][ #  # ]:          0 :     if (!bColumnDescriptor && !bFieldDescriptor)
     255                 :            :     {
     256                 :            :         OSL_FAIL("FmGridHeader::ExecuteDrop: should never have reached this (no extractable format)!");
     257                 :          0 :         return DND_ACTION_NONE;
     258                 :            :     }
     259                 :            : 
     260                 :            :     // extract the descriptor
     261                 :          0 :     ::rtl::OUString sDatasouce, sCommand, sFieldName,sDatabaseLocation,sConnnectionResource;
     262                 :          0 :     sal_Int32       nCommandType = CommandType::COMMAND;
     263                 :          0 :     Reference< XPreparedStatement >     xStatement;
     264                 :          0 :     Reference< XResultSet >             xResultSet;
     265                 :          0 :     Reference< XPropertySet >           xField;
     266                 :          0 :     Reference< XConnection >            xConnection;
     267                 :            : 
     268         [ #  # ]:          0 :     ODataAccessDescriptor aColumn = OColumnTransferable::extractColumnDescriptor(aDroppedData);
     269 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daDataSource))  aColumn[daDataSource]   >>= sDatasouce;
                 [ #  # ]
     270 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daDatabaseLocation))    aColumn[daDatabaseLocation] >>= sDatabaseLocation;
                 [ #  # ]
     271 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daConnectionResource))  aColumn[daConnectionResource] >>= sConnnectionResource;
                 [ #  # ]
     272 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daCommand))     aColumn[daCommand]      >>= sCommand;
                 [ #  # ]
     273 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daCommandType)) aColumn[daCommandType]  >>= nCommandType;
                 [ #  # ]
     274 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daColumnName))  aColumn[daColumnName]   >>= sFieldName;
                 [ #  # ]
     275 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daColumnObject))aColumn[daColumnObject] >>= xField;
         [ #  # ][ #  # ]
     276 [ #  # ][ #  # ]:          0 :     if (aColumn.has(daConnection))  aColumn[daConnection]   >>= xConnection;
         [ #  # ][ #  # ]
     277                 :            : 
     278   [ #  #  #  #  :          0 :     if  (   sFieldName.isEmpty()
          #  #  #  #  #  
              # ][ #  # ]
     279                 :          0 :         ||  sCommand.isEmpty()
     280                 :          0 :         ||  (   sDatasouce.isEmpty()
     281                 :          0 :             &&  sDatabaseLocation.isEmpty()
     282                 :          0 :             &&  !xConnection.is()
     283                 :            :             )
     284                 :            :         )
     285                 :            :     {
     286                 :            :         OSL_FAIL( "FmGridHeader::ExecuteDrop: somebody started a nonsense drag operation!!" );
     287                 :          0 :         return DND_ACTION_NONE;
     288                 :            :     }
     289                 :            : 
     290                 :            :     try
     291                 :            :     {
     292                 :            :         // need a connection
     293         [ #  # ]:          0 :         if (!xConnection.is())
     294                 :            :         {   // the transferable did not contain the connection -> build an own one
     295                 :            :             try
     296                 :            :             {
     297         [ #  # ]:          0 :                 ::rtl::OUString sSignificantSource( sDatasouce.isEmpty() ? sDatabaseLocation : sDatasouce );
     298 [ #  # ][ #  # ]:          0 :                 xConnection = OStaticDataAccessTools().getConnection_withFeedback(sSignificantSource, ::rtl::OUString(),::rtl::OUString(),static_cast<FmGridControl*>(GetParent())->getServiceManager());
         [ #  # ][ #  # ]
                 [ #  # ]
              [ #  #  # ]
                 [ #  # ]
     299                 :            :             }
     300         [ #  # ]:          0 :             catch(NoSuchElementException&)
     301                 :            :             {   // allowed, means sDatasouce isn't a valid data source name ....
     302                 :            :             }
     303         [ #  # ]:          0 :             catch(Exception&)
     304                 :            :             {
     305                 :            :                 OSL_FAIL("FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
     306                 :            :             }
     307                 :            : 
     308         [ #  # ]:          0 :             if (!xConnection.is())
     309                 :            :             {
     310                 :            :                 OSL_FAIL("FmGridHeader::ExecuteDrop: could not retrieve the database access object !");
     311                 :          0 :                 return DND_ACTION_NONE;
     312                 :            :             }
     313                 :            :         }
     314                 :            : 
     315                 :            :         // try to obtain the column object
     316         [ #  # ]:          0 :         if (!xField.is())
     317                 :            :         {
     318                 :            : #ifdef DBG_UTIL
     319                 :            :             Reference< XServiceInfo >  xServiceInfo(xConnection, UNO_QUERY);
     320                 :            :             DBG_ASSERT(xServiceInfo.is() && xServiceInfo->supportsService(SRV_SDB_CONNECTION), "FmGridHeader::ExecuteDrop: invalid connection (no database access connection !)");
     321                 :            : #endif
     322                 :            : 
     323                 :          0 :             Reference< XNameAccess > xFields;
     324      [ #  #  # ]:          0 :             switch (nCommandType)
     325                 :            :             {
     326                 :            :                 case CommandType::TABLE:
     327                 :            :                 {
     328         [ #  # ]:          0 :                     Reference< XTablesSupplier > xSupplyTables(xConnection, UNO_QUERY);
     329                 :          0 :                     Reference< XColumnsSupplier >  xSupplyColumns;
     330 [ #  # ][ #  # ]:          0 :                     xSupplyTables->getTables()->getByName(sCommand) >>= xSupplyColumns;
         [ #  # ][ #  # ]
                 [ #  # ]
     331 [ #  # ][ #  # ]:          0 :                     xFields = xSupplyColumns->getColumns();
                 [ #  # ]
     332                 :            :                 }
     333                 :          0 :                 break;
     334                 :            :                 case CommandType::QUERY:
     335                 :            :                 {
     336         [ #  # ]:          0 :                     Reference< XQueriesSupplier > xSupplyQueries(xConnection, UNO_QUERY);
     337                 :          0 :                     Reference< XColumnsSupplier > xSupplyColumns;
     338 [ #  # ][ #  # ]:          0 :                     xSupplyQueries->getQueries()->getByName(sCommand) >>= xSupplyColumns;
         [ #  # ][ #  # ]
                 [ #  # ]
     339 [ #  # ][ #  # ]:          0 :                     xFields  = xSupplyColumns->getColumns();
                 [ #  # ]
     340                 :            :                 }
     341                 :          0 :                 break;
     342                 :            :                 default:
     343                 :            :                 {
     344 [ #  # ][ #  # ]:          0 :                     xStatement = xConnection->prepareStatement(sCommand);
                 [ #  # ]
     345                 :            :                     // not interested in any results
     346                 :            : 
     347         [ #  # ]:          0 :                     Reference< XPropertySet > xStatProps(xStatement,UNO_QUERY);
     348 [ #  # ][ #  # ]:          0 :                     xStatProps->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MaxRows")), makeAny(sal_Int32(0)));
         [ #  # ][ #  # ]
     349                 :            : 
     350 [ #  # ][ #  # ]:          0 :                     xResultSet = xStatement->executeQuery();
                 [ #  # ]
     351         [ #  # ]:          0 :                     Reference< XColumnsSupplier >  xSupplyCols(xResultSet, UNO_QUERY);
     352         [ #  # ]:          0 :                     if (xSupplyCols.is())
     353 [ #  # ][ #  # ]:          0 :                         xFields = xSupplyCols->getColumns();
                 [ #  # ]
     354                 :            :                 }
     355                 :            :             }
     356                 :            : 
     357 [ #  # ][ #  # ]:          0 :             if (xFields.is() && xFields->hasByName(sFieldName))
         [ #  # ][ #  # ]
                 [ #  # ]
     358 [ #  # ][ #  # ]:          0 :                 xFields->getByName(sFieldName) >>= xField;
                 [ #  # ]
     359                 :            : 
     360         [ #  # ]:          0 :             if (!xField.is())
     361                 :            :             {
     362         [ #  # ]:          0 :                 ::comphelper::disposeComponent(xStatement);
     363                 :          0 :                 return DND_ACTION_NONE;
     364         [ #  # ]:          0 :             }
     365                 :            :         }
     366                 :            : 
     367                 :            :         // do the drop asynchronously
     368                 :            :         // (85957 - UI actions within the drop are not allowed, but we want to open a popup menu)
     369         [ #  # ]:          0 :         m_pImpl->aDropData = aColumn;
     370 [ #  # ][ #  # ]:          0 :         m_pImpl->aDropData[daConnection] <<= xConnection;
     371 [ #  # ][ #  # ]:          0 :         m_pImpl->aDropData[daColumnObject] <<= xField;
     372                 :            : 
     373                 :          0 :         m_pImpl->nDropAction = _rEvt.mnAction;
     374                 :          0 :         m_pImpl->aDropPosPixel = _rEvt.maPosPixel;
     375         [ #  # ]:          0 :         m_pImpl->xDroppedStatement = xStatement;
     376         [ #  # ]:          0 :         m_pImpl->xDroppedResultSet = xResultSet;
     377                 :            : 
     378 [ #  # ][ #  # ]:          0 :         PostUserEvent(LINK(this, FmGridHeader, OnAsyncExecuteDrop));
     379                 :            :     }
     380   [ #  #  #  # ]:          0 :     catch (Exception&)
     381                 :            :     {
     382                 :            :         OSL_FAIL("FmGridHeader::ExecuteDrop: caught an exception while creatin' the column !");
     383         [ #  # ]:          0 :         ::comphelper::disposeComponent(xStatement);
     384                 :          0 :         return sal_False;
     385                 :            :     }
     386                 :            : 
     387 [ #  # ][ #  # ]:          0 :     return DND_ACTION_LINK;
     388                 :            : }
     389                 :            : 
     390                 :            : //------------------------------------------------------------------------------
     391                 :          0 : IMPL_LINK( FmGridHeader, OnAsyncExecuteDrop, void*, /*NOTINTERESTEDIN*/ )
     392                 :            : {
     393                 :          0 :     ::rtl::OUString             sCommand, sFieldName,sURL;
     394                 :          0 :     sal_Int32                   nCommandType = CommandType::COMMAND;
     395                 :          0 :     Reference< XPropertySet >   xField;
     396                 :          0 :     Reference< XConnection >    xConnection;
     397                 :            : 
     398         [ #  # ]:          0 :     ::rtl::OUString sDatasouce = m_pImpl->aDropData.getDataSource();
     399 [ #  # ][ #  # ]:          0 :     if ( sDatasouce.isEmpty() && m_pImpl->aDropData.has(daConnectionResource) )
         [ #  # ][ #  # ]
     400         [ #  # ]:          0 :         m_pImpl->aDropData[daConnectionResource]    >>= sURL;
     401         [ #  # ]:          0 :     m_pImpl->aDropData[daCommand]       >>= sCommand;
     402         [ #  # ]:          0 :     m_pImpl->aDropData[daCommandType]   >>= nCommandType;
     403         [ #  # ]:          0 :     m_pImpl->aDropData[daColumnName]    >>= sFieldName;
     404 [ #  # ][ #  # ]:          0 :     m_pImpl->aDropData[daConnection]    >>= xConnection;
     405 [ #  # ][ #  # ]:          0 :     m_pImpl->aDropData[daColumnObject]  >>= xField;
     406                 :            : 
     407                 :            :     try
     408                 :            :     {
     409                 :            :         // need number formats
     410 [ #  # ][ #  # ]:          0 :         Reference< XNumberFormatsSupplier > xSupplier = OStaticDataAccessTools().getNumberFormats(xConnection, sal_True);
                 [ #  # ]
     411                 :          0 :         Reference< XNumberFormats >  xNumberFormats;
     412         [ #  # ]:          0 :         if (xSupplier.is())
     413 [ #  # ][ #  # ]:          0 :             xNumberFormats = xSupplier->getNumberFormats();
                 [ #  # ]
     414         [ #  # ]:          0 :         if (!xNumberFormats.is())
     415                 :            :         {
     416         [ #  # ]:          0 :             ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
     417         [ #  # ]:          0 :             ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
     418                 :          0 :             return 0L;
     419                 :            :         }
     420                 :            : 
     421                 :            :         // Vom Feld werden nun zwei Informationen benoetigt:
     422                 :            :         // a.) Name des Feldes fuer Label und ControlSource
     423                 :            :         // b.) FormatKey, um festzustellen, welches Feld erzeugt werden soll
     424                 :          0 :         sal_Int32 nDataType = 0;
     425 [ #  # ][ #  # ]:          0 :         xField->getPropertyValue(FM_PROP_FIELDTYPE) >>= nDataType;
                 [ #  # ]
     426                 :            :         // diese Datentypen koennen im Gridcontrol nicht verarbeitet werden
     427         [ #  # ]:          0 :         switch (nDataType)
     428                 :            :         {
     429                 :            :             case DataType::BLOB:
     430                 :            :             case DataType::LONGVARBINARY:
     431                 :            :             case DataType::BINARY:
     432                 :            :             case DataType::VARBINARY:
     433                 :            :             case DataType::OTHER:
     434         [ #  # ]:          0 :                 ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
     435         [ #  # ]:          0 :                 ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
     436                 :          0 :                 return 0L;
     437                 :            :         }
     438                 :            : 
     439                 :            :         // Erstellen der Column
     440 [ #  # ][ #  # ]:          0 :         Reference< XIndexContainer >  xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     441         [ #  # ]:          0 :         Reference< XGridColumnFactory >  xFactory(xCols, UNO_QUERY);
     442                 :            : 
     443         [ #  # ]:          0 :         sal_uInt16 nColId = GetItemId(m_pImpl->aDropPosPixel);
     444                 :            :         // EinfuegePosition, immer vor der aktuellen Spalte
     445         [ #  # ]:          0 :         sal_uInt16 nPos = GetModelColumnPos(nColId);
     446                 :          0 :         Reference< XPropertySet >  xCol, xSecondCol;
     447                 :            : 
     448                 :            :         // Create Column based on type, default textfield
     449         [ #  # ]:          0 :         std::vector<sal_uInt16> aPossibleTypes;
     450   [ #  #  #  #  :          0 :         switch (nDataType)
                #  #  # ]
     451                 :            :         {
     452                 :            :             case DataType::BIT:
     453                 :            :             case DataType::BOOLEAN:
     454         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_CHECKBOX);
     455                 :          0 :                 break;
     456                 :            :             case DataType::TINYINT:
     457                 :            :             case DataType::SMALLINT:
     458                 :            :             case DataType::INTEGER:
     459         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_NUMERICFIELD);
     460         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     461                 :          0 :                 break;
     462                 :            :             case DataType::REAL:
     463                 :            :             case DataType::DOUBLE:
     464                 :            :             case DataType::NUMERIC:
     465                 :            :             case DataType::DECIMAL:
     466         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     467         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_NUMERICFIELD);
     468                 :          0 :                 break;
     469                 :            :             case DataType::TIMESTAMP:
     470         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_TWOFIELDS_DATE_N_TIME);
     471         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_DATEFIELD);
     472         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_TIMEFIELD);
     473         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     474                 :          0 :                 break;
     475                 :            :             case DataType::DATE:
     476         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_DATEFIELD);
     477         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     478                 :          0 :                 break;
     479                 :            :             case DataType::TIME:
     480         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_TIMEFIELD);
     481         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     482                 :          0 :                 break;
     483                 :            :             case DataType::CHAR:
     484                 :            :             case DataType::VARCHAR:
     485                 :            :             case DataType::LONGVARCHAR:
     486                 :            :             default:
     487         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_EDIT);
     488         [ #  # ]:          0 :                 aPossibleTypes.push_back(SID_FM_FORMATTEDFIELD);
     489                 :          0 :                 break;
     490                 :            :         }
     491                 :            :         // if it's a currency field, a a "currency field" option
     492                 :            :         try
     493                 :            :         {
     494 [ #  # ][ #  # ]:          0 :             if  (   ::comphelper::hasProperty(FM_PROP_ISCURRENCY, xField)
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     495 [ #  # ][ #  # ]:          0 :                 &&  ::comphelper::getBOOL(xField->getPropertyValue(FM_PROP_ISCURRENCY)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     496 [ #  # ][ #  # ]:          0 :                 aPossibleTypes.insert(aPossibleTypes.begin(), SID_FM_CURRENCYFIELD);
     497                 :            :         }
     498         [ #  # ]:          0 :         catch(Exception&)
     499                 :            :         {
     500                 :            :             OSL_FAIL("FmGridHeader::ExecuteDrop: Exception occurred!");
     501                 :            :         }
     502                 :            : 
     503                 :          0 :         sal_Bool bDateNTimeCol = sal_False;
     504         [ #  # ]:          0 :         if (!aPossibleTypes.empty())
     505                 :            :         {
     506         [ #  # ]:          0 :             sal_Int32 nPreferedType = aPossibleTypes[0];
     507 [ #  # ][ #  # ]:          0 :             if ((m_pImpl->nDropAction == DND_ACTION_LINK) && (aPossibleTypes.size() > 1))
                 [ #  # ]
     508                 :            :             {
     509 [ #  # ][ #  # ]:          0 :                 ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) );
     510                 :            : 
     511 [ #  # ][ #  # ]:          0 :                 PopupMenu aInsertMenu(SVX_RES(RID_SVXMNU_COLS));
     512         [ #  # ]:          0 :                 PopupMenu aTypeMenu;
     513         [ #  # ]:          0 :                 PopupMenu* pMenu = aInsertMenu.GetPopupMenu(SID_FM_INSERTCOL);
     514 [ #  # ][ #  # ]:          0 :                 for (std::vector<sal_uInt16>::const_iterator iter = aPossibleTypes.begin(); iter != aPossibleTypes.end(); ++iter)
         [ #  # ][ #  # ]
     515 [ #  # ][ #  # ]:          0 :                     SetMenuItem(aImageList, *iter, pMenu, aTypeMenu, sal_True, 0);
     516 [ #  # ][ #  # ]:          0 :                 nPreferedType = aTypeMenu.Execute(this, m_pImpl->aDropPosPixel);
         [ #  # ][ #  # ]
     517                 :            :             }
     518                 :            : 
     519                 :          0 :             bDateNTimeCol = nPreferedType == SID_FM_TWOFIELDS_DATE_N_TIME;
     520         [ #  # ]:          0 :             sal_uInt16 nColCount = bDateNTimeCol ? 2 : 1;
     521                 :          0 :             ::rtl::OUString sFieldService;
     522         [ #  # ]:          0 :             while (nColCount--)
     523                 :            :             {
     524         [ #  # ]:          0 :                 if (bDateNTimeCol)
     525         [ #  # ]:          0 :                     nPreferedType = nColCount ? SID_FM_DATEFIELD : SID_FM_TIMEFIELD;
     526                 :            : 
     527         [ #  # ]:          0 :                 sFieldService = FieldServiceFromId(nPreferedType);
     528                 :          0 :                 Reference< XPropertySet >  xThisRoundCol;
     529         [ #  # ]:          0 :                 if ( !sFieldService.isEmpty() )
     530 [ #  # ][ #  # ]:          0 :                     xThisRoundCol = xFactory->createColumn(sFieldService);
                 [ #  # ]
     531         [ #  # ]:          0 :                 if (nColCount)
     532         [ #  # ]:          0 :                     xSecondCol = xThisRoundCol;
     533                 :            :                 else
     534         [ #  # ]:          0 :                     xCol = xThisRoundCol;
     535                 :          0 :             }
     536                 :            :         }
     537                 :            : 
     538 [ #  # ][ #  # ]:          0 :         if (!xCol.is() || (bDateNTimeCol && !xSecondCol.is()))
         [ #  # ][ #  # ]
     539                 :            :         {
     540         [ #  # ]:          0 :             ::comphelper::disposeComponent(xCol);   // in case only the creation of the second column failed
     541         [ #  # ]:          0 :             ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
     542         [ #  # ]:          0 :             ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
     543                 :          0 :             return 0L;
     544                 :            :         }
     545                 :            : 
     546         [ #  # ]:          0 :         if (bDateNTimeCol)
     547                 :            :         {
     548 [ #  # ][ #  # ]:          0 :             String sTimePostfix( SVX_RES( RID_STR_POSTFIX_TIME ) );
     549 [ #  # ][ #  # ]:          0 :             xCol->setPropertyValue(FM_PROP_LABEL, makeAny( ::rtl::OUString( sFieldName + sTimePostfix ) ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     550                 :            : 
     551 [ #  # ][ #  # ]:          0 :             String sDatePostfix( SVX_RES( RID_STR_POSTFIX_DATE ) );
     552 [ #  # ][ #  # ]:          0 :             xSecondCol->setPropertyValue(FM_PROP_LABEL, makeAny( ::rtl::OUString( sFieldName + sDatePostfix ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     553                 :            :         }
     554                 :            :         else
     555 [ #  # ][ #  # ]:          0 :             xCol->setPropertyValue(FM_PROP_LABEL, makeAny(sFieldName));
         [ #  # ][ #  # ]
     556                 :            : 
     557 [ #  # ][ #  # ]:          0 :         FormControlFactory aControlFactory( ::comphelper::getProcessServiceFactory() );
         [ #  # ][ #  # ]
     558 [ #  # ][ #  # ]:          0 :         aControlFactory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xCol );
     559         [ #  # ]:          0 :         aControlFactory.initializeFieldDependentProperties( xField, xCol, xNumberFormats );
     560                 :            : 
     561 [ #  # ][ #  # ]:          0 :         xCol->setPropertyValue(FM_PROP_CONTROLSOURCE, makeAny(sFieldName));
         [ #  # ][ #  # ]
     562         [ #  # ]:          0 :         if ( xSecondCol.is() )
     563 [ #  # ][ #  # ]:          0 :             xSecondCol->setPropertyValue(FM_PROP_CONTROLSOURCE, makeAny(sFieldName));
         [ #  # ][ #  # ]
     564                 :            : 
     565         [ #  # ]:          0 :         if (bDateNTimeCol)
     566                 :            :         {
     567 [ #  # ][ #  # ]:          0 :             String sRealName,sPurePostfix;
     568                 :            : 
     569                 :            :             String aPostfix[] = {
     570         [ #  # ]:          0 :                 String( SVX_RES( RID_STR_POSTFIX_DATE ) ),
     571         [ #  # ]:          0 :                 String( SVX_RES( RID_STR_POSTFIX_TIME ) )
     572 [ #  # ][ #  # ]:          0 :             };
           [ #  #  #  #  
                   #  # ]
     573                 :            : 
     574         [ #  # ]:          0 :             for ( size_t i=0; i<2; ++i )
     575                 :            :             {
     576 [ #  # ][ #  # ]:          0 :                 sPurePostfix = comphelper::string::stripStart(aPostfix[i], ' ');
                 [ #  # ]
     577 [ #  # ][ #  # ]:          0 :                 sPurePostfix = comphelper::string::stripStart(sPurePostfix, '(');
                 [ #  # ]
     578 [ #  # ][ #  # ]:          0 :                 sPurePostfix = comphelper::string::stripEnd(sPurePostfix, ')');
                 [ #  # ]
     579         [ #  # ]:          0 :                 sRealName = sFieldName;
     580         [ #  # ]:          0 :                 sRealName += '_';
     581         [ #  # ]:          0 :                 sRealName += sPurePostfix;
     582         [ #  # ]:          0 :                 if (i)
     583 [ #  # ][ #  # ]:          0 :                     xSecondCol->setPropertyValue(FM_PROP_NAME, makeAny(::rtl::OUString(sRealName)));
         [ #  # ][ #  # ]
                 [ #  # ]
     584                 :            :                 else
     585 [ #  # ][ #  # ]:          0 :                     xCol->setPropertyValue(FM_PROP_NAME, makeAny(::rtl::OUString(sRealName)));
         [ #  # ][ #  # ]
                 [ #  # ]
     586 [ #  # ][ #  # ]:          0 :             }
         [ #  # ][ #  # ]
     587                 :            :         }
     588                 :            :         else
     589 [ #  # ][ #  # ]:          0 :             xCol->setPropertyValue(FM_PROP_NAME, makeAny(sFieldName));
         [ #  # ][ #  # ]
     590                 :            : 
     591                 :            :         // jetzt einfuegen
     592                 :          0 :         Any aElement;
     593         [ #  # ]:          0 :         aElement <<= xCol;
     594 [ #  # ][ #  # ]:          0 :         xCols->insertByIndex(nPos, aElement);
     595                 :            : 
     596         [ #  # ]:          0 :         if (bDateNTimeCol)
     597                 :            :         {
     598         [ #  # ]:          0 :             aElement <<= xSecondCol;
     599 [ #  # ][ #  # ]:          0 :             xCols->insertByIndex(nPos == (sal_uInt16)-1 ? nPos : ++nPos, aElement);
                 [ #  # ]
     600                 :            :         }
     601                 :            : 
     602                 :            :         // ist die component::Form an die Datenbankangebunden?
     603         [ #  # ]:          0 :         Reference< XFormComponent >  xFormCp(xCols, UNO_QUERY);
     604 [ #  # ][ #  # ]:          0 :         Reference< XPropertySet >  xForm(xFormCp->getParent(), UNO_QUERY);
                 [ #  # ]
     605         [ #  # ]:          0 :         if (xForm.is())
     606                 :            :         {
     607 [ #  # ][ #  # ]:          0 :             if (::comphelper::getString(xForm->getPropertyValue(FM_PROP_DATASOURCE)).isEmpty())
         [ #  # ][ #  # ]
                 [ #  # ]
     608                 :            :             {
     609         [ #  # ]:          0 :                 if ( !sDatasouce.isEmpty() )
     610 [ #  # ][ #  # ]:          0 :                     xForm->setPropertyValue(FM_PROP_DATASOURCE, makeAny(sDatasouce));
         [ #  # ][ #  # ]
     611                 :            :                 else
     612 [ #  # ][ #  # ]:          0 :                     xForm->setPropertyValue(FM_PROP_URL, makeAny(sURL));
         [ #  # ][ #  # ]
     613                 :            :             }
     614                 :            : 
     615 [ #  # ][ #  # ]:          0 :             if (::comphelper::getString(xForm->getPropertyValue(FM_PROP_COMMAND)).isEmpty())
         [ #  # ][ #  # ]
                 [ #  # ]
     616                 :            :             {
     617 [ #  # ][ #  # ]:          0 :                 xForm->setPropertyValue(FM_PROP_COMMAND, makeAny(sCommand));
         [ #  # ][ #  # ]
     618                 :          0 :                 Any aCommandType;
     619      [ #  #  # ]:          0 :                 switch (nCommandType)
     620                 :            :                 {
     621                 :            :                     case CommandType::TABLE:
     622         [ #  # ]:          0 :                         aCommandType <<= (sal_Int32)CommandType::TABLE;
     623                 :          0 :                         break;
     624                 :            :                     case CommandType::QUERY:
     625         [ #  # ]:          0 :                         aCommandType <<= (sal_Int32)CommandType::QUERY;
     626                 :          0 :                         break;
     627                 :            :                     default:
     628         [ #  # ]:          0 :                         aCommandType <<= (sal_Int32)CommandType::COMMAND;
     629 [ #  # ][ #  # ]:          0 :                         xForm->setPropertyValue(FM_PROP_ESCAPE_PROCESSING, bool2any((sal_Bool)(2 == nCommandType)));
         [ #  # ][ #  # ]
     630                 :          0 :                         break;
     631                 :            :                 }
     632 [ #  # ][ #  # ]:          0 :                 xForm->setPropertyValue(FM_PROP_COMMANDTYPE, aCommandType);
                 [ #  # ]
     633                 :            :             }
     634 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     635                 :            :     }
     636   [ #  #  #  # ]:          0 :     catch (Exception&)
     637                 :            :     {
     638                 :            :         OSL_FAIL("FmGridHeader::OnAsyncExecuteDrop: caught an exception while creatin' the column !");
     639         [ #  # ]:          0 :         ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
     640         [ #  # ]:          0 :         ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
     641                 :          0 :         return 0L;
     642                 :            :     }
     643                 :            : 
     644         [ #  # ]:          0 :     ::comphelper::disposeComponent(m_pImpl->xDroppedResultSet);
     645         [ #  # ]:          0 :     ::comphelper::disposeComponent(m_pImpl->xDroppedStatement);
     646                 :          0 :     return 1L;
     647                 :            : }
     648                 :            : 
     649                 :            : //------------------------------------------------------------------------------
     650                 :          0 : void FmGridHeader::PreExecuteColumnContextMenu(sal_uInt16 nColId, PopupMenu& rMenu)
     651                 :            : {
     652         [ #  # ]:          0 :     sal_Bool bDesignMode = static_cast<FmGridControl*>(GetParent())->IsDesignMode();
     653                 :            : 
     654 [ #  # ][ #  # ]:          0 :     Reference< ::com::sun::star::container::XIndexContainer >  xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     655                 :            :     // Aufbau des Insert Menues
     656                 :            :     // mark the column if nColId != HEADERBAR_ITEM_NOTFOUND
     657         [ #  # ]:          0 :     if(nColId > 0)
     658                 :            :     {
     659         [ #  # ]:          0 :         sal_uInt16 nPos2 = GetModelColumnPos(nColId);
     660                 :            : 
     661 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::container::XIndexContainer >  xColumns(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     662                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet> xColumn;
     663 [ #  # ][ #  # ]:          0 :         ::cppu::extractInterface(xColumn, xColumns->getByIndex(nPos2));
                 [ #  # ]
     664         [ #  # ]:          0 :         Reference< ::com::sun::star::view::XSelectionSupplier >  xSelSupplier(xColumns, UNO_QUERY);
     665         [ #  # ]:          0 :         if (xSelSupplier.is())
     666 [ #  # ][ #  # ]:          0 :             xSelSupplier->select(makeAny(xColumn));
                 [ #  # ]
     667                 :            :     }
     668                 :            : 
     669                 :            :     // EinfuegePosition, immer vor der aktuellen Spalte
     670         [ #  # ]:          0 :     sal_uInt16 nPos = GetModelColumnPos(nColId);
     671 [ #  # ][ #  # ]:          0 :     sal_Bool bMarked = nColId && static_cast<FmGridControl*>(GetParent())->isColumnMarked(nColId);
         [ #  # ][ #  # ]
     672                 :            : 
     673 [ #  # ][ #  # ]:          0 :     ImageList aImageList( SVX_RES(RID_SVXIMGLIST_FMEXPL) );
     674 [ #  # ][ #  # ]:          0 :     PopupMenu* pControlMenu = new PopupMenu;
     675                 :            : 
     676         [ #  # ]:          0 :     PopupMenu* pMenu = rMenu.GetPopupMenu(SID_FM_INSERTCOL);
     677         [ #  # ]:          0 :     if (pMenu)
     678                 :            :     {
     679         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_EDIT, pMenu, *pControlMenu, bDesignMode);
     680         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_CHECKBOX, pMenu, *pControlMenu, bDesignMode);
     681         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_COMBOBOX, pMenu, *pControlMenu, bDesignMode);
     682         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_LISTBOX, pMenu, *pControlMenu, bDesignMode);
     683         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_DATEFIELD, pMenu, *pControlMenu, bDesignMode);
     684         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_TIMEFIELD, pMenu, *pControlMenu, bDesignMode);
     685         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_NUMERICFIELD, pMenu, *pControlMenu, bDesignMode);
     686         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_CURRENCYFIELD, pMenu, *pControlMenu, bDesignMode);
     687         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_PATTERNFIELD, pMenu, *pControlMenu, bDesignMode);
     688         [ #  # ]:          0 :         SetMenuItem(aImageList, SID_FM_FORMATTEDFIELD, pMenu, *pControlMenu, bDesignMode);
     689                 :            :     }
     690                 :            : 
     691 [ #  # ][ #  # ]:          0 :     if (pMenu && xCols.is() && nColId)
         [ #  # ][ #  # ]
     692                 :            :     {
     693                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet > xSet;
     694 [ #  # ][ #  # ]:          0 :         ::cppu::extractInterface(xSet, xCols->getByIndex(nPos));
                 [ #  # ]
     695                 :            :         sal_Int16 nClassId;
     696 [ #  # ][ #  # ]:          0 :         xSet->getPropertyValue(FM_PROP_CLASSID) >>= nClassId;
                 [ #  # ]
     697                 :            : 
     698         [ #  # ]:          0 :         Reference< ::com::sun::star::io::XPersistObject >  xServiceQuestion(xSet, UNO_QUERY);
     699 [ #  # ][ #  # ]:          0 :         sal_Int32 nColType = xServiceQuestion.is() ? getColumnTypeByModelName(xServiceQuestion->getServiceName()) : 0;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     700         [ #  # ]:          0 :         if (nColType == TYPE_TEXTFIELD)
     701                 :            :         {   // edit fields and formatted fields have the same service name, thus getColumnTypeByModelName returns TYPE_TEXTFIELD
     702                 :            :             // in both cases. And as columns don't have an ::com::sun::star::lang::XServiceInfo interface, we have to distinguish both
     703                 :            :             // types via the existence of special properties
     704         [ #  # ]:          0 :             Reference< ::com::sun::star::beans::XPropertySet >  xProps(xSet, UNO_QUERY);
     705         [ #  # ]:          0 :             if (xProps.is())
     706                 :            :             {
     707 [ #  # ][ #  # ]:          0 :                 Reference< ::com::sun::star::beans::XPropertySetInfo >  xPropsInfo = xProps->getPropertySetInfo();
     708 [ #  # ][ #  # ]:          0 :                 if (xPropsInfo.is() && xPropsInfo->hasPropertyByName(FM_PROP_FORMATSSUPPLIER))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     709                 :          0 :                     nColType = TYPE_FORMATTEDFIELD;
     710                 :          0 :             }
     711                 :            :         }
     712                 :            : 
     713 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_EDIT + nChangeTypeOffset, bDesignMode && (nColType != TYPE_TEXTFIELD));
                 [ #  # ]
     714 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_COMBOBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_COMBOBOX));
                 [ #  # ]
     715 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_LISTBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_LISTBOX));
                 [ #  # ]
     716 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_CHECKBOX + nChangeTypeOffset, bDesignMode && (nColType != TYPE_CHECKBOX));
                 [ #  # ]
     717 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_DATEFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_DATEFIELD));
                 [ #  # ]
     718 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_NUMERICFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_NUMERICFIELD));
                 [ #  # ]
     719 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_TIMEFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_TIMEFIELD));
                 [ #  # ]
     720 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_CURRENCYFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_CURRENCYFIELD));
                 [ #  # ]
     721 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_PATTERNFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_PATTERNFIELD));
                 [ #  # ]
     722 [ #  # ][ #  # ]:          0 :         pControlMenu->EnableItem(SID_FM_FORMATTEDFIELD + nChangeTypeOffset, bDesignMode && (nColType != TYPE_FORMATTEDFIELD));
                 [ #  # ]
     723         [ #  # ]:          0 :         rMenu.SetPopupMenu(SID_FM_CHANGECOL, pControlMenu);
     724                 :            :     }
     725                 :            : 
     726 [ #  # ][ #  # ]:          0 :     rMenu.EnableItem(SID_FM_INSERTCOL, bDesignMode && xCols.is());
                 [ #  # ]
     727 [ #  # ][ #  # ]:          0 :     rMenu.EnableItem(SID_FM_DELETECOL, bDesignMode && bMarked && xCols.is());
         [ #  # ][ #  # ]
     728 [ #  # ][ #  # ]:          0 :     rMenu.EnableItem(SID_FM_CHANGECOL, bDesignMode && bMarked && xCols.is());
         [ #  # ][ #  # ]
     729 [ #  # ][ #  # ]:          0 :     rMenu.EnableItem(SID_FM_SHOW_PROPERTY_BROWSER, bDesignMode && bMarked && xCols.is());
         [ #  # ][ #  # ]
     730                 :            : 
     731         [ #  # ]:          0 :     PopupMenu* pShowColsMenu = rMenu.GetPopupMenu(SID_FM_SHOWCOLS);
     732                 :          0 :     sal_uInt16 nHiddenCols = 0;
     733         [ #  # ]:          0 :     if (pShowColsMenu)
     734                 :            :     {
     735         [ #  # ]:          0 :         if (xCols.is())
     736                 :            :         {
     737                 :            :             // check for hidden cols
     738                 :          0 :             Reference< ::com::sun::star::beans::XPropertySet >  xCurCol;
     739                 :          0 :             Any aHidden,aName;
     740 [ #  # ][ #  # ]:          0 :             for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
                 [ #  # ]
     741                 :            :             {
     742 [ #  # ][ #  # ]:          0 :                 ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
                 [ #  # ]
     743                 :            :                 DBG_ASSERT(xCurCol.is(), "FmGridHeader::PreExecuteColumnContextMenu : the Peer has invalid columns !");
     744 [ #  # ][ #  # ]:          0 :                 aHidden = xCurCol->getPropertyValue(FM_PROP_HIDDEN);
                 [ #  # ]
     745                 :            :                 DBG_ASSERT(aHidden.getValueType().getTypeClass() == TypeClass_BOOLEAN,
     746                 :            :                     "FmGridHeader::PreExecuteColumnContextMenu : the property 'hidden' should be boolean !");
     747 [ #  # ][ #  # ]:          0 :                 if (::comphelper::getBOOL(aHidden))
     748                 :            :                 {
     749                 :            :                     // put the column name into the 'show col' menu
     750         [ #  # ]:          0 :                     if (nHiddenCols < 16)
     751                 :            :                     {   // (only the first 16 items to keep the menu rather small)
     752 [ #  # ][ #  # ]:          0 :                         aName = xCurCol->getPropertyValue(FM_PROP_LABEL);
                 [ #  # ]
     753 [ #  # ][ #  # ]:          0 :                         pShowColsMenu->InsertItem(nHiddenCols + 1, ::comphelper::getString(aName), 0, nHiddenCols);
         [ #  # ][ #  # ]
     754                 :            :                             // the ID is arbitrary, but should be unique within the whole menu
     755                 :            :                     }
     756                 :          0 :                     ++nHiddenCols;
     757                 :            :                 }
     758                 :          0 :             }
     759                 :            :         }
     760 [ #  # ][ #  # ]:          0 :         pShowColsMenu->EnableItem(SID_FM_SHOWCOLS_MORE, xCols.is() && (nHiddenCols > 16));
                 [ #  # ]
     761 [ #  # ][ #  # ]:          0 :         pShowColsMenu->EnableItem(SID_FM_SHOWALLCOLS, xCols.is() && (nHiddenCols > 0));
                 [ #  # ]
     762                 :            :     }
     763                 :            : 
     764                 :            :     // allow the 'hide column' item ?
     765                 :          0 :     sal_Bool bAllowHide = bMarked;                                          // a column is marked
     766 [ #  # ][ #  # ]:          0 :     bAllowHide = bAllowHide || (!bDesignMode && (nPos != (sal_uInt16)-1));  // OR we are in alive mode and have hit a column
                 [ #  # ]
     767 [ #  # ][ #  # ]:          0 :     bAllowHide = bAllowHide && xCols.is();                              // AND we have a column container
     768 [ #  # ][ #  # ]:          0 :     bAllowHide = bAllowHide && (xCols->getCount()-nHiddenCols > 1);     // AND there are at least two visible columns
         [ #  # ][ #  # ]
     769         [ #  # ]:          0 :     rMenu.EnableItem(SID_FM_HIDECOL,  bAllowHide);
     770                 :            : 
     771                 :          0 :     sal_Bool bChecked = sal_False;
     772         [ #  # ]:          0 :     if (bMarked)
     773                 :            :     {
     774                 :            : 
     775         [ #  # ]:          0 :         SfxViewFrame* pCurrentFrame = SfxViewFrame::Current();
     776                 :          0 :         SfxItemState eState = SFX_ITEM_UNKNOWN;
     777                 :            :         // ask the bindings of the current view frame (which should be the one we're residing in) for the state
     778         [ #  # ]:          0 :         if (pCurrentFrame)
     779                 :            :         {
     780                 :          0 :             SfxPoolItem* pItem = NULL;
     781         [ #  # ]:          0 :             eState = pCurrentFrame->GetBindings().QueryState(SID_FM_CTL_PROPERTIES, pItem);
     782                 :            : 
     783 [ #  # ][ #  # ]:          0 :             if (eState >= SFX_ITEM_AVAILABLE && pItem )
     784                 :            :             {
     785 [ #  # ][ #  # ]:          0 :                 bChecked = pItem->ISA(SfxBoolItem) && ((SfxBoolItem*)pItem)->GetValue();
         [ #  # ][ #  # ]
     786         [ #  # ]:          0 :                 rMenu.CheckItem(SID_FM_SHOW_PROPERTY_BROWSER,bChecked);
     787                 :            :             }
     788 [ #  # ][ #  # ]:          0 :             delete pItem;
     789                 :            :         }
     790         [ #  # ]:          0 :     }
     791                 :          0 : }
     792                 :            : 
     793                 :            : enum InspectorAction { eOpenInspector, eCloseInspector, eUpdateInspector, eNone };
     794                 :            : 
     795                 :            : //------------------------------------------------------------------------------
     796                 :          0 : void FmGridHeader::PostExecuteColumnContextMenu(sal_uInt16 nColId, const PopupMenu& rMenu, sal_uInt16 nExecutionResult)
     797                 :            : {
     798 [ #  # ][ #  # ]:          0 :     Reference< ::com::sun::star::container::XIndexContainer >  xCols(static_cast<FmGridControl*>(GetParent())->GetPeer()->getColumns());
     799         [ #  # ]:          0 :     sal_uInt16 nPos = GetModelColumnPos(nColId);
     800                 :            : 
     801                 :            :     // remove and delet the menu we inserted in PreExecuteColumnContextMenu
     802         [ #  # ]:          0 :     PopupMenu* pControlMenu = rMenu.GetPopupMenu(SID_FM_CHANGECOL);
     803 [ #  # ][ #  # ]:          0 :     delete pControlMenu;
     804                 :            : 
     805                 :          0 :     ::rtl::OUString aFieldType;
     806                 :          0 :     sal_Bool    bReplace = sal_False;
     807                 :          0 :     InspectorAction eInspectorAction = eNone;
     808                 :          0 :     Reference< XPropertySet > xColumnToInspect;
     809   [ #  #  #  #  :          0 :     switch (nExecutionResult)
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
          #  #  #  #  #  
                   #  # ]
     810                 :            :     {
     811                 :            :         case SID_FM_DELETECOL:
     812                 :            :         {
     813                 :          0 :             Reference< XInterface >  xCol;
     814 [ #  # ][ #  # ]:          0 :             ::cppu::extractInterface(xCol, xCols->getByIndex(nPos));
                 [ #  # ]
     815 [ #  # ][ #  # ]:          0 :             xCols->removeByIndex(nPos);
     816         [ #  # ]:          0 :             ::comphelper::disposeComponent(xCol);
     817                 :          0 :         }   break;
     818                 :            :         case SID_FM_SHOW_PROPERTY_BROWSER:
     819         [ #  # ]:          0 :             eInspectorAction = rMenu.IsItemChecked( SID_FM_SHOW_PROPERTY_BROWSER ) ? eOpenInspector : eCloseInspector;
     820 [ #  # ][ #  # ]:          0 :             xColumnToInspect.set( xCols->getByIndex( nPos ), UNO_QUERY );
                 [ #  # ]
     821                 :          0 :             break;
     822                 :            :         case SID_FM_EDIT + nChangeTypeOffset:
     823                 :          0 :             bReplace = sal_True;
     824                 :            :         case SID_FM_EDIT:
     825         [ #  # ]:          0 :             aFieldType = FM_COL_TEXTFIELD;
     826                 :          0 :             break;
     827                 :            :         case SID_FM_COMBOBOX + nChangeTypeOffset:
     828                 :          0 :             bReplace = sal_True;
     829                 :            :         case SID_FM_COMBOBOX:
     830         [ #  # ]:          0 :             aFieldType = FM_COL_COMBOBOX;
     831                 :          0 :             break;
     832                 :            :         case SID_FM_LISTBOX + nChangeTypeOffset:
     833                 :          0 :             bReplace = sal_True;
     834                 :            :         case SID_FM_LISTBOX:
     835         [ #  # ]:          0 :             aFieldType = FM_COL_LISTBOX;
     836                 :          0 :             break;
     837                 :            :         case SID_FM_CHECKBOX + nChangeTypeOffset:
     838                 :          0 :             bReplace = sal_True;
     839                 :            :         case SID_FM_CHECKBOX:
     840         [ #  # ]:          0 :             aFieldType = FM_COL_CHECKBOX;
     841                 :          0 :             break;
     842                 :            :         case SID_FM_DATEFIELD + nChangeTypeOffset:
     843                 :          0 :             bReplace = sal_True;
     844                 :            :         case SID_FM_DATEFIELD:
     845         [ #  # ]:          0 :             aFieldType = FM_COL_DATEFIELD;
     846                 :          0 :             break;
     847                 :            :         case SID_FM_TIMEFIELD + nChangeTypeOffset:
     848                 :          0 :             bReplace = sal_True;
     849                 :            :         case SID_FM_TIMEFIELD:
     850         [ #  # ]:          0 :             aFieldType = FM_COL_TIMEFIELD;
     851                 :          0 :             break;
     852                 :            :         case SID_FM_NUMERICFIELD + nChangeTypeOffset:
     853                 :          0 :             bReplace = sal_True;
     854                 :            :         case SID_FM_NUMERICFIELD:
     855         [ #  # ]:          0 :             aFieldType = FM_COL_NUMERICFIELD;
     856                 :          0 :             break;
     857                 :            :         case SID_FM_CURRENCYFIELD + nChangeTypeOffset:
     858                 :          0 :             bReplace = sal_True;
     859                 :            :         case SID_FM_CURRENCYFIELD:
     860         [ #  # ]:          0 :             aFieldType = FM_COL_CURRENCYFIELD;
     861                 :          0 :             break;
     862                 :            :         case SID_FM_PATTERNFIELD + nChangeTypeOffset:
     863                 :          0 :             bReplace = sal_True;
     864                 :            :         case SID_FM_PATTERNFIELD:
     865         [ #  # ]:          0 :             aFieldType = FM_COL_PATTERNFIELD;
     866                 :          0 :             break;
     867                 :            :         case SID_FM_FORMATTEDFIELD + nChangeTypeOffset:
     868                 :          0 :             bReplace = sal_True;
     869                 :            :         case SID_FM_FORMATTEDFIELD:
     870         [ #  # ]:          0 :             aFieldType = FM_COL_FORMATTEDFIELD;
     871                 :          0 :             break;
     872                 :            :         case SID_FM_HIDECOL:
     873                 :            :         {
     874                 :          0 :             Reference< ::com::sun::star::beans::XPropertySet >  xCurCol;
     875 [ #  # ][ #  # ]:          0 :             ::cppu::extractInterface(xCurCol, xCols->getByIndex(nPos));
                 [ #  # ]
     876 [ #  # ][ #  # ]:          0 :             xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_True));
         [ #  # ][ #  # ]
     877                 :            :         }
     878                 :          0 :         break;
     879                 :            :         case SID_FM_SHOWCOLS_MORE:
     880                 :            :         {
     881         [ #  # ]:          0 :             SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
     882         [ #  # ]:          0 :             if(pFact)
     883                 :            :             {
     884         [ #  # ]:          0 :                 AbstractFmShowColsDialog* pDlg = pFact->CreateFmShowColsDialog(NULL);
     885                 :            :                 DBG_ASSERT(pDlg, "Dialogdiet fail!");
     886         [ #  # ]:          0 :                 pDlg->SetColumns(xCols);
     887         [ #  # ]:          0 :                 pDlg->Execute();
     888 [ #  # ][ #  # ]:          0 :                 delete pDlg;
     889                 :            :             }
     890                 :            : 
     891                 :            :         }
     892                 :          0 :         break;
     893                 :            :         case SID_FM_SHOWALLCOLS:
     894                 :            :         {
     895                 :            :             // just iterate through all the cols ...
     896                 :          0 :             Reference< ::com::sun::star::beans::XPropertySet >  xCurCol;
     897 [ #  # ][ #  # ]:          0 :             for (sal_uInt16 i=0; i<xCols->getCount(); ++i)
                 [ #  # ]
     898                 :            :             {
     899 [ #  # ][ #  # ]:          0 :                 ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
                 [ #  # ]
     900 [ #  # ][ #  # ]:          0 :                 xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_False));
         [ #  # ][ #  # ]
     901                 :          0 :             }
     902                 :            :             // TODO : there must be a more clever way to do this ....
     903                 :            :             // with the above the view is updated after every single model update ...
     904                 :            :         }
     905                 :          0 :         break;
     906                 :            :         default:
     907 [ #  # ][ #  # ]:          0 :             if (nExecutionResult>0 && nExecutionResult<=16)
     908                 :            :             {   // it was a "show column/<colname>" command (there are at most 16 such items)
     909                 :            :                 // search the nExecutionResult'th hidden col
     910                 :          0 :                 Reference< ::com::sun::star::beans::XPropertySet >  xCurCol;
     911 [ #  # ][ #  # ]:          0 :                 for (sal_uInt16 i=0; i<xCols->getCount() && nExecutionResult; ++i)
         [ #  # ][ #  # ]
                 [ #  # ]
     912                 :            :                 {
     913 [ #  # ][ #  # ]:          0 :                     ::cppu::extractInterface(xCurCol, xCols->getByIndex(i));
                 [ #  # ]
     914 [ #  # ][ #  # ]:          0 :                     Any aHidden = xCurCol->getPropertyValue(FM_PROP_HIDDEN);
                 [ #  # ]
     915 [ #  # ][ #  # ]:          0 :                     if (::comphelper::getBOOL(aHidden))
     916         [ #  # ]:          0 :                         if (!--nExecutionResult)
     917                 :            :                         {
     918 [ #  # ][ #  # ]:          0 :                             xCurCol->setPropertyValue(FM_PROP_HIDDEN, makeAny((sal_Bool)sal_False));
         [ #  # ][ #  # ]
     919                 :            :                             break;
     920                 :            :                         }
     921         [ #  # ]:          0 :                 }
     922                 :            :             }
     923                 :          0 :             break;
     924                 :            :     }
     925                 :            : 
     926         [ #  # ]:          0 :     if ( !aFieldType.isEmpty() )
     927                 :            :     {
     928                 :            :         try
     929                 :            :         {
     930         [ #  # ]:          0 :             Reference< XGridColumnFactory > xFactory( xCols, UNO_QUERY_THROW );
     931 [ #  # ][ #  # ]:          0 :             Reference< XPropertySet > xNewCol( xFactory->createColumn( aFieldType ), UNO_SET_THROW );
                 [ #  # ]
     932                 :            : 
     933         [ #  # ]:          0 :             if ( bReplace )
     934                 :            :             {
     935                 :            :                 // ein paar Properties hinueberretten
     936 [ #  # ][ #  # ]:          0 :                 Reference< XPropertySet > xReplaced( xCols->getByIndex( nPos ), UNO_QUERY );
                 [ #  # ]
     937                 :            : 
     938                 :            :                 OStaticDataAccessTools().TransferFormComponentProperties(
     939 [ #  # ][ #  # ]:          0 :                     xReplaced, xNewCol, Application::GetSettings().GetUILocale() );
         [ #  # ][ #  # ]
                 [ #  # ]
     940                 :            : 
     941 [ #  # ][ #  # ]:          0 :                 xCols->replaceByIndex( nPos, makeAny( xNewCol ) );
                 [ #  # ]
     942         [ #  # ]:          0 :                 ::comphelper::disposeComponent( xReplaced );
     943                 :            : 
     944                 :          0 :                 eInspectorAction = eUpdateInspector;
     945         [ #  # ]:          0 :                 xColumnToInspect = xNewCol;
     946                 :            :             }
     947                 :            :             else
     948                 :            :             {
     949 [ #  # ][ #  # ]:          0 :                 FormControlFactory factory( ::comphelper::getProcessServiceFactory() );
         [ #  # ][ #  # ]
     950                 :            : 
     951                 :            :                 ::rtl::OUString sLabel = factory.getDefaultUniqueName_ByComponentType(
     952 [ #  # ][ #  # ]:          0 :                     Reference< XNameAccess >( xCols, UNO_QUERY_THROW ), xNewCol );
     953 [ #  # ][ #  # ]:          0 :                 xNewCol->setPropertyValue( FM_PROP_LABEL, makeAny( sLabel ) );
         [ #  # ][ #  # ]
     954 [ #  # ][ #  # ]:          0 :                 xNewCol->setPropertyValue( FM_PROP_NAME, makeAny( sLabel ) );
         [ #  # ][ #  # ]
     955                 :            : 
     956 [ #  # ][ #  # ]:          0 :                 factory.initializeControlModel( DocumentClassification::classifyHostDocument( xCols ), xNewCol );
     957                 :            : 
     958 [ #  # ][ #  # ]:          0 :                 xCols->insertByIndex( nPos, makeAny( xNewCol ) );
         [ #  # ][ #  # ]
     959         [ #  # ]:          0 :             }
     960                 :            :         }
     961         [ #  # ]:          0 :         catch( const Exception& )
     962                 :            :         {
     963                 :            :             DBG_UNHANDLED_EXCEPTION();
     964                 :            :         }
     965                 :            :     }
     966                 :            : 
     967         [ #  # ]:          0 :     SfxViewFrame* pCurrentFrame = SfxViewFrame::Current();
     968                 :            :     OSL_ENSURE( pCurrentFrame, "FmGridHeader::PostExecuteColumnContextMenu: no view frame -> no bindings -> no property browser!" );
     969         [ #  # ]:          0 :     if ( pCurrentFrame )
     970                 :            :     {
     971         [ #  # ]:          0 :         if ( eInspectorAction == eUpdateInspector )
     972                 :            :         {
     973 [ #  # ][ #  # ]:          0 :             if ( !pCurrentFrame->HasChildWindow( SID_FM_SHOW_PROPERTIES ) )
     974                 :          0 :                 eInspectorAction = eNone;
     975                 :            :         }
     976                 :            : 
     977         [ #  # ]:          0 :         if ( eInspectorAction != eNone )
     978                 :            :         {
     979         [ #  # ]:          0 :             FmInterfaceItem aIFaceItem( SID_FM_SHOW_PROPERTY_BROWSER, xColumnToInspect );
     980         [ #  # ]:          0 :             SfxBoolItem aShowItem( SID_FM_SHOW_PROPERTIES, eInspectorAction == eCloseInspector ? sal_False : sal_True );
     981                 :            : 
     982                 :          0 :             pCurrentFrame->GetBindings().GetDispatcher()->Execute( SID_FM_SHOW_PROPERTY_BROWSER, SFX_CALLMODE_ASYNCHRON,
     983 [ #  # ][ #  # ]:          0 :                                       &aIFaceItem, &aShowItem, 0L );
                 [ #  # ]
     984                 :            :         }
     985                 :          0 :     }
     986                 :          0 : }
     987                 :            : 
     988                 :            : //------------------------------------------------------------------------------
     989                 :          0 : void FmGridHeader::triggerColumnContextMenu( const ::Point& _rPreferredPos )
     990                 :            : {
     991                 :            :     // the affected col
     992         [ #  # ]:          0 :     sal_uInt16 nColId = GetItemId( _rPreferredPos );
     993                 :            : 
     994                 :            :     // the menu
     995 [ #  # ][ #  # ]:          0 :     PopupMenu aContextMenu( SVX_RES( RID_SVXMNU_COLS ) );
     996                 :            : 
     997                 :            :     // let derivees modify the menu
     998         [ #  # ]:          0 :     PreExecuteColumnContextMenu( nColId, aContextMenu );
     999         [ #  # ]:          0 :     aContextMenu.RemoveDisabledEntries( sal_True, sal_True );
    1000                 :            : 
    1001                 :            :     // execute the menu
    1002         [ #  # ]:          0 :     sal_uInt16 nResult = aContextMenu.Execute( this, _rPreferredPos );
    1003                 :            : 
    1004                 :            :     // let derivees handle the result
    1005 [ #  # ][ #  # ]:          0 :     PostExecuteColumnContextMenu( nColId, aContextMenu, nResult );
    1006                 :          0 : }
    1007                 :            : 
    1008                 :            : //------------------------------------------------------------------------------
    1009                 :          0 : void FmGridHeader::Command(const CommandEvent& rEvt)
    1010                 :            : {
    1011         [ #  # ]:          0 :     switch (rEvt.GetCommand())
    1012                 :            :     {
    1013                 :            :         case COMMAND_CONTEXTMENU:
    1014                 :            :         {
    1015         [ #  # ]:          0 :             if (!rEvt.IsMouseEvent())
    1016                 :          0 :                 return;
    1017                 :            : 
    1018                 :          0 :             triggerColumnContextMenu( rEvt.GetMousePosPixel() );
    1019                 :            :         }
    1020                 :          0 :         break;
    1021                 :            :         default:
    1022                 :          0 :             EditBrowserHeader::Command(rEvt);
    1023                 :            :     }
    1024                 :            : }
    1025                 :            : 
    1026                 :            : //------------------------------------------------------------------------------
    1027                 :         40 : FmGridControl::FmGridControl(
    1028                 :            :                 Reference< ::com::sun::star::lang::XMultiServiceFactory > _rxFactory,
    1029                 :            :                 Window* pParent,
    1030                 :            :                 FmXGridPeer* _pPeer,
    1031                 :            :                 WinBits nBits)
    1032                 :            :         :DbGridControl(_rxFactory, pParent, nBits)
    1033                 :            :         ,m_pPeer(_pPeer)
    1034                 :            :         ,m_nCurrentSelectedColumn(-1)
    1035                 :            :         ,m_nMarkedColumnId(BROWSER_INVALIDID)
    1036                 :            :         ,m_bSelecting(sal_False)
    1037         [ +  - ]:         40 :         ,m_bInColumnMove(sal_False)
    1038                 :            : {
    1039                 :         40 :     EnableInteractiveRowHeight( );
    1040                 :         40 : }
    1041                 :            : 
    1042                 :            : //------------------------------------------------------------------------------
    1043                 :          0 : void FmGridControl::Command(const CommandEvent& _rEvt)
    1044                 :            : {
    1045         [ #  # ]:          0 :     if ( COMMAND_CONTEXTMENU == _rEvt.GetCommand() )
    1046                 :            :     {
    1047                 :          0 :         FmGridHeader* pMyHeader = static_cast< FmGridHeader* >( GetHeaderBar() );
    1048 [ #  # ][ #  # ]:          0 :         if ( pMyHeader && !_rEvt.IsMouseEvent() )
                 [ #  # ]
    1049                 :            :         {   // context menu requested by keyboard
    1050 [ #  # ][ #  # ]:          0 :             if  ( 1 == GetSelectColumnCount() || IsDesignMode() )
                 [ #  # ]
    1051                 :            :             {
    1052                 :            :                 sal_uInt16 nSelId = GetColumnId(
    1053 [ #  # ][ #  # ]:          0 :                     sal::static_int_cast< sal_uInt16 >( FirstSelectedColumn() ) );
    1054         [ #  # ]:          0 :                 ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
    1055                 :            : 
    1056 [ #  # ][ #  # ]:          0 :                 Point aRelativePos( pMyHeader->ScreenToOutputPixel( OutputToScreenPixel( aColRect.TopCenter() ) ) );
                 [ #  # ]
    1057         [ #  # ]:          0 :                 pMyHeader->triggerColumnContextMenu( aRelativePos, FmGridHeader::AccessControl() );
    1058                 :            : 
    1059                 :            :                 // handled
    1060                 :          0 :                 return;
    1061                 :            :             }
    1062                 :            :         }
    1063                 :            :     }
    1064                 :            : 
    1065                 :          0 :     DbGridControl::Command( _rEvt );
    1066                 :            : }
    1067                 :            : 
    1068                 :            : // ::com::sun::star::beans::XPropertyChangeListener
    1069                 :            : //------------------------------------------------------------------------------
    1070                 :          0 : void FmGridControl::propertyChange(const ::com::sun::star::beans::PropertyChangeEvent& evt)
    1071                 :            : {
    1072 [ #  # ][ #  # ]:          0 :     if (evt.PropertyName == FM_PROP_ROWCOUNT)
    1073                 :            :     {
    1074                 :            :         // if we're not in the main thread call AdjustRows asynchronously
    1075         [ #  # ]:          0 :         implAdjustInSolarThread(sal_True);
    1076                 :          0 :         return;
    1077                 :            :     }
    1078                 :            : 
    1079                 :          0 :     const DbGridRowRef& xRow = GetCurrentRow();
    1080                 :            :     // waehrend Positionierung wird kein abgleich  der Properties vorgenommen
    1081         [ #  # ]:          0 :     Reference<XPropertySet> xSet(evt.Source,UNO_QUERY);
    1082 [ #  # ][ #  # ]:          0 :     if (xRow.Is() && (::cppu::any2bool(xSet->getPropertyValue(FM_PROP_ISNEW))|| CompareBookmark(getDataSource()->getBookmark(), xRow->GetBookmark())))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
             #  #  #  # ]
    1083                 :            :     {
    1084 [ #  # ][ #  # ]:          0 :         if (evt.PropertyName == FM_PROP_ISMODIFIED)
    1085                 :            :         {
    1086                 :            :             // modified or clean ?
    1087 [ #  # ][ #  # ]:          0 :             GridRowStatus eStatus = ::comphelper::getBOOL(evt.NewValue) ? GRS_MODIFIED : GRS_CLEAN;
    1088         [ #  # ]:          0 :             if (eStatus != xRow->GetStatus())
    1089                 :            :             {
    1090                 :          0 :                 xRow->SetStatus(eStatus);
    1091         [ #  # ]:          0 :                 SolarMutexGuard aGuard;
    1092 [ #  # ][ #  # ]:          0 :                 RowModified(GetCurrentPos());
    1093                 :            :             }
    1094                 :            :         }
    1095                 :          0 :     }
    1096                 :            : }
    1097                 :            : 
    1098                 :            : //------------------------------------------------------------------------------
    1099                 :         42 : void FmGridControl::SetDesignMode(sal_Bool bMode)
    1100                 :            : {
    1101                 :         42 :     sal_Bool bOldMode = IsDesignMode();
    1102                 :         42 :     DbGridControl::SetDesignMode(bMode);
    1103         [ +  - ]:         42 :     if (bOldMode != bMode)
    1104                 :            :     {
    1105         [ +  + ]:         42 :         if (!bMode)
    1106                 :            :         {
    1107                 :            :             // selection aufheben
    1108                 :          2 :             markColumn(USHRT_MAX);
    1109                 :            :         }
    1110                 :            :         else
    1111                 :            :         {
    1112         [ +  - ]:         40 :             Reference< ::com::sun::star::container::XIndexContainer >  xColumns(GetPeer()->getColumns());
    1113         [ +  - ]:         40 :             Reference< ::com::sun::star::view::XSelectionSupplier >  xSelSupplier(xColumns, UNO_QUERY);
    1114         [ +  - ]:         40 :             if (xSelSupplier.is())
    1115                 :            :             {
    1116 [ +  - ][ +  - ]:         40 :                 Any aSelection = xSelSupplier->getSelection();
    1117                 :         40 :                 Reference< ::com::sun::star::beans::XPropertySet >  xColumn;
    1118         [ +  - ]:         40 :                 if (aSelection.getValueType().getTypeClass() == TypeClass_INTERFACE)
    1119         [ +  - ]:         40 :                     ::cppu::extractInterface(xColumn, aSelection);
    1120                 :         40 :                 Reference< XInterface >  xCurrent;
    1121 [ +  - ][ +  - ]:         76 :                 for (sal_uInt16 i=0; i<xColumns->getCount(); ++i)
                 [ +  + ]
    1122                 :            :                 {
    1123 [ +  - ][ +  - ]:         36 :                     ::cppu::extractInterface(xCurrent, xColumns->getByIndex(i));
                 [ +  - ]
    1124 [ -  + ][ +  - ]:         36 :                     if (xCurrent == xColumn)
    1125                 :            :                     {
    1126 [ #  # ][ #  # ]:          0 :                         markColumn(GetColumnIdFromModelPos(i));
    1127                 :          0 :                         break;
    1128                 :            :                     }
    1129                 :         40 :                 }
    1130                 :         40 :             }
    1131                 :            :         }
    1132                 :            :     }
    1133                 :         42 : }
    1134                 :            : 
    1135                 :            : //------------------------------------------------------------------------------
    1136                 :          0 : void FmGridControl::DeleteSelectedRows()
    1137                 :            : {
    1138         [ #  # ]:          0 :     if (!m_pSeekCursor)
    1139                 :            :         return;
    1140                 :            : 
    1141                 :            :     // how many rows are selected?
    1142         [ #  # ]:          0 :     sal_Int32 nSelectedRows = GetSelectRowCount();
    1143                 :            : 
    1144                 :            :     // the current line should be deleted but it is currently in edit mode
    1145 [ #  # ][ #  # ]:          0 :     if ( IsCurrentAppending() )
    1146                 :            :         return;
    1147                 :            :     // is the insert row selected
    1148 [ #  # ][ #  # ]:          0 :     if (GetEmptyRow().Is() && IsRowSelected(GetRowCount() - 1))
         [ #  # ][ #  # ]
                 [ #  # ]
    1149                 :          0 :         nSelectedRows -= 1;
    1150                 :            : 
    1151                 :            :     // nothing to do
    1152         [ #  # ]:          0 :     if (nSelectedRows <= 0)
    1153                 :            :         return;
    1154                 :            : 
    1155                 :            :     // try to confirm the delete
    1156 [ #  # ][ #  # ]:          0 :     Reference< ::com::sun::star::frame::XDispatchProvider >  xDispatcher = (::com::sun::star::frame::XDispatchProvider*)GetPeer();
    1157         [ #  # ]:          0 :     if (xDispatcher.is())
    1158                 :            :     {
    1159                 :          0 :         ::com::sun::star::util::URL aUrl;
    1160         [ #  # ]:          0 :         aUrl.Complete = FMURL_CONFIRM_DELETION;
    1161                 :            :         // #100312# ------------
    1162                 :            :         Reference< ::com::sun::star::util::XURLTransformer > xTransformer(
    1163 [ #  # ][ #  # ]:          0 :             ::com::sun::star::util::URLTransformer::create(::comphelper::getProcessComponentContext()) );
    1164 [ #  # ][ #  # ]:          0 :         xTransformer->parseStrict( aUrl );
    1165                 :            : 
    1166 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::frame::XDispatch >  xDispatch = xDispatcher->queryDispatch(aUrl, rtl::OUString(), 0);
    1167         [ #  # ]:          0 :         Reference< ::com::sun::star::form::XConfirmDeleteListener >  xConfirm(xDispatch, UNO_QUERY);
    1168         [ #  # ]:          0 :         if (xConfirm.is())
    1169                 :            :         {
    1170         [ #  # ]:          0 :             ::com::sun::star::sdb::RowChangeEvent aEvent;
    1171         [ #  # ]:          0 :             aEvent.Source = (Reference< XInterface > )(*getDataSource());
    1172                 :          0 :             aEvent.Rows = nSelectedRows;
    1173                 :          0 :             aEvent.Action = ::com::sun::star::sdb::RowChangeAction::DELETE;
    1174 [ #  # ][ #  # ]:          0 :             if (!xConfirm->confirmDelete(aEvent))
                 [ #  # ]
    1175 [ #  # ][ #  # ]:          0 :                 return;
    1176 [ #  # ][ #  # ]:          0 :         }
         [ #  # ][ #  # ]
    1177                 :            :     }
    1178                 :            : 
    1179                 :          0 :     const MultiSelection* pRowSelection = GetSelection();
    1180 [ #  # ][ #  # ]:          0 :     if ( pRowSelection && pRowSelection->IsAllSelected() )
                 [ #  # ]
    1181                 :            :     {
    1182         [ #  # ]:          0 :         BeginCursorAction();
    1183                 :          0 :         CursorWrapper* pCursor = getDataSource();
    1184 [ #  # ][ #  # ]:          0 :         Reference< XResultSetUpdate >  xUpdateCursor((Reference< XInterface >)*pCursor, UNO_QUERY);
    1185                 :            :         try
    1186                 :            :         {
    1187         [ #  # ]:          0 :             pCursor->beforeFirst();
    1188 [ #  # ][ #  # ]:          0 :             while( pCursor->next() )
    1189 [ #  # ][ #  # ]:          0 :                 xUpdateCursor->deleteRow();
    1190                 :            : 
    1191         [ #  # ]:          0 :             SetUpdateMode(sal_False);
    1192         [ #  # ]:          0 :             SetNoSelection();
    1193                 :            : 
    1194 [ #  # ][ #  # ]:          0 :             xUpdateCursor->moveToInsertRow();
    1195                 :            :         }
    1196         [ #  # ]:          0 :         catch(const Exception&)
    1197                 :            :         {
    1198                 :            :             OSL_FAIL("Exception caught while deleting rows!");
    1199                 :            :         }
    1200                 :            :         // An den DatenCursor anpassen
    1201         [ #  # ]:          0 :         AdjustDataSource(sal_True);
    1202         [ #  # ]:          0 :         EndCursorAction();
    1203         [ #  # ]:          0 :         SetUpdateMode(sal_True);
    1204                 :            :     }
    1205                 :            :     else
    1206                 :            :     {
    1207         [ #  # ]:          0 :         Reference< ::com::sun::star::sdbcx::XDeleteRows >  xDeleteThem((Reference< XInterface >)*getDataSource(), UNO_QUERY);
    1208                 :            : 
    1209                 :            :         // colect the bookmarks of the selected rows
    1210         [ #  # ]:          0 :         Sequence < Any> aBookmarks = getSelectionBookmarks();
    1211                 :            : 
    1212                 :            :         // determine the next row to position after deletion
    1213                 :          0 :         Any aBookmark;
    1214                 :          0 :         sal_Bool bNewPos = sal_False;
    1215                 :            :         // if the current row isn't selected we take the row as row after deletion
    1216                 :            :         OSL_ENSURE( GetCurrentRow().Is(), "FmGridControl::DeleteSelectedRows: no current row here?" );
    1217                 :            :             // crash reports suggest it can happen we don't have a current row - how?
    1218                 :            :             // #154303# / 2008-04-23 / frank.schoenheit@sun.com
    1219 [ #  # ][ #  # ]:          0 :         if ( !IsRowSelected( GetCurrentPos() ) && !IsCurrentAppending() && GetCurrentRow().Is() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1220                 :            :         {
    1221                 :          0 :             aBookmark = GetCurrentRow()->GetBookmark();
    1222                 :          0 :             bNewPos   = sal_True;
    1223                 :            :         }
    1224                 :            :         else
    1225                 :            :         {
    1226                 :            :             // we look for the first row after the selected block for selection
    1227         [ #  # ]:          0 :             long nIdx = LastSelectedRow() + 1;
    1228 [ #  # ][ #  # ]:          0 :             if (nIdx < GetRowCount() - 1)
    1229                 :            :             {
    1230                 :            :                 // there is a next row to position on
    1231 [ #  # ][ #  # ]:          0 :                 if (SeekCursor(nIdx))
    1232                 :            :                 {
    1233         [ #  # ]:          0 :                     GetSeekRow()->SetState(m_pSeekCursor, sal_True);
    1234                 :            : 
    1235                 :          0 :                     bNewPos = sal_True;
    1236                 :            :                     // if it's not the row for inserting we keep the bookmark
    1237 [ #  # ][ #  # ]:          0 :                     if (!IsInsertionRow(nIdx))
    1238         [ #  # ]:          0 :                         aBookmark = m_pSeekCursor->getBookmark();
    1239                 :            :                 }
    1240                 :            :             }
    1241                 :            :             else
    1242                 :            :             {
    1243                 :            :                 // we look for the first row before the selected block for selection after deletion
    1244         [ #  # ]:          0 :                 nIdx = FirstSelectedRow() - 1;
    1245 [ #  # ][ #  # ]:          0 :                 if (nIdx >= 0 && SeekCursor(nIdx))
         [ #  # ][ #  # ]
    1246                 :            :                 {
    1247         [ #  # ]:          0 :                     GetSeekRow()->SetState(m_pSeekCursor, sal_True);
    1248                 :            : 
    1249                 :          0 :                     bNewPos = sal_True;
    1250         [ #  # ]:          0 :                     aBookmark = m_pSeekCursor->getBookmark();
    1251                 :            :                 }
    1252                 :            :             }
    1253                 :            :         }
    1254                 :            : 
    1255                 :            :         // Sind alle Zeilen Selectiert
    1256                 :            :         // Zweite bedingung falls keine einguegeZeile existiert
    1257 [ #  # ][ #  # ]:          0 :         sal_Bool bAllSelected = GetTotalCount() == nSelectedRows || GetRowCount() == nSelectedRows;
                 [ #  # ]
    1258                 :            : 
    1259         [ #  # ]:          0 :         BeginCursorAction();
    1260                 :            : 
    1261                 :            :         // now delete the row
    1262         [ #  # ]:          0 :         Sequence <sal_Int32> aDeletedRows;
    1263         [ #  # ]:          0 :         SetUpdateMode( sal_False );
    1264                 :            :         try
    1265                 :            :         {
    1266 [ #  # ][ #  # ]:          0 :             aDeletedRows = xDeleteThem->deleteRows(aBookmarks);
         [ #  # ][ #  # ]
                 [ #  # ]
    1267                 :            :         }
    1268         [ #  # ]:          0 :         catch(SQLException&)
    1269                 :            :         {
    1270                 :            :         }
    1271         [ #  # ]:          0 :         SetUpdateMode( sal_True );
    1272                 :            : 
    1273                 :            :         // how many rows are deleted?
    1274                 :          0 :         sal_Int32 nDeletedRows = 0;
    1275                 :          0 :         const sal_Int32* pSuccess = aDeletedRows.getConstArray();
    1276         [ #  # ]:          0 :         for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
    1277                 :            :         {
    1278         [ #  # ]:          0 :             if (pSuccess[i])
    1279                 :          0 :                 ++nDeletedRows;
    1280                 :            :         }
    1281                 :            : 
    1282                 :            :         // sind Zeilen geloescht worden?
    1283         [ #  # ]:          0 :         if (nDeletedRows)
    1284                 :            :         {
    1285         [ #  # ]:          0 :             SetUpdateMode(sal_False);
    1286         [ #  # ]:          0 :             SetNoSelection();
    1287                 :            :             try
    1288                 :            :             {
    1289                 :            :                 // did we delete all the rows than try to move to the next possible row
    1290         [ #  # ]:          0 :                 if (nDeletedRows == aDeletedRows.getLength())
    1291                 :            :                 {
    1292                 :            :                     // there exists a new position to move on
    1293         [ #  # ]:          0 :                     if (bNewPos)
    1294                 :            :                     {
    1295         [ #  # ]:          0 :                         if (aBookmark.hasValue())
    1296         [ #  # ]:          0 :                             getDataSource()->moveToBookmark(aBookmark);
    1297                 :            :                         // no valid bookmark so move to the insert row
    1298                 :            :                         else
    1299                 :            :                         {
    1300         [ #  # ]:          0 :                             Reference< XResultSetUpdate >  xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
    1301 [ #  # ][ #  # ]:          0 :                             xUpdateCursor->moveToInsertRow();
    1302                 :            :                         }
    1303                 :            :                     }
    1304                 :            :                     else
    1305                 :            :                     {
    1306         [ #  # ]:          0 :                         Reference< ::com::sun::star::beans::XPropertySet >  xSet((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
    1307                 :            : 
    1308                 :          0 :                         sal_Int32 nRecordCount(0);
    1309 [ #  # ][ #  # ]:          0 :                         xSet->getPropertyValue(FM_PROP_ROWCOUNT) >>= nRecordCount;
                 [ #  # ]
    1310 [ #  # ][ #  # ]:          0 :                         if ( m_pDataCursor->rowDeleted() )
    1311                 :          0 :                             --nRecordCount;
    1312                 :            : 
    1313                 :            :                         // there are no rows left and we have an insert row
    1314 [ #  # ][ #  # ]:          0 :                         if (!nRecordCount && GetEmptyRow().Is())
                 [ #  # ]
    1315                 :            :                         {
    1316         [ #  # ]:          0 :                             Reference< XResultSetUpdate >  xUpdateCursor((Reference< XInterface >)*m_pDataCursor, UNO_QUERY);
    1317 [ #  # ][ #  # ]:          0 :                             xUpdateCursor->moveToInsertRow();
    1318                 :            :                         }
    1319         [ #  # ]:          0 :                         else if (nRecordCount)
    1320                 :            :                             // move to the first row
    1321 [ #  # ][ #  # ]:          0 :                             getDataSource()->first();
    1322                 :            :                     }
    1323                 :            :                 }
    1324                 :            :                 // not all the rows where deleted, so move to the first row which remained in the resultset
    1325                 :            :                 else
    1326                 :            :                 {
    1327         [ #  # ]:          0 :                     for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
    1328                 :            :                     {
    1329         [ #  # ]:          0 :                         if (!pSuccess[i])
    1330                 :            :                         {
    1331         [ #  # ]:          0 :                             getDataSource()->moveToBookmark(aBookmarks.getConstArray()[i]);
    1332                 :          0 :                             break;
    1333                 :            :                         }
    1334                 :            :                     }
    1335                 :            :                 }
    1336                 :            :             }
    1337   [ #  #  #  # ]:          0 :             catch(const Exception&)
    1338                 :            :             {
    1339                 :            :                 try
    1340                 :            :                 {
    1341                 :            :                     // positioning went wrong so try to move to the first row
    1342         [ #  # ]:          0 :                     getDataSource()->first();
    1343                 :            :                 }
    1344         [ #  # ]:          0 :                 catch(const Exception&)
    1345                 :            :                 {
    1346                 :            :                 }
    1347                 :            :             }
    1348                 :            : 
    1349                 :            :             // An den DatenCursor anpassen
    1350         [ #  # ]:          0 :             AdjustDataSource(sal_True);
    1351                 :            : 
    1352                 :            :             // es konnten nicht alle Zeilen geloescht werden
    1353                 :            :             // da nie nicht geloeschten wieder selektieren
    1354         [ #  # ]:          0 :             if (nDeletedRows < nSelectedRows)
    1355                 :            :             {
    1356                 :            :                 // waren alle selektiert
    1357         [ #  # ]:          0 :                 if (bAllSelected)
    1358                 :            :                 {
    1359         [ #  # ]:          0 :                     SelectAll();
    1360 [ #  # ][ #  # ]:          0 :                     if (IsInsertionRow(GetRowCount() - 1))  // einfuegeZeile nicht
                 [ #  # ]
    1361 [ #  # ][ #  # ]:          0 :                         SelectRow(GetRowCount() - 1, sal_False);
    1362                 :            :                 }
    1363                 :            :                 else
    1364                 :            :                 {
    1365                 :            :                     // select the remaining rows
    1366         [ #  # ]:          0 :                     for (sal_Int32 i = 0; i < aDeletedRows.getLength(); i++)
    1367                 :            :                     {
    1368                 :            :                         try
    1369                 :            :                         {
    1370         [ #  # ]:          0 :                             if (!pSuccess[i])
    1371                 :            :                             {
    1372 [ #  # ][ #  # ]:          0 :                                 m_pSeekCursor->moveToBookmark(m_pDataCursor->getBookmark());
    1373         [ #  # ]:          0 :                                 SetSeekPos(m_pSeekCursor->getRow() - 1);
    1374         [ #  # ]:          0 :                                 SelectRow(GetSeekPos());
    1375                 :            :                             }
    1376                 :            :                         }
    1377   [ #  #  #  #  :          0 :                         catch(const Exception&)
                   #  # ]
    1378                 :            :                         {
    1379                 :            :                             // keep the seekpos in all cases
    1380         [ #  # ]:          0 :                             SetSeekPos(m_pSeekCursor->getRow() - 1);
    1381                 :            :                         }
    1382                 :            :                     }
    1383                 :            :                 }
    1384                 :            :             }
    1385                 :            : 
    1386         [ #  # ]:          0 :             EndCursorAction();
    1387         [ #  # ]:          0 :             SetUpdateMode(sal_True);
    1388                 :            :         }
    1389                 :            :         else // Zeile konnte nicht geloescht werden
    1390                 :            :         {
    1391         [ #  # ]:          0 :             EndCursorAction();
    1392                 :            :             try
    1393                 :            :             {
    1394                 :            :                 // currentrow is the insert row?
    1395 [ #  # ][ #  # ]:          0 :                 if (!IsCurrentAppending())
    1396         [ #  # ]:          0 :                     getDataSource()->refreshRow();
    1397                 :            :             }
    1398         [ #  # ]:          0 :             catch(const Exception&)
    1399                 :            :             {
    1400                 :            :             }
    1401 [ #  # ][ #  # ]:          0 :         }
    1402                 :            :     }
    1403                 :            : 
    1404                 :            :     // if there is no selection anymore we can start editing
    1405 [ #  # ][ #  # ]:          0 :     if (!GetSelectRowCount())
    1406 [ #  # ][ #  # ]:          0 :         ActivateCell();
    1407                 :            : }
    1408                 :            : 
    1409                 :            : 
    1410                 :            : // XCurrentRecordListener
    1411                 :            : //------------------------------------------------------------------------------
    1412                 :          0 : void FmGridControl::positioned(const ::com::sun::star::lang::EventObject& /*rEvent*/)
    1413                 :            : {
    1414                 :            :     TRACE_RANGE("FmGridControl::positioned");
    1415                 :            :     // position on the data source (force it to be done in the main thread)
    1416                 :          0 :     implAdjustInSolarThread(sal_False);
    1417                 :          0 : }
    1418                 :            : 
    1419                 :            : //------------------------------------------------------------------------------
    1420                 :          0 : sal_Bool FmGridControl::commit()
    1421                 :            : {
    1422                 :            :     // Commit nur ausfuehren, wenn nicht bereits ein Update vom ::com::sun::star::form::component::GridControl ausgefuehrt
    1423                 :            :     // wird
    1424         [ #  # ]:          0 :     if (!IsUpdating())
    1425                 :            :     {
    1426 [ #  # ][ #  # ]:          0 :         if (Controller().Is() && Controller()->IsModified())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  #  
                   #  # ]
    1427                 :            :         {
    1428         [ #  # ]:          0 :             if (!SaveModified())
    1429                 :          0 :                 return sal_False;
    1430                 :            :         }
    1431                 :            :     }
    1432                 :          0 :     return sal_True;
    1433                 :            : }
    1434                 :            : 
    1435                 :            : //------------------------------------------------------------------------------
    1436                 :          0 : void FmGridControl::inserted(const ::com::sun::star::lang::EventObject& /*rEvent*/)
    1437                 :            : {
    1438                 :          0 :     const DbGridRowRef& xRow = GetCurrentRow();
    1439         [ #  # ]:          0 :     if (!xRow.Is())
    1440                 :          0 :         return;
    1441                 :            : 
    1442                 :            :     // Zeile ist eingefuegt worden, dann den status und mode zuruecksetzen
    1443                 :          0 :     xRow->SetState(m_pDataCursor, sal_False);
    1444                 :          0 :     xRow->SetNew(sal_False);
    1445                 :            : 
    1446                 :            : }
    1447                 :            : 
    1448                 :            : //------------------------------------------------------------------------------
    1449                 :          0 : BrowserHeader* FmGridControl::imp_CreateHeaderBar(BrowseBox* pParent)
    1450                 :            : {
    1451                 :            :     DBG_ASSERT( pParent == this, "FmGridControl::imp_CreateHeaderBar: parent?" );
    1452         [ #  # ]:          0 :     return new FmGridHeader( pParent );
    1453                 :            : }
    1454                 :            : 
    1455                 :            : //------------------------------------------------------------------------------
    1456                 :         42 : void FmGridControl::markColumn(sal_uInt16 nId)
    1457                 :            : {
    1458 [ +  - ][ -  + ]:         42 :     if (GetHeaderBar() && m_nMarkedColumnId != nId)
                 [ -  + ]
    1459                 :            :     {
    1460                 :            :         // deselektieren
    1461         [ #  # ]:          0 :         if (m_nMarkedColumnId != BROWSER_INVALIDID)
    1462                 :            :         {
    1463                 :          0 :             HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(m_nMarkedColumnId) & ~HIB_FLAT;
    1464                 :          0 :             GetHeaderBar()->SetItemBits(m_nMarkedColumnId, aBits);
    1465                 :            :         }
    1466                 :            : 
    1467                 :            : 
    1468         [ #  # ]:          0 :         if (nId != BROWSER_INVALIDID)
    1469                 :            :         {
    1470                 :          0 :             HeaderBarItemBits aBits = GetHeaderBar()->GetItemBits(nId) | HIB_FLAT;
    1471                 :          0 :             GetHeaderBar()->SetItemBits(nId, aBits);
    1472                 :            :         }
    1473                 :          0 :         m_nMarkedColumnId = nId;
    1474                 :            :     }
    1475                 :         42 : }
    1476                 :            : 
    1477                 :            : //------------------------------------------------------------------------------
    1478                 :          0 : sal_Bool FmGridControl::isColumnMarked(sal_uInt16 nId) const
    1479                 :            : {
    1480                 :          0 :     return m_nMarkedColumnId == nId;
    1481                 :            : }
    1482                 :            : 
    1483                 :            : //------------------------------------------------------------------------------
    1484                 :          0 : long FmGridControl::QueryMinimumRowHeight()
    1485                 :            : {
    1486                 :          0 :     long nMinimalLogicHeight = 20; // 0.2 cm
    1487         [ #  # ]:          0 :     long nMinimalPixelHeight = LogicToPixel( Point( 0, nMinimalLogicHeight ), MAP_10TH_MM ).Y();
    1488                 :          0 :     return CalcZoom( nMinimalPixelHeight );
    1489                 :            : }
    1490                 :            : 
    1491                 :            : //------------------------------------------------------------------------------
    1492                 :          0 : void FmGridControl::RowHeightChanged()
    1493                 :            : {
    1494         [ #  # ]:          0 :     DbGridControl::RowHeightChanged();
    1495                 :            : 
    1496 [ #  # ][ #  # ]:          0 :     Reference< XPropertySet > xModel( GetPeer()->getColumns(), UNO_QUERY );
    1497                 :            :     DBG_ASSERT( xModel.is(), "FmGridControl::RowHeightChanged: no model!" );
    1498         [ #  # ]:          0 :     if ( xModel.is() )
    1499                 :            :     {
    1500                 :            :         try
    1501                 :            :         {
    1502 [ #  # ][ #  # ]:          0 :             sal_Int32 nUnzoomedPixelHeight = CalcReverseZoom( GetDataRowHeight() );
    1503 [ #  # ][ #  # ]:          0 :             Any aProperty = makeAny( (sal_Int32)PixelToLogic( Point( 0, nUnzoomedPixelHeight ), MAP_10TH_MM ).Y() );
         [ #  # ][ #  # ]
    1504 [ #  # ][ #  # ]:          0 :             xModel->setPropertyValue( FM_PROP_ROWHEIGHT, aProperty );
         [ #  # ][ #  # ]
    1505                 :            :         }
    1506         [ #  # ]:          0 :         catch( const Exception& )
    1507                 :            :         {
    1508                 :            :             OSL_FAIL( "FmGridControl::RowHeightChanged: caught an exception!" );
    1509                 :            :         }
    1510                 :          0 :     }
    1511                 :          0 : }
    1512                 :            : 
    1513                 :            : //------------------------------------------------------------------------------
    1514                 :          0 : void FmGridControl::ColumnResized(sal_uInt16 nId)
    1515                 :            : {
    1516         [ #  # ]:          0 :     DbGridControl::ColumnResized(nId);
    1517                 :            : 
    1518                 :            :     // Wert ans model uebergeben
    1519 [ #  # ][ #  # ]:          0 :     DbGridColumn* pCol = DbGridControl::GetColumns().at( GetModelColumnPos(nId) );
    1520                 :          0 :     Reference< ::com::sun::star::beans::XPropertySet >  xColModel(pCol->getModel());
    1521         [ #  # ]:          0 :     if (xColModel.is())
    1522                 :            :     {
    1523                 :          0 :         Any aWidth;
    1524         [ #  # ]:          0 :         sal_Int32 nColumnWidth = GetColumnWidth(nId);
    1525         [ #  # ]:          0 :         nColumnWidth = CalcReverseZoom(nColumnWidth);
    1526                 :            :         // Umrechnen in 10THMM
    1527 [ #  # ][ #  # ]:          0 :         aWidth <<= (sal_Int32)PixelToLogic(Point(nColumnWidth,0),MAP_10TH_MM).X();
         [ #  # ][ #  # ]
    1528 [ #  # ][ #  # ]:          0 :         xColModel->setPropertyValue(FM_PROP_WIDTH, aWidth);
                 [ #  # ]
    1529                 :          0 :     }
    1530                 :          0 : }
    1531                 :            : 
    1532                 :            : //------------------------------------------------------------------------------
    1533                 :          0 : void FmGridControl::CellModified()
    1534                 :            : {
    1535                 :          0 :     DbGridControl::CellModified();
    1536                 :          0 :     GetPeer()->CellModified();
    1537                 :          0 : }
    1538                 :            : 
    1539                 :            : //------------------------------------------------------------------------------
    1540                 :          2 : void FmGridControl::BeginCursorAction()
    1541                 :            : {
    1542                 :          2 :     DbGridControl::BeginCursorAction();
    1543                 :          2 :     m_pPeer->stopCursorListening();
    1544                 :          2 : }
    1545                 :            : 
    1546                 :            : //------------------------------------------------------------------------------
    1547                 :          2 : void FmGridControl::EndCursorAction()
    1548                 :            : {
    1549                 :          2 :     m_pPeer->startCursorListening();
    1550                 :          2 :     DbGridControl::EndCursorAction();
    1551                 :          2 : }
    1552                 :            : 
    1553                 :            : //------------------------------------------------------------------------------
    1554                 :          0 : void FmGridControl::ColumnMoved(sal_uInt16 nId)
    1555                 :            : {
    1556                 :          0 :     m_bInColumnMove = sal_True;
    1557                 :            : 
    1558         [ #  # ]:          0 :     DbGridControl::ColumnMoved(nId);
    1559         [ #  # ]:          0 :     Reference< ::com::sun::star::container::XIndexContainer >  xColumns(GetPeer()->getColumns());
    1560                 :            : 
    1561         [ #  # ]:          0 :     if (xColumns.is())
    1562                 :            :     {
    1563                 :            :         // suchen der Spalte und verschieben im Model
    1564                 :            :         // ColumnPos holen
    1565 [ #  # ][ #  # ]:          0 :         DbGridColumn* pCol = DbGridControl::GetColumns().at( GetModelColumnPos(nId) );
    1566                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet >  xCol;
    1567                 :            : 
    1568                 :            :         // Einfuegen muß sich an den Column Positionen orientieren
    1569                 :            :         sal_Int32 i;
    1570                 :          0 :         Reference< XInterface > xCurrent;
    1571 [ #  # ][ #  # ]:          0 :         for (i = 0; !xCol.is() && i < xColumns->getCount(); i++)
         [ #  # ][ #  # ]
                 [ #  # ]
    1572                 :            :         {
    1573 [ #  # ][ #  # ]:          0 :             ::cppu::extractInterface(xCurrent, xColumns->getByIndex(i));
                 [ #  # ]
    1574 [ #  # ][ #  # ]:          0 :             if (xCurrent == pCol->getModel())
    1575                 :            :             {
    1576         [ #  # ]:          0 :                 xCol = pCol->getModel();
    1577                 :          0 :                 break;
    1578                 :            :             }
    1579                 :            :         }
    1580                 :            : 
    1581                 :            :         DBG_ASSERT(i < xColumns->getCount(), "Falscher ::com::sun::star::sdbcx::Index");
    1582 [ #  # ][ #  # ]:          0 :         xColumns->removeByIndex(i);
    1583                 :          0 :         Any aElement;
    1584         [ #  # ]:          0 :         aElement <<= xCol;
    1585 [ #  # ][ #  # ]:          0 :         xColumns->insertByIndex(GetModelColumnPos(nId), aElement);
                 [ #  # ]
    1586         [ #  # ]:          0 :         pCol->setModel(xCol);
    1587                 :            :         // if the column which is shown here is selected ...
    1588 [ #  # ][ #  # ]:          0 :         if ( isColumnSelected(nId,pCol) )
    1589         [ #  # ]:          0 :             markColumn(nId); // ... -> mark it
    1590                 :            :     }
    1591                 :            : 
    1592                 :          0 :     m_bInColumnMove = sal_False;
    1593                 :          0 : }
    1594                 :            : 
    1595                 :            : //------------------------------------------------------------------------------
    1596                 :         44 : void FmGridControl::InitColumnsByModels(const Reference< ::com::sun::star::container::XIndexContainer >& xColumns)
    1597                 :            : {
    1598                 :            :     // Spalten wieder neu setzen
    1599                 :            :     // wenn es nur eine HandleColumn gibt, dann nicht
    1600         [ +  + ]:         44 :     if (GetModelColCount())
    1601                 :            :     {
    1602         [ +  - ]:          2 :         RemoveColumns();
    1603         [ +  - ]:          2 :         InsertHandleColumn();
    1604                 :            :     }
    1605                 :            : 
    1606         [ +  + ]:         44 :     if (!xColumns.is())
    1607                 :         44 :         return;
    1608                 :            : 
    1609         [ +  - ]:         40 :     SetUpdateMode(sal_False);
    1610                 :            : 
    1611                 :            :     // Einfuegen mu� sich an den Column Positionen orientieren
    1612                 :            :     sal_Int32 i;
    1613                 :         40 :     Any aWidth;
    1614 [ +  - ][ +  - ]:         76 :     for (i = 0; i < xColumns->getCount(); ++i)
                 [ +  + ]
    1615                 :            :     {
    1616                 :         36 :         Reference< ::com::sun::star::beans::XPropertySet > xCol;
    1617 [ +  - ][ +  - ]:         36 :         ::cppu::extractInterface(xCol, xColumns->getByIndex(i));
                 [ +  - ]
    1618                 :            : 
    1619                 :            :         rtl::OUString aName(
    1620 [ +  - ][ +  - ]:         36 :             comphelper::getString(xCol->getPropertyValue(FM_PROP_LABEL)));
         [ +  - ][ +  - ]
    1621                 :            : 
    1622 [ +  - ][ +  - ]:         36 :         aWidth = xCol->getPropertyValue(FM_PROP_WIDTH);
                 [ +  - ]
    1623                 :         36 :         sal_Int32 nWidth = 0;
    1624         [ -  + ]:         36 :         if (aWidth >>= nWidth)
    1625 [ #  # ][ #  # ]:          0 :             nWidth = LogicToPixel(Point(nWidth,0),MAP_10TH_MM).X();
                 [ #  # ]
    1626                 :            : 
    1627 [ +  - ][ +  - ]:         36 :         AppendColumn(aName, (sal_uInt16)nWidth);
                 [ +  - ]
    1628         [ +  - ]:         36 :         DbGridColumn* pCol = DbGridControl::GetColumns().at( i );
    1629         [ +  - ]:         36 :         pCol->setModel(xCol);
    1630                 :         36 :     }
    1631                 :            : 
    1632                 :            :     // und jetzt noch die hidden columns rausnehmen
    1633                 :            :     // (wir haben das nicht gleich in der oberen Schleife gemacht, da wir dann Probleme mit den
    1634                 :            :     // IDs der Spalten bekommen haetten : AppendColumn vergibt die automatisch, die Spalte _nach_
    1635                 :            :     // einer versteckten braucht aber eine um eine erhoehte ID ....
    1636                 :         40 :     Any aHidden;
    1637 [ +  - ][ +  - ]:         76 :     for (i = 0; i < xColumns->getCount(); ++i)
                 [ +  + ]
    1638                 :            :     {
    1639                 :         36 :         Reference< ::com::sun::star::beans::XPropertySet > xCol;
    1640 [ +  - ][ +  - ]:         36 :         ::cppu::extractInterface(xCol, xColumns->getByIndex(i));
                 [ +  - ]
    1641 [ +  - ][ +  - ]:         36 :         aHidden = xCol->getPropertyValue(FM_PROP_HIDDEN);
                 [ +  - ]
    1642 [ -  + ][ +  - ]:         36 :         if (::comphelper::getBOOL(aHidden))
    1643 [ #  # ][ #  # ]:          0 :             HideColumn(GetColumnIdFromModelPos((sal_uInt16)i));
    1644                 :         36 :     }
    1645                 :            : 
    1646         [ +  - ]:         44 :     SetUpdateMode(sal_True);
    1647                 :            : }
    1648                 :            : 
    1649                 :            : //------------------------------------------------------------------------------
    1650                 :         62 : void FmGridControl::InitColumnByField(
    1651                 :            :     DbGridColumn* _pColumn, const Reference< XPropertySet >& _rxColumnModel,
    1652                 :            :     const Reference< XNameAccess >& _rxFieldsByNames, const Reference< XIndexAccess >& _rxFieldsByIndex )
    1653                 :            : {
    1654                 :            :     DBG_ASSERT( _rxFieldsByNames == _rxFieldsByIndex, "FmGridControl::InitColumnByField: invalid container interfaces!" );
    1655                 :            : 
    1656                 :            :     // lookup the column which belongs to the control source
    1657                 :         62 :     ::rtl::OUString sFieldName;
    1658 [ +  - ][ +  - ]:         62 :     _rxColumnModel->getPropertyValue( FM_PROP_CONTROLSOURCE ) >>= sFieldName;
                 [ +  - ]
    1659                 :         62 :     Reference< XPropertySet > xField;
    1660 [ +  - ][ +  - ]:         62 :     _rxColumnModel->getPropertyValue( FM_PROP_BOUNDFIELD ) >>= xField;
         [ +  - ][ +  - ]
    1661                 :            : 
    1662                 :            : 
    1663 [ #  # ][ #  # ]:         62 :     if ( !xField.is() && /*sFieldName.getLength() && */_rxFieldsByNames->hasByName( sFieldName ) ) // #i93452# do not check for name length
         [ #  # ][ -  + ]
                 [ -  + ]
    1664 [ #  # ][ #  # ]:          0 :         _rxFieldsByNames->getByName( sFieldName ) >>= xField;
                 [ #  # ]
    1665                 :            : 
    1666                 :            :     // determine the position of this column
    1667                 :         62 :     sal_Int32 nFieldPos = -1;
    1668         [ +  - ]:         62 :     if ( xField.is() )
    1669                 :            :     {
    1670                 :         62 :         Reference< XPropertySet > xCheck;
    1671 [ +  - ][ +  - ]:         62 :         sal_Int32 nFieldCount = _rxFieldsByIndex->getCount();
    1672         [ +  - ]:        992 :         for ( sal_Int32 i = 0; i < nFieldCount; ++i)
    1673                 :            :         {
    1674 [ +  - ][ +  - ]:        992 :             _rxFieldsByIndex->getByIndex( i ) >>= xCheck;
                 [ +  - ]
    1675 [ +  - ][ +  + ]:        992 :             if ( xField.get() == xCheck.get() )
                 [ +  - ]
    1676                 :            :             {
    1677                 :         62 :                 nFieldPos = i;
    1678                 :         62 :                 break;
    1679                 :            :             }
    1680                 :         62 :         }
    1681                 :            :     }
    1682                 :            : 
    1683 [ +  - ][ +  - ]:         62 :     if ( xField.is() && ( nFieldPos >= 0 ) )
                 [ +  - ]
    1684                 :            :     {
    1685                 :            :         // some data types are not allowed
    1686                 :         62 :         sal_Int32 nDataType = DataType::OTHER;
    1687 [ +  - ][ +  - ]:         62 :         xField->getPropertyValue( FM_PROP_FIELDTYPE ) >>= nDataType;
                 [ +  - ]
    1688                 :            : 
    1689                 :         62 :         sal_Bool bIllegalType = sal_False;
    1690         [ -  + ]:         62 :         switch ( nDataType )
    1691                 :            :         {
    1692                 :            :             case DataType::BLOB:
    1693                 :            :             case DataType::LONGVARBINARY:
    1694                 :            :             case DataType::BINARY:
    1695                 :            :             case DataType::VARBINARY:
    1696                 :            :             case DataType::OTHER:
    1697                 :          0 :                 bIllegalType = sal_True;
    1698                 :          0 :                 break;
    1699                 :            :         }
    1700                 :            : 
    1701         [ -  + ]:         62 :         if ( bIllegalType )
    1702                 :            :         {
    1703                 :         62 :             _pColumn->SetObject( (sal_Int16)nFieldPos );
    1704                 :            :             return;
    1705                 :            :         }
    1706                 :            :     }
    1707                 :            : 
    1708                 :            :     // the control type is determined by the ColumnServiceName
    1709 [ +  + ][ +  - ]:         62 :     static ::rtl::OUString s_sPropColumnServiceName( RTL_CONSTASCII_USTRINGPARAM( "ColumnServiceName" ) );
         [ +  - ][ #  # ]
    1710 [ +  - ][ +  - ]:         62 :     if ( !::comphelper::hasProperty( s_sPropColumnServiceName, _rxColumnModel ) )
    1711                 :            :         return;
    1712                 :            : 
    1713         [ +  - ]:         62 :     _pColumn->setModel( _rxColumnModel );
    1714                 :            : 
    1715                 :         62 :     ::rtl::OUString sColumnServiceName;
    1716 [ +  - ][ +  - ]:         62 :     _rxColumnModel->getPropertyValue( s_sPropColumnServiceName ) >>= sColumnServiceName;
    1717                 :            : 
    1718         [ +  - ]:         62 :     sal_Int32 nTypeId = getColumnTypeByModelName( sColumnServiceName );
    1719 [ +  - ][ -  + ]:         62 :     _pColumn->CreateControl( nFieldPos, xField, nTypeId );
                 [ +  - ]
    1720                 :            : }
    1721                 :            : 
    1722                 :            : //------------------------------------------------------------------------------
    1723                 :          2 : void FmGridControl::InitColumnsByFields(const Reference< ::com::sun::star::container::XIndexAccess >& _rxFields)
    1724                 :            : {
    1725         [ +  - ]:          2 :     if ( !_rxFields.is() )
    1726                 :          2 :         return;
    1727                 :            : 
    1728                 :            :     // Spalten initialisieren
    1729         [ +  - ]:          2 :     Reference< XIndexContainer > xColumns( GetPeer()->getColumns() );
    1730         [ +  - ]:          2 :     Reference< XNameAccess > xFieldsAsNames( _rxFields, UNO_QUERY );
    1731                 :            : 
    1732                 :            :     // Einfuegen muss sich an den Column Positionen orientieren
    1733 [ +  - ][ +  - ]:         64 :     for (sal_Int32 i = 0; i < xColumns->getCount(); i++)
                 [ +  + ]
    1734                 :            :     {
    1735         [ +  - ]:         62 :         DbGridColumn* pCol = GetColumns().at( i );
    1736                 :            :         OSL_ENSURE(pCol,"No grid column!");
    1737         [ +  - ]:         62 :         if ( pCol )
    1738                 :            :         {
    1739                 :         62 :             Reference< XPropertySet > xColumnModel;
    1740 [ +  - ][ +  - ]:         62 :             ::cppu::extractInterface( xColumnModel, xColumns->getByIndex( i ) );
                 [ +  - ]
    1741                 :            : 
    1742         [ +  - ]:         62 :             InitColumnByField( pCol, xColumnModel, xFieldsAsNames, _rxFields );
    1743                 :            :         }
    1744                 :          2 :     }
    1745                 :            : }
    1746                 :            : 
    1747                 :            : //------------------------------------------------------------------------------
    1748                 :          0 : void FmGridControl::HideColumn(sal_uInt16 nId)
    1749                 :            : {
    1750                 :          0 :     DbGridControl::HideColumn(nId);
    1751                 :            : 
    1752                 :          0 :     sal_uInt16 nPos = GetModelColumnPos(nId);
    1753         [ #  # ]:          0 :     if (nPos == (sal_uInt16)-1)
    1754                 :          0 :         return;
    1755                 :            : 
    1756                 :          0 :     DbGridColumn* pColumn = GetColumns().at( nPos );
    1757         [ #  # ]:          0 :     if (pColumn->IsHidden())
    1758                 :          0 :         GetPeer()->columnHidden(pColumn);
    1759                 :            : 
    1760         [ #  # ]:          0 :     if (nId == m_nMarkedColumnId)
    1761                 :          0 :         m_nMarkedColumnId = (sal_uInt16)-1;
    1762                 :            : }
    1763                 :            : // -----------------------------------------------------------------------------
    1764                 :          0 : sal_Bool FmGridControl::isColumnSelected(sal_uInt16 /*nId*/,DbGridColumn* _pColumn)
    1765                 :            : {
    1766                 :            :     OSL_ENSURE(_pColumn,"Column can not be null!");
    1767                 :          0 :     sal_Bool bSelected = sal_False;
    1768                 :            :     // if the column which is shown here is selected ...
    1769 [ #  # ][ #  # ]:          0 :     Reference< ::com::sun::star::view::XSelectionSupplier >  xSelSupplier(GetPeer()->getColumns(), UNO_QUERY);
    1770         [ #  # ]:          0 :     if ( xSelSupplier.is() )
    1771                 :            :     {
    1772                 :          0 :         Reference< ::com::sun::star::beans::XPropertySet >  xColumn;
    1773 [ #  # ][ #  # ]:          0 :         xSelSupplier->getSelection() >>= xColumn;
                 [ #  # ]
    1774 [ #  # ][ #  # ]:          0 :         bSelected = (xColumn.get() == _pColumn->getModel().get());
    1775                 :            :     }
    1776                 :          0 :     return bSelected;
    1777                 :            : }
    1778                 :            : 
    1779                 :            : //------------------------------------------------------------------------------
    1780                 :          0 : void FmGridControl::ShowColumn(sal_uInt16 nId)
    1781                 :            : {
    1782                 :          0 :     DbGridControl::ShowColumn(nId);
    1783                 :            : 
    1784                 :          0 :     sal_uInt16 nPos = GetModelColumnPos(nId);
    1785         [ #  # ]:          0 :     if (nPos == (sal_uInt16)-1)
    1786                 :          0 :         return;
    1787                 :            : 
    1788                 :          0 :     DbGridColumn* pColumn = GetColumns().at( nPos );
    1789         [ #  # ]:          0 :     if (!pColumn->IsHidden())
    1790                 :          0 :         GetPeer()->columnVisible(pColumn);
    1791                 :            : 
    1792                 :            :     // if the column which is shown here is selected ...
    1793         [ #  # ]:          0 :     if ( isColumnSelected(nId,pColumn) )
    1794                 :          0 :         markColumn(nId); // ... -> mark it
    1795                 :            : }
    1796                 :            : 
    1797                 :            : //------------------------------------------------------------------------------
    1798                 :          0 : sal_Bool FmGridControl::selectBookmarks(const Sequence< Any >& _rBookmarks)
    1799                 :            : {
    1800         [ #  # ]:          0 :     SolarMutexGuard aGuard;
    1801                 :            :         // need to lock the SolarMutex so that no paint call disturbs us ...
    1802                 :            : 
    1803         [ #  # ]:          0 :     if ( !m_pSeekCursor )
    1804                 :            :     {
    1805                 :            :         OSL_FAIL( "FmGridControl::selectBookmarks: no seek cursor!" );
    1806                 :          0 :         return sal_False;
    1807                 :            :     }
    1808                 :            : 
    1809                 :          0 :     const Any* pBookmark = _rBookmarks.getConstArray();
    1810                 :          0 :     const Any* pBookmarkEnd = pBookmark + _rBookmarks.getLength();
    1811                 :            : 
    1812         [ #  # ]:          0 :     SetNoSelection();
    1813                 :            : 
    1814                 :          0 :     sal_Bool bAllSuccessfull = sal_True;
    1815                 :            :     try
    1816                 :            :     {
    1817         [ #  # ]:          0 :         for (; pBookmark != pBookmarkEnd; ++pBookmark)
    1818                 :            :         {
    1819                 :            :             // move the seek cursor to the row given
    1820 [ #  # ][ #  # ]:          0 :             if (m_pSeekCursor->moveToBookmark(*pBookmark))
    1821 [ #  # ][ #  # ]:          0 :                 SelectRow( m_pSeekCursor->getRow() - 1);
    1822                 :            :             else
    1823                 :          0 :                 bAllSuccessfull = sal_False;
    1824                 :            :         }
    1825                 :            :     }
    1826         [ #  # ]:          0 :     catch(Exception&)
    1827                 :            :     {
    1828                 :            :         OSL_FAIL("FmGridControl::selectBookmarks: could not move to one of the bookmarks!");
    1829                 :          0 :         return sal_False;
    1830                 :            :     }
    1831                 :            : 
    1832 [ #  # ][ #  # ]:          0 :     return bAllSuccessfull;
    1833                 :            : }
    1834                 :            : 
    1835                 :            : //------------------------------------------------------------------------------
    1836                 :          0 : Sequence< Any> FmGridControl::getSelectionBookmarks()
    1837                 :            : {
    1838                 :            :     // lock our update so no paint-triggered seeks interfere ...
    1839                 :          0 :     SetUpdateMode(sal_False);
    1840                 :            : 
    1841                 :          0 :     sal_Int32 nSelectedRows = GetSelectRowCount(), i = 0;
    1842                 :          0 :     Sequence< Any> aBookmarks(nSelectedRows);
    1843         [ #  # ]:          0 :     if ( nSelectedRows )
    1844                 :            :     {
    1845         [ #  # ]:          0 :         Any* pBookmarks = (Any*)aBookmarks.getArray();
    1846                 :            : 
    1847                 :            :         // (I'm not sure if the problem isn't deeper : The szenario : a large table displayed by a grid with a
    1848                 :            :         // thread-safe cursor (dBase). On loading the sdb-cursor started a counting thread. While this counting progress
    1849                 :            :         // was running, I tried do delete 3 records from within the grid. Deletion caused a SeekCursor, which did a
    1850                 :            :         // m_pSeekCursor->moveRelative and a m_pSeekCursor->getPosition.
    1851                 :            :         // Unfortunally the first call caused a propertyChanged(RECORDCOUNT) which resulted in a repaint of the
    1852                 :            :         // navigation bar and the grid. The latter itself will result in SeekRow calls. So after (successfully) returning
    1853                 :            :         // from the moveRelative the getPosition returns an invalid value. And so the SeekCursor fails.
    1854                 :            :         // In the consequence ALL parts of code where two calls to the seek cursor are done, while the second call _relys_ on
    1855                 :            :         // the first one, should be secured against recursion, with a broad-minded interpretion of "recursion" : if any of these
    1856                 :            :         // code parts is executed, no other should be accessible. But this sounds very difficult to achieve ....
    1857                 :            :         // )
    1858                 :            : 
    1859                 :            :         // The next problem caused by the same behaviuor (SeekCursor causes a propertyChanged) : when adjusting rows we implicitly
    1860                 :            :         // change our selection. So a "FirstSelected(); SeekCursor(); NextSelected();" may produce unpredictable results.
    1861                 :            :         // That's why we _first_ collect the indicies of the selected rows and _then_ their bookmarks.
    1862         [ #  # ]:          0 :         long nIdx = FirstSelectedRow();
    1863         [ #  # ]:          0 :         while (nIdx >= 0)
    1864                 :            :         {
    1865                 :            :             // (we misuse the bookmarks array for this ...)
    1866         [ #  # ]:          0 :             pBookmarks[i++] <<= (sal_Int32)nIdx;
    1867         [ #  # ]:          0 :             nIdx = NextSelectedRow();
    1868                 :            :         }
    1869                 :            :         DBG_ASSERT(i == nSelectedRows, "FmGridControl::DeleteSelectedRows : could not collect the row indicies !");
    1870                 :            : 
    1871         [ #  # ]:          0 :         for (i=0; i<nSelectedRows; ++i)
    1872                 :            :         {
    1873         [ #  # ]:          0 :             nIdx = ::comphelper::getINT32(pBookmarks[i]);
    1874 [ #  # ][ #  # ]:          0 :             if (IsInsertionRow(nIdx))
    1875                 :            :             {
    1876                 :            :                 // leerzeile nicht loeschen
    1877         [ #  # ]:          0 :                 aBookmarks.realloc(--nSelectedRows);
    1878         [ #  # ]:          0 :                 SelectRow(nIdx,sal_False);          // selection aufheben fuer leerzeile
    1879                 :          0 :                 break;
    1880                 :            :             }
    1881                 :            : 
    1882                 :            :             // Zunaechst den DatenCursor auf den selektierten Satz pos.
    1883 [ #  # ][ #  # ]:          0 :             if (SeekCursor(nIdx))
    1884                 :            :             {
    1885         [ #  # ]:          0 :                 GetSeekRow()->SetState(m_pSeekCursor, sal_True);
    1886                 :            : 
    1887         [ #  # ]:          0 :                 pBookmarks[i] = m_pSeekCursor->getBookmark();
    1888                 :            :             }
    1889                 :            :     #ifdef DBG_UTIL
    1890                 :            :             else
    1891                 :            :                 OSL_FAIL("FmGridControl::DeleteSelectedRows : a bookmark could not be determined !");
    1892                 :            :     #endif
    1893                 :            :         }
    1894                 :            :     }
    1895         [ #  # ]:          0 :     SetUpdateMode(sal_True);
    1896                 :            : 
    1897                 :            :     // if one of the SeekCursor-calls failed ....
    1898         [ #  # ]:          0 :     aBookmarks.realloc(i);
    1899                 :            : 
    1900                 :            :     // (the alternative : while collecting the bookmarks lock our propertyChanged, this should resolve both our problems.
    1901                 :            :     // but this would be incompatible as we need a locking flag, then ...)
    1902                 :            : 
    1903                 :          0 :     return aBookmarks;
    1904                 :            : }
    1905                 :            : // -----------------------------------------------------------------------------
    1906                 :            : namespace
    1907                 :            : {
    1908                 :          0 :     ::rtl::OUString getColumnPropertyFromPeer(FmXGridPeer* _pPeer,sal_Int32 _nPosition,const ::rtl::OUString& _sPropName)
    1909                 :            :     {
    1910                 :          0 :         ::rtl::OUString sRetText;
    1911 [ #  # ][ #  # ]:          0 :         if ( _pPeer && _nPosition != -1)
    1912                 :            :         {
    1913         [ #  # ]:          0 :             Reference<XIndexContainer> xIndex = _pPeer->getColumns();
    1914 [ #  # ][ #  # ]:          0 :             if ( xIndex.is() && xIndex->getCount() > _nPosition )
         [ #  # ][ #  # ]
                 [ #  # ]
    1915                 :            :             {
    1916                 :          0 :                 Reference<XPropertySet> xProp;
    1917 [ #  # ][ #  # ]:          0 :                 xIndex->getByIndex( _nPosition ) >>= xProp;
                 [ #  # ]
    1918         [ #  # ]:          0 :                 if ( xProp.is() )
    1919 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue( _sPropName ) >>= sRetText;
    1920                 :          0 :             }
    1921                 :            :         }
    1922                 :          0 :         return sRetText;
    1923                 :            :     }
    1924                 :            : }
    1925                 :            : // Object data and state ------------------------------------------------------
    1926                 :          0 : ::rtl::OUString FmGridControl::GetAccessibleObjectName( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition ) const
    1927                 :            : {
    1928                 :          0 :     ::rtl::OUString sRetText;
    1929      [ #  #  # ]:          0 :     switch( _eObjType )
    1930                 :            :     {
    1931                 :            :         case ::svt::BBTYPE_BROWSEBOX:
    1932         [ #  # ]:          0 :             if ( GetPeer() )
    1933                 :            :             {
    1934 [ #  # ][ #  # ]:          0 :                 Reference<XPropertySet> xProp(GetPeer()->getColumns(),UNO_QUERY);
    1935         [ #  # ]:          0 :                 if ( xProp.is() )
    1936 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue(FM_PROP_NAME) >>= sRetText;
                 [ #  # ]
    1937                 :            :             }
    1938                 :          0 :             break;
    1939                 :            :         case ::svt::BBTYPE_COLUMNHEADERCELL:
    1940                 :            :             sRetText = getColumnPropertyFromPeer(
    1941                 :            :                 GetPeer(),
    1942                 :            :                 GetModelColumnPos(
    1943         [ #  # ]:          0 :                     sal::static_int_cast< sal_uInt16 >(_nPosition)),
    1944 [ #  # ][ #  # ]:          0 :                 FM_PROP_LABEL);
    1945                 :          0 :             break;
    1946                 :            :         default:
    1947         [ #  # ]:          0 :             sRetText = DbGridControl::GetAccessibleObjectName(_eObjType,_nPosition);
    1948                 :            :     }
    1949                 :          0 :     return sRetText;
    1950                 :            : }
    1951                 :            : // -----------------------------------------------------------------------------
    1952                 :            : 
    1953                 :          0 : ::rtl::OUString FmGridControl::GetAccessibleObjectDescription( ::svt::AccessibleBrowseBoxObjType _eObjType,sal_Int32 _nPosition ) const
    1954                 :            : {
    1955                 :          0 :     ::rtl::OUString sRetText;
    1956      [ #  #  # ]:          0 :     switch( _eObjType )
    1957                 :            :     {
    1958                 :            :         case ::svt::BBTYPE_BROWSEBOX:
    1959         [ #  # ]:          0 :             if ( GetPeer() )
    1960                 :            :             {
    1961 [ #  # ][ #  # ]:          0 :                 Reference<XPropertySet> xProp(GetPeer()->getColumns(),UNO_QUERY);
    1962         [ #  # ]:          0 :                 if ( xProp.is() )
    1963                 :            :                 {
    1964 [ #  # ][ #  # ]:          0 :                     xProp->getPropertyValue(FM_PROP_HELPTEXT) >>= sRetText;
                 [ #  # ]
    1965         [ #  # ]:          0 :                     if ( sRetText.isEmpty() )
    1966 [ #  # ][ #  # ]:          0 :                         xProp->getPropertyValue(FM_PROP_DESCRIPTION) >>= sRetText;
                 [ #  # ]
    1967                 :          0 :                 }
    1968                 :            :             }
    1969                 :          0 :             break;
    1970                 :            :         case ::svt::BBTYPE_COLUMNHEADERCELL:
    1971                 :            :             sRetText = getColumnPropertyFromPeer(
    1972                 :            :                 GetPeer(),
    1973                 :            :                 GetModelColumnPos(
    1974         [ #  # ]:          0 :                     sal::static_int_cast< sal_uInt16 >(_nPosition)),
    1975 [ #  # ][ #  # ]:          0 :                 FM_PROP_HELPTEXT);
    1976         [ #  # ]:          0 :             if ( sRetText.isEmpty() )
    1977                 :            :                 sRetText = getColumnPropertyFromPeer(
    1978                 :            :                             GetPeer(),
    1979                 :            :                             GetModelColumnPos(
    1980         [ #  # ]:          0 :                                 sal::static_int_cast< sal_uInt16 >(_nPosition)),
    1981 [ #  # ][ #  # ]:          0 :                             FM_PROP_DESCRIPTION);
    1982                 :            : 
    1983                 :          0 :             break;
    1984                 :            :         default:
    1985         [ #  # ]:          0 :             sRetText = DbGridControl::GetAccessibleObjectDescription(_eObjType,_nPosition);
    1986                 :            :     }
    1987                 :          0 :     return sRetText;
    1988                 :            : }
    1989                 :            : // -----------------------------------------------------------------------------
    1990                 :          0 : void FmGridControl::Select()
    1991                 :            : {
    1992                 :          0 :     DbGridControl::Select();
    1993                 :            :     // ... betrifft das unsere Spalten ?
    1994                 :          0 :     const MultiSelection* pColumnSelection = GetColumnSelection();
    1995                 :            : 
    1996                 :            :     sal_uInt16 nSelectedColumn =
    1997                 :          0 :         pColumnSelection && pColumnSelection->GetSelectCount()
    1998                 :            :             ? sal::static_int_cast< sal_uInt16 >(
    1999                 :          0 :                 ((MultiSelection*)pColumnSelection)->FirstSelected())
    2000   [ #  #  #  # ]:          0 :             : SAL_MAX_UINT16;
    2001                 :            :     // die HandleColumn wird nicht selektiert
    2002      [ #  #  # ]:          0 :     switch (nSelectedColumn)
    2003                 :            :     {
    2004                 :          0 :         case SAL_MAX_UINT16: break; // no selection
    2005                 :          0 :         case  0 : nSelectedColumn = SAL_MAX_UINT16; break;
    2006                 :            :                     // handle col can't be seledted
    2007                 :            :         default :
    2008                 :            :             // get the model col pos instead of the view col pos
    2009                 :          0 :             nSelectedColumn = GetModelColumnPos(GetColumnIdFromViewPos(nSelectedColumn - 1));
    2010                 :          0 :             break;
    2011                 :            :     }
    2012                 :            : 
    2013         [ #  # ]:          0 :     if (nSelectedColumn != m_nCurrentSelectedColumn)
    2014                 :            :     {
    2015                 :            :         // VOR dem Aufruf des select am SelectionSupplier !
    2016                 :          0 :         m_nCurrentSelectedColumn = nSelectedColumn;
    2017                 :            : 
    2018         [ #  # ]:          0 :         if (!m_bSelecting)
    2019                 :            :         {
    2020                 :          0 :             m_bSelecting = sal_True;
    2021                 :            : 
    2022                 :            :             try
    2023                 :            :             {
    2024 [ #  # ][ #  # ]:          0 :                 Reference< XIndexAccess >  xColumns(GetPeer()->getColumns(), UNO_QUERY);
    2025         [ #  # ]:          0 :                 Reference< XSelectionSupplier >  xSelSupplier(xColumns, UNO_QUERY);
    2026         [ #  # ]:          0 :                 if (xSelSupplier.is())
    2027                 :            :                 {
    2028         [ #  # ]:          0 :                     if (nSelectedColumn != SAL_MAX_UINT16)
    2029                 :            :                     {
    2030                 :          0 :                         Reference< XPropertySet >  xColumn;
    2031 [ #  # ][ #  # ]:          0 :                         ::cppu::extractInterface(xColumn,xColumns->getByIndex(nSelectedColumn));
                 [ #  # ]
    2032 [ #  # ][ #  # ]:          0 :                         xSelSupplier->select(makeAny(xColumn));
                 [ #  # ]
    2033                 :            :                     }
    2034                 :            :                     else
    2035                 :            :                     {
    2036 [ #  # ][ #  # ]:          0 :                         xSelSupplier->select(Any());
    2037                 :            :                     }
    2038         [ #  # ]:          0 :                 }
    2039                 :            :             }
    2040                 :          0 :             catch(Exception&)
    2041                 :            :             {
    2042                 :            :             }
    2043                 :            : 
    2044                 :            : 
    2045                 :          0 :             m_bSelecting = sal_False;
    2046                 :            :         }
    2047                 :            :     }
    2048                 :          0 : }
    2049                 :            : // -----------------------------------------------------------------------------
    2050                 :          0 : sal_Int32 FmGridControl::GetSelectedColumn() const
    2051                 :            : {
    2052                 :          0 :     return m_nCurrentSelectedColumn;
    2053                 :            : }
    2054                 :            : // -----------------------------------------------------------------------------
    2055                 :          0 : void FmGridControl::KeyInput( const KeyEvent& rKEvt )
    2056                 :            : {
    2057                 :          0 :     sal_Bool bDone = sal_False;
    2058                 :          0 :     const KeyCode& rKeyCode = rKEvt.GetKeyCode();
    2059 [ #  # ][ #  #  :          0 :     if (    IsDesignMode()
          #  #  #  #  #  
                #  #  # ]
    2060                 :          0 :         &&  !rKeyCode.IsShift()
    2061                 :          0 :         &&  !rKeyCode.IsMod1()
    2062                 :          0 :         &&  !rKeyCode.IsMod2()
    2063                 :          0 :         &&  GetParent() )
    2064                 :            :     {
    2065      [ #  #  # ]:          0 :         switch ( rKeyCode.GetCode() )
    2066                 :            :         {
    2067                 :            :             case KEY_ESCAPE:
    2068                 :          0 :                 GetParent()->GrabFocus();
    2069                 :          0 :                 bDone = sal_True;
    2070                 :          0 :                 break;
    2071                 :            :             case KEY_DELETE:
    2072 [ #  # ][ #  # ]:          0 :                 if ( GetSelectColumnCount() && GetPeer() && m_nCurrentSelectedColumn >= 0 )
         [ #  # ][ #  # ]
    2073                 :            :                 {
    2074         [ #  # ]:          0 :                     Reference< ::com::sun::star::container::XIndexContainer >  xCols(GetPeer()->getColumns());
    2075         [ #  # ]:          0 :                     if ( xCols.is() )
    2076                 :            :                     {
    2077                 :            :                         try
    2078                 :            :                         {
    2079 [ #  # ][ #  # ]:          0 :                             if ( m_nCurrentSelectedColumn < xCols->getCount() )
                 [ #  # ]
    2080                 :            :                             {
    2081                 :          0 :                                 Reference< XInterface >  xCol;
    2082 [ #  # ][ #  # ]:          0 :                                 xCols->getByIndex(m_nCurrentSelectedColumn) >>= xCol;
                 [ #  # ]
    2083 [ #  # ][ #  # ]:          0 :                                 xCols->removeByIndex(m_nCurrentSelectedColumn);
    2084 [ #  # ][ #  # ]:          0 :                                 ::comphelper::disposeComponent(xCol);
    2085                 :            :                             }
    2086                 :            :                         }
    2087         [ #  # ]:          0 :                         catch(const Exception&)
    2088                 :            :                         {
    2089                 :            :                             OSL_FAIL("exception occurred while deleting a column");
    2090                 :            :                         }
    2091                 :          0 :                     }
    2092                 :            :                 }
    2093                 :          0 :                 bDone = sal_True;
    2094                 :          0 :                 break;
    2095                 :            :         }
    2096                 :            :     }
    2097         [ #  # ]:          0 :     if ( !bDone )
    2098                 :          0 :         DbGridControl::KeyInput( rKEvt );
    2099                 :          0 : }
    2100                 :            : // -----------------------------------------------------------------------------
    2101                 :            : 
    2102                 :            : 
    2103                 :            : 
    2104                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10