2000-09-18 16:07:07 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* Copyright 2008 by Sun Microsystems, Inc.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* $RCSfile: fuinsert.cxx,v $
|
|
|
|
* $Revision: 1.48 $
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* OpenOffice.org is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License version 3
|
|
|
|
* only, as published by the Free Software Foundation.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* OpenOffice.org is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License version 3 for more details
|
|
|
|
* (a copy is included in the LICENSE file that accompanied this code).
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
2008-04-10 19:20:15 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* version 3 along with OpenOffice.org. If not, see
|
|
|
|
* <http://www.openoffice.org/license.html>
|
|
|
|
* for a copy of the LGPLv3 License.
|
2000-09-18 16:07:07 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 17:50:47 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sd.hxx"
|
|
|
|
|
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>
|
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>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
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>
|
2000-09-18 16:07:07 +00:00
|
|
|
#include <svx/pfiledlg.hxx>
|
|
|
|
#include <svx/impgrf.hxx>
|
|
|
|
#include <svx/dialogs.hrc>
|
|
|
|
#include <svx/linkmgr.hxx>
|
|
|
|
#include <svx/svdetc.hxx>
|
2004-08-12 08:15:37 +00:00
|
|
|
#include <avmedia/mediawindow.hxx>
|
2000-11-10 15:53:19 +00:00
|
|
|
#ifndef _UNOTOOLS_UCBSTREAMHELPER_HXX
|
|
|
|
#include <unotools/ucbstreamhelper.hxx>
|
|
|
|
#endif
|
2003-06-10 12:57:32 +00:00
|
|
|
#include <sfx2/printer.hxx>
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <sot/clsids.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>
|
2000-09-18 16:07:07 +00:00
|
|
|
#ifndef _EDITENG_HXX //autogen
|
|
|
|
#include <svx/editeng.hxx>
|
|
|
|
#endif
|
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
|
|
|
#ifndef _MSGBOX_HXX //autogen
|
|
|
|
#include <vcl/msgbox.hxx>
|
|
|
|
#endif
|
2001-06-22 16:39:56 +00:00
|
|
|
#include <svx/opengrf.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "app.hrc"
|
|
|
|
#include "misc.hxx"
|
|
|
|
#include "sdresid.hxx"
|
2004-01-20 10:02:54 +00:00
|
|
|
#include "View.hxx"
|
2000-09-18 16:07:07 +00:00
|
|
|
#include "app.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"
|
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 );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* FuInsertGraphic::Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuInsertGraphic::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuInsertGraphic( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
2007-09-06 12:55:56 +00:00
|
|
|
#ifdef _MSC_VER
|
2005-12-14 15:59:08 +00:00
|
|
|
#pragma optimize ( "", off )
|
|
|
|
#endif
|
|
|
|
|
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;
|
2009-12-03 18:53:41 +01:00
|
|
|
SdrObject* pPickObj = mpView->GetEmptyPresentationObject( PRESOBJ_GRAPHIC );
|
|
|
|
if( pPickObj )
|
|
|
|
nAction = DND_ACTION_LINK;
|
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
|
|
|
{
|
2001-06-22 16:39:56 +00:00
|
|
|
// store link only?
|
|
|
|
String aFltName(aDlg.GetCurrentFilter());
|
|
|
|
String aPath(aDlg.GetPath());
|
2000-09-18 16:07:07 +00:00
|
|
|
pGrafObj->SetGraphicLink(aPath, aFltName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2001-06-22 16:39:56 +00:00
|
|
|
else
|
|
|
|
{
|
2006-12-13 16:56:12 +00:00
|
|
|
SdGRFFilter::HandleGraphicFilterError( (USHORT)nError, GetGrfFilter()->GetLastError().nStreamError );
|
2001-06-22 16:39:56 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-06 12:55:56 +00:00
|
|
|
#ifdef _MSC_VER
|
2000-09-18 16:07:07 +00:00
|
|
|
#pragma optimize ( "", on )
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* FuInsertClipboard::Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuInsertClipboard::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuInsertClipboard( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
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 ) );
|
2001-09-04 13:38:20 +00:00
|
|
|
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
|
|
|
const String aEmptyString;
|
|
|
|
::com::sun::star::datatransfer::DataFlavor aFlavor;
|
|
|
|
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_EMBED_SOURCE, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_LINK_SOURCE, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_DRAWING, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_SVXB, aEmptyString );
|
|
|
|
pDlg->Insert( FORMAT_GDIMETAFILE, aEmptyString );
|
|
|
|
pDlg->Insert( FORMAT_BITMAP, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_NETSCAPE_BOOKMARK, aEmptyString );
|
|
|
|
pDlg->Insert( FORMAT_STRING, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_HTML, aEmptyString );
|
|
|
|
pDlg->Insert( FORMAT_RTF, aEmptyString );
|
|
|
|
pDlg->Insert( SOT_FORMATSTR_ID_EDITENGINE, aEmptyString );
|
|
|
|
|
|
|
|
//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() ),
|
2004-10-04 17:32:01 +00:00
|
|
|
nAction, 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
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
|*
|
|
|
|
|* FuInsertOLE::Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuInsertOLE::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuInsertOLE( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
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 );
|
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* Diagramm oder StarCalc-Tabelle einfuegen
|
|
|
|
**********************************************************************/
|
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
::rtl::OUString aObjName;
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
// Rechteck mit ausgewogenem Kantenverhaeltnis
|
|
|
|
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
|
|
|
bool bUndo = false;
|
|
|
|
// 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))
|
|
|
|
{
|
|
|
|
bUndo = mpView->IsUndoEnabled();
|
|
|
|
|
|
|
|
if( bUndo )
|
|
|
|
mpView->BegUndo( SdrUndoNewObj::GetComment(*pOleObj) );
|
|
|
|
|
|
|
|
// add new PresObj to the list
|
|
|
|
pOleObj->SetUserCall(pPickObj->GetUserCall());
|
|
|
|
if( bUndo )
|
|
|
|
{
|
|
|
|
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pPickObj ) );
|
|
|
|
mpView->AddUndo( new sd::UndoObjectPresentationKind( *pOleObj ) );
|
|
|
|
}
|
|
|
|
pPage->ReplacePresObj(pPickObj, pOleObj, ePresObjKind);
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-02-09 18:14:49 +01:00
|
|
|
|
|
|
|
bool bRet = true;
|
|
|
|
if( pPickObj )
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarChart" ) ) );
|
|
|
|
}
|
|
|
|
else if (nSlotId == SID_ATTR_TABLE)
|
|
|
|
{
|
|
|
|
pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarCalc" ) ) );
|
|
|
|
}
|
|
|
|
else if (nSlotId == SID_INSERT_MATH)
|
|
|
|
{
|
|
|
|
pOleObj->SetProgName( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM( "StarMath" ) ) );
|
|
|
|
}
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
//HMHmpView->HideMarkHdl();
|
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.
|
2007-06-11 13:53:54 +00:00
|
|
|
mpViewShell->AdaptDefaultsForChart( xObj );
|
2007-05-22 15:13:37 +00:00
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
2010-02-09 18:14:49 +01:00
|
|
|
|
|
|
|
if( bUndo )
|
|
|
|
{
|
|
|
|
mpView->EndUndo();
|
|
|
|
}
|
|
|
|
else if( pPickObj )
|
|
|
|
{
|
|
|
|
// replaced object must be freed if there is no undo action owning it
|
|
|
|
SdrObject::Free( pPickObj );
|
|
|
|
}
|
2000-09-18 16:07:07 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ErrorHandler::HandleError(* new StringErrorInfo(ERRCODE_SFX_OLEGENERAL,
|
|
|
|
aEmptyStr ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/**********************************************************************
|
|
|
|
* Objekt einfuegen
|
|
|
|
**********************************************************************/
|
2004-10-04 17:32:01 +00:00
|
|
|
sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT;
|
|
|
|
BOOL bCreateNew = FALSE;
|
|
|
|
uno::Reference < embed::XEmbeddedObject > xObj;
|
|
|
|
uno::Reference < embed::XStorage > xStorage = comphelper::OStorageHelper::GetTemporaryStorage();
|
|
|
|
SvObjectServerList aServerLst;
|
|
|
|
::rtl::OUString aName;
|
|
|
|
|
2006-10-13 10:02:27 +00:00
|
|
|
::rtl::OUString aIconMediaType;
|
|
|
|
uno::Reference< io::XInputStream > xIconMetaFile;
|
|
|
|
|
2004-10-04 17:32:01 +00:00
|
|
|
SFX_REQUEST_ARG( rReq, pNameItem, SfxGlobalNameItem, SID_INSERT_OBJECT, sal_False );
|
|
|
|
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_APPLET :
|
|
|
|
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 =
|
2006-12-13 16:56:12 +00:00
|
|
|
pFact->CreateInsertObjectDialog( mpViewShell->GetActiveWindow(), nSlotId,
|
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
|
|
|
|
String 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() )
|
|
|
|
{
|
|
|
|
xSet->setPropertyValue( ::rtl::OUString::createFromAscii("PluginURL"),
|
|
|
|
uno::makeAny( ::rtl::OUString( aURL.GetMainURL( INetURLObject::NO_DECODE ) ) ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// PlugIn konnte nicht erzeugt werden
|
2007-04-26 07:37:55 +00:00
|
|
|
String aStrErr( SdResId( STR_ERROR_OBJNOCREATE_PLUGIN ) );
|
2004-10-04 17:32:01 +00:00
|
|
|
String aMask;
|
|
|
|
aMask += sal_Unicode('%');
|
|
|
|
aStrErr.SearchAndReplace( aMask, 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 ) )
|
|
|
|
// aIPObj->OnDocumentPrinterChanged( mpDocSh->GetPrinter(FALSE) );
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-02-12 12:44:26 +00:00
|
|
|
BOOL bInsertNewObject = 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)
|
|
|
|
{
|
|
|
|
// Rechteck mit ausgewogenem Kantenverhaeltnis
|
|
|
|
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
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
/**********************************************************
|
|
|
|
* Ist ein leeres OLE-Objekt vorhanden?
|
|
|
|
**********************************************************/
|
|
|
|
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
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
/**************************************************
|
|
|
|
* Das leere OLE-Objekt bekommt ein neues IPObj
|
|
|
|
**************************************************/
|
|
|
|
bInsertNewObject = FALSE;
|
|
|
|
pObj->SetEmptyPresObj(FALSE);
|
|
|
|
( (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();
|
|
|
|
|
|
|
|
//HMHmpView->HideMarkHdl();
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
/**************************************************************
|
|
|
|
* Ein neues OLE-Objekt wird erzeugt
|
|
|
|
**************************************************************/
|
|
|
|
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
|
|
|
{
|
2009-02-12 12:44:26 +00:00
|
|
|
// #73279# Math objects change their object size during InsertObject.
|
|
|
|
// 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
|
|
|
//HMHmpView->HideMarkHdl();
|
|
|
|
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::Konstruktor
|
|
|
|
|*
|
|
|
|
\************************************************************************/
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
FunctionReference FuInsertAVMedia::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
FunctionReference xFunc( new FuInsertAVMedia( pViewSh, pWin, pView, pDoc, rReq ) );
|
|
|
|
xFunc->DoExecute(rReq);
|
|
|
|
return xFunc;
|
|
|
|
}
|
|
|
|
|
|
|
|
void FuInsertAVMedia::DoExecute( SfxRequest& rReq )
|
2004-08-12 08:15:37 +00:00
|
|
|
{
|
|
|
|
::rtl::OUString aURL;
|
|
|
|
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();
|
|
|
|
bAPI = aURL.getLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( mpWindow, aURL ) )
|
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
|
|
|
|
|
|
|
if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
|
|
|
|
{
|
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;
|
|
|
|
}
|
|
|
|
|
2006-12-13 16:56:12 +00:00
|
|
|
mpView->InsertMediaURL( aURL, nAction, aPos, aSize ) ;
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-01-20 10:02:54 +00:00
|
|
|
} // end of namespace sd
|