/* -*- 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 .
*/
OUStringBuffer aText(rContext); if (!rContext.empty() && !rMessage.empty())
aText.append(":\n"); //TODO! must be internationalized
aText.append(rMessage);
std::unique_ptr<weld::MessageDialog> xBox;
switch (eClassification)
{ case task::InteractionClassification_ERROR:
xBox.reset(Application::CreateMessageDialog(pParent,
VclMessageType::Error, VclButtonsType::NONE, aText.makeStringAndClear(), GetpApp())); break; case task::InteractionClassification_WARNING:
xBox.reset(Application::CreateMessageDialog(pParent,
VclMessageType::Warning, VclButtonsType::NONE, aText.makeStringAndClear(), GetpApp())); break; case task::InteractionClassification_INFO:
xBox.reset(Application::CreateMessageDialog(pParent,
VclMessageType::Info, VclButtonsType::NONE, aText.makeStringAndClear(), GetpApp())); break; case task::InteractionClassification_QUERY:
xBox.reset(Application::CreateMessageDialog(pParent,
VclMessageType::Question, VclButtonsType::NONE, aText.makeStringAndClear(), GetpApp())); break; default:
assert(false); break;
}
switch (nButtonMask)
{ case MessageBoxStyle::NONE: break; case MessageBoxStyle::Ok:
xBox->add_button(GetStandardText(StandardButtonType::OK), static_cast<int>(DialogMask::ButtonsOk)); break; case MessageBoxStyle::OkCancel:
xBox->add_button(GetStandardText(StandardButtonType::OK), static_cast<int>(DialogMask::ButtonsOk));
xBox->add_button(GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); break; case MessageBoxStyle::YesNo:
xBox->add_button(GetStandardText(StandardButtonType::Yes), static_cast<int>(DialogMask::ButtonsYes));
xBox->add_button(GetStandardText(StandardButtonType::No), static_cast<int>(DialogMask::ButtonsNo)); break; case MessageBoxStyle::YesNoCancel:
xBox->add_button(GetStandardText(StandardButtonType::Yes), static_cast<int>(DialogMask::ButtonsYes));
xBox->add_button(GetStandardText(StandardButtonType::No), static_cast<int>(DialogMask::ButtonsNo));
xBox->add_button(GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); break; case MessageBoxStyle::RetryCancel:
xBox->add_button(GetStandardText(StandardButtonType::Retry), static_cast<int>(DialogMask::ButtonsRetry));
xBox->add_button(GetStandardText(StandardButtonType::Cancel), static_cast<int>(DialogMask::ButtonsCancel)); break;
}
if (bObtainErrorStringOnly)
{
rErrorString = aMessage; return;
} else
{ //TODO! It can happen that the buttons calculated below do not match // the error text from the resource (e.g., some text that is not a // question, but YES and NO buttons). Some error texts have // ExtraData that specifies a set of buttons, but that data is not // really useful, because a single error text may well make sense // both with only an OK button and with RETRY and CANCEL buttons.
// The following mapping uses the bit mask // Approve = 8, // Disapprove = 4, // Retry = 2, // Abort = 1
// The mapping has five properties on which the code to select the // correct continuation relies: // 1 The OK button is mapped to Approve if that is available, // otherwise to Abort if that is available, otherwise to none. // 2 The CANCEL button is always mapped to Abort. // 3 The RETRY button is always mapped to Retry. // 4 The NO button is always mapped to Disapprove. // 5 The YES button is always mapped to Approve.
// Because the WinBits button combinations are quite restricted, not // every request can be served here.
// Finally, it seems to be better to leave default button // determination to VCL (the favouring of CANCEL as default button // seems to not always be what the user wants)...
MessageBoxStyle const aButtonMask[16]
= { MessageBoxStyle::NONE,
MessageBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Abort
MessageBoxStyle::NONE,
MessageBoxStyle::RetryCancel /*| MessBoxStyle::DefaultCancel*/, // Retry, Abort
MessageBoxStyle::NONE,
MessageBoxStyle::NONE,
MessageBoxStyle::NONE,
MessageBoxStyle::NONE,
MessageBoxStyle::Ok /*| MessBoxStyle::DefaultOk*/, // Approve
MessageBoxStyle::OkCancel /*| MessBoxStyle::DefaultCancel*/, // Approve, Abort
MessageBoxStyle::NONE,
MessageBoxStyle::NONE,
MessageBoxStyle::YesNo /*| MessBoxStyle::DefaultNo*/, // Approve, Disapprove
MessageBoxStyle::YesNoCancel /*| MessBoxStyle::DefaultCancel*/, // Approve, Disapprove, Abort
MessageBoxStyle::NONE,
MessageBoxStyle::NONE };
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.