Kaydet (Commit) 2f7c3cce authored tarafından Xisco Fauli's avatar Xisco Fauli Kaydeden (comit) Xisco Faulí

Remove unused python code

This code was automatically converted from Java to Python.
It might be used at some point if the remaining java wizards
are converted to python, however that's not the case as
per today, thus this code is unused.

Let's get rid of it as it might create confusion

Change-Id: Ic58ade24b10f7a0654b3e8ae39f6afa712589c3d
Reviewed-on: https://gerrit.libreoffice.org/67868
Tested-by: Jenkins
Reviewed-by: 's avatarXisco Faulí <xiscofauli@libreoffice.org>
üst 00a86e8b
......@@ -84,33 +84,6 @@ class Desktop(object):
return sIncSuffix
@classmethod
def checkforfirstSpecialCharacter(self, _xMSF, _sString, _aLocale):
try:
nStartFlags = ANY_LETTER_OR_NUMBER + ASC_UNDERSCORE
ocharservice = _xMSF.createInstance(
"com.sun.star.i18n.CharacterClassification")
aResult = ocharservice.parsePredefinedToken(KParseType.IDENTNAME,
_sString, 0, _aLocale, nStartFlags, "", nStartFlags, " ")
return aResult.EndPos
except Exception:
traceback.print_exc()
return -1
@classmethod
def removeSpecialCharacters(self, _xMSF, _aLocale, _sname):
snewname = _sname
i = 0
while i < snewname.length():
i = Desktop.checkforfirstSpecialCharacter(_xMSF, snewname,
_aLocale)
if i < snewname.length():
sspecialchar = snewname.substring(i, i + 1)
snewname = JavaTools.replaceSubString(snewname, "",
sspecialchar)
return snewname
'''
Checks if the passed Element Name already exists in the ElementContainer.
If yes it appends a suffix to make it unique
......@@ -124,16 +97,3 @@ class Desktop(object):
sIncSuffix = self.getIncrementSuffix(xElementContainer, sElementName)
return sElementName + sIncSuffix
@classmethod
def getDispatchURL(self, xMSF, _sURL):
try:
oTransformer = xMSF.createInstance("com.sun.star.util.URLTransformer")
oURL = URL()
oURL.Complete = _sURL
ok, oURL = oTransformer.parseStrict(oURL)
if (not ok):
return None
return oURL
except Exception:
traceback.print_exc()
return None
......@@ -69,24 +69,6 @@ class FileAccess(object):
traceback.print_exc()
return ""
@classmethod
def combinePaths(self, xMSF, _sFirstPath, _sSecondPath):
bexists = False
ReturnPath = ""
try:
xUcbInterface = xMSF.createInstance(
"com.sun.star.ucb.SimpleFileAccess")
ReturnPath = _sFirstPath + _sSecondPath
bexists = xUcbInterface.exists(ReturnPath)
except Exception:
traceback.print_exc()
return ""
if not bexists:
raise NoValidPathException (xMSF, "")
return ReturnPath
@classmethod
def getFolderTitles(self, xMSF, FilterName, FolderName, resDict=None):
#Returns and ordered dict containing the template's name and path
......@@ -131,17 +113,6 @@ class FileAccess(object):
return locLayoutFiles
@classmethod
def addPath(self, _sPath, _sPath2):
if not _sPath.endsWith("/"):
_sPath += "/"
if _sPath2.startsWith("/"):
_sPath2 = _sPath2.substring(1)
sNewPath = _sPath + _sPath2
return sNewPath
@classmethod
def getTitle(self, xMSF, _sFile):
sTitle = ""
......
......@@ -84,164 +84,3 @@ class NumberFormatter(object):
def convertStringToNumber(self, _nkey, _sString):
return self.xNumberFormatter.convertStringToNumber(_nkey, _sString)
'''
@param dateCorrection The lDateCorrection to set.
'''
def setNullDateCorrection(self, dateCorrection):
self.lDateCorrection = dateCorrection
def defineNumberFormat(self, _FormatString):
try:
NewFormatKey = self.xNumberFormats.queryKey(
_FormatString, self.aLocale, True)
if NewFormatKey is -1:
NewFormatKey = self.xNumberFormats.addNew(
_FormatString, self.aLocale)
return NewFormatKey
except Exception:
traceback.print_exc()
return -1
'''
returns a numberformat for a FormatString.
@param _FormatString
@param _aLocale
@return
'''
def defineNumberFormat(self, _FormatString, _aLocale):
try:
NewFormatKey = self.xNumberFormats.queryKey(
_FormatString, _aLocale, True)
if NewFormatKey == -1:
NewFormatKey = self.xNumberFormats.addNew(
_FormatString, _aLocale)
return NewFormatKey
except Exception:
traceback.print_exc()
return -1
def setNumberFormat(self, _xFormatObject, _FormatKey, _oNumberFormatter):
try:
xNumberFormat = _oNumberFormatter.xNumberFormats.getByKey(
_FormatKey)
FormatString = str(Helper.getUnoPropertyValue(
xNumberFormat, "FormatString"))
oLocale = Helper.getUnoPropertyValue(xNumberFormat, "Locale")
NewFormatKey = defineNumberFormat(FormatString, oLocale)
_xFormatObject.setPropertyValue(
"FormatsSupplier",
_oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier())
if _xFormatObject.getPropertySetInfo().hasPropertyByName(
"NumberFormat"):
_xFormatObject.setPropertyValue("NumberFormat", NewFormatKey)
elif _xFormatObject.getPropertySetInfo().hasPropertyByName(
"FormatKey"):
_xFormatObject.setPropertyValue("FormatKey", NewFormatKey)
else:
# TODO: throws a exception in a try catch environment, very helpful?
raise Exception
except Exception:
traceback.print_exc()
def getNullDateCorrection(self):
if not self.bNullDateCorrectionIsDefined:
dNullDate = Helper.getUnoStructValue(
self.xNumberFormatSettings, "NullDate")
lNullDate = Helper.convertUnoDatetoInteger(dNullDate)
oCal = java.util.Calendar.getInstance()
oCal.set(1900, 1, 1)
dTime = oCal.getTime()
lTime = dTime.getTime()
lDBNullDate = lTime / (3600 * 24000)
self.lDateCorrection = lDBNullDate - lNullDate
return self.lDateCorrection
else:
return self.lDateCorrection
def setBooleanReportDisplayNumberFormat(self):
FormatString = "[=1]" + str(9745) + ";[=0]" + str(58480) + ";0"
self.iLogicalFormatKey = self.xNumberFormats.queryKey(
FormatString, self.aLocale, True)
try:
if self.iLogicalFormatKey == -1:
self.iLogicalFormatKey = self.xNumberFormats.addNew(
FormatString, self.aLocale)
except Exception:
#MalformedNumberFormat
traceback.print_exc()
self.iLogicalFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.LOGICAL, self.aLocale)
return self.iLogicalFormatKey
'''
@return Returns the iDateFormatKey.
'''
def getDateFormatKey(self):
if self.iDateFormatKey == -1:
self.iDateFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.DATE, self.aLocale)
return self.iDateFormatKey
'''
@return Returns the iDateTimeFormatKey.
'''
def getDateTimeFormatKey(self):
if self.iDateTimeFormatKey == -1:
self.iDateTimeFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.DATETIME, self.aLocale)
return self.iDateTimeFormatKey
'''
@return Returns the iLogicalFormatKey.
'''
def getLogicalFormatKey(self):
if self.iLogicalFormatKey == -1:
self.iLogicalFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.LOGICAL, self.aLocale)
return self.iLogicalFormatKey
'''
@return Returns the iNumberFormatKey.
'''
def getNumberFormatKey(self):
if self.iNumberFormatKey == -1:
self.iNumberFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.NUMBER, self.aLocale)
return self.iNumberFormatKey
'''
@return Returns the iTextFormatKey.
'''
def getTextFormatKey(self):
if self.iTextFormatKey == -1:
self.iTextFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.TEXT, self.aLocale)
return self.iTextFormatKey
'''
@return Returns the iTimeFormatKey.
'''
def getTimeFormatKey(self):
if self.iTimeFormatKey == -1:
self.iTimeFormatKey = self.xNumberFormats.getStandardFormat(
NumberFormat.TIME, self.aLocale)
return self.iTimeFormatKey
......@@ -200,20 +200,6 @@ class OfficeDocument(object):
return bState
def ArraytoCellRange(self, datalist, oTable, xpos, ypos):
try:
rowcount = datalist.length
if rowcount > 0:
colcount = datalist[0].length
if colcount > 0:
xNewRange = oTable.getCellRangeByPosition(
xpos, ypos, (colcount + xpos) - 1,
(rowcount + ypos) - 1)
xNewRange.setDataArray(datalist)
except Exception:
traceback.print_exc()
def showMessageBox(
self, xMSF, windowServiceName, windowAttribute, MessageText):
......
......@@ -40,47 +40,6 @@ class TextFieldHandler(object):
xUp = self.xTextFieldsSupplier.TextFields
xUp.refresh()
def getUserFieldContent(self, xTextCursor):
try:
xTextRange = xTextCursor.getEnd()
oTextField = xTextRange.TextField
if com.sun.star.uno.AnyConverter.isVoid(oTextField):
return ""
else:
xMaster = oTextField.getTextFieldMaster()
UserFieldContent = xMaster.Content
return UserFieldContent
except Exception:
traceback.print_exc()
return ""
def insertUserField(self, xTextCursor, FieldName, FieldTitle):
try:
xField = self.xMSFDoc.createInstance(
"com.sun.star.text.TextField.User")
if self.xTextFieldsSupplier.TextFieldMasters.hasByName(
"com.sun.star.text.FieldMaster.User." + FieldName):
oMaster = self.xTextFieldsSupplier.TextFieldMasters.getByName( \
"com.sun.star.text.FieldMaster.User." + FieldName)
oMaster.dispose()
xPSet = createUserField(FieldName, FieldTitle)
xField.attachTextFieldMaster(xPSet)
xTextCursor.getText().insertTextContent(
xTextCursor, xField, False)
except Exception:
traceback.print_exc()
def createUserField(self, FieldName, FieldTitle):
xPSet = self.xMSFDoc.createInstance(
"com.sun.star.text.FieldMaster.User")
xPSet.Name = FieldName
xPSet.Content = FieldTitle
return xPSet
def __getTextFields(self):
try:
if self.xTextFieldsSupplier.TextFields.hasElements():
......@@ -143,15 +102,6 @@ class TextFieldHandler(object):
except Exception:
traceback.print_exc()
def fixDateFields(self, _bSetFixed):
try:
for i in TextFieldHandler.arrayTextFields:
if i.supportsService(
"com.sun.star.text.TextField.DateTime"):
i.IsFixed = _bSetFixed
except Exception:
traceback.print_exc()
def removeUserFieldByContent(self):
#Remove userfield when its text is empty
xDependentTextFields = TextFieldHandler.arrayTextFields
......
......@@ -41,35 +41,12 @@ class TextSectionHandler(object):
xAllTextSections = self.xTextDocument.TextSections
return xAllTextSections.hasByName(SectionName)
def removeLastTextSection(self):
try:
xAllTextSections = self.xTextDocument.TextSections
oTextSection = xAllTextSections.getByIndex(
xAllTextSections.getCount() - 1)
self.removeTextSection(oTextSection)
except Exception:
traceback.print_exc()
def removeTextSection(self, _oTextSection):
try:
self.xText.removeTextContent(_oTextSection)
except Exception:
traceback.print_exc()
def removeInvisibleTextSections(self):
try:
xAllTextSections = self.xTextDocument.TextSections
TextSectionCount = xAllTextSections.getCount()
i = TextSectionCount - 1
while i >= 0:
xTextContentTextSection = xAllTextSections.getByIndex(i)
if not bool(xTextContentTextSection.getPropertyValue("IsVisible")):
self.xText.removeTextContent(xTextContentTextSection)
i -= 1
except Exception:
traceback.print_exc()
def removeAllTextSections(self):
try:
TextSectionCount = self.xTextDocument.TextSections.Count
......
......@@ -71,7 +71,7 @@ class ControlScroller(object):
for i in range(ControlScroller.nblockincrement):
self.insertControlGroup(i, ypos)
ypos += self.linedistance
def fillupControls(self, binitialize):
for i in range(ControlScroller.nblockincrement):
if i < self.ncurfieldcount:
......@@ -79,7 +79,7 @@ class ControlScroller(object):
if binitialize:
self.CurUnoDialog.repaintDialogStep()
def fillupControl(self, guiRow):
nameProps = self.scrollfields[guiRow]
......@@ -114,24 +114,6 @@ class ControlScroller(object):
else:
self.xScrollBar.Model.Enabled = False
def toggleComponent(self, _bdoenable):
bdoenable = _bdoenable and \
(self.ntotfieldcount > ControlScroller.nblockincrement)
setattr("TitleScrollBar" + self.sincSuffix,
PropertyNames.PROPERTY_ENABLED, bdoenable)
def toggleControls(self, _bdoenable):
n = 0
while n < self.scrollfields.size():
curproperties = self.scrollfields.elementAt(n)
m = 0
while m < curproperties.length:
curproperty = curproperties[m]
setattr(curproperty.Name, PropertyNames.PROPERTY_ENABLED,
_bdoenable)
m += 1
n += 1
def scrollControls(self):
try:
self.nscrollvalue = \
......@@ -192,16 +174,3 @@ class ControlScroller(object):
return getattr(oControlModel, propertyname)
else:
return None
def getScrollFieldValues(self):
retproperties = [[self.scrollfields.size()],[]]
try:
i = 0
while i < self.scrollfields.size():
curproperties = self.scrollfields.elementAt(i)
retproperties[i] = curproperties
i += 1
return retproperties
except Exception:
traceback.print_exc()
return None
......@@ -60,18 +60,3 @@ class PeerConfig(object):
except Exception:
traceback.print_exc()
'''
@param oAPIControl an API control that the interface
XControl can be derived from
@param _propnames
@param _propvalues
'''
def setPeerProperties(self, _xControl, propnames, propvalues):
oPeerTask = self.PeerTask(_xControl, propnames, propvalues)
self.m_aPeerTasks.append(oPeerTask)
def setImageUrl(self, _ocontrolmodel, _oResource):
oImageUrlTask = self.ImageUrlTask(_ocontrolmodel, _oResource)
self.aImageUrlTasks.append(oImageUrlTask)
......@@ -46,79 +46,7 @@ class UnoDialog(object):
except Exception:
traceback.print_exc()
def getPeerConfiguration(self):
if self.m_oPeerConfig is None:
self.m_oPeerConfig = PeerConfig(self)
return self.m_oPeerConfig
def getMAPConversionFactor(self, ControlName):
xControl2 = self.xUnoDialog.getControl(ControlName)
aSize = xControl2.Size
dblMAPWidth = xControl2.Model.Width
return (aSize.Width / dblMAPWidth)
def getpreferredLabelSize(self, LabelName, sLabel):
xControl2 = self.xUnoDialog.getControl(LabelName)
OldText = xControl2.Text
xControl2.setText(sLabel)
aSize = xControl2.PreferredSize
xControl2.setText(OldText)
return aSize
def removeSelectedItems(self, xListBox):
SelList = xListBox.SelectedItemsPos
Sellen = SelList.length
i = Sellen - 1
while i >= 0:
xListBox.removeItems(SelList[i], 1)
i -= 1
def getListBoxItemCount(self, _xListBox):
# This function may look ugly, but this is the only way to check
# the count of values in the model,which is always right.
# the control is only a view and could be right or not.
fieldnames = getModel(_xListBox).StringItemList
return fieldnames.length
def getSelectedItemPos(self, _xListBox):
ipos = getModel(_xListBox).SelectedItems
return ipos[0]
def isListBoxSelected(self, _xListBox):
ipos = getModel(_xListBox).SelectedItems
return ipos.length > 0
'''
The problem with setting the visibility of controls is that
changing the current step of a dialog will automatically make
all controls visible. The PropertyNames.PROPERTY_STEP property
always wins against the property "visible".
Therefore a control meant to be invisible is placed on a step far far away.
Afterwards the step property of the dialog has to be set with
"repaintDialogStep". As the performance of that method is very bad it
should be used only once for all controls
@param controlname the name of the control
@param bIsVisible sets the control visible or invisible
'''
def setControlVisible(self, controlname, bIsVisible):
try:
iCurControlStep = int(getControlProperty(
controlname, PropertyNames.PROPERTY_STEP))
iCurDialogStep = int(self.xDialogModel.Step)
if bIsVisible:
setControlProperty(
controlname, PropertyNames.PROPERTY_STEP, iCurDialogStep)
else:
setControlProperty(
controlname, PropertyNames.PROPERTY_STEP,
UIConsts.INVISIBLESTEP)
except Exception:
traceback.print_exc()
# repaints the currentDialogStep
def repaintDialogStep(self):
try:
ncurstep = int(self.xDialogModel.Step)
......@@ -144,22 +72,6 @@ class UnoDialog(object):
oFocusControl = self.xUnoDialog.getControl(ControlName)
oFocusControl.setFocus()
def selectListBoxItem(self, xListBox, iFieldsSelIndex):
if iFieldsSelIndex > -1:
FieldCount = xListBox.getItemCount()
if FieldCount > 0:
if iFieldsSelIndex < FieldCount:
xListBox.selectItemPos(iFieldsSelIndex, True)
else:
xListBox.selectItemPos((short)(iFieldsSelIndex - 1), True)
# deselects a Listbox. MultipleMode is not supported
def deselectListBox(self, _xBasisListBox):
oListBoxModel = getModel(_xBasisListBox)
sList = oListBoxModel.StringItemList
oListBoxModel.StringItemList = [[],[]]
oListBoxModel.StringItemList = sList
def calculateDialogPosition(self, FramePosSize):
# Todo:check if it would be useful or possible to create a dialog peer
# that can be used for the messageboxes to
......@@ -215,11 +127,6 @@ class UnoDialog(object):
return self.executeDialog( Rectangle (0, 0, 640, 400))
def modifyFontWeight(self, ControlName, FontWeight):
oFontDesc = FontDescriptor.FontDescriptor()
oFontDesc.Weight = FontWeight
setControlProperty(ControlName, "FontDescriptor", oFontDesc)
'''
create a peer for this
dialog, using the given
......
......@@ -55,18 +55,6 @@ class UnoDialog2(UnoDialog):
return xButton
def insertImageButton(
self, sName, actionPerformed, sPropNames, oPropValues, listener):
xButton = self.insertControlModel(
"com.sun.star.awt.UnoControlButtonModel",
sName, sPropNames, oPropValues)
if actionPerformed is not None:
actionPerformed = getattr(listener, actionPerformed)
xButton.addActionListener(
ActionListenerProcAdapter(actionPerformed))
return xButton
def insertCheckBox(
self, sName, itemChanged, sPropNames, oPropValues, listener):
xCheckBox = self.insertControlModel(
......@@ -184,13 +172,6 @@ class UnoDialog2(UnoDialog):
"com.sun.star.awt.UnoControlTimeFieldModel",
sPropNames, oPropValues, listener)
def insertFormattedField(
self, sName, sTextChanged, sPropNames, oPropValues, listener):
return self.insertEditField(
sName, sTextChanged,
"com.sun.star.awt.UnoControlFormattedFieldModel",
sPropNames, oPropValues, listener)
def insertFixedLine(self, sName, sPropNames, oPropValues):
oLine = self.insertControlModel(
"com.sun.star.awt.UnoControlFixedLineModel",
......
......@@ -323,20 +323,6 @@ class WizardDialog(UnoDialog2):
except Exception:
traceback.print_exc()
def setStepEnabled(self, _nStep, bEnabled, enableNextButton=None):
xRoadmapItem = self.getRoadmapItemByID(_nStep)
if xRoadmapItem is not None:
xRoadmapItem.Enabled = bEnabled
if enableNextButton is not None:
if self.getNextAvailableStep() > 0:
self.enableNextButton(bEnabled)
def enableNavigationButtons(
self, _bEnableBack, _bEnableNext, _bEnableFinish):
self.enableBackButton(_bEnableBack)
self.enableNextButton(_bEnableNext)
self.enableFinishButton(_bEnableFinish)
def enableBackButton(self, enabled):
self.xDialogModel.btnWizardBack.Enabled = enabled
......@@ -346,16 +332,6 @@ class WizardDialog(UnoDialog2):
def enableFinishButton(self, enabled):
self.xDialogModel.btnWizardFinish.Enabled = enabled
def enablefromStep(self, _iStep, _bDoEnable):
if _iStep <= self.nMaxStep:
for i in list(range(_iStep, self.nMaxStep)):
self.setStepEnabled(i, _bDoEnable)
enableFinishButton(_bDoEnable)
if not _bDoEnable:
enableNextButton(_iStep > getCurrentStep() + 1)
else:
enableNextButton(not (getCurrentStep() == self.nMaxStep))
def isStepEnabled(self, _nStep):
try:
xRoadmapItem = self.getRoadmapItemByID(_nStep)
......@@ -431,29 +407,6 @@ class WizardDialog(UnoDialog2):
traceback.print_exc()
return -1
def setCurrentStep(self, _nNewstep):
self.nNewStep = _nNewstep
changeToStep(self.nNewStep)
def setRightPaneHeaders(self, _sRightPaneHeaders):
self.nMaxStep = len(_sRightPaneHeaders)
self.sRightPaneHeaders = _sRightPaneHeaders
oFontDesc = uno.createUnoStruct('com.sun.star.awt.FontDescriptor')
oFontDesc.Weight = BOLD
for i in range(self.nMaxStep):
self.insertLabel("lblQueryTitle" + str(i),
("FontDescriptor",
PropertyNames.PROPERTY_HEIGHT,
PropertyNames.PROPERTY_LABEL,
PropertyNames.PROPERTY_MULTILINE,
PropertyNames.PROPERTY_POSITION_X,
PropertyNames.PROPERTY_POSITION_Y,
PropertyNames.PROPERTY_STEP,
PropertyNames.PROPERTY_TABINDEX,
PropertyNames.PROPERTY_WIDTH),(
oFontDesc, 16, _sRightPaneHeaders[i],
True, 91, 8, i + 1, 12, 212))
def cancelWizard(self):
#can be overwritten by extending class
self.xUnoDialog.endExecute()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment