update ooo310-m15
[ooovba.git] / sc / source / filter / xml / xmlcelli.cxx
blob35adc4c6e0b85587d3302d35709d375a1d0c94cd
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: xmlcelli.cxx,v $
10 * $Revision: 1.96.128.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
34 // INCLUDE ---------------------------------------------------------------
36 #include "xmlcelli.hxx"
37 #include "xmlimprt.hxx"
38 #include "xmltabi.hxx"
39 #include "xmlstyli.hxx"
40 #include "xmlannoi.hxx"
41 #include "xmlrubyi.hxx"
42 #include "global.hxx"
43 #include "document.hxx"
44 #include "cellsuno.hxx"
45 #include "docuno.hxx"
46 #include "unonames.hxx"
47 #include "postit.hxx"
49 #include "XMLTableShapeImportHelper.hxx"
50 #include "XMLTextPContext.hxx"
51 #include "XMLStylesImportHelper.hxx"
53 #include "arealink.hxx"
54 #include <svx/linkmgr.hxx>
55 #include "convuno.hxx"
56 #include "XMLConverter.hxx"
57 #include "scerrors.hxx"
58 #include "editutil.hxx"
59 #include "cell.hxx"
61 #include <xmloff/xmltkmap.hxx>
62 #include <xmloff/xmltoken.hxx>
63 #include <xmloff/nmspmap.hxx>
64 #include <xmloff/xmluconv.hxx>
65 #include <xmloff/families.hxx>
66 #include <xmloff/numehelp.hxx>
67 #include <xmloff/xmlnmspe.hxx>
68 #include <svtools/zforlist.hxx>
69 #include <svx/svdocapt.hxx>
70 #include <svx/outlobj.hxx>
71 #include <svx/editobj.hxx>
72 #include <svtools/languageoptions.hxx>
74 #include <com/sun/star/frame/XModel.hpp>
75 #include <com/sun/star/text/XText.hpp>
76 #include <com/sun/star/sheet/XSpreadsheets.hpp>
77 #include <com/sun/star/sheet/XSpreadsheet.hpp>
78 #include <com/sun/star/sheet/XCellRangeAddressable.hpp>
80 #include <com/sun/star/util/XMergeable.hpp>
81 #include <com/sun/star/sheet/XSheetCondition.hpp>
82 #include <com/sun/star/table/XCellRange.hpp>
83 #include <com/sun/star/table/CellAddress.hpp>
84 #include <com/sun/star/util/NumberFormat.hpp>
85 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
86 #include <com/sun/star/util/XNumberFormatTypes.hpp>
87 #include <com/sun/star/util/Date.hpp>
88 #include <com/sun/star/lang/Locale.hpp>
89 #include <com/sun/star/text/ControlCharacter.hpp>
91 #include <rtl/ustrbuf.hxx>
92 #include <tools/date.hxx>
93 #include <i18npool/lang.h>
94 #include <comphelper/extract.hxx>
96 #define SC_CURRENCYSYMBOL "CurrencySymbol"
98 using namespace com::sun::star;
99 using namespace xmloff::token;
101 //------------------------------------------------------------------
103 ScMyImportAnnotation::~ScMyImportAnnotation()
105 delete pRect;
106 delete pItemSet;
107 delete pOPO;
110 //------------------------------------------------------------------
112 ScXMLTableRowCellContext::ScXMLTableRowCellContext( ScXMLImport& rImport,
113 USHORT nPrfx,
114 const ::rtl::OUString& rLName,
115 const ::com::sun::star::uno::Reference<
116 ::com::sun::star::xml::sax::XAttributeList>& xAttrList,
117 const sal_Bool bTempIsCovered,
118 const sal_Int32 nTempRepeatedRows ) :
119 SvXMLImportContext( rImport, nPrfx, rLName ),
120 pContentValidationName(NULL),
121 pMyAnnotation(NULL),
122 pDetectiveObjVec(NULL),
123 pCellRangeSource(NULL),
124 fValue(0.0),
125 nMergedRows(1),
126 nMergedCols(1),
127 nRepeatedRows(nTempRepeatedRows),
128 nCellsRepeated(1),
129 rXMLImport((ScXMLImport&)rImport),
130 eGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT),
131 nCellType(util::NumberFormat::TEXT),
132 bIsMerged(sal_False),
133 bIsMatrix(sal_False),
134 bHasSubTable(sal_False),
135 bIsCovered(bTempIsCovered),
136 bIsEmpty(sal_True),
137 bHasTextImport(sal_False),
138 bIsFirstTextImport(sal_False),
139 bSolarMutexLocked(sal_False),
140 bFormulaTextResult(sal_False)
142 formula::FormulaGrammar::Grammar eStorageGrammar = eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
143 rXMLImport.SetRemoveLastChar(sal_False);
144 rXMLImport.GetTables().AddColumn(bTempIsCovered);
145 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
146 rtl::OUString aLocalName;
147 rtl::OUString* pStyleName = NULL;
148 rtl::OUString* pCurrencySymbol = NULL;
149 const SvXMLTokenMap& rTokenMap = rImport.GetTableRowCellAttrTokenMap();
150 for (sal_Int16 i = 0; i < nAttrCount; ++i)
152 sal_uInt16 nAttrPrefix = rImport.GetNamespaceMap().GetKeyByAttrName(
153 xAttrList->getNameByIndex(i), &aLocalName);
155 const rtl::OUString& sValue = xAttrList->getValueByIndex(i);
156 sal_uInt16 nToken = rTokenMap.Get(nAttrPrefix, aLocalName);
157 switch (nToken)
159 case XML_TOK_TABLE_ROW_CELL_ATTR_STYLE_NAME:
160 pStyleName = new rtl::OUString(sValue);
161 break;
162 case XML_TOK_TABLE_ROW_CELL_ATTR_CONTENT_VALIDATION_NAME:
163 DBG_ASSERT(!pContentValidationName, "here should be only one Validation Name");
164 pContentValidationName = new rtl::OUString(sValue);
165 break;
166 case XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_ROWS:
167 bIsMerged = sal_True;
168 nMergedRows = sValue.toInt32();
169 break;
170 case XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_COLS:
171 bIsMerged = sal_True;
172 nMergedCols = sValue.toInt32();
173 break;
174 case XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_COLS:
175 bIsMatrix = sal_True;
176 nMatrixCols = sValue.toInt32();
177 break;
178 case XML_TOK_TABLE_ROW_CELL_ATTR_SPANNED_MATRIX_ROWS:
179 bIsMatrix = sal_True;
180 nMatrixRows = sValue.toInt32();
181 break;
182 case XML_TOK_TABLE_ROW_CELL_ATTR_REPEATED:
183 nCellsRepeated = std::max( sValue.toInt32(), (sal_Int32) 1 );
184 break;
185 case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE_TYPE:
186 nCellType = GetScImport().GetCellType(sValue);
187 bIsEmpty = sal_False;
188 break;
189 case XML_TOK_TABLE_ROW_CELL_ATTR_VALUE:
191 if (sValue.getLength())
193 rXMLImport.GetMM100UnitConverter().convertDouble(fValue, sValue);
194 bIsEmpty = sal_False;
197 break;
198 case XML_TOK_TABLE_ROW_CELL_ATTR_DATE_VALUE:
200 if (sValue.getLength() && rXMLImport.SetNullDateOnUnitConverter())
202 rXMLImport.GetMM100UnitConverter().convertDateTime(fValue, sValue);
203 bIsEmpty = sal_False;
206 break;
207 case XML_TOK_TABLE_ROW_CELL_ATTR_TIME_VALUE:
209 if (sValue.getLength())
211 rXMLImport.GetMM100UnitConverter().convertTime(fValue, sValue);
212 bIsEmpty = sal_False;
215 break;
216 case XML_TOK_TABLE_ROW_CELL_ATTR_STRING_VALUE:
218 if (sValue.getLength())
220 DBG_ASSERT(!pOUTextValue, "here should be only one string value");
221 pOUTextValue.reset(sValue);
222 bIsEmpty = sal_False;
225 break;
226 case XML_TOK_TABLE_ROW_CELL_ATTR_BOOLEAN_VALUE:
228 if (sValue.getLength())
230 if ( IsXMLToken(sValue, XML_TRUE) )
231 fValue = 1.0;
232 else if ( IsXMLToken(sValue, XML_FALSE) )
233 fValue = 0.0;
234 else
235 rXMLImport.GetMM100UnitConverter().convertDouble(fValue, sValue);
236 bIsEmpty = sal_False;
239 break;
240 case XML_TOK_TABLE_ROW_CELL_ATTR_FORMULA:
242 if (sValue.getLength())
244 DBG_ASSERT(!pOUFormula, "here should be only one formula");
245 rtl::OUString sFormula;
246 sal_uInt16 nFormulaPrefix = GetImport().GetNamespaceMap().
247 _GetKeyByAttrName( sValue, &sFormula, sal_False );
249 if (ScXMLImport::IsAcceptedFormulaNamespace(
250 nFormulaPrefix, sValue, eGrammar,
251 eStorageGrammar))
253 // Namespaces we accept.
254 pOUFormula.reset( sFormula);
256 else
258 // No namespace => entire string.
259 // Also unknown namespace included in formula,
260 // so hopefully will result in string or
261 // compile error.
262 pOUFormula.reset( sValue);
266 break;
267 case XML_TOK_TABLE_ROW_CELL_ATTR_CURRENCY:
268 pCurrencySymbol = new rtl::OUString(sValue);
269 break;
270 default:
274 if (pOUFormula)
276 if (nCellType == util::NumberFormat::TEXT)
277 bFormulaTextResult = sal_True;
278 nCellType = util::NumberFormat::UNDEFINED;
280 rXMLImport.GetStylesImportHelper()->SetAttributes(pStyleName, pCurrencySymbol, nCellType);
283 ScXMLTableRowCellContext::~ScXMLTableRowCellContext()
285 if (pContentValidationName)
286 delete pContentValidationName;
287 if (pMyAnnotation)
288 delete pMyAnnotation;
289 if (pDetectiveObjVec)
290 delete pDetectiveObjVec;
291 if (pCellRangeSource)
292 delete pCellRangeSource;
295 void ScXMLTableRowCellContext::LockSolarMutex()
297 if (!bSolarMutexLocked)
299 GetScImport().LockSolarMutex();
300 bSolarMutexLocked = sal_True;
304 void ScXMLTableRowCellContext::UnlockSolarMutex()
306 if (bSolarMutexLocked)
308 GetScImport().UnlockSolarMutex();
309 bSolarMutexLocked = sal_False;
313 void ScXMLTableRowCellContext::SetCursorOnTextImport(const rtl::OUString& rOUTempText)
315 com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
316 if (CellExists(aCellPos))
318 uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
319 if (xCellRange.is())
321 xBaseCell.set(xCellRange->getCellByPosition(aCellPos.Column, aCellPos.Row));
322 if (xBaseCell.is())
324 xLockable.set(xBaseCell, uno::UNO_QUERY);
325 if (xLockable.is())
326 xLockable->addActionLock();
327 uno::Reference<text::XText> xText(xBaseCell, uno::UNO_QUERY);
328 if (xText.is())
330 uno::Reference<text::XTextCursor> xTextCursor(xText->createTextCursor());
331 if (xTextCursor.is())
333 xTextCursor->setString(rOUTempText);
334 xTextCursor->gotoEnd(sal_False);
335 rXMLImport.GetTextImport()->SetCursor(xTextCursor);
341 else
343 DBG_ERRORFILE("this method should only be called for a existing cell");
347 SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( USHORT nPrefix,
348 const ::rtl::OUString& rLName,
349 const ::com::sun::star::uno::Reference<
350 ::com::sun::star::xml::sax::XAttributeList>& xAttrList )
352 SvXMLImportContext *pContext = 0;
354 const SvXMLTokenMap& rTokenMap = rXMLImport.GetTableRowCellElemTokenMap();
355 sal_Bool bTextP(sal_False);
356 switch( rTokenMap.Get( nPrefix, rLName ) )
358 case XML_TOK_TABLE_ROW_CELL_P:
360 bIsEmpty = sal_False;
361 bTextP = sal_True;
362 com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
363 if (((nCellType == util::NumberFormat::TEXT) || bFormulaTextResult) &&
364 !rXMLImport.GetTables().IsPartOfMatrix(aCellPos.Column, aCellPos.Row))
366 if (!bHasTextImport)
368 bIsFirstTextImport = sal_True;
369 bHasTextImport = sal_True;
370 pContext = new ScXMLTextPContext(rXMLImport, nPrefix, rLName, xAttrList, this);
372 else
374 // com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
375 if (CellExists(aCellPos))
377 if (bIsFirstTextImport && !rXMLImport.GetRemoveLastChar())
379 if (pOUTextContent)
381 SetCursorOnTextImport(*pOUTextContent);
382 pOUTextContent.reset();
384 else
385 SetCursorOnTextImport(rtl::OUString());
386 rXMLImport.SetRemoveLastChar(sal_True);
387 uno::Reference < text::XTextCursor > xTextCursor(rXMLImport.GetTextImport()->GetCursor());
388 if (xTextCursor.is())
390 uno::Reference < text::XText > xText (xTextCursor->getText());
391 uno::Reference < text::XTextRange > xTextRange (xTextCursor, uno::UNO_QUERY);
392 if (xText.is() && xTextRange.is())
393 xText->insertControlCharacter(xTextRange, text::ControlCharacter::PARAGRAPH_BREAK, sal_False);
396 pContext = rXMLImport.GetTextImport()->CreateTextChildContext(
397 rXMLImport, nPrefix, rLName, xAttrList);
398 bIsFirstTextImport = sal_False;
403 break;
404 case XML_TOK_TABLE_ROW_CELL_TABLE:
406 const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
407 rtl::OUString aLocalName;
408 for( sal_Int16 i=0; i < nAttrCount; i++ )
410 sal_uInt16 nAttrPrefix = rXMLImport.GetNamespaceMap().GetKeyByAttrName(
411 xAttrList->getNameByIndex( i ), &aLocalName );
412 if ( nAttrPrefix == XML_NAMESPACE_TABLE
413 && IsXMLToken(aLocalName, XML_IS_SUB_TABLE))
415 bHasSubTable = IsXMLToken(xAttrList->getValueByIndex( i ), XML_TRUE);
418 DBG_ASSERT(bHasSubTable, "it should be a subtable");
419 pContext = new ScXMLTableContext( rXMLImport , nPrefix,
420 rLName, xAttrList,
421 sal_True, nMergedCols);
422 nMergedCols = 1;
423 bIsMerged = sal_False;
425 break;
426 case XML_TOK_TABLE_ROW_CELL_ANNOTATION:
428 bIsEmpty = sal_False;
429 pContext = new ScXMLAnnotationContext( rXMLImport, nPrefix, rLName,
430 xAttrList, this);
432 break;
433 case XML_TOK_TABLE_ROW_CELL_DETECTIVE:
435 bIsEmpty = sal_False;
436 if (!pDetectiveObjVec)
437 pDetectiveObjVec = new ScMyImpDetectiveObjVec();
438 pContext = new ScXMLDetectiveContext(
439 rXMLImport, nPrefix, rLName, pDetectiveObjVec );
441 break;
442 case XML_TOK_TABLE_ROW_CELL_CELL_RANGE_SOURCE:
444 bIsEmpty = sal_False;
445 if (!pCellRangeSource)
446 pCellRangeSource = new ScMyImpCellRangeSource();
447 pContext = new ScXMLCellRangeSourceContext(
448 rXMLImport, nPrefix, rLName, xAttrList, pCellRangeSource );
450 break;
451 case XML_TOK_TABLE_ROW_CELL_RUBY:
453 bIsEmpty = sal_False;
454 pContext = new ScXMLRubyContext( rXMLImport, nPrefix, rLName, xAttrList, this );
456 break;
459 if (!pContext && !bTextP)
461 com::sun::star::table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
462 uno::Reference<drawing::XShapes> xShapes (rXMLImport.GetTables().GetCurrentXShapes());
463 if (xShapes.is())
465 if (aCellPos.Column > MAXCOL)
466 aCellPos.Column = MAXCOL;
467 if (aCellPos.Row > MAXROW)
468 aCellPos.Row = MAXROW;
469 XMLTableShapeImportHelper* pTableShapeImport = (XMLTableShapeImportHelper*)rXMLImport.GetShapeImport().get();
470 pTableShapeImport->SetOnTable(sal_False);
471 pTableShapeImport->SetCell(aCellPos);
472 pContext = rXMLImport.GetShapeImport()->CreateGroupChildContext(
473 rXMLImport, nPrefix, rLName, xAttrList, xShapes);
474 if (pContext)
476 bIsEmpty = sal_False;
477 rXMLImport.ProgressBarIncrement(sal_False);
482 if( !pContext )
483 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLName );
485 return pContext;
488 sal_Bool ScXMLTableRowCellContext::IsMerged (const uno::Reference <table::XCellRange>& xCellRange, const sal_Int32 nCol, const sal_Int32 nRow,
489 table::CellRangeAddress& aCellAddress) const
491 table::CellAddress aCell; // don't need to set the sheet, because every sheet can contain the same count of cells.
492 aCell.Column = nCol;
493 aCell.Row = nRow;
494 if (CellExists(aCell))
496 uno::Reference<sheet::XSheetCellRange> xMergeSheetCellRange (xCellRange->getCellRangeByPosition(nCol,nRow,nCol,nRow), uno::UNO_QUERY);
497 uno::Reference<sheet::XSpreadsheet> xTable (xMergeSheetCellRange->getSpreadsheet());
498 uno::Reference<sheet::XSheetCellCursor> xMergeSheetCursor (xTable->createCursorByRange(xMergeSheetCellRange));
499 if (xMergeSheetCursor.is())
501 xMergeSheetCursor->collapseToMergedArea();
502 uno::Reference<sheet::XCellRangeAddressable> xMergeCellAddress (xMergeSheetCursor, uno::UNO_QUERY);
503 if (xMergeCellAddress.is())
505 aCellAddress = xMergeCellAddress->getRangeAddress();
506 if (aCellAddress.StartColumn == nCol && aCellAddress.EndColumn == nCol &&
507 aCellAddress.StartRow == nRow && aCellAddress.EndRow == nRow)
508 return sal_False;
509 else
510 return sal_True;
514 return sal_False;
517 void ScXMLTableRowCellContext::DoMerge(const com::sun::star::table::CellAddress& aCellPos,
518 const sal_Int32 nCols, const sal_Int32 nRows)
520 if (CellExists(aCellPos))
522 uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
523 if ( xCellRange.is() )
525 table::CellRangeAddress aCellAddress;
526 if (IsMerged(xCellRange, aCellPos.Column, aCellPos.Row, aCellAddress))
528 //unmerge
529 uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
530 aCellAddress.EndColumn, aCellAddress.EndRow), uno::UNO_QUERY);
531 if (xMergeable.is())
532 xMergeable->merge(sal_False);
535 //merge
536 uno::Reference <util::XMergeable> xMergeable (xCellRange->getCellRangeByPosition(aCellAddress.StartColumn, aCellAddress.StartRow,
537 aCellAddress.EndColumn + nCols, aCellAddress.EndRow + nRows), uno::UNO_QUERY);
538 if (xMergeable.is())
539 xMergeable->merge(sal_True);
544 void ScXMLTableRowCellContext::SetContentValidation(com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet>& xPropSet)
546 if (pContentValidationName)
548 ScMyImportValidation aValidation;
549 aValidation.eGrammar = GetScImport().GetDocument()->GetStorageGrammar();
550 if (rXMLImport.GetValidation(*pContentValidationName, aValidation))
552 uno::Reference<beans::XPropertySet> xPropertySet(xPropSet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_VALIXML))), uno::UNO_QUERY);
553 if (xPropertySet.is())
555 if (aValidation.sErrorMessage.getLength())
556 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRMESS)), uno::makeAny(aValidation.sErrorMessage));
557 if (aValidation.sErrorTitle.getLength())
558 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRTITLE)), uno::makeAny(aValidation.sErrorTitle));
559 if (aValidation.sImputMessage.getLength())
560 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPMESS)), uno::makeAny(aValidation.sImputMessage));
561 if (aValidation.sImputTitle.getLength())
562 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_INPTITLE)), uno::makeAny(aValidation.sImputTitle));
563 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWERR)), uno::makeAny(aValidation.bShowErrorMessage));
564 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWINP)), uno::makeAny(aValidation.bShowImputMessage));
565 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_TYPE)), uno::makeAny(aValidation.aValidationType));
566 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_IGNOREBL)), uno::makeAny(aValidation.bIgnoreBlanks));
567 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SHOWLIST)), uno::makeAny(aValidation.nShowList));
568 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_ERRALSTY)), uno::makeAny(aValidation.aAlertStyle));
569 uno::Reference<sheet::XSheetCondition> xCondition(xPropertySet, uno::UNO_QUERY);
570 if (xCondition.is())
572 xCondition->setFormula1(aValidation.sFormula1);
573 xCondition->setFormula2(aValidation.sFormula2);
574 xCondition->setOperator(aValidation.aOperator);
575 // #b4974740# source position must be set as string, because it may
576 // refer to a sheet that hasn't been loaded yet.
577 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_SOURCESTR)), uno::makeAny(aValidation.sBaseCellAddress));
578 // Transport grammar.
579 xPropertySet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_GRAMMAR)), uno::makeAny(static_cast<sal_Int32>(aValidation.eGrammar)));
582 xPropSet->setPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_UNONAME_VALIXML)), uno::makeAny(xPropertySet));
587 void ScXMLTableRowCellContext::SetCellProperties(const uno::Reference<table::XCellRange>& xCellRange,
588 const table::CellAddress& aCellAddress)
590 if (CellExists(aCellAddress) && pContentValidationName && pContentValidationName->getLength())
592 sal_Int32 nBottom = aCellAddress.Row + nRepeatedRows - 1;
593 sal_Int32 nRight = aCellAddress.Column + nCellsRepeated - 1;
594 if (nBottom > MAXROW)
595 nBottom = MAXROW;
596 if (nRight > MAXCOL)
597 nRight = MAXCOL;
598 uno::Reference <beans::XPropertySet> xProperties (xCellRange->getCellRangeByPosition(aCellAddress.Column, aCellAddress.Row,
599 nRight, nBottom), uno::UNO_QUERY);
600 if (xProperties.is())
601 SetContentValidation(xProperties);
605 void ScXMLTableRowCellContext::SetCellProperties(const uno::Reference<table::XCell>& xCell)
607 if (pContentValidationName && pContentValidationName->getLength())
609 uno::Reference <beans::XPropertySet> xProperties (xCell, uno::UNO_QUERY);
610 if (xProperties.is())
611 SetContentValidation(xProperties);
615 void ScXMLTableRowCellContext::SetAnnotation(const table::CellAddress& aCellAddress)
617 /*uno::Reference<sheet::XSheetAnnotationAnchor> xSheetAnnotationAnchor(xCell, uno::UNO_QUERY);
618 if (xSheetAnnotationAnchor.is())
620 uno::Reference <sheet::XSheetAnnotation> xSheetAnnotation (xSheetAnnotationAnchor->getAnnotation());
621 uno::Reference<text::XSimpleText> xSimpleText(xSheetAnnotation, uno::UNO_QUERY);
622 if (xSheetAnnotation.is() && xSimpleText.is())
624 xSimpleText->setString(aMyAnnotation.sText);
625 //xSheetAnnotation->setAuthor(aMyAnnotation.sAuthor);
626 //xSheetAnnotation->setDate();
627 xSheetAnnotation->setIsVisible(aMyAnnotation.bDisplay);
630 if( pMyAnnotation )
632 double fDate;
633 rXMLImport.GetMM100UnitConverter().convertDateTime(fDate, pMyAnnotation->sCreateDate);
634 ScDocument* pDoc = rXMLImport.GetDocument();
635 if (pDoc)
637 LockSolarMutex();
638 SvNumberFormatter* pNumForm = pDoc->GetFormatTable();
639 sal_uInt32 nfIndex = pNumForm->GetFormatIndex(NF_DATE_SYS_DDMMYYYY, LANGUAGE_SYSTEM);
640 String sDate;
641 Color* pColor = NULL;
642 Color** ppColor = &pColor;
643 pNumForm->GetOutputString(fDate, nfIndex, sDate, ppColor);
645 ScAddress aPos;
646 ScUnoConversion::FillScAddress( aPos, aCellAddress );
647 if( ScPostIt* pNote = pDoc->GetOrCreateNote( aPos ) )
649 pNote->SetDate( sDate );
650 pNote->SetAuthor( pMyAnnotation->sAuthor );
651 if( SdrCaptionObj* pCaption = pNote->GetCaption() )
653 if( pMyAnnotation->pOPO )
655 // transfer outliner object to caption
656 pCaption->SetOutlinerParaObject( pMyAnnotation->pOPO );
657 // do not delete the object in ScMyImportAnnotation d'tor
658 pMyAnnotation->pOPO = 0;
660 else
661 pCaption->SetText( pMyAnnotation->sText );
662 // copy all items and reset shadow items
663 if( pMyAnnotation->pItemSet )
664 pNote->SetCaptionItems( *pMyAnnotation->pItemSet );
665 else
666 pNote->SetCaptionDefaultItems(); // default items need to be applied to text
667 if( pMyAnnotation->pRect )
668 pCaption->SetLogicRect( *pMyAnnotation->pRect );
670 uno::Reference<container::XIndexAccess> xShapesIndex (rXMLImport.GetTables().GetCurrentXShapes(), uno::UNO_QUERY); // make draw page
671 if (xShapesIndex.is())
673 sal_Int32 nShapes = xShapesIndex->getCount();
674 uno::Reference < drawing::XShape > xShape;
675 rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes);
678 pNote->ShowCaption( pMyAnnotation->bDisplay );
684 // core implementation
685 void ScXMLTableRowCellContext::SetDetectiveObj( const table::CellAddress& rPosition )
687 if( CellExists(rPosition) && pDetectiveObjVec && pDetectiveObjVec->size() )
689 LockSolarMutex();
690 ScDetectiveFunc aDetFunc( rXMLImport.GetDocument(), rPosition.Sheet );
691 uno::Reference<container::XIndexAccess> xShapesIndex (rXMLImport.GetTables().GetCurrentXShapes(), uno::UNO_QUERY); // make draw page
692 ScMyImpDetectiveObjVec::iterator aItr(pDetectiveObjVec->begin());
693 ScMyImpDetectiveObjVec::iterator aEndItr(pDetectiveObjVec->end());
694 while(aItr != aEndItr)
696 ScAddress aScAddress;
697 ScUnoConversion::FillScAddress( aScAddress, rPosition );
698 aDetFunc.InsertObject( aItr->eObjType, aScAddress, aItr->aSourceRange, aItr->bHasError );
699 if (xShapesIndex.is())
701 sal_Int32 nShapes = xShapesIndex->getCount();
702 uno::Reference < drawing::XShape > xShape;
703 rXMLImport.GetShapeImport()->shapeWithZIndexAdded(xShape, nShapes);
705 ++aItr;
710 // core implementation
711 void ScXMLTableRowCellContext::SetCellRangeSource( const table::CellAddress& rPosition )
713 if( CellExists(rPosition) && pCellRangeSource && pCellRangeSource->sSourceStr.getLength() &&
714 pCellRangeSource->sFilterName.getLength() && pCellRangeSource->sURL.getLength() )
716 ScDocument* pDoc = rXMLImport.GetDocument();
717 if (pDoc)
719 LockSolarMutex();
720 ScRange aDestRange( static_cast<SCCOL>(rPosition.Column), static_cast<SCROW>(rPosition.Row), rPosition.Sheet,
721 static_cast<SCCOL>(rPosition.Column + pCellRangeSource->nColumns - 1),
722 static_cast<SCROW>(rPosition.Row + pCellRangeSource->nRows - 1), rPosition.Sheet );
723 String sFilterName( pCellRangeSource->sFilterName );
724 String sSourceStr( pCellRangeSource->sSourceStr );
725 ScAreaLink* pLink = new ScAreaLink( pDoc->GetDocumentShell(), pCellRangeSource->sURL,
726 sFilterName, pCellRangeSource->sFilterOptions, sSourceStr, aDestRange, pCellRangeSource->nRefresh );
727 SvxLinkManager* pLinkManager = pDoc->GetLinkManager();
728 pLinkManager->InsertFileLink( *pLink, OBJECT_CLIENT_FILE, pCellRangeSource->sURL, &sFilterName, &sSourceStr );
733 bool lcl_IsEmptyOrNote( ScDocument* pDoc, const table::CellAddress& rCurrentPos )
735 ScAddress aScAddress;
736 ScUnoConversion::FillScAddress( aScAddress, rCurrentPos );
737 ScBaseCell* pCell = pDoc->GetCell( aScAddress );
738 return ( !pCell || pCell->GetCellType() == CELLTYPE_NOTE );
741 static sal_Bool lcl_IsHalfWidthKatakana ( const ::rtl::OUString& rString )
743 const sal_Unicode *pString = rString.getStr();
744 sal_Int32 nLen = rString.getLength();
746 for ( sal_Int32 i = 0; i < nLen; ++i )
748 if ( pString[i] < 0xFF00 || pString[i] > 0xFFEF )
749 return sal_False;
752 return sal_True;
755 static sal_Bool lcl_IsFullWidthKatakana ( const ::rtl::OUString& rString )
757 const sal_Unicode *pString = rString.getStr();
758 sal_Int32 nLen = rString.getLength();
760 for ( sal_Int32 i = 0; i < nLen; ++i )
762 if ( pString[i] < 0x30A0 || pString[i] > 0x30FF )
763 return sal_False;
766 return sal_True;
769 static sal_Bool lcl_IsFullWidthHiragana ( const ::rtl::OUString& rString )
771 const sal_Unicode *pString = rString.getStr();
772 sal_Int32 nLen = rString.getLength();
774 for ( sal_Int32 i = 0; i < nLen; ++i )
776 if ( pString[i] < 0x3040 || pString[i] > 0x309F )
777 return sal_False;
780 return sal_True;
783 static sal_uInt16 lcl_GetKanaType ( const ::boost::optional< ::rtl::OUString >& pText )
785 sal_uInt16 aKanaType = 0;
787 if ( lcl_IsHalfWidthKatakana ( *pText ) )
788 aKanaType = 0x00;
789 else if ( lcl_IsFullWidthKatakana ( *pText ) )
790 aKanaType = 0x01;
791 else if ( lcl_IsFullWidthHiragana ( *pText ) )
792 aKanaType = 0x02;
794 return aKanaType;
797 static ScBaseCell* lcl_CreateTextCell ( const String& rString, ScDocument* pDoc,
798 const ::boost::optional< ::rtl::OUString >& pPhoneticText )
800 ScBaseCell *pCell = 0;
802 if ( pPhoneticText && pPhoneticText->getLength() )
804 PhoneticPortionVec xPortions;
805 sal_uInt16 aKanaType = lcl_GetKanaType ( pPhoneticText );
806 ScPhonetic aPhonetic ( 0, 0x30 | aKanaType , 0, *pPhoneticText, xPortions );
807 pCell = new ScAsianStringCell( rString, aPhonetic );
809 else
811 pCell = ScBaseCell::CreateTextCell( rString, pDoc );
814 return pCell;
817 void ScXMLTableRowCellContext::EndElement()
819 if (!bHasSubTable)
821 if (bHasTextImport && rXMLImport.GetRemoveLastChar())
823 if (rXMLImport.GetTextImport()->GetCursor().is())
825 //GetImport().GetTextImport()->GetCursor()->gotoEnd(sal_False);
826 if( GetImport().GetTextImport()->GetCursor()->goLeft( 1, sal_True ) )
828 GetImport().GetTextImport()->GetText()->insertString(
829 GetImport().GetTextImport()->GetCursorAsRange(), rtl::OUString(),
830 sal_True );
832 rXMLImport.GetTextImport()->ResetCursor();
835 table::CellAddress aCellPos = rXMLImport.GetTables().GetRealCellPos();
836 if (aCellPos.Column > 0 && nRepeatedRows > 1)
837 aCellPos.Row -= (nRepeatedRows - 1);
838 uno::Reference<table::XCellRange> xCellRange(rXMLImport.GetTables().GetCurrentXCellRange());
839 if (xCellRange.is())
841 if (bIsMerged)
842 DoMerge(aCellPos, nMergedCols - 1, nMergedRows - 1);
843 if ( !pOUFormula )
845 ::boost::optional< rtl::OUString > pOUText;
847 if(nCellType == util::NumberFormat::TEXT)
849 if (xLockable.is())
850 xLockable->removeActionLock();
852 // #i61702# The formatted text content of xBaseCell / xLockable is invalidated,
853 // so it can't be used after calling removeActionLock (getString always uses the document).
855 if (CellExists(aCellPos) && ((nCellsRepeated > 1) || (nRepeatedRows > 1)))
857 if (!xBaseCell.is())
861 xBaseCell.set(xCellRange->getCellByPosition(aCellPos.Column, aCellPos.Row));
863 catch (lang::IndexOutOfBoundsException&)
865 DBG_ERRORFILE("It seems here are to many columns or rows");
868 uno::Reference <text::XText> xTempText (xBaseCell, uno::UNO_QUERY);
869 if (xTempText.is())
871 pOUText.reset(xTempText->getString());
874 if ( (!pOUTextContent && !pOUText && !pOUTextValue)
875 && ( (pOUTextContent && !pOUTextContent->getLength()) || !pOUTextContent )
876 && ( (pOUText && !pOUText->getLength()) || !pOUText )
877 && ( (pOUTextValue && !pOUTextValue->getLength()) || !pOUTextValue ))
878 bIsEmpty = sal_True;
880 sal_Bool bWasEmpty = bIsEmpty;
881 // uno::Reference <table::XCell> xCell;
882 table::CellAddress aCurrentPos( aCellPos );
883 if ((pContentValidationName && pContentValidationName->getLength()) ||
884 pMyAnnotation || pDetectiveObjVec || pCellRangeSource)
885 bIsEmpty = sal_False;
887 ScMyTables& rTables = rXMLImport.GetTables();
888 for (sal_Int32 i = 0; i < nCellsRepeated; ++i)
890 aCurrentPos.Column = aCellPos.Column + i;
891 if (i > 0)
892 rTables.AddColumn(sal_False);
893 if (!bIsEmpty)
895 for (sal_Int32 j = 0; j < nRepeatedRows; ++j)
897 aCurrentPos.Row = aCellPos.Row + j;
898 if ((aCurrentPos.Column == 0) && (j > 0))
900 rTables.AddRow();
901 rTables.AddColumn(sal_False);
903 if (CellExists(aCurrentPos))
905 // test - bypass the API
906 // if (xBaseCell.is() && (aCurrentPos == aCellPos))
907 // xCell.set(xBaseCell);
908 // else
909 // {
910 // try
911 // {
912 // xCell.set(xCellRange->getCellByPosition(aCurrentPos.Column, aCurrentPos.Row));
913 // }
914 // catch (lang::IndexOutOfBoundsException&)
915 // {
916 // DBG_ERRORFILE("It seems here are to many columns or rows");
917 // }
918 // }
920 // test - bypass the API
921 // if ((!(bIsCovered) || (xCell->getType() == table::CellContentType_EMPTY)))
922 if ((!(bIsCovered) || lcl_IsEmptyOrNote( rXMLImport.GetDocument(), aCurrentPos )))
924 switch (nCellType)
926 case util::NumberFormat::TEXT:
928 sal_Bool bDoIncrement = sal_True;
929 if (rTables.IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row))
931 LockSolarMutex();
932 // test - bypass the API
933 // ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell);
934 // if (pCellObj)
935 // {
936 // if(pOUTextValue && pOUTextValue->getLength())
937 // pCellObj->SetFormulaResultString(*pOUTextValue);
938 // else if (pOUTextContent && pOUTextContent->getLength())
939 // pCellObj->SetFormulaResultString(*pOUTextContent);
940 // else if ( i > 0 && pOUText && pOUText->getLength() )
941 // {
942 // pCellObj->SetFormulaResultString(*pOUText);
943 // }
944 // else
945 // bDoIncrement = sal_False;
946 // }
947 // else
948 // bDoIncrement = sal_False;
949 ScAddress aScAddress;
950 ScUnoConversion::FillScAddress( aScAddress, aCurrentPos );
951 ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( aScAddress );
952 bDoIncrement = ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA );
953 if ( bDoIncrement )
955 ScFormulaCell* pFCell = static_cast<ScFormulaCell*>(pCell);
956 if (pOUTextValue && pOUTextValue->getLength())
957 pFCell->SetHybridString( *pOUTextValue );
958 else if (pOUTextContent && pOUTextContent->getLength())
959 pFCell->SetHybridString( *pOUTextContent );
960 else if ( i > 0 && pOUText && pOUText->getLength() )
961 pFCell->SetHybridString( *pOUText );
962 else
963 bDoIncrement = sal_False;
966 else
968 // test - bypass the API
969 // uno::Reference <text::XText> xText (xCell, uno::UNO_QUERY);
970 // if (xText.is())
971 // {
972 // if(pOUTextValue && pOUTextValue->getLength())
973 // xText->setString(*pOUTextValue);
974 // else if (pOUTextContent && pOUTextContent->getLength())
975 // xText->setString(*pOUTextContent);
976 // else if ( i > 0 && pOUText && pOUText->getLength() )
977 // {
978 // xText->setString(*pOUText);
979 // }
980 // else
981 // bDoIncrement = sal_False;
982 // }
983 LockSolarMutex();
984 ScBaseCell* pNewCell = NULL;
985 ScDocument* pDoc = rXMLImport.GetDocument();
986 if (pOUTextValue && pOUTextValue->getLength())
987 pNewCell = lcl_CreateTextCell( *pOUTextValue, pDoc, pOUPhoneticText );
988 else if (pOUTextContent && pOUTextContent->getLength())
989 pNewCell = lcl_CreateTextCell( *pOUTextContent, pDoc, pOUPhoneticText );
990 else if ( i > 0 && pOUText && pOUText->getLength() )
991 pNewCell = lcl_CreateTextCell( *pOUText, pDoc, pOUPhoneticText );
993 bDoIncrement = pNewCell != NULL;
994 if ( bDoIncrement )
996 ScAddress aScAddress;
997 ScUnoConversion::FillScAddress( aScAddress, aCurrentPos );
998 pDoc->PutCell( aScAddress, pNewCell );
1001 // #i56027# This is about setting simple text, not edit cells,
1002 // so ProgressBarIncrement must be called with bEditCell = FALSE.
1003 // Formatted text that is put into the cell by the child context
1004 // is handled below (bIsEmpty is TRUE then).
1005 if (bDoIncrement || bHasTextImport)
1006 rXMLImport.ProgressBarIncrement(sal_False);
1008 break;
1009 case util::NumberFormat::NUMBER:
1010 case util::NumberFormat::PERCENT:
1011 case util::NumberFormat::CURRENCY:
1012 case util::NumberFormat::TIME:
1013 case util::NumberFormat::DATETIME:
1014 case util::NumberFormat::LOGICAL:
1016 if (rTables.IsPartOfMatrix(aCurrentPos.Column, aCurrentPos.Row))
1018 LockSolarMutex();
1019 // test - bypass the API
1020 // ScCellObj* pCellObj = (ScCellObj*)ScCellRangesBase::getImplementation(xCell);
1021 // if (pCellObj)
1022 // pCellObj->SetFormulaResultDouble(fValue);
1023 ScAddress aScAddress;
1024 ScUnoConversion::FillScAddress( aScAddress, aCurrentPos );
1025 ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( aScAddress );
1026 if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
1027 static_cast<ScFormulaCell*>(pCell)->SetHybridDouble( fValue );
1029 else
1031 // test - bypass the API
1032 // xCell->setValue(fValue);
1033 LockSolarMutex();
1035 // #i62435# Initialize the value cell's script type
1036 // if the default style's number format is latin-only.
1037 // If the cell uses a different format, the script type
1038 // will be reset when the style is applied.
1040 ScBaseCell* pNewCell = new ScValueCell(fValue);
1041 if ( rXMLImport.IsLatinDefaultStyle() )
1042 pNewCell->SetScriptType( SCRIPTTYPE_LATIN );
1043 rXMLImport.GetDocument()->PutCell(
1044 sal::static_int_cast<SCCOL>( aCurrentPos.Column ),
1045 sal::static_int_cast<SCROW>( aCurrentPos.Row ),
1046 sal::static_int_cast<SCTAB>( aCurrentPos.Sheet ),
1047 pNewCell );
1049 rXMLImport.ProgressBarIncrement(sal_False);
1051 break;
1052 default:
1054 DBG_ERROR("no cell type given");
1056 break;
1060 SetAnnotation(aCurrentPos);
1061 SetDetectiveObj( aCurrentPos );
1062 SetCellRangeSource( aCurrentPos );
1064 else
1066 if (!bWasEmpty || (pMyAnnotation))
1068 if (aCurrentPos.Row > MAXROW)
1069 rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
1070 else
1071 rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
1076 else
1078 if ( pOUPhoneticText && pOUPhoneticText->getLength() )
1080 ScAddress aScAddress;
1081 ScDocument* pDoc = rXMLImport.GetDocument();
1082 ScUnoConversion::FillScAddress( aScAddress, aCurrentPos );
1083 ScBaseCell *pBaseCell = pDoc->GetCell( aScAddress );
1084 PhoneticPortionVec xPortions;
1085 sal_uInt16 aKanaType = lcl_GetKanaType ( pOUPhoneticText );
1086 ScPhonetic aPhonetic ( 0, 0x30 | aKanaType , 0, *pOUPhoneticText, xPortions );
1087 ScBaseCell *pNewCell = new ScAsianEditCell( (const ScEditCell&) *pBaseCell, *pDoc, aPhonetic );
1088 pDoc->PutCell( aScAddress, pNewCell );
1090 // #i56027# If the child context put formatted text into the cell,
1091 // bIsEmpty is TRUE and ProgressBarIncrement has to be called
1092 // with bEditCell = TRUE.
1093 if (bHasTextImport)
1094 rXMLImport.ProgressBarIncrement(sal_True);
1095 if ((i == 0) && (aCellPos.Column == 0))
1096 for (sal_Int32 j = 1; j < nRepeatedRows; ++j)
1098 rTables.AddRow();
1099 rTables.AddColumn(sal_False);
1103 if (nCellsRepeated > 1 || nRepeatedRows > 1)
1105 SetCellProperties(xCellRange, aCellPos); // set now only the validation for the complete range with the given cell as start cell
1106 //SetType(xCellRange, aCellPos);
1107 SCCOL nStartCol(aCellPos.Column < MAXCOL ? static_cast<SCCOL>(aCellPos.Column) : MAXCOL);
1108 SCROW nStartRow(aCellPos.Row < MAXROW ? static_cast<SCROW>(aCellPos.Row) : MAXROW);
1109 SCCOL nEndCol(aCellPos.Column + nCellsRepeated - 1 < MAXCOL ? static_cast<SCCOL>(aCellPos.Column + nCellsRepeated - 1) : MAXCOL);
1110 SCROW nEndRow(aCellPos.Row + nRepeatedRows - 1 < MAXROW ? static_cast<SCROW>(aCellPos.Row + nRepeatedRows - 1) : MAXROW);
1111 ScRange aScRange( nStartCol, nStartRow, aCellPos.Sheet,
1112 nEndCol, nEndRow, aCellPos.Sheet );
1113 rXMLImport.GetStylesImportHelper()->AddRange(aScRange);
1115 else if (CellExists(aCellPos))
1117 rXMLImport.GetStylesImportHelper()->AddCell(aCellPos);
1119 // test - bypass the API
1120 // SetCellProperties(xCell); // set now only the validation
1121 SetCellProperties(xCellRange, aCellPos);
1123 //SetType(xTempCell);
1126 else
1128 if (CellExists(aCellPos))
1130 uno::Reference <table::XCell> xCell;
1133 xCell.set(xCellRange->getCellByPosition(aCellPos.Column , aCellPos.Row));
1135 catch (lang::IndexOutOfBoundsException&)
1137 DBG_ERRORFILE("It seems here are to many columns or rows");
1139 if (xCell.is() && pOUFormula)
1141 SetCellProperties(xCell); // set now only the validation
1142 DBG_ASSERT(((nCellsRepeated == 1) && (nRepeatedRows == 1)), "repeated cells with formula not possible now");
1143 rXMLImport.GetStylesImportHelper()->AddCell(aCellPos);
1144 if (!bIsMatrix)
1146 LockSolarMutex();
1147 ScCellObj* pCellObj =
1148 static_cast<ScCellObj*>(ScCellRangesBase::getImplementation(
1149 xCell));
1150 if (pCellObj)
1152 pCellObj->SetFormulaWithGrammar( *pOUFormula, eGrammar);
1153 if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength())
1154 pCellObj->SetFormulaResultString( *pOUTextValue);
1155 else if (fValue != 0.0)
1156 pCellObj->SetFormulaResultDouble( fValue);
1159 else
1161 if (nMatrixCols > 0 && nMatrixRows > 0)
1163 rXMLImport.GetTables().AddMatrixRange(
1164 aCellPos.Column, aCellPos.Row,
1165 aCellPos.Column + nMatrixCols - 1,
1166 aCellPos.Row + nMatrixRows - 1,
1167 *pOUFormula, eGrammar);
1170 SetAnnotation( aCellPos );
1171 SetDetectiveObj( aCellPos );
1172 SetCellRangeSource( aCellPos );
1173 rXMLImport.ProgressBarIncrement(sal_False);
1176 else
1178 if (aCellPos.Row > MAXROW)
1179 rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_ROW_OVERFLOW);
1180 else
1181 rXMLImport.SetRangeOverflowType(SCWARN_IMPORT_COLUMN_OVERFLOW);
1186 UnlockSolarMutex();
1188 bIsMerged = sal_False;
1189 bHasSubTable = sal_False;
1190 nMergedCols = 1;
1191 nMergedRows = 1;
1192 nCellsRepeated = 1;
1195 void ScXMLTableRowCellContext::SetPhoneticText(const rtl::OUString& rOUPhoneticText)
1197 pOUPhoneticText.reset(rOUPhoneticText);