[Solved] How to stop "Adapt Row Height"?

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
Sulochana
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

[Solved] How to stop "Adapt Row Height"?

Post by Sulochana »

Hi,

I wrote a macro which copies and pastes data. Each time the paste function takes place, it takes a long time to process as a progress bar called “Adapt row height” is running.

Please tell me how to switch off this process using a macro command and how to switch this back on.

Thank you,

Sulochana
Last edited by Sulochana on Fri Jun 21, 2013 5:11 am, edited 2 times in total.
OpenOffice 3.1 on Windows 7
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: How to stop "Adapt Row Height"?

Post by hanya »

Code: Select all

Sub SwitchAdjustHeightEnabled
  ThisComponent.IsAdjustHeightEnabled = NOT ThisComponent.IsAdjustHeightEnabled
End Sub
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Sulochana
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

Re: How to stop "Adapt Row Height"?

Post by Sulochana »

Thanks a lot Hanya,

Does this command switch this back on as well? If used twice (at the beginning and at the end)?

Thanks a lot.

Sulochana
OpenOffice 3.1 on Windows 7
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: How to stop "Adapt Row Height"?

Post by hanya »

Yes.
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
Sulochana
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

Re: [SOLVED] How to stop "Adapt Row Height"?

Post by Sulochana »

Thanks a lot Hanya
OpenOffice 3.1 on Windows 7
snapey1979
Posts: 1
Joined: Fri Aug 09, 2013 4:05 pm

Re: [Solved] How to stop "Adapt Row Height"?

Post by snapey1979 »

Great tip Hanya. I have searched high and low for this answer - you win the most helpful tip on the web with regard to this issue :D

I don't know what makes the Adapt row Height so slow, but switching it off has made me a very happy man.
OpenOffice 3.4.1 on Windows (XP & 7)
the.yangist
Posts: 1
Joined: Mon Jan 05, 2015 10:54 pm

Re: [Solved] How to stop "Adapt Row Height"?

Post by the.yangist »

This is a great solution! Can this be converted into an add-on that toggles the Adapt Row Height activation on and off?
OpenOffice 4.1.1 on Windows 8
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] How to stop "Adapt Row Height"?

Post by hanya »

the.yangist wrote:This is a great solution! Can this be converted into an add-on that toggles the Adapt Row Height activation on and off?
I made experimental one. The extension adds View - Adjust Row Height entry under Value Highlighting entry. The state of the entry is not updated if IsAdjustHeightEnabled is changed from other macro or something.
Attachments
AdjustHeight-0.0.1.oxt.zip
Needs Python-UNO. Remove .zip file extension before installing the extension package
(3.6 KiB) Downloaded 368 times
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
hanya
Volunteer
Posts: 885
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: [Solved] How to stop "Adapt Row Height"?

Post by hanya »

Someone asked me about the way to change the adapt row height property before open exisiting file.
Instantiate service as new document and set the property before loading the file from the URL and then load the file into the existing document model. After that view, frame and model are connected each other.

Code: Select all

Sub LoadCalcDocumentWithoutAdjustHeight
  sURL = GetFileToOpen(Array("ODF Spreadsheet (*.ods)", "*.ods", "All", "*.*"))
  if sURL <> "" then LoadDocumentIfNotLoaded(sURL)
End Sub


Function LoadDocumentIfNotLoaded(sURL)
  doc = nothing
  components = StarDesktop.getComponents().createEnumeration()
  do while components.hasMoreElements()
    component = components.nextElement()
    if hasunointerfaces(component, "com.sun.star.lang.XServiceInfo") then
      if component.getURL() = sURL then
        doc = component
        exit do
      end if
    end if
  Loop
  if isnull(doc) then
    zLoadCalcDocumentWithoutAdjustHeightAsync(sURL)
  else
    ' if found, put it front
    doc.getCurrentController().getFrame().getContainerWindow().toFront()
  end if
End Function


Sub zLoadCalcDocumentWithoutAdjustHeightAsync(sURL As String)
  CreateUnoService("com.sun.star.awt.AsyncCallback").addCallback(_
    CreateUnoListener("zLoadCalcDocumentWithoutAdjustHeightAsync_", "com.sun.star.awt.XCallback"), _
    sURL)
End Sub


Sub zLoadCalcDocumentWithoutAdjustHeightAsync_notify(data)
  zLoadCalcDocumentWithProperties(data)
End Sub


' Load Calc document (OpenDocument Spreadsheet) without adjusting row height
' @param sURL          URL to load a Calc document, calc8 only
' @param bEnableAfter  enable adjusting row height after loading finished
Function zLoadCalcDocumentWithProperties(sURL As String, optional bEnableAfter As Boolean) As Variant
  if ismissing(bEnableAfter) then bEnableAfter = False
  ' create new frame to load the file
  frame = StarDesktop.findFrame("_blank", com.sun.star.frame.FrameSearchFlag.CREATE)
  ' set filter options
  Dim args(1) As new com.sun.star.beans.PropertyValue
  args(0).Name = "URL"
  args(0).Value = sURL
  args(1).Name = "FilterName"
  args(1).Value = "calc8"
  ' instantiate new document component
  doc = CreateUnoService("com.sun.star.sheet.SpreadsheetDocument")
  ' disable adjusting height after loading the document
  doc.IsAdjustHeightEnabled = False
  ' load document
  doc.load(args)
  ' setup
  controller = doc.createViewController("Default", args, frame)
  controller.attachModel(doc)
  doc.connectController(controller)
  frame.setComponent(controller.ComponentWindow, controller)
  controller.attachFrame(frame)
  doc.setCurrentController(controller)
  frame.getContainerWindow().setVisible(True) ' show document window
  if bEnableAfter then doc.IsAdjustHeightEnabled = True
  zLoadCalcDocumentWithProperties = doc
End Function


Function GetFileToOpen(optional aFilters as variant) As String
  if ismissing(aFilters) then aFilters = array()
  sURL = ""
  oFilePicker = createUnoService("com.sun.star.ui.dialogs.FilePicker")
  oFilePicker.initialize(Array(com.sun.star.ui.dialogs.TemplateDescription.FILEOPEN_SIMPLE))
  'oFilePicker.setDisplayDirectory("")
  for i = 0 to ubound(aFilters) step 2
    oFilePicker.appendFilter(aFilters(i), aFilters(i+1))
  next
  if oFilePicker.execute() = 1 then
    sFiles = oFilePicker.getFiles()
    sURL = sFiles(0)
  end if
  GetFileToOpen = sURL
End Function
Please, edit this thread's initial post and add "[Solved]" to the subject line if your problem has been solved.
Apache OpenOffice 4-dev on Xubuntu 14.04
eddyparkinson
Posts: 10
Joined: Thu Mar 09, 2017 5:08 am

Re: [Solved] How to stop "Adapt Row Height"?

Post by eddyparkinson »

Adapt row height property before open exisiting file
How to use the code posted by @hanya

TL;DR Run "LoadCalcDocumentWithoutAdjustHeight"


- copy the code
- in openoffice calc - menu->tools->macros->organise macros->open office basic
- Select Macro form->My Macros -> Standard -> Module1 and click "Edit"
- past the code
- Run function "LoadCalcDocumentWithoutAdjustHeight"

Menu
See - Binding to a Menu in viewtopic.php?f=74&t=12882
Open Office 4.1.2 - Windows 10
eddyparkinson
Posts: 10
Joined: Thu Mar 09, 2017 5:08 am

Re: [Solved] How to stop "Adapt Row Height"?

Post by eddyparkinson »

To enable macros

in "Function zLoadCalcDocumentWithProperties" change

Code: Select all

  Dim args(2) As new com.sun.star.beans.PropertyValue
  args(0).Name = "URL"
  args(0).Value = sURL
  args(1).Name = "FilterName"
  args(1).Value = "calc8"
  args(2).Name = "MacroExecutionMode"
  args(2).Value = 4

from: "OpenOffice.org Macro document - Andrew Pitonyak" www.pitonyak.org/AndrewMacro.odt
Open Office 4.1.2 - Windows 10
Post Reply