From 1b78e405c0ba9cb2833bd0ee9474ac45baddaef3 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 16 Dec 2009 14:21:11 +0100 Subject: dba33e: #i107623# allow finishWizard to return a success flag, and re-enable the finish button in case of failure --- .../sun/star/wizards/agenda/AgendaWizardDialogImpl.java | 7 ++++--- wizards/com/sun/star/wizards/db/SQLQueryComposer.java | 2 +- .../com/sun/star/wizards/fax/FaxWizardDialogImpl.java | 6 +++--- wizards/com/sun/star/wizards/form/FormWizard.java | 4 +++- .../sun/star/wizards/letter/LetterWizardDialogImpl.java | 6 +++--- wizards/com/sun/star/wizards/query/Finalizer.java | 2 +- wizards/com/sun/star/wizards/query/QueryWizard.java | 11 +++++------ wizards/com/sun/star/wizards/report/ReportWizard.java | 6 ++++-- wizards/com/sun/star/wizards/table/TableWizard.java | 4 +++- wizards/com/sun/star/wizards/ui/WizardDialog.java | 16 +++++++++++++--- wizards/com/sun/star/wizards/web/WWD_Events.java | 3 ++- 11 files changed, 42 insertions(+), 25 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java index 23dec6a80191..82f767a61ca4 100644 --- a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java @@ -459,7 +459,7 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog running = false; } - public void finishWizard() { + public boolean finishWizard() { boolean bSaveSuccess = false; // pesimistic :( XTextDocument xTextDocument; @@ -480,7 +480,7 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resFileExists); if (answer == 3) // user said: no, do not overwrite.... - return; + return false; } agendaTemplate.xTextDocument.lockControllers(); @@ -550,10 +550,11 @@ public class AgendaWizardDialogImpl extends AgendaWizardDialog } } else { agendaTemplate.xTextDocument.unlockControllers(); - return; + return false; } xDialog.endExecute(); running = false; + return true; } private void closeDocument() { diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java index db5ccd32b8f7..10677558488c 100644 --- a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java +++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java @@ -292,7 +292,7 @@ public class SQLQueryComposer return sFromClause; } - public boolean setQueryCommand(String QueryName, XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) + public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames) { try { diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java index a8dbe94e5db0..fe726c430a9b 100644 --- a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java @@ -212,7 +212,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog running = false; } - public void finishWizard() + public boolean finishWizard() { switchToStep(getCurrentStep(), getMaxStep()); myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription); @@ -239,7 +239,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); if (answer == 3) // user said: no, do not overwrite.... { - return; + return false; } } } @@ -297,7 +297,7 @@ public class FaxWizardDialogImpl extends FaxWizardDialog xDialog.endExecute(); running = false; } - + return true; } public void closeDocument() diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java index 5b0a7939f6c2..678e5d55f3b1 100644 --- a/wizards/com/sun/star/wizards/form/FormWizard.java +++ b/wizards/com/sun/star/wizards/form/FormWizard.java @@ -308,7 +308,7 @@ public class FormWizard extends WizardDialog } // @Override - public void finishWizard() + public boolean finishWizard() { int ncurStep = getCurrentStep(); if ((switchToStep(ncurStep, SOSTORE_PAGE)) || (ncurStep == SOSTORE_PAGE)) @@ -326,6 +326,7 @@ public class FormWizard extends WizardDialog { bcreateForm = true; xDialog.endExecute(); + return true; } } } @@ -335,6 +336,7 @@ public class FormWizard extends WizardDialog showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage); } } + return false; } // @Override diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java index 1a47712ca213..5e5ce985c0c4 100644 --- a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java +++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java @@ -253,7 +253,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog running = false; } - public void finishWizard() + public boolean finishWizard() { switchToStep(getCurrentStep(), getMaxStep()); try @@ -279,7 +279,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning); if (answer == 3) // user said: no, do not overwrite.... { - return; + return false; } } } @@ -356,7 +356,7 @@ public class LetterWizardDialogImpl extends LetterWizardDialog xDialog.endExecute(); running = false; } - + return true; } public void closeDocument() diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 0a7f0a42aec8..f690102ea49f 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -177,7 +177,7 @@ public class Finalizer { CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); String queryname = getTitle(); - boolean bsuccess = CurDBMetaData.oSQLQueryComposer.setQueryCommand(queryname, CurUnoDialog.xWindow, true, true); + boolean bsuccess = CurDBMetaData.oSQLQueryComposer.setQueryCommand(CurUnoDialog.xWindow, true, true); if (bsuccess) { bsuccess = CurDBMetaData.createQuery(CurDBMetaData.oSQLQueryComposer, queryname); diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java index 14fe9c4757a9..6d6fd34f0a88 100644 --- a/wizards/com/sun/star/wizards/query/QueryWizard.java +++ b/wizards/com/sun/star/wizards/query/QueryWizard.java @@ -292,17 +292,16 @@ public class QueryWizard extends WizardDialog } } - public void finishWizard() + public boolean finishWizard() { int ncurStep = getCurrentStep(); - if ((switchToStep(ncurStep, SOSUMMARY_PAGE)) || (ncurStep == SOSUMMARY_PAGE)) + if ( ( ncurStep == SOSUMMARY_PAGE ) + || ( switchToStep( ncurStep, SOSUMMARY_PAGE ) ) + ) { components = CurFinalizer.finish(); - if ( components == null ) - { - setControlProperty("btnWizardFinish", "Enabled", false); - } } + return ( components != null ); } protected void enterStep(int nOldStep, int nNewStep) diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index a4b4e3af18ad..a959c2dfd183 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -329,7 +329,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple boolean bQueryCreated = false; if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) { - bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(sMsgWizardName, this.xWindow, false, false); + bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(this.xWindow, false, false); CurReportDocument.setCommandType(CommandType.COMMAND); String sQuery = CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery(); @@ -520,7 +520,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple enableNavigationButtons(false, false, false); } - public void finishWizard() + public boolean finishWizard() { final int ncurStep = getCurrentStep(); if ((switchToStep(ncurStep, SOSTOREPAGE)) || (ncurStep == SOSTOREPAGE)) @@ -532,9 +532,11 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple nReportMode = CurReportFinalizer.getReportOpenMode(); m_sReportName = CurReportFinalizer.getStoreName(); xDialog.endExecute(); + return true; } } } + return false; } public void cancelWizard() diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 9144dc607a9a..bee58c071546 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -289,7 +289,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet return bIsSuccessfull; } - public void finishWizard() + public boolean finishWizard() { super.switchToStep(super.getCurrentStep(), SOFINALPAGE); tablename = curFinalizer.getTableName(curScenarioSelector.getFirstTableName()); @@ -314,6 +314,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet components = curTableDescriptor.switchtoDataViewmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE, CurFrame); } super.xDialog.endExecute(); + return true; } } else @@ -323,6 +324,7 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet curFinalizer.setFocusToTableNameControl(); } } + return false; } private void callFormWizard() diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java index 15b840fa9c89..01d97c4278ed 100644 --- a/wizards/com/sun/star/wizards/ui/WizardDialog.java +++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java @@ -685,7 +685,7 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL } } - public abstract void finishWizard(); + public abstract boolean finishWizard(); /** * This function will call if the finish button is pressed on the UI. @@ -693,8 +693,18 @@ public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeL public void finishWizard_1() { enableFinishButton(false); - finishWizard(); - removeTerminateListener(); + boolean success = false; + try + { + success = finishWizard(); + } + finally + { + if ( !success ) + enableFinishButton( true ); + } + if ( success ) + removeTerminateListener(); } public int getMaximalStep() diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.java b/wizards/com/sun/star/wizards/web/WWD_Events.java index e396a46ddd30..88b986bb631c 100644 --- a/wizards/com/sun/star/wizards/web/WWD_Events.java +++ b/wizards/com/sun/star/wizards/web/WWD_Events.java @@ -942,9 +942,10 @@ public abstract class WWD_Events extends WWD_Startup /** * the user clicks the finish/create button. */ - public void finishWizard() + public boolean finishWizard() { finishWizard(true); + return true; } /** -- cgit From cd6abead393fa3f4edef8ac056dd8e548d7cf3d1 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Mon, 1 Feb 2010 21:32:33 +0100 Subject: autorecovery: more sophisticated configuration data for interaction handlers The generic css.task.InteractionHandler implementation in module uui is now able to instantiate "sub handlers", i.e. components to delegate a request to, based on the type of the request, and some configuration data. The "old" (and now deprecated) configuration scheme at org.openoffice.ucb.InteractionHandler did not contain type information, so any handlers registered there were always called when no default implementation for a given request was available. The "new" configuration scheme at org.openoffice.Interaction contains UNO type information. That is, a given handler implementation can declare itself responsible for an arbitrary set of UNO types, and for each of those types, whether it is also responsible for sub types. The generic interaction handler implementation uses this configuration data, when it encounteres an interaction request it cannot fullfill itself, to instantiate a component to delegate the request to. As with the "old" data, such a component is required to support the css.task.XInteractionHandler2 interface. Also, if it supports css.lang.XInitialization, then it will be initialized with a name-value pair, the name being "Parent", the value being the XWindow interface of the parent window for any message boxes. As an examplary implementation for this feature, the css.sdb.InteractionHandler has been deprecated. Now the css.sdb.DatabaseInteractionHandler is reponsible for database-related interactions, and the new configuration scheme is pre-filled with data assigning this responsibility. Consequently, a lot of places previously creating an css.sdb.InteractionHandler have been modified to create the default css.task.InteractionHandler. --- wizards/com/sun/star/wizards/db/DBMetaData.java | 4 ++-- wizards/com/sun/star/wizards/db/RecordParser.java | 2 +- wizards/source/formwizard/DBMeta.xba | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 2a7151cd1135..1c934b83f0d5 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -220,7 +220,7 @@ public class DBMetaData this.xMSF = xMSF; xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext"); xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDatabaseContext); - XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); + XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); oInteractionHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); DataSourceNames = xNameAccess.getElementNames(); } @@ -722,7 +722,7 @@ public class DBMetaData } else { - XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); + XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); XInteractionHandler oInteractionHandler2 = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); boolean bExitLoop = true; do diff --git a/wizards/com/sun/star/wizards/db/RecordParser.java b/wizards/com/sun/star/wizards/db/RecordParser.java index cf2853861ccd..fccfe7e4d1f6 100644 --- a/wizards/com/sun/star/wizards/db/RecordParser.java +++ b/wizards/com/sun/star/wizards/db/RecordParser.java @@ -84,7 +84,7 @@ public class RecordParser extends QueryMetaData xRowSetColumnsSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xRowSet); xRowSetComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xRowSet); xExecute = (com.sun.star.sdb.XCompletedExecution) UnoRuntime.queryInterface(com.sun.star.sdb.XCompletedExecution.class, xRowSet); - XInterface oInteraction = (XInterface) xMSF.createInstance("com.sun.star.sdb.InteractionHandler"); + XInterface oInteraction = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); xInteraction = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, oInteraction); } catch (Exception exception) diff --git a/wizards/source/formwizard/DBMeta.xba b/wizards/source/formwizard/DBMeta.xba index f4ac2bbb7fb0..2d8dc2838f5c 100644 --- a/wizards/source/formwizard/DBMeta.xba +++ b/wizards/source/formwizard/DBMeta.xba @@ -86,7 +86,7 @@ Dim Nulllist() oDBConnection = oDBContext.GetByName(sDBName).GetConnection("","") GetConnection() = True Else - oInteractionHandler = createUnoService("com.sun.star.sdb.InteractionHandler") + oInteractionHandler = createUnoService("com.sun.star.task.InteractionHandler") oDataSource = oDBContext.GetByName(sDBName) On Local Error Goto NOCONNECTION Do -- cgit From 6242c77610b6d6c4206da895dfa430b781f60996 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Tue, 2 Feb 2010 22:42:50 +0100 Subject: autorecovery: addDatabaseDocument: do not close the document after having disposed it - this will throw nowadays --- wizards/com/sun/star/wizards/db/DBMetaData.java | 125 ++++++++++++------------ 1 file changed, 61 insertions(+), 64 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 1c934b83f0d5..296d73c5c31a 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -32,9 +32,7 @@ package com.sun.star.wizards.db; import com.sun.star.awt.XWindow; import com.sun.star.lang.XInitialization; import com.sun.star.ui.dialogs.XExecutableDialog; -import java.util.*; -// import com.sun.star.io.IOException; import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.lang.XMultiServiceFactory; @@ -48,7 +46,6 @@ import com.sun.star.container.XHierarchicalNameAccess; import com.sun.star.container.XHierarchicalNameContainer; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; -// import com.sun.star.container.XNamed; import com.sun.star.frame.XComponentLoader; import com.sun.star.frame.XModel; import com.sun.star.frame.XStorable; @@ -57,7 +54,6 @@ import com.sun.star.sdbc.DataType; import com.sun.star.sdb.XOfficeDatabaseDocument; import com.sun.star.sdb.XDocumentDataSource; import com.sun.star.sdb.tools.XConnectionTools; -// import com.sun.star.sdbcx.XAppend; import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.ucb.XSimpleFileAccess; @@ -67,14 +63,10 @@ import com.sun.star.uno.AnyConverter; import com.sun.star.util.XCloseable; import com.sun.star.util.XNumberFormatsSupplier; -import com.sun.star.wizards.common.Properties; -import com.sun.star.wizards.common.*; -// import com.sun.star.wizards.ui.UnoDialog; import com.sun.star.task.XInteractionHandler; import com.sun.star.sdb.XFormDocumentsSupplier; import com.sun.star.sdb.XQueryDefinitionsSupplier; import com.sun.star.sdb.XReportDocumentsSupplier; -// import com.sun.star.sdbc.ColumnValue; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbc.XDatabaseMetaData; import com.sun.star.sdbc.XDataSource; @@ -82,10 +74,18 @@ import com.sun.star.sdbc.XResultSet; import com.sun.star.sdbc.XRow; import com.sun.star.sdb.XCompletedConnection; import com.sun.star.lang.Locale; -// import com.sun.star.util.XFlushable; import com.sun.star.lang.XSingleServiceFactory; import com.sun.star.sdb.XQueriesSupplier; import com.sun.star.sdbcx.XTablesSupplier; +import com.sun.star.wizards.common.Configuration; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NumberFormatter; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.common.SystemDialog; +import java.util.Vector; public class DBMetaData { @@ -219,9 +219,9 @@ public class DBMetaData { this.xMSF = xMSF; xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext"); - xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDatabaseContext); + xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xDatabaseContext ); XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); - oInteractionHandler = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); + oInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xInteractionHandler ); DataSourceNames = xNameAccess.getElementNames(); } catch (Exception exception) @@ -262,6 +262,7 @@ public class DBMetaData return getTableNamesAsNameAccess().hasByName(_stablename); } + @SuppressWarnings("unchecked") public void setTableByName(String _tableName) { CommandObject oTableObject = new CommandObject(_tableName, com.sun.star.sdb.CommandType.TABLE); @@ -330,10 +331,10 @@ public class DBMetaData { oCommand = getQueryNamesAsNameAccess().getByName(Name); } - XColumnsSupplier xCommandCols = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, oCommand); - xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oCommand); + XColumnsSupplier xCommandCols = UnoRuntime.queryInterface( XColumnsSupplier.class, oCommand ); + xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oCommand ); // TODO: Performance leak getColumns() take very long. - xColumns = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xCommandCols.getColumns()); + xColumns = UnoRuntime.queryInterface( XNameAccess.class, xCommandCols.getColumns() ); } catch (Exception exception) { @@ -378,14 +379,14 @@ public class DBMetaData public XNameAccess getQueryNamesAsNameAccess() { - XQueriesSupplier xDBQueries = (XQueriesSupplier) UnoRuntime.queryInterface(XQueriesSupplier.class, DBConnection); - xQueryNames = (XNameAccess) xDBQueries.getQueries(); + XQueriesSupplier xDBQueries = UnoRuntime.queryInterface( XQueriesSupplier.class, DBConnection ); + xQueryNames = xDBQueries.getQueries(); return xQueryNames; } public XNameAccess getTableNamesAsNameAccess() { - XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); + XTablesSupplier xDBTables = UnoRuntime.queryInterface( XTablesSupplier.class, DBConnection ); XNameAccess xTableNames = xDBTables.getTables(); return xTableNames; } @@ -412,7 +413,7 @@ public class DBMetaData return TableNames; } } - TableNames = (String[]) getTableNamesAsNameAccess().getElementNames(); + TableNames = getTableNamesAsNameAccess().getElementNames(); return TableNames; } @@ -458,7 +459,7 @@ public class DBMetaData int itablecount = xDBMetaData.getMaxTablesInSelect(); if (itablecount == 0) { - return this.NOLIMIT; + return DBMetaData.NOLIMIT; } else { @@ -487,7 +488,7 @@ public class DBMetaData iMaxColumnsInSelect = xDBMetaData.getMaxColumnsInSelect(); if (iMaxColumnsInSelect == 0) { - iMaxColumnsInSelect = this.NOLIMIT; + iMaxColumnsInSelect = DBMetaData.NOLIMIT; } } @@ -496,7 +497,7 @@ public class DBMetaData iMaxColumnsInGroupBy = xDBMetaData.getMaxColumnsInGroupBy(); if (iMaxColumnsInGroupBy == 0) { - iMaxColumnsInGroupBy = this.NOLIMIT; + iMaxColumnsInGroupBy = DBMetaData.NOLIMIT; } } @@ -505,7 +506,7 @@ public class DBMetaData iMaxColumnsInTable = xDBMetaData.getMaxColumnsInTable(); if (iMaxColumnsInTable == 0) { - iMaxColumnsInTable = this.NOLIMIT; + iMaxColumnsInTable = DBMetaData.NOLIMIT; } return iMaxColumnsInTable; } @@ -515,8 +516,6 @@ public class DBMetaData try { xDBMetaData = DBConnection.getMetaData(); - XChild xChild = (XChild) UnoRuntime.queryInterface(XChild.class, DBConnection); - Object oDataSource = xChild.getParent(); getDataSourceInterfaces(); setMaxColumnsInGroupBy(); setMaxColumnsInSelect(); @@ -567,7 +566,7 @@ public class DBMetaData try { Object oDataSource = xNameAccess.getByName(DataSourceName); - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, oDataSource); + xDataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource ); } catch (com.sun.star.container.NoSuchElementException e) { @@ -585,7 +584,7 @@ public class DBMetaData { this.DataSourceName = _DataSourceName; getDataSourceInterfaces(); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, getDataSource()); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, getDataSource() ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); @@ -599,8 +598,8 @@ public class DBMetaData public void getDataSourceInterfaces() throws Exception { - xCompleted = (XCompletedConnection) UnoRuntime.queryInterface(XCompletedConnection.class, getDataSource()); - xDataSourcePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, getDataSource()); + xCompleted = UnoRuntime.queryInterface( XCompletedConnection.class, getDataSource() ); + xDataSourcePropertySet = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() ); bPasswordIsRequired = ((Boolean) xDataSourcePropertySet.getPropertyValue("IsPasswordRequired")).booleanValue(); } @@ -615,15 +614,15 @@ public class DBMetaData Properties.getPropertyValue(curproperties, "ActiveConnection")); if (xConnection != null) { - com.sun.star.container.XChild child = (com.sun.star.container.XChild) UnoRuntime.queryInterface(com.sun.star.container.XChild.class, xConnection); + com.sun.star.container.XChild child = UnoRuntime.queryInterface( com.sun.star.container.XChild.class, xConnection ); - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, child.getParent()); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, this.xDataSource); + xDataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.xDataSource ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); } - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDataSource); + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, xDataSource ); if (xPSet != null) { DataSourceName = AnyConverter.toString(xPSet.getPropertyValue("Name")); @@ -646,8 +645,8 @@ public class DBMetaData } else if (Properties.hasPropertyValue(curproperties, "DataSource")) { - xDataSource = (XDataSource) UnoRuntime.queryInterface(XDataSource.class, Properties.getPropertyValue(curproperties, "DataSource")); - XDocumentDataSource xDocu = (XDocumentDataSource) UnoRuntime.queryInterface(XDocumentDataSource.class, this.xDataSource); + xDataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) ); + XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.xDataSource ); if (xDocu != null) { xModel = xDocu.getDatabaseDocument(); @@ -692,7 +691,7 @@ public class DBMetaData try { this.DBConnection = _DBConnection; - this.ConnectionTools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, this.DBConnection); + this.ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, this.DBConnection ); getDataSourceObjects(); return true; } @@ -723,11 +722,11 @@ public class DBMetaData else { XInterface xInteractionHandler = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler"); - XInteractionHandler oInteractionHandler2 = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xInteractionHandler); + XInteractionHandler oInteractionHandler2 = UnoRuntime.queryInterface( XInteractionHandler.class, xInteractionHandler ); boolean bExitLoop = true; do { - XCompletedConnection xCompleted2 = (XCompletedConnection) UnoRuntime.queryInterface(XCompletedConnection.class, xDataSource); + XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, xDataSource ); try { DBConnection = xCompleted2.connectWithCompletion(oInteractionHandler2); @@ -755,8 +754,8 @@ public class DBMetaData } else { - xConnectionComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, DBConnection); - ConnectionTools = (XConnectionTools) UnoRuntime.queryInterface(XConnectionTools.class, DBConnection); + xConnectionComponent = UnoRuntime.queryInterface( XComponent.class, DBConnection ); + ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, DBConnection ); getDataSourceObjects(); } return bgetConnection; @@ -831,17 +830,16 @@ public class DBMetaData { try { - XQueryDefinitionsSupplier xQueryDefinitionsSuppl = (XQueryDefinitionsSupplier) UnoRuntime.queryInterface(XQueryDefinitionsSupplier.class, xDataSource); + XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, xDataSource ); XNameAccess xQueryDefs = xQueryDefinitionsSuppl.getQueryDefinitions(); - XSingleServiceFactory xSSFQueryDefs = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, xQueryDefs); + XSingleServiceFactory xSSFQueryDefs = UnoRuntime.queryInterface( XSingleServiceFactory.class, xQueryDefs ); Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition" - XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oQuery); + XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, oQuery ); String s = _oSQLQueryComposer.m_xQueryAnalyzer.getQuery(); xPSet.setPropertyValue("Command", s); - XNameContainer xNameCont = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xQueryDefs); - XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xQueryDefs); + XNameContainer xNameCont = UnoRuntime.queryInterface( XNameContainer.class, xQueryDefs ); ConnectionTools.getObjectNames().checkNameForCreate(com.sun.star.sdb.CommandType.QUERY, _QueryName); xNameCont.insertByName(_QueryName, oQuery); return true; @@ -885,23 +883,23 @@ public class DBMetaData public XHierarchicalNameAccess getReportDocuments() { - XReportDocumentsSupplier xReportDocumentSuppl = (XReportDocumentsSupplier) UnoRuntime.queryInterface(XReportDocumentsSupplier.class, this.xModel); + XReportDocumentsSupplier xReportDocumentSuppl = UnoRuntime.queryInterface( XReportDocumentsSupplier.class, this.xModel ); xReportDocumentSuppl.getReportDocuments(); - XHierarchicalNameAccess xReportHier = (XHierarchicalNameAccess) UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments()); + XHierarchicalNameAccess xReportHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments() ); return xReportHier; } public XHierarchicalNameAccess getFormDocuments() { - XFormDocumentsSupplier xFormDocumentSuppl = (XFormDocumentsSupplier) UnoRuntime.queryInterface(XFormDocumentsSupplier.class, xModel); - XHierarchicalNameAccess xFormHier = (XHierarchicalNameAccess) UnoRuntime.queryInterface(XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments()); + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + XHierarchicalNameAccess xFormHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); return xFormHier; } public boolean hasFormDocumentByName(String _sFormName) { - XFormDocumentsSupplier xFormDocumentSuppl = (XFormDocumentsSupplier) UnoRuntime.queryInterface(XFormDocumentsSupplier.class, xModel); - XNameAccess xFormNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xFormDocumentSuppl.getFormDocuments()); + XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel ); + XNameAccess xFormNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xFormDocumentSuppl.getFormDocuments() ); return xFormNameAccess.hasByName(_sFormName); } @@ -929,11 +927,10 @@ public class DBMetaData try { PropertyValue[] aDocProperties; - XModel xDocumentModel = (XModel) UnoRuntime.queryInterface(XModel.class, _xComponent); + XModel xDocumentModel = UnoRuntime.queryInterface( XModel.class, _xComponent ); String sPath = xDocumentModel.getURL(); String basename = FileAccess.getBasename(sPath, "/"); - XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, _xComponent); - _xComponent.dispose(); + XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent ); xCloseable.close(false); if (_bcreateTemplate) { @@ -951,13 +948,13 @@ public class DBMetaData { aDocProperties[4] = Properties.createProperty("AsTemplate", new Boolean(_bcreateTemplate)); } - XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, _xDocNameAccess); + XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess ); Object oDBDocument = xDocMSF.createInstanceWithArguments("com.sun.star.sdb.DocumentDefinition", aDocProperties); - XHierarchicalNameContainer xHier = (XHierarchicalNameContainer) UnoRuntime.queryInterface(XHierarchicalNameContainer.class, _xDocNameAccess); + XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess ); String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename); xHier.insertByHierarchicalName(sdocname, oDBDocument); XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); - XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); xSimpleFileAccess.kill(sPath); } catch (Exception e) @@ -971,16 +968,16 @@ public class DBMetaData XComponent[] xRetComponent = new XComponent[2]; try { - XComponentLoader xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, _xDocuments); + XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, _xDocuments ); PropertyValue[] aPropertyValues = new PropertyValue[4]; aPropertyValues[0] = Properties.createProperty("OpenMode", _bOpenInDesign ? "openDesign" : "open"); aPropertyValues[1] = Properties.createProperty("ActiveConnection", this.DBConnection); aPropertyValues[2] = Properties.createProperty("DocumentTitle", _docname); aPropertyValues[3] = Properties.createProperty("AsTemplate", new Boolean(_bAsTemplate)); - XHierarchicalNameContainer xHier = (XHierarchicalNameContainer) UnoRuntime.queryInterface(XHierarchicalNameContainer.class, _xDocuments); + XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocuments ); if (xHier.hasByHierarchicalName(_docname)) { - xRetComponent[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, xHier.getByHierarchicalName(_docname)); + xRetComponent[0] = UnoRuntime.queryInterface( XComponent.class, xHier.getByHierarchicalName( _docname ) ); xRetComponent[1] = xComponentLoader.loadComponentFromURL(_docname, "", 0, aPropertyValues); } } @@ -1018,7 +1015,7 @@ public class DBMetaData String[] sColValues = null; try { - XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, _xResultSet); + XRow xRow = UnoRuntime.queryInterface( XRow.class, _xResultSet ); Vector aColVector = new Vector(); while (_xResultSet.next()) { @@ -1067,9 +1064,9 @@ public class DBMetaData try { XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); - XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface); + XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); String storepath = FileAccess.getOfficePath(xMSF, "Temp", xSimpleFileAccess) + "/" + _storename; - XStorable xStoreable = (XStorable) UnoRuntime.queryInterface(XStorable.class, _xcomponent); + XStorable xStoreable = UnoRuntime.queryInterface( XStorable.class, _xcomponent ); PropertyValue[] oStoreProperties = new PropertyValue[1]; oStoreProperties[0] = Properties.createProperty("FilterName", "writer8"); storepath += ".odt"; @@ -1118,12 +1115,12 @@ public class DBMetaData try { Object oDialog = xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog"); - XInitialization xInitialization = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oDialog); + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oDialog ); PropertyValue[] aPropertyValue = new PropertyValue[2]; aPropertyValue[0] = Properties.createProperty("SQLException", oSQLException); aPropertyValue[1] = Properties.createProperty("ParentWindow", _xWindow); xInitialization.initialize(aPropertyValue); - XExecutableDialog xExecutableDialog = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oDialog); + XExecutableDialog xExecutableDialog = UnoRuntime.queryInterface( XExecutableDialog.class, oDialog ); xExecutableDialog.execute(); } catch (com.sun.star.uno.Exception ex) -- cgit From a31b27b704d5c669674afdf135a61cdf1f30ff3b Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 3 Feb 2010 11:52:40 +0100 Subject: autorecovery: re-work the table wizard so that it does not open the table itself, but uses XDatabaseDocumentUI Consequently, it does not need to return the created model/controller anymore. This way, the application controller has full control over its sub components, which didn't work reliably before. Other wizards (query/form/report) are to follow. For this purpose, they're also to be based on the newly introduced DatabaseObjectWizard class. --- .../star/wizards/common/NamedValueCollection.java | 90 ++++++++++++++++++++++ .../sun/star/wizards/db/DatabaseObjectWizard.java | 75 ++++++++++++++++++ .../com/sun/star/wizards/db/TableDescriptor.java | 11 ++- wizards/com/sun/star/wizards/makefile.mk | 2 + .../sun/star/wizards/table/CallTableWizard.java | 43 ++++------- .../com/sun/star/wizards/table/TableWizard.java | 74 ++++++------------ .../sun/star/wizards/table/XCallTableWizard.java | 42 ---------- wizards/com/sun/star/wizards/table/makefile.mk | 1 - 8 files changed, 212 insertions(+), 126 deletions(-) create mode 100644 wizards/com/sun/star/wizards/common/NamedValueCollection.java create mode 100644 wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java delete mode 100644 wizards/com/sun/star/wizards/table/XCallTableWizard.java (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/common/NamedValueCollection.java b/wizards/com/sun/star/wizards/common/NamedValueCollection.java new file mode 100644 index 000000000000..f8f2cd05224a --- /dev/null +++ b/wizards/com/sun/star/wizards/common/NamedValueCollection.java @@ -0,0 +1,90 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.sun.star.wizards.common; + +import com.sun.star.beans.PropertyAttribute; +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map.Entry; + +/** + * + * @author frank.schoenheit@sun.com + */ +public class NamedValueCollection +{ + final private HashMap< String, Object > m_values = new HashMap< String, Object >(); + + public NamedValueCollection() + { + } + + public NamedValueCollection( final PropertyValue[] i_values ) + { + for ( int i = 0; i < i_values.length; ++i ) + m_values.put( i_values[i].Name, i_values[i].Value ); + } + + public final void put( final String i_name, final Object i_value ) + { + m_values.put( i_name, i_value ); + } + + @SuppressWarnings("unchecked") + public final < T extends Object > T getOrDefault( final String i_key, final T i_default ) + { + if ( m_values.containsKey( i_key ) ) + { + final Object value = m_values.get( i_key ); + try + { + return (T)value; + } + catch ( ClassCastException e ) { } + } + return i_default; + } + + @SuppressWarnings("unchecked") + public final < T extends XInterface > T queryOrDefault( final String i_key, final T i_default, Class i_interfaceClass ) + { + if ( m_values.containsKey( i_key ) ) + { + final Object value = m_values.get( i_key ); + return (T)UnoRuntime.queryInterface( i_interfaceClass, value ); + } + return i_default; + } + + public final boolean has( final String i_key ) + { + return m_values.containsKey( i_key ); + } + + public final PropertyValue[] getPropertyValues() + { + PropertyValue[] values = new PropertyValue[ m_values.size() ]; + + Iterator< Entry< String, Object > > iter = m_values.entrySet().iterator(); + int i = 0; + while ( iter.hasNext() ) + { + Entry< String, Object > entry = iter.next(); + values[i++] = new PropertyValue( + entry.getKey(), + 0, + entry.getValue(), + PropertyState.DIRECT_VALUE + ); + } + + return values; + } +} diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java new file mode 100644 index 000000000000..5c65d73794f0 --- /dev/null +++ b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java @@ -0,0 +1,75 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ + +package com.sun.star.wizards.db; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.container.NoSuchElementException; +import com.sun.star.frame.XController; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.sdbc.SQLException; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.ui.WizardDialog; +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * is a base class for a wizard creating a database object + * @author frank.schoenheit@sun.com + */ +public abstract class DatabaseObjectWizard extends WizardDialog +{ + protected final PropertyValue[] m_wizardContext; + protected final XDatabaseDocumentUI m_docUI; + protected final XFrame m_frame; + + protected DatabaseObjectWizard( final XMultiServiceFactory i_orb, final int i_helpIDBase, final PropertyValue[] i_wizardContext ) + { + super( i_orb, i_helpIDBase ); + m_wizardContext = i_wizardContext; + + final NamedValueCollection wizardContext = new NamedValueCollection( m_wizardContext ); + m_docUI = wizardContext.queryOrDefault( "DocumentUI", (XDatabaseDocumentUI)null, XDatabaseDocumentUI.class ); + + if ( m_docUI != null ) + { + XController docController = UnoRuntime.queryInterface( XController.class, m_docUI ); + m_frame = docController.getFrame(); + } + else + { + XFrame parentFrame = wizardContext.queryOrDefault( "ParentFrame", (XFrame)null, XFrame.class ); + if ( parentFrame != null ) + m_frame = parentFrame; + else + m_frame = Desktop.getActiveFrame( xMSF ); + } + } + + protected final void loadSubComponent( final int i_type, final String i_name, final boolean i_forEditing ) + { + try + { + m_docUI.loadComponent( i_type, i_name, i_forEditing ); + } + catch ( IllegalArgumentException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + catch ( NoSuchElementException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + catch ( SQLException ex ) + { + Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex ); + } + } +} diff --git a/wizards/com/sun/star/wizards/db/TableDescriptor.java b/wizards/com/sun/star/wizards/db/TableDescriptor.java index aa9986b8d9db..74930e6d1bb6 100644 --- a/wizards/com/sun/star/wizards/db/TableDescriptor.java +++ b/wizards/com/sun/star/wizards/db/TableDescriptor.java @@ -36,7 +36,6 @@ import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.WrappedTargetException; import com.sun.star.sdbc.SQLException; import com.sun.star.wizards.common.JavaTools; -import com.sun.star.wizards.ui.WizardDialog; import java.util.Vector; import com.sun.star.awt.VclWindowPeerAttribute; @@ -120,13 +119,13 @@ public class TableDescriptor extends CommandMetaData implements XContainerListen { // XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection); // xTableNames = xDBTables.getTables(); - xTableAppend = (XAppend) UnoRuntime.queryInterface(XAppend.class, getTableNamesAsNameAccess()); - xTableDrop = (XDrop) UnoRuntime.queryInterface(XDrop.class, getTableNamesAsNameAccess()); - xTableDataDescriptorFactory = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, getTableNamesAsNameAccess()); + xTableAppend = UnoRuntime.queryInterface( XAppend.class, getTableNamesAsNameAccess() ); + xTableDrop = UnoRuntime.queryInterface( XDrop.class, getTableNamesAsNameAccess() ); + xTableDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, getTableNamesAsNameAccess() ); xPropTableDataDescriptor = xTableDataDescriptorFactory.createDataDescriptor(); - XColumnsSupplier xColumnsSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xPropTableDataDescriptor); + XColumnsSupplier xColumnsSupplier = UnoRuntime.queryInterface( XColumnsSupplier.class, xPropTableDataDescriptor ); xNameAccessColumns = xColumnsSupplier.getColumns(); - xColumnDataDescriptorFactory = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, xNameAccessColumns); + xColumnDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, xNameAccessColumns ); try { createTypeInspector(); diff --git a/wizards/com/sun/star/wizards/makefile.mk b/wizards/com/sun/star/wizards/makefile.mk index d876d1903d5d..ac4e2d87ece0 100644 --- a/wizards/com/sun/star/wizards/makefile.mk +++ b/wizards/com/sun/star/wizards/makefile.mk @@ -82,6 +82,7 @@ JAVAFILES= \ common$/DebugHelper.java \ common$/PropertySetHelper.java \ common$/NumericalHelper.java \ + common$/NamedValueCollection.java \ db$/DBMetaData.java \ db$/CommandMetaData.java \ db$/QueryMetaData.java \ @@ -94,6 +95,7 @@ JAVAFILES= \ db$/RelationController.java \ db$/TableDescriptor.java \ db$/SQLQueryComposer.java \ + db$/DatabaseObjectWizard.java \ ui$/event$/AbstractListener.java \ ui$/event$/CommonListener.java \ ui$/event$/DataAware.java \ diff --git a/wizards/com/sun/star/wizards/table/CallTableWizard.java b/wizards/com/sun/star/wizards/table/CallTableWizard.java index 7455df894c73..8f7cab8732d6 100644 --- a/wizards/com/sun/star/wizards/table/CallTableWizard.java +++ b/wizards/com/sun/star/wizards/table/CallTableWizard.java @@ -31,7 +31,6 @@ package com.sun.star.wizards.table; import com.sun.star.beans.PropertyAttribute; import com.sun.star.beans.PropertyValue; -import com.sun.star.lang.XComponent; import com.sun.star.uno.Type; import com.sun.star.wizards.common.Properties; @@ -86,41 +85,31 @@ public class CallTableWizard public static class TableWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor { - PropertyValue[] databaseproperties; - public XComponent Document = null; - public XComponent DocumentDefinition = null; + private PropertyValue[] m_wizardContext; + // + public String Command; + public final Integer CommandType = com.sun.star.sdb.CommandType.TABLE; + // /** The constructor of the inner class has a XMultiServiceFactory parameter. - * @param xmultiservicefactoryInitialization A special service factory - * could be introduced while initializing. + * @param i_serviceFactory */ - public TableWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) + public TableWizardImplementation(com.sun.star.lang.XMultiServiceFactory i_serviceFactory) { super(); - xmultiservicefactory = xmultiservicefactoryInitialization; - registerProperty("Document", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); - registerProperty("DocumentDefinition", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); + m_serviceFactory = i_serviceFactory; + registerProperty( "Command", (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) ); + registerProperty( "CommandType", PropertyAttribute.READONLY ); } - public void trigger(String sEvent) + public void trigger( String sEvent ) { try { - if (sEvent.compareTo("start") == 0) + if ( sEvent.compareTo("start") == 0 ) { - TableWizard CurTableWizard = new TableWizard(xmultiservicefactory); - XComponent[] obj = CurTableWizard.startTableWizard(xmultiservicefactory, databaseproperties); - if (obj != null) - { - DocumentDefinition = obj[1]; - Document = obj[0]; - } - } - else if (sEvent.compareTo("end") == 0) - { - DocumentDefinition = null; - Document = null; - databaseproperties = null; + TableWizard CurTableWizard = new TableWizard( m_serviceFactory, m_wizardContext ); + CurTableWizard.startTableWizard(); } } catch (Exception exception) @@ -134,7 +123,7 @@ public class CallTableWizard private static final String __serviceName = "com.sun.star.wizards.table.CallTableWizard"; /** The service manager, that gives access to all registered services. */ - private com.sun.star.lang.XMultiServiceFactory xmultiservicefactory; + private com.sun.star.lang.XMultiServiceFactory m_serviceFactory; /** This method is a member of the interface for initializing an object * directly after its creation. @@ -145,7 +134,7 @@ public class CallTableWizard */ public void initialize(Object[] object) throws com.sun.star.uno.Exception { - databaseproperties = Properties.convertToPropertyValueArray(object); + m_wizardContext = Properties.convertToPropertyValueArray(object); } /** This method returns an array of all supported service names. diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 8b4e0288ef8c..1995a442d58c 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -35,20 +35,19 @@ import com.sun.star.awt.TextEvent; import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XTextListener; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.XPropertySet; -import com.sun.star.frame.XFrame; -import com.sun.star.lang.XComponent; import com.sun.star.lang.XInitialization; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdb.CommandType; +import com.sun.star.sdb.application.DatabaseObject; import com.sun.star.sdbc.SQLException; import com.sun.star.task.XJobExecutor; import com.sun.star.uno.UnoRuntime; import com.sun.star.wizards.common.*; +import com.sun.star.wizards.db.DatabaseObjectWizard; import com.sun.star.wizards.db.TableDescriptor; import com.sun.star.wizards.ui.*; -public class TableWizard extends WizardDialog implements XTextListener, XCompletion +public class TableWizard extends DatabaseObjectWizard implements XTextListener, XCompletion { static String slblFields; @@ -71,13 +70,11 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet public static final int SOPRIMARYKEYPAGE = 3; public static final int SOFINALPAGE = 4; private String sMsgColumnAlreadyExists = ""; - XComponent[] components = null; - XFrame CurFrame; String WizardHeaderText[] = new String[8]; - public TableWizard(XMultiServiceFactory xMSF) + public TableWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext ) { - super(xMSF, 41200); + super( xMSF, 41200, i_wizardContext ); super.addResourceHandler("TableWizard", "dbw"); String sTitle = m_oResource.getResText(UIConsts.RID_TABLE + 1); Helper.setUnoPropertyValues(xDialogModel, @@ -298,21 +295,15 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet { Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(this.curTableDescriptor.xMSF), tablename); } - if (tablename != "") + if ( tablename.length() > 0 ) { if (!curTableDescriptor.hasTableByName(scomposedtablename)) { wizardmode = curFinalizer.finish(); if (createTable()) { - if (wizardmode == Finalizer.MODIFYTABLEMODE) - { - components = curTableDescriptor.switchtoDesignmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE, CurFrame); - } - else if (wizardmode == Finalizer.WORKWITHTABLEMODE) - { - components = curTableDescriptor.switchtoDataViewmode(curTableDescriptor.getComposedTableName(), com.sun.star.sdb.CommandType.TABLE, CurFrame); - } + final boolean editTableDesign = (wizardmode == Finalizer.MODIFYTABLEMODE ); + loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign ); super.xDialog.endExecute(); } } @@ -330,18 +321,17 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet try { Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard"); - PropertyValue[] aProperties = new PropertyValue[4]; - aProperties[0] = Properties.createProperty("ActiveConnection", curTableDescriptor.DBConnection); - aProperties[1] = Properties.createProperty("DataSource", curTableDescriptor.getDataSource()); - aProperties[2] = Properties.createProperty("CommandType", new Integer(CommandType.TABLE)); - aProperties[3] = Properties.createProperty("Command", scomposedtablename); - XInitialization xInitialization = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oFormWizard); - xInitialization.initialize(aProperties); - XJobExecutor xJobExecutor = (XJobExecutor) UnoRuntime.queryInterface(XJobExecutor.class, oFormWizard); + + NamedValueCollection wizardContext = new NamedValueCollection(); + wizardContext.put( "ActiveConnection", curTableDescriptor.DBConnection ); + wizardContext.put( "DataSource", curTableDescriptor.getDataSource() ); + wizardContext.put( "CommandType", CommandType.TABLE ); + wizardContext.put( "Command", scomposedtablename ); + wizardContext.put( "DocumentUI", m_docUI ); + XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oFormWizard ); + xInitialization.initialize( wizardContext.getPropertyValues() ); + XJobExecutor xJobExecutor = UnoRuntime.queryInterface( XJobExecutor.class, oFormWizard ); xJobExecutor.trigger("start"); - XPropertySet prop = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xJobExecutor); - components[0] = (XComponent) prop.getPropertyValue("Document"); - components[1] = (XComponent) prop.getPropertyValue("DocumentDefinition"); } catch (Exception e) { @@ -370,39 +360,24 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet setCurrentRoadmapItemID((short) 1); } - public XComponent[] startTableWizard(XMultiServiceFactory _xMSF, PropertyValue[] CurPropertyValue) + public void startTableWizard( ) { try { curTableDescriptor = new TableDescriptor(xMSF, super.xWindow, this.sMsgColumnAlreadyExists); - if (curTableDescriptor.getConnection(CurPropertyValue)) + if ( curTableDescriptor.getConnection( m_wizardContext ) ) { - if (Properties.hasPropertyValue(CurPropertyValue, "ParentFrame")) - { - CurFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, Properties.getPropertyValue(CurPropertyValue, "ParentFrame")); - } - else - { - CurFrame = Desktop.getActiveFrame(xMSF); - } buildSteps(); createWindowPeer(); curTableDescriptor.setWindowPeer(this.xControl.getPeer()); - // setAutoMnemonic("lblDialogHeader", false); insertFormRelatedSteps(); short RetValue = executeDialog(); xComponent.dispose(); - switch (RetValue) + if ( ( RetValue == 0 ) + && ( wizardmode == Finalizer.STARTFORMWIZARDMODE ) + ) { - case 0: // via Cancelbutton or via sourceCode with "endExecute" - if (wizardmode == Finalizer.STARTFORMWIZARDMODE) - { - callFormWizard(); - } - break; - case 1: - - break; + callFormWizard(); } } } @@ -410,7 +385,6 @@ public class TableWizard extends WizardDialog implements XTextListener, XComplet { jexception.printStackTrace(System.out); } - return components; } public boolean getTableResources() diff --git a/wizards/com/sun/star/wizards/table/XCallTableWizard.java b/wizards/com/sun/star/wizards/table/XCallTableWizard.java deleted file mode 100644 index 47cba7da9314..000000000000 --- a/wizards/com/sun/star/wizards/table/XCallTableWizard.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - ************************************************************************ - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XCallTableWizard.java,v $ - * - * $Revision: 1.3.192.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package com.sun.star.wizards.table; - -public interface XCallTableWizard extends com.sun.star.uno.XInterface -{ - // Methods - public void CallTableDialog(); // static Member - public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = - { - new com.sun.star.lib.uno.typeinfo.MethodTypeInfo("CallTableDialog", 0, 0) - }; -} diff --git a/wizards/com/sun/star/wizards/table/makefile.mk b/wizards/com/sun/star/wizards/table/makefile.mk index d845f6456efb..d0d689fabed7 100644 --- a/wizards/com/sun/star/wizards/table/makefile.mk +++ b/wizards/com/sun/star/wizards/table/makefile.mk @@ -61,7 +61,6 @@ JAVAFILES= \ PrimaryKeyHandler.java \ ScenarioSelector.java \ TableWizard.java \ - XCallTableWizard.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) -- cgit From e2fa939261e012bfe2a675079a0707bcdf8fec54 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 3 Feb 2010 11:53:44 +0100 Subject: autorecovery: removed unused class XCallQueryWizard --- .../sun/star/wizards/query/XCallQueryWizard.java | 42 ---------------------- wizards/com/sun/star/wizards/query/makefile.mk | 1 - 2 files changed, 43 deletions(-) delete mode 100644 wizards/com/sun/star/wizards/query/XCallQueryWizard.java (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/query/XCallQueryWizard.java b/wizards/com/sun/star/wizards/query/XCallQueryWizard.java deleted file mode 100644 index 04cb6303db3f..000000000000 --- a/wizards/com/sun/star/wizards/query/XCallQueryWizard.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - ************************************************************************ - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XCallQueryWizard.java,v $ - * - * $Revision: 1.3.192.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package com.sun.star.wizards.query; - -public interface XCallQueryWizard extends com.sun.star.uno.XInterface -{ - // Methods - public void CallQueryDialog(); // static Member - public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = - { - new com.sun.star.lib.uno.typeinfo.MethodTypeInfo("CallQueryDialog", 0, 0) - }; -} diff --git a/wizards/com/sun/star/wizards/query/makefile.mk b/wizards/com/sun/star/wizards/query/makefile.mk index 887b470b6d8a..c935dc41a49d 100644 --- a/wizards/com/sun/star/wizards/query/makefile.mk +++ b/wizards/com/sun/star/wizards/query/makefile.mk @@ -57,7 +57,6 @@ JAVAFILES= \ Finalizer.java \ QueryWizard.java \ QuerySummary.java\ - XCallQueryWizard.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) -- cgit From 619a6a4ab19ba81c46caad249eaf926281f897d9 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 3 Feb 2010 12:44:27 +0100 Subject: autorecovery: also moved the QueryWizard to using XDatabaseDocumentUI.loadComponent, instead of opening the sub component itself --- .../com/sun/star/wizards/db/CommandMetaData.java | 88 ++++----------------- .../sun/star/wizards/query/CallQueryWizard.java | 38 ++++----- wizards/com/sun/star/wizards/query/Finalizer.java | 90 +++++++++------------- .../com/sun/star/wizards/query/QueryWizard.java | 79 +++++++++---------- 4 files changed, 104 insertions(+), 191 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/db/CommandMetaData.java b/wizards/com/sun/star/wizards/db/CommandMetaData.java index b26259fc8a47..7fae3651a61d 100644 --- a/wizards/com/sun/star/wizards/db/CommandMetaData.java +++ b/wizards/com/sun/star/wizards/db/CommandMetaData.java @@ -30,10 +30,6 @@ package com.sun.star.wizards.db; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.wizards.common.Properties; -import com.sun.star.wizards.common.*; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.sdbc.SQLException; import com.sun.star.sdbcx.KeyType; @@ -41,29 +37,31 @@ import com.sun.star.sdbcx.XColumnsSupplier; import com.sun.star.sdbcx.XKeysSupplier; import com.sun.star.uno.AnyConverter; import com.sun.star.awt.VclWindowPeerAttribute; -import com.sun.star.beans.*; import com.sun.star.uno.UnoRuntime; -import java.util.*; import com.sun.star.lang.Locale; -import com.sun.star.beans.PropertyValue; +import com.sun.star.beans.XPropertySet; import com.sun.star.container.XIndexAccess; import com.sun.star.container.XNameAccess; import com.sun.star.embed.EntryInitModes; -import com.sun.star.frame.*; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NumberFormatter; +import com.sun.star.wizards.common.Resource; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; public class CommandMetaData extends DBMetaData { public Map FieldTitleSet = new HashMap(); public String[] m_aAllFieldNames = new String[]{}; public FieldColumn[] FieldColumns = new FieldColumn[]{}; -// public String[] FieldNames = new String[] {}; public String[] GroupFieldNames = new String[] {}; private String[][] SortFieldNames = new String[][] {}; private String[] RecordFieldNames = new String[] {}; public String[][] AggregateFieldNames = new String[][] {}; public String[] NumericFieldNames = new String[] {}; public String[] NonAggregateFieldNames; - // private int[] FieldTypes; private int CommandType; private String Command; boolean bCatalogAtStart = true; @@ -154,7 +152,7 @@ public class CommandMetaData extends DBMetaData String CurCommandName = CurFieldColumn.getCommandName(); CommandObject oCommand = getTableByName(CurCommandName); Object oColumn = oCommand.getColumns().getByName(CurFieldColumn.getFieldName()); - XPropertySet xColumn = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oColumn); + XPropertySet xColumn = UnoRuntime.queryInterface( XPropertySet.class, oColumn ); return xColumn; } catch (Exception exception) @@ -616,64 +614,6 @@ public class CommandMetaData extends DBMetaData return RecordFieldNames[i]; } - public XComponent[] switchtoDesignmode(String _commandname, int _commandtype,XFrame parentFrame) - { - XComponent[] ret = null; - PropertyValue[] rDispatchArguments = new PropertyValue[_commandtype == com.sun.star.sdb.CommandType.QUERY ? 5 : 3]; - rDispatchArguments[0] = Properties.createProperty("DataSourceName", this.DataSourceName); - rDispatchArguments[1] = Properties.createProperty("ActiveConnection", this.DBConnection); - if (_commandtype == com.sun.star.sdb.CommandType.QUERY) - { - rDispatchArguments[2] = Properties.createProperty("GraphicalDesign", Boolean.TRUE); - rDispatchArguments[3] = Properties.createProperty("Command", _commandname); - rDispatchArguments[4] = Properties.createProperty("CommandType", new Integer(_commandtype)); - ret = showCommandView(".component:DB/QueryDesign", rDispatchArguments,parentFrame); - } - else - { - rDispatchArguments[2] = Properties.createProperty("CurrentTable", _commandname); - ret = showCommandView(".component:DB/TableDesign", rDispatchArguments,parentFrame); - } - return ret; - } - - public XComponent[] switchtoDataViewmode(String _commandname, int _commandtype,XFrame parentFrame) - { - PropertyValue[] rDispatchArguments = new PropertyValue[7]; - rDispatchArguments[0] = Properties.createProperty("DataSourceName", this.DataSourceName); - rDispatchArguments[1] = Properties.createProperty("ActiveConnection", this.DBConnection); - rDispatchArguments[2] = Properties.createProperty("Command", _commandname); - rDispatchArguments[3] = Properties.createProperty("CommandType", new Integer(_commandtype)); - rDispatchArguments[4] = Properties.createProperty("ShowTreeView", Boolean.FALSE); - rDispatchArguments[5] = Properties.createProperty("ShowTreeViewButton", Boolean.FALSE); - rDispatchArguments[6] = Properties.createProperty("ShowMenu", Boolean.TRUE); - return showCommandView(".component:DB/DataSourceBrowser", rDispatchArguments,parentFrame); - } - - // - public XComponent[] showCommandView(String surl, PropertyValue[] _rArgs,XFrame parentFrame) - { - XComponent[] ret = new XComponent[2]; - try - { - XSingleServiceFactory xFac = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class,xMSF.createInstance("com.sun.star.frame.TaskCreator")); - Object[] args = new Object[2]; - args[0] = Properties.createProperty("ParentFrame",parentFrame); - args[1] = Properties.createProperty("TopWindow",Boolean.TRUE); - - XComponentLoader xLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class,xFac.createInstanceWithArguments(args)); - ret[0] = xLoader.loadComponentFromURL(surl, "_self", 0, _rArgs); - if ( ret[0] != null) - { - ret[0] = (XComponent)UnoRuntime.queryInterface(XComponent.class,xLoader); - } - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - return ret; - } /**@deprecated use 'RelationController' class instead * * @param _stablename @@ -691,11 +631,11 @@ public class CommandMetaData extends DBMetaData { java.util.Vector TableVector = new java.util.Vector(); Object oTable = getTableNamesAsNameAccess().getByName(_stablename); - XKeysSupplier xKeysSupplier = (XKeysSupplier) UnoRuntime.queryInterface(XKeysSupplier.class, oTable); + XKeysSupplier xKeysSupplier = UnoRuntime.queryInterface( XKeysSupplier.class, oTable ); xIndexKeys = xKeysSupplier.getKeys(); for (int i = 0; i < xIndexKeys.getCount(); i++) { - XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xIndexKeys.getByIndex(i) ); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIndexKeys.getByIndex( i ) ); int curtype = AnyConverter.toInt(xPropertySet.getPropertyValue("Type")); if (curtype == KeyType.FOREIGN) { @@ -734,7 +674,7 @@ public class CommandMetaData extends DBMetaData { for (int i = 0; i < xIndexKeys.getCount(); i++) { - XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xIndexKeys.getByIndex(i) ); + XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIndexKeys.getByIndex( i ) ); int curtype = AnyConverter.toInt(xPropertySet.getPropertyValue("Type")); if (curtype == KeyType.FOREIGN) { @@ -743,14 +683,14 @@ public class CommandMetaData extends DBMetaData { if (scurreftablename.equals(_sreferencedtablename)) { - XColumnsSupplier xColumnsSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xPropertySet); + XColumnsSupplier xColumnsSupplier = UnoRuntime.queryInterface( XColumnsSupplier.class, xPropertySet ); String[] smastercolnames = xColumnsSupplier.getColumns().getElementNames(); skeycolumnnames = new String[2][smastercolnames.length]; skeycolumnnames[0] = smastercolnames; skeycolumnnames[1] = new String[smastercolnames.length]; for (int n = 0; n < smastercolnames.length; n++) { - XPropertySet xcolPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xColumnsSupplier.getColumns().getByName(smastercolnames[n])); + XPropertySet xcolPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xColumnsSupplier.getColumns().getByName( smastercolnames[n] ) ); skeycolumnnames[1][n] = AnyConverter.toString(xcolPropertySet.getPropertyValue("RelatedColumn")); } return skeycolumnnames; diff --git a/wizards/com/sun/star/wizards/query/CallQueryWizard.java b/wizards/com/sun/star/wizards/query/CallQueryWizard.java index dd9170fb741f..0fa602f67358 100644 --- a/wizards/com/sun/star/wizards/query/CallQueryWizard.java +++ b/wizards/com/sun/star/wizards/query/CallQueryWizard.java @@ -32,6 +32,7 @@ package com.sun.star.wizards.query; import com.sun.star.beans.PropertyAttribute; import com.sun.star.beans.PropertyValue; import com.sun.star.lang.XComponent; +import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.uno.Type; import com.sun.star.wizards.common.Properties; @@ -85,21 +86,22 @@ public class CallQueryWizard */ public static class QueryWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor { - - PropertyValue[] databaseproperties; - public XComponent Document = null; - public XComponent DocumentDefinition = null; + private PropertyValue[] m_wizardContext; + // + public String Command; + public final Integer CommandType = com.sun.star.sdb.CommandType.QUERY; + // /** The constructor of the inner class has a XMultiServiceFactory parameter. * @param xmultiservicefactoryInitialization A special service factory * could be introduced while initializing. */ - public QueryWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) + public QueryWizardImplementation( XMultiServiceFactory i_serviceFactory ) { super(); - xmultiservicefactory = xmultiservicefactoryInitialization; - registerProperty("Document", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); - registerProperty("DocumentDefinition", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); + m_serviceFactory = i_serviceFactory; + registerProperty( "Command", (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) ); + registerProperty( "CommandType", PropertyAttribute.READONLY ); } public void trigger(String sEvent) @@ -108,20 +110,8 @@ public class CallQueryWizard { if (sEvent.compareTo("start") == 0) { - QueryWizard CurQueryWizard = new QueryWizard(xmultiservicefactory); - XComponent[] obj = CurQueryWizard.startQueryWizard(xmultiservicefactory, databaseproperties); - if (obj != null) - { - DocumentDefinition = obj[1]; - Document = obj[0]; - } - CurQueryWizard = null; - } - else if (sEvent.compareTo("end") == 0) - { - DocumentDefinition = null; - Document = null; - databaseproperties = null; + QueryWizard CurQueryWizard = new QueryWizard( m_serviceFactory, m_wizardContext ); + Command = CurQueryWizard.startQueryWizard(); } } catch (Exception exception) @@ -135,7 +125,7 @@ public class CallQueryWizard private static final String __serviceName = "com.sun.star.wizards.query.CallQueryWizard"; /** The service manager, that gives access to all registered services. */ - private com.sun.star.lang.XMultiServiceFactory xmultiservicefactory; + private com.sun.star.lang.XMultiServiceFactory m_serviceFactory; /** This method is a member of the interface for initializing an object * directly after its creation. @@ -146,7 +136,7 @@ public class CallQueryWizard */ public void initialize(Object[] object) throws com.sun.star.uno.Exception { - databaseproperties = Properties.convertToPropertyValueArray(object); + m_wizardContext = Properties.convertToPropertyValueArray(object); } /** This method returns an array of all supported service names. diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 7079b1109742..24f71220c5c7 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -37,19 +37,18 @@ import com.sun.star.lang.XComponent; import com.sun.star.sdb.CommandType; import com.sun.star.uno.*; import com.sun.star.wizards.ui.*; +import java.util.logging.Level; +import java.util.logging.Logger; public class Finalizer { - - private QueryWizard CurUnoDialog; + private QueryWizard m_queryWizard; private String resQuery; - private Object m_aTxtSummary; private Object m_aTxtTitle; private XRadioButton xRadioDisplayQuery; - private XRadioButton xRadioModifyQuery; private QuerySummary CurDBMetaData; - public Finalizer(QueryWizard _CurUnoDialog, QuerySummary _CurDBMetaData) + public Finalizer( QueryWizard i_queryWizard, QuerySummary _CurDBMetaData ) { short curtabindex = (short) (100 * QueryWizard.SOSUMMARY_PAGE); String reslblQueryTitle; @@ -57,17 +56,17 @@ public class Finalizer String resoptModifyQuery; String resflnSummary; String reslblHowGoOn; - this.CurUnoDialog = _CurUnoDialog; + this.m_queryWizard = i_queryWizard; this.CurDBMetaData = _CurDBMetaData; - reslblQueryTitle = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 5); - resoptDisplayQuery = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 6); - resoptModifyQuery = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 7); - resflnSummary = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 87); - reslblHowGoOn = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 8); - resQuery = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 1); + reslblQueryTitle = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 5); + resoptDisplayQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 6); + resoptModifyQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 7); + resflnSummary = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 87); + reslblHowGoOn = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 8); + resQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 1); int curHelpIndex = 40955; - CurUnoDialog.insertLabel("lblQueryTitle", new String[] + m_queryWizard.insertLabel("lblQueryTitle", new String[] { "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" }, @@ -75,7 +74,7 @@ public class Finalizer { new Integer(8), reslblQueryTitle, new Integer(95), new Integer(27), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(52) }); - m_aTxtTitle = CurUnoDialog.insertTextField("txtQueryTitle", 0, null, new String[] + m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", 0, null, new String[] { "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width" }, @@ -83,7 +82,7 @@ public class Finalizer { new Integer(12), "HID:" + curHelpIndex++, new Integer(95), new Integer(37), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(90) }); - CurUnoDialog.insertLabel("lblHowGoOn", new String[] + m_queryWizard.insertLabel("lblHowGoOn", new String[] { "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width" }, @@ -91,7 +90,7 @@ public class Finalizer { new Integer(16), reslblHowGoOn, Boolean.TRUE, new Integer(192), new Integer(27), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(112) }); - this.xRadioDisplayQuery = CurUnoDialog.insertRadioButton("optDisplayQuery", + this.xRadioDisplayQuery = m_queryWizard.insertRadioButton("optDisplayQuery", new String[] { "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width" @@ -101,7 +100,7 @@ public class Finalizer new Integer(9), "HID:" + curHelpIndex++, resoptDisplayQuery, new Integer(192), new Integer(46), new Short((short) 1), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(118) }); - this.xRadioModifyQuery = CurUnoDialog.insertRadioButton("optModifyQuery", + m_queryWizard.insertRadioButton("optModifyQuery", new String[] { "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" @@ -110,7 +109,7 @@ public class Finalizer { new Integer(10), "HID:" + curHelpIndex++, resoptModifyQuery, new Integer(192), new Integer(56), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(118) }); - CurUnoDialog.insertFixedLine("flnSummary", new String[] + m_queryWizard.insertFixedLine("flnSummary", new String[] { "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width" }, @@ -118,7 +117,7 @@ public class Finalizer { new Integer(10), resflnSummary, new Integer(95), new Integer(68), new Integer(8), new Short(curtabindex++), new Integer(209) }); - m_aTxtSummary = CurUnoDialog.insertTextField("txtSummary", 0, null, new String[] + m_queryWizard.insertTextField("txtSummary", 0, null, new String[] { "Height", "HelpURL", "MultiLine", "PositionX", "PositionY", "ReadOnly", "Step", "VScroll", "Width" }, @@ -148,7 +147,7 @@ public class Finalizer } CurDBMetaData.setSummaryString(); - CurUnoDialog.setControlProperty("txtSummary", "Text", CurDBMetaData.getSummaryString()); + m_queryWizard.setControlProperty("txtSummary", "Text", CurDBMetaData.getSummaryString()); return sCurQueryName; } catch (com.sun.star.uno.Exception exception) @@ -164,43 +163,30 @@ public class Finalizer return sTitle; } - public XComponent[] finish() + public String finish() + { + CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); + String queryName = getTitle(); + if ( CurDBMetaData.oSQLQueryComposer.setQueryCommand( queryName, m_queryWizard.xWindow, true, true ) + && CurDBMetaData.createQuery( CurDBMetaData.oSQLQueryComposer, queryName ) + ) + return queryName; + + return ""; + } + + public final boolean displayQueryDesign() { - XComponent[] ret = null; try { - CurDBMetaData.oSQLQueryComposer = new SQLQueryComposer(CurDBMetaData); - String queryname = getTitle(); - boolean bsuccess = CurDBMetaData.oSQLQueryComposer.setQueryCommand(queryname, CurUnoDialog.xWindow, true, true); - if (bsuccess) - { - bsuccess = CurDBMetaData.createQuery(CurDBMetaData.oSQLQueryComposer, queryname); - if (bsuccess) - { - short igoon = AnyConverter.toShort(Helper.getUnoPropertyValue(UnoDialog.getModel(xRadioDisplayQuery), "State")); - if (igoon == (short) 1) - { - ret = CurDBMetaData.switchtoDataViewmode(queryname, - CommandType.QUERY, - CurUnoDialog.getCurFrame()); - } - else - { - ret = CurDBMetaData.switchtoDesignmode(queryname, - CommandType.QUERY, - CurUnoDialog.getCurFrame()); - } - CurUnoDialog.xDialog.endExecute(); - } - } - CurDBMetaData.oSQLQueryComposer = null; - CurDBMetaData = null; - CurUnoDialog = null; + final short state = AnyConverter.toShort( Helper.getUnoPropertyValue( UnoDialog.getModel( xRadioDisplayQuery ), "State" ) ); + final boolean viewMode = state == (short)1; + return !viewMode; } - catch (IllegalArgumentException e) + catch ( IllegalArgumentException ex ) { - e.printStackTrace(); + Logger.getLogger( Finalizer.class.getName() ).log( Level.SEVERE, null, ex ); } - return ret; + return false; } } diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java index dcbb920e4b0d..e46065a4d430 100644 --- a/wizards/com/sun/star/wizards/query/QueryWizard.java +++ b/wizards/com/sun/star/wizards/query/QueryWizard.java @@ -29,29 +29,30 @@ ************************************************************************/ package com.sun.star.wizards.query; -import com.sun.star.frame.XFrame; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.PropertyValue; -import com.sun.star.lang.XComponent; -import com.sun.star.wizards.common.*; -import com.sun.star.wizards.db.*; +import com.sun.star.frame.XFrame; +import com.sun.star.sdb.CommandType; import com.sun.star.sdbc.SQLException; -import com.sun.star.uno.*; -import com.sun.star.wizards.ui.*; +import com.sun.star.uno.AnyConverter; import com.sun.star.wizards.ui.UIConsts; import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.ui.AggregateComponent; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.FilterComponent; +import com.sun.star.wizards.ui.SortingComponent; +import com.sun.star.wizards.ui.TitlesComponent; -public class QueryWizard extends WizardDialog +public class QueryWizard extends DatabaseObjectWizard { - - private XFrame CurFrame; - - public XFrame getCurFrame() - { - return CurFrame; - } public static final String SFILLUPFIELDSLISTBOX = "fillUpFieldsListbox"; private static final int SOFIELDSELECTION_PAGE = 1; private static final int SOSORTING_PAGE = 2; @@ -75,23 +76,21 @@ public class QueryWizard extends WizardDialog private String reslblFields; private String reslblSelFields; private String reslblTables; - // private String resQuery; private String resQueryWizard; private String reslblGroupBy; private String resmsgNonNumericAsGroupBy; - private XComponent[] components = null; //Resources Object - // private short CurTabIndex = 0; + private String m_createdQuery; - public QueryWizard(XMultiServiceFactory xMSF) + public QueryWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext ) { - super(xMSF, 40970); + super( xMSF, 40970, i_wizardContext ); addResourceHandler("QueryWizard", "dbw"); CurDBMetaData = new QuerySummary(xMSF, m_oResource); } - public static void main(String args[]) +/* public static void main(String args[]) { - String ConnectStr = "uno:pipe,name=fs93730;urp;StarOffice.ServiceManager"; + String ConnectStr = "uno:pipe,name=foo;urp;StarOffice.ServiceManager"; try { XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr); @@ -109,13 +108,18 @@ public class QueryWizard extends WizardDialog { jexception.printStackTrace(System.out); } + }*/ + + public final XFrame getFrame() + { + return m_frame; } - public XComponent[] startQueryWizard(XMultiServiceFactory xMSF, PropertyValue[] CurPropertyValues) + public String startQueryWizard() { try { - if (CurDBMetaData.getConnection(CurPropertyValues)) + if ( CurDBMetaData.getConnection( m_wizardContext ) ) { reslblFields = m_oResource.getResText(UIConsts.RID_QUERY + 4); reslblFieldHeader = m_oResource.getResText(UIConsts.RID_QUERY + 19); //Fielnames in AliasComponent @@ -137,22 +141,13 @@ public class QueryWizard extends WizardDialog setRightPaneHeaders(m_oResource, UIConsts.RID_QUERY + 70, 8); this.setMaxStep(8); buildSteps(); - this.CurDBCommandFieldSelection.preselectCommand(CurPropertyValues, false); - if (Properties.hasPropertyValue(CurPropertyValues, "ParentFrame")) - { - CurFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, Properties.getPropertyValue(CurPropertyValues, "ParentFrame")); - } - else - { - CurFrame = Desktop.getActiveFrame(xMSF); - } + this.CurDBCommandFieldSelection.preselectCommand( m_wizardContext, false ); - XWindowPeer windowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, CurFrame.getContainerWindow()); - this.xMSF = xMSF; + XWindowPeer windowPeer = UnoRuntime.queryInterface( XWindowPeer.class, m_frame.getContainerWindow() ); createWindowPeer(windowPeer); CurDBMetaData.setWindowPeer(this.xControl.getPeer()); insertQueryRelatedSteps(); - executeDialog(CurFrame.getContainerWindow().getPosSize()); + executeDialog( m_frame.getContainerWindow().getPosSize() ); } } catch (java.lang.Exception jexception) @@ -164,14 +159,12 @@ public class QueryWizard extends WizardDialog CurAggregateComponent = null; CurDBCommandFieldSelection = null; xWindowPeer = null; - CurFrame = null; CurFinalizer = null; CurDBMetaData.finish(); CurDBMetaData = null; - XComponent[] ret = components; - components = null; System.gc(); - return ret; + + return m_createdQuery; } public void enableRoadmapItems(String[] _FieldNames, boolean _bEnabled) @@ -229,7 +222,6 @@ public class QueryWizard extends WizardDialog { try { -// String[] sRMItemLabels = getRMItemLabels(); setRMItemLabels(m_oResource, UIConsts.RID_QUERY + 80); addRoadmap(); int i = 0; @@ -297,7 +289,12 @@ public class QueryWizard extends WizardDialog int ncurStep = getCurrentStep(); if ((switchToStep(ncurStep, SOSUMMARY_PAGE)) || (ncurStep == SOSUMMARY_PAGE)) { - components = CurFinalizer.finish(); + m_createdQuery = CurFinalizer.finish(); + if ( m_createdQuery.length() > 0 ) + { + loadSubComponent( CommandType.QUERY, m_createdQuery, CurFinalizer.displayQueryDesign() ); + xDialog.endExecute(); + } } } -- cgit From a44bc63de98cdf39179f742b1e661b23749eaffa Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 3 Feb 2010 12:50:22 +0100 Subject: autorecovery: populate the 'Command' property --- wizards/com/sun/star/wizards/table/CallTableWizard.java | 2 +- wizards/com/sun/star/wizards/table/TableWizard.java | 14 +++++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/table/CallTableWizard.java b/wizards/com/sun/star/wizards/table/CallTableWizard.java index 8f7cab8732d6..f52a3d79c430 100644 --- a/wizards/com/sun/star/wizards/table/CallTableWizard.java +++ b/wizards/com/sun/star/wizards/table/CallTableWizard.java @@ -109,7 +109,7 @@ public class CallTableWizard if ( sEvent.compareTo("start") == 0 ) { TableWizard CurTableWizard = new TableWizard( m_serviceFactory, m_wizardContext ); - CurTableWizard.startTableWizard(); + Command = CurTableWizard.startTableWizard(); } } catch (Exception exception) diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java index 1995a442d58c..84accf582174 100644 --- a/wizards/com/sun/star/wizards/table/TableWizard.java +++ b/wizards/com/sun/star/wizards/table/TableWizard.java @@ -72,6 +72,8 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, private String sMsgColumnAlreadyExists = ""; String WizardHeaderText[] = new String[8]; + private String m_tableName; + public TableWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext ) { super( xMSF, 41200, i_wizardContext ); @@ -304,6 +306,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, { final boolean editTableDesign = (wizardmode == Finalizer.MODIFYTABLEMODE ); loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign ); + m_tableName = curTableDescriptor.getComposedTableName(); super.xDialog.endExecute(); } } @@ -360,7 +363,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, setCurrentRoadmapItemID((short) 1); } - public void startTableWizard( ) + public String startTableWizard( ) { try { @@ -373,11 +376,11 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, insertFormRelatedSteps(); short RetValue = executeDialog(); xComponent.dispose(); - if ( ( RetValue == 0 ) - && ( wizardmode == Finalizer.STARTFORMWIZARDMODE ) - ) + if ( RetValue == 0 ) { - callFormWizard(); + if ( wizardmode == Finalizer.STARTFORMWIZARDMODE ) + callFormWizard(); + return m_tableName; } } } @@ -385,6 +388,7 @@ public class TableWizard extends DatabaseObjectWizard implements XTextListener, { jexception.printStackTrace(System.out); } + return ""; } public boolean getTableResources() -- cgit From 722556b9cd099cbb352cb11692ec1b27adfac5dd Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Wed, 3 Feb 2010 12:51:47 +0100 Subject: autorecovery: more unused interfaces removed --- .../com/sun/star/wizards/form/XCallFormWizard.java | 40 --------------------- wizards/com/sun/star/wizards/form/makefile.mk | 1 - .../sun/star/wizards/report/XCallReportWizard.java | 42 ---------------------- 3 files changed, 83 deletions(-) delete mode 100644 wizards/com/sun/star/wizards/form/XCallFormWizard.java delete mode 100644 wizards/com/sun/star/wizards/report/XCallReportWizard.java (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/form/XCallFormWizard.java b/wizards/com/sun/star/wizards/form/XCallFormWizard.java deleted file mode 100644 index c3da310a583d..000000000000 --- a/wizards/com/sun/star/wizards/form/XCallFormWizard.java +++ /dev/null @@ -1,40 +0,0 @@ -/************************************************************************* - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XCallFormWizard.java,v $ - * $Revision: 1.5 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package com.sun.star.wizards.form; - -public interface XCallFormWizard extends com.sun.star.uno.XInterface -{ - // Methods - public void CallFormDialog(); // static Member - public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = - { - new com.sun.star.lib.uno.typeinfo.MethodTypeInfo("CallFormDialog", 0, 0) - }; -} diff --git a/wizards/com/sun/star/wizards/form/makefile.mk b/wizards/com/sun/star/wizards/form/makefile.mk index 2237ac207759..50ee454ef1a5 100644 --- a/wizards/com/sun/star/wizards/form/makefile.mk +++ b/wizards/com/sun/star/wizards/form/makefile.mk @@ -63,7 +63,6 @@ JAVAFILES= \ FormDocument.java \ StyleApplier.java \ UIControlArranger.java \ - XCallFormWizard.java JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) diff --git a/wizards/com/sun/star/wizards/report/XCallReportWizard.java b/wizards/com/sun/star/wizards/report/XCallReportWizard.java deleted file mode 100644 index 562ce506cc56..000000000000 --- a/wizards/com/sun/star/wizards/report/XCallReportWizard.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - ************************************************************************ - * - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * Copyright 2008 by Sun Microsystems, Inc. - * - * OpenOffice.org - a multi-platform office productivity suite - * - * $RCSfile: XCallReportWizard.java,v $ - * - * $Revision: 1.8.36.1 $ - * - * This file is part of OpenOffice.org. - * - * OpenOffice.org is free software: you can redistribute it and/or modify - * it under the terms of the GNU Lesser General Public License version 3 - * only, as published by the Free Software Foundation. - * - * OpenOffice.org is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Lesser General Public License version 3 for more details - * (a copy is included in the LICENSE file that accompanied this code). - * - * You should have received a copy of the GNU Lesser General Public License - * version 3 along with OpenOffice.org. If not, see - * - * for a copy of the LGPLv3 License. - * - ************************************************************************/ -package com.sun.star.wizards.report; - -public interface XCallReportWizard extends com.sun.star.uno.XInterface -{ - // Methods - public void CallReportDialog(); // static Member - public static final com.sun.star.lib.uno.typeinfo.TypeInfo UNOTYPEINFO[] = - { - new com.sun.star.lib.uno.typeinfo.MethodTypeInfo("CallReportDialog", 0, 0) - }; -} -- cgit From b691607b3bda98cee1bb923ccf59cb248bf9cb25 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 4 Feb 2010 14:13:58 +0100 Subject: autorecovery: post-rebase build problems solved --- wizards/com/sun/star/wizards/query/Finalizer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java index 083669192bab..71fddc422d6a 100644 --- a/wizards/com/sun/star/wizards/query/Finalizer.java +++ b/wizards/com/sun/star/wizards/query/Finalizer.java @@ -131,8 +131,9 @@ public class Finalizer public void changeTitle() { final String TitleName = m_aTxtTitle.getText(); - CurUnoDialog.enableFinishButton(!"".equals(TitleName)); + m_queryWizard.enableFinishButton( TitleName.length() > 0 ); } + /* TODO: The title textbox always has to be updated when a new Table has been selected if it is clear that the user has not made any input meanwhile */ -- cgit From c0ea2fcd404cd3830c71752cf1a0c0ee6e5b4e76 Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Thu, 4 Feb 2010 16:04:06 +0100 Subject: autorecovery: form and report wizzard now also using XDatabaseDocumentUI, instead of manipulating document definitions All database object wizards by now employ XDatabaseDocumentUI. This way, it is ensured that the controller has the full control over the opened sub components. Still, other third-party code could use direct access to the document definitions, and open sub documents this way. This would go unnoticed by the application controller at the moment. I would be possible to fix this, by introducing broadcasts from the document definitions, listened to by the controller. But as this sounds like a rare case, and XDatabaseDocumentUI is the preferred way for third-party components, too, such an implementation is deferred to Later ... --- wizards/com/sun/star/wizards/db/DBMetaData.java | 70 +-- .../com/sun/star/wizards/form/CallFormWizard.java | 30 +- wizards/com/sun/star/wizards/form/Finalizer.java | 9 +- wizards/com/sun/star/wizards/form/FormWizard.java | 84 ++-- .../sun/star/wizards/report/CallReportWizard.java | 63 +-- .../com/sun/star/wizards/report/Dataimport.java | 8 +- .../sun/star/wizards/report/IReportDocument.java | 18 +- .../wizards/report/ReportTextImplementation.java | 106 ++--- .../com/sun/star/wizards/report/ReportWizard.java | 478 ++++++--------------- .../reportbuilder/ReportBuilderImplementation.java | 390 ++++++----------- 10 files changed, 372 insertions(+), 884 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java index 296d73c5c31a..40966bf8e813 100644 --- a/wizards/com/sun/star/wizards/db/DBMetaData.java +++ b/wizards/com/sun/star/wizards/db/DBMetaData.java @@ -81,6 +81,7 @@ import com.sun.star.wizards.common.Configuration; import com.sun.star.wizards.common.Desktop; import com.sun.star.wizards.common.FileAccess; import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NamedValueCollection; import com.sun.star.wizards.common.NumberFormatter; import com.sun.star.wizards.common.Properties; import com.sun.star.wizards.common.Resource; @@ -922,82 +923,33 @@ public class DBMetaData * @param _xDocNameAccess * @param _bcreateTemplate describes the type of the document: "form" or "report" */ - public void addDatabaseDocument(XComponent _xComponent, XHierarchicalNameAccess _xDocNameAccess, boolean _bcreateTemplate) + public void addDatabaseDocument(XComponent _xComponent, XHierarchicalNameAccess _xDocNameAccess, boolean i_createTemplate) { try { - PropertyValue[] aDocProperties; XModel xDocumentModel = UnoRuntime.queryInterface( XModel.class, _xComponent ); - String sPath = xDocumentModel.getURL(); - String basename = FileAccess.getBasename(sPath, "/"); + String documentURL = xDocumentModel.getURL(); + String basename = FileAccess.getBasename(documentURL, "/"); XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent ); xCloseable.close(false); - if (_bcreateTemplate) - { - aDocProperties = new PropertyValue[5]; - } - else - { - aDocProperties = new PropertyValue[4]; - } - aDocProperties[0] = Properties.createProperty("Name", basename); - aDocProperties[1] = Properties.createProperty("Parent", _xDocNameAccess); - aDocProperties[2] = Properties.createProperty("URL", sPath); - aDocProperties[3] = Properties.createProperty("DocumentTitle", basename); - if (_bcreateTemplate) - { - aDocProperties[4] = Properties.createProperty("AsTemplate", new Boolean(_bcreateTemplate)); - } + + NamedValueCollection creationArgs = new NamedValueCollection(); + creationArgs.put( "Name", basename ); + creationArgs.put( "URL", documentURL ); + creationArgs.put( "AsTemplate", new Boolean( i_createTemplate ) ); XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess ); - Object oDBDocument = xDocMSF.createInstanceWithArguments("com.sun.star.sdb.DocumentDefinition", aDocProperties); + Object oDBDocument = xDocMSF.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", creationArgs.getPropertyValues() ); XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess ); String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename); xHier.insertByHierarchicalName(sdocname, oDBDocument); XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess"); XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface ); - xSimpleFileAccess.kill(sPath); - } - catch (Exception e) - { - e.printStackTrace(System.out); - } - } - - public XComponent[] openDatabaseDocument(String _docname, boolean _bAsTemplate, boolean _bOpenInDesign, XHierarchicalNameAccess _xDocuments) - { - XComponent[] xRetComponent = new XComponent[2]; - try - { - XComponentLoader xComponentLoader = UnoRuntime.queryInterface( XComponentLoader.class, _xDocuments ); - PropertyValue[] aPropertyValues = new PropertyValue[4]; - aPropertyValues[0] = Properties.createProperty("OpenMode", _bOpenInDesign ? "openDesign" : "open"); - aPropertyValues[1] = Properties.createProperty("ActiveConnection", this.DBConnection); - aPropertyValues[2] = Properties.createProperty("DocumentTitle", _docname); - aPropertyValues[3] = Properties.createProperty("AsTemplate", new Boolean(_bAsTemplate)); - XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocuments ); - if (xHier.hasByHierarchicalName(_docname)) - { - xRetComponent[0] = UnoRuntime.queryInterface( XComponent.class, xHier.getByHierarchicalName( _docname ) ); - xRetComponent[1] = xComponentLoader.loadComponentFromURL(_docname, "", 0, aPropertyValues); - } + xSimpleFileAccess.kill(documentURL); } catch (Exception e) { e.printStackTrace(System.out); } - return xRetComponent; - } - - public XComponent[] openFormDocument(String _sformname, boolean _bOpenInDesign) - { - XHierarchicalNameAccess xFormDocuments = getFormDocuments(); - return openDatabaseDocument(_sformname, false, _bOpenInDesign, xFormDocuments); - } - - public XComponent[] openReportDocument(String _sreportname, boolean _bAsTemplate, boolean _bOpenInDesign) - { - XHierarchicalNameAccess xReportDocuments = getReportDocuments(); - return openDatabaseDocument(_sreportname, _bAsTemplate, _bOpenInDesign, xReportDocuments); } public void createTypeInspector() throws SQLException diff --git a/wizards/com/sun/star/wizards/form/CallFormWizard.java b/wizards/com/sun/star/wizards/form/CallFormWizard.java index 60b0b1705487..a7894ce281ca 100644 --- a/wizards/com/sun/star/wizards/form/CallFormWizard.java +++ b/wizards/com/sun/star/wizards/form/CallFormWizard.java @@ -30,9 +30,7 @@ package com.sun.star.wizards.form; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.PropertyAttribute; import com.sun.star.uno.Type; -import com.sun.star.lang.XComponent; import com.sun.star.wizards.common.Properties; /** This class capsulates the class, that implements the minimal component, a @@ -85,10 +83,7 @@ public class CallFormWizard */ public static class FormWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor { - - PropertyValue[] databaseproperties; - public XComponent Document = null; - public XComponent DocumentDefinition = null; + private PropertyValue[] m_wizardContext; /** The constructor of the inner class has a XMultiServiceFactory parameter. * @param xmultiservicefactoryInitialization A special service factory @@ -97,9 +92,7 @@ public class CallFormWizard public FormWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) { super(); - xmultiservicefactory = xmultiservicefactoryInitialization; - registerProperty("Document", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); - registerProperty("DocumentDefinition", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); + m_serviceFactory = xmultiservicefactoryInitialization; } public void trigger(String sEvent) @@ -108,19 +101,8 @@ public class CallFormWizard { if (sEvent.compareTo("start") == 0) { - FormWizard CurFormWizard = new FormWizard(xmultiservicefactory); - XComponent[] obj = CurFormWizard.startFormWizard(xmultiservicefactory, databaseproperties); - if (obj != null) - { - DocumentDefinition = obj[0]; - Document = obj[1]; - } - } - else if (sEvent.compareTo("end") == 0) - { - DocumentDefinition = null; - Document = null; - databaseproperties = null; + FormWizard CurFormWizard = new FormWizard( m_serviceFactory, m_wizardContext ); + CurFormWizard.startFormWizard(); } } catch (Exception exception) @@ -134,7 +116,7 @@ public class CallFormWizard private static final String __serviceName = "com.sun.star.wizards.form.CallFormWizard"; /** The service manager, that gives access to all registered services. */ - private com.sun.star.lang.XMultiServiceFactory xmultiservicefactory; + private com.sun.star.lang.XMultiServiceFactory m_serviceFactory; /** This method is a member of the interface for initializing an object * directly after its creation. @@ -145,7 +127,7 @@ public class CallFormWizard */ public void initialize(Object[] object) throws com.sun.star.uno.Exception { - databaseproperties = Properties.convertToPropertyValueArray(object); + m_wizardContext = Properties.convertToPropertyValueArray(object); } /** This method returns an array of all supported service names. diff --git a/wizards/com/sun/star/wizards/form/Finalizer.java b/wizards/com/sun/star/wizards/form/Finalizer.java index 2b1ffc5786e2..2294586b813d 100644 --- a/wizards/com/sun/star/wizards/form/Finalizer.java +++ b/wizards/com/sun/star/wizards/form/Finalizer.java @@ -32,7 +32,6 @@ package com.sun.star.wizards.form; import com.sun.star.awt.XRadioButton; import com.sun.star.awt.XTextComponent; import com.sun.star.wizards.common.Desktop; -import com.sun.star.wizards.ui.UIConsts; import com.sun.star.wizards.ui.*; /** @@ -45,7 +44,6 @@ public class Finalizer { WizardDialog CurUnoDialog; - Desktop.OfficePathRetriever curofficepath; short curtabindex; XRadioButton optModifyForm; XRadioButton optWorkWithForm; @@ -88,7 +86,7 @@ public class Finalizer { UIConsts.INTEGERS[8], slblProceed, new Integer(97), new Integer(62), UIConsts.INTEGERS[8], new Short(curtabindex++), new Integer(185) }); - XRadioButton optWorkWithForm = CurUnoDialog.insertRadioButton("optWorkWithForm", null, + CurUnoDialog.insertRadioButton("optWorkWithForm", null, new String[] { "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width" @@ -130,10 +128,9 @@ public class Finalizer return txtFormName.getText(); } - public boolean getOpenMode() + public boolean getOpenForEditing() { - boolean bOpenMode = optModifyForm.getState() ? true : false; - return bOpenMode; + return optModifyForm.getState() ? true : false; } public boolean finish() diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java index 5b0a7939f6c2..9a6c0763aebf 100644 --- a/wizards/com/sun/star/wizards/form/FormWizard.java +++ b/wizards/com/sun/star/wizards/form/FormWizard.java @@ -33,12 +33,18 @@ import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.PropertyValue; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.lang.XComponent; -import com.sun.star.wizards.common.*; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.NoValidPathException; +import com.sun.star.wizards.common.Properties; +import com.sun.star.wizards.db.DatabaseObjectWizard; import com.sun.star.wizards.db.RelationController; import com.sun.star.wizards.document.OfficeDocument; -import com.sun.star.wizards.ui.*; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.UIConsts; -public class FormWizard extends WizardDialog +public class FormWizard extends DatabaseObjectWizard { private CommandFieldSelection curDBCommandFieldSelection; @@ -67,13 +73,13 @@ public class FormWizard extends WizardDialog public static final int SOGRID = 3; public static final int SOTOPJUSTIFIED = 4; private String slblTables; - private boolean bFormOpenMode; - private boolean bcreateForm = false; + private boolean m_openForEditing; + private boolean m_success = false; private String FormName; - public FormWizard(XMultiServiceFactory xMSF) + public FormWizard( XMultiServiceFactory i_servicFactory, final PropertyValue[] i_wizardContext ) { - super(xMSF, 34400); + super( i_servicFactory, 34400, i_wizardContext ); super.addResourceHandler("FormWizard", "dbw"); Helper.setUnoPropertyValues(xDialogModel, new String[] @@ -171,7 +177,6 @@ public class FormWizard extends WizardDialog switch (nOldStep) { case SOMAIN_PAGE: -// curFormDocument.oMainFormDBMetaData.setFieldNames(curDBCommandFieldSelection.getSelectedFieldNames()); { final String sTableName = curDBCommandFieldSelection.getSelectedCommandName(); final String[] aFieldNames = curDBCommandFieldSelection.getSelectedFieldNames(); @@ -219,40 +224,6 @@ public class FormWizard extends WizardDialog } } -/* - public static void main(String args[]) - { - - String ConnectStr = "uno:socket,host=localhost,port=8100;urp;StarOffice.ServiceManager"; //localhost ;Lo-1.Germany.sun.com; 10.16.65.155 - PropertyValue[] curproperties = null; - try - { - XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr); - FormWizard CurFormWizard = new FormWizard(xLocMSF); - if (xLocMSF != null) - { - System.out.println("Connected to " + ConnectStr); - curproperties = new PropertyValue[1]; -// curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/MyHSQL.odb"); - curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/MyHSQL.odb"); - curproperties[0] = Properties.createProperty("DataSourceName", "MyHSQLDatabase"); - // file:///C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/myjapanesehsqldatasourceMyDocAssign.odb"); - // MyDBase; Mydbwizard2DocAssign.odb; MyDBase.odb, Mydbwizard2DocAssign.odb ; Mydbwizard2DocAssign.odb; NewAccessDatabase, MyDocAssign baseLocation ); "DataSourceName", "db1"); - // /--/curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///x:/bc/MyHSQL Database.odb"); //MyDBase; Mydbwizard2DocAssign.odb; MyDBase.odb, Mydbwizard2DocAssign.odb ; Mydbwizard2DocAssign.odb; NewAccessDatabase, baseLocation ); "DataSourceName", "db1"); - // curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography"); - // curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography"); - // Bibliography* CurTableWizard.startTableWizard(xLocMSF, curproperties); - - CurFormWizard.startFormWizard(xLocMSF, curproperties); - } - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - } -*/ - public void buildSteps() throws NoValidPathException { curDBCommandFieldSelection = new CommandFieldSelection(this, curFormDocument.oMainFormDBMetaData, 92, slblFields, slblSelFields, slblTables, true, 34411); @@ -317,14 +288,14 @@ public class FormWizard extends WizardDialog String sNewFormName = curFinalizer.getName(); if (!curFormDocument.oMainFormDBMetaData.hasFormDocumentByName(sNewFormName)) { - bFormOpenMode = curFinalizer.getOpenMode(); + m_openForEditing = curFinalizer.getOpenForEditing(); FormName = curFinalizer.getName(); if (curFormDocument.finalizeForms(CurDataEntrySetter, curFieldLinker, curFormConfiguration)) { if (curFinalizer.finish()) { - bcreateForm = true; + m_success = true; xDialog.endExecute(); } } @@ -340,7 +311,7 @@ public class FormWizard extends WizardDialog // @Override public void cancelWizard() { - bcreateForm = false; + m_success = false; xDialog.endExecute(); } @@ -361,33 +332,29 @@ public class FormWizard extends WizardDialog setCurrentRoadmapItemID((short) 1); } - public XComponent[] startFormWizard(XMultiServiceFactory _xMSF, PropertyValue[] CurPropertyValue) + public void startFormWizard() { - XComponent[] ret = null; try { curFormDocument = new FormDocument(xMSF); - if (curFormDocument.oMainFormDBMetaData.getConnection(CurPropertyValue)) + if ( curFormDocument.oMainFormDBMetaData.getConnection( m_wizardContext ) ) { curFormDocument.oSubFormDBMetaData.getConnection(new PropertyValue[] { Properties.createProperty("ActiveConnection", curFormDocument.oMainFormDBMetaData.DBConnection) }); curFormDocument.xProgressBar.setValue(20); - // SystemDialog.showMessageBox(xMSF, "FormName", 0, "slblFields"); buildSteps(); - // SystemDialog.showMessageBox(xMSF, "FormName", 0, "slblFields"); - this.curDBCommandFieldSelection.preselectCommand(CurPropertyValue, false); + this.curDBCommandFieldSelection.preselectCommand( m_wizardContext, false ); XWindowPeer xWindowPeer2 = createWindowPeer(curFormDocument.xWindowPeer); - curFormDocument.oMainFormDBMetaData.setWindowPeer(xWindowPeer2 /* xControl.getPeer() */ ); - // setAutoMnemonic("lblDialogHeader", false); + curFormDocument.oMainFormDBMetaData.setWindowPeer( xWindowPeer2 ); insertFormRelatedSteps(); - short RetValue = executeDialog(curFormDocument.xFrame); + short dialogReturn = executeDialog(curFormDocument.xFrame); xComponent.dispose(); - if (bcreateForm) + if ( ( dialogReturn == 0 ) && m_success ) { - curFormDocument.oMainFormDBMetaData.addFormDocument(curFormDocument.xComponent); - ret = curFormDocument.oMainFormDBMetaData.openFormDocument(FormName, bFormOpenMode); + curFormDocument.oMainFormDBMetaData.addFormDocument( curFormDocument.xComponent ); + loadSubComponent( DatabaseObject.FORM, FormName, m_openForEditing ); } } } @@ -395,11 +362,10 @@ public class FormWizard extends WizardDialog { jexception.printStackTrace(System.out); } - if ((!bcreateForm) && (curFormDocument != null)) + if ((!m_success) && (curFormDocument != null)) { OfficeDocument.close(curFormDocument.xComponent); } - return ret; } private boolean getFormResources() diff --git a/wizards/com/sun/star/wizards/report/CallReportWizard.java b/wizards/com/sun/star/wizards/report/CallReportWizard.java index 82c405747ad8..424e117c4d4f 100644 --- a/wizards/com/sun/star/wizards/report/CallReportWizard.java +++ b/wizards/com/sun/star/wizards/report/CallReportWizard.java @@ -30,14 +30,12 @@ package com.sun.star.wizards.report; import com.sun.star.beans.PropertyValue; -import com.sun.star.beans.PropertyAttribute; import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; import com.sun.star.text.XTextDocument; import com.sun.star.wizards.common.Properties; -import com.sun.star.lang.XComponent; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.wizards.common.Desktop; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.wizards.common.NamedValueCollection; /** This class capsulates the class, that implements the minimal component, a * factory for creating the service (__getServiceFactory) and a @@ -50,7 +48,7 @@ public class CallReportWizard static boolean bWizardstartedalready; - public static void main(String args[]) +/* public static void main(String args[]) { String ConnectStr = "uno:pipe,name=fs93730;urp;StarOffice.ServiceManager"; try @@ -61,15 +59,15 @@ public class CallReportWizard PropertyValue[] curproperties = new PropertyValue[1]; curproperties[0] = Properties.createProperty("DataSourceName", "countries"); - ReportWizard wizard = new ReportWizard(orb); - wizard.startReportWizard(orb, curproperties); + ReportWizard wizard = new ReportWizard( orb, curproperties ); + wizard.startReportWizard(); } } catch (java.lang.Exception jexception) { jexception.printStackTrace(System.out); } - } + }*/ /** Gives a factory for creating the service. * This method is called by the JavaLoader @@ -121,9 +119,7 @@ public class CallReportWizard public static class ReportWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor { - PropertyValue[] databaseproperties; - public XComponent DocumentDefinition = null; - public XComponent Document = null; + private PropertyValue[] m_wizardContext; /** The constructor of the inner class has a XMultiServiceFactory parameter. * @param xmultiservicefactoryInitialization A special service factory @@ -133,59 +129,32 @@ public class CallReportWizard { super(); xmultiservicefactory = xmultiservicefactoryInitialization; - registerProperty("Document", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); - registerProperty("DocumentDefinition", (short) (PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID)); } public void trigger(String sEvent) { try { - com.sun.star.frame.XComponentLoader xcomponentloader = (com.sun.star.frame.XComponentLoader) com.sun.star.uno.UnoRuntime.queryInterface(com.sun.star.frame.XComponentLoader.class, xmultiservicefactory.createInstance("com.sun.star.frame.Desktop")); if (sEvent.compareTo("start") == 0) { if (bWizardstartedalready != true) { - ReportWizard CurReportWizard = new ReportWizard(xmultiservicefactory); - XComponent[] obj = CurReportWizard.startReportWizard(xmultiservicefactory, databaseproperties); - if (obj != null) - { - DocumentDefinition = obj[0]; - if (obj.length > 1) - { - Document = obj[1]; - } - else - { - Document = null; - } - } + ReportWizard CurReportWizard = new ReportWizard( xmultiservicefactory, m_wizardContext ); + CurReportWizard.startReportWizard(); } bWizardstartedalready = false; } - else if (sEvent.compareTo("end") == 0) - { - DocumentDefinition = null; - Document = null; - databaseproperties = null; - } else if (sEvent.compareTo("fill") == 0) { Dataimport CurDataimport = new Dataimport(xmultiservicefactory); - XTextDocument xTextDocument = null; - if (databaseproperties != null) + if (m_wizardContext != null) { - for (int i = 0; i < databaseproperties.length; ++i) - { - if (databaseproperties[i].Name.equals("TextDocument")) - { - xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, databaseproperties[i].Value); - } - - } - if (xTextDocument != null) + NamedValueCollection context = new NamedValueCollection( m_wizardContext ); + XTextDocument textDocument = context.queryOrDefault( "TextDocument", null, XTextDocument.class ); + XDatabaseDocumentUI documentUI = context.queryOrDefault( "DocumentUI", null, XDatabaseDocumentUI.class ); + if ( textDocument != null ) { - CurDataimport.createReport(xmultiservicefactory, xTextDocument, databaseproperties); + CurDataimport.createReport(xmultiservicefactory, documentUI, textDocument, m_wizardContext); } } } @@ -212,7 +181,7 @@ public class CallReportWizard */ public void initialize(Object[] object) throws com.sun.star.uno.Exception { - this.databaseproperties = Properties.convertToPropertyValueArray(object); + this.m_wizardContext = Properties.convertToPropertyValueArray(object); // xmultiservicefactory = (XMultiservicefactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, object[0]); } diff --git a/wizards/com/sun/star/wizards/report/Dataimport.java b/wizards/com/sun/star/wizards/report/Dataimport.java index d0f6c4a0ceca..067e14d496a5 100644 --- a/wizards/com/sun/star/wizards/report/Dataimport.java +++ b/wizards/com/sun/star/wizards/report/Dataimport.java @@ -31,6 +31,7 @@ package com.sun.star.wizards.report; import com.sun.star.beans.PropertyValue; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.text.XTextDocument; import com.sun.star.wizards.ui.*; @@ -214,11 +215,10 @@ public class Dataimport extends UnoDialog2 implements com.sun.star.awt.XActionLi CurReportDocument.getRecordParser().dispose(); } - public void createReport(final XMultiServiceFactory xMSF, XTextDocument _textDocument, PropertyValue[] properties) + public void createReport( XMultiServiceFactory xMSF, XDatabaseDocumentUI i_documentUI, XTextDocument _textDocument, + PropertyValue[] properties) { - // CurReportDocument = new ReportTextDocument(xMSF, _textDocument,m_oResource); - CurReportDocument = ReportTextImplementation.create(xMSF, _textDocument, m_oResource); -// CurProperties = properties; + CurReportDocument = ReportTextImplementation.create( xMSF, i_documentUI, _textDocument, m_oResource ); showProgressDisplay(xMSF, true); importReportData(xMSF, this, CurReportDocument, properties); } diff --git a/wizards/com/sun/star/wizards/report/IReportDocument.java b/wizards/com/sun/star/wizards/report/IReportDocument.java index af8476f5c3e9..7629b6f54ffd 100644 --- a/wizards/com/sun/star/wizards/report/IReportDocument.java +++ b/wizards/com/sun/star/wizards/report/IReportDocument.java @@ -34,6 +34,8 @@ package com.sun.star.wizards.report; import com.sun.star.beans.PropertyValue; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.XDatabaseDocumentUI; +import com.sun.star.wizards.common.Resource; import java.util.ArrayList; import java.util.Vector; @@ -45,14 +47,14 @@ import java.util.Vector; */ public interface IReportDocument { - // public ReportTextDocument getDoc(); // ------------------------------------------------------------------------- // initialisation // ------------------------------------------------------------------------- + public void initialize( + final XDatabaseDocumentUI i_documentUI, + final Resource i_resource + ); - // ------------------------------------------------------------------------- - // opening the dialog - // ------------------------------------------------------------------------- // ------------------------------------------------------------------------- // Access Helper // ------------------------------------------------------------------------- @@ -211,7 +213,7 @@ public interface IReportDocument * * TODO: add Name to this functionality */ - public void addReportToDBView(/* String Name */); + public void addReportToDBView(); public void importReportData(ReportWizard aWizard); @@ -222,7 +224,11 @@ public interface IReportDocument * @param _bOpenInDesign * @return */ - public XComponent[] createFinalReportDocument(String Name, boolean _bAsTemplate, boolean _bOpenInDesign); + public void createAndOpenReportDocument( + final String Name, + final boolean _bAsTemplate, + final boolean _bOpenInDesign + ); public void dispose(); // ------------------------------------------------------------------------- diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java index 3d79c5d2d8ac..53d7e75dd006 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -34,13 +34,16 @@ package com.sun.star.wizards.report; import com.sun.star.awt.VclWindowPeerAttribute; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.PropertyValue; +import com.sun.star.container.NoSuchElementException; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.container.XNamed; +import com.sun.star.frame.XController; import com.sun.star.frame.XFrame; -// import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.lang.IllegalArgumentException; import com.sun.star.lang.XComponent; import com.sun.star.sdb.CommandType; +import com.sun.star.sdbc.SQLException; import com.sun.star.table.XCellRange; import com.sun.star.text.XTextContent; import com.sun.star.text.XTextCursor; @@ -56,6 +59,8 @@ import com.sun.star.wizards.common.JavaTools; import com.sun.star.wizards.common.Resource; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.wizards.common.SystemDialog; import com.sun.star.wizards.db.DBMetaData; import com.sun.star.wizards.db.SQLQueryComposer; @@ -63,6 +68,8 @@ import com.sun.star.wizards.document.OfficeDocument; import com.sun.star.wizards.ui.UIConsts; import java.util.ArrayList; import java.util.Vector; +import java.util.logging.Level; +import java.util.logging.Logger; /** * @@ -71,11 +78,12 @@ import java.util.Vector; public class ReportTextImplementation extends ReportImplementationHelper implements IReportDocument { - private ReportTextDocument m_aDoc; - private Object m_aInitialDoc; - private Resource m_aResource; + private ReportTextDocument m_aDoc; + private Object m_aInitialDoc; + private Resource m_resource; + private XDatabaseDocumentUI m_documentUI; - public void setInitialDocument(Object _aDoc) + private void setInitialDocument(Object _aDoc) { m_aInitialDoc = _aDoc; } @@ -91,15 +99,15 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme { if (m_aInitialDoc instanceof XTextDocument) { - m_aDoc = new ReportTextDocument(getMSF(), (XTextDocument) m_aInitialDoc, m_aResource, getRecordParser()); + m_aDoc = new ReportTextDocument(getMSF(), (XTextDocument) m_aInitialDoc, m_resource, getRecordParser()); } else if (m_aInitialDoc instanceof String) { - m_aDoc = new ReportTextDocument(getMSF(), (String) m_aInitialDoc, m_aResource, getRecordParser()); + m_aDoc = new ReportTextDocument(getMSF(), (String) m_aInitialDoc, m_resource, getRecordParser()); } else { - throw new RuntimeException("Unknown type for setInitialDoc() given."); + throw new RuntimeException("Unknown type for setInitialDocument() given."); } } return m_aDoc; @@ -107,40 +115,37 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme public void clearDocument() { - int dummy = 0; - /*CurReportDocument.*/ getDoc().oTextSectionHandler.removeAllTextSections(); - /*CurReportDocument.*/ getDoc().oTextTableHandler.removeAllTextTables(); - /*CurReportDocument.*/ getDoc().DBColumnsVector = new Vector(); - //getRecordParser().setGroupFieldNames(new String[]{}); - // CurGroupFieldHandler.removeGroupFieldNames(); + getDoc().oTextSectionHandler.removeAllTextSections(); + getDoc().oTextTableHandler.removeAllTextTables(); + getDoc().DBColumnsVector = new Vector(); } - private ReportTextImplementation(XMultiServiceFactory _xMSF, Resource _oResource) + protected ReportTextImplementation( XMultiServiceFactory i_serviceFactory ) { - super(_xMSF, ReportLayouter.SOOPTLANDSCAPE); - m_aResource = _oResource; + super( i_serviceFactory, ReportLayouter.SOOPTLANDSCAPE ); } - static IReportDocument create(XMultiServiceFactory _xMSF /*, String _sPreviewURL */, Resource _oResource) + public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource ) { - ReportTextImplementation a = new ReportTextImplementation(_xMSF, _oResource); - String sPreviewURL = a.getLayoutPath(); // a.getReportPath() + "/stl-default.ott"; - a.setInitialDocument(sPreviewURL); - a.initialResources(); - return a; + m_documentUI = i_documentUI; + m_resource = i_resource; + + if ( m_aInitialDoc == null ) + setInitialDocument( getLayoutPath() ); + + initialResources(); } - static IReportDocument create(XMultiServiceFactory _xMSF, XTextDocument _aDoc, Resource _oResource) + static IReportDocument create( XMultiServiceFactory i_serviceFactory, XDatabaseDocumentUI i_documentUI, XTextDocument i_initialDocument, Resource i_resources ) { - ReportTextImplementation a = new ReportTextImplementation(_xMSF, _oResource); - a.setInitialDocument(_aDoc); - a.initialResources(); + ReportTextImplementation a = new ReportTextImplementation( i_serviceFactory ); + a.setInitialDocument(i_initialDocument); + a.initialize( i_documentUI, i_resources ); return a; } public XWindowPeer getWizardParent() { - // throw new UnsupportedOperationException("Not supported yet."); return getDoc().xWindowPeer; } static String sMsgQueryCreationImpossible; @@ -153,11 +158,11 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme private void initialResources() { - sReportFormNotExisting = m_aResource.getResText(UIConsts.RID_REPORT + 64); - sMsgQueryCreationImpossible = m_aResource.getResText(UIConsts.RID_REPORT + 65); - sMsgHiddenControlMissing = m_aResource.getResText(UIConsts.RID_REPORT + 66); - sMsgEndAutopilot = m_aResource.getResText(UIConsts.RID_DB_COMMON + 33); - sMsgNoConnection = m_aResource.getResText(UIConsts.RID_DB_COMMON + 14); + sReportFormNotExisting = m_resource.getResText(UIConsts.RID_REPORT + 64); + sMsgQueryCreationImpossible = m_resource.getResText(UIConsts.RID_REPORT + 65); + sMsgHiddenControlMissing = m_resource.getResText(UIConsts.RID_REPORT + 66); + sMsgEndAutopilot = m_resource.getResText(UIConsts.RID_DB_COMMON + 33); + sMsgNoConnection = m_resource.getResText(UIConsts.RID_DB_COMMON + 14); } public void addTextSectionCopies() @@ -185,8 +190,8 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme try { XInterface xTextSection = (XInterface) getDocumentServiceFactory().createInstance("com.sun.star.text.TextSection"); - XTextContent xTextSectionContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xTextSection); - xNamedTextSection = (XNamed) UnoRuntime.queryInterface(XNamed.class, xTextSection); + XTextContent xTextSectionContent = UnoRuntime.queryInterface( XTextContent.class, xTextSection ); + xNamedTextSection = UnoRuntime.queryInterface( XNamed.class, xTextSection ); xTextCursor.gotoEnd(false); xTextCursor.getText().insertTextContent(xTextCursor, xTextSectionContent, true); Helper.setUnoPropertyValue(xTextSection, "LinkRegion", sLinkRegion); @@ -196,7 +201,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme if (bIsGroupTable == true) { XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); - XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, xTextTable); + XCellRange xCellRange = UnoRuntime.queryInterface( XCellRange.class, xTextTable ); CurDBColumn.modifyCellContent(xCellRange, CurGroupValue); } } @@ -211,7 +216,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme private void renameTableofLastSection(String _snewname) { XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); - XNamed xNamedTable = (XNamed) UnoRuntime.queryInterface(XNamed.class, xTextTable); + XNamed xNamedTable = UnoRuntime.queryInterface( XNamed.class, xTextTable ); xNamedTable.setName(_snewname); } @@ -231,7 +236,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme if (oDBForm != null) { String sMsg = sMsgHiddenControlMissing + (char) 13 + sMsgEndAutopilot; - XNameAccess xNamedForm = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oDBForm); + XNameAccess xNamedForm = UnoRuntime.queryInterface( XNameAccess.class, oDBForm ); getRecordParser().Command = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Command", sMsg); String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "CommandType", sMsg); String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames", sMsg); @@ -346,7 +351,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme { CurGroupTableName = ReportTextDocument.TBLGROUPSECTION + Integer.toString(ColIndex + 1); oTable = getDoc().oTextTableHandler.xTextTablesSupplier.getTextTables().getByName(CurGroupTableName); - xGroupBaseTables[ColIndex] = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, oTable); + xGroupBaseTables[ColIndex] = UnoRuntime.queryInterface( XTextTable.class, oTable ); CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex); OldGroupFieldValues[ColIndex] = CurGroupValue; CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex); @@ -574,24 +579,23 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme public void liveupdate_updateReportTitle(String _sTitleName) { - int dummy = 0; - // getDoc().updateReportTitle(_sTitleName); } -// public void finish() -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } public void addReportToDBView() { getRecordParser().addReportDocument(getComponent(), true); } - public XComponent[] createFinalReportDocument(String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign) + public void createAndOpenReportDocument( String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign ) { - // create the real report document, filled with content - XComponent[] ret = getRecordParser().openReportDocument(sReportName, _bAsTemplate, _bOpenInDesign); - return ret; + try + { + m_documentUI.loadComponent( DatabaseObject.REPORT, sReportName, _bOpenInDesign ); + } + catch ( Exception ex ) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } } public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames) @@ -715,8 +719,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme public void importReportData(ReportWizard _aWizard) { Dataimport CurDataimport = new Dataimport(_aWizard.xMSF); - CurDataimport.CurReportDocument = _aWizard.CurReportDocument; - // CurDataimport.showProgressDisplay(xMSF, false); + CurDataimport.CurReportDocument = this; _aWizard.importReportData(_aWizard.xMSF, CurDataimport); } @@ -728,7 +731,6 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme public void setCommand(String _sCommand) { getRecordParser().Command = _sCommand; - // throw new UnsupportedOperationException("Not supported yet."); } public void checkInvariants() throws java.lang.Exception diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index a4b4e3af18ad..245e3716be04 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -32,24 +32,15 @@ package com.sun.star.wizards.report; // import java.util.Vector; -// import com.sun.star.wizards.reportbuilder.ReportBuilderImplementation; -import com.sun.star.awt.Size; import com.sun.star.awt.TextEvent; import com.sun.star.awt.VclWindowPeerAttribute; -import com.sun.star.awt.XControl; -import com.sun.star.awt.XControlModel; -import com.sun.star.awt.XFixedText; -import com.sun.star.awt.XLayoutConstrains; import com.sun.star.awt.XTextListener; -import com.sun.star.awt.XWindow; import com.sun.star.beans.PropertyValue; -// import com.sun.star.beans.XPropertySet; import com.sun.star.container.XContentEnumerationAccess; import com.sun.star.deployment.XPackageInformationProvider; import com.sun.star.lang.EventObject; import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.lang.XServiceInfo; import com.sun.star.logging.XLogger; import com.sun.star.logging.XLoggerPool; import com.sun.star.sdb.CommandType; @@ -57,39 +48,40 @@ import com.sun.star.sdb.CommandType; import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; -import com.sun.star.wizards.common.*; -import com.sun.star.wizards.ui.*; -import com.sun.star.wizards.db.*; -import com.sun.star.lang.XComponent; +import com.sun.star.logging.LogLevel; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.Resource; +import com.sun.star.wizards.common.SystemDialog; +import com.sun.star.wizards.db.DBMetaData; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.SQLQueryComposer; +import com.sun.star.wizards.ui.CommandFieldSelection; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.SortingComponent; +import com.sun.star.wizards.ui.TitlesComponent; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.UnoDialog; +import com.sun.star.wizards.ui.XCompletion; import java.lang.reflect.Method; import java.net.URI; import java.net.URL; import java.net.URLClassLoader; import java.util.Map; -public class ReportWizard extends WizardDialog implements XTextListener, XCompletion +public class ReportWizard extends DatabaseObjectWizard implements XTextListener, XCompletion { - // XMultiServiceFactory xMSF; - // QueryMetaData CurDBMetaData; protected FieldSelection CurGroupFieldSelection; private SortingComponent CurSortingComponent; - // private UnoDialog CurUnoProgressDialog; private TitlesComponent CurTitlesComponent; private CommandFieldSelection CurDBCommandFieldSelection; private GroupFieldHandler CurGroupFieldHandler; private ReportLayouter CurReportLayouter; private ReportFinalizer CurReportFinalizer; - private PropertyValue[] DBGPROPERTYVALUE; - // private String sCommandName = ""; - // private int nCommandType = -1; private int nReportMode = ReportFinalizer.SOCREATEDOCUMENT; private String m_sReportName = ""; protected static final String SOREPORTFORMNAME = "ReportSource"; - // private final int SOSELGROUPLST = 33; - // private final int SOTXTCOLTITLE = 48; - // private final int SOTITLESCROLLBAR = 49; - // private static final int SONULLPAGE = 0; private static final int SOMAINPAGE = 1; private static final int SOTITLEPAGE = 2; protected static final int SOGROUPPAGE = 3; @@ -97,36 +89,21 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple protected static final int SOTEMPLATEPAGE = 5; protected static final int SOSTOREPAGE = 6; - // ReportTextDocument CurReportDocument; - // ReportTextImplementation CurReportDocument; - protected IReportDocument CurReportDocument; + private IReportDocument m_reportDocument; private static String sMsgWizardName; private static String slblFields; private static String slblSelFields; private static String sShowBinaryFields; - // private static String sGroupings; private String[] WizardHeaderText = new String[6]; - // private static String[] WizardTitle = new String[6]; - // private static String sWriterFilterName; - private static String slstDatabasesDefaultText; - private static String slstTablesDefaultText; - private static String sMsgErrorOccured; - private static String sMsgSavingImpossible; - // private static String sMsgNoConnection; - // Progress display relevant Strings private static String slblColumnTitles; private static String slblColumnNames; - private static String sMsgNoConnectionforDataimport; - private static String sMsgQueryCreationImpossible; - private static String sMsgFilePathInvalid; private static String slblTables; -// public static String sBlindTextNote; protected static boolean bCloseDocument; private boolean bHasEscapeProcessing = true; - public ReportWizard(XMultiServiceFactory xMSF) + public ReportWizard( XMultiServiceFactory i_serviceFactory, final PropertyValue[] i_wizardContext ) { - super(xMSF, 34320); + super(i_serviceFactory, 34320, i_wizardContext ); super.addResourceHandler("Report Wizard", "dbw"); if (getReportResources(false) == true) { @@ -166,7 +143,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple { // CurReportDocument.getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection"); // CurReportDocument.getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection"); - CurReportDocument.removeTextTableAndTextSection(); + m_reportDocument.removeTextTableAndTextSection(); } switch (nNewStep) { @@ -175,8 +152,8 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple break; case SOTITLEPAGE: - String[] aFieldNames = CurReportDocument.getRecordParser().getFieldNames(); - Map aFieldTitleSet = CurReportDocument.getRecordParser().getFieldTitleSet(); + String[] aFieldNames = m_reportDocument.getRecordParser().getFieldNames(); + Map aFieldTitleSet = m_reportDocument.getRecordParser().getFieldTitleSet(); CurTitlesComponent.initialize(aFieldNames, aFieldTitleSet); break; @@ -185,10 +162,10 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple break; case SOSORTPAGE: - String[] aFieldNames2 = CurReportDocument.getRecordParser().getFieldNames(); - String[][] aSortFieldNames = CurReportDocument.getRecordParser().getSortFieldNames(); + String[] aFieldNames2 = m_reportDocument.getRecordParser().getFieldNames(); + String[][] aSortFieldNames = m_reportDocument.getRecordParser().getSortFieldNames(); CurSortingComponent.initialize(aFieldNames2, aSortFieldNames); - int nLength = CurReportDocument.getRecordParser().GroupFieldNames.length; + int nLength = m_reportDocument.getRecordParser().GroupFieldNames.length; CurSortingComponent.setReadOnlyUntil(nLength, false); break; @@ -197,7 +174,7 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple case SOSTOREPAGE: //TODO initialize with suitable PathName - CurReportFinalizer.initialize(CurReportDocument.getRecordParser()); + CurReportFinalizer.initialize(m_reportDocument.getRecordParser()); break; default: @@ -213,23 +190,13 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple case SOMAINPAGE: String[] aSelectedFieldNames = CurDBCommandFieldSelection.getSelectedFieldNames(); String aTableName = CurDBCommandFieldSelection.getSelectedCommandName(); - // set all selected field names, DB Table name - // CurReportDocument.getRecordParser().initializeFieldColumns(aSelectedFieldNames, aTableName); int nType = CurDBCommandFieldSelection.getSelectedCommandType(); - // nType = com.sun.star.sdb.CommandType.TABLE; - CurReportDocument.initializeFieldColumns(nType, aTableName, aSelectedFieldNames); - // CurReportDocument.initializeFieldColumns(aSelectedFieldNames, aSelectedCommandName); - // CurReportDocument.getRecordParser().setAllIncludedFieldNames(false); + m_reportDocument.initializeFieldColumns(nType, aTableName, aSelectedFieldNames); if (CurDBCommandFieldSelection.isModified()) { // cleanup document - CurReportDocument.clearDocument(); - // CurReportDocument.getDoc().oTextSectionHandler.removeAllTextSections(); - // CurReportDocument.getDoc().oTextTableHandler.removeAllTextTables(); - // CurReportDocument.getDoc().DBColumnsVector = new Vector(); - CurReportDocument.getRecordParser().setGroupFieldNames(new String[] - { - }); + m_reportDocument.clearDocument(); + m_reportDocument.getRecordParser().setGroupFieldNames(new String[]{}); CurGroupFieldHandler.removeGroupFieldNames(); } break; @@ -238,21 +205,21 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple String[] sFieldTitles = CurTitlesComponent.getFieldTitles(); // set new field name titles // CurReportDocument.getRecordParser().setFieldTitles(sFieldTitles); - CurReportDocument.setFieldTitles(sFieldTitles); + m_reportDocument.setFieldTitles(sFieldTitles); break; case SOGROUPPAGE: // TODO: DESIGN!!! a getter should return a value!!! - CurGroupFieldHandler.getGroupFieldNames(CurReportDocument.getRecordParser()); - String[] aGroupFieldNames = CurReportDocument.getRecordParser().GroupFieldNames; + CurGroupFieldHandler.getGroupFieldNames(m_reportDocument.getRecordParser()); + String[] aGroupFieldNames = m_reportDocument.getRecordParser().GroupFieldNames; // CurReportDocument.getRecordParser().prependSortFieldNames(aGroupFieldNames); - CurReportDocument.setGrouping(aGroupFieldNames); + m_reportDocument.setGrouping(aGroupFieldNames); break; case SOSORTPAGE: String[][] aSortFieldNames = CurSortingComponent.getSortFieldNames(); // CurReportDocument.getRecordParser().SortFieldNames = aSortFieldNames; - CurReportDocument.setSorting(aSortFieldNames); + m_reportDocument.setSorting(aSortFieldNames); // TODO: why do we make a switch here super.enablefromStep(SOTEMPLATEPAGE, true); break; @@ -270,58 +237,33 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple if ((nOldStep < SOTEMPLATEPAGE) && (super.getNewStep() >= SOTEMPLATEPAGE)) { // this is called before SOTEMPLATEPAGE, after SOGROUPPAGE - CurReportDocument.getRecordParser().createRecordFieldNames(); - CurReportLayouter.initialize(CurReportDocument.getContentPath()); + m_reportDocument.getRecordParser().createRecordFieldNames(); + CurReportLayouter.initialize(m_reportDocument.getContentPath()); } } - private XComponent[] dialogFinish(short RetValue) + private void dialogFinish() { - XComponent[] ret = null; - // Report Wizard Dialog is done. - boolean bdisposeDialog = true; - switch (RetValue) - { - case 0: - // via Cancelbutton or via sourceCode with "endExecute" - this.xComponent.dispose(); - if (bCloseDocument == true) - { - // OfficeDocument.dispose(xMSF, CurReportDocument.getDoc().xComponent); - CurReportDocument.dispose(); - return ret; - } - if ((nReportMode == ReportFinalizer.SOCREATETEMPLATE) || (nReportMode == ReportFinalizer.SOUSETEMPLATE)) - { - bdisposeDialog = false; - // Add Report to the DB View - // old: CurReportDocument.getRecordParser().addReportDocument(CurReportDocument.getComponent(), true); - CurReportDocument.addReportToDBView(); - boolean bOpenInDesign = (nReportMode == ReportFinalizer.SOCREATETEMPLATE); - // Create Report - // old: ret = CurReportDocument.getRecordParser().openReportDocument(sReportName, true, bOpenInDesign); - ret = CurReportDocument.createFinalReportDocument(m_sReportName, true, bOpenInDesign); - } - else - { - bdisposeDialog = false; - CurReportDocument.importReportData(this); - // Dataimport CurDataimport = new Dataimport(xMSF); - // CurDataimport.CurReportDocument = CurReportDocument; - // CurDataimport.showProgressDisplay(xMSF, false); - // importReportData(xMSF, CurDataimport); - // old: ret = CurReportDocument.getRecordParser().openReportDocument(sReportName, false, false); - ret = CurReportDocument.createFinalReportDocument(m_sReportName, false, false); - } - return ret; - case 1: - if (bdisposeDialog == true) - { - // CurReportDocument.getDoc().unlockallControllers(); - } - break; + this.xComponent.dispose(); + if (bCloseDocument == true) + { + m_reportDocument.dispose(); + return; + } + + if ( ( nReportMode == ReportFinalizer.SOCREATETEMPLATE ) + || ( nReportMode == ReportFinalizer.SOUSETEMPLATE ) + ) + { + m_reportDocument.addReportToDBView(); + boolean bOpenInDesign = (nReportMode == ReportFinalizer.SOCREATETEMPLATE); + m_reportDocument.createAndOpenReportDocument( m_sReportName, true, bOpenInDesign); + } + else + { + m_reportDocument.importReportData(this); + m_reportDocument.createAndOpenReportDocument( m_sReportName, false, false ); } - return null; } private boolean executeQuery() @@ -329,35 +271,35 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple boolean bQueryCreated = false; if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) { - bQueryCreated = CurReportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(sMsgWizardName, this.xWindow, false, false); + bQueryCreated = m_reportDocument.getRecordParser().oSQLQueryComposer.setQueryCommand(sMsgWizardName, this.xWindow, false, false); - CurReportDocument.setCommandType(CommandType.COMMAND); - String sQuery = CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery(); - CurReportDocument.setCommand(sQuery); + m_reportDocument.setCommandType(CommandType.COMMAND); + String sQuery = m_reportDocument.getRecordParser().oSQLQueryComposer.getQuery(); + m_reportDocument.setCommand(sQuery); } else { try { String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); - DBMetaData.CommandObject oCommand = CurReportDocument.getRecordParser().getQueryByName(sQueryName); - bHasEscapeProcessing = CurReportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); + DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName); + bHasEscapeProcessing = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); String sCommand = (String) oCommand.getPropertySet().getPropertyValue("Command"); if (bHasEscapeProcessing) { // String sCommand = (String) oCommand.xPropertySet.getPropertyValue("Command"); bQueryCreated = (!sCommand.equals("")); - CurReportDocument.getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); - CurReportDocument.getRecordParser().oSQLQueryComposer.prependSortingCriteria(); + m_reportDocument.getRecordParser().oSQLQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); + m_reportDocument.getRecordParser().oSQLQueryComposer.prependSortingCriteria(); // TODO: check with query - CurReportDocument.setCommandType(CommandType.COMMAND); - CurReportDocument.setCommand(CurReportDocument.getRecordParser().oSQLQueryComposer.getQuery()); + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(m_reportDocument.getRecordParser().oSQLQueryComposer.getQuery()); bQueryCreated = true; } else { - CurReportDocument.setCommandType(CommandType.COMMAND); - CurReportDocument.setCommand(sCommand); + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(sCommand); bQueryCreated = true; } } @@ -372,124 +314,10 @@ public class ReportWizard extends WizardDialog implements XTextListener, XComple } return bQueryCreated; } -/* - public static void main(String args[]) - { - String ConnectStr = "uno:socket,host=localhost,port=8107;urp;StarOffice.NamingService"; //localhost ;Lo-1.Germany.sun.com; 10.16.65.155 - try - { - XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr); - - tests(xLocMSF); - - ReportWizard CurReportWizard = new ReportWizard(xLocMSF); - if (xLocMSF != null) - { - System.out.println("Connected to " + ConnectStr); - PropertyValue[] curproperties = new PropertyValue[1]; - // curproperties[0] = Properties.createProperty( - // "DatabaseLocation", - // "file:///localhome/bc93774/NewDatabase2" + - // "C:/Documents and Settings/ll93751/My Documents/RptWizard01_DB.odb"); - // "file://C:/Documents%20and%20Settings/ll93751/My%20Documents/RptWizard01_DB.odb"); -// "C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/MyHSQL.odb"); //MyDocAssign.odb; baseLocation ); "DataSourceName", "db1"); - // curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography"); - curproperties[0] = Properties.createProperty("DataSourceName", "RptWizard01_DB"); - CurReportWizard.startReportWizard(xLocMSF, curproperties, true); - } - } - catch (Exception exception) - { - exception.printStackTrace(System.out); - } - System.exit(1); - } -*/ -/* - private static void tests(XMultiServiceFactory _xMSF) - { - try - { -// String[] sServices = _xMSF.getAvailableServiceNames(); -// File aFile = new File("C:/temp/services.txt"); -// aFile.delete(); -// FileWriter aRAF = new FileWriter(aFile); -// for (int i=0;i 0 ) { - // debug == false - - // Get the path to the extension and try to add the path to the class loader - String sLocation = getPathToExtension(xMSF); - // TODO: Umlaut in filename! - if (sLocation.length() > 0) + try { - try - { - URI aLocationURI = URI.create(sLocation + "/" + "reportbuilderwizard.jar"); - - URL[] aURLs = new URL[1]; - aURLs[0] = aLocationURI.toURL(); - URLClassLoader aClassLoader = new URLClassLoader(aURLs, this.getClass().getClassLoader()); - Class a = aClassLoader.loadClass("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation"); - Method aMethod = a.getMethod("create", new Class[] - { - XMultiServiceFactory.class, Resource.class - }); - CurReportDocument = (IReportDocument) aMethod.invoke(a, new Object[] - { - xMSF, m_oResource - }); - } - catch (Exception e) - { - // TODO: Exception not handled. - int dummy = 0; - // Maybe problems in URI create() if a wrong char is used like '[' ']', ... - System.out.println("There could be a problem with the path '" + sLocation + "'"); - } + URI aLocationURI = URI.create(sLocation + "/" + "reportbuilderwizard.jar"); + + URL[] aURLs = new URL[1]; + aURLs[0] = aLocationURI.toURL(); + URLClassLoader aClassLoader = new URLClassLoader(aURLs, this.getClass().getClassLoader()); + Class a = aClassLoader.loadClass("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation"); + Method aMethod = a.getMethod("create", new Class[] { XMultiServiceFactory.class }); + m_reportDocument = (IReportDocument) aMethod.invoke(a, new Object[] { xMSF }); + } + catch (Exception e) + { + // Maybe problems in URI create() if a wrong char is used like '[' ']', ... + System.out.println("There could be a problem with the path '" + sLocation + "'"); } } } + try { - if (CurReportDocument == null) + if (m_reportDocument == null) { // Fallback, if there is no reportbuilder wizard implementation, we use the old wizard - CurReportDocument = ReportTextImplementation.create(xMSF, m_oResource); + m_reportDocument = new ReportTextImplementation( xMSF ); } - // CurDBMetaData = CurReportDocument.getRecordParser(); -// tests(); + m_reportDocument.initialize( m_docUI, m_oResource ); - if (CurReportDocument.getRecordParser().getConnection(CurPropertyValue)) + if ( m_reportDocument.getRecordParser().getConnection( m_wizardContext ) ) { - // CurReportDocument.getDoc().xProgressBar.setValue(20); - CurReportDocument.getRecordParser().oSQLQueryComposer = new SQLQueryComposer(CurReportDocument.getRecordParser()); + m_reportDocument.getRecordParser().oSQLQueryComposer = new SQLQueryComposer(m_reportDocument.getRecordParser()); buildSteps(); - CurReportDocument.checkInvariants(); + m_reportDocument.checkInvariants(); - this.CurDBCommandFieldSelection.preselectCommand(CurPropertyValue, false); + this.CurDBCommandFieldSelection.preselectCommand( m_wizardContext, false ); - createWindowPeer(CurReportDocument.getWizardParent()); + createWindowPeer(m_reportDocument.getWizardParent()); - CurReportDocument.getRecordParser().setWindowPeer(this.xControl.getPeer()); + m_reportDocument.getRecordParser().setWindowPeer(this.xControl.getPeer()); insertQueryRelatedSteps(); - short RetValue = executeDialog(CurReportDocument.getFrame().getComponentWindow().getPosSize()); - ret = dialogFinish(RetValue); + short RetValue = executeDialog(m_reportDocument.getFrame().getComponentWindow().getPosSize()); + if ( RetValue == 0 ) + dialogFinish(); } - CurReportDocument.getRecordParser().dispose(); + m_reportDocument.getRecordParser().dispose(); } catch (java.io.IOException e) { @@ -742,7 +514,6 @@ public static XLogger getLogger() { jexception.printStackTrace(System.out); } - return ret; } public void importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport) @@ -753,25 +524,25 @@ public static XLogger getLogger() boolean bexecute = false; if (!bHasEscapeProcessing) { - bexecute = CurReportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.QUERY); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.QUERY); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) } else { - bexecute = CurReportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.COMMAND); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.COMMAND); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) } if (bexecute) { - bexecute = CurReportDocument.getRecordParser().getFields(CurReportDocument.getRecordParser().getFieldNames(), false); + bexecute = m_reportDocument.getRecordParser().getFields(m_reportDocument.getRecordParser().getFieldNames(), false); } if (bexecute) { // CurDataimport.insertDatabaseDatatoReportDocument(xMSF); - CurReportDocument.insertDatabaseDatatoReportDocument(xMSF); + m_reportDocument.insertDatabaseDatatoReportDocument(xMSF); } if (CurReportFinalizer.getReportOpenMode() == ReportFinalizer.SOCREATEDOCUMENT) { - bDocisStored = CurReportDocument.getRecordParser().storeDatabaseDocumentToTempPath(CurReportDocument.getComponent(), CurReportFinalizer.getStoreName()); + bDocisStored = m_reportDocument.getRecordParser().storeDatabaseDocumentToTempPath(m_reportDocument.getComponent(), CurReportFinalizer.getStoreName()); } } catch (com.sun.star.wizards.common.InvalidQueryException queryexception) @@ -780,10 +551,10 @@ public static XLogger getLogger() CurDataimport.xComponent.dispose(); if (bDocisStored) { - CurReportDocument.getRecordParser().addReportDocument(CurReportDocument.getComponent(), false); + m_reportDocument.getRecordParser().addReportDocument(m_reportDocument.getComponent(), false); } - CurReportDocument.getRecordParser().dispose(); + m_reportDocument.getRecordParser().dispose(); } public boolean getReportResources(boolean bgetProgressResourcesOnly) @@ -792,9 +563,6 @@ public static XLogger getLogger() if (bgetProgressResourcesOnly == false) { sShowBinaryFields = m_oResource.getResText(UIConsts.RID_REPORT + 60); - slstDatabasesDefaultText = m_oResource.getResText(UIConsts.RID_DB_COMMON + 37); - slstTablesDefaultText = m_oResource.getResText(UIConsts.RID_DB_COMMON + 38); - sMsgErrorOccured = m_oResource.getResText(UIConsts.RID_DB_COMMON + 6); slblTables = m_oResource.getResText(UIConsts.RID_FORM + 6); slblFields = m_oResource.getResText(UIConsts.RID_FORM + 12); slblSelFields = m_oResource.getResText(UIConsts.RID_REPORT + 9); @@ -804,13 +572,9 @@ public static XLogger getLogger() WizardHeaderText[3] = m_oResource.getResText(UIConsts.RID_REPORT + 30); WizardHeaderText[4] = m_oResource.getResText(UIConsts.RID_REPORT + 31); WizardHeaderText[5] = m_oResource.getResText(UIConsts.RID_REPORT + 32); - sMsgSavingImpossible = m_oResource.getResText(UIConsts.RID_DB_COMMON + 30); } - sMsgFilePathInvalid = m_oResource.getResText(UIConsts.RID_DB_COMMON + 36); slblColumnTitles = m_oResource.getResText(UIConsts.RID_REPORT + 70); slblColumnNames = m_oResource.getResText(UIConsts.RID_REPORT + 71); -// sBlindTextNote = m_oResource.getResText(UIConsts.RID_REPORT + 75); -// sBlindTextNote = JavaTools.replaceSubString( sBlindTextNote, String.valueOf((char)13), "
"); return true; } @@ -871,7 +635,7 @@ public static XLogger getLogger() String sContent = (String) Helper.getUnoPropertyValue(oModel, "Text"); String fieldname = this.CurTitlesComponent.getFieldNameByTitleControl(oModel); // CurReportDocument.getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); - CurReportDocument.liveupdate_changeUserFieldContent(fieldname, sContent); + m_reportDocument.liveupdate_changeUserFieldContent(fieldname, sContent); } catch (Exception exception) { @@ -901,8 +665,8 @@ public static XLogger getLogger() if (!bdoenable) { String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); - DBMetaData.CommandObject oCommand = CurReportDocument.getRecordParser().getQueryByName(sQueryName); - bdoenable = CurReportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); + DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName); + bdoenable = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); } super.setStepEnabled(SOSORTPAGE, bdoenable); diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java index dad827841e96..f14f4dce0bd9 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java +++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java @@ -33,11 +33,9 @@ package com.sun.star.wizards.reportbuilder; import com.sun.star.util.XModeSelector; -import com.sun.star.wizards.report.*; import com.sun.star.awt.XWindowPeer; import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; -import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.frame.XController; import com.sun.star.frame.XDispatch; @@ -46,10 +44,15 @@ import com.sun.star.frame.XFrame; import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.report.XReportDefinition; +import com.sun.star.sdb.XSubDocument; +import com.sun.star.sdb.application.DatabaseObject; +import com.sun.star.sdb.application.XDatabaseDocumentUI; import com.sun.star.sdbc.XConnection; import com.sun.star.ucb.XCommandProcessor; import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XModifiable; import com.sun.star.util.XURLTransformer; +import com.sun.star.wizards.common.NoValidPathException; import com.sun.star.wizards.common.Resource; import com.sun.star.wizards.db.FieldColumn; import java.lang.reflect.Constructor; @@ -59,6 +62,15 @@ import java.util.LinkedHashMap; import java.util.Set; import java.util.Vector; import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.NamedValueCollection; +import com.sun.star.wizards.report.IReportBuilderLayouter; +import com.sun.star.wizards.report.IReportDefinitionReadAccess; +import com.sun.star.wizards.report.IReportDocument; +import com.sun.star.wizards.report.ReportImplementationHelper; +import com.sun.star.wizards.report.ReportLayouter; +import com.sun.star.wizards.report.ReportWizard; +import java.util.logging.Level; +import java.util.logging.Logger; /** * This class use the IReportDocument Interface to communicate between the UI @@ -69,61 +81,35 @@ import com.sun.star.wizards.common.FileAccess; public class ReportBuilderImplementation extends ReportImplementationHelper implements IReportDocument, IReportDefinitionReadAccess { + private Resource m_resource; + private XDatabaseDocumentUI m_documentUI; private static final int MAXIMUM_GROUPCOUNT = 4; -// public ReportTextDocument getDoc() -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } - public void clearDocument() + + private ReportBuilderImplementation( XMultiServiceFactory _serviceFactory ) { - // throw new UnsupportedOperationException("Not supported yet."); + // creates an access to the ReportBuilder Extension + super(_serviceFactory, ReportLayouter.SOOPTLANDSCAPE); } - private Resource m_aResource; - public ReportBuilderImplementation() + public static IReportDocument create( XMultiServiceFactory i_serviceFactory ) { - // super(null, ReportLayouter.SOOPTPORTRAIT); - super(null, ReportLayouter.SOOPTLANDSCAPE); - m_aResource = null; + return new ReportBuilderImplementation( i_serviceFactory ); } - private ReportBuilderImplementation(XMultiServiceFactory _aMSF, Resource _oResource) + public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource ) { - // creates an access to the ReportBuilder Extension - // super(_aMSF, ReportLayouter.SOOPTPORTRAIT); - super(_aMSF, ReportLayouter.SOOPTLANDSCAPE); - m_aResource = _oResource; + m_documentUI = i_documentUI; + m_resource = i_resource; } - /** - * This is the Factory method. To create a ReportBuilderImplementation Object. - * - * @param _xMSF - * @param _oResource - * @return - */ - public static IReportDocument create(XMultiServiceFactory _xMSF, Resource _oResource) + public void clearDocument() { - final ReportBuilderImplementation a = new ReportBuilderImplementation(_xMSF, _oResource); - // a.m_xGlobalServiceFactory = _xGlobalServiceFactory; - return a; } -// public void setInitialDocument(Object _aDoc) -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } public XWindowPeer getWizardParent() { - // throw new UnsupportedOperationException("Not supported yet."); - // com.sun.star.frame.XFrame xFrame = thisComponent; - // openReportBuilderView(); - // XInterface xInterface = (XInterface) getMSF().createInstance("com.sun.star.frame.Desktop"); - // XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface); - // XFrame xFrame = xDesktop.getCurrentFrame(); - - final XWindowPeer aWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, getFrame().getComponentWindow()); + final XWindowPeer aWindowPeer = UnoRuntime.queryInterface( XWindowPeer.class, getFrame().getComponentWindow() ); return aWindowPeer; } private XFrame m_xFrame = null; @@ -137,17 +123,12 @@ public class ReportBuilderImplementation extends ReportImplementationHelper */ private IReportBuilderLayouter getReportBuilderLayouter() { - // if (m_aReportBuilderLayouter == null) - // { - // m_aReportBuilderLayouter = ReportBuilderLayouter.create(getRecordParser().getReportDocuments(), getConnection()); - // m_aReportBuilderLayouter = ReportBuilderLayouter.create(m_xReportDefinition /* , getConnection() */ ); final IReportBuilderLayouter aReportBuilderLayouter = (IReportBuilderLayouter) getLayoutMap().get(m_sReportBuilderLayoutName); return aReportBuilderLayouter; - // } } private Object m_aReportDocument; - private XPropertySet m_aDocumentDefinition; - private XReportDefinition m_xReportDefinition; + private XPropertySet m_documentDefinition; + private XReportDefinition m_reportDocument; /** * initialize the Report Builder and open it representation @@ -160,75 +141,36 @@ public class ReportBuilderImplementation extends ReportImplementationHelper // TODO: type down how we got such ID final String sClassID = "d7896d52-b7af-4820-9dfe-d404d015960f"; // CLASSID for Report Builder - Object args[] = new Object[2]; - - final PropertyValue aClassID = new PropertyValue(); - aClassID.Name = "ClassID"; - aClassID.Value = sClassID; - args[0] = aClassID; - - PropertyValue aConnection = new PropertyValue(); - aConnection.Name = "ActiveConnection"; - aConnection.Value = _xConnection; - args[1] = aConnection; - - - XReportDefinition xReportDefinition = null; - final XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, /* getRecordParser().getReportDocuments() */ _aDoc); try { - final Object aObj = xMSF.createInstanceWithArguments("com.sun.star.sdb.DocumentDefinition", args); - final XPropertySet aDocumentDefinition = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, aObj); - m_aDocumentDefinition = aDocumentDefinition; + NamedValueCollection creationArgs = new NamedValueCollection(); + creationArgs.put( "ActiveConnection", _xConnection ); + creationArgs.put( "ClassID", sClassID ); + creationArgs.put( "Mode", "remote" ); - final XCommandProcessor xProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, aObj); - final com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); - aCommand.Name = "openDesign"; - final com.sun.star.ucb.OpenCommandArgument2 aOpenCommand = new com.sun.star.ucb.OpenCommandArgument2(); - aOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT; + XComponent[] docDefinition = new XComponent[] { null }; + XComponent reportDefinitionComp = m_documentUI.createComponentWithArguments( + DatabaseObject.REPORT, creationArgs.getPropertyValues(), docDefinition ); - PropertyValue args2[] = new PropertyValue[2]; - - PropertyValue aPropOpenCommand = new PropertyValue(); - aPropOpenCommand.Name = ""; - aPropOpenCommand.Value = aOpenCommand; - args2[0] = aPropOpenCommand; - - PropertyValue aAddField = new PropertyValue(); - aAddField.Name = "Mode"; - aAddField.Value = "remote"; - args2[1] = aAddField; - - aCommand.Argument = args2; - // com.sun.star.usb.XCommandEnvironment xEnv = new com.sun.star.ucb.XCommandEnvironment(); - final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); - xReportDefinition = (XReportDefinition) UnoRuntime.queryInterface(XReportDefinition.class, aObj2); + m_documentDefinition = UnoRuntime.queryInterface( XPropertySet.class, docDefinition[0] ); + m_reportDocument = UnoRuntime.queryInterface( XReportDefinition.class, reportDefinitionComp ); } catch (com.sun.star.uno.Exception e) { ReportWizard.getLogger().log(com.sun.star.logging.LogLevel.SEVERE, "Problems with initialize the ReportDefinition" + e.getMessage()); } - m_xReportDefinition = xReportDefinition; switchOffPropertyBrowser(); switchOffAddFieldWindow(); setPageOrientation(m_nDefaultPageOrientation, false /* NO_LAYOUT*/); - // try - // { - // Thread.sleep(1000); - // } - // catch (java.lang.InterruptedException e) - // { - // } - } private XModeSelector getModeSelector() { final XController xController = getReportDefinition().getCurrentController(); - final XModeSelector xModeSelector = (XModeSelector) UnoRuntime.queryInterface(XModeSelector.class, xController); + final XModeSelector xModeSelector = UnoRuntime.queryInterface( XModeSelector.class, xController ); return xModeSelector; } @@ -273,11 +215,11 @@ public class ReportBuilderImplementation extends ReportImplementationHelper try { final XController xController = getReportDefinition().getCurrentController(); - final XDispatchProvider xDP = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xController); + final XDispatchProvider xDP = UnoRuntime.queryInterface( XDispatchProvider.class, xController ); // Create special service for parsing of given URL. final Object aURLTransformer = getMSF().createInstance("com.sun.star.util.URLTransformer"); - final XURLTransformer xURLTransformer = (XURLTransformer) UnoRuntime.queryInterface(com.sun.star.util.XURLTransformer.class, aURLTransformer); + final XURLTransformer xURLTransformer = UnoRuntime.queryInterface( com.sun.star.util.XURLTransformer.class, aURLTransformer ); com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1]; aURL[0] = new com.sun.star.util.URL(); @@ -309,41 +251,27 @@ public class ReportBuilderImplementation extends ReportImplementationHelper if (m_xFrame == null) { initialize(getRecordParser().getReportDocuments(), getConnection()); - // m_xFrame = getFrame(); m_xFrame = getReportDefinition().getCurrentController().getFrame(); setPageOrientation(m_nDefaultPageOrientation, true /* NO_LAYOUT*/); } return m_xFrame; } -// public XMultiServiceFactory getDocumentServiceFactory() -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } - -// public void addTextSectionCopies() -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties) { - throw new UnsupportedOperationException("Not supported yet."); + return false; } public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF) { - // throw new UnsupportedOperationException("Not supported yet."); } public void StopProcess() { - throw new UnsupportedOperationException("Not supported yet."); } public void store(String Name, int OpenMode) { - // throw new UnsupportedOperationException("Not supported yet."); - // getReportBuilderLayouter().store(Name); // store into the ZIP Storage if (OpenMode == 1 /* static Report */) { @@ -353,34 +281,25 @@ public class ReportBuilderImplementation extends ReportImplementationHelper try { - final XNameAccess aNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, m_aReportDocument); - final String[] aNames = aNameAccess.getElementNames(); - -// m_xReportDefinition.storeToStorage(m_xReportDefinition.getDocumentStorage(), m_xReportDefinition.getArgs()); - - final XCommandProcessor xProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, m_aDocumentDefinition); + final XCommandProcessor xProcessor = UnoRuntime.queryInterface( XCommandProcessor.class, m_documentDefinition ); com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); - aCommand.Name = "storeOwn"; + aCommand.Name = "store"; - final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); + xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); - final XNameContainer aNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, m_aReportDocument); -// aNameContainer.insertByName(Name, m_xReportDefinition); - aNameContainer.insertByName(Name, m_aDocumentDefinition); + final XNameContainer aNameContainer = UnoRuntime.queryInterface( XNameContainer.class, m_aReportDocument ); + aNameContainer.insertByName(Name, m_documentDefinition); } catch (Exception e) { - int dummy = 0; } } public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount) { - // throw new UnsupportedOperationException("Not supported yet."); final int GroupCount = GroupFieldVector.size(); if (GroupCount < MAXIMUM_GROUPCOUNT) { - // removeGroupNamesofRecordTable(iSelCount); final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); GroupFieldVector.addElement(CurFieldColumn.getFieldName()); } @@ -389,16 +308,10 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void refreshGroupFields(String[] _sNewNames) { - // throw new UnsupportedOperationException("Not supported yet."); } -// public boolean isGroupField(String _FieldName) -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector) { - // throw new UnsupportedOperationException("Not supported yet."); final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle); GroupFieldVector.removeElement(CurFieldColumn.getFieldName()); } @@ -414,15 +327,12 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void setPageOrientation(int nOrientation) { - // throw new UnsupportedOperationException("Not supported yet."); setPageOrientation(nOrientation, true); } public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) { - // throw new UnsupportedOperationException("Not supported yet."); /* Right Listbox */ - final IReportBuilderLayouter aLayouter = getReportBuilderLayouter(); aLayouter.loadAndSetBackgroundTemplate(LayoutTemplatePath); aLayouter.layout(); @@ -448,147 +358,131 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void liveupdate_changeContentTemplate(String ContentTemplatePath) { - // throw new UnsupportedOperationException("Not supported yet."); /* Left Listbox */ setReportBuilderLayouterName(ContentTemplatePath); } public void layout_setupRecordSection(String TemplateName) { - // throw new UnsupportedOperationException("Not supported yet."); } public void removeTextTableAndTextSection() { - // throw new UnsupportedOperationException("Not supported yet."); } public void layout_selectFirstPage() { - // throw new UnsupportedOperationException("Not supported yet."); } - public void dispose() + private void closeReportDefinition() { - // throw new UnsupportedOperationException("Not supported yet."); - getReportBuilderLayouter().dispose(); - try { - // XCloseable xClose = (XCloseable)UnoRuntime.queryInterface(XCloseable.class, m_xReportDefinition); - // xClose.close(true); - // Failed! - - // next idea, which should always work. - // XController xController = m_xReportDefinition.getCurrentController(); - // XDispatchProvider xDispatcher = (XDispatchProvider)UnoRuntime.queryInterface(XDispatchProvider.class, xController); - // xDispatcher.queryDispatch(); - - final XComponent xDocumentComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, m_aDocumentDefinition); - xDocumentComponent.dispose(); - m_xReportDefinition = null; - - // TODO: dispose() office will be killed. - // m_xReportDefinition.dispose(); + if ( m_documentDefinition != null ) + { + // set the document to "not modified", to ensure that it won't ask the user before closing + XModifiable documentModify = UnoRuntime.queryInterface( XModifiable.class, m_reportDocument ); + documentModify.setModified( false ); + // actually close + XSubDocument subComponent = UnoRuntime.queryInterface( XSubDocument.class, m_documentDefinition ); + subComponent.close(); + } } - catch (Exception e) + catch ( Exception ex ) { - // catch all possible exceptions - int dummy = 0; + Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } + m_documentDefinition = null; + m_reportDocument = null; + } + + public void dispose() + { + getReportBuilderLayouter().dispose(); + closeReportDefinition(); } public XComponent getComponent() { - // throw new UnsupportedOperationException("Not supported yet."); return null; } public void liveupdate_changeUserFieldContent(String fieldName, String titlename) { - // throw new UnsupportedOperationException("Not supported yet."); } public void liveupdate_updateReportTitle(String _sTitleName) { - // throw new UnsupportedOperationException("Not supported yet."); } -// public void finish() -// { -// throw new UnsupportedOperationException("Not supported yet."); -// } public void addReportToDBView() { - // throw new UnsupportedOperationException("Not supported yet."); } - private XComponent[] createFinalReportDocument(String Name, Object _aDBConnection, boolean _bAsTemplate, boolean _bOpenInDesign) + private XComponent loadReport( final String i_reportName ) { - XComponent[] xComponents = new XComponent[1]; try { - PropertyValue[] aProperties = new PropertyValue[2]; - aProperties[0] = new PropertyValue(); - aProperties[0].Name = "ActiveConnection"; - // aProperties[0].Value = m_aDocumentDefinition; - aProperties[0].Value = _aDBConnection; - - final com.sun.star.ucb.OpenCommandArgument2 aOpenCommand = new com.sun.star.ucb.OpenCommandArgument2(); - aOpenCommand.Mode = com.sun.star.ucb.OpenMode.DOCUMENT; - - aProperties[1] = new PropertyValue(); - aProperties[1].Name = "OpenCommand"; // This name is 'Schall und Rauch' -// // since Java 6 -// // aProperties[1].Value = Integer.valueOf(com.sun.star.ucb.OpenMode.DOCUMENT); - aProperties[1].Value = aOpenCommand; - -// aProperties[2] = new PropertyValue(); -// aProperties[2].Name = "Title"; // This name is 'Schall und Rauch' -// aProperties[2].Value = Name; - - final XCommandProcessor xProcessor = (XCommandProcessor) UnoRuntime.queryInterface(XCommandProcessor.class, m_aDocumentDefinition); - com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); - aCommand.Name = "open"; - aCommand.Argument = aProperties; - - final Object aObj2 = xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null); - xComponents[0] = (XComponent) UnoRuntime.queryInterface(XComponent.class, aObj2); + return m_documentUI.loadComponent( DatabaseObject.REPORT, i_reportName, false ); } - catch (com.sun.star.uno.Exception e) + catch ( Exception ex ) { - int dummy = 0; + Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } - return xComponents; + return null; } - public XComponent[] createFinalReportDocument(String Name, boolean _bAsTemplate, boolean _bOpenInDesign) + private XComponent loadReportFromDocumentDefinition() { - // XComponent[] xComponents = getReportBuilderLayouter().createFinalReportDocument(Name, getRecordParser().DBConnection ,_bAsTemplate, _bOpenInDesign); - if (_bAsTemplate == true && _bOpenInDesign == false) + final XCommandProcessor commandProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition); + + com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command(); + aCommand.Name = "open"; + try { - final XComponent[] xComponents = createFinalReportDocument(Name, getRecordParser().DBConnection, _bAsTemplate, _bOpenInDesign); - dispose(); - return xComponents; + final Object result = commandProcessor.execute( aCommand, commandProcessor.createCommandIdentifier(), null ); + return UnoRuntime.queryInterface( XComponent.class, result ); } - else if (_bAsTemplate == false) + catch ( Exception ex ) { - final XComponent[] xComponents = createFinalReportDocument(Name, getRecordParser().DBConnection, _bAsTemplate, _bOpenInDesign); - boolean bDocisStored = getRecordParser().storeDatabaseDocumentToTempPath(xComponents[0], Name); - if (bDocisStored) - { - getRecordParser().addReportDocument(xComponents[0], false); - } - dispose(); + Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } - else + return null; + } + + public void createAndOpenReportDocument( String i_name, boolean i_asTemplate, boolean i_openForEditing ) + { + if ( i_openForEditing ) { // we won't destroy the report builder window, also don't create a document // Do we need to reopen the report builder with the known name? switchOnAddFieldWindow(); switchOnPropertyBrowser(); + return; } - return null; + + if ( i_asTemplate ) + { + // don't need the report definition anymore - the document it represents has already been stored + closeReportDefinition(); + + // open the report, again, this time not in design, but containing data + loadReport( i_name ); + } + else + { + // execute the report from the (yet unsaved) report definition + XComponent document = loadReportFromDocumentDefinition(); + + // don't need the report definition anymore + closeReportDefinition(); + + // store the generated report + if ( getRecordParser().storeDatabaseDocumentToTempPath( document, i_name ) ) + getRecordParser().addReportDocument( document, false ); + } + + dispose(); } private XConnection getConnection() @@ -599,7 +493,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames) { getRecordParser().initializeFieldColumns(FieldNames, TableName); -// getRecordParser().createRecordFieldNames(); final com.sun.star.wizards.db.RecordParser a = getRecordParser(); int[] FieldTypes = new int[FieldNames.length]; @@ -610,7 +503,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper FieldWidths[i] = a.FieldColumns[i].getFieldWidth(); } getReportBuilderLayouter().setTableName(_nType, TableName); -// getReportBuilderLayouter().insertFields(getRecordParser().getRecordFieldNames()); getReportBuilderLayouter().insertFieldNames(FieldNames); getReportBuilderLayouter().insertFieldTypes(FieldTypes); getReportBuilderLayouter().insertFieldWidths(FieldWidths); @@ -621,7 +513,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void setFieldTitles(String[] _aFieldTitles) { getRecordParser().setFieldTitles(_aFieldTitles); -// getRecordParser().createRecordFieldNames(); getReportBuilderLayouter().insertFieldTitles(_aFieldTitles); getReportBuilderLayouter().layout(); @@ -630,18 +521,12 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void setSorting(String[][] _aSortFieldNames) { getRecordParser().setSortFieldNames(_aSortFieldNames); -// getRecordParser().createRecordFieldNames(); } public void setGrouping(String[] _aGroupFieldNames) { getRecordParser().prependSortFieldNames(_aGroupFieldNames); - // getRecordParser().createRecordFieldNames(); - - // getReportBuilderLayouter().insertFields(getRecordParser().getRecordFieldNames()); -// getReportBuilderLayouter().insertFieldTitles(getRecordParser().get); - // getReportBuilderLayouter().insertGroups(_aGroupFieldNames); getReportBuilderLayouter().insertGroupNames(_aGroupFieldNames); getReportBuilderLayouter().layout(); } @@ -656,18 +541,18 @@ public class ReportBuilderImplementation extends ReportImplementationHelper { if (m_aReportPath == null) { - // Check general availability of office paths try { - m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard"); - FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report"); + // Check general availability of office paths + m_aReportPath = FileAccess.getOfficePaths( getMSF(), "Template", "share", "/wizard" ); + FileAccess.combinePaths( getMSF(), m_aReportPath, "/wizard/report" ); } - catch (Exception e) + catch ( NoValidPathException ex ) { + Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } } return m_aReportPath; - // return ""; } public String getContentPath() @@ -699,7 +584,7 @@ public class ReportBuilderImplementation extends ReportImplementationHelper }); Object[] aParams = new Object[2]; aParams[0] = this; - aParams[1] = m_aResource; + aParams[1] = m_resource; final IReportBuilderLayouter aReportBuilderLayouter = (IReportBuilderLayouter) cTor.newInstance(aParams); return aReportBuilderLayouter; } @@ -707,34 +592,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper { e.printStackTrace(); } -// catch (NoSuchMethodException ex) -// { -// ex.printStackTrace(); -// } -// catch (SecurityException ex) -// { -// ex.printStackTrace(); -// } -// catch (InstantiationException ex) -// { -// ex.printStackTrace(); -// } -// catch (IllegalAccessException ex) -// { -// ex.printStackTrace(); -// } -// catch (IllegalArgumentException ex) -// { -// ex.printStackTrace(); -// } -// catch (InvocationTargetException ex) -// { -// ex.printStackTrace(); -// } -// catch (ClassNotFoundException e) -// { -// e.printStackTrace(); -// } return null; } private LinkedHashMap m_aLayoutMap = null; @@ -850,11 +707,11 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public XReportDefinition getReportDefinition() { - if (m_xReportDefinition == null) + if (m_reportDocument == null) { throw new NullPointerException("Report Definition is not already initialized, check if you too early access the report definition."); } - return m_xReportDefinition; + return m_reportDocument; } public XMultiServiceFactory getGlobalMSF() @@ -864,7 +721,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper public void importReportData(ReportWizard aWizard) { - // throw new UnsupportedOperationException("Not supported yet."); } public String getDefaultHeaderLayout() @@ -876,7 +732,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper { getRecordParser().Command = _sCommand; getReportDefinition().setCommand(_sCommand); - // throw new UnsupportedOperationException("Not supported yet."); } public void setCommandType(int _nCommand) @@ -893,11 +748,6 @@ public class ReportBuilderImplementation extends ReportImplementationHelper throw new java.io.IOException("default.otr"); } - final String sName = FileAccess.getFilename(sDefaultHeaderLayoutPath); - // if (sName.toLowerCase().equals("default.otr_") || - // LayoutTemplatePath.equals("DefaultLayoutOfHeaders")) - // File aFile = new File(sDefaultHeaderLayoutPath); - // File aFile = new File(sName); FileAccess aAccess = new FileAccess(getGlobalMSF()); if (! aAccess.exists(sDefaultHeaderLayoutPath, true)) { -- cgit From 5a6a877ad0cc8b0703d55302ac01bf79530664fe Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 5 Feb 2010 14:11:36 +0100 Subject: autorecovery: use a human-readable media type instead of this strange class ID --- .../sun/star/wizards/reportbuilder/ReportBuilderImplementation.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java index 9fb9ce575417..59c99b77de03 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java +++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java @@ -139,14 +139,12 @@ public class ReportBuilderImplementation extends ReportImplementationHelper private void initialize(Object _aDoc, XConnection _xConnection) { m_aReportDocument = _aDoc; - // TODO: type down how we got such ID - final String sClassID = "d7896d52-b7af-4820-9dfe-d404d015960f"; // CLASSID for Report Builder try { NamedValueCollection creationArgs = new NamedValueCollection(); creationArgs.put( "ActiveConnection", _xConnection ); - creationArgs.put( "ClassID", sClassID ); + creationArgs.put( "MediaType", "com.sun.star.report.ReportDefinition" ); creationArgs.put( "Mode", "remote" ); XComponent[] docDefinition = new XComponent[] { null }; -- cgit From 4fa9df70fc2aadfc3777878e6e8d7a6e02715cbd Mon Sep 17 00:00:00 2001 From: "Frank Schoenheit [fs]" Date: Fri, 5 Feb 2010 22:03:01 +0100 Subject: autorecovery: allow for a human-readable DocumentServiceName instead of this strange class ID when creating a document definition --- .../star/wizards/reportbuilder/ReportBuilderImplementation.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'wizards') diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java index 59c99b77de03..c1f8bee703db 100644 --- a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java +++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java @@ -136,15 +136,14 @@ public class ReportBuilderImplementation extends ReportImplementationHelper * @param _aDoc * @param _xConnection */ - private void initialize(Object _aDoc, XConnection _xConnection) + private void initialize(Object _aDoc) { m_aReportDocument = _aDoc; try { NamedValueCollection creationArgs = new NamedValueCollection(); - creationArgs.put( "ActiveConnection", _xConnection ); - creationArgs.put( "MediaType", "com.sun.star.report.ReportDefinition" ); + creationArgs.put( "DocumentServiceName", "com.sun.star.report.ReportDefinition" ); creationArgs.put( "Mode", "remote" ); XComponent[] docDefinition = new XComponent[] { null }; @@ -249,7 +248,7 @@ public class ReportBuilderImplementation extends ReportImplementationHelper { if (m_xFrame == null) { - initialize(getRecordParser().getReportDocuments(), getConnection()); + initialize(getRecordParser().getReportDocuments()); m_xFrame = getReportDefinition().getCurrentController().getFrame(); setPageOrientation(m_nDefaultPageOrientation, true /* NO_LAYOUT*/); } -- cgit