1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_filter.hxx"
26 #include <rtl/ustrbuf.hxx>
27
28 #include "xmlfilterdialogstrings.hrc"
29 #include "xmlfiltertabpagebasic.hxx"
30 #include "xmlfiltertabpagebasic.hrc"
31 #include "xmlfiltersettingsdialog.hxx"
32 #include "xmlfilterhelpids.hrc"
33
34 using namespace rtl;
35
XMLFilterTabPageBasic(Window * pParent,ResMgr & rResMgr)36 XMLFilterTabPageBasic::XMLFilterTabPageBasic( Window* pParent, ResMgr& rResMgr ) :
37 TabPage( pParent, ResId( RID_XML_FILTER_TABPAGE_BASIC, rResMgr ) ),
38 maFTFilterName( this, ResId( FT_XML_FILTER_NAME, rResMgr ) ),
39 maEDFilterName( this, ResId( ED_XML_FILTER_NAME, rResMgr ) ),
40 maFTApplication( this, ResId( FT_XML_APPLICATION, rResMgr ) ),
41 maCBApplication( this, ResId( CB_XML_APPLICATION, rResMgr ) ),
42 maFTInterfaceName( this, ResId( FT_XML_INTERFACE_NAME, rResMgr ) ),
43 maEDInterfaceName( this, ResId( ED_XML_INTERFACE_NAME, rResMgr ) ),
44 maFTExtension( this, ResId( FT_XML_EXTENSION, rResMgr ) ),
45 maEDExtension( this, ResId( ED_XML_EXTENSION, rResMgr ) ),
46 maFTDescription( this, ResId( FT_XML_DESCRIPTION, rResMgr ) ),
47 maEDDescription( this, ResId( ED_XML_DESCRIPTION, rResMgr ) )
48 {
49 maCBApplication.SetHelpId( HID_XML_FILTER_APPLICATION );
50 maEDDescription.SetHelpId( HID_XML_FILTER_DESCRIPTION );
51
52 FreeResource();
53
54 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
55 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
56 while( aIter != rInfos.end() )
57 {
58 XubString aEntry( (*aIter++)->maDocumentUIName );
59 maCBApplication.InsertEntry( aEntry );
60 }
61 }
62
~XMLFilterTabPageBasic()63 XMLFilterTabPageBasic::~XMLFilterTabPageBasic()
64 {
65 }
66
checkExtensions(const String & rExtensions)67 static OUString checkExtensions( const String& rExtensions )
68 {
69 const sal_Unicode* pSource = rExtensions.GetBuffer();
70 sal_Int32 nCount = rExtensions.Len();
71
72 String aRet;
73 while( nCount-- )
74 {
75 switch(*pSource)
76 {
77 case sal_Unicode(','):
78 aRet += sal_Unicode(';');
79 break;
80 case sal_Unicode('.'):
81 case sal_Unicode('*'):
82 break;
83 default:
84 aRet += *pSource;
85 }
86
87 pSource++;
88 }
89
90 return aRet;
91 }
92
FillInfo(filter_info_impl * pInfo)93 bool XMLFilterTabPageBasic::FillInfo( filter_info_impl* pInfo )
94 {
95 if( pInfo )
96 {
97 if( maEDFilterName.GetText().Len() )
98 pInfo->maFilterName = maEDFilterName.GetText();
99
100 if( maCBApplication.GetText().Len() )
101 pInfo->maDocumentService = maCBApplication.GetText();
102
103 if( maEDInterfaceName.GetText().Len() )
104 pInfo->maInterfaceName = maEDInterfaceName.GetText();
105
106 if( maEDExtension.GetText().Len() )
107 pInfo->maExtension = checkExtensions( maEDExtension.GetText() );
108
109 pInfo->maComment = string_encode( maEDDescription.GetText() );
110
111 if( pInfo->maDocumentService.getLength() )
112 {
113 std::vector< application_info_impl* >& rInfos = getApplicationInfos();
114 std::vector< application_info_impl* >::iterator aIter( rInfos.begin() );
115 while( aIter != rInfos.end() )
116 {
117 if( pInfo->maDocumentService == (*aIter)->maDocumentUIName )
118 {
119 pInfo->maDocumentService = (*aIter)->maDocumentService;
120 pInfo->maExportService = (*aIter)->maXMLExporter;
121 pInfo->maImportService = (*aIter)->maXMLImporter;
122 break;
123 }
124 aIter++;
125 }
126 }
127 }
128
129 return true;
130 }
131
SetInfo(const filter_info_impl * pInfo)132 void XMLFilterTabPageBasic::SetInfo(const filter_info_impl* pInfo)
133 {
134 if( pInfo )
135 {
136 maEDFilterName.SetText( string_decode(pInfo->maFilterName) );
137 /*
138 if( pInfo->maDocumentService.getLength() )
139 maCBApplication.SetText( getApplicationUIName( pInfo->maDocumentService ) );
140 */
141 if( pInfo->maExportService.getLength() )
142 maCBApplication.SetText( getApplicationUIName( pInfo->maExportService ) );
143 else
144 maCBApplication.SetText( getApplicationUIName( pInfo->maImportService ) );
145 maEDInterfaceName.SetText( string_decode(pInfo->maInterfaceName) );
146 maEDExtension.SetText( pInfo->maExtension );
147 maEDDescription.SetText( string_decode( pInfo->maComment ) );
148 }
149 }
150