Bump version to 5.0-14
[LibreOffice.git] / filter / source / xsltdialog / xmlfiltertabpagebasic.cxx
blob3f4d285a71a390789e2045bb1c3034c2cea545ef
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>
22 #include "xmlfilterdialogstrings.hrc"
23 #include "xmlfiltertabpagebasic.hxx"
24 #include "xmlfiltersettingsdialog.hxx"
26 XMLFilterTabPageBasic::XMLFilterTabPageBasic(vcl::Window* pParent)
27 : TabPage(pParent, "XmlFilterTabPageGeneral", "filter/ui/xmlfiltertabpagegeneral.ui")
29 get(m_pEDFilterName, "filtername");
30 get(m_pCBApplication, "application");
31 get(m_pEDInterfaceName,"interfacename");
32 get(m_pEDExtension, "extension");
33 get(m_pEDDescription, "description");
34 m_pEDDescription->set_height_request(m_pEDDescription->GetTextHeight() * 4);
36 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
37 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
38 while( aIter != rInfos.end() )
40 OUString aEntry( (*aIter++)->maDocumentUIName );
41 m_pCBApplication->InsertEntry( aEntry );
45 XMLFilterTabPageBasic::~XMLFilterTabPageBasic()
47 disposeOnce();
50 void XMLFilterTabPageBasic::dispose()
52 m_pEDFilterName.clear();
53 m_pCBApplication.clear();
54 m_pEDInterfaceName.clear();
55 m_pEDExtension.clear();
56 m_pEDDescription.clear();
57 TabPage::dispose();
60 static OUString checkExtensions( const OUString& rExtensions )
62 const sal_Unicode* pSource = rExtensions.getStr();
63 sal_Int32 nCount = rExtensions.getLength();
65 OUString aRet;
66 while( nCount-- )
68 switch(*pSource)
70 case sal_Unicode(','):
71 aRet += ";";
72 break;
73 case sal_Unicode('.'):
74 case sal_Unicode('*'):
75 break;
76 default:
77 aRet += OUString( *pSource );
80 pSource++;
83 return aRet;
86 bool XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo )
88 if( pInfo )
90 if( !m_pEDFilterName->GetText().isEmpty() )
91 pInfo->maFilterName = m_pEDFilterName->GetText();
93 if( !m_pCBApplication->GetText().isEmpty() )
94 pInfo->maDocumentService = m_pCBApplication->GetText();
96 if( !m_pEDInterfaceName->GetText().isEmpty() )
97 pInfo->maInterfaceName = m_pEDInterfaceName->GetText();
99 if( !m_pEDExtension->GetText().isEmpty() )
100 pInfo->maExtension = checkExtensions( m_pEDExtension->GetText() );
102 pInfo->maComment = string_encode( m_pEDDescription->GetText() );
104 if( !pInfo->maDocumentService.isEmpty() )
106 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
107 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
108 while( aIter != rInfos.end() )
110 if( pInfo->maDocumentService == (*aIter)->maDocumentUIName )
112 pInfo->maDocumentService = (*aIter)->maDocumentService;
113 pInfo->maExportService = (*aIter)->maXMLExporter;
114 pInfo->maImportService = (*aIter)->maXMLImporter;
115 break;
117 ++aIter;
122 return true;
125 void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo)
127 if( pInfo )
129 m_pEDFilterName->SetText( string_decode(pInfo->maFilterName) );
131 if( pInfo->maDocumentService.getLength() )
132 maCBApplication.SetText( getApplicationUIName( pInfo->maDocumentService ) );
134 if( !pInfo->maExportService.isEmpty() )
135 m_pCBApplication->SetText( getApplicationUIName( pInfo->maExportService ) );
136 else
137 m_pCBApplication->SetText( getApplicationUIName( pInfo->maImportService ) );
138 m_pEDInterfaceName->SetText( string_decode(pInfo->maInterfaceName) );
139 m_pEDExtension->SetText( pInfo->maExtension );
140 m_pEDDescription->SetText( string_decode( pInfo->maComment ) );
144 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */