1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <alienwarn.hxx>
21 #include <officecfg/Office/Common.hxx>
23 SfxAlienWarningDialog::SfxAlienWarningDialog(weld::Window
* pParent
,
24 std::u16string_view _rFormatName
,
25 const OUString
& _rDefaultExtension
,
27 : MessageDialogController(pParent
, "sfx/ui/alienwarndialog.ui", "AlienWarnDialog", "ask")
28 , m_xKeepCurrentBtn(m_xBuilder
->weld_button("save"))
29 , m_xUseDefaultFormatBtn(m_xBuilder
->weld_button("cancel"))
30 , m_xWarningOnBox(m_xBuilder
->weld_check_button("ask"))
32 OUString aExtension
= "ODF";
34 // replace formatname (text)
35 OUString sInfoText
= m_xDialog
->get_primary_text();
36 sInfoText
= sInfoText
.replaceAll("%FORMATNAME", _rFormatName
);
37 m_xDialog
->set_primary_text(sInfoText
);
39 // replace formatname (button)
40 sInfoText
= m_xKeepCurrentBtn
->get_label();
41 sInfoText
= sInfoText
.replaceAll("%FORMATNAME", _rFormatName
);
42 m_xKeepCurrentBtn
->set_label(sInfoText
);
44 // hide ODF explanation if default format is alien
45 // and set the proper extension in the button
48 m_xDialog
->set_secondary_text(OUString());
49 aExtension
= _rDefaultExtension
.toAsciiUpperCase();
52 // replace defaultextension (button)
53 sInfoText
= m_xUseDefaultFormatBtn
->get_label();
54 sInfoText
= sInfoText
.replaceAll("%DEFAULTEXTENSION", aExtension
);
55 m_xUseDefaultFormatBtn
->set_label(sInfoText
);
57 // load value of "warning on" checkbox from save options
58 m_xWarningOnBox
->set_active(officecfg::Office::Common::Save::Document::WarnAlienFormat::get());
61 SfxAlienWarningDialog::~SfxAlienWarningDialog()
65 // save value of "warning off" checkbox, if necessary
66 bool bChecked
= m_xWarningOnBox
->get_active();
67 if (officecfg::Office::Common::Save::Document::WarnAlienFormat::get() != bChecked
)
69 auto xChanges
= comphelper::ConfigurationChanges::create();
70 officecfg::Office::Common::Save::Document::WarnAlienFormat::set(bChecked
, xChanges
);
79 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */