vcl/source/window/builder.cxx | 74 +++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 40 deletions(-)
New commits: commit 547b99e0a8071ba92380f8d5f3751d02836942a4 Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 25 11:43:22 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Sep 25 21:10:13 2024 +0200 tdf#130857: Move .ui -> VCL respone code mapping to handleActionWidget Move mapping the (GTK) response code set in the .ui file to the VCL equivalent from VclBuilder::set_response to BuilderBase::handleActionWidget. As VCL response codes are used by all implementations, this is not specific to the vcl::Window implementation and also allows an upcoming QtBuilder::set_response_code implementation to use the passed value as is. Change-Id: I5b6d262a657932038c423c0c2cdcf1fd32c8b6be Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173930 Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> Tested-by: Jenkins diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index bcbdb3bd9f52..9ca9be6e7e49 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -3830,7 +3830,34 @@ void BuilderBase::handleActionWidget(xmlreader::XmlReader &reader) sal_Int32 nDelim = sID.indexOf(':'); if (nDelim != -1) sID = sID.copy(0, nDelim); - set_response(sID, sResponse.toInt32()); + + short nResponse = sResponse.toInt32(); + switch (nResponse) + { + case -5: + nResponse = RET_OK; + break; + case -6: + nResponse = RET_CANCEL; + break; + case -7: + nResponse = RET_CLOSE; + break; + case -8: + nResponse = RET_YES; + break; + case -9: + nResponse = RET_NO; + break; + case -11: + nResponse = RET_HELP; + break; + default: + assert(nResponse >= 100 && "keep non-canned responses in range 100+ to avoid collision with vcl RET_*"); + break; + } + + set_response(sID, nResponse); } void BuilderBase::collectAccelerator(xmlreader::XmlReader& reader, accelmap& rMap) @@ -3909,31 +3936,6 @@ PopupMenu *VclBuilder::get_menu(std::u16string_view sID) void VclBuilder::set_response(std::u16string_view sID, short nResponse) { - switch (nResponse) - { - case -5: - nResponse = RET_OK; - break; - case -6: - nResponse = RET_CANCEL; - break; - case -7: - nResponse = RET_CLOSE; - break; - case -8: - nResponse = RET_YES; - break; - case -9: - nResponse = RET_NO; - break; - case -11: - nResponse = RET_HELP; - break; - default: - assert(nResponse >= 100 && "keep non-canned responses in range 100+ to avoid collision with vcl RET_*"); - break; - } - PushButton* pPushButton = get<PushButton>(sID); assert(pPushButton); Dialog* pDialog = pPushButton->GetParentDialog(); commit ac0989b02fc6b8ff8fa7c985f8dcaf71547c489b Author: Michael Weghorn <m.wegh...@posteo.de> AuthorDate: Wed Sep 25 11:34:56 2024 +0200 Commit: Michael Weghorn <m.wegh...@posteo.de> CommitDate: Wed Sep 25 21:10:05 2024 +0200 tdf#130857 VclBuilder: Use existing VclBuilder::get ... instead of reimplementing the logic in VclBuilder::set_response. Change-Id: I634d918a356caddc79419b94dda7bd0657fa8c20 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173929 Tested-by: Jenkins Reviewed-by: Michael Weghorn <m.wegh...@posteo.de> diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 4b7d3148be9a..bcbdb3bd9f52 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -3934,20 +3934,12 @@ void VclBuilder::set_response(std::u16string_view sID, short nResponse) break; } - for (const auto & child : m_aChildren) - { - if (child.m_sID == sID) - { - PushButton* pPushButton = dynamic_cast<PushButton*>(child.m_pWindow.get()); - assert(pPushButton); - Dialog* pDialog = pPushButton->GetParentDialog(); - assert(pDialog); - pDialog->add_button(pPushButton, nResponse, false); - return; - } - } - - assert(false); + PushButton* pPushButton = get<PushButton>(sID); + assert(pPushButton); + Dialog* pDialog = pPushButton->GetParentDialog(); + assert(pDialog); + pDialog->add_button(pPushButton, nResponse, false); + return; } void VclBuilder::delete_by_name(const OUString& sID)