Fix Border, Highlighting and RadiosInUnison

This commit is contained in:
Kulikova Svetlana
2023-03-10 11:03:54 +03:00
parent 2b3d784d6a
commit 45c0c521bf
3 changed files with 71 additions and 58 deletions

View File

@ -419,22 +419,25 @@
// Строка стиля по умолчанию (в формате CSS2) - DS
if (flags & (1 << 1))
rec["defaultStyle"] = reader.readString();
// Границы - Border/BS
rec["borderStyle"] = reader.readInt();
rec["borderWidth"] = reader.readDouble();
// Dash Pattern границы
if (rec["borderStyle"] == 1)
{
rec["dashed"] = [];
rec["dashed"].push(reader.readDouble());
rec["dashed"].push(reader.readDouble());
}
// Эффекты границы - BE
if (flags & (1 << 2))
rec["borderCloudy"] = reader.readDouble();
// Режим выделения - H
if (flags & (1 << 3))
rec["highlight"] = reader.readString();
// Границы - Border/BS
if (flags & (1 << 4))
{
rec["borderStyle"] = reader.readInt();
rec["borderWidth"] = reader.readDouble();
// Dash Pattern границы
if (rec["borderStyle"] == 1)
{
rec["dashed"] = [];
rec["dashed"].push(reader.readDouble());
rec["dashed"].push(reader.readDouble());
}
}
if (rec["type"] == "checkbox" || rec["type"] == "radiobutton" || rec["type"] == "button")
{

View File

@ -431,29 +431,12 @@ int main(int argc, char* argv[])
std::cout << "DS " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
int nBorderType = READ_INT(pWidgets + i);
i += 4;
std::cout << "Border type " << nBorderType << " ";
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "width " << (double)nPathLength / 100.0 << ", ";
if (nBorderType == 1)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "Dash Pattern " << (double)nPathLength / 100.0 << " ";
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << ", ";
}
if (nFlags & (1 << 2))
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "BE C " << (double)nPathLength / 100.0 << ", ";
}
else
std::cout << "BE S, ";
if (nFlags & (1 << 3))
{
nPathLength = READ_INT(pWidgets + i);
@ -461,6 +444,24 @@ int main(int argc, char* argv[])
std::cout << "H " << std::string((char*)(pWidgets + i), nPathLength) << ", ";
i += nPathLength;
}
if (nFlags & (1 << 4))
{
int nBorderType = READ_INT(pWidgets + i);
i += 4;
std::cout << "Border type " << nBorderType << " ";
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "width " << (double)nPathLength / 100.0 << ", ";
if (nBorderType == 1)
{
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << "Dash Pattern " << (double)nPathLength / 100.0 << " ";
nPathLength = READ_INT(pWidgets + i);
i += 4;
std::cout << (double)nPathLength / 100.0 << ", ";
}
}
if (sType == "checkbox" || sType == "radiobutton" || sType == "button")
{
std::cout << (nFlags & (1 << 9) ? "Yes" : "Off") << ", ";

View File

@ -831,11 +831,30 @@ oObj.free();\
// 2 - Строка стиля по умолчанию - DS
DICT_LOOKUP_STRING(oField, "DS", 1);
// Границы и Dash Pattern - Border/BS
// 3 - Эффекты границы - BE
Object oBE, oBorderBE, oBorderBEI;
if (oField.dictLookup("BE", &oBE)->isDict() && oBE.dictLookup("S", &oBorderBE)->isName("C") && oBE.dictLookup("I", &oBorderBEI)->isNum())
{
nFlags |= (1 << 2);
oRes.AddDouble(oBorderBEI.getNum());
}
oBE.free(); oBorderBE.free(); oBorderBEI.free();
// 4 - Режим выделения - H
Object oHighlighting;
if (oField.dictLookup("H", &oHighlighting)->isName())
{
nFlags |= (1 << 3);
std::string sName(oHighlighting.getName());
oRes.WriteString((BYTE*)sName.c_str(), (unsigned int)sName.length());
}
oHighlighting.free();
// 5 - Границы и Dash Pattern - Border/BS
Object oBorder;
AnnotBorderType nBorderType = annotBorderSolid;
unsigned int nBorderType = 5;
double dBorderWidth = 1, dDashesAlternating = 3, dGaps = 3;
if (oField.dictLookup("BS", &oBorder) && oBorder.isDict())
if (oField.dictLookup("BS", &oBorder)->isDict())
{
Object oV;
if (oBorder.dictLookup("S", &oV)->isName())
@ -850,6 +869,8 @@ oObj.free();\
nBorderType = annotBorderInset;
else if (oV.isName("U"))
nBorderType = annotBorderUnderlined;
else
nBorderType = annotBorderSolid;
}
oV.free();
if (oBorder.dictLookup("W", &oV)->isNum())
@ -872,21 +893,22 @@ oObj.free();\
else
{
oBorder.free();
if (oField.dictLookup("Border", &oBorder) && oBorder.isArray() && oBorder.arrayGetLength() > 2)
if (oField.dictLookup("Border", &oBorder)->isArray() && oBorder.arrayGetLength() > 2)
{
nBorderType = annotBorderSolid;
Object oV;
if (oBorder.arrayGet(2, &oV) && oV.isNum())
dBorderWidth = oV.getNum();
oV.free();
if (oBorder.arrayGetLength() > 3 && oBorder.arrayGet(3, &oV) && oV.isArray() && oV.arrayGetLength() > 1)
if (oBorder.arrayGetLength() > 3 && oBorder.arrayGet(3, &oV)->isArray() && oV.arrayGetLength() > 1)
{
nBorderType = annotBorderDashed;
Object oV1;
if (oV.arrayGet(0, &oV1) && oV1.isNum())
if (oV.arrayGet(0, &oV1)->isNum())
dDashesAlternating = oV1.getNum();
oV1.free();
if (oV.arrayGet(1, &oV1) && oV1.isNum())
if (oV.arrayGet(1, &oV1)->isNum())
dGaps = oV1.getNum();
oV1.free();
}
@ -894,33 +916,18 @@ oObj.free();\
}
}
oBorder.free();
oRes.AddInt(nBorderType);
oRes.AddDouble(dBorderWidth);
if (nBorderType == annotBorderDashed)
if (nBorderType != 5)
{
oRes.AddDouble(dDashesAlternating);
oRes.AddDouble(dGaps);
nFlags |= (1 << 4);
oRes.AddInt(nBorderType);
oRes.AddDouble(dBorderWidth);
if (nBorderType == annotBorderDashed)
{
oRes.AddDouble(dDashesAlternating);
oRes.AddDouble(dGaps);
}
}
// 3 - Эффекты границы - BE
Object oBorderBE, oBorderBEI;
if (oField.dictLookup("BE", &oBorder) && oBorder.isDict() && oBorder.dictLookup("S", &oBorderBE)->isName("C") && oBorder.dictLookup("I", &oBorderBEI)->isNum())
{
nFlags |= (1 << 2);
oRes.AddDouble(oBorderBEI.getNum());
}
oBorder.free(); oBorderBE.free(); oBorderBEI.free();
// 4 - Режим выделения - H
Object oHighlighting;
if (oField.dictLookup("H", &oHighlighting) && oBorder.isName())
{
nFlags |= (1 << 3);
std::string sName(oBorder.getName());
oRes.WriteString((BYTE*)sName.c_str(), (unsigned int)sName.length());
}
oHighlighting.free();
// Значение аннотации из текущего внешнего вида
/*
Object oAP, oAppearance;
@ -973,6 +980,7 @@ oObj.free();\
nFlags |= (1 << 9);
// Если Checkbox/RadioButton наследует Opt, то состояние соответствует порядковому в массиве Kids из Opt
/*
int nDepth = 0;
Object oParentObj;
oField.dictLookup("Parent", &oParentObj);
@ -1005,6 +1013,7 @@ oObj.free();\
++nDepth;
}
oParentObj.free();
*/
Object oMK;
if (oField.dictLookup("MK", &oMK) && oMK.isDict())