Line data Source code
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 :
22 : #include "xmlfilterdialogstrings.hrc"
23 : #include "xmlfiltertabpagebasic.hxx"
24 : #include "xmlfiltersettingsdialog.hxx"
25 :
26 0 : XMLFilterTabPageBasic::XMLFilterTabPageBasic(Window* pParent)
27 0 : : TabPage(pParent, "XmlFilterTabPageGeneral", "filter/ui/xmlfiltertabpagegeneral.ui")
28 : {
29 0 : get(m_pEDFilterName, "filtername");
30 0 : get(m_pCBApplication, "application");
31 0 : get(m_pEDInterfaceName,"interfacename");
32 0 : get(m_pEDExtension, "extension");
33 0 : get(m_pEDDescription, "description");
34 0 : m_pEDDescription->set_height_request(m_pEDDescription->GetTextHeight() * 4);
35 :
36 0 : std::vector< application_info_impl* >& rInfos = getApplicationInfos();
37 0 : std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
38 0 : while( aIter != rInfos.end() )
39 : {
40 0 : OUString aEntry( (*aIter++)->maDocumentUIName );
41 0 : m_pCBApplication->InsertEntry( aEntry );
42 0 : }
43 0 : }
44 :
45 0 : XMLFilterTabPageBasic::~XMLFilterTabPageBasic()
46 : {
47 0 : }
48 0 : static OUString checkExtensions( const OUString& rExtensions )
49 : {
50 0 : const sal_Unicode* pSource = rExtensions.getStr();
51 0 : sal_Int32 nCount = rExtensions.getLength();
52 :
53 0 : OUString aRet;
54 0 : while( nCount-- )
55 : {
56 0 : switch(*pSource)
57 : {
58 : case sal_Unicode(','):
59 0 : aRet += ";";
60 0 : break;
61 : case sal_Unicode('.'):
62 : case sal_Unicode('*'):
63 0 : break;
64 : default:
65 0 : aRet += OUString( *pSource );
66 : }
67 :
68 0 : pSource++;
69 : }
70 :
71 0 : return aRet;
72 : }
73 :
74 0 : bool XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo )
75 : {
76 0 : if( pInfo )
77 : {
78 0 : if( !m_pEDFilterName->GetText().isEmpty() )
79 0 : pInfo->maFilterName = m_pEDFilterName->GetText();
80 :
81 0 : if( !m_pCBApplication->GetText().isEmpty() )
82 0 : pInfo->maDocumentService = m_pCBApplication->GetText();
83 :
84 0 : if( !m_pEDInterfaceName->GetText().isEmpty() )
85 0 : pInfo->maInterfaceName = m_pEDInterfaceName->GetText();
86 :
87 0 : if( !m_pEDExtension->GetText().isEmpty() )
88 0 : pInfo->maExtension = checkExtensions( m_pEDExtension->GetText() );
89 :
90 0 : pInfo->maComment = string_encode( m_pEDDescription->GetText() );
91 :
92 0 : if( !pInfo->maDocumentService.isEmpty() )
93 : {
94 0 : std::vector< application_info_impl* >& rInfos = getApplicationInfos();
95 0 : std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
96 0 : while( aIter != rInfos.end() )
97 : {
98 0 : if( pInfo->maDocumentService == (*aIter)->maDocumentUIName )
99 : {
100 0 : pInfo->maDocumentService = (*aIter)->maDocumentService;
101 0 : pInfo->maExportService = (*aIter)->maXMLExporter;
102 0 : pInfo->maImportService = (*aIter)->maXMLImporter;
103 0 : break;
104 : }
105 0 : ++aIter;
106 : }
107 : }
108 : }
109 :
110 0 : return true;
111 : }
112 :
113 0 : void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo)
114 : {
115 0 : if( pInfo )
116 : {
117 0 : m_pEDFilterName->SetText( string_decode(pInfo->maFilterName) );
118 : /*
119 : if( pInfo->maDocumentService.getLength() )
120 : maCBApplication.SetText( getApplicationUIName( pInfo->maDocumentService ) );
121 : */
122 0 : if( !pInfo->maExportService.isEmpty() )
123 0 : m_pCBApplication->SetText( getApplicationUIName( pInfo->maExportService ) );
124 : else
125 0 : m_pCBApplication->SetText( getApplicationUIName( pInfo->maImportService ) );
126 0 : m_pEDInterfaceName->SetText( string_decode(pInfo->maInterfaceName) );
127 0 : m_pEDExtension->SetText( pInfo->maExtension );
128 0 : m_pEDDescription->SetText( string_decode( pInfo->maComment ) );
129 : }
130 3 : }
131 :
132 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|