Page 1 of 1
[Solved] How to stop "Adapt Row Height"?
Posted: Thu Jun 20, 2013 8:28 am
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
Re: How to stop "Adapt Row Height"?
Posted: Thu Jun 20, 2013 11:32 am
by hanya
Code: Select all
Sub SwitchAdjustHeightEnabled
ThisComponent.IsAdjustHeightEnabled = NOT ThisComponent.IsAdjustHeightEnabled
End Sub
Re: How to stop "Adapt Row Height"?
Posted: Thu Jun 20, 2013 1:16 pm
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
Re: How to stop "Adapt Row Height"?
Posted: Thu Jun 20, 2013 2:42 pm
by hanya
Yes.
Re: [SOLVED] How to stop "Adapt Row Height"?
Posted: Fri Jun 21, 2013 5:12 am
by Sulochana
Thanks a lot Hanya
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Fri Aug 09, 2013 4:12 pm
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
I don't know what makes the Adapt row Height so slow, but switching it off has made me a very happy man.
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Mon Jan 05, 2015 10:57 pm
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?
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Sun Jan 18, 2015 4:18 pm
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.
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Sun Mar 15, 2015 10:10 am
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
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Thu Jul 20, 2017 2:38 am
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
Re: [Solved] How to stop "Adapt Row Height"?
Posted: Fri Jul 21, 2017 2:41 am
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