LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TEditControl.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 898 0.0 %
Date: 2012-08-25 Functions: 0 73 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 2035 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This file is part of the LibreOffice project.
       4                 :            :  *
       5                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       6                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8                 :            :  *
       9                 :            :  * This file incorporates work covered by the following license notice:
      10                 :            :  *
      11                 :            :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12                 :            :  *   contributor license agreements. See the NOTICE file distributed
      13                 :            :  *   with this work for additional information regarding copyright
      14                 :            :  *   ownership. The ASF licenses this file to you under the Apache
      15                 :            :  *   License, Version 2.0 (the "License"); you may not use this file
      16                 :            :  *   except in compliance with the License. You may obtain a copy of
      17                 :            :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18                 :            :  */
      19                 :            : 
      20                 :            : #include "TEditControl.hxx"
      21                 :            : #include <tools/debug.hxx>
      22                 :            : #include <com/sun/star/sdbc/XDatabaseMetaData.hpp>
      23                 :            : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
      24                 :            : #include <com/sun/star/sdbcx/XAlterTable.hpp>
      25                 :            : #include <com/sun/star/sdbcx/XDrop.hpp>
      26                 :            : #include <com/sun/star/sdbcx/XAppend.hpp>
      27                 :            : #include <com/sun/star/beans/PropertyAttribute.hpp>
      28                 :            : #include <com/sun/star/util/XNumberFormatTypes.hpp>
      29                 :            : #include "dbu_tbl.hrc"
      30                 :            : #include "dbustrings.hrc"
      31                 :            : #include "browserids.hxx"
      32                 :            : #include "dbaccess_helpid.hrc"
      33                 :            : #include <comphelper/types.hxx>
      34                 :            : #include "FieldDescControl.hxx"
      35                 :            : #include "FieldDescriptions.hxx"
      36                 :            : #include <vcl/msgbox.hxx>
      37                 :            : #include "TableUndo.hxx"
      38                 :            : #include "TableController.hxx"
      39                 :            : #include <connectivity/dbtools.hxx>
      40                 :            : #include "SqlNameEdit.hxx"
      41                 :            : #include "TableRowExchange.hxx"
      42                 :            : #include <sot/storage.hxx>
      43                 :            : #include "UITools.hxx"
      44                 :            : #include "TableFieldControl.hxx"
      45                 :            : #include "dsntypes.hxx"
      46                 :            : 
      47                 :            : #include "dbaccess_slotid.hrc"
      48                 :            : 
      49                 :            : using namespace ::dbaui;
      50                 :            : using namespace ::comphelper;
      51                 :            : using namespace ::svt;
      52                 :            : using namespace ::com::sun::star::uno;
      53                 :            : using namespace ::com::sun::star::container;
      54                 :            : using namespace ::com::sun::star::io;
      55                 :            : using namespace ::com::sun::star::beans;
      56                 :            : using namespace ::com::sun::star::frame;
      57                 :            : using namespace ::com::sun::star::util;
      58                 :            : using namespace ::com::sun::star::lang;
      59                 :            : using namespace ::com::sun::star::sdbc;
      60                 :            : using namespace ::com::sun::star::sdbcx;
      61                 :            : using namespace ::com::sun::star::sdb;
      62                 :            : 
      63                 :            : namespace dbaui
      64                 :            : {
      65                 :            :     extern String GetTypeString( sal_uInt16 nType );
      66                 :            : }
      67                 :            : //==============================================================================
      68                 :            : 
      69                 :            : //  TYPEINIT1(OTableEditorCtrl, DBView);
      70                 :            : DBG_NAME(OTableEditorCtrl)
      71                 :            : 
      72                 :            : //==============================================================================
      73                 :            : 
      74                 :            : #define HANDLE_ID       0
      75                 :            : 
      76                 :            : // default Spaltenbreiten
      77                 :            : #define FIELDNAME_WIDTH     100
      78                 :            : #define FIELDTYPE_WIDTH     150
      79                 :            : #define FIELDDESCR_WIDTH    300
      80                 :            : 
      81                 :            : // Maximale Eingabelaenge im Beschreibungsfeld
      82                 :            : #define MAX_DESCR_LEN       256
      83                 :            : 
      84                 :            : 
      85                 :            : #define CONTROL_SPACING_X   18  // 6
      86                 :            : #define CONTROL_SPACING_Y   5
      87                 :            : #define CONTROL_HEIGHT      20
      88                 :            : #define CONTROL_WIDTH_1     140 // 100
      89                 :            : #define CONTROL_WIDTH_2     100 // 60
      90                 :            : #define CONTROL_WIDTH_3     250
      91                 :            : #define CONTROL_WIDTH_4     (CONTROL_WIDTH_3 - CONTROL_HEIGHT - 5)
      92                 :            : 
      93                 :            : 
      94                 :            : //==================================================================
      95                 :            : DBG_NAME(ClipboardInvalidator)
      96                 :            : //------------------------------------------------------------------
      97                 :          0 : OTableEditorCtrl::ClipboardInvalidator::ClipboardInvalidator(sal_uLong nTimeout,OTableEditorCtrl* _pOwner)
      98                 :          0 : : m_pOwner(_pOwner)
      99                 :            : {
     100                 :            :     DBG_CTOR(ClipboardInvalidator,NULL);
     101                 :            : 
     102         [ #  # ]:          0 :     m_aInvalidateTimer.SetTimeout(nTimeout);
     103         [ #  # ]:          0 :     m_aInvalidateTimer.SetTimeoutHdl(LINK(this, OTableEditorCtrl::ClipboardInvalidator, OnInvalidate));
     104         [ #  # ]:          0 :     m_aInvalidateTimer.Start();
     105                 :          0 : }
     106                 :            : 
     107                 :            : //------------------------------------------------------------------
     108                 :          0 : OTableEditorCtrl::ClipboardInvalidator::~ClipboardInvalidator()
     109                 :            : {
     110         [ #  # ]:          0 :     m_aInvalidateTimer.Stop();
     111                 :            : 
     112                 :            :     DBG_DTOR(ClipboardInvalidator,NULL);
     113                 :          0 : }
     114                 :            : 
     115                 :            : //------------------------------------------------------------------
     116                 :          0 : IMPL_LINK_NOARG(OTableEditorCtrl::ClipboardInvalidator, OnInvalidate)
     117                 :            : {
     118         [ #  # ]:          0 :     m_pOwner->GetView()->getController().InvalidateFeature(SID_CUT);
     119         [ #  # ]:          0 :     m_pOwner->GetView()->getController().InvalidateFeature(SID_COPY);
     120         [ #  # ]:          0 :     m_pOwner->GetView()->getController().InvalidateFeature(SID_PASTE);
     121                 :          0 :     return 0L;
     122                 :            : }
     123                 :            : 
     124                 :            : //==================================================================
     125                 :          0 : void OTableEditorCtrl::Init()
     126                 :            : {
     127                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     128         [ #  # ]:          0 :     OTableRowView::Init();
     129                 :            : 
     130                 :            :     //////////////////////////////////////////////////////////////////////
     131                 :            :     // Soll der Entwurf ReadOnly geoeffnet werden ?
     132 [ #  # ][ #  # ]:          0 :     sal_Bool bRead(GetView()->getController().isReadOnly());
     133                 :            : 
     134         [ #  # ]:          0 :     SetReadOnly( bRead );
     135                 :            : 
     136                 :            :     //////////////////////////////////////////////////////////////////////
     137                 :            :     // Spalten einfuegen
     138 [ #  # ][ #  # ]:          0 :     String aColumnName( ModuleRes(STR_TAB_FIELD_COLUMN_NAME) );
     139         [ #  # ]:          0 :     InsertDataColumn( FIELD_NAME, aColumnName, FIELDNAME_WIDTH );
     140                 :            : 
     141 [ #  # ][ #  # ]:          0 :     aColumnName = String( ModuleRes(STR_TAB_FIELD_COLUMN_DATATYPE) );
         [ #  # ][ #  # ]
     142         [ #  # ]:          0 :     InsertDataColumn( FIELD_TYPE, aColumnName, FIELDTYPE_WIDTH );
     143                 :            : 
     144 [ #  # ][ #  # ]:          0 :     ::dbaccess::ODsnTypeCollection aDsnTypes(GetView()->getController().getORB());
                 [ #  # ]
     145 [ #  # ][ #  # ]:          0 :     sal_Bool bShowColumnDescription = aDsnTypes.supportsColumnDescription(::comphelper::getString(GetView()->getController().getDataSource()->getPropertyValue(PROPERTY_URL)));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     146 [ #  # ][ #  # ]:          0 :     aColumnName = String( ModuleRes(STR_TAB_HELP_TEXT) );
         [ #  # ][ #  # ]
     147 [ #  # ][ #  # ]:          0 :     InsertDataColumn( HELP_TEXT, aColumnName, bShowColumnDescription ? FIELDTYPE_WIDTH : FIELDDESCR_WIDTH );
     148                 :            : 
     149         [ #  # ]:          0 :     if ( bShowColumnDescription )
     150                 :            :     {
     151 [ #  # ][ #  # ]:          0 :         aColumnName = String( ModuleRes(STR_COLUMN_DESCRIPTION) );
         [ #  # ][ #  # ]
     152         [ #  # ]:          0 :         InsertDataColumn( COLUMN_DESCRIPTION, aColumnName, FIELDTYPE_WIDTH );
     153                 :            :     }
     154                 :            : 
     155         [ #  # ]:          0 :     InitCellController();
     156                 :            : 
     157                 :            :     //////////////////////////////////////////////////////////////////////
     158                 :            :     // Zeilen einfuegen
     159 [ #  # ][ #  # ]:          0 :     RowInserted(0, m_pRowList->size(), sal_True);
                 [ #  # ]
     160                 :          0 : }
     161                 :            : 
     162                 :            : //==================================================================
     163                 :          0 : void OTableEditorCtrl::UpdateAll()
     164                 :            : {
     165                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     166                 :          0 :     RowRemoved(0, GetRowCount(), sal_False);
     167                 :          0 :     m_nDataPos = 0;
     168                 :            : 
     169                 :          0 :     InvalidateFeatures();
     170                 :          0 :     Invalidate();
     171                 :          0 : }
     172                 :            : //==================================================================
     173                 :          0 : OTableEditorCtrl::OTableEditorCtrl(Window* pWindow)
     174                 :            :     :OTableRowView(pWindow)
     175                 :            :     ,pNameCell(NULL)
     176                 :            :     ,pTypeCell(NULL)
     177                 :            :     ,pHelpTextCell(NULL)
     178                 :            :     ,pDescrCell(NULL)
     179                 :            :     ,pDescrWin(NULL)
     180                 :            :     ,nIndexEvent(0)
     181                 :            :     ,nCutEvent(0)
     182                 :            :     ,nPasteEvent(0)
     183                 :            :     ,nDeleteEvent(0)
     184                 :            :     ,nInsNewRowsEvent(0)
     185                 :            :     ,nInvalidateTypeEvent(0)
     186                 :            :     ,m_eChildFocus(NONE)
     187                 :            :     ,nOldDataPos(-1)
     188                 :            :     ,bSaveOnMove(sal_True)
     189                 :            :     ,bReadOnly(sal_True)
     190 [ #  # ][ #  # ]:          0 :     ,m_aInvalidate(500,this)
                 [ #  # ]
     191                 :            : {
     192                 :            :     DBG_CTOR(OTableEditorCtrl,NULL);
     193                 :            : 
     194         [ #  # ]:          0 :     SetHelpId(HID_TABDESIGN_BACKGROUND);
     195         [ #  # ]:          0 :     GetDataWindow().SetHelpId(HID_CTL_TABLEEDIT);
     196                 :            : 
     197         [ #  # ]:          0 :     m_pRowList = GetView()->getController().getRows();
     198                 :          0 :     m_nDataPos = 0;
     199                 :          0 : }
     200                 :            : 
     201                 :            : //------------------------------------------------------------------------------
     202                 :          0 : SfxUndoManager& OTableEditorCtrl::GetUndoManager() const
     203                 :            : {
     204                 :          0 :     return GetView()->getController().GetUndoManager();
     205                 :            : }
     206                 :            : 
     207                 :            : //------------------------------------------------------------------------------
     208                 :          0 : sal_Bool OTableEditorCtrl::IsReadOnly()
     209                 :            : {
     210                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     211                 :          0 :     return bReadOnly;
     212                 :            : }
     213                 :            : 
     214                 :            : //------------------------------------------------------------------------------
     215                 :          0 : void OTableEditorCtrl::SetReadOnly( sal_Bool bRead )
     216                 :            : {
     217                 :            :     // nix zu tun ?
     218         [ #  # ]:          0 :     if (bRead == IsReadOnly())
     219                 :            :         // diese Abfrage ist wichtig, da die zugrundeliegende Def sonst im folgenden gelockt oder ge-unlocked wird, obwohl es
     220                 :            :         // nicht notwendig waere (und was schlimmer ist, das wuerde dann auch nicht wieder rueckgaengig gemacht)
     221                 :          0 :         return;
     222                 :            : 
     223                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     224                 :          0 :     bReadOnly = bRead;
     225                 :            : 
     226                 :            :     //////////////////////////////////////////////////////////////////////
     227                 :            :     // Aktive Zelle disablen
     228                 :          0 :     long nRow(GetCurRow());
     229                 :          0 :     sal_uInt16 nCol(GetCurColumnId());
     230                 :          0 :     DeactivateCell();
     231                 :            : 
     232                 :            :     //////////////////////////////////////////////////////////////////////
     233                 :            :     // Cursor des Browsers anpassen
     234                 :            :     BrowserMode nMode(BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
     235                 :          0 :                       BROWSER_HLINESFULL      | BROWSER_VLINESFULL|BROWSER_AUTOSIZE_LASTCOL);
     236         [ #  # ]:          0 :     if( !bReadOnly )
     237                 :          0 :         nMode |= BROWSER_HIDECURSOR;
     238                 :          0 :     SetMode(nMode);
     239                 :            : 
     240         [ #  # ]:          0 :     if( !bReadOnly )
     241                 :          0 :         ActivateCell( nRow, nCol );
     242                 :            : }
     243                 :            : 
     244                 :            : //------------------------------------------------------------------------------
     245                 :          0 : void OTableEditorCtrl::InitCellController()
     246                 :            : {
     247                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     248                 :            :     //////////////////////////////////////////////////////////////////////
     249                 :            :     // Zelle Feldname
     250                 :          0 :     xub_StrLen nMaxTextLen = EDIT_NOLIMIT;
     251                 :          0 :     ::rtl::OUString sExtraNameChars;
     252                 :          0 :     Reference<XConnection> xCon;
     253                 :            :     try
     254                 :            :     {
     255 [ #  # ][ #  # ]:          0 :         xCon = GetView()->getController().getConnection();
                 [ #  # ]
     256 [ #  # ][ #  # ]:          0 :         Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
                 [ #  # ]
     257                 :            : 
     258 [ #  # ][ #  # ]:          0 :         nMaxTextLen = ((xub_StrLen)xMetaData.is() ? static_cast<xub_StrLen>(xMetaData->getMaxColumnNameLength()) : 0);
                 [ #  # ]
     259                 :            : 
     260         [ #  # ]:          0 :         if( nMaxTextLen == 0 )
     261                 :          0 :             nMaxTextLen = EDIT_NOLIMIT;
     262 [ #  # ][ #  # ]:          0 :         sExtraNameChars = xMetaData.is() ? xMetaData->getExtraNameCharacters() : ::rtl::OUString();
         [ #  # ][ #  # ]
     263                 :            : 
     264                 :            :     }
     265         [ #  # ]:          0 :     catch(SQLException&)
     266                 :            :     {
     267                 :            :         OSL_FAIL("getMaxColumnNameLength");
     268                 :            :     }
     269                 :            : 
     270 [ #  # ][ #  # ]:          0 :     pNameCell = new OSQLNameEdit( &GetDataWindow(), sExtraNameChars,WB_LEFT );
     271         [ #  # ]:          0 :     pNameCell->SetMaxTextLen( nMaxTextLen );
     272         [ #  # ]:          0 :     pNameCell->setCheck( isSQL92CheckEnabled(xCon) );
     273                 :            : 
     274                 :            : 
     275                 :            :     //////////////////////////////////////////////////////////////////////
     276                 :            :     // Zelle Typ
     277 [ #  # ][ #  # ]:          0 :     pTypeCell = new ListBoxControl( &GetDataWindow() );
     278         [ #  # ]:          0 :     pTypeCell->SetDropDownLineCount( 15 );
     279                 :            : 
     280                 :            :     //////////////////////////////////////////////////////////////////////
     281                 :            :     // Zelle Beschreibung
     282 [ #  # ][ #  # ]:          0 :     pDescrCell = new Edit( &GetDataWindow(), WB_LEFT );
     283         [ #  # ]:          0 :     pDescrCell->SetMaxTextLen( MAX_DESCR_LEN );
     284                 :            : 
     285 [ #  # ][ #  # ]:          0 :     pHelpTextCell = new Edit( &GetDataWindow(), WB_LEFT );
     286         [ #  # ]:          0 :     pHelpTextCell->SetMaxTextLen( MAX_DESCR_LEN );
     287                 :            : 
     288         [ #  # ]:          0 :     pNameCell->SetHelpId(HID_TABDESIGN_NAMECELL);
     289         [ #  # ]:          0 :     pTypeCell->SetHelpId(HID_TABDESIGN_TYPECELL);
     290         [ #  # ]:          0 :     pDescrCell->SetHelpId(HID_TABDESIGN_COMMENTCELL);
     291         [ #  # ]:          0 :     pHelpTextCell->SetHelpId(HID_TABDESIGN_HELPTEXT);
     292                 :            : 
     293                 :          0 :     Size aHeight;
     294                 :          0 :     const Control* pControls[] = { pTypeCell,pDescrCell,pNameCell,pHelpTextCell};
     295         [ #  # ]:          0 :     for(sal_Size i= 0; i < sizeof(pControls) / sizeof(pControls[0]);++i)
     296                 :            :     {
     297         [ #  # ]:          0 :         const Size aTemp( pControls[i]->GetOptimalSize(WINDOWSIZE_PREFERRED) );
     298         [ #  # ]:          0 :         if ( aTemp.Height() > aHeight.Height() )
     299                 :          0 :             aHeight.Height() = aTemp.Height();
     300                 :            :     }
     301         [ #  # ]:          0 :     SetDataRowHeight(aHeight.Height());
     302                 :            : 
     303         [ #  # ]:          0 :     ClearModified();
     304                 :          0 : }
     305                 :            : 
     306                 :            : //------------------------------------------------------------------------------
     307                 :          0 : void OTableEditorCtrl::ClearModified()
     308                 :            : {
     309                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     310                 :          0 :     pNameCell->ClearModifyFlag();
     311                 :          0 :     pDescrCell->ClearModifyFlag();
     312                 :          0 :     pHelpTextCell->ClearModifyFlag();
     313                 :          0 :     pTypeCell->SaveValue();
     314                 :          0 : }
     315                 :            : 
     316                 :            : //------------------------------------------------------------------------------
     317 [ #  # ][ #  # ]:          0 : OTableEditorCtrl::~OTableEditorCtrl()
     318                 :            : {
     319                 :            :     DBG_DTOR(OTableEditorCtrl,NULL);
     320                 :            :     //////////////////////////////////////////////////////////////////////
     321                 :            :     // Undo-Manager zuruecksetzen
     322 [ #  # ][ #  # ]:          0 :     GetUndoManager().Clear();
     323                 :            : 
     324                 :            :     //////////////////////////////////////////////////////////////////////
     325                 :            :     // Moegliche Events aus Queue entfernen
     326         [ #  # ]:          0 :     if( nCutEvent )
     327         [ #  # ]:          0 :         Application::RemoveUserEvent( nCutEvent );
     328         [ #  # ]:          0 :     if( nPasteEvent )
     329         [ #  # ]:          0 :         Application::RemoveUserEvent( nPasteEvent );
     330         [ #  # ]:          0 :     if( nDeleteEvent )
     331         [ #  # ]:          0 :         Application::RemoveUserEvent( nDeleteEvent );
     332         [ #  # ]:          0 :     if( nInsNewRowsEvent )
     333         [ #  # ]:          0 :         Application::RemoveUserEvent( nInsNewRowsEvent );
     334         [ #  # ]:          0 :     if( nInvalidateTypeEvent )
     335         [ #  # ]:          0 :         Application::RemoveUserEvent( nInvalidateTypeEvent );
     336                 :            : 
     337                 :            :     //////////////////////////////////////////////////////////////////////
     338                 :            :     // Controltypen zerstoeren
     339 [ #  # ][ #  # ]:          0 :     delete pNameCell;
     340 [ #  # ][ #  # ]:          0 :     delete pTypeCell;
     341 [ #  # ][ #  # ]:          0 :     delete pDescrCell;
     342 [ #  # ][ #  # ]:          0 :     delete pHelpTextCell;
     343         [ #  # ]:          0 : }
     344                 :            : 
     345                 :            : //------------------------------------------------------------------------------
     346                 :          0 : sal_Bool OTableEditorCtrl::SetDataPtr( long nRow )
     347                 :            : {
     348                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     349         [ #  # ]:          0 :     if(nRow == -1)
     350                 :          0 :         return sal_False;
     351                 :            : 
     352                 :            :     OSL_ENSURE((xub_StrLen)nRow < m_pRowList->size(),"Row is greater than size!");
     353         [ #  # ]:          0 :     if(nRow >= (long)m_pRowList->size())
     354                 :          0 :         return sal_False;
     355                 :          0 :     pActRow = (*m_pRowList)[nRow];
     356                 :          0 :     return pActRow != NULL;
     357                 :            : }
     358                 :            : 
     359                 :            : //------------------------------------------------------------------------------
     360                 :          0 : sal_Bool OTableEditorCtrl::SeekRow(long _nRow)
     361                 :            : {
     362                 :            :     // die Basisklasse braucht den Aufruf, da sie sich dort merkt, welche Zeile gepainted wird
     363                 :          0 :     EditBrowseBox::SeekRow(_nRow);
     364                 :            : 
     365                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     366                 :          0 :     m_nCurrentPos = _nRow;
     367                 :          0 :     return SetDataPtr(_nRow);
     368                 :            : }
     369                 :            : 
     370                 :            : //------------------------------------------------------------------------------
     371                 :          0 : void OTableEditorCtrl::PaintCell(OutputDevice& rDev, const Rectangle& rRect,
     372                 :            :                                    sal_uInt16 nColumnId ) const
     373                 :            : {
     374                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     375         [ #  # ]:          0 :     const String aText( GetCellText( m_nCurrentPos, nColumnId ));
     376 [ #  # ][ #  # ]:          0 :     const Size TxtSize(GetDataWindow().GetTextWidth(aText), GetDataWindow().GetTextHeight());
     377                 :            : 
     378         [ #  # ]:          0 :     rDev.Push( PUSH_CLIPREGION );
     379 [ #  # ][ #  # ]:          0 :     rDev.SetClipRegion( rRect );
                 [ #  # ]
     380         [ #  # ]:          0 :     rDev.DrawText( rRect, aText, TEXT_DRAW_LEFT | TEXT_DRAW_VCENTER );
     381 [ #  # ][ #  # ]:          0 :     rDev.Pop();
     382                 :          0 : }
     383                 :            : 
     384                 :            : //------------------------------------------------------------------------------
     385                 :          0 : CellController* OTableEditorCtrl::GetController(long nRow, sal_uInt16 nColumnId)
     386                 :            : {
     387                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     388                 :            :     //////////////////////////////////////////////////////////////////////
     389                 :            :     // Wenn EditorCtrl ReadOnly ist, darf nicht editiert werden
     390 [ #  # ][ #  # ]:          0 :     Reference<XPropertySet> xTable = GetView()->getController().getTable();
     391 [ #  # ][ #  # ]:          0 :     if (IsReadOnly() || (   xTable.is() &&
           [ #  #  #  # ]
                 [ #  # ]
     392 [ #  # ][ #  # ]:          0 :                             xTable->getPropertySetInfo()->hasPropertyByName(PROPERTY_TYPE) &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     393 [ #  # ][ #  # ]:          0 :                             ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"))))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                      # ]
     394                 :          0 :         return NULL;
     395                 :            : 
     396                 :            :     //////////////////////////////////////////////////////////////////////
     397                 :            :     // Wenn Zeile ReadOnly ist, darf sie nicht editiert werden
     398         [ #  # ]:          0 :     SetDataPtr( nRow );
     399         [ #  # ]:          0 :     if( pActRow->IsReadOnly() )
     400                 :          0 :         return NULL;
     401                 :            : 
     402                 :          0 :     OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
     403   [ #  #  #  #  :          0 :     switch (nColumnId)
                      # ]
     404                 :            :     {
     405                 :            :         case FIELD_NAME:
     406 [ #  # ][ #  # ]:          0 :             return new EditCellController( pNameCell );
     407                 :            :         case FIELD_TYPE:
     408 [ #  # ][ #  # ]:          0 :             if (pActFieldDescr && !pActFieldDescr->GetName().isEmpty())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     409 [ #  # ][ #  # ]:          0 :                 return new ListBoxCellController( pTypeCell );
     410                 :          0 :             else return NULL;
     411                 :            :         case HELP_TEXT:
     412 [ #  # ][ #  # ]:          0 :             if (pActFieldDescr && !pActFieldDescr->GetName().isEmpty())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     413 [ #  # ][ #  # ]:          0 :                 return new EditCellController( pHelpTextCell );
     414                 :            :             else
     415                 :          0 :                 return NULL;
     416                 :            :         case COLUMN_DESCRIPTION:
     417 [ #  # ][ #  # ]:          0 :             if (pActFieldDescr && !pActFieldDescr->GetName().isEmpty())
         [ #  # ][ #  # ]
           [ #  #  #  # ]
     418 [ #  # ][ #  # ]:          0 :                 return new EditCellController( pDescrCell );
     419                 :            :             else
     420                 :          0 :                 return NULL;
     421                 :            :         default:
     422                 :          0 :             return NULL;
     423                 :          0 :     }
     424                 :            : }
     425                 :            : 
     426                 :            : //------------------------------------------------------------------------------
     427                 :          0 : void OTableEditorCtrl::InitController(CellControllerRef&, long nRow, sal_uInt16 nColumnId)
     428                 :            : {
     429                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     430 [ #  # ][ #  # ]:          0 :     SeekRow( nRow == -1 ? GetCurRow() : nRow);
     431                 :          0 :     OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
     432         [ #  # ]:          0 :     String aInitString;
     433                 :            : 
     434   [ #  #  #  #  :          0 :     switch (nColumnId)
                      # ]
     435                 :            :     {
     436                 :            :         case FIELD_NAME:
     437         [ #  # ]:          0 :             if( pActFieldDescr )
     438 [ #  # ][ #  # ]:          0 :                 aInitString = pActFieldDescr->GetName();
     439         [ #  # ]:          0 :             pNameCell->SetText( aInitString );
     440         [ #  # ]:          0 :             pNameCell->SaveValue();
     441                 :          0 :             break;
     442                 :            :         case FIELD_TYPE:
     443                 :            :             {
     444 [ #  # ][ #  # ]:          0 :                 if ( pActFieldDescr && pActFieldDescr->getTypeInfo() )
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
     445 [ #  # ][ #  # ]:          0 :                     aInitString = pActFieldDescr->getTypeInfo()->aUIName;
                 [ #  # ]
     446                 :            : 
     447                 :            :                 //////////////////////////////////////////////////////////////
     448                 :            :                 // Anpassen des ComboBoxInhalts
     449         [ #  # ]:          0 :                 pTypeCell->Clear();
     450         [ #  # ]:          0 :                 if( !pActFieldDescr )
     451                 :            :                     break;
     452                 :            : 
     453         [ #  # ]:          0 :                 const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
     454                 :          0 :                 OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
     455                 :          0 :                 OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
     456         [ #  # ]:          0 :                 for(;aIter != aEnd;++aIter)
     457 [ #  # ][ #  # ]:          0 :                     pTypeCell->InsertEntry( aIter->second->aUIName );
                 [ #  # ]
     458         [ #  # ]:          0 :                 pTypeCell->SelectEntry( aInitString );
     459                 :            :             }
     460                 :            : 
     461                 :          0 :             break;
     462                 :            :         case HELP_TEXT:
     463         [ #  # ]:          0 :             if( pActFieldDescr )
     464 [ #  # ][ #  # ]:          0 :                 aInitString = pActFieldDescr->GetHelpText();
     465         [ #  # ]:          0 :             pHelpTextCell->SetText( aInitString );
     466         [ #  # ]:          0 :             pHelpTextCell->SaveValue();
     467                 :          0 :             break;
     468                 :            :         case COLUMN_DESCRIPTION:
     469         [ #  # ]:          0 :             if( pActFieldDescr )
     470 [ #  # ][ #  # ]:          0 :                 aInitString = pActFieldDescr->GetDescription();
     471         [ #  # ]:          0 :             pDescrCell->SetText( aInitString );
     472         [ #  # ]:          0 :             pDescrCell->SaveValue();
     473                 :          0 :             break;
     474                 :            : 
     475         [ #  # ]:          0 :     }
     476                 :          0 : }
     477                 :            : 
     478                 :            : //------------------------------------------------------------------------------
     479                 :          0 : EditBrowseBox::RowStatus OTableEditorCtrl::GetRowStatus(long nRow) const
     480                 :            : {
     481                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     482                 :          0 :     const_cast<OTableEditorCtrl*>(this)->SetDataPtr( nRow );
     483         [ #  # ]:          0 :     if( !pActRow )
     484                 :          0 :         return EditBrowseBox::CLEAN;
     485 [ #  # ][ #  # ]:          0 :     if (nRow >= 0 && nRow == m_nDataPos)
     486                 :            :     {
     487         [ #  # ]:          0 :         if( pActRow->IsPrimaryKey() )
     488                 :          0 :             return EditBrowseBox::CURRENT_PRIMARYKEY;
     489                 :          0 :         return EditBrowseBox::CURRENT;
     490                 :            :     }
     491                 :            :     else
     492                 :            :     {
     493         [ #  # ]:          0 :         if( pActRow->IsPrimaryKey() )
     494                 :          0 :             return EditBrowseBox::PRIMARYKEY;
     495                 :          0 :         return EditBrowseBox::CLEAN;
     496                 :            :     }
     497                 :            : }
     498                 :            : 
     499                 :            : //------------------------------------------------------------------------------
     500                 :          0 : sal_Bool OTableEditorCtrl::SaveCurRow()
     501                 :            : {
     502                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     503         [ #  # ]:          0 :     if (GetFieldDescr(GetCurRow()) == NULL)
     504                 :            :         // in der Zeile, in der ich mich i.A. befinde, stehen keine Daten
     505                 :          0 :         return sal_True;
     506         [ #  # ]:          0 :     if (!SaveModified())
     507                 :          0 :         return sal_False;
     508                 :            : 
     509                 :          0 :     SetDataPtr(GetCurRow());
     510                 :          0 :     pDescrWin->SaveData( pActRow->GetActFieldDescr() );
     511                 :          0 :     return sal_True;
     512                 :            : }
     513                 :            : 
     514                 :            : //------------------------------------------------------------------------------
     515                 :          0 : void OTableEditorCtrl::DisplayData(long nRow, sal_Bool bGrabFocus)
     516                 :            : {
     517                 :            :     // zur richtigen Zelle fahren
     518         [ #  # ]:          0 :     SetDataPtr(nRow);
     519                 :            : 
     520                 :            :     // Editier-Modus temporaer aus
     521                 :          0 :     sal_Bool bWasEditing = IsEditing();
     522         [ #  # ]:          0 :     if (bWasEditing)
     523         [ #  # ]:          0 :         DeactivateCell();
     524                 :            : 
     525                 :          0 :     CellControllerRef aTemp;
     526         [ #  # ]:          0 :     InitController(aTemp, nRow, FIELD_NAME);
     527         [ #  # ]:          0 :     InitController(aTemp, nRow, FIELD_TYPE);
     528         [ #  # ]:          0 :     InitController(aTemp, nRow, COLUMN_DESCRIPTION);
     529         [ #  # ]:          0 :     InitController(aTemp, nRow, HELP_TEXT);
     530                 :            : 
     531         [ #  # ]:          0 :     GoToRow(nRow);
     532                 :            :     // das Description-Window aktualisieren
     533 [ #  # ][ #  # ]:          0 :     GetView()->GetDescWin()->DisplayData(GetFieldDescr(nRow));
                 [ #  # ]
     534                 :            :     // neu zeichnen
     535         [ #  # ]:          0 :     RowModified(nRow);
     536                 :            : 
     537                 :            :     // wieder an
     538 [ #  # ][ #  # ]:          0 :     if (bWasEditing || bGrabFocus)
     539 [ #  # ][ #  # ]:          0 :         ActivateCell(nRow, GetCurColumnId(), bGrabFocus);
     540                 :          0 : }
     541                 :            : 
     542                 :            : //------------------------------------------------------------------------------
     543                 :          0 : void OTableEditorCtrl::CursorMoved()
     544                 :            : {
     545                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     546                 :            :     //////////////////////////////////////////////////////////////////////
     547                 :            :     // Zeilenwechsel ?
     548                 :          0 :     m_nDataPos = GetCurRow();
     549 [ #  # ][ #  # ]:          0 :     if( m_nDataPos != nOldDataPos && m_nDataPos != -1)
     550                 :            :     {
     551                 :          0 :         CellControllerRef aTemp;
     552         [ #  # ]:          0 :         InitController(aTemp,m_nDataPos,FIELD_NAME);
     553         [ #  # ]:          0 :         InitController(aTemp,m_nDataPos,FIELD_TYPE);
     554         [ #  # ]:          0 :         InitController(aTemp,m_nDataPos,COLUMN_DESCRIPTION);
     555 [ #  # ][ #  # ]:          0 :         InitController(aTemp,m_nDataPos,HELP_TEXT);
     556                 :            :     }
     557                 :            : 
     558                 :          0 :     OTableRowView::CursorMoved();
     559                 :          0 : }
     560                 :            : 
     561                 :            : //------------------------------------------------------------------------------
     562                 :          0 : sal_Int32 OTableEditorCtrl::HasFieldName( const String& rFieldName )
     563                 :            : {
     564                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     565                 :            : 
     566 [ #  # ][ #  # ]:          0 :     Reference<XConnection> xCon = GetView()->getController().getConnection();
     567 [ #  # ][ #  # ]:          0 :     Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
                 [ #  # ]
     568                 :            : 
     569 [ #  # ][ #  # ]:          0 :     ::comphelper::UStringMixEqual bCase(xMetaData.is() ? xMetaData->supportsMixedCaseQuotedIdentifiers() : sal_True);
                 [ #  # ]
     570                 :            : 
     571                 :          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aIter = m_pRowList->begin();
     572                 :          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::iterator aEnd = m_pRowList->end();
     573                 :            :     OFieldDescription* pFieldDescr;
     574                 :          0 :     sal_Int32 nCount(0);
     575 [ #  # ][ #  # ]:          0 :     for(;aIter != aEnd;++aIter)
     576                 :            :     {
     577                 :          0 :         pFieldDescr = (*aIter)->GetActFieldDescr();
     578 [ #  # ][ #  # ]:          0 :         if( pFieldDescr && bCase(rFieldName,pFieldDescr->GetName()))
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
             #  #  #  # ]
                 [ #  # ]
     579                 :          0 :             nCount++;
     580                 :            :     }
     581                 :          0 :     return nCount;
     582                 :            : }
     583                 :            : // --------------------------------------------------------------------------------------
     584                 :          0 : sal_Bool OTableEditorCtrl::SaveData(long nRow, sal_uInt16 nColId)
     585                 :            : {
     586                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     587                 :            :     //////////////////////////////////////////////////////////////
     588                 :            :     // Zellinhalte in Datenstruktur speichern
     589         [ #  # ]:          0 :     SetDataPtr( nRow == -1 ? GetCurRow() : nRow);
     590                 :          0 :     OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
     591                 :            : 
     592   [ #  #  #  #  :          0 :     switch( nColId)
                   #  # ]
     593                 :            :     {
     594                 :            :         //////////////////////////////////////////////////////////////
     595                 :            :         // Speichern Inhalt NameCell
     596                 :            :         case FIELD_NAME:
     597                 :            :         {
     598                 :            :             //////////////////////////////////////////////////////////////
     599                 :            :             // Wenn kein Name, nichts machen
     600         [ #  # ]:          0 :             String aName(pNameCell->GetText());
     601                 :            : 
     602         [ #  # ]:          0 :             if( !aName.Len() )
     603                 :            :             {
     604                 :            :                 //////////////////////////////////////////////////////////////
     605                 :            :                 // Wenn FieldDescr existiert, wurde Feld geloescht und alter Inhalt wird wiederhergestellt
     606         [ #  # ]:          0 :                 if (pActFieldDescr)
     607                 :            :                 {
     608 [ #  # ][ #  # ]:          0 :                     GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, nRow, FIELD_TYPE, pActFieldDescr->getTypeInfo()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     609 [ #  # ][ #  # ]:          0 :                     SwitchType(TOTypeInfoSP());
                 [ #  # ]
     610                 :          0 :                     pActFieldDescr = pActRow->GetActFieldDescr();
     611                 :            :                 }
     612                 :            :                 else
     613                 :          0 :                     return sal_True;
     614                 :            :             }
     615         [ #  # ]:          0 :             if(pActFieldDescr)
     616 [ #  # ][ #  # ]:          0 :                 pActFieldDescr->SetName( aName );
     617         [ #  # ]:          0 :             pNameCell->ClearModifyFlag();
     618                 :            : 
     619 [ #  # ][ #  # ]:          0 :             break;
     620                 :            :         }
     621                 :            : 
     622                 :            :         //////////////////////////////////////////////////////////////
     623                 :            :         // Speichern Inhalt TypeCell
     624                 :            :         case FIELD_TYPE:
     625                 :          0 :             break;
     626                 :            : 
     627                 :            :         //////////////////////////////////////////////////////////////
     628                 :            :         // Speichern Inhalt DescrCell
     629                 :            :         case HELP_TEXT:
     630                 :            :         {
     631                 :            :             //////////////////////////////////////////////////////////////
     632                 :            :             // Wenn aktuelle Feldbeschreibung NULL, Default setzen
     633         [ #  # ]:          0 :             if( !pActFieldDescr )
     634                 :            :             {
     635         [ #  # ]:          0 :                 pHelpTextCell->SetText(String());
     636                 :          0 :                 pHelpTextCell->ClearModifyFlag();
     637                 :            :             }
     638                 :            :             else
     639 [ #  # ][ #  # ]:          0 :                 pActFieldDescr->SetHelpText( pHelpTextCell->GetText() );
     640                 :          0 :             break;
     641                 :            :         }
     642                 :            :         case COLUMN_DESCRIPTION:
     643                 :            :         {
     644                 :            :             //////////////////////////////////////////////////////////////
     645                 :            :             // Wenn aktuelle Feldbeschreibung NULL, Default setzen
     646         [ #  # ]:          0 :             if( !pActFieldDescr )
     647                 :            :             {
     648         [ #  # ]:          0 :                 pDescrCell->SetText(String());
     649                 :          0 :                 pDescrCell->ClearModifyFlag();
     650                 :            :             }
     651                 :            :             else
     652 [ #  # ][ #  # ]:          0 :                 pActFieldDescr->SetDescription( pDescrCell->GetText() );
     653                 :          0 :             break;
     654                 :            :         }
     655                 :            :         case FIELD_PROPERTY_DEFAULT:
     656                 :            :         case FIELD_PROPERTY_REQUIRED:
     657                 :            :         case FIELD_PROPERTY_TEXTLEN:
     658                 :            :         case FIELD_PROPERTY_NUMTYPE:
     659                 :            :         case FIELD_PROPERTY_AUTOINC:
     660                 :            :         case FIELD_PROPERTY_LENGTH:
     661                 :            :         case FIELD_PROPERTY_SCALE:
     662                 :            :         case FIELD_PROPERTY_BOOL_DEFAULT:
     663                 :          0 :             pDescrWin->SaveData(pActFieldDescr);
     664                 :            : 
     665 [ #  # ][ #  # ]:          0 :             if ( FIELD_PROPERTY_AUTOINC == nColId && pActFieldDescr->IsAutoIncrement() )
                 [ #  # ]
     666                 :            :             {
     667                 :          0 :                 OTableController& rController = GetView()->getController();
     668         [ #  # ]:          0 :                 if ( rController.isAutoIncrementPrimaryKey() )
     669                 :            :                 {
     670                 :          0 :                     pActFieldDescr->SetPrimaryKey( true );
     671                 :          0 :                     InvalidateHandleColumn();
     672                 :          0 :                     Invalidate();
     673                 :            :                 }
     674                 :            :             }
     675                 :          0 :             break;
     676                 :            :     }
     677                 :          0 :     return sal_True;
     678                 :            : }
     679                 :            : 
     680                 :            : //------------------------------------------------------------------------------
     681                 :          0 : sal_Bool OTableEditorCtrl::SaveModified()
     682                 :            : {
     683                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     684                 :          0 :     sal_uInt16 nColId = GetCurColumnId();
     685                 :            : 
     686         [ #  # ]:          0 :     switch( nColId )
     687                 :            :     {
     688                 :            :         //////////////////////////////////////////////////////////////
     689                 :            :         // TypeCell
     690                 :            :         case FIELD_TYPE:
     691                 :            :         {
     692                 :            :             //////////////////////////////////////////////////////////////////////
     693                 :            :             // Type umstellen
     694                 :          0 :             resetType();
     695                 :          0 :         } break;
     696                 :            :     }
     697                 :            : 
     698                 :          0 :     return sal_True;
     699                 :            : }
     700                 :            : 
     701                 :            : //------------------------------------------------------------------------------
     702                 :          0 : sal_Bool OTableEditorCtrl::CursorMoving(long nNewRow, sal_uInt16 nNewCol)
     703                 :            : {
     704                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     705                 :            : 
     706         [ #  # ]:          0 :     if (!EditBrowseBox::CursorMoving(nNewRow, nNewCol))
     707                 :          0 :         return sal_False;
     708                 :            : 
     709                 :            :     //////////////////////////////////////////////////////////////////////
     710                 :            :     // Wird nach SaveModified() gerufen, aktuelle Zeile ist noch die alte
     711                 :          0 :     m_nDataPos = nNewRow;
     712                 :          0 :     nOldDataPos = GetCurRow();
     713                 :            : 
     714                 :            :     //////////////////////////////////////////////////////////////////////
     715                 :            :     // Marker umsetzen
     716                 :          0 :     InvalidateStatusCell( nOldDataPos );
     717                 :          0 :     InvalidateStatusCell( m_nDataPos );
     718                 :            : 
     719                 :            :     //////////////////////////////////////////////////////////////////////
     720                 :            :     // Daten des Propertyfensters speichern
     721 [ #  # ][ #  # ]:          0 :     if( SetDataPtr(nOldDataPos) && pDescrWin)
                 [ #  # ]
     722                 :          0 :         pDescrWin->SaveData( pActRow->GetActFieldDescr() );
     723                 :            : 
     724                 :            :     //////////////////////////////////////////////////////////////////////
     725                 :            :     // Neue Daten im Propertyfenster anzeigen
     726 [ #  # ][ #  # ]:          0 :     if( SetDataPtr(m_nDataPos) && pDescrWin)
                 [ #  # ]
     727                 :          0 :         pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
     728                 :            : 
     729                 :          0 :     return sal_True;
     730                 :            : }
     731                 :            : 
     732                 :            : //------------------------------------------------------------------------------
     733                 :          0 : IMPL_LINK( OTableEditorCtrl, InvalidateFieldType, void*, /*EMPTYTAG*/ )
     734                 :            : {
     735                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     736                 :          0 :     nInvalidateTypeEvent = 0;
     737         [ #  # ]:          0 :     Invalidate( GetFieldRectPixel(nOldDataPos, FIELD_TYPE) );
     738                 :            : 
     739                 :          0 :     return 0;
     740                 :            : }
     741                 :            : 
     742                 :            : //------------------------------------------------------------------------------
     743                 :          0 : void OTableEditorCtrl::CellModified( long nRow, sal_uInt16 nColId )
     744                 :            : {
     745                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     746                 :            : 
     747                 :            :     //////////////////////////////////////////////////////////////
     748                 :            :     // Wenn aktuelle Feldbeschreibung NULL, Default setzen
     749         [ #  # ]:          0 :     if(nRow == -1)
     750                 :          0 :         nRow = GetCurRow();
     751         [ #  # ]:          0 :     SetDataPtr( nRow );
     752                 :          0 :     OFieldDescription* pActFieldDescr = pActRow->GetActFieldDescr();
     753                 :            : 
     754         [ #  # ]:          0 :     String sActionDescription;
     755   [ #  #  #  # ]:          0 :     switch ( nColId )
     756                 :            :     {
     757 [ #  # ][ #  # ]:          0 :     case FIELD_NAME:    sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_NAME ) ); break;
         [ #  # ][ #  # ]
     758 [ #  # ][ #  # ]:          0 :     case FIELD_TYPE:    sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_TYPE ) ); break;
         [ #  # ][ #  # ]
     759                 :            :     case HELP_TEXT:
     760 [ #  # ][ #  # ]:          0 :     case COLUMN_DESCRIPTION:   sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_DESCRIPTION ) ); break;
         [ #  # ][ #  # ]
     761 [ #  # ][ #  # ]:          0 :     default:            sActionDescription = String( ModuleRes( STR_CHANGE_COLUMN_ATTRIBUTE ) ); break;
         [ #  # ][ #  # ]
     762                 :            :     }
     763                 :            : 
     764 [ #  # ][ #  # ]:          0 :     GetUndoManager().EnterListAction( sActionDescription, String() );
         [ #  # ][ #  # ]
     765         [ #  # ]:          0 :     if (!pActFieldDescr)
     766                 :            :     {
     767         [ #  # ]:          0 :         const OTypeInfoMap* pTypeInfoMap = GetView()->getController().getTypeInfo();
     768         [ #  # ]:          0 :         if ( !pTypeInfoMap->empty() )
     769                 :            :         {
     770         [ #  # ]:          0 :             OTypeInfoMap::const_iterator aTypeIter = pTypeInfoMap->find(DataType::VARCHAR);
     771         [ #  # ]:          0 :             if ( aTypeIter == pTypeInfoMap->end() )
     772                 :          0 :                 aTypeIter = pTypeInfoMap->begin();
     773         [ #  # ]:          0 :             pActRow->SetFieldType( aTypeIter->second );
     774                 :            :         }
     775                 :            :         else
     776 [ #  # ][ #  # ]:          0 :             pActRow->SetFieldType( GetView()->getController().getTypeInfoFallBack() );
         [ #  # ][ #  # ]
     777                 :            : 
     778 [ #  # ][ #  # ]:          0 :         nInvalidateTypeEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, InvalidateFieldType) );
     779                 :          0 :         pActFieldDescr = pActRow->GetActFieldDescr();
     780         [ #  # ]:          0 :         pDescrWin->DisplayData( pActFieldDescr );
     781 [ #  # ][ #  # ]:          0 :         GetUndoManager().AddUndoAction( new OTableEditorTypeSelUndoAct(this, nRow, nColId+1, TOTypeInfoSP()) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     782                 :            :     }
     783                 :            : 
     784         [ #  # ]:          0 :     if( nColId != FIELD_TYPE )
     785 [ #  # ][ #  # ]:          0 :         GetUndoManager().AddUndoAction( new OTableDesignCellUndoAct(this, nRow, nColId) );
         [ #  # ][ #  # ]
     786                 :            :     else
     787                 :            :     {
     788 [ #  # ][ #  # ]:          0 :         GetUndoManager().AddUndoAction(new OTableEditorTypeSelUndoAct(this, GetCurRow(), nColId, GetFieldDescr(GetCurRow())->getTypeInfo()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     789         [ #  # ]:          0 :         resetType();
     790                 :            :     }
     791                 :            : 
     792         [ #  # ]:          0 :     SaveData(nRow,nColId);
     793                 :            :     // SaveData could create a undo action as well
     794 [ #  # ][ #  # ]:          0 :     GetUndoManager().LeaveListAction();
     795         [ #  # ]:          0 :     RowModified(nRow);
     796         [ #  # ]:          0 :     CellControllerRef xController(Controller());
     797         [ #  # ]:          0 :     if(xController.Is())
     798         [ #  # ]:          0 :         xController->SetModified();
     799                 :            : 
     800                 :            :     //////////////////////////////////////////////////////////////////////
     801                 :            :     // Das ModifyFlag setzen
     802 [ #  # ][ #  # ]:          0 :     GetView()->getController().setModified( sal_True );
     803 [ #  # ][ #  # ]:          0 :     InvalidateFeatures();
                 [ #  # ]
     804                 :          0 : }
     805                 :            : // -----------------------------------------------------------------------------
     806                 :          0 : void OTableEditorCtrl::resetType()
     807                 :            : {
     808                 :          0 :     sal_uInt16 nPos = pTypeCell->GetSelectEntryPos();
     809         [ #  # ]:          0 :     if(nPos != LISTBOX_ENTRY_NOTFOUND)
     810         [ #  # ]:          0 :         SwitchType( GetView()->getController().getTypeInfo(nPos) );
     811                 :            :     else
     812         [ #  # ]:          0 :         SwitchType(TOTypeInfoSP());
     813                 :          0 : }
     814                 :            : //------------------------------------------------------------------------------
     815                 :          0 : void OTableEditorCtrl::CellModified()
     816                 :            : {
     817                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     818                 :          0 :     CellModified( GetCurRow(), GetCurColumnId() );
     819                 :          0 : }
     820                 :            : // -----------------------------------------------------------------------------
     821                 :          0 : void OTableEditorCtrl::InvalidateFeatures()
     822                 :            : {
     823         [ #  # ]:          0 :     GetView()->getController().InvalidateFeature(SID_UNDO);
     824         [ #  # ]:          0 :     GetView()->getController().InvalidateFeature(SID_REDO);
     825         [ #  # ]:          0 :     GetView()->getController().InvalidateFeature(SID_SAVEDOC);
     826                 :          0 : }
     827                 :            : //------------------------------------------------------------------------------
     828                 :          0 : void OTableEditorCtrl::Undo()
     829                 :            : {
     830                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     831                 :            : 
     832                 :          0 :     InvalidateFeatures();
     833                 :          0 : }
     834                 :            : //------------------------------------------------------------------------------
     835                 :          0 : void OTableEditorCtrl::Redo()
     836                 :            : {
     837                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     838                 :          0 :     InvalidateFeatures();
     839                 :          0 : }
     840                 :            : 
     841                 :            : //------------------------------------------------------------------------------
     842                 :          0 : void OTableEditorCtrl::CopyRows()
     843                 :            : {
     844                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     845                 :            :     //////////////////////////////////////////////////////////////////////
     846                 :            :     // set to the right row and save it
     847 [ #  # ][ #  # ]:          0 :     if( SetDataPtr(m_nDataPos) )
     848         [ #  # ]:          0 :         pDescrWin->SaveData( pActRow->GetActFieldDescr() );
     849                 :            : 
     850                 :            :     //////////////////////////////////////////////////////////////////////
     851                 :            :     // Selektierte Zeilen in die ClipboardListe kopieren
     852         [ #  # ]:          0 :      ::boost::shared_ptr<OTableRow>  pClipboardRow;
     853         [ #  # ]:          0 :      ::boost::shared_ptr<OTableRow>  pRow;
     854         [ #  # ]:          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> > vClipboardList;
     855 [ #  # ][ #  # ]:          0 :     vClipboardList.reserve(GetSelectRowCount());
     856                 :            : 
     857 [ #  # ][ #  # ]:          0 :     for( long nIndex=FirstSelectedRow(); nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()); nIndex=NextSelectedRow() )
         [ #  # ][ #  # ]
                 [ #  # ]
     858                 :            :     {
     859         [ #  # ]:          0 :         pRow = (*m_pRowList)[nIndex];
     860                 :            :         OSL_ENSURE(pRow,"OTableEditorCtrl::CopyRows: Row is NULL!");
     861 [ #  # ][ #  # ]:          0 :         if ( pRow && pRow->GetActFieldDescr() )
                 [ #  # ]
     862                 :            :         {
     863 [ #  # ][ #  # ]:          0 :             pClipboardRow.reset(new OTableRow( *pRow ));
                 [ #  # ]
     864         [ #  # ]:          0 :             vClipboardList.push_back( pClipboardRow);
     865                 :            :         }
     866                 :            :     }
     867         [ #  # ]:          0 :     if(!vClipboardList.empty())
     868                 :            :     {
     869         [ #  # ]:          0 :         OTableRowExchange* pData = new OTableRowExchange(vClipboardList);
     870 [ #  # ][ #  # ]:          0 :         Reference< ::com::sun::star::datatransfer::XTransferable> xRef = pData;
     871 [ #  # ][ #  # ]:          0 :         pData->CopyToClipboard(GetParent());
     872 [ #  # ][ #  # ]:          0 :     }
     873                 :          0 : }
     874                 :            : 
     875                 :            : //------------------------------------------------------------------------------
     876                 :          0 : String OTableEditorCtrl::GenerateName( const String& rName )
     877                 :            : {
     878                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     879                 :            :     //////////////////////////////////////////////////////////////////////
     880                 :            :     // Basisnamen zum Anhaengen einer Numerierung erstellen
     881         [ #  # ]:          0 :     String aBaseName;
     882 [ #  # ][ #  # ]:          0 :     Reference<XConnection> xCon = GetView()->getController().getConnection();
     883 [ #  # ][ #  # ]:          0 :     Reference< XDatabaseMetaData> xMetaData = xCon.is() ? xCon->getMetaData() : Reference< XDatabaseMetaData>();
                 [ #  # ]
     884                 :            : 
     885 [ #  # ][ #  # ]:          0 :     xub_StrLen nMaxTextLen((xub_StrLen)( xMetaData.is() ? xMetaData->getMaxColumnNameLength() : 0));
                 [ #  # ]
     886                 :            : 
     887         [ #  # ]:          0 :     if( (rName.Len()+2) >nMaxTextLen )
     888 [ #  # ][ #  # ]:          0 :         aBaseName = rName.Copy( 0, nMaxTextLen-2 );
                 [ #  # ]
     889                 :            :     else
     890         [ #  # ]:          0 :         aBaseName = rName;
     891                 :            : 
     892                 :            :     //////////////////////////////////////////////////////////////////////
     893                 :            :     // Namen durchnumerieren (bis 99)
     894         [ #  # ]:          0 :     String aFieldName( rName);
     895                 :          0 :     sal_Int32 i=1;
     896 [ #  # ][ #  # ]:          0 :     while( HasFieldName(aFieldName) )
     897                 :            :     {
     898         [ #  # ]:          0 :         aFieldName = aBaseName;
     899 [ #  # ][ #  # ]:          0 :         aFieldName += String::CreateFromInt32(i);
                 [ #  # ]
     900                 :          0 :         i++;
     901                 :            :     }
     902                 :            : 
     903         [ #  # ]:          0 :     return aFieldName;
     904                 :            : }
     905                 :            : 
     906                 :            : //------------------------------------------------------------------------------
     907                 :          0 : void OTableEditorCtrl::InsertRows( long nRow )
     908                 :            : {
     909                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     910                 :            : 
     911         [ #  # ]:          0 :     ::std::vector<  ::boost::shared_ptr<OTableRow> > vInsertedUndoRedoRows; // need for undo/redo handling
     912                 :            :     //////////////////////////////////////////////////////////////////////
     913                 :            :     // get rows from clipboard
     914 [ #  # ][ #  # ]:          0 :     TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
     915 [ #  # ][ #  # ]:          0 :     if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
     916                 :            :     {
     917                 :          0 :         SotStorageStreamRef aStreamRef;
     918         [ #  # ]:          0 :         aTransferData.GetSotStorageStream(SOT_FORMATSTR_ID_SBA_TABED,aStreamRef);
     919         [ #  # ]:          0 :         if(aStreamRef.Is())
     920                 :            :         {
     921         [ #  # ]:          0 :             aStreamRef->Seek(STREAM_SEEK_TO_BEGIN);
     922         [ #  # ]:          0 :             aStreamRef->ResetError();
     923                 :          0 :             long nInsertRow = nRow;
     924         [ #  # ]:          0 :             String aFieldName;
     925         [ #  # ]:          0 :              ::boost::shared_ptr<OTableRow>  pRow;
     926                 :          0 :             sal_Int32 nSize = 0;
     927         [ #  # ]:          0 :             (*aStreamRef) >> nSize;
     928         [ #  # ]:          0 :             vInsertedUndoRedoRows.reserve(nSize);
     929         [ #  # ]:          0 :             for(sal_Int32 i=0;i < nSize;++i)
     930                 :            :             {
     931 [ #  # ][ #  # ]:          0 :                 pRow.reset(new OTableRow());
                 [ #  # ]
     932         [ #  # ]:          0 :                 (*aStreamRef) >> *pRow;
     933                 :          0 :                 pRow->SetReadOnly( sal_False );
     934         [ #  # ]:          0 :                 sal_Int32 nType = pRow->GetActFieldDescr()->GetType();
     935         [ #  # ]:          0 :                 if ( pRow->GetActFieldDescr() )
     936 [ #  # ][ #  # ]:          0 :                     pRow->GetActFieldDescr()->SetType(GetView()->getController().getTypeInfoByType(nType));
         [ #  # ][ #  # ]
     937                 :            :                 //////////////////////////////////////////////////////////////////////
     938                 :            :                 // Anpassen des Feldnamens
     939 [ #  # ][ #  # ]:          0 :                 aFieldName = GenerateName( pRow->GetActFieldDescr()->GetName() );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     940 [ #  # ][ #  # ]:          0 :                 pRow->GetActFieldDescr()->SetName( aFieldName );
     941                 :          0 :                 pRow->SetPos(nInsertRow);
     942 [ #  # ][ #  # ]:          0 :                 m_pRowList->insert( m_pRowList->begin()+nInsertRow,pRow );
     943 [ #  # ][ #  # ]:          0 :                 vInsertedUndoRedoRows.push_back(::boost::shared_ptr<OTableRow>(new OTableRow(*pRow)));
         [ #  # ][ #  # ]
                 [ #  # ]
     944                 :          0 :                 nInsertRow++;
     945 [ #  # ][ #  # ]:          0 :             }
     946         [ #  # ]:          0 :         }
     947                 :            :     }
     948                 :            :     //////////////////////////////////////////////////////////////////////
     949                 :            :     // Beim RowInserted wird CursorMoved gerufen.
     950                 :            :     // Die UI-Daten duerfen hier beim CursorMoved nicht gespeichert werden.
     951                 :          0 :     bSaveOnMove = sal_False;
     952         [ #  # ]:          0 :     RowInserted( nRow,vInsertedUndoRedoRows.size(),sal_True );
     953                 :          0 :     bSaveOnMove = sal_True;
     954                 :            : 
     955                 :            :     //////////////////////////////////////////////////////////////////////
     956                 :            :     // Undo-Action erzeugen
     957 [ #  # ][ #  # ]:          0 :     GetUndoManager().AddUndoAction( new OTableEditorInsUndoAct(this, nRow,vInsertedUndoRedoRows) );
         [ #  # ][ #  # ]
     958 [ #  # ][ #  # ]:          0 :     GetView()->getController().setModified( sal_True );
     959 [ #  # ][ #  # ]:          0 :     InvalidateFeatures();
     960                 :          0 : }
     961                 :            : 
     962                 :            : //------------------------------------------------------------------------------
     963                 :          0 : void OTableEditorCtrl::DeleteRows()
     964                 :            : {
     965                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
     966                 :            :     OSL_ENSURE(GetView()->getController().isDropAllowed(),"Call of DeleteRows not valid here. Please check isDropAllowed!");
     967                 :            :     //////////////////////////////////////////////////////////////////////
     968                 :            :     // Undo-Action erzeugen
     969         [ #  # ]:          0 :     GetUndoManager().AddUndoAction( new OTableEditorDelUndoAct(this) );
     970                 :            : 
     971                 :            : 
     972                 :            :     //////////////////////////////////////////////////////////////////////
     973                 :            :     // Alle markierten Zeilen loeschen
     974                 :          0 :     long nIndex = FirstSelectedRow();
     975                 :          0 :     nOldDataPos = nIndex;
     976                 :          0 :     bSaveOnMove = sal_False;
     977                 :            : 
     978 [ #  # ][ #  # ]:          0 :     while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
                 [ #  # ]
     979                 :            :     {
     980                 :            :         //////////////////////////////////////////////////////////////////////
     981                 :            :         // Zeile entfernen
     982 [ #  # ][ #  # ]:          0 :         m_pRowList->erase( m_pRowList->begin()+nIndex );
     983                 :          0 :         RowRemoved( nIndex, 1, sal_True );
     984                 :            : 
     985                 :            :         //////////////////////////////////////////////////////////////////////
     986                 :            :         // Leerzeile am Ende wieder einfuegen
     987 [ #  # ][ #  # ]:          0 :         m_pRowList->push_back( ::boost::shared_ptr<OTableRow>(new OTableRow()));
     988                 :          0 :         RowInserted( GetRowCount()-1, 1, sal_True );
     989                 :            : 
     990                 :          0 :         nIndex = FirstSelectedRow();
     991                 :            :     }
     992                 :            : 
     993                 :          0 :     bSaveOnMove = sal_True;
     994                 :            : 
     995                 :            :     //////////////////////////////////////////////////////////////////////
     996                 :            :     // Erzwingen, dass der aktuelle Datensatz angezeigt wird
     997                 :          0 :     m_nDataPos = GetCurRow();
     998                 :          0 :     InvalidateStatusCell( nOldDataPos );
     999                 :          0 :     InvalidateStatusCell( m_nDataPos );
    1000                 :          0 :     SetDataPtr( m_nDataPos );
    1001                 :          0 :     ActivateCell();
    1002                 :          0 :     pDescrWin->DisplayData( pActRow->GetActFieldDescr() );
    1003                 :          0 :     GetView()->getController().setModified( sal_True );
    1004                 :          0 :     InvalidateFeatures();
    1005                 :          0 : }
    1006                 :            : 
    1007                 :            : //------------------------------------------------------------------------------
    1008                 :          0 : void OTableEditorCtrl::InsertNewRows( long nRow )
    1009                 :            : {
    1010                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1011                 :            :     OSL_ENSURE(GetView()->getController().isAddAllowed(),"Call of InsertNewRows not valid here. Please check isAppendAllowed!");
    1012                 :            :     //////////////////////////////////////////////////////////////////////
    1013                 :            :     // Undo-Action erzeugen
    1014                 :          0 :     long nInsertRows = GetSelectRowCount();
    1015         [ #  # ]:          0 :     if( !nInsertRows )
    1016                 :          0 :         nInsertRows = 1;
    1017         [ #  # ]:          0 :     GetUndoManager().AddUndoAction( new OTableEditorInsNewUndoAct(this, nRow, nInsertRows) );
    1018                 :            :     //////////////////////////////////////////////////////////////////////
    1019                 :            :     // Zahl der selektierten Zeilen werden neu eingefuegt
    1020         [ #  # ]:          0 :     for( long i=nRow; i<(nRow+nInsertRows); i++ )
    1021 [ #  # ][ #  # ]:          0 :         m_pRowList->insert( m_pRowList->begin()+i ,::boost::shared_ptr<OTableRow>(new OTableRow()));
                 [ #  # ]
    1022                 :          0 :     RowInserted( nRow, nInsertRows, sal_True );
    1023                 :            : 
    1024                 :          0 :     GetView()->getController().setModified( sal_True );
    1025                 :          0 :     InvalidateFeatures();
    1026                 :          0 : }
    1027                 :            : 
    1028                 :            : //------------------------------------------------------------------------------
    1029                 :          0 : String OTableEditorCtrl::GetControlText( long nRow, sal_uInt16 nColId )
    1030                 :            : {
    1031                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1032                 :            :     //////////////////////////////////////////////////////////////////////
    1033                 :            :     // Controls des Browsers auslesen
    1034         [ #  # ]:          0 :     if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
    1035                 :            :     {
    1036         [ #  # ]:          0 :         GoToRow( nRow );
    1037         [ #  # ]:          0 :         GoToColumnId( nColId );
    1038         [ #  # ]:          0 :         CellControllerRef xController = Controller();
    1039         [ #  # ]:          0 :         if(xController.Is())
    1040         [ #  # ]:          0 :             return xController->GetWindow().GetText();
    1041                 :            :         else
    1042 [ #  # ][ #  # ]:          0 :             return GetCellText(nRow,nColId);
    1043                 :            :     }
    1044                 :            : 
    1045                 :            :     //////////////////////////////////////////////////////////////////////
    1046                 :            :     // Controls der Tabpage Auslesen
    1047                 :            :     else
    1048                 :          0 :         return pDescrWin->GetControlText( nColId );
    1049                 :            : }
    1050                 :            : 
    1051                 :            : //------------------------------------------------------------------------------
    1052                 :          0 : void OTableEditorCtrl::SetControlText( long nRow, sal_uInt16 nColId, const String& rText )
    1053                 :            : {
    1054                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1055                 :            :     //////////////////////////////////////////////////////////////////////
    1056                 :            :     // Controls des Browsers setzen
    1057         [ #  # ]:          0 :     if( nColId < FIELD_FIRST_VIRTUAL_COLUMN )
    1058                 :            :     {
    1059         [ #  # ]:          0 :         GoToRow( nRow );
    1060         [ #  # ]:          0 :         GoToColumnId( nColId );
    1061         [ #  # ]:          0 :         CellControllerRef xController = Controller();
    1062         [ #  # ]:          0 :         if(xController.Is())
    1063         [ #  # ]:          0 :             xController->GetWindow().SetText( rText );
    1064                 :            :         else
    1065 [ #  # ][ #  # ]:          0 :             RowModified(nRow,nColId);
    1066                 :            :     }
    1067                 :            : 
    1068                 :            :     //////////////////////////////////////////////////////////////////////
    1069                 :            :     // Controls der Tabpage setzen
    1070                 :            :     else
    1071                 :            :     {
    1072                 :          0 :         pDescrWin->SetControlText( nColId, rText );
    1073                 :            :     }
    1074                 :          0 : }
    1075                 :            : //------------------------------------------------------------------------------
    1076                 :          0 : void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const TOTypeInfoSP& _pTypeInfo )
    1077                 :            : {
    1078                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1079                 :            :     //////////////////////////////////////////////////////////////////////
    1080                 :            :     // Aktuellen Datenzeiger umsetzen
    1081         [ #  # ]:          0 :     if( nRow == -1 )
    1082                 :          0 :         nRow = GetCurRow();
    1083                 :          0 :     OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
    1084 [ #  # ][ #  # ]:          0 :     if( !pFieldDescr && nColId != FIELD_TYPE)
    1085                 :          0 :         return;
    1086                 :            : 
    1087                 :            :     //////////////////////////////////////////////////////////////////////
    1088                 :            :     // Einzelne Felder setzen
    1089         [ #  # ]:          0 :     switch( nColId )
    1090                 :            :     {
    1091                 :            :         case FIELD_TYPE:
    1092                 :          0 :             SwitchType( _pTypeInfo );
    1093                 :          0 :             break;
    1094                 :            :         default:
    1095                 :            :             OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
    1096                 :            :     }
    1097 [ #  # ][ #  # ]:          0 :     SetControlText(nRow,nColId,_pTypeInfo.get() ? _pTypeInfo->aUIName : ::rtl::OUString());
         [ #  # ][ #  # ]
    1098                 :            : }
    1099                 :            : //------------------------------------------------------------------------------
    1100                 :          0 : void OTableEditorCtrl::SetCellData( long nRow, sal_uInt16 nColId, const ::com::sun::star::uno::Any& _rNewData )
    1101                 :            : {
    1102                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1103                 :            :     //////////////////////////////////////////////////////////////////////
    1104                 :            :     // Aktuellen Datenzeiger umsetzen
    1105         [ #  # ]:          0 :     if( nRow == -1 )
    1106                 :          0 :         nRow = GetCurRow();
    1107         [ #  # ]:          0 :     OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
    1108 [ #  # ][ #  # ]:          0 :     if( !pFieldDescr && nColId != FIELD_TYPE)
    1109                 :          0 :         return;
    1110                 :            : 
    1111         [ #  # ]:          0 :     String sValue;
    1112                 :            :     //////////////////////////////////////////////////////////////////////
    1113                 :            :     // Einzelne Felder setzen
    1114   [ #  #  #  #  :          0 :     switch( nColId )
          #  #  #  #  #  
                #  #  # ]
    1115                 :            :     {
    1116                 :            :         case FIELD_NAME:
    1117 [ #  # ][ #  # ]:          0 :             sValue = ::comphelper::getString(_rNewData);
    1118 [ #  # ][ #  # ]:          0 :             pFieldDescr->SetName( sValue );
    1119                 :          0 :             break;
    1120                 :            : 
    1121                 :            :         case FIELD_TYPE:
    1122                 :            :             OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
    1123                 :          0 :             break;
    1124                 :            : 
    1125                 :            :         case COLUMN_DESCRIPTION:
    1126 [ #  # ][ #  # ]:          0 :             pFieldDescr->SetDescription( sValue = ::comphelper::getString(_rNewData) );
         [ #  # ][ #  # ]
    1127                 :          0 :             break;
    1128                 :            : 
    1129                 :            :         case FIELD_PROPERTY_DEFAULT:
    1130         [ #  # ]:          0 :             pFieldDescr->SetControlDefault( _rNewData );
    1131 [ #  # ][ #  # ]:          0 :             sValue = GetView()->GetDescWin()->getGenPage()->getFieldControl()->getControlDefault(pFieldDescr);
         [ #  # ][ #  # ]
    1132                 :          0 :             break;
    1133                 :            : 
    1134                 :            :         case FIELD_PROPERTY_REQUIRED:
    1135                 :            :             {
    1136 [ #  # ][ #  # ]:          0 :                 sValue = ::comphelper::getString(_rNewData);
    1137 [ #  # ][ #  # ]:          0 :                 pFieldDescr->SetIsNullable( sValue.ToInt32() );
    1138                 :            :             }
    1139                 :          0 :             break;
    1140                 :            : 
    1141                 :            :         case FIELD_PROPERTY_TEXTLEN:
    1142                 :            :         case FIELD_PROPERTY_LENGTH:
    1143                 :            :             {
    1144 [ #  # ][ #  # ]:          0 :                 sValue = ::comphelper::getString(_rNewData);
    1145 [ #  # ][ #  # ]:          0 :                 pFieldDescr->SetPrecision( sValue.ToInt32() );
    1146                 :            :             }
    1147                 :          0 :             break;
    1148                 :            : 
    1149                 :            :         case FIELD_PROPERTY_NUMTYPE:
    1150                 :            :             OSL_FAIL("OTableEditorCtrl::SetCellData: invalid column!");
    1151                 :          0 :             break;
    1152                 :            : 
    1153                 :            :         case FIELD_PROPERTY_AUTOINC:
    1154                 :            :             {
    1155 [ #  # ][ #  # ]:          0 :                 String strYes(ModuleRes(STR_VALUE_YES));
    1156 [ #  # ][ #  # ]:          0 :                 sValue = ::comphelper::getString(_rNewData);
    1157 [ #  # ][ #  # ]:          0 :                 pFieldDescr->SetAutoIncrement(sValue.Equals(strYes));
                 [ #  # ]
    1158                 :            :             }
    1159                 :          0 :             break;
    1160                 :            :         case FIELD_PROPERTY_SCALE:
    1161                 :            :             {
    1162 [ #  # ][ #  # ]:          0 :                 sValue = ::comphelper::getString(_rNewData);
    1163 [ #  # ][ #  # ]:          0 :                 pFieldDescr->SetScale(sValue.ToInt32());
    1164                 :            :             }
    1165                 :          0 :             break;
    1166                 :            : 
    1167                 :            :         case FIELD_PROPERTY_BOOL_DEFAULT:
    1168 [ #  # ][ #  # ]:          0 :             sValue = GetView()->GetDescWin()->BoolStringPersistent(::comphelper::getString(_rNewData));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1169 [ #  # ][ #  # ]:          0 :             pFieldDescr->SetControlDefault(makeAny(::rtl::OUString(sValue)));
                 [ #  # ]
    1170                 :          0 :             break;
    1171                 :            : 
    1172                 :            :         case FIELD_PROPERTY_FORMAT:
    1173                 :            :             {
    1174 [ #  # ][ #  # ]:          0 :                 sValue = ::comphelper::getString(_rNewData);
    1175 [ #  # ][ #  # ]:          0 :                 pFieldDescr->SetFormatKey(sValue.ToInt32());
    1176                 :            :             }
    1177                 :          0 :             break;
    1178                 :            :     }
    1179                 :            : 
    1180 [ #  # ][ #  # ]:          0 :     SetControlText(nRow,nColId,sValue);
    1181                 :            : }
    1182                 :            : 
    1183                 :            : //------------------------------------------------------------------------------
    1184                 :          0 : Any OTableEditorCtrl::GetCellData( long nRow, sal_uInt16 nColId )
    1185                 :            : {
    1186                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1187         [ #  # ]:          0 :     OFieldDescription* pFieldDescr = GetFieldDescr( nRow );
    1188         [ #  # ]:          0 :     if( !pFieldDescr )
    1189                 :          0 :         return Any();
    1190                 :            : 
    1191                 :            :     //////////////////////////////////////////////////////////////////////
    1192                 :            :     // Aktuellen Datenzeiger umsetzen
    1193         [ #  # ]:          0 :     if( nRow==-1 )
    1194                 :          0 :         nRow = GetCurRow();
    1195         [ #  # ]:          0 :     SetDataPtr( nRow );
    1196                 :            : 
    1197 [ #  # ][ #  # ]:          0 :     static const String strYes(ModuleRes(STR_VALUE_YES));
         [ #  # ][ #  # ]
                 [ #  # ]
    1198 [ #  # ][ #  # ]:          0 :     static const String strNo(ModuleRes(STR_VALUE_NO));
         [ #  # ][ #  # ]
                 [ #  # ]
    1199                 :          0 :     ::rtl::OUString sValue;
    1200                 :            :     //////////////////////////////////////////////////////////////////////
    1201                 :            :     // Einzelne Felder auslesen
    1202   [ #  #  #  #  :          0 :     switch( nColId )
          #  #  #  #  #  
             #  #  #  # ]
    1203                 :            :     {
    1204                 :            :         case FIELD_NAME:
    1205         [ #  # ]:          0 :             sValue = pFieldDescr->GetName();
    1206                 :          0 :             break;
    1207                 :            : 
    1208                 :            :         case FIELD_TYPE:
    1209 [ #  # ][ #  # ]:          0 :             if ( pFieldDescr->getTypeInfo() )
                 [ #  # ]
    1210 [ #  # ][ #  # ]:          0 :                 sValue = pFieldDescr->getTypeInfo()->aUIName;
    1211                 :          0 :             break;
    1212                 :            : 
    1213                 :            :         case COLUMN_DESCRIPTION:
    1214         [ #  # ]:          0 :             sValue = pFieldDescr->GetDescription();
    1215                 :          0 :             break;
    1216                 :            :         case HELP_TEXT:
    1217         [ #  # ]:          0 :             sValue = pFieldDescr->GetHelpText();
    1218                 :          0 :             break;
    1219                 :            : 
    1220                 :            :         case FIELD_PROPERTY_DEFAULT:
    1221         [ #  # ]:          0 :             return pFieldDescr->GetControlDefault();
    1222                 :            : 
    1223                 :            :         case FIELD_PROPERTY_REQUIRED:
    1224 [ #  # ][ #  # ]:          0 :             sValue = pFieldDescr->GetIsNullable() == ColumnValue::NULLABLE ? strYes : strNo;
                 [ #  # ]
    1225                 :          0 :             break;
    1226                 :            : 
    1227                 :            :         case FIELD_PROPERTY_TEXTLEN:
    1228                 :            :         case FIELD_PROPERTY_LENGTH:
    1229 [ #  # ][ #  # ]:          0 :             sValue = String::CreateFromInt32(pFieldDescr->GetPrecision());
         [ #  # ][ #  # ]
    1230                 :          0 :             break;
    1231                 :            : 
    1232                 :            :         case FIELD_PROPERTY_NUMTYPE:
    1233                 :            :             OSL_FAIL("OTableEditorCtrl::GetCellData: invalid column!");
    1234                 :          0 :             break;
    1235                 :            : 
    1236                 :            :         case FIELD_PROPERTY_AUTOINC:
    1237 [ #  # ][ #  # ]:          0 :             sValue = pFieldDescr->IsAutoIncrement() ? strYes : strNo;
                 [ #  # ]
    1238                 :          0 :             break;
    1239                 :            : 
    1240                 :            :         case FIELD_PROPERTY_SCALE:
    1241 [ #  # ][ #  # ]:          0 :             sValue = String::CreateFromInt32(pFieldDescr->GetScale());
         [ #  # ][ #  # ]
    1242                 :          0 :             break;
    1243                 :            : 
    1244                 :            :         case FIELD_PROPERTY_BOOL_DEFAULT:
    1245 [ #  # ][ #  # ]:          0 :             sValue = GetView()->GetDescWin()->BoolStringUI(::comphelper::getString(pFieldDescr->GetControlDefault()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1246                 :          0 :             break;
    1247                 :            : 
    1248                 :            :         case FIELD_PROPERTY_FORMAT:
    1249 [ #  # ][ #  # ]:          0 :             sValue = String::CreateFromInt32(pFieldDescr->GetFormatKey());
         [ #  # ][ #  # ]
    1250                 :          0 :             break;
    1251                 :            :     }
    1252                 :            : 
    1253         [ #  # ]:          0 :     return makeAny(sValue);
    1254                 :            : }
    1255                 :            : 
    1256                 :            : //------------------------------------------------------------------------------
    1257                 :          0 : String OTableEditorCtrl::GetCellText( long nRow, sal_uInt16 nColId ) const
    1258                 :            : {
    1259                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1260                 :          0 :     ::rtl::OUString sCellText;
    1261         [ #  # ]:          0 :     const_cast< OTableEditorCtrl* >( this )->GetCellData( nRow, nColId ) >>= sCellText;
    1262         [ #  # ]:          0 :     return sCellText;
    1263                 :            : }
    1264                 :            : 
    1265                 :            : //------------------------------------------------------------------------------
    1266                 :          0 : sal_uInt32 OTableEditorCtrl::GetTotalCellWidth(long nRow, sal_uInt16 nColId)
    1267                 :            : {
    1268                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1269 [ #  # ][ #  # ]:          0 :     return GetTextWidth(GetCellText(nRow, nColId)) + 2 * GetTextWidth(rtl::OUString('0'));
         [ #  # ][ #  # ]
    1270                 :            : }
    1271                 :            : 
    1272                 :            : //------------------------------------------------------------------------------
    1273                 :          0 : OFieldDescription* OTableEditorCtrl::GetFieldDescr( long nRow )
    1274                 :            : {
    1275                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1276                 :            :     std::vector< ::boost::shared_ptr<OTableRow> >::size_type nListCount(
    1277                 :          0 :         m_pRowList->size());
    1278 [ #  # ][ #  # ]:          0 :     if( (nRow<0) || (sal::static_int_cast< unsigned long >(nRow)>=nListCount) )
                 [ #  # ]
    1279                 :            :     {
    1280                 :            :         OSL_FAIL("(nRow<0) || (nRow>=nListCount)");
    1281                 :          0 :         return NULL;
    1282                 :            :     }
    1283         [ #  # ]:          0 :      ::boost::shared_ptr<OTableRow>  pRow = (*m_pRowList)[ nRow ];
    1284         [ #  # ]:          0 :     if( !pRow )
    1285                 :          0 :         return NULL;
    1286         [ #  # ]:          0 :     return pRow->GetActFieldDescr();
    1287                 :            : }
    1288                 :            : 
    1289                 :            : //------------------------------------------------------------------------------
    1290                 :          0 : sal_Bool OTableEditorCtrl::IsCutAllowed( long nRow )
    1291                 :            : {
    1292                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1293                 :          0 :     sal_Bool bIsCutAllowed = (GetView()->getController().isAddAllowed() && GetView()->getController().isDropAllowed()) ||
    1294         [ #  # ]:          0 :                             GetView()->getController().isAlterAllowed();
           [ #  #  #  # ]
    1295                 :            : 
    1296         [ #  # ]:          0 :     if(bIsCutAllowed)
    1297                 :            :     {
    1298   [ #  #  #  #  :          0 :         switch(m_eChildFocus)
                      # ]
    1299                 :            :         {
    1300                 :            :             case DESCRIPTION:
    1301                 :          0 :                 bIsCutAllowed = pDescrCell->GetSelected().Len() != 0;
    1302                 :          0 :                 break;
    1303                 :            :             case HELPTEXT:
    1304                 :          0 :                 bIsCutAllowed = pHelpTextCell->GetSelected().Len() != 0;
    1305                 :          0 :                 break;
    1306                 :            :             case NAME:
    1307                 :          0 :                 bIsCutAllowed = pNameCell->GetSelected().Len() != 0;
    1308                 :          0 :                 break;
    1309                 :            :             case ROW:
    1310                 :          0 :                 bIsCutAllowed = IsCopyAllowed(nRow);
    1311                 :          0 :                 break;
    1312                 :            :             default:
    1313                 :          0 :                 bIsCutAllowed = sal_False;
    1314                 :          0 :                 break;
    1315                 :            :         }
    1316                 :            :     }
    1317                 :            : 
    1318                 :          0 :     return bIsCutAllowed;
    1319                 :            : }
    1320                 :            : 
    1321                 :            : //------------------------------------------------------------------------------
    1322                 :          0 : sal_Bool OTableEditorCtrl::IsCopyAllowed( long /*nRow*/ )
    1323                 :            : {
    1324                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1325                 :          0 :     sal_Bool bIsCopyAllowed = sal_False;
    1326         [ #  # ]:          0 :     if(m_eChildFocus == DESCRIPTION )
    1327                 :          0 :         bIsCopyAllowed = pDescrCell->GetSelected().Len() != 0;
    1328         [ #  # ]:          0 :     else if(HELPTEXT == m_eChildFocus )
    1329                 :          0 :         bIsCopyAllowed = pHelpTextCell->GetSelected().Len() != 0;
    1330         [ #  # ]:          0 :     else if(m_eChildFocus == NAME)
    1331                 :          0 :         bIsCopyAllowed = pNameCell->GetSelected().Len() != 0;
    1332         [ #  # ]:          0 :     else if(m_eChildFocus == ROW)
    1333                 :            :     {
    1334 [ #  # ][ #  # ]:          0 :         Reference<XPropertySet> xTable = GetView()->getController().getTable();
    1335 [ #  # ][ #  # ]:          0 :         if( !GetSelectRowCount() || (xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW"))))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                #  #  # ]
    1336                 :          0 :             return sal_False;
    1337                 :            : 
    1338                 :            :         //////////////////////////////////////////////////////////////////////
    1339                 :            :         // Wenn eine der markierten Zeilen leer ist, kein Copy moeglich
    1340         [ #  # ]:          0 :          ::boost::shared_ptr<OTableRow>  pRow;
    1341         [ #  # ]:          0 :         long nIndex = FirstSelectedRow();
    1342 [ #  # ][ #  # ]:          0 :         while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
                 [ #  # ]
    1343                 :            :         {
    1344         [ #  # ]:          0 :             pRow = (*m_pRowList)[nIndex];
    1345         [ #  # ]:          0 :             if( !pRow->GetActFieldDescr() )
    1346                 :          0 :                 return sal_False;
    1347                 :            : 
    1348         [ #  # ]:          0 :             nIndex = NextSelectedRow();
    1349                 :            :         }
    1350                 :            : 
    1351 [ #  # ][ #  # ]:          0 :         bIsCopyAllowed = sal_True;
                 [ #  # ]
    1352                 :            :     }
    1353                 :            : 
    1354                 :          0 :     return bIsCopyAllowed;
    1355                 :            : }
    1356                 :            : 
    1357                 :            : //------------------------------------------------------------------------------
    1358                 :          0 : sal_Bool OTableEditorCtrl::IsPasteAllowed( long /*nRow*/ )
    1359                 :            : {
    1360                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1361                 :          0 :     sal_Bool bAllowed = GetView()->getController().isAddAllowed();
    1362         [ #  # ]:          0 :     if ( bAllowed )
    1363                 :            :     {
    1364 [ #  # ][ #  # ]:          0 :         TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
    1365         [ #  # ]:          0 :         sal_Bool bRowFormat = aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED);
    1366         [ #  # ]:          0 :         if ( m_eChildFocus == ROW )
    1367                 :          0 :             bAllowed = bRowFormat;
    1368                 :            :         else
    1369 [ #  # ][ #  # ]:          0 :             bAllowed = !bRowFormat && aTransferData.HasFormat(SOT_FORMAT_STRING);
         [ #  # ][ #  # ]
    1370                 :            :     }
    1371                 :            : 
    1372                 :          0 :     return bAllowed;
    1373                 :            : }
    1374                 :            : 
    1375                 :            : //------------------------------------------------------------------------------
    1376                 :          0 : void OTableEditorCtrl::cut()
    1377                 :            : {
    1378         [ #  # ]:          0 :     if(m_eChildFocus == NAME)
    1379                 :            :     {
    1380         [ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
    1381                 :            :         {
    1382                 :          0 :             SaveData(-1,FIELD_NAME);
    1383                 :          0 :             pNameCell->Cut();
    1384                 :          0 :             CellModified(-1,FIELD_NAME);
    1385                 :            :         }
    1386                 :            :     }
    1387         [ #  # ]:          0 :     else if(m_eChildFocus == DESCRIPTION)
    1388                 :            :     {
    1389         [ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
    1390                 :            :         {
    1391                 :          0 :             SaveData(-1,COLUMN_DESCRIPTION);
    1392                 :          0 :             pDescrCell->Cut();
    1393                 :          0 :             CellModified(-1,COLUMN_DESCRIPTION);
    1394                 :            :         }
    1395                 :            :     }
    1396         [ #  # ]:          0 :     else if(HELPTEXT == m_eChildFocus )
    1397                 :            :     {
    1398         [ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
    1399                 :            :         {
    1400                 :          0 :             SaveData(-1,HELP_TEXT);
    1401                 :          0 :             pHelpTextCell->Cut();
    1402                 :          0 :             CellModified(-1,HELP_TEXT);
    1403                 :            :         }
    1404                 :            :     }
    1405         [ #  # ]:          0 :     else if(m_eChildFocus == ROW)
    1406                 :            :     {
    1407         [ #  # ]:          0 :         if (nCutEvent)
    1408                 :          0 :             Application::RemoveUserEvent(nCutEvent);
    1409         [ #  # ]:          0 :         nCutEvent = Application::PostUserEvent(LINK(this, OTableEditorCtrl, DelayedCut));
    1410                 :            :     }
    1411                 :          0 : }
    1412                 :            : 
    1413                 :            : //------------------------------------------------------------------------------
    1414                 :          0 : void OTableEditorCtrl::copy()
    1415                 :            : {
    1416         [ #  # ]:          0 :     if(GetSelectRowCount())
    1417                 :          0 :         OTableRowView::copy();
    1418         [ #  # ]:          0 :     else if(m_eChildFocus == NAME)
    1419                 :          0 :         pNameCell->Copy();
    1420         [ #  # ]:          0 :     else if(HELPTEXT == m_eChildFocus )
    1421                 :          0 :         pHelpTextCell->Copy();
    1422         [ #  # ]:          0 :     else if(m_eChildFocus == DESCRIPTION )
    1423                 :          0 :         pDescrCell->Copy();
    1424                 :          0 : }
    1425                 :            : 
    1426                 :            : //------------------------------------------------------------------------------
    1427                 :          0 : void OTableEditorCtrl::paste()
    1428                 :            : {
    1429 [ #  # ][ #  # ]:          0 :     TransferableDataHelper aTransferData(TransferableDataHelper::CreateFromSystemClipboard(GetParent()));
    1430 [ #  # ][ #  # ]:          0 :     if(aTransferData.HasFormat(SOT_FORMATSTR_ID_SBA_TABED))
    1431                 :            :     {
    1432         [ #  # ]:          0 :         if( nPasteEvent )
    1433         [ #  # ]:          0 :             Application::RemoveUserEvent( nPasteEvent );
    1434 [ #  # ][ #  # ]:          0 :         nPasteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedPaste) );
    1435                 :            :     }
    1436         [ #  # ]:          0 :     else if(m_eChildFocus == NAME)
    1437                 :            :     {
    1438 [ #  # ][ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
                 [ #  # ]
    1439                 :            :         {
    1440         [ #  # ]:          0 :             pNameCell->Paste();
    1441         [ #  # ]:          0 :             CellModified();
    1442                 :            :         }
    1443                 :            :     }
    1444         [ #  # ]:          0 :     else if(HELPTEXT == m_eChildFocus )
    1445                 :            :     {
    1446 [ #  # ][ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
                 [ #  # ]
    1447                 :            :         {
    1448         [ #  # ]:          0 :             pHelpTextCell->Paste();
    1449         [ #  # ]:          0 :             CellModified();
    1450                 :            :         }
    1451                 :            :     }
    1452         [ #  # ]:          0 :     else if(m_eChildFocus == DESCRIPTION)
    1453                 :            :     {
    1454 [ #  # ][ #  # ]:          0 :         if(GetView()->getController().isAlterAllowed())
                 [ #  # ]
    1455                 :            :         {
    1456         [ #  # ]:          0 :             pDescrCell->Paste();
    1457         [ #  # ]:          0 :             CellModified();
    1458                 :            :         }
    1459         [ #  # ]:          0 :     }
    1460                 :          0 : }
    1461                 :            : 
    1462                 :            : //------------------------------------------------------------------------------
    1463                 :          0 : sal_Bool OTableEditorCtrl::IsDeleteAllowed( long /*nRow*/ )
    1464                 :            : {
    1465                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1466                 :            : 
    1467 [ #  # ][ #  # ]:          0 :     return GetSelectRowCount() != 0 && GetView()->getController().isDropAllowed();
    1468                 :            : }
    1469                 :            : 
    1470                 :            : //------------------------------------------------------------------------------
    1471                 :          0 : sal_Bool OTableEditorCtrl::IsInsertNewAllowed( long nRow )
    1472                 :            : {
    1473                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1474                 :            : 
    1475                 :          0 :     sal_Bool bInsertNewAllowed = GetView()->getController().isAddAllowed();
    1476                 :            :     //////////////////////////////////////////////////////////////
    1477                 :            :     // Wenn nur Felder hinzugefuegt werden duerfen, Paste nur in neue Felder
    1478 [ #  # ][ #  # ]:          0 :     if (bInsertNewAllowed && !GetView()->getController().isDropAllowed())
                 [ #  # ]
    1479                 :            :     {
    1480                 :          0 :         SetDataPtr(nRow);
    1481         [ #  # ]:          0 :         if( GetActRow()->IsReadOnly() )
    1482                 :          0 :             return sal_False;
    1483                 :            :     }
    1484                 :            : 
    1485                 :          0 :     return bInsertNewAllowed;
    1486                 :            : }
    1487                 :            : 
    1488                 :            : //------------------------------------------------------------------------------
    1489                 :          0 : sal_Bool OTableEditorCtrl::IsPrimaryKeyAllowed( long /*nRow*/ )
    1490                 :            : {
    1491                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1492 [ #  # ][ #  # ]:          0 :     if( !GetSelectRowCount() )
    1493                 :          0 :         return sal_False;
    1494                 :            : 
    1495         [ #  # ]:          0 :     OTableController& rController = GetView()->getController();
    1496 [ #  # ][ #  # ]:          0 :     if ( !rController.getSdbMetaData().supportsPrimaryKeys() )
                 [ #  # ]
    1497                 :          0 :         return sal_False;
    1498                 :            : 
    1499         [ #  # ]:          0 :     Reference<XPropertySet> xTable = rController.getTable();
    1500                 :            :     //////////////////////////////////////////////////////////////
    1501                 :            :     // Key darf nicht veraendert werden
    1502                 :            :     // Dies gilt jedoch nur, wenn die Tabelle nicht neu ist und keine ::com::sun::star::sdbcx::View. Ansonsten wird kein DROP ausgef�hrt
    1503                 :            : 
    1504 [ #  # ][ #  # ]:          0 :     if(xTable.is() && ::comphelper::getString(xTable->getPropertyValue(PROPERTY_TYPE)) == ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("VIEW")))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  #  
          #  #  #  #  #  
                #  #  # ]
    1505                 :          0 :         return sal_False;
    1506                 :            :     //////////////////////////////////////////////////////////////
    1507                 :            :     // Wenn leeres Feld, kein PrimKey
    1508                 :            :     // Eintrag wird nur erlaubt, wenn
    1509                 :            :     // - kein leerer Eintrag in der Selection ist
    1510                 :            :     // - kein Eintrag vom Typ Memo oder Image ist
    1511                 :            :     // - kein DROP erlaubt ist (s.o.) und die Spalte noch kein Required (not null) gesetzt hatte.
    1512         [ #  # ]:          0 :     long nIndex = FirstSelectedRow();
    1513         [ #  # ]:          0 :      ::boost::shared_ptr<OTableRow>  pRow;
    1514 [ #  # ][ #  # ]:          0 :     while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
                 [ #  # ]
    1515                 :            :     {
    1516         [ #  # ]:          0 :         pRow = (*m_pRowList)[nIndex];
    1517                 :          0 :         OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
    1518         [ #  # ]:          0 :         if(!pFieldDescr)
    1519                 :          0 :             return sal_False;
    1520                 :            :         else
    1521                 :            :         {
    1522                 :            :             //////////////////////////////////////////////////////////////
    1523                 :            :             // Wenn Feldtyp Memo oder Image, kein PrimKey
    1524                 :            :             // oder wenn Spalten nicht gedroped werden k�nnen und das Required Flag ist nicht gesetzt
    1525                 :            :             // oder wenn eine ::com::sun::star::sdbcx::View vorhanden ist und das Required Flag nicht gesetzt ist
    1526         [ #  # ]:          0 :             TOTypeInfoSP pTypeInfo = pFieldDescr->getTypeInfo();
    1527         [ #  # ]:          0 :             if(     pTypeInfo->nSearchType == ColumnSearch::NONE
           [ #  #  #  # ]
                 [ #  # ]
    1528         [ #  # ]:          0 :                 || (pFieldDescr->IsNullable() && pRow->IsReadOnly())
    1529                 :            :               )
    1530 [ #  # ][ #  # ]:          0 :                 return sal_False;
    1531                 :            :         }
    1532                 :            : 
    1533         [ #  # ]:          0 :         nIndex = NextSelectedRow();
    1534                 :            :     }
    1535                 :            : 
    1536         [ #  # ]:          0 :     return sal_True;
    1537                 :            : }
    1538                 :            : 
    1539                 :            : //------------------------------------------------------------------------------
    1540                 :          0 : void OTableEditorCtrl::Command(const CommandEvent& rEvt)
    1541                 :            : {
    1542                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1543         [ #  # ]:          0 :     switch (rEvt.GetCommand())
    1544                 :            :     {
    1545                 :            :         case COMMAND_CONTEXTMENU:
    1546                 :            :         {
    1547                 :          0 :             Point aMenuPos( rEvt.GetMousePosPixel() );
    1548         [ #  # ]:          0 :             if (!rEvt.IsMouseEvent())
    1549                 :            :             {
    1550 [ #  # ][ #  # ]:          0 :                 if  ( 1 == GetSelectColumnCount() )
    1551                 :            :                 {
    1552                 :            :                     sal_uInt16 nSelId = GetColumnId(
    1553                 :            :                         sal::static_int_cast< sal_uInt16 >(
    1554 [ #  # ][ #  # ]:          0 :                             FirstSelectedColumn() ) );
    1555         [ #  # ]:          0 :                     ::Rectangle aColRect( GetFieldRectPixel( 0, nSelId, sal_False ) );
    1556                 :            : 
    1557         [ #  # ]:          0 :                     aMenuPos = aColRect.TopCenter();
    1558                 :            :                 }
    1559 [ #  # ][ #  # ]:          0 :                 else if ( GetSelectRowCount() > 0 )
    1560                 :            :                 {
    1561 [ #  # ][ #  # ]:          0 :                     ::Rectangle aColRect( GetFieldRectPixel( FirstSelectedRow(), HANDLE_ID, sal_True ) );
    1562                 :            : 
    1563         [ #  # ]:          0 :                     aMenuPos = aColRect.TopCenter();
    1564                 :            :                 }
    1565                 :            :                 else
    1566                 :            :                 {
    1567         [ #  # ]:          0 :                     OTableRowView::Command(rEvt);
    1568                 :          0 :                     return;
    1569                 :            :                 }
    1570                 :            :             }
    1571                 :            : 
    1572                 :            :             //////////////////////////////////////////////////////////////
    1573                 :            :             // Kontextmenu einblenden
    1574         [ #  # ]:          0 :             if( !IsReadOnly() )
    1575                 :            :             {
    1576         [ #  # ]:          0 :                 sal_uInt16 nColId = GetColumnAtXPosPixel(aMenuPos.X());
    1577         [ #  # ]:          0 :                 long   nRow = GetRowAtYPosPixel(aMenuPos.Y());
    1578                 :            : 
    1579         [ #  # ]:          0 :                 if ( HANDLE_ID != nColId )
    1580                 :            :                 {
    1581 [ #  # ][ #  # ]:          0 :                     if ( nRow < 0 && nColId != BROWSER_INVALIDID )
    1582                 :            :                     {   // hit the header
    1583         [ #  # ]:          0 :                         if ( 3 != nColId )
    1584                 :            :                         {   // 3 would mean the last column, and this last column is auto-sized
    1585 [ #  # ][ #  # ]:          0 :                             if ( !IsColumnSelected( nColId ) )
    1586         [ #  # ]:          0 :                                 SelectColumnId( nColId );
    1587                 :            : 
    1588 [ #  # ][ #  # ]:          0 :                             PopupMenu aContextMenu( ModuleRes( RID_QUERYCOLPOPUPMENU ) );
    1589         [ #  # ]:          0 :                             aContextMenu.EnableItem( SID_DELETE, sal_False );
    1590         [ #  # ]:          0 :                             aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
    1591 [ #  # ][ #  # ]:          0 :                             switch ( aContextMenu.Execute( this, aMenuPos ) )
    1592                 :            :                             {
    1593                 :            :                                 case ID_BROWSER_COLWIDTH:
    1594         [ #  # ]:          0 :                                     adjustBrowseBoxColumnWidth( this, nColId );
    1595                 :          0 :                                     break;
    1596         [ #  # ]:          0 :                             }
    1597                 :            :                         }
    1598                 :            :                     }
    1599                 :            :                 }
    1600                 :            :                 else
    1601                 :            :                 {
    1602 [ #  # ][ #  # ]:          0 :                     PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
    1603                 :            : 
    1604 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_CUT, IsCutAllowed(nRow) );
    1605 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_COPY, IsCopyAllowed(nRow) );
    1606 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_PASTE, IsPasteAllowed(nRow) );
    1607 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_DELETE, IsDeleteAllowed(nRow) );
    1608 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsPrimaryKeyAllowed(nRow) );
    1609 [ #  # ][ #  # ]:          0 :                     aContextMenu.EnableItem( SID_TABLEDESIGN_INSERTROWS, IsInsertNewAllowed(nRow) );
    1610 [ #  # ][ #  # ]:          0 :                     aContextMenu.CheckItem( SID_TABLEDESIGN_TABED_PRIMARYKEY, IsRowSelected(GetCurRow()) && IsPrimaryKey() );
         [ #  # ][ #  # ]
                 [ #  # ]
    1611                 :            : 
    1612                 :            :                     // jetzt alles, was disabled wurde, wech
    1613         [ #  # ]:          0 :                     aContextMenu.RemoveDisabledEntries(sal_True, sal_True);
    1614                 :            : 
    1615 [ #  # ][ #  # ]:          0 :                     if( SetDataPtr(m_nDataPos) )
    1616         [ #  # ]:          0 :                         pDescrWin->SaveData( pActRow->GetActFieldDescr() );
    1617                 :            : 
    1618                 :            :                     //////////////////////////////////////////////////////////////
    1619                 :            :                     // Alle Aktionen, die die Zeilenzahl veraendern, muessen asynchron
    1620                 :            :                     // ausgefuehrt werden->sonst Probleme zwischen Kontextmenu u. Browser
    1621                 :          0 :                     m_nDataPos = GetCurRow();
    1622   [ #  #  #  #  :          0 :                     switch (aContextMenu.Execute(this, aMenuPos))
                #  #  # ]
                 [ #  # ]
    1623                 :            :                     {
    1624                 :            :                         case SID_CUT:
    1625         [ #  # ]:          0 :                             cut();
    1626                 :          0 :                             break;
    1627                 :            :                         case SID_COPY:
    1628         [ #  # ]:          0 :                             copy();
    1629                 :          0 :                             break;
    1630                 :            :                         case SID_PASTE:
    1631         [ #  # ]:          0 :                             paste();
    1632                 :          0 :                             break;
    1633                 :            :                         case SID_DELETE:
    1634         [ #  # ]:          0 :                             if( nDeleteEvent )
    1635         [ #  # ]:          0 :                                 Application::RemoveUserEvent( nDeleteEvent );
    1636 [ #  # ][ #  # ]:          0 :                             nDeleteEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedDelete) );
    1637                 :          0 :                             break;
    1638                 :            :                         case SID_TABLEDESIGN_INSERTROWS:
    1639         [ #  # ]:          0 :                             if( nInsNewRowsEvent )
    1640         [ #  # ]:          0 :                                 Application::RemoveUserEvent( nInsNewRowsEvent );
    1641 [ #  # ][ #  # ]:          0 :                             nInsNewRowsEvent = Application::PostUserEvent( LINK(this, OTableEditorCtrl, DelayedInsNewRows) );
    1642                 :          0 :                             break;
    1643                 :            :                         case SID_TABLEDESIGN_TABED_PRIMARYKEY:
    1644 [ #  # ][ #  # ]:          0 :                             SetPrimaryKey( !IsPrimaryKey() );
    1645                 :          0 :                             break;
    1646                 :            :                         default:
    1647                 :          0 :                             break;
    1648         [ #  # ]:          0 :                     }
    1649                 :            :                 }
    1650                 :            :             }
    1651                 :            :         }
    1652                 :          0 :         break;
    1653                 :            :         default:
    1654                 :          0 :             OTableRowView::Command(rEvt);
    1655                 :            :     }
    1656                 :            : 
    1657                 :            : }
    1658                 :            : 
    1659                 :            : //------------------------------------------------------------------------------
    1660                 :          0 : IMPL_LINK( OTableEditorCtrl, DelayedCut, void*, /*EMPTYTAG*/ )
    1661                 :            : {
    1662                 :          0 :     nCutEvent = 0;
    1663                 :          0 :     OTableRowView::cut();
    1664                 :          0 :     return 0;
    1665                 :            : }
    1666                 :            : 
    1667                 :            : //------------------------------------------------------------------------------
    1668                 :          0 : IMPL_LINK( OTableEditorCtrl, DelayedPaste, void*, /*EMPTYTAG*/ )
    1669                 :            : {
    1670                 :          0 :     nPasteEvent = 0;
    1671                 :            : 
    1672                 :          0 :     sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
    1673         [ #  # ]:          0 :     if ( !GetView()->getController().getTable().is() )
    1674         [ #  # ]:          0 :         nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : GetCurRow();
    1675                 :            : 
    1676         [ #  # ]:          0 :     if (!IsInsertNewAllowed(nPastePosition))
    1677                 :            :     {   // kein Einfuegen erlaubt, sondern nur anhaengen, also testen, ob hinter der PastePosition noch
    1678                 :            :         // belegte Zeilen erscheinen
    1679                 :            : 
    1680                 :            :         sal_Int32 nFreeFromPos; // ab da nur freie Zeilen
    1681                 :          0 :         ::std::vector< ::boost::shared_ptr<OTableRow> >::reverse_iterator aIter = m_pRowList->rbegin();
    1682 [ #  # ][ #  #  :          0 :         for(nFreeFromPos = m_pRowList->size();
          #  #  #  #  #  
              # ][ #  # ]
    1683 [ #  # ][ #  # ]:          0 :             aIter != m_pRowList->rend() && (!(*aIter) || !(*aIter)->GetActFieldDescr() || (*aIter)->GetActFieldDescr()->GetName().isEmpty());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    1684                 :            :             --nFreeFromPos, ++aIter)
    1685                 :            :             ;
    1686         [ #  # ]:          0 :         if (nPastePosition < nFreeFromPos)  // es gibt mindestens eine belegte hinter PastePosition -> ganz nach hinten
    1687                 :          0 :             nPastePosition = nFreeFromPos;
    1688                 :            :     }
    1689                 :            : 
    1690                 :          0 :     OTableRowView::Paste( nPastePosition );
    1691                 :          0 :     SetNoSelection();
    1692                 :          0 :     GoToRow( nPastePosition );
    1693                 :            : 
    1694                 :          0 :     return 0;
    1695                 :            : }
    1696                 :            : 
    1697                 :            : //------------------------------------------------------------------------------
    1698                 :          0 : IMPL_LINK( OTableEditorCtrl, DelayedDelete, void*, /*EMPTYTAG*/ )
    1699                 :            : {
    1700                 :          0 :     nDeleteEvent = 0;
    1701                 :          0 :     DeleteRows();
    1702                 :          0 :     return 0;
    1703                 :            : }
    1704                 :            : 
    1705                 :            : //------------------------------------------------------------------------------
    1706                 :          0 : IMPL_LINK( OTableEditorCtrl, DelayedInsNewRows, void*, /*EMPTYTAG*/ )
    1707                 :            : {
    1708                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1709                 :          0 :     nInsNewRowsEvent = 0;
    1710                 :          0 :     sal_Int32 nPastePosition = GetView()->getController().getFirstEmptyRowPosition();
    1711         [ #  # ]:          0 :     if ( !GetView()->getController().getTable().is() )
    1712         [ #  # ]:          0 :         nPastePosition = GetSelectRowCount() ? FirstSelectedRow() : m_nDataPos;
    1713                 :            : 
    1714                 :          0 :     InsertNewRows( nPastePosition );
    1715                 :          0 :     SetNoSelection();
    1716                 :          0 :     GoToRow( nPastePosition );
    1717                 :            : 
    1718                 :          0 :     return 0;
    1719                 :            : }
    1720                 :            : // -----------------------------------------------------------------------------
    1721                 :          0 : void OTableEditorCtrl::AdjustFieldDescription(OFieldDescription* _pFieldDesc,
    1722                 :            :                                          MultiSelection& _rMultiSel,
    1723                 :            :                                          sal_Int32 _nPos,
    1724                 :            :                                          sal_Bool _bSet,
    1725                 :            :                                          sal_Bool _bPrimaryKey)
    1726                 :            : {
    1727                 :          0 :     _pFieldDesc->SetPrimaryKey( _bPrimaryKey );
    1728 [ #  # ][ #  # ]:          0 :     if(!_bSet && _pFieldDesc->getTypeInfo()->bNullable)
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1729                 :            :     {
    1730                 :          0 :         _pFieldDesc->SetIsNullable(ColumnValue::NO_NULLS);
    1731         [ #  # ]:          0 :         _pFieldDesc->SetControlDefault(Any());
    1732                 :            :     }
    1733 [ #  # ][ #  # ]:          0 :     if ( _pFieldDesc->IsAutoIncrement() && !_bPrimaryKey )
                 [ #  # ]
    1734                 :            :     {
    1735                 :          0 :         OTableController& rController = GetView()->getController();
    1736         [ #  # ]:          0 :         if ( rController.isAutoIncrementPrimaryKey() )
    1737                 :            :         {
    1738                 :          0 :             _pFieldDesc->SetAutoIncrement(false);
    1739                 :            :         }
    1740                 :            :     }
    1741                 :            :     //////////////////////////////////////////////////////////////////////
    1742                 :            :     // update field description
    1743                 :          0 :     pDescrWin->DisplayData(_pFieldDesc);
    1744                 :            : 
    1745                 :          0 :     _rMultiSel.Insert( _nPos );
    1746                 :          0 :     _rMultiSel.Select( _nPos );
    1747                 :          0 : }
    1748                 :            : //------------------------------------------------------------------------------
    1749                 :          0 : void OTableEditorCtrl::SetPrimaryKey( sal_Bool bSet )
    1750                 :            : {
    1751                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1752                 :            :     //////////////////////////////////////////////////////////////////////
    1753                 :            :     // Evtl. vorhandene Primary Keys loeschen
    1754         [ #  # ]:          0 :     MultiSelection aDeletedPrimKeys;
    1755 [ #  # ][ #  # ]:          0 :     aDeletedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
    1756                 :            : 
    1757         [ #  # ]:          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
    1758         [ #  # ]:          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
    1759 [ #  # ][ #  # ]:          0 :     for(sal_Int32 nRow = 0;aIter != aEnd;++aIter,++nRow)
    1760                 :            :     {
    1761                 :          0 :         OFieldDescription* pFieldDescr = (*aIter)->GetActFieldDescr();
    1762 [ #  # ][ #  # ]:          0 :         if( pFieldDescr && (*aIter)->IsPrimaryKey() && (!bSet || !IsRowSelected(nRow)) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1763                 :            :         {
    1764         [ #  # ]:          0 :             AdjustFieldDescription(pFieldDescr,aDeletedPrimKeys,nRow,bSet,sal_False);
    1765                 :            :         }
    1766                 :            :     }
    1767                 :            : 
    1768                 :            :     //////////////////////////////////////////////////////////////////////
    1769                 :            :     // Die Primary Keys der markierten Zeilen setzen
    1770         [ #  # ]:          0 :     MultiSelection aInsertedPrimKeys;
    1771 [ #  # ][ #  # ]:          0 :     aInsertedPrimKeys.SetTotalRange( Range(0,GetRowCount()) );
    1772         [ #  # ]:          0 :     if( bSet )
    1773                 :            :     {
    1774         [ #  # ]:          0 :         long nIndex = FirstSelectedRow();
    1775 [ #  # ][ #  # ]:          0 :         while( nIndex >= 0 && nIndex < static_cast<long>(m_pRowList->size()) )
                 [ #  # ]
    1776                 :            :         {
    1777                 :            :             //////////////////////////////////////////////////////////////////////
    1778                 :            :             // Key setzen
    1779         [ #  # ]:          0 :              ::boost::shared_ptr<OTableRow>  pRow = (*m_pRowList)[nIndex];
    1780                 :          0 :             OFieldDescription* pFieldDescr = pRow->GetActFieldDescr();
    1781         [ #  # ]:          0 :             if(pFieldDescr)
    1782         [ #  # ]:          0 :                 AdjustFieldDescription(pFieldDescr,aInsertedPrimKeys,nIndex,sal_False,sal_True);
    1783                 :            : 
    1784         [ #  # ]:          0 :             nIndex = NextSelectedRow();
    1785         [ #  # ]:          0 :         }
    1786                 :            :     }
    1787                 :            : 
    1788 [ #  # ][ #  # ]:          0 :     GetUndoManager().AddUndoAction( new OPrimKeyUndoAct(this, aDeletedPrimKeys, aInsertedPrimKeys) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1789                 :            : 
    1790                 :            :     //////////////////////////////////////////////////////////////////////
    1791                 :            :     // Handle-Spalte invalidieren
    1792         [ #  # ]:          0 :     InvalidateHandleColumn();
    1793                 :            : 
    1794                 :            : 
    1795                 :            :     //////////////////////////////////////////////////////////////////////
    1796                 :            :     // Das ModifyFlag der TableDocSh setzen
    1797 [ #  # ][ #  # ]:          0 :     GetView()->getController().setModified( sal_True );
    1798 [ #  # ][ #  # ]:          0 :     InvalidateFeatures();
                 [ #  # ]
    1799                 :          0 : }
    1800                 :            : 
    1801                 :            : //------------------------------------------------------------------------------
    1802                 :          0 : sal_Bool OTableEditorCtrl::IsPrimaryKey()
    1803                 :            : {
    1804                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1805                 :            :     //////////////////////////////////////////////////////////////////////
    1806                 :            :     // Gehoeren alle markierten Felder zu einem Primary Key ?
    1807                 :          0 :     long nPrimaryKeys = 0;
    1808         [ #  # ]:          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aIter = m_pRowList->begin();
    1809         [ #  # ]:          0 :     ::std::vector< ::boost::shared_ptr<OTableRow> >::const_iterator aEnd = m_pRowList->end();
    1810 [ #  # ][ #  # ]:          0 :     for(sal_Int32 nRow=0;aIter != aEnd;++aIter,++nRow)
    1811                 :            :     {
    1812 [ #  # ][ #  # ]:          0 :         if( IsRowSelected(nRow) && !(*aIter)->IsPrimaryKey() )
         [ #  # ][ #  # ]
                 [ #  # ]
    1813                 :          0 :             return sal_False;
    1814 [ #  # ][ #  # ]:          0 :         if( (*aIter)->IsPrimaryKey() )
    1815                 :          0 :             ++nPrimaryKeys;
    1816                 :            :     }
    1817                 :            : 
    1818                 :            :     //////////////////////////////////////////////////////////////////////
    1819                 :            :     // Gibt es unselektierte Felder, die noch zu dem Key gehoeren ?
    1820         [ #  # ]:          0 :     return GetSelectRowCount() == nPrimaryKeys;
    1821                 :            : }
    1822                 :            : 
    1823                 :            : //------------------------------------------------------------------------------
    1824                 :          0 : void OTableEditorCtrl::SwitchType( const TOTypeInfoSP& _pType )
    1825                 :            : {
    1826                 :            :     DBG_CHKTHIS(OTableEditorCtrl,NULL);
    1827                 :            :     //////////////////////////////////////////////////////////////////////
    1828                 :            :     // Wenn noch kein Feldname vergeben wurde
    1829                 :          0 :     long nRow(GetCurRow());
    1830         [ #  # ]:          0 :     OFieldDescription* pActFieldDescr = GetFieldDescr( nRow );
    1831         [ #  # ]:          0 :     if( pActFieldDescr )
    1832                 :            :         //////////////////////////////////////////////////////////////////////
    1833                 :            :         // Alte Beschreibung speichern
    1834         [ #  # ]:          0 :         pDescrWin->SaveData( pActFieldDescr );
    1835                 :            : 
    1836 [ #  # ][ #  # ]:          0 :     if ( nRow < 0 || nRow > static_cast<long>(m_pRowList->size()) )
                 [ #  # ]
    1837                 :          0 :         return;
    1838                 :            :     //////////////////////////////////////////////////////////////////////
    1839                 :            :     // Neue Beschreibung darstellen
    1840         [ #  # ]:          0 :      ::boost::shared_ptr<OTableRow>  pRow = (*m_pRowList)[nRow];
    1841         [ #  # ]:          0 :     pRow->SetFieldType( _pType, sal_True );
    1842         [ #  # ]:          0 :     if ( _pType.get() )
    1843                 :            :     {
    1844         [ #  # ]:          0 :         const sal_uInt16 nCurrentlySelected = pTypeCell->GetSelectEntryPos();
    1845                 :            : 
    1846   [ #  #  #  # ]:          0 :         if  (   ( LISTBOX_ENTRY_NOTFOUND == nCurrentlySelected )
                 [ #  # ]
    1847 [ #  # ][ #  # ]:          0 :             ||  ( GetView()->getController().getTypeInfo( nCurrentlySelected ) != _pType )
         [ #  # ][ #  # ]
                 [ #  # ]
    1848                 :            :             )
    1849                 :            :         {
    1850                 :          0 :             sal_uInt16 nEntryPos = 0;
    1851         [ #  # ]:          0 :             const OTypeInfoMap* pTypeInfo = GetView()->getController().getTypeInfo();
    1852                 :          0 :             OTypeInfoMap::const_iterator aIter = pTypeInfo->begin();
    1853                 :          0 :             OTypeInfoMap::const_iterator aEnd = pTypeInfo->end();
    1854         [ #  # ]:          0 :             for(;aIter != aEnd;++aIter,++nEntryPos)
    1855                 :            :             {
    1856         [ #  # ]:          0 :                 if(aIter->second == _pType)
    1857                 :          0 :                     break;
    1858                 :            :             }
    1859 [ #  # ][ #  # ]:          0 :             if (nEntryPos < pTypeCell->GetEntryCount())
    1860         [ #  # ]:          0 :                 pTypeCell->SelectEntryPos( nEntryPos );
    1861                 :            :         }
    1862                 :            :     }
    1863                 :            : 
    1864                 :          0 :     pActFieldDescr = pRow->GetActFieldDescr();
    1865 [ #  # ][ #  # ]:          0 :     if (pActFieldDescr != NULL && !pActFieldDescr->GetFormatKey())
         [ #  # ][ #  # ]
    1866                 :            :     {
    1867                 :            :         sal_Int32 nFormatKey = ::dbtools::getDefaultNumberFormat( pActFieldDescr->GetType(),
    1868                 :            :             pActFieldDescr->GetScale(),
    1869         [ #  # ]:          0 :             pActFieldDescr->IsCurrency(),
    1870 [ #  # ][ #  # ]:          0 :             Reference< XNumberFormatTypes>(GetView()->getController().getNumberFormatter()->getNumberFormatsSupplier()->getNumberFormats(),UNO_QUERY),
         [ #  # ][ #  # ]
                 [ #  # ]
    1871 [ #  # ][ #  # ]:          0 :             GetView()->getLocale());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1872                 :            : 
    1873         [ #  # ]:          0 :         pActFieldDescr->SetFormatKey(nFormatKey);
    1874                 :            :     }
    1875                 :            : 
    1876 [ #  # ][ #  # ]:          0 :     pDescrWin->DisplayData( pActFieldDescr );
    1877                 :            : }
    1878                 :            : // -----------------------------------------------------------------------------
    1879                 :          0 : OTableDesignView* OTableEditorCtrl::GetView() const
    1880                 :            : {
    1881                 :          0 :     return static_cast<OTableDesignView*>(GetParent()->GetParent());
    1882                 :            : }
    1883                 :            : // -----------------------------------------------------------------------------
    1884                 :          0 : void OTableEditorCtrl::DeactivateCell(sal_Bool bUpdate)
    1885                 :            : {
    1886                 :          0 :     OTableRowView::DeactivateCell(bUpdate);
    1887                 :            :     // now we have to deactivate the field description
    1888                 :          0 :     long nRow(GetCurRow());
    1889         [ #  # ]:          0 :     if (pDescrWin)
    1890 [ #  # ][ #  # ]:          0 :         pDescrWin->SetReadOnly(bReadOnly || !SetDataPtr(nRow) || GetActRow()->IsReadOnly());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1891                 :          0 : }
    1892                 :            : //------------------------------------------------------------------------------
    1893                 :          0 : long OTableEditorCtrl::PreNotify( NotifyEvent& rNEvt )
    1894                 :            : {
    1895         [ #  # ]:          0 :     if (rNEvt.GetType() == EVENT_GETFOCUS)
    1896                 :            :     {
    1897 [ #  # ][ #  # ]:          0 :         if( pHelpTextCell && pHelpTextCell->HasChildPathFocus() )
                 [ #  # ]
    1898                 :          0 :             m_eChildFocus = HELPTEXT;
    1899 [ #  # ][ #  # ]:          0 :         else if( pDescrCell && pDescrCell->HasChildPathFocus() )
                 [ #  # ]
    1900                 :          0 :             m_eChildFocus = DESCRIPTION;
    1901 [ #  # ][ #  # ]:          0 :         else if(pNameCell && pNameCell->HasChildPathFocus() )
                 [ #  # ]
    1902                 :          0 :             m_eChildFocus = NAME;
    1903                 :            :         else
    1904                 :          0 :             m_eChildFocus = ROW;
    1905                 :            :     }
    1906                 :            : 
    1907                 :          0 :     return OTableRowView::PreNotify(rNEvt);
    1908                 :            : }
    1909                 :            : // -----------------------------------------------------------------------------
    1910                 :            : 
    1911                 :            : 
    1912                 :            : 
    1913                 :            : 
    1914                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10