[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-22 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit 4407e3ce7334b179f777b043931ec071dbd7d3b0
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Fri Jul 22 16:22:48 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = 

[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-22 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit dcd9ddaa3f9d5f379fd4d786da825debdbb43db6
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Fri Jul 22 16:13:10 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = 

[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-22 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit c7da5fa2929433652b5007eecc0655011f43a3e6
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Fri Jul 22 15:50:26 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = 

[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-22 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit f2e65b98ebb000faad71e7f1b6794d6f590c20a4
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Fri Jul 22 12:56:30 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = 

[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-22 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit e8225b1022a0f0f199f864b136da7383e7f63b7a
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Fri Jul 22 10:38:56 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = 

[Libreoffice-commits] core.git: Branch 'private/mert/wip_deepl' - cui/inc cui/Library_cui.mk cui/source cui/uiconfig cui/UIConfig_cui.mk desktop/source include/sfx2 include/svtools include/svx include

2022-07-21 Thread Mert Tumer (via logerrit)
Rebased ref, commits from common ancestor:
commit 0b9cd43517787804e8a11899f2f4776b38fc0b4e
Author: Mert Tumer 
AuthorDate: Tue Jul 5 12:03:27 2022 +0300
Commit: Mert Tumer 
CommitDate: Thu Jul 21 22:21:10 2022 +0300

new uno command uno:Translate with deepl api

New Uno command added for translation
right now it is only using deepl translation api

There's a section in the options > language settings
for setting up the api url and auth key

uno:Translate is a menu button under Format tab
which will bring up Language Selection dialog for translation.

DeepL can accept html as the input for translation, this new
feature leverages that by exporting paragraphs/selections to
html and paste them back without losing the formatting (in theory)
This works good in general but we may lose formatting in very complex
styled sentences.

Translation works in two ways;
1) Whole document
when there is no selection, it assumes that we want to translate whole
document. Each paragraphs is sent one by one so that the output timeout
can be minimum for each paragraph.
2) Selection

Signed-off-by: Mert Tumer 
Change-Id: Ia2d3ab2f6757faf565b939e1d670a7dedac33390

diff --git a/cui/Library_cui.mk b/cui/Library_cui.mk
index d455a64ab266..c4c0a52b2ef4 100644
--- a/cui/Library_cui.mk
+++ b/cui/Library_cui.mk
@@ -181,6 +181,7 @@ $(eval $(call gb_Library_add_exception_objects,cui,\
 cui/source/options/optgenrl \
 cui/source/options/opthtml \
 cui/source/options/optlanguagetool \
+cui/source/options/optdeepl \
 cui/source/options/optinet2 \
 cui/source/options/optjava \
 cui/source/options/optjsearch \
diff --git a/cui/UIConfig_cui.mk b/cui/UIConfig_cui.mk
index 806779daaa9d..0ed879e2b228 100644
--- a/cui/UIConfig_cui.mk
+++ b/cui/UIConfig_cui.mk
@@ -139,6 +139,7 @@ $(eval $(call gb_UIConfig_add_uifiles,cui,\
cui/uiconfig/ui/optgeneralpage \
cui/uiconfig/ui/opthtmlpage \
cui/uiconfig/ui/langtoolconfigpage \
+   cui/uiconfig/ui/deepltabpage \
cui/uiconfig/ui/optionsdialog \
cui/uiconfig/ui/optjsearchpage \
cui/uiconfig/ui/optlanguagespage \
diff --git a/cui/inc/treeopt.hrc b/cui/inc/treeopt.hrc
index 952b79ea92d4..6d5bc4004a53 100644
--- a/cui/inc/treeopt.hrc
+++ b/cui/inc/treeopt.hrc
@@ -55,7 +55,8 @@ const std::pair 
SID_LANGUAGE_OPTIONS_RES[] =
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Searching in Japanese"),  
RID_SVXPAGE_JSEARCH_OPTIONS },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Asian Layout"),  
RID_SVXPAGE_ASIAN_LAYOUT },
 { NC_("SID_LANGUAGE_OPTIONS_RES", "Complex Text Layout"),  
RID_SVXPAGE_OPTIONS_CTL },
-{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS }
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "LanguageTool Server Settings"),  
RID_SVXPAGE_LANGTOOL_OPTIONS },
+{ NC_("SID_LANGUAGE_OPTIONS_RES", "DeepL Server Settings"),  
RID_SVXPAGE_DEEPL_OPTIONS }
 };
 
 const std::pair SID_INET_DLG_RES[] =
diff --git a/cui/source/options/optdeepl.cxx b/cui/source/options/optdeepl.cxx
new file mode 100644
index ..94b48ccc2f43
--- /dev/null
+++ b/cui/source/options/optdeepl.cxx
@@ -0,0 +1,55 @@
+/* -*- 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 .
+ */
+
+#include "optdeepl.hxx"
+#include 
+
+OptDeeplTabPage::OptDeeplTabPage(weld::Container* pPage,
+   weld::DialogController* 
pController,
+   const SfxItemSet& rSet)
+: SfxTabPage(pPage, pController, "cui/ui/deepltabpage.ui", "OptDeeplPage", 
)
+, m_xAPIUrl(m_xBuilder->weld_entry("apiurl"))
+, m_xAuthKey(m_xBuilder->weld_entry("authkey"))
+{
+
+}
+
+OptDeeplTabPage::~OptDeeplTabPage() {}
+
+void OptDeeplTabPage::Reset(const SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions = SvxDeeplOptions::Get();
+m_xAPIUrl->set_text(rDeeplOptions.getAPIUrl());
+m_xAuthKey->set_text(rDeeplOptions.getAuthKey());
+}
+
+bool OptDeeplTabPage::FillItemSet(SfxItemSet*)
+{
+SvxDeeplOptions& rDeeplOptions =