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