/* -*- 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/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
// HACK! to avoid neither #REF! from ColRowNames // if a name is added as actually range in the overall formula, // but is interpreted at the individual representation as single-cell reference bool bColRowName = pFCell->HasColRowName(); if ( bColRowName )
{ // ColRowName from RPN-Code? if ( pFCell->GetCode()->GetCodeLen() <= 1 )
{ // ==1: area // ==0: would be an area if...
OUString aBraced = "(" + rStrExp + ")";
pFCell.emplace(*m_pDoc, m_CursorPos, aBraced, bMatrixFormula);
pFCell->SetLimitString(true);
} else
bColRowName = false;
}
FormulaError nErrCode = pFCell->GetErrCode(); if ( nErrCode == FormulaError::NONE || pFCell->IsMatrix() )
{
SvNumberFormatter& aFormatter = *(m_pDoc->GetFormatTable()); const Color* pColor; if (pFCell->IsMatrix())
{
rStrResult = pFCell->GetString().getString();
} elseif (pFCell->IsValue())
{ double n = pFCell->GetValue();
sal_uLong nFormat = aFormatter.GetStandardFormat( n, 0,
pFCell->GetFormatType(), ScGlobal::eLnge );
aFormatter.GetOutputString( n, nFormat, rStrResult, &pColor );
} else
{
sal_uLong nFormat = aFormatter.GetStandardFormat(
pFCell->GetFormatType(), ScGlobal::eLnge);
aFormatter.GetOutputString( pFCell->GetString().getString(), nFormat,
rStrResult, &pColor ); // Indicate it's a string, so a number string doesn't look numeric. // Escape embedded quotation marks first by doubling them, as // usual. Actually the result can be copy-pasted from the result // box as literal into a formula expression.
rStrResult = "\"" + rStrResult.replaceAll( "\"", "\"\"") + "\"";
}
bool ScFormulaDlg::IsDocAllowed(SfxObjectShell* pDocSh) const
{ // not allowed: different from this doc, and no name // pDocSh is always a ScDocShell return !pDocSh || &static_cast<ScDocShell*>(pDocSh)->GetDocument() == m_pDoc || pDocSh->HasName(); // everything else is allowed
}
// if edit line is empty (caused by document switching) -> string is empty // -> don't delete old formula if ( aStrItem.GetValue().isEmpty() )
aRetItem.SetValue( false ); // sal_False = Cancel
m_aHelper.SetDispatcherLock( false ); // turn off modal-mode
// force Enable() of edit line
ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); if ( pScViewShell )
pScViewShell->UpdateInputHandler();
} void ScFormulaDlg::switchBack()
{ // back to the document // (foreign doc could be above - #34222#)
ScInputHandler* pHdl = m_pViewShell->GetInputHandler(); if ( pHdl )
{
pHdl->ViewShellGone(nullptr); // -> get active view
pHdl->ShowRefFrame();
}
// restore current chart (cause mouse-RefInput)
ScTabViewShell* pScViewShell = dynamic_cast<ScTabViewShell*>( SfxViewShell::Current() ); if ( !pScViewShell ) return;
if(rVD.GetCurX()!=nCol || rVD.GetCurY()!=nRow)
pScViewShell->SetCursor(nCol,nRow);
}
formula::FormEditData* ScFormulaDlg::getFormEditData() const
{
ScTabViewShell* pViewShell = m_pViewShell; if (pViewShell) return pViewShell->GetFormEditData(); return nullptr;
} void ScFormulaDlg::setCurrentFormula(const OUString& _sReplacement)
{
ScModule* pScMod = ScModule::get();
{ //fdo#69971 We need the EditEngine Modification handler of the inputbar that we //are feeding to be disabled while this dialog is open. Otherwise we end up in //a situation where... //a) this ScFormulaDlg changes the editengine //b) the modify callback gets called //c) which also modifies the editengine //d) on return from that modify handler the editengine attempts to use // old node pointers which were replaced and removed by c // //We turn it off in the ctor and back on in the dtor, but if calc has //to repaint, e.g. when switching to another window and back, then in //ScMultiTextWnd::Paint a new editengine will have been created via //GetEditView with its default Modification handler enabled. So ensure //it's off when we will access it via InputReplaceSelection
pScMod->InputTurnOffWinEngine();
}
pScMod->InputReplaceSelection(_sReplacement);
} void ScFormulaDlg::setSelection(sal_Int32 _nStart, sal_Int32 _nEnd)
{
ScModule::get()->InputSetSelection(_nStart, _nEnd);
} void ScFormulaDlg::getSelection(sal_Int32& _nStart, sal_Int32& _nEnd) const
{
ScModule::get()->InputGetSelection(_nStart, _nEnd);
}
OUString ScFormulaDlg::getCurrentFormula() const
{
ScFormEditData* pData = m_pViewShell->GetFormEditData(); if (pData && pData->GetInputHandler()) return pData->GetInputHandler()->GetFormString(); return u""_ustr;
}
formula::IFunctionManager* ScFormulaDlg::getFunctionManager()
{ return ScGlobal::GetStarCalcFunctionMgr();
}
uno::Reference< sheet::XFormulaParser> ScFormulaDlg::getFormulaParser() const
{ return m_xParser;
}
uno::Reference< sheet::XFormulaOpCodeMapper> ScFormulaDlg::getFormulaOpCodeMapper() const
{ return m_xOpCodeMapper;
}
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.