29#include <systools/win32/comtools.hxx>
30#include <systools/win32/oleauto.hxx>
40OUString PromptNew(sal_IntPtr hWnd)
45 sal::systools::CoInitializeGuard aGuard(COINIT_APARTMENTTHREADED);
48 sal::systools::COMReference<IDataSourceLocator> dlPrompt;
49 dlPrompt.CoCreateInstance(CLSID_DataLinks,
51 CLSCTX_INPROC_SERVER);
53 sal::systools::ThrowIfFailed(dlPrompt->put_hWnd(hWnd),
"put_hWnd failed");
56 sal::systools::COMReference<IDispatch> piDispatch;
57 sal::systools::ThrowIfFailed(dlPrompt->PromptNew(&piDispatch),
"PromptNew failed");
58 sal::systools::COMReference<ADOConnection> piTmpConnection(piDispatch,
59 sal::systools::COM_QUERY_THROW);
61 sal::systools::BStr _result;
62 sal::systools::ThrowIfFailed(piTmpConnection->get_ConnectionString(&_result),
63 "get_ConnectionString failed");
65 return OUString(_result);
67 catch (
const sal::systools::ComError&)
73OUString PromptEdit(sal_IntPtr hWnd, OUString
const & connstr)
78 sal::systools::CoInitializeGuard aGuard(COINIT_APARTMENTTHREADED);
80 sal::systools::COMReference<ADOConnection> piTmpConnection;
81 piTmpConnection.CoCreateInstance(CLSID_CADOConnection,
nullptr, CLSCTX_INPROC_SERVER);
83 sal::systools::ThrowIfFailed(
84 piTmpConnection->put_ConnectionString(sal::systools::BStr(connstr)),
85 "put_ConnectionString failed");
88 sal::systools::COMReference<IDataSourceLocator> dlPrompt;
89 dlPrompt.CoCreateInstance(CLSID_DataLinks,
91 CLSCTX_INPROC_SERVER);
93 sal::systools::ThrowIfFailed(dlPrompt->put_hWnd(hWnd),
"put_hWnd failed");
98 IDispatch* piDispatch = piTmpConnection.get();
99 VARIANT_BOOL pbSuccess;
100 sal::systools::ThrowIfFailed(dlPrompt->PromptEdit(&piDispatch, &pbSuccess),
101 "PromptEdit failed");
105 catch (
const sal::systools::ComError&)
108 sal::systools::COMReference<IDispatch> piDispatch;
109 sal::systools::ThrowIfFailed(dlPrompt->PromptNew(&piDispatch),
"PromptNew failed");
110 piTmpConnection.set(piDispatch, sal::systools::COM_QUERY_THROW);
113 sal::systools::BStr _result;
114 sal::systools::ThrowIfFailed(piTmpConnection->get_ConnectionString(&_result),
115 "get_ConnectionString failed");
117 return OUString(_result);
119 catch (
const sal::systools::ComError&)
130 if (!oldLink.isEmpty())
132 dataLink=PromptEdit(hWnd,oldLink);
135 dataLink=PromptNew(hWnd);
OUString getAdoDatalink(sal_IntPtr hWnd, OUString const &oldLink)