void CPDF_Annot::DrawBorder(CFX_RenderDevice* pDevice, const CFX_Matrix* pUser2Device, const CPDF_RenderOptions* pOptions) { if (GetSubtype() == CPDF_Annot::Subtype::POPUP) return; uint32_t annot_flags = GetFlags(); if (annot_flags & ANNOTFLAG_HIDDEN) { return; } bool bPrinting = pDevice->GetDeviceClass() == FXDC_PRINTER || (pOptions && (pOptions->m_Flags & RENDER_PRINTPREVIEW)); if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) { return; } if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) { return; } CPDF_Dictionary* pBS = m_pAnnotDict->GetDictBy("BS"); char style_char; FX_FLOAT width; CPDF_Array* pDashArray = nullptr; if (!pBS) { CPDF_Array* pBorderArray = m_pAnnotDict->GetArrayBy("Border"); style_char = 'S'; if (pBorderArray) { width = pBorderArray->GetNumberAt(2); if (pBorderArray->GetCount() == 4) { pDashArray = pBorderArray->GetArrayAt(3); if (!pDashArray) { return; } size_t nLen = pDashArray->GetCount(); size_t i = 0; for (; i < nLen; ++i) { CPDF_Object* pObj = pDashArray->GetDirectObjectAt(i); if (pObj && pObj->GetInteger()) { break; } } if (i == nLen) { return; } style_char = 'D'; } } else { width = 1; } } else { CFX_ByteString style = pBS->GetStringBy("S"); pDashArray = pBS->GetArrayBy("D"); style_char = style[1]; width = pBS->GetNumberBy("W"); } if (width <= 0) { return; } CPDF_Array* pColor = m_pAnnotDict->GetArrayBy("C"); uint32_t argb = 0xff000000; if (pColor) { int R = (int32_t)(pColor->GetNumberAt(0) * 255); int G = (int32_t)(pColor->GetNumberAt(1) * 255); int B = (int32_t)(pColor->GetNumberAt(2) * 255); argb = ArgbEncode(0xff, R, G, B); } CFX_GraphStateData graph_state; graph_state.m_LineWidth = width; if (style_char == 'D') { if (pDashArray) { size_t dash_count = pDashArray->GetCount(); if (dash_count % 2) { dash_count++; } graph_state.m_DashArray = FX_Alloc(FX_FLOAT, dash_count); graph_state.m_DashCount = dash_count; size_t i; for (i = 0; i < pDashArray->GetCount(); ++i) { graph_state.m_DashArray[i] = pDashArray->GetNumberAt(i); } if (i < dash_count) { graph_state.m_DashArray[i] = graph_state.m_DashArray[i - 1]; } } else { graph_state.m_DashArray = FX_Alloc(FX_FLOAT, 2); graph_state.m_DashCount = 2; graph_state.m_DashArray[0] = graph_state.m_DashArray[1] = 3 * 1.0f; } } CFX_FloatRect rect = GetRect(); CFX_PathData path; width /= 2; path.AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width); int fill_type = 0; if (pOptions && (pOptions->m_Flags & RENDER_NOPATHSMOOTH)) { fill_type |= FXFILL_NOPATHSMOOTH; } pDevice->DrawPath(&path, pUser2Device, &graph_state, argb, argb, fill_type); }