LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableDesignControl.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 0 84 0.0 %
Date: 2014-04-11 Functions: 0 12 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #include "TableDesignControl.hxx"
      21             : #include "dbu_tbl.hrc"
      22             : #include "TableDesignView.hxx"
      23             : #include "TableController.hxx"
      24             : #include "browserids.hxx"
      25             : #include <com/sun/star/util/URL.hpp>
      26             : #include <com/sun/star/beans/PropertyValue.hpp>
      27             : #include "dbaccess_helpid.hrc"
      28             : 
      29             : using namespace ::dbaui;
      30             : using namespace ::svt;
      31             : using namespace ::com::sun::star::uno;
      32             : using namespace ::com::sun::star::beans;
      33             : using namespace ::com::sun::star::util;
      34             : // Defines
      35             : #define HANDLE_ID 0
      36             : 
      37           0 : OTableRowView::OTableRowView(Window* pParent)
      38             :     :EditBrowseBox(pParent, ModuleRes(RID_DB_TAB_EDITOR),EBBF_NONE,
      39             :                     BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_AUTOSIZE_LASTCOL |
      40             :                     BROWSER_KEEPSELECTION | BROWSER_HLINESFULL | BROWSER_VLINESFULL)
      41             :     ,m_nDataPos(-1)
      42             :     ,m_nCurrentPos(-1)
      43             :     ,m_nCurUndoActId(0)
      44             :     ,m_bCurrentModified(sal_False)
      45             :     ,m_bUpdatable(sal_False)
      46           0 :     ,m_bClipboardFilled(sal_False)
      47             : {
      48             : 
      49           0 : }
      50             : 
      51           0 : OTableRowView::~OTableRowView()
      52             : {
      53             : 
      54           0 : }
      55             : 
      56           0 : void OTableRowView::Init()
      57             : {
      58           0 :     EditBrowseBox::Init();
      59             : 
      60           0 :     Font aFont( GetDataWindow().GetFont() );
      61           0 :     aFont.SetWeight( WEIGHT_NORMAL );
      62           0 :     GetDataWindow().SetFont( aFont );
      63             : 
      64             :     // set font for the headings to light
      65           0 :     aFont = GetFont();
      66           0 :     aFont.SetWeight( WEIGHT_LIGHT );
      67           0 :     SetFont(aFont);
      68             : 
      69             :     // set up HandleColumn for at maximum 5 digits
      70           0 :     InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth(OUString('0')) * 4)/*, sal_True */);
      71             : 
      72             :     BrowserMode nMode = BROWSER_COLUMNSELECTION | BROWSER_MULTISELECTION | BROWSER_KEEPSELECTION |
      73           0 :                         BROWSER_HLINESFULL | BROWSER_VLINESFULL | BROWSER_AUTOSIZE_LASTCOL;
      74           0 :     if (IsUpdatable())
      75           0 :         nMode |= BROWSER_HIDECURSOR;
      76             : 
      77           0 :     SetMode(nMode);
      78           0 : }
      79             : 
      80           0 : void OTableRowView::KeyInput( const KeyEvent& rEvt )
      81             : {
      82           0 :     if (IsDeleteAllowed(0))
      83             :     {
      84           0 :         if (rEvt.GetKeyCode().GetCode() == KEY_DELETE &&    // Delete rows
      85           0 :             !rEvt.GetKeyCode().IsShift() &&
      86           0 :             !rEvt.GetKeyCode().IsMod1())
      87             :         {
      88           0 :             DeleteRows();
      89           0 :             return;
      90             :         }
      91           0 :         if( rEvt.GetKeyCode().GetCode() == KEY_F2 )
      92             :         {
      93           0 :             ::com::sun::star::util::URL aUrl;
      94           0 :             aUrl.Complete = ".uno:DSBEditDoc";
      95           0 :             GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
      96             :         }
      97             :     }
      98           0 :     EditBrowseBox::KeyInput(rEvt);
      99             : }
     100             : 
     101           0 : void OTableRowView::SetUpdatable( sal_Bool bUpdate )
     102             : {
     103           0 :     m_bUpdatable = bUpdate;
     104             : 
     105           0 : }
     106             : 
     107           0 : void OTableRowView::Command(const CommandEvent& rEvt)
     108             : {
     109             : 
     110           0 :     switch (rEvt.GetCommand())
     111             :     {
     112             :         case COMMAND_CONTEXTMENU:
     113             :         {
     114           0 :             if (!rEvt.IsMouseEvent())
     115             :             {
     116           0 :                 EditBrowseBox::Command(rEvt);
     117           0 :                 return;
     118             :             }
     119             : 
     120           0 :             sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
     121           0 :             long   nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
     122             : 
     123           0 :             if ( nColId == HANDLE_ID )
     124             :             {
     125           0 :                 PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
     126           0 :                 long nSelectRowCount = GetSelectRowCount();
     127           0 :                 aContextMenu.EnableItem( SID_CUT, nSelectRowCount != 0);
     128           0 :                 aContextMenu.EnableItem( SID_COPY, nSelectRowCount  != 0);
     129           0 :                 aContextMenu.EnableItem( SID_PASTE, m_bClipboardFilled );
     130           0 :                 aContextMenu.EnableItem( SID_DELETE, IsUpdatable() && nSelectRowCount != 0 );
     131           0 :                 switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
     132             :                 {
     133             :                     case SID_CUT:
     134           0 :                         cut();
     135           0 :                         break;
     136             :                     case SID_COPY:
     137           0 :                         copy();
     138           0 :                         break;
     139             :                     case SID_PASTE:
     140           0 :                         Paste( nRow );
     141           0 :                         SetNoSelection();
     142           0 :                         GoToRow( nRow );
     143           0 :                         SeekRow( nRow );
     144           0 :                         break;
     145             : 
     146             :                     case SID_DELETE:
     147           0 :                         DeleteRows();
     148           0 :                         break;
     149             :                     case SID_TABLEDESIGN_INSERTROWS:
     150           0 :                         InsertNewRows( nRow );
     151           0 :                         SetNoSelection();
     152           0 :                         GoToRow( nRow );
     153           0 :                         SeekRow( nRow );
     154           0 :                         break;
     155             :                     default:
     156           0 :                         break;
     157           0 :                 }
     158             :             }
     159             : 
     160             :         }
     161             :         default:
     162           0 :             EditBrowseBox::Command(rEvt);
     163             :     }
     164             : 
     165             : }
     166             : 
     167           0 : void OTableRowView::cut()
     168             : {
     169           0 :     CopyRows();
     170           0 :     DeleteRows();
     171           0 : }
     172             : 
     173           0 : void OTableRowView::copy()
     174             : {
     175           0 :     CopyRows();
     176           0 : }
     177             : 
     178           0 : void OTableRowView::paste()
     179             : {
     180             :     OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
     181           0 : }
     182             : 
     183           0 : void OTableRowView::Paste( long nRow )
     184             : {
     185           0 :     InsertRows( nRow );
     186           0 : }
     187             : 
     188           0 : EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
     189             : {
     190           0 :     if (nRow >= 0 && m_nDataPos == nRow)
     191           0 :         return CURRENT;
     192             :     else
     193           0 :         return CLEAN;
     194             : }
     195             : 
     196             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10