¿Nadie tiene un ejemplo???
No pido nada que sea complicado, sólo una orientación, y así facilitarme el
camino de como utilizar Word desde Xailer.
Un Saludo,
Xevi.
"Xevi" <
xevicomas_quitar_esto@gmail.com> escribió en el mensaje
news:[email=
48cea8b7@ozsrv2.ozlan.local...]
48cea8b7@ozsrv2.ozlan.local...[/email]
> Rene,
>
> "el otro producto" no lo he utilizado... vengo directamente de Clipper
> 5.2... C3 y finalmente escogí Xailer, por lo que agradecería cualquier
> ejemplo que puedas o alguien pueda colgar para ver como puedo aplicarlo a
> mi aplicación.
>
> Gracias.
>
> Un saludo,
> Xevi.
>
> "Rene Flores" <"rflores[nospam]"@ciber-tec.com> escribió en el mensaje
> news:[email=
48ce8795@ozsrv2.ozlan.local...]
48ce8795@ozsrv2.ozlan.local...[/email]
>> Xevi:
>>
>> La clase TWord de "el otro producto" funciona perfectamente con Xailer,
>> porque todo lo hace via OLE.
>>
>> Saludos
>>
>> Rene Flores
>>
http://www.ciber.tec.com
>>
>> escribió:
>>> Muy buenas...
>>>
>>> Álguien tiene algun ejemplo de como utilizar Word desde Xailer...
>>> Cómo... enviar texto, todo o parte... cambiar texto, combinar
>>> correspondencia, imprimir.
>>>
>>> Gracias.
>>>
>>> Un Saludo,
>>> Xevi.
>>>
>>>
>>
>>
>
>
> ------------------------------------------------------------ --------------------
>
>
>> // Clase TWord
>> // Esta clase fue iniciada por Pedro Arribas Lopez
>> // Se ha de linkar junto con la clase Ole2 de Jose Gimenez, ya que la
>> // clase OLE original de Fivewin produce un error
>> //
>> // Modificaciones y añadidos:
>> // 22-11-2002 Sebastian Almiron - Se ha añadido el Metodo SayRTF() para
>> poder
>> // imprimir textos FGET. El metodo devuelve un array de dos posiciones,
>> la
>> // primera devuelve .t. si el texto cabe dentro del marco especificado y
>> .f.
>> // si no cabe en el marco o no es un texto FGET. La segunda posición
>> contiene
>> // una cadena FGET con el texto que no cabe en el marco. De este modo
>> podemos
>> // decidir que hacer con el resto del texto FGET (Pj.: ponerlo en la
>> siguiente
>> // pagina.
>> // 20-11-2002 Sebastian Almiron - Se ha modificado el metodo AddImagen()
>> para
>> // que coloque la imagen dentro de un cuadro de texto nuevo, de manera
>> que esta
>> // se pueda colocar en cualquier parte del documento, ya que como estaba
>> originalmente
>> // siempre se ponia donde estubiera el cursor.
>> // 30-07-2002 Sebastian Almiron - modificado el metodo CMSAY que ahora
>> hace
>> // una llamada a ::Say despues de recalcular la posicion x e y
>> // 7-5-2002 Sebastian Almiron - Se ha incorporado el metodo
>> CheckSpelling() que
>> // llama al corrector ortografico. Debe tenerse el documento en pantalla.
>> Por
>> // ejemplo despues de llamar a ::Visualizar().
>> // 7-5-2002 Sebastian Almiron - Se han incorporados los metodos ::Gotop y
>> // ::GoBottom()
>> // 6-5-2002 Sebastian Almiron - Los metodos say, line, etc. ahora pueden
>> // referirse a la cabecera o al cuerpo principal del documento
>> // Ello nos permitirá crear el "impreso" sobre la cabecera cuando este
>> // se repita en muchas hojas, consiguiendo con ello un ahorro
>> // considerable de tiempo y espacio. El metodo SetHeader() hace que todos
>> // los metodos de pintado/escritura se redirijan a la cabecera y el
>> metodo
>> // SetMainDoc() hace que se escriban en el cuerpo principal del
>> documento.
>> // 6-5-2002 Sebastian Almiron - El metodo tabpredeterminado(ncmpos) es
>> para
>> // indicar la distancia de los tabuladoores predeterminados
>> // 6-5-2002 Sebastian Almiron - Existe una nueva propiedad ::oLastsay
>> // que es el ultimo say mandado al documento, ello nos permitirá darle
>> // formato, como por ejemplo añadirle tabuladores.
>> // 6-5-2002 Sebastian Almiron - El metodo TabClearAll(ocuadrotext)
>> elimina
>> // todos los tabuladores existentes, se le puede pasar de parametro el
>> // ultimo say (::olastsay), por defecto se refiere al documento.
>> // 6-5-2002 Sebastian Almiron - El metodo AddTabulador(ocuadrotexto)
>> sirve
>> // para añadir un tabulador, bien al documento (valor por defecto) o bien
>> // al ultimo say (::olastsay)
>> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo ::Box(), su uso
>> es
>> // similar al mismo metodo de TPrinter
>> // 6-5-2002 Sebastian Almiron - Se han añadido los metodos
>> ::SetPortrair() y
>> // setlandscape() al igual que en TPrinter
>> // 6-5-2002 Sebastian Almiron - Se ha añadido el metodo
>> ::Protect(password) que
>> // permite proteger el documento contra cualquier modificacion.
>> // 6-5-2002 Sebastian Almiron - Se ha modificado el metodo ::startpage()
>> y endpage()
>> // que producia bajo ciertas circunstancias paginas en blanco,
>> // ahora se aproxima mas a su uso con TPrinter. En realidad Endpage() no
>> // hace nada pero lo he dejado por mantener la compatibilidad con
>> TPrinter
>> // 6-5-2002 Sebastian Almiron - Se ha motificado el metodo ::Say(), ahora
>> se le
>> // puede indicar la anchura del cuadro de texto, por defecto calcula la
>> anchura
>> // para ajustarlo al texto. Se le puede pasar la altura del cuadro con
>> ello
>> // nos permitirá crear cuadros grandes en el que el texto esté separado
>> por
>> // tabuladores y retornos de carro, evitando tener que crear tantos
>> cuadros
>> // de texto.
>>
>> #include "FiveWin.Ch"
>> #define TAB chr(9)
>> #define ENTER chr(13)
>>
>> #define ALI_LEFT 0
>> #define ALI_CENTER 1
>> #define ALI_RIGHT 2
>> #define ALI_JUSTIFY 3
>>
>> #define LOGPIXELSX 88
>> #define LOGPIXELSY 90
>>
>> // Recorders and fields delimiters of GTF structure
>>
>> #define SP_REG Chr( 5 )
>> #define SP_FIELD Chr( 7 )
>>
>> #define TP_FONT Chr( 15 )
>> #define TP_COLOR Chr( 16 )
>> #define TP_ALIGN Chr( 17 )
>>
>> // Indentify and version of GTF files
>>
>> #define FORMAT_TEXT_TYPE "GTF"
>> #define FORMAT_TEXT_VERSION "1"
>>
>> // LA CLASE TWORD
>>
>> CLASS TWord
>> DATA OleWord
>> DATA hdc INIT 0
>> DATA OleDocs
>> DATA OleActiveDoc
>> DATA OleTexto
>> DATA oselection
>> DATA cNombreDoc
>> DATA nLinea,nCol, nPage
>> DATA nYoffset, nXoffset
>> DATA lstartpag
>> DATA oLastSay
>>
>> METHOD New()
>> METHOD NewDoc( cNombreDoc )
>> METHOD OpenDoc( cNombreDoc )
>> METHOD Write( cTexto, cFuente, cSize, lBold, lShadow, nColor )
>> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
>> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad )
>> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLine, nColor, cTexto,
>> oFuente, nJustify )
>> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
>> METHOD FillRect( aRect, oBrush )
>> METHOD AddImagen( nTop,nLeft,nBottom,nRight, cImagen )
>> //bySebastianAlmiron
>> METHOD Visualizar INLINE OleSetProperty( ::OleWord, "Visible", .t. )
>> METHOD JustificaDoc( nJustify )
>> METHOD Replace( cOld,cNew )
>> METHOD Save()
>> METHOD StartPage()
>> METHOD EndPage()
>> METHOD nHorzRes()
>> METHOD nHorzSize()
>> METHOD nVertRes()
>> METHOD nVertSize()
>> METHOD nLogPixelX()
>> METHOD nLogPixelY()
>> METHOD GetTextHeight( cFont, oFont )
>> METHOD PrintDoc()
>> METHOD Preview()
>> METHOD VistaCompleta()
>> METHOD End()
>> METHOD Protect(cpassword) // bySebastianAlmiron
>> METHOD SetLandScape() // bySebastianAlmiron
>> METHOD SetPortrait() // bySebastianAlmiron
>> METHOD Box(ntop, nleft, nbottom, nright) //bySebastianAlmiron
>> METHOD GetTextWidth(cText, oFont)//bySebastianAlmiron
>> METHOD addTabulador(ncmpos,ocuadrotext)//bySebastianAlmiron
>> METHOD TabClearAll(ocuadrotext)//bySebastianAlmiron
>> METHOD TabPredeterminado(ncmpos)//bySebastianAlmiron
>> METHOD SetHeader()//bySebastianAlmiron
>> METHOD SetMainDoc()//bySebastianAlmiron
>> METHOD Gotop() //bySebastianAlmiron
>> METHOD GoBottom() //bySebastianAlmiron
>> METHOD CheckSpelling() //bySebastianAlmiron
>> METHOD SayRTF( ntop, nleft, ctextFormat, nBottom, nright )
>> //bySebastianAlmiron
>> ENDCLASS
>>
>> METHOD NEW( cDoc )
>> ::OleWord := CreateOleObject( "Word.Application" )
>> return Self
>>
>> METHOD NewDoc( cNombreDoc )
>> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
>> OleInvoke( ::OleDocs,"Add")
>> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
>> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
>> ::cNombreDoc := cNombreDoc
>> ::nLinea := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::lstartpag := .t.
>> ::oselection := ::OleActiveDoc
>> return nil
>>
>> METHOD OpenDoc( cNombreDoc )
>> ::OleDocs := OleGetProperty( ::OleWord, "Documents")
>> IF FILE( cNombreDoc )
>> ::OleActiveDoc := OleInvoke( ::OleDocs,"Open",cNombreDoc )
>> ELSE
>> OleInvoke( ::OleDocs,"Add")
>> ::OleActiveDoc := OleGetProperty( ::OleWord, "ActiveDocument")
>> ENDIF
>> ::OleTexto := OleGetProperty( ::OleWord, "Selection")
>> ::cNombreDoc := cNombreDoc
>> ::nLinea := 0
>> ::nCol := 0
>> ::nPage := 0
>> ::nYoffset := 0
>> ::nXoffset := 0
>> ::oselection := ::OleactiveDoc
>> ::lstartpag := .t.
>> return nil
>>
>> METHOD Say2( nLin,nCol,cTexto,oFuente,nSizeHorz )
>> Local oFont := OleGetProperty( ::OleTexto, "Font")
>> OleSetProperty( oFont, "Name", oFuente:cFaceName )
>> OleSetProperty( oFont, "Size", int(oFuente:nHeight) )
>> OleSetProperty( oFont, "Bold", oFuente:lBold )
>>
>> if ::nLinea < nLin
>> OleInvoke( ::OleTexto,"TypeText", chr(13) )
>> ::nLinea:= nLin
>> ::nCol := 0
>> endif
>> if ::nCol < nCol
>> OleInvoke( ::OleTexto,"TypeText", chr(9) )
>> ::nCol:=nCol
>> endif
>>
>>
>> OleInvoke( ::OleTexto,"TypeText", cTexto )
>> OleInvoke( oFont,"Reset" )
>> release oFont
>> return nil
>>
>> METHOD TextBox( nTop, nLeft, nBottom, nRight, lLinea, nColor, cTexto,
>> oFuente, nJustify )
>> LOCAL oShapes,oCuadro,oFill,oLinea, oFontC, oText, oCuadroText
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop) )
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> oFillColor := OleGetProperty( oFill,"ForeColor")
>> OleSetProperty( oFillColor,"RGB",nColor )
>>
>> oLinea := OleGetProperty( oCuadro, "Line" )
>> if lLinea
>> OleSetProperty( oLinea, "Weight", 1 )
>> else
>> OleSetProperty( oLinea, "Transparency",0)
>> OleSetProperty( oLinea, "Visible",0)
>> endif
>>
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> oFontC := OleGetProperty( oText, "Font")
>>
>> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
>> OleSetProperty( oFontC, "Size", INT(oFuente:nHeight) )
>> OleSetProperty( oFontC, "Bold", oFuente:lBold )
>> OleSetProperty( oText, "Text", cTexto )
>>
>> oParagraph := OleGetProperty( oText, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nJustify )
>>
>> release oParagraph, OLinea, oFillColor, oFill, oFontC, oText,oCuadroText,
>> oCuadro
>> return nil
>>
>> METHOD AddImagen( nTop, nLeft, nBottom, nRight, cImagen )
>>
>> LOCAL oShapes,oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
>> oCuadro6, oCuadro7
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
>> oLinea := OleGetProperty( oCuadro, "Line" )
>> OleSetProperty( oLinea, "Transparency",0)
>> OleSetProperty( oLinea, "Visible",0)
>>
>> oCuadro2 := OleGetProperty(oCuadro,'Anchor')
>> oCuadro3 := OleGetProperty(oCuadro2,'ShapeRange')
>> oCuadro4 := OleGetProperty(oCuadro3,'TextFrame')
>> oCuadro5 := OleGetProperty(oCuadro4,'TextRange')
>>
>> oCuadro6 := OleGetProperty(oCuadro5,'InlineShapes')
>> oCuadro7 := Oleinvoke(oCuadro6, "AddPicture", cImagen,.F.,.T.)
>>
>> release oShapes, oCuadro, oLinea, oCuadro2, oCuadro3, oCuadro4, oCuadro5,
>> oCuadro6, oCuadro7
>> return nil
>>
>>
>> METHOD Say( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
>> naltura )
>> LOCAL oShapes,oFill,oLine,oCuadroText,oText,oFontC,oParagraph
>> local nTamFuente := if(oFuente:nHeight > 0, int(oFuente:nHeight + 2.8),
>> int((oFuente:nHeight*-1)+2.8) )
>>
>> DEFAULT nClrText := nRGB(0,0,0), nBkMode := 2, nPad := 0
>> DEFAULT nSizeHorz := ::GetTextWidth(ctexto,oFuente)
>> DEFAULT naltura := if(oFuente:nHeight > 0, oFuente:nHeight + 12,
>> (oFuente:nHeight*-1)+12)
>>
>> nSizeHorz := nSizeHorz + (nSizeHorz*25/100)
>>
>> do case
>> case npad = 1
>> ncol := ncol - nSizeHorz
>> npad := 2
>> case npad = 2
>> ncol = ncol - (nSizeHorz/2)
>> npad := 1
>> endcase
>> oShapes := OleGetProperty( ::oselection,"Shapes" ) //::OleactiveDoc
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nCol),INT(nLin),nSizeHorz,naltura )
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> oLine := OleGetProperty( oCuadro, "Line" )
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> oFontC := OleGetProperty( oText, "Font")
>> oParagraph := OleGetProperty( oText, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nPad )
>> OleSetProperty( oFill, "Transparency",0)
>> OleSetProperty( oFill, "Visible",0)
>> OleSetProperty( oLine, "Transparency",0)
>> OleSetProperty( oLine, "Visible",0)
>> OleSetProperty( oFontC, "Name", oFuente:cFaceName )
>> OleSetProperty( oFontC, "Size", nTamfuente )
>> //INT(oFuente:nHeight*-1) )
>> OleSetProperty( oFontC, "Bold", oFuente:lBold )
>> OleSetProperty( oFontC, "Italic", oFuente:lItalic )
>> OleSetProperty( oText, "Text", cTexto )
>>
>> OleSetProperty( oCuadroText, "MarginLeft",0)
>> OleSetProperty( oCuadroText, "MarginRight",0)
>>
>> ::oLastSay := otext
>>
>> release oFontC,oText,oCuadro,oLine,oFill,oShapes,oParagraph,ocuadrot ext
>>
>> return NIL
>>
>> METHOD CmSay( nLin,nCol,cTexto,oFuente,nSizeHorz,nClrText,nBkMode,nPad,
>> naltura )
>>
>> nCol := Max( 0, ( nCol * 10 * ::nHorzRes() / ::nHorzSize() ) -
>> ::nYoffset )
>> nLin := Max( 0, ( nLin * 10 * ::nVertRes() / ::nVertSize() ) -
>> ::nXoffset )
>>
>> ::Say(nLin,nCol,ctexto,oFutnte,nZizeHorz,nClrText,nBkMode,nP ad,naltura)
>>
>> return NIL
>>
>> METHOD Line( nTop, nLeft, nBottom, nRight, oPen )
>> LOCAL oShapes,oShapLinea, oLinea
>> if oPen = NIL
>> DEFINE PEN oPen
>> endif
>>
>> oShapes := OleGetProperty( ::oselection ,"Shapes" )
>> oShapLinea := OleInvoke( oShapes, "AddLine", nLeft,nTop,nRight,nBottom )
>> oLinea := OleGetProperty( oShapLinea, "Line" )
>> OleSetProperty( oLinea, "Weight", oPen:nWidth-2 )
>> oPen:End()
>> release oLinea,oShapLinea,oShapes
>>
>> return nil
>>
>> METHOD FillRect( aRect, oBrush )
>> LOCAL oShapes,oShapBox, oFill, oFillColor
>> LOCAL nTop := INT(arect[1])
>> LOCAL nLeft := INT(arect[2])
>> LOCAL nWidth := INT(aRect[4]-aRect[2])
>> LOCAL nHeight := INT(aRect[3]-aRect[1])
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oShapBox := OleInvoke( oShapes,
>> "AddShape",1,nLeft,nTop,nWidth,nHeight )
>> oFill := OleGetproperty( oShapBox,"Fill")
>> oFillColor := OleGetProperty( oFill,"ForeColor")
>> OleSetProperty( oFillColor,"RGB",oBrush:nRGBColor )
>> oBrush:End()
>>
>> release oFillColor,oFill,oShapBox,oShapes
>> return nil
>>
>> METHOD GetTextHeight( cFont, oFont )
>> return oFont:nHeight
>>
>> METHOD Write( cTexto, cFuente, nSize, lBold, lShadow, nColor )
>> Local oFont := OleGetProperty( ::OleTexto, "Font")
>> OleSetProperty( oFont, "Name", cFuente )
>> OleSetProperty( oFont, "Size", nSize )
>> OleSetProperty( oFont, "Bold", lBold )
>> OleSetProperty( oFont, "ColorIndex",nColor )
>> OleSetProperty( oFont, "Emboss",lShadow )
>>
>> OleInvoke( ::OleTexto,"TypeText", cTexto )
>> OleInvoke( oFont,"Reset" )
>> release oFont
>> return nil
>>
>> METHOD Replace( cOld, cNew )
>> LOCAL oTexto, oFind, oReplace
>>
>> oTexto := OleInvoke( ::oselection, "Range" )
>> oFind := OleGetProperty( oTexto, "Find" )
>>
>> OleSetProprerty( oFind, "Text", cOld )
>> OleSetProprerty( oFind, "Forward", .T. )
>> OleSetProprerty( oFind, "Wrap", INT(1) )
>> OleSetProprerty( oFind, "Format", .f. )
>> OleSetProprerty( oFind, "MatchCase", .f. )
>> OleSetProprerty( oFind, "MatchWholeWord", .f. )
>> OleSetProprerty( oFind, "MatchWildcards", .f. )
>> OleSetProprerty( oFind, "MatchSoundsLike", .f. )
>> OleSetProprerty( oFind, "MatchAllWordForms", .f. )
>>
>> OleInvoke( oFind, "Execute")
>> DO WHILE OleGetProprerty( oFind, "Found" )
>> OleSetProprerty( oTexto, "Text", cNew )
>> OleInvoke( oFind, "Execute")
>> Enddo
>>
>> release oReplace,oFind,oTexto
>> return nil
>>
>> METHOD JustificaDoc( nJustify )
>> LOCAL oParagraph := OleGetProperty( ::Oletexto, "ParagraphFormat")
>> OleSetProperty( oParagraph, "Alignment", nJustify )
>> release oParagraph
>> return nil
>>
>> METHOD Save()
>> OleInvoke( ::OleActiveDoc,"SaveAs", ::cNombreDoc )
>> return nil
>>
>> METHOD StartPage()
>> if ::lstartpag = .t.
>> ::lstartpag := .f.
>> else
>> OleInvoke(::OleTexto,"EndKey",6,0)
>> OleInvoke(::OleTexto,"InsertBreak")
>> OleInvoke(::Oletexto,"GotoNext",1)
>> ::nPage++
>> ::nLinea:=0
>> ::nCol :=0
>> endif
>> return nil
>>
>> METHOD EndPage()
>> return nil
>>
>> METHOD PrintDoc()
>> OleInvoke( ::OleWord, "PrintOut" )
>> return nil
>>
>> METHOD Preview()
>> OleSetProperty( ::OleWord, "PrintPreview",.f.)
>> OleInvoke( ::OleActiveDoc, "PrintPreview")
>> ::Visualizar()
>> return nil
>>
>> METHOD VistaCompleta()
>> LOCAL oWindow, oView
>>
>> oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> oView := OleGetProperty( oWindow , "View" )
>> OleSetProperty( oView,"FullScreen", .T. )
>> ::Visualizar()
>> release oView
>> return nil
>>
>> METHOD nHorzRes()
>> nRes := 2
>> return nres
>>
>> METHOD nHorzSize()
>> nRes := 1
>> return nres
>>
>> METHOD nVertRes()
>> nRes := 2
>> return nres
>>
>> METHOD nVertSize()
>> nRes := 1
>> return nres
>>
>> METHOD nLogPixelY()
>> LOCAL nPixels := 55.38
>> return nPixels
>>
>> METHOD nLogPixelX()
>> LOCAL nPixels := 55.38
>> return nPixels
>>
>> METHOD End()
>> OleInvoke(::OleWord,"Quit",0)
>> ::OleTexto := NIL
>> ::OleActiveDoc := NIL
>> ::OleDocs := NIL
>> ::Oleword := NIL
>> OleUninitialize()
>> return nil
>>
>> METHOD Protect(cpassword)
>> OleInvoke( ::OleActiveDoc,"Protect", 2, .F., cpassword )
>> return
>>
>> METHOD SetLandScape()
>> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
>> OleSetProperty( oPageSetup,'Orientation','1')
>> release oPageSetup
>> return
>>
>> METHOD SetPortrait()
>> local oPageSetup := OleGetProperty( ::OleactiveDoc,'PageSetup')
>> OleSetProperty( oPageSetup,'Orientation','0')
>> release oPageSetup
>> return
>>
>> METHOD Box( nTop, nLeft, nBottom, nRight )
>> local oShapes,oShapBox
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>>
>> nRight := nRight - nLeft
>> nBottom := nBottom - nTop
>>
>> oShapBox := OleInvoke( oShapes,
>> "AddShape",1,nLeft,nTop,nRight,nBottom )
>>
>> release oShapBox,oShapes
>> return nil
>>
>> METHOD GetTextWidth(cText, oFont)
>> local nancho
>> if oFont:nHeight > 0
>> nancho := (oFont:nHeight/1.6)*len(ctext)
>> else
>> nancho :=((oFont:nHeight*-1)/1.6)*len(ctext)
>> endif
>> return nancho
>>
>> METHOD addtabulador(npos, ocuadrotext)
>> local otabstop, oParagraphFormat
>> DEFAULT ocuadrotext := ::OleTexto
>> oParagraphFormat := OleGetProperty(ocuadrotext, 'ParagraphFormat')
>> otabstop := OleGetProperty(oParagraphFormat, 'TabStops')
>> OleInvoke(otabstop,'Add',npos)
>> release oParagraphFormat, otabstop
>> return nil
>>
>> METHOD TabClearAll(ocuadrotext)
>> local oparagraphformat, otabstop
>> DEFAULT ocuadrotext := ::Oletexto
>> oparagraphformat := OleGetProperty(ocuadrotext,'ParagraphFormat')
>> otabstop := OleGetProperty(oParagraphformat, 'TabStops')
>> OleInvoke(otabstop,'ClearAll')
>> release oparagraphformat, otabstop
>> return nil
>>
>> METHOD TabPredeterminado(npos)
>> OleSetProperty(::OleactiveDoc,'DefaultTabStop', npos )
>> return nil
>>
>> METHOD SetHeader()
>> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> local oView := OleGetProperty( oWindow , "View")
>> OleSetProperty(oView,"SeekView",9)
>> ::oselection := OleGetProperty( ::OleTexto, "HeaderFooter")
>> release oWindow, oView
>> return
>>
>> METHOD SetMainDoc()
>> local oWindow := OleGetProperty( ::OleActiveDoc , "ActiveWindow" )
>> local oView := OleGetProperty( oWindow , "View")
>> OleSetProperty(oView,"SeekView",0)
>> ::oselection := ::OleActiveDoc
>> release oWindow, oView
>> return
>>
>> METHOD Gotop()
>> OleInvoke(::OleTexto, 'HomeKey', 6)
>> return
>>
>> METHOD GoBottom()
>> OleInvoke(::OleTexto, 'EndKey', 6)
>> return
>>
>> METHOD CheckSpelling()
>> Oleinvoke(::OleActiveDoc, 'CheckSpelling')
>> return
>>
>> METHOD SayRTF( nTop,nLeft, cTextFormat, nBottom,nRight )
>> local cText := "", nPos := 1, nLen := 0, nCrLf, cFormat, cVersion, cType
>> local afuentes := {}, nColorText := 0
>> local cFacename, cHeight, cWidth, lBold, lItalic, lUnderline, lStrikeout
>> local nJustify, nFont
>> local oShapes, oCuadro, oFill, oLine, oCuadrotext
>> local oFont := OleGetProperty( ::OleTexto, "Font")
>> local aSal := {.f.,''}, lnocabe := .f.
>>
>>
>> nLen := AT( SP_REG, SubStr( cTextFormat, nPos ) )
>> cFormat := SubStr( cTextFormat, nPos, nLen - 1 )
>> nPos += nLen
>> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) )
>> cVersion := SubStr( cTextFormat, nPos, nLen - 1 )
>> nPos += nLen
>>
>> if !( cFormat == FORMAT_TEXT_TYPE )
>> asal[1] := .f.
>> return asal
>> endif
>>
>> do whil .t.
>>
>> if Substr( cTextFormat, npos, 1 ) == SP_FIELD
>> nPos += 1
>> exit
>> endif
>>
>> cFacename := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>> cHeight := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> cWidth := Substr( cTextFormat, npos, At( SP_REG, Substr( cTextFormat,
>> nPos ) ) -1 )
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lBold := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lItalic := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lUnderline := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> lStrikeOut := if(val(Substr( cTextFormat, npos, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 )) = 0, .f.,.t.)
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>>
>> aadd( afuentes, {cFacename, cHeight, cWidth, lBold, lItalic, lUnderline,
>> lStrikeOut})
>>
>> enddo
>>
>> oShapes := OleGetProperty( ::oselection,"Shapes" )
>> oCuadro := OleInvoke( oShapes, "AddTextbox",
>> 1,INT(nLeft),INT(nTop),INT(nRight-nLeft),INT(nBottom-nTop))
>> oFill := OleGetProperty( oCuadro, "Fill" )
>> OleSetProperty( oFill, "Transparency",0)
>> OleSetProperty( oFill, "Visible",0)
>> oLine := OleGetProperty( oCuadro, "Line" )
>> OleSetProperty( oLine, "Transparency",0)
>> OleSetProperty( oLine, "Visible",0)
>> oCuadroText := OleGetProperty( oCuadro, "TextFrame" )
>> oText := OleGetProperty( oCuadroText, "TextRange" )
>> OleInvoke(ocuadro,'Select')
>>
>>
>> do while ( cType := SubStr( cTextFormat, nPos, 1 ) ) != SP_FIELD
>> if cType == TP_ALIGN .or. cType == TP_FONT .or. cType == TP_COLOR
>> if cType == TP_ALIGN
>> njustify := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 ))
>> ::Justificadoc(njustify)
>> endif
>> if cType == TP_FONT
>> nfont := val(SubStr( cTextFormat, nPos + 1, nLen -1 ))
>> OleSetProperty( oFont, "Name", afuentes[nfont,1] )
>> OleSetProperty( oFont, "Size", if( val(afuentes[nfont,2]) < 0,
>> val(afuentes[nfont,2])*-1, val(afuentes[nfont,2]) ) )
>> OleSetProperty( oFont, "Bold", afuentes[nfont,4] )
>> OleSetProperty( oFont, "Italic", afuentes[nfont,5] )
>> OleSetProperty( oFont, "Underline", afuentes[nfont,6] )
>> OleSetProperty( oFont, "StrikeThrough", afuentes[nfont,7] )
>> endif
>> if cType == TP_COLOR
>> ncolortext := Val(Substr( cTextFormat, npos +1, At( SP_REG, Substr(
>> cTextFormat, nPos ) ) -1 ))
>> OleSetProperty( oFont,"Color", ncolortext )
>> endif
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nPos += nLen
>> else
>> nLen := At( SP_REG, SubStr( cTextFormat, nPos ) )
>> nCrLf := At( CRLF, SubStr( cTextFormat, nPos ) )
>> if nLen == 0
>> if nCrLf == 0
>> nLen := At( SP_FIELD, SubStr( cTextFormat, nPos ) ) - 1
>> else
>> nLen := nCrLf + 1
>> endif
>> else
>> if nCrLf == 0 .or. nCrLf > nLen
>> do while SubStr( ctextformat, nPos + --nLen - 1, 1 ) > Chr( 32 )
>> enddo
>> --nLen
>> else
>> nLen := nCRLf + 1
>> endif
>> endif
>> cText = SubStr( cTextFormat, nPos, nLen )
>>
>> lnocabe := OleGetProperty( oCuadroText, 'Overflowing')
>> if lnocabe
>> asal[2] := substr( ctextformat,1, 4 )
>> asal[2] := asal[2] + substr( ctextformat, 5, At( SP_FIELD, Substr(
>> cTextformat, 5) ))
>> asal[2] := asal[2] + substr( ctextformat, nPos + nLen)
>> exit
>> endif
>>
>> cText = SubStr( cTextFormat, nPos, nLen )
>> OleInvoke( ::Oletexto, "Typetext", cText )
>>
>> nPos += nLen
>> endif
>> enddo
>>
>>
>> OleInvoke( oFont,"Reset" )
>> release oShapes, oCuadro, oFill, oLine, oCuadrotext, oFont
>> return asal
>>
>>
>>
>
>