Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <SwAppletImpl.hxx>
30 : : #include <svtools/htmlkywd.hxx>
31 : : #include <svl/urihelper.hxx>
32 : : #include <com/sun/star/beans/XPropertySet.hpp>
33 : : #include <com/sun/star/embed/EmbedStates.hpp>
34 : :
35 : : #include <comphelper/embeddedobjectcontainer.hxx>
36 : : #include <sot/clsids.hxx>
37 : : #include <com/sun/star/uno/Any.hxx>
38 : : #include <svtools/embedhlp.hxx>
39 : :
40 : : using namespace com::sun::star;
41 : :
42 : : namespace {
43 : :
44 : : static char const sHTML_O_archive[] = "ARCHIVE";
45 : : static char const sHTML_O_Archives[] = "ARCHIVES";
46 : : static char const sHTML_O_Object[] = "OBJECT";
47 : :
48 : : }
49 : :
50 : 0 : sal_uInt16 SwApplet_Impl::GetOptionType( const ::rtl::OUString& rName, sal_Bool bApplet )
51 : : {
52 [ # # ]: 0 : sal_uInt16 nType = bApplet ? SWHTML_OPTTYPE_PARAM : SWHTML_OPTTYPE_TAG;
53 : :
54 [ # # # # : 0 : switch( rName.toChar() )
# # # # #
# # # ]
55 : : {
56 : : case 'A':
57 : : case 'a':
58 [ # # # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_align ) ||
[ # # ]
59 : 0 : rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_alt ) )
60 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
61 [ # # # # : 0 : else if( bApplet &&
# # ][ # # ]
62 : 0 : (rName.equalsIgnoreAsciiCaseAscii( sHTML_O_archive ) ||
63 : 0 : rName.equalsIgnoreAsciiCaseAscii( sHTML_O_Archives )) )
64 : 0 : nType = SWHTML_OPTTYPE_TAG;
65 : 0 : break;
66 : : case 'C':
67 : : case 'c':
68 [ # # ][ # # : 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_class ) ||
# # # # ]
[ # # ]
69 : 0 : (bApplet && (rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_code ) ||
70 : 0 : rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_codebase ))) )
71 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
72 : 0 : break;
73 : : case 'H':
74 : : case 'h':
75 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_height ) )
76 : 0 : nType = SWHTML_OPTTYPE_SIZE;
77 [ # # ]: 0 : else if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_hspace ) ||
[ # # # # ]
[ # # ]
78 : 0 : (!bApplet && rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SW_HTML_O_Hidden )) )
79 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
80 : 0 : break;
81 : : case 'I':
82 : : case 'i':
83 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_id ) )
84 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
85 : 0 : break;
86 : : case 'M':
87 : : case 'm':
88 [ # # ][ # # ]: 0 : if( bApplet && rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
[ # # ]
89 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
90 : 0 : break;
91 : : case 'N':
92 : : case 'n':
93 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_name ) )
94 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
95 : 0 : break;
96 : : case 'O':
97 : : case 'o':
98 [ # # ][ # # ]: 0 : if( bApplet && rName.equalsIgnoreAsciiCaseAscii( sHTML_O_Object ) )
[ # # ]
99 : 0 : nType = SWHTML_OPTTYPE_TAG;
100 : 0 : break;
101 : : case 'S':
102 : : case 's':
103 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_style ) ||
[ # # # # ]
[ # # ]
104 : 0 : (!bApplet && rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_src )) )
105 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
106 : 0 : break;
107 : : case 'T':
108 : : case 't':
109 [ # # ][ # # ]: 0 : if( !bApplet && rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_type ) )
[ # # ]
110 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
111 : 0 : break;
112 : : case 'V':
113 : : case 'v':
114 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_vspace ) )
115 : 0 : nType = SWHTML_OPTTYPE_IGNORE;
116 : 0 : break;
117 : : case 'W':
118 : : case 'w':
119 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_width ) )
120 : 0 : nType = SWHTML_OPTTYPE_SIZE;
121 : 0 : break;
122 : : }
123 : :
124 : 0 : return nType;
125 : : }
126 : 0 : SwApplet_Impl::SwApplet_Impl( SfxItemPool& rPool, sal_uInt16 nWhich1, sal_uInt16 nWhich2 ) :
127 [ # # ][ # # ]: 0 : aItemSet( rPool, nWhich1, nWhich2 )
128 : : {
129 : 0 : }
130 : :
131 : 0 : void SwApplet_Impl::CreateApplet( const ::rtl::OUString& rCode, const ::rtl::OUString& rName,
132 : : sal_Bool bMayScript, const ::rtl::OUString& rCodeBase,
133 : : const ::rtl::OUString& rDocumentBaseURL )
134 : : {
135 [ # # ]: 0 : comphelper::EmbeddedObjectContainer aCnt;
136 : 0 : ::rtl::OUString aName;
137 : :
138 : : // create Applet; it will be in running state
139 [ # # ][ # # ]: 0 : xApplet = aCnt.CreateEmbeddedObject( SvGlobalName( SO3_APPLET_CLASSID ).GetByteSequence(), aName );
[ # # ][ # # ]
[ # # ][ # # ]
140 [ # # ]: 0 : ::svt::EmbeddedObjectRef::TryRunningState( xApplet );
141 : :
142 [ # # ]: 0 : INetURLObject aUrlBase(rDocumentBaseURL);
143 [ # # ]: 0 : aUrlBase.removeSegment();
144 : :
145 [ # # ]: 0 : ::rtl::OUString sDocBase = aUrlBase.GetMainURL(INetURLObject::NO_DECODE);
146 [ # # ][ # # ]: 0 : uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
[ # # ]
147 [ # # ]: 0 : if ( xSet.is() )
148 : : {
149 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletCode")), uno::makeAny( rCode ) );
[ # # ][ # # ]
150 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletName")), uno::makeAny( rName ) );
[ # # ][ # # ]
151 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletIsScript")), uno::makeAny( sal_Bool(bMayScript) ) );
[ # # ][ # # ]
152 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletDocBase")), uno::makeAny( sDocBase ) );
[ # # ][ # # ]
153 [ # # ]: 0 : if ( !rCodeBase.isEmpty() )
154 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletCodeBase")), uno::makeAny( rCodeBase ) );
[ # # ][ # # ]
155 : : else
156 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletCodeBase")), uno::makeAny( sDocBase ) );
[ # # ][ # # ]
157 [ # # ][ # # ]: 0 : }
158 : 0 : }
159 : : #ifdef SOLAR_JAVA
160 : 0 : sal_Bool SwApplet_Impl::CreateApplet( const ::rtl::OUString& rBaseURL )
161 : : {
162 : 0 : ::rtl::OUString aCode, aName, aCodeBase;
163 : 0 : sal_Bool bMayScript = sal_False;
164 : :
165 : 0 : size_t nArgCount = aCommandList.size();
166 [ # # ]: 0 : for( size_t i = 0; i < nArgCount; i++ )
167 : : {
168 [ # # ]: 0 : const SvCommand& rArg = aCommandList[i];
169 : 0 : const ::rtl::OUString& rName = rArg.GetCommand();
170 [ # # ]: 0 : if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_code ) )
171 : 0 : aCode = rArg.GetArgument();
172 [ # # ]: 0 : else if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_codebase ) )
173 [ # # ]: 0 : aCodeBase = INetURLObject::GetAbsURL( rBaseURL, rArg.GetArgument() );
174 [ # # ]: 0 : else if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_name ) )
175 : 0 : aName = rArg.GetArgument();
176 [ # # ]: 0 : else if( rName.equalsIgnoreAsciiCaseAscii( OOO_STRING_SVTOOLS_HTML_O_mayscript ) )
177 : 0 : bMayScript = sal_True;
178 : 0 : }
179 : :
180 [ # # ]: 0 : if( aCode.isEmpty() )
181 : 0 : return sal_False;
182 [ # # ]: 0 : CreateApplet( aCode, aName, bMayScript, aCodeBase, rBaseURL );
183 : 0 : return sal_True;
184 : : }
185 : : #endif
186 : :
187 [ # # ]: 0 : SwApplet_Impl::~SwApplet_Impl()
188 : : {
189 : 0 : }
190 : 0 : void SwApplet_Impl::FinishApplet()
191 : : {
192 [ # # ][ # # ]: 0 : uno::Reference < beans::XPropertySet > xSet( xApplet->getComponent(), uno::UNO_QUERY );
[ # # ]
193 [ # # ]: 0 : if ( xSet.is() )
194 : : {
195 [ # # ]: 0 : uno::Sequence < beans::PropertyValue > aProps;
196 [ # # ]: 0 : aCommandList.FillSequence( aProps );
197 [ # # ][ # # ]: 0 : xSet->setPropertyValue( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AppletCommands")), uno::makeAny( aProps ) );
[ # # ][ # # ]
[ # # ]
198 : 0 : }
199 : 0 : }
200 : :
201 : : #ifdef SOLAR_JAVA
202 : 0 : void SwApplet_Impl::AppendParam( const ::rtl::OUString& rName, const ::rtl::OUString& rValue )
203 : : {
204 : 0 : aCommandList.Append( rName, rValue );
205 : 0 : }
206 : : #endif
207 : :
208 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|