lok: sd: slideshow render improvements
Changed the slide layer message layout. Sometime some text field layer was missing. Try to skip empty layers. Change-Id: I52f00e637da7ab705a1fcb52a70af88cf619c8f7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/173540 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
This commit is contained in:
committed by
Miklos Vajna
parent
8dba09031b
commit
1ce7c35402
@@ -141,6 +141,13 @@ OUString getPlaceholderType(std::u16string_view sShapeType)
|
|||||||
return aType;
|
return aType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void appendImageInfoPlaceholder(tools::JsonWriter& rJsonWriter)
|
||||||
|
{
|
||||||
|
auto aContentNode = rJsonWriter.startNode("content");
|
||||||
|
rJsonWriter.put("type", "%IMAGETYPE%");
|
||||||
|
rJsonWriter.put("checksum", "%IMAGECHECKSUM%");
|
||||||
|
}
|
||||||
|
|
||||||
class LOKSlideRenderer
|
class LOKSlideRenderer
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -219,6 +226,9 @@ private:
|
|||||||
bool mbMasterPageRenderingDone;
|
bool mbMasterPageRenderingDone;
|
||||||
bool mbDrawPageRenderingDone;
|
bool mbDrawPageRenderingDone;
|
||||||
bool mbSlideRenderingDone;
|
bool mbSlideRenderingDone;
|
||||||
|
bool mbIsPageNumberVisible;
|
||||||
|
bool mbIsDateTimeVisible;
|
||||||
|
bool mbIsFooterVisible;
|
||||||
ShapeSharedPtr mpDPLastAnimatedShape;
|
ShapeSharedPtr mpDPLastAnimatedShape;
|
||||||
OUString msLastPlaceholder;
|
OUString msLastPlaceholder;
|
||||||
|
|
||||||
@@ -250,6 +260,9 @@ LOKSlideRenderer::LOKSlideRenderer(const Size& rViewSize, const Size& rSlideSize
|
|||||||
mbMasterPageRenderingDone(false),
|
mbMasterPageRenderingDone(false),
|
||||||
mbDrawPageRenderingDone(false),
|
mbDrawPageRenderingDone(false),
|
||||||
mbSlideRenderingDone(false),
|
mbSlideRenderingDone(false),
|
||||||
|
mbIsPageNumberVisible(true),
|
||||||
|
mbIsDateTimeVisible(true),
|
||||||
|
mbIsFooterVisible(true),
|
||||||
mbIsBitmapLayer(false)
|
mbIsBitmapLayer(false)
|
||||||
{
|
{
|
||||||
uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( mxDrawPage, uno::UNO_QUERY );
|
uno::Reference< drawing::XMasterPageTarget > xMasterPageTarget( mxDrawPage, uno::UNO_QUERY );
|
||||||
@@ -270,6 +283,34 @@ LOKSlideRenderer::LOKSlideRenderer(const Size& rViewSize, const Size& rSlideSize
|
|||||||
xPropSet->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisibility;
|
xPropSet->getPropertyValue("IsBackgroundObjectsVisible") >>= bBackgroundObjectsVisibility;
|
||||||
mbTextFieldsRenderingDone = mbMasterPageRenderingDone = !bBackgroundObjectsVisibility;
|
mbTextFieldsRenderingDone = mbMasterPageRenderingDone = !bBackgroundObjectsVisibility;
|
||||||
|
|
||||||
|
// try to skip empty layer
|
||||||
|
if (bBackgroundObjectsVisibility)
|
||||||
|
{
|
||||||
|
xPropSet->getPropertyValue("IsPageNumberVisible") >>= mbIsPageNumberVisible;
|
||||||
|
xPropSet->getPropertyValue("IsDateTimeVisible") >>= mbIsDateTimeVisible;
|
||||||
|
xPropSet->getPropertyValue("IsFooterVisible") >>= mbIsFooterVisible;
|
||||||
|
if (mbIsDateTimeVisible)
|
||||||
|
{
|
||||||
|
bool bDateTimeFixed = true; // default: fixed
|
||||||
|
xPropSet->getPropertyValue("IsDateTimeFixed") >>= bDateTimeFixed;
|
||||||
|
if (bDateTimeFixed)
|
||||||
|
{
|
||||||
|
OUString sDateTimeText;
|
||||||
|
xPropSet->getPropertyValue("DateTimeText") >>= sDateTimeText;
|
||||||
|
mbIsDateTimeVisible = !sDateTimeText.isEmpty();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (mbIsFooterVisible)
|
||||||
|
{
|
||||||
|
OUString sFooterText;
|
||||||
|
xPropSet->getPropertyValue("FooterText") >>= sFooterText;
|
||||||
|
mbIsFooterVisible = !sFooterText.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
mbTextFieldsRenderingDone =
|
||||||
|
!mbIsPageNumberVisible && !mbIsDateTimeVisible && !mbIsFooterVisible;
|
||||||
|
}
|
||||||
|
|
||||||
if (!mbTextFieldsRenderingDone)
|
if (!mbTextFieldsRenderingDone)
|
||||||
{
|
{
|
||||||
mpTFShapesFunctor
|
mpTFShapesFunctor
|
||||||
@@ -287,11 +328,22 @@ LOKSlideRenderer::LOKSlideRenderer(const Size& rViewSize, const Size& rSlideSize
|
|||||||
mpMPShapesFunctor->setMasterPageObjectsOnly(true);
|
mpMPShapesFunctor->setMasterPageObjectsOnly(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
mpShapesFunctor = std::make_shared<ShapeImporter>(mxDrawPage, mxDrawPage, mxDrawPagesSupplier,
|
uno::Reference<drawing::XShapes> const xShapes(mxDrawPage, uno::UNO_QUERY_THROW);
|
||||||
mrContext, 0, /* shape num starts at 0 */
|
if (xShapes.is())
|
||||||
false);
|
{
|
||||||
|
mbDrawPageRenderingDone = xShapes->getCount() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mbDrawPageRenderingDone)
|
||||||
|
{
|
||||||
|
mpShapesFunctor
|
||||||
|
= std::make_shared<ShapeImporter>(mxDrawPage, mxDrawPage, mxDrawPagesSupplier,
|
||||||
|
mrContext, 0, /* shape num starts at 0 */
|
||||||
|
false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
collectAnimatedShapes();
|
if (!mbDrawPageRenderingDone)
|
||||||
|
collectAnimatedShapes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOKSlideRenderer::renderBackground(unsigned char* pBuffer)
|
void LOKSlideRenderer::renderBackground(unsigned char* pBuffer)
|
||||||
@@ -349,8 +401,8 @@ void LOKSlideRenderer::renderBackgroundImpl(VirtualDevice& rDevice)
|
|||||||
|
|
||||||
tools::JsonWriter aJsonWriter;
|
tools::JsonWriter aJsonWriter;
|
||||||
aJsonWriter.put("group", "Background");
|
aJsonWriter.put("group", "Background");
|
||||||
std::string sLayerId = GetInterfaceHash(mxDrawPage) + ".0";
|
std::string sSlideHash = GetInterfaceHash(mxDrawPage);
|
||||||
aJsonWriter.put("id", sLayerId);
|
aJsonWriter.put("slideHash", sSlideHash);
|
||||||
|
|
||||||
ShapeSharedPtr const& rBGShape(mpMPShapesFunctor->importBackgroundShape());
|
ShapeSharedPtr const& rBGShape(mpMPShapesFunctor->importBackgroundShape());
|
||||||
mpLayerManager->addShape(rBGShape);
|
mpLayerManager->addShape(rBGShape);
|
||||||
@@ -365,7 +417,7 @@ void LOKSlideRenderer::renderBackgroundImpl(VirtualDevice& rDevice)
|
|||||||
// json
|
// json
|
||||||
mbIsBitmapLayer = true;
|
mbIsBitmapLayer = true;
|
||||||
aJsonWriter.put("type", "bitmap");
|
aJsonWriter.put("type", "bitmap");
|
||||||
aJsonWriter.put("checksum", std::to_string(nChecksum));
|
appendImageInfoPlaceholder(aJsonWriter);
|
||||||
|
|
||||||
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
||||||
maJsonMsgList.push_back(msLastJsonMessage);
|
maJsonMsgList.push_back(msLastJsonMessage);
|
||||||
@@ -379,6 +431,26 @@ void LOKSlideRenderer::renderBackgroundImpl(VirtualDevice& rDevice)
|
|||||||
|
|
||||||
void LOKSlideRenderer::renderMasterPageImpl(VirtualDevice& rDevice)
|
void LOKSlideRenderer::renderMasterPageImpl(VirtualDevice& rDevice)
|
||||||
{
|
{
|
||||||
|
if (!msLastPlaceholder.isEmpty())
|
||||||
|
{
|
||||||
|
tools::JsonWriter aJsonWriter;
|
||||||
|
aJsonWriter.put("group", "MasterPage");
|
||||||
|
aJsonWriter.put("slideHash", GetInterfaceHash(mxDrawPage));
|
||||||
|
aJsonWriter.put("index", mnMPLayerIndex);
|
||||||
|
|
||||||
|
aJsonWriter.put("type", "placeholder");
|
||||||
|
{
|
||||||
|
auto aContentNode = aJsonWriter.startNode("content");
|
||||||
|
aJsonWriter.put("type", msLastPlaceholder);
|
||||||
|
}
|
||||||
|
|
||||||
|
msLastPlaceholder = "";
|
||||||
|
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
||||||
|
maJsonMsgList.push_back(msLastJsonMessage);
|
||||||
|
++mnMPLayerIndex;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mpMPShapesFunctor->isImportDone())
|
if (mpMPShapesFunctor->isImportDone())
|
||||||
mbMasterPageRenderingDone = true;
|
mbMasterPageRenderingDone = true;
|
||||||
|
|
||||||
@@ -387,19 +459,8 @@ void LOKSlideRenderer::renderMasterPageImpl(VirtualDevice& rDevice)
|
|||||||
|
|
||||||
tools::JsonWriter aJsonWriter;
|
tools::JsonWriter aJsonWriter;
|
||||||
aJsonWriter.put("group", "MasterPage");
|
aJsonWriter.put("group", "MasterPage");
|
||||||
std::string sLayerId = GetInterfaceHash(mxMasterPage) + "." + std::to_string(mnMPLayerIndex);
|
aJsonWriter.put("slideHash", GetInterfaceHash(mxDrawPage));
|
||||||
aJsonWriter.put("id", sLayerId);
|
aJsonWriter.put("index", mnMPLayerIndex);
|
||||||
|
|
||||||
if (!msLastPlaceholder.isEmpty())
|
|
||||||
{
|
|
||||||
aJsonWriter.put("type", "placeholder");
|
|
||||||
aJsonWriter.put("placeholderId", msLastPlaceholder);
|
|
||||||
msLastPlaceholder = "";
|
|
||||||
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
|
||||||
maJsonMsgList.push_back(msLastJsonMessage);
|
|
||||||
++mnMPLayerIndex;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bDoRendering = false;
|
bool bDoRendering = false;
|
||||||
while (!mpMPShapesFunctor->isImportDone())
|
while (!mpMPShapesFunctor->isImportDone())
|
||||||
@@ -428,7 +489,10 @@ void LOKSlideRenderer::renderMasterPageImpl(VirtualDevice& rDevice)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
aJsonWriter.put("type", "placeholder");
|
aJsonWriter.put("type", "placeholder");
|
||||||
aJsonWriter.put("placeholderId", sPlaceholderType);
|
{
|
||||||
|
auto aContentNode = aJsonWriter.startNode("content");
|
||||||
|
aJsonWriter.put("type", sPlaceholderType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
bDoRendering = false;
|
bDoRendering = false;
|
||||||
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
||||||
@@ -463,6 +527,11 @@ void LOKSlideRenderer::renderTextFieldsImpl(VirtualDevice& rDevice)
|
|||||||
OUString sPlaceholderType = getPlaceholderType(sShapeType);
|
OUString sPlaceholderType = getPlaceholderType(sShapeType);
|
||||||
if (!sPlaceholderType.isEmpty())
|
if (!sPlaceholderType.isEmpty())
|
||||||
{
|
{
|
||||||
|
if ((!mbIsPageNumberVisible && sPlaceholderType == "SlideNumber") ||
|
||||||
|
(!mbIsDateTimeVisible && sPlaceholderType == "DateTime") ||
|
||||||
|
(!mbIsFooterVisible && sPlaceholderType == "Footer"))
|
||||||
|
continue;
|
||||||
|
|
||||||
mpLayerManager->addShape(rShape);
|
mpLayerManager->addShape(rShape);
|
||||||
|
|
||||||
// render and collect bitmap
|
// render and collect bitmap
|
||||||
@@ -470,16 +539,17 @@ void LOKSlideRenderer::renderTextFieldsImpl(VirtualDevice& rDevice)
|
|||||||
BitmapEx aBitmapEx(rDevice.GetBitmapEx(Point(0, 0), rDevice.GetOutputSizePixel()));
|
BitmapEx aBitmapEx(rDevice.GetBitmapEx(Point(0, 0), rDevice.GetOutputSizePixel()));
|
||||||
BitmapChecksum nChecksum = aBitmapEx.GetChecksum();
|
BitmapChecksum nChecksum = aBitmapEx.GetChecksum();
|
||||||
maBitmapMap[nChecksum] = aBitmapEx;
|
maBitmapMap[nChecksum] = aBitmapEx;
|
||||||
|
mbIsBitmapLayer = true;
|
||||||
|
|
||||||
// json
|
// json
|
||||||
OUString sLayerId = OUString::fromUtf8(GetInterfaceHash(mxMasterPage)) + "." + sPlaceholderType;
|
|
||||||
tools::JsonWriter aJsonWriter;
|
tools::JsonWriter aJsonWriter;
|
||||||
aJsonWriter.put("group", "TextFields");
|
aJsonWriter.put("group", "TextFields");
|
||||||
aJsonWriter.put("id", sLayerId);
|
aJsonWriter.put("slideHash", GetInterfaceHash(mxDrawPage));
|
||||||
mbIsBitmapLayer = true;
|
{
|
||||||
aJsonWriter.put("type", "bitmap");
|
auto aContentNode = aJsonWriter.startNode("content");
|
||||||
aJsonWriter.put("checksum", std::to_string(nChecksum));
|
aJsonWriter.put("type", sPlaceholderType);
|
||||||
|
appendImageInfoPlaceholder(aJsonWriter);
|
||||||
|
}
|
||||||
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
||||||
maJsonMsgList.push_back(msLastJsonMessage);
|
maJsonMsgList.push_back(msLastJsonMessage);
|
||||||
|
|
||||||
@@ -504,7 +574,7 @@ void LOKSlideRenderer::renderLayerImpl(VirtualDevice& rDevice, tools::JsonWriter
|
|||||||
// json
|
// json
|
||||||
mbIsBitmapLayer = true;
|
mbIsBitmapLayer = true;
|
||||||
rJsonWriter.put("type", "bitmap");
|
rJsonWriter.put("type", "bitmap");
|
||||||
rJsonWriter.put("checksum", std::to_string(nChecksum));
|
appendImageInfoPlaceholder(rJsonWriter);
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
rDevice.Erase();
|
rDevice.Erase();
|
||||||
@@ -513,6 +583,21 @@ void LOKSlideRenderer::renderLayerImpl(VirtualDevice& rDevice, tools::JsonWriter
|
|||||||
|
|
||||||
void LOKSlideRenderer::renderDrawPageImpl(VirtualDevice& rDevice)
|
void LOKSlideRenderer::renderDrawPageImpl(VirtualDevice& rDevice)
|
||||||
{
|
{
|
||||||
|
if (mpDPLastAnimatedShape)
|
||||||
|
{
|
||||||
|
tools::JsonWriter aJsonWriter;
|
||||||
|
aJsonWriter.put("group", "DrawPage");
|
||||||
|
aJsonWriter.put("slideHash", GetInterfaceHash(mxDrawPage));
|
||||||
|
aJsonWriter.put("index", mnDPLayerIndex);
|
||||||
|
|
||||||
|
renderAnimatedShapeImpl(rDevice, mpDPLastAnimatedShape, aJsonWriter);
|
||||||
|
mpDPLastAnimatedShape.reset();
|
||||||
|
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
||||||
|
maJsonMsgList.push_back(msLastJsonMessage);
|
||||||
|
++mnDPLayerIndex;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (mpShapesFunctor->isImportDone())
|
if (mpShapesFunctor->isImportDone())
|
||||||
mbDrawPageRenderingDone = true;
|
mbDrawPageRenderingDone = true;
|
||||||
|
|
||||||
@@ -521,18 +606,8 @@ void LOKSlideRenderer::renderDrawPageImpl(VirtualDevice& rDevice)
|
|||||||
|
|
||||||
tools::JsonWriter aJsonWriter;
|
tools::JsonWriter aJsonWriter;
|
||||||
aJsonWriter.put("group", "DrawPage");
|
aJsonWriter.put("group", "DrawPage");
|
||||||
std::string sLayerId = GetInterfaceHash(mxDrawPage) + "." + std::to_string(mnDPLayerIndex);
|
aJsonWriter.put("slideHash", GetInterfaceHash(mxDrawPage));
|
||||||
aJsonWriter.put("id", sLayerId);
|
aJsonWriter.put("index", mnDPLayerIndex);
|
||||||
|
|
||||||
if (mpDPLastAnimatedShape)
|
|
||||||
{
|
|
||||||
renderAnimatedShapeImpl(rDevice, mpDPLastAnimatedShape, aJsonWriter);
|
|
||||||
mpDPLastAnimatedShape.reset();
|
|
||||||
msLastJsonMessage = aJsonWriter.finishAndGetAsOString();
|
|
||||||
maJsonMsgList.push_back(msLastJsonMessage);
|
|
||||||
++mnDPLayerIndex;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool bDoRendering = false;
|
bool bDoRendering = false;
|
||||||
while (!mpShapesFunctor->isImportDone())
|
while (!mpShapesFunctor->isImportDone())
|
||||||
@@ -582,17 +657,14 @@ void LOKSlideRenderer::renderAnimatedShapeImpl(VirtualDevice& rDevice,
|
|||||||
{
|
{
|
||||||
rJsonWriter.put("type", "animated");
|
rJsonWriter.put("type", "animated");
|
||||||
|
|
||||||
|
auto aContentNode = rJsonWriter.startNode("content");
|
||||||
std::string sShapeId = GetInterfaceHash(pShape->getXShape());
|
std::string sShapeId = GetInterfaceHash(pShape->getXShape());
|
||||||
rJsonWriter.put("shapeHash", sShapeId);
|
rJsonWriter.put("hash", sShapeId);
|
||||||
|
|
||||||
bool bIsInitVisible = maAnimatedShapeVisibilityMap.at(sShapeId);
|
bool bIsInitVisible = maAnimatedShapeVisibilityMap.at(sShapeId);
|
||||||
rJsonWriter.put("initVisible", bIsInitVisible);
|
rJsonWriter.put("initVisible", bIsInitVisible);
|
||||||
auto aData = rJsonWriter.startNode("data");
|
mpLayerManager->addShape(pShape);
|
||||||
if (bIsInitVisible)
|
renderLayerImpl(rDevice, rJsonWriter);
|
||||||
{
|
|
||||||
mpLayerManager->addShape(pShape);
|
|
||||||
renderLayerImpl(rDevice, rJsonWriter);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LOKSlideRenderer::renderImpl(LayerGroupType eLayersSet, unsigned char* pBuffer)
|
void LOKSlideRenderer::renderImpl(LayerGroupType eLayersSet, unsigned char* pBuffer)
|
||||||
|
Reference in New Issue
Block a user