summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/xmloff/txtparae.hxx2
-rw-r--r--sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odtbin0 -> 10880 bytes
-rw-r--r--sw/qa/extras/odfexport/odfexport.cxx17
-rw-r--r--sw/source/filter/xml/xmltble.cxx9
-rw-r--r--sw/source/filter/xml/xmltexte.hxx6
-rw-r--r--xmloff/source/text/txtparae.cxx4
6 files changed, 37 insertions, 1 deletions
diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index b85f78f1dbfe..7ded21114fd6 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -365,6 +365,8 @@ protected:
const css::uno::Reference< css::beans::XPropertySet> & i_xPortion,
bool i_bAutoStyles, bool i_isProgress, bool & rPrevCharIsSpace);
+ virtual void exportTableAutoStyles();
+
public:
XMLTextParagraphExport(
diff --git a/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt b/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt
new file mode 100644
index 000000000000..21969e9e5485
--- /dev/null
+++ b/sw/qa/extras/odfexport/data/tdf124470TableAndEmbeddedUsedFonts.odt
Binary files differ
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 2d38f8828f0c..bfc17ca284f3 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -2338,5 +2338,22 @@ DECLARE_ODFEXPORT_TEST(tdf121658, "tdf121658.odt")
CPPUNIT_ASSERT_EQUAL(true, getProperty<bool>(xStyle1, "ParaHyphenationNoCaps"));
}
+DECLARE_ODFEXPORT_TEST(tdf124470, "tdf124470TableAndEmbeddedUsedFonts.odt")
+{
+ // Table styles were exported out of place, inside font-face-decls.
+ // Without the fix in place, this will fail already in ODF validation:
+ // "content.xml[2,2150]: Error: tag name "style:style" is not allowed. Possible tag names are: <font-face>"
+
+ CPPUNIT_ASSERT_EQUAL(1, getPages());
+
+ if (xmlDocPtr pXmlDoc = parseExport("content.xml"))
+ {
+ assertXPath(pXmlDoc, "/office:document-content/office:font-face-decls/style:style", 0);
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='table']", 1);
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='table-column']", 2);
+ assertXPath(pXmlDoc, "/office:document-content/office:automatic-styles/style:style[@style:family='paragraph']", 1);
+ }
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/filter/xml/xmltble.cxx b/sw/source/filter/xml/xmltble.cxx
index bef72a6f5357..80d786d8d884 100644
--- a/sw/source/filter/xml/xmltble.cxx
+++ b/sw/source/filter/xml/xmltble.cxx
@@ -1140,6 +1140,13 @@ void SwXMLExport::ExportTable( const SwTableNode& rTableNd )
}
}
+void SwXMLTextParagraphExport::exportTableAutoStyles() {
+ for (const auto* pTableNode : maTableNodes)
+ {
+ static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles(*pTableNode);
+ }
+}
+
void SwXMLTextParagraphExport::exportTable(
const Reference < XTextContent > & rTextContent,
bool bAutoStyles, bool _bProgress )
@@ -1177,7 +1184,7 @@ void SwXMLTextParagraphExport::exportTable(
// ALL flags are set at the same time.
const bool bExportStyles = bool( GetExport().getExportFlags() & SvXMLExportFlags::STYLES );
if ( bExportStyles || !pFormat->GetDoc()->IsInHeaderFooter( aIdx ) )
- static_cast<SwXMLExport&>(GetExport()).ExportTableAutoStyles( *pTableNd );
+ maTableNodes.push_back(pTableNd);
}
else
{
diff --git a/sw/source/filter/xml/xmltexte.hxx b/sw/source/filter/xml/xmltexte.hxx
index 8da021506c0d..4432e4ce0166 100644
--- a/sw/source/filter/xml/xmltexte.hxx
+++ b/sw/source/filter/xml/xmltexte.hxx
@@ -28,6 +28,7 @@
class SwXMLExport;
class SvXMLAutoStylePoolP;
class SwNoTextNode;
+class SwTableNode;
namespace com { namespace sun { namespace star { namespace style {
class XStyle; } } } }
@@ -38,6 +39,9 @@ class SwXMLTextParagraphExport : public XMLTextParagraphExport
const SvGlobalName aPluginClassId;
const SvGlobalName aIFrameClassId;
+ // Collected autostyles for use in exportTextAutoStyles
+ std::vector<const SwTableNode*> maTableNodes;
+
static SwNoTextNode *GetNoTextNode(
const css::uno::Reference < css::beans::XPropertySet >& rPropSet );
@@ -52,6 +56,8 @@ protected:
const css::uno::Reference< css::text::XTextContent > & rTextContent,
bool bAutoStyles, bool bProgress ) override;
+ virtual void exportTableAutoStyles() override;
+
public:
SwXMLTextParagraphExport(
SwXMLExport& rExp,
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 0238e918535d..b830da30579b 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -3671,8 +3671,12 @@ void XMLTextParagraphExport::recordTrackedChangesNoXText()
pRedlineExport->SetCurrentXText();
}
+void XMLTextParagraphExport::exportTableAutoStyles() {}
+
void XMLTextParagraphExport::exportTextAutoStyles()
{
+ exportTableAutoStyles();
+
GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_PARAGRAPH );
GetAutoStylePool().exportXML( XML_STYLE_FAMILY_TEXT_TEXT );