| 181 | } |
| 182 | |
| 183 | static pag::TextDocumentHandle ParseTextDocument(const AEGP_StreamVal2&, const QVariantMap& map) { |
| 184 | bool runJavaScript = map.value("runJavaScript", false).toBool(); |
| 185 | std::string compID = map.value("compID").toString().toStdString(); |
| 186 | std::string layerIndex = map.value("layerIndex").toString().toStdString(); |
| 187 | std::string keyFrame = map.value("keyFrame").toString().toStdString(); |
| 188 | std::string outPath = map.value("outPath", "").toString().toStdString(); |
| 189 | if (!runJavaScript || compID.empty() || layerIndex.empty() || keyFrame.empty()) { |
| 190 | return std::make_shared<pag::TextDocument>(); |
| 191 | } |
| 192 | |
| 193 | RegisterTextDocumentScript(); |
| 194 | std::string code = |
| 195 | "PAG.printTextDocuments(" + compID + ", " + layerIndex + ", " + keyFrame + ");"; |
| 196 | std::string result = RunScript(code); |
| 197 | if (result.empty()) { |
| 198 | return std::make_shared<pag::TextDocument>(); |
| 199 | } |
| 200 | |
| 201 | QJsonDocument doc = QJsonDocument::fromJson(result.data()); |
| 202 | if (doc.isNull()) { |
| 203 | return std::make_shared<pag::TextDocument>(); |
| 204 | } |
| 205 | QJsonObject obj = doc.object(); |
| 206 | |
| 207 | auto textDocument = std::make_shared<pag::TextDocument>(); |
| 208 | |
| 209 | /* 13212: Horizontal,see function 'AETextDirectionToTextDirection' for detail */ |
| 210 | textDocument->direction = |
| 211 | AETextDirectionToTextDirection(obj.value("lineOrientation").toInt(13212)); |
| 212 | textDocument->applyFill = obj.value("applyFill").toBool(textDocument->applyFill); |
| 213 | textDocument->applyStroke = obj.value("applyStroke").toBool(textDocument->applyStroke); |
| 214 | textDocument->baselineShift = |
| 215 | static_cast<float>(obj.value("baselineShift").toDouble(textDocument->baselineShift)); |
| 216 | textDocument->boxText = obj.value("boxText").toBool(textDocument->boxText); |
| 217 | textDocument->boxTextPos = |
| 218 | ArraryToPoint(obj.value("boxTextPos").toArray(), textDocument->boxTextPos); |
| 219 | textDocument->boxTextSize = |
| 220 | ArraryToPoint(obj.value("boxTextSize").toArray(), textDocument->boxTextSize); |
| 221 | textDocument->fauxBold = obj.value("fauxBold").toBool(textDocument->fauxBold); |
| 222 | textDocument->fauxItalic = obj.value("fauxItalic").toBool(textDocument->fauxItalic); |
| 223 | textDocument->fillColor = ArrayToColor(obj.value("fillColor").toArray(), textDocument->fillColor); |
| 224 | textDocument->fontFamily = obj.value("fontFamily").toString("").toStdString(); |
| 225 | textDocument->fontStyle = obj.value("fontStyle").toString("").toStdString(); |
| 226 | textDocument->fontSize = |
| 227 | static_cast<float>(obj.value("fontSize").toDouble(textDocument->fontSize)); |
| 228 | textDocument->strokeColor = |
| 229 | ArrayToColor(obj.value("strokeColor").toArray(), textDocument->strokeColor); |
| 230 | textDocument->strokeOverFill = obj.value("strokeOverFill").toBool(textDocument->strokeOverFill); |
| 231 | textDocument->strokeWidth = |
| 232 | static_cast<float>(obj.value("strokeWidth").toDouble(textDocument->strokeWidth)); |
| 233 | textDocument->text = obj.value("text").toString("").replace("\\n", "\n").toStdString(); |
| 234 | textDocument->justification = |
| 235 | AEJustificationToJustification(static_cast<float>(obj.value("justification").toInt(0))); |
| 236 | textDocument->leading = static_cast<float>(obj.value("leading").toDouble(textDocument->leading)); |
| 237 | if (textDocument->leading == 0) { |
| 238 | textDocument->leading = |
| 239 | static_cast<float>(obj.value("baselineLocs").toDouble(textDocument->fontSize)); |
| 240 | } |
nothing calls this directly
no test coverage detected