Skip to content

Commit

Permalink
Various improvements.
Browse files Browse the repository at this point in the history
Avoid JS error in app.calc.isRTL when the part is newly added and non-existing in the list.
Parse hash to int when adding a comment marker is being added.
Fix Cypress issues that was related to latest changes on Hide/Show sheets.
Remove debugging code from KitHelper.hpp.
Modify parseDocSize function in helpers.hpp to use JSON instead of text.

Signed-off-by: Gökay Şatır <[email protected]>
Change-Id: I65cc6ef433452da297616f56da8f0d651a23dec6
  • Loading branch information
gokaysatir committed Oct 7, 2024
1 parent 31a7bc4 commit 75bcb6f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion browser/src/canvas/sections/CommentSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ export class Comment extends CanvasSectionObject {
}),
draggable: true
});
if (app.impress.partList[this.sectionProperties.docLayer._selectedPart].hash === this.sectionProperties.data.parthash || app.file.fileBasedView)
if (app.impress.partList[this.sectionProperties.docLayer._selectedPart].hash === parseInt(this.sectionProperties.data.parthash) || app.file.fileBasedView)
this.map.addLayer(this.sectionProperties.annotationMarker);
}
if (this.sectionProperties.data.rectangle != null) {
Expand Down
4 changes: 3 additions & 1 deletion browser/src/docstatefunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ app.calc.isRTL = function () {

const part =
app.map._docLayer._lastStatusJSON.parts[app.map._docLayer._selectedPart];
return part.rtllayout !== 0;

if (part) return part.rtllayout !== 0;
else return false;
};

app.setServerAuditFromCore = function (entries) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ describe(['tagdesktop', 'tagnextcloud', 'tagproxy'], 'Sheet Operations.', functi
//show sheet
calcHelper.selectOptionFromContextMenu('Show Sheet');
cy.cGet('#show-sheets-modal').should('exist');
cy.cGet('#hidden-part-checkbox-1').check();
cy.cGet('#hidden-part-checkbox-Sheet2').check();
cy.cGet('#show-sheets-modal-response').click();
calcHelper.assertNumberofSheets(2);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ describe(['tagmobile', 'tagnextcloud', 'tagproxy'], 'Sheet Operation', function
calcHelper.selectOptionMobileWizard('Show Sheet');

cy.cGet('#mobile-wizard-content-modal-dialog-show-sheets-modal').should('exist');
cy.cGet('#hidden-part-checkbox-1').check();
cy.cGet('#hidden-part-checkbox-Sheet2').check();
cy.cGet('#show-sheets-modal-response').click();

calcHelper.assertNumberofSheets(2);
Expand Down
2 changes: 0 additions & 2 deletions kit/KitHelper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,6 @@ namespace LOKitHelper
resultingString.pop_back();
resultingString += "}";

std::cout << "Resulting string: " << resultingString << std::endl;

return resultingString;
}

Expand Down
12 changes: 4 additions & 8 deletions test/UnitRenderingOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,11 @@ void UnitRenderingOptions::invokeWSDTest()
helpers::sendTextFrame(socket, "status", testname);
const auto status = helpers::assertResponseString(socket, "status:", testname);

// Expected format is something like 'status: type=text parts=2 current=0 width=12808 height=1142'.
Poco::JSON::Parser parser;
Poco::Dynamic::Var statusJsonVar = parser.parse(status.substr(7));
const Poco::SharedPtr<Poco::JSON::Object>& statusJsonObject = statusJsonVar.extract<Poco::JSON::Object::Ptr>();

StringVector tokens(StringVector::tokenize(status, ' '));
LOK_ASSERT_EQUAL(static_cast<size_t>(8), tokens.size());

const std::string token = tokens[5];
const std::string prefix = "height=";
LOK_ASSERT_EQUAL(static_cast<size_t>(0), token.find(prefix));
const int height = std::stoi(token.substr(prefix.size()));
const int height = std::stoi(statusJsonObject->get("height").toString());
// HideWhitespace was ignored, this was 32532, should be around 16706.
LOK_ASSERT(height < 20000);
}
Expand Down
19 changes: 10 additions & 9 deletions test/helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -702,15 +702,16 @@ void parseDocSize(const std::string& message, const std::string& type,
int& part, int& parts, int& width, int& height, int& viewid,
const std::string& testname)
{
StringVector tokens(StringVector::tokenize(message, ' '));

// Expected format is something like 'type= parts= current= width= height='.
const std::string text = tokens[0].substr(std::string("type=").size());
parts = std::stoi(tokens[1].substr(std::string("parts=").size()));
part = std::stoi(tokens[2].substr(std::string("current=").size()));
width = std::stoi(tokens[3].substr(std::string("width=").size()));
height = std::stoi(tokens[4].substr(std::string("height=").size()));
viewid = std::stoi(tokens[5].substr(std::string("viewid=").size()));
Poco::JSON::Parser parser;
Poco::Dynamic::Var statusJsonVar = parser.parse(message);
const Poco::SharedPtr<Poco::JSON::Object>& statusJsonObject = statusJsonVar.extract<Poco::JSON::Object::Ptr>();

const std::string text = statusJsonObject->get("type").toString();
parts = std::stoi(statusJsonObject->get("partscount").toString());
part = std::stoi(statusJsonObject->get("selectedpart").toString());
width = std::stoi(statusJsonObject->get("width").toString());
height = std::stoi(statusJsonObject->get("height").toString());
viewid = std::stoi(statusJsonObject->get("viewid").toString());
LOK_ASSERT_EQUAL(type, text);
LOK_ASSERT(parts > 0);
LOK_ASSERT(part >= 0);
Expand Down

0 comments on commit 75bcb6f

Please sign in to comment.