[sword-cvs] sword/apps/windoze/CBuilder5/BibleCS AboutBoxfrm.dfm,1.54,1.55 RxRichEditX.cpp,1.48,1.49 RxRichEditX.h,1.18,1.19 SplashPage.dfm,1.4,1.5 paraldisp.cpp,1.5,1.6 sword.bpr,1.122,1.123 sword.res,1.109,1.110

sword@www.crosswire.org sword@www.crosswire.org
Wed, 6 Aug 2003 03:34:40 -0700


Update of /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS
In directory www:/tmp/cvs-serv11696/apps/windoze/CBuilder5/BibleCS

Modified Files:
	AboutBoxfrm.dfm RxRichEditX.cpp RxRichEditX.h SplashPage.dfm 
	paraldisp.cpp sword.bpr sword.res 
Log Message:
added figure support

Index: AboutBoxfrm.dfm
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/AboutBoxfrm.dfm,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- AboutBoxfrm.dfm	16 Jul 2003 02:22:31 -0000	1.54
+++ AboutBoxfrm.dfm	6 Aug 2003 10:34:36 -0000	1.55
@@ -1,6 +1,6 @@
 object AboutBox: TAboutBox
-  Left = 290
-  Top = 112
+  Left = 508
+  Top = 196
   BorderStyle = bsDialog
   Caption = 'About The SWORD Project'
   ClientHeight = 508
@@ -103,7 +103,7 @@
       Width = 213
       Height = 21
       AutoSize = False
-      Caption = 'v1.5.6pre8'
+      Caption = 'v1.5.6rc1'
       IsControl = True
     end
     object Copyright: TLabel

Index: RxRichEditX.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/RxRichEditX.cpp,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- RxRichEditX.cpp	5 Jul 2003 01:16:46 -0000	1.48
+++ RxRichEditX.cpp	6 Aug 2003 10:34:36 -0000	1.49
@@ -11,6 +11,7 @@
 #include "mainfrm.h"
 #include <localemgr.h>
 #include <unicodertf.h>
+#include <utilxml.h>
 
 char TRxRichEditX::platformID = 0;
 
@@ -439,6 +440,7 @@
 	Lines->LoadFromStream(RTFStream);
 
 	makeLinks();
+	makeImages();
 	
 	if (Visible) {
 		TComponent *owner = this->Owner;
@@ -992,6 +994,7 @@
 	}
 }
 
+
 void TRxRichEditX::clearHTMLTags()
 {
 	while (true) {
@@ -1019,3 +1022,274 @@
 	SelLength = 0;
 }
 
+
+void TRxRichEditX::makeImages() {
+	while (true) {
+		int start, len, foundAt, endAt;
+
+		start = (SelLength) ? SelStart + SelLength : 0;
+		len = Text.Length() - start;
+		foundAt = this->SearchText("<figure src=\"", start, len, TRichSearchTypes());
+		if (foundAt == -1)
+			break;
+
+		endAt = this->SearchText("\" />", foundAt, len, TRichSearchTypes());
+		if (foundAt == -1)
+			break;
+		SelStart = foundAt;
+		SelLength = (endAt - foundAt)+4;
+		XMLTag tag(this->SelText.c_str());
+		SelText = "";
+		insertImage(tag.getAttribute("src"));		
+	}
+}
+
+
+void TRxRichEditX::insertImage(const char *filePath) {
+//static char *tmp = "D:/Program Files/Borland/Borland Shared/Images/Buttons/alarm.bmp";
+//filePath=tmp;
+	TImage *image = new TImage(this);
+	TJPEGImage *ji = new TJPEGImage();
+	Graphics::TBitmap *bitmap = new Graphics::TBitmap();
+	try {
+	int len = strlen(filePath);
+	if ((len > 4) && (!stricmp(filePath+(len-4), ".jpg"))) {
+//		ji->LoadFromFile(filePath);
+
+
+
+	TFileStream* imageFile;
+	imageFile = new TFileStream(filePath,fmOpenRead|fmShareCompat);
+	ji->LoadFromStream(imageFile);		// load the jpeg from the disk file stream
+	bitmap->Assign(ji);
+	image->Picture->Assign(bitmap);
+	delete imageFile;
+
+//		image->Width = ji->Width;
+//		image->Height = ji->Height;
+		image->Canvas->Draw(0, 0, ji);
+//		image->Picture->Bitmap->Assign(ji);
+	}
+	else	image->Picture->LoadFromFile(filePath);
+	
+	insertRTF(bitmapToRTF(image->Picture->Bitmap));
+	}
+	catch (...){}
+	delete ji;
+	delete image;
+	delete bitmap;
+}
+
+
+// EditStreamInCallback callback function
+DWORD __stdcall editStreamInCallBack(unsigned long dwCookie, unsigned char *pbBuff, long cb, long *pcb) {
+  unsigned long dataAvail;
+  TStream *stream = (TStream *)dwCookie;
+  dataAvail = stream->Size - stream->Position;
+  unsigned long retVal = 0;
+    if (dataAvail <= cb) {
+	 *pcb = stream->Read(pbBuff, dataAvail);
+	 if (*pcb != dataAvail)
+	   retVal = E_FAIL;
+    }
+    else {
+	 *pcb = stream->Read(pbBuff, cb);
+	 if (*pcb != cb)
+	   retVal = E_FAIL;
+    }
+    return retVal;
+}
+
+
+// Insert Stream into RichEdit
+void TRxRichEditX::insertRTF(const char *rtf) {
+TStringStream *ss = new TStringStream(rtf);
+
+  try {
+    EDITSTREAM editStream;
+    editStream.dwCookie = (unsigned long)ss;
+    editStream.dwError = 0;
+    editStream.pfnCallback = editStreamInCallBack;
+    Perform(EM_STREAMIN, SF_RTF | SFF_SELECTION, (int)&editStream);
+  }
+  catch (...) {}
+  delete ss;
+}
+
+
+/*
+// Example to insert image from Image1 into RxRichEdit1
+procedure TForm1.Button1Click(Sender: TObject);
+var
+  SS: TStringStream;
+  BMP: TBitmap;
+begin
+  BMP := TBitmap.Create;
+  BMP := Image1.Picture.Bitmap;
+  SS  := TStringStream.Create(BitmapToRTF(BMP));
+  try
+    PutRTFSelection(RxRichEdit1, SS);
+  finally
+    SS.Free;
+  end;
+end;
+*/
+
+
+
+
+// Convert Bitmap to RTF Code
+SWBuf TRxRichEditX::bitmapToRTF(Graphics::TBitmap *pict) {
+	unsigned char *bi, *bb;
+	SWBuf rtf;
+	unsigned int bis, bbs;
+	char achar[10];
+	char *hexpict;
+	int i;
+	GetDIBSizes(pict->Handle, bis, bbs);
+	bi = new char [bis + 1];
+	bb = new char [bbs + 1];
+	GetDIB(pict->Handle, pict->Palette, bi, bb);
+	rtf = "{\\rtf1 {\\pict\\dibitmap ";
+	hexpict = new char[((bbs + bis) * 2)+1];
+	i = 0;
+	for (int x = 0; x < bis; x++) {
+		sprintf(achar, "%02x", (unsigned int)bi[x]);
+		hexpict[i++] = achar[0];
+		hexpict[i++] = achar[1];
+	}
+	
+	for (int x = 0; x < bbs; x++) {
+		sprintf(achar, "%02x", (unsigned int)bb[x]);
+		hexpict[i++] = achar[0];
+		hexpict[i++] = achar[1];
+	}
+	hexpict[i] = 0;
+	rtf += hexpict;
+	rtf += " }}";
+	delete [] bi;
+	delete [] bb;
+	delete [] hexpict;
+	return rtf;
+}
+
+
+/*
+ uses
+  RichEdit;
+
+// Stream Callback function
+type
+  TEditStreamCallBack = function(dwCookie: Longint; pbBuff: PByte;
+    cb: Longint; var pcb: Longint): DWORD;
+  stdcall;
+
+  TEditStream = record
+    dwCookie: Longint;
+    dwError: Longint;
+    pfnCallback: TEditStreamCallBack;
+  end;
+
+// RichEdit Type
+type
+  TMyRichEdit = TRxRichEdit;
+
+// EditStreamInCallback callback function
+function EditStreamInCallback(dwCookie: Longint; pbBuff: PByte;
+  cb: Longint; var pcb: Longint): DWORD; stdcall;
+  // by P. Below
+var
+  theStream: TStream;
+  dataAvail: LongInt;
+begin
+  theStream := TStream(dwCookie);
+  with theStream do
+  begin
+    dataAvail := Size - Position;
+    Result := 0;
+    if dataAvail <= cb then
+    begin
+	 pcb := read(pbBuff^, dataAvail);
+	 if pcb <> dataAvail then
+	   Result := UINT(E_FAIL);
+    end
+    else
+    begin
+	 pcb := read(pbBuff^, cb);
+	 if pcb <> cb then
+	   Result := UINT(E_FAIL);
+    end;
+  end;
+end;
+
+// Insert Stream into RichEdit
+procedure PutRTFSelection(RichEdit: TMyRichEdit; SourceStream: TStream);
+  // by P. Below
+var
+  EditStream: TEditStream;
+begin
+  with EditStream do
+  begin
+    dwCookie := Longint(SourceStream);
+    dwError := 0;
+    pfnCallback := EditStreamInCallBack;
+  end;
+  RichEdit.Perform(EM_STREAMIN, SF_RTF or SFF_SELECTION, Longint(@EditStream));
+end;
+
+// Convert Bitmap to RTF Code
+function BitmapToRTF(pict: TBitmap): string;
+// by D3k
+var
+  bi, bb, rtf: string;
+  bis, bbs: Cardinal;
+  achar: ShortString;
+  hexpict: string;
+  I: Integer;
+begin
+  GetDIBSizes(pict.Handle, bis, bbs);
+  SetLength(bi, bis);
+  SetLength(bb, bbs);
+  GetDIB(pict.Handle, pict.Palette, PChar(bi)^, PChar(bb)^);
+  rtf := '{\rtf1 {\pict\dibitmap ';
+  SetLength(hexpict, (Length(bb) + Length(bi)) * 2);
+  I := 2;
+  for bis := 1 to Length(bi) do
+  begin
+    achar := Format('%x', [Integer(bi[bis])]);
+    if Length(achar) = 1 then
+	 achar := '0' + achar;
+    hexpict[I - 1] := achar[1];
+    hexpict[I] := achar[2];
+    Inc(I, 2);
+  end;
+  for bbs := 1 to Length(bb) do
+  begin
+    achar := Format('%x', [Integer(bb[bbs])]);
+    if Length(achar) = 1 then
+	 achar := '0' + achar;
+    hexpict[I - 1] := achar[1];
+    hexpict[I] := achar[2];
+    Inc(I, 2);
+  end;
+  rtf := rtf + hexpict + ' }}';
+  Result := rtf;
+end;
+
+
+// Example to insert image from Image1 into RxRichEdit1
+procedure TForm1.Button1Click(Sender: TObject);
+var
+  SS: TStringStream;
+  BMP: TBitmap;
+begin
+  BMP := TBitmap.Create;
+  BMP := Image1.Picture.Bitmap;
+  SS  := TStringStream.Create(BitmapToRTF(BMP));
+  try
+    PutRTFSelection(RxRichEdit1, SS);
+  finally
+    SS.Free;
+  end;
+end;
+*/

Index: RxRichEditX.h
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/RxRichEditX.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- RxRichEditX.h	5 Jul 2003 01:16:46 -0000	1.18
+++ RxRichEditX.h	6 Aug 2003 10:34:36 -0000	1.19
@@ -113,6 +113,10 @@
 	AnsiString type;
 	void recalcAppearance();
 	void makeLinks();
+	void makeImages();
+	void insertImage(const char *filePath);
+	SWBuf bitmapToRTF(Graphics::TBitmap *pict);
+	void insertRTF(const char *rtf);
 	AnsiString getType();
 	static WideString Trim(WideString &src);
 	WideString __fastcall GetText();

Index: SplashPage.dfm
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/SplashPage.dfm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- SplashPage.dfm	15 Jul 2003 22:45:34 -0000	1.4
+++ SplashPage.dfm	6 Aug 2003 10:34:36 -0000	1.5
@@ -25,4938 +25,4938 @@
     Align = alClient
     Picture.Data = {
       07544269746D61709E680200424D9E6802000000000036000000280000005E01
-      000096000000010018000000000068680200230B0000230B0000000000000000
-      0000FDFDFDFCFCFCFAFAFAFDFDFDFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE
-      FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE
-      FEFEFEFEFDFDFDFEFEFEFEFEFEFDFDFDFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE
-      FEFEFEFEFEFEFEFEFDFDFDFEFEFEFEFEFEFDFDFDFEFEFEFDFDFDFEFEFEFEFEFE
-      FEFEFEFAFAFAFBFBFBFEFEFEFDFDFDFDFDFDFAFAFAFCFCFCFBFBFBFEFEFEFEFE
-      FEFBFBFBFBFBFBFAFAFAF9F9F9FAFAFAF8F8F8FBFBFBFBFBFBF8F8F8FAFAFAFB
-      FBFBF9F9F9F4F4F4F4F4F4F9F9F9F9F9F9FAFAFAFBFBFBF8F8F8F8F8F8FCFCFC
[...9827 lines suppressed...]
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      0000000000000000000000000000000000000000000000000000000000000000
+      00000000000000000000}
   end
 end

Index: paraldisp.cpp
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/paraldisp.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- paraldisp.cpp	27 Jun 2003 11:31:41 -0000	1.5
+++ paraldisp.cpp	6 Aug 2003 10:34:36 -0000	1.6
@@ -225,6 +225,7 @@
 				RTFStream->Position = 0;
 				Lines->LoadFromStream(RTFStream);
 				makeLinks();
+				makeImages();
 				versepos =  GetTextLen() - 3;
 			}
 //			newtext = newtext + "}";
@@ -265,6 +266,7 @@
 	Lines->LoadFromStream(RTFStream);
 
 	makeLinks();        
+	makeImages();
 
 	//{ Position control text at current verse }
 	this->SetFocus();

Index: sword.bpr
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/sword.bpr,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- sword.bpr	16 Jul 2003 02:22:31 -0000	1.122
+++ sword.bpr	6 Aug 2003 10:34:36 -0000	1.123
@@ -75,7 +75,7 @@
 MajorVer=1
 MinorVer=5
 Release=5
-Build=62
+Build=68
 Debug=0
 PreRelease=0
 Special=0
@@ -87,13 +87,13 @@
 [Version Info Keys]
 CompanyName=CrossWire Software &amp; Bible Society
 FileDescription=Windows 32bit User Interface to The SWORD Project
-FileVersion=1.5.5.62
+FileVersion=1.5.5.68
 InternalName=biblecs
 LegalCopyright=(c) 2002 CrossWire Bible Society under the terms of the GNU General Public License
 LegalTrademarks=
 OriginalFilename=
 ProductName=The SWORD Project
-ProductVersion=1.5.6pre8
+ProductVersion=1.5.6rc1
 Comments=Seek Him and you will find Him
 
 [HistoryLists\hlIncludePath]

Index: sword.res
===================================================================
RCS file: /usr/local/cvsroot/sword/apps/windoze/CBuilder5/BibleCS/sword.res,v
retrieving revision 1.109
retrieving revision 1.110
diff -u -d -r1.109 -r1.110
Binary files /tmp/cvsDRQ6Qe and /tmp/cvsUGGSYe differ