xref: /aoo41x/main/ucb/workben/ucb/ucbdemo.cxx (revision 2f86921c)
1*2f86921cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*2f86921cSAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*2f86921cSAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*2f86921cSAndrew Rist  * distributed with this work for additional information
6*2f86921cSAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*2f86921cSAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*2f86921cSAndrew Rist  * "License"); you may not use this file except in compliance
9*2f86921cSAndrew Rist  * with the License.  You may obtain a copy of the License at
10*2f86921cSAndrew Rist  *
11*2f86921cSAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*2f86921cSAndrew Rist  *
13*2f86921cSAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*2f86921cSAndrew Rist  * software distributed under the License is distributed on an
15*2f86921cSAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*2f86921cSAndrew Rist  * KIND, either express or implied.  See the License for the
17*2f86921cSAndrew Rist  * specific language governing permissions and limitations
18*2f86921cSAndrew Rist  * under the License.
19*2f86921cSAndrew Rist  *
20*2f86921cSAndrew Rist  *************************************************************/
21*2f86921cSAndrew Rist 
22*2f86921cSAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_ucb.hxx"
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <stack>
28cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
29cdf0e10cSrcweir #include <vos/mutex.hxx>
30cdf0e10cSrcweir #include <vos/process.hxx>
31cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
32cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx>
33cdf0e10cSrcweir #include <com/sun/star/ucb/ContentAction.hpp>
34cdf0e10cSrcweir #include <com/sun/star/ucb/OpenCommandArgument2.hpp>
35cdf0e10cSrcweir #include <com/sun/star/ucb/ContentResultSetCapability.hpp>
36cdf0e10cSrcweir #include <com/sun/star/ucb/SearchCommandArgument.hpp>
37cdf0e10cSrcweir #include <com/sun/star/ucb/NameClash.hpp>
38cdf0e10cSrcweir #include <com/sun/star/ucb/TransferInfo.hpp>
39cdf0e10cSrcweir #include <com/sun/star/ucb/GlobalTransferCommandArgument.hpp>
40cdf0e10cSrcweir #include <com/sun/star/ucb/XContentIdentifierFactory.hpp>
41cdf0e10cSrcweir #include <com/sun/star/ucb/CommandInfo.hpp>
42cdf0e10cSrcweir #include <com/sun/star/ucb/XContentProviderManager.hpp>
43cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
44cdf0e10cSrcweir #include <com/sun/star/beans/Property.hpp>
45cdf0e10cSrcweir #include <com/sun/star/lang/XComponent.hpp>
46cdf0e10cSrcweir #include <com/sun/star/ucb/CHAOSProgressStart.hpp>
47cdf0e10cSrcweir #include <com/sun/star/ucb/OpenMode.hpp>
48cdf0e10cSrcweir #include <com/sun/star/ucb/ResultSetException.hpp>
49cdf0e10cSrcweir #include <com/sun/star/io/XOutputStream.hpp>
50cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
51cdf0e10cSrcweir #include <com/sun/star/beans/XPropertyContainer.hpp>
52cdf0e10cSrcweir #include <com/sun/star/ucb/XProgressHandler.hpp>
53cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandEnvironment.hpp>
54cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeListener.hpp>
55cdf0e10cSrcweir #include <com/sun/star/beans/XPropertiesChangeNotifier.hpp>
56cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandProcessor.hpp>
57cdf0e10cSrcweir #include <com/sun/star/ucb/XDynamicResultSet.hpp>
58cdf0e10cSrcweir #include <com/sun/star/sdbc/XRow.hpp>
59cdf0e10cSrcweir #include <com/sun/star/ucb/XContentAccess.hpp>
60cdf0e10cSrcweir #include <com/sun/star/ucb/XCommandInfo.hpp>
61cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
62cdf0e10cSrcweir #include <com/sun/star/ucb/XSortedDynamicResultSetFactory.hpp>
63cdf0e10cSrcweir #include <com/sun/star/bridge/XUnoUrlResolver.hpp>
64cdf0e10cSrcweir #include <comphelper/processfactory.hxx>
65cdf0e10cSrcweir #include <ucbhelper/configurationkeys.hxx>
66cdf0e10cSrcweir #include <ucbhelper/fileidentifierconverter.hxx>
67cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx>
68cdf0e10cSrcweir #include <tools/debug.hxx>
69cdf0e10cSrcweir 
70cdf0e10cSrcweir #include "tools/time.hxx"
71cdf0e10cSrcweir #include <vcl/wrkwin.hxx>
72cdf0e10cSrcweir #include <vcl/toolbox.hxx>
73cdf0e10cSrcweir #include <vcl/edit.hxx>
74cdf0e10cSrcweir #include <vcl/lstbox.hxx>
75cdf0e10cSrcweir #include <vcl/svapp.hxx>
76cdf0e10cSrcweir #include <vcl/help.hxx>
77cdf0e10cSrcweir #include <srcharg.hxx>
78cdf0e10cSrcweir 
79cdf0e10cSrcweir using ucbhelper::getLocalFileURL;
80cdf0e10cSrcweir using ucbhelper::getSystemPathFromFileURL;
81cdf0e10cSrcweir using ucbhelper::getFileURLFromSystemPath;
82cdf0e10cSrcweir 
83cdf0e10cSrcweir using namespace com::sun::star;
84cdf0e10cSrcweir 
85cdf0e10cSrcweir /*========================================================================
86cdf0e10cSrcweir  *
87cdf0e10cSrcweir  * MyOutWindow.
88cdf0e10cSrcweir  *
89cdf0e10cSrcweir  *======================================================================*/
90cdf0e10cSrcweir 
91cdf0e10cSrcweir #define MYOUTWINDOW_MAXLINES 4096
92cdf0e10cSrcweir 
93cdf0e10cSrcweir class MyOutWindow : public ListBox
94cdf0e10cSrcweir {
95cdf0e10cSrcweir public:
MyOutWindow(Window * pParent,WinBits nWinStyle)96cdf0e10cSrcweir 	MyOutWindow( Window *pParent, WinBits nWinStyle )
97cdf0e10cSrcweir 	: ListBox ( pParent, nWinStyle | WB_AUTOHSCROLL ) {}
~MyOutWindow()98cdf0e10cSrcweir 	~MyOutWindow() {}
99cdf0e10cSrcweir 
100cdf0e10cSrcweir 	void Append( const String &rLine );
101cdf0e10cSrcweir };
102cdf0e10cSrcweir 
103cdf0e10cSrcweir //-------------------------------------------------------------------------
Append(const String & rLine)104cdf0e10cSrcweir void MyOutWindow::Append( const String &rLine )
105cdf0e10cSrcweir {
106cdf0e10cSrcweir 	String aLine( rLine );
107cdf0e10cSrcweir 
108cdf0e10cSrcweir 	xub_StrLen nPos = aLine.Search( '\n' );
109cdf0e10cSrcweir 	while ( nPos != STRING_NOTFOUND )
110cdf0e10cSrcweir 	{
111cdf0e10cSrcweir 		if ( GetEntryCount() >= MYOUTWINDOW_MAXLINES )
112cdf0e10cSrcweir 			RemoveEntry( 0 );
113cdf0e10cSrcweir 
114cdf0e10cSrcweir 		InsertEntry( aLine.Copy( 0, nPos ) );
115cdf0e10cSrcweir 
116cdf0e10cSrcweir 		aLine.Erase( 0, nPos + 1 );
117cdf0e10cSrcweir 		nPos = aLine.Search( '\n' );
118cdf0e10cSrcweir 	}
119cdf0e10cSrcweir 
120cdf0e10cSrcweir 	if ( GetEntryCount() >= MYOUTWINDOW_MAXLINES )
121cdf0e10cSrcweir 		RemoveEntry( 0 );
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 	InsertEntry( aLine );
124cdf0e10cSrcweir 
125cdf0e10cSrcweir 	SetTopEntry( MYOUTWINDOW_MAXLINES - 1 );
126cdf0e10cSrcweir }
127cdf0e10cSrcweir 
128cdf0e10cSrcweir /*========================================================================
129cdf0e10cSrcweir  *
130cdf0e10cSrcweir  * MessagePrinter.
131cdf0e10cSrcweir  *
132cdf0e10cSrcweir  *=======================================================================*/
133cdf0e10cSrcweir 
134cdf0e10cSrcweir class MessagePrinter
135cdf0e10cSrcweir {
136cdf0e10cSrcweir protected:
137cdf0e10cSrcweir 	MyOutWindow* m_pOutEdit;
138cdf0e10cSrcweir 
139cdf0e10cSrcweir public:
MessagePrinter(MyOutWindow * pOutEdit=NULL)140cdf0e10cSrcweir 	MessagePrinter( MyOutWindow* pOutEdit = NULL )
141cdf0e10cSrcweir 	: m_pOutEdit( pOutEdit ) {}
setOutEdit(MyOutWindow * pOutEdit)142cdf0e10cSrcweir 	void setOutEdit( MyOutWindow* pOutEdit )
143cdf0e10cSrcweir 	{ m_pOutEdit = pOutEdit; }
144cdf0e10cSrcweir 	void print( const sal_Char* pText );
145cdf0e10cSrcweir 	void print( const UniString& rText );
146cdf0e10cSrcweir };
147cdf0e10cSrcweir 
148cdf0e10cSrcweir //-------------------------------------------------------------------------
print(const sal_Char * pText)149cdf0e10cSrcweir void MessagePrinter::print( const sal_Char* pText )
150cdf0e10cSrcweir {
151cdf0e10cSrcweir 	print( UniString::CreateFromAscii( pText ) );
152cdf0e10cSrcweir }
153cdf0e10cSrcweir 
154cdf0e10cSrcweir //-------------------------------------------------------------------------
print(const UniString & rText)155cdf0e10cSrcweir void MessagePrinter::print( const UniString& rText )
156cdf0e10cSrcweir {
157cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	if ( m_pOutEdit )
160cdf0e10cSrcweir 	{
161cdf0e10cSrcweir 		m_pOutEdit->Append( rText );
162cdf0e10cSrcweir 		m_pOutEdit->Update();
163cdf0e10cSrcweir 	}
164cdf0e10cSrcweir }
165cdf0e10cSrcweir 
166cdf0e10cSrcweir //============================================================================
167cdf0e10cSrcweir //
168cdf0e10cSrcweir //  TestOutputStream
169cdf0e10cSrcweir //
170cdf0e10cSrcweir //============================================================================
171cdf0e10cSrcweir 
172cdf0e10cSrcweir class TestOutputStream:
173cdf0e10cSrcweir 	public cppu::OWeakObject,
174cdf0e10cSrcweir     public io::XOutputStream
175cdf0e10cSrcweir {
176cdf0e10cSrcweir     rtl::OUString m_sStart;
177cdf0e10cSrcweir 	bool m_bMore;
178cdf0e10cSrcweir 
179cdf0e10cSrcweir public:
TestOutputStream()180cdf0e10cSrcweir 	TestOutputStream(): m_bMore(false) {}
181cdf0e10cSrcweir 
182cdf0e10cSrcweir     virtual uno::Any SAL_CALL queryInterface(const uno::Type & rType)
183cdf0e10cSrcweir     throw(uno::RuntimeException);
acquire()184cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ()
185cdf0e10cSrcweir 	{ OWeakObject::acquire(); }
186cdf0e10cSrcweir 
release()187cdf0e10cSrcweir     virtual void SAL_CALL release() throw ()
188cdf0e10cSrcweir 	{ OWeakObject::release(); }
189cdf0e10cSrcweir 
190cdf0e10cSrcweir     virtual void SAL_CALL writeBytes(const uno::Sequence< sal_Int8 > & rData)
191cdf0e10cSrcweir         throw(uno::RuntimeException);
192cdf0e10cSrcweir 
flush()193cdf0e10cSrcweir     virtual void SAL_CALL flush() throw() {}
194cdf0e10cSrcweir 
closeOutput()195cdf0e10cSrcweir     virtual void SAL_CALL closeOutput() throw() {};
196cdf0e10cSrcweir 
197cdf0e10cSrcweir     rtl::OUString getStart() const;
198cdf0e10cSrcweir };
199cdf0e10cSrcweir 
200cdf0e10cSrcweir //============================================================================
201cdf0e10cSrcweir // virtual
202cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)203cdf0e10cSrcweir TestOutputStream::queryInterface(const uno::Type & rType)
204cdf0e10cSrcweir     throw(uno::RuntimeException)
205cdf0e10cSrcweir {
206cdf0e10cSrcweir     uno::Any aRet = cppu::queryInterface(rType,
207cdf0e10cSrcweir                         static_cast< io::XOutputStream * >(this));
208cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface(rType);
209cdf0e10cSrcweir }
210cdf0e10cSrcweir 
211cdf0e10cSrcweir //============================================================================
212cdf0e10cSrcweir // virtual
writeBytes(const uno::Sequence<sal_Int8> & rData)213cdf0e10cSrcweir void SAL_CALL TestOutputStream::writeBytes(
214cdf0e10cSrcweir                                     const uno::Sequence< sal_Int8 > & rData)
215cdf0e10cSrcweir     throw(uno::RuntimeException)
216cdf0e10cSrcweir {
217cdf0e10cSrcweir 	sal_Int32 nLen = rData.getLength();
218cdf0e10cSrcweir 	if (m_sStart.getLength() + nLen > 500)
219cdf0e10cSrcweir 	{
220cdf0e10cSrcweir 		nLen = 500 - m_sStart.getLength();
221cdf0e10cSrcweir 		m_bMore = true;
222cdf0e10cSrcweir 	}
223cdf0e10cSrcweir 	m_sStart
224cdf0e10cSrcweir         += rtl::OUString(reinterpret_cast< const sal_Char * >(rData.
225cdf0e10cSrcweir                                                               getConstArray()),
226cdf0e10cSrcweir                          nLen, RTL_TEXTENCODING_ISO_8859_1);
227cdf0e10cSrcweir }
228cdf0e10cSrcweir 
229cdf0e10cSrcweir //============================================================================
getStart() const230cdf0e10cSrcweir rtl::OUString TestOutputStream::getStart() const
231cdf0e10cSrcweir {
232cdf0e10cSrcweir     rtl::OUString sResult = m_sStart;
233cdf0e10cSrcweir 	if (m_bMore)
234cdf0e10cSrcweir         sResult += rtl::OUString::createFromAscii("...");
235cdf0e10cSrcweir 	return sResult;
236cdf0e10cSrcweir }
237cdf0e10cSrcweir 
238cdf0e10cSrcweir /*========================================================================
239cdf0e10cSrcweir  *
240cdf0e10cSrcweir  * ProgressHandler.
241cdf0e10cSrcweir  *
242cdf0e10cSrcweir  *=======================================================================*/
243cdf0e10cSrcweir 
244cdf0e10cSrcweir class ProgressHandler:
245cdf0e10cSrcweir 	public cppu::OWeakObject,
246cdf0e10cSrcweir     public ucb::XProgressHandler
247cdf0e10cSrcweir {
248cdf0e10cSrcweir 	MessagePrinter & m_rPrinter;
249cdf0e10cSrcweir 
250cdf0e10cSrcweir     rtl::OUString toString(const uno::Any & rStatus);
251cdf0e10cSrcweir 
252cdf0e10cSrcweir public:
ProgressHandler(MessagePrinter & rThePrinter)253cdf0e10cSrcweir 	ProgressHandler(MessagePrinter & rThePrinter): m_rPrinter(rThePrinter) {}
254cdf0e10cSrcweir 
255cdf0e10cSrcweir     virtual uno::Any SAL_CALL queryInterface(
256cdf0e10cSrcweir                                 const uno::Type & rType)
257cdf0e10cSrcweir         throw(uno::RuntimeException);
258cdf0e10cSrcweir 
acquire()259cdf0e10cSrcweir     virtual void SAL_CALL acquire() throw ()
260cdf0e10cSrcweir 	{ OWeakObject::acquire(); }
261cdf0e10cSrcweir 
release()262cdf0e10cSrcweir     virtual void SAL_CALL release() throw ()
263cdf0e10cSrcweir 	{ OWeakObject::release(); }
264cdf0e10cSrcweir 
265cdf0e10cSrcweir     virtual void SAL_CALL push(const uno::Any & rStatus)
266cdf0e10cSrcweir         throw (uno::RuntimeException);
267cdf0e10cSrcweir 
268cdf0e10cSrcweir     virtual void SAL_CALL update(const uno::Any & rStatus)
269cdf0e10cSrcweir         throw (uno::RuntimeException);
270cdf0e10cSrcweir 
271cdf0e10cSrcweir     virtual void SAL_CALL pop() throw (uno::RuntimeException);
272cdf0e10cSrcweir };
273cdf0e10cSrcweir 
toString(const uno::Any & rStatus)274cdf0e10cSrcweir rtl::OUString ProgressHandler::toString(const uno::Any & rStatus)
275cdf0e10cSrcweir {
276cdf0e10cSrcweir     ucb::CHAOSProgressStart aStart;
277cdf0e10cSrcweir 	if (rStatus >>= aStart)
278cdf0e10cSrcweir 	{
279cdf0e10cSrcweir         rtl::OUString sResult;
280cdf0e10cSrcweir 		if (aStart.Text.getLength() > 0)
281cdf0e10cSrcweir 		{
282cdf0e10cSrcweir 			sResult = aStart.Text;
283cdf0e10cSrcweir             sResult += rtl::OUString::createFromAscii(" ");
284cdf0e10cSrcweir 		}
285cdf0e10cSrcweir         sResult += rtl::OUString::createFromAscii("[");
286cdf0e10cSrcweir         sResult += rtl::OUString::valueOf(aStart.Minimum);
287cdf0e10cSrcweir         sResult += rtl::OUString::createFromAscii("..");
288cdf0e10cSrcweir         sResult += rtl::OUString::valueOf(aStart.Maximum);
289cdf0e10cSrcweir         sResult += rtl::OUString::createFromAscii("]");
290cdf0e10cSrcweir 		return sResult;
291cdf0e10cSrcweir 	}
292cdf0e10cSrcweir 
293cdf0e10cSrcweir     rtl::OUString sText;
294cdf0e10cSrcweir 	if (rStatus >>= sText)
295cdf0e10cSrcweir 		return sText;
296cdf0e10cSrcweir 
297cdf0e10cSrcweir 	sal_Int32 nValue;
298cdf0e10cSrcweir 	if (rStatus >>= nValue)
299cdf0e10cSrcweir 	{
300cdf0e10cSrcweir         rtl::OUString sResult = rtl::OUString::createFromAscii("..");
301cdf0e10cSrcweir         sResult += rtl::OUString::valueOf(nValue);
302cdf0e10cSrcweir         sResult += rtl::OUString::createFromAscii("..");
303cdf0e10cSrcweir         return rtl::OUString(sResult);
304cdf0e10cSrcweir 	}
305cdf0e10cSrcweir 
306cdf0e10cSrcweir     return rtl::OUString::createFromAscii("(Unknown object)");
307cdf0e10cSrcweir }
308cdf0e10cSrcweir 
309cdf0e10cSrcweir //============================================================================
310cdf0e10cSrcweir // virtual
311cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)312cdf0e10cSrcweir ProgressHandler::queryInterface( const uno::Type & rType )
313cdf0e10cSrcweir     throw(uno::RuntimeException)
314cdf0e10cSrcweir {
315cdf0e10cSrcweir     uno::Any aRet = cppu::queryInterface(
316cdf0e10cSrcweir 						rType,
317cdf0e10cSrcweir                         static_cast< ucb::XProgressHandler* >(this));
318cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
319cdf0e10cSrcweir }
320cdf0e10cSrcweir 
321cdf0e10cSrcweir //============================================================================
322cdf0e10cSrcweir // virtual
push(const uno::Any & rStatus)323cdf0e10cSrcweir void SAL_CALL ProgressHandler::push(const uno::Any & rStatus)
324cdf0e10cSrcweir     throw (uno::RuntimeException)
325cdf0e10cSrcweir {
326cdf0e10cSrcweir     rtl::OUString sMessage = rtl::OUString::createFromAscii("Status push: ");
327cdf0e10cSrcweir 	sMessage += toString(rStatus);
328cdf0e10cSrcweir 	m_rPrinter.print(sMessage);
329cdf0e10cSrcweir }
330cdf0e10cSrcweir 
331cdf0e10cSrcweir //============================================================================
332cdf0e10cSrcweir // virtual
update(const uno::Any & rStatus)333cdf0e10cSrcweir void SAL_CALL ProgressHandler::update(const uno::Any & rStatus)
334cdf0e10cSrcweir     throw (uno::RuntimeException)
335cdf0e10cSrcweir {
336cdf0e10cSrcweir     rtl::OUString sMessage = rtl::OUString::createFromAscii("Status update: ");
337cdf0e10cSrcweir 	sMessage += toString(rStatus);
338cdf0e10cSrcweir 	m_rPrinter.print(sMessage);
339cdf0e10cSrcweir }
340cdf0e10cSrcweir 
341cdf0e10cSrcweir //============================================================================
342cdf0e10cSrcweir // virtual
pop()343cdf0e10cSrcweir void SAL_CALL ProgressHandler::pop() throw (uno::RuntimeException)
344cdf0e10cSrcweir {
345cdf0e10cSrcweir 	m_rPrinter.print("Status pop");
346cdf0e10cSrcweir }
347cdf0e10cSrcweir 
348cdf0e10cSrcweir /*========================================================================
349cdf0e10cSrcweir  *
350cdf0e10cSrcweir  * Ucb.
351cdf0e10cSrcweir  *
352cdf0e10cSrcweir  *=======================================================================*/
353cdf0e10cSrcweir 
354cdf0e10cSrcweir #define UCB_MODULE_NAME  "ucb1"
355cdf0e10cSrcweir 
356cdf0e10cSrcweir class Ucb : public MessagePrinter
357cdf0e10cSrcweir {
358cdf0e10cSrcweir private:
359cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory >      m_xFac;
360cdf0e10cSrcweir     uno::Reference< ucb::XContentProvider >          m_xProv;
361cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifierFactory > m_xIdFac;
362cdf0e10cSrcweir 	rtl::OUString m_aConfigurationKey1;
363cdf0e10cSrcweir 	rtl::OUString m_aConfigurationKey2;
364cdf0e10cSrcweir 	sal_Bool m_bInited : 1;
365cdf0e10cSrcweir 
366cdf0e10cSrcweir     static rtl::OUString getUnoURL();
367cdf0e10cSrcweir 
368cdf0e10cSrcweir public:
369cdf0e10cSrcweir     Ucb( uno::Reference< lang::XMultiServiceFactory >& rxFactory,
370cdf0e10cSrcweir 		 rtl::OUString const & rConfigurationKey1,
371cdf0e10cSrcweir 		 rtl::OUString const & rConfigurationKey2 );
372cdf0e10cSrcweir 	~Ucb();
373cdf0e10cSrcweir 
374cdf0e10cSrcweir 	sal_Bool init();
375cdf0e10cSrcweir 
getServiceFactory() const376cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > getServiceFactory() const
377cdf0e10cSrcweir 	{ return m_xFac; }
378cdf0e10cSrcweir 
379cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifierFactory >
380cdf0e10cSrcweir     getContentIdentifierFactory();
381cdf0e10cSrcweir     uno::Reference< ucb::XContentProvider >
382cdf0e10cSrcweir     getContentProvider();
383cdf0e10cSrcweir 
384cdf0e10cSrcweir     static rtl::OUString m_aProtocol;
385cdf0e10cSrcweir };
386cdf0e10cSrcweir 
387cdf0e10cSrcweir // static
388cdf0e10cSrcweir rtl::OUString Ucb::m_aProtocol;
389cdf0e10cSrcweir 
390cdf0e10cSrcweir //-------------------------------------------------------------------------
391cdf0e10cSrcweir // static
getUnoURL()392cdf0e10cSrcweir rtl::OUString Ucb::getUnoURL()
393cdf0e10cSrcweir {
394cdf0e10cSrcweir     rtl::OUString aUnoURL(rtl::OUString::createFromAscii(
395cdf0e10cSrcweir 		                 "uno:socket,host=localhost,port=8121;"));
396cdf0e10cSrcweir 	if (m_aProtocol.getLength() == 0)
397cdf0e10cSrcweir         aUnoURL += rtl::OUString::createFromAscii("urp");
398cdf0e10cSrcweir 	else
399cdf0e10cSrcweir 		aUnoURL += m_aProtocol;
400cdf0e10cSrcweir     aUnoURL += rtl::OUString::createFromAscii(";UCB.Factory");
401cdf0e10cSrcweir 	return aUnoURL;
402cdf0e10cSrcweir }
403cdf0e10cSrcweir 
404cdf0e10cSrcweir //-------------------------------------------------------------------------
Ucb(uno::Reference<lang::XMultiServiceFactory> & rxFactory,rtl::OUString const & rConfigurationKey1,rtl::OUString const & rConfigurationKey2)405cdf0e10cSrcweir Ucb::Ucb( uno::Reference< lang::XMultiServiceFactory >& rxFactory,
406cdf0e10cSrcweir 		  rtl::OUString const & rConfigurationKey1,
407cdf0e10cSrcweir 		  rtl::OUString const & rConfigurationKey2 )
408cdf0e10cSrcweir : m_xFac( rxFactory ),
409cdf0e10cSrcweir   m_aConfigurationKey1( rConfigurationKey1 ),
410cdf0e10cSrcweir   m_aConfigurationKey2( rConfigurationKey2 ),
411cdf0e10cSrcweir   m_bInited( sal_False )
412cdf0e10cSrcweir {
413cdf0e10cSrcweir }
414cdf0e10cSrcweir 
415cdf0e10cSrcweir //-------------------------------------------------------------------------
~Ucb()416cdf0e10cSrcweir Ucb::~Ucb()
417cdf0e10cSrcweir {
418cdf0e10cSrcweir }
419cdf0e10cSrcweir 
420cdf0e10cSrcweir //-------------------------------------------------------------------------
init()421cdf0e10cSrcweir sal_Bool Ucb::init()
422cdf0e10cSrcweir {
423cdf0e10cSrcweir 	if ( m_bInited )
424cdf0e10cSrcweir 		return sal_True;
425cdf0e10cSrcweir 
426cdf0e10cSrcweir 	// Create auto configured UCB:
427cdf0e10cSrcweir 	if (m_xFac.is())
428cdf0e10cSrcweir         try
429cdf0e10cSrcweir         {
430cdf0e10cSrcweir             rtl::OUString aPipe;
431cdf0e10cSrcweir             vos::OSecurity().getUserIdent(aPipe);
432cdf0e10cSrcweir             uno::Sequence< uno::Any > aArgs(4);
433cdf0e10cSrcweir             aArgs[0] <<= m_aConfigurationKey1;
434cdf0e10cSrcweir             aArgs[1] <<= m_aConfigurationKey2;
435cdf0e10cSrcweir             aArgs[2] <<= rtl::OUString::createFromAscii("PIPE");
436cdf0e10cSrcweir             aArgs[3] <<= aPipe;
437cdf0e10cSrcweir #if 0
438cdf0e10cSrcweir             m_xProv
439cdf0e10cSrcweir                 = uno::Reference< XContentProvider >(
440cdf0e10cSrcweir 					  m_xFac->
441cdf0e10cSrcweir 					      createInstanceWithArguments(
442cdf0e10cSrcweir 							  rtl::OUString::createFromAscii(
443cdf0e10cSrcweir 								  "com.sun.star.ucb."
444cdf0e10cSrcweir 								      "UniversalContentBroker"),
445cdf0e10cSrcweir 							  aArgs),
446cdf0e10cSrcweir                          uno::UNO_QUERY);
447cdf0e10cSrcweir #else
448cdf0e10cSrcweir             ::ucbhelper::ContentBroker::initialize( m_xFac, aArgs );
449cdf0e10cSrcweir             m_xProv
450cdf0e10cSrcweir                 = ::ucbhelper::ContentBroker::get()->getContentProviderInterface();
451cdf0e10cSrcweir #endif
452cdf0e10cSrcweir 		}
453cdf0e10cSrcweir         catch (uno::Exception const &) {}
454cdf0e10cSrcweir 
455cdf0e10cSrcweir 	if (m_xProv.is())
456cdf0e10cSrcweir 	{
457cdf0e10cSrcweir 		print("UCB initialized");
458cdf0e10cSrcweir         uno::Reference< ucb::XContentProviderManager > xProvMgr(
459cdf0e10cSrcweir             m_xProv, uno::UNO_QUERY);
460cdf0e10cSrcweir 		if (xProvMgr.is())
461cdf0e10cSrcweir 		{
462cdf0e10cSrcweir 			print("Registered schemes:");
463cdf0e10cSrcweir             uno::Sequence< ucb::ContentProviderInfo >
464cdf0e10cSrcweir 				aInfos(xProvMgr->queryContentProviders());
465cdf0e10cSrcweir 			for (sal_Int32 i = 0; i < aInfos.getLength(); ++i)
466cdf0e10cSrcweir 			{
467cdf0e10cSrcweir 				String aText(RTL_CONSTASCII_USTRINGPARAM("    "));
468cdf0e10cSrcweir 				aText += UniString(aInfos[i].Scheme);
469cdf0e10cSrcweir 				print(aText);
470cdf0e10cSrcweir 			}
471cdf0e10cSrcweir 		}
472cdf0e10cSrcweir 	}
473cdf0e10cSrcweir 	else
474cdf0e10cSrcweir 		print("Error initializing UCB");
475cdf0e10cSrcweir 
476cdf0e10cSrcweir 	m_bInited = m_xProv.is();
477cdf0e10cSrcweir 	return m_bInited;
478cdf0e10cSrcweir }
479cdf0e10cSrcweir 
480cdf0e10cSrcweir //-------------------------------------------------------------------------
481cdf0e10cSrcweir uno::Reference< ucb::XContentIdentifierFactory >
getContentIdentifierFactory()482cdf0e10cSrcweir Ucb::getContentIdentifierFactory()
483cdf0e10cSrcweir {
484cdf0e10cSrcweir 	if ( !m_xIdFac.is() )
485cdf0e10cSrcweir 	{
486cdf0e10cSrcweir 		if ( init() )
487cdf0e10cSrcweir             m_xIdFac = uno::Reference< ucb::XContentIdentifierFactory >(
488cdf0e10cSrcweir                             m_xProv, uno::UNO_QUERY );
489cdf0e10cSrcweir 	}
490cdf0e10cSrcweir 
491cdf0e10cSrcweir     return m_xIdFac;
492cdf0e10cSrcweir }
493cdf0e10cSrcweir 
494cdf0e10cSrcweir //-------------------------------------------------------------------------
getContentProvider()495cdf0e10cSrcweir uno::Reference< ucb::XContentProvider > Ucb::getContentProvider()
496cdf0e10cSrcweir {
497cdf0e10cSrcweir 	if ( !m_xProv.is() )
498cdf0e10cSrcweir 		init();
499cdf0e10cSrcweir 
500cdf0e10cSrcweir     return m_xProv;
501cdf0e10cSrcweir }
502cdf0e10cSrcweir 
503cdf0e10cSrcweir /*========================================================================
504cdf0e10cSrcweir  *
505cdf0e10cSrcweir  * UcbTaskEnvironment.
506cdf0e10cSrcweir  *
507cdf0e10cSrcweir  *=======================================================================*/
508cdf0e10cSrcweir 
509cdf0e10cSrcweir class UcbTaskEnvironment : public cppu::OWeakObject,
510cdf0e10cSrcweir                            public ucb::XCommandEnvironment
511cdf0e10cSrcweir {
512cdf0e10cSrcweir     uno::Reference< task::XInteractionHandler > m_xInteractionHandler;
513cdf0e10cSrcweir     uno::Reference< ucb::XProgressHandler > m_xProgressHandler;
514cdf0e10cSrcweir 
515cdf0e10cSrcweir public:
516cdf0e10cSrcweir     UcbTaskEnvironment( const uno::Reference< task::XInteractionHandler>&
517cdf0e10cSrcweir 						 rxInteractionHandler,
518cdf0e10cSrcweir                         const uno::Reference< ucb::XProgressHandler>&
519cdf0e10cSrcweir 						 rxProgressHandler );
520cdf0e10cSrcweir 	virtual ~UcbTaskEnvironment();
521cdf0e10cSrcweir 
522cdf0e10cSrcweir 	// Interface implementations...
523cdf0e10cSrcweir 
524cdf0e10cSrcweir 	// XInterface
525cdf0e10cSrcweir 
526cdf0e10cSrcweir     virtual uno::Any SAL_CALL queryInterface( const uno::Type & rType )
527cdf0e10cSrcweir         throw( uno::RuntimeException );
528cdf0e10cSrcweir     virtual void SAL_CALL acquire()
529cdf0e10cSrcweir         throw();
530cdf0e10cSrcweir     virtual void SAL_CALL release()
531cdf0e10cSrcweir         throw();
532cdf0e10cSrcweir 
533cdf0e10cSrcweir  	// XCommandEnvironemnt
534cdf0e10cSrcweir 
535cdf0e10cSrcweir     virtual uno::Reference<task::XInteractionHandler> SAL_CALL
getInteractionHandler()536cdf0e10cSrcweir     getInteractionHandler()
537cdf0e10cSrcweir         throw (uno::RuntimeException)
538cdf0e10cSrcweir 	{ return m_xInteractionHandler; }
539cdf0e10cSrcweir 
540cdf0e10cSrcweir     virtual uno::Reference<ucb::XProgressHandler> SAL_CALL
getProgressHandler()541cdf0e10cSrcweir     getProgressHandler()
542cdf0e10cSrcweir         throw (uno::RuntimeException)
543cdf0e10cSrcweir 	{ return m_xProgressHandler; }
544cdf0e10cSrcweir  };
545cdf0e10cSrcweir 
546cdf0e10cSrcweir //-------------------------------------------------------------------------
UcbTaskEnvironment(const uno::Reference<task::XInteractionHandler> & rxInteractionHandler,const uno::Reference<ucb::XProgressHandler> & rxProgressHandler)547cdf0e10cSrcweir UcbTaskEnvironment::UcbTaskEnvironment(
548cdf0e10cSrcweir                     const uno::Reference< task::XInteractionHandler >&
549cdf0e10cSrcweir 					 rxInteractionHandler,
550cdf0e10cSrcweir                     const uno::Reference< ucb::XProgressHandler >&
551cdf0e10cSrcweir 					 rxProgressHandler )
552cdf0e10cSrcweir : m_xInteractionHandler( rxInteractionHandler ),
553cdf0e10cSrcweir   m_xProgressHandler( rxProgressHandler )
554cdf0e10cSrcweir {
555cdf0e10cSrcweir }
556cdf0e10cSrcweir 
557cdf0e10cSrcweir //-------------------------------------------------------------------------
558cdf0e10cSrcweir // virtual
~UcbTaskEnvironment()559cdf0e10cSrcweir UcbTaskEnvironment::~UcbTaskEnvironment()
560cdf0e10cSrcweir {
561cdf0e10cSrcweir }
562cdf0e10cSrcweir 
563cdf0e10cSrcweir //----------------------------------------------------------------------------
564cdf0e10cSrcweir //
565cdf0e10cSrcweir // XInterface methods
566cdf0e10cSrcweir //
567cdf0e10cSrcweir //----------------------------------------------------------------------------
568cdf0e10cSrcweir 
569cdf0e10cSrcweir // virtual
570cdf0e10cSrcweir uno::Any SAL_CALL
queryInterface(const uno::Type & rType)571cdf0e10cSrcweir UcbTaskEnvironment::queryInterface( const uno::Type & rType )
572cdf0e10cSrcweir     throw( uno::RuntimeException )
573cdf0e10cSrcweir {
574cdf0e10cSrcweir     uno::Any aRet = cppu::queryInterface(
575cdf0e10cSrcweir             rType, static_cast< ucb::XCommandEnvironment* >( this ) );
576cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
577cdf0e10cSrcweir }
578cdf0e10cSrcweir 
579cdf0e10cSrcweir //----------------------------------------------------------------------------
580cdf0e10cSrcweir // virtual
acquire()581cdf0e10cSrcweir void SAL_CALL UcbTaskEnvironment::acquire()
582cdf0e10cSrcweir     throw()
583cdf0e10cSrcweir {
584cdf0e10cSrcweir 	OWeakObject::acquire();
585cdf0e10cSrcweir }
586cdf0e10cSrcweir 
587cdf0e10cSrcweir //----------------------------------------------------------------------------
588cdf0e10cSrcweir // virtual
release()589cdf0e10cSrcweir void SAL_CALL UcbTaskEnvironment::release()
590cdf0e10cSrcweir     throw()
591cdf0e10cSrcweir {
592cdf0e10cSrcweir 	OWeakObject::release();
593cdf0e10cSrcweir }
594cdf0e10cSrcweir 
595cdf0e10cSrcweir /*========================================================================
596cdf0e10cSrcweir  *
597cdf0e10cSrcweir  * UcbCommandProcessor.
598cdf0e10cSrcweir  *
599cdf0e10cSrcweir  *=======================================================================*/
600cdf0e10cSrcweir 
601cdf0e10cSrcweir class UcbCommandProcessor : public MessagePrinter
602cdf0e10cSrcweir {
603cdf0e10cSrcweir protected:
604cdf0e10cSrcweir     Ucb& m_rUCB;
605cdf0e10cSrcweir 
606cdf0e10cSrcweir private:
607cdf0e10cSrcweir     uno::Reference< ucb::XCommandProcessor > m_xProcessor;
608cdf0e10cSrcweir     sal_Int32 m_aCommandId;
609cdf0e10cSrcweir 
610cdf0e10cSrcweir public:
611cdf0e10cSrcweir 	UcbCommandProcessor( Ucb& rUCB,
612cdf0e10cSrcweir                          const uno::Reference<
613cdf0e10cSrcweir                             ucb::XCommandProcessor >& rxProcessor,
614cdf0e10cSrcweir 						 MyOutWindow* pOutEdit );
615cdf0e10cSrcweir 
616cdf0e10cSrcweir 	virtual ~UcbCommandProcessor();
617cdf0e10cSrcweir 
618cdf0e10cSrcweir     uno::Any executeCommand( const rtl::OUString& rName,
619cdf0e10cSrcweir                              const uno::Any& rArgument,
620cdf0e10cSrcweir                              bool bPrint = true );
621cdf0e10cSrcweir };
622cdf0e10cSrcweir 
623cdf0e10cSrcweir //-------------------------------------------------------------------------
UcbCommandProcessor(Ucb & rUCB,const uno::Reference<ucb::XCommandProcessor> & rxProcessor,MyOutWindow * pOutEdit)624cdf0e10cSrcweir UcbCommandProcessor::UcbCommandProcessor( Ucb& rUCB,
625cdf0e10cSrcweir                                           const uno::Reference<
626cdf0e10cSrcweir                                             ucb::XCommandProcessor >&
627cdf0e10cSrcweir 										      rxProcessor,
628cdf0e10cSrcweir 										  MyOutWindow* pOutEdit)
629cdf0e10cSrcweir : MessagePrinter( pOutEdit ),
630cdf0e10cSrcweir   m_rUCB( rUCB ),
631cdf0e10cSrcweir   m_xProcessor( rxProcessor ),
632cdf0e10cSrcweir   m_aCommandId( 0 )
633cdf0e10cSrcweir {
634cdf0e10cSrcweir 	if ( m_xProcessor.is() )
635cdf0e10cSrcweir 	{
636cdf0e10cSrcweir 		// Generally, one command identifier per thread is enough. It
637cdf0e10cSrcweir 		// can be used for all commands executed by the processor which
638cdf0e10cSrcweir 		// created this id.
639cdf0e10cSrcweir 		m_aCommandId = m_xProcessor->createCommandIdentifier();
640cdf0e10cSrcweir 	}
641cdf0e10cSrcweir }
642cdf0e10cSrcweir 
643cdf0e10cSrcweir //----------------------------------------------------------------------------
644cdf0e10cSrcweir // virtual
~UcbCommandProcessor()645cdf0e10cSrcweir UcbCommandProcessor::~UcbCommandProcessor()
646cdf0e10cSrcweir {
647cdf0e10cSrcweir }
648cdf0e10cSrcweir 
649cdf0e10cSrcweir //----------------------------------------------------------------------------
executeCommand(const rtl::OUString & rName,const uno::Any & rArgument,bool bPrint)650cdf0e10cSrcweir uno::Any UcbCommandProcessor::executeCommand( const rtl::OUString& rName,
651cdf0e10cSrcweir                                               const uno::Any& rArgument,
652cdf0e10cSrcweir                                               bool bPrint )
653cdf0e10cSrcweir {
654cdf0e10cSrcweir 	if ( m_xProcessor.is() )
655cdf0e10cSrcweir 	{
656cdf0e10cSrcweir         ucb::Command aCommand;
657cdf0e10cSrcweir 		aCommand.Name     = rName;
658cdf0e10cSrcweir 		aCommand.Handle   = -1; /* unknown */
659cdf0e10cSrcweir 		aCommand.Argument = rArgument;
660cdf0e10cSrcweir 
661cdf0e10cSrcweir         uno::Reference< task::XInteractionHandler > xInteractionHandler;
662cdf0e10cSrcweir 		if (m_rUCB.getServiceFactory().is())
663cdf0e10cSrcweir 			xInteractionHandler
664cdf0e10cSrcweir                 = uno::Reference< task::XInteractionHandler >(
665cdf0e10cSrcweir 				      m_rUCB.getServiceFactory()->
666cdf0e10cSrcweir 					      createInstance(
667cdf0e10cSrcweir                               rtl::OUString::createFromAscii(
668cdf0e10cSrcweir 								  "com.sun.star.task.InteractionHandler")),
669cdf0e10cSrcweir                       uno::UNO_QUERY);
670cdf0e10cSrcweir         uno::Reference< ucb::XProgressHandler >
671cdf0e10cSrcweir 			xProgressHandler(new ProgressHandler(m_rUCB));
672cdf0e10cSrcweir         uno::Reference< ucb::XCommandEnvironment > xEnv(
673cdf0e10cSrcweir 			new UcbTaskEnvironment( xInteractionHandler, xProgressHandler ) );
674cdf0e10cSrcweir 
675cdf0e10cSrcweir 		if ( bPrint )
676cdf0e10cSrcweir 		{
677cdf0e10cSrcweir 			UniString aText( UniString::CreateFromAscii(
678cdf0e10cSrcweir 								RTL_CONSTASCII_STRINGPARAM(
679cdf0e10cSrcweir 									"Executing command: " ) ) );
680cdf0e10cSrcweir 			aText += UniString( rName );
681cdf0e10cSrcweir 			print( aText );
682cdf0e10cSrcweir 		}
683cdf0e10cSrcweir 
684cdf0e10cSrcweir 		// Execute command
685cdf0e10cSrcweir         uno::Any aResult;
686cdf0e10cSrcweir 		bool bException = false;
687cdf0e10cSrcweir 		bool bAborted = false;
688cdf0e10cSrcweir 		try
689cdf0e10cSrcweir 		{
690cdf0e10cSrcweir 			aResult = m_xProcessor->execute( aCommand, m_aCommandId, xEnv );
691cdf0e10cSrcweir 		}
692cdf0e10cSrcweir         catch ( ucb::CommandAbortedException const & )
693cdf0e10cSrcweir 		{
694cdf0e10cSrcweir 			bAborted = true;
695cdf0e10cSrcweir 		}
696cdf0e10cSrcweir         catch ( uno::Exception const & )
697cdf0e10cSrcweir 		{
698cdf0e10cSrcweir 			bException = true;
699cdf0e10cSrcweir 		}
700cdf0e10cSrcweir 
701cdf0e10cSrcweir 		if ( bPrint )
702cdf0e10cSrcweir 		{
703cdf0e10cSrcweir 			if ( bException )
704cdf0e10cSrcweir 				print( "execute(...) threw an exception!" );
705cdf0e10cSrcweir 
706cdf0e10cSrcweir 			if ( bAborted )
707cdf0e10cSrcweir 				print( "execute(...) aborted!" );
708cdf0e10cSrcweir 
709cdf0e10cSrcweir 			if ( !bException && !bAborted )
710cdf0e10cSrcweir 				print( "execute() finished." );
711cdf0e10cSrcweir 		}
712cdf0e10cSrcweir 
713cdf0e10cSrcweir 		return aResult;
714cdf0e10cSrcweir 	}
715cdf0e10cSrcweir 
716cdf0e10cSrcweir 	print( "executeCommand failed!" );
717cdf0e10cSrcweir     return uno::Any();
718cdf0e10cSrcweir }
719cdf0e10cSrcweir 
720cdf0e10cSrcweir /*========================================================================
721cdf0e10cSrcweir  *
722cdf0e10cSrcweir  * UcbContent.
723cdf0e10cSrcweir  *
724cdf0e10cSrcweir  *=======================================================================*/
725cdf0e10cSrcweir 
726cdf0e10cSrcweir class UcbContent : public UcbCommandProcessor,
727cdf0e10cSrcweir 				   public cppu::OWeakObject,
728cdf0e10cSrcweir                    public ucb::XContentEventListener,
729cdf0e10cSrcweir                    public beans::XPropertiesChangeListener
730cdf0e10cSrcweir {
731cdf0e10cSrcweir     uno::Reference< ucb::XContent > m_xContent;
732cdf0e10cSrcweir 
733cdf0e10cSrcweir 	struct OpenStackEntry
734cdf0e10cSrcweir 	{
735cdf0e10cSrcweir         uno::Reference< ucb::XContentIdentifier > m_xIdentifier;
736cdf0e10cSrcweir         uno::Reference< ucb::XContent > m_xContent;
737cdf0e10cSrcweir 		sal_uInt32 m_nLevel;
738cdf0e10cSrcweir 		bool m_bUseIdentifier;
739cdf0e10cSrcweir 
OpenStackEntryUcbContent::OpenStackEntry740cdf0e10cSrcweir         OpenStackEntry(uno::Reference< ucb::XContentIdentifier > const &
741cdf0e10cSrcweir                         rTheIdentifier,
742cdf0e10cSrcweir 					   sal_uInt32 nTheLevel):
743cdf0e10cSrcweir 			m_xIdentifier(rTheIdentifier), m_nLevel(nTheLevel),
744cdf0e10cSrcweir 			m_bUseIdentifier(true) {}
745cdf0e10cSrcweir 
OpenStackEntryUcbContent::OpenStackEntry746cdf0e10cSrcweir         OpenStackEntry(uno::Reference< ucb::XContent > const & rTheContent,
747cdf0e10cSrcweir 					   sal_uInt32 nTheLevel):
748cdf0e10cSrcweir 			m_xContent(rTheContent), m_nLevel(nTheLevel),
749cdf0e10cSrcweir 			m_bUseIdentifier(false) {}
750cdf0e10cSrcweir 	};
751cdf0e10cSrcweir 	typedef std::stack< OpenStackEntry > OpenStack;
752cdf0e10cSrcweir 
753cdf0e10cSrcweir private:
754cdf0e10cSrcweir     UcbContent( Ucb& rUCB,
755cdf0e10cSrcweir                 uno::Reference< ucb::XContent >& rxContent,
756cdf0e10cSrcweir                 MyOutWindow* pOutEdit );
757cdf0e10cSrcweir 
758cdf0e10cSrcweir protected:
759cdf0e10cSrcweir 	virtual ~UcbContent();
760cdf0e10cSrcweir 
761cdf0e10cSrcweir public:
762cdf0e10cSrcweir 	static UcbContent* create(
763cdf0e10cSrcweir 			Ucb& rUCB, const UniString& rURL, MyOutWindow* pOutEdit );
764cdf0e10cSrcweir 	void dispose();
765cdf0e10cSrcweir 
766cdf0e10cSrcweir 	const UniString getURL() const;
767cdf0e10cSrcweir 	const UniString getType() const;
768cdf0e10cSrcweir 
769cdf0e10cSrcweir     uno::Sequence< ucb::CommandInfo > getCommands();
770cdf0e10cSrcweir     uno::Sequence< beans::Property >    getProperties();
771cdf0e10cSrcweir 
772cdf0e10cSrcweir     uno::Any  getPropertyValue( const rtl::OUString& rName );
773cdf0e10cSrcweir     void setPropertyValue( const rtl::OUString& rName, const uno::Any& rValue );
774cdf0e10cSrcweir     void addProperty     ( const rtl::OUString& rName, const uno::Any& rValue );
775cdf0e10cSrcweir     void removeProperty  ( const rtl::OUString& rName );
776cdf0e10cSrcweir 
777cdf0e10cSrcweir     rtl::OUString getStringPropertyValue( const rtl::OUString& rName );
778cdf0e10cSrcweir     void setStringPropertyValue( const rtl::OUString& rName,
779cdf0e10cSrcweir                                  const rtl::OUString& rValue );
780cdf0e10cSrcweir     void addStringProperty( const rtl::OUString& rName,
781cdf0e10cSrcweir                             const rtl::OUString& rValue );
782cdf0e10cSrcweir     void open( const rtl::OUString & rName, const UniString& rInput,
783cdf0e10cSrcweir 			   bool bPrint, bool bTiming, bool bSort,
784cdf0e10cSrcweir 			   OpenStack * pStack = 0, sal_uInt32 nLevel = 0,
785cdf0e10cSrcweir 			   sal_Int32 nFetchSize = 0 );
786cdf0e10cSrcweir 	void openAll( Ucb& rUCB, bool bPrint, bool bTiming, bool bSort,
787cdf0e10cSrcweir 				  sal_Int32 nFetchSize );
788cdf0e10cSrcweir     void transfer( const rtl::OUString& rSourceURL, sal_Bool bMove );
789cdf0e10cSrcweir 	void destroy();
790cdf0e10cSrcweir 
791cdf0e10cSrcweir 	// XInterface
792cdf0e10cSrcweir     virtual uno::Any SAL_CALL queryInterface( const uno::Type & rType )
793cdf0e10cSrcweir         throw( uno::RuntimeException );
794cdf0e10cSrcweir     virtual void SAL_CALL
795cdf0e10cSrcweir 	acquire()
796cdf0e10cSrcweir         throw();
797cdf0e10cSrcweir     virtual void SAL_CALL
798cdf0e10cSrcweir 	release()
799cdf0e10cSrcweir         throw();
800cdf0e10cSrcweir 
801cdf0e10cSrcweir 	// XEventListener
802cdf0e10cSrcweir 	// ( base interface of XContentEventListener, XPropertiesChangeListener )
803cdf0e10cSrcweir     virtual void SAL_CALL
804cdf0e10cSrcweir     disposing( const lang::EventObject& Source )
805cdf0e10cSrcweir         throw( uno::RuntimeException );
806cdf0e10cSrcweir 
807cdf0e10cSrcweir 	// XContentEventListener
808cdf0e10cSrcweir     virtual void SAL_CALL
809cdf0e10cSrcweir     contentEvent( const ucb::ContentEvent& evt )
810cdf0e10cSrcweir         throw( uno::RuntimeException );
811cdf0e10cSrcweir 
812cdf0e10cSrcweir 	// XPropertiesChangeListener
813cdf0e10cSrcweir 	virtual void SAL_CALL
814cdf0e10cSrcweir     propertiesChange( const uno::Sequence< beans::PropertyChangeEvent >& evt )
815cdf0e10cSrcweir         throw( uno::RuntimeException );
816cdf0e10cSrcweir };
817cdf0e10cSrcweir 
818cdf0e10cSrcweir //-------------------------------------------------------------------------
UcbContent(Ucb & rUCB,uno::Reference<ucb::XContent> & rxContent,MyOutWindow * pOutEdit)819cdf0e10cSrcweir UcbContent::UcbContent( Ucb& rUCB,
820cdf0e10cSrcweir                         uno::Reference< ucb::XContent >& rxContent,
821cdf0e10cSrcweir                         MyOutWindow* pOutEdit)
822cdf0e10cSrcweir : UcbCommandProcessor( rUCB,
823cdf0e10cSrcweir                        uno::Reference< ucb::XCommandProcessor >(
824cdf0e10cSrcweir                                                 rxContent, uno::UNO_QUERY ),
825cdf0e10cSrcweir 					   pOutEdit ),
826cdf0e10cSrcweir   m_xContent( rxContent )
827cdf0e10cSrcweir {
828cdf0e10cSrcweir }
829cdf0e10cSrcweir 
830cdf0e10cSrcweir //----------------------------------------------------------------------------
831cdf0e10cSrcweir // virtual
~UcbContent()832cdf0e10cSrcweir UcbContent::~UcbContent()
833cdf0e10cSrcweir {
834cdf0e10cSrcweir }
835cdf0e10cSrcweir 
836cdf0e10cSrcweir //-------------------------------------------------------------------------
837cdf0e10cSrcweir // static
create(Ucb & rUCB,const UniString & rURL,MyOutWindow * pOutEdit)838cdf0e10cSrcweir UcbContent* UcbContent::create(
839cdf0e10cSrcweir 		Ucb& rUCB, const UniString& rURL, MyOutWindow* pOutEdit )
840cdf0e10cSrcweir {
841cdf0e10cSrcweir 	if ( !rURL.Len() )
842cdf0e10cSrcweir 		return NULL;
843cdf0e10cSrcweir 
844cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
845cdf0e10cSrcweir 	// Get XContentIdentifier interface from UCB and let it create an
846cdf0e10cSrcweir 	// identifer for the given URL.
847cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
848cdf0e10cSrcweir 
849cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifierFactory > xIdFac =
850cdf0e10cSrcweir 										rUCB.getContentIdentifierFactory();
851cdf0e10cSrcweir 	if ( !xIdFac.is() )
852cdf0e10cSrcweir 		return NULL;
853cdf0e10cSrcweir 
854cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId =
855cdf0e10cSrcweir 							xIdFac->createContentIdentifier( rURL );
856cdf0e10cSrcweir 	if ( !xId.is() )
857cdf0e10cSrcweir 		return NULL;
858cdf0e10cSrcweir 
859cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
860cdf0e10cSrcweir 	// Get XContentProvider interface from UCB and let it create a
861cdf0e10cSrcweir 	// content for the given identifier.
862cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
863cdf0e10cSrcweir 
864cdf0e10cSrcweir     uno::Reference< ucb::XContentProvider > xProv
865cdf0e10cSrcweir         = rUCB.getContentProvider();
866cdf0e10cSrcweir 	if ( !xProv.is() )
867cdf0e10cSrcweir 		return NULL;
868cdf0e10cSrcweir 
869cdf0e10cSrcweir     uno::Reference< ucb::XContent > xContent;
870cdf0e10cSrcweir 	try
871cdf0e10cSrcweir 	{
872cdf0e10cSrcweir 		xContent = xProv->queryContent( xId );
873cdf0e10cSrcweir 	}
874cdf0e10cSrcweir     catch (ucb::IllegalIdentifierException const &) {}
875cdf0e10cSrcweir 	if ( !xContent.is() )
876cdf0e10cSrcweir 		return NULL;
877cdf0e10cSrcweir 
878cdf0e10cSrcweir 	UcbContent* pNew = new UcbContent( rUCB, xContent, pOutEdit );
879cdf0e10cSrcweir 	pNew->acquire();
880cdf0e10cSrcweir 
881cdf0e10cSrcweir 	// Register listener(s).
882cdf0e10cSrcweir 	xContent->addContentEventListener( pNew );
883cdf0e10cSrcweir 
884cdf0e10cSrcweir     uno::Reference< beans::XPropertiesChangeNotifier > xNotifier(
885cdf0e10cSrcweir         xContent, uno::UNO_QUERY );
886cdf0e10cSrcweir 	if ( xNotifier.is() )
887cdf0e10cSrcweir 	{
888cdf0e10cSrcweir 		// Empty sequence -> interested in any property changes.
889cdf0e10cSrcweir         xNotifier->addPropertiesChangeListener(
890cdf0e10cSrcweir             uno::Sequence< rtl::OUString >(), pNew );
891cdf0e10cSrcweir 	}
892cdf0e10cSrcweir 
893cdf0e10cSrcweir 	return pNew;
894cdf0e10cSrcweir }
895cdf0e10cSrcweir 
896cdf0e10cSrcweir //-------------------------------------------------------------------------
getURL() const897cdf0e10cSrcweir const UniString UcbContent::getURL() const
898cdf0e10cSrcweir {
899cdf0e10cSrcweir     uno::Reference< ucb::XContentIdentifier > xId(
900cdf0e10cSrcweir         m_xContent->getIdentifier() );
901cdf0e10cSrcweir 	if ( xId.is() )
902cdf0e10cSrcweir 		return UniString( xId->getContentIdentifier() );
903cdf0e10cSrcweir 
904cdf0e10cSrcweir 	return UniString();
905cdf0e10cSrcweir }
906cdf0e10cSrcweir 
907cdf0e10cSrcweir //-------------------------------------------------------------------------
getType() const908cdf0e10cSrcweir const UniString UcbContent::getType() const
909cdf0e10cSrcweir {
910cdf0e10cSrcweir 	const UniString aType( m_xContent->getContentType() );
911cdf0e10cSrcweir 	return aType;
912cdf0e10cSrcweir }
913cdf0e10cSrcweir 
914cdf0e10cSrcweir //-------------------------------------------------------------------------
dispose()915cdf0e10cSrcweir void UcbContent::dispose()
916cdf0e10cSrcweir {
917cdf0e10cSrcweir     uno::Reference< lang::XComponent > xComponent( m_xContent, uno::UNO_QUERY );
918cdf0e10cSrcweir 	if ( xComponent.is() )
919cdf0e10cSrcweir 		xComponent->dispose();
920cdf0e10cSrcweir }
921cdf0e10cSrcweir 
922cdf0e10cSrcweir //----------------------------------------------------------------------------
open(const rtl::OUString & rName,const UniString & rInput,bool bPrint,bool bTiming,bool bSort,OpenStack * pStack,sal_uInt32 nLevel,sal_Int32 nFetchSize)923cdf0e10cSrcweir void UcbContent::open( const rtl::OUString & rName, const UniString& rInput,
924cdf0e10cSrcweir 					   bool bPrint, bool bTiming, bool bSort,
925cdf0e10cSrcweir 					   OpenStack * pStack, sal_uInt32 nLevel,
926cdf0e10cSrcweir 					   sal_Int32 nFetchSize )
927cdf0e10cSrcweir {
928cdf0e10cSrcweir     uno::Any aArg;
929cdf0e10cSrcweir 
930cdf0e10cSrcweir 	bool bDoSort = false;
931cdf0e10cSrcweir 
932cdf0e10cSrcweir     ucb::OpenCommandArgument2 aOpenArg;
933cdf0e10cSrcweir 	if (rName.compareToAscii("search") == 0)
934cdf0e10cSrcweir 	{
935cdf0e10cSrcweir         ucb::SearchCommandArgument aArgument;
936cdf0e10cSrcweir 		if (!parseSearchArgument(rInput, aArgument.Info))
937cdf0e10cSrcweir 		{
938cdf0e10cSrcweir 			print("Can't parse search argument");
939cdf0e10cSrcweir 			return;
940cdf0e10cSrcweir 		}
941cdf0e10cSrcweir 		aArgument.Properties.realloc(5);
942cdf0e10cSrcweir         aArgument.Properties[0].Name = rtl::OUString::createFromAscii("Title");
943cdf0e10cSrcweir 		aArgument.Properties[0].Handle = -1;
944cdf0e10cSrcweir 		aArgument.Properties[1].Name
945cdf0e10cSrcweir             = rtl::OUString::createFromAscii("DateCreated");
946cdf0e10cSrcweir 		aArgument.Properties[1].Handle = -1;
947cdf0e10cSrcweir         aArgument.Properties[2].Name = rtl::OUString::createFromAscii("Size");
948cdf0e10cSrcweir 		aArgument.Properties[2].Handle = -1;
949cdf0e10cSrcweir         aArgument.Properties[3].Name
950cdf0e10cSrcweir             = rtl::OUString::createFromAscii("IsFolder");
951cdf0e10cSrcweir 		aArgument.Properties[3].Handle = -1;
952cdf0e10cSrcweir 		aArgument.Properties[4].Name
953cdf0e10cSrcweir             = rtl::OUString::createFromAscii("IsDocument");
954cdf0e10cSrcweir 		aArgument.Properties[4].Handle = -1;
955cdf0e10cSrcweir 		aArg <<= aArgument;
956cdf0e10cSrcweir 	}
957cdf0e10cSrcweir 	else
958cdf0e10cSrcweir 	{
959cdf0e10cSrcweir         aOpenArg.Mode = ucb::OpenMode::ALL;
960cdf0e10cSrcweir 		aOpenArg.Priority = 32768;
961cdf0e10cSrcweir //		if ( bFolder )
962cdf0e10cSrcweir 		{
963cdf0e10cSrcweir 			// Property values which shall be in the result set...
964cdf0e10cSrcweir             uno::Sequence< beans::Property > aProps( 5 );
965cdf0e10cSrcweir             beans::Property* pProps = aProps.getArray();
966cdf0e10cSrcweir             pProps[ 0 ].Name   = rtl::OUString::createFromAscii( "Title" );
967cdf0e10cSrcweir 			pProps[ 0 ].Handle = -1; // Important!
968cdf0e10cSrcweir /**/		pProps[ 0 ].Type = getCppuType(static_cast< rtl::OUString * >(0));
969cdf0e10cSrcweir 				// HACK for sorting...
970cdf0e10cSrcweir             pProps[ 1 ].Name   = rtl::OUString::createFromAscii( "DateCreated" );
971cdf0e10cSrcweir 			pProps[ 1 ].Handle = -1; // Important!
972cdf0e10cSrcweir             pProps[ 2 ].Name   = rtl::OUString::createFromAscii( "Size" );
973cdf0e10cSrcweir 			pProps[ 2 ].Handle = -1; // Important!
974cdf0e10cSrcweir             pProps[ 3 ].Name   = rtl::OUString::createFromAscii( "IsFolder" );
975cdf0e10cSrcweir 			pProps[ 3 ].Handle = -1; // Important!
976cdf0e10cSrcweir /**/		pProps[ 3 ].Type = getCppuType(static_cast< sal_Bool * >(0));
977cdf0e10cSrcweir 				// HACK for sorting...
978cdf0e10cSrcweir             pProps[ 4 ].Name   = rtl::OUString::createFromAscii( "IsDocument" );
979cdf0e10cSrcweir 			pProps[ 4 ].Handle = -1; // Important!
980cdf0e10cSrcweir 			aOpenArg.Properties = aProps;
981cdf0e10cSrcweir 
982cdf0e10cSrcweir 			bDoSort = bSort;
983cdf0e10cSrcweir 			if (bDoSort)
984cdf0e10cSrcweir 			{
985cdf0e10cSrcweir 				// Sort criteria... Note that column numbering starts with 1!
986cdf0e10cSrcweir 				aOpenArg.SortingInfo.realloc(2);
987cdf0e10cSrcweir 				// primary sort criterium: column 4 --> IsFolder
988cdf0e10cSrcweir 				aOpenArg.SortingInfo[ 0 ].ColumnIndex = 4;
989cdf0e10cSrcweir 				aOpenArg.SortingInfo[ 0 ].Ascending   = sal_False;
990cdf0e10cSrcweir 				// secondary sort criterium: column 1 --> Title
991cdf0e10cSrcweir 				aOpenArg.SortingInfo[ 1 ].ColumnIndex = 1;
992cdf0e10cSrcweir 				aOpenArg.SortingInfo[ 1 ].Ascending   = sal_True;
993cdf0e10cSrcweir 			}
994cdf0e10cSrcweir 		}
995cdf0e10cSrcweir //		else
996cdf0e10cSrcweir 			aOpenArg.Sink
997cdf0e10cSrcweir 				= static_cast< cppu::OWeakObject * >(new TestOutputStream);
998cdf0e10cSrcweir 		aArg <<= aOpenArg;
999cdf0e10cSrcweir 	}
1000cdf0e10cSrcweir 
1001cdf0e10cSrcweir //	putenv("PROT_REMOTE_ACTIVATE=1"); // to log remote uno traffic
1002cdf0e10cSrcweir 
1003cdf0e10cSrcweir 	ULONG nTime = 0;
1004cdf0e10cSrcweir 	if ( bTiming )
1005cdf0e10cSrcweir 		nTime = Time::GetSystemTicks();
1006cdf0e10cSrcweir 
1007cdf0e10cSrcweir     uno::Any aResult = executeCommand( rName, aArg, bPrint );
1008cdf0e10cSrcweir 
1009cdf0e10cSrcweir     uno::Reference< ucb::XDynamicResultSet > xDynamicResultSet;
1010cdf0e10cSrcweir 	if ( ( aResult >>= xDynamicResultSet ) && xDynamicResultSet.is() )
1011cdf0e10cSrcweir 	{
1012cdf0e10cSrcweir 		if (bDoSort)
1013cdf0e10cSrcweir 		{
1014cdf0e10cSrcweir 			sal_Int16 nCaps = xDynamicResultSet->getCapabilities();
1015cdf0e10cSrcweir             if (!(nCaps & ucb::ContentResultSetCapability::SORTED))
1016cdf0e10cSrcweir 			{
1017cdf0e10cSrcweir 				if (bPrint)
1018cdf0e10cSrcweir 					print("Result set rows are not sorted"
1019cdf0e10cSrcweir 						      "---using sorting cursor");
1020cdf0e10cSrcweir 
1021cdf0e10cSrcweir                 uno::Reference< ucb::XSortedDynamicResultSetFactory >
1022cdf0e10cSrcweir                     xSortedFactory;
1023cdf0e10cSrcweir 				if (m_rUCB.getServiceFactory().is())
1024cdf0e10cSrcweir 					xSortedFactory
1025cdf0e10cSrcweir                         = uno::Reference<
1026cdf0e10cSrcweir                             ucb::XSortedDynamicResultSetFactory >(
1027cdf0e10cSrcweir 						      m_rUCB.
1028cdf0e10cSrcweir 							      getServiceFactory()->
1029cdf0e10cSrcweir 							          createInstance(
1030cdf0e10cSrcweir                                           rtl::OUString::createFromAscii(
1031cdf0e10cSrcweir 											  "com.sun.star.ucb.SortedDynamic"
1032cdf0e10cSrcweir 											      "ResultSetFactory")),
1033cdf0e10cSrcweir                               uno::UNO_QUERY);
1034cdf0e10cSrcweir                 uno::Reference< ucb::XDynamicResultSet > xSorted;
1035cdf0e10cSrcweir 				if (xSortedFactory.is())
1036cdf0e10cSrcweir 					xSorted
1037cdf0e10cSrcweir 						= xSortedFactory->
1038cdf0e10cSrcweir 						      createSortedDynamicResultSet(xDynamicResultSet,
1039cdf0e10cSrcweir 														   aOpenArg.
1040cdf0e10cSrcweir 														       SortingInfo,
1041cdf0e10cSrcweir 														   0);
1042cdf0e10cSrcweir 				if (xSorted.is())
1043cdf0e10cSrcweir 					xDynamicResultSet = xSorted;
1044cdf0e10cSrcweir 				else
1045cdf0e10cSrcweir 					print("Sorting cursor not available!");
1046cdf0e10cSrcweir 			}
1047cdf0e10cSrcweir 		}
1048cdf0e10cSrcweir 
1049cdf0e10cSrcweir         uno::Reference< sdbc::XResultSet > xResultSet(
1050cdf0e10cSrcweir 									xDynamicResultSet->getStaticResultSet() );
1051cdf0e10cSrcweir 		if ( xResultSet.is() )
1052cdf0e10cSrcweir 		{
1053cdf0e10cSrcweir 			if ( bPrint )
1054cdf0e10cSrcweir 			{
1055cdf0e10cSrcweir 				print( "Folder object opened - iterating:" );
1056cdf0e10cSrcweir 				print( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(
1057cdf0e10cSrcweir 					"Content-ID : Title : Size : IsFolder : IsDocument\n"
1058cdf0e10cSrcweir 					"-------------------------------------------------" ) ) );
1059cdf0e10cSrcweir 			}
1060cdf0e10cSrcweir 
1061cdf0e10cSrcweir 			if (nFetchSize > 0)
1062cdf0e10cSrcweir 			{
1063cdf0e10cSrcweir 				bool bSet = false;
1064cdf0e10cSrcweir                 uno::Reference< beans::XPropertySet > xProperties(
1065cdf0e10cSrcweir                     xResultSet, uno::UNO_QUERY);
1066cdf0e10cSrcweir 				if (xProperties.is())
1067cdf0e10cSrcweir 					try
1068cdf0e10cSrcweir 					{
1069cdf0e10cSrcweir 						xProperties->
1070cdf0e10cSrcweir                             setPropertyValue(rtl::OUString::createFromAscii(
1071cdf0e10cSrcweir 								                 "FetchSize"),
1072cdf0e10cSrcweir                                              uno::makeAny(nFetchSize));
1073cdf0e10cSrcweir 						bSet = true;
1074cdf0e10cSrcweir 					}
1075cdf0e10cSrcweir                     catch (beans::UnknownPropertyException const &) {}
1076cdf0e10cSrcweir                     catch (beans::PropertyVetoException const &) {}
1077cdf0e10cSrcweir                     catch (lang::IllegalArgumentException const &) {}
1078cdf0e10cSrcweir                     catch (lang::WrappedTargetException const &) {}
1079cdf0e10cSrcweir 				if (!bSet)
1080cdf0e10cSrcweir 					print("Fetch size not set!");
1081cdf0e10cSrcweir 			}
1082cdf0e10cSrcweir 
1083cdf0e10cSrcweir 			try
1084cdf0e10cSrcweir 			{
1085cdf0e10cSrcweir 				ULONG n = 0;
1086cdf0e10cSrcweir                 uno::Reference< ucb::XContentAccess > xContentAccess(
1087cdf0e10cSrcweir                                                 xResultSet, uno::UNO_QUERY );
1088cdf0e10cSrcweir                 uno::Reference< sdbc::XRow > xRow( xResultSet, uno::UNO_QUERY );
1089cdf0e10cSrcweir 
1090cdf0e10cSrcweir 				while ( xResultSet->next() )
1091cdf0e10cSrcweir 				{
1092cdf0e10cSrcweir 					UniString aText;
1093cdf0e10cSrcweir 
1094cdf0e10cSrcweir 					if ( bPrint )
1095cdf0e10cSrcweir 					{
1096cdf0e10cSrcweir                         rtl::OUString aId( xContentAccess->
1097cdf0e10cSrcweir 									      queryContentIdentifierString() );
1098cdf0e10cSrcweir 						aText += UniString::CreateFromInt32( ++n );
1099cdf0e10cSrcweir 						aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1100cdf0e10cSrcweir 							                   ") " ) );
1101cdf0e10cSrcweir 						aText += UniString( aId );
1102cdf0e10cSrcweir 						aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1103cdf0e10cSrcweir 							                   " : " ) );
1104cdf0e10cSrcweir 					}
1105cdf0e10cSrcweir 
1106cdf0e10cSrcweir 					// Title:
1107cdf0e10cSrcweir 					UniString aTitle( xRow->getString( 1 ) );
1108cdf0e10cSrcweir 					if ( bPrint )
1109cdf0e10cSrcweir 					{
1110cdf0e10cSrcweir 						if ( aTitle.Len() == 0 && xRow->wasNull() )
1111cdf0e10cSrcweir 							aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1112cdf0e10cSrcweir 								                   "<null>" ) );
1113cdf0e10cSrcweir 						else
1114cdf0e10cSrcweir 							aText += aTitle;
1115cdf0e10cSrcweir 						aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1116cdf0e10cSrcweir 							                   " : " ) );
1117cdf0e10cSrcweir 					}
1118cdf0e10cSrcweir 
1119cdf0e10cSrcweir 					// Size:
1120cdf0e10cSrcweir 					sal_Int32 nSize = xRow->getInt( 3 );
1121cdf0e10cSrcweir 					if ( bPrint )
1122cdf0e10cSrcweir 					{
1123cdf0e10cSrcweir 						if ( nSize == 0 && xRow->wasNull() )
1124cdf0e10cSrcweir 							aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1125cdf0e10cSrcweir 								                   "<null>" ) );
1126cdf0e10cSrcweir 						else
1127cdf0e10cSrcweir 							aText += UniString::CreateFromInt32( nSize );
1128cdf0e10cSrcweir 						aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1129cdf0e10cSrcweir 							                   " : " ) );
1130cdf0e10cSrcweir 					}
1131cdf0e10cSrcweir 
1132cdf0e10cSrcweir 					// IsFolder:
1133cdf0e10cSrcweir 					sal_Bool bFolder = xRow->getBoolean( 4 );
1134cdf0e10cSrcweir 					if ( bPrint )
1135cdf0e10cSrcweir 					{
1136cdf0e10cSrcweir 						if ( !bFolder && xRow->wasNull() )
1137cdf0e10cSrcweir 							aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1138cdf0e10cSrcweir 								                   "<null>" ) );
1139cdf0e10cSrcweir 						else
1140cdf0e10cSrcweir 							aText
1141cdf0e10cSrcweir 								+= bFolder ?
1142cdf0e10cSrcweir 								       UniString::CreateFromAscii(
1143cdf0e10cSrcweir 										   RTL_CONSTASCII_STRINGPARAM(
1144cdf0e10cSrcweir 											   "true" ) ) :
1145cdf0e10cSrcweir 							           UniString::CreateFromAscii(
1146cdf0e10cSrcweir 										   RTL_CONSTASCII_STRINGPARAM(
1147cdf0e10cSrcweir 											   "false" ) );
1148cdf0e10cSrcweir 						aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1149cdf0e10cSrcweir 							                   " : " ) );
1150cdf0e10cSrcweir 					}
1151cdf0e10cSrcweir 
1152cdf0e10cSrcweir 					// IsDocument:
1153cdf0e10cSrcweir 					sal_Bool bDocument = xRow->getBoolean( 5 );
1154cdf0e10cSrcweir 					if ( bPrint )
1155cdf0e10cSrcweir 					{
1156cdf0e10cSrcweir 						if ( !bFolder && xRow->wasNull() )
1157cdf0e10cSrcweir 							aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM(
1158cdf0e10cSrcweir 								"<null>" ) );
1159cdf0e10cSrcweir 						else
1160cdf0e10cSrcweir 							aText
1161cdf0e10cSrcweir 								+= bDocument ?
1162cdf0e10cSrcweir 								       UniString::CreateFromAscii(
1163cdf0e10cSrcweir 										   RTL_CONSTASCII_STRINGPARAM(
1164cdf0e10cSrcweir 											   "true" ) ) :
1165cdf0e10cSrcweir 							           UniString::CreateFromAscii(
1166cdf0e10cSrcweir 										   RTL_CONSTASCII_STRINGPARAM(
1167cdf0e10cSrcweir 											   "false" ) ); //  IsDocument
1168cdf0e10cSrcweir 					}
1169cdf0e10cSrcweir 
1170cdf0e10cSrcweir 					if ( bPrint )
1171cdf0e10cSrcweir 						print( aText );
1172cdf0e10cSrcweir 
1173cdf0e10cSrcweir 					if ( pStack && bFolder )
1174cdf0e10cSrcweir 						pStack->push( OpenStackEntry(
1175cdf0e10cSrcweir #if 1
1176cdf0e10cSrcweir 							              xContentAccess->
1177cdf0e10cSrcweir 										      queryContentIdentifier(),
1178cdf0e10cSrcweir #else
1179cdf0e10cSrcweir 							              xContentAccess->queryContent(),
1180cdf0e10cSrcweir #endif
1181cdf0e10cSrcweir 										  nLevel + 1 ) );
1182cdf0e10cSrcweir 				}
1183cdf0e10cSrcweir 			}
1184cdf0e10cSrcweir             catch ( ucb::ResultSetException )
1185cdf0e10cSrcweir 			{
1186cdf0e10cSrcweir 				print( "ResultSetException caught!" );
1187cdf0e10cSrcweir 			}
1188cdf0e10cSrcweir 
1189cdf0e10cSrcweir 			if ( bPrint )
1190cdf0e10cSrcweir 				print( "Iteration done." );
1191cdf0e10cSrcweir 		}
1192cdf0e10cSrcweir 	}
1193cdf0e10cSrcweir 
1194cdf0e10cSrcweir     uno::Reference< lang::XComponent > xComponent(
1195cdf0e10cSrcweir         xDynamicResultSet, uno::UNO_QUERY);
1196cdf0e10cSrcweir     if (xComponent.is())
1197cdf0e10cSrcweir         xComponent->dispose();
1198cdf0e10cSrcweir 
1199cdf0e10cSrcweir //	putenv("PROT_REMOTE_ACTIVATE="); // to log remote uno traffic
1200cdf0e10cSrcweir 
1201cdf0e10cSrcweir 	if ( bTiming )
1202cdf0e10cSrcweir 	{
1203cdf0e10cSrcweir 		nTime = Time::GetSystemTicks() - nTime;
1204cdf0e10cSrcweir 		UniString
1205cdf0e10cSrcweir 			aText( UniString::CreateFromAscii(
1206cdf0e10cSrcweir 				       RTL_CONSTASCII_STRINGPARAM( "Operation took " ) ) );
1207cdf0e10cSrcweir 		aText += UniString::CreateFromInt64( nTime );
1208cdf0e10cSrcweir 		aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " ms." ) );
1209cdf0e10cSrcweir 		print( aText );
1210cdf0e10cSrcweir 	}
1211cdf0e10cSrcweir }
1212cdf0e10cSrcweir 
1213cdf0e10cSrcweir //----------------------------------------------------------------------------
openAll(Ucb & rUCB,bool bPrint,bool bTiming,bool bSort,sal_Int32 nFetchSize)1214cdf0e10cSrcweir void UcbContent::openAll( Ucb& rUCB, bool bPrint, bool bTiming, bool bSort,
1215cdf0e10cSrcweir 						  sal_Int32 nFetchSize )
1216cdf0e10cSrcweir {
1217cdf0e10cSrcweir 	ULONG nTime = 0;
1218cdf0e10cSrcweir 	if ( bTiming )
1219cdf0e10cSrcweir 		nTime = Time::GetSystemTicks();
1220cdf0e10cSrcweir 
1221cdf0e10cSrcweir 	OpenStack aStack;
1222cdf0e10cSrcweir 	aStack.push( OpenStackEntry( m_xContent, 0 ) );
1223cdf0e10cSrcweir 
1224cdf0e10cSrcweir 	while ( !aStack.empty() )
1225cdf0e10cSrcweir 	{
1226cdf0e10cSrcweir 		OpenStackEntry aEntry( aStack.top() );
1227cdf0e10cSrcweir 		aStack.pop();
1228cdf0e10cSrcweir 
1229cdf0e10cSrcweir 		if ( bPrint )
1230cdf0e10cSrcweir 		{
1231cdf0e10cSrcweir 			UniString aText;
1232cdf0e10cSrcweir 			for ( sal_uInt32 i = aEntry.m_nLevel; i != 0; --i )
1233cdf0e10cSrcweir 				aText += '=';
1234cdf0e10cSrcweir 			aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "LEVEL " ) );
1235cdf0e10cSrcweir 			aText += UniString::CreateFromInt64( aEntry.m_nLevel );
1236cdf0e10cSrcweir 
1237cdf0e10cSrcweir             uno::Reference< ucb::XContentIdentifier > xID;
1238cdf0e10cSrcweir 			if ( aEntry.m_bUseIdentifier )
1239cdf0e10cSrcweir 				xID = aEntry.m_xIdentifier;
1240cdf0e10cSrcweir 			else if ( aEntry.m_xContent.is() )
1241cdf0e10cSrcweir 				xID = aEntry.m_xContent->getIdentifier();
1242cdf0e10cSrcweir 			if ( xID.is() )
1243cdf0e10cSrcweir 			{
1244cdf0e10cSrcweir 				aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( ": " ) );
1245cdf0e10cSrcweir 				aText += UniString( xID->getContentIdentifier() );
1246cdf0e10cSrcweir 			}
1247cdf0e10cSrcweir 
1248cdf0e10cSrcweir 			print( aText );
1249cdf0e10cSrcweir 		}
1250cdf0e10cSrcweir 
1251cdf0e10cSrcweir         uno::Reference< ucb::XContent > xChild;
1252cdf0e10cSrcweir 		if ( aEntry.m_bUseIdentifier )
1253cdf0e10cSrcweir 		{
1254cdf0e10cSrcweir             uno::Reference< ucb::XContentProvider > xProv
1255cdf0e10cSrcweir                 = rUCB.getContentProvider();
1256cdf0e10cSrcweir 			if ( !xProv.is() )
1257cdf0e10cSrcweir 			{
1258cdf0e10cSrcweir 				print( "No content provider" );
1259cdf0e10cSrcweir 				return;
1260cdf0e10cSrcweir 			}
1261cdf0e10cSrcweir 
1262cdf0e10cSrcweir 			try
1263cdf0e10cSrcweir 			{
1264cdf0e10cSrcweir 				xChild = xProv->queryContent( aEntry.m_xIdentifier );
1265cdf0e10cSrcweir 			}
1266cdf0e10cSrcweir             catch (ucb::IllegalIdentifierException const &) {}
1267cdf0e10cSrcweir 		}
1268cdf0e10cSrcweir 		else
1269cdf0e10cSrcweir 			xChild = aEntry.m_xContent;
1270cdf0e10cSrcweir 		if ( !xChild.is() )
1271cdf0e10cSrcweir 		{
1272cdf0e10cSrcweir 			print( "No content" );
1273cdf0e10cSrcweir 			return;
1274cdf0e10cSrcweir 		}
1275cdf0e10cSrcweir 
1276cdf0e10cSrcweir 		UcbContent( m_rUCB, xChild, m_pOutEdit ).
1277cdf0e10cSrcweir 			open( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(
1278cdf0e10cSrcweir 				                                  "open" ) ),
1279cdf0e10cSrcweir 				  UniString(), bPrint, false, bSort, &aStack,
1280cdf0e10cSrcweir 				  aEntry.m_nLevel, nFetchSize );
1281cdf0e10cSrcweir 	}
1282cdf0e10cSrcweir 
1283cdf0e10cSrcweir 	if ( bTiming )
1284cdf0e10cSrcweir 	{
1285cdf0e10cSrcweir 		nTime = Time::GetSystemTicks() - nTime;
1286cdf0e10cSrcweir 		UniString
1287cdf0e10cSrcweir 			aText( UniString::CreateFromAscii( RTL_CONSTASCII_STRINGPARAM(
1288cdf0e10cSrcweir 				                                   "Operation took " ) ) );
1289cdf0e10cSrcweir 		aText += UniString::CreateFromInt64( nTime );
1290cdf0e10cSrcweir 		aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " ms." ) );
1291cdf0e10cSrcweir 		print( aText );
1292cdf0e10cSrcweir 	}
1293cdf0e10cSrcweir }
1294cdf0e10cSrcweir 
1295cdf0e10cSrcweir //----------------------------------------------------------------------------
transfer(const rtl::OUString & rSourceURL,sal_Bool bMove)1296cdf0e10cSrcweir void UcbContent::transfer( const rtl::OUString& rSourceURL, sal_Bool bMove  )
1297cdf0e10cSrcweir {
1298cdf0e10cSrcweir 	if ( bMove )
1299cdf0e10cSrcweir 		print( "Moving content..." );
1300cdf0e10cSrcweir 	else
1301cdf0e10cSrcweir 		print( "Copying content..." );
1302cdf0e10cSrcweir 
1303cdf0e10cSrcweir #if 1 /* globalTransfer */
1304cdf0e10cSrcweir 
1305cdf0e10cSrcweir     uno::Reference< ucb::XCommandProcessor > xCommandProcessor(
1306cdf0e10cSrcweir                                 m_rUCB.getContentProvider(), uno::UNO_QUERY );
1307cdf0e10cSrcweir 	if ( xCommandProcessor.is() )
1308cdf0e10cSrcweir 	{
1309cdf0e10cSrcweir 
1310cdf0e10cSrcweir #if 0
1311cdf0e10cSrcweir         ucb::Command aCommand(
1312cdf0e10cSrcweir             rtl::OUString::createFromAscii( "getCommandInfo" ), -1, Any() );
1313cdf0e10cSrcweir         uno::Reference< ucb::XCommandInfo > xInfo;
1314cdf0e10cSrcweir 		xCommandProcessor->execute(
1315cdf0e10cSrcweir             aCommand, 0, uno::Reference< ucb::XCommandEnvironment >() )
1316cdf0e10cSrcweir                 >>= xInfo;
1317cdf0e10cSrcweir 		if ( xInfo.is() )
1318cdf0e10cSrcweir 		{
1319cdf0e10cSrcweir             ucb::CommandInfo aInfo
1320cdf0e10cSrcweir 				= xInfo->getCommandInfoByName(
1321cdf0e10cSrcweir                     rtl::OUString::createFromAscii( "globalTransfer" ) );
1322cdf0e10cSrcweir 
1323cdf0e10cSrcweir             uno::Sequence< ucb::CommandInfo > aCommands
1324cdf0e10cSrcweir                 = xInfo->getCommands();
1325cdf0e10cSrcweir             const ucb::CommandInfo* pCommands = aCommands.getConstArray();
1326cdf0e10cSrcweir 
1327cdf0e10cSrcweir 			String aText( UniString::CreateFromAscii(
1328cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "Commands:\n" ) ) );
1329cdf0e10cSrcweir 			sal_uInt32 nCount = aCommands.getLength();
1330cdf0e10cSrcweir 			for ( sal_uInt32 n = 0; n < nCount; ++n )
1331cdf0e10cSrcweir 			{
1332cdf0e10cSrcweir 				aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "    " ) );
1333cdf0e10cSrcweir 				aText += String( pCommands[ n ].Name );
1334cdf0e10cSrcweir 				aText += '\n';
1335cdf0e10cSrcweir 			}
1336cdf0e10cSrcweir 			print( aText );
1337cdf0e10cSrcweir 		}
1338cdf0e10cSrcweir #endif
1339cdf0e10cSrcweir         ucb::GlobalTransferCommandArgument aArg(
1340cdf0e10cSrcweir                             bMove ? ucb::TransferCommandOperation_MOVE
1341cdf0e10cSrcweir                                   : ucb::TransferCommandOperation_COPY,
1342cdf0e10cSrcweir 							rSourceURL,
1343cdf0e10cSrcweir 							getURL(),
1344cdf0e10cSrcweir                             rtl::OUString(),
1345cdf0e10cSrcweir                             //rtl::OUString::createFromAscii( "NewTitle" ),
1346cdf0e10cSrcweir                             ucb::NameClash::ERROR );
1347cdf0e10cSrcweir 
1348cdf0e10cSrcweir         ucb::Command aTransferCommand( rtl::OUString::createFromAscii(
1349cdf0e10cSrcweir                                                 "globalTransfer" ),
1350cdf0e10cSrcweir                                              -1,
1351cdf0e10cSrcweir                                              uno::makeAny( aArg ) );
1352cdf0e10cSrcweir 
1353cdf0e10cSrcweir         uno::Reference< task::XInteractionHandler > xInteractionHandler;
1354cdf0e10cSrcweir 		if (m_rUCB.getServiceFactory().is())
1355cdf0e10cSrcweir 			xInteractionHandler
1356cdf0e10cSrcweir                 = uno::Reference< task::XInteractionHandler >(
1357cdf0e10cSrcweir 				      	m_rUCB.getServiceFactory()->
1358cdf0e10cSrcweir 					      	createInstance(
1359cdf0e10cSrcweir                                 rtl::OUString::createFromAscii(
1360cdf0e10cSrcweir 								  	"com.sun.star.task.InteractionHandler")),
1361cdf0e10cSrcweir                         uno::UNO_QUERY);
1362cdf0e10cSrcweir         uno::Reference< ucb::XProgressHandler > xProgressHandler(
1363cdf0e10cSrcweir 			new ProgressHandler(m_rUCB));
1364cdf0e10cSrcweir         uno::Reference< ucb::XCommandEnvironment > xEnv(
1365cdf0e10cSrcweir 			new UcbTaskEnvironment( xInteractionHandler, xProgressHandler ) );
1366cdf0e10cSrcweir 
1367cdf0e10cSrcweir 		try
1368cdf0e10cSrcweir 		{
1369cdf0e10cSrcweir 			xCommandProcessor->execute( aTransferCommand, 0, xEnv );
1370cdf0e10cSrcweir 		}
1371cdf0e10cSrcweir         catch ( uno::Exception const & )
1372cdf0e10cSrcweir 		{
1373cdf0e10cSrcweir 			print( "globalTransfer threw exception!" );
1374cdf0e10cSrcweir 			return;
1375cdf0e10cSrcweir 		}
1376cdf0e10cSrcweir 
1377cdf0e10cSrcweir 		print( "globalTransfer finished successfully" );
1378cdf0e10cSrcweir 	}
1379cdf0e10cSrcweir 
1380cdf0e10cSrcweir #else /* transfer */
1381cdf0e10cSrcweir 
1382cdf0e10cSrcweir     uno::Any aArg;
1383cdf0e10cSrcweir     aArg <<= ucb::TransferInfo(
1384cdf0e10cSrcweir             bMove, rSourceURL, rtl::OUString(), ucb::NameClash::ERROR );
1385cdf0e10cSrcweir     executeCommand( rtl::OUString::createFromAscii( "transfer" ), aArg );
1386cdf0e10cSrcweir 
1387cdf0e10cSrcweir //  executeCommand( rtl::OUString::createFromAscii( "flush" ), Any() );
1388cdf0e10cSrcweir 
1389cdf0e10cSrcweir #endif
1390cdf0e10cSrcweir }
1391cdf0e10cSrcweir 
1392cdf0e10cSrcweir //----------------------------------------------------------------------------
destroy()1393cdf0e10cSrcweir void UcbContent::destroy()
1394cdf0e10cSrcweir {
1395cdf0e10cSrcweir 	print( "Deleting content..." );
1396cdf0e10cSrcweir 
1397cdf0e10cSrcweir     uno::Any aArg;
1398cdf0e10cSrcweir 	aArg <<= sal_Bool( sal_True ); // delete physically, not only to trash.
1399cdf0e10cSrcweir     executeCommand( rtl::OUString::createFromAscii( "delete" ), aArg );
1400cdf0e10cSrcweir 
1401cdf0e10cSrcweir //  executeCommand( rtl::OUString::createFromAscii( "flush" ), Any() );
1402cdf0e10cSrcweir }
1403cdf0e10cSrcweir 
1404cdf0e10cSrcweir //-------------------------------------------------------------------------
getCommands()1405cdf0e10cSrcweir uno::Sequence< ucb::CommandInfo > UcbContent::getCommands()
1406cdf0e10cSrcweir {
1407cdf0e10cSrcweir     uno::Any aResult = executeCommand(
1408cdf0e10cSrcweir             rtl::OUString::createFromAscii( "getCommandInfo" ), uno::Any() );
1409cdf0e10cSrcweir 
1410cdf0e10cSrcweir     uno::Reference< ucb::XCommandInfo > xInfo;
1411cdf0e10cSrcweir 	if ( aResult >>= xInfo )
1412cdf0e10cSrcweir 	{
1413cdf0e10cSrcweir         uno::Sequence< ucb::CommandInfo > aCommands(
1414cdf0e10cSrcweir             xInfo->getCommands() );
1415cdf0e10cSrcweir         const ucb::CommandInfo* pCommands = aCommands.getConstArray();
1416cdf0e10cSrcweir 
1417cdf0e10cSrcweir 		String aText( UniString::CreateFromAscii(
1418cdf0e10cSrcweir 						RTL_CONSTASCII_STRINGPARAM( "Commands:\n" ) ) );
1419cdf0e10cSrcweir 		sal_uInt32 nCount = aCommands.getLength();
1420cdf0e10cSrcweir 		for ( sal_uInt32 n = 0; n < nCount; ++n )
1421cdf0e10cSrcweir 		{
1422cdf0e10cSrcweir 			aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "    " ) );
1423cdf0e10cSrcweir 			aText += String( pCommands[ n ].Name );
1424cdf0e10cSrcweir 			aText += '\n';
1425cdf0e10cSrcweir 		}
1426cdf0e10cSrcweir 		print( aText );
1427cdf0e10cSrcweir 
1428cdf0e10cSrcweir 		return aCommands;
1429cdf0e10cSrcweir 	}
1430cdf0e10cSrcweir 
1431cdf0e10cSrcweir 	print( "getCommands failed!" );
1432cdf0e10cSrcweir     return uno::Sequence< ucb::CommandInfo >();
1433cdf0e10cSrcweir }
1434cdf0e10cSrcweir 
1435cdf0e10cSrcweir //-------------------------------------------------------------------------
getProperties()1436cdf0e10cSrcweir uno::Sequence< beans::Property > UcbContent::getProperties()
1437cdf0e10cSrcweir {
1438cdf0e10cSrcweir     uno::Any aResult = executeCommand(
1439cdf0e10cSrcweir         rtl::OUString::createFromAscii( "getPropertySetInfo" ), uno::Any() );
1440cdf0e10cSrcweir 
1441cdf0e10cSrcweir     uno::Reference< beans::XPropertySetInfo > xInfo;
1442cdf0e10cSrcweir 	if ( aResult >>= xInfo )
1443cdf0e10cSrcweir 	{
1444cdf0e10cSrcweir         uno::Sequence< beans::Property > aProps( xInfo->getProperties() );
1445cdf0e10cSrcweir         const beans::Property* pProps = aProps.getConstArray();
1446cdf0e10cSrcweir 
1447cdf0e10cSrcweir 		String aText( UniString::CreateFromAscii(
1448cdf0e10cSrcweir 						RTL_CONSTASCII_STRINGPARAM( "Properties:\n" ) ) );
1449cdf0e10cSrcweir 		sal_uInt32 nCount = aProps.getLength();
1450cdf0e10cSrcweir 		for ( sal_uInt32 n = 0; n < nCount; ++n )
1451cdf0e10cSrcweir 		{
1452cdf0e10cSrcweir 			aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "    " ) );
1453cdf0e10cSrcweir 			aText += UniString( pProps[ n ].Name );
1454cdf0e10cSrcweir 			aText += '\n';
1455cdf0e10cSrcweir 		}
1456cdf0e10cSrcweir 		print( aText );
1457cdf0e10cSrcweir 
1458cdf0e10cSrcweir 		return aProps;
1459cdf0e10cSrcweir 	}
1460cdf0e10cSrcweir 
1461cdf0e10cSrcweir 	print( "getProperties failed!" );
1462cdf0e10cSrcweir     return uno::Sequence< beans::Property >();
1463cdf0e10cSrcweir }
1464cdf0e10cSrcweir 
1465cdf0e10cSrcweir //----------------------------------------------------------------------------
getPropertyValue(const rtl::OUString & rName)1466cdf0e10cSrcweir uno::Any UcbContent::getPropertyValue( const rtl::OUString& rName )
1467cdf0e10cSrcweir {
1468cdf0e10cSrcweir     uno::Sequence< beans::Property > aProps( 1 );
1469cdf0e10cSrcweir     beans::Property& rProp = aProps.getArray()[ 0 ];
1470cdf0e10cSrcweir 
1471cdf0e10cSrcweir 	rProp.Name	     = rName;
1472cdf0e10cSrcweir 	rProp.Handle     = -1; /* unknown */
1473cdf0e10cSrcweir //	rProp.Type       = ;
1474cdf0e10cSrcweir //	rProp.Attributes = ;
1475cdf0e10cSrcweir 
1476cdf0e10cSrcweir     uno::Any aArg;
1477cdf0e10cSrcweir 	aArg <<= aProps;
1478cdf0e10cSrcweir 
1479cdf0e10cSrcweir     uno::Any aResult = executeCommand(
1480cdf0e10cSrcweir         rtl::OUString::createFromAscii( "getPropertyValues" ), aArg );
1481cdf0e10cSrcweir 
1482cdf0e10cSrcweir     uno::Reference< sdbc::XRow > xValues;
1483cdf0e10cSrcweir 	if ( aResult >>= xValues )
1484cdf0e10cSrcweir         return xValues->getObject(
1485cdf0e10cSrcweir             1, uno::Reference< container::XNameAccess>() );
1486cdf0e10cSrcweir 
1487cdf0e10cSrcweir 	print( "getPropertyValue failed!" );
1488cdf0e10cSrcweir     return uno::Any();
1489cdf0e10cSrcweir }
1490cdf0e10cSrcweir 
1491cdf0e10cSrcweir //----------------------------------------------------------------------------
getStringPropertyValue(const rtl::OUString & rName)1492cdf0e10cSrcweir rtl::OUString UcbContent::getStringPropertyValue( const rtl::OUString& rName )
1493cdf0e10cSrcweir {
1494cdf0e10cSrcweir     uno::Any aAny = getPropertyValue( rName );
1495cdf0e10cSrcweir     if ( aAny.getValueType() == getCppuType( (const ::rtl::OUString *)0 ) )
1496cdf0e10cSrcweir 	{
1497cdf0e10cSrcweir         const rtl::OUString aValue(
1498cdf0e10cSrcweir             * static_cast< const rtl::OUString * >( aAny.getValue() ) );
1499cdf0e10cSrcweir 
1500cdf0e10cSrcweir 		UniString aText( rName );
1501cdf0e10cSrcweir 		aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " value: '" ) );
1502cdf0e10cSrcweir 		aText += UniString( aValue );
1503cdf0e10cSrcweir 		aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "'" ) );
1504cdf0e10cSrcweir 		print( aText );
1505cdf0e10cSrcweir 
1506cdf0e10cSrcweir 		return aValue;
1507cdf0e10cSrcweir 	}
1508cdf0e10cSrcweir 
1509cdf0e10cSrcweir 	print( "getStringPropertyValue failed!" );
1510cdf0e10cSrcweir     return rtl::OUString();
1511cdf0e10cSrcweir }
1512cdf0e10cSrcweir 
1513cdf0e10cSrcweir //----------------------------------------------------------------------------
setPropertyValue(const rtl::OUString & rName,const uno::Any & rValue)1514cdf0e10cSrcweir void UcbContent::setPropertyValue( const rtl::OUString& rName,
1515cdf0e10cSrcweir                                    const uno::Any& rValue )
1516cdf0e10cSrcweir {
1517cdf0e10cSrcweir     uno::Sequence< beans::PropertyValue > aProps( 1 );
1518cdf0e10cSrcweir     beans::PropertyValue& rProp = aProps.getArray()[ 0 ];
1519cdf0e10cSrcweir 
1520cdf0e10cSrcweir 	rProp.Name	     = rName;
1521cdf0e10cSrcweir 	rProp.Handle     = -1; /* unknown */
1522cdf0e10cSrcweir 	rProp.Value	     = rValue;
1523cdf0e10cSrcweir //	rProp.State      = ;
1524cdf0e10cSrcweir 
1525cdf0e10cSrcweir     uno::Any aArg;
1526cdf0e10cSrcweir 	aArg <<= aProps;
1527cdf0e10cSrcweir 
1528cdf0e10cSrcweir     executeCommand( rtl::OUString::createFromAscii( "setPropertyValues" ),
1529cdf0e10cSrcweir                     aArg );
1530cdf0e10cSrcweir 
1531cdf0e10cSrcweir //  executeCommand( rtl::OUString::createFromAscii( "flush" ), Any() );
1532cdf0e10cSrcweir }
1533cdf0e10cSrcweir 
1534cdf0e10cSrcweir //----------------------------------------------------------------------------
setStringPropertyValue(const rtl::OUString & rName,const rtl::OUString & rValue)1535cdf0e10cSrcweir void UcbContent::setStringPropertyValue( const rtl::OUString& rName,
1536cdf0e10cSrcweir                                          const rtl::OUString& rValue )
1537cdf0e10cSrcweir {
1538cdf0e10cSrcweir     uno::Any aAny;
1539cdf0e10cSrcweir     aAny <<= rValue;
1540cdf0e10cSrcweir 	setPropertyValue( rName, aAny );
1541cdf0e10cSrcweir 
1542cdf0e10cSrcweir 	UniString aText( rName );
1543cdf0e10cSrcweir 	aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " value set to: '" ) );
1544cdf0e10cSrcweir     aText += UniString( rValue );
1545cdf0e10cSrcweir 	aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( "'" ) );
1546cdf0e10cSrcweir 	print( aText );
1547cdf0e10cSrcweir }
1548cdf0e10cSrcweir 
1549cdf0e10cSrcweir //----------------------------------------------------------------------------
addProperty(const rtl::OUString & rName,const uno::Any & rValue)1550cdf0e10cSrcweir void UcbContent::addProperty( const rtl::OUString& rName,
1551cdf0e10cSrcweir                               const uno::Any& rValue )
1552cdf0e10cSrcweir {
1553cdf0e10cSrcweir     uno::Reference< beans::XPropertyContainer > xContainer( m_xContent,
1554cdf0e10cSrcweir                                                             uno::UNO_QUERY );
1555cdf0e10cSrcweir 	if ( xContainer.is() )
1556cdf0e10cSrcweir 	{
1557cdf0e10cSrcweir 		UniString aText( UniString::CreateFromAscii(
1558cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM(
1559cdf0e10cSrcweir 								"Adding property: " ) ) );
1560cdf0e10cSrcweir 		aText += UniString( rName );
1561cdf0e10cSrcweir 		print( aText );
1562cdf0e10cSrcweir 
1563cdf0e10cSrcweir 		try
1564cdf0e10cSrcweir 		{
1565cdf0e10cSrcweir 			xContainer->addProperty( rName, 0, rValue );
1566cdf0e10cSrcweir 		}
1567cdf0e10cSrcweir         catch ( beans::PropertyExistException const & )
1568cdf0e10cSrcweir 		{
1569cdf0e10cSrcweir 			print( "Adding property failed. Already exists!" );
1570cdf0e10cSrcweir 			return;
1571cdf0e10cSrcweir 		}
1572cdf0e10cSrcweir         catch ( beans::IllegalTypeException const & )
1573cdf0e10cSrcweir 		{
1574cdf0e10cSrcweir 			print( "Adding property failed. Illegal Type!" );
1575cdf0e10cSrcweir 			return;
1576cdf0e10cSrcweir 		}
1577cdf0e10cSrcweir         catch ( lang::IllegalArgumentException const & )
1578cdf0e10cSrcweir 		{
1579cdf0e10cSrcweir 			print( "Adding property failed. Illegal Argument!" );
1580cdf0e10cSrcweir 			return;
1581cdf0e10cSrcweir 		}
1582cdf0e10cSrcweir 
1583cdf0e10cSrcweir 		print( "Adding property succeeded." );
1584cdf0e10cSrcweir 		return;
1585cdf0e10cSrcweir 	}
1586cdf0e10cSrcweir 
1587cdf0e10cSrcweir 	print( "Adding property failed. No XPropertyContainer!" );
1588cdf0e10cSrcweir }
1589cdf0e10cSrcweir 
1590cdf0e10cSrcweir //----------------------------------------------------------------------------
addStringProperty(const rtl::OUString & rName,const rtl::OUString & rValue)1591cdf0e10cSrcweir void UcbContent::addStringProperty(
1592cdf0e10cSrcweir                     const rtl::OUString& rName, const rtl::OUString& rValue )
1593cdf0e10cSrcweir {
1594cdf0e10cSrcweir     uno::Any aValue;
1595cdf0e10cSrcweir 	aValue <<= rValue;
1596cdf0e10cSrcweir 	addProperty( rName, aValue );
1597cdf0e10cSrcweir }
1598cdf0e10cSrcweir 
1599cdf0e10cSrcweir //----------------------------------------------------------------------------
removeProperty(const rtl::OUString & rName)1600cdf0e10cSrcweir void UcbContent::removeProperty( const rtl::OUString& rName )
1601cdf0e10cSrcweir {
1602cdf0e10cSrcweir     uno::Reference< beans::XPropertyContainer > xContainer( m_xContent,
1603cdf0e10cSrcweir                                                             uno::UNO_QUERY );
1604cdf0e10cSrcweir 	if ( xContainer.is() )
1605cdf0e10cSrcweir 	{
1606cdf0e10cSrcweir 		UniString aText( UniString::CreateFromAscii(
1607cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM(
1608cdf0e10cSrcweir 								"Removing property: " ) ) );
1609cdf0e10cSrcweir 		aText += UniString( rName );
1610cdf0e10cSrcweir 		print( aText );
1611cdf0e10cSrcweir 
1612cdf0e10cSrcweir 		try
1613cdf0e10cSrcweir 		{
1614cdf0e10cSrcweir 			xContainer->removeProperty( rName );
1615cdf0e10cSrcweir 		}
1616cdf0e10cSrcweir         catch ( beans::UnknownPropertyException const & )
1617cdf0e10cSrcweir 		{
1618cdf0e10cSrcweir 			print( "Adding property failed. Unknown!" );
1619cdf0e10cSrcweir 			return;
1620cdf0e10cSrcweir 		}
1621cdf0e10cSrcweir 
1622cdf0e10cSrcweir 		print( "Removing property succeeded." );
1623cdf0e10cSrcweir 		return;
1624cdf0e10cSrcweir 	}
1625cdf0e10cSrcweir 
1626cdf0e10cSrcweir 	print( "Removing property failed. No XPropertyContainer!" );
1627cdf0e10cSrcweir }
1628cdf0e10cSrcweir 
1629cdf0e10cSrcweir //----------------------------------------------------------------------------
1630cdf0e10cSrcweir //
1631cdf0e10cSrcweir // XInterface methods
1632cdf0e10cSrcweir //
1633cdf0e10cSrcweir //----------------------------------------------------------------------------
1634cdf0e10cSrcweir 
1635cdf0e10cSrcweir // virtual
queryInterface(const uno::Type & rType)1636cdf0e10cSrcweir uno::Any SAL_CALL UcbContent::queryInterface( const uno::Type & rType )
1637cdf0e10cSrcweir     throw(uno::RuntimeException)
1638cdf0e10cSrcweir {
1639cdf0e10cSrcweir     uno::Any aRet = cppu::queryInterface(
1640cdf0e10cSrcweir 				rType,
1641cdf0e10cSrcweir                 static_cast< lang::XEventListener* >(
1642cdf0e10cSrcweir                     static_cast< ucb::XContentEventListener* >( this ) ),
1643cdf0e10cSrcweir                 static_cast< ucb::XContentEventListener* >( this ),
1644cdf0e10cSrcweir                 static_cast< beans::XPropertiesChangeListener* >( this ) );
1645cdf0e10cSrcweir 	return aRet.hasValue() ? aRet : OWeakObject::queryInterface( rType );
1646cdf0e10cSrcweir }
1647cdf0e10cSrcweir 
1648cdf0e10cSrcweir //----------------------------------------------------------------------------
1649cdf0e10cSrcweir // virtual
acquire()1650cdf0e10cSrcweir void SAL_CALL UcbContent::acquire()
1651cdf0e10cSrcweir     throw()
1652cdf0e10cSrcweir {
1653cdf0e10cSrcweir 	OWeakObject::acquire();
1654cdf0e10cSrcweir }
1655cdf0e10cSrcweir 
1656cdf0e10cSrcweir //----------------------------------------------------------------------------
1657cdf0e10cSrcweir // virtual
release()1658cdf0e10cSrcweir void SAL_CALL UcbContent::release()
1659cdf0e10cSrcweir     throw()
1660cdf0e10cSrcweir {
1661cdf0e10cSrcweir 	OWeakObject::release();
1662cdf0e10cSrcweir }
1663cdf0e10cSrcweir 
1664cdf0e10cSrcweir //----------------------------------------------------------------------------
1665cdf0e10cSrcweir //
1666cdf0e10cSrcweir // XEventListener methods.
1667cdf0e10cSrcweir //
1668cdf0e10cSrcweir //----------------------------------------------------------------------------
1669cdf0e10cSrcweir 
1670cdf0e10cSrcweir // virtual
disposing(const lang::EventObject &)1671cdf0e10cSrcweir void SAL_CALL UcbContent::disposing( const lang::EventObject& /*Source*/ )
1672cdf0e10cSrcweir     throw( uno::RuntimeException )
1673cdf0e10cSrcweir {
1674cdf0e10cSrcweir 	print ( "Content: disposing..." );
1675cdf0e10cSrcweir }
1676cdf0e10cSrcweir 
1677cdf0e10cSrcweir //----------------------------------------------------------------------------
1678cdf0e10cSrcweir //
1679cdf0e10cSrcweir // XContentEventListener methods,
1680cdf0e10cSrcweir //
1681cdf0e10cSrcweir //----------------------------------------------------------------------------
1682cdf0e10cSrcweir 
1683cdf0e10cSrcweir // virtual
contentEvent(const ucb::ContentEvent & evt)1684cdf0e10cSrcweir void SAL_CALL UcbContent::contentEvent( const ucb::ContentEvent& evt )
1685cdf0e10cSrcweir     throw( uno::RuntimeException )
1686cdf0e10cSrcweir {
1687cdf0e10cSrcweir 	switch ( evt.Action )
1688cdf0e10cSrcweir 	{
1689cdf0e10cSrcweir         case ucb::ContentAction::INSERTED:
1690cdf0e10cSrcweir 		{
1691cdf0e10cSrcweir 			UniString aText( UniString::CreateFromAscii(
1692cdf0e10cSrcweir 								RTL_CONSTASCII_STRINGPARAM(
1693cdf0e10cSrcweir 									"contentEvent: INSERTED: " ) ) );
1694cdf0e10cSrcweir 			if ( evt.Content.is() )
1695cdf0e10cSrcweir 			{
1696cdf0e10cSrcweir                 uno::Reference< ucb::XContentIdentifier > xId(
1697cdf0e10cSrcweir 				   						evt.Content->getIdentifier() );
1698cdf0e10cSrcweir 				aText += UniString( xId->getContentIdentifier() );
1699cdf0e10cSrcweir 				aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ) );
1700cdf0e10cSrcweir 				aText += UniString( evt.Content->getContentType() );
1701cdf0e10cSrcweir 			}
1702cdf0e10cSrcweir 
1703cdf0e10cSrcweir 			print( aText );
1704cdf0e10cSrcweir 			break;
1705cdf0e10cSrcweir 		}
1706cdf0e10cSrcweir         case ucb::ContentAction::REMOVED:
1707cdf0e10cSrcweir 			print( "contentEvent: REMOVED" );
1708cdf0e10cSrcweir 			break;
1709cdf0e10cSrcweir 
1710cdf0e10cSrcweir         case ucb::ContentAction::DELETED:
1711cdf0e10cSrcweir 			print( "contentEvent: DELETED" );
1712cdf0e10cSrcweir 			break;
1713cdf0e10cSrcweir 
1714cdf0e10cSrcweir         case ucb::ContentAction::EXCHANGED:
1715cdf0e10cSrcweir 			print( "contentEvent: EXCHANGED" );
1716cdf0e10cSrcweir 			break;
1717cdf0e10cSrcweir 
1718cdf0e10cSrcweir         case ucb::ContentAction::SEARCH_MATCHED:
1719cdf0e10cSrcweir 		{
1720cdf0e10cSrcweir 			String aMatch(RTL_CONSTASCII_USTRINGPARAM(
1721cdf0e10cSrcweir 				              "contentEvent: SEARCH MATCHED "));
1722cdf0e10cSrcweir 			if (evt.Id.is())
1723cdf0e10cSrcweir 			{
1724cdf0e10cSrcweir 				aMatch += String(evt.Id->getContentIdentifier());
1725cdf0e10cSrcweir 				if (evt.Content.is())
1726cdf0e10cSrcweir 				{
1727cdf0e10cSrcweir 					aMatch.AppendAscii(RTL_CONSTASCII_STRINGPARAM(" - "));
1728cdf0e10cSrcweir 					aMatch += String(evt.Content->getContentType());
1729cdf0e10cSrcweir 				}
1730cdf0e10cSrcweir 			}
1731cdf0e10cSrcweir 			else
1732cdf0e10cSrcweir 				aMatch.AppendAscii(RTL_CONSTASCII_STRINGPARAM("<no id>"));
1733cdf0e10cSrcweir 			print(aMatch);
1734cdf0e10cSrcweir 			break;
1735cdf0e10cSrcweir 		}
1736cdf0e10cSrcweir 
1737cdf0e10cSrcweir 		default:
1738cdf0e10cSrcweir 			print( "contentEvent..." );
1739cdf0e10cSrcweir 			break;
1740cdf0e10cSrcweir 	}
1741cdf0e10cSrcweir }
1742cdf0e10cSrcweir 
1743cdf0e10cSrcweir //----------------------------------------------------------------------------
1744cdf0e10cSrcweir //
1745cdf0e10cSrcweir // XPropertiesChangeListener methods.
1746cdf0e10cSrcweir //
1747cdf0e10cSrcweir //----------------------------------------------------------------------------
1748cdf0e10cSrcweir 
1749cdf0e10cSrcweir // virtual
propertiesChange(const uno::Sequence<beans::PropertyChangeEvent> & evt)1750cdf0e10cSrcweir void SAL_CALL UcbContent::propertiesChange(
1751cdf0e10cSrcweir                     const uno::Sequence< beans::PropertyChangeEvent >& evt )
1752cdf0e10cSrcweir     throw( uno::RuntimeException )
1753cdf0e10cSrcweir {
1754cdf0e10cSrcweir 	print( "propertiesChange..." );
1755cdf0e10cSrcweir 
1756cdf0e10cSrcweir 	sal_uInt32 nCount = evt.getLength();
1757cdf0e10cSrcweir 	if ( nCount )
1758cdf0e10cSrcweir 	{
1759cdf0e10cSrcweir         const beans::PropertyChangeEvent* pEvents = evt.getConstArray();
1760cdf0e10cSrcweir 		for ( sal_uInt32 n = 0; n < nCount; ++n )
1761cdf0e10cSrcweir 		{
1762cdf0e10cSrcweir 			UniString aText( UniString::CreateFromAscii(
1763cdf0e10cSrcweir 								RTL_CONSTASCII_STRINGPARAM( "    " ) ) );
1764cdf0e10cSrcweir 			aText += UniString( pEvents[ n ].PropertyName );
1765cdf0e10cSrcweir 			print( aText );
1766cdf0e10cSrcweir 		}
1767cdf0e10cSrcweir 	}
1768cdf0e10cSrcweir }
1769cdf0e10cSrcweir 
1770cdf0e10cSrcweir /*========================================================================
1771cdf0e10cSrcweir  *
1772cdf0e10cSrcweir  * MyWin.
1773cdf0e10cSrcweir  *
1774cdf0e10cSrcweir  *=======================================================================*/
1775cdf0e10cSrcweir 
1776cdf0e10cSrcweir #define MYWIN_ITEMID_CLEAR    		1
1777cdf0e10cSrcweir #define MYWIN_ITEMID_CREATE   		2
1778cdf0e10cSrcweir #define MYWIN_ITEMID_RELEASE   		3
1779cdf0e10cSrcweir #define MYWIN_ITEMID_COMMANDS 		4
1780cdf0e10cSrcweir #define MYWIN_ITEMID_PROPS 			5
1781cdf0e10cSrcweir #define MYWIN_ITEMID_ADD_PROP		6
1782cdf0e10cSrcweir #define MYWIN_ITEMID_REMOVE_PROP	7
1783cdf0e10cSrcweir #define MYWIN_ITEMID_GET_PROP		8
1784cdf0e10cSrcweir #define MYWIN_ITEMID_SET_PROP		9
1785cdf0e10cSrcweir #define MYWIN_ITEMID_OPEN			10
1786cdf0e10cSrcweir #define MYWIN_ITEMID_OPEN_ALL		11
1787cdf0e10cSrcweir #define MYWIN_ITEMID_UPDATE		   	12
1788cdf0e10cSrcweir #define MYWIN_ITEMID_SYNCHRONIZE 	13
1789cdf0e10cSrcweir #define MYWIN_ITEMID_COPY 			14
1790cdf0e10cSrcweir #define MYWIN_ITEMID_MOVE 			15
1791cdf0e10cSrcweir #define MYWIN_ITEMID_DELETE 		16
1792cdf0e10cSrcweir #define MYWIN_ITEMID_SEARCH			17
1793cdf0e10cSrcweir #define MYWIN_ITEMID_TIMING			18
1794cdf0e10cSrcweir #define MYWIN_ITEMID_SORT			19
1795cdf0e10cSrcweir #define MYWIN_ITEMID_FETCHSIZE		20
1796cdf0e10cSrcweir #define MYWIN_ITEMID_SYS2URI		21
1797cdf0e10cSrcweir #define MYWIN_ITEMID_URI2SYS		22
1798cdf0e10cSrcweir #define MYWIN_ITEMID_OFFLINE		23
1799cdf0e10cSrcweir #define MYWIN_ITEMID_ONLINE			24
1800cdf0e10cSrcweir #define MYWIN_ITEMID_REORGANIZE		25
1801cdf0e10cSrcweir 
1802cdf0e10cSrcweir //-------------------------------------------------------------------------
1803cdf0e10cSrcweir class MyWin : public WorkWindow
1804cdf0e10cSrcweir {
1805cdf0e10cSrcweir private:
1806cdf0e10cSrcweir 	ToolBox*			m_pTool;
1807cdf0e10cSrcweir 	Edit*				m_pCmdEdit;
1808cdf0e10cSrcweir 	MyOutWindow*		m_pOutEdit;
1809cdf0e10cSrcweir 
1810cdf0e10cSrcweir 	Ucb 		m_aUCB;
1811cdf0e10cSrcweir 	UcbContent* m_pContent;
1812cdf0e10cSrcweir 
1813cdf0e10cSrcweir 	sal_Int32 m_nFetchSize;
1814cdf0e10cSrcweir 	bool m_bTiming;
1815cdf0e10cSrcweir 	bool m_bSort;
1816cdf0e10cSrcweir 
1817cdf0e10cSrcweir public:
1818cdf0e10cSrcweir 	MyWin( Window *pParent, WinBits nWinStyle,
1819cdf0e10cSrcweir            uno::Reference< lang::XMultiServiceFactory >& rxFactory,
1820cdf0e10cSrcweir 		   rtl::OUString const & rConfigurationKey1,
1821cdf0e10cSrcweir 		   rtl::OUString const & rConfigurationKey2 );
1822cdf0e10cSrcweir 	virtual ~MyWin();
1823cdf0e10cSrcweir 
1824cdf0e10cSrcweir 	void Resize( void );
1825cdf0e10cSrcweir 	DECL_LINK ( ToolBarHandler, ToolBox* );
1826cdf0e10cSrcweir 
1827cdf0e10cSrcweir 	void print( const UniString& rText );
1828cdf0e10cSrcweir 	void print( const sal_Char* pText );
1829cdf0e10cSrcweir };
1830cdf0e10cSrcweir 
1831cdf0e10cSrcweir //-------------------------------------------------------------------------
MyWin(Window * pParent,WinBits nWinStyle,uno::Reference<lang::XMultiServiceFactory> & rxFactory,rtl::OUString const & rConfigurationKey1,rtl::OUString const & rConfigurationKey2)1832cdf0e10cSrcweir MyWin::MyWin( Window *pParent, WinBits nWinStyle,
1833cdf0e10cSrcweir               uno::Reference< lang::XMultiServiceFactory >& rxFactory,
1834cdf0e10cSrcweir 			  rtl::OUString const & rConfigurationKey1,
1835cdf0e10cSrcweir 			  rtl::OUString const & rConfigurationKey2 )
1836cdf0e10cSrcweir : WorkWindow( pParent, nWinStyle ),
1837cdf0e10cSrcweir   m_pTool( NULL ),
1838cdf0e10cSrcweir   m_pOutEdit( NULL ),
1839cdf0e10cSrcweir   m_aUCB( rxFactory, rConfigurationKey1, rConfigurationKey2 ),
1840cdf0e10cSrcweir   m_pContent( NULL ),
1841cdf0e10cSrcweir   m_nFetchSize( 0 ),
1842cdf0e10cSrcweir   m_bTiming( false ),
1843cdf0e10cSrcweir   m_bSort( false )
1844cdf0e10cSrcweir {
1845cdf0e10cSrcweir 	// ToolBox.
1846cdf0e10cSrcweir 	m_pTool = new ToolBox( this, WB_3DLOOK | WB_BORDER  | WB_SCROLL );
1847cdf0e10cSrcweir 
1848cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_CLEAR,
1849cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1850cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1851cdf0e10cSrcweir 						  		"Clear" ) ) );
1852cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_CLEAR,
1853cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1854cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1855cdf0e10cSrcweir 	  							"Clear the Output Window" ) ) );
1856cdf0e10cSrcweir 	m_pTool->InsertSeparator();
1857cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_CREATE,
1858cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1859cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1860cdf0e10cSrcweir 								"Create" ) ) );
1861cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_CREATE,
1862cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1863cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1864cdf0e10cSrcweir 								"Create a content" ) ) );
1865cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_RELEASE,
1866cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1867cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1868cdf0e10cSrcweir 								"Release" ) ) );
1869cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_RELEASE,
1870cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1871cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1872cdf0e10cSrcweir 								"Release current content" ) ) );
1873cdf0e10cSrcweir 	m_pTool->InsertSeparator();
1874cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_COMMANDS,
1875cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1876cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1877cdf0e10cSrcweir 								"Commands" ) ) );
1878cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_COMMANDS,
1879cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1880cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1881cdf0e10cSrcweir 						  		"Get Commands supported by the content" ) ) );
1882cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_PROPS,
1883cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1884cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1885cdf0e10cSrcweir 								"Properties" ) ) );
1886cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_PROPS,
1887cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1888cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1889cdf0e10cSrcweir 								"Get Properties supported by the content" ) ) );
1890cdf0e10cSrcweir 	m_pTool->InsertSeparator();
1891cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_ADD_PROP,
1892cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1893cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1894cdf0e10cSrcweir 								"addProperty" ) ) );
1895cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_ADD_PROP,
1896cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1897cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1898cdf0e10cSrcweir 						  		"Add a new string(!) property to the content. "
1899cdf0e10cSrcweir 						  		"Type the property name in the entry field and "
1900cdf0e10cSrcweir 						  		"push this button. The default value for the "
1901cdf0e10cSrcweir 						  		"property will be set to the string 'DefaultValue'" ) ) );
1902cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_REMOVE_PROP,
1903cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1904cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1905cdf0e10cSrcweir 								"removeProperty" ) ) );
1906cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_REMOVE_PROP,
1907cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1908cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1909cdf0e10cSrcweir 						  		"Removes a property from the content. "
1910cdf0e10cSrcweir 						  		"Type the property name in the entry field and "
1911cdf0e10cSrcweir 						  		"push this button." ) ) );
1912cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_GET_PROP,
1913cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1914cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1915cdf0e10cSrcweir 								"getPropertyValue" ) ) );
1916cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_GET_PROP,
1917cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1918cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1919cdf0e10cSrcweir 						  		"Get a string(!) property value from the content. "
1920cdf0e10cSrcweir 						  		"Type the property name in the entry field and "
1921cdf0e10cSrcweir 						  		"push this button to obtain the value" ) ) );
1922cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_SET_PROP,
1923cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1924cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1925cdf0e10cSrcweir 								"setPropertyValue" ) ) );
1926cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_SET_PROP,
1927cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1928cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1929cdf0e10cSrcweir 						  		"Set a string(!) property value of the content."
1930cdf0e10cSrcweir 						  		"Type the property name in the entry field and "
1931cdf0e10cSrcweir 						  		"push this button to set the value to the string "
1932cdf0e10cSrcweir 						  		"'NewValue'" ) ) );
1933cdf0e10cSrcweir 	m_pTool->InsertSeparator();
1934cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_OPEN,
1935cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1936cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1937cdf0e10cSrcweir 								"Open" ) ) );
1938cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_OPEN,
1939cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1940cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1941cdf0e10cSrcweir 								"Open the content" ) ) );
1942cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_OPEN_ALL,
1943cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1944cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1945cdf0e10cSrcweir 								"Open All" ) ) );
1946cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_OPEN_ALL,
1947cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1948cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1949cdf0e10cSrcweir 								"Open the content and all of its"
1950cdf0e10cSrcweir 									" children" ) ) );
1951cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_UPDATE,
1952cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1953cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1954cdf0e10cSrcweir 								"Update" ) ) );
1955cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_UPDATE,
1956cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1957cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1958cdf0e10cSrcweir 								"Update the content" ) ) );
1959cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_SYNCHRONIZE,
1960cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1961cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1962cdf0e10cSrcweir 								"Synchronize" ) ) );
1963cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_SYNCHRONIZE,
1964cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1965cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1966cdf0e10cSrcweir 								"Synchronize the content" ) ) );
1967cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_SEARCH,
1968cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1969cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1970cdf0e10cSrcweir 								"Search" ) ) );
1971cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_SEARCH,
1972cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1973cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1974cdf0e10cSrcweir 								"Search the content" ) ) );
1975cdf0e10cSrcweir 
1976cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_REORGANIZE,
1977cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1978cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1979cdf0e10cSrcweir 								"Reorganize" ) ) );
1980cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_REORGANIZE,
1981cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1982cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1983cdf0e10cSrcweir 								"Reorganize the content storage" ) ) );
1984cdf0e10cSrcweir 
1985cdf0e10cSrcweir 	m_pTool->InsertSeparator();
1986cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_COPY,
1987cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1988cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1989cdf0e10cSrcweir 								"Copy" ) ) );
1990cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_COPY,
1991cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1992cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1993cdf0e10cSrcweir 								"Copy a content. Type the URL of the source "
1994cdf0e10cSrcweir 								"content into the entry field." ) ) );
1995cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_MOVE,
1996cdf0e10cSrcweir 						  UniString::CreateFromAscii(
1997cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
1998cdf0e10cSrcweir 								"Move" ) ) );
1999cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_MOVE,
2000cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2001cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2002cdf0e10cSrcweir 								"Move a content. Type the URL of the source "
2003cdf0e10cSrcweir 								"content into the entry field." ) ) );
2004cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_DELETE,
2005cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2006cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2007cdf0e10cSrcweir 								"Delete" ) ) );
2008cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_DELETE,
2009cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2010cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2011cdf0e10cSrcweir 								"Delete the content." ) ) );
2012cdf0e10cSrcweir 
2013cdf0e10cSrcweir 	m_pTool->InsertSeparator();
2014cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_TIMING,
2015cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2016cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2017cdf0e10cSrcweir 								"Timing" ) ),
2018cdf0e10cSrcweir 						  TIB_CHECKABLE | TIB_AUTOCHECK );
2019cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_TIMING,
2020cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2021cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2022cdf0e10cSrcweir 								"Display execution times instead of"
2023cdf0e10cSrcweir 								    " output" ) ) );
2024cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_SORT,
2025cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2026cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2027cdf0e10cSrcweir 								"Sort" ) ),
2028cdf0e10cSrcweir 						  TIB_CHECKABLE | TIB_AUTOCHECK );
2029cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_SORT,
2030cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2031cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2032cdf0e10cSrcweir 								"Sort result sets" ) ) );
2033cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_FETCHSIZE,
2034cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2035cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2036cdf0e10cSrcweir 								"Fetch Size" ) ) );
2037cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_FETCHSIZE,
2038cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2039cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2040cdf0e10cSrcweir 								"Set cached cursor fetch size to positive value" ) ) );
2041cdf0e10cSrcweir 
2042cdf0e10cSrcweir 	m_pTool->InsertSeparator();
2043cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_SYS2URI,
2044cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2045cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2046cdf0e10cSrcweir 								"UNC>URI" ) ) );
2047cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_SYS2URI,
2048cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2049cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2050cdf0e10cSrcweir 								"Translate 'System File Path' to URI,"
2051cdf0e10cSrcweir 								    " if possible" ) ) );
2052cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_URI2SYS,
2053cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2054cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2055cdf0e10cSrcweir 								"URI>UNC" ) ) );
2056cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_URI2SYS,
2057cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2058cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2059cdf0e10cSrcweir 								"Translate URI to 'System File Path',"
2060cdf0e10cSrcweir 								    " if possible" ) ) );
2061cdf0e10cSrcweir 
2062cdf0e10cSrcweir 	m_pTool->InsertSeparator();
2063cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_OFFLINE,
2064cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2065cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2066cdf0e10cSrcweir 								"Offline" ) ) );
2067cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_OFFLINE,
2068cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2069cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2070cdf0e10cSrcweir 								"Go offline" ) ) );
2071cdf0e10cSrcweir 	m_pTool->InsertItem ( MYWIN_ITEMID_ONLINE,
2072cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2073cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2074cdf0e10cSrcweir 								"Online" ) ) );
2075cdf0e10cSrcweir 	m_pTool->SetHelpText( MYWIN_ITEMID_ONLINE,
2076cdf0e10cSrcweir 						  UniString::CreateFromAscii(
2077cdf0e10cSrcweir 						  	RTL_CONSTASCII_STRINGPARAM(
2078cdf0e10cSrcweir 								"Go back online" ) ) );
2079cdf0e10cSrcweir 
2080cdf0e10cSrcweir 	m_pTool->SetSelectHdl( LINK( this, MyWin, ToolBarHandler ) );
2081cdf0e10cSrcweir 	m_pTool->Show();
2082cdf0e10cSrcweir 
2083cdf0e10cSrcweir 	// Edit.
2084cdf0e10cSrcweir 	m_pCmdEdit = new Edit( this );
2085cdf0e10cSrcweir 	m_pCmdEdit->SetReadOnly( FALSE );
2086cdf0e10cSrcweir 	m_pCmdEdit->SetText( UniString::CreateFromAscii(
2087cdf0e10cSrcweir 							RTL_CONSTASCII_STRINGPARAM( "file:///" ) ) );
2088cdf0e10cSrcweir 	m_pCmdEdit->Show();
2089cdf0e10cSrcweir 
2090cdf0e10cSrcweir 	// MyOutWindow.
2091cdf0e10cSrcweir 	m_pOutEdit = new MyOutWindow( this, WB_HSCROLL | WB_VSCROLL | WB_BORDER );
2092cdf0e10cSrcweir 	m_pOutEdit->SetReadOnly( TRUE );
2093cdf0e10cSrcweir 	m_pOutEdit->Show();
2094cdf0e10cSrcweir 
2095cdf0e10cSrcweir 	m_aUCB.setOutEdit( m_pOutEdit );
2096cdf0e10cSrcweir }
2097cdf0e10cSrcweir 
2098cdf0e10cSrcweir //-------------------------------------------------------------------------
2099cdf0e10cSrcweir // virtual
~MyWin()2100cdf0e10cSrcweir MyWin::~MyWin()
2101cdf0e10cSrcweir {
2102cdf0e10cSrcweir 	if ( m_pContent )
2103cdf0e10cSrcweir 	{
2104cdf0e10cSrcweir 		m_pContent->dispose();
2105cdf0e10cSrcweir 		m_pContent->release();
2106cdf0e10cSrcweir 	}
2107cdf0e10cSrcweir 
2108cdf0e10cSrcweir     delete m_pTool;
2109cdf0e10cSrcweir 	delete m_pCmdEdit;
2110cdf0e10cSrcweir 	delete m_pOutEdit;
2111cdf0e10cSrcweir }
2112cdf0e10cSrcweir 
2113cdf0e10cSrcweir //-------------------------------------------------------------------------
Resize()2114cdf0e10cSrcweir void MyWin::Resize()
2115cdf0e10cSrcweir {
2116cdf0e10cSrcweir 	Size aWinSize = GetOutputSizePixel();
2117cdf0e10cSrcweir 	int nWinW = aWinSize.Width();
2118cdf0e10cSrcweir 	int nWinH = aWinSize.Height();
2119cdf0e10cSrcweir 	int nBoxH = m_pTool->CalcWindowSizePixel().Height();
2120cdf0e10cSrcweir 
2121cdf0e10cSrcweir 	m_pTool->SetPosSizePixel   (
2122cdf0e10cSrcweir 		Point( 0, 0 ), Size ( nWinW, nBoxH ) );
2123cdf0e10cSrcweir 	m_pCmdEdit->SetPosSizePixel(
2124cdf0e10cSrcweir 		Point( 0, nBoxH ), Size( nWinW, nBoxH ) );
2125cdf0e10cSrcweir 	m_pOutEdit->SetPosSizePixel(
2126cdf0e10cSrcweir 		Point( 0, nBoxH + nBoxH ), Size ( nWinW, nWinH - ( nBoxH + nBoxH ) ) );
2127cdf0e10cSrcweir }
2128cdf0e10cSrcweir 
2129cdf0e10cSrcweir //-------------------------------------------------------------------------
print(const sal_Char * pText)2130cdf0e10cSrcweir void MyWin::print( const sal_Char* pText )
2131cdf0e10cSrcweir {
2132cdf0e10cSrcweir 	print( UniString::CreateFromAscii( pText ) );
2133cdf0e10cSrcweir }
2134cdf0e10cSrcweir 
2135cdf0e10cSrcweir //-------------------------------------------------------------------------
print(const UniString & rText)2136cdf0e10cSrcweir void MyWin::print( const UniString& rText )
2137cdf0e10cSrcweir {
2138cdf0e10cSrcweir 	vos::OGuard aGuard( Application::GetSolarMutex() );
2139cdf0e10cSrcweir 
2140cdf0e10cSrcweir 	if ( m_pOutEdit )
2141cdf0e10cSrcweir 	{
2142cdf0e10cSrcweir 		m_pOutEdit->Append( rText );
2143cdf0e10cSrcweir 		m_pOutEdit->Update();
2144cdf0e10cSrcweir 	}
2145cdf0e10cSrcweir }
2146cdf0e10cSrcweir 
2147cdf0e10cSrcweir //-------------------------------------------------------------------------
IMPL_LINK(MyWin,ToolBarHandler,ToolBox *,pToolBox)2148cdf0e10cSrcweir IMPL_LINK( MyWin, ToolBarHandler, ToolBox*, pToolBox )
2149cdf0e10cSrcweir {
2150cdf0e10cSrcweir 	USHORT nItemId   = pToolBox->GetCurItemId();
2151cdf0e10cSrcweir 	UniString aCmdLine = m_pCmdEdit->GetText();
2152cdf0e10cSrcweir 
2153cdf0e10cSrcweir     ULONG n = Application::ReleaseSolarMutex();
2154cdf0e10cSrcweir 
2155cdf0e10cSrcweir 	switch( nItemId )
2156cdf0e10cSrcweir 	{
2157cdf0e10cSrcweir 		case MYWIN_ITEMID_CLEAR:
2158cdf0e10cSrcweir 		{
2159cdf0e10cSrcweir 			vos::OGuard aGuard( Application::GetSolarMutex() );
2160cdf0e10cSrcweir 
2161cdf0e10cSrcweir 			m_pOutEdit->Clear();
2162cdf0e10cSrcweir 			m_pOutEdit->Show();
2163cdf0e10cSrcweir 			break;
2164cdf0e10cSrcweir 		}
2165cdf0e10cSrcweir 
2166cdf0e10cSrcweir 		case MYWIN_ITEMID_CREATE:
2167cdf0e10cSrcweir 			if ( m_pContent )
2168cdf0e10cSrcweir 			{
2169cdf0e10cSrcweir 				UniString aText( UniString::CreateFromAscii(
2170cdf0e10cSrcweir 									RTL_CONSTASCII_STRINGPARAM(
2171cdf0e10cSrcweir 										"Content released: " ) ) );
2172cdf0e10cSrcweir 				aText += m_pContent->getURL();
2173cdf0e10cSrcweir 
2174cdf0e10cSrcweir 				m_pContent->dispose();
2175cdf0e10cSrcweir 				m_pContent->release();
2176cdf0e10cSrcweir 				m_pContent = NULL;
2177cdf0e10cSrcweir 
2178cdf0e10cSrcweir 				print( aText );
2179cdf0e10cSrcweir 			}
2180cdf0e10cSrcweir 
2181cdf0e10cSrcweir 			m_pContent = UcbContent::create( m_aUCB, aCmdLine, m_pOutEdit );
2182cdf0e10cSrcweir 			if ( m_pContent )
2183cdf0e10cSrcweir 			{
2184cdf0e10cSrcweir 				String aText( UniString::CreateFromAscii(
2185cdf0e10cSrcweir 								RTL_CONSTASCII_STRINGPARAM(
2186cdf0e10cSrcweir 									"Created content: " ) ) );
2187cdf0e10cSrcweir 				aText += String( m_pContent->getURL() );
2188cdf0e10cSrcweir 				aText.AppendAscii( RTL_CONSTASCII_STRINGPARAM( " - " ) );
2189cdf0e10cSrcweir 				aText += String( m_pContent->getType() );
2190cdf0e10cSrcweir 				print( aText );
2191cdf0e10cSrcweir 			}
2192cdf0e10cSrcweir 			else
2193cdf0e10cSrcweir 			{
2194cdf0e10cSrcweir 				String aText( UniString::CreateFromAscii(
2195cdf0e10cSrcweir 								RTL_CONSTASCII_STRINGPARAM(
2196cdf0e10cSrcweir 									"Creation failed for content: " ) ) );
2197cdf0e10cSrcweir 				aText += String( aCmdLine );
2198cdf0e10cSrcweir 				print( aText );
2199cdf0e10cSrcweir 			}
2200cdf0e10cSrcweir 			break;
2201cdf0e10cSrcweir 
2202cdf0e10cSrcweir 		case MYWIN_ITEMID_RELEASE:
2203cdf0e10cSrcweir 			if ( m_pContent )
2204cdf0e10cSrcweir 			{
2205cdf0e10cSrcweir 				UniString aText( UniString::CreateFromAscii(
2206cdf0e10cSrcweir 									RTL_CONSTASCII_STRINGPARAM(
2207cdf0e10cSrcweir 										"Content released: " ) ) );
2208cdf0e10cSrcweir 				aText += m_pContent->getURL();
2209cdf0e10cSrcweir 
2210cdf0e10cSrcweir 				m_pContent->dispose();
2211cdf0e10cSrcweir 				m_pContent->release();
2212cdf0e10cSrcweir 				m_pContent = NULL;
2213cdf0e10cSrcweir 
2214cdf0e10cSrcweir 				print( aText );
2215cdf0e10cSrcweir 			}
2216cdf0e10cSrcweir 			else
2217cdf0e10cSrcweir 				print( "No content!" );
2218cdf0e10cSrcweir 
2219cdf0e10cSrcweir 			break;
2220cdf0e10cSrcweir 
2221cdf0e10cSrcweir 		case MYWIN_ITEMID_COMMANDS:
2222cdf0e10cSrcweir 			if ( m_pContent )
2223cdf0e10cSrcweir 				m_pContent->getCommands();
2224cdf0e10cSrcweir 			else
2225cdf0e10cSrcweir 				print( "No content!" );
2226cdf0e10cSrcweir 
2227cdf0e10cSrcweir 			break;
2228cdf0e10cSrcweir 
2229cdf0e10cSrcweir 		case MYWIN_ITEMID_PROPS:
2230cdf0e10cSrcweir 			if ( m_pContent )
2231cdf0e10cSrcweir 				m_pContent->getProperties();
2232cdf0e10cSrcweir 			else
2233cdf0e10cSrcweir 				print( "No content!" );
2234cdf0e10cSrcweir 
2235cdf0e10cSrcweir 			break;
2236cdf0e10cSrcweir 
2237cdf0e10cSrcweir 		case MYWIN_ITEMID_ADD_PROP:
2238cdf0e10cSrcweir 			if ( m_pContent )
2239cdf0e10cSrcweir 				m_pContent->addStringProperty(
2240cdf0e10cSrcweir 						aCmdLine,
2241cdf0e10cSrcweir                         rtl::OUString::createFromAscii( "DefaultValue" ) );
2242cdf0e10cSrcweir 			else
2243cdf0e10cSrcweir 				print( "No content!" );
2244cdf0e10cSrcweir 
2245cdf0e10cSrcweir 			break;
2246cdf0e10cSrcweir 
2247cdf0e10cSrcweir 		case MYWIN_ITEMID_REMOVE_PROP:
2248cdf0e10cSrcweir 			if ( m_pContent )
2249cdf0e10cSrcweir 				m_pContent->removeProperty(	aCmdLine );
2250cdf0e10cSrcweir 			else
2251cdf0e10cSrcweir 				print( "No content!" );
2252cdf0e10cSrcweir 
2253cdf0e10cSrcweir 			break;
2254cdf0e10cSrcweir 
2255cdf0e10cSrcweir 		case MYWIN_ITEMID_GET_PROP:
2256cdf0e10cSrcweir 			if ( m_pContent )
2257cdf0e10cSrcweir 				m_pContent->getStringPropertyValue( aCmdLine );
2258cdf0e10cSrcweir 			else
2259cdf0e10cSrcweir 				print( "No content!" );
2260cdf0e10cSrcweir 
2261cdf0e10cSrcweir 			break;
2262cdf0e10cSrcweir 
2263cdf0e10cSrcweir 		case MYWIN_ITEMID_SET_PROP:
2264cdf0e10cSrcweir 			if ( m_pContent )
2265cdf0e10cSrcweir 				m_pContent->setStringPropertyValue(
2266cdf0e10cSrcweir 								aCmdLine,
2267cdf0e10cSrcweir                                 rtl::OUString::createFromAscii( "NewValue" ) );
2268cdf0e10cSrcweir 			else
2269cdf0e10cSrcweir 				print( "No content!" );
2270cdf0e10cSrcweir 
2271cdf0e10cSrcweir 			break;
2272cdf0e10cSrcweir 
2273cdf0e10cSrcweir 		case MYWIN_ITEMID_OPEN:
2274cdf0e10cSrcweir 			if ( m_pContent )
2275cdf0e10cSrcweir                 m_pContent->open(rtl::OUString::createFromAscii("open"),
2276cdf0e10cSrcweir 								 aCmdLine, !m_bTiming, m_bTiming, m_bSort, 0,
2277cdf0e10cSrcweir 								 0, m_nFetchSize);
2278cdf0e10cSrcweir 			else
2279cdf0e10cSrcweir 				print( "No content!" );
2280cdf0e10cSrcweir 
2281cdf0e10cSrcweir 			break;
2282cdf0e10cSrcweir 
2283cdf0e10cSrcweir 		case MYWIN_ITEMID_OPEN_ALL:
2284cdf0e10cSrcweir 			if ( m_pContent )
2285cdf0e10cSrcweir 				m_pContent->openAll(m_aUCB, !m_bTiming, m_bTiming, m_bSort,
2286cdf0e10cSrcweir 									m_nFetchSize);
2287cdf0e10cSrcweir 			else
2288cdf0e10cSrcweir 				print( "No content!" );
2289cdf0e10cSrcweir 
2290cdf0e10cSrcweir 			break;
2291cdf0e10cSrcweir 
2292cdf0e10cSrcweir 		case MYWIN_ITEMID_UPDATE:
2293cdf0e10cSrcweir 			if ( m_pContent )
2294cdf0e10cSrcweir                 m_pContent->open(rtl::OUString::createFromAscii("update"),
2295cdf0e10cSrcweir 								 aCmdLine, !m_bTiming, m_bTiming, m_bSort, 0,
2296cdf0e10cSrcweir 								 0, m_nFetchSize);
2297cdf0e10cSrcweir 			else
2298cdf0e10cSrcweir 				print( "No content!" );
2299cdf0e10cSrcweir 
2300cdf0e10cSrcweir 			break;
2301cdf0e10cSrcweir 
2302cdf0e10cSrcweir 		case MYWIN_ITEMID_SYNCHRONIZE:
2303cdf0e10cSrcweir 			if ( m_pContent )
2304cdf0e10cSrcweir                 m_pContent->open(rtl::OUString::createFromAscii("synchronize"),
2305cdf0e10cSrcweir 								 aCmdLine, !m_bTiming, m_bTiming, m_bSort, 0,
2306cdf0e10cSrcweir 								 0, m_nFetchSize);
2307cdf0e10cSrcweir 			else
2308cdf0e10cSrcweir 				print( "No content!" );
2309cdf0e10cSrcweir 
2310cdf0e10cSrcweir 			break;
2311cdf0e10cSrcweir 
2312cdf0e10cSrcweir 		case MYWIN_ITEMID_SEARCH:
2313cdf0e10cSrcweir 			if ( m_pContent )
2314cdf0e10cSrcweir                 m_pContent->open(rtl::OUString::createFromAscii("search"),
2315cdf0e10cSrcweir 								 aCmdLine, !m_bTiming, m_bTiming, m_bSort, 0,
2316cdf0e10cSrcweir 								 0, m_nFetchSize);
2317cdf0e10cSrcweir 			else
2318cdf0e10cSrcweir 				print( "No content!" );
2319cdf0e10cSrcweir 
2320cdf0e10cSrcweir 			break;
2321cdf0e10cSrcweir 
2322cdf0e10cSrcweir 		case MYWIN_ITEMID_REORGANIZE:
2323cdf0e10cSrcweir 			if ( m_pContent )
2324cdf0e10cSrcweir 				m_pContent->executeCommand (
2325cdf0e10cSrcweir                     rtl::OUString::createFromAscii ("reorganizeData"),
2326cdf0e10cSrcweir                     uno::Any());
2327cdf0e10cSrcweir 			else
2328cdf0e10cSrcweir 				print( "No content!" );
2329cdf0e10cSrcweir 
2330cdf0e10cSrcweir 			break;
2331cdf0e10cSrcweir 
2332cdf0e10cSrcweir 		case MYWIN_ITEMID_COPY:
2333cdf0e10cSrcweir 			if ( m_pContent )
2334cdf0e10cSrcweir 				m_pContent->transfer( aCmdLine, sal_False );
2335cdf0e10cSrcweir 			else
2336cdf0e10cSrcweir 				print( "No content!" );
2337cdf0e10cSrcweir 
2338cdf0e10cSrcweir 			break;
2339cdf0e10cSrcweir 
2340cdf0e10cSrcweir 		case MYWIN_ITEMID_MOVE:
2341cdf0e10cSrcweir 			if ( m_pContent )
2342cdf0e10cSrcweir 				m_pContent->transfer( aCmdLine, sal_True );
2343cdf0e10cSrcweir 			else
2344cdf0e10cSrcweir 				print( "No content!" );
2345cdf0e10cSrcweir 
2346cdf0e10cSrcweir 			break;
2347cdf0e10cSrcweir 
2348cdf0e10cSrcweir 		case MYWIN_ITEMID_DELETE:
2349cdf0e10cSrcweir 			if ( m_pContent )
2350cdf0e10cSrcweir 				m_pContent->destroy();
2351cdf0e10cSrcweir 			else
2352cdf0e10cSrcweir 				print( "No content!" );
2353cdf0e10cSrcweir 
2354cdf0e10cSrcweir 			break;
2355cdf0e10cSrcweir 
2356cdf0e10cSrcweir 		case MYWIN_ITEMID_TIMING:
2357cdf0e10cSrcweir 			m_bTiming = m_pTool->IsItemChecked(MYWIN_ITEMID_TIMING) != false;
2358cdf0e10cSrcweir 			break;
2359cdf0e10cSrcweir 
2360cdf0e10cSrcweir 		case MYWIN_ITEMID_SORT:
2361cdf0e10cSrcweir 			m_bSort = m_pTool->IsItemChecked(MYWIN_ITEMID_SORT) != false;
2362cdf0e10cSrcweir 			break;
2363cdf0e10cSrcweir 
2364cdf0e10cSrcweir 		case MYWIN_ITEMID_FETCHSIZE:
2365cdf0e10cSrcweir 		{
2366cdf0e10cSrcweir 			m_nFetchSize = aCmdLine.ToInt32();
2367cdf0e10cSrcweir 			String aText;
2368cdf0e10cSrcweir 			if (m_nFetchSize > 0)
2369cdf0e10cSrcweir 			{
2370cdf0e10cSrcweir 				aText.AssignAscii("Fetch size set to ");
2371cdf0e10cSrcweir 				aText += String::CreateFromInt32(m_nFetchSize);
2372cdf0e10cSrcweir 			}
2373cdf0e10cSrcweir 			else
2374cdf0e10cSrcweir 				aText.AssignAscii("Fetch size reset to default");
2375cdf0e10cSrcweir 			print(aText);
2376cdf0e10cSrcweir 			break;
2377cdf0e10cSrcweir 		}
2378cdf0e10cSrcweir 
2379cdf0e10cSrcweir 		case MYWIN_ITEMID_SYS2URI:
2380cdf0e10cSrcweir 		{
2381cdf0e10cSrcweir             uno::Reference< ucb::XContentProviderManager >
2382cdf0e10cSrcweir                 xManager(m_aUCB.getContentProvider(), uno::UNO_QUERY);
2383cdf0e10cSrcweir 			DBG_ASSERT(xManager.is(),
2384cdf0e10cSrcweir 					   "MyWin::ToolBarHandler(): Service lacks interface");
2385cdf0e10cSrcweir 
2386cdf0e10cSrcweir             rtl::OUString aURL(getLocalFileURL(xManager));
2387cdf0e10cSrcweir 
2388cdf0e10cSrcweir 			String aText(RTL_CONSTASCII_USTRINGPARAM("Local file URL: "));
2389cdf0e10cSrcweir 			aText += String(aURL);
2390cdf0e10cSrcweir 			aText.AppendAscii("\nConversion: ");
2391cdf0e10cSrcweir 			aText += aCmdLine;
2392cdf0e10cSrcweir 			aText.AppendAscii(" to ");
2393cdf0e10cSrcweir             aText += String(getFileURLFromSystemPath(xManager,
2394cdf0e10cSrcweir 														  aURL,
2395cdf0e10cSrcweir 														  aCmdLine));
2396cdf0e10cSrcweir 			print(aText);
2397cdf0e10cSrcweir 			break;
2398cdf0e10cSrcweir 		}
2399cdf0e10cSrcweir 
2400cdf0e10cSrcweir 		case MYWIN_ITEMID_URI2SYS:
2401cdf0e10cSrcweir 		{
2402cdf0e10cSrcweir             uno::Reference< ucb::XContentProviderManager >
2403cdf0e10cSrcweir                 xManager(m_aUCB.getContentProvider(), uno::UNO_QUERY);
2404cdf0e10cSrcweir 			DBG_ASSERT(xManager.is(),
2405cdf0e10cSrcweir 					   "MyWin::ToolBarHandler(): Service lacks interface");
2406cdf0e10cSrcweir 
2407cdf0e10cSrcweir 			String aText(RTL_CONSTASCII_USTRINGPARAM("Conversion: "));
2408cdf0e10cSrcweir 			aText += aCmdLine;
2409cdf0e10cSrcweir 			aText.AppendAscii(" to ");
2410cdf0e10cSrcweir             aText += String(getSystemPathFromFileURL(xManager,
2411cdf0e10cSrcweir 														  aCmdLine));
2412cdf0e10cSrcweir 			print(aText);
2413cdf0e10cSrcweir 			break;
2414cdf0e10cSrcweir 		}
2415cdf0e10cSrcweir 
2416cdf0e10cSrcweir 		case MYWIN_ITEMID_OFFLINE:
2417cdf0e10cSrcweir 		case MYWIN_ITEMID_ONLINE:
2418cdf0e10cSrcweir 		{
2419cdf0e10cSrcweir             uno::Reference< ucb::XContentProviderManager >
2420cdf0e10cSrcweir                 xManager(m_aUCB.getContentProvider(), uno::UNO_QUERY);
2421cdf0e10cSrcweir             uno::Reference< ucb::XCommandProcessor > xProcessor;
2422cdf0e10cSrcweir 			if (xManager.is())
2423cdf0e10cSrcweir 				xProcessor
2424cdf0e10cSrcweir                     = uno::Reference< ucb::XCommandProcessor >(
2425cdf0e10cSrcweir                         xManager->queryContentProvider(aCmdLine),
2426cdf0e10cSrcweir                         uno::UNO_QUERY);
2427cdf0e10cSrcweir 			if (!xProcessor.is())
2428cdf0e10cSrcweir 			{
2429cdf0e10cSrcweir 				String aText(RTL_CONSTASCII_USTRINGPARAM(
2430cdf0e10cSrcweir 					             "No offline support for URL "));
2431cdf0e10cSrcweir 				aText += aCmdLine;
2432cdf0e10cSrcweir 				print(aText);
2433cdf0e10cSrcweir 				break;
2434cdf0e10cSrcweir 			}
2435cdf0e10cSrcweir 
2436cdf0e10cSrcweir             rtl::OUString aName;
2437cdf0e10cSrcweir             uno::Any aArgument;
2438cdf0e10cSrcweir 			if (nItemId == MYWIN_ITEMID_OFFLINE)
2439cdf0e10cSrcweir 			{
2440cdf0e10cSrcweir                 aName = rtl::OUString::createFromAscii("goOffline");
2441cdf0e10cSrcweir 
2442cdf0e10cSrcweir                 uno::Sequence<
2443cdf0e10cSrcweir                     uno::Reference< ucb::XContentIdentifier > >
2444cdf0e10cSrcweir                         aIdentifiers(1);
2445cdf0e10cSrcweir 				aIdentifiers[0]
2446cdf0e10cSrcweir 					= m_aUCB.getContentIdentifierFactory()->
2447cdf0e10cSrcweir 					             createContentIdentifier(aCmdLine);
2448cdf0e10cSrcweir 				aArgument <<= aIdentifiers;
2449cdf0e10cSrcweir 			}
2450cdf0e10cSrcweir 			else
2451cdf0e10cSrcweir                 aName = rtl::OUString::createFromAscii("goOnline");
2452cdf0e10cSrcweir 
2453cdf0e10cSrcweir 			UcbCommandProcessor(m_aUCB, xProcessor, m_pOutEdit).
2454cdf0e10cSrcweir 				executeCommand(aName, aArgument);
2455cdf0e10cSrcweir 			break;
2456cdf0e10cSrcweir 		}
2457cdf0e10cSrcweir 
2458cdf0e10cSrcweir 		default: // Ignored.
2459cdf0e10cSrcweir 			break;
2460cdf0e10cSrcweir 	}
2461cdf0e10cSrcweir 
2462cdf0e10cSrcweir     Application::AcquireSolarMutex( n );
2463cdf0e10cSrcweir 	return 0;
2464cdf0e10cSrcweir }
2465cdf0e10cSrcweir 
2466cdf0e10cSrcweir /*========================================================================
2467cdf0e10cSrcweir  *
2468cdf0e10cSrcweir  * MyApp.
2469cdf0e10cSrcweir  *
2470cdf0e10cSrcweir  *=======================================================================*/
2471cdf0e10cSrcweir class MyApp : public Application
2472cdf0e10cSrcweir {
2473cdf0e10cSrcweir public:
2474cdf0e10cSrcweir 	virtual void Main();
2475cdf0e10cSrcweir };
2476cdf0e10cSrcweir 
2477cdf0e10cSrcweir MyApp aMyApp;
2478cdf0e10cSrcweir 
2479cdf0e10cSrcweir //-------------------------------------------------------------------------
2480cdf0e10cSrcweir // virtual
Main()2481cdf0e10cSrcweir void MyApp::Main()
2482cdf0e10cSrcweir {
2483cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2484cdf0e10cSrcweir 	// Read command line params.
2485cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2486cdf0e10cSrcweir 
2487cdf0e10cSrcweir 	rtl::OUString aConfigurationKey1(rtl::OUString::createFromAscii(
2488cdf0e10cSrcweir 		                                 UCB_CONFIGURATION_KEY1_LOCAL));
2489cdf0e10cSrcweir 	rtl::OUString aConfigurationKey2(rtl::OUString::createFromAscii(
2490cdf0e10cSrcweir 		                                 UCB_CONFIGURATION_KEY2_OFFICE));
2491cdf0e10cSrcweir 
2492cdf0e10cSrcweir 	USHORT nParams = Application::GetCommandLineParamCount();
2493cdf0e10cSrcweir 	for ( USHORT n = 0; n < nParams; ++n )
2494cdf0e10cSrcweir 	{
2495cdf0e10cSrcweir 		String aParam( Application::GetCommandLineParam( n ) );
2496cdf0e10cSrcweir 		if (aParam.CompareIgnoreCaseToAscii("-key=",
2497cdf0e10cSrcweir 											RTL_CONSTASCII_LENGTH("-key="))
2498cdf0e10cSrcweir 			    == COMPARE_EQUAL)
2499cdf0e10cSrcweir 		{
2500cdf0e10cSrcweir 			xub_StrLen nSlash
2501cdf0e10cSrcweir 				= aParam.Search('/', RTL_CONSTASCII_LENGTH("-key="));
2502cdf0e10cSrcweir 			if (nSlash == STRING_NOTFOUND)
2503cdf0e10cSrcweir 			{
2504cdf0e10cSrcweir 				aConfigurationKey1
2505cdf0e10cSrcweir 					= aParam.Copy(RTL_CONSTASCII_LENGTH("-key="));
2506cdf0e10cSrcweir 				aConfigurationKey2 = rtl::OUString();
2507cdf0e10cSrcweir 			}
2508cdf0e10cSrcweir 			else
2509cdf0e10cSrcweir 			{
2510cdf0e10cSrcweir 				aConfigurationKey1
2511cdf0e10cSrcweir 					= aParam.Copy(RTL_CONSTASCII_LENGTH("-key="),
2512cdf0e10cSrcweir 								  nSlash - RTL_CONSTASCII_LENGTH("-key="));
2513cdf0e10cSrcweir 				aConfigurationKey2
2514cdf0e10cSrcweir 					= aParam.Copy(nSlash + 1);
2515cdf0e10cSrcweir 			}
2516cdf0e10cSrcweir 		}
2517cdf0e10cSrcweir 	}
2518cdf0e10cSrcweir 
2519cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2520cdf0e10cSrcweir 	// Initialize local Service Manager and basic services.
2521cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2522cdf0e10cSrcweir 
2523cdf0e10cSrcweir     uno::Reference< lang::XMultiServiceFactory > xFac;
2524cdf0e10cSrcweir 	try
2525cdf0e10cSrcweir 	{
2526cdf0e10cSrcweir         uno::Reference< uno::XComponentContext > xCtx(
2527cdf0e10cSrcweir             cppu::defaultBootstrap_InitialComponentContext() );
2528cdf0e10cSrcweir         if ( !xCtx.is() )
2529cdf0e10cSrcweir         {
2530cdf0e10cSrcweir             DBG_ERROR( "Error creating initial component context!" );
2531cdf0e10cSrcweir             return;
2532cdf0e10cSrcweir         }
2533cdf0e10cSrcweir 
2534cdf0e10cSrcweir         xFac = uno::Reference< lang::XMultiServiceFactory >(
2535cdf0e10cSrcweir             xCtx->getServiceManager(), uno::UNO_QUERY );
2536cdf0e10cSrcweir 
2537cdf0e10cSrcweir         if ( !xFac.is() )
2538cdf0e10cSrcweir         {
2539cdf0e10cSrcweir             DBG_ERROR( "No service manager!" );
2540cdf0e10cSrcweir             return;
2541cdf0e10cSrcweir         }
2542cdf0e10cSrcweir 	}
2543cdf0e10cSrcweir 	catch ( uno::Exception )
2544cdf0e10cSrcweir 	{
2545cdf0e10cSrcweir         DBG_ERROR( "Exception during creation of initial component context!" );
2546cdf0e10cSrcweir 		return;
2547cdf0e10cSrcweir 	}
2548cdf0e10cSrcweir 
2549cdf0e10cSrcweir 	comphelper::setProcessServiceFactory( xFac );
2550cdf0e10cSrcweir 
2551cdf0e10cSrcweir     uno::Reference< lang::XComponent > xComponent( xFac, uno::UNO_QUERY );
2552cdf0e10cSrcweir 
2553cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2554cdf0e10cSrcweir 	// Create Application Window...
2555cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2556cdf0e10cSrcweir 
2557cdf0e10cSrcweir 	Help::EnableBalloonHelp();
2558cdf0e10cSrcweir 
2559cdf0e10cSrcweir 	MyWin *pMyWin = new MyWin( NULL, WB_APP | WB_STDWORK, xFac,
2560cdf0e10cSrcweir 							   aConfigurationKey1, aConfigurationKey2 );
2561cdf0e10cSrcweir 
2562cdf0e10cSrcweir 	pMyWin->
2563cdf0e10cSrcweir 		SetText(
2564cdf0e10cSrcweir 			UniString::CreateFromAscii(
2565cdf0e10cSrcweir 				RTL_CONSTASCII_STRINGPARAM( "UCB Demo/Test Application" ) ) );
2566cdf0e10cSrcweir 
2567cdf0e10cSrcweir 	pMyWin->SetPosSizePixel( 0, 0, 1024, 768 );
2568cdf0e10cSrcweir 
2569cdf0e10cSrcweir 	pMyWin->Show();
2570cdf0e10cSrcweir 
2571cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2572cdf0e10cSrcweir 	// Go...
2573cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2574cdf0e10cSrcweir 
2575cdf0e10cSrcweir 	Execute();
2576cdf0e10cSrcweir 
2577cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2578cdf0e10cSrcweir 	// Destroy Application Window...
2579cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2580cdf0e10cSrcweir 
2581cdf0e10cSrcweir 	delete pMyWin;
2582cdf0e10cSrcweir 
2583cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2584cdf0e10cSrcweir 	// Cleanup.
2585cdf0e10cSrcweir 	//////////////////////////////////////////////////////////////////////
2586cdf0e10cSrcweir 
2587cdf0e10cSrcweir     ::ucbhelper::ContentBroker::deinitialize();
2588cdf0e10cSrcweir 
2589cdf0e10cSrcweir 	// Dispose local service manager.
2590cdf0e10cSrcweir 	if ( xComponent.is() )
2591cdf0e10cSrcweir 		xComponent->dispose();
2592cdf0e10cSrcweir }
2593cdf0e10cSrcweir 
2594