LCOV - code coverage report
Current view: top level - sw/source/uibase/shells - grfshex.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 1 53 1.9 %
Date: 2015-06-13 12:38:46 Functions: 2 3 66.7 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       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/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      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 .
      18             :  */
      19             : 
      20             : #include <docary.hxx>
      21             : #include <grfsh.hxx>
      22             : #include <wrtsh.hxx>
      23             : #include <view.hxx>
      24             : #include <textsh.hxx>
      25             : #include <viewopt.hxx>
      26             : #include <swundo.hxx>
      27             : #include <shells.hrc>
      28             : #include <caption.hxx>
      29             : #include <vcl/graphicfilter.hxx>
      30             : #include <sfx2/htmlmode.hxx>
      31             : #include <drawdoc.hxx>
      32             : #include <doc.hxx>
      33             : #include <IDocumentDrawModelAccess.hxx>
      34             : #include <docsh.hxx>
      35             : #include <frmfmt.hxx>
      36             : #include <frmmgr.hxx>
      37             : #include <vcl/msgbox.hxx>
      38             : #include <svx/svdomedia.hxx>
      39             : #include <svx/svdview.hxx>
      40             : #include <svx/svdpagv.hxx>
      41             : #include <SwStyleNameMapper.hxx>
      42             : #include <sfx2/filedlghelper.hxx>
      43             : #include <com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp>
      44             : #include <com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp>
      45             : #include <com/sun/star/ui/dialogs/ListboxControlActions.hpp>
      46             : #include <poolfmt.hrc>
      47             : 
      48             : #include <sfx2/request.hxx>
      49             : #include <sfx2/viewfrm.hxx>
      50             : #include <svl/stritem.hxx>
      51             : #include <avmedia/mediawindow.hxx>
      52             : #include <vcl/svapp.hxx>
      53             : 
      54             : // -> #111827#
      55             : #include <SwRewriter.hxx>
      56             : #include <comcore.hrc>
      57             : // <- #111827#
      58             : 
      59             : using namespace ::com::sun::star;
      60             : using namespace ::com::sun::star::uno;
      61             : using namespace ::com::sun::star::ui::dialogs;
      62             : using namespace ::sfx2;
      63             : 
      64           0 : bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
      65             : {
      66           0 :     OUString     aURL;
      67           0 :     const SfxItemSet*   pReqArgs = rReq.GetArgs();
      68           0 :     vcl::Window*             pWindow = &GetView().GetViewFrame()->GetWindow();
      69           0 :     bool                bAPI = false, bRet = false;
      70             : 
      71           0 :     if( pReqArgs )
      72             :     {
      73           0 :         const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
      74             : 
      75           0 :         if( pStringItem )
      76             :         {
      77           0 :             aURL = pStringItem->GetValue();
      78           0 :             bAPI = !aURL.isEmpty();
      79             :         }
      80             :     }
      81             : 
      82           0 :     bool bLink(true);
      83           0 :     if (bAPI ||
      84           0 :         ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
      85             :     {
      86           0 :         Size aPrefSize;
      87             : 
      88           0 :         if( pWindow )
      89           0 :             pWindow->EnterWait();
      90             : 
      91           0 :         if( !::avmedia::MediaWindow::isMediaURL( aURL, "", true, &aPrefSize ) )
      92             :         {
      93           0 :             if( pWindow )
      94           0 :                 pWindow->LeaveWait();
      95             : 
      96           0 :             if( !bAPI )
      97           0 :                 ::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
      98             :         }
      99             :         else
     100             :         {
     101           0 :             SwWrtShell& rSh = GetShell();
     102             : 
     103           0 :             if( !rSh.HasDrawView() )
     104           0 :                 rSh.MakeDrawView();
     105             : 
     106           0 :             Size            aDocSz( rSh.GetDocSize() );
     107           0 :                const SwRect&    rVisArea = rSh.VisArea();
     108           0 :             Point           aPos( rVisArea.Center() );
     109           0 :             Size            aSize;
     110             : 
     111           0 :             if( rVisArea.Width() > aDocSz.Width())
     112           0 :                 aPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
     113             : 
     114           0 :             if(rVisArea.Height() > aDocSz.Height())
     115           0 :                 aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
     116             : 
     117           0 :             if( aPrefSize.Width() && aPrefSize.Height() )
     118             :             {
     119           0 :                 if( pWindow )
     120           0 :                     aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP );
     121             :                 else
     122           0 :                     aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
     123             :             }
     124             :             else
     125           0 :                 aSize = Size( 2835, 2835 );
     126             : 
     127           0 :             OUString realURL;
     128           0 :             if (bLink)
     129             :             {
     130           0 :                 realURL = aURL;
     131             :             }
     132             :             else
     133             :             {
     134             :                 uno::Reference<frame::XModel> const xModel(
     135           0 :                         rSh.GetDoc()->GetDocShell()->GetModel());
     136           0 :                 bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
     137           0 :                 if (!bRet) { return bRet; }
     138             :             }
     139             : 
     140           0 :             SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
     141             : 
     142           0 :             pObj->SetModel(rSh.GetDoc()->getIDocumentDrawModelAccess().GetDrawModel()); // set before setURL
     143           0 :             pObj->setURL( realURL, "" );
     144           0 :             rSh.EnterStdMode();
     145           0 :             rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
     146           0 :             bRet = true;
     147             : 
     148           0 :             if( pWindow )
     149           0 :                 pWindow->LeaveWait();
     150             :         }
     151             :     }
     152             : 
     153           0 :     return bRet;
     154         177 : }
     155             : 
     156             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11