1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: grfshex.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
47 #include <viewopt.hxx>
52 #include <caption.hxx>
53 #define _SVSTDARR_STRINGSSORTDTOR
54 #include <svtools/svstdarr.hxx>
55 #include <svtools/filter.hxx>
56 #include <svx/impgrf.hxx>
57 #include <svx/htmlmode.hxx>
63 #include <vcl/msgbox.hxx>
64 #ifndef _SVX_SVDOMEDIA_HXX
65 #include <svx/svdomedia.hxx>
67 #ifndef _SVX_SVDVIEW_HXX
68 #include <svx/svdview.hxx>
70 #ifndef _SVX_SVDPAGV_HXX
71 #include <svx/svdpagv.hxx>
73 #include <SwStyleNameMapper.hxx>
74 #include <sfx2/filedlghelper.hxx>
75 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
76 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
77 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
79 #include <poolfmt.hrc>
82 #include <sfx2/request.hxx>
83 #include <sfx2/viewfrm.hxx>
84 #include <svtools/stritem.hxx>
85 #include <avmedia/mediawindow.hxx>
86 #include <vcl/svapp.hxx>
89 #include <SwRewriter.hxx>
91 #include <comcore.hrc>
94 using namespace ::com::sun::star::uno
;
95 using namespace ::com::sun::star::ui::dialogs
;
96 using namespace ::sfx2
;
97 using ::rtl::OUString
;
99 bool SwTextShell::InsertMediaDlg( SfxRequest
& rReq
)
101 ::rtl::OUString aURL
;
102 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
103 Window
* pWindow
= &GetView().GetViewFrame()->GetWindow();
104 bool bAPI
= false, bRet
= false;
108 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, &pReqArgs
->Get( rReq
.GetSlot() ) );
112 aURL
= pStringItem
->GetValue();
113 bAPI
= aURL
.getLength();
117 if( bAPI
|| ::avmedia::MediaWindow::executeMediaURLDialog( pWindow
, aURL
) )
122 pWindow
->EnterWait();
124 if( !::avmedia::MediaWindow::isMediaURL( aURL
, true, &aPrefSize
) )
127 pWindow
->LeaveWait();
130 ::avmedia::MediaWindow::executeFormatErrorBox( pWindow
);
134 SwWrtShell
& rSh
= GetShell();
136 if( !rSh
.HasDrawView() )
139 Size
aDocSz( rSh
.GetDocSize() );
140 const SwRect
& rVisArea
= rSh
.VisArea();
141 Point
aPos( rVisArea
.Center() );
144 if( rVisArea
.Width() > aDocSz
.Width())
145 aPos
.X() = aDocSz
.Width() / 2 + rVisArea
.Left();
147 if(rVisArea
.Height() > aDocSz
.Height())
148 aPos
.Y() = aDocSz
.Height() / 2 + rVisArea
.Top();
150 if( aPrefSize
.Width() && aPrefSize
.Height() )
153 aSize
= pWindow
->PixelToLogic( aPrefSize
, MAP_TWIP
);
155 aSize
= Application::GetDefaultDevice()->PixelToLogic( aPrefSize
, MAP_TWIP
);
158 aSize
= Size( 2835, 2835 );
160 SdrMediaObj
* pObj
= new SdrMediaObj( Rectangle( aPos
, aSize
) );
162 pObj
->setURL( aURL
);
164 rSh
.SwFEShell::Insert( *pObj
, 0, 0, &aPos
);
168 pWindow
->LeaveWait();