From d143054f6f1cdaa9669619c8ec3c6803a01b1bd1 Mon Sep 17 00:00:00 2001 From: "cmanske%netscape.com" Date: Wed, 30 Sep 1998 20:30:51 +0000 Subject: [PATCH] Added more support to change list to blockquote --- lib/layout/editor.cpp | 2 +- lib/layout/edtbuf.cpp | 58 +++++++++++++++++++++++++++---------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/lib/layout/editor.cpp b/lib/layout/editor.cpp index e658312108f7..67729bea9666 100644 --- a/lib/layout/editor.cpp +++ b/lib/layout/editor.cpp @@ -1462,7 +1462,7 @@ XP_Bool EDT_GetToggleListState(MWContext *pContext, intn iTagType) // Description list is a special case - it doesn't (and shouldn't) // have
  • items. It should contain
    (Desc.Title) and //
    (Desc. text) items. - if ( nParagraphFormat == P_LIST_ITEM || iTagType == P_DESC_LIST ) { + if ( nParagraphFormat == P_LIST_ITEM || iTagType == P_DESC_LIST || iTagType == P_BLOCKQUOTE ) { pData = EDT_GetListData(pContext); bIsMyList = ( pData && pData->iTagType == iTagType ); } diff --git a/lib/layout/edtbuf.cpp b/lib/layout/edtbuf.cpp index 44b7d6ae7f6c..83e0ae99602b 100644 --- a/lib/layout/edtbuf.cpp +++ b/lib/layout/edtbuf.cpp @@ -4405,7 +4405,6 @@ void CEditBuffer::MorphListContainer( TagType t ) void CEditBuffer::MorphListContainer2( TagType t, CEditSelection& /*selection*/ ) { - //TODO: HANDLE LISTS IN SELECTION EDT_ListData * pListData = GetListData(); if( !pListData ){ // We don't have container -- start one @@ -4444,60 +4443,77 @@ void CEditBuffer::ToggleList(intn iTagType) EndBatchChanges(); } } else { + GetSelection(selection); ToggleList2(iTagType, selection); } } +// TODO: HANDLE SELECTION -- SEE MorphContainerSelection // This doesn't seem to pay attention to selection - probably source of some bugs void CEditBuffer::ToggleList2(intn iTagType, CEditSelection& /*selection*/) { - EDT_ListData * pData = NULL; + EDT_ListData * pListData = NULL; TagType nParagraphFormat = GetParagraphFormatting(); XP_Bool bIsMyList = FALSE; - XP_Bool bIsDescList = FALSE; - if ( nParagraphFormat == P_LIST_ITEM || iTagType == P_DESC_LIST ) + if ( nParagraphFormat == P_LIST_ITEM || iTagType == P_DESC_LIST || iTagType == P_BLOCKQUOTE ) { - pData = GetListData(); - bIsMyList = ( pData && pData->iTagType == iTagType ); + pListData = GetListData(); + bIsMyList = ( pListData && pListData->iTagType == iTagType ); } - bIsDescList = bIsMyList && (iTagType == P_DESC_LIST); - if ( (nParagraphFormat == P_LIST_ITEM || bIsDescList) - && bIsMyList ) + if ( bIsMyList && + (nParagraphFormat == P_LIST_ITEM || + iTagType == P_DESC_LIST) ) { // This will remove any list container MorphContainer(P_NSDT); } + else if( bIsMyList && iTagType == P_BLOCKQUOTE ) + { + // Remove all indent levels + if( m_pCurrent ) + { + CEditContainerElement *pContainer; + CEditListElement *pList; + m_pCurrent->FindList(pContainer, pList); + TerminateList(pContainer); + Relayout( pContainer, 0, pContainer ); + } + } else { - if ( !pData ) + if ( !pListData ) { - // Create a numbered list item ONLY if not Description list + if( iTagType == P_BLOCKQUOTE ) + { + Indent(); + } + // Create a numbered list item ONLY if not Description list or BlockQuote // (This will automatically indent, i.e., create the list container) - if (nParagraphFormat != P_LIST_ITEM && iTagType != P_DESC_LIST) { + else if (nParagraphFormat != P_LIST_ITEM && iTagType != P_DESC_LIST ) + { MorphContainer(P_LIST_ITEM); } - pData = GetListData(); + pListData = GetListData(); } else if (nParagraphFormat == P_LIST_ITEM && iTagType == P_DESC_LIST ) { // We are converting an existing list item into // a description, so remove the list item MorphContainer(P_DESC_TITLE); - pData = GetListData(); + pListData = GetListData(); } - - if ( pData && (pData->iTagType != iTagType) ) + if ( pListData && (pListData->iTagType != iTagType) ) { - pData->iTagType = iTagType; - pData->eType = ED_LIST_TYPE_DEFAULT; - SetListData(pData); + pListData->iTagType = iTagType; + pListData->eType = ED_LIST_TYPE_DEFAULT; + SetListData(pListData); } } - if ( pData ) - EDT_FreeListData(pData); + if ( pListData ) + EDT_FreeListData(pListData); } void CEditBuffer::SetParagraphAlign( ED_Alignment eAlign ){