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.
  • D Offline
    D Offline
    denix56
    wrote on 4 Jul 2016, 10:44 last edited by denix56 7 Apr 2016, 10:51
    #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
    • V Offline
      V Offline
      VRonin
      wrote on 4 Jul 2016, 12:38 last edited by VRonin 7 Apr 2016, 12:38
      #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

      D 1 Reply Last reply 5 Jul 2016, 11:29
      1
      • J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 5 Jul 2016, 05:39 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

        V 1 Reply Last reply 5 Jul 2016, 07:50
        0
        • J jsulm
          5 Jul 2016, 05:39

          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?

          V Offline
          V Offline
          VRonin
          wrote on 5 Jul 2016, 07:50 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
          • V VRonin
            4 Jul 2016, 12:38

            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?

            D Offline
            D Offline
            denix56
            wrote on 5 Jul 2016, 11:29 last edited by denix56 7 May 2016, 11:35
            #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).

            M 1 Reply Last reply 5 Jul 2016, 11:37
            0
            • D denix56
              5 Jul 2016, 11:29

              @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).

              M Offline
              M Offline
              mrjj
              Lifetime Qt Champion
              wrote on 5 Jul 2016, 11:37 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
              • D Offline
                D Offline
                denix56
                wrote on 5 Jul 2016, 13:14 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
                • M Offline
                  M Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on 5 Jul 2016, 13:19 last edited by mrjj 7 May 2016, 13:20
                  #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

                  D 1 Reply Last reply 5 Jul 2016, 14:59
                  1
                  • D Offline
                    D Offline
                    denix56
                    wrote on 5 Jul 2016, 14:57 last edited by denix56 7 May 2016, 15:18
                    #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
                    • M mrjj
                      5 Jul 2016, 13:19

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

                      D Offline
                      D Offline
                      denix56
                      wrote on 5 Jul 2016, 14:59 last edited by denix56 7 May 2016, 15:02
                      #10
                      This post is deleted!
                      1 Reply Last reply
                      0

                      1/10

                      4 Jul 2016, 10:44

                      • Login

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