Kaydet (Commit) d5d96b15 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

fdo#60740: Export multi-line formula results to ods without UNO API.

Change-Id: I69391a9d2ffb0afae7f40c8449196c986375db3f
üst a8bf7099
......@@ -310,6 +310,7 @@ public:
void SetResultToken( const formula::FormulaToken* pToken );
double GetResultDouble() const;
OUString GetResultString() const;
void SetErrCode( sal_uInt16 n );
bool IsHyperLinkCell() const;
......
......@@ -1705,6 +1705,11 @@ double ScFormulaCell::GetResultDouble() const
return aResult.GetDouble();
}
OUString ScFormulaCell::GetResultString() const
{
return aResult.GetString();
}
void ScFormulaCell::SetResultMatrix( SCCOL nCols, SCROW nRows, const ScConstMatrixRef& pMat, formula::FormulaToken* pUL )
{
aResult.SetMatrix(nCols, nRows, pMat, pUL);
......
......@@ -3352,9 +3352,7 @@ void ScXMLExport::WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount)
else if (aCell.nType == table::CellContentType_FORMULA && IsMultiLineFormulaCell(aCell))
{
bEditCell = true;
uno::Reference<text::XText> xText(xCurrentTableCellRange->getCellByPosition(aCell.aCellAddress.Column, aCell.aCellAddress.Row), uno::UNO_QUERY);
if ( xText.is())
GetTextParagraphExport()->exportText(xText, false, false);
WriteMultiLineFormulaResult(aCell.maBaseCell.mpFormula);
}
else
{
......@@ -3404,6 +3402,42 @@ void ScXMLExport::WriteEditCell(const EditTextObject* pText)
flushParagraph(*this, aParaTexts[nCurPara], xMapper, xStylePool, rAttrMap, itPara, itSecEnd);
}
void ScXMLExport::WriteMultiLineFormulaResult(const ScFormulaCell* pCell)
{
OUString aElemName = GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TEXT, GetXMLToken(XML_P));
OUString aResStr = pCell->GetResultString();
const sal_Unicode* p = aResStr.getStr();
const sal_Unicode* pEnd = p + static_cast<size_t>(aResStr.getLength());
const sal_Unicode* pPara = p; // paragraph head.
for (; p != pEnd; ++p)
{
if (*p != '\n')
continue;
// flush the paragraph.
OUString aContent;
if (*pPara == '\n')
++pPara;
if (p > pPara)
aContent = OUString(pPara, p-pPara);
SvXMLElementExport aElem(*this, aElemName, false, false);
Characters(aContent);
pPara = p;
}
OUString aContent;
if (*pPara == '\n')
++pPara;
if (pEnd > pPara)
aContent = OUString(pPara, pEnd-pPara);
SvXMLElementExport aElem(*this, aElemName, false, false);
Characters(aContent);
}
void ScXMLExport::ExportShape(const uno::Reference < drawing::XShape >& xShape, awt::Point* pPoint)
{
uno::Reference < beans::XPropertySet > xShapeProps ( xShape, uno::UNO_QUERY );
......
......@@ -61,6 +61,7 @@ class ScXMLCachedRowAttrAccess;
class ScRangeName;
class ScXMLEditAttributeMap;
class EditTextObject;
class ScFormulaCell;
typedef std::vector< com::sun::star::uno::Reference < com::sun::star::drawing::XShapes > > ScMyXShapesVec;
......@@ -180,6 +181,7 @@ class ScXMLExport : public SvXMLExport
void WriteTable(sal_Int32 nTable, const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSpreadsheet>& xTable);
void WriteCell(ScMyCell& aCell, sal_Int32 nEqualCellCount);
void WriteEditCell(const EditTextObject* pText);
void WriteMultiLineFormulaResult(const ScFormulaCell* pCell);
void WriteAreaLink(const ScMyCell& rMyCell);
void WriteAnnotation(ScMyCell& rMyCell);
void WriteDetective(const ScMyCell& rMyCell);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment