def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) row = 0 col = 0 text = sheet.getCellByPosition(row, col).getFormula() while text != "Z": while text != "Z": if ( text == u"\u2190" or text == u"\u2191" or text == u"\u2192" or text == u"\u2193" or text == "N" or text == "S" or text == "W" or text == "E" ): sheet.getCellByPosition(col, row).setFormula("") col += 1 text = sheet.getCellByPosition(col, row).getFormula() row += 1 col = 0 text = sheet.getCellByPosition(col, row).getFormula()
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) row = 0 col = 0 text = sheet.getCellByPosition(row, col).getFormula() while text != 'Z': while text != 'Z': if text == u"\u2190" or \ text == u"\u2191" or \ text == u"\u2192" or \ text == u"\u2193" or \ text == 'N' or \ text == 'S' or \ text == 'W' or \ text == 'E': sheet.getCellByPosition(col, row).setFormula('') col += 1 text = sheet.getCellByPosition(col, row).getFormula() row += 1 col = 0 text = sheet.getCellByPosition(col, row).getFormula()
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() sheet = doc.getSheets().getByIndex(0) col = row = 0 cell = sheet.getCellByPosition(col, row) text = cell.getFormula() while text != 'Z': while text != 'Z': srcCoord = CellCoordinates(col, row) # if it is a wall-cell, jump it if isWall(sheet, srcCoord): col += 1 text = sheet.getCellByPosition(col, row).getFormula() continue srcCell = sheet.getCellByPosition(srcCoord.col, \ srcCoord.row) print srcCell.CellBackColor if srcCell.CellBackColor == 32768: srcState = nameState(srcCoord.col, srcCoord.row) col += 1 text = sheet.getCellByPosition(col, row).getFormula() col = 0 row += 1 text = sheet.getCellByPosition(col, row).getFormula()
def export_pdf(self, target: str = None, source: str = None): ## open docx with libreoffice if source: path = source else: if self.filename: path = self.filename else: raise BaseException("Error source filename") if target: target_path = target else: target_path = "file://" + self.filename print("Loading file " + path) p = makePropertyValue("Hidden", True) oDoc = ooo.loadComponentFromURL("file://" + path, (p, )) if False: ## add a page break and insert a document cursor = oDoc.Text.createTextCursor() cursor.gotoStart(False) # Inserts a paragraph break at cursor position oDoc.Text.insertControlCharacter( cursor.End, uno.getConstantByName( 'com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK'), False) cursor.gotoStart(False) cursor.insertDocumentFromURL( "file:///work/deva/dev/docs/sdd/templates/test.odt", ()) ## refresh all indexes (TOC, etc.) dispatcher = Danny.OOo.OOoLib.createUnoService( "com.sun.star.frame.DispatchHelper") #dispatcher.executeDispatch(oDoc.getCurrentController(), ".uno:UpdateAllIndexes", "", 0, ()) dispatcher.executeDispatch(oDoc.getCurrentController(), ".uno:UpdateAll", "", 0, ()) ## export to PDF p = makePropertyValue("FilterName", "writer_pdf_Export") oDoc.storeToURL(target_path, (p, )) ## clean all #oDoc.store() oDoc.dispose() oDoc.close(True)
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() sheet = doc.getSheets().getByIndex(0) col = row = 0 cell = sheet.getCellByPosition(col, row) text = cell.getFormula() S = [] A = resolveActions() T = [] R = [] G = [] while text != 'Z': while text != 'Z': srcCoord = CellCoordinates(col, row) # if it is a wall-cell, jump it if isWall(sheet, srcCoord): col += 1 text = sheet.getCellByPosition(col, row).getFormula() continue srcState = nameState(srcCoord.col, srcCoord.row) S.append(srcState) resolveGoal(sheet, srcCoord, G) for a in A: resolveTransitionAndReward(sheet, srcCoord, a, T, R, G) col += 1 text = sheet.getCellByPosition(col, row).getFormula() col = 0 row += 1 text = sheet.getCellByPosition(col, row).getFormula() list2file(S, sys.argv[1] + 'states.in') actions2file(A, sys.argv[1] + 'actions.in') list2file(T, sys.argv[1] + 'transitions.in') list2file(R, sys.argv[1] + 'rewards.in') list2file(G, sys.argv[1] + 'goals.in')
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) row = 0 col = 0 text = sheet.getCellByPosition(row, col).getFormula() while text != "Z": while text != "Z": print row, col, sheet.getCellByPosition(col, row).getFormula() col += 1 text = sheet.getCellByPosition(row, col).getFormula() row += 1 col = 0 text = sheet.getCellByPosition(row, col).getFormula()
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) row = 0 col = 0 text = sheet.getCellByPosition(row, col).getFormula() while text != 'Z': while text != 'Z': print row, col, sheet.getCellByPosition(col, row).getFormula() col += 1 text = sheet.getCellByPosition(row, col).getFormula() row += 1 col = 0 text = sheet.getCellByPosition(row, col).getFormula()
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) P = [] f = open(sys.argv[1] + 'policy.out') for line in f: row = line[:line.find('col')] row = row.replace('row','') col = line[line.find('col'):] col = col.replace('col','') action = line.split()[1] p = [] p.append(col) p.append(row) p.append(action) P.append(p) for p in P: cell = sheet.getCellByPosition(p[0], p[1]) value = cell.getValue() if value: print cell.CellBackColor else: if p[2] == 'North': c = u"\u2191" if p[2] == 'South': c = u"\u2193" if p[2] == 'West': c = u"\u2190" if p[2] == 'East': c = u"\u2192" sheet.getCellByPosition(p[0], p[1]).setFormula(c) cell.CellBackColor = 32768
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) P = [] f = open(sys.argv[1] + 'policy.out') for line in f: row = line[:line.find('col')] row = row.replace('row', '') col = line[line.find('col'):] col = col.replace('col', '') action = line.split()[1] p = [] p.append(col) p.append(row) p.append(action) P.append(p) for p in P: value = sheet.getCellByPosition(p[0], p[1]).getValue() if value: pass else: if p[2] == 'North': c = u"\u2191" if p[2] == 'South': c = u"\u2193" if p[2] == 'West': c = u"\u2190" if p[2] == 'East': c = u"\u2192" sheet.getCellByPosition(p[0], p[1]).setFormula(c)
def main(): desktop = OOoLib.getDesktop() doc = desktop.getCurrentComponent() # Insert code from above to get the document # reference 'doc'. sheet = doc.getSheets().getByIndex(0) row = 0 col = 0 cell = sheet.getCellByPosition(col, row) text = cell.getFormula() S = [] T = [] R = [] G = [] while text != 'Z': while text != 'Z': currentCell = sheet.getCellByPosition(col, row) targetCell = sheet.getCellByPosition(col, row - 1) resolveTransition(currentCell, targetCell) cellType = currentCell.getType() if cellType == TEXT: # It is a 'X'-cell, in other words, a wall # Nothing to do here pass else: # It is a normal cell # create the state s s = 'row' + str(row) + 'col' + str(col) S.append(s) # North neighbor if sheet.getCellByPosition(col, row - 1).getType() == TEXT: pass else: s2 = nameState(col, row - 1) r0 = sheet.getCellByPosition(col, row).getValue() if r0: pass else: T.append(s + ' North ' + s2 + ' ' + str(1.0)) # resolve rewards r = sheet.getCellByPosition(col, row - 1).getValue() if r: rStr = s + ' ' + 'North' + ' ' + str(r) R.append(rStr) # South neighbor if sheet.getCellByPosition(col, row + 1).getType() == TEXT: pass else: s2 = 'row' + str(row + 1) + 'col' + str(col) r0 = sheet.getCellByPosition(col, row).getValue() if r0: pass else: T.append(s + ' South ' + s2 + ' ' + str(1.0)) # resolve rewards r = sheet.getCellByPosition(col, row + 1).getValue() if r: rStr = s + ' ' + 'South' + ' ' + str(r) R.append(rStr) # West neighbor if sheet.getCellByPosition(col - 1, row).getType() == TEXT: pass else: s2 = 'row' + str(row) + 'col' + str(col - 1) r0 = sheet.getCellByPosition(col, row).getValue() if r0: pass else: T.append(s + ' West ' + s2 + ' ' + str(1.0)) # resolve rewards r = sheet.getCellByPosition(col - 1, row).getValue() if r != 0: rStr = s + ' ' + 'West' + ' ' + str(r) R.append(rStr) # East neighbor if sheet.getCellByPosition(col + 1, row).getType() == TEXT: pass else: s2 = 'row' + str(row) + 'col' + str(col + 1) r0 = sheet.getCellByPosition(col, row).getValue() if r0: pass else: T.append(s + ' East ' + s2 + ' ' + str(1.0)) # resolve rewards r = sheet.getCellByPosition(col + 1, row).getValue() if r != 0: rStr = s + ' ' + 'East' + ' ' + str(r) R.append(rStr) if currentCell.CellBackColor == 32768: G.append(s) col += 1 text = sheet.getCellByPosition(col, row).getFormula() row += 1 col = 0 text = sheet.getCellByPosition(col, row).getFormula() f = open(sys.argv[1] + 'states.in', 'w') for s in S: f.write(s + '\n') f.close() f = open(sys.argv[1] + 'actions.in', 'w') f.write('North\n') f.write('South\n') f.write('West\n') f.write('East\n') f.close() f = open(sys.argv[1] + 'transitions.in', 'w') for t in T: f.write(t + '\n') f.close() f = open(sys.argv[1] + 'rewards.in', 'w') for r in R: f.write(r + '\n') f.close() f = open(sys.argv[1] + 'goals.in', 'w') for g in G: f.write(g + '\n') f.close()