LCOV - code coverage report
Current view: top level - extensions/source/bibliography - bibview.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 87 1.1 %
Date: 2014-11-03 Functions: 2 14 14.3 %
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 "bib.hrc"
      22             : #include "bibcont.hxx"
      23             : #include "bibbeam.hxx"
      24             : #include "general.hxx"
      25             : #include "bibview.hxx"
      26             : #include "datman.hxx"
      27             : #include "bibresid.hxx"
      28             : #include "bibmod.hxx"
      29             : #include "bibconfig.hxx"
      30             : 
      31             : 
      32             : #include <vcl/svapp.hxx>
      33             : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      34             : #include <com/sun/star/form/XLoadable.hpp>
      35             : #include <vcl/msgbox.hxx>
      36             : #include <tools/debug.hxx>
      37             : 
      38             : using namespace ::com::sun::star;
      39             : using namespace ::com::sun::star::form;
      40             : using namespace ::com::sun::star::beans;
      41             : using namespace ::com::sun::star::lang;
      42             : using namespace ::com::sun::star::uno;
      43             : 
      44             : 
      45             : namespace bib
      46             : {
      47             : 
      48             : 
      49             : 
      50           0 :     BibView::BibView( vcl::Window* _pParent, BibDataManager* _pManager, WinBits _nStyle )
      51             :         :BibWindow( _pParent, _nStyle )
      52             :         ,m_pDatMan( _pManager )
      53             :         ,m_xDatMan( _pManager )
      54           0 :         ,m_pGeneralPage( NULL )
      55             :     {
      56           0 :         if ( m_xDatMan.is() )
      57           0 :             connectForm( m_xDatMan );
      58           0 :     }
      59             : 
      60             : 
      61           0 :     BibView::~BibView()
      62             :     {
      63           0 :         BibGeneralPage* pGeneralPage = m_pGeneralPage;
      64           0 :         m_pGeneralPage = NULL;
      65             : 
      66           0 :         pGeneralPage->CommitActiveControl();
      67           0 :         Reference< XForm > xForm = m_pDatMan->getForm();
      68           0 :         Reference< XPropertySet > xProps( xForm, UNO_QUERY );
      69           0 :         Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
      70             :         DBG_ASSERT( xResUpd.is(), "BibView::~BibView: invalid form!" );
      71             : 
      72           0 :         if ( xResUpd.is() )
      73             :         {
      74           0 :             Any aModified = xProps->getPropertyValue( "IsModified" );
      75           0 :             bool bFlag = false;
      76           0 :             if ( ( aModified >>= bFlag ) && bFlag )
      77             :             {
      78             : 
      79             :                 try
      80             :                 {
      81           0 :                     Any aNew = xProps->getPropertyValue( "IsNew" );
      82           0 :                     aNew >>= bFlag;
      83           0 :                     if ( bFlag )
      84           0 :                         xResUpd->insertRow();
      85             :                     else
      86           0 :                         xResUpd->updateRow();
      87             :                 }
      88           0 :                 catch( const uno::Exception& rEx)
      89             :                 {
      90             :                    (void) rEx;
      91             :                 }
      92           0 :             }
      93             :         }
      94             : 
      95           0 :         if ( isFormConnected() )
      96           0 :             disconnectForm();
      97             : 
      98           0 :         pGeneralPage->RemoveListeners();
      99           0 :         m_xGeneralPage = NULL;
     100           0 :     }
     101             : 
     102           0 :     void BibView::UpdatePages()
     103             :     {
     104             :         // TODO:
     105             :         // this is _strange_: Why not updating the existent general page?
     106             :         // I consider the current behaviour a HACK.
     107             :         // frank.schoenheit@sun.com
     108           0 :         if ( m_pGeneralPage )
     109             :         {
     110           0 :             m_pGeneralPage->Hide();
     111           0 :             m_pGeneralPage->RemoveListeners();
     112           0 :             m_xGeneralPage = 0;
     113             :         }
     114             : 
     115           0 :         m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan );
     116           0 :         m_pGeneralPage->Show();
     117             : 
     118           0 :         Resize();
     119             : 
     120           0 :         if( HasFocus() )
     121             :             // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
     122           0 :             m_pGeneralPage->GrabFocus();
     123             : 
     124           0 :         OUString sErrorString( m_pGeneralPage->GetErrorString() );
     125           0 :         if ( !sErrorString.isEmpty() )
     126             :         {
     127           0 :             bool bExecute = BibModul::GetConfig()->IsShowColumnAssignmentWarning();
     128           0 :             if(!m_pDatMan->HasActiveConnection())
     129             :             {
     130             :                 //no connection is available -> the data base has to be assigned
     131           0 :                 m_pDatMan->DispatchDBChangeDialog();
     132           0 :                 bExecute = false;
     133             :             }
     134           0 :             else if(bExecute)
     135             :             {
     136           0 :                 sErrorString += "\n";
     137           0 :                 sErrorString += BIB_RESSTR(RID_MAP_QUESTION);
     138           0 :                 QueryBox aQuery( this, WB_YES_NO, sErrorString );
     139           0 :                 aQuery.SetDefaultCheckBoxText();
     140           0 :                 short nResult = aQuery.Execute();
     141             :                 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
     142           0 :                     !aQuery.GetCheckBoxState());
     143           0 :                 if( RET_YES != nResult )
     144             :                 {
     145           0 :                     bExecute = false;
     146           0 :                 }
     147             :             }
     148           0 :             if(bExecute)
     149             :             {
     150           0 :                 Application::PostUserEvent( STATIC_LINK( this, BibView, CallMappingHdl ) );
     151             :             }
     152           0 :         }
     153           0 :     }
     154             : 
     155           0 :     void BibView::_loaded( const EventObject& _rEvent )
     156             :     {
     157           0 :         UpdatePages();
     158           0 :         FormControlContainer::_loaded( _rEvent );
     159           0 :     }
     160             : 
     161           0 :     void BibView::_reloaded( const EventObject& _rEvent )
     162             :     {
     163           0 :         UpdatePages();
     164           0 :         FormControlContainer::_loaded( _rEvent );
     165           0 :     }
     166             : 
     167           0 :     IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG )
     168             :     {
     169           0 :         pThis->m_pDatMan->CreateMappingDialog( pThis );
     170           0 :         return 0;
     171             :     }
     172             : 
     173           0 :     void BibView::Resize()
     174             :     {
     175           0 :         if ( m_pGeneralPage )
     176             :         {
     177           0 :             ::Size aSz( GetOutputSizePixel() );
     178           0 :             m_pGeneralPage->SetSizePixel( aSz );
     179             :         }
     180           0 :         Window::Resize();
     181           0 :     }
     182             : 
     183           0 :     Reference< awt::XControlContainer > BibView::getControlContainer()
     184             :     {
     185           0 :         Reference< awt::XControlContainer > xReturn;
     186           0 :         if ( m_pGeneralPage )
     187           0 :             xReturn = m_pGeneralPage->GetControlContainer();
     188           0 :         return xReturn;
     189             :     }
     190             : 
     191           0 :     void BibView::GetFocus()
     192             :     {
     193           0 :         if( m_pGeneralPage )
     194           0 :             m_pGeneralPage->GrabFocus();
     195           0 :     }
     196             : 
     197           0 :     bool BibView::HandleShortCutKey( const KeyEvent& rKeyEvent )
     198             :     {
     199           0 :         return m_pGeneralPage && m_pGeneralPage->HandleShortCutKey( rKeyEvent );
     200             :     }
     201             : 
     202             : 
     203          12 : }   // namespace bib
     204             : 
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10