첨부 실행 코드는 나눔고딕코딩 폰트를 사용합니다.
유용한 소스 코드가 있으면 icodebroker@naver.com으로 보내주시면 감사합니다.
블로그 자료는 자유롭게 사용하세요.

728x90
반응형
using DevExpress.XtraRichEdit.API.Native;

#region 추상 넘버링 리스트 생성하기 - CreateAbstractNumberingList(document, numberingType)

/// <summary>
/// 추상 넘버링 리스트 생성하기
/// </summary>
/// <param name="document">Document 객체</param>
/// <param name="numberingType">NumberingType 객체</param>
/// <returns>AbstractNumberingList 객체</returns>
private AbstractNumberingList CreateAbstractNumberingList(Document document, NumberingType numberingType)
{
    AbstractNumberingList abstractNumberingList = document.AbstractNumberingLists.Add();

    abstractNumberingList.NumberingType = numberingType;

    return abstractNumberingList;
}

#endregion

#region 리스트 레벨 설정하기 - SetListLevel(abstractNumberingList, levelIndex, leftIndent, firstLineIndent, numberingFormat, displayFormatString)

/// <summary>
/// 리스트 레벨 설정하기
/// </summary>
/// <param name="abstractNumberingList">AbstractNumberingList 객체</param>
/// <param name="levelIndex">레벨 인덱스</param>
/// <param name="leftIndent">왼쪽 들여쓰기</param>
/// <param name="firstLineIndent">첫번째 라인 들여쓰기</param>
/// <param name="numberingFormat">NumberingFormat 객체</param>
/// <param name="displayFormatString">디스플레이 포맷 문자열</param>
private void SetListLevel
(
    AbstractNumberingList abstractNumberingList,
    int                   levelIndex,
    int                   leftIndent,
    int                   firstLineIndent,
    NumberingFormat       numberingFormat,
    string                displayFormatString
)
{
    ListLevel listLevel = abstractNumberingList.Levels[levelIndex];

    listLevel.ParagraphProperties.LeftIndent          = leftIndent;
    listLevel.ParagraphProperties.FirstLineIndentType = ParagraphFirstLineIndent.Hanging;
    listLevel.ParagraphProperties.FirstLineIndent     = firstLineIndent;
    listLevel.Start                                   = 1;
    listLevel.NumberingFormat                         = numberingFormat;
    listLevel.DisplayFormatString                     = displayFormatString;
}

#endregion

#region 넘버링 리스트 생성하기 - CreateNumberingList(document, abstractNumberingListIndex)

/// <summary>
/// 넘버링 리스트 생성하기
/// </summary>
/// <param name="document">Document 객체</param>
/// <param name="abstractNumberingListIndex">추상 넘버링 리스트 인덱스</param>
/// <returns>NumberingList 객체</returns>
private NumberingList CreateNumberingList(Document document, int abstractNumberingListIndex)
{
    NumberingList numberingList = document.NumberingLists.Add(abstractNumberingListIndex);

    return numberingList;
}

#endregion

#region 넘버링 리스트 패러그래프 추가하기 - AppendNumberingListParagraph(document, listIndex, listLevel, text)

/// <summary>
/// 넘버링 리스트 패러그래프 추가하기
/// </summary>
/// <param name="document">Document 객체</param>
/// <param name="listIndex">리스트 인덱스</param>
/// <param name="listLevel">리스트 레벨</param>
/// <param name="text">텍스트</param>
private void AppendNumberingListParagraph(Document document, int listIndex, int listLevel, string text)
{
    document.AppendText(text);

    document.AppendParagraph();

    Paragraph paragraph = document.Paragraphs[document.Paragraphs.Count - 2];

    paragraph.ListIndex = listIndex;
    paragraph.ListLevel = listLevel;
}

#endregion

...

Document document = this.richEditControl.Document;

document.BeginUpdate();

AbstractNumberingList abstractNumberingList = CreateAbstractNumberingList(document, NumberingType.MultiLevel);

SetListLevel(abstractNumberingList, 0, 150, 75 , NumberingFormat.Decimal                  , "{0}"          );
SetListLevel(abstractNumberingList, 1, 300, 150, NumberingFormat.DecimalEnclosedParenthses, "{0}→{1}"     );
SetListLevel(abstractNumberingList, 2, 450, 220, NumberingFormat.LowerRoman               , "{0}→{1}→{2}");

int listIndex = abstractNumberingList.Index;

NumberingList numberingList = CreateNumberingList(document, listIndex);

AppendNumberingListParagraph(document, listIndex, 0, "Level 0 Paragraph 00");
AppendNumberingListParagraph(document, listIndex, 0, "Level 0 Paragraph 01");
AppendNumberingListParagraph(document, listIndex, 0, "Level 0 Paragraph 02");
AppendNumberingListParagraph(document, listIndex, 1, "Level 1 Paragraph 03");
AppendNumberingListParagraph(document, listIndex, 1, "Level 1 Paragraph 04");
AppendNumberingListParagraph(document, listIndex, 2, "Level 2 Paragraph 05");
AppendNumberingListParagraph(document, listIndex, 2, "Level 2 Paragraph 06");
AppendNumberingListParagraph(document, listIndex, 0, "Level 0 Paragraph 07");
AppendNumberingListParagraph(document, listIndex, 1, "Level 1 Paragraph 08");
AppendNumberingListParagraph(document, listIndex, 1, "Level 1 Paragraph 09");
AppendNumberingListParagraph(document, listIndex, 0, "Level 0 Paragraph 10");

document.EndUpdate();
728x90
반응형
Posted by 사용자 icodebroker

댓글을 달아 주세요