WideString CBC_OnedCode128Writer::FilterContents(WideStringView contents) { const wchar_t limit = m_codeFormat == BC_CODE128_B ? 126 : 106; WideString filtered; filtered.Reserve(contents.GetLength()); for (size_t i = 0; i < contents.GetLength(); i++) { wchar_t ch = contents[i]; if (ch > 175) { i++; continue; } if (ch >= 32 && ch <= limit) filtered += ch; } return filtered; }
bool CPDF_TextPage::IsHyphen(wchar_t curChar) const { WideStringView curText = m_TempTextBuf.AsStringView(); if (curText.IsEmpty()) curText = m_TextBuf.AsStringView(); if (curText.IsEmpty()) return false; auto iter = curText.rbegin(); for (; (iter + 1) != curText.rend() && *iter == 0x20; ++iter) { // Do nothing } if (!IsHyphenCode(*iter)) return false; if ((iter + 1) != curText.rend()) { iter++; if (FXSYS_iswalpha(*iter) && FXSYS_iswalnum(curChar)) return true; } const PAGECHAR_INFO* pPrevCharInfo = GetPrevCharInfo(); return pPrevCharInfo && pPrevCharInfo->m_Flag == FPDFTEXT_CHAR_PIECE && IsHyphenCode(pPrevCharInfo->m_Unicode); }
bool CBC_Code39::Encode(WideStringView contents) { if (contents.IsEmpty()) return false; BCFORMAT format = BCFORMAT_CODE_39; int32_t outWidth = 0; int32_t outHeight = 0; auto* pWriter = GetOnedCode39Writer(); WideString filtercontents = pWriter->FilterContents(contents); m_renderContents = pWriter->RenderTextContents(contents); ByteString byteString = filtercontents.ToUTF8(); std::unique_ptr<uint8_t, FxFreeDeleter> data( pWriter->Encode(byteString, format, outWidth, outHeight)); return data && pWriter->RenderResult(m_renderContents.AsStringView(), data.get(), outWidth); }
CFX_CSSSyntaxStatus CFX_CSSStyleSheet::LoadStyleRule( CFX_CSSSyntaxParser* pSyntax, std::vector<std::unique_ptr<CFX_CSSStyleRule>>* ruleArray) { std::vector<std::unique_ptr<CFX_CSSSelector>> selectors; CFX_CSSStyleRule* pStyleRule = nullptr; int32_t iValueLen = 0; const CFX_CSSData::Property* property = nullptr; WideString wsName; while (1) { switch (pSyntax->DoSyntaxParse()) { case CFX_CSSSyntaxStatus::Selector: { WideStringView strValue = pSyntax->GetCurrentString(); auto pSelector = CFX_CSSSelector::FromString(strValue); if (pSelector) selectors.push_back(std::move(pSelector)); break; } case CFX_CSSSyntaxStatus::PropertyName: { WideStringView strValue = pSyntax->GetCurrentString(); property = CFX_CSSData::GetPropertyByName(strValue); if (!property) wsName = WideString(strValue); break; } case CFX_CSSSyntaxStatus::PropertyValue: { if (property || iValueLen > 0) { WideStringView strValue = pSyntax->GetCurrentString(); auto* decl = pStyleRule->GetDeclaration(); if (!strValue.IsEmpty()) { if (property) { decl->AddProperty(property, strValue); } else { decl->AddProperty(wsName, WideString(strValue)); } } } break; } case CFX_CSSSyntaxStatus::DeclOpen: { if (!pStyleRule && !selectors.empty()) { auto rule = pdfium::MakeUnique<CFX_CSSStyleRule>(); pStyleRule = rule.get(); pStyleRule->SetSelector(&selectors); ruleArray->push_back(std::move(rule)); } else { SkipRuleSet(pSyntax); return CFX_CSSSyntaxStatus::None; } break; } case CFX_CSSSyntaxStatus::DeclClose: { if (pStyleRule && pStyleRule->GetDeclaration()->empty()) { ruleArray->pop_back(); pStyleRule = nullptr; } return CFX_CSSSyntaxStatus::None; } case CFX_CSSSyntaxStatus::EOS: return CFX_CSSSyntaxStatus::EOS; case CFX_CSSSyntaxStatus::Error: default: return CFX_CSSSyntaxStatus::Error; } } }