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 <[email protected]>
AuthorDate: Tue May 4 14:28:54 2021 +0200
Commit:     Jean-Pierre Ledure <[email protected]>
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 <[email protected]>
    Tested-by: Jenkins
    Reviewed-by: Jean-Pierre Ledure <[email protected]>

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                           =       
&quot;SENDMAILERROR&quot;
 &apos; SF_TextStream
 Const FILENOTOPENERROR                 =       &quot;FILENOTOPENERROR&quot;
 Const FILEOPENMODEERROR                        =       
&quot;FILEOPENMODEERROR&quot;
+Const ENDOFFILEERROR                   =       &quot;ENDOFFILEERROR&quot;
 
 &apos; SF_UI
 Const DOCUMENTERROR                            =       
&quot;DOCUMENTERROR&quot;
@@ -842,6 +843,9 @@ Try:
                        Case FILEOPENMODEERROR          &apos;  
SF_TextStream._IsFileOpen(FileName)
                                sMessage = sLocation _
                                        &amp; &quot;\n&quot; &amp; 
&quot;\n&quot; &amp; .GetText(&quot;FILEOPENMODE&quot;, pvArgs(0), pvArgs(1))
+                       Case ENDOFFILEERROR                     &apos;  
SF_TextStream.ReadLine/ReadAll/SkipLine(FileName)
+                               sMessage = sLocation _
+                                       &amp; &quot;\n&quot; &amp; 
&quot;\n&quot; &amp; .GetText(&quot;ENDOFFILE&quot;, pvArgs(0))
                        Case DOCUMENTERROR                      &apos;  
SF_UI.GetDocument(ArgName, WindowName)
                                sMessage = sLocation _
                                        &amp; &quot;\n&quot; &amp; 
&quot;\n&quot; &amp; &quot;\n&quot; &amp; .GetText(&quot;VALIDATEERROR&quot;, 
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:
                                                                        &amp;   
&quot;%1: A file name\n&quot; _
                                                                        &amp;   
&quot;%2: READ, WRITE or APPEND&quot; _
                                        )
+       &apos;  SF_TextStream.ReadLine, ReadAll, SkipLine
+                       .AddText(       Context := &quot;ENDOFFILE&quot; _
+                                               , MsgId := &quot;The requested 
file read operation could not be completed because an unexpected end-of-file 
was encountered.\n\n&quot; _
+                                                                       &amp; 
&quot;File name = &apos;%1&apos;&quot; _
+                                               , Comment :=    
&quot;SF_TextStream.ReadLine/ReadAll/SkipLine error message\n&quot; _
+                                                                       &amp;   
&quot;%1: A file name&quot; _
+                                       )
        &apos;  SF_UI.Document
                        .AddText(       Context := &quot;DOCUMENT&quot; _
                                                , MsgId := &quot;The requested 
document could not be found.\n\n&quot; _
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                 =       &quot;FILENOTOPENERROR&quot;    
        &apos;  The file is already closed
 Const FILEOPENMODEERROR                        =       
&quot;FILEOPENMODEERROR&quot;           &apos;  The file is open in 
incompatible mode
+Const ENDOFFILEERROR                   =       &quot;ENDOFFILEERROR&quot;      
        &apos;  When file was read, an end-of-file was encountered
 
 REM ============================================================= PRIVATE 
MEMBERS
 
@@ -341,8 +342,7 @@ Finally:
 Catch:
        GoTo Finally
 CatchEOF:
-       &apos;TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
-       MsgBox &quot;END OF FILE ERROR !!&quot;
+       SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
        GoTo Finally
 End Function    &apos;   ScriptForge.SF_TextStream.ReadAll
 
@@ -406,8 +406,7 @@ Finally:
 Catch:
        GoTo Finally
 CatchEOF:
-       &apos;TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
-       MsgBox &quot;END OF FILE ERROR !!&quot;
+       SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
        GoTo Finally
 End Function    &apos;   ScriptForge.SF_TextStream.ReadLine
 
@@ -486,8 +485,7 @@ Finally:
 Catch:
        GoTo Finally
 CatchEOF:
-       &apos;TODO: SF_Exception.RaiseFatal(FILEWRITEMODEERROR, cstThisSub)
-       MsfBox &quot;END OF FILE ERROR !!&quot;
+       SF_Exception.RaiseFatal(ENDOFFILEERROR, FileName)
        GoTo Finally
 End Sub                    &apos;   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@ADDRESS>\n"
 "Language-Team: LANGUAGE <EMAIL@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@ADDRESS>\n"
 "Language-Team: LANGUAGE <EMAIL@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 <[email protected]>
AuthorDate: Tue May 4 10:51:41 2021 +0200
Commit:     Noel Grandin <[email protected]>
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 <[email protected]>

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())
_______________________________________________
Libreoffice-commits mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to