LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - mmdocselectpage.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 81 0.0 %
Date: 2012-08-25 Functions: 0 8 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 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                 :            : #include <unotools/pathoptions.hxx>
      30                 :            : #include <sfx2/filedlghelper.hxx>
      31                 :            : #include <sfx2/new.hxx>
      32                 :            : #include <sfx2/docfilt.hxx>
      33                 :            : #include <sfx2/fcontnr.hxx>
      34                 :            : #include <sfx2/docfac.hxx>
      35                 :            : #include <vcl/msgbox.hxx>
      36                 :            : #include <view.hxx>
      37                 :            : #include <docsh.hxx>
      38                 :            : #include <mmdocselectpage.hxx>
      39                 :            : #include <mailmergewizard.hxx>
      40                 :            : #include <shellio.hxx>
      41                 :            : #include <swabstdlg.hxx>
      42                 :            : #include <mmconfigitem.hxx>
      43                 :            : 
      44                 :            : #include <dbui.hrc>
      45                 :            : #include <mmdocselectpage.hrc>
      46                 :            : 
      47                 :            : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      48                 :            : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      49                 :            : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      50                 :            : 
      51                 :            : using namespace ::com::sun::star::ui::dialogs;
      52                 :            : using namespace ::com::sun::star;
      53                 :            : using namespace ::com::sun::star::uno;
      54                 :            : using namespace svt;
      55                 :            : 
      56                 :          0 : SwMailMergeDocSelectPage::SwMailMergeDocSelectPage( SwMailMergeWizard* _pParent ) :
      57                 :            :     svt::OWizardPage(_pParent, SW_RES(DLG_MM_DOCSELECT_PAGE)),
      58                 :            : #ifdef MSC
      59                 :            : #pragma warning (disable : 4355)
      60                 :            : #endif
      61                 :            :     m_aHeaderFI(this,          SW_RES(  FI_HEADER           ) ),
      62                 :            :     m_aHowToFT          (this, SW_RES( FT_HOWTO )),
      63                 :            :     m_aCurrentDocRB     (this, SW_RES( RB_CURRENTDOC )),
      64                 :            :     m_aNewDocRB         (this, SW_RES( RB_NEWDOC )),
      65                 :            :     m_aLoadDocRB        (this, SW_RES( RB_LOADDOC )),
      66                 :            :     m_aLoadTemplateRB   (this, SW_RES( RB_LOADTEMPLATE )),
      67                 :            :     m_aRecentDocRB      (this, SW_RES( RB_RECENTDOC )),
      68                 :            :     m_aBrowseDocPB      (this, SW_RES( PB_LOADDOC )),
      69                 :            :     m_aBrowseTemplatePB (this, SW_RES( PB_BROWSETEMPLATE )),
      70                 :            :     m_aRecentDocLB      (this, SW_RES( LB_RECENTDOC )),
      71                 :            : #ifdef MSC
      72                 :            : #pragma warning (default : 4355)
      73                 :            : #endif
      74                 :          0 :     m_pWizard(_pParent)
      75                 :            : {
      76                 :          0 :     FreeResource();
      77                 :            : 
      78                 :          0 :     m_aCurrentDocRB.Check();
      79                 :          0 :     DocSelectHdl(&m_aNewDocRB);
      80                 :            : 
      81                 :          0 :     Link aDocSelectLink = LINK(this, SwMailMergeDocSelectPage, DocSelectHdl);
      82                 :          0 :     m_aCurrentDocRB.SetClickHdl(aDocSelectLink);
      83                 :          0 :     m_aNewDocRB.SetClickHdl(aDocSelectLink);
      84                 :          0 :     m_aLoadDocRB.SetClickHdl(aDocSelectLink);
      85                 :          0 :     m_aLoadTemplateRB.SetClickHdl(aDocSelectLink);
      86                 :          0 :     m_aRecentDocRB.SetClickHdl(aDocSelectLink);
      87                 :            : 
      88                 :          0 :     Link aFileSelectHdl = LINK(this, SwMailMergeDocSelectPage, FileSelectHdl);
      89                 :          0 :     m_aBrowseDocPB.SetClickHdl(aFileSelectHdl);
      90                 :          0 :     m_aBrowseTemplatePB.SetClickHdl(aFileSelectHdl);
      91                 :            : 
      92                 :            :     const uno::Sequence< ::rtl::OUString >& rDocs =
      93                 :          0 :                             m_pWizard->GetConfigItem().GetSavedDocuments();
      94                 :          0 :     for(sal_Int32 nDoc = 0; nDoc < rDocs.getLength(); ++nDoc)
      95                 :            :     {
      96                 :            :         //insert in reverse order
      97                 :          0 :         m_aRecentDocLB.InsertEntry(rDocs[nDoc], 0);
      98                 :            :     }
      99                 :          0 :     m_aRecentDocLB.SelectEntryPos(0);
     100                 :          0 :     if(!rDocs.getLength())
     101                 :            :     {
     102                 :          0 :         m_aRecentDocRB.Enable(sal_False);
     103                 :            :     }
     104                 :          0 : }
     105                 :            : 
     106                 :          0 : SwMailMergeDocSelectPage::~SwMailMergeDocSelectPage()
     107                 :            : {
     108                 :          0 : }
     109                 :            : 
     110                 :          0 : IMPL_LINK(SwMailMergeDocSelectPage, DocSelectHdl, RadioButton*, pButton)
     111                 :            : {
     112                 :          0 :     m_aRecentDocLB.Enable(&m_aRecentDocRB == pButton);
     113                 :            : 
     114                 :          0 :     m_pWizard->UpdateRoadmap();
     115                 :          0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     116                 :            : 
     117                 :          0 :     return 0;
     118                 :            : }
     119                 :            : 
     120                 :          0 : IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, PushButton*, pButton)
     121                 :            : {
     122                 :          0 :     bool bTemplate = &m_aBrowseTemplatePB == pButton;
     123                 :            : 
     124                 :          0 :     if(bTemplate)
     125                 :            :     {
     126                 :          0 :         m_aLoadTemplateRB.Check();
     127                 :          0 :         SfxNewFileDialog* pNewFileDlg = new SfxNewFileDialog(this, 0);
     128                 :          0 :         sal_uInt16 nRet = pNewFileDlg->Execute();
     129                 :          0 :         if(RET_TEMPLATE_LOAD == nRet)
     130                 :          0 :             bTemplate = false;
     131                 :          0 :         else if(RET_CANCEL != nRet)
     132                 :          0 :             m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
     133                 :          0 :         delete pNewFileDlg;
     134                 :            :     }
     135                 :            :     else
     136                 :          0 :         m_aLoadDocRB.Check();
     137                 :            : 
     138                 :          0 :     if(!bTemplate)
     139                 :            :     {
     140                 :          0 :         sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     141                 :          0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     142                 :            : 
     143                 :          0 :         xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
     144                 :            : 
     145                 :          0 :         SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory();
     146                 :          0 :         SfxFilterMatcher aMatcher( rtl::OUString::createFromAscii(rFact.GetShortName()) );
     147                 :          0 :         SfxFilterMatcherIter aIter( aMatcher );
     148                 :          0 :         Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
     149                 :          0 :         const SfxFilter* pFlt = aIter.First();
     150                 :          0 :         while( pFlt )
     151                 :            :         {
     152                 :          0 :             if( pFlt && pFlt->IsAllowedAsTemplate() )
     153                 :            :             {
     154                 :          0 :                 const String sWild = pFlt->GetWildcard().getGlob();
     155                 :          0 :                 xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
     156                 :            : 
     157                 :            :                 // #i40125
     158                 :          0 :                 if(pFlt->GetFilterFlags() & SFX_FILTER_DEFAULT)
     159                 :          0 :                     xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
     160                 :            :             }
     161                 :            : 
     162                 :            : 
     163                 :          0 :             pFlt = aIter.Next();
     164                 :            :         }
     165                 :            : 
     166                 :          0 :         if( ERRCODE_NONE == aDlgHelper.Execute() )
     167                 :            :         {
     168                 :          0 :             m_sLoadFileName = xFP->getFiles().getConstArray()[0];
     169                 :          0 :         }
     170                 :            :     }
     171                 :          0 :     m_pWizard->UpdateRoadmap();
     172                 :          0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     173                 :            : 
     174                 :          0 :     return 0;
     175                 :            : }
     176                 :            : 
     177                 :          0 : sal_Bool SwMailMergeDocSelectPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     178                 :            : {
     179                 :          0 :     sal_Bool bReturn = sal_False;
     180                 :          0 :     bool bNext = _eReason == ::svt::WizardTypes::eTravelForward;
     181                 :          0 :     if(bNext || _eReason == ::svt::WizardTypes::eValidate )
     182                 :            :     {
     183                 :          0 :         ::rtl::OUString sReloadDocument;
     184                 :          0 :         bReturn = m_aCurrentDocRB.IsChecked() ||
     185                 :          0 :                 m_aNewDocRB.IsChecked() ||
     186                 :          0 :                 (!(sReloadDocument = m_sLoadFileName).isEmpty() && m_aLoadDocRB.IsChecked() )||
     187                 :          0 :                 (!(sReloadDocument = m_sLoadTemplateName).isEmpty() && m_aLoadTemplateRB.IsChecked())||
     188                 :          0 :                 (m_aRecentDocRB.IsChecked() && !(sReloadDocument = m_aRecentDocLB.GetSelectEntry()).isEmpty());
     189                 :          0 :         if( _eReason == ::svt::WizardTypes::eValidate )
     190                 :          0 :             m_pWizard->SetDocumentLoad(!m_aCurrentDocRB.IsChecked());
     191                 :            : 
     192                 :          0 :         if(bNext && !m_aCurrentDocRB.IsChecked())
     193                 :            :         {
     194                 :          0 :             if(!sReloadDocument.isEmpty())
     195                 :          0 :                 m_pWizard->SetReloadDocument( sReloadDocument );
     196                 :          0 :             m_pWizard->SetRestartPage(MM_OUTPUTTYPETPAGE);
     197                 :          0 :             m_pWizard->EndDialog(RET_LOAD_DOC);
     198                 :          0 :         }
     199                 :            :     }
     200                 :          0 :     return bReturn;
     201                 :            : }
     202                 :            : 
     203                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10