1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE script:module PUBLIC "-//OpenOffice.org//DTD OfficeDocument 1.0//EN" "module.dtd">
<script:module xmlns:script="http://openoffice.org/2000/script" script:name="Tablas" script:language="StarBasic">REM ***** BASIC Módulo Tablas *****
Option explicit
Const Extension as string = "Revisiones v 1.0.0"
Global oTablas as Object
Global oTabla as Object
Global vCursor as Object
Dim oDlg as Object
'Dim Dlg_Activo as Boolean 'dlg No modal evita ejecuciones múltiples
' Dim Dlg_Mostrado as Boolean ' dlg No modal para cerrar el diálogo
Global Indice_Tbl as Integer
Dim Ultima_Tbl as integer
Rem ############
Sub DlgTablas'(oTabla)
Dim Dlg As Object
' Call L10n.Cargar_Idioma
Call L10n.Trad_Tablas
If Thiscomponent.HasLocation = false then : Msgbox (T_Txt(24),0+48+0,Extension) : Exit Sub : End If ' Primero tienes que guardar el archivo
If Tablas.F_PruebaSelec = 0 Then :Exit Sub : End If
oTablas = ThisComponent.TextTables
Ultima_Tbl = oTablas.getCount -1
If Ultima_Tbl < 0 Then : Msgbox (T_Txt(14), 0+48+0,Extension) : Exit Sub : End If ' no hay tablas en el documento
Indice_Tbl = 0
oTabla = oTablas.getbyIndex(Indice_Tbl)
vCursor = ThisComponent.CurrentController.getViewCursor()
vCursor.gotoStart(False)
vcursor.gotoRange(oTabla.getAnchor,false)
If Dlg_Activo = False then
DialogLibraries.loadLibrary("SanityCheck")
oDlg = CreateUnoDialog(DialogLibraries.getByName("SanityCheck").getByName("DlgTablas"))
Dlg_Activo = True
Dlg_Mostrado = True
oDlg.Model.PositionX = 530
oDlg.Model.PositionY = 60
' oDlg.Model.Step = 1
Call Parametros_Tablas
Do While Dlg_Mostrado = True
Wait 200
oDlg.SetVisible(True)
Loop
oDlg.dispose
Dlg_Activo= False
End If
End Sub
sub parar
Dlg_Mostrado = False
DLg_Activo = False
end sub
Rem ############
Sub Parametros_Tablas
If not Dlg_Mostrado then : Msgbox (T_Txt(26),0+48+0,Extension) : exit sub: end if 'Esta macro no se puede ejecutar sola
If Thiscomponent.HasLocation = false then : Msgbox (T_Txt(24),0+48+0, Extension) : Exit Sub : End If 'Primero guarda el documento.
If Imagenes.F_Prueba_Sel = 0 Then : Exit Sub : End If
If Ultima_Tbl < 0 Then : Dlg_Mostrado = False : Msgbox (T_txt(25), 0+48+0, Extension) : Exit Sub : End If 'si se borran todas las tablas
Ultima_Tbl = oTablas.getCount -1
oTabla = oTablas.getbyIndex(Indice_Tbl)
vCursor.gotoRange(oTabla.Anchor,False)
With oDlg.getModel
' oDlg.TiTle = T_Txt(0)
.getByName("Lbl_NombreT").Label = T_Txt(1)
.getByName("Lbl_EstiloT").Label = T_Txt(2)
.getByName("Fr_Tipo").Label = T_Txt(3)
.getByName("Opt_Datos").Label = T_Txt(4)
.getByName("Opt_Distribucion").Label = T_Txt(5)
.getByName("Lbl_Info").Label = T_Txt(6)
.getByName("Btn_Anterior").Label = T_Txt(7)
.getByName("Btn_Optimizar").Label = T_Txt(8)
.getByName("Btn_Siguiente").Label = T_Txt(10)
.getByName("Btn_Salir").Label = T_Txt(11)
.getByName("Lbl_Nombre").Label = oTabla.Name
.getByName("Lbl_Estilo").Label = oTabla.TableTemplateName
.getbyName("Btn_Optimizar").EnableVisible = True
.getbyName("Lbl_Optimizada").EnableVisible= False
.getbyName("Opt_Datos").State= 0
.getbyName("Opt_Distribucion").State= 0
If Indice_Tbl = 0 then
.getByName("Btn_Anterior").EnableVisible = False
.getByName("Btn_Siguiente").EnableVisible = True
WIth .getByName("Lbl_Ultima")
.EnableVisible = True : .label = T_Txt(13) : .PositionX = 12 : .PositionY = 120
End With
ElseIf Indice_Tbl = Ultima_Tbl then
.getByName("Btn_Siguiente").EnableVisible = False
.getByName("Btn_Anterior").EnableVisible = True
.getByName("Btn_Salir").state = 1
WIth .getByName("Lbl_Ultima")
.EnableVisible = True : .label = T_Txt(12) : .PositionX = 115 : .PositionY = 120
End With
Else
.getByName("Lbl_Ultima").EnableVisible = False
.getByName("Btn_Siguiente").EnableVisible = True
.getByName("Btn_Anterior").EnableVisible = True
.getByName("Btn_Salir").state = 0
End If
end with
End sub
Rem ############
sub OnBtn_Anterior(oEv)
oDlg = oEv.Source.Context
If oTablas.getCount -1 <> Ultima_Tbl Then
Ultima_Tbl = oTablas.getCount -1
Msgbox (T_Txt(18), 0+64+0, Extension )
Indice_Tbl = 0
ElseIf Not Indice_Tbl < 0 then
Indice_Tbl = Indice_Tbl -1
End If
Call Parametros_Tablas
end sub
Rem ############
Sub OnBtn_Siguiente(oEv)
oDlg = oEv.Source.Context
If oTablas.getCount -1 <> Ultima_Tbl Then
Ultima_Tbl = oTablas.getCount -1
Indice_Tbl = 0
Msgbox (T_Txt(18), 0+64+0,Extension )
ElseIf Indice_Tbl < Ultima_Tbl Then
Indice_Tbl = Indice_Tbl + 1
End if
Call Parametros_Tablas
End Sub
Rem ############
Sub OnBtn_Salir(oEv)
Dlg_Mostrado = False
Msgbox (T_Txt(19), 0+64+0, Extension)
End Sub
Rem ############
Sub OnRadioButtons(oEv)
Dim oDlg : oDlg = oEv.Source.Context
If oDlg.getModel.getByName("Opt_Datos").state = 1 Then
oDlg.getModel.getByName("Lbl_Info").label = T_Txt(20) & Chr(13) & T_Txt(22)
Else
oDlg.getModel.getByName("Lbl_Info").label = T_Txt(21) & Chr(13) & T_Txt(22)
End If
End Sub
Rem ############
Sub OnBtn_Optimizar(oEv)
oDlg = oEv.Source.Context
If oDlg.getModel.getByName("Opt_Datos").state = 1 Then
Call optimizar(oTabla,1)
ElseIf oDlg.getModel.getByName("Opt_Distribucion").state = 1 Then
Call optimizar(oTabla,0)
Else
Msgbox (T_Txt(15),, Extension)
End if
oDlg.getModel.getByName("Lbl_Optimizada").label = T_Txt(9)
End sub
Rem ############
Sub Optimizar(tabla,Tipo)
Rem Tabla de datos
With oTabla
Dim nRow as Integer, nCol as Integer, oCell as Object
If Tipo = 1 then
.RelativeWidth = 90
.HoriOrient = 2 'centrada
.RepeatHeadline = True
.HeaderRowCount = 1
.TableBorderDistances.TopDistance = 500
For nRow = 0 To oTabla.getRows().getCount() - 1
For nCol = 0 To oTabla.getColumns().getCount() - 1
oCell = oTabla.getCellByPosition(nCol, nRow)
If nRow = 0 Then
oCell.BackColor = RGB(230,230,230)
Formato_Par(oCell.getText(), "Table Heading")
Else
Formato_Par(oCell.getText(), "Table Contents")
End If
Next
.TableTemplateName = "LO User Guides"
Next
Rem Tabla de contenido
ElseIf Tipo = 0 then
.TableBorderDistances.TopDistance = 0
.TableTemplateName = ""
For nRow = 0 To oTabla.getRows().getCount() - 1
For nCol = 0 To oTabla.getColumns().getCount() - 1
oCell = oTabla.getCellByPosition(nCol, nRow)
Formato_Par(oCell.getText(), "Table Contents")
Next
Next
End If
Rem Comunes
.TableBorderDistances.RightDistance = 0
.TableBorderDistances.LeftDistance = 0
.TableBorderDistances.BottomDistance = 0
.CollapsingBorders = True 'fusionar lineas bordes
.BreakType = 0' Quebrar saltos de página etc
.Split = True
.BottomMargin =200
' .TopMargin = 100
Dim i as Integer, oRows as Object, oRow as Object
For i= 0 to otabla.Rows().count -1
oRow = otabla.getRows().getbyIndex(i)
oRow.IsAutoHeight= True
oRow.Height = 0
Next
End With
oDlg.getModel.getbyname("Btn_Optimizar").enableVisible = False
oDlg.getModel.getbyName("Lbl_Optimizada").EnableVisible= True
End sub
sub pruebaDeprueba
If Tablas.F_PruebaSelec = 0 Then :Exit Sub : End If
vCursor = ThisComponent.CurrentController.getViewCursor()
vCursor.gotoStart(False)
End sub
Rem ############
Function F_PruebaSelec()As Boolean 'Pasar prueba selección
Call L10n.Trad_Tablas
Dim oSel : oSel= ThisComponent.getCurrentSelection
On error goto Errores
If not oSel.supportsService("com.sun.star.text.TextRanges") then
F_PruebaSelec = 0
Msgbox (T_Txt(16), 0+64+0,Extension)
Exit Function
End If
Errores:
if Err = 0 then : F_PruebaSelec = 1 : Exit Function
Elseif Err = 91 then : Msgbox (T_Txt(17), 0+64+0, Extension)
Elseif Err <> 0 then : Msgbox ("Error N." & Err & " Linea n. " & Erl & CHR(13) & CHR(13) & Error, 0+48+0, "Error")
End if
F_PruebaSelec = 0
End Function
Rem ############
Sub Formato_Par(oText, sParStyle As String)
Dim oEnum, oPar
oEnum = oText.createEnumeration()
Do While oEnum.hasMoreElements()
oPar = oEnum.nextElement()
If opar.supportsService("com.sun.star.text.Paragraph") Then
oPar.ParaStyleName = sParStyle
oPar.ParaVertAlignment = 3
End If
Loop
End Sub
REM ================= Fin Tablas ===========================================================
</script:module>
|