/* -*- 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 .
*/
void ScFormulaReferenceHelper::dispose()
{ // common cleanup for ScAnyRefDlg and ScFormulaDlg is done here
HideReference();
enableInput( true );
ScInputHandler* pInputHdl = ScModule::get()->GetInputHdl(); if ( pInputHdl )
pInputHdl->ResetDelayTimer(); // stop the timer for disabling the input line
if(pTabViewShell!=nullptr)
{ // bDoneRefMode is sal_False when called from before SetReference. // In that case, RefMode was just started and must not be ended now.
if ( bDoneRefMode )
pTabViewShell->DoneRefMode();
pTabViewShell->ClearHighlightRanges();
// Exclude ';' semicolon as it is the separator for ParseWithNames() used // in ShowSimpleReference(). Also sheet separator '.' dot is part of simple // reference (could be array col/row separator as well but then in '{' '}' // braces). Prefer '!' exclamation mark to be intersection operator rather // than Excel sheet separator. if (comphelper::string::indexOfAny( rStr, u"()+-*/^%&=<>~! #[]{},|\\@", 0) != -1)
{
ShowFormulaReference(rStr);
} else
{
ShowSimpleReference(rStr);
}
}
if( m_pRefEdit == pEdit ) // is this the active ref edit field?
{
m_pRefEdit->GrabFocus(); // before RefInputDone()
m_pDlg->RefInputDone( true ); // finish ref input
} else
{
m_pDlg->RefInputDone( true ); // another active ref edit?
m_pDlg->RefInputStart( pEdit, pButton ); // start ref input // pRefEdit might differ from pEdit after RefInputStart() (i.e. ScFormulaDlg) if( m_pRefEdit )
m_pRefEdit->GrabFocus();
}
}
void ScFormulaReferenceHelper::DoClose( sal_uInt16 nId )
{
SfxApplication* pSfxApp = SfxGetpApp();
SetDispatcherLock( false ); //! here and in dtor ?
SfxViewFrame* pViewFrm = SfxViewFrame::Current(); if ( pViewFrm && pViewFrm->HasChildWindow(FID_INPUTLINE_STATUS) )
{ // The input row is disabled with ToolBox::Disable disabled, thus it must be // reenabled with ToolBox::Enable (before the AppWindow is enabled) // for the buttons to be drawn as enabled.
SfxChildWindow* pChild = pViewFrm->GetChildWindow(FID_INPUTLINE_STATUS); if (pChild)
{
ScInputWindow* pWin = static_cast<ScInputWindow*>(pChild->GetWindow());
pWin->Enable();
}
}
// find parent view frame to close dialog
SfxViewFrame* pMyViewFrm = nullptr; if ( m_pBindings )
{
SfxDispatcher* pMyDisp = m_pBindings->GetDispatcher(); if (pMyDisp)
pMyViewFrm = pMyDisp->GetFrame();
}
ScModule::get()->SetRefDialog(nId, false, pMyViewFrm);
ScTabViewShell* pScViewShell = ScTabViewShell::GetActiveViewShell(); if ( pScViewShell )
pScViewShell->UpdateInputHandler(true);
}
void ScFormulaReferenceHelper::SetDispatcherLock( bool bLock )
{ if (!comphelper::LibreOfficeKit::isActive())
{ // lock / unlock only the dispatchers of Calc documents
ScDocShell* pDocShell = static_cast<ScDocShell*>(SfxObjectShell::GetFirst(checkSfxObjectShell<ScDocShell>)); while (pDocShell)
{
SfxViewFrame* pFrame = SfxViewFrame::GetFirst(pDocShell); while (pFrame)
{
SfxDispatcher* pDisp = pFrame->GetDispatcher(); if (pDisp)
pDisp->Lock(bLock);
pFrame = SfxViewFrame::GetNext(*pFrame, pDocShell);
}
pDocShell = static_cast<ScDocShell*>(SfxObjectShell::GetNext(*pDocShell, checkSfxObjectShell<ScDocShell>));
} return; // if a new view is created while the dialog is open, // that view's dispatcher is locked when trying to create the dialog // for that view (ScTabViewShell::CreateRefDialog)
}
// lock / unlock only the dispatcher of Calc document
SfxDispatcher* pDisp = nullptr; if ( m_pBindings )
{
pDisp = m_pBindings->GetDispatcher();
} elseif(SfxViewFrame* pViewFrame = SfxViewFrame::Current())
{ if (dynamic_cast< ScTabViewShell* >(pViewFrame->GetViewShell()))
pDisp = pViewFrame->GetDispatcher();
}
void ScRefHandler::SwitchToDocument()
{
ScTabViewShell* pCurrent = ScTabViewShell::GetActiveViewShell(); if (pCurrent)
{
SfxObjectShell* pObjSh = pCurrent->GetObjectShell(); if ( pObjSh && pObjSh->GetTitle() == m_aDocName )
{ // right document already visible -> nothing to do return;
}
}
SfxViewShell* pSh = SfxViewShell::GetFirst( true, checkSfxViewShell<ScTabViewShell> ); while ( pSh )
{
SfxObjectShell* pObjSh = pSh->GetObjectShell(); if ( pObjSh && pObjSh->GetTitle() == m_aDocName )
{ // switch to first TabViewShell for document static_cast<ScTabViewShell*>(pSh)->SetActive(); return;
}
pSh = SfxViewShell::GetNext( *pSh, true, checkSfxViewShell<ScTabViewShell> );
}
}
bool ScRefHandler::IsDocAllowed(SfxObjectShell* pDocSh) const// pDocSh may be 0
{ // if aDocName isn't initialized, allow if ( m_aDocName.isEmpty() ) returntrue;
if ( !pDocSh ) returnfalse;
// default: allow only same document (overridden in function dialog) return m_aDocName==pDocSh->GetTitle();
}
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.