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