[Libreoffice-commits] core.git: sw/qa sw/source
Miklos Vajna (via logerrit)
logerrit at kemper.freedesktop.org
Tue Jul 16 20:06:07 UTC 2019
sw/qa/extras/uiwriter/uiwriter2.cxx | 25 +++++++++++++++++++++++++
sw/source/uibase/uno/unotxdoc.cxx | 9 ++++++++-
2 files changed, 33 insertions(+), 1 deletion(-)
New commits:
commit 28fcb7d86765194b4015e7023449333f43aba0c5
Author: Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Tue Jul 16 16:22:29 2019 +0200
Commit: Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Jul 16 22:05:14 2019 +0200
sw comments on frames: no overlay in the LOK API, either
So that the Online and the desktop rendering result match.
Change-Id: Iabc62e74f5ce5880b663b4d7217c81729592a356
Reviewed-on: https://gerrit.libreoffice.org/75729
Reviewed-by: Miklos Vajna <vmiklos at collabora.com>
Tested-by: Jenkins
diff --git a/sw/qa/extras/uiwriter/uiwriter2.cxx b/sw/qa/extras/uiwriter/uiwriter2.cxx
index eac8676a2469..2c9e4e91f610 100644
--- a/sw/qa/extras/uiwriter/uiwriter2.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter2.cxx
@@ -8,6 +8,11 @@
*/
#include <swmodeltestbase.hxx>
+
+#include <sstream>
+
+#include <boost/property_tree/json_parser.hpp>
+
#include <com/sun/star/awt/FontWeight.hpp>
#include <com/sun/star/frame/DispatchHelper.hpp>
#include <com/sun/star/style/LineSpacing.hpp>
@@ -1619,6 +1624,26 @@ CPPUNIT_TEST_FIXTURE(SwUiWriterTest2, testImageComment)
const SwRect& rAnchor = pItem->pPostIt->GetAnchorRect();
CPPUNIT_ASSERT_LESSEQUAL(static_cast<long>(1418), rAnchor.Left());
}
+
+ // Test the comment anchor we expose via the LOK API.
+ // Without the accompanying fix in place, this test would have failed with:
+ // - Expected: 1418, 1418, 0, 0
+ // - Actual : 1418, 1418, 1024, 1024
+ // I.e. the anchor position had a non-empty size, which meant different rendering via tiled
+ // rendering and on the desktop.
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument*>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ OUString aPostits = pTextDoc->getPostIts();
+ std::stringstream aStream(aPostits.toUtf8().getStr());
+ boost::property_tree::ptree aTree;
+ boost::property_tree::read_json(aStream, aTree);
+ for (boost::property_tree::ptree::value_type& rValue : aTree.get_child("comments"))
+ {
+ const boost::property_tree::ptree& rComment = rValue.second;
+ OString aAnchorPos(rComment.get<std::string>("anchorPos").c_str());
+ CPPUNIT_ASSERT_EQUAL(OString("1418, 1418, 0, 0"), aAnchorPos);
+ }
+
#endif
// Now delete the image.
diff --git a/sw/source/uibase/uno/unotxdoc.cxx b/sw/source/uibase/uno/unotxdoc.cxx
index ccb0497d4179..c37e3abdc9ec 100644
--- a/sw/source/uibase/uno/unotxdoc.cxx
+++ b/sw/source/uibase/uno/unotxdoc.cxx
@@ -3346,10 +3346,17 @@ OUString SwXTextDocument::getPostIts()
const SwPostItField* pField = pWin->GetPostItField();
const SwRect& aRect = pWin->GetAnchorRect();
- const tools::Rectangle aSVRect(aRect.Pos().getX(),
+ tools::Rectangle aSVRect(aRect.Pos().getX(),
aRect.Pos().getY(),
aRect.Pos().getX() + aRect.SSize().Width(),
aRect.Pos().getY() + aRect.SSize().Height());
+
+ if (!sidebarItem->maLayoutInfo.mPositionFromCommentAnchor)
+ {
+ // Comments on frames: anchor position is the corner position, not the whole frame.
+ aSVRect.SetSize(Size(0, 0));
+ }
+
std::vector<OString> aRects;
for (const basegfx::B2DRange& aRange : pWin->GetAnnotationTextRanges())
{
More information about the Libreoffice-commits
mailing list