summaryrefslogtreecommitdiff
path: root/userguides/sanitycheck/SanityCheck/Tablas.xba
blob: 3c6a209b676c9ee786196fc1977e0fb7aff828d8 (plain)
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  = &quot;Revisiones v 1.0.0&quot; 
 Global oTablas as Object
 Global oTabla as Object
 Global vCursor as Object
 Dim oDlg as Object
 &apos;Dim Dlg_Activo as Boolean &apos;dlg No modal evita ejecuciones múltiples
&apos; Dim Dlg_Mostrado as Boolean &apos; dlg No modal para cerrar el diálogo
 Global Indice_Tbl as Integer
 Dim Ultima_Tbl as integer

 Rem ############
Sub DlgTablas&apos;(oTabla)

 Dim Dlg As Object
 &apos;  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 &apos; 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 &lt; 0 Then : Msgbox (T_Txt(14), 0+48+0,Extension) : Exit Sub  : End If &apos; 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(&quot;SanityCheck&quot;)
     oDlg = CreateUnoDialog(DialogLibraries.getByName(&quot;SanityCheck&quot;).getByName(&quot;DlgTablas&quot;))
     Dlg_Activo = True
     Dlg_Mostrado = True
     oDlg.Model.PositionX = 530
     oDlg.Model.PositionY = 60
&apos;     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 &apos;Esta macro no se puede ejecutar sola
   If  Thiscomponent.HasLocation = false then : Msgbox (T_Txt(24),0+48+0, Extension) : Exit Sub : End If &apos;Primero guarda el documento.
   If Imagenes.F_Prueba_Sel = 0 Then : Exit Sub : End If
   If Ultima_Tbl &lt; 0 Then : Dlg_Mostrado = False : Msgbox (T_txt(25), 0+48+0, Extension) : Exit Sub : End If   &apos;si se borran todas las tablas

   Ultima_Tbl = oTablas.getCount -1

   oTabla = oTablas.getbyIndex(Indice_Tbl)
   vCursor.gotoRange(oTabla.Anchor,False)

With oDlg.getModel
&apos;     oDlg.TiTle = T_Txt(0)
	.getByName(&quot;Lbl_NombreT&quot;).Label = T_Txt(1)
	.getByName(&quot;Lbl_EstiloT&quot;).Label = T_Txt(2)
	.getByName(&quot;Fr_Tipo&quot;).Label = T_Txt(3)
	.getByName(&quot;Opt_Datos&quot;).Label = T_Txt(4)
	.getByName(&quot;Opt_Distribucion&quot;).Label = T_Txt(5)
	.getByName(&quot;Lbl_Info&quot;).Label = T_Txt(6)
	.getByName(&quot;Btn_Anterior&quot;).Label = T_Txt(7)
	.getByName(&quot;Btn_Optimizar&quot;).Label = T_Txt(8)
	.getByName(&quot;Btn_Siguiente&quot;).Label = T_Txt(10)
	.getByName(&quot;Btn_Salir&quot;).Label = T_Txt(11)
	.getByName(&quot;Lbl_Nombre&quot;).Label = oTabla.Name 
	.getByName(&quot;Lbl_Estilo&quot;).Label = oTabla.TableTemplateName
    .getbyName(&quot;Btn_Optimizar&quot;).EnableVisible = True
    .getbyName(&quot;Lbl_Optimizada&quot;).EnableVisible= False
    .getbyName(&quot;Opt_Datos&quot;).State= 0
    .getbyName(&quot;Opt_Distribucion&quot;).State= 0
    
   If Indice_Tbl = 0 then
      .getByName(&quot;Btn_Anterior&quot;).EnableVisible = False
      .getByName(&quot;Btn_Siguiente&quot;).EnableVisible = True
       WIth .getByName(&quot;Lbl_Ultima&quot;)
        .EnableVisible = True : .label = T_Txt(13) : .PositionX = 12 : .PositionY = 120
       End With
   ElseIf Indice_Tbl = Ultima_Tbl then
      .getByName(&quot;Btn_Siguiente&quot;).EnableVisible = False
      .getByName(&quot;Btn_Anterior&quot;).EnableVisible = True
      .getByName(&quot;Btn_Salir&quot;).state = 1
      WIth .getByName(&quot;Lbl_Ultima&quot;)
       .EnableVisible = True : .label = T_Txt(12) : .PositionX = 115 : .PositionY = 120
      End With
   Else
      .getByName(&quot;Lbl_Ultima&quot;).EnableVisible = False
      .getByName(&quot;Btn_Siguiente&quot;).EnableVisible = True
      .getByName(&quot;Btn_Anterior&quot;).EnableVisible = True
      .getByName(&quot;Btn_Salir&quot;).state = 0
   End If
end with

End sub

 Rem ############
sub OnBtn_Anterior(oEv)

   oDlg = oEv.Source.Context
   If oTablas.getCount -1 &lt;&gt; Ultima_Tbl Then
     Ultima_Tbl = oTablas.getCount -1
     Msgbox (T_Txt(18), 0+64+0, Extension )
     Indice_Tbl = 0
   ElseIf Not Indice_Tbl &lt; 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 &lt;&gt; Ultima_Tbl Then 
     Ultima_Tbl = oTablas.getCount -1
     Indice_Tbl = 0 
     Msgbox (T_Txt(18), 0+64+0,Extension )
   ElseIf Indice_Tbl &lt; 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(&quot;Opt_Datos&quot;).state = 1 Then 
     oDlg.getModel.getByName(&quot;Lbl_Info&quot;).label = T_Txt(20) &amp; Chr(13) &amp; T_Txt(22)
   Else
     oDlg.getModel.getByName(&quot;Lbl_Info&quot;).label = T_Txt(21) &amp; Chr(13) &amp; T_Txt(22)
   End If
End Sub

 Rem ############
Sub OnBtn_Optimizar(oEv)

  oDlg = oEv.Source.Context
   If oDlg.getModel.getByName(&quot;Opt_Datos&quot;).state = 1 Then
     Call optimizar(oTabla,1)
   ElseIf oDlg.getModel.getByName(&quot;Opt_Distribucion&quot;).state = 1 Then
     Call optimizar(oTabla,0)
   Else 
    Msgbox (T_Txt(15),, Extension)
   End if
   oDlg.getModel.getByName(&quot;Lbl_Optimizada&quot;).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 &apos;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(), &quot;Table Heading&quot;)
         Else
           Formato_Par(oCell.getText(), &quot;Table Contents&quot;)
         End If
       Next
     .TableTemplateName = &quot;LO User Guides&quot;
    Next    
 Rem Tabla de contenido
   ElseIf Tipo = 0 then
     .TableBorderDistances.TopDistance = 0
     .TableTemplateName = &quot;&quot;
     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(), &quot;Table Contents&quot;)
       Next
     Next 
   End If  
 Rem Comunes 
   .TableBorderDistances.RightDistance = 0
   .TableBorderDistances.LeftDistance = 0
   .TableBorderDistances.BottomDistance = 0
   .CollapsingBorders = True &apos;fusionar lineas bordes
   .BreakType = 0&apos; Quebrar saltos de página etc
   .Split = True
   .BottomMargin =200
&apos;   .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(&quot;Btn_Optimizar&quot;).enableVisible = False
   oDlg.getModel.getbyName(&quot;Lbl_Optimizada&quot;).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 &apos;Pasar prueba selección

 Call L10n.Trad_Tablas
 Dim oSel : oSel= ThisComponent.getCurrentSelection
   On error goto Errores
   If not oSel.supportsService(&quot;com.sun.star.text.TextRanges&quot;) 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 &lt;&gt; 0 then : Msgbox (&quot;Error N.&quot; &amp; Err  &amp; &quot;  Linea n. &quot; &amp; Erl &amp; CHR(13)  &amp; CHR(13) &amp; Error, 0+48+0, &quot;Error&quot;)
   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(&quot;com.sun.star.text.Paragraph&quot;) Then
       oPar.ParaStyleName = sParStyle
       oPar.ParaVertAlignment = 3
     End If
   Loop
End Sub

 REM ================= Fin Tablas ===========================================================
</script:module>