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>
|
2018-02-19 10:33:35 -06:00
|
|
|
#include <vcl/svapp.hxx>
|
|
|
|
#include <vcl/weld.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 ---------------------------------------------------------
|
|
|
|
|
2018-05-17 03:51:42 -05:00
|
|
|
IMPL_LINK(NameClashDialog, ButtonHdl_Impl, weld::Button&, rBtn, void)
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2020-10-12 02:52:12 -05:00
|
|
|
tools::Long nRet = tools::Long(ABORT);
|
2018-05-17 03:51:42 -05:00
|
|
|
if (m_xBtnRename.get() == &rBtn)
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2020-10-12 02:52:12 -05:00
|
|
|
nRet = tools::Long(RENAME);
|
2018-05-17 03:51:42 -05:00
|
|
|
OUString aNewName = m_xEDNewName->get_text();
|
|
|
|
if ( ( aNewName == m_aNewName ) || aNewName.isEmpty() )
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2018-05-17 03:51:42 -05:00
|
|
|
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(m_xDialog.get(),
|
2018-02-19 10:33:35 -06:00
|
|
|
VclMessageType::Warning, VclButtonsType::Ok,
|
2018-05-17 03:51:42 -05:00
|
|
|
m_aSameName));
|
2018-02-19 10:33:35 -06:00
|
|
|
xErrorBox->run();
|
2015-08-19 02:11:34 -05:00
|
|
|
return;
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
2018-05-17 03:51:42 -05:00
|
|
|
m_aNewName = aNewName;
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
2018-05-17 03:51:42 -05:00
|
|
|
else if (m_xBtnOverwrite.get() == &rBtn)
|
2020-10-12 02:52:12 -05:00
|
|
|
nRet = tools::Long(OVERWRITE);
|
2010-06-25 08:18:20 -05:00
|
|
|
|
2018-05-17 03:51:42 -05:00
|
|
|
m_xDialog->response(nRet);
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
|
2014-02-22 14:20:15 -06:00
|
|
|
|
2018-05-17 03:51:42 -05:00
|
|
|
NameClashDialog::NameClashDialog( weld::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 )
|
2024-05-15 13:46:04 -05:00
|
|
|
: GenericDialogController(pParent, u"uui/ui/simplenameclash.ui"_ustr, u"SimpleNameClashDialog"_ustr)
|
2018-05-17 03:51:42 -05:00
|
|
|
, m_aNewName(rClashingName)
|
2024-05-15 13:46:04 -05:00
|
|
|
, m_xFTMessage(m_xBuilder->weld_label(u"warning"_ustr))
|
|
|
|
, m_xEDNewName(m_xBuilder->weld_entry(u"newname"_ustr))
|
|
|
|
, m_xBtnOverwrite(m_xBuilder->weld_button(u"replace"_ustr))
|
|
|
|
, m_xBtnRename(m_xBuilder->weld_button(u"rename"_ustr))
|
|
|
|
, m_xBtnCancel(m_xBuilder->weld_button(u"cancel"_ustr))
|
2010-06-25 08:18:20 -05:00
|
|
|
{
|
2018-05-17 03:51:42 -05:00
|
|
|
Link<weld::Button&,void> aLink( LINK( this, NameClashDialog, ButtonHdl_Impl ) );
|
|
|
|
m_xBtnOverwrite->connect_clicked( aLink );
|
|
|
|
m_xBtnRename->connect_clicked( aLink );
|
|
|
|
m_xBtnCancel->connect_clicked( 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);
|
2018-05-17 03:51:42 -05:00
|
|
|
m_xBtnOverwrite->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;
|
|
|
|
|
2018-05-17 03:51:42 -05:00
|
|
|
m_aSameName = 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 );
|
2018-05-17 03:51:42 -05:00
|
|
|
m_xFTMessage->set_label(aInfo);
|
2012-01-19 18:05:49 -06:00
|
|
|
if ( !rProposedNewName.isEmpty() )
|
2018-05-17 03:51:42 -05:00
|
|
|
m_xEDNewName->set_text( rProposedNewName );
|
2010-06-25 08:18:20 -05:00
|
|
|
else
|
2018-05-17 03:51:42 -05:00
|
|
|
m_xEDNewName->set_text( rClashingName );
|
2010-06-25 08:18:20 -05:00
|
|
|
}
|
|
|
|
|
2015-03-09 07:29:30 -05:00
|
|
|
NameClashDialog::~NameClashDialog()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2011-09-29 15:42:27 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|