Files
libreoffice/sc/source/ui/view/viewfun7.cxx

457 lines
16 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
2012-11-30 12:23:25 +00:00
/*
* This file is part of the LibreOffice project.
2000-09-18 16:07:07 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
2012-11-30 12:23:25 +00:00
* 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/.
2000-09-18 16:07:07 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
2012-11-30 12:23:25 +00:00
* This file incorporates work covered by the following license notice:
2000-09-18 16:07:07 +00:00
*
re-base on ALv2 code. Includes: Patches contributed by Herbert Duerr i#118735 prevent endless loop if vlookup/hlookup doesn't find anything http://svn.apache.org/viewvc?view=revision&revision=1239673 Patches contributed by Andre Fischer remove lp_solver http://svn.apache.org/viewvc?view=revision&revision=1199180 i#118160: Added external CoinMP library. http://svn.apache.org/viewvc?view=revision&revision=1233909 Patches contributed by Armin Le-Grand i#118485 - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 i#118524: apply patch, followup fixes to 118485 http://svn.apache.org/viewvc?view=revision&revision=1186077 Patches contributed by lihuiibm i#108860 - Fix range validation. http://svn.apache.org/viewvc?view=revision&revision=1242846 i#118954 Chart data will lost after copy to different file http://svn.apache.org/viewvc?view=revision&revision=1301345 Patches contributed by Ariel Constenla-Haile Fix Linux build breaker: extra qualification on member http://svn.apache.org/viewvc?view=revision&revision=1301591 i#118696 - i#118697 - Fix some Sheet Tab Color API issues http://svn.apache.org/viewvc?view=revision&revision=1225428 i#118697 - Fix uninitialized variable http://svn.apache.org/viewvc?view=revision&revision=1225859 i#118771 - ScUndoImportTab should preserve tab background color http://svn.apache.org/viewvc?view=revision&revision=1230356 i#118921 - Repaint linked sheet tab background color after updating link http://svn.apache.org/viewvc?view=revision&revision=1245177 i#118927 - Undo/Redo "Update Link" does not reset sheet tab color http://svn.apache.org/viewvc?view=revision&revision=1245241 i#118747 - Copy tab color when transferring sheets across documents http://svn.apache.org/viewvc?view=revision&revision=1230355 Patch contributed by Oliver Rainer-Wittman i#118012 - methods <ScBroadcastAreaSlot::AreaBroadcast(..)> and <ScBroadcastAreaSlot::AreaBroadcastInRange(..)> adapt stl-container iteration in order to avoid destroyed iterators during iteration. http://svn.apache.org/viewvc?view=revision&revision=1297916 Patches contributed by Mathias Bauer gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 http://svn.apache.org/viewvc?view=revision&revision=1396797 http://svn.apache.org/viewvc?view=revision&revision=1397315 Patch contributed by Daniel Rentz calc69: #i116936# fix VBA symbol Cells http://svn.apache.org/viewvc?view=revision&revision=1172135 Patches contributed by leiw: i#118546 CPU 100% on switched off AutoCalculate with Conditional Formatting on date values http://svn.apache.org/viewvc?view=revision&revision=1301380 Re-add new function documentation. Many various cleanups. Add missing calc66: #o11817313# also look at formula result number format, remove redundant binaries.
2012-11-30 12:23:25 +00:00
* 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 .
*/
2000-09-18 16:07:07 +00:00
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
2000-09-18 16:07:07 +00:00
#include <svx/svditer.hxx>
#include <svx/svdograf.hxx>
#include <svx/svdoole2.hxx>
#include <svx/svdouno.hxx>
#include <svx/svdpage.hxx>
#include <svx/svdpagv.hxx>
#include <svx/svdundo.hxx>
#include <svx/xbtmpit.hxx>
#include <svx/xoutbmp.hxx>
#include <svtools/embedhlp.hxx>
2000-09-18 16:07:07 +00:00
#include <sfx2/objsh.hxx>
#include <sfx2/viewfrm.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <com/sun/star/embed/Aspects.hpp>
2000-09-18 16:07:07 +00:00
#include "document.hxx"
2000-09-18 16:07:07 +00:00
#include "viewfunc.hxx"
#include "tabvwsh.hxx"
#include "drawview.hxx"
#include "scmod.hxx"
#include "drwlayer.hxx"
2001-03-30 18:14:44 +00:00
#include "drwtrans.hxx"
2000-09-18 16:07:07 +00:00
#include "globstr.hrc"
#include "chartlis.hxx"
#include "docuno.hxx"
#include "docsh.hxx"
#include "convuno.hxx"
#include "dragdata.hxx"
#include <gridwin.hxx>
2000-09-18 16:07:07 +00:00
extern Point aDragStartDiff;
bool bPasteIsMove = false;
2000-09-18 16:07:07 +00:00
using namespace com::sun::star;
static void lcl_AdjustInsertPos( ScViewData* pData, Point& rPos, Size& rSize )
2000-09-18 16:07:07 +00:00
{
SdrPage* pPage = pData->GetScDrawView()->GetModel()->GetPage( static_cast<sal_uInt16>(pData->GetTabNo()) );
OSL_ENSURE(pPage,"pPage ???");
2000-09-18 16:07:07 +00:00
Size aPgSize( pPage->GetSize() );
if (aPgSize.Width() < 0)
aPgSize.Width() = -aPgSize.Width();
2000-09-18 16:07:07 +00:00
long x = aPgSize.Width() - rPos.X() - rSize.Width();
long y = aPgSize.Height() - rPos.Y() - rSize.Height();
// if necessary: adjustments (80/200) for pixel approx. errors
2000-09-18 16:07:07 +00:00
if( x < 0 )
rPos.X() += x + 80;
if( y < 0 )
rPos.Y() += y + 200;
rPos.X() += rSize.Width() / 2; // position at paste is center
2000-09-18 16:07:07 +00:00
rPos.Y() += rSize.Height() / 2;
}
void ScViewFunc::PasteDraw( const Point& rLogicPos, SdrModel* pModel,
bool bGroup, const OUString& rSrcShellID, const OUString& rDestShellID )
2000-09-18 16:07:07 +00:00
{
bool bSameDocClipboard = rSrcShellID == rDestShellID;
2000-09-18 16:07:07 +00:00
MakeDrawLayer();
Point aPos( rLogicPos );
// MapMode at Outliner-RefDevice has to be right (as in FuText::MakeOutliner)
//! merge with FuText::MakeOutliner?
2000-09-18 16:07:07 +00:00
MapMode aOldMapMode;
OutputDevice* pRef = GetViewData().GetDocument()->GetDrawLayer()->GetRefDevice();
2000-09-18 16:07:07 +00:00
if (pRef)
{
aOldMapMode = pRef->GetMapMode();
pRef->SetMapMode( MapMode(MAP_100TH_MM) );
}
bool bNegativePage = GetViewData().GetDocument()->IsNegativePage( GetViewData().GetTabNo() );
2001-03-30 18:14:44 +00:00
SdrView* pDragEditView = NULL;
ScModule* pScMod = SC_MOD();
const ScDragData& rData = pScMod->GetDragData();
ScDrawTransferObj* pDrawTrans = rData.pDrawTransfer;
if (pDrawTrans)
2000-09-18 16:07:07 +00:00
{
2001-03-30 18:14:44 +00:00
pDragEditView = pDrawTrans->GetDragSourceView();
2000-09-18 16:07:07 +00:00
aPos -= aDragStartDiff;
if ( bNegativePage )
{
if (aPos.X() > 0) aPos.X() = 0;
}
else
{
if (aPos.X() < 0) aPos.X() = 0;
}
2000-09-18 16:07:07 +00:00
if (aPos.Y() < 0) aPos.Y() = 0;
}
ScDrawView* pScDrawView = GetScDrawView();
2000-09-18 16:07:07 +00:00
if (bGroup)
pScDrawView->BegUndo( ScGlobal::GetRscString( STR_UNDO_PASTE ) );
2000-09-18 16:07:07 +00:00
bool bSameDoc = ( pDragEditView && pDragEditView->GetModel() == pScDrawView->GetModel() );
2000-09-18 16:07:07 +00:00
if (bSameDoc)
{
// copy locally - incl. charts
2000-09-18 16:07:07 +00:00
Point aSourceStart = pDragEditView->GetAllMarkedRect().TopLeft();
long nDiffX = aPos.X() - aSourceStart.X();
long nDiffY = aPos.Y() - aSourceStart.Y();
// move within a page?
2000-09-18 16:07:07 +00:00
if ( bPasteIsMove &&
pScDrawView->GetSdrPageView()->GetPage() ==
pDragEditView->GetSdrPageView()->GetPage() )
2000-09-18 16:07:07 +00:00
{
if ( nDiffX != 0 || nDiffY != 0 )
pDragEditView->MoveAllMarked(Size(nDiffX,nDiffY), false);
2000-09-18 16:07:07 +00:00
}
else
{
SdrModel* pDrawModel = pDragEditView->GetModel();
SCTAB nTab = GetViewData().GetTabNo();
SdrPage* pDestPage = pDrawModel->GetPage( static_cast< sal_uInt16 >( nTab ) );
OSL_ENSURE(pDestPage,"who is this, Page?");
2000-09-18 16:07:07 +00:00
::std::vector< OUString > aExcludedChartNames;
if ( pDestPage )
{
ScChartHelper::GetChartNames( aExcludedChartNames, pDestPage );
}
SdrMarkList aMark = pDragEditView->GetMarkedObjectList();
2000-09-18 16:07:07 +00:00
aMark.ForceSort();
const size_t nMarkAnz=aMark.GetMarkCount();
for (size_t nm=0; nm<nMarkAnz; ++nm) {
2000-09-18 16:07:07 +00:00
const SdrMark* pM=aMark.GetMark(nm);
const SdrObject* pObj=pM->GetMarkedSdrObj();
SdrObject* pNeuObj=pObj->Clone();
2000-09-18 16:07:07 +00:00
if (pNeuObj!=NULL)
{
pNeuObj->SetModel(pDrawModel);
pNeuObj->SetPage(pDestPage);
2011-03-02 21:32:00 +01:00
// copy graphics within the same model - always needs new name
2000-09-18 16:07:07 +00:00
if ( pNeuObj->ISA(SdrGrafObj) && !bPasteIsMove )
pNeuObj->SetName(static_cast<ScDrawLayer*>(pDrawModel)->GetNewGraphicName());
2000-09-18 16:07:07 +00:00
if (nDiffX!=0 || nDiffY!=0)
pNeuObj->NbcMove(Size(nDiffX,nDiffY));
if (pDestPage)
pDestPage->InsertObject( pNeuObj );
pScDrawView->AddUndo(new SdrUndoInsertObj( *pNeuObj ));
2000-09-18 16:07:07 +00:00
if (ScDrawLayer::IsCellAnchored(*pNeuObj))
ScDrawLayer::SetCellAnchoredFromPosition(*pNeuObj, *GetViewData().GetDocument(), nTab);
2000-09-18 16:07:07 +00:00
}
}
if (bPasteIsMove)
pDragEditView->DeleteMarked();
ScDocument* pDocument = GetViewData().GetDocument();
ScDocShell* pDocShell = GetViewData().GetDocShell();
ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL );
if ( pDocument && pDestPage && pModelObj && pDrawTrans )
{
const ScRangeListVector& rProtectedChartRangesVector( pDrawTrans->GetProtectedChartRangesVector() );
ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pDestPage, pModelObj, nTab,
rProtectedChartRangesVector, aExcludedChartNames, bSameDoc );
}
2000-09-18 16:07:07 +00:00
}
}
else
{
bPasteIsMove = false; // no internal move happened
2000-09-18 16:07:07 +00:00
SdrView aView(pModel); // #i71529# never create a base class of SdrView directly!
SdrPageView* pPv = aView.ShowSdrPage(aView.GetModel()->GetPage(0));
aView.MarkAllObj(pPv);
2000-09-18 16:07:07 +00:00
Size aSize = aView.GetAllMarkedRect().GetSize();
lcl_AdjustInsertPos( &GetViewData(), aPos, aSize );
2000-09-18 16:07:07 +00:00
// don't change marking if OLE object is active
// (at Drop from OLE object it would be deactivated in the middle of ExecuteDrag!)
2000-09-18 16:07:07 +00:00
SdrInsertFlags nOptions = SdrInsertFlags::NONE;
SfxInPlaceClient* pClient = GetViewData().GetViewShell()->GetIPClient();
if ( pClient && pClient->IsObjectInPlaceActive() )
nOptions |= SdrInsertFlags::DONTMARK;
2000-09-18 16:07:07 +00:00
::std::vector< OUString > aExcludedChartNames;
SCTAB nTab = GetViewData().GetTabNo();
SdrPage* pPage = pScDrawView->GetModel()->GetPage( static_cast< sal_uInt16 >( nTab ) );
OSL_ENSURE( pPage, "Page?" );
if ( pPage )
{
ScChartHelper::GetChartNames( aExcludedChartNames, pPage );
}
// #89247# Set flag for ScDocument::UpdateChartListeners() which is
// called during paste.
if ( !bSameDocClipboard )
GetViewData().GetDocument()->SetPastingDrawFromOtherDoc( true );
pScDrawView->Paste(*pModel, aPos, NULL, nOptions, rSrcShellID, rDestShellID);
2000-09-18 16:07:07 +00:00
if ( !bSameDocClipboard )
GetViewData().GetDocument()->SetPastingDrawFromOtherDoc( false );
2011-03-02 21:32:00 +01:00
// Paste puts all objects on the active (front) layer
2000-09-18 16:07:07 +00:00
// controls must be on SC_LAYER_CONTROLS
if (pPage)
{
SdrObjListIter aIter( *pPage, IM_DEEPNOGROUPS );
SdrObject* pObject = aIter.Next();
while (pObject)
{
if ( pObject->ISA(SdrUnoObj) && pObject->GetLayer() != SC_LAYER_CONTROLS )
pObject->NbcSetLayer(SC_LAYER_CONTROLS);
if (ScDrawLayer::IsCellAnchored(*pObject))
ScDrawLayer::SetCellAnchoredFromPosition(*pObject, *GetViewData().GetDocument(), nTab);
2000-09-18 16:07:07 +00:00
pObject = aIter.Next();
}
}
2011-03-02 21:32:00 +01:00
// all graphics objects must have names
GetViewData().GetDocument()->EnsureGraphicNames();
ScDocument* pDocument = GetViewData().GetDocument();
ScDocShell* pDocShell = GetViewData().GetDocShell();
ScModelObj* pModelObj = ( pDocShell ? ScModelObj::getImplementation( pDocShell->GetModel() ) : NULL );
ScDrawTransferObj* pTransferObj = ScDrawTransferObj::GetOwnClipboard( NULL );
if ( pDocument && pPage && pModelObj && ( pTransferObj || pDrawTrans ) )
{
const ScRangeListVector& rProtectedChartRangesVector(
pTransferObj ? pTransferObj->GetProtectedChartRangesVector() : pDrawTrans->GetProtectedChartRangesVector() );
ScChartHelper::CreateProtectedChartListenersAndNotify( pDocument, pPage, pModelObj, nTab,
rProtectedChartRangesVector, aExcludedChartNames, bSameDocClipboard );
}
2000-09-18 16:07:07 +00:00
}
if (bGroup)
{
pScDrawView->GroupMarked();
pScDrawView->EndUndo();
2000-09-18 16:07:07 +00:00
}
if (pRef)
pRef->SetMapMode( aOldMapMode );
// GetViewData().GetViewShell()->SetDrawShell( true );
2011-03-02 21:32:00 +01:00
// It is not sufficient to just set the DrawShell if we pasted, for
// example, a chart. SetDrawShellOrSub() would only work for D&D in the
// same document but not if inserting from the clipboard, therefore
// MarkListHasChanged() is what we need.
pScDrawView->MarkListHasChanged();
2000-09-18 16:07:07 +00:00
}
bool ScViewFunc::PasteObject( const Point& rPos, const uno::Reference < embed::XEmbeddedObject >& xObj,
const Size* pDescSize, const Graphic* pReplGraph, const OUString& aMediaType, sal_Int64 nAspect )
2000-09-18 16:07:07 +00:00
{
MakeDrawLayer();
if ( xObj.is() )
2000-09-18 16:07:07 +00:00
{
OUString aName;
//TODO/MBA: is that OK?
comphelper::EmbeddedObjectContainer& aCnt = GetViewData().GetViewShell()->GetObjectShell()->GetEmbeddedObjectContainer();
if ( !aCnt.HasEmbeddedObject( xObj ) )
aCnt.InsertEmbeddedObject( xObj, aName );
else
aName = aCnt.GetEmbeddedObjectName( xObj );
2000-09-18 16:07:07 +00:00
svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
if ( pReplGraph )
aObjRef.SetGraphic( *pReplGraph, aMediaType );
2000-09-18 16:07:07 +00:00
Size aSize;
if ( nAspect == embed::Aspects::MSOLE_ICON )
{
MapMode aMapMode( MAP_100TH_MM );
aSize = aObjRef.GetSize( &aMapMode );
}
else
{
// working with visual area can switch object to running state
MapUnit aMapObj = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
MapUnit aMap100 = MAP_100TH_MM;
if ( pDescSize && pDescSize->Width() && pDescSize->Height() )
{
// use size from object descriptor if given
aSize = OutputDevice::LogicToLogic( *pDescSize, aMap100, aMapObj );
awt::Size aSz;
aSz.Width = aSize.Width();
aSz.Height = aSize.Height();
xObj->setVisualAreaSize( nAspect, aSz );
}
2000-09-18 16:07:07 +00:00
awt::Size aSz;
try
{
aSz = xObj->getVisualAreaSize( nAspect );
}
catch ( embed::NoVisualAreaSizeException& )
{
// the default size will be set later
}
aSize = Size( aSz.Width, aSz.Height );
aSize = OutputDevice::LogicToLogic( aSize, aMapObj, aMap100 ); // for SdrOle2Obj
if( aSize.Height() == 0 || aSize.Width() == 0 )
{
2011-03-01 19:05:02 +01:00
OSL_FAIL("SvObjectDescriptor::GetSize == 0");
aSize.Width() = 5000;
aSize.Height() = 5000;
aSize = OutputDevice::LogicToLogic( aSize, aMap100, aMapObj );
aSz.Width = aSize.Width();
aSz.Height = aSize.Height();
xObj->setVisualAreaSize( nAspect, aSz );
}
2000-09-18 16:07:07 +00:00
}
// don't call AdjustInsertPos
Point aInsPos = rPos;
if ( GetViewData().GetDocument()->IsNegativePage( GetViewData().GetTabNo() ) )
aInsPos.X() -= aSize.Width();
Rectangle aRect( aInsPos, aSize );
2000-09-18 16:07:07 +00:00
ScDrawView* pDrView = GetScDrawView();
SdrOle2Obj* pSdrObj = new SdrOle2Obj( aObjRef, aName, aRect );
SdrPageView* pPV = pDrView->GetSdrPageView();
pDrView->InsertObjectSafe( pSdrObj, *pPV ); // don't mark if OLE
GetViewData().GetViewShell()->SetDrawShell( true );
return true;
2000-09-18 16:07:07 +00:00
}
else
return false;
2000-09-18 16:07:07 +00:00
}
bool ScViewFunc::PasteBitmapEx( const Point& rPos, const BitmapEx& rBmpEx )
2000-09-18 16:07:07 +00:00
{
OUString aEmpty;
Resolves: #i121504# Support for alpha channel in clipboard for all systems (cherry picked from commit ef3931ff410117e1237b3bef7bc090e8b83b9519) Conflicts: automation/source/server/statemnt.cxx basic/source/runtime/methods.cxx canvas/source/vcl/devicehelper.cxx canvas/source/vcl/spritedevicehelper.cxx drawinglayer/source/processor2d/vclhelperbufferdevice.cxx drawinglayer/source/processor2d/vclmetafileprocessor2d.cxx drawinglayer/source/tools/converters.cxx dtrans/source/win32/dtobj/FmtFilter.cxx editeng/source/items/bulitem.cxx extensions/source/scanner/sanedlg.cxx external/gcc3_specific/makefile.mk filter/source/graphicfilter/eos2met/eos2met.cxx filter/source/graphicfilter/ios2met/ios2met.cxx filter/source/msfilter/msdffimp.cxx fpicker/source/office/iodlg.cxx framework/source/fwe/classes/addonsoptions.cxx framework/source/fwe/helper/actiontriggerhelper.cxx sc/source/filter/excel/xiescher.cxx sc/source/ui/docshell/docsh.cxx sc/source/ui/inc/viewfunc.hxx sd/source/ui/app/sdxfer.cxx sd/source/ui/unoidl/unopage.cxx sd/source/ui/view/sdview3.cxx sfx2/source/appl/fileobj.cxx sfx2/source/appl/linkmgr2.cxx sfx2/source/dialog/filedlghelper.cxx sfx2/source/dialog/intro.cxx sfx2/source/doc/docinf.cxx sot/inc/sot/formats.hxx sot/source/base/formats.cxx svtools/bmpmaker/bmpcore.cxx svtools/bmpmaker/bmpsum.cxx svtools/inc/svtools/transfer.hxx svtools/source/filter/filter.cxx svtools/source/filter/wmf/emfwr.cxx svtools/source/filter/wmf/enhwmf.cxx svtools/source/filter/wmf/winwmf.cxx svtools/source/filter/wmf/wmfwr.cxx svtools/source/graphic/graphic.cxx svtools/source/graphic/provider.cxx svtools/source/misc/transfer.cxx svx/inc/svx/xoutbmp.hxx svx/source/sdr/overlay/overlaymanagerbuffered.cxx svx/source/xoutdev/_xoutbmp.cxx sw/source/core/view/viewsh.cxx sw/source/filter/ww1/w1filter.cxx sw/source/filter/ww8/ww8par.hxx sw/source/ui/dochdl/swdtflvr.cxx toolkit/source/awt/vclxbitmap.cxx toolkit/source/helper/vclunohelper.cxx vcl/Library_vcl.mk vcl/Package_inc.mk vcl/aqua/source/dtrans/DataFlavorMapping.cxx vcl/aqua/source/dtrans/OSXTransferable.cxx vcl/aqua/source/dtrans/PictToBmpFlt.cxx vcl/aqua/source/dtrans/PictToBmpFlt.hxx vcl/inc/vcl/alpha.hxx vcl/inc/vcl/bitmap.hxx vcl/inc/vcl/bitmapex.hxx vcl/inc/vcl/pngwrite.hxx vcl/inc/vcl/salbtype.hxx vcl/inc/vcl/wall.hxx vcl/source/gdi/animate.cxx vcl/source/gdi/bitmap2.cxx vcl/source/gdi/bitmapex.cxx vcl/source/gdi/bmpconv.cxx vcl/source/gdi/cvtsvm.cxx vcl/source/gdi/impgraph.cxx vcl/source/gdi/impimagetree.cxx vcl/source/gdi/metaact.cxx vcl/source/gdi/wall.cxx Change-Id: I79938bc412c048c3d4e64f430f216e73bec16167
2013-01-10 16:28:40 +00:00
Graphic aGraphic(rBmpEx);
2000-09-18 16:07:07 +00:00
return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
}
bool ScViewFunc::PasteMetaFile( const Point& rPos, const GDIMetaFile& rMtf )
2000-09-18 16:07:07 +00:00
{
OUString aEmpty;
2000-09-18 16:07:07 +00:00
Graphic aGraphic(rMtf);
return PasteGraphic( rPos, aGraphic, aEmpty, aEmpty );
}
bool ScViewFunc::PasteGraphic( const Point& rPos, const Graphic& rGraphic,
const OUString& rFile, const OUString& rFilter )
2000-09-18 16:07:07 +00:00
{
MakeDrawLayer();
ScDrawView* pScDrawView = GetScDrawView();
2000-09-18 16:07:07 +00:00
if (!pScDrawView)
return false;
// #i123922# check if the drop was over an existing object; if yes, evtl. replace
// the graphic for a SdrGraphObj (including link state updates) or adapt the fill
// style for other objects
SdrPageView* pPageView = pScDrawView->GetSdrPageView();
if (pPageView)
{
SdrObject* pPickObj = 0;
if (pScDrawView->PickObj(rPos, pScDrawView->getHitTolLog(), pPickObj, pPageView))
{
const OUString aBeginUndo(ScGlobal::GetRscString(STR_UNDO_DRAGDROP));
SdrObject* pResult = pScDrawView->ApplyGraphicToObject(
*pPickObj,
rGraphic,
aBeginUndo,
rFile,
rFilter);
if (pResult)
{
// we are done; mark the modified/new object
pScDrawView->MarkObj(pResult, pScDrawView->GetSdrPageView());
return true;
}
}
}
2000-09-18 16:07:07 +00:00
Point aPos( rPos );
vcl::Window* pWin = GetActiveWin();
2000-09-18 16:07:07 +00:00
MapMode aSourceMap = rGraphic.GetPrefMapMode();
MapMode aDestMap( MAP_100TH_MM );
if (aSourceMap.GetMapUnit() == MAP_PIXEL)
{
// consider pixel correction, so bitmap fits to screen
Fraction aScaleX, aScaleY;
pScDrawView->CalcNormScale( aScaleX, aScaleY );
2000-09-18 16:07:07 +00:00
aDestMap.SetScaleX(aScaleX);
aDestMap.SetScaleY(aScaleY);
}
Size aSize = pWin->LogicToLogic( rGraphic.GetPrefSize(), &aSourceMap, &aDestMap );
2011-01-16 19:11:44 +01:00
if ( GetViewData().GetDocument()->IsNegativePage( GetViewData().GetTabNo() ) )
aPos.X() -= aSize.Width();
GetViewData().GetViewShell()->SetDrawShell( true );
2000-09-18 16:07:07 +00:00
Rectangle aRect(aPos, aSize);
SdrGrafObj* pGrafObj = new SdrGrafObj(rGraphic, aRect);
// path was the name of the graphic in history
2000-09-18 16:07:07 +00:00
ScDrawLayer* pLayer = static_cast<ScDrawLayer*>( pScDrawView->GetModel() );
OUString aName = pLayer->GetNewGraphicName(); // "Graphics"
2000-09-18 16:07:07 +00:00
pGrafObj->SetName(aName);
// don't mark if OLE
pScDrawView->InsertObjectSafe(pGrafObj, *pScDrawView->GetSdrPageView());
2011-03-02 21:32:00 +01:00
// SetGraphicLink has to be used after inserting the object,
// otherwise an empty graphic is swapped in and the contact stuff crashes.
// See #i37444#.
if (!rFile.isEmpty())
rhbz#887420 Implement "block untrusted referer links" feature For now, this checks for a trusted referer (if the BlockUntrustedRefererLinks configuration prop is set) in utl::MediaDescriptor::impl_openStreamWithURL and SvxBrushItem::GetGraphicObject. Checking in additional places will probably be necessary to block /all/ unwanted communication. Also, some places marked /*TODO?*/ currently pass in an empty referer (which is always considered trusted) and will probably need to be adapted. Ideally, Referer URIs would never be empty (and consistently use something like <private:user> for cases where access is explicitly initiated by the user and should never be blocked), but that's a very daunting task, so start small by identifying the places that potentially need blocking and adding appropriate Referer URIs there. Also, Referer information should always be computed as freshly as possible from the context in which an access attempt is made, but, again, always carrying the information from the context all the way to the relevant functions is a very daunting task, so for now store the information upon object instantiation in some cases (SvxBrushItem, SdrGrafObj, ...). The Referer URI (css.document.MediaDescriptor property; SID_REFERER) was already used to track macro execution, and there is one place in SfxApplication::OpenDocExec_Impl where opening of hyperlinks (explicitly clicked by the user) is done that needs the current document's URI as Referer to check execution of macro URIs but needs an empty (or <private:user>, see above) Referer to not block non-macro URIs. Special code has been added there to handle that. Change-Id: Iafbdc07a9fe925d9ee580d4f5778448f18f2ebd9
2013-11-14 10:39:27 +01:00
pGrafObj->SetGraphicLink( rFile, ""/*TODO?*/, rFilter );
return true;
2000-09-18 16:07:07 +00:00
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */