https://bugs.documentfoundation.org/show_bug.cgi?id=171061

Enrico Cora <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |[email protected]

--- Comment #1 from Enrico Cora <[email protected]> ---
Created attachment 205837
  --> https://bugs.documentfoundation.org/attachment.cgi?id=205837&action=edit
SNAP LINES TO REMOVE MANUALLY IN DRAW

3 Macros tested to remove all snap lines, but fails all.

Sub DELETE_GUIDELINES0
'RimuoviTutteLeLineeGuida
    Dim oDoc As Object
    Dim oDrawPage As Object
    Dim oSnapLines As Object
    Dim i As Integer

    ' Ottieni il documento e la pagina corrente
    oDoc = ThisComponent
    oDrawPage = oDoc.CurrentController.CurrentPage
    oSnapLines = oDrawPage.getSnapLines()

    ' Rimuovi le linee partendo dall'ultima (per non sballare l'indice)
    If oSnapLines.getCount() > 0 Then
        For i = oSnapLines.getCount() - 1 To 0 Step -1
            oSnapLines.removeByIndex(i)
        Next i
        MsgBox "Tutte le linee guida sono state rimosse.", 64, "Operazione
Completata"
    Else
        MsgBox "Nessuna linea guida trovata nella pagina.", 48, "Attenzione"
    End If
End Sub
'
Sub DELETE_GUIDELINES1
    Dim oDoc As Object
    Dim oDrawPage As Object
    Dim oSnapLines As Object
    Dim i As Integer

    On Error Resume Next
    oDoc = ThisComponent

    ' Accede alla pagina di disegno visualizzata al momento
    oDrawPage = oDoc.CurrentController.CurrentPage

    ' Utilizza la proprietà SnapLines direttamente
    oSnapLines = oDrawPage.SnapLines

    If Not IsNull(oSnapLines) Then
        If oSnapLines.getCount() > 0 Then
            ' Rimuove le linee partendo dall'ultima per evitare errori di
indice
            For i = oSnapLines.getCount() - 1 To 0 Step -1
                oSnapLines.removeByIndex(i)
            Next i
            MsgBox "Tutte le linee guida sono state rimosse con successo.", 64,
"Fine Operazione"
        Else
            MsgBox "Nessuna linea guida rilevata in questa pagina.", 48, "Info"
        End If
    Else
        MsgBox "Impossibile accedere alle linee guida su questa pagina.", 16,
"Errore"
    End If
End Sub
'
Sub DELETE_GUIDELINES2
    Dim oDoc As Object
    Dim oPage As Object
    Dim oSnapLines As Object
    Dim i As Long

    oDoc = ThisComponent

    ' Verifichiamo che siamo in un documento che supporta le pagine di disegno
    If Not HasUnoInterfaces(oDoc, "com.sun.star.drawing.XDrawPagesSupplier")
Then
        MsgBox "Questo comando funziona solo in LibreOffice Draw.", 16, "Errore
Documento"
        Exit Sub
    End If

    ' Puntiamo alla pagina corrente
    oPage = oDoc.CurrentController.CurrentPage

    ' Proviamo ad accedere alle SnapLines tramite il metodo standard UNO
    On Error Resume Next
    oSnapLines = oPage.getSnapLines()
    On Error GoTo 0

    If IsNull(oSnapLines) Or IsEmpty(oSnapLines) Then
        MsgBox "Errore: Impossibile trovare il contenitore delle linee guida.",
16, "Errore API"
        Exit Sub
    End If

    ' Se ci sono linee, le eliminiamo
    If oSnapLines.getCount() > 0 Then
        For i = oSnapLines.getCount() - 1 To 0 Step -1
            oSnapLines.removeByIndex(i)
        Next i
        MsgBox "Tutte le linee guida rimosse con successo.", 64, "Successo"
    Else
        MsgBox "Nessuna linea guida presente in questa pagina.", 48, "Info"
    End If
End Sub

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to