For bug 75161

This commit is contained in:
Svetlana Kulikova
2025-10-20 17:18:41 +03:00
parent 4a2d0b5e1f
commit 650fb84b6d
5 changed files with 32 additions and 4 deletions

View File

@ -1928,7 +1928,7 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
oInfo.GetBE(nS, dI);
pAnnot->SetBE(nS, dI);
}
if (nFlags & (1 << 3))
if ((nFlags & (1 << 3)) && !oInfo.IsFreeText())
pAnnot->SetC(oInfo.GetC());
if (nFlags & (1 << 4))
{
@ -1983,9 +1983,10 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
if (nFlags & (1 << 3))
{
NSStringUtils::CStringBuilder oRC;
oRC += L"<?xml version=\"1.0\"?><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:23.8.0\" xfa:spec=\"2.0.2\"><p dir=\"ltr\">";
oRC += L"<?xml version=\"1.0\"?><body xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:xfa=\"http://www.xfa.org/schema/xfa-data/1.0/\" xfa:APIVersion=\"Acrobat:23.8.0\" xfa:spec=\"2.0.2\">";
std::vector<CAnnotFieldInfo::CMarkupAnnotPr::CFontData*> arrRC = pPr->GetRC();
bool bCurRTL = false;
if (!arrRC.empty())
{
NSStringUtils::CStringBuilder oDS;
@ -2005,10 +2006,19 @@ HRESULT CPdfWriter::AddAnnotField(NSFonts::IApplicationFonts* pAppFonts, CAnnotF
(unsigned char)(arrRC[0]->dColor[1] * 255.0),
(unsigned char)(arrRC[0]->dColor[2] * 255.0));
sDefaultStyle = oDS.GetData();
bCurRTL = (arrRC[0]->nFontFlag >> 7) & 1;
}
oRC += (bCurRTL ? L"<p dir=\"rtl\">" : L"<p dir=\"ltr\">");
for (int i = 0; i < arrRC.size(); ++i)
{
bool bRTL = (arrRC[i]->nFontFlag >> 7) & 1;
if (bRTL != bCurRTL)
{
oRC += (bRTL ? L"</p><p dir=\"rtl\">" : L"</p><p dir=\"ltr\">");
bCurRTL = bRTL;
}
oRC += L"<span style=\"";
GetRCSpanStyle(arrRC[i], oRC);
oRC += L"\">";

View File

@ -3195,6 +3195,17 @@ std::vector<CAnnotMarkup::CFontData*> CAnnotMarkup::ReadRC(const std::string& sR
if (oLightReader.GetNameA() != "p")
continue;
bool bRTL = false;
while (oLightReader.MoveToNextAttribute())
{
if (oLightReader.GetNameA() == "dir" && oLightReader.GetTextA() == "rtl")
{
bRTL = true;
break;
}
}
oLightReader.MoveToElement();
int nDepthSpan = oLightReader.GetDepth();
if (oLightReader.IsEmptyNode() || !oLightReader.ReadNextSiblingNode2(nDepthSpan))
continue;
@ -3215,12 +3226,16 @@ std::vector<CAnnotMarkup::CFontData*> CAnnotMarkup::ReadRC(const std::string& sR
}
oLightReader.MoveToElement();
if (bRTL)
pFont->unFontFlags |= (1 << 7);
pFont->sText = oLightReader.GetText2A();
arrRC.push_back(pFont);
}
else if (sName == "#text")
{
CAnnotMarkup::CFontData* pFont = new CAnnotMarkup::CFontData(oFontBase);
if (bRTL)
pFont->unFontFlags |= (1 << 7);
pFont->sText = oLightReader.GetTextA();
arrRC.push_back(pFont);
}

View File

@ -346,7 +346,7 @@ public:
{
bool bFind;
BYTE nAlign;
unsigned int unFontFlags; // 0 Bold, 1 Italic, 3 зачеркнутый, 4 подчеркнутый, 5 vertical-align, 6 actual font
unsigned int unFontFlags; // 0 Bold, 1 Italic, 3 зачеркнутый, 4 подчеркнутый, 5 vertical-align, 6 actual font, 7 RTL
double dFontSise;
double dVAlign;
double dColor[3];