diff options
Diffstat (limited to 'userguides/sanitycheck/SanityCheck/Imagenes.xba')
-rw-r--r-- | userguides/sanitycheck/SanityCheck/Imagenes.xba | 550 |
1 files changed, 550 insertions, 0 deletions
diff --git a/userguides/sanitycheck/SanityCheck/Imagenes.xba b/userguides/sanitycheck/SanityCheck/Imagenes.xba new file mode 100644 index 00000000..cc48cb0b --- /dev/null +++ b/userguides/sanitycheck/SanityCheck/Imagenes.xba @@ -0,0 +1,550 @@ +<?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="Imagenes" script:language="StarBasic" script:moduleType="normal">REM ***** BASIC Módulo Imagenes ***** + Option Explicit + + Const Extension as string = "Revisiones v 1.0.0" + Global oImgs as Object + Global oImg as Object + Global vCursor as Object ' CursorVisible + Dim oDlgImgs as Object + Global Dlg_Activo as Boolean 'dlg No modal evita ejecuciones múltiples + Global Dlg_Mostrado as Boolean ' dlg No modal para cerrar el diálogo + Global Indice_Img as Integer + Dim Ultima_Img as integer + Public oProgressBar + Dim PBcounter as Integer + + Rem ############ + Sub DlgImagenes +Msgbox "Comprobar renombrado de imágenes" + Call L10n.Trad_Imagenes + If Thiscomponent.HasLocation = false then : Msgbox (I_Txt(34),0+48+0, Extension) : Exit Sub : End If + If Imagenes.F_Prueba_Sel = 0 Then : Exit Sub : End If + oImgs = ThisComponent.GraphicObjects() + Ultima_Img = oImgs.getCount -1 + If Ultima_Img < 0 Then : Msgbox (I_Txt(39), 0+48+0,Extension) : Exit Sub : End If + Indice_Img = 0 + oImg = oImgs.getbyIndex(Indice_Img) + vCursor = Thiscomponent.CurrentController.getViewCursor() + vCursor.gotoStart(False) + If Dlg_Activo = False then + Dlg_Activo = True + Dlg_Mostrado = True + DialogLibraries.loadLibrary("SanityCheck") + oDlgImgs = CreateUnoDialog(DialogLibraries.getByName("SanityCheck").getByName("DlgImagenes")) + With oDlgImgs.Model() + .TiTle = I_Txt(0): .PositionX = 530: .PositionY = 60: .Step = 1 + .GetByName("Btn_Img_Name").Label = I_Txt(1) + .GetByName("Btn_Ancla").Label = I_Txt(2) + .GetByName("Btn_Desc_Marco").Label = I_Txt(1) + .GetByName("Btn_Editar").Label = I_Txt(3) + .GetByName("Btn_De_Marco").Label = I_Txt(4) + .GetByName("Btn_Recorte").Label = I_Txt(5) + .GetByName("Btn_Anterior").Label = I_Txt(6) + .GetByName("Btn_Siguiente").Label = I_Txt(7) + .GetByName("Btn_Salir").Label = I_Txt(8) + .GetByName("Fr_Marco").Label = I_Txt(10) + .GetByName("Fr_Desc").Label = I_Txt(11) + .GetByName("Lbl_Anclaje").Label = I_Txt(12) + .GetByName("Tx_Ayuda").Text = I_Txt(9) + End With + Call Imagenes.Cargar_Parametros + Do While Dlg_Mostrado = True + Wait 200 + oDlgImgs.SetVisible(True) + Loop + oDlgImgs.dispose + Dlg_Activo= False + End If +end sub + + Rem ############ +Sub Cargar_Parametros + +' Call L10n.Trad_Imagenes + If not Dlg_Mostrado then : Msgbox I_Txt(33),0+48+0, Extension : exit sub: end if + If Imagenes.F_Prueba_Sel = 0 Then : Exit Sub : End If + If Ultima_Img < 0 Then : Dlg_Mostrado = False : Msgbox (I_Txt(35),0+48+0, Extension) : Exit Sub : End If 'si se borran todas las imágenes + Ultima_Img = oImgs.getCount -1 + oImg = oImgs.getbyIndex(Indice_Img) + vCursor.gotoRange(oImg.Anchor,False) + + WITH oDlgImgs.getModel + Dim Img_ancla As String , Recorte as String + Select case oImg.Anchortype + Case 0 : Img_Ancla = I_Txt(13) + Case 1 : Img_Ancla = I_Txt(14) + Case 2 : Img_Ancla = I_Txt(15) + Case 3 : Img_Ancla = I_Txt(16) + Case 4 : Img_Ancla = I_Txt(17) + End select + Dim secuencia + If not isempty(oImg.Anchor.TextFrame) Then + secuencia = split(oImg.Anchor.getText.string,": ", 2)(0) + Else + secuencia = I_Txt(26) + End if + .getByName("Fr_Img").label = I_Txt(18) & Indice_Img +1 & " / " & Ultima_Img + 1 & " (" & secuencia & ")"'oImg.Anchor.gettext().String + .getByName("Tx_Nombre_Img").text = oImg.Name + .getByName("Tx_Desc_Img").TextColor = RGB(0,0,0) ' RESET + .getByName("Tx_Desc_Marco").TextColor = RGB(0,0,0) ' RESET +' .getByName("Btn_Leyendas").EnableVisible = False ' RESET + If Indice_Img = 0 then + .getByName("Btn_Anterior").EnableVisible = False + .getByName("Btn_Siguiente").EnableVisible = True + with .getByName("Lbl_Ultima") + .EnableVisible = True : .label = I_Txt(19) : .PositionX = 70 : .PositionY = 157 + End with + ElseIf Indice_Img = Ultima_Img then + .getByName("Btn_Siguiente").EnableVisible = False + .getByName("Btn_Anterior").EnableVisible = True + .getByName("Btn_Salir").state = 1 + with .getByName("Lbl_Ultima") + .EnableVisible = True : .label = I_Txt(21) : .PositionX = 128 : .PositionY = 157 + 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 + If oImg.AnchorType <> 1 then + .getByName("Lbl_Ancla").TextColor = RGB(200,0,0) + .getByName("Lbl_Ancla").label = Img_Ancla + .getByName("Btn_Ancla").Enabled = True + Else + .getByName("Lbl_Ancla").TextColor = RGB(0,120,0) + .getByName("Lbl_Ancla").label = Img_Ancla + .getByName("Btn_Ancla").Enabled = False + End If + Dim DescMarco As string + If not isempty(oImg.Anchor.TextFrame()) then + DescMarco = oImg.Anchor.TextFrame().Description + Else + DescMarco = "" + End if + Dim oRec : oRec = oImg.GraphicCrop() + If oRec.Right + oRec.Left + oRec.Top + oRec.Bottom <> 0 then + .getByName("Btn_Recorte").EnableVisible = True + .getByName("Lbl_Recorte").TextColor = RGB(200,0,0) + .getByName("Lbl_Recorte").label = I_Txt(22) + Else + .getByName("Btn_Recorte").EnableVisible = False + .getByName("Lbl_Recorte").TextColor = RGB(0,120,0) + .getByName("Lbl_Recorte").label = I_Txt(23) + End if + Dim Aspecto as String, Escala as String + Aspecto = Format(oImg.ActualSize.Width / oImg.ActualSize.Height, "###00.0") + Escala = Format(oImg.Width / oImg.Height, "###00.0") + If Aspecto <> Escala then + .getbyName("Lbl_Escala").label= I_Txt(24) + .getByName("Lbl_Escala").TextColor = RGB(200,0,0) + Else + .getbyName("Lbl_Escala").label = I_Txt(25) + .getByName("Lbl_Escala").TextColor = RGB(0,120,0) + End if + If isEmpty(oImg.Anchor.TextFrame()) then + .getByName("Tx_Desc_Marco").Enabled = False + .getByName("Tx_Desc_Marco").Text = I_Txt(26) + .getByName("Tx_Desc_Img").Text = oImg.Description + .getByName("Btn_Desc_Marco").Enabled = False + .getByName("Btn_De_Marco").Enabled =False + ElseIf Not isEmpty(oImg.Anchor.TextFrame()) then + .getByName("Tx_Desc_Marco").Enabled = True + .getByName("Btn_Desc_Marco").Enabled = True + .getByName("Btn_De_Marco").Enabled = True + .getByName("Tx_Desc_Marco").Text = "" ' RESET + .getByName("Tx_Desc_Img").Text = oImg.Description + .getByName("Tx_Desc_Marco").Text = oImg.Anchor.TextFrame.Description + End If + END WITH +End Sub + + Rem ############ +sub OnBtn_Anterior(oEv) + + oDlgImgs = oEv.Source.Context + If oImgs.getCount -1 <> Ultima_Img Then + Ultima_Img = oImgs.getCount -1 + Msgbox (I_Txt(27), 0+64+0, Extension) + Indice_Img = 0 + ElseIf Not Indice_Img < 0 then + Indice_Img = Indice_Img -1 + End If + Call Imagenes.Cargar_Parametros +end sub + + Rem ############ +Sub OnBtn_Siguiente(oEv) + + oDlgImgs = oEv.Source.Context + If oImgs.getCount -1 <> Ultima_Img Then + Ultima_Img = oImgs.getCount -1 + Indice_Img = 0 + Msgbox (I_Txt(27), 0+64+0, Extension) + ElseIf Indice_Img < Ultima_Img Then + Indice_Img = Indice_Img + 1 + End if + Call Imagenes.Cargar_Parametros +End Sub + + Rem ############ +Sub OnBtn_Salir + Dlg_Mostrado = False + Dlg_Activo = False + Msgbox (I_Txt(28), 0+64+0, Extension) +End Sub + + Rem ############ +Sub OnBtn_Ayuda(oEv) + + oDlgImgs = oEv.Source.Context + With oDlgImgs.getModel + If .Step = 1 then + .Step = 2 + .getByName("Btn_Ayuda").Label = "↫" + Else + .Step = 1 + .getByName("Btn_Ayuda").Label = "?" + End If + End With +End Sub + + Rem ############ +Sub OnTx_Nombre_Img(oEv) + + oDlgImgs = oEv.Source.Context + oDlgImgs.getModel.getByName("Tx_Nombre_Img").TextColor = RGB(120,0,0) +End Sub + + Rem ############ +Sub OnBtn_Cambiar_Nombre_Img(oEv) + +On error goto ERRORES: + oDlgImgs = oEv.Source.Context + If oDlgImgs.getModel.getByName("Tx_Nombre_Img").Text = "" then + Msgbox (I_Txt(30), 0+48+0, "Error") + oDlgImgs.getModel.getByName("Tx_Nombre_Img").Text = oImg.name + Exit Sub + Else + oImg.Name = oDlgImgs.getModel.getByName("Tx_Nombre_Img").Text + oDlgImgs.getModel.getByName("Tx_Nombre_Img").TextColor = RGB(0,120,0) + End If +ERRORES: + If Err = 1 Then + Msgbox (Chr(13) & I_Txt(31), 0+48+0, "Error") + End If +End Sub + + Rem ############ +Sub OnBtn_Ancla(oEv) + + oDlgImgs = oEv.Source.Context + oImg.AnchorType = 1 + With oDlg.getModel + .getByName("Lbl_Ancla").label = I_Txt(14) + .getByName("Lbl_Ancla").TextColor = RGB(0,120,0) + End With +End Sub + + Rem ############ +Sub OnTx_Desc_Marco(oEv) + + oDlgImgs = oEv.Source.Context + oDlgImgs.getModel.getByName("Tx_Desc_Marco").TextColor = RGB(120,0,0) +End Sub + + Rem ############ +Sub OnBtn_Cambiar_Desc_Marco(oEv) + + oDlgImgs = oEv.Source.Context + oImg.Anchor.TextFrame.Description = oDlgImgs.getModel.getByName("Tx_Desc_Marco").Text + oDlgImgs.getModel.getByName("Tx_Desc_Marco").TextColor = RGB(0,120,0) +End Sub + + Rem ############ +Sub OnTx_Desc_Img(oEv) + + oDlgImgs = oEv.Source.Context + oDlgImgs.getModel.getByName("Tx_Desc_Img").TextColor = RGB(120,0,0) +End Sub + + Rem ############ +Sub OnBtn_Cambiar_Desc_Img(oEv) + + oDlgImgs = oEv.Source.Context + oImg.Description = oDlg.getModel.getByName("Tx_Desc_Img").Text + oDlgImgs.getModel.getByName("Tx_Desc_Img").TextColor = RGB(0,120,0) +End Sub + + Rem ############ +Sub OnBtn_Desde_Marco(oEv) + + oDlgImgs = oEv.Source.Context + oImg.Description = oImg.Anchor.TextFrame.Description + oDlgImgs.getModel.getByName("Tx_Desc_Img").Text = oImg.Description + oDlgImgs.getModel.getByName("Tx_Desc_Img").TextColor = RGB(0,120,0) +End Sub + + Rem ############ +Sub OnBtn_Editar_pulsado(oEv) + + oDlgImgs = oEv.Source.Context + Dim Miimagen : Miimagen = ThisComponent.GraphicObjects.getbyName(oimg.name) + ThisComponent.getCurrentController.select(Miimagen) +End Sub + + Rem ############ +Sub OnBtn_Editar_soltado(oEv) + + oDlgImgs = oEv.Source.Context + Dim Document as Object, Dispatcher as Object + Document = ThisComponent.Currentcontroller.Frame + Dispatcher = CreateUnoService("com.sun.star.frame.DispatchHelper") + Dispatcher.executeDispatch(document, ".uno:ExternalEdit", "", 0, Array()) +End Sub + + Rem ############ +Function F_Ajuste_Imagenes_Marcos + Rem + Rem + Rem ====================================================== + + Call L10n.Trad_Imagenes + + If Not Thiscomponent.HasLocation then : Msgbox (I_Txt(34),0+48+0,Extension ) : Exit Function : End If + REM 1º: Formato de imagen (Obligatorio antes de formato marcos) + Dim i as integer + Static s as String + oImgs = ThisComponent.GraphicObjects() + If oImgs.getCount = 0 Then : Msgbox (I_Txt(39), 0+48+0, Extension) : Exit Function : End If + + oProgressBar = ThisComponent.CurrentController.getStatusIndicator() + oProgressBar.start( I_Txt(32), oImgs.Count * 2 ) + oProgressBar.setValue( 1 ) + Pbcounter = 0 + + FOR i = 0 to oImgs.Count-1 + + Wait 2 + pbCounter = pBcounter + 1 + oProgressBar.setValue(pBCounter) + + oImg = oImgs.getByIndex(i) + With oImg + .AnchorType = 1 + .VertOrient = 1 + .VertOrientRelation = 0 + .RelativeHeight = 0 + .RelativeHeightRelation = 0 + .RelativeWidth = 0 + .RelativeWidthRelation = 0 + .getAnchor.ParaStyleName = "Figure" + End With + + If oImg.name = " LibreOfficeLogo" then + if ThisComponent.StyleFamilies.getByName("ParagraphStyles").hasbyName("New Chapter") then + With oImg + .getAnchor.ParaStyleName = "New Chapter" + .Description = "LibreOffice Logo" + .Title = "LibreOffice Logo" + If Comunes.F_LOVersion <= 7.5 then : .Decorative = True : end if + End With + end If + End If + + NEXT + s = I_Txt(40) + s= s & F_Ajuste_Marcos 'Ajuste de marcos y luego Descripciones + Msgbox (s,0+64+0, I_Txt(41)) + F_Ajuste_Imagenes_Marcos = s +End Function + + Rem ############ +Function F_Ajuste_Marcos + + Dim s : Call L10n.Trad_Imagenes + If isEmpty(oProgressBar) then + oProgressBar = ThisComponent.CurrentController.getStatusIndicator() + oProgressBar.start( I_Txt(32), 1 ) + oProgressBar.setValue( 1 ) + Pbcounter = 0 + End if + Dim oFrames as Object, oFrame as Object, oFCursor as Object, i as integer + REM Ajuste Marcos + oFrames = ThisComponent.TextFrames() + FOR i = 0 to oFrames.getcount -1 + wait 2 + pbCounter = pBCounter + 1 + oProgressBar.setValue( pBCounter ) + oFrame = oFrames.getByIndex(i) + With oFrame REM Formato Marco y Descripción + .getAnchor().ParaStyleName = "Figure" REM Estilo de párrafo del Marco + .AnchorType = 1 + .SizeType = 0 + .FrameIsAutomaticHeight = True + .VertOrient = 1 + .IsSyncHeightToWidth = False + .IsSyncWidthToHeight = False + .RelativeHeight = 0 + .RelativeHeightRelation = 0 + .RelativeWidth = 0 + .RelativeWidthRelation = 0 + End With + NEXT + s= s & Chr(13) & I_Txt(42) + Rem Descripción Marcos + Dim oEnum as Object, oPar, oCursor as Object + FOR i = 0 to oFrames.getcount -1 + pbCounter = pBcounter + 1 + oFrame = oFrames.getByIndex(i) + oFCursor = oFrame.Text.createTextCursor() REM Cursor dentro del marco + oEnum = oFrame.Anchor.createEnumeration + oFCursor.gotoStart(False) + oFCursor.goRight(1, True) REM primer carácter (vacío = Objeto) + Rem Marcos de solo texto -Revisión Leyenda y Descripción + IF oFCursor.string <> "" then + oFrame.Description = left(oframe.string,40) & "…" + Rem comentario marco texto + oPar = oEnum.nextElement() + oCursor = oPar.getText().createTextCursorByRange(oPar) + oCursor.gotoStartOfParagraph(False) + Call InsertAnnotation(oPar, oCursor, I_Txt(45)) + Rem MARCOS CON IMÁGENES - Ancho auto, Compruebo leyenda, Formateo para la descripción y avisos + ElSEIF oFCursor.string = "" then + oFrame.Width = 2000 'anchura mínima + oFrame.WidthType = 0'Automático = 0'mínima 2 + if inStr(oframe.string,": ") <> 0 then + oFrame.Description = split(oframe.string,": ", 2)(1) + else + oFCursor.gotoend(False) + oFCursor.gotoStartofParagraph(True) + oFrame.Description = oFcursor.getString + Rem comentario leyenda mal formada + oPar = oEnum.nextElement() + oCursor = oPar.getText().createTextCursorByRange(oPar) + oCursor.gotoEndOfParagraph(False)' Antes start + Call InsertAnnotation(oPar, oCursor, I_Txt(46)) + end if + Rem formato párrafo como Caption + oFCursor.gotoStart(False) REM inicio del marco + oFCursor.goRight(1, False) REM Mismo punto sin selec (asi no borra imagen) + if Not oFCursor.isEndOfParagraph then + oFCursor.String = Chr(13) REM Salto Parrafo y Formato Leyenda + end if + oFCursor.gotoNextParagraph(False) + oFCursor.ParaStyleName ="Caption" + END IF + NEXT + s = s & Chr(13) & I_Txt(43) + Rem Descripciones imágenes y comentarios recortes/escala + Dim oImgs as Object, oImg as Object + Dim oRec As Object, SinRecortes as Integer + Dim Aspecto as Variant, Escala as Variant + oImgs = ThisComponent.GraphicObjects() + For i = 0 to oImgs.getcount -1 + pbCounter = pBcounter + 1 + oImg = oImgs.getByIndex(i) + If Not isEmpty(oImg.anchor.TextFrame) then + oImg.Description = oImg.anchor.TextFrame.Description + oImg.Title = oImg.Description + End If + Rem Imagen recortada + oRec = oImg.GraphicCrop() : SinRecortes = oRec.Right + oRec.Left + oRec.Top + oRec.Bottom + oEnum = oImg.Anchor.createEnumeration + If SinRecortes <> 0 then'Imagen recortada + oPar = oEnum.nextElement() + oCursor = oPar.getText().createTextCursorByRange(oPar) + oCursor.gotoEndOfParagraph(False) ' Antes start + Call InsertAnnotation(oPar, oCursor, I_Txt(47)) + End if + Rem Imagen deformada + Aspecto = Format(oImg.ActualSize.Width / oImg.ActualSize.Height, "###00.0") + Escala = Format(oImg.Width / oImg.Height, "###00.0") + oEnum = oImg.Anchor.createEnumeration + If Aspecto <> Escala And SinRecortes = 0 Then + oPar = oEnum.nextElement() + oCursor = oPar.getText().createTextCursorByRange(oPar) + oCursor.gotoEndOfParagraph(False) ' antes start + Call InsertAnnotation(oPar, oCursor, I_Txt(48)) + End if + Next + s = s & Chr(13) & I_Txt(44) + F_Ajuste_Marcos = s + Rem Descripción del logo + oImg = ThisComponent.GraphicObjects.getByIndex(0) + With oImg + .Name = " LibreOffice Logo" 'espacio la ordena en 1er lugar + .Description = "LibreOffice Logo" + .Title = "LibreOffice Logo" + If Comunes.F_LOVersion <= 7.5 then : .Decorative = True : end if + If ThisComponent.StyleFamilies.getByName("ParagraphStyles").hasbyName("New Chapter") then + .getAnchor.ParaStyleName = "New Chapter" + End if + End With + oProgressbar.end + F_Ajuste_Marcos = s +End Function + + Rem ############ +Function F_Prueba_Sel()As Boolean 'Pasar prueba selección + + Call L10n.Trad_Imagenes + Dim oSel : oSel= ThisComponent.getCurrentSelection + On error goto Errores + If not oSel.supportsService("com.sun.star.text.TextRanges") then + Msgbox (I_Txt(37), 0+0+64,Extension) + F_Prueba_Sel = 0 + Exit Function + End If +Errores: + if Err = 0 then + F_Prueba_Sel = 1 + Exit Function + Elseif Err = 91 then + Msgbox (I_Txt(38), 0+64+0,"Error") + Elseif Err <> 0 then + Msgbox (I_Txt(36) & Err & " Linea n. " & Erl & CHR(13) & CHR(13) & Error, 0+48+0, "Error") + End if + F_Prueba_Sel = 0 +End Function + + Rem ############ +Function F_AlternarLeyenda() + + Call L10n.Trad_Imagenes + If ThisComponent.HasLocation = false then : Msgbox (I_Txt(34),0+48+0,Extension): Exit Function : End If + If Imagenes.F_Prueba_Sel = 0 Then Exit Function + If ThisComponent.TextFrames.Count = 0 Then : Msgbox (I_Txt(53),0+64+0, Extension): Exit Function: End If + If Msgbox (I_Txt(50), 4+48+256, Extension) = 6 Then + Goto SIGUIENTE + else + Msgbox (I_Txt(51), 0+64+0, Extension): Exit Function + End If +SIGUIENTE: + Dim Document as Object, dispatcher as Object + Document = ThisComponent.CurrentController.Frame + Dispatcher = createUnoService("com.sun.star.frame.DispatchHelper") + vCursor = ThisComponent.CurrentController.getViewCursor + Dim oImages : oImages = ThisComponent.GraphicObjects() + Dim oFCursor as Object, oFrame as Variant, i as Integer + For i = 0 to oImages.count - 1 + oImg = oImages.getbyIndex(i) + oFrame = oImg.Anchor.TextFrame() + IF Not isEmpty(oImg.Anchor.TextFrame()) then + oFCursor = oFrame.Text.createTextCursor' Entro en el marco + oFCursor.gotoStart(False) + vcursor.gotoRange(oFCursor,False) + dispatcher.executeDispatch(document, ".uno:MoveDown", "", 0, Array())' End If + End If + Next + Dim marco1 : marco1 = ThisComponent.getTextFrames.getByIndex(0).Anchor + vcursor.gotoRange(marco1,False) + Msgbox (I_Txt(52),0+64+0, Extension) + F_AlternarLeyenda = Chr(13) & I_Txt(52) +End Function + REM ================= Fin Imagenes =========================================================== + + +</script:module>
\ No newline at end of file |