Using MRI

The Application Programming Interface and the OASIS Open Document Format

Using MRI

Postby mike phillips » Wed Jan 15, 2014 12:26 pm

Having been urged to use MRI I need some help with this please!

If I use MRI <-Selection on a highlighted part of code I get a box simply saying 'void'

If I write this code
Code: Select all   Expand viewCollapse view
REM  *****  BASIC  *****

Option Explicit

Global oMRI As Object

sub Main
  Globalscope.BasicLibraries.LoadLibrary("MRILib")
  oMRI = CreateUnoService("mytools.Mri")
  oMRI.inspect(CellProtection)
end sub


it tells me the variable is not set.

Help please?
OpenOffice 4 on Windows 7
mike phillips
 
Posts: 118
Joined: Wed Feb 15, 2012 9:35 pm

Re: Using MRI

Postby RPG » Wed Jan 15, 2014 12:32 pm

Hello

Read the help file about: option explicit
And the variable does not have value.

Romke
LibreOffice 6.3.3.2 on openSUSE Leap 15
RPG
Volunteer
 
Posts: 2193
Joined: Tue Apr 14, 2009 7:15 pm
Location: Netherlands

Re: Using MRI

Postby Villeroy » Wed Jan 15, 2014 12:52 pm

That macro has been written already. See "MyMacros".MRILib>Module1.Mri
It takes an optional argument which is the object you want to inspect. If that object is missing, Mri will inspect the StarDesktop variable (the collection of all frames).

Code: Select all   Expand viewCollapse view
GlobalScope.BasicLibraries.loadLibrary("MRILib")
sh = ThisComponent.Sheets.getByIndex(0)
cell = sh.getCellByPosition(0,0)
CellProtection = cell.CellProtection
MRILib.Module1.Mri(CellProtection)

But with MRI you don't need any additional code. Just select some cell(s) and call Tools>Add-ons>MRI(selection). Then double-click the line starting with "CellProtection".
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04, no OpenOffice, LibreOffice 6.4
User avatar
Villeroy
Volunteer
 
Posts: 28342
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Using MRI

Postby mike phillips » Wed Jan 15, 2014 7:16 pm

Thank you, Villeroy. Great help.

It appears that Cell protection does not offer any way of recognising the original protection set up on the sheet - it was set to allow access to unlocked cells only. After running
Code: Select all   Expand viewCollapse view
Sheet.setPropertyValue( "CellProtection", tUnProtect )
Sheet.Protect("")

it appears to lock ALL cells. Is there a way to 'honour' the original protection criteria?
OpenOffice 4 on Windows 7
mike phillips
 
Posts: 118
Joined: Wed Feb 15, 2012 9:35 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 1 guest