xref: /trunk/main/sfx2/source/bastyp/frmhtml.cxx (revision cdf0e10c)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include <tools/list.hxx>
32*cdf0e10cSrcweir #include <tools/table.hxx>
33*cdf0e10cSrcweir #include <svtools/htmltokn.h>
34*cdf0e10cSrcweir #include <svtools/asynclink.hxx>
35*cdf0e10cSrcweir 
36*cdf0e10cSrcweir #define _SVSTDARR_USHORTS
37*cdf0e10cSrcweir #define _SVSTDARR_ULONGS
38*cdf0e10cSrcweir #include <svl/svstdarr.hxx>
39*cdf0e10cSrcweir 
40*cdf0e10cSrcweir #include <sfx2/sfx.hrc>
41*cdf0e10cSrcweir 
42*cdf0e10cSrcweir #include <sfx2/frmhtml.hxx>
43*cdf0e10cSrcweir #include <sfx2/docfile.hxx>
44*cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
45*cdf0e10cSrcweir #include <sfx2/evntconf.hxx>
46*cdf0e10cSrcweir #include <sfx2/request.hxx>
47*cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
48*cdf0e10cSrcweir #include "sfxtypes.hxx"
49*cdf0e10cSrcweir 
50*cdf0e10cSrcweir #define SFX_HTMLFRMSIZE_REL 0x0001
51*cdf0e10cSrcweir #define SFX_HTMLFRMSIZE_PERCENT 0x0002
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_yes[] =	"YES";
54*cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_no[] =		"NO";
55*cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_auto[] =	"AUTO";
56*cdf0e10cSrcweir 
57*cdf0e10cSrcweir #define HTML_O_READONLY "READONLY"
58*cdf0e10cSrcweir #define HTML_O_EDIT 	"EDIT"
59*cdf0e10cSrcweir 
60*cdf0e10cSrcweir static HTMLOptionEnum __READONLY_DATA aScollingTable[] =
61*cdf0e10cSrcweir {
62*cdf0e10cSrcweir 	{ sHTML_SC_yes,		ScrollingYes	},
63*cdf0e10cSrcweir 	{ sHTML_SC_no,		ScrollingNo	  	},
64*cdf0e10cSrcweir 	{ sHTML_SC_auto,   	ScrollingAuto	},
65*cdf0e10cSrcweir 	{ 0,				0				}
66*cdf0e10cSrcweir };
67*cdf0e10cSrcweir 
68*cdf0e10cSrcweir void SfxFrameHTMLParser::ParseFrameOptions( SfxFrameDescriptor *pFrame, const HTMLOptions *pOptions, const String& rBaseURL )
69*cdf0e10cSrcweir {
70*cdf0e10cSrcweir 	// die Optionen holen und setzen
71*cdf0e10cSrcweir 	Size aMargin( pFrame->GetMargin() );
72*cdf0e10cSrcweir 
73*cdf0e10cSrcweir 	// MIB 15.7.97: Netscape scheint marginwidth auf 0 zu setzen, sobald
74*cdf0e10cSrcweir 	// marginheight gesetzt wird und umgekehrt. Machen wir jetzt wegen
75*cdf0e10cSrcweir 	// bug #41665# auch so.
76*cdf0e10cSrcweir 	// Netscape l"a\st aber ein direktes Setzen auf 0 nicht zu, IE4.0 schon.
77*cdf0e10cSrcweir 	// Den Bug machen wir nicht mit!
78*cdf0e10cSrcweir 	sal_Bool bMarginWidth = sal_False, bMarginHeight = sal_False;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir 	sal_uInt16 nArrLen = pOptions->Count();
81*cdf0e10cSrcweir 	for ( sal_uInt16 i=0; i<nArrLen; i++ )
82*cdf0e10cSrcweir 	{
83*cdf0e10cSrcweir 		const HTMLOption *pOption = (*pOptions)[i];
84*cdf0e10cSrcweir 		switch( pOption->GetToken() )
85*cdf0e10cSrcweir 		{
86*cdf0e10cSrcweir 		case HTML_O_BORDERCOLOR:
87*cdf0e10cSrcweir 			{
88*cdf0e10cSrcweir 				Color aColor;
89*cdf0e10cSrcweir 				pOption->GetColor( aColor );
90*cdf0e10cSrcweir 				pFrame->SetWallpaper( Wallpaper( aColor ) );
91*cdf0e10cSrcweir 				break;
92*cdf0e10cSrcweir 			}
93*cdf0e10cSrcweir 		case HTML_O_SRC:
94*cdf0e10cSrcweir             pFrame->SetURL(
95*cdf0e10cSrcweir                 String(
96*cdf0e10cSrcweir                     INetURLObject::GetAbsURL(
97*cdf0e10cSrcweir                         rBaseURL, pOption->GetString())) );
98*cdf0e10cSrcweir 			break;
99*cdf0e10cSrcweir 		case HTML_O_NAME:
100*cdf0e10cSrcweir 			pFrame->SetName( pOption->GetString() );
101*cdf0e10cSrcweir 			break;
102*cdf0e10cSrcweir 		case HTML_O_MARGINWIDTH:
103*cdf0e10cSrcweir 			aMargin.Width() = pOption->GetNumber();
104*cdf0e10cSrcweir 
105*cdf0e10cSrcweir //			if( aMargin.Width() < 1 )
106*cdf0e10cSrcweir //				aMargin.Width() = 1;
107*cdf0e10cSrcweir 			if( !bMarginHeight )
108*cdf0e10cSrcweir 				aMargin.Height() = 0;
109*cdf0e10cSrcweir 			bMarginWidth = sal_True;
110*cdf0e10cSrcweir 			break;
111*cdf0e10cSrcweir 		case HTML_O_MARGINHEIGHT:
112*cdf0e10cSrcweir 			aMargin.Height() = pOption->GetNumber();
113*cdf0e10cSrcweir 
114*cdf0e10cSrcweir //			if( aMargin.Height() < 1 )
115*cdf0e10cSrcweir //				aMargin.Height() = 1;
116*cdf0e10cSrcweir 			if( !bMarginWidth )
117*cdf0e10cSrcweir 				aMargin.Width() = 0;
118*cdf0e10cSrcweir 			bMarginHeight = sal_True;
119*cdf0e10cSrcweir 			break;
120*cdf0e10cSrcweir 		case HTML_O_SCROLLING:
121*cdf0e10cSrcweir 			pFrame->SetScrollingMode(
122*cdf0e10cSrcweir 				(ScrollingMode)pOption->GetEnum( aScollingTable,
123*cdf0e10cSrcweir 												 ScrollingAuto ) );
124*cdf0e10cSrcweir 			break;
125*cdf0e10cSrcweir 		case HTML_O_FRAMEBORDER:
126*cdf0e10cSrcweir 		{
127*cdf0e10cSrcweir 			String aStr = pOption->GetString();
128*cdf0e10cSrcweir 			sal_Bool bBorder = sal_True;
129*cdf0e10cSrcweir 			if ( aStr.EqualsIgnoreCaseAscii("NO") ||
130*cdf0e10cSrcweir 				 aStr.EqualsIgnoreCaseAscii("0") )
131*cdf0e10cSrcweir 				bBorder = sal_False;
132*cdf0e10cSrcweir 			pFrame->SetFrameBorder( bBorder );
133*cdf0e10cSrcweir 			break;
134*cdf0e10cSrcweir 		}
135*cdf0e10cSrcweir 		case HTML_O_NORESIZE:
136*cdf0e10cSrcweir 			pFrame->SetResizable( sal_False );
137*cdf0e10cSrcweir 			break;
138*cdf0e10cSrcweir 		default:
139*cdf0e10cSrcweir 			if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
140*cdf0e10cSrcweir 														HTML_O_READONLY ) )
141*cdf0e10cSrcweir 			{
142*cdf0e10cSrcweir 				String aStr = pOption->GetString();
143*cdf0e10cSrcweir 				sal_Bool bReadonly = sal_True;
144*cdf0e10cSrcweir 				if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
145*cdf0e10cSrcweir 					bReadonly = sal_False;
146*cdf0e10cSrcweir 				pFrame->SetReadOnly( bReadonly );
147*cdf0e10cSrcweir 			}
148*cdf0e10cSrcweir 			else if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
149*cdf0e10cSrcweir 														HTML_O_EDIT ) )
150*cdf0e10cSrcweir 			{
151*cdf0e10cSrcweir 				String aStr = pOption->GetString();
152*cdf0e10cSrcweir 				sal_Bool bEdit = sal_True;
153*cdf0e10cSrcweir 				if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
154*cdf0e10cSrcweir 					bEdit = sal_False;
155*cdf0e10cSrcweir 				pFrame->SetEditable( bEdit );
156*cdf0e10cSrcweir 			}
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 			break;
159*cdf0e10cSrcweir 		}
160*cdf0e10cSrcweir 	}
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir 	pFrame->SetMargin( aMargin );
163*cdf0e10cSrcweir }
164