20#include <core_resource.hxx>
30#include <osl/diagnose.h>
38#include <com/sun/star/awt/XSystemDependentWindowPeer.hpp>
39#include <com/sun/star/ui/dialogs/XFolderPicker2.hpp>
40#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
41#include <com/sun/star/lang/SystemDependent.hpp>
42#include <com/sun/star/mozilla/MozillaBootstrap.hpp>
43#include <com/sun/star/task/InteractionHandler.hpp>
44#include <com/sun/star/ucb/XProgressHandler.hpp>
52#include <rtl/process.h>
57#include <com/sun/star/mozilla/XMozillaBootstrap.hpp>
71 using namespace ::com::sun::star::mozilla;
73 using namespace ::
svt;
77 , m_bUserGrabFocus(false)
78 , m_pCollection(nullptr)
79 , m_xFT_Connection(m_xBuilder->weld_label(
"browseurllabel"))
80 , m_xPB_Connection(m_xBuilder->weld_button(
"browse"))
81 , m_xPB_CreateDB(m_xBuilder->weld_button(
"create"))
82 , m_xConnectionURL(new
OConnectionURLEdit(m_xBuilder->weld_entry(
"browseurl"), m_xBuilder->weld_label(
"browselabel")))
90 OSL_ENSURE(
m_pCollection,
"OConnectionHelper::OConnectionHelper : really need a DSN type collection !");
105 bool bValid, bReadonly;
123 OUString sUrl = pUrlItem->
GetValue();
145 OSL_ENSURE(m_pAdminDialog,
"No Admin dialog set! ->GPF");
156 bool bDoBrowse =
false;
157 OUString sOldPath = getURLNoPrefix();
160 if (!sOldPath.isEmpty())
161 xFolderPicker->setDisplayDirectory(sOldPath);
162 if (0 == xFolderPicker->execute())
166 sOldPath = xFolderPicker->getDirectory();
167 switch (checkPathExistence(sOldPath))
180 OUString sSelectedDirectory = xFolderPicker->getDirectory();
186 setURLNoPrefix( sSelectedDirectory );
187 SetRoadmapStateValue(
true);
200 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
201 FileDialogFlags::NONE,
203 ,SfxFilterFlags::IMPORT, SfxFilterFlags::NONE,
GetFrameWeld());
204 askForFileName(aFileDlg);
211 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
212 FileDialogFlags::NONE,
214 SfxFilterFlags::IMPORT, SfxFilterFlags::NONE,
GetFrameWeld());
215 askForFileName(aFileDlg);
220 OUString sFilterName(
DBA_RES (STR_MSACCESS_FILTERNAME));
222 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
224 aFileDlg.
AddFilter(sFilterName,
"*.mdb;*.mde");
226 askForFileName(aFileDlg);
231 OUString sFilterName2(
DBA_RES (STR_MSACCESS_2007_FILTERNAME));
233 ui::dialogs::TemplateDescription::FILEOPEN_READONLY_VERSION,
235 aFileDlg.
AddFilter(sFilterName2,
"*.accdb;*.accde");
237 askForFileName(aFileDlg);
244 OUString sCurrDatasource = getURLNoPrefix();
245 OUString sDataSource;
246 if ( getSelectedDataSource(sDataSource,sCurrDatasource) && !sDataSource.isEmpty() )
248 setURLNoPrefix(sDataSource);
249 SetRoadmapStateValue(
true);
259 OUString sOldDataSource=getURLNoPrefix();
260 OUString sNewDataSource;
264 css::uno::Reference<css::awt::XSystemDependentWindowPeer> xSysDepWin(pDialog->
GetXWindow(), css::uno::UNO_QUERY);
267 css::uno::Sequence<sal_Int8> aProcessIdent(16);
268 rtl_getGlobalProcessId(
reinterpret_cast<sal_uInt8*
>(aProcessIdent.getArray()));
269 css::uno::Any aAny = xSysDepWin->getWindowHandle(aProcessIdent, css::lang::SystemDependent::SYSTEM_WIN32);
272 hWnd =
reinterpret_cast<HWND
>(tmp);
275 sNewDataSource =
getAdoDatalink(
reinterpret_cast<sal_IntPtr
>(hWnd),sOldDataSource);
276 if ( !sNewDataSource.isEmpty() )
278 setURLNoPrefix(sNewDataSource);
279 SetRoadmapStateValue(
true);
288 MozillaProductType profileType = MozillaProductType_Mozilla;
290 profileType = MozillaProductType_Thunderbird;
296 css::uno::Sequence< OUString > list;
298 xMozillaBootstrap->getProfileList( profileType, list );
299 const OUString * pArray = list.getConstArray();
301 sal_Int32
count = list.getLength();
303 std::set<OUString> aProfiles;
305 aProfiles.insert(pArray[
index]);
309 OUString sOldProfile=getURLNoPrefix();
311 if (!sOldProfile.isEmpty())
312 aSelector.
Select(sOldProfile);
314 aSelector.
Select(xMozillaBootstrap->getDefaultProfile(profileType));
322 OUString sFilterName(
DBA_RES (STR_FIREBIRD_FILTERNAME));
324 ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
328 askForFileName(aFileDlg);
335 checkTestConnection();
340 OSL_ENSURE(m_pAdminDialog,
"No Admin dialog set! ->GPF");
346 OUString sFilterName(
DBA_RES (STR_FIREBIRD_FILTERNAME));
348 ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION,
352 askForFileName(aFileDlg);
359 checkTestConnection();
370 OSL_ENSURE(
m_pCollection,
"OConnectionHelper::impl_setURL: have no interpreter for the URLs!" );
377 OUString sTypePrefix, sFileURLEncoded;
385 sFileURLEncoded = sURL;
393 if ( !sFileURLEncoded.isEmpty() )
415 OSL_ENSURE(
m_pCollection,
"OConnectionHelper::impl_getURL: have no interpreter for the URLs!" );
422 OUString sFileURLDecoded = sURL;
425 if ( !sFileURLDecoded.isEmpty() )
460 OUString sQuery(
DBA_RES(STR_ASK_FOR_DIRECTORY_CREATION));
466 VclMessageType::Question, VclButtonsType::YesNo,
468 xQueryBox->set_default_response(
RET_YES);
469 sal_Int32 nQueryResult = xQueryBox->run();
472 switch (nQueryResult)
476 bool bTryCreate =
false;
481 sQuery =
DBA_RES(STR_COULD_NOT_CREATE_DIRECTORY);
487 VclMessageType::Question, VclButtonsType::NONE,
491 xWhatToDo->set_default_response(
RET_RETRY);
492 nQueryResult = xWhatToDo->run();
535 task::InteractionHandler::createWithParent(
m_xORB,
nullptr);
537 xInteractionHandler = pHandler;
543 const bool bExists = bIsFile? aCheckExistence.
isDocument(): aCheckExistence.
isFolder();
555 if (!m_pCollection->isFileSystemBased(
m_eType))
557 if (!m_bUserGrabFocus)
560 m_xConnectionURL->SaveValueNoPrefix();
565 if (!m_pCollection->isFileSystemBased(
m_eType))
567 if (!m_bUserGrabFocus)
577 aParser.
SetURL(_rPathURL);
581 std::vector< OUString > aToBeCreated;
587 aToBeCreated.push_back(aParser.
getName());
602 OUString sContentType;
603 if ( INetProtocol::File == eProtocol )
605 sContentType =
"application/vnd.sun.staroffice.fsys-folder";
611 aContentType >>= sContentType;
618 for ( std::vector< OUString >::const_reverse_iterator aLocalName = aToBeCreated.rbegin();
619 aLocalName != aToBeCreated.rend();
625 if (!aParent.
insertNewContent(sContentType, aNewDirectoryProperties, aNewDirectoryAttributes, aParent))
657 if ( ( sURL != sOldPath ) && !sURL.isEmpty() )
670 OUString sFile =
DBA_RES( STR_FILE_DOES_NOT_EXIST );
706 if ( !sOldPath.isEmpty() )
OUString getAdoDatalink(sal_IntPtr hWnd, OUString const &oldLink)
static weld::MessageDialog * CreateMessageDialog(weld::Widget *pParent, VclMessageType eMessageType, VclButtonsType eButtonType, const OUString &rPrimaryMessage, const ILibreOfficeKitNotifier *pNotifier=nullptr)
const OUString & GetValue() const
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
sal_Int32 getSegmentCount(bool bIgnoreFinalSlash=true) const
INetProtocol GetProtocol() const
bool SetURL(std::u16string_view rTheAbsURIRef, EncodeMechanism eMechanism=EncodeMechanism::WasEncoded, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8)
const SfxPoolItem * GetItem(sal_uInt16 nWhich, bool bSearchInParent=true) const
weld::Window * GetFrameWeld() const
OUString GetFactoryEmptyDocumentURL(EFactory eFactory) const
OUString SubstituteVariable(const OUString &rVar) const
DATASOURCE_TYPE determineType(std::u16string_view _rDsn) const
OUString cutPrefix(std::u16string_view _sURL) const
on a given string, cut the type prefix and return the result
bool isFileSystemBased(std::u16string_view _sURL) const
check if the given data source type is based on the file system - i.e. the URL is a prefix plus a fil...
OUString getPrefix(std::u16string_view _sURL) const
on a given string, return the type prefix
bool supportsDBCreation(std::u16string_view _sURL) const
bool supportsBrowsing(std::u16string_view _sURL) const
allows an ODsnTypeCollection to be transported in an SfxItemSet
::dbaccess::ODsnTypeCollection * getCollection() const
virtual void enableConfirmSettings(bool _bEnable)=0
enables or disables the user's possibility to confirm the settings
virtual void fillControls(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to save the value if necessary
virtual void fillWindows(std::vector< std::unique_ptr< ISaveValueWrapper > > &_rControlList) override
will be called inside <method>implInitControls</method> to disable if necessary
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue) override
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
IS_PATH_EXIST pathExists(const OUString &_rURL, bool bIsFile) const
virtual ~OConnectionHelper() override
std::unique_ptr< weld::Label > m_xFT_Connection
the DSN type collection instance
OUString getURLNoPrefix() const
std::unique_ptr< weld::Button > m_xPB_CreateDB
OUString impl_getURL() const
OConnectionHelper(weld::Container *pPage, weld::DialogController *pController, const OUString &_rUIXMLDescription, const OUString &_rId, const SfxItemSet &_rCoreAttrs)
void impl_setURL(std::u16string_view _rURL, bool _bPrefix)
virtual bool checkTestConnection()
void askForFileName(::sfx2::FileDialogHelper &_aFileOpen)
opens the FileOpen dialog and asks for a FileName
bool createDirectoryDeep(std::u16string_view _rPathNormalized)
std::unique_ptr< OConnectionURLEdit > m_xConnectionURL
void implUpdateURLDependentStates() const
void setURLNoPrefix(std::u16string_view _rURL)
::dbaccess::ODsnTypeCollection * m_pCollection
sal_Int32 checkPathExistence(const OUString &_rURL)
checks if the path is existence
std::unique_ptr< weld::Button > m_xPB_Connection
void setURL(std::u16string_view _rURL)
OUString GetSelected() const
void Select(const OUString &_rEntry)
virtual short run() override
static void getFlags(const SfxItemSet &_rSet, bool &_rValid, bool &_rReadonly)
analyze the invalid and the readonly flag which may be present in the set
IDatabaseSettingsDialog * m_pAdminDialog
void SetRoadmapStateValue(bool _bDoEnable)
css::uno::Reference< css::uno::XComponentContext > m_xORB
virtual void callModifiedHdl(weld::Widget *=nullptr)
virtual void implInitControls(const SfxItemSet &_rSet, bool _bSaveValue)
called from within Reset and ActivatePage, use to initialize the controls with the items from the giv...
void AddFilter(const OUString &rFilterName, const OUString &rExtension)
void SetDisplayDirectory(const OUString &rPath)
void SetCurrentFilter(const OUString &rFilter)
OUString get(NOTATION _eOutputNotation) const
css::uno::Any getPropertyValue(const OUString &rPropertyName)
bool insertNewContent(const OUString &rContentType, const css::uno::Sequence< OUString > &rPropertyNames, const css::uno::Sequence< css::uno::Any > &rPropertyValues, Content &rNewContent)
virtual css::uno::Reference< css::awt::XWindow > GetXWindow()=0
#define DBG_UNHANDLED_EXCEPTION(...)
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
#define DSID_TYPECOLLECTION
const EnumerationType m_eType
#define LINK(Instance, Class, Member)
OString stripEnd(const OString &rIn, char c)
Reference< XComponentContext > getProcessComponentContext()
DATASOURCE_TYPE
known datasource types
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
css::uno::Reference< css::ui::dialogs::XFolderPicker2 > createFolderPicker(const css::uno::Reference< css::uno::XComponentContext > &rContext, weld::Window *pPreferredParent)
OUString VCL_DLLPUBLIC GetStandardText(StandardButtonType eButton)