summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBehrend Cornelius <bc@openoffice.org>2002-11-08 16:25:56 +0000
committerBehrend Cornelius <bc@openoffice.org>2002-11-08 16:25:56 +0000
commite8b82ba75ee1e1c40159c84f804fae0d48cccdcf (patch)
tree38bfdd4801756a9d933e4d6bf1d1d297f4daf46a
parent532a29a74f87bdf07d599b411091c4976837741e (diff)
#104710# Exceptionhandling for pathretrieving added
-rw-r--r--wizards/com/sun/star/wizards/report/Dataimport.java24
-rw-r--r--wizards/com/sun/star/wizards/report/ReportWizard.java60
2 files changed, 53 insertions, 31 deletions
diff --git a/wizards/com/sun/star/wizards/report/Dataimport.java b/wizards/com/sun/star/wizards/report/Dataimport.java
index 98452d5499fc..69894f47330d 100644
--- a/wizards/com/sun/star/wizards/report/Dataimport.java
+++ b/wizards/com/sun/star/wizards/report/Dataimport.java
@@ -2,9 +2,9 @@
*
* $RCSfile: Dataimport.java,v $
*
- * $Revision: 1.17 $
+ * $Revision: 1.18 $
*
- * last change: $Author: bc $ $Date: 2002-10-31 15:27:23 $
+ * last change: $Author: bc $ $Date: 2002-11-08 17:25:55 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -292,7 +292,7 @@ public class Dataimport extends ReportWizard{
}}
- public String getValueofHiddenControl(XMultiServiceFactory xMSF, XNameAccess xNamedForm, String ControlName, ReportDocument CurReportDocument, boolean[] bgoOn){
+ public String getValueofHiddenControl(XMultiServiceFactory xMSF, XNameAccess xNamedForm, String ControlName, boolean[] bgoOn){
try{
if (bgoOn[0] == true){
String ControlValue = (String) tools.getUNOPropertyValue(xNamedForm.getByName(ControlName), "HiddenValue");
@@ -304,7 +304,7 @@ public class Dataimport extends ReportWizard{
catch(com.sun.star.uno.Exception exception){
sMsgHiddenControlMissing = tools.replaceSubString(sMsgHiddenControlMissing, SOREPORTFORMNAME, "<REPORTFORM>");
sMsgHiddenControlMissing = tools.replaceSubString(sMsgHiddenControlMissing, ControlName, "<CONTROLNAME>");
- UNODialogs.showMessageBox(xMSF, CurReportDocument.Frame, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sMsgHiddenControlMissing + (char) 13 + sMsgEndAutopilot);
+ UNODialogs.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sMsgHiddenControlMissing + (char) 13 + sMsgEndAutopilot);
bgoOn[0] = false;
return null;
}}
@@ -319,12 +319,13 @@ public class Dataimport extends ReportWizard{
boolean[] bgoOn = new boolean[1];
bgoOn[0] = true;
XNameAccess xNamedForm = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBForm);
- CurReportDocument.CurDBMetaData.DataSourceName = (String) getValueofHiddenControl(xMSF, xNamedForm, "DataSourceName", CurReportDocument, bgoOn);
- CurReportDocument.CurDBMetaData.Command = getValueofHiddenControl(xMSF, xNamedForm, "Command", CurReportDocument, bgoOn);
- String sCommandType = getValueofHiddenControl(xMSF, xNamedForm, "CommandType", CurReportDocument, bgoOn);
- String sGroupFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "GroupFieldNames", CurReportDocument, bgoOn);
- String sFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "FieldNames", CurReportDocument, bgoOn);
- String sRecordFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "RecordFieldNames", CurReportDocument, bgoOn);
+ // Todo make up an exception class to catch that error
+ CurReportDocument.CurDBMetaData.DataSourceName = (String) getValueofHiddenControl(xMSF, xNamedForm, "DataSourceName", bgoOn);
+ CurReportDocument.CurDBMetaData.Command = getValueofHiddenControl(xMSF, xNamedForm, "Command", bgoOn);
+ String sCommandType = getValueofHiddenControl(xMSF, xNamedForm, "CommandType", bgoOn);
+ String sGroupFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "GroupFieldNames", bgoOn);
+ String sFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "FieldNames", bgoOn);
+ String sRecordFieldNames = getValueofHiddenControl(xMSF, xNamedForm, "RecordFieldNames", bgoOn);
CurReportDocument.CurDBMetaData.FieldNames = tools.ArrayoutofString(sFieldNames,";");
CurReportDocument.CurDBMetaData.RecordFieldNames = tools.ArrayoutofString(sRecordFieldNames,";");
CurReportDocument.CurDBMetaData.GroupFieldNames = tools.ArrayoutofString(sGroupFieldNames,";");
@@ -342,7 +343,7 @@ public class Dataimport extends ReportWizard{
}
else{
sReportFormNotExisting = tools.replaceSubString(sReportFormNotExisting, SOREPORTFORMNAME, "<REPORTFORM>");
- UNODialogs.showMessageBox(xMSF, CurReportDocument.Frame, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sReportFormNotExisting + (char) 13 + sMsgEndAutopilot);
+ UNODialogs.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sReportFormNotExisting + (char) 13 + sMsgEndAutopilot);
return false;
}
}
@@ -384,7 +385,6 @@ public class Dataimport extends ReportWizard{
XNameAccess xTextTables = CurReportDocument.TextTablesSupplier.getTextTables();
xTextDocument = CurReportDocument.ReportTextDocument;
xTextCursor = CurReportDocument.createTextCursor(CurReportDocument.ReportTextDocument.getText());
- XFrame xFrame = CurReportDocument.Frame;
xTextDocument.lockControllers();
if (CurDBMetaData.ResultSet.next() == true){
diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java
index a60651241fc7..cf427638bd3f 100644
--- a/wizards/com/sun/star/wizards/report/ReportWizard.java
+++ b/wizards/com/sun/star/wizards/report/ReportWizard.java
@@ -2,9 +2,9 @@
*
* $RCSfile: ReportWizard.java,v $
*
- * $Revision: 1.42 $
+ * $Revision: 1.43 $
*
- * last change: $Author: bc $ $Date: 2002-10-31 15:27:23 $
+ * last change: $Author: bc $ $Date: 2002-11-08 17:25:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -143,6 +143,7 @@ import com.sun.star.frame.XDispatch;
import com.sun.star.frame.XDispatchProvider;
import com.sun.star.util.XURLTransformer;
+
import java.io.*;
import java.util.*;
@@ -682,7 +683,7 @@ public class ReportWizard {
bcreateTemplate = ((Short) CurUNODialog.getPropertyOfDialogControl("optCreateReportTemplate", "State")).shortValue() == (short) 1;
boolean bDocisStored;
StorePath = getStorePath();
- if (tools.PathisValid(xGlobalMSF, StorePath, CurReportDocument.xWindowPeer, sMsgFilePathInvalid, bfinalaskbeforeOverwrite)){
+ if (tools.PathisValid(xGlobalMSF, StorePath, sMsgFilePathInvalid, bfinalaskbeforeOverwrite)){
if (bcreateTemplate == true){
CurReportDocument.createDBForm(xMSF, SOREPORTFORMNAME);
tools.attachEventCall(CurReportDocument.ReportTextDocument, "OnNew", "macro:///Tools.Debug.FillDocument()"); //"service:com.sun.star.wizards.report.CallReportWizard?fill"
@@ -878,8 +879,8 @@ public class ReportWizard {
String sStorePath = "";
boolean bStoreAsTemplate = ((Short) CurUNODialog.getPropertyOfDialogControl("optCreateReportTemplate", "State")).shortValue() == (short) 1;
if (bStoreAsTemplate == true){
- if (CurReportPaths.UserTemplatePath == null)
- CurReportPaths.UserTemplatePath = tools.getOfficePath(xMSF, "Template","user");
+// if (CurReportPaths.UserTemplatePath == null)
+// CurReportPaths.UserTemplatePath = tools.getOfficePath(xMSF, "Template","user");
sStorePath = tools.callStoreDialog(xMSF, CurReportPaths.UserTemplatePath, DefaultName + ".stw", "writer_StarOffice_XML_Writer_Template");
CurUNODialog.assignPropertyToDialogControl("txtSavePath_1", "Text", sStorePath);
if (sStorePath != ""){
@@ -893,8 +894,8 @@ public class ReportWizard {
}
else{
- if (CurReportPaths.WorkPath == null)
- CurReportPaths.WorkPath = tools.getOfficePath(xMSF, "Work","");
+// if (CurReportPaths.WorkPath == null)
+// CurReportPaths.WorkPath = tools.getOfficePath(xMSF, "Work","");
sStorePath = tools.callStoreDialog(xMSF, CurReportPaths.WorkPath, DefaultName + ".sxw", "writer_StarOffice_XML_Writer");
CurUNODialog.assignPropertyToDialogControl("txtSavePath_2", "Text", sStorePath);
if (sStorePath != ""){
@@ -967,14 +968,14 @@ public class ReportWizard {
DefaultName = "Report_" + CurReportDocument.CurDBMetaData.DataSourceName + "_" + CurReportDocument.CurDBMetaData.MainCommandName;
if (DefaultName.equals(OldDefaultName) == false){
OldDefaultName = DefaultName;
- CurReportPaths.UserTemplatePath = tools.getOfficePath(xMSF, "Template","user");
+// CurReportPaths.UserTemplatePath = tools.getOfficePath(xMSF, "Template","user");
DefaultPath = CurReportPaths.UserTemplatePath + "/" + DefaultName + ".stw";
DefaultPath = tools.convertfromURLNotation(DefaultPath);
CurUNODialog.assignPropertyToDialogControl("txtSavePath_1", "Text", DefaultPath);
baskbeforeOverwrite[0] = true;
bmodifiedbySaveAsDialog[0] = false;
- CurReportPaths.WorkPath = tools.getOfficePath(xMSF, "Work","");
+// CurReportPaths.WorkPath = tools.getOfficePath(xMSF, "Work","");
DefaultPath = CurReportPaths.WorkPath + "/" + DefaultName + ".sxw";
DefaultPath = tools.convertfromURLNotation(DefaultPath);
CurUNODialog.assignPropertyToDialogControl("txtSavePath_2", "Text", DefaultPath);
@@ -1380,10 +1381,15 @@ public class ReportWizard {
xGlobalMSF = xMSF;
xDesktop = tools.getDesktop(xMSF);
XFramesSupplier xFrameSuppl = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop);
+ CurReportPaths = new ReportPaths();
+ if (CurReportPaths.initialize(xMSF) == false)
+ return;
CurReportDocument = new ReportDocument(xMSF, true, false);
- CurReportPaths = new ReportPaths(xMSF);
CurReportDocument.changePageOrientation(CurReportPaths.BitmapPath, null, true);
- getReportResources(xMSF, false);
+ if (getReportResources(xMSF, false) == false){
+ tools.disposeDocument(xMSF, CurReportDocument.Component);
+ return;
+ }
DatabaseNames = CurReportDocument.CurDBMetaData.getDatabaseNames(CurReportDocument);
if (DatabaseNames.length > 0){
CurReportDocument.ProgressBar.setValue(20);
@@ -1410,7 +1416,7 @@ public class ReportWizard {
case 0: // via Cancelbutton or via sourceCode with "endExecute"
if (bCloseDocument == true){
CurUNODialog.xComponent.dispose();
- CurReportDocument.Component.dispose();
+ tools.disposeDocument(xMSF, CurReportDocument.Component);
CurReportDocument.CurDBMetaData.disposeDBMetaData();
return;
}
@@ -1439,8 +1445,8 @@ public class ReportWizard {
CurReportDocument.ReportTextDocument.unlockControllers();
}
else{
- int iMsg = UNODialogs.showMessageBox(xMSF, CurReportDocument.Frame, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sMsgNoDatabaseAvailable);
- CurReportDocument.Component.dispose();
+ int iMsg = UNODialogs.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sMsgNoDatabaseAvailable);
+ tools.disposeDocument(xMSF, CurReportDocument.Component);
}
}
catch(java.lang.Exception jexception ){
@@ -1475,8 +1481,9 @@ public class ReportWizard {
}
- public static void getReportResources(XMultiServiceFactory xMSF, boolean bgetProgressResourcesOnly){
- final int RID_COMMON = 1000;
+ public static boolean getReportResources(XMultiServiceFactory xMSF, boolean bgetProgressResourcesOnly){
+ try{
+ final int RID_COMMON = 1000;
final int RID_FORM = 2200;
final int RID_REPORT = 2400;
XInvocation xResInvoke = tools.initResources(xMSF, "ReportWizard","dbw");
@@ -1559,7 +1566,12 @@ public class ReportWizard {
sMsgHiddenControlMissing = tools.getResText(xResInvoke, RID_REPORT + 66);
sProgressDataImport = tools.getResText(xResInvoke, RID_REPORT + 67);
sMsgNoConnection = tools.getResText(xResInvoke, RID_COMMON + 14);
+ return true;
}
+ catch(com.sun.star.uno.Exception exception){
+ tools.showCommonResourceError(xMSF);
+ return false;
+ }}
class ReportPaths{
@@ -1570,12 +1582,22 @@ public class ReportWizard {
public String[][] ContentFiles;
public String UserTemplatePath;
public String WorkPath;
- public ReportPaths(XMultiServiceFactory xMSF){
+ public ReportPaths(){
+ }
+
+ public boolean initialize(XMultiServiceFactory xMSF){
+ try{
TemplatePath = tools.getOfficePath(xMSF, "Template","share");
- BitmapPath = TemplatePath + "/wizard/bitmap";
- ReportPath = TemplatePath + "/wizard/report";
+ UserTemplatePath = tools.getOfficePath(xMSF, "Template","user");
+ BitmapPath = tools.combinePaths(xMSF, TemplatePath, "/wizard/bitmap");
+ ReportPath = tools.combinePaths(xMSF, TemplatePath, "/wizard/report");
+ WorkPath = tools.getOfficePath(xMSF, "Work","");
ContentFiles = tools.getFolderTitles(xMSF, "cnt", ReportPath);
LayoutFiles = tools.getFolderTitles(xMSF,"stl", ReportPath);
+ return true;
}
+ catch (tools.NoValidPathException nopathexception){
+ return false;
+ }}
}
}