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

Generated by: LCOV version 1.10