desktop/qa/desktop_lib/test_desktop_lib.cxx | 5 + desktop/source/lib/init.cxx | 18 +++++ drawinglayer/source/primitive2d/sceneprimitive2d.cxx | 61 +++++++++++++++-- include/LibreOfficeKit/LibreOfficeKit.h | 3 include/LibreOfficeKit/LibreOfficeKit.hxx | 5 + include/vcl/ITiledRenderable.hxx | 6 + linguistic/source/gciterator.cxx | 68 +++++++++++-------- sc/inc/docuno.hxx | 3 sc/source/ui/unoobj/docuno.cxx | 6 + sd/source/ui/inc/unomodel.hxx | 2 sd/source/ui/unoidl/unomodel.cxx | 6 + sw/inc/unotxdoc.hxx | 2 sw/source/uibase/shells/textsh1.cxx | 3 sw/source/uibase/uno/unotxdoc.cxx | 22 ++++++ 14 files changed, 177 insertions(+), 33 deletions(-)
New commits: commit 13ea6f6b6c8e7485036b577d948b8f66a8827947 Author: Armin Le Grand (allotropia) <[email protected]> AuthorDate: Fri Dec 8 16:05:43 2023 +0100 Commit: Andras Timar <[email protected]> CommitDate: Mon Jan 15 15:23:57 2024 +0100 3D SW-Renderer: Add functionality to balance quality/speed For this purpose allow reduced 3D quality in some circumstances and make a compromize between quality and speed. This is balanced between those two targets, fine-tuning/experimenting can be done with some static local values if needed. Change-Id: Ib00b6e9c3c3ff165d82ff12d23bf15196f0a0ee0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160467 Tested-by: Jenkins Reviewed-by: Armin Le Grand <[email protected]> diff --git a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx index 76504eb8e8fe..e2f44b690aa5 100644 --- a/drawinglayer/source/primitive2d/sceneprimitive2d.cxx +++ b/drawinglayer/source/primitive2d/sceneprimitive2d.cxx @@ -34,6 +34,7 @@ #include <utility> #include <vcl/BitmapTools.hxx> #include <comphelper/threadpool.hxx> +#include <comphelper/lok.hxx> #include <toolkit/helper/vclunohelper.hxx> using namespace com::sun::star; @@ -280,7 +281,7 @@ namespace drawinglayer::primitive2d // determine the oversample value static const sal_uInt16 nDefaultOversampleValue(3); - const sal_uInt16 nOversampleValue(SvtOptionsDrawinglayer::IsAntiAliasing() ? nDefaultOversampleValue : 0); + sal_uInt16 nOversampleValue(SvtOptionsDrawinglayer::IsAntiAliasing() ? nDefaultOversampleValue : 0); geometry::ViewInformation3D aViewInformation3D(getViewInformation3D()); { @@ -352,12 +353,62 @@ namespace drawinglayer::primitive2d const double fLogicY((aInverseOToV * basegfx::B2DVector(0.0, aDiscreteRange.getHeight() * fReduceFactor)).getLength()); // generate ViewSizes - const double fFullViewSizeX((rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(fLogicX, 0.0)).getLength()); - const double fFullViewSizeY((rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(0.0, fLogicY)).getLength()); + double fFullViewSizeX((rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(fLogicX, 0.0)).getLength()); + double fFullViewSizeY((rViewInformation.getObjectToViewTransformation() * basegfx::B2DVector(0.0, fLogicY)).getLength()); // generate RasterWidth and RasterHeight for visible part - const sal_Int32 nRasterWidth(basegfx::fround(fFullViewSizeX * aUnitVisibleRange.getWidth()) + 1); - const sal_Int32 nRasterHeight(basegfx::fround(fFullViewSizeY * aUnitVisibleRange.getHeight()) + 1); + sal_Int32 nRasterWidth(basegfx::fround(fFullViewSizeX * aUnitVisibleRange.getWidth()) + 1); + sal_Int32 nRasterHeight(basegfx::fround(fFullViewSizeY * aUnitVisibleRange.getHeight()) + 1); + + if(!rViewInformation.getReducedDisplayQuality() && comphelper::LibreOfficeKit::isActive()) + { + // for this purpose allow reduced 3D quality and make a compromize + // between quality and speed. This is balanced between those two + // targets, fine-tuning/experimenting can be done with the values + // below. + + // define some values which allow fine-tuning this feature + static const double fMin(80.0); + static const double fSqareMin(fMin * fMin); + static const double fMax(800.0); + static const double fSqareMax(fMax * fMax); + static const double fMaxReduction(0.65); + + // get the square pixels (work on pixel numbers to get same + // behaviour independent of width/height relations) + const double fSquarePixels(nRasterWidth * nRasterHeight); + + if (fSquarePixels > fSqareMin) + { + // only reduce at all when more than fSqareMin pixels needed + double fReduction(fMaxReduction); + + if (fSquarePixels < fSqareMax) + { + // range between fSqareMin and fSqareMax, calculate a + // linear interpolated reduction based on square root + fReduction = sqrt(fSquarePixels); // [fMin .. fMax] + fReduction = fReduction - fMin; // [0 .. (fMax - fMin)] + fReduction = fReduction / (fMax - fMin); // [0 .. 1] + fReduction = 1.0 - (fReduction * (1.0 - fMaxReduction)); // [1 .. fMaxReduction] + + // reduce oversampling for this range + if(nOversampleValue > 2) + nOversampleValue--; + } + else + { + // more than fSqareMax pixels, disable oversampling + nOversampleValue = 0; + } + + // adapt needed values to reduction + nRasterWidth = basegfx::fround(fReduction * nRasterWidth); + nRasterHeight = basegfx::fround(fReduction * nRasterHeight); + fFullViewSizeX *= fReduction; + fFullViewSizeY *= fReduction; + } + } if(!(nRasterWidth && nRasterHeight)) return; commit 4524ee0bbb4a133f74c3d3eec6ad2e2c97729e82 Author: Gökay Şatır <[email protected]> AuthorDate: Wed Nov 22 12:15:31 2023 +0300 Commit: Andras Timar <[email protected]> CommitDate: Mon Jan 15 15:14:53 2024 +0100 tdf#150716 - Partially solves the issue. This PR fixes the IgnoreAll issue. "Ignore" functionality needs another PR. Grammar checker and spell checker have different implementations. IgnoreAll functionality is implemented for spell checker but not grammar checker. This PR implements IgnoreAll for grammar checkers. Note: Ignore All function is valid per editing session. The ignored words is reset after the session is closed. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I7c2b77b18e0a26a6a1c5fa9e8e66075a34612884 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/159813 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Miklos Vajna <[email protected]> (cherry picked from commit c0a619aa945c852652dc353dbe4c42cabbc2b779) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161699 Tested-by: Jenkins Reviewed-by: Caolán McNamara <[email protected]> diff --git a/linguistic/source/gciterator.cxx b/linguistic/source/gciterator.cxx index 2ef50fbeab27..2f1232289c10 100644 --- a/linguistic/source/gciterator.cxx +++ b/linguistic/source/gciterator.cxx @@ -27,6 +27,7 @@ #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/linguistic2/XDictionary.hpp> #include <com/sun/star/linguistic2/XSupportedLocales.hpp> #include <com/sun/star/linguistic2/XProofreader.hpp> #include <com/sun/star/linguistic2/XProofreadingIterator.hpp> @@ -409,39 +410,54 @@ void GrammarCheckingIterator::ProcessResult( uno::Sequence< text::TextMarkupDescriptor > aDescriptors( nErrors + 1 ); text::TextMarkupDescriptor * pDescriptors = aDescriptors.getArray(); + uno::Reference< linguistic2::XDictionary > xIgnoreAll = ::GetIgnoreAllList(); + sal_Int32 ignoredCount = 0; + // at pos 0 .. nErrors-1 -> all grammar errors for (const linguistic2::SingleProofreadingError &rError : rRes.aErrors) { - text::TextMarkupDescriptor &rDesc = *pDescriptors++; - - rDesc.nType = rError.nErrorType; - rDesc.nOffset = rError.nErrorStart; - rDesc.nLength = rError.nErrorLength; - - // the proofreader may return SPELLING but right now our core - // does only handle PROOFREADING if the result is from the proofreader... - // (later on we may wish to color spelling errors found by the proofreader - // differently for example. But no special handling right now. - if (rDesc.nType == text::TextMarkupType::SPELLCHECK) - rDesc.nType = text::TextMarkupType::PROOFREADING; - - uno::Reference< container::XStringKeyMap > xKeyMap( - new LngXStringKeyMap()); - for( const beans::PropertyValue& rProperty : rError.aProperties ) + OUString word(rRes.aText.subView(rError.nErrorStart, rError.nErrorLength)); + bool ignored = xIgnoreAll->getEntry(word).is(); + + if (!ignored) { - if ( rProperty.Name == "LineColor" ) - { - xKeyMap->insertValue(rProperty.Name, - rProperty.Value); - rDesc.xMarkupInfoContainer = xKeyMap; - } - else if ( rProperty.Name == "LineType" ) + text::TextMarkupDescriptor &rDesc = *pDescriptors++; + + rDesc.nType = rError.nErrorType; + rDesc.nOffset = rError.nErrorStart; + rDesc.nLength = rError.nErrorLength; + + // the proofreader may return SPELLING but right now our core + // does only handle PROOFREADING if the result is from the proofreader... + // (later on we may wish to color spelling errors found by the proofreader + // differently for example. But no special handling right now. + if (rDesc.nType == text::TextMarkupType::SPELLCHECK) + rDesc.nType = text::TextMarkupType::PROOFREADING; + + uno::Reference< container::XStringKeyMap > xKeyMap(new LngXStringKeyMap()); + for( const beans::PropertyValue& rProperty : rError.aProperties ) { - xKeyMap->insertValue(rProperty.Name, - rProperty.Value); - rDesc.xMarkupInfoContainer = xKeyMap; + if ( rProperty.Name == "LineColor" ) + { + xKeyMap->insertValue(rProperty.Name, rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } + else if ( rProperty.Name == "LineType" ) + { + xKeyMap->insertValue(rProperty.Name, rProperty.Value); + rDesc.xMarkupInfoContainer = xKeyMap; + } } } + else + ignoredCount++; + } + + if (ignoredCount != 0) + { + aDescriptors.realloc(aDescriptors.getLength() - ignoredCount); + pDescriptors = aDescriptors.getArray(); + pDescriptors += aDescriptors.getLength() - 1; } // at pos nErrors -> sentence markup diff --git a/sw/source/uibase/shells/textsh1.cxx b/sw/source/uibase/shells/textsh1.cxx index 2bf6c670e489..31c93384ea3b 100644 --- a/sw/source/uibase/shells/textsh1.cxx +++ b/sw/source/uibase/shells/textsh1.cxx @@ -2041,8 +2041,9 @@ void SwTextShell::Execute(SfxRequest &rReq) SwPaM *pPaM = rWrtSh.GetCursor(); if (pPaM) SwEditShell::IgnoreGrammarErrorAt( *pPaM ); - if (xDictionary.is()) + if (xDictionary.is() && pPaM) { + linguistic::AddEntryToDic( xDictionary, pPaM->GetText(), false, OUString() ); // refresh the layout of all paragraphs (workaround to launch a dictionary event) xDictionary->setActive(false); xDictionary->setActive(true); commit 2458f3e0a4102524f62d34d34fa946d9489e6e96 Author: Gökay Şatır <[email protected]> AuthorDate: Thu Dec 14 15:53:17 2023 +0300 Commit: Andras Timar <[email protected]> CommitDate: Mon Jan 15 15:14:52 2024 +0100 Implement hyperlinkInfoAtPosition for Writer. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: Ibc71e4ee83625637f726646feb2c0192f3007687 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161381 Tested-by: Jenkins diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index b3654b5f9588..4725c69d6213 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3777,7 +3777,24 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) OUString SwXTextDocument::hyperlinkInfoAtPosition(int x, int y) { - return OUString::createFromAscii(std::to_string(x + y)); + SolarMutexGuard aGuard; + SwWrtShell* pWrtShell = m_pDocShell->GetWrtShell(); + + if (pWrtShell) + { + const Point point(x, y); + SwContentAtPos aContentAtPos(IsAttrAtPos::InetAttr); + + if (pWrtShell->GetContentAtPos(point, aContentAtPos)) + { + OUString url = static_cast<const SwFormatINetFormat*>(aContentAtPos.aFnd.pAttr)->GetValue(); + return url; + } + else + return OUString(); + } + else + return OUString(); } uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection() commit f0538496dcda09a76e6ea04b5f745018cb639b00 Author: Gökay Şatır <[email protected]> AuthorDate: Tue Nov 28 14:32:59 2023 +0300 Commit: Andras Timar <[email protected]> CommitDate: Mon Jan 15 15:14:52 2024 +0100 In readonly mode, we restrict many events like click. In readonly mode, Online users need to be able to click on a hyperlink and get the related info. For this purpose, this PR adds a new function template that sends the hyperlink info if there is any at the clicked position. I will send the implementation with the next commit. Signed-off-by: Gökay Şatır <[email protected]> Change-Id: I886ea22a7097aac73ade0da78a88ddfc95ad819c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160022 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/161372 Tested-by: Jenkins diff --git a/desktop/qa/desktop_lib/test_desktop_lib.cxx b/desktop/qa/desktop_lib/test_desktop_lib.cxx index b3410bd8eb49..cc4360807717 100644 --- a/desktop/qa/desktop_lib/test_desktop_lib.cxx +++ b/desktop/qa/desktop_lib/test_desktop_lib.cxx @@ -3702,8 +3702,11 @@ void DesktopLOKTest::testABI() CPPUNIT_ASSERT_EQUAL(documentClassOffset(71), offsetof(struct _LibreOfficeKitDocumentClass, getA11yCaretPosition)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), + offsetof(struct _LibreOfficeKitDocumentClass, hyperlinkInfoAtPosition)); + // As above - CPPUNIT_ASSERT_EQUAL(documentClassOffset(72), sizeof(struct _LibreOfficeKitDocumentClass)); + CPPUNIT_ASSERT_EQUAL(documentClassOffset(73), sizeof(struct _LibreOfficeKitDocumentClass)); } CPPUNIT_TEST_SUITE_REGISTRATION(DesktopLOKTest); diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index ab12a160b97a..efed041791bf 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -1139,6 +1139,9 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsigned nWindowId, int nType, const char* pText); + +static char* doc_hyperlinkInfoAtPosition(LibreOfficeKitDocument *pThis, int x, int y); + static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, @@ -1424,6 +1427,7 @@ LibLODocument_Impl::LibLODocument_Impl(uno::Reference <css::lang::XComponent> xC m_pDocumentClass->registerCallback = doc_registerCallback; m_pDocumentClass->postKeyEvent = doc_postKeyEvent; m_pDocumentClass->postWindowExtTextInputEvent = doc_postWindowExtTextInputEvent; + m_pDocumentClass->hyperlinkInfoAtPosition = doc_hyperlinkInfoAtPosition; m_pDocumentClass->removeTextContext = doc_removeTextContext; m_pDocumentClass->postWindowKeyEvent = doc_postWindowKeyEvent; m_pDocumentClass->postMouseEvent = doc_postMouseEvent; @@ -4693,6 +4697,20 @@ static void doc_postWindowExtTextInputEvent(LibreOfficeKitDocument* pThis, unsig SfxLokHelper::postExtTextEventAsync(pWindow, nType, OUString::fromUtf8(std::string_view(pText, strlen(pText)))); } +static char* doc_hyperlinkInfoAtPosition(LibreOfficeKitDocument* pThis, int x, int y) +{ + SolarMutexGuard aGuard; + + ITiledRenderable* pDoc = getTiledRenderable(pThis); + if (!pDoc) + { + SetLastExceptionMsg("Document doesn't support tiled rendering"); + return nullptr; + } + + return convertOUString(pDoc->hyperlinkInfoAtPosition(x, y)); +} + static void doc_removeTextContext(LibreOfficeKitDocument* pThis, unsigned nLOKWindowId, int nCharBefore, int nCharAfter) { SolarMutexGuard aGuard; diff --git a/include/LibreOfficeKit/LibreOfficeKit.h b/include/LibreOfficeKit/LibreOfficeKit.h index 96d6a3d3aca7..ed7f4e7f2d28 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.h +++ b/include/LibreOfficeKit/LibreOfficeKit.h @@ -511,6 +511,9 @@ struct _LibreOfficeKitDocumentClass /// @see lok::Document::getA11yCaretPosition. int (*getA11yCaretPosition) (LibreOfficeKitDocument* pThis); + /// @see lok::Document::hyperlinkInfoAtPosition(). + char* (*hyperlinkInfoAtPosition) (LibreOfficeKitDocument* pThis, int x,int y); + #endif // defined LOK_USE_UNSTABLE_API || defined LIBO_INTERNAL_ONLY }; diff --git a/include/LibreOfficeKit/LibreOfficeKit.hxx b/include/LibreOfficeKit/LibreOfficeKit.hxx index c06d2f6d6619..6f75eb6be5cb 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -362,6 +362,11 @@ public: mpDoc->pClass->setTextSelection(mpDoc, nType, nX, nY); } + char* hyperlinkInfoAtPosition(int x, int y) + { + return mpDoc->pClass->hyperlinkInfoAtPosition(mpDoc, x, y); + } + /** * Gets the currently selected text. * diff --git a/include/vcl/ITiledRenderable.hxx b/include/vcl/ITiledRenderable.hxx index be6c050ad36d..41d1143bf019 100644 --- a/include/vcl/ITiledRenderable.hxx +++ b/include/vcl/ITiledRenderable.hxx @@ -166,6 +166,12 @@ public: */ virtual void setTextSelection(int nType, int nX, int nY) = 0; + /* + * Gets the info of hyperlink under the mouse position if any. + * @see lok::Document::hyperlinkInfoAtPosition(). + */ + virtual OUString hyperlinkInfoAtPosition(int x, int y) = 0; + /** * Gets the selection as a transferable for later processing */ diff --git a/sc/inc/docuno.hxx b/sc/inc/docuno.hxx index 611b0c22d2b9..bc4608efbc3f 100644 --- a/sc/inc/docuno.hxx +++ b/sc/inc/docuno.hxx @@ -346,6 +346,9 @@ public: /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; + /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx index c906f39336f5..7d6d59fc1352 100644 --- a/sc/source/ui/unoobj/docuno.cxx +++ b/sc/source/ui/unoobj/docuno.cxx @@ -892,6 +892,12 @@ void ScModelObj::setTextSelection(int nType, int nX, int nY) } } +OUString ScModelObj::hyperlinkInfoAtPosition(int /*x*/, int /*y*/) +{ + // To be implemented.. + return OUString(); +} + uno::Reference<datatransfer::XTransferable> ScModelObj::getSelection() { SolarMutexGuard aGuard; diff --git a/sd/source/ui/inc/unomodel.hxx b/sd/source/ui/inc/unomodel.hxx index e0fa051d8826..37ead03a9279 100644 --- a/sd/source/ui/inc/unomodel.hxx +++ b/sd/source/ui/inc/unomodel.hxx @@ -254,6 +254,8 @@ public: virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; /// @see vcl::ITiledRenderable::setGraphicSelection(). diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx index dd9d5739555b..69bdf8f8cf67 100644 --- a/sd/source/ui/unoidl/unomodel.cxx +++ b/sd/source/ui/unoidl/unomodel.cxx @@ -2699,6 +2699,12 @@ void SdXImpressDocument::setTextSelection(int nType, int nX, int nY) } } +OUString SdXImpressDocument::hyperlinkInfoAtPosition(int /*x*/, int /*y*/) +{ + // To be implemented.. + return OUString(); +} + uno::Reference<datatransfer::XTransferable> SdXImpressDocument::getSelection() { SolarMutexGuard aGuard; diff --git a/sw/inc/unotxdoc.hxx b/sw/inc/unotxdoc.hxx index 32ae6c27e452..b9e40d23f0cd 100644 --- a/sw/inc/unotxdoc.hxx +++ b/sw/inc/unotxdoc.hxx @@ -423,6 +423,8 @@ public: virtual void postMouseEvent(int nType, int nX, int nY, int nCount, int nButtons, int nModifier) override; /// @see vcl::ITiledRenderable::setTextSelection(). virtual void setTextSelection(int nType, int nX, int nY) override; + /// @see vcl::ITiledRenderable::hyperlinkInfoAtPosition(). + virtual OUString hyperlinkInfoAtPosition(int x, int y) override; /// @see vcl::ITiledRenderable::getSelection(). virtual css::uno::Reference<css::datatransfer::XTransferable> getSelection() override; /// @see vcl::ITiledRenderable::setGraphicSelection(). diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx index f5e0904fa8d3..b3654b5f9588 100644 --- a/sw/source/uibase/uno/unotxdoc.cxx +++ b/sw/source/uibase/uno/unotxdoc.cxx @@ -3775,6 +3775,11 @@ void SwXTextDocument::setTextSelection(int nType, int nX, int nY) } } +OUString SwXTextDocument::hyperlinkInfoAtPosition(int x, int y) +{ + return OUString::createFromAscii(std::to_string(x + y)); +} + uno::Reference<datatransfer::XTransferable> SwXTextDocument::getSelection() { SolarMutexGuard aGuard;
