New function OfficeExtractImage

New function OfficeExtractImage

Postby driessen » Sun Apr 26, 2015 4:40 pm

Hello,

Can someone explain me this new function? Or provide us with an example?

Thanks.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: New function OfficeExtractImage

Postby nageswaragunupudi » Mon Apr 27, 2015 3:19 pm

Purpose of this function is to extract thumbnails from MS Office documents (docx,xlsx,pptx) if saved with thumbnails.

I suggest you first go through the disucssion about saving and extraction of thumbnails of office ducuments
viewtopic.php?f=3&t=13602.

If an office document docx, xlsx or pptx is saved with a thumbnail, this function extracts the thumbnail and saves in the same folder.

OfficeExtractImage( "c:\fwh\samples\cust.docx" ) --> "c:\fwh\samples\cust.emf" // empty value in case of failure
OfficeExtractImage( "c:\fwh\samples\cust.xlsx" ) --> "c:\fwh\samples\cust.wmf"
OfficeExtractImage( "c:\fwh\samples\mppt.pptxx" ) --> "c:\fwh\samples\mppt.jpeg"

Second parameter is lReExtract ( default .f. ). When .f., if the function finds an already extracted thumbnail, returns the name of the thumbnail file. When .t., the function re-extracts the thumbnail.

Notes:
1) The document must have been saved with "save thumbnail" option checked while saving.
2) OfficeExtractImage is named similar to IExtractImage interface.

The new class TXImage can display emf/wmf in addition to any image file that the TImage class handles. This is the most suitable viewer to view the thumbnails.

Testing:
You may Select any docx, which is saved with thumbnail.

For this illustration, I opened and saved c:\fwh\manual\manual FWH english.doc as c:\fwh\manual\FWHmanual.docx with thumbnail.

In addition, I used xbrowser with customer.dbf and saved as word document from the print preview as c:\fwh\samples\cust.docx and c:\fwh\samoles\cust.xlsx, with "save thumbnail" option checked.

When the docx and xlx are ready, here is a sample program to view:
Code: Select all  Expand view

#include "fivewin.ch"

//----------------------------------------------------------------------------//

function Main()

   local aDocs := { "c:\fwh\manual\fwhmanual.docx", "c:\fwh\samples\cust.docx", "c:\fwh\samples\cust.xlsx" }
   local oDlg, oFont, oBrw, oImage, oBrush

   DEFINE FONT oFont NAME "ARIAL" SIZE 0,-18
   DEFINE BRUSH oBrush FILE "c:\fwh\bitmaps\backgrnd\stone.bmp"

   DEFINE DIALOG oDlg SIZE ScreenWidth() * 0.6, ScreenHeight() * 0.95 PIXEL ;
      FONT oFont TRUEPIXEL TITLE "FWH 15.04: OFFICE THUMBNAIL VIEWER"

   @ 20,20 XBROWSE oBrw SIZE 300,-20 PIXEL OF oDlg ;
      DATASOURCE aDocs COLUMNS 1 HEADERS "Document" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :bChange       := { || oImage:Refresh() }
      :CreateFromCode()
   END

   @ 20,320 XIMAGE oImage SOURCE OfficeExtractImage( oBrw:Document:Value ) SIZE -20,-20 OF oDlg
   oImage:SetBrush( oBrush )

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont
   RELEASE BRUSH oBrush

return nil

//----------------------------------------------------------------------------//
 


Image

Image

Note:
The function in the released version works with xHarbour but not with Harbour, due to some bugs in Harbour's HB_UnzipFile() function. The fix/woraround for Harbour is ready and will be released soon.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10245
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New function OfficeExtractImage

Postby driessen » Wed Apr 29, 2015 12:13 pm

Mr. Rao,

Thanks a lot for your explanation.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.02 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc77
User avatar
driessen
 
Posts: 1396
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: New function OfficeExtractImage

Postby cnavarro » Wed Apr 29, 2015 1:51 pm

Mr Rao

This error,
Stack Calls
===========
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 29/04/2015, 15:46:53
Error description: Error BASE/1004 Message not found: TXBROWSE:DOCUMENT

Stack Calls
===========
Called from: .\source\function\HARBOUR.PRG => _CLSSETERROR( 244 )
Called from: .\source\classes\XBROWSE.PRG => TXBROWSE:DOCUMENT( 8415 )
Called from: scicode.prg => (b)MAIN10( 433 )
Called from: .\source\classes\XIMAGE.PRG => TXIMAGE:REFRESH( 154 )
Called from: .\source\classes\WINDOW.PRG => (b)TWINDOW( 585 )
Called from: .\source\classes\WINDOW.PRG => TXIMAGE:SETBRUSH( 0 )

Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: New function OfficeExtractImage

Postby nageswaragunupudi » Wed Apr 29, 2015 1:55 pm

I guess you might have made some changes in the source code provided above, very likely in the HEADERS clause.
Please compile and build exactly without changing the code. You may change the array of documents ofcourse.

Note:
oBrw:Document refers to column with header "Document"
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10245
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New function OfficeExtractImage

Postby cnavarro » Wed Apr 29, 2015 1:56 pm

nageswaragunupudi wrote:I guess you might have made some changes in the source code provided above, very likely in the HEADERS clause.
Please compile and build exactly without changing the code. You may change the array of documents ofcourse.

Note:
oBrw:Document refers to column with header "Document"


You are right, apologies

But I fail to see the images ( Office 2010 )
Cristobal Navarro
Hay dos tipos de personas: las que te hacen perder el tiempo y las que te hacen perder la noción del tiempo
El secreto de la felicidad no está en hacer lo que te gusta, sino en que te guste lo que haces
User avatar
cnavarro
 
Posts: 6500
Joined: Wed Feb 15, 2012 8:25 pm
Location: España

Re: New function OfficeExtractImage

Postby nageswaragunupudi » Wed Apr 29, 2015 4:15 pm

1) We can extract the images only if we first saved with thumbnail option checked.
2) As I said earlier this extraction is not working with Harbour due to some bugs in HB_UnzipFile() function of Harbour. This is fixed and revised build is ready for release.
This works well with xHarbour

Meanwhile sent you the revised olefuncs.prg by email to you.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10245
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: New function OfficeExtractImage

Postby Silvio.Falconi » Fri Mar 24, 2017 11:38 am

TWO QUESTION

Do I must have Office installed ?
Wich is the difference of Xmage vs Image class ?
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 6768
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: richard-service and 16 guests