Академический Документы
Профессиональный Документы
Культура Документы
' Accepts the name of a control and returns the respective control model as
object
' The Container can either be a whole document or a specific sheet of a
Calc-Document
' 'CName' is the name of the Control
Function getControlModel(oContainer as Object, CName as String)
Dim aForm, oForms as Object
Dim i as Integer
oForms = oContainer.Drawpage.GetForms
For i = 0 To oForms.Count-1
aForm = oForms.GetbyIndex(i)
If aForm.HasByName(CName) Then
GetControlModel = aForm.GetbyName(CName)
Exit Function
End If
Next i
Msgbox("No Control with the name '" & CName & "' found" , 16,
GetProductName())
End Function
' Gets the Shape of a Control( e. g. to reset the size or Position of the control
' Parameters:
' The 'oContainer' is the Document or a specific sheet of a Calc - Document
' 'CName' is the Name of the Control
Function GetControlShape(oContainer as Object,CName as String)
Dim i as integer
Dim aShape as Object
For i = 0 to oContainer.DrawPage.Count-1
aShape = oContainer.DrawPage(i)
If HasUnoInterfaces(aShape,
"com.sun.star.drawing.XControlShape") then
If ashape.Control.Name = CName then
GetControlShape = aShape
exit Function
End If
End If
Next
End Function
If aForm.HasByName(CName) Then
oControlModel = aForm.GetbyName(CName)
GetControlView = oController.GetControl(oControlModel)
Exit Function
End If
Next i
Msgbox("No Control with the name '" & CName & "' found" , 16,
GetProductName())
End Function
' Parameters:
' The 'oContainer' is the Document or a specific sheet of a Calc - Document
' 'CName' is the Name of the Control
Function DisposeControl(oContainer as Object, CName as String) as Boolean
Dim aControl as Object
aControl = GetControlModel(oContainer,CName)
If not IsNull(aControl) Then
aControl.Dispose()
DisposeControl = True
Else
DisposeControl = False
End If
End Function
oForms = oContainer.DrawPage.Forms
For i = 0 To oForms.Count-1
aForm = oForms(i)
If aForm.HasbyName(sGroupName) Then
aForm.GetGroupbyName(sGroupName,aControlModel)
GetControlGroupModel = aControlModel
Exit Function
End If
Next i
Msgbox("No Controlgroup with the name '" & sGroupName & "' found"
, 16, GetProductName())
End Function
oControlGroup(i).DefaultState = oControlGroup(i).State
If oControlGroup(i).State Then
GetRefValue = oControlGroup(i).RefValue
exit Function
End If
Next
GetRefValue() = -1
End Function
oFolderDialog.SetDisplayDirectory(InitPath)
End If
iAccept = oFolderDialog.Execute()
If iAccept = 1 Then
sPath = oFolderDialog.GetDirectory()
If oUcb.Exists(sPath) Then
oRefModel.Text = ConvertFromUrl(sPath)
End If
End If
End Sub
If oUcb.Exists(InitPath) Then
oFileDialog.SetDisplayDirectory(InitPath)
End If
iAccept = oFileDialog.Execute()
If iAccept = 1 Then
sPath = oFileDialog.Files(0)
If oUcb.Exists(sPath) Then
oRefModel.Text = ConvertFromUrl(sPath)
End If
End If
oFileDialog.Dispose()
End Sub
oStoreDialog.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.
CHECKBOX_AUTOEXTENSION,0, true)
iAccept = oStoreDialog.Execute()
If iAccept = 1 Then
sPath = oStoreDialog.Files(0)
UIFilterName = oStoreDialog.GetCurrentFilter()
FilterIndex = IndexInArray(UIFilterName, FilterNames())
FilterName = FilterNames(FilterIndex,2)
If Not IsMissing(iAddProcedure) Then
Select Case iAddProcedure
Case 1
CommitLastDocumentChanges(sPath)
End Select
End If
On Local Error Goto NOSAVING
If FilterName = "" Then
' Todo: Catch the case that a document that has to be
overwritten is writeportected (e.g. it is open)
oDocument.StoreAsUrl(sPath, NoArgs())
Else
oStoreProperties(0).Name = "FilterName"
oStoreProperties(0).Value = FilterName
oDocument.StoreAsUrl(sPath, oStoreProperties())
End If
End If
oStoreDialog.dispose()
StoreDocument() = sPath
Exit Function
NOSAVING:
If Err <> 0 Then
'
Msgbox("Document cannot be saved under '" &
ConvertFromUrl(sPath) & "'", 48, GetProductName())
sPath = ""
oStoreDialog.dispose()
Resume NOERROR
NOERROR:
End If
End Function
Else
oWindowPointer.SetType(com.sun.star.awt.SystemPointer.WAIT)
End If
oWindowPeer.SetPointer(oWindowPointer)
End Sub
OverwriteModel.cmdNo.Label = lblNo
OverwriteModel.cmdCancel.Label = lblCancel
OverwriteModel.lblQueryforSave.Label = QueryString
OverwriteModel.cmdNo.DefaultButton = True
DlgOverwrite.GetControl("cmdNo").SetFocus()
iGeneralOverwrite = 999
LocRetValue = DlgOverwrite.execute()
If iGeneralOverwrite = 999 Then
iGeneralOverwrite = SBOVERWRITECANCEL
End If
DlgOverwrite.dispose()
Else
iGeneralOverwrite = SBOVERWRITECANCEL
End If
End Sub
Sub SetOVERWRITEToQuery()
iGeneralOverwrite = SBOVERWRITEQUERY
DlgOverwrite.EndExecute()
End Sub
Sub SetOVERWRITEToAlways()
iGeneralOverwrite = SBOVERWRITEALWAYS
DlgOverwrite.EndExecute()
End Sub
Sub SetOVERWRITEToNever()
iGeneralOverwrite = SBOVERWRITENEVER
DlgOverwrite.EndExecute()
End Sub