1*d119d52dSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*d119d52dSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d119d52dSAndrew Rist * or more contributor license agreements. See the NOTICE file
5*d119d52dSAndrew Rist * distributed with this work for additional information
6*d119d52dSAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*d119d52dSAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d119d52dSAndrew Rist * "License"); you may not use this file except in compliance
9*d119d52dSAndrew Rist * with the License. You may obtain a copy of the License at
10*d119d52dSAndrew Rist *
11*d119d52dSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*d119d52dSAndrew Rist *
13*d119d52dSAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d119d52dSAndrew Rist * software distributed under the License is distributed on an
15*d119d52dSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d119d52dSAndrew Rist * KIND, either express or implied. See the License for the
17*d119d52dSAndrew Rist * specific language governing permissions and limitations
18*d119d52dSAndrew Rist * under the License.
19*d119d52dSAndrew Rist *
20*d119d52dSAndrew Rist *************************************************************/
21*d119d52dSAndrew Rist
22*d119d52dSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_sfx2.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include <tools/list.hxx>
28cdf0e10cSrcweir #include <tools/table.hxx>
29cdf0e10cSrcweir #include <svtools/htmltokn.h>
30cdf0e10cSrcweir #include <svtools/asynclink.hxx>
31cdf0e10cSrcweir
32cdf0e10cSrcweir #define _SVSTDARR_USHORTS
33cdf0e10cSrcweir #define _SVSTDARR_ULONGS
34cdf0e10cSrcweir #include <svl/svstdarr.hxx>
35cdf0e10cSrcweir
36cdf0e10cSrcweir #include <sfx2/sfx.hrc>
37cdf0e10cSrcweir
38cdf0e10cSrcweir #include <sfx2/frmhtml.hxx>
39cdf0e10cSrcweir #include <sfx2/docfile.hxx>
40cdf0e10cSrcweir #include <sfx2/viewfrm.hxx>
41cdf0e10cSrcweir #include <sfx2/evntconf.hxx>
42cdf0e10cSrcweir #include <sfx2/request.hxx>
43cdf0e10cSrcweir #include <sfx2/fcontnr.hxx>
44cdf0e10cSrcweir #include "sfxtypes.hxx"
45cdf0e10cSrcweir
46cdf0e10cSrcweir #define SFX_HTMLFRMSIZE_REL 0x0001
47cdf0e10cSrcweir #define SFX_HTMLFRMSIZE_PERCENT 0x0002
48cdf0e10cSrcweir
49cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_yes[] = "YES";
50cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_no[] = "NO";
51cdf0e10cSrcweir static sal_Char __READONLY_DATA sHTML_SC_auto[] = "AUTO";
52cdf0e10cSrcweir
53cdf0e10cSrcweir #define HTML_O_READONLY "READONLY"
54cdf0e10cSrcweir #define HTML_O_EDIT "EDIT"
55cdf0e10cSrcweir
56cdf0e10cSrcweir static HTMLOptionEnum __READONLY_DATA aScollingTable[] =
57cdf0e10cSrcweir {
58cdf0e10cSrcweir { sHTML_SC_yes, ScrollingYes },
59cdf0e10cSrcweir { sHTML_SC_no, ScrollingNo },
60cdf0e10cSrcweir { sHTML_SC_auto, ScrollingAuto },
61cdf0e10cSrcweir { 0, 0 }
62cdf0e10cSrcweir };
63cdf0e10cSrcweir
ParseFrameOptions(SfxFrameDescriptor * pFrame,const HTMLOptions * pOptions,const String & rBaseURL)64cdf0e10cSrcweir void SfxFrameHTMLParser::ParseFrameOptions( SfxFrameDescriptor *pFrame, const HTMLOptions *pOptions, const String& rBaseURL )
65cdf0e10cSrcweir {
66cdf0e10cSrcweir // die Optionen holen und setzen
67cdf0e10cSrcweir Size aMargin( pFrame->GetMargin() );
68cdf0e10cSrcweir
69cdf0e10cSrcweir // MIB 15.7.97: Netscape scheint marginwidth auf 0 zu setzen, sobald
70cdf0e10cSrcweir // marginheight gesetzt wird und umgekehrt. Machen wir jetzt wegen
71cdf0e10cSrcweir // bug #41665# auch so.
72cdf0e10cSrcweir // Netscape l"a\st aber ein direktes Setzen auf 0 nicht zu, IE4.0 schon.
73cdf0e10cSrcweir // Den Bug machen wir nicht mit!
74cdf0e10cSrcweir sal_Bool bMarginWidth = sal_False, bMarginHeight = sal_False;
75cdf0e10cSrcweir
76cdf0e10cSrcweir sal_uInt16 nArrLen = pOptions->Count();
77cdf0e10cSrcweir for ( sal_uInt16 i=0; i<nArrLen; i++ )
78cdf0e10cSrcweir {
79cdf0e10cSrcweir const HTMLOption *pOption = (*pOptions)[i];
80cdf0e10cSrcweir switch( pOption->GetToken() )
81cdf0e10cSrcweir {
82cdf0e10cSrcweir case HTML_O_BORDERCOLOR:
83cdf0e10cSrcweir {
84cdf0e10cSrcweir Color aColor;
85cdf0e10cSrcweir pOption->GetColor( aColor );
86cdf0e10cSrcweir pFrame->SetWallpaper( Wallpaper( aColor ) );
87cdf0e10cSrcweir break;
88cdf0e10cSrcweir }
89cdf0e10cSrcweir case HTML_O_SRC:
90cdf0e10cSrcweir pFrame->SetURL(
91cdf0e10cSrcweir String(
92cdf0e10cSrcweir INetURLObject::GetAbsURL(
93cdf0e10cSrcweir rBaseURL, pOption->GetString())) );
94cdf0e10cSrcweir break;
95cdf0e10cSrcweir case HTML_O_NAME:
96cdf0e10cSrcweir pFrame->SetName( pOption->GetString() );
97cdf0e10cSrcweir break;
98cdf0e10cSrcweir case HTML_O_MARGINWIDTH:
99cdf0e10cSrcweir aMargin.Width() = pOption->GetNumber();
100cdf0e10cSrcweir
101cdf0e10cSrcweir // if( aMargin.Width() < 1 )
102cdf0e10cSrcweir // aMargin.Width() = 1;
103cdf0e10cSrcweir if( !bMarginHeight )
104cdf0e10cSrcweir aMargin.Height() = 0;
105cdf0e10cSrcweir bMarginWidth = sal_True;
106cdf0e10cSrcweir break;
107cdf0e10cSrcweir case HTML_O_MARGINHEIGHT:
108cdf0e10cSrcweir aMargin.Height() = pOption->GetNumber();
109cdf0e10cSrcweir
110cdf0e10cSrcweir // if( aMargin.Height() < 1 )
111cdf0e10cSrcweir // aMargin.Height() = 1;
112cdf0e10cSrcweir if( !bMarginWidth )
113cdf0e10cSrcweir aMargin.Width() = 0;
114cdf0e10cSrcweir bMarginHeight = sal_True;
115cdf0e10cSrcweir break;
116cdf0e10cSrcweir case HTML_O_SCROLLING:
117cdf0e10cSrcweir pFrame->SetScrollingMode(
118cdf0e10cSrcweir (ScrollingMode)pOption->GetEnum( aScollingTable,
119cdf0e10cSrcweir ScrollingAuto ) );
120cdf0e10cSrcweir break;
121cdf0e10cSrcweir case HTML_O_FRAMEBORDER:
122cdf0e10cSrcweir {
123cdf0e10cSrcweir String aStr = pOption->GetString();
124cdf0e10cSrcweir sal_Bool bBorder = sal_True;
125cdf0e10cSrcweir if ( aStr.EqualsIgnoreCaseAscii("NO") ||
126cdf0e10cSrcweir aStr.EqualsIgnoreCaseAscii("0") )
127cdf0e10cSrcweir bBorder = sal_False;
128cdf0e10cSrcweir pFrame->SetFrameBorder( bBorder );
129cdf0e10cSrcweir break;
130cdf0e10cSrcweir }
131cdf0e10cSrcweir case HTML_O_NORESIZE:
132cdf0e10cSrcweir pFrame->SetResizable( sal_False );
133cdf0e10cSrcweir break;
134cdf0e10cSrcweir default:
135cdf0e10cSrcweir if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
136cdf0e10cSrcweir HTML_O_READONLY ) )
137cdf0e10cSrcweir {
138cdf0e10cSrcweir String aStr = pOption->GetString();
139cdf0e10cSrcweir sal_Bool bReadonly = sal_True;
140cdf0e10cSrcweir if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
141cdf0e10cSrcweir bReadonly = sal_False;
142cdf0e10cSrcweir pFrame->SetReadOnly( bReadonly );
143cdf0e10cSrcweir }
144cdf0e10cSrcweir else if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
145cdf0e10cSrcweir HTML_O_EDIT ) )
146cdf0e10cSrcweir {
147cdf0e10cSrcweir String aStr = pOption->GetString();
148cdf0e10cSrcweir sal_Bool bEdit = sal_True;
149cdf0e10cSrcweir if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
150cdf0e10cSrcweir bEdit = sal_False;
151cdf0e10cSrcweir pFrame->SetEditable( bEdit );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir
154cdf0e10cSrcweir break;
155cdf0e10cSrcweir }
156cdf0e10cSrcweir }
157cdf0e10cSrcweir
158cdf0e10cSrcweir pFrame->SetMargin( aMargin );
159cdf0e10cSrcweir }
160