Recent

Author Topic: Richmemo, insert grid and image, problems under linux  (Read 1260 times)

antoniog

  • New member
  • *
  • Posts: 7
Richmemo, insert grid and image, problems under linux
« on: June 11, 2020, 06:22:55 pm »
Good evening.
I have two procedures for:
- inserting  a grid
- inserting an image
and then saving Richmemo in  DBMemo field of SQLite Table.
The two procedures work perfectly under Window 10x64 but under Linux Mintx64 they do not work.
Can anyone help me make them work even under linux.
Thanks.
Code: Pascal  [Select][+][-]
  1. //**********Insert a grid **************
  2. //**************************************
  3. procedure TCapitolatoF.BitBtn3Click(Sender: TObject);
  4. var
  5.  rig, col, i, f, larghe,LineNo : integer;
  6.  tabella,IntRiga, FinRiga,Riga, c : string;
  7. begin
  8.  RichMemo3.SetFocus;
  9.  c:='';
  10.  rig:= StrtoInt(MaskEdit3.Text);  // number of lines
  11.  col:= StrtoInt(MaskEdit4.Text);  // number of columns
  12.  larghe := round(RichMemo3.Width/col);
  13.  IntRiga := '\trowd\trgaph70\trleft5\trbrdrl\brdrs\brdrw10 \trbrdrt\brdrs\brdrw10 \trbrdrr\brdrs\brdrw10 \trbrdrb\brdrs\brdrw10 \trpaddl70\trpaddr70\trpaddfl3\trpaddfr3';
  14.  Riga := '\clbrdrl\brdrw10\brdrs\clbrdrt\brdrw10\brdrs\clbrdrr\brdrw10\brdrs\clbrdrb\brdrw10\brdrs \cellx';
  15.  for f:= 1 to col  do begin c:=c+'\cell'; end;
  16.  FinRiga := '\pard\intbl\widctlpar' + c + '\row';
  17.  tabella:='';
  18.  for i:= 1 to rig  do
  19.     begin
  20.       tabella:=Tabella+IntRiga;
  21.       for f:= 1 to col  do
  22.          begin
  23.            tabella:=tabella+Riga+IntToStr(Larghe*f*10);
  24.          end;
  25.         tabella:=tabella+FinRiga;
  26.     end;
  27.     tabella:=tabella+'\pard\f18\par\pard '+ #10;
  28.     DBMemo2.Visible:=True;
  29.     Clipboard.AsText := tabella;
  30.     RichMemo3.PasteFromClipboard;
  31.     DBMemo2.Text:=RichMemo3.Rtf;
  32.     DBMemo2.Text:= StringReplace(DBMemo2.Text, '\\','\', [rfReplaceAll]);
  33.     RichMemo3.Rtf:= DBMemo2.Text;
  34.     //DBMemo2.Visible:=False;
  35.     Panel28.Visible:=False;
  36. end;
  37.  

Code: Pascal  [Select][+][-]
  1.  
  2. //**********Insert an image **************
  3. //**************************************
  4.  
  5. procedure TCapitolatoF.BitBtn4Click(Sender: TObject);
  6. var
  7.  mDim, nome : string;
  8. h1 , w1 : integer;
  9. h, w : string;
  10. ARect: TRect;
  11. TmpBmp: TBitmap;
  12. begin
  13.   h:='100';
  14.   w:='100';
  15.    if RadioGroup2.ItemIndex=1 then
  16.      begin
  17.        if Trim(Edit3.Text)<>'' then
  18.         //h:=Trim(Edit1.text); //+'%';
  19.         h:= Trim(Edit3.Text);
  20.        if Trim(Edit4.Text)<>'' then
  21.         w:= Trim(Edit4.Text);
  22.      end else
  23.      begin
  24.        h:='100';
  25.        w:='100';
  26.        //mDim:=' '+ h+' '+w;
  27.        //h1:= 1;
  28.        //w1:= 1;
  29.      end;
  30.      if OpenPictureDialog1.Execute then
  31.       begin
  32.         Image1.Picture.Clear;
  33.         if (OpenPictureDialog1.Files.Count = 1) and (FileExistsUTF8(OpenPictureDialog1.FileName)) then
  34.             begin
  35.               try
  36.                  TmpBmp:= TBitmap.Create;
  37.                  try
  38.                     Image1.Picture.LoadFromFile(OpenPictureDialog1.FileName);
  39.                     h1:= round(Image1.Picture.Height*(strtoint(h)/100));
  40.                     w1:= round(Image1.Picture.Width*(strtoint(w)/100));
  41.                     ARect:= Rect (0,0, w1, h1);
  42.                     TmpBmp.Width := w1;
  43.                     TmpBmp.Height := h1;
  44.                     TmpBmp.Canvas.StretchDraw (ARect, Image1.Picture.Bitmap);
  45.                     Image1.Picture.Bitmap.Assign(TmpBmp);
  46.                     Clipboard.Assign(Image1.Picture.Bitmap);
  47.                     RichMemo3.PasteFromClipboard;
  48.                     RichMemo3.Lines.Add('');
  49.                     DBMemo2.Text:=RichMemo3.Rtf;
  50.                     //csatestomemo.Text:=RichMemo3.Rtf;
  51.                  finally
  52.                     TmpBmp.Free;
  53.                  end;
  54.                 except
  55.                  on E : Exception do showmessage('Errore nella creazione dell''immagine');
  56.             end;
  57.         end;
  58.      end;
  59.    Panel29.Visible:=False;
  60. end;
  61.  
  62.  

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2514
    • havefunsoft.com
Re: Richmemo, insert grid and image, problems under linux
« Reply #1 on: June 11, 2020, 07:29:09 pm »
and I'm afraid it won't work.
RichMemo depends on the underlying widgetset to support tables.
As far as I know there's no such functionality in Gtk2.

In Qt5 it might work. The Qt5 TextEdit seems to support tables.

It should work fine for macOS (with Cocoa used).

So, if Linux with Gtk2 is desired, you might want to try KMemo instead.
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

antoniog

  • New member
  • *
  • Posts: 7
Re: Richmemo, insert grid and image, problems under linux
« Reply #2 on: June 12, 2020, 01:01:18 am »
Skalogryz, thanks for the reply.
Yet I am sure that in a previous version it worked, before inserting the redo function. I remember that after an update of Lazarus,
richmemo, in compiling,  gave an access violation error that was repaired by the programmer, but after this repair, it stopped working correctly.
Working,I don't remember the version of richmemo, I think previous to 1.0 while the version of Lazarus, I think, 1.0.6
I need to find previous working versions to evaluate what to do.
I don't like KMemo.

antoniog

  • New member
  • *
  • Posts: 7
Re: Richmemo, insert grid and image, problems under linux
« Reply #3 on: June 24, 2020, 02:30:38 am »
I tried Kmemo, I tried to insert a table with copy and paste but I got the same result as recall, it does not recognize the tables.

dbannon

  • Hero Member
  • *****
  • Posts: 1149
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Richmemo, insert grid and image, problems under linux
« Reply #4 on: June 24, 2020, 09:03:06 am »
For you to copy and paste a table into KMemo, it will have to come in in  format that KMemo expects, that is RTF.  KMemo will also accept plain text but I don't see how a table would be presented in plain text.

Or are you copying in an image ?

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

antoniog

  • New member
  • *
  • Posts: 7
Re: Richmemo, insert grid and image, problems under linux
« Reply #5 on: June 25, 2020, 01:44:38 am »
dbannon, thanks for the answer.
I have to copy texts including grids and images into a "memo" from libreoffice writer or microsoft word files.
The write or word document includes many articles, I want to copy one article at a time and save it in a sqlite table.
This thing works under Windows but not works under Linux using "RichMemo", Skalogryz advised me, under GTK2, to use TKMemo, I tried, but copying and pasting gives me the same result as for "Richmemo", TKmemo does not recognize the grids.

dbannon

  • Hero Member
  • *****
  • Posts: 1149
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Richmemo, insert grid and image, problems under linux
« Reply #6 on: June 25, 2020, 02:27:54 pm »
Hmm, that does sound a bit challenging I must admit.  TK has another component in there, KGrid, I wonder if that would help you ?  I have not used it at all, I use KMemo.

I have not tried to paste anything other than (marked up) text and images into KMemo.  It does apparently have a table mode, from the wiki -

"advanced table support with full row/cell formatting and even with cell merging support, so even very complex tables created with MS Word can be loaded, saved, viewed and edited in KMemo"

So, I guess that must mean it can be done, the problem must relate to the format you are pasting.  When we copy and paste, the source application lists the formats it can deliver in, the receiving application looks through that list and chooses something it likes. Usually plain text is the fall back when all else fails. So, do you see some plain text content arrive in the KMemo ?

EDIT:  I just tried to paste an Open Office table into a tomboy-ng note (which is basically a KMemo) and the table content copied across cleanly but no sign of a table structure. That says to me it is, in fact, deciding to deal with just the plain text parts of the paste.   

Davo 
« Last Edit: June 25, 2020, 02:43:31 pm by dbannon »
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

antoniog

  • New member
  • *
  • Posts: 7
Re: Richmemo, insert grid and image, problems under linux
« Reply #7 on: June 25, 2020, 03:23:50 pm »
The basic document is in .doc or .docx format, also converted to .rtf
the grid pasted on kmemo loses its structure keeping only the text

dbannon

  • Hero Member
  • *****
  • Posts: 1149
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Richmemo, insert grid and image, problems under linux
« Reply #8 on: June 26, 2020, 08:46:46 am »
I don't think the copy and paste process cares what format the origional document was in, its all about what openoffice decides to paste.

> the grid pasted on kmemo loses its structure keeping only the text

Yep, thats consistent with what I said earlier.

Attached is a very short program I used to debug a copy and paste issue in LCL.  It reports on the clipboard content when you hit refresh (it does not paste, it just tells you what is there).  I just tried it with a table from openoffice and yes, there does seem to be some RTF content.  So, maybe what you need to do is, perhaps, save that rtf content (its a stream so easy to do) and see if the content you are looking for is really there.  If it is, maybe (lots of maybes here) you can extract it from the clipboard stream and do, directly, what you want.

Maybe ...

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

antoniog

  • New member
  • *
  • Posts: 7
Re: Richmemo, insert grid and image, problems under linux
« Reply #9 on: June 26, 2020, 04:43:09 pm »
Davo, thank you for your interest in my problem.
Using your example, nothing is resolved,
in the attached images:
1.png - what I copy to the clipboard
2.png - what I get after the paste
The same thing in Richmemo and KMemo

dbannon

  • Hero Member
  • *****
  • Posts: 1149
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Richmemo, insert grid and image, problems under linux
« Reply #10 on: June 27, 2020, 06:01:22 am »

Using your example, nothing is resolved,
....
Sorry antoniog, perhaps I was not clear. What I am suggesting is that you need to extract the information out of the clipboard yourself, its going to take a bit of coding to do that but it should be possible.

My snippit was nothing more that showing you how you can look at the clipboard contents, you need to do the coding I am afraid !

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018