Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 :
21 : #include <svtools/htmltokn.h>
22 : #include <svtools/asynclink.hxx>
23 :
24 : #include <sfx2/sfx.hrc>
25 :
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"
33 :
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";
37 :
38 : #define HTML_O_READONLY "READONLY"
39 : #define HTML_O_EDIT "EDIT"
40 :
41 : static HTMLOptionEnum const aScollingTable[] =
42 : {
43 : { sHTML_SC_yes, ScrollingYes },
44 : { sHTML_SC_no, ScrollingNo },
45 : { sHTML_SC_auto, ScrollingAuto },
46 : { 0, 0 }
47 : };
48 :
49 1 : void SfxFrameHTMLParser::ParseFrameOptions(
50 : SfxFrameDescriptor *pFrame, const HTMLOptions& rOptions, const OUString& rBaseURL )
51 : {
52 : // Get and set the options
53 1 : Size aMargin( pFrame->GetMargin() );
54 :
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 1 : bool bMarginWidth = false, bMarginHeight = false;
61 :
62 2 : for (size_t i = 0, n = rOptions.size(); i < n; ++i)
63 : {
64 1 : const HTMLOption& aOption = rOptions[i];
65 1 : switch( aOption.GetToken() )
66 : {
67 : case HTML_O_BORDERCOLOR:
68 : {
69 0 : Color aColor;
70 0 : aOption.GetColor( aColor );
71 0 : pFrame->SetWallpaper( Wallpaper( aColor ) );
72 0 : break;
73 : }
74 : case HTML_O_SRC:
75 : pFrame->SetURL(
76 : INetURLObject::GetAbsURL(
77 0 : rBaseURL, aOption.GetString()) );
78 0 : break;
79 : case HTML_O_NAME:
80 0 : pFrame->SetName( aOption.GetString() );
81 0 : break;
82 : case HTML_O_MARGINWIDTH:
83 0 : aMargin.Width() = aOption.GetNumber();
84 :
85 0 : if( !bMarginHeight )
86 0 : aMargin.Height() = 0;
87 0 : bMarginWidth = true;
88 0 : break;
89 : case HTML_O_MARGINHEIGHT:
90 0 : aMargin.Height() = aOption.GetNumber();
91 :
92 0 : if( !bMarginWidth )
93 0 : aMargin.Width() = 0;
94 0 : bMarginHeight = true;
95 0 : break;
96 : case HTML_O_SCROLLING:
97 : pFrame->SetScrollingMode(
98 : (ScrollingMode)aOption.GetEnum( aScollingTable,
99 0 : ScrollingAuto ) );
100 0 : break;
101 : case HTML_O_FRAMEBORDER:
102 : {
103 0 : OUString aStr = aOption.GetString();
104 0 : bool bBorder = true;
105 0 : if ( aStr.equalsIgnoreAsciiCase("NO") ||
106 0 : aStr.equalsIgnoreAsciiCase("0") )
107 0 : bBorder = false;
108 0 : pFrame->SetFrameBorder( bBorder );
109 0 : break;
110 : }
111 : case HTML_O_NORESIZE:
112 0 : pFrame->SetResizable( false );
113 0 : break;
114 : default:
115 1 : if (aOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_READONLY))
116 : {
117 0 : OUString aStr = aOption.GetString();
118 0 : bool bReadonly = true;
119 0 : if ( aStr.equalsIgnoreAsciiCase("FALSE") )
120 0 : bReadonly = false;
121 0 : pFrame->SetReadOnly( bReadonly );
122 : }
123 1 : else if (aOption.GetTokenString().equalsIgnoreAsciiCase(HTML_O_EDIT))
124 : {
125 0 : OUString aStr = aOption.GetString();
126 0 : bool bEdit = true;
127 0 : if ( aStr.equalsIgnoreAsciiCase("FALSE") )
128 0 : bEdit = false;
129 0 : pFrame->SetEditable( bEdit );
130 : }
131 :
132 1 : break;
133 : }
134 : }
135 :
136 1 : pFrame->SetMargin( aMargin );
137 649 : }
138 :
139 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|