1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir 
28*cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
29*cdf0e10cSrcweir #include "precompiled_desktop.hxx"
30*cdf0e10cSrcweir 
31*cdf0e10cSrcweir #include "cppuhelper/implbase4.hxx"
32*cdf0e10cSrcweir #include "cppuhelper/implementationentry.hxx"
33*cdf0e10cSrcweir #include "rtl/ustrbuf.hxx"
34*cdf0e10cSrcweir #include "rtl/ustring.h"
35*cdf0e10cSrcweir #include "rtl/ustring.hxx"
36*cdf0e10cSrcweir #include "rtl/bootstrap.hxx"
37*cdf0e10cSrcweir #include "sal/types.h"
38*cdf0e10cSrcweir #include "sal/config.h"
39*cdf0e10cSrcweir #include "boost/scoped_array.hpp"
40*cdf0e10cSrcweir #include "com/sun/star/lang/XServiceInfo.hpp"
41*cdf0e10cSrcweir #include "com/sun/star/lang/XInitialization.hpp"
42*cdf0e10cSrcweir #include "com/sun/star/lang/WrappedTargetException.hpp"
43*cdf0e10cSrcweir #include "com/sun/star/task/XJob.hpp"
44*cdf0e10cSrcweir #include "com/sun/star/configuration/backend/XLayer.hpp"
45*cdf0e10cSrcweir #include "com/sun/star/configuration/backend/XLayerHandler.hpp"
46*cdf0e10cSrcweir #include "com/sun/star/configuration/backend/MalformedDataException.hpp"
47*cdf0e10cSrcweir #include "com/sun/star/configuration/backend/TemplateIdentifier.hpp"
48*cdf0e10cSrcweir #include "jvmfwk/framework.h"
49*cdf0e10cSrcweir #include "jvmfwk.hxx"
50*cdf0e10cSrcweir #include <stack>
51*cdf0e10cSrcweir #include <stdio.h>
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir #include "osl/thread.hxx"
54*cdf0e10cSrcweir #define OUSTR(x) rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( x ))
55*cdf0e10cSrcweir 
56*cdf0e10cSrcweir #define SERVICE_NAME "com.sun.star.migration.Java"
57*cdf0e10cSrcweir #define IMPL_NAME "com.sun.star.comp.desktop.migration.Java"
58*cdf0e10cSrcweir 
59*cdf0e10cSrcweir #define ENABLE_JAVA     1
60*cdf0e10cSrcweir #define USER_CLASS_PATH 2
61*cdf0e10cSrcweir 
62*cdf0e10cSrcweir namespace css = com::sun::star;
63*cdf0e10cSrcweir using namespace rtl;
64*cdf0e10cSrcweir using namespace com::sun::star::uno;
65*cdf0e10cSrcweir using namespace com::sun::star::beans;
66*cdf0e10cSrcweir using namespace com::sun::star::lang;
67*cdf0e10cSrcweir using namespace com::sun::star::configuration::backend;
68*cdf0e10cSrcweir 
69*cdf0e10cSrcweir namespace migration
70*cdf0e10cSrcweir {
71*cdf0e10cSrcweir 
72*cdf0e10cSrcweir class CJavaInfo
73*cdf0e10cSrcweir {
74*cdf0e10cSrcweir     CJavaInfo(const CJavaInfo&);
75*cdf0e10cSrcweir     CJavaInfo& operator = (const CJavaInfo&);
76*cdf0e10cSrcweir public:
77*cdf0e10cSrcweir     JavaInfo* pData;
78*cdf0e10cSrcweir     CJavaInfo();
79*cdf0e10cSrcweir     ~CJavaInfo();
80*cdf0e10cSrcweir     operator JavaInfo* ();
81*cdf0e10cSrcweir };
82*cdf0e10cSrcweir 
83*cdf0e10cSrcweir CJavaInfo::CJavaInfo(): pData(NULL)
84*cdf0e10cSrcweir {
85*cdf0e10cSrcweir }
86*cdf0e10cSrcweir 
87*cdf0e10cSrcweir CJavaInfo::~CJavaInfo()
88*cdf0e10cSrcweir {
89*cdf0e10cSrcweir     jfw_freeJavaInfo(pData);
90*cdf0e10cSrcweir }
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir CJavaInfo::operator JavaInfo*()
93*cdf0e10cSrcweir {
94*cdf0e10cSrcweir     return pData;
95*cdf0e10cSrcweir }
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir 
98*cdf0e10cSrcweir class JavaMigration : public ::cppu::WeakImplHelper4<
99*cdf0e10cSrcweir     css::lang::XServiceInfo,
100*cdf0e10cSrcweir     css::lang::XInitialization,
101*cdf0e10cSrcweir     css::task::XJob,
102*cdf0e10cSrcweir     css::configuration::backend::XLayerHandler>
103*cdf0e10cSrcweir {
104*cdf0e10cSrcweir public:
105*cdf0e10cSrcweir     // XServiceInfo
106*cdf0e10cSrcweir     virtual OUString SAL_CALL getImplementationName()
107*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
108*cdf0e10cSrcweir     virtual sal_Bool SAL_CALL supportsService( const OUString & rServiceName )
109*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
110*cdf0e10cSrcweir     virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames()
111*cdf0e10cSrcweir         throw (css::uno::RuntimeException);
112*cdf0e10cSrcweir 
113*cdf0e10cSrcweir 	//XInitialization
114*cdf0e10cSrcweir     virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
115*cdf0e10cSrcweir         throw(css::uno::Exception, css::uno::RuntimeException);
116*cdf0e10cSrcweir 
117*cdf0e10cSrcweir     //XJob
118*cdf0e10cSrcweir     virtual css::uno::Any SAL_CALL execute(
119*cdf0e10cSrcweir         const css::uno::Sequence<css::beans::NamedValue >& Arguments )
120*cdf0e10cSrcweir         throw (css::lang::IllegalArgumentException, css::uno::Exception,
121*cdf0e10cSrcweir                css::uno::RuntimeException);
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir         // XLayerHandler
124*cdf0e10cSrcweir     virtual void SAL_CALL startLayer()
125*cdf0e10cSrcweir         throw(::com::sun::star::lang::WrappedTargetException);
126*cdf0e10cSrcweir 
127*cdf0e10cSrcweir     virtual void SAL_CALL endLayer()
128*cdf0e10cSrcweir         throw(
129*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
130*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir     virtual void SAL_CALL overrideNode(
133*cdf0e10cSrcweir             const rtl::OUString& aName,
134*cdf0e10cSrcweir             sal_Int16 aAttributes,
135*cdf0e10cSrcweir             sal_Bool bClear)
136*cdf0e10cSrcweir         throw(
137*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
138*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir     virtual void SAL_CALL addOrReplaceNode(
141*cdf0e10cSrcweir             const rtl::OUString& aName,
142*cdf0e10cSrcweir             sal_Int16 aAttributes)
143*cdf0e10cSrcweir         throw(
144*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
145*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
146*cdf0e10cSrcweir 
147*cdf0e10cSrcweir     virtual void SAL_CALL  addOrReplaceNodeFromTemplate(
148*cdf0e10cSrcweir             const rtl::OUString& aName,
149*cdf0e10cSrcweir             const ::com::sun::star::configuration::backend::TemplateIdentifier& aTemplate,
150*cdf0e10cSrcweir             sal_Int16 aAttributes )
151*cdf0e10cSrcweir         throw(
152*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
153*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
154*cdf0e10cSrcweir 
155*cdf0e10cSrcweir     virtual void SAL_CALL  endNode()
156*cdf0e10cSrcweir         throw(
157*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
158*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir     virtual void SAL_CALL  dropNode(
161*cdf0e10cSrcweir             const rtl::OUString& aName )
162*cdf0e10cSrcweir         throw(
163*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
164*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
165*cdf0e10cSrcweir 
166*cdf0e10cSrcweir     virtual void SAL_CALL  overrideProperty(
167*cdf0e10cSrcweir             const rtl::OUString& aName,
168*cdf0e10cSrcweir             sal_Int16 aAttributes,
169*cdf0e10cSrcweir             const css::uno::Type& aType,
170*cdf0e10cSrcweir             sal_Bool bClear )
171*cdf0e10cSrcweir         throw(
172*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
173*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir     virtual void SAL_CALL  setPropertyValue(
176*cdf0e10cSrcweir             const css::uno::Any& aValue )
177*cdf0e10cSrcweir         throw(
178*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
179*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
180*cdf0e10cSrcweir 
181*cdf0e10cSrcweir     virtual void SAL_CALL setPropertyValueForLocale(
182*cdf0e10cSrcweir             const css::uno::Any& aValue,
183*cdf0e10cSrcweir             const rtl::OUString& aLocale )
184*cdf0e10cSrcweir         throw(
185*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
186*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir     virtual void SAL_CALL  endProperty()
189*cdf0e10cSrcweir         throw(
190*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
191*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
192*cdf0e10cSrcweir 
193*cdf0e10cSrcweir     virtual void SAL_CALL  addProperty(
194*cdf0e10cSrcweir             const rtl::OUString& aName,
195*cdf0e10cSrcweir             sal_Int16 aAttributes,
196*cdf0e10cSrcweir             const css::uno::Type& aType )
197*cdf0e10cSrcweir         throw(
198*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
199*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
200*cdf0e10cSrcweir 
201*cdf0e10cSrcweir     virtual void SAL_CALL  addPropertyWithValue(
202*cdf0e10cSrcweir             const rtl::OUString& aName,
203*cdf0e10cSrcweir             sal_Int16 aAttributes,
204*cdf0e10cSrcweir             const css::uno::Any& aValue )
205*cdf0e10cSrcweir         throw(
206*cdf0e10cSrcweir             ::com::sun::star::configuration::backend::MalformedDataException,
207*cdf0e10cSrcweir             ::com::sun::star::lang::WrappedTargetException );
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir 
210*cdf0e10cSrcweir 
211*cdf0e10cSrcweir     //----------------
212*cdf0e10cSrcweir     ~JavaMigration();
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir private:
215*cdf0e10cSrcweir     OUString m_sUserDir;
216*cdf0e10cSrcweir 	css::uno::Reference< ::css::configuration::backend::XLayer>	m_xLayer;
217*cdf0e10cSrcweir 
218*cdf0e10cSrcweir     void migrateJavarc();
219*cdf0e10cSrcweir     typedef ::std::pair< ::rtl::OUString,	sal_Int16>	TElementType;
220*cdf0e10cSrcweir     typedef ::std::stack< TElementType > TElementStack;
221*cdf0e10cSrcweir     TElementStack m_aStack;
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir };
224*cdf0e10cSrcweir 
225*cdf0e10cSrcweir JavaMigration::~JavaMigration()
226*cdf0e10cSrcweir {
227*cdf0e10cSrcweir     OSL_ASSERT(m_aStack.empty());
228*cdf0e10cSrcweir }
229*cdf0e10cSrcweir 
230*cdf0e10cSrcweir OUString jvmfwk_getImplementationName()
231*cdf0e10cSrcweir {
232*cdf0e10cSrcweir     return OUSTR(IMPL_NAME);
233*cdf0e10cSrcweir }
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir css::uno::Sequence< OUString > jvmfwk_getSupportedServiceNames()
236*cdf0e10cSrcweir {
237*cdf0e10cSrcweir     OUString str_name = OUSTR(SERVICE_NAME);
238*cdf0e10cSrcweir     return css::uno::Sequence< OUString >( &str_name, 1 );
239*cdf0e10cSrcweir }
240*cdf0e10cSrcweir 
241*cdf0e10cSrcweir // XServiceInfo
242*cdf0e10cSrcweir OUString SAL_CALL JavaMigration::getImplementationName()
243*cdf0e10cSrcweir     throw (css::uno::RuntimeException)
244*cdf0e10cSrcweir {
245*cdf0e10cSrcweir     return jvmfwk_getImplementationName();
246*cdf0e10cSrcweir }
247*cdf0e10cSrcweir 
248*cdf0e10cSrcweir sal_Bool SAL_CALL JavaMigration::supportsService( const OUString & rServiceName )
249*cdf0e10cSrcweir         throw (css::uno::RuntimeException)
250*cdf0e10cSrcweir {
251*cdf0e10cSrcweir     css::uno::Sequence< OUString > const & rSNL = getSupportedServiceNames();
252*cdf0e10cSrcweir     OUString const * pArray = rSNL.getConstArray();
253*cdf0e10cSrcweir     for ( sal_Int32 nPos = rSNL.getLength(); nPos--; )
254*cdf0e10cSrcweir     {
255*cdf0e10cSrcweir         if (rServiceName.equals( pArray[ nPos ] ))
256*cdf0e10cSrcweir             return true;
257*cdf0e10cSrcweir     }
258*cdf0e10cSrcweir     return false;
259*cdf0e10cSrcweir 
260*cdf0e10cSrcweir }
261*cdf0e10cSrcweir 
262*cdf0e10cSrcweir css::uno::Sequence< OUString > SAL_CALL JavaMigration::getSupportedServiceNames()
263*cdf0e10cSrcweir         throw (css::uno::RuntimeException)
264*cdf0e10cSrcweir {
265*cdf0e10cSrcweir     return jvmfwk_getSupportedServiceNames();
266*cdf0e10cSrcweir }
267*cdf0e10cSrcweir 
268*cdf0e10cSrcweir //XInitialization ----------------------------------------------------------------------
269*cdf0e10cSrcweir void SAL_CALL JavaMigration::initialize( const css::uno::Sequence< css::uno::Any >& aArguments )
270*cdf0e10cSrcweir         throw(css::uno::Exception, css::uno::RuntimeException)
271*cdf0e10cSrcweir {
272*cdf0e10cSrcweir     const css::uno::Any* pIter = aArguments.getConstArray();
273*cdf0e10cSrcweir 	const css::uno::Any* pEnd = pIter + aArguments.getLength();
274*cdf0e10cSrcweir 	css::uno::Sequence<css::beans::NamedValue> aOldConfigValues;
275*cdf0e10cSrcweir 	css::beans::NamedValue aValue;
276*cdf0e10cSrcweir 	for(;pIter != pEnd;++pIter)
277*cdf0e10cSrcweir 	{
278*cdf0e10cSrcweir 		*pIter >>= aValue;
279*cdf0e10cSrcweir 		if (aValue.Name.equalsAscii("OldConfiguration"))
280*cdf0e10cSrcweir 		{
281*cdf0e10cSrcweir             sal_Bool bSuccess = aValue.Value >>= aOldConfigValues;
282*cdf0e10cSrcweir             OSL_ENSURE(bSuccess == sal_True, "[Service implementation " IMPL_NAME
283*cdf0e10cSrcweir                        "] XInitialization::initialize: Argument OldConfiguration has wrong type.");
284*cdf0e10cSrcweir             if (bSuccess)
285*cdf0e10cSrcweir             {
286*cdf0e10cSrcweir                 const css::beans::NamedValue* pIter2 = aOldConfigValues.getConstArray();
287*cdf0e10cSrcweir                 const css::beans::NamedValue* pEnd2 = pIter2 + aOldConfigValues.getLength();
288*cdf0e10cSrcweir                 for(;pIter2 != pEnd2;++pIter2)
289*cdf0e10cSrcweir                 {
290*cdf0e10cSrcweir                     if ( pIter2->Name.equalsAscii("org.openoffice.Office.Java") )
291*cdf0e10cSrcweir                     {
292*cdf0e10cSrcweir                         pIter2->Value >>= m_xLayer;
293*cdf0e10cSrcweir                         break;
294*cdf0e10cSrcweir                     }
295*cdf0e10cSrcweir                 }
296*cdf0e10cSrcweir 			}
297*cdf0e10cSrcweir 		}
298*cdf0e10cSrcweir         else if (aValue.Name.equalsAscii("UserData"))
299*cdf0e10cSrcweir         {
300*cdf0e10cSrcweir             if ( !(aValue.Value >>= m_sUserDir) )
301*cdf0e10cSrcweir             {
302*cdf0e10cSrcweir                 OSL_ENSURE(
303*cdf0e10cSrcweir                     false,
304*cdf0e10cSrcweir                     "[Service implementation " IMPL_NAME
305*cdf0e10cSrcweir                     "] XInitialization::initialize: Argument UserData has wrong type.");
306*cdf0e10cSrcweir             }
307*cdf0e10cSrcweir         }
308*cdf0e10cSrcweir 	}
309*cdf0e10cSrcweir 
310*cdf0e10cSrcweir }
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir //XJob
313*cdf0e10cSrcweir css::uno::Any SAL_CALL JavaMigration::execute(
314*cdf0e10cSrcweir         const css::uno::Sequence<css::beans::NamedValue >& )
315*cdf0e10cSrcweir         throw (css::lang::IllegalArgumentException, css::uno::Exception,
316*cdf0e10cSrcweir                css::uno::RuntimeException)
317*cdf0e10cSrcweir {
318*cdf0e10cSrcweir     migrateJavarc();
319*cdf0e10cSrcweir     if (m_xLayer.is())
320*cdf0e10cSrcweir         m_xLayer->readData(this);
321*cdf0e10cSrcweir 
322*cdf0e10cSrcweir     return css::uno::Any();
323*cdf0e10cSrcweir }
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir void JavaMigration::migrateJavarc()
326*cdf0e10cSrcweir {
327*cdf0e10cSrcweir     if (m_sUserDir.getLength() == 0)
328*cdf0e10cSrcweir         return;
329*cdf0e10cSrcweir 
330*cdf0e10cSrcweir     OUString sValue;
331*cdf0e10cSrcweir     rtl::Bootstrap javaini(m_sUserDir + OUSTR("/user/config/"SAL_CONFIGFILE("java")));
332*cdf0e10cSrcweir     sal_Bool bSuccess = javaini.getFrom(OUSTR("Home"), sValue);
333*cdf0e10cSrcweir     OSL_ENSURE(bSuccess, "[Service implementation " IMPL_NAME
334*cdf0e10cSrcweir                        "] XJob::execute: Could not get Home entry from java.ini/javarc.");
335*cdf0e10cSrcweir     if (bSuccess == sal_True && sValue.getLength() > 0)
336*cdf0e10cSrcweir     {
337*cdf0e10cSrcweir         //get the directory
338*cdf0e10cSrcweir         CJavaInfo aInfo;
339*cdf0e10cSrcweir         javaFrameworkError err = jfw_getJavaInfoByPath(sValue.pData, &aInfo.pData);
340*cdf0e10cSrcweir 
341*cdf0e10cSrcweir         if (err == JFW_E_NONE)
342*cdf0e10cSrcweir         {
343*cdf0e10cSrcweir             if (jfw_setSelectedJRE(aInfo) != JFW_E_NONE)
344*cdf0e10cSrcweir             {
345*cdf0e10cSrcweir                 OSL_ENSURE(0, "[Service implementation " IMPL_NAME
346*cdf0e10cSrcweir                            "] XJob::execute: jfw_setSelectedJRE failed.");
347*cdf0e10cSrcweir                 fprintf(stderr, "\nCannot migrate Java. An error occured.\n");
348*cdf0e10cSrcweir             }
349*cdf0e10cSrcweir         }
350*cdf0e10cSrcweir         else if (err == JFW_E_FAILED_VERSION)
351*cdf0e10cSrcweir         {
352*cdf0e10cSrcweir             fprintf(stderr, "\nCannot migrate Java settings because the version of the Java  "
353*cdf0e10cSrcweir                     "is not supported anymore.\n");
354*cdf0e10cSrcweir         }
355*cdf0e10cSrcweir     }
356*cdf0e10cSrcweir }
357*cdf0e10cSrcweir 
358*cdf0e10cSrcweir 
359*cdf0e10cSrcweir // XLayerHandler
360*cdf0e10cSrcweir void SAL_CALL JavaMigration::startLayer()
361*cdf0e10cSrcweir     throw(css::lang::WrappedTargetException)
362*cdf0e10cSrcweir {
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir // -----------------------------------------------------------------------------
365*cdf0e10cSrcweir 
366*cdf0e10cSrcweir void SAL_CALL JavaMigration::endLayer()
367*cdf0e10cSrcweir     throw(
368*cdf0e10cSrcweir         MalformedDataException,
369*cdf0e10cSrcweir         WrappedTargetException )
370*cdf0e10cSrcweir {
371*cdf0e10cSrcweir }
372*cdf0e10cSrcweir // -----------------------------------------------------------------------------
373*cdf0e10cSrcweir 
374*cdf0e10cSrcweir void SAL_CALL JavaMigration::overrideNode(
375*cdf0e10cSrcweir         const ::rtl::OUString&,
376*cdf0e10cSrcweir         sal_Int16,
377*cdf0e10cSrcweir         sal_Bool)
378*cdf0e10cSrcweir     throw(
379*cdf0e10cSrcweir         MalformedDataException,
380*cdf0e10cSrcweir         WrappedTargetException )
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir {
383*cdf0e10cSrcweir 
384*cdf0e10cSrcweir }
385*cdf0e10cSrcweir // -----------------------------------------------------------------------------
386*cdf0e10cSrcweir 
387*cdf0e10cSrcweir void SAL_CALL JavaMigration::addOrReplaceNode(
388*cdf0e10cSrcweir         const ::rtl::OUString&,
389*cdf0e10cSrcweir         sal_Int16)
390*cdf0e10cSrcweir     throw(
391*cdf0e10cSrcweir         MalformedDataException,
392*cdf0e10cSrcweir         WrappedTargetException )
393*cdf0e10cSrcweir {
394*cdf0e10cSrcweir 
395*cdf0e10cSrcweir }
396*cdf0e10cSrcweir void SAL_CALL  JavaMigration::endNode()
397*cdf0e10cSrcweir     throw(
398*cdf0e10cSrcweir         MalformedDataException,
399*cdf0e10cSrcweir         WrappedTargetException )
400*cdf0e10cSrcweir {
401*cdf0e10cSrcweir }
402*cdf0e10cSrcweir // -----------------------------------------------------------------------------
403*cdf0e10cSrcweir 
404*cdf0e10cSrcweir void SAL_CALL  JavaMigration::dropNode(
405*cdf0e10cSrcweir         const ::rtl::OUString& )
406*cdf0e10cSrcweir     throw(
407*cdf0e10cSrcweir         MalformedDataException,
408*cdf0e10cSrcweir         WrappedTargetException )
409*cdf0e10cSrcweir {
410*cdf0e10cSrcweir }
411*cdf0e10cSrcweir // -----------------------------------------------------------------------------
412*cdf0e10cSrcweir 
413*cdf0e10cSrcweir void SAL_CALL  JavaMigration::overrideProperty(
414*cdf0e10cSrcweir         const ::rtl::OUString& aName,
415*cdf0e10cSrcweir         sal_Int16,
416*cdf0e10cSrcweir         const Type&,
417*cdf0e10cSrcweir         sal_Bool )
418*cdf0e10cSrcweir     throw(
419*cdf0e10cSrcweir         MalformedDataException,
420*cdf0e10cSrcweir         WrappedTargetException )
421*cdf0e10cSrcweir {
422*cdf0e10cSrcweir     if (aName.equalsAscii("Enable"))
423*cdf0e10cSrcweir         m_aStack.push(TElementStack::value_type(aName,ENABLE_JAVA));
424*cdf0e10cSrcweir     else if (aName.equalsAscii("UserClassPath"))
425*cdf0e10cSrcweir         m_aStack.push(TElementStack::value_type(aName, USER_CLASS_PATH));
426*cdf0e10cSrcweir }
427*cdf0e10cSrcweir // -----------------------------------------------------------------------------
428*cdf0e10cSrcweir 
429*cdf0e10cSrcweir void SAL_CALL  JavaMigration::setPropertyValue(
430*cdf0e10cSrcweir         const Any& aValue )
431*cdf0e10cSrcweir     throw(
432*cdf0e10cSrcweir         MalformedDataException,
433*cdf0e10cSrcweir         WrappedTargetException )
434*cdf0e10cSrcweir {
435*cdf0e10cSrcweir     if ( !m_aStack.empty())
436*cdf0e10cSrcweir     {
437*cdf0e10cSrcweir         switch (m_aStack.top().second)
438*cdf0e10cSrcweir         {
439*cdf0e10cSrcweir         case ENABLE_JAVA:
440*cdf0e10cSrcweir         {
441*cdf0e10cSrcweir             sal_Bool val = sal_Bool();
442*cdf0e10cSrcweir             if ((aValue >>= val) == sal_False)
443*cdf0e10cSrcweir                 throw MalformedDataException(
444*cdf0e10cSrcweir                     OUSTR("[Service implementation " IMPL_NAME
445*cdf0e10cSrcweir                        "] XLayerHandler::setPropertyValue received wrong type for Enable property"), 0, Any());
446*cdf0e10cSrcweir             if (jfw_setEnabled(val) != JFW_E_NONE)
447*cdf0e10cSrcweir                 throw WrappedTargetException(
448*cdf0e10cSrcweir                     OUSTR("[Service implementation " IMPL_NAME
449*cdf0e10cSrcweir                        "] XLayerHandler::setPropertyValue: jfw_setEnabled failed."), 0, Any());
450*cdf0e10cSrcweir 
451*cdf0e10cSrcweir             break;
452*cdf0e10cSrcweir         }
453*cdf0e10cSrcweir         case USER_CLASS_PATH:
454*cdf0e10cSrcweir          {
455*cdf0e10cSrcweir              OUString cp;
456*cdf0e10cSrcweir              if ((aValue >>= cp) == sal_False)
457*cdf0e10cSrcweir                  throw MalformedDataException(
458*cdf0e10cSrcweir                      OUSTR("[Service implementation " IMPL_NAME
459*cdf0e10cSrcweir                            "] XLayerHandler::setPropertyValue received wrong type for UserClassPath property"), 0, Any());
460*cdf0e10cSrcweir 
461*cdf0e10cSrcweir              if (jfw_setUserClassPath(cp.pData) != JFW_E_NONE)
462*cdf0e10cSrcweir                  throw WrappedTargetException(
463*cdf0e10cSrcweir                      OUSTR("[Service implementation " IMPL_NAME
464*cdf0e10cSrcweir                        "] XLayerHandler::setPropertyValue: jfw_setUserClassPath failed."), 0, Any());
465*cdf0e10cSrcweir              break;
466*cdf0e10cSrcweir          }
467*cdf0e10cSrcweir         default:
468*cdf0e10cSrcweir             OSL_ASSERT(0);
469*cdf0e10cSrcweir         }
470*cdf0e10cSrcweir     }
471*cdf0e10cSrcweir }
472*cdf0e10cSrcweir // -----------------------------------------------------------------------------
473*cdf0e10cSrcweir 
474*cdf0e10cSrcweir void SAL_CALL JavaMigration::setPropertyValueForLocale(
475*cdf0e10cSrcweir         const Any&,
476*cdf0e10cSrcweir         const ::rtl::OUString& )
477*cdf0e10cSrcweir     throw(
478*cdf0e10cSrcweir         MalformedDataException,
479*cdf0e10cSrcweir         WrappedTargetException )
480*cdf0e10cSrcweir {
481*cdf0e10cSrcweir }
482*cdf0e10cSrcweir // -----------------------------------------------------------------------------
483*cdf0e10cSrcweir 
484*cdf0e10cSrcweir void SAL_CALL  JavaMigration::endProperty()
485*cdf0e10cSrcweir     throw(
486*cdf0e10cSrcweir         MalformedDataException,
487*cdf0e10cSrcweir         WrappedTargetException )
488*cdf0e10cSrcweir {
489*cdf0e10cSrcweir         	if (!m_aStack.empty())
490*cdf0e10cSrcweir                 m_aStack.pop();
491*cdf0e10cSrcweir }
492*cdf0e10cSrcweir // -----------------------------------------------------------------------------
493*cdf0e10cSrcweir 
494*cdf0e10cSrcweir void SAL_CALL  JavaMigration::addProperty(
495*cdf0e10cSrcweir         const rtl::OUString&,
496*cdf0e10cSrcweir         sal_Int16,
497*cdf0e10cSrcweir         const Type& )
498*cdf0e10cSrcweir     throw(
499*cdf0e10cSrcweir         MalformedDataException,
500*cdf0e10cSrcweir         WrappedTargetException )
501*cdf0e10cSrcweir {
502*cdf0e10cSrcweir }
503*cdf0e10cSrcweir // -----------------------------------------------------------------------------
504*cdf0e10cSrcweir 
505*cdf0e10cSrcweir void SAL_CALL  JavaMigration::addPropertyWithValue(
506*cdf0e10cSrcweir         const rtl::OUString&,
507*cdf0e10cSrcweir         sal_Int16,
508*cdf0e10cSrcweir         const Any& )
509*cdf0e10cSrcweir     throw(
510*cdf0e10cSrcweir         MalformedDataException,
511*cdf0e10cSrcweir         WrappedTargetException )
512*cdf0e10cSrcweir {
513*cdf0e10cSrcweir }
514*cdf0e10cSrcweir 
515*cdf0e10cSrcweir void SAL_CALL JavaMigration::addOrReplaceNodeFromTemplate(
516*cdf0e10cSrcweir         const rtl::OUString&,
517*cdf0e10cSrcweir         const TemplateIdentifier&,
518*cdf0e10cSrcweir         sal_Int16 )
519*cdf0e10cSrcweir     throw(
520*cdf0e10cSrcweir         MalformedDataException,
521*cdf0e10cSrcweir         WrappedTargetException )
522*cdf0e10cSrcweir {
523*cdf0e10cSrcweir }
524*cdf0e10cSrcweir 
525*cdf0e10cSrcweir // -----------------------------------------------------------------------------
526*cdf0e10cSrcweir //ToDo enable java, user class path
527*cdf0e10cSrcweir 
528*cdf0e10cSrcweir } //end namespace jfw
529*cdf0e10cSrcweir 
530