Use correct object
[LibreOffice.git] / sfx2 / source / bastyp / frmhtml.cxx
bloba15a6cc7a02208c533f77415929b3bd0981b50fe
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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>
23 #include <sfx2/frmdescr.hxx>
24 #include <sfx2/frmhtml.hxx>
26 char const sHTML_SC_yes[] = "YES";
27 char const sHTML_SC_no[] = "NO";
28 char const sHTML_SC_auto[] = "AUTO";
30 HTMLOptionEnum<ScrollingMode> const aScrollingTable[] =
32 { sHTML_SC_yes, ScrollingMode::Yes },
33 { sHTML_SC_no, ScrollingMode::No },
34 { sHTML_SC_auto, ScrollingMode::Auto },
35 { nullptr, ScrollingMode(0) }
38 namespace SfxFrameHTMLParser
40 void ParseFrameOptions(
41 SfxFrameDescriptor *pFrame, const HTMLOptions& rOptions, std::u16string_view rBaseURL )
43 // Get and set the options
44 Size aMargin( pFrame->GetMargin() );
46 // Netscape seems to set marginwidth to 0 as soon as
47 // marginheight is set, and vice versa.
48 // Netscape does however not allow for a direct
49 // setting to 0, while IE4.0 does
50 // We will not mimic that bug !
51 bool bMarginWidth = false, bMarginHeight = false;
53 for (const auto & rOption : rOptions)
55 switch( rOption.GetToken() )
57 case HtmlOptionId::SRC:
58 pFrame->SetURL(
59 INetURLObject::GetAbsURL(
60 rBaseURL, rOption.GetString()) );
61 break;
62 case HtmlOptionId::NAME:
63 pFrame->SetName( rOption.GetString() );
64 break;
65 case HtmlOptionId::MARGINWIDTH:
66 aMargin.setWidth( rOption.GetNumber() );
68 if( !bMarginHeight )
69 aMargin.setHeight( 0 );
70 bMarginWidth = true;
71 break;
72 case HtmlOptionId::MARGINHEIGHT:
73 aMargin.setHeight( rOption.GetNumber() );
75 if( !bMarginWidth )
76 aMargin.setWidth( 0 );
77 bMarginHeight = true;
78 break;
79 case HtmlOptionId::SCROLLING:
80 pFrame->SetScrollingMode( rOption.GetEnum( aScrollingTable, ScrollingMode::Auto ) );
81 break;
82 case HtmlOptionId::FRAMEBORDER:
84 const OUString& aStr = rOption.GetString();
85 bool bBorder = true;
86 if ( aStr.equalsIgnoreAsciiCase("NO") ||
87 aStr.equalsIgnoreAsciiCase("0") )
88 bBorder = false;
89 pFrame->SetFrameBorder( bBorder );
90 break;
92 default:
93 break;
97 pFrame->SetMargin( aMargin );
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */