aboutsummaryrefslogtreecommitdiffstats
path: root/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp')
-rw-r--r--apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp77
1 files changed, 56 insertions, 21 deletions
diff --git a/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp b/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp
index 1fa4976..f42ffb1 100644
--- a/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp
+++ b/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp
@@ -445,26 +445,26 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
verses->Persist(1);
(*verses) = TOP;
- SWKey *saveKey = (*module);
+ SWKey *saveKey = (SWKey *)(*module);
+ SWKey origKeyValue = *saveKey;
if (!saveKey->Persist())
saveKey = 0;
module->setKey(verses);
SWKey *lastKey = 0;
bool first = true;
+ SWKey *testKey = module->CreateKey();
while (verses->Count() && !module->Error() && newtext.Length() < 40000 ) {
- SWKey *testKey = verses->GetElement();
- VerseKey *element = SWDYNAMIC_CAST(VerseKey, testKey);
if (heading) {
- if (element) {
- if (lastKey != element) {
+ if (SWDYNAMIC_CAST(VerseKey, testKey)) {
+ if (lastKey != verses->GetElement()) {
if (!first)
- newtext += "\\par\\par ";
+ newtext += "{\\par\\par}";
newtext += RTFHeadingPre;
- newtext += element->getRangeText();
+ newtext += verses->GetElement()->getRangeText();
newtext += ":";
newtext += RTFHeadingPost;
- newtext += "\\par ";
+ newtext += "{\\par}";
}
}
else {
@@ -477,12 +477,16 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
int i;
char *start1 = buf;
char *start2 = buf2;
- for (i = 0; i < strlen(buf); i++) {
- if (*start1 == '0')
+ int len = strlen(buf);
+ for (i = 0; i < len; i++) {
+ if (*start1 == '0') {
start1++;
- if (*start2 == '0')
+ }
+ if (*start2 == '0') {
start2++;
- if ((*start1 != '0') && (*start2 != '0')) if ((buf[i] == buf2[i]) || (buf[i] != '0'))
+ }
+ if ((start1[0] != '0') && (start2[0] != '0'))
+// if ((buf[i] == buf2[i]) || (buf[i] != '0'))
break;
}
for (i = 0; i < strlen(start1) && (i < strlen(start2)); i++) {
@@ -497,24 +501,24 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
}
delete [] buf2;
if (!first)
- newtext += "\\par\\par ";
+ newtext += "{\\par\\par}";
newtext += RTFHeadingPre;
- SWKey *key = *module;
+ strcpy(buf, module->KeyText());
// VerseKey locales are not yet UTF8, so don't try to convert them.
- if (!SWDYNAMIC_CAST(VerseKey, key))
+ if (!SWDYNAMIC_CAST(VerseKey, testKey))
filter.ProcessText(buf, 253, *module, module);
newtext = newtext + RTFHeadingPre + buf + RTFHeadingPost + ":\\par ";
newtext += RTFHeadingPost;
- newtext += "\\par ";
+ newtext += "{\\par}";
}
// newtext += RTFHeadingPost;
}
else { // hack to make searchlist entries fit in box better
newtext += "";
}
- lastKey = element;
+ lastKey = verses->GetElement();
first = false;
newtext = newtext + "{";
@@ -529,7 +533,7 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
}
if (*loop == '\n') {
if (!stripNewlines)
- tmptext += "\\par ";
+ tmptext += "{\\par}";
}
else tmptext += *loop;
@@ -540,7 +544,7 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
newtext = newtext + RTFVersePre + tmptext + RTFVersePost;
if (verseNum)
newtext = newtext + RTFVerseMarkPre + IntToStr(VerseKey(module->KeyText()).Verse()) + RTFVerseMarkPost;
- newtext = newtext + "\\par ";
+ newtext = newtext + "{\\par}";
}
else {
if (verseNum)
@@ -551,10 +555,10 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
newtext = newtext + "}";
(*module)++;
}
-
+ delete testKey;
if (saveKey)
module->setKey(saveKey);
- else module->setKey(SWKey("")); //remove our persist key
+ else module->setKey(origKeyValue); //remove our persist key
newtext += RTFTrailer;
@@ -562,6 +566,37 @@ void TRxRichEditX::fillWithVerses(SWModule *module, ListKey *verses, bool headin
RTFStream->WriteBuffer(newtext.c_str(), newtext.Length());
RTFStream->Position = 0;
Lines->LoadFromStream(RTFStream);
+
+ // make links
+ while (true) {
+ int start, len, foundAt, endAt;
+
+ start = (SelLength) ? SelStart + SelLength : 0;
+ len = Text.Length() - start;
+ foundAt = this->SearchText("<a href=\"\">", start, len, TRichSearchTypes());
+ if (foundAt == -1)
+ break;
+
+ SelStart = foundAt;
+ SelLength = 11;
+ this->SelText = "";
+ endAt = this->SearchText("</a>", foundAt, len, TRichSearchTypes());
+ if (foundAt == -1)
+ break;
+ SelStart = endAt;
+ SelLength = 4;
+ this->SelText = "";
+ SelStart = foundAt;
+ SelLength = endAt - foundAt;
+ this->SelAttributes->Link = true;
+ }
+ if (Visible) {
+ this->SetFocus();
+ SelStart = 0;
+ SelLength = 0;
+ SendMessage(Handle, EM_SCROLLCARET, 0, 0);
+ }
+
Repaint();
delete RTFStream;