LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - textdrw.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 47 0.0 %
Date: 2014-04-14 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 <svx/svdview.hxx>
      21             : #include <tools/urlobj.hxx>
      22             : #include <svx/fmglob.hxx>
      23             : #include <svx/svdouno.hxx>
      24             : #include <com/sun/star/form/FormButtonType.hpp>
      25             : #include <com/sun/star/beans/XPropertySet.hpp>
      26             : 
      27             : #include <view.hxx>
      28             : #include <wrtsh.hxx>
      29             : #include <edtwin.hxx>
      30             : #include <swundo.hxx>
      31             : #include <basesh.hxx>
      32             : 
      33             : #include <poolfmt.hrc>
      34             : 
      35             : #include <docsh.hxx>
      36             : #include <sfx2/docfile.hxx>
      37             : #include <svl/urihelper.hxx>
      38             : #include <avmedia/mediawindow.hxx>
      39             : 
      40             : #include <unomid.h>
      41             : 
      42             : using namespace ::com::sun::star;
      43             : 
      44           0 : void SwBaseShell::InsertURLButton(const OUString& rURL, const OUString& rTarget, const OUString& rTxt)
      45             : {
      46           0 :     SwWrtShell& rSh = GetShell();
      47             : 
      48           0 :     if (!rSh.HasDrawView())
      49           0 :         rSh.MakeDrawView();
      50           0 :     SdrView *pSdrView = rSh.GetDrawView();
      51             : 
      52             :     // OBJ_FM_BUTTON
      53           0 :     pSdrView->SetDesignMode(true);
      54           0 :     pSdrView->SetCurrentObj(OBJ_FM_BUTTON);
      55           0 :     pSdrView->SetEditMode(false);
      56             : 
      57           0 :     Point aStartPos(rSh.GetCharRect().Pos() + Point(0, 1));
      58             : 
      59           0 :     rSh.StartAction();
      60           0 :     rSh.StartUndo( UNDO_UI_INSERT_URLBTN );
      61           0 :     if (rSh.BeginCreate(OBJ_FM_BUTTON, FmFormInventor, aStartPos))
      62             :     {
      63           0 :         pSdrView->SetOrtho(false);
      64           0 :          Size aSz(GetView().GetEditWin().PixelToLogic(Size(140, 20)));
      65           0 :         Point aEndPos(aSz.Width(), aSz.Height());
      66             : 
      67           0 :         rSh.MoveCreate(aStartPos + aEndPos);
      68           0 :         rSh.EndCreate(SDRCREATE_FORCEEND);
      69             : 
      70           0 :         const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList();
      71           0 :         if (rMarkList.GetMark(0))
      72             :         {
      73           0 :             SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj());
      74           0 :             uno::Reference< awt::XControlModel >  xControlModel = pUnoCtrl->GetUnoControlModel();
      75             : 
      76             :             OSL_ENSURE( xControlModel.is(), "UNO-Control without Model" );
      77           0 :             if( !xControlModel.is() )
      78           0 :                 return;
      79             : 
      80           0 :             uno::Reference< beans::XPropertySet >  xPropSet(xControlModel, uno::UNO_QUERY);
      81             : 
      82           0 :             uno::Any aTmp;
      83             : 
      84           0 :             aTmp <<= OUString(rTxt);
      85           0 :             xPropSet->setPropertyValue( "Label", aTmp );
      86             : 
      87           0 :             SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium();
      88           0 :             INetURLObject aAbs;
      89           0 :             if( pMedium )
      90           0 :                 aAbs = pMedium->GetURLObject();
      91             : 
      92           0 :             aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rURL));
      93           0 :             xPropSet->setPropertyValue( "TargetURL", aTmp );
      94             : 
      95           0 :             if( !rTarget.isEmpty() )
      96             :             {
      97           0 :                 aTmp <<= rTarget;
      98           0 :                 xPropSet->setPropertyValue( "TargetFrame", aTmp );
      99             :             }
     100             : 
     101           0 :             form::FormButtonType eButtonType = form::FormButtonType_URL;
     102           0 :             aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0));
     103           0 :             xPropSet->setPropertyValue( "ButtonType", aTmp );
     104             : 
     105           0 :             if ( ::avmedia::MediaWindow::isMediaURL( rURL, ""/*TODO?*/ ) )
     106             :             {
     107             :                 // #105638# OJ
     108           0 :                 aTmp <<= sal_True;
     109           0 :                 xPropSet->setPropertyValue("DispatchURLInternal", aTmp );
     110           0 :             }
     111             :         }
     112             : 
     113           0 :         if (rSh.IsObjSelected())
     114             :         {
     115           0 :             rSh.UnSelectFrm();
     116             :         }
     117             :     }
     118           0 :     rSh.EndUndo( UNDO_UI_INSERT_URLBTN );
     119           0 :     rSh.EndAction();
     120             : }
     121             : 
     122             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10