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
|
|
|
|
2006-09-16 17:50:47 +00:00
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
#include "fuinsert.hxx"
|
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <comphelper/storagehelper.hxx>
|
|
|
|
#include <comphelper/processfactory.hxx>
|
|
|
|
#include <toolkit/helper/vclunohelper.hxx>
|
|
|
|
#include <svx/svxdlg.hxx>
|
2005-03-15 10:21:27 +00:00
|
|
|
#include <com/sun/star/embed/NoVisualAreaSizeException.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>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <svtools/sores.hxx>
|
|
|
|
#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>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/pfiledlg.hxx>
|
|
|
|
#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>
|
2000-11-10 15:53:19 +00:00
|
|
|
#include <unotools/ucbstreamhelper.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>
|
2001-01-19 18:15:28 +00:00
|
|
|
#include <vcl/msgbox.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
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "app.hrc"
|
|
|
|
#include "sdresid.hxx"
|
2004-01-20 10:02:54 +00:00
|
|
|
#include "View.hxx"
|
2013-04-19 15:49:58 -04:00
|
|
|
#include "sdmod.hxx"
|
2004-01-20 10:02:54 +00:00
|
|
|
#include "Window.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "drawview.hxx"
|
2004-01-20 10:02:54 +00:00
|
|
|
#include "DrawViewShell.hxx"
|
|
|
|
#include "DrawDocShell.hxx"
|
|
|
|
#include "GraphicDocShell.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "strings.hrc"
|
|
|
|
#include "drawdoc.hxx"
|
2001-02-13 11:17:06 +00:00
|
|
|
#include "sdgrffilter.hxx"
|
2001-01-19 18:15:28 +00:00
|
|
|
#include "sdxfer.hxx"
|
2006-11-14 13:29:15 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
2010-02-09 18:14:49 +01:00
|
|
|
#include "undo/undoobjects.hxx"
|
2012-05-31 13:23:45 +00:00
|
|
|
#include "glob.hrc"
|
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
|
|
|
|
|
|
|
TYPEINIT1( FuInsertGraphic, FuPoor );
|
|
|
|
TYPEINIT1( FuInsertClipboard, FuPoor );
|
|
|
|
TYPEINIT1( FuInsertOLE, FuPoor );
|
2004-08-12 08:15:37 +00:00
|
|
|
TYPEINIT1( FuInsertAVMedia, FuPoor );
|
2014-03-27 11:22:02 +01:00
|
|
|
TYPEINIT1( FuInsert3DModel, FuPoor );
|
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,
|
|
|
|
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> FuInsertGraphic::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 FuInsertGraphic( 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 FuInsertGraphic::DoExecute( SfxRequest& )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-25 16:54:47 +00:00
|
|
|
SvxOpenGraphicDialog aDlg(SdResId(STR_INSERTGRAPHIC));
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-22 16:39:56 +00:00
|
|
|
if( aDlg.Execute() == GRFILTER_OK )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-06-22 16:39:56 +00:00
|
|
|
Graphic aGraphic;
|
2006-12-13 16:56:12 +00:00
|
|
|
int nError = aDlg.GetGraphic(aGraphic);
|
|
|
|
if( nError == GRFILTER_OK )
|
2001-06-22 16:39:56 +00:00
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpViewShell && mpViewShell->ISA(DrawViewShell))
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2001-03-08 10:12:28 +00:00
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
2012-12-04 15:56:38 +01:00
|
|
|
SdrObject* pPickObj;
|
2014-02-07 01:26:23 +00:00
|
|
|
bool bSelectionReplaced(false);
|
2012-12-04 15:56:38 +01:00
|
|
|
|
|
|
|
if( ( pPickObj = mpView->GetSelectedSingleObject( mpView->GetPage() ) ) || ( pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC ) ) )
|
2014-02-07 01:26:23 +00:00
|
|
|
{
|
2009-12-03 18:53:41 +01:00
|
|
|
nAction = DND_ACTION_LINK;
|
2014-02-07 01:26:23 +00:00
|
|
|
}
|
|
|
|
else if(1 == mpView->GetMarkedObjectCount())
|
|
|
|
{
|
|
|
|
pPickObj = mpView->GetMarkedObjectByIndex(0);
|
|
|
|
nAction = DND_ACTION_MOVE;
|
|
|
|
bSelectionReplaced = true;
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
Point aPos;
|
2006-12-13 16:56:12 +00:00
|
|
|
Rectangle aRect(aPos, mpWindow->GetOutputSizePixel() );
|
2000-09-18 16:07:07 +00:00
|
|
|
aPos = aRect.Center();
|
2006-12-13 16:56:12 +00:00
|
|
|
aPos = mpWindow->PixelToLogic(aPos);
|
2009-12-03 18:53:41 +01:00
|
|
|
SdrGrafObj* pGrafObj = mpView->InsertGraphic(aGraphic, nAction, aPos, pPickObj, NULL);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2001-06-22 16:39:56 +00:00
|
|
|
if(pGrafObj && aDlg.IsAsLink())
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2010-08-25 22:53:55 +02:00
|
|
|
// really store as link only?
|
|
|
|
if( SvtMiscOptions().ShowLinkWarningDialog() )
|
|
|
|
{
|
|
|
|
SvxLinkWarningDialog aWarnDlg(mpWindow,aDlg.GetPath());
|
|
|
|
if( aWarnDlg.Execute() != RET_OK )
|
|
|
|
return; // don't store as link
|
|
|
|
}
|
|
|
|
|
|
|
|
// store as link
|
2013-08-24 22:22:45 +04:00
|
|
|
OUString aFltName(aDlg.GetCurrentFilter());
|
|
|
|
OUString aPath(aDlg.GetPath());
|
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
|
|
|
OUString aReferer;
|
|
|
|
if (mpDocSh->HasName()) {
|
|
|
|
aReferer = mpDocSh->GetMedium()->GetName();
|
|
|
|
}
|
|
|
|
pGrafObj->SetGraphicLink(aPath, aReferer, aFltName);
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2014-02-07 01:26:23 +00:00
|
|
|
|
|
|
|
if(bSelectionReplaced && pGrafObj)
|
|
|
|
{
|
|
|
|
mpView->MarkObj(pGrafObj, mpView->GetSdrPageView());
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
2001-06-22 16:39:56 +00:00
|
|
|
else
|
|
|
|
{
|
2011-05-19 23:10:04 +01:00
|
|
|
SdGRFFilter::HandleGraphicFilterError( (sal_uInt16)nError, GraphicFilter::GetGraphicFilter().GetLastError().nStreamError );
|
2001-06-22 16:39:56 +00:00
|
|
|
}
|
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 ) );
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_uLong nFormatId;
|
2001-03-16 16:41:14 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
2006-12-13 16:56:12 +00:00
|
|
|
SfxAbstractPasteDialog* pDlg = pFact->CreatePasteDialog( mpViewShell->GetActiveWindow() );
|
2004-10-04 17:32:01 +00:00
|
|
|
if ( pDlg )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
::com::sun::star::datatransfer::DataFlavor aFlavor;
|
|
|
|
|
2013-08-24 22:22:45 +04:00
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_DRAWING, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_SVXB, OUString() );
|
|
|
|
pDlg->Insert( FORMAT_GDIMETAFILE, OUString() );
|
|
|
|
pDlg->Insert( FORMAT_BITMAP, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, OUString() );
|
|
|
|
pDlg->Insert( FORMAT_STRING, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_HTML, OUString() );
|
|
|
|
pDlg->Insert( FORMAT_RTF, OUString() );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_EDITENGINE, OUString() );
|
2004-10-04 17:32:01 +00:00
|
|
|
|
|
|
|
//TODO/MBA: testing
|
|
|
|
nFormatId = pDlg->GetFormat( aDataHelper );
|
|
|
|
if( nFormatId && aDataHelper.GetTransferable().is() )
|
2001-08-03 13:43:08 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( !mpView->InsertData( aDataHelper,
|
|
|
|
mpWindow->PixelToLogic( Rectangle( Point(), mpWindow->GetOutputSizePixel() ).Center() ),
|
2011-01-17 11:41:00 +01:00
|
|
|
nAction, sal_False, nFormatId ) &&
|
2006-12-13 16:56:12 +00:00
|
|
|
( mpViewShell && mpViewShell->ISA( DrawViewShell ) ) )
|
2001-08-03 13:43:08 +00:00
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
DrawViewShell* pDrViewSh = static_cast<DrawViewShell*>(mpViewShell);
|
2004-10-04 17:32:01 +00:00
|
|
|
INetBookmark aINetBookmark( aEmptyStr, aEmptyStr );
|
|
|
|
|
|
|
|
if( ( aDataHelper.HasFormat( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aINetBookmark ) ) ||
|
|
|
|
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_FILEGRPDESCRIPTOR, aINetBookmark ) ) ||
|
|
|
|
( aDataHelper.HasFormat( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR ) &&
|
|
|
|
aDataHelper.GetINetBookmark( SOT_FORMATSTR_ID_UNIFORMRESOURCELOCATOR, aINetBookmark ) ) )
|
|
|
|
{
|
|
|
|
pDrViewSh->InsertURLField( aINetBookmark.GetURL(), aINetBookmark.GetDescription(), aEmptyStr, NULL );
|
|
|
|
}
|
2001-08-03 13:43:08 +00:00
|
|
|
}
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
delete pDlg;
|
|
|
|
}
|
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
|
|
|
{
|
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 ) );
|
|
|
|
|
|
|
|
Rectangle aRect;
|
|
|
|
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
|
2010-02-09 18:14:49 +01:00
|
|
|
aSize.Width() = 14100;
|
|
|
|
aSize.Height() = 10000;
|
|
|
|
Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aUnit );
|
|
|
|
aSz.Width = aTmp.Width();
|
|
|
|
aSz.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSize = OutputDevice::LogicToLogic(aSize, aUnit, MAP_100TH_MM);
|
|
|
|
}
|
|
|
|
|
|
|
|
Point aPos;
|
|
|
|
Rectangle aWinRect(aPos, mpWindow->GetOutputSizePixel() );
|
|
|
|
aPos = aWinRect.Center();
|
|
|
|
aPos = mpWindow->PixelToLogic(aPos);
|
|
|
|
aPos.X() -= aSize.Width() / 2;
|
|
|
|
aPos.Y() -= aSize.Height() / 2;
|
|
|
|
aRect = Rectangle(aPos, aSize);
|
2005-03-15 10:21:27 +00:00
|
|
|
}
|
|
|
|
|
2010-02-09 18:14:49 +01:00
|
|
|
SdrOle2Obj* pOleObj = new SdrOle2Obj( svt::EmbeddedObjectRef( xObj, nAspect ), aObjName, aRect );
|
|
|
|
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
|
|
|
{
|
2010-02-09 18:14:49 +01:00
|
|
|
SdPage* pPage = static_cast< SdPage* >(pPickObj->GetPage());
|
|
|
|
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 )
|
2014-03-10 11:09:59 +02:00
|
|
|
mpView->ReplaceObjectAtView(pPickObj, *pPV, pOleObj, true );
|
2000-09-18 16:07:07 +00:00
|
|
|
else
|
2010-02-09 18:14:49 +01:00
|
|
|
bRet = mpView->InsertObjectAtView(pOleObj, *pPV, SDRINSERT_SETDEFLAYER);
|
|
|
|
|
|
|
|
if( bRet )
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
|
|
|
if (nSlotId == SID_INSERT_DIAGRAM)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pOleObj->SetProgName( OUString( "StarChart" ));
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (nSlotId == SID_ATTR_TABLE)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pOleObj->SetProgName( OUString( "StarCalc" ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else if (nSlotId == SID_INSERT_MATH)
|
|
|
|
{
|
2013-04-07 12:06:47 +02:00
|
|
|
pOleObj->SetProgName( OUString( "StarMath" ) );
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pOleObj->SetLogicRect(aRect);
|
2010-02-09 18:14:49 +01:00
|
|
|
Size aTmp( OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aUnit ) );
|
|
|
|
awt::Size aVisualSize;
|
|
|
|
aVisualSize.Width = aTmp.Width();
|
|
|
|
aVisualSize.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aVisualSize );
|
2006-12-13 16:56:12 +00:00
|
|
|
mpViewShell->ActivateObject(pOleObj, SVVERB_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
|
|
|
|
{
|
|
|
|
ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL,
|
|
|
|
aEmptyStr ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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;
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_Bool bCreateNew = sal_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;
|
|
|
|
|
2014-01-28 20:00:21 +01:00
|
|
|
SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, false );
|
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();
|
2006-12-13 16:56:12 +00:00
|
|
|
if (mpDoc->GetDocumentType() == DOCUMENT_TYPE_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
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
// intentionally no break!
|
|
|
|
}
|
|
|
|
case SID_INSERT_PLUGIN :
|
|
|
|
case SID_INSERT_FLOATINGFRAME :
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
|
|
|
|
SfxAbstractInsertObjectDialog* pDlg =
|
2010-07-10 18:21:24 +02:00
|
|
|
pFact->CreateInsertObjectDialog( mpViewShell->GetActiveWindow(), SD_MOD()->GetSlotPool()->GetSlot(nSlotId)->GetCommandString(),
|
2004-10-04 17:32:01 +00:00
|
|
|
xStorage, &aServerLst );
|
|
|
|
if ( pDlg )
|
|
|
|
{
|
|
|
|
pDlg->Execute();
|
|
|
|
bCreateNew = pDlg->IsCreateNew();
|
|
|
|
xObj = pDlg->GetObject();
|
2006-10-13 10:02:27 +00:00
|
|
|
|
|
|
|
xIconMetaFile = pDlg->GetIconIfIconified( &aIconMediaType );
|
|
|
|
if ( xIconMetaFile.is() )
|
|
|
|
nAspect = embed::Aspects::MSOLE_ICON;
|
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
if ( xObj.is() )
|
2006-12-13 16:56:12 +00:00
|
|
|
mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().InsertEmbeddedObject( xObj, aName );
|
2004-10-04 17:32:01 +00:00
|
|
|
DELETEZ( pDlg );
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2004-10-04 17:32:01 +00:00
|
|
|
case SID_INSERT_SOUND :
|
|
|
|
case SID_INSERT_VIDEO :
|
2000-09-18 16:07:07 +00:00
|
|
|
{
|
2004-10-04 17:32:01 +00:00
|
|
|
// create special filedialog for plugins
|
2006-12-13 16:56:12 +00:00
|
|
|
SvxPluginFileDlg aPluginFileDialog (mpWindow, nSlotId);
|
2004-10-04 17:32:01 +00:00
|
|
|
if( ERRCODE_NONE == aPluginFileDialog.Execute () )
|
|
|
|
{
|
|
|
|
// get URL
|
2013-08-24 22:22:45 +04:00
|
|
|
OUString aStrURL(aPluginFileDialog.GetPath());
|
2005-01-11 11:11:43 +00:00
|
|
|
INetURLObject aURL( aStrURL, INET_PROT_FILE );
|
2004-10-04 17:32:01 +00:00
|
|
|
if( aURL.GetProtocol() != INET_PROT_NOT_VALID )
|
|
|
|
{
|
|
|
|
// create a plugin object
|
2006-12-13 16:56:12 +00:00
|
|
|
xObj = mpViewShell->GetObjectShell()->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_PLUGIN_CLASSID ).GetByteSequence(), aName );
|
2004-10-04 17:32:01 +00:00
|
|
|
}
|
|
|
|
|
2006-02-01 17:40:24 +00:00
|
|
|
if ( xObj.is() && svt::EmbeddedObjectRef::TryRunningState( xObj ) )
|
2004-10-04 17:32:01 +00:00
|
|
|
{
|
|
|
|
// set properties from dialog
|
|
|
|
uno::Reference < embed::XComponentSupplier > xSup( xObj, uno::UNO_QUERY );
|
|
|
|
if ( xSup.is() )
|
|
|
|
{
|
|
|
|
uno::Reference < beans::XPropertySet > xSet( xSup->getComponent(), uno::UNO_QUERY );
|
|
|
|
if ( xSet.is() )
|
|
|
|
{
|
2012-04-13 15:07:17 -03:00
|
|
|
xSet->setPropertyValue("PluginURL",
|
2013-04-07 12:06:47 +02:00
|
|
|
uno::makeAny( OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
|
2004-10-04 17:32:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-03-12 20:27:21 +01:00
|
|
|
// unable to create PlugIn
|
2013-08-24 22:22:45 +04:00
|
|
|
OUString aStrErr( SdResId( STR_ERROR_OBJNOCREATE_PLUGIN ) );
|
|
|
|
aStrErr = aStrErr.replaceFirst( "%", aStrURL );
|
2006-12-13 16:56:12 +00:00
|
|
|
ErrorBox( mpWindow, WB_3DLOOK | WB_OK, aStrErr ).Execute();
|
2004-10-04 17:32:01 +00:00
|
|
|
}
|
|
|
|
}
|
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())
|
|
|
|
{
|
|
|
|
//TODO/LATER: needs status for RESIZEONPRINTERCHANGE
|
|
|
|
//if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xObj->getStatus( nAspect ) )
|
2011-01-17 11:41:00 +01:00
|
|
|
// aIPObj->OnDocumentPrinterChanged( mpDocSh->GetPrinter(sal_False) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2011-01-17 11:41:00 +01:00
|
|
|
sal_Bool bInsertNewObject = sal_True;
|
2006-10-13 10:02:27 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
Size aSize;
|
|
|
|
MapUnit aMapUnit = MAP_100TH_MM;
|
|
|
|
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
|
2009-02-12 12:44:26 +00:00
|
|
|
aSize.Width() = 14100;
|
|
|
|
aSize.Height() = 10000;
|
|
|
|
Size aTmp = OutputDevice::LogicToLogic( aSize, MAP_100TH_MM, aMapUnit );
|
|
|
|
aSz.Width = aTmp.Width();
|
|
|
|
aSz.Height = aTmp.Height();
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
aSize = OutputDevice::LogicToLogic(aSize, aMapUnit, MAP_100TH_MM);
|
|
|
|
}
|
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
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if (pObj->GetObjInventor() == SdrInventor &&
|
|
|
|
pObj->GetObjIdentifier() == OBJ_OLE2)
|
|
|
|
{
|
|
|
|
if ( !( (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
|
2011-01-17 11:41:00 +01:00
|
|
|
bInsertNewObject = sal_False;
|
2014-01-28 20:00:21 +01:00
|
|
|
pObj->SetEmptyPresObj(false);
|
2009-02-12 12:44:26 +00:00
|
|
|
( (SdrOle2Obj*) pObj)->SetOutlinerParaObject(NULL);
|
|
|
|
( (SdrOle2Obj*) pObj)->SetObjRef(xObj);
|
|
|
|
( (SdrOle2Obj*) pObj)->SetPersistName(aName);
|
|
|
|
( (SdrOle2Obj*) pObj)->SetName(aName);
|
|
|
|
( (SdrOle2Obj*) pObj)->SetAspect(nAspect);
|
|
|
|
Rectangle aRect = ( (SdrOle2Obj*) pObj)->GetLogicRect();
|
|
|
|
|
|
|
|
if ( nAspect == embed::Aspects::MSOLE_ICON )
|
|
|
|
{
|
|
|
|
if( xIconMetaFile.is() )
|
|
|
|
( (SdrOle2Obj*) pObj)->SetGraphicToObj( xIconMetaFile, aIconMediaType );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit );
|
|
|
|
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 );
|
|
|
|
MapMode aMapMode( MAP_100TH_MM );
|
|
|
|
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);
|
|
|
|
Rectangle aRect (aPnt, aSize);
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
SdrOle2Obj* pObj = new SdrOle2Obj( aObjRef, aName, aRect);
|
2003-03-27 09:58:12 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
if( mpView->InsertObjectAtView(pObj, *pPV, SDRINSERT_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 ),
|
|
|
|
MapMode( aMapUnit ), MapMode( MAP_100TH_MM ) );
|
|
|
|
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 )
|
|
|
|
{
|
|
|
|
Size aTmp = OutputDevice::LogicToLogic( aRect.GetSize(), MAP_100TH_MM, aMapUnit );
|
|
|
|
awt::Size aSz( aTmp.Width(), aTmp.Height() );
|
|
|
|
xObj->setVisualAreaSize( nAspect, aSz );
|
|
|
|
}
|
|
|
|
|
|
|
|
mpViewShell->ActivateObject(pObj, SVVERB_SHOW);
|
2006-10-13 10:02:27 +00:00
|
|
|
}
|
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
Size aVisSizePixel = mpWindow->GetOutputSizePixel();
|
|
|
|
Rectangle aVisAreaWin = mpWindow->PixelToLogic( Rectangle( Point(0,0), aVisSizePixel) );
|
|
|
|
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-01-20 10:02:54 +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 )
|
|
|
|
{
|
|
|
|
const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
|
|
|
|
|
|
|
|
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);
|
|
|
|
if (bAPI ||
|
|
|
|
::avmedia::MediaWindow::executeMediaURLDialog(mpWindow, aURL, & bLink))
|
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
|
|
|
|
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 )
|
2006-12-13 16:56:12 +00:00
|
|
|
::avmedia::MediaWindow::executeFormatErrorBox( mpWindow );
|
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 )
|
|
|
|
aSize = mpWindow->PixelToLogic( aPrefSize, MAP_100TH_MM );
|
2004-08-12 08:15:37 +00:00
|
|
|
else
|
|
|
|
aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_100TH_MM );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aSize = Size( 5000, 5000 );
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( mpWindow )
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
aPos = mpWindow->PixelToLogic( Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() );
|
2004-08-12 08:15:37 +00:00
|
|
|
aPos.X() -= aSize.Width() >> 1;
|
|
|
|
aPos.Y() -= aSize.Height() >> 1;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-27 11:22:02 +01:00
|
|
|
FuInsert3DModel::FuInsert3DModel(
|
|
|
|
ViewShell* pViewSh,
|
|
|
|
::sd::Window* pWin,
|
|
|
|
::sd::View* pView,
|
|
|
|
SdDrawDocument* pDoc,
|
|
|
|
SfxRequest& rReq)
|
|
|
|
: FuPoor(pViewSh, pWin, pView, pDoc, rReq)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
rtl::Reference<FuPoor> FuInsert3DModel::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
rtl::Reference<FuPoor> xFunc( new FuInsert3DModel( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuInsert3DModel::DoExecute( SfxRequest& )
|
|
|
|
{
|
|
|
|
sfx2::FileDialogHelper aDlg( ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE, 0 );
|
|
|
|
|
|
|
|
aDlg.SetTitle( "Open 3DModel" );
|
|
|
|
aDlg.AddFilter( "GL Transmission Format", "*.json" );
|
|
|
|
aDlg.AddFilter( "All files", "*.*" );
|
|
|
|
|
|
|
|
OUString sURL;
|
|
|
|
if( aDlg.Execute() == ERRCODE_NONE )
|
|
|
|
{
|
|
|
|
const INetURLObject aURL( aDlg.GetPath() );
|
|
|
|
sURL = aURL.GetMainURL( INetURLObject::DECODE_UNAMBIGUOUS );
|
|
|
|
}
|
|
|
|
else if( !sURL.isEmpty() )
|
|
|
|
sURL = OUString();
|
|
|
|
|
|
|
|
if (!sURL.isEmpty())
|
|
|
|
{
|
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->EnterWait();
|
|
|
|
|
|
|
|
Point aPos;
|
|
|
|
Size aSize(480,360);
|
|
|
|
sal_Int8 nAction = DND_ACTION_COPY;
|
|
|
|
|
|
|
|
if( mpWindow )
|
|
|
|
{
|
|
|
|
aPos = mpWindow->PixelToLogic( Rectangle( aPos, mpWindow->GetOutputSizePixel() ).Center() );
|
|
|
|
aPos.X() -= aSize.Width() >> 1;
|
|
|
|
aPos.Y() -= aSize.Height() >> 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
mpView->InsertMediaURL( sURL, nAction, aPos, aSize, false ) ;
|
|
|
|
|
|
|
|
if( mpWindow )
|
|
|
|
mpWindow->LeaveWait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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: */
|