1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <rtl/ustrbuf.hxx>
21 #include <vcl/svapp.hxx>
22 #include "xmlfiltercommon.hxx"
23 #include "xmlfiltertabpagebasic.hxx"
25 XMLFilterTabPageBasic::XMLFilterTabPageBasic(weld::Widget
* pPage
)
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"))
34 m_xEDDescription
->set_size_request(-1, m_xEDDescription
->get_height_rows(4));
36 std::vector
< application_info_impl
> const & rInfos
= getApplicationInfos();
37 for (auto const& info
: rInfos
)
39 OUString
aEntry( info
.maDocumentUIName
);
40 m_xCBApplication
->append_text( aEntry
);
44 XMLFilterTabPageBasic::~XMLFilterTabPageBasic()
48 static OUString
checkExtensions( const OUString
& rExtensions
)
50 const sal_Unicode
* pSource
= rExtensions
.getStr();
51 sal_Int32 nCount
= rExtensions
.getLength();
65 aRet
.append( *pSource
);
71 return aRet
.makeStringAndClear();
74 void XMLFilterTabPageBasic::FillInfo( filter_info_impl
* pInfo
)
79 if( !m_xEDFilterName
->get_text().isEmpty() )
80 pInfo
->maFilterName
= m_xEDFilterName
->get_text();
82 if( !m_xCBApplication
->get_active_text().isEmpty() )
83 pInfo
->maDocumentService
= m_xCBApplication
->get_active_text();
85 if( !m_xEDInterfaceName
->get_text().isEmpty() )
86 pInfo
->maInterfaceName
= m_xEDInterfaceName
->get_text();
88 if( !m_xEDExtension
->get_text().isEmpty() )
89 pInfo
->maExtension
= checkExtensions( m_xEDExtension
->get_text() );
91 pInfo
->maComment
= string_encode( m_xEDDescription
->get_text() );
93 if( pInfo
->maDocumentService
.isEmpty() )
96 std::vector
< application_info_impl
> const & rInfos
= getApplicationInfos();
97 for (auto const& info
: rInfos
)
99 if( pInfo
->maDocumentService
== info
.maDocumentUIName
)
101 pInfo
->maDocumentService
= info
.maDocumentService
;
102 pInfo
->maExportService
= info
.maXMLExporter
;
103 pInfo
->maImportService
= info
.maXMLImporter
;
109 void XMLFilterTabPageBasic::SetInfo(const filter_info_impl
* pInfo
)
114 m_xEDFilterName
->set_text( string_decode(pInfo
->maFilterName
) );
116 if( pInfo->maDocumentService.getLength() )
117 maCBApplication.set_text( getApplicationUIName( pInfo->maDocumentService ) );
119 if( !pInfo
->maExportService
.isEmpty() )
120 m_xCBApplication
->set_entry_text( getApplicationUIName( pInfo
->maExportService
) );
122 m_xCBApplication
->set_entry_text( getApplicationUIName( pInfo
->maImportService
) );
123 m_xEDInterfaceName
->set_text( string_decode(pInfo
->maInterfaceName
) );
124 m_xEDExtension
->set_text( pInfo
->maExtension
);
125 m_xEDDescription
->set_text( string_decode( pInfo
->maComment
) );
128 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */