1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
25 #include <viewopt.hxx>
28 #include <caption.hxx>
29 #include <vcl/graphicfilter.hxx>
30 #include <sfx2/htmlmode.hxx>
35 #include <vcl/msgbox.hxx>
36 #include <svx/svdomedia.hxx>
37 #include <svx/svdview.hxx>
38 #include <svx/svdpagv.hxx>
39 #include <SwStyleNameMapper.hxx>
40 #include <sfx2/filedlghelper.hxx>
41 #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
42 #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
43 #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
44 #include <poolfmt.hrc>
46 #include <sfx2/request.hxx>
47 #include <sfx2/viewfrm.hxx>
48 #include <svl/stritem.hxx>
49 #include <avmedia/mediawindow.hxx>
50 #include <vcl/svapp.hxx>
53 #include <SwRewriter.hxx>
54 #include <comcore.hrc>
57 using namespace ::com::sun::star
;
58 using namespace ::com::sun::star::uno
;
59 using namespace ::com::sun::star::ui::dialogs
;
60 using namespace ::sfx2
;
62 bool SwTextShell::InsertMediaDlg( SfxRequest
& rReq
)
65 const SfxItemSet
* pReqArgs
= rReq
.GetArgs();
66 Window
* pWindow
= &GetView().GetViewFrame()->GetWindow();
67 bool bAPI
= false, bRet
= false;
71 const SfxStringItem
* pStringItem
= PTR_CAST( SfxStringItem
, &pReqArgs
->Get( rReq
.GetSlot() ) );
75 aURL
= pStringItem
->GetValue();
76 bAPI
= !aURL
.isEmpty();
82 ::avmedia::MediaWindow::executeMediaURLDialog(pWindow
, aURL
, & bLink
))
89 if( !::avmedia::MediaWindow::isMediaURL( aURL
, true, &aPrefSize
) )
95 ::avmedia::MediaWindow::executeFormatErrorBox( pWindow
);
99 SwWrtShell
& rSh
= GetShell();
101 if( !rSh
.HasDrawView() )
104 Size
aDocSz( rSh
.GetDocSize() );
105 const SwRect
& rVisArea
= rSh
.VisArea();
106 Point
aPos( rVisArea
.Center() );
109 if( rVisArea
.Width() > aDocSz
.Width())
110 aPos
.X() = aDocSz
.Width() / 2 + rVisArea
.Left();
112 if(rVisArea
.Height() > aDocSz
.Height())
113 aPos
.Y() = aDocSz
.Height() / 2 + rVisArea
.Top();
115 if( aPrefSize
.Width() && aPrefSize
.Height() )
118 aSize
= pWindow
->PixelToLogic( aPrefSize
, MAP_TWIP
);
120 aSize
= Application::GetDefaultDevice()->PixelToLogic( aPrefSize
, MAP_TWIP
);
123 aSize
= Size( 2835, 2835 );
132 uno::Reference
<frame::XModel
> const xModel(
133 rSh
.GetDoc()->GetDocShell()->GetModel());
134 bRet
= ::avmedia::EmbedMedia(xModel
, aURL
, realURL
);
135 if (!bRet
) { return bRet
; }
138 SdrMediaObj
* pObj
= new SdrMediaObj( Rectangle( aPos
, aSize
) );
140 pObj
->SetModel(rSh
.GetDoc()->GetDrawModel()); // set before setURL
141 pObj
->setURL( realURL
);
143 rSh
.SwFEShell::InsertDrawObj( *pObj
, aPos
);
147 pWindow
->LeaveWait();
154 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */