LibreOffice Module sc (master) 1
scuiasciiopt.cxx
Go to the documentation of this file.
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#undef SC_DLLIMPLEMENTATION
21
22#include <svx/txencbox.hxx>
23
24#include <global.hxx>
25#include <scresid.hxx>
26#include <impex.hxx>
27#include <scuiasciiopt.hxx>
28#include <strings.hrc>
29#include <strings.hxx>
30#include <csvtablebox.hxx>
31#include <osl/thread.h>
33
34#include <optutil.hxx>
35#include <com/sun/star/uno/Any.hxx>
36#include <com/sun/star/uno/Sequence.hxx>
37#include <miscuno.hxx>
38#include <osl/diagnose.h>
39#include <vcl/svapp.hxx>
40#include <comphelper/lok.hxx>
41#include <o3tl/string_view.hxx>
42
43#include <unicode/ucsdet.h>
44
47
48// Maximum number of source lines to concatenate while generating the preview
49// for one logical line. This may result in a wrong preview if the actual
50// number of embedded line feeds is greater, but a number too high would take
51// too much time (loop excessively if unlimited and large data) if none of the
52// selected separators are actually used in data but a field at start of line
53// is quoted.
54constexpr sal_uInt32 kMaxEmbeddedLinefeeds = 500;
55
56using namespace com::sun::star::uno;
57
58namespace {
59
60// Defines - CSV Import Preserve Options
61// For usage of index order see lcl_CreatePropertiesNames() below.
62enum CSVImportOptionsIndex
63{
64 CSVIO_MergeDelimiters = 0,
65 CSVIO_Separators,
66 CSVIO_TextSeparators,
67 CSVIO_FixedWidth,
68 CSVIO_RemoveSpace,
69 CSVIO_EvaluateFormulas,
70 // Settings for *all* dialog invocations above.
71 // Settings not for SC_TEXTTOCOLUMNS below.
72 CSVIO_FromRow,
73 CSVIO_Text2ColSkipEmptyCells = CSVIO_FromRow,
74 CSVIO_CharSet,
75 CSVIO_QuotedAsText,
76 CSVIO_DetectSpecialNum,
77 CSVIO_DetectScientificNum,
78 CSVIO_Language,
79 // Plus one not for SC_IMPORTFILE.
80 CSVIO_PasteSkipEmptyCells
81};
82
83}
84
85// Config items for all three paths are defined in
86// officecfg/registry/schema/org/openoffice/Office/Calc.xcs
87// If not, options are neither loaded nor saved.
88const ::std::vector<OUString> CSVImportOptionNames =
89{
90 "MergeDelimiters",
91 "Separators",
92 "TextSeparators",
93 "FixedWidth",
94 "RemoveSpace",
95 "EvaluateFormulas",
96 "FromRow",
97 "CharSet",
98 "QuotedFieldAsText",
99 "DetectSpecialNumbers",
100 "DetectScientificNumbers",
101 "Language",
102 "SkipEmptyCells"
103};
104constexpr OUStringLiteral aSep_Path = u"Office.Calc/Dialogs/CSVImport";
105constexpr OUStringLiteral aSep_Path_Clpbrd = u"Office.Calc/Dialogs/ClipboardTextImport";
106constexpr OUStringLiteral aSep_Path_Text2Col = u"Office.Calc/Dialogs/TextToColumnsImport";
107
108namespace {
109CSVImportOptionsIndex getSkipEmptyCellsIndex( ScImportAsciiCall eCall )
110{
111 return eCall == SC_TEXTTOCOLUMNS ? CSVIO_Text2ColSkipEmptyCells : CSVIO_PasteSkipEmptyCells;
112}
113}
114
115static void lcl_FillCombo(weld::ComboBox& rCombo, std::u16string_view rList, sal_Unicode cSelect)
116{
117 OUString aStr;
118 if (!rList.empty())
119 {
120 sal_Int32 nIdx {0};
121 do
122 {
123 const OUString sEntry {o3tl::getToken(rList, 0, '\t', nIdx)};
124 rCombo.append_text(sEntry);
125 if (nIdx>0 && static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rList, 0, '\t', nIdx))) == cSelect)
126 aStr = sEntry;
127 }
128 while (nIdx>0);
129 }
130
131 if ( cSelect )
132 {
133 if (aStr.isEmpty())
134 aStr = OUString(cSelect); // Ascii
135
136 rCombo.set_entry_text(aStr);
137 }
138}
139
140static sal_Unicode lcl_CharFromCombo(const weld::ComboBox& rCombo, std::u16string_view rList)
141{
142 sal_Unicode c = 0;
143 OUString aStr = rCombo.get_active_text();
144 if ( !aStr.isEmpty() && !rList.empty() )
145 {
146 sal_Int32 nIdx {0};
147 OUString sToken {o3tl::getToken(rList, 0, '\t', nIdx)};
148 while (nIdx>0)
149 {
150 if ( ScGlobal::GetTransliteration().isEqual( aStr, sToken ) )
151 {
152 sal_Int32 nTmpIdx {nIdx};
153 c = static_cast<sal_Unicode>(o3tl::toInt32(o3tl::getToken(rList, 0, '\t', nTmpIdx)));
154 }
155 // Skip to next token at even position
156 sToken = o3tl::getToken(rList, 1, '\t', nIdx);
157 }
158 if (!c)
159 {
160 sal_Unicode cFirst = aStr[0];
161 // #i24235# first try the first character of the string directly
162 if( (aStr.getLength() == 1) || (cFirst < '0') || (cFirst > '9') )
163 c = cFirst;
164 else // keep old behaviour for compatibility (i.e. "39" -> "'")
165 c = static_cast<sal_Unicode>(aStr.toInt32()); // Ascii
166 }
167 }
168 return c;
169}
170
171static void lcl_CreatePropertiesNames ( OUString& rSepPath, Sequence<OUString>& rNames, ScImportAsciiCall eCall )
172{
173 sal_Int32 nProperties = 0;
174
175 switch(eCall)
176 {
177 case SC_IMPORTFILE:
178 rSepPath = aSep_Path;
179 nProperties = 12;
180 break;
181 case SC_PASTETEXT:
182 rSepPath = aSep_Path_Clpbrd;
183 nProperties = 13;
184 break;
185 case SC_TEXTTOCOLUMNS:
186 default:
187 rSepPath = aSep_Path_Text2Col;
188 nProperties = 7;
189 break;
190 }
191 rNames.realloc( nProperties );
192 OUString* pNames = rNames.getArray();
193 pNames[ CSVIO_MergeDelimiters ] = CSVImportOptionNames[ CSVIO_MergeDelimiters ];
194 pNames[ CSVIO_Separators ] = CSVImportOptionNames[ CSVIO_Separators ];
195 pNames[ CSVIO_TextSeparators ] = CSVImportOptionNames[ CSVIO_TextSeparators ];
196 pNames[ CSVIO_FixedWidth ] = CSVImportOptionNames[ CSVIO_FixedWidth ];
197 pNames[ CSVIO_RemoveSpace ] = CSVImportOptionNames[ CSVIO_RemoveSpace ];
198 pNames[ CSVIO_EvaluateFormulas ] = CSVImportOptionNames[ CSVIO_EvaluateFormulas ];
199 if (eCall != SC_TEXTTOCOLUMNS)
200 {
201 pNames[ CSVIO_FromRow ] = CSVImportOptionNames[ CSVIO_FromRow ];
202 pNames[ CSVIO_CharSet ] = CSVImportOptionNames[ CSVIO_CharSet ];
203 pNames[ CSVIO_QuotedAsText ] = CSVImportOptionNames[ CSVIO_QuotedAsText ];
204 pNames[ CSVIO_DetectSpecialNum ] = CSVImportOptionNames[ CSVIO_DetectSpecialNum ];
205 pNames[ CSVIO_DetectScientificNum ] = CSVImportOptionNames[ CSVIO_DetectScientificNum ];
206 pNames[ CSVIO_Language ] = CSVImportOptionNames[ CSVIO_Language ];
207 }
208 if (eCall != SC_IMPORTFILE)
209 {
210 const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
211 assert( nSkipEmptyCells < rNames.getLength());
212 pNames[ nSkipEmptyCells ] = CSVImportOptionNames[ CSVIO_PasteSkipEmptyCells ];
213 }
214}
215
216static void lcl_LoadSeparators( OUString& rFieldSeparators, OUString& rTextSeparators,
217 bool& rMergeDelimiters, bool& rQuotedAsText, bool& rDetectSpecialNum, bool& rDetectScientificNum,
218 bool& rFixedWidth, sal_Int32& rFromRow, sal_Int32& rCharSet,
219 sal_Int32& rLanguage, bool& rSkipEmptyCells, bool& rRemoveSpace,
220 bool& rEvaluateFormulas, ScImportAsciiCall eCall )
221{
222 Sequence<Any>aValues;
223 const Any *pProperties;
224 Sequence<OUString> aNames;
225 OUString aSepPath;
226 lcl_CreatePropertiesNames ( aSepPath, aNames, eCall);
227 ScLinkConfigItem aItem( aSepPath );
228 aValues = aItem.GetProperties( aNames );
229 pProperties = aValues.getConstArray();
230
231 if( pProperties[ CSVIO_MergeDelimiters ].hasValue() )
232 rMergeDelimiters = ScUnoHelpFunctions::GetBoolFromAny( pProperties[ CSVIO_MergeDelimiters ] );
233
234 if( pProperties[ CSVIO_RemoveSpace ].hasValue() )
235 rRemoveSpace = ScUnoHelpFunctions::GetBoolFromAny( pProperties[ CSVIO_RemoveSpace ] );
236
237 if( pProperties[ CSVIO_Separators ].hasValue() )
238 pProperties[ CSVIO_Separators ] >>= rFieldSeparators;
239
240 if( pProperties[ CSVIO_TextSeparators ].hasValue() )
241 pProperties[ CSVIO_TextSeparators ] >>= rTextSeparators;
242
243 if( pProperties[ CSVIO_FixedWidth ].hasValue() )
244 rFixedWidth = ScUnoHelpFunctions::GetBoolFromAny( pProperties[ CSVIO_FixedWidth ] );
245
246 if( pProperties[ CSVIO_EvaluateFormulas ].hasValue() )
247 rEvaluateFormulas = ScUnoHelpFunctions::GetBoolFromAny( pProperties[ CSVIO_EvaluateFormulas ] );
248
249 if (eCall != SC_TEXTTOCOLUMNS)
250 {
251 if( pProperties[ CSVIO_FromRow ].hasValue() )
252 pProperties[ CSVIO_FromRow ] >>= rFromRow;
253
254 if( pProperties[ CSVIO_CharSet ].hasValue() )
255 pProperties[ CSVIO_CharSet ] >>= rCharSet;
256
257 if ( pProperties[ CSVIO_QuotedAsText ].hasValue() )
258 pProperties[ CSVIO_QuotedAsText ] >>= rQuotedAsText;
259
260 if ( pProperties[ CSVIO_DetectSpecialNum ].hasValue() )
261 pProperties[ CSVIO_DetectSpecialNum ] >>= rDetectSpecialNum;
262
263 if ( pProperties[ CSVIO_DetectScientificNum ].hasValue() )
264 pProperties[ CSVIO_DetectScientificNum ] >>= rDetectScientificNum;
265
266 if ( pProperties[ CSVIO_Language ].hasValue() )
267 pProperties[ CSVIO_Language ] >>= rLanguage;
268 }
269 if (eCall != SC_IMPORTFILE)
270 {
271 const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
272 assert( nSkipEmptyCells < aValues.getLength());
273 if ( pProperties[nSkipEmptyCells].hasValue() )
274 rSkipEmptyCells = ScUnoHelpFunctions::GetBoolFromAny( pProperties[nSkipEmptyCells] );
275 }
276}
277
279 const OUString& sFieldSeparators, const OUString& sTextSeparators, bool bMergeDelimiters, bool bQuotedAsText,
280 bool bDetectSpecialNum, bool bDetectScientificNum, bool bFixedWidth, sal_Int32 nFromRow,
281 sal_Int32 nCharSet, sal_Int32 nLanguage, bool bSkipEmptyCells, bool bRemoveSpace, bool bEvaluateFormulas,
282 ScImportAsciiCall eCall )
283{
284 Sequence<Any> aValues;
285 Any *pProperties;
286 Sequence<OUString> aNames;
287 OUString aSepPath;
288 lcl_CreatePropertiesNames ( aSepPath, aNames, eCall );
289 ScLinkConfigItem aItem( aSepPath );
290 aValues = aItem.GetProperties( aNames );
291 pProperties = aValues.getArray();
292
293 pProperties[ CSVIO_MergeDelimiters ] <<= bMergeDelimiters;
294 pProperties[ CSVIO_RemoveSpace ] <<= bRemoveSpace;
295 pProperties[ CSVIO_Separators ] <<= sFieldSeparators;
296 pProperties[ CSVIO_TextSeparators ] <<= sTextSeparators;
297 pProperties[ CSVIO_FixedWidth ] <<= bFixedWidth;
298 pProperties[ CSVIO_EvaluateFormulas ] <<= bEvaluateFormulas;
299 if (eCall != SC_TEXTTOCOLUMNS)
300 {
301 pProperties[ CSVIO_FromRow ] <<= nFromRow;
302 pProperties[ CSVIO_CharSet ] <<= nCharSet;
303 pProperties[ CSVIO_QuotedAsText ] <<= bQuotedAsText;
304 pProperties[ CSVIO_DetectSpecialNum ] <<= bDetectSpecialNum;
305 pProperties[ CSVIO_DetectScientificNum ] <<= bDetectScientificNum;
306 pProperties[ CSVIO_Language ] <<= nLanguage;
307 }
308 if (eCall != SC_IMPORTFILE)
309 {
310 const sal_Int32 nSkipEmptyCells = getSkipEmptyCellsIndex(eCall);
311 assert( nSkipEmptyCells < aValues.getLength());
312 pProperties[ nSkipEmptyCells ] <<= bSkipEmptyCells;
313 }
314
315 aItem.PutProperties(aNames, aValues);
316}
317
318ScImportAsciiDlg::ScImportAsciiDlg(weld::Window* pParent, std::u16string_view aDatName,
319 SvStream* pInStream, ScImportAsciiCall eCall)
320 : GenericDialogController(pParent, "modules/scalc/ui/textimportcsv.ui", "TextImportCsvDialog")
321 , mpDatStream(pInStream)
322 , mnStreamPos(pInStream ? pInStream->Tell() : 0)
323 , mnRowPosCount(0)
324 , mcTextSep(ScAsciiOptions::cDefaultTextSep)
325 , meCall(eCall)
326 , mbDetectSep(eCall != SC_TEXTTOCOLUMNS)
327 , mxFtCharSet(m_xBuilder->weld_label("textcharset"))
328 , mxLbCharSet(new SvxTextEncodingBox(m_xBuilder->weld_combo_box("charset")))
329 , mxFtCustomLang(m_xBuilder->weld_label("textlanguage"))
330 , mxLbCustomLang(new SvxLanguageBox(m_xBuilder->weld_combo_box("language")))
331 , mxFtRow(m_xBuilder->weld_label("textfromrow"))
332 , mxNfRow(m_xBuilder->weld_spin_button("fromrow"))
333 , mxRbFixed(m_xBuilder->weld_radio_button("tofixedwidth"))
334 , mxRbSeparated(m_xBuilder->weld_radio_button("toseparatedby"))
335 , mxCkbTab(m_xBuilder->weld_check_button("tab"))
336 , mxCkbSemicolon(m_xBuilder->weld_check_button("semicolon"))
337 , mxCkbComma(m_xBuilder->weld_check_button("comma"))
338 , mxCkbRemoveSpace(m_xBuilder->weld_check_button("removespace"))
339 , mxCkbSpace(m_xBuilder->weld_check_button("space"))
340 , mxCkbOther(m_xBuilder->weld_check_button("other"))
341 , mxEdOther(m_xBuilder->weld_entry("inputother"))
342 , mxCkbAsOnce(m_xBuilder->weld_check_button("mergedelimiters"))
343 , mxFtTextSep(m_xBuilder->weld_label("texttextdelimiter"))
344 , mxCbTextSep(m_xBuilder->weld_combo_box("textdelimiter"))
345 , mxCkbQuotedAsText(m_xBuilder->weld_check_button("quotedfieldastext"))
346 , mxCkbDetectNumber(m_xBuilder->weld_check_button("detectspecialnumbers"))
347 , mxCkbDetectScientificNumber(m_xBuilder->weld_check_button("detectscientificnumbers"))
348 , mxCkbEvaluateFormulas(m_xBuilder->weld_check_button("evaluateformulas"))
349 , mxCkbSkipEmptyCells(m_xBuilder->weld_check_button("skipemptycells"))
350 , mxLbType(m_xBuilder->weld_combo_box("columntype"))
351 , mxAltTitle(m_xBuilder->weld_label("textalttitle"))
352 , mxTableBox(new ScCsvTableBox(*m_xBuilder))
353{
354 OUString aName = m_xDialog->get_title();
355 switch (meCall)
356 {
357 case SC_TEXTTOCOLUMNS:
358 m_xDialog->set_title(mxAltTitle->get_label());
359 break;
360 case SC_IMPORTFILE:
362 {
363 aName += OUString::Concat(" - [") + aDatName + "]";
364 m_xDialog->set_title(aName);
365 }
366 break;
367 default:
368 break;
369 }
370
371 // To be able to prefill the correct values based on the file extension
372 bool bIsTSV = (o3tl::endsWithIgnoreAsciiCase(aDatName, ".tsv") || o3tl::endsWithIgnoreAsciiCase(aDatName, ".tab"));
373
374 // Default options are set in officecfg/registry/schema/org/openoffice/Office/Calc.xcs
375 OUString sFieldSeparators(",;\t");
376 OUString sTextSeparators(mcTextSep);
377 bool bMergeDelimiters = false;
378 bool bFixedWidth = false;
379 bool bQuotedFieldAsText = false;
380 bool bDetectSpecialNum = true;
381 bool bDetectScientificNum = true;
382 bool bEvaluateFormulas = (meCall != SC_IMPORTFILE);
383 bool bSkipEmptyCells = true;
384 bool bRemoveSpace = false;
385 sal_Int32 nFromRow = 1;
386 sal_Int32 nCharSet = -1;
387 sal_Int32 nLanguage = 0;
388 lcl_LoadSeparators (sFieldSeparators, sTextSeparators, bMergeDelimiters,
389 bQuotedFieldAsText, bDetectSpecialNum, bDetectScientificNum, bFixedWidth, nFromRow,
390 nCharSet, nLanguage, bSkipEmptyCells, bRemoveSpace, bEvaluateFormulas, meCall);
391 // load from saved settings
392 maFieldSeparators = sFieldSeparators;
393
394 if( bMergeDelimiters && !bIsTSV )
395 mxCkbAsOnce->set_active(true);
396 if (bQuotedFieldAsText)
397 mxCkbQuotedAsText->set_active(true);
398 if (bRemoveSpace)
399 mxCkbRemoveSpace->set_active(true);
400 if (bDetectSpecialNum)
401 {
402 mxCkbDetectNumber->set_active(true);
403 bDetectScientificNum = true;
404 mxCkbDetectScientificNumber->set_sensitive(false);
405 }
406 if (bDetectScientificNum)
407 mxCkbDetectScientificNumber->set_active(true);
408 if (bEvaluateFormulas)
409 mxCkbEvaluateFormulas->set_active(true);
410 if (bSkipEmptyCells)
411 mxCkbSkipEmptyCells->set_active(true);
412 if (bFixedWidth && !bIsTSV)
413 mxRbFixed->set_active(true);
414 if (nFromRow != 1)
415 mxNfRow->set_value(nFromRow);
416
417 // Clipboard is always Unicode, else detect.
418 rtl_TextEncoding ePreselectUnicode = (meCall == SC_IMPORTFILE ?
419 RTL_TEXTENCODING_DONTKNOW : RTL_TEXTENCODING_UNICODE);
420 // Sniff for Unicode / not
421 if( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW && mpDatStream )
422 {
423 mpDatStream->Seek( 0 );
424 constexpr size_t buffsize = 4096;
425 sal_Int8 bytes[buffsize] = { 0 };
426 sal_Int32 nRead = mpDatStream->ReadBytes( bytes, buffsize );
427 mpDatStream->Seek( 0 );
428
429 if ( nRead > 0 )
430 {
431 UErrorCode uerr = U_ZERO_ERROR;
432 UCharsetDetector* ucd = ucsdet_open( &uerr );
433 ucsdet_setText( ucd, reinterpret_cast<const char*>(bytes), nRead, &uerr );
434
435 if ( const UCharsetMatch* match = ucsdet_detect(ucd, &uerr) )
436 {
437 const char* pEncodingName = ucsdet_getName( match, &uerr );
438
439 if ( U_SUCCESS(uerr) && !strcmp("UTF-8", pEncodingName) )
440 {
441 ePreselectUnicode = RTL_TEXTENCODING_UTF8; // UTF-8
442 mpDatStream->StartReadingUnicodeText( RTL_TEXTENCODING_UTF8 );
443 }
444 else if ( U_SUCCESS(uerr) && !strcmp("UTF-16LE", pEncodingName) )
445 {
446 ePreselectUnicode = RTL_TEXTENCODING_UNICODE; // UTF-16LE
447 mpDatStream->SetEndian( SvStreamEndian::LITTLE );
448 mpDatStream->StartReadingUnicodeText( RTL_TEXTENCODING_UNICODE );
449 }
450 else if ( U_SUCCESS(uerr) && !strcmp("UTF-16BE", pEncodingName) )
451 {
452 ePreselectUnicode = RTL_TEXTENCODING_UNICODE; // UTF-16BE
453 mpDatStream->SetEndian( SvStreamEndian::BIG );
454 mpDatStream->StartReadingUnicodeText( RTL_TEXTENCODING_UNICODE );
455 }
456 else // other
457 mpDatStream->StartReadingUnicodeText( RTL_TEXTENCODING_DONTKNOW );
458 }
459
460 ucsdet_close( ucd );
461 }
462
464 }
465
466 if (bIsTSV)
467 SetSeparators('\t');
468 else
469 {
470 // Some MS-Excel convention is the first line containing the field
471 // separator as "sep=|" (without quotes and any field separator
472 // character). The second possibility seems to be it is present *with*
473 // quotes so it shows up as cell content *including* the separator and
474 // can be preserved during round trips. Check for an exact match of
475 // any such and set separator.
476 /* TODO: it is debatable whether the unquoted form should rather be
477 * treated special to actually include the separator in the field data.
478 * Currently it does not. */
479 sal_Unicode cSep = 0;
480 OUString aLine;
481 // Try to read one more character, if more than 7 it can't be an exact
482 // match of any.
485 if (aLine.getLength() == 8)
486 ; // nothing
487 else if (aLine.getLength() == 5 && aLine.startsWithIgnoreAsciiCase("sep="))
488 cSep = aLine[4];
489 else if (aLine.getLength() == 7 && aLine[6] == '"' && aLine.startsWithIgnoreAsciiCase("\"sep="))
490 cSep = aLine[5];
491
492 // Set Separators in the dialog from maFieldSeparators (empty are not
493 // set) or an optionally defined by file content field separator.
494 SetSeparators(cSep);
495 }
496
497 // Get Separators from the dialog (empty are set from default)
499
500 mxNfRow->connect_value_changed( LINK( this, ScImportAsciiDlg, FirstRowHdl ) );
501
502 // *** Separator characters ***
504 mxCbTextSep->set_entry_text(sTextSeparators);
505 // tdf#69207 - use selected text delimiter to parse the provided data
507
508 Link<weld::Toggleable&,void> aSeparatorClickHdl =LINK( this, ScImportAsciiDlg, SeparatorClickHdl );
509 Link<weld::Toggleable&,void> aOtherOptionsClickHdl =LINK( this, ScImportAsciiDlg, OtherOptionsClickHdl );
510 mxCbTextSep->connect_changed( LINK( this, ScImportAsciiDlg, SeparatorComboBoxHdl ) );
511 mxCkbTab->connect_toggled( aSeparatorClickHdl );
512 mxCkbSemicolon->connect_toggled( aSeparatorClickHdl );
513 mxCkbComma->connect_toggled( aSeparatorClickHdl );
514 mxCkbAsOnce->connect_toggled( aSeparatorClickHdl );
515 mxCkbSpace->connect_toggled( aSeparatorClickHdl );
516 mxCkbRemoveSpace->connect_toggled( aSeparatorClickHdl );
517 mxCkbOther->connect_toggled( aSeparatorClickHdl );
518 mxEdOther->connect_changed(LINK(this, ScImportAsciiDlg, SeparatorEditHdl));
519 mxCkbQuotedAsText->connect_toggled( aOtherOptionsClickHdl );
520 mxCkbDetectNumber->connect_toggled( aOtherOptionsClickHdl );
521 mxCkbDetectScientificNumber->connect_toggled( aOtherOptionsClickHdl );
522 mxCkbEvaluateFormulas->connect_toggled( aOtherOptionsClickHdl );
523 mxCkbSkipEmptyCells->connect_toggled( aOtherOptionsClickHdl );
524
525 // *** text encoding ListBox ***
526 // all encodings allowed, including Unicode, but subsets are excluded
527 mxLbCharSet->FillFromTextEncodingTable( true );
528 // Insert one "SYSTEM" entry for compatibility in AsciiOptions and system
529 // independent document linkage.
530 mxLbCharSet->InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, ScResId( SCSTR_CHARSET_USER ) );
531 if ( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW )
532 {
533 rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding();
534 // Prefer UTF-8, as UTF-16 would have already been detected from the stream.
535 // This gives a better chance that the file is going to be opened correctly.
536 if ( ( eSystemEncoding == RTL_TEXTENCODING_UNICODE ) && mpDatStream )
537 eSystemEncoding = RTL_TEXTENCODING_UTF8;
538 mxLbCharSet->SelectTextEncoding( eSystemEncoding );
539 }
540 else
541 {
542 mxLbCharSet->SelectTextEncoding( ePreselectUnicode );
543 }
544
545 if (nCharSet >= 0 && ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW)
546 mxLbCharSet->set_active(nCharSet);
547
549 mxLbCharSet->connect_changed( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
550
551 mxLbCustomLang->SetLanguageList(
552 SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false, false);
553 mxLbCustomLang->InsertLanguage(LANGUAGE_SYSTEM);
554 mxLbCustomLang->set_active_id(static_cast<LanguageType>(nLanguage));
555
556 // *** column type ListBox ***
557 OUString aColumnUser( ScResId( SCSTR_COLUMN_USER ) );
558 for (sal_Int32 nIdx {0}; nIdx>=0; )
559 {
560 mxLbType->append_text(aColumnUser.getToken(0, ';', nIdx));
561 }
562
563 mxLbType->connect_changed( LINK( this, ScImportAsciiDlg, LbColTypeHdl ) );
564 mxLbType->set_sensitive(false);
565
566 // *** table box preview ***
567 mxTableBox->Init();
568 mxTableBox->SetUpdateTextHdl( LINK( this, ScImportAsciiDlg, UpdateTextHdl ) );
569 mxTableBox->InitTypes( *mxLbType );
570 mxTableBox->SetColTypeHdl( LINK( this, ScImportAsciiDlg, ColTypeHdl ) );
571
572 mxRbSeparated->connect_toggled( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
573 mxRbFixed->connect_toggled( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
574
576 RbSepFix();
577
579
580 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
581
583 {
584 mxFtCharSet->set_sensitive(false);
585 mxLbCharSet->set_sensitive(false);
586 mxFtCustomLang->set_sensitive(false);
587 mxLbCustomLang->set_active_id(LANGUAGE_SYSTEM);
588 mxLbCustomLang->set_sensitive(false);
589 mxFtRow->set_sensitive(false);
590 mxNfRow->set_sensitive(false);
591
592 // Quoted field as text option is not used for text-to-columns mode.
593 mxCkbQuotedAsText->set_active(false);
594 mxCkbQuotedAsText->set_sensitive(false);
595
596 // Always detect special numbers for text-to-columns mode.
597 mxCkbDetectNumber->set_active(true);
598 mxCkbDetectNumber->set_sensitive(false);
599 mxCkbDetectScientificNumber->set_active(true);
600 mxCkbDetectScientificNumber->set_sensitive(false);
601 }
602 if (meCall == SC_IMPORTFILE)
603 {
604 //Empty cells in imported file are empty
605 mxCkbSkipEmptyCells->set_active(false);
606 mxCkbSkipEmptyCells->hide();
607 }
608 m_xDialog->SetInstallLOKNotifierHdl(LINK(this, ScImportAsciiDlg, InstallLOKNotifierHdl));
609}
610
612{
613 return GetpApp();
614}
615
617{
618}
619
620bool ScImportAsciiDlg::GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep )
621{
622 if (nLine >= ASCIIDLG_MAXROWS || !mpDatStream)
623 return false;
624
625 bool bRet = true;
626 bool bFixed = mxRbFixed->get_active();
627
628 if (!mpRowPosArray)
629 mpRowPosArray.reset( new sal_uLong[ASCIIDLG_MAXROWS + 2] );
630
631 if (!mnRowPosCount) // complete re-fresh
632 {
633 memset( mpRowPosArray.get(), 0, sizeof(mpRowPosArray[0]) * (ASCIIDLG_MAXROWS+2));
634
635 Seek(0);
637
640 }
641
642 if (nLine >= mnRowPosCount)
643 {
644 // need to work out some more line information
645 do
646 {
648 {
649 bRet = false;
650 break;
651 }
652 rText = ReadCsvLine(*mpDatStream, !bFixed, maFieldSeparators,
653 mcTextSep, rcDetectSep, kMaxEmbeddedLinefeeds);
656 } while (nLine >= mnRowPosCount && mpDatStream->good());
657 if (mpDatStream->eof() &&
659 {
660 // the very end, not even an empty line read
661 bRet = false;
663 }
664 }
665 else
666 {
667 Seek( mpRowPosArray[nLine]);
670 }
671
672 // If the file content isn't unicode, ReadUniStringLine
673 // may try to seek beyond the file's end and cause a CANTSEEK error
674 // (depending on the stream type). The error code has to be cleared,
675 // or further read operations (including non-unicode) will fail.
678
680
681 return bRet;
682}
683
685{
686 rOpt.SetCharSet( meCharSet );
688 rOpt.SetLanguage(mxLbCustomLang->get_active_id());
689 rOpt.SetFixedLen( mxRbFixed->get_active() );
690 rOpt.SetStartRow( mxNfRow->get_value() );
691 mxTableBox->FillColumnData( rOpt );
692 if( mxRbSeparated->get_active() )
693 {
694 rOpt.SetFieldSeps( GetSeparators() );
695 rOpt.SetMergeSeps( mxCkbAsOnce->get_active() );
696 rOpt.SetRemoveSpace( mxCkbRemoveSpace->get_active() );
698 }
699
700 rOpt.SetQuotedAsText(mxCkbQuotedAsText->get_active());
701 rOpt.SetDetectSpecialNumber(mxCkbDetectNumber->get_active());
703 rOpt.SetEvaluateFormulas(mxCkbEvaluateFormulas->get_active());
704 rOpt.SetSkipEmptyCells(mxCkbSkipEmptyCells->get_active());
705}
706
708{
709 lcl_SaveSeparators( maFieldSeparators, mxCbTextSep->get_active_text(), mxCkbAsOnce->get_active(),
710 mxCkbQuotedAsText->get_active(), mxCkbDetectNumber->get_active(), mxCkbDetectScientificNumber->get_active(),
711 mxRbFixed->get_active(),
712 mxNfRow->get_value(),
713 mxLbCharSet->get_active(),
714 static_cast<sal_uInt16>(mxLbCustomLang->get_active_id()),
715 mxCkbSkipEmptyCells->get_active(), mxCkbRemoveSpace->get_active(),
716 mxCkbEvaluateFormulas->get_active(), meCall );
717}
718
720{
721 if (cSep)
722 {
723 // Exclusively set a separator, maFieldSeparators needs not be
724 // modified, it's obtained by GetSeparators() after this call.
725 constexpr sal_Unicode aSeps[] = { '\t', ';', ',', ' ' };
726 for (const sal_Unicode c : aSeps)
727 {
728 const bool bSet = (c == cSep);
729 switch (c)
730 {
731 case '\t': mxCkbTab->set_active(bSet); break;
732 case ';': mxCkbSemicolon->set_active(bSet); break;
733 case ',': mxCkbComma->set_active(bSet); break;
734 case ' ': mxCkbSpace->set_active(bSet); break;
735 }
736 if (bSet)
737 cSep = 0;
738 }
739 if (cSep)
740 {
741 mxCkbOther->set_active(true);
742 mxEdOther->set_text(OUStringChar(cSep));
743 }
744 }
745 else
746 {
747 for (sal_Int32 i = 0; i < maFieldSeparators.getLength(); ++i)
748 {
749 switch (maFieldSeparators[i])
750 {
751 case '\t': mxCkbTab->set_active(true); break;
752 case ';': mxCkbSemicolon->set_active(true); break;
753 case ',': mxCkbComma->set_active(true); break;
754 case ' ': mxCkbSpace->set_active(true); break;
755 default:
756 mxCkbOther->set_active(true);
757 mxEdOther->set_text(mxEdOther->get_text() + OUStringChar(maFieldSeparators[i]));
758 }
759 }
760 }
761}
762
764{
765 meCharSet = mxLbCharSet->GetSelectTextEncoding();
766 mbCharSetSystem = (meCharSet == RTL_TEXTENCODING_DONTKNOW);
767 if( mbCharSetSystem )
768 meCharSet = osl_getThreadTextEncoding();
769}
770
772{
773 OUString aSepChars;
774 if( mxCkbTab->get_active() )
775 aSepChars += "\t";
776 if( mxCkbSemicolon->get_active() )
777 aSepChars += ";";
778 if( mxCkbComma->get_active() )
779 aSepChars += ",";
780 if( mxCkbSpace->get_active() )
781 aSepChars += " ";
782 if( mxCkbOther->get_active() )
783 aSepChars += mxEdOther->get_text();
784 return aSepChars;
785}
786
788{
789 bool bEnable = mxRbSeparated->get_active();
790 mxCkbTab->set_sensitive( bEnable );
791 mxCkbSemicolon->set_sensitive( bEnable );
792 mxCkbComma->set_sensitive( bEnable );
793 mxCkbSpace->set_sensitive( bEnable );
794 mxCkbRemoveSpace->set_sensitive( bEnable );
795 mxCkbOther->set_sensitive( bEnable );
796 mxEdOther->set_sensitive( bEnable );
797 mxCkbAsOnce->set_sensitive( bEnable );
798 mxFtTextSep->set_sensitive( bEnable );
799 mxCbTextSep->set_sensitive( bEnable );
800}
801
803{
804 mnRowPosCount = 0;
805 if (mpDatStream)
807}
808
810{
811 weld::WaitObject aWaitObj(m_xDialog.get());
812 if( mxRbFixed->get_active() )
813 mxTableBox->SetFixedWidthMode();
814 else
815 mxTableBox->SetSeparatorsMode();
817}
818
819IMPL_LINK(ScImportAsciiDlg, RbSepFixHdl, weld::Toggleable&, rButton, void)
820{
821 if (!rButton.get_active())
822 return;
823 RbSepFix();
824}
825
826IMPL_LINK(ScImportAsciiDlg, SeparatorClickHdl, weld::Toggleable&, rCtrl, void)
827{
828 SeparatorHdl(&rCtrl);
829}
830
831IMPL_LINK( ScImportAsciiDlg, SeparatorComboBoxHdl, weld::ComboBox&, rCtrl, void )
832{
833 SeparatorHdl(&rCtrl);
834}
835
836IMPL_LINK( ScImportAsciiDlg, SeparatorEditHdl, weld::Entry&, rEdit, void )
837{
838 SeparatorHdl(&rEdit);
839}
840
841IMPL_LINK(ScImportAsciiDlg, OtherOptionsClickHdl, weld::Toggleable&, rCtrl, void)
842{
843 if (&rCtrl == mxCkbDetectNumber.get())
844 {
845 if (mxCkbDetectNumber->get_active())
846 {
847 mxCkbDetectScientificNumber->set_active(true);
848 mxCkbDetectScientificNumber->set_sensitive(false);
849 }
850 else
851 mxCkbDetectScientificNumber->set_sensitive(true);
852 return;
853 }
854}
855
857{
858 OSL_ENSURE( pCtrl, "ScImportAsciiDlg::SeparatorHdl - missing sender" );
859 OSL_ENSURE( !mxRbFixed->get_active(), "ScImportAsciiDlg::SeparatorHdl - not allowed in fixed width" );
860
861 /* #i41550# First update state of the controls. The GetSeparators()
862 function needs final state of the check boxes. */
863 if (pCtrl == mxCkbOther.get() && mxCkbOther->get_active())
864 mxEdOther->grab_focus();
865 else if (pCtrl == mxEdOther.get())
866 mxCkbOther->set_active(!mxEdOther->get_text().isEmpty());
867
868 OUString aOldFldSeps( maFieldSeparators);
870 sal_Unicode cOldSep = mcTextSep;
872 // Any separator changed may result in completely different lines due to
873 // embedded line breaks.
874 if (cOldSep != mcTextSep || aOldFldSeps != maFieldSeparators)
876
877 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
878}
879
881{
882 if (mxLbCharSet->get_active() != -1)
883 {
884 weld::WaitObject aWaitObj(m_xDialog.get());
885 rtl_TextEncoding eOldCharSet = meCharSet;
886 SetSelectedCharSet();
887 // switching char-set invalidates 8bit -> String conversions
888 if (eOldCharSet != meCharSet)
889 UpdateVertical();
890
891 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
892 }
893}
894
895IMPL_LINK(ScImportAsciiDlg, FirstRowHdl, weld::SpinButton&, rNumField, void)
896{
897 mxTableBox->GetGrid().Execute( CSVCMD_SETFIRSTIMPORTLINE, rNumField.get_value() - 1);
898}
899
900IMPL_LINK(ScImportAsciiDlg, LbColTypeHdl, weld::ComboBox&, rListBox, void)
901{
902 if (&rListBox == mxLbType.get())
903 mxTableBox->GetGrid().Execute(CSVCMD_SETCOLUMNTYPE, rListBox.get_active());
904}
905
907{
908 // Checking the separator can only be done once for the very first time
909 // when the dialog wasn't already presented to the user.
910 // As a side effect this has the benefit that the check is only done on the
911 // first set of visible lines.
912 mbDetectSep = (mbDetectSep && !mxRbFixed->get_active()
913 && (!mxCkbTab->get_active() || !mxCkbSemicolon->get_active()
914 || !mxCkbComma->get_active() || !mxCkbSpace->get_active()));
915 sal_Unicode cDetectSep = (mbDetectSep ? 0 : 0xffff);
916
917 sal_Int32 nBaseLine = mxTableBox->GetGrid().GetFirstVisLine();
918 sal_Int32 nRead = mxTableBox->GetGrid().GetVisLineCount();
919 // If mnRowPosCount==0, this is an initializing call, read ahead for row
920 // count and resulting scroll bar size and position to be able to scroll at
921 // all. When adding lines, read only the amount of next lines to be
922 // displayed.
923 if (!mnRowPosCount || nRead > CSV_PREVIEW_LINES)
924 nRead = CSV_PREVIEW_LINES;
925
926 sal_Int32 i;
927 for (i = 0; i < nRead; i++)
928 {
929 if (!GetLine( nBaseLine + i, maPreviewLine[i], cDetectSep))
930 break;
931 }
932 for (; i < CSV_PREVIEW_LINES; i++)
933 maPreviewLine[i].clear();
934
935 if (mbDetectSep)
936 {
937 mbDetectSep = false;
938 if (cDetectSep)
939 {
940 // Expect separator to be appended by now so all subsequent
941 // GetLine()/ReadCsvLine() actually used it.
942 assert(maFieldSeparators.endsWith(OUStringChar(cDetectSep)));
943 // Preselect separator in UI.
944 switch (cDetectSep)
945 {
946 case '\t': mxCkbTab->set_active(true); break;
947 case ';': mxCkbSemicolon->set_active(true); break;
948 case ',': mxCkbComma->set_active(true); break;
949 case ' ': mxCkbSpace->set_active(true); break;
950 }
951 }
952 }
953
954 mxTableBox->GetGrid().Execute( CSVCMD_SETLINECOUNT, mnRowPosCount);
955 bool bMergeSep = mxCkbAsOnce->get_active();
956 bool bRemoveSpace = mxCkbRemoveSpace->get_active();
957 mxTableBox->SetUniStrings( maPreviewLine, maFieldSeparators, mcTextSep, bMergeSep, bRemoveSpace );
958}
959
960IMPL_LINK( ScImportAsciiDlg, ColTypeHdl, ScCsvTableBox&, rTableBox, void )
961{
962 sal_Int32 nType = rTableBox.GetSelColumnType();
963 sal_Int32 nTypeCount = mxLbType->get_count();
964 bool bEmpty = (nType == CSV_TYPE_MULTI);
965 bool bEnable = ((0 <= nType) && (nType < nTypeCount)) || bEmpty;
966
967 mxLbType->set_sensitive( bEnable );
968
969 if (bEmpty)
970 mxLbType->set_active(-1);
971 else if (bEnable)
972 mxLbType->set_active(nType);
973}
974
975/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const SCROW MAXROWCOUNT
Definition: address.hxx:62
size_t SCSIZE
size_t typedef to be able to find places where code was changed from USHORT to size_t and is used to ...
Definition: address.hxx:44
ScImportAsciiCall
How ScImportAsciiDlg is called.
Definition: asciiopt.hxx:109
@ SC_IMPORTFILE
Definition: asciiopt.hxx:110
@ SC_TEXTTOCOLUMNS
Definition: asciiopt.hxx:112
@ SC_PASTETEXT
Definition: asciiopt.hxx:111
Reference< XExecutableDialog > m_xDialog
void SetFieldSeps(const OUString &rStr)
Definition: asciiopt.hxx:79
void SetRemoveSpace(bool bSet)
Definition: asciiopt.hxx:81
void SetCharSet(rtl_TextEncoding eNew)
Definition: asciiopt.hxx:76
void SetLanguage(LanguageType e)
Definition: asciiopt.hxx:90
void SetFixedLen(bool bSet)
Definition: asciiopt.hxx:78
void SetTextSep(sal_Unicode c)
Definition: asciiopt.hxx:88
void SetQuotedAsText(bool bSet)
Definition: asciiopt.hxx:82
void SetDetectScientificNumber(bool bSet)
Definition: asciiopt.hxx:84
void SetMergeSeps(bool bSet)
Definition: asciiopt.hxx:80
void SetStartRow(sal_Int32 nRow)
Definition: asciiopt.hxx:89
void SetSkipEmptyCells(bool bSet)
Definition: asciiopt.hxx:86
void SetCharSetSystem(bool bSet)
Definition: asciiopt.hxx:77
void SetEvaluateFormulas(bool bSet)
Definition: asciiopt.hxx:85
void SetDetectSpecialNumber(bool bSet)
Definition: asciiopt.hxx:83
The control in the CSV import dialog that contains a ruler and a data grid to visualize and modify th...
Definition: csvtablebox.hxx:44
static SC_DLLPUBLIC ::utl::TransliterationWrapper & GetTransliteration()
Definition: global.cxx:1026
std::unique_ptr< weld::SpinButton > mxNfRow
std::unique_ptr< weld::CheckButton > mxCkbComma
std::unique_ptr< weld::CheckButton > mxCkbSkipEmptyCells
void SetupSeparatorCtrls()
Enables or disables all separator checkboxes and edit fields.
std::unique_ptr< weld::ComboBox > mxLbType
std::unique_ptr< weld::CheckButton > mxCkbDetectNumber
std::unique_ptr< weld::Label > mxFtRow
std::unique_ptr< weld::CheckButton > mxCkbQuotedAsText
OUString maFieldSeparators
std::unique_ptr< weld::RadioButton > mxRbFixed
void SetSelectedCharSet()
Sets the selected char set data to meCharSet and mbCharSetSystem.
bool GetLine(sal_uLong nLine, OUString &rText, sal_Unicode &rcDetectSep)
sal_Unicode mcTextSep
std::unique_ptr< weld::CheckButton > mxCkbDetectScientificNumber
OUString GetSeparators() const
Returns all separator characters in a string.
std::unique_ptr< weld::CheckButton > mxCkbSemicolon
std::unique_ptr< sal_uLong[]> mpRowPosArray
ScImportAsciiDlg(weld::Window *pParent, std::u16string_view aDatName, SvStream *pInStream, ScImportAsciiCall eCall)
std::unique_ptr< weld::CheckButton > mxCkbOther
void GetOptions(ScAsciiOptions &rOpt)
void SetSeparators(sal_Unicode cSep)
Set separators in ui from maFieldSeparators or an optionally defined separator.
std::unique_ptr< weld::Entry > mxEdOther
std::unique_ptr< weld::CheckButton > mxCkbAsOnce
sal_uLong mnStreamPos
std::unique_ptr< weld::CheckButton > mxCkbRemoveSpace
std::unique_ptr< weld::Label > mxFtTextSep
bool mbCharSetSystem
Selected char set.
ScImportAsciiCall meCall
Is System char set selected?
std::unique_ptr< weld::Label > mxFtCharSet
Whether to detect a possible separator.
std::unique_ptr< weld::CheckButton > mxCkbEvaluateFormulas
bool Seek(sal_uLong nPos)
std::unique_ptr< weld::Label > mxFtCustomLang
void SeparatorHdl(const weld::Widget *)
std::unique_ptr< weld::CheckButton > mxCkbSpace
std::unique_ptr< ScCsvTableBox > mxTableBox
std::unique_ptr< weld::ComboBox > mxCbTextSep
std::unique_ptr< weld::Label > mxAltTitle
std::unique_ptr< SvxTextEncodingBox > mxLbCharSet
rtl_TextEncoding meCharSet
std::unique_ptr< weld::RadioButton > mxRbSeparated
sal_uLong mnRowPosCount
SvStream * mpDatStream
std::unique_ptr< weld::CheckButton > mxCkbTab
std::unique_ptr< SvxLanguageBox > mxLbCustomLang
virtual ~ScImportAsciiDlg() override
static void EmbeddedNullTreatment(OUString &rStr)
Definition: impex.cxx:1855
void PutProperties(const css::uno::Sequence< OUString > &rNames, const css::uno::Sequence< css::uno::Any > &rValues)
Definition: optutil.hxx:55
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
Definition: optutil.hxx:53
static bool GetBoolFromAny(const css::uno::Any &aAny)
Definition: miscuno.cxx:139
virtual void ResetError()
sal_uInt64 Tell() const
void StartReadingUnicodeText(rtl_TextEncoding eReadBomCharSet)
void SetEndian(SvStreamEndian SvStreamEndian)
bool good() const
bool eof() const
bool ReadUniOrByteStringLine(OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxCodepointsToRead=0xFFFE)
sal_uInt64 Seek(sal_uInt64 nPos)
void SetStreamCharSet(rtl_TextEncoding eCharSet)
std::size_t ReadBytes(void *pData, std::size_t nSize)
rtl_TextEncoding GetStreamCharSet() const
ErrCode GetError() const
virtual OUString get_active_text() const=0
virtual void set_entry_text(const OUString &rStr)=0
void append_text(const OUString &rStr)
std::shared_ptr< weld::Dialog > m_xDialog
const sal_Int32 CSV_PREVIEW_LINES
TODO make string array dynamic.
Definition: csvcontrol.hxx:42
const sal_Int32 CSV_TYPE_MULTI
Multi selection with different types.
Definition: csvcontrol.hxx:49
@ CSVCMD_SETCOLUMNTYPE
Update cell texts with current split settings. [-].
Definition: csvcontrol.hxx:184
@ CSVCMD_SETLINECOUNT
Change character pixel width. [width in pixel].
Definition: csvcontrol.hxx:171
@ CSVCMD_SETFIRSTIMPORTLINE
Send selected column type to external controls. [-].
Definition: csvcontrol.hxx:186
@ CSVCMD_NEWCELLTEXTS
Move to make passed position visible (for mouse tracking). [position].
Definition: csvcontrol.hxx:182
float u
#define ERRCODE_IO_CANTSEEK
OUString ReadCsvLine(SvStream &rStream, bool bEmbeddedLineBreak, OUString &rFieldSeparators, sal_Unicode cFieldQuote, sal_Unicode &rcDetectSep, sal_uInt32 nMaxSourceLines)
Read a CSV (comma separated values) data line using ReadUniOrByteStringLine().
Definition: impex.cxx:2738
OUString aName
#define LANGUAGE_SYSTEM
aStr
bool match(const sal_Unicode *pWild, const sal_Unicode *pStr, const sal_Unicode cEscape)
int i
bool endsWithIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2, std::u16string_view *rest=nullptr)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
std::vector< sal_uInt8 > bytes
QPRO_FUNC_TYPE nType
Definition: qproform.cxx:398
OUString ScResId(TranslateId aId)
Definition: scdll.cxx:90
const SCSIZE ASCIIDLG_MAXROWS
TODO make dynamic.
static void lcl_SaveSeparators(const OUString &sFieldSeparators, const OUString &sTextSeparators, bool bMergeDelimiters, bool bQuotedAsText, bool bDetectSpecialNum, bool bDetectScientificNum, bool bFixedWidth, sal_Int32 nFromRow, sal_Int32 nCharSet, sal_Int32 nLanguage, bool bSkipEmptyCells, bool bRemoveSpace, bool bEvaluateFormulas, ScImportAsciiCall eCall)
IMPL_STATIC_LINK_NOARG(ScImportAsciiDlg, InstallLOKNotifierHdl, void *, vcl::ILibreOfficeKitNotifier *)
static sal_Unicode lcl_CharFromCombo(const weld::ComboBox &rCombo, std::u16string_view rList)
IMPL_LINK_NOARG(ScImportAsciiDlg, CharSetHdl, weld::ComboBox &, void)
constexpr OUStringLiteral aSep_Path_Text2Col
constexpr sal_uInt32 kMaxEmbeddedLinefeeds
constexpr OUStringLiteral aSep_Path
static void lcl_LoadSeparators(OUString &rFieldSeparators, OUString &rTextSeparators, bool &rMergeDelimiters, bool &rQuotedAsText, bool &rDetectSpecialNum, bool &rDetectScientificNum, bool &rFixedWidth, sal_Int32 &rFromRow, sal_Int32 &rCharSet, sal_Int32 &rLanguage, bool &rSkipEmptyCells, bool &rRemoveSpace, bool &rEvaluateFormulas, ScImportAsciiCall eCall)
const ::std::vector< OUString > CSVImportOptionNames
static void lcl_CreatePropertiesNames(OUString &rSepPath, Sequence< OUString > &rNames, ScImportAsciiCall eCall)
static void lcl_FillCombo(weld::ComboBox &rCombo, std::u16string_view rList, sal_Unicode cSelect)
IMPL_LINK(ScImportAsciiDlg, RbSepFixHdl, weld::Toggleable &, rButton, void)
constexpr OUStringLiteral aSep_Path_Clpbrd
sal_uIntPtr sal_uLong
constexpr OUStringLiteral SCSTR_TEXTSEP
Definition: strings.hxx:15
VCL_DLLPUBLIC Application * GetpApp()
sal_uInt16 sal_Unicode
signed char sal_Int8
sal_Int32 nProperties