Show the templatename on status bar

I am trying to show the template-name next to current style name on status bar. This code works. It shows the current template name (same as File - Properties - General - Template:) but replace all other items on status bar.

Function ProgressBar
  ProgressBar = ThisComponent.CurrentController.StatusIndicator
End Function

Sub StatusText()
  Dim sInformation 
  Dim iLen as Integer
  Dim iRest As Integer
  sInformation = ThisComponent.getDocumentProperties().TemplateName
  iLen=Len(sInformation)
  iRest=350-iLen
  ProgressBar.start(sInformation+SPACE(iRest),0)
End Sub

I got this code from “Useful Macro Information For OpenOffice.org By Andrew Pitonyak”. It is working, but it does not show any other items on status bar. I need TemplateName next to style name.

The ProgressBar is for display the state of a process. It will be appeared instead of the default Status indicator (you must use RESET and END to display the default informations again):

REM  *****  BASIC  *****

Function ProgressBar
  ProgressBar = ThisComponent.CurrentController.StatusIndicator
End Function

Sub StatusText()
 Dim sInformation 
 Dim iLen as Integer
 Dim iRest As Integer
  
	sInformation = "Done: "
  
'Print sInformation ' test only
'xray ProgressBar	'test only
  
	ProgressBar.start(sInformation,100)
	For i = 0 to 100		
		wait 10
		ProgressValue = i
		ProgressBar.text = sInformation + str(Progressvalue) + "%"
		ProgressBar.value = ProgressValue
	next i  	
  	ProgressBar.value = 0
	ProgressBar.reset
	ProgressBar.end
End Sub

My sample contains a simple FOR cycle, but you can assign the real percent value of your macro project what requests a long time. (You can do it without a FOR cycle, in small or large steps) The progress bar will inform the user how many percent is done of the progress/process.
.
Do you use one of excellent Object inspection tools: XrayTool or MRI? By usage of them you will able to list and examine the existing Properties and Methods of the programming objects, like the ProgressBar in your sample.
.
Progressbar.ods (10.5 KB)

I understood that “ProgressBar” is the wrong choice here for the reasons you explained. The question, however is “How to display current template name in status bar”?

Crossposted:

It would be more logical to reflect the name of the template in the title of the window, this is easy to do using macros.

In that case the filename will be replaced with template-name and that is as bad as replacing status bar. I guess there is no easy solution, even crossposting did not help!

Bolivar can carry double. :slightly_smiling_face:

ThisComponent.Title= ThisComponent.Title & "(template name: " & ThisComponent.DocumentProperties.TemplateName & ")"

No.
The title bar will show the string you assign to it. Something like
fn=something.odt&tn=mytemplate.ott might be a good choice
Personally I prefer to show even more information there.

Please study this post of the bugreport site. Try to apply the suggestion to the Calc. Maybe you will able to change the statusbar of the Calc with or without macro:

https://bugs.documentfoundation.org/show_bug.cgi?id=92406#c15

Since a document template does not change (generally; but you can decide otherwise), I don’t see the interest of displaying a constant information at all time.

If you want to get reminded about the template, you can File>Properties, General tab.

Remember that when you change template contents, mainly styles, the name remains the same but the appearance of your document is updated next time you open it.

So, your question may be a theoretical one, just to learn how to control the UI through macros but has little interest in taming Writer

I am happy with the workaround of showing the template name next to filename in title. But I “really” wish I was able to place it next to style name in the status bar. Open source software lets me customize to my heart’s content. I hope the feature request (Bug 92406) is accepted.