Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / cui / source / options / optdeepl.cxx
blob75db4af70f77f745d32e14f77b955f459898e9de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 "optdeepl.hxx"
21 #include <officecfg/Office/Linguistic.hxx>
23 OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage, weld::DialogController* pController,
24 const SfxItemSet& rSet)
25 : SfxTabPage(pPage, pController, "cui/ui/optdeeplpage.ui", "OptDeeplPage", &rSet)
26 , m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
27 , m_xAuthKey(m_xBuilder->weld_entry("authkey"))
31 OptDeeplTabPage::~OptDeeplTabPage() {}
33 void OptDeeplTabPage::Reset(const SfxItemSet*)
35 std::optional<OUString> oDeeplAPIUrl
36 = officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get();
37 if (oDeeplAPIUrl && !oDeeplAPIUrl->isEmpty())
38 m_xAPIUrl->set_text(*officecfg::Office::Linguistic::Translation::Deepl::ApiURL::get());
40 std::optional<OUString> oDeeplAuthKey
41 = officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get();
42 if (oDeeplAuthKey && !oDeeplAuthKey->isEmpty())
43 m_xAuthKey->set_text(*officecfg::Office::Linguistic::Translation::Deepl::AuthKey::get());
46 bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
48 std::shared_ptr<comphelper::ConfigurationChanges> batch(
49 comphelper::ConfigurationChanges::create());
50 officecfg::Office::Linguistic::Translation::Deepl::ApiURL::set(m_xAPIUrl->get_text(), batch);
51 officecfg::Office::Linguistic::Translation::Deepl::AuthKey::set(m_xAuthKey->get_text(), batch);
52 batch->commit();
53 return false;
56 std::unique_ptr<SfxTabPage> OptDeeplTabPage::Create(weld::Container* pPage,
57 weld::DialogController* pController,
58 const SfxItemSet* rAttrSet)
60 return std::make_unique<OptDeeplTabPage>(pPage, pController, *rAttrSet);