xref: /aosp_15_r20/external/pdfium/xfa/fxfa/cxfa_texttabstopscontext.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2017 The PDFium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xfa/fxfa/cxfa_texttabstopscontext.h"
8 
9 #include <algorithm>
10 
11 CXFA_TextTabstopsContext::CXFA_TextTabstopsContext() = default;
12 
13 CXFA_TextTabstopsContext::~CXFA_TextTabstopsContext() = default;
14 
Append(uint32_t dwAlign,float fTabstops)15 void CXFA_TextTabstopsContext::Append(uint32_t dwAlign, float fTabstops) {
16   XFA_TABSTOPS tabstop;
17   tabstop.dwAlign = dwAlign;
18   tabstop.fTabstops = fTabstops;
19 
20   auto it = std::lower_bound(m_tabstops.begin(), m_tabstops.end(), tabstop);
21   m_tabstops.insert(it, tabstop);
22 }
23 
RemoveAll()24 void CXFA_TextTabstopsContext::RemoveAll() {
25   m_tabstops.clear();
26 }
27 
Reset()28 void CXFA_TextTabstopsContext::Reset() {
29   m_iTabIndex = -1;
30   m_bHasTabstops = false;
31   m_fTabWidth = 0;
32   m_fLeft = 0;
33 }
34