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 mxCbTextSep->connect_changed( LINK( this, ScImportAsciiDlg, SeparatorComboBoxHdl ) );
510 mxCkbTab->connect_toggled( aSeparatorClickHdl );
511 mxCkbSemicolon->connect_toggled( aSeparatorClickHdl );
512 mxCkbComma->connect_toggled( aSeparatorClickHdl );
513 mxCkbAsOnce->connect_toggled( aSeparatorClickHdl );
514 mxCkbQuotedAsText->connect_toggled( aSeparatorClickHdl );
515 mxCkbDetectNumber->connect_toggled( aSeparatorClickHdl );
516 mxCkbDetectScientificNumber->connect_toggled( aSeparatorClickHdl );
517 mxCkbEvaluateFormulas->connect_toggled( aSeparatorClickHdl );
518 mxCkbSkipEmptyCells->connect_toggled( aSeparatorClickHdl );
519 mxCkbSpace->connect_toggled( aSeparatorClickHdl );
520 mxCkbRemoveSpace->connect_toggled( aSeparatorClickHdl );
521 mxCkbOther->connect_toggled( aSeparatorClickHdl );
522 mxEdOther->connect_changed(LINK(this, ScImportAsciiDlg, SeparatorEditHdl));
523
524 // *** text encoding ListBox ***
525 // all encodings allowed, including Unicode, but subsets are excluded
526 mxLbCharSet->FillFromTextEncodingTable( true );
527 // Insert one "SYSTEM" entry for compatibility in AsciiOptions and system
528 // independent document linkage.
529 mxLbCharSet->InsertTextEncoding( RTL_TEXTENCODING_DONTKNOW, ScResId( SCSTR_CHARSET_USER ) );
530 if ( ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW )
531 {
532 rtl_TextEncoding eSystemEncoding = osl_getThreadTextEncoding();
533 // Prefer UTF-8, as UTF-16 would have already been detected from the stream.
534 // This gives a better chance that the file is going to be opened correctly.
535 if ( ( eSystemEncoding == RTL_TEXTENCODING_UNICODE ) && mpDatStream )
536 eSystemEncoding = RTL_TEXTENCODING_UTF8;
537 mxLbCharSet->SelectTextEncoding( eSystemEncoding );
538 }
539 else
540 {
541 mxLbCharSet->SelectTextEncoding( ePreselectUnicode );
542 }
543
544 if (nCharSet >= 0 && ePreselectUnicode == RTL_TEXTENCODING_DONTKNOW)
545 mxLbCharSet->set_active(nCharSet);
546
548 mxLbCharSet->connect_changed( LINK( this, ScImportAsciiDlg, CharSetHdl ) );
549
550 mxLbCustomLang->SetLanguageList(
551 SvxLanguageListFlags::ALL | SvxLanguageListFlags::ONLY_KNOWN, false, false);
552 mxLbCustomLang->InsertLanguage(LANGUAGE_SYSTEM);
553 mxLbCustomLang->set_active_id(static_cast<LanguageType>(nLanguage));
554
555 // *** column type ListBox ***
556 OUString aColumnUser( ScResId( SCSTR_COLUMN_USER ) );
557 for (sal_Int32 nIdx {0}; nIdx>=0; )
558 {
559 mxLbType->append_text(aColumnUser.getToken(0, ';', nIdx));
560 }
561
562 mxLbType->connect_changed( LINK( this, ScImportAsciiDlg, LbColTypeHdl ) );
563 mxLbType->set_sensitive(false);
564
565 // *** table box preview ***
566 mxTableBox->Init();
567 mxTableBox->SetUpdateTextHdl( LINK( this, ScImportAsciiDlg, UpdateTextHdl ) );
568 mxTableBox->InitTypes( *mxLbType );
569 mxTableBox->SetColTypeHdl( LINK( this, ScImportAsciiDlg, ColTypeHdl ) );
570
571 mxRbSeparated->connect_toggled( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
572 mxRbFixed->connect_toggled( LINK( this, ScImportAsciiDlg, RbSepFixHdl ) );
573
575 RbSepFix();
576
578
579 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
580
582 {
583 mxFtCharSet->set_sensitive(false);
584 mxLbCharSet->set_sensitive(false);
585 mxFtCustomLang->set_sensitive(false);
586 mxLbCustomLang->set_active_id(LANGUAGE_SYSTEM);
587 mxLbCustomLang->set_sensitive(false);
588 mxFtRow->set_sensitive(false);
589 mxNfRow->set_sensitive(false);
590
591 // Quoted field as text option is not used for text-to-columns mode.
592 mxCkbQuotedAsText->set_active(false);
593 mxCkbQuotedAsText->set_sensitive(false);
594
595 // Always detect special numbers for text-to-columns mode.
596 mxCkbDetectNumber->set_active(true);
597 mxCkbDetectNumber->set_sensitive(false);
598 mxCkbDetectScientificNumber->set_active(true);
599 mxCkbDetectScientificNumber->set_sensitive(false);
600 }
601 if (meCall == SC_IMPORTFILE)
602 {
603 //Empty cells in imported file are empty
604 mxCkbSkipEmptyCells->set_active(false);
605 mxCkbSkipEmptyCells->hide();
606 }
607 m_xDialog->SetInstallLOKNotifierHdl(LINK(this, ScImportAsciiDlg, InstallLOKNotifierHdl));
608}
609
611{
612 return GetpApp();
613}
614
616{
617}
618
619bool ScImportAsciiDlg::GetLine( sal_uLong nLine, OUString &rText, sal_Unicode& rcDetectSep )
620{
621 if (nLine >= ASCIIDLG_MAXROWS || !mpDatStream)
622 return false;
623
624 bool bRet = true;
625 bool bFixed = mxRbFixed->get_active();
626
627 if (!mpRowPosArray)
628 mpRowPosArray.reset( new sal_uLong[ASCIIDLG_MAXROWS + 2] );
629
630 if (!mnRowPosCount) // complete re-fresh
631 {
632 memset( mpRowPosArray.get(), 0, sizeof(mpRowPosArray[0]) * (ASCIIDLG_MAXROWS+2));
633
634 Seek(0);
636
639 }
640
641 if (nLine >= mnRowPosCount)
642 {
643 // need to work out some more line information
644 do
645 {
647 {
648 bRet = false;
649 break;
650 }
651 rText = ReadCsvLine(*mpDatStream, !bFixed, maFieldSeparators,
652 mcTextSep, rcDetectSep, kMaxEmbeddedLinefeeds);
655 } while (nLine >= mnRowPosCount && mpDatStream->good());
656 if (mpDatStream->eof() &&
658 {
659 // the very end, not even an empty line read
660 bRet = false;
662 }
663 }
664 else
665 {
666 Seek( mpRowPosArray[nLine]);
669 }
670
671 // If the file content isn't unicode, ReadUniStringLine
672 // may try to seek beyond the file's end and cause a CANTSEEK error
673 // (depending on the stream type). The error code has to be cleared,
674 // or further read operations (including non-unicode) will fail.
677
679
680 return bRet;
681}
682
684{
685 rOpt.SetCharSet( meCharSet );
687 rOpt.SetLanguage(mxLbCustomLang->get_active_id());
688 rOpt.SetFixedLen( mxRbFixed->get_active() );
689 rOpt.SetStartRow( mxNfRow->get_value() );
690 mxTableBox->FillColumnData( rOpt );
691 if( mxRbSeparated->get_active() )
692 {
693 rOpt.SetFieldSeps( GetSeparators() );
694 rOpt.SetMergeSeps( mxCkbAsOnce->get_active() );
695 rOpt.SetRemoveSpace( mxCkbRemoveSpace->get_active() );
697 }
698
699 rOpt.SetQuotedAsText(mxCkbQuotedAsText->get_active());
700 rOpt.SetDetectSpecialNumber(mxCkbDetectNumber->get_active());
702 rOpt.SetEvaluateFormulas(mxCkbEvaluateFormulas->get_active());
703 rOpt.SetSkipEmptyCells(mxCkbSkipEmptyCells->get_active());
704}
705
707{
708 lcl_SaveSeparators( maFieldSeparators, mxCbTextSep->get_active_text(), mxCkbAsOnce->get_active(),
709 mxCkbQuotedAsText->get_active(), mxCkbDetectNumber->get_active(), mxCkbDetectScientificNumber->get_active(),
710 mxRbFixed->get_active(),
711 mxNfRow->get_value(),
712 mxLbCharSet->get_active(),
713 static_cast<sal_uInt16>(mxLbCustomLang->get_active_id()),
714 mxCkbSkipEmptyCells->get_active(), mxCkbRemoveSpace->get_active(),
715 mxCkbEvaluateFormulas->get_active(), meCall );
716}
717
719{
720 if (cSep)
721 {
722 // Exclusively set a separator, maFieldSeparators needs not be
723 // modified, it's obtained by GetSeparators() after this call.
724 constexpr sal_Unicode aSeps[] = { '\t', ';', ',', ' ' };
725 for (const sal_Unicode c : aSeps)
726 {
727 const bool bSet = (c == cSep);
728 switch (c)
729 {
730 case '\t': mxCkbTab->set_active(bSet); break;
731 case ';': mxCkbSemicolon->set_active(bSet); break;
732 case ',': mxCkbComma->set_active(bSet); break;
733 case ' ': mxCkbSpace->set_active(bSet); break;
734 }
735 if (bSet)
736 cSep = 0;
737 }
738 if (cSep)
739 {
740 mxCkbOther->set_active(true);
741 mxEdOther->set_text(OUStringChar(cSep));
742 }
743 }
744 else
745 {
746 for (sal_Int32 i = 0; i < maFieldSeparators.getLength(); ++i)
747 {
748 switch (maFieldSeparators[i])
749 {
750 case '\t': mxCkbTab->set_active(true); break;
751 case ';': mxCkbSemicolon->set_active(true); break;
752 case ',': mxCkbComma->set_active(true); break;
753 case ' ': mxCkbSpace->set_active(true); break;
754 default:
755 mxCkbOther->set_active(true);
756 mxEdOther->set_text(mxEdOther->get_text() + OUStringChar(maFieldSeparators[i]));
757 }
758 }
759 }
760}
761
763{
764 meCharSet = mxLbCharSet->GetSelectTextEncoding();
765 mbCharSetSystem = (meCharSet == RTL_TEXTENCODING_DONTKNOW);
766 if( mbCharSetSystem )
767 meCharSet = osl_getThreadTextEncoding();
768}
769
771{
772 OUString aSepChars;
773 if( mxCkbTab->get_active() )
774 aSepChars += "\t";
775 if( mxCkbSemicolon->get_active() )
776 aSepChars += ";";
777 if( mxCkbComma->get_active() )
778 aSepChars += ",";
779 if( mxCkbSpace->get_active() )
780 aSepChars += " ";
781 if( mxCkbOther->get_active() )
782 aSepChars += mxEdOther->get_text();
783 return aSepChars;
784}
785
787{
788 bool bEnable = mxRbSeparated->get_active();
789 mxCkbTab->set_sensitive( bEnable );
790 mxCkbSemicolon->set_sensitive( bEnable );
791 mxCkbComma->set_sensitive( bEnable );
792 mxCkbSpace->set_sensitive( bEnable );
793 mxCkbRemoveSpace->set_sensitive( bEnable );
794 mxCkbOther->set_sensitive( bEnable );
795 mxEdOther->set_sensitive( bEnable );
796 mxCkbAsOnce->set_sensitive( bEnable );
797 mxFtTextSep->set_sensitive( bEnable );
798 mxCbTextSep->set_sensitive( bEnable );
799}
800
802{
803 mnRowPosCount = 0;
804 if (mpDatStream)
806}
807
809{
810 weld::WaitObject aWaitObj(m_xDialog.get());
811 if( mxRbFixed->get_active() )
812 mxTableBox->SetFixedWidthMode();
813 else
814 mxTableBox->SetSeparatorsMode();
816}
817
818IMPL_LINK(ScImportAsciiDlg, RbSepFixHdl, weld::Toggleable&, rButton, void)
819{
820 if (!rButton.get_active())
821 return;
822 RbSepFix();
823}
824
825IMPL_LINK(ScImportAsciiDlg, SeparatorClickHdl, weld::Toggleable&, rCtrl, void)
826{
827 SeparatorHdl(&rCtrl);
828}
829
830IMPL_LINK( ScImportAsciiDlg, SeparatorComboBoxHdl, weld::ComboBox&, rCtrl, void )
831{
832 SeparatorHdl(&rCtrl);
833}
834
835IMPL_LINK( ScImportAsciiDlg, SeparatorEditHdl, weld::Entry&, rEdit, void )
836{
837 SeparatorHdl(&rEdit);
838}
839
841{
842 OSL_ENSURE( pCtrl, "ScImportAsciiDlg::SeparatorHdl - missing sender" );
843 OSL_ENSURE( !mxRbFixed->get_active(), "ScImportAsciiDlg::SeparatorHdl - not allowed in fixed width" );
844
845 if (pCtrl == mxCkbDetectNumber.get())
846 {
847 if (mxCkbDetectNumber->get_active())
848 {
849 mxCkbDetectScientificNumber->set_active(true);
850 mxCkbDetectScientificNumber->set_sensitive(false);
851 }
852 else
853 mxCkbDetectScientificNumber->set_sensitive(true);
854 return;
855 }
856 /* #i41550# First update state of the controls. The GetSeparators()
857 function needs final state of the check boxes. */
858 if (pCtrl == mxCkbOther.get() && mxCkbOther->get_active())
859 mxEdOther->grab_focus();
860 else if (pCtrl == mxEdOther.get())
861 mxCkbOther->set_active(!mxEdOther->get_text().isEmpty());
862
863 OUString aOldFldSeps( maFieldSeparators);
865 sal_Unicode cOldSep = mcTextSep;
867 // Any separator changed may result in completely different lines due to
868 // embedded line breaks.
869 if (cOldSep != mcTextSep || aOldFldSeps != maFieldSeparators)
871
872 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
873}
874
876{
877 if (mxLbCharSet->get_active() != -1)
878 {
879 weld::WaitObject aWaitObj(m_xDialog.get());
880 rtl_TextEncoding eOldCharSet = meCharSet;
881 SetSelectedCharSet();
882 // switching char-set invalidates 8bit -> String conversions
883 if (eOldCharSet != meCharSet)
884 UpdateVertical();
885
886 mxTableBox->GetGrid().Execute( CSVCMD_NEWCELLTEXTS );
887 }
888}
889
890IMPL_LINK(ScImportAsciiDlg, FirstRowHdl, weld::SpinButton&, rNumField, void)
891{
892 mxTableBox->GetGrid().Execute( CSVCMD_SETFIRSTIMPORTLINE, rNumField.get_value() - 1);
893}
894
895IMPL_LINK(ScImportAsciiDlg, LbColTypeHdl, weld::ComboBox&, rListBox, void)
896{
897 if (&rListBox == mxLbType.get())
898 mxTableBox->GetGrid().Execute(CSVCMD_SETCOLUMNTYPE, rListBox.get_active());
899}
900
902{
903 // Checking the separator can only be done once for the very first time
904 // when the dialog wasn't already presented to the user.
905 // As a side effect this has the benefit that the check is only done on the
906 // first set of visible lines.
907 mbDetectSep = (mbDetectSep && !mxRbFixed->get_active()
908 && (!mxCkbTab->get_active() || !mxCkbSemicolon->get_active()
909 || !mxCkbComma->get_active() || !mxCkbSpace->get_active()));
910 sal_Unicode cDetectSep = (mbDetectSep ? 0 : 0xffff);
911
912 sal_Int32 nBaseLine = mxTableBox->GetGrid().GetFirstVisLine();
913 sal_Int32 nRead = mxTableBox->GetGrid().GetVisLineCount();
914 // If mnRowPosCount==0, this is an initializing call, read ahead for row
915 // count and resulting scroll bar size and position to be able to scroll at
916 // all. When adding lines, read only the amount of next lines to be
917 // displayed.
918 if (!mnRowPosCount || nRead > CSV_PREVIEW_LINES)
919 nRead = CSV_PREVIEW_LINES;
920
921 sal_Int32 i;
922 for (i = 0; i < nRead; i++)
923 {
924 if (!GetLine( nBaseLine + i, maPreviewLine[i], cDetectSep))
925 break;
926 }
927 for (; i < CSV_PREVIEW_LINES; i++)
928 maPreviewLine[i].clear();
929
930 if (mbDetectSep)
931 {
932 mbDetectSep = false;
933 if (cDetectSep)
934 {
935 // Expect separator to be appended by now so all subsequent
936 // GetLine()/ReadCsvLine() actually used it.
937 assert(maFieldSeparators.endsWith(OUStringChar(cDetectSep)));
938 // Preselect separator in UI.
939 switch (cDetectSep)
940 {
941 case '\t': mxCkbTab->set_active(true); break;
942 case ';': mxCkbSemicolon->set_active(true); break;
943 case ',': mxCkbComma->set_active(true); break;
944 case ' ': mxCkbSpace->set_active(true); break;
945 }
946 }
947 }
948
949 mxTableBox->GetGrid().Execute( CSVCMD_SETLINECOUNT, mnRowPosCount);
950 bool bMergeSep = mxCkbAsOnce->get_active();
951 bool bRemoveSpace = mxCkbRemoveSpace->get_active();
952 mxTableBox->SetUniStrings( maPreviewLine, maFieldSeparators, mcTextSep, bMergeSep, bRemoveSpace );
953}
954
955IMPL_LINK( ScImportAsciiDlg, ColTypeHdl, ScCsvTableBox&, rTableBox, void )
956{
957 sal_Int32 nType = rTableBox.GetSelColumnType();
958 sal_Int32 nTypeCount = mxLbType->get_count();
959 bool bEmpty = (nType == CSV_TYPE_MULTI);
960 bool bEnable = ((0 <= nType) && (nType < nTypeCount)) || bEmpty;
961
962 mxLbType->set_sensitive( bEnable );
963
964 if (bEmpty)
965 mxLbType->set_active(-1);
966 else if (bEnable)
967 mxLbType->set_active(nType);
968}
969
970/* 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:1849
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:2731
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