Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <docary.hxx>
30 : : #include <grfsh.hxx>
31 : : #include <wrtsh.hxx>
32 : : #include <view.hxx>
33 : : #include <textsh.hxx>
34 : : #include <viewopt.hxx>
35 : : #include <swundo.hxx>
36 : : #include <shells.hrc>
37 : : #include <caption.hxx>
38 : : #include <svtools/filter.hxx>
39 : : #include <svx/htmlmode.hxx>
40 : : #include <doc.hxx>
41 : : #include <docsh.hxx>
42 : : #include <frmfmt.hxx>
43 : : #include <frmmgr.hxx>
44 : : #include <vcl/msgbox.hxx>
45 : : #include <svx/svdomedia.hxx>
46 : : #include <svx/svdview.hxx>
47 : : #include <svx/svdpagv.hxx>
48 : : #include <SwStyleNameMapper.hxx>
49 : : #include <sfx2/filedlghelper.hxx>
50 : : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
51 : : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
52 : : #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
53 : : #include <poolfmt.hrc>
54 : :
55 : : #include <sfx2/request.hxx>
56 : : #include <sfx2/viewfrm.hxx>
57 : : #include <svl/stritem.hxx>
58 : : #include <avmedia/mediawindow.hxx>
59 : : #include <vcl/svapp.hxx>
60 : :
61 : : // -> #111827#
62 : : #include <SwRewriter.hxx>
63 : : #include <comcore.hrc>
64 : : // <- #111827#
65 : :
66 : : using namespace ::com::sun::star;
67 : : using namespace ::com::sun::star::uno;
68 : : using namespace ::com::sun::star::ui::dialogs;
69 : : using namespace ::sfx2;
70 : : using ::rtl::OUString;
71 : :
72 : 0 : bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
73 : : {
74 : 0 : ::rtl::OUString aURL;
75 : 0 : const SfxItemSet* pReqArgs = rReq.GetArgs();
76 [ # # ]: 0 : Window* pWindow = &GetView().GetViewFrame()->GetWindow();
77 : 0 : bool bAPI = false, bRet = false;
78 : :
79 [ # # ]: 0 : if( pReqArgs )
80 : : {
81 [ # # ][ # # ]: 0 : const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ]
82 : :
83 [ # # ]: 0 : if( pStringItem )
84 : : {
85 [ # # ]: 0 : aURL = pStringItem->GetValue();
86 : 0 : bAPI = !aURL.isEmpty();
87 : : }
88 : : }
89 : :
90 : 0 : bool bLink(true);
91 [ # # ][ # # ]: 0 : if (bAPI ||
[ # # ]
92 [ # # ]: 0 : ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
93 : : {
94 : 0 : Size aPrefSize;
95 : :
96 [ # # ]: 0 : if( pWindow )
97 [ # # ]: 0 : pWindow->EnterWait();
98 : :
99 [ # # ][ # # ]: 0 : if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
100 : : {
101 [ # # ]: 0 : if( pWindow )
102 [ # # ]: 0 : pWindow->LeaveWait();
103 : :
104 [ # # ]: 0 : if( !bAPI )
105 [ # # ]: 0 : ::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
106 : : }
107 : : else
108 : : {
109 [ # # ]: 0 : SwWrtShell& rSh = GetShell();
110 : :
111 [ # # ][ # # ]: 0 : if( !rSh.HasDrawView() )
112 [ # # ]: 0 : rSh.MakeDrawView();
113 : :
114 [ # # ]: 0 : Size aDocSz( rSh.GetDocSize() );
115 : 0 : const SwRect& rVisArea = rSh.VisArea();
116 [ # # ]: 0 : Point aPos( rVisArea.Center() );
117 : 0 : Size aSize;
118 : :
119 [ # # ]: 0 : if( rVisArea.Width() > aDocSz.Width())
120 : 0 : aPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
121 : :
122 [ # # ]: 0 : if(rVisArea.Height() > aDocSz.Height())
123 : 0 : aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
124 : :
125 [ # # ][ # # ]: 0 : if( aPrefSize.Width() && aPrefSize.Height() )
[ # # ]
126 : : {
127 [ # # ]: 0 : if( pWindow )
128 [ # # ][ # # ]: 0 : aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP );
[ # # ]
129 : : else
130 [ # # ][ # # ]: 0 : aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
[ # # ][ # # ]
131 : : }
132 : : else
133 : 0 : aSize = Size( 2835, 2835 );
134 : :
135 : 0 : ::rtl::OUString realURL;
136 [ # # ]: 0 : if (bLink)
137 : : {
138 : 0 : realURL = aURL;
139 : : }
140 : : else
141 : : {
142 : : uno::Reference<frame::XModel> const xModel(
143 [ # # ]: 0 : rSh.GetDoc()->GetDocShell()->GetModel());
144 [ # # ]: 0 : bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
145 [ # # ][ # # ]: 0 : if (!bRet) { return bRet; }
146 : : }
147 : :
148 [ # # ][ # # ]: 0 : SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
[ # # ]
149 : :
150 [ # # ][ # # ]: 0 : pObj->SetModel(rSh.GetDoc()->GetDrawModel()); // set before setURL
151 [ # # ]: 0 : pObj->setURL( realURL );
152 [ # # ]: 0 : rSh.EnterStdMode();
153 [ # # ]: 0 : rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
154 : 0 : bRet = true;
155 : :
156 [ # # ]: 0 : if( pWindow )
157 [ # # ][ # # ]: 0 : pWindow->LeaveWait();
158 : : }
159 : : }
160 : :
161 : 0 : return bRet;
162 : : }
163 : :
164 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|