@@ -150,15 +150,15 @@ static void AddPropertyIfNotEmpty(Dictionary<string, object?> properties, string
150150 }
151151 else if ( property . VTInt32 != null )
152152 {
153- value = int . Parse ( property . VTInt32 . Text ! ) ;
153+ value = int . Parse ( property . VTInt32 . Text ) ;
154154 }
155155 else if ( property . VTFloat != null )
156156 {
157- value = float . Parse ( property . VTFloat . Text ! ) ;
157+ value = float . Parse ( property . VTFloat . Text ) ;
158158 }
159159 else if ( property . VTDouble != null )
160160 {
161- value = double . Parse ( property . VTDouble . Text ! ) ;
161+ value = double . Parse ( property . VTDouble . Text ) ;
162162 }
163163 else if ( property . VTDate != null )
164164 {
@@ -177,15 +177,15 @@ static void AddPropertyIfNotEmpty(Dictionary<string, object?> properties, string
177177
178178 static string ? GetWordDocumentText ( WordprocessingDocument document )
179179 {
180- var mainPart = document . MainDocumentPart ;
181- if ( mainPart ? . Document . Body == null )
180+ var body = document . MainDocumentPart ? . Document . Body ;
181+
182+ if ( body == null )
182183 {
183184 return null ;
184185 }
185186
186187 var builder = new StringBuilder ( ) ;
187-
188- foreach ( var paragraph in mainPart . Document . Body . Elements < Paragraph > ( ) )
188+ foreach ( var paragraph in body . Elements < Paragraph > ( ) )
189189 {
190190 var paragraphText = GetWordParagraphText ( paragraph ) ;
191191 if ( ! string . IsNullOrEmpty ( paragraphText ) )
@@ -195,7 +195,7 @@ static void AddPropertyIfNotEmpty(Dictionary<string, object?> properties, string
195195 }
196196
197197 // Also get text from tables
198- foreach ( var table in mainPart . Document . Body . Elements < WordTable > ( ) )
198+ foreach ( var table in body . Elements < WordTable > ( ) )
199199 {
200200 foreach ( var row in table . Elements < TableRow > ( ) )
201201 {
@@ -222,7 +222,12 @@ static void AddPropertyIfNotEmpty(Dictionary<string, object?> properties, string
222222 }
223223 }
224224
225- var result = builder . ToString ( ) . TrimEnd ( ) ;
225+ builder . TrimEnd ( ) ;
226+ if ( builder . Length == 0 )
227+ {
228+ return null ;
229+ }
230+ var result = builder . ToString ( ) ;
226231 return string . IsNullOrEmpty ( result ) ? null : result ;
227232 }
228233
@@ -244,9 +249,9 @@ static string GetWordParagraphText(Paragraph paragraph)
244249 }
245250
246251 // Handle breaks
247- foreach ( var br in run . Elements < WordBreak > ( ) )
252+ foreach ( var wordBreak in run . Elements < WordBreak > ( ) )
248253 {
249- if ( br . Type ? . Value == BreakValues . Page )
254+ if ( wordBreak . Type ? . Value == BreakValues . Page )
250255 {
251256 builder . AppendLine ( ) ;
252257 builder . AppendLine ( "--- Page Break ---" ) ;
0 commit comments