LCOV - code coverage report
Current view: top level - libreoffice/filter/source/xsltdialog - xmlfiltertabpagexslt.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 78 0.0 %
Date: 2012-12-17 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 <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 <osl/file.hxx>
      26             : #include <svl/urihelper.hxx>
      27             : 
      28             : #include "xmlfiltertabpagexslt.hxx"
      29             : #include "xmlfiltertabpagexslt.hrc"
      30             : #include "xmlfiltersettingsdialog.hxx"
      31             : #include "xmlfilterhelpids.hrc"
      32             : 
      33             : using namespace ::rtl;
      34             : using namespace ::com::sun::star::uno;
      35             : using namespace ::com::sun::star::frame;
      36             : using namespace ::com::sun::star::lang;
      37             : 
      38           0 : XMLFilterTabPageXSLT::XMLFilterTabPageXSLT( Window* pParent, ResMgr& rResMgr, const css::uno::Reference< XMultiServiceFactory >& rxMSF ) :
      39             :     TabPage( pParent, ResId( RID_XML_FILTER_TABPAGE_XSLT, rResMgr ) ),
      40             : 
      41             :     maFTDocType( this, ResId( FT_XML_DOCTYPE, rResMgr ) ),
      42             :     maEDDocType( this, ResId( ED_XML_DOCTYPE, rResMgr ) ),
      43             : 
      44             :     maFTExportXSLT( this, ResId( FT_XML_EXPORT_XSLT, rResMgr ) ),
      45             :     maEDExportXSLT( this, ResId( ED_XML_EXPORT_XSLT, rResMgr ), INET_PROT_FILE ),
      46             :     maPBExprotXSLT( this, ResId( PB_XML_EXPORT_XSLT_BROWSE, rResMgr ) ),
      47             : 
      48             :     maFTImportXSLT( this, ResId( FT_XML_IMPORT_XSLT, rResMgr ) ),
      49             :     maEDImportXSLT( this, ResId( ED_XML_IMPORT_XSLT, rResMgr ), INET_PROT_FILE ),
      50             :     maPBImportXSLT( this, ResId( PB_XML_IMPORT_XSLT_BROWSE, rResMgr ) ),
      51             : 
      52             :     maFTImportTemplate( this, ResId( FT_XML_IMPORT_TEMPLATE, rResMgr ) ),
      53             :     maEDImportTemplate( this, ResId( ED_XML_IMPORT_TEMPLATE, rResMgr ), INET_PROT_FILE ),
      54             :     maPBImportTemplate( this, ResId( PB_XML_IMPORT_TEMPLATE_BROWSE, rResMgr ) ),
      55             : 
      56             :     maFTNeedsXSLT2( this, ResId (FT_XML_NEEDS_XSLT2, rResMgr ) ),
      57             :     maCBNeedsXSLT2( this, ResId (CB_XML_NEEDS_XSLT2, rResMgr ) ),
      58             : 
      59             :     sHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ),
      60             :     sSHTTPSchema( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ),
      61             :     sFILESchema( RTL_CONSTASCII_USTRINGPARAM( "file://" ) ),
      62             :     sFTPSchema( RTL_CONSTASCII_USTRINGPARAM( "ftp://" ) ),
      63           0 :     sInstPath( RTL_CONSTASCII_USTRINGPARAM( "$(prog)/" ) )
      64             : {
      65           0 :     FreeResource();
      66             : 
      67             :     try
      68             :     {
      69           0 :         css::uno::Reference< XConfigManager > xCfgMgr( rxMSF->createInstance(OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.config.SpecialConfigManager" ))), UNO_QUERY );
      70           0 :         if( xCfgMgr.is() )
      71           0 :             sInstPath = xCfgMgr->substituteVariables( sInstPath );
      72             :     }
      73           0 :     catch(const Exception&)
      74             :     {
      75             :         OSL_FAIL( "XMLFilterTabPageXSLT::XMLFilterTabPageXSLT exception catched!" );
      76             :     }
      77             : 
      78           0 :     maPBExprotXSLT.SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      79           0 :     maPBImportXSLT.SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      80           0 :     maPBImportTemplate.SetClickHdl( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
      81             : 
      82           0 :     maEDExportXSLT.SetHelpId( HID_XML_FILTER_EXPORT_XSLT );
      83           0 :     maEDImportXSLT.SetHelpId( HID_XML_FILTER_IMPORT_XSLT );
      84           0 :     maEDImportTemplate.SetHelpId( HID_XML_FILTER_IMPORT_TEMPLATE );
      85           0 :     maCBNeedsXSLT2.SetHelpId( HID_XML_FILTER_NEEDS_XSLT2 );
      86           0 : }
      87             : 
      88           0 : XMLFilterTabPageXSLT::~XMLFilterTabPageXSLT()
      89             : {
      90           0 : }
      91             : 
      92           0 : bool XMLFilterTabPageXSLT::FillInfo( filter_info_impl* pInfo )
      93             : {
      94           0 :     if( pInfo )
      95             :     {
      96           0 :         pInfo->maDocType = maEDDocType.GetText();
      97           0 :         pInfo->maExportXSLT = GetURL( maEDExportXSLT );
      98           0 :         pInfo->maImportXSLT = GetURL( maEDImportXSLT );
      99           0 :         pInfo->maImportTemplate = GetURL( maEDImportTemplate );
     100           0 :         pInfo->mbNeedsXSLT2 = maCBNeedsXSLT2.IsChecked();
     101             :     }
     102             : 
     103           0 :     return true;
     104             : }
     105             : 
     106           0 : void XMLFilterTabPageXSLT::SetInfo(const filter_info_impl* pInfo)
     107             : {
     108           0 :     if( pInfo )
     109             :     {
     110           0 :         maEDDocType.SetText( pInfo->maDocType );
     111             : 
     112           0 :         SetURL( maEDExportXSLT, pInfo->maExportXSLT );
     113           0 :         SetURL( maEDImportXSLT, pInfo->maImportXSLT );
     114           0 :         SetURL( maEDImportTemplate, pInfo->maImportTemplate );
     115           0 :         maCBNeedsXSLT2.Check( pInfo->mbNeedsXSLT2 );
     116             :     }
     117           0 : }
     118             : 
     119           0 : void XMLFilterTabPageXSLT::SetURL( SvtURLBox& rURLBox, const OUString& rURL )
     120             : {
     121           0 :     OUString aPath;
     122             : 
     123           0 :     if( rURL.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "file://" ) ) ) )
     124             :     {
     125           0 :         osl::FileBase::getSystemPathFromFileURL( rURL, aPath );
     126             : 
     127           0 :         rURLBox.SetBaseURL( rURL );
     128           0 :         rURLBox.SetText( aPath );
     129             :     }
     130           0 :     else if( rURL.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ) ) ||
     131           0 :              rURL.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ) ) ||
     132           0 :              rURL.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "ftp://" ) ) ) )
     133             :     {
     134           0 :         rURLBox.SetBaseURL( rURL );
     135           0 :         rURLBox.SetText( rURL );
     136             :     }
     137           0 :     else if( !rURL.isEmpty() )
     138             :     {
     139           0 :         rtl::OUString aURL( rURL );
     140           0 :         aURL = URIHelper::SmartRel2Abs( sInstPath, aURL, Link(), false );
     141           0 :         osl::FileBase::getSystemPathFromFileURL( aURL, aPath );
     142             : 
     143           0 :         rURLBox.SetBaseURL( aURL );
     144           0 :         rURLBox.SetText( aPath );
     145             :     }
     146             :     else
     147             :     {
     148           0 :         rURLBox.SetBaseURL( sInstPath );
     149           0 :         String aEmpty;
     150           0 :         rURLBox.SetText( aEmpty );
     151           0 :     }
     152           0 : }
     153             : 
     154           0 : OUString XMLFilterTabPageXSLT::GetURL( SvtURLBox& rURLBox )
     155             : {
     156           0 :     OUString aURL;
     157           0 :     OUString aStrPath ( rURLBox.GetText() );
     158           0 :     if( aStrPath.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "http://" ) ) ) ||
     159           0 :         aStrPath.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "shttp://" ) ) ) ||
     160           0 :         aStrPath.matchIgnoreAsciiCase( OUString( RTL_CONSTASCII_USTRINGPARAM( "ftp://" ) ) ) )
     161             :     {
     162           0 :         return aStrPath;
     163             :     }
     164             :     else
     165             :     {
     166           0 :         const String aBaseURL ( rURLBox.GetBaseURL() );
     167           0 :         osl::FileBase::getFileURLFromSystemPath( aStrPath, aURL );
     168             :     }
     169             : 
     170           0 :     return aURL;
     171             : }
     172             : 
     173           0 : IMPL_LINK ( XMLFilterTabPageXSLT, ClickBrowseHdl_Impl, PushButton *, pButton )
     174             : {
     175             :     SvtURLBox* pURLBox;
     176             : 
     177           0 :     if( pButton == &maPBExprotXSLT )
     178             :     {
     179           0 :         pURLBox = &maEDExportXSLT;
     180             :     }
     181           0 :     else if( pButton == &maPBImportXSLT )
     182             :     {
     183           0 :         pURLBox = &maEDImportXSLT;
     184             :     }
     185             :     else
     186             :     {
     187           0 :         pURLBox = &maEDImportTemplate;
     188             :     }
     189             : 
     190             :     // Open Fileopen-Dialog
     191             :        ::sfx2::FileDialogHelper aDlg(
     192           0 :         com::sun::star::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
     193             : 
     194           0 :     aDlg.SetDisplayDirectory( GetURL( *pURLBox ) );
     195             : 
     196           0 :     if ( aDlg.Execute() == ERRCODE_NONE )
     197             :     {
     198           0 :         OUString aURL( aDlg.GetPath() );
     199             : 
     200           0 :         SetURL( *pURLBox, aURL );
     201             :     }
     202             : 
     203           0 :     return( 0L );
     204           0 : }
     205             : 
     206             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10