OpenOffice Base - how to change height of Table Control in Macro? - openoffice.org

I've got Table Control in Libre/OpenOffice Base form which is filled dynamically.
I want to change height of it to match number of rows.
How to do it?
I've tried changing getSize() / setSize(), and height property but I'm getting:
Property or method not found: getSize
My code:
oTable = oForm.GetByName("MySubForm").GetByName("MyTable")
oTable.getSize()
Visualisation:
http://i.imgur.com/IHi75.png
About this Table Control as it is named in Base - in debugger it's com.star.comp.forms.OGridControlModel, in content.xml it's listed as com.sun.star.form.component.GridControl

Your problem is the Table object has no height, the height is based on the number of rows (as well as the TopMargin and BottomMargin).
Every row has it's own Height property.
If you want a Table's height you need to sum the Height of all of the rows. Tables have TopMargin and BottomMargin properties that effect ?perceived? height as well.
Rows = Table.getRows
For I = 0 To Rows.getCount() - 1
Row = Rows.getByIndex(I)
CurrentHeight = CurrentHeight + Row.Height
Next
If you want to set a Table's height you need to either add/remove rows or change the Height of the current rows.
Rows.insertByIndex(Rows.getCount(), 1)
Row = Rows.getByIndex(Rows.getCount() - 1)
Row.IsAutoHeight = False
Row.Height = 1000
You can look at the full documentation online.
http://wiki.services.openoffice.org/wiki/Documentation/BASIC_Guide/More_Than_Text

Related

Multicolumn list with flexible columns width - iOS

I want to create list with two columns. Text in first column should be aligned to left and text in second column should be aligned to right. Space between columns should be constant. Different cases depends on texts length should be covered:
1.
Text 123
TextText 12
Tex 123
Text 1
Te 123456
T 12
Te 1234
Te 1
Text 123
TextText 12
TextTextTextTextText 123
Text 1
Both columns should have flexible width depends on the longest text. They also should have some minimum width so it will not be completely invisible if text in other column will be too long. Whole list also should have flexible width, of course there is some max width and then text in first column should be divided into lines. I don't want to divide into lines text in second column as long as I don't have to.
How to create such list?
I try to use for it two stack views one next to the other. These two stack views I have in my custom control. My custom control is added to container view using xib and have constraints equals to 0 for top, leading and bottom and greater or equals 0 for trailing. To these stack views I add labels programatically and I also set content hugging priority for them (first label has lower priority than second one). One think stil doesn't work, first stack view is as width as first label in this stack view. It doesn't change his width when other labels with longer texts are added. Is it possible to have working solution without calculating stack views width manually?
private void Initialize()
{
_firstStackView = new UIStackView
{
TranslatesAutoresizingMaskIntoConstraints = false,
Axis = UILayoutConstraintAxis.Vertical,
Spacing = 4
};
_secondStackView = new UIStackView
{
TranslatesAutoresizingMaskIntoConstraints = false,
Axis = UILayoutConstraintAxis.Vertical,
Spacing = 4,
Alignment = UIStackViewAlignment.Trailing
};
Add(_firstStackView);
Add(_secondStackView);
AddConstraints();
}
private void AddConstraints()
{
NSLayoutConstraint.ActivateConstraints(
new[]
{
_firstStackView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor),
_secondStackView.LeadingAnchor.ConstraintEqualTo(_firstStackView.TrailingAnchor, 20),
TrailingAnchor.ConstraintEqualTo(_secondStackView.TrailingAnchor),
_firstStackView.TopAnchor.ConstraintEqualTo(TopAnchor),
_firstStackView.BottomAnchor.ConstraintEqualTo(BottomAnchor),
_secondStackView.CenterYAnchor.ConstraintEqualTo(_firstStackView.CenterYAnchor),
_secondStackView.WidthAnchor.ConstraintGreaterThanOrEqualTo(WidthAnchor, 0.25f),
_firstStackView.WidthAnchor.ConstraintGreaterThanOrEqualTo(WidthAnchor, 0.25f),
});
}
You can use UICollectionView to create list with two columns. Space between columns and grid size can be adjusted by changing UICollectionViewLayout.
Implement text adaptive width and height:
Instantiate UILabel
Set the UILabel property to get the text content and font
Calculate the size according to text and font
Use CGSize to set the maximum width you want
Set the frame according to the size
You can see some useful info here
For more details, you can refer to the following doc:
Collection Views in Xamarin.iOS | Microsoft Docs

Whats wrong with changing the tableview height with bottom constraint

I have a parent view which has a tableview and tableviews leading,trailing,top,bottom is zero.
and I have a label to show if there are no records ... to show a message and I have vertically and horizontally centered it.
Based on content size of tableview I have to change the parentview's height and i can't directly do because there is no height property defined for parent view .. only leading,trailing,top and bottom property.
Now I have to change the bottom property value with respect to tables content size
if there are no records have to set the bottom constraint to higher value so that parent view height reduces
(Xamarin c# but constraints are same as iOS objective c or swift no change though)
if(vuParent.Frame.Height - tblMine.ContentSize.Height > 0 && !tblMine.Hidden && tblMine.ContentSize.Height!=0)
{
constraintBottomvuParent.Constant = 10 + vuParent.Frame.Height - tblMine.ContentSize.Height;
}
else if(vuParent.Frame.Height - tblMine.ContentSize.Height < 0)
{
constraintBottomvuParent.Constant = 10;
}else
{
constraintBottomvuParent.Constant = 200;
}
if there is any better way kindly let me know
Thanks

Popup View with Header-TableView-Footer and AutoLayout Not Working

Context:
I have a pop up view that contains a tableview. I would like the pop up view to be less than the whole height of the screen but would like the tableview to scale with the number of rows it has. (If the table view contains 2 rows then it would fit those 2 rows and would not scroll, if the table view has 30 rows it will max out at the height of the screen and allow scrolling).
View Hierarchy:
- viewContainer (clear background, whole view)
-- viewPopUp (pop up container)
--- labelHeader
--- tableView
--- buttonOK
Constraints:
viewPopUp.centerY = viewContainer.centerY
viewPopUp.centerX = viewContainer.centerX
viewPopUp.leadingSpaceTo superView = 32 #750
viewPopUp.trailingSpaceTo superView = 32 #750
viewPopUp.width &lt= 300
viewPopUp.height &lt= 0.8 * viewContainer.height
labelHeader.topSpaceTo superView = 0
labelHeader.leadingSpaceTo superView = 0
labelHeader.trailingSpaceTo superView = 0
labelHeader.bottomSpaceTo tableView = 0
labelHeader.height = 33
tableView.topSpaceTo labelHeader = 0
tableView.leadingSpaceTo superView = 0
tableView.trailingSpaceTo superView = 0
tableView.bottomSpaceTo buttonOk = 0
tableView.height &gt= 0
tableView.height = 0 #200
buttonOk.topSpaceTo tableView = 0
buttonOK.leadingSpaceTo superView = 0
buttonOK.trailingSpaceTo superView = 0
buttonOk.bottomSpaceTo superview = 0
buttonOK.height = 35
My Question:
In my UIViewController's viewDidLoad I know exactly how many rows will need to be represented in this tableView and I would like to add an additional constraint to have the tableView scale to this number as described in the context above.
I have tried tableView.height = count * rowHeight #500 but this does not update the view. I am not sure if I am not calling something like needsUpdateConstraints or needsUpdateLayout etc.
If I add the above constraint as required then it will update the tableView as expected but I receive constraint warnings and I believe this will break if it pushes the tableView past the size of the screen which is why I wanted to add it as a non-required constraint so it will drop off after it reaches the screen height.
Does anyone have any ideas on how I can reach this desired outcome?
Thanks!
Assuming that the height of the rows are always the same, you could calculate the height of the table, check it against the view height and set this value to a referenced height constraint added to the table view.
The code would look something like:
//calculate the height
var tableHeight = numberOfRows * rowHeight
if tableheight > maxHeight {
tableHeight = maxHeight
}
self.tableHeightConstraint.constant = tableHeight //this constraint should be a iboutlet
self.view.layoutIfNeeded()
Hope it helps.

iOS: `UICollectionview`, how to get a cell's `contentoffset` by it's `indexPath`

I'm using a UICollectionview with a circular layout. I'm trying to calculate the contentOffsetper item but with the circular layout the full contentsize does not seem match the content.
The collectionview's total contentSize = 780
The content offset of the last item = 397(?)
The content offset per item = 33(?)
Is there any way I can get the offset for an item by it's indexPath or at least the correct (397) value for the last item's in the collectionview? I got these values by testing and printing the contentoffset but I would like to calculate these numbers (33 and 397) by code without having to scroll.
So is there a way to calculate a cell's contentoffset(?) inside the collectionview by it's indexPath?
Thanks!
I found the problem, the contentsize of the scrollview is the size of the content + the size of the uicollectionview's frame. That was the reason the contentSize returned a larger size than the actual content was.
so:
(contentSizeX - collectionviews frame X) / cells = contentOffset per item
(780 - 383) / 12 => 33

After changing my UItableView's Height, my scroll does not work again. Cant reach data at the bottom

So I am currently very new to ios programming and I am having a bit of an issue with my table view. First I call my web API to get the data I required to populate my table View. Using the data I am able to calculate the number of rows and sections that would exist on my table view. After that I calculate the correct height of my table view. I change the height of my table view and reload the table. It looks like this
func tableViewHight(numberOfRows : Int)
{
let sectionHeight = CGFloat(30) * CGFloat(numberOfSections - 1)
//This is the height of all the sections in my tableview put together(except the first section since its height will always be 0)
let tableviewMaximumHeight = UIScreen.mainScreen().bounds.size.height - self.myTableView.frame.origin.y
//Maximum height would be the distance from the y position of my table view, all the way to the bottom of the device.
if(tableviewMaximumHeight <= (cellRowHeight * CGFloat(numberOfRows) + sectionHeight))
{
self.myTableView.frame.size.height = tableviewMaximumHeight
}
else
{
self.myTableView.frame.size.height = cellRowHeight * CGFloat(numberOfRows) + sectionHeight
}
self.myTableView.reloadData()
}
My table view is able to change height and reload data perfectly. The only Problem is that I am not able to reach the bottom of my table view. I do not know what else to do. I have already check that my table view has
myTableView.scrollEnabled = true
myTableView.scrollTop = false
If you guys have any advice, I would appreciate it :).
The problem when you manually set the height of a UITableView is that you'll then also have to manually set its content height.
Use Autolayout instead to set the height.
Have an IBOutlet for an NSLayoutConstraint variable (say, tableHeightConstraint) that sets the height of your table, then, in your code:
tableHeightConstraint.constant = tableviewMaximumHeight
or
tableHeightConstraint.constant = cellRowHeight * CGFloat(numberOfRows) + sectionHeight
I found the main root of my problem. The issued lied in my maximumTableviewHeight variable. The problem was that I would the value for this variable in the view did load and apparently the y position of the my table view would always give zero in the view did load. Once the maximum table view height was resolve. The application worked like a a charm.

Resources