2001-07-17 07:43:35 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-10 20:25:24 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2008-04-10 20:25:24 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2008-04-10 20:25:24 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2008-04-10 20:25:24 +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.
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2008-04-10 20:25:24 +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).
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
2008-04-10 20:25:24 +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.
|
2001-07-17 07:43:35 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-16 22:15:24 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_sw.hxx"
|
|
|
|
|
2001-07-17 07:43:35 +00:00
|
|
|
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <grfsh.hxx>
|
|
|
|
#include <wrtsh.hxx>
|
|
|
|
#include <view.hxx>
|
|
|
|
#include <docary.hxx>
|
|
|
|
#include <textsh.hxx>
|
|
|
|
#include <viewopt.hxx>
|
|
|
|
#include <swundo.hxx>
|
|
|
|
#include <shells.hrc>
|
|
|
|
#include <caption.hxx>
|
|
|
|
#define _SVSTDARR_STRINGSSORTDTOR
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/svstdarr.hxx>
|
2001-07-17 07:43:35 +00:00
|
|
|
#include <svtools/filter.hxx>
|
|
|
|
#include <svx/htmlmode.hxx>
|
|
|
|
#include <docsh.hxx>
|
|
|
|
#include <frmfmt.hxx>
|
|
|
|
#include <frmmgr.hxx>
|
|
|
|
#include <vcl/msgbox.hxx>
|
2004-08-12 09:15:13 +00:00
|
|
|
#include <svx/svdomedia.hxx>
|
|
|
|
#include <svx/svdview.hxx>
|
|
|
|
#include <svx/svdpagv.hxx>
|
2001-07-20 10:12:36 +00:00
|
|
|
#include <SwStyleNameMapper.hxx>
|
2001-07-17 07:43:35 +00:00
|
|
|
#include <sfx2/filedlghelper.hxx>
|
|
|
|
#include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
|
|
|
|
#include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
|
|
|
|
#include <poolfmt.hrc>
|
|
|
|
|
2002-07-01 08:04:45 +00:00
|
|
|
#include <sfx2/request.hxx>
|
2004-10-04 18:30:18 +00:00
|
|
|
#include <sfx2/viewfrm.hxx>
|
2009-10-16 00:05:16 +02:00
|
|
|
#include <svl/stritem.hxx>
|
2004-08-12 09:15:13 +00:00
|
|
|
#include <avmedia/mediawindow.hxx>
|
2006-11-14 14:20:17 +00:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
|
2004-05-18 13:12:31 +00:00
|
|
|
// -> #111827#
|
|
|
|
#include <SwRewriter.hxx>
|
|
|
|
#include <undobj.hxx>
|
|
|
|
#include <comcore.hrc>
|
|
|
|
// <- #111827#
|
2002-07-01 08:04:45 +00:00
|
|
|
|
2001-07-17 07:43:35 +00:00
|
|
|
using namespace ::com::sun::star::uno;
|
|
|
|
using namespace ::com::sun::star::ui::dialogs;
|
|
|
|
using namespace ::sfx2;
|
2008-03-12 11:54:12 +00:00
|
|
|
using ::rtl::OUString;
|
2001-07-17 07:43:35 +00:00
|
|
|
|
2004-08-12 09:15:13 +00:00
|
|
|
bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
|
|
|
|
{
|
|
|
|
::rtl::OUString aURL;
|
|
|
|
const SfxItemSet* pReqArgs = rReq.GetArgs();
|
|
|
|
Window* pWindow = &GetView().GetViewFrame()->GetWindow();
|
|
|
|
bool bAPI = false, bRet = false;
|
2001-07-17 07:43:35 +00:00
|
|
|
|
2004-08-12 09:15:13 +00:00
|
|
|
if( pReqArgs )
|
|
|
|
{
|
|
|
|
const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
|
|
|
|
|
|
|
|
if( pStringItem )
|
|
|
|
{
|
|
|
|
aURL = pStringItem->GetValue();
|
|
|
|
bAPI = aURL.getLength();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( bAPI || ::avmedia::MediaWindow::executeMediaURLDialog( pWindow, aURL ) )
|
|
|
|
{
|
|
|
|
Size aPrefSize;
|
|
|
|
|
|
|
|
if( pWindow )
|
|
|
|
pWindow->EnterWait();
|
|
|
|
|
|
|
|
if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
|
|
|
|
{
|
|
|
|
if( pWindow )
|
|
|
|
pWindow->LeaveWait();
|
|
|
|
|
|
|
|
if( !bAPI )
|
|
|
|
::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SwWrtShell& rSh = GetShell();
|
|
|
|
|
|
|
|
if( !rSh.HasDrawView() )
|
|
|
|
rSh.MakeDrawView();
|
|
|
|
|
|
|
|
Size aDocSz( rSh.GetDocSize() );
|
|
|
|
const SwRect& rVisArea = rSh.VisArea();
|
|
|
|
Point aPos( rVisArea.Center() );
|
|
|
|
Size aSize;
|
|
|
|
|
|
|
|
if( rVisArea.Width() > aDocSz.Width())
|
|
|
|
aPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
|
|
|
|
|
|
|
|
if(rVisArea.Height() > aDocSz.Height())
|
|
|
|
aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
|
|
|
|
|
|
|
|
if( aPrefSize.Width() && aPrefSize.Height() )
|
|
|
|
{
|
|
|
|
if( pWindow )
|
|
|
|
aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP );
|
|
|
|
else
|
|
|
|
aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
aSize = Size( 2835, 2835 );
|
|
|
|
|
|
|
|
SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
|
|
|
|
|
|
|
|
pObj->setURL( aURL );
|
|
|
|
rSh.EnterStdMode();
|
2009-12-30 15:07:06 +01:00
|
|
|
rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
|
2004-08-12 09:15:13 +00:00
|
|
|
bRet = true;
|
|
|
|
|
|
|
|
if( pWindow )
|
|
|
|
pWindow->LeaveWait();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return bRet;
|
|
|
|
}
|