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 <o3tl/string_view.hxx>
30#include <svtools/embedhlp.hxx>
31#include <tools/globname.hxx>
32#include <tools/urlobj.hxx>
33#include <hintids.hxx>
34
35using namespace com::sun::star;
36
37SwHtmlOptType SwApplet_Impl::GetOptionType( std::u16string_view rName, bool bApplet )
38{
40
41 switch( rName[0] )
42 {
43 case 'A':
44 case 'a':
48 else if( bApplet &&
49 (rName == u"ARCHIVE" || rName == u"ARCHIVES" ) )
51 break;
52 case 'C':
53 case 'c':
58 break;
59 case 'H':
60 case 'h':
66 break;
67 case 'I':
68 case 'i':
71 break;
72 case 'M':
73 case 'm':
76 break;
77 case 'N':
78 case 'n':
81 break;
82 case 'O':
83 case 'o':
84 if( bApplet && rName == u"OBJECT" )
86 break;
87 case 'S':
88 case 's':
92 break;
93 case 'T':
94 case 't':
97 break;
98 case 'V':
99 case 'v':
102 break;
103 case 'W':
104 case 'w':
107 break;
108 }
109
110 return nType;
111}
113 m_aItemSet( rPool, svl::Items<RES_FRMATR_BEGIN, RES_FRMATR_END-1> )
114{
115}
116
117void SwApplet_Impl::CreateApplet( const OUString& rCode, const OUString& rName,
118 bool bMayScript, const OUString& rCodeBase,
119 std::u16string_view rDocumentBaseURL )
120{
122 OUString aName;
123
124 // create Applet; it will be in running state
127
128 INetURLObject aUrlBase(rDocumentBaseURL);
129 aUrlBase.removeSegment();
130
131 OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::DecodeMechanism::NONE);
132 uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
133 if ( xSet.is() )
134 {
135 xSet->setPropertyValue("AppletCode", uno::Any( rCode ) );
136 xSet->setPropertyValue("AppletName", uno::Any( rName ) );
137 xSet->setPropertyValue("AppletIsScript", uno::Any( bMayScript ) );
138 xSet->setPropertyValue("AppletDocBase", uno::Any( sDocBase ) );
139 if ( !rCodeBase.isEmpty() )
140 xSet->setPropertyValue("AppletCodeBase", uno::Any( rCodeBase ) );
141 else
142 xSet->setPropertyValue("AppletCodeBase", uno::Any( sDocBase ) );
143 }
144}
145#if HAVE_FEATURE_JAVA
146bool SwApplet_Impl::CreateApplet( std::u16string_view rBaseURL )
147{
148 OUString aCode, aName, aCodeBase;
149 bool bMayScript = false;
150
151 size_t nArgCount = m_aCommandList.size();
152 for( size_t i = 0; i < nArgCount; i++ )
153 {
154 const SvCommand& rArg = m_aCommandList[i];
155 const OUString& rName = rArg.GetCommand();
156 if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_code ) )
157 aCode = rArg.GetArgument();
158 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_codebase ) )
159 aCodeBase = INetURLObject::GetAbsURL( rBaseURL, rArg.GetArgument() );
160 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_name ) )
161 aName = rArg.GetArgument();
162 else if( rName.equalsIgnoreAsciiCase( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
163 bMayScript = true;
164 }
165
166 if( aCode.isEmpty() )
167 return false;
168 CreateApplet( aCode, aName, bMayScript, aCodeBase, rBaseURL );
169 return true;
170}
171#endif
172
174{
175}
177{
178 uno::Reference < beans::XPropertySet > xSet( m_xApplet->getComponent(), uno::UNO_QUERY );
179 if ( xSet.is() )
180 {
181 uno::Sequence < beans::PropertyValue > aProps;
183 xSet->setPropertyValue("AppletCommands", uno::Any( aProps ) );
184 }
185}
186
187#if HAVE_FEATURE_JAVA
188void SwApplet_Impl::AppendParam( const OUString& rName, const OUString& rValue )
189{
190 m_aCommandList.Append( rName, rValue );
191}
192#endif
193
194/* 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
static SwHtmlOptType GetOptionType(std::u16string_view rName, bool bApplet)
css::uno::Reference< css::embed::XEmbeddedObject > m_xApplet
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 > &)
float u
constexpr sal_uInt16 RES_FRMATR_BEGIN(RES_PARATR_LIST_END)
constexpr sal_uInt16 RES_FRMATR_END(141)
#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
bool equalsIgnoreAsciiCase(std::u16string_view s1, std::u16string_view s2)
QPRO_FUNC_TYPE nType