#include "FiveWin.ch"
static oWnd
//----------------------------------------------------------------------------//
function Main()
DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
TITLE "Ejemplos de OpenOffice" ;
MENU BuildMenu()
SET MESSAGE OF oWnd ;
TO FWVERSION + " " + FWCOPYRIGHT ;
CENTERED DATE CLOCK KEYBOARD 2007
ACTIVATE WINDOW oWnd MAXIMIZED // Now the app will start maximized
return nil
//----------------------------------------------------------------------------//
function BuildMenu()
local oMenu
MENU oMenu 2007
MENUITEM "Writer"
MENU
MENUITEM "Abrir un archivo en &blanco..." ;
ACTION Writer00() ;
MESSAGE "Solamente abre un fichero en blanco"
MENUITEM "Abrir un archivo un archivo determinado..." ;
ACTION Writer01() ;
MESSAGE "Solamente abre un fichero"
ENDMENU
MENUITEM "&Exit"
MENU
MENUITEM "&Calculator..." ;
ACTION WinExec( "Calc" ) ;
MESSAGE "Using the Windows calculator"
SEPARATOR
MENUITEM "&End..." ;
ACTION If( MsgYesNo( "Quieres salir ?", "Porfavor, selecciona" ),;
(TOpenOffice():Finaliza(), oWnd:End()),) ;
MESSAGE "Salir de la aplicación"
ENDMENU
ENDMENU
return oMenu
/*-----------------------------------------------------------------------------------------------*/
FUNCTION Writer00()
LOCAL oDoc
/* Para abrir un documento en blanco basta que no mandemos nada a la clase tOpenOffic:Writter */
MsgRun( "Instanciando OpenOffice",;
"Un momento por favor..." ,;
{ || oDoc := TOpenOffice():Writer( , .T. ) } )
RETURN NIL
FUNCTION Writer01()
LOCAL cFile, oDoc
cFile := cGetFile32( "*.*", "Buscar Archivos" )
IF cFile = NIL; RETURN NIL; ENDIF
//cFilePath( GetModuleFileName( GetInstance() ) ) + "Macros.odt"
MsgRun( "Instanciando OpenOffice",;
"Un momento por favor..." ,;
{ || oDoc := TOpenOffice():Writer( cFile , .T. ) } ) //cFile
RETURN NIL
#include "Fivewin.ch"
#DEFINE CR CHR(13)
#DEFINE wdTAB CHR(9)
** API CONTROL CHARACTERS FOR insertControlCharacter
#define PARAGRAPH_BREAK 0
#define LINE_BREAK 1
#DEFINE HARD_HYPHEN 2
#DEFINE SOFT_HYPHEN 3
#DEFINE HARD_SPACE 4
#DEFINE APPEND_PARAGRAPH 5
#DEFINE STANDARD_FORMAT ".odt"
/*-----------------------------------------------------------------------------------------------*/
CLASS TOpenOffice
CLASSDATA oService // Objeto Servicio
CLASSDATA oDesktop // Objeto Escritorio
CLASSDATA oDisp // Objeto Disp
DATA oDoc // Objeto Documento
* DATA oTxt // Objeto Texto
DATA oRng // Objeto Rango
DATA oCursor // Objeto Cursor
DATA oSourceframe // Objeto SourceFrame
DATA lOpen Init .T. // Boleano para saber si esta abierto un objeto
METHOD Writer(cFile)
METHOD Close() INLINE ::oDoc:Close( .T. )
METHOD Copy() INLINE ::Dispatch( "Copy" )
METHOD ConvertToURL( cFile )
METHOD Dispatch( cMethod, aArgs )
METHOD GetPropertyValue( cName, cValue )
METHOD New() Constructor
METHOD Print() INLINE ::Dispatch( "Print" )
METHOD PrintDefault() INLINE ::Dispatch( "PrintDefault" )
METHOD Visible( lVisible )
METHOD Paste() INLINE ::Dispatch( "Paste" )
METHOD Preview() INLINE ::Dispatch( "PrintPreview" )
METHOD Finaliza()
ERROR HANDLER ERROR( xVal )
ENDCLASS
/*-----------------------------------------------------------------------------------------------*/
METHOD Visible( lVisible )
IF lVisible == NIL
RETURN ::oDoc:getCurrentController():GetFrame():getComponentWindow():IsVisible()
ELSE
::oDoc:getCurrentController():GetFrame():getComponentWindow():setVisible( lVisible )
ENDIF
RETURN NIL
/*-----------------------------------------------------------------------------------------------*/
METHOD Writer( cFile, lVisible ) CLASS TOpenOffice
LOCAL cUrl, oDoc, oTxt, aArg := {}
::New()
IF !::lOpen; RETURN NIL; ENDIF
DEFAULT lVisible := .T.
IF cFile == NIL
cUrl := "private:factory/swriter"
ELSE
cUrl := "file:///" + cFile
ENDIF
IF !lVisible
AAdd( aArg, ::GetPropertyValue( "Hidden", .T. ) ) //Le asigna la propiedad de que este escondido
//(Ojo no puedes volverlo a mostrar) para
//ejecutarse mas rapido. Ejemplo: realizar una
ENDIF //impresion de un documento sin que lo puedan modificar
oDoc := ::oDesktop:LoadComponentFromUrl( cUrl, "_blank", 0, aArg )
RETURN oDoc //oSheet
/*-----------------------------------------------------------------------------------------------*/
METHOD Dispatch( cMethod, aArgs ) CLASS TOpenOffice
DEFAULT aArgs := {}
IF ValType( aArgs ) == "O"; aArgs := { aArgs }; ENDIF
::oDisp:ExecuteDispatch( ::oDoc:GetCurrentController():GetFrame(), ".uno:" + cMethod, "", 0, aArgs )
RETURN NIL
/*-----------------------------------------------------------------------------------------------*/
METHOD GetPropertyValue( cName, xValue ) CLASS TOpenOffice
LOCAL oArg
oArg := ::oService:Bridge_GetStruct( "com.sun.star.beans.PropertyValue" )
oArg:Name := cName
oArg:Value := xValue
RETURN oArg
/*-----------------------------------------------------------------------------------------------*/
METHOD New() CLASS TOpenOffice
// Par usar cualquier aplicativo de OpenOffice lo primero que se tiene que hacer es cargar el ServiceManager
// una vez se tiene capturado se debe instanciar el objeto Destop y finlamente el Despachador
IF ::oDesktop != NIL; RETURN SELF; ENDIF
IF ::oService != NIL; RETURN SELF; ENDIF
::lOpen := .T.
TRY
::oService := TOleAuto():New( "com.sun.star.ServiceManager" )
CATCH
MsgStop( "No se puede iniciar el servicio manager" )
::lOpen := .F.
END
IF ::lOpen
::oDesktop := ::oService:CreateInstance( "com.sun.star.frame.Desktop" )
::oDisp := ::oService:CreateInstance( "com.sun.star.frame.DispatchHelper" )
ENDIF
RETURN SELF
/*-----------------------------------------------------------------------------------------------*/
METHOD ERROR( xVal ) CLASS TOpenOffice
MsgInfo( __GetMessage() + " Inexistente" )
RETURN NIL
/*-----------------------------------------------------------------------------------------------*/
METHOD ConvertToURL( cFile ) CLASS TOpenOffice
LOCAL nFor, nLen := Len( cFile )
FOR nFor := 1 TO nLen
IF cFile[ nFor ] == "\"
cFile[ nFor ] := "/"
ENDIF
NEXT
RETURN cFile
/*-----------------------------------------------------------------------------------------------*/
METHOD Finaliza() CLASS TOpenOffice
::oDesktop:=nil
::oDoc:=nil
::oDisp:=nil
*::oService:=nil //Try to uncomment (created with toleauto)
Return nil
Andrés González wrote:Please Enrico, could you test my example if destroy all objects automatically.
Thanks.
FUNCTION MAIN()
LOCAL oTest := TTest()
oTest:oRs = CREATEOBJECT( "ADODB.Recordset" )
RETURN NIL
#include "Hbclass.ch"
CLASS TTest
CLASSDATA oRs
ENDCLASS
Andrés González wrote:Rochiha, the program run ok and look marvellous, but why i have to comment this lines to run de program, where are they defined. See "*"
- Code: Select all Expand view
oFRLbx:nStyle := 1
oFRLbx:nLineStyle := 10
*oFRLbx:nHeaderStyle := 2
*oFRLbx:nHeaderHeight := 20
*oFRLbx:nLineHeight := 15
oFRLbx:lMChange := .f.
*oFRLbx:lOnlyBorder := .f.
*oFRLbx:lAdjLastCol := .f.
*oFRLbx:Set3DStyle()
// -> Cabecalho
oFRLbx:nClrBackHead := nRGB(194,218,242)
// -> Linha divisora
*oFRLbx:nClrLine := nRGB(194,218,242)
// -> Cores das linhas Texto e Fundo
// -> Cor do cursor com foco
oFRLbx:nClrForeFocus := CLR_BLACK
oFRLbx:nClrBackFocus := nRGB(194,218,242)
// -> Cor do cursor sem foco
*oFRLbx:nClrNFFore := CLR_BLACK
*oFRLbx:nClrNFBack := nRGB(194,218,242)
oFRLbx:SetFont( oFntLBX )
Enrico Maria Giordano wrote:This is a reduced sample of the problem:
- Code: Select all Expand view
FUNCTION MAIN()
LOCAL oTest := TTest()
oTest:oRs = CREATEOBJECT( "ADODB.Recordset" )
RETURN NIL
#include "Hbclass.ch"
CLASS TTest
CLASSDATA oRs
ENDCLASS
I'm going to ask for info to the xHarbour developers and report back here...
EMG
2008-08-28 22:30 UTC-0430 Ron Pinkas <ron/at/xharbour.com>
* include/classes.h
* source/vm/classes.c
+ Added hb_clsClearAllClassDatas()
* source/vm/hvm.c
+ Add call to clear class datas before disabling Destructors
/*
This change dismisses the restriction on storing a destructable object
into a classdata, but by the time such Destructor are activated
classdatas might have been cleaned, which means that Destructors should
not rely on any classdata value.
*/
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 106 guests