Kaydet (Commit) f7f9b741 authored tarafından Andras Timar's avatar Andras Timar

replace PathDialog to xFolderPicker, remmove obsoleted PathDialog class

and at the same time we got rid of tools/fsys.hxx dependency in svtools

Change-Id: I5237529681a8b6ec32f41086af41ac575fbcff9b
üst 37303d22
......@@ -23,7 +23,6 @@
#include <tools/urlobj.hxx>
#include <svtools/svmedit.hxx>
#include <svtools/filedlg.hxx>
#include <vcl/dialog.hxx>
#include <vcl/button.hxx>
#include <vcl/fixed.hxx>
......@@ -41,12 +40,17 @@
#include <sfx2/lnkbase.hxx>
#include <sfx2/objsh.hxx>
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <comphelper/processfactory.hxx>
#include <dialmgr.hxx>
#define FILEOBJECT ( OBJECT_CLIENT_FILE & ~OBJECT_CLIENT_SO )
using namespace sfx2;
using namespace ::com::sun::star;
class SvBaseLinkMemberList : private std::vector<SvBaseLink*> {
public:
......@@ -342,47 +346,55 @@ IMPL_LINK( SvBaseLinksDlg, ChangeSourceClickHdl, PushButton *, pPushButton )
sal_uInt16 nSelectionCount = (sal_uInt16)Links().GetSelectionCount();
if(nSelectionCount > 1)
{
PathDialog aPathDlg( this );
String sType, sFile, sLinkName;
String sFilter;
SvTreeListEntry* pEntry = Links().FirstSelected();
SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
INetURLObject aUrl(sFile);
if(aUrl.GetProtocol() == INET_PROT_FILE)
{
rtl::OUString sOldPath(aUrl.PathToFileName());
sal_Int32 nLen = aUrl.GetName().getLength();
sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
aPathDlg.SetPath(sOldPath);
}
if(aPathDlg.Execute() == RET_OK)
try
{
OUString aPath = aPathDlg.GetPath();
uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(comphelper::getProcessComponentContext());
for( sal_uInt16 i = 0; i < nSelectionCount; i++)
String sType, sFile, sLinkName;
String sFilter;
SvTreeListEntry* pEntry = Links().FirstSelected();
SvBaseLink* pLink = (SvBaseLink*)pEntry->GetUserData();
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, 0, 0 );
INetURLObject aUrl(sFile);
if(aUrl.GetProtocol() == INET_PROT_FILE)
{
pEntry = i==0 ?
OUString sOldPath(aUrl.PathToFileName());
sal_Int32 nLen = aUrl.GetName().getLength();
sOldPath = sOldPath.copy(0, sOldPath.getLength() - nLen);
xFolderPicker->setDisplayDirectory(sOldPath);
}
if (xFolderPicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
{
OUString aPath = xFolderPicker->getDirectory();
for( sal_uInt16 i = 0; i < nSelectionCount; i++)
{
pEntry = i==0 ?
Links().FirstSelected() :
Links().NextSelected( pEntry );
DBG_ASSERT(pEntry,"Wo ist der Entry");
pLink = (SvBaseLink*)pEntry->GetUserData();
DBG_ASSERT(pLink,"Wo ist der Link");
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
INetURLObject aUrl_(sFile);
INetURLObject aUrl2(aPath, INET_PROT_FILE);
aUrl2.insertName( aUrl_.getName() );
String sNewLinkName;
MakeLnkName( sNewLinkName, 0 ,
aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
pLink->SetLinkSourceName( sNewLinkName );
pLink->Update();
Links().NextSelected( pEntry );
DBG_ASSERT(pEntry,"Where is the entry?");
pLink = (SvBaseLink*)pEntry->GetUserData();
DBG_ASSERT(pLink,"Where is the link?");
pLinkMgr->GetDisplayNames( pLink, &sType, &sFile, &sLinkName, &sFilter );
INetURLObject aUrl_(sFile);
INetURLObject aUrl2(aPath, INET_PROT_FILE);
aUrl2.insertName( aUrl_.getName() );
String sNewLinkName;
MakeLnkName( sNewLinkName, 0 ,
aUrl2.GetMainURL(INetURLObject::DECODE_TO_IURI), sLinkName, &sFilter);
pLink->SetLinkSourceName( sNewLinkName );
pLink->Update();
}
if( pLinkMgr->GetPersist() )
pLinkMgr->GetPersist()->SetModified();
LinkManager* pNewMgr = pLinkMgr;
pLinkMgr = 0;
SetManager( pNewMgr );
}
if( pLinkMgr->GetPersist() )
pLinkMgr->GetPersist()->SetModified();
LinkManager* pNewMgr = pLinkMgr;
pLinkMgr = 0;
SetManager( pNewMgr );
}
catch (uno::Exception & e)
{
SAL_WARN("cui.dialogs", "SvBaseLinksDlg: caught UNO exception: " << e.Message);
}
}
else
......
......@@ -50,7 +50,6 @@ $(eval $(call gb_SrsTarget_add_files,svt/res,\
svtools/source/control/ctrltool.src \
svtools/source/control/filectrl.src \
svtools/source/dialogs/addresstemplate.src \
svtools/source/dialogs/filedlg2.src \
svtools/source/dialogs/formats.src \
svtools/source/dialogs/so3res.src \
svtools/source/dialogs/wizardmachine.src \
......
......@@ -128,8 +128,6 @@ $(eval $(call gb_Library_add_exception_objects,svt,\
svtools/source/control/valueset \
svtools/source/dialogs/addresstemplate \
svtools/source/dialogs/colrdlg \
svtools/source/dialogs/filedlg \
svtools/source/dialogs/filedlg2 \
svtools/source/dialogs/insdlg \
svtools/source/dialogs/mcvmath \
svtools/source/dialogs/PlaceEditDialog \
......
......@@ -55,8 +55,6 @@ $(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/embedtransfer.hxx,svto
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/extcolorcfg.hxx,svtools/extcolorcfg.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/extensionlistbox.hxx,svtools/extensionlistbox.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/filectrl.hxx,svtools/filectrl.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/filedlg.hxx,svtools/filedlg.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/filedlg2.hrc,svtools/filedlg2.hrc))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/fileurlbox.hxx,svtools/fileurlbox.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/fileview.hxx,svtools/fileview.hxx))
$(eval $(call gb_Package_add_file,svtools_inc,inc/svtools/filechangedchecker.hxx,svtools/filechangedchecker.hxx))
......
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef SVT_FILEDLG_HXX
#define SVT_FILEDLG_HXX
#include "svtools/svtdllapi.h"
#include <vcl/dialog.hxx>
class Edit;
class ImpSvFileDlg;
// --------------
// - SvPathDialog -
// --------------
class SVT_DLLPUBLIC PathDialog : public ModalDialog
{
private:
ImpSvFileDlg* pImpFileDlg; // Implementation
Link aOKHdlLink; // Link to OK-Handler
public:
PathDialog( Window* pParent, WinBits nWinStyle = 0, sal_Bool bCreateDir = sal_True );
~PathDialog();
virtual long OK();
void SetPath( const rtl::OUString& rNewPath );
rtl::OUString GetPath() const;
void SetOKHdl( const Link& rLink ) { aOKHdlLink = rLink; }
const Link& GetOKHdl() const { return aOKHdlLink; }
virtual short Execute();
};
#endif // FILEDLG_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svtools/filedlg.hxx>
#include <filedlg2.hxx>
PathDialog::PathDialog( Window* _pParent, WinBits nStyle, sal_Bool bCreateDir ) :
ModalDialog( _pParent, WB_STDMODAL | nStyle )
{
pImpFileDlg = new ImpSvFileDlg;
pImpFileDlg->CreatePathDialog(this, bCreateDir);
}
PathDialog::~PathDialog()
{
delete pImpFileDlg;
}
short PathDialog::Execute()
{
pImpFileDlg->GetDialog()->PreExecute();
short n = ModalDialog::Execute();
return n;
}
rtl::OUString PathDialog::GetPath() const
{
return pImpFileDlg->GetDialog()->GetPath();
}
void PathDialog::SetPath( const rtl::OUString& rPath )
{
pImpFileDlg->GetDialog()->SetPath( rPath );
}
long PathDialog::OK()
{
if( aOKHdlLink.IsSet() )
return aOKHdlLink.Call( this );
else
return sal_True;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
This diff is collapsed.
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef FILEDLG2_HXX
#define FILEDLG2_HXX
#include <tools/fsys.hxx>
#include <vcl/button.hxx>
#include <vcl/unohelp.hxx>
#include <vector>
class FixedText;
class Edit;
class ListBox;
class ListBox;
class Button;
class PathDialog;
class ImpPathDialog;
struct ImpFilterItem
{
String aName;
String aMask;
ImpFilterItem( const String & rFilter, const String & rMask )
{
aName = rFilter;
aMask = rMask;
}
};
typedef ::std::vector< ImpFilterItem* > ImpFilterList;
#include <vcl/lstbox.hxx>
class KbdListBox : public ListBox
{
public:
KbdListBox( Window* pParent, WinBits nStyle = WB_BORDER )
: ListBox ( pParent, nStyle )
{};
virtual long PreNotify( NotifyEvent& rNEvt );
};
class ImpPathDialog
{
private:
PathDialog* pSvPathDialog;
Edit* pEdit;
FixedText* pDirTitel;
KbdListBox* pDirList;
FixedText* pDirPath;
ListBox* pDriveList;
FixedText* pDriveTitle;
PushButton* pLoadBtn;
PushButton* pOkBtn;
PushButton* pCancelBtn;
PushButton* pHomeBtn;
PushButton* pNewDirBtn;
sal_uInt16 nOwnChildren;
DirEntry aPath; // aktuell angewaehlter Pfad
sal_uInt16 nDirCount; // Anzahl der Verzeichnis-
// Verschachtelungen
protected:
virtual void UpdateEntries( const sal_Bool bWithDirs );
void UpdateDirs( const DirEntry& rTmpPath );
sal_Bool IsFileOk( const DirEntry& rDirEntry );
void InitControls();
DECL_LINK( SelectHdl, ListBox * );
DECL_LINK( DblClickHdl, ListBox * );
DECL_LINK( ClickHdl, Button * );
public:
ImpPathDialog( PathDialog* pDlg, RESOURCE_TYPE nType, sal_Bool bCreateDir );
virtual ~ImpPathDialog();
virtual void SetPath( const OUString& rPath );
virtual OUString GetPath() const;
virtual void PreExecute();
PathDialog* GetPathDialog() const { return pSvPathDialog; }
void SetOkButtonText( const String& rText ) { pOkBtn->SetText( rText ); }
void SetCancelButtonText( const String& rText ) { pCancelBtn->SetText( rText ); }
};
class ImpSvFileDlg
{
private:
ImpPathDialog* pDlg;
public:
ImpSvFileDlg() { pDlg = 0; }
~ImpSvFileDlg() { delete pDlg; }
ImpPathDialog* GetDialog() const { return pDlg; }
void CreatePathDialog(PathDialog* pCreateFrom, bool bCreate);
void SetOkButtonText( const String& rText ) { pDlg->SetOkButtonText( rText ); } // ihr habts ja nicht anders gewollt
void SetCancelButtonText( const String& rText ) { pDlg->SetCancelButtonText( rText ); }
};
#endif // FILEDLG2_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <svtools/filedlg2.hrc>
String STR_FILEDLG_SELECT
{
Text [ en-US ] = "Select Directory" ;
};
String STR_FILEDLG_CANTCHDIR
{
Text [ en-US ] = "Cannot change to directory" ;
};
String STR_FILEDLG_OPEN
{
Text [ en-US ] = "Open" ;
};
String STR_FILEDLG_FILE
{
Text [ en-US ] = "~File" ;
};
String STR_FILEDLG_DIR
{
Text [ en-US ] = "~Directory" ;
};
String STR_FILEDLG_TYPE
{
Text [ en-US ] = "File ~type" ;
};
String STR_FILEDLG_CANTOPENFILE
{
Text [ en-US ] = "Can't open file" ;
};
String STR_FILEDLG_CANTOPENDIR
{
Text [ en-US ] = "Can't open directory" ;
};
String STR_FILEDLG_OVERWRITE
{
Text [ en-US ] = "This file already exists. \nOverwrite ?" ;
};
String STR_FILEDLG_GOUP
{
Text [ en-US ] = "Up One Level" ;
};
String STR_FILEDLG_SAVE
{
Text [ en-US ] = "Save" ;
};
String STR_FILEDLG_DRIVES
{
Text [ en-US ] = "D~rive" ;
};
String STR_FILEDLG_HOME
{
Text [ en-US ] = "User Directory" ;
};
String STR_FILEDLG_NEWDIR
{
Text [ en-US ] = "Create Directory" ;
};
String STR_FILEDLG_ASKNEWDIR
{
Text [ en-US ] = "Do you want the directory %s to be created ?" ;
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -18,23 +18,24 @@
*/
#include <comphelper/string.hxx>
#include <svtools/filedlg.hxx>
#include <vcl/msgbox.hxx>
#include "logindlg.hxx"
#include "logindlg.hrc"
#include "ids.hrc"
#include <tools/resid.hxx>
#include <osl/file.hxx>
#ifdef UNX
#include <limits.h>
#define _MAX_PATH PATH_MAX
#endif
// LoginDialog -------------------------------------------------------
#include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
#include <com/sun/star/ui/dialogs/FolderPicker.hpp>
#include <comphelper/processfactory.hxx>
//............................................................................
//............................................................................
using namespace com::sun::star;
static void lcl_Move( Window &rWin, long nOffset )
{
......@@ -184,7 +185,6 @@ void LoginDialog::HideControls_Impl( sal_uInt16 nFlags )
}
};
// -----------------------------------------------------------------------
void LoginDialog::EnableUseSysCredsControls_Impl( sal_Bool bUseSysCredsEnabled )
{
aErrorInfo.Enable( !bUseSysCredsEnabled );
......@@ -201,8 +201,6 @@ void LoginDialog::EnableUseSysCredsControls_Impl( sal_Bool bUseSysCredsEnabled )
aAccountED.Enable( !bUseSysCredsEnabled );
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(LoginDialog, OKHdl_Impl)
{
// trim the strings
......@@ -212,30 +210,36 @@ IMPL_LINK_NOARG(LoginDialog, OKHdl_Impl)
return 1;
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(LoginDialog, PathHdl_Impl)
{
PathDialog* pDlg = new PathDialog( this, WB_3DLOOK );
pDlg->SetPath( aPathED.GetText() );
try
{
uno::Reference<ui::dialogs::XFolderPicker2> xFolderPicker = ui::dialogs::FolderPicker::create(comphelper::getProcessComponentContext());
OUString aPath( aPathED.GetText() );
osl::FileBase::getFileURLFromSystemPath( aPath, aPath );
xFolderPicker->setDisplayDirectory( aPath );
if ( pDlg->Execute() == RET_OK )
aPathED.SetText( pDlg->GetPath() );
if (xFolderPicker->execute() == ui::dialogs::ExecutableDialogResults::OK)
{
osl::FileBase::getSystemPathFromFileURL( xFolderPicker->getDirectory(), aPath );
aPathED.SetText( aPath );
}
}
catch (uno::Exception & e)
{
SAL_WARN("uui", "LoginDialog::PathHdl_Impl: caught UNO exception: " << e.Message);
}
delete pDlg;
return 1;
}
// -----------------------------------------------------------------------
IMPL_LINK_NOARG(LoginDialog, UseSysCredsHdl_Impl)
{
EnableUseSysCredsControls_Impl( aUseSysCredsCB.IsChecked() );
return 1;
}
// -----------------------------------------------------------------------
LoginDialog::LoginDialog
(
Window* pParent,
......@@ -296,14 +300,10 @@ LoginDialog::LoginDialog
HideControls_Impl( nFlags );
};
// -----------------------------------------------------------------------
LoginDialog::~LoginDialog()
{
}
// -----------------------------------------------------------------------
void LoginDialog::SetUseSystemCredentials( sal_Bool bUse )
{
if ( aUseSysCredsCB.IsVisible() )
......@@ -313,8 +313,6 @@ void LoginDialog::SetUseSystemCredentials( sal_Bool bUse )
}
}
// -----------------------------------------------------------------------
void LoginDialog::ClearPassword()
{
aPasswordED.SetText( String() );
......@@ -325,15 +323,10 @@ void LoginDialog::ClearPassword()
aPasswordED.GrabFocus();
};
// -----------------------------------------------------------------------
void LoginDialog::ClearAccount()
{
aAccountED.SetText( String() );
aAccountED.GrabFocus();
};
//............................................................................
//............................................................................
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment