1
#########################################################################
3
# Copyright (c) 2003-2004 Danny Brewer d29583@groovegarden.com
4
# Copyright (C) 2004-2010 OpenERP SA (<http://openerp.com>).
6
# This library is free software; you can redistribute it and/or
7
# modify it under the terms of the GNU Lesser General Public
8
# License as published by the Free Software Foundation; either
9
# version 2.1 of the License, or (at your option) any later version.
11
# This library is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
# Lesser General Public License for more details.
16
# You should have received a copy of the GNU Lesser General Public
17
# License along with this library; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
# See: http://www.gnu.org/licenses/lgpl.html
22
#############################################################################
29
from com.sun.star.task import XJobExecutor
30
if __name__<>"package":
32
from Expression import Expression
33
from Fields import Fields
34
from Repeatln import RepeatIn
35
from lib.error import *
39
class modify(unohelper.Base, XJobExecutor ):
40
def __init__(self, ctx):
42
self.module = "openerp_report"
45
# Variable Declaration
46
desktop = getDesktop()
47
doc = desktop.getCurrentComponent()
48
docinfo = doc.getDocumentInfo()
49
self.oVC = doc.CurrentController.getViewCursor()
50
if not docinfo.getUserFieldValue(0)=="":
51
self.sMyHost= docinfo.getUserFieldValue(0)
54
"Please insert user define field Field-1",
55
"Just go to File->Properties->User Define \n"
56
"Field-1 E.g. http://localhost:8069"
60
# Check weather Field-4 is available or not otherwise exit from application
61
if not docinfo.getUserFieldValue(3) == "" and not docinfo.getUserFieldValue(0)=="":
62
if self.oVC.TextField:
63
self.oCurObj=self.oVC.TextField
64
item = self.oCurObj.Items[0]
66
kind, group1, group2 = self.getOperation(self.oCurObj.Items[1] )
68
start_group1 = group1[:group1.find(".")]
69
stop_group1 = group1[group1.find("."):].replace(".", "/")
72
Fields( start_group1, stop_group1, item, True )
73
elif kind == "expression":
74
Expression( group1, item, True )
75
elif kind == "repeatIn":
76
RepeatIn( start_group1, group2, stop_group1, item, True )
79
"Please place your cursor at beginning of field that you want to modify.",""
84
"Please insert user define field Field-1 or Field-4",
85
"Just go to File->Properties->User Define \n"
86
"Field-1 E.g. http://localhost:8069 \n"
88
"Field-4 E.g. account.invoice"
92
def getOperation(self, str):
93
#str = "[[ RepeatIn(objects, 'variable') ]]" #repeatIn
94
#str = "[[ saleorder.partner_id.name ]]" # field
95
#str = "[[ some thing complex ]]" # expression
96
method1 = lambda x: (u'repeatIn', x.group(1), x.group(2))
97
method2 = lambda x: (u'field', x.group(1), None)
98
method3 = lambda x: (u'expression', x.group(1), None)
100
('\\[\\[ *repeatIn\\( *(.+)*, *\'([a-zA-Z0-9_]+)\' *\\) *\\]\\]', method1),
101
('\\[\\[ *([a-zA-Z0-9_\.]+) *\\]\\]', method2),
102
('\\[\\[ *(.+) *\\]\\]', method3)
104
for (rule,method) in regexes:
105
res = re.match(rule, str)
109
if __name__<>"package":
112
g_ImplementationHelper.addImplementation( modify, "org.openoffice.openerp.report.modify", ("com.sun.star.task.Job",),)
115
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: