Version 3.6.0.4, tag libreoffice-3.6.0.4
[LibreOffice.git] / sfx2 / source / bastyp / frmhtml.cxx
blobdc24e354102d66b5a647b504cb31e5b3a3d80e59
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
30 #include <svtools/htmltokn.h>
31 #include <svtools/asynclink.hxx>
33 #include <sfx2/sfx.hrc>
35 #include <sfx2/frmhtml.hxx>
36 #include <sfx2/docfile.hxx>
37 #include <sfx2/viewfrm.hxx>
38 #include <sfx2/evntconf.hxx>
39 #include <sfx2/request.hxx>
40 #include <sfx2/fcontnr.hxx>
41 #include "sfxtypes.hxx"
43 static sal_Char const sHTML_SC_yes[] = "YES";
44 static sal_Char const sHTML_SC_no[] = "NO";
45 static sal_Char const sHTML_SC_auto[] = "AUTO";
47 #define HTML_O_READONLY "READONLY"
48 #define HTML_O_EDIT "EDIT"
50 static HTMLOptionEnum const aScollingTable[] =
52 { sHTML_SC_yes, ScrollingYes },
53 { sHTML_SC_no, ScrollingNo },
54 { sHTML_SC_auto, ScrollingAuto },
55 { 0, 0 }
58 void SfxFrameHTMLParser::ParseFrameOptions(
59 SfxFrameDescriptor *pFrame, const HTMLOptions& rOptions, const String& rBaseURL )
61 // Get and set the options
62 Size aMargin( pFrame->GetMargin() );
64 // Netscape seems to set marginwidth to 0 as soon as
65 // marginheight is set, and vice versa.
66 // Netscape does however not allow for a direct
67 // seting to 0, while IE4.0 does
68 // We will not mimic that bug !
69 sal_Bool bMarginWidth = sal_False, bMarginHeight = sal_False;
71 for (size_t i = 0, n = rOptions.size(); i < n; ++i)
73 const HTMLOption& aOption = rOptions[i];
74 switch( aOption.GetToken() )
76 case HTML_O_BORDERCOLOR:
78 Color aColor;
79 aOption.GetColor( aColor );
80 pFrame->SetWallpaper( Wallpaper( aColor ) );
81 break;
83 case HTML_O_SRC:
84 pFrame->SetURL(
85 String(
86 INetURLObject::GetAbsURL(
87 rBaseURL, aOption.GetString())) );
88 break;
89 case HTML_O_NAME:
90 pFrame->SetName( aOption.GetString() );
91 break;
92 case HTML_O_MARGINWIDTH:
93 aMargin.Width() = aOption.GetNumber();
95 if( !bMarginHeight )
96 aMargin.Height() = 0;
97 bMarginWidth = sal_True;
98 break;
99 case HTML_O_MARGINHEIGHT:
100 aMargin.Height() = aOption.GetNumber();
102 if( !bMarginWidth )
103 aMargin.Width() = 0;
104 bMarginHeight = sal_True;
105 break;
106 case HTML_O_SCROLLING:
107 pFrame->SetScrollingMode(
108 (ScrollingMode)aOption.GetEnum( aScollingTable,
109 ScrollingAuto ) );
110 break;
111 case HTML_O_FRAMEBORDER:
113 String aStr = aOption.GetString();
114 sal_Bool bBorder = sal_True;
115 if ( aStr.EqualsIgnoreCaseAscii("NO") ||
116 aStr.EqualsIgnoreCaseAscii("0") )
117 bBorder = sal_False;
118 pFrame->SetFrameBorder( bBorder );
119 break;
121 case HTML_O_NORESIZE:
122 pFrame->SetResizable( sal_False );
123 break;
124 default:
125 if ( aOption.GetTokenString().EqualsIgnoreCaseAscii(
126 HTML_O_READONLY ) )
128 String aStr = aOption.GetString();
129 sal_Bool bReadonly = sal_True;
130 if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
131 bReadonly = sal_False;
132 pFrame->SetReadOnly( bReadonly );
134 else if ( aOption.GetTokenString().EqualsIgnoreCaseAscii(
135 HTML_O_EDIT ) )
137 String aStr = aOption.GetString();
138 sal_Bool bEdit = sal_True;
139 if ( aStr.EqualsIgnoreCaseAscii("FALSE") )
140 bEdit = sal_False;
141 pFrame->SetEditable( bEdit );
144 break;
148 pFrame->SetMargin( aMargin );
151 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */