diff options
author | Marco Cecchetti <marco.cecchetti@collabora.com> | 2024-11-05 18:50:18 +0100 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2024-11-11 10:21:13 +0100 |
commit | 0846964661ae63bfd7164d6fea882ce41ce62563 (patch) | |
tree | a6fc7a196fb64cdf30de75858a306736122d6674 /sd | |
parent | bd3ac9a9546101904eacfb79f707b1b76c413800 (diff) |
slideshow: create a placeholder even if text field content is hidden
A placeholder always needs to be exported even if the content is hidden since it
could be visible on another slide and master page layers should be cached on the
client.
In order to support text fields different from the default ones a hash is used
for linking text field placeholder and text field content in place of the text
field type.
Any text field content should be sent first, so that when the client try to draw
a master page layer corresponding to a text field placeholder the content is
already available.
Slideshow unit tests have been updated to match the new implementation.
Change-Id: I845888d141e0f02c2066a9cb17d89ab152bf28b8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/176168
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Diffstat (limited to 'sd')
-rw-r--r-- | sd/qa/unit/tiledrendering/tiledrendering.cxx | 274 | ||||
-rw-r--r-- | sd/source/ui/tools/SlideshowLayerRenderer.cxx | 158 |
2 files changed, 262 insertions, 170 deletions
diff --git a/sd/qa/unit/tiledrendering/tiledrendering.cxx b/sd/qa/unit/tiledrendering/tiledrendering.cxx index f78c8d09e296..08fcd72b4040 100644 --- a/sd/qa/unit/tiledrendering/tiledrendering.cxx +++ b/sd/qa/unit/tiledrendering/tiledrendering.cxx @@ -3400,7 +3400,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); @@ -3408,17 +3408,16 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nTop)); // bottom-left corner - CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nBottom)); + CPPUNIT_ASSERT_EQUAL(Color(0x90, 0x80, 0xff), aBitmapEx.GetPixelColor(nLeft, nBottom)); // bottom-right corner - CPPUNIT_ASSERT_EQUAL(Color(0xff, 0xd0, 0x40), aBitmapEx.GetPixelColor(nRight, nBottom)); + CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nRight, nBottom)); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); } @@ -3429,7 +3428,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); // TODO - check JSON content - debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); @@ -3448,9 +3447,8 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); } @@ -3461,7 +3459,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); @@ -3469,28 +3467,62 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_WithFie CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nTop)); // bottom-left corner - CPPUNIT_ASSERT_EQUAL(Color(0x90, 0x80, 0xff), aBitmapEx.GetPixelColor(nLeft, nBottom)); + CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nLeft, nBottom)); // bottom-right corner - CPPUNIT_ASSERT_EQUAL(aTransparentColor, aBitmapEx.GetPixelColor(nRight, nBottom)); + CPPUNIT_ASSERT_EQUAL(Color(0xff, 0xd0, 0x40), aBitmapEx.GetPixelColor(nRight, nBottom)); boost::property_tree::ptree aTree; readJSON(aTree, aJson); CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); + bool bIsBitmapLayer = true; + OUString aJson; + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); + + boost::property_tree::ptree aTree; + readJSON(aTree, aJson); + + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); + } + + { + std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); + bool bIsBitmapLayer = true; + OUString aJson; + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); + + boost::property_tree::ptree aTree; + readJSON(aTree, aJson); + + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); + } + + { + std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); bool bIsBitmapLayer = false; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(5, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); BitmapEx aBitmapEx = vcl::bitmap::CreateFromData(pBuffer.data(), nViewWidth, nViewHeight, nViewWidth * 4, /*nBitsPerPixel*/32, true, true); @@ -3558,135 +3590,142 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_SlideNu { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = true; + bool bIsBitmapLayer = false; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(!bIsBitmapLayer); + CPPUNIT_ASSERT(bIsBitmapLayer); debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); { auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); + auto aContentChildChild = aContentChild.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); } } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = true; + bool bIsBitmapLayer = false; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(!bIsBitmapLayer); + CPPUNIT_ASSERT(bIsBitmapLayer); debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); { auto aContentChild = aTree.get_child("content"); CPPUNIT_ASSERT_EQUAL(std::string("Footer"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); + auto aContentChildChild = aContentChild.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); } } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = true; + bool bIsBitmapLayer = false; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(!bIsBitmapLayer); + CPPUNIT_ASSERT(bIsBitmapLayer); debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); { auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); + auto aContentChildChild = aContentChild.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); } } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); + CPPUNIT_ASSERT(!bIsBitmapLayer); debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("DrawPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); + { + auto aContentChild = aTree.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); + } } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); + CPPUNIT_ASSERT(!bIsBitmapLayer); debugWriteImageToFile(5, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); { auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); - auto aContentChildChild = aContentChild.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("Footer"), aContentChild.get_child("type").get_value<std::string>()); } } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); + CPPUNIT_ASSERT(!bIsBitmapLayer); debugWriteImageToFile(6, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); { auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("Footer"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); - auto aContentChildChild = aContentChild.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); } } @@ -3697,22 +3736,15 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_SlideNu CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(6, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(7, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); - CPPUNIT_ASSERT_EQUAL(std::string("TextFields"), aTree.get_child("group").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("DrawPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); - { - auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "content")); - auto aContentChildChild = aContentChild.get_child("content"); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChildChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChildChild.get_child("checksum").get_value<std::string>()); - } } { @@ -3768,48 +3800,62 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; - CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); boost::property_tree::ptree aTree; readJSON(aTree, aJson); CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); - + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "hash")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "initVisible")); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; - CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); boost::property_tree::ptree aTree; readJSON(aTree, aJson); CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); + auto aContentChild = aTree.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("Footer"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); + } + { + std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); + bool bIsBitmapLayer = true; + OUString aJson; + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); + + boost::property_tree::ptree aTree; + readJSON(aTree, aJson); + + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "hash")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "initVisible")); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); } { @@ -3818,7 +3864,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -3846,7 +3892,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati OUString aJson; CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -3921,52 +3967,62 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; - CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); - - debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); boost::property_tree::ptree aTree; readJSON(aTree, aJson); CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(0, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); - + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "hash")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "initVisible")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "bounds")); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("DateTime"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); } { std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); - bool bIsBitmapLayer = false; + bool bIsBitmapLayer = true; OUString aJson; - CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); - CPPUNIT_ASSERT(bIsBitmapLayer); - - debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); boost::property_tree::ptree aTree; readJSON(aTree, aJson); CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(1, aTree.get_child("index").get_value<int>()); - CPPUNIT_ASSERT_EQUAL(std::string("bitmap"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); + auto aContentChild = aTree.get_child("content"); + CPPUNIT_ASSERT_EQUAL(std::string("Footer"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); + } + + { + std::vector<sal_uInt8> pBuffer(nViewWidth * nViewHeight * 4); + bool bIsBitmapLayer = true; + OUString aJson; + CPPUNIT_ASSERT( + !pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); + CPPUNIT_ASSERT(!bIsBitmapLayer); + + boost::property_tree::ptree aTree; + readJSON(aTree, aJson); + CPPUNIT_ASSERT_EQUAL(std::string("MasterPage"), aTree.get_child("group").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(2, aTree.get_child("index").get_value<int>()); + CPPUNIT_ASSERT_EQUAL(std::string("placeholder"), aTree.get_child("type").get_value<std::string>()); CPPUNIT_ASSERT_EQUAL(true, has_child(aTree, "content")); auto aContentChild = aTree.get_child("content"); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "hash")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "initVisible")); - CPPUNIT_ASSERT_EQUAL(false, has_child(aContentChild, "bounds")); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGETYPE%"), aContentChild.get_child("type").get_value<std::string>()); - CPPUNIT_ASSERT_EQUAL(std::string("%IMAGECHECKSUM%"), aContentChild.get_child("checksum").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(std::string("SlideNumber"), aContentChild.get_child("type").get_value<std::string>()); + CPPUNIT_ASSERT_EQUAL(true, has_child(aContentChild, "hash")); } { @@ -3976,7 +4032,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(1, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -4001,7 +4057,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(2, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -4030,7 +4086,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(5, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(3, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -4059,7 +4115,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(6, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(4, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); @@ -4084,7 +4140,7 @@ CPPUNIT_TEST_FIXTURE(SdTiledRenderingTest, testSlideshowLayeredRendering_Animati CPPUNIT_ASSERT(!pXImpressDocument->renderNextSlideLayer(pBuffer.data(), bIsBitmapLayer, aJson)); CPPUNIT_ASSERT(bIsBitmapLayer); - debugWriteImageToFile(7, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); + debugWriteImageToFile(5, pBuffer, nViewWidth, nViewHeight, aJson.toUtf8().getStr()); boost::property_tree::ptree aTree; readJSON(aTree, aJson); diff --git a/sd/source/ui/tools/SlideshowLayerRenderer.cxx b/sd/source/ui/tools/SlideshowLayerRenderer.cxx index 7ca9a4566cc9..18b4f88703bc 100644 --- a/sd/source/ui/tools/SlideshowLayerRenderer.cxx +++ b/sd/source/ui/tools/SlideshowLayerRenderer.cxx @@ -96,20 +96,55 @@ public: namespace { -bool hasFields(SdrObject* pObject) +sal_Int32 getFieldType(SdrObject* pObject) { auto* pTextObject = dynamic_cast<SdrTextObj*>(pObject); if (!pTextObject) - return false; + return -2; OutlinerParaObject* pOutlinerParagraphObject = pTextObject->GetOutlinerParaObject(); if (pOutlinerParagraphObject) { const EditTextObject& rEditText = pOutlinerParagraphObject->GetTextObject(); - if (rEditText.IsFieldObject()) - return true; + if (rEditText.IsFieldObject() && rEditText.GetField() && rEditText.GetField()->GetField()) + return rEditText.GetField()->GetField()->GetClassId(); } - return false; + return -2; +} + +bool hasFields(SdrObject* pObject) { return getFieldType(pObject) > -2; } + +OUString getFieldName(sal_Int32 nType) +{ + switch (nType) + { + case text::textfield::Type::PAGE: + return u"Page"_ustr; + case text::textfield::Type::PAGE_NAME: + return u"PageName"_ustr; + default: + return u""_ustr; + } +} + +OUString getMasterTextFieldType(SdrObject* pObject) +{ + OUString aType; + + uno::Reference<drawing::XShape> xShape = pObject->getUnoShape(); + if (!xShape.is()) + return aType; + + OUString sShapeType = xShape->getShapeType(); + + if (sShapeType == u"com.sun.star.presentation.SlideNumberShape") + aType = u"SlideNumber"_ustr; + else if (sShapeType == u"com.sun.star.presentation.FooterShape") + aType = u"Footer"_ustr; + else if (sShapeType == u"com.sun.star.presentation.DateTimeShape") + aType = u"DateTime"_ustr; + + return aType; } /// Sets visible for all kinds of polypolys in the container @@ -252,27 +287,11 @@ private: mpCurrentRenderPass = newRenderPass(); } - OUString getMasterTextFieldString(SdrObject* pObject) + bool isTextFieldVisible(std::u16string_view svType) const { - OUString aType; - - uno::Reference<drawing::XShape> xShape = pObject->getUnoShape(); - if (!xShape.is()) - return aType; - - OUString sShapeType = xShape->getShapeType(); - - if (mrRenderState.mbSlideNumberEnabled - && sShapeType == u"com.sun.star.presentation.SlideNumberShape") - aType = u"SlideNumber"_ustr; - else if (mrRenderState.mbFooterEnabled - && sShapeType == u"com.sun.star.presentation.FooterShape") - aType = u"Footer"_ustr; - else if (mrRenderState.mbDateTimeEnabled - && sShapeType == u"com.sun.star.presentation.DateTimeShape") - aType = u"DateTime"_ustr; - - return aType; + return (mrRenderState.mbSlideNumberEnabled && svType == u"SlideNumber") + || (mrRenderState.mbFooterEnabled && svType == u"Footer") + || (mrRenderState.mbDateTimeEnabled && svType == u"DateTime"); } public: @@ -288,9 +307,13 @@ public: if (mrRenderState.maRenderPasses.back().isEmpty()) mrRenderState.maRenderPasses.pop_back(); + // Merge text field render passes into the main render pass list. + // We prepend them, so that they are rendered and sent to the client first. + // So, when the client try to draw a master page layer corresponding + // to a text field placeholder the content is already available. for (auto& rRenderWork : mrRenderState.maTextFields) { - mrRenderState.maRenderPasses.push_back(rRenderWork); + mrRenderState.maRenderPasses.push_front(rRenderWork); } } @@ -315,19 +338,58 @@ public: const bool bVisible = pObject->getSdrPageFromSdrObject()->checkVisibility(rOriginal, rDisplayInfo, true); - if (!bVisible) - return; - // Determine the current stage, depending on the page RenderStage eCurrentStage = pPage->IsMasterPage() ? RenderStage::Master : RenderStage::Slide; + OUString sTextFieldType = getMasterTextFieldType(pObject); + bool isPresentationTextField = !sTextFieldType.isEmpty(); + if (!isPresentationTextField) + { + sTextFieldType = getFieldName(getFieldType(pObject)); + } + + // Check if the object has slide number, footer, date/time + if (eCurrentStage == RenderStage::Master && !sTextFieldType.isEmpty()) + { + // it's not possible to set visibility for non-presentation text fields + bool bIsTextFieldVisible + = !isPresentationTextField || isTextFieldVisible(sTextFieldType); + + // A placeholder always needs to be exported even if the content is hidden + // since it could be visible on another slide and master page layers should be cached + // on the client + closeRenderPass(); + + mpCurrentRenderPass->maObjectsAndParagraphs.emplace(pObject, std::deque<sal_Int32>()); + mpCurrentRenderPass->meStage = eCurrentStage; + mpCurrentRenderPass->mbPlaceholder = true; + mpCurrentRenderPass->maFieldType = sTextFieldType; + mpCurrentRenderPass->mpObject = pObject; + closeRenderPass(); + + // Collect text field content if it's visible + // Both checks are needed! + if (bVisible && bIsTextFieldVisible) + { + RenderPass aTextFieldPass; + aTextFieldPass.maObjectsAndParagraphs.emplace(pObject, std::deque<sal_Int32>()); + aTextFieldPass.meStage = RenderStage::TextFields; + aTextFieldPass.maFieldType = sTextFieldType; + aTextFieldPass.mpObject = pObject; + + mrRenderState.maTextFields.push_back(aTextFieldPass); + } + return; + } + + if (!bVisible) + return; + // We switched from master objecst to slide objects if (eCurrentStage == RenderStage::Slide && mePreviousStage == RenderStage::Master) closeRenderPass(); - OUString sTextFieldString = getMasterTextFieldString(pObject); - // check if object is in an animation auto aIterator = mrRenderState.maAnimationRenderInfoList.find(pObject); if (aIterator != mrRenderState.maAnimationRenderInfoList.end()) @@ -383,36 +445,6 @@ public: closeRenderPass(); } } - // Check if the object has slide number, footer, date/time - else if (eCurrentStage == RenderStage::Master && !sTextFieldString.isEmpty()) - { - closeRenderPass(); - - mpCurrentRenderPass->maObjectsAndParagraphs.emplace(pObject, std::deque<sal_Int32>()); - mpCurrentRenderPass->meStage = eCurrentStage; - mpCurrentRenderPass->mbPlaceholder = true; - mpCurrentRenderPass->maFieldType = sTextFieldString; - mpCurrentRenderPass->mpObject = pObject; - closeRenderPass(); - - RenderPass aTextFieldPass; - aTextFieldPass.maObjectsAndParagraphs.emplace(pObject, std::deque<sal_Int32>()); - aTextFieldPass.meStage = RenderStage::TextFields; - aTextFieldPass.maFieldType = sTextFieldString; - aTextFieldPass.mpObject = pObject; - - mrRenderState.maTextFields.push_back(aTextFieldPass); - } - // Check if the object has fields - else if (eCurrentStage == RenderStage::Master && hasFields(pObject)) - { - closeRenderPass(); - - mpCurrentRenderPass->maObjectsAndParagraphs.emplace(pObject, std::deque<sal_Int32>()); - mpCurrentRenderPass->meStage = eCurrentStage; - mpCurrentRenderPass->mpObject = pObject; - closeRenderPass(); - } // No specal handling is needed, just add the object to the current rendering pass else { @@ -750,12 +782,16 @@ void SlideshowLayerRenderer::writeJSON(OString& rJsonMsg, RenderPass const& rRen { ::tools::ScopedJsonWriterNode aContentNode = aJsonWriter.startNode("content"); aJsonWriter.put("type", rRenderPass.maFieldType); + std::string sHash = pObject ? std::to_string(pObject->GetUniqueID()) : ""; + aJsonWriter.put("hash", sHash); } } else if (rRenderPass.meStage == RenderStage::TextFields) { ::tools::ScopedJsonWriterNode aContentNode = aJsonWriter.startNode("content"); aJsonWriter.put("type", rRenderPass.maFieldType); + std::string sHash = pObject ? std::to_string(pObject->GetUniqueID()) : ""; + aJsonWriter.put("hash", sHash); writeContentNode(aJsonWriter); } else |