summaryrefslogtreecommitdiff
path: root/fpdfsdk/src/fxedit
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk/src/fxedit')
-rw-r--r--fpdfsdk/src/fxedit/fxet_ap.cpp392
-rw-r--r--fpdfsdk/src/fxedit/fxet_edit.cpp5306
-rw-r--r--fpdfsdk/src/fxedit/fxet_list.cpp1511
-rw-r--r--fpdfsdk/src/fxedit/fxet_module.cpp37
-rw-r--r--fpdfsdk/src/fxedit/fxet_pageobjs.cpp1243
5 files changed, 3952 insertions, 4537 deletions
diff --git a/fpdfsdk/src/fxedit/fxet_ap.cpp b/fpdfsdk/src/fxedit/fxet_ap.cpp
index 309a98f41e..b9900d899b 100644
--- a/fpdfsdk/src/fxedit/fxet_ap.cpp
+++ b/fpdfsdk/src/fxedit/fxet_ap.cpp
@@ -8,218 +8,206 @@
#include "../../include/fxedit/fx_edit.h"
#include "../../include/fxedit/fxet_edit.h"
-CFX_ByteString GetPDFWordString(IFX_Edit_FontMap * pFontMap, int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord)
-{
- ASSERT (pFontMap != NULL);
-
- CFX_ByteString sWord;
-
- if (CPDF_Font * pPDFFont = pFontMap->GetPDFFont(nFontIndex))
- {
- if (SubWord > 0)
- {
- Word = SubWord;
- }
- else
- {
- FX_DWORD dwCharCode = -1;
-
- if (pPDFFont->IsUnicodeCompatible())
- dwCharCode = pPDFFont->CharCodeFromUnicode(Word);
- else
- dwCharCode = pFontMap->CharCodeFromUnicode(nFontIndex, Word);
-
- if (dwCharCode > 0 )
- {
- pPDFFont->AppendChar(sWord, dwCharCode);
- return sWord;
- }
- }
-
- pPDFFont->AppendChar(sWord, Word);
- }
-
- return sWord;
+CFX_ByteString GetPDFWordString(IFX_Edit_FontMap* pFontMap,
+ int32_t nFontIndex,
+ FX_WORD Word,
+ FX_WORD SubWord) {
+ ASSERT(pFontMap != NULL);
+
+ CFX_ByteString sWord;
+
+ if (CPDF_Font* pPDFFont = pFontMap->GetPDFFont(nFontIndex)) {
+ if (SubWord > 0) {
+ Word = SubWord;
+ } else {
+ FX_DWORD dwCharCode = -1;
+
+ if (pPDFFont->IsUnicodeCompatible())
+ dwCharCode = pPDFFont->CharCodeFromUnicode(Word);
+ else
+ dwCharCode = pFontMap->CharCodeFromUnicode(nFontIndex, Word);
+
+ if (dwCharCode > 0) {
+ pPDFFont->AppendChar(sWord, dwCharCode);
+ return sWord;
+ }
+ }
+
+ pPDFFont->AppendChar(sWord, Word);
+ }
+
+ return sWord;
}
-static CFX_ByteString GetWordRenderString(const CFX_ByteString & strWords)
-{
- if (strWords.GetLength() > 0)
- return PDF_EncodeString(strWords) + " Tj\n";
+static CFX_ByteString GetWordRenderString(const CFX_ByteString& strWords) {
+ if (strWords.GetLength() > 0)
+ return PDF_EncodeString(strWords) + " Tj\n";
- return "";
+ return "";
}
-static CFX_ByteString GetFontSetString(IFX_Edit_FontMap * pFontMap, int32_t nFontIndex, FX_FLOAT fFontSize)
-{
- CFX_ByteTextBuf sRet;
+static CFX_ByteString GetFontSetString(IFX_Edit_FontMap* pFontMap,
+ int32_t nFontIndex,
+ FX_FLOAT fFontSize) {
+ CFX_ByteTextBuf sRet;
- if (pFontMap)
- {
- CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
+ if (pFontMap) {
+ CFX_ByteString sFontAlias = pFontMap->GetPDFFontAlias(nFontIndex);
- if (sFontAlias.GetLength() > 0 && fFontSize > 0 )
- sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
- }
+ if (sFontAlias.GetLength() > 0 && fFontSize > 0)
+ sRet << "/" << sFontAlias << " " << fFontSize << " Tf\n";
+ }
- return sRet.GetByteString();
+ return sRet.GetByteString();
}
-CFX_ByteString IFX_Edit::GetEditAppearanceStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset,
- const CPVT_WordRange * pRange /* = NULL*/, FX_BOOL bContinuous/* = TRUE*/, FX_WORD SubWord/* = 0*/)
-{
- CFX_ByteTextBuf sEditStream, sWords;
-
- CPDF_Point ptOld(0.0f,0.0f),ptNew(0.0f,0.0f);
- int32_t nCurFontIndex = -1;
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
-
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- if (bContinuous)
- {
- if (place.LineCmp(oldplace) != 0)
- {
- if (sWords.GetSize() > 0)
- {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
- }
- else
- {
- CPVT_Line line;
- pIterator->GetLine(line);
- ptNew = CPDF_Point(line.ptLine.x + ptOffset.x, line.ptLine.y + ptOffset.y);
- }
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y)
- {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y << " Td\n";
-
- ptOld = ptNew;
- }
- }
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- if (word.nFontIndex != nCurFontIndex)
- {
- if (sWords.GetSize() > 0)
- {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
- sEditStream << GetFontSetString(pEdit->GetFontMap(),word.nFontIndex,word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sWords << GetPDFWordString(pEdit->GetFontMap(),nCurFontIndex,word.Word,SubWord);
- }
-
- oldplace = place;
- }
- else
- {
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- ptNew = CPDF_Point(word.ptWord.x + ptOffset.x, word.ptWord.y + ptOffset.y);
-
- if (ptNew.x != ptOld.x || ptNew.y != ptOld.y)
- {
- sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y << " Td\n";
- ptOld = ptNew;
- }
-
- if (word.nFontIndex != nCurFontIndex)
- {
- sEditStream << GetFontSetString(pEdit->GetFontMap(),word.nFontIndex,word.fFontSize);
- nCurFontIndex = word.nFontIndex;
- }
-
- sEditStream << GetWordRenderString(GetPDFWordString(pEdit->GetFontMap(),nCurFontIndex,word.Word,SubWord));
- }
- }
- }
-
- if (sWords.GetSize() > 0)
- {
- sEditStream << GetWordRenderString(sWords.GetByteString());
- sWords.Clear();
- }
- }
-
- CFX_ByteTextBuf sAppStream;
- if (sEditStream.GetSize() > 0)
- {
- int32_t nHorzScale = pEdit->GetHorzScale();
- if (nHorzScale != 100)
- {
- sAppStream << nHorzScale << " Tz\n";
- }
-
- FX_FLOAT fCharSpace = pEdit->GetCharSpace();
- if (!FX_EDIT_IsFloatZero(fCharSpace))
- {
- sAppStream << fCharSpace << " Tc\n";
- }
-
- sAppStream << sEditStream;
- }
-
- return sAppStream.GetByteString();
+CFX_ByteString IFX_Edit::GetEditAppearanceStream(
+ IFX_Edit* pEdit,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange /* = NULL*/,
+ FX_BOOL bContinuous /* = TRUE*/,
+ FX_WORD SubWord /* = 0*/) {
+ CFX_ByteTextBuf sEditStream, sWords;
+
+ CPDF_Point ptOld(0.0f, 0.0f), ptNew(0.0f, 0.0f);
+ int32_t nCurFontIndex = -1;
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0) {
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.GetByteString());
+ sWords.Clear();
+ }
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CPDF_Point(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+ } else {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+ ptNew = CPDF_Point(line.ptLine.x + ptOffset.x,
+ line.ptLine.y + ptOffset.y);
+ }
+
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+
+ ptOld = ptNew;
+ }
+ }
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (word.nFontIndex != nCurFontIndex) {
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.GetByteString());
+ sWords.Clear();
+ }
+ sEditStream << GetFontSetString(pEdit->GetFontMap(),
+ word.nFontIndex, word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sWords << GetPDFWordString(pEdit->GetFontMap(), nCurFontIndex,
+ word.Word, SubWord);
+ }
+
+ oldplace = place;
+ } else {
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ ptNew = CPDF_Point(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y);
+
+ if (ptNew.x != ptOld.x || ptNew.y != ptOld.y) {
+ sEditStream << ptNew.x - ptOld.x << " " << ptNew.y - ptOld.y
+ << " Td\n";
+ ptOld = ptNew;
+ }
+
+ if (word.nFontIndex != nCurFontIndex) {
+ sEditStream << GetFontSetString(pEdit->GetFontMap(),
+ word.nFontIndex, word.fFontSize);
+ nCurFontIndex = word.nFontIndex;
+ }
+
+ sEditStream << GetWordRenderString(GetPDFWordString(
+ pEdit->GetFontMap(), nCurFontIndex, word.Word, SubWord));
+ }
+ }
+ }
+
+ if (sWords.GetSize() > 0) {
+ sEditStream << GetWordRenderString(sWords.GetByteString());
+ sWords.Clear();
+ }
+ }
+
+ CFX_ByteTextBuf sAppStream;
+ if (sEditStream.GetSize() > 0) {
+ int32_t nHorzScale = pEdit->GetHorzScale();
+ if (nHorzScale != 100) {
+ sAppStream << nHorzScale << " Tz\n";
+ }
+
+ FX_FLOAT fCharSpace = pEdit->GetCharSpace();
+ if (!FX_EDIT_IsFloatZero(fCharSpace)) {
+ sAppStream << fCharSpace << " Tc\n";
+ }
+
+ sAppStream << sEditStream;
+ }
+
+ return sAppStream.GetByteString();
}
-CFX_ByteString IFX_Edit::GetSelectAppearanceStream(IFX_Edit* pEdit, const CPDF_Point & ptOffset,
- const CPVT_WordRange * pRange /*= NULL*/)
-{
- CFX_ByteTextBuf sRet;
-
- if (pRange && pRange->IsExist())
- {
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- pIterator->SetAt(pRange->BeginPos);
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
-
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word) && pIterator->GetLine(line))
- {
- //CPDF_Rect rcWordSel = CPDF_Rect(word.ptWord.x,line.ptLine.y + line.fLineDescent,
- // word.ptWord.x+word.fWidth,line.ptLine.y + line.fLineAscent);
-
- sRet << word.ptWord.x + ptOffset.x << " " << line.ptLine.y + line.fLineDescent
- << " " << word.fWidth << " " << line.fLineAscent - line.fLineDescent << " re\nf\n";
- }
- }
- }
- }
-
- return sRet.GetByteString();
+CFX_ByteString IFX_Edit::GetSelectAppearanceStream(
+ IFX_Edit* pEdit,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange /*= NULL*/) {
+ CFX_ByteTextBuf sRet;
+
+ if (pRange && pRange->IsExist()) {
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ pIterator->SetAt(pRange->BeginPos);
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word) && pIterator->GetLine(line)) {
+ // CPDF_Rect rcWordSel = CPDF_Rect(word.ptWord.x,line.ptLine.y +
+ // line.fLineDescent,
+ // word.ptWord.x+word.fWidth,line.ptLine.y +
+ //line.fLineAscent);
+
+ sRet << word.ptWord.x + ptOffset.x << " "
+ << line.ptLine.y + line.fLineDescent << " " << word.fWidth << " "
+ << line.fLineAscent - line.fLineDescent << " re\nf\n";
+ }
+ }
+ }
+ }
+
+ return sRet.GetByteString();
}
-
diff --git a/fpdfsdk/src/fxedit/fxet_edit.cpp b/fpdfsdk/src/fxedit/fxet_edit.cpp
index 63115c2626..efef2ca884 100644
--- a/fpdfsdk/src/fxedit/fxet_edit.cpp
+++ b/fpdfsdk/src/fxedit/fxet_edit.cpp
@@ -7,1495 +7,1312 @@
#include "../../include/fxedit/fxet_stub.h"
#include "../../include/fxedit/fxet_edit.h"
-#define FX_EDIT_UNDO_MAXITEM 10000
+#define FX_EDIT_UNDO_MAXITEM 10000
-/* ---------------------------- CFX_Edit_Iterator ---------------------------- */
+/* ---------------------------- CFX_Edit_Iterator ----------------------------
+ */
-CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit * pEdit,IPDF_VariableText_Iterator * pVTIterator) :
- m_pEdit(pEdit),
- m_pVTIterator(pVTIterator)
-{
-}
+CFX_Edit_Iterator::CFX_Edit_Iterator(CFX_Edit* pEdit,
+ IPDF_VariableText_Iterator* pVTIterator)
+ : m_pEdit(pEdit), m_pVTIterator(pVTIterator) {}
-CFX_Edit_Iterator::~CFX_Edit_Iterator()
-{
-}
+CFX_Edit_Iterator::~CFX_Edit_Iterator() {}
-FX_BOOL CFX_Edit_Iterator::NextWord()
-{
- return m_pVTIterator->NextWord();
+FX_BOOL CFX_Edit_Iterator::NextWord() {
+ return m_pVTIterator->NextWord();
}
-FX_BOOL CFX_Edit_Iterator::NextLine()
-{
- return m_pVTIterator->NextLine();
+FX_BOOL CFX_Edit_Iterator::NextLine() {
+ return m_pVTIterator->NextLine();
}
-FX_BOOL CFX_Edit_Iterator::NextSection()
-{
- return m_pVTIterator->NextSection();
+FX_BOOL CFX_Edit_Iterator::NextSection() {
+ return m_pVTIterator->NextSection();
}
-FX_BOOL CFX_Edit_Iterator::PrevWord()
-{
- return m_pVTIterator->PrevWord();
+FX_BOOL CFX_Edit_Iterator::PrevWord() {
+ return m_pVTIterator->PrevWord();
}
-FX_BOOL CFX_Edit_Iterator::PrevLine()
-{
- return m_pVTIterator->PrevLine();
+FX_BOOL CFX_Edit_Iterator::PrevLine() {
+ return m_pVTIterator->PrevLine();
}
-FX_BOOL CFX_Edit_Iterator::PrevSection()
-{
- return m_pVTIterator->PrevSection();
+FX_BOOL CFX_Edit_Iterator::PrevSection() {
+ return m_pVTIterator->PrevSection();
}
-FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word & word) const
-{
- ASSERT(m_pEdit);
+FX_BOOL CFX_Edit_Iterator::GetWord(CPVT_Word& word) const {
+ ASSERT(m_pEdit);
- if (m_pVTIterator->GetWord(word))
- {
- word.ptWord = m_pEdit->VTToEdit(word.ptWord);
- return TRUE;
- }
- return FALSE;
+ if (m_pVTIterator->GetWord(word)) {
+ word.ptWord = m_pEdit->VTToEdit(word.ptWord);
+ return TRUE;
+ }
+ return FALSE;
}
-FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line & line) const
-{
- ASSERT(m_pEdit);
+FX_BOOL CFX_Edit_Iterator::GetLine(CPVT_Line& line) const {
+ ASSERT(m_pEdit);
- if (m_pVTIterator->GetLine(line))
- {
- line.ptLine = m_pEdit->VTToEdit(line.ptLine);
- return TRUE;
- }
- return FALSE;
+ if (m_pVTIterator->GetLine(line)) {
+ line.ptLine = m_pEdit->VTToEdit(line.ptLine);
+ return TRUE;
+ }
+ return FALSE;
}
-FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section & section) const
-{
- ASSERT(m_pEdit);
+FX_BOOL CFX_Edit_Iterator::GetSection(CPVT_Section& section) const {
+ ASSERT(m_pEdit);
- if (m_pVTIterator->GetSection(section))
- {
- section.rcSection = m_pEdit->VTToEdit(section.rcSection);
- return TRUE;
- }
- return FALSE;
+ if (m_pVTIterator->GetSection(section)) {
+ section.rcSection = m_pEdit->VTToEdit(section.rcSection);
+ return TRUE;
+ }
+ return FALSE;
}
-void CFX_Edit_Iterator::SetAt(int32_t nWordIndex)
-{
- m_pVTIterator->SetAt(nWordIndex);
+void CFX_Edit_Iterator::SetAt(int32_t nWordIndex) {
+ m_pVTIterator->SetAt(nWordIndex);
}
-void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace & place)
-{
- m_pVTIterator->SetAt(place);
+void CFX_Edit_Iterator::SetAt(const CPVT_WordPlace& place) {
+ m_pVTIterator->SetAt(place);
}
-const CPVT_WordPlace & CFX_Edit_Iterator::GetAt() const
-{
- return m_pVTIterator->GetAt();
+const CPVT_WordPlace& CFX_Edit_Iterator::GetAt() const {
+ return m_pVTIterator->GetAt();
}
-IFX_Edit* CFX_Edit_Iterator::GetEdit() const
-{
- return m_pEdit;
+IFX_Edit* CFX_Edit_Iterator::GetEdit() const {
+ return m_pEdit;
}
-/* --------------------------- CFX_Edit_Provider ------------------------------- */
+/* --------------------------- CFX_Edit_Provider -------------------------------
+ */
-CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap * pFontMap) : m_pFontMap(pFontMap)
-{
- ASSERT(m_pFontMap != NULL);
+CFX_Edit_Provider::CFX_Edit_Provider(IFX_Edit_FontMap* pFontMap)
+ : m_pFontMap(pFontMap) {
+ ASSERT(m_pFontMap != NULL);
}
-CFX_Edit_Provider::~CFX_Edit_Provider()
-{
-}
+CFX_Edit_Provider::~CFX_Edit_Provider() {}
-IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap()
-{
- return m_pFontMap;
+IFX_Edit_FontMap* CFX_Edit_Provider::GetFontMap() {
+ return m_pFontMap;
}
-int32_t CFX_Edit_Provider::GetCharWidth(int32_t nFontIndex, FX_WORD word, int32_t nWordStyle)
-{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- {
- FX_DWORD charcode = word;
+int32_t CFX_Edit_Provider::GetCharWidth(int32_t nFontIndex,
+ FX_WORD word,
+ int32_t nWordStyle) {
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex)) {
+ FX_DWORD charcode = word;
- if (pPDFFont->IsUnicodeCompatible())
- charcode = pPDFFont->CharCodeFromUnicode(word);
- else
- charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word);
+ if (pPDFFont->IsUnicodeCompatible())
+ charcode = pPDFFont->CharCodeFromUnicode(word);
+ else
+ charcode = m_pFontMap->CharCodeFromUnicode(nFontIndex, word);
- if (charcode != -1)
- return pPDFFont->GetCharWidthF(charcode);
- }
+ if (charcode != -1)
+ return pPDFFont->GetCharWidthF(charcode);
+ }
- return 0;
+ return 0;
}
-int32_t CFX_Edit_Provider::GetTypeAscent(int32_t nFontIndex)
-{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- return pPDFFont->GetTypeAscent();
+int32_t CFX_Edit_Provider::GetTypeAscent(int32_t nFontIndex) {
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
+ return pPDFFont->GetTypeAscent();
- return 0;
+ return 0;
}
-int32_t CFX_Edit_Provider::GetTypeDescent(int32_t nFontIndex)
-{
- if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
- return pPDFFont->GetTypeDescent();
+int32_t CFX_Edit_Provider::GetTypeDescent(int32_t nFontIndex) {
+ if (CPDF_Font* pPDFFont = m_pFontMap->GetPDFFont(nFontIndex))
+ return pPDFFont->GetTypeDescent();
- return 0;
+ return 0;
}
-int32_t CFX_Edit_Provider::GetWordFontIndex(FX_WORD word, int32_t charset, int32_t nFontIndex)
-{
- return m_pFontMap->GetWordFontIndex(word,charset,nFontIndex);
+int32_t CFX_Edit_Provider::GetWordFontIndex(FX_WORD word,
+ int32_t charset,
+ int32_t nFontIndex) {
+ return m_pFontMap->GetWordFontIndex(word, charset, nFontIndex);
}
-int32_t CFX_Edit_Provider::GetDefaultFontIndex()
-{
- return 0;
+int32_t CFX_Edit_Provider::GetDefaultFontIndex() {
+ return 0;
}
-FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word)
-{
- return FX_EDIT_ISLATINWORD(word);
+FX_BOOL CFX_Edit_Provider::IsLatinWord(FX_WORD word) {
+ return FX_EDIT_ISLATINWORD(word);
}
-/* --------------------------------- CFX_Edit_Refresh --------------------------------- */
+/* --------------------------------- CFX_Edit_Refresh
+ * --------------------------------- */
-CFX_Edit_Refresh::CFX_Edit_Refresh()
-{
-}
+CFX_Edit_Refresh::CFX_Edit_Refresh() {}
-CFX_Edit_Refresh::~CFX_Edit_Refresh()
-{
-}
+CFX_Edit_Refresh::~CFX_Edit_Refresh() {}
-void CFX_Edit_Refresh::BeginRefresh()
-{
- m_RefreshRects.Empty();
- m_OldLineRects = m_NewLineRects;
+void CFX_Edit_Refresh::BeginRefresh() {
+ m_RefreshRects.Empty();
+ m_OldLineRects = m_NewLineRects;
}
-void CFX_Edit_Refresh::Push(const CPVT_WordRange & linerange,const CPDF_Rect & rect)
-{
- m_NewLineRects.Add(linerange,rect);
+void CFX_Edit_Refresh::Push(const CPVT_WordRange& linerange,
+ const CPDF_Rect& rect) {
+ m_NewLineRects.Add(linerange, rect);
}
-void CFX_Edit_Refresh::NoAnalyse()
-{
- {
- for (int32_t i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++)
- if (CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i))
- m_RefreshRects.Add(pOldRect->m_rcLine);
- }
+void CFX_Edit_Refresh::NoAnalyse() {
+ {
+ for (int32_t i = 0, sz = m_OldLineRects.GetSize(); i < sz; i++)
+ if (CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i))
+ m_RefreshRects.Add(pOldRect->m_rcLine);
+ }
- {
- for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++)
- if (CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i))
- m_RefreshRects.Add(pNewRect->m_rcLine);
- }
+ {
+ for (int32_t i = 0, sz = m_NewLineRects.GetSize(); i < sz; i++)
+ if (CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i))
+ m_RefreshRects.Add(pNewRect->m_rcLine);
+ }
}
-void CFX_Edit_Refresh::Analyse(int32_t nAlignment)
-{
- FX_BOOL bLineTopChanged = FALSE;
- CPDF_Rect rcResult;
- FX_FLOAT fWidthDiff;
-
- int32_t szMax = FX_EDIT_MAX(m_OldLineRects.GetSize(),m_NewLineRects.GetSize());
- int32_t i = 0;
-
- while (i < szMax)
- {
- CFX_Edit_LineRect * pOldRect = m_OldLineRects.GetAt(i);
- CFX_Edit_LineRect * pNewRect = m_NewLineRects.GetAt(i);
-
- if (pOldRect)
- {
- if (pNewRect)
- {
- if (bLineTopChanged)
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- else
- {
- if (*pNewRect != *pOldRect)
- {
- if (!pNewRect->IsSameTop(*pOldRect) || !pNewRect->IsSameHeight(*pOldRect))
- {
- bLineTopChanged = TRUE;
- continue;
- }
-
- if (nAlignment == 0)
- {
- if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos)
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- else
- {
- if (!pNewRect->IsSameLeft(*pOldRect))
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- }
- else
- {
- fWidthDiff = pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width();
- rcResult = pNewRect->m_rcLine;
- if (fWidthDiff > 0.0f)
- rcResult.left = rcResult.right - fWidthDiff;
- else
- {
- rcResult.left = rcResult.right;
- rcResult.right += (-fWidthDiff);
- }
- }
- m_RefreshRects.Add(rcResult);
- }
- }
- else
- {
- rcResult = pOldRect->m_rcLine;
- rcResult.Union(pNewRect->m_rcLine);
- m_RefreshRects.Add(rcResult);
- }
- }
- else
- {
- //don't need to do anything
- }
- }
- }
- else
- {
- m_RefreshRects.Add(pOldRect->m_rcLine);
- }
- }
- else
- {
- if (pNewRect)
- {
- m_RefreshRects.Add(pNewRect->m_rcLine);
+void CFX_Edit_Refresh::Analyse(int32_t nAlignment) {
+ FX_BOOL bLineTopChanged = FALSE;
+ CPDF_Rect rcResult;
+ FX_FLOAT fWidthDiff;
+
+ int32_t szMax =
+ FX_EDIT_MAX(m_OldLineRects.GetSize(), m_NewLineRects.GetSize());
+ int32_t i = 0;
+
+ while (i < szMax) {
+ CFX_Edit_LineRect* pOldRect = m_OldLineRects.GetAt(i);
+ CFX_Edit_LineRect* pNewRect = m_NewLineRects.GetAt(i);
+
+ if (pOldRect) {
+ if (pNewRect) {
+ if (bLineTopChanged) {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
+ } else {
+ if (*pNewRect != *pOldRect) {
+ if (!pNewRect->IsSameTop(*pOldRect) ||
+ !pNewRect->IsSameHeight(*pOldRect)) {
+ bLineTopChanged = TRUE;
+ continue;
}
- else
- {
- //error
+
+ if (nAlignment == 0) {
+ if (pNewRect->m_wrLine.BeginPos != pOldRect->m_wrLine.BeginPos) {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
+ } else {
+ if (!pNewRect->IsSameLeft(*pOldRect)) {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ } else {
+ fWidthDiff =
+ pNewRect->m_rcLine.Width() - pOldRect->m_rcLine.Width();
+ rcResult = pNewRect->m_rcLine;
+ if (fWidthDiff > 0.0f)
+ rcResult.left = rcResult.right - fWidthDiff;
+ else {
+ rcResult.left = rcResult.right;
+ rcResult.right += (-fWidthDiff);
+ }
+ }
+ m_RefreshRects.Add(rcResult);
+ }
+ } else {
+ rcResult = pOldRect->m_rcLine;
+ rcResult.Union(pNewRect->m_rcLine);
+ m_RefreshRects.Add(rcResult);
}
+ } else {
+ // don't need to do anything
+ }
}
- i++;
+ } else {
+ m_RefreshRects.Add(pOldRect->m_rcLine);
+ }
+ } else {
+ if (pNewRect) {
+ m_RefreshRects.Add(pNewRect->m_rcLine);
+ } else {
+ // error
+ }
}
+ i++;
+ }
}
-void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect & rect)
-{
- m_RefreshRects.Add(rect);
+void CFX_Edit_Refresh::AddRefresh(const CPDF_Rect& rect) {
+ m_RefreshRects.Add(rect);
}
-const CFX_Edit_RectArray * CFX_Edit_Refresh::GetRefreshRects() const
-{
- return &m_RefreshRects;
+const CFX_Edit_RectArray* CFX_Edit_Refresh::GetRefreshRects() const {
+ return &m_RefreshRects;
}
-void CFX_Edit_Refresh::EndRefresh()
-{
- m_RefreshRects.Empty();
+void CFX_Edit_Refresh::EndRefresh() {
+ m_RefreshRects.Empty();
}
-/* ------------------------------------- CFX_Edit_Undo ------------------------------------- */
+/* ------------------------------------- CFX_Edit_Undo
+ * ------------------------------------- */
-CFX_Edit_Undo::CFX_Edit_Undo(int32_t nBufsize) : m_nCurUndoPos(0),
- m_nBufSize(nBufsize),
- m_bModified(FALSE),
- m_bVirgin(TRUE),
- m_bWorking(FALSE)
-{
-}
+CFX_Edit_Undo::CFX_Edit_Undo(int32_t nBufsize)
+ : m_nCurUndoPos(0),
+ m_nBufSize(nBufsize),
+ m_bModified(FALSE),
+ m_bVirgin(TRUE),
+ m_bWorking(FALSE) {}
-CFX_Edit_Undo::~CFX_Edit_Undo()
-{
- Reset();
+CFX_Edit_Undo::~CFX_Edit_Undo() {
+ Reset();
}
-FX_BOOL CFX_Edit_Undo::CanUndo() const
-{
- return m_nCurUndoPos > 0;
+FX_BOOL CFX_Edit_Undo::CanUndo() const {
+ return m_nCurUndoPos > 0;
}
-void CFX_Edit_Undo::Undo()
-{
- m_bWorking = TRUE;
+void CFX_Edit_Undo::Undo() {
+ m_bWorking = TRUE;
- if (m_nCurUndoPos > 0)
- {
- IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos-1);
- ASSERT(pItem != NULL);
+ if (m_nCurUndoPos > 0) {
+ IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos - 1);
+ ASSERT(pItem != NULL);
- pItem->Undo();
+ pItem->Undo();
- m_nCurUndoPos--;
- m_bModified = (m_nCurUndoPos != 0);
- }
+ m_nCurUndoPos--;
+ m_bModified = (m_nCurUndoPos != 0);
+ }
- m_bWorking = FALSE;
+ m_bWorking = FALSE;
}
-FX_BOOL CFX_Edit_Undo::CanRedo() const
-{
- return m_nCurUndoPos < m_UndoItemStack.GetSize();
+FX_BOOL CFX_Edit_Undo::CanRedo() const {
+ return m_nCurUndoPos < m_UndoItemStack.GetSize();
}
-void CFX_Edit_Undo::Redo()
-{
- m_bWorking = TRUE;
+void CFX_Edit_Undo::Redo() {
+ m_bWorking = TRUE;
- int32_t nStackSize = m_UndoItemStack.GetSize();
+ int32_t nStackSize = m_UndoItemStack.GetSize();
- if (m_nCurUndoPos < nStackSize)
- {
- IFX_Edit_UndoItem * pItem = m_UndoItemStack.GetAt(m_nCurUndoPos);
- ASSERT(pItem != NULL);
+ if (m_nCurUndoPos < nStackSize) {
+ IFX_Edit_UndoItem* pItem = m_UndoItemStack.GetAt(m_nCurUndoPos);
+ ASSERT(pItem != NULL);
- pItem->Redo();
+ pItem->Redo();
- m_nCurUndoPos++;
- m_bModified = (m_nCurUndoPos != 0);
- }
+ m_nCurUndoPos++;
+ m_bModified = (m_nCurUndoPos != 0);
+ }
- m_bWorking = FALSE;
+ m_bWorking = FALSE;
}
-FX_BOOL CFX_Edit_Undo::IsWorking() const
-{
- return m_bWorking;
+FX_BOOL CFX_Edit_Undo::IsWorking() const {
+ return m_bWorking;
}
-void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem)
-{
- ASSERT(!m_bWorking);
- ASSERT(pItem != NULL);
- ASSERT(m_nBufSize > 1);
+void CFX_Edit_Undo::AddItem(IFX_Edit_UndoItem* pItem) {
+ ASSERT(!m_bWorking);
+ ASSERT(pItem != NULL);
+ ASSERT(m_nBufSize > 1);
- if (m_nCurUndoPos < m_UndoItemStack.GetSize())
- RemoveTails();
+ if (m_nCurUndoPos < m_UndoItemStack.GetSize())
+ RemoveTails();
- if (m_UndoItemStack.GetSize() >= m_nBufSize)
- {
- RemoveHeads();
- m_bVirgin = FALSE;
- }
+ if (m_UndoItemStack.GetSize() >= m_nBufSize) {
+ RemoveHeads();
+ m_bVirgin = FALSE;
+ }
- m_UndoItemStack.Add(pItem);
- m_nCurUndoPos = m_UndoItemStack.GetSize();
+ m_UndoItemStack.Add(pItem);
+ m_nCurUndoPos = m_UndoItemStack.GetSize();
- m_bModified = (m_nCurUndoPos != 0);
+ m_bModified = (m_nCurUndoPos != 0);
}
-FX_BOOL CFX_Edit_Undo::IsModified() const
-{
- return m_bVirgin ? m_bModified : TRUE;
+FX_BOOL CFX_Edit_Undo::IsModified() const {
+ return m_bVirgin ? m_bModified : TRUE;
}
-IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex)
-{
- if (nIndex>=0 && nIndex < m_UndoItemStack.GetSize())
- return m_UndoItemStack.GetAt(nIndex);
+IFX_Edit_UndoItem* CFX_Edit_Undo::GetItem(int32_t nIndex) {
+ if (nIndex >= 0 && nIndex < m_UndoItemStack.GetSize())
+ return m_UndoItemStack.GetAt(nIndex);
- return NULL;
+ return NULL;
}
-void CFX_Edit_Undo::RemoveHeads()
-{
- ASSERT(m_UndoItemStack.GetSize() > 1);
+void CFX_Edit_Undo::RemoveHeads() {
+ ASSERT(m_UndoItemStack.GetSize() > 1);
- delete m_UndoItemStack.GetAt(0);
- m_UndoItemStack.RemoveAt(0);
+ delete m_UndoItemStack.GetAt(0);
+ m_UndoItemStack.RemoveAt(0);
}
-void CFX_Edit_Undo::RemoveTails()
-{
- for (int32_t i = m_UndoItemStack.GetSize()-1; i >= m_nCurUndoPos; i--)
- {
- delete m_UndoItemStack.GetAt(i);
- m_UndoItemStack.RemoveAt(i);
- }
+void CFX_Edit_Undo::RemoveTails() {
+ for (int32_t i = m_UndoItemStack.GetSize() - 1; i >= m_nCurUndoPos; i--) {
+ delete m_UndoItemStack.GetAt(i);
+ m_UndoItemStack.RemoveAt(i);
+ }
}
-void CFX_Edit_Undo::Reset()
-{
- for (int32_t i=0, sz=m_UndoItemStack.GetSize(); i < sz; i++)
- {
- delete m_UndoItemStack.GetAt(i);
- }
- m_nCurUndoPos = 0;
- m_UndoItemStack.RemoveAll();
+void CFX_Edit_Undo::Reset() {
+ for (int32_t i = 0, sz = m_UndoItemStack.GetSize(); i < sz; i++) {
+ delete m_UndoItemStack.GetAt(i);
+ }
+ m_nCurUndoPos = 0;
+ m_UndoItemStack.RemoveAll();
}
-/* -------------------------------- CFX_Edit_GroupUndoItem -------------------------------- */
+/* -------------------------------- CFX_Edit_GroupUndoItem
+ * -------------------------------- */
-CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle) : m_sTitle(sTitle)
-{
-}
+CFX_Edit_GroupUndoItem::CFX_Edit_GroupUndoItem(const CFX_WideString& sTitle)
+ : m_sTitle(sTitle) {}
-CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem()
-{
- for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
- {
- delete m_Items[i];
- }
+CFX_Edit_GroupUndoItem::~CFX_Edit_GroupUndoItem() {
+ for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) {
+ delete m_Items[i];
+ }
- m_Items.RemoveAll();
+ m_Items.RemoveAll();
}
-void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem)
-{
- ASSERT(pUndoItem != NULL);
+void CFX_Edit_GroupUndoItem::AddUndoItem(CFX_Edit_UndoItem* pUndoItem) {
+ ASSERT(pUndoItem != NULL);
- pUndoItem->SetFirst(FALSE);
- pUndoItem->SetLast(FALSE);
+ pUndoItem->SetFirst(FALSE);
+ pUndoItem->SetLast(FALSE);
- m_Items.Add(pUndoItem);
+ m_Items.Add(pUndoItem);
- if (m_sTitle.IsEmpty())
- m_sTitle = pUndoItem->GetUndoTitle();
+ if (m_sTitle.IsEmpty())
+ m_sTitle = pUndoItem->GetUndoTitle();
}
-void CFX_Edit_GroupUndoItem::UpdateItems()
-{
- if (m_Items.GetSize() > 0)
- {
- CFX_Edit_UndoItem* pFirstItem = m_Items[0];
- ASSERT(pFirstItem != NULL);
- pFirstItem->SetFirst(TRUE);
+void CFX_Edit_GroupUndoItem::UpdateItems() {
+ if (m_Items.GetSize() > 0) {
+ CFX_Edit_UndoItem* pFirstItem = m_Items[0];
+ ASSERT(pFirstItem != NULL);
+ pFirstItem->SetFirst(TRUE);
- CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1];
- ASSERT(pLastItem != NULL);
- pLastItem->SetLast(TRUE);
- }
+ CFX_Edit_UndoItem* pLastItem = m_Items[m_Items.GetSize() - 1];
+ ASSERT(pLastItem != NULL);
+ pLastItem->SetLast(TRUE);
+ }
}
-void CFX_Edit_GroupUndoItem::Undo()
-{
- for (int i=m_Items.GetSize()-1; i>=0; i--)
- {
- CFX_Edit_UndoItem* pUndoItem = m_Items[i];
- ASSERT(pUndoItem != NULL);
+void CFX_Edit_GroupUndoItem::Undo() {
+ for (int i = m_Items.GetSize() - 1; i >= 0; i--) {
+ CFX_Edit_UndoItem* pUndoItem = m_Items[i];
+ ASSERT(pUndoItem != NULL);
- pUndoItem->Undo();
- }
+ pUndoItem->Undo();
+ }
}
-void CFX_Edit_GroupUndoItem::Redo()
-{
- for (int i=0,sz=m_Items.GetSize(); i<sz; i++)
- {
- CFX_Edit_UndoItem* pUndoItem = m_Items[i];
- ASSERT(pUndoItem != NULL);
+void CFX_Edit_GroupUndoItem::Redo() {
+ for (int i = 0, sz = m_Items.GetSize(); i < sz; i++) {
+ CFX_Edit_UndoItem* pUndoItem = m_Items[i];
+ ASSERT(pUndoItem != NULL);
- pUndoItem->Redo();
- }
+ pUndoItem->Redo();
+ }
}
-CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle()
-{
- return m_sTitle;
+CFX_WideString CFX_Edit_GroupUndoItem::GetUndoTitle() {
+ return m_sTitle;
}
-/* ------------------------------------- CFX_Edit_UndoItem derived classes ------------------------------------- */
+/* ------------------------------------- CFX_Edit_UndoItem derived classes
+ * ------------------------------------- */
-CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps)
- : m_pEdit(pEdit), m_wpOld(wpOldPlace), m_wpNew(wpNewPlace), m_Word(word), m_nCharset(charset), m_WordProps()
-{
- if (pWordProps)
- m_WordProps = *pWordProps;
+CFXEU_InsertWord::CFXEU_InsertWord(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ FX_WORD word,
+ int32_t charset,
+ const CPVT_WordProps* pWordProps)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_Word(word),
+ m_nCharset(charset),
+ m_WordProps() {
+ if (pWordProps)
+ m_WordProps = *pWordProps;
}
-CFXEU_InsertWord::~CFXEU_InsertWord()
-{
-}
+CFXEU_InsertWord::~CFXEU_InsertWord() {}
-void CFXEU_InsertWord::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
+void CFXEU_InsertWord::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE);
+ }
}
-void CFXEU_InsertWord::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- m_pEdit->Backspace(FALSE,TRUE);
- }
+void CFXEU_InsertWord::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ m_pEdit->Backspace(FALSE, TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
-CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_SecProps(),
- m_WordProps()
-{
- if (pSecProps)
- m_SecProps = *pSecProps;
- if (pWordProps)
- m_WordProps = *pWordProps;
-}
-
-CFXEU_InsertReturn::~CFXEU_InsertReturn()
-{
-}
-
-void CFXEU_InsertReturn::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
+CFXEU_InsertReturn::CFXEU_InsertReturn(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_SecProps(),
+ m_WordProps() {
+ if (pSecProps)
+ m_SecProps = *pSecProps;
+ if (pWordProps)
+ m_WordProps = *pWordProps;
}
-void CFXEU_InsertReturn::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- m_pEdit->Backspace(FALSE,TRUE);
- }
-}
+CFXEU_InsertReturn::~CFXEU_InsertReturn() {}
-/* -------------------------------------------------------------------------- */
-//CFXEU_Backspace
-
-CFXEU_Backspace::CFXEU_Backspace(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps)
-{
-}
-
-CFXEU_Backspace::~CFXEU_Backspace()
-{
-}
-
-void CFXEU_Backspace::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->Backspace(FALSE,TRUE);
- }
+void CFXEU_InsertReturn::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE);
+ }
}
-void CFXEU_Backspace::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- if (m_wpNew.SecCmp(m_wpOld) != 0)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
- }
+void CFXEU_InsertReturn::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ m_pEdit->Backspace(FALSE, TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
-//CFXEU_Delete
-
-CFXEU_Delete::CFXEU_Delete(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps, FX_BOOL bSecEnd) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps),
- m_bSecEnd(bSecEnd)
-{
-}
-
-CFXEU_Delete::~CFXEU_Delete()
-{
-}
-
-void CFXEU_Delete::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->Delete(FALSE,TRUE);
- }
+// CFXEU_Backspace
+
+CFXEU_Backspace::CFXEU_Backspace(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ FX_WORD word,
+ int32_t charset,
+ const CPVT_SecProps& SecProps,
+ const CPVT_WordProps& WordProps)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps) {}
+
+CFXEU_Backspace::~CFXEU_Backspace() {}
+
+void CFXEU_Backspace::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->Backspace(FALSE, TRUE);
+ }
+}
+
+void CFXEU_Backspace::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ if (m_wpNew.SecCmp(m_wpOld) != 0) {
+ m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE);
+ } else {
+ m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE);
+ }
+ }
}
-void CFXEU_Delete::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpNew);
- if (m_bSecEnd)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,TRUE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,TRUE);
- }
- }
+/* -------------------------------------------------------------------------- */
+// CFXEU_Delete
+
+CFXEU_Delete::CFXEU_Delete(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ FX_WORD word,
+ int32_t charset,
+ const CPVT_SecProps& SecProps,
+ const CPVT_WordProps& WordProps,
+ FX_BOOL bSecEnd)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps),
+ m_bSecEnd(bSecEnd) {}
+
+CFXEU_Delete::~CFXEU_Delete() {}
+
+void CFXEU_Delete::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->Delete(FALSE, TRUE);
+ }
+}
+
+void CFXEU_Delete::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpNew);
+ if (m_bSecEnd) {
+ m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, TRUE);
+ } else {
+ m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, TRUE);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
-//CFXEU_Clear
+// CFXEU_Clear
-CFXEU_Clear::CFXEU_Clear(CFX_Edit * pEdit, const CPVT_WordRange & wrSel, const CFX_WideString & swText) :
- m_pEdit(pEdit),
- m_wrSel(wrSel),
- m_swText(swText)
-{
-}
+CFXEU_Clear::CFXEU_Clear(CFX_Edit* pEdit,
+ const CPVT_WordRange& wrSel,
+ const CFX_WideString& swText)
+ : m_pEdit(pEdit), m_wrSel(wrSel), m_swText(swText) {}
-CFXEU_Clear::~CFXEU_Clear()
-{
-}
+CFXEU_Clear::~CFXEU_Clear() {}
-void CFXEU_Clear::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->Clear(FALSE,TRUE);
- }
+void CFXEU_Clear::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
+ m_pEdit->Clear(FALSE, TRUE);
+ }
}
-void CFXEU_Clear::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wrSel.BeginPos);
- m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE, TRUE);
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- }
+void CFXEU_Clear::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wrSel.BeginPos);
+ m_pEdit->InsertText(m_swText.c_str(), DEFAULT_CHARSET, NULL, NULL, FALSE,
+ TRUE);
+ m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
+ }
}
/* -------------------------------------------------------------------------- */
-//CFXEU_ClearRich
-
-CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CPVT_WordRange & wrSel, FX_WORD word, int32_t charset,
- const CPVT_SecProps & SecProps, const CPVT_WordProps & WordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_wrSel(wrSel),
- m_Word(word),
- m_nCharset(charset),
- m_SecProps(SecProps),
- m_WordProps(WordProps)
-{
-}
-
-CFXEU_ClearRich::~CFXEU_ClearRich()
-{
-}
-
-void CFXEU_ClearRich::Redo()
-{
- if (m_pEdit && IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->Clear(FALSE,TRUE);
- }
-}
-
-void CFXEU_ClearRich::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- if (m_wpNew.SecCmp(m_wpOld) != 0)
- {
- m_pEdit->InsertReturn(&m_SecProps,&m_WordProps,FALSE,FALSE);
- }
- else
- {
- m_pEdit->InsertWord(m_Word,m_nCharset,&m_WordProps,FALSE,FALSE);
- }
-
- if (IsFirst())
- {
- m_pEdit->PaintInsertText(m_wrSel.BeginPos,m_wrSel.EndPos);
- m_pEdit->SetSel(m_wrSel.BeginPos,m_wrSel.EndPos);
- }
- }
+// CFXEU_ClearRich
+
+CFXEU_ClearRich::CFXEU_ClearRich(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ const CPVT_WordRange& wrSel,
+ FX_WORD word,
+ int32_t charset,
+ const CPVT_SecProps& SecProps,
+ const CPVT_WordProps& WordProps)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_wrSel(wrSel),
+ m_Word(word),
+ m_nCharset(charset),
+ m_SecProps(SecProps),
+ m_WordProps(WordProps) {}
+
+CFXEU_ClearRich::~CFXEU_ClearRich() {}
+
+void CFXEU_ClearRich::Redo() {
+ if (m_pEdit && IsLast()) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
+ m_pEdit->Clear(FALSE, TRUE);
+ }
+}
+
+void CFXEU_ClearRich::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ if (m_wpNew.SecCmp(m_wpOld) != 0) {
+ m_pEdit->InsertReturn(&m_SecProps, &m_WordProps, FALSE, FALSE);
+ } else {
+ m_pEdit->InsertWord(m_Word, m_nCharset, &m_WordProps, FALSE, FALSE);
+ }
+
+ if (IsFirst()) {
+ m_pEdit->PaintInsertText(m_wrSel.BeginPos, m_wrSel.EndPos);
+ m_pEdit->SetSel(m_wrSel.BeginPos, m_wrSel.EndPos);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
-//CFXEU_InsertText
-
-CFXEU_InsertText::CFXEU_InsertText(CFX_Edit * pEdit, const CPVT_WordPlace & wpOldPlace, const CPVT_WordPlace & wpNewPlace,
- const CFX_WideString & swText, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps) :
- m_pEdit(pEdit),
- m_wpOld(wpOldPlace),
- m_wpNew(wpNewPlace),
- m_swText(swText),
- m_nCharset(charset),
- m_SecProps(),
- m_WordProps()
-{
- if (pSecProps)
- m_SecProps = *pSecProps;
- if (pWordProps)
- m_WordProps = *pWordProps;
-}
-
-CFXEU_InsertText::~CFXEU_InsertText()
-{
-}
-
-void CFXEU_InsertText::Redo()
-{
- if (m_pEdit && IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->SetCaret(m_wpOld);
- m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps, FALSE, TRUE);
- }
-}
-
-void CFXEU_InsertText::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SelectNone();
- m_pEdit->SetSel(m_wpOld,m_wpNew);
- m_pEdit->Clear(FALSE,TRUE);
- }
+// CFXEU_InsertText
+
+CFXEU_InsertText::CFXEU_InsertText(CFX_Edit* pEdit,
+ const CPVT_WordPlace& wpOldPlace,
+ const CPVT_WordPlace& wpNewPlace,
+ const CFX_WideString& swText,
+ int32_t charset,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps)
+ : m_pEdit(pEdit),
+ m_wpOld(wpOldPlace),
+ m_wpNew(wpNewPlace),
+ m_swText(swText),
+ m_nCharset(charset),
+ m_SecProps(),
+ m_WordProps() {
+ if (pSecProps)
+ m_SecProps = *pSecProps;
+ if (pWordProps)
+ m_WordProps = *pWordProps;
+}
+
+CFXEU_InsertText::~CFXEU_InsertText() {}
+
+void CFXEU_InsertText::Redo() {
+ if (m_pEdit && IsLast()) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetCaret(m_wpOld);
+ m_pEdit->InsertText(m_swText.c_str(), m_nCharset, &m_SecProps, &m_WordProps,
+ FALSE, TRUE);
+ }
+}
+
+void CFXEU_InsertText::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SelectNone();
+ m_pEdit->SetSel(m_wpOld, m_wpNew);
+ m_pEdit->Clear(FALSE, TRUE);
+ }
}
/* -------------------------------------------------------------------------- */
-CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep,
- const CPVT_SecProps & oldsecprops, const CPVT_WordProps & oldwordprops,
- const CPVT_SecProps & newsecprops, const CPVT_WordProps & newwordprops, const CPVT_WordRange & range)
- : m_pEdit(pEdit),
- m_wpPlace(place),
- m_wrPlace(range),
- m_eProps(ep),
- m_OldSecProps(oldsecprops),
- m_NewSecProps(newsecprops),
- m_OldWordProps(oldwordprops),
- m_NewWordProps(newwordprops)
-{
-}
-
-CFXEU_SetSecProps::~CFXEU_SetSecProps()
-{
-}
-
-void CFXEU_SetSecProps::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_NewSecProps,&m_NewWordProps,m_wrPlace,FALSE);
- if (IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
-}
-
-void CFXEU_SetSecProps::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SetSecProps(m_eProps,m_wpPlace,&m_OldSecProps,&m_OldWordProps,m_wrPlace,FALSE);
- if (IsFirst())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
+CFXEU_SetSecProps::CFXEU_SetSecProps(CFX_Edit* pEdit,
+ const CPVT_WordPlace& place,
+ EDIT_PROPS_E ep,
+ const CPVT_SecProps& oldsecprops,
+ const CPVT_WordProps& oldwordprops,
+ const CPVT_SecProps& newsecprops,
+ const CPVT_WordProps& newwordprops,
+ const CPVT_WordRange& range)
+ : m_pEdit(pEdit),
+ m_wpPlace(place),
+ m_wrPlace(range),
+ m_eProps(ep),
+ m_OldSecProps(oldsecprops),
+ m_NewSecProps(newsecprops),
+ m_OldWordProps(oldwordprops),
+ m_NewWordProps(newwordprops) {}
+
+CFXEU_SetSecProps::~CFXEU_SetSecProps() {}
+
+void CFXEU_SetSecProps::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_NewSecProps, &m_NewWordProps,
+ m_wrPlace, FALSE);
+ if (IsLast()) {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps, m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos);
+ }
+ }
+}
+
+void CFXEU_SetSecProps::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SetSecProps(m_eProps, m_wpPlace, &m_OldSecProps, &m_OldWordProps,
+ m_wrPlace, FALSE);
+ if (IsFirst()) {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps, m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos);
+ }
+ }
}
/* -------------------------------------------------------------------------- */
-CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit * pEdit, const CPVT_WordPlace & place, EDIT_PROPS_E ep,
- const CPVT_WordProps & oldprops, const CPVT_WordProps & newprops, const CPVT_WordRange & range)
- : m_pEdit(pEdit),
- m_wpPlace(place),
- m_wrPlace(range),
- m_eProps(ep),
- m_OldWordProps(oldprops),
- m_NewWordProps(newprops)
-{
-}
-
-CFXEU_SetWordProps::~CFXEU_SetWordProps()
-{
-}
-
-void CFXEU_SetWordProps::Redo()
-{
- if (m_pEdit)
- {
- m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_NewWordProps,m_wrPlace,FALSE);
- if (IsLast())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
-}
-
-void CFXEU_SetWordProps::Undo()
-{
- if (m_pEdit)
- {
- m_pEdit->SetWordProps(m_eProps,m_wpPlace,&m_OldWordProps,m_wrPlace,FALSE);
- if (IsFirst())
- {
- m_pEdit->SelectNone();
- m_pEdit->PaintSetProps(m_eProps,m_wrPlace);
- m_pEdit->SetSel(m_wrPlace.BeginPos,m_wrPlace.EndPos);
- }
- }
-}
-
-/* ------------------------------------- CFX_Edit ------------------------------------- */
-
-CFX_Edit::CFX_Edit(IPDF_VariableText * pVT) :
- m_pVT(pVT),
- m_pNotify(NULL),
- m_pOprNotify(NULL),
- m_pVTProvide(NULL),
- m_wpCaret(-1,-1,-1),
- m_wpOldCaret(-1,-1,-1),
- m_SelState(),
- m_ptScrollPos(0,0),
- m_ptRefreshScrollPos(0,0),
- m_bEnableScroll(FALSE),
- m_pIterator(NULL),
- m_ptCaret(0.0f,0.0f),
- m_Undo(FX_EDIT_UNDO_MAXITEM),
- m_nAlignment(0),
- m_bNotifyFlag(FALSE),
- m_bEnableOverflow(FALSE),
- m_bEnableRefresh(TRUE),
- m_rcOldContent(0.0f,0.0f,0.0f,0.0f),
- m_bEnableUndo(TRUE),
- m_bNotify(TRUE),
- m_bOprNotify(FALSE),
- m_pGroupUndoItem(NULL)
-{
- ASSERT(pVT != NULL);
-}
-
-CFX_Edit::~CFX_Edit()
-{
- delete m_pVTProvide;
- m_pVTProvide = NULL;
- delete m_pIterator;
- m_pIterator = NULL;
- ASSERT(m_pGroupUndoItem == NULL);
+CFXEU_SetWordProps::CFXEU_SetWordProps(CFX_Edit* pEdit,
+ const CPVT_WordPlace& place,
+ EDIT_PROPS_E ep,
+ const CPVT_WordProps& oldprops,
+ const CPVT_WordProps& newprops,
+ const CPVT_WordRange& range)
+ : m_pEdit(pEdit),
+ m_wpPlace(place),
+ m_wrPlace(range),
+ m_eProps(ep),
+ m_OldWordProps(oldprops),
+ m_NewWordProps(newprops) {}
+
+CFXEU_SetWordProps::~CFXEU_SetWordProps() {}
+
+void CFXEU_SetWordProps::Redo() {
+ if (m_pEdit) {
+ m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_NewWordProps, m_wrPlace,
+ FALSE);
+ if (IsLast()) {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps, m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos);
+ }
+ }
+}
+
+void CFXEU_SetWordProps::Undo() {
+ if (m_pEdit) {
+ m_pEdit->SetWordProps(m_eProps, m_wpPlace, &m_OldWordProps, m_wrPlace,
+ FALSE);
+ if (IsFirst()) {
+ m_pEdit->SelectNone();
+ m_pEdit->PaintSetProps(m_eProps, m_wrPlace);
+ m_pEdit->SetSel(m_wrPlace.BeginPos, m_wrPlace.EndPos);
+ }
+ }
+}
+
+/* ------------------------------------- CFX_Edit
+ * ------------------------------------- */
+
+CFX_Edit::CFX_Edit(IPDF_VariableText* pVT)
+ : m_pVT(pVT),
+ m_pNotify(NULL),
+ m_pOprNotify(NULL),
+ m_pVTProvide(NULL),
+ m_wpCaret(-1, -1, -1),
+ m_wpOldCaret(-1, -1, -1),
+ m_SelState(),
+ m_ptScrollPos(0, 0),
+ m_ptRefreshScrollPos(0, 0),
+ m_bEnableScroll(FALSE),
+ m_pIterator(NULL),
+ m_ptCaret(0.0f, 0.0f),
+ m_Undo(FX_EDIT_UNDO_MAXITEM),
+ m_nAlignment(0),
+ m_bNotifyFlag(FALSE),
+ m_bEnableOverflow(FALSE),
+ m_bEnableRefresh(TRUE),
+ m_rcOldContent(0.0f, 0.0f, 0.0f, 0.0f),
+ m_bEnableUndo(TRUE),
+ m_bNotify(TRUE),
+ m_bOprNotify(FALSE),
+ m_pGroupUndoItem(NULL) {
+ ASSERT(pVT != NULL);
+}
+
+CFX_Edit::~CFX_Edit() {
+ delete m_pVTProvide;
+ m_pVTProvide = NULL;
+ delete m_pIterator;
+ m_pIterator = NULL;
+ ASSERT(m_pGroupUndoItem == NULL);
}
// public methods
-void CFX_Edit::Initialize()
-{
- m_pVT->Initialize();
- SetCaret(m_pVT->GetBeginWordPlace());
- SetCaretOrigin();
+void CFX_Edit::Initialize() {
+ m_pVT->Initialize();
+ SetCaret(m_pVT->GetBeginWordPlace());
+ SetCaretOrigin();
}
-void CFX_Edit::SetFontMap(IFX_Edit_FontMap * pFontMap)
-{
- delete m_pVTProvide;
- m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap));
+void CFX_Edit::SetFontMap(IFX_Edit_FontMap* pFontMap) {
+ delete m_pVTProvide;
+ m_pVT->SetProvider(m_pVTProvide = new CFX_Edit_Provider(pFontMap));
}
-void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider)
-{
- m_pVT->SetProvider(pProvider);
+void CFX_Edit::SetVTProvider(IPDF_VariableText_Provider* pProvider) {
+ m_pVT->SetProvider(pProvider);
}
-void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify)
-{
- m_pNotify = pNotify;
+void CFX_Edit::SetNotify(IFX_Edit_Notify* pNotify) {
+ m_pNotify = pNotify;
}
-void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify)
-{
- m_pOprNotify = pOprNotify;
+void CFX_Edit::SetOprNotify(IFX_Edit_OprNotify* pOprNotify) {
+ m_pOprNotify = pOprNotify;
}
-IFX_Edit_Iterator * CFX_Edit::GetIterator()
-{
- if (!m_pIterator)
- m_pIterator = new CFX_Edit_Iterator(this,m_pVT->GetIterator());
+IFX_Edit_Iterator* CFX_Edit::GetIterator() {
+ if (!m_pIterator)
+ m_pIterator = new CFX_Edit_Iterator(this, m_pVT->GetIterator());
- return m_pIterator;
+ return m_pIterator;
}
-IPDF_VariableText * CFX_Edit::GetVariableText()
-{
- return m_pVT;
+IPDF_VariableText* CFX_Edit::GetVariableText() {
+ return m_pVT;
}
-IFX_Edit_FontMap* CFX_Edit::GetFontMap()
-{
- if (m_pVTProvide)
- return m_pVTProvide->GetFontMap();
+IFX_Edit_FontMap* CFX_Edit::GetFontMap() {
+ if (m_pVTProvide)
+ return m_pVTProvide->GetFontMap();
- return NULL;
+ return NULL;
}
-void CFX_Edit::SetPlateRect(const CPDF_Rect & rect, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetPlateRect(rect);
- m_ptScrollPos = CPDF_Point(rect.left,rect.top);
- if (bPaint) Paint();
+void CFX_Edit::SetPlateRect(const CPDF_Rect& rect, FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetPlateRect(rect);
+ m_ptScrollPos = CPDF_Point(rect.left, rect.top);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetAlignmentH(int32_t nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetAlignment(nFormat);
- if (bPaint) Paint();
+void CFX_Edit::SetAlignmentH(int32_t nFormat /* =0 */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetAlignment(nFormat);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetAlignmentV(int32_t nFormat/* =0 */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_nAlignment = nFormat;
- if (bPaint) Paint();
+void CFX_Edit::SetAlignmentV(int32_t nFormat /* =0 */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_nAlignment = nFormat;
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetPasswordChar(FX_WORD wSubWord/* ='*' */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetPasswordChar(wSubWord);
- if (bPaint) Paint();
+void CFX_Edit::SetPasswordChar(FX_WORD wSubWord /* ='*' */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetPasswordChar(wSubWord);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetLimitChar(int32_t nLimitChar/* =0 */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetLimitChar(nLimitChar);
- if (bPaint) Paint();
+void CFX_Edit::SetLimitChar(int32_t nLimitChar /* =0 */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetLimitChar(nLimitChar);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetCharArray(int32_t nCharArray/* =0 */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetCharArray(nCharArray);
- if (bPaint) Paint();
+void CFX_Edit::SetCharArray(int32_t nCharArray /* =0 */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetCharArray(nCharArray);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace/* =0.0f */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetCharSpace(fCharSpace);
- if (bPaint) Paint();
+void CFX_Edit::SetCharSpace(FX_FLOAT fCharSpace /* =0.0f */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetCharSpace(fCharSpace);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetHorzScale(int32_t nHorzScale/* =100 */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetHorzScale(nHorzScale);
- if (bPaint) Paint();
+void CFX_Edit::SetHorzScale(int32_t nHorzScale /* =100 */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetHorzScale(nHorzScale);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetMultiLine(bMultiLine);
- if (bPaint) Paint();
+void CFX_Edit::SetMultiLine(FX_BOOL bMultiLine /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetMultiLine(bMultiLine);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetAutoReturn(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetAutoReturn(bAuto);
- if (bPaint) Paint();
+void CFX_Edit::SetAutoReturn(FX_BOOL bAuto /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetAutoReturn(bAuto);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetLineLeading(fLineLeading);
- if (bPaint) Paint();
+void CFX_Edit::SetLineLeading(FX_FLOAT fLineLeading /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetLineLeading(fLineLeading);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetAutoFontSize(bAuto);
- if (bPaint) Paint();
+void CFX_Edit::SetAutoFontSize(FX_BOOL bAuto /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetAutoFontSize(bAuto);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetFontSize(fFontSize);
- if (bPaint) Paint();
+void CFX_Edit::SetFontSize(FX_FLOAT fFontSize, FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetFontSize(fFontSize);
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetAutoScroll(FX_BOOL bAuto/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_bEnableScroll = bAuto;
- if (bPaint) Paint();
+void CFX_Edit::SetAutoScroll(FX_BOOL bAuto /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_bEnableScroll = bAuto;
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/, FX_BOOL bPaint/* = TRUE*/)
-{
- m_bEnableOverflow = bAllowed;
- if (bPaint) Paint();
+void CFX_Edit::SetTextOverflow(FX_BOOL bAllowed /*= FALSE*/,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_bEnableOverflow = bAllowed;
+ if (bPaint)
+ Paint();
}
-void CFX_Edit::SetSel(int32_t nStartChar,int32_t nEndChar)
-{
- if (m_pVT->IsValid())
- {
- if (nStartChar == 0 && nEndChar < 0)
- {
- SelectAll();
- }
- else if (nStartChar < 0)
- {
- SelectNone();
- }
- else
- {
- if (nStartChar < nEndChar)
- {
- SetSel(m_pVT->WordIndexToWordPlace(nStartChar),m_pVT->WordIndexToWordPlace(nEndChar));
- }
- else
- {
- SetSel(m_pVT->WordIndexToWordPlace(nEndChar),m_pVT->WordIndexToWordPlace(nStartChar));
- }
- }
+void CFX_Edit::SetSel(int32_t nStartChar, int32_t nEndChar) {
+ if (m_pVT->IsValid()) {
+ if (nStartChar == 0 && nEndChar < 0) {
+ SelectAll();
+ } else if (nStartChar < 0) {
+ SelectNone();
+ } else {
+ if (nStartChar < nEndChar) {
+ SetSel(m_pVT->WordIndexToWordPlace(nStartChar),
+ m_pVT->WordIndexToWordPlace(nEndChar));
+ } else {
+ SetSel(m_pVT->WordIndexToWordPlace(nEndChar),
+ m_pVT->WordIndexToWordPlace(nStartChar));
+ }
}
+ }
}
-void CFX_Edit::SetSel(const CPVT_WordPlace & begin,const CPVT_WordPlace & end)
-{
- if (m_pVT->IsValid())
- {
- SelectNone();
+void CFX_Edit::SetSel(const CPVT_WordPlace& begin, const CPVT_WordPlace& end) {
+ if (m_pVT->IsValid()) {
+ SelectNone();
- m_SelState.Set(begin,end);
+ m_SelState.Set(begin, end);
- SetCaret(m_SelState.EndPos);
+ SetCaret(m_SelState.EndPos);
- if (m_SelState.IsExist())
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_SelState.BeginPos,m_SelState.EndPos);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- else
- {
- ScrollToCaret();
- SetCaretInfo();
- }
+ if (m_SelState.IsExist()) {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_SelState.BeginPos, m_SelState.EndPos);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ } else {
+ ScrollToCaret();
+ SetCaretInfo();
}
+ }
}
-void CFX_Edit::GetSel(int32_t & nStartChar, int32_t & nEndChar) const
-{
- nStartChar = -1;
- nEndChar = -1;
+void CFX_Edit::GetSel(int32_t& nStartChar, int32_t& nEndChar) const {
+ nStartChar = -1;
+ nEndChar = -1;
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
- }
- else
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
- }
- }
- else
- {
- nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
- nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
- }
+ if (m_pVT->IsValid()) {
+ if (m_SelState.IsExist()) {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0) {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
+ } else {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_SelState.EndPos);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_SelState.BeginPos);
+ }
+ } else {
+ nStartChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
+ nEndChar = m_pVT->WordPlaceToWordIndex(m_wpCaret);
}
+ }
}
-int32_t CFX_Edit::GetCaret() const
-{
- if (m_pVT->IsValid())
- return m_pVT->WordPlaceToWordIndex(m_wpCaret);
+int32_t CFX_Edit::GetCaret() const {
+ if (m_pVT->IsValid())
+ return m_pVT->WordPlaceToWordIndex(m_wpCaret);
- return -1;
+ return -1;
}
-CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const
-{
- return m_wpCaret;
+CPVT_WordPlace CFX_Edit::GetCaretWordPlace() const {
+ return m_wpCaret;
}
-CFX_WideString CFX_Edit::GetText() const
-{
- CFX_WideString swRet;
+CFX_WideString CFX_Edit::GetText() const {
+ CFX_WideString swRet;
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bRich = m_pVT->IsRichText();
+ if (m_pVT->IsValid()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ FX_BOOL bRich = m_pVT->IsRichText();
- pIterator->SetAt(0);
+ pIterator->SetAt(0);
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = pIterator->GetAt();
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
-
- if (pIterator->GetWord(wordinfo))
- {
- if (bRich)
- {
- swRet += wordinfo.Word;
- }
- else
- {
- swRet += wordinfo.Word;
- }
- }
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
- if (oldplace.SecCmp(place) != 0)
- {
- swRet += 0x0D;
- swRet += 0x0A;
- }
+ if (pIterator->GetWord(wordinfo)) {
+ if (bRich) {
+ swRet += wordinfo.Word;
+ } else {
+ swRet += wordinfo.Word;
+ }
+ }
- oldplace = place;
- }
+ if (oldplace.SecCmp(place) != 0) {
+ swRet += 0x0D;
+ swRet += 0x0A;
}
+
+ oldplace = place;
+ }
}
+ }
- return swRet;
+ return swRet;
}
-CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange & range) const
-{
- CFX_WideString swRet;
+CFX_WideString CFX_Edit::GetRangeText(const CPVT_WordRange& range) const {
+ CFX_WideString swRet;
- if (m_pVT->IsValid())
- {
- FX_BOOL bRich = m_pVT->IsRichText();
+ if (m_pVT->IsValid()) {
+ FX_BOOL bRich = m_pVT->IsRichText();
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = range;
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordRange wrTemp = range;
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- CPVT_Word wordinfo;
- CPVT_WordPlace oldplace = wrTemp.BeginPos;
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0)break;
-
- if (pIterator->GetWord(wordinfo))
- {
- if (bRich)
- {
- swRet += wordinfo.Word;
- }
- else
- {
- swRet += wordinfo.Word;
- }
- }
+ CPVT_Word wordinfo;
+ CPVT_WordPlace oldplace = wrTemp.BeginPos;
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
- if (oldplace.SecCmp(place) != 0)
- {
- swRet += 0x0D;
- swRet += 0x0A;
- }
+ if (pIterator->GetWord(wordinfo)) {
+ if (bRich) {
+ swRet += wordinfo.Word;
+ } else {
+ swRet += wordinfo.Word;
+ }
+ }
- oldplace = place;
- }
+ if (oldplace.SecCmp(place) != 0) {
+ swRet += 0x0D;
+ swRet += 0x0A;
}
+
+ oldplace = place;
+ }
}
+ }
- return swRet;
+ return swRet;
}
-CFX_WideString CFX_Edit::GetSelText() const
-{
- return GetRangeText(m_SelState.ConvertToWordRange());
+CFX_WideString CFX_Edit::GetSelText() const {
+ return GetRangeText(m_SelState.ConvertToWordRange());
}
-int32_t CFX_Edit::GetTotalWords() const
-{
- return m_pVT->GetTotalWords();
+int32_t CFX_Edit::GetTotalWords() const {
+ return m_pVT->GetTotalWords();
}
-int32_t CFX_Edit::GetTotalLines() const
-{
- int32_t nLines = 0;
+int32_t CFX_Edit::GetTotalLines() const {
+ int32_t nLines = 0;
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(0);
- while (pIterator->NextLine())
- nLines++;
- }
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(0);
+ while (pIterator->NextLine())
+ nLines++;
+ }
- return nLines+1;
+ return nLines + 1;
}
-CPVT_WordRange CFX_Edit::GetSelectWordRange() const
-{
- return m_SelState.ConvertToWordRange();
+CPVT_WordRange CFX_Edit::GetSelectWordRange() const {
+ return m_SelState.ConvertToWordRange();
}
-CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange & wr1, const CPVT_WordRange & wr2)
-{
- CPVT_WordRange wrRet;
+CPVT_WordRange CFX_Edit::CombineWordRange(const CPVT_WordRange& wr1,
+ const CPVT_WordRange& wr2) {
+ CPVT_WordRange wrRet;
- if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0)
- {
- wrRet.BeginPos = wr1.BeginPos;
- }
- else
- {
- wrRet.BeginPos = wr2.BeginPos;
- }
+ if (wr1.BeginPos.WordCmp(wr2.BeginPos) < 0) {
+ wrRet.BeginPos = wr1.BeginPos;
+ } else {
+ wrRet.BeginPos = wr2.BeginPos;
+ }
- if (wr1.EndPos.WordCmp(wr2.EndPos) < 0)
- {
- wrRet.EndPos = wr2.EndPos;
- }
- else
- {
- wrRet.EndPos = wr1.EndPos;
- }
+ if (wr1.EndPos.WordCmp(wr2.EndPos) < 0) {
+ wrRet.EndPos = wr2.EndPos;
+ } else {
+ wrRet.EndPos = wr1.EndPos;
+ }
- return wrRet;
+ return wrRet;
}
-FX_BOOL CFX_Edit::IsRichText() const
-{
- return m_pVT->IsRichText();
+FX_BOOL CFX_Edit::IsRichText() const {
+ return m_pVT->IsRichText();
}
-void CFX_Edit::SetRichText(FX_BOOL bRichText/* =TRUE */, FX_BOOL bPaint/* = TRUE*/)
-{
- m_pVT->SetRichText(bRichText);
- if (bPaint) Paint();
+void CFX_Edit::SetRichText(FX_BOOL bRichText /* =TRUE */,
+ FX_BOOL bPaint /* = TRUE*/) {
+ m_pVT->SetRichText(bRichText);
+ if (bPaint)
+ Paint();
}
-FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex)
-{
- CPVT_WordProps WordProps;
- WordProps.nFontIndex = nFontIndex;
- return SetRichTextProps(EP_FONTINDEX,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichFontIndex(int32_t nFontIndex) {
+ CPVT_WordProps WordProps;
+ WordProps.nFontIndex = nFontIndex;
+ return SetRichTextProps(EP_FONTINDEX, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize)
-{
- CPVT_WordProps WordProps;
- WordProps.fFontSize = fFontSize;
- return SetRichTextProps(EP_FONTSIZE,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichFontSize(FX_FLOAT fFontSize) {
+ CPVT_WordProps WordProps;
+ WordProps.fFontSize = fFontSize;
+ return SetRichTextProps(EP_FONTSIZE, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor)
-{
- CPVT_WordProps WordProps;
- WordProps.dwWordColor = dwColor;
- return SetRichTextProps(EP_WORDCOLOR,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextColor(FX_COLORREF dwColor) {
+ CPVT_WordProps WordProps;
+ WordProps.dwWordColor = dwColor;
+ return SetRichTextProps(EP_WORDCOLOR, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextScript(int32_t nScriptType)
-{
- CPVT_WordProps WordProps;
- WordProps.nScriptType = nScriptType;
- return SetRichTextProps(EP_SCRIPTTYPE,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextScript(int32_t nScriptType) {
+ CPVT_WordProps WordProps;
+ WordProps.nScriptType = nScriptType;
+ return SetRichTextProps(EP_SCRIPTTYPE, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold)
-{
- CPVT_WordProps WordProps;
- if (bBold)
- WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- return SetRichTextProps(EP_BOLD,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextBold(FX_BOOL bBold) {
+ CPVT_WordProps WordProps;
+ if (bBold)
+ WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ return SetRichTextProps(EP_BOLD, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic)
-{
- CPVT_WordProps WordProps;
- if (bItalic)
- WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- return SetRichTextProps(EP_ITALIC,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextItalic(FX_BOOL bItalic) {
+ CPVT_WordProps WordProps;
+ if (bItalic)
+ WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ return SetRichTextProps(EP_ITALIC, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline)
-{
- CPVT_WordProps WordProps;
- if (bUnderline)
- WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- return SetRichTextProps(EP_UNDERLINE,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextUnderline(FX_BOOL bUnderline) {
+ CPVT_WordProps WordProps;
+ if (bUnderline)
+ WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ return SetRichTextProps(EP_UNDERLINE, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout)
-{
- CPVT_WordProps WordProps;
- if (bCrossout)
- WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- return SetRichTextProps(EP_CROSSOUT,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextCrossout(FX_BOOL bCrossout) {
+ CPVT_WordProps WordProps;
+ if (bCrossout)
+ WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ return SetRichTextProps(EP_CROSSOUT, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace)
-{
- CPVT_WordProps WordProps;
- WordProps.fCharSpace = fCharSpace;
- return SetRichTextProps(EP_CHARSPACE,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextCharSpace(FX_FLOAT fCharSpace) {
+ CPVT_WordProps WordProps;
+ WordProps.fCharSpace = fCharSpace;
+ return SetRichTextProps(EP_CHARSPACE, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale /*= 100*/)
-{
- CPVT_WordProps WordProps;
- WordProps.nHorzScale = nHorzScale;
- return SetRichTextProps(EP_HORZSCALE,NULL,&WordProps);
+FX_BOOL CFX_Edit::SetRichTextHorzScale(int32_t nHorzScale /*= 100*/) {
+ CPVT_WordProps WordProps;
+ WordProps.nHorzScale = nHorzScale;
+ return SetRichTextProps(EP_HORZSCALE, NULL, &WordProps);
}
-FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading)
-{
- CPVT_SecProps SecProps;
- SecProps.fLineLeading = fLineLeading;
- return SetRichTextProps(EP_LINELEADING,&SecProps,NULL);
+FX_BOOL CFX_Edit::SetRichTextLineLeading(FX_FLOAT fLineLeading) {
+ CPVT_SecProps SecProps;
+ SecProps.fLineLeading = fLineLeading;
+ return SetRichTextProps(EP_LINELEADING, &SecProps, NULL);
}
-FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent)
-{
- CPVT_SecProps SecProps;
- SecProps.fLineIndent = fLineIndent;
- return SetRichTextProps(EP_LINEINDENT,&SecProps,NULL);
+FX_BOOL CFX_Edit::SetRichTextLineIndent(FX_FLOAT fLineIndent) {
+ CPVT_SecProps SecProps;
+ SecProps.fLineIndent = fLineIndent;
+ return SetRichTextProps(EP_LINEINDENT, &SecProps, NULL);
}
-FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment)
-{
- CPVT_SecProps SecProps;
- SecProps.nAlignment = nAlignment;
- return SetRichTextProps(EP_ALIGNMENT,&SecProps,NULL);
+FX_BOOL CFX_Edit::SetRichTextAlignment(int32_t nAlignment) {
+ CPVT_SecProps SecProps;
+ SecProps.nAlignment = nAlignment;
+ return SetRichTextProps(EP_ALIGNMENT, &SecProps, NULL);
}
-FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps, const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps)
-{
- FX_BOOL bSet = FALSE;
- FX_BOOL bSet1,bSet2;
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
+FX_BOOL CFX_Edit::SetRichTextProps(EDIT_PROPS_E eProps,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps) {
+ FX_BOOL bSet = FALSE;
+ FX_BOOL bSet1, bSet2;
+ if (m_pVT->IsValid() && m_pVT->IsRichText()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- BeginGroupUndo(L"");;
+ BeginGroupUndo(L"");
+ ;
- bSet = SetSecProps(eProps,wrTemp.BeginPos,pSecProps,pWordProps,wrTemp,TRUE);
+ bSet = SetSecProps(eProps, wrTemp.BeginPos, pSecProps, pWordProps, wrTemp,
+ TRUE);
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
- bSet1 = SetSecProps(eProps,place,pSecProps,pWordProps,wrTemp,TRUE);
- bSet2 = SetWordProps(eProps,place,pWordProps,wrTemp,TRUE);
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
+ bSet1 = SetSecProps(eProps, place, pSecProps, pWordProps, wrTemp, TRUE);
+ bSet2 = SetWordProps(eProps, place, pWordProps, wrTemp, TRUE);
- if (!bSet)
- bSet = (bSet1 || bSet2);
- }
+ if (!bSet)
+ bSet = (bSet1 || bSet2);
+ }
- EndGroupUndo();
+ EndGroupUndo();
- if (bSet)
- {
- PaintSetProps(eProps,wrTemp);
- }
- }
+ if (bSet) {
+ PaintSetProps(eProps, wrTemp);
+ }
}
+ }
- return bSet;
+ return bSet;
}
-void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange & wr)
-{
- switch(eProps)
- {
+void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange& wr) {
+ switch (eProps) {
case EP_LINELEADING:
case EP_LINEINDENT:
case EP_ALIGNMENT:
- RearrangePart(wr);
- ScrollToCaret();
- Refresh(RP_ANALYSE);
- SetCaretOrigin();
- SetCaretInfo();
- break;
+ RearrangePart(wr);
+ ScrollToCaret();
+ Refresh(RP_ANALYSE);
+ SetCaretOrigin();
+ SetCaretInfo();
+ break;
case EP_WORDCOLOR:
case EP_UNDERLINE:
case EP_CROSSOUT:
- Refresh(RP_OPTIONAL,&wr);
- break;
+ Refresh(RP_OPTIONAL, &wr);
+ break;
case EP_FONTINDEX:
case EP_FONTSIZE:
case EP_SCRIPTTYPE:
@@ -1503,2053 +1320,1814 @@ void CFX_Edit::PaintSetProps(EDIT_PROPS_E eProps, const CPVT_WordRange & wr)
case EP_HORZSCALE:
case EP_BOLD:
case EP_ITALIC:
- RearrangePart(wr);
- ScrollToCaret();
-
- CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos),
- m_pVT->GetSectionEndPlace(wr.EndPos));
- Refresh(RP_ANALYSE,&wrRefresh);
-
- SetCaretOrigin();
- SetCaretInfo();
- break;
- }
-}
-
-FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps,
- const CPVT_WordRange & wr, FX_BOOL bAddUndo)
-{
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bSet = FALSE;
- CPVT_Section secinfo;
- CPVT_Section OldSecinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
-
- if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT || eProps == EP_ALIGNMENT)
- {
- if (pSecProps)
- {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo))
- {
- if (bAddUndo) OldSecinfo = secinfo;
-
- switch(eProps)
- {
- case EP_LINELEADING:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,pSecProps->fLineLeading))
- {
- secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
- bSet = TRUE;
- }
- break;
- case EP_LINEINDENT:
- if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,pSecProps->fLineIndent))
- {
- secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
- bSet = TRUE;
- }
- break;
- case EP_ALIGNMENT:
- if (secinfo.SecProps.nAlignment != pSecProps->nAlignment)
- {
- secinfo.SecProps.nAlignment = pSecProps->nAlignment;
- bSet = TRUE;
- }
- break;
- default:
- break;
- }
- }
+ RearrangePart(wr);
+ ScrollToCaret();
+
+ CPVT_WordRange wrRefresh(m_pVT->GetSectionBeginPlace(wr.BeginPos),
+ m_pVT->GetSectionEndPlace(wr.EndPos));
+ Refresh(RP_ANALYSE, &wrRefresh);
+
+ SetCaretOrigin();
+ SetCaretInfo();
+ break;
+ }
+}
+
+FX_BOOL CFX_Edit::SetSecProps(EDIT_PROPS_E eProps,
+ const CPVT_WordPlace& place,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps,
+ const CPVT_WordRange& wr,
+ FX_BOOL bAddUndo) {
+ if (m_pVT->IsValid() && m_pVT->IsRichText()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ FX_BOOL bSet = FALSE;
+ CPVT_Section secinfo;
+ CPVT_Section OldSecinfo;
+
+ CPVT_WordPlace oldplace = pIterator->GetAt();
+
+ if (eProps == EP_LINELEADING || eProps == EP_LINEINDENT ||
+ eProps == EP_ALIGNMENT) {
+ if (pSecProps) {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo)) {
+ if (bAddUndo)
+ OldSecinfo = secinfo;
+
+ switch (eProps) {
+ case EP_LINELEADING:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineLeading,
+ pSecProps->fLineLeading)) {
+ secinfo.SecProps.fLineLeading = pSecProps->fLineLeading;
+ bSet = TRUE;
}
- }
- else
- {
- if (pWordProps && place == m_pVT->GetSectionBeginPlace(place))
- {
- pIterator->SetAt(place);
- if (pIterator->GetSection(secinfo))
- {
- if (bAddUndo) OldSecinfo = secinfo;
-
- switch(eProps)
- {
- case EP_FONTINDEX:
- if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
- {
- secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
- bSet = TRUE;
- }
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,pWordProps->fFontSize))
- {
- secinfo.WordProps.fFontSize = pWordProps->fFontSize;
- bSet = TRUE;
- }
- break;
- case EP_WORDCOLOR:
- if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
- {
- secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
- bSet = TRUE;
- }
- break;
- case EP_SCRIPTTYPE:
- if (secinfo.WordProps.nScriptType != pWordProps->nScriptType)
- {
- secinfo.WordProps.nScriptType = pWordProps->nScriptType;
- bSet = TRUE;
- }
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
- {
- secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
- bSet = TRUE;
- }
- break;
- case EP_HORZSCALE:
- if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
- {
- secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
- bSet = TRUE;
- }
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
- {
- secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- else
- {
- if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
- {
- secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
+ break;
+ case EP_LINEINDENT:
+ if (!FX_EDIT_IsFloatEqual(secinfo.SecProps.fLineIndent,
+ pSecProps->fLineIndent)) {
+ secinfo.SecProps.fLineIndent = pSecProps->fLineIndent;
+ bSet = TRUE;
}
+ break;
+ case EP_ALIGNMENT:
+ if (secinfo.SecProps.nAlignment != pSecProps->nAlignment) {
+ secinfo.SecProps.nAlignment = pSecProps->nAlignment;
+ bSet = TRUE;
+ }
+ break;
+ default:
+ break;
}
-
- if (bSet)
- {
- pIterator->SetSection(secinfo);
-
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_SetSecProps
- (this,place,eProps,OldSecinfo.SecProps,OldSecinfo.WordProps,secinfo.SecProps,secinfo.WordProps,wr));
+ }
+ }
+ } else {
+ if (pWordProps && place == m_pVT->GetSectionBeginPlace(place)) {
+ pIterator->SetAt(place);
+ if (pIterator->GetSection(secinfo)) {
+ if (bAddUndo)
+ OldSecinfo = secinfo;
+
+ switch (eProps) {
+ case EP_FONTINDEX:
+ if (secinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
+ secinfo.WordProps.nFontIndex = pWordProps->nFontIndex;
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fFontSize,
+ pWordProps->fFontSize)) {
+ secinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (secinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
+ secinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (secinfo.WordProps.nScriptType != pWordProps->nScriptType) {
+ secinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(secinfo.WordProps.fCharSpace,
+ pWordProps->fCharSpace)) {
+ secinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (secinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
+ secinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ if ((secinfo.WordProps.nWordStyle &
+ PVTWORD_STYLE_UNDERLINE) == 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ } else {
+ if ((secinfo.WordProps.nWordStyle &
+ PVTWORD_STYLE_UNDERLINE) != 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) ==
+ 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) !=
+ 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) ==
+ 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) !=
+ 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) ==
+ 0) {
+ secinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ } else {
+ if ((secinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) !=
+ 0) {
+ secinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
}
+ break;
+ default:
+ break;
}
+ }
+ }
+ }
- pIterator->SetAt(oldplace);
+ if (bSet) {
+ pIterator->SetSection(secinfo);
- return bSet;
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_SetSecProps(
+ this, place, eProps, OldSecinfo.SecProps, OldSecinfo.WordProps,
+ secinfo.SecProps, secinfo.WordProps, wr));
}
+ }
+
+ pIterator->SetAt(oldplace);
+
+ return bSet;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps, const CPVT_WordPlace & place,
- const CPVT_WordProps * pWordProps, const CPVT_WordRange & wr, FX_BOOL bAddUndo)
-{
- if (m_pVT->IsValid() && m_pVT->IsRichText())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- FX_BOOL bSet = FALSE;
- CPVT_Word wordinfo;
- CPVT_Word OldWordinfo;
-
- CPVT_WordPlace oldplace = pIterator->GetAt();
-
- if (pWordProps)
- {
- pIterator->SetAt(place);
- if (pIterator->GetWord(wordinfo))
- {
- if (bAddUndo) OldWordinfo = wordinfo;
-
- switch(eProps)
- {
- case EP_FONTINDEX:
- if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex)
- {
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- {
- wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(wordinfo.Word,wordinfo.nCharset,pWordProps->nFontIndex);
- }
- bSet = TRUE;
- }
- break;
- case EP_FONTSIZE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,pWordProps->fFontSize))
- {
- wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
- bSet = TRUE;
- }
- break;
- case EP_WORDCOLOR:
- if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor)
- {
- wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
- bSet = TRUE;
- }
- break;
- case EP_SCRIPTTYPE:
- if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType)
- {
- wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
- bSet = TRUE;
- }
- break;
- case EP_CHARSPACE:
- if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,pWordProps->fCharSpace))
- {
- wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
- bSet = TRUE;
- }
- break;
- case EP_HORZSCALE:
- if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale)
- {
- wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
- bSet = TRUE;
- }
- break;
- case EP_UNDERLINE:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
- bSet = TRUE;
- }
- }
- break;
- case EP_CROSSOUT:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
- bSet = TRUE;
- }
- }
- break;
- case EP_BOLD:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
- bSet = TRUE;
- }
- }
- break;
- case EP_ITALIC:
- if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC)
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) == 0)
- {
- wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- else
- {
- if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) != 0)
- {
- wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
- bSet = TRUE;
- }
- }
- break;
- default:
- break;
- }
- }
- }
+FX_BOOL CFX_Edit::SetWordProps(EDIT_PROPS_E eProps,
+ const CPVT_WordPlace& place,
+ const CPVT_WordProps* pWordProps,
+ const CPVT_WordRange& wr,
+ FX_BOOL bAddUndo) {
+ if (m_pVT->IsValid() && m_pVT->IsRichText()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ FX_BOOL bSet = FALSE;
+ CPVT_Word wordinfo;
+ CPVT_Word OldWordinfo;
- if (bSet)
- {
- pIterator->SetWord(wordinfo);
+ CPVT_WordPlace oldplace = pIterator->GetAt();
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_SetWordProps
- (this,place,eProps,OldWordinfo.WordProps,wordinfo.WordProps,wr));
+ if (pWordProps) {
+ pIterator->SetAt(place);
+ if (pIterator->GetWord(wordinfo)) {
+ if (bAddUndo)
+ OldWordinfo = wordinfo;
+
+ switch (eProps) {
+ case EP_FONTINDEX:
+ if (wordinfo.WordProps.nFontIndex != pWordProps->nFontIndex) {
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap()) {
+ wordinfo.WordProps.nFontIndex = pFontMap->GetWordFontIndex(
+ wordinfo.Word, wordinfo.nCharset, pWordProps->nFontIndex);
}
- }
+ bSet = TRUE;
+ }
+ break;
+ case EP_FONTSIZE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fFontSize,
+ pWordProps->fFontSize)) {
+ wordinfo.WordProps.fFontSize = pWordProps->fFontSize;
+ bSet = TRUE;
+ }
+ break;
+ case EP_WORDCOLOR:
+ if (wordinfo.WordProps.dwWordColor != pWordProps->dwWordColor) {
+ wordinfo.WordProps.dwWordColor = pWordProps->dwWordColor;
+ bSet = TRUE;
+ }
+ break;
+ case EP_SCRIPTTYPE:
+ if (wordinfo.WordProps.nScriptType != pWordProps->nScriptType) {
+ wordinfo.WordProps.nScriptType = pWordProps->nScriptType;
+ bSet = TRUE;
+ }
+ break;
+ case EP_CHARSPACE:
+ if (!FX_EDIT_IsFloatEqual(wordinfo.WordProps.fCharSpace,
+ pWordProps->fCharSpace)) {
+ wordinfo.WordProps.fCharSpace = pWordProps->fCharSpace;
+ bSet = TRUE;
+ }
+ break;
+ case EP_HORZSCALE:
+ if (wordinfo.WordProps.nHorzScale != pWordProps->nHorzScale) {
+ wordinfo.WordProps.nHorzScale = pWordProps->nHorzScale;
+ bSet = TRUE;
+ }
+ break;
+ case EP_UNDERLINE:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) ==
+ 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) !=
+ 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_UNDERLINE;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_CROSSOUT:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) ==
+ 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) !=
+ 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_CROSSOUT;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_BOLD:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_BOLD) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) == 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_BOLD) != 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_BOLD;
+ bSet = TRUE;
+ }
+ }
+ break;
+ case EP_ITALIC:
+ if (pWordProps->nWordStyle & PVTWORD_STYLE_ITALIC) {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) ==
+ 0) {
+ wordinfo.WordProps.nWordStyle |= PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ } else {
+ if ((wordinfo.WordProps.nWordStyle & PVTWORD_STYLE_ITALIC) !=
+ 0) {
+ wordinfo.WordProps.nWordStyle &= ~PVTWORD_STYLE_ITALIC;
+ bSet = TRUE;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ }
- pIterator->SetAt(oldplace);
- return bSet;
+ if (bSet) {
+ pIterator->SetWord(wordinfo);
+
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_SetWordProps(this, place, eProps,
+ OldWordinfo.WordProps,
+ wordinfo.WordProps, wr));
}
+ }
+
+ pIterator->SetAt(oldplace);
+ return bSet;
}
+ }
- return FALSE;
+ return FALSE;
}
-void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset /*= DEFAULT_CHARSET*/,
- const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
-{
- SetText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
+void CFX_Edit::SetText(const FX_WCHAR* text,
+ int32_t charset /*= DEFAULT_CHARSET*/,
+ const CPVT_SecProps* pSecProps /*= NULL*/,
+ const CPVT_WordProps* pWordProps /*= NULL*/) {
+ SetText(text, charset, pSecProps, pWordProps, TRUE, TRUE);
}
-FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset /*= DEFAULT_CHARSET*/, const CPVT_WordProps * pWordProps /*= NULL*/)
-{
- return InsertWord(word,charset,pWordProps,TRUE,TRUE);
+FX_BOOL CFX_Edit::InsertWord(FX_WORD word,
+ int32_t charset /*= DEFAULT_CHARSET*/,
+ const CPVT_WordProps* pWordProps /*= NULL*/) {
+ return InsertWord(word, charset, pWordProps, TRUE, TRUE);
}
-FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
-{
- return InsertReturn(pSecProps,pWordProps,TRUE,TRUE);
+FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps /*= NULL*/,
+ const CPVT_WordProps* pWordProps /*= NULL*/) {
+ return InsertReturn(pSecProps, pWordProps, TRUE, TRUE);
}
-FX_BOOL CFX_Edit::Backspace()
-{
- return Backspace(TRUE,TRUE);
+FX_BOOL CFX_Edit::Backspace() {
+ return Backspace(TRUE, TRUE);
}
-FX_BOOL CFX_Edit::Delete()
-{
- return Delete(TRUE,TRUE);
+FX_BOOL CFX_Edit::Delete() {
+ return Delete(TRUE, TRUE);
}
-FX_BOOL CFX_Edit::Clear()
-{
- return Clear(TRUE,TRUE);
+FX_BOOL CFX_Edit::Clear() {
+ return Clear(TRUE, TRUE);
}
-FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset /*= DEFAULT_CHARSET*/,
- const CPVT_SecProps * pSecProps /*= NULL*/,const CPVT_WordProps * pWordProps /*= NULL*/)
-{
- return InsertText(text,charset,pSecProps,pWordProps,TRUE,TRUE);
+FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text,
+ int32_t charset /*= DEFAULT_CHARSET*/,
+ const CPVT_SecProps* pSecProps /*= NULL*/,
+ const CPVT_WordProps* pWordProps /*= NULL*/) {
+ return InsertText(text, charset, pSecProps, pWordProps, TRUE, TRUE);
}
-FX_FLOAT CFX_Edit::GetFontSize() const
-{
- return m_pVT->GetFontSize();
+FX_FLOAT CFX_Edit::GetFontSize() const {
+ return m_pVT->GetFontSize();
}
-FX_WORD CFX_Edit::GetPasswordChar() const
-{
- return m_pVT->GetPasswordChar();
+FX_WORD CFX_Edit::GetPasswordChar() const {
+ return m_pVT->GetPasswordChar();
}
-int32_t CFX_Edit::GetCharArray() const
-{
- return m_pVT->GetCharArray();
+int32_t CFX_Edit::GetCharArray() const {
+ return m_pVT->GetCharArray();
}
-CPDF_Rect CFX_Edit::GetPlateRect() const
-{
- return m_pVT->GetPlateRect();
+CPDF_Rect CFX_Edit::GetPlateRect() const {
+ return m_pVT->GetPlateRect();
}
-CPDF_Rect CFX_Edit::GetContentRect() const
-{
- return VTToEdit(m_pVT->GetContentRect());
+CPDF_Rect CFX_Edit::GetContentRect() const {
+ return VTToEdit(m_pVT->GetContentRect());
}
-int32_t CFX_Edit::GetHorzScale() const
-{
- return m_pVT->GetHorzScale();
+int32_t CFX_Edit::GetHorzScale() const {
+ return m_pVT->GetHorzScale();
}
-FX_FLOAT CFX_Edit::GetCharSpace() const
-{
- return m_pVT->GetCharSpace();
+FX_FLOAT CFX_Edit::GetCharSpace() const {
+ return m_pVT->GetCharSpace();
}
// inner methods
-CPVT_WordRange CFX_Edit::GetWholeWordRange() const
-{
- if (m_pVT->IsValid())
- return CPVT_WordRange(m_pVT->GetBeginWordPlace(),m_pVT->GetEndWordPlace());
+CPVT_WordRange CFX_Edit::GetWholeWordRange() const {
+ if (m_pVT->IsValid())
+ return CPVT_WordRange(m_pVT->GetBeginWordPlace(), m_pVT->GetEndWordPlace());
- return CPVT_WordRange();
+ return CPVT_WordRange();
}
-CPVT_WordRange CFX_Edit::GetVisibleWordRange() const
-{
- if (m_bEnableOverflow) return GetWholeWordRange();
+CPVT_WordRange CFX_Edit::GetVisibleWordRange() const {
+ if (m_bEnableOverflow)
+ return GetWholeWordRange();
- if (m_pVT->IsValid())
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ if (m_pVT->IsValid()) {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPVT_WordPlace place1 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left,rcPlate.top)));
- CPVT_WordPlace place2 = m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.right,rcPlate.bottom)));
+ CPVT_WordPlace place1 =
+ m_pVT->SearchWordPlace(EditToVT(CPDF_Point(rcPlate.left, rcPlate.top)));
+ CPVT_WordPlace place2 = m_pVT->SearchWordPlace(
+ EditToVT(CPDF_Point(rcPlate.right, rcPlate.bottom)));
- return CPVT_WordRange(place1,place2);
- }
+ return CPVT_WordRange(place1, place2);
+ }
- return CPVT_WordRange();
+ return CPVT_WordRange();
}
-CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const
-{
- if (m_pVT->IsValid())
- {
- return m_pVT->SearchWordPlace(EditToVT(point));
- }
-
- return CPVT_WordPlace();
-}
+CPVT_WordPlace CFX_Edit::SearchWordPlace(const CPDF_Point& point) const {
+ if (m_pVT->IsValid()) {
+ return m_pVT->SearchWordPlace(EditToVT(point));
+ }
-void CFX_Edit::Paint()
-{
- if (m_pVT->IsValid())
- {
- RearrangeAll();
- ScrollToCaret();
- Refresh(RP_NOANALYSE);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ return CPVT_WordPlace();
}
-void CFX_Edit::RearrangeAll()
-{
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- m_pVT->RearrangeAll();
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetScrollInfo();
- SetContentChanged();
- }
+void CFX_Edit::Paint() {
+ if (m_pVT->IsValid()) {
+ RearrangeAll();
+ ScrollToCaret();
+ Refresh(RP_NOANALYSE);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
-void CFX_Edit::RearrangePart(const CPVT_WordRange & range)
-{
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- m_pVT->RearrangePart(range);
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetScrollInfo();
- SetContentChanged();
- }
+void CFX_Edit::RearrangeAll() {
+ if (m_pVT->IsValid()) {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ m_pVT->RearrangeAll();
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetScrollInfo();
+ SetContentChanged();
+ }
}
-void CFX_Edit::SetContentChanged()
-{
- if (m_bNotify && m_pNotify)
- {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (rcContent.Width() != m_rcOldContent.Width() ||
- rcContent.Height() != m_rcOldContent.Height())
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnContentChange(rcContent);
- m_bNotifyFlag = FALSE;
- }
- m_rcOldContent = rcContent;
- }
- }
+void CFX_Edit::RearrangePart(const CPVT_WordRange& range) {
+ if (m_pVT->IsValid()) {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ m_pVT->RearrangePart(range);
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetScrollInfo();
+ SetContentChanged();
+ }
}
-void CFX_Edit::SelectAll()
-{
- if (m_pVT->IsValid())
- {
- m_SelState = GetWholeWordRange();
- SetCaret(m_SelState.EndPos);
-
- ScrollToCaret();
- CPVT_WordRange wrVisible = GetVisibleWordRange();
- Refresh(RP_OPTIONAL,&wrVisible);
- SetCaretInfo();
- }
+void CFX_Edit::SetContentChanged() {
+ if (m_bNotify && m_pNotify) {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ if (rcContent.Width() != m_rcOldContent.Width() ||
+ rcContent.Height() != m_rcOldContent.Height()) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnContentChange(rcContent);
+ m_bNotifyFlag = FALSE;
+ }
+ m_rcOldContent = rcContent;
+ }
+ }
+}
+
+void CFX_Edit::SelectAll() {
+ if (m_pVT->IsValid()) {
+ m_SelState = GetWholeWordRange();
+ SetCaret(m_SelState.EndPos);
+
+ ScrollToCaret();
+ CPVT_WordRange wrVisible = GetVisibleWordRange();
+ Refresh(RP_OPTIONAL, &wrVisible);
+ SetCaretInfo();
+ }
}
-void CFX_Edit::SelectNone()
-{
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
- m_SelState.Default();
- Refresh(RP_OPTIONAL,&wrTemp);
- }
+void CFX_Edit::SelectNone() {
+ if (m_pVT->IsValid()) {
+ if (m_SelState.IsExist()) {
+ CPVT_WordRange wrTemp = m_SelState.ConvertToWordRange();
+ m_SelState.Default();
+ Refresh(RP_OPTIONAL, &wrTemp);
}
+ }
}
-FX_BOOL CFX_Edit::IsSelected() const
-{
- return m_SelState.IsExist();
+FX_BOOL CFX_Edit::IsSelected() const {
+ return m_SelState.IsExist();
}
-CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point & point) const
-{
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+CPDF_Point CFX_Edit::VTToEdit(const CPDF_Point& point) const {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- FX_FLOAT fPadding = 0.0f;
+ FX_FLOAT fPadding = 0.0f;
- switch (m_nAlignment)
- {
+ switch (m_nAlignment) {
case 0:
- fPadding = 0.0f;
- break;
+ fPadding = 0.0f;
+ break;
case 1:
- fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
- break;
+ fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
+ break;
case 2:
- fPadding = rcPlate.Height() - rcContent.Height();
- break;
- }
+ fPadding = rcPlate.Height() - rcContent.Height();
+ break;
+ }
- return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
- point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
+ point.y - (m_ptScrollPos.y + fPadding - rcPlate.top));
}
-CPDF_Point CFX_Edit::EditToVT(const CPDF_Point & point) const
-{
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+CPDF_Point CFX_Edit::EditToVT(const CPDF_Point& point) const {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- FX_FLOAT fPadding = 0.0f;
+ FX_FLOAT fPadding = 0.0f;
- switch (m_nAlignment)
- {
+ switch (m_nAlignment) {
case 0:
- fPadding = 0.0f;
- break;
+ fPadding = 0.0f;
+ break;
case 1:
- fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
- break;
+ fPadding = (rcPlate.Height() - rcContent.Height()) * 0.5f;
+ break;
case 2:
- fPadding = rcPlate.Height() - rcContent.Height();
- break;
- }
+ fPadding = rcPlate.Height() - rcContent.Height();
+ break;
+ }
- return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
- point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
+ return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
+ point.y + (m_ptScrollPos.y + fPadding - rcPlate.top));
}
-CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect & rect) const
-{
- CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right,rect.top));
+CPDF_Rect CFX_Edit::VTToEdit(const CPDF_Rect& rect) const {
+ CPDF_Point ptLeftBottom = VTToEdit(CPDF_Point(rect.left, rect.bottom));
+ CPDF_Point ptRightTop = VTToEdit(CPDF_Point(rect.right, rect.top));
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
+ return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
}
-CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect & rect) const
-{
- CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right,rect.top));
+CPDF_Rect CFX_Edit::EditToVT(const CPDF_Rect& rect) const {
+ CPDF_Point ptLeftBottom = EditToVT(CPDF_Point(rect.left, rect.bottom));
+ CPDF_Point ptRightTop = EditToVT(CPDF_Point(rect.right, rect.top));
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
+ return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
}
-void CFX_Edit::SetScrollInfo()
-{
- if (m_bNotify && m_pNotify)
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
+void CFX_Edit::SetScrollInfo() {
+ if (m_bNotify && m_pNotify) {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right,
- rcContent.left, rcContent.right, rcPlate.Width() / 3, rcPlate.Width());
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollInfoX(rcPlate.left, rcPlate.right, rcContent.left,
+ rcContent.right, rcPlate.Width() / 3,
+ rcPlate.Width());
- m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
- rcContent.bottom, rcContent.top, rcPlate.Height() / 3, rcPlate.Height());
- m_bNotifyFlag = FALSE;
- }
+ m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
+ rcContent.bottom, rcContent.top,
+ rcPlate.Height() / 3, rcPlate.Height());
+ m_bNotifyFlag = FALSE;
}
+ }
}
-void CFX_Edit::SetScrollPosX(FX_FLOAT fx)
-{
- if (!m_bEnableScroll) return;
-
- if (m_pVT->IsValid())
- {
- if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x,fx))
- {
- m_ptScrollPos.x = fx;
- Refresh(RP_NOANALYSE);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollPosX(fx);
- m_bNotifyFlag = FALSE;
- }
- }
+void CFX_Edit::SetScrollPosX(FX_FLOAT fx) {
+ if (!m_bEnableScroll)
+ return;
+
+ if (m_pVT->IsValid()) {
+ if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.x, fx)) {
+ m_ptScrollPos.x = fx;
+ Refresh(RP_NOANALYSE);
+
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollPosX(fx);
+ m_bNotifyFlag = FALSE;
}
+ }
}
+ }
}
-void CFX_Edit::SetScrollPosY(FX_FLOAT fy)
-{
- if (!m_bEnableScroll) return;
-
- if (m_pVT->IsValid())
- {
- if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y,fy))
- {
- m_ptScrollPos.y = fy;
- Refresh(RP_NOANALYSE);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollPosY(fy);
- m_bNotifyFlag = FALSE;
- }
- }
+void CFX_Edit::SetScrollPosY(FX_FLOAT fy) {
+ if (!m_bEnableScroll)
+ return;
+
+ if (m_pVT->IsValid()) {
+ if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) {
+ m_ptScrollPos.y = fy;
+ Refresh(RP_NOANALYSE);
+
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollPosY(fy);
+ m_bNotifyFlag = FALSE;
}
+ }
}
+ }
}
-void CFX_Edit::SetScrollPos(const CPDF_Point & point)
-{
- SetScrollPosX(point.x);
- SetScrollPosY(point.y);
- SetScrollLimit();
- SetCaretInfo();
+void CFX_Edit::SetScrollPos(const CPDF_Point& point) {
+ SetScrollPosX(point.x);
+ SetScrollPosY(point.y);
+ SetScrollLimit();
+ SetCaretInfo();
}
-CPDF_Point CFX_Edit::GetScrollPos() const
-{
- return m_ptScrollPos;
+CPDF_Point CFX_Edit::GetScrollPos() const {
+ return m_ptScrollPos;
}
-void CFX_Edit::SetScrollLimit()
-{
- if (m_pVT->IsValid())
- {
- CPDF_Rect rcContent = m_pVT->GetContentRect();
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
-
- if (rcPlate.Width() > rcContent.Width())
- {
- SetScrollPosX(rcPlate.left);
- }
- else
- {
- if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left))
- {
- SetScrollPosX(rcContent.left);
- }
- else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x, rcContent.right - rcPlate.Width()))
- {
- SetScrollPosX(rcContent.right - rcPlate.Width());
- }
- }
+void CFX_Edit::SetScrollLimit() {
+ if (m_pVT->IsValid()) {
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- if (rcPlate.Height() > rcContent.Height())
- {
- SetScrollPosY(rcPlate.top);
- }
- else
- {
- if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y, rcContent.bottom + rcPlate.Height()))
- {
- SetScrollPosY(rcContent.bottom + rcPlate.Height());
- }
- else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top))
- {
- SetScrollPosY(rcContent.top);
- }
- }
- }
-}
+ if (rcPlate.Width() > rcContent.Width()) {
+ SetScrollPosX(rcPlate.left);
+ } else {
+ if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.x, rcContent.left)) {
+ SetScrollPosX(rcContent.left);
+ } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.x,
+ rcContent.right - rcPlate.Width())) {
+ SetScrollPosX(rcContent.right - rcPlate.Width());
+ }
+ }
+
+ if (rcPlate.Height() > rcContent.Height()) {
+ SetScrollPosY(rcPlate.top);
+ } else {
+ if (FX_EDIT_IsFloatSmaller(m_ptScrollPos.y,
+ rcContent.bottom + rcPlate.Height())) {
+ SetScrollPosY(rcContent.bottom + rcPlate.Height());
+ } else if (FX_EDIT_IsFloatBigger(m_ptScrollPos.y, rcContent.top)) {
+ SetScrollPosY(rcContent.top);
+ }
+ }
+ }
+}
+
+void CFX_Edit::ScrollToCaret() {
+ SetScrollLimit();
+
+ if (m_pVT->IsValid()) {
+ CPDF_Point ptHead(0, 0);
+ CPDF_Point ptFoot(0, 0);
+
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_wpCaret);
+
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ } else if (pIterator->GetLine(line)) {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
+ }
+
+ CPDF_Point ptHeadEdit = VTToEdit(ptHead);
+ CPDF_Point ptFootEdit = VTToEdit(ptFoot);
-void CFX_Edit::ScrollToCaret()
-{
- SetScrollLimit();
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- if (m_pVT->IsValid())
- {
- CPDF_Point ptHead(0,0);
- CPDF_Point ptFoot(0,0);
+ if (!FX_EDIT_IsFloatEqual(rcPlate.left, rcPlate.right)) {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
+ FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left)) {
+ SetScrollPosX(ptHead.x);
+ } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right)) {
+ SetScrollPosX(ptHead.x - rcPlate.Width());
+ }
+ }
+
+ if (!FX_EDIT_IsFloatEqual(rcPlate.top, rcPlate.bottom)) {
+ if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
+ FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom)) {
+ if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top)) {
+ SetScrollPosY(ptFoot.y + rcPlate.Height());
+ }
+ } else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top)) {
+ if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom)) {
+ SetScrollPosY(ptHead.y);
+ }
+ }
+ }
+ }
+}
+
+void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan,
+ const CPVT_WordRange* pRange1,
+ const CPVT_WordRange* pRange2) {
+ if (m_bEnableRefresh && m_pVT->IsValid()) {
+ m_Refresh.BeginRefresh();
+ RefreshPushLineRects(GetVisibleWordRange());
+
+ // if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x) ||
+ // !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollPos.y))
+ // {
+ m_Refresh.NoAnalyse();
+ m_ptRefreshScrollPos = m_ptScrollPos;
+ // }
+ // else
+ // {
+ // switch (ePlan)
+ // {
+ // case RP_ANALYSE:
+ // m_Refresh.Analyse(m_pVT->GetAlignment());
+ //
+ // if (pRange1) RefreshPushRandomRects(*pRange1);
+ // if (pRange2) RefreshPushRandomRects(*pRange2);
+ // break;
+ // case RP_NOANALYSE:
+ // m_Refresh.NoAnalyse();
+ // break;
+ // case RP_OPTIONAL:
+ // if (pRange1) RefreshPushRandomRects(*pRange1);
+ // if (pRange2) RefreshPushRandomRects(*pRange2);
+ // break;
+ // }
+ // }
+
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ if (const CFX_Edit_RectArray* pRects = m_Refresh.GetRefreshRects()) {
+ for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
+ m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
+ }
+ m_bNotifyFlag = FALSE;
+ }
+ }
+
+ m_Refresh.EndRefresh();
+ }
+}
+
+void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange& wr) {
+ if (m_pVT->IsValid()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordPlace wpBegin = wr.BeginPos;
+ m_pVT->UpdateWordPlace(wpBegin);
+ CPVT_WordPlace wpEnd = wr.EndPos;
+ m_pVT->UpdateWordPlace(wpEnd);
+ pIterator->SetAt(wpBegin);
+
+ CPVT_Line lineinfo;
+ do {
+ if (!pIterator->GetLine(lineinfo))
+ break;
+ if (lineinfo.lineplace.LineCmp(wpEnd) > 0)
+ break;
+
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace, lineinfo.lineEnd),
+ VTToEdit(rcLine));
+
+ } while (pIterator->NextLine());
+ }
+ }
+}
+
+void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange& wr) {
+ if (m_pVT->IsValid()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordRange wrTemp = wr;
+
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
+
+ while (pIterator->NextWord()) {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
+
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
+
+ if (place.LineCmp(wrTemp.BeginPos) == 0 ||
+ place.LineCmp(wrTemp.EndPos) == 0) {
+ CPDF_Rect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.AddRefresh(VTToEdit(rcWord));
+ } else {
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
+
+ m_Refresh.AddRefresh(VTToEdit(rcLine));
+
+ pIterator->NextLine();
+ }
+ }
+ }
+ }
+}
+
+void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordRange wrTemp = wr;
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
+ m_pVT->UpdateWordPlace(wrTemp.BeginPos);
+ m_pVT->UpdateWordPlace(wrTemp.EndPos);
+ pIterator->SetAt(wrTemp.BeginPos);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- }
- else if (pIterator->GetLine(line))
- {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
+ CPVT_Word wordinfo;
+ CPVT_Line lineinfo;
+ CPVT_WordPlace place;
- CPDF_Point ptHeadEdit = VTToEdit(ptHead);
- CPDF_Point ptFootEdit = VTToEdit(ptFoot);
+ while (pIterator->NextWord()) {
+ place = pIterator->GetAt();
+ if (place.WordCmp(wrTemp.EndPos) > 0)
+ break;
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ pIterator->GetWord(wordinfo);
+ pIterator->GetLine(lineinfo);
- if (!FX_EDIT_IsFloatEqual(rcPlate.left,rcPlate.right))
- {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.x, rcPlate.left) ||
- FX_EDIT_IsFloatEqual(ptHeadEdit.x, rcPlate.left))
- {
- SetScrollPosX(ptHead.x);
- }
- else if (FX_EDIT_IsFloatBigger(ptHeadEdit.x, rcPlate.right))
- {
- SetScrollPosX(ptHead.x - rcPlate.Width());
- }
- }
+ if (place.LineCmp(wrTemp.BeginPos) == 0 ||
+ place.LineCmp(wrTemp.EndPos) == 0) {
+ CPDF_Rect rcWord(wordinfo.ptWord.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ wordinfo.ptWord.x + wordinfo.fWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
- if (!FX_EDIT_IsFloatEqual(rcPlate.top,rcPlate.bottom))
- {
- if (FX_EDIT_IsFloatSmaller(ptFootEdit.y, rcPlate.bottom) ||
- FX_EDIT_IsFloatEqual(ptFootEdit.y, rcPlate.bottom))
- {
- if (FX_EDIT_IsFloatSmaller(ptHeadEdit.y, rcPlate.top))
- {
- SetScrollPosY(ptFoot.y + rcPlate.Height());
- }
- }
- else if (FX_EDIT_IsFloatBigger(ptHeadEdit.y, rcPlate.top))
- {
- if (FX_EDIT_IsFloatBigger(ptFootEdit.y, rcPlate.bottom))
- {
- SetScrollPosY(ptHead.y);
- }
- }
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = VTToEdit(rcWord);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
}
- }
-}
+ } else {
+ CPDF_Rect rcLine(lineinfo.ptLine.x,
+ lineinfo.ptLine.y + lineinfo.fLineDescent,
+ lineinfo.ptLine.x + lineinfo.fLineWidth,
+ lineinfo.ptLine.y + lineinfo.fLineAscent);
-void CFX_Edit::Refresh(REFRESH_PLAN_E ePlan,const CPVT_WordRange * pRange1,const CPVT_WordRange * pRange2)
-{
- if (m_bEnableRefresh && m_pVT->IsValid())
- {
- m_Refresh.BeginRefresh();
- RefreshPushLineRects(GetVisibleWordRange());
-
-// if (!FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.x,m_ptScrollPos.x) ||
-// !FX_EDIT_IsFloatEqual(m_ptRefreshScrollPos.y,m_ptScrollPos.y))
-// {
- m_Refresh.NoAnalyse();
- m_ptRefreshScrollPos = m_ptScrollPos;
-// }
-// else
-// {
-// switch (ePlan)
-// {
-// case RP_ANALYSE:
-// m_Refresh.Analyse(m_pVT->GetAlignment());
-//
-// if (pRange1) RefreshPushRandomRects(*pRange1);
-// if (pRange2) RefreshPushRandomRects(*pRange2);
-// break;
-// case RP_NOANALYSE:
-// m_Refresh.NoAnalyse();
-// break;
-// case RP_OPTIONAL:
-// if (pRange1) RefreshPushRandomRects(*pRange1);
-// if (pRange2) RefreshPushRandomRects(*pRange2);
-// break;
-// }
-// }
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- if (const CFX_Edit_RectArray * pRects = m_Refresh.GetRefreshRects())
- {
- for (int32_t i = 0, sz = pRects->GetSize(); i < sz; i++)
- m_pNotify->IOnInvalidateRect(pRects->GetAt(i));
- }
- m_bNotifyFlag = FALSE;
- }
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = VTToEdit(rcLine);
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
}
- m_Refresh.EndRefresh();
+ pIterator->NextLine();
+ }
}
+ }
}
-void CFX_Edit::RefreshPushLineRects(const CPVT_WordRange & wr)
-{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpBegin = wr.BeginPos;
- m_pVT->UpdateWordPlace(wpBegin);
- CPVT_WordPlace wpEnd = wr.EndPos;
- m_pVT->UpdateWordPlace(wpEnd);
- pIterator->SetAt(wpBegin);
-
- CPVT_Line lineinfo;
- do
- {
- if (!pIterator->GetLine(lineinfo))break;
- if (lineinfo.lineplace.LineCmp(wpEnd) > 0)break;
-
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- m_Refresh.Push(CPVT_WordRange(lineinfo.lineplace,lineinfo.lineEnd),VTToEdit(rcLine));
-
- }while (pIterator->NextLine());
- }
- }
+void CFX_Edit::SetCaret(const CPVT_WordPlace& place) {
+ m_wpOldCaret = m_wpCaret;
+ m_wpCaret = place;
}
-void CFX_Edit::RefreshPushRandomRects(const CPVT_WordRange & wr)
-{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = wr;
+void CFX_Edit::SetCaretInfo() {
+ if (m_bNotify && m_pNotify) {
+ if (!m_bNotifyFlag) {
+ CPDF_Point ptHead(0.0f, 0.0f), ptFoot(0.0f, 0.0f);
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ ptHead.x = word.ptWord.x + word.fWidth;
+ ptHead.y = word.ptWord.y + word.fAscent;
+ ptFoot.x = word.ptWord.x + word.fWidth;
+ ptFoot.y = word.ptWord.y + word.fDescent;
+ } else if (pIterator->GetLine(line)) {
+ ptHead.x = line.ptLine.x;
+ ptHead.y = line.ptLine.y + line.fLineAscent;
+ ptFoot.x = line.ptLine.x;
+ ptFoot.y = line.ptLine.y + line.fLineDescent;
+ }
+ }
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetCaret(!m_SelState.IsExist(), VTToEdit(ptHead),
+ VTToEdit(ptFoot), m_wpCaret);
+ m_bNotifyFlag = FALSE;
+ }
+ }
- while (pIterator->NextWord())
- {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
+ SetCaretChange();
+}
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
+void CFX_Edit::SetCaretChange() {
+ if (m_wpCaret == m_wpOldCaret)
+ return;
- if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
- {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ if (m_bNotify && m_pVT->IsRichText() && m_pNotify) {
+ CPVT_SecProps SecProps;
+ CPVT_WordProps WordProps;
- m_Refresh.AddRefresh(VTToEdit(rcWord));
- }
- else
- {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Section section;
- m_Refresh.AddRefresh(VTToEdit(rcLine));
+ if (pIterator->GetSection(section)) {
+ SecProps = section.SecProps;
+ WordProps = section.WordProps;
+ }
- pIterator->NextLine();
- }
- }
- }
+ if (pIterator->GetWord(word)) {
+ WordProps = word.WordProps;
+ }
}
-}
-
-void CFX_Edit::RefreshWordRange(const CPVT_WordRange& wr)
-{
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- CPVT_WordRange wrTemp = wr;
-
- m_pVT->UpdateWordPlace(wrTemp.BeginPos);
- m_pVT->UpdateWordPlace(wrTemp.EndPos);
- pIterator->SetAt(wrTemp.BeginPos);
-
- CPVT_Word wordinfo;
- CPVT_Line lineinfo;
- CPVT_WordPlace place;
-
- while (pIterator->NextWord())
- {
- place = pIterator->GetAt();
- if (place.WordCmp(wrTemp.EndPos) > 0) break;
-
- pIterator->GetWord(wordinfo);
- pIterator->GetLine(lineinfo);
-
- if (place.LineCmp(wrTemp.BeginPos) == 0 || place.LineCmp(wrTemp.EndPos) == 0)
- {
- CPDF_Rect rcWord(wordinfo.ptWord.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- wordinfo.ptWord.x + wordinfo.fWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcWord);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- }
- else
- {
- CPDF_Rect rcLine(lineinfo.ptLine.x,
- lineinfo.ptLine.y + lineinfo.fLineDescent,
- lineinfo.ptLine.x + lineinfo.fLineWidth,
- lineinfo.ptLine.y + lineinfo.fLineAscent);
-
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = VTToEdit(rcLine);
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- pIterator->NextLine();
- }
- }
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnCaretChange(SecProps, WordProps);
+ m_bNotifyFlag = FALSE;
}
+ }
}
-void CFX_Edit::SetCaret(const CPVT_WordPlace & place)
-{
- m_wpOldCaret = m_wpCaret;
- m_wpCaret = place;
-}
-
-void CFX_Edit::SetCaretInfo()
-{
- if (m_bNotify && m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- CPDF_Point ptHead(0.0f,0.0f),ptFoot(0.0f,0.0f);
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- ptHead.x = word.ptWord.x + word.fWidth;
- ptHead.y = word.ptWord.y + word.fAscent;
- ptFoot.x = word.ptWord.x + word.fWidth;
- ptFoot.y = word.ptWord.y + word.fDescent;
- }
- else if (pIterator->GetLine(line))
- {
- ptHead.x = line.ptLine.x;
- ptHead.y = line.ptLine.y + line.fLineAscent;
- ptFoot.x = line.ptLine.x;
- ptFoot.y = line.ptLine.y + line.fLineDescent;
- }
- }
-
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetCaret(!m_SelState.IsExist(),VTToEdit(ptHead),VTToEdit(ptFoot), m_wpCaret);
- m_bNotifyFlag = FALSE;
- }
- }
+void CFX_Edit::SetCaret(int32_t nPos) {
+ if (m_pVT->IsValid()) {
+ SelectNone();
+ SetCaret(m_pVT->WordIndexToWordPlace(nPos));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- SetCaretChange();
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
-void CFX_Edit::SetCaretChange()
-{
- if (m_wpCaret == m_wpOldCaret) return;
+void CFX_Edit::OnMouseDown(const CPDF_Point& point,
+ FX_BOOL bShift,
+ FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ SelectNone();
+ SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (m_bNotify && m_pVT->IsRichText() && m_pNotify)
- {
- CPVT_SecProps SecProps;
- CPVT_WordProps WordProps;
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Section section;
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+}
- if (pIterator->GetSection(section))
- {
- SecProps = section.SecProps;
- WordProps = section.WordProps;
- }
+void CFX_Edit::OnMouseMove(const CPDF_Point& point,
+ FX_BOOL bShift,
+ FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
- if (pIterator->GetWord(word))
- {
- WordProps = word.WordProps;
- }
- }
+ if (m_wpCaret != m_wpOldCaret) {
+ m_SelState.SetEndPos(m_wpCaret);
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnCaretChange(SecProps,WordProps);
- m_bNotifyFlag = FALSE;
- }
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretOrigin();
+ SetCaretInfo();
}
+ }
}
-void CFX_Edit::SetCaret(int32_t nPos)
-{
- if (m_pVT->IsValid())
- {
- SelectNone();
- SetCaret(m_pVT->WordIndexToWordPlace(nPos));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+void CFX_Edit::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ SetCaret(m_pVT->GetUpWordPlace(m_wpCaret, m_ptCaret));
+ if (bShift) {
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret) {
ScrollToCaret();
- SetCaretOrigin();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
SetCaretInfo();
+ }
+ } else {
+ SelectNone();
+
+ ScrollToCaret();
+ SetCaretInfo();
}
+ }
}
-void CFX_Edit::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- SelectNone();
- SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+void CFX_Edit::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ SetCaret(m_pVT->GetDownWordPlace(m_wpCaret, m_ptCaret));
+ if (bShift) {
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ if (m_wpOldCaret != m_wpCaret) {
ScrollToCaret();
- SetCaretOrigin();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
SetCaretInfo();
+ }
+ } else {
+ SelectNone();
+
+ ScrollToCaret();
+ SetCaretInfo();
}
+ }
}
-void CFX_Edit::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->SearchWordPlace(EditToVT(point)));
+void CFX_Edit::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ if (bShift) {
+ if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
- if (m_wpCaret != m_wpOldCaret)
- {
- m_SelState.SetEndPos(m_wpCaret);
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
-}
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
-void CFX_Edit::OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->GetUpWordPlace(m_wpCaret,m_ptCaret));
-
- if (bShift)
- {
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- }
+ if (m_wpOldCaret != m_wpCaret) {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ } else {
+ if (m_SelState.IsExist()) {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0)
+ SetCaret(m_SelState.BeginPos);
else
- {
- SelectNone();
+ SetCaret(m_SelState.EndPos);
- ScrollToCaret();
- SetCaretInfo();
- }
- }
-}
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ } else {
+ if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-void CFX_Edit::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- SetCaret(m_pVT->GetDownWordPlace(m_wpCaret,m_ptCaret));
-
- if (bShift)
- {
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
- }
- else
- {
- SelectNone();
+ SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
- ScrollToCaret();
- SetCaretInfo();
- }
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
+ }
}
-void CFX_Edit::OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret, m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- }
- else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (m_wpCaret == m_pVT->GetLineBeginPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionBeginPlace(m_wpCaret))
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ if (bShift) {
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
- SetCaret(m_pVT->GetPrevWordPlace(m_wpCaret));
+ if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
-}
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
-void CFX_Edit::OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- if (m_wpOldCaret != m_wpCaret)
- {
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret,m_wpCaret);
- Refresh(RP_OPTIONAL,&wr);
- SetCaretInfo();
- }
- }
+ if (m_wpOldCaret != m_wpCaret) {
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ }
+ } else {
+ if (m_SelState.IsExist()) {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0)
+ SetCaret(m_SelState.BeginPos);
else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+ SetCaret(m_SelState.EndPos);
- if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
- m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
- SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ } else {
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
+ if (m_wpCaret == m_pVT->GetLineEndPlace(m_wpCaret) &&
+ m_wpCaret != m_pVT->GetSectionEndPlace(m_wpCaret))
+ SetCaret(m_pVT->GetNextWordPlace(m_wpCaret));
+
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
+ }
}
-void CFX_Edit::OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (bCtrl)
- SetCaret(m_pVT->GetBeginWordPlace());
- else
- SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret,m_wpCaret);
-
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
+void CFX_Edit::OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ if (bShift) {
+ if (bCtrl)
+ SetCaret(m_pVT->GetBeginWordPlace());
+ else
+ SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ } else {
+ if (m_SelState.IsExist()) {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) < 0)
+ SetCaret(m_SelState.BeginPos);
else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)<0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (bCtrl)
- SetCaret(m_pVT->GetBeginWordPlace());
- else
- SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
-}
+ SetCaret(m_SelState.EndPos);
-void CFX_Edit::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (m_pVT->IsValid())
- {
- if (bShift)
- {
- if (bCtrl)
- SetCaret(m_pVT->GetEndWordPlace());
- else
- SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
-
- if (m_SelState.IsExist())
- m_SelState.SetEndPos(m_wpCaret);
- else
- m_SelState.Set(m_wpOldCaret, m_wpCaret);
-
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
- Refresh(RP_OPTIONAL, &wr);
- SetCaretInfo();
- }
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ } else {
+ if (bCtrl)
+ SetCaret(m_pVT->GetBeginWordPlace());
else
- {
- if (m_SelState.IsExist())
- {
- if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos)>0)
- SetCaret(m_SelState.BeginPos);
- else
- SetCaret(m_SelState.EndPos);
-
- SelectNone();
- ScrollToCaret();
- SetCaretInfo();
- }
- else
- {
- if (bCtrl)
- SetCaret(m_pVT->GetEndWordPlace());
- else
- SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
-
- ScrollToCaret();
- SetCaretOrigin();
- SetCaretInfo();
- }
- }
- }
-}
+ SetCaret(m_pVT->GetLineBeginPlace(m_wpCaret));
-void CFX_Edit::SetText(const FX_WCHAR* text,int32_t charset,
- const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- Empty();
- DoInsertText(CPVT_WordPlace(0,0,-1), text, charset, pSecProps, pWordProps);
- if (bPaint) Paint();
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret);
- //if (bAddUndo)
-}
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
+}
+
+void CFX_Edit::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (m_pVT->IsValid()) {
+ if (bShift) {
+ if (bCtrl)
+ SetCaret(m_pVT->GetEndWordPlace());
+ else
+ SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
+
+ if (m_SelState.IsExist())
+ m_SelState.SetEndPos(m_wpCaret);
+ else
+ m_SelState.Set(m_wpOldCaret, m_wpCaret);
+
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, m_wpCaret);
+ Refresh(RP_OPTIONAL, &wr);
+ SetCaretInfo();
+ } else {
+ if (m_SelState.IsExist()) {
+ if (m_SelState.BeginPos.WordCmp(m_SelState.EndPos) > 0)
+ SetCaret(m_SelState.BeginPos);
+ else
+ SetCaret(m_SelState.EndPos);
+
+ SelectNone();
+ ScrollToCaret();
+ SetCaretInfo();
+ } else {
+ if (bCtrl)
+ SetCaret(m_pVT->GetEndWordPlace());
+ else
+ SetCaret(m_pVT->GetLineEndPlace(m_wpCaret));
-FX_BOOL CFX_Edit::InsertWord(FX_WORD word, int32_t charset, const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (IsTextOverflow()) return FALSE;
+ ScrollToCaret();
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
+ }
+ }
+}
+
+void CFX_Edit::SetText(const FX_WCHAR* text,
+ int32_t charset,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps,
+ FX_BOOL bAddUndo,
+ FX_BOOL bPaint) {
+ Empty();
+ DoInsertText(CPVT_WordPlace(0, 0, -1), text, charset, pSecProps, pWordProps);
+ if (bPaint)
+ Paint();
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnSetText(m_wpCaret, m_wpOldCaret);
+ // if (bAddUndo)
+}
+
+FX_BOOL CFX_Edit::InsertWord(FX_WORD word,
+ int32_t charset,
+ const CPVT_WordProps* pWordProps,
+ FX_BOOL bAddUndo,
+ FX_BOOL bPaint) {
+ if (IsTextOverflow())
+ return FALSE;
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
+ if (m_pVT->IsValid()) {
+ m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->InsertWord(m_wpCaret,word,GetCharSetFromUnicode(word, charset),pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ SetCaret(m_pVT->InsertWord(
+ m_wpCaret, word, GetCharSetFromUnicode(word, charset), pWordProps));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertWord(this,m_wpOldCaret,m_wpCaret,word,charset,pWordProps));
- }
+ if (m_wpCaret != m_wpOldCaret) {
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_InsertWord(this, m_wpOldCaret, m_wpCaret,
+ word, charset, pWordProps));
+ }
- if (bPaint)
- PaintInsertText(m_wpOldCaret, m_wpCaret);
+ if (bPaint)
+ PaintInsertText(m_wpOldCaret, m_wpCaret);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertWord(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps * pSecProps,const CPVT_WordProps * pWordProps,
- FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (IsTextOverflow()) return FALSE;
+FX_BOOL CFX_Edit::InsertReturn(const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps,
+ FX_BOOL bAddUndo,
+ FX_BOOL bPaint) {
+ if (IsTextOverflow())
+ return FALSE;
- if (m_pVT->IsValid())
- {
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->InsertSection(m_wpCaret,pSecProps,pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ if (m_pVT->IsValid()) {
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(m_pVT->InsertSection(m_wpCaret, pSecProps, pWordProps));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertReturn(this,m_wpOldCaret,m_wpCaret,pSecProps,pWordProps));
- }
+ if (m_wpCaret != m_wpOldCaret) {
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_InsertReturn(this, m_wpOldCaret, m_wpCaret,
+ pSecProps, pWordProps));
+ }
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret));
- ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
- Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ if (bPaint) {
+ RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret));
+ ScrollToCaret();
+ CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
+ Refresh(RP_ANALYSE, &wr);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertReturn(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (m_pVT->IsValid())
- {
- if (m_wpCaret == m_pVT->GetBeginWordPlace()) return FALSE;
+FX_BOOL CFX_Edit::Backspace(FX_BOOL bAddUndo, FX_BOOL bPaint) {
+ if (m_pVT->IsValid()) {
+ if (m_wpCaret == m_pVT->GetBeginWordPlace())
+ return FALSE;
- CPVT_Section section;
- CPVT_Word word;
+ CPVT_Section section;
+ CPVT_Word word;
- if (bAddUndo)
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
- }
+ if (bAddUndo) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_wpCaret);
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
+ }
+ }
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(m_pVT->BackSpaceWord(m_wpCaret));
- m_SelState.Set(m_wpCaret,m_wpCaret);
-
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
- AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,section.WordProps));
- else
- AddEditUndoItem(new CFXEU_Backspace(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,word.WordProps));
- }
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(m_pVT->BackSpaceWord(m_wpCaret));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
+
+ if (m_wpCaret != m_wpOldCaret) {
+ if (bAddUndo && m_bEnableUndo) {
+ if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
+ AddEditUndoItem(new CFXEU_Backspace(
+ this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset,
+ section.SecProps, section.WordProps));
+ else
+ AddEditUndoItem(new CFXEU_Backspace(
+ this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset,
+ section.SecProps, word.WordProps));
+ }
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpCaret,m_wpOldCaret));
- ScrollToCaret();
+ if (bPaint) {
+ RearrangePart(CPVT_WordRange(m_wpCaret, m_wpOldCaret));
+ ScrollToCaret();
- CPVT_WordRange wr;
- if (m_wpCaret.SecCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),GetVisibleWordRange().EndPos);
- else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
- else
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+ CPVT_WordRange wr;
+ if (m_wpCaret.SecCmp(m_wpOldCaret) != 0)
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),
+ GetVisibleWordRange().EndPos);
+ else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),
+ m_pVT->GetSectionEndPlace(m_wpCaret));
+ else
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpCaret),
+ m_pVT->GetSectionEndPlace(m_wpCaret));
- Refresh(RP_ANALYSE, &wr);
+ Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnBackSpace(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (m_pVT->IsValid())
- {
- if (m_wpCaret == m_pVT->GetEndWordPlace()) return FALSE;
+FX_BOOL CFX_Edit::Delete(FX_BOOL bAddUndo, FX_BOOL bPaint) {
+ if (m_pVT->IsValid()) {
+ if (m_wpCaret == m_pVT->GetEndWordPlace())
+ return FALSE;
- CPVT_Section section;
- CPVT_Word word;
+ CPVT_Section section;
+ CPVT_Word word;
- if (bAddUndo)
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
- pIterator->GetSection(section);
- pIterator->GetWord(word);
- }
- }
+ if (bAddUndo) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_pVT->GetNextWordPlace(m_wpCaret));
+ pIterator->GetSection(section);
+ pIterator->GetWord(word);
+ }
+ }
- m_pVT->UpdateWordPlace(m_wpCaret);
- FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCaret));
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ FX_BOOL bSecEnd = (m_wpCaret == m_pVT->GetSectionEndPlace(m_wpCaret));
- SetCaret(m_pVT->DeleteWord(m_wpCaret));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ SetCaret(m_pVT->DeleteWord(m_wpCaret));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (bAddUndo && m_bEnableUndo)
- {
- if (bSecEnd)
- AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,section.WordProps,bSecEnd));
- else
- AddEditUndoItem(new CFXEU_Delete(this,m_wpOldCaret,m_wpCaret,word.Word,word.nCharset,
- section.SecProps,word.WordProps,bSecEnd));
- }
+ if (bAddUndo && m_bEnableUndo) {
+ if (bSecEnd)
+ AddEditUndoItem(new CFXEU_Delete(
+ this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset,
+ section.SecProps, section.WordProps, bSecEnd));
+ else
+ AddEditUndoItem(new CFXEU_Delete(
+ this, m_wpOldCaret, m_wpCaret, word.Word, word.nCharset,
+ section.SecProps, word.WordProps, bSecEnd));
+ }
- if (bPaint)
- {
- RearrangePart(CPVT_WordRange(m_wpOldCaret,m_wpCaret));
- ScrollToCaret();
+ if (bPaint) {
+ RearrangePart(CPVT_WordRange(m_wpOldCaret, m_wpCaret));
+ ScrollToCaret();
- CPVT_WordRange wr;
- if (bSecEnd)
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),GetVisibleWordRange().EndPos);
- else if (m_wpCaret.LineCmp(m_wpOldCaret) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
- else
- wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),m_pVT->GetSectionEndPlace(m_wpCaret));
+ CPVT_WordRange wr;
+ if (bSecEnd)
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),
+ GetVisibleWordRange().EndPos);
+ else if (m_wpCaret.LineCmp(m_wpOldCaret) != 0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(m_wpCaret),
+ m_pVT->GetSectionEndPlace(m_wpCaret));
+ else
+ wr = CPVT_WordRange(m_pVT->GetPrevWordPlace(m_wpOldCaret),
+ m_pVT->GetSectionEndPlace(m_wpCaret));
- Refresh(RP_ANALYSE, &wr);
+ Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnDelete(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Empty()
-{
- if (m_pVT->IsValid())
- {
- m_pVT->DeleteWords(GetWholeWordRange());
- SetCaret(m_pVT->GetBeginWordPlace());
+FX_BOOL CFX_Edit::Empty() {
+ if (m_pVT->IsValid()) {
+ m_pVT->DeleteWords(GetWholeWordRange());
+ SetCaret(m_pVT->GetBeginWordPlace());
- return TRUE;
- }
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (m_pVT->IsValid())
- {
- if (m_SelState.IsExist())
- {
- CPVT_WordRange range = m_SelState.ConvertToWordRange();
-
- if (bAddUndo && m_bEnableUndo)
- {
- if (m_pVT->IsRichText())
- {
- BeginGroupUndo(L"");
-
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(range.EndPos);
-
- CPVT_Word wordinfo;
- CPVT_Section secinfo;
- do
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (place.WordCmp(range.BeginPos) <= 0)break;
-
- CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
-
- if (oldplace.SecCmp(place) != 0)
- {
- if (pIterator->GetSection(secinfo))
- {
- AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
- wordinfo.nCharset,secinfo.SecProps,secinfo.WordProps));
- }
- }
- else
- {
- if (pIterator->GetWord(wordinfo))
- {
- oldplace = m_pVT->AjustLineHeader(oldplace,TRUE);
- place = m_pVT->AjustLineHeader(place,TRUE);
-
- AddEditUndoItem(new CFXEU_ClearRich(this,oldplace,place,range,wordinfo.Word,
- wordinfo.nCharset,secinfo.SecProps,wordinfo.WordProps));
- }
- }
- }while (pIterator->PrevWord());
- }
- EndGroupUndo();
+FX_BOOL CFX_Edit::Clear(FX_BOOL bAddUndo, FX_BOOL bPaint) {
+ if (m_pVT->IsValid()) {
+ if (m_SelState.IsExist()) {
+ CPVT_WordRange range = m_SelState.ConvertToWordRange();
+
+ if (bAddUndo && m_bEnableUndo) {
+ if (m_pVT->IsRichText()) {
+ BeginGroupUndo(L"");
+
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(range.EndPos);
+
+ CPVT_Word wordinfo;
+ CPVT_Section secinfo;
+ do {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (place.WordCmp(range.BeginPos) <= 0)
+ break;
+
+ CPVT_WordPlace oldplace = m_pVT->GetPrevWordPlace(place);
+
+ if (oldplace.SecCmp(place) != 0) {
+ if (pIterator->GetSection(secinfo)) {
+ AddEditUndoItem(new CFXEU_ClearRich(
+ this, oldplace, place, range, wordinfo.Word,
+ wordinfo.nCharset, secinfo.SecProps, secinfo.WordProps));
}
- else
- {
- AddEditUndoItem(new CFXEU_Clear(this,range,GetSelText()));
+ } else {
+ if (pIterator->GetWord(wordinfo)) {
+ oldplace = m_pVT->AjustLineHeader(oldplace, TRUE);
+ place = m_pVT->AjustLineHeader(place, TRUE);
+
+ AddEditUndoItem(new CFXEU_ClearRich(
+ this, oldplace, place, range, wordinfo.Word,
+ wordinfo.nCharset, secinfo.SecProps, wordinfo.WordProps));
}
- }
+ }
+ } while (pIterator->PrevWord());
+ }
+ EndGroupUndo();
+ } else {
+ AddEditUndoItem(new CFXEU_Clear(this, range, GetSelText()));
+ }
+ }
- SelectNone();
- SetCaret(m_pVT->DeleteWords(range));
- m_SelState.Set(m_wpCaret,m_wpCaret);
+ SelectNone();
+ SetCaret(m_pVT->DeleteWords(range));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (bPaint)
- {
- RearrangePart(range);
- ScrollToCaret();
+ if (bPaint) {
+ RearrangePart(range);
+ ScrollToCaret();
- CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
- Refresh(RP_ANALYSE, &wr);
+ CPVT_WordRange wr(m_wpOldCaret, GetVisibleWordRange().EndPos);
+ Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnClear(m_wpCaret, m_wpOldCaret);
- return TRUE;
- }
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps, FX_BOOL bAddUndo, FX_BOOL bPaint)
-{
- if (IsTextOverflow()) return FALSE;
+FX_BOOL CFX_Edit::InsertText(const FX_WCHAR* text,
+ int32_t charset,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps,
+ FX_BOOL bAddUndo,
+ FX_BOOL bPaint) {
+ if (IsTextOverflow())
+ return FALSE;
- m_pVT->UpdateWordPlace(m_wpCaret);
- SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps));
- m_SelState.Set(m_wpCaret,m_wpCaret);
-
- if (m_wpCaret != m_wpOldCaret)
- {
- if (bAddUndo && m_bEnableUndo)
- {
- AddEditUndoItem(new CFXEU_InsertText(this,m_wpOldCaret,m_wpCaret,text,charset,pSecProps,pWordProps));
- }
+ m_pVT->UpdateWordPlace(m_wpCaret);
+ SetCaret(DoInsertText(m_wpCaret, text, charset, pSecProps, pWordProps));
+ m_SelState.Set(m_wpCaret, m_wpCaret);
- if (bPaint)
- PaintInsertText(m_wpOldCaret, m_wpCaret);
+ if (m_wpCaret != m_wpOldCaret) {
+ if (bAddUndo && m_bEnableUndo) {
+ AddEditUndoItem(new CFXEU_InsertText(this, m_wpOldCaret, m_wpCaret, text,
+ charset, pSecProps, pWordProps));
+ }
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
+ if (bPaint)
+ PaintInsertText(m_wpOldCaret, m_wpCaret);
- return TRUE;
- }
- return FALSE;
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnInsertText(m_wpCaret, m_wpOldCaret);
+
+ return TRUE;
+ }
+ return FALSE;
}
-void CFX_Edit::PaintInsertText(const CPVT_WordPlace & wpOld, const CPVT_WordPlace & wpNew)
-{
- if (m_pVT->IsValid())
- {
- RearrangePart(CPVT_WordRange(wpOld,wpNew));
- ScrollToCaret();
+void CFX_Edit::PaintInsertText(const CPVT_WordPlace& wpOld,
+ const CPVT_WordPlace& wpNew) {
+ if (m_pVT->IsValid()) {
+ RearrangePart(CPVT_WordRange(wpOld, wpNew));
+ ScrollToCaret();
- CPVT_WordRange wr;
- if (m_wpCaret.LineCmp(wpOld) !=0)
- wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld),m_pVT->GetSectionEndPlace(wpNew));
- else
- wr = CPVT_WordRange(wpOld,m_pVT->GetSectionEndPlace(wpNew));
- Refresh(RP_ANALYSE, &wr);
- SetCaretOrigin();
- SetCaretInfo();
- }
+ CPVT_WordRange wr;
+ if (m_wpCaret.LineCmp(wpOld) != 0)
+ wr = CPVT_WordRange(m_pVT->GetLineBeginPlace(wpOld),
+ m_pVT->GetSectionEndPlace(wpNew));
+ else
+ wr = CPVT_WordRange(wpOld, m_pVT->GetSectionEndPlace(wpNew));
+ Refresh(RP_ANALYSE, &wr);
+ SetCaretOrigin();
+ SetCaretInfo();
+ }
}
-FX_BOOL CFX_Edit::Redo()
-{
- if (m_bEnableUndo)
- {
- if (m_Undo.CanRedo())
- {
- m_Undo.Redo();
- return TRUE;
- }
+FX_BOOL CFX_Edit::Redo() {
+ if (m_bEnableUndo) {
+ if (m_Undo.CanRedo()) {
+ m_Undo.Redo();
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::Undo()
-{
- if (m_bEnableUndo)
- {
- if (m_Undo.CanUndo())
- {
- m_Undo.Undo();
- return TRUE;
- }
+FX_BOOL CFX_Edit::Undo() {
+ if (m_bEnableUndo) {
+ if (m_Undo.CanUndo()) {
+ m_Undo.Undo();
+ return TRUE;
}
+ }
- return FALSE;
+ return FALSE;
}
-void CFX_Edit::SetCaretOrigin()
-{
- if (m_pVT->IsValid())
- {
- if (IPDF_VariableText_Iterator * pIterator = m_pVT->GetIterator())
- {
- pIterator->SetAt(m_wpCaret);
- CPVT_Word word;
- CPVT_Line line;
- if (pIterator->GetWord(word))
- {
- m_ptCaret.x = word.ptWord.x + word.fWidth;
- m_ptCaret.y = word.ptWord.y;
- }
- else if (pIterator->GetLine(line))
- {
- m_ptCaret.x = line.ptLine.x;
- m_ptCaret.y = line.ptLine.y;
- }
- }
+void CFX_Edit::SetCaretOrigin() {
+ if (m_pVT->IsValid()) {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ pIterator->SetAt(m_wpCaret);
+ CPVT_Word word;
+ CPVT_Line line;
+ if (pIterator->GetWord(word)) {
+ m_ptCaret.x = word.ptWord.x + word.fWidth;
+ m_ptCaret.y = word.ptWord.y;
+ } else if (pIterator->GetLine(line)) {
+ m_ptCaret.x = line.ptLine.x;
+ m_ptCaret.y = line.ptLine.y;
+ }
}
+ }
}
-int32_t CFX_Edit::WordPlaceToWordIndex(const CPVT_WordPlace & place) const
-{
- if (m_pVT->IsValid())
- return m_pVT->WordPlaceToWordIndex(place);
+int32_t CFX_Edit::WordPlaceToWordIndex(const CPVT_WordPlace& place) const {
+ if (m_pVT->IsValid())
+ return m_pVT->WordPlaceToWordIndex(place);
- return -1;
+ return -1;
}
-CPVT_WordPlace CFX_Edit::WordIndexToWordPlace(int32_t index) const
-{
- if (m_pVT->IsValid())
- return m_pVT->WordIndexToWordPlace(index);
+CPVT_WordPlace CFX_Edit::WordIndexToWordPlace(int32_t index) const {
+ if (m_pVT->IsValid())
+ return m_pVT->WordIndexToWordPlace(index);
- return CPVT_WordPlace();
+ return CPVT_WordPlace();
}
-FX_BOOL CFX_Edit::IsTextFull() const
-{
- int32_t nTotalWords = m_pVT->GetTotalWords();
- int32_t nLimitChar = m_pVT->GetLimitChar();
- int32_t nCharArray = m_pVT->GetCharArray();
+FX_BOOL CFX_Edit::IsTextFull() const {
+ int32_t nTotalWords = m_pVT->GetTotalWords();
+ int32_t nLimitChar = m_pVT->GetLimitChar();
+ int32_t nCharArray = m_pVT->GetCharArray();
- return IsTextOverflow() || (nLimitChar>0 && nTotalWords >= nLimitChar)
- || (nCharArray>0 && nTotalWords >= nCharArray);
+ return IsTextOverflow() || (nLimitChar > 0 && nTotalWords >= nLimitChar) ||
+ (nCharArray > 0 && nTotalWords >= nCharArray);
}
-FX_BOOL CFX_Edit::IsTextOverflow() const
-{
- if (!m_bEnableScroll && !m_bEnableOverflow)
- {
- CPDF_Rect rcPlate = m_pVT->GetPlateRect();
- CPDF_Rect rcContent = m_pVT->GetContentRect();
-
- if (m_pVT->IsMultiLine() && GetTotalLines() > 1)
- {
- if (FX_EDIT_IsFloatBigger(rcContent.Height(),rcPlate.Height())) return TRUE;
- }
+FX_BOOL CFX_Edit::IsTextOverflow() const {
+ if (!m_bEnableScroll && !m_bEnableOverflow) {
+ CPDF_Rect rcPlate = m_pVT->GetPlateRect();
+ CPDF_Rect rcContent = m_pVT->GetContentRect();
- if (FX_EDIT_IsFloatBigger(rcContent.Width(),rcPlate.Width())) return TRUE;
+ if (m_pVT->IsMultiLine() && GetTotalLines() > 1) {
+ if (FX_EDIT_IsFloatBigger(rcContent.Height(), rcPlate.Height()))
+ return TRUE;
}
- return FALSE;
+ if (FX_EDIT_IsFloatBigger(rcContent.Width(), rcPlate.Width()))
+ return TRUE;
+ }
+
+ return FALSE;
}
-CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace & place) const
-{
- return m_pVT->GetLineBeginPlace(place);
+CPVT_WordPlace CFX_Edit::GetLineBeginPlace(const CPVT_WordPlace& place) const {
+ return m_pVT->GetLineBeginPlace(place);
}
-CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace & place) const
-{
- return m_pVT->GetLineEndPlace(place);
+CPVT_WordPlace CFX_Edit::GetLineEndPlace(const CPVT_WordPlace& place) const {
+ return m_pVT->GetLineEndPlace(place);
}
-CPVT_WordPlace CFX_Edit::GetSectionBeginPlace(const CPVT_WordPlace & place) const
-{
- return m_pVT->GetSectionBeginPlace(place);
+CPVT_WordPlace CFX_Edit::GetSectionBeginPlace(
+ const CPVT_WordPlace& place) const {
+ return m_pVT->GetSectionBeginPlace(place);
}
-CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace & place) const
-{
- return m_pVT->GetSectionEndPlace(place);
+CPVT_WordPlace CFX_Edit::GetSectionEndPlace(const CPVT_WordPlace& place) const {
+ return m_pVT->GetSectionEndPlace(place);
}
-FX_BOOL CFX_Edit::CanUndo() const
-{
- if (m_bEnableUndo)
- {
- return m_Undo.CanUndo();
- }
+FX_BOOL CFX_Edit::CanUndo() const {
+ if (m_bEnableUndo) {
+ return m_Undo.CanUndo();
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::CanRedo() const
-{
- if (m_bEnableUndo)
- {
- return m_Undo.CanRedo();
- }
+FX_BOOL CFX_Edit::CanRedo() const {
+ if (m_bEnableUndo) {
+ return m_Undo.CanRedo();
+ }
- return FALSE;
+ return FALSE;
}
-FX_BOOL CFX_Edit::IsModified() const
-{
- if (m_bEnableUndo)
- {
- return m_Undo.IsModified();
- }
+FX_BOOL CFX_Edit::IsModified() const {
+ if (m_bEnableUndo) {
+ return m_Undo.IsModified();
+ }
- return FALSE;
+ return FALSE;
}
-void CFX_Edit::EnableRefresh(FX_BOOL bRefresh)
-{
- m_bEnableRefresh = bRefresh;
+void CFX_Edit::EnableRefresh(FX_BOOL bRefresh) {
+ m_bEnableRefresh = bRefresh;
}
-void CFX_Edit::EnableUndo(FX_BOOL bUndo)
-{
- m_bEnableUndo = bUndo;
+void CFX_Edit::EnableUndo(FX_BOOL bUndo) {
+ m_bEnableUndo = bUndo;
}
-void CFX_Edit::EnableNotify(FX_BOOL bNotify)
-{
- m_bNotify = bNotify;
+void CFX_Edit::EnableNotify(FX_BOOL bNotify) {
+ m_bNotify = bNotify;
}
-void CFX_Edit::EnableOprNotify(FX_BOOL bNotify)
-{
- m_bOprNotify = bNotify;
+void CFX_Edit::EnableOprNotify(FX_BOOL bNotify) {
+ m_bOprNotify = bNotify;
}
-FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const
-{
- if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+FX_FLOAT CFX_Edit::GetLineTop(const CPVT_WordPlace& place) const {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
+ pIterator->SetAt(wpOld);
- return line.ptLine.y + line.fLineAscent;
- }
+ return line.ptLine.y + line.fLineAscent;
+ }
- return 0.0f;
+ return 0.0f;
}
-FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const
-{
- if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator())
- {
- CPVT_WordPlace wpOld = pIterator->GetAt();
+FX_FLOAT CFX_Edit::GetLineBottom(const CPVT_WordPlace& place) const {
+ if (IPDF_VariableText_Iterator* pIterator = m_pVT->GetIterator()) {
+ CPVT_WordPlace wpOld = pIterator->GetAt();
- pIterator->SetAt(place);
- CPVT_Line line;
- pIterator->GetLine(line);
+ pIterator->SetAt(place);
+ CPVT_Line line;
+ pIterator->GetLine(line);
- pIterator->SetAt(wpOld);
+ pIterator->SetAt(wpOld);
- return line.ptLine.y + line.fLineDescent;
- }
+ return line.ptLine.y + line.fLineDescent;
+ }
- return 0.0f;
+ return 0.0f;
}
-CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place, const FX_WCHAR* text, int32_t charset,
- const CPVT_SecProps * pSecProps, const CPVT_WordProps * pWordProps)
-{
- CPVT_WordPlace wp = place;
+CPVT_WordPlace CFX_Edit::DoInsertText(const CPVT_WordPlace& place,
+ const FX_WCHAR* text,
+ int32_t charset,
+ const CPVT_SecProps* pSecProps,
+ const CPVT_WordProps* pWordProps) {
+ CPVT_WordPlace wp = place;
- if (m_pVT->IsValid())
- {
- CFX_WideString sText = text;
+ if (m_pVT->IsValid()) {
+ CFX_WideString sText = text;
- for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++)
- {
- FX_WORD word = sText[i];
- switch (word)
- {
- case 0x0D:
- wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
- if (sText[i+1] == 0x0A)
- i++;
- break;
- case 0x0A:
- wp = m_pVT->InsertSection(wp,pSecProps,pWordProps);
- if (sText[i+1] == 0x0D)
- i++;
- break;
- case 0x09:
- word = 0x20;
- default:
- wp = m_pVT->InsertWord(wp,word,GetCharSetFromUnicode(word, charset),pWordProps);
- break;
- }
- }
+ for (int32_t i = 0, sz = sText.GetLength(); i < sz; i++) {
+ FX_WORD word = sText[i];
+ switch (word) {
+ case 0x0D:
+ wp = m_pVT->InsertSection(wp, pSecProps, pWordProps);
+ if (sText[i + 1] == 0x0A)
+ i++;
+ break;
+ case 0x0A:
+ wp = m_pVT->InsertSection(wp, pSecProps, pWordProps);
+ if (sText[i + 1] == 0x0D)
+ i++;
+ break;
+ case 0x09:
+ word = 0x20;
+ default:
+ wp = m_pVT->InsertWord(wp, word, GetCharSetFromUnicode(word, charset),
+ pWordProps);
+ break;
+ }
}
+ }
- return wp;
+ return wp;
}
-int32_t CFX_Edit::GetCharSetFromUnicode(FX_WORD word, int32_t nOldCharset)
-{
- if (IFX_Edit_FontMap* pFontMap = GetFontMap())
- return pFontMap->CharSetFromUnicode(word, nOldCharset);
- return nOldCharset;
+int32_t CFX_Edit::GetCharSetFromUnicode(FX_WORD word, int32_t nOldCharset) {
+ if (IFX_Edit_FontMap* pFontMap = GetFontMap())
+ return pFontMap->CharSetFromUnicode(word, nOldCharset);
+ return nOldCharset;
}
-void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle)
-{
- ASSERT(m_pGroupUndoItem == NULL);
+void CFX_Edit::BeginGroupUndo(const CFX_WideString& sTitle) {
+ ASSERT(m_pGroupUndoItem == NULL);
- m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
+ m_pGroupUndoItem = new CFX_Edit_GroupUndoItem(sTitle);
}
-void CFX_Edit::EndGroupUndo()
-{
- ASSERT(m_pGroupUndoItem != NULL);
-
- m_pGroupUndoItem->UpdateItems();
- m_Undo.AddItem(m_pGroupUndoItem);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(m_pGroupUndoItem);
- m_pGroupUndoItem = NULL;
-}
+void CFX_Edit::EndGroupUndo() {
+ ASSERT(m_pGroupUndoItem != NULL);
-void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem)
-{
- if (m_pGroupUndoItem)
- m_pGroupUndoItem->AddUndoItem(pEditUndoItem);
- else
- {
- m_Undo.AddItem(pEditUndoItem);
- if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(pEditUndoItem);
- }
+ m_pGroupUndoItem->UpdateItems();
+ m_Undo.AddItem(m_pGroupUndoItem);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnAddUndo(m_pGroupUndoItem);
+ m_pGroupUndoItem = NULL;
}
-void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem)
-{
- m_Undo.AddItem(pUndoItem);
+void CFX_Edit::AddEditUndoItem(CFX_Edit_UndoItem* pEditUndoItem) {
+ if (m_pGroupUndoItem)
+ m_pGroupUndoItem->AddUndoItem(pEditUndoItem);
+ else {
+ m_Undo.AddItem(pEditUndoItem);
if (m_bOprNotify && m_pOprNotify)
- m_pOprNotify->OnAddUndo(pUndoItem);
+ m_pOprNotify->OnAddUndo(pEditUndoItem);
+ }
}
+void CFX_Edit::AddUndoItem(IFX_Edit_UndoItem* pUndoItem) {
+ m_Undo.AddItem(pUndoItem);
+ if (m_bOprNotify && m_pOprNotify)
+ m_pOprNotify->OnAddUndo(pUndoItem);
+}
diff --git a/fpdfsdk/src/fxedit/fxet_list.cpp b/fpdfsdk/src/fxedit/fxet_list.cpp
index d94cc16c86..70dc8d5262 100644
--- a/fpdfsdk/src/fxedit/fxet_list.cpp
+++ b/fpdfsdk/src/fxedit/fxet_list.cpp
@@ -8,1004 +8,829 @@
#include "../../include/fxedit/fxet_edit.h"
#include "../../include/fxedit/fxet_list.h"
-/* ------------------------------- CFX_ListItem ---------------------------------- */
+/* ------------------------------- CFX_ListItem
+ * ---------------------------------- */
-CFX_ListItem::CFX_ListItem() : m_pEdit(NULL),
- m_bSelected(FALSE),
- m_bCaret(FALSE),
- m_rcListItem(0.0f,0.0f,0.0f,0.0f)
-{
- m_pEdit = IFX_Edit::NewEdit();
- ASSERT(m_pEdit != NULL);
+CFX_ListItem::CFX_ListItem()
+ : m_pEdit(NULL),
+ m_bSelected(FALSE),
+ m_bCaret(FALSE),
+ m_rcListItem(0.0f, 0.0f, 0.0f, 0.0f) {
+ m_pEdit = IFX_Edit::NewEdit();
+ ASSERT(m_pEdit != NULL);
- m_pEdit->SetAlignmentV(1);
- m_pEdit->Initialize();
+ m_pEdit->SetAlignmentV(1);
+ m_pEdit->Initialize();
}
-CFX_ListItem::~CFX_ListItem()
-{
- IFX_Edit::DelEdit(m_pEdit);
+CFX_ListItem::~CFX_ListItem() {
+ IFX_Edit::DelEdit(m_pEdit);
}
-void CFX_ListItem::SetFontMap(IFX_Edit_FontMap * pFontMap)
-{
- if (m_pEdit)
- m_pEdit->SetFontMap(pFontMap);
+void CFX_ListItem::SetFontMap(IFX_Edit_FontMap* pFontMap) {
+ if (m_pEdit)
+ m_pEdit->SetFontMap(pFontMap);
}
-IFX_Edit* CFX_ListItem::GetEdit() const
-{
- return m_pEdit;
+IFX_Edit* CFX_ListItem::GetEdit() const {
+ return m_pEdit;
}
-IFX_Edit_Iterator* CFX_ListItem::GetIterator() const
-{
- if (m_pEdit)
- return m_pEdit->GetIterator();
+IFX_Edit_Iterator* CFX_ListItem::GetIterator() const {
+ if (m_pEdit)
+ return m_pEdit->GetIterator();
- return NULL;
+ return NULL;
}
-void CFX_ListItem::SetRect(const CLST_Rect & rect)
-{
- m_rcListItem = rect;
+void CFX_ListItem::SetRect(const CLST_Rect& rect) {
+ m_rcListItem = rect;
}
-CLST_Rect CFX_ListItem::GetRect() const
-{
- return m_rcListItem;
+CLST_Rect CFX_ListItem::GetRect() const {
+ return m_rcListItem;
}
-FX_BOOL CFX_ListItem::IsSelected() const
-{
- return m_bSelected;
+FX_BOOL CFX_ListItem::IsSelected() const {
+ return m_bSelected;
}
-void CFX_ListItem::SetSelect(FX_BOOL bSelected)
-{
- m_bSelected = bSelected;
+void CFX_ListItem::SetSelect(FX_BOOL bSelected) {
+ m_bSelected = bSelected;
}
-FX_BOOL CFX_ListItem::IsCaret() const
-{
- return m_bCaret;
+FX_BOOL CFX_ListItem::IsCaret() const {
+ return m_bCaret;
}
-void CFX_ListItem::SetCaret(FX_BOOL bCaret)
-{
- m_bCaret = bCaret;
+void CFX_ListItem::SetCaret(FX_BOOL bCaret) {
+ m_bCaret = bCaret;
}
-void CFX_ListItem::SetText(const FX_WCHAR* text)
-{
- if (m_pEdit)
- m_pEdit->SetText(text);
+void CFX_ListItem::SetText(const FX_WCHAR* text) {
+ if (m_pEdit)
+ m_pEdit->SetText(text);
}
-void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize)
-{
- if (m_pEdit)
- m_pEdit->SetFontSize(fFontSize);
+void CFX_ListItem::SetFontSize(FX_FLOAT fFontSize) {
+ if (m_pEdit)
+ m_pEdit->SetFontSize(fFontSize);
}
-FX_FLOAT CFX_ListItem::GetItemHeight() const
-{
- if (m_pEdit)
- return m_pEdit->GetContentRect().Height();
+FX_FLOAT CFX_ListItem::GetItemHeight() const {
+ if (m_pEdit)
+ return m_pEdit->GetContentRect().Height();
- return 0.0f;
+ return 0.0f;
}
-FX_WORD CFX_ListItem::GetFirstChar() const
-{
- CPVT_Word word;
+FX_WORD CFX_ListItem::GetFirstChar() const {
+ CPVT_Word word;
- if (IFX_Edit_Iterator* pIterator = GetIterator())
- {
- pIterator->SetAt(1);
- pIterator->GetWord(word);
- }
+ if (IFX_Edit_Iterator* pIterator = GetIterator()) {
+ pIterator->SetAt(1);
+ pIterator->GetWord(word);
+ }
- return word.Word;
+ return word.Word;
}
-CFX_WideString CFX_ListItem::GetText() const
-{
- if (m_pEdit)
- return m_pEdit->GetText();
+CFX_WideString CFX_ListItem::GetText() const {
+ if (m_pEdit)
+ return m_pEdit->GetText();
- return L"";
+ return L"";
}
-/* ------------------------------------ CFX_List --------------------------------- */
+/* ------------------------------------ CFX_List
+ * --------------------------------- */
-CFX_List::CFX_List() : m_fFontSize(0.0f), m_pFontMap(NULL), m_bMultiple(FALSE)
-{
+CFX_List::CFX_List()
+ : m_fFontSize(0.0f), m_pFontMap(NULL), m_bMultiple(FALSE) {}
+
+CFX_List::~CFX_List() {
+ Empty();
}
-CFX_List::~CFX_List()
-{
- Empty();
+void CFX_List::Empty() {
+ for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++)
+ delete m_aListItems.GetAt(i);
+
+ m_aListItems.RemoveAll();
}
-void CFX_List::Empty()
-{
- for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++)
- delete m_aListItems.GetAt(i);
+void CFX_List::SetFontMap(IFX_Edit_FontMap* pFontMap) {
+ m_pFontMap = pFontMap;
+}
- m_aListItems.RemoveAll();
+void CFX_List::SetFontSize(FX_FLOAT fFontSize) {
+ m_fFontSize = fFontSize;
}
-void CFX_List::SetFontMap(IFX_Edit_FontMap * pFontMap)
-{
- m_pFontMap = pFontMap;
+void CFX_List::AddItem(const FX_WCHAR* str) {
+ if (CFX_ListItem* pListItem = new CFX_ListItem()) {
+ pListItem->SetFontMap(m_pFontMap);
+ pListItem->SetFontSize(m_fFontSize);
+ pListItem->SetText(str);
+ m_aListItems.Add(pListItem);
+ }
}
-void CFX_List::SetFontSize(FX_FLOAT fFontSize)
-{
- m_fFontSize = fFontSize;
+void CFX_List::ReArrange(int32_t nItemIndex) {
+ FX_FLOAT fPosY = 0.0f;
+
+ if (CFX_ListItem* pPrevItem = m_aListItems.GetAt(nItemIndex - 1))
+ fPosY = pPrevItem->GetRect().bottom;
+
+ for (int32_t i = nItemIndex, sz = m_aListItems.GetSize(); i < sz; i++) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) {
+ FX_FLOAT fListItemHeight = pListItem->GetItemHeight();
+ pListItem->SetRect(CLST_Rect(0.0f, fPosY, 0.0f, fPosY + fListItemHeight));
+ fPosY += fListItemHeight;
+ }
+ }
+
+ SetContentRect(CLST_Rect(0.0f, 0.0f, 0.0f, fPosY));
}
-void CFX_List::AddItem(const FX_WCHAR* str)
-{
- if (CFX_ListItem * pListItem = new CFX_ListItem())
- {
- pListItem->SetFontMap(m_pFontMap);
- pListItem->SetFontSize(m_fFontSize);
- pListItem->SetText(str);
- m_aListItems.Add(pListItem);
- }
+IFX_Edit* CFX_List::GetItemEdit(int32_t nIndex) const {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
+ return pListItem->GetEdit();
+ }
+
+ return NULL;
}
-void CFX_List::ReArrange(int32_t nItemIndex)
-{
- FX_FLOAT fPosY = 0.0f;
+int32_t CFX_List::GetCount() const {
+ return m_aListItems.GetSize();
+}
- if (CFX_ListItem * pPrevItem = m_aListItems.GetAt(nItemIndex - 1))
- fPosY = pPrevItem->GetRect().bottom;
+CPDF_Rect CFX_List::GetPlateRect() const {
+ return CFX_ListContainer::GetPlateRect();
+}
- for (int32_t i=nItemIndex,sz=m_aListItems.GetSize(); i<sz; i++)
- {
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(i))
- {
- FX_FLOAT fListItemHeight = pListItem->GetItemHeight();
- pListItem->SetRect(CLST_Rect(0.0f,fPosY,0.0f,fPosY + fListItemHeight));
- fPosY += fListItemHeight;
- }
- }
+CPDF_Rect CFX_List::GetContentRect() const {
+ return InnerToOuter(CFX_ListContainer::GetContentRect());
+}
- SetContentRect(CLST_Rect(0.0f,0.0f,0.0f,fPosY));
+FX_FLOAT CFX_List::GetFontSize() const {
+ return m_fFontSize;
}
-IFX_Edit * CFX_List::GetItemEdit(int32_t nIndex) const
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex))
- {
- return pListItem->GetEdit();
- }
+int32_t CFX_List::GetItemIndex(const CPDF_Point& point) const {
+ CPDF_Point pt = OuterToInner(point);
+
+ FX_BOOL bFirst = TRUE;
+ FX_BOOL bLast = TRUE;
- return NULL;
+ for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) {
+ CLST_Rect rcListItem = pListItem->GetRect();
+
+ if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top)) {
+ bFirst = FALSE;
+ }
+
+ if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom)) {
+ bLast = FALSE;
+ }
+
+ if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom) {
+ return i;
+ }
+ }
+ }
+
+ if (bFirst)
+ return 0;
+ if (bLast)
+ return m_aListItems.GetSize() - 1;
+
+ return -1;
}
-int32_t CFX_List::GetCount() const
-{
- return m_aListItems.GetSize();
+FX_FLOAT CFX_List::GetFirstHeight() const {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(0)) {
+ return pListItem->GetItemHeight();
+ }
+
+ return 1.0f;
}
-CPDF_Rect CFX_List::GetPlateRect() const
-{
- return CFX_ListContainer::GetPlateRect();
+int32_t CFX_List::GetFirstSelected() const {
+ for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) {
+ if (pListItem->IsSelected())
+ return i;
+ }
+ }
+ return -1;
}
-CPDF_Rect CFX_List::GetContentRect() const
-{
- return InnerToOuter(CFX_ListContainer::GetContentRect());
+int32_t CFX_List::GetLastSelected() const {
+ for (int32_t i = m_aListItems.GetSize() - 1; i >= 0; i--) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(i)) {
+ if (pListItem->IsSelected())
+ return i;
+ }
+ }
+ return -1;
}
-FX_FLOAT CFX_List::GetFontSize() const
-{
- return m_fFontSize;
+FX_WCHAR CFX_List::Toupper(FX_WCHAR c) const {
+ if ((c >= 'a') && (c <= 'z'))
+ c = c - ('a' - 'A');
+ return c;
}
-int32_t CFX_List::GetItemIndex(const CPDF_Point & point) const
-{
- CPDF_Point pt = OuterToInner(point);
+int32_t CFX_List::FindNext(int32_t nIndex, FX_WCHAR nChar) const {
+ int32_t nCircleIndex = nIndex;
- FX_BOOL bFirst = TRUE;
- FX_BOOL bLast = TRUE;
+ for (int32_t i = 0, sz = m_aListItems.GetSize(); i < sz; i++) {
+ nCircleIndex++;
+ if (nCircleIndex >= sz)
+ nCircleIndex = 0;
- for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++)
- {
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(i))
- {
- CLST_Rect rcListItem = pListItem->GetRect();
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nCircleIndex)) {
+ if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar))
+ return nCircleIndex;
+ }
+ }
- if (FX_EDIT_IsFloatBigger(pt.y, rcListItem.top))
- {
- bFirst = FALSE;
- }
+ return nCircleIndex;
+}
- if (FX_EDIT_IsFloatSmaller(pt.y, rcListItem.bottom))
- {
- bLast = FALSE;
- }
+CPDF_Rect CFX_List::GetItemRect(int32_t nIndex) const {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
+ CPDF_Rect rcItem = pListItem->GetRect();
+ rcItem.left = 0.0f;
+ rcItem.right = GetPlateRect().Width();
+ return InnerToOuter(rcItem);
+ }
- if (pt.y >= rcListItem.top && pt.y < rcListItem.bottom)
- {
- return i;
- }
- }
- }
+ return CPDF_Rect();
+}
- if (bFirst) return 0;
- if (bLast) return m_aListItems.GetSize()-1;
+FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
+ return pListItem->IsSelected();
+ }
+
+ return FALSE;
+}
- return -1;
+void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) {
+ pListItem->SetSelect(bSelected);
+ }
}
-FX_FLOAT CFX_List::GetFirstHeight() const
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(0))
- {
- return pListItem->GetItemHeight();
- }
+void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret) {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nItemIndex)) {
+ pListItem->SetCaret(bCaret);
+ }
+}
- return 1.0f;
+void CFX_List::SetMultipleSel(FX_BOOL bMultiple) {
+ m_bMultiple = bMultiple;
}
-int32_t CFX_List::GetFirstSelected() const
-{
- for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++)
- {
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(i))
- {
- if (pListItem->IsSelected())
- return i;
- }
- }
- return -1;
+FX_BOOL CFX_List::IsMultipleSel() const {
+ return m_bMultiple;
}
-int32_t CFX_List::GetLastSelected() const
-{
- for (int32_t i=m_aListItems.GetSize()-1; i>=0; i--)
- {
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(i))
- {
- if (pListItem->IsSelected())
- return i;
- }
- }
- return -1;
+FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const {
+ return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize();
}
-FX_WCHAR CFX_List::Toupper(FX_WCHAR c) const
-{
- if ( (c >= 'a') && (c <= 'z') )
- c = c - ('a' - 'A');
- return c;
+CFX_WideString CFX_List::GetItemText(int32_t nIndex) const {
+ if (CFX_ListItem* pListItem = m_aListItems.GetAt(nIndex)) {
+ return pListItem->GetText();
+ }
+
+ return L"";
}
-int32_t CFX_List::FindNext(int32_t nIndex,FX_WCHAR nChar) const
-{
- int32_t nCircleIndex = nIndex;
+/* ------------------------------------ CPLST_Select
+ * ---------------------------------- */
- for (int32_t i=0,sz=m_aListItems.GetSize(); i<sz; i++)
- {
- nCircleIndex ++;
- if (nCircleIndex >= sz) nCircleIndex = 0;
+CPLST_Select::CPLST_Select() {}
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nCircleIndex))
- {
- if (Toupper(pListItem->GetFirstChar()) == Toupper(nChar))
- return nCircleIndex;
- }
- }
+CPLST_Select::~CPLST_Select() {
+ for (int32_t i = 0, sz = m_aItems.GetSize(); i < sz; i++)
+ delete m_aItems.GetAt(i);
- return nCircleIndex;
+ m_aItems.RemoveAll();
}
-CPDF_Rect CFX_List::GetItemRect(int32_t nIndex) const
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex))
- {
- CPDF_Rect rcItem = pListItem->GetRect();
- rcItem.left = 0.0f;
- rcItem.right = GetPlateRect().Width();
- return InnerToOuter(rcItem);
- }
+void CPLST_Select::Add(int32_t nItemIndex) {
+ int32_t nIndex = Find(nItemIndex);
- return CPDF_Rect();
+ if (nIndex < 0)
+ m_aItems.Add(new CPLST_Select_Item(nItemIndex, 1));
+ else {
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(nIndex)) {
+ pItem->nState = 1;
+ }
+ }
}
-FX_BOOL CFX_List::IsItemSelected(int32_t nIndex) const
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex))
- {
- return pListItem->IsSelected();
- }
+void CPLST_Select::Add(int32_t nBeginIndex, int32_t nEndIndex) {
+ if (nBeginIndex > nEndIndex) {
+ int32_t nTemp = nEndIndex;
+ nEndIndex = nBeginIndex;
+ nBeginIndex = nTemp;
+ }
- return FALSE;
+ for (int32_t i = nBeginIndex; i <= nEndIndex; i++)
+ Add(i);
}
-void CFX_List::SetItemSelect(int32_t nItemIndex, FX_BOOL bSelected)
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex))
- {
- pListItem->SetSelect(bSelected);
- }
+void CPLST_Select::Sub(int32_t nItemIndex) {
+ for (int32_t i = m_aItems.GetSize() - 1; i >= 0; i--) {
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(i))
+ if (pItem->nItemIndex == nItemIndex)
+ pItem->nState = -1;
+ }
}
-void CFX_List::SetItemCaret(int32_t nItemIndex, FX_BOOL bCaret)
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nItemIndex))
- {
- pListItem->SetCaret(bCaret);
- }
+void CPLST_Select::Sub(int32_t nBeginIndex, int32_t nEndIndex) {
+ if (nBeginIndex > nEndIndex) {
+ int32_t nTemp = nEndIndex;
+ nEndIndex = nBeginIndex;
+ nBeginIndex = nTemp;
+ }
+
+ for (int32_t i = nBeginIndex; i <= nEndIndex; i++)
+ Sub(i);
}
-void CFX_List::SetMultipleSel(FX_BOOL bMultiple)
-{
- m_bMultiple = bMultiple;
+int32_t CPLST_Select::Find(int32_t nItemIndex) const {
+ for (int32_t i = 0, sz = m_aItems.GetSize(); i < sz; i++) {
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(i)) {
+ if (pItem->nItemIndex == nItemIndex)
+ return i;
+ }
+ }
+
+ return -1;
}
-FX_BOOL CFX_List::IsMultipleSel() const
-{
- return m_bMultiple;
+FX_BOOL CPLST_Select::IsExist(int32_t nItemIndex) const {
+ return Find(nItemIndex) >= 0;
}
-FX_BOOL CFX_List::IsValid(int32_t nItemIndex) const
-{
- return nItemIndex >= 0 && nItemIndex < m_aListItems.GetSize();
+int32_t CPLST_Select::GetCount() const {
+ return m_aItems.GetSize();
}
-CFX_WideString CFX_List::GetItemText(int32_t nIndex) const
-{
- if (CFX_ListItem * pListItem = m_aListItems.GetAt(nIndex))
- {
- return pListItem->GetText();
- }
+int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const {
+ if (nIndex >= 0 && nIndex < m_aItems.GetSize())
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(nIndex))
+ return pItem->nItemIndex;
- return L"";
+ return -1;
}
-/* ------------------------------------ CPLST_Select ---------------------------------- */
+int32_t CPLST_Select::GetState(int32_t nIndex) const {
+ if (nIndex >= 0 && nIndex < m_aItems.GetSize())
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(nIndex))
+ return pItem->nState;
-CPLST_Select::CPLST_Select()
-{
+ return 0;
}
-CPLST_Select::~CPLST_Select()
-{
- for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++)
- delete m_aItems.GetAt(i);
+void CPLST_Select::DeselectAll() {
+ for (int32_t i = 0, sz = m_aItems.GetSize(); i < sz; i++) {
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(i)) {
+ pItem->nState = -1;
+ }
+ }
+}
- m_aItems.RemoveAll();
+void CPLST_Select::Done() {
+ for (int32_t i = m_aItems.GetSize() - 1; i >= 0; i--) {
+ if (CPLST_Select_Item* pItem = m_aItems.GetAt(i)) {
+ if (pItem->nState == -1) {
+ delete pItem;
+ m_aItems.RemoveAt(i);
+ } else {
+ pItem->nState = 0;
+ }
+ }
+ }
}
-void CPLST_Select::Add(int32_t nItemIndex)
-{
- int32_t nIndex = Find(nItemIndex);
+/* ------------------------------------ CFX_ListCtrl
+ * --------------------------------- */
+
+CFX_ListCtrl::CFX_ListCtrl()
+ : m_pNotify(NULL),
+ m_bNotifyFlag(FALSE),
+ m_ptScrollPos(0.0f, 0.0f),
+ m_nSelItem(-1),
+ m_nFootIndex(-1),
+ m_bCtrlSel(FALSE),
+ m_nCaretIndex(-1) {}
- if (nIndex < 0)
- m_aItems.Add(new CPLST_Select_Item(nItemIndex,1));
- else
- {
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex))
- {
- pItem->nState = 1;
- }
- }
+CFX_ListCtrl::~CFX_ListCtrl() {}
+
+void CFX_ListCtrl::SetNotify(IFX_List_Notify* pNotify) {
+ m_pNotify = pNotify;
}
-void CPLST_Select::Add(int32_t nBeginIndex, int32_t nEndIndex)
-{
- if (nBeginIndex > nEndIndex)
- {
- int32_t nTemp = nEndIndex;
- nEndIndex = nBeginIndex;
- nBeginIndex = nTemp;
- }
+CPDF_Point CFX_ListCtrl::InToOut(const CPDF_Point& point) const {
+ CPDF_Rect rcPlate = GetPlateRect();
- for (int32_t i=nBeginIndex; i<=nEndIndex; i++) Add(i);
+ return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
+ point.y - (m_ptScrollPos.y - rcPlate.top));
}
-void CPLST_Select::Sub(int32_t nItemIndex)
-{
- for (int32_t i=m_aItems.GetSize()-1; i>=0; i--)
- {
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(i))
- if (pItem->nItemIndex == nItemIndex)
- pItem->nState = -1;
- }
+CPDF_Point CFX_ListCtrl::OutToIn(const CPDF_Point& point) const {
+ CPDF_Rect rcPlate = GetPlateRect();
+
+ return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
+ point.y + (m_ptScrollPos.y - rcPlate.top));
}
-void CPLST_Select::Sub(int32_t nBeginIndex, int32_t nEndIndex)
-{
- if (nBeginIndex > nEndIndex)
- {
- int32_t nTemp = nEndIndex;
- nEndIndex = nBeginIndex;
- nBeginIndex = nTemp;
- }
+CPDF_Rect CFX_ListCtrl::InToOut(const CPDF_Rect& rect) const {
+ CPDF_Point ptLeftBottom = InToOut(CPDF_Point(rect.left, rect.bottom));
+ CPDF_Point ptRightTop = InToOut(CPDF_Point(rect.right, rect.top));
- for (int32_t i=nBeginIndex; i<=nEndIndex; i++) Sub(i);
+ return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
}
-int32_t CPLST_Select::Find(int32_t nItemIndex) const
-{
- for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++)
- {
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(i))
- {
- if (pItem->nItemIndex == nItemIndex)
- return i;
- }
- }
+CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect& rect) const {
+ CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left, rect.bottom));
+ CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right, rect.top));
- return -1;
+ return CPDF_Rect(ptLeftBottom.x, ptLeftBottom.y, ptRightTop.x, ptRightTop.y);
}
-FX_BOOL CPLST_Select::IsExist(int32_t nItemIndex) const
-{
- return Find(nItemIndex) >= 0;
+void CFX_ListCtrl::OnMouseDown(const CPDF_Point& point,
+ FX_BOOL bShift,
+ FX_BOOL bCtrl) {
+ int32_t nHitIndex = GetItemIndex(point);
+
+ if (IsMultipleSel()) {
+ if (bCtrl) {
+ if (IsItemSelected(nHitIndex)) {
+ m_aSelItems.Sub(nHitIndex);
+ SelectItems();
+ m_bCtrlSel = FALSE;
+ } else {
+ m_aSelItems.Add(nHitIndex);
+ SelectItems();
+ m_bCtrlSel = TRUE;
+ }
+
+ m_nFootIndex = nHitIndex;
+ } else if (bShift) {
+ m_aSelItems.DeselectAll();
+ m_aSelItems.Add(m_nFootIndex, nHitIndex);
+ SelectItems();
+ } else {
+ m_aSelItems.DeselectAll();
+ m_aSelItems.Add(nHitIndex);
+ SelectItems();
+
+ m_nFootIndex = nHitIndex;
+ }
+
+ SetCaret(nHitIndex);
+ } else {
+ SetSingleSelect(nHitIndex);
+ }
+
+ if (!IsItemVisible(nHitIndex))
+ ScrollToListItem(nHitIndex);
}
-int32_t CPLST_Select::GetCount() const
-{
- return m_aItems.GetSize();
+void CFX_ListCtrl::OnMouseMove(const CPDF_Point& point,
+ FX_BOOL bShift,
+ FX_BOOL bCtrl) {
+ int32_t nHitIndex = GetItemIndex(point);
+
+ if (IsMultipleSel()) {
+ if (bCtrl) {
+ if (m_bCtrlSel)
+ m_aSelItems.Add(m_nFootIndex, nHitIndex);
+ else
+ m_aSelItems.Sub(m_nFootIndex, nHitIndex);
+
+ SelectItems();
+ } else {
+ m_aSelItems.DeselectAll();
+ m_aSelItems.Add(m_nFootIndex, nHitIndex);
+ SelectItems();
+ }
+
+ SetCaret(nHitIndex);
+ } else {
+ SetSingleSelect(nHitIndex);
+ }
+
+ if (!IsItemVisible(nHitIndex))
+ ScrollToListItem(nHitIndex);
}
-int32_t CPLST_Select::GetItemIndex(int32_t nIndex) const
-{
- if (nIndex >= 0 && nIndex < m_aItems.GetSize())
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex))
- return pItem->nItemIndex;
+void CFX_ListCtrl::OnVK(int32_t nItemIndex, FX_BOOL bShift, FX_BOOL bCtrl) {
+ if (IsMultipleSel()) {
+ if (nItemIndex >= 0 && nItemIndex < GetCount()) {
+ if (bCtrl) {
+ } else if (bShift) {
+ m_aSelItems.DeselectAll();
+ m_aSelItems.Add(m_nFootIndex, nItemIndex);
+ SelectItems();
+ } else {
+ m_aSelItems.DeselectAll();
+ m_aSelItems.Add(nItemIndex);
+ SelectItems();
+ m_nFootIndex = nItemIndex;
+ }
+
+ SetCaret(nItemIndex);
+ }
+ } else {
+ SetSingleSelect(nItemIndex);
+ }
- return -1;
+ if (!IsItemVisible(nItemIndex))
+ ScrollToListItem(nItemIndex);
}
-int32_t CPLST_Select::GetState(int32_t nIndex) const
-{
- if (nIndex >= 0 && nIndex < m_aItems.GetSize())
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(nIndex))
- return pItem->nState;
+void CFX_ListCtrl::OnVK_UP(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(IsMultipleSel() ? GetCaret() - 1 : GetSelect() - 1, bShift, bCtrl);
+}
- return 0;
+void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(IsMultipleSel() ? GetCaret() + 1 : GetSelect() + 1, bShift, bCtrl);
}
-void CPLST_Select::DeselectAll()
-{
- for (int32_t i=0,sz=m_aItems.GetSize(); i<sz; i++)
- {
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(i))
- {
- pItem->nState = -1;
- }
- }
-}
-
-void CPLST_Select::Done()
-{
- for (int32_t i=m_aItems.GetSize()-1; i>=0; i--)
- {
- if (CPLST_Select_Item * pItem = m_aItems.GetAt(i))
- {
- if (pItem->nState == -1)
- {
- delete pItem;
- m_aItems.RemoveAt(i);
- }
- else
- {
- pItem->nState = 0;
- }
- }
- }
-}
-
-/* ------------------------------------ CFX_ListCtrl --------------------------------- */
+void CFX_ListCtrl::OnVK_LEFT(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(0, bShift, bCtrl);
+}
-CFX_ListCtrl::CFX_ListCtrl() : m_pNotify(NULL),
- m_bNotifyFlag(FALSE),
- m_ptScrollPos(0.0f,0.0f),
- m_nSelItem(-1),
- m_nFootIndex(-1),
- m_bCtrlSel(FALSE),
- m_nCaretIndex(-1)
-{
-}
-
-CFX_ListCtrl::~CFX_ListCtrl()
-{
+void CFX_ListCtrl::OnVK_RIGHT(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(GetCount() - 1, bShift, bCtrl);
}
-
-void CFX_ListCtrl::SetNotify(IFX_List_Notify * pNotify)
-{
- m_pNotify = pNotify;
-}
-
-CPDF_Point CFX_ListCtrl::InToOut(const CPDF_Point & point) const
-{
- CPDF_Rect rcPlate = GetPlateRect();
-
- return CPDF_Point(point.x - (m_ptScrollPos.x - rcPlate.left),
- point.y - (m_ptScrollPos.y - rcPlate.top));
-}
-
-CPDF_Point CFX_ListCtrl::OutToIn(const CPDF_Point & point) const
-{
- CPDF_Rect rcPlate = GetPlateRect();
-
- return CPDF_Point(point.x + (m_ptScrollPos.x - rcPlate.left),
- point.y + (m_ptScrollPos.y - rcPlate.top));
-}
-
-CPDF_Rect CFX_ListCtrl::InToOut(const CPDF_Rect & rect) const
-{
- CPDF_Point ptLeftBottom = InToOut(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = InToOut(CPDF_Point(rect.right,rect.top));
-
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
-}
-
-CPDF_Rect CFX_ListCtrl::OutToIn(const CPDF_Rect & rect) const
-{
- CPDF_Point ptLeftBottom = OutToIn(CPDF_Point(rect.left,rect.bottom));
- CPDF_Point ptRightTop = OutToIn(CPDF_Point(rect.right,rect.top));
-
- return CPDF_Rect(ptLeftBottom.x,ptLeftBottom.y,ptRightTop.x,ptRightTop.y);
-}
-
-void CFX_ListCtrl::OnMouseDown(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- int32_t nHitIndex = GetItemIndex(point);
-
- if (IsMultipleSel())
- {
- if (bCtrl)
- {
- if (IsItemSelected(nHitIndex))
- {
- m_aSelItems.Sub(nHitIndex);
- SelectItems();
- m_bCtrlSel = FALSE;
- }
- else
- {
- m_aSelItems.Add(nHitIndex);
- SelectItems();
- m_bCtrlSel = TRUE;
- }
-
- m_nFootIndex = nHitIndex;
- }
- else if (bShift)
- {
- m_aSelItems.DeselectAll();
- m_aSelItems.Add(m_nFootIndex,nHitIndex);
- SelectItems();
- }
- else
- {
- m_aSelItems.DeselectAll();
- m_aSelItems.Add(nHitIndex);
- SelectItems();
-
- m_nFootIndex = nHitIndex;
- }
-
- SetCaret(nHitIndex);
- }
- else
- {
- SetSingleSelect(nHitIndex);
- }
-
- if (!IsItemVisible(nHitIndex))
- ScrollToListItem(nHitIndex);
-}
-
-void CFX_ListCtrl::OnMouseMove(const CPDF_Point & point,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- int32_t nHitIndex = GetItemIndex(point);
-
- if (IsMultipleSel())
- {
- if (bCtrl)
- {
- if (m_bCtrlSel)
- m_aSelItems.Add(m_nFootIndex,nHitIndex);
- else
- m_aSelItems.Sub(m_nFootIndex,nHitIndex);
-
- SelectItems();
- }
- else
- {
- m_aSelItems.DeselectAll();
- m_aSelItems.Add(m_nFootIndex,nHitIndex);
- SelectItems();
- }
-
- SetCaret(nHitIndex);
- }
- else
- {
- SetSingleSelect(nHitIndex);
- }
-
- if (!IsItemVisible(nHitIndex))
- ScrollToListItem(nHitIndex);
-}
-
-void CFX_ListCtrl::OnVK(int32_t nItemIndex,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- if (IsMultipleSel())
- {
- if (nItemIndex >= 0 && nItemIndex < GetCount())
- {
- if (bCtrl)
- {
- }
- else if (bShift)
- {
- m_aSelItems.DeselectAll();
- m_aSelItems.Add(m_nFootIndex,nItemIndex);
- SelectItems();
- }
- else
- {
- m_aSelItems.DeselectAll();
- m_aSelItems.Add(nItemIndex);
- SelectItems();
- m_nFootIndex = nItemIndex;
- }
-
- SetCaret(nItemIndex);
- }
- }
- else
- {
- SetSingleSelect(nItemIndex);
- }
-
- if (!IsItemVisible(nItemIndex))
- ScrollToListItem(nItemIndex);
-}
-
-void CFX_ListCtrl::OnVK_UP(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(IsMultipleSel() ? GetCaret()-1 : GetSelect()-1, bShift, bCtrl);
-}
-
-void CFX_ListCtrl::OnVK_DOWN(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(IsMultipleSel() ? GetCaret()+1 : GetSelect()+1, bShift, bCtrl);
-}
-
-void CFX_ListCtrl::OnVK_LEFT(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(0, bShift, bCtrl);
-}
-
-void CFX_ListCtrl::OnVK_RIGHT(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(GetCount()-1, bShift, bCtrl);
-}
-
-void CFX_ListCtrl::OnVK_HOME(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(0, bShift, bCtrl);
-}
-
-void CFX_ListCtrl::OnVK_END(FX_BOOL bShift,FX_BOOL bCtrl)
-{
- OnVK(GetCount()-1, bShift, bCtrl);
-}
-
-FX_BOOL CFX_ListCtrl::OnChar(FX_WORD nChar,FX_BOOL bShift,FX_BOOL bCtrl)
-{
- int32_t nIndex = GetLastSelected();
- int32_t nFindIndex = FindNext(nIndex,nChar);
-
- if (nFindIndex != nIndex)
- {
- OnVK(nFindIndex, bShift, bCtrl);
- return TRUE;
- }
- return FALSE;
+
+void CFX_ListCtrl::OnVK_HOME(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(0, bShift, bCtrl);
+}
+
+void CFX_ListCtrl::OnVK_END(FX_BOOL bShift, FX_BOOL bCtrl) {
+ OnVK(GetCount() - 1, bShift, bCtrl);
+}
+
+FX_BOOL CFX_ListCtrl::OnChar(FX_WORD nChar, FX_BOOL bShift, FX_BOOL bCtrl) {
+ int32_t nIndex = GetLastSelected();
+ int32_t nFindIndex = FindNext(nIndex, nChar);
+
+ if (nFindIndex != nIndex) {
+ OnVK(nFindIndex, bShift, bCtrl);
+ return TRUE;
+ }
+ return FALSE;
}
/* -------- inner methods ------- */
-void CFX_ListCtrl::SetPlateRect(const CPDF_Rect & rect)
-{
- CFX_ListContainer::SetPlateRect(rect);
- m_ptScrollPos.x = rect.left;
- SetScrollPos(CPDF_Point(rect.left,rect.top));
- ReArrange(0);
- InvalidateItem(-1);
-}
-
-CPDF_Rect CFX_ListCtrl::GetItemRect(int32_t nIndex) const
-{
- return InToOut(CFX_List::GetItemRect(nIndex));
-}
-
-void CFX_ListCtrl::AddString(const FX_WCHAR* string)
-{
- AddItem(string);
- ReArrange(GetCount() - 1);
-}
-
-void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected)
-{
- if (!IsValid(nItemIndex)) return;
-
- if (bSelected != IsItemSelected(nItemIndex))
- {
- if (bSelected)
- {
- SetItemSelect(nItemIndex,TRUE);
- InvalidateItem(nItemIndex);
- }
- else
- {
- SetItemSelect(nItemIndex,FALSE);
- InvalidateItem(nItemIndex);
- }
- }
-}
-
-void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex)
-{
- if (!IsValid(nItemIndex)) return;
-
- if (m_nSelItem != nItemIndex)
- {
- if (m_nSelItem >= 0)
- {
- SetItemSelect(m_nSelItem,FALSE);
- InvalidateItem(m_nSelItem);
- }
-
- SetItemSelect(nItemIndex,TRUE);
- InvalidateItem(nItemIndex);
- m_nSelItem = nItemIndex;
- }
-}
-
-void CFX_ListCtrl::SetCaret(int32_t nItemIndex)
-{
- if (!IsValid(nItemIndex)) return;
-
- if (IsMultipleSel())
- {
- int32_t nOldIndex = m_nCaretIndex;
-
- if (nOldIndex != nItemIndex)
- {
- m_nCaretIndex = nItemIndex;
-
- SetItemCaret(nOldIndex, FALSE);
- SetItemCaret(nItemIndex,TRUE);
-
- InvalidateItem(nOldIndex);
- InvalidateItem(nItemIndex);
- }
- }
-}
-
-void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex)
-{
- if (m_pNotify)
- {
- if (nItemIndex == -1)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = GetPlateRect();
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- else
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- CPDF_Rect rcRefresh = GetItemRect(nItemIndex);
- rcRefresh.left -= 1.0f;
- rcRefresh.right += 1.0f;
- rcRefresh.bottom -= 1.0f;
- rcRefresh.top += 1.0f;
-
- m_pNotify->IOnInvalidateRect(&rcRefresh);
- m_bNotifyFlag = FALSE;
- }
- }
- }
-}
-
-void CFX_ListCtrl::SelectItems()
-{
- for (int32_t i=0,sz=m_aSelItems.GetCount(); i<sz; i++)
- {
- int32_t nItemIndex = m_aSelItems.GetItemIndex(i);
- int32_t nState = m_aSelItems.GetState(i);
-
- switch(nState)
- {
- case 1:
- SetMultipleSelect(nItemIndex, TRUE);
- break;
- case -1:
- SetMultipleSelect(nItemIndex, FALSE);
- break;
- }
- }
-
- m_aSelItems.Done();
-}
-
-void CFX_ListCtrl::Select(int32_t nItemIndex)
-{
- if (!IsValid(nItemIndex)) return;
-
- if (IsMultipleSel())
- {
- m_aSelItems.Add(nItemIndex);
- SelectItems();
- }
- else
- SetSingleSelect(nItemIndex);
-}
-
-FX_BOOL CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const
-{
- CPDF_Rect rcPlate = GetPlateRect();
- CPDF_Rect rcItem = GetItemRect(nItemIndex);
-
- return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top;
-}
-
-void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex)
-{
- if (!IsValid(nItemIndex)) return;
-
- CPDF_Rect rcPlate = GetPlateRect();
- CPDF_Rect rcItem = CFX_List::GetItemRect(nItemIndex);
- CPDF_Rect rcItemCtrl = GetItemRect(nItemIndex);
-
- if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom))
- {
- if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top))
- {
- SetScrollPosY(rcItem.bottom + rcPlate.Height());
- }
- }
- else if (FX_EDIT_IsFloatBigger(rcItemCtrl.top, rcPlate.top))
- {
- if (FX_EDIT_IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom))
- {
- SetScrollPosY(rcItem.top);
- }
- }
-}
-
-void CFX_ListCtrl::SetScrollInfo()
-{
- if (m_pNotify)
- {
- CPDF_Rect rcPlate = GetPlateRect();
- CPDF_Rect rcContent = CFX_List::GetContentRect();
-
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
- rcContent.bottom, rcContent.top, GetFirstHeight(), rcPlate.Height());
- m_bNotifyFlag = FALSE;
- }
- }
-}
-
-void CFX_ListCtrl::SetScrollPos(const CPDF_Point & point)
-{
- SetScrollPosY(point.y);
-}
-
-void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy)
-{
- if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y,fy))
- {
- CPDF_Rect rcPlate = GetPlateRect();
- CPDF_Rect rcContent = CFX_List::GetContentRect();
-
- if (rcPlate.Height() > rcContent.Height())
- {
- fy = rcPlate.top;
- }
- else
- {
- if (FX_EDIT_IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom))
- {
- fy = rcContent.bottom + rcPlate.Height();
- }
- else if (FX_EDIT_IsFloatBigger(fy, rcContent.top))
- {
- fy = rcContent.top;
- }
- }
-
- m_ptScrollPos.y = fy;
- InvalidateItem(-1);
+void CFX_ListCtrl::SetPlateRect(const CPDF_Rect& rect) {
+ CFX_ListContainer::SetPlateRect(rect);
+ m_ptScrollPos.x = rect.left;
+ SetScrollPos(CPDF_Point(rect.left, rect.top));
+ ReArrange(0);
+ InvalidateItem(-1);
+}
+
+CPDF_Rect CFX_ListCtrl::GetItemRect(int32_t nIndex) const {
+ return InToOut(CFX_List::GetItemRect(nIndex));
+}
+
+void CFX_ListCtrl::AddString(const FX_WCHAR* string) {
+ AddItem(string);
+ ReArrange(GetCount() - 1);
+}
+
+void CFX_ListCtrl::SetMultipleSelect(int32_t nItemIndex, FX_BOOL bSelected) {
+ if (!IsValid(nItemIndex))
+ return;
- if (m_pNotify)
- {
- if (!m_bNotifyFlag)
- {
- m_bNotifyFlag = TRUE;
- m_pNotify->IOnSetScrollPosY(fy);
- m_bNotifyFlag = FALSE;
- }
- }
- }
-}
-
-CPDF_Rect CFX_ListCtrl::GetContentRect() const
-{
- return InToOut(CFX_List::GetContentRect());
+ if (bSelected != IsItemSelected(nItemIndex)) {
+ if (bSelected) {
+ SetItemSelect(nItemIndex, TRUE);
+ InvalidateItem(nItemIndex);
+ } else {
+ SetItemSelect(nItemIndex, FALSE);
+ InvalidateItem(nItemIndex);
+ }
+ }
}
-void CFX_ListCtrl::ReArrange(int32_t nItemIndex)
-{
- CFX_List::ReArrange(nItemIndex);
- SetScrollInfo();
-}
-
-void CFX_ListCtrl::SetTopItem(int32_t nIndex)
-{
- if (IsValid(nIndex))
- {
- GetPlateRect();
- CPDF_Rect rcItem = CFX_List::GetItemRect(nIndex);
- SetScrollPosY(rcItem.top);
- }
-}
-
-int32_t CFX_ListCtrl::GetTopItem() const
-{
- int32_t nItemIndex = GetItemIndex(GetBTPoint());
-
- if (!IsItemVisible(nItemIndex) && IsItemVisible(nItemIndex + 1))
- nItemIndex += 1;
-
- return nItemIndex;
-}
-
-void CFX_ListCtrl::Empty()
-{
- CFX_List::Empty();
- InvalidateItem(-1);
+void CFX_ListCtrl::SetSingleSelect(int32_t nItemIndex) {
+ if (!IsValid(nItemIndex))
+ return;
+
+ if (m_nSelItem != nItemIndex) {
+ if (m_nSelItem >= 0) {
+ SetItemSelect(m_nSelItem, FALSE);
+ InvalidateItem(m_nSelItem);
+ }
+
+ SetItemSelect(nItemIndex, TRUE);
+ InvalidateItem(nItemIndex);
+ m_nSelItem = nItemIndex;
+ }
}
-void CFX_ListCtrl::Cancel()
-{
- m_aSelItems.DeselectAll();
+void CFX_ListCtrl::SetCaret(int32_t nItemIndex) {
+ if (!IsValid(nItemIndex))
+ return;
+
+ if (IsMultipleSel()) {
+ int32_t nOldIndex = m_nCaretIndex;
+
+ if (nOldIndex != nItemIndex) {
+ m_nCaretIndex = nItemIndex;
+
+ SetItemCaret(nOldIndex, FALSE);
+ SetItemCaret(nItemIndex, TRUE);
+
+ InvalidateItem(nOldIndex);
+ InvalidateItem(nItemIndex);
+ }
+ }
}
-int32_t CFX_ListCtrl::GetItemIndex(const CPDF_Point & point) const
-{
- return CFX_List::GetItemIndex(OutToIn(point));
+void CFX_ListCtrl::InvalidateItem(int32_t nItemIndex) {
+ if (m_pNotify) {
+ if (nItemIndex == -1) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = GetPlateRect();
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
+ } else {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ CPDF_Rect rcRefresh = GetItemRect(nItemIndex);
+ rcRefresh.left -= 1.0f;
+ rcRefresh.right += 1.0f;
+ rcRefresh.bottom -= 1.0f;
+ rcRefresh.top += 1.0f;
+
+ m_pNotify->IOnInvalidateRect(&rcRefresh);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+ }
+}
+
+void CFX_ListCtrl::SelectItems() {
+ for (int32_t i = 0, sz = m_aSelItems.GetCount(); i < sz; i++) {
+ int32_t nItemIndex = m_aSelItems.GetItemIndex(i);
+ int32_t nState = m_aSelItems.GetState(i);
+
+ switch (nState) {
+ case 1:
+ SetMultipleSelect(nItemIndex, TRUE);
+ break;
+ case -1:
+ SetMultipleSelect(nItemIndex, FALSE);
+ break;
+ }
+ }
+
+ m_aSelItems.Done();
+}
+
+void CFX_ListCtrl::Select(int32_t nItemIndex) {
+ if (!IsValid(nItemIndex))
+ return;
+
+ if (IsMultipleSel()) {
+ m_aSelItems.Add(nItemIndex);
+ SelectItems();
+ } else
+ SetSingleSelect(nItemIndex);
}
-CFX_WideString CFX_ListCtrl::GetText() const
-{
- if (IsMultipleSel())
- return GetItemText(m_nCaretIndex);
- return GetItemText(m_nSelItem);
+FX_BOOL CFX_ListCtrl::IsItemVisible(int32_t nItemIndex) const {
+ CPDF_Rect rcPlate = GetPlateRect();
+ CPDF_Rect rcItem = GetItemRect(nItemIndex);
+
+ return rcItem.bottom >= rcPlate.bottom && rcItem.top <= rcPlate.top;
}
+void CFX_ListCtrl::ScrollToListItem(int32_t nItemIndex) {
+ if (!IsValid(nItemIndex))
+ return;
+
+ CPDF_Rect rcPlate = GetPlateRect();
+ CPDF_Rect rcItem = CFX_List::GetItemRect(nItemIndex);
+ CPDF_Rect rcItemCtrl = GetItemRect(nItemIndex);
+
+ if (FX_EDIT_IsFloatSmaller(rcItemCtrl.bottom, rcPlate.bottom)) {
+ if (FX_EDIT_IsFloatSmaller(rcItemCtrl.top, rcPlate.top)) {
+ SetScrollPosY(rcItem.bottom + rcPlate.Height());
+ }
+ } else if (FX_EDIT_IsFloatBigger(rcItemCtrl.top, rcPlate.top)) {
+ if (FX_EDIT_IsFloatBigger(rcItemCtrl.bottom, rcPlate.bottom)) {
+ SetScrollPosY(rcItem.top);
+ }
+ }
+}
+
+void CFX_ListCtrl::SetScrollInfo() {
+ if (m_pNotify) {
+ CPDF_Rect rcPlate = GetPlateRect();
+ CPDF_Rect rcContent = CFX_List::GetContentRect();
+
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollInfoY(rcPlate.bottom, rcPlate.top,
+ rcContent.bottom, rcContent.top,
+ GetFirstHeight(), rcPlate.Height());
+ m_bNotifyFlag = FALSE;
+ }
+ }
+}
+
+void CFX_ListCtrl::SetScrollPos(const CPDF_Point& point) {
+ SetScrollPosY(point.y);
+}
+
+void CFX_ListCtrl::SetScrollPosY(FX_FLOAT fy) {
+ if (!FX_EDIT_IsFloatEqual(m_ptScrollPos.y, fy)) {
+ CPDF_Rect rcPlate = GetPlateRect();
+ CPDF_Rect rcContent = CFX_List::GetContentRect();
+
+ if (rcPlate.Height() > rcContent.Height()) {
+ fy = rcPlate.top;
+ } else {
+ if (FX_EDIT_IsFloatSmaller(fy - rcPlate.Height(), rcContent.bottom)) {
+ fy = rcContent.bottom + rcPlate.Height();
+ } else if (FX_EDIT_IsFloatBigger(fy, rcContent.top)) {
+ fy = rcContent.top;
+ }
+ }
+
+ m_ptScrollPos.y = fy;
+ InvalidateItem(-1);
+
+ if (m_pNotify) {
+ if (!m_bNotifyFlag) {
+ m_bNotifyFlag = TRUE;
+ m_pNotify->IOnSetScrollPosY(fy);
+ m_bNotifyFlag = FALSE;
+ }
+ }
+ }
+}
+
+CPDF_Rect CFX_ListCtrl::GetContentRect() const {
+ return InToOut(CFX_List::GetContentRect());
+}
+
+void CFX_ListCtrl::ReArrange(int32_t nItemIndex) {
+ CFX_List::ReArrange(nItemIndex);
+ SetScrollInfo();
+}
+
+void CFX_ListCtrl::SetTopItem(int32_t nIndex) {
+ if (IsValid(nIndex)) {
+ GetPlateRect();
+ CPDF_Rect rcItem = CFX_List::GetItemRect(nIndex);
+ SetScrollPosY(rcItem.top);
+ }
+}
+
+int32_t CFX_ListCtrl::GetTopItem() const {
+ int32_t nItemIndex = GetItemIndex(GetBTPoint());
+
+ if (!IsItemVisible(nItemIndex) && IsItemVisible(nItemIndex + 1))
+ nItemIndex += 1;
+
+ return nItemIndex;
+}
+
+void CFX_ListCtrl::Empty() {
+ CFX_List::Empty();
+ InvalidateItem(-1);
+}
+
+void CFX_ListCtrl::Cancel() {
+ m_aSelItems.DeselectAll();
+}
+
+int32_t CFX_ListCtrl::GetItemIndex(const CPDF_Point& point) const {
+ return CFX_List::GetItemIndex(OutToIn(point));
+}
+
+CFX_WideString CFX_ListCtrl::GetText() const {
+ if (IsMultipleSel())
+ return GetItemText(m_nCaretIndex);
+ return GetItemText(m_nSelItem);
+}
diff --git a/fpdfsdk/src/fxedit/fxet_module.cpp b/fpdfsdk/src/fxedit/fxet_module.cpp
index d1421641bc..5c0086ae21 100644
--- a/fpdfsdk/src/fxedit/fxet_module.cpp
+++ b/fpdfsdk/src/fxedit/fxet_module.cpp
@@ -10,37 +10,30 @@
/* ---------------------- IFX_Edit ---------------------- */
-IFX_Edit* IFX_Edit::NewEdit()
-{
- if (IPDF_VariableText * pVT = IPDF_VariableText::NewVariableText())
- {
- return new CFX_Edit(pVT);
- }
-
- return NULL;
+IFX_Edit* IFX_Edit::NewEdit() {
+ if (IPDF_VariableText* pVT = IPDF_VariableText::NewVariableText()) {
+ return new CFX_Edit(pVT);
+ }
+
+ return NULL;
}
-void IFX_Edit::DelEdit(IFX_Edit* pEdit)
-{
- ASSERT(pEdit != NULL);
+void IFX_Edit::DelEdit(IFX_Edit* pEdit) {
+ ASSERT(pEdit != NULL);
- IPDF_VariableText::DelVariableText(pEdit->GetVariableText());
+ IPDF_VariableText::DelVariableText(pEdit->GetVariableText());
- delete (CFX_Edit*)pEdit;
+ delete (CFX_Edit*)pEdit;
}
-
/* ---------------------- IFX_List ---------------------- */
-IFX_List* IFX_List::NewList()
-{
- return new CFX_ListCtrl();
+IFX_List* IFX_List::NewList() {
+ return new CFX_ListCtrl();
}
-void IFX_List::DelList(IFX_List* pList)
-{
- ASSERT(pList != NULL);
+void IFX_List::DelList(IFX_List* pList) {
+ ASSERT(pList != NULL);
- delete (CFX_ListCtrl*)pList;
+ delete (CFX_ListCtrl*)pList;
}
-
diff --git a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
index 1c0269b682..1fb669bb57 100644
--- a/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
+++ b/fpdfsdk/src/fxedit/fxet_pageobjs.cpp
@@ -8,634 +8,665 @@
#include "../../include/fxedit/fx_edit.h"
#include "../../include/fxedit/fxet_edit.h"
-#define FX_EDIT_UNDERLINEHALFWIDTH 0.5f
-#define FX_EDIT_CROSSOUTHALFWIDTH 0.5f
-
-extern CFX_ByteString GetPDFWordString(IFX_Edit_FontMap * pFontMap, int32_t nFontIndex, FX_WORD Word, FX_WORD SubWord);
-
-CPDF_Rect GetUnderLineRect(const CPVT_Word& word)
-{
- return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f,
- word.ptWord.x + word.fWidth, word.ptWord.y + word.fDescent * 0.25f);
+#define FX_EDIT_UNDERLINEHALFWIDTH 0.5f
+#define FX_EDIT_CROSSOUTHALFWIDTH 0.5f
+
+extern CFX_ByteString GetPDFWordString(IFX_Edit_FontMap* pFontMap,
+ int32_t nFontIndex,
+ FX_WORD Word,
+ FX_WORD SubWord);
+
+CPDF_Rect GetUnderLineRect(const CPVT_Word& word) {
+ return CPDF_Rect(word.ptWord.x, word.ptWord.y + word.fDescent * 0.5f,
+ word.ptWord.x + word.fWidth,
+ word.ptWord.y + word.fDescent * 0.25f);
}
-CPDF_Rect GetCrossoutRect(const CPVT_Word& word)
-{
- return CPDF_Rect(word.ptWord.x, word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f + word.fDescent * 0.25f,
- word.ptWord.x + word.fWidth, word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f);
+CPDF_Rect GetCrossoutRect(const CPVT_Word& word) {
+ return CPDF_Rect(word.ptWord.x,
+ word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f +
+ word.fDescent * 0.25f,
+ word.ptWord.x + word.fWidth,
+ word.ptWord.y + (word.fAscent + word.fDescent) * 0.5f);
}
-static void DrawTextString(CFX_RenderDevice* pDevice, const CPDF_Point& pt, CPDF_Font* pFont, FX_FLOAT fFontSize, CPDF_Matrix* pUser2Device,
- const CFX_ByteString& str, FX_ARGB crTextFill, FX_ARGB crTextStroke, int32_t nHorzScale)
-{
- FX_FLOAT x = pt.x, y = pt.y;
- pUser2Device->Transform(x, y);
-
- if (pFont)
- {
- if (nHorzScale != 100)
- {
- CPDF_Matrix mt(nHorzScale/100.0f,0,0,1,0,0);
- mt.Concat(*pUser2Device);
-
- CPDF_RenderOptions ro;
- ro.m_Flags = RENDER_CLEARTYPE;
- ro.m_ColorMode = RENDER_COLOR_NORMAL;
-
- if (crTextStroke != 0)
- {
- CPDF_Point pt1(0,0), pt2(1,0);
- pUser2Device->Transform(pt1.x, pt1.y);
- pUser2Device->Transform(pt2.x, pt2.y);
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
-
- CPDF_TextRenderer::DrawTextString(pDevice,x, y, pFont, fFontSize, &mt, str, crTextFill, crTextStroke, &gsd, &ro);
- }
- else
- CPDF_TextRenderer::DrawTextString(pDevice,x, y, pFont, fFontSize, &mt, str, crTextFill, 0, NULL, &ro);
- }
- else
- {
- CPDF_RenderOptions ro;
- ro.m_Flags = RENDER_CLEARTYPE;
- ro.m_ColorMode = RENDER_COLOR_NORMAL;
-
- if (crTextStroke != 0)
- {
- CPDF_Point pt1(0,0), pt2(1,0);
- pUser2Device->Transform(pt1.x, pt1.y);
- pUser2Device->Transform(pt2.x, pt2.y);
- CFX_GraphStateData gsd;
- gsd.m_LineWidth = (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
-
- CPDF_TextRenderer::DrawTextString(pDevice,x, y, pFont, fFontSize, pUser2Device, str, crTextFill, crTextStroke, &gsd, &ro);
- }
- else
- CPDF_TextRenderer::DrawTextString(pDevice,x, y, pFont, fFontSize, pUser2Device, str, crTextFill, 0, NULL, &ro);
- }
- }
+static void DrawTextString(CFX_RenderDevice* pDevice,
+ const CPDF_Point& pt,
+ CPDF_Font* pFont,
+ FX_FLOAT fFontSize,
+ CPDF_Matrix* pUser2Device,
+ const CFX_ByteString& str,
+ FX_ARGB crTextFill,
+ FX_ARGB crTextStroke,
+ int32_t nHorzScale) {
+ FX_FLOAT x = pt.x, y = pt.y;
+ pUser2Device->Transform(x, y);
+
+ if (pFont) {
+ if (nHorzScale != 100) {
+ CPDF_Matrix mt(nHorzScale / 100.0f, 0, 0, 1, 0, 0);
+ mt.Concat(*pUser2Device);
+
+ CPDF_RenderOptions ro;
+ ro.m_Flags = RENDER_CLEARTYPE;
+ ro.m_ColorMode = RENDER_COLOR_NORMAL;
+
+ if (crTextStroke != 0) {
+ CPDF_Point pt1(0, 0), pt2(1, 0);
+ pUser2Device->Transform(pt1.x, pt1.y);
+ pUser2Device->Transform(pt2.x, pt2.y);
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth =
+ (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
+
+ CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
+ str, crTextFill, crTextStroke, &gsd,
+ &ro);
+ } else
+ CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize, &mt,
+ str, crTextFill, 0, NULL, &ro);
+ } else {
+ CPDF_RenderOptions ro;
+ ro.m_Flags = RENDER_CLEARTYPE;
+ ro.m_ColorMode = RENDER_COLOR_NORMAL;
+
+ if (crTextStroke != 0) {
+ CPDF_Point pt1(0, 0), pt2(1, 0);
+ pUser2Device->Transform(pt1.x, pt1.y);
+ pUser2Device->Transform(pt2.x, pt2.y);
+ CFX_GraphStateData gsd;
+ gsd.m_LineWidth =
+ (FX_FLOAT)FXSYS_fabs((pt2.x + pt2.y) - (pt1.x + pt1.y));
+
+ CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
+ pUser2Device, str, crTextFill,
+ crTextStroke, &gsd, &ro);
+ } else
+ CPDF_TextRenderer::DrawTextString(pDevice, x, y, pFont, fFontSize,
+ pUser2Device, str, crTextFill, 0,
+ NULL, &ro);
+ }
+ }
}
-void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF color,
- const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange)
-{
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty())
- {
- CPDF_Rect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
- }
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- CFX_PathData pathUnderline;
- CPDF_Rect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, rcUnderline.right, rcUnderline.top);
-
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0, FXFILL_WINDING);
- }
- }
- }
- }
-
- pDevice->RestoreState();
+void IFX_Edit::DrawUnderline(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ IFX_Edit* pEdit,
+ FX_COLORREF color,
+ const CPDF_Rect& rcClip,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange) {
+ pDevice->SaveState();
+
+ if (!rcClip.IsEmpty()) {
+ CPDF_Rect rcTemp = rcClip;
+ pUser2Device->TransformRect(rcTemp);
+ FX_RECT rcDevClip;
+ rcDevClip.left = (int32_t)rcTemp.left;
+ rcDevClip.right = (int32_t)rcTemp.right;
+ rcDevClip.top = (int32_t)rcTemp.top;
+ rcDevClip.bottom = (int32_t)rcTemp.bottom;
+ pDevice->SetClip_Rect(&rcDevClip);
+ }
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CFX_PathData pathUnderline;
+ CPDF_Rect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
+
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, color, 0,
+ FXFILL_WINDING);
+ }
+ }
+ }
+ }
+
+ pDevice->RestoreState();
}
-void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit, FX_COLORREF crTextFill, FX_COLORREF crTextStroke,
- const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, IFX_SystemHandler* pSystemHandler, void* pFFLData)
-{
-
- FX_BOOL bContinuous = pEdit->GetCharArray() == 0;
- if (pEdit->GetCharSpace() > 0.0f)
- bContinuous = FALSE;
-
- FX_WORD SubWord = pEdit->GetPasswordChar();
- FX_FLOAT fFontSize = pEdit->GetFontSize();
- CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
- int32_t nHorzScale = pEdit->GetHorzScale();
-
- FX_COLORREF crCurFill = crTextFill;
- FX_COLORREF crOldFill = crCurFill;
-
- FX_BOOL bSelect = FALSE;
- const FX_COLORREF crWhite = ArgbEncode(255,255,255,255);
- const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113);
-
- CFX_ByteTextBuf sTextBuf;
- int32_t nFontIndex = -1;
- CPDF_Point ptBT(0.0f,0.0f);
-
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty())
- {
- CPDF_Rect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
- }
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- if (wrSelect.IsExist())
- {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect)
- {
- crCurFill = crWhite;
- }
- else
- {
- crCurFill = crTextFill;
- }
- }
- if(pSystemHandler && pSystemHandler->IsSelectionImplemented())
- {
- crCurFill = crTextFill;
- crOldFill = crCurFill;
- }
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
-
- if (bSelect)
- {
-
- CPVT_Line line;
- pIterator->GetLine(line);
-
- if(pSystemHandler && pSystemHandler->IsSelectionImplemented())
- {
- CPDF_Rect rc(word.ptWord.x,line.ptLine.y + line.fLineDescent,
- word.ptWord.x+word.fWidth,line.ptLine.y + line.fLineAscent);
- rc.Intersect(rcClip);
- //CFX_Edit* pEt = (CFX_Edit*)pEdit;
- //CPDF_Rect rcEdit = pEt->VTToEdit(rc);
- pSystemHandler->OutputSelectedRect(pFFLData,rc);
- }
- else
- {
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x,line.ptLine.y + line.fLineDescent,
- word.ptWord.x+word.fWidth,line.ptLine.y + line.fLineAscent);
-
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, FXFILL_WINDING);
- }
- }
-
- if (bContinuous)
- {
- if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
- crOldFill != crCurFill)
- {
- if (sTextBuf.GetLength() > 0)
- {
- DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(nFontIndex),
- fFontSize, pUser2Device, sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale);
-
- sTextBuf.Clear();
- }
- nFontIndex = word.nFontIndex;
- ptBT = word.ptWord;
- crOldFill = crCurFill;
- }
-
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord);
- }
- else
- {
- DrawTextString(pDevice,CPDF_Point(word.ptWord.x+ptOffset.x, word.ptWord.y+ptOffset.y), pFontMap->GetPDFFont(word.nFontIndex),
- fFontSize, pUser2Device, GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord), crCurFill, crTextStroke, nHorzScale);
-
- }
- oldplace = place;
-
-
- }
- }
-
- if (sTextBuf.GetLength() > 0)
- {
- DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(nFontIndex),
- fFontSize, pUser2Device, sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale);
- }
- }
- }
-
- pDevice->RestoreState();
+void IFX_Edit::DrawEdit(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ IFX_Edit* pEdit,
+ FX_COLORREF crTextFill,
+ FX_COLORREF crTextStroke,
+ const CPDF_Rect& rcClip,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange,
+ IFX_SystemHandler* pSystemHandler,
+ void* pFFLData) {
+ FX_BOOL bContinuous = pEdit->GetCharArray() == 0;
+ if (pEdit->GetCharSpace() > 0.0f)
+ bContinuous = FALSE;
+
+ FX_WORD SubWord = pEdit->GetPasswordChar();
+ FX_FLOAT fFontSize = pEdit->GetFontSize();
+ CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
+ int32_t nHorzScale = pEdit->GetHorzScale();
+
+ FX_COLORREF crCurFill = crTextFill;
+ FX_COLORREF crOldFill = crCurFill;
+
+ FX_BOOL bSelect = FALSE;
+ const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
+ const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
+
+ CFX_ByteTextBuf sTextBuf;
+ int32_t nFontIndex = -1;
+ CPDF_Point ptBT(0.0f, 0.0f);
+
+ pDevice->SaveState();
+
+ if (!rcClip.IsEmpty()) {
+ CPDF_Rect rcTemp = rcClip;
+ pUser2Device->TransformRect(rcTemp);
+ FX_RECT rcDevClip;
+ rcDevClip.left = (int32_t)rcTemp.left;
+ rcDevClip.right = (int32_t)rcTemp.right;
+ rcDevClip.top = (int32_t)rcTemp.top;
+ rcDevClip.bottom = (int32_t)rcTemp.bottom;
+ pDevice->SetClip_Rect(&rcDevClip);
+ }
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ if (bSelect) {
+ crCurFill = crWhite;
+ } else {
+ crCurFill = crTextFill;
+ }
+ }
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ crCurFill = crTextFill;
+ crOldFill = crCurFill;
+ }
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+
+ if (pSystemHandler && pSystemHandler->IsSelectionImplemented()) {
+ CPDF_Rect rc(word.ptWord.x, line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth,
+ line.ptLine.y + line.fLineAscent);
+ rc.Intersect(rcClip);
+ // CFX_Edit* pEt = (CFX_Edit*)pEdit;
+ // CPDF_Rect rcEdit = pEt->VTToEdit(rc);
+ pSystemHandler->OutputSelectedRect(pFFLData, rc);
+ } else {
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(word.ptWord.x,
+ line.ptLine.y + line.fLineDescent,
+ word.ptWord.x + word.fWidth,
+ line.ptLine.y + line.fLineAscent);
+
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
+ }
+ }
+
+ if (bContinuous) {
+ if (place.LineCmp(oldplace) != 0 || word.nFontIndex != nFontIndex ||
+ crOldFill != crCurFill) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(pDevice, CPDF_Point(ptBT.x + ptOffset.x,
+ ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize,
+ pUser2Device, sTextBuf.GetByteString(),
+ crOldFill, crTextStroke, nHorzScale);
+
+ sTextBuf.Clear();
+ }
+ nFontIndex = word.nFontIndex;
+ ptBT = word.ptWord;
+ crOldFill = crCurFill;
+ }
+
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word,
+ SubWord);
+ } else {
+ DrawTextString(
+ pDevice, CPDF_Point(word.ptWord.x + ptOffset.x,
+ word.ptWord.y + ptOffset.y),
+ pFontMap->GetPDFFont(word.nFontIndex), fFontSize, pUser2Device,
+ GetPDFWordString(pFontMap, word.nFontIndex, word.Word, SubWord),
+ crCurFill, crTextStroke, nHorzScale);
+ }
+ oldplace = place;
+ }
+ }
+
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(nFontIndex), fFontSize, pUser2Device,
+ sTextBuf.GetByteString(), crOldFill, crTextStroke, nHorzScale);
+ }
+ }
+ }
+
+ pDevice->RestoreState();
}
-void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device, IFX_Edit* pEdit,
- const CPDF_Rect& rcClip, const CPDF_Point& ptOffset, const CPVT_WordRange* pRange)
-{
- //FX_FLOAT fFontSize = pEdit->GetFontSize();
- CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
-
- FX_COLORREF crCurText = ArgbEncode(255, 0,0,0);
- FX_COLORREF crOld = crCurText;
- FX_BOOL bSelect = FALSE;
- const FX_COLORREF crWhite = ArgbEncode(255,255,255,255);
- const FX_COLORREF crSelBK = ArgbEncode(255,0,51,113);
-
- CFX_ByteTextBuf sTextBuf;
- CPVT_WordProps wp;
- CPDF_Point ptBT(0.0f,0.0f);
-
- pDevice->SaveState();
-
- if (!rcClip.IsEmpty())
- {
- CPDF_Rect rcTemp = rcClip;
- pUser2Device->TransformRect(rcTemp);
- FX_RECT rcDevClip;
- rcDevClip.left = (int32_t)rcTemp.left;
- rcDevClip.right = (int32_t)rcTemp.right;
- rcDevClip.top = (int32_t)rcTemp.top;
- rcDevClip.bottom = (int32_t)rcTemp.bottom;
- pDevice->SetClip_Rect(&rcDevClip);
- }
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- word.WordProps.fFontSize = word.fFontSize;
-
- crCurText = ArgbEncode(255,word.WordProps.dwWordColor);
-
- if (wrSelect.IsExist())
- {
- bSelect = place.WordCmp(wrSelect.BeginPos) > 0 && place.WordCmp(wrSelect.EndPos) <= 0;
- if (bSelect)
- {
- crCurText = crWhite;
- }
- }
-
- if (bSelect)
- {
- CPVT_Line line;
- pIterator->GetLine(line);
-
- CFX_PathData pathSelBK;
- pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
- line.ptLine.y + line.fLineDescent + ptOffset.y,
- word.ptWord.x+word.fWidth + ptOffset.x,
- line.ptLine.y + line.fLineAscent + ptOffset.y);
-
- pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0, FXFILL_WINDING);
- }
-
- if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText)
- {
- if (sTextBuf.GetLength() > 0)
- {
- DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, pUser2Device, sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale);
-
- sTextBuf.Clear();
- }
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
- }
-
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, word.Word, 0);
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {
- CFX_PathData pathUnderline;
- CPDF_Rect rcUnderline = GetUnderLineRect(word);
- pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom, rcUnderline.right, rcUnderline.top);
-
- pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0, FXFILL_WINDING);
- }
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- CFX_PathData pathCrossout;
- CPDF_Rect rcCrossout = GetCrossoutRect(word);
- pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom, rcCrossout.right, rcCrossout.top);
-
- pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0, FXFILL_WINDING);
- }
-
- oldplace = place;
- }
- }
-
- if (sTextBuf.GetLength() > 0)
- {
- DrawTextString(pDevice, CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), pFontMap->GetPDFFont(wp.nFontIndex),
- wp.fFontSize, pUser2Device, sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale);
- }
- }
- }
-
- pDevice->RestoreState();
+void IFX_Edit::DrawRichEdit(CFX_RenderDevice* pDevice,
+ CPDF_Matrix* pUser2Device,
+ IFX_Edit* pEdit,
+ const CPDF_Rect& rcClip,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange) {
+ // FX_FLOAT fFontSize = pEdit->GetFontSize();
+ CPVT_WordRange wrSelect = pEdit->GetSelectWordRange();
+
+ FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0);
+ FX_COLORREF crOld = crCurText;
+ FX_BOOL bSelect = FALSE;
+ const FX_COLORREF crWhite = ArgbEncode(255, 255, 255, 255);
+ const FX_COLORREF crSelBK = ArgbEncode(255, 0, 51, 113);
+
+ CFX_ByteTextBuf sTextBuf;
+ CPVT_WordProps wp;
+ CPDF_Point ptBT(0.0f, 0.0f);
+
+ pDevice->SaveState();
+
+ if (!rcClip.IsEmpty()) {
+ CPDF_Rect rcTemp = rcClip;
+ pUser2Device->TransformRect(rcTemp);
+ FX_RECT rcDevClip;
+ rcDevClip.left = (int32_t)rcTemp.left;
+ rcDevClip.right = (int32_t)rcTemp.right;
+ rcDevClip.top = (int32_t)rcTemp.top;
+ rcDevClip.bottom = (int32_t)rcTemp.bottom;
+ pDevice->SetClip_Rect(&rcDevClip);
+ }
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
+
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+
+ if (wrSelect.IsExist()) {
+ bSelect = place.WordCmp(wrSelect.BeginPos) > 0 &&
+ place.WordCmp(wrSelect.EndPos) <= 0;
+ if (bSelect) {
+ crCurText = crWhite;
+ }
+ }
+
+ if (bSelect) {
+ CPVT_Line line;
+ pIterator->GetLine(line);
+
+ CFX_PathData pathSelBK;
+ pathSelBK.AppendRect(word.ptWord.x + ptOffset.x,
+ line.ptLine.y + line.fLineDescent + ptOffset.y,
+ word.ptWord.x + word.fWidth + ptOffset.x,
+ line.ptLine.y + line.fLineAscent + ptOffset.y);
+
+ pDevice->DrawPath(&pathSelBK, pUser2Device, NULL, crSelBK, 0,
+ FXFILL_WINDING);
+ }
+
+ if (place.LineCmp(oldplace) != 0 ||
+ word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize,
+ pUser2Device, sTextBuf.GetByteString(), crOld, 0,
+ wp.nHorzScale);
+
+ sTextBuf.Clear();
+ }
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
+
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0);
+
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE) {
+ CFX_PathData pathUnderline;
+ CPDF_Rect rcUnderline = GetUnderLineRect(word);
+ pathUnderline.AppendRect(rcUnderline.left, rcUnderline.bottom,
+ rcUnderline.right, rcUnderline.top);
+
+ pDevice->DrawPath(&pathUnderline, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
+ }
+
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CFX_PathData pathCrossout;
+ CPDF_Rect rcCrossout = GetCrossoutRect(word);
+ pathCrossout.AppendRect(rcCrossout.left, rcCrossout.bottom,
+ rcCrossout.right, rcCrossout.top);
+
+ pDevice->DrawPath(&pathCrossout, pUser2Device, NULL, crCurText, 0,
+ FXFILL_WINDING);
+ }
+
+ oldplace = place;
+ }
+ }
+
+ if (sTextBuf.GetLength() > 0) {
+ DrawTextString(
+ pDevice, CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, pUser2Device,
+ sTextBuf.GetByteString(), crOld, 0, wp.nHorzScale);
+ }
+ }
+ }
+
+ pDevice->RestoreState();
}
-static void AddRectToPageObjects(CPDF_PageObjects* pPageObjs, FX_COLORREF crFill, const CPDF_Rect& rcFill)
-{
- CPDF_PathObject* pPathObj = new CPDF_PathObject;
- CPDF_PathData* pPathData = pPathObj->m_Path.GetModify();
- pPathData->AppendRect(rcFill.left,rcFill.bottom,rcFill.right,rcFill.top);
+static void AddRectToPageObjects(CPDF_PageObjects* pPageObjs,
+ FX_COLORREF crFill,
+ const CPDF_Rect& rcFill) {
+ CPDF_PathObject* pPathObj = new CPDF_PathObject;
+ CPDF_PathData* pPathData = pPathObj->m_Path.GetModify();
+ pPathData->AppendRect(rcFill.left, rcFill.bottom, rcFill.right, rcFill.top);
- FX_FLOAT rgb[3];
- rgb[0] = FXARGB_R(crFill) / 255.0f ;
- rgb[1] = FXARGB_G(crFill) / 255.0f;
- rgb[2] = FXARGB_B(crFill) / 255.0f;
- pPathObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+ FX_FLOAT rgb[3];
+ rgb[0] = FXARGB_R(crFill) / 255.0f;
+ rgb[1] = FXARGB_G(crFill) / 255.0f;
+ rgb[2] = FXARGB_B(crFill) / 255.0f;
+ pPathObj->m_ColorState.SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
- pPathObj->m_FillType = FXFILL_ALTERNATE;
- pPathObj->m_bStroke = FALSE;
+ pPathObj->m_FillType = FXFILL_ALTERNATE;
+ pPathObj->m_bStroke = FALSE;
- pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pPathObj);
+ pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pPathObj);
}
-static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs, FX_COLORREF crText,
- CPDF_Font* pFont, FX_FLOAT fFontSize, FX_FLOAT fCharSpace, int32_t nHorzScale,
- const CPDF_Point& point, const CFX_ByteString& text)
-{
- CPDF_TextObject* pTxtObj = new CPDF_TextObject;
-
- CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify();
- pTextStateData->m_pFont = pFont;
- pTextStateData->m_FontSize = fFontSize;
- pTextStateData->m_CharSpace = fCharSpace;
- pTextStateData->m_WordSpace = 0;
- pTextStateData->m_TextMode = 0;
- pTextStateData->m_Matrix[0] = nHorzScale / 100.0f;
- pTextStateData->m_Matrix[1] = 0;
- pTextStateData->m_Matrix[2] = 0;
- pTextStateData->m_Matrix[3] = 1;
-
- FX_FLOAT rgb[3];
- rgb[0] = FXARGB_R(crText) / 255.0f ;
- rgb[1] = FXARGB_G(crText) / 255.0f;
- rgb[2] = FXARGB_B(crText) / 255.0f;
- pTxtObj->m_ColorState.SetFillColor(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB),rgb, 3);
- pTxtObj->m_ColorState.SetStrokeColor(CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB),rgb, 3);
-
- pTxtObj->SetPosition(point.x,point.y);
- pTxtObj->SetText(text);
-
- pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(),pTxtObj);
-
- return pTxtObj;
+static CPDF_TextObject* AddTextObjToPageObjects(CPDF_PageObjects* pPageObjs,
+ FX_COLORREF crText,
+ CPDF_Font* pFont,
+ FX_FLOAT fFontSize,
+ FX_FLOAT fCharSpace,
+ int32_t nHorzScale,
+ const CPDF_Point& point,
+ const CFX_ByteString& text) {
+ CPDF_TextObject* pTxtObj = new CPDF_TextObject;
+
+ CPDF_TextStateData* pTextStateData = pTxtObj->m_TextState.GetModify();
+ pTextStateData->m_pFont = pFont;
+ pTextStateData->m_FontSize = fFontSize;
+ pTextStateData->m_CharSpace = fCharSpace;
+ pTextStateData->m_WordSpace = 0;
+ pTextStateData->m_TextMode = 0;
+ pTextStateData->m_Matrix[0] = nHorzScale / 100.0f;
+ pTextStateData->m_Matrix[1] = 0;
+ pTextStateData->m_Matrix[2] = 0;
+ pTextStateData->m_Matrix[3] = 1;
+
+ FX_FLOAT rgb[3];
+ rgb[0] = FXARGB_R(crText) / 255.0f;
+ rgb[1] = FXARGB_G(crText) / 255.0f;
+ rgb[2] = FXARGB_B(crText) / 255.0f;
+ pTxtObj->m_ColorState.SetFillColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+ pTxtObj->m_ColorState.SetStrokeColor(
+ CPDF_ColorSpace::GetStockCS(PDFCS_DEVICERGB), rgb, 3);
+
+ pTxtObj->SetPosition(point.x, point.y);
+ pTxtObj->SetText(text);
+
+ pPageObjs->InsertObject(pPageObjs->GetLastObjectPosition(), pTxtObj);
+
+ return pTxtObj;
}
-void IFX_Edit::GeneratePageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit,
- const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF crText, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
-{
- FX_FLOAT fFontSize = pEdit->GetFontSize();
-
- int32_t nOldFontIndex = -1;
-
- CFX_ByteTextBuf sTextBuf;
- CPDF_Point ptBT(0.0f,0.0f);
-
- ObjArray.RemoveAll();
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- if (place.LineCmp(oldplace) != 0 || nOldFontIndex != word.nFontIndex)
- {
- if (sTextBuf.GetLength() > 0)
- {
- ObjArray.Add(AddTextObjToPageObjects(pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 0.0f, 100,
- CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString()));
-
- sTextBuf.Clear();
- }
-
- ptBT = word.ptWord;
- nOldFontIndex = word.nFontIndex;
- }
-
- sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0);
- oldplace = place;
- }
- }
-
- if (sTextBuf.GetLength() > 0)
- {
- ObjArray.Add(AddTextObjToPageObjects(pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex), fFontSize, 0.0f, 100,
- CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString()));
- }
- }
- }
+void IFX_Edit::GeneratePageObjects(
+ CPDF_PageObjects* pPageObjects,
+ IFX_Edit* pEdit,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange,
+ FX_COLORREF crText,
+ CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) {
+ FX_FLOAT fFontSize = pEdit->GetFontSize();
+
+ int32_t nOldFontIndex = -1;
+
+ CFX_ByteTextBuf sTextBuf;
+ CPDF_Point ptBT(0.0f, 0.0f);
+
+ ObjArray.RemoveAll();
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ if (place.LineCmp(oldplace) != 0 ||
+ nOldFontIndex != word.nFontIndex) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex),
+ fFontSize, 0.0f, 100,
+ CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.GetByteString()));
+
+ sTextBuf.Clear();
+ }
+
+ ptBT = word.ptWord;
+ nOldFontIndex = word.nFontIndex;
+ }
+
+ sTextBuf << GetPDFWordString(pFontMap, word.nFontIndex, word.Word, 0);
+ oldplace = place;
+ }
+ }
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pPageObjects, crText, pFontMap->GetPDFFont(nOldFontIndex),
+ fFontSize, 0.0f, 100,
+ CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.GetByteString()));
+ }
+ }
+ }
}
-void IFX_Edit::GenerateRichPageObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit,
- const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray)
-{
-
-
- FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0);
- FX_COLORREF crOld = crCurText;
-
-
- CFX_ByteTextBuf sTextBuf;
- CPVT_WordProps wp;
- CPDF_Point ptBT(0.0f,0.0f);
-
- ObjArray.RemoveAll();
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- word.WordProps.fFontSize = word.fFontSize;
-
- crCurText = ArgbEncode(255,word.WordProps.dwWordColor);
-
- if (place.LineCmp(oldplace) != 0 || word.WordProps.fCharSpace > 0.0f || word.WordProps.nHorzScale != 100 ||
- FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
- crOld != crCurText)
- {
- if (sTextBuf.GetLength() > 0)
- {
- ObjArray.Add(AddTextObjToPageObjects(pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString()));
-
- sTextBuf.Clear();
- }
-
- wp = word.WordProps;
- ptBT = word.ptWord;
- crOld = crCurText;
-
- }
-
- sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex, word.Word, 0);
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_UNDERLINE)
- {/*
- AddLineToPageObjects(pPageObjects, crCurText,
- CPDF_Point(word.ptWord.x, word.ptWord.y + word.fDescent * 0.4f),
- CPDF_Point(word.ptWord.x + word.fWidth, word.ptWord.y + word.fDescent * 0.4f));
+void IFX_Edit::GenerateRichPageObjects(
+ CPDF_PageObjects* pPageObjects,
+ IFX_Edit* pEdit,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange,
+ CFX_ArrayTemplate<CPDF_TextObject*>& ObjArray) {
+ FX_COLORREF crCurText = ArgbEncode(255, 0, 0, 0);
+ FX_COLORREF crOld = crCurText;
+
+ CFX_ByteTextBuf sTextBuf;
+ CPVT_WordProps wp;
+ CPDF_Point ptBT(0.0f, 0.0f);
+
+ ObjArray.RemoveAll();
+
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (IFX_Edit_FontMap* pFontMap = pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ word.WordProps.fFontSize = word.fFontSize;
+
+ crCurText = ArgbEncode(255, word.WordProps.dwWordColor);
+
+ if (place.LineCmp(oldplace) != 0 ||
+ word.WordProps.fCharSpace > 0.0f ||
+ word.WordProps.nHorzScale != 100 ||
+ FXSYS_memcmp(&word.WordProps, &wp, sizeof(CPVT_WordProps)) != 0 ||
+ crOld != crCurText) {
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.GetByteString()));
+
+ sTextBuf.Clear();
+ }
+
+ wp = word.WordProps;
+ ptBT = word.ptWord;
+ crOld = crCurText;
+ }
+
+ sTextBuf << GetPDFWordString(pFontMap, word.WordProps.nFontIndex,
+ word.Word, 0);
+
+ if (word.WordProps.nWordStyle &
+ PVTWORD_STYLE_UNDERLINE) { /*
+ AddLineToPageObjects(pPageObjects,
+ crCurText,
+ CPDF_Point(word.ptWord.x,
+ word.ptWord.y + word.fDescent *
+ 0.4f),
+ CPDF_Point(word.ptWord.x
+ + word.fWidth, word.ptWord.y +
+ word.fDescent * 0.4f));
*/
- CPDF_Rect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
-
- AddRectToPageObjects(pPageObjects, crCurText, rcUnderline);
- }
-
- if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT)
- {
- CPDF_Rect rcCrossout = GetCrossoutRect(word);
- rcCrossout.left += ptOffset.x;
- rcCrossout.right += ptOffset.x;
- rcCrossout.top += ptOffset.y;
- rcCrossout.bottom += ptOffset.y;
-
- AddRectToPageObjects(pPageObjects, crCurText, rcCrossout);
- }
-
- oldplace = place;
- }
- }
-
- if (sTextBuf.GetLength() > 0)
- {
- ObjArray.Add(AddTextObjToPageObjects(pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex), wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
- CPDF_Point(ptBT.x+ptOffset.x, ptBT.y+ptOffset.y), sTextBuf.GetByteString()));
- }
- }
- }
+ CPDF_Rect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+
+ AddRectToPageObjects(pPageObjects, crCurText, rcUnderline);
+ }
+
+ if (word.WordProps.nWordStyle & PVTWORD_STYLE_CROSSOUT) {
+ CPDF_Rect rcCrossout = GetCrossoutRect(word);
+ rcCrossout.left += ptOffset.x;
+ rcCrossout.right += ptOffset.x;
+ rcCrossout.top += ptOffset.y;
+ rcCrossout.bottom += ptOffset.y;
+
+ AddRectToPageObjects(pPageObjects, crCurText, rcCrossout);
+ }
+
+ oldplace = place;
+ }
+ }
+
+ if (sTextBuf.GetLength() > 0) {
+ ObjArray.Add(AddTextObjToPageObjects(
+ pPageObjects, crOld, pFontMap->GetPDFFont(wp.nFontIndex),
+ wp.fFontSize, wp.fCharSpace, wp.nHorzScale,
+ CPDF_Point(ptBT.x + ptOffset.x, ptBT.y + ptOffset.y),
+ sTextBuf.GetByteString()));
+ }
+ }
+ }
}
-void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects, IFX_Edit* pEdit,
- const CPDF_Point& ptOffset, const CPVT_WordRange* pRange, FX_COLORREF color)
-{
-
-
- if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator())
- {
- if (pEdit->GetFontMap())
- {
- if (pRange)
- pIterator->SetAt(pRange->BeginPos);
- else
- pIterator->SetAt(0);
-
- CPVT_WordPlace oldplace;
-
- while (pIterator->NextWord())
- {
- CPVT_WordPlace place = pIterator->GetAt();
- if (pRange && place.WordCmp(pRange->EndPos) > 0) break;
-
- CPVT_Word word;
- if (pIterator->GetWord(word))
- {
- CPDF_Rect rcUnderline = GetUnderLineRect(word);
- rcUnderline.left += ptOffset.x;
- rcUnderline.right += ptOffset.x;
- rcUnderline.top += ptOffset.y;
- rcUnderline.bottom += ptOffset.y;
- AddRectToPageObjects(pPageObjects, color, rcUnderline);
- }
- }
- }
- }
+void IFX_Edit::GenerateUnderlineObjects(CPDF_PageObjects* pPageObjects,
+ IFX_Edit* pEdit,
+ const CPDF_Point& ptOffset,
+ const CPVT_WordRange* pRange,
+ FX_COLORREF color) {
+ if (IFX_Edit_Iterator* pIterator = pEdit->GetIterator()) {
+ if (pEdit->GetFontMap()) {
+ if (pRange)
+ pIterator->SetAt(pRange->BeginPos);
+ else
+ pIterator->SetAt(0);
+
+ CPVT_WordPlace oldplace;
+
+ while (pIterator->NextWord()) {
+ CPVT_WordPlace place = pIterator->GetAt();
+ if (pRange && place.WordCmp(pRange->EndPos) > 0)
+ break;
+
+ CPVT_Word word;
+ if (pIterator->GetWord(word)) {
+ CPDF_Rect rcUnderline = GetUnderLineRect(word);
+ rcUnderline.left += ptOffset.x;
+ rcUnderline.right += ptOffset.x;
+ rcUnderline.top += ptOffset.y;
+ rcUnderline.bottom += ptOffset.y;
+ AddRectToPageObjects(pPageObjects, color, rcUnderline);
+ }
+ }
+ }
+ }
}
-