bump product version to 4.1.6.2
[LibreOffice.git] / filter / source / xsltdialog / xmlfiltertabpagebasic.cxx
blob1848a2f380663f32d4d833e156dfc2bd2b9e6b2b
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 "xmlfiltertabpagebasic.hrc"
25 #include "xmlfiltersettingsdialog.hxx"
26 #include "xmlfilterhelpids.hrc"
28 XMLFilterTabPageBasic::XMLFilterTabPageBasic( Window* pParent, ResMgr& rResMgr ) :
29 TabPage( pParent, ResId( RID_XML_FILTER_TABPAGE_BASIC, rResMgr ) ),
30 maFTFilterName( this, ResId( FT_XML_FILTER_NAME, rResMgr ) ),
31 maEDFilterName( this, ResId( ED_XML_FILTER_NAME, rResMgr ) ),
32 maFTApplication( this, ResId( FT_XML_APPLICATION, rResMgr ) ),
33 maCBApplication( this, ResId( CB_XML_APPLICATION, rResMgr ) ),
34 maFTInterfaceName( this, ResId( FT_XML_INTERFACE_NAME, rResMgr ) ),
35 maEDInterfaceName( this, ResId( ED_XML_INTERFACE_NAME, rResMgr ) ),
36 maFTExtension( this, ResId( FT_XML_EXTENSION, rResMgr ) ),
37 maEDExtension( this, ResId( ED_XML_EXTENSION, rResMgr ) ),
38 maFTDescription( this, ResId( FT_XML_DESCRIPTION, rResMgr ) ),
39 maEDDescription( this, ResId( ED_XML_DESCRIPTION, rResMgr ) )
41 maCBApplication.SetHelpId( HID_XML_FILTER_APPLICATION );
42 maEDDescription.SetHelpId( HID_XML_FILTER_DESCRIPTION );
44 FreeResource();
46 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
47 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
48 while( aIter != rInfos.end() )
50 OUString aEntry( (*aIter++)->maDocumentUIName );
51 maCBApplication.InsertEntry( aEntry );
55 XMLFilterTabPageBasic::~XMLFilterTabPageBasic()
59 static OUString checkExtensions( const OUString& rExtensions )
61 const sal_Unicode* pSource = rExtensions.getStr();
62 sal_Int32 nCount = rExtensions.getLength();
64 OUString aRet;
65 while( nCount-- )
67 switch(*pSource)
69 case sal_Unicode(','):
70 aRet += ";";
71 break;
72 case sal_Unicode('.'):
73 case sal_Unicode('*'):
74 break;
75 default:
76 aRet += OUString( *pSource );
79 pSource++;
82 return aRet;
85 bool XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo )
87 if( pInfo )
89 if( !maEDFilterName.GetText().isEmpty() )
90 pInfo->maFilterName = maEDFilterName.GetText();
92 if( !maCBApplication.GetText().isEmpty() )
93 pInfo->maDocumentService = maCBApplication.GetText();
95 if( !maEDInterfaceName.GetText().isEmpty() )
96 pInfo->maInterfaceName = maEDInterfaceName.GetText();
98 if( !maEDExtension.GetText().isEmpty() )
99 pInfo->maExtension = checkExtensions( maEDExtension.GetText() );
101 pInfo->maComment = string_encode( maEDDescription.GetText() );
103 if( !pInfo->maDocumentService.isEmpty() )
105 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
106 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
107 while( aIter != rInfos.end() )
109 if( pInfo->maDocumentService == (*aIter)->maDocumentUIName )
111 pInfo->maDocumentService = (*aIter)->maDocumentService;
112 pInfo->maExportService = (*aIter)->maXMLExporter;
113 pInfo->maImportService = (*aIter)->maXMLImporter;
114 break;
116 ++aIter;
121 return true;
124 void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo)
126 if( pInfo )
128 maEDFilterName.SetText( string_decode(pInfo->maFilterName) );
130 if( pInfo->maDocumentService.getLength() )
131 maCBApplication.SetText( getApplicationUIName( pInfo->maDocumentService ) );
133 if( !pInfo->maExportService.isEmpty() )
134 maCBApplication.SetText( getApplicationUIName( pInfo->maExportService ) );
135 else
136 maCBApplication.SetText( getApplicationUIName( pInfo->maImportService ) );
137 maEDInterfaceName.SetText( string_decode(pInfo->maInterfaceName) );
138 maEDExtension.SetText( pInfo->maExtension );
139 maEDDescription.SetText( string_decode( pInfo->maComment ) );
143 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */