LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/bibliography - bibcont.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 125 0.0 %
Date: 2012-12-27 Functions: 0 29 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             : 
      21             : #include <osl/mutex.hxx>
      22             : #include <cppuhelper/weak.hxx>
      23             : #include <toolkit/helper/vclunohelper.hxx>
      24             : #include <com/sun/star/awt/XWindow.hpp>
      25             : #include <com/sun/star/awt/XWindowPeer.hpp>
      26             : #include <com/sun/star/frame/XDispatchProvider.hpp>
      27             : #include <com/sun/star/frame/FrameSearchFlag.hpp>
      28             : #include <com/sun/star/util/XURLTransformer.hpp>
      29             : #include "bibconfig.hxx"
      30             : 
      31             : 
      32             : #include "datman.hxx"
      33             : #include "bibcont.hxx"
      34             : 
      35             : 
      36           0 : BibShortCutHandler::~BibShortCutHandler()
      37             : {
      38           0 : }
      39             : 
      40           0 : sal_Bool BibShortCutHandler::HandleShortCutKey( const KeyEvent& )
      41             : {
      42           0 :     return sal_False;
      43             : }
      44             : 
      45             : 
      46           0 : BibWindow::BibWindow( Window* pParent, WinBits nStyle ) : Window( pParent, nStyle ), BibShortCutHandler( this )
      47             : {
      48           0 : }
      49             : 
      50           0 : BibWindow::~BibWindow()
      51             : {
      52           0 : }
      53             : 
      54             : 
      55           0 : BibSplitWindow::BibSplitWindow( Window* pParent, WinBits nStyle ) : SplitWindow( pParent, nStyle ), BibShortCutHandler( this )
      56             : {
      57           0 : }
      58             : 
      59           0 : BibSplitWindow::~BibSplitWindow()
      60             : {
      61           0 : }
      62             : 
      63             : 
      64           0 : BibTabPage::BibTabPage( Window* pParent, const ResId& rResId ) : TabPage( pParent, rResId ), BibShortCutHandler( this )
      65             : {
      66           0 : }
      67             : 
      68           0 : BibTabPage::~BibTabPage()
      69             : {
      70           0 : }
      71             : 
      72             : 
      73             : using namespace osl;
      74             : using namespace ::com::sun::star;
      75             : using namespace ::com::sun::star::uno;
      76             : using namespace ::com::sun::star::frame;
      77             : using namespace ::rtl;
      78             : 
      79             : #define C2U(cChar) OUString::createFromAscii(cChar)
      80             : #define PROPERTY_FRAME                      1
      81             : //split window size is a percent value
      82             : #define WIN_MIN_HEIGHT 10
      83             : #define WIN_STEP_SIZE 5
      84             : 
      85           0 : BibWindowContainer::BibWindowContainer( Window* pParent, BibShortCutHandler* pChildWin, WinBits nStyle ) :
      86             :         BibWindow( pParent, nStyle ),
      87           0 :         pChild( pChildWin )
      88             : {
      89           0 :     if(pChild!=NULL)
      90             :     {
      91           0 :         Window* pChildWindow = GetChild();
      92           0 :         pChildWindow->SetParent(this);
      93           0 :         pChildWindow->Show();
      94           0 :         pChildWindow->SetPosPixel(Point(0,0));
      95             :     }
      96           0 : }
      97             : 
      98           0 : BibWindowContainer::~BibWindowContainer()
      99             : {
     100           0 :     if( pChild )
     101             :     {
     102           0 :         Window* pDel = GetChild();
     103           0 :         pChild = NULL;          // prevents GetFocus for child while deleting!
     104           0 :         delete pDel;
     105             :     }
     106           0 : }
     107             : 
     108           0 : void BibWindowContainer::Resize()
     109             : {
     110           0 :     if( pChild )
     111           0 :         GetChild()->SetSizePixel( GetOutputSizePixel() );
     112           0 : }
     113             : 
     114           0 : void BibWindowContainer::GetFocus()
     115             : {
     116           0 :     if( pChild )
     117           0 :         GetChild()->GrabFocus();
     118           0 : }
     119             : 
     120           0 : sal_Bool BibWindowContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
     121             : {
     122           0 :     return pChild? pChild->HandleShortCutKey( rKeyEvent ) : sal_False;
     123             : }
     124             : 
     125             : 
     126           0 : BibBookContainer::BibBookContainer(Window* pParent, WinBits nStyle):
     127             :     BibSplitWindow(pParent,nStyle),
     128             :     pTopWin(NULL),
     129           0 :     pBottomWin(NULL)
     130             : {
     131           0 :     pBibMod = OpenBibModul();
     132           0 :     aTimer.SetTimeoutHdl(LINK( this, BibBookContainer, SplitHdl));
     133           0 :     aTimer.SetTimeout(400);
     134           0 : }
     135             : 
     136           0 : BibBookContainer::~BibBookContainer()
     137             : {
     138           0 :     if( xTopFrameRef.is() )
     139           0 :         xTopFrameRef->dispose();
     140           0 :     if( xBottomFrameRef.is() )
     141           0 :         xBottomFrameRef->dispose();
     142             : 
     143           0 :     if( pTopWin )
     144             :     {
     145           0 :         Window* pDel = pTopWin;
     146           0 :         pTopWin = NULL;         // prevents GetFocus for child while deleting!
     147           0 :         delete pDel;
     148             :     }
     149             : 
     150           0 :     if( pBottomWin )
     151             :     {
     152           0 :         Window* pDel = pBottomWin;
     153           0 :         pBottomWin = NULL;      // prevents GetFocus for child while deleting!
     154           0 :         delete pDel;
     155             :     }
     156             : 
     157           0 :     CloseBibModul( pBibMod );
     158           0 : }
     159             : 
     160           0 : void BibBookContainer::Split()
     161             : {
     162           0 :     aTimer.Start();
     163           0 : }
     164           0 : IMPL_LINK( BibBookContainer, SplitHdl, Timer*,/*pT*/)
     165             : {
     166           0 :     long nSize= GetItemSize( TOP_WINDOW);
     167           0 :     BibConfig* pConfig = BibModul::GetConfig();
     168           0 :     pConfig->setBeamerSize(nSize);
     169           0 :     nSize = GetItemSize( BOTTOM_WINDOW);
     170           0 :     pConfig->setViewSize(nSize);
     171           0 :     return 0;
     172             : }
     173             : 
     174           0 : void BibBookContainer::createTopFrame( BibShortCutHandler* pWin )
     175             : {
     176           0 :     if ( xTopFrameRef.is() ) xTopFrameRef->dispose();
     177             : 
     178           0 :     if(pTopWin)
     179             :     {
     180           0 :         RemoveItem(TOP_WINDOW);
     181           0 :         delete pTopWin;
     182             :     }
     183           0 :     pTopWin=new BibWindowContainer(this,pWin);
     184           0 :     pTopWin->Show();
     185           0 :     BibConfig* pConfig = BibModul::GetConfig();
     186           0 :     long nSize = pConfig->getBeamerSize();
     187           0 :     InsertItem(TOP_WINDOW, pTopWin, nSize, 1, 0, SWIB_PERCENTSIZE  );
     188             : 
     189           0 : }
     190             : 
     191           0 : void BibBookContainer::createBottomFrame( BibShortCutHandler* pWin )
     192             : {
     193           0 :     if ( xBottomFrameRef.is() ) xBottomFrameRef->dispose();
     194             : 
     195           0 :     if(pBottomWin)
     196             :     {
     197           0 :         RemoveItem(BOTTOM_WINDOW);
     198           0 :         delete pBottomWin;
     199             :     }
     200             : 
     201           0 :     pBottomWin=new BibWindowContainer(this,pWin);
     202             : 
     203           0 :     BibConfig* pConfig = BibModul::GetConfig();
     204           0 :     long nSize = pConfig->getViewSize();
     205           0 :     InsertItem(BOTTOM_WINDOW, pBottomWin, nSize, 1, 0, SWIB_PERCENTSIZE  );
     206             : 
     207           0 : }
     208             : 
     209           0 : void BibBookContainer::GetFocus()
     210             : {
     211           0 :     if( pBottomWin )
     212           0 :         pBottomWin->GrabFocus();
     213           0 : }
     214             : 
     215           0 : long BibBookContainer::PreNotify( NotifyEvent& rNEvt )
     216             : {
     217           0 :     long nHandled = 0;
     218           0 :     if( EVENT_KEYINPUT == rNEvt.GetType()  )
     219             :     {
     220           0 :         const KeyEvent* pKEvt = rNEvt.GetKeyEvent();
     221           0 :         const KeyCode aKeyCode = pKEvt->GetKeyCode();
     222           0 :         sal_uInt16 nKey = aKeyCode.GetCode();
     223           0 :         const sal_uInt16 nModifier = aKeyCode.GetModifier();
     224             : 
     225           0 :         if( KEY_MOD2 == nModifier )
     226             :         {
     227           0 :             if( KEY_UP == nKey || KEY_DOWN == nKey )
     228             :             {
     229           0 :                 if(pTopWin && pBottomWin)
     230             :                 {
     231           0 :                     sal_uInt16 nFirstWinId = KEY_UP == nKey ? TOP_WINDOW : BOTTOM_WINDOW;
     232           0 :                     sal_uInt16 nSecondWinId = KEY_UP == nKey ? BOTTOM_WINDOW : TOP_WINDOW;
     233           0 :                     long nHeight = GetItemSize( nFirstWinId );
     234           0 :                     nHeight -= WIN_STEP_SIZE;
     235           0 :                     if(nHeight < WIN_MIN_HEIGHT)
     236           0 :                         nHeight = WIN_MIN_HEIGHT;
     237           0 :                     SetItemSize( nFirstWinId, nHeight );
     238           0 :                     SetItemSize( nSecondWinId, 100 - nHeight );
     239             :                 }
     240           0 :                 nHandled = 1;
     241             :             }
     242           0 :             else if( pKEvt->GetCharCode() && HandleShortCutKey( *pKEvt ) )
     243           0 :                 nHandled = 1;
     244             :         }
     245             :     }
     246             : 
     247           0 :     return nHandled;
     248             : }
     249             : 
     250           0 : sal_Bool BibBookContainer::HandleShortCutKey( const KeyEvent& rKeyEvent )
     251             : {
     252           0 :     sal_Bool bRet = sal_False;
     253             : 
     254           0 :     if( pTopWin )
     255           0 :         bRet = pTopWin->HandleShortCutKey( rKeyEvent );
     256             : 
     257           0 :     if( !bRet && pBottomWin )
     258           0 :         bRet = pBottomWin->HandleShortCutKey( rKeyEvent );
     259             : 
     260           0 :     return bRet;
     261             : }
     262             : 
     263             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10