[Libreoffice-commits] core.git: 2 commits - editeng/source wizards/source
Jean-Pierre Ledure (via logerrit)
logerrit at kemper.freedesktop.org
Tue May 4 14:14:44 UTC 2021
editeng/source/editeng/editobj.cxx | 47 ++++++++++----------------
wizards/source/scriptforge/SF_Exception.xba | 4 ++
wizards/source/scriptforge/SF_Root.xba | 7 +++
wizards/source/scriptforge/SF_TextStream.xba | 10 ++---
wizards/source/scriptforge/po/ScriptForge.pot | 13 ++++++-
wizards/source/scriptforge/po/en.po | 13 ++++++-
6 files changed, 58 insertions(+), 36 deletions(-)
New commits:
commit f38c39534ffc9f33bfa4a588624c35b662b55b62
Author: Jean-Pierre Ledure <jp at ledure.be>
AuthorDate: Tue May 4 14:28:54 2021 +0200
Commit: Jean-Pierre Ledure <jp at ledure.be>
CommitDate: Tue May 4 16:14:10 2021 +0200
ScriptForge - (SF_TextStream)FIX raise error when end-of-file
Error was announced with a message box.
Error message was not translatable.
Managed with standard exception handling.
Change-Id: I10d67985ec4bdebce5bda9123caddb4134646b48
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115095
Tested-by: Jean-Pierre Ledure <jp at ledure.be>
Tested-by: Jenkins
Reviewed-by: Jean-Pierre Ledure <jp at ledure.be>
diff --git a/wizards/source/scriptforge/SF_Exception.xba b/wizards/source/scriptforge/SF_Exception.xba
index ddfe56a069c8..6bdf9908a411 100644
--- a/wizards/source/scriptforge/SF_Exception.xba
+++ b/wizards/source/scriptforge/SF_Exception.xba
@@ -85,6 +85,7 @@ Const SENDMAILERROR = "SENDMAILERROR"
' SF_TextStream
Const FILENOTOPENERROR = "FILENOTOPENERROR"
Const FILEOPENMODEERROR = "FILEOPENMODEERROR"
+Const ENDOFFILEERROR = "ENDOFFILEERROR"
' SF_UI
Const DOCUMENTERROR = "DOCUMENTERROR"
@@ -842,6 +843,9 @@ Try:
Case FILEOPENMODEERROR ' SF_TextStream._IsFileOpen(FileName)
sMessage = sLocation _
& "\n" & "\n" & .GetText("FILEOPENMODE", pvArgs(0), pvArgs(1))
+ Case ENDOFFILEERROR ' SF_TextStream.ReadLine/ReadAll/SkipLine(FileName)
+ sMessage = sLocation _
+ & "\n" & "\n" & .GetText("ENDOFFILE", pvArgs(0))
Case DOCUMENTERROR ' SF_UI.GetDocument(ArgName, WindowName)
sMessage = sLocation _
& "\n" & "\n" & "\n" & .GetText("VALIDATEERROR", pvArgs(0)) _
diff --git a/wizards/source/scriptforge/SF_Root.xba b/wizards/source/scriptforge/SF_Root.xba
index 39cf315bd3d2..0a5aaa6055ab 100644
--- a/wizards/source/scriptforge/SF_Root.xba
+++ b/wizards/source/scriptforge/SF_Root.xba
@@ -647,6 +647,13 @@ Try:
& "%1: A file name\n" _
& "%2: READ, WRITE or APPEND" _
)
+ ' SF_TextStream.ReadLine, ReadAll, SkipLine
+ .AddText( Context := "ENDOFFILE" _
+ , MsgId := "The requested file read operation could not be completed because an unexpected end-of-file was encountered.\n\n" _
+ & "File name = '%1'" _
+ , Comment := "SF_TextStream.ReadLine/ReadAll/SkipLine error message\n" _
+ & "%1: A file name" _
+ )
' SF_UI.Document
.AddText( Context := "DOCUMENT" _
, MsgId := "The requested document could not be found.\n\n" _
diff --git a/wizards/source/scriptforge/SF_TextStream.xba b/wizards/source/scriptforge/SF_TextStream.xba
index 27ff3d9bb4c9..827c5e303344 100644
--- a/wizards/source/scriptforge/SF_TextStream.xba
+++ b/wizards/source/scriptforge/SF_TextStream.xba
@@ -41,6 +41,7 @@ REM ================================================================== EXCEPTION
Const FILENOTOPENERROR = "FILENOTOPENERROR" ' The file is already closed
Const FILEOPENMODEERROR = "FILEOPENMODEERROR" ' The file is open in incompatible mode
+Const ENDOFFILEERROR = "ENDOFFILEERROR" ' When file was read, an end-of-file was encountered
REM ============================================================= PRIVATE MEMBERS
@@ -341,8 +342,7 @@ Finally:
Catch:
GoTo Finally
CatchEOF:
- 'TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
- MsgBox "END OF FILE ERROR !!"
+ SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
GoTo Finally
End Function ' ScriptForge.SF_TextStream.ReadAll
@@ -406,8 +406,7 @@ Finally:
Catch:
GoTo Finally
CatchEOF:
- 'TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
- MsgBox "END OF FILE ERROR !!"
+ SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
GoTo Finally
End Function ' ScriptForge.SF_TextStream.ReadLine
@@ -486,8 +485,7 @@ Finally:
Catch:
GoTo Finally
CatchEOF:
- 'TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
- MsfBox "END OF FILE ERROR !!"
+ SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
GoTo Finally
End Sub ' ScriptForge.SF_TextStream.SkipLine
diff --git a/wizards/source/scriptforge/po/ScriptForge.pot b/wizards/source/scriptforge/po/ScriptForge.pot
index 012eebf29466..709175d73147 100644
--- a/wizards/source/scriptforge/po/ScriptForge.pot
+++ b/wizards/source/scriptforge/po/ScriptForge.pot
@@ -14,7 +14,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
-"POT-Creation-Date: 2021-05-02 17:38:42\n"
+"POT-Creation-Date: 2021-05-04 14:09:55\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL at ADDRESS>\n"
@@ -514,6 +514,17 @@ msgid ""
"Open mode = %2"
msgstr ""
+#. SF_TextStream.ReadLine/ReadAll/SkipLine error message
+#. %1: A file name
+#, kde-format
+msgctxt "ENDOFFILE"
+msgid ""
+"The requested file read operation could not be completed because an "
+"unexpected end-of-file was encountered.\n"
+"\n"
+"File name = '%1'"
+msgstr ""
+
#. SF_UI.GetDocument error message
#. %1: An identifier
#. %2: A string
diff --git a/wizards/source/scriptforge/po/en.po b/wizards/source/scriptforge/po/en.po
index 012eebf29466..709175d73147 100644
--- a/wizards/source/scriptforge/po/en.po
+++ b/wizards/source/scriptforge/po/en.po
@@ -14,7 +14,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: https://bugs.libreoffice.org/enter_bug.cgi?product=LibreOffice&bug_status=UNCONFIRMED&component=UI\n"
-"POT-Creation-Date: 2021-05-02 17:38:42\n"
+"POT-Creation-Date: 2021-05-04 14:09:55\n"
"PO-Revision-Date: YYYY-MM-DD HH:MM:SS\n"
"Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
"Language-Team: LANGUAGE <EMAIL at ADDRESS>\n"
@@ -514,6 +514,17 @@ msgid ""
"Open mode = %2"
msgstr ""
+#. SF_TextStream.ReadLine/ReadAll/SkipLine error message
+#. %1: A file name
+#, kde-format
+msgctxt "ENDOFFILE"
+msgid ""
+"The requested file read operation could not be completed because an "
+"unexpected end-of-file was encountered.\n"
+"\n"
+"File name = '%1'"
+msgstr ""
+
#. SF_UI.GetDocument error message
#. %1: An identifier
#. %2: A string
commit 30312222e5f7de5ebbabbf8ad33e373a53385971
Author: Noel Grandin <noel at peralex.com>
AuthorDate: Tue May 4 10:51:41 2021 +0200
Commit: Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Tue May 4 16:14:03 2021 +0200
speed up saving large ODS a little
by looping over the sections only once, and
moving the vector containing the borders outside
the loop.
Change-Id: Icf68ced94aa45a4737fb7d5a3fe076ab2931034e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115059
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 2736021b85cd..0d202ac59203 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -850,59 +850,50 @@ public:
void EditTextObjectImpl::GetAllSections( std::vector<editeng::Section>& rAttrs ) const
{
- std::vector<std::vector<size_t>> aParaBorders(aContents.size());
+ std::vector<editeng::Section> aAttrs;
+ aAttrs.reserve(aContents.size());
+ std::vector<size_t> aBorders;
- // First pass: determine section borders for each paragraph.
for (size_t nPara = 0; nPara < aContents.size(); ++nPara)
{
+ aBorders.clear();
const ContentInfo& rC = *aContents[nPara];
- std::vector<size_t>& rBorders = aParaBorders[nPara];
- rBorders.push_back(0);
- rBorders.push_back(rC.GetText().getLength());
+ aBorders.push_back(0);
+ aBorders.push_back(rC.GetText().getLength());
for (const XEditAttribute & rAttr : rC.maCharAttribs)
{
const SfxPoolItem* pItem = rAttr.GetItem();
if (!pItem)
continue;
- rBorders.push_back(rAttr.GetStart());
- rBorders.push_back(rAttr.GetEnd());
+ aBorders.push_back(rAttr.GetStart());
+ aBorders.push_back(rAttr.GetEnd());
}
- }
- // Sort and remove duplicates for each paragraph.
- for (auto & paraBorders : aParaBorders)
- {
- std::sort(paraBorders.begin(), paraBorders.end());
- auto itUniqueEnd = std::unique(paraBorders.begin(), paraBorders.end());
- paraBorders.erase(itUniqueEnd, paraBorders.end());
- }
+ // Sort and remove duplicates for each paragraph.
+ std::sort(aBorders.begin(), aBorders.end());
+ auto itUniqueEnd = std::unique(aBorders.begin(), aBorders.end());
+ aBorders.erase(itUniqueEnd, aBorders.end());
- std::vector<editeng::Section> aAttrs;
+ // Create storage for each section. Note that this creates storage even
+ // for unformatted sections. The entries are sorted first by paragraph,
+ // then by section positions. They don't overlap with each other.
- // Create storage for each section. Note that this creates storage even
- // for unformatted sections. The entries are sorted first by paragraph,
- // then by section positions. They don't overlap with each other.
- size_t nPara1 = 0;
- for (auto const& paraBorders : aParaBorders)
- {
- if (paraBorders.size() == 1 && paraBorders[0] == 0)
+ if (aBorders.size() == 1 && aBorders[0] == 0)
{
// Empty paragraph. Push an empty section.
- aAttrs.emplace_back(nPara1, 0, 0);
- ++nPara1;
+ aAttrs.emplace_back(nPara, 0, 0);
continue;
}
- auto itBorder = paraBorders.begin(), itBorderEnd = paraBorders.end();
+ auto itBorder = aBorders.begin(), itBorderEnd = aBorders.end();
size_t nPrev = *itBorder;
size_t nCur;
for (++itBorder; itBorder != itBorderEnd; ++itBorder, nPrev = nCur)
{
nCur = *itBorder;
- aAttrs.emplace_back(nPara1, nPrev, nCur);
+ aAttrs.emplace_back(nPara, nPrev, nCur);
}
- ++nPara1;
}
if (aAttrs.empty())
More information about the Libreoffice-commits
mailing list