LCOV - code coverage report
Current view: top level - filter/source/xsltdialog - xmlfiltertabpagexslt.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 90 1.1 %
Date: 2015-06-13 12:38:46 Functions: 2 12 16.7 %
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 <com/sun/star/frame/XConfigManager.hpp>
      21             : 
      22             : #include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
      23             : #include <sfx2/filedlghelper.hxx>
      24             : #include <unotools/localfilehelper.hxx>
      25             : #include <unotools/pathoptions.hxx>
      26             : #include <osl/file.hxx>
      27             : #include <svl/urihelper.hxx>
      28             : 
      29             : #include "xmlfiltertabpagexslt.hxx"
      30             : #include "xmlfiltersettingsdialog.hxx"
      31             : 
      32             : using namespace ::com::sun::star::uno;
      33             : using namespace ::com::sun::star::frame;
      34             : using namespace ::com::sun::star::lang;
      35             : 
      36           0 : XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( vcl::Window* pParent) :
      37             :     TabPage( pParent, "XmlFilterTabPageTransformation", "filter/ui/xmlfiltertabpagetransformation.ui" ),
      38             : 
      39           0 :     sInstPath( "$(prog)/" )
      40             : {
      41           0 :     get(m_pEDDocType,"doc");
      42           0 :     get(m_pEDExportXSLT,"xsltexport");
      43           0 :     get(m_pPBExprotXSLT,"browseexport");
      44           0 :     get(m_pEDImportXSLT,"xsltimport");
      45           0 :     get(m_pPBImportXSLT,"browseimport");
      46           0 :     get(m_pEDImportTemplate,"tempimport");
      47           0 :     get(m_pPBImportTemplate,"browsetemp");
      48           0 :     get(m_pCBNeedsXSLT2,"filtercb");
      49             : 
      50             : 
      51           0 :     SvtPathOptions aOptions;
      52           0 :     sInstPath = aOptions.SubstituteVariable( sInstPath );
      53             : 
      54           0 :     m_pPBExprotXSLT->SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      55           0 :     m_pPBImportXSLT->SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      56           0 :     m_pPBImportTemplate->SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      57           0 : }
      58             : 
      59           0 : XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT()
      60             : {
      61           0 :     disposeOnce();
      62           0 : }
      63             : 
      64           0 : void XMLFilterTabPageXSLT::dispose()
      65             : {
      66           0 :     m_pEDDocType.clear();
      67           0 :     m_pEDExportXSLT.clear();
      68           0 :     m_pPBExprotXSLT.clear();
      69           0 :     m_pEDImportXSLT.clear();
      70           0 :     m_pPBImportXSLT.clear();
      71           0 :     m_pEDImportTemplate.clear();
      72           0 :     m_pPBImportTemplate.clear();
      73           0 :     m_pCBNeedsXSLT2.clear();
      74           0 :     TabPage::dispose();
      75           0 : }
      76             : 
      77           0 : bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo )
      78             : {
      79           0 :     if( pInfo )
      80             :     {
      81           0 :         pInfo->maDocType = m_pEDDocType->GetText();
      82           0 :         pInfo->maExportXSLT = GetURL( m_pEDExportXSLT );
      83           0 :         pInfo->maImportXSLT = GetURL( m_pEDImportXSLT );
      84           0 :         pInfo->maImportTemplate = GetURL( m_pEDImportTemplate );
      85           0 :         pInfo->mbNeedsXSLT2 = m_pCBNeedsXSLT2->IsChecked();
      86             :     }
      87             : 
      88           0 :     return true;
      89             : }
      90             : 
      91           0 : void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo)
      92             : {
      93           0 :     if( pInfo )
      94             :     {
      95           0 :         m_pEDDocType->SetText( pInfo->maDocType );
      96             : 
      97           0 :         SetURL( m_pEDExportXSLT, pInfo->maExportXSLT );
      98           0 :         SetURL( m_pEDImportXSLT, pInfo->maImportXSLT );
      99           0 :         SetURL( m_pEDImportTemplate, pInfo->maImportTemplate );
     100           0 :         m_pCBNeedsXSLT2->Check( pInfo->mbNeedsXSLT2 );
     101             :     }
     102           0 : }
     103             : 
     104           0 : void XMLFilterTabPageXSLT::SetURL( SvtURLBox* rURLBox, const OUString& rURL )
     105             : {
     106           0 :     OUString aPath;
     107             : 
     108           0 :     if( rURL.matchIgnoreAsciiCase( "file://" ) )
     109             :     {
     110           0 :         osl::FileBase::getSystemPathFromFileURL( rURL, aPath );
     111             : 
     112           0 :         rURLBox->SetBaseURL( rURL );
     113           0 :         rURLBox->SetText( aPath );
     114             :     }
     115           0 :     else if( rURL.matchIgnoreAsciiCase( "http://" ) ||
     116           0 :              rURL.matchIgnoreAsciiCase( "https://" ) ||
     117           0 :              rURL.matchIgnoreAsciiCase( "ftp://" ) )
     118             :     {
     119           0 :         rURLBox->SetBaseURL( rURL );
     120           0 :         rURLBox->SetText( rURL );
     121             :     }
     122           0 :     else if( !rURL.isEmpty() )
     123             :     {
     124           0 :         OUString aURL( rURL );
     125           0 :         aURL = URIHelper::SmartRel2Abs( INetURLObject(sInstPath), aURL, Link<OUString *, bool>(), false );
     126           0 :         osl::FileBase::getSystemPathFromFileURL( aURL, aPath );
     127             : 
     128           0 :         rURLBox->SetBaseURL( aURL );
     129           0 :         rURLBox->SetText( aPath );
     130             :     }
     131             :     else
     132             :     {
     133           0 :         rURLBox->SetBaseURL( sInstPath );
     134           0 :         OUString aEmpty;
     135           0 :         rURLBox->SetText( aEmpty );
     136           0 :     }
     137           0 : }
     138             : 
     139           0 : OUString XMLFilterTabPageXSLT::GetURL( SvtURLBox* rURLBox )
     140             : {
     141           0 :     OUString aURL;
     142           0 :     OUString aStrPath ( rURLBox->GetText() );
     143           0 :     if( aStrPath.matchIgnoreAsciiCase( "http://" ) ||
     144           0 :         aStrPath.matchIgnoreAsciiCase( "https://" ) ||
     145           0 :         aStrPath.matchIgnoreAsciiCase( "ftp://" ) )
     146             :     {
     147           0 :         return aStrPath;
     148             :     }
     149             :     else
     150             :     {
     151           0 :         osl::FileBase::getFileURLFromSystemPath( aStrPath, aURL );
     152             :     }
     153             : 
     154           0 :     return aURL;
     155             : }
     156             : 
     157           0 : IMPL_LINK ( XMLFilterTabPageXSLT, ClickBrowseHdl_Impl, PushButton *, pButton )
     158             : {
     159             :     SvtURLBox* pURLBox;
     160             : 
     161           0 :     if( pButton == m_pPBExprotXSLT )
     162             :     {
     163           0 :         pURLBox = m_pEDExportXSLT;
     164             :     }
     165           0 :     else if( pButton == m_pPBImportXSLT )
     166             :     {
     167           0 :         pURLBox = m_pEDImportXSLT;
     168             :     }
     169             :     else
     170             :     {
     171           0 :         pURLBox = m_pEDImportTemplate;
     172             :     }
     173             : 
     174             :     // Open Fileopen-Dialog
     175             :        ::sfx2::FileDialogHelper aDlg(
     176           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     177             : 
     178           0 :     aDlg.SetDisplayDirectory( GetURL( pURLBox ) );
     179             : 
     180           0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     181             :     {
     182           0 :         OUString aURL( aDlg.GetPath() );
     183             : 
     184           0 :         SetURL( pURLBox, aURL );
     185             :     }
     186             : 
     187           0 :     return 0L;
     188           3 : }
     189             : 
     190             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11