LCOV - code coverage report
Current view: top level - dbaccess/source/ui/dlg - RelationDlg.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 89 0.0 %
Date: 2012-08-25 Functions: 0 10 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 189 0.0 %

           Branch data     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 "RelationDlg.hrc"
      21                 :            : #include "RelationDlg.hxx"
      22                 :            : 
      23                 :            : #include <vcl/wrkwin.hxx>
      24                 :            : 
      25                 :            : #include <vcl/svapp.hxx>
      26                 :            : #include "dbu_dlg.hrc"
      27                 :            : #include "dbaccess_helpid.hrc"
      28                 :            : #include <com/sun/star/sdbc/KeyRule.hpp>
      29                 :            : 
      30                 :            : #include <tools/debug.hxx>
      31                 :            : #include <tools/diagnose_ex.h>
      32                 :            : #include "UITools.hxx"
      33                 :            : #include "JoinDesignView.hxx"
      34                 :            : #include "JoinController.hxx"
      35                 :            : #include <connectivity/dbexception.hxx>
      36                 :            : #include "RTableConnectionData.hxx"
      37                 :            : #include "RelationControl.hxx"
      38                 :            : #include <cppuhelper/exc_hlp.hxx>
      39                 :            : 
      40                 :            : #include <algorithm>
      41                 :            : 
      42                 :            : using namespace ::com::sun::star::uno;
      43                 :            : using namespace ::com::sun::star::sdbc;
      44                 :            : using namespace ::com::sun::star::container;
      45                 :            : using namespace ::com::sun::star::beans;
      46                 :            : using namespace ::dbaui;
      47                 :            : using namespace ::dbtools;
      48                 :            : 
      49                 :            : //========================================================================
      50                 :            : // class ORelationDialog
      51                 :            : DBG_NAME(ORelationDialog)
      52                 :            : //========================================================================
      53                 :          0 : ORelationDialog::ORelationDialog( OJoinTableView* pParent,
      54                 :            :                                  const TTableConnectionData::value_type& pConnectionData,
      55                 :            :                                  sal_Bool bAllowTableSelect )
      56                 :            :     :ModalDialog( pParent, ModuleRes(DLG_REL_PROPERTIES) )
      57                 :          0 :     ,m_pTableMap(pParent->GetTabWinMap())
      58                 :            : 
      59                 :            :     ,aFL_CascUpd(           this, ModuleRes(FL_CASC_UPD) )
      60                 :            :     ,aRB_NoCascUpd(         this, ModuleRes(RB_NO_CASC_UPD) )
      61                 :            :     ,aRB_CascUpd(           this, ModuleRes(RB_CASC_UPD) )
      62                 :            :     ,aRB_CascUpdNull(       this, ModuleRes(RB_CASC_UPD_NULL) )
      63                 :            :     ,aRB_CascUpdDefault(    this, ModuleRes(RB_CASC_UPD_DEFAULT) )
      64                 :            :     ,aFL_CascDel(           this, ModuleRes(FL_CASC_DEL) )
      65                 :            :     ,aRB_NoCascDel(         this, ModuleRes(RB_NO_CASC_DEL) )
      66                 :            :     ,aRB_CascDel(           this, ModuleRes(RB_CASC_DEL) )
      67                 :            :     ,aRB_CascDelNull(       this, ModuleRes(RB_CASC_DEL_NULL) )
      68                 :            :     ,aRB_CascDelDefault(    this, ModuleRes(RB_CASC_DEL_DEFAULT) )
      69                 :            : 
      70                 :            :     ,aPB_OK( this, ModuleRes( PB_OK ) )
      71                 :            :     ,aPB_CANCEL( this, ModuleRes( PB_CANCEL ) )
      72                 :            :     ,aPB_HELP( this, ModuleRes( PB_HELP ) )
      73                 :            : 
      74                 :            :     ,m_pOrigConnData( pConnectionData )
      75 [ #  # ][ #  # ]:          0 :     ,m_bTriedOneUpdate(sal_False)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
      76                 :            : {
      77                 :            :     DBG_CTOR(ORelationDialog,NULL);
      78                 :            : 
      79 [ #  # ][ #  # ]:          0 :     m_xConnection = pParent->getDesignView()->getController().getConnection();
      80                 :            : 
      81                 :            :     //////////////////////////////////////////////////////////////////////
      82                 :            :     // Connection kopieren
      83 [ #  # ][ #  # ]:          0 :     m_pConnData.reset( static_cast<ORelationTableConnectionData*>(pConnectionData->NewInstance()) );
      84         [ #  # ]:          0 :     m_pConnData->CopyFrom( *pConnectionData );
      85                 :            : 
      86         [ #  # ]:          0 :     Init(m_pConnData);
      87 [ #  # ][ #  # ]:          0 :     m_pTableControl.reset( new OTableListBoxControl(this,ModuleRes(WND_CONTROL),m_pTableMap,this) );
                 [ #  # ]
      88                 :            : 
      89         [ #  # ]:          0 :     aPB_OK.SetClickHdl( LINK(this, ORelationDialog, OKClickHdl) );
      90                 :            : 
      91         [ #  # ]:          0 :     m_pTableControl->Init( m_pConnData );
      92         [ #  # ]:          0 :     if ( bAllowTableSelect )
      93         [ #  # ]:          0 :         m_pTableControl->fillListBoxes();
      94                 :            :     else
      95         [ #  # ]:          0 :         m_pTableControl->fillAndDisable(pConnectionData);
      96                 :            : 
      97         [ #  # ]:          0 :     m_pTableControl->lateInit();
      98                 :            : 
      99         [ #  # ]:          0 :     m_pTableControl->NotifyCellChange();
     100                 :            : 
     101         [ #  # ]:          0 :     FreeResource();
     102                 :          0 : }
     103                 :            : 
     104                 :            : //------------------------------------------------------------------------
     105                 :          0 : void ORelationDialog::Init(const TTableConnectionData::value_type& _pConnectionData)
     106                 :            : {
     107                 :          0 :     ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(_pConnectionData.get());
     108                 :            :     // Update Rules
     109   [ #  #  #  #  :          0 :     switch (pConnData->GetUpdateRules())
                      # ]
     110                 :            :     {
     111                 :            :     case KeyRule::NO_ACTION:
     112                 :            :     case KeyRule::RESTRICT:
     113                 :          0 :         aRB_NoCascUpd.Check( sal_True );
     114                 :          0 :         break;
     115                 :            : 
     116                 :            :     case KeyRule::CASCADE:
     117                 :          0 :         aRB_CascUpd.Check( sal_True );
     118                 :          0 :         break;
     119                 :            : 
     120                 :            :     case KeyRule::SET_NULL:
     121                 :          0 :         aRB_CascUpdNull.Check( sal_True );
     122                 :          0 :         break;
     123                 :            :     case KeyRule::SET_DEFAULT:
     124                 :          0 :         aRB_CascUpdDefault.Check( sal_True );
     125                 :          0 :         break;
     126                 :            :     }
     127                 :            : 
     128                 :            :     // Delete Rules
     129   [ #  #  #  #  :          0 :     switch (pConnData->GetDeleteRules())
                      # ]
     130                 :            :     {
     131                 :            :     case KeyRule::NO_ACTION:
     132                 :            :     case KeyRule::RESTRICT:
     133                 :          0 :         aRB_NoCascDel.Check( sal_True );
     134                 :          0 :         break;
     135                 :            : 
     136                 :            :     case KeyRule::CASCADE:
     137                 :          0 :         aRB_CascDel.Check( sal_True );
     138                 :          0 :         break;
     139                 :            : 
     140                 :            :     case KeyRule::SET_NULL:
     141                 :          0 :         aRB_CascDelNull.Check( sal_True );
     142                 :          0 :         break;
     143                 :            :     case KeyRule::SET_DEFAULT:
     144                 :          0 :         aRB_CascDelDefault.Check( sal_True );
     145                 :          0 :         break;
     146                 :            :     }
     147                 :          0 : }
     148                 :            : 
     149                 :            : //------------------------------------------------------------------------
     150 [ #  # ][ #  # ]:          0 : ORelationDialog::~ORelationDialog()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     151                 :            : {
     152                 :            :     DBG_DTOR(ORelationDialog,NULL);
     153         [ #  # ]:          0 : }
     154                 :            : 
     155                 :            : //------------------------------------------------------------------------
     156                 :            : 
     157                 :            : 
     158                 :            : //------------------------------------------------------------------------
     159                 :          0 : IMPL_LINK( ORelationDialog, OKClickHdl, Button*, /*pButton*/ )
     160                 :            : {
     161                 :            :     //////////////////////////////////////////////////////////////////////
     162                 :            :     // RadioButtons auslesen
     163                 :          0 :     sal_uInt16 nAttrib = 0;
     164                 :            : 
     165                 :            :     // Delete Rules
     166         [ #  # ]:          0 :     if( aRB_NoCascDel.IsChecked() )
     167                 :          0 :         nAttrib |= KeyRule::NO_ACTION;
     168         [ #  # ]:          0 :     if( aRB_CascDel.IsChecked() )
     169                 :          0 :         nAttrib |= KeyRule::CASCADE;
     170         [ #  # ]:          0 :     if( aRB_CascDelNull.IsChecked() )
     171                 :          0 :         nAttrib |= KeyRule::SET_NULL;
     172         [ #  # ]:          0 :     if( aRB_CascDelDefault.IsChecked() )
     173                 :          0 :         nAttrib |= KeyRule::SET_DEFAULT;
     174                 :            : 
     175                 :          0 :     ORelationTableConnectionData* pConnData = static_cast<ORelationTableConnectionData*>(m_pConnData.get());
     176                 :          0 :     pConnData->SetDeleteRules( nAttrib );
     177                 :            : 
     178                 :            :     // Update Rules
     179                 :          0 :     nAttrib = 0;
     180         [ #  # ]:          0 :     if( aRB_NoCascUpd.IsChecked() )
     181                 :          0 :         nAttrib |= KeyRule::NO_ACTION;
     182         [ #  # ]:          0 :     if( aRB_CascUpd.IsChecked() )
     183                 :          0 :         nAttrib |= KeyRule::CASCADE;
     184         [ #  # ]:          0 :     if( aRB_CascUpdNull.IsChecked() )
     185                 :          0 :         nAttrib |= KeyRule::SET_NULL;
     186         [ #  # ]:          0 :     if( aRB_CascUpdDefault.IsChecked() )
     187                 :          0 :         nAttrib |= KeyRule::SET_DEFAULT;
     188                 :          0 :     pConnData->SetUpdateRules( nAttrib );
     189                 :            : 
     190                 :          0 :     m_pTableControl->SaveModified();
     191                 :            : 
     192                 :            :     //// wenn die ComboBoxen fuer die Tabellenauswahl enabled sind (Constructor mit bAllowTableSelect==sal_True), dann muss ich in die
     193                 :            :     //// Connection auch die Tabellennamen stecken
     194                 :            :     //m_pConnData->SetSourceWinName(m_pTableControl->getSourceWinName());
     195                 :            :     //m_pConnData->SetDestWinName(m_pTableControl->getDestWinName());
     196                 :            : 
     197                 :            :     // try to create the relation
     198                 :            :     try
     199                 :            :     {
     200                 :          0 :         ORelationTableConnectionData* pOrigConnData = static_cast<ORelationTableConnectionData*>(m_pOrigConnData.get());
     201 [ #  # ][ #  # ]:          0 :         if ( *pConnData == *pOrigConnData || pConnData->Update())
         [ #  # ][ #  # ]
                 [ #  # ]
     202                 :            :         {
     203         [ #  # ]:          0 :             m_pOrigConnData->CopyFrom( *m_pConnData );
     204         [ #  # ]:          0 :             EndDialog( RET_OK );
     205                 :          0 :             return 0L;
     206                 :            :         }
     207                 :            :     }
     208      [ #  #  # ]:          0 :     catch( const SQLException& )
     209                 :            :     {
     210                 :            :         ::dbaui::showError( SQLExceptionInfo( ::cppu::getCaughtException() ),
     211                 :            :                             this,
     212   [ #  #  #  #  :          0 :                             static_cast<OJoinTableView*>(GetParent())->getDesignView()->getController().getORB());
          #  #  #  #  #  
                #  #  # ]
     213                 :            :     }
     214                 :          0 :     catch( const Exception& )
     215                 :            :     {
     216                 :            :         DBG_UNHANDLED_EXCEPTION();
     217                 :            :     }
     218                 :            : 
     219                 :          0 :     m_bTriedOneUpdate = sal_True;
     220                 :            :     // this means that the original connection may be lost (if m_pConnData was not a newly created but an
     221                 :            :     // existent conn to be modified), which we reflect by returning RET_NO (see ::Execute)
     222                 :            : 
     223                 :            :     // try again
     224                 :          0 :     Init(m_pConnData);
     225                 :          0 :     m_pTableControl->Init( m_pConnData );
     226                 :          0 :     m_pTableControl->lateInit();
     227                 :            : 
     228                 :          0 :     return 0;
     229                 :            : }
     230                 :            : 
     231                 :            : 
     232                 :            : //------------------------------------------------------------------------
     233                 :          0 : short ORelationDialog::Execute()
     234                 :            : {
     235                 :          0 :     short nResult = ModalDialog::Execute();
     236 [ #  # ][ #  # ]:          0 :     if ((nResult != RET_OK) && m_bTriedOneUpdate)
     237                 :          0 :         return RET_NO;
     238                 :            : 
     239                 :          0 :     return nResult;
     240                 :            : }
     241                 :            : // -----------------------------------------------------------------------------
     242                 :          0 : TTableConnectionData::value_type ORelationDialog::getConnectionData() const
     243                 :            : {
     244                 :          0 :     return m_pConnData;
     245                 :            : }
     246                 :            : // -----------------------------------------------------------------------------
     247                 :          0 : void ORelationDialog::setValid(sal_Bool _bValid)
     248                 :            : {
     249                 :          0 :     aPB_OK.Enable(_bValid);
     250                 :          0 : }
     251                 :            : // -----------------------------------------------------------------------------
     252                 :          0 : void ORelationDialog::notifyConnectionChange()
     253                 :            : {
     254                 :          0 :     Init(m_pConnData);
     255                 :          0 : }
     256                 :            : // -----------------------------------------------------------------------------
     257                 :            : 
     258                 :            : 
     259                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10