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

Side by Side Diff: xfa/fxfa/app/xfa_textlayout.cpp

Issue 1882043004: Remove implicit cast from CFX_WideString to (const wchar_t*) (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: win error #2 Created 4 years, 8 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
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/fxfa/app/xfa_textlayout.h" 7 #include "xfa/fxfa/app/xfa_textlayout.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 0x61, 0x62, 0x69, 0x70, 0x0001f714, 296 0x61, 0x62, 0x69, 0x70, 0x0001f714,
297 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8, 297 0x00022a55, 0x000239bb, 0x00025881, 0x0bd37faa, 0x0bd37fb8,
298 0xa73e3af2, 0xb182eaae, 0xdb8ac455, 298 0xa73e3af2, 0xb182eaae, 0xdb8ac455,
299 }; 299 };
300 CFX_WideString wsName; 300 CFX_WideString wsName;
301 if (pXMLNode->GetType() == FDE_XMLNODE_Element) { 301 if (pXMLNode->GetType() == FDE_XMLNODE_Element) {
302 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode); 302 CFDE_XMLElement* pXMLElement = static_cast<CFDE_XMLElement*>(pXMLNode);
303 pXMLElement->GetLocalTagName(wsName); 303 pXMLElement->GetLocalTagName(wsName);
304 tagProvider.SetTagNameObj(wsName); 304 tagProvider.SetTagNameObj(wsName);
305 uint32_t dwHashCode = 305 uint32_t dwHashCode =
306 FX_HashCode_String_GetW(wsName, wsName.GetLength(), TRUE); 306 FX_HashCode_String_GetW(wsName.c_str(), wsName.GetLength(), TRUE);
307 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t); 307 static const int32_t s_iCount = sizeof(s_XFATagName) / sizeof(uint32_t);
308 CFX_DSPATemplate<uint32_t> lookup; 308 CFX_DSPATemplate<uint32_t> lookup;
309 tagProvider.m_bTagAviliable = 309 tagProvider.m_bTagAviliable =
310 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1; 310 lookup.Lookup(dwHashCode, s_XFATagName, s_iCount) > -1;
311 CFX_WideString wsValue; 311 CFX_WideString wsValue;
312 pXMLElement->GetString(FX_WSTRC(L"style").c_str(), wsValue); 312 pXMLElement->GetString(FX_WSTRC(L"style").c_str(), wsValue);
313 if (!wsValue.IsEmpty()) { 313 if (!wsValue.IsEmpty()) {
314 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue); 314 tagProvider.SetAttribute(FX_WSTRC(L"style"), wsValue);
315 } 315 }
316 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) { 316 } else if (pXMLNode->GetType() == FDE_XMLNODE_Text) {
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 CXFA_TextTabstopsContext* pTabstopContext) { 577 CXFA_TextTabstopsContext* pTabstopContext) {
578 if (pStyle == NULL || pTabstopContext == NULL) { 578 if (pStyle == NULL || pTabstopContext == NULL) {
579 return FALSE; 579 return FALSE;
580 } 580 }
581 CFX_WideString wsValue; 581 CFX_WideString wsValue;
582 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) && 582 if (!pStyle->GetCustomStyle(FX_WSTRC(L"xfa-tab-stops"), wsValue) &&
583 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) { 583 !pStyle->GetCustomStyle(FX_WSTRC(L"tab-stops"), wsValue)) {
584 return FALSE; 584 return FALSE;
585 } 585 }
586 int32_t iLength = wsValue.GetLength(); 586 int32_t iLength = wsValue.GetLength();
587 const FX_WCHAR* pTabStops = wsValue; 587 const FX_WCHAR* pTabStops = wsValue.c_str();
588 int32_t iCur = 0; 588 int32_t iCur = 0;
589 int32_t iLast = 0; 589 int32_t iLast = 0;
590 CFX_WideString wsAlign; 590 CFX_WideString wsAlign;
591 XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None; 591 XFA_TABSTOPSSTATUS eStatus = XFA_TABSTOPSSTATUS_None;
592 FX_WCHAR ch; 592 FX_WCHAR ch;
593 while (iCur < iLength) { 593 while (iCur < iLength) {
594 ch = pTabStops[iCur]; 594 ch = pTabStops[iCur];
595 switch (eStatus) { 595 switch (eStatus) {
596 case XFA_TABSTOPSSTATUS_None: 596 case XFA_TABSTOPSSTATUS_None:
597 if (ch <= ' ') { 597 if (ch <= ' ') {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
633 } 633 }
634 while (iCur < iLength && pTabStops[iCur] <= ' ') { 634 while (iCur < iLength && pTabStops[iCur] <= ' ') {
635 iCur++; 635 iCur++;
636 } 636 }
637 iLast = iCur; 637 iLast = iCur;
638 eStatus = XFA_TABSTOPSSTATUS_Location; 638 eStatus = XFA_TABSTOPSSTATUS_Location;
639 } 639 }
640 break; 640 break;
641 case XFA_TABSTOPSSTATUS_Location: 641 case XFA_TABSTOPSSTATUS_Location:
642 if (ch == ' ') { 642 if (ch == ' ') {
643 uint32_t dwHashCode = 643 uint32_t dwHashCode = FX_HashCode_String_GetW(
644 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); 644 wsAlign.c_str(), wsAlign.GetLength(), TRUE);
645 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); 645 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
646 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); 646 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
647 pTabstopContext->Append(dwHashCode, fPos); 647 pTabstopContext->Append(dwHashCode, fPos);
648 wsAlign.Empty(); 648 wsAlign.Empty();
649 eStatus = XFA_TABSTOPSSTATUS_None; 649 eStatus = XFA_TABSTOPSSTATUS_None;
650 } 650 }
651 iCur++; 651 iCur++;
652 break; 652 break;
653 default: 653 default:
654 break; 654 break;
655 } 655 }
656 } 656 }
657 if (!wsAlign.IsEmpty()) { 657 if (!wsAlign.IsEmpty()) {
658 uint32_t dwHashCode = 658 uint32_t dwHashCode =
659 FX_HashCode_String_GetW(wsAlign, wsAlign.GetLength(), TRUE); 659 FX_HashCode_String_GetW(wsAlign.c_str(), wsAlign.GetLength(), TRUE);
660 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast)); 660 CXFA_Measurement ms(CFX_WideStringC(pTabStops + iLast, iCur - iLast));
661 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt); 661 FX_FLOAT fPos = ms.ToUnit(XFA_UNIT_Pt);
662 pTabstopContext->Append(dwHashCode, fPos); 662 pTabstopContext->Append(dwHashCode, fPos);
663 } 663 }
664 return TRUE; 664 return TRUE;
665 } 665 }
666 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider) 666 CXFA_TextLayout::CXFA_TextLayout(CXFA_TextProvider* pTextProvider)
667 : m_bHasBlock(FALSE), 667 : m_bHasBlock(FALSE),
668 m_pTextProvider(pTextProvider), 668 m_pTextProvider(pTextProvider),
669 m_pTextDataNode(nullptr), 669 m_pTextDataNode(nullptr),
(...skipping 1320 matching lines...) Expand 10 before | Expand all | Expand 10 after
1990 tr.iLength = iLength; 1990 tr.iLength = iLength;
1991 tr.fFontSize = pPiece->fFontSize; 1991 tr.fFontSize = pPiece->fFontSize;
1992 tr.iBidiLevel = pPiece->iBidiLevel; 1992 tr.iBidiLevel = pPiece->iBidiLevel;
1993 tr.iCharRotation = 0; 1993 tr.iCharRotation = 0;
1994 tr.wLineBreakChar = L'\n'; 1994 tr.wLineBreakChar = L'\n';
1995 tr.iVerticalScale = pPiece->iVerScale; 1995 tr.iVerticalScale = pPiece->iVerScale;
1996 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab; 1996 tr.dwLayoutStyles = FX_RTFLAYOUTSTYLE_ExpandTab;
1997 tr.iHorizontalScale = pPiece->iHorScale; 1997 tr.iHorizontalScale = pPiece->iHorScale;
1998 return TRUE; 1998 return TRUE;
1999 } 1999 }
OLDNEW
« no previous file with comments | « xfa/fxfa/app/xfa_textlayout.h ('k') | xfa/fxfa/fm2js/xfa_fm2jscontext.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698