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