summaryrefslogtreecommitdiff
path: root/fpdfsdk/fxedit
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-13 17:51:27 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-13 17:51:27 -0700
commit71a452f8ce12e31cc4e0d8c7878567b0c7fc63c2 (patch)
treea0ee545eb67b14f9398df98196d88e5150893ce8 /fpdfsdk/fxedit
parentafe94306e3c542f0d499e7f7706ee5dec4028d8a (diff)
downloadpdfium-71a452f8ce12e31cc4e0d8c7878567b0c7fc63c2.tar.xz
Make CFX_ByteString(const CFX_ByteStringC&) explicit.
Add missing helper function to CFX_ByteTextBuf to avoid the anti-pattern CFX_ByteString(sBuf.AsStringC()), using the name "Make" to indicate there's an allocation going on in this case. Change some method arguments to take pre-existing ByteStrings where possible. Review-Url: https://codereview.chromium.org/1977093002
Diffstat (limited to 'fpdfsdk/fxedit')
-rw-r--r--fpdfsdk/fxedit/fxet_ap.cpp15
-rw-r--r--fpdfsdk/fxedit/fxet_pageobjs.cpp22
2 files changed, 17 insertions, 20 deletions
diff --git a/fpdfsdk/fxedit/fxet_ap.cpp b/fpdfsdk/fxedit/fxet_ap.cpp
index 262f1e70cd..563acb65b5 100644
--- a/fpdfsdk/fxedit/fxet_ap.cpp
+++ b/fpdfsdk/fxedit/fxet_ap.cpp
@@ -48,15 +48,12 @@ static CFX_ByteString GetFontSetString(IPVT_FontMap* pFontMap,
int32_t nFontIndex,
FX_FLOAT fFontSize) {
CFX_ByteTextBuf sRet;
-
if (pFontMap) {
CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
-
if (sFontAlias.GetLength() > 0 && fFontSize > 0)
sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
}
-
- return sRet.AsStringC();
+ return sRet.MakeString();
}
CFX_ByteString IFX_Edit::GetEditAppearanceStream(
@@ -87,7 +84,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
if (bContinuous) {
if (place.LineCmp(oldplace) != 0) {
if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.AsStringC());
+ sEditStream << GetWordRenderString(sWords.MakeString());
sWords.Clear();
}
@@ -114,7 +111,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
if (pIterator->GetWord(word)) {
if (word.nFontIndex != nCurFontIndex) {
if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.AsStringC());
+ sEditStream << GetWordRenderString(sWords.MakeString());
sWords.Clear();
}
sEditStream << GetFontSetString(pEdit->GetFontMap(), word.nFontIndex,
@@ -152,7 +149,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
}
if (sWords.GetSize() > 0) {
- sEditStream << GetWordRenderString(sWords.AsStringC());
+ sEditStream << GetWordRenderString(sWords.MakeString());
sWords.Clear();
}
@@ -171,7 +168,7 @@ CFX_ByteString IFX_Edit::GetEditAppearanceStream(
sAppStream << sEditStream;
}
- return sAppStream.AsStringC();
+ return sAppStream.MakeString();
}
CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
@@ -200,5 +197,5 @@ CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
}
}
- return sRet.AsStringC();
+ return sRet.MakeString();
}
diff --git a/fpdfsdk/fxedit/fxet_pageobjs.cpp b/fpdfsdk/fxedit/fxet_pageobjs.cpp
index 1fe29af283..e8d9e2a371 100644
--- a/fpdfsdk/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/fxedit/fxet_pageobjs.cpp
@@ -228,7 +228,7 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
pDevice,
CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
+ sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
sTextBuf.Clear();
}
@@ -253,10 +253,10 @@ void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
}
if (sTextBuf.GetLength() > 0) {
- DrawTextString(pDevice,
- CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOldFill, crTextStroke, nHorzScale);
+ DrawTextString(
+ pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.MakeString(), crOldFill, crTextStroke, nHorzScale);
}
}
@@ -340,7 +340,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
pDevice,
CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
+ sTextBuf.MakeString(), crOld, 0, wp.nHorzScale);
sTextBuf.Clear();
}
@@ -381,7 +381,7 @@ void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
DrawTextString(
pDevice, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
- sTextBuf.AsStringC(), crOld, 0, wp.nHorzScale);
+ sTextBuf.MakeString(), crOld, 0, wp.nHorzScale);
}
}
@@ -483,7 +483,7 @@ void IFX_Edit::GeneratePageObjects(
pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex),
fFontSize, 0.0f, 100,
CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ sTextBuf.MakeString()));
sTextBuf.Clear();
}
@@ -502,7 +502,7 @@ void IFX_Edit::GeneratePageObjects(
ObjArray.Add(AddTextObjToPageObjects(
pObjectHolder, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize,
0.0f, 100, CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ sTextBuf.MakeString()));
}
}
}
@@ -551,7 +551,7 @@ void IFX_Edit::GenerateRichPageObjects(
pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ sTextBuf.MakeString()));
sTextBuf.Clear();
}
@@ -594,7 +594,7 @@ void IFX_Edit::GenerateRichPageObjects(
pObjectHolder, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
CFX_FloatPoint(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
- sTextBuf.AsStringC()));
+ sTextBuf.MakeString()));
}
}
}