LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableDesignControl.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 79 1.3 %
Date: 2015-06-13 12:38:46 Functions: 2 11 18.2 %
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(vcl::Window* pParent)
      38             :     :EditBrowseBox(pParent, ModuleRes(RID_DB_TAB_EDITOR),EditBrowseBoxFlags::NONE,
      39             :                     BrowserMode::COLUMNSELECTION | BrowserMode::MULTISELECTION | BrowserMode::AUTOSIZE_LASTCOL |
      40           0 :                     BrowserMode::KEEPHIGHLIGHT | BrowserMode::HLINES | BrowserMode::VLINES)
      41             :     ,m_nDataPos(-1)
      42             :     ,m_nCurrentPos(-1)
      43             :     ,m_nCurUndoActId(0)
      44             :     ,m_bCurrentModified(false)
      45           0 :     ,m_bClipboardFilled(false)
      46             : {
      47             : 
      48           0 : }
      49             : 
      50           0 : void OTableRowView::Init()
      51             : {
      52           0 :     EditBrowseBox::Init();
      53             : 
      54           0 :     vcl::Font aFont( GetDataWindow().GetFont() );
      55           0 :     aFont.SetWeight( WEIGHT_NORMAL );
      56           0 :     GetDataWindow().SetFont( aFont );
      57             : 
      58             :     // set font for the headings to light
      59           0 :     aFont = GetFont();
      60           0 :     aFont.SetWeight( WEIGHT_LIGHT );
      61           0 :     SetFont(aFont);
      62             : 
      63             :     // set up HandleColumn for at maximum 5 digits
      64           0 :     InsertHandleColumn(static_cast<sal_uInt16>(GetTextWidth(OUString('0')) * 4)/*, sal_True */);
      65             : 
      66             :     BrowserMode nMode = BrowserMode::COLUMNSELECTION | BrowserMode::MULTISELECTION | BrowserMode::KEEPHIGHLIGHT |
      67           0 :                         BrowserMode::HLINES | BrowserMode::VLINES | BrowserMode::AUTOSIZE_LASTCOL;
      68             : 
      69           0 :     SetMode(nMode);
      70           0 : }
      71             : 
      72           0 : void OTableRowView::KeyInput( const KeyEvent& rEvt )
      73             : {
      74           0 :     if (IsDeleteAllowed(0))
      75             :     {
      76           0 :         if (rEvt.GetKeyCode().GetCode() == KEY_DELETE &&    // Delete rows
      77           0 :             !rEvt.GetKeyCode().IsShift() &&
      78           0 :             !rEvt.GetKeyCode().IsMod1())
      79             :         {
      80           0 :             DeleteRows();
      81           0 :             return;
      82             :         }
      83           0 :         if( rEvt.GetKeyCode().GetCode() == KEY_F2 )
      84             :         {
      85           0 :             ::com::sun::star::util::URL aUrl;
      86           0 :             aUrl.Complete = ".uno:DSBEditDoc";
      87           0 :             GetView()->getController().dispatch( aUrl,Sequence< PropertyValue >() );
      88             :         }
      89             :     }
      90           0 :     EditBrowseBox::KeyInput(rEvt);
      91             : }
      92             : 
      93           0 : void OTableRowView::Command(const CommandEvent& rEvt)
      94             : {
      95             : 
      96           0 :     switch (rEvt.GetCommand())
      97             :     {
      98             :         case CommandEventId::ContextMenu:
      99             :         {
     100           0 :             if (!rEvt.IsMouseEvent())
     101             :             {
     102           0 :                 EditBrowseBox::Command(rEvt);
     103           0 :                 return;
     104             :             }
     105             : 
     106           0 :             sal_uInt16 nColId = GetColumnAtXPosPixel(rEvt.GetMousePosPixel().X());
     107           0 :             long   nRow = GetRowAtYPosPixel(rEvt.GetMousePosPixel().Y());
     108             : 
     109           0 :             if ( nColId == HANDLE_ID )
     110             :             {
     111           0 :                 PopupMenu aContextMenu(ModuleRes(RID_TABLEDESIGNROWPOPUPMENU));
     112           0 :                 long nSelectRowCount = GetSelectRowCount();
     113           0 :                 aContextMenu.EnableItem( SID_CUT, nSelectRowCount != 0);
     114           0 :                 aContextMenu.EnableItem( SID_COPY, nSelectRowCount  != 0);
     115           0 :                 aContextMenu.EnableItem( SID_PASTE, m_bClipboardFilled );
     116           0 :                 aContextMenu.EnableItem( SID_DELETE, false );
     117           0 :                 switch (aContextMenu.Execute(this, rEvt.GetMousePosPixel()))
     118             :                 {
     119             :                     case SID_CUT:
     120           0 :                         cut();
     121           0 :                         break;
     122             :                     case SID_COPY:
     123           0 :                         copy();
     124           0 :                         break;
     125             :                     case SID_PASTE:
     126           0 :                         Paste( nRow );
     127           0 :                         SetNoSelection();
     128           0 :                         GoToRow( nRow );
     129           0 :                         SeekRow( nRow );
     130           0 :                         break;
     131             : 
     132             :                     case SID_DELETE:
     133           0 :                         DeleteRows();
     134           0 :                         break;
     135             :                     case SID_TABLEDESIGN_INSERTROWS:
     136           0 :                         InsertNewRows( nRow );
     137           0 :                         SetNoSelection();
     138           0 :                         GoToRow( nRow );
     139           0 :                         SeekRow( nRow );
     140           0 :                         break;
     141             :                     default:
     142           0 :                         break;
     143           0 :                 }
     144             :             }
     145             : 
     146             :         }
     147             :         //fall-through
     148             :         default:
     149           0 :             EditBrowseBox::Command(rEvt);
     150             :     }
     151             : 
     152             : }
     153             : 
     154           0 : void OTableRowView::cut()
     155             : {
     156           0 :     CopyRows();
     157           0 :     DeleteRows();
     158           0 : }
     159             : 
     160           0 : void OTableRowView::copy()
     161             : {
     162           0 :     CopyRows();
     163           0 : }
     164             : 
     165           0 : void OTableRowView::paste()
     166             : {
     167             :     OSL_FAIL("OTableRowView::Paste : (pseudo-) abstract method called !");
     168           0 : }
     169             : 
     170           0 : void OTableRowView::Paste( long nRow )
     171             : {
     172           0 :     InsertRows( nRow );
     173           0 : }
     174             : 
     175           0 : EditBrowseBox::RowStatus OTableRowView::GetRowStatus(long nRow) const
     176             : {
     177           0 :     if (nRow >= 0 && m_nDataPos == nRow)
     178           0 :         return CURRENT;
     179             :     else
     180           0 :         return CLEAN;
     181          36 : }
     182             : 
     183             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11