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

Generated by: LCOV version 1.10