LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - mmpreparemergepage.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 82 0.0 %
Date: 2014-04-14 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             : #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             : #include <unomid.h>
      33             : 
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::beans;
      36             : using namespace ::com::sun::star::sdbc;
      37             : 
      38           0 : SwMailMergePrepareMergePage::SwMailMergePrepareMergePage( SwMailMergeWizard* _pParent)
      39             :     : svt::OWizardPage(_pParent, "MMPreparePage", "modules/swriter/ui/mmpreparepage.ui")
      40           0 :     , m_pWizard(_pParent)
      41             : {
      42           0 :     get(m_pFirstPB, "first");
      43           0 :     get(m_pPrevPB, "prev");
      44           0 :     get(m_pRecordED, "record-nospin");
      45           0 :     get(m_pNextPB, "next");
      46           0 :     get(m_pLastPB, "last");
      47           0 :     get(m_pExcludeCB, "exclude");
      48           0 :     get(m_pEditPB, "edit");
      49             : 
      50           0 :     m_pEditPB->SetClickHdl( LINK( this, SwMailMergePrepareMergePage, EditDocumentHdl_Impl));
      51           0 :     Link aMoveLink(LINK( this, SwMailMergePrepareMergePage, MoveHdl_Impl));
      52           0 :     m_pFirstPB->SetClickHdl( aMoveLink );
      53           0 :     m_pPrevPB->SetClickHdl( aMoveLink );
      54           0 :     m_pNextPB->SetClickHdl( aMoveLink );
      55           0 :     m_pLastPB->SetClickHdl( aMoveLink );
      56           0 :     m_pRecordED->SetModifyHdl( aMoveLink );
      57           0 :     m_pExcludeCB->SetClickHdl(LINK(this, SwMailMergePrepareMergePage, ExcludeHdl_Impl));
      58           0 :     aMoveLink.Call(m_pRecordED);
      59           0 : }
      60             : 
      61           0 : IMPL_LINK_NOARG(SwMailMergePrepareMergePage, EditDocumentHdl_Impl)
      62             : {
      63           0 :     m_pWizard->SetRestartPage(MM_PREPAREMERGEPAGE);
      64           0 :     m_pWizard->EndDialog(RET_EDIT_DOC);
      65           0 :     return 0;
      66             : }
      67             : 
      68           0 : IMPL_LINK( SwMailMergePrepareMergePage, MoveHdl_Impl, void*, pCtrl)
      69             : {
      70           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
      71           0 :     sal_Int32 nPos = rConfigItem.GetResultSetPosition();
      72           0 :     if (pCtrl == m_pFirstPB)
      73             :     {
      74           0 :         rConfigItem.MoveResultSet(1);
      75             :     }
      76           0 :     else if (pCtrl == m_pPrevPB)
      77             :     {
      78           0 :         rConfigItem.MoveResultSet(nPos - 1);
      79             :     }
      80           0 :     else if (pCtrl == m_pRecordED)
      81             :     {
      82           0 :         rConfigItem.MoveResultSet( static_cast< sal_Int32 >(m_pRecordED->GetValue()) );
      83             :     }
      84           0 :     else if (pCtrl == m_pNextPB)
      85           0 :         rConfigItem.MoveResultSet(nPos + 1);
      86           0 :     else if (pCtrl == m_pLastPB)
      87           0 :         rConfigItem.MoveResultSet(-1);
      88             : 
      89           0 :     nPos = rConfigItem.GetResultSetPosition();
      90           0 :     m_pRecordED->SetValue(nPos);
      91             :     bool bIsFirst;
      92             :     bool bIsLast;
      93           0 :     bool bValid = rConfigItem.IsResultSetFirstLast(bIsFirst, bIsLast);
      94           0 :     m_pFirstPB->Enable(bValid && !bIsFirst);
      95           0 :     m_pPrevPB->Enable(bValid && !bIsFirst);
      96           0 :     m_pNextPB->Enable(bValid && !bIsLast);
      97           0 :     m_pLastPB->Enable(bValid && !bIsLast);
      98           0 :     m_pExcludeCB->Check(rConfigItem.IsRecordExcluded( rConfigItem.GetResultSetPosition() ));
      99             :     //now the record has to be merged into the source document
     100           0 :     const SwDBData& rDBData = rConfigItem.GetCurrentDBData();
     101             : 
     102           0 :     Sequence< PropertyValue > aArgs(7);
     103           0 :     Sequence<Any> aSelection(1);
     104           0 :     aSelection[0] <<= rConfigItem.GetResultSetPosition();
     105           0 :     aArgs[0].Name = "Selection";
     106           0 :     aArgs[0].Value <<= aSelection;
     107           0 :     aArgs[1].Name = "DataSourceName";
     108           0 :     aArgs[1].Value <<= rDBData.sDataSource;
     109           0 :     aArgs[2].Name = "Command";
     110           0 :     aArgs[2].Value <<= rDBData.sCommand;
     111           0 :     aArgs[3].Name = "CommandType";
     112           0 :     aArgs[3].Value <<= rDBData.nCommandType;
     113           0 :     aArgs[4].Name = "ActiveConnection";
     114           0 :     aArgs[4].Value <<=  rConfigItem.GetConnection().getTyped();
     115           0 :     aArgs[5].Name = "Filter";
     116           0 :     aArgs[5].Value <<= rConfigItem.GetFilter();
     117           0 :     aArgs[6].Name = "Cursor";
     118           0 :     aArgs[6].Value <<= rConfigItem.GetResultSet();
     119             : 
     120           0 :     ::svx::ODataAccessDescriptor aDescriptor(aArgs);
     121           0 :     SwWrtShell& rSh = m_pWizard->GetSwView()->GetWrtShell();
     122           0 :     SwMergeDescriptor aMergeDesc( DBMGR_MERGE, rSh, aDescriptor );
     123           0 :     rSh.GetNewDBMgr()->MergeNew(aMergeDesc);
     124           0 :     return 0;
     125             : }
     126             : 
     127           0 : IMPL_LINK( SwMailMergePrepareMergePage, ExcludeHdl_Impl, CheckBox*, pBox)
     128             : {
     129           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     130           0 :     rConfigItem.ExcludeRecord( rConfigItem.GetResultSetPosition(), pBox->IsChecked());
     131           0 :     return 0;
     132             : };
     133             : 
     134           0 : void  SwMailMergePrepareMergePage::ActivatePage()
     135             : {
     136           0 :     MoveHdl_Impl(m_pRecordED);
     137           0 : }
     138             : 
     139             : /*-------------------------------------------------------------------------
     140             :     merge the data into a new file
     141             :   -----------------------------------------------------------------------*/
     142           0 : bool SwMailMergePrepareMergePage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     143             : {
     144           0 :     SwMailMergeConfigItem& rConfigItem = m_pWizard->GetConfigItem();
     145           0 :     if(::svt::WizardTypes::eTravelForward == _eReason && !rConfigItem.IsMergeDone())
     146             :     {
     147           0 :         m_pWizard->CreateTargetDocument();
     148           0 :         m_pWizard->SetRestartPage(MM_MERGEPAGE);
     149           0 :         m_pWizard->EndDialog(RET_TARGET_CREATED);
     150             :     }
     151           0 :     return true;
     152           0 : }
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10