Update ooo320-m1
[ooovba.git] / sfx2 / source / bastyp / frmhtml.cxx
blobf1071be2645a611dbdcdb8d6020e8c4bf6a4ca9b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmhtml.cxx,v $
10 * $Revision: 1.14 $
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_sfx2.hxx"
34 #include <tools/list.hxx>
35 #include <tools/table.hxx>
36 #include <svtools/htmltokn.h>
37 #include <svtools/asynclink.hxx>
39 #define _SVSTDARR_USHORTS
40 #define _SVSTDARR_ULONGS
41 #include <svtools/svstdarr.hxx>
43 #include <sfx2/sfx.hrc>
45 #include <sfx2/frmhtml.hxx>
46 #include <sfx2/docfile.hxx>
47 #include <sfx2/viewfrm.hxx>
48 #include <sfx2/evntconf.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/fcontnr.hxx>
51 #include "sfxtypes.hxx"
53 #define SFX_HTMLFRMSIZE_REL 0x0001
54 #define SFX_HTMLFRMSIZE_PERCENT 0x0002
56 static sal_Char __READONLY_DATA sHTML_SC_yes[] = "YES";
57 static sal_Char __READONLY_DATA sHTML_SC_no[] = "NO";
58 static sal_Char __READONLY_DATA sHTML_SC_auto[] = "AUTO";
60 #define HTML_O_READONLY "READONLY"
61 #define HTML_O_EDIT "EDIT"
63 static HTMLOptionEnum __READONLY_DATA aScollingTable[] =
65 { sHTML_SC_yes, ScrollingYes },
66 { sHTML_SC_no, ScrollingNo },
67 { sHTML_SC_auto, ScrollingAuto },
68 { 0, 0 }
71 void SfxFrameHTMLParser::ParseFrameOptions( SfxFrameDescriptor *pFrame, const HTMLOptions *pOptions, const String& rBaseURL )
73 // die Optionen holen und setzen
74 Size aMargin( pFrame->GetMargin() );
76 // MIB 15.7.97: Netscape scheint marginwidth auf 0 zu setzen, sobald
77 // marginheight gesetzt wird und umgekehrt. Machen wir jetzt wegen
78 // bug #41665# auch so.
79 // Netscape l"a\st aber ein direktes Setzen auf 0 nicht zu, IE4.0 schon.
80 // Den Bug machen wir nicht mit!
81 BOOL bMarginWidth = FALSE, bMarginHeight = FALSE;
83 USHORT nArrLen = pOptions->Count();
84 for ( USHORT i=0; i<nArrLen; i++ )
86 const HTMLOption *pOption = (*pOptions)[i];
87 switch( pOption->GetToken() )
89 case HTML_O_BORDERCOLOR:
91 Color aColor;
92 pOption->GetColor( aColor );
93 pFrame->SetWallpaper( Wallpaper( aColor ) );
94 break;
96 case HTML_O_SRC:
97 pFrame->SetURL(
98 String(
99 INetURLObject::GetAbsURL(
100 rBaseURL, pOption->GetString())) );
101 break;
102 case HTML_O_NAME:
103 pFrame->SetName( pOption->GetString() );
104 break;
105 case HTML_O_MARGINWIDTH:
106 aMargin.Width() = pOption->GetNumber();
108 // if( aMargin.Width() < 1 )
109 // aMargin.Width() = 1;
110 if( !bMarginHeight )
111 aMargin.Height() = 0;
112 bMarginWidth = TRUE;
113 break;
114 case HTML_O_MARGINHEIGHT:
115 aMargin.Height() = pOption->GetNumber();
117 // if( aMargin.Height() < 1 )
118 // aMargin.Height() = 1;
119 if( !bMarginWidth )
120 aMargin.Width() = 0;
121 bMarginHeight = TRUE;
122 break;
123 case HTML_O_SCROLLING:
124 pFrame->SetScrollingMode(
125 (ScrollingMode)pOption->GetEnum( aScollingTable,
126 ScrollingAuto ) );
127 break;
128 case HTML_O_FRAMEBORDER:
130 String aStr = pOption->GetString();
131 BOOL bBorder = TRUE;
132 if ( aStr.EqualsIgnoreCaseAscii("NO") ||
133 aStr.EqualsIgnoreCaseAscii("0") )
134 bBorder = FALSE;
135 pFrame->SetFrameBorder( bBorder );
136 break;
138 case HTML_O_NORESIZE:
139 pFrame->SetResizable( FALSE );
140 break;
141 default:
142 if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
143 HTML_O_READONLY ) )
145 String aStr = pOption->GetString();
146 BOOL bReadonly = TRUE;
147 if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
148 bReadonly = FALSE;
149 pFrame->SetReadOnly( bReadonly );
151 else if ( pOption->GetTokenString().EqualsIgnoreCaseAscii(
152 HTML_O_EDIT ) )
154 String aStr = pOption->GetString();
155 BOOL bEdit = TRUE;
156 if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
157 bEdit = FALSE;
158 pFrame->SetEditable( bEdit );
161 break;
165 pFrame->SetMargin( aMargin );