#!/usr/bin/env python # # This file is part of the LibreOffice project. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. # import sys import os import xml.parsers.expat alltitles=[] def is_present(title): for i in alltitles: try: if i.strip() == title.strip(): return True except: return False return False def make_unique(title): n=0 t = title while is_present(t): n=n+1 t = title+"_%d"%(n) return t replace_text_list = [ ["$[officename]","LibreOffice"], ["%PRODUCTNAME","LibreOffice"], ["$PRODUCTNAME","LibreOffice"], ['"+"',"Plus"], ['"*"',"Star"], ['"-"',"Minus"], ['"/"',"Slash"], ['"^"',"Cap"], ['#',"No"], [')','_'], ['(','_'], [']','_'], ['[','_'], ['\\','_'], ['/','_'], ['&',"and"], [';','_'] ] replace_readable_list = [ ["$[officename]","{{ProductName}}"], ["%PRODUCTNAME","{{ProductName}}"], ["$PRODUCTNAME","{{ProductName}}"] ] modules_list = [ ["sbasic","Basic"], ["scalc","Calc"], ["schart","Chart"], ["sdraw","Draw"], ["simpress","Impress"], ["smath","Math"], ["swriter","Writer"], ["shared","Common"] ] def get_module(text): for i in modules_list: if text.find('/' + i[0] + '/') >=0: return i[1] return "" def replace_text(text, replace_list): for i in replace_list: if text.find(i[0]) >= 0: text = text.replace(i[0],i[1]) return text def wiki_text(text): t = replace_text(text, replace_text_list) if t == '': t = 'LibreOffice' # hardcoded fallback return t.strip() def readable_text(text): return replace_text(text, replace_readable_list) class TitleParser: title = '' is_title = False def start_element(self, name, attrs): if name == 'title': self.is_title = True def end_element(self, name): if name == 'title': self.is_title = False def char_data(self, data): if self.is_title: self.title = self.title + data def get_title(self): return self.title.strip() def parsexhp(filename): module = get_module(filename) if module == '': return parsing = True file=open(filename,"r") p = xml.parsers.expat.ParserCreate() tp = TitleParser() p.StartElementHandler = tp.start_element p.EndElementHandler = tp.end_element p.CharacterDataHandler = tp.char_data buf = file.read() try: p.Parse(buf) except: sys.stderr.write('Cannot parse %s, skipping it\n'% filename) file.close() return file.close() title = tp.get_title() if len(title) > 0: readable_title = readable_text(title) title = module + '/' + wiki_text(title) title = title.replace(' ', '_') title = title.replace('___', '_') title = title.replace('__', '_') title = title.strip('_') title = make_unique(title) alltitles.append(title) return((filename, title, readable_title)) # Main Function def gettitles(path): pattern = "xhp" alltitles = [] for root, dirs, files in os.walk(path): for i in files: if i.find(pattern) >= 0: t = parsexhp(root+"/"+i) if t is not None: alltitles.append(t) return alltitles # vim:set shiftwidth=4 softtabstop=4 expandtab: istro/collabora/cp-4.0 LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/sw/inc/swcommands.h
AgeCommit message (Expand)Author
2017-04-13convert annotation menu to .uiCaolán McNamara
2017-04-12convert header/footer menu to .uiCaolán McNamara
2017-04-12convert annotation page break menu to .uiCaolán McNamara
2016-02-28Unused definesMaxim Monastirsky
2016-02-21Convert RID_INSERT_FIELD_CTRL to xmlMaxim Monastirsky
2016-01-19Kill .src based Writer context menusMaxim Monastirsky
2015-11-01tdf#80657 Adding new field to jump to specific page.Gulsah Kose
2015-01-08brute-force find-and-remove of unused #define constants.Noel Grandin
2014-12-18Typo: .uno:*TracedChange -> .uno:*TrackedChange.Jan Holesovsky
2014-06-19sw: add UI for removing the textbox of a draw shapeMiklos Vajna
2014-06-19sw: add UI for adding a textbox for a draw shapeMiklos Vajna
2014-04-29do not have a separate action for accepting changes in a selectionLuboš Luňák
2014-04-28allow accepting/rejecting changes in a selection (bnc#874790)Luboš Luňák
2014-04-23add a 'format all comments' featureCaolán McNamara
2013-11-05fixincludeguards.sh: swThomas Arnhold
2013-10-16[API CHANGE]: PreView -> Preview, including .uno:PrintPagePreView.Jan Holesovsky
2013-05-20Resolves: #i121420# merge sidebar featureOliver-Rainer Wittmann
2012-11-27fdo#48317 - Support jumping to next/previous changeMuhammad Haggag
2012-09-28Drop .src layout for inserttable and use Gokul's .uiCaolán McNamara
2012-07-01Combine popup menu entries and IDs (SID_SAVE_GRAPHIC)Tomaž Vajngerl
2012-06-28Enable menu option "Edit witn External Tool.." for Calc.Tomaž Vajngerl
2012-06-22re-base on ALv2 code.Michael Meeks
2012-06-13Tidy up *commands.h - Remove unused CMD_ definesThomas Arnhold
2012-06-08targetted revert of OLE2 object save in writer context menuMichael Meeks