Julian,
Do you know a solution? problem is very irritating...I can't find the bug...
Janno.
Julian,
Do you know a solution? problem is very irritating...I can't find the bug...
Janno.
Julian,
Restructured the TextObjectLoad event.
To test WPTools I made it very simple:
try cImageSource := Copy( sname, 15, Length( sname ) ); // Image naam, dus bijv: test.jpg cImagePath := fDSBS2.cImagePath + cImageSource; // Path + Image, dus: c:\dcms\cache\site.nl\images\test.jpg {* * Search in the database for the image *} DSBS.qryImages.First; if DSBS.qryImages.Locate( 'Name', cImageSource, [loCaseInSensitive] ) then begin {* * Gevonden! Vul het WPImage object *} (Sender as TWPOImage).FileExtension := ExtractFileExt( cImagePath ); (Sender as TWPOImage).LoadFromFile( cImagePath ); Done := True; end else begin {* * Image niet gevonden! *} ShowMessage( 'Image not found!' ); end; except MessageDlg( 'Someting goes wrong!!', mtError, [mbOk], 0 ); end;
It is very strange. I decided to add a showmessage in the try-except statement in WriteHTMLCode of wpembobj:
[~line 1959] // to execute the OnHTMLCreateImageEvent event again{$IFDEF WPALWAYSCREATEIMAGEEVENT} FHTMLImgName := '';{$ENDIF} except // Better save text than nothing ! showmessage( 'failed to save image!!! exception!' ); end;
Any idea what goes wrong?
After a while of working i get these showmessages().
Statement which explodes:
if soCreateImageEventForAllImages in FMemo.Header.HTMLStoreOptions then
FHTMLImgName := ''
else
fmemo seems to be 'nil' at errortime, and procedure parameters too... s is () and filename =''...
Julian,
First, I'll test this today.
Then, the problem exist with already saved images too.. It''s not only with new images you want to save to the html-page..
My LoadStreamEvent code is as follows:
procedure TfSiteAlgemeen.WPRichText1TextObjectLoadStreamEvent( Sender: TObject; const sname: String; State: TWPOCurrState; var Done: Boolean);var cImage: String; MyFormat: Word; AData: Cardinal; APalette: HPALETTE; Bitm: TBitmap; cActiveImage: String; cImageKaal : String; // kale imagenaam, dus bijv 'as400' ipv '/files/images/as400.gif' I: Integer; TempImg: TImage; bImgFound: Boolean;begin try cImageKaal := Copy( sname, 15, Length( sname ) ); // kale imagenaam, 'add' bijv. cImage := fDSBS2.cImagePath + Copy( sname, 15, Length( sname ) ); // full local path naar image *including* extension // check database DSBS.qryImages.First; DSBS.qryImages.Locate( 'Name', cImageKaal, [loPartialKey, loCaseInSensitive] ); // check of hij wel *EXACT* dezelfde naam heeft als wat ik nodig heb. cActiveImage := DSBS.qryImages.FieldByName( 'Name' ).asString; if cActiveImage = cImageKaal then begin bImgFound := True; end else begin bImgFound := False; end; if bImgFound then begin // yes! hij is in de db gevonden // load image in a TImage try TempImg := TImage.Create( WPRichText1 ); TempImg.Picture.LoadFromFile( cImage ); except try TempImg := TImage.Create( WPRichText1 ); TempImg.Stretch := True; TempImg.Picture.Assign( fDSBS2.Image1.Picture.Graphic ); // error image, red cross finally // [..] end; end; end else begin // not found try TempImg := TImage.Create( WPRichText1 ); TempImg.Stretch := True; TempImg.Picture.Assign( fDSBS2.Image1.Picture.Graphic ); // error image, red cross finally end; end; try (Sender as TWPOImage).Picture.Assign( TempImg.Picture ); except end;// (Sender as TWPOImage).ObjName := DSBS.qryImages.FieldByName( 'ImgID' ).asString;// showmessage('senderojname: '+ (Sender as TWPOImage).ObjName); Done := True;// TempImg.Free; except end;
Normally users insert code as follows:
bObjRuled := False;
//1. Create a copy in our image directory
imgpath := fDSBS2.cImagePath;
imgname := DSBS.qryImages.FieldByName( 'name' ).asString;
ext := Copy( imgname, Length( imgName ) - 2, Length( imgName ) );
if LowerCase(ext) = 'jpg' then begin
obj := TWPOJpgImage.Create( WPRichText1 ); //JZ - create JPEG Object !
bObjRuled := True;
end;
if LowerCase(ext) = 'gif' then begin
obj := TWPOGifImage.Create( WPRichText1 );
bObjRuled := True;
end;
if bObjRuled then begin
try
// We load at once
obj.LoadFromFile( imgpath + imgname );
except
TmpImg := TImage.Create( WPRichText1 );
TmpImg.Stretch := true;
TmpImg.Picture.Assign( fDSBS2.Image1.Picture.Graphic );
TmpImg.Height := DSBS.qryImages.FieldByName( 'Height' ).AsInteger;
TmpImg.Width := DSBS.qryImages.FieldByName( 'Width' ).AsInteger;
obj.Assign( TmpImg.Picture.Graphic );
TmpImg.Free;
end;
WPRichText1.Tag := 1;
// andere props
obj.StreamName := '/files/images/' + imgname;
WPRichText1.InputString(#13+#13);
WPRichText1.CPMoveBack;
WPRichText1.TextObjects.Insert(obj); // poot um er maar in
WPRichText1.CPMoveNext;WPRichText1.CPMoveNext;
end else begin
MessageD( 'Cannot load file, invalid format! ', mtError, [mbOK], 0 );
end;
end;
frmImageSubmit.Free;
Alles anzeigen
Hey Julian,
Our customers are complaining about WPTools v4.22b. It loses (forget to save) HTML-imageobjects when writing html-page (wpxmlwriter).
So i just test it out. And they're right. I create an HTML-page. Put some text on it, insert two JPG images and save the page as HTML.
First time it's okay, but after a while of testing, suddenly images are not any more saved...!
You can imagine... Customers creating a photo gallery page on their company site.. just inserting fifth image, save, and lose (all | some of) their imageobjects...
Some more information:
* It doesn't make sens if you have JPG/GIF images inserted. Tested only JPG / GIF and combinations.
* It's accidently and irritating.
* It happens with both resized and not resized images.
* It doesn't make sense if page is having tables / links or not.. I got it with the simpliest pages too...
* Sometimes random(x) of x images are saved.
* I have already installed new wpxmlint422b patch. this doesn't make any sense...
I've reached end of my mind with this problem now...
Thanks,
Janno
Janno de Wit
DNA services B.V.
Julian,
Searched for a while in WPXMLFile.pas and fixed the solution.
Problem:
You save the column-width like <TD style="width:90%">. When wptools load the page it seems that "width:90%" isn't parsed.
But wptools will parse <TD WIDTH="90%">!
Thus, I inserted at line ~795 of WPXMLFile.pas:
--
EXTRACSSStyle := 'width:' + FormatFloat('0', (save_par^.celldef^.CWidthPC / 255) * 100) + '%;';
// -JDW @ 06/05 Parameter toegevoegd omdat style="width:50%;" niet goed ingelezen wordt.
FParams.Add( 'WIDTH="' + FormatFloat('0', (save_par^.celldef^.CWidthPC / 255) * 100) + '%"' );
if not (blEnabled in save_par^.border.LineType) then
------
to save the width again in <TD>.
Thanks.
Janno.
Julian,
Yesterday upgraded WPTools to v4.22b. This solves many problems (suddenly disappearing imageobjects, etc). But there are yet some small problems:
- Saving of the Table Border is not done correctly, see my other suggestion / post @ My Table Post. Border-width Points are calculated incorrect.
- Reading the Cell Width is not done correctly (since 4.22(b)). The Cell width is written correctly, but in the Reading routines it's not restored, so a table width col1=10% and col2=90% will be read in wptools as col1=50% and col2=50%.
Many thanks for solving this small problems.
Janno de Wit.
anyone an idea?
have you any idea Julian?
Seems to be line 965 of wpcssint?
To save a page I'm using .AsString. Is this okay?
Hi Julian,
I created an html-page with v4.11d. The result is as follows:
<html><head><meta name="Generator" content="WPTools V4.0 HTML/CSS Export"/>
<style type="text/css"><!--
p{display:block;font-family:"Verdana";font-size:10pt;color:black;margin:0.00in;text-align:center;}
LI{display:list-item;font-family:"Verdana";font-size:10pt;color:black;margin-top:0.00in;margin-bottom:0.00in;text-align:center;}
td{display:block;font-family:"Verdana";font-size:0pt;color:black;margin-left:0.00in;margin-right:0.00in;text-align:left;}
--></style>
</head><BODY><p class="p"><SPAN style="font-family:'Verdana';font-size:14pt;"><B>Situatie aangemelde deelnemers</B></SPAN></p>
<p class="p"><SPAN style="font-family:'Verdana';font-size:14pt;"><B>per </B></SPAN><SPAN style="font-family:'Verdana';font-size:14pt;color:red;">22</SPAN><SPAN style="font-family:'Verdana';font-size:14pt;"><B> maart 2004</B></SPAN><SPAN style="font-family:'Verdana';"> </SPAN></p>
<ul style="padding:0px;margin:0 .25in;"><li class="p" style="background-color:white;"><SPAN style="font-family:'Verdana';">Company</SPAN></li>
When I load this page in WPTools v4.22 everything is left-aligned.
What bug can this be?
And the second problem:
The table i created in the previous topic is after saving some times written to HTML with the following style:
border-width:15pt;
This is a very fat border ;-) Can you fix it?
Thanks,
Janno.
border-width:15pt;
[two minutes later:]
It's now saved as having a 255pt border:
<table width="100%" style="border:1px solid black;border-collapse:collapse;width:100%;margin-left:0px;margin-right:0.00in"><tr><td class="p" VALIGN="top" style="border-style:solid;border-width:255pt;background-color:white;padding:2pt;width:60%;"
It seems I cannot save the page again. Any new save-attempts did not save anything...
Thanks Julian, this fixes my problem :-)
Hi Julian,
I've got a suggestion / bug for v4.22a:
WPtools is currently set:
* Zooming = 100
* Pagelayout = wplayNormal
When I create a table of say 2 rows and 2 columns, the bottom-line and rightline is not displayed. When i save the html-code it is perfectly saved. I can only not see the border in wptools!
Here is a screenshot:
http://www.atlantux.net/wptools/tablebordernotvisible.jpg
Many thanks,
Janno.
Have you any idea where to find it Julian ?
It is not the last character of a hyperlink, but the last character of a style is missed too...
thus: <b>test</b> becomes in wptools:
[fsBold]tes[/fsBold]
Julian,
I've got a problem with v4.22a (just downloaded)
When i read an html page with the WPRichText the last Character the link is skipped... And the space before the link is not inserted in the code.
Thus:
this is an <a href="test.html">hyperlink</a>
Becomes after reading in wptools:
this is an[afshyperlink]hyperlin[/afshyperlink]
What problem can this be?
Many thanks,
Janno
Yes, you're right. I suggest that since v4.20 working with tables is not very happy anymore. This worked okay in 4.18
Julian,
When I do a list with numbering in an HTML-page. At my WPTools I see:
And when I show the page in a web browser, it becomes:
You save before the <li> tag an <ol style="list-style:upper-roman;">-tag.
This is wrong for numbering, it should be "decimal", which is the default of IE..
Can you fix this?
Thanks.
Janno.
Julian,
There are stille problems with v4.21 html-handling.
Next one:
I have a html-file with a table. This table has borders enabled.
The first time i save the file. It's written as follows:
(border-collapse and border:1px solid black is appended by me).
<table width="100%" style="border:1px solid black;border-collapse:collapse;padding:1px;margin-left:0.00in"><tr><td class="p" VALIGN="top" width="7%;" style="border-style:solid;border-width:1px;background-color:white;width:7%;border-width:1px;"><SPAN style="font-size:10pt;"> </SPAN></td>
The second time i save the file, it is saved as:
<table width="100%" style="border:1px solid black;border-collapse:collapse;padding:1px;margin-left:0.00in">
<tr>
<td class="td" VALIGN="top" width="50%;" style="border-style:solid;border-width:0pt;background-color:white;width:50%;">
<SPAN style="font-size:10pt;">test</SPAN></td>
You see wptools is saving the cellborder not any more as 'border-width:1px' but as 'border-width:0pt;'. This is wrong. But *where* is it going wrong?
Thanks for your reply,
Janno.
Hi Julian,
Found the following:
Writer does not save <td WIDTH=XX%>, but saves the column-width in STYLE="width:XX%".
Reader only reads <td WIDTH=XX%>
Okay, but now the following problem:
FMemo.TextTables.GetLeftRight(FMemo.GetParObjectTable(save_par).TableTag, l, r); n := FMemo.Header.PageWidth - FMemo.Header.LeftMargin - FMemo.Header.RightMargin; str := FormatFloat('0', ((n - (l + r)) / n) * 100); // <= ALWAYS 100?? c := DecimalSeparator; DecimalSeparator := '.'; [..] FParams.Add('width=' + str + '%');
str = always 100. So always "100%" is now the str-result??
So i searched for another problem: line ~796
EXTRACSSStyle := 'width:' + FormatFloat('0', (save_par^.celldef^.CWidthPC / 255) * 100) + '%;';
// jdw
if (Pos('width:', EXTRACSSStyle) > 0) then
FParams.Add( StringReplace(EXTRACSSStyle, ':', '=', []) );
// jdw
Last 2 lines of code is to save the cell-width?
Maybe not as tidy as it should, can you fix it?
Janno.
Hi Julian,
This is not the solution !? This is a change in WPXMLWriter. The problem is not the writer, but seems to be the xml-reader!
The output of Wpxmlwriter is like this:
<table width="100%" style="padding:1px;margin-left:0.00in">
<tr>
<td style="width:7%;border:0px;">
You see the cell-width is correctly saved. But the reader does not read it correctly...
Regards,
Janno.
Hi Julian,
WPTools v4.21 with WPXMLFILE.pas is currently not loading the tablecell-width correctly. When you drag the cell-border to, say, 20% and you save the HTML file. The page is saved correct.
But, when you reopen the page the cell-width is read incorrectly.
Can you reproduce & fix this problem?
Regards,
Janno de Wit