LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - mmdocselectpage.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 89 0.0 %
Date: 2014-11-03 Functions: 0 10 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 <unotools/pathoptions.hxx>
      21             : #include <sfx2/filedlghelper.hxx>
      22             : #include <sfx2/new.hxx>
      23             : #include <sfx2/docfilt.hxx>
      24             : #include <sfx2/fcontnr.hxx>
      25             : #include <sfx2/docfac.hxx>
      26             : #include <vcl/msgbox.hxx>
      27             : #include <view.hxx>
      28             : #include <docsh.hxx>
      29             : #include <mmdocselectpage.hxx>
      30             : #include <mailmergewizard.hxx>
      31             : #include <shellio.hxx>
      32             : #include <swabstdlg.hxx>
      33             : #include <mmconfigitem.hxx>
      34             : 
      35             : #include <dbui.hrc>
      36             : 
      37             : #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
      38             : #include <com/sun/star/ui/dialogs/XFilePicker.hpp>
      39             : #include <com/sun/star/ui/dialogs/XFilterManager.hpp>
      40             : #include <boost/scoped_ptr.hpp>
      41             : 
      42             : using namespace ::com::sun::star::ui::dialogs;
      43             : using namespace ::com::sun::star;
      44             : using namespace ::com::sun::star::uno;
      45             : using namespace svt;
      46             : 
      47           0 : SwMailMergeDocSelectPage::SwMailMergeDocSelectPage(SwMailMergeWizard* pParent)
      48             :     : svt::OWizardPage(pParent, "MMSelectPage",
      49             :         "modules/swriter/ui/mmselectpage.ui")
      50           0 :     , m_pWizard(pParent)
      51             : {
      52           0 :     get(m_pCurrentDocRB, "currentdoc");
      53           0 :     get(m_pNewDocRB, "newdoc");
      54           0 :     get(m_pLoadDocRB, "loaddoc");
      55           0 :     get(m_pLoadTemplateRB, "template");
      56           0 :     get(m_pRecentDocRB, "recentdoc");
      57           0 :     get(m_pBrowseDocPB, "browsedoc");
      58           0 :     get(m_pBrowseTemplatePB, "browsetemplate");
      59           0 :     get(m_pRecentDocLB, "recentdoclb");
      60             : 
      61           0 :     m_pCurrentDocRB->Check();
      62           0 :     DocSelectHdl(m_pNewDocRB);
      63             : 
      64           0 :     Link aDocSelectLink = LINK(this, SwMailMergeDocSelectPage, DocSelectHdl);
      65           0 :     m_pCurrentDocRB->SetClickHdl(aDocSelectLink);
      66           0 :     m_pNewDocRB->SetClickHdl(aDocSelectLink);
      67           0 :     m_pLoadDocRB->SetClickHdl(aDocSelectLink);
      68           0 :     m_pLoadTemplateRB->SetClickHdl(aDocSelectLink);
      69           0 :     m_pRecentDocRB->SetClickHdl(aDocSelectLink);
      70             : 
      71           0 :     Link aFileSelectHdl = LINK(this, SwMailMergeDocSelectPage, FileSelectHdl);
      72           0 :     m_pBrowseDocPB->SetClickHdl(aFileSelectHdl);
      73           0 :     m_pBrowseTemplatePB->SetClickHdl(aFileSelectHdl);
      74             : 
      75             :     const uno::Sequence< OUString >& rDocs =
      76           0 :                             m_pWizard->GetConfigItem().GetSavedDocuments();
      77           0 :     for(sal_Int32 nDoc = 0; nDoc < rDocs.getLength(); ++nDoc)
      78             :     {
      79             :         //insert in reverse order
      80           0 :         m_pRecentDocLB->InsertEntry(rDocs[nDoc], 0);
      81             :     }
      82           0 :     m_pRecentDocLB->SelectEntryPos(0);
      83           0 :     if(!rDocs.getLength())
      84             :     {
      85           0 :         m_pRecentDocRB->Enable(false);
      86             :     }
      87             : 
      88             :     //Temp hack until all pages are converted to .ui and wizard
      89             :     //base class adapted
      90           0 :     SetSizePixel(LogicToPixel(Size(260 , 250), MapMode(MAP_APPFONT)));
      91           0 : }
      92             : 
      93           0 : SwMailMergeDocSelectPage::~SwMailMergeDocSelectPage()
      94             : {
      95           0 : }
      96             : 
      97           0 : IMPL_LINK(SwMailMergeDocSelectPage, DocSelectHdl, RadioButton*, pButton)
      98             : {
      99           0 :     m_pRecentDocLB->Enable(m_pRecentDocRB == pButton);
     100             : 
     101           0 :     m_pWizard->UpdateRoadmap();
     102           0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     103             : 
     104           0 :     return 0;
     105             : }
     106             : 
     107           0 : IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, PushButton*, pButton)
     108             : {
     109           0 :     bool bTemplate = m_pBrowseTemplatePB == pButton;
     110             : 
     111           0 :     if(bTemplate)
     112             :     {
     113           0 :         m_pLoadTemplateRB->Check();
     114           0 :         boost::scoped_ptr<SfxNewFileDialog> pNewFileDlg(new SfxNewFileDialog(this, 0));
     115           0 :         sal_uInt16 nRet = pNewFileDlg->Execute();
     116           0 :         if(RET_TEMPLATE_LOAD == nRet)
     117           0 :             bTemplate = false;
     118           0 :         else if(RET_CANCEL != nRet)
     119           0 :             m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
     120             :     }
     121             :     else
     122           0 :         m_pLoadDocRB->Check();
     123             : 
     124           0 :     if(!bTemplate)
     125             :     {
     126           0 :         sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     127           0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     128             : 
     129           0 :         xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
     130             : 
     131           0 :         SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory();
     132           0 :         SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) );
     133           0 :         SfxFilterMatcherIter aIter( aMatcher );
     134           0 :         Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
     135           0 :         const SfxFilter* pFlt = aIter.First();
     136           0 :         while( pFlt )
     137             :         {
     138           0 :             if( pFlt && pFlt->IsAllowedAsTemplate() )
     139             :             {
     140           0 :                 const OUString sWild = pFlt->GetWildcard().getGlob();
     141           0 :                 xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
     142             : 
     143             :                 // #i40125
     144           0 :                 if(pFlt->GetFilterFlags() & SFX_FILTER_DEFAULT)
     145           0 :                     xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
     146             :             }
     147             : 
     148           0 :             pFlt = aIter.Next();
     149             :         }
     150             : 
     151           0 :         if( ERRCODE_NONE == aDlgHelper.Execute() )
     152             :         {
     153           0 :             m_sLoadFileName = xFP->getFiles().getConstArray()[0];
     154           0 :         }
     155             :     }
     156           0 :     m_pWizard->UpdateRoadmap();
     157           0 :     m_pWizard->enableButtons(WZB_NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     158             : 
     159           0 :     return 0;
     160             : }
     161             : 
     162           0 : bool SwMailMergeDocSelectPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     163             : {
     164           0 :     bool bReturn = false;
     165           0 :     bool bNext = _eReason == ::svt::WizardTypes::eTravelForward;
     166           0 :     if(bNext || _eReason == ::svt::WizardTypes::eValidate )
     167             :     {
     168           0 :         OUString sReloadDocument;
     169           0 :         bReturn = m_pCurrentDocRB->IsChecked() ||
     170           0 :                 m_pNewDocRB->IsChecked() ||
     171           0 :                 (!(sReloadDocument = m_sLoadFileName).isEmpty() && m_pLoadDocRB->IsChecked() )||
     172           0 :                 (!(sReloadDocument = m_sLoadTemplateName).isEmpty() && m_pLoadTemplateRB->IsChecked())||
     173           0 :                 (m_pRecentDocRB->IsChecked() && !(sReloadDocument = m_pRecentDocLB->GetSelectEntry()).isEmpty());
     174           0 :         if( _eReason == ::svt::WizardTypes::eValidate )
     175           0 :             m_pWizard->SetDocumentLoad(!m_pCurrentDocRB->IsChecked());
     176             : 
     177           0 :         if(bNext && !m_pCurrentDocRB->IsChecked())
     178             :         {
     179           0 :             if(!sReloadDocument.isEmpty())
     180           0 :                 m_pWizard->SetReloadDocument( sReloadDocument );
     181           0 :             m_pWizard->SetRestartPage(MM_OUTPUTTYPETPAGE);
     182           0 :             m_pWizard->EndDialog(RET_LOAD_DOC);
     183           0 :         }
     184             :     }
     185           0 :     return bReturn;
     186           0 : }
     187             : 
     188             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10