Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Editing .pptx in Qt

Editing .pptx in Qt

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 4 Posters 3.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • denix56D Offline
    denix56D Offline
    denix56
    wrote on last edited by denix56
    #1

    I have such problem - i am trying to edit slide*.xml in .pptx. I unpack .pptx, then in loop I readline() from .xml file, modify each line ( i am modifying only visble text), and write it to QTemporaryfile. after that i replace source .xml with tempfile (remove source file and QTemporaryFile::copy()). But after zipping powerpoint saying to me that it cannot open file saying something about recovering. I compared source file and modifyed file, the only change is modifyed text. I tried to do that process manually, but everything is working only if i modify source .xml file, replacing it with other file, that contains the same information gives the error, also i tried to setPermissions to the copied tempfile that source file had had, but it did not help.
    How to modify .pptx correctly? Maybe power point .xml have some kind of encrypting? like additionals bytes written in the end?

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2

      No particular "kind of encrypting", just plain old xml.

      then in loop I readline() from .xml file

      I would use the QtXml module here to make the changes, see http://www.qtcentre.org/threads/14392-how-to-modify-the-text-of-node-in-xml-docment

      To identify the problem better I'd ask for two things:

      • using your method and modifying only one xml file then telling powerpoint to recover your file, are all the slides messed up or just the one you modified?
      • If you manually edit the xml does it work?

      also,

      after zipping

      what do you use to zip it?

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      denix56D 1 Reply Last reply
      1
      • jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #3

        I'm not familiar with pptx file format, but is it possible that PowerPoint stores file checksums somewhere in the archive and checks them when loading?

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        VRoninV 1 Reply Last reply
        0
        • jsulmJ jsulm

          I'm not familiar with pptx file format, but is it possible that PowerPoint stores file checksums somewhere in the archive and checks them when loading?

          VRoninV Offline
          VRoninV Offline
          VRonin
          wrote on last edited by
          #4

          @jsulm ISO 29500 does not envisage checksums. You can easily check this is not the case by changing a string inside a slide#.xml and save. The file will work perfectly

          "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
          ~Napoleon Bonaparte

          On a crusade to banish setIndexWidget() from the holy land of Qt

          1 Reply Last reply
          1
          • VRoninV VRonin

            No particular "kind of encrypting", just plain old xml.

            then in loop I readline() from .xml file

            I would use the QtXml module here to make the changes, see http://www.qtcentre.org/threads/14392-how-to-modify-the-text-of-node-in-xml-docment

            To identify the problem better I'd ask for two things:

            • using your method and modifying only one xml file then telling powerpoint to recover your file, are all the slides messed up or just the one you modified?
            • If you manually edit the xml does it work?

            also,

            after zipping

            what do you use to zip it?

            denix56D Offline
            denix56D Offline
            denix56
            wrote on last edited by denix56
            #5

            @VRonin I have tried to use winrar and 7z. Problem is only with slides I modified. If I modify the exciting .xml, everything's ok, but replacing it with file, that comtains same text gives an error.
            I want to modify values of each field, where Cyrillic text was replaced with question marks due to some kind of bug in the program (not mine).

            mrjjM 1 Reply Last reply
            0
            • denix56D denix56

              @VRonin I have tried to use winrar and 7z. Problem is only with slides I modified. If I modify the exciting .xml, everything's ok, but replacing it with file, that comtains same text gives an error.
              I want to modify values of each field, where Cyrillic text was replaced with question marks due to some kind of bug in the program (not mine).

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              hi
              I open one and changed slide1.xml with some text and change it.
              then i zipped it again.
              and power point would just open and show the new text.
              seem to be nothing checks or anything.

              1 Reply Last reply
              0
              • denix56D Offline
                denix56D Offline
                denix56
                wrote on last edited by
                #7

                I have found interesting thing - every xml file, that is created by PowerPoint has some invisible symbols at the beginning, that could not be deleted by editor (like notepad).
                slide1.xml is file generated by the program and slide3.xml - is an original file, i copied text from slide1.xml and replaced text in slide3 with it. Here is a result

                C:\Users\Denis\Documents\apertium-gp-docs\p.GN2aKw\ppt\slides>fc /A slide1.xml slide3.xml
                Comparing files slide1.xml and SLIDE3.XML
                ***** slide1.xml
                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                <p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocumen
                ***** SLIDE3.XML
                <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
                <p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocumen


                1 Reply Last reply
                0
                • mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  that looks like a BOM maker. for utf-8
                  http://stackoverflow.com/questions/4614378/getting-ï-at-the-beginning-of-my-xml-file-after-save

                  denix56D 1 Reply Last reply
                  1
                  • denix56D Offline
                    denix56D Offline
                    denix56
                    wrote on last edited by denix56
                    #9

                    @mrjj Thanks, your answer showed me the right way for my search. there was no BOM in the original file, it appeared there due to my fault :)
                    So, i have solved it finally. There was two problems.
                    First one was encodingof Cyrrilic symbols when I was writing to the temporary file. It can be solved by setting encoding manually.
                    QTextStream stream(&tmpSlide);
                    stream.setCodec(QTextCodec::codecForName("UTF-8"));

                    And the second one - i missed to set the type of archive for 7z
                    It can be solved by adding -tzip to args.

                    1 Reply Last reply
                    2
                    • mrjjM mrjj

                      that looks like a BOM maker. for utf-8
                      http://stackoverflow.com/questions/4614378/getting-ï-at-the-beginning-of-my-xml-file-after-save

                      denix56D Offline
                      denix56D Offline
                      denix56
                      wrote on last edited by denix56
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved