Kaydet (Commit) 791d8b4f authored tarafından Miklos Vajna's avatar Miklos Vajna

DOCX import: convert MathType to Math if MathTypeToMath is enabled

With this, math equations created by Word <= 2003 and embedded to docx
files can be edited finally. Previously the result was read-only and
opened in an unexpected new window.

Change-Id: I4f9dd1cca4a149959f6151cf9af9242b53190ef5
üst bf33f22f
...@@ -49,6 +49,26 @@ public: ...@@ -49,6 +49,26 @@ public:
return std::find(aBlacklist.begin(), aBlacklist.end(), filename) == aBlacklist.end(); return std::find(aBlacklist.begin(), aBlacklist.end(), filename) == aBlacklist.end();
} }
virtual void preTest(const char* pFilename) SAL_OVERRIDE
{
if (OString(pFilename) == "fdo58949.docx")
{
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(false, pBatch);
pBatch->commit();
}
}
virtual void postTest(const char* pFilename) SAL_OVERRIDE
{
if (OString(pFilename) == "fdo58949.docx")
{
std::shared_ptr<comphelper::ConfigurationChanges> pBatch(comphelper::ConfigurationChanges::create());
officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::set(true, pBatch);
pBatch->commit();
}
}
}; };
DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt") DECLARE_ODFEXPORT_TEST(testFdo38244, "fdo38244.odt")
......
...@@ -2647,6 +2647,15 @@ DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx") ...@@ -2647,6 +2647,15 @@ DECLARE_OOXMLIMPORT_TEST(testFdo87488, "fdo87488.docx")
} }
} }
DECLARE_OOXMLIMPORT_TEST(mathtype, "mathtype.docx")
{
uno::Reference<text::XTextEmbeddedObjectsSupplier> xTextEmbeddedObjectsSupplier(mxComponent, uno::UNO_QUERY);
uno::Reference<container::XIndexAccess> xEmbeddedObjects(xTextEmbeddedObjectsSupplier->getEmbeddedObjects(), uno::UNO_QUERY);
// This failed as the Model property was empty.
auto xModel = getProperty< uno::Reference<lang::XServiceInfo> >(xEmbeddedObjects->getByIndex(0), "Model");
CPPUNIT_ASSERT(xModel->supportsService("com.sun.star.formula.FormulaProperties"));
}
#endif #endif
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
......
...@@ -225,6 +225,10 @@ void OLEHandler::importStream(uno::Reference<uno::XComponentContext> xComponentC ...@@ -225,6 +225,10 @@ void OLEHandler::importStream(uno::Reference<uno::XComponentContext> xComponentC
OUString aFilterService; OUString aFilterService;
if (m_sProgId == "Word.Document.12") if (m_sProgId == "Word.Document.12")
aFilterService = "com.sun.star.comp.Writer.WriterFilter"; aFilterService = "com.sun.star.comp.Writer.WriterFilter";
else if (m_sProgId == "Equation.3")
aFilterService = "com.sun.star.comp.Math.MathTypeFilter";
else
SAL_WARN("writerfilter", "OLEHandler::importStream: unhandled m_sProgId: " << m_sProgId);
if (!m_xInputStream.is() || aFilterService.isEmpty()) if (!m_xInputStream.is() || aFilterService.isEmpty())
return; return;
...@@ -253,8 +257,19 @@ OUString OLEHandler::getCLSID(uno::Reference<uno::XComponentContext> xComponentC ...@@ -253,8 +257,19 @@ OUString OLEHandler::getCLSID(uno::Reference<uno::XComponentContext> xComponentC
{ {
OUString aRet; OUString aRet;
if (officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get(xComponentContext) && m_sProgId == "Word.Document.12") // See officecfg/registry/data/org/openoffice/Office/Embedding.xcu.
aRet = "8BC6B165-B1B2-4EDD-aa47-dae2ee689dd6"; if (m_sProgId == "Word.Document.12")
{
if (officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get(xComponentContext))
aRet = "8BC6B165-B1B2-4EDD-aa47-dae2ee689dd6";
}
else if (m_sProgId == "Equation.3")
{
if (officecfg::Office::Common::Filter::Microsoft::Import::MathTypeToMath::get(xComponentContext))
aRet = "078B7ABA-54FC-457F-8551-6147E776A997";
}
else
SAL_WARN("writerfilter", "OLEHandler::getCLSID: unhandled m_sProgId: " << m_sProgId);
return aRet; return aRet;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment