]> source.dussan.org Git - poi.git/commitdiff
more XSLF updates
authorYegor Kozlov <yegor@apache.org>
Fri, 12 Aug 2011 08:16:02 +0000 (08:16 +0000)
committerYegor Kozlov <yegor@apache.org>
Fri, 12 Aug 2011 08:16:02 +0000 (08:16 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1157002 13f79535-47bb-0310-9956-ffa450edef68

build.xml
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFRelation.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlide.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFSlideMaster.java
src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java [new file with mode: 0755]

index 182b88cd7794546059a7c1dad67d63538c059dda..2d9a5cde18960f16fcd2340d3eef1728204e9b8b 100644 (file)
--- a/build.xml
+++ b/build.xml
@@ -664,6 +664,12 @@ under the License.
             <classpath refid="test.scratchpad.classpath"/>
             <syspropertyset refid="junit.properties"/>
             <jvmarg value="${poi.test.locale}"/>
+            <!-- 
+              YK: ensure that JUnit has enough memory to run tests. 
+              Without the line below tests fail on Mac OS X with jdk-1.6.26 
+              and on Windows with jdk-1.5.22 
+            -->
+            <jvmarg value="-Xmx256M"/>            
             <formatter type="plain"/>
             <batchtest todir="${scratchpad.reports.test}">
                 <fileset dir="${scratchpad.src.test}">
index c546d93dfc42f6ad96681a86d359ecf3fdde48bb..10a35dfeeed09cc33c23d31c8814abfd67fb422a 100644 (file)
@@ -107,7 +107,7 @@ public class XSLFRelation extends POIXMLRelation {
          "application/vnd.openxmlformats-officedocument.theme+xml",
          "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme",
          "/ppt/theme/theme#.xml", 
-         null
+         XSLFTheme.class
    );
    
    public static final XSLFRelation VML_DRAWING = new XSLFRelation(
index f864344d7148c9c88950e941d694a861cc869afe..ff4e64d308e51ee9e96e9c1ad4d0a6fd5c1d2b4b 100644 (file)
@@ -23,6 +23,7 @@ import org.apache.poi.openxml4j.opc.PackagePartName;
 import org.apache.poi.openxml4j.opc.TargetMode;
 import org.apache.poi.sl.usermodel.Slide;
 import org.apache.poi.util.Beta;
+import org.apache.poi.util.IOUtils;
 import org.apache.xmlbeans.XmlException;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupShapeProperties;
 import org.openxmlformats.schemas.drawingml.x2006.main.CTGroupTransform2D;
@@ -35,8 +36,10 @@ import org.openxmlformats.schemas.presentationml.x2006.main.CTGroupShapeNonVisua
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlide;
 import org.openxmlformats.schemas.presentationml.x2006.main.SldDocument;
 import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMasterIdListEntry;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideLayoutIdListEntry;
 
 import java.io.IOException;
+import java.io.OutputStream;
 import java.util.List;
 import java.util.regex.Pattern;
 
@@ -135,5 +138,4 @@ public final class XSLFSlide extends XSLFSheet {
     public boolean getFollowMasterBackground(){
         return !_slide.isSetShowMasterSp() || _slide.getShowMasterSp();    
     }
-
 }
index d7c86407a29d82c82b8e1565b83a11682ecbecb7..a0229f90173b370e2d66f503c4aecfa7ae5ab630 100755 (executable)
@@ -52,6 +52,7 @@ import java.util.Map;
  public class XSLFSlideMaster extends XSLFSheet {
        private CTSlideMaster _slide;
     private Map<String, XSLFSlideLayout> _layouts;
+    private XSLFTheme _theme;
 
     XSLFSlideMaster() {
         super();
@@ -87,4 +88,16 @@ import java.util.Map;
         }
         return _layouts.get(name);
     }
+
+    public XSLFTheme getTheme(){
+        if(_theme == null){
+            for (POIXMLDocumentPart p : getRelations()) {
+                if (p instanceof XSLFTheme){
+                    _theme = (XSLFTheme)p;
+                    break;
+                }
+            }
+        }
+        return _theme;
+    }
 }
\ No newline at end of file
diff --git a/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java b/src/ooxml/java/org/apache/poi/xslf/usermodel/XSLFTheme.java
new file mode 100755 (executable)
index 0000000..d107b3a
--- /dev/null
@@ -0,0 +1,87 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+package org.apache.poi.xslf.usermodel;
+
+import org.apache.poi.POIXMLDocumentPart;
+import org.apache.poi.openxml4j.opc.PackagePart;
+import org.apache.poi.openxml4j.opc.PackageRelationship;
+import org.apache.poi.util.Beta;
+import org.apache.poi.util.Internal;
+import org.apache.xmlbeans.XmlException;
+import org.apache.xmlbeans.XmlOptions;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideLayout;
+import org.openxmlformats.schemas.presentationml.x2006.main.SldLayoutDocument;
+import org.openxmlformats.schemas.presentationml.x2006.main.CTSlideMaster;
+import org.openxmlformats.schemas.drawingml.x2006.main.ThemeDocument;
+import org.openxmlformats.schemas.drawingml.x2006.main.CTOfficeStyleSheet;
+import org.openxmlformats.schemas.officeDocument.x2006.relationships.STRelationshipId;
+
+import javax.xml.namespace.QName;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Map;
+import java.util.HashMap;
+
+@Beta
+public class XSLFTheme extends POIXMLDocumentPart {
+    private CTOfficeStyleSheet _theme;
+
+    XSLFTheme() {
+        super();
+        _theme = CTOfficeStyleSheet.Factory.newInstance();
+    }
+
+    public XSLFTheme(PackagePart part, PackageRelationship rel) throws IOException, XmlException {
+        super(part, rel);
+        ThemeDocument doc =
+            ThemeDocument.Factory.parse(getPackagePart().getInputStream());
+        _theme = doc.getTheme();
+    }
+
+
+    public String getName(){
+        return _theme.getName();
+    }
+
+    public void setName(String name){
+        _theme.setName(name);
+    }
+
+    /**
+     * While developing only!
+     */
+    @Internal
+    public CTOfficeStyleSheet getXmlObject() {
+        return _theme;
+    }
+
+    protected final void commit() throws IOException {
+        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
+
+        Map<String, String> map = new HashMap<String, String>();
+        map.put("http://schemas.openxmlformats.org/drawingml/2006/main", "a");
+        xmlOptions.setSaveSuggestedPrefixes(map);
+        xmlOptions.setSaveSyntheticDocumentElement(
+                new QName("http://schemas.openxmlformats.org/drawingml/2006/main", "theme"));
+
+        PackagePart part = getPackagePart();
+        OutputStream out = part.getOutputStream();
+        getXmlObject().save(out, xmlOptions);
+        out.close();
+    }
+
+}
\ No newline at end of file