/* -*- 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 .
*/
if( nMouseClickPageId == 0 )
{ // Click in the area next to the existing tabs:
SfxDispatcher* pDispatcher = rViewData.GetViewShell()->GetViewFrame().GetDispatcher();
pDispatcher->Execute( FID_TAB_DESELECTALL, SfxCallMode::SYNCHRON | SfxCallMode::RECORD ); // forget page ID, to be really sure that the dialog is not called twice
nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
}
// Insert a new sheet at the right end, with default name.
ScDocument& rDoc = rViewData.GetDocument();
ScModule* pScMod = ScModule::get(); if (!rDoc.IsDocEditable() || pScMod->IsTableLocked()) return;
// auto-accept any in-process input - which would otherwise end up on the new sheet if (!pScMod->IsFormulaMode())
pScMod->InputEnterHandler();
void ScTabControl::Select()
{ /* Remember last clicked page ID. */
nSelPageIdByMouse = nMouseClickPageId; /* Reset nMouseClickPageId, so that next Select() call may invalidate
nSelPageIdByMouse (i.e. if called from keyboard). */
nMouseClickPageId = TabBar::PAGE_NOT_FOUND;
void ScTabControl::SwitchToPageId(sal_uInt16 nId)
{ if (!nId) return;
bool bAlreadySelected = IsPageSelected( nId ); //make the clicked page the current one
SetCurPageId( nId ); //change the selection when the current one is not already //selected or part of a multi selection if(bAlreadySelected) return;
sal_uInt16 nCount = GetMaxId();
for (sal_uInt16 i=1; i<=nCount; i++)
SelectPage( i, i==nId );
Select();
if (comphelper::LibreOfficeKit::isActive())
{ // notify LibreOfficeKit about changed page
OString aPayload = OString::number(nId - 1);
rViewData.GetViewShell()->libreOfficeKitViewCallback(LOK_CALLBACK_SET_PART, aPayload);
}
}
// first activate ViewFrame (Bug 19493):
pViewSh->SetActive();
if (rCEvt.GetCommand() != CommandEventId::ContextMenu || bDisable) return;
// #i18735# select the page that is under the mouse cursor // if multiple tables are selected and the one under the cursor // is not part of them then unselect them
sal_uInt16 nId = GetPageId( rCEvt.GetMousePosPixel() );
SwitchToPageId(nId);
// #i52073# OLE inplace editing has to be stopped before showing the sheet tab context menu
pViewSh->DeactivateOle();
// Popup-Menu: // get Dispatcher from ViewData (ViewFrame) instead of Shell (Frame), so it can't be null
rViewData.GetDispatcher().ExecutePopup( u"sheettab"_ustr );
}
TransferableObjectDescriptor aObjDesc;
rDocSh.FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScTransferObj ctor
rtl::Reference<ScTransferObj> pTransferObj = new ScTransferObj( std::move(pClipDoc), std::move(aObjDesc) );
ScDocument& rDoc = rViewData.GetDocument(); const ScDragData* pData = ScModule::get()->GetDragData(); if ( pData && pData->pCellTransfer &&
(pData->pCellTransfer->GetDragSourceFlags() & ScDragSrc::Table) &&
pData->pCellTransfer->GetSourceDocument() == &rDoc )
{ // moving of tables within the document
SCTAB nPos = GetPrivatDropPos( rEvt.maPosPixel );
HideDropPos();
if ( nPos == pData->pCellTransfer->GetVisibleTab() && rEvt.mnAction == DND_ACTION_MOVE )
{ // #i83005# do nothing - don't move to the same position // (too easily triggered unintentionally, and might take a long time in large documents)
} else
{ if ( !rDoc.GetChangeTrack() && rDoc.IsDocEditable() )
{ //! use table selection from the tab control where dragging was started?
rViewData.GetView()->MoveTable( lcl_DocShellNr(rDoc), nPos, rEvt.mnAction != DND_ACTION_MOVE );
TabBarAllowRenamingReturnCode nRet = TABBAR_RENAMING_CANCEL;
sal_uInt16 nId = GetEditPageId(); if ( nId )
{
SCTAB nTab = nId - 1;
OUString aNewName = GetEditText(); bool bDone = pViewSh->RenameTable( aNewName, nTab ); if ( bDone )
nRet = TABBAR_RENAMING_YES; elseif ( bErrorShown )
{ // if the error message from this TabControl is currently visible, // don't end edit mode now, to avoid problems when returning to // the other call (showing the error) - this should not happen
OSL_FAIL("ScTabControl::AllowRenaming: nested calls");
nRet = TABBAR_RENAMING_NO;
} elseif (rViewData.GetDocShell().IsInModalMode())
{ // don't show error message above any modal dialog // instead cancel renaming without error message // e.g. start with default Sheet1, add another sheet // alt+left click on Sheet2 tab, edit to say Sheet1 // ctrl+S to trigger modal file save dialog
nRet = TABBAR_RENAMING_CANCEL;
} else
{
bErrorShown = true;
pViewSh->ErrorMessage( STR_INVALIDTABNAME );
bErrorShown = false;
nRet = TABBAR_RENAMING_NO;
}
} return nRet;
}
void ScTabControl::EndRenaming()
{ if ( HasFocus() )
rViewData.GetView()->ActiveGrabFocus();
}
void ScTabControl::Mirror()
{
TabBar::Mirror(); if( nSelPageIdByMouse != TabBar::PAGE_NOT_FOUND )
{
tools::Rectangle aRect( GetPageRect( GetCurPageId() ) ); if( !aRect.IsEmpty() )
SetPointerPosPixel( aRect.Center() );
nSelPageIdByMouse = TabBar::PAGE_NOT_FOUND; // only once after a Select()
}
}
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.