2010-10-12 15:51:52 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-27 16:10:40 +00:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2017-10-09 19:10:13 +02:00
|
|
|
#include <config_features.h>
|
|
|
|
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <fuinsert.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <comphelper/storagehelper.hxx>
|
2018-06-29 15:38:29 +02:00
|
|
|
#include <editeng/outlobj.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <svx/svxdlg.hxx>
|
2016-01-13 22:34:34 +01:00
|
|
|
#include <com/sun/star/embed/EmbedVerbs.hpp>
|
2005-03-15 10:21:27 +00:00
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
|
2014-06-09 14:32:53 -04:00
|
|
|
#include <com/sun/star/embed/XComponentSupplier.hpp>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <com/sun/star/embed/Aspects.hpp>
|
|
|
|
#include <com/sun/star/beans/XPropertySet.hpp>
|
2007-05-22 15:13:37 +00:00
|
|
|
#include <com/sun/star/chart2/XChartDocument.hpp>
|
|
|
|
#include <com/sun/star/drawing/FillStyle.hpp>
|
2014-03-27 11:22:02 +01:00
|
|
|
#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
|
2004-10-04 17:32:01 +00:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <tools/urlobj.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/urihelper.hxx>
|
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
|
|
|
#include <sfx2/docfile.hxx>
|
2010-07-10 18:21:24 +02:00
|
|
|
#include <sfx2/msgpool.hxx>
|
2015-12-18 02:30:18 +01:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <svtools/insdlg.hxx>
|
2003-03-27 09:58:12 +00:00
|
|
|
#include <sfx2/request.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/globalnameitem.hxx>
|
2009-10-06 07:38:24 +02:00
|
|
|
#include <unotools/pathoptions.hxx>
|
2010-08-25 22:53:55 +02:00
|
|
|
#include <svtools/miscopt.hxx>
|
2014-07-10 13:33:32 -04:00
|
|
|
#include <svtools/embedhlp.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/dialogs.hrc>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/linkmgr.hxx>
|
2010-08-25 22:53:55 +02:00
|
|
|
#include <svx/linkwarn.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/svdetc.hxx>
|
2004-08-12 08:15:37 +00:00
|
|
|
#include <avmedia/mediawindow.hxx>
|
2003-06-10 12:57:32 +00:00
|
|
|
#include <sfx2/printer.hxx>
|
2013-04-19 18:08:13 -04:00
|
|
|
#include <comphelper/classids.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svtools/sfxecode.hxx>
|
2001-03-16 16:41:14 +00:00
|
|
|
#include <svtools/transfer.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/urlbmk.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/svdobj.hxx>
|
|
|
|
#include <svx/svdograf.hxx>
|
|
|
|
#include <svx/svdoole2.hxx>
|
2004-08-12 08:15:37 +00:00
|
|
|
#include <svx/svdomedia.hxx>
|
2010-01-08 18:32:51 +01:00
|
|
|
#include <editeng/editeng.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <sot/storage.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <sot/formats.hxx>
|
|
|
|
#include <svx/svdpagv.hxx>
|
2010-01-13 22:25:07 +01:00
|
|
|
#include <sfx2/opengrf.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2012-11-14 11:09:12 +00:00
|
|
|
#include <svx/charthelper.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <app.hrc>
|
|
|
|
#include <sdresid.hxx>
|
|
|
|
#include <View.hxx>
|
|
|
|
#include <sdmod.hxx>
|
|
|
|
#include <Window.hxx>
|
|
|
|
#include <drawview.hxx>
|
|
|
|
#include <DrawViewShell.hxx>
|
|
|
|
#include <DrawDocShell.hxx>
|
|
|
|
#include <GraphicDocShell.hxx>
|
|
|
|
#include <strings.hrc>
|
|
|
|
#include <drawdoc.hxx>
|
2018-05-27 16:44:14 +02:00
|
|
|
#include <sdpage.hxx>
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <sdgrffilter.hxx>
|
|
|
|
#include <sdxfer.hxx>
|
2006-11-14 13:29:15 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2017-10-23 22:32:55 +02:00
|
|
|
#include <undo/undoobjects.hxx>
|
2015-09-18 09:09:12 +01:00
|
|
|
#include <memory>
|
2018-03-17 07:00:02 +09:00
|
|
|
#include <vcl/weld.hxx>
|
2018-05-27 16:44:14 +02:00
|
|
|
#include <vcl/errinf.hxx>
|
2018-03-17 07:00:02 +09:00
|
|
|
|
|
|
|
#include <vcl/GraphicNativeTransform.hxx>
|
|
|
|
#include <vcl/GraphicNativeMetadata.hxx>
|
2006-11-14 13:29:15 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
using namespace com::sun::star;
|
2004-01-20 10:02:54 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
namespace sd {
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
FuInsertGraphic::FuInsertGraphic (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
2016-07-05 12:05:28 +00:00
|
|
|
SfxRequest& rReq,
|
|
|
|
bool replaceExistingImage)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq),
|
|
|
|
mbReplaceExistingImage(replaceExistingImage)
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-07-05 12:05:28 +00:00
|
|
|
rtl::Reference<FuPoor> FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc, SfxRequest& rReq, bool replaceExistingImage )
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
2016-07-05 12:05:28 +00:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq, replaceExistingImage ) );
|
2005-12-14 15:59:08 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
2015-12-16 17:13:06 -04:00
|
|
|
void FuInsertGraphic::DoExecute( SfxRequest& rReq )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2015-12-16 17:13:06 -04:00
|
|
|
OUString aFileName;
|
|
|
|
OUString aFilterName;
|
|
|
|
Graphic aGraphic;
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-12-16 17:13:06 -04:00
|
|
|
bool bAsLink = false;
|
2017-06-01 16:47:00 +02:00
|
|
|
ErrCode nError = ERRCODE_GRFILTER_OPENERROR;
|
2015-12-16 17:13:06 -04:00
|
|
|
|
|
|
|
const SfxItemSet* pArgs = rReq.GetArgs();
|
|
|
|
const SfxPoolItem* pItem;
|
|
|
|
|
|
|
|
if ( pArgs &&
|
|
|
|
pArgs->GetItemState( SID_INSERT_GRAPHIC, true, &pItem ) == SfxItemState::SET )
|
|
|
|
{
|
|
|
|
aFileName = static_cast<const SfxStringItem*>(pItem)->GetValue();
|
|
|
|
|
|
|
|
if ( pArgs->GetItemState( FN_PARAM_FILTER, true, &pItem ) == SfxItemState::SET )
|
|
|
|
aFilterName = static_cast<const SfxStringItem*>(pItem)->GetValue();
|
|
|
|
|
|
|
|
if ( pArgs->GetItemState( FN_PARAM_1, true, &pItem ) == SfxItemState::SET )
|
|
|
|
bAsLink = static_cast<const SfxBoolItem*>(pItem)->GetValue();
|
|
|
|
|
|
|
|
nError = GraphicFilter::LoadGraphic( aFileName, aFilterName, aGraphic, &GraphicFilter::GetGraphicFilter() );
|
|
|
|
}
|
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2018-04-04 14:33:16 +01:00
|
|
|
SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC), mpWindow ? mpWindow->GetFrameWeld() : nullptr);
|
2015-12-16 17:13:06 -04:00
|
|
|
|
2017-06-01 16:47:00 +02:00
|
|
|
if( aDlg.Execute() != ERRCODE_NONE )
|
2016-02-16 19:05:47 -04:00
|
|
|
return; // cancel dialog
|
|
|
|
|
|
|
|
nError = aDlg.GetGraphic(aGraphic);
|
|
|
|
bAsLink = aDlg.IsAsLink();
|
|
|
|
aFileName = aDlg.GetPath();
|
2017-11-23 16:52:23 +00:00
|
|
|
aFilterName = aDlg.GetDetectedFilter();
|
2015-12-16 17:13:06 -04:00
|
|
|
}
|
2012-12-04 15:56:38 +01:00
|
|
|
|
2017-06-01 16:47:00 +02:00
|
|
|
if( nError == ERRCODE_NONE )
|
2015-12-16 17:13:06 -04:00
|
|
|
{
|
2018-03-17 07:00:02 +09:00
|
|
|
GraphicNativeMetadata aMetadata;
|
|
|
|
if ( aMetadata.read(aGraphic) )
|
|
|
|
{
|
|
|
|
const sal_uInt16 aRotation = aMetadata.getRotation();
|
|
|
|
if (aRotation != 0)
|
|
|
|
{
|
|
|
|
std::unique_ptr<weld::MessageDialog> xQueryBox(Application::CreateMessageDialog(nullptr, VclMessageType::Question,VclButtonsType::YesNo,SdResId(STR_QUERYROTATION)));
|
|
|
|
if (xQueryBox->run() == RET_YES)
|
|
|
|
{
|
|
|
|
GraphicNativeTransform aTransform( aGraphic );
|
|
|
|
aTransform.rotate( aRotation );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-09 16:30:29 +02:00
|
|
|
if( dynamic_cast< DrawViewShell *>( mpViewShell ) )
|
2015-12-16 17:13:06 -04:00
|
|
|
{
|
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
2018-06-21 15:51:05 +02:00
|
|
|
SdrObject* pPickObj;
|
2015-12-16 17:13:06 -04:00
|
|
|
|
2018-06-21 15:51:05 +02:00
|
|
|
if( ( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) && mbReplaceExistingImage ) || (pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) )
|
2015-12-16 17:13:06 -04:00
|
|
|
{
|
|
|
|
nAction = DND_ACTION_LINK;
|
2018-06-21 15:51:05 +02:00
|
|
|
} else {
|
|
|
|
pPickObj = nullptr;
|
2015-12-16 17:13:06 -04:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2018-03-08 21:07:40 +01:00
|
|
|
Point aPos = mpWindow->GetVisibleCenter();
|
2015-12-16 17:13:06 -04:00
|
|
|
SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, nullptr);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2015-12-16 17:13:06 -04:00
|
|
|
if(pGrafObj && bAsLink )
|
|
|
|
{
|
|
|
|
// really store as link only?
|
|
|
|
if( SvtMiscOptions().ShowLinkWarningDialog() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2018-02-19 16:33:35 +00:00
|
|
|
SvxLinkWarningDialog aWarnDlg(mpWindow->GetFrameWeld(), aFileName);
|
|
|
|
if (aWarnDlg.run() != RET_OK)
|
2015-12-16 17:13:06 -04:00
|
|
|
return; // don't store as link
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2014-02-07 01:26:23 +00:00
|
|
|
|
2015-12-16 17:13:06 -04:00
|
|
|
// store as link
|
|
|
|
OUString aReferer;
|
|
|
|
if (mpDocSh->HasName()) {
|
|
|
|
aReferer = mpDocSh->GetMedium()->GetName();
|
2014-02-07 01:26:23 +00:00
|
|
|
}
|
2015-12-16 17:13:06 -04:00
|
|
|
pGrafObj->SetGraphicLink(aFileName, aReferer, aFilterName);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2015-12-16 17:13:06 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-01 16:47:00 +02:00
|
|
|
SdGRFFilter::HandleGraphicFilterError( nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
FuInsertClipboard::FuInsertClipboard (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2005-12-14 15:59:08 +00:00
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuInsertClipboard::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuInsertClipboard( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 15:59:08 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
void FuInsertClipboard::DoExecute( SfxRequest& )
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( mpWindow ) );
|
2015-03-12 14:53:28 +02:00
|
|
|
SotClipboardFormatId nFormatId;
|
2001-03-16 16:41:14 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
2018-04-03 16:27:56 +01:00
|
|
|
ScopedVclPtr<SfxAbstractPasteDialog> pDlg(pFact->CreatePasteDialog(mpViewShell->GetFrameWeld()));
|
2018-05-31 08:29:01 +02:00
|
|
|
pDlg->Insert( SotClipboardFormatId::EMBED_SOURCE, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::LINK_SOURCE, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::DRAWING, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::SVXB, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::GDIMETAFILE, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::BITMAP, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::NETSCAPE_BOOKMARK, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::STRING, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::HTML, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::RTF, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::RICHTEXT, OUString() );
|
|
|
|
pDlg->Insert( SotClipboardFormatId::EDITENGINE_ODF_TEXT_FLAT, OUString() );
|
|
|
|
|
|
|
|
//TODO/MBA: testing
|
|
|
|
nFormatId = pDlg->GetFormat( aDataHelper );
|
|
|
|
if( nFormatId != SotClipboardFormatId::NONE && aDataHelper.GetTransferable().is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2018-05-31 08:29:01 +02:00
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
|
|
|
DrawViewShell* pDrViewSh = nullptr;
|
2004-10-04 17:32:01 +00:00
|
|
|
|
2018-05-31 08:29:01 +02:00
|
|
|
if (!mpView->InsertData( aDataHelper,
|
|
|
|
mpWindow->PixelToLogic( ::tools::Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ),
|
|
|
|
nAction, false, nFormatId ))
|
|
|
|
{
|
|
|
|
pDrViewSh = dynamic_cast<DrawViewShell*>(mpViewShell);
|
|
|
|
}
|
2015-10-14 12:16:22 +01:00
|
|
|
|
2018-05-31 08:29:01 +02:00
|
|
|
if (pDrViewSh)
|
|
|
|
{
|
|
|
|
INetBookmark aINetBookmark( "", "" );
|
|
|
|
|
|
|
|
if( ( aDataHelper.HasFormat( SotClipboardFormatId::NETSCAPE_BOOKMARK ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SotClipboardFormatId::NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
|
|
|
|
( aDataHelper.HasFormat( SotClipboardFormatId::FILEGRPDESCRIPTOR ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SotClipboardFormatId::FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
|
|
|
|
( aDataHelper.HasFormat( SotClipboardFormatId::UNIFORMRESOURCELOCATOR ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SotClipboardFormatId::UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
|
2001-08-03 13:43:08 +00:00
|
|
|
{
|
2018-05-31 08:29:01 +02:00
|
|
|
pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), "" );
|
2001-08-03 13:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
2004-10-04 17:32:01 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
FuInsertOLE::FuInsertOLE (
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
2000-09-18 16:07:07 +00:00
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuInsertOLE::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuInsertOLE( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 15:59:08 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuInsertOLE::DoExecute( SfxRequest& rReq )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if ( nSlotId == SID_ATTR_TABLE ||
|
|
|
|
nSlotId == SID_INSERT_DIAGRAM ||
|
|
|
|
nSlotId == SID_INSERT_MATH )
|
|
|
|
{
|
2010-02-09 18:14:49 +01:00
|
|
|
PresObjKind ePresObjKind = (nSlotId == SID_INSERT_DIAGRAM) ? PRESOBJ_CHART : PRESOBJ_OBJECT;
|
|
|
|
|
|
|
|
SdrObject* pPickObj = mpView->GetEmptyPresentationObject( ePresObjKind );
|
|
|
|
|
2013-03-12 20:27:21 +01:00
|
|
|
// insert diagram or Calc table
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aObjName;
|
2004-10-04 17:32:01 +00:00
|
|
|
SvGlobalName aName;
|
2000-09-18 16:07:07 +00:00
|
|
|
if (nSlotId == SID_INSERT_DIAGRAM)
|
2004-10-04 17:32:01 +00:00
|
|
|
aName = SvGlobalName( SO3_SCH_CLASSID);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (nSlotId == SID_ATTR_TABLE)
|
2004-10-04 17:32:01 +00:00
|
|
|
aName = SvGlobalName(SO3_SC_CLASSID);
|
2000-09-18 16:07:07 +00:00
|
|
|
else if (nSlotId == SID_INSERT_MATH)
|
2004-10-04 17:32:01 +00:00
|
|
|
aName = SvGlobalName(SO3_SM_CLASSID);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj = mpViewShell->GetViewFrame()->GetObjectShell()->
|
2004-10-04 17:32:01 +00:00
|
|
|
GetEmbeddedObjectContainer().CreateEmbeddedObject( aName.GetByteSequence(), aObjName );
|
|
|
|
if ( xObj.is() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2014-06-09 14:32:53 -04:00
|
|
|
uno::Reference<embed::XComponentSupplier> xCompSupp(xObj, uno::UNO_QUERY);
|
|
|
|
if (xCompSupp.is())
|
|
|
|
{
|
|
|
|
// Create default chart type.
|
|
|
|
uno::Reference<chart2::XChartDocument> xChartDoc(xCompSupp->getComponent(), uno::UNO_QUERY);
|
|
|
|
if (xChartDoc.is())
|
|
|
|
xChartDoc->createDefaultChart();
|
|
|
|
}
|
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
|
2010-02-09 18:14:49 +01:00
|
|
|
|
|
|
|
MapUnit aUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
|
|
|
|
|
2017-03-30 20:27:55 +02:00
|
|
|
::tools::Rectangle aRect;
|
2010-02-09 18:14:49 +01:00
|
|
|
if( pPickObj )
|
2005-03-15 10:21:27 +00:00
|
|
|
{
|
2010-02-09 18:14:49 +01:00
|
|
|
aRect = pPickObj->GetLogicRect();
|
|
|
|
|
|
|
|
awt::Size aSz;
|
|
|
|
aSz.Width = aRect.GetWidth();
|
|
|
|
aSz.Height = aRect.GetHeight();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
2005-03-15 10:21:27 +00:00
|
|
|
}
|
2010-02-09 18:14:49 +01:00
|
|
|
else
|
2005-03-15 10:21:27 +00:00
|
|
|
{
|
2010-02-09 18:14:49 +01:00
|
|
|
awt::Size aSz;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aSz = xObj->getVisualAreaSize( nAspect );
|
|
|
|
}
|
|
|
|
catch ( embed::NoVisualAreaSizeException& )
|
|
|
|
{
|
|
|
|
// the default size will be set later
|
|
|
|
}
|
|
|
|
|
|
|
|
Size aSize( aSz.Width, aSz.Height );
|
|
|
|
|
|
|
|
if (aSize.Height() == 0 || aSize.Width() == 0)
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// rectangle with balanced edge ratio
|
2018-02-14 12:48:06 +02:00
|
|
|
aSize.setWidth( 14100 );
|
|
|
|
aSize.setHeight( 10000 );
|
2017-10-26 23:15:06 +02:00
|
|
|
Size aTmp = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(aUnit));
|
2010-02-09 18:14:49 +01:00
|
|
|
aSz.Width = aTmp.Width();
|
|
|
|
aSz.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 23:15:06 +02:00
|
|
|
aSize = OutputDevice::LogicToLogic(aSize, MapMode(aUnit), MapMode(MapUnit::Map100thMM));
|
2010-02-09 18:14:49 +01:00
|
|
|
}
|
|
|
|
|
2018-03-08 21:07:40 +01:00
|
|
|
Point aPos = mpWindow->GetVisibleCenter();
|
2018-02-16 08:43:34 +02:00
|
|
|
aPos.AdjustX( -(aSize.Width() / 2) );
|
|
|
|
aPos.AdjustY( -(aSize.Height() / 2) );
|
2017-03-30 20:27:55 +02:00
|
|
|
aRect = ::tools::Rectangle(aPos, aSize);
|
2005-03-15 10:21:27 +00:00
|
|
|
}
|
|
|
|
|
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects
Added need for SdrModel& in constructors of SdrModel,
SdrPage, SdrView and SdrObjList. Builds, not finished.
SOSAW080: removed and replaced old SdrModel
Removed and replaced GetModel()/SetModel() in all using
classes (SdrObject, SdrPage, SdrView), added accessors
to new referenced SdrModel, adapted all accessing places.
Refactored/Extended ::Clone and ::operator== for these
classes to allow cloning objects to a target SdrModel.
Adapted places where this is done AFAP. Added quite some
comments (tagged with 'TTTT') where possible further work
is needed. Builds completely, thus checking in. This does
not mean that this change is done yet.
SOSAW080: Adapted SdrPage/SdrModel relationship
Also needed to work on copy-construction of SdrPage and hierarchy,
quite some stuff removed, no copy-constructor anymore, no
MigrateItemPool stuff. Builds well, test stuck, will need
some cleanup/finetunung
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Debugging/Stabilizing/MakeUnitTestWork
SOSAW080: Stabilized for UnitTests, cleanups
SOSAW080: Adapted GetObjGraphic to just take a const SdrObject&
SOSAW080: Removed ChangeModel from classes
Classes SvxTextEditSource and SvxDrawPage (including
TextEditSource stuff) do not need change of SdrModel
anymore.
SOSAW080: Adapted some comments to make more readable
SOSAW080: Corrected constructor
SOSAW080: getSdrModelFromUnoModel added override marks
SOSAW080: Added missing includes
SOSAW080: Corrected SdrPage constructor
SOSAW080: Corrected some SdrObject::Clone scenarios
Especially when cloning to another SdrModel and taking
the sdr::properties into account.
SOSAW080: Added include for Mac-Build
SOSAW080: Added Scale to DefaultProperties
If a SdrModel change happens in DefaultProperties copy
constructor (used from Clone()), potentially a Scale
for the SfxItems has to be done.
SOSAW080: Added missing include for MacBuild
SOSAW080: Corrected CppunitTest_sc_anchor_test
An adaption of a SdrPathObj instantiation was missing,
added that. Seems as if that test is no tpart of the
usual 'make' scenario, but used/executed in gerrit builds
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
SOSAW080: Solve UNO API calls that move SvxShapes to other Model
Due to UNO API tests I got a call to insert an xShape to a
xDrawPage which was constructed in another Model, this has now to
be done by Cloning the SdrObject to the new SdrModel, getting
rid of the old one and getting all the UNO implementation
stuff right (referemces SdrObject <-> xShape).
1cb7d573d323e98a89761fe662c10c4a654fdec0
24617494a0ef79f6e33dfcb02782a833a81c6434
763f39094b6a48b529a6952d01468f8776c97679
242b9e228a9a042c3a5bdd38b1ea6600144276d5
242b9e228a9a042c3a5bdd38b1ea6600144276d5
33a6f3f306b70c223171aef796dd5ee041ad14df
6878b33f8b05738a44c0910e40a60a0f0d1d58ed
0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2
8c4626274a5cc531dad27f27c0c45d4c528fb2fb
446685a49a6d67aedd01cfbbd5e87b07f97a4d7b
c1b5ed3c99bc7219a0061e4ece24ea42afd2889a
22de9a1c8af7c25be5c108671ddc548ba323ed47
4caf6b6fbbe6e8130741d793dffb560fd01d4ed5
488b9601735ec1822433f82f633990063951fe08
c366d60299f239e3df856ddffedb19e743e4be0c
c5137ba8c597c7b5f90318df50e87b93a39a28dc
f9e646242cf89f6fde1315046952252a2c429779
f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410
1694b54903df784385abaa8452e1201e12344238
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
7b5c241faec7488924e5935ae8b19f785846b5e4
bf097ee7467895823fbd158a2a9543da3b5a5078
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
Reviewed-on: https://gerrit.libreoffice.org/52526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-03-01 15:54:32 +01:00
|
|
|
SdrOle2Obj* pOleObj = new SdrOle2Obj(
|
|
|
|
mpView->getSdrModelFromSdrView(),
|
|
|
|
svt::EmbeddedObjectRef( xObj, nAspect ),
|
|
|
|
aObjName,
|
|
|
|
aRect);
|
2010-02-09 18:14:49 +01:00
|
|
|
SdrPageView* pPV = mpView->GetSdrPageView();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-02-09 18:14:49 +01:00
|
|
|
// if we have a pick obj we need to make this new ole a pres obj replacing the current pick obj
|
|
|
|
if( pPickObj )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
SOSAW080: Derive SdrObjGroup from SdrObjList
Also simplify parent/child relationships, get rid
of double data (SdrPage/Parent infos in SdrObjects,
also in SdrObjList). This is all not needed - when a
SdrObject is inserted to a SdrPage, get SdrPage by
traveling over parents (no double info, member as soon
as inserted, ...).
More cleanups/reworks included, will need some more
cleanups, too.
Stabilizing: SetRectsDirty/DefaultStyleSheet
Had to correct the SetRectsDirty stuff for 3D due to
going down the hierarchy while the 2D implementation
goes the other direction -> endless loops. Added special
handling for 3D stuff for now (will be chnaged again when
SnapRect is no longer needed at SdrObject level).
Also had to adapt how the DefaultStyleSheet is set at
incarnated SdrObjects - better: their properties. Since
we now always have a SdrModel, it is possible to correctly
initialize with the correct default StyleSheet from that
SdrModel.
This needs to be done after ForceDefaultAttributes and in a
way that again deletes Items that are set in the StyleSheet.
This leads to an error in CppunitTest_sd_import_tests where
I checked tdf100491 - it is okay and thus I change the control
instance of the imported, XML-dumped file.
The less hard attributes, the better for Styles in general.
Cleanup of comments for last two commits
Corrected SvxShape::getParent()
Needed to get the direct parent, so test for SdrObject
first (to get SdrObjGroup/E3DScene), for SdrPage second
Fixed CppunitTest_sc_subsequent_export_test
Several problems arose. The used SdrCaptionObj was
Cloned, but the clone not inserted to a SdrPage. This
leads to not being able to access a UNO API imlementation
of the SdrPage (SvxPage) on lower levels.
It worked before due to SdrObject having a SdrPage*
additionally to being added to a SdrPage - this is exactly
the main cleanup this change does.
Looked for why it is cloned, could see no reasons. The
SdrCaptionObj exists during all im/export, not difference
to other SdrObjects (that do not get cloned). It is not
changed in any way. It *might* be to suppress a crash that
happened due to UNO API Service emfio/emfio not being
available in the UnitTest scenario. Interestingly it
did not crash with the cloned SdrCaptionObj, but the
Graphic exported was probably wrong.
Fixed by no longer Cloning the SdrCaptionObj and adding
emfio/emfio UNO API Service.
d139f821a5b39535a3e7b9c6261df7e18f8ae8ac
910e7f4bc628a715fda7545dffaf3369d5e76ea0
ca1de01b723051e09ac37d7ec7bba978beea41c5
3a76da1471dfe75e69847f64a6a3519ad21c8c9c
Change-Id: I986586e326b563acebf00d931a7084c6eb09e5f8
Reviewed-on: https://gerrit.libreoffice.org/54689
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-04-16 22:34:50 +02:00
|
|
|
SdPage* pPage = static_cast< SdPage* >(pPickObj->getSdrPageFromSdrObject());
|
2010-02-09 18:14:49 +01:00
|
|
|
if(pPage && pPage->IsPresObj(pPickObj))
|
|
|
|
{
|
2010-02-23 00:23:09 +01:00
|
|
|
pPage->InsertPresObj( pOleObj, ePresObjKind );
|
2010-02-09 18:14:49 +01:00
|
|
|
pOleObj->SetUserCall(pPickObj->GetUserCall());
|
|
|
|
}
|
2014-02-17 15:48:54 +00:00
|
|
|
|
|
|
|
// #i123468# we need to end text edit before replacing the object. There cannot yet
|
|
|
|
// being text typed (else it would not be an EmptyPresObj anymore), but it may be
|
|
|
|
// in text edit mode
|
|
|
|
if (mpView->IsTextEdit())
|
|
|
|
{
|
|
|
|
mpView->SdrEndTextEdit();
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-02-09 18:14:49 +01:00
|
|
|
|
|
|
|
bool bRet = true;
|
|
|
|
if( pPickObj )
|
2015-08-20 12:58:15 +02:00
|
|
|
mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2015-04-23 15:00:26 +02:00
|
|
|
bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SdrInsertFlags::SETDEFLAYER);
|
2010-02-09 18:14:49 +01:00
|
|
|
|
|
|
|
if( bRet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (nSlotId == SID_INSERT_DIAGRAM)
|
|
|
|
{
|
2015-11-06 09:37:00 +01:00
|
|
|
pOleObj->SetProgName( "StarChart");
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (nSlotId == SID_ATTR_TABLE)
|
|
|
|
{
|
2015-11-06 09:37:00 +01:00
|
|
|
pOleObj->SetProgName( "StarCalc" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (nSlotId == SID_INSERT_MATH)
|
|
|
|
{
|
2015-11-06 09:37:00 +01:00
|
|
|
pOleObj->SetProgName( "StarMath" );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pOleObj->SetLogicRect(aRect);
|
2017-10-26 23:15:06 +02:00
|
|
|
Size aTmp( OutputDevice::LogicToLogic(aRect.GetSize(), MapMode(MapUnit::Map100thMM), MapMode(aUnit)) );
|
2010-02-09 18:14:49 +01:00
|
|
|
awt::Size aVisualSize;
|
|
|
|
aVisualSize.Width = aTmp.Width();
|
|
|
|
aVisualSize.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aVisualSize );
|
2016-01-13 22:34:34 +01:00
|
|
|
mpViewShell->ActivateObject(pOleObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
|
2007-05-22 15:13:37 +00:00
|
|
|
|
|
|
|
if (nSlotId == SID_INSERT_DIAGRAM)
|
|
|
|
{
|
|
|
|
// note, that this call modified the chart model which
|
|
|
|
// results in a change notification. So call this after
|
|
|
|
// everything else is finished.
|
2012-11-14 11:09:12 +00:00
|
|
|
ChartHelper::AdaptDefaultsForChart( xObj );
|
2007-05-22 15:13:37 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-02-07 22:48:33 +01:00
|
|
|
ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL,
|
|
|
|
"" ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// insert object
|
2004-10-04 17:32:01 +00:00
|
|
|
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bCreateNew = false;
|
2004-10-04 17:32:01 +00:00
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj;
|
|
|
|
uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
|
|
|
|
SvObjectServerList aServerLst;
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aName;
|
2004-10-04 17:32:01 +00:00
|
|
|
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aIconMediaType;
|
2006-10-13 10:02:27 +00:00
|
|
|
uno::Reference< io::XInputStream > xIconMetaFile;
|
|
|
|
|
2015-10-16 08:42:39 +02:00
|
|
|
const SfxGlobalNameItem* pNameItem = rReq.GetArg<SfxGlobalNameItem>(SID_INSERT_OBJECT);
|
2004-10-04 17:32:01 +00:00
|
|
|
if ( nSlotId == SID_INSERT_OBJECT && pNameItem )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
SvGlobalName aClassName = pNameItem->GetValue();
|
2006-12-13 16:56:12 +00:00
|
|
|
xObj = mpViewShell->GetViewFrame()->GetObjectShell()->
|
2004-10-04 17:32:01 +00:00
|
|
|
GetEmbeddedObjectContainer().CreateEmbeddedObject( aClassName.GetByteSequence(), aName );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-10-04 17:32:01 +00:00
|
|
|
else
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
switch ( nSlotId )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
case SID_INSERT_OBJECT :
|
|
|
|
{
|
|
|
|
aServerLst.FillInsertObjects();
|
2016-10-11 12:21:55 +02:00
|
|
|
if (mpDoc->GetDocumentType() == DocumentType::Draw)
|
2004-10-04 17:32:01 +00:00
|
|
|
{
|
|
|
|
aServerLst.Remove( GraphicDocShell::Factory().GetClassId() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aServerLst.Remove( DrawDocShell::Factory().GetClassId() );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2016-05-10 16:42:16 +02:00
|
|
|
SAL_FALLTHROUGH;
|
2004-10-04 17:32:01 +00:00
|
|
|
}
|
|
|
|
case SID_INSERT_FLOATINGFRAME :
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
2016-10-27 20:55:49 +01:00
|
|
|
ScopedVclPtr<SfxAbstractInsertObjectDialog> pDlg(
|
2018-04-04 10:22:34 +01:00
|
|
|
pFact->CreateInsertObjectDialog( mpViewShell->GetFrameWeld(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommandString(),
|
2014-05-19 22:25:31 +09:00
|
|
|
xStorage, &aServerLst ));
|
2018-05-31 08:29:01 +02:00
|
|
|
pDlg->Execute();
|
|
|
|
bCreateNew = pDlg->IsCreateNew();
|
|
|
|
xObj = pDlg->GetObject();
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2018-05-31 08:29:01 +02:00
|
|
|
xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
|
|
|
|
if ( xIconMetaFile.is() )
|
|
|
|
nAspect = embed::Aspects::MSOLE_ICON;
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2018-05-31 08:29:01 +02:00
|
|
|
if ( xObj.is() )
|
|
|
|
mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
|
2004-10-04 17:32:01 +00:00
|
|
|
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
try
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
if (xObj.is())
|
|
|
|
{
|
2014-04-24 10:52:02 +02:00
|
|
|
bool bInsertNewObject = true;
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
Size aSize;
|
2016-09-20 16:41:39 +02:00
|
|
|
MapUnit aMapUnit = MapUnit::Map100thMM;
|
2009-02-12 12:44:26 +00:00
|
|
|
if ( nAspect != embed::Aspects::MSOLE_ICON )
|
2006-10-13 10:02:27 +00:00
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
awt::Size aSz;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
aSz = xObj->getVisualAreaSize( nAspect );
|
|
|
|
}
|
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{
|
|
|
|
// the default size will be set later
|
|
|
|
}
|
2005-03-15 10:21:27 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
aSize =Size( aSz.Width, aSz.Height );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObj->getMapUnit( nAspect ) );
|
|
|
|
if (aSize.Height() == 0 || aSize.Width() == 0)
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// rectangle with balanced edge ratio
|
2018-02-14 12:48:06 +02:00
|
|
|
aSize.setWidth( 14100 );
|
|
|
|
aSize.setHeight( 10000 );
|
2017-10-26 23:15:06 +02:00
|
|
|
Size aTmp = OutputDevice::LogicToLogic(aSize, MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
|
2009-02-12 12:44:26 +00:00
|
|
|
aSz.Width = aTmp.Width();
|
|
|
|
aSz.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 23:15:06 +02:00
|
|
|
aSize = OutputDevice::LogicToLogic(aSize, MapMode(aMapUnit), MapMode(MapUnit::Map100thMM));
|
2009-02-12 12:44:26 +00:00
|
|
|
}
|
2006-10-13 10:02:27 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if ( mpView->AreObjectsMarked() )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// as an empty OLE object available?
|
2009-02-12 12:44:26 +00:00
|
|
|
const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if (rMarkList.GetMarkCount() == 1)
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
SdrMark* pMark = rMarkList.GetMark(0);
|
|
|
|
SdrObject* pObj = pMark->GetMarkedSdrObj();
|
2006-11-14 13:29:15 +00:00
|
|
|
|
2016-11-21 11:45:50 +02:00
|
|
|
if (pObj->GetObjInventor() == SdrInventor::Default &&
|
2009-02-12 12:44:26 +00:00
|
|
|
pObj->GetObjIdentifier() == OBJ_OLE2)
|
|
|
|
{
|
2014-10-29 11:04:25 +02:00
|
|
|
if ( !static_cast<SdrOle2Obj*>(pObj)->GetObjRef().is() )
|
2006-10-13 10:02:27 +00:00
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// the empty OLE object gets a new IPObj
|
2014-04-24 10:52:02 +02:00
|
|
|
bInsertNewObject = false;
|
2014-01-28 20:00:21 +01:00
|
|
|
pObj->SetEmptyPresObj(false);
|
2015-11-10 10:23:02 +01:00
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetOutlinerParaObject(nullptr);
|
2014-10-29 11:04:25 +02:00
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetObjRef(xObj);
|
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetPersistName(aName);
|
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetName(aName);
|
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetAspect(nAspect);
|
2017-03-30 20:27:55 +02:00
|
|
|
::tools::Rectangle aRect = static_cast<SdrOle2Obj*>(pObj)->GetLogicRect();
|
2009-02-12 12:44:26 +00:00
|
|
|
|
|
|
|
if ( nAspect == embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
|
|
|
if( xIconMetaFile.is() )
|
2014-10-29 11:04:25 +02:00
|
|
|
static_cast<SdrOle2Obj*>(pObj)->SetGraphicToObj( xIconMetaFile, aIconMediaType );
|
2009-02-12 12:44:26 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-10-26 23:15:06 +02:00
|
|
|
Size aTmp = OutputDevice::LogicToLogic(aRect.GetSize(), MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
|
2009-02-12 12:44:26 +00:00
|
|
|
awt::Size aSz( aTmp.Width(), aTmp.Height() );
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
2006-10-13 10:02:27 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if (bInsertNewObject)
|
2006-10-13 10:02:27 +00:00
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// we create a new OLE object
|
2009-02-12 12:44:26 +00:00
|
|
|
SdrPageView* pPV = mpView->GetSdrPageView();
|
|
|
|
Size aPageSize = pPV->GetPage()->GetSize();
|
|
|
|
|
|
|
|
// get the size from the iconified object
|
|
|
|
::svt::EmbeddedObjectRef aObjRef( xObj, nAspect );
|
|
|
|
if ( nAspect == embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
|
|
|
aObjRef.SetGraphicStream( xIconMetaFile, aIconMediaType );
|
2016-09-20 16:41:39 +02:00
|
|
|
MapMode aMapMode( MapUnit::Map100thMM );
|
2009-02-12 12:44:26 +00:00
|
|
|
aSize = aObjRef.GetSize( &aMapMode );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
Point aPnt ((aPageSize.Width() - aSize.Width()) / 2,
|
|
|
|
(aPageSize.Height() - aSize.Height()) / 2);
|
2017-03-30 20:27:55 +02:00
|
|
|
::tools::Rectangle aRect (aPnt, aSize);
|
SOSAW080: Added first bunch of basic changes to helpers
SOSAW080: Make SdrModel& prerequisite to SdrObjects
Added need for SdrModel& in constructors of SdrModel,
SdrPage, SdrView and SdrObjList. Builds, not finished.
SOSAW080: removed and replaced old SdrModel
Removed and replaced GetModel()/SetModel() in all using
classes (SdrObject, SdrPage, SdrView), added accessors
to new referenced SdrModel, adapted all accessing places.
Refactored/Extended ::Clone and ::operator== for these
classes to allow cloning objects to a target SdrModel.
Adapted places where this is done AFAP. Added quite some
comments (tagged with 'TTTT') where possible further work
is needed. Builds completely, thus checking in. This does
not mean that this change is done yet.
SOSAW080: Adapted SdrPage/SdrModel relationship
Also needed to work on copy-construction of SdrPage and hierarchy,
quite some stuff removed, no copy-constructor anymore, no
MigrateItemPool stuff. Builds well, test stuck, will need
some cleanup/finetunung
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Smaller corrections/includes adapted
SOSAW080: Debugging/Stabilizing/MakeUnitTestWork
SOSAW080: Stabilized for UnitTests, cleanups
SOSAW080: Adapted GetObjGraphic to just take a const SdrObject&
SOSAW080: Removed ChangeModel from classes
Classes SvxTextEditSource and SvxDrawPage (including
TextEditSource stuff) do not need change of SdrModel
anymore.
SOSAW080: Adapted some comments to make more readable
SOSAW080: Corrected constructor
SOSAW080: getSdrModelFromUnoModel added override marks
SOSAW080: Added missing includes
SOSAW080: Corrected SdrPage constructor
SOSAW080: Corrected some SdrObject::Clone scenarios
Especially when cloning to another SdrModel and taking
the sdr::properties into account.
SOSAW080: Added include for Mac-Build
SOSAW080: Added Scale to DefaultProperties
If a SdrModel change happens in DefaultProperties copy
constructor (used from Clone()), potentially a Scale
for the SfxItems has to be done.
SOSAW080: Added missing include for MacBuild
SOSAW080: Corrected CppunitTest_sc_anchor_test
An adaption of a SdrPathObj instantiation was missing,
added that. Seems as if that test is no tpart of the
usual 'make' scenario, but used/executed in gerrit builds
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Reworked SvxShape to use SdrObject's SdrModel
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
SOSAW080: Solve UNO API calls that move SvxShapes to other Model
Due to UNO API tests I got a call to insert an xShape to a
xDrawPage which was constructed in another Model, this has now to
be done by Cloning the SdrObject to the new SdrModel, getting
rid of the old one and getting all the UNO implementation
stuff right (referemces SdrObject <-> xShape).
1cb7d573d323e98a89761fe662c10c4a654fdec0
24617494a0ef79f6e33dfcb02782a833a81c6434
763f39094b6a48b529a6952d01468f8776c97679
242b9e228a9a042c3a5bdd38b1ea6600144276d5
242b9e228a9a042c3a5bdd38b1ea6600144276d5
33a6f3f306b70c223171aef796dd5ee041ad14df
6878b33f8b05738a44c0910e40a60a0f0d1d58ed
0a636caf3cb36c2f9c6cd11aa22cb9bc435dc8f2
8c4626274a5cc531dad27f27c0c45d4c528fb2fb
446685a49a6d67aedd01cfbbd5e87b07f97a4d7b
c1b5ed3c99bc7219a0061e4ece24ea42afd2889a
22de9a1c8af7c25be5c108671ddc548ba323ed47
4caf6b6fbbe6e8130741d793dffb560fd01d4ed5
488b9601735ec1822433f82f633990063951fe08
c366d60299f239e3df856ddffedb19e743e4be0c
c5137ba8c597c7b5f90318df50e87b93a39a28dc
f9e646242cf89f6fde1315046952252a2c429779
f830fbc5fadd89d04be5edd2a5abf9b0d4bf0410
1694b54903df784385abaa8452e1201e12344238
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
17bcb44d2e29920c0c74430c2d9c703b36cfa0ad
7b5c241faec7488924e5935ae8b19f785846b5e4
bf097ee7467895823fbd158a2a9543da3b5a5078
Change-Id: Iaf53535de0502a481466be74a1768bbb39f0e78c
Reviewed-on: https://gerrit.libreoffice.org/52526
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
2018-03-01 15:54:32 +01:00
|
|
|
SdrOle2Obj* pObj = new SdrOle2Obj(
|
|
|
|
mpView->getSdrModelFromSdrView(),
|
|
|
|
aObjRef,
|
|
|
|
aName,
|
|
|
|
aRect);
|
2003-03-27 09:58:12 +00:00
|
|
|
|
2015-04-23 15:00:26 +02:00
|
|
|
if( mpView->InsertObjectAtView(pObj, *pPV, SdrInsertFlags::SETDEFLAYER) )
|
2003-03-27 09:58:12 +00:00
|
|
|
{
|
2011-02-07 22:11:09 +01:00
|
|
|
// Math objects change their object size during InsertObject.
|
2009-02-12 12:44:26 +00:00
|
|
|
// New size must be set in SdrObject, or a wrong scale will be set at
|
|
|
|
// ActivateObject.
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if ( nAspect != embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
|
|
|
try
|
2006-10-13 10:02:27 +00:00
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
awt::Size aSz = xObj->getVisualAreaSize( nAspect );
|
|
|
|
|
|
|
|
Size aNewSize = Window::LogicToLogic( Size( aSz.Width, aSz.Height ),
|
2016-09-20 16:41:39 +02:00
|
|
|
MapMode( aMapUnit ), MapMode( MapUnit::Map100thMM ) );
|
2009-02-12 12:44:26 +00:00
|
|
|
if ( aNewSize != aSize )
|
|
|
|
{
|
|
|
|
aRect.SetSize( aNewSize );
|
|
|
|
pObj->SetLogicRect( aRect );
|
|
|
|
}
|
2006-10-13 10:02:27 +00:00
|
|
|
}
|
2009-02-12 12:44:26 +00:00
|
|
|
catch( embed::NoVisualAreaSizeException& )
|
|
|
|
{}
|
2005-03-15 10:21:27 +00:00
|
|
|
}
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if (bCreateNew)
|
2006-10-13 10:02:27 +00:00
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
pObj->SetLogicRect(aRect);
|
|
|
|
|
|
|
|
if ( nAspect != embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
2017-10-26 23:15:06 +02:00
|
|
|
Size aTmp = OutputDevice::LogicToLogic(aRect.GetSize(), MapMode(MapUnit::Map100thMM), MapMode(aMapUnit));
|
2009-02-12 12:44:26 +00:00
|
|
|
awt::Size aSz( aTmp.Width(), aTmp.Height() );
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
|
2016-01-13 22:34:34 +01:00
|
|
|
mpViewShell->ActivateObject(pObj, embed::EmbedVerbs::MS_OLEVERB_SHOW);
|
2006-10-13 10:02:27 +00:00
|
|
|
}
|
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
Size aVisSizePixel = mpWindow->GetOutputSizePixel();
|
2017-03-30 20:27:55 +02:00
|
|
|
::tools::Rectangle aVisAreaWin = mpWindow->PixelToLogic( ::tools::Rectangle( Point(0,0), aVisSizePixel) );
|
2009-02-12 12:44:26 +00:00
|
|
|
mpViewShell->VisAreaChanged(aVisAreaWin);
|
|
|
|
mpDocSh->SetVisArea(aVisAreaWin);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-02-12 12:44:26 +00:00
|
|
|
catch (uno::Exception&)
|
|
|
|
{
|
|
|
|
// For some reason the object can not be inserted. For example
|
|
|
|
// because it is password protected and is not properly unlocked.
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-08-12 08:15:37 +00:00
|
|
|
FuInsertAVMedia::FuInsertAVMedia(
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> FuInsertAVMedia::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
2005-12-14 15:59:08 +00:00
|
|
|
{
|
2013-10-25 15:42:11 +02:00
|
|
|
rtl::Reference<FuPoor> xFunc( new FuInsertAVMedia( pViewSh, pWin, pView, pDoc, rReq ) );
|
2005-12-14 15:59:08 +00:00
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
OUString aURL;
|
2004-08-12 08:15:37 +00:00
|
|
|
const SfxItemSet* pReqArgs = rReq.GetArgs();
|
|
|
|
bool bAPI = false;
|
|
|
|
|
|
|
|
if( pReqArgs )
|
|
|
|
{
|
2015-09-30 16:10:07 +02:00
|
|
|
const SfxStringItem* pStringItem = dynamic_cast<const SfxStringItem*>( &pReqArgs->Get( rReq.GetSlot() ) );
|
2004-08-12 08:15:37 +00:00
|
|
|
|
|
|
|
if( pStringItem )
|
|
|
|
{
|
|
|
|
aURL = pStringItem->GetValue();
|
2012-01-08 09:52:25 -02:00
|
|
|
bAPI = !aURL.isEmpty();
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-30 16:08:24 +01:00
|
|
|
bool bLink(true);
|
2017-10-09 19:10:13 +02:00
|
|
|
if (bAPI
|
|
|
|
#if HAVE_FEATURE_AVMEDIA
|
2018-04-04 14:33:16 +01:00
|
|
|
|| ::avmedia::MediaWindow::executeMediaURLDialog(mpWindow ? mpWindow->GetFrameWeld() : nullptr, aURL, & bLink)
|
2017-10-09 19:10:13 +02:00
|
|
|
#endif
|
|
|
|
)
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
|
|
|
Size aPrefSize;
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->EnterWait();
|
2004-08-12 08:15:37 +00:00
|
|
|
|
2017-10-09 19:10:13 +02:00
|
|
|
#if HAVE_FEATURE_AVMEDIA
|
2013-11-20 14:43:45 +01:00
|
|
|
if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) )
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->LeaveWait();
|
2004-08-12 08:15:37 +00:00
|
|
|
|
|
|
|
if( !bAPI )
|
2018-02-19 16:33:35 +00:00
|
|
|
::avmedia::MediaWindow::executeFormatErrorBox(mpWindow->GetFrameWeld());
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Point aPos;
|
|
|
|
Size aSize;
|
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
|
|
|
|
|
|
|
if( aPrefSize.Width() && aPrefSize.Height() )
|
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
2017-10-26 23:15:06 +02:00
|
|
|
aSize = mpWindow->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM));
|
2004-08-12 08:15:37 +00:00
|
|
|
else
|
2017-10-26 23:15:06 +02:00
|
|
|
aSize = Application::GetDefaultDevice()->PixelToLogic(aPrefSize, MapMode(MapUnit::Map100thMM));
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
aSize = Size( 5000, 5000 );
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
2017-03-30 20:27:55 +02:00
|
|
|
aPos = mpWindow->PixelToLogic( ::tools::Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() );
|
2018-02-16 08:43:34 +02:00
|
|
|
aPos.AdjustX( -(aSize.Width() >> 1) );
|
|
|
|
aPos.AdjustY( -(aSize.Height() >> 1) );
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
|
|
|
|
2011-12-02 23:54:33 +01:00
|
|
|
mpView->InsertMediaURL( aURL, nAction, aPos, aSize, bLink ) ;
|
2004-08-12 08:15:37 +00:00
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->LeaveWait();
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
2017-10-09 19:10:13 +02:00
|
|
|
#else
|
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->LeaveWait();
|
|
|
|
(void) aPrefSize;
|
|
|
|
(void) bLink;
|
|
|
|
#endif
|
2004-08-12 08:15:37 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
} // end of namespace sd
|
2010-10-12 15:51:52 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|