Revert "work"
authorBen Pfaff <blp@cs.stanford.edu>
Thu, 15 May 2025 14:43:38 +0000 (07:43 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Thu, 15 May 2025 14:43:38 +0000 (07:43 -0700)
This reverts commit 0d77a0d0c5eca5666a5bb5c62a8dd69f0ce9d3fe.

rust/pspp/src/output/spv.rs

index f8b0ff22e39289d25bfc31c1d4969d63bf555d8f..df39a7126c07a884de0422449a888df24b6c4054 100644 (file)
@@ -427,6 +427,23 @@ impl Heading {
     }
 }
 
+enum Child {
+    Container(Container),
+    Heading(Box<Heading>),
+}
+
+impl Child {
+    fn emit<W>(&self, writer: &mut XmlWriter<W>) -> IoResult<()>
+    where
+        W: Write,
+    {
+        match self {
+            Child::Container(container) => container.emit(writer),
+            Child::Heading(heading) => heading.emit(writer),
+        }
+    }
+}
+
 fn maybe_with_attribute<'a, 'b, W, I>(
     element: ElementWriter<'a, W>,
     attr: Option<I>,
@@ -454,19 +471,12 @@ impl Container {
     where
         W: Write,
     {
-        let mut element = if !self.content.is_heading() {
-            let mut element = writer
-                .create_element("container")
-                .with_attribute(("visibility", if self.show { "visible" } else { "hidden" }));
-            if self.page_break_before {
-                element = element.with_attribute(("page-break-before", "always"));
-            }
-            element
-        } else {
-            let mut element = writer
-                .create_element("heading")
-                .with_attribute(("visibility", if self.show { "visible" } else { "hidden" }));
-        };
+        let mut element = writer
+            .create_element("container")
+            .with_attribute(("visibility", if self.show { "visible" } else { "hidden" }));
+        if self.page_break_before {
+            element = element.with_attribute(("page-break-before", "always"));
+        }
         element.write_inner_content(|writer| {
             self.label.emit(writer)?;
             self.content
@@ -492,7 +502,6 @@ impl Label {
 }
 
 enum Content {
-    Heading(Vec<Box<Container>>),
     Table(Table),
 }
 
@@ -518,21 +527,6 @@ impl Content {
         );
         element
     }
-
-    fn is_heading(&self) -> bool {
-        match self {
-            Content::Heading(_) => true,
-            _ => false,
-        }
-    }
-
-    fn element_name(&self) -> &'static str {
-        if self.is_heading() {
-            "heading"
-        } else {
-            "container"
-        }
-    }
 }
 
 struct Table {