https://bugs.documentfoundation.org/show_bug.cgi?id=165773
--- Comment #2 from Mark <[email protected]> --- I created a new Calc file and created 65 rows with check boxes in column 'A' using my macro. I could not reproduce the problem. So I made a copy of the original file with check boxes in Colunn 'A, then deleted most of the rows with the check boxes, but saved one. Then I inserted new rows below the saved row until I had 65 rows again, with the same formatting as the saved one, or course, but then I noticed something odd... Firstly, MOST of the new rows had check boxes in Column 'A. I didn't expect the "data" (the check boxes) would be copied into the new rows. I thought they would all be empty. But even odder... some of the check boxes were checked and some were not. But the last rows I added had no check boxes. When I save, the odd scrolling behavior and the disabling and re-enabling the check boxes does happen. And the scroll goes down near the last filled rows and stays there. But this happens ***ONLY*** when I Save after manually changing one of the check boxes. And sometimes some of the check boxes ***DO*** sort of disappear. When I click them, the re-appear. CORRECTION: They don't always actually DISAPPEAR. They just show only their BORDER/OUTLINE. No background and no check. But this file I can attach. Below is the macro I wrote to create the check boxes. I'm not sure why they look different from the default. Maybe the LOOK3D Visual Effect? But then how would Safe Mode change them??? Maybe some Calc setting??? ================================================================================================== ``` ' xVisualEffect as Byte, : default = 1 - LOOK3D, 0 = NONE 1 = LOOK3D 2 = FLAT ' bLabelCentered as Boolean, : default = FALSE (i.e. Left-Aligned) ' lCheckBoxRGB as Long, : default = RGB(240, 240, 240) - Light Gray ' lLabelRGB as Long, : default = RGB(40, 40, 40) - Dark Gray ' xFontHeight as Byte, : default = 9, minimum = 5, maximum = 56 ' iFontWeight as Integer : default = 100 (NORMAL,) minimum = 25, maximum = 200 - This is a PERCENTAGE - 100% is NORMAL (400), 175% is BOLD (700) ' sFontName as Integer _ default = "Arial" Sub CreateCheckBoxes( optional xVisualEffect as Byte, _ optional bLabelCentered as Boolean, _ optional lCheckBoxRGB as Long, _ optional lLabelRGB as Long, _ optional xFontHeight as Byte, _ optional iFontWeight as Integer, _ optional sFontName as String _ ) 'GlobalScope.BasicLibraries.loadLibrary("ScriptForge") Const c_xDefaultVisualEffect as Byte = 1 ' 1 - LOOK3D, 0 = NONE 1 = LOOK3D 2 = FLAT Const c_xDefaultFontHeight as Byte = 9 ' What are the bounds on this??? Const c_xMinimumFontHeight as Byte = 5 Const c_xMaximumFontHeight as Byte = 56 Const c_iDefaultFontWeight as Integer = 100 ' NORMAL - This is a PERCENTAGE - 100% is NORMAL (400), 175% is BOLD (700) Const c_iMinimumFontWeight as Integer = 25 Const c_iMaximumFontWeight as Integer = 200 Const c_sDefaultFontName as String = "Arial" ''' set defaults for all the parameters ''' If (isMissing(xVisualEffect)) Then xVisualEffect = c_xDefaultVisualEffect ElseIf (c_xVisualEffect < 0 OR c_xVisualEffect > 2) Then xVisualEffect = c_xDefaultVisualEffect ' out-of-bounds value gets the default End If If (isMissing(bLabelCentered)) Then bLabelCentered = FALSE End If If (isMissing(lCheckBoxRGB)) Then lCheckBoxRGB = RGB(240, 240, 240) ' Light Gray End IF If (isMissing(lLabelRGB)) Then lLabelRGB = RGB(40, 40, 40) ' Dark Gray End If If (isMissing(xFontHeight)) Then xFontHeight = c_xDefaultFontHeight ElseIf (xFontHeight < c_xMinimumFontHeight) Then ' Minimum height is 5!!! xFontHeight = c_xMinimumFontHeight ' out-of-bounds value gets the default ElseIf (xFontHeight > c_xMaximumFontHeight) Then ' Maximum height is 56!!! xFontHeight = c_xMaximumFontHeight ' out-of-bounds value gets the default End If If (isMissing(iFontWeight)) Then iFontWeight = c_iDefaultFontWeight ElseIf (iFontWeight < c_iMinimumFontWeight) Then ' Minimum weight is 25%!!! iFontWeight = c_iMinimumFontWeight ' out-of-bounds value gets the default ElseIf (iFontWeight > c_iMaximumFontWeight) Then ' Maximum weight is 200%!!! iFontWeight = c_iMaximumFontWeight ' out-of-bounds value gets the default End If If (isMissing(sFontName)) Then sFontName = c_sDefaultFontName ElseIf (sFontName = "") Then sFontName = c_sDefaultFontName End If Dim xCheckBoxALign as Byte '''' 0 = Left 1 = Centered 2 = Right If (bLabelCentered) Then xCheckBoxAlign = 1 ' Center Else xCheckBoxAlign = 0 ' Left End If Dim oDoc as Object Dim oSelection as Object Dim oSelRanges as Object Dim oSelRange as Object Dim oSheet as Object Dim oCell as Object Dim sCheckBoxLabel as String Dim oCheckBox as Object Dim oFontDesc as Object Dim oShape as Object oDoc = ThisComponent oSelection = oDoc.GetCurrentSelection() ' this returns com.sun.star.uno.XInterface, the base interface of all UNO interfaces if (IsNull(oSelection)) Then MsgBox("Something must be selected", MB_ICONEXCLAMATION, "Error") Exit Sub End If If (oSelection.supportsService("com.sun.star.sheet.SheetCellRanges")) Then oSelRanges = oSelection ElseIf (oSelection.supportsService("com.sun.star.sheet.SheetCellRange")) Then oSelRanges = ThisComponent.createInstance("com.sun.star.sheet.SheetCellRanges") oSelRanges.addRangeAddress(oSelection.RangeAddress, FALSE) Else MsgBox("One or more cells must be selected", MB_ICONEXCLAMATION, "Error") Exit Sub End If For Each oSelRange In oSelRanges Dim lRowMax as Long, lColMax as Long, lRow as Long, lCol as Long lRowMax = oSelRange.Rows.Count - 1 lColMax = oSelRange.Columns.Count - 1 oSheet = oSelRange.SpreadSheet For lRow = 0 To lRowMax For lCol = 0 To lColMax oCell = oSelRange.getCellByPosition(lCol, lRow) sCheckBoxLabel = oCell.String ' Create and configure a CheckBox oCheckBox = oDoc.createInstance("com.sun.star.form.component.CheckBox") oCheckBox.VisualEffect = xVisualEffect ' 0 = NONE 1 = LOOK3D 2 = FLAT oCheckBox.BackgroundColor = lCheckBoxRGB if (FALSE) Then '' create a Disabled, Checked CheckBox with light cyan background (for a header, etc) oCheckBox.State = 1 ' 0 = not checked 1 = checked 2 = don't know oCheckBox.BackgroundColor = RGB(238,255,252) oCheckBox.Enabled = FALSE End If If (sCheckBoxLabel <> "") Then '' if there's no text in the cell then there's no label to deal with oCheckBox.Name = sCheckBoxLabel & "_CheckBox" oCheckBox.Label = sCheckBoxLabel oCheckBox.Align = xCheckBoxAlign oCheckBox.TextColor = lLabelRGB ' oCheckBox.FontName = sFontName ' Use FontDescriptor instead ' Create and configure a FontDescriptor for the CheckBox and apply it oFontDesc = oCheckBox.FontDescriptor ' oFontDesc = oDoc.createInstance("com.sun.star.awt.FontDescriptor") ''''' MABXXX WHY DOESN'T THIS WORK??? oFontDesc.Name = sFontName oFontDesc.Height = xFontHeight oFontDesc.Weight = iFontWeight ' This is a PERCENTAGE - 100% is NORMAL (400), 175% is BOLD (700) oCheckBox.FontDescriptor = oFontDesc ''MsgBox("font height=" & oFontDesc.Height & " font weight=" & oFontDesc.Weight, MB_ICONEXCLAMATION, "Error") End If oShape = oDoc.createInstance("com.sun.star.drawing.ControlShape") '' oShape.Name = sCheckBoxLabel & "_Shape" oShape.Control = oCheckBox ' Set the CheckBox as the Control in the Shape oSheet.DrawPage.add(oShape) ' Add the Shape (that contains the CheckBox) to the Sheet - MUST be ABOVE the following lines oShape.Size = oCell.Size ' Size the Shape with the Size of the selected Cell oShape.Position = oCell.Position ' Position the Shape into the selected Cell oShape.Anchor = oCell ' Anchor the Shape to the selected Cell oShape.ResizeWithCell = TRUE ' Resize the Shape every time the Cell size changes oShape.SizeProtect = FALSE ' Don't allow the Shape to RESIZE, TRUE prevents ResizeWithCell oShape.MoveProtect = TRUE ' Don't allow the Shape to MOVE Next lCol Next lRow Next oSelRange End Sub 'CreateCheckBoxes ``` -- You are receiving this mail because: You are the assignee for the bug.
