/* -*- 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 .
*/
// visible section is only changed inplace! // the object area must be set after the scaling since it triggers the resizing
aRect.SetSize( aOleSize );
pClient->SetObjArea( aRect );
}
namespace {
class PopupCallback : public cppu::WeakImplHelper<css::awt::XCallback>
{
ScTabViewShell* m_pViewShell;
SdrOle2Obj* m_pObject;
{ // #i118485# center on BoundRect for activation, // OLE may be sheared/rotated now const tools::Rectangle& rBoundRect = pObj->GetCurrentBoundRect(); const Point aDelta(rBoundRect.Center() - aRect.Center());
aRect.Move(aDelta.X(), aDelta.Y());
}
if ( pClient->GetAspect() != embed::Aspects::MSOLE_ICON
&& ( xObj->getStatus( pClient->GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
{ // scale must always be 1 - change VisArea if different from client size
// visible section is only changed inplace! // the object area must be set after the scaling since it triggers the resizing
aRect.SetSize( aOleSize );
pClient->SetObjArea( aRect );
// attach listener to selection changes in chart that affect cell // ranges, so those can be highlighted // note: do that after DoVerb, so that the chart controller exists if ( SvtModuleOptions().IsChartInstalled() )
{
SvGlobalName aObjClsId ( xObj->getClassID() ); if (SotExchange::IsChart( aObjClsId ))
{ try
{
uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY_THROW );
uno::Reference< chart2::data::XDataReceiver > xDataReceiver(
xSup->getComponent(), uno::UNO_QUERY_THROW );
uno::Reference< chart2::data::XRangeHighlighter > xRangeHighlighter(
xDataReceiver->getRangeHighlighter()); if (xRangeHighlighter.is())
{
uno::Reference< view::XSelectionChangeListener > xListener( new ScChartRangeSelectionListener( this ));
xRangeHighlighter->addSelectionChangeListener( xListener );
}
uno::Reference<awt::XRequestCallback> xPopupRequest(xDataReceiver->getPopupRequest()); if (xPopupRequest.is())
{
uno::Reference<awt::XCallback> xCallback(new PopupCallback(this, pObj));
uno::Any aAny;
xPopupRequest->addCallback(xCallback, aAny);
}
} catch( const uno::Exception & )
{
TOOLS_WARN_EXCEPTION( "sc", "Exception caught while querying chart" );
}
}
}
}
} if (nErr != ERRCODE_NONE && !bErrorShown)
ErrorHandler::HandleError(nErr);
// #i118524# refresh handles to suppress for activated OLE if(GetScDrawView())
{
GetScDrawView()->AdjustMarkHdl();
} //! SetDocumentName should already happen in Sfx ??? //TODO/LATER: how "SetDocumentName"? //xIPObj->SetDocumentName( GetViewData().GetDocShell().GetTitle() );
}
ErrCode ScTabViewShell::DoVerb(sal_Int32 nVerb)
{
SdrView* pView = GetScDrawView(); if (!pView) return ERRCODE_SO_NOTIMPL; // should not be
switch ( nSlot )
{ case SID_INSERT_GRAPHIC:
FuInsertGraphic(*this, pWin, pView, rModel, rReq); // shell is set in MarkListHasChanged break;
case SID_INSERT_AVMEDIA:
FuInsertMedia(*this, pWin, pView, rModel, rReq); // shell is set in MarkListHasChanged break;
case SID_INSERT_DIAGRAM:
FuInsertChart(*this, pWin, pView, rModel, rReq, LINK( this, ScTabViewShell, DialogClosedHdl )); if (comphelper::LibreOfficeKit::isActive())
rDocSh.SetModified(); break;
case SID_INSERT_OBJECT: case SID_INSERT_SMATH: case SID_INSERT_FLOATINGFRAME:
FuInsertOLE(*this, pWin, pView, rModel, rReq); break;
case SID_INSERT_SIGNATURELINE: case SID_EDIT_SIGNATURELINE:
{ const uno::Reference<frame::XModel> xModel( GetViewData().GetDocShell().GetBaseModel() );
VclAbstractDialogFactory* pFact = VclAbstractDialogFactory::Create();
VclPtr<AbstractSignatureLineDialog> pDialog(pFact->CreateSignatureLineDialog(
pWin->GetFrameWeld(), xModel, rReq.GetSlot() == SID_EDIT_SIGNATURELINE)); auto xRequest = std::make_shared<SfxRequest>(rReq);
rReq.Ignore(); // the 'old' request is not relevant any more
pDialog->StartExecuteAsync(
[pDialog, xRequest=std::move(xRequest)] (sal_Int32 nResult)->void
{ if (nResult == RET_OK)
pDialog->Apply();
pDialog->disposeOnce();
xRequest->Done();
}
); break;
}
case SID_SIGN_SIGNATURELINE:
{ const uno::Reference<frame::XModel> xModel(
GetViewData().GetDocShell().GetBaseModel());
case SID_INSERT_SMATH: if ( bOle || bTabProt || !SvtModuleOptions().IsMathInstalled() || bShared )
rSet.DisableItem( nWhich ); break;
case SID_INSERT_OBJECT: case SID_INSERT_FLOATINGFRAME: if ( bOle || bTabProt || bShared )
rSet.DisableItem( nWhich ); break;
case SID_INSERT_AVMEDIA: case SID_FONTWORK_GALLERY_FLOATER: if ( bTabProt || bShared )
rSet.DisableItem( nWhich ); break;
case SID_INSERT_SIGNATURELINE: case SID_INSERT_QRCODE: if ( bTabProt || bShared || (pSdrView && pSdrView->GetMarkedObjectList().GetMarkCount() != 0))
rSet.DisableItem( nWhich ); break; case SID_EDIT_SIGNATURELINE: case SID_SIGN_SIGNATURELINE: if (!IsSignatureLineSelected() || IsSignatureLineSigned())
rSet.DisableItem(nWhich); break;
case SID_EDIT_QRCODE: if (!IsQRCodeSelected())
rSet.DisableItem(nWhich); break;
case SID_INSERT_GRAPHIC: if (bTabProt || bShared)
{ // do not disable 'insert graphic' item if the currently marked area is editable (not protected) // if there is no marked area, check the current cell bool bDisableInsertImage = true;
ScMarkData& rMark = GetViewData().GetMarkData(); if (!rMark.GetMarkedRanges().empty() && GetViewData().GetDocument().IsSelectionEditable(rMark))
bDisableInsertImage = false; else
{ if (GetViewData().GetDocument().IsBlockEditable
(GetViewData().GetTabNo(), GetViewData().GetCurX(), GetViewData().GetCurY(), GetViewData().GetCurX(), GetViewData().GetCurY()))
{
bDisableInsertImage = false;
}
}
if (bDisableInsertImage)
rSet.DisableItem(nWhich);
} break;
case SID_LINKS:
{ if (GetViewData().GetDocument().GetLinkManager()->GetLinks().empty())
rSet.DisableItem( SID_LINKS );
} break;
}
nWhich = aIter.NextWhich();
}
}
bool ScTabViewShell::IsSignatureLineSelected()
{
SdrView* pSdrView = GetScDrawView(); if (!pSdrView) returnfalse;
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); if (rMarkList.GetMarkCount() != 1) returnfalse;
SdrObject* pPickObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); if (!pPickObj) returnfalse;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj); if (!pGraphic) returnfalse;
return pGraphic->isSignatureLine();
}
bool ScTabViewShell::IsQRCodeSelected()
{
SdrView* pSdrView = GetScDrawView(); if (!pSdrView) returnfalse;
const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); if (rMarkList.GetMarkCount() != 1) returnfalse;
SdrObject* pPickObj = rMarkList.GetMark(0)->GetMarkedSdrObj(); if (!pPickObj) returnfalse;
SdrGrafObj* pGraphic = dynamic_cast<SdrGrafObj*>(pPickObj); if (!pGraphic) returnfalse;
// Repair mode: allow undo/redo of all undo actions, even if access would // be limited based on the view shell ID. bool bRepair = false; if (pReqArgs && pReqArgs->GetItemState(SID_REPAIRPACKAGE, false, &pItem) == SfxItemState::SET)
bRepair = static_cast<const SfxBoolItem*>(pItem)->GetValue();
sal_uInt16 nUndoOffset = 0; if (comphelper::LibreOfficeKit::isActive() && !bRepair)
{
SfxUndoAction* pAction = nullptr; if (bIsUndo)
{ if (pUndoManager->GetUndoActionCount() != 0)
pAction = pUndoManager->GetUndoAction();
} else
{ if (pUndoManager->GetRedoActionCount() != 0)
pAction = pUndoManager->GetRedoAction();
} if (pAction)
{ // If another view created the undo action, prevent undoing it from this view. // Unless we know that the other view's undo action is independent from us.
ViewShellId nViewShellId = GetViewShellId(); if (pAction->GetViewShellId() != nViewShellId)
{
sal_uInt16 nOffset = 0; if (pUndoManager->IsViewUndoActionIndependent(this, nOffset))
{ // Execute the undo with an offset: don't undo the top action, but an // earlier one, since it's independent and that belongs to our view.
nUndoOffset += nOffset;
} else
{
rReq.SetReturnValue(SfxUInt32Item(SID_UNDO, static_cast<sal_uInt32>(SID_REPAIRPACKAGE))); return;
}
}
}
}
// lock paint for more than one cell undo action (not for editing within a cell) bool bLockPaint = ( nCount > 1 && pUndoManager == GetUndoManager() ); if ( bLockPaint )
rDocSh.LockPaint();
for (sal_uInt16 i=0; i<nCount; i++)
{ if ( bIsUndo )
pUndoManager->UndoWithContext(aUndoRedoContext); else
pUndoManager->RedoWithContext(aUndoRedoContext);
}
} catch ( const uno::Exception& )
{ // no need to handle. By definition, the UndoManager handled this by clearing the // Undo/Redo stacks
}
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.