[Libreoffice-commits] core.git: 4 commits - sfx2/source solenv/bin starmath/Library_sm.mk starmath/source starmath/util sw/qa writerfilter/source
Miklos Vajna
vmiklos at collabora.co.uk
Wed Apr 15 08:20:08 PDT 2015
sfx2/source/doc/objcont.cxx | 10 +-
solenv/bin/create-tags | 3
starmath/Library_sm.mk | 1
starmath/source/unofilter.cxx | 131 ++++++++++++++++++++++++++++
starmath/util/sm.component | 4
sw/qa/extras/odfexport/odfexport.cxx | 20 ++++
sw/qa/extras/ooxmlimport/data/mathtype.docx |binary
sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 9 +
writerfilter/source/dmapper/OLEHandler.cxx | 19 +++-
9 files changed, 190 insertions(+), 7 deletions(-)
New commits:
commit 0c1434196e4ba0ef97c2f33c2335647410ad5ff8
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Apr 15 16:57:42 2015 +0200
sfx2: silence bogus SfxObjectShell::isTiledRendering() warnings
It's expected that e.g. the basic ide doesn't override these methods.
Change-Id: Ie32002c8416c5c0cd81ddf010fa5156b0698560e
diff --git a/sfx2/source/doc/objcont.cxx b/sfx2/source/doc/objcont.cxx
index 6fdc691..1a5452f 100644
--- a/sfx2/source/doc/objcont.cxx
+++ b/sfx2/source/doc/objcont.cxx
@@ -643,12 +643,14 @@ bool SfxObjectShell::IsModifyPasswordEntered()
return pImp->m_bModifyPasswordEntered;
}
-void SfxObjectShell::libreOfficeKitCallback(SAL_UNUSED_PARAMETER int nType, SAL_UNUSED_PARAMETER const char* pPayload) const {
- SAL_WARN("tiled-rendering", "LOK callback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
+void SfxObjectShell::libreOfficeKitCallback(SAL_UNUSED_PARAMETER int nType, SAL_UNUSED_PARAMETER const char* pPayload) const
+{
+ SAL_INFO("tiled-rendering", "SfxObjectShell::libreOfficeKitCallback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
}
-bool SfxObjectShell::isTiledRendering() const {
- SAL_WARN("tiled-rendering", "LOK callback interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
+bool SfxObjectShell::isTiledRendering() const
+{
+ SAL_INFO("tiled-rendering", "SfxObjectShell::isTiledRendering interface not overridden for SfxObjectShell subclass typeId: " << typeid(*this).name());
return false;
}
commit 791d8b4f1f656a8553c25fe9034ca8a350efaaae
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Apr 15 15:41:11 2015 +0200
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
diff --git a/sw/qa/extras/odfexport/odfexport.cxx b/sw/qa/extras/odfexport/odfexport.cxx
index 3ab9bc7..848bec8 100644
--- a/sw/qa/extras/odfexport/odfexport.cxx
+++ b/sw/qa/extras/odfexport/odfexport.cxx
@@ -49,6 +49,26 @@ public:
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")
diff --git a/sw/qa/extras/ooxmlimport/data/mathtype.docx b/sw/qa/extras/ooxmlimport/data/mathtype.docx
new file mode 100644
index 0000000..bf60f43
Binary files /dev/null and b/sw/qa/extras/ooxmlimport/data/mathtype.docx differ
diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
index bf54c2d..107060f 100644
--- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
+++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx
@@ -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
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index b04c927..328d2d7 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -225,6 +225,10 @@ void OLEHandler::importStream(uno::Reference<uno::XComponentContext> xComponentC
OUString aFilterService;
if (m_sProgId == "Word.Document.12")
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())
return;
@@ -253,8 +257,19 @@ OUString OLEHandler::getCLSID(uno::Reference<uno::XComponentContext> xComponentC
{
OUString aRet;
- if (officecfg::Office::Common::Filter::Microsoft::Import::WinWordToWriter::get(xComponentContext) && m_sProgId == "Word.Document.12")
- aRet = "8BC6B165-B1B2-4EDD-aa47-dae2ee689dd6";
+ // See officecfg/registry/data/org/openoffice/Office/Embedding.xcu.
+ 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;
}
commit bf33f22ff29b6e4f6ea204e7d438cf28a1079392
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Apr 15 15:39:09 2015 +0200
tags: also index officecfg wrappers
Change-Id: I6211762b03bd85a1388027906858020a767f12f6
diff --git a/solenv/bin/create-tags b/solenv/bin/create-tags
index 80377f9..7334936 100755
--- a/solenv/bin/create-tags
+++ b/solenv/bin/create-tags
@@ -29,4 +29,5 @@ $ctags -h "+.hdl.hrc" --langmap=c:+.hrc.src,c++:+.hdl $omnicppoptions \
--languages=-HTML,Java,JavaScript \
-R --append=yes --totals=yes \
$w/UnoApiHeadersTarget/udkapi/normal \
- $w/UnoApiHeadersTarget/offapi/normal
+ $w/UnoApiHeadersTarget/offapi/normal \
+ $w/CustomTarget/officecfg/registry
commit add60d233f70ff56472448bd50b3771f38974c52
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date: Wed Apr 15 14:55:15 2015 +0200
starmath: allow UNO import of MathType
com.sun.star.comp.Math.XMLImporter already handled MathML import, but
MathType was not possible externally.
Change-Id: I5bf7181758a12eeaa576d016d3704a771ac5a8ba
diff --git a/starmath/Library_sm.mk b/starmath/Library_sm.mk
index ce46d77..5358b59 100644
--- a/starmath/Library_sm.mk
+++ b/starmath/Library_sm.mk
@@ -88,6 +88,7 @@ $(eval $(call gb_Library_add_exception_objects,sm,\
starmath/source/tmpdevice \
starmath/source/typemap \
starmath/source/unodoc \
+ starmath/source/unofilter \
starmath/source/unomodel \
starmath/source/utility \
starmath/source/view \
diff --git a/starmath/source/unofilter.cxx b/starmath/source/unofilter.cxx
new file mode 100644
index 0000000..4058609
--- /dev/null
+++ b/starmath/source/unofilter.cxx
@@ -0,0 +1,131 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <memory>
+
+#include <com/sun/star/document/XFilter.hpp>
+#include <com/sun/star/document/XImporter.hpp>
+#include <com/sun/star/uno/XComponentContext.hpp>
+#include <cppuhelper/implbase.hxx>
+#include <sot/storage.hxx>
+#include <tools/stream.hxx>
+#include <unotools/mediadescriptor.hxx>
+#include <unotools/ucbstreamhelper.hxx>
+
+#include <document.hxx>
+#include <mathtype.hxx>
+#include <unomodel.hxx>
+
+using namespace ::com::sun::star;
+
+/// Invokes the MathType importer via UNO.
+class MathTypeFilter : public cppu::WeakImplHelper
+ <
+ document::XFilter,
+ document::XImporter,
+ lang::XServiceInfo
+ >
+{
+ uno::Reference<uno::XComponentContext> m_xContext;
+ uno::Reference<lang::XComponent> m_xDstDoc;
+
+public:
+ MathTypeFilter(const uno::Reference<uno::XComponentContext>& xContext);
+ virtual ~MathTypeFilter();
+
+ // XFilter
+ virtual sal_Bool SAL_CALL filter(const uno::Sequence<beans::PropertyValue>& rDescriptor) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual void SAL_CALL cancel() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XImporter
+ virtual void SAL_CALL setTargetDocument(const uno::Reference<lang::XComponent>& xDoc) throw (lang::IllegalArgumentException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
+
+ // XServiceInfo
+ virtual OUString SAL_CALL getImplementationName() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual sal_Bool SAL_CALL supportsService(const OUString& ServiceName) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+ virtual uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
+};
+
+MathTypeFilter::MathTypeFilter(const uno::Reference< uno::XComponentContext >& rxContext)
+ : m_xContext(rxContext)
+{
+}
+
+MathTypeFilter::~MathTypeFilter()
+{
+}
+
+sal_Bool MathTypeFilter::filter(const uno::Sequence<beans::PropertyValue>& rDescriptor) throw(uno::RuntimeException, std::exception)
+{
+ bool bSuccess = false;
+ utl::MediaDescriptor aMediaDesc(rDescriptor);
+ aMediaDesc.addInputStream();
+ uno::Reference<io::XInputStream> xInputStream;
+ aMediaDesc[utl::MediaDescriptor::PROP_INPUTSTREAM()] >>= xInputStream;
+ std::unique_ptr<SvStream> pStream(utl::UcbStreamHelper::CreateStream(xInputStream));
+ if (pStream)
+ {
+ if (SotStorage::IsStorageFile(pStream.get()))
+ {
+ SvStorageRef aStorage(new SotStorage(pStream.get(), false));
+ // Is this a MathType Storage?
+ if (aStorage->IsStream(OUString("Equation Native")))
+ {
+ if (SmModel* pModel = dynamic_cast<SmModel*>(m_xDstDoc.get()))
+ {
+ SmDocShell* pDocShell = static_cast<SmDocShell*>(pModel->GetObjectShell());
+ OUString aText = pDocShell->GetText();
+ MathType aEquation(aText);
+ bSuccess = aEquation.Parse(aStorage) == 1;
+ if (bSuccess)
+ {
+ pDocShell->SetText(aText);
+ pDocShell->Parse();
+ }
+ }
+ }
+ }
+ }
+ return bSuccess;
+}
+
+void MathTypeFilter::cancel() throw(uno::RuntimeException, std::exception)
+{
+}
+
+void MathTypeFilter::setTargetDocument(const uno::Reference< lang::XComponent >& xDoc) throw(lang::IllegalArgumentException, uno::RuntimeException, std::exception)
+{
+ m_xDstDoc = xDoc;
+}
+
+OUString MathTypeFilter::getImplementationName() throw(uno::RuntimeException, std::exception)
+{
+ return OUString("com.sun.star.comp.Math.MathTypeFilter");
+}
+
+sal_Bool MathTypeFilter::supportsService(const OUString& rServiceName) throw(uno::RuntimeException, std::exception)
+{
+ return cppu::supportsService(this, rServiceName);
+}
+
+uno::Sequence<OUString> MathTypeFilter::getSupportedServiceNames() throw(uno::RuntimeException, std::exception)
+{
+ uno::Sequence<OUString> aRet =
+ {
+ OUString("com.sun.star.document.ImportFilter")
+ };
+ return aRet;
+}
+
+extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* SAL_CALL com_sun_star_comp_Math_MathTypeFilter_get_implementation(uno::XComponentContext* pComponent, uno::Sequence<uno::Any> const&)
+{
+ return cppu::acquire(new MathTypeFilter(pComponent));
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/starmath/util/sm.component b/starmath/util/sm.component
index 2c7507f..2534b0f 100644
--- a/starmath/util/sm.component
+++ b/starmath/util/sm.component
@@ -49,4 +49,8 @@
<implementation name="com.sun.star.comp.Math.XMLSettingsExporter">
<service name="com.sun.star.xml.XMLExportFilter"/>
</implementation>
+ <implementation name="com.sun.star.comp.Math.MathTypeFilter"
+ constructor="com_sun_star_comp_Math_MathTypeFilter_get_implementation">
+ <service name="com.sun.star.document.ImportFilter"/>
+ </implementation>
</component>
More information about the Libreoffice-commits
mailing list