1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _DBAUI_LINKEDDOCUMENTS_HXX_
25 #define _DBAUI_LINKEDDOCUMENTS_HXX_
26 
27 #include "AppElementType.hxx"
28 
29 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #endif
32 #ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
33 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
34 #endif
35 #ifndef _COM_SUN_STAR_LANG_XCOMPONENT_HPP_
36 #include <com/sun/star/lang/XComponent.hpp>
37 #endif
38 #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
39 #include <com/sun/star/beans/XPropertySet.hpp>
40 #endif
41 #ifndef _COM_SUN_STAR_SDBC_XCONNECTION_HPP_
42 #include <com/sun/star/sdbc/XConnection.hpp>
43 #endif
44 #include <com/sun/star/frame/XFrame.hpp>
45 #ifndef _COM_SUN_STAR_FRAME_XCOMPONENTLOADER_HPP_
46 #include <com/sun/star/frame/XComponentLoader.hpp>
47 #endif
48 #ifndef _COM_SUN_STAR_UCB_XCONTENT_HPP_
49 #include <com/sun/star/ucb/XContent.hpp>
50 #endif
51 #include <com/sun/star/sdb/application/XDatabaseDocumentUI.hpp>
52 #ifndef _LINK_HXX
53 #include <tools/link.hxx>
54 #endif
55 #ifndef _STRING_HXX
56 #include <tools/string.hxx>
57 #endif
58 #ifndef COMPHELPER_NAMEDVALUECOLLECTION_HXX
59 #include <comphelper/namedvaluecollection.hxx>
60 #endif
61 
62 class Window;
63 //......................................................................
64 namespace dbaui
65 {
66 //......................................................................
67 
68 	//==================================================================
69 	//= OLinkedDocumentsAccess
70 	//==================================================================
71 	class OLinkedDocumentsAccess
72 	{
73 	protected:
74 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >
75 					m_xORB;
76 		::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
77 					m_xDocumentContainer;
78 		::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>
79 					m_xConnection;
80         ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >
81                     m_xDocumentUI;
82 		Window*		m_pDialogParent;
83 		String		m_sCurrentlyEditing;
84         ::rtl::OUString
85                     m_sDataSourceName;
86 
87 	public:
88 		OLinkedDocumentsAccess(
89             Window* _pDialogParent,
90             const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::application::XDatabaseDocumentUI >& i_rDocumentUI,
91             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& _rxORB,
92             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxContainer,
93             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
94             const ::rtl::OUString& _sDataSourceName
95         );
96 		~OLinkedDocumentsAccess();
97 
isConnected() const98         inline sal_Bool isConnected() const { return m_xConnection.is(); }
99 
100         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>
101                 open(
102                     const ::rtl::OUString& _rLinkName,
103                     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>& _xDefinition,
104                     ElementOpenMode _eOpenMode,
105                     const ::comphelper::NamedValueCollection& _rAdditionalArgs
106                 );
107 
108         ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
109                 newDocument(
110                           sal_Int32 i_nActionID,
111                     const ::comphelper::NamedValueCollection& i_rCreationArgs,
112                           ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& o_rDefinition
113                 );
114 
115         void    newFormWithPilot(
116                     const sal_Int32 _nCommandType = -1,
117                     const ::rtl::OUString& _rObjectName = ::rtl::OUString()
118                 );
119         void    newReportWithPilot(
120                     const sal_Int32 _nCommandType = -1,
121                     const ::rtl::OUString& _rObjectName = ::rtl::OUString()
122                 );
123         void    newQueryWithPilot();
124         void    newTableWithPilot();
125 
126 		enum RESULT
127 		{
128 			ERROR,
129 			SUCCESS,
130 			CANCEL
131 		};
132     private:
133 		::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >
134             impl_open(
135                 const ::rtl::OUString& _rLinkName,
136                 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _xDefinition,
137                 ElementOpenMode _eOpenMode,
138                 const ::comphelper::NamedValueCollection& _rAdditionalArgs
139             );
140 
141         void
142             impl_newWithPilot(
143                 const char* _pWizardService,
144                 const sal_Int32 _nCommandType,
145                 const ::rtl::OUString& _rObjectName
146             );
147 
148 	};
149 
150 //......................................................................
151 }	// namespace dbaui
152 //......................................................................
153 
154 #endif // _DBAUI_LINKEDDOCUMENTS_HXX_
155 
156