1 /************************************************************************/
2 /*									*/
3 /*  Shift the indentation level of the selection.			*/
4 /*									*/
5 /************************************************************************/
6 
7 #   include	"docEditConfig.h"
8 
9 #   include	<stddef.h>
10 #   include	<stdio.h>
11 #   include	<ctype.h>
12 
13 #   include	"docEdit.h"
14 #   include	<docTreeNode.h>
15 #   include	<docNodeTree.h>
16 #   include	<docDocumentList.h>
17 
18 #   include	<appDebugon.h>
19 
20 /************************************************************************/
21 /*									*/
22 /*  Increase/Decrease the indentation level of the paragraphs in the	*/
23 /*  selection.								*/
24 /*									*/
25 /************************************************************************/
26 
docEditShiftIndent(EditOperation * eo,int step)27 int docEditShiftIndent(		EditOperation *	eo,
28 				int		step )
29     {
30     int				rval= 0;
31 
32     BufferDocument *		bd= eo->eoDocument;
33 
34     BufferItem *		paraNode;
35 
36     ParagraphProperties		ppSet;
37 
38     docInitParagraphProperties( &ppSet );
39 
40     paraNode= eo->eoHeadDp.dpNode;
41     while( paraNode )
42 	{
43 	PropertyMask	ppDoneMask;
44 	PropertyMask	ppSetMask;
45 	int		apply= 0;
46 
47 	utilPropMaskClear( &ppDoneMask );
48 	utilPropMaskClear( &ppSetMask );
49 
50 	if  ( paraNode->biParaListOverride >= 1 )
51 	    {
52 	    struct ListOverride *	lo;
53 	    DocumentList *		dl;
54 	    int				ilvl;
55 
56 	    ilvl= paraNode->biParaListLevel;
57 	    ilvl += step;
58 
59 	    if  ( docGetListOfParagraph( &lo, &dl,
60 					    paraNode->biParaListOverride, bd ) )
61 		{ LDEB(paraNode->biParaListOverride); rval= -1; goto ready; }
62 
63 	    if  ( ilvl >= 0 )
64 		{
65 		if  ( ilvl < dl->dlLevelCount )
66 		    {
67 		    PROPmaskADD( &ppSetMask, PPpropLISTLEVEL );
68 
69 		    ppSet.ppListLevel= ilvl;
70 		    apply= 1;
71 		    }
72 		}
73 	    }
74 	else{
75 	    const DocumentProperties *	dp= &(bd->bdProperties);
76 
77 	    ppSet.ppLeftIndentTwips= paraNode->biParaLeftIndentTwips+
78 						step* dp->dpTabIntervalTwips;
79 
80 	    if  ( paraNode->biParaLeftIndentTwips > 0	&&
81 		  ppSet.ppLeftIndentTwips < 0		)
82 		{ ppSet.ppLeftIndentTwips= 0;	}
83 
84 	    if  ( ppSet.ppLeftIndentTwips >= 0 )
85 		{
86 		PROPmaskADD( &ppSetMask, PPpropLEFT_INDENT );
87 		apply= 1;
88 
89 		if  ( ppSet.ppLeftIndentTwips+ ppSet.ppFirstIndentTwips < 0 )
90 		    {
91 		    ppSet.ppFirstIndentTwips= -ppSet.ppLeftIndentTwips;
92 		    PROPmaskADD( &ppSetMask, PPpropFIRST_INDENT );
93 		    }
94 		}
95 	    }
96 
97 	if  ( apply )
98 	    {
99 	    if  ( docEditUpdParaProperties( eo, &ppDoneMask, paraNode,
100 				    &ppSetMask, &ppSet,
101 				    (const DocumentAttributeMap *)0 ) )
102 		{ LDEB(1); rval= -1; goto ready; }
103 
104 	    if  ( ! utilPropMaskIsEmpty( &ppDoneMask ) )
105 		{
106 		docEditIncludeNodeInReformatRange( eo, paraNode );
107 		}
108 	    }
109 
110 	if  ( paraNode == eo->eoTailDp.dpNode )
111 	    { break;	}
112 
113 	paraNode= docNextParagraph( paraNode );
114 	if  ( ! paraNode )
115 	    { XDEB(paraNode);	}
116 	}
117 
118   ready:
119 
120     docCleanParagraphProperties( &ppSet );
121 
122     return rval;
123     }
124 
125