1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sc.hxx" 30 31 32 33 // INCLUDE --------------------------------------------------------------- 34 35 //#define SI_VCDRAWOBJ 36 37 #include <tools/urlobj.hxx> 38 #include <svx/fmglob.hxx> 39 #include <svx/svdouno.hxx> 40 #include <svx/svdpagv.hxx> 41 #include <sfx2/objsh.hxx> 42 #include <sfx2/docfile.hxx> 43 44 #include <com/sun/star/form/FormButtonType.hpp> 45 #include <com/sun/star/beans/XPropertySet.hpp> 46 #include <com/sun/star/awt/XControlModel.hpp> 47 48 using namespace com::sun::star; 49 50 #include "tabvwsh.hxx" 51 #include "document.hxx" 52 #include "drawview.hxx" 53 #include "globstr.hrc" 54 #include <avmedia/mediawindow.hxx> 55 56 //------------------------------------------------------------------------ 57 58 void ScTabViewShell::InsertURLButton( const String& rName, const String& rURL, 59 const String& rTarget, 60 const Point* pInsPos ) 61 { 62 // Tabelle geschuetzt ? 63 64 ScViewData* pViewData = GetViewData(); 65 ScDocument* pDoc = pViewData->GetDocument(); 66 SCTAB nTab = pViewData->GetTabNo(); 67 if ( pDoc->IsTabProtected(nTab) ) 68 { 69 ErrorMessage(STR_PROTECTIONERR); 70 return; 71 } 72 73 MakeDrawLayer(); 74 75 ScTabView* pView = pViewData->GetView(); 76 // SdrView* pDrView = pView->GetSdrView(); 77 ScDrawView* pDrView = pView->GetScDrawView(); 78 SdrModel* pModel = pDrView->GetModel(); 79 80 SdrObject* pObj = SdrObjFactory::MakeNewObject(FmFormInventor, OBJ_FM_BUTTON, 81 pDrView->GetSdrPageView()->GetPage(), pModel); 82 SdrUnoObj* pUnoCtrl = PTR_CAST(SdrUnoObj, pObj); 83 84 uno::Reference<awt::XControlModel> xControlModel = pUnoCtrl->GetUnoControlModel(); 85 DBG_ASSERT( xControlModel.is(), "UNO-Control ohne Model" ); 86 if( !xControlModel.is() ) 87 return; 88 89 uno::Reference< beans::XPropertySet > xPropSet( xControlModel, uno::UNO_QUERY ); 90 uno::Any aAny; 91 92 aAny <<= rtl::OUString(rName); 93 xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "Label" ), aAny ); 94 95 ::rtl::OUString aTmp = INetURLObject::GetAbsURL( pDoc->GetDocumentShell()->GetMedium()->GetBaseURL(), rURL ); 96 aAny <<= aTmp; 97 xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetURL" ), aAny ); 98 99 if( rTarget.Len() ) 100 { 101 aAny <<= rtl::OUString(rTarget); 102 xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "TargetFrame" ), aAny ); 103 } 104 105 form::FormButtonType eButtonType = form::FormButtonType_URL; 106 aAny <<= eButtonType; 107 xPropSet->setPropertyValue( rtl::OUString::createFromAscii( "ButtonType" ), aAny ); 108 109 if ( ::avmedia::MediaWindow::isMediaURL( rURL ) ) 110 { 111 // #105638# OJ 112 aAny <<= sal_True; 113 xPropSet->setPropertyValue( rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DispatchURLInternal" )), aAny ); 114 } 115 116 Point aPos; 117 if (pInsPos) 118 aPos = *pInsPos; 119 else 120 aPos = GetInsertPos(); 121 122 // Groesse wie in 3.1: 123 Size aSize = GetActiveWin()->PixelToLogic(Size(140, 20)); 124 125 if ( pDoc->IsNegativePage(nTab) ) 126 aPos.X() -= aSize.Width(); 127 128 pObj->SetLogicRect(Rectangle(aPos, aSize)); 129 // pObj->Resize(Point(), Fraction(1, 1), Fraction(1, 1)); 130 131 // am alten VC-Button musste die Position/Groesse nochmal explizit 132 // gesetzt werden - das scheint mit UnoControls nicht noetig zu sein 133 134 // nicht markieren wenn Ole 135 pDrView->InsertObjectSafe( pObj, *pDrView->GetSdrPageView() ); 136 } 137 138 139 140 141