/* -*- 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 ( eMode == SC_SELTRANS_INVALID )
eMode = SC_SELTRANS_DRAW_OTHER; // something selected but no special selection
}
} if ( eMode == SC_SELTRANS_INVALID ) // no drawing object selected
{
ScViewData& rViewData = pView->GetViewData(); const ScMarkData& rMark = rViewData.GetMarkData(); // allow MultiMarked because GetSimpleArea may be able to merge into a simple range // (GetSimpleArea modifies a local copy of MarkData) // Also allow simple filtered area. if ( rMark.IsMarked() || rMark.IsMultiMarked() )
{
ScRange aRange;
ScMarkType eMarkType = rViewData.GetSimpleArea( aRange ); if (eMarkType == SC_MARK_SIMPLE || eMarkType == SC_MARK_SIMPLE_FILTERED)
{ // only for "real" selection, cursor alone isn't used if ( aRange.aStart == aRange.aEnd )
eMode = SC_SELTRANS_CELL; else
eMode = SC_SELTRANS_CELLS;
}
}
}
if ( eMode != SC_SELTRANS_INVALID )
pRet = new ScSelectionTransferObj( pView, eMode );
}
} catch (...)
{
}
return pRet;
}
ScSelectionTransferObj::ScSelectionTransferObj( ScTabView* pSource, ScSelectionTransferMode eNewMode ) :
pView( pSource ),
eMode( eNewMode )
{ //! store range for StillValid
}
ScSelectionTransferObj::~ScSelectionTransferObj()
{
ScModule* pScMod = ScModule::get(); if (pScMod && pScMod->GetSelectionTransfer() == this)
{ // this is reached when the object wasn't really copied to the selection // (CopyToSelection has no effect under Windows)
void ScSelectionTransferObj::CreateCellData()
{
OSL_ENSURE( !mxCellData.is(), "CreateCellData twice" ); if ( pView )
{
ScViewData& rViewData = pView->GetViewData();
ScMarkData aNewMark( rViewData.GetMarkData() ); // use local copy for MarkToSimple
aNewMark.MarkToSimple();
// similar to ScViewFunctionSet::BeginDrag if ( aNewMark.IsMarked() && !aNewMark.IsMultiMarked() )
{
ScDocShell& rDocSh = rViewData.GetDocShell();
const ScRange& aSelRange = aNewMark.GetMarkArea();
ScDocShellRef aDragShellRef; if ( rDocSh.GetDocument().HasOLEObjectsInArea( aSelRange, &aNewMark ) )
{
aDragShellRef = new ScDocShell; // DocShell needs a Ref immediately
aDragShellRef->DoInitNew();
}
ScDrawLayer::SetGlobalDrawPersist( aDragShellRef.get() );
ScDocumentUniquePtr pClipDoc(new ScDocument( SCDOCMODE_CLIP )); // bApi = sal_True -> no error messages // #i18364# bStopEdit = sal_False -> don't end edit mode // (this may be called from pasting into the edit line) bool bCopied = rViewData.GetView()->CopyToClip( pClipDoc.get(), false, true, true, false );
ScDrawLayer::SetGlobalDrawPersist(nullptr);
if ( bCopied )
{
TransferableObjectDescriptor aObjDesc;
rDocSh.FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScTransferObj ctor
rtl::Reference<ScTransferObj> xTransferObj = new ScTransferObj( std::move(pClipDoc), std::move(aObjDesc) );
// SetDragHandlePos is not used - there is no mouse position //? xTransferObj->SetVisibleTab( nTab );
xTransferObj->SetDrawPersist(aDragShellRef); // keep persist for ole objects alive
TransferableObjectDescriptor aObjDesc;
rDocSh.FillTransferableObjectDescriptor( aObjDesc );
aObjDesc.maDisplayName = rDocSh.GetMedium()->GetURLObject().GetURLNoPass(); // maSize is set in ScDrawTransferObj ctor
rtl::Reference<ScDrawTransferObj> pTransferObj = new ScDrawTransferObj( std::move(pModel), rDocSh, std::move(aObjDesc) );
pTransferObj->SetDrawPersist(aDragShellRef); // keep persist for ole objects alive
pTransferObj->SetDragSource( pDrawView ); // copies selection
uno::Reference<datatransfer::XTransferable> xSource; switch (eMode)
{ case SC_SELTRANS_CELL: case SC_SELTRANS_CELLS:
xSource = GetCellData(); break; case SC_SELTRANS_DRAW_BITMAP: case SC_SELTRANS_DRAW_GRAPHIC: case SC_SELTRANS_DRAW_BOOKMARK: case SC_SELTRANS_DRAW_OLE: case SC_SELTRANS_DRAW_OTHER:
xSource = GetDrawData(); break; default:
{ // added to avoid warnings
}
}
if ( xSource.is() )
{
TransferableDataHelper aHelper( xSource );
uno::Any aAny = aHelper.GetAny(rFlavor, rDestDoc);
bOK = SetAny( aAny );
}
return bOK;
}
void ScSelectionTransferObj::ObjectReleased()
{ // called when another selection is set from outside
ForgetView();
ScModule* pScMod = ScModule::get(); if ( pScMod->GetSelectionTransfer() == this )
pScMod->SetSelectionTransfer( nullptr );
TransferableHelper::ObjectReleased();
}
sal_Bool SAL_CALL ScSelectionTransferObj::isComplex()
{ switch (eMode)
{ case SC_SELTRANS_CELL: case SC_SELTRANS_CELLS: returnfalse; default: returntrue;
}
}
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.