LCOV - code coverage report
Current view: top level - extensions/source/bibliography - bibview.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 85 0.0 %
Date: 2012-08-25 Functions: 0 11 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 138 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : 
      30                 :            : #include "bib.hrc"
      31                 :            : #include "bibcont.hxx"
      32                 :            : #include "bibbeam.hxx"
      33                 :            : #include "general.hxx"
      34                 :            : #include "bibview.hxx"
      35                 :            : #include "datman.hxx"
      36                 :            : #include "bibresid.hxx"
      37                 :            : #include "bibmod.hxx"
      38                 :            : #include "sections.hrc"
      39                 :            : #include "bibconfig.hxx"
      40                 :            : 
      41                 :            : 
      42                 :            : #include <vcl/svapp.hxx>
      43                 :            : #include <com/sun/star/sdbc/XResultSetUpdate.hpp>
      44                 :            : #include <com/sun/star/form/XLoadable.hpp>
      45                 :            : #include <vcl/msgbox.hxx>
      46                 :            : #include <tools/debug.hxx>
      47                 :            : 
      48                 :            : using namespace ::com::sun::star;
      49                 :            : using namespace ::com::sun::star::form;
      50                 :            : using namespace ::com::sun::star::beans;
      51                 :            : using namespace ::com::sun::star::lang;
      52                 :            : using namespace ::com::sun::star::uno;
      53                 :            : 
      54                 :            : #define C2U( cChar ) ::rtl::OUString::createFromAscii( cChar )
      55                 :            : 
      56                 :            : //.........................................................................
      57                 :            : namespace bib
      58                 :            : {
      59                 :            : //.........................................................................
      60                 :            : 
      61                 :            :     // -----------------------------------------------------------------------
      62                 :          0 :     BibView::BibView( Window* _pParent, BibDataManager* _pManager, WinBits _nStyle )
      63                 :            :         :BibWindow( _pParent, _nStyle )
      64                 :            :         ,m_pDatMan( _pManager )
      65                 :            :         ,m_xDatMan( _pManager )
      66 [ #  # ][ #  # ]:          0 :         ,m_pGeneralPage( NULL )
                 [ #  # ]
      67                 :            :     {
      68         [ #  # ]:          0 :         if ( m_xDatMan.is() )
      69         [ #  # ]:          0 :             connectForm( m_xDatMan );
      70                 :          0 :     }
      71                 :            : 
      72                 :            :     // -----------------------------------------------------------------------
      73         [ #  # ]:          0 :     BibView::~BibView()
      74                 :            :     {
      75                 :          0 :         BibGeneralPage* pGeneralPage = m_pGeneralPage;
      76                 :          0 :         m_pGeneralPage = NULL;
      77                 :            : 
      78         [ #  # ]:          0 :         pGeneralPage->CommitActiveControl();
      79                 :          0 :         Reference< XForm > xForm = m_pDatMan->getForm();
      80         [ #  # ]:          0 :         Reference< XPropertySet > xProps( xForm, UNO_QUERY );
      81         [ #  # ]:          0 :         Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
      82                 :            :         DBG_ASSERT( xResUpd.is(), "BibView::~BibView: invalid form!" );
      83                 :            : 
      84         [ #  # ]:          0 :         if ( xResUpd.is() )
      85                 :            :         {
      86 [ #  # ][ #  # ]:          0 :             Any aModified = xProps->getPropertyValue( C2U( "IsModified" ) );
      87                 :          0 :             sal_Bool bFlag = sal_False;
      88 [ #  # ][ #  # ]:          0 :             if ( ( aModified >>= bFlag ) && bFlag )
                 [ #  # ]
      89                 :            :             {
      90                 :            : 
      91                 :            :                 try
      92                 :            :                 {
      93 [ #  # ][ #  # ]:          0 :                     Any aNew = xProps->getPropertyValue( C2U( "IsNew" ) );
      94                 :          0 :                     aNew >>= bFlag;
      95         [ #  # ]:          0 :                     if ( bFlag )
      96 [ #  # ][ #  # ]:          0 :                         xResUpd->insertRow();
      97                 :            :                     else
      98 [ #  # ][ #  # ]:          0 :                         xResUpd->updateRow();
                 [ #  # ]
      99                 :            :                 }
     100         [ #  # ]:          0 :                 catch( const uno::Exception& rEx)
     101                 :            :                 {
     102                 :            :                    (void) rEx;
     103                 :            :                 }
     104                 :          0 :             }
     105                 :            :         }
     106                 :            : 
     107         [ #  # ]:          0 :         if ( isFormConnected() )
     108         [ #  # ]:          0 :             disconnectForm();
     109                 :            : 
     110         [ #  # ]:          0 :         pGeneralPage->RemoveListeners();
     111         [ #  # ]:          0 :         m_xGeneralPage = NULL;
     112         [ #  # ]:          0 :     }
     113                 :            : 
     114                 :          0 :     void BibView::UpdatePages()
     115                 :            :     {
     116                 :            :         // TODO:
     117                 :            :         // this is _strange_: Why not updating the existent general page?
     118                 :            :         // I consider the current behaviour a HACK.
     119                 :            :         // frank.schoenheit@sun.com
     120         [ #  # ]:          0 :         if ( m_pGeneralPage )
     121                 :            :         {
     122         [ #  # ]:          0 :             m_pGeneralPage->Hide();
     123         [ #  # ]:          0 :             m_pGeneralPage->RemoveListeners();
     124         [ #  # ]:          0 :             m_xGeneralPage = 0;
     125                 :            :         }
     126                 :            : 
     127 [ #  # ][ #  # ]:          0 :         m_xGeneralPage = m_pGeneralPage = new BibGeneralPage( this, m_pDatMan );
                 [ #  # ]
     128                 :            : 
     129         [ #  # ]:          0 :         Resize();
     130                 :            : 
     131 [ #  # ][ #  # ]:          0 :         if( HasFocus() )
     132                 :            :             // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
     133         [ #  # ]:          0 :             m_pGeneralPage->GrabFocus();
     134                 :            : 
     135         [ #  # ]:          0 :         String sErrorString( m_pGeneralPage->GetErrorString() );
     136         [ #  # ]:          0 :         if ( sErrorString.Len() )
     137                 :            :         {
     138         [ #  # ]:          0 :             sal_Bool bExecute = BibModul::GetConfig()->IsShowColumnAssignmentWarning();
     139 [ #  # ][ #  # ]:          0 :             if(!m_pDatMan->HasActiveConnection())
     140                 :            :             {
     141                 :            :                 //no connection is available -> the data base has to be assigned
     142         [ #  # ]:          0 :                 m_pDatMan->DispatchDBChangeDialog();
     143                 :          0 :                 bExecute = sal_False;
     144                 :            :             }
     145         [ #  # ]:          0 :             else if(bExecute)
     146                 :            :             {
     147         [ #  # ]:          0 :                 sErrorString += '\n';
     148 [ #  # ][ #  # ]:          0 :                 sErrorString += String( BibResId( RID_MAP_QUESTION ) );
         [ #  # ][ #  # ]
     149         [ #  # ]:          0 :                 QueryBox aQuery( this, WB_YES_NO, sErrorString );
     150         [ #  # ]:          0 :                 aQuery.SetDefaultCheckBoxText();
     151         [ #  # ]:          0 :                 short nResult = aQuery.Execute();
     152                 :            :                 BibModul::GetConfig()->SetShowColumnAssignmentWarning(
     153 [ #  # ][ #  # ]:          0 :                     !aQuery.GetCheckBoxState());
     154         [ #  # ]:          0 :                 if( RET_YES != nResult )
     155                 :            :                 {
     156                 :          0 :                     bExecute = sal_False;
     157         [ #  # ]:          0 :                 }
     158                 :            :             }
     159         [ #  # ]:          0 :             if(bExecute)
     160                 :            :             {
     161 [ #  # ][ #  # ]:          0 :                 Application::PostUserEvent( STATIC_LINK( this, BibView, CallMappingHdl ) );
     162                 :            :             }
     163         [ #  # ]:          0 :         }
     164                 :          0 :     }
     165                 :            : 
     166                 :          0 :     void BibView::_loaded( const EventObject& _rEvent )
     167                 :            :     {
     168                 :          0 :         UpdatePages();
     169                 :          0 :         FormControlContainer::_loaded( _rEvent );
     170                 :          0 :     }
     171                 :            : 
     172                 :          0 :     void BibView::_reloaded( const EventObject& _rEvent )
     173                 :            :     {
     174                 :          0 :         UpdatePages();
     175                 :          0 :         FormControlContainer::_loaded( _rEvent );
     176                 :          0 :     }
     177                 :            : 
     178                 :          0 :     IMPL_STATIC_LINK( BibView, CallMappingHdl, BibView*, EMPTYARG )
     179                 :            :     {
     180                 :          0 :         pThis->m_pDatMan->CreateMappingDialog( pThis );
     181                 :          0 :         return 0;
     182                 :            :     }
     183                 :            : 
     184                 :          0 :     void BibView::Resize()
     185                 :            :     {
     186         [ #  # ]:          0 :         if ( m_pGeneralPage )
     187                 :            :         {
     188                 :          0 :             ::Size aSz( GetOutputSizePixel() );
     189         [ #  # ]:          0 :             m_pGeneralPage->SetSizePixel( aSz );
     190                 :            :         }
     191                 :          0 :         Window::Resize();
     192                 :          0 :     }
     193                 :            : 
     194                 :          0 :     Reference< awt::XControlContainer > BibView::getControlContainer()
     195                 :            :     {
     196                 :          0 :         Reference< awt::XControlContainer > xReturn;
     197         [ #  # ]:          0 :         if ( m_pGeneralPage )
     198         [ #  # ]:          0 :             xReturn = m_pGeneralPage->GetControlContainer();
     199                 :          0 :         return xReturn;
     200                 :            :     }
     201                 :            : 
     202                 :          0 :     void BibView::GetFocus()
     203                 :            :     {
     204         [ #  # ]:          0 :         if( m_pGeneralPage )
     205                 :          0 :             m_pGeneralPage->GrabFocus();
     206                 :          0 :     }
     207                 :            : 
     208                 :          0 :     sal_Bool BibView::HandleShortCutKey( const KeyEvent& rKeyEvent )
     209                 :            :     {
     210         [ #  # ]:          0 :         return m_pGeneralPage? m_pGeneralPage->HandleShortCutKey( rKeyEvent ) : sal_False;
     211                 :            :     }
     212                 :            : 
     213                 :            : //.........................................................................
     214                 :            : }   // namespace bib
     215                 :            : //.........................................................................
     216                 :            : 
     217                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10