diff options
author | Tamás Zolnai <tamas.zolnai@collabora.com> | 2018-11-10 18:57:26 +0100 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2018-12-10 12:12:52 +0100 |
commit | 1a5b2d2b6f28ec33c5e100fbc5b0c3438df6b006 (patch) | |
tree | 7d140891da23f8d46915e08febf229f52d501385 | |
parent | 89161e4d5835b93f0942e960a116a0d3863cc55c (diff) |
Introduce client-server message for requesting the selected shape as SVG
It works for Impress only now.
Change-Id: I95e3e37ae7df49b567108f6d6467038b715e886d
-rw-r--r-- | desktop/qa/desktop_lib/test_desktop_lib.cxx | 3 | ||||
-rw-r--r-- | desktop/source/lib/init.cxx | 38 | ||||
-rw-r--r-- | filter/source/svg/svgfilter.cxx | 1 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.h | 5 | ||||
-rw-r--r-- | include/LibreOfficeKit/LibreOfficeKit.hxx | 9 |
5 files changed, 55 insertions, 1 deletions
diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 057a228d2e6b..b62986ec8d81 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -2522,9 +2522,10 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(43), offsetof(struct _LibreOfficeKitDocumentClass, insertCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(44), offsetof(struct _LibreOfficeKitDocumentClass, addCertificate)); CPPUNIT_ASSERT_EQUAL(documentClassOffset(45), offsetof(struct _LibreOfficeKitDocumentClass, getSignatureState)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), offsetof(struct _LibreOfficeKitDocumentClass, renderShapeSelection)); // Extending is fine, update this, and add new assert for the offsetof the // new method - CPPUNIT_ASSERT_EQUAL(documentClassOffset(46), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(47), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 178562574a30..311ff63e7eab 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -120,6 +120,7 @@ #include <unotools/mediadescriptor.hxx> #include <unotools/pathoptions.hxx> #include <unotools/tempfile.hxx> +#include <unotools/streamwrap.hxx> #include <osl/module.hxx> #include <comphelper/sequence.hxx> #include <sfx2/sfxbasemodel.hxx> @@ -750,6 +751,8 @@ static bool doc_addCertificate(LibreOfficeKitDocument* pThis, static int doc_getSignatureState(LibreOfficeKitDocument* pThis); +static void doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char*& pOutput, size_t& nOutputSize); + LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) : mxComponent(xComponent) { @@ -812,6 +815,8 @@ LibLODocument_Impl::LibLODocument_Impl(const uno::Reference <css::lang::XCompone m_pDocumentClass->addCertificate = doc_addCertificate; m_pDocumentClass->getSignatureState = doc_getSignatureState; + m_pDocumentClass->renderShapeSelection = doc_renderShapeSelection; + gDocumentClass = m_pDocumentClass; } pClass = m_pDocumentClass.get(); @@ -2600,6 +2605,39 @@ static void doc_postWindowKeyEvent(LibreOfficeKitDocument* /*pThis*/, unsigned n } } +static void doc_renderShapeSelection(LibreOfficeKitDocument* pThis, char*& pOutput, size_t& nOutputSize) +{ + SolarMutexGuard aGuard; + if (gImpl) + gImpl->maLastExceptionMsg.clear(); + + std::cout << "doc_renderShapeSelection" << std::endl; + + LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis); + + uno::Reference<frame::XStorable> xStorable(pDocument->mxComponent, uno::UNO_QUERY_THROW); + + SvMemoryStream aOutStream; + uno::Reference < io::XOutputStream > xOut = new utl::OOutputStreamWrapper( aOutStream ); + + utl::MediaDescriptor aMediaDescriptor; + aMediaDescriptor["FilterName"] <<= OUString("impress_svg_Export"); + aMediaDescriptor["SelectionOnly"] <<= true; + aMediaDescriptor["OutputStream"] <<= xOut; + + xStorable->storeToURL("private:stream", aMediaDescriptor.getAsConstPropertyValueList()); + + + size_t nStreamSize = aOutStream.GetEndOfData(); + char* pTmp = pOutput; + pOutput = new char[nOutputSize + nStreamSize]; + std::memcpy(pOutput, pTmp, nOutputSize); + std::memcpy(pOutput+nOutputSize, aOutStream.GetData(), nStreamSize); + + nOutputSize += nStreamSize; + delete [] pTmp; +} + /** Class to react on finishing of a dispatched command. This will call a LOK_COMMAND_FINISHED callback when postUnoCommand was diff --git a/filter/source/svg/svgfilter.cxx b/filter/source/svg/svgfilter.cxx index cba3d3210ad9..2ce0c1be2919 100644 --- a/filter/source/svg/svgfilter.cxx +++ b/filter/source/svg/svgfilter.cxx @@ -120,6 +120,7 @@ sal_Bool SAL_CALL SVGFilter::filter( const Sequence< PropertyValue >& rDescripto { // #i124608# extract single selection wanted from dialog return values rDescriptor[nInd].Value >>= bSelectionOnly; + bPageProvided = false; } else if (rDescriptor[nInd].Name == "PagePos") { diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index eecadf745b97..a3241b940a65 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -335,6 +335,11 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getSignatureState(). int (*getSignatureState) (LibreOfficeKitDocument* pThis); + /// @see lok::Document::renderShapeSelection + void (*renderShapeSelection) (LibreOfficeKitDocument* pThis, + char*& pOutput, + size_t& nOutputSize); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 10d3a24a4711..615ea7229e79 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -591,6 +591,15 @@ public: return mpDoc->pClass->getSignatureState(mpDoc); } + /** + * Gets an image of the selected shapes. + * + */ + void renderShapeSelection(char*& pOutput, size_t& nOutputSize) + { + mpDoc->pClass->renderShapeSelection(mpDoc, pOutput, nOutputSize); + } + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; |