2011-09-29 15:42:27 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-11 13:49:09 -05:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2014-05-19 04:50:39 -05:00
|
|
|
#include <osl/file.hxx>
|
2017-07-31 11:16:27 -05:00
|
|
|
#include <unotools/resmgr.hxx>
|
2017-06-11 14:56:30 -05:00
|
|
|
#include <vcl/layout.hxx>
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2017-10-23 15:28:38 -05:00
|
|
|
#include <strings.hrc>
|
2010-06-25 08:18:20 -05:00
|
|
|
#include "nameclashdlg.hxx"
|
|
|
|
|
|
|
|
// NameClashDialog ---------------------------------------------------------
|
|
|
|
|
2016-10-05 00:56:12 -05:00
|
|
|
IMPL_LINK( NameClashDialog, ButtonHdl_Impl, Button *, pBtn, void )
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2018-01-12 13:12:15 -06:00
|
|
|
long nRet = long(ABORT);
|
2014-08-20 05:29:37 -05:00
|
|
|
if ( m_pBtnRename == pBtn )
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2018-01-12 13:12:15 -06:00
|
|
|
nRet = long(RENAME);
|
2014-08-20 05:29:37 -05:00
|
|
|
OUString aNewName = m_pEDNewName->GetText();
|
2012-01-19 18:05:49 -06:00
|
|
|
if ( ( aNewName == maNewName ) || aNewName.isEmpty() )
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2015-03-31 17:04:14 -05:00
|
|
|
ScopedVclPtrInstance< MessageDialog > aError(nullptr, maSameName);
|
2015-02-11 06:42:23 -06:00
|
|
|
aError->Execute();
|
2015-08-19 02:11:34 -05:00
|
|
|
return;
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
maNewName = aNewName;
|
|
|
|
}
|
2014-08-20 05:29:37 -05:00
|
|
|
else if ( m_pBtnOverwrite == pBtn )
|
2018-01-12 13:12:15 -06:00
|
|
|
nRet = long(OVERWRITE);
|
2010-06-25 08:18:20 -05:00
|
|
|
|
|
|
|
EndDialog( nRet );
|
|
|
|
}
|
|
|
|
|
2014-02-22 14:20:15 -06:00
|
|
|
|
2017-06-11 14:56:30 -05:00
|
|
|
NameClashDialog::NameClashDialog( vcl::Window* pParent, const std::locale& rResLocale,
|
2013-04-07 05:06:47 -05:00
|
|
|
OUString const & rTargetFolderURL,
|
|
|
|
OUString const & rClashingName,
|
|
|
|
OUString const & rProposedNewName,
|
2010-06-25 08:18:20 -05:00
|
|
|
bool bAllowOverwrite )
|
2014-08-20 05:29:37 -05:00
|
|
|
: ModalDialog( pParent, "SimpleNameClashDialog", "uui/ui/simplenameclash.ui" ),
|
2010-06-25 08:18:20 -05:00
|
|
|
maNewName ( rClashingName )
|
|
|
|
{
|
2014-08-20 05:29:37 -05:00
|
|
|
get(m_pFTMessage, "warning");
|
|
|
|
get(m_pEDNewName, "newname");
|
|
|
|
get(m_pBtnOverwrite, "replace");
|
|
|
|
get(m_pBtnRename, "rename");
|
|
|
|
get(m_pBtnCancel, "cancel");
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2015-08-19 02:11:34 -05:00
|
|
|
Link<Button*,void> aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
|
2014-08-20 05:29:37 -05:00
|
|
|
m_pBtnOverwrite->SetClickHdl( aLink );
|
|
|
|
m_pBtnRename->SetClickHdl( aLink );
|
|
|
|
m_pBtnCancel->SetClickHdl( aLink );
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2013-09-25 05:18:11 -05:00
|
|
|
OUString aInfo;
|
2010-06-25 08:18:20 -05:00
|
|
|
if ( bAllowOverwrite )
|
|
|
|
{
|
2017-06-11 14:56:30 -05:00
|
|
|
aInfo = Translate::get(STR_RENAME_OR_REPLACE, rResLocale);
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-06-11 14:56:30 -05:00
|
|
|
aInfo = Translate::get(STR_NAME_CLASH_RENAME_ONLY, rResLocale);
|
2014-08-20 05:29:37 -05:00
|
|
|
m_pBtnOverwrite->Hide();
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
|
2013-04-07 05:06:47 -05:00
|
|
|
OUString aPath;
|
2010-06-28 06:44:39 -05:00
|
|
|
if ( osl::FileBase::E_None != osl::FileBase::getSystemPathFromFileURL( rTargetFolderURL, aPath ) )
|
|
|
|
aPath = rTargetFolderURL;
|
|
|
|
|
2017-06-11 14:56:30 -05:00
|
|
|
maSameName = Translate::get(STR_SAME_NAME_USED, rResLocale);
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2013-09-25 05:18:11 -05:00
|
|
|
aInfo = aInfo.replaceFirst( "%NAME", rClashingName );
|
|
|
|
aInfo = aInfo.replaceFirst( "%FOLDER", aPath );
|
2014-08-20 05:29:37 -05:00
|
|
|
m_pFTMessage->SetText( aInfo );
|
2012-01-19 18:05:49 -06:00
|
|
|
if ( !rProposedNewName.isEmpty() )
|
2014-08-20 05:29:37 -05:00
|
|
|
m_pEDNewName->SetText( rProposedNewName );
|
2010-06-25 08:18:20 -05:00
|
|
|
else
|
2014-08-20 05:29:37 -05:00
|
|
|
m_pEDNewName->SetText( rClashingName );
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
|
2015-03-09 07:29:30 -05:00
|
|
|
NameClashDialog::~NameClashDialog()
|
|
|
|
{
|
2015-03-10 02:07:06 -05:00
|
|
|
disposeOnce();
|
2015-03-09 07:29:30 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
void NameClashDialog::dispose()
|
|
|
|
{
|
|
|
|
m_pFTMessage.clear();
|
|
|
|
m_pEDNewName.clear();
|
|
|
|
m_pBtnOverwrite.clear();
|
|
|
|
m_pBtnRename.clear();
|
|
|
|
m_pBtnCancel.clear();
|
|
|
|
ModalDialog::dispose();
|
|
|
|
}
|
|
|
|
|
2011-09-29 15:42:27 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|