1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
29 #define _DBAUI_LINKEDDOCUMENTS_HXX_
30 
31 #include "AppElementType.hxx"
32 
33 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
34 #include <com/sun/star/container/XNameAccess.hpp>
35 #endif
36 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
37 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
38 #endif
39 #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
40 #include <com/sun/star/lang/XComponent.hpp>
41 #endif
42 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
43 #include <com/sun/star/beans/XPropertySet.hpp>
44 #endif
45 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
46 #include <com/sun/star/sdbc/XConnection.hpp>
47 #endif
48 #include <com/sun/star/frame/XFrame.hpp>
49 #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
50 #include <com/sun/star/frame/XComponentLoader.hpp>
51 #endif
52 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
53 #include <com/sun/star/ucb/XContent.hpp>
54 #endif
55 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
56 #ifndef _LINK_HXX
57 #include <tools/link.hxx>
58 #endif
59 #ifndef _STRING_HXX
60 #include <tools/string.hxx>
61 #endif
62 #ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
63 #include <comphelper/namedvaluecollection.hxx>
64 #endif
65 
66 class Window;
67 //......................................................................
68 namespace dbaui
69 {
70 //......................................................................
71 
72 	//==================================================================
73 	//= OLinkedDocumentsAccess
74 	//==================================================================
75 	class OLinkedDocumentsAccess
76 	{
77 	protected:
78 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
79 					m_xORB;
80 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
81 					m_xDocumentContainer;
82 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>
83 					m_xConnection;
84         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
85                     m_xDocumentUI;
86 		Window*		m_pDialogParent;
87 		String		m_sCurrentlyEditing;
88         ::rtl::OUString
89                     m_sDataSourceName;
90 
91 	public:
92 		OLinkedDocumentsAccess(
93             Window* _pDialogParent,
94             const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rDocumentUI,
95             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
96             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
97             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
98             const ::rtl::OUString& _sDataSourceName
99         );
100 		~OLinkedDocumentsAccess();
101 
102         inline sal_Bool isConnected() const { return m_xConnection.is(); }
103 
104         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
105                 open(
106                     const ::rtl::OUString& _rLinkName,
107                     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _xDefinition,
108                     ElementOpenMode _eOpenMode,
109                     const ::comphelper::NamedValueCollection& _rAdditionalArgs
110                 );
111 
112         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
113                 newDocument(
114                           sal_Int32 i_nActionID,
115                     const ::comphelper::NamedValueCollection& i_rCreationArgs,
116                           ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_rDefinition
117                 );
118 
119         void    newFormWithPilot(
120                     const sal_Int32 _nCommandType = -1,
121                     const ::rtl::OUString& _rObjectName = ::rtl::OUString()
122                 );
123         void    newReportWithPilot(
124                     const sal_Int32 _nCommandType = -1,
125                     const ::rtl::OUString& _rObjectName = ::rtl::OUString()
126                 );
127         void    newQueryWithPilot();
128         void    newTableWithPilot();
129 
130 		enum RESULT
131 		{
132 			ERROR,
133 			SUCCESS,
134 			CANCEL
135 		};
136     private:
137 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
138             impl_open(
139                 const ::rtl::OUString& _rLinkName,
140                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition,
141                 ElementOpenMode _eOpenMode,
142                 const ::comphelper::NamedValueCollection& _rAdditionalArgs
143             );
144 
145         void
146             impl_newWithPilot(
147                 const char* _pWizardService,
148                 const sal_Int32 _nCommandType,
149                 const ::rtl::OUString& _rObjectName
150             );
151 
152 	};
153 
154 //......................................................................
155 }	// namespace dbaui
156 //......................................................................
157 
158 #endif // _DBAUI_LINKEDDOCUMENTS_HXX_
159 
160