wizards/source/sfdocuments/SF_Calc.xba | 46 ++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-)
New commits: commit 2953ff4682333cd81f4d53a56dd67175a5fedb18 Author: Jean-Pierre Ledure <j...@ledure.be> AuthorDate: Wed Feb 26 14:51:06 2025 +0100 Commit: Jean-Pierre Ledure <j...@ledure.be> CommitDate: Wed Feb 26 16:37:09 2025 +0100 ScriptForge (SF_Calc) formatting, case-sensitive arguments Next methods: AlignRange() => TMBLCR BorderRange() => LTRBUDHV DecorateFont() => BUSI receive a string argument describing what they have to do. Those arguments become case-sensitive: only upper-case characters are considered. Now: calc.DecorateFont(range, decoration := "BI") may be written as: calc.DecorateFont(range, _ decoration := "Bold+Italic") which improves the readability of user's scripts. The functionality is available both in Basic and Python scripts. To be considered in the 25.8 documentation. Change-Id: If241f7aef2e8cbfa5b7dd240e26489790a8cca13 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/182232 Reviewed-by: Jean-Pierre Ledure <j...@ledure.be> Tested-by: Jenkins diff --git a/wizards/source/sfdocuments/SF_Calc.xba b/wizards/source/sfdocuments/SF_Calc.xba index a3654da7e813..3e0de474bd48 100644 --- a/wizards/source/sfdocuments/SF_Calc.xba +++ b/wizards/source/sfdocuments/SF_Calc.xba @@ -471,7 +471,7 @@ Public Function AlignRange(Optional ByVal TargetRange As Variant _ ''' The impacted cells may be determined with a filter formula and its scope. ''' Args: ''' TargetRange : the cell or the range as a string in which cells should be re-aligned. -''' Alignment: a string combining 1 or 2 of next characters: +''' Alignment: a string combining 1 or 2 of next characters (other characters are ignored): ''' L align Left ''' R align Right ''' C Center gorizontally @@ -485,7 +485,7 @@ Public Function AlignRange(Optional ByVal TargetRange As Variant _ ''' Returns: ''' A string representing the updated range ''' Examples: -''' oDoc.AlignRange("SheetX.A1:J30", "MC", FilterFormula := "IsNumeric(A1), FilterScope := "CELL") +''' oDoc.AlignRange("SheetX.A1:J30", "Middle,Center", FilterFormula := "IsNumeric(A1), FilterScope := "CELL") ''' ' Align to the middle of the cells, horizontally and vertically Dim sAlign As String ' Return value @@ -522,12 +522,12 @@ Try: If Len(FilterFormula) = 0 Then vRanges = Array(oRange) Else vRanges() = _ComputeFilter(oRange, FilterFormula, UCase(FilterScope)) For Each oARange In vRanges With oARange.XCellRange - If InStr(Alignment, "L") > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.LEFT - If InStr(Alignment, "C") > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.CENTER - If InStr(Alignment, "R") > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.RIGHT - If InStr(Alignment, "B") > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.BOTTOM - If InStr(Alignment, "M") > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.CENTER - If InStr(Alignment, "T") > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.TOP + If InStr(1, Alignment, "L", 0) > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.LEFT + If InStr(1, Alignment, "C", 0) > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.CENTER + If InStr(1, Alignment, "R", 0) > 0 Then .ParaAdjust = com.sun.star.style.ParagraphAdjust.RIGHT + If InStr(1, Alignment, "B", 0) > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.BOTTOM + If InStr(1, Alignment, "M", 0) > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.CENTER + If InStr(1, Alignment, "T", 0) > 0 Then .VertJustify = com.sun.star.table.CellVertJustify.TOP End With Next oARange @@ -555,7 +555,7 @@ Public Function BorderRange(Optional ByVal TargetRange As Variant _ ''' To clear the full range use Border = "" without the FilterFormula argument. ''' Args: ''' TargetRange : the cell or the range as a string on which borders should be applied -''' Borders: a string combining next characters: +''' Borders: a string combining next characters (other characters are ignored): ''' B Bottom outer line ''' L Left outer line ''' T Top outer line @@ -1759,7 +1759,7 @@ Public Function DecorateFont(Optional ByVal TargetRange As Variant _ ''' TargetRange : the cell or the range as a string in which cell fonts should be re-decorated. ''' FontName: the name of the font to be used. The name is not checked. Default = no change. ''' FontSize: the size of the font in pixels. Default = no change. -''' Decoration: a string combining 1 or more of next characters (default = no change): +''' Decoration: a string combining 1 or more of next characters (other characters are ignored). Default = no change: ''' B Bold ''' U Underline ''' I Italic @@ -1817,10 +1817,10 @@ Try: If Len(FontName) > 0 Then .CharFontName = FontName If FontSize > 0 Then .CharHeight = FontSize If Len(Decoration) > 0 Then - If InStr(Decoration, "B") > 0 Then .CharWeight = com.sun.star.awt.FontWeight.BOLD - If InStr(Decoration, "U") > 0 Then .CharUnderline = com.sun.star.awt.FontUnderline.SINGLE - If InStr(Decoration, "I") > 0 Then .CharPosture = com.sun.star.awt.FontSlant.ITALIC - If InStr(Decoration, "S") > 0 Then .CharStrikeout = com.sun.star.awt.FontStrikeout.SINGLE + If InStr(1, Decoration, "B", 0) > 0 Then .CharWeight = com.sun.star.awt.FontWeight.BOLD + If InStr(1, Decoration, "U", 0) > 0 Then .CharUnderline = com.sun.star.awt.FontUnderline.SINGLE + If InStr(1, Decoration, "I", 0) > 0 Then .CharPosture = com.sun.star.awt.FontSlant.ITALIC + If InStr(1, Decoration, "S", 0) > 0 Then .CharStrikeout = com.sun.star.awt.FontStrikeout.SINGLE End If End With Next ODRange @@ -4406,7 +4406,7 @@ Try: iDefaultStyle = com.sun.star.table.BorderLineStyle.SOLID ' Bottom borders - If InStr(pvBorders, "B") > 0 Then + If InStr(1, pvBorders, "B", 0) > 0 Then With oTableBorder .BottomLine.LineStyle = iDefaultStyle .BottomLine.LineWidth = cstLineWidth @@ -4415,7 +4415,7 @@ Try: End If ' Left borders - If InStr(pvBorders, "L") > 0 Then + If InStr(1, pvBorders, "L", 0) > 0 Then With oTableBorder .LeftLine.LineStyle = iDefaultStyle .LeftLine.LineWidth = cstLineWidth @@ -4424,7 +4424,7 @@ Try: End If ' Top borders - If InStr(pvBorders, "T") > 0 Then + If InStr(1, pvBorders, "T", 0) > 0 Then With oTableBorder .TopLine.LineStyle = iDefaultStyle .TopLine.LineWidth = cstLineWidth @@ -4433,7 +4433,7 @@ Try: End If ' Right borders - If InStr(pvBorders, "R") > 0 Then + If InStr(1, pvBorders, "R", 0) > 0 Then With oTableBorder .RightLine.LineStyle = iDefaultStyle .RightLine.LineWidth = cstLineWidth @@ -4442,7 +4442,7 @@ Try: End If ' Horizontal inner borders - If InStr(pvBorders, "H") > 0 Then + If InStr(1, pvBorders, "H", 0) > 0 Then With oTableBorder .HorizontalLine.LineStyle = iDefaultStyle .HorizontalLine.LineWidth = cstLineWidth @@ -4451,7 +4451,7 @@ Try: End If ' Vertical inner borders - If InStr(pvBorders, "V") > 0 Then + If InStr(1, pvBorders, "V", 0) > 0 Then With oTableBorder .VerticalLine.LineStyle = iDefaultStyle .VerticalLine.LineWidth = cstLineWidth @@ -4460,7 +4460,7 @@ Try: End If ' Bottom-up diagonal - If InStr(pvBorders, "U") > 0 Then + If InStr(1, pvBorders, "U", 0) > 0 Then Set oBorderLine = New com.sun.star.table.BorderLine2 With oBorderLine .LineStyle = iDefaultStyle @@ -4470,7 +4470,7 @@ Try: End If ' Top-down diagonal - If InStr(pvBorders, "D") > 0 Then + If InStr(1, pvBorders, "D", 0) > 0 Then Set oBorderLine = New com.sun.star.table.BorderLine2 With oBorderLine .LineStyle = iDefaultStyle @@ -5403,4 +5403,4 @@ CatchSheet: End Function ' SFDocuments.SF_Calc._ValidateSheetName REM ============================================ END OF SFDOCUMENTS.SF_CALC -</script:module> +</script:module> \ No newline at end of file