Menu

#57 LibreOfice 5 Impress: Same equation reappears every time with bigger size

v1.0_(example)
closed-fixed
nobody
None
5
2018-05-08
2015-10-07
Rav Bell
No

My system: Arch Linux with LibreOffice 5.0.1.2.0

Bug appears in Impress and Not in Writer

Nature of Bug:
I open a document in Impress and type an equation in TexMaths. I get the equation that I typed. I try to type another equation. After I finish the dialog, I get the previous equation in a larger size. I try one more time, the first equation appears in even more bigger size. This goes on and on. But if I save the document after I get the first equation and close, then reopen and type another equation, I get it fine. Everytime I need a new equation to be typed I have close and reopne the document. This is quite frustrating. I tried to see the workings of the bash script that you have written. The temporary files that it creates like the tex and svg files, always have the latest equation have typed, but some how it is not updated in the document. Could you please look into this bug.

Related

Bugs: #57

Discussion

  • Roland Baudin

    Roland Baudin - 2015-12-20

    I can't reproduce the bug. Could you attach some test document so that I can make some tests ?

     
    • Rav Bell

      Rav Bell - 2015-12-31

      Sorry for the long delay in replying. I updated my arch linux and also libreoffice from 5.0.1.2.0 to 5.0.3.2. After this I cannot reproduce the bug anymore. I have not tried on 5.0.4 yet. It works just fine for now! Thanks for the great software.

       
      • Matthias B.

        Matthias B. - 2016-07-18

        After a upgrade from 5.0.x to 5.1.4.2 on debian 8.5 (Build ID: 1:5.1.4~rc2-2~bpo8+1) this problem has appeared again for me.

         
  • Lee McCuller

    Lee McCuller - 2015-12-27

    I also see this bug running libreoffice 5.0.4 in arch-linux. They do have their own package of the extension but the bug remains after installing the website version. I have a workaround which will make all texmath edits into new objects, leaving the old ones and preventing the aggravating resize.

    It looks to me that there is some issue in the clipboard and selection tricks used to import the object. My workaround is in TexMathsEquations.xba

    ' ================== Current document is an Impress or Draw document ==================
    ElseIf GetDocumentType(oDoc) = "simpress" or GetDocumentType(oDoc) = "sdraw" Then
    
        ' Edit equation: remove old image
        ' If EditEquation Then 
        '  
        '  ' Fill in reference to original shape (used to keep animations and Z index)
        '  Dim oOriginalShape as Variant
        '  Dim oOriginalShapeZOrder as Long
        '  oOriginalShape = oDocCtrl.getSelection().getByIndex(0)
        '  oOriginalShapeZOrder = oOriginalShape.ZOrder
        '  ' oDispatcher.executeDispatch(oDocCtrl.Frame,".uno:Cut","", 0, Array() )
        ' 
        ' End If
    
        ' Import the new image to the clipboard
        ret = ImportGraphicIntoClipboard(ConvertToURL( glb_sTmpPath & "tmpfile." & sEqFormat), sEqFormat, sEqDPI, sEqTransp)
        If ret = FALSE Then Exit Sub
    
        ' Paste image to the current document
        oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
    
        ' Select image
        oGraphic = oDocCtrl.getSelection().getByIndex(0)
    
        ' Set the graphic object name
        oGraphic.Name = sEqname
    
        ' Edit equation: set its position equal to the previous one
        If EditEquation Then
            oGraphic.setPosition(oShapePosition)
    
        ' New equation: Position the image at the center of the visible area
        Else
    
            Dim oPosition as Variant
            oPosition = createUnoStruct( "com.sun.star.awt.Point" ) 
            oPosition.X = oDocCtrl.VisibleArea.X + oDocCtrl.VisibleArea.Width / 2 - (oGraphic.Size.Width*iEqSize/10) / 2
            oPosition.Y = oDocCtrl.VisibleArea.Y + oDocCtrl.VisibleArea.Height / 2  - (oGraphic.Size.Height* iEqSize/10) / 2
            oGraphic.setPosition(oPosition)
    
        End If
    
        ' Scale the image
        oShapeSize = oGraphic.Size
        If EditEquation Then
            oShapeSize.Width = oShapeSize.Width
            oShapeSize.Height = oShapeSize.Height
    
            ' oShapeSize.Width = oOriginalShape.Size.Width
            ' oShapeSize.Height = oOriginalShape.Size.Height
        Else
            oShapeSize.Width = oShapeSize.Width * iEqSize / 10
            oShapeSize.Height = oShapeSize.Height * iEqSize / 10
        End If
        oGraphic.Size = oShapeSize
    
        ' Set image attributes (size, type LaTeX code) for further editing
        SetAttributes( oGraphic, iEqSize, sEqType, sEqCode, sEqFormat, sEqDPI, sEqTransp, sEqName)
    
        ' Trick to allow undoing the equation insertion
        oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Cut", "", 0, Array())
        oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
    
        ' Select image
        oGraphic = oDocCtrl.getSelection().getByIndex(0)
    
        ' Edit equation: transfer animations from old shape to new shape
        ' If EditEquation and GetDocumentType(oDoc) = "simpress" Then
        '  TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic)             
        '  TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic) 
        ' End If
    
        ' Preserve Z index of equation
        ' If EditEquation Then
        '  oGraphic.ZOrder = oOriginalShapeZOrder
        ' End If
    
    End If
    

    Somewhat strange that you can not replicated the bug if it was intruduced in libreoffice 5, but maybe there is something unique about arch. I tried to dig around to see if there was any way to import an SVG into the document without having to use the programmatic cut/paste stuff with the selection as is currently but the API semantics for libreoffice are eluding me so far.

     
  • Roland Baudin

    Roland Baudin - 2015-12-27

    Thanks for the patch (and investigation!).
    Anyway, could you send me a test document, so that I could test on Ubuntu and Windows ?
    Does the bug occur with PNG ? What are the version of texlive, dvipng, dvisvgm ?

     
  • Lee McCuller

    Lee McCuller - 2015-12-27

    Hi, my texlive is 2015.37497
    dvipng 1.15
    dvisvgm 1.9.2.

    Huh, well what do you know. I have been running my patched version and I switched back to your distributed version and I cannot trigger the bug now on my version of libreoffice. The minor update from 5.0.2 to 5.0.4 since october must have fixed the bug.

    It previously could be triggered by opening a fresh document, making an "A", then selecting it and changing it to a "B" and the object would be the "A" but much larger. Selecting and editting it again would show that the tex metadata had been updated to a "B" but the svg object would not have been updated and the rescaling code (that my patch adjusts) would make the old object much larger.

    Perhaps the bug should be closed as the new version must have fixed the underlying change...

    thanks for making this extension, it really makes libreoffice way more useful for the sciences.

     
  • Roland Baudin

    Roland Baudin - 2015-12-28

    OK, I'll wait a bit before clossing the bug.
    If you can reproduce it, tell me!

     
  • Nils Becker

    Nils Becker - 2016-08-11

    Hey, I see exactly the same bug on Archlinux running the libreoffice-fresh package. When I switch to an inofficial package of libreoffice (libreoffice-fresh-rpm from the AUR) the bug disappears.

    So I assume it is not strictly related to this extension but rather due to an interaction between texmaths and the way libreoffice is built in the official archlinux package. I will inform the maintainers about it.

     
  • Luca Formaggia

    Luca Formaggia - 2016-08-19

    It happens also on libreoffice 5.2 freshly installed on ubuntu 16.04 using the PPA. Also the version originally shipped with the ubuntu 16.04 distro has the same problem. Very annoying. I will try the workaround.

     
  • Luca Formaggia

    Luca Formaggia - 2016-08-20

    Unfortunately, the workaround does not work for me. It creates a copy of the equation all right but with a much smaller size!

     
  • Nils Becker

    Nils Becker - 2016-08-21

    Okay, as I needed it working right now (and downgrading is always a little bit tricky with archlinux), I fixed it (at least for me). The reason seem to be the dispatcher calls for cutting and pasting (as mentioned by Lee McCuller). Especially the restoration of the initial clipboard at line 900 seem to scramble things.

    The code which is working for me (it replaces the equation at the correct place/size) is below. Pretty sure it breaks the intended Undo/Redo functionality - but I don't care.

    ' ================== Current document is an Impress or Draw document ==================
        ElseIf GetDocumentType(oDoc) = "simpress" or GetDocumentType(oDoc) = "sdraw" Then
    
            ' Edit equation: remove old image
            If EditEquation Then            
                ' Fill in reference to original shape (used to keep animations and Z index)
                Dim oOriginalShape as Variant
                Dim oOriginalShapeZOrder as Long
                oOriginalShape = oDocCtrl.getSelection().getByIndex(0)
                oOriginalShapeZOrder = oOriginalShape.ZOrder
                ' Comment out all clipboard interactions
                ' oDispatcher.executeDispatch(oDocCtrl.Frame,".uno:Cut","", 0, Array() )
                ' Remove original shape...
                ' in a very clumsy way as it seems to be impossible to get the index of the current slide opened in Impress...
                Dim i as Long
                For i = 0 To oDoc.getDrawPages().getCount()-1
                    oDoc.getDrawPages().getByIndex(i).remove(oOriginalShape)
                Next
            End If
    
            ' Import the new image to the clipboard
            ret = ImportGraphicIntoClipboard(ConvertToURL( glb_sTmpPath & "tmpfile." & sEqFormat), sEqFormat, sEqDPI, sEqTransp)
            If ret = FALSE Then Exit Sub
    
            ' Paste image to the current document
            oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
    
            ' Select image
            oGraphic = oDocCtrl.getSelection().getByIndex(0)
    
            ' Set the graphic object name
            oGraphic.Name = sEqname
    
            ' Edit equation: set its position equal to the previous one
            If EditEquation Then
                oGraphic.setPosition(oShapePosition)
    
            ' New equation: Position the image at the center of the visible area
            Else
    
                Dim oPosition as Variant
                oPosition = createUnoStruct( "com.sun.star.awt.Point" ) 
                oPosition.X = oDocCtrl.VisibleArea.X + oDocCtrl.VisibleArea.Width / 2 - (oGraphic.Size.Width*iEqSize/10) / 2
                oPosition.Y = oDocCtrl.VisibleArea.Y + oDocCtrl.VisibleArea.Height / 2  - (oGraphic.Size.Height* iEqSize/10) / 2
                oGraphic.setPosition(oPosition)
    
            End If
    
            ' Scale the image
            oShapeSize = oGraphic.Size
            oShapeSize.Width = oShapeSize.Width * iEqSize / 10
            oShapeSize.Height = oShapeSize.Height * iEqSize / 10
            oGraphic.Size = oShapeSize
    
            ' Set image attributes (size, type LaTeX code) for further editing
            SetAttributes( oGraphic, iEqSize, sEqType, sEqCode, sEqFormat, sEqDPI, sEqTransp, sEqName)
    
            ' Comment out all clipboard interactions
            ' Trick to allow undoing the equation insertion
            ' oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Cut", "", 0, Array())
            ' oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
    
            ' Select image
            oGraphic = oDocCtrl.getSelection().getByIndex(0)
    
            ' Edit equation: transfer animations from old shape to new shape
            If EditEquation and GetDocumentType(oDoc) = "simpress" Then
                TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic)             
                TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic) 
            End If
    
            ' Preserve Z index of equation
            If EditEquation Then
                oGraphic.ZOrder = oOriginalShapeZOrder
            End If
    
        End If
    
        ' Comment out all clipboard interactions
        ' If Writer is installed, restore initial clipboard content
        ' If Not (getGUIType() = 1 And sVersion = "5") Then ' Doesn't work on Windows with Libreoffice 5.x
        '      If ComponentInstalled( "Writer" ) Then
        '      TextToClipboard(sClipContent)
        '     End If
        '  End If
    

    I bow down to the original programmer. Libreoffice macro programming is the worst thing that has happened to me in a long time. Not because of the horrible syntax but simply because of the lack of documentation.

     
    • Luca Formaggia

      Luca Formaggia - 2016-08-24

      The workaround seems to work! Thank you!! Just for further information to
      the developer, the original version was working incorrectly only in
      Impress, not in the Writer.

      I am using Libreoffice:
      Version: 5.2.0.4
      Build ID: 1:5.2.0~rc4-0ubuntu1~xenial2
      CPU Threads: 4; OS Version: Linux 4.4; UI Render: default;
      Locale: en-US (en_US.UTF-8)

      on an ubuntu 16.04 64bit. texlive, dvipng and dvisvg are the default ones
      that come with the ubuntu distro.

      Best,

      Luca

      On Sun, Aug 21, 2016 at 1:53 PM, Nils Becker ncbecker@users.sf.net wrote:

      Okay, as I needed it working right now (and downgrading is always a little
      bit tricky with archlinux), I fixed it (at least for me). The reason seem
      to be the dispatcher calls for cutting and pasting (as mentioned by Lee
      McCuller). Especially the restoration of the initial clipboard at line 900
      seem to scramble things.

      The code which is working for me (it replaces the equation at the correct
      place/size) is below. Pretty sure it breaks the intended Undo/Redo
      functionality - but I don't care.

      ' ================== Current document is an Impress or Draw document ==================
      ElseIf GetDocumentType(oDoc) = "simpress" or GetDocumentType(oDoc) = "sdraw" Then

          ' Edit equation: remove old image
          If EditEquation Then
              ' Fill in reference to original shape (used to keep animations and Z index)
              Dim oOriginalShape as Variant
              Dim oOriginalShapeZOrder as Long
              oOriginalShape = oDocCtrl.getSelection().getByIndex(0)
              oOriginalShapeZOrder = oOriginalShape.ZOrder
              ' Comment out all clipboard interactions
              ' oDispatcher.executeDispatch(oDocCtrl.Frame,".uno:Cut","", 0, Array() )
              ' Remove original shape...
              ' in a very clumsy way as it seems to be impossible to get the index of the current slide opened in Impress...
              Dim i as Long
              For i = 0 To oDoc.getDrawPages().getCount()-1
                  oDoc.getDrawPages().getByIndex(i).remove(oOriginalShape)
              Next
          End If
      
          ' Import the new image to the clipboard
          ret = ImportGraphicIntoClipboard(ConvertToURL( glb_sTmpPath & "tmpfile." & sEqFormat), sEqFormat, sEqDPI, sEqTransp)
          If ret = FALSE Then Exit Sub
      
          ' Paste image to the current document
          oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
      
          ' Select image
          oGraphic = oDocCtrl.getSelection().getByIndex(0)
      
          ' Set the graphic object name
          oGraphic.Name = sEqname
      
          ' Edit equation: set its position equal to the previous one
          If EditEquation Then
              oGraphic.setPosition(oShapePosition)
      
          ' New equation: Position the image at the center of the visible area
          Else
      
              Dim oPosition as Variant
              oPosition = createUnoStruct( "com.sun.star.awt.Point" )
              oPosition.X = oDocCtrl.VisibleArea.X + oDocCtrl.VisibleArea.Width / 2 - (oGraphic.Size.Width*iEqSize/10) / 2
              oPosition.Y = oDocCtrl.VisibleArea.Y + oDocCtrl.VisibleArea.Height / 2  - (oGraphic.Size.Height* iEqSize/10) / 2
              oGraphic.setPosition(oPosition)
      
          End If
      
          ' Scale the image
          oShapeSize = oGraphic.Size
          oShapeSize.Width = oShapeSize.Width * iEqSize / 10
          oShapeSize.Height = oShapeSize.Height * iEqSize / 10
          oGraphic.Size = oShapeSize
      
          ' Set image attributes (size, type LaTeX code) for further editing
          SetAttributes( oGraphic, iEqSize, sEqType, sEqCode, sEqFormat, sEqDPI, sEqTransp, sEqName)
      
          ' Comment out all clipboard interactions
          ' Trick to allow undoing the equation insertion
          ' oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Cut", "", 0, Array())
          ' oDispatcher.executeDispatch( oDocCtrl.Frame, ".uno:Paste", "", 0, Array())
      
          ' Select image
          oGraphic = oDocCtrl.getSelection().getByIndex(0)
      
          ' Edit equation: transfer animations from old shape to new shape
          If EditEquation and GetDocumentType(oDoc) = "simpress" Then
              TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic)
              TransferAnimations(oDocCtrl.getCurrentPage(), oOriginalShape, oGraphic)
          End If
      
          ' Preserve Z index of equation
          If EditEquation Then
              oGraphic.ZOrder = oOriginalShapeZOrder
          End If
      
      End If
      
      ' Comment out all clipboard interactions
      ' If Writer is installed, restore initial clipboard content
      ' If Not (getGUIType() = 1 And sVersion = "5") Then ' Doesn't work on Windows with Libreoffice 5.x
      '      If ComponentInstalled( "Writer" ) Then
      '      TextToClipboard(sClipContent)
      '     End If
      '  End If
      

      I bow down to the original programmer. Libreoffice macro programming is
      the worst thing that has happened to me in a long time. Not because of the
      horrible syntax but simply because of the lack of documentation.


      Status: open
      Group: v1.0_(example)
      Created: Wed Oct 07, 2015 11:48 AM UTC by Rav Bell
      Last Updated: Sat Aug 20, 2016 08:02 PM UTC
      Owner: nobody

      My system: Arch Linux with LibreOffice 5.0.1.2.0

      Bug appears in Impress and Not in Writer

      Nature of Bug:
      I open a document in Impress and type an equation in TexMaths. I get the
      equation that I typed. I try to type another equation. After I finish the
      dialog, I get the previous equation in a larger size. I try one more time,
      the first equation appears in even more bigger size. This goes on and on.
      But if I save the document after I get the first equation and close, then
      reopen and type another equation, I get it fine. Everytime I need a new
      equation to be typed I have close and reopne the document. This is quite
      frustrating. I tried to see the workings of the bash script that you have
      written. The temporary files that it creates like the tex and svg files,
      always have the latest equation have typed, but some how it is not updated
      in the document. Could you please look into this bug.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/texmaths/bugs/57/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

      --
      Luca Formaggia

       

      Related

      Bugs: #57

  • Daniel Blaschke

    Daniel Blaschke - 2016-09-03

    Hi!
    I too experience this bug on Debian 8 (Jessie) with Libreoffice 5.1.5 from backports.
    I did some testing, and see this bug in impress in texmaths versions 0.39, 0.41, and 0.42 but not in 0.37.
    Not sure if it is related, but in writer recompiling equations with texmaths 0.39, 0.41 creates duplicates, in 0.37 it works fine and in 0.42 I cannot edit equations in writer at all because I get the error that the object I just created with techmaths is "not a texmaths equation".
    thanks for the great work!
    cheers, daniel

     
  • Roland Baudin

    Roland Baudin - 2018-05-08
    • status: open --> closed-fixed
     
  • Roland Baudin

    Roland Baudin - 2018-05-08

    Things should be OK now, so I close the bug.

     

Log in to post a comment.