1*96de5490SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*96de5490SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*96de5490SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*96de5490SAndrew Rist  * distributed with this work for additional information
6*96de5490SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*96de5490SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*96de5490SAndrew Rist  * "License"); you may not use this file except in compliance
9*96de5490SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*96de5490SAndrew Rist  *
11*96de5490SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*96de5490SAndrew Rist  *
13*96de5490SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*96de5490SAndrew Rist  * software distributed under the License is distributed on an
15*96de5490SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*96de5490SAndrew Rist  * KIND, either express or implied.  See the License for the
17*96de5490SAndrew Rist  * specific language governing permissions and limitations
18*96de5490SAndrew Rist  * under the License.
19*96de5490SAndrew Rist  *
20*96de5490SAndrew Rist  *************************************************************/
21*96de5490SAndrew Rist 
22*96de5490SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_dbaccess.hxx"
26cdf0e10cSrcweir #ifndef DBAUI_COLLECTIONVIEW_HXX
27cdf0e10cSrcweir #include "CollectionView.hxx"
28cdf0e10cSrcweir #endif
29cdf0e10cSrcweir #ifndef DBAUI_COLLECTIONVIEW_HRC
30cdf0e10cSrcweir #include "CollectionView.hrc"
31cdf0e10cSrcweir #endif
32cdf0e10cSrcweir #ifndef _TOOLS_DEBUG_HXX
33cdf0e10cSrcweir #include <tools/debug.hxx>
34cdf0e10cSrcweir #endif
35cdf0e10cSrcweir #ifndef TOOLS_DIAGNOSE_EX_H
36cdf0e10cSrcweir #include <tools/diagnose_ex.h>
37cdf0e10cSrcweir #endif
38cdf0e10cSrcweir #ifndef _DBAUI_MODULE_DBU_HXX_
39cdf0e10cSrcweir #include "moduledbu.hxx"
40cdf0e10cSrcweir #endif
41cdf0e10cSrcweir #ifndef _DBU_DLG_HRC_
42cdf0e10cSrcweir #include "dbu_dlg.hrc"
43cdf0e10cSrcweir #endif
44cdf0e10cSrcweir #ifndef _COMPHELPER_INTERACTION_HXX_
45cdf0e10cSrcweir #include <comphelper/interaction.hxx>
46cdf0e10cSrcweir #endif
47cdf0e10cSrcweir #ifndef _CPPUHELPER_EXC_HLP_HXX_
48cdf0e10cSrcweir #include <cppuhelper/exc_hlp.hxx>
49cdf0e10cSrcweir #endif
50cdf0e10cSrcweir #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_
51cdf0e10cSrcweir #include <toolkit/helper/vclunohelper.hxx>
52cdf0e10cSrcweir #endif
53cdf0e10cSrcweir #ifndef SVT_QUERYFOLDER_HXX
54cdf0e10cSrcweir #include <svtools/QueryFolderName.hxx>
55cdf0e10cSrcweir #endif
56cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
57cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp>
58cdf0e10cSrcweir #endif
59cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_XINITIALIZATION_HPP_
60cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp>
61cdf0e10cSrcweir #endif
62cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XCHILD_HPP_
63cdf0e10cSrcweir #include <com/sun/star/container/XChild.hpp>
64cdf0e10cSrcweir #endif
65cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
66cdf0e10cSrcweir #include <com/sun/star/container/XNameContainer.hpp>
67cdf0e10cSrcweir #endif
68cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
69cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp>
70cdf0e10cSrcweir #endif
71cdf0e10cSrcweir #ifndef _SV_MSGBOX_HXX
72cdf0e10cSrcweir #include <vcl/msgbox.hxx>
73cdf0e10cSrcweir #endif
74cdf0e10cSrcweir #ifndef DBACCESS_SHARED_DBUSTRINGS_HRC
75cdf0e10cSrcweir #include "dbustrings.hrc"
76cdf0e10cSrcweir #endif
77cdf0e10cSrcweir #ifndef DBAUI_TOOLS_HXX
78cdf0e10cSrcweir #include "UITools.hxx"
79cdf0e10cSrcweir #endif
80cdf0e10cSrcweir #ifndef _COM_SUN_STAR_CONTAINER_XHIERARCHICALNAMECONTAINER_HPP_
81cdf0e10cSrcweir #include <com/sun/star/container/XHierarchicalNameContainer.hpp>
82cdf0e10cSrcweir #endif
83cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_INTERACTIVEAUGMENTEDIOEXCEPTION_HPP_
84cdf0e10cSrcweir #include <com/sun/star/ucb/InteractiveAugmentedIOException.hpp>
85cdf0e10cSrcweir #endif
86cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UCB_IOERRORCODE_HPP_
87cdf0e10cSrcweir #include <com/sun/star/ucb/IOErrorCode.hpp>
88cdf0e10cSrcweir #endif
89cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_XINTERACTIONHANDLER_HPP_
90cdf0e10cSrcweir #include <com/sun/star/task/XInteractionHandler.hpp>
91cdf0e10cSrcweir #endif
92cdf0e10cSrcweir #ifndef _COM_SUN_STAR_TASK_INTERACTIONCLASSIFICATION_HPP_
93cdf0e10cSrcweir #include <com/sun/star/task/InteractionClassification.hpp>
94cdf0e10cSrcweir #endif
95cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_SQLEXCEPTION_HPP_
96cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLException.hpp>
97cdf0e10cSrcweir #endif
98cdf0e10cSrcweir #ifndef _COM_SUN_STAR_AWT_XWINDOW_HPP_
99cdf0e10cSrcweir #include <com/sun/star/awt/XWindow.hpp>
100cdf0e10cSrcweir #endif
101cdf0e10cSrcweir #ifndef INCLUDED_SVTOOLS_VIEWOPTIONS_HXX
102cdf0e10cSrcweir #include <unotools/viewoptions.hxx>
103cdf0e10cSrcweir #endif
104cdf0e10cSrcweir #ifndef _OSL_THREAD_H_
105cdf0e10cSrcweir #include <osl/thread.h>
106cdf0e10cSrcweir #endif
107cdf0e10cSrcweir #ifndef _DBHELPER_DBEXCEPTION_HXX_
108cdf0e10cSrcweir #include <connectivity/dbexception.hxx>
109cdf0e10cSrcweir #endif
110cdf0e10cSrcweir 
111cdf0e10cSrcweir #define FILEDIALOG_DEF_IMAGEBORDER	10
112cdf0e10cSrcweir //.........................................................................
113cdf0e10cSrcweir namespace dbaui
114cdf0e10cSrcweir {
115cdf0e10cSrcweir //.........................................................................
116cdf0e10cSrcweir 
117cdf0e10cSrcweir using namespace ::com::sun::star::uno;
118cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
119cdf0e10cSrcweir using namespace ::com::sun::star::lang;
120cdf0e10cSrcweir using namespace ::com::sun::star::beans;
121cdf0e10cSrcweir using namespace ::com::sun::star::container;
122cdf0e10cSrcweir using namespace ::com::sun::star::ucb;
123cdf0e10cSrcweir using namespace ::com::sun::star::task;
124cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
125cdf0e10cSrcweir using namespace comphelper;
126cdf0e10cSrcweir // -----------------------------------------------------------------------------
127cdf0e10cSrcweir DBG_NAME(OCollectionView)
128cdf0e10cSrcweir OCollectionView::OCollectionView( Window * pParent
129cdf0e10cSrcweir 								 ,const Reference< XContent>& _xContent
130cdf0e10cSrcweir 								 ,const ::rtl::OUString& _sDefaultName
131cdf0e10cSrcweir 								 ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _xORB)
132cdf0e10cSrcweir 	: ModalDialog( pParent, ModuleRes(DLG_COLLECTION_VIEW))
133cdf0e10cSrcweir 	, m_aFTCurrentPath(	this, ModuleRes( FT_EXPLORERFILE_CURRENTPATH ) )
134cdf0e10cSrcweir 	, m_aNewFolder(		this, ModuleRes( BTN_EXPLORERFILE_NEWFOLDER ) )
135cdf0e10cSrcweir 	, m_aUp(			this, ModuleRes( BTN_EXPLORERFILE_UP ) )
136cdf0e10cSrcweir     , m_aView(			this, ModuleRes( CTRL_VIEW ) ,FILEVIEW_SHOW_TITLE )
137cdf0e10cSrcweir 	, m_aFTName(		this, ModuleRes( FT_EXPLORERFILE_FILENAME ) )
138cdf0e10cSrcweir 	, m_aName(			this, ModuleRes( ED_EXPLORERFILE_FILENAME ) )
139cdf0e10cSrcweir 	, m_aFL(			this, ModuleRes( FL_1 ) )
140cdf0e10cSrcweir 	, m_aPB_OK(			this, ModuleRes( BTN_EXPLORERFILE_SAVE ) )
141cdf0e10cSrcweir 	, m_aPB_CANCEL(		this, ModuleRes( PB_CANCEL ) )
142cdf0e10cSrcweir 	, m_aPB_HELP(		this, ModuleRes( PB_HELP ) )
143cdf0e10cSrcweir 	, m_sPath(			ModuleRes( STR_PATHNAME ) )
144cdf0e10cSrcweir 	, m_xContent(_xContent)
145cdf0e10cSrcweir 	, m_xORB(_xORB)
146cdf0e10cSrcweir 	, m_bCreateForm(sal_True)
147cdf0e10cSrcweir {
148cdf0e10cSrcweir 	DBG_CTOR(OCollectionView,NULL);
149cdf0e10cSrcweir 	FreeResource();
150cdf0e10cSrcweir 
151cdf0e10cSrcweir 	OSL_ENSURE(m_xContent.is(),"No valid content!");
152cdf0e10cSrcweir 	m_aView.Initialize(m_xContent,String());
153cdf0e10cSrcweir 	m_aFTCurrentPath.SetStyle( m_aFTCurrentPath.GetStyle() | WB_PATHELLIPSIS );
154cdf0e10cSrcweir 	initCurrentPath();
155cdf0e10cSrcweir 
156cdf0e10cSrcweir 	m_aName.SetText(_sDefaultName);
157cdf0e10cSrcweir 	m_aName.GrabFocus();
158cdf0e10cSrcweir 
159cdf0e10cSrcweir 	m_aNewFolder.SetStyle( m_aNewFolder.GetStyle() | WB_NOPOINTERFOCUS );
160cdf0e10cSrcweir 	m_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SC));
161cdf0e10cSrcweir 	m_aUp.SetModeImage(ModuleRes(IMG_NAVIGATION_BTN_UP_SCH),BMP_COLOR_HIGHCONTRAST);
162cdf0e10cSrcweir 	m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SC));
163cdf0e10cSrcweir 	m_aNewFolder.SetModeImage(ModuleRes(IMG_NAVIGATION_CREATEFOLDER_SCH),BMP_COLOR_HIGHCONTRAST);
164cdf0e10cSrcweir 
165cdf0e10cSrcweir 	m_aView.SetDoubleClickHdl( LINK( this, OCollectionView, Dbl_Click_FileView ) );
166cdf0e10cSrcweir 	m_aView.EnableAutoResize();
167cdf0e10cSrcweir 	m_aUp.SetClickHdl( LINK( this, OCollectionView, Up_Click ) );
168cdf0e10cSrcweir 	m_aNewFolder.SetClickHdl( LINK( this, OCollectionView, NewFolder_Click ) );
169cdf0e10cSrcweir 	m_aPB_OK.SetClickHdl( LINK( this, OCollectionView, Save_Click ) );
170cdf0e10cSrcweir }
171cdf0e10cSrcweir // -----------------------------------------------------------------------------
172cdf0e10cSrcweir OCollectionView::~OCollectionView( )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir 	DBG_DTOR(OCollectionView,NULL);
175cdf0e10cSrcweir }
176cdf0e10cSrcweir // -----------------------------------------------------------------------------
177cdf0e10cSrcweir Reference< XContent> OCollectionView::getSelectedFolder() const
178cdf0e10cSrcweir {
179cdf0e10cSrcweir 	return m_xContent;
180cdf0e10cSrcweir }
181cdf0e10cSrcweir // -----------------------------------------------------------------------------
182cdf0e10cSrcweir IMPL_LINK( OCollectionView, Save_Click, PushButton*, EMPTYARG )
183cdf0e10cSrcweir {
184cdf0e10cSrcweir 	::rtl::OUString sName = m_aName.GetText();
185cdf0e10cSrcweir 	if ( !sName.getLength() )
186cdf0e10cSrcweir 		return 0;
187cdf0e10cSrcweir 	try
188cdf0e10cSrcweir 	{
189cdf0e10cSrcweir 		::rtl::OUString sSubFolder = m_aView.GetCurrentURL();
190cdf0e10cSrcweir 		sal_Int32 nIndex = sName.lastIndexOf('/') + 1;
191cdf0e10cSrcweir 		if ( nIndex )
192cdf0e10cSrcweir 		{
193cdf0e10cSrcweir 			if ( nIndex == 1 ) // special handling for root
194cdf0e10cSrcweir 			{
195cdf0e10cSrcweir 				Reference<XChild> xChild(m_xContent,UNO_QUERY);
196cdf0e10cSrcweir 				Reference<XNameAccess> xNameAccess(xChild,UNO_QUERY);
197cdf0e10cSrcweir 				while( xNameAccess.is() )
198cdf0e10cSrcweir 				{
199cdf0e10cSrcweir 					xNameAccess.set(xChild->getParent(),UNO_QUERY);
200cdf0e10cSrcweir 					if ( xNameAccess.is() )
201cdf0e10cSrcweir 					{
202cdf0e10cSrcweir 						m_xContent.set(xNameAccess,UNO_QUERY);
203cdf0e10cSrcweir 						xChild.set(m_xContent,UNO_QUERY);
204cdf0e10cSrcweir 					}
205cdf0e10cSrcweir 				}
206cdf0e10cSrcweir 				m_aView.Initialize(m_xContent,String());
207cdf0e10cSrcweir 				initCurrentPath();
208cdf0e10cSrcweir 			}
209cdf0e10cSrcweir 			sSubFolder = sName.copy(0,nIndex-1);
210cdf0e10cSrcweir 			sName = sName.copy(nIndex);
211cdf0e10cSrcweir 			Reference<XHierarchicalNameContainer> xHier(m_xContent,UNO_QUERY);
212cdf0e10cSrcweir 			OSL_ENSURE(xHier.is(),"XHierarchicalNameContainer not supported!");
213cdf0e10cSrcweir 			if ( sSubFolder.getLength() && xHier.is() )
214cdf0e10cSrcweir 			{
215cdf0e10cSrcweir 				if ( xHier->hasByHierarchicalName(sSubFolder) )
216cdf0e10cSrcweir 				{
217cdf0e10cSrcweir 					m_xContent.set(xHier->getByHierarchicalName(sSubFolder),UNO_QUERY);
218cdf0e10cSrcweir 				}
219cdf0e10cSrcweir 				else // sub folder doesn't exist
220cdf0e10cSrcweir 				{
221cdf0e10cSrcweir 					Sequence< Any > aValues(2);
222cdf0e10cSrcweir 					PropertyValue aValue;
223cdf0e10cSrcweir 					aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceName"));
224cdf0e10cSrcweir 					aValue.Value <<= sSubFolder;
225cdf0e10cSrcweir 					aValues[0] <<= aValue;
226cdf0e10cSrcweir 
227cdf0e10cSrcweir 					aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ResourceType"));
228cdf0e10cSrcweir 					aValue.Value <<= ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("folder"));
229cdf0e10cSrcweir 					aValues[1] <<= aValue;
230cdf0e10cSrcweir 
231cdf0e10cSrcweir 					InteractionClassification eClass = InteractionClassification_ERROR;
232cdf0e10cSrcweir 					::com::sun::star::ucb::IOErrorCode eError = IOErrorCode_NOT_EXISTING_PATH;
233cdf0e10cSrcweir 					::rtl::OUString sTemp;
234cdf0e10cSrcweir 					InteractiveAugmentedIOException aException(sTemp,Reference<XInterface>(),eClass,eError,aValues);
235cdf0e10cSrcweir 
236cdf0e10cSrcweir 
237cdf0e10cSrcweir 					Reference<XInitialization> xIni(m_xORB->createInstance(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.task.InteractionHandler"))),UNO_QUERY);
238cdf0e10cSrcweir 					if ( xIni.is() )
239cdf0e10cSrcweir 					{
240cdf0e10cSrcweir 						aValue.Name = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Parent"));
241cdf0e10cSrcweir 						aValue.Value <<= VCLUnoHelper::GetInterface( this );
242cdf0e10cSrcweir 						Sequence< Any > aArgs(1);
243cdf0e10cSrcweir 						aArgs[0] <<= makeAny(aValue);
244cdf0e10cSrcweir 						xIni->initialize(aArgs);
245cdf0e10cSrcweir 						OInteractionRequest* pRequest = new OInteractionRequest(makeAny(aException));
246cdf0e10cSrcweir 						Reference< XInteractionRequest > xRequest(pRequest);
247cdf0e10cSrcweir 
248cdf0e10cSrcweir 						OInteractionApprove* pApprove = new OInteractionApprove;
249cdf0e10cSrcweir 						pRequest->addContinuation(pApprove);
250cdf0e10cSrcweir 
251cdf0e10cSrcweir 						Reference< XInteractionHandler > xHandler(xIni,UNO_QUERY);
252cdf0e10cSrcweir 						xHandler->handle(xRequest);
253cdf0e10cSrcweir 					}
254cdf0e10cSrcweir 					return 0;
255cdf0e10cSrcweir 				}
256cdf0e10cSrcweir 			}
257cdf0e10cSrcweir 		}
258cdf0e10cSrcweir 		Reference<XNameContainer> xNameContainer(m_xContent,UNO_QUERY);
259cdf0e10cSrcweir 		if ( xNameContainer.is() )
260cdf0e10cSrcweir 		{
261cdf0e10cSrcweir 			Reference< XContent> xContent;
262cdf0e10cSrcweir 			if ( xNameContainer->hasByName(sName) )
263cdf0e10cSrcweir 			{
264cdf0e10cSrcweir 				QueryBox aBox( this, WB_YES_NO, ModuleRes( STR_ALREADYEXISTOVERWRITE ) );
265cdf0e10cSrcweir 				if ( aBox.Execute() != RET_YES )
266cdf0e10cSrcweir 					return 0;
267cdf0e10cSrcweir 				// xNameContainer->removeByName(sName);
268cdf0e10cSrcweir 			}
269cdf0e10cSrcweir 			m_aName.SetText(sName);
270cdf0e10cSrcweir 			EndDialog( sal_True );
271cdf0e10cSrcweir 		}
272cdf0e10cSrcweir 	}
273cdf0e10cSrcweir     catch( const Exception& )
274cdf0e10cSrcweir     {
275cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
276cdf0e10cSrcweir     }
277cdf0e10cSrcweir 	return 0;
278cdf0e10cSrcweir }
279cdf0e10cSrcweir // -----------------------------------------------------------------------------
280cdf0e10cSrcweir IMPL_LINK( OCollectionView, NewFolder_Click, PushButton*, EMPTYARG )
281cdf0e10cSrcweir {
282cdf0e10cSrcweir 	try
283cdf0e10cSrcweir 	{
284cdf0e10cSrcweir 		Reference<XHierarchicalNameContainer> xNameContainer(m_xContent,UNO_QUERY);
285cdf0e10cSrcweir 		if ( dbaui::insertHierachyElement(this,m_xORB,xNameContainer,String(),m_bCreateForm) )
286cdf0e10cSrcweir 			m_aView.Initialize(m_xContent,String());
287cdf0e10cSrcweir 	}
288cdf0e10cSrcweir     catch( const SQLException& )
289cdf0e10cSrcweir     {
290cdf0e10cSrcweir         showError( ::dbtools::SQLExceptionInfo( ::cppu::getCaughtException() ), this, m_xORB );
291cdf0e10cSrcweir     }
292cdf0e10cSrcweir     catch( const Exception& )
293cdf0e10cSrcweir     {
294cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
295cdf0e10cSrcweir     }
296cdf0e10cSrcweir 	return 0;
297cdf0e10cSrcweir }
298cdf0e10cSrcweir // -----------------------------------------------------------------------------
299cdf0e10cSrcweir IMPL_LINK( OCollectionView, Up_Click, PushButton*, EMPTYARG )
300cdf0e10cSrcweir {
301cdf0e10cSrcweir 	try
302cdf0e10cSrcweir 	{
303cdf0e10cSrcweir 		Reference<XChild> xChild(m_xContent,UNO_QUERY);
304cdf0e10cSrcweir 		if ( xChild.is() )
305cdf0e10cSrcweir 		{
306cdf0e10cSrcweir 			Reference<XNameAccess> xNameAccess(xChild->getParent(),UNO_QUERY);
307cdf0e10cSrcweir 			if ( xNameAccess.is() )
308cdf0e10cSrcweir 			{
309cdf0e10cSrcweir 				m_xContent.set(xNameAccess,UNO_QUERY);
310cdf0e10cSrcweir 				m_aView.Initialize(m_xContent,String());
311cdf0e10cSrcweir 				initCurrentPath();
312cdf0e10cSrcweir 			}
313cdf0e10cSrcweir 			else
314cdf0e10cSrcweir 				m_aUp.Disable();
315cdf0e10cSrcweir 		}
316cdf0e10cSrcweir 	}
317cdf0e10cSrcweir     catch( const Exception& )
318cdf0e10cSrcweir     {
319cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
320cdf0e10cSrcweir     }
321cdf0e10cSrcweir 	return 0;
322cdf0e10cSrcweir }
323cdf0e10cSrcweir // -----------------------------------------------------------------------------
324cdf0e10cSrcweir IMPL_LINK( OCollectionView, Dbl_Click_FileView, SvtFileView*, EMPTYARG )
325cdf0e10cSrcweir {
326cdf0e10cSrcweir 	try
327cdf0e10cSrcweir 	{
328cdf0e10cSrcweir 		Reference<XNameAccess> xNameAccess(m_xContent,UNO_QUERY);
329cdf0e10cSrcweir 		if ( xNameAccess.is() )
330cdf0e10cSrcweir 		{
331cdf0e10cSrcweir 			::rtl::OUString sSubFolder = m_aView.GetCurrentURL();
332cdf0e10cSrcweir 			sal_Int32 nIndex = sSubFolder.lastIndexOf('/') + 1;
333cdf0e10cSrcweir 			sSubFolder = sSubFolder.getToken(0,'/',nIndex);
334cdf0e10cSrcweir 			if ( sSubFolder.getLength() )
335cdf0e10cSrcweir 			{
336cdf0e10cSrcweir 				Reference< XContent> xContent;
337cdf0e10cSrcweir 				if ( xNameAccess->hasByName(sSubFolder) )
338cdf0e10cSrcweir 					xContent.set(xNameAccess->getByName(sSubFolder),UNO_QUERY);
339cdf0e10cSrcweir 				if ( xContent.is() )
340cdf0e10cSrcweir 				{
341cdf0e10cSrcweir 					m_xContent = xContent;
342cdf0e10cSrcweir 					m_aView.Initialize(m_xContent,String());
343cdf0e10cSrcweir 					initCurrentPath();
344cdf0e10cSrcweir 				}
345cdf0e10cSrcweir 			}
346cdf0e10cSrcweir 		}
347cdf0e10cSrcweir 	}
348cdf0e10cSrcweir     catch( const Exception& )
349cdf0e10cSrcweir     {
350cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
351cdf0e10cSrcweir     }
352cdf0e10cSrcweir 	return 0;
353cdf0e10cSrcweir }
354cdf0e10cSrcweir // -----------------------------------------------------------------------------
355cdf0e10cSrcweir void OCollectionView::initCurrentPath()
356cdf0e10cSrcweir {
357cdf0e10cSrcweir 	sal_Bool bEnable = sal_False;
358cdf0e10cSrcweir 	try
359cdf0e10cSrcweir 	{
360cdf0e10cSrcweir 		if ( m_xContent.is() )
361cdf0e10cSrcweir 		{
362cdf0e10cSrcweir 			const ::rtl::OUString sCID = m_xContent->getIdentifier()->getContentIdentifier();
363cdf0e10cSrcweir 			const static ::rtl::OUString s_sFormsCID(RTL_CONSTASCII_USTRINGPARAM("private:forms"));
364cdf0e10cSrcweir             const static ::rtl::OUString s_sReportsCID(RTL_CONSTASCII_USTRINGPARAM("private:reports"));
365cdf0e10cSrcweir 			m_bCreateForm = s_sFormsCID.compareTo(sCID) == 0;
366cdf0e10cSrcweir             ::rtl::OUString sPath(RTL_CONSTASCII_USTRINGPARAM("/"));
367cdf0e10cSrcweir             if ( m_bCreateForm && sCID.getLength() != s_sFormsCID.getLength())
368cdf0e10cSrcweir                 sPath = sCID.copy(s_sFormsCID.getLength());
369cdf0e10cSrcweir             else if ( !m_bCreateForm && sCID.getLength() != s_sReportsCID.getLength() )
370cdf0e10cSrcweir                 sPath = sCID.copy(s_sReportsCID.getLength());
371cdf0e10cSrcweir 
372cdf0e10cSrcweir 			m_aFTCurrentPath.SetText(sPath);
373cdf0e10cSrcweir 			Reference<XChild> xChild(m_xContent,UNO_QUERY);
374cdf0e10cSrcweir 			bEnable = xChild.is() && Reference<XNameAccess>(xChild->getParent(),UNO_QUERY).is();
375cdf0e10cSrcweir 		}
376cdf0e10cSrcweir 	}
377cdf0e10cSrcweir     catch( const Exception& )
378cdf0e10cSrcweir     {
379cdf0e10cSrcweir         DBG_UNHANDLED_EXCEPTION();
380cdf0e10cSrcweir     }
381cdf0e10cSrcweir 	m_aUp.Enable(bEnable);
382cdf0e10cSrcweir }
383cdf0e10cSrcweir // -----------------------------------------------------------------------------
384cdf0e10cSrcweir ::rtl::OUString OCollectionView::getName() const
385cdf0e10cSrcweir {
386cdf0e10cSrcweir 	return m_aName.GetText();
387cdf0e10cSrcweir }
388cdf0e10cSrcweir // -----------------------------------------------------------------------------
389cdf0e10cSrcweir //.........................................................................
390cdf0e10cSrcweir }	// namespace dbaui
391cdf0e10cSrcweir //.........................................................................
392cdf0e10cSrcweir 
393cdf0e10cSrcweir 
394