Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: xfa/fgas/layout/fgas_textbreak.cpp

Issue 1998873002: Clean up XFA code which causes warnings (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/fgas/layout/fgas_textbreak.h" 7 #include "xfa/fgas/layout/fgas_textbreak.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after
1187 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f); 1187 int32_t iFontSize = FXSYS_round(fFontSize * 20.0f);
1188 int32_t iAscent = pFont->GetAscent(); 1188 int32_t iAscent = pFont->GetAscent();
1189 int32_t iDescent = pFont->GetDescent(); 1189 int32_t iDescent = pFont->GetDescent();
1190 int32_t iMaxHeight = iAscent - iDescent; 1190 int32_t iMaxHeight = iAscent - iDescent;
1191 FX_FLOAT fFontHeight = fFontSize; 1191 FX_FLOAT fFontHeight = fFontSize;
1192 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight; 1192 FX_FLOAT fAscent = fFontHeight * (FX_FLOAT)iAscent / (FX_FLOAT)iMaxHeight;
1193 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight; 1193 FX_FLOAT fDescent = fFontHeight * (FX_FLOAT)iDescent / (FX_FLOAT)iMaxHeight;
1194 FX_BOOL bVerticalDoc = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0; 1194 FX_BOOL bVerticalDoc = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalLayout) != 0;
1195 FX_BOOL bVerticalChar = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0; 1195 FX_BOOL bVerticalChar = (dwStyles & FX_TXTLAYOUTSTYLE_VerticalChars) != 0;
1196 int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation; 1196 int32_t iRotation = GetLineRotation(dwStyles) + pTxtRun->iCharRotation;
1197 int32_t iCharRotation;
1198 FX_WCHAR wch, wPrev = 0xFEFF, wNext, wForm, wLast = 0xFEFF;
1199 int32_t iWidth, iCharWidth, iCharHeight;
1200 FX_FLOAT fX, fY, fCharWidth, fCharHeight; 1197 FX_FLOAT fX, fY, fCharWidth, fCharHeight;
1201 int32_t iHorScale = pTxtRun->iHorizontalScale; 1198 int32_t iHorScale = pTxtRun->iHorizontalScale;
1202 int32_t iVerScale = pTxtRun->iVerticalScale; 1199 int32_t iVerScale = pTxtRun->iVerticalScale;
1203 FX_BOOL bSkipSpace = pTxtRun->bSkipSpace; 1200 FX_BOOL bSkipSpace = pTxtRun->bSkipSpace;
1204 FX_BOOL bEmptyChar, bShadda = FALSE, bLam = FALSE;
1205 uint32_t dwProps, dwCharType;
1206 FX_FORMCHAR formChars[3]; 1201 FX_FORMCHAR formChars[3];
1207 FX_FLOAT fYBase; 1202 FX_FLOAT fYBase;
1208 fX = rtText.left; 1203 fX = rtText.left;
1209 if (bVerticalDoc) { 1204 if (bVerticalDoc) {
1210 fX += (rtText.width - fFontSize) / 2.0f; 1205 fX += (rtText.width - fFontSize) / 2.0f;
1211 fYBase = bRTLPiece ? rtText.bottom() : rtText.top; 1206 fYBase = bRTLPiece ? rtText.bottom() : rtText.top;
1212 fY = fYBase; 1207 fY = fYBase;
1213 } else { 1208 } else {
1214 if (bRTLPiece) { 1209 if (bRTLPiece) {
1215 fX = rtText.right(); 1210 fX = rtText.right();
1216 } 1211 }
1217 fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f; 1212 fYBase = rtText.top + (rtText.height - fFontSize) / 2.0f;
1218 fY = fYBase + fAscent; 1213 fY = fYBase + fAscent;
1219 } 1214 }
1220 int32_t iCount = 0, iNext, iForms; 1215 int32_t iCount = 0;
1216 int32_t iNext = 0;
1217 FX_WCHAR wPrev = 0xFEFF;
1218 FX_WCHAR wNext = 0xFEFF;
1219 FX_WCHAR wForm = 0xFEFF;
1220 FX_WCHAR wLast = 0xFEFF;
1221 FX_BOOL bShadda = FALSE;
1222 FX_BOOL bLam = FALSE;
1221 for (int32_t i = 0; i <= iLength; i++) { 1223 for (int32_t i = 0; i <= iLength; i++) {
1224 int32_t iWidth;
1225 FX_WCHAR wch;
1222 if (pAccess != NULL) { 1226 if (pAccess != NULL) {
1223 wch = pAccess->GetChar(pIdentity, i); 1227 wch = pAccess->GetChar(pIdentity, i);
1224 iWidth = pAccess->GetWidth(pIdentity, i); 1228 iWidth = pAccess->GetWidth(pIdentity, i);
1225 } else { 1229 } else {
1226 wch = *pStr++; 1230 wch = *pStr++;
1227 iWidth = *pWidths++; 1231 iWidth = *pWidths++;
1228 } 1232 }
1229 dwProps = FX_GetUnicodeProperties(wch); 1233 uint32_t dwProps = FX_GetUnicodeProperties(wch);
1230 dwCharType = (dwProps & FX_CHARTYPEBITSMASK); 1234 uint32_t dwCharType = (dwProps & FX_CHARTYPEBITSMASK);
1231 if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) { 1235 if (dwCharType == FX_CHARTYPE_ArabicAlef && iWidth == 0) {
1232 wPrev = 0xFEFF; 1236 wPrev = 0xFEFF;
1233 wLast = wch; 1237 wLast = wch;
1234 continue; 1238 continue;
1235 } 1239 }
1236 if (dwCharType >= FX_CHARTYPE_ArabicAlef) { 1240 if (dwCharType >= FX_CHARTYPE_ArabicAlef) {
1237 if (i < iLength) { 1241 if (i < iLength) {
1238 if (pAccess != NULL) { 1242 if (pAccess != NULL) {
1239 iNext = i + 1; 1243 iNext = i + 1;
1240 while (iNext <= iLength) { 1244 while (iNext <= iLength) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 } else { 1337 } else {
1334 wForm = wch; 1338 wForm = wch;
1335 } 1339 }
1336 if (dwCharType != FX_CHARTYPE_Combination) { 1340 if (dwCharType != FX_CHARTYPE_Combination) {
1337 bShadda = FALSE; 1341 bShadda = FALSE;
1338 } 1342 }
1339 if (dwCharType < FX_CHARTYPE_ArabicAlef) { 1343 if (dwCharType < FX_CHARTYPE_ArabicAlef) {
1340 bLam = FALSE; 1344 bLam = FALSE;
1341 } 1345 }
1342 dwProps = FX_GetUnicodeProperties(wForm); 1346 dwProps = FX_GetUnicodeProperties(wForm);
1343 iCharRotation = iRotation; 1347 int32_t iCharRotation = iRotation;
1344 if (bVerticalChar && (dwProps & 0x8000) != 0) { 1348 if (bVerticalChar && (dwProps & 0x8000) != 0) {
1345 iCharRotation++; 1349 iCharRotation++;
1346 } 1350 }
1347 iCharRotation %= 4; 1351 iCharRotation %= 4;
1348 bEmptyChar = 1352 FX_BOOL bEmptyChar =
1349 (dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control); 1353 (dwCharType >= FX_CHARTYPE_Tab && dwCharType <= FX_CHARTYPE_Control);
1350 if (wForm == 0xFEFF) { 1354 if (wForm == 0xFEFF) {
1351 bEmptyChar = TRUE; 1355 bEmptyChar = TRUE;
1352 } 1356 }
1353 iForms = bLam ? 3 : 1; 1357 int32_t iForms = bLam ? 3 : 1;
1354 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms; 1358 iCount += (bEmptyChar && bSkipSpace) ? 0 : iForms;
1355 if (pCharPos == NULL) { 1359 if (pCharPos == NULL) {
1356 if (iWidth > 0) { 1360 if (iWidth > 0) {
1357 wPrev = wch; 1361 wPrev = wch;
1358 } 1362 }
1359 wLast = wch; 1363 wLast = wch;
1360 continue; 1364 continue;
1361 } 1365 }
1362 iCharWidth = iWidth; 1366 int32_t iCharWidth = iWidth;
1363 if (iCharWidth < 0) { 1367 if (iCharWidth < 0) {
1364 iCharWidth = -iCharWidth; 1368 iCharWidth = -iCharWidth;
1365 } 1369 }
1366 iCharWidth /= iFontSize; 1370 iCharWidth /= iFontSize;
1367 formChars[0].wch = wch; 1371 formChars[0].wch = wch;
1368 formChars[0].wForm = wForm; 1372 formChars[0].wForm = wForm;
1369 formChars[0].iWidth = iCharWidth; 1373 formChars[0].iWidth = iCharWidth;
1370 if (bLam) { 1374 if (bLam) {
1371 formChars[1].wForm = 0x0651; 1375 formChars[1].wForm = 0x0651;
1372 iCharWidth = 0; 1376 iCharWidth = 0;
(...skipping 14 matching lines...) Expand all
1387 } 1391 }
1388 if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) { 1392 if (!bEmptyChar || (bEmptyChar && !bSkipSpace)) {
1389 pCharPos->m_GlyphIndex = 1393 pCharPos->m_GlyphIndex =
1390 bCharCode ? wch : pFont->GetGlyphIndex(wForm, FALSE); 1394 bCharCode ? wch : pFont->GetGlyphIndex(wForm, FALSE);
1391 pCharPos->m_ExtGID = pCharPos->m_GlyphIndex; 1395 pCharPos->m_ExtGID = pCharPos->m_GlyphIndex;
1392 pCharPos->m_FontCharWidth = iCharWidth; 1396 pCharPos->m_FontCharWidth = iCharWidth;
1393 if (pWSForms) { 1397 if (pWSForms) {
1394 *pWSForms += wForm; 1398 *pWSForms += wForm;
1395 } 1399 }
1396 } 1400 }
1401 int32_t iCharHeight;
1397 if (bVerticalDoc) { 1402 if (bVerticalDoc) {
1398 iCharHeight = iCharWidth; 1403 iCharHeight = iCharWidth;
1399 iCharWidth = 1000; 1404 iCharWidth = 1000;
1400 } else { 1405 } else {
1401 iCharHeight = 1000; 1406 iCharHeight = 1000;
1402 } 1407 }
1403 fCharWidth = fFontSize * iCharWidth / 1000.0f; 1408 fCharWidth = fFontSize * iCharWidth / 1000.0f;
1404 fCharHeight = fFontSize * iCharHeight / 1000.0f; 1409 fCharHeight = fFontSize * iCharHeight / 1000.0f;
1405 if (bRTLPiece && dwCharType != FX_CHARTYPE_Combination) { 1410 if (bRTLPiece && dwCharType != FX_CHARTYPE_Combination) {
1406 if (bVerticalDoc) { 1411 if (bVerticalDoc) {
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 rtBBoxF.height = fHeight; 1652 rtBBoxF.height = fHeight;
1648 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f); 1653 rtBBoxF.top = std::max(rtBBoxF.top, 0.0f);
1649 } 1654 }
1650 rtArray.SetAt(i, rtBBoxF); 1655 rtArray.SetAt(i, rtBBoxF);
1651 continue; 1656 continue;
1652 } 1657 }
1653 rtArray.SetAt(i, rect); 1658 rtArray.SetAt(i, rect);
1654 } 1659 }
1655 return iLength; 1660 return iLength;
1656 } 1661 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698