LibreOffice Module filter (master) 1
xmlfiltertabpagexslt.cxx
Go to the documentation of this file.
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/ui/dialogs/TemplateDescription.hpp>
23#include <osl/file.hxx>
24#include <svl/urihelper.hxx>
25#include <vcl/svapp.hxx>
26
27#include "xmlfiltercommon.hxx"
29
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::lang;
32
34 : sInstPath( "$(prog)/" )
35 , m_pDialog(pDialog)
36 , m_xBuilder(Application::CreateBuilder(pPage, "filter/ui/xmlfiltertabpagetransformation.ui"))
37 , m_xContainer(m_xBuilder->weld_widget("XmlFilterTabPageTransformation"))
38 , m_xEDDocType(m_xBuilder->weld_entry("doc"))
39 , m_xEDExportXSLT(new SvtURLBox(m_xBuilder->weld_combo_box("xsltexport")))
40 , m_xPBExprotXSLT(m_xBuilder->weld_button("browseexport"))
41 , m_xEDImportXSLT(new SvtURLBox(m_xBuilder->weld_combo_box("xsltimport")))
42 , m_xPBImportXSLT(m_xBuilder->weld_button("browseimport"))
43 , m_xEDImportTemplate(new SvtURLBox(m_xBuilder->weld_combo_box("tempimport")))
44 , m_xPBImportTemplate(m_xBuilder->weld_button("browsetemp"))
45 , m_xCBNeedsXSLT2(m_xBuilder->weld_check_button("filtercb"))
46{
47 SvtPathOptions aOptions;
49
50 m_xPBExprotXSLT->connect_clicked( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
51 m_xPBImportXSLT->connect_clicked( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
52 m_xPBImportTemplate->connect_clicked( LINK ( this, XMLFilterTabPageXSLT, ClickBrowseHdl_Impl ) );
53}
54
56{
57}
58
60{
61 if( pInfo )
62 {
63 pInfo->maDocType = m_xEDDocType->get_text();
67 pInfo->mbNeedsXSLT2 = m_xCBNeedsXSLT2->get_active();
68 }
69}
70
72{
73 if( pInfo )
74 {
75 m_xEDDocType->set_text( pInfo->maDocType );
76
80 m_xCBNeedsXSLT2->set_active(pInfo->mbNeedsXSLT2);
81 }
82}
83
84void XMLFilterTabPageXSLT::SetURL( SvtURLBox& rURLBox, const OUString& rURL )
85{
86 OUString aPath;
87
88 if( rURL.matchIgnoreAsciiCase( "file://" ) )
89 {
90 osl::FileBase::getSystemPathFromFileURL( rURL, aPath );
91
92 rURLBox.SetBaseURL( rURL );
93 rURLBox.set_entry_text( aPath );
94 }
95 else if( rURL.matchIgnoreAsciiCase( "http://" ) ||
96 rURL.matchIgnoreAsciiCase( "https://" ) ||
97 rURL.matchIgnoreAsciiCase( "ftp://" ) )
98 {
99 rURLBox.SetBaseURL( rURL );
100 rURLBox.set_entry_text( rURL );
101 }
102 else if( !rURL.isEmpty() )
103 {
105 osl::FileBase::getSystemPathFromFileURL( aURL, aPath );
106
107 rURLBox.SetBaseURL( aURL );
108 rURLBox.set_entry_text( aPath );
109 }
110 else
111 {
112 rURLBox.SetBaseURL( sInstPath );
113 rURLBox.set_entry_text( "" );
114 }
115}
116
118{
119 OUString aURL;
120 OUString aStrPath(rURLBox.get_active_text());
121 if( aStrPath.matchIgnoreAsciiCase( "http://" ) ||
122 aStrPath.matchIgnoreAsciiCase( "https://" ) ||
123 aStrPath.matchIgnoreAsciiCase( "ftp://" ) )
124 {
125 return aStrPath;
126 }
127 else
128 {
129 osl::FileBase::getFileURLFromSystemPath( aStrPath, aURL );
130 }
131
132 return aURL;
133}
134
135IMPL_LINK ( XMLFilterTabPageXSLT, ClickBrowseHdl_Impl, weld::Button&, rButton, void )
136{
137 SvtURLBox* pURLBox;
138
139 if( &rButton == m_xPBExprotXSLT.get() )
140 {
141 pURLBox = m_xEDExportXSLT.get();
142 }
143 else if( &rButton == m_xPBImportXSLT.get() )
144 {
145 pURLBox = m_xEDImportXSLT.get();
146 }
147 else
148 {
149 pURLBox = m_xEDImportTemplate.get();
150 }
151
152 // Open Fileopen-Dialog
153 ::sfx2::FileDialogHelper aDlg(css::ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
154 FileDialogFlags::NONE, m_pDialog);
155
156 aDlg.SetDisplayDirectory(GetURL(*pURLBox));
157
158 if (aDlg.Execute() == ERRCODE_NONE)
159 {
160 OUString aURL(aDlg.GetPath());
161 SetURL(*pURLBox, aURL);
162 }
163}
164
165/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString SubstituteVariable(const OUString &rVar) const
void set_entry_text(const OUString &rStr)
void SetBaseURL(const OUString &rURL)
OUString get_active_text() const
std::unique_ptr< weld::CheckButton > m_xCBNeedsXSLT2
std::unique_ptr< weld::Button > m_xPBExprotXSLT
std::unique_ptr< SvtURLBox > m_xEDExportXSLT
std::unique_ptr< weld::Entry > m_xEDDocType
std::unique_ptr< SvtURLBox > m_xEDImportTemplate
void FillInfo(filter_info_impl *pInfo)
std::unique_ptr< weld::Button > m_xPBImportXSLT
std::unique_ptr< SvtURLBox > m_xEDImportXSLT
static OUString GetURL(const SvtURLBox &rURLBox)
std::unique_ptr< weld::Button > m_xPBImportTemplate
XMLFilterTabPageXSLT(weld::Widget *pPage, weld::Dialog *pDialog)
void SetInfo(const filter_info_impl *pInfo)
void SetURL(SvtURLBox &rURLBox, const OUString &rURL)
OUString GetPath() const
void SetDisplayDirectory(const OUString &rPath)
URL aURL
virtual OUString GetURL() const override
#define ERRCODE_NONE
SVL_DLLPUBLIC OUString SmartRel2Abs(INetURLObject const &rTheBaseURIRef, OUString const &rTheRelURIRef, Link< OUString *, bool > const &rMaybeFileHdl=Link< OUString *, bool >(), bool bCheckFileExists=true, bool bIgnoreFragment=false, INetURLObject::EncodeMechanism eEncodeMechanism=INetURLObject::EncodeMechanism::WasEncoded, INetURLObject::DecodeMechanism eDecodeMechanism=INetURLObject::DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8, FSysStyle eStyle=FSysStyle::Detect)
Reference< XNameAccess > m_xContainer
IMPL_LINK(XMLFilterTabPageXSLT, ClickBrowseHdl_Impl, weld::Button &, rButton, void)