/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: sbaexpob.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2005/09/09 10:53:56 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _SBA_SBAEXPOB_HXX
#define _SBA_SBAEXPOB_HXX

#ifndef _SBA_DBDEFOBJ_HXX
#include <dbdefobj.hxx>
#endif

#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP_
#include <com/sun/star/beans/PropertyValue.hpp>
#endif

#ifndef _COM_SUN_STAR_UNO_SEQUENCE_HXX_
#include <com/sun/star/uno/Sequence.hxx>
#endif

#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif
FORWARD_DECLARE_INTERFACE(frame, XController)
FORWARD_DECLARE_INTERFACE(awt, XWindow)
FORWARD_DECLARE_INTERFACE(lang, XMultiServiceFactory)
class FontList; 
namespace binfilter {

//FORWARD_DECLARE_INTERFACE(uno, Reference)
//STRIP008 FORWARD_DECLARE_INTERFACE(frame, XController)
//STRIP008 FORWARD_DECLARE_INTERFACE(awt, XWindow)
//STRIP008 FORWARD_DECLARE_INTERFACE(lang, XMultiServiceFactory)


class SbaQueryObj;
class SvxFontListItem;

class SbaDBDefHint;
class SbaSqlDlg;
class SbaObject;
class SbaDBDatabaseItem;
class SbaDatabase;
class OEnvironment;
class ODatabaseAccessContext;
class SbaXdbEngine;
class XControllerRef;
class SbaDataExchObj;
class SfxObjectFactory;
class SdbDatabaseGuard;

//==================================================================
// SbaObjectExt
//==================================================================
class SbaObjectExt
{
	friend class SbaObject;
	friend class SbaDBDataDef;
	friend class SbaTableDef;
	friend class SbaQueryDef;
	friend class SbaFileDef;
	friend class SbaFormDef;
	friend class SbaReportDef;
	friend class SbaDLL;

	SbaObject&				rSbaObj;
	SbaXdbEngine*			m_pEngine;
	ODatabaseAccessContext*	m_pContext;
	OEnvironment*			m_pEnvironment;
	BOOL					m_bTriedUnoInitialization;

	FontList*				pFontList;
	SvxFontListItem*		pFontListItem;

private:
	SbaObjectExt(SbaObject& rObj);
	~SbaObjectExt();

	void SetEngine();
	XubString GetUrlFilename(const XubString& _rDbPath,const XubString& _rTitle) const;

public:
	// Dialog zum Anlegen oder Aendern einer Datenbankkonfiguration
	virtual BOOL SetDatabaseEntry(const XubString& aFilename,
								  BOOL bReadOnly,
								  XubString& rTitle, XubString& rParams,SbaDatabase* pDatabase=NULL);

	virtual XubString	CreateDatabaseAlias(const XubString& _rURL, const XubString& _rTitle, BOOL _bAllowUIInteraction = FALSE, BOOL _bUrgent = FALSE);
		// if the registration fails and _bAllowUIInteraction is TRUE, the user is asked to enter another title.
		// if - additionally - _bUrgent is TRUE, the upcoming text will sound a little bit more urgent ("we really need it) :)
		// the Title the database is registered for will be returned, or an empty string of the url wasn't registered
	virtual void	DropDatabaseAlias(const XubString& _rURL, BOOL _bConfirm = FALSE);
	virtual XubString	ResolveDatabaseAlias(const XubString& _rTitle);
		// get the URL for the given title, empty string if the title is unknown
	virtual XubString	GetDatabaseAlias(const XubString& _rURL);
		// get the title the URL is registered under, empty string if nothing is known about the URL
	virtual void RebindDatabaseAlias(const XubString& _rOldURL, const XubString& _rNewURL);
		// rebind all aliases pointing to _rOldURL

//	Schnittstelle fuer den Explorer
//  Tabellen oder Abfragedefinition oeffnen oder neu erzeugen
	virtual SbaDBDef* OpenDBDef(const XubString& rURL, DBObject eDBObjType, BOOL bShowError = TRUE, BOOL bNew = FALSE);
	virtual SbaDBDef* OpenDBDef(const XubString& rURL, BOOL bShowError = TRUE, BOOL bNew = FALSE);

	//	virtual Window*	CreateBeamerWindow(Window* pParentWin, const XubString& rURL, ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>& xController);
	/** create an UI component for the given database related URL
		@param		_rURL			the URL of the object to be loaded
		@param		_rxParent		the parent window. must not be NULL.
		@param		_rxFactory		the service manager which should be used for creation of sub components
		@param		_rxCompWindow	[out] contains the newly created component window, if successful
		@param		_rxController	[out] contains the newly created component controller, if successful
		@return						sal_True if successful, sal_False otherwise
	*/
	virtual sal_Bool CreateUIComponent(
		const XubString&																		/* [in] */	_rURL,
		const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >				/* [in] */	_rxParent,
		const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >	/* [in] */	_rxFactory,
		::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >&						/* [out] */	_rxCompWindow,
		::com::sun::star::uno::Reference< ::com::sun::star::frame::XController>&				/* [out] */	_rxController);

	virtual void SetAddressBookEntry(const XubString& rFileName, const XubString& rTablename);
	virtual SbaDBDatabaseItem* CreateDatabaseItem( USHORT nWhich, SbaDatabase* pDatabase );
	virtual SbaSqlDlg* CreateSQLDlg( Window* pParent, SbaDatabase* pDatabase );

	// Klammern fuer mehrere Datenbankaktionen
	virtual void BeginDBAction();
	virtual void CancelDBAction();
	virtual void EndDBAction();
	virtual void ShowDbStatus(const SdbStatus& rStatus, DBErrorContext eContext);
	virtual BOOL DoCompact(SbaDatabase* pDatabse);

	virtual BOOL DoReorganize(const XubString& strDatabaseFile);

	virtual SbaDataExchObj* CreateDataExchObj(USHORT nType, SbaDatabase* pDB, DBObject eKind,
			const XubString& rName);

	virtual SbaDatabase* GetDatabaseNoOpen(const XubString& rName);

	virtual XubString readFavoriteTarget(const XubString& _rUrlFile);
	virtual XubString readFavoriteTitle(const XubString& _rUrlFile);
	virtual void writeFavoriteTarget(const XubString& _rUrlFile, const XubString& _rTargetLocation);
	virtual void writeFavoriteTitle(const XubString& _rUrlFile, const XubString& _rTitle);

	const SvxFontListItem& FontListItem() const {return *pFontListItem;}
	virtual BOOL ExecuteUserSettings(SbaDatabase* pDatabse);
	virtual BOOL ExecuteBackup(SbaDatabase* pDatabase);
	virtual BOOL ExecuteConvert(const XubString& rCon,BOOL _bTry=TRUE);

	virtual SfxObjectFactory* GetObjectDocumentFactory(const ::rtl::OUString& _rUrl, const ::rtl::OUString& _rFrameName,
		const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& _rArgs) const;

	virtual SdbDatabaseGuard* CreateDatabaseGuard(SdbDatabase* _pDB);

	virtual BOOL	IsThreadSafe(const XubString& _rSdbFile);
		// it's a hack. 
};

#define SBA_MOD_EXT() \
	SBA_MOD()->GetSbaObjectExt()

} //namespace binfilter
#endif


