LibreOffice Module sc (master)  1
xmlcelli.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 <memory>
21 #include "xmlcelli.hxx"
22 #include "xmlimprt.hxx"
23 #include "xmlannoi.hxx"
24 #include <global.hxx>
25 #include <cellvalue.hxx>
26 #include <document.hxx>
27 #include <docuno.hxx>
28 #include <postit.hxx>
29 #include <sheetdata.hxx>
30 #include <cellform.hxx>
31 #include <validat.hxx>
32 #include <patattr.hxx>
33 #include <scitems.hxx>
34 #include <docpool.hxx>
35 
38 #include "celltextparacontext.hxx"
40 
41 #include <arealink.hxx>
42 #include <sfx2/linkmgr.hxx>
43 #include <scerrors.hxx>
44 #include <editutil.hxx>
45 #include <formulacell.hxx>
46 #include "editattributemap.hxx"
47 #include <tokenarray.hxx>
48 #include <scmatrix.hxx>
49 #include <documentimport.hxx>
50 #include <externalrefmgr.hxx>
51 
52 #include <xmloff/maptype.hxx>
53 #include <xmloff/xmltkmap.hxx>
54 #include <xmloff/xmltoken.hxx>
55 #include <xmloff/xmlprmap.hxx>
56 #include <xmloff/xmluconv.hxx>
57 #include <xmloff/families.hxx>
58 #include <xmloff/xmlnamespace.hxx>
59 #include <xmloff/prstylei.hxx>
60 #include <xmloff/xmlimppr.hxx>
61 #include <svl/zforlist.hxx>
62 #include <svx/svdocapt.hxx>
63 #include <editeng/eeitem.hxx>
64 #include <editeng/outlobj.hxx>
65 #include <editeng/wghtitem.hxx>
66 #include <editeng/colritem.hxx>
67 #include <editeng/fhgtitem.hxx>
68 #include <editeng/postitem.hxx>
69 #include <editeng/flditem.hxx>
70 #include <editeng/fontitem.hxx>
71 #include <editeng/udlnitem.hxx>
72 #include <editeng/wrlmitem.hxx>
76 #include <editeng/contouritem.hxx>
77 #include <editeng/shdditem.hxx>
78 #include <editeng/kernitem.hxx>
79 #include <editeng/autokernitem.hxx>
82 #include <editeng/langitem.hxx>
83 #include <svx/unoapi.hxx>
84 #include <svl/sharedstringpool.hxx>
85 #include <sax/tools/converter.hxx>
86 #include <sax/fastattribs.hxx>
87 
88 #include <com/sun/star/util/NumberFormat.hpp>
89 
90 #include <com/sun/star/sheet/ValidationType.hpp>
91 #include <com/sun/star/sheet/ValidationAlertStyle.hpp>
92 
93 #include <rtl/ustrbuf.hxx>
94 #include <sal/log.hxx>
95 #include <i18nlangtag/lang.h>
96 
98 #include <comphelper/lok.hxx>
99 
100 using namespace com::sun::star;
101 using namespace xmloff::token;
102 
104  maItemSet(rEditEngine.GetEmptyItemSet()) {}
105 
106 ScXMLTableRowCellContext::Field::Field(std::unique_ptr<SvxFieldData> pData) : mpData(std::move(pData)) {}
107 
109 {
110 }
111 
114  const bool bTempIsCovered,
115  const sal_Int32 nTempRepeatedRows ) :
116  ScXMLImportContext( rImport ),
117  mpEditEngine(GetScImport().GetEditEngine()),
118  mnCurParagraph(0),
119  fValue(0.0),
120  nMergedRows(1),
121  nMatrixRows(0),
122  nRepeatedRows(nTempRepeatedRows),
123  nMergedCols(1),
124  nMatrixCols(0),
125  nColsRepeated(1),
126  rXMLImport(rImport),
127  eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
128  nCellType(util::NumberFormat::TEXT),
129  bIsMerged(false),
130  bIsMatrix(false),
131  bIsCovered(bTempIsCovered),
132  bIsEmpty(true),
133  mbNewValueType(false),
134  mbErrorValue(false),
135  bSolarMutexLocked(false),
136  bFormulaTextResult(false),
137  mbPossibleErrorCell(false),
139  mbEditEngineHasText(false),
140  mbHasFormatRuns(false),
141  mbHasStyle(false),
143 {
144  rtl::math::setNan(&fValue); // NaN by default
145 
146  rXMLImport.GetTables().AddColumn(bTempIsCovered);
147 
148  std::optional<OUString> xStyleName;
149  std::optional<OUString> xCurrencySymbol;
150  if ( rAttrList.is() )
151  {
152  for (auto &it : *rAttrList)
153  {
154  switch ( it.getToken() )
155  {
157  xStyleName = it.toString();
158  mbHasStyle = true;
159  break;
161  OSL_ENSURE(!maContentValidationName, "here should be only one Validation Name");
162  if (!it.isEmpty())
163  maContentValidationName = it.toString();
164  break;
166  bIsMerged = true;
167  nMergedRows = static_cast<SCROW>(it.toInt32());
168  break;
170  bIsMerged = true;
171  nMergedCols = static_cast<SCCOL>(it.toInt32());
172  break;
174  bIsMatrix = true;
175  nMatrixCols = static_cast<SCCOL>(it.toInt32());
176  break;
178  bIsMatrix = true;
179  nMatrixRows = static_cast<SCROW>(it.toInt32());
180  break;
182  nColsRepeated = static_cast<SCCOL>(std::min<sal_Int32>( MAXCOLCOUNT,
183  std::max( it.toInt32(), static_cast<sal_Int32>(1) ) ));
184  break;
186  nCellType = ScXMLImport::GetCellType(it.toCString(), it.getLength());
187  bIsEmpty = false;
188  break;
189  case XML_ELEMENT( CALC_EXT, XML_VALUE_TYPE ):
190  if(it.isString( "error" ) )
191  mbErrorValue = true;
192  else
193  nCellType = ScXMLImport::GetCellType(it.toCString(), it.getLength());
194  bIsEmpty = false;
195  mbNewValueType = true;
196  break;
197  case XML_ELEMENT( OFFICE, XML_VALUE ):
198  {
199  if (!it.isEmpty())
200  {
201  fValue = it.toDouble();
202  bIsEmpty = false;
203 
204  //if office:value="0", let's get the text:p in case this is
205  //a special case in HasSpecialCaseFormulaText(). If it
206  //turns out not to be a special case, we'll use the 0 value.
207  if(fValue == 0.0)
208  bFormulaTextResult = true;
209  }
210  }
211  break;
213  {
214  if (!it.isEmpty() && rXMLImport.SetNullDateOnUnitConverter())
215  {
217  bIsEmpty = false;
218  }
219  }
220  break;
222  {
223  if (!it.isEmpty())
224  {
226  bIsEmpty = false;
227  }
228  }
229  break;
231  {
232  if (!it.isEmpty())
233  {
234  OSL_ENSURE(!maStringValue, "here should be only one string value");
235  maStringValue = it.toString();
236  bIsEmpty = false;
237  }
238  }
239  break;
241  {
242  if (!it.isEmpty())
243  {
244  if ( IsXMLToken( it, XML_TRUE ) )
245  fValue = 1.0;
246  else if ( IsXMLToken( it, XML_FALSE ) )
247  fValue = 0.0;
248  else
249  fValue = it.toDouble();
250  bIsEmpty = false;
251  }
252  }
253  break;
254  case XML_ELEMENT( TABLE, XML_FORMULA ):
255  {
256  if (!it.isEmpty())
257  {
258  OSL_ENSURE(!maFormula, "here should be only one formula");
259  OUString aFormula, aFormulaNmsp;
260  rXMLImport.ExtractFormulaNamespaceGrammar( aFormula, aFormulaNmsp, eGrammar, it.toString() );
261  maFormula = FormulaWithNamespace(aFormula, aFormulaNmsp);
262  }
263  }
264  break;
266  xCurrencySymbol = it.toString();
267  break;
268  default:
269  ;
270  }
271  }
272  }
273 
274  if (maFormula)
275  {
276  if (nCellType == util::NumberFormat::TEXT)
277  bFormulaTextResult = true;
278  if(nCellType == util::NumberFormat::DATETIME)
279  nCellType = util::NumberFormat::UNDEFINED;
280  //if bIsEmpty is true at this point, then there is no office value.
281  //we must get the text:p (even if it is empty) in case this a special
282  //case in HasSpecialCaseFormulaText().
283  if(bIsEmpty)
284  bFormulaTextResult = true;
285  }
286  rXMLImport.GetStylesImportHelper()->SetAttributes(std::move(xStyleName), std::move(xCurrencySymbol), nCellType);
287 }
288 
290 {
291 }
292 
294 {
295  if (!bSolarMutexLocked)
296  {
298  bSolarMutexLocked = true;
299  }
300 }
301 
302 namespace {
303 
304 bool cellExists( const ScDocument& rDoc, const ScAddress& rCellPos )
305 {
306  return( rCellPos.Col() >= 0 && rCellPos.Row() >= 0 &&
307  rCellPos.Col() <= rDoc.MaxCol() && rCellPos.Row() <= rDoc.MaxRow() );
308 }
309 
310 }
311 
312 void ScXMLTableRowCellContext::PushParagraphSpan(const OUString& rSpan, const OUString& rStyleName)
313 {
314  sal_Int32 nBegin = maParagraph.getLength();
315  sal_Int32 nEnd = nBegin + rSpan.getLength();
316  maParagraph.append(rSpan);
317 
318  PushFormat(nBegin, nEnd, rStyleName);
319 }
320 
321 void ScXMLTableRowCellContext::PushParagraphField(std::unique_ptr<SvxFieldData> pData, const OUString& rStyleName)
322 {
323  mbHasFormatRuns = true;
324  maFields.push_back(std::make_unique<Field>(std::move(pData)));
325  Field& rField = *maFields.back();
326 
327  sal_Int32 nPos = maParagraph.getLength();
328  maParagraph.append('\1'); // Placeholder text for inserted field item.
331  rField.maSelection.nStartPos = nPos;
332  rField.maSelection.nEndPos = nPos+1;
333 
334  PushFormat(nPos, nPos+1, rStyleName);
335 }
336 
337 void ScXMLTableRowCellContext::PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString& rStyleName)
338 {
339  if (rStyleName.isEmpty())
340  return;
341 
342  // Get the style information from xmloff.
343  rtl::Reference<XMLPropertySetMapper> xMapper = GetImport().GetTextImport()->GetTextImportPropertySetMapper()->getPropertySetMapper();
344  if (!xMapper.is())
345  // We can't do anything without the mapper.
346  return;
347 
348  sal_Int32 nEntryCount = xMapper->GetEntryCount();
349 
350  SvXMLStylesContext* pAutoStyles = GetImport().GetAutoStyles();
351  if (!pAutoStyles)
352  return;
353 
354  // Style name for text span corresponds with the name of an automatic style.
355  const XMLPropStyleContext* pStyle = dynamic_cast<const XMLPropStyleContext*>(
356  pAutoStyles->FindStyleChildContext(XmlStyleFamily::TEXT_TEXT, rStyleName));
357 
358  if (!pStyle)
359  // No style by that name found.
360  return;
361 
362  const std::vector<XMLPropertyState>& rProps = pStyle->GetProperties();
363  if (rProps.empty())
364  return;
365 
366  const ScXMLEditAttributeMap& rEditAttrMap = GetScImport().GetEditAttributeMap();
367 
368  mbHasFormatRuns = true;
369  maFormats.push_back(std::make_unique<ParaFormat>(*mpEditEngine));
370  ParaFormat& rFmt = *maFormats.back();
372  rFmt.maSelection.nStartPos = nBegin;
373  rFmt.maSelection.nEndPos = nEnd;
374 
375  // Store the used text styles for export.
376  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
378  pSheetData->AddTextStyle(rStyleName, aCellPos, rFmt.maSelection);
379 
380  std::unique_ptr<SfxPoolItem> pPoolItem;
381  sal_uInt16 nLastItemID = EE_CHAR_END + 1;
382 
383  for (const auto& rProp : rProps)
384  {
385  if (rProp.mnIndex == -1 || rProp.mnIndex >= nEntryCount)
386  continue;
387 
388  const OUString& rName = xMapper->GetEntryAPIName(rProp.mnIndex);
389  const ScXMLEditAttributeMap::Entry* pEntry = rEditAttrMap.getEntryByAPIName(rName);
390  if (!pEntry)
391  continue;
392 
393  if (nLastItemID != pEntry->mnItemID && pPoolItem)
394  {
395  // Flush the last item when the item ID changes.
396  rFmt.maItemSet.Put(*pPoolItem);
397  pPoolItem.reset();
398  }
399 
400  switch (pEntry->mnItemID)
401  {
402  case EE_CHAR_FONTINFO:
405  {
406  // Font properties need to be consolidated into a single item.
407  if (!pPoolItem)
408  pPoolItem.reset(new SvxFontItem(pEntry->mnItemID));
409 
410  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
411  }
412  break;
413  case EE_CHAR_WEIGHT:
414  case EE_CHAR_WEIGHT_CJK:
415  case EE_CHAR_WEIGHT_CTL:
416  {
417  if (!pPoolItem)
418  pPoolItem.reset(new SvxWeightItem(WEIGHT_NORMAL, pEntry->mnItemID));
419 
420  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
421  }
422  break;
423  case EE_CHAR_FONTHEIGHT:
426  {
427  if (!pPoolItem)
428  pPoolItem.reset(new SvxFontHeightItem(240, 100, pEntry->mnItemID));
429 
430  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
431  }
432  break;
433  case EE_CHAR_ITALIC:
434  case EE_CHAR_ITALIC_CJK:
435  case EE_CHAR_ITALIC_CTL:
436  {
437  if (!pPoolItem)
438  pPoolItem.reset(new SvxPostureItem(ITALIC_NONE, pEntry->mnItemID));
439 
440  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
441  }
442  break;
443  case EE_CHAR_UNDERLINE:
444  {
445  if (!pPoolItem)
446  pPoolItem.reset(new SvxUnderlineItem(LINESTYLE_NONE, pEntry->mnItemID));
447 
448  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
449  }
450  break;
451  case EE_CHAR_OVERLINE:
452  {
453  if (!pPoolItem)
454  pPoolItem.reset(new SvxOverlineItem(LINESTYLE_NONE, pEntry->mnItemID));
455 
456  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
457  }
458  break;
459  case EE_CHAR_COLOR:
460  {
461  if (!pPoolItem)
462  pPoolItem.reset(new SvxColorItem(pEntry->mnItemID));
463 
464  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
465  }
466  break;
467  case EE_CHAR_WLM:
468  {
469  if (!pPoolItem)
470  pPoolItem.reset(new SvxWordLineModeItem(false, pEntry->mnItemID));
471 
472  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
473  }
474  break;
475  case EE_CHAR_STRIKEOUT:
476  {
477  if (!pPoolItem)
478  pPoolItem.reset(new SvxCrossedOutItem(STRIKEOUT_NONE, pEntry->mnItemID));
479 
480  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
481  }
482  break;
483  case EE_CHAR_RELIEF:
484  {
485  if (!pPoolItem)
486  pPoolItem.reset(new SvxCharReliefItem(FontRelief::NONE, pEntry->mnItemID));
487 
488  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
489  }
490  break;
491  case EE_CHAR_OUTLINE:
492  {
493  if (!pPoolItem)
494  pPoolItem.reset(new SvxContourItem(false, pEntry->mnItemID));
495 
496  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
497  }
498  break;
499  case EE_CHAR_SHADOW:
500  {
501  if (!pPoolItem)
502  pPoolItem.reset(new SvxShadowedItem(false, pEntry->mnItemID));
503 
504  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
505  }
506  break;
507  case EE_CHAR_KERNING:
508  {
509  if (!pPoolItem)
510  pPoolItem.reset(new SvxKerningItem(0, pEntry->mnItemID));
511 
512  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
513  }
514  break;
515  case EE_CHAR_PAIRKERNING:
516  {
517  if (!pPoolItem)
518  pPoolItem.reset(new SvxAutoKernItem(false, pEntry->mnItemID));
519 
520  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
521  }
522  break;
523  case EE_CHAR_FONTWIDTH:
524  {
525  if (!pPoolItem)
526  pPoolItem.reset(new SvxCharScaleWidthItem(100, pEntry->mnItemID));
527 
528  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
529  }
530  break;
531  case EE_CHAR_ESCAPEMENT:
532  {
533  if (!pPoolItem)
534  pPoolItem.reset(new SvxEscapementItem(pEntry->mnItemID));
535 
536  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
537  }
538  break;
540  {
541  if (!pPoolItem)
542  pPoolItem.reset(new SvxEmphasisMarkItem(FontEmphasisMark::NONE, pEntry->mnItemID));
543 
544  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
545  }
546  break;
547  case EE_CHAR_LANGUAGE:
550  {
551  if (!pPoolItem)
552  pPoolItem.reset(new SvxLanguageItem(LANGUAGE_DONTKNOW, pEntry->mnItemID));
553 
554  pPoolItem->PutValue(rProp.maValue, pEntry->mnFlag);
555  }
556  break;
557  default:
558  ;
559  }
560 
561  nLastItemID = pEntry->mnItemID;
562  }
563 
564  if (pPoolItem)
565  rFmt.maItemSet.Put(*pPoolItem);
566 }
567 
569 {
570  if (!maFirstParagraph)
571  return mpEditEngine->GetText(0);
572 
573  return *maFirstParagraph;
574 }
575 
576 void ScXMLTableRowCellContext::PushParagraphFieldDate(const OUString& rStyleName)
577 {
578  PushParagraphField(std::make_unique<SvxDateField>(), rStyleName);
579 }
580 
582 {
584  PushParagraphField(std::make_unique<SvxTableField>(nTab), rStyleName);
585 }
586 
588 {
589  PushParagraphField(std::make_unique<SvxFileField>(), rStyleName);
590 }
591 
593  const OUString& rURL, const OUString& rRep, const OUString& rStyleName, const OUString& rTargetFrame)
594 {
595  OUString aAbsURL = GetScImport().GetAbsoluteReference(rURL);
596  std::unique_ptr<SvxURLField> pURLField(new SvxURLField(aAbsURL, rRep, SvxURLFormat::Repr));
597  pURLField->SetTargetFrame(rTargetFrame);
598  PushParagraphField(std::move(pURLField), rStyleName);
599 }
600 
602 {
603  // EditEngine always has at least one paragraph even when its content is empty.
604 
606  {
607  if (maFirstParagraph)
608  {
609  // Flush the cached first paragraph first.
610  mpEditEngine->Clear();
612  maFirstParagraph.reset();
613  }
615  }
616  else if (mbHasFormatRuns)
617  {
618  mpEditEngine->Clear();
619  mpEditEngine->SetTextCurrentDefaults(maParagraph.makeStringAndClear());
620  mbEditEngineHasText = true;
621  }
622  else if (mnCurParagraph == 0)
623  {
624  maFirstParagraph = maParagraph.makeStringAndClear();
625  mbEditEngineHasText = true;
626  }
627 
628  ++mnCurParagraph;
629 }
630 
631 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL ScXMLTableRowCellContext::createFastChildContext(
632  sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttrList )
633 {
634  SvXMLImportContext *pContext = nullptr;
635  sax_fastparser::FastAttributeList *pAttribList =
637 
638  bool bTextP(false);
639  switch (nElement)
640  {
641  case XML_ELEMENT( TEXT, XML_P ):
642  {
643  bIsEmpty = false;
644  bTextP = true;
645 
646  pContext = new ScXMLCellTextParaContext(rXMLImport, *this);
647  }
648  break;
650  {
651  SAL_WARN("sc", "ScXMLTableRowCellContext::createFastChildContext: subtables are not supported");
652  }
653  break;
655  {
656  bIsEmpty = false;
657  if (!pDetectiveObjVec)
659  pContext = new ScXMLDetectiveContext(
660  rXMLImport, pDetectiveObjVec.get() );
661  }
662  break;
664  {
665  bIsEmpty = false;
666  if (!pCellRangeSource)
668  pContext = new ScXMLCellRangeSourceContext(
669  rXMLImport, pAttribList, pCellRangeSource.get() );
670  }
671  break;
673  {
674  bIsEmpty = false;
675  OSL_ENSURE(
677  "ScXMLTableRowCellContext::CreateChildContext - multiple annotations in one cell");
679  pContext = new ScXMLAnnotationContext( rXMLImport, nElement,
680  xAttrList, *mxAnnotationData);
681  }
682  break;
683  }
684 
685  if (!pContext && !bTextP)
686  {
688  uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
689  if (xShapes.is())
690  {
692  if (aCellPos.Col() > pDoc->MaxCol())
693  aCellPos.SetCol(pDoc->MaxCol());
694  if (aCellPos.Row() > pDoc->MaxRow())
695  aCellPos.SetRow(pDoc->MaxRow());
696  XMLTableShapeImportHelper* pTableShapeImport =
697  static_cast< XMLTableShapeImportHelper* >( rXMLImport.GetShapeImport().get() );
698  pTableShapeImport->SetOnTable(false);
699  pTableShapeImport->SetCell(aCellPos);
701  rXMLImport, nElement, xAttrList, xShapes);
702  if (pContext)
703  {
704  bIsEmpty = false;
706  }
707  }
708  }
709 
710  return pContext;
711 }
712 
713 void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScAddress, const SCCOL nCols, const SCROW nRows )
714 {
715  SCCOL mergeToCol = rScAddress.Col() + nCols;
716  SCROW mergeToRow = rScAddress.Row() + nRows;
718  bool bInBounds = rScAddress.Col() <= pDoc->MaxCol() && rScAddress.Row() <= pDoc->MaxRow() &&
719  mergeToCol <= pDoc->MaxCol() && mergeToRow <= pDoc->MaxRow();
720  if( bInBounds )
721  {
722  pDoc->DoMerge( rScAddress.Tab(),
723  rScAddress.Col(), rScAddress.Row(), mergeToCol, mergeToRow );
724  }
725 }
726 
727 namespace {
728 
729 ScValidationMode validationTypeToMode( const sheet::ValidationType eVType )
730 {
732  switch( eVType )
733  {
734  case sheet::ValidationType_WHOLE: eMode = SC_VALID_WHOLE; break;
735  case sheet::ValidationType_DECIMAL: eMode = SC_VALID_DECIMAL; break;
736  case sheet::ValidationType_DATE: eMode = SC_VALID_DATE; break;
737  case sheet::ValidationType_TIME: eMode = SC_VALID_TIME; break;
738  case sheet::ValidationType_TEXT_LEN: eMode = SC_VALID_TEXTLEN; break;
739  case sheet::ValidationType_LIST: eMode = SC_VALID_LIST; break;
740  case sheet::ValidationType_CUSTOM: eMode = SC_VALID_CUSTOM; break;
741  default: eMode = SC_VALID_ANY; break;
742  }
743  return eMode;
744 }
745 
746 ScValidErrorStyle validAlertToValidError( const sheet::ValidationAlertStyle eVAlertStyle )
747 {
748  ScValidErrorStyle eVErrStyle;
749  switch( eVAlertStyle )
750  {
751  case sheet::ValidationAlertStyle_STOP: eVErrStyle = SC_VALERR_STOP; break;
752  case sheet::ValidationAlertStyle_WARNING: eVErrStyle = SC_VALERR_WARNING; break;
753  case sheet::ValidationAlertStyle_MACRO: eVErrStyle = SC_VALERR_MACRO; break;
754  default: eVErrStyle = SC_VALERR_INFO; break;
755  //should INFO be the default? seems to be the most unobtrusive choice.
756  }
757  return eVErrStyle;
758 }
759 
760 }
761 
763 {
765  return;
766 
768  ScMyImportValidation aValidation;
769  aValidation.eGrammar1 = aValidation.eGrammar2 = pDoc->GetStorageGrammar();
770  if( !rXMLImport.GetValidation(*maContentValidationName, aValidation) )
771  return;
772 
773  ScValidationData aScValidationData(
774  validationTypeToMode(aValidation.aValidationType),
776  aValidation.sFormula1, aValidation.sFormula2, *pDoc, ScAddress(),
777  aValidation.sFormulaNmsp1, aValidation.sFormulaNmsp2,
778  aValidation.eGrammar1, aValidation.eGrammar2
779  );
780 
781  aScValidationData.SetIgnoreBlank( aValidation.bIgnoreBlanks );
782  aScValidationData.SetListType( aValidation.nShowList );
783 
784  // set strings for error / input even if disabled (and disable afterwards)
785  aScValidationData.SetInput( aValidation.sInputTitle, aValidation.sInputMessage );
786  if( !aValidation.bShowInputMessage )
787  aScValidationData.ResetInput();
788  aScValidationData.SetError( aValidation.sErrorTitle, aValidation.sErrorMessage, validAlertToValidError(aValidation.aAlertStyle) );
789  if( !aValidation.bShowErrorMessage )
790  aScValidationData.ResetError();
791 
792  if( !aValidation.sBaseCellAddress.isEmpty() )
793  aScValidationData.SetSrcString( aValidation.sBaseCellAddress );
794 
795  sal_uLong nIndex = pDoc->AddValidationEntry( aScValidationData );
796 
797  ScPatternAttr aPattern( pDoc->GetPool() );
798  aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_VALIDDATA, nIndex ) );
799  if( rScRange.aStart == rScRange.aEnd ) //for a single cell
800  {
801  pDoc->ApplyPattern( rScRange.aStart.Col(), rScRange.aStart.Row(),
802  rScRange.aStart.Tab(), aPattern );
803  }
804  else //for repeating cells
805  {
806  pDoc->ApplyPatternAreaTab( rScRange.aStart.Col(), rScRange.aStart.Row(),
807  rScRange.aEnd.Col(), rScRange.aEnd.Row(),
808  rScRange.aStart.Tab(), aPattern );
809  }
810 
811  // is the below still needed?
812  // For now, any sheet with validity is blocked from stream-copying.
813  // Later, the validation names could be stored along with the style names.
814  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(GetImport().GetModel())->GetSheetSaveData();
815  pSheetData->BlockSheet( GetScImport().GetTables().GetCurrentSheet() );
816 }
817 
819 {
820  SetContentValidation( ScRange(rCellPos, rCellPos) );
821 }
822 
824 {
826  if (!pDoc || !mxAnnotationData)
827  return;
828 
829  LockSolarMutex();
830 
831  ScPostIt* pNote = nullptr;
832 
833  uno::Reference< drawing::XShapes > xShapes = rXMLImport.GetTables().GetCurrentXShapes();
834  sal_Int32 nOldShapeCount = xShapes.is() ? xShapes->getCount() : 0;
835 
836  OSL_ENSURE( !mxAnnotationData->mxShape.is() || mxAnnotationData->mxShapes.is(),
837  "ScXMLTableRowCellContext::SetAnnotation - shape without drawing page" );
838  if( mxAnnotationData->mxShape.is() && mxAnnotationData->mxShapes.is() )
839  {
840  OSL_ENSURE( mxAnnotationData->mxShapes.get() == xShapes.get(), "ScXMLTableRowCellContext::SetAnnotation - different drawing pages" );
841  SdrObject* pObject = ::GetSdrObjectFromXShape( mxAnnotationData->mxShape );
842  OSL_ENSURE( pObject, "ScXMLTableRowCellContext::SetAnnotation - cannot get SdrObject from shape" );
843 
844  /* Try to reuse the drawing object already created (but only if the
845  note is visible, and the object is a caption object). */
846  if( mxAnnotationData->mbShown && mxAnnotationData->mbUseShapePos && !comphelper::LibreOfficeKit::isActive())
847  {
848  if( SdrCaptionObj* pCaption = dynamic_cast< SdrCaptionObj* >( pObject ) )
849  {
850  OSL_ENSURE( !pCaption->GetLogicRect().IsEmpty(), "ScXMLTableRowCellContext::SetAnnotation - invalid caption rectangle" );
851  // create the cell note with the caption object
852  pNote = ScNoteUtil::CreateNoteFromCaption( *pDoc, rPos, pCaption );
853  // forget pointer to object (do not create note again below)
854  pObject = nullptr;
855  }
856  }
857 
858  // drawing object has not been used to create a note -> use shape data
859  if( pObject )
860  {
861  // rescue settings from drawing object before the shape is removed
862  ::std::unique_ptr< SfxItemSet > xItemSet( new SfxItemSet( pObject->GetMergedItemSet() ) );
863  ::std::unique_ptr< OutlinerParaObject > xOutlinerObj;
864  if( OutlinerParaObject* pOutlinerObj = pObject->GetOutlinerParaObject() )
865  xOutlinerObj.reset( new OutlinerParaObject( *pOutlinerObj ) );
866  tools::Rectangle aCaptionRect;
867  if( mxAnnotationData->mbUseShapePos )
868  aCaptionRect = pObject->GetLogicRect();
869  // remove the shape from the drawing page, this invalidates pObject
870  mxAnnotationData->mxShapes->remove( mxAnnotationData->mxShape );
871  pObject = nullptr;
872  // update current number of existing objects
873  if( xShapes.is() )
874  nOldShapeCount = xShapes->getCount();
875 
876  // an outliner object is required (empty note captions not allowed)
877  if (xOutlinerObj)
878  {
879  // create cell note with all data from drawing object
881  {
882  pNote = ScNoteUtil::CreateNoteFromObjectData( *pDoc, rPos,
883  std::move(xItemSet), xOutlinerObj.release(),
884  aCaptionRect, mxAnnotationData->mbShown );
885  }
886  else
887  {
888  pNote = ScNoteUtil::CreateNoteFromObjectData( *pDoc, rPos,
889  std::move(xItemSet), xOutlinerObj.release(),
890  aCaptionRect, false );
891  }
892 
893  }
894  }
895  }
896  else if( !mxAnnotationData->maSimpleText.isEmpty() )
897  {
898  // create note from simple text
899  pNote = ScNoteUtil::CreateNoteFromString( *pDoc, rPos,
900  mxAnnotationData->maSimpleText, mxAnnotationData->mbShown, false );
901  }
902 
903  // set author and date
904  if( pNote )
905  {
906  double fDate;
908  {
909  SvNumberFormatter* pNumForm = pDoc->GetFormatTable();
910  sal_uInt32 nfIndex = pNumForm->GetFormatIndex( NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM );
911  OUString aDate;
912  const Color* pColor = nullptr;
913  pNumForm->GetOutputString( fDate, nfIndex, aDate, &pColor );
914  pNote->SetDate( aDate );
915  }
916  pNote->SetAuthor( mxAnnotationData->maAuthor );
917  }
918 
919  // register a shape that has been newly created in the ScNoteUtil functions
920  if( xShapes.is() && (nOldShapeCount < xShapes->getCount()) )
921  {
922  uno::Reference< drawing::XShape > xShape;
923  rXMLImport.GetShapeImport()->shapeWithZIndexAdded( xShape, xShapes->getCount() );
924  }
925 
926  // store the style names for stream copying
927  ScSheetSaveData* pSheetData = comphelper::getUnoTunnelImplementation<ScModelObj>(rXMLImport.GetModel())->GetSheetSaveData();
928  pSheetData->HandleNoteStyles( mxAnnotationData->maStyleName, mxAnnotationData->maTextStyle, rPos );
929 
930  for (const auto& rContentStyle : mxAnnotationData->maContentStyles)
931  {
932  pSheetData->AddNoteContentStyle( rContentStyle.mnFamily, rContentStyle.maName, rPos, rContentStyle.maSelection );
933  }
934 }
935 
936 // core implementation
938 {
940  if( !pDoc || !cellExists(*pDoc, rPosition) || !pDetectiveObjVec || pDetectiveObjVec->empty() )
941  return;
942 
943  LockSolarMutex();
944  ScDetectiveFunc aDetFunc( *pDoc, rPosition.Tab() );
945  uno::Reference<container::XIndexAccess> xShapesIndex = rXMLImport.GetTables().GetCurrentXShapes(); // make draw page
946  for(const auto& rDetectiveObj : *pDetectiveObjVec)
947  {
948  aDetFunc.InsertObject( rDetectiveObj.eObjType, rPosition, rDetectiveObj.aSourceRange, rDetectiveObj.bHasError );
949  if (xShapesIndex.is())
950  {
951  sal_Int32 nShapes = xShapesIndex->getCount();
952  uno::Reference < drawing::XShape > xShape;
953  rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes);
954  }
955  }
956 }
957 
958 // core implementation
960 {
962  if( !pDoc || !cellExists(*pDoc, rPosition) || !pCellRangeSource || pCellRangeSource->sSourceStr.isEmpty() ||
963  pCellRangeSource->sFilterName.isEmpty() || pCellRangeSource->sURL.isEmpty() )
964  return;
965 
966  LockSolarMutex();
967  ScRange aDestRange( rPosition.Col(), rPosition.Row(), rPosition.Tab(),
968  rPosition.Col() + static_cast<SCCOL>(pCellRangeSource->nColumns - 1),
969  rPosition.Row() + static_cast<SCROW>(pCellRangeSource->nRows - 1), rPosition.Tab() );
970  OUString sFilterName( pCellRangeSource->sFilterName );
971  OUString sSourceStr( pCellRangeSource->sSourceStr );
973  sFilterName, pCellRangeSource->sFilterOptions, sSourceStr, aDestRange, pCellRangeSource->nRefresh );
974  sfx2::LinkManager* pLinkManager = pDoc->GetLinkManager();
975  pLinkManager->InsertFileLink( *pLink, sfx2::SvBaseLinkObjectType::ClientFile, pCellRangeSource->sURL, &sFilterName, &sSourceStr );
976 }
977 
979 {
980  if(!pFCell)
981  return;
982 
983  bool bMayForceNumberformat = true;
984 
985  if(mbErrorValue)
986  {
987  // don't do anything here
988  // we need to recalc anyway
989  }
990  else if( bFormulaTextResult && maStringValue )
991  {
992  if( !IsPossibleErrorString() )
993  {
996  pFCell->ResetDirty();
997  // A General format doesn't force any other format for a string
998  // result, don't attempt to recalculate this later.
999  bMayForceNumberformat = false;
1000  }
1001  }
1002  else if (std::isfinite(fValue))
1003  {
1004  pFCell->SetHybridDouble(fValue);
1005  if (mbPossibleEmptyDisplay && fValue == 0.0)
1006  {
1007  // Needs to be recalculated to propagate, otherwise would be
1008  // propagated as empty string. So don't ResetDirty().
1010  }
1011  else
1012  pFCell->ResetDirty();
1013  }
1014 
1015  if (bMayForceNumberformat)
1016  // Re-calculate to get number format only when style is not set.
1017  pFCell->SetNeedNumberFormat(!mbHasStyle);
1018 }
1019 
1021  const SCCOL nCurrentCol, const ::std::optional< OUString >& pOUText )
1022 {
1023  ScDocument* pDoc = rXMLImport.GetDocument();
1024  bool bDoIncrement = true;
1025  //matrix reference cells that contain text formula results;
1026  //cell was already put in document, just need to set text here.
1027  if( pDoc && rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) )
1028  {
1029  ScRefCellValue aCell(*pDoc, rCurrentPos);
1030  bDoIncrement = aCell.meType == CELLTYPE_FORMULA;
1031  if ( bDoIncrement )
1032  {
1033  ScFormulaCell* pFCell = aCell.mpFormula;
1034  OUString aCellString;
1035  if (maStringValue)
1036  aCellString = *maStringValue;
1037  else if (mbEditEngineHasText)
1038  aCellString = GetFirstParagraph();
1039  else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
1040  aCellString = *pOUText;
1041  else
1042  bDoIncrement = false;
1043 
1044  if(mbErrorValue)
1045  bDoIncrement = false;
1046 
1047  if(!aCellString.isEmpty())
1048  {
1049  if (bDoIncrement && !IsPossibleErrorString() && pFCell)
1050  {
1051  pFCell->SetHybridString(pDoc->GetSharedStringPool().intern(aCellString));
1052  pFCell->ResetDirty();
1053  }
1054  else
1055  {
1056  ScAddress aTopLeftMatrixCell;
1057  if (pFCell && pFCell->GetMatrixOrigin(*pDoc, aTopLeftMatrixCell))
1058  {
1059  ScFormulaCell* pMatrixCell = pDoc->GetFormulaCell(aTopLeftMatrixCell);
1060  if (pMatrixCell)
1061  pMatrixCell->SetDirty();
1062  }
1063  else
1064  SAL_WARN("sc", "matrix cell without matrix");
1065  }
1066  }
1067  }
1068  }
1069  else //regular text cells
1070  {
1072  if (maStringValue)
1073  {
1074  rDoc.setStringCell(rCurrentPos, *maStringValue);
1075  bDoIncrement = true;
1076  }
1077  else if (mbEditEngineHasText)
1078  {
1079  if (maFirstParagraph)
1080  {
1081  // This is a normal text without format runs.
1082  rDoc.setStringCell(rCurrentPos, *maFirstParagraph);
1083  }
1084  else
1085  {
1086  // This text either has format runs, has field(s), or consists of multiple lines.
1087  for (const auto& rxFormat : maFormats)
1088  mpEditEngine->QuickSetAttribs(rxFormat->maItemSet, rxFormat->maSelection);
1089 
1090  for (const auto& rxField : maFields)
1091  mpEditEngine->QuickInsertField(SvxFieldItem(*rxField->mpData, EE_FEATURE_FIELD), rxField->maSelection);
1092 
1093  // This edit engine uses the SfxItemPool instance returned
1094  // from pDoc->GetEditPool() to create the text object, which
1095  // is a prerequisite for using this constructor of ScEditCell.
1096  rDoc.setEditCell(rCurrentPos, mpEditEngine->CreateTextObject());
1097  }
1098  bDoIncrement = true;
1099  }
1100  else if ( nCurrentCol > 0 && pOUText && !pOUText->isEmpty() )
1101  {
1102  rDoc.setStringCell(rCurrentPos, *pOUText);
1103  bDoIncrement = true;
1104  }
1105  else
1106  bDoIncrement = false;
1107  }
1108 
1109  // #i56027# This is about setting simple text, not edit cells,
1110  // so ProgressBarIncrement must be called with bEditCell = FALSE.
1111  // Formatted text that is put into the cell by the child context
1112  // is handled in AddCellsToTable() (bIsEmpty is true then).
1113  if (bDoIncrement)
1115 }
1116 
1118 {
1119  //matrix reference cells that contain value formula results;
1120  //cell was already put in document, just need to set value here.
1121  if( rXMLImport.GetTables().IsPartOfMatrix(rCurrentPos) )
1122  {
1123  ScRefCellValue aCell(*rXMLImport.GetDocument(), rCurrentPos);
1124  if (aCell.meType == CELLTYPE_FORMULA)
1125  {
1126  ScFormulaCell* pFCell = aCell.mpFormula;
1127  SetFormulaCell(pFCell);
1128  if (pFCell)
1129  pFCell->SetNeedNumberFormat( true );
1130  }
1131  }
1132  else //regular value cell
1133  {
1134  // fdo#62250 absent values are not NaN, set to 0.0
1135  // PutValueCell() is called only for a known cell value type,
1136  // bIsEmpty==false in all these cases, no sense to check it here.
1137  if (!std::isfinite( fValue))
1138  fValue = 0.0;
1139 
1140  // #i62435# Initialize the value cell's script type if the default
1141  // style's number format is latin-only. If the cell uses a different
1142  // format, the script type will be reset when the style is applied.
1143 
1144  rXMLImport.GetDoc().setNumericCell(rCurrentPos, fValue);
1145  }
1147 }
1148 
1149 namespace {
1150 
1151 bool isEmptyOrNote( const ScDocument* pDoc, const ScAddress& rCurrentPos )
1152 {
1153  CellType eType = pDoc->GetCellType(rCurrentPos);
1154  return (eType == CELLTYPE_NONE);
1155 }
1156 
1157 }
1158 
1160  const ::std::optional< OUString >& pOUText, ScAddress& rCurrentPos )
1161 {
1162  ScDocument* pDoc = rXMLImport.GetDocument();
1163  ScMyTables& rTables = rXMLImport.GetTables();
1164  bool bWasEmpty = bIsEmpty;
1165  for (SCCOL i = 0; i < nColsRepeated; ++i)
1166  {
1167  rCurrentPos.SetCol( rCellPos.Col() + i );
1168 
1169  // it makes no sense to import data after the last supported column
1170  // fdo#58539 & gnome#627150
1171  if(rCurrentPos.Col() > pDoc->MaxCol())
1172  break;
1173 
1174  if (i > 0)
1175  rTables.AddColumn(false);
1176  if (!bIsEmpty)
1177  {
1178  for (SCROW j = 0; j < nRepeatedRows; ++j)
1179  {
1180  rCurrentPos.SetRow( rCellPos.Row() + j );
1181 
1182  // it makes no sense to import data after last supported row
1183  // fdo#58539 & gnome#627150
1184  if(rCurrentPos.Row() > pDoc->MaxRow())
1185  break;
1186 
1187  if( (rCurrentPos.Col() == 0) && (j > 0) )
1188  {
1189  rTables.AddRow();
1190  rTables.AddColumn(false);
1191  }
1192  if( cellExists(*pDoc, rCurrentPos) )
1193  {
1194  if( !bIsCovered || isEmptyOrNote(pDoc, rCurrentPos) )
1195  {
1196  switch (nCellType)
1197  {
1198  case util::NumberFormat::TEXT:
1199  {
1200  PutTextCell( rCurrentPos, i, pOUText );
1201  }
1202  break;
1203  case util::NumberFormat::NUMBER:
1205  case util::NumberFormat::CURRENCY:
1206  case util::NumberFormat::TIME:
1207  case util::NumberFormat::DATETIME:
1208  case util::NumberFormat::LOGICAL:
1209  {
1210  PutValueCell( rCurrentPos );
1211  }
1212  break;
1213  default:
1214  {
1215  OSL_FAIL("no cell type given");
1216  }
1217  break;
1218  }
1219  }
1220 
1221  SetAnnotation( rCurrentPos );
1222  SetDetectiveObj( rCurrentPos );
1223  SetCellRangeSource( rCurrentPos );
1224  }
1225  else
1226  {
1227  if (!bWasEmpty || mxAnnotationData)
1228  {
1229  if (rCurrentPos.Row() > pDoc->MaxRow())
1231  else
1233  }
1234  }
1235  }
1236  }
1237  else
1238  {
1239  if ((i == 0) && (rCellPos.Col() == 0))
1240  {
1241  for (sal_Int32 j = 1; j < nRepeatedRows; ++j)
1242  {
1243  rTables.AddRow();
1244  rTables.AddColumn(false);
1245  }
1246  }
1247  }
1248  }
1249 }
1250 
1252 {
1253  return ( (nColsRepeated > 1) || (nRepeatedRows > 1) );
1254 }
1255 
1256 namespace {
1257 
1258 // from ScCellObj::GetOutputString_Imp(). all of it may not be necessary.
1259 OUString getOutputString( ScDocument* pDoc, const ScAddress& aCellPos )
1260 {
1261  if (!pDoc)
1262  return OUString();
1263 
1264  ScRefCellValue aCell(*pDoc, aCellPos);
1265  switch (aCell.meType)
1266  {
1267  case CELLTYPE_NONE:
1268  return OUString();
1269  case CELLTYPE_EDIT:
1270  {
1271  // GetString on EditCell replaces linebreaks with spaces;
1272  // however here we need line breaks
1273  const EditTextObject* pData = aCell.mpEditText;
1274  EditEngine& rEngine = pDoc->GetEditEngine();
1275  rEngine.SetText(*pData);
1276  return rEngine.GetText();
1277  // also don't format EditCells per NumberFormatter
1278  }
1279  break;
1280  default:
1281  {
1282  // like in GetString for document (column)
1283  const Color* pColor;
1284  sal_uInt32 nNumFmt = pDoc->GetNumberFormat(aCellPos);
1285  OUString aStr;
1286  ScCellFormat::GetString(aCell, nNumFmt, aStr, &pColor, *pDoc->GetFormatTable(), *pDoc);
1287  return aStr;
1288  }
1289  }
1290 }
1291 
1292 }
1293 
1295 {
1296  ::std::optional< OUString > pOUText;
1297 
1298  ScDocument* pDoc = rXMLImport.GetDocument();
1299  if( nCellType == util::NumberFormat::TEXT )
1300  {
1301  if( !bIsEmpty && !maStringValue && !mbEditEngineHasText && cellExists(*pDoc, rCellPos) && CellsAreRepeated() )
1302  pOUText = getOutputString(pDoc, rCellPos);
1303 
1304  if (!mbEditEngineHasText && !pOUText && !maStringValue)
1305  bIsEmpty = true;
1306  }
1307 
1308  ScAddress aCurrentPos( rCellPos );
1309  if( mxAnnotationData || pDetectiveObjVec || pCellRangeSource ) // has special content
1310  bIsEmpty = false;
1311 
1312  AddTextAndValueCell( rCellPos, pOUText, aCurrentPos );
1313 
1314  if( CellsAreRepeated() )
1315  {
1316  SCCOL nStartCol( std::min(rCellPos.Col(), pDoc->MaxCol()) );
1317  SCROW nStartRow( std::min(rCellPos.Row(), pDoc->MaxRow()) );
1318  SCCOL nEndCol( std::min<SCCOL>(rCellPos.Col() + nColsRepeated - 1, pDoc->MaxCol()) );
1319  SCROW nEndRow( std::min(rCellPos.Row() + nRepeatedRows - 1, pDoc->MaxRow()) );
1320  ScRange aScRange( nStartCol, nStartRow, rCellPos.Tab(), nEndCol, nEndRow, rCellPos.Tab() );
1321  SetContentValidation( aScRange );
1322  rXMLImport.GetStylesImportHelper()->AddRange( aScRange );
1323  }
1324  else if( cellExists(*pDoc, rCellPos) )
1325  {
1327  SetContentValidation( rCellPos );
1328  }
1329 }
1330 
1332 {
1333  ScDocument* pDoc = rXMLImport.GetDocument();
1334  ScDocumentImport& rDocImport = rXMLImport.GetDoc();
1335 
1336  OUString aText = maFormula->first;
1337 
1338  ScExternalRefManager::ApiGuard aExtRefGuard(*pDoc);
1339 
1340  if ( aText.isEmpty() )
1341  return;
1342 
1343  // temporary formula string as string tokens
1344  std::unique_ptr<ScTokenArray> pCode(new ScTokenArray(*pDoc));
1345 
1346  // Check the special case of a single error constant without leading
1347  // '=' and create an error formula cell without tokens.
1349  if (nError != FormulaError::NONE)
1350  {
1351  pCode->SetCodeError(nError);
1352  }
1353  else
1354  {
1355  // 5.2 and earlier wrote broken "Err:xxx" as formula to designate
1356  // an error formula cell.
1357  if (aText.startsWithIgnoreAsciiCase("Err:") && aText.getLength() <= 9 &&
1358  ((nError =
1359  GetScImport().GetFormulaErrorConstant( OUString::Concat("#ERR") + aText.subView(4) + "!")) != FormulaError::NONE))
1360  {
1361  pCode->SetCodeError(nError);
1362  }
1363  else
1364  {
1365  OUString aFormulaNmsp = maFormula->second;
1367  aFormulaNmsp.clear();
1368  pCode->AssignXMLString( aText, aFormulaNmsp );
1369  rDocImport.getDoc().IncXMLImportedFormulaCount( aText.getLength() );
1370  }
1371  }
1372 
1373  ScFormulaCell* pNewCell = new ScFormulaCell(*pDoc, rCellPos, std::move(pCode), eGrammar, ScMatrixMode::NONE);
1374  SetFormulaCell(pNewCell);
1375  rDocImport.setFormulaCell(rCellPos, pNewCell);
1376 }
1377 
1379 {
1380  ScDocument* pDoc = rXMLImport.GetDocument();
1381  if( cellExists(*pDoc, rCellPos) )
1382  {
1383  SetContentValidation( rCellPos );
1384  SAL_WARN_IF((nColsRepeated != 1) || (nRepeatedRows != 1), "sc", "repeated cells with formula not possible now");
1386 
1387  //add matrix
1388  if(bIsMatrix)
1389  {
1390  if (nMatrixCols > 0 && nMatrixRows > 0)
1391  {
1392  //matrix cells are put in the document, but we must set the
1393  //value/text of each matrix cell later
1395  rCellPos.Col(), rCellPos.Row(),
1396  std::min<SCCOL>(rCellPos.Col() + nMatrixCols - 1, pDoc->MaxCol()),
1397  std::min<SCROW>(rCellPos.Row() + nMatrixRows - 1, pDoc->MaxRow()),
1398  maFormula->first, maFormula->second, eGrammar);
1399 
1400  // Set the value/text of the top-left matrix position in its
1401  // cached result. For import, we only need to set the correct
1402  // matrix geometry and the value type of the top-left element.
1403  ScFormulaCell* pFCell = pDoc->GetFormulaCell(rCellPos);
1404  if (pFCell)
1405  {
1408  {
1409  if (!IsPossibleErrorString())
1410  {
1411  pFCell->SetResultMatrix(
1414  pFCell->ResetDirty();
1415  }
1416  }
1417  else if (std::isfinite(fValue))
1418  {
1419  pFCell->SetResultMatrix(
1421  pFCell->ResetDirty();
1422  }
1423  }
1424  }
1425  }
1426  else
1427  PutFormulaCell( rCellPos );
1428 
1429  SetAnnotation( rCellPos );
1430  SetDetectiveObj( rCellPos );
1431  SetCellRangeSource( rCellPos );
1433  }
1434  else
1435  {
1436  if (rCellPos.Row() > pDoc->MaxRow())
1438  else
1440  }
1441 }
1442 
1443 //There are cases where a formula cell is exported with an office:value of 0 or
1444 //no office:value at all, but the formula cell will have a text:p value which
1445 //contains the intended formula result.
1446 //These cases include when a formula result:
1447 // - is blank
1448 // - has a constant error value beginning with "#" (such as "#VALUE!" or "#N/A")
1449 // - has an "Err:[###]" (where "[###]" is an error number)
1450 // Libreoffice 4.1+ with ODF1.2 extended write however calcext:value-type="error" in that case
1452 {
1453  if (!mbEditEngineHasText)
1454  return;
1455 
1456  const OUString aStr = GetFirstParagraph();
1457 
1458  if (mbNewValueType)
1459  {
1460  if (aStr.isEmpty())
1461  mbPossibleEmptyDisplay = true;
1462  return;
1463  }
1464 
1465  if (aStr.isEmpty())
1466  {
1467  mbPossibleErrorCell = true;
1468  mbPossibleEmptyDisplay = true;
1469  }
1470  else if (aStr.startsWith("Err:"))
1471  mbPossibleErrorCell = true;
1472  else if (aStr.startsWith("#"))
1474 }
1475 
1477 {
1479  return false;
1480  else if(mbNewValueType && mbErrorValue)
1481  return true;
1483  GetScImport().GetFormulaErrorConstant(*maStringValue) != FormulaError::NONE);
1484 }
1485 
1486 void SAL_CALL ScXMLTableRowCellContext::endFastElement(sal_Int32 /*nElement*/)
1487 {
1490  {
1492  }
1493 
1495  if( aCellPos.Col() > 0 && nRepeatedRows > 1 )
1496  aCellPos.SetRow( aCellPos.Row() - (nRepeatedRows - 1) );
1497  if( bIsMerged )
1498  DoMerge( aCellPos, nMergedCols - 1, nMergedRows - 1 );
1499 
1500  if (maFormula)
1501  AddFormulaCell(aCellPos);
1502  else
1503  AddNonFormulaCell(aCellPos);
1504 
1505  //if LockSolarMutex got used, we presumably need to ensure an UnlockSolarMutex
1506  if (bSolarMutexLocked)
1507  {
1509  bSolarMutexLocked = false;
1510  }
1511 
1512  bIsMerged = false;
1513  nMergedCols = 1;
1514  nMergedRows = 1;
1515  nColsRepeated = 1;
1516 }
1517 
1518 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
exports com.sun.star.lib. util
Matrix data type that can store values of mixed types.
Definition: scmatrix.hxx:113
void HandleNoteStyles(const OUString &rStyleName, const OUString &rTextName, const ScAddress &rCellPos)
Definition: sheetdata.cxx:61
void SetAuthor(const OUString &rAuthor)
Sets a new author date for this note.
Definition: postit.cxx:887
OUString sFormulaNmsp2
Definition: xmlimprt.hxx:98
OUString GetText(LineEnd eEnd=LINEEND_LF) const
bool CellsAreRepeated() const
Definition: xmlcelli.cxx:1251
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CJK(EE_CHAR_START+17)
void AddCell(const ScAddress &rAddress)
OUString GetFirstParagraph() const
Definition: xmlcelli.cxx:568
virtual ~ScXMLTableRowCellContext() override
Definition: xmlcelli.cxx:289
sal_Int32 nStartPara
void AddTextAndValueCell(const ScAddress &rScCellPos, const ::std::optional< OUString > &pOUText, ScAddress &rScCurrentPos)
Definition: xmlcelli.cxx:1159
sal_Int32 nIndex
XML_NUMBER_ROWS_SPANNED
void IncXMLImportedFormulaCount(sal_uLong nVal)
Definition: document.hxx:2355
ScAddress aStart
Definition: address.hxx:500
constexpr TypedWhichId< SvxAutoKernItem > EE_CHAR_PAIRKERNING(EE_CHAR_START+11)
SharedString intern(const OUString &rStr)
SC_DLLPUBLIC svl::SharedStringPool & GetSharedStringPool()
Definition: documen2.cxx:563
XML_VALUE_TYPE
XML_STYLE_NAME
constexpr TypedWhichId< SvxKerningItem > EE_CHAR_KERNING(EE_CHAR_START+12)
void SetDate(const OUString &rDate)
Sets a new creation date for this note.
Definition: postit.cxx:882
void PutFormulaCell(const ScAddress &rScCurrentPos)
Definition: xmlcelli.cxx:1331
ScXMLTableRowCellContext(ScXMLImport &rImport, const rtl::Reference< sax_fastparser::FastAttributeList > &rAttrList, const bool bIsCovered, const sal_Int32 nRepeatedRows)
Definition: xmlcelli.cxx:112
Provide mapping from ODF text formatting styles to EditEngine's, for rich-text cell content import...
SCROW Row() const
Definition: address.hxx:262
ScEditEngineDefaulter * mpEditEngine
unformatted first paragraph, for better performance.
Definition: xmlcelli.hxx:70
XML_ANNOTATION
void SetAnnotation(const ScAddress &rPosition)
Definition: xmlcelli.cxx:823
OUString sFormulaNmsp1
Definition: xmlimprt.hxx:97
void SetOnTable(const bool bTempOnTable)
std::unique_ptr< ContentProperties > pData
void PutValueCell(const ScAddress &rScCurrentPos)
Definition: xmlcelli.cxx:1117
sal_uInt32 GetFormatIndex(NfIndexTableOffset, LanguageType eLnge=LANGUAGE_DONTKNOW)
ScDocument * GetDocument()
Definition: xmlimprt.hxx:206
SC_DLLPUBLIC const ScFormulaCell * GetFormulaCell(const ScAddress &rPos) const
Definition: document.cxx:3721
void QuickInsertField(const SvxFieldItem &rFld, const ESelection &rSel)
const ::std::vector< XMLPropertyState > & GetProperties() const
XML_DETECTIVE
ScValidErrorStyle
Definition: validat.hxx:51
sal_uIntPtr sal_uLong
void PushParagraphSpan(const OUString &rSpan, const OUString &rStyleName)
Definition: xmlcelli.cxx:312
ScMyTables & GetTables()
Definition: xmlimprt.hxx:209
SvXMLImport & GetImport()
constexpr OUStringLiteral PERCENT(u"Percent")
XML_VALUE
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC(EE_CHAR_START+7)
const SfxItemSet & GetItemSet() const
ParaFormatsType maFormats
Definition: xmlcelli.hxx:74
SC_DLLPUBLIC void GetNumberFormat(SCCOL nCol, SCROW nRow, SCTAB nTab, sal_uInt32 &rFormat) const
Definition: document.cxx:3639
ScAddress aEnd
Definition: address.hxx:501
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
std::optional< OUString > maContentValidationName
office:string-value attribute
Definition: xmlcelli.hxx:67
const ScXMLEditAttributeMap & GetEditAttributeMap() const
Definition: xmlimprt.cxx:1660
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CJK(EE_CHAR_START+15)
This is very similar to ScCellValue, except that it references the original value instead of copying ...
Definition: cellvalue.hxx:104
ScMyStylesImportHelper * GetStylesImportHelper()
Definition: xmlimprt.hxx:256
rtl::Reference< XMLTextImportHelper > const & GetTextImport()
const SCCOL MAXCOLCOUNT
Definition: address.hxx:64
Accessor class to ScDocument.
EmbeddedObjectRef * pObject
void BlockSheet(SCTAB nTab)
Definition: sheetdata.cxx:92
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT(EE_CHAR_START+2)
formula::FormulaGrammar::Grammar eGrammar
Definition: xmlcelli.hxx:84
void setEditCell(const ScAddress &rPos, std::unique_ptr< EditTextObject > pEditText)
SC_DLLPUBLIC ScDocumentPool * GetPool()
Definition: document.cxx:6054
void SetListType(sal_Int16 nListType)
Definition: validat.hxx:118
css::sheet::ConditionOperator aOperator
Definition: xmlimprt.hxx:102
void SetDetectiveObj(const ScAddress &rPosition)
Definition: xmlcelli.cxx:937
bool SetNullDateOnUnitConverter()
Definition: xmlimprt.cxx:1103
void PushParagraphFieldDocTitle(const OUString &rStyleName)
Definition: xmlcelli.cxx:587
void DoMerge(const ScAddress &rScCellPos, const SCCOL nCols, const SCROW nRows)
Definition: xmlcelli.cxx:713
LINESTYLE_NONE
void AddColumn(bool bIsCovered)
Definition: xmlsubti.cxx:175
void SetText(const OUString &rStr)
SC_DLLPUBLIC SCROW MaxRow() const
Definition: document.hxx:870
void SetSrcString(const OUString &rNew)
Definition: conditio.cxx:460
void SetAttributes(std::optional< OUString > pStyleName, std::optional< OUString > pCurrency, const sal_Int16 nCellType)
void LockSolarMutex()
Definition: xmlimprt.cxx:1518
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO_CTL(EE_CHAR_START+18)
Additional class containing cell annotation data.
Definition: postit.hxx:160
XML_NUMBER_COLUMNS_REPEATED
void AddTextStyle(const OUString &rName, const ScAddress &rCellPos, const ESelection &rSelection)
Definition: sheetdata.cxx:87
void SetInput(const OUString &rTitle, const OUString &rMsg)
Definition: validat.cxx:160
static ScPostIt * CreateNoteFromCaption(ScDocument &rDoc, const ScAddress &rPos, SdrCaptionObj *pCaption)
Creates a cell note using the passed caption drawing object.
Definition: postit.cxx:1225
::boost::intrusive_ptr< ScMatrix > ScMatrixRef
Definition: types.hxx:26
SfxItemSet maItemSet
Mode eMode
ScFormulaCell * mpFormula
Definition: cellvalue.hxx:111
SCTAB Tab() const
Definition: address.hxx:271
void SetRow(SCROW nRowP)
Definition: address.hxx:275
XML_NUMBER_COLUMNS_SPANNED
sal_Int32 nEndPos
FormulaError GetFormulaErrorConstant(const OUString &rStr) const
Definition: xmlimprt.cxx:1638
void SetNeedNumberFormat(bool bVal)
void SetCol(SCCOL nColP)
Definition: address.hxx:279
XML_FALSE
ScValidationMode
Definition: validat.hxx:39
constexpr TypedWhichId< SvxContourItem > EE_CHAR_OUTLINE(EE_CHAR_START+8)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT(EE_CHAR_START+4)
void SetDirty(bool bDirtyFlag=true)
OUString sInputTitle
Definition: xmlimprt.hxx:91
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, const OUString &rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
DocumentType eType
bool GetValidation(const OUString &sName, ScMyImportValidation &aValidation)
Definition: xmlimprt.cxx:564
constexpr TypedWhichId< SfxUInt32Item > ATTR_VALIDDATA(153)
constexpr TypedWhichId< SvxShadowedItem > EE_CHAR_SHADOW(EE_CHAR_START+9)
This class exists only to provide GetScImport() to its derived classes.
SC_DLLPUBLIC SCCOL MaxCol() const
Definition: document.hxx:869
SC_DLLPUBLIC SvNumberFormatter * GetFormatTable() const
Definition: documen2.cxx:438
sal_Int32 nEndPara
std::optional< FormulaWithNamespace > maFormula
Definition: xmlcelli.hxx:65
void SetTextCurrentDefaults(const EditTextObject &rTextObject)
SetText and apply defaults already set.
Definition: editutil.cxx:555
void AddNoteContentStyle(XmlStyleFamily nFamily, const OUString &rName, const ScAddress &rCellPos, const ESelection &rSelection)
Definition: sheetdata.cxx:79
int i
void PushParagraphField(std::unique_ptr< SvxFieldData > pData, const OUString &rStyleName)
Definition: xmlcelli.cxx:321
#define LANGUAGE_SYSTEM
constexpr TypedWhichId< SvxCharScaleWidthItem > EE_CHAR_FONTWIDTH(EE_CHAR_START+3)
sal_Int16 SCCOL
Definition: types.hxx:22
constexpr TypedWhichId< SvxCharReliefItem > EE_CHAR_RELIEF(EE_CHAR_START+26)
XML_CURRENCY
void convertDateTime(OUStringBuffer &rBuffer, const double &fDateTime, bool const bAddTimeIf0AM=false)
std::pair< OUString, OUString > FormulaWithNamespace
Definition: xmlcelli.hxx:63
SC_DLLPUBLIC void ApplyPattern(SCCOL nCol, SCROW nRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4761
std::unique_ptr< EditTextObject > CreateTextObject()
WEIGHT_NORMAL
css::sheet::ValidationType aValidationType
Definition: xmlimprt.hxx:101
XML_SUB_TABLE
XML_STRING_VALUE
void SetCell(const ScAddress &rAddress)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CJK(EE_CHAR_START+21)
#define LANGUAGE_DONTKNOW
std::unique_ptr< ScMyImpDetectiveObjVec > pDetectiveObjVec
Definition: xmlcelli.hxx:78
SC_DLLPUBLIC void ApplyPatternAreaTab(SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, SCTAB nTab, const ScPatternAttr &rAttr)
Definition: document.cxx:4784
void PutTextCell(const ScAddress &rScCurrentPos, const SCCOL nCurrentCol, const ::std::optional< OUString > &pOUText)
Definition: xmlcelli.cxx:1020
NF_DATE_SYS_DDMMYYYY
static void convertDuration(OUStringBuffer &rBuffer, const double fTime)
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CTL(EE_CHAR_START+24)
void SetIgnoreBlank(bool bSet)
Definition: conditio.cxx:415
ScXMLImport & rXMLImport
Definition: xmlcelli.hxx:83
formula::FormulaGrammar::Grammar GetStorageGrammar() const
Definition: document.hxx:2436
ScXMLImport & GetScImport()
static sal_Int16 GetCellType(const char *rStrValue, const sal_Int32 nStrLength)
Definition: xmlimprt.cxx:518
constexpr sal_uInt16 EE_CHAR_END(EE_CHAR_START+32)
ITALIC_NONE
OUStringBuffer maParagraph
Definition: xmlcelli.hxx:71
SC_DLLPUBLIC void DoMerge(SCTAB nTab, SCCOL nStartCol, SCROW nStartRow, SCCOL nEndCol, SCROW nEndRow, bool bDeleteCaptions=true)
Definition: documen3.cxx:2051
bool IsPartOfMatrix(const ScAddress &rScAddress) const
Definition: xmlsubti.cxx:280
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlcelli.cxx:631
void AddMatrixRange(const SCCOL nStartColumn, const SCROW nStartRow, const SCCOL nEndColumn, const SCROW nEndRow, const OUString &rFormula, const OUString &rFormulaNmsp, const formula::FormulaGrammar::Grammar)
Definition: xmlsubti.cxx:259
void ExtractFormulaNamespaceGrammar(OUString &rFormula, OUString &rFormulaNmsp,::formula::FormulaGrammar::Grammar &reGrammar, const OUString &rAttrValue, bool bRestrictToExternalNmsp=false) const
Extracts the formula string, the formula grammar namespace URL, and a grammar enum value from the pas...
Definition: xmlimprt.cxx:1579
XML_CELL_RANGE_SOURCE
FormulaError
SCCOL Col() const
Definition: address.hxx:267
sal_Int32 GetParagraphCount() const
void AddNonFormulaCell(const ScAddress &rScCellPos)
Definition: xmlcelli.cxx:1294
std::optional< OUString > maStringValue
table:formula attribute
Definition: xmlcelli.hxx:66
OUString sBaseCellAddress
Definition: xmlimprt.hxx:99
void SetHybridEmptyDisplayedAsString()
For import only: set an empty cell result to be displayed as empty string.
XML_NUMBER_MATRIX_ROWS_SPANNED
formula::FormulaGrammar::Grammar eGrammar2
Definition: xmlimprt.hxx:104
bool GetMatrixOrigin(const ScDocument &rDoc, ScAddress &rPos) const
const ScAddress & GetCurrentCellPos() const
Definition: xmlsubti.hxx:81
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE_CTL(EE_CHAR_START+16)
TABLE
CellType meType
Definition: cellvalue.hxx:106
SC_DLLPUBLIC sal_uLong AddValidationEntry(const ScValidationData &rNew)
Definition: documen4.cxx:716
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
void setFormulaCell(const ScAddress &rPos, const OUString &rFormula, formula::FormulaGrammar::Grammar eGrammar, const double *pResult=nullptr)
sal_Int32 SCROW
Definition: types.hxx:18
constexpr TypedWhichId< SvxCrossedOutItem > EE_CHAR_STRIKEOUT(EE_CHAR_START+6)
void PushFormat(sal_Int32 nBegin, sal_Int32 nEnd, const OUString &rStyleName)
Definition: xmlcelli.cxx:337
XML_NUMBER_MATRIX_COLUMNS_SPANNED
void ResetInput()
Definition: validat.cxx:150
OUString sErrorMessage
Definition: xmlimprt.hxx:94
void SetContentValidation(const ScRange &rScRange)
Definition: xmlcelli.cxx:762
void SetCellRangeSource(const ScAddress &rPosition)
Definition: xmlcelli.cxx:959
void SetResultMatrix(SCCOL nCols, SCROW nRows, const ScConstMatrixRef &pMat, const formula::FormulaToken *pUL)
OUString GetAbsoluteReference(const OUString &rValue) const
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CTL(EE_CHAR_START+20)
#define SAL_WARN_IF(condition, area, stream)
SvBaseLink * pLink
XML_BOOLEAN_VALUE
constexpr TypedWhichId< SvxEscapementItem > EE_CHAR_ESCAPEMENT(EE_CHAR_START+10)
css::uno::Reference< css::drawing::XShapes > const & GetCurrentXShapes()
Definition: xmlsubti.cxx:231
CellType
Definition: global.hxx:283
#define SCWARN_IMPORT_ROW_OVERFLOW
Definition: scerrors.hxx:63
void InsertParagraph(sal_Int32 nPara, const EditTextObject &rTxtObj, const bool bAppend=false)
void setStringCell(const ScAddress &rPos, const OUString &rStr)
constexpr TypedWhichId< SvxWeightItem > EE_CHAR_WEIGHT_CTL(EE_CHAR_START+22)
void UnlockSolarMutex()
Definition: xmlimprt.cxx:1536
constexpr TypedWhichId< SvxColorItem > EE_CHAR_COLOR(EE_CHAR_START+0)
void AddFormulaCell(const ScAddress &rScCellPos)
Definition: xmlcelli.cxx:1378
css::sheet::ValidationAlertStyle aAlertStyle
Definition: xmlimprt.hxx:100
XML_P
void SetError(const OUString &rTitle, const OUString &rMsg, ScValidErrorStyle eStyle)
Definition: validat.cxx:167
constexpr TypedWhichId< SvxWordLineModeItem > EE_CHAR_WLM(EE_CHAR_START+13)
void PushParagraphFieldURL(const OUString &rURL, const OUString &rRep, const OUString &rStyleName, const OUString &rTargetFrame)
Definition: xmlcelli.cxx:592
void SetHybridString(const svl::SharedString &r)
For import only: set a string result.
#define XML_ELEMENT(prefix, name)
constexpr TypedWhichId< SvxEmphasisMarkItem > EE_CHAR_EMPHASISMARK(EE_CHAR_START+25)
std::unique_ptr< ScXMLAnnotationData > mxAnnotationData
Definition: xmlcelli.hxx:77
constexpr TypedWhichId< SvxOverlineItem > EE_CHAR_OVERLINE(EE_CHAR_START+29)
void QuickSetAttribs(const SfxItemSet &rSet, const ESelection &rSel)
const SvXMLUnitConverter & GetMM100UnitConverter() const
const css::uno::Reference< css::frame::XModel > & GetModel() const
constexpr TypedWhichId< SvxLanguageItem > EE_CHAR_LANGUAGE(EE_CHAR_START+14)
constexpr TypedWhichId< SvxFontItem > EE_CHAR_FONTINFO(EE_CHAR_START+1)
void PushParagraphFieldSheetName(const OUString &rStyleName)
Definition: xmlcelli.cxx:581
std::optional< OUString > maFirstParagraph
Definition: xmlcelli.hxx:68
#define SCWARN_IMPORT_COLUMN_OVERFLOW
Definition: scerrors.hxx:64
void SetHybridDouble(double n)
For import only: set a double result.
XML_TRUE
Field(const Field &)=delete
void PushParagraphFieldDate(const OUString &rStyleName)
Definition: xmlcelli.cxx:576
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override
Definition: xmlcelli.cxx:1486
OUString sInputMessage
Definition: xmlimprt.hxx:92
formula::FormulaGrammar::Grammar eGrammar1
Definition: xmlimprt.hxx:103
constexpr TypedWhichId< SvxPostureItem > EE_CHAR_ITALIC_CJK(EE_CHAR_START+23)
constexpr TypedWhichId< SvxUnderlineItem > EE_CHAR_UNDERLINE(EE_CHAR_START+5)
static ScConditionMode GetModeFromApi(css::sheet::ConditionOperator nOperator)
Definition: conditio.cxx:1396
SfxObjectShell * GetDocumentShell() const
Definition: document.hxx:1055
#define SAL_WARN(area, stream)
constexpr TypedWhichId< SvxFontHeightItem > EE_CHAR_FONTHEIGHT_CJK(EE_CHAR_START+19)
XML_CONTENT_VALIDATION_NAME
constexpr sal_uInt16 EE_FEATURE_FIELD(EE_FEATURE_NOTCONV+1)
static void GetString(const ScRefCellValue &rCell, sal_uInt32 nFormat, OUString &rString, const Color **ppColor, SvNumberFormatter &rFormatter, const ScDocument &rDoc, bool bNullVals=true, bool bFormula=false, bool bUseStarFormat=false)
Definition: cellform.cxx:31
static ScPostIt * CreateNoteFromObjectData(ScDocument &rDoc, const ScAddress &rPos, std::unique_ptr< SfxItemSet > pItemSet, OutlinerParaObject *pOutlinerObj, const tools::Rectangle &rCaptionRect, bool bShown)
Creates a cell note based on the passed caption object data.
Definition: postit.cxx:1241
static ScPostIt * CreateNoteFromString(ScDocument &rDoc, const ScAddress &rPos, const OUString &rNoteText, bool bShown, bool bAlwaysCreateCaption, sal_uInt32 nPostItId=0)
Creates a cell note based on the passed string and inserts it into the document.
Definition: postit.cxx:1274
::std::vector< ScMyImpDetectiveObj > ScMyImpDetectiveObjVec
static SvXMLShapeContext * CreateGroupChildContext(SvXMLImport &rImport, sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList, css::uno::Reference< css::drawing::XShapes > const &rShapes, bool bTemporaryShape=false)
This context handles element inside .
void setNumericCell(const ScAddress &rPos, double fVal)
STRIKEOUT_NONE
XML_DATE_VALUE
void ProgressBarIncrement()
Definition: xmlimprt.cxx:1569
SC_DLLPUBLIC sfx2::LinkManager * GetLinkManager()
Definition: documen2.cxx:215
XML_TIME_VALUE
SvXMLStylesContext * GetAutoStyles()
const Entry * getEntryByAPIName(const OUString &rAPIName) const
void AddRow()
Definition: xmlsubti.cxx:164
aStr
std::unique_ptr< ScMyImpCellRangeSource > pCellRangeSource
Definition: xmlcelli.hxx:79
TEXT
void ResetError()
Definition: validat.cxx:155
void GetOutputString(const double &fOutNumber, sal_uInt32 nFIndex, OUString &sOutString, const Color **ppColor, bool bUseStarFormat=false)
SC_DLLPUBLIC ScFieldEditEngine & GetEditEngine()
Definition: documen2.cxx:454
ScDocumentImport & GetDoc()
Definition: xmlimprt.cxx:513
void SetFormulaCell(ScFormulaCell *pFCell) const
Definition: xmlcelli.cxx:978
SC_DLLPUBLIC void GetCellType(SCCOL nCol, SCROW nRow, SCTAB nTab, CellType &rCellType) const
Definition: document.cxx:3745
bool IsPossibleErrorString() const
Definition: xmlcelli.cxx:1476
sal_uInt16 nPos
sal_Int16 SCTAB
Definition: types.hxx:23
Use this guard when performing something from the API that might query values from external reference...
OUString sErrorTitle
Definition: xmlimprt.hxx:93
void Clear()
rtl::Reference< XMLShapeImportHelper > const & GetShapeImport()
ParaFormat(const ScEditEngineDefaulter &rEditEngine)
Definition: xmlcelli.cxx:103
void SetRangeOverflowType(ErrCode nType)
Definition: xmlimprt.cxx:1559
ScDocument & getDoc()
sal_Int32 nStartPos
XML_FORMULA