diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:06:44 +0000 |
commit | ed5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch) | |
tree | 7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /wizards/com/sun/star/wizards/report | |
parent | Initial commit. (diff) | |
download | libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip |
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wizards/com/sun/star/wizards/report')
16 files changed, 4404 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/report/CallReportWizard.java b/wizards/com/sun/star/wizards/report/CallReportWizard.java new file mode 100644 index 000000000..08ca4bf89 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/CallReportWizard.java @@ -0,0 +1,205 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyValue; +import com.sun.star.uno.Type; +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 com.sun.star.wizards.common.PropertyNames; +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>). + */ +public class CallReportWizard +{ + + private static boolean bWizardstartedalready; + + /** Gives a factory for creating the service. + * This method is called by the <code>JavaLoader</code> + * <p> + * @return Returns a <code>XSingleServiceFactory</code> for creating the component. + * @see com.sun.star.comp.loader.JavaLoader + * @param stringImplementationName The implementation name of the component. + * @param xMSF The service manager, who gives access to every known service. + * @param xregistrykey Makes structural information (except regarding treestructures) of a single + * registry key accessible. + */ + public static com.sun.star.lang.XSingleServiceFactory __getServiceFactory(String stringImplementationName, com.sun.star.lang.XMultiServiceFactory xMSF, com.sun.star.registry.XRegistryKey xregistrykey) + { + com.sun.star.lang.XSingleServiceFactory xsingleservicefactory = null; + if (stringImplementationName.equals( + ReportWizardImplementation.class.getName())) + { + xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory( + ReportWizardImplementation.class, + ReportWizardImplementation.__serviceName, + xMSF, + xregistrykey); + } + return xsingleservicefactory; + } + + /** This class implements the component. At least the interfaces XServiceInfo, + * XTypeProvider, and XInitialization should be provided by the service. + */ + 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.task.XJobExecutor + { + + private PropertyValue[] m_wizardContext; + + /** The constructor of the inner class has a XMultiServiceFactory parameter. + * @param xmultiservicefactoryInitialization A special service factory + * could be introduced while initializing. + */ + public ReportWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization) + { + super(); + xmultiservicefactory = xmultiservicefactoryInitialization; + } + + public void trigger(String sEvent) + { + try + { + if (sEvent.equals(PropertyNames.START)) + { + if (!bWizardstartedalready) + { + ReportWizard CurReportWizard = new ReportWizard( xmultiservicefactory, m_wizardContext ); + CurReportWizard.startReportWizard(); + } + bWizardstartedalready = false; + } + else if (sEvent.equals("fill")) + { + Dataimport CurDataimport = new Dataimport(xmultiservicefactory); + if (m_wizardContext != 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, documentUI, textDocument, m_wizardContext); + } + } + } + } + catch (Exception e) + { + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); + } + System.gc(); + } + /** The service name, that must be used to get an instance of this service. + */ + private static final String __serviceName = "com.sun.star.wizards.report.CallReportWizard"; + /** The service manager, that gives access to all registered services. + */ + private final com.sun.star.lang.XMultiServiceFactory xmultiservicefactory; + + /** This method is a member of the interface for initializing an object + * directly after its creation. + * @param object This array of arbitrary objects will be passed to the + * component after its creation. + * @throws com.sun.star.uno.Exception Every exception will not be handled, but will be + * passed to the caller. + */ + public void initialize(Object[] object) throws com.sun.star.uno.Exception + { + this.m_wizardContext = Properties.convertToPropertyValueArray(object); + + } + + /** This method returns an array of all supported service names. + * @return Array of supported service names. + */ + public java.lang.String[] getSupportedServiceNames() + { + String[] stringSupportedServiceNames = new String[] { __serviceName }; + + return stringSupportedServiceNames; + } + + /** This method returns true, if the given service will be + * supported by the component. + * @param stringService Service name. + * @return True, if the given service name will be supported. + */ + public boolean supportsService(String stringService) + { + boolean booleanSupportsService = false; + + if (stringService.equals(__serviceName)) + { + booleanSupportsService = true; + } + return booleanSupportsService; + } + + @Override + public byte[] getImplementationId() + { + return new byte[0]; + } + + /** Return the class name of the component. + * @return Class name of the component. + */ + public java.lang.String getImplementationName() + { + return ReportWizardImplementation.class.getName(); + } + + /** Provides a sequence of all types (usually interface types) + * provided by the object. + * @return Sequence of all types (usually interface types) provided by the + * service. + */ + @Override + public Type[] getTypes() + { + Type[] typeReturn = + { + }; + + try + { + typeReturn = new Type[] + { + new Type(com.sun.star.task.XJobExecutor.class), + new Type(com.sun.star.lang.XTypeProvider.class), + new Type(com.sun.star.lang.XServiceInfo.class), + new Type(com.sun.star.lang.XInitialization.class) + }; + } + catch (Exception e) + { + Logger.getLogger(CallReportWizard.class.getName()).log(Level.SEVERE, null, e); + } + + return typeReturn; + } + } +} diff --git a/wizards/com/sun/star/wizards/report/DBColumn.java b/wizards/com/sun/star/wizards/report/DBColumn.java new file mode 100644 index 000000000..5ca1f56a8 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/DBColumn.java @@ -0,0 +1,451 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.beans.PropertyState; +import com.sun.star.beans.XPropertySet; +import com.sun.star.beans.XPropertyState; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.style.ParagraphAdjust; +import com.sun.star.table.XCell; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XTableColumns; +import com.sun.star.table.XTableRows; +import com.sun.star.text.XDependentTextField; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.db.*; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.text.TextDocument; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.TextFieldHandler; + +public class DBColumn +{ + + private XCell xValCell; + private XTextRange xValTextCell; + private XTextCursor xValCellCursor; + public XCell xNameCell; + private XTextRange xNameTextCell; + private boolean bAlignLeft; + private String CharFontName; + private PropertyState PropertyState; + public int ValColumn = 1; + private int ValRow = 0; + public FieldColumn CurDBField; + private XTextTable xTextTable; + private XTableColumns xTableColumns; + private XCellRange xCellRange; + public XNamed xTableName; + private boolean bIsGroupColumn; + private RecordParser CurDBMetaData; + private RecordTable CurRecordTable; + private TextTableHandler oTextTableHandler; + + public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bforce) + { + initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, _bforce); + } + + public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i) + { + initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, false); + } + + private void initializeRecordTableMembers(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bForce) + { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + this.CurRecordTable = _CurRecordTable; + bIsGroupColumn = false; + if (CurDBMetaData.RecordFieldColumns != null) + { + CurDBField = CurDBMetaData.getFieldColumnByFieldName(CurDBMetaData.RecordFieldColumns[i].getFieldName()); + } + else + { + CurDBField = CurDBMetaData.getFieldColumnByFieldName(CurDBMetaData.getRecordFieldName(i)); + } + if (_bForce) + { + assignCells(i, true); + } + else + { + for (int n = 0; n < CurRecordTable.xTableColumns.getCount(); n++) + { + assignCells(n, false); + } + } + } + + private boolean assignCells(int _nColumn, boolean _bforce) + { + try + { + XCell xCell = CurRecordTable.xCellRange.getCellByPosition(_nColumn, 0); + XTextRange xTextCell = UnoRuntime.queryInterface(XTextRange.class, xCell); + String CompString = "Column"; + XTextCursor xLocCellCursor = TextDocument.createTextCursor(xCell); + if (isNameCell(xLocCellCursor, CurDBField.getFieldName(), CompString) || (_bforce)) + { + xNameCell = xCell; + xNameTextCell = xTextCell; + xValCell = CurRecordTable.xCellRange.getCellByPosition(_nColumn, 1); + xValTextCell = UnoRuntime.queryInterface(XTextRange.class, xValCell); + xValCellCursor = TextDocument.createTextCursor(xValCell); + ValColumn = _nColumn; + return true; + } + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + return false; + } + + public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, String _FieldName, String TableName, DBColumn OldDBColumn) { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + CurDBField = CurDBMetaData.getFieldColumnByDisplayName(_FieldName); + bIsGroupColumn = true; + getTableColumns(TableName); + xNameCell = OldDBColumn.xNameCell; + xNameTextCell = OldDBColumn.xNameTextCell; + xValCell = OldDBColumn.xValCell; + xValTextCell = OldDBColumn.xValTextCell; + xValCellCursor = TextDocument.createTextCursor(xValCell); + ValColumn = OldDBColumn.ValColumn; + ValRow = OldDBColumn.ValRow; + initializeNumberFormat(); + } + + public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, String _FieldName, String TableName) throws Exception + { + this.oTextTableHandler = _oTextTableHandler; + this.CurDBMetaData = _CurDBMetaData; + CurDBField = CurDBMetaData.getFieldColumnByFieldName(_FieldName); + bIsGroupColumn = true; + XTextRange xTextCell; + XCell xCell; + getTableColumns(TableName); + + XTableRows xRows = null; + try + { + xRows = xTextTable.getRows(); + } + catch (java.lang.NullPointerException e) + { + e.printStackTrace(); +// TODO: handle the nullpointer right +// return; + } + for (int n = 0; n < xTableColumns.getCount(); n++) + { + for (int m = 0; m < xRows.getCount(); m++) + { + xCell = xCellRange.getCellByPosition(n, m); + xTextCell = UnoRuntime.queryInterface(XTextRange.class, xCell); + String CompString = TableName.substring(4); + XTextCursor xLocCellCursor = TextDocument.createTextCursor(xCell); + if (isNameCell(xLocCellCursor, CurDBField.getFieldName(), CompString)) + { + xNameCell = xCell; + xNameTextCell = xTextCell; + } + else + { //In Grouping Sections only two cells are allowed ' if (CellString.equals(CurFieldString)){ + xValCell = xCell; + xValTextCell = xTextCell; + xValCellCursor = xLocCellCursor; + ValColumn = n; + ValRow = m; + checkforLeftAlignment(); + } + } + } + } + + private void getTableColumns(String TableName) + { + try + { + XNameAccess xAllTextTables = oTextTableHandler.xTextTablesSupplier.getTextTables(); + if (xAllTextTables.hasByName(TableName)) + { + Object oTextTable = xAllTextTables.getByName(TableName); + xCellRange = UnoRuntime.queryInterface(XCellRange.class, oTextTable); + xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTextTable); + xTableName = UnoRuntime.queryInterface(XNamed.class, oTextTable); + xTableColumns = xTextTable.getColumns(); + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void initializeNumberFormat() + { + if (CurDBField.isBoolean()) + { + NumberFormatter oNumberFormatter = oTextTableHandler.getNumberFormatter(); + int iLogicalFormatKey = oNumberFormatter.setBooleanReportDisplayNumberFormat(); + oNumberFormatter.setNumberFormat(xValCell, iLogicalFormatKey, oNumberFormatter); + } + else + { + oTextTableHandler.getNumberFormatter().setNumberFormat(xValCell, CurDBField.getDBFormatKey(), CurDBMetaData.getNumberFormatter()); + } + setCellFont(); + } + + public void insertColumnData(TextFieldHandler oTextFieldHandler, boolean _bIsLandscape) + { + insertUserFieldToTableCell(oTextFieldHandler); + replaceValueCellofTable(_bIsLandscape); + } + + private void insertUserFieldToTableCell(TextFieldHandler oTextFieldHandler) + { + XTextCursor xTextCursor = TextDocument.createTextCursor(xNameCell); + xTextCursor.gotoStart(false); + xTextCursor.gotoEnd(true); + xTextCursor.setString(PropertyNames.EMPTY_STRING); + oTextFieldHandler.insertUserField(xTextCursor, CurDBField.getFieldName(), CurDBField.getFieldTitle()); + } + + + + public void formatValueCell() + { + initializeNumberFormat(); + if (checkforLeftAlignment()) + { + bAlignLeft = true; + } + } + + private boolean checkforLeftAlignment() + { + bAlignLeft = ((CurDBField.isNumberFormat()) && (ValColumn == xTableColumns.getCount() - 1)); + return bAlignLeft; + } + + public void modifyCellContent(XCellRange xCellRange, Object CurGroupValue) + { + try + { + xValCell = xCellRange.getCellByPosition(ValColumn, ValRow); + xValTextCell = UnoRuntime.queryInterface(XTextRange.class, xValCell); + modifyCellContent(CurGroupValue); + if (bAlignLeft) + { + xValCellCursor = TextDocument.createTextCursor(xValCell); + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(com.sun.star.style.ParagraphAdjust.LEFT_value)); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void modifyCellContent(Object CurGroupValue) + { + double dblValue = 0; + try + { + if (xValCell != null) + { + if (AnyConverter.isString(CurGroupValue)) + { + String sValue = AnyConverter.toString(CurGroupValue); + xValTextCell.setString(sValue); + } + else + { + if (AnyConverter.isBoolean(CurGroupValue)) + { + dblValue = AnyConverter.toInt(CurGroupValue); + } + if (AnyConverter.isByte(CurGroupValue)) + { + dblValue = AnyConverter.toByte(CurGroupValue); + } + else if (AnyConverter.isDouble(CurGroupValue)) + { + dblValue = AnyConverter.toDouble(CurGroupValue); + } + else if (AnyConverter.isFloat(CurGroupValue)) + { + dblValue = AnyConverter.toFloat(CurGroupValue); + } + else if (AnyConverter.isInt(CurGroupValue)) + { + dblValue = AnyConverter.toInt(CurGroupValue); + } + else if (AnyConverter.isLong(CurGroupValue)) + { + dblValue = AnyConverter.toLong(CurGroupValue); + } + else if (AnyConverter.isShort(CurGroupValue)) + { + dblValue = AnyConverter.toShort(CurGroupValue); + } + xValCell.setValue(dblValue); + } + } + } + catch (IllegalArgumentException exception) + { + System.err.println(exception); + } + } + // If the parameter CurGroupValue is null the placeholders are inserted + private void replaceValueCellofTable(boolean _bIsLandscape) + { + try + { + Object CurGroupValue; + if (!bIsGroupColumn && !CurDBField.isNumberFormat()) + { + CurGroupValue = BlindtextCreator.adjustBlindTextlength(CurDBField.getFieldTitle(), CurDBField.getFieldWidth(), _bIsLandscape, bIsGroupColumn, CurDBMetaData.getRecordFieldNames()); + } + else + { + CurGroupValue = CurDBField.getDefaultValue(); + } + modifyCellContent(CurGroupValue); + if (bAlignLeft) + { + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(ParagraphAdjust.LEFT_value)); + } + + int nFieldType = CurDBField.getFieldType(); + if ((nFieldType == com.sun.star.sdbc.DataType.BIT) || + (nFieldType == com.sun.star.sdbc.DataType.BOOLEAN)) + { + CharFontName = "StarSymbol"; + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + if (!bIsGroupColumn) + { + Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", Integer.valueOf(ParagraphAdjust.CENTER_value)); + } + } + else + { + if (PropertyState == com.sun.star.beans.PropertyState.DEFAULT_VALUE) + { + XPropertyState xPropState = UnoRuntime.queryInterface(XPropertyState.class, xValCellCursor); + xPropState.setPropertyToDefault("CharFontName"); + } + else + { + if (PropertyState == com.sun.star.beans.PropertyState.DIRECT_VALUE) + { + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + } + } + } + } + catch (com.sun.star.beans.UnknownPropertyException exception) + { + exception.printStackTrace(System.err); + } + } + + public void setCellFont() + { + try + { + XPropertyState xPropertyState; + int nFieldType = CurDBField.getFieldType(); + if ((nFieldType == com.sun.star.sdbc.DataType.BIT) || + (nFieldType == com.sun.star.sdbc.DataType.BOOLEAN)) + { + CharFontName = "StarSymbol"; + PropertyState = com.sun.star.beans.PropertyState.DIRECT_VALUE; + xValCellCursor.gotoStart(false); + xValCellCursor.gotoEnd(true); + Helper.setUnoPropertyValue(xValCellCursor, "CharFontName", CharFontName); + } + else + { + xPropertyState = UnoRuntime.queryInterface(XPropertyState.class, xValCellCursor); + PropertyState = xPropertyState.getPropertyState("CharFontName"); + CharFontName = AnyConverter.toString(Helper.getUnoPropertyValue(xValCellCursor, "CharFontName")); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean isNameCell(XTextCursor xCellCursor, String CurFieldName, String CompString) + { + try + { + xCellCursor.gotoStart(false); + XTextRange xTextRange = xCellCursor.getEnd(); + Object oTextField = Helper.getUnoPropertyValue(xTextRange, "TextField"); + if (AnyConverter.isVoid(oTextField)) + { + return false; + } + else + { + XDependentTextField xDependent = UnoRuntime.queryInterface(XDependentTextField.class, oTextField); + XPropertySet xMaster = xDependent.getTextFieldMaster(); + String UserFieldName = (String) xMaster.getPropertyValue(PropertyNames.PROPERTY_NAME); + boolean bIsNameCell = false; + if ((UserFieldName.startsWith(CompString)) || (UserFieldName.equals(CurFieldName))) + { + bIsNameCell = true; + } + else + { + // stupid hack, 'Title' is not a real good Table-Cell-Name + // take a look at xmloff/source/text/txtvfldi.txt, there exists 2 '_renamed_' strings + String sLocalCurFieldName = CurFieldName + "_renamed_"; + if (UserFieldName.startsWith(sLocalCurFieldName)) + { + bIsNameCell = true; + } + } + return bIsNameCell; + } + } + // Todo: Insert a resource; Exception should be thrown to the calling routine + catch (Exception exception) + { + exception.printStackTrace(System.err); + return true; //most probably this is really the Namecell!!!! + } + } +} diff --git a/wizards/com/sun/star/wizards/report/Dataimport.java b/wizards/com/sun/star/wizards/report/Dataimport.java new file mode 100644 index 000000000..8e9d3e321 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/Dataimport.java @@ -0,0 +1,169 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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.*; +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 +{ + + // ReportTextDocument CurReportDocument; + IReportDocument CurReportDocument; + + private String sProgressDBConnection; + private String sProgressDataImport; + private String sProgressTitle; + private String sStop; + + public Dataimport(XMultiServiceFactory _xMSF) + { + super(_xMSF); + super.addResourceHandler(); + sProgressDBConnection = m_oResource.getResText("RID_DB_COMMON_34"); + sProgressDataImport = m_oResource.getResText("RID_REPORT_67"); + sProgressTitle = m_oResource.getResText("RID_REPORT_62"); + m_oResource.getResText("RID_REPORT_63"); + sStop = m_oResource.getResText("RID_DB_COMMON_21"); + + } + + public void disposing(com.sun.star.lang.EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + // bStopProcess = true; + CurReportDocument.StopProcess(); + } + + private void showProgressDisplay(boolean bgetConnection) + { + try + { + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TITLE, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 84, 0, sProgressTitle, 180 + }); + com.sun.star.awt.FontDescriptor oFontDesc = new com.sun.star.awt.FontDescriptor(); + oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD; + if (bgetConnection) + { + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDBConnection", + new String[] + { + PropertyNames.FONT_DESCRIPTOR, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + oFontDesc, 10, sProgressDBConnection, 6, 6, 0, 150 + }); + + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, sProgressDataImport, 6, 24, 0, 120 + }); + } + else + { + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport", + new String[] + { + PropertyNames.FONT_DESCRIPTOR, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + oFontDesc, 10, sProgressDataImport, 6, 24, 0, 120 + }); + } + insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblCurProgress", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, PropertyNames.EMPTY_STRING, 12, 42, 0, 120 + }); + + insertButton("cmdCancel", 10000, this, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH, PropertyNames.PROPERTY_LABEL + }, + new Object[] + { + 14, HelpIds.getHelpIdString(34321), 74, 58, 0, Short.valueOf((short) 1), 40, sStop + }); + createWindowPeer(CurReportDocument.getWizardParent()); + calculateDialogPosition(CurReportDocument.getFrame().getComponentWindow().getPosSize()); + xWindow.setVisible(true); + super.xReschedule.reschedule(); + } + catch (Exception e) + { + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); + // return; + } + catch (java.lang.Exception e) + { + Logger.getLogger(Dataimport.class.getName()).log(Level.SEVERE, null, e); + // return; + } + } + + private void importReportData(final XMultiServiceFactory _xMSF, PropertyValue[] _properties) + { + if (CurReportDocument.reconnectToDatabase(_xMSF, _properties)) + { + // The following calls to remove the Sections must occur after the connection to the database + modifyFontWeight("lblProgressDBConnection", com.sun.star.awt.FontWeight.NORMAL); + modifyFontWeight("lblProgressDataImport", com.sun.star.awt.FontWeight.BOLD); + CurReportDocument.insertDatabaseDatatoReportDocument(_xMSF); + } + xComponent.dispose(); + CurReportDocument.getRecordParser().dispose(); + } + + public void createReport( XMultiServiceFactory xMSF, XDatabaseDocumentUI i_documentUI, XTextDocument _textDocument, + PropertyValue[] properties) + { + CurReportDocument = ReportTextImplementation.create( xMSF, i_documentUI, _textDocument, m_oResource ); + showProgressDisplay(true); + importReportData(xMSF, properties); + } +} diff --git a/wizards/com/sun/star/wizards/report/GroupFieldHandler.java b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java new file mode 100644 index 000000000..26543bb46 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java @@ -0,0 +1,185 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import java.util.ArrayList; + +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.CommandMetaData; +import com.sun.star.wizards.db.QueryMetaData; +import com.sun.star.wizards.ui.FieldSelection; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.WizardDialog; + +public class GroupFieldHandler extends FieldSelection +{ + + private IReportDocument CurReportDocument; + private final ArrayList<String> GroupFieldVector = new ArrayList<String>(); + private QueryMetaData CurDBMetaData; + private static final short MAXSELFIELDS = 4; + + public GroupFieldHandler(IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog) + { + super(_CurUnoDialog, ReportWizard.SOGROUPPAGE, 95, 27, 210, 127, + _CurUnoDialog.m_oResource.getResText("RID_REPORT_19"), + _CurUnoDialog.m_oResource.getResText("RID_REPORT_50"), 34340, false); + + try + { + this.CurReportDocument = _CurReportDocument; + this.CurDBMetaData = CurReportDocument.getRecordParser(); + CurUnoDialog.setControlProperty("lstFields_2", "MultiSelection", Boolean.FALSE); + CurUnoDialog.setControlProperty("lstSelFields_2", "MultiSelection", Boolean.FALSE); + addFieldSelectionListener(new FieldSelectionListener()); + String sNote = ReportWizard.getBlindTextNote(_CurReportDocument, _CurUnoDialog.m_oResource); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_1", + new String[] + { + PropertyNames.PROPERTY_ENABLED, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Boolean.FALSE, 18, sNote, Boolean.TRUE, 95, 158, Integer.valueOf(ReportWizard.SOGROUPPAGE), 209 + }); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private boolean isGroupField(String _FieldName) + { + return (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, _FieldName) != -1); + } + + public void initialize() + { + try + { + ArrayList<String> NormalFieldsVector = new ArrayList<String>(); + ArrayList<String> SelFieldsVector = new ArrayList<String>(); + String[] sFieldNames = CurDBMetaData.getFieldNames(); + for (int i = 0; i < sFieldNames.length; i++) + { + String sfieldtitle = sFieldNames[i]; // CurDBMetaData.getFieldTitle(sFieldNames[i]); + if (isGroupField(sFieldNames[i])) + { + SelFieldsVector.add(sfieldtitle); + } + else + { + NormalFieldsVector.add(sfieldtitle); + } + } + String[] SelFields = new String[SelFieldsVector.size()]; + SelFieldsVector.toArray(SelFields); + String[] NormalFields = new String[NormalFieldsVector.size()]; + NormalFieldsVector.toArray(NormalFields); + super.initialize(NormalFields, SelFields, true); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void removeGroupFieldNames() + { + emptyFieldsListBoxes(); + GroupFieldVector.clear(); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + } + + public void getGroupFieldNames(CommandMetaData CurDBMetaData) + { + String[] GroupFieldNames = new String[GroupFieldVector.size()]; + GroupFieldVector.toArray(GroupFieldNames); + CurDBMetaData.GroupFieldNames = GroupFieldNames; + } + // @Override + @Override + protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex) + { + super.toggleListboxButtons(iFieldsSelIndex, iSelFieldsSelIndex); + int iSelCount = xSelectedFieldsListBox.getItemCount(); + if (iSelCount >= MAXSELFIELDS) + { + CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + } + } + + @Override + public void selectFields(boolean bMoveAll) + { + int iSelCount = xSelectedFieldsListBox.getItemCount(); + if (iSelCount < MAXSELFIELDS) + { + super.selectFields(bMoveAll); + } + + } + + /* protected */ private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + public void moveItemDown(String Selitem) + { + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + + public void moveItemUp(String item) + { + CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + + public void shiftFromLeftToRight(String[] Selitems, String[] Newitems) + { + String CurGroupTitle = Selitems[0]; + int iSelCount = xSelectedFieldsListBox.getItemCount(); + String[] CurGroupNames = xFieldsListBox.getItems(); + CurReportDocument.liveupdate_addGroupNametoDocument(CurGroupNames, CurGroupTitle, GroupFieldVector, CurReportDocument.getReportPath(), iSelCount); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + if (iSelCount >= MAXSELFIELDS) + { + toggleMoveButtons(false, false); + } + } + + public void shiftFromRightToLeft(String[] OldSelitems, String[] Newitems) + { + int iSelPos = OldSelitems.length; + if (iSelPos > 0) + { + String OldGroupTitle = OldSelitems[0]; + String[] NewSelList = xSelectedFieldsListBox.getItems(); + CurReportDocument.liveupdate_removeGroupName(NewSelList, OldGroupTitle, GroupFieldVector); + String[] NewSelGroupNames = xSelectedFieldsListBox.getItems(); + CurUnoDialog.setControlProperty("lblBlindTextNote_1", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(NewSelGroupNames.length == 0)); + + // CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems()); + } + } + + public void setID(String sIncSuffix) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java b/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java new file mode 100644 index 000000000..ad7993df0 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java @@ -0,0 +1,106 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +/** + * This Interface separate the ReportBuilderImplementation from the layout. + * Only these less methods are allowed to access from the ReportBuilderImplementation. + */ +public interface IReportBuilderLayouter +{ + + /** + * Get the internal name of the current layout. + * This name identifies the layout in the internal access list. + * @return the internal layout name. + */ + String getName(); + + /** + * Get the localized name of the layout, which is shown in the layout page of the report wizard. + * This name comes out of the resource and will be translate in different languages. + * @return localized name of the layout. + */ + String getLocalizedName(); + + /** + * For Landscape give nOrientation == com.sun.star.wizards.report.ReportLayouter.SOOPTLANDSCAPE + * All other numbers are interpreted as portrait format. + */ + void setPageOrientation(int nOrientation); + + /** + * dispose the layouter + */ + void dispose(); + + /** + * Set the table name of the report + * This is the name to the database table. + * @param _nType something of com.sun.star.sdb.CommandType + */ + void setTableName(int _nType, String TableName); + + /** + * Insert the field names, these are the field names out of a given datebase table + */ + void insertFieldNames(final String[] FieldNames); + + /** + * Insert the field type (Varchar, int, ...) as internal an int representation. + */ + void insertFieldTypes(int[] FieldTypes); + + /** + * Insert the field width in count of chars as given in the database. + */ + void insertFieldWidths(int[] FieldWidths); + + /** + * Insert the titles of the field names. This names are free formed + */ + void insertFieldTitles(String[] _aFieldTitles); + + /** + * Insert the names of the groups, the group names are names out of the field names. + * + * If a group name is given here, it will not shown in the fields/titles, but must be in the field string list. + */ + void insertGroupNames(String[] _aGroupFieldNames); + + /** + * Insert the names of the groups which should be used as sorting, the group names are names out of the field names. + * + * If a group name is given here, it will not shown in the fields/titles, but must be in the field string list. + */ + void insertSortingNames(String[][] _aSortFieldNames); + + /** + * This method redraws the whole layout with all its content + */ + void layout(); + + /** + * Initialize the current Layouter with data's out of another Layouter. + * + * This Method copies the internal fields, groups and titles + */ + void initializeData(IReportBuilderLayouter aOtherLayouter); + + void loadAndSetBackgroundTemplate(String LayoutTemplatePath); +} diff --git a/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java b/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java new file mode 100644 index 000000000..3cdabfc23 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java @@ -0,0 +1,48 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.report.XReportDefinition; + +/** + * This interface contains only one function to give access to the ReportDefinition. + * The ReportDefinition will be initialized very late, late after the ReportLayouters. + * So we need this interface for the late access. + */ +public interface IReportDefinitionReadAccess +{ + + /** + * Gives access to a ReportDefinition, if initialized. + * @return a ReportDefinition or null. + */ + XReportDefinition getReportDefinition(); /* should throw NullPointerException but does not. */ + + + /** + * This ServiceFactory is the 'global' Service Factory, which knows all and everything in the program. + * @return the global service factory of the program + */ + XMultiServiceFactory getGlobalMSF(); + + /** + * Returns the file path to the default report definition, we need this name for early initialisation + */ + String getDefaultHeaderLayout(); +} diff --git a/wizards/com/sun/star/wizards/report/IReportDocument.java b/wizards/com/sun/star/wizards/report/IReportDocument.java new file mode 100644 index 000000000..ec04d6780 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/IReportDocument.java @@ -0,0 +1,219 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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; + +/** + * New Interface which gives us the possibility to switch on the fly between the old + * Wizard and the new Report Builder Wizard, which use the same UI. + */ +public interface IReportDocument +{ + + // initialisation + + void initialize( + final XDatabaseDocumentUI i_documentUI, + final Resource i_resource + ); + + + // Access Helper + + /** + * Gives access to the DB Values + */ + com.sun.star.wizards.db.RecordParser getRecordParser(); + + /** + * Give access to the parent document + * It is a document in the old Wizard + * It is a Report Builder in the new Wizard + */ + com.sun.star.awt.XWindowPeer getWizardParent(); + + /** + * + * @return the Frame of the document Window or Report Builder Window + */ + com.sun.star.frame.XFrame getFrame(); + + XComponent getComponent(); + + + // First step: After entering the table name, select fields + + /** + * Is called after first step, set Tablename and the fields, which should occur in the Report. + */ + void initializeFieldColumns(final int _aType, final String TableName, final String[] FieldNames); + + /** + * Empties the report document + */ + void clearDocument(); + + /** + * Empties the report document, if we called back, don't remove Grouping/Sorting + */ + void removeTextTableAndTextSection(); + + + // Second step: Label field titles + + /** + * Set new names for the titles + */ + void setFieldTitles(final String[] sFieldTitles); + + /** + * Change the name of the 'title' of one field. + * It is possible to give all element names new names which are used as + * element title of a given element name. + * This is only used as a preview + */ + void liveupdate_changeUserFieldContent(final String FieldName, final String TitleName); + + // Third step: Grouping + + /* Grouping Page */ + // Document should not hold the grouping information! + /** + * Called by press ('greater than') add a group to the group list + */ + boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount); + + void refreshGroupFields(String[] _sNewNames); + /** + * Called by press ('less than') Removes an already set Groupname out of the list + */ + void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.ArrayList<String> GroupFieldVector); + + /** + * set the list how to group + */ + void setGrouping(String[] aGroupList); + + // Fourth step: Sorting + + /** + * Set the list how to sort + */ + void setSorting(String[][] aSort); + + // Fivth step: Templates / Layout + + /* Template Page */ + void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException; + + int getDefaultPageOrientation(); + + ArrayList<String> getReportPath(); + + String getLayoutPath(); + + String getContentPath(); + + /** + * Called if a new Layout is selected + */ + void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/); + + /** + * Called if a new Template is selected + */ + void liveupdate_changeContentTemplate(String ContentTemplatePath); + + void layout_selectFirstPage(); + + void layout_setupRecordSection(String TemplateName); + + // finishing + + // preview (update titlenames) + // addTextListener + /** + * Set the Title into the document from the 'Create Report Page' + * BUG: The Title is empty after create Report. + */ + void liveupdate_updateReportTitle(String _sTitleName); + + /** + * Store the document by the given name + */ + void store(String Name, int OpenMode) throws com.sun.star.uno.Exception; + + /** + * The current report is added to the DB View under the given name + * + * TODO: add Name to this functionality + */ + void addReportToDBView(); + + void importReportData(ReportWizard aWizard); + + /** + * Create the final Report document + */ + void createAndOpenReportDocument( + final String Name, + final boolean _bAsTemplate, + final boolean _bOpenInDesign + ); + + void dispose(); + + // Garbage dump + + /* DataImport */ + // ??? + // ??? + boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties); + // ??? + void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF); + // ??? + /** + * set an internal variable to stop a maybe longer DB access. + */ + void StopProcess(); // cancel + + /** + * Returns a string list of layouts. + */ + String[][] getDataLayout(); + + /** + * Returns a string list of header layouts + */ + String[][] getHeaderLayout(); + + void setCommandType(int CommandType); + + void setCommand(String Command); + + /** + * check internal invariants + */ + void checkInvariants() throws java.lang.Exception; +} diff --git a/wizards/com/sun/star/wizards/report/MANIFEST.MF b/wizards/com/sun/star/wizards/report/MANIFEST.MF new file mode 100644 index 000000000..1a4f8da6e --- /dev/null +++ b/wizards/com/sun/star/wizards/report/MANIFEST.MF @@ -0,0 +1,2 @@ +RegistrationClassName: com.sun.star.wizards.report.CallReportWizard +UNO-Type-Path: diff --git a/wizards/com/sun/star/wizards/report/RecordTable.java b/wizards/com/sun/star/wizards/report/RecordTable.java new file mode 100644 index 000000000..50e605dbc --- /dev/null +++ b/wizards/com/sun/star/wizards/report/RecordTable.java @@ -0,0 +1,85 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.container.XIndexAccess; +import com.sun.star.container.XNameAccess; +import com.sun.star.container.XNamed; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.table.XCellRange; +import com.sun.star.table.XTableColumns; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.ViewHandler; + +public class RecordTable +{ + + XNamed xTableName; + XCellRange xCellRange; + public XTextTable xTextTable; + private TextTableHandler oTextTableHandler; + XTableColumns xTableColumns; + + public RecordTable(TextTableHandler _oTextTableHandler) + { + try + { + this.oTextTableHandler = _oTextTableHandler; + XNameAccess xAllTextTables = oTextTableHandler.xTextTablesSupplier.getTextTables(); + if ((xAllTextTables.hasByName(ReportTextDocument.TBLRECORDSECTION)) || (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION))) + { + Object oTable; + if (xAllTextTables.hasByName(ReportTextDocument.COPYOFTBLRECORDSECTION)) + { + oTable = xAllTextTables.getByName(ReportTextDocument.COPYOFTBLRECORDSECTION); + } + else + { + oTable = xAllTextTables.getByName(ReportTextDocument.TBLRECORDSECTION); + } + xTextTable = UnoRuntime.queryInterface(XTextTable.class, oTable); + xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); + } + else + { + XIndexAccess xTableIndex = UnoRuntime.queryInterface(XIndexAccess.class, xAllTextTables); + int n = xTableIndex.getCount() - 1; + Object x = xTableIndex.getByIndex(n); + xTextTable = UnoRuntime.queryInterface(XTextTable.class, x); + xTableName = UnoRuntime.queryInterface(XNamed.class, xTextTable); + xTableName.setName(ReportTextDocument.TBLRECORDSECTION); + } + xTextTable.getRows(); + xTableColumns = xTextTable.getColumns(); + xCellRange = UnoRuntime.queryInterface(XCellRange.class, xTextTable); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void adjustOptimalTableWidths(XMultiServiceFactory _xMSF, ViewHandler oViewHandler) + { // setTableColumnSeparators(){ + oTextTableHandler.adjustOptimalTableWidths(_xMSF, xTextTable); + oViewHandler.collapseViewCursorToStart(); + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportFinalizer.java b/wizards/com/sun/star/wizards/report/ReportFinalizer.java new file mode 100644 index 000000000..048c2d3e9 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportFinalizer.java @@ -0,0 +1,259 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; +import com.sun.star.awt.ItemEvent; +import com.sun.star.awt.TextEvent; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.awt.XTextComponent; +import com.sun.star.uno.Exception; +import com.sun.star.wizards.common.Desktop; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.common.PropertyNames; +import com.sun.star.wizards.db.RecordParser; +import com.sun.star.wizards.ui.UIConsts; +import com.sun.star.wizards.ui.WizardDialog; +import com.sun.star.wizards.ui.event.XItemListenerAdapter; +import com.sun.star.wizards.ui.event.XTextListenerAdapter; + +public class ReportFinalizer +{ + + private WizardDialog CurUnoDialog; + private XTextComponent xTitleTextBox; + private String StoreName; + private String OldDefaultName; + private IReportDocument CurReportDocument; + public static final int SOCREATEDOCUMENT = 1; + public static final int SOCREATETEMPLATE = 2; + public static final int SOUSETEMPLATE = 3; + public ReportFinalizer(IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog) + { + this.CurUnoDialog = _CurUnoDialog; + this.CurReportDocument = _CurReportDocument; + short curtabindex = (short) (ReportWizard.SOSTOREPAGE * 100); + + String sSaveAsTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_40"); + String sUseTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_41"); + String sEditTemplate = CurUnoDialog.m_oResource.getResText("RID_REPORT_42"); + String sSaveAsDocument = CurUnoDialog.m_oResource.getResText("RID_REPORT_43"); + String sReportTitle = CurUnoDialog.m_oResource.getResText("RID_REPORT_33"); + String slblHowProceed = CurUnoDialog.m_oResource.getResText("RID_REPORT_78"); + String slblChooseReportKind = CurUnoDialog.m_oResource.getResText("RID_REPORT_79"); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblTitle", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sReportTitle, 95, 27, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 68 + }); + + xTitleTextBox = CurUnoDialog.insertTextField("txtTitle", new XTextListenerAdapter() { + @Override + public void textChanged(TextEvent arg0) { + changeReportTitle(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 12, "HID:WIZARDS_HID_DLGREPORT_4_TITLE", 95, 37, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblChooseReportKind", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblChooseReportKind, 95, 57, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + CurUnoDialog.insertRadioButton("optCreateDocument", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", sSaveAsDocument, 95, 69, Short.valueOf((short) 0), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 138 + }); + + CurUnoDialog.insertRadioButton("optCreateReportTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", sSaveAsTemplate, 95, 81, Short.valueOf((short) 1), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblHowProceed", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblHowProceed, 105, 93, Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 209 + }); + + + CurUnoDialog.insertRadioButton("optEditTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", sEditTemplate, 111, 105, 6, Short.valueOf(curtabindex++), 138 + }); + + CurUnoDialog.insertRadioButton("optUseTemplate", new XItemListenerAdapter() { + @Override + public void itemStateChanged(ItemEvent event) { + toggleSubTemplateControls(); + } + }, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", sUseTemplate, 111, 115, Short.valueOf((short) 1), Integer.valueOf(ReportWizard.SOSTOREPAGE), Short.valueOf(curtabindex++), 138 + }); + } + + + /** + * This function is called if one of the radio buttons is pressed + */ + private void toggleSubTemplateControls() + { + // String sStorePath = PropertyNames.EMPTY_STRING; + Short iState = (Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", PropertyNames.PROPERTY_STATE); + boolean bDoTemplateEnable = iState.shortValue() == 1; + CurUnoDialog.setControlProperty("optEditTemplate", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + CurUnoDialog.setControlProperty("optUseTemplate", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + CurUnoDialog.setControlProperty("lblHowProceed", PropertyNames.PROPERTY_ENABLED, bDoTemplateEnable); + + String sTitle = xTitleTextBox.getText(); + boolean bDoEnable = sTitle.equals(PropertyNames.EMPTY_STRING); + CurUnoDialog.enableFinishButton(!bDoEnable); + } + public void initialize(RecordParser _CurDBMetaData) + { + String FirstCommandName = _CurDBMetaData.getIncludedCommandNames()[0]; + String DefaultName = Desktop.getUniqueName(_CurDBMetaData.getReportDocuments(), FirstCommandName); + if (!DefaultName.equals(OldDefaultName)) + { + OldDefaultName = DefaultName; + } + xTitleTextBox.setText(DefaultName); + } + + public String getStoreName() + { + if (CurUnoDialog != null) + { + String LocStoreName = xTitleTextBox.getText(); + if (!LocStoreName.equals(PropertyNames.EMPTY_STRING)) + { + StoreName = LocStoreName; + } + } + return StoreName; + } + + private void changeReportTitle() + { + final String TitleName = xTitleTextBox.getText(); + CurReportDocument.liveupdate_updateReportTitle(TitleName); + CurUnoDialog.enableFinishButton(!PropertyNames.EMPTY_STRING.equals(TitleName)); + } + + public int getReportOpenMode() + { + int ReportMode = SOCREATEDOCUMENT; + boolean bcreateTemplate = ((Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (bcreateTemplate) + { + ReportMode = SOCREATETEMPLATE; + } + boolean buseTemplate = ((Short) CurUnoDialog.getControlProperty("optUseTemplate", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (buseTemplate) + { + ReportMode = SOUSETEMPLATE; + } + boolean buseDocument = ((Short) CurUnoDialog.getControlProperty("optCreateDocument", PropertyNames.PROPERTY_STATE)).shortValue() == (short) 1; + if (buseDocument) + { + ReportMode = SOCREATEDOCUMENT; + } + return ReportMode; + } + + public boolean finish() + { + StoreName = getStoreName(); + if (!CurReportDocument.getRecordParser().getReportDocuments().hasByHierarchicalName(StoreName)) + { + try + { + CurReportDocument.store(StoreName, getReportOpenMode()); + ReportWizard.bCloseDocument = false; + return true; + } + catch(Exception e) + { + CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK,e.getLocalizedMessage() ); + CurUnoDialog.enableFinishButton(false); + return false; + } + } + String sMsgReportDocumentNameDuplicate = CurUnoDialog.m_oResource.getResText("RID_REPORT_76"); + String sShowMsgReportNameisDuplicate = JavaTools.replaceSubString(sMsgReportDocumentNameDuplicate, StoreName, "%REPORTNAME"); + /* int iMsg = */ CurUnoDialog.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sShowMsgReportNameisDuplicate); + CurUnoDialog.enableFinishButton(false); + return false; + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java b/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java new file mode 100644 index 000000000..54b0bac36 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java @@ -0,0 +1,49 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.db.RecordParser; + +public class ReportImplementationHelper +{ + + private RecordParser m_aCurDBMetaData; + private final XMultiServiceFactory m_xMSF; + protected int m_nDefaultPageOrientation; + + public ReportImplementationHelper(XMultiServiceFactory _aMSF, int _nOrientation) + { + m_xMSF = _aMSF; + m_nDefaultPageOrientation = _nOrientation; + } + + public RecordParser getRecordParser() + { + if (m_aCurDBMetaData == null) + { + m_aCurDBMetaData = new RecordParser(getMSF()); + } + return m_aCurDBMetaData; + } + + public XMultiServiceFactory getMSF() + { + return m_xMSF; + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportLayouter.java b/wizards/com/sun/star/wizards/report/ReportLayouter.java new file mode 100644 index 000000000..f6397ce92 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportLayouter.java @@ -0,0 +1,425 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.awt.XListBox; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.ui.*; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.util.XSearchable; +import com.sun.star.util.XSearchDescriptor; +import com.sun.star.container.XIndexAccess; +import com.sun.star.text.*; +import com.sun.star.wizards.common.TextElement; +import com.sun.star.wizards.common.PlaceholderTextElement; + +import java.util.List; +import java.util.ArrayList; + +public class ReportLayouter +{ + + private UnoDialog CurUnoDialog; + private static final int SOCONTENTLST = 29; + final public static int SOOPTLANDSCAPE = 30; + final public static int SOOPTPORTRAIT = 31; + private static final int SOLAYOUTLST = 32; + private XListBox xContentListBox; + private XListBox xLayoutListBox; + private int iOldContentPos; + private int iOldLayoutPos; + private IReportDocument CurReportDocument; + private String[][] LayoutFiles; + private String[][] ContentFiles; + private Object aOrientationImage; + private final XMultiServiceFactory m_xMSF; + private XTextRange trTitleconst, trAuthorconst, trDateconst, trPageconst; + private TextElement teTitleconst, teAuthorconst, teDateconst, tePageconst; + private List<XTextRange> constRangeList = new ArrayList<XTextRange>(); + private final boolean isBuilderInstalled; + + public ReportLayouter(XMultiServiceFactory _xMSF, IReportDocument _CurReportDocument, UnoDialog _CurUnoDialog, boolean _isBuilderInstalled) + { + m_xMSF = _xMSF; + isBuilderInstalled = _isBuilderInstalled; + try + { + short curtabindex = (short) (100 * ReportWizard.SOTEMPLATEPAGE); + this.CurUnoDialog = _CurUnoDialog; + this.CurReportDocument = _CurReportDocument; + //TODO the constructor for the OfficePathRetriever is redundant and should be instantiated elsewhere + String slblDataStructure = CurUnoDialog.m_oResource.getResText("RID_REPORT_15"); + String slblPageLayout = CurUnoDialog.m_oResource.getResText("RID_REPORT_16"); + + String sOrientationHeader = CurUnoDialog.m_oResource.getResText("RID_REPORT_22"); + String sOrientVertical = CurUnoDialog.m_oResource.getResText("RID_REPORT_23"); + String sOrientHorizontal = CurUnoDialog.m_oResource.getResText("RID_REPORT_24"); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblContent", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblDataStructure, 95, 27, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 99 + }); + + short iSelPos = 0; + ContentFiles = CurReportDocument.getDataLayout(); + iSelPos = (short) JavaTools.FieldInList(ContentFiles[1], CurReportDocument.getContentPath()); + if (iSelPos < 0) + { + iSelPos = 0; + } + iOldContentPos = iSelPos; + xContentListBox = CurUnoDialog.insertListBox("lstContent", SOCONTENTLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.SELECTED_ITEMS, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 108, "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", 95, 37, new short[] + { + iSelPos + }, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), ContentFiles[0], Short.valueOf(curtabindex++), 99 + }); + + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblLayout", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, slblPageLayout, 205, 27, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 99 + }); + + short iSelLayoutPos = 0; + LayoutFiles = CurReportDocument.getHeaderLayout(); + iSelLayoutPos = (short) JavaTools.FieldInList(LayoutFiles[1], CurReportDocument.getLayoutPath()); + if (iSelLayoutPos < 0) + { + iSelLayoutPos = (short) JavaTools.FieldInList(LayoutFiles[0], CurReportDocument.getLayoutPath()); + if (iSelLayoutPos < 0) + { + iSelLayoutPos = 0; + } + } + xLayoutListBox = CurUnoDialog.insertListBox("lstLayout", SOLAYOUTLST, new ActionListenerImpl(), new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.SELECTED_ITEMS, PropertyNames.PROPERTY_STEP, PropertyNames.STRING_ITEM_LIST, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 108, "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", 205, 37, new short[] + { + iSelLayoutPos + }, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), LayoutFiles[0], Short.valueOf(curtabindex++), 99 + }); + iOldLayoutPos = iSelPos; + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblOrientation", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 8, sOrientationHeader, 95, 148, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 74 + }); + + short m_nLandscapeState = CurReportDocument.getDefaultPageOrientation() == SOOPTLANDSCAPE ? (short) 1 : 0; + CurUnoDialog.insertRadioButton("optLandscape", SOOPTLANDSCAPE, new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", sOrientHorizontal, 101, 158, Short.valueOf(m_nLandscapeState), Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 60 + }); + + short m_nPortraitState = CurReportDocument.getDefaultPageOrientation() == SOOPTPORTRAIT ? (short) 1 : (short) 0; + CurUnoDialog.insertRadioButton("optPortrait", SOOPTPORTRAIT, new ItemListenerImpl(), + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_HELPURL, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STATE, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_TABINDEX, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 10, "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", sOrientVertical, 101, 171, Short.valueOf(m_nPortraitState), Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), Short.valueOf(curtabindex++), 60 + }); + + aOrientationImage = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgOrientation", + new String[] + { + PropertyNames.PROPERTY_BORDER, PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, "ScaleImage", PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Short.valueOf("0"), 23, 164, 158, Boolean.FALSE, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), 30 + }); + + String sNote = ReportWizard.getBlindTextNote(CurReportDocument, CurUnoDialog.m_oResource); + CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_2", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_MULTILINE, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 34, sNote, Boolean.TRUE, 205, 148, Integer.valueOf(ReportWizard.SOTEMPLATEPAGE), 99 + }); + if (m_nLandscapeState == 1) + { + CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, "private:graphicrepository/wizards/res/landscape_32.png"); + } + else + { + CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, "private:graphicrepository/wizards/res/portrait_32.png"); + } + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + public void initialize(String _defaultTemplatePath) + { + CurReportDocument.layout_setupRecordSection(_defaultTemplatePath); + if (CurUnoDialog.getControlProperty("txtTitle", "Text").equals(PropertyNames.EMPTY_STRING)) + { + String[] sCommandNames = CurReportDocument.getRecordParser().getIncludedCommandNames(); + CurUnoDialog.setControlProperty("txtTitle", "Text", sCommandNames[0]); + } + CurReportDocument.layout_selectFirstPage(); + CurUnoDialog.setFocus("lblContent"); + } + + class ItemListenerImpl implements com.sun.star.awt.XItemListener + { + + public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject) + { + try + { + int iPos; + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + // LLA: should we lock controllers here? + // CurReportDocument.getDoc().xTextDocument.lockControllers(); + int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList); + switch (iKey) + { + case SOCONTENTLST: + iPos = xContentListBox.getSelectedItemPos(); + if (iPos != iOldContentPos) + { + iOldContentPos = iPos; + CurReportDocument.liveupdate_changeContentTemplate(ContentFiles[1][iPos]); + if(!isBuilderInstalled) + { + clearConstants(); + drawConstants(); + } + } + break; + + case SOLAYOUTLST: + iPos = xLayoutListBox.getSelectedItemPos(); + if (iPos != iOldLayoutPos) + { + iOldLayoutPos = iPos; + CurReportDocument.liveupdate_changeLayoutTemplate(LayoutFiles[1][iPos]/*, Desktop.getBitmapPath(m_xMSF)*/); + if(!isBuilderInstalled) + { + clearConstants(); + drawConstants(); + } + } + break; + + case SOOPTLANDSCAPE: + // CurReportDocument.getDoc().changePageOrientation(true); + try + { + CurReportDocument.setPageOrientation(SOOPTLANDSCAPE); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + } + Helper.setUnoPropertyValue(aOrientationImage, PropertyNames.PROPERTY_IMAGEURL, "private:graphicrepository/wizards/res/landscape_32.png"); + + break; + + case SOOPTPORTRAIT: + // CurReportDocument.getDoc().changePageOrientation( false); + try + { + CurReportDocument.setPageOrientation(SOOPTPORTRAIT); + } + catch (com.sun.star.lang.IllegalArgumentException e) + { + } + + CurUnoDialog.setControlProperty("imgOrientation", PropertyNames.PROPERTY_IMAGEURL, Desktop.getBitmapPath(m_xMSF) + "/portrait.gif"); + Helper.setUnoPropertyValue(aOrientationImage, PropertyNames.PROPERTY_IMAGEURL, "private:graphicrepository/wizards/res/portrait_32.png"); + break; + + default: + break; + } + } + catch (RuntimeException e) + { + e.printStackTrace(); + } + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + + public void disposing(EventObject eventObject) + { + } + } + + class ActionListenerImpl implements com.sun.star.awt.XActionListener + { + + public void disposing(EventObject eventObject) + { + } + + public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent) + { + try + { + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.FALSE); + boolean blandscape = (((Short) CurUnoDialog.getControlProperty("optLandscape", PropertyNames.PROPERTY_STATE)).shortValue() == 1); + CurReportDocument.setPageOrientation((blandscape) ? SOOPTLANDSCAPE : SOOPTPORTRAIT); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, PropertyNames.PROPERTY_ENABLED, Boolean.TRUE); + } + } + + public void drawConstants() + { + constRangeList = searchFillInItems(1); + + XTextRange item = null; + + for (int i = 0; i < constRangeList.size(); i++) + { + item = constRangeList.get(i); + String text = item.getString().trim().toLowerCase(); + if (text.equals("#titleconst#")) + { + teTitleconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_86"), PropertyNames.EMPTY_STRING, m_xMSF); + trTitleconst = item; + constRangeList.remove(i--); + writeTitle(teTitleconst, trTitleconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_86")); + } + else if (text.equals("#authorconst#")) + { + teAuthorconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_87"), PropertyNames.EMPTY_STRING, m_xMSF); + trAuthorconst = item; + constRangeList.remove(i--); + writeTitle(teAuthorconst, trAuthorconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_87")); + } + else if (text.equals("#dateconst#")) + { + teDateconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_88"), PropertyNames.EMPTY_STRING, m_xMSF); + trDateconst = item; + constRangeList.remove(i--); + writeTitle(teDateconst, trDateconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_88")); + } + else if (text.equals("#pageconst#")) + { + tePageconst = new PlaceholderTextElement(item, CurUnoDialog.m_oResource.getResText("RID_REPORT_93"), PropertyNames.EMPTY_STRING, m_xMSF); + trPageconst = item; + constRangeList.remove(i--); + writeTitle(tePageconst, trPageconst, CurUnoDialog.m_oResource.getResText("RID_REPORT_93")); + } + } + } + + private void clearConstants() + { + constRangeList.clear(); + trTitleconst = null; + teTitleconst = null; + trAuthorconst = null; + teAuthorconst = null; + trDateconst = null; + teDateconst = null; + trPageconst = null; + tePageconst = null; + } + + private void writeTitle(TextElement te, XTextRange tr, String text) + { + te.setText(text == null ? PropertyNames.EMPTY_STRING : text); + te.write(tr); + } + + private List<XTextRange> searchFillInItems(int type) + { + try + { + XSearchable xSearchable = UnoRuntime.queryInterface(XSearchable.class, CurReportDocument.getComponent()); + XSearchDescriptor sd = xSearchable.createSearchDescriptor(); + + if(type == 0) + { + sd.setSearchString("<[^>]+>"); + } + else if(type == 1) + { + sd.setSearchString("#[^#]+#"); + } + sd.setPropertyValue("SearchRegularExpression", Boolean.TRUE); + sd.setPropertyValue("SearchWords", Boolean.TRUE); + + XIndexAccess ia = xSearchable.findAll(sd); + List<XTextRange> l = new ArrayList<XTextRange>(ia.getCount()); + for (int i = 0; i < ia.getCount(); i++) + { + try + { + l.add(UnoRuntime.queryInterface(XTextRange.class, ia.getByIndex(i))); + } + catch (Exception ex) + { + System.err.println("Nonfatal Error in finding fillins."); + } + } + return l; + } + catch (Exception ex) + { + throw new IllegalArgumentException("Fatal Error: Loading template failed: searching fillins failed", ex); + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportTextDocument.java b/wizards/com/sun/star/wizards/report/ReportTextDocument.java new file mode 100644 index 000000000..1c109c0b1 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java @@ -0,0 +1,668 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +import com.sun.star.lang.IllegalArgumentException; +import com.sun.star.text.XRelativeTextContentRemove; +import com.sun.star.text.XTextContent; +import java.util.ArrayList; +import java.util.Comparator; +import com.sun.star.awt.VclWindowPeerAttribute; +import com.sun.star.container.XNameAccess; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.uno.AnyConverter; +import com.sun.star.uno.Exception; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.wizards.db.*; +import com.sun.star.wizards.common.*; +import com.sun.star.wizards.ui.*; +import com.sun.star.sdb.CommandType; +import com.sun.star.text.XTextDocument; +import com.sun.star.wizards.common.JavaTools; +import com.sun.star.wizards.text.TextTableHandler; +import com.sun.star.wizards.text.TextSectionHandler; +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<FieldColumn> +{ + + 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 Object ReportPageStyle; + private Object FirstPageStyle; + public ArrayList<DBColumn> DBColumnsVector; + private RecordTable CurRecordTable; + private String sMsgCommonReportError; + private String ContentTemplatePath; + private boolean bIsCurLandscape; + public TextTableHandler oTextTableHandler; + public TextSectionHandler oTextSectionHandler; + public FormHandler oFormHandler; + private TextStyleHandler oTextStyleHandler; + public TextFieldHandler oTextFieldHandler; + public ViewHandler oViewHandler; + public static final String TBLRECORDSECTION = "Tbl_RecordSection"; + public static final String TBLGROUPSECTION = "Tbl_GroupField"; + public static final String RECORDSECTION = "RecordSection"; + public static final String GROUPSECTION = "GroupField"; + public static final String COPYOFTBLRECORDSECTION = "CopyOf" + TBLRECORDSECTION; + public static final String COPYOFTBLGROUPSECTION = "CopyOf" + TBLGROUPSECTION; + public static final String COPYOFRECORDSECTION = "CopyOf" + RECORDSECTION; + public static final String COPYOFGROUPSECTION = "CopyOf" + GROUPSECTION; + private RecordParser CurDBMetaData; + + /** Creates new ReportDocument */ + public ReportTextDocument(XMultiServiceFactory xMSF, XTextDocument _textDocument, Resource oResource, RecordParser _aRP) + { + super(xMSF, _textDocument, false); + lateInit(oResource, _aRP); + } + + public ReportTextDocument(XMultiServiceFactory xMSF, String _sPreviewURL, Resource oResource, RecordParser _aRP) + { + super(xMSF, _sPreviewURL, true, null); + lateInit(oResource, _aRP); + } + + private void lateInit(Resource oResource, RecordParser _aRecordParser) + { + oTextTableHandler = new TextTableHandler(xTextDocument); + oTextSectionHandler = new TextSectionHandler(xMSFDoc, xTextDocument); + oFormHandler = new FormHandler(xMSFDoc, xTextDocument); + oTextStyleHandler = new TextStyleHandler(xTextDocument); + oViewHandler = new ViewHandler(xTextDocument); + oTextFieldHandler = new TextFieldHandler(xMSFDoc, xTextDocument); + DBColumnsVector = new java.util.ArrayList<DBColumn>(); + NumberFormatter oNumberFormatter = oTextTableHandler.getNumberFormatter(); + CurDBMetaData = _aRecordParser; + long lDateCorrection = oNumberFormatter.getNullDateCorrection(); + oNumberFormatter.setBooleanReportDisplayNumberFormat(); + oNumberFormatter.setNullDateCorrection(lDateCorrection); + sMsgCommonReportError = oResource.getResText("RID_REPORT_72"); + sMsgCommonReportError = JavaTools.replaceSubString(sMsgCommonReportError, String.valueOf((char) 13), "<BR>"); + bIsCurLandscape = true; + getReportPageStyles(); + } + + public void swapContentTemplate(String ContentTemplatePath) + { + this.ContentTemplatePath = ContentTemplatePath; + loadSectionsfromTemplate(ContentTemplatePath); + oTextStyleHandler.loadStyleTemplates(ContentTemplatePath, "LoadTextStyles"); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + oViewHandler.selectFirstPage(oTextTableHandler); + } + + public void swapLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) + { + try + { + boolean bOldIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, ISLANDSCAPE)); + oTextStyleHandler.loadStyleTemplates(LayoutTemplatePath, "LoadPageStyles"); + changePageOrientation(bOldIsCurLandscape); + oViewHandler.selectFirstPage(oTextTableHandler); + } + catch (IllegalArgumentException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void createReportForm(String SOREPORTFORMNAME) + { + com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME); + XNameAccess xNameAccess = UnoRuntime.queryInterface(XNameAccess.class, xNamedForm); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND_TYPE, Integer.toString(CurDBMetaData.getCommandType())); + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, QUERYNAME, CurDBMetaData.getCommandName()); + if (CurDBMetaData.getCommandType() == CommandType.QUERY) + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.COMMAND, ""); + //DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName()); + //oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, COMMAND, CurDBMetaData.Command); + } + else + { + oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, PropertyNames.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())); + } + + private void getReportPageStyles() + { + try + { + Object oPageStyleFamily = oTextStyleHandler.xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles"); + ReportPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "Standard"); + FirstPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "First Page"); + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void changePageOrientation(boolean bNewLandscape) + { + try + { + 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)); + if (bIsCurLandscape != bNewLandscape) + { + oNewSize = new com.sun.star.awt.Size(oLocSize.Height, oLocSize.Width); + Helper.setUnoPropertyValue(ReportPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(ReportPageStyle, SIZE, oNewSize); + Helper.setUnoPropertyValue(FirstPageStyle, ISLANDSCAPE, bNewLandscape); + Helper.setUnoPropertyValue(FirstPageStyle, SIZE, oNewSize); + AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "LeftMargin")); + AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "RightMargin")); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + } + } + catch (IllegalArgumentException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + private boolean loadSectionsfromTemplate(String sTemplateUrl) + { + try + { + int i; + DBColumn CurDBColumn; + int GroupCount = CurDBMetaData.GroupFieldNames.length; + CurRecordTable = null; + for (i = 0; i < GroupCount; i++) + { + String SectionName = GROUPSECTION + Integer.toString(i + 1); + oTextTableHandler.renameTextTable("Tbl_" + SectionName, "MyTextTable"); + oTextSectionHandler.linkSectiontoTemplate(sTemplateUrl, SectionName); + oTextTableHandler.renameTextTable("MyTextTable", "Tbl_" + SectionName); + } + if (oTextSectionHandler.xTextSectionsSupplier.getTextSections().getElementNames().length > CurDBMetaData.GroupFieldNames.length) + { + oTextSectionHandler.linkSectiontoTemplate(sTemplateUrl, RECORDSECTION); + CurRecordTable = new RecordTable(oTextTableHandler); + insertColumnstoRecordTable(); + } + for (i = 0; i < GroupCount; i++) + { + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurDBMetaData.GroupFieldNames[i], TBLGROUPSECTION + (i + 1)); + CurDBColumn.formatValueCell(); + DBColumnsVector.set(i, CurDBColumn); + replaceFieldValueInGroupTable(CurDBColumn, i); + } + return true; + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + return false; + } + } + + public void setupRecordSection(String TemplateName) + { + this.ContentTemplatePath = TemplateName; + if (CurDBMetaData.getRecordFieldNames().length > 0) + { + boolean bAddParagraph = true; + if (CurDBMetaData.GroupFieldNames != null) + { + bAddParagraph = (CurDBMetaData.GroupFieldNames.length == 0); + } + oTextSectionHandler.insertTextSection(RECORDSECTION, TemplateName, bAddParagraph); + CurRecordTable = new RecordTable(oTextTableHandler); + insertColumnstoRecordTable(); + if (CurRecordTable != null) + { + CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler); + } + } + else + { + CurRecordTable = null; + } + } + + public void refreshGroupFields(String[] _sNewNames) + { + int nSize = DBColumnsVector.size(); + for (int i = 0; i < nSize; i++) + { + DBColumn CurDBColumn = DBColumnsVector.get(i); + String sFieldName = CurDBColumn.CurDBField.getFieldName(); + if (!sFieldName.equals(_sNewNames[i])) + { + CurDBColumn.CurDBField = CurDBMetaData.getFieldColumnByDisplayName(_sNewNames[i]); + CurDBColumn.insertColumnData(oTextFieldHandler, bIsCurLandscape); + } + } + } + + private void updateTextSections(String[] SelGroupNames) + { + String TableName; + DBColumn OldDBColumn; + DBColumn CurDBColumn; + // XNameAccess xTableNames = oTextTableHandler.xTextTablesSupplier.getTextTables(); + int GroupFieldCount = SelGroupNames.length; + for (int i = 0; i < GroupFieldCount; i++) + { + TableName = TBLGROUPSECTION + Integer.toString(i + 1); + OldDBColumn = DBColumnsVector.get(i); + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, SelGroupNames[i], TableName, OldDBColumn); + CurDBColumn.formatValueCell(); + DBColumnsVector.set(i, CurDBColumn); + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + } + } + + private void replaceFieldValueInGroupTable(DBColumn CurDBColumn, int TableIndex) + { + String TableName = TBLGROUPSECTION + (TableIndex + 1); + // Note: for some reason the table might lose its name and has to be renamed therefore + String OldTableName = CurDBColumn.xTableName.getName(); + if (OldTableName.compareTo(TableName) != 0) + { + CurDBColumn.xTableName.setName(TableName); + } + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + CurDBColumn.setCellFont(); + } + + private void insertColumnstoRecordTable() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + DBColumn CurDBColumn; + // Note for some reason the table might lose its name and has to be renamed therefore + String OldTableName = CurRecordTable.xTableName.getName(); + if (OldTableName.compareTo(TBLRECORDSECTION) != 0) + { + CurRecordTable = new RecordTable(oTextTableHandler); + } + com.sun.star.table.XTableColumns xColumns = CurRecordTable.xTextTable.getColumns(); + int ColCount = xColumns.getCount(); + int RecordCount = CurDBMetaData.getRecordFieldNames().length; + if (ColCount > RecordCount) + { + int RemoveCount = ColCount - RecordCount; + xColumns.removeByIndex(0, RemoveCount); + } + else if (ColCount < RecordCount) + { + int AddCount = RecordCount - ColCount; + CurRecordTable.xTextTable.getColumns().insertByIndex(ColCount, AddCount); + } + for (int i = 0; i < RecordCount; i++) + { + CurDBColumn = new DBColumn(CurRecordTable, oTextTableHandler, CurDBMetaData, i, true); + CurDBColumn.initializeNumberFormat(); + CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape); + if (DBColumnsVector.size() <= (i + GroupCount)) + { + DBColumnsVector.add(CurDBColumn); + } + else + { + DBColumnsVector.set(i + GroupCount, CurDBColumn); + } + } + } + + public boolean addGroupNametoDocument(String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount) + { + DBColumn CurDBColumn = null; + int GroupCount = GroupFieldVector.size(); + if (GroupCount < 4) + { + removeGroupNamesofRecordTable(iSelCount); + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.add(CurFieldColumn.getFieldName()); + GroupCount += 1; + try + { + String sPath = FileAccess.getPathFromList(xMSF, ReportPath, "cnt-default.ott"); + oTextSectionHandler.insertTextSection(GROUPSECTION + GroupCount, sPath, GroupCount == 1); + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurFieldColumn.getFieldName(), TBLGROUPSECTION + (GroupCount)); + CurDBColumn.formatValueCell(); + DBColumnsVector.add(CurDBColumn); + replaceFieldValueInGroupTable(CurDBColumn, GroupCount - 1); + } + catch (Exception exception) + { + showCommonReportErrorBox(exception); + } + + } + + return (CurDBColumn != null); + } + + public void removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.ArrayList<String> GroupFieldVector) + { + removeGroupNamesofRecordTable(NewSelGroupNames.length + 1); + FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle); + GroupFieldVector.remove(CurFieldColumn.getFieldName()); + oTextSectionHandler.removeLastTextSection(); + oTextTableHandler.removeLastTextTable(); + // if the previously selected item is somewhere in the middle of the listbox (and not at the end) the + // Textsections have to be updated + if (JavaTools.FieldInList(NewSelGroupNames, CurGroupTitle) == -1) + { + updateTextSections(NewSelGroupNames); + } + int iSelItemCount = NewSelGroupNames.length; + DBColumnsVector.remove(iSelItemCount); + } + + private void removeGroupNamesofRecordTable(int GroupFieldCount) + { + int CurFieldCount = DBColumnsVector.size(); + if (CurFieldCount > GroupFieldCount) + { + for (int i = CurFieldCount - 1; i >= GroupFieldCount; i--) + { + DBColumnsVector.remove(i); + } + } + } + + private void showCommonReportErrorBox(Exception exception) + { + String SystemContentPath = JavaTools.convertfromURLNotation(ContentTemplatePath); + String sMsgCurCommonReportError = JavaTools.replaceSubString(sMsgCommonReportError, SystemContentPath, "%PATH"); + CurDBMetaData.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgCurCommonReportError); + exception.printStackTrace(System.err); + } + + public void getallDBColumns() + { + try + { + DBColumn CurDBColumn; + for (int i = 0; i < CurDBMetaData.FieldColumns.length; i++) + { + if (i < CurDBMetaData.GroupFieldNames.length) + { + CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, CurDBMetaData.GroupFieldNames[i], COPYOFTBLGROUPSECTION + (i + 1)); + } + else + { + if (CurRecordTable == null) + { + CurRecordTable = new RecordTable(oTextTableHandler); + } + CurDBColumn = new DBColumn(CurRecordTable, oTextTableHandler, CurDBMetaData, i - CurDBMetaData.GroupFieldNames.length); + } + if (CurDBColumn.xNameCell != null) + { + DBColumnsVector.add(CurDBColumn); + } + else + { + String DelFieldName; + if (i < CurDBMetaData.GroupFieldNames.length) + { + DelFieldName = CurDBMetaData.GroupFieldNames[i]; + CurDBMetaData.GroupFieldNames = JavaTools.removefromList(CurDBMetaData.GroupFieldNames, new String[] + { + DelFieldName + }); + CurDBMetaData.GroupFieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.GroupFieldColumns); + } + else + { + DelFieldName = CurDBMetaData.getRecordFieldName(i - CurDBMetaData.GroupFieldNames.length); + String[] aNewList = JavaTools.removefromList(CurDBMetaData.getRecordFieldNames(), new String[] + { + DelFieldName + }); + CurDBMetaData.setRecordFieldNames(aNewList); + CurDBMetaData.RecordFieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.RecordFieldColumns); + CurDBMetaData.FieldColumns = removeFieldColumnByFieldName(DelFieldName, CurDBMetaData.FieldColumns); + + } + i--; + } + } + java.util.Arrays.sort(CurDBMetaData.RecordFieldColumns, this); + } + catch (Exception exception) + { + showCommonReportErrorBox(exception); + } + } + + public int compare(FieldColumn oFieldColumn1, FieldColumn oFieldColumn2) + { + DBColumn oDBColumn1 = getDBColumnByName(oFieldColumn1.getFieldName()); + DBColumn oDBColumn2 = getDBColumnByName(oFieldColumn2.getFieldName()); + if (oDBColumn1.ValColumn < oDBColumn2.ValColumn) + { + return -1; + } + else if (oDBColumn1.ValColumn == oDBColumn2.ValColumn) + { + return 0; + } + else + { + return 1; + } + } + + private DBColumn getDBColumnByName(String _FieldName) + { + for (int i = 0; i < DBColumnsVector.size(); i++) + { + DBColumn oDBColumn = DBColumnsVector.get(i); + if (oDBColumn.CurDBField.getFieldName().equals(_FieldName)) + { + return oDBColumn; + } + } + throw new IllegalArgumentException("Searching for column " + _FieldName + " failed"); + } + + private static FieldColumn[] removeFieldColumnByFieldName(String _FieldName, FieldColumn[] _FieldColumns) + { + try + { + ArrayList<FieldColumn> aFieldColumns = new ArrayList<FieldColumn>(); + for (int i = 0; i < _FieldColumns.length; i++) + { + FieldColumn CurFieldColumn = _FieldColumns[i]; + if (!CurFieldColumn.getFieldName().equals(_FieldName)) + { + aFieldColumns.add(CurFieldColumn); + } + } + FieldColumn[] aRetList = new FieldColumn[aFieldColumns.size()]; + aFieldColumns.toArray(aRetList); + return aRetList; + } + catch (RuntimeException e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + return null; + } + } + + public void removeAllVisibleTextSections() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sInvisibleSectionNames = new String[GroupCount + 1]; + sInvisibleSectionNames[0] = RECORDSECTION; + for (int i = 1; i <= GroupCount; i++) + { + sInvisibleSectionNames[i] = GROUPSECTION + i; + } + XNameAccess xNameAccessTextSections = UnoRuntime.queryInterface(XNameAccess.class, oTextSectionHandler.xTextSectionsSupplier.getTextSections()); + String[] sSectionNames = xNameAccessTextSections.getElementNames(); + for (int i = 0; i < sSectionNames.length; i++) + { + String sSectionName = sSectionNames[i]; + if (JavaTools.FieldInList(sInvisibleSectionNames, sSectionName) < 0) + { + oTextSectionHandler.removeTextSectionbyName(sSectionName); + } + } + } + + private String[] getLayoutTextTableNames() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sLayoutTableNames = new String[GroupCount + 1]; + for (int i = 0; i < GroupCount; i++) + { + sLayoutTableNames[i] = TBLGROUPSECTION + (i + 1); + } + sLayoutTableNames[GroupCount] = TBLRECORDSECTION; + return sLayoutTableNames; + } + + public void removeNonLayoutTextTables() + { + String[] sLayoutTableNames = getLayoutTextTableNames(); + XNameAccess xNameAccessTextTables = UnoRuntime.queryInterface(XNameAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables()); + String[] sTableNames = xNameAccessTextTables.getElementNames(); + for (int i = 0; i < sTableNames.length; i++) + { + String sTableName = sTableNames[i]; + if (JavaTools.FieldInList(sLayoutTableNames, sTableName) < 0) + { + oTextTableHandler.removeTextTablebyName(sTableName); + } + } + } + + public void removeLayoutTextTables() + { + String[] sLayoutTableNames = getLayoutTextTableNames(); + XNameAccess xNameAccessTextTables = UnoRuntime.queryInterface(XNameAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables()); + XRelativeTextContentRemove xRelativeTextContentRemove = UnoRuntime.queryInterface(XRelativeTextContentRemove.class, xText); + String[] sTableNames = xNameAccessTextTables.getElementNames(); + for (int i = 0; i < sTableNames.length; i++) + { + String sTableName = sTableNames[i]; + if (JavaTools.FieldInList(sLayoutTableNames, sTableName) > -1) + { + if (!sTableName.equals(sLayoutTableNames[0])) + { + XTextContent xTextContent = UnoRuntime.queryInterface(XTextContent.class, oTextTableHandler.getByName(sTableName)); + boolean bleaveloop = false; + while (!bleaveloop) + { + try + { + xRelativeTextContentRemove.removeTextContentAfter(xTextContent); + // IllegalArgumentException may be thrown when no paragraphbreak is there + } + catch (IllegalArgumentException iexception) + { + bleaveloop = true; + } + } + } + oTextTableHandler.removeTextTablebyName(sTableName); + } + } + } + + public void setLayoutSectionsVisible(boolean _IsVisible) + { + try + { + XNameAccess xTextSections = oTextSectionHandler.xTextSectionsSupplier.getTextSections(); + Object oTextSection; + int GroupFieldCount = CurDBMetaData.GroupFieldNames.length; + for (int i = 0; i < GroupFieldCount; i++) + { + oTextSection = xTextSections.getByName(GROUPSECTION + String.valueOf(i + 1)); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); + } + if (xTextSections.hasByName(RECORDSECTION)) + { + oTextSection = xTextSections.getByName(RECORDSECTION); + Helper.setUnoPropertyValue(oTextSection, ISVISIBLE, _IsVisible); + } + } + catch (Exception e) + { + Logger.getLogger(ReportTextDocument.class.getName()).log(Level.SEVERE, null, e); + } + } + + public void removeCopiedTextSections() + { + int GroupCount = CurDBMetaData.GroupFieldNames.length; + String[] sCopyTextSections = new String[GroupCount + 1]; + String[] sCopyTextTables = new String[GroupCount + 1]; + sCopyTextSections[0] = COPYOFRECORDSECTION; + sCopyTextTables[0] = COPYOFTBLRECORDSECTION; + for (int i = 1; i <= GroupCount; i++) + { + sCopyTextSections[i] = COPYOFGROUPSECTION + (i); + sCopyTextTables[i] = COPYOFTBLGROUPSECTION + (i); + } + for (int i = 0; i <= GroupCount; i++) + { + oTextTableHandler.removeTextTablebyName(sCopyTextTables[i]); + oTextSectionHandler.removeTextSectionbyName(sCopyTextSections[i]); + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportTextImplementation.java b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java new file mode 100644 index 000000000..590d54473 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java @@ -0,0 +1,831 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +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.XNameAccess; +import com.sun.star.container.XNameContainer; +import com.sun.star.container.XNamed; +import com.sun.star.frame.XFrame; +import com.sun.star.lang.XComponent; +import com.sun.star.sdb.CommandType; +import com.sun.star.table.XCellRange; +import com.sun.star.text.XTextContent; +import com.sun.star.text.XTextCursor; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextTable; +import com.sun.star.uno.Any; +import com.sun.star.uno.UnoRuntime; +import com.sun.star.uno.XInterface; +import com.sun.star.wizards.common.FileAccess; +import com.sun.star.wizards.common.Helper; +import com.sun.star.wizards.common.InvalidQueryException; +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.PropertyNames; +import com.sun.star.wizards.common.SystemDialog; +import com.sun.star.wizards.db.DBMetaData; +import com.sun.star.wizards.document.OfficeDocument; +import com.sun.star.wizards.ui.UIConsts; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +public class ReportTextImplementation extends ReportImplementationHelper implements IReportDocument +{ + + private ReportTextDocument m_aDoc; + private Object m_aInitialDoc; + private Resource m_resource; + private XDatabaseDocumentUI m_documentUI; + + private void setInitialDocument(Object _aDoc) + { + m_aInitialDoc = _aDoc; + } + + /** + * This is a TEMPORARY function to give direct access to the old text document. + * We have to remove this!!! + * @return + */ + private ReportTextDocument getDoc() + { + if (m_aDoc == null) + { + if (m_aInitialDoc instanceof XTextDocument) + { + 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_resource, getRecordParser()); + } + else + { + throw new RuntimeException("Unknown type for setInitialDocument() given."); + } + } + return m_aDoc; + } + + public void clearDocument() + { + getDoc().oTextSectionHandler.removeAllTextSections(); + getDoc().oTextTableHandler.removeAllTextTables(); + getDoc().DBColumnsVector = new ArrayList<DBColumn>(); + } + + protected ReportTextImplementation( XMultiServiceFactory i_serviceFactory ) + { + super( i_serviceFactory, ReportLayouter.SOOPTLANDSCAPE ); + } + + public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource ) + { + m_documentUI = i_documentUI; + m_resource = i_resource; + + if ( m_aInitialDoc == null ) + setInitialDocument( getLayoutPath() ); + + initialResources(); + } + + static IReportDocument create( XMultiServiceFactory i_serviceFactory, XDatabaseDocumentUI i_documentUI, XTextDocument i_initialDocument, Resource i_resources ) + { + ReportTextImplementation a = new ReportTextImplementation( i_serviceFactory ); + a.setInitialDocument(i_initialDocument); + a.initialize( i_documentUI, i_resources ); + return a; + } + + public XWindowPeer getWizardParent() + { + return getDoc().xWindowPeer; + } + private static String sMsgQueryCreationImpossible; + private static String sReportFormNotExisting; + private static String sMsgEndAutopilot; + + private void initialResources() + { + sReportFormNotExisting = m_resource.getResText("RID_REPORT_64"); + sMsgQueryCreationImpossible = m_resource.getResText("RID_REPORT_65"); + m_resource.getResText("RID_REPORT_66"); + sMsgEndAutopilot = m_resource.getResText("RID_DB_COMMON_33"); + m_resource.getResText("RID_DB_COMMON_14"); + } + + private void addTextSectionCopies() + { + m_aDoc.setLayoutSectionsVisible(false); + XTextCursor xTextCursor = ReportTextDocument.createTextCursor(m_aDoc.xTextDocument.getText()); + xTextCursor.gotoStart(false); + for (int i = 0; i < getRecordParser().GroupFieldNames.length; i++) + { + XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(i + 1), null, null); + xNamedTextSection.setName(ReportTextDocument.COPYOFGROUPSECTION + (i + 1)); + renameTableofLastSection(ReportTextDocument.COPYOFTBLGROUPSECTION + (i + 1)); + } + if (getRecordParser().getRecordFieldNames().length > 0) + { + XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.RECORDSECTION, null, null); + xNamedTextSection.setName(ReportTextDocument.COPYOFRECORDSECTION); + renameTableofLastSection(ReportTextDocument.COPYOFTBLRECORDSECTION); + } + } + + private XNamed addLinkedTextSection(XTextCursor xTextCursor, String sLinkRegion, DBColumn CurDBColumn, Object CurGroupValue) + { + XNamed xNamedTextSection = null; + try + { + XInterface xTextSection = (XInterface) getDocumentServiceFactory().createInstance("com.sun.star.text.TextSection"); + 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); + if (CurDBColumn != null) + { + boolean bIsGroupTable = (!sLinkRegion.equals(ReportTextDocument.RECORDSECTION)); + if (bIsGroupTable) + { + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + XCellRange xCellRange = UnoRuntime.queryInterface( XCellRange.class, xTextTable ); + CurDBColumn.modifyCellContent(xCellRange, CurGroupValue); + } + } + } + catch (Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } + return xNamedTextSection; + } + + private void renameTableofLastSection(String _snewname) + { + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + XNamed xNamedTable = UnoRuntime.queryInterface( XNamed.class, xTextTable ); + xNamedTable.setName(_snewname); + } + + private int showMessageBox(String windowServiceName, int windowAttribute, String MessageText) + { + return SystemDialog.showMessageBox(getMSF(), getWizardParent(), windowServiceName, windowAttribute, MessageText); + } + + public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] _properties) + { + try + { + XNameContainer xNamedForms = getDoc().oFormHandler.getDocumentForms(); + Object oDBForm = Helper.getUnoObjectbyName(xNamedForms, ReportWizard.SOREPORTFORMNAME); + boolean bgetConnection; + if (oDBForm != null) + { + XNameAccess xNamedForm = UnoRuntime.queryInterface( XNameAccess.class, oDBForm ); + getRecordParser().Command = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND); + String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND_TYPE); + String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames"); + String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames"); + String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames"); + + String sorting = PropertyNames.EMPTY_STRING; + if ( xNamedForm.hasByName( "Sorting" ) ) + sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting"); + + String sQueryName = PropertyNames.EMPTY_STRING; + if ( xNamedForm.hasByName( "QueryName" ) ) + sQueryName = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "QueryName"); + + String[] sFieldNameList = JavaTools.ArrayoutofString(sFieldNames, PropertyNames.SEMI_COLON); + String[] sNewList = JavaTools.ArrayoutofString(sRecordFieldNames, PropertyNames.SEMI_COLON); + if ( sorting.length() > 0) + { + String[] sortList = JavaTools.ArrayoutofString(sorting, PropertyNames.SEMI_COLON); + 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, PropertyNames.SEMI_COLON); + int nOrigCommandType = Integer.parseInt(sCommandType); + getRecordParser().setCommandType(nOrigCommandType); + + 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(PropertyNames.EMPTY_STRING))) + { + DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); + if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + { + getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); + } + else + { + nCommandType = com.sun.star.sdb.CommandType.QUERY; + getRecordParser().Command = sQueryName; + } + } + + bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true); + if (bexecute) + { + bexecute = getRecordParser().getFields(sFieldNameList, true); + + boolean addSort = true; + if ( (nOrigCommandType == CommandType.QUERY) && !sQueryName.equals(PropertyNames.EMPTY_STRING) ) + { + DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName); + if (!getRecordParser().hasEscapeProcessing(oCommand.getPropertySet())) + addSort = false; + } + if ( !(addSort && bexecute) ) + { + return bexecute; + } + getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command); + getRecordParser().getSQLQueryComposer().prependSortingCriteria(); + getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery(); + + bexecute = getRecordParser().executeCommand(nCommandType); + } + return bexecute; + } + else + { + return false; + } + } + else + { + sReportFormNotExisting = JavaTools.replaceSubString(sReportFormNotExisting, ReportWizard.SOREPORTFORMNAME, "<REPORTFORM>"); + showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sReportFormNotExisting + (char) 13 + sMsgEndAutopilot); + return false; + } + } + catch (InvalidQueryException queryexception) + { + return false; + } + catch (java.lang.Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + return false; + } + } + private boolean m_bStopProcess; + + public void StopProcess() + { + m_bStopProcess = true; + } + + public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF) + { + try + { + int ColIndex; + boolean breset; + Object oTable; + ArrayList<Object[]> DataVector = new ArrayList<Object[]>(); + DBColumn CurDBColumn; + Object CurGroupValue; + String CurGroupTableName; + getDoc().oTextFieldHandler.fixDateFields(true); + getDoc().removeAllVisibleTextSections(); + getDoc().removeNonLayoutTextTables(); + addTextSectionCopies(); + getDoc().getallDBColumns(); + int GroupFieldCount = getRecordParser().GroupFieldNames.length; + int FieldCount = getRecordParser().FieldColumns.length; + Object[] OldGroupFieldValues = new Object[GroupFieldCount]; + int RecordFieldCount = FieldCount - GroupFieldCount; + XTextDocument xTextDocument = getDoc().xTextDocument; + XTextCursor xTextCursor = ReportTextDocument.createTextCursor(getDoc().xTextDocument.getText()); + xTextDocument.lockControllers(); + + if (getRecordParser().ResultSet.next()) + { + replaceUserFields(); + Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page"); + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurGroupTableName = ReportTextDocument.TBLGROUPSECTION + Integer.toString(ColIndex + 1); + oTable = getDoc().oTextTableHandler.xTextTablesSupplier.getTextTables().getByName(CurGroupTableName); + CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex); + OldGroupFieldValues[ColIndex] = CurGroupValue; + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); //COPYOF!!!! + } + if (getRecordParser().getcurrentRecordData(DataVector)) + { + m_bStopProcess = false; + while ((getRecordParser().ResultSet.next()) && (!m_bStopProcess)) + { + breset = false; + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex); + if ((!CurGroupValue.equals(OldGroupFieldValues[ColIndex])) || (breset)) + { + breset = true; + insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount); + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); + OldGroupFieldValues[ColIndex] = CurGroupValue; + breset = ColIndex != GroupFieldCount - 1; + } + } + getRecordParser().getcurrentRecordData(DataVector); + } + insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount); + } + else + { + getDoc().unlockallControllers(); + return; + } + } + else + { + for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++) + { + CurDBColumn = getDoc().DBColumnsVector.get(ColIndex); + Object oValue = PropertyNames.EMPTY_STRING; + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, oValue); + } + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null); + Object[][] RecordArray = new Object[1][RecordFieldCount]; + for (int i = 0; i < RecordArray[0].length; i++) + { + RecordArray[0][i] = Any.VOID; + } + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1); + } + getDoc().oTextSectionHandler.breakLinkofTextSections(); + } + catch (Exception ex) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex ); + } + getDoc().unlockallControllers(); + getDoc().setLayoutSectionsVisible(false); + getDoc().removeCopiedTextSections(); + getDoc().oTextSectionHandler.removeInvisibleTextSections(); + getDoc().removeLayoutTextTables(); + } + + private void insertDataToRecordTable(XTextCursor xTextCursor, ArrayList<Object[]> DataVector, int FieldCount) + { + int DataLength = DataVector.size(); + if ((FieldCount > 0) && (DataLength > 0)) + { + addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null); + Object[][] RecordArray = new Object[DataLength][FieldCount]; + DataVector.toArray(RecordArray); + XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable(); + if (DataLength > 1) + { + xTextTable.getRows().insertByIndex(xTextTable.getRows().getCount(), DataLength - 1); + } + OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1); + } + DataVector.clear(); + } + private void replaceUserFields() + { + DBColumn CurDBColumn; + XTextCursor xNameCellCursor; + String FieldContent; + int iCount = getDoc().DBColumnsVector.size(); + for (int i = 0; i < iCount; i++) + { + CurDBColumn = getDoc().DBColumnsVector.get(i); + xNameCellCursor = ReportTextDocument.createTextCursor(CurDBColumn.xNameCell); + xNameCellCursor.gotoStart(false); + FieldContent = getDoc().oTextFieldHandler.getUserFieldContent(xNameCellCursor); + if (!FieldContent.equals(PropertyNames.EMPTY_STRING)) + { + xNameCellCursor.goRight((short) 1, true); + xNameCellCursor.setString(FieldContent); + } + } + } + + public XFrame getFrame() + { + return m_aDoc.xFrame; + } + + private XMultiServiceFactory getDocumentServiceFactory() + { + return m_aDoc.xMSFDoc; + } + + public void store(String _sName, int _nOpenMode) throws com.sun.star.uno.Exception + { + getDoc().createReportForm(ReportWizard.SOREPORTFORMNAME); + getDoc().oTextFieldHandler.updateDateFields(); + getDoc().oTextFieldHandler.fixDateFields(false); + if ((_nOpenMode == ReportFinalizer.SOCREATETEMPLATE || _nOpenMode == ReportFinalizer.SOUSETEMPLATE)) + { + getDoc().oTextSectionHandler.breakLinkofTextSections(); + getRecordParser().storeDatabaseDocumentToTempPath(getComponent(), _sName); + } + } + + public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector, ArrayList<String> ReportPath, int iSelCount) + { + return getDoc().addGroupNametoDocument(CurGroupTitle, GroupFieldVector, ReportPath, iSelCount); + } + + public void refreshGroupFields(String[] _sNewNames) + { + getDoc().refreshGroupFields(_sNewNames); + } + + public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, ArrayList<String> GroupFieldVector) + { + getDoc().removeGroupName(NewSelGroupNames, CurGroupTitle, GroupFieldVector); + } + + public void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException + { + // LLA: should we lock controllers here? + // CurReportDocument.getDoc().xTextDocument.lockControllers(); + if (nOrientation == ReportLayouter.SOOPTLANDSCAPE) + { + getDoc().changePageOrientation(true); + } + else if (nOrientation == ReportLayouter.SOOPTPORTRAIT) + { + getDoc().changePageOrientation(false); + } + else + { + throw new com.sun.star.lang.IllegalArgumentException("Unknown Orientation."); + } + } + + public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/) + { + getDoc().swapLayoutTemplate(LayoutTemplatePath/*, BitmapPath*/); + } + + public void liveupdate_changeContentTemplate(String ContentTemplatePath) + { + getDoc().swapContentTemplate(ContentTemplatePath); + } + + public void layout_setupRecordSection(String TemplateName) + { + getDoc().setupRecordSection(TemplateName); + } + + public void removeTextTableAndTextSection() + { + getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection"); + getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection"); + } + + public void layout_selectFirstPage() + { + getDoc().oViewHandler.selectFirstPage(getDoc().oTextTableHandler); + } + + public void dispose() + { + OfficeDocument.dispose(getMSF(), getComponent()); + } + + public XComponent getComponent() + { + return getDoc().xComponent; + } + + public void liveupdate_changeUserFieldContent(String fieldname, String sfieldtitle) + { + getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); + } + + public void liveupdate_updateReportTitle(String _sTitleName) + { + } + + public void addReportToDBView() + { + getRecordParser().addReportDocument(getComponent(), true); + } + + public void createAndOpenReportDocument( String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign ) + { + 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) + { + getRecordParser().initializeFieldColumns(FieldNames, TableName); + } + + public void setFieldTitles(String[] sFieldTitles) + { + getRecordParser().setFieldTitles(sFieldTitles); + } + + public void setSorting(String[][] aSortFieldNames) + { + getRecordParser().setSortFieldNames(aSortFieldNames); + } + + public void setGrouping(String[] aGroupFieldNames) + { + getRecordParser().prependSortFieldNames(aGroupFieldNames); + } + +// TODO: we have to change to String List!!!! + private ArrayList<String> m_aReportPath = null; + + public ArrayList<String> getReportPath() + { + if (m_aReportPath == null) + { + // Check general availability of office paths + try + { + m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template"); + FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report"); + } + catch (Exception e) + { + Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, e ); + } + } + return m_aReportPath; + } + + public String getContentPath() + { + ArrayList<String> aReportPath = getReportPath(); + for (int i = 0; i < aReportPath.size(); i++) + { + String sPath = aReportPath.get(i); + sPath += "/cnt-default.ott"; + if (FileAccess.isPathValid(getMSF(), sPath)) + { + return sPath; + } + } + return PropertyNames.EMPTY_STRING; + } + + public String getLayoutPath() + { + ArrayList<String> aReportPath = getReportPath(); + for (int i = 0; i < aReportPath.size(); i++) + { + String sPath = aReportPath.get(i); + sPath += "/stl-default.ott"; + if (FileAccess.isPathValid(getMSF(), sPath)) + { + return sPath; + } + } + return PropertyNames.EMPTY_STRING; + } + + public int getDefaultPageOrientation() + { + return m_nDefaultPageOrientation; + } + + public String[][] getDataLayout() + { + String[][] ContentFiles; + try + { + ContentFiles = FileAccess.getFolderTitles(getMSF(), "cnt", getReportPath()); + exchangeContentTitlesWithLocalisedOnes(ContentFiles); + } + catch (com.sun.star.wizards.common.NoValidPathException e) + { + ContentFiles = new String[2][]; + String[] a = new String[] { "DefaultLayoutOfData" }; + String[] b = new String[] { "default" }; + ContentFiles[1] = a; + ContentFiles[0] = b; + } + return ContentFiles; + } + + public String[][] getHeaderLayout() + { + String[][] LayoutFiles; + try + { + LayoutFiles = FileAccess.getFolderTitles(getMSF(), "stl", getReportPath()); + exchangeLayoutTitlesWithLocalisedOnes(LayoutFiles); + } + catch (com.sun.star.wizards.common.NoValidPathException e) + { + LayoutFiles = new String[2][]; + String[] a = new String[] { "DefaultLayoutOfHeaders" }; + String[] b = new String[] { "default" }; + LayoutFiles[1] = a; + LayoutFiles[0] = b; + } + return LayoutFiles; + } + + public void importReportData(ReportWizard _aWizard) + { + Dataimport CurDataimport = new Dataimport(_aWizard.xMSF); + CurDataimport.CurReportDocument = this; + _aWizard.importReportData(_aWizard.xMSF, CurDataimport); + } + + public void setCommandType(int _nCommand) + { + // already set somewhere else + } + + public void setCommand(String _sCommand) + { + getRecordParser().Command = _sCommand; + } + + public void checkInvariants() throws java.lang.Exception + { + } + + private void exchangeContentTitlesWithLocalisedOnes(String[][] ContentFiles) + { + for(int i = 0; i < ContentFiles[0].length; ++i) + { + if( ContentFiles[0][i].equals("Align Left - Border") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_94"); + } + else if( ContentFiles[0][i].equals("Align Left - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_95"); + } + else if( ContentFiles[0][i].equals("Align Left - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_96"); + } + else if( ContentFiles[0][i].equals("Align Left - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_97"); + } + else if( ContentFiles[0][i].equals("Align Left - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_98"); + } + else if( ContentFiles[0][i].equals("Align Left - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_99"); + } + else if( ContentFiles[0][i].equals("Default") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_100"); + } + else if( ContentFiles[0][i].equals("Outline - Borders") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_101"); + } + else if( ContentFiles[0][i].equals("Outline - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_102"); + } + else if( ContentFiles[0][i].equals("Outline - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_103"); + } + else if( ContentFiles[0][i].equals("Outline - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_104"); + } + else if( ContentFiles[0][i].equals("Outline - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_105"); + } + else if( ContentFiles[0][i].equals("Outline - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_106"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Borders") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_107"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Compact") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_108"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Elegant") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_109"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Highlighted") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_110"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Modern") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_111"); + } + else if( ContentFiles[0][i].equals("Outline, indented - Red & Blue") ) + { + ContentFiles[0][i] = m_resource.getResText("RID_REPORT_112"); + } + } + } + + private void exchangeLayoutTitlesWithLocalisedOnes(String[][] LayoutFiles) + { + for(int i = 0; i < LayoutFiles[0].length; ++i) + { + if( LayoutFiles[0][i].equals("Bubbles") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_113"); + } + else if( LayoutFiles[0][i].equals("Cinema") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_114"); + } + else if( LayoutFiles[0][i].equals("Controlling") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_115"); + } + else if( LayoutFiles[0][i].equals("Default") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_116"); + } + else if( LayoutFiles[0][i].equals("Drafting") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_117"); + } + else if( LayoutFiles[0][i].equals("Finances") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_118"); + } + else if( LayoutFiles[0][i].equals("Flipchart") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_119"); + } + else if( LayoutFiles[0][i].equals("Formal with Company Logo") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_120"); + } + else if( LayoutFiles[0][i].equals("Generic") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_121"); + } + else if( LayoutFiles[0][i].equals("Worldmap") ) + { + LayoutFiles[0][i] = m_resource.getResText("RID_REPORT_122"); + } + } + } +} diff --git a/wizards/com/sun/star/wizards/report/ReportWizard.java b/wizards/com/sun/star/wizards/report/ReportWizard.java new file mode 100644 index 000000000..1b3eff175 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/ReportWizard.java @@ -0,0 +1,676 @@ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ +package com.sun.star.wizards.report; + +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.container.XContentEnumerationAccess; +import com.sun.star.lang.EventObject; +import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.logging.XLogger; +import com.sun.star.logging.XLoggerPool; +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.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.common.PropertyNames; +import com.sun.star.wizards.db.DBMetaData; +import com.sun.star.wizards.db.DatabaseObjectWizard; +import com.sun.star.wizards.db.RecordParser; +import com.sun.star.wizards.db.SQLQueryComposer; +import com.sun.star.wizards.ui.CommandFieldSelection; +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 java.lang.reflect.Method; +import java.util.Map; + +public class ReportWizard extends DatabaseObjectWizard implements XTextListener +{ + private SortingComponent CurSortingComponent; + private TitlesComponent CurTitlesComponent; + private CommandFieldSelection CurDBCommandFieldSelection; + private GroupFieldHandler CurGroupFieldHandler; + private ReportLayouter CurReportLayouter; + private ReportFinalizer CurReportFinalizer; + private int nReportMode = ReportFinalizer.SOCREATEDOCUMENT; + private String m_sReportName = PropertyNames.EMPTY_STRING; + protected static final String SOREPORTFORMNAME = "ReportSource"; + private static final int SOMAINPAGE = 1; + private static final int SOTITLEPAGE = 2; + protected static final int SOGROUPPAGE = 3; + private static final int SOSORTPAGE = 4; + protected static final int SOTEMPLATEPAGE = 5; + protected static final int SOSTOREPAGE = 6; + private IReportDocument m_reportDocument; + private static String sMsgWizardName; + private static String slblFields; + private static String slblSelFields; + private static String sShowBinaryFields; + private String[] WizardHeaderText = new String[6]; + private static String slblColumnTitles; + private static String slblColumnNames; + private static String slblTables; + protected static boolean bCloseDocument; + private boolean bHasEscapeProcessing = true; + + public ReportWizard(XMultiServiceFactory i_serviceFactory, final PropertyValue[] i_wizardContext) + { + super(i_serviceFactory, 34320, i_wizardContext); + super.addResourceHandler(); + if (getReportResources(false)) + { + Helper.setUnoPropertyValues(xDialogModel, + new String[] + { + PropertyNames.PROPERTY_HEIGHT, + PropertyNames.PROPERTY_MOVEABLE, + PropertyNames.PROPERTY_NAME, + PropertyNames.PROPERTY_POSITION_X, + PropertyNames.PROPERTY_POSITION_Y, + PropertyNames.PROPERTY_STEP, + PropertyNames.PROPERTY_TABINDEX, + PropertyNames.PROPERTY_TITLE, + PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + Integer.valueOf(210), + Boolean.TRUE, + "DialogReport", + 102, + 41, + 1, + Short.valueOf((short) 0), + sMsgWizardName, + 310 + }); + drawNaviBar(); + setRightPaneHeaders(this.WizardHeaderText); + } + } + + @Override + protected void enterStep(int nOldStep, int nNewStep) + { + if ((nOldStep >= SOTEMPLATEPAGE) && (nNewStep < SOTEMPLATEPAGE)) + { + m_reportDocument.removeTextTableAndTextSection(); + } + switch (nNewStep) + { + case SOMAINPAGE: + CurDBCommandFieldSelection.setModified(false); + break; + + case SOTITLEPAGE: + String[] aFieldNames = m_reportDocument.getRecordParser().getFieldNames(); + Map<String, String> aFieldTitleSet = m_reportDocument.getRecordParser().getFieldTitleSet(); + CurTitlesComponent.initialize(aFieldNames, aFieldTitleSet); + break; + + case SOGROUPPAGE: + CurGroupFieldHandler.initialize(); + break; + + case SOSORTPAGE: + String[] aFieldNames2 = m_reportDocument.getRecordParser().getFieldNames(); + String[][] aSortFieldNames = m_reportDocument.getRecordParser().getSortFieldNames(); + CurSortingComponent.initialize(aFieldNames2, aSortFieldNames); + int nLength = m_reportDocument.getRecordParser().GroupFieldNames.length; + CurSortingComponent.setReadOnlyUntil(nLength); + break; + + case SOTEMPLATEPAGE: + break; + + case SOSTOREPAGE: + //TODO initialize with suitable PathName + CurReportFinalizer.initialize(m_reportDocument.getRecordParser()); + break; + + default: + break; + } + } + + @Override + protected void leaveStep(int nOldStep, int nNewStep) + { + + switch (nOldStep) + { + case SOMAINPAGE: + String[] aSelectedFieldNames = CurDBCommandFieldSelection.getSelectedFieldNames(); + String aTableName = CurDBCommandFieldSelection.getSelectedCommandName(); + int nType = CurDBCommandFieldSelection.getSelectedCommandType(); + m_reportDocument.initializeFieldColumns(nType, aTableName, aSelectedFieldNames); + if (CurDBCommandFieldSelection.isModified()) + { + // cleanup document + m_reportDocument.clearDocument(); + m_reportDocument.getRecordParser().setGroupFieldNames(new String[] + { + }); + CurGroupFieldHandler.removeGroupFieldNames(); + } + break; + + case SOTITLEPAGE: + String[] sFieldTitles = CurTitlesComponent.getFieldTitles(); + // set new field name titles + // CurReportDocument.getRecordParser().setFieldTitles(sFieldTitles); + m_reportDocument.setFieldTitles(sFieldTitles); + break; + + case SOGROUPPAGE: + // TODO: DESIGN!!! a getter should return a value!!! + CurGroupFieldHandler.getGroupFieldNames(m_reportDocument.getRecordParser()); + String[] aGroupFieldNames = m_reportDocument.getRecordParser().GroupFieldNames; + // CurReportDocument.getRecordParser().prependSortFieldNames(aGroupFieldNames); + m_reportDocument.setGrouping(aGroupFieldNames); + break; + + case SOSORTPAGE: + String[][] aSortFieldNames = CurSortingComponent.getSortFieldNames(); + // CurReportDocument.getRecordParser().SortFieldNames = aSortFieldNames; + m_reportDocument.setSorting(aSortFieldNames); + // TODO: why do we make a switch here + super.enablefromStep(SOTEMPLATEPAGE, true); + break; + + case SOTEMPLATEPAGE: + break; + + case SOSTOREPAGE: + break; + + default: + break; + } + + if ((nOldStep < SOTEMPLATEPAGE) && (super.getNewStep() >= SOTEMPLATEPAGE)) + { +// this is called before SOTEMPLATEPAGE, after SOGROUPPAGE + m_reportDocument.getRecordParser().createRecordFieldNames(); + CurReportLayouter.initialize(m_reportDocument.getContentPath()); + } + } + + private void dialogFinish() + { + this.xComponent.dispose(); + if (bCloseDocument) + { + 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); + } + } + + private boolean executeQuery() + { + boolean bQueryCreated = false; + final RecordParser recordParser = m_reportDocument.getRecordParser(); + final SQLQueryComposer sqlQueryComposer = recordParser.getSQLQueryComposer(); + if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE) + { + if (m_reportDocument instanceof ReportTextImplementation) + { + bQueryCreated = sqlQueryComposer.setQueryCommand(this.xWindow, false, false); + m_reportDocument.setCommandType(CommandType.COMMAND); + String sQuery = sqlQueryComposer.getQuery(); + m_reportDocument.setCommand(sQuery); + } + else + { + bQueryCreated = true; + } + } + else + { + try + { + String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); + DBMetaData.CommandObject oCommand = recordParser.getQueryByName(sQueryName); + bHasEscapeProcessing = recordParser.hasEscapeProcessing(oCommand.getPropertySet()); + String sCommand = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND); + if (bHasEscapeProcessing) + { + if (m_reportDocument instanceof ReportTextImplementation) + { + sqlQueryComposer.m_xQueryAnalyzer.setQuery(sCommand); + sqlQueryComposer.prependSortingCriteria(); + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(sqlQueryComposer.getQuery()); + } + } + else + { + m_reportDocument.setCommandType(CommandType.COMMAND); + m_reportDocument.setCommand(sCommand); + } + bQueryCreated = true; + } + catch (Exception e) + { + e.printStackTrace(System.err); + } + } + if (!bQueryCreated) + { + super.vetoableChange(null); + } + return bQueryCreated; + } + + private void buildSteps() + { + // CurReportDocument.getDoc().xProgressBar.setValue(30); + CurDBCommandFieldSelection = new CommandFieldSelection(this, m_reportDocument.getRecordParser(), 100, slblFields, slblSelFields, slblTables, true, 34330); + CurDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener()); + if (!isReportBuilderInstalled()) + { + insertLabel("lblBinaryFields", + new String[] + { + PropertyNames.PROPERTY_HEIGHT, PropertyNames.PROPERTY_LABEL, PropertyNames.PROPERTY_POSITION_X, PropertyNames.PROPERTY_POSITION_Y, PropertyNames.PROPERTY_STEP, PropertyNames.PROPERTY_WIDTH + }, + new Object[] + { + 16, sShowBinaryFields, 95, 162, 1, 210 + }); + } + CurTitlesComponent = new TitlesComponent(this, SOTITLEPAGE, 97, 37, 210, 7, slblColumnNames, slblColumnTitles, 34381); + CurTitlesComponent.addTextListener(this); + CurGroupFieldHandler = new GroupFieldHandler(m_reportDocument, this); + CurSortingComponent = new SortingComponent(this, SOSORTPAGE, 95, 30, 210, 34348); + CurReportLayouter = new ReportLayouter(xMSF, m_reportDocument, this, isReportBuilderInstalled()); + CurReportFinalizer = new ReportFinalizer(m_reportDocument, this); + bCloseDocument = true; + enableNavigationButtons(false, false, false); + } + + @Override + public boolean finishWizard() + { + final int ncurStep = getCurrentStep(); + if ((switchToStep(ncurStep, SOSTOREPAGE)) || (ncurStep == SOSTOREPAGE)) + { + if (this.executeQuery()) + { + if (CurReportFinalizer.finish()) + { + nReportMode = CurReportFinalizer.getReportOpenMode(); + m_sReportName = CurReportFinalizer.getStoreName(); + xDialog.endExecute(); + return true; + } + } + } + return false; + } + + @Override + public void cancelWizard() + { + xDialog.endExecute(); + } + + private void insertQueryRelatedSteps() + { + setRMItemLabels(m_oResource); + addRoadmap(); + int i = 0; + i = insertRoadmapItem(0, true, m_oResource.getResText("RID_QUERY_80"), SOMAINPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_68"), SOTITLEPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_11"), SOGROUPPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_12"), SOSORTPAGE); // Orderby is always supported + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_13"), SOTEMPLATEPAGE); + i = insertRoadmapItem(i, false, m_oResource.getResText("RID_REPORT_14"), SOSTOREPAGE); + setRoadmapInteractive(true); + setRoadmapComplete(true); + setCurrentRoadmapItemID((short) 1); + } + + private boolean isReportBuilderInstalled() + { + //! Check if the new Report Builder Extension is available + XContentEnumerationAccess a = com.sun.star.uno.UnoRuntime.queryInterface(XContentEnumerationAccess.class, xMSF); + com.sun.star.container.XEnumeration e = a.createContentEnumeration("org.libreoffice.report.pentaho.SOReportJobFactory"); + if (e == null) + { + return false; + } + return e.hasMoreElements(); + } + + private static XLogger m_xLogger; + + private static void initializeLogger(XMultiServiceFactory _xMSF) + { + XComponentContext xContext = Helper.getComponentContext(_xMSF); + + final Object aLoggerPool = xContext.getValueByName("/singletons/com.sun.star.logging.LoggerPool"); + if (aLoggerPool == null) + { + System.out.println("Can't get singleton from logging"); + } + final XLoggerPool xLoggerPool = UnoRuntime.queryInterface(XLoggerPool.class, aLoggerPool); + m_xLogger = xLoggerPool.getNamedLogger("com.sun.star.wizards.ReportBuilder"); + } + + public static XLogger getLogger() + { + return m_xLogger; + } + + public void startReportWizard() + { + initializeLogger(xMSF); + getLogger().log(LogLevel.SEVERE, "Start Report Wizard"); + + if (isReportBuilderInstalled()) + { + Class<?> a = null; + try + { + a = Class.forName("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation"); + } + catch (ClassNotFoundException e) + { + System.err.println("ReportBuilderImplementation is unavailable"); + } + if (a != null) + { + try + { + Method aMethod = a.getMethod("create", new Class[] + { + XMultiServiceFactory.class + }); + m_reportDocument = (IReportDocument) aMethod.invoke(a, xMSF + ); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + } + + try + { + if (m_reportDocument == null) + { + // Fallback, if there is no reportbuilder wizard implementation, we use the old wizard + m_reportDocument = new ReportTextImplementation(xMSF); + } + + m_reportDocument.initialize(m_docUI, m_oResource); + + if (m_reportDocument.getRecordParser().getConnection(m_wizardContext)) + { + buildSteps(); + + if(!isReportBuilderInstalled()) CurReportLayouter.drawConstants(); + + m_reportDocument.checkInvariants(); + + this.CurDBCommandFieldSelection.preselectCommand(m_wizardContext, false); + + createWindowPeer(m_reportDocument.getWizardParent()); + + m_reportDocument.getRecordParser().setWindowPeer(this.xControl.getPeer()); + insertQueryRelatedSteps(); + short RetValue = executeDialog(m_reportDocument.getFrame().getComponentWindow().getPosSize()); + if (RetValue == 0) + { + dialogFinish(); + } + } + m_reportDocument.getRecordParser().dispose(); + } + catch (java.io.IOException e) + { + String sMessage = e.getMessage(); + if (sMessage.equals("default.otr")) + { + sMessage = m_oResource.getResText("RID_REPORT_92"); + } + // show a dialog with the error message + SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMessage); + } + catch (java.lang.Exception jexception) + { + jexception.printStackTrace(System.err); + } + } + + public void importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport) + { + boolean bDocisStored = false; + try + { + boolean bexecute = false; + if (!bHasEscapeProcessing) + { + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.QUERY); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + } + else + { + bexecute = m_reportDocument.getRecordParser().executeCommand(com.sun.star.sdb.CommandType.COMMAND); // sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot)) + } + if (bexecute) + { + bexecute = m_reportDocument.getRecordParser().getFields(m_reportDocument.getRecordParser().getFieldNames(), false); + } + if (bexecute) + { + // CurDataimport.insertDatabaseDatatoReportDocument(xMSF); + m_reportDocument.insertDatabaseDatatoReportDocument(xMSF); + } + + if (CurReportFinalizer.getReportOpenMode() == ReportFinalizer.SOCREATEDOCUMENT) + { + bDocisStored = m_reportDocument.getRecordParser().storeDatabaseDocumentToTempPath(m_reportDocument.getComponent(), CurReportFinalizer.getStoreName()); + } + } + catch (com.sun.star.wizards.common.InvalidQueryException queryexception) + { + } + CurDataimport.xComponent.dispose(); + if (bDocisStored) + { + m_reportDocument.getRecordParser().addReportDocument(m_reportDocument.getComponent(), false); + } + m_reportDocument.getRecordParser().dispose(); + } + + private boolean getReportResources(boolean bgetProgressResourcesOnly) + { + sMsgWizardName = super.m_oResource.getResText("RID_REPORT_0"); + if (!bgetProgressResourcesOnly) + { + sShowBinaryFields = m_oResource.getResText("RID_REPORT_60"); + slblTables = m_oResource.getResText("RID_FORM_6"); + slblFields = m_oResource.getResText("RID_FORM_12"); + slblSelFields = m_oResource.getResText("RID_REPORT_9"); + WizardHeaderText[0] = m_oResource.getResText("RID_REPORT_28"); + WizardHeaderText[1] = m_oResource.getResText("RID_REPORT_69"); + WizardHeaderText[2] = m_oResource.getResText("RID_REPORT_29"); + WizardHeaderText[3] = m_oResource.getResText("RID_REPORT_30"); + WizardHeaderText[4] = m_oResource.getResText("RID_REPORT_31"); + WizardHeaderText[5] = m_oResource.getResText("RID_REPORT_32"); + } + slblColumnTitles = m_oResource.getResText("RID_REPORT_70"); + slblColumnNames = m_oResource.getResText("RID_REPORT_71"); + return true; + } + + public static String getBlindTextNote(Object _aDocument, Resource _oResource) + { + String sBlindTextNote = PropertyNames.EMPTY_STRING; + if (_aDocument instanceof ReportTextImplementation) + { + sBlindTextNote = _oResource.getResText("RID_REPORT_75"); + sBlindTextNote = JavaTools.replaceSubString(sBlindTextNote, String.valueOf((char) 13), "<BR>"); + } + return sBlindTextNote; + } + + private void enableRoadmapItems(boolean _bEnabled) + { + try + { + Object oRoadmapItem = null; + int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, PropertyNames.PROPERTY_STEP)); + boolean bEnabled = false; + int CurItemID; + for (int i = 0; i < getRMItemCount(); i++) + { + oRoadmapItem = this.xIndexContRoadmap.getByIndex(i); + CurItemID = AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmapItem, "ID")); + if (CurItemID > CurStep) + { + bEnabled = _bEnabled; + } + else + { + bEnabled = true; + } + + Helper.setUnoPropertyValue(oRoadmapItem, PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + } + } + catch (com.sun.star.uno.Exception exception) + { + exception.printStackTrace(System.err); + } + } + + private void enableWizardSteps(String[] NewItems) + { + boolean bEnabled = NewItems.length > 0; + setControlProperty("btnWizardNext", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + setControlProperty("btnWizardFinish", PropertyNames.PROPERTY_ENABLED, Boolean.valueOf(bEnabled)); + enableRoadmapItems(bEnabled); // Note: Performance wise this could be improved + } + + public void textChanged(TextEvent xTextEvent) + { + try + { + Object oModel = UnoDialog.getModel(xTextEvent.Source); + String sContent = (String) Helper.getUnoPropertyValue(oModel, "Text"); + String fieldname = this.CurTitlesComponent.getFieldNameByTitleControl(oModel); + // CurReportDocument.getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle); + m_reportDocument.liveupdate_changeUserFieldContent(fieldname, sContent); + } + catch (Exception exception) + { + exception.printStackTrace(System.err); + } + } + + @Override + public void disposing(EventObject EventObject) + { + } + + private void toggleSortingPage() + { + int nlCommandType = this.CurDBCommandFieldSelection.getSelectedCommandType(); + boolean bdoenable = (nlCommandType == CommandType.TABLE); + if (!bdoenable) + { + String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName(); + DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName); + bdoenable = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()); + } + super.setStepEnabled(SOSORTPAGE, bdoenable); + } + + private class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener + { + + private int m_nID; + + public void setID(String sIncSuffix) + { + m_nID = 1; + if (sIncSuffix != null) + { + if ((!sIncSuffix.equals(PropertyNames.EMPTY_STRING)) && (!sIncSuffix.equals("_"))) + { + String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1]; + m_nID = Integer.parseInt(sID); + } + } + } + + public void shiftFromLeftToRight(String[] SelItems, String[] NewItems) + { + if (m_nID == 1) + { + CurDBCommandFieldSelection.setModified(true); + enableWizardSteps(NewItems); + toggleSortingPage(); + } + } + + public void shiftFromRightToLeft(String[] SelItems, String[] NewItems) + { + // TODO When the ListFieldbox is refilled only fields of the current Command may be merged into the Listbox + if (m_nID == 1) + { + enableWizardSteps(NewItems); + CurDBCommandFieldSelection.setModified(true); + } + } + + public void moveItemDown(String item) + { + } + + public void moveItemUp(String item) + { + } + } +} diff --git a/wizards/com/sun/star/wizards/report/report.component b/wizards/com/sun/star/wizards/report/report.component new file mode 100644 index 000000000..68c8ce940 --- /dev/null +++ b/wizards/com/sun/star/wizards/report/report.component @@ -0,0 +1,26 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + --> + +<component loader="com.sun.star.loader.Java2" + xmlns="http://openoffice.org/2010/uno-components"> + <implementation name= + "com.sun.star.wizards.report.CallReportWizard$ReportWizardImplementation"> + <service name="com.sun.star.wizards.report.CallReportWizard"/> + </implementation> +</component> |