LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sw/source/ui/shells - grfshex.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 53 1.9 %
Date: 2013-07-09 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 <doc.hxx>
      32             : #include <docsh.hxx>
      33             : #include <frmfmt.hxx>
      34             : #include <frmmgr.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>
      45             : 
      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>
      51             : 
      52             : // -> #111827#
      53             : #include <SwRewriter.hxx>
      54             : #include <comcore.hrc>
      55             : // <- #111827#
      56             : 
      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;
      61             : 
      62           0 : bool SwTextShell::InsertMediaDlg( SfxRequest& rReq )
      63             : {
      64           0 :     OUString     aURL;
      65           0 :     const SfxItemSet*   pReqArgs = rReq.GetArgs();
      66           0 :     Window*             pWindow = &GetView().GetViewFrame()->GetWindow();
      67           0 :     bool                bAPI = false, bRet = false;
      68             : 
      69           0 :     if( pReqArgs )
      70             :     {
      71           0 :         const SfxStringItem* pStringItem = PTR_CAST( SfxStringItem, &pReqArgs->Get( rReq.GetSlot() ) );
      72             : 
      73           0 :         if( pStringItem )
      74             :         {
      75           0 :             aURL = pStringItem->GetValue();
      76           0 :             bAPI = !aURL.isEmpty();
      77             :         }
      78             :     }
      79             : 
      80           0 :     bool bLink(true);
      81           0 :     if (bAPI ||
      82           0 :         ::avmedia::MediaWindow::executeMediaURLDialog(pWindow, aURL, & bLink))
      83             :     {
      84           0 :         Size aPrefSize;
      85             : 
      86           0 :         if( pWindow )
      87           0 :             pWindow->EnterWait();
      88             : 
      89           0 :         if( !::avmedia::MediaWindow::isMediaURL( aURL, true, &aPrefSize ) )
      90             :         {
      91           0 :             if( pWindow )
      92           0 :                 pWindow->LeaveWait();
      93             : 
      94           0 :             if( !bAPI )
      95           0 :                 ::avmedia::MediaWindow::executeFormatErrorBox( pWindow );
      96             :         }
      97             :         else
      98             :         {
      99           0 :             SwWrtShell& rSh = GetShell();
     100             : 
     101           0 :             if( !rSh.HasDrawView() )
     102           0 :                 rSh.MakeDrawView();
     103             : 
     104           0 :             Size            aDocSz( rSh.GetDocSize() );
     105           0 :                const SwRect&    rVisArea = rSh.VisArea();
     106           0 :             Point           aPos( rVisArea.Center() );
     107           0 :             Size            aSize;
     108             : 
     109           0 :             if( rVisArea.Width() > aDocSz.Width())
     110           0 :                 aPos.X() = aDocSz.Width() / 2 + rVisArea.Left();
     111             : 
     112           0 :             if(rVisArea.Height() > aDocSz.Height())
     113           0 :                 aPos.Y() = aDocSz.Height() / 2 + rVisArea.Top();
     114             : 
     115           0 :             if( aPrefSize.Width() && aPrefSize.Height() )
     116             :             {
     117           0 :                 if( pWindow )
     118           0 :                     aSize = pWindow->PixelToLogic( aPrefSize, MAP_TWIP );
     119             :                 else
     120           0 :                     aSize = Application::GetDefaultDevice()->PixelToLogic( aPrefSize, MAP_TWIP );
     121             :             }
     122             :             else
     123           0 :                 aSize = Size( 2835, 2835 );
     124             : 
     125           0 :             OUString realURL;
     126           0 :             if (bLink)
     127             :             {
     128           0 :                 realURL = aURL;
     129             :             }
     130             :             else
     131             :             {
     132             :                 uno::Reference<frame::XModel> const xModel(
     133           0 :                         rSh.GetDoc()->GetDocShell()->GetModel());
     134           0 :                 bRet = ::avmedia::EmbedMedia(xModel, aURL, realURL);
     135           0 :                 if (!bRet) { return bRet; }
     136             :             }
     137             : 
     138           0 :             SdrMediaObj* pObj = new SdrMediaObj( Rectangle( aPos, aSize ) );
     139             : 
     140           0 :             pObj->SetModel(rSh.GetDoc()->GetDrawModel()); // set before setURL
     141           0 :             pObj->setURL( realURL );
     142           0 :             rSh.EnterStdMode();
     143           0 :             rSh.SwFEShell::InsertDrawObj( *pObj, aPos );
     144           0 :             bRet = true;
     145             : 
     146           0 :             if( pWindow )
     147           0 :                 pWindow->LeaveWait();
     148             :         }
     149             :     }
     150             : 
     151           0 :     return bRet;
     152          99 : }
     153             : 
     154             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10