/* -*- 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 .
*/
case FID_TABLE_HIDE:
{ if ( rDoc.IsDocEditable() )
{
ScMarkData& rMark = rViewData.GetMarkData();
SCTAB nActiveTab = -1; // For the cases when user right clicks on a non-active tab and hides it. This case is possible for Online. if (pReqArgs)
{ const SfxPoolItem *pItem; if( pReqArgs->HasItem( FID_TABLE_HIDE, &pItem ) )
{
SCTAB nTabNumber = static_cast<const SfxInt16Item*>(pItem)->GetValue(); // Does selected sheets (tabs) list include the sheet to be hidden?
std::set<SCTAB>::iterator it = rMark.GetSelectedTabs().find(nTabNumber); if (it == rMark.GetSelectedTabs().end())
{ // No it doesn't, so we won't shift the selected tab. Let's remember its position.
nActiveTab = GetViewData().GetTabNo();
}
rMark.SelectOneTable(nTabNumber);
}
}
HideTable( rMark, nActiveTab );
}
} break;
case FID_INS_TABLE: case FID_INS_TABLE_EXT:
ExecuteInsertTable(rReq); break;
case FID_TAB_APPEND: case FID_TAB_RENAME: case FID_TAB_MENU_RENAME:
{ // FID_TAB_MENU_RENAME - "rename" in menu // FID_TAB_RENAME - "name"-property for basic // equal execute, but MENU_RENAME may be disabled inside GetState
ExecuteAppendOrRenameTable(rReq);
} break;
case FID_TAB_MOVE:
{
ExecuteMoveTable(rReq);
} break;
case FID_TAB_DUPLICATE:
{ // Get info about current document and selected tab
SCTAB nTab = rViewData.GetTabNo();
OUString aDocName = GetViewData().GetDocShell().GetTitle(SFX_TITLE_FULLNAME);
sal_uInt16 nDoc = 0; bool bCpy = true;
// Hard warning as there is potential of data loss on deletion
bDoIt = (RET_YES == xQueryBox->run());
} else
{ bool bHasData = false;
ScMarkData& rMark = rViewData.GetMarkData(); for ( SCTAB i = 0; i < nTabCount && !bHasData; i++ )
{ if ( rMark.GetTableSelect(i) && !rDoc.IsTabProtected(i) )
{
SCCOL nStartCol;
SCROW nStartRow;
bHasData = rDoc.GetDataStart( i, nStartCol, nStartRow );
}
} // Do not ask for confirmation if all selected tabs are empty if (bHasData)
{
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Question, VclButtonsType::YesNo,
aQueryDeleteTab));
xQueryBox->set_default_response(RET_YES);
// no parameter given, ask for confirmation
bDoIt = (RET_YES == xQueryBox->run());
} else
bDoIt = true;
}
}
if (bDoIt)
{
SCTAB nNewTab = nCurrentTab;
std::vector<SCTAB> TheTabs;
if (bHasIndex)
{ // sheet no. provided by the parameter
TheTabs.push_back(nTabNr); if (nNewTab > nTabNr && nNewTab > 0)
--nNewTab;
} else
{
SCTAB nFirstTab = 0; bool bTabFlag = false;
ScMarkData& rMark = rViewData.GetMarkData(); for (SCTAB i = 0; i < nTabCount; i++)
{ if (rMark.GetTableSelect(i) && !rDoc.IsTabProtected(i))
{
TheTabs.push_back(i);
bTabFlag = true; if (nNewTab == i && i+1 < nTabCount)
nNewTab++;
} if (!bTabFlag)
nFirstTab = i;
} if (nNewTab >= nTabCount - static_cast<SCTAB>(TheTabs.size()))
nNewTab = nFirstTab;
}
case FID_TABLE_VISIBLE:
rSet.Put( SfxBoolItem( nWhich, rDoc.IsVisible(nTab) )); break;
case FID_TABLE_HIDE:
{
sal_uInt16 nVis = 0; // enable menu : check to make sure we won't hide all sheets. we need at least one visible at all times. for ( SCTAB i=0; i < nTabCount && nVis<nTabSelCount + 1; i++ ) if (rDoc.IsVisible(i))
++nVis; if ( nVis<=nTabSelCount || !rDoc.IsDocEditable() )
rSet.DisableItem( nWhich );
} break;
case FID_TABLE_SHOW:
{ bool bHasHidden = false; for ( SCTAB i=0; i < nTabCount && !bHasHidden; i++ ) if (!rDoc.IsVisible(i))
bHasHidden = true; if ( !bHasHidden || rDoc.IsDocProtected() || nTabSelCount > 1 )
rSet.DisableItem( nWhich );
} break;
case FID_DELETE_TABLE:
{ if ( rDoc.GetChangeTrack() )
rSet.DisableItem( nWhich ); else
{
sal_uInt16 nVis = 0; for ( SCTAB i=0; i < nTabCount && nVis<2; i++ ) if (rDoc.IsVisible(i))
++nVis; if ( rDoc.IsTabProtected(nTab)
|| !rDoc.IsDocEditable()
|| nVis < 2
|| nTabSelCount == nTabCount)
rSet.DisableItem( nWhich );
}
} break;
case FID_INS_TABLE: case FID_INS_TABLE_EXT: case FID_TAB_APPEND: if ( !rDoc.IsDocEditable() ||
nTabCount > MAXTAB ||
( nWhich == FID_INS_TABLE_EXT && rDocShell.IsDocShared() ) )
rSet.DisableItem( nWhich ); break;
case FID_TAB_MOVE: case FID_TAB_DUPLICATE: if ( !rDoc.IsDocEditable()
|| rDoc.GetChangeTrack() != nullptr
|| nTabCount > MAXTAB)
rSet.DisableItem( nWhich ); break;
// FID_TAB_MENU_RENAME - "rename" from Menu // FID_TAB_RENAME - "name"-property for Basic
case FID_TAB_MENU_RENAME: if ( !rDoc.IsDocEditable() ||
rDoc.IsTabProtected(nTab) ||nTabSelCount > 1 ||
rDocShell.IsDocShared() )
rSet.DisableItem( nWhich ); break;
case FID_TAB_RENAME:
{
OUString aTabName;
rDoc.GetName( nTab, aTabName );
// if FID_TAB_MOVE has parameters if( pReqArgs != nullptr )
{
SCTAB nTableCount = rDoc.GetTableCount(); const SfxPoolItem* pItem;
// if UseCurrentDocument(FN_PARAM_3) is true ignore the document name provided and use current document if( pReqArgs->HasItem( FN_PARAM_3, &pItem ) )
bUseCurrentDocument = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if( pReqArgs->HasItem( FN_PARAM_1, &pItem ) )
{ // nTab is the target tab. // source tab is either the active tab or the tab that context menu opened on. // table is 1-based
nTab = static_cast<const SfxUInt16Item*>(pItem)->GetValue() - 1; if ( nTab >= nTableCount )
nTab = SC_TAB_APPEND;
} if( pReqArgs->HasItem( FN_PARAM_2, &pItem ) )
bCpy = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if (pReqArgs->HasItem(FN_PARAM_4, &pItem))
{
bFromContextMenu = static_cast<const SfxBoolItem*>(pItem)->GetValue();
if (bFromContextMenu)
{ // source tab: the tab that context menu opened on if (pReqArgs->HasItem(FN_PARAM_5, &pItem))
nContextMenuTab
= static_cast<const SfxUInt16Item*>(pItem)->GetValue();
if (pReqArgs->HasItem(FN_PARAM_6, &pItem))
bFromMoveOrCopySheetDialog
= static_cast<const SfxBoolItem*>(pItem)->GetValue();
}
}
if (bFromMoveOrCopySheetDialog)
{
OUString aDefaultName;
rDoc.GetName(nContextMenuTab, aDefaultName);
// We support direct renaming of sheet only when one sheet // is selected.
pDlg->EnableRenameTable(nTabSelCount == 1);
auto xRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
pDlg->StartExecuteAsync(
[this, pDlg, xRequest=std::move(xRequest)] (sal_Int32 nResult)->void
{ if (nResult == RET_OK)
{
DoMoveTableFromDialog(*xRequest, pDlg);
}
pDlg->disposeOnce();
}
);
}
if( bDoIt )
{
rReq.Done(); // record, while doc is active
// sheet number from basic: 1-based // 0 is special, means adding at the end
nTabNr = static_cast<const SfxUInt16Item*>(pTabItem)->GetValue(); if (nTabNr == 0)
nTabNr = nTabCount; else
--nTabNr;
for(SCTAB j=nSelHigh+1;j<nTabCount;j++)
{ if(!rDoc.IsScenario(j))
{
nTabAfter=j; break;
} else// #101672#; increase nTabAfter, because it is possible that the scenario tables are the last
nTabAfter = j + 1;
}
auto xRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
ExecuteAppendOrRenameTableDialog(pDlg, xRequest, nSlot);
}
}
auto xRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
ExecuteTableBackgroundDialog(pDlg, xRequest, aTabBgColor, nSlot);
}
}
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.