diff options
author | Ashod Nakashian <ashod.nakashian@collabora.co.uk> | 2019-02-13 13:51:14 -0500 |
---|---|---|
committer | Ashod Nakashian <ashnakash@gmail.com> | 2019-02-22 15:26:21 +0100 |
commit | b1a3db96dea8d0c2ec57ed843703f7b93b9dd4fe (patch) | |
tree | a49bbc76284e104cdfd97ee19e1e3b58aa9c8359 /desktop/source | |
parent | 18b5a001cc5b306e1548fb70e610bdc1164cf4ca (diff) |
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: Ashod Nakashian <ashnakash@gmail.com>
Diffstat (limited to 'desktop/source')
-rw-r--r-- | desktop/source/lib/init.cxx | 103 |
1 files changed, 35 insertions, 68 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index a7e1161a1bde..cd1492cb65ae 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -93,7 +93,6 @@ #include <sfx2/viewfrm.hxx> #include <sfx2/msgpool.hxx> #include <sfx2/dispatch.hxx> -#include <sfx2/lokhelper.hxx> #include <sfx2/DocumentSigner.hxx> #include <svx/dialmgr.hxx> #include <svx/dialogs.hrc> @@ -400,94 +399,62 @@ static boost::property_tree::ptree unoAnyToPropertyTree(const uno::Any& anyItem) return aTree; } -namespace { +namespace desktop { -/// Represents an invalidated rectangle inside a given document part. -struct RectangleAndPart +RectangleAndPart RectangleAndPart::Create(const std::string& rPayload) { - tools::Rectangle m_aRectangle; - int m_nPart; - - RectangleAndPart() - : m_nPart(INT_MIN) // -1 is reserved to mean "all parts". + RectangleAndPart aRet; + if (rPayload.compare(0, 5, "EMPTY") == 0) // payload starts with "EMPTY" { - } + 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 - { - std::stringstream ss; - ss << m_aRectangle.toString(); - if (m_nPart >= -1) - ss << ", " << m_nPart; - return ss.str().c_str(); + return aRet; } - /// Infinite Rectangle is both sides are - /// equal or longer than SfxLokHelper::MaxTwips. - bool isInfinite() const + std::istringstream aStream(rPayload); + long nLeft, nTop, nWidth, nHeight; + long nPart = INT_MIN; + char nComma; + if (comphelper::LibreOfficeKit::isPartInInvalidation()) { - return m_aRectangle.GetWidth() >= SfxLokHelper::MaxTwips && - m_aRectangle.GetHeight() >= SfxLokHelper::MaxTwips; + aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight >> nComma >> nPart; } - - /// Empty Rectangle is when it has zero dimensions. - bool isEmpty() const + else { - 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; - if (rPayload.compare(0, 5, "EMPTY") == 0) // payload starts with "EMPTY" + // The top-left corner starts at (0, 0). + // Anything negative is invalid. + if (nLeft < 0) { - aRet.m_aRectangle = tools::Rectangle(0, 0, SfxLokHelper::MaxTwips, SfxLokHelper::MaxTwips); - if (comphelper::LibreOfficeKit::isPartInInvalidation()) - aRet.m_nPart = std::stol(rPayload.substr(6)); - - return aRet; + nWidth += nLeft; + nLeft = 0; } - std::istringstream aStream(rPayload); - long nLeft, nTop, nWidth, nHeight; - long nPart = INT_MIN; - char nComma; - if (comphelper::LibreOfficeKit::isPartInInvalidation()) + if (nTop < 0) { - aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight >> nComma >> nPart; - } - else - { - aStream >> nLeft >> nComma >> nTop >> nComma >> nWidth >> nComma >> nHeight; + nHeight += nTop; + nTop = 0; } if (nWidth > 0 && nHeight > 0) { - // The top-left corner starts at (0, 0). - // 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); - } + 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) { @@ -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); }); 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)) { SAL_INFO("lok", "Skipping queue [" << type << "]: [" << payload << "] since all tiles need to be invalidated."); |