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

Creating a macro - Writing a Script - Using the API

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

Postby Sulochana » Thu Jun 20, 2013 8:28 am

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
Sulochana
 
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

Re: How to stop "Adapt Row Height"?

Postby hanya » Thu Jun 20, 2013 11:32 am

Code: Select all   Expand viewCollapse view
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
hanya
Volunteer
 
Posts: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

Re: How to stop "Adapt Row Height"?

Postby Sulochana » Thu Jun 20, 2013 1:16 pm

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
Sulochana
 
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

Re: How to stop "Adapt Row Height"?

Postby hanya » Thu Jun 20, 2013 2:42 pm

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
hanya
Volunteer
 
Posts: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby Sulochana » Fri Jun 21, 2013 5:12 am

Thanks a lot Hanya
OpenOffice 3.1 on Windows 7
Sulochana
 
Posts: 17
Joined: Sat Jun 08, 2013 5:53 am

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

Postby snapey1979 » Fri Aug 09, 2013 4:12 pm

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)
snapey1979
 
Posts: 1
Joined: Fri Aug 09, 2013 4:05 pm

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

Postby the.yangist » Mon Jan 05, 2015 10:57 pm

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
the.yangist
 
Posts: 1
Joined: Mon Jan 05, 2015 10:54 pm

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

Postby hanya » Sun Jan 18, 2015 4:18 pm

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 109 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: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby hanya » Sun Mar 15, 2015 10:10 am

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   Expand viewCollapse view
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
hanya
Volunteer
 
Posts: 879
Joined: Fri Nov 23, 2007 9:27 am
Location: Japan

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

Postby eddyparkinson » Thu Jul 20, 2017 2:38 am

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 https://forum.openoffice.org/en/forum/v ... 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"?

Postby eddyparkinson » Fri Jul 21, 2017 2:41 am

To enable macros

in "Function zLoadCalcDocumentWithProperties" change

Code: Select all   Expand viewCollapse view
  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
eddyparkinson
 
Posts: 10
Joined: Thu Mar 09, 2017 5:08 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests