Jump to content
PeterPanettone

GExperts SourceExport problem

Recommended Posts

I guess you mean the squares on the left hand border? (You should have said so, because i just starred at this picture for several minutes before i noticed them.) Everything else looks fine to me.

Edited by dummzeuch

Share this post


Link to post
2 hours ago, dummzeuch said:

I guess you mean the squares on the left hand border? (You should have said so, because i just starred at this picture for several minutes before i noticed them.) Everything else looks fine to me.

Yes. What are the squares doing there?

Share this post


Link to post

My guess would be that these are additional line feed characters that word can't handle. But for now that's just a guess. Please file a bug report and include all files you used to create these screenshots.

Share this post


Link to post

I just tried to reproduce this, but I could not. The RTF-code saved to a file looks fine to me and pasting into Wordpad and Libre Office Writer also works as expected. So this might be a MS Word specific issue. I don't own any MS Word license that I could use for the test.

 

I tried Delphi 2007 and 10.3 since you did not mention your version.

 

Does anybody know of a tool that can display RTF clipboard contents as text (I only found some that strip RTF formatting from the text) or do I have to write one myself?

 

@PeterPanettone what about the bug report? Maybe it's something in your file(s) that causes the problem.

Share this post


Link to post

I've tried it now with a fresh new WinWord document where I pasted the clipboard content. No squares there.

 

Then I retried it with the document where the squares have appeared yesterday. The squares appeared again.

 

So I have to conclude that the problem appears only in a specific WinWord document.

 

I could not find out why.

Share this post


Link to post

I have analyzed what GExperts exports as HTML clipboard format:

Version:0.9
StartHTML:0000000105
EndHTML:0000002128
StartFragment:0000001413
EndFragment:0000002112
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fragment of MainForm.pas</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="SynEdit HTML exporter" />
<style type="text/css">
<!--
body { color: #000000; background-color: #FFFFFF; }
.pas1-assembler { background-color: #FFFFFF; color: #000000; }
.pas1-character { background-color: #FFFFFF; color: #0000FF; }
.pas1-comment { background-color: #FFFFFF; color: #008000; font-style: italic; }
.pas1-float { background-color: #FFFFFF; color: #0000FF; }
.pas1-hexadecimal { background-color: #FFFFFF; color: #0000FF; }
.pas1-identifier { background-color: #FFFFFF; color: #000000; }
.pas1-number { background-color: #FFFFFF; color: #0000FF; }
.pas1-preprocessor { background-color: #FFFFFF; color: #008000; font-style: italic; }
.pas1-reservedword { background-color: #FFFFFF; color: #000080; font-weight: bold; }
.pas1-space { background-color: #FFFFFF; color: #000000; }
.pas1-string { background-color: #FFFFFF; color: #0000FF; }
.pas1-symbol { background-color: #FFFFFF; color: #000000; }
-->
</style>
</head>
<body>
<!--StartFragment--><pre><code><span class="pas1-reservedword">function</span><span class="pas1-space"> PAIsWindowMinimized(h: HWND): Boolean;
</span><span class="pas1-comment">// Detects whether a window is minimized or not
</span><span class="pas1-reservedword">var
</span><span class="pas1-space">  wp: Winapi.Windows.WINDOWPLACEMENT;
</span><span class="pas1-reservedword">begin
</span><span class="pas1-space">  wp.length := SizeOf(Winapi.Windows.WINDOWPLACEMENT);
  Winapi.Windows.GetWindowPlacement(h, @wp);
  Result := wp.showCmd = Winapi.Windows.SW_SHOWMINIMIZED;
</span><span class="pas1-reservedword">end</span><span class="pas1-symbol">;

</span></code></pre><!--EndFragment--></body>
</html>*

 

This is what CnWizards image.png.23b1b4236580995fae08791627221cfd.png exports as HTML format:

Version:1.0
StartHTML:000000176
EndHTML:000003298
StartFragment:000001389
EndFragment:000003263
StartSelection:000001389
EndSelection:000003263
SourceURL:http://www.cnpack.org/
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="CnPack Source2Html Wizard (http://www.cnpack.org)">
<style type="text/css">
<!--
body { font-family: "Courier New"; font-size: 11pt;color: #000000 }

.u0 { font-family: "Courier New"; font-size: 11pt;color: #000000 }
.u1 { font-family: "Courier New"; font-size: 11pt; font-style: italic;color: #008000 }
.u2 { font-family: "Courier New"; font-size: 11pt;color: #0000FF }
.u3 { font-family: "Courier New"; font-size: 11pt;color: #008080 }
.u4 { font-family: "Courier New"; font-size: 11pt;color: #000000 }
.u5 { font-family: "Courier New"; font-size: 11pt; font-weight: bold;color: #000080 }
.u6 { font-family: "Courier New"; font-size: 11pt;color: #FF0000 }
.u7 { font-family: "Courier New"; font-size: 11pt;color: #000000 }
.u8 { font-family: "Courier New"; font-size: 11pt;color: #0000FF }
.u9 { font-family: "Courier New"; font-size: 11pt;color: #000000 }
.u10 { font-family: "Courier New"; font-size: 11pt;color: #0000FF }
-->
</style> 
</head>
<body bgcolor="#FFFFFF">
<!--StartFragment--><span class="u5">function</span>&nbsp;<span class="u4">PAIsWindowMinimized</span><span class="u9">(</span><span class="u4">h</span><span class="u9">:</span>&nbsp;<span class="u4">HWND</span><span class="u9">):</span>&nbsp;<span class="u4">Boolean</span><span class="u9">;</span>
<br><span class="u9"></span><span class="u1">//&nbsp;Detects&nbsp;whether&nbsp;a&nbsp;window&nbsp;is&nbsp;minimized&nbsp;or&nbsp;not</span>
<br><span class="u5">var</span>
<br>&nbsp;&nbsp;<span class="u4">wp</span><span class="u9">:</span>&nbsp;<span class="u4">Winapi</span><span class="u9">.</span><span class="u4">Windows</span><span class="u9">.</span><span class="u4">WINDOWPLACEMENT</span><span class="u9">;</span>
<br><span class="u5">begin</span>
<br>&nbsp;&nbsp;<span class="u4">wp</span><span class="u9">.</span><span class="u4">length</span>&nbsp;<span class="u9">:=</span>&nbsp;<span class="u4">SizeOf</span><span class="u9">(</span><span class="u4">Winapi</span><span class="u9">.</span><span class="u4">Windows</span><span class="u9">.</span><span class="u4">WINDOWPLACEMENT</span><span class="u9">);</span>
<br>&nbsp;&nbsp;<span class="u4">Winapi</span><span class="u9">.</span><span class="u4">Windows</span><span class="u9">.</span><span class="u4">GetWindowPlacement</span><span class="u9">(</span><span class="u4">h</span><span class="u9">,</span>&nbsp;<span class="u9">@</span><span class="u4">wp</span><span class="u9">);</span>
<br>&nbsp;&nbsp;<span class="u4">Result</span>&nbsp;<span class="u9">:=</span>&nbsp;<span class="u4">wp</span><span class="u9">.</span><span class="u4">showCmd</span>&nbsp;<span class="u9">=</span>&nbsp;<span class="u4">Winapi</span><span class="u9">.</span><span class="u4">Windows</span><span class="u9">.</span><span class="u4">SW_SHOWMINIMIZED</span><span class="u9">;</span>
<br><span class="u5">end</span><span class="u9">;</span>
<!--EndFragment--></body>
</html>
*

 

BTW, the fragment exported by CNWizards does not create the squares in the faulty WinWord document.

Edited by PeterPanettone

Share this post


Link to post

I have just updated SynEdit to the latest version from GitHub. Since both, RTF and HTML-Snippets are generated using the functionality in SynEdit, this may solve the problem.

 

But as I said: I haven't got any Winword license to test this.

 

Could you please compile a new dll with the current sources and check?

Share this post


Link to post
8 minutes ago, dummzeuch said:

Could you please compile a new dll with the current sources and check?

Yes, I will test it. Thank you very much!

Share this post


Link to post

Test results:

 

Nothing seems to have changed. This means that pasting in the faulty WinWord document still shows the squares at line starts. In a normal new WinWord document, there is no problem, the fragment looks as desired with the correct syntax highlighting.

 

Here is the HTML exported by GExperts:

 

Version:0.9
StartHTML:0000000105
EndHTML:0000002128
StartFragment:0000001413
EndFragment:0000002112
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Fragment of MainForm.pas</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="SynEdit HTML exporter" />
<style type="text/css">
<!--
body { color: #000000; background-color: #FFFFFF; }
.pas1-assembler { background-color: #FFFFFF; color: #000000; }
.pas1-character { background-color: #FFFFFF; color: #0000FF; }
.pas1-comment { background-color: #FFFFFF; color: #008000; font-style: italic; }
.pas1-float { background-color: #FFFFFF; color: #0000FF; }
.pas1-hexadecimal { background-color: #FFFFFF; color: #0000FF; }
.pas1-identifier { background-color: #FFFFFF; color: #000000; }
.pas1-number { background-color: #FFFFFF; color: #0000FF; }
.pas1-preprocessor { background-color: #FFFFFF; color: #008000; font-style: italic; }
.pas1-reservedword { background-color: #FFFFFF; color: #000080; font-weight: bold; }
.pas1-space { background-color: #FFFFFF; color: #000000; }
.pas1-string { background-color: #FFFFFF; color: #0000FF; }
.pas1-symbol { background-color: #FFFFFF; color: #000000; }
-->
</style>
</head>
<body>
<!--StartFragment--><pre><code><span class="pas1-reservedword">function</span><span class="pas1-space"> PAIsWindowMinimized(h: HWND): Boolean;
</span><span class="pas1-comment">// Detects whether a window is minimized or not
</span><span class="pas1-reservedword">var
</span><span class="pas1-space">  wp: Winapi.Windows.WINDOWPLACEMENT;
</span><span class="pas1-reservedword">begin
</span><span class="pas1-space">  wp.length := SizeOf(Winapi.Windows.WINDOWPLACEMENT);
  Winapi.Windows.GetWindowPlacement(h, @wp);
  Result := wp.showCmd = Winapi.Windows.SW_SHOWMINIMIZED;
</span><span class="pas1-reservedword">end</span><span class="pas1-symbol">;

</span></code></pre><!--EndFragment--></body>
</html>

 

Share this post


Link to post

BTW, I've found absolutely no use for the "HTML fragment text" export option:

 

image.png.c6586edb50b82a8649332cb2586f7819.png

 

... since this option copies a very simplified HTML text to the clipboard which seems to be useless:

 

<pre>
<code><span style="font: 10pt Courier New;"><span class="pas1-reservedword">function</span><span class="pas1-space"> PAIsWindowMinimized(h: HWND): Boolean;
</span><span class="pas1-comment">// Detects whether a window is minimized or not
</span><span class="pas1-reservedword">var
</span><span class="pas1-space">  wp: Winapi.Windows.WINDOWPLACEMENT;
</span><span class="pas1-reservedword">begin
</span><span class="pas1-space">  wp.length := SizeOf(Winapi.Windows.WINDOWPLACEMENT);
  Winapi.Windows.GetWindowPlacement(h, @wp);
  Result := wp.showCmd = Winapi.Windows.SW_SHOWMINIMIZED;
</span><span class="pas1-reservedword">end</span><span class="pas1-symbol">;

</span></span>
</code></pre>

 

Share this post


Link to post

This seems to be missing the CSS for the various span elements. It's possible that this was meant to copy multiple code fragments into the same document which already has got the CSS definitions. But I don't really know, I have never used or looked at this functionality before.

Share this post


Link to post

BTW, I've found the Fragment prefix useless:

 

Version:0.9
StartHTML:0000000105
EndHTML:0000002128
StartFragment:0000001413
EndFragment:0000002112

This becomes clear when you try to paste the HTML from the clipboard clip exported by GExperts into a Thunderbird e-mail with Insert/HTML:

 

image.thumb.png.a462f0f99c97940d8a002cf2a077fb7f.png

 

In this case, you should omit the first five lines shown above.

 

Despite many experiments I made, I have not found an easy and satisfactory way to export source code with correct syntax highlighting to a Thunderbird e-mail. So I will either try to correct the GExperts expert or to create my own solution, where I tend to the latter.

 

Share this post


Link to post
7 minutes ago, PeterPanettone said:

BTW, I've found the Fragment prefix useless:


Version:0.9
StartHTML:0000000105
EndHTML:0000002128
StartFragment:0000001413
EndFragment:0000002112

 

This is something defined by Microsoft:

 

https://docs.microsoft.com/en-us/windows/win32/dataxchg/html-clipboard-format

 

When I paste such a fragment into Notepad++ (or the standard Notepad) I don't get these prefixes. So I guess it's Thunderbird which does not know how to handle it.

Edited by dummzeuch

Share this post


Link to post

BTW, in the file \gexperts-code-r2671-trunk\Projects\DelphiXx103\GExpertsRS103_version.ini there is this typo:

 

InternalName=GExperts for Delphi 10.3 Tokyo

 

Shouldn't it be "Rio"?

Share this post


Link to post
1 minute ago, PeterPanettone said:

BTW, in the file \gexperts-code-r2671-trunk\Projects\DelphiXx103\GExpertsRS103_version.ini there is this typo:

 

InternalName=GExperts for Delphi 10.3 Tokyo

 

Shouldn't it be "Rio"?

Ouch, I fixed the version number but not the name.

Share this post


Link to post

Copying as "Formatted text/RTF/HTML" does not create an html fragment but a document complete with CSS. Have you tried that? Of course it depends which of the three formats the receiving application inserts.

 

OK, it won't work either. Thunderbird in that case simply inserts plain text. 😞

Edited by dummzeuch

Share this post


Link to post

My version of Thunderbird (52.9.1) doesn't insert the prefix for a HTML fragment, but it shows the code as HTML code (the same goes for RTF fragment) No formatted text at all. I'll update and check the latest version too

Share this post


Link to post

It's also interesting: If I save the fragment from GExperts to a RTF file and then open it in WinWord, then it looks correct. But when I copy that from WinWord and paste it into a Thunderbird e-mail I get lines as paragraphs:

 

image.thumb.png.effb8842a3bc9d56a2ae842364a00cdb.png

 

This means that the saved RTF file lacks paragraph information (or Thunderbird is not able to transform paragraphs to lines).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×