Skip to content

Commit 74c1265

Browse files
committed
Added wait dialog for export of source text.
1 parent da26426 commit 74c1265

File tree

4 files changed

+54
-14
lines changed

4 files changed

+54
-14
lines changed

source/ExportFunctions.cpp

+28
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,13 @@ void DoExportAsType(enum ExportType exportType)
17901790
{
17911791
case sourceTextExport:
17921792
{
1793+
CWaitDlg waitDlg(gpApp->GetMainFrame());
1794+
// indicate we want the closing the document wait message
1795+
waitDlg.m_nWaitMsgNum = 18; // 18 has _("Please wait while Adapt It exports the source text...")
1796+
waitDlg.Centre();
1797+
waitDlg.Show(TRUE);// On Linux, the dialog frame appears, but the text in it is not displayed (need ShowModal() for that)
1798+
waitDlg.Update();
1799+
17931800
nTextLength = RebuildSourceText(source, pList);
17941801
nTextLength = nTextLength; // avoid gcc warning set but not used warning
17951802

@@ -17417,6 +17424,17 @@ int RebuildSourceText(wxString& source, SPList* pUseThisList)
1741717424
}
1741817425
wxASSERT(pList != NULL);
1741917426

17427+
int nTotal = pList->GetCount();
17428+
wxString msgDisplayed;
17429+
wxString progMsg = _("Rebuilding Source Text - %d of %d Total words and phrases");
17430+
//wxFileName fn(exportName);
17431+
msgDisplayed = progMsg.Format(progMsg, 1, nTotal);
17432+
CStatusBar* pStatusBar = NULL;
17433+
pStatusBar = (CStatusBar*)gpApp->GetMainFrame()->m_pStatusBar;
17434+
pStatusBar->StartProgress(_("Rebuilding Source Text"), msgDisplayed, nTotal);
17435+
int counter = 0;
17436+
17437+
1742017438
// BEW 5Apr23, (legacy commenting...) As we traverse the list of CSourcePhrase
1742117439
// instances, the special things we must be careful of are:
1742217440
// 1. source phrase placeholders (we ignore these, but we don't
@@ -17539,6 +17557,13 @@ int RebuildSourceText(wxString& source, SPList* pUseThisList)
1753917557
}
1754017558
#endif
1754117559

17560+
counter++;
17561+
if (counter % 200 == 0)
17562+
{
17563+
msgDisplayed = progMsg.Format(progMsg, counter, nTotal);
17564+
pStatusBar->UpdateProgress(_("Rebuilding Source Text"), counter, msgDisplayed);
17565+
}
17566+
1754217567
wxASSERT(pSrcPhrase != 0);
1754317568
str.Empty();
1754417569

@@ -17549,6 +17574,7 @@ int RebuildSourceText(wxString& source, SPList* pUseThisList)
1754917574
if (pSrcPhrase->m_nSequNumber > 0)
1755017575
{
1755117576

17577+
1755217578
#if defined(_DEBUG)
1755317579
if (pSrcPhrase->m_nSequNumber == 391)
1755417580
{
@@ -17920,6 +17946,8 @@ int RebuildSourceText(wxString& source, SPList* pUseThisList)
1792017946
} // end of else block, i.e., it's a single word sourcephrase
1792117947
} // end of while (pos_pList != NULL) for scanning whole document's CSourcePhrase instances
1792217948

17949+
pStatusBar->FinishProgress(_("Rebuilding Source Text"));
17950+
1792317951
source.Trim(); // trim the end
1792417952
gpApp->GetDocument()->m_bCurrentlyFiltering = FALSE; // restore default, BEW 28Mar23
1792517953

source/WaitDlg.cpp

+10-6
Original file line numberDiff line numberDiff line change
@@ -146,9 +146,11 @@ void CWaitDlg::InitDialog(wxInitDialogEvent& WXUNUSED(event))
146146
// // IDS_WAIT_FOR_RTF_OUTPUT
147147
// WaitMsg = _("Please wait for Adapt It to output the RTF file. This may take a while...");
148148
// break;
149-
//case 2:
150-
// WaitMsg = _("Please wait while Adapt It opens the document...");
151-
// break;
149+
case 2:
150+
{
151+
WaitMsg = _("Please wait while Adapt It opens the document...");
152+
}
153+
break;
152154
//case 3:
153155
// WaitMsg = _("Please wait while Adapt It processes filter changes...");
154156
// break;
@@ -199,9 +201,11 @@ void CWaitDlg::InitDialog(wxInitDialogEvent& WXUNUSED(event))
199201
//case 17:
200202
// WaitMsg = _("Please wait while the free translation is sent to Paratext...");
201203
// break;
202-
//case 18:
203-
// WaitMsg = _("Please wait while the free translation is sent to Bibledit...");
204-
// break;
204+
case 18:
205+
{
206+
WaitMsg = _("Please wait while Adapt It exports the source text...");
207+
}
208+
break;
205209
//case 19:
206210
// WaitMsg = _("Exporting the translation...");
207211
// break;

source/XML.cpp

+7-2
Original file line numberDiff line numberDiff line change
@@ -997,6 +997,7 @@ bool ParseXML(wxString& path, const wxString& progressTitle, wxUint32 nProgMax,
997997

998998
bOpenOK = file.Open(path,wxFile::read);
999999
}
1000+
wxFileName fn(path);
10001001
if (bOpenOK)
10011002
{
10021003
gpApp->m_owner = NOOWNER; // mrh - initial defaults. If we read the appropriate tags, these will be replaced.
@@ -1022,12 +1023,12 @@ bool ParseXML(wxString& path, const wxString& progressTitle, wxUint32 nProgMax,
10221023
// to avoid exceeding the maximum range for the dialog.
10231024
nTotal = nChunks;
10241025
wxString progMsg = _("Reading File %s - part %d of %d");
1025-
wxFileName fn(path);
1026-
msgDisplayed = progMsg.Format(progMsg,fn.GetFullName().c_str(),nCurrChunk,nTotal);
1026+
//wxFileName fn(path);
10271027
// whm 25Aug11 added nProgMax
10281028
CStatusBar *pStatusBar = (CStatusBar*)gpApp->GetMainFrame()->m_pStatusBar;
10291029
if (!progressTitle.IsEmpty() && nCurrChunk < nProgMax)
10301030
{
1031+
msgDisplayed = progMsg.Format(progMsg, fn.GetFullName().c_str(), nCurrChunk, nTotal);
10311032
pStatusBar->UpdateProgress(progressTitle, nCurrChunk, msgDisplayed);
10321033
}
10331034

@@ -1058,6 +1059,7 @@ bool ParseXML(wxString& path, const wxString& progressTitle, wxUint32 nProgMax,
10581059
// whm 25Aug11 added nProgMax
10591060
if (!progressTitle.IsEmpty() && nCurrChunk < nProgMax)
10601061
{
1062+
msgDisplayed = progMsg.Format(progMsg, fn.GetFullName().c_str(), nCurrChunk, nTotal);
10611063
pStatusBar->UpdateProgress(progressTitle, nCurrChunk, msgDisplayed);
10621064
}
10631065
}
@@ -1191,6 +1193,7 @@ bool ParseXML(wxString& path, const wxString& progressTitle, wxUint32 nProgMax,
11911193
// whm 25Aug11 added nProgMax
11921194
if (!progressTitle.IsEmpty() && nCurrChunk < nProgMax)
11931195
{
1196+
msgDisplayed = progMsg.Format(progMsg, fn.GetFullName().c_str(), nCurrChunk, nTotal);
11941197
pStatusBar->UpdateProgress(progressTitle, nCurrChunk, msgDisplayed);
11951198
}
11961199
}
@@ -1297,6 +1300,7 @@ r: comp = strncmp(pPos,comment,4);
12971300
// whm 25Aug11 added nProgMax
12981301
if (!progressTitle.IsEmpty() && nCurrChunk < nProgMax)
12991302
{
1303+
msgDisplayed = progMsg.Format(progMsg, fn.GetFullName().c_str(), nCurrChunk, nTotal);
13001304
pStatusBar->UpdateProgress(progressTitle, nCurrChunk, msgDisplayed);
13011305
}
13021306
continue; // no more data to transfer
@@ -1340,6 +1344,7 @@ r: comp = strncmp(pPos,comment,4);
13401344
// whm 25Aug11 added nProgMax
13411345
if (!progressTitle.IsEmpty() && nCurrChunk < nProgMax)
13421346
{
1347+
msgDisplayed = progMsg.Format(progMsg, fn.GetFullName().c_str(), nCurrChunk, nTotal);
13431348
pStatusBar->UpdateProgress(progressTitle, nCurrChunk, msgDisplayed);
13441349
}
13451350
}

source/helpers.cpp

+9-6
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@
7979
#include "KbServer.h"
8080
#include "md5_SB.h"
8181
#include "ConsistentChanger.h"
82+
#include "StatusBar.h"
8283

8384
//#if defined (_KBSERVER)
8485
#include <stdio.h>
@@ -3484,7 +3485,7 @@ wxString RemoveMultipleSpaces(wxString& rString)
34843485
// spaces.
34853486
if (rString == wxEmptyString)
34863487
return wxEmptyString;
3487-
3488+
34883489
// Set up a write buffer pDestBuff which is the same size as rString.
34893490
// Then copy characters using pointers from the rString buffer to the atemp buffer (not
34903491
// advancing the pointer for where multiple spaces are adjacent to each other).
@@ -3536,11 +3537,11 @@ wxString RemoveMultipleSpaces(wxString& rString)
35363537
// Copy whatever we are pointing at and then advance
35373538
//debugStr = wxString(pDestBuff, (size_t)(pNew - pDestBuff));
35383539
*pNew++ = *pOld++; // copy chars from pOld buffer to pNew buffer and then advance pointers
3540+
35393541
}
35403542
*pNew = (wxChar)0; // terminate the new buffer string with a null char
35413543
destString = wxString(pDestBuff, (size_t)(pNew - pDestBuff));
35423544

3543-
35443545
// whm 12Jan2024 added routine below to remove all spaces after an EOL and before the
35453546
// of a usfm or unknown marker.
35463547
// Note: Since this block follows the preceding modifications of rString, we will start
@@ -3569,7 +3570,7 @@ wxString RemoveMultipleSpaces(wxString& rString)
35693570
wxStringBuffer pDestBuff2(destString, nLen2 + 1); // pDestBuff is the pointer to the write buffer
35703571
wxChar* pOld2 = pSourceBuffStart2;
35713572
wxChar* pNew2 = pDestBuff2;
3572-
3573+
CAdapt_ItDoc* pDoc = gpApp->GetDocument();
35733574
wxChar spaceCh2 = _T(' ');
35743575
wxChar eolCR2 = _T('\r');
35753576
wxChar eolLF2 = _T('\n');
@@ -3605,10 +3606,12 @@ wxString RemoveMultipleSpaces(wxString& rString)
36053606
itemLen = ParseWhiteSpace(pAux); // this parses past EOL and any following whitespace
36063607
wxString debugWhites = wxString(pAux, itemLen); wxUnusedVar(debugWhites);
36073608
pAux += itemLen; // point past the whites - past EOL(s) and any spaces
3608-
CAdapt_ItDoc* pDoc = gpApp->GetDocument();
3609-
if (pDoc->IsMarker(pAux))
3609+
if (*pAux == _T('\\'))
36103610
{
3611-
bMarkerFollowsSpaceAfterEOL = TRUE;
3611+
if (pDoc->IsMarker(pAux))
3612+
{
3613+
bMarkerFollowsSpaceAfterEOL = TRUE;
3614+
}
36123615
}
36133616
if (bMarkerFollowsSpaceAfterEOL)
36143617
{

0 commit comments

Comments
 (0)