21#include <osl/diagnose.h>
36#include <com/sun/star/task/XStatusIndicator.hpp>
38#include <com/sun/star/task/XStatusIndicatorFactory.hpp>
40#include <officecfg/Office/Linguistic.hxx>
44 static const std::vector<SwLanguageListItem> gLanguageVec{
79 : GenericDialogController(pParent,
"modules/swriter/ui/translationdialog.ui",
80 "LanguageSelectDialog")
82 , m_xLanguageListBox(m_xBuilder->weld_combo_box(
"combobox1"))
83 , m_xBtnCancel(m_xBuilder->weld_button(
"cancel"))
84 , m_xBtnTranslate(m_xBuilder->weld_button(
"translate"))
85 , m_bTranslationStarted(false)
86 , m_bCancelTranslation(false)
94 m_xLanguageListBox->append_text(OStringToOUString(item.getName(), RTL_TEXTENCODING_UTF8));
115 const auto selected = rBox.get_active();
122 if (m_bTranslationStarted)
123 m_bCancelTranslation =
true;
136 std::optional<OUString> oDeeplAPIUrl
138 std::optional<OUString> oDeeplKey
140 if (!oDeeplAPIUrl || oDeeplAPIUrl->isEmpty() || !oDeeplKey || oDeeplKey->isEmpty())
142 SAL_WARN(
"sw.ui",
"SwTranslateLangSelectDlg: API options are not set");
147 const OString aAPIUrl
149 RTL_TEXTENCODING_UTF8)
151 const OString aAuthKey =
OUStringToOString(*oDeeplKey, RTL_TEXTENCODING_UTF8).trim();
152 const auto aTargetLang
155 m_bTranslationStarted =
true;
Reference< XExecutableDialog > m_xDialog
static int selectedLangIdx
std::unique_ptr< weld::ComboBox > m_xLanguageListBox
static std::optional< SwLanguageListItem > GetSelectedLanguage()
SwTranslateLangSelectDlg(weld::Window *pParent, SwWrtShell &rSh)
std::unique_ptr< weld::Button > m_xBtnTranslate
std::unique_ptr< weld::Button > m_xBtnCancel
Used by the UI to modify the document model.
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
SW_DLLPUBLIC void TranslateDocumentCancellable(SwWrtShell &rWrtSh, const TranslateAPIConfig &rConfig, bool &rCancelTranslation)
OString OUStringToOString(std::u16string_view str, ConnectionSettings const *settings)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
static const std::vector< SwLanguageListItem > & getLanguageVec()
IMPL_LINK_NOARG(SwTranslateLangSelectDlg, LangSelectCancelHdl, weld::Button &, void)
IMPL_STATIC_LINK(SwTranslateLangSelectDlg, LangSelectHdl, weld::ComboBox &, rBox, void)