'bs_BrOffice_Writer:
%REM
Library bs_BrOffice_Writer
Description: Comments for Library
Biblioteca criada para armazenar as funções utilizadas para montagem de relatórios
na ferramenta BrOffice.org Writer
%END REM
Option Public
'Option Declare
Dim objServiceManager As Variant
Dim objCoreReflection As Variant
Dim StarDesktop As Variant
Dim dispatcher As Variant
Dim sUrl As Variant
Dim oDoc As Variant
Dim frame As Variant
Dim oPlanilha As Variant
Dim oCellRange As Variant
Dim oAddr As Variant
Dim border
Dim vEnd As Variant
Dim Charts As Variant
Dim Chart
Dim Rect As Variant
Dim classSize As Variant
'sWriter
Dim oCursor
Dim oText
Dim oField
Dim oCelula
Dim oCurTab As Variant
Dim IntCelula() As Integer 'Array de inteiros das Linhas e Colunas de todas as Abas (PRIMEIRA DIMENSAO - POSIÇÃO 0 PARA LINHA E 1 PARA COLUNA)
Dim strListNomeCelula List As String 'Armazena as letras correspondentes a celula
%REM
Sub WRITER_Initialize
Description: Comments for Sub
%END REM
Sub WRITER_Initialize
Set objServiceManager = CreateObject("com.sun.star.ServiceManager")
Set objCoreReflection = objServiceManager.createInstance("com.sun.star.reflection.CoreReflection")
Set StarDesktop = objServiceManager.createInstance("com.sun.star.frame.Desktop")
Set dispatcher = objServiceManager.createInstance("com.sun.star.frame.DispatchHelper")
'Cria um novo documento do WRITER
Dim args(0)
Set args(0) = WRITER_makePropertyValue("Hidden", True)
sUrl = "private:factory/swriter"
Set oDoc = StarDesktop.loadComponentFromURL(sUrl, "_blank", 0, args())
'Set oPlanilha = oDoc.getSheets().getByIndex(0)
Set frame = oDoc.CurrentController.Frame
End Sub
Function WRITER_makePropertyValue(sName As String, vValue) As Variant
Dim vStruct
Set vStruct = objServiceManager.Bridge_GetStruct("com.sun.star.beans.PropertyValue")
vStruct.name = sName
vStruct.value = vValue
Set WRITER_makePropertyValue = vStruct
End Function
Function WRITER_createStruct(strTypeName)
Dim aStruct
Set classSize = objCoreReflection.forName(strTypeName)
classSize.createObject aStruct
Set WRITER_createStruct = aStruct
End Function
%REM
Sub WRITER_Terminate
Description: Comments for Sub
%END REM
Sub WRITER_Terminate()
Set objServiceManager = Nothing
Set objCoreReflection = Nothing
Set StarDesktop = Nothing
Set dispatcher = Nothing
Set oDoc = Nothing
Set classSize = Nothing
End Sub
%REM
Sub WRITER_showFile
Description: Comments for Sub
%END REM
Sub WRITER_showFile()
oDoc.getCurrentController().getFrame().getContainerWindow().setVisible(True)
End Sub
%REM
Sub WRITER_insertText
Description: Comments for Sub
%END REM
Sub WRITER_insertText(strTexto As String)
Set oText = oDoc.Text
Set oCursor = oText.createTextCursor()
Call oCursor.SetString(strTexto)
End Sub
%REM
Sub WRITER_montaTable
Description: Comments for Sub
%END REM
Sub WRITER_montaTable(intLinha As Integer, intColuna As Integer, nomeTabela As String)
Set table = oDoc.createInstance("com.sun.star.text.TextTable")
table.Name = nomeTabela
Call table.initialize( intLinha, intColuna )
Set oText = oDoc.Text
Set oCursor = oText.createTextCursor()
Call oText.insertTextContent( oCursor, table, False )
End Sub
%REM
Sub WRITER_insertTextTable
Description: Comments for Sub
%END REM
Sub WRITER_insertTextTable(nomeTabela As String, posicaoCelula As String, strTexto As String)
Set table = oDoc.getTextTables().getByName(nomeTabela)
Set oCelula = table.getCellByName(posicaoCelula)
Call oCelula.SetString(strTexto)
End Sub
%REM
Sub WRITER_mergeCells
Description: Comments for Sub
%END REM
Sub WRITER_mergeCells(nomeTabela As String, posicaoCelula As String, QtdeCelula As Integer)
Dim table As Variant
Set table = oDoc.getTextTables().getByName(nomeTabela)
Set oCurTab = table.createCursorByCellName("A1")
Call oCurTab.gotoCellByName(posicaoCelula, False)
Call oCurTab.goRight(QtdeCelula, True)
Call oCurTab.mergeRange()
End Sub
%REM
Sub WRITER_insertParagraph
Description: Comments for Sub
%END REM
Sub WRITER_insertParagraph
Set oText = oDoc.Text
Set oTxtRng = oText.getEnd()
'com.sun.star.text.ControlCharacter.LINE_BREAK
Call oText.insertControlCharacter(oTxtRng, 1, False)
End Sub
Nenhum comentário:
Postar um comentário