1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 #include <svtools/htmltokn.h>
22 #include <svtools/asynclink.hxx>
24 #include <sfx2/sfx.hrc>
26 #include <sfx2/frmhtml.hxx>
27 #include <sfx2/docfile.hxx>
28 #include <sfx2/viewfrm.hxx>
29 #include <sfx2/evntconf.hxx>
30 #include <sfx2/request.hxx>
31 #include <sfx2/fcontnr.hxx>
32 #include "sfxtypes.hxx"
34 static sal_Char
const sHTML_SC_yes
[] = "YES";
35 static sal_Char
const sHTML_SC_no
[] = "NO";
36 static sal_Char
const sHTML_SC_auto
[] = "AUTO";
38 #define HTML_O_READONLY "READONLY"
39 #define HTML_O_EDIT "EDIT"
41 static HTMLOptionEnum
const aScollingTable
[] =
43 { sHTML_SC_yes
, ScrollingYes
},
44 { sHTML_SC_no
, ScrollingNo
},
45 { sHTML_SC_auto
, ScrollingAuto
},
49 void SfxFrameHTMLParser::ParseFrameOptions(
50 SfxFrameDescriptor
*pFrame
, const HTMLOptions
& rOptions
, const OUString
& rBaseURL
)
52 // Get and set the options
53 Size
aMargin( pFrame
->GetMargin() );
55 // Netscape seems to set marginwidth to 0 as soon as
56 // marginheight is set, and vice versa.
57 // Netscape does however not allow for a direct
58 // seting to 0, while IE4.0 does
59 // We will not mimic that bug !
60 bool bMarginWidth
= false, bMarginHeight
= false;
62 for (size_t i
= 0, n
= rOptions
.size(); i
< n
; ++i
)
64 const HTMLOption
& aOption
= rOptions
[i
];
65 switch( aOption
.GetToken() )
67 case HTML_O_BORDERCOLOR
:
70 aOption
.GetColor( aColor
);
71 pFrame
->SetWallpaper( Wallpaper( aColor
) );
76 INetURLObject::GetAbsURL(
77 rBaseURL
, aOption
.GetString()) );
80 pFrame
->SetName( aOption
.GetString() );
82 case HTML_O_MARGINWIDTH
:
83 aMargin
.Width() = aOption
.GetNumber();
89 case HTML_O_MARGINHEIGHT
:
90 aMargin
.Height() = aOption
.GetNumber();
96 case HTML_O_SCROLLING
:
97 pFrame
->SetScrollingMode(
98 (ScrollingMode
)aOption
.GetEnum( aScollingTable
,
101 case HTML_O_FRAMEBORDER
:
103 OUString aStr
= aOption
.GetString();
105 if ( aStr
.equalsIgnoreAsciiCase("NO") ||
106 aStr
.equalsIgnoreAsciiCase("0") )
108 pFrame
->SetFrameBorder( bBorder
);
111 case HTML_O_NORESIZE
:
112 pFrame
->SetResizable( false );
115 if (aOption
.GetTokenString().equalsIgnoreAsciiCase(HTML_O_READONLY
))
117 OUString aStr
= aOption
.GetString();
118 bool bReadonly
= true;
119 if ( aStr
.equalsIgnoreAsciiCase("FALSE") )
121 pFrame
->SetReadOnly( bReadonly
);
123 else if (aOption
.GetTokenString().equalsIgnoreAsciiCase(HTML_O_EDIT
))
125 OUString aStr
= aOption
.GetString();
127 if ( aStr
.equalsIgnoreAsciiCase("FALSE") )
129 pFrame
->SetEditable( bEdit
);
136 pFrame
->SetMargin( aMargin
);
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */