1 /************************************************************************/
2 /* */
3 /* Manage note properties. */
4 /* */
5 /************************************************************************/
6
7 # include "docBaseConfig.h"
8
9 # include <appDebugon.h>
10
11 # include <utilPropMask.h>
12
13 # include "docTreeType.h"
14 # include "docNoteProperties.h"
15
docInitNoteProperties(NoteProperties * np)16 void docInitNoteProperties( NoteProperties * np )
17 {
18 utilInitMemoryBuffer( &(np->npFixedText) );
19 np->npTreeType= DOCinFOOTNOTE;
20 np->npAutoNumber= 1;
21 }
22
docCleanNoteProperties(NoteProperties * np)23 void docCleanNoteProperties( NoteProperties * np )
24 {
25 utilCleanMemoryBuffer( &(np->npFixedText) );
26 }
27
docCopyNoteProperties(NoteProperties * to,const NoteProperties * from)28 int docCopyNoteProperties( NoteProperties * to,
29 const NoteProperties * from )
30 {
31 if ( utilCopyMemoryBuffer( &(to->npFixedText), &(from->npFixedText) ) )
32 { LDEB(1); return -1; }
33
34 to->npTreeType= from->npTreeType;
35 to->npAutoNumber= from->npAutoNumber;
36
37 return 0;
38 }
39
docNotePropertyDifference(PropertyMask * pDifMask,const NoteProperties * np1,const PropertyMask * cmpMask,const NoteProperties * np2)40 int docNotePropertyDifference( PropertyMask * pDifMask,
41 const NoteProperties * np1,
42 const PropertyMask * cmpMask,
43 const NoteProperties * np2 )
44 {
45 PropertyMask difMask;
46
47 utilPropMaskClear( &difMask );
48
49 if ( PROPmaskISSET( cmpMask, NOTEpropFIXED_TEXT ) )
50 {
51 if ( ! utilEqualMemoryBuffer( &(np1->npFixedText),
52 &(np2->npFixedText) ) )
53 {
54 PROPmaskADD( &difMask, NOTEpropFIXED_TEXT );
55 }
56 }
57
58 if ( PROPmaskISSET( cmpMask, NOTEpropTREE_TYPE ) )
59 {
60 if ( np1->npTreeType != np2->npTreeType )
61 {
62 PROPmaskADD( &difMask, NOTEpropTREE_TYPE );
63 }
64 }
65
66 if ( PROPmaskISSET( cmpMask, NOTEpropAUTO_NUMBER ) )
67 {
68 if ( np1->npAutoNumber != np2->npAutoNumber )
69 {
70 PROPmaskADD( &difMask, NOTEpropAUTO_NUMBER );
71 }
72 }
73
74 *pDifMask= difMask;
75 return 0;
76 }
77
docUpdNoteProperties(PropertyMask * npDoneMask,NoteProperties * npTo,const PropertyMask * npSetMask,const NoteProperties * npSet)78 int docUpdNoteProperties( PropertyMask * npDoneMask,
79 NoteProperties * npTo,
80 const PropertyMask * npSetMask,
81 const NoteProperties * npSet )
82 {
83 PropertyMask doneMask;
84
85 utilPropMaskClear( &doneMask );
86
87 if ( PROPmaskISSET( npSetMask, NOTEpropFIXED_TEXT ) )
88 {
89 if ( ! utilEqualMemoryBuffer( &(npTo->npFixedText),
90 &(npSet->npFixedText) ) )
91 {
92 if ( utilCopyMemoryBuffer( &(npTo->npFixedText),
93 &(npSet->npFixedText) ) )
94 { LDEB(1); return -1; }
95
96 PROPmaskADD( &doneMask, NOTEpropFIXED_TEXT );
97 }
98 }
99
100 if ( PROPmaskISSET( npSetMask, NOTEpropTREE_TYPE ) )
101 {
102 if ( npTo->npTreeType != npSet->npTreeType )
103 {
104 npTo->npTreeType= npSet->npTreeType;
105 PROPmaskADD( &doneMask, NOTEpropTREE_TYPE );
106 }
107 }
108
109 if ( PROPmaskISSET( npSetMask, NOTEpropAUTO_NUMBER ) )
110 {
111 if ( npTo->npAutoNumber != npSet->npAutoNumber )
112 {
113 npTo->npAutoNumber= npSet->npAutoNumber;
114 PROPmaskADD( &doneMask, NOTEpropAUTO_NUMBER );
115 }
116 }
117
118 if ( npDoneMask )
119 { utilPropMaskOr( npDoneMask, npDoneMask, &doneMask); }
120
121 return 0;
122 }
123
124