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

Generated by: LCOV version 1.10