android: Update app-specific/MIME type icons
[LibreOffice.git] / filter / source / xsltdialog / xmlfiltertabpagebasic.cxx
blob63b969a2fa808bc51d804c74e9827b3df10a1e53
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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();
53 OUStringBuffer aRet;
54 while( nCount-- )
56 switch(*pSource)
58 case u',':
59 aRet.append(";");
60 break;
61 case u'.':
62 case u'*':
63 break;
64 default:
65 aRet.append( *pSource );
68 pSource++;
71 return aRet.makeStringAndClear();
74 void XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo )
76 if( !pInfo )
77 return;
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() )
94 return;
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;
104 break;
109 void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo)
111 if( !pInfo )
112 return;
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 ) );
121 else
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: */