diff options
author | Ocke.Janssen <Ocke.Janssen@oracle.com> | 2011-01-20 13:12:51 +0100 |
---|---|---|
committer | Ocke.Janssen <Ocke.Janssen@oracle.com> | 2011-01-20 13:12:51 +0100 |
commit | e0c1daa9561ff447351135f3318d1a1183077212 (patch) | |
tree | 266e63f408dd7593ba113c2a857b8cdeaa49dfc0 /wizards/com/sun/star/wizards/report | |
parent | a5fa6f4652b4a723f935c611a68b039ed3f7f46c (diff) |
dba34d: #i98163# import hidden value correted
Diffstat (limited to 'wizards/com/sun/star/wizards/report')
5 files changed, 105 insertions, 58 deletions
diff --git a/wizards/com/sun/star/wizards/report/CallReportWizard.java b/wizards/com/sun/star/wizards/report/CallReportWizard.java index c66596e11c02..fc0a60447cd3 100644 --- a/wizards/com/sun/star/wizards/report/CallReportWizard.java +++ b/wizards/com/sun/star/wizards/report/CallReportWizard.java @@ -28,11 +28,12 @@ package com.sun.star.wizards.report; import com.sun.star.beans.PropertyValue; 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.sdb.application.XDatabaseDocumentUI; import com.sun.star.wizards.common.NamedValueCollection; +import java.util.logging.Level; +import java.util.logging.Logger; /** This class capsulates the class, that implements the minimal component, a * factory for creating the service (<CODE>__getServiceFactory</CODE>). @@ -138,9 +139,9 @@ public class CallReportWizard } } } - catch (Exception exception) + catch (Exception e) { - System.err.println(exception); + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); } System.gc(); } @@ -212,11 +213,11 @@ public class CallReportWizard try { - byteReturn = new String("" + this.hashCode()).getBytes(); + byteReturn = ("" + this.hashCode()).getBytes(); } - catch (Exception exception) + catch (Exception e) { - System.err.println(exception); + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); } return (byteReturn); @@ -251,9 +252,9 @@ public class CallReportWizard new Type(com.sun.star.lang.XInitialization.class) }; } - catch (Exception exception) + catch (Exception e) { - System.err.println(exception); + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); } return (typeReturn); diff --git a/wizards/com/sun/star/wizards/report/Dataimport.java b/wizards/com/sun/star/wizards/report/Dataimport.java index 00b58fb5e008..6ae33413605d 100644 --- a/wizards/com/sun/star/wizards/report/Dataimport.java +++ b/wizards/com/sun/star/wizards/report/Dataimport.java @@ -34,6 +34,8 @@ import com.sun.star.text.XTextDocument; import com.sun.star.wizards.ui.*; import com.sun.star.wizards.common.*; import com.sun.star.uno.Exception; +import java.util.logging.Level; +import java.util.logging.Logger; public class Dataimport extends UnoDialog2 implements com.sun.star.awt.XActionListener { // extends ReportWizard @@ -186,14 +188,14 @@ public class Dataimport extends UnoDialog2 implements com.sun.star.awt.XActionLi super.xReschedule.reschedule(); return; } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); // return; } - catch (java.lang.Exception jexception) + catch (java.lang.Exception e) { - jexception.printStackTrace(System.out); + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); // return; } } diff --git a/wizards/com/sun/star/wizards/report/ReportTextDocument.java b/wizards/com/sun/star/wizards/report/ReportTextDocument.java index 3ab9e704b9b9..cec7f0cbed1d 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextDocument.java +++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java @@ -53,9 +53,17 @@ import com.sun.star.wizards.text.TextStyleHandler; import com.sun.star.wizards.text.TextFieldHandler; import com.sun.star.wizards.text.ViewHandler; import com.sun.star.wizards.document.FormHandler; +import java.util.logging.Level; +import java.util.logging.Logger; class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implements Comparator { + + private static final String COMMAND = "Command"; + private static final String ISLANDSCAPE = "IsLandscape"; + private static final String ISVISIBLE = "IsVisible"; + private static final String QUERYNAME = "QueryName"; + private static final String SIZE = "Size"; // private XMultiServiceFactory xMSF; // private XMultiServiceFactory xMSFDoc; private Object ReportPageStyle; @@ -102,7 +110,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen lateInit(oResource, _aRP); } - void lateInit(Resource oResource, RecordParser _aRecordParser) + private void lateInit(Resource oResource, RecordParser _aRecordParser) { oTextTableHandler = new TextTableHandler(xMSFDoc, xTextDocument); oTextSectionHandler = new TextSectionHandler(xMSFDoc, xTextDocument); @@ -146,12 +154,12 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { oTextSection = xTextSections.getByName(RECORDSECTION); } - boolean bLayoutMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(oTextSection, "IsVisible")); + boolean bLayoutMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(oTextSection, ISVISIBLE)); return bLayoutMode; } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); // In doubt we rather suggest this is LayoutMode... return true; } @@ -172,7 +180,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen } // xProgressBar.setValue(100); oViewHandler.selectFirstPage(oTextTableHandler); - // xProgressBar.end(); + // xProgressBar.end(); } public void swapLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) @@ -181,17 +189,17 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { // xProgressBar.start("", 10); this.LayoutTemplatePath = LayoutTemplatePath; - boolean bOldIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, "IsLandscape")); + boolean bOldIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, ISLANDSCAPE)); oTextStyleHandler.loadStyleTemplates(LayoutTemplatePath, "LoadPageStyles"); // xProgressBar.setValue(60); changePageOrientation(bOldIsCurLandscape); // xProgressBar.setValue(100); oViewHandler.selectFirstPage(oTextTableHandler); - // xProgressBar.end(); + // xProgressBar.end(); } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); } } @@ -199,21 +207,41 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME); XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xNamedForm); - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "CommandType", new String(Integer.toString(CurDBMetaData.getCommandType()))); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "CommandType", Integer.toString(CurDBMetaData.getCommandType())); if (CurDBMetaData.getCommandType() == CommandType.QUERY) { - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "QueryName", CurDBMetaData.getCommandName()); - // oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", ""); - DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName()); - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", CurDBMetaData.Command); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName()); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", ""); + //DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName()); + //oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command); } else { - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "QueryName", ""); - oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", CurDBMetaData.Command); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, ""); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command); } oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "GroupFieldNames", JavaTools.ArraytoString(CurDBMetaData.GroupFieldNames)); oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "FieldNames", JavaTools.ArraytoString(CurDBMetaData.getFieldNames())); + String[][] sortFieldNames = CurDBMetaData.getSortFieldNames(); + if (sortFieldNames != null && sortFieldNames.length > 0) + { + final String space = ","; + final String colon = ";"; + StringBuilder orderBy = new StringBuilder(); + for (String[] sortPair : sortFieldNames) + { + orderBy.append(sortPair[0]).append(space).append(sortPair[1]).append(colon); + } + if (orderBy.length() != 0) + { + orderBy.delete(orderBy.lastIndexOf(colon), orderBy.length()); + } + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Sorting", orderBy.toString()); + } + else + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Sorting", ""); + } oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "RecordFieldNames", JavaTools.ArraytoString(CurDBMetaData.getRecordFieldNames())); } @@ -230,9 +258,9 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen ReportPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "Standard"); FirstPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "First Page"); } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); } } @@ -242,15 +270,15 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { com.sun.star.awt.Size oNewSize; getReportPageStyles(); - com.sun.star.awt.Size oLocSize = (com.sun.star.awt.Size) Helper.getUnoStructValue(ReportPageStyle, "Size"); - bIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, "IsLandscape")); + com.sun.star.awt.Size oLocSize = (com.sun.star.awt.Size) Helper.getUnoStructValue(ReportPageStyle, SIZE); + bIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, ISLANDSCAPE)); if (bIsCurLandscape != bNewLandscape) { oNewSize = new com.sun.star.awt.Size(oLocSize.Height, oLocSize.Width); - Helper.setUnoPropertyValue(ReportPageStyle, "IsLandscape", new Boolean(bNewLandscape)); - Helper.setUnoPropertyValue(ReportPageStyle, "Size", oNewSize); - Helper.setUnoPropertyValue(FirstPageStyle, "IsLandscape", new Boolean(bNewLandscape)); - Helper.setUnoPropertyValue(FirstPageStyle, "Size", oNewSize); + Helper.setUnoPropertyValue(ReportPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(ReportPageStyle, SIZE, oNewSize); + Helper.setUnoPropertyValue(FirstPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(FirstPageStyle, SIZE, oNewSize); int iLeftMargin = AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "LeftMargin")); int iRightMargin = AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "RightMargin")); PageWidth = oNewSize.Width - iLeftMargin - iRightMargin; @@ -260,9 +288,9 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen } } } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); } } @@ -303,9 +331,9 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen } return true; } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); return false; } } @@ -352,6 +380,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen // { // return (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, _FieldName) != -1); // } + public void replaceFieldValueInRecordSection(int RecordCount) { int GroupCount = CurDBMetaData.GroupFieldNames.length; @@ -367,7 +396,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen String TableName; DBColumn OldDBColumn; DBColumn CurDBColumn; - XNameAccess xTableNames = oTextTableHandler.xTextTablesSupplier.getTextTables(); + // XNameAccess xTableNames = oTextTableHandler.xTextTablesSupplier.getTextTables(); int GroupFieldCount = SelGroupNames.length; for (int i = 0; i < GroupFieldCount; i++) { @@ -639,7 +668,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { try { - Vector aFieldColumns = new Vector(); + ArrayList<FieldColumn> aFieldColumns = new ArrayList<FieldColumn>(); for (int i = 0; i < _FieldColumns.length; i++) { FieldColumn CurFieldColumn = _FieldColumns[i]; @@ -654,7 +683,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen } catch (RuntimeException e) { - e.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); return null; } } @@ -728,7 +757,7 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen { // xRelativeTextContentRemove.removeTextContentBefore(xTextContent); xRelativeTextContentRemove.removeTextContentAfter(xTextContent); - // IllegalArgumentException may be thrown when no paragraphbreak is there + // IllegalArgumentException may be thrown when no paragraphbreak is there } catch (IllegalArgumentException iexception) { @@ -751,17 +780,17 @@ class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implemen for (int i = 0; i < GroupFieldCount; i++) { oTextSection = xTextSections.getByName(GROUPSECTION + String.valueOf(i + 1)); - Helper.setUnoPropertyValue(oTextSection, "IsVisible", new Boolean(_IsVisible)); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); } if (xTextSections.hasByName(RECORDSECTION)) { oTextSection = xTextSections.getByName(RECORDSECTION); - Helper.setUnoPropertyValue(oTextSection, "IsVisible", new Boolean(_IsVisible)); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); } } - catch (Exception exception) + catch (Exception e) { - exception.printStackTrace(System.out); + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); } } diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java index ceecaf28ba4f..535139b8f985 100644 --- a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -202,9 +202,9 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme } } } - catch (Exception exception) + catch (Exception ex) { - exception.printStackTrace(System.out); + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } return xNamedTextSection; } @@ -237,6 +237,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "CommandType", sMsg); String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames", sMsg); String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames", sMsg); + final String sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting", sMsg); String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames", sMsg); if (xNamedForm.hasByName("QueryName")) { @@ -244,16 +245,28 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme } String[] sFieldNameList = JavaTools.ArrayoutofString(sFieldNames, ";"); String[] sNewList = JavaTools.ArrayoutofString(sRecordFieldNames, ";"); + if ( !"".equals(sorting)) + { + String[] sortList = JavaTools.ArrayoutofString(sorting, ";"); + ArrayList<String[]> aSortFields = new ArrayList<String[]>(); + for (String sortEntry : sortList) + { + aSortFields.add(JavaTools.ArrayoutofString(sortEntry, ",")); + } + String[][] sortFieldNames = new String[aSortFields.size()][2]; + aSortFields.toArray(sortFieldNames); + getRecordParser().setSortFieldNames(sortFieldNames); + } getRecordParser().setRecordFieldNames(sNewList); getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, ";"); getRecordParser().setCommandType(Integer.valueOf(sCommandType).intValue()); + sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>"); bgetConnection = getRecordParser().getConnection(_properties); int nCommandType = com.sun.star.sdb.CommandType.COMMAND; boolean bexecute = false; if (bgetConnection) { - if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals(""))) { DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); @@ -262,6 +275,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue("Command"); getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); getRecordParser().getSQLQueryComposer().prependSortingCriteria(); + getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); } else { @@ -293,13 +307,14 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme { return false; } - catch (java.lang.Exception javaexception) + catch (java.lang.Exception ex) { - javaexception.printStackTrace(System.out); + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); return false; } - catch (com.sun.star.wizards.document.FormHandler.UnknownHiddenControlException exception) + catch (com.sun.star.wizards.document.FormHandler.UnknownHiddenControlException ex) { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); return false; } } @@ -322,8 +337,6 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme Object CurGroupValue; String CurGroupTableName; // RecordParser CurDBMetaData = getRecordParser(); - com.sun.star.style.BreakType CorrBreakValue = null; - String CorrPageDescName = ""; getDoc().oTextFieldHandler.fixDateFields(true); getDoc().removeAllVisibleTextSections(); getDoc().removeNonLayoutTextTables(); @@ -403,8 +416,9 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme } getDoc().oTextSectionHandler.breakLinkofTextSections(); } - catch (Exception exception) + catch (Exception ex) { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); } // catch (java.lang.Exception javaexception) // { @@ -629,6 +643,7 @@ public class ReportTextImplementation extends ReportImplementationHelper impleme } catch (Exception e) { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, e ); } } return m_aReportPath; diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java index 0c9eef8f430d..0ec981b54218 100644 --- a/wizards/com/sun/star/wizards/report/ReportWizard.java +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -457,7 +457,7 @@ public class ReportWizard extends DatabaseObjectWizard implements XTextListener, // 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) + if (sLocation.length() == 0) { try { |