public boolean processSelectInsert() { if (enabledControls.contains(new String("dt_initdebate_hansarddate"))) { // get the value and set it into the document String dateOfHansard = (String) theControlDataMap.get("dt_initdebate_hansarddate"); ooDocMetadata meta = new ooDocMetadata(ooDocument); meta.AddProperty("Bungeni_DebateOfficialDate", dateOfHansard); XTextRange selRange = (XTextRange) ooDocument.getSingleSelectionRange().get("XTextRange"); String strSelection = selRange.getString(); boolean bDateAdd = action_replaceTextWithField(ooDocument, "debaterecord_official_date", strSelection); if (!bDateAdd) { checkFieldsMessages.add("There was an error while marking the handard date"); } return bDateAdd; } if (enabledControls.contains(new String("dt_initdebate_timeofhansard"))) { // get the current time value into the document String timeOfHansard = (String) theControlDataMap.get("dt_initdebate_timeofhansard"); ooDocMetadata meta = new ooDocMetadata(ooDocument); meta.AddProperty("Bungeni_DebateOfficialTime", timeOfHansard); XTextRange selRange = (XTextRange) ooDocument.getSingleSelectionRange().get("XTextRange"); String strSelection = selRange.getString(); boolean bTimeAdd = action_replaceTextWithField(ooDocument, "debaterecord_official_time", strSelection); if (!bTimeAdd) { checkFieldsMessages.add("There was an error while marking the handard time"); } return bTimeAdd; } return true; }
public boolean postFullEdit() { boolean bFullEdit = false; try { ooDocMetadata meta = new ooDocMetadata(ooDocument); meta.AddProperty( "Bungeni_DebateOfficialDate", (String) theControlDataMap.get("dt_initdebate_hansarddate")); meta.AddProperty( "Bungeni_DebateOfficialTime", (String) theControlDataMap.get("dt_initdebate_timeofhansard")); bFullEdit = true; } catch (Exception ex) { log.error("postFullEdit: error :" + ex.getMessage()); checkFieldsMessages.add("There was an error setting document level metadata"); bFullEdit = false; return bFullEdit; } finally { return bFullEdit; } }
private boolean sectionEditAction() { // if section exists // update fields String containerSection = theAction.action_naming_convention(); if (ooDocument.hasSection(containerSection) && ooDocument.hasSection("int:masthead_datetime")) { // now edit the fields and set the new values String strDebateDate = "", strTimeOfHansard = ""; Date dtDebate = dt_initdebate_hansarddate.getDate(); SimpleDateFormat df = new SimpleDateFormat("HH:mm"); strTimeOfHansard = df.format((Date) dt_initdebate_timeofhansard.getValue()); // .getText(); SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd yyyy"); strDebateDate = formatter.format(dtDebate); ExternalMacro setFieldValue = ExternalMacroFactory.getMacroDefinition("SetReferenceInputFieldValue"); setFieldValue.addParameter(new String("debaterecord_official_date")); setFieldValue.addParameter(strDebateDate); setFieldValue.addParameter(new String("int:masthead_datetime")); ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams()); setFieldValue.clearParams(); setFieldValue.addParameter(new String("debaterecord_official_time")); setFieldValue.addParameter(strTimeOfHansard); setFieldValue.addParameter(new String("int:masthead_datetime")); ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams()); // set date and time of hansard to document ooDocMetadata meta = new ooDocMetadata(ooDocument); meta.AddProperty("Bungeni_DebateOfficialDate", strDebateDate); meta.AddProperty("Bungeni_DebateOfficialTime", strTimeOfHansard); return true; } else { MessageBox.OK(parent, "There is no masthead section available for editing in this document!"); return false; } }
private boolean sectionInsertionAction() { String strDebateDate = "", strTimeOfHansard = "", strLogoPath = ""; Date dtDebate = dt_initdebate_hansarddate.getDate(); SimpleDateFormat df = new SimpleDateFormat("HH:mm"); strTimeOfHansard = df.format((Date) dt_initdebate_timeofhansard.getValue()); SimpleDateFormat formatter = new SimpleDateFormat("MMMM dd yyyy"); strDebateDate = formatter.format(dtDebate); strLogoPath = m_strLogoPath; long sectionBackColor = 0xffffff; float sectionLeftMargin = (float) .2; log.debug("section left margin : " + sectionLeftMargin); // get the parent section name of this action // query action parents to find the parent of this action // String parentSectionName = ExternalMacro AddSectionInsideSection = ExternalMacroFactory.getMacroDefinition("AddSectionInsideSectionWithStyle"); AddSectionInsideSection.addParameter(ooDocument.getComponent()); AddSectionInsideSection.addParameter(BungeniEditorPropertiesHelper.getDocumentRoot()); AddSectionInsideSection.addParameter(theAction.action_naming_convention()); AddSectionInsideSection.addParameter(sectionBackColor); AddSectionInsideSection.addParameter(sectionLeftMargin); ooDocument.executeMacro( AddSectionInsideSection.toString(), AddSectionInsideSection.getParams()); this.setSectionMetadataForAction(theAction.action_naming_convention(), theAction); // embed logo image ExternalMacro addImageIntoSection = ExternalMacroFactory.getMacroDefinition("AddImageIntoSection"); addImageIntoSection.addParameter(theAction.action_naming_convention()); addImageIntoSection.addParameter(m_strLogoPath); ooDocument.executeMacro(addImageIntoSection.toString(), addImageIntoSection.getParams()); // loading the related document ExternalMacro insertDocIntoSection = ExternalMacroFactory.getMacroDefinition("InsertDocumentIntoSection"); insertDocIntoSection.addParameter(ooDocument.getComponent()); insertDocIntoSection.addParameter(theAction.action_naming_convention()); insertDocIntoSection.addParameter(FragmentsFactory.getFragment("hansard_masthead")); ooDocument.executeMacro(insertDocIntoSection.toString(), insertDocIntoSection.getParams()); ExternalMacro setFieldValue = ExternalMacroFactory.getMacroDefinition("SetReferenceInputFieldValue"); setFieldValue.addParameter(new String("debaterecord_official_date")); setFieldValue.addParameter(strDebateDate); setFieldValue.addParameter(new String("int:masthead_datetime")); ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams()); setFieldValue.clearParams(); setFieldValue.addParameter(new String("debaterecord_official_time")); setFieldValue.addParameter(strTimeOfHansard); setFieldValue.addParameter(new String("int:masthead_datetime")); ooDocument.executeMacro(setFieldValue.toString(), setFieldValue.getParams()); ooDocMetadata meta = new ooDocMetadata(ooDocument); meta.AddProperty("Bungeni_DebateOfficialDate", strDebateDate); meta.AddProperty("Bungeni_DebateOfficialTime", strTimeOfHansard); enableButtons(true); // MessageBox.OK(parent, "Prayers section was successfully added"); return true; }