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