| OLD | NEW |
| 1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
| 6 | 6 |
| 7 #include "xfa/fxfa/app/xfa_textlayout.h" | 7 #include "xfa/fxfa/app/xfa_textlayout.h" |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 978 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 989 return TRUE; | 989 return TRUE; |
| 990 } | 990 } |
| 991 fLinePos += fLineHeight; | 991 fLinePos += fLineHeight; |
| 992 } | 992 } |
| 993 return FALSE; | 993 return FALSE; |
| 994 } | 994 } |
| 995 int32_t CXFA_TextLayout::CountBlocks() const { | 995 int32_t CXFA_TextLayout::CountBlocks() const { |
| 996 int32_t iCount = m_Blocks.GetSize() / 2; | 996 int32_t iCount = m_Blocks.GetSize() / 2; |
| 997 return iCount > 0 ? iCount : 1; | 997 return iCount > 0 ? iCount : 1; |
| 998 } | 998 } |
| 999 |
| 999 FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, | 1000 FX_BOOL CXFA_TextLayout::CalcSize(const CFX_SizeF& minSize, |
| 1000 const CFX_SizeF& maxSize, | 1001 const CFX_SizeF& maxSize, |
| 1001 CFX_SizeF& defaultSize) { | 1002 CFX_SizeF& defaultSize) { |
| 1002 defaultSize.x = maxSize.x; | 1003 defaultSize.x = maxSize.x; |
| 1003 if (defaultSize.x < 1) { | 1004 if (defaultSize.x < 1) { |
| 1004 defaultSize.x = 0xFFFF; | 1005 defaultSize.x = 0xFFFF; |
| 1005 } | 1006 } |
| 1006 if (m_pBreak) | 1007 if (m_pBreak) |
| 1007 m_pBreak->Release(); | 1008 m_pBreak->Release(); |
| 1008 | 1009 |
| 1009 m_pBreak = CreateBreak(FALSE); | 1010 m_pBreak = CreateBreak(FALSE); |
| 1010 FX_FLOAT fLinePos = 0; | 1011 FX_FLOAT fLinePos = 0; |
| 1011 m_iLines = 0; | 1012 m_iLines = 0; |
| 1012 m_fMaxWidth = 0; | 1013 m_fMaxWidth = 0; |
| 1013 Loader(defaultSize, fLinePos, FALSE); | 1014 Loader(defaultSize, fLinePos, FALSE); |
| 1014 if (fLinePos < 0.1f) { | 1015 if (fLinePos < 0.1f) { |
| 1015 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); | 1016 fLinePos = m_textParser.GetFontSize(m_pTextProvider, NULL); |
| 1016 } | 1017 } |
| 1017 if (m_pTabstopContext) { | 1018 delete m_pTabstopContext; |
| 1018 delete m_pTabstopContext; | 1019 m_pTabstopContext = nullptr; |
| 1019 m_pTabstopContext = NULL; | |
| 1020 } | |
| 1021 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); | 1020 defaultSize = CFX_SizeF(m_fMaxWidth, fLinePos); |
| 1022 return TRUE; | 1021 return TRUE; |
| 1023 } | 1022 } |
| 1023 |
| 1024 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { | 1024 FX_BOOL CXFA_TextLayout::Layout(const CFX_SizeF& size, FX_FLOAT* fHeight) { |
| 1025 if (size.x < 1) { | 1025 if (size.x < 1) { |
| 1026 return FALSE; | 1026 return FALSE; |
| 1027 } | 1027 } |
| 1028 Unload(); | 1028 Unload(); |
| 1029 m_pBreak = CreateBreak(TRUE); | 1029 m_pBreak = CreateBreak(TRUE); |
| 1030 if (m_pLoader) { | 1030 if (m_pLoader) { |
| 1031 m_pLoader->m_iTotalLines = -1; | 1031 m_pLoader->m_iTotalLines = -1; |
| 1032 m_pLoader->m_iChar = 0; | 1032 m_pLoader->m_iChar = 0; |
| 1033 } | 1033 } |
| 1034 m_iLines = 0; | 1034 m_iLines = 0; |
| 1035 FX_FLOAT fLinePos = 0; | 1035 FX_FLOAT fLinePos = 0; |
| 1036 Loader(size, fLinePos, TRUE); | 1036 Loader(size, fLinePos, TRUE); |
| 1037 UpdateAlign(size.y, fLinePos); | 1037 UpdateAlign(size.y, fLinePos); |
| 1038 if (m_pTabstopContext) { | 1038 delete m_pTabstopContext; |
| 1039 delete m_pTabstopContext; | 1039 m_pTabstopContext = nullptr; |
| 1040 m_pTabstopContext = NULL; | 1040 if (fHeight) |
| 1041 } | |
| 1042 if (fHeight) { | |
| 1043 *fHeight = fLinePos; | 1041 *fHeight = fLinePos; |
| 1044 } | |
| 1045 return TRUE; | 1042 return TRUE; |
| 1046 } | 1043 } |
| 1044 |
| 1047 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { | 1045 FX_BOOL CXFA_TextLayout::Layout(int32_t iBlock) { |
| 1048 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { | 1046 if (m_pLoader == NULL || iBlock < 0 || iBlock >= CountBlocks()) { |
| 1049 return FALSE; | 1047 return FALSE; |
| 1050 } | 1048 } |
| 1051 if (m_pLoader->m_fWidth < 1) { | 1049 if (m_pLoader->m_fWidth < 1) { |
| 1052 return FALSE; | 1050 return FALSE; |
| 1053 } | 1051 } |
| 1054 m_pLoader->m_iTotalLines = -1; | 1052 m_pLoader->m_iTotalLines = -1; |
| 1055 m_iLines = 0; | 1053 m_iLines = 0; |
| 1056 FX_FLOAT fLinePos = 0; | 1054 FX_FLOAT fLinePos = 0; |
| (...skipping 904 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1961 tr.iLength = iLength; | 1959 tr.iLength = iLength; |
| 1962 tr.fFontSize = pPiece->fFontSize; | 1960 tr.fFontSize = pPiece->fFontSize; |
| 1963 tr.iBidiLevel = pPiece->iBidiLevel; | 1961 tr.iBidiLevel = pPiece->iBidiLevel; |
| 1964 tr.iCharRotation = 0; | 1962 tr.iCharRotation = 0; |
| 1965 tr.wLineBreakChar = L'\n'; | 1963 tr.wLineBreakChar = L'\n'; |
| 1966 tr.iVerticalScale = pPiece->iVerScale; | 1964 tr.iVerticalScale = pPiece->iVerScale; |
| 1967 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; | 1965 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; |
| 1968 tr.iHorizontalScale = pPiece->iHorScale; | 1966 tr.iHorizontalScale = pPiece->iHorScale; |
| 1969 return TRUE; | 1967 return TRUE; |
| 1970 } | 1968 } |
| OLD | NEW |