fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / dbaccess / source / ui / dlg / adodatalinks.cxx
blobe30fbd493870f77b7ebf8e0cad5c68ab0fc9e3b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
22 #if defined(WNT)
23 #if defined _MSC_VER
24 #pragma warning(push, 1)
25 #pragma warning(disable: 4917)
26 #endif
27 // LO/windows.h conflict
28 #undef WB_LEFT
29 #undef WB_RIGHT
30 #include "msdasc.h"
31 #if defined _MSC_VER
32 #pragma warning(push, 1)
33 #endif
35 #include <initguid.h>
36 #include <adoid.h>
37 #include <adoint.h>
39 #include "adodatalinks.hxx"
41 #ifdef __MINGW32__
42 const IID IID_IDataSourceLocator = { 0x2206CCB2, 0x19C1, 0x11D1, { 0x89, 0xE0, 0x00, 0xC0, 0x4F, 0xD7, 0xA8, 0x29 } };
43 const CLSID CLSID_DataLinks = { 0x2206CDB2, 0x19C1, 0x11D1, { 0x89, 0xE0, 0x00, 0xC0, 0x4F, 0xD7, 0xA8, 0x29 } };
44 #endif
47 BSTR PromptEdit(long hWnd,BSTR connstr);
48 BSTR PromptNew(long hWnd);
50 OUString getAdoDatalink(long hWnd,OUString& oldLink)
52 OUString dataLink;
53 if (!oldLink.isEmpty())
55 dataLink=reinterpret_cast<sal_Unicode *>(PromptEdit(hWnd,(BSTR)oldLink.getStr()));
57 else
58 dataLink=reinterpret_cast<sal_Unicode *>(PromptNew(hWnd));
59 return dataLink;
62 BSTR PromptNew(long hWnd)
64 BSTR connstr=NULL;
65 HRESULT hr;
66 IDataSourceLocator* dlPrompt = NULL;
67 ADOConnection* piTmpConnection = NULL;
68 BSTR _result=NULL;
70 // Initialize COM
71 ::CoInitialize( NULL );
73 // Instantiate DataLinks object.
74 hr = CoCreateInstance(
75 CLSID_DataLinks, //clsid -- Data Links UI
76 NULL, //pUnkOuter
77 CLSCTX_INPROC_SERVER, //dwClsContext
78 IID_IDataSourceLocator, //riid
79 (void**)&dlPrompt //ppvObj
81 if( FAILED( hr ) )
83 return connstr;
86 dlPrompt->put_hWnd(hWnd);
87 if( FAILED( hr ) )
89 dlPrompt->Release( );
90 return connstr;
93 // Prompt for connection information.
94 hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection);
96 if( FAILED( hr ) || !piTmpConnection )
98 dlPrompt->Release( );
99 return connstr;
102 hr = piTmpConnection->get_ConnectionString(&_result);
103 if( FAILED( hr ) )
105 piTmpConnection->Release( );
106 dlPrompt->Release( );
107 return connstr;
110 piTmpConnection->Release( );
111 dlPrompt->Release( );
112 CoUninitialize();
113 return _result;
116 BSTR PromptEdit(long hWnd,BSTR connstr)
118 HRESULT hr;
119 IDataSourceLocator* dlPrompt = NULL;
120 ADOConnection* piTmpConnection = NULL;
121 BSTR _result=NULL;
123 // Initialize COM
124 ::CoInitialize( NULL );
126 hr = CoCreateInstance(CLSID_CADOConnection,
127 NULL,
128 CLSCTX_INPROC_SERVER,
129 IID_IADOConnection,
130 (LPVOID *)&piTmpConnection);
131 if( FAILED( hr ) )
133 piTmpConnection->Release( );
134 return connstr;
138 hr = piTmpConnection->put_ConnectionString(connstr);
139 if( FAILED( hr ) )
141 piTmpConnection->Release( );
142 return connstr;
145 // Instantiate DataLinks object.
146 hr = CoCreateInstance(
147 CLSID_DataLinks, //clsid -- Data Links UI
148 NULL, //pUnkOuter
149 CLSCTX_INPROC_SERVER, //dwClsContext
150 IID_IDataSourceLocator, //riid
151 (void**)&dlPrompt //ppvObj
153 if( FAILED( hr ) )
155 piTmpConnection->Release( );
156 dlPrompt->Release( );
157 return connstr;
160 dlPrompt->put_hWnd(hWnd);
161 if( FAILED( hr ) )
163 piTmpConnection->Release( );
164 dlPrompt->Release( );
165 return connstr;
168 VARIANT_BOOL pbSuccess;
170 // Prompt for connection information.
171 hr = dlPrompt->PromptEdit((IDispatch **)&piTmpConnection,&pbSuccess);
172 if( SUCCEEDED( hr ) && sal_False == pbSuccess ) //if user press cancel then sal_False == pbSuccess
174 piTmpConnection->Release( );
175 dlPrompt->Release( );
176 return connstr;
179 if( FAILED( hr ) )
181 // Prompt for new connection information.
182 piTmpConnection->Release( );
183 piTmpConnection = NULL;
184 hr = dlPrompt->PromptNew((IDispatch **)&piTmpConnection);
185 if( FAILED( hr ) || !piTmpConnection )
187 dlPrompt->Release( );
188 return connstr;
192 hr = piTmpConnection->get_ConnectionString(&_result);
193 if( FAILED( hr ) )
195 piTmpConnection->Release( );
196 dlPrompt->Release( );
197 return connstr;
200 piTmpConnection->Release( );
201 dlPrompt->Release( );
202 CoUninitialize();
203 return _result;
206 #endif
208 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */