/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// Check the paste flag to see whether we want to paste this cell. If the // flag says we don't want to paste this cell, we'll return with true.
InsertDeleteFlags nFlags = getInsertFlag(); bool bNumeric = (nFlags & InsertDeleteFlags::VALUE) != InsertDeleteFlags::NONE; bool bDateTime = (nFlags & InsertDeleteFlags::DATETIME) != InsertDeleteFlags::NONE; bool bString = (nFlags & InsertDeleteFlags::STRING) != InsertDeleteFlags::NONE; bool bBoolean = (nFlags & InsertDeleteFlags::SPECIAL_BOOLEAN) != InsertDeleteFlags::NONE; bool bFormula = (nFlags & InsertDeleteFlags::FORMULA) != InsertDeleteFlags::NONE;
switch (rSrcCell.getType())
{ case CELLTYPE_VALUE:
{ bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric; if (!bPaste) // Don't paste this.
rSrcCell.clear();
} break; case CELLTYPE_STRING: case CELLTYPE_EDIT:
{ if (!bString) // Skip pasting.
rSrcCell.clear();
} break; case CELLTYPE_FORMULA:
{ if (bBoolean)
{ // Check if this formula cell is a boolean cell, and if so, go ahead and paste it. const ScTokenArray* pCode = rSrcCell.getFormula()->GetCode(); if (pCode && pCode->GetLen() == 1)
{ const formula::FormulaToken* p = pCode->FirstToken(); if (p->GetOpCode() == ocTrue || p->GetOpCode() == ocFalse) // This is a boolean formula. Good. break;
}
}
if (bFormula) // Good. break;
FormulaError nErr = rSrcCell.getFormula()->GetErrCode(); if (nErr != FormulaError::NONE)
{ // error codes are cloned with values if (!bNumeric) // Error code is treated as numeric value. Don't paste it.
rSrcCell.clear(); else
{ // Turn this into a formula cell with just the error code.
ScFormulaCell* pErrCell = new ScFormulaCell(*mpClipDoc, rSrcPos);
pErrCell->SetErrCode(nErr);
rSrcCell.set(pErrCell);
}
} elseif (rSrcCell.getFormula()->IsEmptyDisplayedAsString())
{ // Empty stays empty and doesn't become 0.
rSrcCell.clear();
} elseif (rSrcCell.getFormula()->IsValue())
{ bool bPaste = isDateCell(rSrcCol, rSrcPos.Row()) ? bDateTime : bNumeric; if (!bPaste)
{ // Don't paste this.
rSrcCell.clear(); break;
}
// Turn this into a numeric cell.
rSrcCell.set(rSrcCell.getFormula()->GetValue());
} elseif (bString)
{
svl::SharedString aStr = rSrcCell.getFormula()->GetString(); if (aStr.isEmpty())
{ // do not clone empty string
rSrcCell.clear(); break;
}
// Turn this into a string or edit cell. if (rSrcCell.getFormula()->IsMultilineResult())
{
std::unique_ptr<EditTextObject> pObj(mrDestDoc.CreateSharedStringTextObject(
rSrcCell.getFormula()->GetString()));
rSrcCell.set(*pObj);
} else
rSrcCell.set(rSrcCell.getFormula()->GetString());
} else // We don't want to paste this.
rSrcCell.clear();
} break; case CELLTYPE_NONE: default: // There is nothing to paste.
rSrcCell.clear();
}
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.