Protected sections

The Application Programming Interface and the OASIS Open Document Format

Protected sections

Postby arui1977 » Mon Oct 06, 2008 9:41 am

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   Expand viewCollapse view
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   Expand viewCollapse view
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   Expand viewCollapse view
XTextRange cursorStartRange = xViewCursor.getEnd();
cursorStartRange.setString ( text );


Thanks for your help.

OOo 2.4.X on Ms Windows XP
Posts: 1
Joined: Mon Oct 06, 2008 9:04 am

Re: Protected sections

Postby cornouws » Sat Oct 18, 2008 10:12 pm

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   Expand viewCollapse view
   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
      msgBox "No section"
   End If

The most recent LibreOffice and on Ubuntu - sometimes on Windows XP
Posts: 44
Joined: Mon Jan 14, 2008 10:43 pm

Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest