Makefile.fetch | 4 configmgr/source/components.cxx | 4 configure.ac | 20 desktop/qa/data/blank_presentation.odp |binary desktop/qa/data/sheets.ods |binary desktop/qa/desktop_lib/test_desktop_lib.cxx | 144 desktop/source/lib/init.cxx | 89 distro-configs/CPLinux.conf | 1 download.lst | 3 external/Module_external.mk | 1 external/more_fonts/ExternalPackage_karla.mk | 19 external/more_fonts/Module_more_fonts.mk | 2 external/more_fonts/UnpackedTarball_karla.mk | 14 external/noto_font/ExternalPackage_noto.mk | 230 external/noto_font/Makefile | 7 external/noto_font/Module_noto_font.mk | 17 external/noto_font/README | 1 external/noto_font/UnpackedTarball_noto.mk | 14 include/LibreOfficeKit/LibreOfficeKit.h | 2 include/LibreOfficeKit/LibreOfficeKit.hxx | 13 libreofficekit/README | 7 libreofficekit/qa/gtktiledviewer/gtktiledviewer.cxx | 52 oox/source/export/drawingml.cxx | 13 readlicense_oo/license/LICENSE | 26 readlicense_oo/license/LICENSE.fodt | 810 - readlicense_oo/license/LICENSE.html |10032 +++++++++++++++++- sc/qa/unit/tiledrendering/tiledrendering.cxx | 100 sc/source/ui/unoobj/docuno.cxx | 2 sc/source/ui/view/gridwin4.cxx | 10 scp2/source/ooo/file_font_ooo.scp | 8 scp2/source/ooo/module_hidden_ooo.scp | 14 sd/CppunitTest_sd_tiledrendering.mk | 1 sd/inc/Annotation.hxx | 4 sd/qa/unit/tiledrendering/data/tdf105502.odp |binary sd/qa/unit/tiledrendering/data/tdf81754.pptx |binary sd/qa/unit/tiledrendering/tiledrendering.cxx | 251 sd/sdi/drviewsh.sdi | 5 sd/source/core/annotations/Annotation.cxx | 24 sd/source/filter/html/htmlex.cxx | 16 sd/source/ui/annotations/annotationmanager.cxx | 234 sd/source/ui/annotations/annotationmanagerimpl.hxx | 5 sd/source/ui/inc/View.hxx | 3 sd/source/ui/inc/unomodel.hxx | 2 sd/source/ui/remotecontrol/BluetoothServer.cxx | 2 sd/source/ui/remotecontrol/BluetoothServiceRecord.hxx | 2 sd/source/ui/unoidl/unomodel.cxx | 50 setup_native/source/packinfo/package_names.txt | 1 setup_native/source/packinfo/packinfo_office.txt | 15 sfx2/source/appl/macroloader.cxx | 18 sfx2/source/control/dispatch.cxx | 5 sfx2/source/control/unoctitm.cxx | 1 svx/sdi/svx.sdi | 4 sw/inc/format.hxx | 2 sw/inc/ftninfo.hxx | 2 sw/inc/lineinfo.hxx | 2 sw/inc/ndindex.hxx | 2 sw/inc/pagedesc.hxx | 2 sw/inc/section.hxx | 2 sw/inc/tox.hxx | 2 sw/inc/txtatr.hxx | 2 sw/inc/unosett.hxx | 4 sw/inc/unostyle.hxx | 2 sw/inc/usrfld.hxx | 2 sw/source/core/inc/frmtool.hxx | 8 sw/source/core/layout/frmtool.cxx | 6 sw/source/core/text/frmform.cxx | 4 sw/source/uibase/uno/unotxdoc.cxx | 2 67 files changed, 11700 insertions(+), 646 deletions(-)
New commits: commit cf1b71694fc921195b572dd906d71d70b0608044 Author: Katarina Behrens <katarina.behr...@cib.de> Date: Sun Feb 19 23:58:52 2017 +0100 Run macro:// via LOKit Change-Id: I54d3c734d86d4b44e1dfe1ad7728e2f51cd26d53 Reviewed-on: https://gerrit.libreoffice.org/34538 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> (cherry picked from commit e7729f458409f7fef2b7dab752205e3b230acb65) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index eb8017e..0f2d41c 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -112,6 +112,7 @@ public: void testCommentsCalc(); void testCommentsImpress(); void testCommentsCallbacksWriter(); + void testRunMacro(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -151,6 +152,7 @@ public: CPPUNIT_TEST(testCommentsCalc); CPPUNIT_TEST(testCommentsImpress); CPPUNIT_TEST(testCommentsCallbacksWriter); + CPPUNIT_TEST(testRunMacro); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; @@ -2145,6 +2147,19 @@ void DesktopLOKTest::testCommentsCallbacksWriter() comphelper::LibreOfficeKit::setActive(false); } +void DesktopLOKTest::testRunMacro() +{ + LibLibreOffice_Impl aOffice; + bool bGoodMacro, bNonExistentMacro; + + // Tools macros come pre-installed in system share/basic folder, + bGoodMacro = aOffice.m_pOfficeClass->runMacro(&aOffice, OString("macro:///Tools.Debug.ActivateReadOnlyFlag()").getStr()); + CPPUNIT_ASSERT(bGoodMacro); + + bNonExistentMacro = aOffice.m_pOfficeClass->runMacro(&aOffice, OString("macro:///I.Am.Not(There)").getStr()); + CPPUNIT_ASSERT(!bNonExistentMacro); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 46d5aa4..936ca6b 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -40,6 +40,8 @@ #include <com/sun/star/frame/Desktop.hpp> #include <com/sun/star/frame/DispatchResultEvent.hpp> #include <com/sun/star/frame/DispatchResultState.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XSynchronousDispatch.hpp> #include <com/sun/star/frame/XStorable.hpp> #include <com/sun/star/lang/Locale.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -1058,6 +1060,7 @@ static void doc_destroy(LibreOfficeKitDocument *pThis) static void lo_destroy (LibreOfficeKit* pThis); static int lo_initialize (LibreOfficeKit* pThis, const char* pInstallPath, const char* pUserProfilePath); static LibreOfficeKitDocument* lo_documentLoad (LibreOfficeKit* pThis, const char* pURL); +static bool lo_runMacro (LibreOfficeKit* pThis, const char* pURL); static char * lo_getError (LibreOfficeKit* pThis); static void lo_freeError (char* pFree); static LibreOfficeKitDocument* lo_documentLoadWithOptions (LibreOfficeKit* pThis, @@ -1086,6 +1089,7 @@ LibLibreOffice_Impl::LibLibreOffice_Impl() m_pOfficeClass->destroy = lo_destroy; m_pOfficeClass->documentLoad = lo_documentLoad; + m_pOfficeClass->runMacro = lo_runMacro; m_pOfficeClass->getError = lo_getError; m_pOfficeClass->freeError = lo_freeError; m_pOfficeClass->documentLoadWithOptions = lo_documentLoadWithOptions; @@ -1215,6 +1219,90 @@ static LibreOfficeKitDocument* lo_documentLoadWithOptions(LibreOfficeKit* pThis, return nullptr; } +static bool lo_runMacro( LibreOfficeKit* pThis, const char *pURL) +{ + SolarMutexGuard aGuard; + + LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis); + + OUString sURL( pURL, strlen(pURL), RTL_TEXTENCODING_UTF8 ); + if (sURL.isEmpty()) + { + pLib->maLastExceptionMsg = "Macro to run was not provided."; + SAL_INFO("lok", "Macro URL is empty"); + return false; + } + + if (!sURL.startsWith("macro://")) + { + pLib->maLastExceptionMsg = "This doesn't look like macro URL"; + SAL_INFO("lok", "Macro URL is invalid"); + return false; + } + + pLib->maLastExceptionMsg.clear(); + + if (!xContext.is()) + { + pLib->maLastExceptionMsg = "ComponentContext is not available"; + SAL_INFO("lok", "ComponentContext is not available"); + return false; + } + + util::URL aURL; + aURL.Complete = sURL; + + uno::Reference < util::XURLTransformer > xParser( util::URLTransformer::create( xContext ) ); + + if( xParser.is() ) + xParser->parseStrict( aURL ); + + uno::Reference<frame::XDesktop2> xComponentLoader = frame::Desktop::create(xContext); + + if (!xComponentLoader.is()) + { + pLib->maLastExceptionMsg = "ComponentLoader is not available"; + SAL_INFO("lok", "ComponentLoader is not available"); + return false; + } + + xFactory = xContext->getServiceManager(); + + if (xFactory.is()) + { + uno::Reference<frame::XDispatchProvider> xDP; + xSFactory.set(xFactory, uno::UNO_QUERY_THROW); + xDP.set( xSFactory->createInstance("com.sun.star.comp.sfx2.SfxMacroLoader"), uno::UNO_QUERY ); + uno::Reference<frame::XDispatch> xD = xDP->queryDispatch( aURL, OUString(), 0); + + if (!xD.is()) + { + pLib->maLastExceptionMsg = "Macro loader is not available"; + SAL_INFO("lok", "Macro loader is not available"); + return false; + } + + uno::Reference < frame::XSynchronousDispatch > xSyncDisp( xD, uno::UNO_QUERY_THROW ); + uno::Sequence<css::beans::PropertyValue> aEmpty; + css::beans::PropertyValue aErr; + uno::Any aRet; + + aRet = xSyncDisp->dispatchWithReturnValue( aURL, aEmpty ); + aRet >>= aErr; + + if (aErr.Name == "ErrorCode") + { + pLib->maLastExceptionMsg = "An error occured running macro"; + SAL_INFO("lok", "Macro execution terminated with errors"); + return false; + } + + return true; + } + + return false; +} + static void lo_registerCallback (LibreOfficeKit* pThis, LibreOfficeKitCallback pCallback, void* pData) diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 55cff72..da6bba9 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -78,6 +78,8 @@ struct _LibreOfficeKitClass /// @see lok::Office::getVersionInfo(). char* (*getVersionInfo) (LibreOfficeKit* pThis); + + bool (*runMacro) (LibreOfficeKit *pThis, const char* pURL); #endif }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index 46ecb5f..12c0428 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -601,6 +601,19 @@ public: { return mpThis->pClass->getVersionInfo(mpThis); } + + /** + * Run a macro. + * + * Same syntax as on command line is permissible (ie. the macro:// URI forms) + * + * @param pURL macro url to run + */ + + inline bool runMacro( const char* pURL) + { + return mpThis->pClass->runMacro( mpThis, pURL ); + } #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/sfx2/source/appl/macroloader.cxx b/sfx2/source/appl/macroloader.cxx index 3ab011f..1d6c8e0 100644 --- a/sfx2/source/appl/macroloader.cxx +++ b/sfx2/source/appl/macroloader.cxx @@ -154,7 +154,23 @@ uno::Any SAL_CALL SfxMacroLoader::dispatchWithReturnValue( throw (uno::RuntimeException, std::exception) { uno::Any aRet; - loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() ); + ErrCode nErr = loadMacro( aURL.Complete, aRet, GetObjectShell_Impl() ); + + // aRet gets set to a different value only if nErr == ERRCODE_NONE + // Return it in such case to preserve the original behaviour + + // In all other cases (nErr != ERRCODE_NONE), the calling code gets + // the actual error code back + if ( nErr != ERRCODE_NONE ) + { + beans::PropertyValue aErrorCode; + + aErrorCode.Name = "ErrorCode"; + aErrorCode.Value <<= nErr; + + aRet <<= aErrorCode; + } + return aRet; } commit 41ed5f82271e61b1d08e3adf42f0995ac4516600 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Feb 27 09:14:41 2017 +0100 sw: prefix members of SwLayNotify Change-Id: I40df0def8da88ba2c5719508a9df390e1d391fac (cherry picked from commit 74f6850a8ecd839ef76b6eef704fff408d3e639e) diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index 4c8de72..e015957 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -188,14 +188,14 @@ public: class SwLayNotify : public SwFrameNotify { - bool bLowersComplete; + bool m_bLowersComplete; public: SwLayNotify( SwLayoutFrame *pLayFrame ); ~SwLayNotify(); - void SetLowersComplete( bool b ) { bLowersComplete = b; } - bool IsLowersComplete() { return bLowersComplete; } + void SetLowersComplete( bool b ) { m_bLowersComplete = b; } + bool IsLowersComplete() { return m_bLowersComplete; } }; class SwFlyNotify : public SwLayNotify diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index da17ec9..329c081 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -409,7 +409,7 @@ SwFrameNotify::~SwFrameNotify() SwLayNotify::SwLayNotify( SwLayoutFrame *pLayFrame ) : SwFrameNotify( pLayFrame ), - bLowersComplete( false ) + m_bLowersComplete( false ) { } commit 431520fec6525dbc40d4961f3a13ccc7839613b1 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Fri Feb 24 09:12:41 2017 +0100 libreofficekit: adapt README to reality Change-Id: I7098e5c304a0fa945e3d3ba794be2b7932788c74 (cherry picked from commit 28974126aa02d98b1808fd8fc01bc45f9a407a90) diff --git a/libreofficekit/README b/libreofficekit/README index a8396d4..8defd38 100644 --- a/libreofficekit/README +++ b/libreofficekit/README @@ -13,10 +13,9 @@ Integrating LOK into other software LOK functionality can be accessed by including LibreOfficeKit.h[xx] in your program. -LOK initialisation (lok_init) requires the inclusion of LibreOfficeKitInit.h -in your program. Should you be using the C++ LibreOfficeKit.hxx header you -must first include LibreOfficeKitInit.h followed by LibreOfficeKit.hxx in any -files where you need to use lok_cpp_init. +LOK initialisation (lok_init) requires the inclusion of LibreOfficeKitInit.h in +your program. If you use the C++ LibreOfficeKit.hxx header, it already includes +LibreOfficeKitInit.h for you. (LibreOfficeKit.hxx is a simple and fully inlined C++ wrapper for the same functionality as in LibreOfficeKit.h.) commit 3460e65b97bee4f32b79ccb56628dacdda71c4ae Author: Pranav Kant <pran...@collabora.co.uk> Date: Wed Feb 22 19:26:28 2017 +0530 lok: these are not always plain ascii Change-Id: I9783b6b2839805189015dbad8a97128c89e0a4a9 (cherry picked from commit 46b5dff4db336df2ff6496d91b0a2c559c6a9592) diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index f5149af..ba14902 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -1028,7 +1028,7 @@ OUString ScModelObj::getPostIts() std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - return OUString::createFromAscii(aStream.str().c_str()); + return OUString::fromUtf8(aStream.str().c_str()); } void ScModelObj::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& /*rArguments*/) diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 67f4e33..3199294 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2412,7 +2412,7 @@ OUString SdXImpressDocument::getPostIts() std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - return OUString::createFromAscii(aStream.str().c_str()); + return OUString::fromUtf8(aStream.str().c_str()); } void SdXImpressDocument::initializeForTiledRendering(const css::uno::Sequence<css::beans::PropertyValue>& rArguments) diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index 84c286c..b89e6e8 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3277,7 +3277,7 @@ OUString SwXTextDocument::getPostIts() std::stringstream aStream; boost::property_tree::write_json(aStream, aTree); - return OUString::createFromAscii(aStream.str().c_str()); + return OUString::fromUtf8(aStream.str().c_str()); } int SwXTextDocument::getPart() commit 627da0afeaa27f5f5c7227030dccf2e5c460ad32 Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue Feb 21 16:05:02 2017 +0530 sd lok: Support editing annotations by id + unit test Change-Id: Id4faf59eab8c72a2d78157bca15a5e07f9622dde Reviewed-on: https://gerrit.libreoffice.org/34512 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: pranavk <pran...@collabora.co.uk> (cherry picked from commit 1b4ce7cd8e4c1e1732ee6434cadd29cb23583a54) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index d142921..379f2fe 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1647,6 +1647,25 @@ void SdTiledRenderingTest::testCommentCallbacks() CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty()); + // Edit this annotation now + aArgs = comphelper::InitPropertySequence( + { + {"Id", uno::makeAny(OUString::number(nComment1))}, + {"Text", uno::makeAny(OUString("Edited comment"))}, + }); + comphelper::dispatchCommand(".uno:EditAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView1.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView2.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); + CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty()); + CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + // Delete the comment aArgs = comphelper::InitPropertySequence( { diff --git a/sd/sdi/drviewsh.sdi b/sd/sdi/drviewsh.sdi index 0ae6eea..553843a 100644 --- a/sd/sdi/drviewsh.sdi +++ b/sd/sdi/drviewsh.sdi @@ -154,6 +154,11 @@ interface ImpressEditView : DrawView ExecMethod = ExecuteAnnotation; StateMethod = GetAnnotationState; ] + SID_EDIT_POSTIT + [ + ExecMethod = ExecuteAnnotation; + StateMethod = GetAnnotationState; + ] SID_REPLYTO_POSTIT [ ExecMethod = ExecuteAnnotation; diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 2184e0c..d9847a1 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -354,6 +354,9 @@ void AnnotationManagerImpl::ExecuteAnnotation(SfxRequest& rReq ) case SID_DELETEALLBYAUTHOR_POSTIT: ExecuteDeleteAnnotation( rReq ); break; + case SID_EDIT_POSTIT: + ExecuteEditAnnotation( rReq ); + break; case SID_PREVIOUS_POSTIT: case SID_NEXT_POSTIT: SelectNextAnnotation( rReq.GetSlot() == SID_NEXT_POSTIT ); @@ -434,6 +437,41 @@ void AnnotationManagerImpl::ExecuteDeleteAnnotation(SfxRequest& rReq) UpdateTags(); } +void AnnotationManagerImpl::ExecuteEditAnnotation(SfxRequest& rReq) +{ + const SfxItemSet* pArgs = rReq.GetArgs(); + Reference< XAnnotation > xAnnotation; + sal_uInt32 nId = 0; + OUString sText; + if (pArgs) + { + const SfxPoolItem* pPoolItem = nullptr; + if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_ID, true, &pPoolItem)) + { + nId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32(); + xAnnotation = GetAnnotationById(nId); + } + if (SfxItemState::SET == pArgs->GetItemState(SID_ATTR_POSTIT_TEXT, true, &pPoolItem)) + sText = static_cast<const SfxStringItem*>(pPoolItem)->GetValue(); + + if (xAnnotation.is() && !sText.isEmpty()) + { + // TODO: Not allow other authors to change others' comments ? + Reference<XText> xText(xAnnotation->getTextRange()); + xText->setString(sText); + + const SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + lcl_CommentNotification(CommentNotificationType::Modify, pViewShell, xAnnotation); + pViewShell = SfxViewShell::GetNext(*pViewShell); + } + } + } + + UpdateTags(true); +} + void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) { SdPage* pPage = GetCurrentPage(); @@ -719,9 +757,13 @@ void AnnotationManagerImpl::GetAnnotationState(SfxItemSet& rSet) Reference< XAnnotation > xAnnotation; GetSelectedAnnotation( xAnnotation ); - // Don't disable SID_DELETE_POSTIT slot in case of LOK + // Don't disable these slot in case of LOK, as postit doesn't need to + // selected before doing an operation on it in LOK if( (!xAnnotation.is() && !comphelper::LibreOfficeKit::isActive()) || bReadOnly ) + { rSet.DisableItem( SID_DELETE_POSTIT ); + rSet.DisableItem( SID_EDIT_POSTIT ); + } SdPage* pPage = nullptr; diff --git a/sd/source/ui/annotations/annotationmanagerimpl.hxx b/sd/source/ui/annotations/annotationmanagerimpl.hxx index 5cba9ee..339af45 100644 --- a/sd/source/ui/annotations/annotationmanagerimpl.hxx +++ b/sd/source/ui/annotations/annotationmanagerimpl.hxx @@ -66,6 +66,7 @@ public: void ExecuteInsertAnnotation(SfxRequest& rReq); void ExecuteDeleteAnnotation(SfxRequest& rReq); + void ExecuteEditAnnotation(SfxRequest& rReq); void ExecuteReplyToAnnotation(SfxRequest& rReq); void SelectNextAnnotation(bool bForeward); commit 2689793e31a7ab443f44883b17a0e371708066ff Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue Feb 21 15:20:45 2017 +0530 sd lok: Include parthash in annotation list and callbacks ... and update the tests accordingly. Change-Id: Id11f2d19274e743b0e2a0bbeb0c21936f12b7777 (cherry picked from commit ede35e5c693a287f31e3c02d8afd33580e827380) diff --git a/sd/inc/Annotation.hxx b/sd/inc/Annotation.hxx index 39e746c..27f1d51 100644 --- a/sd/inc/Annotation.hxx +++ b/sd/inc/Annotation.hxx @@ -37,6 +37,8 @@ SdrUndoAction* CreateUndoInsertOrRemoveAnnotation( const css::uno::Reference< cs sal_uInt32 getAnnotationId(const css::uno::Reference <css::office::XAnnotation>& xAnnotation); +const SdPage* getAnnotationPage(const css::uno::Reference<css::office::XAnnotation>& xAnnotation); + } #endif diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index c70bdd5..d142921 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1618,6 +1618,8 @@ void SdTiledRenderingTest::testCommentCallbacks() CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), aView2.m_aCommentCallbackResult.get<std::string>("author")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); + CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty()); // Reply to a just added comment SfxLokHelper::setView(nView2); @@ -1642,6 +1644,8 @@ void SdTiledRenderingTest::testCommentCallbacks() CPPUNIT_ASSERT(aReplyTextView1.endsWith("Reply to comment")); CPPUNIT_ASSERT(aReplyTextView2.startsWith("Reply to LOK User1")); CPPUNIT_ASSERT(aReplyTextView2.endsWith("Reply to comment")); + CPPUNIT_ASSERT(!aView1.m_aCommentCallbackResult.get<std::string>("parthash").empty()); + CPPUNIT_ASSERT(!aView2.m_aCommentCallbackResult.get<std::string>("parthash").empty()); // Delete the comment aArgs = comphelper::InitPropertySequence( diff --git a/sd/source/core/annotations/Annotation.cxx b/sd/source/core/annotations/Annotation.cxx index eb64dab..d82ba73 100644 --- a/sd/source/core/annotations/Annotation.cxx +++ b/sd/source/core/annotations/Annotation.cxx @@ -379,6 +379,14 @@ sal_uInt32 getAnnotationId(const Reference<XAnnotation>& xAnnotation) return nId; } +const SdPage* getAnnotationPage(const Reference<XAnnotation>& xAnnotation) +{ + Annotation* pAnnotation = dynamic_cast<Annotation*>(xAnnotation.get()); + if (pAnnotation) + return pAnnotation->GetPage(); + return nullptr; +} + UndoInsertOrRemoveAnnotation::UndoInsertOrRemoveAnnotation( Annotation& rAnnotation, bool bInsert ) : SdrUndoAction( *rAnnotation.GetModel() ) , mxAnnotation( &rAnnotation ) diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index d023770..2184e0c 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -122,13 +122,15 @@ namespace { (nType == CommentNotificationType::Remove ? "Remove" : (nType == CommentNotificationType::Modify ? "Modify" : "???")))); aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); - if (nType != CommentNotificationType::Remove) + if (nType != CommentNotificationType::Remove && rxAnnotation.is()) { aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); aAnnotation.put("author", rxAnnotation->getAuthor()); aAnnotation.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime())); uno::Reference<text::XText> xText(rxAnnotation->getTextRange()); aAnnotation.put("text", xText->getString()); + const SdPage* pPage = sd::getAnnotationPage(rxAnnotation); + aAnnotation.put("parthash", pPage ? OString::number(pPage->GetHashCode()) : OString()); } boost::property_tree::ptree aTree; diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index 958fa25..67f4e33 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2401,6 +2401,7 @@ OUString SdXImpressDocument::getPostIts() aAnnotation.put("dateTime", utl::toISO8601(xAnnotation->getDateTime())); uno::Reference<text::XText> xText(xAnnotation->getTextRange()); aAnnotation.put("text", xText->getString()); + aAnnotation.put("parthash", OUString::number(pPage->GetHashCode())); aAnnotations.push_back(std::make_pair("", aAnnotation)); } commit e75899ee3aaf8ab31787861d3bdd5376e45ca64e Author: Jan Holesovsky <ke...@collabora.com> Date: Mon Feb 20 12:55:19 2017 +0100 Improve readability. Change-Id: Ibbbac458e3ef8b3d02f4d73cd8bf3ac880ff0522 (cherry picked from commit ca5277c1ad181c15ce604077e07935b2de946c7c) diff --git a/sc/source/ui/view/gridwin4.cxx b/sc/source/ui/view/gridwin4.cxx index b26ac76..43a7e56 100644 --- a/sc/source/ui/view/gridwin4.cxx +++ b/sc/source/ui/view/gridwin4.cxx @@ -819,7 +819,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { MapMode aNew = aOrig; - auto aOrigin = aOriginalMode.GetOrigin(); + Point aOrigin = aOriginalMode.GetOrigin(); aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX); aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY); static const double twipFactor = 15 * 1.76388889; // 26.45833335 @@ -893,7 +893,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { - auto aOrigin = aOriginalMode.GetOrigin(); + Point aOrigin = aOriginalMode.GetOrigin(); aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + aOutputData.nScrX); aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + aOutputData.nScrY); const double twipFactor = 15 * 1.76388889; // 26.45833335 @@ -962,7 +962,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI Rectangle aBackground(aStart, aEnd); // Need to draw the background in absolute coords. - auto aOrigin = aOriginalMode.GetOrigin(); + Point aOrigin = aOriginalMode.GetOrigin(); aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScreenX); aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScreenY); aBackground += aOrigin; @@ -1026,7 +1026,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { // Need to draw the background in absolute coords. - auto aOrigin = aOriginalMode.GetOrigin(); + Point aOrigin = aOriginalMode.GetOrigin(); aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX); aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY); aBackground += aOrigin; @@ -1037,7 +1037,7 @@ void ScGridWindow::DrawContent(OutputDevice &rDevice, const ScTableInfo& rTableI if (bIsTiledRendering) { - auto aOrigin = aOriginalMode.GetOrigin(); + Point aOrigin = aOriginalMode.GetOrigin(); aOrigin.setX(aOrigin.getX() / TWIPS_PER_PIXEL + nScrX); aOrigin.setY(aOrigin.getY() / TWIPS_PER_PIXEL + nScrY); static const double twipFactor = 15 * 1.76388889; // 26.45833335 commit c460133d0f2cccc0ba6e2b60dda523e56f14d26e Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue Feb 21 11:05:47 2017 +0530 Revert "sw lok: Move this test to sw/" This reverts commit b7640cbb4b34df2cb05c6fbe60346bca96846924. Not much idea yet but moving it to sw/ for some reason makes callback pertaining to last 'InsertAnnotation' uno command not firing and on ubsan tinderbox even the first 'InsertAnnotation' command is a noOp failing the tests there. Lets keep it in desktop/ for now where it was earlier. Conflicts: desktop/qa/desktop_lib/test_desktop_lib.cxx Change-Id: I67f5bdeffa218ae2a7afe0896f7cdde5324a5f09 (cherry picked from commit 0f6e813827fed1baefe6001b6e9655b0aeedcc46) diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index 896c90d..eb8017e 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -111,6 +111,7 @@ public: void testCommentsWriter(); void testCommentsCalc(); void testCommentsImpress(); + void testCommentsCallbacksWriter(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -149,6 +150,7 @@ public: CPPUNIT_TEST(testCommentsWriter); CPPUNIT_TEST(testCommentsCalc); CPPUNIT_TEST(testCommentsImpress); + CPPUNIT_TEST(testCommentsCallbacksWriter); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; @@ -1736,6 +1738,7 @@ class ViewCallback public: bool m_bTilesInvalidated; Rectangle m_aOwnCursor; + boost::property_tree::ptree m_aCommentCallbackResult; ViewCallback() : m_bTilesInvalidated(false) @@ -1769,6 +1772,14 @@ public: m_aOwnCursor.setHeight(aSeq[3].toInt32()); } break; + case LOK_CALLBACK_COMMENT: + { + m_aCommentCallbackResult.clear(); + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, m_aCommentCallbackResult); + m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment"); + } + break; } } }; @@ -2046,6 +2057,94 @@ void DesktopLOKTest::testCommentsImpress() comphelper::LibreOfficeKit::setActive(false); } +void DesktopLOKTest::testCommentsCallbacksWriter() +{ + comphelper::LibreOfficeKit::setActive(); + // Comments callback are emitted only if tiled annotations are off + comphelper::LibreOfficeKit::setTiledAnnotations(false); + ViewCallback aView1; + ViewCallback aView2; + LibLODocument_Impl* pDocument = loadDoc("comments.odt"); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView1); + pDocument->m_pDocumentClass->createView(pDocument); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, "{}"); + pDocument->m_pDocumentClass->registerCallback(pDocument, &ViewCallback::callback, &aView2); + + // Add a new comment + OString aCommandArgs("{ \"Text\": { \"type\": \"string\", \"value\": \"Additional comment\" }, \"Author\": { \"type\": \"string\", \"value\": \"LOK User1\" } }"); + pDocument->pClass->postUnoCommand(pDocument, ".uno:InsertAnnotation", aCommandArgs.getStr(), false); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id"); + + // Reply to a comment just added + aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment\" } }"; + pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + int nCommentId2 = aView1.m_aCommentCallbackResult.get<int>("id"); + + // Edit the previously added comment + aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId2) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Edited comment\" } }"; + pDocument->pClass->postUnoCommand(pDocument, ".uno:EditAnnotation", aCommandArgs.getStr(), false); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + // parent is unchanged still + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + + // Delete the reply comment just added + aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId2) + "\" } }"; + pDocument->pClass->postUnoCommand(pDocument, ".uno:DeleteComment", aCommandArgs.getStr(), false); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Remove' action + CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nCommentId2, aView1.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id")); + + // Reply to nCommentId1 again + aCommandArgs = "{ \"Id\": { \"type\": \"string\", \"value\": \"" + OString::number(nCommentId1) + "\" }, \"Text\": { \"type\": \"string\", \"value\": \"Reply comment again\" } }"; + pDocument->pClass->postUnoCommand(pDocument, ".uno:ReplyComment", aCommandArgs.getStr(), false); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent")); + CPPUNIT_ASSERT_EQUAL(std::string("Reply comment again"), aView1.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("Reply comment again"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + + // .uno:ViewAnnotations returns total of 5 comments + boost::property_tree::ptree aTree; + char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewAnnotations"); + std::stringstream aStream(pJSON); + free(pJSON); + CPPUNIT_ASSERT(!aStream.str().empty()); + boost::property_tree::read_json(aStream, aTree); + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(5), aTree.get_child("comments").size()); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/tiledrendering/tiledrendering.cxx b/sw/qa/extras/tiledrendering/tiledrendering.cxx index f937fe4..c9829f2 100644 --- a/sw/qa/extras/tiledrendering/tiledrendering.cxx +++ b/sw/qa/extras/tiledrendering/tiledrendering.cxx @@ -81,7 +81,7 @@ public: void testPaintCallbacks(); void testUndoRepairResult(); void testRedoRepairResult(); - void testCommentsCallbacks(); + CPPUNIT_TEST_SUITE(SwTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -126,7 +126,6 @@ public: CPPUNIT_TEST(testPaintCallbacks); CPPUNIT_TEST(testUndoRepairResult); CPPUNIT_TEST(testRedoRepairResult); - CPPUNIT_TEST(testCommentsCallbacks); CPPUNIT_TEST_SUITE_END(); @@ -652,7 +651,6 @@ public: bool m_bViewLock; /// Set if any callback was invoked. bool m_bCalled; - boost::property_tree::ptree m_aCommentCallbackResult; ViewCallback() : m_bOwnCursorInvalidated(false), @@ -759,14 +757,6 @@ public: m_bViewLock = aTree.get_child("rectangle").get_value<std::string>() != "EMPTY"; } break; - case LOK_CALLBACK_COMMENT: - { - m_aCommentCallbackResult.clear(); - std::stringstream aStream(pPayload); - boost::property_tree::read_json(aStream, m_aCommentCallbackResult); - m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment"); - } - break; } } }; @@ -1681,102 +1671,6 @@ void SwTiledRenderingTest::testRedoRepairResult() comphelper::LibreOfficeKit::setActive(false); } -void SwTiledRenderingTest::testCommentsCallbacks() -{ - comphelper::LibreOfficeKit::setActive(); - // Comments callback are emitted only if tiled annotations are off - comphelper::LibreOfficeKit::setTiledAnnotations(false); - - SwXTextDocument* pXTextDocument = createDoc(); - ViewCallback aView1; - SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); - int nView1 = SfxLokHelper::getView(); - - // Crete a second view - SfxLokHelper::createView(); - pXTextDocument->initializeForTiledRendering({}); - ViewCallback aView2; - SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); - - SfxLokHelper::setView(nView1); - - // Add a new comment - uno::Sequence<beans::PropertyValue> aPropertyValues(comphelper::InitPropertySequence( - { - {"Text", uno::makeAny(OUString("Comment"))}, - {"Author", uno::makeAny(OUString("LOK User1"))}, - })); - comphelper::dispatchCommand(".uno:InsertAnnotation", aPropertyValues); - Scheduler::ProcessEventsToIdle(); - - // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action - CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); - int nCommentId1 = aView1.m_aCommentCallbackResult.get<int>("id"); - - // Reply to a comment just added - aPropertyValues = comphelper::InitPropertySequence( - { - {"Id", uno::makeAny(OUString::number(nCommentId1))}, - {"Text", uno::makeAny(OUString("Reply comment"))}, - }); - comphelper::dispatchCommand(".uno:ReplyComment", aPropertyValues); - Scheduler::ProcessEventsToIdle(); - - // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action and linked to its parent comment - CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent")); - CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent")); - CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("Reply comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); - int nCommentId2 = aView1.m_aCommentCallbackResult.get<int>("id"); - - // Edit the previously added comment - aPropertyValues = comphelper::InitPropertySequence( - { - {"Id", uno::makeAny(OUString::number(nCommentId2))}, - {"Text", uno::makeAny(OUString("Edited comment"))}, - }); - comphelper::dispatchCommand(".uno:EditAnnotation", aPropertyValues); - Scheduler::ProcessEventsToIdle(); - - // We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action - CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action")); - // parent is unchanged still - CPPUNIT_ASSERT_EQUAL(nCommentId1, aView1.m_aCommentCallbackResult.get<int>("parent")); - CPPUNIT_ASSERT_EQUAL(nCommentId1, aView2.m_aCommentCallbackResult.get<int>("parent")); - CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); - CPPUNIT_ASSERT_EQUAL(std::string("Edited comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); - - // Delete the reply comment just added - aPropertyValues = comphelper::InitPropertySequence( - { - {"Id", uno::makeAny(OUString::number(nCommentId2))}, - }); - comphelper::dispatchCommand(".uno:DeleteComment", aPropertyValues); - Scheduler::ProcessEventsToIdle(); - - // We received a LOK_CALLBACK_COMMENT callback with comment 'Remove' action - CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView1.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView2.m_aCommentCallbackResult.get<std::string>("action")); - CPPUNIT_ASSERT_EQUAL(nCommentId2, aView1.m_aCommentCallbackResult.get<int>("id")); - CPPUNIT_ASSERT_EQUAL(nCommentId2, aView2.m_aCommentCallbackResult.get<int>("id")); - - // .uno:ViewAnnotations returns total of 1 comment - OUString aPostIts = pXTextDocument->getPostIts(); - std::stringstream aStream(aPostIts.toUtf8().getStr()); - boost::property_tree::ptree aTree; - boost::property_tree::read_json(aStream, aTree); - CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(1), aTree.get_child("comments").size()); - - mxComponent->dispose(); - mxComponent.clear(); - comphelper::LibreOfficeKit::setTiledAnnotations(true); - comphelper::LibreOfficeKit::setActive(false); -} - CPPUNIT_TEST_SUITE_REGISTRATION(SwTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 1ad56de1728c5180be97789532edaa2a12ff8dee Author: Pranav Kant <pran...@collabora.co.uk> Date: Tue Feb 21 11:45:57 2017 +0530 sfx2: fix incorrect debug output Fallback from 9351353b63886f494782f28f5400f5d71d22bcbd While at it, add one more such statement in Execute_ Change-Id: Ibebc6f007542751718b53ed978ee52c300d14439 (cherry picked from commit e4a0b50943921dcf6a914983cb693f9f6d20e145) diff --git a/sfx2/source/control/dispatch.cxx b/sfx2/source/control/dispatch.cxx index 71cd48b..c22fe43 100644 --- a/sfx2/source/control/dispatch.cxx +++ b/sfx2/source/control/dispatch.cxx @@ -911,6 +911,7 @@ bool SfxDispatcher::GetShellAndSlot_Impl(sal_uInt16 nSlot, SfxShell** ppShell, void SfxDispatcher::Execute_(SfxShell& rShell, const SfxSlot& rSlot, SfxRequest& rReq, SfxCallMode eCallMode) { + SFX_STACK(SfxDispatcher::Execute_); DBG_ASSERT( !xImp->bFlushing, "recursive call to dispatcher" ); DBG_ASSERT( xImp->aToDoStack.empty(), "unprepared InPlace _Execute" ); @@ -1738,7 +1739,7 @@ SfxSlotFilterState SfxDispatcher::IsSlotEnabledByFilter_Impl( sal_uInt16 nSID ) */ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer, bool bModal) { - SFX_STACK(SfxDispatcher::_FindServer); + SFX_STACK(SfxDispatcher::FindServer_); // Dispatcher locked? (nevertheless let SID_HELP_PI through) if ( IsLocked(nSlot) ) @@ -1872,7 +1873,7 @@ bool SfxDispatcher::FindServer_(sal_uInt16 nSlot, SfxSlotServer& rServer, bool b bool SfxDispatcher::FillState_(const SfxSlotServer& rSvr, SfxItemSet& rState, const SfxSlot* pRealSlot) { - SFX_STACK(SfxDispatcher::_FillState); + SFX_STACK(SfxDispatcher::FillState_); const SfxSlot *pSlot = rSvr.GetSlot(); if ( pSlot && IsLocked( pSlot->GetSlotId() ) ) commit 8388724fbc5ff2cc29ad62b5ad5a57016aaafed3 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 15:12:40 2017 +0530 sd lok: use per view author in annotations reply too Change-Id: Ibc727b54ebfcbdd1c95b679a35ddc8878ceecbfd (cherry picked from commit 7cc5aca1901ca7d67dffdcfc29537f32c31e0235) diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 23500c4..d023770 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -597,10 +597,17 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) std::unique_ptr< OutlinerParaObject > pOPO( pOutliner->CreateParaObject() ); pTextApi->SetText( *pOPO.get() ); - SvtUserOptions aUserOptions; - xAnnotation->setAuthor( aUserOptions.GetFullName() ); - xAnnotation->setInitials( aUserOptions.GetID() ); + OUString sReplyAuthor; + if (comphelper::LibreOfficeKit::isActive()) + sReplyAuthor = mrBase.GetMainViewShell()->GetView()->GetAuthor(); + else + { + SvtUserOptions aUserOptions; + sReplyAuthor = aUserOptions.GetFullName(); + xAnnotation->setInitials( aUserOptions.GetID() ); + } + xAnnotation->setAuthor( sReplyAuthor ); // set current time to reply xAnnotation->setDateTime( getCurrentDateTime() ); commit 5926175aa87e8429a5615d9157f381c0c16927b2 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 16:12:11 2017 +0530 sd lok: Don't rely on model notify events Place comment notification triggers at the end of the annotation insertion/modification function to accomplish the desired behavior. See inline comment for details. Change-Id: I0cbd51feb455d497826d6a4534a8bbd817be7b31 (cherry picked from commit b02416ea4742873153227b6eaca00a15e7335987) diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index 99f61ff..23500c4 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -109,18 +109,20 @@ using namespace ::com::sun::star::office; namespace { - void lcl_CommentNotification(const OUString& rEventName, const sd::ViewShellBase& rViewShell, Reference<XAnnotation>& rxAnnotation) + enum class CommentNotificationType { Add, Modify, Remove }; + + void lcl_CommentNotification(CommentNotificationType nType, const SfxViewShell* pViewShell, Reference<XAnnotation>& rxAnnotation) { // callbacks only if tiled annotations are explicltly turned off by LOK client if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations()) return; boost::property_tree::ptree aAnnotation; - aAnnotation.put("action", (rEventName == "OnAnnotationInserted" ? "Add" : - (rEventName == "OnAnnotationRemoved" ? "Remove" : - (rEventName == "OnAnnotationChanged" ? "Modify" : "???")))); + aAnnotation.put("action", (nType == CommentNotificationType::Add ? "Add" : + (nType == CommentNotificationType::Remove ? "Remove" : + (nType == CommentNotificationType::Modify ? "Modify" : "???")))); aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); - if (rEventName != "OnAnnotationRemoved") + if (nType != CommentNotificationType::Remove) { aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); aAnnotation.put("author", rxAnnotation->getAuthor()); @@ -135,7 +137,7 @@ namespace { boost::property_tree::write_json(aStream, aTree); std::string aPayload = aStream.str(); - rViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str()); } } // anonymous ns @@ -276,12 +278,21 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje { if( aEvent.EventName == "OnAnnotationInserted" || aEvent.EventName == "OnAnnotationRemoved" || aEvent.EventName == "OnAnnotationChanged" ) { - Reference<XAnnotation> xAnnotation(aEvent.Source, uno::UNO_QUERY); - if (xAnnotation.is()) + // AnnotationInsertion and modification is not handled here because when + // a new annotation is inserted, it consists of OnAnnotationInserted + // followed by a chain of OnAnnotationChanged (called for setting each + // of the annotation attributes - author, text etc.). This is not what a + // LOK client wants. So only handle removal here as annotation removal + // consists of only one event - 'OnAnnotationRemoved' + if ( aEvent.EventName == "OnAnnotationRemoved" ) { - // Inform our LOK clients - lcl_CommentNotification(aEvent.EventName, mrBase, xAnnotation); + Reference< XAnnotation > xAnnotation( aEvent.Source, uno::UNO_QUERY ); + if ( xAnnotation.is() ) + { + lcl_CommentNotification(CommentNotificationType::Remove, &mrBase, xAnnotation); + } } + UpdateTags(); } } @@ -507,6 +518,14 @@ void AnnotationManagerImpl::InsertAnnotation(const OUString& rText) if( mpDoc->IsUndoEnabled() ) mpDoc->EndUndo(); + // Tell our LOK clients about new comment added + const SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + lcl_CommentNotification(CommentNotificationType::Add, pViewShell, xAnnotation); + pViewShell = SfxViewShell::GetNext(*pViewShell); + } + UpdateTags(true); SelectAnnotation( xAnnotation, true ); } @@ -585,6 +604,14 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) // set current time to reply xAnnotation->setDateTime( getCurrentDateTime() ); + // Tell our LOK clients about this (comment modification) + const SfxViewShell* pViewShell = SfxViewShell::GetFirst(); + while (pViewShell) + { + lcl_CommentNotification(CommentNotificationType::Modify, pViewShell, xAnnotation); + pViewShell = SfxViewShell::GetNext(*pViewShell); + } + UpdateTags(true); SelectAnnotation( xAnnotation, true ); } commit 8a541f4a27526cf6277c86ca6634b5a6e38f4622 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 19:33:22 2017 +0530 desktop: unit test to for sd ViewAnnotations command Change-Id: Ib830ff786f12d9edc791623dead74b3eeeabad71 (cherry picked from commit 65cfa0eed38ceeb4e96c97b76772bb191129fd83) diff --git a/desktop/qa/data/blank_presentation.odp b/desktop/qa/data/blank_presentation.odp index 157901f..a7d57a4 100644 Binary files a/desktop/qa/data/blank_presentation.odp and b/desktop/qa/data/blank_presentation.odp differ diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index a2c5262..896c90d 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -110,6 +110,7 @@ public: void testGetFontSubset(); void testCommentsWriter(); void testCommentsCalc(); + void testCommentsImpress(); CPPUNIT_TEST_SUITE(DesktopLOKTest); CPPUNIT_TEST(testGetStyles); @@ -147,6 +148,7 @@ public: CPPUNIT_TEST(testGetFontSubset); CPPUNIT_TEST(testCommentsWriter); CPPUNIT_TEST(testCommentsCalc); + CPPUNIT_TEST(testCommentsImpress); CPPUNIT_TEST_SUITE_END(); uno::Reference<lang::XComponent> mxComponent; @@ -1986,6 +1988,64 @@ void DesktopLOKTest::testCommentsCalc() comphelper::LibreOfficeKit::setActive(false); } + +void DesktopLOKTest::testCommentsImpress() +{ + comphelper::LibreOfficeKit::setActive(); + // Disable tiled rendering for comments + comphelper::LibreOfficeKit::setTiledAnnotations(false); + + LibLODocument_Impl* pDocument = loadDoc("blank_presentation.odp"); + pDocument->m_pDocumentClass->initializeForRendering(pDocument, nullptr); + + // Can we get all the comments using .uno:ViewAnnotations command ? + boost::property_tree::ptree aTree; + char* pJSON = pDocument->m_pDocumentClass->getCommandValues(pDocument, ".uno:ViewAnnotations"); + std::stringstream aStream(pJSON); + free(pJSON); + CPPUNIT_ASSERT(!aStream.str().empty()); + boost::property_tree::read_json(aStream, aTree); + // There are 2 comments in the document already + CPPUNIT_ASSERT_EQUAL(static_cast<size_t>(2), aTree.get_child("comments").size()); + + // Check if all comment fields have valid data + int nIdx = 0; + for (const auto& rComment : aTree.get_child("comments")) + { + switch(nIdx) + { + case 0: + { + CPPUNIT_ASSERT(rComment.second.get<int>("id") > 0); + CPPUNIT_ASSERT_EQUAL(std::string("This is comment1"), rComment.second.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), rComment.second.get<std::string>("author")); + css::util::DateTime aDateTime; + OUString aDateTimeString = OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str()); + CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime)); + } + break; + case 1: + { + CPPUNIT_ASSERT(rComment.second.get<int>("id") > 0); + CPPUNIT_ASSERT_EQUAL(std::string("This is comment2"), rComment.second.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), rComment.second.get<std::string>("author")); + css::util::DateTime aDateTime; + OUString aDateTimeString = OUString::createFromAscii(rComment.second.get<std::string>("dateTime").c_str()); + CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime)); + } + break; + } + + ++nIdx; + } + + // We checked all the comments + CPPUNIT_ASSERT_EQUAL(2, nIdx); + + comphelper::LibreOfficeKit::setTiledAnnotations(true); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 6f050c4591400acbf860e99ae70da7a18fab5103 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 18:21:44 2017 +0530 sd lok: Unit tests for comments api Change-Id: I88a5cbc952a1ddc2f8ccd5f34b86bf797916171c (cherry picked from commit 1654980341cff652de65d3b2aed52230e781e63a) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 2013bfe..c70bdd5 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -34,6 +34,7 @@ #include <comphelper/lok.hxx> #include <svx/svdotable.hxx> #include <svx/svdoutl.hxx> +#include <unotools/datetime.hxx> #include <DrawDocShell.hxx> #include <ViewShellBase.hxx> @@ -89,6 +90,7 @@ public: void testTdf104405(); void testTdf81754(); void testTdf105502(); + void testCommentCallbacks(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -122,11 +124,12 @@ public: CPPUNIT_TEST(testTdf104405); CPPUNIT_TEST(testTdf81754); CPPUNIT_TEST(testTdf105502); + CPPUNIT_TEST(testCommentCallbacks); CPPUNIT_TEST_SUITE_END(); private: - SdXImpressDocument* createDoc(const char* pName); + SdXImpressDocument* createDoc(const char* pName, const uno::Sequence<beans::PropertyValue>& rArguments = uno::Sequence<beans::PropertyValue>()); static void callback(int nType, const char* pPayload, void* pData); void callbackImpl(int nType, const char* pPayload); xmlDocPtr parseXmlDump(); @@ -173,14 +176,14 @@ void SdTiledRenderingTest::tearDown() test::BootstrapFixture::tearDown(); } -SdXImpressDocument* SdTiledRenderingTest::createDoc(const char* pName) +SdXImpressDocument* SdTiledRenderingTest::createDoc(const char* pName, const uno::Sequence<beans::PropertyValue>& rArguments) { if (mxComponent.is()) mxComponent->dispose(); mxComponent = loadFromDesktop(m_directories.getURLFromSrc(DATA_DIRECTORY) + OUString::createFromAscii(pName), "com.sun.star.presentation.PresentationDocument"); SdXImpressDocument* pImpressDocument = dynamic_cast<SdXImpressDocument*>(mxComponent.get()); CPPUNIT_ASSERT(pImpressDocument); - pImpressDocument->initializeForTiledRendering(uno::Sequence<beans::PropertyValue>()); + pImpressDocument->initializeForTiledRendering(rArguments); return pImpressDocument; } @@ -898,6 +901,7 @@ public: std::map<int, bool> m_aViewCursorInvalidations; std::map<int, bool> m_aViewCursorVisibilities; bool m_bViewSelectionSet; + boost::property_tree::ptree m_aCommentCallbackResult; ViewCallback() : m_bGraphicSelectionInvalidated(false), @@ -975,6 +979,14 @@ public: m_bViewSelectionSet = true; } break; + case LOK_CALLBACK_COMMENT: + { + m_aCommentCallbackResult.clear(); + std::stringstream aStream(pPayload); + boost::property_tree::read_json(aStream, m_aCommentCallbackResult); + m_aCommentCallbackResult = m_aCommentCallbackResult.get_child("comment"); + } + break; } } }; @@ -1559,6 +1571,99 @@ void SdTiledRenderingTest::testTdf105502() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testCommentCallbacks() +{ + // Load the document. + comphelper::LibreOfficeKit::setActive(); + // Set the tield annotations off + comphelper::LibreOfficeKit::setTiledAnnotations(false); + + SdXImpressDocument* pXImpressDocument = createDoc("dummy.odp", comphelper::InitPropertySequence( + { + {".uno:Author", uno::makeAny(OUString("LOK User1"))}, + })); + ViewCallback aView1; + int nView1 = SfxLokHelper::getView(); + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView1); + + SfxLokHelper::createView(); + uno::Sequence<beans::PropertyValue> aArgs(comphelper::InitPropertySequence( + { + {".uno:Author", uno::makeAny(OUString("LOK User2"))}, + })); + pXImpressDocument->initializeForTiledRendering(aArgs); + ViewCallback aView2; + SfxViewShell::Current()->registerLibreOfficeKitViewCallback(&ViewCallback::callback, &aView2); + int nView2 = SfxLokHelper::getView(); + + SfxLokHelper::setView(nView1); + + // Add a new comment + aArgs = comphelper::InitPropertySequence( + { + {"Text", uno::makeAny(OUString("Comment"))}, + }); + comphelper::dispatchCommand(".uno:InsertAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Add' action + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Add"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + int nComment1 = aView1.m_aCommentCallbackResult.get<int>("id"); + CPPUNIT_ASSERT_EQUAL(nComment1, aView2.m_aCommentCallbackResult.get<int>("id")); + css::util::DateTime aDateTime; + OUString aDateTimeString = OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("dateTime").c_str()); + CPPUNIT_ASSERT(utl::ISO8601parseDateTime(aDateTimeString, aDateTime)); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), aView1.m_aCommentCallbackResult.get<std::string>("author")); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User1"), aView2.m_aCommentCallbackResult.get<std::string>("author")); + CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView1.m_aCommentCallbackResult.get<std::string>("text")); + CPPUNIT_ASSERT_EQUAL(std::string("Comment"), aView2.m_aCommentCallbackResult.get<std::string>("text")); + + // Reply to a just added comment + SfxLokHelper::setView(nView2); + aArgs = comphelper::InitPropertySequence( + { + {"Id", uno::makeAny(OUString::number(nComment1))}, + {"Text", uno::makeAny(OUString("Reply to comment"))}, + }); + comphelper::dispatchCommand(".uno:ReplyToAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Modify' action + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Modify"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView1.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView2.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), aView1.m_aCommentCallbackResult.get<std::string>("author")); + CPPUNIT_ASSERT_EQUAL(std::string("LOK User2"), aView2.m_aCommentCallbackResult.get<std::string>("author")); + OUString aReplyTextView1 = OUString::createFromAscii(aView1.m_aCommentCallbackResult.get<std::string>("text").c_str()); + OUString aReplyTextView2 = OUString::createFromAscii(aView2.m_aCommentCallbackResult.get<std::string>("text").c_str()); + CPPUNIT_ASSERT(aReplyTextView1.startsWith("Reply to LOK User1")); + CPPUNIT_ASSERT(aReplyTextView1.endsWith("Reply to comment")); + CPPUNIT_ASSERT(aReplyTextView2.startsWith("Reply to LOK User1")); + CPPUNIT_ASSERT(aReplyTextView2.endsWith("Reply to comment")); + + // Delete the comment + aArgs = comphelper::InitPropertySequence( + { + {"Id", uno::makeAny(OUString::number(nComment1))}, + }); + comphelper::dispatchCommand(".uno:DeleteAnnotation", aArgs); + Scheduler::ProcessEventsToIdle(); + + // We received a LOK_CALLBACK_COMMENT callback with comment 'Remove' action + CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView1.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(std::string("Remove"), aView2.m_aCommentCallbackResult.get<std::string>("action")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView1.m_aCommentCallbackResult.get<int>("id")); + CPPUNIT_ASSERT_EQUAL(nComment1, aView2.m_aCommentCallbackResult.get<int>("id")); + + mxComponent->dispose(); + mxComponent.clear(); + + comphelper::LibreOfficeKit::setTiledAnnotations(true); + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit a1e6cc8072d530a728a76ec0cdc847281bde4019 Author: Fakabbir Amin <fakab...@gmail.com> Date: Fri Feb 17 19:48:40 2017 +0530 tdf#84323: Make osl::Condition::wait more readable Improved readability of calls to osl::Condition::wait. Change-Id: I69fb9815561013f1eb9fd4a649e32902e09473c6 Reviewed-on: https://gerrit.libreoffice.org/34399 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> (cherry picked from commit 12fc1d5399a688a80eec2565a4b552377e428ab7) diff --git a/configmgr/source/components.cxx b/configmgr/source/components.cxx index 7eb8796..dfd72dc 100644 --- a/configmgr/source/components.cxx +++ b/configmgr/source/components.cxx @@ -21,6 +21,7 @@ #include <algorithm> #include <cassert> +#include <chrono> #include <cstddef> #include <list> #include <set> @@ -178,8 +179,7 @@ Components::WriteThread::WriteThread( } void Components::WriteThread::execute() { - TimeValue t = { 1, 0 }; // 1 sec - delay_.wait(&t); // must not throw; result_error is harmless and ignored + delay_.wait(std::chrono::seconds(1)); // must not throw; result_error is harmless and ignored osl::MutexGuard g(*lock_); // must not throw try { try { diff --git a/sc/qa/unit/tiledrendering/tiledrendering.cxx b/sc/qa/unit/tiledrendering/tiledrendering.cxx index b9b2be5..3965684 100644 --- a/sc/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sc/qa/unit/tiledrendering/tiledrendering.cxx @@ -32,6 +32,7 @@ #include <sfx2/lokhelper.hxx> #include <svx/svdpage.hxx> +#include <chrono> #include <tabvwsh.hxx> #include <docsh.hxx> #include <document.hxx> @@ -352,15 +353,13 @@ void ScTiledRenderingTest::testDocumentSize() // Set cursor column pViewShell->SetCursor(100, 0); // 2 seconds - TimeValue aTime = { 2 , 0 }; - osl::Condition::Result aResult = m_aDocSizeCondition.wait(aTime); + osl::Condition::Result aResult = m_aDocSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); // Set cursor row pViewShell->SetCursor(0, 100); // 2 seconds - aTime = { 2 , 0 }; - aResult = m_aDocSizeCondition.wait(aTime); + aResult = m_aDocSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); comphelper::LibreOfficeKit::setActive(false); diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index cbb8703..2013bfe 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -45,6 +45,8 @@ #include <sfx2/request.hxx> #include <svx/svxids.hrc> +#include <chrono> + using namespace css; static const char* const DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; @@ -668,8 +670,7 @@ void SdTiledRenderingTest::testInsertDeletePage() for (unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:InsertPage", aArgs); - TimeValue aTimeValue = { 2 , 0 }; // 2 seconds max - osl::Condition::Result aResult = m_aDocumentSizeCondition.wait(aTimeValue); + osl::Condition::Result aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); // Verify inserted slides @@ -686,7 +687,7 @@ void SdTiledRenderingTest::testInsertDeletePage() for (unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:DeletePage", aArgs); - aResult = m_aDocumentSizeCondition.wait(aTimeValue); + aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); // Verify deleted slides @@ -702,7 +703,7 @@ void SdTiledRenderingTest::testInsertDeletePage() for (unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:Undo", aArgs); - aResult = m_aDocumentSizeCondition.wait(aTimeValue); + aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); // Verify inserted slides @@ -718,7 +719,7 @@ void SdTiledRenderingTest::testInsertDeletePage() for (unsigned it = 1; it <= 10; it++) comphelper::dispatchCommand(".uno:Redo", aArgs); - aResult = m_aDocumentSizeCondition.wait(aTimeValue); + aResult = m_aDocumentSizeCondition.wait(std::chrono::seconds(2)); CPPUNIT_ASSERT_EQUAL(aResult, osl::Condition::result_ok); // Verify deleted slides commit 6c2c2322fd18e627f3fa98f7de8092e0e526bc7e Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Wed Jan 25 11:15:46 2017 +0100 tdf#105502 sd increase font size: handle table selection In part of a table shape is selected, then only operate on the selected cells, not on all of them. Change-Id: I3a9ba2b99bcaa2e355b6fcdafdd142d4a809bce6 Reviewed-on: https://gerrit.libreoffice.org/33524 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit cbc84a6599c08e5c79e544212c69c6946d0cdbf0) diff --git a/sd/qa/unit/tiledrendering/data/tdf105502.odp b/sd/qa/unit/tiledrendering/data/tdf105502.odp new file mode 100644 index 0000000..6fe8180 Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/tdf105502.odp differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 65079fc..cbb8703 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -42,6 +42,8 @@ #include <unomodel.hxx> #include <drawdoc.hxx> #include <undo/undomanager.hxx> +#include <sfx2/request.hxx> +#include <svx/svxids.hrc> using namespace css; @@ -84,6 +86,7 @@ public: void testTdf103083(); void testTdf104405(); void testTdf81754(); + void testTdf105502(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -116,6 +119,7 @@ public: CPPUNIT_TEST(testTdf103083); CPPUNIT_TEST(testTdf104405); CPPUNIT_TEST(testTdf81754); + CPPUNIT_TEST(testTdf105502); CPPUNIT_TEST_SUITE_END(); @@ -1505,6 +1509,55 @@ void SdTiledRenderingTest::testTdf81754() xDocShRef->DoClose(); } +void SdTiledRenderingTest::testTdf105502() +{ + // Load the document. + comphelper::LibreOfficeKit::setActive(); + SdXImpressDocument* pXImpressDocument = createDoc("tdf105502.odp"); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + sd::Window* pWindow = pViewShell->GetActiveWindow(); + CPPUNIT_ASSERT(pWindow); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(0); + auto pTableObject = dynamic_cast<sdr::table::SdrTableObj*>(pObject); + CPPUNIT_ASSERT(pTableObject); + + // Select the first row. + sd::View* pView = pViewShell->GetView(); + pView->MarkObj(pObject, pView->GetSdrPageView()); + pView->SdrBeginTextEdit(pObject); + rtl::Reference<sdr::SelectionController> xSelectionController(pView->getSelectionController()); + CPPUNIT_ASSERT(xSelectionController.is()); + SfxRequest aRequest(pViewShell->GetViewFrame(), SID_TABLE_SELECT_ROW); + xSelectionController->Execute(aRequest); + + // Assert that the A1:B1 selection succeeded. + CPPUNIT_ASSERT(xSelectionController->hasSelectedCells()); + sdr::table::CellPos aFirstCell; + sdr::table::CellPos aLastCell; + xSelectionController->getSelectedCells(aFirstCell, aLastCell); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aFirstCell.mnCol); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aFirstCell.mnRow); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(1), aLastCell.mnCol); + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), aLastCell.mnRow); + + // Grow font size for the selection. + comphelper::dispatchCommand(".uno:Grow", {}); + Scheduler::ProcessEventsToIdle(); + + // Assert that the selected A1 has now a larger font than the unselected + // A2. + xmlDocPtr pXmlDoc = parseXmlDump(); + sal_Int32 nA1Height = getXPath(pXmlDoc, "//Cell[1]/SdrText/OutlinerParaObject/EditTextObject/ContentInfo/attribs[1]/SvxFontHeightItem", "height").toInt32(); + sal_Int32 nA2Height = getXPath(pXmlDoc, "//Cell[3]/SdrText/OutlinerParaObject/EditTextObject/ContentInfo/attribs[1]/SvxFontHeightItem", "height").toInt32(); + // This failed when FuText::ChangeFontSize() never did "continue" in the + // text loop, instead of doing so depending on what IsInSelection() returns. + CPPUNIT_ASSERT(nA1Height > nA2Height); + xmlFreeDoc(pXmlDoc); + + comphelper::LibreOfficeKit::setActive(false); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit 8f4b26a280a2a1c074929922a513db47507187d1 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Tue Jan 17 09:11:11 2017 +0100 sw, sd: fix indentation The indentation in these files is consistent otherwise, let's keep it that way. Change-Id: I1d73caa03425cd4d1c98ff07935512b002fb2c72 (cherry picked from commit d74e3b5bc43635c8c86988884b97929c3b086732) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 58dc9e6..65079fc 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1493,7 +1493,7 @@ void SdTiledRenderingTest::testTdf81754() // now save, reload, and assert that we did not lose the edit ::sd::DrawDocShellRef xDocShRef = saveAndReload(pXImpressDocument->GetDocShell(), PPTX); - const SdrPage *pPage = GetPage(1, xDocShRef); + const SdrPage* pPage = GetPage(1, xDocShRef); SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pPage->GetObj(1)); CPPUNIT_ASSERT(pTextObject); diff --git a/sw/inc/lineinfo.hxx b/sw/inc/lineinfo.hxx index 4cd232e..155a4c0 100644 --- a/sw/inc/lineinfo.hxx +++ b/sw/inc/lineinfo.hxx @@ -50,7 +50,7 @@ class SW_DLLPUBLIC SwLineNumberInfo : public SwClient /**< purpose of derivation bool bRestartEachPage; /**< Restart counting at the first paragraph of each page (even on follows when paragraphs are splitted) */ protected: - virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; + virtual void Modify( const SfxPoolItem*, const SfxPoolItem* ) override; public: SwLineNumberInfo(); diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx index eb6a28f..005ab57 100644 --- a/sw/inc/tox.hxx +++ b/sw/inc/tox.hxx @@ -80,7 +80,7 @@ class SW_DLLPUBLIC SwTOXMark protected: // SwClient - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; public: diff --git a/sw/inc/txtatr.hxx b/sw/inc/txtatr.hxx index 02ee37d..ddb3f1b 100644 --- a/sw/inc/txtatr.hxx +++ b/sw/inc/txtatr.hxx @@ -74,7 +74,7 @@ class SW_DLLPUBLIC SwTextRuby : public SwTextAttrNesting, public SwClient { SwTextNode* m_pTextNode; protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; public: SwTextRuby( SwFormatRuby& rAttr, sal_Int32 nStart, sal_Int32 nEnd ); virtual ~SwTextRuby() override; diff --git a/sw/inc/unosett.hxx b/sw/inc/unosett.hxx index 6386f4f..73ce65c 100644 --- a/sw/inc/unosett.hxx +++ b/sw/inc/unosett.hxx @@ -140,8 +140,8 @@ class SwXNumberingRules : public cppu::WeakAggImplHelper5 > { private: - class Impl; - ::sw::UnoImplPtr<Impl> m_pImpl; + class Impl; + ::sw::UnoImplPtr<Impl> m_pImpl; OUString m_sNewCharStyleNames[MAXLEVEL]; OUString m_sNewBulletFontNames[MAXLEVEL]; diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx index eda8646..9806d2f 100644 --- a/sw/inc/unostyle.hxx +++ b/sw/inc/unostyle.hxx @@ -151,7 +151,7 @@ class SwXAutoStyleFamily : public cppu::WeakImplHelper< css::style::XAutoStyleFa IStyleAccess::SwAutoStyleFamily m_eFamily; protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) override; public: SwXAutoStyleFamily(SwDocShell* pDocShell, IStyleAccess::SwAutoStyleFamily eFamily); diff --git a/sw/inc/usrfld.hxx b/sw/inc/usrfld.hxx index 45de281..e2490f9 100644 --- a/sw/inc/usrfld.hxx +++ b/sw/inc/usrfld.hxx @@ -62,7 +62,7 @@ public: virtual bool PutValue( const css::uno::Any& rVal, sal_uInt16 nMId ) override; protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; }; inline bool SwUserFieldType::IsValid() const commit 15db136ab1311c24b9220d8ed65392df3685027d Author: Stephan Bergmann <sberg...@redhat.com> Date: Tue Jan 10 08:10:42 2017 +0100 New loplugin:conststringvar: sd Change-Id: I7aa74260f1456a22bae368738e3947ead1ecc7be (cherry picked from commit 5637e56cc68b36c9a9484580e9053cca5c04a771) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index 7eb13a8..58dc9e6 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -45,7 +45,7 @@ using namespace css; -static const char* DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; +static const char* const DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools { diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 8bc792b..4443c42 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -2239,7 +2239,7 @@ OUString const & HtmlExport::getDocumentTitle() return mDocTitle; } -static const char* JS_NavigateAbs = +static const char JS_NavigateAbs[] = "function NavigateAbs( nPage )\r\n" "{\r\n" " frames[\"show\"].location.href = \"img\" + nPage + \".$EXT\";\r\n" @@ -2259,7 +2259,7 @@ static const char* JS_NavigateAbs = " }\r\n" "}\r\n\r\n"; -static const char* JS_NavigateRel = +static const char JS_NavigateRel[] = "function NavigateRel( nDelta )\r\n" "{\r\n" " var nPage = parseInt(nCurrentPage) + parseInt(nDelta);\r\n" @@ -2269,14 +2269,14 @@ static const char* JS_NavigateRel = " }\r\n" "}\r\n\r\n"; -static const char* JS_ExpandOutline = +static const char JS_ExpandOutline[] = "function ExpandOutline()\r\n" "{\r\n" " frames[\"navbar2\"].location.href = \"navbar4.$EXT\";\r\n" " frames[\"outline\"].location.href = \"outline1.$EXT\";\r\n" "}\r\n\r\n"; -static const char * JS_CollapseOutline = +static const char JS_CollapseOutline[] = "function CollapseOutline()\r\n" "{\r\n" " frames[\"navbar2\"].location.href = \"navbar3.$EXT\";\r\n" @@ -2304,7 +2304,7 @@ bool HtmlExport::CreateFrames() aStr.append(OUString::number(mnSdPageCount)); aStr.append(";\r\n\r\n"); - OUString aFunction = OUString::createFromAscii(JS_NavigateAbs); + OUString aFunction = JS_NavigateAbs; if(mbNotes) { @@ -2316,17 +2316,17 @@ bool HtmlExport::CreateFrames() aFunction = aFunction.replaceAll(aPlaceHolder, maHTMLExtension); aStr.append(aFunction); - aTmp = OUString::createFromAscii(JS_NavigateRel); + aTmp = JS_NavigateRel; aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension); aStr.append(aTmp); if(mbImpress) { - aTmp = OUString::createFromAscii(JS_ExpandOutline); + aTmp = JS_ExpandOutline; aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension); aStr.append(aTmp); - aTmp = OUString::createFromAscii(JS_CollapseOutline); + aTmp = JS_CollapseOutline; aTmp = aTmp.replaceAll(aPlaceHolder, maHTMLExtension); aStr.append(aTmp); } diff --git a/sd/source/ui/remotecontrol/BluetoothServer.cxx b/sd/source/ui/remotecontrol/BluetoothServer.cxx index 3002160..d515911 100644 --- a/sd/source/ui/remotecontrol/BluetoothServer.cxx +++ b/sd/source/ui/remotecontrol/BluetoothServer.cxx @@ -219,7 +219,7 @@ getBluez5Adapter(DBusConnection *pConnection) if (!pMsg) return nullptr; - const gchar* pInterfaceType = "org.bluez.Adapter1"; + const gchar* const pInterfaceType = "org.bluez.Adapter1"; pMsg = sendUnrefAndWaitForReply( pConnection, pMsg ); diff --git a/sd/source/ui/remotecontrol/BluetoothServiceRecord.hxx b/sd/source/ui/remotecontrol/BluetoothServiceRecord.hxx index d85f257..722f4f9 100644 --- a/sd/source/ui/remotecontrol/BluetoothServiceRecord.hxx +++ b/sd/source/ui/remotecontrol/BluetoothServiceRecord.hxx @@ -21,7 +21,7 @@ // for numbers see: // https://www.bluetooth.org/Technical/AssignedNumbers/service_discovery.htm -static const char *bluetooth_service_record = +static const char * const bluetooth_service_record = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<record>" "<attribute id=\"0x0001\">" // Service class ID list commit 64490112969e31be5694343c3259dcba863f2fe5 Author: Jan Holesovsky <ke...@collabora.com> Date: Wed Jan 4 20:40:28 2017 +0100 tdf#81754: Unit test for the loss of text on save of pptx. The problem itself was fixed by commit 2ad50c9a8c8411a57bbbd7a52734e72ffc4cc0ee. Change-Id: Ie7f0781e1f5a4d6c5297882a5f64a68b85558515 (cherry picked from commit 6106fea591f685bc1fd5b65ade86e2e45dbc58e1) diff --git a/sd/CppunitTest_sd_tiledrendering.mk b/sd/CppunitTest_sd_tiledrendering.mk index 60790c4..711f6eb 100644 --- a/sd/CppunitTest_sd_tiledrendering.mk +++ b/sd/CppunitTest_sd_tiledrendering.mk @@ -19,6 +19,7 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_tiledrendering, \ comphelper \ cppu \ cppuhelper \ + drawinglayer \ editeng \ sal \ sfx \ diff --git a/sd/qa/unit/tiledrendering/data/tdf81754.pptx b/sd/qa/unit/tiledrendering/data/tdf81754.pptx new file mode 100644 index 0000000..8a1fa1d Binary files /dev/null and b/sd/qa/unit/tiledrendering/data/tdf81754.pptx differ diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index e031d06..7eb13a8 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -7,6 +7,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ +#include "../sdmodeltestbase.hxx" #include <test/bootstrapfixture.hxx> #include <unotest/macros_test.hxx> #include <test/xmltesttools.hxx> @@ -19,6 +20,7 @@ #include <comphelper/propertysequence.hxx> #include <comphelper/string.hxx> #include <editeng/editids.hrc> +#include <editeng/editobj.hxx> #include <editeng/editview.hxx> #include <editeng/editobj.hxx> #include <editeng/outliner.hxx> @@ -45,7 +47,7 @@ using namespace css; static const char* DATA_DIRECTORY = "/sd/qa/unit/tiledrendering/data/"; -class SdTiledRenderingTest : public test::BootstrapFixture, public unotest::MacrosTest, public XmlTestTools +class SdTiledRenderingTest : public SdModelTestBase, public XmlTestTools { public: SdTiledRenderingTest(); @@ -81,6 +83,7 @@ public: void testPostKeyEventInvalidation(); void testTdf103083(); void testTdf104405(); + void testTdf81754(); CPPUNIT_TEST_SUITE(SdTiledRenderingTest); CPPUNIT_TEST(testRegisterCallback); @@ -112,6 +115,8 @@ public: CPPUNIT_TEST(testPostKeyEventInvalidation); CPPUNIT_TEST(testTdf103083); CPPUNIT_TEST(testTdf104405); + CPPUNIT_TEST(testTdf81754); + CPPUNIT_TEST_SUITE_END(); private: @@ -1466,6 +1471,40 @@ void SdTiledRenderingTest::testTdf104405() comphelper::LibreOfficeKit::setActive(false); } +void SdTiledRenderingTest::testTdf81754() +{ + SdXImpressDocument* pXImpressDocument = createDoc("tdf81754.pptx"); + sd::ViewShell* pViewShell = pXImpressDocument->GetDocShell()->GetViewShell(); + SdPage* pActualPage = pViewShell->GetActualPage(); + SdrObject* pObject = pActualPage->GetObj(1); + + SdrTextObj* pTextObj = static_cast<SdrTextObj*>(pObject); + SdrView* pView = pViewShell->GetView(); + pView->MarkObj(pTextObj, pView->GetSdrPageView()); + SfxStringItem aInputString(SID_ATTR_CHAR, "x"); + pViewShell->GetViewFrame()->GetDispatcher()->ExecuteList(SID_ATTR_CHAR, + SfxCallMode::SYNCHRON, { &aInputString }); + + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYINPUT, 'x', 0); + pXImpressDocument->postKeyEvent(LOK_KEYEVENT_KEYUP, 'x', 0); + + Scheduler::ProcessEventsToIdle(); + + // now save, reload, and assert that we did not lose the edit + ::sd::DrawDocShellRef xDocShRef = saveAndReload(pXImpressDocument->GetDocShell(), PPTX); + + const SdrPage *pPage = GetPage(1, xDocShRef); + SdrTextObj* pTextObject = dynamic_cast<SdrTextObj*>(pPage->GetObj(1)); + CPPUNIT_ASSERT(pTextObject); + + OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); + const EditTextObject& aEdit = pOutlinerParagraphObject->GetTextObject(); + + CPPUNIT_ASSERT_EQUAL(OUString("Somethingxx"), aEdit.GetText(0)); + + xDocShRef->DoClose(); +} + CPPUNIT_TEST_SUITE_REGISTRATION(SdTiledRenderingTest); CPPUNIT_PLUGIN_IMPLEMENT(); commit ce3ce69b2f1dd7f8c032389b8979865bbdcc5dfa Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Thu Dec 8 09:25:32 2016 +0100 Indentation fixes Change-Id: I35de0c30a3f4f82bc923e467d5f0acf0ed90684f (cherry picked from commit a215174eba5962abcef10a5a1a852fdc9364105b) diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index d8f7f23..e031d06 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -1432,9 +1432,9 @@ void SdTiledRenderingTest::testTdf104405() rEditView.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char. // trigger the clone-formatting/paintbrush command to copy formatting contents of cell - uno::Sequence< beans::PropertyValue > aArgs( 1 ); + uno::Sequence< beans::PropertyValue > aArgs(1); aArgs[0].Name = "PersistentCopy"; - aArgs[0].Value = uno::makeAny( true ); + aArgs[0].Value = uno::makeAny(true); comphelper::dispatchCommand(".uno:FormatPaintbrush", aArgs); Scheduler::ProcessEventsToIdle(); @@ -1447,10 +1447,10 @@ void SdTiledRenderingTest::testTdf104405() rEditView2.SetSelection(ESelection(0, 0, 0, 3)); // start para, start char, end para, end char. Rectangle aRect = pTableObject->GetCurrentBoundRect(); pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONDOWN, - convertMm100ToTwip(aRect.getX() ), convertMm100ToTwip(aRect.getY() ), + convertMm100ToTwip(aRect.getX()), convertMm100ToTwip(aRect.getY()), 1, MOUSE_LEFT, 0); pXImpressDocument->postMouseEvent(LOK_MOUSEEVENT_MOUSEBUTTONUP, - convertMm100ToTwip(aRect.getX() ), convertMm100ToTwip(aRect.getY() ), + convertMm100ToTwip(aRect.getX()), convertMm100ToTwip(aRect.getY()), 1, MOUSE_LEFT, 0); Scheduler::ProcessEventsToIdle(); @@ -1460,7 +1460,7 @@ void SdTiledRenderingTest::testTdf104405() OString aPrefix = "/SdDrawDocument/SdrModel/SdPage/SdrObjList/SdrTableObj/SdrTableObjImpl" "/TableModel/Cell[1]/DefaultProperties/SfxItemSet/SdrTextVertAdjustItem"; // the following name has a compiler-dependant part - CPPUNIT_ASSERT_EQUAL( getXPath(pXmlDoc, aPrefix, "value"), OUString("2") ); + CPPUNIT_ASSERT_EQUAL(getXPath(pXmlDoc, aPrefix, "value"), OUString("2")); xmlFreeDoc(pXmlDoc); comphelper::LibreOfficeKit::setActive(false); diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx index 21f8db5..a30af53 100644 --- a/sw/inc/format.hxx +++ b/sw/inc/format.hxx @@ -69,7 +69,7 @@ protected: SwFormat( SwAttrPool& rPool, const OUString &rFormatNm, const sal_uInt16* pWhichRanges, SwFormat *pDrvdFrame, sal_uInt16 nFormatWhich ); SwFormat( const SwFormat& rFormat ); - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNewValue ) override; public: diff --git a/sw/inc/ftninfo.hxx b/sw/inc/ftninfo.hxx index 3c5af52..d10ab32 100644 --- a/sw/inc/ftninfo.hxx +++ b/sw/inc/ftninfo.hxx @@ -38,7 +38,7 @@ class SW_DLLPUBLIC SwEndNoteInfo : public SwClient OUString sSuffix; protected: bool m_bEndNote; - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; public: SvxNumberType aFormat; diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx index 435a313..66cac16 100644 --- a/sw/inc/ndindex.hxx +++ b/sw/inc/ndindex.hxx @@ -79,7 +79,7 @@ public: RegisterIndex( m_pNode->GetNodes() ); } - virtual ~SwNodeIndex() override + virtual ~SwNodeIndex() override { DeRegisterIndex( m_pNode->GetNodes() ); } inline sal_uLong operator++(); diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx index 592886d..fec4ad5 100644 --- a/sw/inc/pagedesc.hxx +++ b/sw/inc/pagedesc.hxx @@ -184,7 +184,7 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify }; protected: - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNewValue ) override; public: const OUString& GetName() const { return m_StyleName; } diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx index 920ef8c..78a65d6 100644 --- a/sw/inc/section.hxx +++ b/sw/inc/section.hxx @@ -286,7 +286,7 @@ class SW_DLLPUBLIC SwSectionFormat protected: SwSectionFormat( SwFrameFormat* pDrvdFrame, SwDoc *pDoc ); - virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; + virtual void Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) override; public: virtual ~SwSectionFormat() override; commit 47a330e790a958c5260700af04e9606501624e98 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 13:30:48 2017 +0530 sd lok: Implement comment callback notifications Change-Id: Ibd3d2467a4bbac520987fa71a6d14994f58dd055 Reviewed-on: https://gerrit.libreoffice.org/34460 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: pranavk <pran...@collabora.co.uk> (cherry picked from commit 3d10c608b05f648c5ff09f68a76b88090572b831) diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index e1d3d37..99f61ff 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -19,6 +19,8 @@ #include "sddll.hxx" +#include <boost/property_tree/json_parser.hpp> + #include <com/sun/star/beans/XMultiPropertyStates.hpp> #include <com/sun/star/frame/XController.hpp> #include <com/sun/star/frame/XModel.hpp> @@ -37,6 +39,7 @@ #include <sal/macros.h> #include <svl/style.hxx> #include <svl/itempool.hxx> +#include <unotools/datetime.hxx> #include <unotools/useroptions.hxx> #include <unotools/syslocale.hxx> #include <unotools/saveopt.hxx> @@ -61,6 +64,8 @@ #include <editeng/udlnitem.hxx> #include <editeng/crossedoutitem.hxx> +#include <LibreOfficeKit/LibreOfficeKitEnums.h> + #include <svx/postattr.hxx> #include <svx/svdetc.hxx> @@ -102,6 +107,39 @@ using namespace ::com::sun::star::ui; using namespace ::com::sun::star::task; using namespace ::com::sun::star::office; +namespace { + + void lcl_CommentNotification(const OUString& rEventName, const sd::ViewShellBase& rViewShell, Reference<XAnnotation>& rxAnnotation) + { + // callbacks only if tiled annotations are explicltly turned off by LOK client + if (!comphelper::LibreOfficeKit::isActive() || comphelper::LibreOfficeKit::isTiledAnnotations()) + return; + + boost::property_tree::ptree aAnnotation; + aAnnotation.put("action", (rEventName == "OnAnnotationInserted" ? "Add" : + (rEventName == "OnAnnotationRemoved" ? "Remove" : + (rEventName == "OnAnnotationChanged" ? "Modify" : "???")))); + aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); + if (rEventName != "OnAnnotationRemoved") + { + aAnnotation.put("id", sd::getAnnotationId(rxAnnotation)); + aAnnotation.put("author", rxAnnotation->getAuthor()); + aAnnotation.put("dateTime", utl::toISO8601(rxAnnotation->getDateTime())); + uno::Reference<text::XText> xText(rxAnnotation->getTextRange()); + aAnnotation.put("text", xText->getString()); + } + + boost::property_tree::ptree aTree; + aTree.add_child("comment", aAnnotation); + std::stringstream aStream; + boost::property_tree::write_json(aStream, aTree); + std::string aPayload = aStream.str(); + + rViewShell.libreOfficeKitViewCallback(LOK_CALLBACK_COMMENT, aPayload.c_str()); + } + +} // anonymous ns + namespace sd { SfxItemPool* GetAnnotationPool() @@ -238,6 +276,12 @@ void SAL_CALL AnnotationManagerImpl::notifyEvent( const css::document::EventObje { if( aEvent.EventName == "OnAnnotationInserted" || aEvent.EventName == "OnAnnotationRemoved" || aEvent.EventName == "OnAnnotationChanged" ) { + Reference<XAnnotation> xAnnotation(aEvent.Source, uno::UNO_QUERY); + if (xAnnotation.is()) + { + // Inform our LOK clients + lcl_CommentNotification(aEvent.EventName, mrBase, xAnnotation); + } UpdateTags(); } } commit 08cdff16dc60065ef519743f19ba458b8d207f33 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 11:29:46 2017 +0530 sd lok: Support for replying to annotations by id Change-Id: I9e6416b87300c20969669ee9592f0b560959e160 Reviewed-on: https://gerrit.libreoffice.org/34459 Tested-by: Jenkins <c...@libreoffice.org> Reviewed-by: pranavk <pran...@collabora.co.uk> (cherry picked from commit 357fae01a15b88a53873278cccb1040b4d46bdba) diff --git a/sd/source/ui/annotations/annotationmanager.cxx b/sd/source/ui/annotations/annotationmanager.cxx index dd5f78d..e1d3d37 100644 --- a/sd/source/ui/annotations/annotationmanager.cxx +++ b/sd/source/ui/annotations/annotationmanager.cxx @@ -472,11 +472,21 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) { Reference< XAnnotation > xAnnotation; const SfxItemSet* pArgs = rReq.GetArgs(); + sal_uInt32 nReplyId = 0; // Id of the comment to reply to + OUString sReplyText; if( pArgs ) { const SfxPoolItem* pPoolItem = nullptr; - if( SfxItemState::SET == pArgs->GetItemState( rReq.GetSlot(), true, &pPoolItem ) ) + if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_ID, true, &pPoolItem ) ) + { + nReplyId = static_cast<const SvxPostItIdItem*>(pPoolItem)->GetValue().toUInt32(); + xAnnotation = GetAnnotationById(nReplyId); + } + else if( SfxItemState::SET == pArgs->GetItemState( rReq.GetSlot(), true, &pPoolItem ) ) static_cast<const SfxUnoAnyItem*>( pPoolItem )->GetValue() >>= xAnnotation; + + if( SfxItemState::SET == pArgs->GetItemState( SID_ATTR_POSTIT_TEXT, true, &pPoolItem ) ) + sReplyText = static_cast<const SvxPostItTextItem*>( pPoolItem )->GetValue(); } TextApiObject* pTextApi = getTextApiObject( xAnnotation ); @@ -518,6 +528,9 @@ void AnnotationManagerImpl::ExecuteReplyToAnnotation( SfxRequest& rReq ) pOutliner->QuickSetAttribs( aAnswerSet, aSel ); } + if (!sReplyText.isEmpty()) + pOutliner->Insert(sReplyText); + std::unique_ptr< OutlinerParaObject > pOPO( pOutliner->CreateParaObject() ); pTextApi->SetText( *pOPO.get() ); diff --git a/svx/sdi/svx.sdi b/svx/sdi/svx.sdi index aa0f036..91265a3 100644 --- a/svx/sdi/svx.sdi +++ b/svx/sdi/svx.sdi @@ -4575,7 +4575,7 @@ SfxBoolItem ShowAnnotations SID_SHOW_POSTIT SfxVoidItem ReplyToAnnotation SID_REPLYTO_POSTIT -() +(SvxPostItIdItem Id SID_ATTR_POSTIT_ID,SvxPostItTextItem Text SID_ATTR_POSTIT_TEXT) [ AutoUpdate = FALSE, FastCall = FALSE, commit 2c5e93e4bb4e5c3cc40935460cfe90ab591b9019 Author: Miklos Vajna <vmik...@collabora.co.uk> Date: Mon Feb 20 09:27:09 2017 +0100 sw: prefix members of SwBorderAttrAccess Change-Id: Iff8bf7d5d2b5b50e21726429c8b836ae560400e1 Reviewed-on: https://gerrit.libreoffice.org/34458 Reviewed-by: Miklos Vajna <vmik...@collabora.co.uk> Tested-by: Jenkins <c...@libreoffice.org> (cherry picked from commit fd27564ecbdf0a85b05e2578759dca9ad6efcd05) diff --git a/sw/source/core/inc/frmtool.hxx b/sw/source/core/inc/frmtool.hxx index c99bf11..4c8de72 100644 --- a/sw/source/core/inc/frmtool.hxx +++ b/sw/source/core/inc/frmtool.hxx @@ -365,7 +365,7 @@ public: class SwBorderAttrAccess : public SwCacheAccess { - const SwFrame *pConstructor; //opt: for passing on to SwBorderAttrs + const SwFrame *m_pConstructor; //opt: for passing on to SwBorderAttrs protected: virtual SwCacheObj *NewObj() override; diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index 09ffe34..da17ec9 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -2170,14 +2170,14 @@ SwBorderAttrAccess::SwBorderAttrAccess( SwCache &rCach, const SwFrame *pFrame ) (pFrame->IsContentFrame() ? static_cast<SwModify const *>(static_cast<const SwContentFrame*>(pFrame)->GetNode())->IsInCache() : static_cast<SwModify const *>(static_cast<const SwLayoutFrame*>(pFrame)->GetFormat())->IsInCache()) ), - pConstructor( pFrame ) + m_pConstructor( pFrame ) { } SwCacheObj *SwBorderAttrAccess::NewObj() { const_cast<SwModify *>(static_cast<SwModify const *>(m_pOwner))->SetInCache( true ); - return new SwBorderAttrs( static_cast<SwModify const *>(m_pOwner), pConstructor ); + return new SwBorderAttrs( static_cast<SwModify const *>(m_pOwner), m_pConstructor ); } SwBorderAttrs *SwBorderAttrAccess::Get() commit d47547ff546cd7d150359d16e6f1b7972b22d3b2 Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 13:30:13 2017 +0530 lok: listen for DeleteAnnotation state changes Change-Id: I2ea0d237cbbfd912b012ed400a328bfb6546cdfb (cherry picked from commit 866582435fa8ea0a76ad08d07e7df3a344072c94) diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a62b777..46d5aa4 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1399,6 +1399,7 @@ static void doc_iniUnoCommands () OUString(".uno:Paste"), OUString(".uno:SelectAll"), OUString(".uno:InsertAnnotation"), + OUString(".uno:DeleteAnnotation"), OUString(".uno:ReplyComment"), OUString(".uno:InsertRowsBefore"), OUString(".uno:InsertRowsAfter"), diff --git a/sfx2/source/control/unoctitm.cxx b/sfx2/source/control/unoctitm.cxx index 0beb487..40455e1 100644 --- a/sfx2/source/control/unoctitm.cxx +++ b/sfx2/source/control/unoctitm.cxx @@ -1042,6 +1042,7 @@ static void InterceptLOKStateChangeEvent(const SfxViewFrame* pViewFrame, const c aEvent.FeatureURL.Path == "Paste" || aEvent.FeatureURL.Path == "SelectAll" || aEvent.FeatureURL.Path == "InsertAnnotation" || + aEvent.FeatureURL.Path == "DeleteAnnotation" || aEvent.FeatureURL.Path == "InsertRowsBefore" || aEvent.FeatureURL.Path == "InsertRowsAfter" || aEvent.FeatureURL.Path == "InsertColumnsBefore" || commit ce5a895046a2f50735a7fe00992c32f66d285b7e Author: Pranav Kant <pran...@collabora.co.uk> Date: Mon Feb 20 11:27:53 2017 +0530 gtktiledviewer: Different reply uno command for impress Change-Id: I9dcd32a7e64198ca4772f263ed89a458e298c53b (cherry picked from commit 57d75ba3176063249e27524a7c7e425b3a2e75b4) ... etc. - the rest is truncated _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits