LibreOffice Module sfx2 (master) 1
frmhtml.cxx
Go to the documentation of this file.
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
23#include <sfx2/frmdescr.hxx>
24#include <sfx2/frmhtml.hxx>
25
26char const sHTML_SC_yes[] = "YES";
27char const sHTML_SC_no[] = "NO";
28char const sHTML_SC_auto[] = "AUTO";
29
31{
35 { nullptr, ScrollingMode(0) }
36};
37
39{
41 SfxFrameDescriptor *pFrame, const HTMLOptions& rOptions, std::u16string_view rBaseURL )
42{
43 // Get and set the options
44 Size aMargin( pFrame->GetMargin() );
45
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;
52
53 for (const auto & rOption : rOptions)
54 {
55 switch( rOption.GetToken() )
56 {
57 case HtmlOptionId::SRC:
58 pFrame->SetURL(
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() );
67
68 if( !bMarginHeight )
69 aMargin.setHeight( 0 );
70 bMarginWidth = true;
71 break;
72 case HtmlOptionId::MARGINHEIGHT:
73 aMargin.setHeight( rOption.GetNumber() );
74
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:
83 {
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;
91 }
92 default:
93 break;
94 }
95 }
96
97 pFrame->SetMargin( aMargin );
98}
99}
100
101/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static OUString GetAbsURL(std::u16string_view rTheBaseURIRef, OUString const &rTheRelURIRef, EncodeMechanism eEncodeMechanism=EncodeMechanism::WasEncoded, DecodeMechanism eDecodeMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
void SetURL(std::u16string_view rURL)
Definition: frmdescr.cxx:45
void SetScrollingMode(ScrollingMode eMode)
Definition: frmdescr.hxx:84
void SetName(const OUString &rName)
Definition: frmdescr.hxx:74
void SetFrameBorder(bool bBorder)
Definition: frmdescr.hxx:92
const Size & GetMargin() const
Definition: frmdescr.hxx:78
void SetMargin(const Size &rMargin)
Definition: frmdescr.hxx:80
void setWidth(tools::Long nWidth)
void setHeight(tools::Long nHeight)
ScrollingMode
Definition: frmdescr.hxx:40
char const sHTML_SC_no[]
Definition: frmhtml.cxx:27
char const sHTML_SC_auto[]
Definition: frmhtml.cxx:28
HTMLOptionEnum< ScrollingMode > const aScrollingTable[]
Definition: frmhtml.cxx:30
char const sHTML_SC_yes[]
Definition: frmhtml.cxx:26
aStr
Definition: mgetempl.cxx:407
void ParseFrameOptions(SfxFrameDescriptor *pFrame, const HTMLOptions &rOptions, std::u16string_view rBaseURL)
Definition: frmhtml.cxx:40
::std::vector< HTMLOption > HTMLOptions