def test_ooo_ns(self): """ Check that ooo exists in namespace declarations """ calcdoc = OpenDocumentSpreadsheet() table = odf.table.Table(name="Costs") forms = odf.office.Forms() form = odf.form.Form( controlimplementation="ooo:com.sun.star.form.component.Form") lb = odf.form.Listbox( controlimplementation="ooo:com.sun.star.form.component.ListBox", dropdown="true", id="control1") form.addElement(lb) forms.addElement(form) table.addElement(forms) # One empty line tr = odf.table.TableRow() table.addElement(tr) tr = odf.table.TableRow() # One empty cell cell = odf.table.TableCell() tr.addElement(cell) cell = odf.table.TableCell() draw = odf.draw.Control(control="control1", height="0.1126in", width="0.798in", x="0.0303in", y="0.0205in", endcelladdress="Costs.B2", endx="0.8283in", endy="0.1331in") cell.addElement(draw) tr.addElement(cell) table.addElement(tr) calcdoc.spreadsheet.addElement(table) result = calcdoc.contentxml( ) # contentxml() is supposed to yeld a bytes self.assertNotEqual( -1, result.find(b'''xmlns:ooo="http://openoffice.org/2004/office"'''))
def test_ooo_ns(self): """ Check that ooo exists in namespace declarations """ calcdoc = OpenDocumentSpreadsheet() table = odf.table.Table(name="Costs") forms = odf.office.Forms() form = odf.form.Form( controlimplementation="ooo:com.sun.star.form.component.Form") lb = odf.form.Listbox( controlimplementation="ooo:com.sun.star.form.component.ListBox", dropdown="true", id="control1") form.addElement(lb) forms.addElement(form) table.addElement(forms) # One empty line tr = odf.table.TableRow() table.addElement(tr) tr = odf.table.TableRow() # One empty cell cell = odf.table.TableCell() tr.addElement(cell) cell = odf.table.TableCell() draw = odf.draw.Control( control="control1", height="0.1126in", width="0.798in", x="0.0303in", y="0.0205in", endcelladdress="Costs.B2", endx="0.8283in", endy="0.1331in") cell.addElement(draw) tr.addElement(cell) table.addElement(tr) calcdoc.spreadsheet.addElement(table) result = unicode(calcdoc.contentxml(),'utf-8') self.assertNotEqual(-1, result.find(u'''xmlns:ooo="http://openoffice.org/2004/office"'''))
def create_form(self, calcdoc, sreqs): forms = odf.office.Forms( applydesignmode="false", automaticfocus="false") form = odf.form.Form( applyfilter="true", commandtype="table", controlimplementation="ooo:com.sun.star.form.component.Form", name="Standard", targetframe="", href="") # Listboxes for compliant i=0 for req in sreqs: lb = odf.form.Listbox( id="lbcompliant%s" % req.name, boundcolumn="1", dropdown="yes", controlimplementation="ooo:com.sun.star.form.component.ListBox", linkedcell="Deps.%s2" % self.sscoords[i], listlinkagetype="selection", name="ListBox Compliant %s" % req.name, size="3", sourcecellrange="Constants.A1:Constants.A3" ) lbproperties = odf.form.Properties() lbprop = odf.form.Property( propertyname="DefaultControl", stringvalue="com.sun.star.form.control.ListBox", valuetype="string") lbproperties.addElement(lbprop) # Default selection lstprop = odf.form.ListProperty( propertyname="DefaultSelection", valuetype="float") defaultval = odf.form.ListValue(stringvalue='0') lstprop.addElement(defaultval) lbproperties.addElement(lstprop) lb.addElement(lbproperties) form.addElement(lb) i+=1 # Listboxes for dependent from i=0 for req in sreqs: # When there is only one entry in the list, there is no # need to have a dropdown list. ddown="yes" if len(req.outgoing)<=1: ddown="no" lb = odf.form.Listbox( id="lbdependentfrom%s" % req.name, boundcolumn="1", dropdown="yes", controlimplementation="ooo:com.sun.star.form.component.ListBox", linkedcell="Deps.%s3" % self.sscoords[i], listlinkagetype="selection", name="ListBox Dependet From %s" % req.name, size="3", sourcecellrange="Deps.%s5:Deps.%s%d" % ( self.sscoords[i], self.sscoords[i], len(req.outgoing)+4) ) lbproperties = odf.form.Properties() lbprop = odf.form.Property( propertyname="DefaultControl", stringvalue="com.sun.star.form.control.ListBox", valuetype="string") lbproperties.addElement(lbprop) # Default selection lstprop = odf.form.ListProperty( propertyname="DefaultSelection", valuetype="float") defaultval = odf.form.ListValue(stringvalue='0') lstprop.addElement(defaultval) lbproperties.addElement(lstprop) # Read only # When there is only one dependent requirement, it makes # no sense to have something which can be changed. # Therefore this should be readonly then. if len(req.outgoing)<=1: lstprop = odf.form.Property( propertyname="ReadOnly", valuetype="boolean", booleanvalue="true") lbproperties.addElement(lstprop) lb.addElement(lbproperties) form.addElement(lb) i+=1 forms.addElement(form) calcdoc.addElement(forms)
def create_form(self, calcdoc, sreqs): forms = odf.office.Forms( applydesignmode="false", automaticfocus="false") form = odf.form.Form( applyfilter="true", commandtype="table", controlimplementation="ooo:com.sun.star.form.component.Form", name="Standard", targetframe="", href="") # Listboxes for compliant i = 0 for req in sreqs: lb = odf.form.Listbox( id="lbcompliant%s" % req.get_name(), boundcolumn="1", dropdown="yes", controlimplementation="ooo:com.sun.star.form.component.ListBox", linkedcell="Deps.%s2" % self.__sscoords[i], listlinkagetype="selection", name="ListBox Compliant %s" % req.get_name(), size="3", sourcecellrange="Constants.A1:Constants.A3" ) lbproperties = odf.form.Properties() lbprop = odf.form.Property( propertyname="DefaultControl", stringvalue="com.sun.star.form.control.ListBox", valuetype="string") lbproperties.addElement(lbprop) # Default selection lstprop = odf.form.ListProperty( propertyname="DefaultSelection", valuetype="float") defaultval = odf.form.ListValue(stringvalue='0') lstprop.addElement(defaultval) lbproperties.addElement(lstprop) lb.addElement(lbproperties) form.addElement(lb) i += 1 # Listboxes for dependent from i = 0 for req in sreqs: # When there is only one entry in the list, there is no # need to have a dropdown list. ddown = "yes" if req.get_incoming_cnt() <= 1: ddown = "no" lb = odf.form.Listbox( id="lbdependentfrom%s" % req.get_name(), boundcolumn="1", dropdown="yes", controlimplementation="ooo:com.sun.star.form.component.ListBox", linkedcell="Deps.%s3" % self.__sscoords[i], listlinkagetype="selection", name="ListBox Dependet From %s" % req.get_name(), size="3", sourcecellrange="Deps.%s5:Deps.%s%d" % ( self.__sscoords[i], self.__sscoords[i], req.get_incoming_cnt() + 4) ) lbproperties = odf.form.Properties() lbprop = odf.form.Property( propertyname="DefaultControl", stringvalue="com.sun.star.form.control.ListBox", valuetype="string") lbproperties.addElement(lbprop) # Default selection lstprop = odf.form.ListProperty( propertyname="DefaultSelection", valuetype="float") defaultval = odf.form.ListValue(stringvalue='0') lstprop.addElement(defaultval) lbproperties.addElement(lstprop) # Read only # When there is only one dependent requirement, it makes # no sense to have something which can be changed. # Therefore this should be readonly then. if req.get_incoming_cnt() <= 1: lstprop = odf.form.Property( propertyname="ReadOnly", valuetype="boolean", booleanvalue="true") lbproperties.addElement(lstprop) lb.addElement(lbproperties) form.addElement(lb) i += 1 forms.addElement(form) calcdoc.addElement(forms)