LibreOffice Module filter (master) 1
xmlfiltertabpagebasic.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 <rtl/ustrbuf.hxx>
21#include <vcl/svapp.hxx>
22#include "xmlfiltercommon.hxx"
24
26 : m_xBuilder(Application::CreateBuilder(pPage, "filter/ui/xmlfiltertabpagegeneral.ui"))
27 , m_xContainer(m_xBuilder->weld_widget("XmlFilterTabPageGeneral"))
28 , m_xEDFilterName(m_xBuilder->weld_entry("filtername"))
29 , m_xCBApplication(m_xBuilder->weld_combo_box("application"))
30 , m_xEDInterfaceName(m_xBuilder->weld_entry("interfacename"))
31 , m_xEDExtension(m_xBuilder->weld_entry("extension"))
32 , m_xEDDescription(m_xBuilder->weld_text_view("description"))
33{
34 m_xEDDescription->set_size_request(-1, m_xEDDescription->get_height_rows(4));
35
36 std::vector< application_info_impl > const & rInfos = getApplicationInfos();
37 for (auto const& info : rInfos)
38 {
39 OUString aEntry( info.maDocumentUIName );
40 m_xCBApplication->append_text( aEntry );
41 }
42}
43
45{
46}
47
48static OUString checkExtensions( const OUString& rExtensions )
49{
50 const sal_Unicode* pSource = rExtensions.getStr();
51 sal_Int32 nCount = rExtensions.getLength();
52
53 OUStringBuffer aRet;
54 while( nCount-- )
55 {
56 switch(*pSource)
57 {
58 case u',':
59 aRet.append(";");
60 break;
61 case u'.':
62 case u'*':
63 break;
64 default:
65 aRet.append( *pSource );
66 }
67
68 pSource++;
69 }
70
71 return aRet.makeStringAndClear();
72}
73
75{
76 if( !pInfo )
77 return;
78
79 if( !m_xEDFilterName->get_text().isEmpty() )
80 pInfo->maFilterName = m_xEDFilterName->get_text();
81
82 if( !m_xCBApplication->get_active_text().isEmpty() )
83 pInfo->maDocumentService = m_xCBApplication->get_active_text();
84
85 if( !m_xEDInterfaceName->get_text().isEmpty() )
86 pInfo->maInterfaceName = m_xEDInterfaceName->get_text();
87
88 if( !m_xEDExtension->get_text().isEmpty() )
89 pInfo->maExtension = checkExtensions( m_xEDExtension->get_text() );
90
91 pInfo->maComment = string_encode( m_xEDDescription->get_text() );
92
93 if( pInfo->maDocumentService.isEmpty() )
94 return;
95
96 std::vector< application_info_impl > const & rInfos = getApplicationInfos();
97 for (auto const& info : rInfos)
98 {
99 if( pInfo->maDocumentService == info.maDocumentUIName )
100 {
101 pInfo->maDocumentService = info.maDocumentService;
102 pInfo->maExportService = info.maXMLExporter;
103 pInfo->maImportService = info.maXMLImporter;
104 break;
105 }
106 }
107}
108
110{
111 if( !pInfo )
112 return;
113
114 m_xEDFilterName->set_text( string_decode(pInfo->maFilterName) );
115 /*
116 if( pInfo->maDocumentService.getLength() )
117 maCBApplication.set_text( getApplicationUIName( pInfo->maDocumentService ) );
118 */
119 if( !pInfo->maExportService.isEmpty() )
120 m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maExportService ) );
121 else
122 m_xCBApplication->set_entry_text( getApplicationUIName( pInfo->maImportService ) );
124 m_xEDExtension->set_text( pInfo->maExtension );
125 m_xEDDescription->set_text( string_decode( pInfo->maComment ) );
126}
127
128/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void FillInfo(filter_info_impl *pInfo)
std::unique_ptr< weld::TextView > m_xEDDescription
XMLFilterTabPageBasic(weld::Widget *pPage)
void SetInfo(const filter_info_impl *pInfo)
std::unique_ptr< weld::Entry > m_xEDInterfaceName
std::unique_ptr< weld::Entry > m_xEDExtension
std::unique_ptr< weld::Entry > m_xEDFilterName
std::unique_ptr< weld::ComboBox > m_xCBApplication
OUString maDocumentService
int nCount
float u
Reference< XNameAccess > m_xContainer
sal_uInt16 sal_Unicode
OUString string_encode(const OUString &rText)
std::vector< application_info_impl > const & getApplicationInfos()
OUString getApplicationUIName(std::u16string_view rServiceName)
OUString string_decode(const OUString &rText)
static OUString checkExtensions(const OUString &rExtensions)