Include text boxes in Word Count

Thankfully, LibreOffice offers word count directly in the pane below the text, which is amazing and convenient. However, I noticed that text boxes are always excluded in this count, which is understandable. However, is there a way to be able to get a word count that includes all the text boxes in the particular document?

Details:
OS → Windows 10 Home
LO Version → 5.3 (Latest Updates are Installed)
Program → Writer

Thank you! Help is appreciated.

yes this is possible using a macro, such as:

Function WordCount_Total() As Long
	Dim lCount As Long
	lCount = ThisComponent.WordCount			REM standard document word count.
	lCount = lCount + WordCount_Textboxes()		REM include word count from textboxes.
	WordCount_Total = lCount
End Function

Function WordCount_Textboxes() As Long
REM This function returns the total number of words within all Textboxes in the current document.
	Dim lCount As Long, oShape as Object
	Dim oDrawpage : oDrawpage = ThisComponent.getDrawPage()
	For i = 0 To oDrawpage.getCount() - 1
		oShape = oDrawPage.getByIndex( i )
		If HasUNOInterfaces( oShape, "com.sun.star.text.XTextAppend" ) Then
			lCount = lCount + WordCount_String( oShape.getString() )
		End If
	Next
	WordCount_Textboxes = lCount
End Function

Function WordCount_String( sString$ ) As Long
REM Returns the number of words in the specified string.
	Dim i As Long, j As Long, lCount As Long
	Dim sWordList() As String
	Dim sSeparators() As String : sSeparators = Array( chr(9), chr(13), chr(32) )
	For i = 0 To Ubound( sSeparators )
		sWordList = Split( sString, sSeparators( i ) )
		If Ubound( sWordList ) > 0 Then
			For j = 0 To Ubound( sWordList )
				If sWordList( j ) <> "" Then lCount = 1 + lCount
			Next
		End If
	Next
	WordCount_String = lCount
End Function

HTH, lib

I’d advise you to try to enhance the existing functionality in LO code, esp. given that you already have working code. It’d be easy to port this to c++, and I’d (we’d) provide you necessary help to get you going. Just open a RFE at Bugzilla, assign it to yourself and join #libreoffice-dev at FreeNode.