Protected sections

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
arui1977
Posts: 1
Joined: Mon Oct 06, 2008 9:04 am

Protected sections

Post by arui1977 »

I'm currently integrating OOO (2.4) in a java project and I have two questions:

1. When I declare a section protected I can't replace text with

Code: Select all

xReplaceDescr.setSearchString("$"+key );
xReplaceDescr.setReplaceString(values.get(key).toString() );
xReplaceable.replaceAll( xReplaceDescr );
How can I replace Text in a protected section ?

2. when I use

Code: Select all

xViewCursorSupplier =( XTextViewCursorSupplier )UnoRuntime.queryInterface (  XTextViewCursorSupplier.class, mxDoc.getCurrentController() );
xViewCursor = xViewCursorSupplier.getViewCursor();
to get the current cursor-position. Is it possible to detect a protected section, to prevent paste text with

Code: Select all

XTextRange cursorStartRange = xViewCursor.getEnd(); 
cursorStartRange.setString ( text );
?

Thanks for your help.

Andreas
OOo 2.4.X on Ms Windows XP
cornouws
Posts: 44
Joined: Mon Jan 14, 2008 10:43 pm

Re: Protected sections

Post by cornouws »

Hi Andreas,

I'm not using Java, but can give you some basic code. I expect you can use it to find the right objects and properties, to detect if section is protected. And if so, to temporarely unprotect.

Code: Select all

	If ThisComponent.TextSections.Count > 0 Then
		msgBox ThisComponent.TextSections.getByIndex(0).isProtected
	End If
	oViewCursor = ThisComponent.getCurrentController.getViewCursor()
	If Not IsEmpty (oViewCursor.TextSection) Then
		msgbox oViewCursor.TextSection.isProtected
	Else
		msgBox "No section"
	End If

Regards,
Cor
The most recent LibreOffice and OpenOffice.org on Ubuntu - sometimes on Windows XP
Post Reply