Skip to content

Commit

Permalink
Merge pull request #25 from mlipok/CleanUp
Browse files Browse the repository at this point in the history
CleanUp
  • Loading branch information
mlipok authored Sep 27, 2023
2 parents 3afb170 + fb02b6c commit 82d2046
Show file tree
Hide file tree
Showing 16 changed files with 466 additions and 490 deletions.
2 changes: 1 addition & 1 deletion Examples/_LOWriter_ComError_UserFunction 2.au3
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Func Example()
MsgBox($MB_OK, "", "Now I will retrieve the function's name that I set.")

; Return the currently set User Function and any Parameters by calling the Default keyword in the first parameter.
$aReturn = _LOWriter_ComError_UserFunction(Default) ;Since I set parameters, the return will be an Array.
$aReturn = _LOWriter_ComError_UserFunction(Default) ; Since I set parameters, the return will be an Array.

If Not IsArray($aReturn) Then _ERROR("Error retrieving function Array. Error:" & @error & " Extended:" & @extended)

Expand Down
2 changes: 1 addition & 1 deletion Examples/_LOWriter_DocPrintSizeSettings.au3
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Func Example()
"I will now modify the settings and show the result.")

; Changes the print settings to all false.
_LOWriter_DocPrintSizeSettings($oDoc, $LOW_PAPER_TABLOID) ;,False,False,False,False)
_LOWriter_DocPrintSizeSettings($oDoc, $LOW_PAPER_TABLOID) ; ,False,False,False,False)
If (@error > 0) Then _ERROR("Error setting Writer Document Print settings. Error:" & @error & " Extended:" & @extended)

; Now retrieve the settings again.
Expand Down
2 changes: 1 addition & 1 deletion Examples/_LOWriter_DocZoom.au3
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Func Example()
$iReturn = _LOWriter_DocZoom($oDoc)
If (@error > 0) Then _ERROR("Failed to retrieve current zoom value. Error:" & @error & " Extended:" & @extended)

$iZoom = Int($iReturn * .75) ;Set my new zoom value to 75% of the current zoom value.
$iZoom = Int($iReturn * .75) ; Set my new zoom value to 75% of the current zoom value.

; Zoom cannot be less than 20% or greater than 600%, if my value is outside of this, set it to 140%
If ($iZoom < 20) Or ($iZoom > 600) Then $iZoom = 140
Expand Down
28 changes: 14 additions & 14 deletions LibreOfficeWriter.au3
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ Func _LOWriter_CellBackColor(ByRef $oCell, $iBackColor = Null, $bBackTransparent
If Not __LOWriter_IntIsBetween($iBackColor, $LOW_COLOR_OFF, $LOW_COLOR_WHITE) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)
$oCell.BackColor = $iBackColor
If ($iBackColor = $LOW_COLOR_OFF) Then $oCell.BackTransparent = True
$iError = ($oCell.BackColor() = $iBackColor) ? $iError : BitOR($iError, 1) ;Error setting color.
$iError = ($oCell.BackColor() = $iBackColor) ? $iError : BitOR($iError, 1) ; Error setting color.
EndIf

If ($bBackTransparent <> Null) Then
If Not IsBool($bBackTransparent) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0)
$oCell.BackTransparent = $bBackTransparent
$iError = ($oCell.BackTransparent() = $bBackTransparent) ? $iError : BitOR($iError, 2) ;Error setting BackTransparent.
$iError = ($oCell.BackTransparent() = $bBackTransparent) ? $iError : BitOR($iError, 2) ; Error setting BackTransparent.
EndIf

Return ($iError = 0) ? SetError($__LOW_STATUS_SUCCESS, 0, 1) : SetError($__LOW_STATUS_PROP_SETTING_ERROR, $iError, 0)
Expand Down Expand Up @@ -512,7 +512,7 @@ Func _LOWriter_CellCreateTextCursor(ByRef $oCell)
#forceref $oCOM_ErrorHandler

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ;Can only create a Text Cursor for individual cells.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ; Can only create a Text Cursor for individual cells.

Return SetError($__LOW_STATUS_SUCCESS, 0, $oCell.Text.createTextCursor())
EndFunc ;==>_LOWriter_CellCreateTextCursor
Expand Down Expand Up @@ -550,7 +550,7 @@ Func _LOWriter_CellFormula(ByRef $oCell, $sFormula = Null)

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sFormula) And Not ($sFormula = Null) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ;Can only set/get formula value for individual cells.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ; Can only set/get formula value for individual cells.
If ($sFormula = Null) Then Return SetError($__LOW_STATUS_SUCCESS, 1, $oCell.getFormula())

$oCell.setFormula($sFormula)
Expand Down Expand Up @@ -588,7 +588,7 @@ Func _LOWriter_CellGetDataType(ByRef $oCell)
#forceref $oCOM_ErrorHandler

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ;Can only get Data Type for individual cells
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ; Can only get Data Type for individual cells

Return SetError($__LOW_STATUS_SUCCESS, 0, $oCell.getType())
EndFunc ;==>_LOWriter_CellGetDataType
Expand Down Expand Up @@ -618,7 +618,7 @@ Func _LOWriter_CellGetError(ByRef $oCell)
#forceref $oCOM_ErrorHandler

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ;Can only get Error for individual cells.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ; Can only get Error for individual cells.

Return SetError($__LOW_STATUS_SUCCESS, 0, $oCell.getError())

Expand Down Expand Up @@ -649,7 +649,7 @@ Func _LOWriter_CellGetName(ByRef $oCell)
#forceref $oCOM_ErrorHandler

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ;Can only get Cell Name for individual cells.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ; Can only get Cell Name for individual cells.

Return SetError($__LOW_STATUS_SUCCESS, 0, $oCell.CellName())
EndFunc ;==>_LOWriter_CellGetName
Expand Down Expand Up @@ -687,7 +687,7 @@ Func _LOWriter_CellProtect(ByRef $oCell, $bProtect = Null)
#forceref $oCOM_ErrorHandler

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ;Can only set individual cell protect property.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0) ; Can only set individual cell protect property.
If ($bProtect = Null) Then Return SetError($__LOW_STATUS_SUCCESS, 0, $oCell.IsProtected())
If Not IsBool($bProtect) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0)
$oCell.IsProtected = $bProtect
Expand Down Expand Up @@ -727,7 +727,7 @@ Func _LOWriter_CellString(ByRef $oCell, $sString = Null)

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If Not IsString($sString) And Not ($sString = Null) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ;Can only set/get a String for individual cells.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ; Can only set/get a String for individual cells.

If ($sString = Null) Then Return SetError($__LOW_STATUS_SUCCESS, 1, $oCell.getString())

Expand Down Expand Up @@ -770,7 +770,7 @@ Func _LOWriter_CellValue(ByRef $oCell, $nValue = Null)

If Not IsObj($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 1, 0)
If Not IsNumber($nValue) And Not ($nValue = Null) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ;Can only set/get individual cell values.
If __LOWriter_IsCellRange($oCell) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 3, 0) ; Can only set/get individual cell values.

If ($nValue = Null) Then Return SetError($__LOW_STATUS_SUCCESS, 1, $oCell.getValue())

Expand Down Expand Up @@ -972,13 +972,13 @@ Func _LOWriter_EndnoteInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False, $
Switch __LOWriter_Internal_CursorGetDataType($oDoc, $oCursor)

Case $LOW_CURDATA_FRAME, $LOW_CURDATA_FOOTNOTE, $LOW_CURDATA_ENDNOTE, $LOW_CURDATA_HEADER_FOOTER
Return SetError($__LOW_STATUS_INPUT_ERROR, 5, 0) ;Unsupported cursor type.
Return SetError($__LOW_STATUS_INPUT_ERROR, 5, 0) ; Unsupported cursor type.
Case $LOW_CURDATA_BODY_TEXT, $LOW_CURDATA_CELL
$oEndNote = $oDoc.createInstance("com.sun.star.text.Endnote")
If Not IsObj($oEndNote) Then Return SetError($__LOW_STATUS_INIT_ERROR, 1, 0)

Case Else
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ;Unknown Cursor type.
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ; Unknown Cursor type.
EndSwitch

If ($sLabel <> Null) Then
Expand Down Expand Up @@ -1494,13 +1494,13 @@ Func _LOWriter_FootnoteInsert(ByRef $oDoc, ByRef $oCursor, $bOverwrite = False,
Switch __LOWriter_Internal_CursorGetDataType($oDoc, $oCursor)

Case $LOW_CURDATA_FRAME, $LOW_CURDATA_FOOTNOTE, $LOW_CURDATA_ENDNOTE, $LOW_CURDATA_HEADER_FOOTER
Return SetError($__LOW_STATUS_INPUT_ERROR, 5, 0) ;Unsupported cursor type.
Return SetError($__LOW_STATUS_INPUT_ERROR, 5, 0) ; Unsupported cursor type.
Case $LOW_CURDATA_BODY_TEXT, $LOW_CURDATA_CELL
$oFootNote = $oDoc.createInstance("com.sun.star.text.Footnote")
If Not IsObj($oFootNote) Then Return SetError($__LOW_STATUS_INIT_ERROR, 1, 0)

Case Else
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ;Unknown Cursor type.
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ; Unknown Cursor type.
EndSwitch

If ($sLabel <> Null) Then
Expand Down
4 changes: 2 additions & 2 deletions LibreOfficeWriter_Cursor.au3
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Func _LOWriter_CursorGetStatus(ByRef $oCursor, $iFlag)
$vReturn = Execute("$oCursor" & $aiCommands[$iFlag])
Return (@error > 0) ? SetError($__LOW_STATUS_PROCESSING_ERROR, 3, 0) : SetError($__LOW_STATUS_SUCCESS, 0, $vReturn)
Case Else
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ;unknown cursor data type.
Return SetError($__LOW_STATUS_INPUT_ERROR, 6, 0) ; unknown cursor data type.
EndSwitch

EndFunc ;==>_LOWriter_CursorGetStatus
Expand Down Expand Up @@ -389,6 +389,6 @@ Func _LOWriter_CursorMove(ByRef $oCursor, $iMove, $iCount = 1, $bSelect = False)
$bMoved = __LOWriter_ViewCursorMove($oCursor, $iMove, $iCount, $bSelect)
Return SetError(@error, @extended, $bMoved)
Case Else
Return SetError($__LOW_STATUS_PROCESSING_ERROR, 3, 0) ;unknown cursor data type.
Return SetError($__LOW_STATUS_PROCESSING_ERROR, 3, 0) ; unknown cursor data type.
EndSwitch
EndFunc ;==>_LOWriter_CursorMove
12 changes: 6 additions & 6 deletions LibreOfficeWriter_DirectFormating.au3
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ Func _LOWriter_DirFrmtCharBorderColor(ByRef $oSelection, $iTop = Null, $iBottom
If Not __LOWriter_DirFrmtCheck($oSelection) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)
If $bClearDirFrmt Then
$oSelection.setPropertyToDefault("CharTopBorder")
$oSelection.setPropertyToDefault("CharBottomBorder") ;Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharBottomBorder") ; Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharLeftBorder")
$oSelection.setPropertyToDefault("CharRightBorder")
If __LOWriter_VarsAreNull($iTop, $iBottom, $iLeft, $iRight) Then Return SetError($__LOW_STATUS_SUCCESS, 0, 2)
Expand Down Expand Up @@ -381,7 +381,7 @@ Func _LOWriter_DirFrmtCharBorderStyle(ByRef $oSelection, $iTop = Null, $iBottom

If $bClearDirFrmt Then
$oSelection.setPropertyToDefault("CharTopBorder")
$oSelection.setPropertyToDefault("CharBottomBorder") ;Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharBottomBorder") ; Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharLeftBorder")
$oSelection.setPropertyToDefault("CharRightBorder")
If __LOWriter_VarsAreNull($iTop, $iBottom, $iLeft, $iRight) Then Return SetError($__LOW_STATUS_SUCCESS, 0, 2)
Expand Down Expand Up @@ -478,7 +478,7 @@ Func _LOWriter_DirFrmtCharBorderWidth(ByRef $oSelection, $iTop = Null, $iBottom

If $bClearDirFrmt Then
$oSelection.setPropertyToDefault("CharTopBorder")
$oSelection.setPropertyToDefault("CharBottomBorder") ;Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharBottomBorder") ; Resetting one truly resets all, but just to be sure, reset all.
$oSelection.setPropertyToDefault("CharLeftBorder")
$oSelection.setPropertyToDefault("CharRightBorder")
If __LOWriter_VarsAreNull($iTop, $iBottom, $iLeft, $iRight) Then Return SetError($__LOW_STATUS_SUCCESS, 0, 2)
Expand Down Expand Up @@ -1301,7 +1301,7 @@ Func _LOWriter_DirFrmtFontColor(ByRef $oSelection, $iFontColor = Null, $iTranspa

If ($iHighlight = Default) Then
If __LOWriter_VersionCheck(4.2) Then $oSelection.setPropertyToDefault("CharHighlight")
$oSelection.setPropertyToDefault("CharBackColor") ;Both may be used? not sure. Both do the same thing, so reset both to make sure.
$oSelection.setPropertyToDefault("CharBackColor") ; Both may be used? not sure. Both do the same thing, so reset both to make sure.
$iHighlight = Null
EndIf

Expand Down Expand Up @@ -2345,7 +2345,7 @@ Func _LOWriter_DirFrmtParHyphenation(ByRef $oSelection, $bAutoHyphen = Null, $bH
If Not __LOWriter_DirFrmtCheck($oSelection) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)

If $bClearDirFrmt Then
$oSelection.setPropertyToDefault("ParaIsHyphenation") ;Resetting one resets all.
$oSelection.setPropertyToDefault("ParaIsHyphenation") ; Resetting one resets all.
If __LOWriter_VarsAreNull($bAutoHyphen, $bHyphenNoCaps, $iMaxHyphens, $iMinLeadingChar, $iMinTrailingChar) Then Return SetError($__LOW_STATUS_SUCCESS, 0, 2)
EndIf

Expand Down Expand Up @@ -2427,7 +2427,7 @@ Func _LOWriter_DirFrmtParIndent(ByRef $oSelection, $iBeforeTxt = Null, $iAfterTx
If Not __LOWriter_DirFrmtCheck($oSelection) Then Return SetError($__LOW_STATUS_INPUT_ERROR, 2, 0)

If $bClearDirFrmt Then
$oSelection.setPropertyToDefault("ParaLeftMargin") ;Resetting one resets all -- but just in case reset the rest.
$oSelection.setPropertyToDefault("ParaLeftMargin") ; Resetting one resets all -- but just in case reset the rest.
$oSelection.setPropertyToDefault("ParaRightMargin")
$oSelection.setPropertyToDefault("ParaFirstLineIndent")
$oSelection.setPropertyToDefault("ParaIsAutoFirstLineIndent")
Expand Down
Loading

0 comments on commit 82d2046

Please sign in to comment.