LCOV - code coverage report
Current view: top level - filter/source/xsltdialog - xmlfiltertabpagexslt.cxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 1 78 1.3 %
Date: 2014-11-03 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 ::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 : }
      62             : 
      63           0 : bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo )
      64             : {
      65           0 :     if( pInfo )
      66             :     {
      67           0 :         pInfo->maDocType = m_pEDDocType->GetText();
      68           0 :         pInfo->maExportXSLT = GetURL( m_pEDExportXSLT );
      69           0 :         pInfo->maImportXSLT = GetURL( m_pEDImportXSLT );
      70           0 :         pInfo->maImportTemplate = GetURL( m_pEDImportTemplate );
      71           0 :         pInfo->mbNeedsXSLT2 = m_pCBNeedsXSLT2->IsChecked();
      72             :     }
      73             : 
      74           0 :     return true;
      75             : }
      76             : 
      77           0 : void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo)
      78             : {
      79           0 :     if( pInfo )
      80             :     {
      81           0 :         m_pEDDocType->SetText( pInfo->maDocType );
      82             : 
      83           0 :         SetURL( m_pEDExportXSLT, pInfo->maExportXSLT );
      84           0 :         SetURL( m_pEDImportXSLT, pInfo->maImportXSLT );
      85           0 :         SetURL( m_pEDImportTemplate, pInfo->maImportTemplate );
      86           0 :         m_pCBNeedsXSLT2->Check( pInfo->mbNeedsXSLT2 );
      87             :     }
      88           0 : }
      89             : 
      90           0 : void XMLFilterTabPageXSLT::SetURL( SvtURLBox* rURLBox, const OUString& rURL )
      91             : {
      92           0 :     OUString aPath;
      93             : 
      94           0 :     if( rURL.matchIgnoreAsciiCase( "file://" ) )
      95             :     {
      96           0 :         osl::FileBase::getSystemPathFromFileURL( rURL, aPath );
      97             : 
      98           0 :         rURLBox->SetBaseURL( rURL );
      99           0 :         rURLBox->SetText( aPath );
     100             :     }
     101           0 :     else if( rURL.matchIgnoreAsciiCase( "http://" ) ||
     102           0 :              rURL.matchIgnoreAsciiCase( "https://" ) ||
     103           0 :              rURL.matchIgnoreAsciiCase( "ftp://" ) )
     104             :     {
     105           0 :         rURLBox->SetBaseURL( rURL );
     106           0 :         rURLBox->SetText( rURL );
     107             :     }
     108           0 :     else if( !rURL.isEmpty() )
     109             :     {
     110           0 :         OUString aURL( rURL );
     111           0 :         aURL = URIHelper::SmartRel2Abs( INetURLObject(sInstPath), aURL, Link(), false );
     112           0 :         osl::FileBase::getSystemPathFromFileURL( aURL, aPath );
     113             : 
     114           0 :         rURLBox->SetBaseURL( aURL );
     115           0 :         rURLBox->SetText( aPath );
     116             :     }
     117             :     else
     118             :     {
     119           0 :         rURLBox->SetBaseURL( sInstPath );
     120           0 :         OUString aEmpty;
     121           0 :         rURLBox->SetText( aEmpty );
     122           0 :     }
     123           0 : }
     124             : 
     125           0 : OUString XMLFilterTabPageXSLT::GetURL( SvtURLBox* rURLBox )
     126             : {
     127           0 :     OUString aURL;
     128           0 :     OUString aStrPath ( rURLBox->GetText() );
     129           0 :     if( aStrPath.matchIgnoreAsciiCase( "http://" ) ||
     130           0 :         aStrPath.matchIgnoreAsciiCase( "https://" ) ||
     131           0 :         aStrPath.matchIgnoreAsciiCase( "ftp://" ) )
     132             :     {
     133           0 :         return aStrPath;
     134             :     }
     135             :     else
     136             :     {
     137           0 :         osl::FileBase::getFileURLFromSystemPath( aStrPath, aURL );
     138             :     }
     139             : 
     140           0 :     return aURL;
     141             : }
     142             : 
     143           0 : IMPL_LINK ( XMLFilterTabPageXSLT, ClickBrowseHdl_Impl, PushButton *, pButton )
     144             : {
     145             :     SvtURLBox* pURLBox;
     146             : 
     147           0 :     if( pButton == m_pPBExprotXSLT )
     148             :     {
     149           0 :         pURLBox = m_pEDExportXSLT;
     150             :     }
     151           0 :     else if( pButton == m_pPBImportXSLT )
     152             :     {
     153           0 :         pURLBox = m_pEDImportXSLT;
     154             :     }
     155             :     else
     156             :     {
     157           0 :         pURLBox = m_pEDImportTemplate;
     158             :     }
     159             : 
     160             :     // Open Fileopen-Dialog
     161             :        ::sfx2::FileDialogHelper aDlg(
     162           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     163             : 
     164           0 :     aDlg.SetDisplayDirectory( GetURL( pURLBox ) );
     165             : 
     166           0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     167             :     {
     168           0 :         OUString aURL( aDlg.GetPath() );
     169             : 
     170           0 :         SetURL( pURLBox, aURL );
     171             :     }
     172             : 
     173           0 :     return( 0L );
     174           6 : }
     175             : 
     176             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10