Kaydet (Commit) b1a3db96 authored tarafından Ashod Nakashian's avatar Ashod Nakashian Kaydeden (comit) Ashod Nakashian

LOK: Move RectangleAndPart to the header

This is in preparation to cache them.

Change-Id: Ic511caf5a8798750288e9271f6898ab38fe2055f
Reviewed-on: https://gerrit.libreoffice.org/67889
Tested-by: Jenkins
Reviewed-by: 's avatarAshod Nakashian <ashnakash@gmail.com>
üst 18b5a001
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <LibreOfficeKit/LibreOfficeKitEnums.h>
#include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/beans/PropertyValue.hpp>
#include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XComponent.hpp>
#include <tools/gen.hxx>
#include <sfx2/lokhelper.hxx>
#include <desktop/dllapi.h> #include <desktop/dllapi.h>
...@@ -29,6 +31,43 @@ class LOKInteractionHandler; ...@@ -29,6 +31,43 @@ class LOKInteractionHandler;
namespace desktop { namespace desktop {
/// Represents an invalidated rectangle inside a given document part.
struct RectangleAndPart
{
tools::Rectangle m_aRectangle;
int m_nPart;
RectangleAndPart()
: m_nPart(INT_MIN) // -1 is reserved to mean "all parts".
{
}
OString toString() const
{
std::stringstream ss;
ss << m_aRectangle.toString();
if (m_nPart >= -1)
ss << ", " << m_nPart;
return ss.str().c_str();
}
/// Infinite Rectangle is both sides are
/// equal or longer than SfxLokHelper::MaxTwips.
bool isInfinite() const
{
return m_aRectangle.GetWidth() >= SfxLokHelper::MaxTwips &&
m_aRectangle.GetHeight() >= SfxLokHelper::MaxTwips;
}
/// Empty Rectangle is when it has zero dimensions.
bool isEmpty() const
{
return m_aRectangle.IsEmpty();
}
static RectangleAndPart Create(const std::string& rPayload);
};
class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle class DESKTOP_DLLPUBLIC CallbackFlushHandler : public Idle
{ {
public: public:
......
...@@ -93,7 +93,6 @@ ...@@ -93,7 +93,6 @@
#include <sfx2/viewfrm.hxx> #include <sfx2/viewfrm.hxx>
#include <sfx2/msgpool.hxx> #include <sfx2/msgpool.hxx>
#include <sfx2/dispatch.hxx> #include <sfx2/dispatch.hxx>
#include <sfx2/lokhelper.hxx>
#include <sfx2/DocumentSigner.hxx> #include <sfx2/DocumentSigner.hxx>
#include <svx/dialmgr.hxx> #include <svx/dialmgr.hxx>
#include <svx/dialogs.hrc> #include <svx/dialogs.hrc>
...@@ -400,94 +399,62 @@ static boost::property_tree::ptree unoAnyToPropertyTree(const uno::Any& anyItem) ...@@ -400,94 +399,62 @@ static boost::property_tree::ptree unoAnyToPropertyTree(const uno::Any& anyItem)
return aTree; return aTree;
} }
namespace { namespace desktop {
/// Represents an invalidated rectangle inside a given document part. RectangleAndPart RectangleAndPart::Create(const std::string& rPayload)
struct RectangleAndPart
{ {
tools::Rectangle m_aRectangle; RectangleAndPart aRet;
int m_nPart; if (rPayload.compare(0, 5, "EMPTY") == 0) // payload starts with "EMPTY"
RectangleAndPart()
: m_nPart(INT_MIN) // -1 is reserved to mean "all parts".
{ {
} aRet.m_aRectangle = tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips);
if (comphelper::LibreOfficeKit::isPartInInvalidation())
aRet.m_nPart = std::stol(rPayload.substr(6));
OString toString() const return aRet;
{
std::stringstream ss;
ss << m_aRectangle.toString();
if (m_nPart >= -1)
ss << ", " << m_nPart;
return ss.str().c_str();
} }
/// Infinite Rectangle is both sides are std::istringstream aStream(rPayload);
/// equal or longer than SfxLokHelper::MaxTwips. long nLeft, nTop, nWidth, nHeight;
bool isInfinite() const long nPart = INT_MIN;
char nComma;
if (comphelper::LibreOfficeKit::isPartInInvalidation())
{ {
return m_aRectangle.GetWidth() >= SfxLokHelper::MaxTwips && aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight >> nComma >> nPart;
m_aRectangle.GetHeight() >= SfxLokHelper::MaxTwips;
} }
else
/// Empty Rectangle is when it has zero dimensions.
bool isEmpty() const
{ {
return m_aRectangle.IsEmpty(); aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
} }
static RectangleAndPart Create(const std::string& rPayload) if (nWidth > 0 && nHeight > 0)
{ {
RectangleAndPart aRet; // The top-left corner starts at (0, 0).
if (rPayload.compare(0, 5, "EMPTY") == 0) // payload starts with "EMPTY" // Anything negative is invalid.
if (nLeft < 0)
{ {
aRet.m_aRectangle = tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips); nWidth += nLeft;
if (comphelper::LibreOfficeKit::isPartInInvalidation()) nLeft = 0;
aRet.m_nPart = std::stol(rPayload.substr(6));
return aRet;
} }
std::istringstream aStream(rPayload); if (nTop < 0)
long nLeft, nTop, nWidth, nHeight;
long nPart = INT_MIN;
char nComma;
if (comphelper::LibreOfficeKit::isPartInInvalidation())
{ {
aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight >> nComma >> nPart; nHeight += nTop;
} nTop = 0;
else
{
aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight;
} }
if (nWidth > 0 && nHeight > 0) if (nWidth > 0 && nHeight > 0)
{ {
// The top-left corner starts at (0, 0). aRet.m_aRectangle = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
// Anything negative is invalid.
if (nLeft < 0)
{
nWidth += nLeft;
nLeft = 0;
}
if (nTop < 0)
{
nHeight += nTop;
nTop = 0;
}
if (nWidth > 0 && nHeight > 0)
{
aRet.m_aRectangle = tools::Rectangle(nLeft, nTop, nLeft + nWidth, nTop + nHeight);
}
} }
// else leave empty rect.
aRet.m_nPart = nPart;
return aRet;
} }
}; // else leave empty rect.
aRet.m_nPart = nPart;
return aRet;
}
}
namespace {
bool lcl_isViewCallbackType(const int type) bool lcl_isViewCallbackType(const int type)
{ {
...@@ -1045,7 +1012,7 @@ void CallbackFlushHandler::queue(const int type, const char* data) ...@@ -1045,7 +1012,7 @@ void CallbackFlushHandler::queue(const int type, const char* data)
[] (const queue_type::value_type& elem) { return (elem.first == LOK_CALLBACK_INVALIDATE_TILES); }); [] (const queue_type::value_type& elem) { return (elem.first == LOK_CALLBACK_INVALIDATE_TILES); });
if (pos != m_queue.rend()) if (pos != m_queue.rend())
{ {
RectangleAndPart rcOld = RectangleAndPart::Create(pos->second); const RectangleAndPart rcOld = RectangleAndPart::Create(pos->second);
if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart)) if (rcOld.isInfinite() && (rcOld.m_nPart == -1 || rcOld.m_nPart == rcNew.m_nPart))
{ {
SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload << "] since all tiles need to be invalidated."); SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload << "] since all tiles need to be invalidated.");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment