LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/dbui - mmpreparemergepage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2013-07-09 Functions: 0 13 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             : #include <mmpreparemergepage.hxx>
      21             : #include <mailmergewizard.hxx>
      22             : #include <mmconfigitem.hxx>
      23             : #include <dbui.hrc>
      24             : #include <swtypes.hxx>
      25             : #include <view.hxx>
      26             : #include <dbmgr.hxx>
      27             : #include <wrtsh.hxx>
      28             : #include <svx/dataaccessdescriptor.hxx>
      29             : #include <com/sun/star/sdbc/XConnection.hpp>
      30             : #include <swabstdlg.hxx>
      31             : 
      32             : 
      33             : #include <mmpreparemergepage.hrc>
      34             : 
      35             : #include <unomid.h>
      36             : 
      37             : using namespace ::com::sun::star::uno;
      38             : using namespace ::com::sun::star::beans;
      39             : using namespace ::com::sun::star::sdbc;
      40             : 
      41           0 : SwMailMergePrepareMergePage::SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent) :
      42             :     svt::OWizardPage( _pParent, SW_RES(DLG_MM_PREPAREMERGE_PAGE)),
      43             : #ifdef _MSC_VER
      44             : #pragma warning (disable : 4355)
      45             : #endif
      46             :     m_aHeaderFI(this,  SW_RES(     FI_HEADER ) ),
      47             :     m_aPreviewFI(this, SW_RES(     FI_PREVIEW ) ),
      48             :     m_aRecipientFT(this, SW_RES(   FT_RECIPIENT ) ),
      49             :     m_aFirstPB(this, SW_RES(       PB_FIRST   ) ),
      50             :     m_aPrevPB(this, SW_RES(        PB_PREV    ) ),
      51             :     m_aRecordED(this, SW_RES(      ED_RECORD  ) ),
      52             :     m_aNextPB(this, SW_RES(        PB_NEXT    ) ),
      53             :     m_aLastPB(this, SW_RES(        PB_LAST    ) ),
      54             :     m_ExcludeCB(this, SW_RES(      CB_EXCLUDE    ) ),
      55             :     m_aNoteHeaderFL(this, SW_RES(  FL_NOTEHEADER ) ),
      56             :     m_aEditFI(this, SW_RES(        FI_EDIT       ) ),
      57             :     m_aEditPB(this, SW_RES(        PB_EDIT       ) ),
      58             : #ifdef _MSC_VER
      59             : #pragma warning (default : 4355)
      60             : #endif
      61           0 :     m_pWizard(_pParent)
      62             : {
      63           0 :     FreeResource();
      64           0 :     m_aEditPB.SetClickHdl( LINK( this, SwMailMergePrepareMergePage, EditDocumentHdl_Impl));
      65           0 :     Link aMoveLink(LINK( this, SwMailMergePrepareMergePage, MoveHdl_Impl));
      66           0 :     m_aFirstPB.SetClickHdl( aMoveLink );
      67           0 :     m_aPrevPB.SetClickHdl( aMoveLink );
      68           0 :     m_aNextPB.SetClickHdl( aMoveLink );
      69           0 :     m_aLastPB.SetClickHdl( aMoveLink );
      70           0 :     m_aRecordED.SetActionHdl( aMoveLink );
      71           0 :     m_ExcludeCB.SetClickHdl(LINK(this, SwMailMergePrepareMergePage, ExcludeHdl_Impl));
      72           0 :     aMoveLink.Call(&m_aRecordED);
      73           0 : }
      74             : 
      75           0 : SwMailMergePrepareMergePage::~SwMailMergePrepareMergePage()
      76             : {
      77           0 : }
      78             : 
      79           0 : IMPL_LINK_NOARG(SwMailMergePrepareMergePage, EditDocumentHdl_Impl)
      80             : {
      81           0 :     m_pWizard->SetRestartPage(MM_PREPAREMERGEPAGE);
      82           0 :     m_pWizard->EndDialog(RET_EDIT_DOC);
      83           0 :     return 0;
      84             : }
      85             : 
      86           0 : IMPL_LINK( SwMailMergePrepareMergePage, MoveHdl_Impl, void*, pCtrl)
      87             : {
      88           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
      89           0 :     sal_Int32 nPos = rConfigItem.GetResultSetPosition();
      90           0 :     if(pCtrl == &m_aFirstPB)
      91             :     {
      92           0 :         rConfigItem.MoveResultSet(1);
      93             :     }
      94           0 :     else if(pCtrl == &m_aPrevPB)
      95             :     {
      96           0 :         rConfigItem.MoveResultSet(nPos - 1);
      97             :     }
      98           0 :     else if(pCtrl == &m_aRecordED)
      99             :     {
     100           0 :         rConfigItem.MoveResultSet( static_cast< sal_Int32 >(m_aRecordED.GetValue()) );
     101             :     }
     102           0 :     else if(pCtrl == &m_aNextPB)
     103           0 :         rConfigItem.MoveResultSet(nPos + 1);
     104           0 :     else if(pCtrl == &m_aLastPB)
     105           0 :         rConfigItem.MoveResultSet(-1);
     106             : 
     107           0 :     nPos = rConfigItem.GetResultSetPosition();
     108           0 :     m_aRecordED.SetValue(nPos);
     109             :     bool bIsFirst;
     110             :     bool bIsLast;
     111           0 :     bool bValid = rConfigItem.IsResultSetFirstLast(bIsFirst, bIsLast);
     112           0 :     m_aFirstPB.Enable(bValid && !bIsFirst);
     113           0 :     m_aPrevPB.Enable(bValid && !bIsFirst);
     114           0 :     m_aNextPB.Enable(bValid && !bIsLast);
     115           0 :     m_aLastPB.Enable(bValid && !bIsLast);
     116           0 :     m_ExcludeCB.Check(rConfigItem.IsRecordExcluded( rConfigItem.GetResultSetPosition() ));
     117             :     //now the record has to be merged into the source document
     118           0 :     const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
     119             : 
     120           0 :     Sequence< PropertyValue > aArgs(7);
     121           0 :     Sequence<Any> aSelection(1);
     122           0 :     aSelection[0] <<= rConfigItem.GetResultSetPosition();
     123           0 :     aArgs[0].Name = "Selection";
     124           0 :     aArgs[0].Value <<= aSelection;
     125           0 :     aArgs[1].Name = "DataSourceName";
     126           0 :     aArgs[1].Value <<= rDBData.sDataSource;
     127           0 :     aArgs[2].Name = "Command";
     128           0 :     aArgs[2].Value <<= rDBData.sCommand;
     129           0 :     aArgs[3].Name = "CommandType";
     130           0 :     aArgs[3].Value <<= rDBData.nCommandType;
     131           0 :     aArgs[4].Name = "ActiveConnection";
     132           0 :     aArgs[4].Value <<=  rConfigItem.GetConnection().getTyped();
     133           0 :     aArgs[5].Name = "Filter";
     134           0 :     aArgs[5].Value <<= rConfigItem.GetFilter();
     135           0 :     aArgs[6].Name = "Cursor";
     136           0 :     aArgs[6].Value <<= rConfigItem.GetResultSet();
     137             : 
     138           0 :     ::svx::ODataAccessDescriptor aDescriptor(aArgs);
     139           0 :     SwWrtShell& rSh = m_pWizard->GetSwView()->GetWrtShell();
     140           0 :     SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
     141           0 :     rSh.GetNewDBMgr()->MergeNew(aMergeDesc);
     142           0 :     return 0;
     143             : }
     144             : 
     145           0 : IMPL_LINK( SwMailMergePrepareMergePage, ExcludeHdl_Impl, CheckBox*, pBox)
     146             : {
     147           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     148           0 :     rConfigItem.ExcludeRecord( rConfigItem.GetResultSetPosition(), pBox->IsChecked());
     149           0 :     return 0;
     150             : };
     151             : 
     152           0 : void  SwMailMergePrepareMergePage::ActivatePage()
     153             : {
     154           0 :     MoveHdl_Impl(&m_aRecordED);
     155           0 : }
     156             : 
     157             : /*-------------------------------------------------------------------------
     158             :     merge the data into a new file
     159             :   -----------------------------------------------------------------------*/
     160           0 : sal_Bool  SwMailMergePrepareMergePage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     161             : {
     162           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     163           0 :     if(::svt::WizardTypes::eTravelForward == _eReason && !rConfigItem.IsMergeDone())
     164             :     {
     165           0 :         m_pWizard->CreateTargetDocument();
     166           0 :         m_pWizard->SetRestartPage(MM_MERGEPAGE);
     167           0 :         m_pWizard->EndDialog(RET_TARGET_CREATED);
     168             :     }
     169           0 :     return sal_True;
     170           0 : }
     171             : 
     172             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10