1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <svx/svdview.hxx> 29cdf0e10cSrcweir #include <tools/urlobj.hxx> 30cdf0e10cSrcweir #include <svx/fmglob.hxx> 31cdf0e10cSrcweir #include <svx/svdouno.hxx> 32cdf0e10cSrcweir #include <com/sun/star/form/FormButtonType.hpp> 33cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include <view.hxx> 36cdf0e10cSrcweir #include <wrtsh.hxx> 37cdf0e10cSrcweir #include <edtwin.hxx> 38cdf0e10cSrcweir #include <swundo.hxx> 39cdf0e10cSrcweir #include <basesh.hxx> 40cdf0e10cSrcweir 41cdf0e10cSrcweir #ifndef _POOLFMT_HRC 42cdf0e10cSrcweir #include <poolfmt.hrc> 43cdf0e10cSrcweir #endif 44cdf0e10cSrcweir 45cdf0e10cSrcweir #include <docsh.hxx> 46cdf0e10cSrcweir #include <sfx2/docfile.hxx> 47cdf0e10cSrcweir #include <svl/urihelper.hxx> 48cdf0e10cSrcweir #include <avmedia/mediawindow.hxx> 49cdf0e10cSrcweir 50cdf0e10cSrcweir #include <unomid.h> 51cdf0e10cSrcweir 52cdf0e10cSrcweir 53cdf0e10cSrcweir using namespace ::com::sun::star; 54cdf0e10cSrcweir using ::rtl::OUString; 55cdf0e10cSrcweir /*--------------------------------------------------------------------------- 56cdf0e10cSrcweir Beschreibung: 57cdf0e10cSrcweir ----------------------------------------------------------------------------*/ 58cdf0e10cSrcweir 59cdf0e10cSrcweir void SwBaseShell::InsertURLButton(const String& rURL, const String& rTarget, const String& rTxt) 60cdf0e10cSrcweir { 61cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 62cdf0e10cSrcweir 63cdf0e10cSrcweir if (!rSh.HasDrawView()) 64cdf0e10cSrcweir rSh.MakeDrawView(); 65cdf0e10cSrcweir SdrView *pSdrView = rSh.GetDrawView(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir // OBJ_FM_BUTTON 68cdf0e10cSrcweir pSdrView->SetDesignMode(sal_True); 69cdf0e10cSrcweir pSdrView->SetCurrentObj(OBJ_FM_BUTTON); 70cdf0e10cSrcweir pSdrView->SetEditMode(sal_False); 71cdf0e10cSrcweir 72cdf0e10cSrcweir Point aStartPos(rSh.GetCharRect().Pos() + Point(0, 1)); 73cdf0e10cSrcweir 74cdf0e10cSrcweir rSh.StartAction(); 75cdf0e10cSrcweir rSh.StartUndo( UNDO_UI_INSERT_URLBTN ); 76cdf0e10cSrcweir if (rSh.BeginCreate(OBJ_FM_BUTTON, FmFormInventor, aStartPos)) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir pSdrView->SetOrtho(sal_False); 79cdf0e10cSrcweir Size aSz(GetView().GetEditWin().PixelToLogic(Size(140, 20))); 80cdf0e10cSrcweir Point aEndPos(aSz.Width(), aSz.Height()); 81cdf0e10cSrcweir 82cdf0e10cSrcweir rSh.MoveCreate(aStartPos + aEndPos); 83cdf0e10cSrcweir rSh.EndCreate(SDRCREATE_FORCEEND); 84cdf0e10cSrcweir 85cdf0e10cSrcweir const SdrMarkList& rMarkList = pSdrView->GetMarkedObjectList(); 86cdf0e10cSrcweir if (rMarkList.GetMark(0)) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, rMarkList.GetMark(0)->GetMarkedSdrObj()); 89cdf0e10cSrcweir uno::Reference< awt::XControlModel > xControlModel = pUnoCtrl->GetUnoControlModel(); 90cdf0e10cSrcweir 91cdf0e10cSrcweir ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); 92cdf0e10cSrcweir if( !xControlModel.is() ) 93cdf0e10cSrcweir return; 94cdf0e10cSrcweir 95cdf0e10cSrcweir uno::Reference< beans::XPropertySet > xPropSet(xControlModel, uno::UNO_QUERY); 96cdf0e10cSrcweir 97cdf0e10cSrcweir 98cdf0e10cSrcweir uno::Any aTmp; 99cdf0e10cSrcweir 100cdf0e10cSrcweir aTmp <<= OUString(rTxt); 101cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("Label"), aTmp ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir SfxMedium* pMedium = rSh.GetView().GetDocShell()->GetMedium(); 104cdf0e10cSrcweir INetURLObject aAbs; 105cdf0e10cSrcweir if( pMedium ) 106cdf0e10cSrcweir aAbs = pMedium->GetURLObject(); 107cdf0e10cSrcweir 108cdf0e10cSrcweir aTmp <<= OUString(URIHelper::SmartRel2Abs(aAbs, rURL)); 109cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("TargetURL"), aTmp ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir if( rTarget.Len() ) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir aTmp <<= OUString(rTarget); 114cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("TargetFrame"), aTmp ); 115cdf0e10cSrcweir } 116cdf0e10cSrcweir 117cdf0e10cSrcweir 118cdf0e10cSrcweir form::FormButtonType eButtonType = form::FormButtonType_URL; 119cdf0e10cSrcweir aTmp.setValue( &eButtonType, ::getCppuType((const form::FormButtonType*)0)); 120cdf0e10cSrcweir xPropSet->setPropertyValue( C2U("ButtonType"), aTmp ); 121cdf0e10cSrcweir 122cdf0e10cSrcweir if ( ::avmedia::MediaWindow::isMediaURL( rURL ) ) 123cdf0e10cSrcweir { 124cdf0e10cSrcweir // #105638# OJ 125cdf0e10cSrcweir aTmp <<= sal_True; 126cdf0e10cSrcweir xPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), aTmp ); 127cdf0e10cSrcweir } 128cdf0e10cSrcweir } 129cdf0e10cSrcweir 130cdf0e10cSrcweir if (rSh.IsObjSelected()) 131cdf0e10cSrcweir { 132cdf0e10cSrcweir rSh.UnSelectFrm(); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir } 135cdf0e10cSrcweir rSh.EndUndo( UNDO_UI_INSERT_URLBTN ); 136cdf0e10cSrcweir rSh.EndAction(); 137cdf0e10cSrcweir } 138cdf0e10cSrcweir 139cdf0e10cSrcweir 140