LCOV - code coverage report
Current view: top level - dbaccess/source/ui/tabledesign - TableDesignView.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 156 0.6 %
Date: 2015-06-13 12:38:46 Functions: 2 29 6.9 %
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 "TableDesignView.hxx"
      21             : #include <tools/debug.hxx>
      22             : #include "TableController.hxx"
      23             : #include "dbaccess_helpid.hrc"
      24             : #include "FieldDescriptions.hxx"
      25             : #include "TEditControl.hxx"
      26             : #include "TableFieldDescWin.hxx"
      27             : #include "TableRow.hxx"
      28             : #include <unotools/configmgr.hxx>
      29             : #include <comphelper/types.hxx>
      30             : #include <com/sun/star/datatransfer/clipboard/XClipboard.hpp>
      31             : #include <unotools/syslocale.hxx>
      32             : #include <vcl/settings.hxx>
      33             : #include "UITools.hxx"
      34             : #include <boost/scoped_ptr.hpp>
      35             : 
      36             : using namespace ::dbaui;
      37             : using namespace ::utl;
      38             : using namespace ::com::sun::star::uno;
      39             : using namespace ::com::sun::star::datatransfer::clipboard;
      40             : using namespace ::com::sun::star::lang;
      41             : using namespace ::com::sun::star::beans;
      42             : 
      43             : // class OTableBorderWindow
      44           0 : OTableBorderWindow::OTableBorderWindow(vcl::Window* pParent) : Window(pParent,WB_BORDER)
      45           0 :     ,m_aHorzSplitter( VclPtr<Splitter>::Create(this) )
      46             : {
      47             : 
      48           0 :     ImplInitSettings( true, true, true );
      49             :     // Children erzeugen
      50           0 :     m_pEditorCtrl   = VclPtr<OTableEditorCtrl>::Create( this);
      51           0 :     m_pFieldDescWin = VclPtr<OTableFieldDescWin>::Create( this );
      52             : 
      53           0 :     m_pFieldDescWin->SetHelpId(HID_TAB_DESIGN_DESCWIN);
      54             : 
      55             :     // set depending windows and controls
      56           0 :     m_pEditorCtrl->SetDescrWin(m_pFieldDescWin);
      57             : 
      58             :     // Splitter einrichten
      59           0 :     m_aHorzSplitter->SetSplitHdl( LINK(this, OTableBorderWindow, SplitHdl) );
      60           0 :     m_aHorzSplitter->Show();
      61           0 : }
      62             : 
      63           0 : OTableBorderWindow::~OTableBorderWindow()
      64             : {
      65           0 :     disposeOnce();
      66           0 : }
      67             : 
      68           0 : void OTableBorderWindow::dispose()
      69             : {
      70             :     // Children zerstoeren
      71             :     //  ::dbaui::notifySystemWindow(this,m_pFieldDescWin,::comphelper::mem_fun(&TaskPaneList::RemoveWindow));
      72           0 :     m_pEditorCtrl->Hide();
      73           0 :     m_pFieldDescWin->Hide();
      74           0 :     m_pEditorCtrl.disposeAndClear();
      75           0 :     m_pFieldDescWin.disposeAndClear();
      76           0 :     m_aHorzSplitter.disposeAndClear();
      77           0 :     vcl::Window::dispose();
      78           0 : }
      79             : 
      80           0 : void OTableBorderWindow::Resize()
      81             : {
      82           0 :     const long nSplitterHeight(3);
      83             : 
      84             :     // Abmessungen parent window
      85           0 :     Size aOutputSize( GetOutputSize() );
      86           0 :     long nOutputWidth   = aOutputSize.Width();
      87           0 :     long nOutputHeight  = aOutputSize.Height();
      88           0 :     long nSplitPos      = m_aHorzSplitter->GetSplitPosPixel();
      89             : 
      90             :     // Verschiebebereich Splitter mittleres Drittel des Outputs
      91           0 :     long nDragPosY = nOutputHeight/3;
      92           0 :     long nDragSizeHeight = nOutputHeight/3;
      93           0 :     m_aHorzSplitter->SetDragRectPixel( Rectangle(Point(0,nDragPosY), Size(nOutputWidth,nDragSizeHeight) ), this );
      94           0 :     if( (nSplitPos < nDragPosY) || (nSplitPos > (nDragPosY+nDragSizeHeight)) )
      95           0 :         nSplitPos = nDragPosY+nDragSizeHeight-5;
      96             : 
      97             :     // Splitter setzen
      98           0 :     m_aHorzSplitter->SetPosSizePixel( Point( 0, nSplitPos ), Size(nOutputWidth, nSplitterHeight));
      99           0 :     m_aHorzSplitter->SetSplitPosPixel( nSplitPos );
     100             : 
     101             :     // Fenster setzen
     102           0 :     m_pEditorCtrl->SetPosSizePixel( Point(0, 0), Size(nOutputWidth , nSplitPos) );
     103             : 
     104           0 :     m_pFieldDescWin->SetPosSizePixel(   Point(0, nSplitPos+nSplitterHeight),
     105           0 :                         Size(nOutputWidth, nOutputHeight-nSplitPos-nSplitterHeight) );
     106           0 : }
     107             : 
     108           0 : IMPL_LINK( OTableBorderWindow, SplitHdl, Splitter*, pSplit )
     109             : {
     110           0 :     if(pSplit == m_aHorzSplitter.get())
     111             :     {
     112           0 :         m_aHorzSplitter->SetPosPixel( Point( m_aHorzSplitter->GetPosPixel().X(),m_aHorzSplitter->GetSplitPosPixel() ) );
     113           0 :         Resize();
     114             :     }
     115           0 :     return 0;
     116             : }
     117             : 
     118           0 : void OTableBorderWindow::ImplInitSettings( bool bFont, bool bForeground, bool bBackground )
     119             : {
     120           0 :     const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
     121             : 
     122             :     // FIXME RenderContext
     123             : 
     124           0 :     if ( bFont )
     125             :     {
     126           0 :         vcl::Font aFont = rStyleSettings.GetAppFont();
     127           0 :         if ( IsControlFont() )
     128           0 :             aFont.Merge( GetControlFont() );
     129           0 :         SetPointFont(*this,  aFont);
     130             :     }
     131             : 
     132           0 :     if ( bFont || bForeground )
     133             :     {
     134           0 :         Color aTextColor = rStyleSettings.GetButtonTextColor();
     135           0 :         if ( IsControlForeground() )
     136           0 :             aTextColor = GetControlForeground();
     137           0 :         SetTextColor( aTextColor );
     138             :     }
     139             : 
     140           0 :     if ( bBackground )
     141             :     {
     142           0 :         if( IsControlBackground() )
     143           0 :             SetBackground( GetControlBackground() );
     144             :         else
     145           0 :             SetBackground( rStyleSettings.GetFaceColor() );
     146             :     }
     147           0 : }
     148             : 
     149           0 : void OTableBorderWindow::DataChanged( const DataChangedEvent& rDCEvt )
     150             : {
     151           0 :     Window::DataChanged( rDCEvt );
     152             : 
     153           0 :     if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
     154           0 :          (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
     155             :     {
     156           0 :         ImplInitSettings( true, true, true );
     157           0 :         Invalidate();
     158             :     }
     159           0 : }
     160             : 
     161           0 : void OTableBorderWindow::GetFocus()
     162             : {
     163           0 :     Window::GetFocus();
     164             : 
     165             :     // forward the focus to the current cell of the editor control
     166           0 :     if (m_pEditorCtrl)
     167           0 :         m_pEditorCtrl->GrabFocus();
     168           0 : }
     169             : 
     170             : // class OTableDesignView
     171           0 : OTableDesignView::OTableDesignView( vcl::Window* pParent,
     172             :                                     const Reference< XComponentContext >& _rxOrb,
     173             :                                     OTableController& _rController
     174             :                                    ) :
     175             :     ODataView( pParent, _rController,_rxOrb )
     176             :     ,m_rController( _rController )
     177           0 :     ,m_eChildFocus(NONE)
     178             : {
     179             : 
     180             :     try
     181             :     {
     182           0 :         m_aLocale = SvtSysLocale().GetLanguageTag().getLocale();
     183             :     }
     184           0 :     catch(Exception&)
     185             :     {
     186             :     }
     187             : 
     188           0 :     m_pWin = VclPtr<OTableBorderWindow>::Create(this);
     189           0 :     m_pWin->Show();
     190           0 : }
     191             : 
     192           0 : OTableDesignView::~OTableDesignView()
     193             : {
     194           0 :     disposeOnce();
     195           0 : }
     196             : 
     197           0 : void OTableDesignView::dispose()
     198             : {
     199           0 :     m_pWin->Hide();
     200           0 :     m_pWin.disposeAndClear();
     201           0 :     ODataView::dispose();
     202           0 : }
     203             : 
     204           0 : void OTableDesignView::initialize()
     205             : {
     206           0 :     GetEditorCtrl()->Init();
     207           0 :     GetDescWin()->Init();
     208             :     // first call after the editctrl has been set
     209             : 
     210           0 :     GetEditorCtrl()->Show();
     211           0 :     GetDescWin()->Show();
     212             : 
     213           0 :     GetEditorCtrl()->DisplayData(0);
     214           0 : }
     215             : 
     216           0 : void OTableDesignView::resizeDocumentView(Rectangle& _rPlayground)
     217             : {
     218           0 :     m_pWin->SetPosSizePixel( _rPlayground.TopLeft(), _rPlayground.GetSize() );
     219             : 
     220             :     // just for completeness: there is no space left, we occupied it all ...
     221           0 :     _rPlayground.SetPos( _rPlayground.BottomRight() );
     222           0 :     _rPlayground.SetSize( Size( 0, 0 ) );
     223           0 : }
     224             : 
     225           0 : bool OTableDesignView::PreNotify( NotifyEvent& rNEvt )
     226             : {
     227           0 :     bool bHandled = false;
     228           0 :     if (rNEvt.GetType() == MouseNotifyEvent::GETFOCUS)
     229             :     {
     230           0 :         if( GetDescWin() && GetDescWin()->HasChildPathFocus() )
     231           0 :             m_eChildFocus = DESCRIPTION;
     232           0 :         else if ( GetEditorCtrl() && GetEditorCtrl()->HasChildPathFocus() )
     233           0 :             m_eChildFocus = EDITOR;
     234             :         else
     235           0 :             m_eChildFocus = NONE;
     236             :     }
     237             : 
     238           0 :     return bHandled || ODataView::PreNotify(rNEvt);
     239             : }
     240             : 
     241           0 : IClipboardTest* OTableDesignView::getActiveChild() const
     242             : {
     243           0 :     IClipboardTest* pTest = NULL;
     244           0 :     switch(m_eChildFocus)
     245             :     {
     246             :         case DESCRIPTION:
     247           0 :             pTest = GetDescWin();
     248           0 :             break;
     249             :         case EDITOR:
     250           0 :             pTest = GetEditorCtrl();
     251           0 :             break;
     252             :         case NONE:
     253           0 :             break;
     254             :     }
     255           0 :     return pTest;
     256             : }
     257             : 
     258           0 : bool OTableDesignView::isCopyAllowed()
     259             : {
     260           0 :     IClipboardTest* pTest = getActiveChild();
     261           0 :     return pTest && pTest->isCopyAllowed();
     262             : }
     263             : 
     264           0 : bool OTableDesignView::isCutAllowed()
     265             : {
     266           0 :     IClipboardTest* pTest = getActiveChild();
     267           0 :     return pTest && pTest->isCutAllowed();
     268             : }
     269             : 
     270           0 : bool OTableDesignView::isPasteAllowed()
     271             : {
     272           0 :     IClipboardTest* pTest = getActiveChild();
     273           0 :     return pTest && pTest->isPasteAllowed();
     274             : }
     275             : 
     276           0 : void OTableDesignView::copy()
     277             : {
     278           0 :     IClipboardTest* pTest = getActiveChild();
     279           0 :     if ( pTest )
     280           0 :         pTest->copy();
     281           0 : }
     282             : 
     283           0 : void OTableDesignView::cut()
     284             : {
     285           0 :     IClipboardTest* pTest = getActiveChild();
     286           0 :     if ( pTest )
     287           0 :         pTest->cut();
     288           0 : }
     289             : 
     290           0 : void OTableDesignView::paste()
     291             : {
     292           0 :     IClipboardTest* pTest = getActiveChild();
     293           0 :     if ( pTest )
     294           0 :         pTest->paste();
     295           0 : }
     296             : 
     297             : // set the view readonly or not
     298           0 : void OTableDesignView::setReadOnly(bool _bReadOnly)
     299             : {
     300           0 :     GetDescWin()->SetReadOnly(_bReadOnly);
     301           0 :     GetEditorCtrl()->SetReadOnly(_bReadOnly);
     302           0 : }
     303             : 
     304           0 : void OTableDesignView::reSync()
     305             : {
     306           0 :     GetEditorCtrl()->DeactivateCell();
     307           0 :      ::boost::shared_ptr<OTableRow>  pRow = (*GetEditorCtrl()->GetRowList())[GetEditorCtrl()->GetCurRow()];
     308           0 :     OFieldDescription* pFieldDescr = pRow ? pRow->GetActFieldDescr() : NULL;
     309           0 :     if ( pFieldDescr )
     310           0 :         GetDescWin()->DisplayData(pFieldDescr);
     311           0 : }
     312             : 
     313           0 : void OTableDesignView::GetFocus()
     314             : {
     315           0 :     if ( GetEditorCtrl() )
     316           0 :         GetEditorCtrl()->GrabFocus();
     317          36 : }
     318             : 
     319             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11