LibreOffice Module sc (master)  1
difimp.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 #include <svl/numformat.hxx>
21 #include <svl/zforlist.hxx>
22 #include <tools/stream.hxx>
23 #include <osl/diagnose.h>
24 #include <dif.hxx>
25 #include <docpool.hxx>
26 #include <document.hxx>
27 #include <fprogressbar.hxx>
28 #include <ftools.hxx>
29 #include <patattr.hxx>
30 #include <scerrors.hxx>
31 #include <scitems.hxx>
32 #include <stringutil.hxx>
33 #include <table.hxx>
34 #include <memory>
35 
36 const sal_Unicode pKeyTABLE[] = { 'T', 'A', 'B', 'L', 'E', 0 };
37 const sal_Unicode pKeyVECTORS[] = { 'V', 'E', 'C', 'T', 'O', 'R', 'S', 0 };
38 const sal_Unicode pKeyTUPLES[] = { 'T', 'U', 'P', 'L', 'E', 'S', 0 };
39 const sal_Unicode pKeyDATA[] = { 'D', 'A', 'T', 'A', 0 };
40 const sal_Unicode pKeyBOT[] = { 'B', 'O', 'T', 0 };
41 const sal_Unicode pKeyEOD[] = { 'E', 'O', 'D', 0 };
42 const sal_Unicode pKeyERROR[] = { 'E', 'R', 'R', 'O', 'R', 0 };
43 const sal_Unicode pKeyTRUE[] = { 'T', 'R', 'U', 'E', 0 };
44 const sal_Unicode pKeyFALSE[] = { 'F', 'A', 'L', 'S', 'E', 0 };
45 const sal_Unicode pKeyNA[] = { 'N', 'A', 0 };
46 const sal_Unicode pKeyV[] = { 'V', 0 };
47 const sal_Unicode pKey1_0[] = { '1', ',', '0', 0 };
48 
50  const rtl_TextEncoding eVon )
51 {
52  DifParser aDifParser( rIn, *pDoc, eVon );
53 
54  SCTAB nBaseTab = rInsPos.Tab();
55 
56  TOPIC eTopic = T_UNKNOWN;
57  bool bSyntErrWarn = false;
58  bool bOverflowWarn = false;
59 
60  OUStringBuffer& rData = aDifParser.m_aData;
61 
62  rIn.Seek( 0 );
63 
64  ScfStreamProgressBar aPrgrsBar( rIn, pDoc->GetDocumentShell() );
65 
66  while( eTopic != T_DATA && eTopic != T_END )
67  {
68  eTopic = aDifParser.GetNextTopic();
69 
70  aPrgrsBar.Progress();
71 
72  const bool bData = !rData.isEmpty();
73 
74  switch( eTopic )
75  {
76  case T_TABLE:
77  {
78  if( aDifParser.nVector != 0 || aDifParser.nVal != 1 )
79  bSyntErrWarn = true;
80  if( bData )
81  pDoc->RenameTab(nBaseTab, rData.toString());
82  }
83  break;
84  case T_VECTORS:
85  {
86  if( aDifParser.nVector != 0 )
87  bSyntErrWarn = true;
88  }
89  break;
90  case T_TUPLES:
91  {
92  if( aDifParser.nVector != 0 )
93  bSyntErrWarn = true;
94  }
95  break;
96  case T_DATA:
97  {
98  if( aDifParser.nVector != 0 || aDifParser.nVal != 0 )
99  bSyntErrWarn = true;
100  }
101  break;
102  case T_LABEL:
103  case T_COMMENT:
104  case T_SIZE:
105  case T_PERIODICITY:
106  case T_MAJORSTART:
107  case T_MINORSTART:
108  case T_TRUELENGTH:
109  case T_UINITS:
110  case T_DISPLAYUNITS:
111  case T_END:
112  case T_UNKNOWN:
113  break;
114  default:
115  OSL_FAIL( "ScImportDif - missing enum" );
116  }
117 
118  }
119 
120  if( eTopic == T_DATA )
121  { // data starts here
122  SCCOL nBaseCol = rInsPos.Col();
123 
124  SCCOL nColCnt = SCCOL_MAX;
125  SCROW nRowCnt = rInsPos.Row();
126  DifAttrCache aAttrCache;
127 
128  DATASET eCurrent = D_UNKNOWN;
129 
130  ScSetStringParam aStrParam; // used to set string value without number detection.
131  aStrParam.setTextInput();
132 
133  while( eCurrent != D_EOD )
134  {
135  eCurrent = aDifParser.GetNextDataset();
136 
137  aPrgrsBar.Progress();
138  ScAddress aPos(nColCnt, nRowCnt, nBaseTab);
139 
140  OUString aData = rData.toString();
141 
142  switch( eCurrent )
143  {
144  case D_BOT:
145  if( nColCnt < SCCOL_MAX )
146  nRowCnt++;
147  nColCnt = nBaseCol;
148  break;
149  case D_EOD:
150  break;
151  case D_NUMERIC: // Number cell
152  if( nColCnt == SCCOL_MAX )
153  nColCnt = nBaseCol;
154 
155  if( pDoc->ValidCol(nColCnt) && pDoc->ValidRow(nRowCnt) )
156  {
157  pDoc->EnsureTable(nBaseTab);
158 
159  if( DifParser::IsV( aData.getStr() ) )
160  {
161  pDoc->SetValue(aPos, aDifParser.fVal);
162  aAttrCache.SetNumFormat( pDoc, nColCnt, nRowCnt,
163  aDifParser.nNumFormat );
164  }
165  else if( aData == pKeyTRUE || aData == pKeyFALSE )
166  {
167  pDoc->SetValue(aPos, aDifParser.fVal);
168  aAttrCache.SetNumFormat( pDoc, nColCnt, nRowCnt,
169  aDifParser.nNumFormat );
170  }
171  else if( aData == pKeyNA || aData == pKeyERROR )
172  {
173  pDoc->SetString(aPos, aData, &aStrParam);
174  }
175  else
176  {
177  OUString aTmp = "#IND:" + aData + "?";
178  pDoc->SetString(aPos, aTmp, &aStrParam);
179  }
180  }
181  else
182  bOverflowWarn = true;
183 
184  nColCnt++;
185  break;
186  case D_STRING: // Text cell
187  if( nColCnt == SCCOL_MAX )
188  nColCnt = nBaseCol;
189 
190  if( pDoc->ValidCol(nColCnt) && pDoc->ValidRow(nRowCnt) )
191  {
192  if (!aData.isEmpty())
193  {
194  pDoc->EnsureTable(nBaseTab);
195  pDoc->SetTextCell(aPos, aData);
196  }
197  }
198  else
199  bOverflowWarn = true;
200 
201  nColCnt++;
202  break;
203  case D_UNKNOWN:
204  break;
205  case D_SYNT_ERROR:
206  break;
207  default:
208  OSL_FAIL( "ScImportDif - missing enum" );
209  }
210  }
211 
212  aAttrCache.Apply( *pDoc, nBaseTab );
213  }
214  else
215  return SCERR_IMPORT_FORMAT;
216 
217  if( bSyntErrWarn )
218 
219  // FIXME: Add proper warning!
221 
222  else if( bOverflowWarn )
224  else
225  return ERRCODE_NONE;
226 }
227 
228 DifParser::DifParser( SvStream& rNewIn, const ScDocument& rDoc, rtl_TextEncoding eCharSet )
229  : fVal(0.0)
230  , nVector(0)
231  , nVal(0)
232  , nNumFormat(0)
233  , pNumFormatter(rDoc.GetFormatTable())
234  , rIn(rNewIn)
235 {
236  if ( rIn.GetStreamCharSet() != eCharSet )
237  {
238  OSL_FAIL( "CharSet passed overrides and modifies StreamCharSet" );
239  rIn.SetStreamCharSet( eCharSet );
240  }
241  rIn.StartReadingUnicodeText( eCharSet );
242 }
243 
245 {
246  enum STATE { S_VectorVal, S_Data, S_END, S_START, S_UNKNOWN, S_ERROR_L2 };
247 
248  static const sal_Unicode pKeyLABEL[] = { 'L', 'A', 'B', 'E', 'L', 0 };
249  static const sal_Unicode pKeyCOMMENT[] = { 'C', 'O', 'M', 'M', 'E', 'N', 'T', 0 };
250  static const sal_Unicode pKeySIZE[] = { 'S', 'I', 'Z', 'E', 0 };
251  static const sal_Unicode pKeyPERIODICITY[] = { 'P', 'E', 'R', 'I', 'O', 'D', 'I', 'C', 'I', 'T', 'Y', 0 };
252  static const sal_Unicode pKeyMAJORSTART[] = { 'M', 'A', 'J', 'O', 'R', 'S', 'T', 'A', 'R', 'T', 0 };
253  static const sal_Unicode pKeyMINORSTART[] = { 'M', 'I', 'N', 'O', 'R', 'S', 'T', 'A', 'R', 'T', 0 };
254  static const sal_Unicode pKeyTRUELENGTH[] = { 'T', 'R', 'U', 'E', 'L', 'E', 'N', 'G', 'T', 'H', 0 };
255  static const sal_Unicode pKeyUINITS[] = { 'U', 'I', 'N', 'I', 'T', 'S', 0 };
256  static const sal_Unicode pKeyDISPLAYUNITS[] = { 'D', 'I', 'S', 'P', 'L', 'A', 'Y', 'U', 'N', 'I', 'T', 'S', 0 };
257  static const sal_Unicode pKeyUNKNOWN[] = { 0 };
258 
259  static const sal_Unicode* ppKeys[] =
260  {
261  pKeyTABLE, // 0
262  pKeyVECTORS,
263  pKeyTUPLES,
264  pKeyDATA,
265  pKeyLABEL,
266  pKeyCOMMENT, // 5
267  pKeySIZE,
268  pKeyPERIODICITY,
269  pKeyMAJORSTART,
270  pKeyMINORSTART,
271  pKeyTRUELENGTH, // 10
272  pKeyUINITS,
273  pKeyDISPLAYUNITS,
274  pKeyUNKNOWN // 13
275  };
276 
277  static const TOPIC pTopics[] =
278  {
279  T_TABLE, // 0
280  T_VECTORS,
281  T_TUPLES,
282  T_DATA,
283  T_LABEL,
284  T_COMMENT, // 5
285  T_SIZE,
287  T_MAJORSTART,
288  T_MINORSTART,
289  T_TRUELENGTH, // 10
290  T_UINITS,
292  T_UNKNOWN // 13
293  };
294 
295  STATE eS = S_START;
296  OUString aLine;
297 
298  nVector = 0;
299  nVal = 0;
300  TOPIC eRet = T_UNKNOWN;
301 
302  while( eS != S_END )
303  {
304  if( !ReadNextLine( aLine ) )
305  {
306  eS = S_END;
307  eRet = T_END;
308  }
309 
310  switch( eS )
311  {
312  case S_START:
313  {
314  const sal_Unicode* pRef;
315  sal_uInt16 nCnt = 0;
316  bool bSearch = true;
317 
318  pRef = ppKeys[ nCnt ];
319 
320  while( bSearch )
321  {
322  if( aLine == pRef )
323  {
324  eRet = pTopics[ nCnt ];
325  bSearch = false;
326  }
327  else
328  {
329  nCnt++;
330  pRef = ppKeys[ nCnt ];
331  if( !*pRef )
332  bSearch = false;
333  }
334  }
335 
336  if( *pRef )
337  eS = S_VectorVal;
338  else
339  eS = S_UNKNOWN;
340  }
341  break;
342  case S_VectorVal:
343  {
344  const sal_Unicode* pCur = aLine.getStr();
345 
346  pCur = ScanIntVal( pCur, nVector );
347 
348  if( pCur && *pCur == ',' )
349  {
350  pCur++;
351  ScanIntVal( pCur, nVal );
352  eS = S_Data;
353  }
354  else
355  eS = S_ERROR_L2;
356  }
357  break;
358  case S_Data:
359  OSL_ENSURE( aLine.getLength() >= 2,
360  "+GetNextTopic(): <String> is too short!" );
361  if( aLine.getLength() > 2 )
362  m_aData.append(aLine.subView(1, aLine.getLength() - 2));
363  else
364  m_aData.truncate();
365  eS = S_END;
366  break;
367  case S_END:
368  OSL_FAIL( "DifParser::GetNextTopic - unexpected state" );
369  break;
370  case S_UNKNOWN:
371  // skip 2 lines
372  ReadNextLine( aLine );
373  [[fallthrough]];
374  case S_ERROR_L2: // error happened in line 2
375  // skip 1 line
376  ReadNextLine( aLine );
377  eS = S_END;
378  break;
379  default:
380  OSL_FAIL( "DifParser::GetNextTopic - missing enum" );
381  }
382  }
383 
384  return eRet;
385 }
386 
387 static void lcl_DeEscapeQuotesDif(OUStringBuffer& rString)
388 {
389  // Special handling for DIF import: Escaped (duplicated) quotes are resolved.
390  // Single quote characters are left in place because older versions didn't
391  // escape quotes in strings (and Excel doesn't when using the clipboard).
392  // The quotes around the string are removed before this function is called.
393 
394  rString = rString.toString().replaceAll("\"\"", "\"");
395 }
396 
397 // Determine if passed in string is numeric data and set fVal/nNumFormat if so
398 DATASET DifParser::GetNumberDataset( const sal_Unicode* pPossibleNumericData )
399 {
400  DATASET eRet = D_SYNT_ERROR;
401 
402  OSL_ENSURE( pNumFormatter, "-DifParser::GetNumberDataset(): No Formatter, more fun!" );
403  OUString aTestVal( pPossibleNumericData );
404  sal_uInt32 nFormat = 0;
405  double fTmpVal;
406  if( pNumFormatter->IsNumberFormat( aTestVal, nFormat, fTmpVal ) )
407  {
408  fVal = fTmpVal;
409  nNumFormat = nFormat;
410  eRet = D_NUMERIC;
411  }
412  else
413  eRet = D_SYNT_ERROR;
414 
415  return eRet;
416 }
417 
418 bool DifParser::ReadNextLine( OUString& rStr )
419 {
420  if( aLookAheadLine.isEmpty() )
421  {
423  }
424  else
425  {
426  rStr = aLookAheadLine;
427  aLookAheadLine.clear();
428  return true;
429  }
430 }
431 
432 // Look ahead in the stream to determine if the next line is the first line of
433 // a valid data record structure
435 {
436  const sal_Unicode* pCurrentBuffer;
437  bool bValidStructure = false;
438 
439  OSL_ENSURE( aLookAheadLine.isEmpty(), "*DifParser::LookAhead(): LookAhead called twice in a row" );
441 
442  pCurrentBuffer = aLookAheadLine.getStr();
443 
444  switch( *pCurrentBuffer )
445  {
446  case '-': // Special Datatype
447  pCurrentBuffer++;
448 
449  if( Is1_0( pCurrentBuffer ) )
450  {
451  bValidStructure = true;
452  }
453  break;
454  case '0': // Numeric Data
455  pCurrentBuffer++;
456  if( *pCurrentBuffer == ',' )
457  {
458  pCurrentBuffer++;
459  bValidStructure = ( GetNumberDataset(pCurrentBuffer) != D_SYNT_ERROR );
460  }
461  break;
462  case '1': // String Data
463  if( Is1_0( aLookAheadLine.getStr() ) )
464  {
465  bValidStructure = true;
466  }
467  break;
468  }
469  return bValidStructure;
470 }
471 
473 {
474  DATASET eRet = D_UNKNOWN;
475  OUString aLine;
476  const sal_Unicode* pCurrentBuffer;
477 
478  ReadNextLine( aLine );
479 
480  pCurrentBuffer = aLine.getStr();
481 
482  switch( *pCurrentBuffer )
483  {
484  case '-': // Special Datatype
485  pCurrentBuffer++;
486 
487  if( Is1_0( pCurrentBuffer ) )
488  {
489  ReadNextLine( aLine );
490  if( IsBOT( aLine.getStr() ) )
491  eRet = D_BOT;
492  else if( IsEOD( aLine.getStr() ) )
493  eRet = D_EOD;
494  }
495  break;
496  case '0': // Numeric Data
497  pCurrentBuffer++; // value in fVal, 2. line in m_aData
498  if( *pCurrentBuffer == ',' )
499  {
500  pCurrentBuffer++;
501  eRet = GetNumberDataset(pCurrentBuffer);
502  OUString aTmpLine;
503  ReadNextLine( aTmpLine );
504  if ( eRet == D_SYNT_ERROR )
505  { // for broken records write "#ERR: data" to cell
506  m_aData = OUString::Concat("#ERR: ") + pCurrentBuffer + " (" + aTmpLine + ")";
507  eRet = D_STRING;
508  }
509  else
510  {
511  m_aData = aTmpLine;
512  }
513  }
514  break;
515  case '1': // String Data
516  if( Is1_0( aLine.getStr() ) )
517  {
518  ReadNextLine( aLine );
519  sal_Int32 nLineLength = aLine.getLength();
520  const sal_Unicode* pLine = aLine.getStr();
521 
522  if( nLineLength >= 1 && *pLine == '"' )
523  {
524  // Quotes are not always escaped (duplicated), see lcl_DeEscapeQuotesDif
525  // A look ahead into the next line is needed in order to deal with
526  // multiline strings containing quotes
527  if( LookAhead() )
528  {
529  // Single line string
530  if( nLineLength >= 2 && pLine[nLineLength - 1] == '"' )
531  {
532  m_aData = aLine.subView( 1, nLineLength - 2 );
534  eRet = D_STRING;
535  }
536  }
537  else
538  {
539  // Multiline string
540  m_aData = aLine.subView( 1 );
541  bool bContinue = true;
542  while ( bContinue )
543  {
544  m_aData.append("\n");
545  bContinue = !rIn.eof() && ReadNextLine( aLine );
546  if( bContinue )
547  {
548  nLineLength = aLine.getLength();
549  if( nLineLength >= 1 )
550  {
551  pLine = aLine.getStr();
552  bContinue = !LookAhead();
553  if( bContinue )
554  {
555  m_aData.append(aLine);
556  }
557  else if( pLine[nLineLength - 1] == '"' )
558  {
559  m_aData.append(aLine.subView(0, nLineLength -1));
561  eRet = D_STRING;
562  }
563  }
564  }
565  }
566  }
567  }
568  }
569  break;
570  }
571 
572  if( eRet == D_UNKNOWN )
573  ReadNextLine( aLine );
574 
575  if( rIn.eof() )
576  eRet = D_EOD;
577 
578  return eRet;
579 }
580 
581 const sal_Unicode* DifParser::ScanIntVal( const sal_Unicode* pStart, sal_uInt32& rRet )
582 {
583  // eat leading whitespace, not specified, but seen in the wild
584  while (*pStart == ' ' || *pStart == '\t')
585  ++pStart;
586 
587  sal_Unicode cCurrent = *pStart;
588 
589  if( IsNumber( cCurrent ) )
590  rRet = static_cast<sal_uInt32>( cCurrent - '0' );
591  else
592  return nullptr;
593 
594  pStart++;
595  cCurrent = *pStart;
596 
597  while( IsNumber( cCurrent ) && rRet < ( 0xFFFFFFFF / 10 ) )
598  {
599  rRet *= 10;
600  rRet += static_cast<sal_uInt32>( cCurrent - '0' );
601 
602  pStart++;
603  cCurrent = *pStart;
604  }
605 
606  return pStart;
607 }
608 
610  : mpCurrent(nullptr)
611 {
612 }
613 
614 void DifColumn::SetNumFormat( const ScDocument* pDoc, SCROW nRow, const sal_uInt32 nNumFormat )
615 {
616  OSL_ENSURE( pDoc->ValidRow(nRow), "*DifColumn::SetNumFormat(): Row too big!" );
617 
618  if( nNumFormat > 0 )
619  {
620  if(mpCurrent)
621  {
622  OSL_ENSURE( nRow > 0,
623  "*DifColumn::SetNumFormat(): more cannot be zero!" );
624  OSL_ENSURE( nRow > mpCurrent->nEnd,
625  "*DifColumn::SetNumFormat(): start from scratch?" );
626 
627  if( mpCurrent->nNumFormat == nNumFormat && mpCurrent->nEnd == nRow - 1 )
628  mpCurrent->nEnd = nRow;
629  else
630  NewEntry( nRow, nNumFormat );
631  }
632  else
633  NewEntry(nRow,nNumFormat );
634  }
635  else
636  mpCurrent = nullptr;
637 }
638 
639 void DifColumn::NewEntry( const SCROW nPos, const sal_uInt32 nNumFormat )
640 {
641  maEntries.emplace_back();
642  mpCurrent = &maEntries.back();
643  mpCurrent->nStart = mpCurrent->nEnd = nPos;
644  mpCurrent->nNumFormat = nNumFormat;
645 
646 }
647 
648 void DifColumn::Apply( ScDocument& rDoc, const SCCOL nCol, const SCTAB nTab )
649 {
650  ScPatternAttr aAttr( rDoc.GetPool() );
651  SfxItemSet &rItemSet = aAttr.GetItemSet();
652 
653  for (const auto& rEntry : maEntries)
654  {
655  OSL_ENSURE( rEntry.nNumFormat > 0,
656  "+DifColumn::Apply(): Number format must not be 0!" );
657 
658  rItemSet.Put( SfxUInt32Item( ATTR_VALUE_FORMAT, rEntry.nNumFormat ) );
659 
660  rDoc.ApplyPatternAreaTab( nCol, rEntry.nStart, nCol, rEntry.nEnd, nTab, aAttr );
661 
662  rItemSet.ClearItem();
663  }
664 }
665 
667 {
668 }
669 
671 {
672 }
673 
674 void DifAttrCache::SetNumFormat( const ScDocument* pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat )
675 {
676  OSL_ENSURE( pDoc->ValidCol(nCol), "-DifAttrCache::SetNumFormat(): Col too big!" );
677 
678  if( !maColMap.count(nCol) )
679  maColMap[ nCol ].reset( new DifColumn );
680 
681  maColMap[ nCol ]->SetNumFormat( pDoc, nRow, nNumFormat );
682 }
683 
685 {
686  for( SCCOL nCol : rDoc.GetColumnsRange(nTab, 0, rDoc.MaxCol()) )
687  {
688  if( maColMap.count(nCol) )
689  maColMap[ nCol ]->Apply( rDoc, nCol, nTab );
690  }
691 }
692 
693 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static void lcl_DeEscapeQuotesDif(OUStringBuffer &rString)
Definition: difimp.cxx:387
static bool IsBOT(const sal_Unicode *pRef)
Definition: dif.hxx:91
TOPIC GetNextTopic()
Definition: difimp.cxx:244
A simplified progress bar based on the stream position of an existing stream.
Store parameters used in the ScDocument::SetString() method.
Definition: stringutil.hxx:34
const sal_Unicode pKeyTABLE[]
Definition: difimp.cxx:36
Definition: dif.hxx:50
SCROW Row() const
Definition: address.hxx:261
const sal_Unicode pKeyFALSE[]
Definition: difimp.cxx:44
DATASET
Definition: dif.hxx:56
void setTextInput()
Call this whenever you need to unconditionally set input as text, no matter what the input is...
Definition: stringutil.cxx:38
bool ReadUniOrByteStringLine(OUString &rStr, rtl_TextEncoding eSrcCharSet, sal_Int32 nMaxCodepointsToRead=0xFFFE)
const sal_Unicode pKeyBOT[]
Definition: difimp.cxx:40
OUStringBuffer m_aData
Definition: dif.hxx:61
const sal_Unicode pKeyVECTORS[]
Definition: difimp.cxx:37
const sal_Unicode pKeyV[]
Definition: difimp.cxx:46
const SCCOL SCCOL_MAX
Definition: address.hxx:56
static bool IsNumber(const sal_Unicode cChar)
Definition: dif.hxx:121
Definition: dif.hxx:51
#define SCWARN_IMPORT_RANGE_OVERFLOW
Definition: scerrors.hxx:61
const ContentProperties & rData
sal_uInt64 Seek(sal_uInt64 nPos)
Definition: dif.hxx:56
SC_DLLPUBLIC void SetValue(SCCOL nCol, SCROW nRow, SCTAB nTab, const double &rVal)
Definition: document.cxx:3489
const sal_Unicode pKeyERROR[]
Definition: difimp.cxx:42
virtual ErrCode ScImportDif(SvStream &, ScDocument *, const ScAddress &rInsPos, const rtl_TextEncoding eSrc) override
Definition: difimp.cxx:49
std::vector< ENTRY > maEntries
Definition: dif.hxx:138
SC_DLLPUBLIC void SetTextCell(const ScAddress &rPos, const OUString &rStr)
Call this if you are not sure whether to put this as an edit text or a simple text.
Definition: document.cxx:3462
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6087
sal_uInt16 sal_Unicode
SC_DLLPUBLIC bool RenameTab(SCTAB nTab, const OUString &rName, bool bExternalDocument=false)
Definition: document.cxx:853
bool eof() const
void StartReadingUnicodeText(rtl_TextEncoding eReadBomCharSet)
void SetNumFormat(const ScDocument *pDoc, const SCCOL nCol, const SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:674
DATASET GetNextDataset()
Definition: difimp.cxx:472
Definition: dif.hxx:50
const sal_Unicode pKey1_0[]
Definition: difimp.cxx:47
SCTAB Tab() const
Definition: address.hxx:270
bool LookAhead()
Definition: difimp.cxx:434
SvStream & rIn
Definition: dif.hxx:68
const sal_Unicode pKeyTUPLES[]
Definition: difimp.cxx:38
constexpr OUStringLiteral aData
SCROW nStart
Definition: dif.hxx:133
SC_DLLPUBLIC bool SetString(SCCOL nCol, SCROW nRow, SCTAB nTab, const OUString &rString, const ScSetStringParam *pParam=nullptr)
Definition: document.cxx:3394
static bool Is1_0(const sal_Unicode *pRef)
Definition: dif.hxx:107
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:871
TOPIC
Definition: dif.hxx:47
sal_uInt32 nVal
Definition: dif.hxx:64
sal_Int16 SCCOL
Definition: types.hxx:21
bool ValidCol(SCCOL nCol) const
Definition: document.hxx:874
OUString aLookAheadLine
Definition: dif.hxx:69
std::map< SCCOL, std::unique_ptr< DifColumn > > maColMap
Definition: dif.hxx:163
Definition: dif.hxx:50
bool IsNumberFormat(const OUString &sString, sal_uInt32 &F_Index, double &fOutNumber, SvNumInputOptions eInputOptions=SvNumInputOptions::NONE)
void SetNumFormat(const ScDocument *pDoc, SCROW nRow, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:614
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALUE_FORMAT(146)
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4817
const sal_Unicode pKeyDATA[]
Definition: difimp.cxx:39
sal_uInt32 nVector
Definition: dif.hxx:63
SCCOL Col() const
Definition: address.hxx:266
SC_DLLPUBLIC void EnsureTable(SCTAB nTab)
Definition: documen2.cxx:540
static bool IsV(const sal_Unicode *pRef)
Definition: dif.hxx:115
Definition: dif.hxx:50
sal_Int32 SCROW
Definition: types.hxx:17
void NewEntry(const SCROW nPos, const sal_uInt32 nNumFormat)
Definition: difimp.cxx:639
sal_uInt32 nNumFormat
Definition: dif.hxx:132
bool ValidRow(SCROW nRow) const
Definition: document.hxx:875
Definition: dif.hxx:56
const sal_Unicode pKeyEOD[]
Definition: difimp.cxx:41
ENTRY * mpCurrent
Definition: dif.hxx:137
#define ERRCODE_NONE
DifParser(SvStream &, const ScDocument &, rtl_TextEncoding)
Definition: difimp.cxx:228
void SetStreamCharSet(rtl_TextEncoding eCharSet)
rtl_TextEncoding GetStreamCharSet() const
SvNumberFormatter * pNumFormatter
Definition: dif.hxx:67
STATE
#define SCERR_IMPORT_FORMAT
Definition: scerrors.hxx:33
Definition: dif.hxx:50
SC_DLLPUBLIC ScColumnsRange GetColumnsRange(SCTAB nTab, SCCOL nColBegin, SCCOL nColEnd) const
Definition: document.cxx:2537
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1057
SCROW nEnd
Definition: dif.hxx:134
Definition: dif.hxx:56
void Apply(ScDocument &rDoc, const SCCOL nCol, const SCTAB nTab)
Definition: difimp.cxx:648
DifColumn()
Definition: difimp.cxx:609
sal_uInt32 nNumFormat
Definition: dif.hxx:65
static bool IsEOD(const sal_Unicode *pRef)
Definition: dif.hxx:99
const sal_Unicode pKeyTRUE[]
Definition: difimp.cxx:43
static const sal_Unicode * ScanIntVal(const sal_Unicode *pStart, sal_uInt32 &rRet)
Definition: difimp.cxx:581
const sal_Unicode pKeyNA[]
Definition: difimp.cxx:45
void Apply(ScDocument &, SCTAB nTab)
Definition: difimp.cxx:684
sal_Int16 SCTAB
Definition: types.hxx:22
DATASET GetNumberDataset(const sal_Unicode *pPossibleNumericData)
Definition: difimp.cxx:398
Definition: dif.hxx:53
double fVal
Definition: dif.hxx:62
bool ReadNextLine(OUString &rStr)
Definition: difimp.cxx:418