| 75 | } |
| 76 | |
| 77 | bool Section::loadSectionFile(const int fontId, const float lineCompression, const bool extraParagraphSpacing, |
| 78 | const uint8_t paragraphAlignment, const uint16_t viewportWidth, |
| 79 | const uint16_t viewportHeight, const bool hyphenationEnabled, const bool embeddedStyle, |
| 80 | const uint8_t imageRendering, const bool focusReadingEnabled) { |
| 81 | if (!Storage.openFileForRead("SCT", filePath, file)) { |
| 82 | return false; |
| 83 | } |
| 84 | |
| 85 | // Match parameters |
| 86 | { |
| 87 | uint8_t version; |
| 88 | serialization::readPod(file, version); |
| 89 | if (version != SECTION_FILE_VERSION) { |
| 90 | // Explicit close() required: member variable persists beyond function scope |
| 91 | file.close(); |
| 92 | LOG_ERR("SCT", "Deserialization failed: Unknown version %u", version); |
| 93 | clearCache(); |
| 94 | return false; |
| 95 | } |
| 96 | |
| 97 | int fileFontId; |
| 98 | uint16_t fileViewportWidth, fileViewportHeight; |
| 99 | float fileLineCompression; |
| 100 | bool fileExtraParagraphSpacing; |
| 101 | uint8_t fileParagraphAlignment; |
| 102 | bool fileHyphenationEnabled; |
| 103 | bool fileEmbeddedStyle; |
| 104 | uint8_t fileImageRendering; |
| 105 | bool fileFocusReadingEnabled; |
| 106 | serialization::readPod(file, fileFontId); |
| 107 | serialization::readPod(file, fileLineCompression); |
| 108 | serialization::readPod(file, fileExtraParagraphSpacing); |
| 109 | serialization::readPod(file, fileParagraphAlignment); |
| 110 | serialization::readPod(file, fileViewportWidth); |
| 111 | serialization::readPod(file, fileViewportHeight); |
| 112 | serialization::readPod(file, fileHyphenationEnabled); |
| 113 | serialization::readPod(file, fileEmbeddedStyle); |
| 114 | serialization::readPod(file, fileImageRendering); |
| 115 | serialization::readPod(file, fileFocusReadingEnabled); |
| 116 | |
| 117 | if (fontId != fileFontId || lineCompression != fileLineCompression || |
| 118 | extraParagraphSpacing != fileExtraParagraphSpacing || paragraphAlignment != fileParagraphAlignment || |
| 119 | viewportWidth != fileViewportWidth || viewportHeight != fileViewportHeight || |
| 120 | hyphenationEnabled != fileHyphenationEnabled || embeddedStyle != fileEmbeddedStyle || |
| 121 | imageRendering != fileImageRendering || focusReadingEnabled != fileFocusReadingEnabled) { |
| 122 | file.close(); |
| 123 | LOG_ERR("SCT", "Deserialization failed: Parameters do not match"); |
| 124 | clearCache(); |
| 125 | return false; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | serialization::readPod(file, pageCount); |
| 130 | // Explicit close() required: member variable persists beyond function scope |
| 131 | file.close(); |
| 132 | LOG_DBG("SCT", "Deserialization succeeded: %d pages", pageCount); |
| 133 | return true; |
| 134 | } |
no test coverage detected