LCOV - code coverage report
Current view: top level - sw/source/ui/dbui - mmdocselectpage.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 0 102 0.0 %
Date: 2015-06-13 12:38:46 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 <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 :     disposeOnce();
      96           0 : }
      97             : 
      98           0 : void SwMailMergeDocSelectPage::dispose()
      99             : {
     100           0 :     m_pCurrentDocRB.clear();
     101           0 :     m_pNewDocRB.clear();
     102           0 :     m_pLoadDocRB.clear();
     103           0 :     m_pLoadTemplateRB.clear();
     104           0 :     m_pRecentDocRB.clear();
     105           0 :     m_pBrowseDocPB.clear();
     106           0 :     m_pBrowseTemplatePB.clear();
     107           0 :     m_pRecentDocLB.clear();
     108           0 :     m_pWizard.clear();
     109           0 :     svt::OWizardPage::dispose();
     110           0 : }
     111             : 
     112           0 : IMPL_LINK(SwMailMergeDocSelectPage, DocSelectHdl, RadioButton*, pButton)
     113             : {
     114           0 :     m_pRecentDocLB->Enable(m_pRecentDocRB == pButton);
     115             : 
     116           0 :     m_pWizard->UpdateRoadmap();
     117           0 :     m_pWizard->enableButtons(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     118             : 
     119           0 :     return 0;
     120             : }
     121             : 
     122           0 : IMPL_LINK(SwMailMergeDocSelectPage, FileSelectHdl, PushButton*, pButton)
     123             : {
     124           0 :     bool bTemplate = m_pBrowseTemplatePB == pButton;
     125             : 
     126           0 :     if(bTemplate)
     127             :     {
     128           0 :         m_pLoadTemplateRB->Check();
     129           0 :         VclPtrInstance< SfxNewFileDialog > pNewFileDlg(this, 0);
     130           0 :         sal_uInt16 nRet = pNewFileDlg->Execute();
     131           0 :         if(RET_TEMPLATE_LOAD == nRet)
     132           0 :             bTemplate = false;
     133           0 :         else if(RET_CANCEL != nRet)
     134           0 :             m_sLoadTemplateName = pNewFileDlg->GetTemplateFileName();
     135             :     }
     136             :     else
     137           0 :         m_pLoadDocRB->Check();
     138             : 
     139           0 :     if(!bTemplate)
     140             :     {
     141           0 :         sfx2::FileDialogHelper aDlgHelper( TemplateDescription::FILEOPEN_SIMPLE, 0 );
     142           0 :         Reference < XFilePicker > xFP = aDlgHelper.GetFilePicker();
     143             : 
     144           0 :         xFP->setDisplayDirectory( SvtPathOptions().GetWorkPath() );
     145             : 
     146           0 :         SfxObjectFactory &rFact = m_pWizard->GetSwView()->GetDocShell()->GetFactory();
     147           0 :         SfxFilterMatcher aMatcher( OUString::createFromAscii(rFact.GetShortName()) );
     148           0 :         SfxFilterMatcherIter aIter( aMatcher );
     149           0 :         Reference<XFilterManager> xFltMgr(xFP, UNO_QUERY);
     150           0 :         const SfxFilter* pFlt = aIter.First();
     151           0 :         while( pFlt )
     152             :         {
     153           0 :             if( pFlt && pFlt->IsAllowedAsTemplate() )
     154             :             {
     155           0 :                 const OUString sWild = pFlt->GetWildcard().getGlob();
     156           0 :                 xFltMgr->appendFilter( pFlt->GetUIName(), sWild );
     157             : 
     158             :                 // #i40125
     159           0 :                 if(pFlt->GetFilterFlags() & SfxFilterFlags::DEFAULT)
     160           0 :                     xFltMgr->setCurrentFilter( pFlt->GetUIName() ) ;
     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(WizardButtonFlags::NEXT, m_pWizard->isStateEnabled(MM_OUTPUTTYPETPAGE));
     173             : 
     174           0 :     return 0;
     175             : }
     176             : 
     177           0 : bool SwMailMergeDocSelectPage::commitPage( ::svt::WizardTypes::CommitPageReason _eReason )
     178             : {
     179           0 :     bool bReturn = false;
     180           0 :     bool bNext = _eReason == ::svt::WizardTypes::eTravelForward;
     181           0 :     if(bNext || _eReason == ::svt::WizardTypes::eValidate )
     182             :     {
     183           0 :         OUString sReloadDocument;
     184           0 :         bReturn = m_pCurrentDocRB->IsChecked() ||
     185           0 :                 m_pNewDocRB->IsChecked() ||
     186           0 :                 (!(sReloadDocument = m_sLoadFileName).isEmpty() && m_pLoadDocRB->IsChecked() )||
     187           0 :                 (!(sReloadDocument = m_sLoadTemplateName).isEmpty() && m_pLoadTemplateRB->IsChecked())||
     188           0 :                 (m_pRecentDocRB->IsChecked() && !(sReloadDocument = m_pRecentDocLB->GetSelectEntry()).isEmpty());
     189           0 :         if( _eReason == ::svt::WizardTypes::eValidate )
     190           0 :             m_pWizard->SetDocumentLoad(!m_pCurrentDocRB->IsChecked());
     191             : 
     192           0 :         if(bNext && !m_pCurrentDocRB->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           0 : }
     202             : 
     203             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11