LibreOffice Module sw (master) 1
SwAppletImpl.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#include <SwAppletImpl.hxx>
21#include <svtools/htmlkywd.hxx>
22#include <com/sun/star/beans/XPropertySet.hpp>
23#include <com/sun/star/beans/PropertyValue.hpp>
24#include <com/sun/star/embed/XEmbeddedObject.hpp>
25
28#include <com/sun/star/uno/Any.hxx>
29#include <svtools/embedhlp.hxx>
30#include <tools/globname.hxx>
31#include <tools/urlobj.hxx>
32#include <hintids.hxx>
33
34using namespace com::sun::star;
35
36SwHtmlOptType SwApplet_Impl::GetOptionType( const OUString& rName, bool bApplet )
37{
39
40 switch( rName.toChar() )
41 {
42 case 'A':
43 case 'a':
44 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_align ) ||
45 rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_alt ) )
47 else if( bApplet &&
48 (rName == "ARCHIVE" || rName == "ARCHIVES" ) )
50 break;
51 case 'C':
52 case 'c':
53 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_class ) ||
54 (bApplet && (rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) ||
55 rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
57 break;
58 case 'H':
59 case 'h':
60 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_height ) )
62 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
63 (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SW_HTML_O_Hidden )) )
65 break;
66 case 'I':
67 case 'i':
68 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_id ) )
70 break;
71 case 'M':
72 case 'm':
73 if( bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
75 break;
76 case 'N':
77 case 'n':
78 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
80 break;
81 case 'O':
82 case 'o':
83 if( bApplet && rName == "OBJECT" )
85 break;
86 case 'S':
87 case 's':
88 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_style ) ||
89 (!bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_src )) )
91 break;
92 case 'T':
93 case 't':
94 if( !bApplet && rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_type ) )
96 break;
97 case 'V':
98 case 'v':
99 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
101 break;
102 case 'W':
103 case 'w':
104 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_width ) )
106 break;
107 }
108
109 return nType;
110}
112 m_aItemSet( rPool, svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1> )
113{
114}
115
116void SwApplet_Impl::CreateApplet( const OUString& rCode, const OUString& rName,
117 bool bMayScript, const OUString& rCodeBase,
118 std::u16string_view rDocumentBaseURL )
119{
121 OUString aName;
122
123 // create Applet; it will be in running state
126
127 INetURLObject aUrlBase(rDocumentBaseURL);
128 aUrlBase.removeSegment();
129
130 OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::DecodeMechanism::NONE);
131 uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
132 if ( xSet.is() )
133 {
134 xSet->setPropertyValue("AppletCode", uno::Any( rCode ) );
135 xSet->setPropertyValue("AppletName", uno::Any( rName ) );
136 xSet->setPropertyValue("AppletIsScript", uno::Any( bMayScript ) );
137 xSet->setPropertyValue("AppletDocBase", uno::Any( sDocBase ) );
138 if ( !rCodeBase.isEmpty() )
139 xSet->setPropertyValue("AppletCodeBase", uno::Any( rCodeBase ) );
140 else
141 xSet->setPropertyValue("AppletCodeBase", uno::Any( sDocBase ) );
142 }
143}
144#if HAVE_FEATURE_JAVA
145bool SwApplet_Impl::CreateApplet( std::u16string_view rBaseURL )
146{
147 OUString aCode, aName, aCodeBase;
148 bool bMayScript = false;
149
150 size_t nArgCount = m_aCommandList.size();
151 for( size_t i = 0; i < nArgCount; i++ )
152 {
153 const SvCommand& rArg = m_aCommandList[i];
154 const OUString& rName = rArg.GetCommand();
155 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) )
156 aCode = rArg.GetArgument();
157 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ) )
158 aCodeBase = INetURLObject::GetAbsURL( rBaseURL, rArg.GetArgument() );
159 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
160 aName = rArg.GetArgument();
161 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
162 bMayScript = true;
163 }
164
165 if( aCode.isEmpty() )
166 return false;
167 CreateApplet( aCode, aName, bMayScript, aCodeBase, rBaseURL );
168 return true;
169}
170#endif
171
173{
174}
176{
177 uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
178 if ( xSet.is() )
179 {
180 uno::Sequence < beans::PropertyValue > aProps;
182 xSet->setPropertyValue("AppletCommands", uno::Any( aProps ) );
183 }
184}
185
186#if HAVE_FEATURE_JAVA
187void SwApplet_Impl::AppendParam( const OUString& rName, const OUString& rValue )
188{
189 m_aCommandList.Append( rName, rValue );
190}
191#endif
192
193/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define OOO_STRING_SW_HTML_O_Hidden
SwHtmlOptType
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
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 FillSequence(css::uno::Sequence< css::beans::PropertyValue > &) const
size_t size() const
void Append(const OUString &rCommand, const OUString &rArg)
const OUString & GetArgument() const
const OUString & GetCommand() const
SwApplet_Impl(SfxItemPool &rPool)
void CreateApplet(const OUString &rCode, const OUString &rName, bool bMayScript, const OUString &rCodeBase, std::u16string_view rBaseURL)
SvCommandList m_aCommandList
css::uno::Reference< css::embed::XEmbeddedObject > m_xApplet
static SwHtmlOptType GetOptionType(const OUString &rName, bool bApplet)
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
#define SO3_APPLET_CLASSID
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr sal_uInt16 RES_FRMATR_END(133)
#define OOO_STRING_SVTOOLS_HTML_O_height
#define OOO_STRING_SVTOOLS_HTML_O_mayscript
#define OOO_STRING_SVTOOLS_HTML_O_align
#define OOO_STRING_SVTOOLS_HTML_O_src
#define OOO_STRING_SVTOOLS_HTML_O_code
#define OOO_STRING_SVTOOLS_HTML_O_class
#define OOO_STRING_SVTOOLS_HTML_O_hspace
#define OOO_STRING_SVTOOLS_HTML_O_vspace
#define OOO_STRING_SVTOOLS_HTML_O_type
#define OOO_STRING_SVTOOLS_HTML_O_name
#define OOO_STRING_SVTOOLS_HTML_O_id
#define OOO_STRING_SVTOOLS_HTML_O_width
#define OOO_STRING_SVTOOLS_HTML_O_codebase
#define OOO_STRING_SVTOOLS_HTML_O_alt
#define OOO_STRING_SVTOOLS_HTML_O_style
OUString aName
int i
QPRO_FUNC_TYPE nType