summaryrefslogtreecommitdiff
path: root/wizards/com/sun
diff options
context:
space:
mode:
Diffstat (limited to 'wizards/com/sun')
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaTemplate.java1961
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java385
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java109
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java597
-rw-r--r--wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java221
-rw-r--r--wizards/com/sun/star/wizards/agenda/CGAgenda.java83
-rw-r--r--wizards/com/sun/star/wizards/agenda/CGTopic.java87
-rw-r--r--wizards/com/sun/star/wizards/agenda/CallWizard.java224
-rw-r--r--wizards/com/sun/star/wizards/agenda/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/agenda/TemplateConsts.java146
-rw-r--r--wizards/com/sun/star/wizards/agenda/TopicsControl.java1321
-rw-r--r--wizards/com/sun/star/wizards/agenda/agenda.component35
-rw-r--r--wizards/com/sun/star/wizards/agenda/makefile.mk79
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigGroup.java183
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigNode.java53
-rw-r--r--wizards/com/sun/star/wizards/common/ConfigSet.java452
-rw-r--r--wizards/com/sun/star/wizards/common/Configuration.java457
-rw-r--r--wizards/com/sun/star/wizards/common/DebugHelper.java58
-rw-r--r--wizards/com/sun/star/wizards/common/Desktop.java509
-rw-r--r--wizards/com/sun/star/wizards/common/FileAccess.java1200
-rw-r--r--wizards/com/sun/star/wizards/common/HelpIds.java1047
-rw-r--r--wizards/com/sun/star/wizards/common/Helper.java444
-rw-r--r--wizards/com/sun/star/wizards/common/IRenderer.java40
-rw-r--r--wizards/com/sun/star/wizards/common/Indexable.java44
-rw-r--r--wizards/com/sun/star/wizards/common/InvalidQueryException.java40
-rw-r--r--wizards/com/sun/star/wizards/common/JavaTools.java785
-rw-r--r--wizards/com/sun/star/wizards/common/MANIFEST.MF1
-rw-r--r--wizards/com/sun/star/wizards/common/NamedValueCollection.java90
-rw-r--r--wizards/com/sun/star/wizards/common/NoValidPathException.java44
-rw-r--r--wizards/com/sun/star/wizards/common/NumberFormatter.java333
-rw-r--r--wizards/com/sun/star/wizards/common/NumericalHelper.java1625
-rw-r--r--wizards/com/sun/star/wizards/common/Properties.java126
-rw-r--r--wizards/com/sun/star/wizards/common/PropertySetHelper.java396
-rw-r--r--wizards/com/sun/star/wizards/common/Resource.java143
-rw-r--r--wizards/com/sun/star/wizards/common/SystemDialog.java428
-rw-r--r--wizards/com/sun/star/wizards/common/TerminateWizardException.java43
-rw-r--r--wizards/com/sun/star/wizards/common/UCB.java269
-rw-r--r--wizards/com/sun/star/wizards/common/XMLHelper.java74
-rw-r--r--wizards/com/sun/star/wizards/common/XMLProvider.java46
-rw-r--r--wizards/com/sun/star/wizards/common/delzip0
-rw-r--r--wizards/com/sun/star/wizards/db/BlindtextCreator.java113
-rw-r--r--wizards/com/sun/star/wizards/db/ColumnPropertySet.java213
-rw-r--r--wizards/com/sun/star/wizards/db/CommandMetaData.java772
-rw-r--r--wizards/com/sun/star/wizards/db/CommandName.java267
-rw-r--r--wizards/com/sun/star/wizards/db/DBMetaData.java1103
-rw-r--r--wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java76
-rw-r--r--wizards/com/sun/star/wizards/db/FieldColumn.java471
-rw-r--r--wizards/com/sun/star/wizards/db/MANIFEST.MF0
-rw-r--r--wizards/com/sun/star/wizards/db/QueryMetaData.java300
-rw-r--r--wizards/com/sun/star/wizards/db/RecordParser.java306
-rw-r--r--wizards/com/sun/star/wizards/db/RelationController.java161
-rw-r--r--wizards/com/sun/star/wizards/db/SQLQueryComposer.java489
-rw-r--r--wizards/com/sun/star/wizards/db/TableDescriptor.java861
-rw-r--r--wizards/com/sun/star/wizards/db/TypeInspector.java465
-rw-r--r--wizards/com/sun/star/wizards/document/Control.java359
-rw-r--r--wizards/com/sun/star/wizards/document/DatabaseControl.java269
-rw-r--r--wizards/com/sun/star/wizards/document/FormHandler.java594
-rw-r--r--wizards/com/sun/star/wizards/document/GridControl.java93
-rw-r--r--wizards/com/sun/star/wizards/document/OfficeDocument.java459
-rw-r--r--wizards/com/sun/star/wizards/document/Shape.java142
-rw-r--r--wizards/com/sun/star/wizards/document/TimeStampControl.java172
-rw-r--r--wizards/com/sun/star/wizards/fax/CGFax.java60
-rw-r--r--wizards/com/sun/star/wizards/fax/CGFaxWizard.java38
-rw-r--r--wizards/com/sun/star/wizards/fax/CallWizard.java240
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxDocument.java212
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialog.java628
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.java116
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java873
-rw-r--r--wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.java182
-rw-r--r--wizards/com/sun/star/wizards/fax/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/fax/fax.component35
-rw-r--r--wizards/com/sun/star/wizards/fax/makefile.mk70
-rw-r--r--wizards/com/sun/star/wizards/form/CallFormWizard.java206
-rw-r--r--wizards/com/sun/star/wizards/form/DataEntrySetter.java147
-rw-r--r--wizards/com/sun/star/wizards/form/FieldLinker.java313
-rw-r--r--wizards/com/sun/star/wizards/form/Finalizer.java139
-rw-r--r--wizards/com/sun/star/wizards/form/FormConfiguration.java241
-rw-r--r--wizards/com/sun/star/wizards/form/FormControlArranger.java731
-rw-r--r--wizards/com/sun/star/wizards/form/FormDocument.java596
-rw-r--r--wizards/com/sun/star/wizards/form/FormWizard.java481
-rw-r--r--wizards/com/sun/star/wizards/form/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/form/StyleApplier.java494
-rw-r--r--wizards/com/sun/star/wizards/form/UIControlArranger.java504
-rw-r--r--wizards/com/sun/star/wizards/form/form.component35
-rw-r--r--wizards/com/sun/star/wizards/form/makefile.mk75
-rw-r--r--wizards/com/sun/star/wizards/letter/CGLetter.java66
-rw-r--r--wizards/com/sun/star/wizards/letter/CGLetterWizard.java39
-rw-r--r--wizards/com/sun/star/wizards/letter/CGPaperElementLocation.java40
-rw-r--r--wizards/com/sun/star/wizards/letter/CallWizard.java240
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterDocument.java330
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialog.java913
-rwxr-xr-xwizards/com/sun/star/wizards/letter/LetterWizardDialogConst.java93
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialogEvents.java89
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java1543
-rw-r--r--wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.java207
-rw-r--r--wizards/com/sun/star/wizards/letter/LocaleCodes.java202
-rw-r--r--wizards/com/sun/star/wizards/letter/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/letter/letter.component35
-rw-r--r--wizards/com/sun/star/wizards/letter/makefile.mk73
-rw-r--r--wizards/com/sun/star/wizards/makefile.mk150
-rw-r--r--wizards/com/sun/star/wizards/query/CallQueryWizard.java215
-rw-r--r--wizards/com/sun/star/wizards/query/Finalizer.java195
-rw-r--r--wizards/com/sun/star/wizards/query/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/query/QuerySummary.java254
-rw-r--r--wizards/com/sun/star/wizards/query/QueryWizard.java557
-rw-r--r--wizards/com/sun/star/wizards/query/makefile.mk69
-rw-r--r--wizards/com/sun/star/wizards/query/query.component35
-rw-r--r--wizards/com/sun/star/wizards/report/CallReportWizard.java263
-rw-r--r--wizards/com/sun/star/wizards/report/DBColumn.java482
-rw-r--r--wizards/com/sun/star/wizards/report/Dataimport.java222
-rw-r--r--wizards/com/sun/star/wizards/report/GroupFieldHandler.java196
-rwxr-xr-xwizards/com/sun/star/wizards/report/IReportBuilderLayouter.java119
-rwxr-xr-xwizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java61
-rw-r--r--wizards/com/sun/star/wizards/report/IReportDocument.java268
-rw-r--r--wizards/com/sun/star/wizards/report/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/report/RecordTable.java99
-rw-r--r--wizards/com/sun/star/wizards/report/ReportFinalizer.java293
-rw-r--r--wizards/com/sun/star/wizards/report/ReportImplementationHelper.java68
-rw-r--r--wizards/com/sun/star/wizards/report/ReportLayouter.java341
-rw-r--r--wizards/com/sun/star/wizards/report/ReportTextDocument.java786
-rw-r--r--wizards/com/sun/star/wizards/report/ReportTextImplementation.java734
-rw-r--r--wizards/com/sun/star/wizards/report/ReportWizard.java761
-rw-r--r--wizards/com/sun/star/wizards/report/delzip0
-rw-r--r--wizards/com/sun/star/wizards/report/makefile.mk76
-rw-r--r--wizards/com/sun/star/wizards/report/report.component35
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/Manifest.mf2
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java748
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java105
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java62
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java137
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java333
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java166
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java133
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java52
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java1693
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java55
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java74
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java86
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java67
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java154
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk71
-rw-r--r--wizards/com/sun/star/wizards/reportbuilder/makefile.mk55
-rw-r--r--wizards/com/sun/star/wizards/table/CGCategory.java88
-rw-r--r--wizards/com/sun/star/wizards/table/CGTable.java95
-rw-r--r--wizards/com/sun/star/wizards/table/CallTableWizard.java213
-rw-r--r--wizards/com/sun/star/wizards/table/FieldDescription.java176
-rw-r--r--wizards/com/sun/star/wizards/table/FieldFormatter.java433
-rw-r--r--wizards/com/sun/star/wizards/table/Finalizer.java364
-rw-r--r--wizards/com/sun/star/wizards/table/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java460
-rw-r--r--wizards/com/sun/star/wizards/table/ScenarioSelector.java385
-rw-r--r--wizards/com/sun/star/wizards/table/TableWizard.java438
-rw-r--r--wizards/com/sun/star/wizards/table/makefile.mk73
-rw-r--r--wizards/com/sun/star/wizards/table/table.component35
-rw-r--r--wizards/com/sun/star/wizards/text/TextDocument.java483
-rw-r--r--wizards/com/sun/star/wizards/text/TextFieldHandler.java348
-rw-r--r--wizards/com/sun/star/wizards/text/TextFrameHandler.java51
-rw-r--r--wizards/com/sun/star/wizards/text/TextSectionHandler.java271
-rw-r--r--wizards/com/sun/star/wizards/text/TextStyleHandler.java114
-rw-r--r--wizards/com/sun/star/wizards/text/TextTableHandler.java253
-rw-r--r--wizards/com/sun/star/wizards/text/ViewHandler.java115
-rw-r--r--wizards/com/sun/star/wizards/ui/AggregateComponent.java610
-rw-r--r--wizards/com/sun/star/wizards/ui/ButtonList.java907
-rw-r--r--wizards/com/sun/star/wizards/ui/CommandFieldSelection.java474
-rw-r--r--wizards/com/sun/star/wizards/ui/ControlScroller.java510
-rw-r--r--wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java158
-rw-r--r--wizards/com/sun/star/wizards/ui/DocumentPreview.java186
-rw-r--r--wizards/com/sun/star/wizards/ui/FieldSelection.java697
-rw-r--r--wizards/com/sun/star/wizards/ui/FilterComponent.java954
-rw-r--r--wizards/com/sun/star/wizards/ui/ImageList.java1134
-rwxr-xr-xwizards/com/sun/star/wizards/ui/PathSelection.java188
-rw-r--r--wizards/com/sun/star/wizards/ui/PeerConfig.java261
-rw-r--r--wizards/com/sun/star/wizards/ui/SortingComponent.java384
-rw-r--r--wizards/com/sun/star/wizards/ui/TitlesComponent.java249
-rw-r--r--wizards/com/sun/star/wizards/ui/UIConsts.java83
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog.java1148
-rw-r--r--wizards/com/sun/star/wizards/ui/UnoDialog2.java384
-rw-r--r--wizards/com/sun/star/wizards/ui/WizardDialog.java811
-rw-r--r--wizards/com/sun/star/wizards/ui/XCommandSelectionListener.java43
-rw-r--r--wizards/com/sun/star/wizards/ui/XCompletion.java39
-rw-r--r--wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java53
-rwxr-xr-xwizards/com/sun/star/wizards/ui/XPathSelectionListener.java34
-rw-r--r--wizards/com/sun/star/wizards/ui/event/AbstractListener.java133
-rw-r--r--wizards/com/sun/star/wizards/ui/event/CommonListener.java167
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAware.java365
-rw-r--r--wizards/com/sun/star/wizards/ui/event/DataAwareFields.java507
-rw-r--r--wizards/com/sun/star/wizards/ui/event/EventNames.java52
-rw-r--r--wizards/com/sun/star/wizards/ui/event/ListModelBinder.java209
-rw-r--r--wizards/com/sun/star/wizards/ui/event/MethodInvocation.java108
-rw-r--r--wizards/com/sun/star/wizards/ui/event/RadioDataAware.java101
-rw-r--r--wizards/com/sun/star/wizards/ui/event/SimpleDataAware.java84
-rw-r--r--wizards/com/sun/star/wizards/ui/event/Task.java204
-rw-r--r--wizards/com/sun/star/wizards/ui/event/TaskEvent.java65
-rw-r--r--wizards/com/sun/star/wizards/ui/event/TaskListener.java51
-rw-r--r--wizards/com/sun/star/wizards/ui/event/UnoDataAware.java265
-rw-r--r--wizards/com/sun/star/wizards/web/AbstractErrorHandler.java238
-rw-r--r--wizards/com/sun/star/wizards/web/BackgroundsDialog.java290
-rw-r--r--wizards/com/sun/star/wizards/web/CallWizard.java295
-rw-r--r--wizards/com/sun/star/wizards/web/ErrorHandler.java117
-rw-r--r--wizards/com/sun/star/wizards/web/ExtensionVerifier.java63
-rw-r--r--wizards/com/sun/star/wizards/web/FTPDialog.java752
-rw-r--r--wizards/com/sun/star/wizards/web/FTPDialogResources.java98
-rw-r--r--wizards/com/sun/star/wizards/web/IconsDialog.java208
-rw-r--r--wizards/com/sun/star/wizards/web/ImageListDialog.java283
-rw-r--r--wizards/com/sun/star/wizards/web/LogTaskListener.java103
-rw-r--r--wizards/com/sun/star/wizards/web/MANIFEST.MF2
-rw-r--r--wizards/com/sun/star/wizards/web/Process.java844
-rw-r--r--wizards/com/sun/star/wizards/web/ProcessErrorHandler.java92
-rw-r--r--wizards/com/sun/star/wizards/web/ProcessErrors.java48
-rw-r--r--wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java68
-rw-r--r--wizards/com/sun/star/wizards/web/StatusDialog.java305
-rw-r--r--wizards/com/sun/star/wizards/web/StylePreview.java154
-rw-r--r--wizards/com/sun/star/wizards/web/TOCPreview.java120
-rw-r--r--wizards/com/sun/star/wizards/web/WWD_Events.java1305
-rw-r--r--wizards/com/sun/star/wizards/web/WWD_General.java393
-rw-r--r--wizards/com/sun/star/wizards/web/WWD_Startup.java984
-rw-r--r--wizards/com/sun/star/wizards/web/WWHID.java186
-rw-r--r--wizards/com/sun/star/wizards/web/WebWizard.java72
-rw-r--r--wizards/com/sun/star/wizards/web/WebWizardConst.java73
-rw-r--r--wizards/com/sun/star/wizards/web/WebWizardDialog.java931
-rw-r--r--wizards/com/sun/star/wizards/web/WebWizardDialogResources.java349
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGArgument.java35
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGContent.java68
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDesign.java91
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGDocument.java453
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGExporter.java57
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGFilter.java35
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGGeneralInfo.java92
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGIconSet.java35
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGImage.java45
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGLayout.java87
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGPublish.java94
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSession.java110
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSessionName.java38
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGSettings.java212
-rw-r--r--wizards/com/sun/star/wizards/web/data/CGStyle.java54
-rw-r--r--wizards/com/sun/star/wizards/web/data/ConfigSetItem.java55
-rw-r--r--wizards/com/sun/star/wizards/web/data/TypeDetection.java79
-rw-r--r--wizards/com/sun/star/wizards/web/data/makefile.mk74
-rw-r--r--wizards/com/sun/star/wizards/web/export/AbstractExporter.java192
-rw-r--r--wizards/com/sun/star/wizards/web/export/ConfiguredExporter.java98
-rw-r--r--wizards/com/sun/star/wizards/web/export/CopyExporter.java88
-rw-r--r--wizards/com/sun/star/wizards/web/export/Exporter.java61
-rw-r--r--wizards/com/sun/star/wizards/web/export/FilterExporter.java89
-rw-r--r--wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java105
-rw-r--r--wizards/com/sun/star/wizards/web/export/makefile.mk63
-rw-r--r--wizards/com/sun/star/wizards/web/makefile.mk93
-rw-r--r--wizards/com/sun/star/wizards/web/status/ErrorLog.java69
-rw-r--r--wizards/com/sun/star/wizards/web/status/ErrorReporter.java46
-rw-r--r--wizards/com/sun/star/wizards/web/status/LogTaskListener.java87
-rw-r--r--wizards/com/sun/star/wizards/web/status/Task.java196
-rw-r--r--wizards/com/sun/star/wizards/web/status/TaskEvent.java71
-rw-r--r--wizards/com/sun/star/wizards/web/status/TaskListener.java58
-rw-r--r--wizards/com/sun/star/wizards/web/web.component35
254 files changed, 69886 insertions, 0 deletions
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java
new file mode 100644
index 000000000000..422f4c8134f9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaTemplate.java
@@ -0,0 +1,1961 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import java.util.Calendar;
+import java.util.Hashtable;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+
+import com.sun.star.awt.TextEvent;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNamed;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.i18n.NumberFormatIndex;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.table.XCell;
+import com.sun.star.table.XTableRows;
+import com.sun.star.text.*;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.XNumberFormatter;
+import com.sun.star.util.XSearchDescriptor;
+import com.sun.star.util.XSearchable;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NumberFormatter;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.text.TextDocument;
+import com.sun.star.wizards.text.TextSectionHandler;
+import com.sun.star.wizards.ui.UnoDialog2;
+import com.sun.star.wizards.ui.event.DataAware;
+
+/**
+ *
+ * The classes here implement the whole document-functionality of the agenda wizard:
+ * the live-preview and the final "creation" of the document, when the user clicks "finish". <br/>
+ * <br/>
+ * <h2>Some terminology:<h2/>
+ * items are names or headings. we don't make any distinction.
+ *
+ * <br/>
+ * The Agenda Template is used as general "controller" of the whole document, whereas the
+ * two child-classes ItemsTable and TopicsTable control the item tables (note plural!) and the
+ * topics table (note singular).
+ * <br/> <br/>
+ * Other small classes are used to abstract the handling of cells and text and we
+ * try to use them as components.
+ * <br/><br/>
+ * We tried to keep the Agenda Template as flexible as possible, though there
+ * must be many limitations, because it is generated dynamically.<br/><br/>
+ * To keep the template flexible the following decisions were made:<br/>
+ * 1. Item tables.<br/>
+ * 1.a. there might be arbitrary number of Item tables.<br/>
+ * 1.b. Item tables design (bordewr, background) is arbitrary.<br/>
+ * 1.c. Items text styles are individual, and use stylelist styles with predefined names.<br/>
+ * As result the following limitations:<br/>
+ * Pairs of Name->value for each item.<br/>
+ * Tables contain *only* those pairs.<br/>
+ * 2. Topics table.<br/>
+ * 2.a. arbitrary structure.<br/>
+ * 2.b. design is arbitrary.<br/>
+ * As result the following limitations:<br/>
+ * No column merge is allowed.<br/>
+ * One compolsary Heading row.<br/>
+ * <br/><br/>
+ * To let the template be flexible, we use a kind of "detection": we look where
+ * the items are read the design of each table, reaplying it after writing the
+ * table.
+ * <br/><br/>
+ * A note about threads:<br/>
+ * Many methods here are synchronized, in order to avoid colission made by
+ * events fired too often.
+ * @author rpiterman
+ *
+ */
+public class AgendaTemplate extends TextDocument implements TemplateConsts, DataAware.Listener
+{
+
+ /**
+ * resources.
+ */
+ AgendaWizardDialogResources resources;
+ /**
+ * data model. This keeps the status of the agenda document, and
+ * every redraw is done according to this data.
+ * Exception: topic data is written programatically, event-oriented.
+ */
+ CGAgenda agenda;
+ /**
+ * the UNO Text Document serrvice
+ */
+ Object document;
+ /**
+ * Service Factory
+ */
+ XMultiServiceFactory docMSF;
+ /**
+ * The template-filename of the current template.
+ * Since we often re-link section and the break the link,
+ * inorder to restore them, we need a template to link to.
+ * This is practically an identicall copy of the current template.
+ */
+ String template;
+ /**
+ * used for common operations on sections.
+ */
+ TextSectionHandler textSectionHandler;
+ /**
+ * a component loader.
+ */
+ XComponentLoader xComponentLoader;
+ /**
+ * an array containing all ItemTable object (which control each an Items
+ * Table in the document.
+ */
+ ItemsTable[] itemsTables;
+ /**
+ * the controller of the topics table.
+ */
+ Topics topics;
+ /**
+ * Stores reusable OOo Placeholder TextFields to insert to the document.
+ */
+ Map itemsCache;
+ /**
+ * This map is used to find which tables contains a certain Item, so
+ * the keys are the different Items, the Objects are the ItemTable controllers.
+ * When an Item must be redrawn (because the user checked or uncheced it),
+ * the controller is retrieved from this Map, and a redraw is issued on this controller.
+ */
+ Map itemsMap = new Hashtable(11);
+ /**
+ * A temporary variable used to list all items and map them.
+ */
+ List _allItems = new Vector();
+ /**
+ * keep a reference on some static items in the document,
+ * so when their content is changed (through the user), we
+ * can just reference them and set their text.
+ */
+ TextElement teTitle, teDate, teTime, teLocation;
+ XTextRange trTitle, trDate, trTime, trLocation;
+ /**
+ * used to format the date / time.
+ */
+ int dateFormat, timeFormat;
+ XNumberFormatter dateFormatter, timeFormatter;
+ /**
+ * used to transfare time from VCL to UNO.
+ */
+ long docNullTime;
+ Calendar calendar;
+ /**
+ * used to set the document title property (step 6).
+ */
+ private XDocumentProperties m_xDocProps;
+
+ /**
+ * loads the given template, and analyze its structure.
+ * @param templateURL
+ * @param topics
+ * @see AgendaTemplate.initialize()
+ * @see AgendaTemplate.initializeData()
+ */
+ public synchronized void load(String templateURL, List topics)
+ {
+ template = calcTemplateName(templateURL);
+ document = loadAsPreview(templateURL, false);
+ docMSF = ((XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document));
+ xFrame.getComponentWindow().setEnable(false);
+ xTextDocument.lockControllers();
+ initialize();
+ initializeData(topics);
+ xTextDocument.unlockControllers();
+ }
+
+ /**
+ * The agenda templates are in format of aw-XXX.ott
+ * the templates name is then XXX.ott.
+ * This method calculates it.
+ * @param url
+ * @return the template name without the "aw-" at the beginning.
+ */
+ private String calcTemplateName(String url)
+ {
+ return FileAccess.connectURLs(FileAccess.getParentDir(url), FileAccess.getFilename(url).substring(3));
+ }
+
+ /**
+ * synchronize the document to the model.<br/>
+ * this method rewrites all titles, item tables , and the topics table-
+ * thus synchronizing the document to the data model (CGAgenda).
+ * @param topicsData since the model does not contain Topics
+ * information (it is only actualized on save) the given list
+ * supplies this information.
+ */
+ private void initializeData(List topicsData)
+ {
+ for (int i = 0; i < itemsTables.length; i++)
+ {
+ try
+ {
+ itemsTables[i].write("");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ redrawTitle("txtTitle");
+ redrawTitle("txtDate");
+ redrawTitle("txtTime");
+ redrawTitle("cbLocation");
+
+ topics.writeAll(topicsData);
+
+ setTemplateTitle(agenda.cp_TemplateName);
+
+ }
+
+ /**
+ * redraws/rewrites the table which contains the given item
+ * This method is called when the user checks/unchecks an item.
+ * The table is being found, in which the item is, and redrawn.
+ * @param itemName
+ */
+ public synchronized void redraw(String itemName)
+ {
+ try
+ {
+ // get the table in which the item is...
+ Object itemsTable =
+ itemsMap.get(itemName);
+ // rewrite the table.
+ ((ItemsTable) itemsTable).write(null);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * update the documents title property to the given title
+ * @param newTitle new title.
+ */
+ synchronized void setTemplateTitle(String newTitle)
+ {
+ m_xDocProps.setTitle(newTitle);
+ }
+
+ /**
+ * constructor. The document is *not* loaded here.
+ * only some formal members are set.
+ * @param xmsf_ service factory.
+ * @param agenda_ the data model (CGAgenda)
+ * @param resources_ resources.
+ */
+ AgendaTemplate(XMultiServiceFactory xmsf_, CGAgenda agenda_, AgendaWizardDialogResources resources_, XTerminateListener listener)
+ {
+ super(xmsf_, listener, "WIZARD_LIVE_PREVIEW");
+
+ agenda = agenda_;
+ resources = resources_;
+
+ if (itemsCache == null)
+ {
+ initItemsCache();
+ }
+ _allItems = null;
+
+ }
+
+ /**
+ * checks the data model if the
+ * item corresponding to the given string should be shown
+ * @param itemName a string representing an Item (name or heading).
+ * @return true if the model specifies that the item should be displayed.
+ */
+ boolean isShowItem(String itemName)
+ {
+ if (itemName.equals(FILLIN_MEETING_TYPE))
+ {
+ return agenda.cp_ShowMeetingType;
+ }
+ else if (itemName.equals(FILLIN_READ))
+ {
+ return agenda.cp_ShowRead;
+ }
+ else if (itemName.equals(FILLIN_BRING))
+ {
+ return agenda.cp_ShowBring;
+ }
+ else if (itemName.equals(FILLIN_NOTES))
+ {
+ return agenda.cp_ShowNotes;
+ }
+ else if (itemName.equals(FILLIN_FACILITATOR))
+ {
+ return agenda.cp_ShowFacilitator;
+ }
+ else if (itemName.equals(FILLIN_TIMEKEEPER))
+ {
+ return agenda.cp_ShowTimekeeper;
+ }
+ else if (itemName.equals(FILLIN_NOTETAKER))
+ {
+ return agenda.cp_ShowNotetaker;
+ }
+ else if (itemName.equals(FILLIN_PARTICIPANTS))
+ {
+ return agenda.cp_ShowAttendees;
+ }
+ else if (itemName.equals(FILLIN_CALLED_BY))
+ {
+ return agenda.cp_ShowCalledBy;
+ }
+ else if (itemName.equals(FILLIN_OBSERVERS))
+ {
+ return agenda.cp_ShowObservers;
+ }
+ else if (itemName.equals(FILLIN_RESOURCE_PERSONS))
+ {
+ return agenda.cp_ShowResourcePersons;
+ }
+ else
+ {
+ throw new IllegalArgumentException("No such item");
+ }
+ }
+
+ /**
+ * itemsCache is a Map containing all agenda item. These are object which
+ * "write themselfs" to the table, given a table cursor.
+ * A cache is used in order to reuse the objects, instead of recreate them.
+ * This method fills the cache will all items objects (names and headings).
+ */
+ private void initItemsCache()
+ {
+ itemsCache = new Hashtable(11);
+
+ XMultiServiceFactory xmsf = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
+ // Headings
+
+ itemsCache.put(FILLIN_MEETING_TYPE,
+ new AgendaItem(FILLIN_MEETING_TYPE, new TextElement(resources.itemMeetingType, STYLE_MEETING_TYPE),
+ new PlaceholderElement(STYLE_MEETING_TYPE_TEXT, resources.reschkMeetingTitle_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_BRING,
+ new AgendaItem(FILLIN_BRING, new TextElement(resources.itemBring, STYLE_BRING),
+ new PlaceholderElement(STYLE_BRING_TEXT, resources.reschkBring_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_READ,
+ new AgendaItem(FILLIN_READ, new TextElement(resources.itemRead, STYLE_READ),
+ new PlaceholderElement(STYLE_READ_TEXT, resources.reschkRead_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_NOTES,
+ new AgendaItem(FILLIN_NOTES, new TextElement(resources.itemNote, STYLE_NOTES),
+ new PlaceholderElement(STYLE_NOTES_TEXT, resources.reschkNotes_value, resources.resPlaceHolderHint, xmsf)));
+
+ // Names
+
+ itemsCache.put(FILLIN_CALLED_BY,
+ new AgendaItem(FILLIN_CALLED_BY, new TextElement(resources.itemCalledBy, STYLE_CALLED_BY),
+ new PlaceholderElement(STYLE_CALLED_BY_TEXT, resources.reschkConvenedBy_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_FACILITATOR,
+ new AgendaItem(FILLIN_FACILITATOR, new TextElement(resources.itemFacilitator, STYLE_FACILITATOR),
+ new PlaceholderElement(STYLE_FACILITATOR_TEXT, resources.reschkPresiding_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_PARTICIPANTS,
+ new AgendaItem(FILLIN_PARTICIPANTS, new TextElement(resources.itemAttendees, STYLE_PARTICIPANTS),
+ new PlaceholderElement(STYLE_PARTICIPANTS_TEXT, resources.reschkAttendees_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_NOTETAKER,
+ new AgendaItem(FILLIN_NOTETAKER, new TextElement(resources.itemNotetaker, STYLE_NOTETAKER),
+ new PlaceholderElement(STYLE_NOTETAKER_TEXT, resources.reschkNoteTaker_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_TIMEKEEPER,
+ new AgendaItem(FILLIN_TIMEKEEPER, new TextElement(resources.itemTimekeeper, STYLE_TIMEKEEPER),
+ new PlaceholderElement(STYLE_TIMEKEEPER_TEXT, resources.reschkTimekeeper_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_OBSERVERS,
+ new AgendaItem(FILLIN_OBSERVERS, new TextElement(resources.itemObservers, STYLE_OBSERVERS),
+ new PlaceholderElement(STYLE_OBSERVERS_TEXT, resources.reschkObservers_value, resources.resPlaceHolderHint, xmsf)));
+
+ itemsCache.put(FILLIN_RESOURCE_PERSONS,
+ new AgendaItem(FILLIN_RESOURCE_PERSONS, new TextElement(resources.itemResource, STYLE_RESOURCE_PERSONS),
+ new PlaceholderElement(STYLE_RESOURCE_PERSONS_TEXT, resources.reschkResourcePersons_value, resources.resPlaceHolderHint, xmsf)));
+
+ }
+
+ /**
+ * Initializes a template.<br/>
+ * This method does the following tasks:<br/>
+ * Get a Time and Date format for the document, and retrieve the null date of the document (which is
+ * document-specific).<br/>
+ * Initializes the Items Cache map.
+ * Analyses the document:<br/>
+ * -find all "fille-ins" (apear as &gt;xxx&lt; in the document).
+ * -analyze all items sections (and the tables in them).
+ * -locate the titles and actualize them
+ * -analyze the topics table
+ */
+ private void initialize()
+ {
+ /*
+ * Get the default locale of the document, and create the date and time formatters.
+ */
+ XMultiServiceFactory docMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
+ try
+ {
+ Object defaults = docMSF.createInstance("com.sun.star.text.Defaults");
+ Locale l = (Locale) Helper.getUnoStructValue(defaults, "CharLocale");
+
+ java.util.Locale jl = new java.util.Locale(
+ l.Language, l.Country, l.Variant);
+
+ calendar = Calendar.getInstance(jl);
+
+ XNumberFormatsSupplier nfs = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, document);
+ Object formatSettings = nfs.getNumberFormatSettings();
+ com.sun.star.util.Date date = (com.sun.star.util.Date) Helper.getUnoPropertyValue(formatSettings, "NullDate");
+
+ calendar.set(date.Year, date.Month - 1, date.Day);
+
+ docNullTime = JavaTools.getTimeInMillis(calendar);
+
+ dateFormat = NumberFormatter.getNumberFormatterKey(nfs, NumberFormatIndex.DATE_SYSTEM_LONG);
+ timeFormat = NumberFormatter.getNumberFormatterKey(nfs, NumberFormatIndex.TIME_HHMM);
+
+
+ dateFormatter = NumberFormatter.createNumberFormatter(xMSF, nfs);
+ timeFormatter = NumberFormatter.createNumberFormatter(xMSF, nfs);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new NullPointerException("Fatal Error: could not initialize locale or date/time formats.");
+ }
+
+ /*
+ * get the document properties object.
+ */
+ m_xDocProps = OfficeDocument.getDocumentProperties(document);
+
+ initItemsCache();
+ initializeItems();
+ initializeTitles();
+ initializeItemsSections();
+ XMultiServiceFactory xMultiServiceFactory = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
+ textSectionHandler = new TextSectionHandler(xMultiServiceFactory, (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, document));
+ initializeTopics();
+ _allItems.clear();
+ _allItems = null;
+ }
+
+ /**
+ * locates the titles (name, location, date, time) and saves a reference to thier Text ranges.
+ *
+ */
+ private void initializeTitles()
+ {
+ XTextRange item = null;
+
+ XMultiServiceFactory xmsf = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
+
+ for (int i = 0; i < _allItems.size(); i++)
+ {
+ item = (XTextRange) _allItems.get(i);
+ String text = item.getString().trim().toLowerCase();
+ if (text.equals(FILLIN_TITLE))
+ {
+
+ teTitle = new PlaceholderTextElement(item, resources.resPlaceHolderTitle, resources.resPlaceHolderHint, xmsf);
+ trTitle = item;
+ _allItems.remove(i--);
+ }
+ else if (text.equals(FILLIN_DATE))
+ {
+ teDate = new PlaceholderTextElement(item, resources.resPlaceHolderDate, resources.resPlaceHolderHint, xmsf);
+ trDate = item;
+ _allItems.remove(i--);
+ }
+ else if (text.equals(FILLIN_TIME))
+ {
+ teTime = new PlaceholderTextElement(item, resources.resPlaceHolderTime, resources.resPlaceHolderHint, xmsf);
+ trTime = item;
+ _allItems.remove(i--);
+ }
+ else if (text.equals(FILLIN_LOCATION))
+ {
+ teLocation = new PlaceholderTextElement(item, resources.resPlaceHolderLocation, resources.resPlaceHolderHint, xmsf);
+ trLocation = item;
+ _allItems.remove(i--);
+ }
+ }
+ }
+
+ private void initializeTopics()
+ {
+ topics = new Topics();
+ }
+
+ private void initializeItems()
+ {
+ _allItems = searchFillInItems();
+ }
+
+ /**
+ * searches the document for items in the format "&gt;*&lt;"
+ * @return a vector containing the XTextRanges of the found items
+ */
+ private List searchFillInItems()
+ {
+ try
+ {
+ XSearchable xSearchable = (XSearchable) UnoRuntime.queryInterface(XSearchable.class, document);
+ XSearchDescriptor sd = xSearchable.createSearchDescriptor();
+ sd.setSearchString("<[^>]+>");
+ sd.setPropertyValue("SearchRegularExpression", Boolean.TRUE);
+ sd.setPropertyValue("SearchWords", Boolean.TRUE);
+
+ XIndexAccess ia = xSearchable.findAll(sd);
+
+ List l = new Vector(ia.getCount());
+ for (int i = 0; i < ia.getCount(); i++)
+ {
+ try
+ {
+ l.add((XTextRange) UnoRuntime.queryInterface(XTextRange.class, ia.getByIndex(i)));
+ }
+ catch (Exception ex)
+ {
+ System.err.println("Nonfatal Error in finding fillins.");
+ }
+ }
+ return l;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new IllegalArgumentException("Fatal Error: Loading template failed: searching fillins failed");
+ }
+ }
+
+ /**
+ * analyze the item sections in the template. delegates the analyze of each table to the
+ * ItemsTable class.
+ */
+ private void initializeItemsSections()
+ {
+ String[] sections = getSections(document, TemplateConsts.SECTION_ITEMS);
+
+ // for each section - there is a table...
+ itemsTables = new ItemsTable[sections.length];
+
+ for (int i = 0; i < itemsTables.length; i++)
+ {
+ try
+ {
+ itemsTables[i] = new ItemsTable(getSection(sections[i]), getTable(sections[i]));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new IllegalArgumentException("Fatal Error while initialilzing Template: items table in section " + sections[i]);
+ }
+ }
+
+ }
+
+ private String[] getSections(Object document, String s)
+ {
+ XTextSectionsSupplier xTextSectionsSupplier = (XTextSectionsSupplier) UnoRuntime.queryInterface(XTextSectionsSupplier.class, document);
+ String[] allSections = xTextSectionsSupplier.getTextSections().getElementNames();
+ return getNamesWhichStartWith(allSections, s);
+ }
+
+ Object getSection(String name) throws NoSuchElementException, WrappedTargetException
+ {
+ XTextSectionsSupplier xTextSectionsSupplier = (XTextSectionsSupplier) UnoRuntime.queryInterface(XTextSectionsSupplier.class, document);
+ return ((Any) (xTextSectionsSupplier.getTextSections().getByName(name))).getObject();
+ }
+
+ Object getTable(String name) throws NoSuchElementException, WrappedTargetException
+ {
+ XTextTablesSupplier xTextTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, document);
+ return ((Any) xTextTablesSupplier.getTextTables().getByName(name)).getObject();
+ }
+
+ /**
+ * implementation of DataAware.Listener, is
+ * called when title/date/time or location are
+ * changed.
+ */
+ public synchronized void eventPerformed(Object param)
+ {
+ TextEvent te = (TextEvent) param;
+ String controlName = (String) Helper.getUnoPropertyValue(
+ UnoDialog2.getModel(te.Source),
+ "Name");
+ redrawTitle(controlName);
+
+ }
+
+ private synchronized void redrawTitle(String controlName)
+ {
+ if (controlName.equals("txtTitle"))
+ {
+ writeTitle(teTitle, trTitle, agenda.cp_Title);
+ }
+ else if (controlName.equals("txtDate"))
+ {
+ writeTitle(teDate, trDate, getDateString(agenda.cp_Date));
+ }
+ else if (controlName.equals("txtTime"))
+ {
+ writeTitle(teTime, trTime, getTimeString(agenda.cp_Time));
+ }
+ else if (controlName.equals("cbLocation"))
+ {
+ writeTitle(teLocation, trLocation, agenda.cp_Location);
+ }
+ else
+ {
+ throw new IllegalArgumentException("No such title control...");
+ }
+ }
+
+ private void writeTitle(TextElement te, XTextRange tr, String text)
+ {
+ te.text = (text == null ? "" : text);
+ te.write(tr);
+ }
+ private static long DAY_IN_MILLIS = (24 * 60 * 60 * 1000);
+
+ private String getDateString(String d)
+ {
+ if (d == null || d.equals(""))
+ {
+ return "";
+ }
+ int date = new Integer(d).intValue();
+ calendar.clear();
+ calendar.set(date / 10000,
+ (date % 10000) / 100 - 1,
+ date % 100);
+
+ long date1 = JavaTools.getTimeInMillis(calendar);
+ /*
+ * docNullTime and date1 are in millis, but
+ * I need a day...
+ */
+ double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1;
+
+ return dateFormatter.convertNumberToString(dateFormat, daysDiff);
+ }
+
+ private String getTimeString(String s)
+ {
+ if (s == null || s.equals(""))
+ {
+ return "";
+ }
+ int time = new Integer(s).intValue();
+
+ double t = ((double) (time / 1000000) / 24) + ((double) ((time % 1000000) / 1000) / (24 * 60));
+ return timeFormatter.convertNumberToString(timeFormat, t);
+ }
+
+ /* *******************************************
+ * F I N I S H
+ *********************************************/
+ /** the user clicked finish **/
+ public synchronized void finish(List topics)
+ {
+ createMinutes(topics);
+ deleteHiddenSections();
+ textSectionHandler.removeAllTextSections();
+ }
+
+ /**
+ * hidden sections exist when an item's section is hidden because the
+ * user specified not to display any items which it contains.
+ * When finishing the wizard removes this sections entireley from the document.
+ */
+ private void deleteHiddenSections()
+ {
+ XTextSectionsSupplier xTextSectionsSupplier = (XTextSectionsSupplier) UnoRuntime.queryInterface(XTextSectionsSupplier.class, document);
+ String[] allSections = xTextSectionsSupplier.getTextSections().getElementNames();
+ try
+ {
+ for (int i = 0; i < allSections.length; i++)
+ {
+ Object section = getSection(allSections[i]);
+ //Try3.showProps(section);
+ boolean visible = ((Boolean) Helper.getUnoPropertyValue(section, "IsVisible")).booleanValue();
+ if (!visible)
+ {
+ ((XTextContent) UnoRuntime.queryInterface(XTextContent.class, section)).getAnchor().setString("");
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * create the minutes for the given topics or remove the minutes section from the document.
+ * If no topics are supplied, or the user
+ * specified not to create minuts, the minutes section will be removed,
+ * @param topicsData supplies PropertyValue arrays containing the values for the topics.
+ */
+ public synchronized void createMinutes(List topicsData)
+ {
+
+ // if the minutes section should be removed (the
+ // user did not check "create minutes")
+ if (!agenda.cp_IncludeMinutes || (topicsData.size() <= 1))
+ {
+ try
+ {
+ Object minutesAllSection = getSection(SECTION_MINUTES_ALL);
+ XTextSection xTextSection = (XTextSection) UnoRuntime.queryInterface(XTextSection.class, minutesAllSection);
+ xTextSection.getAnchor().setString("");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ // the user checked "create minutes"
+ else
+ {
+ try
+ {
+ String itemText;
+ XTextRange item;
+ int topicStartTime = 0;
+ try
+ {
+ topicStartTime = new Integer(agenda.cp_Time).intValue();
+ }
+ catch (Exception ex)
+ {
+ }
+
+ String time;
+
+ // first I replace the minutes titles...
+ List items = searchFillInItems();
+ for (int itemIndex = 0; itemIndex < items.size(); itemIndex++)
+ {
+ item = (XTextRange) items.get(itemIndex);
+ itemText = item.getString().trim().toLowerCase();
+
+ if (itemText.equals(FILLIN_MINUTES_TITLE))
+ {
+ fillMinutesItem(item, agenda.cp_Title, resources.resPlaceHolderTitle);
+ }
+ else if (itemText.equals(FILLIN_MINUTES_LOCATION))
+ {
+ fillMinutesItem(item, agenda.cp_Location, resources.resPlaceHolderLocation);
+ }
+ else if (itemText.equals(FILLIN_MINUTES_DATE))
+ {
+ fillMinutesItem(item, getDateString(agenda.cp_Date), resources.resPlaceHolderDate);
+ }
+ else if (itemText.equals(FILLIN_MINUTES_TIME))
+ {
+ fillMinutesItem(item, getTimeString(agenda.cp_Time), resources.resPlaceHolderTime);
+ }
+ }
+
+ items.clear();
+
+ /*
+ * now add minutes for each topic.
+ * The template contains *one* minutes section, so
+ * we first use the one available, and then add a new one...
+ *
+ * topics data has *always* an empty topic at the end...
+ */
+ for (int i = 0; i < topicsData.size() - 1; i++)
+ {
+ PropertyValue[] topic = (PropertyValue[]) topicsData.get(i);
+
+ items = searchFillInItems();
+ for (int itemIndex = 0; itemIndex < items.size(); itemIndex++)
+ {
+ item = (XTextRange) items.get(itemIndex);
+ itemText = item.getString().trim().toLowerCase();
+
+ if (itemText.equals(FILLIN_MINUTE_NUM))
+ {
+ fillMinutesItem(item, topic[0].Value, "");
+ }
+ else if (itemText.equals(FILLIN_MINUTE_TOPIC))
+ {
+ fillMinutesItem(item, topic[1].Value, "");
+ }
+ else if (itemText.equals(FILLIN_MINUTE_RESPONSIBLE))
+ {
+ fillMinutesItem(item, topic[2].Value, "");
+ }
+ else if (itemText.equals(FILLIN_MINUTE_TIME))
+ {
+ int topicTime = 0;
+
+ try
+ {
+ topicTime = (new Integer((String) topic[3].Value)).intValue();
+ }
+ catch (Exception ex)
+ {
+ }
+ // if the topic has no time, we do not display any time here.
+ if (topicTime == 0 || topicStartTime == 0)
+ {
+ time = (String) topic[3].Value;
+ }
+ else
+ {
+ time = getTimeString(String.valueOf(topicStartTime)) + " - ";
+ topicStartTime += topicTime * 1000;
+ time += getTimeString(String.valueOf(topicStartTime));
+ }
+ fillMinutesItem(item, time, "");
+ }
+ }
+
+ textSectionHandler.removeTextSectionbyName(SECTION_MINUTES);
+
+ // after the last section we do not insert a new one.
+ if (i < topicsData.size() - 2)
+ {
+ textSectionHandler.insertTextSection(SECTION_MINUTES, template, false);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * given a text range and a text, fills the given
+ * text range with the given text.
+ * If the given text is empty, uses a placeholder with the giveb placeholder text.
+ * @param range text range to fill
+ * @param text the text to fill to the text range object.
+ * @param placeholder the placeholder text to use, if the text argument is empty (null or "")
+ */
+ private void fillMinutesItem(XTextRange range, Object text, String placeholder)
+ {
+ String paraStyle = (String) Helper.getUnoPropertyValue(range, "ParaStyleName");
+ range.setString((String) text);
+ Helper.setUnoPropertyValue(range, "ParaStyleName", paraStyle);
+ if (text == null || text.equals(""))
+ {
+ if (placeholder != null && !placeholder.equals(""))
+ {
+ XTextContent placeHolder = createPlaceHolder(docMSF, placeholder, resources.resPlaceHolderHint);
+ try
+ {
+ range.getStart().getText().insertTextContent(range.getStart(), placeHolder, true);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ }
+ }
+
+ /**
+ * creates a placeholder field with the given text and given hint.
+ * @param xmsf service factory
+ * @param ph place holder text
+ * @param hint hint text
+ * @return the place holder field.
+ */
+ public static XTextContent createPlaceHolder(XMultiServiceFactory xmsf, String ph, String hint)
+ {
+ Object placeHolder;
+ try
+ {
+ placeHolder = xmsf.createInstance("com.sun.star.text.TextField.JumpEdit");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ Helper.setUnoPropertyValue(placeHolder, "PlaceHolder", ph);
+ Helper.setUnoPropertyValue(placeHolder, "Hint", hint);
+ Helper.setUnoPropertyValue(placeHolder, "PlaceHolderType", new Short(PlaceholderType.TEXT));
+ return (XTextContent) UnoRuntime.queryInterface(XTextContent.class, placeHolder);
+
+ }
+
+ /*
+ * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+ * =================================
+ * The ItemTable class
+ * =================================
+ * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+ */
+ public class ItemsTable
+ {
+
+ Object table;
+ Object section;
+ /**
+ * the items in the table.
+ */
+ List items = new Vector(6);
+
+ public ItemsTable(Object section_, Object table_)
+ {
+
+ table = table_;
+ section = section_;
+
+ AgendaItem ai;
+ XTextRange item;
+ String iText;
+
+ /* go through all <*> items in the document
+ * and each one if it is in this table.
+ * If they are, register them to belong here, notice their order
+ * and remove them from the list of all <*> items, so the next
+ * search will be faster.
+ */
+ for (int i = 0; i < _allItems.size(); i++)
+ {
+ item = (XTextRange) _allItems.get(i);
+ Object t = Helper.getUnoPropertyValue(item, "TextTable");
+ if ((t instanceof Any) && ((Any) t).getObject() == table)
+ {
+ iText = item.getString().toLowerCase().trim();
+ ai = (AgendaItem) itemsCache.get(item.getString().toLowerCase().trim());
+ if (ai != null)
+ {
+ items.add(ai);
+ _allItems.remove(i--);
+ itemsMap.put(iText, this);
+ }
+ }
+ }
+
+ }
+
+ /**
+ * link the section to the template. this will restore the original table
+ * with all the items.<br/>
+ * then break the link, to make the section editable.<br/>
+ * then, starting at cell one, write all items that should be visible.
+ * then clear the rest and remove obsolete rows.
+ * If no items are visible, hide the section.
+ * @param dummy we need a param to make this an Implementation of AgendaElement.
+ * @throws Exception
+ */
+ public synchronized void write(Object dummy) throws Exception
+ {
+ synchronized(this)
+ {
+ String name = getName(section);
+
+ // link and unlink the section to the template.
+ textSectionHandler.linkSectiontoTemplate(section, template, name);
+ textSectionHandler.breakLinkOfTextSection(section);
+
+ // we need to get a new instance after linking.
+ table = getTable(name);
+ section = getSection(name);
+
+ XTextTable xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, table);
+ XTextTableCursor cursor = xTextTable.createCursorByCellName("A1");
+ AgendaItem ai;
+ // should this section be visible?
+ boolean visible = false;
+
+ // write items
+ // ===========
+ String cellName = "";
+
+ /* now go through all items that belong to this
+ * table. Check each one agains the model. If it should
+ * be display, call it's write method.
+ * All items are of type AgendaItem which means they write
+ * two cells to the table: a title (text) and a placeholder.
+ * see AgendaItem class below.
+ */
+ for (int i = 0; i < items.size(); i++)
+ {
+ ai = (AgendaItem) items.get(i);
+ if (isShowItem(ai.name))
+ {
+ visible = true;
+ ai.table = table;
+ ai.write(cursor);
+ // I store the cell name which was last written...
+ cellName = cursor.getRangeName();
+
+ cursor.goRight((short) 1, false);
+
+ }
+ }
+
+ Helper.setUnoPropertyValue(section, "IsVisible", visible ? Boolean.TRUE : Boolean.FALSE);
+ if (!visible)
+ {
+ return;
+ /* remove obsolete rows
+ * ====================
+ * if the cell that was last written is the current cell,
+ * it means this is the end of the table, so we end here.
+ * (because after getting the cellName above, I call the goRight method.
+ * If it did not go right, it means its the last cell.
+ */
+ }
+ if (cellName.equals(cursor.getRangeName()))
+ {
+ return;
+ /*
+ * if not, we continue and clear all cells until we are at the end of the row.
+ */
+ }
+ Object cell;
+ while ((!cellName.equals(cursor.getRangeName()) && (!cursor.getRangeName().startsWith("A"))))
+ {
+ cell = xTextTable.getCellByName(cursor.getRangeName());
+ ((XTextRange) UnoRuntime.queryInterface(XTextRange.class, cell)).setString("");
+ cellName = cursor.getRangeName();
+ cursor.goRight((short) 1, false);
+ }
+
+ /*
+ * again: if we are at the end of the table, end here.
+ */
+ if (cellName.equals(cursor.getRangeName()))
+ {
+ return;
+ }
+ int rowIndex = getRowIndex(cursor);
+ int rowsCount = getRowCount((XTextTable) UnoRuntime.queryInterface(XTextTable.class, table));
+
+ /* now before deleteing i move the cursor up so it
+ * does not disappear, because it will crash office.
+ */
+ cursor.gotoStart(false);
+
+ if (rowsCount >= rowIndex)
+ {
+ removeTableRows(table, rowIndex - 1, (rowsCount - rowIndex) + 1);
+ }
+ }
+ }
+ }
+
+ /*
+ * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+ * =================================
+ * The Topics class
+ * =================================
+ * $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
+ */
+ /**
+ * This class handles the preview of the topics table.
+ * You can call it the controller of the topics table.
+ * It differs from ItemsTable in that it has no data model -
+ * the update is done programttically.<br/>
+ * <br/>
+ * The decision to make this class a class by its own
+ * was done out of logic reasons and not design/functionality reasons,
+ * since there is anyway only one instance of this class at runtime
+ * it could have also be implemented in the AgendaTemplate class
+ * but for clarity and separation I decided to make a sub class for it.
+ *
+ * @author rp143992
+ */
+ public class Topics
+ {
+
+ /**
+ * the topics table
+ */
+ XTextTable table;
+ /**
+ * A List of Cell Formatters for the first row.
+ */
+ List firstRowFormat = new Vector();
+ /**
+ * A List of Cell Formatters for the last row.
+ * (will contain them in reverse order)
+ */
+ List lastRowFormat = new Vector();
+ /**
+ * the format of the cell of each topic cell.
+ */
+ List topicCellFormats = new Vector();
+ /**
+ * for each topic cell there is
+ * a member in this vector
+ */
+ List topicCells = new Vector();
+ int rowsPerTopic;
+ /**
+ * fields which hold the number of the
+ * fillins in the cells vectors.
+ */
+ int numCell = -1;
+ int topicCell = -1;
+ int responsibleCell = -1;
+ int timeCell = -1;
+ /**
+ * this is a list which traces which topics were written to the document
+ * and which not. When a cell needs to be actualized, it is checked that the
+ * whole topic is already present in the document, using this vector.
+ * The vector contains nulls for topics which were not written, and
+ * empty strings for topics which were written (though any other
+ * object would also do - i check only if it is a null or not...);
+ */
+ List writtenTopics = new Vector();
+
+ /**
+ * Analyze the structure of the Topics table.
+ * The structure Must be as follows:<br>
+ * -One Header Row. <br>
+ * -arbitrary number of rows per topic <br>
+ * -arbitrary content in the topics row <br>
+ * -only soft formatting will be restored. <br>
+ * -the topic rows must repeat three times. <br>
+ * -in the topics rows, placeholders for number, topic, responsible, and duration
+ * must be placed.<br>
+ * <br>
+ * A word about table format: to reconstruct the format of the
+ * table we hold to the following formats: first row (header), topic, and last row.
+ * We hold the format of the last row, because one might wish to give it
+ * a special format, other than the one on the bottom of each topic.
+ * The left and right borders of the whole table are, on the other side,
+ * part of the topics rows format, and need not be preserved seperateley.
+ */
+ public Topics()
+ {
+ Object t;
+
+ Map topicItems = new Hashtable(4);
+
+ // This is the topics table. say hallo :-)
+ try
+ {
+ t = getTable(SECTION_TOPICS);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ throw new IllegalArgumentException("Fatal error while loading template: table " + SECTION_TOPICS + " could not load.");
+ }
+
+ // and this is the XTable.
+ table = ((XTextTable) UnoRuntime.queryInterface(XTextTable.class, t));
+
+ /* first I store all <*> ranges
+ * which are in the topics table.
+ * I store each <*> range in this - the key
+ * is the cell it is in. Later when analyzing the topic,
+ * cell by cell, I check in this map to know
+ * if a cell contains a <*> or not.
+ */
+ Hashtable items = new Hashtable();
+
+ XTextRange item;
+ Object cell;
+ for (int i = 0; i < _allItems.size(); i++)
+ {
+ item = (XTextRange) _allItems.get(i);
+ t = Helper.getUnoPropertyValue(item, "TextTable");
+ if ((t instanceof Any) && ((Any) t).getObject() == table)
+ {
+ cell = Helper.getUnoPropertyValue(item, "Cell");
+ items.put(((Any) cell).getObject(), item);
+ }
+ }
+
+ /*
+ * in the topics table, there are always one
+ * title row and three topics defined.
+ * So no mutter how many rows a topic takes - we
+ * can restore its structure and format.
+ */
+ int rows = getRowCount(table);
+
+ rowsPerTopic = (rows - 1) / 3;
+
+ String firstCell = "A" + (1 + rowsPerTopic + 1);
+ String afterLastCell = "A" + (1 + (rowsPerTopic * 2) + 1);
+
+ // go to the first row of the 2. topic
+ XTextTableCursor cursor = table.createCursorByCellName(firstCell);
+ XTextRange range;
+
+ // analyze the structure of the topic rows.
+ while (!cursor.getRangeName().equals(afterLastCell))
+ {
+ cell = table.getCellByName(cursor.getRangeName());
+ XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, cell);
+ // first I store the content and para style of the cell
+ AgendaElement ae = new TextElement(xTextRange);
+ // if the cell contains a relevant <...>
+ // i add the text element to the hash,
+ // so it's text can be updated later.
+ range = (XTextRange) items.get(cell);
+ if (range != null)
+ {
+ topicItems.put(xTextRange.getString().toLowerCase().trim(), ae);
+ }
+
+ topicCells.add(ae);
+
+ // and store the format of the cell.
+ topicCellFormats.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName())));
+
+ // goto next cell.
+ cursor.goRight((short) 1, false);
+ }
+
+ /*
+ * now - in which cell is every fillin?
+ */
+ numCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_NUMBER));
+ topicCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_TOPIC));
+ responsibleCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_RESPONSIBLE));
+ timeCell = topicCells.indexOf(topicItems.get(FILLIN_TOPIC_TIME));
+
+
+
+ /* now that we know how the topics look like,
+ * we get the format of the first and last rows.
+ */
+
+ // format of first row
+ cursor.gotoStart(false);
+ do
+ {
+ firstRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName())));
+ cursor.goRight((short) 1, false);
+ }
+ while (!cursor.getRangeName().startsWith("A"));
+
+ // format of the last row
+ cursor.gotoEnd(false);
+ while (!cursor.getRangeName().startsWith("A"))
+ {
+ lastRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName())));
+ cursor.goLeft((short) 1, false);
+ }
+ // we missed the A cell - so we have to add it also..
+ lastRowFormat.add(new TableCellFormatter(table.getCellByName(cursor.getRangeName())));
+
+ removeTableRows(table, 1 + rowsPerTopic, rows - rowsPerTopic - 1);
+
+ }
+
+ /**
+ * @param topic the topic number to write
+ * @param data the data of the topic.
+ * @return the number of rows that have been added
+ * to the table. 0 or a negative number: no rows added.
+ */
+ private int write2(int topic, PropertyValue[] data) throws Exception
+ {
+ while (topic >= writtenTopics.size())
+ {
+ writtenTopics.add(null);
+ }
+ writtenTopics.set(topic, "");
+
+ // make sure threr are enough rows for me...
+ int rows = getRowCount(table);
+ int reqRows = 1 + (topic + 1) * rowsPerTopic;
+ int firstRow = reqRows - rowsPerTopic + 1;
+ int diff = reqRows - rows;
+ if (diff > 0)
+ {
+ insertTableRows(table, rows, diff); // set the item's text...
+ }
+ setItemText(numCell, data[0].Value);
+ setItemText(topicCell, data[1].Value);
+ setItemText(responsibleCell, data[2].Value);
+ setItemText(timeCell, data[3].Value);
+
+ // now write !
+ XTextTableCursor cursor = table.createCursorByCellName("A" + firstRow);
+
+ for (int i = 0; i < topicCells.size(); i++)
+ {
+ ((AgendaElement) topicCells.get(i)).write(table.getCellByName(cursor.getRangeName()));
+ cursor.goRight((short) 1, false);
+ }
+
+ // now format !
+ cursor.gotoCellByName("A" + firstRow, false);
+
+ formatTable(cursor, topicCellFormats, false);
+
+ return diff;
+
+ }
+
+ /**
+ * check if the topic with the given index is written to the table.
+ * @param topic the topic number (0 base)
+ * @return true if the topic is already written to the table. False if not.
+ * (false would mean new rows must be added to the table in order to
+ * be able to write this topic).
+ */
+ private boolean isWritten(int topic)
+ {
+ return (writtenTopics.size() > topic && writtenTopics.get(topic) != null);
+ }
+
+ /**
+ * rewrites a single cell containing.
+ * This is used in order to refresh the topic/responsible/duration data in the
+ * preview document, in response to a change in the gui (by the user).
+ * Since the structure of the topics table is flexible, we don't reference a cell
+ * number. Rather, we use "what" argument to specify which cell should be redrawn.
+ * The Topics object, which analyzed the structure of the topics table appon
+ * initialization, refreshes the approperiate cell.
+ * @param topic index of the topic (0 based).
+ * @param what 0 for num, 1 for topic, 2 for responsible, 3 for duration
+ * @param data the row's data.
+ * @throws Exception if something goes wrong (thow nothing should)
+ */
+ public void writeCell(int topic, int what, PropertyValue[] data) throws Exception
+ {
+ // if the whole row should be written...
+ if (!isWritten(topic))
+ {
+ write(topic, data);
+ // write only the "what" cell.
+ }
+ else
+ {
+ // calculate the table row.
+ int firstRow = 1 + (topic * rowsPerTopic) + 1;
+ // go to the first cell of this topic.
+ XTextTableCursor cursor = table.createCursorByCellName("A" + firstRow);
+
+ TextElement te = null;
+ int cursorMoves = 0;
+
+ switch (what)
+ {
+ case 0:
+ te = setItemText(numCell, data[0].Value);
+ cursorMoves = numCell;
+ break;
+ case 1:
+ te = setItemText(topicCell, data[1].Value);
+ cursorMoves = topicCell;
+ break;
+ case 2:
+ te = setItemText(responsibleCell, data[2].Value);
+ cursorMoves = responsibleCell;
+ break;
+ case 3:
+ te = setItemText(timeCell, data[3].Value);
+ cursorMoves = timeCell;
+ break;
+ }
+ // move the cursor to the needed cell...
+ cursor.goRight((short) cursorMoves, false);
+ XCell xc = table.getCellByName(cursor.getRangeName());
+ // and write it !
+ te.write(xc);
+ ((TableCellFormatter) topicCellFormats.get(cursorMoves)).format(xc);
+
+ }
+ }
+
+ /**
+ * writes the given topic.
+ * if the first topic was involved, reformat the
+ * first row.
+ * If any rows were added to the table, reformat
+ * the last row.
+ * @param topic the index of the topic to write.
+ * @param data the topic's data. (see TopicsControl
+ * for explanation about the topics data model)
+ * @throws Exception if something goes wrong (though nothing should).
+ */
+ public void write(int topic, PropertyValue[] data) throws Exception
+ {
+ int diff = write2(topic, data);
+ /* if the first topic has been written,
+ * one needs to reformat the first row.
+ */
+ if (topic == 0)
+ {
+ formatFirstRow();
+ }
+ /*
+ * if any rows were added, one needs to format
+ * the whole table again.
+ */
+ if (diff > 0)
+ {
+ formatLastRow();
+ }
+ }
+
+ /**
+ * Writes all the topics to thetopics table.
+ * @param topicsData a List containing all Topic's Data.
+ */
+ public void writeAll(List topicsData)
+ {
+ try
+ {
+ for (int i = 0; i < topicsData.size() - 1; i++)
+ {
+ write2(i, (PropertyValue[]) topicsData.get(i));
+ }
+ formatLastRow();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * removes obsolete rows, reducing the
+ * topics table to the given number of topics.
+ * Note this method does only reducing - if
+ * the number of topics given is greater than the
+ * number of actuall topics it does *not* add
+ * new rows !
+ * Note also that the first topic will never be removed.
+ * If the table contains no topics, the whole section will
+ * be removed uppon finishing.
+ * The reason for that is a "table-design" one: the first topic is
+ * maintained in order to be able to add rows with a design of this topic,
+ * and not of the header row.
+ * @param topics the number of topics the table should contain.
+ * @throws Exception
+ */
+ public void reduceDocumentTo(int topics) throws Exception
+ {
+ // we never remove the first topic...
+ if (topics <= 0)
+ {
+ topics = 1;
+ }
+ XTableRows tableRows = table.getRows();
+ int targetNumOfRows = topics * rowsPerTopic + 1;
+ if (tableRows.getCount() > targetNumOfRows)
+ {
+ tableRows.removeByIndex(targetNumOfRows, tableRows.getCount() - targetNumOfRows);
+ }
+ formatLastRow();
+ while (writtenTopics.size() > topics)
+ {
+ writtenTopics.remove(topics);
+ }
+ }
+
+ /**
+ * reapply the format of the first (header) row.
+ */
+ private void formatFirstRow()
+ {
+ XTextTableCursor cursor = table.createCursorByCellName("A1");
+ formatTable(cursor, firstRowFormat, false);
+ }
+
+ /**
+ * reaply the format of the last row.
+ */
+ private void formatLastRow()
+ {
+ XTextTableCursor cursor = table.createCursorByCellName("A1");
+ cursor.gotoEnd(false);
+ formatTable(cursor, lastRowFormat, true);
+ }
+
+ /**
+ * returns a text element for the given cell,
+ * which will write the given text.
+ * @param cell the topics cell number.
+ * @param value the value to write.
+ * @return a TextElement object which will write the given value
+ * to the given cell.
+ */
+ private TextElement setItemText(int cell, Object value)
+ {
+ if (cell >= 0)
+ {
+ TextElement te = ((TextElement) topicCells.get(cell));
+ if (te != null)
+ {
+ te.text = value.toString();
+ }
+ return te;
+ }
+ return null;
+ }
+
+ /**
+ * formats a series of cells from the given one,
+ * using the given List of TableCellFormatter objects,
+ * in the given order.
+ * This method is used to format the first (header) and the last
+ * rows of the table.
+ * @param cursor a table cursor, pointing to the start cell to format
+ * @param formats a List containing TableCellFormatter objects. Each will format one cell in the direction specified.
+ * @param reverse if true the cursor will move left, formatting in reverse order (used for the last row).
+ */
+ private void formatTable(XTextTableCursor cursor, List formats, boolean reverse)
+ {
+ for (int i = 0; i < formats.size(); i++)
+ {
+ ((TableCellFormatter) formats.get(i)).format(table.getCellByName(cursor.getRangeName()));
+ if (reverse)
+ {
+ cursor.goLeft((short) 1, false);
+ }
+ else
+ {
+ cursor.goRight((short) 1, false);
+ }
+ }
+ }
+ }
+
+
+ /*
+ * =================================
+ * Here are some static help methods
+ * =================================
+ */
+ public static String[] getNamesWhichStartWith(String[] allNames, String prefix)
+ {
+ Vector v = new Vector();
+ for (int i = 0; i < allNames.length; i++)
+ {
+ if (allNames[i].startsWith(prefix))
+ {
+ v.add(allNames[i]);
+ }
+ }
+ String[] s = new String[v.size()];
+ System.arraycopy(v.toArray(), 0, s, 0, s.length);
+ return s;
+ }
+
+ /**
+ * Convenience method, costs the given object to an XNamed, and returnes its name.
+ * @param obj an XNamed object.
+ * @return the name of the given object.
+ */
+ public static String getName(Object obj)
+ {
+ return ((XNamed) UnoRuntime.queryInterface(XNamed.class, obj)).getName();
+ }
+
+ /**
+ * convenience method, for removing a number of cells from a table.
+ * @param table
+ * @param start
+ * @param count
+ */
+ public static void removeTableRows(Object table, int start, int count)
+ {
+ XTableRows rows = ((XTextTable) UnoRuntime.queryInterface(XTextTable.class, table)).getRows();
+ rows.removeByIndex(start, count);
+ }
+
+ /**
+ * Convenience method for inserting some cells into a table.
+ * @param table
+ * @param start
+ * @param count
+ */
+ public static void insertTableRows(Object table, int start, int count)
+ {
+ XTableRows rows = ((XTextTable) UnoRuntime.queryInterface(XTextTable.class, table)).getRows();
+ rows.insertByIndex(start, count);
+ }
+
+ /**
+ * returns the row index for this cursor, assuming
+ * the cursor points to a single cell.
+ * @param cursor
+ * @return the row index in which the cursor is.
+ */
+ public static int getRowIndex(XTextTableCursor cursor)
+ {
+ return getRowIndex(cursor.getRangeName());
+ }
+
+ /**
+ * returns the row index for this cell name.
+ * @param cellName
+ * @return the row index for this cell name.
+ */
+ public static int getRowIndex(String cellName)
+ {
+ return Integer.parseInt(cellName.substring(1));
+ }
+
+ /**
+ * returns the rows count of this table, assuming
+ * there is no vertical merged cells.
+ * @param table
+ * @return the rows count of the given table.
+ */
+ public static int getRowCount(XTextTable table)
+ {
+ String[] cells = table.getCellNames();
+ return getRowIndex(cells[cells.length - 1]);
+ }
+}
+
+/*
+ * ===========================================================================================
+ *
+ * End of AgendaTempalte class
+ *
+ * ===========================================================================================
+ *
+ */
+/*
+ * =================================
+ * The AgendaElement interface
+ * =================================
+ */
+/**
+ * Interface that is used for writing content to a Uno Text / TextRange
+ * @author rp143992
+ *
+ */
+interface AgendaElement
+{
+
+ void write(Object any) throws Exception;
+}
+
+
+/*
+ * =================================
+ * The ParaStyled class
+ * =================================
+ */
+/**
+ * Basic implementation of the AgendaElement interface -
+ * writes nothing, but applies a ParaStyle to the given XText/XTextRange
+ * @author rp143992
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+class ParaStyled implements AgendaElement
+{
+
+ String paraStyle;
+
+ ParaStyled(String paraStyle_)
+ {
+ paraStyle = paraStyle_;
+ }
+
+ void format(Object textRange)
+ {
+ XText o;
+ o = ((XText) UnoRuntime.queryInterface(XText.class, textRange));
+ if (o == null)
+ {
+ o = ((XTextRange) UnoRuntime.queryInterface(XTextRange.class, textRange)).getText();
+ }
+ XTextRange xtr = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, textRange);
+ XTextCursor cursor = o.createTextCursorByRange(xtr);
+
+ Helper.setUnoPropertyValue(cursor, "ParaStyleName", paraStyle);
+ }
+
+ public void write(Object textRange)
+ {
+ format(textRange);
+ }
+}
+
+/*
+ * =================================
+ * The TextElement class
+ * =================================
+ */
+/**
+ * A basic implementation of AgendaElement:
+ * writes a String to the given XText/XTextRange, and applies
+ * a ParaStyle to it (using the parent class).
+ * @author rp143992
+ */
+class TextElement extends ParaStyled
+{
+
+ String text;
+
+ TextElement(XTextRange range)
+ {
+ this(range.getString(), (String) Helper.getUnoPropertyValue(range.getStart(), "ParaStyleName"));
+ }
+
+ TextElement(String text_, String paraStyle_)
+ {
+ super(paraStyle_);
+ text = text_;
+ }
+
+ public void write(Object textRange)
+ {
+ ((XTextRange) UnoRuntime.queryInterface(XTextRange.class, textRange)).setString(text);
+ if (!text.equals(""))
+ {
+ super.write(textRange);
+ }
+ }
+}
+
+/**
+ * A Text element which, if the text to write is empty (null or "")
+ * inserts a placeholder instead.
+ * @author rp143992
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+class PlaceholderTextElement extends TextElement
+{
+
+ String hint;
+ String placeHolderText;
+ XMultiServiceFactory xmsf;
+
+ PlaceholderTextElement(XTextRange textRange, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_)
+ {
+ super(textRange);
+ placeHolderText = placeHolderText_;
+ hint = hint_;
+ xmsf = xmsf_;
+ }
+
+ PlaceholderTextElement(String text, String paraStyle, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_)
+ {
+ super(text, paraStyle);
+ placeHolderText = placeHolderText_;
+ hint = hint_;
+ xmsf = xmsf_;
+ }
+
+ public void write(Object textRange)
+ {
+ super.write(textRange);
+ if (text == null || text.equals(""))
+ {
+ XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, textRange);
+ try
+ {
+ XTextContent xTextContent = AgendaTemplate.createPlaceHolder(xmsf, placeHolderText, hint);
+ xTextRange.getText().insertTextContent(xTextRange.getStart(), xTextContent, true);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+}
+
+/*
+ * =================================
+ * The PlaceHolder class
+ * =================================
+ */
+/**
+ * An Agenda element which writes no text, but inserts a placeholder, and formats
+ * it using a ParaStyleName.
+ * @author rp143992
+ *
+ */
+class PlaceholderElement extends ParaStyled
+{
+
+ String hint;
+ String placeHolderText;
+ XMultiServiceFactory xmsf;
+
+ PlaceholderElement(String paraStyle, String placeHolderText_, String hint_, XMultiServiceFactory xmsf_)
+ {
+ super(paraStyle);
+ placeHolderText = placeHolderText_;
+ hint = hint_;
+ xmsf = xmsf_;
+ }
+
+ public void write(Object textRange)
+ {
+ XTextRange xTextRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, textRange);
+ try
+ {
+ XTextContent xTextContent = AgendaTemplate.createPlaceHolder(xmsf, placeHolderText, hint);
+ xTextRange.getText().insertTextContent(xTextRange.getStart(), xTextContent, true);
+ super.write(textRange);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
+
+
+/*
+ * =================================
+ * The AgendaItem class
+ * =================================
+ */
+/**
+ * An implementation of AgendaElement which
+ * gets as a parameter a table cursor, and writes
+ * a text to the cell marked by this table cursor, and
+ * a place holder to the next cell.
+ * @author rp143992
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+class AgendaItem implements AgendaElement
+{
+
+ TextElement textElement;
+ AgendaElement field;
+ public Object table;
+ String name;
+
+ AgendaItem(String name_, TextElement te, AgendaElement f)
+ {
+ name = name_;
+ field = f;
+ textElement = te;
+ }
+
+ public void write(Object tableCursor) throws Exception
+ {
+ XTextTableCursor xTextTableCursor = (XTextTableCursor) UnoRuntime.queryInterface(XTextTableCursor.class, tableCursor);
+ XTextTable xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, table);
+
+ String cellname = xTextTableCursor.getRangeName();
+ Object cell = xTextTable.getCellByName(cellname);
+
+ textElement.write(cell);
+
+ xTextTableCursor.goRight((short) 1, false);
+
+ //second field is actually always null...
+ // this is a preparation for adding placeholders.
+ if (field != null)
+ {
+ field.write(xTextTable.getCellByName(xTextTableCursor.getRangeName()));
+ }
+ }
+}
+
+/*
+ * =================================
+ * The TableCellFormatter class
+ * =================================
+ */
+/**
+ * reads/write a table cell format from/to a table cell or a group of cells.
+ *
+ */
+class TableCellFormatter
+{
+
+ static String[] properties = new String[]
+ {
+ "BackColor",
+ "BackTransparent",
+ "BorderDistance",
+ "BottomBorder",
+ "BottomBorderDistance",
+ "LeftBorder",
+ "LeftBorderDistance",
+ "RightBorder",
+ "RightBorderDistance",
+ "TopBorder",
+ "TopBorderDistance"
+ };
+ private Object[] values = new Object[properties.length];
+
+ public TableCellFormatter(Object tableCell)
+ {
+ for (int i = 0; i < properties.length; i++)
+ {
+ values[i] = Helper.getUnoPropertyValue(tableCell, properties[i]);
+ }
+ }
+
+ public void format(Object tableCell)
+ {
+ Helper.setUnoPropertyValues(tableCell, properties, values);
+ }
+}
+
+
+
+
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java
new file mode 100644
index 000000000000..86567277da1d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialog.java
@@ -0,0 +1,385 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XDateField;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XTimeField;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.WizardDialog;
+
+/**
+ * This class is generated Automatically....
+ * bla bla bla
+ */
+public abstract class AgendaWizardDialog extends WizardDialog implements AgendaWizardDialogConst, UIConsts {
+ //GUI Components as Class members.
+ XFixedText lblTitle1;
+ XCheckBox chkMinutes;
+ XFixedText lblHelp1;
+ XFixedText lblPageDesign;
+ XListBox listPageDesign;
+ //Image Control
+ XControl imgHelp1;
+ XControl imgHelp2;
+ XControl imgHelp3;
+ XControl imgHelp4;
+ XControl imgHelp6;
+ XFixedText lblTitle2;
+ XFixedText lblTime;
+ XFixedText lblTitle;
+ XFixedText lblLocation;
+ XTextComponent cbLocation;
+ XTimeField txtTime;
+ XTextComponent txtTitle;
+ XFixedText lblHelp2;
+ XFixedText lblDate;
+ XDateField txtDate;
+ XFixedText lblTitle3;
+ XCheckBox chkMeetingTitle;
+ XCheckBox chkRead;
+ XCheckBox chkBring;
+ XCheckBox chkNotes;
+ XFixedText lblHelp3;
+ XFixedText lblTitle5;
+ XCheckBox chkConvenedBy;
+ XCheckBox chkPresiding;
+ XCheckBox chkNoteTaker;
+ XCheckBox chkTimekeeper;
+ XCheckBox chkAttendees;
+ XCheckBox chkObservers;
+ XCheckBox chkResourcePersons;
+ XFixedText lblHelp4;
+ XFixedText lblTitle4;
+ XFixedText lblTopic;
+ XFixedText lblResponsible;
+ XFixedText lblDuration;
+ //XFixedText lblHelp5;
+ XTextComponent txtTemplateName;
+ XRadioButton optCreateAgenda;
+ XRadioButton optMakeChanges;
+ XFixedText lblProceed;
+ XFixedText lblTemplateName;
+ XFixedText lblTemplatePath;
+ XFixedText lblTitle6;
+ XTextComponent txtTemplatePath;
+ XButton btnTemplatePath;
+ XFixedText lblHelp6;
+ XFixedText lblHelpPg6;
+ XButton btnInsert;
+ XButton btnRemove;
+ XButton btnUp;
+ XButton btnDown;
+
+ final private String IMGHELP1_HID = "";
+
+
+ //Font Descriptors as Class members.
+ FontDescriptor fontDescriptor1 = new FontDescriptor();
+ FontDescriptor fontDescriptor2 = new FontDescriptor();
+ FontDescriptor fontDescriptor4 = new FontDescriptor();
+
+ //Resources Object
+ AgendaWizardDialogResources resources;
+
+ private String[] PROPS_LIST = new String[] {"Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_LABEL_B = new String[] {"FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_CHECK = new String[] {"Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"};
+ private String[] PROPS_BUTTON = new String[] {"Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_X = new String[] {"Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_TEXTAREA = new String[] {"Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_TEXT = new String[] {"Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"};
+ private String[] PROPS_IMAGE = new String[] {"Border", "Height", "HelpURL", "ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"};
+
+ private static final Short NO_BORDER = new Short((short)0);
+
+ public AgendaWizardDialog(XMultiServiceFactory xmsf) {
+ super(xmsf,HID);
+ //Load Resources
+ resources = new AgendaWizardDialogResources(xmsf);
+
+ //set dialog properties...
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[] { "Closeable","Height","Moveable","PositionX","PositionY","Step","TabIndex","Title","Width"},
+ new Object[] { Boolean.TRUE,new Integer(210),Boolean.TRUE,new Integer(200),new Integer(52),INTEGERS[1],new Short((short)1),resources.resAgendaWizardDialog_title,new Integer(310)}
+ );
+
+ //Set member- FontDescriptors...
+ fontDescriptor1.Weight = 150;
+ fontDescriptor1.Underline = com.sun.star.awt.FontUnderline.SINGLE;
+ fontDescriptor2.Weight = 100;
+ fontDescriptor4.Weight = 150;
+ }
+
+ //build components
+ public void buildStep1() {
+ lblTitle1 = insertLabel("lblTitle1",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle1_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[1],new Short((short)100),new Integer(212)}
+ );
+ lblPageDesign = insertLabel("lblPageDesign",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblPageDesign_value,new Integer(97),new Integer(32),INTEGERS[1],new Short((short)101),new Integer(66)}
+ );
+ listPageDesign = insertListBox("listPageDesign", null, null,
+ PROPS_LIST,
+ new Object[] { Boolean.TRUE,INTEGER_12,LISTPAGEDESIGN_HID,new Integer(166),new Integer(30),INTEGERS[1],new Short((short)102),new Integer(70)}
+ );
+ chkMinutes = insertCheckBox("chkMinutes", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[9],CHKMINUTES_HID,resources.reschkMinutes_value,new Integer(97),new Integer(50),new Short((short)0),INTEGERS[1],new Short((short)103),new Integer(203)}
+ );
+ imgHelp1 = insertImage("imgHelp1",
+ PROPS_IMAGE,
+ new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID, AgendaWizardDialogConst.INFO_IMAGE_URL, new Integer(92),new Integer(145), Boolean.FALSE, INTEGERS[1], new Short((short)104),INTEGERS[10]}
+ );
+ lblHelp1 = insertLabel("lblHelp1",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(39),resources.reslblHelp1_value,Boolean.TRUE,new Integer(104),new Integer(145),INTEGERS[1],new Short((short)105),new Integer(199)}
+ );
+
+ }
+
+ public void buildStep2() {
+ lblTitle2 = insertLabel("lblTitle2",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle2_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[2],new Short((short)200),new Integer(212)}
+ );
+ lblDate = insertLabel("lblDate",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblDate_value,new Integer(97),new Integer(32),INTEGERS[2],new Short((short)201),new Integer(66)}
+ );
+ txtDate = insertDateField("txtDate", null,
+ PROPS_LIST,
+ new Object[] { Boolean.TRUE,INTEGER_12,TXTDATE_HID,new Integer(166),new Integer(30),INTEGERS[2],new Short((short)202),new Integer(70)}
+ );
+ lblTime = insertLabel("lblTime",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblTime_value,new Integer(97),new Integer(50),INTEGERS[2],new Short((short)203),new Integer(66)}
+ );
+ txtTime = insertTimeField("txtTime", null,
+ new String[] {"Height", "HelpURL", "PositionX", "PositionY", "Step", "StrictFormat", "TabIndex", "Width"},
+ new Object[] { INTEGER_12,TXTTIME_HID,new Integer(166),new Integer(48),INTEGERS[2],Boolean.TRUE,new Short((short)204),new Integer(70)}
+ );
+
+ lblTitle = insertLabel("lblTitle",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblTitle_value,new Integer(97),new Integer(68),INTEGERS[2],new Short((short)205),new Integer(66)}
+ );
+ txtTitle = insertTextField("txtTitle", null,
+ new String[] {"Height", "HelpURL", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"},
+ new Object[] { new Integer(26),TXTTITLE_HID,Boolean.TRUE,new Integer(166),new Integer(66),INTEGERS[2],new Short((short)206),new Integer(138)}
+ );
+ lblLocation = insertLabel("lblLocation",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblLocation_value,new Integer(97),new Integer(100),INTEGERS[2],new Short((short)207),new Integer(66)}
+ );
+ cbLocation = insertTextField("cbLocation", null,null,
+ new String[] { "Height", "HelpURL", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"},
+ new Object[] { new Integer(34),CBLOCATION_HID,Boolean.TRUE,new Integer(166),new Integer(98),INTEGERS[2],new Short((short)208),new Integer(138)}
+ );
+
+ imgHelp2 = insertImage("imgHelp2",
+ PROPS_IMAGE,
+ new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, new Integer(92),new Integer(145),Boolean.FALSE, INTEGERS[2],new Short((short)209),INTEGERS[10]}
+ );
+ lblHelp2 = insertLabel("lblHelp2",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(39),resources.reslblHelp2_value,Boolean.TRUE,new Integer(104),new Integer(145),INTEGERS[2],new Short((short)210),new Integer(199)}
+ );
+
+ }
+
+ public void buildStep3() {
+ lblTitle3 = insertLabel("lblTitle3",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle3_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[3],new Short((short)300),new Integer(212)}
+ );
+ chkMeetingTitle = insertCheckBox("chkMeetingTitle", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKMEETINGTITLE_HID,resources.reschkMeetingTitle_value,new Integer(97),new Integer(32),new Short((short)1),INTEGERS[3],new Short((short)301),new Integer(69)}
+ );
+ chkRead = insertCheckBox("chkRead", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKREAD_HID,resources.reschkRead_value,new Integer(97),new Integer(46),new Short((short)0),INTEGERS[3],new Short((short)302),new Integer(162)}
+ );
+ chkBring = insertCheckBox("chkBring", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKBRING_HID,resources.reschkBring_value,new Integer(97),new Integer(60),new Short((short)0),INTEGERS[3],new Short((short)303),new Integer(162)}
+ );
+ chkNotes = insertCheckBox("chkNotes", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKNOTES_HID,resources.reschkNotes_value,new Integer(97),new Integer(74),new Short((short)1),INTEGERS[3],new Short((short)304),new Integer(160)}
+ );
+ imgHelp3 = insertImage("imgHelp3",
+ PROPS_IMAGE,
+ new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, new Integer(92),new Integer(145),Boolean.FALSE, INTEGERS[3],new Short((short)305),INTEGERS[10]}
+ );
+ lblHelp3 = insertLabel("lblHelp3",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(39),resources.reslblHelp3_value,Boolean.TRUE,new Integer(104),new Integer(145),INTEGERS[3],new Short((short)306),new Integer(199)}
+ );
+ }
+
+ public void buildStep4() {
+ lblTitle5 = insertLabel("lblTitle5",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle5_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[4],new Short((short)400),new Integer(212)}
+ );
+ chkConvenedBy = insertCheckBox("chkConvenedBy", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKCONVENEDBY_HID,resources.reschkConvenedBy_value,new Integer(97),new Integer(32),new Short((short)1),INTEGERS[4],new Short((short)401),new Integer(150)}
+ );
+ chkPresiding = insertCheckBox("chkPresiding", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKPRESIDING_HID,resources.reschkPresiding_value,new Integer(97),new Integer(46),new Short((short)0),INTEGERS[4],new Short((short)402),new Integer(150)}
+ );
+ chkNoteTaker = insertCheckBox("chkNoteTaker", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKNOTETAKER_HID,resources.reschkNoteTaker_value,new Integer(97),new Integer(60),new Short((short)0),INTEGERS[4],new Short((short)403),new Integer(150)}
+ );
+ chkTimekeeper = insertCheckBox("chkTimekeeper", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKTIMEKEEPER_HID,resources.reschkTimekeeper_value,new Integer(97),new Integer(74),new Short((short)0),INTEGERS[4],new Short((short)404),new Integer(150)}
+ );
+ chkAttendees = insertCheckBox("chkAttendees", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKATTENDEES_HID,resources.reschkAttendees_value,new Integer(97),new Integer(88),new Short((short)1),INTEGERS[4],new Short((short)405),new Integer(150)}
+ );
+ chkObservers = insertCheckBox("chkObservers", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKOBSERVERS_HID,resources.reschkObservers_value,new Integer(97),new Integer(102),new Short((short)0),INTEGERS[4],new Short((short)406),new Integer(150)}
+ );
+ chkResourcePersons = insertCheckBox("chkResourcePersons", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],CHKRESOURCEPERSONS_HID,resources.reschkResourcePersons_value,new Integer(97),new Integer(116),new Short((short)0),INTEGERS[4],new Short((short)407),new Integer(150)}
+ );
+ imgHelp4 = insertImage("imgHelp4",
+ PROPS_IMAGE,
+ new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, new Integer(92),new Integer(145),Boolean.FALSE, INTEGERS[4],new Short((short)408),INTEGERS[10]}
+ );
+ lblHelp4 = insertLabel("lblHelp4",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(39),resources.reslblHelp4_value,Boolean.TRUE,new Integer(104),new Integer(145),INTEGERS[4],new Short((short)409),new Integer(199)}
+ );
+ }
+
+ public void buildStep5() {
+ lblTitle4 = insertLabel("lblTitle4",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle4_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[5],new Short((short)500),new Integer(212)}
+ );
+ lblTopic = insertLabel("lblTopic",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblTopic_value,new Integer(107),new Integer(28),INTEGERS[5],new Short((short)71),new Integer(501)}
+ );
+ lblResponsible = insertLabel("lblResponsible",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblResponsible_value,new Integer(195),new Integer(28),INTEGERS[5],new Short((short)72),new Integer(502)}
+ );
+ lblDuration = insertLabel("lblDuration",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblDuration_value,new Integer(267),new Integer(28),INTEGERS[5],new Short((short)73),new Integer(503)}
+ );
+
+
+
+
+
+ btnInsert = insertButton("btnInsert", BTNINSERT_ACTION_PERFORMED,
+ PROPS_BUTTON,
+ new Object[] { INTEGER_14,BTNINSERT_HID,resources.resButtonInsert,new Integer(92),new Integer(136),INTEGERS[5],new Short((short)580),INTEGER_40}
+ );
+ btnRemove = insertButton("btnRemove", BTNREMOVE_ACTION_PERFORMED,
+ PROPS_BUTTON,
+ new Object[] { INTEGER_14,BTNREMOVE_HID,resources.resButtonRemove,new Integer(134),new Integer(136),INTEGERS[5],new Short((short)581),INTEGER_40}
+ );
+ btnUp = insertButton("btnUp", BTNUP_ACTION_PERFORMED,
+ PROPS_BUTTON,
+ new Object[] { INTEGER_14,BTNUP_HID,resources.resButtonUp,new Integer(222),new Integer(136),INTEGERS[5],new Short((short)582),INTEGER_40}
+ );
+ btnDown = insertButton("btnDown", BTNDOWN_ACTION_PERFORMED,
+ PROPS_BUTTON,
+ new Object[] { INTEGER_14,BTNDOWN_HID,resources.resButtonDown,new Integer(264),new Integer(136),INTEGERS[5],new Short((short)583),INTEGER_40}
+ );
+
+
+ }
+
+ public void buildStep6() {
+
+ lblTitle6 = insertLabel("lblTitle6",
+ PROPS_LABEL_B,
+ new Object[] { fontDescriptor4,INTEGER_16,resources.reslblTitle6_value,Boolean.TRUE,new Integer(91),INTEGERS[8],INTEGERS[6],new Short((short)600),new Integer(212)}
+ );
+ lblHelpPg6 = insertLabel("lblHelpPg6",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(24),resources.reslblHelpPg6_value,Boolean.TRUE,new Integer(97),new Integer(32),INTEGERS[6],new Short((short)601),new Integer(204)}
+ );
+
+ lblTemplateName = insertLabel("lblTemplateName",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblTemplateName_value,new Integer(97),new Integer(62),INTEGERS[6],new Short((short)602),new Integer(101)}
+ );
+ txtTemplateName = insertTextField("txtTemplateName", TXTTEMPLATENAME_TEXT_CHANGED,
+ PROPS_X,
+ new Object[] { INTEGER_12,TXTTEMPLATENAME_HID,new Integer(202),new Integer(60),INTEGERS[6],new Short((short)603),new Integer(100)}
+ );
+ lblProceed = insertLabel("lblProceed",
+ PROPS_TEXT,
+ new Object[] { INTEGERS[8],resources.reslblProceed_value,new Integer(97),new Integer(101),INTEGERS[6],new Short((short)607),new Integer(204)}
+ );
+ optCreateAgenda = insertRadioButton("optCreateAgenda", null,
+ PROPS_CHECK,
+ new Object[] { INTEGERS[8],OPTCREATEAGENDA_HID,resources.resoptCreateAgenda_value,new Integer(103),new Integer(113),new Short((short)1),INTEGERS[6],new Short((short)608),new Integer(198)}
+ );
+ optMakeChanges = insertRadioButton("optMakeChanges", null,
+ PROPS_BUTTON,
+ new Object[] { INTEGERS[8],OPTMAKECHANGES_HID,resources.resoptMakeChanges_value,new Integer(103),new Integer(125),INTEGERS[6],new Short((short)609),new Integer(198)}
+ );
+ imgHelp6 = insertImage("imgHelp6",
+ PROPS_IMAGE,
+ new Object[] { NO_BORDER, INTEGERS[10],IMGHELP1_HID,AgendaWizardDialogConst.INFO_IMAGE_URL, new Integer(92),new Integer(145),Boolean.FALSE, INTEGERS[6],new Short((short)610),INTEGERS[10]}
+ );
+ lblHelp6 = insertLabel("lblHelp6",
+ PROPS_TEXTAREA,
+ new Object[] { new Integer(39),resources.reslblHelp6_value,Boolean.TRUE,new Integer(104),new Integer(145),INTEGERS[6],new Short((short)611),new Integer(199)}
+ );
+
+ }
+
+}
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java
new file mode 100644
index 000000000000..87d60d916731
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogConst.java
@@ -0,0 +1,109 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import com.sun.star.wizards.common.HelpIds;
+
+public interface AgendaWizardDialogConst {
+
+ /**
+ * These are event method names, used with reflection
+ * to call the methods under these names uppon
+ * events.
+ */
+
+ final String LISTPAGEDESIGN_ACTION_PERFORMED = "pageDesignChanged";
+ final String TXTTEMPLATENAME_TEXT_CHANGED = "templateTitleChanged";
+ final String BTNTEMPLATEPATH_ACTION_PERFORMED = "saveAs";
+ final String BTNINSERT_ACTION_PERFORMED = "insertRow";
+ final String BTNREMOVE_ACTION_PERFORMED = "removeRow";
+ final String BTNUP_ACTION_PERFORMED = "rowUp";
+ final String BTNDOWN_ACTION_PERFORMED = "rowDown";
+
+ final String INFO_IMAGE_URL = "private:resource/dbu/image/19205";
+ /* ====================================
+ * Help IDs
+ * ====================================
+ */
+ final int HID = 41051;
+
+ /*
+ * "HID:(hid)" - the dialog
+ * "HID:(hid+1) - the help button
+ * "HID:(hid+2)" - the back button
+ * "HID:(hid+3)" - the next button
+ * "HID:(hid+4)" - the create button
+ * "HID:(hid+5)" - the cancel button
+ */
+
+ final String LISTPAGEDESIGN_HID = HelpIds.getHelpIdString((HID + 6));
+ final String CHKMINUTES_HID = HelpIds.getHelpIdString((HID + 7));
+ final String TXTTIME_HID = HelpIds.getHelpIdString((HID + 8));
+ final String TXTDATE_HID = HelpIds.getHelpIdString((HID + 9));
+ final String TXTTITLE_HID = HelpIds.getHelpIdString((HID + 10));
+ final String CBLOCATION_HID = HelpIds.getHelpIdString((HID + 11));
+
+ final String CHKMEETINGTITLE_HID = HelpIds.getHelpIdString((HID + 12));
+ final String CHKREAD_HID = HelpIds.getHelpIdString((HID + 13));
+ final String CHKBRING_HID = HelpIds.getHelpIdString((HID + 14));
+ final String CHKNOTES_HID = HelpIds.getHelpIdString((HID + 15));
+
+ final String CHKCONVENEDBY_HID = HelpIds.getHelpIdString((HID + 16));
+ final String CHKPRESIDING_HID = HelpIds.getHelpIdString((HID + 17));
+ final String CHKNOTETAKER_HID = HelpIds.getHelpIdString((HID + 18));
+ final String CHKTIMEKEEPER_HID = HelpIds.getHelpIdString((HID + 19));
+ final String CHKATTENDEES_HID = HelpIds.getHelpIdString((HID + 20));
+ final String CHKOBSERVERS_HID = HelpIds.getHelpIdString((HID + 21));
+ final String CHKRESOURCEPERSONS_HID = HelpIds.getHelpIdString((HID + 22));
+
+ final String TXTTEMPLATENAME_HID = HelpIds.getHelpIdString((HID + 23));
+ final String TXTTEMPLATEPATH_HID = HelpIds.getHelpIdString((HID + 24));
+ final String BTNTEMPLATEPATH_HID = HelpIds.getHelpIdString((HID + 25));
+
+ final String OPTCREATEAGENDA_HID = HelpIds.getHelpIdString((HID + 26));
+ final String OPTMAKECHANGES_HID = HelpIds.getHelpIdString((HID + 27));
+
+ final String BTNINSERT_HID = HelpIds.getHelpIdString((HID + 28));
+ final String BTNREMOVE_HID = HelpIds.getHelpIdString((HID + 29));
+ final String BTNUP_HID = HelpIds.getHelpIdString((HID + 30));
+ final String BTNDOWN_HID = HelpIds.getHelpIdString((HID + 31));
+
+ final int LAST_HID = HID + 32;
+
+ /*
+ * 32 : scroll bar
+ * 33 - 35 first topics row
+ * 36 - 38 second
+ * 39 - 41
+ * 42 - 44
+ * 45 - 47
+ * total 5 rows / 3 controls.
+ */
+
+
+}
+
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java
new file mode 100644
index 000000000000..50ee492f8c78
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogImpl.java
@@ -0,0 +1,597 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.agenda;
+
+import java.util.Vector;
+
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.text.ViewHandler;
+import com.sun.star.wizards.ui.PathSelection;
+import com.sun.star.wizards.ui.XPathSelectionListener;
+import com.sun.star.wizards.ui.event.DataAware;
+import com.sun.star.wizards.ui.event.RadioDataAware;
+import com.sun.star.wizards.ui.event.UnoDataAware;
+
+/**
+ * This class is the dialog implementation class -
+ * there is not much business logic here - but mostley
+ * event methods.
+ * Some event methods are also implemented in TopicsControl and TopicsControl.ControlRow.
+ * @author rp143992
+ */
+public class AgendaWizardDialogImpl extends AgendaWizardDialog
+{
+ /**
+ * used to prevent a double start of the wizard.
+ */
+ static boolean running;
+
+ /**
+ * the preview document controller.
+ */
+ AgendaTemplate agendaTemplate;
+ /**
+ * the data model, read from the OOo configuration.
+ * (live synchronized: when the user changes the gui,
+ * the data model changes, except for topics).
+ */
+ private CGAgenda agenda;
+
+ /**
+ * the topics control, a gui element which
+ * manipulates the topics data according to the
+ * user's input.
+ */
+ private TopicsControl topicsControl;
+
+ /**
+ * an array with two array memebers:
+ * agendaTemplates[0] contains an array with
+ * UI template names.
+ * agendaTemplates[1] contains an array with
+ * corresponding URLs.
+ */
+ private String[][] agendaTemplates;
+
+ PathSelection myPathSelection;
+
+ String sTemplatePath;
+ String sUserTemplatePath;
+ String sBitmapPath;
+
+ String sPath;
+
+ /** constructor */
+ public AgendaWizardDialogImpl(XMultiServiceFactory xmsf)
+ {
+ super(xmsf);
+ }
+
+ protected void enterStep(int OldStep, int NewStep) {}
+ protected void leaveStep(int OldStep, int NewStep) {}
+
+ /**
+ * read the configuration data, open the specified template,
+ * initialize the template controller (AgendaTemplate) and
+ * set the status of the displayed template to the one
+ * read from the configuration.
+ * build the dialog.
+ * Synchronize the dialog to the same status (read from
+ * the configuration).
+ * show the dialog.
+ */
+ public void startWizard() {
+ running = true;
+ try {
+ // read configuration data.
+ agenda = new CGAgenda();
+
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", false);
+ agenda.readConfiguration(root,"cp_");
+
+ // initialize the agenda template
+ agendaTemplate = new AgendaTemplate(xMSF, agenda, resources, this);
+ initializeTemplates();
+
+ agendaTemplate.load(agendaTemplates[1][agenda.cp_AgendaType] , new Vector());
+
+ // build the dialog.
+ buildStep1();
+ buildStep2();
+ buildStep3();
+ buildStep4();
+ buildStep5();
+ topicsControl = new TopicsControl(this,xMSF, agenda);
+ buildStep6();
+ drawNaviBar();
+
+ initializePaths();
+
+ //special Control for setting the save Path:
+ insertPathSelectionControl();
+
+ // create the peer
+ XWindow xw = agendaTemplate.xFrame.getContainerWindow();
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xw);
+ this.createWindowPeer( xWindowPeer );
+
+ // initialize roadmap
+ this.addRoadmap();
+ this.insertRoadMapItems(
+ new String[] { resources.resStep1, resources.resStep2, resources.resStep3, resources.resStep4, resources.resStep5, resources.resStep6, } ,
+ new int[] { 1,2,3,4,5,6},
+ new boolean[] { true,true,true,true,true,true }
+ );
+ this.setMaxStep(6);
+
+ // synchronize GUI and CGAgenda object.
+ makeDA();
+ if(myPathSelection.xSaveTextBox.getText().equalsIgnoreCase("")) {myPathSelection.initializePath();}
+
+ executeDialog(agendaTemplate.xFrame);
+ removeTerminateListener();
+ closeDocument();
+ running = false;
+
+ }
+ catch (Exception ex) {
+ removeTerminateListener();
+ ex.printStackTrace();
+ running=false;
+ return;
+ }
+
+
+ }
+
+ private class myPathSelectionListener implements XPathSelectionListener {
+ public void validatePath() {
+ if (myPathSelection.usedPathPicker) {
+ filenameChanged = true;
+ }
+ myPathSelection.usedPathPicker = false;
+ }
+ }
+
+
+ public void insertPathSelectionControl() {
+ myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE);
+ myPathSelection.insert(6, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString( HID + 24 ), HelpIds.getHelpIdString( HID + 25 ));
+ myPathSelection.sDefaultDirectory = sUserTemplatePath;
+ myPathSelection.sDefaultName = "myAgendaTemplate.ott";
+ myPathSelection.sDefaultFilter = "writer8_template";
+ myPathSelection.addSelectionListener(new myPathSelectionListener());
+ }
+
+ private void initializePaths() {
+ try {
+ sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard");
+ sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", "");
+ sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap");
+ } catch (NoValidPathException e) {
+ e.printStackTrace();
+ }
+ }
+
+ private void checkSavePath() {
+ if (agenda.cp_TemplatePath == null ||
+ agenda.cp_TemplatePath.equals("") ||
+ !getFileAccess().exists(FileAccess.getParentDir(agenda.cp_TemplatePath),false) ||
+ !getFileAccess().isDirectory(FileAccess.getParentDir(agenda.cp_TemplatePath )))
+ {
+ try {
+ agenda.cp_TemplatePath =
+ FileAccess.connectURLs(
+ FileAccess.getOfficePath(xMSF, "Work", "", "") ,
+ resources.resDefaultFilename
+ );
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ /**
+ * bind controls to the agenda member (DataAware model)
+ */
+ private void makeDA() {
+
+ setControlProperty("listPageDesign", "StringItemList", agendaTemplates[0]);
+
+ checkSavePath();
+ //setFilename(agenda.cp_TemplatePath);
+
+ UnoDataAware.attachListBox( agenda, "cp_AgendaType", listPageDesign , null, true ).updateUI();
+ UnoDataAware.attachCheckBox( agenda, "cp_IncludeMinutes", chkMinutes, null, true).updateUI();
+
+ UnoDataAware.attachEditControl(agenda, "cp_Title", txtTitle, agendaTemplate , true).updateUI();
+ UnoDataAware.attachDateControl(agenda, "cp_Date", txtDate, agendaTemplate , true).updateUI();
+ UnoDataAware.attachTimeControl(agenda, "cp_Time", txtTime, agendaTemplate , true).updateUI();
+ UnoDataAware.attachEditControl(agenda, "cp_Location", cbLocation, agendaTemplate , true).updateUI();
+
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowMeetingType", chkMeetingTitle , new RedrawListener( TemplateConsts.FILLIN_MEETING_TYPE ) , true);
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowRead", chkRead , new RedrawListener( TemplateConsts.FILLIN_READ ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowBring", chkBring , new RedrawListener( TemplateConsts.FILLIN_BRING ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowNotes", chkNotes , new RedrawListener( TemplateConsts.FILLIN_NOTES ) , true).updateUI();
+
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowCalledBy", chkConvenedBy , new RedrawListener( TemplateConsts.FILLIN_CALLED_BY ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowFacilitator", chkPresiding , new RedrawListener( TemplateConsts.FILLIN_FACILITATOR ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowNotetaker", chkNoteTaker , new RedrawListener( TemplateConsts.FILLIN_NOTETAKER ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowTimekeeper", chkTimekeeper , new RedrawListener( TemplateConsts.FILLIN_TIMEKEEPER ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowAttendees", chkAttendees , new RedrawListener( TemplateConsts.FILLIN_PARTICIPANTS ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowObservers", chkObservers , new RedrawListener( TemplateConsts.FILLIN_OBSERVERS ) , true).updateUI();
+ UnoDataAware.attachCheckBox(agenda,"cp_ShowResourcePersons", chkResourcePersons , new RedrawListener( TemplateConsts.FILLIN_RESOURCE_PERSONS ) , true).updateUI();
+
+ UnoDataAware.attachEditControl(agenda, "cp_TemplateName", txtTemplateName, null, true).updateUI();
+ RadioDataAware.attachRadioButtons( agenda, "cp_ProceedMethod",
+ new Object[] {optCreateAgenda, optMakeChanges} ,null,true).updateUI();
+
+ listPageDesign.addItemListener(new XItemListener() {
+ public void itemStateChanged(ItemEvent ie) {
+ pageDesignChanged(ie);
+ }
+ public void disposing(EventObject eo) {}
+ });
+ }
+
+ /** used in developement to start the wizard */
+ public static void main(String args[])
+ {
+ String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ try {
+ XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr);
+ AgendaWizardDialogImpl wizard = new AgendaWizardDialogImpl(xLocMSF);
+ wizard.startWizard();
+
+ }
+ catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+
+
+ /*
+ private void initializePaths() {
+ try {
+
+ sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user");
+ sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap");
+ } catch (NoValidPathException e) {
+ e.printStackTrace();
+ }
+ }*/
+
+ /**
+ * read the available agenda wizard templates.
+ */
+ public boolean initializeTemplates() {
+ try {
+ String sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard");
+
+ //sCurrentNorm = Norms[getCurrentLetter().cp_Norm];
+ String sAgendaPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/wizard/agenda" );
+
+ agendaTemplates = FileAccess.getFolderTitles(xMSF, "aw" , sAgendaPath);
+
+ return true;
+ } catch (NoValidPathException nopathexception) {
+ nopathexception.printStackTrace();
+ return false;
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ return false;
+ }
+ }
+
+ /* ******************************
+ * Event methods
+ * ******************************
+ */
+
+ /**
+ * first page, page design listbox changed.
+ */
+ public void pageDesignChanged(ItemEvent ie) {
+ int selected = ie.Selected;
+ try {
+ agendaTemplate.load( agendaTemplates[1][selected] , topicsControl.getTopicsData());
+ }
+ catch (Exception ex) {
+ SystemDialog.showMessageBox(xMSF, "ErrBox", VclWindowPeerAttribute.OK, resources.resErrOpenTemplate);
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * last page, template title changed...
+ */
+ public void templateTitleChanged() {
+ String title = (String)Helper.getUnoPropertyValue( getModel(txtTemplateName), "Text" );
+ agendaTemplate.setTemplateTitle( title );
+ }
+
+
+ private FileAccess fileAccess1;
+ /** convenience method.
+ * instead of creating a FileAccess object every time
+ * it is needed, I have a FileAccess object memeber.
+ * the first time it is needed it will be created, and
+ * then be reused...
+ * @return the FileAccess memeber object.
+ */
+ private FileAccess getFileAccess() {
+ if (fileAccess1 == null)
+ try {
+ fileAccess1 = new FileAccess(xMSF);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return fileAccess1;
+
+ }
+ /**
+ * indicates if the filename was changed by the user through
+ * the "save as" dialog.
+ * If it is so, one needs not warn the user
+ * upon overwrite, since she was already warned.
+ */
+ private boolean filenameChanged = false;
+
+ /**
+ * last page, "browse" ("...") button was clicked...
+ */
+ public void saveAs() {
+ try {
+
+ checkSavePath();
+
+ SystemDialog saveAs = SystemDialog.createStoreDialog(xMSF);
+ saveAs.addFilterToDialog("ott","writer8_template",true);
+ // call the saveAs dialog.
+ String url = saveAs.callStoreDialog(
+ FileAccess.getParentDir(agenda.cp_TemplatePath),
+ FileAccess.getFilename(agenda.cp_TemplatePath));
+
+ if (url != null) {
+ agenda.cp_TemplatePath = url;
+ setFilename(url);
+ filenameChanged = true;
+ }
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+
+ }
+
+ /**
+ * is called when the user
+ * changes the path through the "save as" dialog.
+ * The path displayed is a translated, user-friendly, platform dependant path.
+ * @param url the new save url.
+ */
+ private void setFilename(String url) {
+ try {
+ String path = getFileAccess().getPath(url,"");
+ Helper.setUnoPropertyValue( getModel(myPathSelection.xSaveTextBox), "Text", path);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public void insertRow() {
+ topicsControl.insertRow();
+ }
+
+ public void removeRow() {
+ topicsControl.removeRow();
+ }
+
+ public void rowUp() {
+ topicsControl.rowUp();
+ }
+
+ public void rowDown() {
+ topicsControl.rowDown();
+ }
+
+
+ /* ************************
+ * Navigation bar methods
+ * ************************
+ */
+
+ public void cancelWizard() {
+ xDialog.endExecute();
+ running = false;
+ }
+
+ public boolean finishWizard() {
+ boolean bSaveSuccess = false; // pesimistic :(
+ XTextDocument xTextDocument;
+
+ try {
+ FileAccess fileAccess = new FileAccess(xMSF);
+ sPath = myPathSelection.getSelectedPath();
+ if (sPath.equals("")) {
+ myPathSelection.triggerPathPicker();
+ sPath = myPathSelection.getSelectedPath();
+ }
+ sPath = fileAccess.getURL(sPath);
+
+ //first, if the filename was not changed, thus
+ //it is coming from a saved session, check if the
+ // file exists and warn the user.
+ if (!filenameChanged)
+ if (fileAccess.exists(sPath, true)) {
+
+ int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resFileExists);
+ if (answer == 3) // user said: no, do not overwrite....
+ return false;
+ }
+
+ agendaTemplate.xTextDocument.lockControllers();
+
+ xTextDocument = (XTextDocument)UnoRuntime.queryInterface(XTextDocument.class,agendaTemplate.document);
+
+ bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath , "writer8_template", false );
+ } catch (Exception e) {
+ SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "ErrBox", VclWindowPeerAttribute.OK, resources.resErrSaveTemplate);
+ //e.printStackTrace();
+ }
+
+ if (bSaveSuccess) {
+ try {
+ topicsControl.saveTopics(agenda);
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Agenda", true);
+ agenda.writeConfiguration(root,"cp_");
+ Configuration.commit(root);
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+
+ agendaTemplate.finish( topicsControl.getTopicsData());
+ try {
+ XStorable xStoreable = (XStorable) UnoRuntime.queryInterface(XStorable.class, agendaTemplate.document);
+ xStoreable.store();
+ }
+ catch (Exception ex) {
+ SystemDialog.showMessageBox(xMSF, "ErrBox", VclWindowPeerAttribute.OK, resources.resErrSaveTemplate);
+ ex.printStackTrace();
+ }
+
+ //xWindow.setVisible(false);
+ //running = false;
+ agendaTemplate.xTextDocument.unlockControllers();
+ //closeDocument();
+ //removeTerminateListener();
+
+ PropertyValue loadValues[] = new PropertyValue[2];
+ loadValues[0] = new PropertyValue();
+ loadValues[0].Name = "AsTemplate";
+ if (agenda.cp_ProceedMethod == 1) {
+ loadValues[0].Value = Boolean.TRUE;
+ } else {
+ loadValues[0].Value = Boolean.FALSE;
+ }
+ loadValues[1] = new PropertyValue();
+ loadValues[1].Name = "InteractionHandler";
+ try {
+ XInteractionHandler xIH = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler"));
+ loadValues[1].Value = xIH;
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ //Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), agenda.cp_TemplatePath, "_default", new PropertyValue[0]);
+ Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", new PropertyValue[0]);
+ xTextDocument = (com.sun.star.text.XTextDocument) oDoc;
+ XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument);
+ try {
+ myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL));
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ } else {
+ agendaTemplate.xTextDocument.unlockControllers();
+ return false;
+ }
+ xDialog.endExecute();
+ running = false;
+ return true;
+ }
+
+ private void closeDocument() {
+ try {
+ //xComponent.dispose();
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, agendaTemplate.xFrame);
+ xCloseable.close(false);
+ } catch (CloseVetoException e) {
+ e.printStackTrace();
+ }
+ }
+
+ /* ********************
+ * Sub Classes
+ * ********************
+ */
+
+
+ /**
+ * this class is used to redraw an item's table when
+ * the user clicks one of the checkboxes in step 3 or 4.
+ */
+ private class RedrawListener implements DataAware.Listener {
+
+ private String itemName;
+
+ public RedrawListener(String itemName_) {
+ itemName = itemName_;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Listener#eventPerformed(java.lang.Object)
+ */
+ public void eventPerformed(Object event) {
+ agendaTemplate.xTextDocument.lockControllers();
+ agendaTemplate.redraw(itemName);
+ agendaTemplate.xTextDocument.unlockControllers();
+ }
+ }
+
+
+}
+
diff --git a/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java
new file mode 100644
index 000000000000..21730c9aa040
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/AgendaWizardDialogResources.java
@@ -0,0 +1,221 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.agenda;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Resource;
+
+public class AgendaWizardDialogResources extends Resource {
+
+ final static String UNIT_NAME = "dbwizres";
+ final static String MODULE_NAME = "dbw";
+ final static int RID_AGENDAWIZARDDIALOG_START = 5000;
+ final static int RID_COMMON_START = 500;
+
+
+ String resAgendaWizardDialog_title;
+ String resoptMakeChanges_value;
+ String reslblTemplateName_value;
+ String reslblTemplatePath_value;
+ String reslblProceed_value;
+ String reslblTitle1_value;
+ String reslblTitle3_value;
+ String reslblTitle2_value;
+ String reslblTitle4_value;
+ String reslblTitle5_value;
+ String reslblTitle6_value;
+ String reschkMinutes_value;
+ String reslblHelp1_value;
+ String reslblTime_value;
+ String reslblTitle_value;
+ String reslblLocation_value;
+ String reslblHelp2_value;
+ String resbtnTemplatePath_value;
+ String resoptCreateAgenda_value;
+ String reslblHelp6_value;
+ String reslblTopic_value;
+ String reslblResponsible_value;
+ String reslblDuration_value;
+ String reschkConvenedBy_value;
+ String reschkPresiding_value;
+ String reschkNoteTaker_value;
+ String reschkTimekeeper_value;
+ String reschkAttendees_value;
+ String reschkObservers_value;
+ String reschkResourcePersons_value;
+ String reslblHelp4_value;
+ String reschkMeetingTitle_value;
+ String reschkRead_value;
+ String reschkBring_value;
+ String reschkNotes_value;
+ String reslblHelp3_value;
+
+ String reslblDate_value;
+ String reslblHelpPg6_value;
+ String reslblPageDesign_value;
+
+ String resDefaultFilename;
+ String resDefaultTitle;
+
+ String resErrSaveTemplate;
+
+ String resPlaceHolderTitle;
+ String resPlaceHolderDate;
+ String resPlaceHolderTime;
+ String resPlaceHolderLocation;
+ String resPlaceHolderHint;
+
+ String resStep1;
+ String resStep2;
+ String resStep3;
+ String resStep4;
+ String resStep5;
+ String resStep6;
+
+ String resErrOpenTemplate;
+
+ String itemMeetingType;
+ String itemRead;
+ String itemBring;
+ String itemNote;
+ String itemCalledBy;
+ String itemFacilitator;
+ String itemNotetaker;
+ String itemTimekeeper;
+ String itemAttendees;
+ String itemObservers;
+ String itemResource;
+
+ String resButtonInsert;
+ String resButtonRemove;
+ String resButtonUp;
+ String resButtonDown;
+
+
+
+
+ // *** common resources ***
+
+ String resFileExists;
+
+public AgendaWizardDialogResources(XMultiServiceFactory xmsf) {
+ super(xmsf,UNIT_NAME,MODULE_NAME);
+
+ /**
+ * Delete the String, uncomment the getResText method
+ *
+ */
+ resAgendaWizardDialog_title = getResText(RID_AGENDAWIZARDDIALOG_START + 1);
+ resoptMakeChanges_value = getResText(RID_AGENDAWIZARDDIALOG_START + 2);
+ reslblTemplateName_value = getResText(RID_AGENDAWIZARDDIALOG_START + 3);
+ reslblTemplatePath_value = getResText(RID_AGENDAWIZARDDIALOG_START + 4);
+ reslblProceed_value = getResText(RID_AGENDAWIZARDDIALOG_START + 5);
+ reslblTitle1_value = getResText(RID_AGENDAWIZARDDIALOG_START + 6);
+ reslblTitle3_value = getResText(RID_AGENDAWIZARDDIALOG_START + 7);
+ reslblTitle2_value = getResText(RID_AGENDAWIZARDDIALOG_START + 8);
+ reslblTitle4_value = getResText(RID_AGENDAWIZARDDIALOG_START + 9);
+ reslblTitle5_value = getResText(RID_AGENDAWIZARDDIALOG_START + 10);
+ reslblTitle6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 11);
+ reschkMinutes_value = getResText(RID_AGENDAWIZARDDIALOG_START + 12);
+ reslblHelp1_value = getResText(RID_AGENDAWIZARDDIALOG_START + 13);
+ reslblTime_value = getResText(RID_AGENDAWIZARDDIALOG_START + 14);
+ reslblTitle_value = getResText(RID_AGENDAWIZARDDIALOG_START + 15);
+ reslblLocation_value = getResText(RID_AGENDAWIZARDDIALOG_START + 16);
+ reslblHelp2_value = getResText(RID_AGENDAWIZARDDIALOG_START + 17);
+ resbtnTemplatePath_value = getResText(RID_AGENDAWIZARDDIALOG_START + 18);
+ resoptCreateAgenda_value = getResText(RID_AGENDAWIZARDDIALOG_START + 19);
+ reslblHelp6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 20);
+ reslblTopic_value = getResText(RID_AGENDAWIZARDDIALOG_START + 21);
+ reslblResponsible_value = getResText(RID_AGENDAWIZARDDIALOG_START + 22);
+ reslblDuration_value = getResText(RID_AGENDAWIZARDDIALOG_START + 23);
+ reschkConvenedBy_value = getResText(RID_AGENDAWIZARDDIALOG_START + 24);
+ reschkPresiding_value = getResText(RID_AGENDAWIZARDDIALOG_START + 25);
+ reschkNoteTaker_value = getResText(RID_AGENDAWIZARDDIALOG_START + 26);
+ reschkTimekeeper_value = getResText(RID_AGENDAWIZARDDIALOG_START + 27);
+ reschkAttendees_value = getResText(RID_AGENDAWIZARDDIALOG_START + 28);
+ reschkObservers_value = getResText(RID_AGENDAWIZARDDIALOG_START + 29);
+ reschkResourcePersons_value = getResText(RID_AGENDAWIZARDDIALOG_START + 30);
+ reslblHelp4_value = getResText(RID_AGENDAWIZARDDIALOG_START + 31);
+ reschkMeetingTitle_value = getResText(RID_AGENDAWIZARDDIALOG_START + 32);
+ reschkRead_value = getResText(RID_AGENDAWIZARDDIALOG_START + 33);
+ reschkBring_value = getResText(RID_AGENDAWIZARDDIALOG_START + 34);
+ reschkNotes_value = getResText(RID_AGENDAWIZARDDIALOG_START + 35);
+ reslblHelp3_value = getResText(RID_AGENDAWIZARDDIALOG_START + 36);
+ reslblDate_value = getResText(RID_AGENDAWIZARDDIALOG_START + 38);
+ reslblHelpPg6_value = getResText(RID_AGENDAWIZARDDIALOG_START + 39);
+ reslblPageDesign_value = getResText(RID_AGENDAWIZARDDIALOG_START + 40);
+
+ resDefaultFilename = getResText(RID_AGENDAWIZARDDIALOG_START + 41);
+ resDefaultFilename = resDefaultFilename.substring(0,resDefaultFilename.length()-4) + ".ott";
+
+ resDefaultTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 42);
+
+ resErrSaveTemplate = getResText(RID_AGENDAWIZARDDIALOG_START + 43);
+
+ resPlaceHolderTitle = getResText(RID_AGENDAWIZARDDIALOG_START + 44);
+ resPlaceHolderDate = getResText(RID_AGENDAWIZARDDIALOG_START + 45);
+ resPlaceHolderTime = getResText(RID_AGENDAWIZARDDIALOG_START + 46);
+ resPlaceHolderLocation = getResText(RID_AGENDAWIZARDDIALOG_START + 47);
+ resPlaceHolderHint = getResText(RID_AGENDAWIZARDDIALOG_START + 48);
+
+
+ resStep1 = getResText(RID_AGENDAWIZARDDIALOG_START + 50);
+ resStep2 = getResText(RID_AGENDAWIZARDDIALOG_START + 51);
+ resStep3 = getResText(RID_AGENDAWIZARDDIALOG_START + 52);
+ resStep4 = getResText(RID_AGENDAWIZARDDIALOG_START + 53);
+ resStep5 = getResText(RID_AGENDAWIZARDDIALOG_START + 54);
+ resStep6 = getResText(RID_AGENDAWIZARDDIALOG_START + 55);
+
+ resErrOpenTemplate = getResText(RID_AGENDAWIZARDDIALOG_START + 56);
+
+ itemMeetingType = getResText(RID_AGENDAWIZARDDIALOG_START + 57);
+ itemBring = getResText(RID_AGENDAWIZARDDIALOG_START + 58);
+ itemRead = getResText(RID_AGENDAWIZARDDIALOG_START + 59);
+ itemNote = getResText(RID_AGENDAWIZARDDIALOG_START + 60);
+
+ itemCalledBy = getResText(RID_AGENDAWIZARDDIALOG_START + 61);
+ itemFacilitator = getResText(RID_AGENDAWIZARDDIALOG_START + 62);
+ itemAttendees = getResText(RID_AGENDAWIZARDDIALOG_START + 63);
+ itemNotetaker = getResText(RID_AGENDAWIZARDDIALOG_START + 64);
+ itemTimekeeper = getResText(RID_AGENDAWIZARDDIALOG_START + 65);
+ itemObservers = getResText(RID_AGENDAWIZARDDIALOG_START + 66);
+ itemResource = getResText(RID_AGENDAWIZARDDIALOG_START + 67);
+
+ resButtonInsert = getResText(RID_AGENDAWIZARDDIALOG_START + 68);
+ resButtonRemove = getResText(RID_AGENDAWIZARDDIALOG_START + 69);
+ resButtonUp = getResText(RID_AGENDAWIZARDDIALOG_START + 70);
+ resButtonDown = getResText(RID_AGENDAWIZARDDIALOG_START + 71);
+
+ /*
+ * Common resources
+ */
+
+ resFileExists = getResText(RID_COMMON_START + 19);
+
+ }
+}
diff --git a/wizards/com/sun/star/wizards/agenda/CGAgenda.java b/wizards/com/sun/star/wizards/agenda/CGAgenda.java
new file mode 100644
index 000000000000..b7dc1cc37c00
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/CGAgenda.java
@@ -0,0 +1,83 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import com.sun.star.wizards.common.ConfigGroup;
+import com.sun.star.wizards.common.ConfigSet;
+
+/**
+ * CGAgenda means Configuration Group Agenda.
+ * This object encapsulates a OOo configuration group, used
+ * to save the state of the agenda wizard for reloading uppon
+ * next start.
+ */
+public class CGAgenda extends ConfigGroup
+{
+
+ /** step 1 - design*/
+ public int cp_AgendaType;
+ /** step 1 - include minutes*/
+ public boolean cp_IncludeMinutes;
+ /** step 2 - title */
+ public String cp_Title = "";
+ /** step 2 - date */
+ public String cp_Date;
+ /** step 2 - time */
+ public String cp_Time;
+ /** step 2 - location */
+ public String cp_Location = "";
+ /** step 3 - show meeting type */
+ public boolean cp_ShowMeetingType;
+ /** step 3 - show read */
+ public boolean cp_ShowRead;
+ /** step 3 - show bring */
+ public boolean cp_ShowBring;
+ /** step 3 - show notes */
+ public boolean cp_ShowNotes;
+ /** step 4 - show called by */
+ public boolean cp_ShowCalledBy;
+ /** step 4 - show facilitator */
+ public boolean cp_ShowFacilitator;
+ /** step 4 - show notes taker */
+ public boolean cp_ShowNotetaker;
+ /** step 4 - show time keeper */
+ public boolean cp_ShowTimekeeper;
+ /** step 4 - show attendees */
+ public boolean cp_ShowAttendees;
+ /** step 4 - show observers */
+ public boolean cp_ShowObservers;
+ /** step 4 - show resource persons */
+ public boolean cp_ShowResourcePersons;
+ /** page 6 - template title */
+ public String cp_TemplateName;
+ /** page 6 - template url */
+ public String cp_TemplatePath;
+ /** page 6 - how to proceed */
+ public int cp_ProceedMethod;
+ /** page 5 - topics ( a set )*/
+ public ConfigSet cp_Topics = new ConfigSet(CGTopic.class);
+}
diff --git a/wizards/com/sun/star/wizards/agenda/CGTopic.java b/wizards/com/sun/star/wizards/agenda/CGTopic.java
new file mode 100644
index 000000000000..74b818205b9f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/CGTopic.java
@@ -0,0 +1,87 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.wizards.common.ConfigGroup;
+import com.sun.star.wizards.common.Indexable;
+
+/**
+ * CGTopic means: Configuration Group Topic.
+ * This object encapsulates a configuration group with topic information.
+ * Since the topics gui conftrol uses its own data model, there is
+ * also code here to convert from the data model to CGTopic object (the constructor)
+ * and vice versa (setDataToRow method - used when loading the last session...)
+ */
+public class CGTopic extends ConfigGroup implements Indexable {
+
+ /** sort order */
+ public int cp_Index;
+ /** topic name */
+ public String cp_Topic;
+ /** responsible */
+ public String cp_Responsible;
+ /** time */
+ public String cp_Time;
+
+ public CGTopic() {}
+
+ /**
+ * create a new CGTopic object with data from the given row.
+ * the row object is a PropertyValue array, as used
+ * by the TopicsControl's data model.
+ * @param row PropertyValue array as used by the TopicsControl data model.
+ */
+ public CGTopic( Object row) {
+ PropertyValue[] pv = (PropertyValue[])row;
+ String num = (String)pv[0].Value;
+ cp_Index = Integer.valueOf(num.substring(0,num.length() - 1)).intValue();
+ cp_Topic = (String)pv[1].Value;
+ cp_Responsible = (String)pv[2].Value;
+ cp_Time = (String)pv[3].Value;
+ }
+
+ /**
+ * copies the data in this CGTopic object
+ * to the given row.
+ * @param row the row object (PropertyValue array) to
+ * copy the data to.
+ */
+ public void setDataToRow(Object row) {
+ PropertyValue[] pv = (PropertyValue[])row;
+ pv[0].Value = "" + cp_Index + ".";
+ pv[1].Value = cp_Topic;
+ pv[2].Value = cp_Responsible;
+ pv[3].Value = cp_Time;
+ }
+
+ public int getIndex() {
+ return cp_Index;
+ }
+
+}
diff --git a/wizards/com/sun/star/wizards/agenda/CallWizard.java b/wizards/com/sun/star/wizards/agenda/CallWizard.java
new file mode 100644
index 000000000000..3dc8dcd8ef91
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/CallWizard.java
@@ -0,0 +1,224 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.task.XJob;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.Type;
+
+/**
+ * This class capsulates the class, that implements the minimal component, a factory for
+ * creating the service (<CODE>__getServiceFactory</CODE>).
+ *
+ * @author $author$
+ * @version $Revision: 1.5.52.1 $
+ */
+public class CallWizard {
+
+ /**
+ * Gives a factory for creating the service. This method is called by the
+ * <code>JavaLoader</code>
+ *
+ * <p></p>
+ *
+ * @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 tree
+ * structures) of a single registry key accessible.
+ *
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the component.
+ *
+ * @see com.sun.star.comp.loader.JavaLoader#
+ */
+ public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey) {
+ XSingleServiceFactory xsingleservicefactory = null;
+
+ if (stringImplementationName.equals(WizardImplementation.class.getName())) {
+ xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__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 WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor {
+
+ /**
+ * The constructor of the inner class has a XMultiServiceFactory parameter.
+ *
+ * @param xmultiservicefactoryInitialization A special service factory could be
+ * introduced while initializing.
+ */
+ public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization) {
+ xmultiservicefactory = xmultiservicefactoryInitialization;
+
+ if (xmultiservicefactory != null) {
+
+ }
+ }
+
+ /**
+ * Execute Wizard
+ *
+ * @param str only valid parameter is 'start' at the moment.
+ */
+
+ public void trigger(String str) {
+ try {
+ if (str.equalsIgnoreCase("start")) {
+ AgendaWizardDialogImpl aw = new AgendaWizardDialogImpl(xmultiservicefactory);
+ if (!AgendaWizardDialogImpl.running) {
+ aw.startWizard();
+ }
+ }
+ }
+ catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ //*******************************************
+
+ /**
+ * The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "com.sun.star.wizards.agenda.CallWizard";
+
+ /**
+ * The service manager, that gives access to all registered services.
+ */
+ private 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 method returns an array of all supported service names.
+ *
+ * @return Array of supported service names.
+ */
+ public java.lang.String[] getSupportedServiceNames() {
+ String[] stringSupportedServiceNames = new String[1];
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /**
+ * This method returns an array of bytes, that can be used to unambiguously
+ * distinguish between two sets of types, e.g. to realise hashing functionality
+ * when the object is introspected. Two objects that return the same ID also
+ * have to return the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to return an empty
+ * sequence. Important: If the object aggregates other objects the ID has to be
+ * unique for the whole combination of objects.
+ *
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId() {
+ byte[] byteReturn = {
+ };
+
+ try {
+ byteReturn = ("" + this.hashCode()).getBytes();
+ } catch (Exception exception) {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /**
+ * Return the class name of the component.
+ *
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName() {
+ return (WizardImplementation.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.
+ */
+ public com.sun.star.uno.Type[] getTypes() {
+ Type[] typeReturn = {
+ };
+
+ try {
+ typeReturn = new Type[] { new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class)};
+ } catch (Exception exception) {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/agenda/MANIFEST.MF b/wizards/com/sun/star/wizards/agenda/MANIFEST.MF
new file mode 100644
index 000000000000..b9a31ef4732c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.agenda.CallWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/agenda/TemplateConsts.java b/wizards/com/sun/star/wizards/agenda/TemplateConsts.java
new file mode 100644
index 000000000000..44ce6a1e0f0e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/TemplateConsts.java
@@ -0,0 +1,146 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+/**
+ * @author rpiterman
+ *
+ */
+public interface TemplateConsts
+{
+
+ public final static String FILLIN_TITLE = "<title>";
+ public final static String FILLIN_DATE = "<date>";
+ public final static String FILLIN_TIME = "<time>";
+ public final static String FILLIN_LOCATION = "<location>";
+ /**
+ * section name <b>prefix</b> for sections that contain items.
+ * this is also used as table name prefix, since each items section
+ * must contain a table whos name is identical name to the section's name.
+ */
+ public final static String SECTION_ITEMS = "AGENDA_ITEMS";
+ /**
+ * the name of the section which contains the topics.
+ */
+ public final static String SECTION_TOPICS = "AGENDA_TOPICS";
+ /**
+ * the name of the parent minutes section.
+ */
+ public final static String SECTION_MINUTES_ALL = "MINUTES_ALL";
+ /**
+ * the name of the child nimutes section.
+ * This section will be duplicated for each topic.
+ */
+ public final static String SECTION_MINUTES = "MINUTES"; //public final static String AGENDA_ITEM = "AGENDA_ITEM";
+ /**
+ * taged headings and names.
+ * These will be searched in item tables (in the template) and will be
+ * replaced with resource strings.
+ *
+ * headings...
+ */
+ public final static String FILLIN_MEETING_TYPE = "<meeting-type>";
+ public final static String FILLIN_BRING = "<bring>";
+ public final static String FILLIN_READ = "<read>";
+ public final static String FILLIN_NOTES = "<notes>";
+ /**
+ * names...
+ */
+ public final static String FILLIN_CALLED_BY = "<called-by>";
+ public final static String FILLIN_FACILITATOR = "<facilitator>";
+ public final static String FILLIN_PARTICIPANTS = "<attendees>";
+ public final static String FILLIN_NOTETAKER = "<notetaker>";
+ public final static String FILLIN_TIMEKEEPER = "<timekeeper>";
+ public final static String FILLIN_OBSERVERS = "<observers>";
+ public final static String FILLIN_RESOURCE_PERSONS = "<resource-persons>";
+ /**
+ * Styles (paragraph styles) used for agenda items.
+ * headings styles
+ *
+ */
+ public final static String STYLE_MEETING_TYPE = "MeetingType";
+ public final static String STYLE_BRING = "Bring";
+ public final static String STYLE_READ = "Read";
+ public final static String STYLE_NOTES = "Notes";
+ /**
+ * names styles
+ */
+ public final static String STYLE_CALLED_BY = "CalledBy";
+ public final static String STYLE_FACILITATOR = "Facilitator";
+ public final static String STYLE_PARTICIPANTS = "Attendees";
+ public final static String STYLE_NOTETAKER = "Notetaker";
+ public final static String STYLE_TIMEKEEPER = "Timekeeper";
+ public final static String STYLE_OBSERVERS = "Observers";
+ public final static String STYLE_RESOURCE_PERSONS = "ResourcePersons";
+ /**
+ * Styles (paragraph styles) used for the <b>text</b> of agenda items
+ * The agenda wizard creates fill-in fields with the given styles...)
+ *
+ * headings fields styles
+ */
+ public final static String STYLE_MEETING_TYPE_TEXT = "MeetingTypeText";
+ public final static String STYLE_BRING_TEXT = "BringText";
+ public final static String STYLE_READ_TEXT = "ReadText";
+ public final static String STYLE_NOTES_TEXT = "NotesText";
+ /**
+ * names field styles
+ */
+ public final static String STYLE_CALLED_BY_TEXT = "CalledByText";
+ public final static String STYLE_FACILITATOR_TEXT = "FacilitatorText";
+ public final static String STYLE_PARTICIPANTS_TEXT = "AttendeesText";
+ public final static String STYLE_NOTETAKER_TEXT = "NotetakerText";
+ public final static String STYLE_TIMEKEEPER_TEXT = "TimekeeperText";
+ public final static String STYLE_OBSERVERS_TEXT = "ObserversText";
+ public final static String STYLE_RESOURCE_PERSONS_TEXT = "ResourcePersonsText";
+ /**
+ * Fillins for the topic table.
+ * These strings will be searched inside the topic table as
+ * part of detecting its structure.
+ */
+ public final static String FILLIN_TOPIC_NUMBER = "<num>";
+ public final static String FILLIN_TOPIC_TOPIC = "<topic>";
+ public final static String FILLIN_TOPIC_RESPONSIBLE = "<responsible>";
+ public final static String FILLIN_TOPIC_TIME = "<topic-time>";
+ /**
+ * fillins for minutes.
+ * These will be searched in the minutes section and will be replaced
+ * with the appropriate data.
+ */
+ public final static String FILLIN_MINUTES_TITLE = "<minutes-title>";
+ public final static String FILLIN_MINUTES_LOCATION = "<minutes-location>";
+ public final static String FILLIN_MINUTES_DATE = "<minutes-date>";
+ public final static String FILLIN_MINUTES_TIME = "<minutes-time>";
+ /**
+ * Minutes-topic fillins
+ * These will be searched in the minutes-child-section, and
+ * will be replaced with topic data.
+ */
+ public final static String FILLIN_MINUTE_NUM = "<mnum>";
+ public final static String FILLIN_MINUTE_TOPIC = "<mtopic>";
+ public final static String FILLIN_MINUTE_RESPONSIBLE = "<mresponsible>";
+ public final static String FILLIN_MINUTE_TIME = "<mtime>";
+}
diff --git a/wizards/com/sun/star/wizards/agenda/TopicsControl.java b/wizards/com/sun/star/wizards/agenda/TopicsControl.java
new file mode 100644
index 000000000000..3cd1e550e874
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/TopicsControl.java
@@ -0,0 +1,1321 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.agenda;
+
+import java.util.List;
+import com.sun.star.wizards.common.HelpIds;
+
+import com.sun.star.awt.FocusEvent;
+import com.sun.star.awt.Key;
+import com.sun.star.awt.KeyEvent;
+import com.sun.star.awt.KeyModifier;
+import com.sun.star.awt.Selection;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XFocusListener;
+import com.sun.star.awt.XKeyListener;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.ui.ControlScroller;
+import com.sun.star.wizards.ui.UnoDialog2;
+import com.sun.star.wizards.ui.event.EventNames;
+import com.sun.star.wizards.ui.event.MethodInvocation;
+
+/**
+ * @author rpiterman
+ * This class implements the UI functionality of the topics scroller control.
+ * <br/>
+ * During developement, there has been a few changes which were not *fully* done -
+ * mainly in converting the topics and time boxes from combobox and time box to normal textboxes,
+ * so in the code they might be referenced as combobox or timebox. This should be
+ * rather understood as topicstextbox and timetextbox.
+ * <br/>
+ * <br/>
+ * Important behaiviour of this control is that there is always a
+ * blank row at the end, in which the user can enter data.<br/>
+ * Once the row is not blank (thus, the user entered data...),
+ * a new blank row is added.<br/>
+ * Once the user removes the last *unempty* row, by deleteing its data, it becomes
+ * the *last empty row* and the one after is being automatically removed.<br/>
+ * <br/>
+ * The contorl shows 5 rows at a time.<br/>
+ * If, for example, only 2 rows exist (from which the 2ed one is empty...)
+ * then the other three rows, which do not exist in the data model, are disabled.
+ * <br/>
+ * The following other functionality is implemented:
+ * <br/>
+ * 0. synchroniting data between controls, data model and live preview.
+ * 1. Tab scrolling.<br/>
+ * 2. Keyboard scrolling.<br/>
+ * 3. Removing rows and adding new rows.<br/>
+ * 4. Moving rows up and down. <br/>
+ * <br/>
+ * This control relays on the ControlScroller control which uses the following
+ * Data model:<br/>
+ * 1. It uses a vector, whos members are arrays of PropertyValue.<br/>
+ * 2. Each array represents a row.<br/>
+ * (Note: the Name and Value memebrs of the PropertyValue object are being used...)
+ * 3. Each property Value represents a value for a single control with the following rules:<br/>
+ * 3. a. the Value of the property is used for as value of the controls (usually text).<br/>
+ * 3. b. the Name of the property is used to map values to UI controls in the following manner:<br/>
+ * 3. b. 1. only the Name of the first X Rows is regarded, where X is the number of visible rows
+ * (in the agenda wizard this would be 5, since 5 topic rows are visible on the dialog).<br/>
+ * 3. b. 2. The Names of the first X (or 5...) rows are the names of the UI Controls to
+ * hold values. When the control scroller scrolls, it looks at the first 5 rows and uses
+ * the names specified there to map the current values to the specified controls.
+ * <br/>
+ * This data model makes the following limitations on the implementation:
+ * When moving rows, only the values should be moved. The Rows objects, which contain
+ * also the Names of the controls should not be switched. <br/>
+ * also when deleting or inserting rows, attention should be paid that no rows should be removed
+ * or inserted. Instead, only the Values should rotate.
+ * <br/>
+ * <br/>
+ * To save the topics in the registry a ConfigSet of objects of type CGTopic is
+ * being used.
+ * This one is not synchronized "live", since it is unnecessary... instead, it is
+ * synchronized on call, before the settings should be saved.
+ */
+public class TopicsControl extends ControlScroller implements XFocusListener
+{
+
+ /**
+ * The name prefix of the number (label) controls
+ */
+ public static final String LABEL = "lblTopicCnt_";
+ /**
+ * The name prefix of the topic (text) controls
+ */
+ public static final String TOPIC = "txtTopicTopic_";
+ /**
+ * The name prefix of the responsible (text) controls
+ */
+ public static final String RESP = "cbTopicResp_";
+ /**
+ * The name prefix of the time (text) controls
+ */
+ public static final String TIME = "txtTopicTime_";
+ Object lastFocusControl;
+ int lastFocusRow;
+ /**
+ * the last
+ * topic text box.
+ * When pressing tab on this one a scroll down *may* be performed.
+ */
+ private Object firstTopic;
+ /**
+ * the first time box.
+ * When pressing shift-tab on this control, a scroll up *may* be performed.
+ */
+ private Object lastTime;
+ /**
+ * is used when constructing to track the tab index
+ * of the created control rows.
+ */
+ private int tabIndex = 520;
+
+ /**
+ * create a new TopicControl. Since this is used specifically for the
+ * agenda dialog, I use step 5, and constant location - and need no paramter...
+ * @param dialog the parent dialog
+ * @param xmsf service factory
+ * @param agenda the Agenda configuration data (contains the current topics data).
+ */
+ public TopicsControl(AgendaWizardDialog dialog, XMultiServiceFactory xmsf, CGAgenda agenda)
+ {
+ super(dialog, xmsf, 5, 92, 38, 212, 5, 18, AgendaWizardDialogConst.LAST_HID);
+ initializeScrollFields(agenda);
+ initialize(agenda.cp_Topics.getSize() + 1);
+
+ // set some focus listeners for TAB scroll down and up...
+ try
+ {
+
+ // prepare scroll down on tab press...
+ Object lastTime = ((ControlRow) ControlGroupVector.get(nblockincrement - 1)).timebox;
+
+ MethodInvocation mi = new MethodInvocation("lastControlKeyPressed", this, KeyEvent.class);
+ dialog.getGuiEventListener().add(TIME + (nblockincrement - 1), EventNames.EVENT_KEY_PRESSED, mi);
+
+ addKeyListener(lastTime, (XKeyListener) dialog.getGuiEventListener());
+
+ //prepare scroll up on tab press...
+ firstTopic = ((ControlRow) ControlGroupVector.get(0)).textbox;
+
+ mi = new MethodInvocation("firstControlKeyPressed", this, KeyEvent.class);
+ dialog.getGuiEventListener().add(TOPIC + 0, EventNames.EVENT_KEY_PRESSED, mi);
+
+ addKeyListener(firstTopic, (XKeyListener) dialog.getGuiEventListener());
+
+ }
+ catch (NoSuchMethodException ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ /**
+ * Is used to add a keylistener to different controls...
+ */
+ static void addKeyListener(Object control, XKeyListener listener)
+ {
+ XWindow xlastControl = (XWindow) UnoRuntime.queryInterface(XWindow.class,
+ control);
+ xlastControl.addKeyListener(listener);
+ }
+
+ /**
+ * Is used to add a focuslistener to different controls...
+ */
+ static void addFocusListener(Object control, XFocusListener listener)
+ {
+ XWindow xlastControl = (XWindow) UnoRuntime.queryInterface(XWindow.class,
+ control);
+ xlastControl.addFocusListener(listener);
+ }
+
+ /**
+ * Implementation of the parent class...
+ */
+ protected void initializeScrollFields()
+ {
+ }
+
+ /**
+ * initializes the data of the control.
+ * @param agenda
+ */
+ protected void initializeScrollFields(CGAgenda agenda)
+ {
+ // create a row for each topic with the given values....
+ for (int i = 0; i < agenda.cp_Topics.getSize(); i++)
+ {
+ PropertyValue[] row = newRow(i);
+ ((CGTopic) agenda.cp_Topics.getElementAt(i)).setDataToRow(row);
+ // a parent class method
+ registerControlGroup(row, i);
+ this.updateDocumentRow(i);
+ }
+ // inserts a blank row at the end...
+ insertRowAtEnd();
+ }
+
+ /**
+ * Insert a blank (empty) row
+ * as last row of the control.
+ * The control has always a blank row at the
+ * end, which enables the user to enter data...
+ */
+ protected void insertRowAtEnd()
+ {
+ int l = scrollfields.size();
+ registerControlGroup(newRow(l), l);
+ setTotalFieldCount(l + 1);
+
+ // if the new row is visible, it must have been disabled
+ // so it should be now enabled...
+ if (l - nscrollvalue < nblockincrement)
+ {
+ ((ControlRow) ControlGroupVector.get(l - nscrollvalue)).setEnabled(true);
+ }
+ }
+
+ /**
+ * The Topics Set in the CGAgenda object is synchronized to
+ * the current content of the topics.
+ * @param agenda
+ */
+ void saveTopics(CGAgenda agenda)
+ {
+ agenda.cp_Topics.clear();
+ for (int i = 0; i < scrollfields.size() - 1; i++)
+ {
+ agenda.cp_Topics.add(i,
+ new CGTopic(scrollfields.get(i)));
+ }
+ }
+
+ /**
+ * overrides the parent class method to also enable the
+ * row whenever data is written to it.
+ * @param guiRow
+ */
+ protected void fillupControls(int guiRow)
+ {
+ super.fillupControls(guiRow);
+ ((ControlRow) ControlGroupVector.get(guiRow)).setEnabled(true);
+ }
+
+ /**
+ * remove the last row
+ */
+ protected void removeLastRow()
+ {
+ int l = scrollfields.size();
+
+ // if we should scroll up...
+ if ((l - nscrollvalue >= 1) && (l - nscrollvalue <= nblockincrement) && nscrollvalue > 0)
+ {
+ while ((l - nscrollvalue >= 1) && (l - nscrollvalue <= nblockincrement) && nscrollvalue > 0)
+ {
+ setScrollValue(nscrollvalue - 1);
+ }
+ }
+ // if we should disable a row...
+ else if (nscrollvalue == 0 && l - 1 < nblockincrement)
+ {
+ ControlRow cr = (ControlRow) ControlGroupVector.get(l - 1);
+ cr.setEnabled(false);
+ }
+
+ unregisterControlGroup(l - 1);
+ setTotalFieldCount(l - 1);
+ }
+
+ /**
+ * in order to use the "move up", "down" "insert" and "remove" buttons,
+ * we track the last control the gained focus, in order to know which
+ * row should be handled.
+ * @param fe
+ */
+ public void focusGained(FocusEvent fe)
+ {
+ XControl xc = (XControl) UnoRuntime.queryInterface(XControl.class, fe.Source);
+ focusGained(xc);
+ }
+
+ /**
+ * Sometimes I set the focus programatically to a control
+ * (for example when moving a row up or down, the focus should move
+ * with it).
+ * In such cases, no VCL event is being triggered so it must
+ * be called programtically.
+ * This is done by this method.
+ * @param control
+ */
+ private void focusGained(XControl control)
+ {
+ try
+ {
+ //calculate in which row we are...
+ String name = (String) Helper.getUnoPropertyValue(UnoDialog2.getModel(control), "Name");
+ int i = name.indexOf("_");
+ String num = name.substring(i + 1);
+ lastFocusRow = Integer.valueOf(num).intValue() + nscrollvalue;
+ lastFocusControl = control;
+ // enable/disable the buttons...
+ enableButtons();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * enable or disable the buttons according to the
+ * current row we are in.
+ */
+ private void enableButtons()
+ {
+ UnoDialog2.setEnabled(getAD().btnInsert, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE));
+ UnoDialog2.setEnabled(getAD().btnRemove, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE));
+ UnoDialog2.setEnabled(getAD().btnUp, (lastFocusRow > 0 ? Boolean.TRUE : Boolean.FALSE));
+ UnoDialog2.setEnabled(getAD().btnDown, (lastFocusRow < scrollfields.size() - 1 ? Boolean.TRUE : Boolean.FALSE));
+ }
+
+ /**
+ * compolsary implementation of FocusListener.
+ * @param fe
+ */
+ public void focusLost(FocusEvent fe)
+ {
+ }
+
+ /**
+ * compolsary implementation of FocusListener.
+ * @param o
+ */
+ public void disposing(EventObject o)
+ {
+ }
+
+ /**
+ * Convenience method. Is used to get a reference of
+ * the template controller (live preview in background).
+ * @return the parent dialog, casted to AgendaWizardDialog.
+ */
+ private AgendaWizardDialog getAD()
+ {
+ return (AgendaWizardDialog) this.CurUnoDialog;
+ }
+
+ /**
+ * move the current row up
+ */
+ public void rowUp()
+ {
+ rowUp(lastFocusRow - nscrollvalue, lastFocusControl);
+ }
+
+ /**
+ * move the current row down.
+ */
+ public void rowDown()
+ {
+ rowDown(lastFocusRow - nscrollvalue, lastFocusControl);
+ }
+
+ private void lockDoc()
+ {
+ //((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.xTextDocument.lockControllers();
+ }
+
+ private void unlockDoc()
+ {
+ //((AgendaWizardDialogImpl)CurUnoDialog).agendaTemplate.xTextDocument.unlockControllers();
+ }
+
+ /**
+ * Removes the current row.
+ * See general class documentation explanation about the
+ * data model used and the limitations which explain the implementation here.
+ */
+ public void removeRow()
+ {
+ lockDoc();
+ for (int i = lastFocusRow; i < scrollfields.size() - 1; i++)
+ {
+ PropertyValue[] pv1 = (PropertyValue[]) scrollfields.get(i);
+ PropertyValue[] pv2 = (PropertyValue[]) scrollfields.get(i + 1);
+ pv1[1].Value = pv2[1].Value;
+ pv1[2].Value = pv2[2].Value;
+ pv1[3].Value = pv2[3].Value;
+ updateDocumentRow(i);
+ if (i - nscrollvalue < nblockincrement)
+ {
+ fillupControls(i - nscrollvalue);
+ }
+ }
+ removeLastRow();
+ // update the live preview background document
+ reduceDocumentToTopics();
+
+ // the focus should return to the edit control
+ focus(lastFocusControl);
+ unlockDoc();
+ }
+
+ /**
+ * Inserts a row before the current row.
+ * See general class documentation explanation about the
+ * data model used and the limitations which explain the implementation here.
+ */
+ public void insertRow()
+ {
+ lockDoc();
+ insertRowAtEnd();
+ for (int i = scrollfields.size() - 2; i > lastFocusRow; i--)
+ {
+ PropertyValue[] pv1 = (PropertyValue[]) scrollfields.get(i);
+ PropertyValue[] pv2 = (PropertyValue[]) scrollfields.get(i - 1);
+ pv1[1].Value = pv2[1].Value;
+ pv1[2].Value = pv2[2].Value;
+ pv1[3].Value = pv2[3].Value;
+ updateDocumentRow(i);
+ if (i - nscrollvalue < nblockincrement)
+ {
+ fillupControls(i - nscrollvalue);
+ }
+ }
+
+ // after rotating all the properties from this row on,
+ // we clear the row, so it is practically a new one...
+ PropertyValue[] pv1 = (PropertyValue[]) scrollfields.get(lastFocusRow);
+ pv1[1].Value = "";
+ pv1[2].Value = "";
+ pv1[3].Value = "";
+
+ // update the preview document.
+ updateDocumentRow(lastFocusRow);
+
+ fillupControls(lastFocusRow - nscrollvalue);
+
+ focus(lastFocusControl);
+ unlockDoc();
+ }
+
+ /**
+ * create a new row with the given index.
+ * The index is important because it is used in the
+ * Name member of the PropertyValue objects.
+ * To know why see general class documentation above (data model explanation).
+ * @param i the index of the new row
+ * @return
+ */
+ private PropertyValue[] newRow(int i)
+ {
+ PropertyValue[] pv = new PropertyValue[4];
+ pv[0] = Properties.createProperty(LABEL + i, "" + (i + 1) + ".");
+ pv[1] = Properties.createProperty(TOPIC + i, "");
+ pv[2] = Properties.createProperty(RESP + i, "");
+ pv[3] = Properties.createProperty(TIME + i, "");
+ return pv;
+ }
+
+ /**
+ * Implementation of ControlScroller
+ * This is a UI method which inserts a new row to the control.
+ * It uses the child-class ControlRow. (see below).
+ * @param _index
+ * @param npos
+ * @see ControlRow
+ */
+ protected void insertControlGroup(int _index, int npos)
+ {
+ ControlRow oControlRow = new ControlRow((AgendaWizardDialog) CurUnoDialog, iCompPosX, npos, _index, tabIndex);
+ ControlGroupVector.addElement(oControlRow);
+ tabIndex += 4;
+ }
+
+ /**
+ * Implementation of ControlScroller
+ * This is a UI method which makes a row visibele.
+ * As far as I know it is never called.
+ * @param _index
+ * @param _bIsVisible
+ * @see ControlRow
+ */
+ protected void setControlGroupVisible(int _index, boolean _bIsVisible)
+ {
+ ((ControlRow) ControlGroupVector.get(_index)).setVisible(_bIsVisible);
+
+ }
+
+ /**
+ * Checks if a row is empty.
+ * This is used when the last row is changed.
+ * If it is empty, the next row (which is always blank) is removed.
+ * If it is not empty, a next row must exist.
+ * @param row the index number of the row to check.
+ * @return true if empty. false if not.
+ */
+ protected boolean isRowEmpty(int row)
+ {
+ PropertyValue[] data = getTopicData(row);
+
+ // now - is this row empty?
+ return data[1].Value.equals("") &&
+ data[2].Value.equals("") &&
+ data[3].Value.equals("");
+
+ }
+ /**
+ * is used for data tracking.
+ */
+ private Object[] oldData;
+
+ /**
+ * update the preview document and
+ * remove/insert rows if needed.
+ * @param guiRow
+ * @param column
+ */
+ synchronized void fieldChanged(int guiRow, int column)
+ {
+ synchronized(this)
+ {
+
+ try
+ {
+ // First, I update the document
+ PropertyValue[] data = getTopicData(guiRow + nscrollvalue);
+
+ if (data == null)
+ {
+ return;
+ }
+ boolean equal = true;
+
+ if (oldData != null)
+ {
+ for (int i = 0; i < data.length && equal; i++)
+ {
+ equal = (equal & data[i].Value.equals(oldData[i]));
+ }
+ if (equal)
+ {
+ return;
+ }
+ }
+ else
+ {
+ oldData = new Object[4];
+ }
+ for (int i = 0; i < data.length; i++)
+ {
+ oldData[i] = data[i].Value;
+ }
+ updateDocumentCell(guiRow + nscrollvalue, column, data);
+
+ if (isRowEmpty(guiRow + nscrollvalue))
+ {
+ /* if this is the row before the last one
+ * (the last row is always empty)
+ * delete the last row...
+ */
+ if (guiRow + nscrollvalue == scrollfields.size() - 2)
+ {
+ removeLastRow();
+
+ /*
+ * now consequentially check the last two rows,
+ * and remove the last one if they are both empty.
+ * (actually I check always the "before last" row,
+ * because the last one is always empty...
+ */
+ while (scrollfields.size() > 1 && isRowEmpty(scrollfields.size() - 2))
+ {
+ removeLastRow();
+ }
+ ControlRow cr = (ControlRow) ControlGroupVector.get(scrollfields.size() - nscrollvalue - 1);
+
+ // if a remove was performed, set focus to the last row with some data in it...
+ focus(getControl(cr, column));
+
+ // update the preview document.
+ reduceDocumentToTopics();
+ }
+
+ }
+ else
+ { // row contains data
+ // is this the last row?
+ if ((guiRow + nscrollvalue + 1) == scrollfields.size())
+ {
+ insertRowAtEnd();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ /**
+ * return the corresponding row data for the given index.
+ * @param topic index of the topic to get.
+ * @return a PropertyValue array with the data for the given topic.
+ */
+ public PropertyValue[] getTopicData(int topic)
+ {
+ if (topic < scrollfields.size())
+ {
+ return (PropertyValue[]) scrollfields.get(topic);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * If the user presses tab on the last control, and
+ * there *are* more rows in the model, scroll down.
+ * @param event
+ */
+ public void lastControlKeyPressed(KeyEvent event)
+ {
+ // if tab without shift was pressed...
+ if ((event.KeyCode == Key.TAB) && (event.Modifiers == 0))
+ // if there is another row...
+ {
+ if ((nblockincrement + nscrollvalue) < scrollfields.size())
+ {
+ setScrollValue(nscrollvalue + 1);
+ //focus(firstTopic);
+ focus(getControl((ControlRow) ControlGroupVector.get(4), 1));
+
+ }
+ }
+ }
+
+ /**
+ * If the user presses shift-tab on the first control, and
+ * there *are* more rows in the model, scroll up.
+ * @param event
+ */
+ public void firstControlKeyPressed(KeyEvent event)
+ {
+ // if tab with shift was pressed...
+ if ((event.KeyCode == Key.TAB) && (event.Modifiers == KeyModifier.SHIFT))
+ {
+ if (nscrollvalue > 0)
+ {
+ setScrollValue(nscrollvalue - 1);
+ focus(lastTime);
+ }
+ }
+ }
+
+ /**
+ * sets focus to the given control.
+ * @param textControl
+ */
+ private void focus(Object textControl)
+ {
+ ((XWindow) UnoRuntime.queryInterface(XWindow.class, textControl)).setFocus();
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, textControl);
+ String text = xTextComponent.getText();
+ xTextComponent.setSelection(new Selection(0, text.length()));
+ XControl xc = (XControl) UnoRuntime.queryInterface(XControl.class, textControl);
+ focusGained(xc);
+ }
+
+ /**
+ * moves the given row one row down.
+ * @param guiRow the gui index of the row to move.
+ * @param control the control to gain focus after moving.
+ */
+ synchronized void rowDown(int guiRow, Object control)
+ {
+ // only perform if this is not the last row.
+ int actuallRow = guiRow + nscrollvalue;
+ if (actuallRow + 1 < scrollfields.size())
+ {
+ // get the current selection
+ Selection selection = getSelection(control);
+
+ // the last row should scroll...
+ boolean scroll = guiRow == (nblockincrement - 1);
+ if (scroll)
+ {
+ setScrollValue(nscrollvalue + 1);
+ }
+ int scroll1 = nscrollvalue;
+
+ switchRows(guiRow, guiRow + (scroll ? -1 : 1));
+
+ if (nscrollvalue != scroll1)
+ {
+ guiRow += (nscrollvalue - scroll1);
+ }
+ setSelection(guiRow + (scroll ? 0 : 1), control, selection);
+ }
+ }
+
+ synchronized void rowUp(int guiRow, Object control)
+ {
+ // only perform if this is not the first row
+ int actuallRow = guiRow + nscrollvalue;
+ if (actuallRow > 0)
+ {
+ // get the current selection
+ Selection selection = getSelection(control);
+
+ // the last row should scroll...
+ boolean scroll = (guiRow == 0);
+ if (scroll)
+ {
+ setScrollValue(nscrollvalue - 1);
+ }
+ switchRows(guiRow, guiRow + (scroll ? 1 : -1));
+
+ setSelection(guiRow - (scroll ? 0 : 1), control, selection);
+ }
+ }
+
+ /**
+ * moves the cursor up.
+ * @param guiRow
+ * @param control
+ */
+ synchronized void cursorUp(int guiRow, Object control)
+ {
+ // is this the last full row ?
+ int actuallRow = guiRow + nscrollvalue;
+ //if this is the first row
+ if (actuallRow == 0)
+ {
+ return;
+ // the first row should scroll...
+ }
+ boolean scroll = (guiRow == 0);
+ ControlRow upperRow;
+ if (scroll)
+ {
+ setScrollValue(nscrollvalue - 1);
+ upperRow = (ControlRow) ControlGroupVector.get(guiRow);
+ }
+ else
+ {
+ upperRow = (ControlRow) ControlGroupVector.get(guiRow - 1);
+ }
+ focus(getControl(upperRow, control));
+
+ }
+
+ /**
+ * moves the cursor down
+ * @param guiRow
+ * @param control
+ */
+ synchronized void cursorDown(int guiRow, Object control)
+ {
+ // is this the last full row ?
+ int actuallRow = guiRow + nscrollvalue;
+ //if this is the last row, exit
+ if (actuallRow == scrollfields.size() - 1)
+ {
+ return;
+ // the first row should scroll...
+ }
+ boolean scroll = (guiRow == nblockincrement - 1);
+ ControlRow lowerRow;
+ if (scroll)
+ {
+ setScrollValue(nscrollvalue + 1);
+ lowerRow = (ControlRow) ControlGroupVector.get(guiRow);
+ }
+ // if we scrolled we are done...
+ //otherwise...
+ else
+ {
+ lowerRow = (ControlRow) ControlGroupVector.get(guiRow + 1);
+ }
+ focus(getControl(lowerRow, control));
+ }
+
+ /**
+ * changes the values of the given rows with eachother
+ * @param row1 one can figure out what this parameter is...
+ * @param row2 one can figure out what this parameter is...
+ */
+ private void switchRows(int row1, int row2)
+ {
+ PropertyValue[] o1 = (PropertyValue[]) scrollfields.get(row1 + nscrollvalue);
+ PropertyValue[] o2 = (PropertyValue[]) scrollfields.get(row2 + nscrollvalue);
+
+ Object temp = null;
+ for (int i = 1; i < o1.length; i++)
+ {
+ temp = o1[i].Value;
+ o1[i].Value = o2[i].Value;
+ o2[i].Value = temp;
+ }
+
+ fillupControls(row1);
+ fillupControls(row2);
+
+ updateDocumentRow(row1 + nscrollvalue, o1);
+ updateDocumentRow(row2 + nscrollvalue, o2);
+
+ /*
+ * if we changed the last row, add another one...
+ */
+ if ((row1 + nscrollvalue + 1 == scrollfields.size()) ||
+ (row2 + nscrollvalue + 1 == scrollfields.size()))
+ {
+ insertRowAtEnd();
+ /*
+ * if we did not change the last row but
+ * we did change the one before - check if we
+ * have two empty rows at the end.
+ * If so, delete the last one...
+ */
+ }
+ else if ((row1 + nscrollvalue) + (row2 + nscrollvalue) == (scrollfields.size() * 2 - 5))
+ {
+ if (isRowEmpty(scrollfields.size() - 2) && isRowEmpty(scrollfields.size() - 1))
+ {
+ removeLastRow();
+ reduceDocumentToTopics();
+ }
+ }
+ }
+
+ /**
+ * returns the current Selection of a text field
+ * @param control a text field from which the Selection object
+ * should be gotten.
+ * @return the selection object.
+ */
+ private Selection getSelection(Object control)
+ {
+ return ((XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, control)).getSelection();
+ }
+
+ /**
+ * sets a text selection to a given control.
+ * This is used when one moves a row up or down.
+ * After moving row X to X+/-1, the selection (or cursor position) of the
+ * last focused control should be restored.
+ * The control's row is the given guiRow.
+ * The control's column is detecte4d according to the given event.
+ * This method is called as subsequent to different events,
+ * thus it is comfortable to use the event here to detect the column,
+ * rather than in the different event methods.
+ * @param guiRow the row of the control to set the selection to.
+ * @param eventSource helps to detect the control's column to set the selection to.
+ * @param s the selection object to set.
+ */
+ private void setSelection(int guiRow, Object eventSource, Selection s)
+ {
+ ControlRow cr = (ControlRow) ControlGroupVector.get(guiRow);
+ Object control = getControl(cr, eventSource);
+ ((XWindow) UnoRuntime.queryInterface(XWindow.class, control)).setFocus();
+ ((XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, control)).setSelection(s);
+ }
+
+ /**
+ * returns a control out of the given row, according to a column number.
+ * @param cr control row object.
+ * @param column the column number.
+ * @return the control...
+ */
+ private Object getControl(ControlRow cr, int column)
+ {
+ switch (column)
+ {
+ case 0:
+ return cr.label;
+ case 1:
+ return cr.textbox;
+ case 2:
+ return cr.combobox;
+ case 3:
+ return cr.timebox;
+ default:
+ throw new IllegalArgumentException("No such column");
+ }
+ }
+
+ /**
+ * returns a control out of the given row, which is
+ * in the same column as the given control.
+ * @param cr control row object
+ * @param control a control indicating a column.
+ * @return
+ */
+ private Object getControl(ControlRow cr, Object control)
+ {
+ int column = getColumn(control);
+ return getControl(cr, column);
+ }
+
+ /**
+ * returns the column number of the given control.
+ * @param control
+ * @return
+ */
+ private int getColumn(Object control)
+ {
+ String name = (String) Helper.getUnoPropertyValue(UnoDialog2.getModel(control), "Name");
+ if (name.startsWith(TOPIC))
+ {
+ return 1;
+ }
+ if (name.startsWith(RESP))
+ {
+ return 2;
+ }
+ if (name.startsWith(TIME))
+ {
+ return 3;
+ }
+ if (name.startsWith(LABEL))
+ {
+ return 0;
+ }
+ return -1;
+ }
+
+ /**
+ * updates the given row in the preview document.
+ * @param row
+ */
+ private void updateDocumentRow(int row)
+ {
+ updateDocumentRow(row, (PropertyValue[]) scrollfields.get(row));
+ }
+
+ /**
+ * update the given row in the preview document with the given data.
+ * @param row
+ * @param data
+ */
+ private void updateDocumentRow(int row, PropertyValue[] data)
+ {
+ try
+ {
+ ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.write(row, data);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * updates a single cell in the preview document.
+ * Is called when a single value is changed, since we really
+ * don't have to update the whole row for one small changhe...
+ * @param row the data row to update (topic number).
+ * @param column the column to update (a gui column, not a document column).
+ * @param data the data of the entire row.
+ */
+ private void updateDocumentCell(int row, int column, PropertyValue[] data)
+ {
+ try
+ {
+ ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.writeCell(row, column, data);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * when removeing rows, this method updates
+ * the preview document to show the number of rows
+ * according to the data model.
+ */
+ private void reduceDocumentToTopics()
+ {
+ try
+ {
+ ((AgendaWizardDialogImpl) CurUnoDialog).agendaTemplate.topics.reduceDocumentTo(scrollfields.size() - 1);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * needed to make this data poblic.
+ * @return the List containing the topics data.
+ */
+ public List getTopicsData()
+ {
+ return scrollfields;
+ }
+ /**
+ * A static member used for the child-class ControlRow (GUI Constant)
+ */
+ private static Integer I_12 = new Integer(12);
+ /**
+ * A static member used for the child-class ControlRow (GUI Constant)
+ */
+ private static Integer I_8 = new Integer(8);
+ /**
+ * A static member used for the child-class ControlRow (GUI Constant)
+ */
+ private static final String[] LABEL_PROPS = new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+ /**
+ * A static member used for the child-class ControlRow (GUI Constant)
+ */
+ private static final String[] TEXT_PROPS = new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+
+ /**
+ *
+ * @author rp143992
+ * A class represting a single GUI row.
+ * Note that the instance methods of this class
+ * are being called and handle controls of
+ * a single row.
+ */
+ public class ControlRow implements XKeyListener
+ {
+
+ /**
+ * the number (label) control
+ */
+ Object label;
+ /**
+ * the topic (text) control
+ */
+ Object textbox;
+ /**
+ * the responsible (text, yes, text) control
+ */
+ Object combobox;
+ /**
+ * the time (text, yes, text) control
+ */
+ Object timebox;
+ /**
+ * the row offset of this instance (0 = first gui row)
+ */
+ int offset;
+
+ /**
+ * called through an event listener when the
+ * topic text is changed by the user.
+ * updates the data model and the preview document.
+ */
+ public void topicTextChanged()
+ {
+ try
+ {
+ // update the data model
+ fieldInfo(offset, 1);
+ // update the preview document
+ fieldChanged(offset, 1);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * called through an event listener when the
+ * responsible text is changed by the user.
+ * updates the data model and the preview document.
+ */
+ public void responsibleTextChanged()
+ {
+ try
+ {
+ // update the data model
+ fieldInfo(offset, 2);
+ // update the preview document
+ fieldChanged(offset, 2);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * called through an event listener when the
+ * time text is changed by the user.
+ * updates the data model and the preview document.
+ */
+ public void timeTextChanged()
+ {
+ try
+ {
+ // update the data model
+ fieldInfo(offset, 3);
+ // update the preview document
+ fieldChanged(offset, 3);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * constructor. Create the row in the given dialog given cordinates,
+ * with the given offset (row number) and tabindex.
+ * Note that since I use this specifically for the agenda wizard,
+ * the step and all control coordinates inside the
+ * row are constant (5).
+ * @param dialog the agenda dialog
+ * @param x x coordinates
+ * @param y y coordinates
+ * @param i the gui row index
+ * @param tabindex first tab index for this row.
+ */
+ public ControlRow(AgendaWizardDialog dialog, int x, int y, int i, int tabindex)
+ {
+
+ offset = i;
+
+ Integer y_ = new Integer(y);
+
+ label = dialog.insertLabel(LABEL + i,
+ LABEL_PROPS,
+ new Object[]
+ {
+ I_8, "" + (i + 1) + ".", new Integer(x + 4), new Integer(y + 2), IStep, new Short((short) tabindex), new Integer(10)
+ });
+
+ textbox = dialog.insertTextField(TOPIC + i, "topicTextChanged", this,
+ TEXT_PROPS,
+ new Object[]
+ {
+ I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 1), new Integer(x + 15), y_, IStep, new Short((short) (tabindex + 1)), new Integer(84)
+ });
+
+ combobox = dialog.insertTextField(RESP + i, "responsibleTextChanged", this,
+ TEXT_PROPS,
+ new Object[]
+ {
+ I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 2), new Integer(x + 103), y_, IStep, new Short((short) (tabindex + 2)), new Integer(68)
+ });
+
+ timebox = dialog.insertTextField(TIME + i, "timeTextChanged", this,
+ TEXT_PROPS,
+ new Object[]
+ {
+ I_12, HelpIds.getHelpIdString(curHelpIndex + i * 3 + 3), new Integer(x + 175), y_, IStep, new Short((short) (tabindex + 3)), new Integer(20)
+ });
+
+ setEnabled(false);
+ addKeyListener(textbox, this);
+ addKeyListener(combobox, this);
+ addKeyListener(timebox, this);
+
+ addFocusListener(textbox, TopicsControl.this);
+ addFocusListener(combobox, TopicsControl.this);
+ addFocusListener(timebox, TopicsControl.this);
+
+ }
+
+ /**
+ * not implemented.
+ * @param visible
+ */
+ public void setVisible(boolean visible)
+ {
+ // Helper.setUnoPropertyValue(UnoDialog2.getModel(button),"Visible", visible ? Boolean.TRUE : Boolean.FASLE);
+ }
+
+ /**
+ * enables/disables the row.
+ * @param enabled true for enable, false for disable.
+ */
+ public void setEnabled(boolean enabled)
+ {
+ Boolean b = enabled ? Boolean.TRUE : Boolean.FALSE;
+ UnoDialog2.setEnabled(label, b);
+ UnoDialog2.setEnabled(textbox, b);
+ UnoDialog2.setEnabled(combobox, b);
+ UnoDialog2.setEnabled(timebox, b);
+ }
+
+ /**
+ * Impelementation of XKeyListener.
+ * Optionally performs the one of the following:
+ * cursor up, or down, row up or down
+ */
+ public void keyPressed(KeyEvent event)
+ {
+ if (isMoveDown(event))
+ {
+ rowDown(offset, event.Source);
+ }
+ else if (isMoveUp(event))
+ {
+ rowUp(offset, event.Source);
+ }
+ else if (isDown(event))
+ {
+ cursorDown(offset, event.Source);
+ }
+ else if (isUp(event))
+ {
+ cursorUp(offset, event.Source);
+ }
+ enableButtons();
+ }
+
+ /**
+ * returns the column number of the given control.
+ * The given control must belong to this row or
+ * an IllegalArgumentException will accure.
+ * @param control
+ * @return an int columnd number of the given control (0 to 3).
+ */
+ private int getColumn(Object control)
+ {
+ if (control == textbox)
+ {
+ return 1;
+ }
+ else if (control == combobox)
+ {
+ return 2;
+ }
+ else if (control == timebox)
+ {
+ return 3;
+ }
+ else if (control == label)
+ {
+ return 0;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Control is not part of this ControlRow");
+ }
+ }
+
+ private boolean isMoveDown(KeyEvent e)
+ {
+ return (e.KeyCode == Key.DOWN) && (e.Modifiers == KeyModifier.MOD1);
+ }
+
+ private boolean isMoveUp(KeyEvent e)
+ {
+ return (e.KeyCode == Key.UP) && (e.Modifiers == KeyModifier.MOD1);
+ }
+
+ private boolean isDown(KeyEvent e)
+ {
+ return (e.KeyCode == Key.DOWN) && (e.Modifiers == 0);
+ }
+
+ private boolean isUp(KeyEvent e)
+ {
+ return (e.KeyCode == Key.UP) && (e.Modifiers == 0);
+ }
+
+ public void keyReleased(KeyEvent arg0)
+ {
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/agenda/agenda.component b/wizards/com/sun/star/wizards/agenda/agenda.component
new file mode 100644
index 000000000000..e35087d947e2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/agenda.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.wizards.agenda.CallWizard$WizardImplementation">
+ <service name="com.sun.star.wizards.agenda.CallWizard"/>
+ </implementation>
+</component>
diff --git a/wizards/com/sun/star/wizards/agenda/makefile.mk b/wizards/com/sun/star/wizards/agenda/makefile.mk
new file mode 100644
index 000000000000..1f07e9adfbcc
--- /dev/null
+++ b/wizards/com/sun/star/wizards/agenda/makefile.mk
@@ -0,0 +1,79 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = agenda
+PACKAGE = com$/sun$/star$/wizards$/agenda
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar \
+ jurt.jar \
+ ridl.jar \
+ juh.jar \
+ java_uno.jar \
+ java_uno_accessbridge \
+ commonwizards.jar
+
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/agenda
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ AgendaTemplate.java \
+ AgendaWizardDialog.java \
+ AgendaWizardDialogConst.java \
+ AgendaWizardDialogImpl.java \
+ AgendaWizardDialogResources.java \
+ CGAgenda.java \
+ CGTopic.java \
+ CallWizard.java \
+ TemplateConsts.java \
+ TopicsControl.java
+
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/agenda.component
+
+$(MISC)/agenda.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ agenda.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt agenda.component
diff --git a/wizards/com/sun/star/wizards/common/ConfigGroup.java b/wizards/com/sun/star/wizards/common/ConfigGroup.java
new file mode 100644
index 000000000000..1b260132a5f4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/ConfigGroup.java
@@ -0,0 +1,183 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import java.lang.reflect.Field;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class ConfigGroup implements ConfigNode
+{
+
+ public Object root;
+
+ public void writeConfiguration(Object configurationView, Object param)
+ {
+ Field[] fields = getClass().getFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ if (fields[i].getName().startsWith((String) param))
+ {
+ try
+ {
+ writeField(fields[i], configurationView, (String) param);
+ }
+ catch (Exception ex)
+ {
+ System.out.println("Error writing field: " + fields[i].getName());
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private void writeField(Field field, Object configView, String prefix) throws Exception
+ {
+ String propertyName = field.getName().substring(prefix.length());
+ //System.out.println("Going to save:" + propertyName);
+ Class fieldType = field.getType();
+ if (ConfigNode.class.isAssignableFrom(fieldType))
+ {
+ Object childView = Configuration.addConfigNode(configView, propertyName);
+ ConfigNode child = (ConfigNode) field.get(this);
+ child.writeConfiguration(childView, prefix);
+ }
+ else if (fieldType.isPrimitive())
+ {
+ Configuration.set(convertValue(field), propertyName, configView);
+ }
+ else if (fieldType.equals(String.class))
+ {
+ Configuration.set(field.get(this), propertyName, configView);
+ }
+ }
+
+ /**
+ * convert the primitive type value of the
+ * given Field object to the corresponding
+ * Java Object value.
+ * @param field
+ * @return the value of the field as a Object.
+ * @throws IllegalAccessException
+ */
+ public Object convertValue(Field field) throws IllegalAccessException
+ {
+ if (field.getType().equals(Boolean.TYPE))
+ {
+ return (field.getBoolean(this) ? Boolean.TRUE : Boolean.FALSE);
+ }
+ if (field.getType().equals(Integer.TYPE))
+ {
+ return new Integer(field.getInt(this));
+ }
+ if (field.getType().equals(Short.TYPE))
+ {
+ return new Short(field.getShort(this));
+ }
+ if (field.getType().equals(Float.TYPE))
+ {
+ return new Double(field.getFloat(this));
+ }
+ if (field.getType().equals(Double.TYPE))
+ {
+ return new Double(field.getDouble(this));
+ }
+ //System.out.println("ohoh...");
+ return null; //and good luck with it :-) ...
+ }
+
+ public void readConfiguration(Object configurationView, Object param)
+ {
+ Field[] fields = getClass().getFields();
+ for (int i = 0; i < fields.length; i++)
+ {
+ if (fields[i].getName().startsWith((String) param))
+ {
+ try
+ {
+ readField(fields[i], configurationView, (String) param);
+ }
+ catch (Exception ex)
+ {
+ System.out.println("Error reading field: " + fields[i].getName());
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ private void readField(Field field, Object configView, String prefix) throws Exception
+ {
+ String propertyName = field.getName().substring(prefix.length());
+
+ Class fieldType = field.getType();
+ if (ConfigNode.class.isAssignableFrom(fieldType))
+ {
+ ConfigNode child = (ConfigNode) field.get(this);
+ child.setRoot(root);
+ child.readConfiguration(Configuration.getNode(propertyName, configView), prefix);
+ }
+ else if (fieldType.isPrimitive())
+ {
+ if (fieldType.equals(Boolean.TYPE))
+ {
+ field.setBoolean(this, Configuration.getBoolean(propertyName, configView));
+ }
+ else if (fieldType.equals(Integer.TYPE))
+ {
+ field.setInt(this, Configuration.getInt(propertyName, configView));
+ }
+ else if (fieldType.equals(Short.TYPE))
+ {
+ field.setShort(this, Configuration.getShort(propertyName, configView));
+ }
+ else if (fieldType.equals(Float.TYPE))
+ {
+ field.setFloat(this, Configuration.getFloat(propertyName, configView));
+ }
+ else if (fieldType.equals(Double.TYPE))
+ {
+ field.setDouble(this, Configuration.getDouble(propertyName, configView));
+ }
+ }
+ else if (fieldType.equals(String.class))
+ {
+ field.set(this, Configuration.getString(propertyName, configView));
+ }
+ }
+
+ public void setRoot(Object newRoot)
+ {
+ root = newRoot;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.common.ConfigNode#writeConfiguration(java.lang.Object, java.lang.Object)
+ */
+}
diff --git a/wizards/com/sun/star/wizards/common/ConfigNode.java b/wizards/com/sun/star/wizards/common/ConfigNode.java
new file mode 100644
index 000000000000..23c0f9c5ba81
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/ConfigNode.java
@@ -0,0 +1,53 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+/**
+ * This Interface specifies a method of an object which is
+ * capable of reading adn writing its data out of the
+ * OO Configuration. <br/>
+ * There are 2 direct implementations: ConfigGroup and ConfigSet.
+ * The root is the first Java Object in the configuration hirarchie.
+ * @author rpiterman
+ */
+public interface ConfigNode
+{
+
+ /**
+ * reads the object data out of the configuration.
+ * @param configurationView is a ::com::sun::star::configuration::HierarchyElement
+ * which represents the node corresponding to the Object.
+ * @param param a free parameter. Since the intension of this interface is
+ * to be used in a tree like way, reading objects and subobjects and so on,
+ * it might be practical to be able to pass an extra parameter, for a free use.
+ */
+ public void readConfiguration(Object configurationView, Object param);
+
+ public void writeConfiguration(Object configurationView, Object param);
+
+ public void setRoot(Object root);
+}
diff --git a/wizards/com/sun/star/wizards/common/ConfigSet.java b/wizards/com/sun/star/wizards/common/ConfigSet.java
new file mode 100644
index 000000000000..216f91b5e430
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/ConfigSet.java
@@ -0,0 +1,452 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import java.util.*;
+
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+
+
+import org.w3c.dom.*;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class ConfigSet implements ConfigNode, XMLProvider, ListModel
+{
+
+ private Class childClass;
+ private Map childrenMap = new HashMap();
+ private List childrenList = new Vector();
+ public Object root;
+ /**
+ * After reading the configuration set items,
+ * the ConfigSet checks this field.
+ * If it is true, it will remove any nulls from
+ * the vector.
+ * subclasses can change this field in the constructor
+ * to avoid this "deletion" of nulls.
+ */
+ protected boolean noNulls = true;
+ /** Utility field used by event firing mechanism. */
+ private javax.swing.event.EventListenerList listenerList = null;
+
+ public ConfigSet(Class childType)
+ {
+ childClass = childType;
+ }
+
+ public void add(String name, Object child)
+ {
+ childrenMap.put(name, child);
+ try
+ {
+ int i = ((Indexable) child).getIndex();
+ int oldSize = getSize();
+ while (getSize() <= i)
+ {
+ childrenList.add(null);
+ }
+ childrenList.set(i, child);
+ if (oldSize > i)
+ {
+ oldSize = i;
+ }
+ fireListDataListenerIntervalAdded(oldSize, i);
+ }
+ catch (ClassCastException cce)
+ {
+ childrenList.add(child);
+ fireListDataListenerIntervalAdded(getSize() - 1, getSize() - 1);
+ }
+ }
+
+ public void add(int i, Object o)
+ {
+ int name = i;
+ while (getElement("" + name) != null)
+ {
+ name++;
+ }
+ childrenMap.put("" + name, o);
+ childrenList.add(i, o);
+
+ fireListDataListenerIntervalAdded(i, i);
+ }
+
+ protected Object createChild() throws InstantiationException, IllegalAccessException
+ {
+ return childClass.newInstance();
+ }
+
+ public void writeConfiguration(Object configView, Object param)
+ {
+ Object[] names = childrenMap.keySet().toArray();
+
+ if (ConfigNode.class.isAssignableFrom(childClass))
+ {
+ //first I remove all the children from the configuration.
+ String children[] = Configuration.getChildrenNames(configView);
+ for (int i = 0; i < children.length; i++)
+ {
+ try
+ {
+ Configuration.removeNode(configView, children[i]);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ } // and add them new.
+ }
+ for (int i = 0; i < names.length; i++)
+ {
+ try
+ {
+ ConfigNode child = (ConfigNode) getElement(names[i]);
+ Object childView = Configuration.addConfigNode(configView, (String) names[i]);
+ child.writeConfiguration(childView, param);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ //for a set of primitive / String type.
+ else
+ {
+ throw new IllegalArgumentException("Unable to write primitive sets to configuration (not implemented)");
+ }
+ }
+
+ public void readConfiguration(Object configurationView, Object param)
+ {
+ String[] names = Configuration.getChildrenNames(configurationView);
+
+ if (ConfigNode.class.isAssignableFrom(childClass))
+ {
+
+ for (int i = 0; i < names.length; i++)
+ {
+ try
+ {
+ ConfigNode child = (ConfigNode) createChild();
+ child.setRoot(root);
+ child.readConfiguration(Configuration.getNode(names[i], configurationView), param);
+ add(names[i], child);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ //remove any nulls from the list
+ if (noNulls)
+ {
+ for (int i = 0; i < childrenList.size(); i++)
+ {
+ if (childrenList.get(i) == null)
+ {
+ childrenList.remove(i--);
+ }
+ }
+ }
+ }
+ //for a set of primitive / String type.
+ else
+ {
+ for (int i = 0; i < names.length; i++)
+ {
+ try
+ {
+ Object child = Configuration.getNode(names[i], configurationView);
+ add(names[i], child);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public void remove(Object obj)
+ {
+ Object key = getKey(obj);
+ childrenMap.remove(key);
+ int i = childrenList.indexOf(obj);
+ childrenList.remove(obj);
+ fireListDataListenerIntervalRemoved(i, i);
+ }
+
+ public void remove(int i)
+ {
+ Object o = getElementAt(i);
+ remove(o);
+ }
+
+ public void clear()
+ {
+ childrenMap.clear();
+ childrenList.clear();
+ }
+
+ public void update(int i)
+ {
+ fireListDataListenerContentsChanged(i, i);
+ }
+
+ public Node createDOM(Node parent)
+ {
+
+ Object[] items = items();
+
+ for (int i = 0; i < items.length; i++)
+ {
+ Object item = items[i];
+ if (item instanceof XMLProvider)
+ {
+ ((XMLProvider) item).createDOM(parent);
+ }
+ }
+ return parent;
+ }
+
+ public Object[] items()
+ {
+ return childrenList.toArray();
+ }
+
+ public Object getKey(Object object)
+ {
+ for (Iterator i = childrenMap.entrySet().iterator(); i.hasNext();)
+ {
+
+ Map.Entry me = (Map.Entry) i.next();
+ if (me.getValue() == object)
+ {
+ return me.getKey();
+ }
+ }
+ return null;
+ }
+
+ public Object getKey(int i)
+ {
+ int c = 0;
+ while (i > -1)
+ {
+ if (getElementAt(c) != null)
+ {
+ i--;
+ }
+ c++;
+ }
+ if (c == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return getKey(getElementAt(c - 1));
+ }
+ }
+
+ public void setRoot(Object newRoot)
+ {
+ root = newRoot;
+ }
+
+ /** Registers ListDataListener to receive events.
+ * @param listener The listener to register.
+ *
+ */
+ public synchronized void addListDataListener(javax.swing.event.ListDataListener listener)
+ {
+ if (listenerList == null)
+ {
+ listenerList = new javax.swing.event.EventListenerList();
+ }
+ listenerList.add(javax.swing.event.ListDataListener.class, listener);
+ }
+
+ /** Removes ListDataListener from the list of listeners.
+ * @param listener The listener to remove.
+ *
+ */
+ public synchronized void removeListDataListener(javax.swing.event.ListDataListener listener)
+ {
+ listenerList.remove(javax.swing.event.ListDataListener.class, listener);
+ }
+
+ /** Notifies all registered listeners about the event.
+ *
+ * @param event The event to be fired
+ *
+ */
+ private void fireListDataListenerIntervalAdded(int i0, int i1)
+ {
+ ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_ADDED, i0, i1);
+ if (listenerList == null)
+ {
+ return;
+ }
+ Object[] listeners = listenerList.getListenerList();
+ for (int i = listeners.length - 2; i >= 0; i -= 2)
+ {
+ if (listeners[i] == javax.swing.event.ListDataListener.class)
+ {
+ ((javax.swing.event.ListDataListener) listeners[i + 1]).intervalAdded(event);
+ }
+ }
+ }
+
+ /** Notifies all registered listeners about the event.
+ *
+ * @param event The event to be fired
+ *
+ */
+ private void fireListDataListenerIntervalRemoved(int i0, int i1)
+ {
+ ListDataEvent event = new ListDataEvent(this, ListDataEvent.INTERVAL_REMOVED, i0, i1);
+ if (listenerList == null)
+ {
+ return;
+ }
+ Object[] listeners = listenerList.getListenerList();
+ for (int i = listeners.length - 2; i >= 0; i -= 2)
+ {
+ if (listeners[i] == javax.swing.event.ListDataListener.class)
+ {
+ ((javax.swing.event.ListDataListener) listeners[i + 1]).intervalRemoved(event);
+ }
+ }
+ }
+
+ /** Notifies all registered listeners about the event.
+ *
+ * @param event The event to be fired
+ *
+ */
+ private void fireListDataListenerContentsChanged(int i0, int i1)
+ {
+ ListDataEvent event = new ListDataEvent(this, ListDataEvent.CONTENTS_CHANGED, i0, i1);
+ if (listenerList == null)
+ {
+ return;
+ }
+ Object[] listeners = listenerList.getListenerList();
+ for (int i = listeners.length - 2; i >= 0; i -= 2)
+ {
+ if (listeners[i] == javax.swing.event.ListDataListener.class)
+ {
+ ((javax.swing.event.ListDataListener) listeners[i + 1]).contentsChanged(event);
+ }
+ }
+ }
+
+ public Object getElementAt(int i)
+ {
+ return childrenList.get(i);
+ }
+
+ public Object getElement(Object o)
+ {
+ return childrenMap.get(o);
+ }
+
+ public int getSize()
+ {
+ return childrenList.size();
+ }
+
+ public Set keys()
+ {
+ return childrenMap.keySet();
+ }
+
+ public int getIndexOf(Object item)
+ {
+ return childrenList.indexOf(item);
+ }
+
+ /**
+ * Set members might include a property
+ * which orders them.
+ * This method reindexes the given member to be
+ * the index number 0
+ * Do not forget to call commit() after calling this method.
+ * @param confView
+ * @param memebrName
+ */
+ public void reindexSet(Object confView, String memberName, String indexPropertyName) throws Exception
+ {
+ /*
+ * First I read all memebrs of the set,
+ * except the one that should be number 0
+ * to a vector, ordered by there index property
+ */
+ String[] names = Configuration.getChildrenNames(confView);
+ Vector v = new Vector(names.length);
+ Object member = null;
+ int index = 0;
+ for (int i = 0; i < names.length; i++)
+ {
+ if (!names[i].equals(memberName))
+ {
+ member = Configuration.getConfigurationNode(names[i], confView);
+ index = Configuration.getInt(indexPropertyName, member);
+ while (index >= v.size())
+ {
+ v.add(null);
+ }
+ v.setElementAt(member, index);
+
+ }
+ /**
+ * Now I reindex them
+ */
+ }
+ index = 1;
+ for (int i = 0; i < v.size(); i++)
+ {
+ member = v.get(i);
+ if (member != null)
+ {
+ Configuration.set(index++, indexPropertyName, member);
+ }
+ }
+
+ }
+
+ public void sort(Comparator comparator)
+ {
+ Collections.sort(this.childrenList, comparator);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/Configuration.java b/wizards/com/sun/star/wizards/common/Configuration.java
new file mode 100644
index 000000000000..cbe724335cf8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Configuration.java
@@ -0,0 +1,457 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.beans.*;
+import com.sun.star.container.*;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.Locale;
+import com.sun.star.util.XChangesBatch;
+
+/**
+ * This class gives access to the OO configuration api.
+ * It contains 4 get and 4 set convenience methods for getting and settings properties
+ * in the configuration. <br/>
+ * For the get methods, two parameters must be given: name and parent, where name is the
+ * name of the property, parent is a HierarchyElement (::com::sun::star::configuration::HierarchyElement)<br/>
+ * The get and set methods support hieryrchical property names like "options/gridX". <br/>
+ * NOTE: not yet supported, but sometime later,
+ * If you will ommit the "parent" parameter, then the "name" parameter must be in hierarchy form from
+ * the root of the registry.
+ * @author rpiterman
+ */
+public abstract class Configuration
+{
+
+ public static int getInt(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return 0;
+ }
+ return AnyConverter.toInt(o);
+ }
+
+ public static short getShort(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return (short) 0;
+ }
+ return AnyConverter.toShort(o);
+ }
+
+ public static float getFloat(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return (float) 0;
+ }
+ return AnyConverter.toFloat(o);
+ }
+
+ public static double getDouble(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return (double) 0;
+ }
+ return AnyConverter.toDouble(o);
+ }
+
+ public static String getString(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return "";
+ }
+ return (String) o;
+ }
+
+ public static boolean getBoolean(String name, Object parent) throws Exception
+ {
+ Object o = getNode(name, parent);
+ if (AnyConverter.isVoid(o))
+ {
+ return false;
+ }
+ return AnyConverter.toBoolean(o);
+ }
+
+ public static Object getNode(String name, Object parent) throws Exception
+ {
+ return ((XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, parent)).getByName(name);
+ }
+
+ public static void set(int value, String name, Object parent) throws Exception
+ {
+ set(new Integer(value), name, parent);
+ }
+
+ public static void set(short value, String name, Object parent) throws Exception
+ {
+ set(new Short(value), name, parent);
+ }
+
+ public static void set(String value, String name, Object parent) throws Exception
+ {
+ set((Object) value, name, parent);
+ }
+
+ public static void set(boolean value, String name, Object parent) throws Exception
+ {
+ if (value == true)
+ {
+ set(Boolean.TRUE, name, parent);
+ }
+ else
+ {
+ set(Boolean.FALSE, name, parent);
+ }
+ }
+
+ public static void set(Object value, String name, Object parent) throws com.sun.star.lang.IllegalArgumentException, PropertyVetoException, UnknownPropertyException, WrappedTargetException
+ {
+ ((XHierarchicalPropertySet) UnoRuntime.queryInterface(XHierarchicalPropertySet.class, parent)).setHierarchicalPropertyValue(name, value);
+ }
+
+ /** Creates a new instance of RegistryEntry
+ * @param name
+ * @param parent
+ * @return
+ * @throws Exception
+ */
+ public static Object getConfigurationNode(String name, Object parent) throws Exception
+ {
+ return ((XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, parent)).getByName(name);
+ }
+
+ public static Object getConfigurationRoot(XMultiServiceFactory xmsf, String sPath, boolean updateable) throws com.sun.star.uno.Exception
+ {
+
+ Object oConfigProvider;
+ oConfigProvider = xmsf.createInstance("com.sun.star.configuration.ConfigurationProvider");
+ XMultiServiceFactory confMsf = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider);
+
+ final String sView = updateable ? "com.sun.star.configuration.ConfigurationUpdateAccess" : "com.sun.star.configuration.ConfigurationAccess";
+
+ Object args[] = new Object[updateable ? 2 : 1];
+
+ PropertyValue aPathArgument = new PropertyValue();
+ aPathArgument.Name = "nodepath";
+ aPathArgument.Value = sPath;
+
+ args[0] = aPathArgument;
+
+ if (updateable)
+ {
+
+ PropertyValue aModeArgument = new PropertyValue();
+ aModeArgument.Name = "lazywrite";
+ aModeArgument.Value = Boolean.FALSE;
+
+ args[1] = aModeArgument;
+ }
+
+ return confMsf.createInstanceWithArguments(sView, args);
+ }
+
+ public static String[] getChildrenNames(Object configView)
+ {
+ XNameAccess nameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, configView);
+ return nameAccess.getElementNames();
+ }
+
+ public static String getProductName(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ Object oProdNameAccess = getConfigurationRoot(xMSF, "org.openoffice.Setup/Product", false);
+ String ProductName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "ooName");
+ return ProductName;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static String getOfficeLocaleString(XMultiServiceFactory xMSF)
+ {
+ String sLocale = "";
+ try
+ {
+ Locale aLocLocale = new Locale();
+ Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false);
+ sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale");
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return sLocale;
+ }
+
+ public static Locale getOfficeLocale(XMultiServiceFactory xMSF)
+ {
+ Locale aLocLocale = new Locale();
+ // Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false);
+ // String sLocale = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale");
+ String sLocale = getOfficeLocaleString(xMSF);
+ String[] sLocaleList = JavaTools.ArrayoutofString(sLocale, "-");
+ aLocLocale.Language = sLocaleList[0];
+ if (sLocaleList.length > 1)
+ {
+ aLocLocale.Country = sLocaleList[1];
+ }
+ return aLocLocale;
+ }
+
+ public static String getOfficeLinguistic(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ Object oMasterKey = getConfigurationRoot(xMSF, "org.openoffice.Setup/L10N/", false);
+ String sLinguistic = (String) Helper.getUnoObjectbyName(oMasterKey, "ooLocale");
+ return sLinguistic;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * This method creates a new configuration node and adds it
+ * to the given view. Note that if a node with the given name
+ * already exists it will be completely removed from
+ * the configuration.
+ * @param configView
+ * @param name
+ * @return the new created configuration node.
+ * @throws com.sun.star.lang.WrappedTargetException
+ * @throws ElementExistException
+ * @throws NoSuchElementException
+ * @throws com.sun.star.uno.Exception
+ */
+ public static Object addConfigNode(Object configView, String name) throws com.sun.star.lang.WrappedTargetException, ElementExistException, NoSuchElementException, com.sun.star.uno.Exception
+ {
+
+ XNameContainer xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, configView);
+
+ if (xNameContainer == null)
+ {
+ XNameReplace xNameReplace = (XNameReplace) UnoRuntime.queryInterface(XNameReplace.class, configView);
+ return xNameReplace.getByName(name);
+ }
+ else
+ {
+
+ /*if (xNameContainer.hasByName(name))
+ xNameContainer.removeByName(name);*/
+
+ // create a new detached set element (instance of DataSourceDescription)
+ XSingleServiceFactory xElementFactory = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, configView);
+
+ // the new element is the result !
+ Object newNode = xElementFactory.createInstance();
+ // insert it - this also names the element
+ xNameContainer.insertByName(name, newNode);
+
+ return newNode;
+ }
+ }
+
+ public static void removeNode(Object configView, String name) throws NoSuchElementException, WrappedTargetException
+ {
+ XNameContainer xNameContainer = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, configView);
+
+ if (xNameContainer.hasByName(name))
+ {
+ xNameContainer.removeByName(name);
+ }
+ }
+
+ public static void commit(Object configView) throws WrappedTargetException
+ {
+ XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, configView);
+ xUpdateControl.commitChanges();
+ }
+
+ public static void updateConfiguration(XMultiServiceFactory xmsf, String path, String name, ConfigNode node, Object param) throws com.sun.star.uno.Exception, com.sun.star.container.ElementExistException, NoSuchElementException, WrappedTargetException
+ {
+ Object view = Configuration.getConfigurationRoot(xmsf, path, true);
+ addConfigNode(path, name);
+ node.writeConfiguration(view, param);
+ XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, view);
+ xUpdateControl.commitChanges();
+ }
+
+ public static void removeNode(XMultiServiceFactory xmsf, String path, String name) throws com.sun.star.uno.Exception, com.sun.star.container.ElementExistException, NoSuchElementException, WrappedTargetException
+ {
+ Object view = Configuration.getConfigurationRoot(xmsf, path, true);
+ removeNode(view, name);
+ XChangesBatch xUpdateControl = (XChangesBatch) UnoRuntime.queryInterface(XChangesBatch.class, view);
+ xUpdateControl.commitChanges();
+ }
+
+ public static String[] getNodeDisplayNames(XNameAccess _xNameAccessNode)
+ {
+ String[] snames = null;
+ return getNodeChildNames(_xNameAccessNode, "Name");
+ }
+
+ public static String[] getNodeChildNames(XNameAccess xNameAccessNode, String _schildname)
+ {
+ String[] snames = null;
+ try
+ {
+ snames = xNameAccessNode.getElementNames();
+ String[] sdisplaynames = new String[snames.length];
+ for (int i = 0; i < snames.length; i++)
+ {
+ Object oContent = Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname);
+ if (!AnyConverter.isVoid(oContent))
+ {
+ sdisplaynames[i] = (String) Helper.getUnoPropertyValue(xNameAccessNode.getByName(snames[i]), _schildname);
+ }
+ else
+ {
+ sdisplaynames[i] = snames[i];
+ }
+ }
+ return sdisplaynames;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return snames;
+ }
+ }
+
+ public static XNameAccess getChildNodebyIndex(XNameAccess _xNameAccess, int _index)
+ {
+ try
+ {
+ String[] snames = _xNameAccess.getElementNames();
+ Object oNode = _xNameAccess.getByName(snames[_index]);
+ XNameAccess xNameAccessNode = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oNode);
+ return xNameAccessNode;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static XNameAccess getChildNodebyName(XNameAccess _xNameAccessNode, String _SubNodeName)
+ {
+ try
+ {
+ if (_xNameAccessNode.hasByName(_SubNodeName))
+ {
+ return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(_SubNodeName));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static XNameAccess getChildNodebyDisplayName(XNameAccess _xNameAccessNode, String _displayname)
+ {
+ String[] snames = null;
+ return getChildNodebyDisplayName(_xNameAccessNode, _displayname, "Name");
+ }
+
+ public static XNameAccess getChildNodebyDisplayName(XNameAccess _xNameAccessNode, String _displayname, String _nodename)
+ {
+ String[] snames = null;
+ try
+ {
+ snames = _xNameAccessNode.getElementNames();
+ String[] sdisplaynames = new String[snames.length];
+ for (int i = 0; i < snames.length; i++)
+ {
+ String curdisplayname = (String) Helper.getUnoPropertyValue(_xNameAccessNode.getByName(snames[i]), _nodename);
+ if (curdisplayname.equals(_displayname))
+ {
+ return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(snames[i]));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static XNameAccess getChildNodebyDisplayName(XMultiServiceFactory _xMSF, Locale _aLocale, XNameAccess _xNameAccessNode, String _displayname, String _nodename, int _nmaxcharcount)
+ {
+ String[] snames = null;
+ try
+ {
+ snames = _xNameAccessNode.getElementNames();
+ String[] sdisplaynames = new String[snames.length];
+ for (int i = 0; i < snames.length; i++)
+ {
+ String curdisplayname = (String) Helper.getUnoPropertyValue(_xNameAccessNode.getByName(snames[i]), _nodename);
+ if ((_nmaxcharcount > 0) && (_nmaxcharcount < curdisplayname.length()))
+ {
+ curdisplayname = curdisplayname.substring(0, _nmaxcharcount);
+ }
+ curdisplayname = Desktop.removeSpecialCharacters(_xMSF, _aLocale, curdisplayname);
+
+ if (curdisplayname.equals(_displayname))
+ {
+ return (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, _xNameAccessNode.getByName(snames[i]));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/DebugHelper.java b/wizards/com/sun/star/wizards/common/DebugHelper.java
new file mode 100644
index 000000000000..b560fb643a40
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/DebugHelper.java
@@ -0,0 +1,58 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.uno.Exception;
+
+/**
+ *
+ * @author ll93751
+ */
+public class DebugHelper
+{
+
+ public static void exception(String DetailedMessage, Exception ex, int err, String additionalArgument) throws java.lang.Exception
+ {
+// throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public static void exception(int err, String additionalArgument) throws java.lang.Exception
+ {
+// throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public static void exception(Exception ex) throws java.lang.Exception
+ {
+// throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public static void writeInfo(String msg)
+ {
+// throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/Desktop.java b/wizards/com/sun/star/wizards/common/Desktop.java
new file mode 100644
index 000000000000..8902696c37b4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Desktop.java
@@ -0,0 +1,509 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+// import java.util.Date;
+
+// import com.sun.star.awt.XToolkit;
+import com.sun.star.beans.PropertyValue;
+// import com.sun.star.frame.XDesktop;
+// import com.sun.star.frame.XFrame;
+// import com.sun.star.frame.XFramesSupplier;
+
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiComponentFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.uno.XNamingService;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.lang.Locale;
+import com.sun.star.uno.XInterface;
+import com.sun.star.bridge.XUnoUrlResolver;
+import com.sun.star.comp.helper.Bootstrap;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.util.XStringSubstitution;
+import com.sun.star.frame.*;
+import com.sun.star.i18n.KParseType;
+import com.sun.star.i18n.ParseResult;
+import com.sun.star.i18n.XCharacterClassification;
+
+public class Desktop
+{
+
+ /** Creates a new instance of Desktop */
+ public Desktop()
+ {
+ }
+
+ public static XDesktop getDesktop(XMultiServiceFactory xMSF)
+ {
+ com.sun.star.uno.XInterface xInterface = null;
+ XDesktop xDesktop = null;
+ if (xMSF != null)
+ {
+ try
+ {
+ xInterface = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.frame.Desktop");
+ xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xInterface);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ else
+ {
+ System.out.println("Can't create a desktop. null pointer !");
+ }
+ return xDesktop;
+ }
+
+ public static XFrame getActiveFrame(XMultiServiceFactory xMSF)
+ {
+ XDesktop xDesktop = getDesktop(xMSF);
+ XFramesSupplier xFrameSuppl = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop);
+ XFrame xFrame = xFrameSuppl.getActiveFrame();
+ return xFrame;
+ }
+
+ public static XComponent getActiveComponent(XMultiServiceFactory _xMSF)
+ {
+ XFrame xFrame = getActiveFrame(_xMSF);
+ return (XComponent) UnoRuntime.queryInterface(XComponent.class, xFrame.getController().getModel());
+ }
+
+ public static XTextDocument getActiveTextDocument(XMultiServiceFactory _xMSF)
+ {
+ XComponent xComponent = getActiveComponent(_xMSF);
+ return (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+ }
+
+ public static XSpreadsheetDocument getActiveSpreadsheetDocument(XMultiServiceFactory _xMSF)
+ {
+ XComponent xComponent = getActiveComponent(_xMSF);
+ return (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, xComponent);
+ }
+
+ public static XDispatch getDispatcher(XMultiServiceFactory xMSF, XFrame xFrame, String _stargetframe, com.sun.star.util.URL oURL)
+ {
+ try
+ {
+ com.sun.star.util.URL[] oURLArray = new com.sun.star.util.URL[1];
+ oURLArray[0] = oURL;
+ XDispatchProvider xDispatchProvider = (XDispatchProvider) UnoRuntime.queryInterface(XDispatchProvider.class, xFrame);
+ XDispatch xDispatch = xDispatchProvider.queryDispatch(oURLArray[0], _stargetframe, FrameSearchFlag.ALL); // "_self"
+ return xDispatch;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static com.sun.star.util.URL getDispatchURL(XMultiServiceFactory xMSF, String _sURL)
+ {
+ try
+ {
+ Object oTransformer = xMSF.createInstance("com.sun.star.util.URLTransformer");
+ XURLTransformer xTransformer = (XURLTransformer) UnoRuntime.queryInterface(XURLTransformer.class, oTransformer);
+ com.sun.star.util.URL[] oURL = new com.sun.star.util.URL[1];
+ oURL[0] = new com.sun.star.util.URL();
+ oURL[0].Complete = _sURL;
+ xTransformer.parseStrict(oURL);
+ return oURL[0];
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame, String _stargetframe)
+ {
+ com.sun.star.util.URL oURL = getDispatchURL(xMSF, sURL);
+ XDispatch xDispatch = getDispatcher(xMSF, xFrame, _stargetframe, oURL);
+ dispatchURL(xDispatch, oURL);
+ }
+
+ public static void dispatchURL(XMultiServiceFactory xMSF, String sURL, XFrame xFrame)
+ {
+ dispatchURL(xMSF, sURL, xFrame, "");
+ }
+
+ public static void dispatchURL(XDispatch _xDispatch, com.sun.star.util.URL oURL)
+ {
+ PropertyValue[] oArg = new PropertyValue[0];
+ _xDispatch.dispatch(oURL, oArg);
+ }
+
+ public static XMultiComponentFactory getMultiComponentFactory() throws com.sun.star.uno.Exception, RuntimeException, java.lang.Exception
+ {
+ XComponentContext xcomponentcontext = Bootstrap.createInitialComponentContext(null);
+ // initial serviceManager
+ return xcomponentcontext.getServiceManager();
+ }
+
+ public static XMultiServiceFactory connect(String connectStr) throws com.sun.star.uno.Exception, com.sun.star.uno.RuntimeException, Exception
+ {
+ XMultiComponentFactory componentFactory = getMultiComponentFactory();
+ Object xUrlResolver = componentFactory.createInstanceWithContext( "com.sun.star.bridge.UnoUrlResolver", null );
+ XUnoUrlResolver urlResolver = UnoRuntime.queryInterface(XUnoUrlResolver.class, xUrlResolver);
+ XMultiServiceFactory orb = UnoRuntime.queryInterface(XMultiServiceFactory.class, urlResolver.resolve( connectStr ) );
+ return orb;
+ }
+
+ public static String getIncrementSuffix(XNameAccess xElementContainer, String ElementName)
+ {
+ boolean bElementexists = true;
+ int i = 1;
+ String sIncSuffix = "";
+ String BaseName = ElementName;
+ while (bElementexists == true)
+ {
+ bElementexists = xElementContainer.hasByName(ElementName);
+ if (bElementexists == true)
+ {
+ i += 1;
+ ElementName = BaseName + Integer.toString(i);
+ }
+ }
+ if (i > 1)
+ {
+ sIncSuffix = Integer.toString(i);
+ }
+ return sIncSuffix;
+ }
+
+ public static String getIncrementSuffix(XHierarchicalNameAccess xElementContainer, String ElementName)
+ {
+ boolean bElementexists = true;
+ int i = 1;
+ String sIncSuffix = "";
+ String BaseName = ElementName;
+ while (bElementexists == true)
+ {
+ bElementexists = xElementContainer.hasByHierarchicalName(ElementName);
+ if (bElementexists == true)
+ {
+ i += 1;
+ ElementName = BaseName + Integer.toString(i);
+ }
+ }
+ if (i > 1)
+ {
+ sIncSuffix = Integer.toString(i);
+ }
+ return sIncSuffix;
+ }
+
+ public static int checkforfirstSpecialCharacter(XMultiServiceFactory _xMSF, String _sString, Locale _aLocale)
+ {
+ try
+ {
+ int nStartFlags = com.sun.star.i18n.KParseTokens.ANY_LETTER_OR_NUMBER + com.sun.star.i18n.KParseTokens.ASC_UNDERSCORE;
+ int nContFlags = nStartFlags;
+ Object ocharservice = _xMSF.createInstance("com.sun.star.i18n.CharacterClassification");
+ XCharacterClassification xCharacterClassification = (XCharacterClassification) UnoRuntime.queryInterface(XCharacterClassification.class, ocharservice);
+ ParseResult aResult = xCharacterClassification.parsePredefinedToken(KParseType.IDENTNAME, _sString, 0, _aLocale, nStartFlags, "", nContFlags, " ");
+ return aResult.EndPos;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+ public static String removeSpecialCharacters(XMultiServiceFactory _xMSF, Locale _aLocale, String _sname)
+ {
+ String snewname = _sname;
+ int i = 0;
+ while (i < snewname.length())
+ {
+ i = Desktop.checkforfirstSpecialCharacter(_xMSF, snewname, _aLocale);
+ if (i < snewname.length())
+ {
+ String sspecialchar = snewname.substring(i, i + 1);
+ snewname = JavaTools.replaceSubString(snewname, "", sspecialchar);
+ }
+ }
+ return snewname;
+ }
+
+ /**
+ * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a
+ * suffix to make it unique
+ * @param xElementContainer
+ * @param sElementName
+ * @return a unique Name ready to be added to the container.
+ */
+ public static String getUniqueName(XNameAccess xElementContainer, String sElementName)
+ {
+ String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName);
+ return sElementName + sIncSuffix;
+ }
+
+ /**
+ * Checks if the passed Element Name already exists in the ElementContainer. If yes it appends a
+ * suffix to make it unique
+ * @param xElementContainer
+ * @param sElementName
+ * @return a unique Name ready to be added to the container.
+ */
+ public static String getUniqueName(XHierarchicalNameAccess xElementContainer, String sElementName)
+ {
+ String sIncSuffix = getIncrementSuffix(xElementContainer, sElementName);
+ return sElementName + sIncSuffix;
+ }
+
+ /**
+ * Checks if the passed Element Name already exists in the list If yes it appends a
+ * suffix to make it unique
+ * @param _slist
+ * @param _sElementName
+ * @param _sSuffixSeparator
+ * @return a unique Name not being in the passed list.
+ */
+ public static String getUniqueName(String[] _slist, String _sElementName, String _sSuffixSeparator)
+ {
+ int a = 2;
+ String scompname = _sElementName;
+ boolean bElementexists = true;
+ if (_slist == null)
+ {
+ return _sElementName;
+ }
+ if (_slist.length == 0)
+ {
+ return _sElementName;
+ }
+ while (bElementexists == true)
+ {
+ for (int i = 0; i < _slist.length; i++)
+ {
+ if (JavaTools.FieldInList(_slist, scompname) == -1)
+ {
+ return scompname;
+ }
+ }
+ scompname = _sElementName + _sSuffixSeparator + a++;
+ }
+ return "";
+ }
+
+ /**
+ * @deprecated use Configuration.getConfigurationRoot() with the same parameters instead
+ * @param xMSF
+ * @param KeyName
+ * @param bForUpdate
+ * @return
+ */
+ public static XInterface getRegistryKeyContent(XMultiServiceFactory xMSF, String KeyName, boolean bForUpdate)
+ {
+ try
+ {
+ Object oConfigProvider;
+ PropertyValue[] aNodePath = new PropertyValue[1];
+ oConfigProvider = xMSF.createInstance("com.sun.star.configuration.ConfigurationProvider");
+ aNodePath[0] = new PropertyValue();
+ aNodePath[0].Name = "nodepath";
+ aNodePath[0].Value = KeyName;
+ XMultiServiceFactory xMSFConfig = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oConfigProvider);
+ if (bForUpdate == true)
+ {
+ return (XInterface) xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationUpdateAccess", aNodePath);
+ }
+ else
+ {
+ return (XInterface) xMSFConfig.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ /**
+ * @deprecated used to retrieve the most common paths used in the office application
+ * @author bc93774
+ *
+ */
+ public class OfficePathRetriever
+ {
+
+ public String TemplatePath;
+ public String BitmapPath;
+ public String UserTemplatePath;
+ public String WorkPath;
+
+ public OfficePathRetriever(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ TemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard");
+ UserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", "");
+ BitmapPath = FileAccess.combinePaths(xMSF, TemplatePath, "/../wizard/bitmap");
+ WorkPath = FileAccess.getOfficePath(xMSF, "Work", "", "");
+ }
+ catch (NoValidPathException nopathexception)
+ {
+ }
+ }
+ }
+
+ public static String getTemplatePath(XMultiServiceFactory _xMSF)
+ {
+ try
+ {
+ String sTemplatePath = FileAccess.getOfficePath(_xMSF, "Template", "share", "/wizard");
+ return sTemplatePath;
+ }
+ catch (NoValidPathException nopathexception)
+ {
+ }
+ return "";
+ }
+
+ public static String getUserTemplatePath(XMultiServiceFactory _xMSF)
+ {
+ try
+ {
+ String sUserTemplatePath = FileAccess.getOfficePath(_xMSF, "Template", "user", "");
+ return sUserTemplatePath;
+ }
+ catch (NoValidPathException nopathexception)
+ {
+ }
+ return "";
+ }
+
+ public static String getBitmapPath(XMultiServiceFactory _xMSF)
+ {
+ try
+ {
+ String sBitmapPath = FileAccess.combinePaths(_xMSF, getTemplatePath(_xMSF), "/../wizard/bitmap");
+ return sBitmapPath;
+ }
+ catch (NoValidPathException nopathexception)
+ {
+ }
+ return "";
+ }
+
+ public static String getWorkPath(XMultiServiceFactory _xMSF)
+ {
+ try
+ {
+ String sWorkPath = FileAccess.getOfficePath(_xMSF, "Work", "", "");
+ return sWorkPath;
+ }
+ catch (NoValidPathException nopathexception)
+ {
+ }
+ return "";
+ }
+
+ public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF)
+ {
+ Object xPathSubst = null;
+ try
+ {
+ xPathSubst = xMSF.createInstance("com.sun.star.util.PathSubstitution");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+ if (xPathSubst != null)
+ {
+ return (XStringSubstitution) UnoRuntime.queryInterface(XStringSubstitution.class, xPathSubst);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * This method searches (and hopefully finds...) a frame
+ * with a componentWindow.
+ * It does it in three phases:
+ * 1. Check if the given desktop argument has a componentWindow.
+ * If it is null, the myFrame argument is taken.
+ * 2. Go up the tree of frames and search a frame with a component window.
+ * 3. Get from the desktop all the components, and give the first one
+ * which has a frame.
+ * @param xMSF
+ * @param myFrame
+ * @param desktop
+ * @return
+ * @throws NoSuchElementException
+ * @throws WrappedTargetException
+ */
+ public static XFrame findAFrame(XMultiServiceFactory xMSF, XFrame myFrame, XFrame desktop)
+ throws NoSuchElementException,
+ WrappedTargetException
+ {
+ if (desktop == null)
+ {
+ desktop = myFrame; // we go up in the tree...
+ }
+ while (desktop != null && desktop.getComponentWindow() == null)
+ {
+ desktop = desktop.findFrame("_parent", FrameSearchFlag.PARENT);
+ }
+ if (desktop == null)
+ {
+
+ for (XEnumeration e = Desktop.getDesktop(xMSF).getComponents().createEnumeration(); e.hasMoreElements();)
+ {
+
+ Object comp = ((Any) e.nextElement()).getObject();
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, comp);
+ XFrame xFrame = xModel.getCurrentController().getFrame();
+
+ if (xFrame != null && xFrame.getComponentWindow() != null)
+ {
+ return xFrame;
+ }
+ }
+ }
+ return desktop;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/FileAccess.java b/wizards/com/sun/star/wizards/common/FileAccess.java
new file mode 100644
index 000000000000..6278d7e71a97
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/FileAccess.java
@@ -0,0 +1,1200 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.Locale;
+import com.sun.star.uno.Exception;
+import com.sun.star.util.XMacroExpander;
+// import com.sun.star.wizards.common.NoValidPathException;
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Vector;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.io.XActiveDataSink;
+import com.sun.star.io.XInputStream;
+// import com.sun.star.io.XStream;
+import com.sun.star.io.XTextInputStream;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.*;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.DateTime;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.XDocumentProperties;
+
+/**
+ * This class delivers static convenience methods
+ * to use with ucb SimpleFileAccess service.
+ * You can also instanciate the class, to encapsulate
+ * some functionality of SimpleFileAccess. The instance
+ * keeps a reference to an XSimpleFileAccess and an
+ * XFileIdentifierConverter, saves the permanent
+ * overhead of quering for those interfaces, and delivers
+ * conveneince methods for using them.
+ * These Convenince methods include mainly Exception-handling.
+ */
+public class FileAccess
+{
+
+ /**
+ *
+ * @param xMSF
+ * @param sPath
+ * @param sAddPath
+ */
+ public static void addOfficePath(XMultiServiceFactory xMSF, String sPath, String sAddPath)
+ {
+ XSimpleFileAccess xSimpleFileAccess = null;
+ String ResultPath = getOfficePath(xMSF, sPath, xSimpleFileAccess);
+ // As there are several conventions about the look of Url (e.g. with " " or with "%20") you cannot make a
+ // simple String comparison to find out, if a path is already in "ResultPath"
+ String[] PathList = JavaTools.ArrayoutofString(ResultPath, ";");
+ int MaxIndex = PathList.length - 1;
+ String CompCurPath;
+ // sAddPath.replace(null, (char) 47);
+ String CompAddPath = JavaTools.replaceSubString(sAddPath, "", "/");
+ String CurPath;
+ for (int i = 0; i <= MaxIndex; i++)
+ {
+ CurPath = JavaTools.convertfromURLNotation(PathList[i]);
+ CompCurPath = JavaTools.replaceSubString(CurPath, "", "/");
+ if (CompCurPath.equals(CompAddPath))
+ {
+ return;
+ }
+ }
+ ResultPath += ";" + sAddPath;
+ return;
+ }
+
+ public static String deleteLastSlashfromUrl(String _sPath)
+ {
+ if (_sPath.endsWith("/"))
+ {
+ return _sPath.substring(0, _sPath.length() - 1);
+ }
+ else
+ {
+ return _sPath;
+ }
+ }
+
+ /**
+ * Further information on arguments value see in OO Developer Guide,
+ * chapter 6.2.7
+ * @param xMSF
+ * @param sPath
+ * @param xSimpleFileAccess
+ * @return the respective path of the office application. A probable following "/" at the end is trimmed.
+ */
+ public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, XSimpleFileAccess xSimpleFileAccess)
+ {
+ try
+ {
+ String ResultPath = "";
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings");
+ ResultPath = com.sun.star.uno.AnyConverter.toString(Helper.getUnoPropertyValue(xInterface, sPath));
+ ResultPath = deleteLastSlashfromUrl(ResultPath);
+ return ResultPath;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return "";
+ }
+ }
+
+ /**
+ * Further information on arguments value see in OO Developer Guide,
+ * chapter 6.2.7
+ * @param xMSF
+ * @param sPath
+ * @param sType use "share" or "user". Set to "" if not needed eg for the WorkPath;
+ * In the return Officepath a possible slash at the end is cut off
+ * @param sSearchDir
+ * @return
+ * @throws NoValidPathException
+ */
+ public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, String sType, String sSearchDir) throws NoValidPathException
+ {
+ //This method currently only works with sPath="Template"
+
+ String ResultPath = "";
+
+ String Template_writable = "";
+ String[] Template_internal;
+ String[] Template_user;
+
+ boolean bexists = false;
+ try
+ {
+ XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings");
+ XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, xPathInterface);
+ String WritePath = "";
+ String[] ReadPaths = null;
+ XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+
+ Template_writable = (String) xPropertySet.getPropertyValue(sPath + "_writable");
+ Template_internal = (String[]) xPropertySet.getPropertyValue(sPath + "_internal");
+ Template_user = (String[]) xPropertySet.getPropertyValue(sPath + "_user");
+ int iNumEntries = Template_user.length + Template_internal.length + 1;
+ ReadPaths = new String[iNumEntries];
+ int t = 0;
+ for (int i = 0; i < Template_internal.length; i++)
+ {
+ ReadPaths[t] = Template_internal[i];
+ t++;
+ }
+ for (int i = 0; i < Template_user.length; i++)
+ {
+ ReadPaths[t] = Template_user[i];
+ t++;
+ }
+ ReadPaths[t] = Template_writable;
+ WritePath = Template_writable;
+
+ if (sType.equalsIgnoreCase("user"))
+ {
+ ResultPath = WritePath;
+ bexists = true;
+ }
+ else
+ {
+ //find right path using the search sub path
+ for (int i = 0; i < ReadPaths.length; i++)
+ {
+ String tmpPath = ReadPaths[i] + sSearchDir;
+ if (xSimpleFileAccess.exists(tmpPath))
+ {
+ ResultPath = ReadPaths[i];
+ bexists = true;
+ break;
+ }
+ }
+ }
+ ResultPath = deleteLastSlashfromUrl(ResultPath);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ ResultPath = "";
+ }
+ if (bexists == false)
+ {
+ throw new NoValidPathException(xMSF, "");
+ }
+ return ResultPath;
+ }
+
+ public static ArrayList<String> getOfficePaths(XMultiServiceFactory xMSF, String _sPath, String sType, String sSearchDir) throws NoValidPathException
+ {
+ //This method currently only works with sPath="Template"
+
+ // String ResultPath = "";
+ ArrayList<String> aPathList = new ArrayList<String>();
+ String Template_writable = "";
+ String[] Template_internal;
+ String[] Template_user;
+
+ // String [] ReadPaths = null;
+
+ // boolean bexists = false;
+ try
+ {
+ XInterface xPathInterface = (XInterface) xMSF.createInstance("com.sun.star.util.PathSettings");
+ XPropertySet xPropertySet = (XPropertySet) com.sun.star.uno.UnoRuntime.queryInterface(XPropertySet.class, xPathInterface);
+ // String WritePath = "";
+ // XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ // XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+
+ Template_writable = (String) xPropertySet.getPropertyValue(_sPath + "_writable");
+ Template_internal = (String[]) xPropertySet.getPropertyValue(_sPath + "_internal");
+ Template_user = (String[]) xPropertySet.getPropertyValue(_sPath + "_user");
+
+ // int iNumEntries = Template_user.length + Template_internal.length + 1;
+ for (int i = 0; i < Template_internal.length; i++)
+ {
+ String sPath = Template_internal[i];
+ if (sPath.startsWith("vnd."))
+ {
+ String sPathToExpand = sPath.substring("vnd.sun.star.Expand:".length());
+
+ XMacroExpander xExpander = Helper.getMacroExpander(xMSF);
+ sPath = xExpander.expandMacros(sPathToExpand);
+ }
+
+ // if there exists a language in the directory, we try to add the right language
+ sPath = checkIfLanguagePathExists(xMSF, sPath);
+
+ aPathList.add(sPath);
+ }
+ for (int i = 0; i < Template_user.length; i++)
+ {
+ aPathList.add(Template_user[i]);
+ }
+ aPathList.add(Template_writable);
+ // WritePath = Template_writable;
+
+// if (sType.equalsIgnoreCase("user"))
+// {
+// ResultPath = WritePath;
+// bexists = true;
+// }
+
+ // There was a bug here, because we have to search through the whole list of paths
+// else
+// {
+// //find right path using the search sub path
+// for (int i = 0; i<ReadPaths.length; i++)
+// {
+// String tmpPath = ReadPaths[i]+sSearchDir;
+// if (xSimpleFileAccess.exists(tmpPath))
+// {
+// ResultPath = ReadPaths[i];
+// bexists = true;
+// break;
+// }
+// }
+// }
+// ResultPath = deleteLastSlashfromUrl(ResultPath);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ // ResultPath = "";
+ }
+// if (bexists == false)
+// {
+// throw new NoValidPathException(xMSF, "");
+// }
+// return ResultPath;
+ return aPathList;
+ }
+
+ private static String checkIfLanguagePathExists(XMultiServiceFactory _xMSF, String _sPath)
+ {
+ try
+ {
+ Object defaults = _xMSF.createInstance("com.sun.star.text.Defaults");
+ Locale aLocale = (Locale) Helper.getUnoStructValue(defaults, "CharLocale");
+ if (aLocale == null)
+ {
+ java.util.Locale.getDefault();
+ aLocale = new com.sun.star.lang.Locale();
+ aLocale.Country = java.util.Locale.getDefault().getCountry();
+ aLocale.Language = java.util.Locale.getDefault().getLanguage();
+ aLocale.Variant = java.util.Locale.getDefault().getVariant();
+ }
+
+ String sLanguage = aLocale.Language;
+ String sCountry = aLocale.Country;
+ String sVariant = aLocale.Variant;
+
+ // de-DE-Bayrisch
+ StringBuffer aLocaleAll = new StringBuffer();
+ aLocaleAll.append(sLanguage).append('-').append(sCountry).append('-').append(sVariant);
+ String sPath = _sPath + "/" + aLocaleAll.toString();
+
+ XInterface xInterface = (XInterface) _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ return sPath;
+ }
+
+ // de-DE
+ StringBuffer aLocaleLang_Country = new StringBuffer();
+ aLocaleLang_Country.append(sLanguage).append('-').append(sCountry);
+ sPath = _sPath + "/" + aLocaleLang_Country.toString();
+
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ return sPath;
+ }
+
+ // de
+ StringBuffer aLocaleLang = new StringBuffer();
+ aLocaleLang.append(sLanguage);
+ sPath = _sPath + "/" + aLocaleLang.toString();
+
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ return sPath;
+ }
+
+ // the absolute default is en-US or en
+ sPath = _sPath + "/en-US";
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ return sPath;
+ }
+
+ sPath = _sPath + "/en";
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ return sPath;
+ }
+
+ // java.util.Locale jl = new java.util.Locale(
+ // l.Language , l.Country, l.Variant );
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ }
+
+ return _sPath;
+ }
+
+ /*
+ public static String getOfficePath(XMultiServiceFactory xMSF, String sPath, String sType) throws NoValidPathException {
+ String ResultPath = "";
+ Object oPathSettings;
+ int iPathCount;
+ String[] PathList;
+ boolean bexists = false;
+ try {
+ XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+ ResultPath = getOfficePath(xMSF, sPath, xSimpleFileAccess);
+ PathList = JavaTools.ArrayoutofString(ResultPath, ";");
+ if (!sType.equals("")) {
+ ResultPath = "";
+ String CurPath = "";
+ String EndString = "/" + sType;
+ int EndLength = EndString.length();
+ sType = "/" + sType + "/";
+ int MaxIndex = PathList.length - 1;
+ int iPos;
+ for (int i = 0; i <= MaxIndex; i++) {
+ CurPath = PathList[i];
+ iPos = CurPath.length() - EndLength;
+ if ((CurPath.indexOf(sType) > 0) || (CurPath.indexOf(EndString) == iPos)) {
+ ResultPath = deleteLastSlashfromUrl(CurPath);
+ if (xSimpleFileAccess.exists(ResultPath))
+ break;
+ }
+ }
+ } else
+ ResultPath = PathList[0];
+ if (ResultPath.equals("") == false)
+ bexists = xSimpleFileAccess.exists(ResultPath);
+ } catch (Exception exception) {
+ exception.printStackTrace(System.out);
+ ResultPath = "";
+ }
+ if (bexists == false)
+ throw new NoValidPathException(xMSF);
+ return ResultPath;
+ }
+ **/
+ public static void combinePaths(XMultiServiceFactory xMSF, ArrayList _aFirstPath, String _sSecondPath) throws NoValidPathException
+ {
+ for (int i = 0; i < _aFirstPath.size(); ++i)
+ {
+ String sOnePath = (String) _aFirstPath.get(i);
+ sOnePath = addPath(sOnePath, _sSecondPath);
+ if (isPathValid(xMSF, sOnePath))
+ {
+ _aFirstPath.add(i, sOnePath);
+ _aFirstPath.remove(i + 1);
+ }
+ else
+ {
+ _aFirstPath.remove(i);
+ --i;
+ }
+ }
+ }
+
+ public static boolean isPathValid(XMultiServiceFactory xMSF, String _sPath)
+ {
+ boolean bExists = false;
+ try
+ {
+ XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+ bExists = xSimpleFileAccess.exists(_sPath);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return bExists;
+ }
+
+ public static String combinePaths(XMultiServiceFactory xMSF, String _sFirstPath, String _sSecondPath) throws NoValidPathException
+ {
+ boolean bexists = false;
+ String ReturnPath = "";
+ try
+ {
+ XInterface xUcbInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+ ReturnPath = _sFirstPath + _sSecondPath;
+ bexists = xSimpleFileAccess.exists(ReturnPath);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return "";
+ }
+ if (bexists == false)
+ {
+ throw new NoValidPathException(xMSF, "");
+ }
+ return ReturnPath;
+ }
+
+ public static boolean createSubDirectory(XMultiServiceFactory xMSF, XSimpleFileAccess xSimpleFileAccess, String Path)
+ {
+ String sNoDirCreation = "";
+ try
+ {
+ Resource oResource = new Resource(xMSF, "ImportWizard", "imp");
+ if (oResource != null)
+ {
+ sNoDirCreation = oResource.getResText(1050);
+ String sMsgDirNotThere = oResource.getResText(1051);
+ String sQueryForNewCreation = oResource.getResText(1052);
+ String OSPath = JavaTools.convertfromURLNotation(Path);
+ String sQueryMessage = JavaTools.replaceSubString(sMsgDirNotThere, OSPath, "%1");
+ sQueryMessage = sQueryMessage + (char) 13 + sQueryForNewCreation;
+ int icreate = SystemDialog.showMessageBox(xMSF, "QueryBox", VclWindowPeerAttribute.YES_NO, sQueryMessage);
+ if (icreate == 2)
+ {
+ xSimpleFileAccess.createFolder(Path);
+ return true;
+ }
+ }
+ return false;
+ }
+ catch (com.sun.star.ucb.CommandAbortedException exception)
+ {
+ String sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1");
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgNoDir);
+ return false;
+ }
+ catch (com.sun.star.uno.Exception unoexception)
+ {
+ String sMsgNoDir = JavaTools.replaceSubString(sNoDirCreation, Path, "%1");
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgNoDir);
+ return false;
+ }
+ }
+
+ // checks if the root of a path exists. if the parameter xWindowPeer is not null then also the directory is
+ // created when it does not exists and the user
+ public static boolean PathisValid(XMultiServiceFactory xMSF, String Path, String sMsgFilePathInvalid, boolean baskbeforeOverwrite)
+ {
+ try
+ {
+ String SubDir;
+ String SubDirPath = "";
+ int SubLen;
+ int NewLen;
+ int RestLen;
+ boolean bexists;
+ boolean bSubDirexists = true;
+ String LowerCasePath;
+ String NewPath = Path;
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
+ if (baskbeforeOverwrite)
+ {
+ if (xSimpleFileAccess.exists(Path))
+ {
+ Resource oResource = new Resource(xMSF, "ImportWizard", "imp");
+ String sFileexists = oResource.getResText(1053);
+ String NewString = JavaTools.convertfromURLNotation(Path);
+ sFileexists = JavaTools.replaceSubString(sFileexists, NewString, "<1>");
+ sFileexists = JavaTools.replaceSubString(sFileexists, String.valueOf((char) 13), "<CR>");
+ int iLeave = SystemDialog.showMessageBox(xMSF, "QueryBox", VclWindowPeerAttribute.YES_NO, sFileexists);
+ if (iLeave == 3)
+ {
+ return false;
+ }
+ }
+ }
+ String[] DirArray = JavaTools.ArrayoutofString(Path, "/");
+ int MaxIndex = DirArray.length - 1;
+ if (MaxIndex > 0)
+ {
+ for (int i = MaxIndex; i >= 0; i--)
+ {
+ SubDir = DirArray[i];
+ SubLen = SubDir.length();
+ NewLen = NewPath.length();
+ RestLen = NewLen - SubLen;
+ if (RestLen > 0)
+ {
+ NewPath = NewPath.substring(0, NewLen - SubLen - 1);
+ if (i == MaxIndex)
+ {
+ SubDirPath = NewPath;
+ }
+ bexists = xSimpleFileAccess.exists(NewPath);
+ if (bexists)
+ {
+ LowerCasePath = NewPath.toLowerCase();
+ bexists = (((LowerCasePath.equals("file:///")) || (LowerCasePath.equals("file://")) || (LowerCasePath.equals("file:/")) || (LowerCasePath.equals("file:"))) == false);
+ }
+ if (bexists)
+ {
+ if (bSubDirexists == false)
+ {
+ boolean bSubDiriscreated = createSubDirectory(xMSF, xSimpleFileAccess, SubDirPath);
+ return bSubDiriscreated;
+ }
+ return true;
+ }
+ else
+ {
+ bSubDirexists = false;
+ }
+ }
+ }
+ }
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgFilePathInvalid);
+ return false;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMsgFilePathInvalid);
+ return false;
+ }
+ }
+
+ /**
+ * searches a directory for files which start with a certain
+ * prefix, and returns their URLs and document-titles.
+ * @param xMSF
+ * @param FilterName the prefix of the filename. a "-" is added to the prefix !
+ * @param FolderName the folder (URL) to look for files...
+ * @return an array with two array members. The first one, with document titles,
+ * the second with the corresponding URLs.
+ * @deprecated please use the getFolderTitles() with ArrayList
+ */
+ public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String FilterName, String FolderName)
+ {
+ String[][] LocLayoutFiles = new String[2][]; //{"",""}{""};
+ try
+ {
+ java.util.Vector<String> TitleVector = null;
+ java.util.Vector<String> NameVector = null;
+
+ XInterface xDocInterface = (XInterface) xMSF.createInstance("com.sun.star.document.DocumentProperties");
+ XDocumentProperties xDocProps = (XDocumentProperties) UnoRuntime.queryInterface(XDocumentProperties.class, xDocInterface);
+
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface);
+
+ String[] nameList = xSimpleFileAccess.getFolderContents(FolderName, false);
+
+ TitleVector = new java.util.Vector<String>(/*nameList.length*/);
+ NameVector = new java.util.Vector<String>(nameList.length);
+
+ FilterName = FilterName == null || FilterName.equals("") ? null : FilterName + "-";
+
+ String fileName = "";
+ PropertyValue[] noArgs = { };
+ for (int i = 0; i < nameList.length; i++)
+ {
+ fileName = getFilename(nameList[i]);
+
+ if (FilterName == null || fileName.startsWith(FilterName))
+ {
+ xDocProps.loadFromMedium(nameList[i], noArgs);
+ NameVector.addElement(nameList[i]);
+ TitleVector.addElement(xDocProps.getTitle());
+ }
+ }
+ String[] LocNameList = new String[NameVector.size()];
+ String[] LocTitleList = new String[TitleVector.size()];
+
+ NameVector.copyInto(LocNameList);
+ TitleVector.copyInto(LocTitleList);
+ LocLayoutFiles[1] = LocNameList;
+ LocLayoutFiles[0] = LocTitleList;
+
+ JavaTools.bubblesortList(LocLayoutFiles);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return LocLayoutFiles;
+ }
+
+ /**
+ * We search in all given path for a given file
+ * @param _sPath
+ * @param _sPath2
+ * @return
+ */
+ public static String addPath(String _sPath, String _sPath2)
+ {
+ String sNewPath;
+ if (!_sPath.endsWith("/"))
+ {
+ _sPath += "/";
+ }
+ if (_sPath2.startsWith("/"))
+ {
+ _sPath2 = _sPath2.substring(1);
+ }
+ sNewPath = _sPath + _sPath2;
+ return sNewPath;
+ }
+
+ public static String getPathFromList(XMultiServiceFactory xMSF, ArrayList _aList, String _sFile)
+ {
+ String sFoundFile = "";
+ try
+ {
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface);
+
+ for (int i = 0; i < _aList.size(); i++)
+ {
+ String sPath = (String) _aList.get(i);
+ sPath = addPath(sPath, _sFile);
+ if (xSimpleFileAccess.exists(sPath))
+ {
+ sFoundFile = sPath;
+ }
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ }
+ return sFoundFile;
+ }
+
+ /**
+ *
+ * @param xMSF
+ * @param _sStartFilterName
+ * @param FolderNames
+ * @return
+ * @throws com.sun.star.wizards.common.NoValidPathException
+ */
+ public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList FolderNames)
+ throws NoValidPathException
+ {
+ return getFolderTitles(xMSF, _sStartFilterName, FolderNames, "");
+ }
+
+ private static String getTitle(XMultiServiceFactory xMSF, String _sFile)
+ {
+ String sTitle = "";
+ try
+ {
+ XInterface xDocInterface = (XInterface) xMSF.createInstance("com.sun.star.document.DocumentProperties");
+ XDocumentProperties xDocProps = (XDocumentProperties) UnoRuntime.queryInterface(XDocumentProperties.class, xDocInterface);
+ PropertyValue[] noArgs = { };
+ xDocProps.loadFromMedium(_sFile, noArgs);
+ sTitle = xDocProps.getTitle();
+ }
+ catch (Exception e)
+ {
+ }
+ return sTitle;
+ }
+
+ public static String[][] getFolderTitles(com.sun.star.lang.XMultiServiceFactory xMSF, String _sStartFilterName, ArrayList FolderName, String _sEndFilterName)
+ throws NoValidPathException
+ {
+ String[][] LocLayoutFiles = new String[2][]; //{"",""}{""};
+ if (FolderName.size() == 0)
+ {
+ throw new NoValidPathException(null, "Path not given.");
+ }
+ ArrayList<String> TitleVector = new ArrayList<String>();
+ ArrayList<String> URLVector = new ArrayList<String>();
+
+ com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = null;
+ try
+ {
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ throw new NoValidPathException(null, "Internal error.");
+ }
+
+ for (int j = 0; j < FolderName.size(); j++)
+ {
+ String sFolderName = (String) FolderName.get(j);
+
+ try
+ {
+ String[] nameList = xSimpleFileAccess.getFolderContents(sFolderName, false);
+ _sStartFilterName = _sStartFilterName == null || _sStartFilterName.equals("") ? null : _sStartFilterName + "-";
+
+ String fileName = "";
+ for (int i = 0; i < nameList.length; i++)
+ {
+ fileName = getFilename(nameList[i]);
+ String sTitle;
+
+ if (_sStartFilterName == null || fileName.startsWith(_sStartFilterName))
+ {
+ if (_sEndFilterName.equals(""))
+ {
+ sTitle = getTitle(xMSF, nameList[i]);
+ }
+ else if (fileName.endsWith(_sEndFilterName))
+ {
+ fileName = fileName.replaceAll(_sEndFilterName + "$", "");
+ sTitle = fileName;
+ }
+ else
+ {
+ // no or wrong (start|end) filter
+ continue;
+ }
+ URLVector.add(nameList[i]);
+ TitleVector.add(sTitle);
+ }
+ }
+ }
+ catch (com.sun.star.ucb.CommandAbortedException exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ }
+ }
+
+ String[] LocNameList = new String[URLVector.size()];
+ String[] LocTitleList = new String[TitleVector.size()];
+
+ // LLA: we have to check if this works
+ URLVector.toArray(LocNameList);
+ TitleVector.toArray(LocTitleList);
+
+ LocLayoutFiles[1] = LocNameList;
+ LocLayoutFiles[0] = LocTitleList;
+
+ JavaTools.bubblesortList(LocLayoutFiles);
+
+ return LocLayoutFiles;
+ }
+ public XSimpleFileAccess2 fileAccess;
+ public XFileIdentifierConverter filenameConverter;
+
+ public FileAccess(XMultiServiceFactory xmsf) throws com.sun.star.uno.Exception
+ {
+ //get a simple file access...
+ Object fa = xmsf.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ fileAccess = (XSimpleFileAccess2) UnoRuntime.queryInterface(XSimpleFileAccess2.class, fa);
+ //get the file identifier converter
+ Object fcv = xmsf.createInstance("com.sun.star.ucb.FileContentProvider");
+ filenameConverter = (XFileIdentifierConverter) UnoRuntime.queryInterface(XFileIdentifierConverter.class, fcv);
+ }
+
+ public String getURL(String parentPath, String childPath)
+ {
+ String parent = filenameConverter.getSystemPathFromFileURL(parentPath);
+ File f = new File(parent, childPath);
+ String r = filenameConverter.getFileURLFromSystemPath(parentPath, f.getAbsolutePath());
+ return r;
+ }
+
+ public String getURL(String path)
+ {
+ File f = new File(path);
+ String r = filenameConverter.getFileURLFromSystemPath(
+ path, f.getAbsolutePath());
+ return r;
+ }
+
+ public String getPath(String parentURL, String childURL)
+ {
+ return filenameConverter.getSystemPathFromFileURL(parentURL + (((childURL == null || childURL.equals("")) ? "" : "/" + childURL)));
+ }
+
+ /**
+ * @author rpiterman
+ * @param filename
+ * @return the extension of the given filename.
+ */
+ public static String getExtension(String filename)
+ {
+ int p = filename.indexOf(".");
+ if (p == -1)
+ {
+ return "";
+ }
+ else
+ {
+ do
+ {
+ filename = filename.substring(p + 1);
+ }
+ while ((p = filename.indexOf(".")) > -1);
+ }
+ return filename;
+ }
+
+ /**
+ * @author rpiterman
+ * @param s
+ * @return
+ */
+ public boolean mkdir(String s)
+ {
+ try
+ {
+ fileAccess.createFolder(s);
+ return true;
+ }
+ catch (CommandAbortedException cax)
+ {
+ cax.printStackTrace();
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ return false;
+ }
+
+ /**
+ * @author rpiterman
+ * @param filename
+ * @param def what to return in case of an exception
+ * @return true if the given file exists or not.
+ * if an exception accures, returns the def value.
+ */
+ public boolean exists(String filename, boolean def)
+ {
+ try
+ {
+ return fileAccess.exists(filename);
+ }
+ catch (CommandAbortedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ }
+
+ return def;
+ }
+
+ /**
+ * @author rpiterman
+ * @param filename
+ * @return
+ */
+ public boolean isDirectory(String filename)
+ {
+ try
+ {
+ return fileAccess.isFolder(filename);
+ }
+ catch (CommandAbortedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ }
+
+ return false;
+ }
+
+ /**
+ * lists the files in a given directory
+ * @author rpiterman
+ * @param dir
+ * @param includeFolders
+ * @return
+ */
+ public String[] listFiles(String dir, boolean includeFolders)
+ {
+ try
+ {
+ return fileAccess.getFolderContents(dir, includeFolders);
+ }
+ catch (CommandAbortedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ }
+
+ return new String[0];
+ }
+
+ /**
+ * @author rpiterman
+ * @param file
+ * @return
+ */
+ public boolean delete(String file)
+ {
+ try
+ {
+ fileAccess.kill(file);
+ return true;
+ }
+ catch (CommandAbortedException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ return false;
+ }
+
+ /**
+ * @author rpiterman
+ * @param path
+ * @return
+ */
+ public static String getFilename(String path)
+ {
+ return getFilename(path, "/");
+ }
+
+ /**
+ * return the filename out of a system-dependent path
+ * @param path
+ * @return
+ */
+ public static String getPathFilename(String path)
+ {
+ return getFilename(path, File.separator);
+ }
+
+ /**
+ * @author rpiterman
+ * @param path
+ * @param pathSeparator
+ * @return
+ */
+ public static String getFilename(String path, String pathSeparator)
+ {
+ String[] s = JavaTools.ArrayoutofString(path, pathSeparator);
+ return s[s.length - 1];
+ }
+
+ public static String getBasename(String path, String pathSeparator)
+ {
+ String filename = getFilename(path, pathSeparator);
+ String sExtension = getExtension(filename);
+ String basename = filename.substring(0, filename.length() - (sExtension.length() + 1));
+ return basename;
+ }
+
+ /**
+ * @author rpiterman
+ * @param source
+ * @param target
+ * @return
+ */
+ public boolean copy(String source, String target)
+ {
+ try
+ {
+ fileAccess.copy(source, target);
+ return true;
+ }
+ catch (CommandAbortedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ }
+
+ return false;
+ }
+
+ public DateTime getLastModified(String url)
+ {
+ try
+ {
+ return fileAccess.getDateTimeModified(url);
+ }
+ catch (CommandAbortedException e)
+ {
+ }
+ catch (Exception e)
+ {
+ }
+ return null;
+ }
+
+ /**
+ *
+ * @param url
+ * @return the parent dir of the given url.
+ * if the path points to file, gives the directory in which the file is.
+ */
+ public static String getParentDir(String url)
+ {
+ if (url.endsWith("/"))
+ {
+ return getParentDir(url.substring(0, url.length() - 1));
+ }
+ int pos = -1;
+ int lastPos = 0;
+ while ((pos = url.indexOf("/", pos + 1)) > -1)
+ {
+ lastPos = pos;
+ }
+ return url.substring(0, lastPos);
+ }
+
+ public String createNewDir(String parentDir, String name)
+ {
+ String s = getNewFile(parentDir, name, "");
+ if (mkdir(s))
+ {
+ return s;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public String getNewFile(String parentDir, String name, String extension)
+ {
+
+ int i = 0;
+ String url;
+ do
+ {
+ String filename = filename(name, extension, i++);
+ String u = getURL(parentDir, filename);
+ url = u;
+ }
+ while (exists(url, true));
+
+ return url;
+ }
+
+ private static String filename(String name, String ext, int i)
+ {
+ return name + (i == 0 ? "" : String.valueOf(i)) + (ext.equals("") ? "" : "." + ext);
+ }
+
+ public int getSize(String url)
+ {
+ try
+ {
+ return fileAccess.getSize(url);
+ }
+ catch (Exception ex)
+ {
+ return -1;
+ }
+ }
+
+ public static String connectURLs(String urlFolder, String urlFilename)
+ {
+ return urlFolder + (urlFolder.endsWith("/") ? "" : "/") +
+ (urlFilename.startsWith("/") ? urlFilename.substring(1) : urlFilename);
+ }
+
+ public static String[] getDataFromTextFile(XMultiServiceFactory _xMSF, String _filepath)
+ {
+ String[] sFileData = null;
+ try
+ {
+ Vector<String> oDataVector = new Vector<String>();
+ Object oSimpleFileAccess = _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, oSimpleFileAccess);
+ if (xSimpleFileAccess.exists(_filepath))
+ {
+ XInputStream xInputStream = xSimpleFileAccess.openFileRead(_filepath);
+ Object oTextInputStream = _xMSF.createInstance("com.sun.star.io.TextInputStream");
+ XTextInputStream xTextInputStream = (XTextInputStream) UnoRuntime.queryInterface(XTextInputStream.class, oTextInputStream);
+ XActiveDataSink xActiveDataSink = (XActiveDataSink) UnoRuntime.queryInterface(XActiveDataSink.class, oTextInputStream);
+ xActiveDataSink.setInputStream(xInputStream);
+ while (!xTextInputStream.isEOF())
+ {
+ oDataVector.addElement( xTextInputStream.readLine());
+ }
+ xTextInputStream.closeInput();
+ sFileData = new String[oDataVector.size()];
+ oDataVector.toArray(sFileData);
+
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return sFileData;
+ }
+
+ /**
+ * shortens a filename to a user displayable representation.
+ * @param path
+ * @param maxLength
+ * @return
+ */
+ public static String getShortFilename(String path, int maxLength)
+ {
+ int firstPart = 0;
+
+ if (path.length() > maxLength)
+ {
+ if (path.startsWith("/"))
+ { // unix
+ int nextSlash = path.indexOf("/", 1) + 1;
+ firstPart = Math.min(nextSlash, (maxLength - 3) / 2);
+ }
+ else
+ { //windows
+ firstPart = Math.min(10, (maxLength - 3) / 2);
+ }
+
+ String s1 = path.substring(0, firstPart);
+ String s2 = path.substring(path.length() - (maxLength - (3 + firstPart)));
+
+ return s1 + "..." + s2;
+ }
+ else
+ {
+ return path;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/HelpIds.java b/wizards/com/sun/star/wizards/common/HelpIds.java
new file mode 100644
index 000000000000..ad8faa2b2d42
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/HelpIds.java
@@ -0,0 +1,1047 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+public class HelpIds
+{
+ private static String array1[] = new String[]
+ {
+ "HID:WIZARDS_HID0_WEBWIZARD", // HID:34200
+ "HID:WIZARDS_HID0_HELP", // HID:34201
+ "HID:WIZARDS_HID0_NEXT", // HID:34202
+ "HID:WIZARDS_HID0_PREV", // HID:34203
+ "HID:WIZARDS_HID0_CREATE", // HID:34204
+ "HID:WIZARDS_HID0_CANCEL", // HID:34205
+ "HID:WIZARDS_HID0_STATUS_DIALOG", // HID:34206
+ "HID:WIZARDS_HID1_LST_SESSIONS", // HID:34207
+ "",
+ "HID:WIZARDS_HID1_BTN_DEL_SES", // HID:34209
+ "HID:WIZARDS_HID2_LST_DOCS", // HID:34210
+ "HID:WIZARDS_HID2_BTN_ADD_DOC", // HID:34211
+ "HID:WIZARDS_HID2_BTN_REM_DOC", // HID:34212
+ "HID:WIZARDS_HID2_BTN_DOC_UP", // HID:34213
+ "HID:WIZARDS_HID2_BTN_DOC_DOWN", // HID:34214
+ "HID:WIZARDS_HID2_TXT_DOC_TITLE", // HID:34215
+ "HID:WIZARDS_HID2_TXT_DOC_DESC", // HID:34216
+ "HID:WIZARDS_HID2_TXT_DOC_AUTHOR", // HID:34217
+ "HID:WIZARDS_HID2_LST_DOC_EXPORT", // HID:34218
+ "HID:WIZARDS_HID2_STATUS_ADD_DOCS", // HID:34219
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG1", // HID:34220
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG2", // HID:34221
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG3", // HID:34222
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG4", // HID:34223
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG5", // HID:34224
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG6", // HID:34225
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG7", // HID:34226
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG8", // HID:34227
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG9", // HID:34228
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG10", // HID:34229
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG11", // HID:34230
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG12", // HID:34231
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG13", // HID:34232
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG14", // HID:34233
+ "HID:WIZARDS_HID3_IL_LAYOUTS_IMG15", // HID:34234
+ "HID:WIZARDS_HID4_CHK_DISPLAY_FILENAME", // HID:34235
+ "HID:WIZARDS_HID4_CHK_DISPLAY_DESCRIPTION", // HID:34236
+ "HID:WIZARDS_HID4_CHK_DISPLAY_AUTHOR", // HID:34237
+ "HID:WIZARDS_HID4_CHK_DISPLAY_CR_DATE", // HID:34238
+ "HID:WIZARDS_HID4_CHK_DISPLAY_UP_DATE", // HID:34239
+ "HID:WIZARDS_HID4_CHK_DISPLAY_FORMAT", // HID:34240
+ "HID:WIZARDS_HID4_CHK_DISPLAY_F_ICON", // HID:34241
+ "HID:WIZARDS_HID4_CHK_DISPLAY_PAGES", // HID:34242
+ "HID:WIZARDS_HID4_CHK_DISPLAY_SIZE", // HID:34243
+ "HID:WIZARDS_HID4_GRP_OPTIMAIZE_640", // HID:34244
+ "HID:WIZARDS_HID4_GRP_OPTIMAIZE_800", // HID:34245
+ "HID:WIZARDS_HID4_GRP_OPTIMAIZE_1024", // HID:34246
+ "HID:WIZARDS_HID5_LST_STYLES", // HID:34247
+ "HID:WIZARDS_HID5_BTN_BACKGND", // HID:34248
+ "HID:WIZARDS_HID5_BTN_ICONS", // HID:34249
+ "HID:WIZARDS_HID6_TXT_SITE_TITLE", // HID:34250
+ "",
+ "",
+ "HID:WIZARDS_HID6_TXT_SITE_DESC", // HID:34253
+ "",
+ "HID:WIZARDS_HID6_DATE_SITE_CREATED", // HID:34255
+ "HID:WIZARDS_HID6_DATE_SITE_UPDATED", // HID:34256
+ "",
+ "HID:WIZARDS_HID6_TXT_SITE_EMAIL", // HID:34258
+ "HID:WIZARDS_HID6_TXT_SITE_COPYRIGHT", // HID:34259
+ "HID:WIZARDS_HID7_BTN_PREVIEW", // HID:34260
+ "HID:WIZARDS_HID7_CHK_PUBLISH_LOCAL", // HID:34261
+ "HID:WIZARDS_HID7_TXT_LOCAL", // HID:34262
+ "HID:WIZARDS_HID7_BTN_LOCAL", // HID:34263
+ "HID:WIZARDS_HID7_CHK_PUBLISH_ZIP", // HID:34264
+ "HID:WIZARDS_HID7_TXT_ZIP", // HID:34265
+ "HID:WIZARDS_HID7_BTN_ZIP", // HID:34266
+ "HID:WIZARDS_HID7_CHK_PUBLISH_FTP", // HID:34267
+ "HID:WIZARDS_HID7_TXT_FTP", // HID:34268
+ "HID:WIZARDS_HID7_BTN_FTP", // HID:34269
+ "HID:WIZARDS_HID7_CHK_SAVE", // HID:34270
+ "HID:WIZARDS_HID7_TXT_SAVE", // HID:34271
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_BG", // HID:34290
+ "HID:WIZARDS_HID_BG_BTN_OTHER", // HID:34291
+ "HID:WIZARDS_HID_BG_BTN_NONE", // HID:34292
+ "HID:WIZARDS_HID_BG_BTN_OK", // HID:34293
+ "HID:WIZARDS_HID_BG_BTN_CANCEL", // HID:34294
+ "HID:WIZARDS_HID_BG_BTN_BACK", // HID:34295
+ "HID:WIZARDS_HID_BG_BTN_FW", // HID:34296
+ "HID:WIZARDS_HID_BG_BTN_IMG1", // HID:34297
+ "HID:WIZARDS_HID_BG_BTN_IMG2", // HID:34298
+ "HID:WIZARDS_HID_BG_BTN_IMG3", // HID:34299
+ "HID:WIZARDS_HID_BG_BTN_IMG4", // HID:34300
+ "HID:WIZARDS_HID_BG_BTN_IMG5", // HID:34301
+ "HID:WIZARDS_HID_BG_BTN_IMG6", // HID:34302
+ "HID:WIZARDS_HID_BG_BTN_IMG7", // HID:34303
+ "HID:WIZARDS_HID_BG_BTN_IMG8", // HID:34304
+ "HID:WIZARDS_HID_BG_BTN_IMG9", // HID:34305
+ "HID:WIZARDS_HID_BG_BTN_IMG10", // HID:34306
+ "HID:WIZARDS_HID_BG_BTN_IMG11", // HID:34307
+ "HID:WIZARDS_HID_BG_BTN_IMG12", // HID:34308
+ "HID:WIZARDS_HID_BG_BTN_IMG13", // HID:34309
+ "HID:WIZARDS_HID_BG_BTN_IMG14", // HID:34300
+ "HID:WIZARDS_HID_BG_BTN_IMG15", // HID:34311
+ "HID:WIZARDS_HID_BG_BTN_IMG16", // HID:34312
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_DIALOG", // HID:34320
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_0_CMDPREV", // HID:34322
+ "HID:WIZARDS_HID_DLGREPORT_0_CMDNEXT", // HID:34323
+ "HID:WIZARDS_HID_DLGREPORT_0_CMDFINISH", // HID:34324
+ "HID:WIZARDS_HID_DLGREPORT_0_CMDCANCEL", // HID:34325
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_1_LBTABLES", // HID:34330
+ "HID:WIZARDS_HID_DLGREPORT_1_FIELDSAVAILABLE", // HID:34331
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVESELECTED", // HID:34332
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEALL", // HID:34333
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVESELECTED", // HID:34334
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDREMOVEALL", // HID:34335
+ "HID:WIZARDS_HID_DLGREPORT_1_FIELDSSELECTED", // HID:34336
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEUP", // HID:34337
+ "HID:WIZARDS_HID_DLGREPORT_1_CMDMOVEDOWN", // HID:34338
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_2_GROUPING", // HID:34340
+ "HID:WIZARDS_HID_DLGREPORT_2_CMDGROUP", // HID:34341
+ "HID:WIZARDS_HID_DLGREPORT_2_CMDUNGROUP", // HID:34342
+ "HID:WIZARDS_HID_DLGREPORT_2_PREGROUPINGDEST", // HID:34343
+ "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEUPGROUP", // HID:34344
+ "HID:WIZARDS_HID_DLGREPORT_2_CMDMOVEDOWNGROUP", // HID:34345
+ "HID:WIZARDS_HID_DLGREPORT_3_SORT1", // HID:34346
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND1", // HID:34347
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND1", // HID:34348
+ "HID:WIZARDS_HID_DLGREPORT_3_SORT2", // HID:34349
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND2", // HID:34350
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND2", // HID:34351
+ "HID:WIZARDS_HID_DLGREPORT_3_SORT3", // HID:34352
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND3", // HID:34353
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND3", // HID:34354
+ "HID:WIZARDS_HID_DLGREPORT_3_SORT4", // HID:34355
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTASCEND4", // HID:34356
+ "HID:WIZARDS_HID_DLGREPORT_3_OPTDESCEND4", // HID:34357
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_4_TITLE", // HID:34362
+ "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", // HID:34363
+ "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", // HID:34364
+ "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", // HID:34365
+ "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", // HID:34366
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", // HID:34370
+ "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", // HID:34371
+ "HID:WIZARDS_HID_DLGREPORT_5_TXTTEMPLATEPATH", // HID:34372
+ "HID:WIZARDS_HID_DLGREPORT_5_CMDTEMPLATEPATH", // HID:34373
+ "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", // HID:34374
+ "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", // HID:34375
+ "HID:WIZARDS_HID_DLGREPORT_5_TXTDOCUMENTPATH", // HID:34376
+ "HID:WIZARDS_HID_DLGREPORT_5_CMDDOCUMENTPATH", // HID:34377
+ "HID:WIZARDS_HID_DLGREPORT_5_CHKLINKTODB", // HID:34378
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_1", // HID:34381
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_2", // HID:34382
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_3", // HID:34383
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_4", // HID:34384
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_5", // HID:34385
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_6", // HID:34386
+ "HID:WIZARDS_HID_DLGREPORT_6_TXTTITLE_7", // HID:34387
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_DIALOG", // HID:34400
+ "",
+ "HID:WIZARDS_HID_DLGFORM_CMDPREV", // HID:34402
+ "HID:WIZARDS_HID_DLGFORM_CMDNEXT", // HID:34403
+ "HID:WIZARDS_HID_DLGFORM_CMDFINISH", // HID:34404
+ "HID:WIZARDS_HID_DLGFORM_CMDCANCEL", // HID:34405
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_MASTER_LBTABLES", // HID:34411
+ "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSAVAILABLE", // HID:34412
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVESELECTED", // HID:34413
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEALL", // HID:34414
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVESELECTED", // HID:34415
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDREMOVEALL", // HID:34416
+ "HID:WIZARDS_HID_DLGFORM_MASTER_FIELDSSELECTED", // HID:34417
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEUP", // HID:34418
+ "HID:WIZARDS_HID_DLGFORM_MASTER_CMDMOVEDOWN", // HID:34419
+ "",
+ "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", // HID:34421
+ "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", // HID:34422
+ "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", // HID:34423
+ "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", // HID:34424
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_SUB_LBTABLES", // HID:34431
+ "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSAVAILABLE", // HID:34432
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVESELECTED", // HID:34433
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEALL", // HID:34434
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVESELECTED", // HID:34435
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDREMOVEALL", // HID:34436
+ "HID:WIZARDS_HID_DLGFORM_SUB_FIELDSSELECTED", // HID:34437
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEUP", // HID:34438
+ "HID:WIZARDS_HID_DLGFORM_SUB_CMDMOVEDOWN", // HID:34439
+ "",
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK1", // HID:34441
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK1", // HID:34442
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK2", // HID:34443
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK2", // HID:34444
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK3", // HID:34445
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK3", // HID:34446
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTSLAVELINK4", // HID:34447
+ "HID:WIZARDS_HID_DLGFORM_LINKER_LSTMASTERLINK4", // HID:34448
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", // HID:34451
+ "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", // HID:34452
+ "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED", // HID:34453
+ "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED", // HID:34454
+ "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE", // HID:34455
+ "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED", // HID:34456
+ "HID:WIZARDS_HID_DLGFORM_CMDLEFTLABELED2", // HID:34457
+ "HID:WIZARDS_HID_DLGFORM_CMDTOPLABELED2", // HID:34458
+ "HID:WIZARDS_HID_DLGFORM_CMDTABLESTYLE2", // HID:34459
+ "HID:WIZARDS_HID_DLGFORM_CMDTOPJUSTIFIED2", // HID:34460
+ "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", // HID:34461
+ "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", // HID:34462
+ "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", // HID:34463
+ "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", // HID:34464
+ "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", // HID:34465
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", // HID:34471
+ "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", // HID:34472
+ "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", // HID:34473
+ "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", // HID:34474
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGFORM_TXTPATH", // HID:34481
+ "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", // HID:34482
+ "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", // HID:34483
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGNEWSLTR_DIALOG", // HID:34500
+ "HID:WIZARDS_HID_DLGNEWSLTR_OPTSTANDARDLAYOUT", // HID:34501
+ "HID:WIZARDS_HID_DLGNEWSLTR_OPTPARTYLAYOUT", // HID:34502
+ "HID:WIZARDS_HID_DLGNEWSLTR_OPTBROCHURELAYOUT", // HID:34503
+ "HID:WIZARDS_HID_DLGNEWSLTR_OPTSINGLESIDED", // HID:34504
+ "HID:WIZARDS_HID_DLGNEWSLTR_OPTDOUBLESIDED", // HID:34505
+ "HID:WIZARDS_HID_DLGNEWSLTR_CMDGOON", // HID:34506
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SELLBUY", // HID:34520
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SELLBUY", // HID:34521
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTQUANTITY", // HID:34522
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTRATE", // HID:34523
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTDATE", // HID:34524
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTCOMMISSION", // HID:34525
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTFIX", // HID:34526
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTMINIMUM", // HID:34527
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SELLBUY", // HID:34528
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SELLBUY", // HID:34529
+ "HID:WIZARDS_HID_DLGDEPOT_1_LSTSELLSTOCKS", // HID:34530
+ "HID:WIZARDS_HID_DLGDEPOT_2_LSTBUYSTOCKS", // HID:34531
+ "HID:WIZARDS_HID_DLGDEPOT_DIALOG_SPLIT", // HID:34532
+ "HID:WIZARDS_HID_DLGDEPOT_0_LSTSTOCKNAMES", // HID:34533
+ "HID:WIZARDS_HID_DLGDEPOT_0_TXTSTOCKID_SPLIT", // HID:34534
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_SPLIT", // HID:34535
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_SPLIT", // HID:34536
+ "HID:WIZARDS_HID_DLGDEPOT_1_OPTPERSHARE", // HID:34537
+ "HID:WIZARDS_HID_DLGDEPOT_1_OPTTOTAL", // HID:34538
+ "HID:WIZARDS_HID_DLGDEPOT_1_TXTDIVIDEND", // HID:34539
+ "HID:WIZARDS_HID_DLGDEPOT_2_TXTOLDRATE", // HID:34540
+ "HID:WIZARDS_HID_DLGDEPOT_2_TXTNEWRATE", // HID:34541
+ "HID:WIZARDS_HID_DLGDEPOT_2_TXTDATE", // HID:34542
+ "HID:WIZARDS_HID_DLGDEPOT_3_TXTSTARTDATE", // HID:34543
+ "HID:WIZARDS_HID_DLGDEPOT_3_TXTENDDATE", // HID:34544
+ "HID:WIZARDS_HID_DLGDEPOT_3_OPTDAILY", // HID:34545
+ "HID:WIZARDS_HID_DLGDEPOT_3_OPTWEEKLY", // HID:34546
+ "HID:WIZARDS_HID_DLGDEPOT_DIALOG_HISTORY", // HID:34547
+ "HID:WIZARDS_HID_DLGDEPOT_LSTMARKETS", // HID:34548
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDCANCEL_HISTORY", // HID:34549
+ "HID:WIZARDS_HID_DLGDEPOT_0_CMDGOON_HISTORY", // HID:34550
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGIMPORT_DIALOG", // HID:34570
+ "HID:WIZARDS_HID_DLGIMPORT_0_CMDHELP", // HID:34571
+ "HID:WIZARDS_HID_DLGIMPORT_0_CMDCANCEL", // HID:34572
+ "HID:WIZARDS_HID_DLGIMPORT_0_CMDPREV", // HID:34573
+ "HID:WIZARDS_HID_DLGIMPORT_0_CMDNEXT", // HID:34574
+ "HID:WIZARDS_HID_DLGIMPORT_0_OPTSODOCUMENTS", // HID:34575
+ "HID:WIZARDS_HID_DLGIMPORT_0_OPTMSDOCUMENTS", // HID:34576
+ "HID:WIZARDS_HID_DLGIMPORT_0_CHKLOGFILE", // HID:34577
+ "HID:WIZARDS_HID_DLGIMPORT_2_CHKWORD", // HID:34578
+ "HID:WIZARDS_HID_DLGIMPORT_2_CHKEXCEL", // HID:34579
+ "HID:WIZARDS_HID_DLGIMPORT_2_CHKPOWERPOINT", // HID:34580
+ "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATE", // HID:34581
+ "HID:WIZARDS_HID_DLGIMPORT_2_CBTEMPLATERECURSE", // HID:34582
+ "HID:WIZARDS_HID_DLGIMPORT_2_LBTEMPLATEPATH", // HID:34583
+ "HID:WIZARDS_HID_DLGIMPORT_2_EDTEMPLATEPATH", // HID:34584
+ "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT", // HID:34585
+ "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENT", // HID:34586
+ "HID:WIZARDS_HID_DLGIMPORT_2_CBDOCUMENTRECURSE", // HID:34587
+ "HID:WIZARDS_HID_DLGIMPORT_2_LBDOCUMENTPATH", // HID:34588
+ "HID:WIZARDS_HID_DLGIMPORT_2_EDDOCUMENTPATH", // HID:34589
+ "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT", // HID:34590
+ "HID:WIZARDS_HID_DLGIMPORT_2_LBEXPORTDOCUMENTPATH", // HID:34591
+ "HID:WIZARDS_HID_DLGIMPORT_2_EDEXPORTDOCUMENTPATH", // HID:34592
+ "HID:WIZARDS_HID_DLGIMPORT_2_CMDEXPORTPATHSELECT", // HID:34593
+ "",
+ "HID:WIZARDS_HID_DLGIMPORT_3_TBSUMMARY", // HID:34595
+ "HID:WIZARDS_HID_DLGIMPORT_0_CHKWRITER", // HID:34596
+ "HID:WIZARDS_HID_DLGIMPORT_0_CHKCALC", // HID:34597
+ "HID:WIZARDS_HID_DLGIMPORT_0_CHKIMPRESS", // HID:34598
+ "HID:WIZARDS_HID_DLGIMPORT_0_CHKMATHGLOBAL", // HID:34599
+ "HID:WIZARDS_HID_DLGIMPORT_2_CMDTEMPLATEPATHSELECT2", // HID:34600
+ "HID:WIZARDS_HID_DLGIMPORT_2_CMDDOCUMENTPATHSELECT2", // HID:34601
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_DIALOG", // HID:34630
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_CANCEL", // HID:34631
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA1", // HID:34632
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONAGENDA2", // HID:34633
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_AGENDAOKAY", // HID:34634
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER1", // HID:34635
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_OPTIONLETTER2", // HID:34636
+ "HID:WIZARDS_HID_DLGCORRESPONDENCE_LETTEROKAY", // HID:34637
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGSTYLES_DIALOG", // HID:34650
+ "HID:WIZARDS_HID_DLGSTYLES_LISTBOX", // HID:34651
+ "HID:WIZARDS_HID_DLGSTYLES_CANCEL", // HID:34652
+ "HID:WIZARDS_HID_DLGSTYLES_OKAY", // HID:34653
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGCONVERT_DIALOG", // HID:34660
+ "HID:WIZARDS_HID_DLGCONVERT_CHECKBOX1", // HID:34661
+ "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON1", // HID:34662
+ "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON2", // HID:34663
+ "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON3", // HID:34664
+ "HID:WIZARDS_HID_DLGCONVERT_OPTIONBUTTON4", // HID:34665
+ "HID:WIZARDS_HID_DLGCONVERT_LISTBOX1", // HID:34666
+ "HID:WIZARDS_HID_DLGCONVERT_OBFILE", // HID:34667
+ "HID:WIZARDS_HID_DLGCONVERT_OBDIR", // HID:34668
+ "HID:WIZARDS_HID_DLGCONVERT_COMBOBOX1", // HID:34669
+ "HID:WIZARDS_HID_DLGCONVERT_TBSOURCE", // HID:34670
+ "HID:WIZARDS_HID_DLGCONVERT_CHECKRECURSIVE", // HID:34671
+ "HID:WIZARDS_HID_DLGCONVERT_TBTARGET", // HID:34672
+ "HID:WIZARDS_HID_DLGCONVERT_CBCANCEL", // HID:34673
+ "HID:WIZARDS_HID_DLGCONVERT_CBHELP", // HID:34674
+ "HID:WIZARDS_HID_DLGCONVERT_CBBACK", // HID:34675
+ "HID:WIZARDS_HID_DLGCONVERT_CBGOON", // HID:34676
+ "HID:WIZARDS_HID_DLGCONVERT_CBSOURCEOPEN", // HID:34677
+ "HID:WIZARDS_HID_DLGCONVERT_CBTARGETOPEN", // HID:34678
+ "HID:WIZARDS_HID_DLGCONVERT_CHKPROTECT", // HID:34679
+ "HID:WIZARDS_HID_DLGCONVERT_CHKTEXTDOCUMENTS", // HID:34680
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGPASSWORD_CMDGOON", // HID:34690
+ "HID:WIZARDS_HID_DLGPASSWORD_CMDCANCEL", // HID:34691
+ "HID:WIZARDS_HID_DLGPASSWORD_CMDHELP", // HID:34692
+ "HID:WIZARDS_HID_DLGPASSWORD_TXTPASSWORD", // HID:34693
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_DIALOG", // HID:34700
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_PREVIEW", // HID:34701
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPYEAR", // HID:34702
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_OPMONTH", // HID:34703
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDYEAR", // HID:34704
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_EDMONTH", // HID:34705
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINYEAR", // HID:34706
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_SPINMONTH", // HID:34707
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_1_CMBSTATE", // HID:34708
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_LBOWNDATA", // HID:34709
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDINSERT", // HID:34710
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CMDDELETE", // HID:34711
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENT", // HID:34712
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_CHKEVENT", // HID:34713
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTDAY", // HID:34714
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTDAY", // HID:34715
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTMONTH", // HID:34716
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTMONTH", // HID:34717
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_EDEVENTYEAR", // HID:34718
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_2_SPINEVENTYEAR", // HID:34719
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOWNDATA", // HID:34720
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDCANCEL", // HID:34721
+ "HID:WIZARDS_HID_DLGHOLIDAYCAL_0_CMDOK" // HID:34722
+ };
+ private static String array2[] = new String[]
+ {
+ "HID:WIZARDS_HID_LTRWIZ_OPTBUSINESSLETTER", // HID:40769
+ "HID:WIZARDS_HID_LTRWIZ_OPTPRIVOFFICIALLETTER", // HID:40770
+ "HID:WIZARDS_HID_LTRWIZ_OPTPRIVATELETTER", // HID:40771
+ "HID:WIZARDS_HID_LTRWIZ_LSTBUSINESSSTYLE", // HID:40772
+ "HID:WIZARDS_HID_LTRWIZ_CHKBUSINESSPAPER", // HID:40773
+ "HID:WIZARDS_HID_LTRWIZ_LSTPRIVOFFICIALSTYLE", // HID:40774
+ "HID:WIZARDS_HID_LTRWIZ_LSTPRIVATESTYLE", // HID:40775
+ "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYLOGO", // HID:40776
+ "HID:WIZARDS_HID_LTRWIZ_NUMLOGOHEIGHT", // HID:40777
+ "HID:WIZARDS_HID_LTRWIZ_NUMLOGOX", // HID:40778
+ "HID:WIZARDS_HID_LTRWIZ_NUMLOGOWIDTH", // HID:40779
+ "HID:WIZARDS_HID_LTRWIZ_NUMLOGOY", // HID:40780
+ "HID:WIZARDS_HID_LTRWIZ_CHKPAPERCOMPANYADDRESS", // HID:40781
+ "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSHEIGHT", // HID:40782
+ "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSX", // HID:40783
+ "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSWIDTH", // HID:40784
+ "HID:WIZARDS_HID_LTRWIZ_NUMADDRESSY", // HID:40785
+ "HID:WIZARDS_HID_LTRWIZ_CHKCOMPANYRECEIVER", // HID:40786
+ "HID:WIZARDS_HID_LTRWIZ_CHKPAPERFOOTER", // HID:40787
+ "HID:WIZARDS_HID_LTRWIZ_NUMFOOTERHEIGHT", // HID:40788
+ "HID:WIZARDS_HID_LTRWIZ_LSTLETTERNORM", // HID:40789
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSELOGO", // HID:40790
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSEADDRESSRECEIVER", // HID:40791
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSESIGNS", // HID:40792
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSESUBJECT", // HID:40793
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSESALUTATION", // HID:40794
+ "HID:WIZARDS_HID_LTRWIZ_LSTSALUTATION", // HID:40795
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSEBENDMARKS", // HID:40796
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSEGREETING", // HID:40797
+ "HID:WIZARDS_HID_LTRWIZ_LSTGREETING", // HID:40798
+ "HID:WIZARDS_HID_LTRWIZ_CHKUSEFOOTER", // HID:40799
+ "HID:WIZARDS_HID_LTRWIZ_OPTSENDERPLACEHOLDER", // HID:40800
+ "HID:WIZARDS_HID_LTRWIZ_OPTSENDERDEFINE", // HID:40801
+ "HID:WIZARDS_HID_LTRWIZ_TXTSENDERNAME", // HID:40802
+ "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTREET", // HID:40803
+ "HID:WIZARDS_HID_LTRWIZ_TXTSENDERPOSTCODE", // HID:40804
+ "HID:WIZARDS_HID_LTRWIZ_TXTSENDERSTATE_TEXT", // HID:40805
+ "HID:WIZARDS_HID_LTRWIZ_TXTSENDERCITY", // HID:40806
+ "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERPLACEHOLDER", // HID:40807
+ "HID:WIZARDS_HID_LTRWIZ_OPTRECEIVERDATABASE", // HID:40808
+ "HID:WIZARDS_HID_LTRWIZ_TXTFOOTER", // HID:40809
+ "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERNEXTPAGES", // HID:40810
+ "HID:WIZARDS_HID_LTRWIZ_CHKFOOTERPAGENUMBERS", // HID:40811
+ "HID:WIZARDS_HID_LTRWIZ_TXTTEMPLATENAME", // HID:40812
+ "HID:WIZARDS_HID_LTRWIZ_OPTCREATELETTER", // HID:40813
+ "HID:WIZARDS_HID_LTRWIZ_OPTMAKECHANGES", // HID:40814
+ "HID:WIZARDS_HID_LTRWIZ_TXTPATH", // HID:40815
+ "HID:WIZARDS_HID_LTRWIZ_CMDPATH", // HID:40816
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_LTRWIZARD", // HID:40820
+ "HID:WIZARDS_HID_LTRWIZARD_HELP", // HID:40821
+ "HID:WIZARDS_HID_LTRWIZARD_BACK", // HID:40822
+ "HID:WIZARDS_HID_LTRWIZARD_NEXT", // HID:40823
+ "HID:WIZARDS_HID_LTRWIZARD_CREATE", // HID:40824
+ "HID:WIZARDS_HID_LTRWIZARD_CANCEL", // HID:40825
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTTABLES", // HID:40850
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDS", // HID:40851
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVESELECTED", // HID:40852
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEALL", // HID:40853
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVESELECTED", // HID:40854
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDREMOVEALL", // HID:40855
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTSELFIELDS", // HID:40856
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEUP", // HID:40857
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDMOVEDOWN", // HID:40858
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_SORT1", // HID:40865
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND1", // HID:40866
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND1", // HID:40867
+ "HID:WIZARDS_HID_QUERYWIZARD_SORT2", // HID:40868
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND2", // HID:40869
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND2", // HID:40870
+ "HID:WIZARDS_HID_QUERYWIZARD_SORT3", // HID:40871
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND3", // HID:40872
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND3", // HID:40873
+ "HID:WIZARDS_HID_QUERYWIZARD_SORT4", // HID:40874
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTASCEND4", // HID:40875
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTDESCEND4", // HID:40876
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHALL", // HID:40878
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTMATCHANY", // HID:40879
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_1", // HID:40880
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_1", // HID:40881
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_1", // HID:40882
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_2", // HID:40883
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_2", // HID:40884
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_2", // HID:40885
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFIELDNAME_3", // HID:40886
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTOPERATOR_3", // HID:40887
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTVALUE_3", // HID:40888
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATEDETAILQUERY", // HID:40895
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTAGGREGATESUMMARYQUERY", // HID:40896
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_1", // HID:40897
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_1", // HID:40898
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_2", // HID:40899
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_2", // HID:40900
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_3", // HID:40901
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_3", // HID:40902
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_4", // HID:40903
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_4", // HID:40904
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFUNCTION_5", // HID:40905
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTAGGREGATEFIELDS_5", // HID:40906
+ "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEPLUS", // HID:40907
+ "HID:WIZARDS_HID_QUERYWIZARD_BTNAGGREGATEMINUS", // HID:40908
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDS", // HID:40915
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVESELECTED", // HID:40916
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERREMOVESELECTED", // HID:40917
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERSELFIELDS", // HID:40918
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEUP", // HID:40919
+ "HID:WIZARDS_HID_QUERYWIZARD_CMDFILTERMOVEDOWN", // HID:40920
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHALL", // HID:40923
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTGROUPMATCHANY", // HID:40924
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_1", // HID:40925
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_1", // HID:40926
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_1", // HID:40927
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_2", // HID:40928
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_2", // HID:40929
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_2", // HID:40930
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTERFIELDNAME_3", // HID:40931
+ "HID:WIZARDS_HID_QUERYWIZARD_LSTFILTEROPERATOR_3", // HID:40932
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTFILTERVALUE_3", // HID:40933
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_1", // HID:40940
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_2", // HID:40941
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_3", // HID:40942
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_4", // HID:40943
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_5", // HID:40944
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_6", // HID:40945
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTTITLE_7", // HID:40946
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTQUERYTITLE", // HID:40955
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTDISPLAYQUERY", // HID:40956
+ "HID:WIZARDS_HID_QUERYWIZARD_OPTMODIFYQUERY", // HID:40957
+ "HID:WIZARDS_HID_QUERYWIZARD_TXTSUMMARY", // HID:40958
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD", // HID:40970
+ "",
+ "HID:WIZARDS_HID_QUERYWIZARD_BACK", // HID:40972
+ "HID:WIZARDS_HID_QUERYWIZARD_NEXT", // HID:40973
+ "HID:WIZARDS_HID_QUERYWIZARD_CREATE", // HID:40974
+ "HID:WIZARDS_HID_QUERYWIZARD_CANCEL", // HID:40975
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_IS", // HID:41000
+ "",
+ "HID:WIZARDS_HID_IS_BTN_NONE", // HID:41002
+ "HID:WIZARDS_HID_IS_BTN_OK", // HID:41003
+ "HID:WIZARDS_HID_IS_BTN_CANCEL", // HID:41004
+ "HID:WIZARDS_HID_IS_BTN_IMG1", // HID:41005
+ "HID:WIZARDS_HID_IS_BTN_IMG2", // HID:41006
+ "HID:WIZARDS_HID_IS_BTN_IMG3", // HID:41007
+ "HID:WIZARDS_HID_IS_BTN_IMG4", // HID:41008
+ "HID:WIZARDS_HID_IS_BTN_IMG5", // HID:41009
+ "HID:WIZARDS_HID_IS_BTN_IMG6", // HID:41010
+ "HID:WIZARDS_HID_IS_BTN_IMG7", // HID:41011
+ "HID:WIZARDS_HID_IS_BTN_IMG8", // HID:41012
+ "HID:WIZARDS_HID_IS_BTN_IMG9", // HID:41013
+ "HID:WIZARDS_HID_IS_BTN_IMG10", // HID:41014
+ "HID:WIZARDS_HID_IS_BTN_IMG11", // HID:41015
+ "HID:WIZARDS_HID_IS_BTN_IMG12", // HID:41016
+ "HID:WIZARDS_HID_IS_BTN_IMG13", // HID:41017
+ "HID:WIZARDS_HID_IS_BTN_IMG14", // HID:41018
+ "HID:WIZARDS_HID_IS_BTN_IMG15", // HID:41019
+ "HID:WIZARDS_HID_IS_BTN_IMG16", // HID:41020
+ "HID:WIZARDS_HID_IS_BTN_IMG17", // HID:41021
+ "HID:WIZARDS_HID_IS_BTN_IMG18", // HID:41022
+ "HID:WIZARDS_HID_IS_BTN_IMG19", // HID:41023
+ "HID:WIZARDS_HID_IS_BTN_IMG20", // HID:41024
+ "HID:WIZARDS_HID_IS_BTN_IMG21", // HID:41025
+ "HID:WIZARDS_HID_IS_BTN_IMG22", // HID:41026
+ "HID:WIZARDS_HID_IS_BTN_IMG23", // HID:41027
+ "HID:WIZARDS_HID_IS_BTN_IMG24", // HID:41028
+ "HID:WIZARDS_HID_IS_BTN_IMG25", // HID:41029
+ "HID:WIZARDS_HID_IS_BTN_IMG26", // HID:41030
+ "HID:WIZARDS_HID_IS_BTN_IMG27", // HID:41031
+ "HID:WIZARDS_HID_IS_BTN_IMG28", // HID:41032
+ "HID:WIZARDS_HID_IS_BTN_IMG29", // HID:41033
+ "HID:WIZARDS_HID_IS_BTN_IMG30", // HID:41034
+ "HID:WIZARDS_HID_IS_BTN_IMG31", // HID:41035
+ "HID:WIZARDS_HID_IS_BTN_IMG32", // HID:41036
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_FTP", // HID:41040
+ "HID:WIZARDS_HID_FTP_SERVER", // HID:41041
+ "HID:WIZARDS_HID_FTP_USERNAME", // HID:41042
+ "HID:WIZARDS_HID_FTP_PASS", // HID:41043
+ "HID:WIZARDS_HID_FTP_TEST", // HID:41044
+ "HID:WIZARDS_HID_FTP_TXT_PATH", // HID:41045
+ "HID:WIZARDS_HID_FTP_BTN_PATH", // HID:41046
+ "HID:WIZARDS_HID_FTP_OK", // HID:41047
+ "HID:WIZARDS_HID_FTP_CANCEL", // HID:41048
+ "",
+ "",
+ "HID:WIZARDS_HID_AGWIZ", // HID:41051
+ "HID:WIZARDS_HID_AGWIZ_HELP", // HID:41052
+ "HID:WIZARDS_HID_AGWIZ_NEXT", // HID:41053
+ "HID:WIZARDS_HID_AGWIZ_PREV", // HID:41054
+ "HID:WIZARDS_HID_AGWIZ_CREATE", // HID:41055
+ "HID:WIZARDS_HID_AGWIZ_CANCEL", // HID:41056
+ "HID:WIZARDS_HID_AGWIZ_1_LIST_PAGEDESIGN", // HID:41057
+ "HID:WIZARDS_HID_AGWIZ_1_CHK_MINUTES", // HID:41058
+ "HID:WIZARDS_HID_AGWIZ_2_TXT_TIME", // HID:41059
+ "HID:WIZARDS_HID_AGWIZ_2_TXT_DATE", // HID:41060
+ "HID:WIZARDS_HID_AGWIZ_2_TXT_TITLE", // HID:41061
+ "HID:WIZARDS_HID_AGWIZ_2_TXT_LOCATION", // HID:41062
+ "HID:WIZARDS_HID_AGWIZ_3_CHK_MEETING_TYPE", // HID:41063
+ "HID:WIZARDS_HID_AGWIZ_3_CHK_READ", // HID:41064
+ "HID:WIZARDS_HID_AGWIZ_3_CHK_BRING", // HID:41065
+ "HID:WIZARDS_HID_AGWIZ_3_CHK_NOTES", // HID:41066
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_CALLED_BY", // HID:41067
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_FACILITATOR", // HID:41068
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_NOTETAKER", // HID:41069
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_TIMEKEEPER", // HID:41070
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_ATTENDEES", // HID:41071
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_OBSERVERS", // HID:41072
+ "HID:WIZARDS_HID_AGWIZ_4_CHK_RESOURCEPERSONS", // HID:41073
+ "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATENAME", // HID:41074
+ "HID:WIZARDS_HID_AGWIZ_6_TXT_TEMPLATEPATH", // HID:41075
+ "HID:WIZARDS_HID_AGWIZ_6_BTN_TEMPLATEPATH", // HID:41076
+ "HID:WIZARDS_HID_AGWIZ_6_OPT_CREATEAGENDA", // HID:41077
+ "HID:WIZARDS_HID_AGWIZ_6_OPT_MAKECHANGES", // HID:41078
+ "HID:WIZARDS_HID_AGWIZ_5_BTN_INSERT", // HID:41079
+ "HID:WIZARDS_HID_AGWIZ_5_BTN_REMOVE", // HID:41080
+ "HID:WIZARDS_HID_AGWIZ_5_BTN_UP", // HID:41081
+ "HID:WIZARDS_HID_AGWIZ_5_BTN_DOWN", // HID:41082
+ "HID:WIZARDS_HID_AGWIZ_5_SCROLL_BAR", // HID:41083
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_1", // HID:41084
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_1", // HID:41085
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_1", // HID:41086
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_2", // HID:41087
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_2", // HID:41088
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_2", // HID:41089
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_3", // HID:41090
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_3", // HID:41091
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_3", // HID:41092
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_4", // HID:41093
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_4", // HID:41094
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_4", // HID:41095
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_TOPIC_5", // HID:41096
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_RESPONSIBLE_5", // HID:41097
+ "HID:WIZARDS_HID_AGWIZ_5_TXT_MINUTES_5", // HID:41098
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_FAXWIZ_OPTBUSINESSFAX", // HID:41120
+ "HID:WIZARDS_HID_FAXWIZ_LSTBUSINESSSTYLE", // HID:41121
+ "HID:WIZARDS_HID_FAXWIZ_OPTPRIVATEFAX", // HID:41122
+ "HID:WIZARDS_HID_LSTPRIVATESTYLE", // HID:41123
+ "HID:WIZARDS_HID_IMAGECONTROL3", // HID:41124
+ "HID:WIZARDS_HID_CHKUSELOGO", // HID:41125
+ "HID:WIZARDS_HID_CHKUSEDATE", // HID:41126
+ "HID:WIZARDS_HID_CHKUSECOMMUNICATIONTYPE", // HID:41127
+ "HID:WIZARDS_HID_LSTCOMMUNICATIONTYPE", // HID:41128
+ "HID:WIZARDS_HID_CHKUSESUBJECT", // HID:41129
+ "HID:WIZARDS_HID_CHKUSESALUTATION", // HID:41130
+ "HID:WIZARDS_HID_LSTSALUTATION", // HID:41131
+ "HID:WIZARDS_HID_CHKUSEGREETING", // HID:41132
+ "HID:WIZARDS_HID_LSTGREETING", // HID:41133
+ "HID:WIZARDS_HID_CHKUSEFOOTER", // HID:41134
+ "HID:WIZARDS_HID_OPTSENDERPLACEHOLDER", // HID:41135
+ "HID:WIZARDS_HID_OPTSENDERDEFINE", // HID:41136
+ "HID:WIZARDS_HID_TXTSENDERNAME", // HID:41137
+ "HID:WIZARDS_HID_TXTSENDERSTREET", // HID:41138
+ "HID:WIZARDS_HID_TXTSENDERPOSTCODE", // HID:41139
+ "HID:WIZARDS_HID_TXTSENDERSTATE", // HID:41140
+ "HID:WIZARDS_HID_TXTSENDERCITY", // HID:41141
+ "HID:WIZARDS_HID_TXTSENDERFAX", // HID:41142
+ "HID:WIZARDS_HID_OPTRECEIVERPLACEHOLDER", // HID:41143
+ "HID:WIZARDS_HID_OPTRECEIVERDATABASE", // HID:41144
+ "HID:WIZARDS_HID_TXTFOOTER", // HID:41145
+ "HID:WIZARDS_HID_CHKFOOTERNEXTPAGES", // HID:41146
+ "HID:WIZARDS_HID_CHKFOOTERPAGENUMBERS", // HID:41147
+ "HID:WIZARDS_HID_TXTTEMPLATENAME", // HID:41148
+ "HID:WIZARDS_HID_FILETEMPLATEPATH", // HID:41149
+ "HID:WIZARDS_HID_OPTCREATEFAX", // HID:41150
+ "HID:WIZARDS_HID_OPTMAKECHANGES", // HID:41151
+ "HID:WIZARDS_HID_IMAGECONTROL2", // HID:41152
+ "HID:WIZARDS_HID_FAXWIZ_TXTPATH", // HID:41153
+ "HID:WIZARDS_HID_FAXWIZ_CMDPATH", // HID:41154
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_FAXWIZARD", // HID:41180
+ "HID:WIZARDS_HID_FAXWIZARD_HELP", // HID:41181
+ "HID:WIZARDS_HID_FAXWIZARD_BACK", // HID:41182
+ "HID:WIZARDS_HID_FAXWIZARD_NEXT", // HID:41183
+ "HID:WIZARDS_HID_FAXWIZARD_CREATE", // HID:41184
+ "HID:WIZARDS_HID_FAXWIZARD_CANCEL", // HID:41185
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGTABLE_DIALOG", // HID:41200
+ "",
+ "HID:WIZARDS_HID_DLGTABLE_CMDPREV", // HID:41202
+ "HID:WIZARDS_HID_DLGTABLE_CMDNEXT", // HID:41203
+ "HID:WIZARDS_HID_DLGTABLE_CMDFINISH", // HID:41204
+ "HID:WIZARDS_HID_DLGTABLE_CMDCANCEL", // HID:41205
+ "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", // HID:41206
+ "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", // HID:41207
+ "HID:WIZARDS_HID_DLGTABLE_LBTABLES", // HID:41208
+ "HID:WIZARDS_HID_DLGTABLE_FIELDSAVAILABLE", // HID:41209
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVESELECTED", // HID:41210
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEALL", // HID:41211
+ "HID:WIZARDS_HID_DLGTABLE_CMDREMOVESELECTED", // HID:41212
+ "HID:WIZARDS_HID_DLGTABLE_CMDREMOVEALL", // HID:41213
+ "HID:WIZARDS_HID_DLGTABLE_FIELDSSELECTED", // HID:41214
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP", // HID:41215
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN", // HID:41216
+ "",
+ "",
+ "",
+ "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", // HID:41220
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", // HID:41221
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", // HID:41222
+ "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", // HID:41223
+ "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", // HID:41224
+ "HID:WIZARDS_HID_DLGTABLE_COLNAME", // HID:41225
+ "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER", // HID:41226
+ "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", // HID:41227
+ "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", // HID:41228
+ "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", // HID:41229
+ "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", // HID:41230
+ "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME", // HID:41231
+ "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", // HID:41232
+ "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", // HID:41233
+ "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_AVAILABLE", // HID:41234
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVE_PK_SELECTED", // HID:41235
+ "HID:WIZARDS_HID_DLGTABLE_CMDREMOVE_PK_SELECTED", // HID:41236
+ "HID:WIZARDS_HID_DLGTABLE_FIELDS_PK_SELECTED", // HID:41237
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEUP_PK_SELECTED", // HID:41238
+ "HID:WIZARDS_HID_DLGTABLE_CMDMOVEDOWN_PK_SELECTED", // HID:41239
+ "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", // HID:41240
+ "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", // HID:41241
+ "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", // HID:41242
+ "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", // HID:41243
+ "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", // HID:41244
+ "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA" // HID:41245
+ };
+
+ public static String getHelpIdString( int nHelpId )
+ {
+ if ( nHelpId >= 34200 && nHelpId <= 34722 )
+ return array1[ nHelpId - 34200 ];
+ else if ( nHelpId >= 40769 && nHelpId <= 41245 )
+ return array2[ nHelpId - 40769 ];
+ else
+ return new String();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/Helper.java b/wizards/com/sun/star/wizards/common/Helper.java
new file mode 100644
index 000000000000..0df16b360de0
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Helper.java
@@ -0,0 +1,444 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.uno.XComponentContext;
+import com.sun.star.util.XMacroExpander;
+import java.util.Calendar;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+// import com.sun.star.i18n.NumberFormatIndex;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+// import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.XNumberFormatter;
+
+public class Helper
+{
+
+ /** Creates a new instance of Helper */
+ public Helper()
+ {
+ }
+
+ public static long convertUnoDatetoInteger(com.sun.star.util.Date DateValue)
+ {
+ java.util.Calendar oCal = java.util.Calendar.getInstance();
+ oCal.set(DateValue.Year, DateValue.Month, DateValue.Day);
+ java.util.Date dTime = oCal.getTime();
+ long lTime = dTime.getTime();
+ long lDate = lTime / (3600 * 24000);
+ return lDate;
+ }
+
+ public static void setUnoPropertyValue(Object oUnoObject, String PropertyName, Object PropertyValue)
+ {
+ try
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject);
+ if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName))
+ {
+ xPSet.setPropertyValue(PropertyName, PropertyValue);
+ }
+ else
+ {
+ Property[] selementnames = xPSet.getPropertySetInfo().getProperties();
+ throw new java.lang.IllegalArgumentException("No Such Property: '" + PropertyName + "'");
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public static Object getUnoObjectbyName(Object oUnoObject, String ElementName)
+ {
+ try
+ {
+ com.sun.star.container.XNameAccess xName = (com.sun.star.container.XNameAccess) UnoRuntime.queryInterface(com.sun.star.container.XNameAccess.class, oUnoObject);
+ if (xName.hasByName(ElementName) == true)
+ {
+ return xName.getByName(ElementName);
+ }
+ else
+ {
+ throw new RuntimeException();
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static Object getPropertyValue(PropertyValue[] CurPropertyValue, String PropertyName)
+ {
+ int MaxCount = CurPropertyValue.length;
+ for (int i = 0; i < MaxCount; i++)
+ {
+ if (CurPropertyValue[i] != null)
+ {
+ if (CurPropertyValue[i].Name.equals(PropertyName))
+ {
+ return CurPropertyValue[i].Value;
+ }
+ }
+ }
+ throw new RuntimeException();
+ }
+
+ public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName, java.lang.Class xClass)
+ {
+ try
+ {
+ if (oUnoObject != null)
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject);
+ Object oObject = xPSet.getPropertyValue(PropertyName);
+ if (AnyConverter.isVoid(oObject))
+ {
+ return null;
+ }
+ else
+ {
+ return com.sun.star.uno.AnyConverter.toObject(new com.sun.star.uno.Type(xClass), oObject);
+ }
+ }
+ return null;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static Object getPropertyValuefromAny(Object[] CurPropertyValue, String PropertyName)
+ {
+ if (CurPropertyValue != null)
+ {
+ int MaxCount = CurPropertyValue.length;
+ for (int i = 0; i < MaxCount; i++)
+ {
+ if (CurPropertyValue[i] != null)
+ {
+ PropertyValue aValue = (PropertyValue) CurPropertyValue[i];
+ if (aValue != null && aValue.Name.equals(PropertyName))
+ {
+ return aValue.Value;
+ }
+ }
+ }
+ }
+ // System.out.println("Property not found: " + PropertyName);
+ return null;
+ }
+
+ public static Object getPropertyValuefromAny(Object[] CurPropertyValue, String PropertyName, java.lang.Class xClass)
+ {
+ try
+ {
+ if (CurPropertyValue != null)
+ {
+ int MaxCount = CurPropertyValue.length;
+ for (int i = 0; i < MaxCount; i++)
+ {
+ if (CurPropertyValue[i] != null)
+ {
+ PropertyValue aValue = (PropertyValue) CurPropertyValue[i];
+ if (aValue != null && aValue.Name.equals(PropertyName))
+ {
+ return com.sun.star.uno.AnyConverter.toObject(new com.sun.star.uno.Type(xClass), aValue.Value);
+ }
+ }
+ }
+ }
+ // System.out.println("Property not found: " + PropertyName);
+ return null;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static Object getUnoPropertyValue(Object oUnoObject, String PropertyName)
+ {
+ try
+ {
+ if (oUnoObject != null)
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject);
+ // Property[] aProps = xPSet.getPropertySetInfo().getProperties();
+ Object oObject = xPSet.getPropertyValue(PropertyName);
+ return oObject;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static Object getUnoArrayPropertyValue(Object oUnoObject, String PropertyName)
+ {
+ try
+ {
+ if (oUnoObject != null)
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject);
+ Object oObject = xPSet.getPropertyValue(PropertyName);
+ if (AnyConverter.isArray(oObject))
+ {
+ return getArrayValue(oObject);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public static Object getUnoStructValue(Object oUnoObject, String PropertyName)
+ {
+ try
+ {
+ if (oUnoObject != null)
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oUnoObject);
+ if (xPSet.getPropertySetInfo().hasPropertyByName(PropertyName) == true)
+ {
+ Object oObject = xPSet.getPropertyValue(PropertyName);
+ return oObject;
+ }
+ }
+ return null;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static void setUnoPropertyValues(Object oUnoObject, String[] PropertyNames, Object[] PropertyValues)
+ {
+ try
+ {
+ com.sun.star.beans.XMultiPropertySet xMultiPSetLst = (com.sun.star.beans.XMultiPropertySet) UnoRuntime.queryInterface(com.sun.star.beans.XMultiPropertySet.class, oUnoObject);
+ if (xMultiPSetLst != null)
+ {
+ xMultiPSetLst.setPropertyValues(PropertyNames, PropertyValues);
+ }
+ else
+ {
+ for (int i = 0; i < PropertyNames.length; i++)
+ {
+ //System.out.println(PropertyNames[i] + "=" + PropertyValues[i]);
+ setUnoPropertyValue(oUnoObject, PropertyNames[i], PropertyValues[i]);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * @author bc93774
+ * checks if the value of an object that represents an array is null.
+ * check beforehand if the Object is really an array with "AnyConverter.IsArray(oObject)
+ * @param oValue the paramter that has to represent an object
+ * @return a null reference if the array is empty
+ */
+ public static Object getArrayValue(Object oValue)
+ {
+ try
+ {
+ Object oPropList = com.sun.star.uno.AnyConverter.toArray(oValue);
+ int nlen = java.lang.reflect.Array.getLength(oPropList);
+ if (nlen == 0)
+ {
+ return null;
+ }
+ else
+ {
+ return oPropList;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+ private static long DAY_IN_MILLIS = (24 * 60 * 60 * 1000);
+
+ public static class DateUtils
+ {
+
+ private long docNullTime;
+ private XNumberFormatter formatter;
+ private XNumberFormatsSupplier formatSupplier;
+ private Calendar calendar;
+
+ public DateUtils(XMultiServiceFactory xmsf, Object document) throws Exception
+ {
+ XMultiServiceFactory docMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, document);
+
+ Object defaults = docMSF.createInstance("com.sun.star.text.Defaults");
+ Locale l = (Locale) Helper.getUnoStructValue(defaults, "CharLocale");
+
+ java.util.Locale jl = new java.util.Locale(
+ l.Language, l.Country, l.Variant);
+
+ calendar = Calendar.getInstance(jl);
+
+ formatSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, document);
+
+ Object formatSettings = formatSupplier.getNumberFormatSettings();
+ com.sun.star.util.Date date = (com.sun.star.util.Date) Helper.getUnoPropertyValue(formatSettings, "NullDate");
+
+ calendar.set(date.Year, date.Month - 1, date.Day);
+ docNullTime = getTimeInMillis();
+
+ formatter = NumberFormatter.createNumberFormatter(xmsf, formatSupplier);
+ }
+
+ /**
+ * @param format a constant of the enumeration NumberFormatIndex
+ * @return
+ */
+ public int getFormat(short format)
+ {
+ return NumberFormatter.getNumberFormatterKey(formatSupplier, format);
+ }
+
+ public XNumberFormatter getFormatter()
+ {
+ return formatter;
+ }
+
+ private long getTimeInMillis()
+ {
+ java.util.Date dDate = calendar.getTime();
+ return dDate.getTime();
+ }
+
+ /**
+ * @param date a VCL date in form of 20041231
+ * @return a document relative date
+ */
+ public synchronized double getDocumentDateAsDouble(int date)
+ {
+ calendar.clear();
+ calendar.set(date / 10000,
+ (date % 10000) / 100 - 1,
+ date % 100);
+
+ long date1 = getTimeInMillis();
+ /*
+ * docNullTime and date1 are in millis, but
+ * I need a day...
+ */
+ double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1;
+
+ return daysDiff;
+ }
+
+ public double getDocumentDateAsDouble(DateTime date)
+ {
+ return getDocumentDateAsDouble(date.Year * 10000 + date.Month * 100 + date.Day);
+ }
+
+ public synchronized double getDocumentDateAsDouble(long javaTimeInMillis)
+ {
+ calendar.clear();
+ JavaTools.setTimeInMillis(calendar, javaTimeInMillis);
+
+ long date1 = getTimeInMillis();
+
+ /*
+ * docNullTime and date1 are in millis, but
+ * I need a day...
+ */
+ double daysDiff = (date1 - docNullTime) / DAY_IN_MILLIS + 1;
+
+ return daysDiff;
+
+ }
+
+ public String format(int formatIndex, int date)
+ {
+ return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(date));
+ }
+
+ public String format(int formatIndex, DateTime date)
+ {
+ return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(date));
+ }
+
+ public String format(int formatIndex, long javaTimeInMillis)
+ {
+ return formatter.convertNumberToString(formatIndex, getDocumentDateAsDouble(javaTimeInMillis));
+ }
+ }
+
+ public static XComponentContext getComponentContext(XMultiServiceFactory _xMSF)
+ {
+ // Get the path to the extension and try to add the path to the class loader
+ final XPropertySet xProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xMSF);
+ final PropertySetHelper aHelper = new PropertySetHelper(xProps);
+ final Object aDefaultContext = aHelper.getPropertyValueAsObject("DefaultContext");
+ final XComponentContext xComponentContext = (XComponentContext) UnoRuntime.queryInterface(XComponentContext.class, aDefaultContext);
+ return xComponentContext;
+ }
+
+ public static XMacroExpander getMacroExpander(XMultiServiceFactory _xMSF)
+ {
+ final XComponentContext xComponentContext = getComponentContext(_xMSF);
+ final Object aSingleton = xComponentContext.getValueByName("/singletons/com.sun.star.util.theMacroExpander");
+ XMacroExpander xExpander = (XMacroExpander) UnoRuntime.queryInterface(XMacroExpander.class, aSingleton);
+ // String[][] aStrListList = xProvider.getExtensionList();
+// final String sLocation = xProvider.getPackageLocation("com.sun.reportdesigner");
+ return xExpander;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/IRenderer.java b/wizards/com/sun/star/wizards/common/IRenderer.java
new file mode 100644
index 000000000000..1aa73eaa599b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/IRenderer.java
@@ -0,0 +1,40 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+/**
+ * A General interface which gives a string
+ * that represents the rendered argument object.
+ * Can be used to reference resources, internationalizartion
+ * a.s.o
+ */
+public interface IRenderer
+{
+
+ public String render(Object object);
+}
diff --git a/wizards/com/sun/star/wizards/common/Indexable.java b/wizards/com/sun/star/wizards/common/Indexable.java
new file mode 100644
index 000000000000..d95640f1ec70
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Indexable.java
@@ -0,0 +1,44 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Indexable.java
+ *
+ * Created on 16. September 2003, 11:38
+ */
+
+package com.sun.star.wizards.common;
+
+/**
+ *
+ * @author rpiterman
+ */
+public interface Indexable {
+
+ public int getIndex();
+
+}
diff --git a/wizards/com/sun/star/wizards/common/InvalidQueryException.java b/wizards/com/sun/star/wizards/common/InvalidQueryException.java
new file mode 100644
index 000000000000..325f6fdc3760
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/InvalidQueryException.java
@@ -0,0 +1,40 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class InvalidQueryException extends java.lang.Throwable
+{
+// TODO don't show messages in Excetions
+ public InvalidQueryException(XMultiServiceFactory xMSF, String sCommand)
+ {
+ final int RID_REPORT = 2400;
+ SystemDialog.showErrorBox(xMSF, "ReportWizard", "dbw", RID_REPORT + 65, "<STATEMENT>", sCommand); // Querycreationnotpossible
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/JavaTools.java b/wizards/com/sun/star/wizards/common/JavaTools.java
new file mode 100644
index 000000000000..836b2a7ea242
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/JavaTools.java
@@ -0,0 +1,785 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.util.DateTime;
+import com.sun.star.beans.PropertyValue;
+import java.util.*;
+import java.io.File;
+
+import com.sun.star.lib.util.UrlToFileMapper;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+/**
+ *
+ * @author bc93774
+ */
+public class JavaTools
+{
+
+ /** Creates a new instance of JavaTools */
+ public JavaTools()
+ {
+ }
+
+/*
+ public static void main(String args[])
+ {
+ String sPath = "";
+ DateTime oDateTime = null;
+ long n;
+ String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService"; //localhost ;Lo-1.Germany.sun.com; 10.16.65.155
+ try
+ {
+ XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr);
+ if (xLocMSF != null)
+ {
+ System.out.println("Connected to " + ConnectStr);
+ oDateTime = getDateTime(9500000);
+ sPath = convertfromURLNotation("file:///E:/trash/Web%20Wizard.xcu");
+ n = getMillis(oDateTime);
+ int a = 1;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+*/
+ public static String[] copyStringArray(String[] FirstArray)
+ {
+ if (FirstArray != null)
+ {
+ String[] SecondArray = new String[FirstArray.length];
+ for (int i = 0; i < FirstArray.length; i++)
+ {
+ SecondArray[i] = FirstArray[i];
+ }
+ return SecondArray;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public static Object[] initializeArray(Object[] olist, Object ovalue)
+ {
+ for (int i = 0; i < olist.length; i++)
+ {
+ olist[i] = ovalue;
+ }
+ return olist;
+ }
+
+ public static Object[][] initializeMultiDimArray(Object[][] olist, Object[] ovalue)
+ {
+ for (int i = 0; i < olist.length; i++)
+ {
+ olist[i] = ovalue;
+ }
+ return olist;
+ }
+
+ public static String[] ArrayOutOfMultiDimArray(String _sMultiDimArray[][], int _index)
+ {
+ String[] sRetArray = null;
+ if (_sMultiDimArray != null)
+ {
+ sRetArray = new String[_sMultiDimArray.length];
+ for (int i = 0; i < _sMultiDimArray.length; i++)
+ {
+ sRetArray[i] = _sMultiDimArray[i][_index];
+ }
+ }
+ return sRetArray;
+ }
+
+ public static int[] initializeintArray(int FieldCount, int nValue)
+ {
+ int[] LocintArray = new int[FieldCount];
+ for (int i = 0; i < LocintArray.length; i++)
+ {
+ LocintArray[i] = nValue;
+ }
+ return LocintArray;
+ }
+
+ /**converts a list of Integer values included in an Integer vector to a list of int values
+ *
+ *
+ * @param _aIntegerVector
+ * @return
+ */
+ public static int[] IntegerTointList(Vector<Integer> _aIntegerVector)
+ {
+ try
+ {
+ Integer[] nIntegerValues = new Integer[_aIntegerVector.size()];
+ int[] nintValues = new int[_aIntegerVector.size()];
+ _aIntegerVector.toArray(nIntegerValues);
+ for (int i = 0; i < nIntegerValues.length; i++)
+ {
+ nintValues[i] = nIntegerValues[i].intValue();
+ }
+ return nintValues;
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ /**converts a list of Boolean values included in a Boolean vector to a list of boolean values
+ *
+ *
+ * @param _aBooleanVector
+ * @return
+ */
+ public static boolean[] BooleanTobooleanList(Vector<Boolean> _aBooleanVector)
+ {
+ try
+ {
+ Boolean[] bBooleanValues = new Boolean[_aBooleanVector.size()];
+ boolean[] bbooleanValues = new boolean[_aBooleanVector.size()];
+ _aBooleanVector.toArray(bBooleanValues);
+ for (int i = 0; i < bBooleanValues.length; i++)
+ {
+ bbooleanValues[i] = bBooleanValues[i].booleanValue();
+ }
+ return bbooleanValues;
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static String[] multiDimListToArray(String[][] multidimlist)
+ {
+ String[] retlist = new String[]
+ {
+ };
+ retlist = new String[multidimlist.length];
+ for (int i = 0; i < multidimlist.length; i++)
+ {
+ retlist[i] = multidimlist[i][0];
+ }
+ return retlist;
+ }
+
+ public static String getlongestArrayItem(String[] StringArray)
+ {
+ String sLongestItem = "";
+ int FieldCount = StringArray.length;
+ int iOldLength = 0;
+ int iCurLength = 0;
+ for (int i = 0; i < FieldCount; i++)
+ {
+ iCurLength = StringArray[i].length();
+ if (iCurLength > iOldLength)
+ {
+ iOldLength = iCurLength;
+ sLongestItem = StringArray[i];
+ }
+ }
+ return sLongestItem;
+ }
+
+ public static String ArraytoString(String[] LocArray)
+ {
+ String ResultString = "";
+ int iLen = LocArray.length;
+ for (int i = 0; i < iLen; i++)
+ {
+ ResultString += LocArray[i];
+ if (i < iLen - 1)
+ {
+ ResultString += ";";
+ }
+ }
+ return ResultString;
+ }
+
+ /**
+ * @author bc93774
+ * @param SearchList
+ * @param SearchString
+ * @return the index of the field that contains the string 'SearchString' or '-1' if not it is
+ * not contained within the array
+ */
+ public static int FieldInList(String[] SearchList, String SearchString)
+ {
+ int FieldLen = SearchList.length;
+ int retvalue = -1;
+ for (int i = 0; i < FieldLen; i++)
+ {
+ if (SearchList[i].compareTo(SearchString) == 0)
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ return retvalue;
+ }
+
+ public static int FieldInList(String[] SearchList, String SearchString, int StartIndex)
+ {
+ int FieldLen = SearchList.length;
+ int retvalue = -1;
+ if (StartIndex < FieldLen)
+ {
+ for (int i = StartIndex; i < FieldLen; i++)
+ {
+ if (SearchList[i].compareTo(SearchString) == 0)
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ }
+ return retvalue;
+ }
+
+ public static int FieldInTable(String[][] SearchList, String SearchString)
+ {
+ int retvalue;
+ if (SearchList.length > 0)
+ {
+ int FieldLen = SearchList.length;
+ retvalue = -1;
+ for (int i = 0; i < FieldLen; i++)
+ {
+ if (SearchList[i][0] != null)
+ {
+ if (SearchList[i][0].compareTo(SearchString) == 0)
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ retvalue = -1;
+ }
+ return retvalue;
+ }
+
+ public static int FieldInIntTable(int[][] SearchList, int SearchValue)
+ {
+ int retvalue = -1;
+ for (int i = 0; i < SearchList.length; i++)
+ {
+ if (SearchList[i][0] == SearchValue)
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ return retvalue;
+ }
+
+ public static int FieldInIntTable(int[] SearchList, int SearchValue, int _startindex)
+ {
+ int retvalue = -1;
+ for (int i = _startindex; i < SearchList.length; i++)
+ {
+ if (SearchList[i] == SearchValue)
+ {
+ retvalue = i;
+ break;
+ }
+ }
+ return retvalue;
+ }
+
+ public static int FieldInIntTable(int[] SearchList, int SearchValue)
+ {
+ return FieldInIntTable(SearchList, SearchValue, 0);
+ }
+
+ public static int getArraylength(Object[] MyArray)
+ {
+ int FieldCount = 0;
+ if (MyArray != null)
+ {
+ FieldCount = MyArray.length;
+ }
+ return FieldCount;
+ }
+
+ /**
+ * @author bc93774
+ * This function bubble sorts an array of with 2 dimensions.
+ * The default sorting order is the first dimension
+ * Only if sort2ndValue is True the second dimension is the relevant for the sorting order
+ */
+ public static String[][] bubblesortList(String[][] SortList)
+ {
+ String DisplayDummy;
+ int SortCount = SortList[0].length;
+ int DimCount = SortList.length;
+ for (int s = 0; s < SortCount; s++)
+ {
+ for (int t = 0; t < SortCount - s - 1; t++)
+ {
+ if (SortList[0][t].compareTo(SortList[0][t + 1]) > 0)
+ {
+ for (int k = 0; k < DimCount; k++)
+ {
+ DisplayDummy = SortList[k][t];
+ SortList[k][t] = SortList[k][t + 1];
+ SortList[k][t + 1] = DisplayDummy;
+ }
+ }
+ }
+ }
+ return SortList;
+ }
+
+ /**
+ * @param MainString
+ * @param Token
+ * @return
+ */
+ public static String[] ArrayoutofString(String MainString, String Token)
+ {
+ String[] StringArray;
+ if (MainString.equals("") == false)
+ {
+ Vector StringVector = new Vector();
+ String LocString = null;
+ int iIndex;
+ do
+ {
+ iIndex = MainString.indexOf(Token);
+ if (iIndex < 0)
+ {
+ StringVector.addElement(MainString);
+ }
+ else
+ {
+ StringVector.addElement(MainString.substring(0, iIndex));
+ MainString = MainString.substring(iIndex + 1, MainString.length());
+ }
+ }
+ while (iIndex >= 0);
+ int FieldCount = StringVector.size();
+ StringArray = new String[FieldCount];
+ StringVector.copyInto(StringArray);
+ }
+ else
+ {
+ StringArray = new String[0];
+ }
+ return StringArray;
+ }
+
+ public static String replaceSubString(String MainString, String NewSubString, String OldSubString)
+ {
+ try
+ {
+ int NewIndex = 0;
+ int OldIndex = 0;
+ int NewSubLen = NewSubString.length();
+ int OldSubLen = OldSubString.length();
+ while (NewIndex != -1)
+ {
+ NewIndex = MainString.indexOf(OldSubString, OldIndex);
+ if (NewIndex != -1)
+ {
+ MainString = MainString.substring(0, NewIndex) + NewSubString + MainString.substring(NewIndex + OldSubLen);
+ OldIndex = NewIndex + NewSubLen;
+ }
+ }
+ return MainString;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static String getFilenameOutOfPath(String sPath)
+ {
+ String[] Hierarchy = ArrayoutofString(sPath, "/");
+ return Hierarchy[Hierarchy.length - 1];
+ }
+
+ public static String getFileDescription(String sPath)
+ {
+ String sFilename = getFilenameOutOfPath(sPath);
+ String[] FilenameList = ArrayoutofString(sFilename, ".");
+ String FileDescription = "";
+ for (int i = 0; i < FilenameList.length - 1; i++)
+ {
+ FileDescription += FilenameList[i];
+ }
+ return FileDescription;
+ }
+
+ public static String convertfromURLNotation(String _sURLPath)
+ {
+ String sPath = "";
+ try
+ {
+ URL oJavaURL = new URL(_sURLPath);
+ File oFile = UrlToFileMapper.mapUrlToFile(oJavaURL);
+ sPath = oFile.getAbsolutePath();
+ }
+ catch (MalformedURLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (IOException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return sPath;
+ }
+
+ public static DateTime getDateTime(long timeMillis)
+ {
+ java.util.Calendar cal = java.util.Calendar.getInstance();
+ setTimeInMillis(cal, timeMillis);
+ DateTime dt = new DateTime();
+ dt.Year = (short) cal.get(Calendar.YEAR);
+ dt.Day = (short) cal.get(Calendar.DAY_OF_MONTH);
+ dt.Month = (short) (cal.get(Calendar.MONTH) + 1);
+ dt.Hours = (short) cal.get(Calendar.HOUR);
+ dt.Minutes = (short) cal.get(Calendar.MINUTE);
+ dt.Seconds = (short) cal.get(Calendar.SECOND);
+ dt.HundredthSeconds = (short) cal.get(Calendar.MILLISECOND);
+ return dt;
+ }
+
+ public static long getTimeInMillis(Calendar _calendar)
+ {
+ java.util.Date dDate = _calendar.getTime();
+ return dDate.getTime();
+ }
+
+ public static void setTimeInMillis(Calendar _calendar, long _timemillis)
+ {
+ java.util.Date dDate = new java.util.Date();
+ dDate.setTime(_timemillis);
+ _calendar.setTime(dDate);
+ }
+
+ public static long getMillis(DateTime time)
+ {
+ java.util.Calendar cal = java.util.Calendar.getInstance();
+ cal.set(time.Year, time.Month, time.Day, time.Hours, time.Minutes, time.Seconds);
+ return getTimeInMillis(cal);
+ }
+
+ public static String[] removeOutdatedFields(String[] baselist, String[] _complist)
+ {
+ String[] retarray = new String[]
+ {
+ };
+ if ((baselist != null) && (_complist != null))
+ {
+ Vector retvector = new Vector();
+// String[] orderedcomplist = new String[_complist.length];
+// System.arraycopy(_complist, 0, orderedcomplist, 0, _complist.length);
+ for (int i = 0; i < baselist.length; i++)
+// if (Arrays.binarySearch(orderedcomplist, baselist[i]) != -1)
+ {
+ if (FieldInList(_complist, baselist[i]) > -1)
+ {
+ retvector.add(baselist[i]);
+ // else
+ // here you could call the method of a defined interface to notify the calling method
+ // }
+ }
+ }
+ retarray = new String[retvector.size()];
+ retvector.toArray(retarray);
+ }
+ return (retarray);
+ }
+
+ public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist, int _compindex)
+ {
+ String[][] retarray = new String[][] {};
+ if ((baselist != null) && (_complist != null))
+ {
+ if (baselist.length > 0)
+ {
+ Vector retvector = new Vector();
+ for (int i = 0; i < baselist.length; i++)
+ {
+ String sValue = baselist[i][_compindex];
+ if (FieldInList(_complist, sValue) != -1)
+ {
+ retvector.add(baselist[i]);
+ // else
+ // here you could call the method of a defined interface to notify the calling method
+ }
+ }
+ retarray = new String[retvector.size()][2];
+ retvector.toArray(retarray);
+ }
+ }
+ return (retarray);
+ }
+
+ public static String[][] removeOutdatedFields(String[][] baselist, String[] _complist)
+ {
+ return removeOutdatedFields(baselist, _complist, 0);
+ }
+
+ public static PropertyValue[][] removeOutdatedFields(PropertyValue[][] baselist, String[] _complist)
+ {
+ PropertyValue[][] retarray = new PropertyValue[][]
+ {
+ };
+ if ((baselist != null) && (_complist != null))
+ {
+ Vector firstdimvector = new Vector();
+ int b = 0;
+ for (int n = 0; n < baselist.length; n++)
+ {
+ Vector secdimvector = new Vector();
+ PropertyValue[] internalArray;
+ int a = 0;
+ for (int m = 0; m < baselist[n].length; m++)
+ {
+ if (FieldInList(_complist, baselist[n][m].Name) > -1)
+ {
+ secdimvector.add(baselist[n][m]);
+ a++;
+ }
+ }
+ if (a > 0)
+ {
+ internalArray = new PropertyValue[a];
+ secdimvector.toArray(internalArray);
+ firstdimvector.add(internalArray);
+ b++;
+ }
+ }
+ retarray = new PropertyValue[b][];
+ firstdimvector.toArray(retarray);
+ }
+ return (retarray);
+ }
+
+ /**
+ * searches a multidimensional array for duplicate fields. According to the following example
+ * SlaveFieldName1 ;SlaveFieldName2; SlaveFieldName3
+ * MasterFieldName1;MasterFieldName2;MasterFieldName3
+ * The entries SlaveFieldNameX and MasterFieldNameX are grouped together and then the created groups are compared
+ * If a group is duplicate the entry of the second group is returned.
+ * @param _scomplist
+ * @return
+ */
+ public static int getDuplicateFieldIndex(String[][] _scomplist)
+ {
+ int retvalue = -1;
+ if (_scomplist.length > 0)
+ {
+ int fieldcount = _scomplist[0].length;
+ String[] sDescList = new String[fieldcount];
+ for (int m = 0; m < fieldcount; m++)
+ {
+ for (int n = 0; n < _scomplist.length; n++)
+ {
+ if (n == 0)
+ {
+ sDescList[m] = new String();
+ }
+ sDescList[m] += _scomplist[n][m];
+ }
+ }
+ return getDuplicateFieldIndex(sDescList);
+ }
+ return retvalue;
+ }
+
+ /**
+ * not tested!!!!!
+ * @param scomplist
+ * @return
+ */
+ public static int getDuplicateFieldIndex(String[] scomplist)
+ {
+ for (int n = 0; n < scomplist.length; n++)
+ {
+ String scurvalue = scomplist[n];
+ for (int m = n; m < scomplist.length; m++)
+ {
+ if (m != n)
+ {
+ if (scurvalue.equals(scomplist[m]))
+ {
+ return m;
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ public static int getDuplicateFieldIndex(String[] _scomplist, String _fieldname)
+ {
+ int iduplicate = 0;
+ for (int n = 0; n < _scomplist.length; n++)
+ {
+ if (_scomplist[n].equals(_fieldname))
+ {
+ iduplicate++;
+ if (iduplicate == 2)
+ {
+ return n;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public static boolean isEqual(PropertyValue firstPropValue, PropertyValue secPropValue)
+ {
+ if (!firstPropValue.Name.equals(secPropValue.Name))
+ {
+ return false;
+ //TODO replace 'equals' with AnyConverter.getType(firstpropValue).equals(secPropValue) to check content and Type
+ }
+ if (!firstPropValue.Value.equals(secPropValue.Value))
+ {
+ return false;
+ }
+ return (firstPropValue.Handle == secPropValue.Handle);
+ }
+
+ public static int[] getDuplicateFieldIndex(PropertyValue[][] ocomplist)
+ {
+ for (int n = 0; n < ocomplist.length; n++)
+ {
+ PropertyValue[] ocurValue = ocomplist[n];
+ for (int m = n; m < ocurValue.length; m++)
+ {
+ PropertyValue odetValue = ocurValue[m];
+ for (int s = 0; s < ocurValue.length; s++)
+ {
+ if (s != m)
+ {
+ if (isEqual(odetValue, ocurValue[s]))
+ {
+ return new int[]
+ {
+ n, s
+ };
+ }
+ }
+ }
+ }
+ }
+ return new int[]
+ {
+ -1, -1
+ };
+ }
+
+ public static String getSuffixNumber(String _sbasestring)
+ {
+ int suffixcharcount = 0;
+ for (int i = _sbasestring.length() - 1; i >= 0; i--)
+ {
+ char b = _sbasestring.charAt(i);
+ if ((b >= '0') && (b <= '9'))
+ {
+ suffixcharcount++;
+ }
+ else
+ {
+ break;
+ }
+ }
+ int istart = _sbasestring.length() - suffixcharcount;
+ return _sbasestring.substring(istart, _sbasestring.length());
+ }
+
+ public static String[] removefromList(String[] _sbaselist, String[] _sdellist)
+ {
+ Vector tempbaselist = new Vector();
+ for (int i = 0; i < _sbaselist.length; i++)
+ {
+ if (FieldInList(_sdellist, _sbaselist[i]) == -1)
+ {
+ tempbaselist.add(_sbaselist[i]);
+ }
+ }
+ String[] sretlist = new String[tempbaselist.size()];
+ tempbaselist.toArray(sretlist);
+ return sretlist;
+ }
+
+ /**
+ * compares two strings. If one of them is empty and the other one is null it also returns true
+ * @param sFirstString
+ * @param sSecondString
+ * @return
+ */
+ public static boolean isSame(String sFirstString, String sSecondString)
+ {
+ boolean bissame = false;
+ if (sFirstString == null)
+ {
+ if (sSecondString != null)
+ {
+ bissame = sSecondString.equals("");
+ }
+ else
+ {
+ bissame = (sSecondString == null);
+ }
+ }
+ else
+ {
+ if (sFirstString.equals(""))
+ {
+ bissame = (sSecondString == null);
+ }
+ else if (sSecondString != null)
+ {
+ bissame = sFirstString.equals(sSecondString);
+ }
+ }
+ return bissame;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/MANIFEST.MF b/wizards/com/sun/star/wizards/common/MANIFEST.MF
new file mode 100644
index 000000000000..a670e80c31e7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/MANIFEST.MF
@@ -0,0 +1 @@
+Class-Path: saxon9.jar
diff --git a/wizards/com/sun/star/wizards/common/NamedValueCollection.java b/wizards/com/sun/star/wizards/common/NamedValueCollection.java
new file mode 100644
index 000000000000..f8f2cd05224a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/NamedValueCollection.java
@@ -0,0 +1,90 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.sun.star.wizards.common;
+
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+
+/**
+ *
+ * @author frank.schoenheit@sun.com
+ */
+public class NamedValueCollection
+{
+ final private HashMap< String, Object > m_values = new HashMap< String, Object >();
+
+ public NamedValueCollection()
+ {
+ }
+
+ public NamedValueCollection( final PropertyValue[] i_values )
+ {
+ for ( int i = 0; i < i_values.length; ++i )
+ m_values.put( i_values[i].Name, i_values[i].Value );
+ }
+
+ public final void put( final String i_name, final Object i_value )
+ {
+ m_values.put( i_name, i_value );
+ }
+
+ @SuppressWarnings("unchecked")
+ public final < T extends Object > T getOrDefault( final String i_key, final T i_default )
+ {
+ if ( m_values.containsKey( i_key ) )
+ {
+ final Object value = m_values.get( i_key );
+ try
+ {
+ return (T)value;
+ }
+ catch ( ClassCastException e ) { }
+ }
+ return i_default;
+ }
+
+ @SuppressWarnings("unchecked")
+ public final < T extends XInterface > T queryOrDefault( final String i_key, final T i_default, Class i_interfaceClass )
+ {
+ if ( m_values.containsKey( i_key ) )
+ {
+ final Object value = m_values.get( i_key );
+ return (T)UnoRuntime.queryInterface( i_interfaceClass, value );
+ }
+ return i_default;
+ }
+
+ public final boolean has( final String i_key )
+ {
+ return m_values.containsKey( i_key );
+ }
+
+ public final PropertyValue[] getPropertyValues()
+ {
+ PropertyValue[] values = new PropertyValue[ m_values.size() ];
+
+ Iterator< Entry< String, Object > > iter = m_values.entrySet().iterator();
+ int i = 0;
+ while ( iter.hasNext() )
+ {
+ Entry< String, Object > entry = iter.next();
+ values[i++] = new PropertyValue(
+ entry.getKey(),
+ 0,
+ entry.getValue(),
+ PropertyState.DIRECT_VALUE
+ );
+ }
+
+ return values;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/NoValidPathException.java b/wizards/com/sun/star/wizards/common/NoValidPathException.java
new file mode 100644
index 000000000000..f4975d2fff0c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/NoValidPathException.java
@@ -0,0 +1,44 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.common;
+
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class NoValidPathException extends Exception
+{
+ public NoValidPathException(XMultiServiceFactory xMSF, String _sText)
+ {
+ super(_sText);
+ // TODO: NEVER open a dialog in an exception
+ if (xMSF != null)
+ {
+ SystemDialog.showErrorBox(xMSF, "dbwizres", "dbw", 521); // OfficePathnotavailable
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/NumberFormatter.java b/wizards/com/sun/star/wizards/common/NumberFormatter.java
new file mode 100644
index 000000000000..ccfbee303f98
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/NumberFormatter.java
@@ -0,0 +1,333 @@
+/*************************************************************************
+*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.common;
+
+import java.util.Date;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.NumberFormat;
+import com.sun.star.util.XNumberFormatTypes;
+import com.sun.star.util.XNumberFormats;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.XNumberFormatter;
+
+
+public class NumberFormatter
+{
+
+ public int iDateFormatKey = -1;
+ public int iDateTimeFormatKey = -1;
+ public int iNumberFormatKey = -1;
+ public int iTextFormatKey = -1;
+ public int iTimeFormatKey = -1;
+ public int iLogicalFormatKey = -1;
+ public long lDateCorrection;
+ public XNumberFormatter xNumberFormatter;
+ public XNumberFormats xNumberFormats;
+ public XNumberFormatTypes xNumberFormatTypes;
+ public XPropertySet xNumberFormatSettings;
+ private boolean bNullDateCorrectionIsDefined = false;
+ private Locale aLocale;
+
+
+ public NumberFormatter(XMultiServiceFactory _xMSF, XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception
+ {
+ aLocale = _aLocale;
+ Object oNumberFormatter = _xMSF.createInstance("com.sun.star.util.NumberFormatter");
+ xNumberFormats = _xNumberFormatsSupplier.getNumberFormats();
+ xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings();
+ xNumberFormatter = (XNumberFormatter) UnoRuntime.queryInterface(XNumberFormatter.class, oNumberFormatter);
+ xNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier);
+ xNumberFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
+
+ }
+
+ public NumberFormatter(XNumberFormatsSupplier _xNumberFormatsSupplier, Locale _aLocale) throws Exception
+ {
+ aLocale = _aLocale;
+ xNumberFormats = _xNumberFormatsSupplier.getNumberFormats();
+ xNumberFormatSettings = _xNumberFormatsSupplier.getNumberFormatSettings();
+ xNumberFormatTypes = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xNumberFormats);
+ }
+
+
+ /**
+ * @param _xMSF
+ * @param _xNumberFormatsSupplier
+ * @return
+ * @throws Exception
+ * @deprecated
+ *
+ */
+ public static XNumberFormatter createNumberFormatter(XMultiServiceFactory _xMSF, XNumberFormatsSupplier _xNumberFormatsSupplier) throws Exception
+ {
+ Object oNumberFormatter = _xMSF.createInstance("com.sun.star.util.NumberFormatter");
+ XNumberFormatter xNumberFormatter = (XNumberFormatter) UnoRuntime.queryInterface(XNumberFormatter.class, oNumberFormatter);
+ xNumberFormatter.attachNumberFormatsSupplier(_xNumberFormatsSupplier);
+ return xNumberFormatter;
+ }
+
+
+ /**
+ * gives a key to pass to a NumberFormat object. <br/>
+ * example: <br/>
+ * <pre>
+ * XNumberFormatsSupplier nsf = (XNumberFormatsSupplier)UnoRuntime.queryInterface(...,document);
+ * int key = Desktop.getNumberFormatterKey( nsf, ...star.i18n.NumberFormatIndex.DATE...);
+ * XNumberFormatter nf = Desktop.createNumberFormatter(xmsf, nsf);
+ * nf.convertNumberToString( key, 1972 );
+ * </pre>
+ * @param numberFormatsSupplier
+ * @param type - a constant out of i18n.NumberFormatIndex enumeration.
+ * @return a key to use with a util.NumberFormat instance.
+ *
+ */
+ public static int getNumberFormatterKey( Object numberFormatsSupplier, short type)
+ {
+ Object numberFormatTypes = ((XNumberFormatsSupplier)UnoRuntime.queryInterface(XNumberFormatsSupplier.class,numberFormatsSupplier)).getNumberFormats();
+ Locale l = new Locale();
+ return ((XNumberFormatTypes)UnoRuntime.queryInterface(XNumberFormatTypes.class,numberFormatTypes)).getFormatIndex(type, l);
+ }
+
+
+ public String convertNumberToString(int _nkey, double _dblValue)
+ {
+ return xNumberFormatter.convertNumberToString(_nkey, _dblValue);
+ }
+
+
+ public static String convertNumberToString(XNumberFormatter _xNumberFormatter, int _nkey, double _dblValue)
+ {
+ return _xNumberFormatter.convertNumberToString(_nkey, _dblValue);
+ }
+
+
+ public double convertStringToNumber(int _nkey, String _sString)throws Exception
+ {
+ return xNumberFormatter.convertStringToNumber(_nkey, _sString);
+ }
+
+
+ /**
+ * @param dateCorrection The lDateCorrection to set.
+ */
+ public void setNullDateCorrection(long dateCorrection)
+ {
+ lDateCorrection = dateCorrection;
+ }
+
+
+ public int defineNumberFormat(String _FormatString)
+ {
+ try
+ {
+ int NewFormatKey = xNumberFormats.queryKey(_FormatString, aLocale, true);
+ if (NewFormatKey == -1)
+ {
+ NewFormatKey = xNumberFormats.addNew(_FormatString, aLocale);
+ }
+ return NewFormatKey;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+
+ /**
+ * returns a numberformat for a FormatString.
+ * @param _FormatString
+ * @param _aLocale
+ * @return
+ */
+ public int defineNumberFormat(String _FormatString, Locale _aLocale)
+ {
+ try
+ {
+ int NewFormatKey = xNumberFormats.queryKey(_FormatString, _aLocale, true);
+ if (NewFormatKey == -1)
+ {
+ NewFormatKey = xNumberFormats.addNew(_FormatString, _aLocale);
+ }
+ return NewFormatKey;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+
+
+ public void setNumberFormat(XInterface _xFormatObject, int _FormatKey, NumberFormatter _oNumberFormatter)
+ {
+ try
+ {
+ XPropertySet xNumberFormat = _oNumberFormatter.xNumberFormats.getByKey(_FormatKey); //CurDBField.DBFormatKey);
+ String FormatString = AnyConverter.toString(Helper.getUnoPropertyValue(xNumberFormat, "FormatString"));
+ Locale oLocale = (Locale) Helper.getUnoPropertyValue(xNumberFormat, "Locale");
+ int NewFormatKey = defineNumberFormat(FormatString, oLocale);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xFormatObject);
+ xPSet.setPropertyValue("FormatsSupplier", _oNumberFormatter.xNumberFormatter.getNumberFormatsSupplier());
+ if (xPSet.getPropertySetInfo().hasPropertyByName("NumberFormat"))
+ {
+ xPSet.setPropertyValue("NumberFormat", new Integer(NewFormatKey));
+ }
+ else if (xPSet.getPropertySetInfo().hasPropertyByName("FormatKey"))
+ {
+ xPSet.setPropertyValue("FormatKey", new Integer(NewFormatKey));
+ }
+ else
+ {
+ // TODO: throws a exception in a try catch environment, very helpful?
+ throw new Exception();
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+
+ public long getNullDateCorrection()
+ {
+ if (!this.bNullDateCorrectionIsDefined)
+ {
+ com.sun.star.util.Date dNullDate = (com.sun.star.util.Date) Helper.getUnoStructValue(this.xNumberFormatSettings, "NullDate");
+ long lNullDate = Helper.convertUnoDatetoInteger(dNullDate);
+ java.util.Calendar oCal = java.util.Calendar.getInstance();
+ oCal.set(1900, 1, 1);
+ Date dTime = oCal.getTime();
+ long lTime = dTime.getTime();
+ long lDBNullDate = lTime / (3600 * 24000);
+ lDateCorrection = lDBNullDate - lNullDate;
+ return lDateCorrection;
+ }
+ else
+ {
+ return this.lDateCorrection;
+ }
+ }
+
+
+ public int setBooleanReportDisplayNumberFormat()
+ {
+ String FormatString = "[=1]" + '"' + (char)9745 + '"' + ";[=0]" + '"' + (char)58480 + '"' + ";0";
+ iLogicalFormatKey = xNumberFormats.queryKey(FormatString, aLocale, true);
+ try
+ {
+ if (iLogicalFormatKey == -1)
+ {
+ iLogicalFormatKey = xNumberFormats.addNew(FormatString, aLocale);
+ }
+ }
+ catch (Exception e)
+ { //MalformedNumberFormat
+ e.printStackTrace();
+ iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale);
+ }
+ return iLogicalFormatKey;
+ }
+
+
+ /**
+ * @return Returns the iDateFormatKey.
+ */
+ public int getDateFormatKey()
+ {
+ if (iDateFormatKey == -1)
+ {
+ iDateFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATE, aLocale);
+ }
+ return iDateFormatKey;
+ }
+ /**
+ * @return Returns the iDateTimeFormatKey.
+ */
+ public int getDateTimeFormatKey()
+ {
+ if (iDateTimeFormatKey == -1)
+ {
+ iDateTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.DATETIME, aLocale);
+ }
+ return iDateTimeFormatKey;
+ }
+ /**
+ * @return Returns the iLogicalFormatKey.
+ */
+ public int getLogicalFormatKey()
+ {
+ if (iLogicalFormatKey == -1)
+ {
+ iLogicalFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.LOGICAL, aLocale);
+ }
+ return iLogicalFormatKey;
+ }
+ /**
+ * @return Returns the iNumberFormatKey.
+ */
+ public int getNumberFormatKey()
+ {
+ if (iNumberFormatKey == -1)
+ {
+ iNumberFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.NUMBER, aLocale);
+ }
+ return iNumberFormatKey;
+ }
+ /**
+ * @return Returns the iTextFormatKey.
+ */
+ public int getTextFormatKey()
+ {
+ if (iTextFormatKey == -1)
+ {
+ iTextFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TEXT, aLocale);
+ }
+ return iTextFormatKey;
+ }
+ /**
+ * @return Returns the iTimeFormatKey.
+ */
+ public int getTimeFormatKey()
+ {
+ if (iTimeFormatKey == -1)
+ {
+ iTimeFormatKey = xNumberFormatTypes.getStandardFormat(NumberFormat.TIME, aLocale);
+ }
+ return iTimeFormatKey;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/NumericalHelper.java b/wizards/com/sun/star/wizards/common/NumericalHelper.java
new file mode 100644
index 000000000000..109affffd5ef
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/NumericalHelper.java
@@ -0,0 +1,1625 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+// import com.sun.star.beans.XPropertySet;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.TypeClass;
+
+/**
+ * A class for helping with all kinds of numerical conversions.
+ * Optional or named parameters in SO are of the Object type in Java.
+ * These objects must be converted to the right simple value type.
+ * Unfortunately, StarBasic does not know the original desired type,
+ * and a value that should be a "Float" is delivered as "Byte". This class
+ * handles the conversions of these types.<br>
+ * This class does not log warnings (or throws Exceptions) when the precision
+ * of a value is lost.
+ */
+public class NumericalHelper
+{
+
+ public static final int UNKNOWN_TYPE = -32768;
+ public static final int BYTE_TYPE = 0;
+ public static final int SHORT_TYPE = 1;
+ public static final int INT_TYPE = 2;
+ public static final int LONG_TYPE = 3;
+ public static final int FLOAT_TYPE = 4;
+ public static final int DOUBLE_TYPE = 5;
+ public static final int CHAR_TYPE = 6;
+ public static final int STRING_TYPE = -1;
+ public static final int BOOLEAN_TYPE = -2;
+ public static final int ARRAY_TYPE = -3;
+ public static final int SEQUENCE_TYPE = -4;
+ public static final int ASCII_VALUE_0 = 48;
+ public static final int ASCII_VALUE_A = 65;
+ public static final int COUNT_CHARS_IN_ALPHABET = 26;
+ private static final int HEX_BASE = 16;
+ private static final int DEC_BASE = 10;
+ private static final int ASCII_LETTER_A_OFFSET = 55;
+
+ /**
+ * private c'tor to prevent instantiation
+ */
+ private NumericalHelper()
+ {
+ // private c'tor, so noone can instantiate
+ }
+
+ /**
+ * get the type of an object: returns all types that can possibly converted
+ * with this class.
+ * @param obj an object that is checked for conversion
+ * @return the type of the object
+ */
+ public static int getType(Object obj)
+ {
+ try
+ {
+ TypeObject aTypeObject = getTypeObject(obj);
+ return aTypeObject.iType;
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore this one; just return unknown type
+ }
+ return UNKNOWN_TYPE;
+ }
+
+ /**
+ * get a byte value from the object
+ * @param aValue
+ * @return a byte
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static byte toByte(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+
+ byte retValue = 0;
+ // boolean hasConversionWarning = false;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (byte) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (byte) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (byte) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (byte) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (byte) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (byte) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Byte b = new Byte((String) aTypeObject.aValue);
+ retValue = b.byteValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to byte: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? (byte) -1 : (byte) 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a char value from the object
+ * @param aValue
+ * @return a char
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static char toChar(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+
+ char retValue = 0;
+ boolean hasConversionWarning = false;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case CHAR_TYPE:
+ retValue = getChar(aTypeObject);
+ break;
+ case BYTE_TYPE:
+ retValue = (char) getByte(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (char) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (char) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (char) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (char) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (char) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ String s = (String) aTypeObject.aValue;
+ if (s.length() > 0)
+ {
+ retValue = s.charAt(0);
+ }
+ else
+ {
+ retValue = (char) 0;
+ }
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to char: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? (char) -1 : (char) 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a short value from the object
+ * @param aValue
+ * @return a short
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static short toShort(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ short retValue = 0;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (short) getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (byte) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (short) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (short) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (short) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (short) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Short s = new Short((String) aTypeObject.aValue);
+ retValue = s.shortValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to short: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? (short) -1 : (short) 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ public static boolean isValidAndNumerical(Object aValue) throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (aValue != null)
+ {
+ if (!AnyConverter.isVoid(aValue))
+ {
+ return (NumericalHelper.isNumerical(aValue));
+ }
+ }
+ return false;
+ }
+
+ public static boolean isValidAndBoolean(Object aValue) throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (aValue != null)
+ {
+ if (!AnyConverter.isVoid(aValue))
+ {
+ int nType = AnyConverter.getType(aValue).getTypeClass().getValue();
+ return (nType == TypeClass.BOOLEAN_value);
+ }
+ }
+ return false;
+ }
+
+ public static boolean isValid(Object aValue)
+ {
+ if (aValue != null)
+ {
+ if (!AnyConverter.isVoid(aValue))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ @param aValue a object this can contain anything
+ @return true, if the parameter aValue is type of real numbers
+ @deprecate, use isRealNumber() instead.
+ */
+ public static boolean isNumerical(Object aValue)
+ {
+ try
+ {
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ case CHAR_TYPE:
+ case SHORT_TYPE:
+ case INT_TYPE:
+ case LONG_TYPE:
+ case DOUBLE_TYPE:
+ case FLOAT_TYPE:
+ return true;
+ default:
+ return false;
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ return false;
+ }
+ }
+
+ /**
+ @param _aValue a object this can contain anything
+ @return true, if the parameter aValue is type of real numbers
+
+ see also http://en.wikipedia.org/wiki/Mathematics
+ */
+ public static boolean isRealNumber(Object _aValue)
+ {
+ return isNumerical(_aValue);
+ }
+
+ /**
+ @param aValue a object this can contain anything
+ * @return true, if the value is type of any integer values. double / float are not(!) integer values
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ public static boolean isInteger(Object aValue) throws com.sun.star.lang.IllegalArgumentException
+ {
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ case CHAR_TYPE:
+ case SHORT_TYPE:
+ case INT_TYPE:
+ case LONG_TYPE:
+ return true;
+ default:
+ return false;
+ }
+ }
+
+ /**
+ * Can a given object be converted to a String array?
+ * @param aValue the object to test
+ * @return true, if the object can be converted to a String array.
+ */
+ public static boolean isStringArray(Object aValue)
+ {
+ try
+ {
+ toStringArray(aValue);
+ return true;
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore
+ }
+ return false;
+ }
+
+ /**
+ * Can a given object be converted to an int array?
+ * @param aValue the object to test
+ * @return true, if the object can be converted to an Integer array.
+ */
+ public static boolean isIntegerArray(Object aValue)
+ {
+ try
+ {
+ toIntArray(aValue);
+ return true;
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore
+ }
+ return false;
+ }
+// public static int toIntWithErrorMessage(Object _aValue) throws com.sun.star.script.BasicErrorException{
+// try {
+// return toInt(_aValue);
+// }
+// catch(com.sun.star.lang.IllegalArgumentException e) {
+// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, "");
+// return 0;
+// }}
+//
+//
+// public static String toStringWithErrorMessage(Object _aValue) throws com.sun.star.script.BasicErrorException{
+// try {
+// return toString(_aValue);
+// }
+// catch(com.sun.star.lang.IllegalArgumentException e) {
+// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, "");
+// return "";
+// }}
+//
+//
+// public static int toIntWithErrorMessage(Object _aValue, int _ndefaultValue) throws com.sun.star.script.BasicErrorException{
+// try {
+// return toInt(_aValue, _ndefaultValue);
+// }
+// catch(com.sun.star.uno.Exception e) {
+// DebugHelper.exception(BasicErrorCode.SbERR_CONVERSION, "");
+// return 0;
+// }}
+//
+// public static boolean toBooleanWithErrorMessage(Object _oObject, int _nTrueField, int _nFalseField) throws com.sun.star.script.BasicErrorException{
+// return toBooleanWithErrorMessage(_oObject, new int[]{_nTrueField}, new int[]{_nFalseField});
+// }
+//
+//
+// public static boolean toBooleanWithErrorMessage(Object _oObject) throws com.sun.star.script.BasicErrorException{
+// try{
+// return toBoolean(_oObject);
+// }
+// catch (java.lang.Exception e){
+// DebugHelper.exception(BasicErrorCode.SbERR_BAD_ARGUMENT, "");
+// return false;
+// }
+// }
+//
+//
+// public static boolean toBooleanWithErrorMessage(Object _oObject, int[] _nTrueFields, int[] _nFalseFields) throws com.sun.star.script.BasicErrorException{
+// try{
+// int nValue = NumericalHelper.toIntWithErrorMessage(_oObject);
+// if (ContainerUtilities.FieldInIntTable(_nTrueFields, nValue) > -1){
+// return true;
+// }
+// else if (ContainerUtilities.FieldInIntTable(_nFalseFields, nValue) > -1){
+// return false;
+// }
+// else{
+// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, "");
+// return false;
+// }
+// }catch (java.lang.Exception e){
+// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, "");
+// return false;
+// }}
+//
+//
+// public static boolean toBooleanWithErrorMessage(Object _oObject, int _nTrueField, int _nFalseField, boolean _bdefaultValue) throws com.sun.star.script.BasicErrorException{
+// return toBooleanWithErrorMessage(_oObject, new int[]{_nTrueField}, new int[]{_nFalseField}, _bdefaultValue);
+// }
+//
+//
+// public static boolean toBooleanWithErrorMessage(Object _oObject, int[] _nTrueFields, int[] _nFalseFields, boolean _bdefaultValue) throws com.sun.star.script.BasicErrorException{
+// try{
+// if ((_oObject == null) || (AnyConverter.isVoid(_oObject))){
+// return _bdefaultValue;
+// }
+// else{
+// int nValue = NumericalHelper.toIntWithErrorMessage(_oObject);
+// if (ContainerUtilities.FieldInIntTable(_nTrueFields, nValue) > -1){
+// return true;
+// }
+// else if (ContainerUtilities.FieldInIntTable(_nFalseFields, nValue) > -1){
+// return false;
+// }
+// else{
+// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, "");
+// return false;
+// }
+// }
+// }catch (java.lang.Exception e){
+// DebugHelper.exception(BasicErrorCode.SbERR_OUT_OF_RANGE, "");
+// return false;
+// }}
+ /**
+ * get an int value from the object
+ * @param aValue
+ * @return an int
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static int toInt(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ int retValue = 0;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (int) getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (int) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (int) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (int) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (int) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (int) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Integer i = new Integer((String) aTypeObject.aValue);
+ retValue = i.intValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to int: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? -1 : 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a long value from the object
+ * @param aValue
+ * @return a long
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static long toLong(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ long retValue = 0;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (long) getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (long) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (long) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (long) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (long) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (long) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Long l = new Long((String) aTypeObject.aValue);
+ retValue = l.longValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to short: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? -1 : 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a float value from the object
+ * @param aValue
+ * @return a float
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static float toFloat(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ float retValue = (float) 0.0;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (float) getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (float) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (float) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (float) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (float) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (float) getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Float f = new Float((String) aTypeObject.aValue);
+ retValue = f.floatValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to short: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? (float) -1 : (float) 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a double value from the object
+ * @param aValue
+ * @return a double
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static double toDouble(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ double retValue = 0.0;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (double) getByte(aTypeObject);
+ break;
+ case CHAR_TYPE:
+ retValue = (double) getChar(aTypeObject);
+ break;
+ case SHORT_TYPE:
+ retValue = (double) getShort(aTypeObject);
+ break;
+ case INT_TYPE:
+ retValue = (double) getInt(aTypeObject);
+ break;
+ case LONG_TYPE:
+ retValue = (double) getLong(aTypeObject);
+ break;
+ case FLOAT_TYPE:
+ retValue = (double) getFloat(aTypeObject);
+ break;
+ case DOUBLE_TYPE:
+ retValue = getDouble(aTypeObject);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Float f = new Float((String) aTypeObject.aValue);
+ retValue = f.floatValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to short: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = getBool(aTypeObject) ? (double) -1 : (double) 0;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a String value from the object
+ * @param aValue
+ * @return a String
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static String toString(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ String retValue = null;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = ((Byte) aTypeObject.aValue).toString();
+ break;
+ case CHAR_TYPE:
+ retValue = ((Character) aTypeObject.aValue).toString();
+ break;
+ case SHORT_TYPE:
+ retValue = ((Short) aTypeObject.aValue).toString();
+ break;
+ case INT_TYPE:
+ retValue = ((Integer) aTypeObject.aValue).toString();
+ break;
+ case LONG_TYPE:
+ retValue = ((Long) aTypeObject.aValue).toString();
+ break;
+ case FLOAT_TYPE:
+ retValue = ((Float) aTypeObject.aValue).toString();
+ break;
+ case DOUBLE_TYPE:
+ retValue = ((Double) aTypeObject.aValue).toString();
+ break;
+ case STRING_TYPE:
+ retValue = (String) aTypeObject.aValue;
+ break;
+ case BOOLEAN_TYPE:
+ retValue = ((Boolean) aTypeObject.aValue).toString();
+ break;
+ case ARRAY_TYPE:
+ retValue = new String(toByteArray((aValue)));
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get a boolean value from the object
+ * @param aValue
+ * @return a boolean
+ * @throws com.sun.star.lang.IllegalArgumentException if the object cannot be converted
+ */
+ public static boolean toBoolean(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ boolean retValue = true;
+ TypeObject aTypeObject = getTypeObject(aValue);
+ switch (aTypeObject.iType)
+ {
+ case BYTE_TYPE:
+ retValue = (((Byte) aTypeObject.aValue).byteValue() != 0);
+ break;
+ case CHAR_TYPE:
+ retValue = (((Character) aTypeObject.aValue).charValue() != 0);
+ break;
+ case SHORT_TYPE:
+ retValue = (((Short) aTypeObject.aValue).shortValue() != 0);
+ break;
+ case INT_TYPE:
+ retValue = (((Integer) aTypeObject.aValue).intValue() != 0);
+ break;
+ case LONG_TYPE:
+ retValue = (((Long) aTypeObject.aValue).longValue() != 0);
+ break;
+ case FLOAT_TYPE:
+ retValue = (((Float) aTypeObject.aValue).floatValue() != 0);
+ break;
+ case DOUBLE_TYPE:
+ retValue = (((Double) aTypeObject.aValue).doubleValue() != 0);
+ break;
+ case STRING_TYPE:
+ try
+ {
+ Boolean b = Boolean.valueOf((String) aTypeObject.aValue);
+ retValue = b.booleanValue();
+ }
+ catch (java.lang.NumberFormatException e)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert to short: " + aTypeObject.aValue);
+ }
+ break;
+ case BOOLEAN_TYPE:
+ retValue = ((Boolean) aTypeObject.aValue).booleanValue();
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return retValue;
+ }
+
+ /**
+ * get an int array from an object
+ * @param anArrayValue a value that is constructed into an array
+ * @return an integer array
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ public static int[] toIntArray(Object anArrayValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ int[] retValue = null;
+ TypeObject aTypeObject = getTypeObject(anArrayValue);
+ if (aTypeObject.iType == SEQUENCE_TYPE)
+ {
+ aTypeObject = convertSequenceToObjectArray(aTypeObject);
+ }
+ if (aTypeObject.iType == ARRAY_TYPE)
+ {
+ Object[] obj = (Object[]) aTypeObject.aValue;
+ retValue = new int[obj.length];
+ for (int i = 0; i < obj.length; i++)
+ {
+ retValue[i] = toInt(obj[i]);
+ }
+ }
+ else
+ { // object is not really an array
+ retValue = new int[]
+ {
+ toInt(anArrayValue)
+ };
+ }
+ return retValue;
+ }
+
+ /**
+ * get an byte array from an object
+ * @param anArrayValue a value that is constructed into an array
+ * @return a byte array
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ public static byte[] toByteArray(Object anArrayValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ byte[] retValue = null;
+ TypeObject aTypeObject = getTypeObject(anArrayValue);
+ if (aTypeObject.iType == SEQUENCE_TYPE)
+ {
+ aTypeObject = convertSequenceToObjectArray(aTypeObject);
+ }
+ if (aTypeObject.iType == ARRAY_TYPE)
+ {
+ Object[] obj = (Object[]) aTypeObject.aValue;
+ retValue = new byte[obj.length];
+ for (int i = 0; i < obj.length; i++)
+ {
+ retValue[i] = toByte(obj[i]);
+ }
+ }
+ else
+ { // object is not really an array
+ retValue = new byte[]
+ {
+ toByte(anArrayValue)
+ };
+ }
+ return retValue;
+ }
+
+ /**
+ * get a short array from an object
+ * @param anArrayValue a value that is constructed into an array
+ * @return a short array
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ public static short[] toShortArray(Object anArrayValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ short[] retValue = null;
+ TypeObject aTypeObject = getTypeObject(anArrayValue);
+ if (aTypeObject.iType == SEQUENCE_TYPE)
+ {
+ aTypeObject = convertSequenceToObjectArray(aTypeObject);
+ }
+ if (aTypeObject.iType == ARRAY_TYPE)
+ {
+ Object[] obj = (Object[]) aTypeObject.aValue;
+ retValue = new short[obj.length];
+ for (int i = 0; i < obj.length; i++)
+ {
+ retValue[i] = toShort(obj[i]);
+ }
+ }
+ else
+ { // object is not really an array
+ retValue = new short[]
+ {
+ toShort(anArrayValue)
+ };
+ }
+ return retValue;
+ }
+
+ /**
+ * get a string array from an object
+ * @param anArrayValue a value that is constructed into an array
+ * @return a short array
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ public static String[] toStringArray(Object anArrayValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ String[] retValue = null;
+ TypeObject aTypeObject = getTypeObject(anArrayValue);
+ if (aTypeObject.iType == SEQUENCE_TYPE)
+ {
+ aTypeObject = convertSequenceToObjectArray(aTypeObject);
+ }
+ if (aTypeObject.iType == ARRAY_TYPE)
+ {
+ Object[] obj = (Object[]) aTypeObject.aValue;
+ retValue = new String[obj.length];
+ for (int i = 0; i < obj.length; i++)
+ {
+ retValue[i] = toString(obj[i]);
+ }
+ }
+ else
+ { // object is not really an array
+ retValue = new String[]
+ {
+ toString(anArrayValue)
+ };
+ }
+ return retValue;
+ }
+
+ /**
+ * get an int from an object
+ * @param _aValue a value that is constructed into an int
+ * @param _ndefaultValue the value that is returned, if conversion fails, or if 'aValue' is null
+ * @return an int value
+ * @throws java.lang.Exception
+ */
+ public static int toInt(Object _aValue, int _ndefaultValue) throws Exception
+ {
+ int nreturn = _ndefaultValue;
+ try
+ {
+ if ((_aValue != null) && (!(AnyConverter.isVoid(_aValue))))
+ {
+ if (isInteger(_aValue))
+ {
+ nreturn = toInt(_aValue);
+ }
+ else
+ {
+ DebugHelper.exception(1/* BasicErrorCode.SbERR_CONVERSION*/, "");
+ }
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ DebugHelper.exception(1 /*BasicErrorCode.SbERR_METHOD_FAILED*/, "");
+ }
+ return nreturn;
+ }
+
+ /**
+ * get a long from an object
+ * @param aValue a value that is constructed into a long
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a long value
+ */
+ public static long toLong(Object aValue, long defaultValue)
+ {
+ try
+ {
+ return toLong(aValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a float from an object
+ * @param aValue a value that is constructed into a float
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a long value
+ */
+ public static float toFloat(Object aValue, float defaultValue)
+ {
+ try
+ {
+ return toFloat(aValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a double from an object
+ * @param aValue a value that is constructed into a double
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a double value
+ */
+ public static double toDouble(Object aValue, double defaultValue)
+ {
+ try
+ {
+ return toDouble(aValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a string from an object
+ * @param aValue a value that is constructed into a string
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a string value
+ */
+ public static String toString(Object aValue, String defaultValue)
+ {
+ try
+ {
+ return toString(aValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a boolean from an object
+ * @param aValue a value that is constructed into a boolean
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a boolean value
+ */
+ public static boolean toBoolean(Object aValue, boolean defaultValue)
+ {
+ try
+ {
+ return toBoolean(aValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a int array from an object
+ * @param anArrayValue a value that is constructed into an int array
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return an int array
+ */
+ public static int[] toIntArray(Object anArrayValue, int[] defaultValue)
+ {
+ try
+ {
+ return toIntArray(anArrayValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a short array from an object
+ * @param anArrayValue a value that is constructed into a short array
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a short array
+ */
+ public static short[] toShortArray(Object anArrayValue, short[] defaultValue)
+ {
+ try
+ {
+ return toShortArray(anArrayValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a string array from an object
+ * @param anArrayValue a value that is constructed into a string array
+ * @param defaultValue the value that is returned, if conversion fails
+ * @return a string array
+ */
+ public static String[] toStringArray(Object anArrayValue, String[] defaultValue)
+ {
+ try
+ {
+ return toStringArray(anArrayValue);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ // ignore exception
+ }
+ return defaultValue;
+ }
+
+ /**
+ * get a hexadecimal representation from a number
+ * @param number the number to transform
+ * @return a String with the hex code of the number
+ */
+ public static String getHexStringFromNumber(long number)
+ {
+ TransformNumToHex num = new TransformNumToHex(number);
+ return num.getResult();
+ }
+
+ /**
+ * Get the roman equivalent to an arabic number, e.g. 17 -> XVII.
+ * The allowed range for numbers goes from 1 to 3999. These can be
+ * converted using ASCII letters (3999 -> MMMCMXCIX).
+ * @param n the arabic number
+ * @return the roman equivalent as string
+ * @throws BasicErrorException if the number cannot be converted.
+ */
+// public static String getRomanEquivalent(int n)
+// throws com.sun.star.script.BasicErrorException {
+// return RomanNumbering.getRomanEquivalent(n);
+// }
+ /**
+ * get the type object from the given object
+ * @param aValue an object representing a (numerical) value; can also be an 'any'
+ * @return a type object: the object together with the its type information
+ * @throws com.sun.star.lang.IllegalArgumentException if the object is unknown
+ */
+ private static TypeObject getTypeObject(Object aValue)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ TypeObject aTypeObject = new TypeObject();
+ if (aValue == null || AnyConverter.isVoid(aValue))
+ {
+ throw new com.sun.star.lang.IllegalArgumentException("Cannot convert a null object.");
+ }
+ int type = AnyConverter.getType(aValue).getTypeClass().getValue();
+ switch (type)
+ {
+ case TypeClass.CHAR_value:
+ aTypeObject.iType = CHAR_TYPE;
+ aTypeObject.aValue = new Character(AnyConverter.toChar(aValue));
+ break;
+ case TypeClass.BYTE_value:
+ aTypeObject.iType = BYTE_TYPE;
+ aTypeObject.aValue = new Byte(AnyConverter.toByte(aValue));
+ break;
+ case TypeClass.SHORT_value:
+ aTypeObject.iType = SHORT_TYPE;
+ aTypeObject.aValue = new Short(AnyConverter.toShort(aValue));
+ break;
+ case TypeClass.LONG_value:
+ aTypeObject.iType = INT_TYPE;
+ aTypeObject.aValue = new Integer(AnyConverter.toInt(aValue));
+ break;
+ case TypeClass.HYPER_value:
+ aTypeObject.iType = LONG_TYPE;
+ aTypeObject.aValue = new Long(AnyConverter.toLong(aValue));
+ break;
+ case TypeClass.FLOAT_value:
+ aTypeObject.iType = FLOAT_TYPE;
+ aTypeObject.aValue = new Float(AnyConverter.toFloat(aValue));
+ break;
+ case TypeClass.DOUBLE_value:
+ aTypeObject.iType = DOUBLE_TYPE;
+ aTypeObject.aValue = new Double(AnyConverter.toDouble(aValue));
+ break;
+ case TypeClass.STRING_value:
+ aTypeObject.iType = STRING_TYPE;
+ aTypeObject.aValue = AnyConverter.toString(aValue);
+ break;
+ case TypeClass.BOOLEAN_value:
+ aTypeObject.iType = BOOLEAN_TYPE;
+ aTypeObject.aValue = Boolean.valueOf(AnyConverter.toBoolean(aValue));
+ break;
+ case TypeClass.ARRAY_value:
+ aTypeObject.iType = ARRAY_TYPE;
+ aTypeObject.aValue = new Object[]
+ {
+ AnyConverter.toArray(aValue)
+ };
+ break;
+ case TypeClass.SEQUENCE_value:
+ aTypeObject.iType = SEQUENCE_TYPE;
+ aTypeObject.aValue = aValue;
+ break;
+ default:
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert this type: " + aValue.getClass().getName());
+ }
+ return aTypeObject;
+ }
+
+ /**
+ * get the simple byte type
+ */
+ private static byte getByte(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != BYTE_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a byte type.");
+ }
+ return ((Byte) typeObject.aValue).byteValue();
+ }
+
+ /**
+ * get the simple char type
+ */
+ private static char getChar(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != CHAR_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a char type.");
+ }
+ return ((Character) typeObject.aValue).charValue();
+ }
+
+ /**
+ * get the simple short type
+ */
+ private static short getShort(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != SHORT_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a short type.");
+ }
+ return ((Short) typeObject.aValue).shortValue();
+ }
+
+ /**
+ * get the simple int type
+ * @param typeObject
+ * @return
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ static int getInt(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != INT_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not an int type.");
+ }
+ return ((Integer) typeObject.aValue).intValue();
+ }
+
+ /**
+ * get the simple float type
+ * @throws com.sun.star.lang.IllegalArgumentException
+ */
+ static float getFloat(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != FLOAT_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a float type.");
+ }
+ return ((Float) typeObject.aValue).floatValue();
+ }
+
+ /**
+ * get the simple double type
+ */
+ private static double getDouble(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != DOUBLE_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a double type.");
+ }
+ return ((Double) typeObject.aValue).doubleValue();
+ }
+
+ /**
+ * get the simple long type
+ */
+ private static long getLong(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != LONG_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a long type.");
+ }
+ return ((Long) typeObject.aValue).longValue();
+ }
+
+ /**
+ * get the simple boolean type
+ */
+ private static boolean getBool(TypeObject typeObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ if (typeObject.iType != BOOLEAN_TYPE)
+ {
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Given argument is not a boolean type.");
+ }
+ return ((Boolean) typeObject.aValue).booleanValue();
+ }
+
+ /**
+ * a class to contain a type and a value for easier conversions
+ */
+ private static class TypeObject
+ {
+
+ public int iType;
+ public Object aValue;
+ }
+
+ /**
+ * simple class to construct a hexadecimal value from a long number
+ */
+ private static class TransformNumToHex
+ {
+
+ private StringBuffer val;
+
+ public TransformNumToHex(long number)
+ {
+ val = new StringBuffer();
+ transform(number);
+ }
+
+ private void transform(long number)
+ {
+ int index = (int) (number % HEX_BASE);
+ number = number / HEX_BASE;
+ if (index < DEC_BASE)
+ {
+ val.insert(0, index);
+ }
+ else
+ {
+ val.insert(0, (char) (ASCII_LETTER_A_OFFSET + index));
+ }
+ if (number > 0)
+ {
+ transform(number);
+ }
+ }
+
+ public String getResult()
+ {
+ return val.toString();
+ }
+ }
+
+ private static TypeObject convertSequenceToObjectArray(
+ TypeObject sourceObject)
+ throws com.sun.star.lang.IllegalArgumentException
+ {
+ TypeObject destObject = new TypeObject();
+ Object array = sourceObject.aValue;
+ destObject.iType = ARRAY_TYPE;
+ Class c = array.getClass();
+ Object[] aShortVal = null;
+ if (c.equals(byte[].class))
+ {
+ byte[] vals = (byte[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Byte(vals[i]);
+ }
+ }
+ else if (c.equals(short[].class))
+ {
+ short[] vals = (short[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Short(vals[i]);
+ }
+ }
+ else if (c.equals(int[].class))
+ {
+ int[] vals = (int[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Integer(vals[i]);
+ }
+ }
+ else if (c.equals(long[].class))
+ {
+ long[] vals = (long[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Long(vals[i]);
+ }
+ }
+ else if (c.equals(float[].class))
+ {
+ float[] vals = (float[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Float(vals[i]);
+ }
+ }
+ else if (c.equals(double[].class))
+ {
+ double[] vals = (double[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = new Double(vals[i]);
+ }
+ }
+ else if (c.equals(boolean[].class))
+ {
+ boolean[] vals = (boolean[]) array;
+ aShortVal = new Object[vals.length];
+ for (int i = 0; i < vals.length; i++)
+ {
+ aShortVal[i] = Boolean.valueOf(vals[i]);
+ }
+ }
+ // if nothing did match, try this
+ if (aShortVal == null)
+ {
+ try
+ {
+ aShortVal = (Object[]) array;
+ }
+ catch (java.lang.ClassCastException e)
+ {
+ // unknown type cannot be converted
+ throw new com.sun.star.lang.IllegalArgumentException(
+ "Cannot convert unknown type: '" + e.getMessage() + "'");
+ }
+ }
+ destObject.aValue = aShortVal;
+ return destObject;
+ }
+
+// public static boolean isObjectNumericRepresentation(Object _oValue, NumberFormatter _oNumberFormatter, XPropertySet _xPropertySet) throws com.sun.star.script.BasicErrorException{
+// try{
+// int nNumberFormat = AnyConverter.toInt(_xPropertySet.getPropertyValue("NumberFormat"));
+// if (AnyConverter.isString(_oValue)){
+// String sCellContent = AnyConverter.toString(_oValue);
+// try{
+// _oNumberFormatter.convertStringToNumber(nNumberFormat, sCellContent);
+// return true;
+// }catch (Exception e){
+// return false;
+// }
+// }
+// else{
+// return true;
+// }
+// }
+// catch (com.sun.star.uno.Exception e){
+// DebugHelper.exception(1 /*BasicErrorCode.SbERR_METHOD_FAILED*/, "");
+// return false;
+// }}
+ /**
+ * Helper class for roman numbering
+ */
+ private static class RomanNumbering
+ {
+
+ /** the used roman lettesrs **/
+ private static final String[] ROMAN_EQUIV = new String[]
+ {
+ "I", "V", "X", "L", "C", "D", "M"
+ };
+ /** max number that can be converted **/
+ private static final int MAX_NUMBER = 3999;
+ /** min number that can be converted **/
+ private static final int MIN_NUMBER = 1;
+ /** ASCII code for the number 0 **/
+ private static final int ASCII_CODE_0 = 48;
+ /** special number for the conversion algorithm **/
+ private static final int FOUR = 4;
+ /** special number for the conversion algorithm **/
+ private static final int FIVE = 5;
+ /** special number for the conversion algorithm **/
+ private static final int NINE = 9;
+
+ /**
+ * Get the roman equivalent to an arabic number, e.g. 17 -> XVII.
+ * The allowed range for numbers goes from 1 to 3999. These can be
+ * converted using ASCII letters (3999 -> MMMCMXCIX).
+ * @param n the arabic number
+ * @return the roman equivalent as string
+ * @throws BasicErrorException if the number cannot be converted.
+ */
+ public static String getRomanEquivalent(int n)
+ throws Exception
+ {
+ StringBuffer romanNumber = new StringBuffer();
+ try
+ {
+ if (n > MAX_NUMBER || n < MIN_NUMBER)
+ {
+ DebugHelper.exception(1 /*BasicErrorCode.SbERR_OUT_OF_RANGE*/, "");
+ }
+ String number = NumericalHelper.toString(new Integer(n));
+ /* converison idea: every digit is written with a maximum of two
+ * different roman symbols, using three in total, e.g. CC, CD,
+ * DCC, CM for the hundreds (meaning 200, 400, 700 and 900).
+ * So every digit is converted seperately with regard to the
+ * special cases 4 and 9.
+ */
+ int symbolIndex = 0;
+ for (int i = number.length() - 1; i >= 0; i--)
+ {
+ StringBuffer romanDigit = new StringBuffer();
+ int b = (int) number.charAt(i) - ASCII_CODE_0;
+ if (b == FOUR)
+ { // special case IV
+ romanDigit.append(ROMAN_EQUIV[symbolIndex]);
+ romanDigit.append(ROMAN_EQUIV[symbolIndex + 1]);
+ }
+ else if (b == NINE)
+ { // special case IX
+ romanDigit.append(ROMAN_EQUIV[symbolIndex]);
+ romanDigit.append(ROMAN_EQUIV[symbolIndex + 2]);
+ }
+ else
+ {
+ if (b >= FIVE)
+ { // special case V
+ romanDigit.append(ROMAN_EQUIV[symbolIndex + 1]);
+ b = b - FIVE;
+ }
+ for (int j = 0; j < b; j++)
+ { // append I's
+ romanDigit.append(ROMAN_EQUIV[symbolIndex]);
+ }
+ }
+ // next group of three symbols
+ symbolIndex += 2;
+ // append in reverse: we are starting at the right
+ romanNumber.append(romanDigit.reverse());
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.exception(e);
+ }
+ // reverse again to get the number
+ return romanNumber.reverse().toString();
+ }
+ }
+
+ public static boolean representsIntegerNumber(double _dblvalue)
+ {
+ double dblsecvalue = (double) ((int) _dblvalue);
+ return Double.compare(_dblvalue, dblsecvalue) == 0;
+ }
+
+ public static double roundDouble(Double _Dblvalue, int _ndecimals)
+ {
+ return roundDouble(_Dblvalue.doubleValue(), _ndecimals);
+ }
+
+ public static double roundDouble(double _dblvalue, int _ndecimals)
+ {
+ double dblfactor = java.lang.Math.pow(10.0, (double) _ndecimals);
+ double dblretvalue = ((double) ((int) (_dblvalue * dblfactor))) / dblfactor;
+ return dblretvalue;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/Properties.java b/wizards/com/sun/star/wizards/common/Properties.java
new file mode 100644
index 000000000000..6b4155d15adf
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Properties.java
@@ -0,0 +1,126 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Properties.java
+ *
+ * Created on 1. Oktober 2003, 17:16
+ */
+package com.sun.star.wizards.common;
+
+import com.sun.star.beans.PropertyValue;
+import java.util.*;
+
+/**
+ * Simplifies handling Arrays of PropertyValue.
+ * To make a use of this class, instantiate it, and call
+ * the put(propName,propValue) method.
+ * caution: propName should always be a String.
+ * When finished, call the getProperties() method to get an array of the set properties.
+ * @author rp
+ */
+public class Properties extends Hashtable
+{
+
+ public static Object getPropertyValue(PropertyValue[] props, String propName)
+ {
+ for (int i = 0; i < props.length; i++)
+ {
+ if (propName.equals(props[i].Name))
+ {
+ return props[i].Value;
+ }
+ }
+ throw new IllegalArgumentException("Property '" + propName + "' not found.");
+ }
+
+ public static boolean hasPropertyValue(PropertyValue[] props, String propName)
+ {
+ for (int i = 0; i < props.length; i++)
+ {
+ if (propName.equals(props[i].Name))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public PropertyValue[] getProperties()
+ {
+ return getProperties(this);
+ }
+
+ public static PropertyValue[] getProperties(Map map)
+ {
+ PropertyValue[] pv = new PropertyValue[map.size()];
+
+ Iterator it = map.keySet().iterator();
+ for (int i = 0; i < pv.length; i++)
+ {
+ pv[i] = createProperty((String) it.next(), map);
+ }
+ return pv;
+ }
+
+ public static PropertyValue createProperty(String name, Map map)
+ {
+ return createProperty(name, map.get(name));
+ }
+
+ public static PropertyValue createProperty(String name, Object value)
+ {
+ PropertyValue pv = new PropertyValue();
+ pv.Name = name;
+ pv.Value = value;
+ return pv;
+ }
+
+ public static PropertyValue createProperty(String name, Object value, int handle)
+ {
+ PropertyValue pv = createProperty(name, value);
+ pv.Handle = handle;
+ return pv;
+ }
+
+ public static PropertyValue[] convertToPropertyValueArray(Object[] _oObjectArray)
+ {
+ PropertyValue[] retproperties = null;
+ if (_oObjectArray != null)
+ {
+ if (_oObjectArray.length > 0)
+ {
+ retproperties = new PropertyValue[_oObjectArray.length];
+ for (int i = 0; i < _oObjectArray.length; i++)
+ {
+ retproperties[i] = (PropertyValue) _oObjectArray[i];
+ }
+ }
+ }
+ return retproperties;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/PropertySetHelper.java b/wizards/com/sun/star/wizards/common/PropertySetHelper.java
new file mode 100644
index 000000000000..aec166a5c1c5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/PropertySetHelper.java
@@ -0,0 +1,396 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.beans.Property;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.lang.XServiceInfo;
+
+// import com.sun.star.container.XNameAccess;
+import java.util.HashMap;
+
+public class PropertySetHelper
+{
+
+ protected XPropertySet m_xPropertySet;
+ private HashMap<String, Object> m_aHashMap;
+
+ public PropertySetHelper(Object _aObj)
+ {
+ if (_aObj == null)
+ {
+ return;
+ }
+ m_xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _aObj);
+ }
+
+ private HashMap<String, Object> getHashMap()
+ {
+ if (m_aHashMap == null)
+ {
+ m_aHashMap = new HashMap<String, Object>();
+ }
+ return m_aHashMap;
+ }
+
+ /**
+ set a property, don't throw any exceptions, they will only write down as a hint in the helper debug output
+ @param _sName name of the property to set
+ @param _aValue property value as object
+ */
+ public void setPropertyValueDontThrow(String _sName, Object _aValue)
+ {
+ try
+ {
+ setPropertyValue(_sName, _aValue);
+ }
+ catch (Exception e)
+ {
+ DebugHelper.writeInfo("Don't throw the exception with property name(" + _sName + " ) : " + e.getMessage());
+ }
+ }
+
+ /**
+ set a property,
+ @param _sName name of the property to set
+ @param _aValue property value as object
+ * @throws java.lang.Exception
+ */
+ public void setPropertyValue(String _sName, Object _aValue) throws java.lang.Exception
+ {
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ m_xPropertySet.setPropertyValue(_sName, _aValue);
+ }
+ // Exceptions are not from interest
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ DebugHelper.exception(e);
+ }
+ catch (com.sun.star.beans.PropertyVetoException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ DebugHelper.exception(e);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ DebugHelper.exception(e);
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ DebugHelper.exception(e);
+ }
+ }
+ else
+ {
+ // DebugHelper.writeInfo("PropertySetHelper.setProperty() can't get XPropertySet");
+ getHashMap().put(_sName, _aValue);
+ }
+ }
+
+ /**
+ get a property and convert it to a int value
+ @param _sName the string name of the property
+ @param _nDefault if an error occur, return this value
+ @return the int value of the property
+ */
+ public int getPropertyValueAsInteger(String _sName, int _nDefault)
+ {
+ Object aObject = null;
+ int nValue = _nDefault;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ if (aObject != null)
+ {
+ try
+ {
+ nValue = NumericalHelper.toInt(aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo("can't convert a object to integer.");
+ }
+ }
+ return nValue;
+ }
+
+ /**
+ get a property and convert it to a short value
+ @param _sName the string name of the property
+ @param _nDefault if an error occur, return this value
+ @return the int value of the property
+ */
+ public short getPropertyValueAsShort(String _sName, short _nDefault)
+ {
+ Object aObject = null;
+ short nValue = _nDefault;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ if (aObject != null)
+ {
+ try
+ {
+ nValue = NumericalHelper.toShort(aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo("can't convert a object to short.");
+ }
+ }
+ return nValue;
+ }
+
+ /**
+ get a property and convert it to a double value
+ @param _sName the string name of the property
+ @param _nDefault if an error occur, return this value
+ @return the int value of the property
+ */
+ public double getPropertyValueAsDouble(String _sName, double _nDefault)
+ {
+ Object aObject = null;
+ double nValue = _nDefault;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ if (aObject == null)
+ {
+ if (getHashMap().containsKey(_sName))
+ {
+ aObject = getHashMap().get(_sName);
+ }
+ }
+ if (aObject != null)
+ {
+ try
+ {
+ nValue = NumericalHelper.toDouble(aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo("can't convert a object to integer.");
+ }
+ }
+ return nValue;
+ }
+
+ /**
+ get a property and convert it to a boolean value
+ @param _sName the string name of the property
+ @param _bDefault if an error occur, return this value
+ @return the boolean value of the property
+ */
+ public boolean getPropertyValueAsBoolean(String _sName, boolean _bDefault)
+ {
+ Object aObject = null;
+ boolean bValue = _bDefault;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ DebugHelper.writeInfo("UnknownPropertyException caught: Name:=" + _sName);
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ if (aObject != null)
+ {
+ try
+ {
+ bValue = NumericalHelper.toBoolean(aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo("can't convert a object to boolean.");
+ }
+ }
+ return bValue;
+ }
+
+ /**
+ get a property and convert it to a string value
+ @param _sName the string name of the property
+ @param _sDefault if an error occur, return this value
+ @return the string value of the property
+ */
+ public String getPropertyValueAsString(String _sName, String _sDefault)
+ {
+ Object aObject = null;
+ String sValue = _sDefault;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ if (aObject != null)
+ {
+ try
+ {
+ sValue = AnyConverter.toString(aObject);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ DebugHelper.writeInfo("can't convert a object to string.");
+ }
+ }
+ return sValue;
+ }
+
+ /**
+ get a property and don't convert it
+ @param _sName the string name of the property
+ @return the object value of the property without any conversion
+ */
+ public Object getPropertyValueAsObject(String _sName)
+ {
+ Object aObject = null;
+
+ if (m_xPropertySet != null)
+ {
+ try
+ {
+ aObject = m_xPropertySet.getPropertyValue(_sName);
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ DebugHelper.writeInfo(e.getMessage());
+ }
+ }
+ return aObject;
+ }
+
+ /**
+ * Debug helper, to show all properties which are available in the given object.
+ * @param _xObj the object of which the properties should shown
+ */
+ public static void showProperties(Object _xObj)
+ {
+ PropertySetHelper aHelper = new PropertySetHelper(_xObj);
+ aHelper.showProperties();
+ }
+
+ /**
+ Debug helper, to show all properties which are available in the current object.
+ */
+ public void showProperties()
+ {
+ String sName = "";
+
+ if (m_xPropertySet != null)
+ {
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, m_xPropertySet);
+ if (xServiceInfo != null)
+ {
+ sName = xServiceInfo.getImplementationName();
+ }
+ XPropertySetInfo xInfo = m_xPropertySet.getPropertySetInfo();
+ Property[] aAllProperties = xInfo.getProperties();
+ DebugHelper.writeInfo("Show all properties of Implementation of :'" + sName + "'");
+ for (int i = 0; i < aAllProperties.length; i++)
+ {
+ DebugHelper.writeInfo(" - " + aAllProperties[i].Name);
+ }
+ }
+ else
+ {
+ DebugHelper.writeInfo("The given object don't support XPropertySet interface.");
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/Resource.java b/wizards/com/sun/star/wizards/common/Resource.java
new file mode 100644
index 000000000000..8dc660b21d07
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/Resource.java
@@ -0,0 +1,143 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.common;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.script.XInvocation;
+import com.sun.star.beans.PropertyValue;
+
+public class Resource
+{
+
+ XInvocation xInvocation;
+ XMultiServiceFactory xMSF;
+ String Unit;
+ String Module;
+
+ /** Creates a new instance of Resource
+ * @param _xMSF
+ * @param _Unit
+ * @param _Module
+ */
+ public Resource(XMultiServiceFactory _xMSF, String _Unit, String _Module)
+ {
+ this.xMSF = _xMSF;
+ this.Unit = _Unit;
+ this.Module = _Module;
+ this.xInvocation = initResources();
+ }
+
+ public String getResText(int nID)
+ {
+ try
+ {
+ short[][] PointerArray = new short[1][];
+ Object[][] DummyArray = new Object[1][];
+ Object[] nIDArray = new Object[1];
+ nIDArray[0] = new Integer(nID);
+ final String IDString = (String) xInvocation.invoke("getString", nIDArray, PointerArray, DummyArray);
+ return IDString;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found");
+ }
+ }
+
+ public PropertyValue[] getStringList(int nID)
+ {
+ try
+ {
+ short[][] PointerArray = new short[1][];
+ Object[][] DummyArray = new Object[1][];
+ Object[] nIDArray = new Object[1];
+ nIDArray[0] = new Integer(nID);
+ //Object bla = xInvocation.invoke("getStringList", nIDArray, PointerArray, DummyArray);
+ PropertyValue[] ResProp = (PropertyValue[]) xInvocation.invoke("getStringList", nIDArray, PointerArray, DummyArray);
+ return ResProp;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found");
+ }
+ }
+
+ public String[] getResArray(int nID, int iCount)
+ {
+ try
+ {
+ String[] ResArray = new String[iCount];
+ for (int i = 0; i < iCount; i++)
+ {
+ ResArray[i] = getResText(nID + i);
+ }
+ return ResArray;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ throw new java.lang.IllegalArgumentException("Resource with ID not" + String.valueOf(nID) + "not found");
+ }
+ }
+
+ public XInvocation initResources()
+ {
+ try
+ {
+ com.sun.star.uno.XInterface xResource = (com.sun.star.uno.XInterface) xMSF.createInstance("com.sun.star.resource.VclStringResourceLoader");
+ if (xResource == null)
+ {
+ showCommonResourceError(xMSF);
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ XInvocation xResInvoke = (XInvocation) com.sun.star.uno.UnoRuntime.queryInterface(XInvocation.class, xResource);
+ xResInvoke.setValue("FileName", Module);
+ return xResInvoke;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ showCommonResourceError(xMSF);
+ return null;
+ }
+ }
+
+ public static void showCommonResourceError(XMultiServiceFactory xMSF)
+ {
+ String ProductName = Configuration.getProductName(xMSF);
+ String sError = "The files required could not be found.\nPlease start the %PRODUCTNAME Setup and choose 'Repair'.";
+ sError = JavaTools.replaceSubString(sError, ProductName, "%PRODUCTNAME");
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sError);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/SystemDialog.java b/wizards/com/sun/star/wizards/common/SystemDialog.java
new file mode 100644
index 000000000000..ac3a38c9cf7d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/SystemDialog.java
@@ -0,0 +1,428 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ui.dialogs.*;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.util.XStringSubstitution;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.frame.XFrame;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XMessageBox;
+import com.sun.star.beans.PropertyValue;
+
+public class SystemDialog
+{
+
+ Object systemDialog;
+ XFilePicker xFilePicker;
+ XFolderPicker xFolderPicker;
+ XFilterManager xFilterManager;
+ XInitialization xInitialize;
+ XExecutableDialog xExecutable;
+ XComponent xComponent;
+ XFilePickerControlAccess xFilePickerControlAccess;
+ XMultiServiceFactory xMSF;
+ public XStringSubstitution xStringSubstitution;
+ public String sStorePath;
+
+ /**
+ *
+ * @param xMSF
+ * @param ServiceName
+ * @param type according to com.sun.star.ui.dialogs.TemplateDescription
+ */
+ public SystemDialog(XMultiServiceFactory xMSF, String ServiceName, short type)
+ {
+ try
+ {
+ this.xMSF = xMSF;
+ systemDialog = (XInterface) xMSF.createInstance(ServiceName);
+ xFilePicker = (XFilePicker) UnoRuntime.queryInterface(XFilePicker.class, systemDialog);
+ xFolderPicker = (XFolderPicker) UnoRuntime.queryInterface(XFolderPicker.class, systemDialog);
+ xFilterManager = (XFilterManager) UnoRuntime.queryInterface(XFilterManager.class, systemDialog);
+ xInitialize = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, systemDialog);
+ xExecutable = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, systemDialog);
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, systemDialog);
+ xFilePickerControlAccess = (XFilePickerControlAccess) UnoRuntime.queryInterface(XFilePickerControlAccess.class, systemDialog);
+ xStringSubstitution = createStringSubstitution(xMSF);
+ Short[] listAny = new Short[]
+ {
+ new Short(type)
+ };
+ if (xInitialize != null)
+ {
+ xInitialize.initialize(listAny);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ }
+
+ public static SystemDialog createStoreDialog(XMultiServiceFactory xmsf)
+ {
+ return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FilePicker", TemplateDescription.FILESAVE_AUTOEXTENSION);
+ }
+
+ public static SystemDialog createOpenDialog(XMultiServiceFactory xmsf)
+ {
+ return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FilePicker", TemplateDescription.FILEOPEN_SIMPLE);
+ }
+
+ public static SystemDialog createFolderDialog(XMultiServiceFactory xmsf)
+ {
+ return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.FolderPicker", (short) 0);
+ }
+
+ public static SystemDialog createOfficeFolderDialog(XMultiServiceFactory xmsf)
+ {
+ return new SystemDialog(xmsf, "com.sun.star.ui.dialogs.OfficeFolderPicker", (short) 0);
+ }
+
+ private String subst(String path)
+ {
+ try
+ {
+ //System.out.println("SystemDialog.subst:");
+ //System.out.println(path);
+ String s = xStringSubstitution.substituteVariables(path, false);
+ //System.out.println(s);
+ return s;
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return path;
+ }
+ }
+
+ /**
+ * ATTENTION a BUG : The extension calculated
+ * here gives the last 3 chars of the filename - what
+ * if the extension is of 4 or more chars?
+ *
+ * @param DisplayDirectory
+ * @param DefaultName
+ * @param sDocuType
+ * @return
+ */
+ public String callStoreDialog(String DisplayDirectory, String DefaultName, String sDocuType)
+ {
+ String sExtension = DefaultName.substring(DefaultName.length() - 3, DefaultName.length());
+ addFilterToDialog(sExtension, sDocuType, true);
+ return callStoreDialog(DisplayDirectory, DefaultName);
+ }
+
+ /**
+ *
+ * @param displayDir
+ * @param defaultName
+ * given url to a local path.
+ * @return
+ */
+ public String callStoreDialog(String displayDir, String defaultName)
+ {
+ sStorePath = null;
+ try
+ {
+ xFilePickerControlAccess.setValue(com.sun.star.ui.dialogs.ExtendedFilePickerElementIds.CHECKBOX_AUTOEXTENSION, (short) 0, new Boolean(true));
+ xFilePicker.setDefaultName(defaultName);
+ xFilePicker.setDisplayDirectory(subst(displayDir));
+ if (execute(xExecutable))
+ {
+ String[] sPathList = xFilePicker.getFiles();
+ sStorePath = sPathList[0];
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ return sStorePath;
+ }
+
+ public String callFolderDialog(String title, String description, String displayDir)
+ {
+ try
+ {
+ xFolderPicker.setDisplayDirectory(subst(displayDir));
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iae)
+ {
+ iae.printStackTrace();
+ throw new IllegalArgumentException(iae.getMessage());
+ }
+ xFolderPicker.setTitle(title);
+ xFolderPicker.setDescription(description);
+ if (execute(xFolderPicker))
+ {
+ return xFolderPicker.getDirectory();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private boolean execute(XExecutableDialog execDialog)
+ {
+ return execDialog.execute() == 1;
+ }
+
+ public String[] callOpenDialog(boolean multiSelect, String displayDirectory)
+ {
+
+ try
+ {
+ xFilePicker.setMultiSelectionMode(multiSelect);
+ xFilePicker.setDisplayDirectory(subst(displayDirectory));
+ if (execute(xExecutable))
+ {
+ return xFilePicker.getFiles();
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ return null;
+ }
+
+ //("writer_StarOffice_XML_Writer_Template") 'StarOffice XML (Writer)
+ public void addFilterToDialog(String sExtension, String filterName, boolean setToDefault)
+ {
+ try
+ {
+ //get the localized filtername
+ String uiName = getFilterUIName(filterName);
+ String pattern = "*." + sExtension;
+
+ //add the filter
+ addFilter(uiName, pattern, setToDefault);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void addFilter(String uiName, String pattern, boolean setToDefault)
+ {
+ try
+ {
+ xFilterManager.appendFilter(uiName, pattern);
+ if (setToDefault)
+ {
+ xFilterManager.setCurrentFilter(uiName);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * converts the name returned from getFilterUIName_(...) so the
+ * product name is correct.
+ * @param filterName
+ * @return
+ */
+ private String getFilterUIName(String filterName)
+ {
+ String prodName = Configuration.getProductName(xMSF);
+ String[][] s = new String[][]
+ {
+ {
+ getFilterUIName_(filterName)
+ }
+ };
+ s[0][0] = JavaTools.replaceSubString(s[0][0], prodName, "%productname%");
+ return s[0][0];
+ }
+
+ /**
+ * note the result should go through conversion of the product name.
+ * @param filterName
+ * @return the UI localized name of the given filter name.
+ */
+ private String getFilterUIName_(String filterName)
+ {
+ try
+ {
+ Object oFactory = xMSF.createInstance("com.sun.star.document.FilterFactory");
+ Object oObject = Helper.getUnoObjectbyName(oFactory, filterName);
+ Object oArrayObject = AnyConverter.toArray(oObject);
+ PropertyValue[] xPropertyValue = (PropertyValue[]) oArrayObject; //UnoRuntime.queryInterface(XPropertyValue.class, oObject);
+ int MaxCount = xPropertyValue.length;
+ for (int i = 0; i < MaxCount; i++)
+ {
+ PropertyValue aValue = xPropertyValue[i];
+ if (aValue != null && aValue.Name.equals("UIName"))
+ {
+ return AnyConverter.toString(aValue.Value);
+ }
+ }
+ throw new NullPointerException("UIName property not found for Filter " + filterName);
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public static int showErrorBox(XMultiServiceFactory xMSF, String ResName, String ResPrefix, int ResID, String AddTag, String AddString)
+ {
+ Resource oResource;
+ String ProductName = Configuration.getProductName(xMSF);
+ oResource = new Resource(xMSF, ResName, ResPrefix);
+ String sErrorMessage = oResource.getResText(ResID);
+ sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME");
+ sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>");
+ sErrorMessage = JavaTools.replaceSubString(sErrorMessage, AddString, AddTag);
+ return SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage);
+ }
+
+ public static int showErrorBox(XMultiServiceFactory xMSF, String ResName, String ResPrefix, int ResID)
+ {
+ Resource oResource;
+ String ProductName = Configuration.getProductName(xMSF);
+ oResource = new Resource(xMSF, ResName, ResPrefix);
+ String sErrorMessage = oResource.getResText(ResID);
+ sErrorMessage = JavaTools.replaceSubString(sErrorMessage, ProductName, "%PRODUCTNAME");
+ sErrorMessage = JavaTools.replaceSubString(sErrorMessage, String.valueOf((char) 13), "<BR>");
+ return showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage);
+ }
+
+ /*
+ * example:
+ * (xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, "message")
+ */
+ /**
+ * @param windowServiceName one of the following strings:
+ * "ErrorBox", "WarningBox", "MessBox", "InfoBox", "QueryBox".
+ * There are other values possible, look
+ * under src/toolkit/source/awt/vcltoolkit.cxx
+ * @param windowAttribute see com.sun.star.awt.VclWindowPeerAttribute
+ * @return 0 = cancel, 1 = ok, 2 = yes, 3 = no(I'm not sure here)
+ * other values check for yourself ;-)
+ */
+ public static int showMessageBox(XMultiServiceFactory xMSF, String windowServiceName, int windowAttribute, String MessageText)
+ {
+
+ short iMessage = 0;
+ try
+ {
+ if (MessageText == null)
+ {
+ return 0;
+ }
+ XFrame xFrame = Desktop.getActiveFrame(xMSF);
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow());
+ return showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return iMessage;
+ }
+
+ /**
+ * just like the other showMessageBox(...) method, but recieves a
+ * peer argument to use to create the message box.
+ * @param xMSF
+ * @param peer
+ * @param windowServiceName
+ * @param windowAttribute
+ * @param MessageText
+ * @return
+ */
+ public static int showMessageBox(XMultiServiceFactory xMSF, XWindowPeer peer, String windowServiceName, int windowAttribute, String MessageText)
+ {
+ // If the peer is null we try to get one from the desktop...
+ if (peer == null)
+ {
+ return showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText);
+ }
+ short iMessage = 0;
+ try
+ {
+ XInterface xAWTToolkit = (XInterface) xMSF.createInstance("com.sun.star.awt.Toolkit");
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, xAWTToolkit);
+ com.sun.star.awt.WindowDescriptor oDescriptor = new com.sun.star.awt.WindowDescriptor();
+ oDescriptor.WindowServiceName = windowServiceName;
+ oDescriptor.Parent = peer;
+ oDescriptor.Type = com.sun.star.awt.WindowClass.MODALTOP;
+ oDescriptor.WindowAttributes = windowAttribute;
+ XWindowPeer xMsgPeer = xToolkit.createWindow(oDescriptor);
+ XMessageBox xMsgbox = (XMessageBox) UnoRuntime.queryInterface(XMessageBox.class, xMsgPeer);
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xMsgbox);
+ xMsgbox.setMessageText(MessageText);
+ iMessage = xMsgbox.execute();
+ xComponent.dispose();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace(System.out);
+ }
+ return iMessage;
+ }
+
+ public static XStringSubstitution createStringSubstitution(XMultiServiceFactory xMSF)
+ {
+ Object xPathSubst = null;
+ try
+ {
+ xPathSubst = xMSF.createInstance(
+ "com.sun.star.util.PathSubstitution");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ e.printStackTrace();
+ }
+ if (xPathSubst != null)
+ {
+ return (XStringSubstitution) UnoRuntime.queryInterface(
+ XStringSubstitution.class, xPathSubst);
+ }
+ else
+ {
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/TerminateWizardException.java b/wizards/com/sun/star/wizards/common/TerminateWizardException.java
new file mode 100644
index 000000000000..124d98f9ff31
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/TerminateWizardException.java
@@ -0,0 +1,43 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.common;
+
+// import com.sun.star.wizards.common.Resource;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class TerminateWizardException extends Exception
+{
+
+ public TerminateWizardException(XMultiServiceFactory xMSF)
+ {
+ Resource oResource = new Resource(xMSF, "AutoPilot", "dbw");
+ String sErrorMessage = oResource.getResText(1006);
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", com.sun.star.awt.VclWindowPeerAttribute.OK, sErrorMessage);
+ printStackTrace(System.out);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/UCB.java b/wizards/com/sun/star/wizards/common/UCB.java
new file mode 100644
index 000000000000..5e3ad00698df
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/UCB.java
@@ -0,0 +1,269 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * Created on 31.10.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.common;
+
+import java.util.List;
+import java.util.Vector;
+
+import com.sun.star.beans.Property;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.ucb.*;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * @author rpiterman
+ * This class is used to copy the content of a folder to
+ * another folder.
+ * There is an incosistency with argument order.
+ * It should be always: dir,filename.
+ */
+public class UCB
+{
+
+ private Object ucb;
+ private FileAccess fa;
+
+ public UCB(XMultiServiceFactory xmsf) throws Exception
+ {
+ String[] keys = new String[2];
+ keys[ 0 ] = "Local";
+ keys[ 1 ] = "Office";
+ ucb = xmsf.createInstanceWithArguments(
+ "com.sun.star.ucb.UniversalContentBroker", keys );
+ fa = new FileAccess(xmsf);
+ }
+
+ public void deleteDirContent(String dir)
+ throws Exception
+ {
+ if (!fa.exists(dir,true))
+ {
+ return;
+ }
+ List l = listFiles(dir,null);
+ for (int i = 0; i<l.size(); i++)
+ {
+ delete(FileAccess.connectURLs(dir ,(String)l.get(i)));
+ }
+ }
+
+ public void delete(String filename) throws Exception
+ {
+ //System.out.println("UCB.delete(" + filename);
+ executeCommand( getContent(filename),"delete",Boolean.TRUE);
+ }
+
+ public void copy(String sourceDir, String targetDir) throws Exception
+ {
+ copy(sourceDir,targetDir,(Verifier)null);
+ }
+
+ public void copy(String sourceDir, String targetDir, Verifier verifier) throws Exception
+ {
+ List files = listFiles(sourceDir,verifier);
+ for (int i = 0; i<files.size(); i++)
+ {
+ copy(sourceDir, (String)files.get(i), targetDir);
+ }
+
+ }
+
+ public void copy(String sourceDir, String filename, String targetDir, String targetName) throws Exception
+ {
+ if (!fa.exists(targetDir,true))
+ {
+ fa.fileAccess.createFolder(targetDir);
+ }
+ //System.out.println("UCB.copy(" + sourceDir + ", " + filename + ", " + targetDir+ ", " + targetName);
+ executeCommand(ucb, "globalTransfer", copyArg(sourceDir,filename, targetDir,targetName));
+ }
+
+ /**
+ * @deprecated
+ * @param sourceDir
+ * @param filename
+ * @param targetDir
+ * @throws Exception
+ */
+ public void copy(String sourceDir, String filename, String targetDir) throws Exception
+ {
+ copy(sourceDir,filename, targetDir, "");
+ }
+
+ /**
+ * target name can be "", in which case the name stays lige the source name
+ * @param sourceDir
+ * @param sourceFilename
+ * @param targetDir
+ * @param targetFilename
+ * @return
+ */
+ public GlobalTransferCommandArgument copyArg(String sourceDir, String sourceFilename, String targetDir, String targetFilename)
+ {
+
+ GlobalTransferCommandArgument aArg = new GlobalTransferCommandArgument();
+ aArg.Operation = TransferCommandOperation.COPY;
+ aArg.SourceURL = fa.getURL(sourceDir,sourceFilename);
+ aArg.TargetURL = targetDir;
+ aArg.NewTitle = targetFilename;
+ // fail, if object with same name exists in target folder
+ aArg.NameClash = NameClash.OVERWRITE;
+ return aArg;
+ }
+
+ public Object executeCommand(Object xContent, String aCommandName, Object aArgument)
+ throws com.sun.star.ucb.CommandAbortedException,
+ com.sun.star.uno.Exception
+ {
+ XCommandProcessor xCmdProcessor = (XCommandProcessor)UnoRuntime.queryInterface(
+ XCommandProcessor.class, xContent);
+ Command aCommand = new Command();
+ aCommand.Name = aCommandName;
+ aCommand.Handle = -1; // not available
+ aCommand.Argument = aArgument;
+ return xCmdProcessor.execute(aCommand, 0, null);
+ }
+
+ public List listFiles(String path, Verifier verifier) throws Exception
+ {
+ Object xContent = getContent(path);
+
+ OpenCommandArgument2 aArg = new OpenCommandArgument2();
+ aArg.Mode = OpenMode.ALL;
+ aArg.Priority = 32768;
+
+ // Fill info for the properties wanted.
+ aArg.Properties = new Property[] {new Property()};
+
+ aArg.Properties[0].Name = "Title";
+ aArg.Properties[0].Handle = -1;
+
+ XDynamicResultSet xSet;
+
+ xSet = (XDynamicResultSet)UnoRuntime.queryInterface(
+ XDynamicResultSet.class,executeCommand(xContent, "open", aArg));
+
+ XResultSet xResultSet = xSet.getStaticResultSet();
+
+ List files = new Vector();
+
+ if (xResultSet.first())
+ {
+ // obtain XContentAccess interface for child content access and XRow for properties
+ XContentAccess xContentAccess = (XContentAccess)UnoRuntime.queryInterface(
+ XContentAccess.class, xResultSet);
+ XRow xRow = (XRow)UnoRuntime.queryInterface(XRow.class, xResultSet);
+ do
+ {
+ // Obtain URL of child.
+ String aId = xContentAccess.queryContentIdentifierString();
+ // First column: Title (column numbers are 1-based!)
+ String aTitle = xRow.getString(1);
+ if (aTitle.length() == 0 && xRow.wasNull())
+ {
+ ; //ignore
+ }
+ else
+ {
+ files.add(aTitle);
+ }
+ }
+ while (xResultSet.next()); // next child
+ }
+
+ if (verifier != null)
+ {
+ for (int i = 0; i<files.size(); i++)
+ {
+ if (!verifier.verify(files.get(i)))
+ {
+ files.remove(i--);
+ }
+ }
+ }
+
+ return files;
+ }
+
+ public Object getContentProperty(Object content, String propName, Class type)
+ throws Exception
+ {
+ Property[] pv = new Property[1];
+ pv[0] = new Property();
+ pv[0].Name = propName;
+ pv[0].Handle = -1;
+
+ Object row = executeCommand(content,"getPropertyValues",pv);
+ XRow xrow = (XRow)UnoRuntime.queryInterface(XRow.class,row);
+ if (type.equals(String.class))
+ {
+ return xrow.getString(1);
+ }
+ else if (type.equals(Boolean.class))
+ {
+ return xrow.getBoolean(1) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (type.equals(Integer.class))
+ {
+ return new Integer(xrow.getInt(1));
+ }
+ else if (type.equals(Short.class))
+ {
+ return new Short(xrow.getShort(1));
+ }
+ else
+ {
+ return null;
+ }
+
+ }
+
+ public Object getContent(String path) throws Exception
+ {
+ //System.out.println("Getting Content for : " + path);
+ XContentIdentifier id = ((XContentIdentifierFactory) UnoRuntime.queryInterface(XContentIdentifierFactory.class, ucb)).createContentIdentifier(path);
+
+ return ((XContentProvider)UnoRuntime.queryInterface(
+ XContentProvider.class,ucb)).queryContent(id);
+ }
+
+ public static interface Verifier
+ {
+
+ public boolean verify(Object object);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/XMLHelper.java b/wizards/com/sun/star/wizards/common/XMLHelper.java
new file mode 100644
index 000000000000..326ba03fbeea
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/XMLHelper.java
@@ -0,0 +1,74 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * XMLHelper.java
+ *
+ * Created on 30. September 2003, 15:38
+ */
+package com.sun.star.wizards.common;
+
+import org.w3c.dom.*;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class XMLHelper
+{
+
+ public static Node addElement(Node parent, String name, String[] attNames, String[] attValues)
+ {
+ Document doc = parent.getOwnerDocument();
+ if (doc == null)
+ {
+ doc = (Document) parent;
+ }
+ Element e = doc.createElement(name);
+ for (int i = 0; i < attNames.length; i++)
+ {
+ if (attValues[i] != null && (!attValues[i].equals("")))
+ {
+ e.setAttribute(attNames[i], attValues[i]);
+ }
+ }
+ parent.appendChild(e);
+ return e;
+ }
+
+ public static Node addElement(Node parent, String name, String attNames, String attValues)
+ {
+ return addElement(parent, name, new String[]
+ {
+ attNames
+ }, new String[]
+ {
+ attValues
+ });
+ }
+}
diff --git a/wizards/com/sun/star/wizards/common/XMLProvider.java b/wizards/com/sun/star/wizards/common/XMLProvider.java
new file mode 100644
index 000000000000..f5c2fd662d31
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/XMLProvider.java
@@ -0,0 +1,46 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * XMLSupplier.java
+ *
+ * Created on 19. September 2003, 11:52
+ */
+package com.sun.star.wizards.common;
+
+import org.w3c.dom.Node;
+
+/**
+ *
+ * @author rpiterman
+ */
+public interface XMLProvider
+{
+
+ public Node createDOM(Node parent);
+}
diff --git a/wizards/com/sun/star/wizards/common/delzip b/wizards/com/sun/star/wizards/common/delzip
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/common/delzip
diff --git a/wizards/com/sun/star/wizards/db/BlindtextCreator.java b/wizards/com/sun/star/wizards/db/BlindtextCreator.java
new file mode 100644
index 000000000000..b52381def054
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/BlindtextCreator.java
@@ -0,0 +1,113 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.wizards.common.JavaTools;
+
+/**
+ *
+ * @author bc93774
+ */
+public class BlindtextCreator
+{
+
+ public static final String BlindText =
+ "Ut wisi enim ad minim veniam, quis nostrud exerci tation " + "ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor " + "in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at " + "vero et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore " + "te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy " + "nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, " + "quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. " + "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum " + "dolore eu feugiat nulla facilisis at vero et accumsan et iusto odio dignissim qui blandit praesent " + "luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Nam liber tempor cum soluta nobis " + "eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum.";
+
+ public static String adjustBlindTextlength(String FieldTitle, int FieldWidth, boolean bIsCurLandscape, boolean bIsGroupTable, String[] _RecordFieldNames)
+ {
+ String BlindTextString = "";
+ if (bIsGroupTable)
+ {
+ return getBlindTextString(FieldTitle, FieldWidth, FieldWidth);
+ }
+ int MaxFieldCount = getMaxFieldCount(bIsCurLandscape);
+ if (_RecordFieldNames.length <= 2 * MaxFieldCount)
+ {
+ if (_RecordFieldNames.length <= MaxFieldCount)
+ {
+ BlindTextString = getBlindTextString(FieldTitle, FieldWidth, FieldWidth);
+ }
+ else
+ {
+ BlindTextString = getBlindTextString(FieldTitle, FieldWidth, (int) (0.5 * FieldWidth));
+ }
+ }
+ else
+ {
+ BlindTextString = getBlindTextString(FieldTitle, FieldWidth, (int) 1.1 * FieldTitle.length());
+ }
+ return BlindTextString;
+ }
+
+ public static String getBlindTextString(String FieldTitle, int FieldWidth, int MaxWidth)
+ {
+ String[] BlindTextArray = JavaTools.ArrayoutofString(BlindText, " ");
+ String PartBlindText = BlindTextArray[0];
+ String NewPartBlindText;
+ int MaxHeaderWidth;
+ int iWidth = FieldWidth;
+ int Titlelength = (int) 1.1 * FieldTitle.length(); // We assume that the TableHeading is bold
+
+ if (Titlelength > PartBlindText.length())
+ {
+ MaxHeaderWidth = Titlelength;
+ }
+ else
+ {
+ MaxHeaderWidth = PartBlindText.length();
+ }
+ if (MaxHeaderWidth > MaxWidth)
+ {
+ MaxWidth = MaxHeaderWidth;
+ }
+ int i = 1;
+ do
+ {
+ NewPartBlindText = PartBlindText + " " + BlindTextArray[i];
+ if (NewPartBlindText.length() < MaxWidth)
+ {
+ PartBlindText = NewPartBlindText;
+ i += 1;
+ }
+ }
+ while (NewPartBlindText.length() < MaxWidth);
+ return PartBlindText;
+ }
+
+ private static int getMaxFieldCount(boolean bIsCurLandscape)
+ {
+ if (bIsCurLandscape == true)
+ {
+ return 5;
+ }
+ else
+ {
+ return 3;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/ColumnPropertySet.java b/wizards/com/sun/star/wizards/db/ColumnPropertySet.java
new file mode 100644
index 000000000000..204ba2328321
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/ColumnPropertySet.java
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.wizards.common.Properties;
+// import com.sun.star.wizards.db.TypeInspector;
+
+public class ColumnPropertySet
+{
+
+ TypeInspector oTypeInspector;
+ public XPropertySet xPropertySet;
+ private int nType;
+ private String sTypeName = "";
+
+ public ColumnPropertySet(TypeInspector _oTypeInspector, XPropertySet _xPropertySet)
+ {
+ xPropertySet = _xPropertySet;
+ oTypeInspector = _oTypeInspector;
+ }
+
+ private PropertyValue[] propertySet2PropertyValueArray(XPropertySet _xNewPropertySet) throws com.sun.star.uno.Exception
+ {
+ Property[] props = _xNewPropertySet.getPropertySetInfo().getProperties();
+ PropertyValue[] ret = new PropertyValue[props.length];
+ for (int i = 0; i < props.length; i++)
+ {
+ PropertyValue val = new PropertyValue();
+ val.Name = props[i].Name;
+ val.Value = _xNewPropertySet.getPropertyValue(val.Name);
+ ret[i] = val;
+ }
+ return ret;
+ }
+
+ private void assignPropertyValues(String _sNewName, PropertyValue[] _aNewColPropertyValues, boolean _bsetDefaultProperties)
+ {
+ try
+ {
+ nType = ((Integer) Properties.getPropertyValue(_aNewColPropertyValues, "Type")).intValue();
+ nType = oTypeInspector.convertDataType(nType);
+ if (Properties.hasPropertyValue(_aNewColPropertyValues, "TypeName"))
+ {
+ sTypeName = (String) Properties.getPropertyValue(_aNewColPropertyValues, "TypeName");
+ }
+ Integer precision = null;
+ if (Properties.hasPropertyValue(_aNewColPropertyValues, "Precision"))
+ {
+ precision = (Integer) Properties.getPropertyValue(_aNewColPropertyValues, "Precision");
+
+ }
+ if ((nType == DataType.VARCHAR) && (precision == null || precision.intValue() == 0))
+ {
+ precision = new Integer(50);
+ }
+ if (precision != null)
+ {
+ xPropertySet.setPropertyValue("Precision", precision);
+ }
+ setType(nType, sTypeName, precision);
+ for (int i = 0; i < _aNewColPropertyValues.length; i++)
+ {
+ String sPropName = _aNewColPropertyValues[i].Name;
+ if (_sNewName != null && sPropName.equals("Name"))
+ {
+ xPropertySet.setPropertyValue("Name", _sNewName);
+ }
+ else if (sPropName.equals("Precision"))
+ {
+ // do nothing, see above
+ }
+ else if ((!sPropName.equals("Type")) && (!sPropName.equals("TypeName")))
+ {
+ Object oColValue = _aNewColPropertyValues[i].Value;
+ assignPropertyValue(sPropName, oColValue);
+ }
+ }
+ if (_bsetDefaultProperties)
+ {
+ assignPropertyValue("IsNullable", new Integer(oTypeInspector.isNullable(xPropertySet)));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ }
+
+ public void assignPropertyValues(PropertyValue[] _aNewColPropertyValues, boolean _bsetDefaultProperties)
+ {
+ assignPropertyValues(null /* dont change the name */, _aNewColPropertyValues, _bsetDefaultProperties);
+ }
+
+ public void assignNewPropertySet(String _sNewName, XPropertySet _xNewPropertySet)
+ {
+ try
+ {
+ assignPropertyValues(
+ _sNewName, propertySet2PropertyValueArray(_xNewPropertySet), false /*setDefaultProperties*/);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private int getPrecision()
+ {
+ try
+ {
+ return ((Integer) xPropertySet.getPropertyValue("Precision")).intValue();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return 0;
+ }
+ }
+
+ private void setType(int _nType, String _sTypeName, Integer precision)
+ {
+ if (_sTypeName.equals(""))
+ {
+ sTypeName = oTypeInspector.getDefaultTypeName(nType, precision);
+ }
+ else
+ {
+ sTypeName = _sTypeName;
+ }
+ nType = oTypeInspector.getDataType(sTypeName);
+ assignPropertyValue("Type", new Integer(nType));
+ assignPropertyValue("TypeName", sTypeName);
+ }
+
+ private void assignPropertyValue(String _spropname, Object _oValue)
+ {
+ try
+ {
+ if (_spropname.equals("Type"))
+ {
+ nType = ((Integer) _oValue).intValue();
+ xPropertySet.setPropertyValue("Type", new Integer(nType));
+ }
+ else if (_spropname.equals("Name"))
+ {
+ String sName = (String) _oValue;
+ if (!sName.equals(""))
+ {
+ xPropertySet.setPropertyValue("Name", sName);
+ }
+ }
+ else if (_spropname.equals("Scale"))
+ {
+ int nScale = ((Integer) _oValue).intValue();
+ nScale = oTypeInspector.getScale(xPropertySet);
+ xPropertySet.setPropertyValue("Scale", new Integer(nScale));
+ }
+ else if (_spropname.equals("IsNullable"))
+ {
+ int nNullability = ((Integer) _oValue).intValue();
+ nNullability = oTypeInspector.getNullability(xPropertySet, nNullability);
+ xPropertySet.setPropertyValue("IsNullable", new Integer(nNullability));
+ }
+ else if (_spropname.equals("TypeName"))
+ {
+ String sTypeName = (String) _oValue;
+ xPropertySet.setPropertyValue("TypeName", sTypeName);
+ }
+ else
+ {
+ xPropertySet.setPropertyValue(_spropname, _oValue);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private int getType()
+ {
+ return nType;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/CommandMetaData.java b/wizards/com/sun/star/wizards/db/CommandMetaData.java
new file mode 100644
index 000000000000..ad54020e8645
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/CommandMetaData.java
@@ -0,0 +1,772 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.db;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbcx.KeyType;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.sdbcx.XKeysSupplier;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.lang.Locale;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.embed.EntryInitModes;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NumberFormatter;
+import com.sun.star.wizards.common.Resource;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Vector;
+
+public class CommandMetaData extends DBMetaData
+{
+ public Map FieldTitleSet = new HashMap();
+ public String[] m_aAllFieldNames = new String[]{};
+ public FieldColumn[] FieldColumns = new FieldColumn[]{};
+ public String[] GroupFieldNames = new String[] {};
+ private String[][] SortFieldNames = new String[][] {};
+ private String[] RecordFieldNames = new String[] {};
+ public String[][] AggregateFieldNames = new String[][] {};
+ public String[] NumericFieldNames = new String[] {};
+ public String[] NonAggregateFieldNames;
+ private int CommandType;
+ private String Command;
+ boolean bCatalogAtStart = true;
+ String sCatalogSep = "";
+ String sIdentifierQuote = "";
+ boolean bCommandComposerAttributesalreadyRetrieved = false;
+
+
+ private XIndexAccess xIndexKeys;
+
+ public CommandMetaData(XMultiServiceFactory xMSF, Locale _aLocale, NumberFormatter oNumberFormatter)
+ {
+ super(xMSF, _aLocale, oNumberFormatter);
+ }
+
+ public CommandMetaData(XMultiServiceFactory xMSF)
+ {
+ super(xMSF);
+ }
+
+
+ public void initializeFieldColumns(boolean _bgetDefaultValue, String _CommandName, String[] _FieldNames)
+ {
+ this.setCommandName(_CommandName);
+ FieldColumns = new FieldColumn[_FieldNames.length];
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ FieldColumns[i] = new FieldColumn(this, _FieldNames[i], this.getCommandName(), false);
+// if (_bgetDefaultValue)
+// {
+// FieldColumns[i].getDefaultValue();
+// }
+ }
+ }
+
+
+ public void initializeFieldColumns(String[] _FieldNames, XNameAccess _xColumns)
+ {
+ FieldColumns = new FieldColumn[_FieldNames.length];
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ FieldColumns[i] = new FieldColumn(this,_xColumns, _FieldNames[i] );
+ }
+ }
+
+
+ public void initializeFieldColumns(String[] _FieldNames, String _CommandName)
+ {
+ this.setCommandName(_CommandName);
+ FieldColumns = new FieldColumn[_FieldNames.length];
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ FieldColumns[i] = new FieldColumn(this, _FieldNames[i], _CommandName, false);
+ if (FieldTitleSet != null)
+ {
+ if (FieldTitleSet.containsKey(_FieldNames[i]))
+ {
+ FieldColumns[i].setFieldTitle( (String) FieldTitleSet.get(_FieldNames[i]) );
+ if (FieldColumns[i].getFieldTitle() == null)
+ {
+ FieldColumns[i].setFieldTitle( _FieldNames[i] );
+ FieldTitleSet.put(_FieldNames[i], _FieldNames[i]);
+ }
+ }
+ }
+ }
+ }
+
+ public Map getFieldTitleSet()
+ {
+ return FieldTitleSet;
+ }
+
+
+ public XPropertySet getColumnObjectByFieldName(String _FieldName, boolean _bgetByDisplayName)
+ {
+ try
+ {
+ FieldColumn CurFieldColumn = null;
+ if (_bgetByDisplayName)
+ {
+ CurFieldColumn = this.getFieldColumnByDisplayName(_FieldName);
+ }
+ else
+ {
+ CurFieldColumn = this.getFieldColumnByFieldName(_FieldName);
+ }
+ String CurCommandName = CurFieldColumn.getCommandName();
+ CommandObject oCommand = getTableByName(CurCommandName);
+ Object oColumn = oCommand.getColumns().getByName(CurFieldColumn.getFieldName());
+ XPropertySet xColumn = UnoRuntime.queryInterface( XPropertySet.class, oColumn );
+ return xColumn;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+
+ // @SuppressWarnings("unchecked")
+ public void prependSortFieldNames(String[] _fieldnames)
+ {
+ Vector aSortFields = new Vector();
+ for (int i = 0; i < _fieldnames.length; i++)
+ {
+ String[] sSortFieldName = new String[2];
+ sSortFieldName[0] = _fieldnames[i];
+ int index = JavaTools.FieldInTable(SortFieldNames, _fieldnames[i]);
+ if (index > -1)
+
+ {
+ sSortFieldName[1] = SortFieldNames[index][1];
+ }
+ else
+
+ {
+ sSortFieldName[1] = "ASC";
+ }
+ aSortFields.add(sSortFieldName);
+ }
+ for (int i = 0; i < SortFieldNames.length; i++)
+ {
+ if (JavaTools.FieldInList(_fieldnames, SortFieldNames[i][0]) == -1)
+ {
+ aSortFields.add(SortFieldNames[i]);
+ }
+ }
+ SortFieldNames = new String[aSortFields.size()][2];
+ aSortFields.toArray(SortFieldNames);
+ }
+
+ public String[][] getSortFieldNames()
+ {
+ return SortFieldNames;
+ }
+ public void setSortFieldNames(String[][] aNewListList)
+ {
+ SortFieldNames = aNewListList;
+ }
+
+ public FieldColumn getFieldColumn(String _FieldName, String _CommandName)
+ {
+ if (FieldColumns.length > 0)
+ {
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (FieldColumns[i].getFieldName().equals(_FieldName))
+
+ {
+ if (FieldColumns[i].getCommandName().equals(_CommandName))
+ {
+ return FieldColumns[i];
+ }
+ }
+ }
+ }
+ return null;
+ }
+
+
+
+ public FieldColumn getFieldColumnByFieldName(String _FieldName)
+ {
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ String sFieldName = FieldColumns[i].getFieldName();
+ if (sFieldName.equals(_FieldName))
+ {
+ return FieldColumns[i];
+ }
+ if (_FieldName.indexOf('.') == -1)
+ {
+ String sCompound = Command + "." + _FieldName;
+ if (sFieldName.equals(sCompound))
+ {
+ return FieldColumns[i];
+ }
+ }
+ }
+ throw new com.sun.star.uno.RuntimeException();
+ }
+
+
+ public FieldColumn getFieldColumnByDisplayName(String _DisplayName)
+ {
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ String sDisplayName = FieldColumns[i].getDisplayFieldName();
+ if (sDisplayName.equals(_DisplayName))
+ {
+ return FieldColumns[i];
+ }
+ if (_DisplayName.indexOf('.') == -1)
+ {
+ String sCompound = Command + "." + _DisplayName;
+ if (sDisplayName.equals(sCompound))
+ {
+ return FieldColumns[i];
+ }
+ }
+ }
+ throw new com.sun.star.uno.RuntimeException();
+ }
+
+
+ public FieldColumn getFieldColumnByTitle(String _FieldTitle)
+ {
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (FieldColumns[i].getFieldTitle().equals(_FieldTitle))
+ {
+ return FieldColumns[i];
+ }
+ }
+ // throw new com.sun.star.uno.RuntimeException();
+ // LLA: Group works with fields direct
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (FieldColumns[i].getFieldName().equals(_FieldTitle))
+ {
+ return FieldColumns[i];
+ }
+ }
+ throw new com.sun.star.uno.RuntimeException();
+ }
+
+
+ public boolean getFieldNamesOfCommand(String _commandname, int _commandtype, boolean _bAppendMode)
+ {
+ try
+ {
+ // Object oField;
+ java.util.Vector<String> ResultFieldNames = new java.util.Vector<String>(10);
+ String[] FieldNames;
+ CommandObject oCommand = this.getCommandByName(_commandname, _commandtype);
+ FieldNames = oCommand.getColumns().getElementNames();
+ if (FieldNames.length > 0)
+ {
+ for (int n = 0; n < FieldNames.length; n++)
+ {
+ final String sFieldName = FieldNames[n];
+ Object oField = oCommand.getColumns().getByName(sFieldName);
+ int iType = AnyConverter.toInt(Helper.getUnoPropertyValue(oField, "Type"));
+ // BinaryFieldTypes are not included in the WidthList
+ if (JavaTools.FieldInIntTable(WidthList, iType) >= 0)
+ {
+// if (_bAppendMode)
+// ResultFieldNames.addElement(_commandname + "." + FieldNames[n]);
+// else
+ ResultFieldNames.addElement(sFieldName);
+ }
+ else if (JavaTools.FieldInIntTable(BinaryTypes, iType) >= 0)
+ {
+ ResultFieldNames.addElement(sFieldName);
+ }
+ }
+ // FieldNames = new String[FieldNames.length];
+ // FieldTypes = new int[FieldNames.length];
+ m_aAllFieldNames = new String[ResultFieldNames.size()];
+ ResultFieldNames.copyInto(m_aAllFieldNames);
+ return true;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ Resource oResource = new Resource(xMSF, "Database", "dbw");
+ String sMsgNoFieldsFromCommand = oResource.getResText(RID_DB_COMMON + 45);
+ sMsgNoFieldsFromCommand = JavaTools.replaceSubString(sMsgNoFieldsFromCommand, _commandname, "%NAME");
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgNoFieldsFromCommand);
+ return false;
+ }
+
+
+
+
+
+
+ public String[] getOrderableColumns(String[] _fieldnames)
+ {
+ Vector<String> aOrderableColumns = new Vector<String>();
+ int ncount = 0;
+ for (int i = 0; i < _fieldnames.length; i++)
+ {
+ FieldColumn ofieldcolumn = getFieldColumnByFieldName(_fieldnames[i]);
+ if (getDBDataTypeInspector().isColumnOrderable(ofieldcolumn.getXColumnPropertySet()))
+ {
+ aOrderableColumns.addElement(_fieldnames[i]);
+ ncount++;
+ }
+ }
+ String[] sretfieldnames = new String[ncount];
+ aOrderableColumns.toArray(sretfieldnames);
+ return sretfieldnames;
+ }
+
+
+ /**
+ * @return Returns the command.
+ */
+ public String getCommandName()
+ {
+ return Command;
+ }
+ /**
+ * @param _command The command to set.
+ */
+ public void setCommandName(String _command)
+ {
+ Command = _command;
+ }
+
+ /**
+ * @return Returns the commandType.
+ */
+ public int getCommandType()
+ {
+ return CommandType;
+ }
+
+ /**
+ * @param _commandType The commandType to set.
+ */
+ public void setCommandType(int _commandType)
+ {
+ CommandType = _commandType;
+ }
+
+
+ public boolean isnumeric(FieldColumn _oFieldColumn)
+ {
+ try
+ {
+ CommandObject oTable = super.getTableByName(_oFieldColumn.getCommandName());
+ Object oField = oTable.getColumns().getByName(_oFieldColumn.getFieldName());
+ int iType = AnyConverter.toInt(Helper.getUnoPropertyValue(oField, "Type"));
+ int ifound = java.util.Arrays.binarySearch(NumericTypes, iType);
+ if ((ifound < NumericTypes.length) && (ifound > 0))
+ {
+ return (NumericTypes[ifound] == iType);
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public String[] setNumericFields()
+ {
+ try
+ {
+ Vector<String> numericfieldsvector = new java.util.Vector<String>();
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (isnumeric(FieldColumns[i]))
+ {
+ numericfieldsvector.addElement(FieldColumns[i].getDisplayFieldName());
+ }
+ }
+ NumericFieldNames = new String[numericfieldsvector.size()];
+ numericfieldsvector.toArray(NumericFieldNames);
+ return NumericFieldNames;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return new String[]{};
+ }
+ }
+
+ public String[] getFieldNames(String[] _sDisplayFieldNames, String _sCommandName)
+ {
+ Vector<String> sFieldNamesVector = new java.util.Vector<String>();
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (_sCommandName.equals(FieldColumns[i].getCommandName()))
+ {
+ if (JavaTools.FieldInList(_sDisplayFieldNames, FieldColumns[i].getDisplayFieldName()) > -1)
+ {
+ sFieldNamesVector.addElement(FieldColumns[i].getFieldName());
+ }
+ }
+ }
+ String[] sFieldNames = new String[sFieldNamesVector.size()];
+ sFieldNamesVector.toArray(sFieldNames);
+ return sFieldNames;
+ }
+
+
+
+ public String[] getFieldNames()
+ {
+ String[] sFieldNames = new String[FieldColumns.length];
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ sFieldNames[i] = FieldColumns[i].getFieldName();
+ }
+ return sFieldNames;
+ }
+
+ public String[] getDisplayFieldNames()
+ {
+ String[] sDisplayFieldNames = new String[FieldColumns.length];
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ sDisplayFieldNames[i] = FieldColumns[i].getDisplayFieldName();
+ }
+ return sDisplayFieldNames;
+ }
+
+
+ public String[] setNonAggregateFieldNames()
+ {
+ try
+ {
+ Vector<String> nonaggregatefieldsvector = new java.util.Vector<String>();
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (JavaTools.FieldInTable(AggregateFieldNames, FieldColumns[i].getDisplayFieldName()) == -1)
+ {
+ nonaggregatefieldsvector.addElement(FieldColumns[i].getDisplayFieldName());
+ }
+ }
+ NonAggregateFieldNames = new String[nonaggregatefieldsvector.size()];
+ nonaggregatefieldsvector.toArray(NonAggregateFieldNames);
+ return NonAggregateFieldNames;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return new String[]{};
+ }
+ }
+
+ /**
+ * the fieldnames passed over are not necessarily the ones that are defined in the class
+ * @param _DisplayFieldNames
+ * @return
+ */
+ public boolean hasNumericalFields(String[] _DisplayFieldNames)
+
+ {
+ if (_DisplayFieldNames != null)
+ {
+ if (_DisplayFieldNames.length > 0)
+ {
+ for (int i = 0; i < _DisplayFieldNames.length; i++)
+ {
+ if (isnumeric(getFieldColumnByDisplayName(_DisplayFieldNames[i])))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public String getFieldTitle(String FieldName)
+ {
+ String FieldTitle = FieldName;
+ if (this.FieldTitleSet != null)
+ {
+ FieldTitle = (String) this.FieldTitleSet.get(FieldName); //FieldTitles[TitleIndex];
+ if (FieldTitle == null)
+ {
+ return FieldName;
+ }
+ }
+ return FieldTitle;
+ }
+
+
+ public void setFieldTitles(String[] sFieldTitles)
+ {
+ int nFieldColLength = FieldColumns.length;
+ for (int i = 0; i < sFieldTitles.length; i++)
+ {
+ if (i < nFieldColLength)
+ {
+ FieldColumns[i].setFieldTitle(sFieldTitles[i]);
+ }
+
+ }
+ }
+
+
+ public String[] getFieldTitles()
+ {
+ String[] sFieldTitles = new String[FieldColumns.length];
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ sFieldTitles[i] = FieldColumns[i].getFieldTitle();
+ }
+ return sFieldTitles;
+ }
+
+
+ public void setGroupFieldNames(String[] GroupFieldNames)
+ {
+ this.GroupFieldNames = GroupFieldNames;
+ }
+
+
+ public String[] getGroupFieldNames()
+ {
+ return GroupFieldNames;
+ }
+
+ public void createRecordFieldNames()
+ {
+ String CurFieldName;
+ int GroupFieldCount;
+ int TotFieldCount = FieldColumns.length;
+ // int SortFieldCount = SortFieldNames[0].length;
+ GroupFieldCount = JavaTools.getArraylength(GroupFieldNames);
+ RecordFieldNames = new String[TotFieldCount - GroupFieldCount];
+
+ int a = 0;
+ for (int i = 0; i < TotFieldCount; i++)
+ {
+ CurFieldName = FieldColumns[i].getFieldName();
+ if (JavaTools.FieldInList(GroupFieldNames, CurFieldName) < 0)
+ {
+ RecordFieldNames[a] = CurFieldName;
+ // a += 1;
+ ++a;
+ }
+ }
+ }
+ public void setRecordFieldNames(String [] _aNewList)
+ {
+ RecordFieldNames = _aNewList;
+ }
+ public String[] getRecordFieldNames()
+ {
+ return RecordFieldNames;
+ }
+ public String getRecordFieldName(int i)
+ {
+ return RecordFieldNames[i];
+ }
+
+ /**@deprecated use 'RelationController' class instead
+ *
+ * @param _stablename
+ * @param _ncommandtype
+ * @return
+ */
+ public String[] getReferencedTables(String _stablename, int _ncommandtype)
+ {
+ String[] sTotReferencedTables = new String[]{};
+ try
+ {
+ if (_ncommandtype == com.sun.star.sdb.CommandType.TABLE)
+ {
+ if (xDBMetaData.supportsIntegrityEnhancementFacility())
+ {
+ java.util.Vector<String> TableVector = new java.util.Vector<String>();
+ Object oTable = getTableNamesAsNameAccess().getByName(_stablename);
+ XKeysSupplier xKeysSupplier = UnoRuntime.queryInterface( XKeysSupplier.class, oTable );
+ xIndexKeys = xKeysSupplier.getKeys();
+ for (int i = 0; i < xIndexKeys.getCount(); i++)
+ {
+ XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIndexKeys.getByIndex( i ) );
+ int curtype = AnyConverter.toInt(xPropertySet.getPropertyValue("Type"));
+ if (curtype == KeyType.FOREIGN)
+ {
+ // getImportedKeys (RelationController.cxx /source/ui/relationdesign) /Zeile 475
+ String sreftablename = AnyConverter.toString(xPropertySet.getPropertyValue("ReferencedTable"));
+ if (getTableNamesAsNameAccess().hasByName(sreftablename))
+ {
+ TableVector.addElement(sreftablename);
+ }
+ }
+ }
+ if (TableVector.size() > 0)
+ {
+ sTotReferencedTables = new String[TableVector.size()];
+ TableVector.copyInto(sTotReferencedTables);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return sTotReferencedTables;
+ }
+
+ /**@deprecated use 'RelationController' class instead
+ *
+ * @param _sreferencedtablename
+ * @return
+ */
+ public String[][] getKeyColumns(String _sreferencedtablename)
+ {
+ String[][] skeycolumnnames = null;
+ try
+ {
+ for (int i = 0; i < xIndexKeys.getCount(); i++)
+ {
+ XPropertySet xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xIndexKeys.getByIndex( i ) );
+ int curtype = AnyConverter.toInt(xPropertySet.getPropertyValue("Type"));
+ if (curtype == KeyType.FOREIGN)
+ {
+ String scurreftablename = AnyConverter.toString(xPropertySet.getPropertyValue("ReferencedTable"));
+ if (getTableNamesAsNameAccess().hasByName(scurreftablename))
+ {
+ if (scurreftablename.equals(_sreferencedtablename))
+ {
+ XColumnsSupplier xColumnsSupplier = UnoRuntime.queryInterface( XColumnsSupplier.class, xPropertySet );
+ String[] smastercolnames = xColumnsSupplier.getColumns().getElementNames();
+ skeycolumnnames = new String[2][smastercolnames.length];
+ skeycolumnnames[0] = smastercolnames;
+ skeycolumnnames[1] = new String[smastercolnames.length];
+ for (int n = 0; n < smastercolnames.length; n++)
+ {
+ XPropertySet xcolPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xColumnsSupplier.getColumns().getByName( smastercolnames[n] ) );
+ skeycolumnnames[1][n] = AnyConverter.toString(xcolPropertySet.getPropertyValue("RelatedColumn"));
+ }
+ return skeycolumnnames;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return skeycolumnnames;
+ }
+
+
+ public void openFormDocument(boolean _bReadOnly)
+ {
+ try
+ {
+ Object oEmbeddedFactory = super.xMSF.createInstance("com.sun.star.embed.OOoEmbeddedObjectFactory");
+ int iEntryInitMode = EntryInitModes.DEFAULT_INIT; //TRUNCATE_INIT???
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+
+ public void setCommandComposingAttributes()
+ {
+ try
+ {
+ boolean bCatalogAtStart2 = xDBMetaData.isCatalogAtStart();
+ sCatalogSep = xDBMetaData.getCatalogSeparator();
+ sIdentifierQuote = xDBMetaData.getIdentifierQuoteString();
+ bCommandComposerAttributesalreadyRetrieved = true;
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+
+ /**
+ * @return Returns the bCatalogAtStart.
+ */
+ public boolean isCatalogAtStart()
+ {
+ if (!bCommandComposerAttributesalreadyRetrieved)
+ {
+ setCommandComposingAttributes();
+ }
+ return bCatalogAtStart;
+ }
+
+ /**
+ * @return Returns the sCatalogSep.
+ */
+ public String getCatalogSeparator()
+ {
+ if (!bCommandComposerAttributesalreadyRetrieved)
+ {
+ setCommandComposingAttributes();
+ }
+ return sCatalogSep;
+ }
+
+ /**
+ * @return Returns the sIdentifierQuote.
+ */
+ public String getIdentifierQuote()
+ {
+ if (!bCommandComposerAttributesalreadyRetrieved)
+ {
+ setCommandComposingAttributes();
+ }
+ return sIdentifierQuote;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/CommandName.java b/wizards/com/sun/star/wizards/db/CommandName.java
new file mode 100644
index 000000000000..aa8a4f9c7ea9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/CommandName.java
@@ -0,0 +1,267 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.Exception;
+import com.sun.star.wizards.common.JavaTools;
+
+public class CommandName
+{
+
+ protected CommandMetaData oCommandMetaData;
+ protected String CatalogName = "";
+ protected String SchemaName = "";
+ protected String TableName = "";
+ protected String DisplayName = "";
+ protected String ComposedName = "";
+ protected String AliasName = "";
+ protected boolean bCatalogAtStart;
+ protected String sCatalogSep;
+ protected String sIdentifierQuote;
+ protected boolean baddQuotation = true;
+
+ public CommandName(CommandMetaData _CommandMetaData, String _DisplayName)
+ {
+ oCommandMetaData = _CommandMetaData;
+ setComposedCommandName(_DisplayName);
+ }
+
+ public CommandName(CommandMetaData _CommandMetaData, String _CatalogName, String _SchemaName, String _TableName, boolean _baddQuotation)
+ {
+ try
+ {
+ baddQuotation = _baddQuotation;
+ oCommandMetaData = _CommandMetaData;
+ if ((_CatalogName != null) && (oCommandMetaData.xDBMetaData.supportsCatalogsInTableDefinitions()))
+ {
+ if (!_CatalogName.equals(""))
+ {
+ CatalogName = _CatalogName;
+ }
+ }
+ if ((_SchemaName != null) && (oCommandMetaData.xDBMetaData.supportsSchemasInTableDefinitions()))
+ {
+ if (!_SchemaName.equals(""))
+ {
+ SchemaName = _SchemaName;
+ }
+ }
+ if (_TableName != null)
+ {
+ if (!_TableName.equals(""))
+ {
+ TableName = _TableName;
+ }
+ }
+ setComposedCommandName();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void setComposedCommandName(String _DisplayName)
+ {
+ try
+ {
+ if (this.setMetaDataAttributes())
+ {
+ this.DisplayName = _DisplayName;
+ int iIndex;
+ if (oCommandMetaData.xDBMetaData.supportsCatalogsInDataManipulation() == true)
+ { // ...dann Catalog mit in TableName
+ iIndex = _DisplayName.indexOf(sCatalogSep);
+ if (iIndex >= 0)
+ {
+ if (bCatalogAtStart == true)
+ {
+ CatalogName = _DisplayName.substring(0, iIndex);
+ _DisplayName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
+ }
+ else
+ {
+ CatalogName = _DisplayName.substring(iIndex + 1, _DisplayName.length());
+ _DisplayName = _DisplayName.substring(0, iIndex);
+ }
+ }
+ }
+ if (oCommandMetaData.xDBMetaData.supportsSchemasInDataManipulation() == true)
+ {
+ String[] NameList;
+ NameList = new String[0];
+ NameList = JavaTools.ArrayoutofString(_DisplayName, ".");
+ SchemaName = NameList[0];
+ TableName = NameList[1]; // TODO Was ist mit diesem Fall: CatalogSep = "." und CatalogName = ""
+ }
+ else
+ {
+ TableName = _DisplayName;
+ }
+ setComposedCommandName();
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void setComposedCommandName()
+ {
+ if (this.setMetaDataAttributes())
+ {
+ if (CatalogName != null)
+ {
+ if (!CatalogName.equals(""))
+ {
+ if (bCatalogAtStart == true)
+ {
+ ComposedName = quoteName(CatalogName) + sCatalogSep;
+ }
+ }
+ }
+ if (SchemaName != null)
+ {
+ if (!SchemaName.equals(""))
+ {
+ ComposedName += quoteName(SchemaName) + ".";
+ }
+ }
+ if (ComposedName.equals(""))
+ {
+ ComposedName = quoteName(TableName);
+ }
+ else
+ {
+ ComposedName += quoteName(TableName);
+ }
+ if ((bCatalogAtStart == false) && (CatalogName != null))
+ {
+ if (!CatalogName.equals(""))
+ {
+ ComposedName += sCatalogSep + quoteName(CatalogName);
+ }
+ }
+ }
+ }
+
+ private boolean setMetaDataAttributes()
+ {
+ try
+ {
+ bCatalogAtStart = oCommandMetaData.xDBMetaData.isCatalogAtStart();
+ sCatalogSep = oCommandMetaData.xDBMetaData.getCatalogSeparator();
+ sIdentifierQuote = oCommandMetaData.xDBMetaData.getIdentifierQuoteString();
+ return true;
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public String quoteName(String _sName)
+ {
+ if (baddQuotation)
+ {
+ return quoteName(_sName, this.oCommandMetaData.getIdentifierQuote());
+ }
+ else
+ {
+ return _sName;
+ }
+ }
+
+ public static String quoteName(String sName, String _sIdentifierQuote)
+ {
+ if (sName == null)
+ {
+ sName = "";
+ }
+ String ReturnQuote = "";
+ ReturnQuote = _sIdentifierQuote + sName + _sIdentifierQuote;
+ return ReturnQuote;
+ }
+
+ public void setAliasName(String _AliasName)
+ {
+ AliasName = _AliasName;
+ }
+
+ public String getAliasName()
+ {
+ return AliasName;
+ }
+
+ /**
+ * @return Returns the catalogName.
+ */
+ public String getCatalogName()
+ {
+ return CatalogName;
+ }
+
+ /**
+ * @return Returns the composedName.
+ */
+ public String getComposedName()
+ {
+ return ComposedName;
+ }
+
+ /**
+ * @return Returns the displayName.
+ */
+ public String getDisplayName()
+ {
+ return DisplayName;
+ }
+
+ /**
+ * @return Returns the schemaName.
+ */
+ public String getSchemaName()
+ {
+ return SchemaName;
+ }
+
+ /**
+ * @return Returns the tableName.
+ */
+ public String getTableName()
+ {
+ return TableName;
+ }
+
+ public CommandMetaData getCommandMetaData()
+ {
+ return oCommandMetaData;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/DBMetaData.java b/wizards/com/sun/star/wizards/db/DBMetaData.java
new file mode 100644
index 000000000000..323ded34385a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/DBMetaData.java
@@ -0,0 +1,1103 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.awt.XWindow;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.ui.dialogs.XExecutableDialog;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XHierarchicalNameContainer;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.sdb.XOfficeDatabaseDocument;
+import com.sun.star.sdb.XDocumentDataSource;
+import com.sun.star.sdb.tools.XConnectionTools;
+import com.sun.star.sdbcx.XColumnsSupplier;
+
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XNumberFormatsSupplier;
+
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.sdb.XFormDocumentsSupplier;
+import com.sun.star.sdb.XQueryDefinitionsSupplier;
+import com.sun.star.sdb.XReportDocumentsSupplier;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XDatabaseMetaData;
+import com.sun.star.sdbc.XDataSource;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.sdb.XCompletedConnection;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.sdb.XQueriesSupplier;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.sdbcx.XTablesSupplier;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NamedValueCollection;
+import com.sun.star.wizards.common.NumberFormatter;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.uno.Any;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class DBMetaData
+{
+ private XNameAccess xQueryNames;
+ public XDatabaseMetaData xDBMetaData;
+ private XDataSource m_dataSource;
+ private XPropertySet m_dataSourceSettings;
+ private XOfficeDatabaseDocument xModel;
+ private XPropertySet xDataSourcePropertySet;
+ public String[] DataSourceNames;
+ public String[] CommandNames;
+ public java.util.Vector CommandObjects = new Vector(1);
+ public Locale aLocale;
+ public int[] CommandTypes;
+ public String DataSourceName;
+ public com.sun.star.sdbc.XConnection DBConnection;
+ public com.sun.star.sdb.tools.XConnectionTools ConnectionTools;
+ public com.sun.star.lang.XMultiServiceFactory xMSF;
+ public XComponent xConnectionComponent;
+
+ private XNameAccess xNameAccess;
+ private XInterface xDatabaseContext;
+ private XWindowPeer xWindowPeer;
+ private String[] TableNames = new String[] {};
+ private String[] QueryNames = new String[] {};
+
+ protected int[][] WidthList;
+ protected static final int[] NumericTypes = {
+ DataType.TINYINT, // == -6;
+ DataType.BIGINT, // == -5
+ DataType.NUMERIC, // == - 2
+ DataType.DECIMAL, // == 3;
+ DataType.INTEGER, // == 4;
+ DataType.SMALLINT, // == 5;
+ DataType.FLOAT, // == 6;
+ DataType.REAL, // == 7;
+ DataType.DOUBLE, // == 8;
+ };
+ protected static final int[] BinaryTypes = { //new int[12];
+ DataType.BINARY,
+ DataType.VARBINARY,
+ DataType.LONGVARBINARY,
+ DataType.BLOB,
+ DataType.SQLNULL,
+ DataType.OBJECT,
+ DataType.DISTINCT,
+ DataType.STRUCT,
+ DataType.ARRAY,
+ DataType.CLOB,
+ DataType.REF
+ /* DataType.OTHER, */
+ };
+
+ private int iMaxColumnsInSelect;
+ private int iMaxColumnsInGroupBy;
+ private int iMaxColumnsInTable;
+ private int iMaxColumnNameLength = -1;
+ private int iMaxTableNameLength = -1;
+ private boolean bPasswordIsRequired;
+ private final static int NOLIMIT = 9999999;
+ protected final static int RID_DB_COMMON = 1000;
+ private final static int INVALID = 9999999;
+ public TypeInspector oTypeInspector;
+ private NumberFormatter oNumberFormatter = null;
+ private long lDateCorrection = INVALID;
+ private boolean bdisposeConnection = false;
+
+ public XPropertySet getDataSourcePropertySet()
+ {
+ return xDataSourcePropertySet;
+ }
+
+ public DBMetaData(XMultiServiceFactory xMSF)
+ {
+ getInterfaces(xMSF);
+ InitializeWidthList();
+ }
+
+ public DBMetaData(XMultiServiceFactory xMSF, Locale _aLocale, NumberFormatter _oNumberFormatter)
+ {
+ oNumberFormatter = _oNumberFormatter;
+ aLocale = _aLocale;
+ getInterfaces(xMSF);
+ InitializeWidthList();
+ }
+
+ public NumberFormatter getNumberFormatter()
+ {
+ if (oNumberFormatter == null)
+ {
+ try
+ {
+ XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) AnyConverter.toObject(XNumberFormatsSupplier.class, xDataSourcePropertySet.getPropertyValue("NumberFormatsSupplier"));
+ //TODO get the locale from the datasource
+ aLocale = Configuration.getOfficeLocale(xMSF);
+ oNumberFormatter = new NumberFormatter(xMSF, xNumberFormatsSupplier, aLocale);
+ lDateCorrection = oNumberFormatter.getNullDateCorrection();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ return oNumberFormatter;
+ }
+
+ public long getNullDateCorrection()
+ {
+ if (lDateCorrection == INVALID)
+ {
+ if (oNumberFormatter == null)
+ {
+ oNumberFormatter = getNumberFormatter();
+ }
+ lDateCorrection = oNumberFormatter.getNullDateCorrection();
+ }
+ return lDateCorrection;
+ }
+
+ private void getInterfaces(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ this.xMSF = xMSF;
+ xDatabaseContext = (XInterface) xMSF.createInstance("com.sun.star.sdb.DatabaseContext");
+ xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xDatabaseContext );
+ DataSourceNames = xNameAccess.getElementNames();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void setCommandTypes()
+ {
+ int TableCount;
+ int QueryCount;
+ int CommandCount;
+ int i;
+ int a;
+ TableCount = JavaTools.getArraylength(TableNames);
+ QueryCount = JavaTools.getArraylength(QueryNames);
+ CommandCount = TableCount + QueryCount;
+ CommandTypes = new int[CommandCount];
+ if (TableCount > 0)
+ {
+ for (i = 0; i < TableCount; i++)
+ {
+ CommandTypes[i] = com.sun.star.sdb.CommandType.TABLE;
+ }
+ a = i;
+ for (i = 0; i < QueryCount; i++)
+ {
+ CommandTypes[a] = com.sun.star.sdb.CommandType.QUERY;
+ a += 1;
+ }
+ }
+ }
+
+ public boolean hasTableByName(String _stablename)
+ {
+ return getTableNamesAsNameAccess().hasByName(_stablename);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setTableByName(String _tableName)
+ {
+ CommandObject oTableObject = new CommandObject(_tableName, com.sun.star.sdb.CommandType.TABLE);
+ this.CommandObjects.addElement(oTableObject);
+ }
+
+ public CommandObject getTableByName(String _tablename)
+ {
+ return getCommandByName(_tablename, com.sun.star.sdb.CommandType.TABLE);
+ }
+
+ public CommandObject getQueryByName(String _queryname)
+ {
+ return getCommandByName(_queryname, com.sun.star.sdb.CommandType.QUERY);
+ }
+
+ public CommandObject getCommandByName(String _commandname, int _commandtype)
+ {
+ CommandObject oCommand = null;
+ for (int i = 0; i < CommandObjects.size(); i++)
+ {
+ oCommand = (CommandObject) CommandObjects.elementAt(i);
+ if ((oCommand.Name.equals(_commandname)) && (oCommand.CommandType == _commandtype))
+ {
+ return oCommand;
+ }
+ }
+ if (oCommand == null)
+ {
+ oCommand = new CommandObject(_commandname, _commandtype);
+ CommandObjects.addElement(oCommand);
+ }
+ return oCommand;
+ }
+
+ public void setQueryByName(String _QueryName)
+ {
+ CommandObject oQueryObject = new CommandObject(_QueryName, com.sun.star.sdb.CommandType.QUERY);
+ this.CommandObjects.addElement(oQueryObject);
+ }
+
+ public class CommandObject
+ {
+
+ private XNameAccess xColumns;
+ private XPropertySet xPropertySet;
+ private String Name;
+ private int CommandType;
+
+ public CommandObject(String _CommandName, int _CommandType)
+ {
+ try
+ {
+ Object oCommand;
+ this.Name = _CommandName;
+ this.CommandType = _CommandType;
+ // if (getTableNamesAsNameAccess() == null)
+ // {
+ // initCommandNames();
+ // }
+ if (CommandType == com.sun.star.sdb.CommandType.TABLE)
+ {
+ oCommand = getTableNamesAsNameAccess().getByName(Name);
+ }
+ else
+ {
+ oCommand = getQueryNamesAsNameAccess().getByName(Name);
+ }
+ XColumnsSupplier xCommandCols = UnoRuntime.queryInterface( XColumnsSupplier.class, oCommand );
+ xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oCommand );
+// TODO: Performance leak getColumns() take very long.
+ xColumns = UnoRuntime.queryInterface( XNameAccess.class, xCommandCols.getColumns() );
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ public XNameAccess getColumns()
+ {
+ return xColumns;
+ }
+ public String getName()
+ {
+ return Name;
+ }
+ public XPropertySet getPropertySet()
+ {
+ return xPropertySet;
+ }
+ }
+
+ public boolean hasEscapeProcessing(XPropertySet _xQueryPropertySet)
+ {
+ boolean bHasEscapeProcessing = false;
+ try
+ {
+ if (_xQueryPropertySet.getPropertySetInfo().hasPropertyByName("EscapeProcessing"))
+ {
+ bHasEscapeProcessing = AnyConverter.toBoolean(_xQueryPropertySet.getPropertyValue("EscapeProcessing"));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return bHasEscapeProcessing;
+ }
+
+ public XNameAccess getQueryNamesAsNameAccess()
+ {
+ XQueriesSupplier xDBQueries = UnoRuntime.queryInterface( XQueriesSupplier.class, DBConnection );
+ xQueryNames = xDBQueries.getQueries();
+ return xQueryNames;
+ }
+
+ public XNameAccess getTableNamesAsNameAccess()
+ {
+ XTablesSupplier xDBTables = UnoRuntime.queryInterface( XTablesSupplier.class, DBConnection );
+ XNameAccess xTableNames = xDBTables.getTables();
+ return xTableNames;
+ }
+
+ public String[] getQueryNames()
+ {
+ if (QueryNames != null)
+ {
+ if (QueryNames.length > 0)
+ {
+ return QueryNames;
+ }
+ }
+ QueryNames = getQueryNamesAsNameAccess().getElementNames();
+ return QueryNames;
+ }
+
+ public String[] getTableNames()
+ {
+ if (TableNames != null)
+ {
+ if (TableNames.length > 0)
+ {
+ return TableNames;
+ }
+ }
+ TableNames = getTableNamesAsNameAccess().getElementNames();
+ return TableNames;
+ }
+
+ private void InitializeWidthList()
+ {
+ WidthList = new int[17][2];
+ WidthList[0][0] = DataType.BIT; // == -7;
+ WidthList[1][0] = DataType.BOOLEAN; // = 16
+ WidthList[2][0] = DataType.TINYINT; // == -6;
+ WidthList[3][0] = DataType.BIGINT; // == -5;
+ WidthList[4][0] = DataType.LONGVARCHAR; // == -1;
+ WidthList[5][0] = DataType.CHAR; // == 1;
+ WidthList[6][0] = DataType.NUMERIC; // == 2;
+ WidthList[7][0] = DataType.DECIMAL; // == 3; [mit Nachkommastellen]
+ WidthList[8][0] = DataType.INTEGER; // == 4;
+ WidthList[9][0] = DataType.SMALLINT; // == 5;
+ WidthList[10][0] = DataType.FLOAT; // == 6;
+ WidthList[11][0] = DataType.REAL; // == 7;
+ WidthList[12][0] = DataType.DOUBLE; // == 8;
+ WidthList[13][0] = DataType.VARCHAR; // == 12;
+ WidthList[14][0] = DataType.DATE; // == 91;
+ WidthList[15][0] = DataType.TIME; // == 92;
+ WidthList[16][0] = DataType.TIMESTAMP; // == 93;
+ // NumericTypes are all types where aggregate functions can be performed on.
+ // Similarly to a major competitor date/time/timmestamp fields are not included
+
+
+ }
+
+ public boolean isBinaryDataType(int _itype)
+ {
+ if (NumericTypes == null)
+ {
+ InitializeWidthList();
+ }
+ return (JavaTools.FieldInIntTable(BinaryTypes, _itype) > -1);
+ }
+
+ public int getMaxTablesInSelect()
+ {
+ try
+ {
+ int itablecount = xDBMetaData.getMaxTablesInSelect();
+ if (itablecount == 0)
+ {
+ return DBMetaData.NOLIMIT;
+ }
+ else
+ {
+ return itablecount;
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return - 1;
+ }
+ }
+
+ public int getMaxColumnsInSelect()
+ {
+ return iMaxColumnsInSelect;
+ }
+
+ public int getMaxColumnsInGroupBy()
+ {
+ return iMaxColumnsInGroupBy;
+ }
+
+ private void setMaxColumnsInSelect() throws SQLException
+ {
+ iMaxColumnsInSelect = xDBMetaData.getMaxColumnsInSelect();
+ if (iMaxColumnsInSelect == 0)
+ {
+ iMaxColumnsInSelect = DBMetaData.NOLIMIT;
+ }
+ }
+
+ private void setMaxColumnsInGroupBy() throws SQLException
+ {
+ iMaxColumnsInGroupBy = xDBMetaData.getMaxColumnsInGroupBy();
+ if (iMaxColumnsInGroupBy == 0)
+ {
+ iMaxColumnsInGroupBy = DBMetaData.NOLIMIT;
+ }
+ }
+
+ public int getMaxColumnsInTable() throws SQLException
+ {
+ iMaxColumnsInTable = xDBMetaData.getMaxColumnsInTable();
+ if (iMaxColumnsInTable == 0)
+ {
+ iMaxColumnsInTable = DBMetaData.NOLIMIT;
+ }
+ return iMaxColumnsInTable;
+ }
+
+ private void getDataSourceObjects() throws Exception
+ {
+ try
+ {
+ xDBMetaData = DBConnection.getMetaData();
+ getDataSourceInterfaces();
+ setMaxColumnsInGroupBy();
+ setMaxColumnsInSelect();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void ensureDataSourceSettings() throws UnknownPropertyException, WrappedTargetException
+ {
+ if ( m_dataSourceSettings != null )
+ return;
+
+ XPropertySet dataSourceProperties = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() );
+ m_dataSourceSettings = UnoRuntime.queryInterface( XPropertySet.class, dataSourceProperties.getPropertyValue( "Settings" ) );
+ }
+
+ public boolean isSQL92CheckEnabled()
+ {
+ boolean isSQL92CheckEnabled = false;
+ try
+ {
+ ensureDataSourceSettings();
+ isSQL92CheckEnabled = AnyConverter.toBoolean( m_dataSourceSettings.getPropertyValue( "EnableSQL92Check" ) );
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return isSQL92CheckEnabled;
+ }
+
+ public String verifyName(String _sname, int _maxlen)
+ {
+ if (_sname.length() > _maxlen)
+ {
+ return _sname.substring(0, _maxlen);
+ }
+ if (this.isSQL92CheckEnabled())
+ {
+ return Desktop.removeSpecialCharacters(xMSF, Configuration.getOfficeLocale(xMSF), _sname);
+ }
+ return _sname;
+ }
+
+ public XDataSource getDataSource()
+ {
+ if (m_dataSource == null)
+ {
+ try
+ {
+ Object oDataSource = xNameAccess.getByName(DataSourceName);
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, oDataSource );
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException e)
+ {
+ }
+ }
+ return m_dataSource;
+ }
+
+ private void setDataSourceByName(String _DataSourceName)
+ {
+ try
+ {
+ this.DataSourceName = _DataSourceName;
+ getDataSourceInterfaces();
+ XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, getDataSource() );
+ if (xDocu != null)
+ {
+ xModel = xDocu.getDatabaseDocument();
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void getDataSourceInterfaces() throws Exception
+ {
+ xDataSourcePropertySet = UnoRuntime.queryInterface( XPropertySet.class, getDataSource() );
+ bPasswordIsRequired = ((Boolean) xDataSourcePropertySet.getPropertyValue("IsPasswordRequired")).booleanValue();
+ }
+
+ public boolean getConnection(PropertyValue[] curproperties)
+ {
+ try
+ {
+ XConnection xConnection = null;
+ if (Properties.hasPropertyValue(curproperties, "ActiveConnection"))
+ {
+ xConnection = UnoRuntime.queryInterface( XConnection.class, Properties.getPropertyValue( curproperties, "ActiveConnection" ) );
+ if (xConnection != null)
+ {
+ com.sun.star.container.XChild child = UnoRuntime.queryInterface( com.sun.star.container.XChild.class, xConnection );
+
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, child.getParent() );
+ XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, m_dataSource );
+ if (xDocu != null)
+ {
+ xModel = xDocu.getDatabaseDocument();
+ }
+ XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, m_dataSource );
+ if (xPSet != null)
+ {
+ DataSourceName = AnyConverter.toString(xPSet.getPropertyValue("Name"));
+ }
+ return getConnection(xConnection);
+ }
+ else
+ {
+ bdisposeConnection = true;
+ }
+ }
+ else
+ {
+ bdisposeConnection = true;
+ }
+ if (Properties.hasPropertyValue(curproperties, "DataSourceName"))
+ {
+ String sDataSourceName = AnyConverter.toString(Properties.getPropertyValue(curproperties, "DataSourceName"));
+ return getConnection(sDataSourceName);
+ }
+ else if (Properties.hasPropertyValue(curproperties, "DataSource"))
+ {
+ m_dataSource = UnoRuntime.queryInterface( XDataSource.class, Properties.getPropertyValue( curproperties, "DataSource" ) );
+ XDocumentDataSource xDocu = UnoRuntime.queryInterface( XDocumentDataSource.class, this.m_dataSource );
+ if (xDocu != null)
+ {
+ xModel = xDocu.getDatabaseDocument();
+ }
+ return getConnection(m_dataSource);
+ }
+ if (Properties.hasPropertyValue(curproperties, "DatabaseLocation"))
+ {
+ String sDataSourceName = AnyConverter.toString(Properties.getPropertyValue(curproperties, "DatabaseLocation"));
+ return getConnection(sDataSourceName);
+ }
+ else if (xConnection != null)
+ {
+ bdisposeConnection = false;
+ return getConnection(xConnection);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (UnknownPropertyException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (WrappedTargetException e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ return false;
+ }
+
+ private boolean getConnection(String _DataSourceName)
+ {
+ setDataSourceByName(_DataSourceName);
+ return getConnection( getDataSource() );
+ }
+
+ private boolean getConnection(com.sun.star.sdbc.XConnection _DBConnection)
+ {
+ try
+ {
+ this.DBConnection = _DBConnection;
+ this.ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, this.DBConnection );
+ getDataSourceObjects();
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ private boolean getConnection(XDataSource _dataSource)
+ {
+ Resource oResource = new Resource(xMSF, "Database", "dbw");
+ try
+ {
+ int iMsg = 0;
+ boolean bgetConnection = false;
+ if (DBConnection != null)
+ {
+ xConnectionComponent.dispose();
+ }
+ getDataSourceInterfaces();
+ if (bPasswordIsRequired == false)
+ {
+ DBConnection = _dataSource.getConnection("", "");
+ bgetConnection = true;
+ }
+ else
+ {
+ XInteractionHandler xInteractionHandler = UnoRuntime.queryInterface( XInteractionHandler.class, xMSF.createInstance("com.sun.star.task.InteractionHandler") );
+ boolean bExitLoop = true;
+ do
+ {
+ XCompletedConnection xCompleted2 = UnoRuntime.queryInterface( XCompletedConnection.class, _dataSource );
+ try
+ {
+ DBConnection = xCompleted2.connectWithCompletion( xInteractionHandler );
+ bgetConnection = DBConnection != null;
+ if (bgetConnection == false)
+ {
+ bExitLoop = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ // Note: WindowAttributes from toolkit/source/awt/vclxtoolkit.cxx
+ String sMsgNoConnection = oResource.getResText(RID_DB_COMMON + 14);
+ iMsg = showMessageBox("QueryBox", VclWindowPeerAttribute.RETRY_CANCEL, sMsgNoConnection);
+ bExitLoop = iMsg == 0;
+ bgetConnection = false;
+ }
+ }
+ while (bExitLoop == false);
+ }
+ if (bgetConnection == false)
+ {
+ String sMsgConnectionImpossible = oResource.getResText(RID_DB_COMMON + 35);
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible);
+ }
+ else
+ {
+ xConnectionComponent = UnoRuntime.queryInterface( XComponent.class, DBConnection );
+ ConnectionTools = UnoRuntime.queryInterface( XConnectionTools.class, DBConnection );
+ getDataSourceObjects();
+ }
+ return bgetConnection;
+ }
+ catch (Exception exception)
+ {
+ String sMsgConnectionImpossible = oResource.getResText(RID_DB_COMMON + 35);
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMsgConnectionImpossible);
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public int getMaxColumnNameLength()
+ {
+ try
+ {
+ if (iMaxColumnNameLength <= 0)
+ {
+ iMaxColumnNameLength = xDBMetaData.getMaxColumnNameLength();
+ }
+ return iMaxColumnNameLength;
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return 0;
+ }
+ }
+
+ public int getMaxTableNameLength()
+ {
+ try
+ {
+ if (iMaxTableNameLength <= 0)
+ {
+ iMaxTableNameLength = xDBMetaData.getMaxTableNameLength();
+ }
+ return iMaxTableNameLength;
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return 0;
+ }
+ }
+
+ public boolean supportsPrimaryKeys()
+ {
+ boolean supportsPrimaryKeys = false;
+ try
+ {
+ ensureDataSourceSettings();
+ Any primaryKeySupport = (Any)m_dataSourceSettings.getPropertyValue( "PrimaryKeySupport" );
+ if ( AnyConverter.isVoid( primaryKeySupport ) )
+ supportsPrimaryKeys = supportsCoreSQLGrammar();
+ else
+ supportsPrimaryKeys = AnyConverter.toBoolean( primaryKeySupport );
+ }
+ catch ( Exception ex )
+ {
+ Logger.getLogger( DBMetaData.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ return supportsPrimaryKeys;
+ }
+
+ public boolean supportsCoreSQLGrammar()
+ {
+ try
+ {
+ return xDBMetaData.supportsCoreSQLGrammar();
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public boolean supportsAutoIncrementation()
+ {
+ return false;
+ }
+
+ /**
+ * inserts a Query to a datasource; There is no validation if the queryname is already existing in the datasource
+ * @param oQuery
+ * @param QueryName
+ */
+ public boolean createQuery(SQLQueryComposer _oSQLQueryComposer, String _QueryName)
+ {
+ try
+ {
+ XQueryDefinitionsSupplier xQueryDefinitionsSuppl = UnoRuntime.queryInterface( XQueryDefinitionsSupplier.class, m_dataSource );
+ XNameAccess xQueryDefs = xQueryDefinitionsSuppl.getQueryDefinitions();
+ XSingleServiceFactory xSSFQueryDefs = UnoRuntime.queryInterface( XSingleServiceFactory.class, xQueryDefs );
+ Object oQuery = xSSFQueryDefs.createInstance(); //"com.sun.star.sdb.QueryDefinition"
+ XPropertySet xPSet = UnoRuntime.queryInterface( XPropertySet.class, oQuery );
+
+ String s = _oSQLQueryComposer.m_xQueryAnalyzer.getQuery();
+ xPSet.setPropertyValue("Command", s);
+
+ XNameContainer xNameCont = UnoRuntime.queryInterface( XNameContainer.class, xQueryDefs );
+ ConnectionTools.getObjectNames().checkNameForCreate(com.sun.star.sdb.CommandType.QUERY, _QueryName);
+ xNameCont.insertByName(_QueryName, oQuery);
+ return true;
+ }
+ catch (WrappedTargetException exception)
+ {
+ SQLException sqlError = null;
+ try
+ {
+ sqlError = (SQLException) exception.TargetException;
+ }
+ catch (ClassCastException castError)
+ {
+ }
+
+ if (sqlError != null)
+ {
+ callSQLErrorMessageDialog(sqlError, null);
+ return false;
+ }
+ exception.printStackTrace(System.out);
+ }
+ catch (SQLException exception)
+ {
+ callSQLErrorMessageDialog(exception, null);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public void dispose()
+ {
+ if ((DBConnection != null) && (this.bdisposeConnection))
+ {
+ xConnectionComponent.dispose();
+ }
+ }
+
+ public XHierarchicalNameAccess getReportDocuments()
+ {
+ XReportDocumentsSupplier xReportDocumentSuppl = UnoRuntime.queryInterface( XReportDocumentsSupplier.class, this.xModel );
+ xReportDocumentSuppl.getReportDocuments();
+ XHierarchicalNameAccess xReportHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xReportDocumentSuppl.getReportDocuments() );
+ return xReportHier;
+ }
+
+ public XHierarchicalNameAccess getFormDocuments()
+ {
+ XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel );
+ XHierarchicalNameAccess xFormHier = UnoRuntime.queryInterface( XHierarchicalNameAccess.class, xFormDocumentSuppl.getFormDocuments() );
+ return xFormHier;
+ }
+
+ public boolean hasFormDocumentByName(String _sFormName)
+ {
+ XFormDocumentsSupplier xFormDocumentSuppl = UnoRuntime.queryInterface( XFormDocumentsSupplier.class, xModel );
+ XNameAccess xFormNameAccess = UnoRuntime.queryInterface( XNameAccess.class, xFormDocumentSuppl.getFormDocuments() );
+ return xFormNameAccess.hasByName(_sFormName);
+ }
+
+ public void addFormDocument(XComponent _xComponent)
+ {
+ XHierarchicalNameAccess _xFormDocNameAccess = getFormDocuments();
+ addDatabaseDocument(_xComponent, _xFormDocNameAccess, false);
+ }
+
+ public void addReportDocument(XComponent _xComponent, boolean _bcreatedynamicreport)
+ {
+ XHierarchicalNameAccess xReportDocNameAccess = getReportDocuments();
+ addDatabaseDocument(_xComponent, xReportDocNameAccess, _bcreatedynamicreport);
+ }
+
+ /**
+ * adds the passed document as a report or a form to the database. Afterwards the document is deleted.
+ * the document may not be open
+ * @param _xComponent
+ * @param _xDocNameAccess
+ * @param _bcreateTemplate describes the type of the document: "form" or "report"
+ */
+ public void addDatabaseDocument(XComponent _xComponent, XHierarchicalNameAccess _xDocNameAccess, boolean i_createTemplate)
+ {
+ try
+ {
+ XModel xDocumentModel = UnoRuntime.queryInterface( XModel.class, _xComponent );
+ String documentURL = xDocumentModel.getURL();
+ String basename = FileAccess.getBasename(documentURL, "/");
+ XCloseable xCloseable = UnoRuntime.queryInterface( XCloseable.class, _xComponent );
+ xCloseable.close(false);
+
+ NamedValueCollection creationArgs = new NamedValueCollection();
+ creationArgs.put( "Name", basename );
+ creationArgs.put( "URL", documentURL );
+ creationArgs.put( "AsTemplate", i_createTemplate );
+ XMultiServiceFactory xDocMSF = UnoRuntime.queryInterface( XMultiServiceFactory.class, _xDocNameAccess );
+ Object oDBDocument = xDocMSF.createInstanceWithArguments( "com.sun.star.sdb.DocumentDefinition", creationArgs.getPropertyValues() );
+ XHierarchicalNameContainer xHier = UnoRuntime.queryInterface( XHierarchicalNameContainer.class, _xDocNameAccess );
+ String sdocname = Desktop.getUniqueName(_xDocNameAccess, basename);
+ xHier.insertByHierarchicalName(sdocname, oDBDocument);
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
+ xSimpleFileAccess.kill(documentURL);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void createTypeInspector() throws SQLException
+ {
+ oTypeInspector = new TypeInspector(xDBMetaData.getTypeInfo());
+ }
+
+ public TypeInspector getDBDataTypeInspector()
+ {
+ return oTypeInspector;
+ }
+
+ private String[] StringsFromResultSet(XResultSet _xResultSet, int _icol)
+ {
+ String[] sColValues = null;
+ try
+ {
+ XRow xRow = UnoRuntime.queryInterface( XRow.class, _xResultSet );
+ Vector aColVector = new Vector();
+ while (_xResultSet.next())
+ {
+ aColVector.addElement(xRow.getString(_icol));
+ }
+ sColValues = new String[aColVector.size()];
+ aColVector.toArray(sColValues);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ return sColValues;
+ }
+
+ public String[] getCatalogNames()
+ {
+ try
+ {
+ XResultSet xResultSet = xDBMetaData.getCatalogs();
+ return StringsFromResultSet(xResultSet, 1);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public String[] getSchemaNames()
+ {
+ try
+ {
+ XResultSet xResultSet = xDBMetaData.getSchemas();
+ return StringsFromResultSet(xResultSet, 1);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public boolean storeDatabaseDocumentToTempPath(XComponent _xcomponent, String _storename)
+ {
+ try
+ {
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = UnoRuntime.queryInterface( XSimpleFileAccess.class, xInterface );
+ String storepath = FileAccess.getOfficePath(xMSF, "Temp", xSimpleFileAccess) + "/" + _storename;
+ XStorable xStoreable = UnoRuntime.queryInterface( XStorable.class, _xcomponent );
+ PropertyValue[] oStoreProperties = new PropertyValue[1];
+ oStoreProperties[0] = Properties.createProperty("FilterName", "writer8");
+ storepath += ".odt";
+ xStoreable.storeAsURL(storepath, oStoreProperties);
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public int showMessageBox(String windowServiceName, int windowAttribute, String MessageText)
+ {
+ if (getWindowPeer() != null)
+ {
+ return SystemDialog.showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText);
+ }
+ else
+ {
+ return SystemDialog.showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText);
+ }
+ }
+
+ /**
+ * @return Returns the xWindowPeer.
+ */
+ public XWindowPeer getWindowPeer()
+ {
+ return xWindowPeer;
+ }
+
+ /**
+ * @param windowPeer The xWindowPeer to set.
+ * Should be called as soon as a Windowpeer of a wizard dialog is available
+ * The windowpeer is needed to call a Messagebox
+ */
+ public void setWindowPeer(XWindowPeer windowPeer)
+ {
+ xWindowPeer = windowPeer;
+ }
+
+ public void callSQLErrorMessageDialog(SQLException oSQLException, XWindow _xWindow)
+ {
+ try
+ {
+ Object oDialog = xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog");
+ XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oDialog );
+ PropertyValue[] aPropertyValue = new PropertyValue[2];
+ aPropertyValue[0] = Properties.createProperty("SQLException", oSQLException);
+ aPropertyValue[1] = Properties.createProperty("ParentWindow", _xWindow);
+ xInitialization.initialize(aPropertyValue);
+ XExecutableDialog xExecutableDialog = UnoRuntime.queryInterface( XExecutableDialog.class, oDialog );
+ xExecutableDialog.execute();
+ }
+ catch (com.sun.star.uno.Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void finish()
+ {
+ xQueryNames = null;
+ xNameAccess = null;
+ xDatabaseContext = null;
+ xDBMetaData = null;
+ m_dataSource = null;
+ xModel = null;
+ xDataSourcePropertySet = null;
+ xWindowPeer = null;
+ DBConnection = null;
+ ConnectionTools = null;
+ xMSF = null;
+ xConnectionComponent = null;
+ CommandObjects = null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
new file mode 100644
index 000000000000..e03323c6ebbc
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/DatabaseObjectWizard.java
@@ -0,0 +1,76 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package com.sun.star.wizards.db;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.NamedValueCollection;
+import com.sun.star.wizards.ui.WizardDialog;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * is a base class for a wizard creating a database object
+ * @author frank.schoenheit@sun.com
+ */
+public abstract class DatabaseObjectWizard extends WizardDialog
+{
+ protected final PropertyValue[] m_wizardContext;
+ protected final XDatabaseDocumentUI m_docUI;
+ protected final XFrame m_frame;
+
+ protected DatabaseObjectWizard( final XMultiServiceFactory i_orb, final int i_helpIDBase, final PropertyValue[] i_wizardContext )
+ {
+ super( i_orb, i_helpIDBase );
+ m_wizardContext = i_wizardContext;
+
+ final NamedValueCollection wizardContext = new NamedValueCollection( m_wizardContext );
+ m_docUI = wizardContext.queryOrDefault( "DocumentUI", (XDatabaseDocumentUI)null, XDatabaseDocumentUI.class );
+
+ if ( m_docUI != null )
+ {
+ XController docController = UnoRuntime.queryInterface( XController.class, m_docUI );
+ m_frame = docController.getFrame();
+ }
+ else
+ {
+ XFrame parentFrame = wizardContext.queryOrDefault( "ParentFrame", (XFrame)null, XFrame.class );
+ if ( parentFrame != null )
+ m_frame = parentFrame;
+ else
+ m_frame = Desktop.getActiveFrame( xMSF );
+ }
+ }
+
+ protected final void loadSubComponent( final int i_type, final String i_name, final boolean i_forEditing )
+ {
+ try
+ {
+ if ( m_docUI != null )
+ m_docUI.loadComponent( i_type, i_name, i_forEditing );
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex );
+ }
+ catch ( NoSuchElementException ex )
+ {
+ Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex );
+ }
+ catch ( SQLException ex )
+ {
+ Logger.getLogger( this.getClass().getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/FieldColumn.java b/wizards/com/sun/star/wizards/db/FieldColumn.java
new file mode 100644
index 000000000000..041aab5f5300
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/FieldColumn.java
@@ -0,0 +1,471 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+// import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.*;
+
+public class FieldColumn
+{
+ protected int ColIndex;
+
+ private Object DefaultValue;
+ private String m_sFieldName;
+ private String m_sDisplayFieldName;
+ private String FieldTitle;
+ private String m_sCommandName;
+ private int m_nDBFormatKey;
+ private int m_nFieldType;
+ private XPropertySet m_xColPropertySet;
+
+ // field meta data
+ private int FieldWidth;
+ private int StandardFormatKey;
+ private boolean bIsNumberFormat;
+
+ private static boolean bFormatKeysInitialized = false;
+ private static int iDateFormatKey;
+ private static int iDateTimeFormatKey;
+ private static int iNumberFormatKey;
+ private static int iTextFormatKey;
+ private static int iTimeFormatKey;
+ private static int iLogicalFormatKey;
+
+ private CommandMetaData m_aCommandMetaData;
+
+ public FieldColumn(CommandMetaData oCommandMetaData, String _DisplayFieldName)
+ {
+ m_sDisplayFieldName = _DisplayFieldName;
+ m_sCommandName = oCommandMetaData.getCommandName();
+ m_sFieldName = getOnlyFieldName(m_sDisplayFieldName, m_sCommandName);
+// TODO: could be wrong here!
+// FieldTitle = _DisplayFieldName; // oCommandMetaData.getFieldTitle(m_sFieldName);
+ FieldTitle = m_sFieldName;
+ DBMetaData.CommandObject oTable = oCommandMetaData.getTableByName(m_sCommandName);
+ initializeFormatKeys(oCommandMetaData, oTable.getColumns());
+ }
+
+ public FieldColumn(CommandMetaData oCommandMetaData, String _FieldName, String _CommandName, boolean _bInstantiateByDisplayName)
+ {
+ m_sCommandName = _CommandName;
+ if (_bInstantiateByDisplayName)
+ {
+ m_sDisplayFieldName = _FieldName;
+ m_sFieldName = getOnlyFieldName(_FieldName, _CommandName);
+ }
+ else
+ {
+ m_sFieldName = _FieldName;
+ m_sDisplayFieldName = composeDisplayFieldName(_CommandName, m_sFieldName);
+ }
+ FieldTitle = m_sFieldName;
+ m_aCommandMetaData = oCommandMetaData;
+ }
+
+ public FieldColumn(CommandMetaData oCommandMetaData, XNameAccess _xColumns, String _FieldName)
+ {
+ m_sFieldName = _FieldName;
+// FieldTitle = m_sFieldName;
+ m_sDisplayFieldName = m_sFieldName;
+ ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1;
+ initializeFormatKeys(oCommandMetaData, _xColumns);
+ }
+
+ public int getFieldType()
+ {
+ if (m_nFieldType == 0)
+ {
+ DBMetaData.CommandObject oTable = m_aCommandMetaData.getTableByName(m_sCommandName);
+ initializeFormatKeys(m_aCommandMetaData, oTable.getColumns());
+ }
+ return m_nFieldType;
+ }
+
+ public int getFieldWidth()
+ {
+ getFieldType(); // will collect meta data 'bout the column, if not already done so
+ return FieldWidth;
+ }
+
+ public int getDBFormatKey()
+ {
+ getFieldType(); // will collect meta data 'bout the column, if not already done so
+ return m_nDBFormatKey;
+ }
+
+ public int getStandardFormatKey()
+ {
+ getFieldType(); // will collect meta data 'bout the column, if not already done so
+ return StandardFormatKey;
+ }
+ public boolean isNumberFormat()
+ {
+ getFieldType(); // will collect meta data 'bout the column, if not already done so
+ return bIsNumberFormat;
+ }
+
+ /**
+ * Remove the pre name, we want the name after the 'dot'
+ * @param _DisplayFieldName
+ * @param _CommandName
+ * @return
+ */
+ private String getOnlyFieldName(String _DisplayFieldName, String _CommandName)
+ {
+ final String sName = _DisplayFieldName.substring(_CommandName.length() + 1, _DisplayFieldName.length());
+ return sName;
+ }
+
+ public static String composeDisplayFieldName(String _sCommandName, String _sFieldName)
+ {
+ return _sCommandName + "." + _sFieldName;
+ }
+
+ private void initializeFormatKeys(CommandMetaData oCommandMetaData, XNameAccess _xColumns)
+ {
+ try
+ {
+ m_xColPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xColumns.getByName(m_sFieldName));
+ ColIndex = JavaTools.FieldInList(_xColumns.getElementNames(), m_sFieldName) + 1;
+ m_nFieldType = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Type"));
+ getTyperelatedFieldData();
+
+ if (bFormatKeysInitialized == false)
+ {
+ final NumberFormatter aNumberFormatter = oCommandMetaData.getNumberFormatter();
+
+ iDateFormatKey = aNumberFormatter.getDateFormatKey();
+ iDateTimeFormatKey = aNumberFormatter.getDateTimeFormatKey();
+ iNumberFormatKey = aNumberFormatter.getNumberFormatKey();
+ iTextFormatKey = aNumberFormatter.getTextFormatKey();
+ iTimeFormatKey = aNumberFormatter.getTimeFormatKey();
+ iLogicalFormatKey = aNumberFormatter.getLogicalFormatKey();
+ bFormatKeysInitialized = true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public XPropertySet getXColumnPropertySet()
+ {
+ getFieldType(); // will collect meta data 'bout the column, if not already done so
+ return m_xColPropertySet;
+ }
+
+ public void setCommandName(String _CommandName)
+ {
+ m_sCommandName = _CommandName;
+ }
+
+ public String getDisplayFieldName()
+ {
+ return m_sDisplayFieldName;
+ }
+
+ public String getCommandName()
+ {
+ return m_sCommandName;
+ }
+
+ public String getFieldName()
+ {
+ return m_sFieldName;
+ }
+
+ public String getFieldTitle()
+ {
+ return FieldTitle;
+ }
+
+ public void setFieldTitle(String _sTitle)
+ {
+ FieldTitle = _sTitle;
+ }
+
+ public static String getCommandName(String _DisplayName)
+ {
+ String locCommandName = null;
+ String[] sFieldMetaData = JavaTools.ArrayoutofString(_DisplayName, ".");
+ if (sFieldMetaData.length >= 2)
+ {
+ String locfieldname = sFieldMetaData[sFieldMetaData.length - 1];
+ locCommandName = _DisplayName.substring(0, _DisplayName.length() - locfieldname.length() - 1);
+ }
+ return locCommandName;
+ }
+
+ public boolean isBoolean()
+ {
+ boolean bIsBoolean = false;
+ switch ( getFieldType() )
+ {
+ case DataType.BIT: // == -7;
+ case DataType.BOOLEAN:
+ bIsBoolean = true;
+ break;
+ default:
+ bIsBoolean = false;
+ }
+ return bIsBoolean;
+ }
+
+ private void getTyperelatedFieldData()
+ {
+ try
+ {
+ switch ( getFieldType() )
+ {
+ case DataType.BIT: // == -7;
+ case DataType.BOOLEAN:
+ // Todo: Look if the defaultvalue has been set in the Datasource
+ StandardFormatKey = iLogicalFormatKey;
+ FieldWidth = 5;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.TINYINT: // == -6;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 5;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.SMALLINT: // == 5;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 5;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.INTEGER: // == 4;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 10;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.BIGINT: // == -5;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 15;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.CHAR: // == 1;
+ StandardFormatKey = iTextFormatKey;
+ getTextFieldWidth(10);
+ bIsNumberFormat = false;
+ break;
+
+ case DataType.VARCHAR: // == 12;
+ StandardFormatKey = iTextFormatKey;
+ getTextFieldWidth(30);
+ bIsNumberFormat = false;
+ break;
+
+ case DataType.LONGVARCHAR: // == -1;
+ StandardFormatKey = iTextFormatKey;
+ getTextFieldWidth(60);
+ bIsNumberFormat = false;
+ break;
+
+ case DataType.NUMERIC: // == 2;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 20;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.DECIMAL: // == 3; [mit Nachkommastellen]
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 10 + AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Scale")) + 1;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.FLOAT: // == 6;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 10 + AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Scale")) + 1;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.REAL: // == 7;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 10 + AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Scale")) + 1;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.DOUBLE: // == 8;
+ StandardFormatKey = iNumberFormatKey;
+ FieldWidth = 10 + AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Scale")) + 1;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.DATE: // == 91;
+ StandardFormatKey = iDateFormatKey;
+ FieldWidth = 10;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.TIME: // == 92;
+ StandardFormatKey = iTimeFormatKey;
+ FieldWidth = 10;
+ bIsNumberFormat = true;
+ break;
+
+ case DataType.TIMESTAMP: // == 93;
+ StandardFormatKey = iDateTimeFormatKey;
+ FieldWidth = 20;
+ bIsNumberFormat = true;
+ break;
+ }
+
+ Object oKey = m_xColPropertySet.getPropertyValue("FormatKey");
+ if (AnyConverter.isVoid(oKey))
+ {
+ m_nDBFormatKey = StandardFormatKey;
+ }
+ else
+ {
+ m_nDBFormatKey = AnyConverter.toInt(oKey);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ m_nDBFormatKey = StandardFormatKey;
+ }
+ }
+
+ private void getTextFieldWidth(int iWidth)
+ {
+ try
+ {
+ FieldWidth = AnyConverter.toInt(m_xColPropertySet.getPropertyValue("Precision"));
+ if (FieldWidth > 0)
+ {
+ if (FieldWidth > (2 * iWidth))
+ {
+ FieldWidth = 2 * iWidth;
+ }
+ else if (FieldWidth == 0)
+ {
+ FieldWidth = iWidth;
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void initDefaultValue()
+ {
+ switch (getFieldType())
+ {
+ case DataType.BIT: // == -7;
+ case DataType.BOOLEAN:
+ DefaultValue = (Object) Integer.valueOf("1");
+ break;
+
+ case DataType.TINYINT: // == -6;
+ DefaultValue = (Object) Integer.valueOf("98");
+ break;
+
+ case DataType.SMALLINT: // == 5;
+ DefaultValue = (Object) Integer.valueOf("987");
+ break;
+
+ case DataType.INTEGER: // == 4;
+ DefaultValue = (Object) Integer.valueOf("9876");
+ break;
+
+ case DataType.BIGINT: // == -5;
+ DefaultValue = (Object) Integer.valueOf("98765");
+ break;
+
+ case DataType.CHAR: // == 1;
+ DefaultValue = (Object) String.valueOf('x');
+ break;
+
+ case DataType.VARCHAR: // == 12;
+ DefaultValue = (Object) BlindtextCreator.getBlindTextString(FieldTitle, FieldWidth, FieldWidth);
+ break;
+
+ case DataType.LONGVARCHAR: // == -1;
+ DefaultValue = (Object) BlindtextCreator.getBlindTextString(FieldTitle, FieldWidth, FieldWidth);
+ break;
+
+ case DataType.NUMERIC: // == 2;
+ DefaultValue = (Object) Double.valueOf("9876.5");
+ break;
+
+ case DataType.DECIMAL: // == 3; [mit Nachkommastellen]
+ DefaultValue = (Object) Double.valueOf("9876.5");
+ break;
+
+ case DataType.FLOAT: // == 6;
+ DefaultValue = (Object) Double.valueOf("9876.5");
+ break;
+
+ case DataType.REAL: // == 7;
+ DefaultValue = (Object) Double.valueOf("9876.5");
+ break;
+
+ case DataType.DOUBLE: // == 8;
+ DefaultValue = (Object) Double.valueOf("9876.54");
+ break;
+
+ case DataType.DATE: // == 91;
+ DefaultValue = (Object) Double.valueOf("42510");
+ break;
+
+ case DataType.TIME: // == 92;
+ DefaultValue = (Object) Double.valueOf("10");
+ break;
+
+ case DataType.TIMESTAMP: // == 93;
+ DefaultValue = (Object) Double.valueOf("5454110");
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ public Object getDefaultValue()
+ {
+ if ( DefaultValue == null )
+ initDefaultValue();
+ return DefaultValue;
+ }
+
+}
diff --git a/wizards/com/sun/star/wizards/db/MANIFEST.MF b/wizards/com/sun/star/wizards/db/MANIFEST.MF
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/MANIFEST.MF
diff --git a/wizards/com/sun/star/wizards/db/QueryMetaData.java b/wizards/com/sun/star/wizards/db/QueryMetaData.java
new file mode 100644
index 000000000000..bad14c2faa20
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/QueryMetaData.java
@@ -0,0 +1,300 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.PropertyValue;
+
+import java.util.*;
+import com.sun.star.lang.Locale;
+import com.sun.star.wizards.common.*;
+
+public class QueryMetaData extends CommandMetaData
+{
+
+ private SQLQueryComposer oSQLQueryComposer = null;
+ FieldColumn CurFieldColumn;
+ public String Command;
+ // Vector CommandNamesV;
+ private PropertyValue[][] m_aFilterConditions; /* = new PropertyValue[][] {}; */
+
+ public PropertyValue[][] GroupByFilterConditions = new PropertyValue[][]
+ {
+ };
+ public String[] UniqueAggregateFieldNames = new String[]
+ {
+ };
+ public int Type = QueryType.SODETAILQUERY;
+
+ public static interface QueryType
+ {
+
+ final static int SOSUMMARYQUERY = 0;
+ final static int SODETAILQUERY = 1;
+ }
+
+ public QueryMetaData(XMultiServiceFactory xMSF, Locale CharLocale, NumberFormatter oNumberFormatter)
+ {
+ super(xMSF, CharLocale, oNumberFormatter);
+ }
+
+ public QueryMetaData(XMultiServiceFactory _xMSF)
+ {
+ super(_xMSF);
+ }
+
+ public void setFilterConditions(PropertyValue[][] _FilterConditions)
+ {
+ this.m_aFilterConditions = _FilterConditions;
+ }
+
+ public PropertyValue[][] getFilterConditions()
+ {
+ if (m_aFilterConditions == null)
+ {
+ m_aFilterConditions = new PropertyValue[][]
+ {
+ };
+ }
+ return m_aFilterConditions;
+ }
+
+ public void setGroupByFilterConditions(PropertyValue[][] _GroupByFilterConditions)
+ {
+ this.GroupByFilterConditions = _GroupByFilterConditions;
+ }
+
+ public PropertyValue[][] getGroupByFilterConditions()
+ {
+ return this.GroupByFilterConditions;
+ }
+// public void addFieldColumn(String _FieldName, String _sCommandName){
+// FieldColumn oFieldColumn = getFieldColumn(_FieldName, _sCommandName);
+// if (oFieldColumn == null){
+// FieldColumn[] LocFieldColumns = new FieldColumn[FieldColumns.length + 1];
+// System.arraycopy(FieldColumns, 0, LocFieldColumns, 0, FieldColumns.length);
+// LocFieldColumns[FieldColumns.length] = new FieldColumn(this, _FieldName, _sCommandName);
+// FieldColumns = LocFieldColumns;
+// }
+// }
+ public void addSeveralFieldColumns(String[] _FieldNames, String _sCommandName)
+ {
+ Vector oToBeAddedFieldColumns = new Vector();
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ FieldColumn oFieldColumn = getFieldColumn(_FieldNames[i], _sCommandName);
+ if (oFieldColumn == null)
+ {
+ oToBeAddedFieldColumns.add(new FieldColumn(this, _FieldNames[i], _sCommandName, false));
+ }
+ }
+ if (oToBeAddedFieldColumns.size() > 0)
+ {
+ int nOldFieldCount = FieldColumns.length;
+ FieldColumn[] LocFieldColumns = new FieldColumn[nOldFieldCount + oToBeAddedFieldColumns.size()];
+ System.arraycopy(FieldColumns, 0, LocFieldColumns, 0, nOldFieldCount);
+ for (int i = 0; i < oToBeAddedFieldColumns.size(); i++)
+ {
+ LocFieldColumns[nOldFieldCount + i] = (FieldColumn) oToBeAddedFieldColumns.elementAt(i);
+ }
+ FieldColumns = LocFieldColumns;
+ }
+ }
+
+ public void reorderFieldColumns(String[] _sDisplayFieldNames)
+ {
+ FieldColumn[] LocFieldColumns = new FieldColumn[FieldColumns.length];
+ for (int i = 0; i < _sDisplayFieldNames.length; i++)
+ {
+ FieldColumn LocFieldColumn = this.getFieldColumnByDisplayName(_sDisplayFieldNames[i]);
+ LocFieldColumns[i] = LocFieldColumn;
+ }
+ System.arraycopy(LocFieldColumns, 0, FieldColumns, 0, LocFieldColumns.length);
+ }
+
+ public void removeSeveralFieldColumnsByDisplayFieldName(String[] _DisplayFieldNames)
+ {
+ Vector oRemainingFieldColumns = new Vector();
+ int a = 0;
+ for (int n = 0; n < FieldColumns.length; n++)
+ {
+ String sDisplayFieldName = FieldColumns[n].getDisplayFieldName();
+ if (!(JavaTools.FieldInList(_DisplayFieldNames, sDisplayFieldName) > -1))
+ {
+ oRemainingFieldColumns.add(FieldColumns[n]);
+ }
+ }
+ FieldColumns = new FieldColumn[oRemainingFieldColumns.size()];
+ oRemainingFieldColumns.toArray(FieldColumns);
+ }
+
+ public void removeFieldColumn(String _sFieldName, String _sCommandName)
+ {
+ FieldColumn oFieldColumn = getFieldColumn(_sFieldName, _sCommandName);
+ int a = 0;
+ if (oFieldColumn != null)
+ {
+ FieldColumn[] LocFieldColumns = new FieldColumn[FieldColumns.length - 1];
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (!FieldColumns[i].getFieldName().equals(_sFieldName))
+ {
+ if (!FieldColumns[i].getCommandName().equals(_sCommandName))
+ {
+ LocFieldColumns[a] = FieldColumns[i];
+ a++;
+ }
+ }
+ }
+ FieldColumns = LocFieldColumns;
+ }
+ }
+
+ public String[] getIncludedCommandNames()
+ {
+ // FieldColumn CurQueryField;
+ Vector CommandNamesV = new Vector(1);
+ // String CurCommandName;
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ final FieldColumn CurQueryField = FieldColumns[i];
+ final String CurCommandName = CurQueryField.getCommandName();
+ if (!CommandNamesV.contains(CurCommandName))
+ {
+ CommandNamesV.addElement(CurCommandName);
+ }
+ }
+ String[] sIncludedCommandNames = new String[CommandNamesV.size()];
+ CommandNamesV.toArray(sIncludedCommandNames);
+ return sIncludedCommandNames;
+ }
+
+ public static String[] getIncludedCommandNames(String[] _FieldNames)
+ {
+ Vector CommandNames = new Vector(1);
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ String CurCommandName = "";
+ String[] MetaList = JavaTools.ArrayoutofString(_FieldNames[i], ".");
+ if (MetaList.length > 1)
+ {
+ for (int a = 0; a < MetaList.length - 1; a++)
+ {
+ CurCommandName += MetaList[a];
+ }
+ if (!CommandNames.contains(CurCommandName))
+ {
+ CommandNames.addElement(CurCommandName);
+ }
+ }
+ }
+ String[] sIncludedCommandNames = new String[CommandNames.size()];
+ CommandNames.toArray(sIncludedCommandNames);
+ return sIncludedCommandNames;
+ }
+
+ public String[] getFieldNamesOfCommand(String _sCommandName)
+ {
+ CommandObject oTable = getTableByName(_sCommandName);
+ return oTable.getColumns().getElementNames();
+ }
+
+ public void initializeFieldTitleSet(boolean _bAppendMode)
+ {
+ try
+ {
+ // this.getIncludedCommandNames(); // fills the var CommandNamesV indirectly :-(
+ if (FieldTitleSet == null)
+ {
+ FieldTitleSet = new HashMap();
+ }
+ String[] aCommandNames = getIncludedCommandNames();
+ for (int i = 0; i < aCommandNames.length; i++)
+ {
+ String sCommandName = aCommandNames[i];
+ CommandObject oTable = getTableByName(sCommandName);
+ String sTableName = oTable.getName();
+ String[] LocFieldNames = oTable.getColumns().getElementNames();
+ for (int a = 0; a < LocFieldNames.length; a++)
+ {
+ String sDisplayFieldName = FieldColumn.composeDisplayFieldName(sTableName, LocFieldNames[a]);
+ if (!FieldTitleSet.containsKey(sDisplayFieldName))
+ {
+ FieldTitleSet.put(sDisplayFieldName, LocFieldNames[a]);
+ }
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getUniqueAggregateFieldNames()
+ {
+ Vector UniqueAggregateFieldVector = new Vector(0);
+ for (int i = 0; i < AggregateFieldNames.length; i++)
+ {
+ if (!UniqueAggregateFieldVector.contains(AggregateFieldNames[i][0]))
+ {
+ UniqueAggregateFieldVector.add(AggregateFieldNames[i][0]);
+ }
+ }
+ UniqueAggregateFieldNames = new String[UniqueAggregateFieldVector.size()];
+ UniqueAggregateFieldVector.toArray(UniqueAggregateFieldNames);
+ return UniqueAggregateFieldNames;
+ }
+
+ public boolean hasNumericalFields()
+ {
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ if (FieldColumns[i].isNumberFormat())
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public int getAggregateIndex(String _DisplayFieldName)
+ {
+ int iAggregate = -1;
+ if (Type == QueryType.SOSUMMARYQUERY)
+ {
+ iAggregate = JavaTools.FieldInTable(AggregateFieldNames, _DisplayFieldName);
+ }
+ return iAggregate;
+ }
+ public SQLQueryComposer getSQLQueryComposer()
+ {
+ if ( oSQLQueryComposer == null )
+ oSQLQueryComposer = new SQLQueryComposer(this);
+ return oSQLQueryComposer;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/RecordParser.java b/wizards/com/sun/star/wizards/db/RecordParser.java
new file mode 100644
index 000000000000..6c8ddb5b2c36
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/RecordParser.java
@@ -0,0 +1,306 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.sdb.XCompletedExecution;
+import com.sun.star.lang.Locale;
+import com.sun.star.wizards.common.InvalidQueryException;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NumberFormatter;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.task.XInteractionHandler;
+
+public class RecordParser extends QueryMetaData
+{
+
+ XNameAccess xColumns;
+ com.sun.star.sdbc.XRow xRow;
+ com.sun.star.sdbc.XRow xResultSetRow;
+ public XResultSet ResultSet;
+ XInterface xRowSet;
+ XCompletedExecution xExecute;
+ XColumnsSupplier xRowSetColumnsSupplier;
+ XComponent xRowSetComponent;
+ XInteractionHandler xInteraction;
+ public FieldColumn[] GroupFieldColumns;
+ public FieldColumn[] RecordFieldColumns;
+
+ public RecordParser(XMultiServiceFactory _xMSF, Locale _aLocale, NumberFormatter _oNumberFormatter)
+ {
+ super(_xMSF, _aLocale, _oNumberFormatter);
+ getInterfaces();
+ }
+
+ /** Creates a new instance of RecordParser */
+ public RecordParser(XMultiServiceFactory _xMSF)
+ {
+ super(_xMSF);
+ getInterfaces();
+ }
+
+ private void getInterfaces()
+ {
+ try
+ {
+ xRowSet = (XInterface) xMSF.createInstance("com.sun.star.sdb.RowSet");
+ xRowSetColumnsSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xRowSet);
+ xRowSetComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xRowSet);
+ xExecute = (com.sun.star.sdb.XCompletedExecution) UnoRuntime.queryInterface(com.sun.star.sdb.XCompletedExecution.class, xRowSet);
+ XInterface oInteraction = (XInterface) xMSF.createInstance("com.sun.star.task.InteractionHandler");
+ xInteraction = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, oInteraction);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ private Object getColumnStringValue(int ColIndex)
+ {
+ try
+ {
+ com.sun.star.uno.Type CurType;
+ Object oAny;
+ String sValue = xResultSetRow.getString(ColIndex); //???
+ CurType = new com.sun.star.uno.Type(String.class);
+ oAny = AnyConverter.toObject(CurType, sValue);
+ return oAny;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ private Object getColumnDoubleValue(int ColIndex, boolean bisDate)
+ {
+ try
+ {
+ Double DblValue;
+ if (bisDate)
+ {
+ DblValue = new Double(xResultSetRow.getDouble(ColIndex) + (double) super.getNullDateCorrection());
+ }
+ else
+ {
+ DblValue = new Double(xResultSetRow.getDouble(ColIndex));
+ }
+ if (!xResultSetRow.wasNull())
+ {
+ return DblValue;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return Any.VOID;
+ }
+
+ public Object getColumnValue(int ColIndex, int iType)
+ {
+ boolean bResult;
+ Object oAny = Any.VOID;
+ switch (iType)
+ {
+ case DataType.BIT: // == -7;
+ case DataType.BOOLEAN:
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.TINYINT: // == -6;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.BIGINT: // == -5;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.CHAR: // == 1;
+ oAny = getColumnStringValue(ColIndex);
+ break;
+
+ case DataType.VARCHAR: // == 12;
+ oAny = getColumnStringValue(ColIndex);
+ // double sResult = xResultSetRow.getClob(ColIndex); //???
+ break;
+
+ case DataType.LONGVARCHAR: // == -1;
+ oAny = getColumnStringValue(ColIndex);
+ // double sResult = xResultSetRow.getCharacterStream(ColIndex);
+ break;
+
+ case DataType.NUMERIC: // == 2;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.INTEGER: // == 4;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.SMALLINT: // == 5;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.DECIMAL: // == 3; [mit Nachkommastellen]
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.FLOAT: // == 6;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.REAL: // == 7;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.DOUBLE: // == 8;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.DATE: // == 91;
+ oAny = getColumnDoubleValue(ColIndex, true);
+ break;
+
+ case DataType.TIME: // == 92;
+ oAny = getColumnDoubleValue(ColIndex, false);
+ break;
+
+ case DataType.TIMESTAMP: // == 93;
+ oAny = getColumnDoubleValue(ColIndex, true);
+ break;
+ }
+
+ // Is the index OK; increment?
+ // String sValue = xResultSetRow.getString(ColIndex);
+ return oAny;
+ }
+
+ public boolean executeCommand(int _nCommandType) throws InvalidQueryException
+ {
+ try
+ {
+ Helper.setUnoPropertyValue(xRowSet, "DataSourceName", DataSourceName);
+ Helper.setUnoPropertyValue(xRowSet, "ActiveConnection", DBConnection);
+ Helper.setUnoPropertyValue(xRowSet, "Command", Command);
+ Helper.setUnoPropertyValue(xRowSet, "CommandType", new Integer(_nCommandType)); // CommandType
+ xExecute.executeWithCompletion(xInteraction);
+ com.sun.star.sdb.XResultSetAccess xResultAccess = (com.sun.star.sdb.XResultSetAccess) UnoRuntime.queryInterface(com.sun.star.sdb.XResultSetAccess.class, xRowSet);
+ ResultSet = xResultAccess.createResultSet();
+ xResultSetRow = (com.sun.star.sdbc.XRow) UnoRuntime.queryInterface(com.sun.star.sdbc.XRow.class, ResultSet);
+ XColumnsSupplier xDBCols = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, ResultSet);
+ xColumns = xDBCols.getColumns();
+ setCommandType(_nCommandType);
+ return true;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ throw new InvalidQueryException(xMSF, Command);
+ }
+ }
+
+ public boolean getFields(String[] _sFieldNames, boolean binitializeDBColumns)
+ {
+ try
+ {
+ if (binitializeDBColumns == true)
+ {
+ initializeFieldColumns(_sFieldNames, xColumns);
+ }
+ String[] AllQueryFieldNames = xColumns.getElementNames();
+ String[] sFieldNames = getFieldNames();
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ String sFieldName = FieldColumns[i].getFieldName();
+ int nColIndex = JavaTools.FieldInList(AllQueryFieldNames, sFieldName) + 1;
+ FieldColumns[i].ColIndex = nColIndex;
+ if (nColIndex == -1)
+ {
+ throw new InvalidQueryException(xMSF, Command);
+ }
+ }
+ GroupFieldColumns = getFieldColumnList(GroupFieldNames);
+ RecordFieldColumns = getFieldColumnList(getRecordFieldNames());
+ return true;
+ }
+ catch (InvalidQueryException queryexception)
+ {
+ queryexception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ private FieldColumn[] getFieldColumnList(String[] _FieldNames)
+ {
+ FieldColumn[] LocFieldColumns = new FieldColumn[_FieldNames.length];
+ for (int i = 0; i < _FieldNames.length; i++)
+ {
+ LocFieldColumns[i] = super.getFieldColumnByFieldName(_FieldNames[i]);
+ }
+ return LocFieldColumns;
+ }
+
+ public Object getGroupColumnValue(int ColIndex)
+ {
+ FieldColumn CurDBFieldColumn = this.GroupFieldColumns[ColIndex];
+ return getColumnValue(CurDBFieldColumn.ColIndex, CurDBFieldColumn.getFieldType());
+ }
+
+ public boolean getcurrentRecordData(java.util.Vector DataVector)
+ {
+ Object[] RecordValueArray = new Object[RecordFieldColumns.length];
+ for (int i = 0; i < RecordFieldColumns.length; i++)
+ {
+ FieldColumn CurDBFieldColumn = this.RecordFieldColumns[i];
+ RecordValueArray[i] = getColumnValue(CurDBFieldColumn.ColIndex, CurDBFieldColumn.getFieldType()); //FinalColIndex
+ }
+ DataVector.addElement(RecordValueArray);
+ return true;
+ }
+
+ public void dispose()
+ {
+ if (xRowSetComponent != null)
+ {
+ xRowSetComponent.dispose();
+ }
+ super.dispose();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/RelationController.java b/wizards/com/sun/star/wizards/db/RelationController.java
new file mode 100644
index 000000000000..acf47581d3e2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/RelationController.java
@@ -0,0 +1,161 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import java.util.Vector;
+
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.JavaTools;
+
+/**
+ * @author bc93774
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Style - Code Templates
+ */
+public class RelationController extends CommandName
+{
+
+ private int PKTABLE_CAT = 1;
+ private int PKTABLE_SCHEM = 2;
+ private int PKTABLE_NAME = 3;
+ private int PKCOLUMN_NAME = 4;
+ private int FKTABLE_CAT = 5;
+ private int FKTABLE_SCHEM = 6;
+ private int FKTABLE_NAME = 7;
+ private int FKCOLUMN_NAME = 8;
+
+ public RelationController(CommandMetaData _CommandMetaData, String _CatalogName, String _SchemaName, String _TableName, boolean _baddQuotation)
+ {
+ super(_CommandMetaData, _CatalogName, _SchemaName, _TableName, _baddQuotation);
+ }
+
+ public RelationController(CommandMetaData _CommandMetaData, String _DisplayName)
+ {
+ super(_CommandMetaData, _DisplayName);
+ }
+
+ public String[] getExportedKeys()
+ {
+ String[] sReferencedTableNames = new String[]
+ {
+ };
+ try
+ {
+ String[] sTableNames = super.getCommandMetaData().getTableNames();
+ Vector aReferencedTableVector = new Vector();
+ XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getExportedKeys((getCatalogName(this)), getSchemaName(), getTableName());
+ XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
+ while (xResultSet.next())
+ {
+ String sForeignCatalog = xRow.getString(FKTABLE_CAT);
+ String sForeignScheme = xRow.getString(FKTABLE_SCHEM);
+ String sForeignTableName = xRow.getString(FKTABLE_NAME);
+ CommandName oCommandName = new CommandName(getCommandMetaData(), sForeignCatalog, sForeignScheme, sForeignTableName, false);
+ aReferencedTableVector.add(oCommandName.getComposedName());
+ }
+ sReferencedTableNames = new String[aReferencedTableVector.size()];
+ aReferencedTableVector.toArray(sReferencedTableNames);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return sReferencedTableNames;
+ }
+
+ private Object getCatalogName(CommandName _oCommandName)
+ {
+ String sLocCatalog = _oCommandName.getCatalogName();
+ if (sLocCatalog.equals(""))
+ {
+ return null;
+ }
+ else
+ {
+ return sLocCatalog;
+ }
+ }
+
+ public String[][] getImportedKeyColumns(String _sreferencedtablename)
+ {
+ String[][] sKeyColumnNames = new String[][]
+ {
+ };
+ try
+ {
+ CommandName oLocCommandName = new CommandName(super.getCommandMetaData(), _sreferencedtablename);
+ XResultSet xResultSet = super.getCommandMetaData().xDBMetaData.getImportedKeys(getCatalogName(oLocCommandName), oLocCommandName.getSchemaName(), oLocCommandName.getTableName());
+ XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
+ boolean bleaveLoop = false;
+ Vector aMasterFieldNamesVector = new Vector();
+ Vector aSlaveFieldNamesVector = new Vector();
+ while (xResultSet.next() && !bleaveLoop)
+ {
+ String sPrimaryCatalog = null;
+ String sPrimarySchema = null;
+ if (super.getCommandMetaData().xDBMetaData.supportsCatalogsInDataManipulation())
+ {
+ sPrimaryCatalog = xRow.getString(PKTABLE_CAT);
+ }
+ if (super.getCommandMetaData().xDBMetaData.supportsSchemasInDataManipulation())
+ {
+ sPrimarySchema = xRow.getString(PKTABLE_SCHEM);
+ }
+ String sPrimaryTableName = xRow.getString(PKTABLE_NAME);
+ String sPrimaryColumnName = xRow.getString(PKCOLUMN_NAME);
+ String sForeignColumnName = xRow.getString(FKCOLUMN_NAME);
+ if (JavaTools.isSame(getTableName(), sPrimaryTableName))
+ {
+ if (sPrimarySchema == null || JavaTools.isSame(getSchemaName(), sPrimarySchema))
+ {
+ if (JavaTools.isSame(getCatalogName(), sPrimaryCatalog))
+ {
+ aSlaveFieldNamesVector.add(sForeignColumnName);
+ aMasterFieldNamesVector.add(sPrimaryColumnName);
+ bleaveLoop = true; //Only one relation may exist between two tables...
+ }
+ }
+
+ }
+ }
+ sKeyColumnNames = new String[2][aMasterFieldNamesVector.size()];
+ sKeyColumnNames[0] = new String[aSlaveFieldNamesVector.size()];
+ sKeyColumnNames[1] = new String[aMasterFieldNamesVector.size()];
+ aSlaveFieldNamesVector.toArray(sKeyColumnNames[0]);
+ aMasterFieldNamesVector.toArray(sKeyColumnNames[1]);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return sKeyColumnNames;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/SQLQueryComposer.java b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
new file mode 100644
index 000000000000..235da2d7c04a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/SQLQueryComposer.java
@@ -0,0 +1,489 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import java.util.Vector;
+
+// import com.sun.star.lang.IllegalArgumentException;
+// import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.beans.*;
+// import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XIndexAccess;
+// import com.sun.star.container.XNameAccess;
+import com.sun.star.sdbcx.XColumnsSupplier;
+// import com.sun.star.sdb.XColumn;
+import com.sun.star.sdb.XSQLQueryComposerFactory;
+import com.sun.star.sdb.XSingleSelectQueryComposer;
+import com.sun.star.sdb.XSingleSelectQueryAnalyzer;
+import com.sun.star.ui.dialogs.XExecutableDialog;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.awt.XWindow;
+import com.sun.star.sdb.SQLFilterOperator;
+
+import com.sun.star.wizards.common.*;
+
+public class SQLQueryComposer
+{
+
+ public XColumnsSupplier xColSuppl;
+ // XSQLQueryComposer xSQLQueryComposer;
+ QueryMetaData CurDBMetaData;
+ // String m_sSelectClause;
+ // String m_sFromClause;
+ public XSingleSelectQueryAnalyzer m_xQueryAnalyzer;
+ Vector composedCommandNames = new Vector(1);
+ private XSingleSelectQueryComposer m_queryComposer;
+ XMultiServiceFactory xMSF;
+ boolean bincludeGrouping = true;
+
+ public SQLQueryComposer(QueryMetaData _CurDBMetaData)
+ {
+ try
+ {
+ this.CurDBMetaData = _CurDBMetaData;
+ xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, CurDBMetaData.DBConnection);
+ final Object oQueryComposer = xMSF.createInstance("com.sun.star.sdb.SingleSelectQueryComposer");
+ m_xQueryAnalyzer = (XSingleSelectQueryAnalyzer) UnoRuntime.queryInterface(XSingleSelectQueryAnalyzer.class, oQueryComposer);
+ m_queryComposer = (XSingleSelectQueryComposer) UnoRuntime.queryInterface(XSingleSelectQueryComposer.class, m_xQueryAnalyzer);
+ XSQLQueryComposerFactory xSQLComposerFactory;
+ xSQLComposerFactory = (XSQLQueryComposerFactory) UnoRuntime.queryInterface(XSQLQueryComposerFactory.class, CurDBMetaData.DBConnection);
+ // /* XSQLQueryComposer */ xSQLQueryComposer = xSQLComposerFactory.createQueryComposer();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ private boolean addtoSelectClause(String DisplayFieldName) throws SQLException
+ {
+ if (bincludeGrouping)
+ {
+ if (CurDBMetaData.xDBMetaData.supportsGroupByUnrelated())
+ {
+ if (CurDBMetaData.GroupFieldNames != null)
+ {
+ if (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, DisplayFieldName) > -1)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ return true;
+ }
+
+ public String getSelectClause(boolean _baddAliasFieldNames) throws SQLException
+ {
+ String sSelectBaseClause = "SELECT ";
+ String sSelectClause = sSelectBaseClause;
+ for (int i = 0; i < CurDBMetaData.FieldColumns.length; i++)
+ {
+ if (addtoSelectClause(CurDBMetaData.FieldColumns[i].getDisplayFieldName()))
+ {
+ int iAggregate = CurDBMetaData.getAggregateIndex(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
+ if (iAggregate > -1)
+ {
+ sSelectClause += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + getComposedAliasFieldName(CurDBMetaData.AggregateFieldNames[iAggregate][0]) + ")";
+ if (_baddAliasFieldNames)
+ {
+ sSelectClause += getAliasFieldNameClause(CurDBMetaData.AggregateFieldNames[iAggregate][0]);
+ }
+ }
+ else
+ {
+ sSelectClause += getComposedAliasFieldName(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
+ if (_baddAliasFieldNames)
+ {
+ sSelectClause += getAliasFieldNameClause(CurDBMetaData.FieldColumns[i].getDisplayFieldName());
+ }
+ }
+ sSelectClause += ", ";
+ }
+ }
+ // TODO: little bit unhandy version of remove the append 'comma' at the end
+ if (sSelectClause.equals(sSelectBaseClause))
+ {
+ sSelectClause = sSelectClause.substring(0, sSelectClause.length() - 1);
+ }
+ else
+ {
+ sSelectClause = sSelectClause.substring(0, sSelectClause.length() - 2);
+ }
+ return sSelectClause;
+ }
+
+ public String getAliasFieldNameClause(String _FieldName)
+ {
+ String FieldTitle = CurDBMetaData.getFieldTitle(_FieldName);
+ if (!FieldTitle.equals(_FieldName))
+ {
+ return " AS " + CommandName.quoteName(FieldTitle, CurDBMetaData.getIdentifierQuote());
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public void appendFilterConditions() throws SQLException
+ {
+ try
+ {
+ for (int i = 0; i < CurDBMetaData.getFilterConditions().length; i++)
+ {
+ m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void prependSortingCriteria() throws SQLException
+ {
+ XIndexAccess xColumnIndexAccess = m_xQueryAnalyzer.getOrderColumns();
+ m_queryComposer.setOrder("");
+ for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++)
+ {
+ appendSortingCriterion(i, false);
+ }
+ for (int i = 0; i < xColumnIndexAccess.getCount(); i++)
+ {
+ try
+ {
+ XPropertySet xColumnPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xColumnIndexAccess.getByIndex(i));
+ String sName = (String) xColumnPropertySet.getPropertyValue("Name");
+ if (JavaTools.FieldInTable(CurDBMetaData.getSortFieldNames(), sName) == -1)
+ {
+ boolean bascend = AnyConverter.toBoolean(xColumnPropertySet.getPropertyValue("IsAscending"));
+ m_queryComposer.appendOrderByColumn(xColumnPropertySet, bascend);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+
+ private void appendSortingCriterion(int _SortIndex, boolean _baddAliasFieldNames) throws SQLException
+ {
+ String sSortValue = CurDBMetaData.getSortFieldNames()[_SortIndex][0];
+ XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(sSortValue, _baddAliasFieldNames);
+
+ String sSort = CurDBMetaData.getSortFieldNames()[_SortIndex][1];
+ boolean bascend = (sSort.equals("ASC"));
+ m_queryComposer.appendOrderByColumn(xColumn, bascend);
+ }
+
+ public void appendSortingcriteria(boolean _baddAliasFieldNames) throws SQLException
+ {
+ String sOrder = "";
+ m_queryComposer.setOrder("");
+ for (int i = 0; i < CurDBMetaData.getSortFieldNames().length; i++)
+ {
+ String sSortValue = CurDBMetaData.getSortFieldNames()[i][0];
+ int iAggregate = CurDBMetaData.getAggregateIndex(sSortValue);
+ if (iAggregate > -1)
+ {
+ sOrder = m_xQueryAnalyzer.getOrder();
+ if (sOrder.length() > 0)
+ {
+ sOrder += ", ";
+ }
+ sOrder += CurDBMetaData.AggregateFieldNames[iAggregate][1] + "(" + CurDBMetaData.AggregateFieldNames[iAggregate][0] + ")";
+ sOrder += " " + CurDBMetaData.getSortFieldNames()[i][1];
+ m_queryComposer.setOrder(sOrder);
+ }
+ else
+ {
+ appendSortingCriterion(i, _baddAliasFieldNames);
+ }
+ sOrder = m_xQueryAnalyzer.getOrder();
+ }
+ // just for debug!
+ sOrder = m_queryComposer.getOrder();
+ int dummy = 0;
+ }
+
+ public void appendGroupByColumns(boolean _baddAliasFieldNames) throws SQLException
+ {
+ for (int i = 0; i < CurDBMetaData.GroupFieldNames.length; i++)
+ {
+ XPropertySet xColumn = CurDBMetaData.getColumnObjectByFieldName(CurDBMetaData.GroupFieldNames[i], _baddAliasFieldNames);
+ m_queryComposer.appendGroupByColumn(xColumn);
+ }
+ String s = m_xQueryAnalyzer.getQuery();
+ }
+
+ public void setDBMetaData(QueryMetaData _oDBMetaData)
+ {
+ this.CurDBMetaData = _oDBMetaData;
+ }
+
+ private PropertyValue[][] replaceConditionsByAlias(PropertyValue _filterconditions[][])
+ {
+ for (int n = 0; n < _filterconditions.length; n++)
+ {
+ for (int m = 0; m < _filterconditions[n].length; m++)
+ {
+ _filterconditions[n][m].Name = getComposedAliasFieldName(_filterconditions[n][m].Name);
+ }
+ }
+ return _filterconditions;
+ }
+
+ public String getQuery()
+ {
+ return m_xQueryAnalyzer.getQuery();
+ }
+
+ public String getFromClause()
+ {
+ String sFromClause = "FROM";
+ composedCommandNames.clear();
+ String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
+ for (int i = 0; i < sCommandNames.length; i++)
+ {
+ CommandName curCommandName = new CommandName(CurDBMetaData, sCommandNames[i]); //(setComposedCommandName)
+ curCommandName.setAliasName(getuniqueAliasName(curCommandName.getTableName()));
+ sFromClause += " " + curCommandName.getComposedName() + " " + quoteName(curCommandName.getAliasName());
+ if (i < sCommandNames.length - 1)
+ {
+ sFromClause += ", ";
+ }
+ // fill composedCommandNames
+ composedCommandNames.add(curCommandName);
+ }
+ return sFromClause;
+ }
+
+ public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames)
+ {
+ return setQueryCommand(_xParentWindow,_bincludeGrouping, _baddAliasFieldNames,true);
+ }
+ public boolean setQueryCommand(XWindow _xParentWindow, boolean _bincludeGrouping, boolean _baddAliasFieldNames, boolean addQuery)
+ {
+ try
+ {
+ String s;
+ bincludeGrouping = _bincludeGrouping;
+ if ( addQuery )
+ {
+ String sFromClause = getFromClause();
+ String sSelectClause = getSelectClause(_baddAliasFieldNames);
+ String queryclause = sSelectClause + " " + sFromClause;
+ m_xQueryAnalyzer.setQuery(queryclause);
+ if (CurDBMetaData.getFilterConditions() != null)
+ {
+ if (CurDBMetaData.getFilterConditions().length > 0)
+ {
+ CurDBMetaData.setFilterConditions(replaceConditionsByAlias(CurDBMetaData.getFilterConditions()));
+ m_queryComposer.setStructuredFilter(CurDBMetaData.getFilterConditions());
+ }
+ }
+ }
+ s = m_xQueryAnalyzer.getQuery();
+ if (_bincludeGrouping)
+ {
+ appendGroupByColumns(_baddAliasFieldNames);
+ if (CurDBMetaData.GroupByFilterConditions.length > 0)
+ {
+ m_queryComposer.setStructuredHavingClause(CurDBMetaData.GroupByFilterConditions);
+ }
+ }
+ appendSortingcriteria(_baddAliasFieldNames);
+
+ s = m_xQueryAnalyzer.getQuery();
+ return true;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ displaySQLErrorDialog(exception, _xParentWindow);
+ return false;
+ }
+ }
+
+ private String getComposedAliasFieldName(String _fieldname)
+ {
+ FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByDisplayName(_fieldname);
+ CommandName curComposedCommandName = getComposedCommandByDisplayName(CurFieldColumn.getCommandName());
+ if ( curComposedCommandName == null )
+ return _fieldname;
+ String curAliasName = curComposedCommandName.getAliasName();
+ return quoteName(curAliasName) + "." + quoteName(CurFieldColumn.getFieldName());
+ }
+
+ private CommandName getComposedCommandByAliasName(String _AliasName)
+ {
+ if (composedCommandNames != null)
+ {
+ CommandName curComposedName;
+ for (int i = 0; i < composedCommandNames.size(); i++)
+ {
+ curComposedName = (CommandName) composedCommandNames.elementAt(i);
+ if (curComposedName.getAliasName().equals(_AliasName))
+ {
+ return curComposedName;
+ }
+ }
+ }
+ return null;
+ }
+
+ public CommandName getComposedCommandByDisplayName(String _DisplayName)
+ {
+ if (composedCommandNames != null)
+ {
+ CommandName curComposedName;
+ for (int i = 0; i < composedCommandNames.size(); i++)
+ {
+ curComposedName = (CommandName) composedCommandNames.elementAt(i);
+ if (curComposedName.getDisplayName().equals(_DisplayName))
+ {
+ return curComposedName;
+ }
+ }
+ }
+ return null;
+ }
+
+ public String getuniqueAliasName(String _TableName)
+ {
+ int a = 0;
+ String AliasName = "";
+ boolean bAliasNameexists = true;
+ String locAliasName = _TableName;
+ while (bAliasNameexists == true)
+ {
+ bAliasNameexists = (getComposedCommandByAliasName(locAliasName) != null);
+ if (bAliasNameexists)
+ {
+ a++;
+ locAliasName = _TableName + "_" + String.valueOf(a);
+ }
+ else
+ {
+ AliasName = locAliasName;
+ }
+ }
+ return AliasName;
+ }
+
+ private String quoteName(String _sname)
+ {
+ return CommandName.quoteName(_sname, CurDBMetaData.getIdentifierQuote());
+ }
+
+ public void displaySQLErrorDialog(Exception _exception, XWindow _xParentWindow)
+ {
+ try
+ {
+ Object oErrorDialog = CurDBMetaData.xMSF.createInstance("com.sun.star.sdb.ErrorMessageDialog");
+ XInitialization xInitialize = (XInitialization) UnoRuntime.queryInterface(XInitialization.class, oErrorDialog);
+ XExecutableDialog xExecute = (XExecutableDialog) UnoRuntime.queryInterface(XExecutableDialog.class, oErrorDialog);
+ PropertyValue[] rDispatchArguments = new PropertyValue[3];
+ rDispatchArguments[0] = Properties.createProperty("Title", Configuration.getProductName(CurDBMetaData.xMSF) + " Base");
+ rDispatchArguments[1] = Properties.createProperty("ParentWindow", _xParentWindow);
+ rDispatchArguments[2] = Properties.createProperty("SQLException", _exception);
+ xInitialize.initialize(rDispatchArguments);
+ xExecute.execute();
+ //TODO dispose???
+ }
+ catch (Exception typeexception)
+ {
+ typeexception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * retrieves a normalized structured filter
+ *
+ * <p>XSingleSelectQueryComposer.getStructuredFilter has a strange habit of returning the predicate (equal, not equal, etc)
+ * effectively twice: Once as SQLFilterOperator, and once in the value. That is, if you have a term "column <> 3", then
+ * you'll get an SQLFilterOperator.NOT_EQUAL (which is fine), <strong>and</strong> the textual value of the condition
+ * will read "<> 3". The latter is strange enough, but even more strange is that this behavior is not even consistent:
+ * for SQLFilterOperator.EQUAL, the "=" sign is not include in the textual value.</p>
+ *
+ * <p>To abstract from this weirdness, use this function here, which strips the unwanted tokens from the textual value
+ * representation.</p>
+ */
+ public PropertyValue[][] getNormalizedStructuredFilter()
+ {
+ final PropertyValue[][] structuredFilter = m_queryComposer.getStructuredFilter();
+ for ( int i=0; i<structuredFilter.length; ++i )
+ {
+ for ( int j=0; j<structuredFilter[i].length; ++j )
+ {
+ if ( !( structuredFilter[i][j].Value instanceof String ) )
+ continue;
+ final StringBuffer textualValue = new StringBuffer( (String)structuredFilter[i][j].Value );
+ switch ( structuredFilter[i][j].Handle )
+ {
+ case SQLFilterOperator.EQUAL:
+ break;
+ case SQLFilterOperator.NOT_EQUAL:
+ case SQLFilterOperator.LESS_EQUAL:
+ case SQLFilterOperator.GREATER_EQUAL:
+ textualValue.delete( 0, 2 );
+ break;
+ case SQLFilterOperator.LESS:
+ case SQLFilterOperator.GREATER:
+ textualValue.delete( 0, 1 );
+ break;
+ case SQLFilterOperator.NOT_LIKE:
+ textualValue.delete( 0, 8 );
+ break;
+ case SQLFilterOperator.LIKE:
+ textualValue.delete( 0, 4 );
+ break;
+ case SQLFilterOperator.SQLNULL:
+ textualValue.delete( 0, 7 );
+ break;
+ case SQLFilterOperator.NOT_SQLNULL:
+ textualValue.delete( 0, 11 );
+ break;
+ }
+ structuredFilter[i][j].Value = textualValue.toString().trim();
+ }
+ }
+ return structuredFilter;
+ }
+
+ public XSingleSelectQueryComposer getQueryComposer()
+ {
+ return m_queryComposer;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/db/TableDescriptor.java b/wizards/com/sun/star/wizards/db/TableDescriptor.java
new file mode 100644
index 000000000000..8e3b740417c4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/TableDescriptor.java
@@ -0,0 +1,861 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import com.sun.star.awt.XWindow;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.wizards.common.JavaTools;
+import java.util.Vector;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.ContainerEvent;
+import com.sun.star.container.XContainer;
+import com.sun.star.container.XContainerListener;
+import com.sun.star.container.XHierarchicalNameAccess;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbcx.KeyType;
+import com.sun.star.sdbcx.XAppend;
+import com.sun.star.sdbcx.XColumnsSupplier;
+import com.sun.star.sdbcx.XDataDescriptorFactory;
+import com.sun.star.sdbcx.XDrop;
+import com.sun.star.sdbcx.XKeysSupplier;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Properties;
+
+public class TableDescriptor extends CommandMetaData implements XContainerListener
+{
+
+ XDataDescriptorFactory xTableDataDescriptorFactory;
+ XPropertySet xPropTableDataDescriptor;
+ private XNameAccess xNameAccessColumns;
+ private XIndexAccess xIndexAccessKeys;
+ public XDataDescriptorFactory xColumnDataDescriptorFactory;
+ XContainer xTableContainer;
+ XAppend xTableAppend;
+ XDrop xTableDrop;
+ private XAppend xKeyAppend;
+ private XDrop xKeyDrop;
+ private String[] sTableFilters = null;
+ private Vector columncontainer;
+ private Vector keycolumncontainer;
+ public XHierarchicalNameAccess xTableHierarchicalNameAccess;
+ private CommandName ComposedTableName;
+ private XAppend xKeyColAppend;
+ private XColumnsSupplier xKeyColumnSupplier;
+ private XPropertySet xKey;
+ private boolean bIDFieldisInserted = false;
+ private String IDFieldName = "";
+ private String sColumnAlreadyExistsMessage = "";
+// private WizardDialog oUnoDialog;
+ private XWindow xWindow;
+
+ /**
+ * @param xMSF
+ */
+ public TableDescriptor(XMultiServiceFactory xMSF, XWindow _xWindow, String _sColumnAlreadyExistsMessage)
+ {
+ super(xMSF);
+ columncontainer = new Vector();
+ keycolumncontainer = new Vector();
+ sColumnAlreadyExistsMessage = _sColumnAlreadyExistsMessage;
+ xWindow = _xWindow;
+ }
+
+ private class ColumnDescriptor
+ {
+
+ String Name;
+ XPropertySet xColPropertySet;
+
+ public ColumnDescriptor(XPropertySet _xColPropertySet, String _Name)
+ {
+ Name = _Name;
+ xColPropertySet = _xColPropertySet;
+ }
+ }
+
+ public boolean getConnection(PropertyValue[] _curPropertyValue)
+ {
+ if (super.getConnection(_curPropertyValue))
+ {
+ // XTablesSupplier xDBTables = (XTablesSupplier) UnoRuntime.queryInterface(XTablesSupplier.class, DBConnection);
+ // xTableNames = xDBTables.getTables();
+ xTableAppend = UnoRuntime.queryInterface( XAppend.class, getTableNamesAsNameAccess() );
+ xTableDrop = UnoRuntime.queryInterface( XDrop.class, getTableNamesAsNameAccess() );
+ xTableDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, getTableNamesAsNameAccess() );
+ xPropTableDataDescriptor = xTableDataDescriptorFactory.createDataDescriptor();
+ XColumnsSupplier xColumnsSupplier = UnoRuntime.queryInterface( XColumnsSupplier.class, xPropTableDataDescriptor );
+ xNameAccessColumns = xColumnsSupplier.getColumns();
+ xColumnDataDescriptorFactory = UnoRuntime.queryInterface( XDataDescriptorFactory.class, xNameAccessColumns );
+ try
+ {
+ createTypeInspector();
+ sTableFilters = (String[]) AnyConverter.toArray(getDataSourcePropertySet().getPropertyValue("TableFilter"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ private void removePrimaryKeys()
+ {
+ if (keycolumncontainer.size() > 0)
+ {
+ for (int i = (keycolumncontainer.size() - 1); i >= 0; i--)
+ {
+ keycolumncontainer.remove(i);
+ }
+ }
+ }
+
+ public boolean createPrimaryKeys(String[] _fieldnames, boolean _bAutoincrementation)
+ {
+ try
+ {
+ XKeysSupplier xKeySupplier = (XKeysSupplier) UnoRuntime.queryInterface(XKeysSupplier.class, xPropTableDataDescriptor);
+ xIndexAccessKeys = xKeySupplier.getKeys();
+ XDataDescriptorFactory xKeyFac = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, xIndexAccessKeys);
+ xKeyDrop = (XDrop) UnoRuntime.queryInterface(XDrop.class, xIndexAccessKeys);
+ xKeyAppend = (XAppend) UnoRuntime.queryInterface(XAppend.class, xKeyFac);
+ xKey = xKeyFac.createDataDescriptor();
+ xKey.setPropertyValue("Type", new Integer(KeyType.PRIMARY));
+ xKeyColumnSupplier = (XColumnsSupplier) UnoRuntime.queryInterface(XColumnsSupplier.class, xKey);
+ XDataDescriptorFactory xKeyColFac = (XDataDescriptorFactory) UnoRuntime.queryInterface(XDataDescriptorFactory.class, xKeyColumnSupplier.getColumns());
+ xKeyColAppend = (XAppend) UnoRuntime.queryInterface(XAppend.class, xKeyColFac);
+ removePrimaryKeys();
+ for (int i = 0; i < _fieldnames.length; i++)
+ {
+ XPropertySet xKeyColPropertySet = xKeyColFac.createDataDescriptor();
+ xKeyColPropertySet.setPropertyValue("Name", _fieldnames[i]);
+ keycolumncontainer.add(xKeyColPropertySet);
+ XPropertySet xColPropertySet = null;
+ if (hasByName(_fieldnames[i]))
+ {
+ xColPropertySet = getByName(_fieldnames[i]);
+ }
+ else
+ {
+ xColPropertySet = addPrimaryKeyColumn(_fieldnames[i]);
+ }
+ xColPropertySet.setPropertyValue("IsNullable", new Integer(com.sun.star.sdbc.ColumnValue.NO_NULLS));
+ if (_bAutoincrementation)
+ {
+ int nDataType = oTypeInspector.getAutoIncrementIndex(xColPropertySet);
+ if (nDataType != oTypeInspector.INVALID)
+ {
+ if (xColPropertySet.getPropertySetInfo().hasPropertyByName("IsAutoIncrement"))
+ {
+ xColPropertySet.setPropertyValue("Type", new Integer(nDataType));
+ xColPropertySet.setPropertyValue("IsAutoIncrement", new Boolean(_bAutoincrementation));
+ }
+ }
+ }
+ modifyColumn(_fieldnames[i], xColPropertySet);
+ }
+ return true;
+ }
+ catch (UnknownPropertyException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (PropertyVetoException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (WrappedTargetException e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ return false;
+ }
+
+ public boolean isColunnNameDuplicate(XNameAccess _xColumns, XPropertySet _xToBeAppendedPropertySet)
+ {
+ try
+ {
+ String sColumnName = (String) AnyConverter.toString(_xToBeAppendedPropertySet.getPropertyValue("Name"));
+ if (_xColumns.hasByName(sColumnName))
+ {
+ String sMessage = JavaTools.replaceSubString(sColumnAlreadyExistsMessage, sColumnName, "%FIELDNAME");
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMessage);
+ return true;
+ }
+ return false;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ /**
+ * creates the table under the passed name
+ * @param _catalogname
+ * @param _schemaname
+ * @param _tablename is made unique if necessary
+ * @param _fieldnames
+ * @return true or false to indicate successful creation or not
+ */
+ public boolean createTable(String _catalogname, String _schemaname, String _tablename, String[] _fieldnames)
+ {
+ boolean breturn = true;
+ try
+ {
+ XAppend xAppendColumns = (XAppend) UnoRuntime.queryInterface(XAppend.class, xNameAccessColumns);
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ XPropertySet xColPropertySet = getByIndex(i);
+ if (!isColunnNameDuplicate(xNameAccessColumns, xColPropertySet))
+ {
+ xAppendColumns.appendByDescriptor(xColPropertySet); //xColPropertySet.setPropertyValue("Type", new Integer(32423))
+ }
+ else
+ {
+ breturn = false;
+ }
+ }
+ if (breturn)
+ {
+ assignTableProperty("Name", _tablename);
+ assignTableProperty("CatalogName", _catalogname);
+ assignTableProperty("SchemaName", _schemaname);
+ xTableContainer = (XContainer) UnoRuntime.queryInterface(XContainer.class, getTableNamesAsNameAccess());
+ xTableContainer.addContainerListener(this);
+ if (keycolumncontainer.size() > 0)
+ {
+ for (int i = 0; i < keycolumncontainer.size(); i++)
+ {
+ XPropertySet xKeyColPropertySet = (XPropertySet) keycolumncontainer.get(i);
+ if (!isColunnNameDuplicate(xKeyColumnSupplier.getColumns(), xKeyColPropertySet))
+ {
+ xKeyColAppend.appendByDescriptor(xKeyColPropertySet);
+ }
+ else
+ {
+ breturn = false;
+ }
+ }
+ if (breturn)
+ {
+ xKeyAppend.appendByDescriptor(xKey);
+ }
+ }
+ if (breturn)
+ {
+ // TODO: LLA: describe what is he doing here.
+ xTableAppend.appendByDescriptor(xPropTableDataDescriptor);
+ }
+ }
+ }
+ catch (SQLException oSQLException)
+ {
+ super.callSQLErrorMessageDialog(oSQLException, xWindow);
+ breturn = false;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ breturn = false;
+ }
+ if (!breturn)
+ {
+ removeAllColumnsFromDescriptor(_tablename);
+ this.removePrimaryKeys();
+ }
+ return breturn;
+ }
+
+ private boolean removeAllColumnsFromDescriptor(String _tablename)
+ {
+ try
+ {
+ xPropTableDataDescriptor.setPropertyValue("Name", "");
+ if ((xKeyDrop != null) && (xIndexAccessKeys != null))
+ {
+ int icount = xIndexAccessKeys.getCount();
+ if (icount > 0)
+ {
+ for (int i = xIndexAccessKeys.getCount() - 1; i >= 0; i--)
+ {
+ xKeyDrop.dropByIndex(i);
+ }
+ }
+ }
+ XDrop xColumnDrop = (XDrop) UnoRuntime.queryInterface(XDrop.class, xNameAccessColumns);
+ for (int i = xNameAccessColumns.getElementNames().length - 1; i >= 0; i--)
+ {
+ xColumnDrop.dropByIndex(i);
+ }
+ if (xTableDrop != null)
+ {
+ if (getTableNamesAsNameAccess().hasByName(_tablename))
+ {
+ xTableDrop.dropByName(_tablename);
+ }
+ }
+ if (bIDFieldisInserted)
+ {
+ this.dropColumnbyName(this.IDFieldName);
+ bIDFieldisInserted = false;
+ }
+ return false;
+ }
+ catch (SQLException oSQLException)
+ {
+ super.callSQLErrorMessageDialog(oSQLException, xWindow);
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public boolean createTable(String _catalogname, String _schemaname, String _tablename, String[] _keycolumnnames, boolean _bAutoincrementation, String[] _fieldnames)
+ {
+ if (createPrimaryKeys(_keycolumnnames, _bAutoincrementation))
+ {
+ return createTable(_catalogname, _schemaname, _tablename, _fieldnames);
+ }
+ return false;
+ }
+
+ private void assignTableProperty(String _spropname, String _svalue)
+ {
+ if (_svalue != null)
+ {
+ if (!_svalue.equals(""))
+ {
+ try
+ {
+ xPropTableDataDescriptor.setPropertyValue(_spropname, _svalue);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+ }
+
+ public boolean modifyColumnName(String _soldname, String _snewname)
+ {
+ try
+ {
+ return modifyColumn(_soldname, "Name", _snewname);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, e.getMessage());
+ return false;
+ }
+ }
+
+ public boolean modifyColumn(String _sname, String _spropname, Object _oValue)
+ {
+ try
+ {
+ if (this.columncontainer.size() > 0)
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ if (oColumnDescriptor.Name.equals(_sname))
+ {
+ oColumnDescriptor.xColPropertySet.setPropertyValue(_spropname, _oValue);
+ if (_spropname.equals("Name"))
+ {
+ oColumnDescriptor.Name = (String) _oValue;
+ }
+ columncontainer.remove(i);
+ columncontainer.insertElementAt(oColumnDescriptor, i);
+ return true;
+ }
+ }
+ }
+ }
+ catch (UnknownPropertyException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (PropertyVetoException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ catch (WrappedTargetException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public boolean modifyColumn(String _sname, XPropertySet _xColPropertySet)
+ {
+ try
+ {
+ if (this.columncontainer.size() > 0)
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ if (oColumnDescriptor.Name.equals(_sname))
+ {
+ oColumnDescriptor.xColPropertySet = _xColPropertySet;
+ oColumnDescriptor.Name = (String) _xColPropertySet.getPropertyValue("Name");
+ columncontainer.remove(i);
+ columncontainer.insertElementAt(oColumnDescriptor, i);
+ return true;
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public void dropColumnbyName(String _sname)
+ {
+ try
+ {
+ if (columncontainer.size() > 0)
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ if (oColumnDescriptor != null)
+ {
+ if (oColumnDescriptor.Name.equals(_sname))
+ {
+ columncontainer.remove(i);
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getColumnNames()
+ {
+ if (columncontainer.size() > 0)
+ {
+ try
+ {
+ String[] fieldnames = new String[columncontainer.size()];
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ fieldnames[i] = oColumnDescriptor.Name;
+ }
+ return fieldnames;
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ return new String[]
+ {
+ };
+ }
+
+ private boolean hasByName(String _fieldname)
+ {
+ try
+ {
+ if (columncontainer.size() > 0)
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ if (oColumnDescriptor.Name.equals(_fieldname))
+ {
+ return true;
+ }
+ }
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ private ColumnDescriptor getColumnDescriptorByName(String _fieldname)
+ {
+ try
+ {
+ if (this.columncontainer.size() > 0)
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ if (oColumnDescriptor.Name.equals(_fieldname))
+ {
+ return oColumnDescriptor;
+ }
+ }
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public XPropertySet getByName(String _fieldname)
+ {
+ ColumnDescriptor oColumnDescriptor = getColumnDescriptorByName(_fieldname);
+ if (oColumnDescriptor != null)
+ {
+ return oColumnDescriptor.xColPropertySet;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ private XPropertySet getByIndex(int _index)
+ {
+ try
+ {
+ if (columncontainer.size() > _index)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(_index);
+ return oColumnDescriptor.xColPropertySet;
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public XPropertySet clonePropertySet(String _snewname, XPropertySet _xnewPropertySet)
+ {
+ XPropertySet xRetPropertySet = xColumnDataDescriptorFactory.createDataDescriptor();
+ try
+ {
+ if (hasByName(_snewname))
+ {
+ Object oColumn = getByName(_snewname);
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oColumn);
+ Property[] aColProperties = xPropertySet.getPropertySetInfo().getProperties();
+ for (int i = 0; i < aColProperties.length; i++)
+ {
+ String sPropName = aColProperties[i].Name;
+ Object oColValue = _xnewPropertySet.getPropertyValue(sPropName);
+ xRetPropertySet.setPropertyValue(sPropName, oColValue);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return xRetPropertySet;
+ }
+
+ public boolean addColumn(PropertyValue[] _aNewPropertyValues)
+ {
+ try
+ {
+ String sname = (String) Properties.getPropertyValue(_aNewPropertyValues, "Name");
+ if (!hasByName(sname))
+ {
+ ColumnPropertySet oPropertySet = new ColumnPropertySet(oTypeInspector, xColumnDataDescriptorFactory.createDataDescriptor());
+ oPropertySet.assignPropertyValues(_aNewPropertyValues, true);
+ ColumnDescriptor oColumnDescriptor = new ColumnDescriptor(oPropertySet.xPropertySet, sname);
+ this.columncontainer.add(oColumnDescriptor);
+ return true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public boolean moveColumn(int _nOldIndex, int _nNewIndex)
+ {
+ try
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) this.columncontainer.get(_nOldIndex);
+ this.columncontainer.remove(_nOldIndex);
+ columncontainer.add(_nNewIndex, oColumnDescriptor);
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public boolean addColumn(String _columnname, XPropertySet _xNewColPropertySet)
+ {
+ try
+ {
+ if (!hasByName(_columnname))
+ {
+ if (_columnname.equals(""))
+ {
+ return false;
+ }
+ else
+ {
+ ColumnPropertySet oPropertySet = new ColumnPropertySet(oTypeInspector, xColumnDataDescriptorFactory.createDataDescriptor());
+ oPropertySet.assignNewPropertySet(_columnname, _xNewColPropertySet);
+ ColumnDescriptor oColumnDescriptor = new ColumnDescriptor(oPropertySet.xPropertySet, _columnname);
+ columncontainer.add(oColumnDescriptor);
+ return true;
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public XPropertySet addPrimaryKeyColumn(String _columnname)
+ {
+ try
+ {
+ if (!hasByName(_columnname))
+ {
+ try
+ {
+ XPropertySet xColPropertySet = xColumnDataDescriptorFactory.createDataDescriptor();
+ IDFieldName = Desktop.getUniqueName(getColumnNames(), _columnname, "");
+ xColPropertySet.setPropertyValue("Name", IDFieldName);
+
+ int nDataType = oTypeInspector.convertDataType(com.sun.star.sdbc.DataType.INTEGER);
+ xColPropertySet.setPropertyValue("Type", new Integer(nDataType));
+ xColPropertySet.setPropertyValue("TypeName", oTypeInspector.getDefaultTypeName(nDataType, null));
+ ColumnDescriptor oColumnDescriptor = new ColumnDescriptor(xColPropertySet, IDFieldName);
+ this.columncontainer.add(0, oColumnDescriptor);
+ this.bIDFieldisInserted = true;
+ return xColPropertySet;
+ }
+ catch (RuntimeException e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public String[] getNonBinaryFieldNames()
+ {
+ Vector NonBinaryFieldNameVector = new Vector();
+ try
+ {
+ for (int i = 0; i < columncontainer.size(); i++)
+ {
+ ColumnDescriptor oColumnDescriptor = (ColumnDescriptor) columncontainer.get(i);
+ XPropertySet xColPropertySet = getByName(oColumnDescriptor.Name);
+ Property[] aProperties = xColPropertySet.getPropertySetInfo().getProperties();
+ int itype;
+ try
+ {
+ itype = AnyConverter.toInt(xColPropertySet.getPropertyValue("Type"));
+ if (!isBinaryDataType(itype))
+ {
+ NonBinaryFieldNameVector.addElement(oColumnDescriptor.Name);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ String[] sbinaryfieldnames = new String[NonBinaryFieldNameVector.size()];
+ NonBinaryFieldNameVector.toArray(sbinaryfieldnames);
+ return sbinaryfieldnames;
+ }
+
+ public String getComposedTableName(String _scatalogname, String _sschemaname, String _stablename)
+ {
+ ComposedTableName = new CommandName(this, _scatalogname, _sschemaname, _stablename, false);
+ return ComposedTableName.getComposedName();
+ }
+
+ public String getComposedTableName()
+ {
+ if (ComposedTableName != null)
+ {
+ return this.ComposedTableName.getComposedName();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.container.XContainerListener#elementInserted(com.sun.star.container.ContainerEvent)
+ */
+ public void elementInserted(ContainerEvent arg0)
+ {
+ try
+ {
+ XPropertySet xTablePropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, arg0.Element);
+ String stablename = AnyConverter.toString(xTablePropertySet.getPropertyValue("Name"));
+ String sschemaname = AnyConverter.toString(xPropTableDataDescriptor.getPropertyValue("SchemaName"));
+ String scatalogname = AnyConverter.toString(xPropTableDataDescriptor.getPropertyValue("CatalogName"));
+ ComposedTableName = new CommandName(this, scatalogname, sschemaname, stablename, false);
+ appendTableNameToFilter(ComposedTableName.getComposedName());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.container.XContainerListener#elementRemoved(com.sun.star.container.ContainerEvent)
+ */
+ public void elementRemoved(ContainerEvent arg0)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.container.XContainerListener#elementReplaced(com.sun.star.container.ContainerEvent)
+ */
+ public void elementReplaced(ContainerEvent arg0)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ }
+
+ /**
+ * @param _stablename
+ * @return
+ */
+ public boolean appendTableNameToFilter(String _scomposedtablename)
+ {
+ boolean bhastoinsert = true;
+ for (int i = 0; i < sTableFilters.length; i++)
+ {
+ if (sTableFilters[i].compareTo("%") > -1)
+ {
+ if (sTableFilters[i].endsWith("." + _scomposedtablename))
+ {
+ bhastoinsert = false;
+ }
+ else if (sTableFilters[i].length() == 1)
+ {
+ bhastoinsert = false;
+ }
+ }
+ else if (sTableFilters[i].equals(_scomposedtablename))
+ {
+ bhastoinsert = false;
+ }
+ if (!bhastoinsert)
+ {
+ break;
+ }
+ }
+ if (bhastoinsert)
+ {
+ String[] sNewTableFilters = new String[sTableFilters.length + 1];
+ System.arraycopy(sTableFilters, 0, sNewTableFilters, 0, sTableFilters.length);
+ sNewTableFilters[sTableFilters.length] = _scomposedtablename;
+ sTableFilters = sNewTableFilters;
+ try
+ {
+ getDataSourcePropertySet().setPropertyValue("TableFilter", sTableFilters);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ bhastoinsert = false;
+ }
+ }
+ return bhastoinsert;
+ }
+}
+
diff --git a/wizards/com/sun/star/wizards/db/TypeInspector.java b/wizards/com/sun/star/wizards/db/TypeInspector.java
new file mode 100644
index 000000000000..1f22801fd8c5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/db/TypeInspector.java
@@ -0,0 +1,465 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.db;
+
+import java.util.Vector;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.sdbc.ColumnSearch;
+import com.sun.star.sdbc.ColumnValue;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.sdbc.XResultSet;
+import com.sun.star.sdbc.XRow;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.JavaTools;
+
+public class TypeInspector
+{
+
+ private String[] sDataTypeNames;
+ private int[] nDataTypeInfos;
+ private int[] nPrecisionInfos;
+ private int[] nNullableInfos;
+ private int[] nSearchables;
+ private boolean[] bisAutoIncrementableInfos;
+ private int[] nMinScaleInfos;
+ private int[] nMaxScaleInfos;
+ private int[] nNumericFallBackList = new int[]
+ {
+ DataType.INTEGER, DataType.FLOAT, DataType.REAL, DataType.DOUBLE, DataType.NUMERIC, DataType.DECIMAL
+ };
+ final int INVALID = 999999;
+ XResultSet xResultSet;
+
+ public class TypeInfo
+ {
+
+ public int nDataType;
+ public String sDataTypeName;
+ public boolean bisAutoIncrementable;
+
+ public TypeInfo(int _nDataType, String _sDataTypeName, boolean _bisAutoIncrementable)
+ {
+ nDataType = _nDataType;
+ sDataTypeName = _sDataTypeName;
+ bisAutoIncrementable = _bisAutoIncrementable;
+ }
+ }
+
+ public TypeInspector(XResultSet _xResultSet)
+ {
+ try
+ {
+ xResultSet = _xResultSet;
+ Vector<String> aTypeNameVector = new Vector<String>();
+ Vector<Integer> aTypeVector = new Vector<Integer>();
+ Vector<Integer> aNullableVector = new Vector<Integer>();
+ Vector<Boolean> aAutoIncrementVector = new Vector<Boolean>();
+ Vector<Integer> aPrecisionVector = new Vector<Integer>();
+ Vector<Integer> aMinScaleVector = new Vector<Integer>();
+ Vector<Integer> aMaxScaleVector = new Vector<Integer>();
+ Vector<Integer> aSearchableVector = new Vector<Integer>();
+ // Integer[] aIntegerDataTypes = null;
+// XResultSet xResultSet = xDBMetaDagetTypeInfo();
+ XRow xRow = (XRow) UnoRuntime.queryInterface(XRow.class, xResultSet);
+ while (xResultSet.next())
+ {
+ aTypeNameVector.addElement(new String(xRow.getString(1)));
+ aTypeVector.addElement(new Integer(xRow.getShort(2)));
+ aPrecisionVector.addElement(new Integer(xRow.getInt(3)));
+ aNullableVector.addElement(new Integer(xRow.getShort(7)));
+ aSearchableVector.addElement(new Integer(xRow.getShort(9)));
+ aAutoIncrementVector.addElement(new Boolean(xRow.getBoolean(12)));
+ aMinScaleVector.addElement(new Integer(xRow.getShort(14)));
+ aMaxScaleVector.addElement(new Integer(xRow.getShort(15)));
+
+ }
+ sDataTypeNames = new String[aTypeNameVector.size()];
+ aTypeNameVector.toArray(sDataTypeNames);
+ nDataTypeInfos = JavaTools.IntegerTointList(aTypeVector);
+ nNullableInfos = JavaTools.IntegerTointList(aNullableVector);
+ nSearchables = JavaTools.IntegerTointList(aSearchableVector);
+ bisAutoIncrementableInfos = JavaTools.BooleanTobooleanList(aAutoIncrementVector);
+ nPrecisionInfos = JavaTools.IntegerTointList(aPrecisionVector);
+ nMinScaleInfos = JavaTools.IntegerTointList(aMinScaleVector);
+ nMaxScaleInfos = JavaTools.IntegerTointList(aMaxScaleVector);
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public int getScale(XPropertySet _xColPropertySet)
+ {
+ try
+ {
+ int i = getDataTypeIndex(_xColPropertySet, false);
+ int nScale = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Scale"));
+ if (i == -1)
+ {
+ return nScale;
+ }
+ if (nScale > nMaxScaleInfos[i])
+ {
+ return nMaxScaleInfos[i];
+ }
+ else if (nScale < nMinScaleInfos[i])
+ {
+ return nMinScaleInfos[i];
+ }
+ else
+ {
+ return nScale;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return 0;
+ }
+ }
+
+ public int getNullability(XPropertySet _xColPropertySet, int _nNullable)
+ {
+ int i = getDataTypeIndex(_xColPropertySet, false);
+ if (i == -1)
+ {
+ return ColumnValue.NO_NULLS;
+ }
+ int nNullable = _nNullable;
+ if (nNullable == ColumnValue.NULLABLE)
+ {
+ return nNullableInfos[i]; //probably nullability is not allowed
+ }
+ return nNullable;
+ }
+
+ public int getNullability(XPropertySet _xColPropertySet)
+ {
+ try
+ {
+ int i = getDataTypeIndex(_xColPropertySet, false);
+ if (i == -1)
+ {
+ return ColumnValue.NO_NULLS;
+ }
+ int nNullable = AnyConverter.toInt(_xColPropertySet.getPropertyValue("IsNullable"));
+ if (nNullable == ColumnValue.NULLABLE)
+ {
+ return nNullableInfos[i];
+ }
+ return nNullable;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return ColumnValue.NO_NULLS;
+ }
+
+ public boolean isColumnOrderable(XPropertySet _xColPropertySet)
+ {
+ int i = getDataTypeIndex(_xColPropertySet, false);
+ if (i > -1)
+ {
+ return (nSearchables[i] != ColumnSearch.NONE);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int isNullable(XPropertySet _xColPropertySet)
+ {
+ int i = getDataTypeIndex(_xColPropertySet, false);
+ if (i > -1)
+ {
+ return nNullableInfos[i];
+ }
+ else
+ {
+ return ColumnValue.NO_NULLS;
+ }
+ }
+
+ private int getDataTypeIndex(XPropertySet _xColPropertySet, boolean _bCheckNumericAttributes)
+ {
+ try
+ {
+ int nPrecision = -1;
+ int nScale = -1;
+ int nDataType = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Type"));
+ String sTypeName = AnyConverter.toString(_xColPropertySet.getPropertyValue("TypeName"));
+ if (_bCheckNumericAttributes)
+ {
+ nPrecision = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Precision"));
+ nScale = AnyConverter.toInt(_xColPropertySet.getPropertyValue("Scale"));
+ }
+ boolean bleaveloop = false;
+ int startindex = 0;
+ while (!bleaveloop)
+ {
+ int i = JavaTools.FieldInIntTable(nDataTypeInfos, nDataType, startindex);
+ startindex = i + 1;
+ bleaveloop = (i < 0);
+ if (!bleaveloop)
+ {
+ if (sTypeName.equals(sDataTypeNames[i]))
+ {
+ if (_bCheckNumericAttributes)
+ {
+ if (nPrecision <= nPrecisionInfos[i])
+ {
+ if ((nScale >= nMinScaleInfos[i]) && (nScale <= nMinScaleInfos[i]))
+ {
+ return i;
+ }
+ }
+ }
+ else
+ {
+ return i;
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return -1;
+ }
+
+ public boolean supportsDataType(int _curDataType)
+ {
+ return (JavaTools.FieldInIntTable(nDataTypeInfos, _curDataType) > -1);
+ }
+
+ public int getLastConversionFallbackDataType()
+ {
+ if (supportsDataType(DataType.VARCHAR))
+ {
+ return DataType.VARCHAR;
+ }
+ else
+ {
+ return DataType.LONGVARCHAR;
+ }
+ }
+
+ /**
+ * an empty string is returned when no appropriate Typename can be found
+ * finds the first TypeName of the passed datatype.
+ * @param _curDataType
+ * @return
+ */
+ public String getDefaultTypeName(int _curDataType, Integer precision)
+ {
+ String ret = "";
+ for (int i = 0; i < nDataTypeInfos.length; i++)
+ {
+ if (nDataTypeInfos[i] == _curDataType)
+ {
+// System.out.println( "Desired prec " + precision + ",nPrecisionInfos[i]="+nPrecisionInfos[i] + ",sDataTypeNames[i]="+sDataTypeNames[i] );
+
+ if (precision == null || nPrecisionInfos[i] >= precision.intValue())
+ {
+ ret = sDataTypeNames[i]; // this fits best !
+ break;
+ }
+ else if (ret.length() == 0)
+ {
+ // in case we dont find anything else, we at return a typename
+ // with the correct class
+ ret = sDataTypeNames[i];
+ }
+ }
+ }
+// System.out.println( "_curDataType="+_curDataType+",precision="+precision+",ret="+
+ return ret;
+ }
+
+ public int getDataType(String _sTypeName)
+ {
+ int i = JavaTools.FieldInList(sDataTypeNames, _sTypeName);
+ if (i > -1)
+ {
+ return nDataTypeInfos[i];
+ }
+ else
+ {
+ return getLastConversionFallbackDataType();
+ }
+ }
+
+ public int convertDataType(int _curDataType)
+ {
+ int retDataType = _curDataType;
+ if (!supportsDataType(_curDataType))
+ {
+ switch (_curDataType)
+ {
+ case DataType.BIT:
+ retDataType = convertDataType(DataType.BOOLEAN);
+ break;
+ case DataType.BOOLEAN:
+ retDataType = convertDataType(DataType.BIT);
+ break;
+ case DataType.TINYINT:
+ retDataType = convertDataType(DataType.SMALLINT);
+ break;
+ case DataType.SMALLINT:
+ retDataType = convertDataType(DataType.INTEGER);
+ break;
+ case DataType.INTEGER:
+ retDataType = convertDataType(DataType.FLOAT);
+ break;
+ case DataType.FLOAT:
+ retDataType = convertDataType(DataType.REAL);
+ break;
+ case DataType.DATE:
+ case DataType.TIME:
+ retDataType = convertDataType(DataType.TIMESTAMP);
+ break;
+ case DataType.TIMESTAMP:
+ case DataType.REAL:
+ case DataType.BIGINT:
+ retDataType = convertDataType(DataType.DOUBLE);
+ break;
+ case DataType.DOUBLE:
+ retDataType = convertDataType(DataType.NUMERIC);
+ break;
+ case DataType.NUMERIC:
+ retDataType = convertDataType(DataType.DECIMAL);
+ break;
+ case DataType.DECIMAL:
+ if (supportsDataType(DataType.DOUBLE))
+ {
+ retDataType = convertDataType(DataType.DOUBLE);
+ }
+ else if (supportsDataType(DataType.NUMERIC))
+ {
+ retDataType = DataType.NUMERIC;
+ }
+ else
+ {
+ retDataType = getLastConversionFallbackDataType();
+ }
+ break;
+ case DataType.VARCHAR:
+ retDataType = getLastConversionFallbackDataType();
+ break;
+ default:
+ retDataType = getLastConversionFallbackDataType();
+ }
+ }
+ return retDataType;
+ }
+
+ public int getAutoIncrementIndex(XPropertySet _xColPropertySet)
+ {
+ try
+ {
+ boolean bleaveloop = false;
+ int startindex = 0;
+ int curDataType = ((Integer) _xColPropertySet.getPropertyValue("Type")).intValue();
+ while (!bleaveloop)
+ {
+ int i = JavaTools.FieldInIntTable(nDataTypeInfos, curDataType, startindex);
+ startindex = i + 1;
+ bleaveloop = (i == -1);
+ if (!bleaveloop)
+ {
+ if (bisAutoIncrementableInfos[i])
+ {
+ return nDataTypeInfos[i];
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return INVALID;
+
+ }
+
+ public boolean isAutoIncrementable(XPropertySet _xColPropertySet)
+ {
+ return (getAutoIncrementIndex(_xColPropertySet) != INVALID);
+ }
+
+ /** finds the first available DataType that can be used as a primary key in a table.
+ * @return The first datatype that also supports Autoincrmentation is taken according to the following list:
+ *1) INTEGER
+ *2) FLOAT
+ *3) REAL
+ *4) DOUBLE
+ *5) NUMERIC
+ *6) DECIMAL *
+ * If no appropriate datatype is found ther first available numeric type after DataType.INTEGER
+ * according to the 'convertDataType' method is returned
+ */
+ /**TODO the fallback order is the same as implemented in the method 'convertDataType'.
+ * It's not very elegant to have the same intelligence
+ * on several spots in the class!!
+ *
+ */
+ public TypeInfo findAutomaticPrimaryKeyType()
+ {
+ int nDataType;
+ for (int n = 0; n < this.nNumericFallBackList.length; n++)
+ {
+ nDataType = nNumericFallBackList[n];
+ boolean bleaveloop = false;
+ int startindex = 0;
+ while (!bleaveloop)
+ {
+ int i = JavaTools.FieldInIntTable(nDataTypeInfos, nDataType, startindex);
+ bleaveloop = (i < 0);
+ if (!bleaveloop)
+ {
+ if (this.bisAutoIncrementableInfos[i])
+ {
+ return new TypeInfo(nDataType, this.sDataTypeNames[i], true);
+ }
+ startindex = i + 1;
+ }
+ startindex = i + 1;
+ }
+ }
+ // As Autoincrementation is not supported for any numeric datatype we take the first available numeric Type;
+ nDataType = convertDataType(DataType.INTEGER);
+ return new TypeInfo(nDataType, getDefaultTypeName(nDataType, null), false);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/Control.java b/wizards/com/sun/star/wizards/document/Control.java
new file mode 100644
index 000000000000..fb4191277b8c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/Control.java
@@ -0,0 +1,359 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XLayoutConstrains;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNamed;
+import com.sun.star.wizards.common.*;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.lang.IllegalArgumentException;
+
+public class Control extends Shape
+{
+
+ XControlModel xControlModel;
+ XControl xControl;
+ public XPropertySet xPropertySet;
+ XPropertySet xControlPropertySet;
+ XWindowPeer xWindowPeer;
+ Object oDefaultValue;
+ GridControl oGridControl;
+ String sServiceName;
+ XNamed xNamed;
+ final int SOMAXTEXTSIZE = 50;
+ private int icontroltype;
+ protected XNameContainer xFormName;
+ protected final int IIMGFIELDWIDTH = 3000;
+
+ public Control()
+ {
+ }
+
+ public Control(FormHandler _oFormHandler, String _sServiceName, Point _aPoint)
+ {
+ super(_oFormHandler, _sServiceName, _aPoint, null);
+ }
+
+ public Control(FormHandler _oFormHandler, XNameContainer _xFormName, int _icontroltype, String _FieldName, Point _aPoint, Size _aSize)
+ {
+ super(_oFormHandler, _aPoint, _aSize);
+ xFormName = _xFormName;
+ createControl(_icontroltype, _aPoint, _aSize, null, _FieldName);
+ }
+
+ public Control(FormHandler _oFormHandler, XShapes _xGroupShapes, XNameContainer _xFormName, int _icontroltype, Point _aPoint, Size _aSize)
+ {
+ super(_oFormHandler, _aPoint, _aSize);
+ xFormName = _xFormName;
+ createControl(_icontroltype, _aPoint, _aSize, _xGroupShapes, null);
+ }
+
+ public Control(FormHandler _oFormHandler, int _icontroltype, Point _aPoint, Size _aSize)
+ {
+ super(_oFormHandler, _aPoint, _aSize);
+ createControl(_icontroltype, _aPoint, _aSize, null, null);
+ }
+
+ public void createControl(int _icontroltype, Point _aPoint, Size _aSize, XShapes _xGroupShapes, String _FieldName)
+ {
+ try
+ {
+ icontroltype = _icontroltype;
+ sServiceName = oFormHandler.sModelServices[getControlType()];
+ Object oControlModel = oFormHandler.xMSFDoc.createInstance(sServiceName);
+ xControlModel = UnoRuntime.queryInterface( XControlModel.class, oControlModel );
+ xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oControlModel );
+
+ XPropertySetInfo xPSI = xPropertySet.getPropertySetInfo();
+ if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) )
+ xPropertySet.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) );
+
+ insertControlInContainer(_FieldName);
+ xControlShape.setControl(xControlModel);
+ if (_xGroupShapes == null)
+ {
+ oFormHandler.xDrawPage.add(xShape);
+ }
+ else
+ {
+ _xGroupShapes.add(xShape);
+ }
+ xControl = oFormHandler.xControlAccess.getControl(xControlModel);
+ xControlPropertySet = UnoRuntime.queryInterface( XPropertySet.class, xControl );
+ xWindowPeer = xControl.getPeer();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void insertControlInContainer(String _fieldname)
+ {
+ try
+ {
+ if (xFormName != null)
+ {
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xFormName);
+ String sControlName = Desktop.getUniqueName(xNameAccess, getControlName(_fieldname));
+ xPropertySet.setPropertyValue("Name", sControlName);
+ xFormName.insertByName(sControlName, xControlModel);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String getControlName(String _fieldname)
+ {
+ String controlname = "";
+ switch (getControlType())
+ {
+ case FormHandler.SOLABEL:
+ controlname = "lbl" + _fieldname;
+ break;
+ case FormHandler.SOTEXTBOX:
+ controlname = "txt" + _fieldname;
+ break;
+ case FormHandler.SOCHECKBOX:
+ controlname = "chk" + _fieldname;
+ break;
+ case FormHandler.SODATECONTROL:
+ controlname = "dat" + _fieldname;
+ break;
+ case FormHandler.SOTIMECONTROL:
+ controlname = "tim" + _fieldname;
+ break;
+ case FormHandler.SONUMERICCONTROL:
+ controlname = "fmt" + _fieldname;
+ break;
+ case FormHandler.SOGRIDCONTROL:
+ controlname = "grd" + _fieldname;
+ break;
+ case FormHandler.SOIMAGECONTROL:
+ controlname = "img" + _fieldname;
+ break;
+ default:
+ controlname = "ctrl" + _fieldname;
+ }
+ return controlname;
+ }
+
+ private void setDefaultValue(Object DatabaseField)
+ {
+ oDefaultValue = Helper.getUnoPropertyValue(DatabaseField, "DefaultValue");
+ }
+
+ public int getPreferredWidth(String sText)
+ {
+ Size aPeerSize = getPreferredSize(sText);
+ return ((aPeerSize.Width + 10) * oFormHandler.getXPixelFactor());
+ }
+
+ public int getPreferredHeight(String sText)
+ {
+ Size aPeerSize = getPreferredSize(sText);
+ if (getControlType() == FormHandler.SOCHECKBOX)
+ {
+ return (aPeerSize.Height * oFormHandler.getXPixelFactor());
+ }
+ else
+ {
+ return ((aPeerSize.Height + 2) * oFormHandler.getXPixelFactor());
+ }
+ }
+
+ public int getPreferredWidth()
+ {
+ if (getControlType() == FormHandler.SOIMAGECONTROL)
+ {
+ return IIMGFIELDWIDTH;
+ }
+ else
+ {
+ Size aPeerSize = getPeerSize();
+ // We increase the preferred Width a bit so that the control does not become too small
+ // when we change the border from "3D" to "Flat"
+ if (getControlType() == FormHandler.SOCHECKBOX)
+ {
+ return ((aPeerSize.Width * oFormHandler.getXPixelFactor()));
+ }
+ else
+ {
+ return ((aPeerSize.Width * oFormHandler.getXPixelFactor()) + 200);
+ }
+ }
+ }
+
+ public int getPreferredHeight()
+ {
+ if (getControlType() == FormHandler.SOIMAGECONTROL)
+ {
+ return 2000;
+ }
+ else
+ {
+ Size aPeerSize = getPeerSize();
+ int nHeight = aPeerSize.Height;
+ // We increase the preferred Height a bit so that the control does not become too small
+ // when we change the border from "3D" to "Flat"
+ return ((nHeight + 1) * oFormHandler.getYPixelFactor());
+ }
+ }
+
+ public Size getPreferredSize(String sText)
+ {
+ try
+ {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName("Text"))
+ {
+ xPropertySet.setPropertyValue("Text", sText);
+ }
+ else if (xPropertySet.getPropertySetInfo().hasPropertyByName("Label"))
+ {
+ xPropertySet.setPropertyValue("Label", sText);
+ }
+ else
+ {
+ throw new IllegalArgumentException();
+ }
+ return getPeer().getPreferredSize();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void setPropertyValue(String _sPropertyName, Object _aPropertyValue) throws Exception
+ {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName(_sPropertyName))
+ {
+ xPropertySet.setPropertyValue(_sPropertyName, _aPropertyValue);
+ }
+ }
+
+ /** the peer should be retrieved every time before it is used because it
+ * might be disposed otherwise
+ *
+ * @return
+ */
+ public XLayoutConstrains getPeer()
+ {
+ return (XLayoutConstrains) UnoRuntime.queryInterface(XLayoutConstrains.class, xControl.getPeer());
+ }
+
+ public Size getPeerSize()
+ {
+ try
+ {
+ Size aPreferredSize = null;
+ double dblEffMax = 0;
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName("EffectiveMax"))
+ {
+ Object oValue = xPropertySet.getPropertyValue("EffectiveMax");
+ if (xPropertySet.getPropertyValue("EffectiveMax") != com.sun.star.uno.Any.VOID)
+ {
+ dblEffMax = AnyConverter.toDouble(xPropertySet.getPropertyValue("EffectiveMax"));
+ }
+ if (dblEffMax == 0)
+ {
+ // This is relevant for decimal fields
+ xPropertySet.setPropertyValue("EffectiveValue", new Double(99999));
+ }
+ else
+ {
+ xPropertySet.setPropertyValue("EffectiveValue", new Double(dblEffMax)); //new Double(100000.2)); //
+ }
+ aPreferredSize = getPeer().getPreferredSize();
+ xPropertySet.setPropertyValue("EffectiveValue", com.sun.star.uno.Any.VOID);
+ }
+ else if (getControlType() == FormHandler.SOCHECKBOX)
+ {
+ aPreferredSize = getPeer().getPreferredSize();
+ }
+ else if (getControlType() == FormHandler.SODATECONTROL)
+ {
+ xPropertySet.setPropertyValue("Date", new Integer(4711)); //TODO find a better date
+ aPreferredSize = getPeer().getPreferredSize();
+ xPropertySet.setPropertyValue("Date", com.sun.star.uno.Any.VOID);
+ }
+ else if (getControlType() == FormHandler.SOTIMECONTROL)
+ {
+ xPropertySet.setPropertyValue("Time", new Integer(47114)); //TODO find a better time
+ aPreferredSize = getPeer().getPreferredSize();
+ xPropertySet.setPropertyValue("Time", com.sun.star.uno.Any.VOID);
+ }
+ else
+ {
+ String stext;
+ short iTextLength = AnyConverter.toShort(xPropertySet.getPropertyValue("MaxTextLen"));
+ if (iTextLength < this.SOMAXTEXTSIZE)
+ {
+ stext = FormHandler.SOSIZETEXT.substring(0, this.SOMAXTEXTSIZE);
+ }
+ else
+ {
+ stext = FormHandler.SOSIZETEXT.substring(0, iTextLength);
+ }
+ xPropertySet.setPropertyValue("Text", stext);
+ aPreferredSize = getPeer().getPreferredSize();
+ xPropertySet.setPropertyValue("Text", "");
+ }
+ return aPreferredSize;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ /**
+ * @return
+ */
+ public int getControlType()
+ {
+ return icontroltype;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/DatabaseControl.java b/wizards/com/sun/star/wizards/document/DatabaseControl.java
new file mode 100644
index 000000000000..b0b1523840a9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/DatabaseControl.java
@@ -0,0 +1,269 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.db.FieldColumn;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class DatabaseControl extends Control
+{
+
+ private int m_nFieldType;
+ // private int iMemofieldwidth = IIMGFIELDWIDTH;
+ // private int iMemofieldheight = -1;
+ // private FieldColumn m_FieldColumn;
+
+ public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn)
+ {
+ super();
+ // m_FieldColumn = _curfieldcolumn;
+ if (_curfieldcolumn.getFieldType() != DataType.TIMESTAMP)
+ {
+ createGridColumn(_oGridControl, _curfieldcolumn, _curfieldcolumn.getFieldType(), _curfieldcolumn.getFieldTitle());
+ }
+ }
+
+ public DatabaseControl(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle)
+ {
+ super();
+ // m_FieldColumn = _curfieldcolumn;
+ createGridColumn(_oGridControl, _curfieldcolumn, _fieldtype, _columntitle);
+ }
+
+ protected int getFieldType()
+ {
+ return m_nFieldType;
+ }
+
+ private void createGridColumn(GridControl _oGridControl, FieldColumn _curfieldcolumn, int _fieldtype, String _columntitle)
+ {
+ try
+ {
+ m_nFieldType = _fieldtype;
+ String sFieldName = _curfieldcolumn.getFieldName();
+ String sUniqueName = Desktop.getUniqueName(_oGridControl.xNameAccess, sFieldName);
+
+ String sGridColumnName = getGridColumnName();
+ XPropertySet xPropColumn = _oGridControl.xGridColumnFactory.createColumn(sGridColumnName);
+ xPropColumn.setPropertyValue("Name", sUniqueName);
+ boolean bHidden = false;
+ if (_fieldtype == DataType.LONGVARBINARY) //TODO CONTROLType abfragen!!!!!!
+ {
+ bHidden = true;
+ }
+ xPropColumn.setPropertyValue("Hidden", new Boolean(bHidden));
+ xPropColumn.setPropertyValue("DataField", sFieldName);
+ xPropColumn.setPropertyValue("Label", _columntitle);
+ xPropColumn.setPropertyValue("Width", new Integer(0)); // Width of column is adjusted to Columname
+
+ XPropertySetInfo xPSI = xPropColumn.getPropertySetInfo();
+ if ( xPSI.hasPropertyByName( "MouseWheelBehavior" ) )
+ xPropColumn.setPropertyValue( "MouseWheelBehavior", new Short( com.sun.star.awt.MouseWheelBehavior.SCROLL_DISABLED ) );
+
+ setNumericLimits();
+ _oGridControl.xNameContainer.insertByName(sFieldName, xPropColumn);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public DatabaseControl(FormHandler _oFormHandler, String _sServiceName, Point _aPoint)
+ {
+ super(_oFormHandler, _sServiceName, _aPoint);
+ }
+
+ public DatabaseControl(FormHandler _oFormHandler, XNameContainer _xFormName, String _curFieldName, int _fieldtype, Point _aPoint)
+ {
+ super(_oFormHandler, _xFormName, _oFormHandler.getControlType(_fieldtype), _curFieldName, _aPoint, null);
+ try
+ {
+ m_nFieldType = _fieldtype;
+ Helper.setUnoPropertyValue(xControlModel, "DataField", _curFieldName);
+ setNumericLimits();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public DatabaseControl(FormHandler _oFormHandler, XShapes _xGroupShapes, XNameContainer _xFormName, String _curFieldName, int _fieldtype, Point _aPoint)
+ {
+ super(_oFormHandler, _xGroupShapes, _xFormName, _oFormHandler.getControlType(_fieldtype), _aPoint, null);
+ try
+ {
+ m_nFieldType = _fieldtype;
+ Helper.setUnoPropertyValue(xControlModel, "DataField", _curFieldName);
+ setNumericLimits();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private String getGridColumnName()
+ {
+ for (int i = 0; i < FormHandler.oControlData.length; i++)
+ {
+ if (FormHandler.oControlData[i].DataType == getFieldType())
+ {
+ return FormHandler.oControlData[i].GridColumnName;
+ }
+ }
+ return "";
+ }
+
+ public int getControlHeight()
+ {
+ if (getControlType() == FormHandler.SOIMAGECONTROL)
+ {
+ // return oFormHandler.getImageControlHeight();
+ final int nMemofieldheight = oFormHandler.getControlReferenceHeight() * 4;
+ return nMemofieldheight;
+ }
+ else
+ {
+ if (getFieldType() == DataType.LONGVARCHAR)
+ {
+ // Helper.setUnoPropertyValue(xControlModel, "MultiLine", Boolean.TRUE);
+ final int nMemofieldheight = oFormHandler.getControlReferenceHeight() * 4;
+ return nMemofieldheight;
+ }
+ else if (getControlType() == FormHandler.SOCHECKBOX)
+ {
+ return super.getPreferredHeight();
+ }
+ }
+ return oFormHandler.getControlReferenceHeight();
+ }
+
+ public int getControlWidth()
+ {
+ if (getControlType() == FormHandler.SOIMAGECONTROL)
+ {
+ return 2 * getControlHeight();
+ }
+ if (getFieldType() == DataType.LONGVARCHAR)
+ {
+ return 2 * getControlHeight();
+ }
+ else
+ {
+ return getPreferredWidth();
+ }
+ }
+
+ private static long m_nLongMax = 0;
+ public static long getLongMax()
+ {
+ if (m_nLongMax == 0)
+ {
+ }
+ return m_nLongMax;
+ }
+ public void setNumericLimits()
+ {
+ try
+ {
+ if (getControlType() == FormHandler.SONUMERICCONTROL)
+ {
+ xPropertySet.setPropertyValue("TreatAsNumber", Boolean.TRUE);
+ // Math.
+ // 2^63 - 1 = 9223372036854775807
+ // int nIntMax = 0x7fffffff;
+ // int nIntMin = -0x80000000;
+ // long nLongMax = nIntMax;
+ // nLongMax <<= (4*4);
+ // nLongMax |= 0xffff;
+ // nLongMax <<= (4*4);
+ // nLongMax |= 0xffff;
+
+ // long nLongMin = nIntMin;
+ // nLongMin <<= (8*4);
+
+ // long nLong2 = (long)9223372036854775807;
+
+ switch (getFieldType())
+ {
+ case DataType.BIGINT:
+ xPropertySet.setPropertyValue("EffectiveMax", new Double(Long.MAX_VALUE));
+ xPropertySet.setPropertyValue("EffectiveMin", new Double(Long.MIN_VALUE));
+ break;
+ case DataType.INTEGER:
+ xPropertySet.setPropertyValue("EffectiveMax", new Double(Integer.MAX_VALUE));
+ xPropertySet.setPropertyValue("EffectiveMin", new Double(Integer.MIN_VALUE));
+ break;
+ case DataType.SMALLINT:
+ xPropertySet.setPropertyValue("EffectiveMax", new Double(Short.MAX_VALUE));
+ xPropertySet.setPropertyValue("EffectiveMin", new Double(Short.MIN_VALUE));
+ break;
+ case DataType.TINYINT:
+ xPropertySet.setPropertyValue("EffectiveMax", new Double(127));
+ xPropertySet.setPropertyValue("EffectiveMin", new Double(-128));
+ break;
+ case DataType.FLOAT:
+ case DataType.REAL:
+ case DataType.DOUBLE:
+ case DataType.DECIMAL:
+ case DataType.NUMERIC:
+ break;
+ }
+ }
+ // else if (getControlType() == FormHandler.SOTEXTBOX)
+ // { // com.sun.star.sdbc.DataType.CHAR, com.sun.star.sdbc.DataType.VARCHAR, com.sun.star.sdbc.DataType.LONGVARCHAR
+ // }
+ else if (getControlType() == FormHandler.SOIMAGECONTROL)
+ {
+ xPropertySet.setPropertyValue("ScaleMode", com.sun.star.awt.ImageScaleMode.Isotropic);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ /**
+ * @return
+ */
+}
diff --git a/wizards/com/sun/star/wizards/document/FormHandler.java b/wizards/com/sun/star/wizards/document/FormHandler.java
new file mode 100644
index 000000000000..7b558d67cd9f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/FormHandler.java
@@ -0,0 +1,594 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XDevice;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XChild;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.view.XControlAccess;
+import com.sun.star.wizards.common.*;
+
+import com.sun.star.sdbc.DataType;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XInterface;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XDrawPage;
+import com.sun.star.drawing.XDrawPageSupplier;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapeGrouper;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.form.XFormsSupplier;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.container.XNamed;
+
+public class FormHandler
+{
+
+ public XFormsSupplier xFormsSupplier;
+ public XMultiServiceFactory xMSFDoc;
+ public XMultiServiceFactory xMSF;
+ public XDrawPage xDrawPage;
+ private XDrawPageSupplier xDrawPageSupplier;
+ public String[] sModelServices = new String[8];
+ public static ControlData[] oControlData;
+
+ public final static int SOLABEL = 0;
+ public final static int SOTEXTBOX = 1;
+ public final static int SOCHECKBOX = 2;
+ public final static int SODATECONTROL = 3;
+ public final static int SOTIMECONTROL = 4;
+ public final static int SONUMERICCONTROL = 5;
+ public final static int SOGRIDCONTROL = 6;
+ public final static int SOIMAGECONTROL = 7;
+ public final static int SODATETIMECONTROL = 8;
+ int iImageControlHeight = 2000;
+ public static String SOSIZETEXT = "The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.";
+ int iXPixelFactor = -1;
+ int iYPixelFactor = -1;
+ int iXNirwanaPos = 50000;
+ int iYNirwanaPos = 50000;
+ public int nLabelHeight = -1;
+ public int nDBRefHeight = -1;
+ public int BasicLabelDiffHeight = -1;
+ XNameAccess xNamedForms;
+ XControlAccess xControlAccess;
+ XShapeGrouper xShapeGrouper;
+ XNameContainer xNamedFormContainer;
+
+ public class ControlData
+ {
+
+ int DataType;
+ int ControlType;
+ String ControlService;
+ String GridColumnName;
+ boolean bIsText;
+ }
+
+ /** Creates a new instance of FormHandler */
+ public FormHandler(XMultiServiceFactory _xMSF, XTextDocument xTextDocument)
+ {
+ this.xMSF = _xMSF;
+ xDrawPageSupplier = (XDrawPageSupplier) UnoRuntime.queryInterface(XDrawPageSupplier.class, xTextDocument);
+ xDrawPage = xDrawPageSupplier.getDrawPage();
+ xFormsSupplier = (XFormsSupplier) UnoRuntime.queryInterface(XFormsSupplier.class, xDrawPage);
+ xShapeGrouper = (XShapeGrouper) UnoRuntime.queryInterface(XShapeGrouper.class, xDrawPage);
+ xControlAccess = (XControlAccess) UnoRuntime.queryInterface(XControlAccess.class, xTextDocument.getCurrentController());
+ xMSFDoc = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ sModelServices[SOLABEL] = "com.sun.star.form.component.FixedText";
+ sModelServices[SOTEXTBOX] = "com.sun.star.form.component.TextField";
+ sModelServices[SOCHECKBOX] = "com.sun.star.form.component.CheckBox";
+ sModelServices[SODATECONTROL] = "com.sun.star.form.component.DateField";
+ sModelServices[SOTIMECONTROL] = "com.sun.star.form.component.TimeField";
+ sModelServices[SONUMERICCONTROL] = "com.sun.star.form.component.FormattedField";
+ sModelServices[SOGRIDCONTROL] = "com.sun.star.form.component.GridControl";
+ sModelServices[SOIMAGECONTROL] = "com.sun.star.form.component.DatabaseImageControl";
+
+ oControlData = new ControlData[22];
+ oControlData[0] = createControlData(DataType.BIT, SOCHECKBOX, "CheckBox", "CheckBox", false);
+ oControlData[1] = createControlData(DataType.BOOLEAN, SOCHECKBOX, "CheckBox", "CheckBox", false);
+ oControlData[2] = createControlData(DataType.TINYINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[3] = createControlData(DataType.SMALLINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[4] = createControlData(DataType.INTEGER, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[5] = createControlData(DataType.BIGINT, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[6] = createControlData(DataType.FLOAT, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[7] = createControlData(DataType.REAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[8] = createControlData(DataType.DOUBLE, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[9] = createControlData(DataType.NUMERIC, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[10] = createControlData(DataType.DECIMAL, SONUMERICCONTROL, "FormattedField", "FormattedField", false);
+ oControlData[11] = createControlData(DataType.CHAR, SOTEXTBOX, "TextField", "TextField", false);
+ oControlData[12] = createControlData(DataType.VARCHAR, SOTEXTBOX, "TextField", "TextField", true);
+ oControlData[13] = createControlData(DataType.LONGVARCHAR, SOTEXTBOX, "TextField", "TextField", true);
+ oControlData[14] = createControlData(DataType.DATE, SODATECONTROL, "DateField", "DateField", false);
+ oControlData[15] = createControlData(DataType.TIME, SOTIMECONTROL, "TimeField", "TimeField", false);
+ oControlData[16] = createControlData(DataType.TIMESTAMP, SODATECONTROL, "DateField", "TextField", false);
+ // oImageControlData = new ControlData[4];
+ oControlData[17] = createControlData(DataType.BINARY, SOIMAGECONTROL, "ImageControl", "TextField", false);
+ oControlData[18] = createControlData(DataType.VARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false);
+ oControlData[19] = createControlData(DataType.LONGVARBINARY, SOIMAGECONTROL, "ImageControl", "TextField", false);
+ oControlData[20] = createControlData(DataType.BLOB, SOIMAGECONTROL, "ImageControl", "TextField", false);
+
+ oControlData[21] = createControlData(DataType.OTHER, SOIMAGECONTROL, "ImageControl", "TextField", false);
+ }
+
+ public int getControlType(int _fieldtype)
+ {
+ for (int i = 0; i < oControlData.length; i++)
+ {
+ if (oControlData[i].DataType == _fieldtype)
+ {
+ final int nType = oControlData[i].ControlType;
+ return nType;
+ }
+ }
+ return -1;
+ }
+
+ public void setglobalMultiServiceFactory(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public String getModelServiceName(int _fieldtype)
+ {
+ int icontroltype = getControlType(_fieldtype);
+ if (icontroltype > -1)
+ {
+ return sModelServices[icontroltype];
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public void initializeBasicControlValues()
+ {
+ Control oLabelControl = new Control(this, SOLABEL, new Point(), new Size());
+ XDevice xDevice = (XDevice) UnoRuntime.queryInterface(XDevice.class, oLabelControl.xWindowPeer);
+ iXPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterX);
+ iYPixelFactor = (int) (100000 / xDevice.getInfo().PixelPerMeterY);
+
+ nLabelHeight = (oLabelControl.getPreferredHeight("The quick brown fox...") + 1);
+ Control oTextControl = new Control(this, SOTEXTBOX, new Point(), new Size());
+ nDBRefHeight = (oTextControl.getPreferredHeight("The quick brown fox...") + 1);
+ BasicLabelDiffHeight = (nDBRefHeight - nLabelHeight) / 2;
+ xDrawPage.remove(oLabelControl.xShape);
+ xDrawPage.remove(oTextControl.xShape);
+ }
+
+ public ControlData createControlData(int _datatype, int _controltype, String _scontrolservicename, String _gridcolumnname, boolean _bIsTextControl)
+ {
+ ControlData curControlData = new ControlData();
+ curControlData.DataType = _datatype;
+ curControlData.ControlType = _controltype;
+ curControlData.ControlService = _scontrolservicename;
+ curControlData.GridColumnName = _gridcolumnname;
+ curControlData.bIsText = _bIsTextControl;
+ return curControlData;
+ }
+
+ public XNameContainer getDocumentForms()
+ {
+ XNameContainer xNamedForms = xFormsSupplier.getForms();
+ return xNamedForms;
+ }
+
+ public String getValueofHiddenControl(XNameAccess xNamedForm, String ControlName, String sMsg) throws com.sun.star.wizards.document.FormHandler.UnknownHiddenControlException
+ {
+ try
+ {
+ if (xNamedForm.hasByName(ControlName))
+ {
+ String ControlValue = AnyConverter.toString(com.sun.star.wizards.common.Helper.getUnoPropertyValue(xNamedForm.getByName(ControlName), "HiddenValue"));
+ return ControlValue;
+ }
+ else
+ {
+ throw new UnknownHiddenControlException(xNamedForm, ControlName, sMsg);
+ }
+ }
+ catch (Exception exception)
+ {
+ throw new UnknownHiddenControlException(xNamedForm, ControlName, sMsg);
+ }
+ }
+
+ public void insertHiddenControl(XNameAccess xNameAccess, XNameContainer xNamedForm, String ControlName, String ControlValue)
+ {
+ try
+ {
+ XInterface xHiddenControl;
+ if (xNameAccess.hasByName(ControlName) == true)
+ {
+ xHiddenControl = (XInterface) AnyConverter.toObject(new Type(XInterface.class), xNameAccess.getByName(ControlName));
+ }
+ else
+ {
+ xHiddenControl = (XInterface) xMSFDoc.createInstance("com.sun.star.form.component.HiddenControl");
+ xNamedForm.insertByName(ControlName, xHiddenControl);
+ }
+ Helper.setUnoPropertyValue(xHiddenControl, "HiddenValue", ControlValue);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public class UnknownHiddenControlException extends java.lang.Throwable
+ {
+
+ public UnknownHiddenControlException(XNameAccess xNamedForm, String ControlName, String sMsgHiddenControlisMissing)
+ {
+ XNamed xNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class, xNamedForm);
+ String FormName = xNamed.getName();
+ sMsgHiddenControlisMissing = JavaTools.replaceSubString(sMsgHiddenControlisMissing, FormName, "<REPORTFORM>");
+ sMsgHiddenControlisMissing = JavaTools.replaceSubString(sMsgHiddenControlisMissing, ControlName, "<CONTROLNAME>");
+ SystemDialog.showMessageBox(xMSFDoc, "ErrorBox", VclWindowPeerAttribute.OK, sMsgHiddenControlisMissing);
+ }
+ }
+
+ public boolean hasFormByName(String _FormName)
+ {
+ xNamedFormContainer = getDocumentForms();
+ xNamedForms = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xNamedFormContainer);
+ return xNamedForms.hasByName(_FormName);
+ }
+
+ public void removeFormByName(String _FormName)
+ {
+ try
+ {
+ if (hasFormByName(_FormName))
+ {
+ removeControlsofForm(_FormName);
+ xNamedFormContainer.removeByName(_FormName);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeControlsofForm(String _FormName)
+ {
+ try
+ {
+ for (int i = xDrawPage.getCount() - 1; i >= 0; i--)
+ {
+ if (belongsToForm(xDrawPage.getByIndex(i), _FormName))
+ {
+ XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xDrawPage.getByIndex(i));
+ xDrawPage.remove(xShape);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void removeElement( XNameContainer _parentContainer, String _formName )
+ {
+ try
+ {
+ _parentContainer.removeByName( _formName );
+ }
+ catch ( WrappedTargetException e )
+ {
+ e.printStackTrace( System.err );
+ }
+ catch( final NoSuchElementException e )
+ {
+ e.printStackTrace( System.err );
+ }
+ }
+
+ public boolean belongsToForm(Object _oDrawPageElement, String _FormName)
+ {
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, _oDrawPageElement);
+ if (xServiceInfo.supportsService("com.sun.star.drawing.ControlShape"))
+ {
+ XControlShape xControlShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, _oDrawPageElement);
+ XControlModel xControlModel = xControlShape.getControl();
+ xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xControlShape.getControl());
+ if (xServiceInfo.supportsService("com.sun.star.form.FormComponent"))
+ {
+ XChild xChild = (XChild) UnoRuntime.queryInterface(XChild.class, xControlModel);
+ XNamed xNamed = (XNamed) UnoRuntime.queryInterface(XNamed.class, xChild.getParent());
+ String sName = xNamed.getName();
+ return _FormName.equals(sName);
+ }
+ }
+ return false;
+ }
+
+ public XNameContainer insertFormbyName(String _FormName, XNameContainer _xNamedFormContainer)
+ {
+ try
+ {
+ Object oDBForm;
+ if (!hasFormByName(_FormName))
+ {
+ oDBForm = xMSFDoc.createInstance("com.sun.star.form.component.Form");
+ _xNamedFormContainer.insertByName(_FormName, oDBForm);
+ XNameContainer xNamedForm;
+ xNamedForm = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oDBForm);
+ return xNamedForm;
+ }
+ else
+ {
+ return getFormByName(_FormName);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public XNameContainer insertSubFormbyName(String _FormName, XNameContainer _xNamedFormContainer)
+ {
+ return insertFormbyName(_FormName, _xNamedFormContainer);
+ }
+
+ public XNameContainer insertFormbyName(String _FormName)
+ {
+ return insertFormbyName(_FormName, getDocumentForms());
+ }
+
+ public XNameContainer getFormByName(String _sname)
+ {
+ XNameContainer xNamedForm = null;
+ try
+ {
+ if (xNamedForms.hasByName(_sname))
+ {
+ Object oDBForm = AnyConverter.toObject(new Type(XInterface.class), Helper.getUnoObjectbyName(xNamedForms, _sname));
+ xNamedForm = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, oDBForm);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return xNamedForm;
+ }
+
+ /**
+ * @return
+ */
+ public int getXPixelFactor()
+ {
+ if (iXPixelFactor == -1)
+ {
+ initializeBasicControlValues();
+ }
+ return iXPixelFactor;
+ }
+
+ /**
+ * @return
+ */
+ public int getYPixelFactor()
+ {
+ if (iYPixelFactor == -1)
+ {
+ initializeBasicControlValues();
+ }
+ return iYPixelFactor;
+ }
+
+ /**
+ * @param i
+ */
+ public void setXPixelFactor(int i)
+ {
+ iXPixelFactor = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setYPixelFactor(int i)
+ {
+ iYPixelFactor = i;
+ }
+
+ /**
+ * @return
+ */
+ public int getImageControlHeight()
+ {
+ return iImageControlHeight;
+ }
+
+ /**
+ * @param i
+ */
+ public void setImageControlHeight(int i)
+ {
+ iImageControlHeight = i;
+ }
+ // Note: as Shapes cannot be removed from the DrawPage without destroying
+ // the object we have to park them somewhere beyond the visible area of the page
+ public void moveShapesToNirwana(Control[] ControlList)
+ {
+ if (ControlList != null)
+ {
+ for (int i = 0; i < ControlList.length; i++)
+ {
+ if (ControlList[i] != null)
+// try {
+// this.xDrawPage.remove(ControlList[i].xShape);
+ {
+ ControlList[i].setPosition(new Point(this.iXNirwanaPos, this.iYNirwanaPos));
+// String sControlName = (String) ControlList[i].xPropertySet.getPropertyValue("Name");
+//
+// if (_xNamedForm.hasByName(sControlName))
+// _xNamedForm.removeByName(sControlName);
+// } catch (Exception e) {
+// e.printStackTrace(System.out);
+// }
+ }
+ }
+ }
+ }
+
+ public void moveShapesToNirwana()
+ {
+ try
+ {
+ for (int i = 0; i < this.xDrawPage.getCount(); i++)
+ {
+ XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xDrawPage.getByIndex(i));
+ xShape.setPosition(new Point(this.iXNirwanaPos, this.iYNirwanaPos));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void removeAllShapes() throws Exception
+ {
+ for (int i = this.xDrawPage.getCount(); i > -1; i--)
+ {
+ XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xDrawPage.getByIndex(i));
+ removeShape(xShape);
+ }
+ }
+
+ /**
+ * By removing the shape the whole control is disposed too
+ *
+ */
+ public void removeShape(XShape _xShape)
+ {
+ xDrawPage.remove(_xShape);
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, _xShape);
+ xComponent.dispose();
+ }
+ // Destroy all Shapes in Nirwana
+ public void removeNirwanaShapes() throws Exception
+ {
+ for (int i = this.xDrawPage.getCount(); i > -1; i--)
+ {
+ XShape xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xDrawPage.getByIndex(i));
+ if (xShape.getPosition().Y < this.iYNirwanaPos)
+ {
+ xDrawPage.remove(xShape);
+ }
+ }
+ }
+
+ public XShape groupShapesTogether(XMultiServiceFactory _xMSF, XShape _xLabelShape, XShape _xControlShape)
+ {
+ try
+ {
+ Object oGroupShape = _xMSF.createInstance("com.sun.star.drawing.ShapeCollection");
+ XShapes xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, oGroupShape);
+ xShapes.add(_xLabelShape);
+ xShapes.add(_xControlShape);
+ return this.xShapeGrouper.group(xShapes);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ /**
+ * @return
+ */
+ public int getBasicLabelDiffHeight()
+ {
+ if (this.BasicLabelDiffHeight == -1)
+ {
+ initializeBasicControlValues();
+ }
+ return BasicLabelDiffHeight;
+ }
+
+ /**
+ * @return
+ */
+ public int getControlReferenceHeight()
+ {
+ if (this.nDBRefHeight == -1)
+ {
+ initializeBasicControlValues();
+ }
+ return nDBRefHeight;
+ }
+
+ /**
+ * @return
+ */
+ public int getLabelHeight()
+ {
+ if (this.nLabelHeight == -1)
+ {
+ initializeBasicControlValues();
+ }
+ return nLabelHeight;
+ }
+
+ public void setDrawObjectsCaptureMode(boolean _bCaptureObjects)
+ {
+ try
+ {
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, this.xMSFDoc.createInstance("com.sun.star.text.DocumentSettings"));
+ xPropertySet.setPropertyValue("DoNotCaptureDrawObjsOnPage", new Boolean(!_bCaptureObjects));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/GridControl.java b/wizards/com/sun/star/wizards/document/GridControl.java
new file mode 100644
index 000000000000..66bae37e1ed3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/GridControl.java
@@ -0,0 +1,93 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.FieldColumn;
+import com.sun.star.sdbc.*;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.form.XGridColumnFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+
+public class GridControl extends Shape
+{
+
+ FieldColumn[] fieldcolumns;
+ public XNameContainer xNameContainer;
+ public XGridColumnFactory xGridColumnFactory;
+ public XPropertySet xPropertySet;
+ XNameAccess xNameAccess;
+ final String SODEFAULTNAME = "Grid1";
+ XControlModel xControlModel;
+ public XComponent xComponent;
+
+ public GridControl(XMultiServiceFactory _xMSF, String _sname, FormHandler _oFormHandler, XNameContainer _xFormName, FieldColumn[] _fieldcolumns, Point _aPoint, Size _aSize)
+ {
+ super(_oFormHandler, _aPoint, _aSize);
+ try
+ {
+ fieldcolumns = _fieldcolumns;
+ Object oGridModel = oFormHandler.xMSFDoc.createInstance(oFormHandler.sModelServices[FormHandler.SOGRIDCONTROL]);
+ xNameContainer = UnoRuntime.queryInterface( XNameContainer.class, oGridModel );
+ xNameAccess = UnoRuntime.queryInterface( XNameAccess.class, oGridModel );
+ _xFormName.insertByName(_sname, oGridModel);
+ xControlModel = UnoRuntime.queryInterface( XControlModel.class, oGridModel );
+ xControlShape.setControl(xControlModel);
+ xPropertySet = UnoRuntime.queryInterface( XPropertySet.class, oGridModel );
+ oFormHandler.xDrawPage.add(xShape);
+ xGridColumnFactory = UnoRuntime.queryInterface( XGridColumnFactory.class, oGridModel );
+ xComponent = UnoRuntime.queryInterface( XComponent.class, oGridModel );
+
+// Helper.setUnoPropertyValue(oGridModel, "Name", _sname);
+ for (int i = 0; i < fieldcolumns.length; i++)
+ {
+ FieldColumn curfieldcolumn = fieldcolumns[i];
+ if (curfieldcolumn.getFieldType() == DataType.TIMESTAMP)
+ {
+ TimeStampControl oControl = new TimeStampControl(new Resource(_xMSF, "", "dbw"), this, curfieldcolumn);
+ }
+ else
+ {
+ Control oControl = new DatabaseControl(this, curfieldcolumn);
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/OfficeDocument.java b/wizards/com/sun/star/wizards/document/OfficeDocument.java
new file mode 100644
index 000000000000..ea132453bb30
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/OfficeDocument.java
@@ -0,0 +1,459 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.document.XDocumentPropertiesSupplier;
+import com.sun.star.document.XEventsSupplier;
+import com.sun.star.document.XTypeDetection;
+import com.sun.star.drawing.XDrawPagesSupplier;
+import com.sun.star.wizards.common.*;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.WindowAttribute;
+import com.sun.star.awt.WindowDescriptor;
+import com.sun.star.awt.XToolkit;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.sheet.XCellRangeData;
+import com.sun.star.sheet.XSpreadsheetDocument;
+import com.sun.star.table.XCellRange;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XFrames;
+import com.sun.star.frame.XFramesSupplier;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XStorable;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.util.XCloseable;
+import com.sun.star.util.XModifiable;
+
+public class OfficeDocument
+{
+
+ private XWindowPeer xWindowPeer;
+ private XMultiServiceFactory xMSF;
+
+ /** Creates a new instance of OfficeDocument */
+ public OfficeDocument(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public static void attachEventCall(XComponent xComponent, String EventName, String EventType, String EventURL)
+ {
+ try
+ {
+ XEventsSupplier xEventsSuppl = (XEventsSupplier) UnoRuntime.queryInterface(XEventsSupplier.class, xComponent);
+ PropertyValue[] oEventProperties = new PropertyValue[2];
+ oEventProperties[0] = new PropertyValue();
+ oEventProperties[0].Name = "EventType";
+ oEventProperties[0].Value = EventType; // "Service", "StarBasic"
+ oEventProperties[1] = new PropertyValue();
+ oEventProperties[1].Name = "Script"; //"URL";
+ oEventProperties[1].Value = EventURL;
+ xEventsSuppl.getEvents().replaceByName(EventName, oEventProperties);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public static void dispose(XMultiServiceFactory xMSF, XComponent xComponent)
+ {
+ try
+ {
+ if (xComponent != null)
+ {
+ XModifiable xModified = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, xComponent);
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+ XFrame xFrame = xModel.getCurrentController().getFrame();
+ if (xModified.isModified())
+ {
+ xModified.setModified(false);
+ }
+ Desktop.dispatchURL(xMSF, ".uno:CloseDoc", xFrame);
+ }
+ }
+ catch (PropertyVetoException exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * Create a new office document, attached to the given frame.
+ * @param desktop
+ * @param frame
+ * @param sDocumentType e.g. swriter, scalc, ( simpress, scalc : not tested)
+ * @return the document Component (implements XComponent) object ( XTextDocument, or XSpreadsheedDocument )
+ */
+ public static Object createNewDocument(XFrame frame, String sDocumentType, boolean preview, boolean readonly)
+ {
+
+ PropertyValue[] loadValues = new PropertyValue[2];
+ loadValues[0] = new PropertyValue();
+ loadValues[0].Name = "ReadOnly";
+ loadValues[0].Value = readonly ? Boolean.TRUE : Boolean.FALSE;
+ loadValues[1] = new PropertyValue();
+ loadValues[1].Name = "Preview";
+ loadValues[1].Value = preview ? Boolean.TRUE : Boolean.FALSE;
+
+ Object oDocument = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ XInterface xInterface = null;
+ String sURL = "private:factory/" + sDocumentType;
+
+ try
+ {
+ xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, frame);
+ /*if (frame.getName() == null || frame.getName().equals(""));
+ frame.setName("T" + System.currentTimeMillis());*/
+ XComponent xComponent = xComponentLoader.loadComponentFromURL(sURL, "_self", 0, loadValues);
+
+ if (sDocumentType == "swriter")
+ {
+ oDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+ }
+ else if (sDocumentType == "scalc")
+ {
+ oDocument = (XSpreadsheetDocument) UnoRuntime.queryInterface(XSpreadsheetDocument.class, xComponent);
+ //TODO:
+ // else if (sDocumentType == "simpress")
+ // else if (sDocumentType == "sdraw")
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return oDocument;
+ }
+
+ public static XFrame createNewFrame(XMultiServiceFactory xMSF, XTerminateListener listener)
+ {
+ return createNewFrame(xMSF, listener, "_blank");
+ }
+
+ public static XFrame createNewFrame(XMultiServiceFactory xMSF, XTerminateListener listener, String FrameName)
+ {
+ XFrame xFrame = null;
+ if (FrameName.equalsIgnoreCase("WIZARD_LIVE_PREVIEW"))
+ {
+ xFrame = createNewPreviewFrame(xMSF, listener);
+ }
+ else
+ {
+ XFrame xF = (XFrame) UnoRuntime.queryInterface(XFrame.class, Desktop.getDesktop(xMSF));
+ xFrame = xF.findFrame(FrameName, 0);
+ if (listener != null)
+ {
+ XFramesSupplier xFS = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, xF);
+ XFrames xFF = xFS.getFrames();
+ xFF.remove(xFrame);
+ XDesktop xDesktop = (XDesktop) UnoRuntime.queryInterface(XDesktop.class, xF);
+ xDesktop.addTerminateListener(listener);
+ }
+ }
+ return xFrame;
+ }
+
+ public static XFrame createNewPreviewFrame(XMultiServiceFactory xMSF, XTerminateListener listener)
+ {
+ XToolkit xToolkit = null;
+ try
+ {
+ xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, xMSF.createInstance("com.sun.star.awt.Toolkit"));
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ //describe the window and its properties
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = com.sun.star.awt.WindowClass.TOP;
+ aDescriptor.WindowServiceName = "window";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = null;
+ aDescriptor.Bounds = new Rectangle(10, 10, 640, 480);
+ aDescriptor.WindowAttributes = WindowAttribute.BORDER |
+ WindowAttribute.MOVEABLE |
+ WindowAttribute.SIZEABLE |
+ //WindowAttribute.CLOSEABLE |
+ VclWindowPeerAttribute.CLIPCHILDREN;
+
+ //create a new blank container window
+ XWindowPeer xPeer = null;
+ try
+ {
+ xPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xToolkit.createWindow(aDescriptor));
+ }
+ catch (IllegalArgumentException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xPeer);
+
+ //define some further properties of the frame window
+ //if it's needed .-)
+ //xPeer->setBackground(...);
+
+ //create new empty frame and set window on it
+ XFrame xFrame = null;
+ try
+ {
+ xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, xMSF.createInstance("com.sun.star.frame.Frame"));
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ xFrame.initialize(xWindow);
+
+ //from now this frame is useable ...
+ //and not part of the desktop tree.
+ //You are alone with him .-)
+
+ if (listener != null)
+ {
+ Desktop.getDesktop(xMSF).addTerminateListener(listener);
+ }
+
+ return xFrame;
+
+ }
+
+ public static Object load(XInterface xInterface, String sURL, String sFrame, PropertyValue[] xValues)
+ {
+ // XComponent xComponent = null;
+ Object oDocument = null;
+ com.sun.star.frame.XComponentLoader xComponentLoader = null;
+ //XInterface xInterface = null;
+ try
+ {
+ xComponentLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, xInterface);
+ com.sun.star.lang.XComponent xComponent = xComponentLoader.loadComponentFromURL(sURL, sFrame, 0, xValues);
+
+ XServiceInfo xComponentService = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xComponent);
+ if (xComponentService.supportsService("com.sun.star.text.TextDocument"))
+ {
+ oDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent); //TODO: write if clauses for Calc, Impress and Draw
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return oDocument;
+ }
+
+ public static boolean store(XMultiServiceFactory xMSF, XComponent xComponent, String StorePath, String FilterName, boolean bStoreToUrl)
+ {
+ try
+ {
+ XStorable xStoreable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xComponent);
+ PropertyValue[] oStoreProperties;
+ if (FilterName.length() > 0)
+ {
+ oStoreProperties = new PropertyValue[2];
+ oStoreProperties[0] = new PropertyValue();
+ oStoreProperties[0].Name = "FilterName";
+ oStoreProperties[0].Value = FilterName;
+ oStoreProperties[1] = new PropertyValue();
+ oStoreProperties[1].Name = "InteractionHandler";
+ oStoreProperties[1].Value = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler"));
+ }
+ else
+ {
+ oStoreProperties = new PropertyValue[0];
+ }
+ if (bStoreToUrl == true)
+ {
+ xStoreable.storeToURL(StorePath, oStoreProperties);
+ }
+ else
+ {
+ xStoreable.storeAsURL(StorePath, oStoreProperties);
+ }
+ return true;
+ }
+ catch (Exception exception)
+ {
+
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public static boolean close(XComponent xComponent)
+ {
+ boolean bState = false;
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, xComponent);
+
+ if (xModel != null)
+ {
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, xModel);
+
+ if (xCloseable != null)
+ {
+ try
+ {
+ xCloseable.close(true);
+ bState = true;
+ }
+ catch (com.sun.star.util.CloseVetoException exCloseVeto)
+ {
+ System.out.println("could not close doc");
+ bState = false;
+ }
+ }
+ else
+ {
+ XComponent xDisposeable = (XComponent) UnoRuntime.queryInterface(XComponent.class, xModel);
+ xDisposeable.dispose();
+ bState = true;
+ }
+ }
+ return bState;
+ }
+
+ public static void ArraytoCellRange(Object[][] datalist, Object oTable, int xpos, int ypos)
+ {
+ try
+ {
+ int rowcount = datalist.length;
+ if (rowcount > 0)
+ {
+ int colcount = datalist[0].length;
+ if (colcount > 0)
+ {
+ XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, oTable);
+ XCellRange xNewRange = xCellRange.getCellRangeByPosition(xpos, ypos, (colcount + xpos) - 1, (rowcount + ypos) - 1);
+ XCellRangeData xDataArray = (XCellRangeData) UnoRuntime.queryInterface(XCellRangeData.class, xNewRange);
+ xDataArray.setDataArray(datalist);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public static PropertyValue[] getFileMediaDecriptor(XMultiServiceFactory xmsf, String url)
+ throws Exception
+ {
+ Object typeDetect = xmsf.createInstance("com.sun.star.document.TypeDetection");
+
+ PropertyValue[][] mediaDescr = new PropertyValue[1][1];
+ mediaDescr[0][0] = new PropertyValue();
+ mediaDescr[0][0].Name = "URL";
+ mediaDescr[0][0].Value = url;
+
+ String type = ((XTypeDetection) UnoRuntime.queryInterface(XTypeDetection.class, typeDetect)).queryTypeByDescriptor(mediaDescr, true);
+
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, typeDetect);
+ if (type.equals(""))
+ {
+ return null;
+ }
+ else
+ {
+ return (PropertyValue[]) xNameAccess.getByName(type);
+ }
+ }
+
+ public static PropertyValue[] getTypeMediaDescriptor(XMultiServiceFactory xmsf, String type)
+ throws Exception
+ {
+ Object typeDetect = xmsf.createInstance("com.sun.star.document.TypeDetection");
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, typeDetect);
+ return (PropertyValue[]) xNameAccess.getByName(type);
+ }
+
+ /**
+ * returns the count of slides in a presentation,
+ * or the count of pages in a draw document.
+ * @param model a presentation or a draw document
+ * @return the number of slides/pages in the given document.
+ */
+ public static int getSlideCount(Object model)
+ {
+ XDrawPagesSupplier xDrawPagesSupplier = (XDrawPagesSupplier) UnoRuntime.queryInterface(XDrawPagesSupplier.class, model);
+ return xDrawPagesSupplier.getDrawPages().getCount();
+ }
+
+ public static XDocumentProperties getDocumentProperties(Object document)
+ {
+ XDocumentPropertiesSupplier xDocumentPropertiesSupplier = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, document);
+ return xDocumentPropertiesSupplier.getDocumentProperties();
+ }
+
+ public static int showMessageBox(XMultiServiceFactory xMSF, String windowServiceName, int windowAttribute, String MessageText)
+ {
+// if (getWindowPeer() != null)
+ // return SystemDialog.showMessageBox(xMSF, xWindowPeer, windowServiceName, windowAttribute, MessageText);
+// else
+ return SystemDialog.showMessageBox(xMSF, windowServiceName, windowAttribute, MessageText);
+ }
+
+ /**
+ * @return Returns the xWindowPeer.
+ */
+ public XWindowPeer getWindowPeer()
+ {
+ return xWindowPeer;
+ }
+
+ /**
+ * @param windowPeer The xWindowPeer to set.
+ * Should be called as soon as a Windowpeer of a wizard dialog is available
+ * The windowpeer is needed to call a Messagebox
+ */
+ public void setWindowPeer(XWindowPeer windowPeer)
+ {
+ xWindowPeer = windowPeer;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/Shape.java b/wizards/com/sun/star/wizards/document/Shape.java
new file mode 100644
index 000000000000..b2ef1a27e662
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/Shape.java
@@ -0,0 +1,142 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.text.TextContentAnchorType;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class Shape
+{
+
+ public XShape xShape;
+ protected FormHandler oFormHandler;
+ public XServiceInfo xServiceInfo;
+ protected Point aPoint;
+ protected Size aSize;
+ protected XControlShape xControlShape;
+ public XMultiServiceFactory xMSF;
+ public XShapes xShapes;
+
+ public Shape(FormHandler _oFormHandler, Point _aPoint, Size _aSize)
+ {
+ this.aPoint = _aPoint;
+ this.aSize = _aSize;
+ this.oFormHandler = _oFormHandler;
+ createShape("com.sun.star.drawing.ControlShape");
+ }
+
+ public Shape(FormHandler _oFormHandler, String _sServiceName, Point _aPoint, Size _aSize)
+ {
+ try
+ {
+ this.aPoint = _aPoint;
+ this.aSize = _aSize;
+ this.oFormHandler = _oFormHandler;
+ Object oShape = oFormHandler.xMSF.createInstance(_sServiceName);
+ xShapes = (XShapes) UnoRuntime.queryInterface(XShapes.class, oShape);
+ xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oShape);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public Shape()
+ {
+ }
+
+ private void createShape(String sServiceName)
+ {
+ try
+ {
+ xMSF = oFormHandler.xMSFDoc;
+ Object oShape = xMSF.createInstance(sServiceName);
+ xShape = (XShape) UnoRuntime.queryInterface(XShape.class, oShape);
+ xShape.setPosition(aPoint);
+ if (aSize != null)
+ {
+ xShape.setSize(aSize);
+ }
+ else
+ {
+ xShape.setSize(new Size(1000, 100));
+ }
+ Helper.setUnoPropertyValue(xShape, "AnchorType", TextContentAnchorType.AT_PARAGRAPH);
+ xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, xShape);
+ xControlShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, xShape);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public Size getSize()
+ {
+ return xShape.getSize();
+ }
+
+ public void setSize(Size _aSize)
+ {
+ try
+ {
+ xShape.setSize(_aSize);
+ }
+ catch (PropertyVetoException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public Point getPosition()
+ {
+ return xShape.getPosition();
+ }
+
+ public void setPosition(Point _aPoint)
+ {
+ xShape.setPosition(_aPoint);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/document/TimeStampControl.java b/wizards/com/sun/star/wizards/document/TimeStampControl.java
new file mode 100644
index 000000000000..88733ee883c1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/document/TimeStampControl.java
@@ -0,0 +1,172 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.document;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.FieldColumn;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.sdbc.*;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.drawing.XControlShape;
+import com.sun.star.drawing.XShape;
+import com.sun.star.drawing.XShapes;
+
+public class TimeStampControl extends DatabaseControl
+{
+
+ DatabaseControl oDateControl;
+ DatabaseControl oTimeControl;
+// XShape xGroupShape;
+ Resource oResource;
+ private String sDateAppendix; // = GetResText(RID_FORM + 4)
+ private String sTimeAppendix; // = GetResText(RID_FORM + 5)
+ XShapes xGroupShapes = null;
+ double nreldatewidth;
+ double nreltimewidth;
+ int nTimeWidth;
+ int nDBWidth;
+ int nDateWidth;
+ XShape xShapeGroup;
+
+ public TimeStampControl(Resource _oResource, FormHandler _oFormHandler, XNameContainer _xFormName, String _curFieldName, Point _aPoint)
+ {
+ super(_oFormHandler, "com.sun.star.drawing.ShapeCollection", _aPoint);
+ oResource = _oResource;
+// xGroupShape = xShape;
+ oDateControl = new DatabaseControl(oFormHandler, _xFormName, _curFieldName, DataType.DATE, aPoint);
+ int nDBHeight = oDateControl.getControlHeight();
+ nDateWidth = oDateControl.getPreferredWidth();
+ oDateControl.setSize(new Size(nDateWidth, nDBHeight));
+ Point aTimePoint = new Point(aPoint.X + 10 + nDateWidth, aPoint.Y);
+ oTimeControl = new DatabaseControl(oFormHandler, _xFormName, _curFieldName, DataType.TIME, aTimePoint);
+ nTimeWidth = oTimeControl.getPreferredWidth();
+ oTimeControl.setSize(new Size(nTimeWidth, nDBHeight));
+ nDBWidth = nDateWidth + nTimeWidth + 10;
+ xShapes.add(oDateControl.xShape);
+ xShapes.add(oTimeControl.xShape);
+ xShapeGroup = _oFormHandler.xShapeGrouper.group(xShapes);
+ xShapeGroup = (XShape) UnoRuntime.queryInterface(XShape.class, xShapeGroup);
+ nreldatewidth = 1.0 / ((double) getSize().Width / (double) nDateWidth);
+ nreltimewidth = 1.0 - nreldatewidth;
+ }
+
+ public XPropertySet getControlofGroupShapeByIndex(int _i)
+ {
+ try
+ {
+ if (_i < xShapes.getCount())
+ {
+ Object oControl = xShapes.getByIndex(_i);
+ XControlShape xControlShape = (XControlShape) UnoRuntime.queryInterface(XControlShape.class, oControl);
+ XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlShape.getControl());
+ return xPropertySet;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public TimeStampControl(Resource _oResource, GridControl _oGridControl, FieldColumn _curfieldcolumn)
+ {
+ super(_oGridControl, _curfieldcolumn);
+ oResource = _oResource;
+ sDateAppendix = oResource.getResText(UIConsts.RID_FORM + 88);
+ sTimeAppendix = oResource.getResText(UIConsts.RID_FORM + 89);
+ oDateControl = new DatabaseControl(_oGridControl, _curfieldcolumn, DataType.DATE, _curfieldcolumn.getFieldTitle() + " " + sDateAppendix);
+ oTimeControl = new DatabaseControl(_oGridControl, _curfieldcolumn, DataType.TIME, _curfieldcolumn.getFieldTitle() + " " + sTimeAppendix);
+ }
+
+ public void setPropertyValue(String _sPropertyName, Object _aPropertyValue) throws Exception
+ {
+ oDateControl.setPropertyValue(_sPropertyName, _aPropertyValue);
+ oTimeControl.setPropertyValue(_sPropertyName, _aPropertyValue);
+ }
+
+ public int getPreferredWidth()
+ {
+ return nDBWidth;
+ }
+
+ public void setSize(Size _aSize)
+ {
+ try
+ {
+ int ndatewidth = (int) (nreldatewidth * (double) _aSize.Width);
+ int ntimewidth = (int) (nreltimewidth * (double) _aSize.Width);
+ oDateControl.xShape.setSize(new Size(ndatewidth, _aSize.Height));
+ oTimeControl.xShape.setSize(new Size(ntimewidth, _aSize.Height));
+ }
+ catch (PropertyVetoException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public Size getSize()
+ {
+ int ncontrolwidth = oDateControl.xShape.getSize().Width + oTimeControl.xShape.getSize().Width;
+ return new Size(ncontrolwidth, oDateControl.xShape.getSize().Height);
+ }
+
+ public Point getPosition()
+ {
+ return xShapeGroup.getPosition();
+ }
+
+ public void setPosition(Point _aPoint)
+ {
+ // --> TESTING
+ Point aBeforePt = xShapeGroup.getPosition();
+ // <--
+ xShapeGroup.setPosition(_aPoint);
+// oDateControl.xShape.setPosition(_aPoint);
+// Point atimepoint = new Point(oDateControl.xShape.getPosition().X + oDateControl.xShape.getSize().Width, oDateControl.xShape.getPosition().Y );
+// oTimeControl.xShape.setPosition(atimepoint);
+ // --> TESTING
+ Point aAfterPt = xShapeGroup.getPosition();
+ // <--
+ }
+
+ public int getControlType()
+ {
+ return FormHandler.SODATETIMECONTROL;
+ }
+}
+
+
+
+
+
diff --git a/wizards/com/sun/star/wizards/fax/CGFax.java b/wizards/com/sun/star/wizards/fax/CGFax.java
new file mode 100644
index 000000000000..067c4dce09f1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/CGFax.java
@@ -0,0 +1,60 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGFax extends ConfigGroup
+{
+
+ public int cp_Style;
+ public boolean cp_PrintCompanyLogo;
+ public boolean cp_PrintDate;
+ public boolean cp_PrintSubjectLine;
+ public boolean cp_PrintSalutation;
+ public boolean cp_PrintCommunicationType;
+ public boolean cp_PrintGreeting;
+ public boolean cp_PrintFooter;
+ public String cp_CommunicationType;
+ public String cp_Salutation;
+ public String cp_Greeting;
+ public int cp_SenderAddressType;
+ public String cp_SenderCompanyName;
+ public String cp_SenderStreet;
+ public String cp_SenderPostCode;
+ public String cp_SenderState;
+ public String cp_SenderCity;
+ public String cp_SenderFax;
+ public int cp_ReceiverAddressType;
+ public String cp_Footer;
+ public boolean cp_FooterOnlySecondPage;
+ public boolean cp_FooterPageNumbers;
+ public int cp_CreationType;
+ public String cp_TemplateName;
+ public String cp_TemplatePath;
+}
diff --git a/wizards/com/sun/star/wizards/fax/CGFaxWizard.java b/wizards/com/sun/star/wizards/fax/CGFaxWizard.java
new file mode 100644
index 000000000000..232d4ee8c163
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/CGFaxWizard.java
@@ -0,0 +1,38 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGFaxWizard extends ConfigGroup
+{
+
+ public int cp_FaxType;
+ public CGFax cp_BusinessFax = new CGFax();
+ public CGFax cp_PrivateFax = new CGFax();
+}
diff --git a/wizards/com/sun/star/wizards/fax/CallWizard.java b/wizards/com/sun/star/wizards/fax/CallWizard.java
new file mode 100644
index 000000000000..69e061f95918
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/CallWizard.java
@@ -0,0 +1,240 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.task.XJob;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.Type;
+
+/**
+ * This class capsulates the class, that implements the minimal component, a factory for
+ * creating the service (<CODE>__getServiceFactory</CODE>).
+ *
+ * @author $author$
+ * @version $Revision: 1.3.192.1 $
+ */
+public class CallWizard
+{
+
+ /**
+ * Gives a factory for creating the service. This method is called by the
+ * <code>JavaLoader</code>
+ *
+ * <p></p>
+ *
+ * @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 tree
+ * structures) of a single registry key accessible.
+ *
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the component.
+ *
+ * @see com.sun.star.comp.loader.JavaLoader#
+ */
+ public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey)
+ {
+ XSingleServiceFactory xsingleservicefactory = null;
+
+ if (stringImplementationName.equals(WizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__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 WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor
+ {
+
+ /**
+ * The constructor of the inner class has a XMultiServiceFactory parameter.
+ *
+ * @param xmultiservicefactoryInitialization A special service factory could be
+ * introduced while initializing.
+ */
+ public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization)
+ {
+ xmultiservicefactory = xmultiservicefactoryInitialization;
+
+ if (xmultiservicefactory != null)
+ {
+ }
+ }
+
+ /**
+ * Execute Wizard
+ *
+ * @param str only valid parameter is 'start' at the moment.
+ */
+ public void trigger(String str)
+ {
+ if (str.equalsIgnoreCase("start"))
+ {
+ FaxWizardDialogImpl lw = new FaxWizardDialogImpl(xmultiservicefactory);
+ if (!FaxWizardDialogImpl.running)
+ {
+ lw.startWizard(xmultiservicefactory, null);
+ }
+ }
+ } //*******************************************
+ /**
+ * The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "com.sun.star.wizards.fax.CallWizard";
+ /**
+ * The service manager, that gives access to all registered services.
+ */
+ private 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 method returns an array of all supported service names.
+ *
+ * @return Array of supported service names.
+ */
+ public java.lang.String[] getSupportedServiceNames()
+ {
+ String[] stringSupportedServiceNames = new String[1];
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /**
+ * This method returns an array of bytes, that can be used to unambiguously
+ * distinguish between two sets of types, e.g. to realise hashing functionality
+ * when the object is introspected. Two objects that return the same ID also
+ * have to return the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to return an empty
+ * sequence. Important: If the object aggregates other objects the ID has to be
+ * unique for the whole combination of objects.
+ *
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = ("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /**
+ * Return the class name of the component.
+ *
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (WizardImplementation.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.
+ */
+ public com.sun.star.uno.Type[] getTypes()
+ {
+ Type[] typeReturn =
+ {
+ };
+
+ try
+ {
+ typeReturn = new Type[]
+ {
+ new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class)
+ };
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/fax/FaxDocument.java b/wizards/com/sun/star/wizards/fax/FaxDocument.java
new file mode 100644
index 000000000000..8eafbed257d1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/FaxDocument.java
@@ -0,0 +1,212 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.text.*;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.text.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.style.NumberingType;
+import com.sun.star.style.ParagraphAdjust;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.style.XStyle;
+
+public class FaxDocument extends TextDocument
+{
+
+ XDesktop xDesktop;
+ boolean keepLogoFrame = true;
+ boolean keepTypeFrame = true;
+
+ public FaxDocument(XMultiServiceFactory xMSF, XTerminateListener listener)
+ {
+ super(xMSF, listener, "WIZARD_LIVE_PREVIEW");
+ }
+
+ public XWindowPeer getWindowPeer()
+ {
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xTextDocument);
+ return xWindowPeer;
+ }
+
+ public void switchElement(String sElement, boolean bState)
+ {
+ try
+ {
+ TextSectionHandler mySectionHandler = new TextSectionHandler(xMSF, xTextDocument);
+ Object oSection = mySectionHandler.xTextSectionsSupplier.getTextSections().getByName(sElement);
+ Helper.setUnoPropertyValue(oSection, "IsVisible", new Boolean(bState));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void updateDateFields()
+ {
+ TextFieldHandler FH = new TextFieldHandler(xMSFDoc, xTextDocument);
+ FH.updateDateFields();
+ }
+
+ public void switchFooter(String sPageStyle, boolean bState, boolean bPageNumber, String sText)
+ {
+ if (xTextDocument != null)
+ {
+ xTextDocument.lockControllers();
+ try
+ {
+ XStyleFamiliesSupplier xStyleFamiliesSupplier = (XStyleFamiliesSupplier) com.sun.star.uno.UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument);
+ com.sun.star.container.XNameAccess xNameAccess = null;
+ xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
+
+ com.sun.star.container.XNameContainer xPageStyleCollection = null;
+ xPageStyleCollection = (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xNameAccess.getByName("PageStyles"));
+
+ XText xFooterText;
+ XStyle xPageStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, xPageStyleCollection.getByName(sPageStyle));
+
+ if (bState)
+ {
+ Helper.setUnoPropertyValue(xPageStyle, "FooterIsOn", new Boolean(true));
+ xFooterText = (XText) UnoRuntime.queryInterface(XText.class, Helper.getUnoPropertyValue(xPageStyle, "FooterText"));
+ xFooterText.setString(sText);
+ if (bPageNumber)
+ {
+ //Adding the Page Number
+ XTextCursor myCursor = xFooterText.createTextCursor();
+ myCursor.gotoEnd(false);
+ xFooterText.insertControlCharacter(myCursor, ControlCharacter.PARAGRAPH_BREAK, false);
+ XPropertySet xCursorPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, myCursor);
+ xCursorPSet.setPropertyValue("ParaAdjust", ParagraphAdjust.CENTER);
+ XTextField xPageNumberField = (XTextField) UnoRuntime.queryInterface(XTextField.class, xMSFDoc.createInstance("com.sun.star.text.TextField.PageNumber"));
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageNumberField);
+ xPSet.setPropertyValue("SubType", PageNumberType.CURRENT);
+ xPSet.setPropertyValue("NumberingType", new Short(NumberingType.ARABIC));
+ xFooterText.insertTextContent(xFooterText.getEnd(), xPageNumberField, false);
+ }
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(xPageStyle, "FooterIsOn", new Boolean(false));
+ }
+ xTextDocument.unlockControllers();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public boolean hasElement(String sElement)
+ {
+ if (xTextDocument != null)
+ {
+ TextSectionHandler mySectionHandler = new TextSectionHandler(xMSF, xTextDocument);
+ return mySectionHandler.hasTextSectionByName(sElement);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public void switchUserField(String sFieldName, String sNewContent, boolean bState)
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument);
+ if (bState)
+ {
+ myFieldHandler.changeUserFieldContent(sFieldName, sNewContent);
+ }
+ else
+ {
+ myFieldHandler.changeUserFieldContent(sFieldName, "");
+ }
+ }
+
+ public void fillSenderWithUserData()
+ {
+ try
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSFDoc, xTextDocument);
+ Object oUserDataAccess = Configuration.getConfigurationRoot(xMSF, "org.openoffice.UserProfile/Data", false);
+ myFieldHandler.changeUserFieldContent("Company", (String) Helper.getUnoObjectbyName(oUserDataAccess, "o"));
+ myFieldHandler.changeUserFieldContent("Street", (String) Helper.getUnoObjectbyName(oUserDataAccess, "street"));
+ myFieldHandler.changeUserFieldContent("PostCode", (String) Helper.getUnoObjectbyName(oUserDataAccess, "postalcode"));
+ myFieldHandler.changeUserFieldContent("State", (String) Helper.getUnoObjectbyName(oUserDataAccess, "st"));
+ myFieldHandler.changeUserFieldContent("City", (String) Helper.getUnoObjectbyName(oUserDataAccess, "l"));
+ myFieldHandler.changeUserFieldContent("Fax", (String) Helper.getUnoObjectbyName(oUserDataAccess, "facsimiletelephonenumber"));
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void killEmptyUserFields()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument);
+ myFieldHandler.removeUserFieldByContent("");
+ }
+
+ public void killEmptyFrames()
+ {
+ try
+ {
+ if (!keepLogoFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Company Logo", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ if (!keepTypeFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Communication Type", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialog.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.java
new file mode 100644
index 000000000000..8c81ba5e5fec
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialog.java
@@ -0,0 +1,628 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.ui.*;
+
+public abstract class FaxWizardDialog extends WizardDialog implements FaxWizardDialogConst, UIConsts
+{
+
+ XRadioButton optBusinessFax;
+ XListBox lstBusinessStyle;
+ XRadioButton optPrivateFax;
+ XListBox lstPrivateStyle;
+ XFixedText lblBusinessStyle;
+ XFixedText lblTitle1;
+ XFixedText lblPrivateStyle;
+ XFixedText lblIntroduction;
+ //Image Control
+ XControl ImageControl3;
+ XCheckBox chkUseLogo;
+ XCheckBox chkUseDate;
+ XCheckBox chkUseCommunicationType;
+ XComboBox lstCommunicationType;
+ XCheckBox chkUseSubject;
+ XCheckBox chkUseSalutation;
+ XComboBox lstSalutation;
+ XCheckBox chkUseGreeting;
+ XComboBox lstGreeting;
+ XCheckBox chkUseFooter;
+ XFixedText lblTitle3;
+ XRadioButton optSenderPlaceholder;
+ XRadioButton optSenderDefine;
+ XTextComponent txtSenderName;
+ XTextComponent txtSenderStreet;
+ XTextComponent txtSenderPostCode;
+ XTextComponent txtSenderState;
+ XTextComponent txtSenderCity;
+ XTextComponent txtSenderFax;
+ XRadioButton optReceiverDatabase;
+ XRadioButton optReceiverPlaceholder;
+ XFixedText lblSenderAddress;
+ //Fixed Line
+ XControl FixedLine2;
+ XFixedText lblSenderName;
+ XFixedText lblSenderStreet;
+ XFixedText lblPostCodeCity;
+ XFixedText lblTitle4;
+ XFixedText Label1;
+ XFixedText Label2;
+ XTextComponent txtFooter;
+ XCheckBox chkFooterNextPages;
+ XCheckBox chkFooterPageNumbers;
+ XFixedText lblFooter;
+ XFixedText lblTitle5;
+ XTextComponent txtTemplateName;
+ //File Control
+ XControl fileTemplatePath;
+ XRadioButton optCreateFax;
+ XRadioButton optMakeChanges;
+ XFixedText lblFinalExplanation1;
+ XFixedText lblProceed;
+ XFixedText lblFinalExplanation2;
+ //Image Control
+ XControl ImageControl2;
+ XFixedText lblTemplateName;
+ XFixedText lblTemplatePath;
+ XFixedText lblTitle6;
+ XFixedText Label9;
+ //Font Descriptors as Class members.
+ FontDescriptor fontDescriptor1 = new FontDescriptor();
+ FontDescriptor fontDescriptor2 = new FontDescriptor();
+ FontDescriptor fontDescriptor4 = new FontDescriptor();
+ FontDescriptor fontDescriptor5 = new FontDescriptor(); //Resources Object
+ FaxWizardDialogResources resources;
+
+ public FaxWizardDialog(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, HIDMAIN);
+ //Load Resources
+ resources = new FaxWizardDialogResources(xmsf);
+
+
+ //set dialog properties...
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "Moveable", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(210), Boolean.TRUE, new Integer(104), new Integer(52), INTEGERS[1], new Short((short) 1), resources.resFaxWizardDialog_title, new Integer(310)
+ });
+
+
+
+ //Set member- FontDescriptors...
+ fontDescriptor1.Weight = 150;
+ fontDescriptor1.Underline = com.sun.star.awt.FontUnderline.SINGLE;
+ fontDescriptor2.Weight = 100;
+ fontDescriptor4.Weight = 100;
+ fontDescriptor5.Weight = 150;
+ }
+ //build components
+ public void buildStep1()
+ {
+ optBusinessFax = insertRadioButton("optBusinessFax", OPTBUSINESSFAX_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTBUSINESSFAX_HID, resources.resoptBusinessFax_value, new Integer(97), new Integer(28), INTEGERS[1], new Short((short) 1), new Integer(184)
+ });
+ lstBusinessStyle = insertListBox("lstBusinessStyle", LSTBUSINESSSTYLE_ACTION_PERFORMED, LSTBUSINESSSTYLE_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, LSTBUSINESSSTYLE_HID, new Integer(180), INTEGER_40, INTEGERS[1], new Short((short) 3), new Integer(74)
+ });
+ optPrivateFax = insertRadioButton("optPrivateFax", OPTPRIVATEFAX_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTPRIVATEFAX_HID, resources.resoptPrivateFax_value, new Integer(97), new Integer(81), INTEGERS[1], new Short((short) 2), new Integer(184)
+ });
+ lstPrivateStyle = insertListBox("lstPrivateStyle", LSTPRIVATESTYLE_ACTION_PERFORMED, LSTPRIVATESTYLE_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, LSTPRIVATESTYLE_HID, new Integer(180), new Integer(95), INTEGERS[1], new Short((short) 4), new Integer(74)
+ });
+ lblBusinessStyle = insertLabel("lblBusinessStyle",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblBusinessStyle_value, new Integer(110), new Integer(42), INTEGERS[1], new Short((short) 32), new Integer(60)
+ });
+ lblTitle1 = insertLabel("lblTitle1",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGER_16, resources.reslblTitle1_value, Boolean.TRUE, new Integer(91), INTEGERS[8], INTEGERS[1], new Short((short) 37), new Integer(212)
+ });
+ lblPrivateStyle = insertLabel("lblPrivateStyle",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPrivateStyle_value, new Integer(110), new Integer(95), INTEGERS[1], new Short((short) 50), new Integer(60)
+ });
+ lblIntroduction = insertLabel("lblIntroduction",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(39), resources.reslblIntroduction_value, Boolean.TRUE, new Integer(104), new Integer(145), INTEGERS[1], new Short((short) 55), new Integer(199)
+ });
+ ImageControl3 = insertInfoImage(92, 145, 1);
+// ImageControl3 = insertImage("ImageControl3",
+// new String[] {"Border", "Height", "ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"},
+// new Object[] { new Short((short)0),INTEGERS[10],"private:resource/dbu/image/19205",new Integer(92),new Integer(145),Boolean.FALSE,INTEGERS[1],new Short((short)56),INTEGERS[10]}
+// );
+ }
+
+ public void buildStep2()
+ {
+ chkUseLogo = insertCheckBox("chkUseLogo", CHKUSELOGO_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSELOGO_HID, resources.reschkUseLogo_value, new Integer(97), new Integer(28), new Short((short) 0), INTEGERS[2], new Short((short) 5), new Integer(212)
+ });
+ chkUseDate = insertCheckBox("chkUseDate", CHKUSEDATE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSEDATE_HID, resources.reschkUseDate_value, new Integer(97), new Integer(43), new Short((short) 0), INTEGERS[2], new Short((short) 6), new Integer(212)
+ });
+ chkUseCommunicationType = insertCheckBox("chkUseCommunicationType", CHKUSECOMMUNICATIONTYPE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSECOMMUNICATIONTYPE_HID, resources.reschkUseCommunicationType_value, new Integer(97), new Integer(57), new Short((short) 0), INTEGERS[2], new Short((short) 7), new Integer(100)
+ });
+ lstCommunicationType = insertComboBox("lstCommunicationType", LSTCOMMUNICATIONTYPE_ACTION_PERFORMED, LSTCOMMUNICATIONTYPE_ITEM_CHANGED, LSTCOMMUNICATIONTYPE_TEXT_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, LSTCOMMUNICATIONTYPE_HID, new Integer(105), new Integer(68), INTEGERS[2], new Short((short) 8), new Integer(174)
+ });
+ chkUseSubject = insertCheckBox("chkUseSubject", CHKUSESUBJECT_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSESUBJECT_HID, resources.reschkUseSubject_value, new Integer(97), new Integer(87), new Short((short) 0), INTEGERS[2], new Short((short) 9), new Integer(212)
+ });
+ chkUseSalutation = insertCheckBox("chkUseSalutation", CHKUSESALUTATION_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSESALUTATION_HID, resources.reschkUseSalutation_value, new Integer(97), new Integer(102), new Short((short) 0), INTEGERS[2], new Short((short) 10), new Integer(100)
+ });
+ lstSalutation = insertComboBox("lstSalutation", LSTSALUTATION_ACTION_PERFORMED, LSTSALUTATION_ITEM_CHANGED, LSTSALUTATION_TEXT_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, LSTSALUTATION_HID, new Integer(105), new Integer(113), INTEGERS[2], new Short((short) 11), new Integer(174)
+ });
+ chkUseGreeting = insertCheckBox("chkUseGreeting", CHKUSEGREETING_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSEGREETING_HID, resources.reschkUseGreeting_value, new Integer(97), new Integer(132), new Short((short) 0), INTEGERS[2], new Short((short) 12), new Integer(100)
+ });
+ lstGreeting = insertComboBox("lstGreeting", LSTGREETING_ACTION_PERFORMED, LSTGREETING_ITEM_CHANGED, LSTGREETING_TEXT_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, LSTGREETING_HID, new Integer(105), new Integer(143), INTEGERS[2], new Short((short) 13), new Integer(174)
+ });
+ chkUseFooter = insertCheckBox("chkUseFooter", CHKUSEFOOTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKUSEFOOTER_HID, resources.reschkUseFooter_value, new Integer(97), new Integer(163), new Short((short) 0), INTEGERS[2], new Short((short) 14), new Integer(212)
+ });
+ lblTitle3 = insertLabel("lblTitle3",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGER_16, resources.reslblTitle3_value, Boolean.TRUE, new Integer(91), INTEGERS[8], INTEGERS[2], new Short((short) 59), new Integer(212)
+ });
+ }
+
+ public void buildStep3()
+ {
+ optSenderPlaceholder = insertRadioButton("optSenderPlaceholder", OPTSENDERPLACEHOLDER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTSENDERPLACEHOLDER_HID, resources.resoptSenderPlaceholder_value, new Integer(104), new Integer(42), INTEGERS[3], new Short((short) 15), new Integer(149)
+ });
+ optSenderDefine = insertRadioButton("optSenderDefine", OPTSENDERDEFINE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTSENDERDEFINE_HID, resources.resoptSenderDefine_value, new Integer(104), new Integer(54), INTEGERS[3], new Short((short) 16), new Integer(149)
+ });
+ txtSenderName = insertTextField("txtSenderName", TXTSENDERNAME_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERNAME_HID, new Integer(182), new Integer(67), INTEGERS[3], new Short((short) 17), new Integer(119)
+ });
+ txtSenderStreet = insertTextField("txtSenderStreet", TXTSENDERSTREET_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERSTREET_HID, new Integer(182), new Integer(81), INTEGERS[3], new Short((short) 18), new Integer(119)
+ });
+ txtSenderPostCode = insertTextField("txtSenderPostCode", TXTSENDERPOSTCODE_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERPOSTCODE_HID, new Integer(182), new Integer(95), INTEGERS[3], new Short((short) 19), new Integer(25)
+ });
+ txtSenderState = insertTextField("txtSenderState", TXTSENDERSTATE_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERSTATE_HID, new Integer(211), new Integer(95), INTEGERS[3], new Short((short) 20), new Integer(21)
+ });
+ txtSenderCity = insertTextField("txtSenderCity", TXTSENDERCITY_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERCITY_HID, new Integer(236), new Integer(95), INTEGERS[3], new Short((short) 21), new Integer(65)
+ });
+ txtSenderFax = insertTextField("txtSenderFax", TXTSENDERFAX_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTSENDERFAX_HID, new Integer(182), new Integer(109), INTEGERS[3], new Short((short) 22), new Integer(119)
+ });
+ optReceiverPlaceholder = insertRadioButton("optReceiverPlaceholder", OPTRECEIVERPLACEHOLDER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTRECEIVERPLACEHOLDER_HID, resources.resoptReceiverPlaceholder_value, new Integer(104), new Integer(148), INTEGERS[3], new Short((short) 23), new Integer(200)
+ });
+ optReceiverDatabase = insertRadioButton("optReceiverDatabase", OPTRECEIVERDATABASE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTRECEIVERDATABASE_HID, resources.resoptReceiverDatabase_value, new Integer(104), new Integer(160), INTEGERS[3], new Short((short) 24), new Integer(200)
+ });
+ lblSenderAddress = insertLabel("lblSenderAddress",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderAddress_value, new Integer(97), new Integer(28), INTEGERS[3], new Short((short) 46), new Integer(136)
+ });
+ FixedLine2 = insertFixedLine("FixedLine2",
+ new String[]
+ {
+ "Height", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[5], new Integer(90), new Integer(126), INTEGERS[3], new Short((short) 51), new Integer(212)
+ });
+ lblSenderName = insertLabel("lblSenderName",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderName_value, new Integer(113), new Integer(69), INTEGERS[3], new Short((short) 52), new Integer(68)
+ });
+ lblSenderStreet = insertLabel("lblSenderStreet",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderStreet_value, new Integer(113), new Integer(82), INTEGERS[3], new Short((short) 53), new Integer(68)
+ });
+ lblPostCodeCity = insertLabel("lblPostCodeCity",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPostCodeCity_value, new Integer(113), new Integer(97), INTEGERS[3], new Short((short) 54), new Integer(68)
+ });
+ lblTitle4 = insertLabel("lblTitle4",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGER_16, resources.reslblTitle4_value, Boolean.TRUE, new Integer(91), INTEGERS[8], INTEGERS[3], new Short((short) 60), new Integer(212)
+ });
+ Label1 = insertLabel("lblSenderFax",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.resLabel1_value, new Integer(113), new Integer(111), INTEGERS[3], new Short((short) 68), new Integer(68)
+ });
+ Label2 = insertLabel("Label2",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.resLabel2_value, new Integer(97), new Integer(137), INTEGERS[3], new Short((short) 69), new Integer(136)
+ });
+ }
+
+ public void buildStep4()
+ {
+ txtFooter = insertTextField("txtFooter", TXTFOOTER_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(47), TXTFOOTER_HID, Boolean.TRUE, new Integer(97), INTEGER_40, INTEGERS[4], new Short((short) 25), new Integer(203)
+ });
+ chkFooterNextPages = insertCheckBox("chkFooterNextPages", CHKFOOTERNEXTPAGES_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKFOOTERNEXTPAGES_HID, resources.reschkFooterNextPages_value, new Integer(97), new Integer(92), new Short((short) 0), INTEGERS[4], new Short((short) 26), new Integer(202)
+ });
+ chkFooterPageNumbers = insertCheckBox("chkFooterPageNumbers", CHKFOOTERPAGENUMBERS_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], CHKFOOTERPAGENUMBERS_HID, resources.reschkFooterPageNumbers_value, new Integer(97), new Integer(106), new Short((short) 0), INTEGERS[4], new Short((short) 27), new Integer(201)
+ });
+ lblFooter = insertLabel("lblFooter",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor4, INTEGERS[8], resources.reslblFooter_value, new Integer(97), new Integer(28), INTEGERS[4], new Short((short) 33), new Integer(116)
+ });
+ lblTitle5 = insertLabel("lblTitle5",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGER_16, resources.reslblTitle5_value, Boolean.TRUE, new Integer(91), INTEGERS[8], INTEGERS[4], new Short((short) 61), new Integer(212)
+ });
+ }
+
+ public void buildStep5()
+ {
+ txtTemplateName = insertTextField("txtTemplateName", TXTTEMPLATENAME_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, TXTTEMPLATENAME_HID, new Integer(202), new Integer(56), INTEGERS[5], new Short((short) 28), resources.restxtTemplateName_value, new Integer(100)
+ });
+ /*
+ fileTemplatePath = insertFileControl("fileTemplatePath", FILETEMPLATEPATH_TEXT_CHANGED,
+ new String[] {"Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"},
+ new Object[] { INTEGER_12,FILETEMPLATEPATH_HID,new Integer(172),new Integer(74),INTEGERS[5],new Short((short)29),new Integer(130)}
+ );
+ */
+ optCreateFax = insertRadioButton("optCreateFax", OPTCREATEFAX_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTCREATEFAX_HID, resources.resoptCreateFax_value, new Integer(104), new Integer(111), INTEGERS[5], new Short((short) 30), new Integer(198)
+ });
+ optMakeChanges = insertRadioButton("optMakeChanges", OPTMAKECHANGES_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], OPTMAKECHANGES_HID, resources.resoptMakeChanges_value, new Integer(104), new Integer(123), INTEGERS[5], new Short((short) 31), new Integer(198)
+ });
+ lblFinalExplanation1 = insertLabel("lblFinalExplanation1",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(28), resources.reslblFinalExplanation1_value, Boolean.TRUE, new Integer(97), new Integer(28), INTEGERS[5], new Short((short) 34), new Integer(205)
+ });
+ lblProceed = insertLabel("lblProceed",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblProceed_value, new Integer(97), new Integer(100), INTEGERS[5], new Short((short) 35), new Integer(204)
+ });
+ lblFinalExplanation2 = insertLabel("lblFinalExplanation2",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(33), resources.reslblFinalExplanation2_value, Boolean.TRUE, new Integer(104), new Integer(145), INTEGERS[5], new Short((short) 36), new Integer(199)
+ });
+ ImageControl2 = insertImage("ImageControl2",
+ new String[]
+ {
+ "Border", "Height", "ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 0), INTEGERS[10], "private:resource/dbu/image/19205", new Integer(92), new Integer(145), Boolean.FALSE, INTEGERS[5], new Short((short) 47), INTEGERS[10]
+ });
+ lblTemplateName = insertLabel("lblTemplateName",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblTemplateName_value, new Integer(97), new Integer(58), INTEGERS[5], new Short((short) 57), new Integer(101)
+ });
+ /*
+ lblTemplatePath = insertLabel("lblTemplatePath",
+ new String[] {"Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"},
+ new Object[] { INTEGERS[8],resources.reslblTemplatePath_value,new Integer(97),new Integer(77),INTEGERS[5],new Short((short)58),new Integer(71)}
+ );
+ */
+ lblTitle6 = insertLabel("lblTitle6",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGER_16, resources.reslblTitle6_value, Boolean.TRUE, new Integer(91), INTEGERS[8], INTEGERS[5], new Short((short) 62), new Integer(212)
+ });
+
+ }
+} \ No newline at end of file
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.java
new file mode 100644
index 000000000000..a3c5c8e488dd
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogConst.java
@@ -0,0 +1,116 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+import com.sun.star.wizards.common.*;
+
+public interface FaxWizardDialogConst
+{
+
+ public static final String OPTBUSINESSFAX_ITEM_CHANGED = "optBusinessFaxItemChanged";
+ public static final String LSTBUSINESSSTYLE_ACTION_PERFORMED = null; // "lstBusinessStyleActionPerformed";
+ public static final String LSTBUSINESSSTYLE_ITEM_CHANGED = "lstBusinessStyleItemChanged";
+ public static final String OPTPRIVATEFAX_ITEM_CHANGED = "optPrivateFaxItemChanged";
+ public static final String LSTPRIVATESTYLE_ACTION_PERFORMED = null; // "lstPrivateStyleActionPerformed";
+ public static final String LSTPRIVATESTYLE_ITEM_CHANGED = "lstPrivateStyleItemChanged";
+ public static final String CHKUSELOGO_ITEM_CHANGED = "chkUseLogoItemChanged";
+ public static final String CHKUSEDATE_ITEM_CHANGED = "chkUseDateItemChanged";
+ public static final String CHKUSECOMMUNICATIONTYPE_ITEM_CHANGED = "chkUseCommunicationItemChanged";
+ public static final String LSTCOMMUNICATIONTYPE_ACTION_PERFORMED = null; // "lstCommunicationActionPerformed";
+ public static final String LSTCOMMUNICATIONTYPE_ITEM_CHANGED = "lstCommunicationItemChanged";
+ public static final String LSTCOMMUNICATIONTYPE_TEXT_CHANGED = "lstCommunicationTextChanged";
+ public static final String CHKUSESUBJECT_ITEM_CHANGED = "chkUseSubjectItemChanged";
+ public static final String CHKUSESALUTATION_ITEM_CHANGED = "chkUseSalutationItemChanged";
+ public static final String LSTSALUTATION_ACTION_PERFORMED = null; // "lstSalutationActionPerformed";
+ public static final String LSTSALUTATION_ITEM_CHANGED = "lstSalutationItemChanged";
+ public static final String LSTSALUTATION_TEXT_CHANGED = "lstSalutationTextChanged";
+ public static final String CHKUSEGREETING_ITEM_CHANGED = "chkUseGreetingItemChanged";
+ public static final String LSTGREETING_ACTION_PERFORMED = null; // "lstGreetingActionPerformed";
+ public static final String LSTGREETING_ITEM_CHANGED = "lstGreetingItemChanged";
+ public static final String LSTGREETING_TEXT_CHANGED = "lstGreetingTextChanged";
+ public static final String CHKUSEFOOTER_ITEM_CHANGED = "chkUseFooterItemChanged";
+ public static final String OPTSENDERPLACEHOLDER_ITEM_CHANGED = "optSenderPlaceholderItemChanged";
+ public static final String OPTSENDERDEFINE_ITEM_CHANGED = "optSenderDefineItemChanged";
+ public static final String TXTSENDERNAME_TEXT_CHANGED = "txtSenderNameTextChanged";
+ public static final String TXTSENDERSTREET_TEXT_CHANGED = "txtSenderStreetTextChanged";
+ public static final String TXTSENDERPOSTCODE_TEXT_CHANGED = "txtSenderPostCodeTextChanged";
+ public static final String TXTSENDERSTATE_TEXT_CHANGED = "txtSenderStateTextChanged";
+ public static final String TXTSENDERCITY_TEXT_CHANGED = "txtSenderCityTextChanged";
+ public static final String TXTSENDERFAX_TEXT_CHANGED = "txtSenderFaxTextChanged";
+ public static final String OPTRECEIVERPLACEHOLDER_ITEM_CHANGED = "optReceiverPlaceholderItemChanged";
+ public static final String OPTRECEIVERDATABASE_ITEM_CHANGED = "optReceiverDatabaseItemChanged";
+ public static final String TXTFOOTER_TEXT_CHANGED = "txtFooterTextChanged";
+ public static final String CHKFOOTERNEXTPAGES_ITEM_CHANGED = "chkFooterNextPagesItemChanged";
+ public static final String CHKFOOTERPAGENUMBERS_ITEM_CHANGED = "chkFooterPageNumbersItemChanged";
+ public static final String TXTTEMPLATENAME_TEXT_CHANGED = "txtTemplateNameTextChanged";
+ public static final String FILETEMPLATEPATH_TEXT_CHANGED = null; // "fileTemplatePathTextChanged";
+ public static final String OPTCREATEFAX_ITEM_CHANGED = "optCreateFaxItemChanged";
+ public static final String OPTMAKECHANGES_ITEM_CHANGED = "optMakeChangesItemChanged";
+ public static final String imageURLImageControl2 = null; //"images/ImageControl2";
+ public static final String imageURLImageControl3 = null; //"images/ImageControl3";
+
+ /* ====================================
+ * Help IDs
+ * ====================================
+ */
+ public final static int HID = 41119; //TODO enter first hid here
+ public static final int HIDMAIN = 41180;
+ public final String OPTBUSINESSFAX_HID = HelpIds.getHelpIdString(HID + 1);
+ public final String LSTBUSINESSSTYLE_HID = HelpIds.getHelpIdString(HID + 2);
+ public final String OPTPRIVATEFAX_HID = HelpIds.getHelpIdString(HID + 3);
+ public final String LSTPRIVATESTYLE_HID = HelpIds.getHelpIdString(HID + 4);
+ public final String IMAGECONTROL3_HID = HelpIds.getHelpIdString(HID + 5);
+ public final String CHKUSELOGO_HID = HelpIds.getHelpIdString(HID + 6);
+ public final String CHKUSEDATE_HID = HelpIds.getHelpIdString(HID + 7);
+ public final String CHKUSECOMMUNICATIONTYPE_HID = HelpIds.getHelpIdString(HID + 8);
+ public final String LSTCOMMUNICATIONTYPE_HID = HelpIds.getHelpIdString(HID + 9);
+ public final String CHKUSESUBJECT_HID = HelpIds.getHelpIdString(HID + 10);
+ public final String CHKUSESALUTATION_HID = HelpIds.getHelpIdString(HID + 11);
+ public final String LSTSALUTATION_HID = HelpIds.getHelpIdString(HID + 12);
+ public final String CHKUSEGREETING_HID = HelpIds.getHelpIdString(HID + 13);
+ public final String LSTGREETING_HID = HelpIds.getHelpIdString(HID + 14);
+ public final String CHKUSEFOOTER_HID = HelpIds.getHelpIdString(HID + 15);
+ public final String OPTSENDERPLACEHOLDER_HID = HelpIds.getHelpIdString(HID + 16);
+ public final String OPTSENDERDEFINE_HID = HelpIds.getHelpIdString(HID + 17);
+ public final String TXTSENDERNAME_HID = HelpIds.getHelpIdString(HID + 18);
+ public final String TXTSENDERSTREET_HID = HelpIds.getHelpIdString(HID + 19);
+ public final String TXTSENDERPOSTCODE_HID = HelpIds.getHelpIdString(HID + 20);
+ public final String TXTSENDERSTATE_HID = HelpIds.getHelpIdString(HID + 21);
+ public final String TXTSENDERCITY_HID = HelpIds.getHelpIdString(HID + 22);
+ public final String TXTSENDERFAX_HID = HelpIds.getHelpIdString(HID + 23);
+ public final String OPTRECEIVERPLACEHOLDER_HID = HelpIds.getHelpIdString(HID + 24);
+ public final String OPTRECEIVERDATABASE_HID = HelpIds.getHelpIdString(HID + 25);
+ public final String TXTFOOTER_HID = HelpIds.getHelpIdString(HID + 26);
+ public final String CHKFOOTERNEXTPAGES_HID = HelpIds.getHelpIdString(HID + 27);
+ public final String CHKFOOTERPAGENUMBERS_HID = HelpIds.getHelpIdString(HID + 28);
+ public final String TXTTEMPLATENAME_HID = HelpIds.getHelpIdString(HID + 29);
+ public final String FILETEMPLATEPATH_HID = HelpIds.getHelpIdString(HID + 30);
+ public final String OPTCREATEFAX_HID = HelpIds.getHelpIdString(HID + 31);
+ public final String OPTMAKECHANGES_HID = HelpIds.getHelpIdString(HID + 32);
+ public final String IMAGECONTROL2_HID = HelpIds.getHelpIdString(HID + 33);
+}
+
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java
new file mode 100644
index 000000000000..892505baa85b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogImpl.java
@@ -0,0 +1,873 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import java.util.Vector;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.document.XDocumentPropertiesSupplier;
+import com.sun.star.graphic.XGraphicProvider;
+import com.sun.star.graphic.XGraphic;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.RuntimeException;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.text.*;
+import com.sun.star.wizards.common.*;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.document.*;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.wizards.ui.event.*;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.document.MacroExecMode;
+
+public class FaxWizardDialogImpl extends FaxWizardDialog
+{
+
+ protected void enterStep(int OldStep, int NewStep)
+ {
+ }
+
+ protected void leaveStep(int OldStep, int NewStep)
+ {
+ }
+ static FaxDocument myFaxDoc;
+ static boolean running;
+ XTextDocument xTextDocument;
+ PathSelection myPathSelection;
+ CGFaxWizard myConfig;
+ Vector mainDA = new Vector();
+ Vector faxDA = new Vector();
+ String[][] BusinessFiles;
+ String[][] PrivateFiles;
+ String sTemplatePath;
+ String sUserTemplatePath;
+ String sBitmapPath;
+ String sFaxPath;
+ String sWorkPath;
+ String sPath;
+ boolean bEditTemplate;
+ boolean bSaveSuccess = false;
+ private boolean filenameChanged = false;
+ final static int RM_TYPESTYLE = 1;
+ final static int RM_ELEMENTS = 2;
+ final static int RM_SENDERRECEIVER = 3;
+ final static int RM_FOOTER = 4;
+ final static int RM_FINALSETTINGS = 5;
+
+ public FaxWizardDialogImpl(XMultiServiceFactory xmsf)
+ {
+ super(xmsf);
+ }
+
+ public static void main(String args[])
+ {
+ //only being called when starting wizard remotely
+
+ try
+ {
+ String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr);
+ FaxWizardDialogImpl lw = new FaxWizardDialogImpl(xLocMSF);
+ lw.startWizard(xLocMSF, null);
+ }
+ catch (RuntimeException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (java.lang.Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ public void startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue)
+ {
+
+ running = true;
+ try
+ {
+ //Number of steps on WizardDialog:
+ setMaxStep(5);
+
+ //instatiate The Document Frame for the Preview
+ myFaxDoc = new FaxDocument(xMSF, this);
+
+ //create the dialog:
+ drawNaviBar();
+ buildStep1();
+ buildStep2();
+ buildStep3();
+ buildStep4();
+ buildStep5();
+
+ initializeSalutation();
+ initializeGreeting();
+ initializeCommunication();
+ initializePaths();
+
+ //special Control for setting the save Path:
+ insertPathSelectionControl();
+
+ //load the last used settings from the registry and apply listeners to the controls:
+ initConfiguration();
+
+ initializeTemplates(xMSF);
+
+ //update the dialog UI according to the loaded Configuration
+ updateUI();
+
+ if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(""))
+ {
+ myPathSelection.initializePath();
+ }
+
+ XWindow xContainerWindow = myFaxDoc.xFrame.getContainerWindow();
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xContainerWindow);
+ createWindowPeer(xWindowPeer);
+
+ //add the Roadmap to the dialog:
+ insertRoadmap();
+
+ //load the last used document and apply last used settings:
+ //TODO:
+ setConfiguration();
+
+ //If the configuration does not define Greeting/Salutation/CommunicationType yet choose a default
+ setDefaultForGreetingAndSalutationAndCommunication();
+
+ //disable funtionality that is not supported by the template:
+ initializeElements();
+
+ //disable the document, so that the user cannot change anything:
+ myFaxDoc.xFrame.getComponentWindow().setEnable(false);
+
+ executeDialog(myFaxDoc.xFrame);
+ removeTerminateListener();
+ closeDocument();
+ running = false;
+
+ }
+ catch (Exception exception)
+ {
+ removeTerminateListener();
+ exception.printStackTrace(System.out);
+ running = false;
+ return;
+ }
+ }
+
+ public void cancelWizard()
+ {
+ xDialog.endExecute();
+ running = false;
+ }
+
+ public boolean finishWizard()
+ {
+ switchToStep(getCurrentStep(), getMaxStep());
+ myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription);
+ try
+ {
+ //myFaxDoc.xTextDocument.lockControllers();
+ FileAccess fileAccess = new FileAccess(xMSF);
+ sPath = myPathSelection.getSelectedPath();
+ if (sPath.equals(""))
+ {
+ myPathSelection.triggerPathPicker();
+ sPath = myPathSelection.getSelectedPath();
+ }
+ sPath = fileAccess.getURL(sPath);
+
+ //first, if the filename was not changed, thus
+ //it is coming from a saved session, check if the
+ // file exists and warn the user.
+ if (!filenameChanged)
+ {
+ if (fileAccess.exists(sPath, true))
+ {
+
+ int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning);
+ if (answer == 3) // user said: no, do not overwrite....
+ {
+ return false;
+ }
+ }
+ }
+ myFaxDoc.setWizardTemplateDocInfo(resources.resFaxWizardDialog_title, resources.resTemplateDescription);
+ myFaxDoc.killEmptyUserFields();
+ myFaxDoc.keepLogoFrame = (chkUseLogo.getState() != 0);
+ myFaxDoc.keepTypeFrame = (chkUseCommunicationType.getState() != 0);
+ myFaxDoc.killEmptyFrames();
+
+
+ bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath, "writer8_template", false);
+ if (bSaveSuccess)
+ {
+ saveConfiguration();
+ XInteractionHandler xIH = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler"));
+ PropertyValue loadValues[] = new PropertyValue[4];
+ loadValues[0] = new PropertyValue();
+ loadValues[0].Name = "AsTemplate";
+ loadValues[1] = new PropertyValue();
+ loadValues[1].Name = "MacroExecutionMode";
+ loadValues[1].Value = new Short(MacroExecMode.ALWAYS_EXECUTE);
+ loadValues[2] = new PropertyValue();
+ loadValues[2].Name = "UpdateDocMode";
+ loadValues[2].Value = new Short(com.sun.star.document.UpdateDocMode.FULL_UPDATE);
+ loadValues[3] = new PropertyValue();
+ loadValues[3].Name = "InteractionHandler";
+ loadValues[3].Value = xIH;
+
+
+ if (bEditTemplate)
+ {
+ loadValues[0].Value = Boolean.FALSE;
+ }
+ else
+ {
+ loadValues[0].Value = Boolean.TRUE;
+ }
+ Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", loadValues);
+ XTextDocument xTextDocument = (com.sun.star.text.XTextDocument) oDoc;
+ XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument);
+ myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL));
+ }
+ else
+ {
+ //TODO: Error Handling
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ xDialog.endExecute();
+ running = false;
+ }
+ return true;
+ }
+
+ public void closeDocument()
+ {
+ try
+ {
+ //xComponent.dispose();
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, myFaxDoc.xFrame);
+ xCloseable.close(false);
+ }
+ catch (CloseVetoException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void insertRoadmap()
+ {
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, resources.RoadmapLabels[RM_TYPESTYLE], RM_TYPESTYLE);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_ELEMENTS], RM_ELEMENTS);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_SENDERRECEIVER], RM_SENDERRECEIVER);
+ i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_FOOTER], RM_FOOTER);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_FINALSETTINGS], RM_FINALSETTINGS);
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+
+ private class myPathSelectionListener implements XPathSelectionListener
+ {
+
+ public void validatePath()
+ {
+ if (myPathSelection.usedPathPicker)
+ {
+ filenameChanged = true;
+ }
+ myPathSelection.usedPathPicker = false;
+ }
+ }
+
+ public void insertPathSelectionControl()
+ {
+ myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE);
+ myPathSelection.insert(5, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString(HID + 34), HelpIds.getHelpIdString(HID + 35));
+ myPathSelection.sDefaultDirectory = sUserTemplatePath;
+ myPathSelection.sDefaultName = "myFaxTemplate.ott";
+ myPathSelection.sDefaultFilter = "writer8_template";
+ myPathSelection.addSelectionListener(new myPathSelectionListener());
+ }
+
+ private void insertIcons()
+ {
+ try
+ {
+ Object oGS = xMSF.createInstance("com.sun.star.graphic.GraphicProvider");
+ XGraphicProvider xGraphicProvider = (XGraphicProvider) UnoRuntime.queryInterface(XGraphicProvider.class, oGS);
+
+ PropertyValue GraphicValues[] = new PropertyValue[1];
+ GraphicValues[0] = new PropertyValue();
+ GraphicValues[0].Name = "URL";
+ GraphicValues[0].Value = "private:resource/svx/imagelist/18000/18022";
+ XGraphic xGraphic = xGraphicProvider.queryGraphic(GraphicValues);
+
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ private void updateUI()
+ {
+ UnoDataAware.updateUI(mainDA);
+ UnoDataAware.updateUI(faxDA);
+ }
+
+ private void initializePaths()
+ {
+ try
+ {
+ sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard");
+ sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", "");
+ sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap");
+ }
+ catch (NoValidPathException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean initializeTemplates(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ String sFaxSubPath = "/wizard/fax";
+ sFaxPath = FileAccess.combinePaths(xMSF, sTemplatePath, sFaxSubPath);
+ sWorkPath = FileAccess.getOfficePath(xMSF, "Work", "", "");
+
+ BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus", sFaxPath);
+ PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri", sFaxPath);
+
+ setControlProperty("lstBusinessStyle", "StringItemList", BusinessFiles[0]);
+ setControlProperty("lstPrivateStyle", "StringItemList", PrivateFiles[0]);
+
+ setControlProperty("lstBusinessStyle", "SelectedItems", new short[]
+ {
+ 0
+ });
+ setControlProperty("lstPrivateStyle", "SelectedItems", new short[]
+ {
+ 0
+ });
+
+ return true;
+ }
+ catch (NoValidPathException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
+ }
+
+ public void initializeElements()
+ {
+ setControlProperty("chkUseLogo", "Enabled", new Boolean(myFaxDoc.hasElement("Company Logo")));
+ setControlProperty("chkUseSubject", "Enabled", new Boolean(myFaxDoc.hasElement("Subject Line")));
+ setControlProperty("chkUseDate", "Enabled", new Boolean(myFaxDoc.hasElement("Date")));
+ myFaxDoc.updateDateFields();
+ }
+
+ public void initializeSalutation()
+ {
+ setControlProperty("lstSalutation", "StringItemList", resources.SalutationLabels);
+ }
+
+ public void initializeGreeting()
+ {
+ setControlProperty("lstGreeting", "StringItemList", resources.GreetingLabels);
+ }
+
+ public void initializeCommunication()
+ {
+ setControlProperty("lstCommunicationType", "StringItemList", resources.CommunicationLabels);
+ }
+
+ private void setDefaultForGreetingAndSalutationAndCommunication()
+ {
+ XTextComponent xTextComponent;
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ if (xTextComponent.getText().equals(""))
+ {
+ xTextComponent.setText(resources.SalutationLabels[0]);
+ }
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ if (xTextComponent.getText().equals(""))
+ {
+ xTextComponent.setText(resources.GreetingLabels[0]);
+ }
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType);
+ if (xTextComponent.getText().equals(""))
+ {
+ xTextComponent.setText(resources.CommunicationLabels[0]);
+ }
+ }
+
+ public void initConfiguration()
+ {
+ try
+ {
+ myConfig = new CGFaxWizard();
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Fax", false);
+ myConfig.readConfiguration(root, "cp_");
+ mainDA.add(RadioDataAware.attachRadioButtons(myConfig, "cp_FaxType", new Object[]
+ {
+ optBusinessFax, optPrivateFax
+ }, null, true));
+ mainDA.add(UnoDataAware.attachListBox(myConfig.cp_BusinessFax, "cp_Style", lstBusinessStyle, null, true));
+ mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateFax, "cp_Style", lstPrivateStyle, null, true));
+
+ CGFax cgl = myConfig.cp_BusinessFax;
+
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyLogo", chkUseLogo, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSubjectLine", chkUseSubject, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSalutation", chkUseSalutation, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintDate", chkUseDate, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCommunicationType", chkUseCommunicationType, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintGreeting", chkUseGreeting, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintFooter", chkUseFooter, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Salutation", lstSalutation, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Greeting", lstGreeting, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_CommunicationType", lstCommunicationType, null, true));
+ faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType", new Object[]
+ {
+ optSenderDefine, optSenderPlaceholder
+ }, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName", txtSenderName, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderStreet", txtSenderStreet, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode", txtSenderPostCode, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderState", txtSenderState, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCity", txtSenderCity, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderFax", txtSenderFax, null, true));
+ faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType", new Object[]
+ {
+ optReceiverDatabase, optReceiverPlaceholder
+ }, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_Footer", txtFooter, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage", chkFooterNextPages, null, true));
+ faxDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers", chkFooterPageNumbers, null, true));
+ faxDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_CreationType", new Object[]
+ {
+ optCreateFax, optMakeChanges
+ }, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplateName", txtTemplateName, null, true));
+ faxDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplatePath", myPathSelection.xSaveTextBox, null, true));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ }
+
+ }
+
+ public void saveConfiguration()
+ {
+ try
+ {
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Fax", true);
+ myConfig.writeConfiguration(root, "cp_");
+ Configuration.commit(root);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void setConfiguration()
+ {
+ //set correct Configuration tree:
+ if (optBusinessFax.getState())
+ {
+ optBusinessFaxItemChanged();
+ }
+ if (optPrivateFax.getState())
+ {
+ optPrivateFaxItemChanged();
+ }
+ }
+
+ public void optBusinessFaxItemChanged()
+ {
+ DataAware.setDataObject(faxDA, myConfig.cp_BusinessFax, true);
+ setControlProperty("lblBusinessStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lstBusinessStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lblPrivateStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstPrivateStyle", "Enabled", Boolean.FALSE);
+ lstBusinessStyleItemChanged();
+ enableSenderReceiver();
+ setPossibleFooter(true);
+ }
+
+ public void lstBusinessStyleItemChanged()
+ {
+ xTextDocument = myFaxDoc.loadAsPreview(BusinessFiles[1][lstBusinessStyle.getSelectedItemPos()], false);
+ initializeElements();
+ setElements();
+ }
+
+ public void optPrivateFaxItemChanged()
+ {
+ DataAware.setDataObject(faxDA, myConfig.cp_PrivateFax, true);
+ setControlProperty("lblBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPrivateStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lstPrivateStyle", "Enabled", Boolean.TRUE);
+ lstPrivateStyleItemChanged();
+ disableSenderReceiver();
+ setPossibleFooter(false);
+ }
+
+ public void lstPrivateStyleItemChanged()
+ {
+ xTextDocument = myFaxDoc.loadAsPreview(PrivateFiles[1][lstPrivateStyle.getSelectedItemPos()], false);
+ initializeElements();
+ setElements();
+ }
+
+ public void txtTemplateNameTextChanged()
+ {
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ XDocumentProperties xDocProps = xDocPropsSuppl.getDocumentProperties();
+ String TitleName = txtTemplateName.getText();
+ xDocProps.setTitle(TitleName);
+ }
+
+ public void optSenderPlaceholderItemChanged()
+ {
+ setControlProperty("lblSenderName", "Enabled", Boolean.FALSE);
+ setControlProperty("lblSenderStreet", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPostCodeCity", "Enabled", Boolean.FALSE);
+ setControlProperty("lblSenderFax", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderName", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderStreet", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderPostCode", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderState", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderCity", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderFax", "Enabled", Boolean.FALSE);
+ myFaxDoc.fillSenderWithUserData();
+ }
+
+ public void optSenderDefineItemChanged()
+ {
+ setControlProperty("lblSenderName", "Enabled", Boolean.TRUE);
+ setControlProperty("lblSenderStreet", "Enabled", Boolean.TRUE);
+ setControlProperty("lblPostCodeCity", "Enabled", Boolean.TRUE);
+ setControlProperty("lblSenderFax", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderName", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderStreet", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderPostCode", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderState", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderCity", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderFax", "Enabled", Boolean.TRUE);
+ txtSenderNameTextChanged();
+ txtSenderStreetTextChanged();
+ txtSenderPostCodeTextChanged();
+ txtSenderStateTextChanged();
+ txtSenderCityTextChanged();
+ txtSenderFaxTextChanged();
+ }
+
+ public void optReceiverPlaceholderItemChanged()
+ {
+ OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Placeholder()");
+ }
+
+ public void optReceiverDatabaseItemChanged()
+ {
+ OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Database()");
+ }
+
+ public void optCreateFaxItemChanged()
+ {
+ bEditTemplate = false;
+ }
+
+ public void optMakeChangesItemChanged()
+ {
+ bEditTemplate = true;
+ }
+
+ public void txtSenderNameTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("Company", txtSenderName.getText());
+ }
+
+ public void txtSenderStreetTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("Street", txtSenderStreet.getText());
+ }
+
+ public void txtSenderCityTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("City", txtSenderCity.getText());
+ }
+
+ public void txtSenderPostCodeTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("PostCode", txtSenderPostCode.getText());
+ }
+
+ public void txtSenderStateTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("State", txtSenderState.getText());
+ }
+
+ public void txtSenderFaxTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myFaxDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("Fax", txtSenderFax.getText());
+ }
+ //switch Elements on/off -------------------------------------------------------
+ public void setElements()
+ {
+ //UI relevant:
+ if (optSenderDefine.getState())
+ {
+ optSenderDefineItemChanged();
+ }
+ if (optSenderPlaceholder.getState())
+ {
+ optSenderPlaceholderItemChanged();
+ }
+ chkUseLogoItemChanged();
+ chkUseSubjectItemChanged();
+ chkUseSalutationItemChanged();
+ chkUseGreetingItemChanged();
+ chkUseCommunicationItemChanged();
+ chkUseDateItemChanged();
+ chkUseFooterItemChanged();
+ txtTemplateNameTextChanged();
+
+ //not UI relevant:
+ if (optReceiverDatabase.getState())
+ {
+ optReceiverDatabaseItemChanged();
+ }
+ if (optReceiverPlaceholder.getState())
+ {
+ optReceiverPlaceholderItemChanged();
+ }
+ if (optCreateFax.getState())
+ {
+ optCreateFaxItemChanged();
+ }
+ if (optMakeChanges.getState())
+ {
+ optMakeChangesItemChanged();
+ }
+ }
+
+ public void chkUseLogoItemChanged()
+ {
+ if (myFaxDoc.hasElement("Company Logo"))
+ {
+ myFaxDoc.switchElement("Company Logo", (chkUseLogo.getState() != 0));
+ }
+ }
+
+ public void chkUseSubjectItemChanged()
+ {
+ if (myFaxDoc.hasElement("Subject Line"))
+ {
+ myFaxDoc.switchElement("Subject Line", (chkUseSubject.getState() != 0));
+ }
+ }
+
+ public void chkUseDateItemChanged()
+ {
+ if (myFaxDoc.hasElement("Date"))
+ {
+ myFaxDoc.switchElement("Date", (chkUseDate.getState() != 0));
+ }
+ }
+
+ public void chkUseFooterItemChanged()
+ {
+ try
+ {
+ boolean bFooterPossible = (chkUseFooter.getState() != 0) && AnyConverter.toBoolean(getControlProperty("chkUseFooter", "Enabled"));
+
+ if (chkFooterNextPages.getState() != 0)
+ {
+ myFaxDoc.switchFooter("First Page", false, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ myFaxDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ }
+ else
+ {
+ myFaxDoc.switchFooter("First Page", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ myFaxDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ }
+
+ //enable/disable roadmap item for footer page
+ XInterface BPaperItem = getRoadmapItemByID(RM_FOOTER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", new Boolean(bFooterPossible));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void chkFooterNextPagesItemChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ public void chkFooterPageNumbersItemChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ public void txtFooterTextChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ public void chkUseSalutationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ myFaxDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0));
+ setControlProperty("lstSalutation", "Enabled", new Boolean(chkUseSalutation.getState() != 0));
+ }
+
+ public void lstSalutationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ myFaxDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0));
+ }
+
+ public void lstSalutationTextChanged()
+ {
+ }
+
+ public void chkUseCommunicationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType);
+ myFaxDoc.switchUserField("CommunicationType", xTextComponent.getText(), (chkUseCommunicationType.getState() != 0));
+ setControlProperty("lstCommunicationType", "Enabled", new Boolean(chkUseCommunicationType.getState() != 0));
+ }
+
+ public void lstCommunicationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstCommunicationType);
+ myFaxDoc.switchUserField("CommunicationType", xTextComponent.getText(), (chkUseCommunicationType.getState() != 0));
+ }
+
+ public void lstCommunicationTextChanged()
+ {
+ }
+
+ public void chkUseGreetingItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ myFaxDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0));
+ setControlProperty("lstGreeting", "Enabled", new Boolean(chkUseGreeting.getState() != 0));
+ }
+
+ public void lstGreetingItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ myFaxDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0));
+ }
+
+ public void lstGreetingTextChanged()
+ {
+ }
+
+ private void setPossibleFooter(boolean bState)
+ {
+ setControlProperty("chkUseFooter", "Enabled", new Boolean(bState));
+ if (!bState)
+ {
+ chkUseFooter.setState((short) 0);
+ }
+ chkUseFooterItemChanged();
+ }
+
+ private void enableSenderReceiver()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.TRUE);
+ }
+
+ private void disableSenderReceiver()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.FALSE);
+ }
+}
+
+
+
+
+
diff --git a/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.java b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.java
new file mode 100644
index 000000000000..0043d25590d8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/FaxWizardDialogResources.java
@@ -0,0 +1,182 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.fax;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Resource;
+
+public class FaxWizardDialogResources extends Resource
+{
+
+ final static String UNIT_NAME = "dbwizres";
+ final static String MODULE_NAME = "dbw";
+ final static int RID_FAXWIZARDDIALOG_START = 3200;
+ final static int RID_FAXWIZARDCOMMUNICATION_START = 3270;
+ final static int RID_FAXWIZARDGREETING_START = 3280;
+ final static int RID_FAXWIZARDSALUTATION_START = 3290;
+ final static int RID_FAXWIZARDROADMAP_START = 3300;
+ final static int RID_RID_COMMON_START = 500;
+ protected String[] RoadmapLabels = new String[7];
+ protected String[] SalutationLabels = new String[4];
+ protected String[] GreetingLabels = new String[4];
+ protected String[] CommunicationLabels = new String[3];
+ String resOverwriteWarning;
+ String resTemplateDescription;
+ String resFaxWizardDialog_title;
+ String resLabel9_value;
+ String resoptBusinessFax_value;
+ String resoptPrivateFax_value;
+ String reschkUseLogo_value;
+ String reschkUseSubject_value;
+ String reschkUseSalutation_value;
+ String reschkUseGreeting_value;
+ String reschkUseFooter_value;
+ String resoptSenderPlaceholder_value;
+ String resoptSenderDefine_value;
+ String restxtTemplateName_value;
+ String resoptCreateFax_value;
+ String resoptMakeChanges_value;
+ String reslblBusinessStyle_value;
+ String reslblPrivateStyle_value;
+ String reslblIntroduction_value;
+ String reslblSenderAddress_value;
+ String reslblSenderName_value;
+ String reslblSenderStreet_value;
+ String reslblPostCodeCity_value;
+ String reslblFooter_value;
+ String reslblFinalExplanation1_value;
+ String reslblFinalExplanation2_value;
+ String reslblTemplateName_value;
+ String reslblTemplatePath_value;
+ String reslblProceed_value;
+ String reslblTitle1_value;
+ String reslblTitle3_value;
+ String reslblTitle4_value;
+ String reslblTitle5_value;
+ String reslblTitle6_value;
+ String reschkFooterNextPages_value;
+ String reschkFooterPageNumbers_value;
+ String reschkUseDate_value;
+ String reschkUseCommunicationType_value;
+ String resLabel1_value;
+ String resoptReceiverPlaceholder_value;
+ String resoptReceiverDatabase_value;
+ String resLabel2_value;
+
+ public FaxWizardDialogResources(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, UNIT_NAME, MODULE_NAME);
+ /**
+ * Delete the String, uncomment the getResText method
+ *
+ */
+ resFaxWizardDialog_title = getResText(RID_FAXWIZARDDIALOG_START + 1);
+ resLabel9_value = getResText(RID_FAXWIZARDDIALOG_START + 2);
+ resoptBusinessFax_value = getResText(RID_FAXWIZARDDIALOG_START + 3);
+ resoptPrivateFax_value = getResText(RID_FAXWIZARDDIALOG_START + 4);
+ reschkUseLogo_value = getResText(RID_FAXWIZARDDIALOG_START + 5);
+ reschkUseSubject_value = getResText(RID_FAXWIZARDDIALOG_START + 6);
+ reschkUseSalutation_value = getResText(RID_FAXWIZARDDIALOG_START + 7);
+ reschkUseGreeting_value = getResText(RID_FAXWIZARDDIALOG_START + 8);
+ reschkUseFooter_value = getResText(RID_FAXWIZARDDIALOG_START + 9);
+ resoptSenderPlaceholder_value = getResText(RID_FAXWIZARDDIALOG_START + 10);
+ resoptSenderDefine_value = getResText(RID_FAXWIZARDDIALOG_START + 11);
+ restxtTemplateName_value = getResText(RID_FAXWIZARDDIALOG_START + 12);
+ resoptCreateFax_value = getResText(RID_FAXWIZARDDIALOG_START + 13);
+ resoptMakeChanges_value = getResText(RID_FAXWIZARDDIALOG_START + 14);
+ reslblBusinessStyle_value = getResText(RID_FAXWIZARDDIALOG_START + 15);
+ reslblPrivateStyle_value = getResText(RID_FAXWIZARDDIALOG_START + 16);
+ reslblIntroduction_value = getResText(RID_FAXWIZARDDIALOG_START + 17);
+ reslblSenderAddress_value = getResText(RID_FAXWIZARDDIALOG_START + 18);
+ reslblSenderName_value = getResText(RID_FAXWIZARDDIALOG_START + 19);
+ reslblSenderStreet_value = getResText(RID_FAXWIZARDDIALOG_START + 20);
+ reslblPostCodeCity_value = getResText(RID_FAXWIZARDDIALOG_START + 21);
+ reslblFooter_value = getResText(RID_FAXWIZARDDIALOG_START + 22);
+ reslblFinalExplanation1_value = getResText(RID_FAXWIZARDDIALOG_START + 23);
+ reslblFinalExplanation2_value = getResText(RID_FAXWIZARDDIALOG_START + 24);
+ reslblTemplateName_value = getResText(RID_FAXWIZARDDIALOG_START + 25);
+ reslblTemplatePath_value = getResText(RID_FAXWIZARDDIALOG_START + 26);
+ reslblProceed_value = getResText(RID_FAXWIZARDDIALOG_START + 27);
+ reslblTitle1_value = getResText(RID_FAXWIZARDDIALOG_START + 28);
+ reslblTitle3_value = getResText(RID_FAXWIZARDDIALOG_START + 29);
+ reslblTitle4_value = getResText(RID_FAXWIZARDDIALOG_START + 30);
+ reslblTitle5_value = getResText(RID_FAXWIZARDDIALOG_START + 31);
+ reslblTitle6_value = getResText(RID_FAXWIZARDDIALOG_START + 32);
+ reschkFooterNextPages_value = getResText(RID_FAXWIZARDDIALOG_START + 33);
+ reschkFooterPageNumbers_value = getResText(RID_FAXWIZARDDIALOG_START + 34);
+ reschkUseDate_value = getResText(RID_FAXWIZARDDIALOG_START + 35);
+ reschkUseCommunicationType_value = getResText(RID_FAXWIZARDDIALOG_START + 36);
+ resLabel1_value = getResText(RID_FAXWIZARDDIALOG_START + 37);
+ resoptReceiverPlaceholder_value = getResText(RID_FAXWIZARDDIALOG_START + 38);
+ resoptReceiverDatabase_value = getResText(RID_FAXWIZARDDIALOG_START + 39);
+ resLabel2_value = getResText(RID_FAXWIZARDDIALOG_START + 40);
+ loadRoadmapResources();
+ loadSalutationResources();
+ loadGreetingResources();
+ loadCommunicationResources();
+ loadCommonResources();
+ }
+
+ private void loadCommonResources()
+ {
+ resOverwriteWarning = getResText(RID_RID_COMMON_START + 19);
+ resTemplateDescription = getResText(RID_RID_COMMON_START + 20);
+ }
+
+ private void loadRoadmapResources()
+ {
+ for (int i = 1; i < 6; i++)
+ {
+ RoadmapLabels[i] = getResText(RID_FAXWIZARDROADMAP_START + i);
+ }
+ }
+
+ private void loadSalutationResources()
+ {
+ for (int i = 1; i < 5; i++)
+ {
+ SalutationLabels[i - 1] = getResText(RID_FAXWIZARDSALUTATION_START + i);
+ }
+ }
+
+ private void loadGreetingResources()
+ {
+ for (int i = 1; i < 5; i++)
+ {
+ GreetingLabels[i - 1] = getResText(RID_FAXWIZARDGREETING_START + i);
+ }
+ }
+
+ private void loadCommunicationResources()
+ {
+ for (int i = 1; i < 4; i++)
+ {
+ CommunicationLabels[i - 1] = getResText(RID_FAXWIZARDCOMMUNICATION_START + i);
+ }
+ }
+} \ No newline at end of file
diff --git a/wizards/com/sun/star/wizards/fax/MANIFEST.MF b/wizards/com/sun/star/wizards/fax/MANIFEST.MF
new file mode 100644
index 000000000000..4e699ee9073b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.fax.CallWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/fax/fax.component b/wizards/com/sun/star/wizards/fax/fax.component
new file mode 100644
index 000000000000..462fe2901255
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/fax.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.wizards.fax.CallWizard$WizardImplementation">
+ <service name="com.sun.star.wizards.fax.CallWizard"/>
+ </implementation>
+</component>
diff --git a/wizards/com/sun/star/wizards/fax/makefile.mk b/wizards/com/sun/star/wizards/fax/makefile.mk
new file mode 100644
index 000000000000..5cf08939263b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/fax/makefile.mk
@@ -0,0 +1,70 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = fax
+PACKAGE = com$/sun$/star$/wizards$/fax
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar java_uno_accessbridge commonwizards.jar
+
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/fax
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ CallWizard.java \
+ CGFax.java \
+ FaxDocument.java \
+ FaxWizardDialog.java \
+ CGFaxWizard.java \
+ FaxWizardDialogConst.java \
+ FaxWizardDialogResources.java \
+ FaxWizardDialogImpl.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/fax.component
+
+$(MISC)/fax.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ fax.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt fax.component
diff --git a/wizards/com/sun/star/wizards/form/CallFormWizard.java b/wizards/com/sun/star/wizards/form/CallFormWizard.java
new file mode 100644
index 000000000000..0538eb5fa1b3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/CallFormWizard.java
@@ -0,0 +1,206 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.Type;
+import com.sun.star.wizards.common.Properties;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>).
+ * @author Bertram Nolte
+ */
+public class CallFormWizard
+{
+
+ /** 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 xmultiservicefactory The service manager, who gives access to every
+ * known service.
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) 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(FormWizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(FormWizardImplementation.class, FormWizardImplementation.__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 FormWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor
+ {
+ 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 FormWizardImplementation(com.sun.star.lang.XMultiServiceFactory xmultiservicefactoryInitialization)
+ {
+ super();
+ m_serviceFactory = xmultiservicefactoryInitialization;
+ }
+
+ public void trigger(String sEvent)
+ {
+ try
+ {
+ if (sEvent.compareTo("start") == 0)
+ {
+ FormWizard CurFormWizard = new FormWizard( m_serviceFactory, m_wizardContext );
+ CurFormWizard.startFormWizard();
+ }
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+ 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.form.CallFormWizard";
+ /** The service manager, that gives access to all registered services.
+ */
+ private com.sun.star.lang.XMultiServiceFactory m_serviceFactory;
+
+ /** 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 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
+ {
+ 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[1];
+
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /** This method returns an array of bytes, that can be used to
+ * unambiguously distinguish between two sets of types, e.g.
+ * to realise hashing functionality when the object is introspected.
+ * Two objects that return the same ID also have to return
+ * the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to
+ * return an empty sequence. Important: If the object
+ * aggregates other objects the ID has to be unique for the
+ * whole combination of objects.
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = new String("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (FormWizardImplementation.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.
+ */
+ 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.beans.XPropertySet.class), new Type(com.sun.star.beans.XFastPropertySet.class), new Type(com.sun.star.beans.XMultiPropertySet.class), new Type(com.sun.star.lang.XInitialization.class)
+ };
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/DataEntrySetter.java b/wizards/com/sun/star/wizards/form/DataEntrySetter.java
new file mode 100644
index 000000000000..7fab3dcdd5b1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/DataEntrySetter.java
@@ -0,0 +1,147 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.WizardDialog;
+import com.sun.star.wizards.ui.UIConsts;
+
+public class DataEntrySetter
+{
+
+ private WizardDialog CurUnoDialog;
+ private short curtabindex;
+ private XRadioButton optNewDataOnly;
+ private XRadioButton optDisplayAllData;
+ private XCheckBox chknomodification;
+ private XCheckBox chknodeletion;
+ private XCheckBox chknoaddition;
+
+ public DataEntrySetter(WizardDialog _CurUnoDialog)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (FormWizard.SODATA_PAGE * 100);
+ Integer IDataStep = new Integer(FormWizard.SODATA_PAGE);
+ String sNewDataOnly = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 44); //
+ String sDisplayAllData = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 46); //
+ String sNoModification = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 47); // AllowUpdates
+ String sNoDeletion = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 48); // AllowDeletes
+ String sNoAddition = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 49); // AlowInserts
+ String sdontdisplayExistingData = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 45);
+
+ optNewDataOnly = CurUnoDialog.insertRadioButton("optNewDataOnly", "toggleCheckBoxes", this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTNEWDATAONLY", sNewDataOnly, new Integer(98), new Integer(25), IDataStep, new Short(curtabindex++), new Integer(195)
+ });
+
+ optDisplayAllData = CurUnoDialog.insertRadioButton("optDisplayAllData", "toggleCheckBoxes", this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTDISPLAYALLDATA", sDisplayAllData, new Integer(98), new Integer(50), new Short((short) 1), IDataStep, new Short(curtabindex++), new Integer(197)
+ });
+ chknomodification = CurUnoDialog.insertCheckBox("chknomodification", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOMODIFICATION", sNoModification, new Integer(108), new Integer(62), new Short((short) 0), IDataStep, new Short(curtabindex++), new Integer(189)
+ });
+ chknodeletion = CurUnoDialog.insertCheckBox("chknodeletion", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNODELETION", sNoDeletion, new Integer(108), new Integer(74), new Short((short) 0), IDataStep, new Short(curtabindex++), new Integer(189)
+ });
+ chknoaddition = CurUnoDialog.insertCheckBox("chknoaddition", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKNOADDITION", sNoAddition, new Integer(108), new Integer(86), new Short((short) 0), IDataStep, new Short(curtabindex++), new Integer(191)
+ });
+ CurUnoDialog.insertLabel("lbldontdisplayExistingData",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sdontdisplayExistingData, new Integer(108), new Integer(33), IDataStep, new Short(curtabindex++), new Integer(134)
+ });
+ }
+
+ public PropertyValue[] getFormProperties()
+ {
+ PropertyValue[] retProperties;
+ if (optDisplayAllData.getState())
+ {
+ retProperties = new PropertyValue[3];
+ boolean bAllowUpdates = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknomodification), "State")).shortValue()) != 1;
+ boolean bAllowDeletes = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknodeletion), "State")).shortValue()) != 1;
+ boolean bAllowInserts = (((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(chknoaddition), "State")).shortValue()) != 1;
+ retProperties[0] = Properties.createProperty("AllowUpdates", new Boolean(bAllowUpdates));
+ retProperties[1] = Properties.createProperty("AllowDeletes", new Boolean(bAllowDeletes));
+ retProperties[2] = Properties.createProperty("AllowInserts", new Boolean(bAllowInserts));
+ }
+ else
+ {
+ retProperties = new PropertyValue[1];
+ retProperties[0] = Properties.createProperty("IgnoreResult", new Boolean(true));
+ }
+ return retProperties;
+
+ }
+
+ public void toggleCheckBoxes()
+ {
+ boolean bdisplayalldata = optDisplayAllData.getState();
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chknomodification), "Enabled", new Boolean(bdisplayalldata));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chknodeletion), "Enabled", new Boolean(bdisplayalldata));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chknoaddition), "Enabled", new Boolean(bdisplayalldata));
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/FieldLinker.java b/wizards/com/sun/star/wizards/form/FieldLinker.java
new file mode 100644
index 000000000000..a3b4b7f5b70a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/FieldLinker.java
@@ -0,0 +1,313 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.uno.Exception;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.db.RelationController;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.WizardDialog;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.DBLimitedFieldSelection;
+
+public class FieldLinker extends DBLimitedFieldSelection
+{
+
+ private XFixedText[] lblSlaveFields;
+ private XFixedText[] lblMasterFields;
+ private XListBox[] lstSlaveFields;
+ private XListBox[] lstMasterFields;
+ private final int SOMASTERINDEX = 1;
+ private final int SOSLAVEINDEX = 0;
+ private int SOFIRSTLINKLST = 0;
+ private int SOSECLINKLST = 1;
+ private int SOTHIRDLINKLST = 2;
+ private int SOFOURTHLINKLST = 3;
+ private int[] SOLINKLST = null;
+ private String[] sSlaveListHeader;
+ private String[] sMasterListHeader; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40);
+ private String sSlaveHidString;
+ private String sMasterHidString;
+ private Integer IListBoxPosX;
+
+ public FieldLinker(WizardDialog _CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int _firsthelpid)
+ {
+ super(_CurUnoDialog, iStep, iCompPosX, iCompPosY, iCompWidth, _firsthelpid);
+ }
+
+ protected void insertControlGroup(int i)
+ {
+ try
+ {
+ if (i == 0)
+ {
+ lblSlaveFields = new XFixedText[rowcount];
+ lblMasterFields = new XFixedText[rowcount];
+ lstSlaveFields = new XListBox[rowcount];
+ lstMasterFields = new XListBox[rowcount];
+ SOFIRSTLINKLST = 0;
+ SOSECLINKLST = 1;
+ SOTHIRDLINKLST = 2;
+ SOFOURTHLINKLST = 3;
+ IListBoxPosX = new Integer(iCompPosX + 6);
+ sSlaveListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 20, 4); //new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40);
+ sMasterListHeader = CurUnoDialog.m_oResource.getResArray(UIConsts.RID_FORM + 24, 4);// new String[rowcount];""; //CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40);
+ SOLINKLST = new int[]
+ {
+ SOFIRSTLINKLST, SOSECLINKLST, SOTHIRDLINKLST, SOFOURTHLINKLST
+ };
+ }
+ sSlaveHidString = HelpIds.getHelpIdString(FirstHelpIndex + (i * 2));
+ sMasterHidString = HelpIds.getHelpIdString(FirstHelpIndex + (i * 2) + 1);
+ boolean bDoEnable = (i < 2);
+ lblSlaveFields[i] = CurUnoDialog.insertLabel("lblSlaveFieldLink" + new Integer(i + 1).toString(),
+ new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Boolean(bDoEnable), new Integer(8), sSlaveListHeader[i], new Integer(97), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97)
+ });
+ lstSlaveFields[i] = CurUnoDialog.insertListBox("lstSlaveFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Dropdown",
+ "Enabled",
+ "Height",
+ "HelpURL",
+ "LineCount",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE,
+ new Boolean(bDoEnable),
+ UIConsts.INTEGER_12,
+ sSlaveHidString,
+ Short.valueOf(UnoDialog.getListBoxLineCount()),
+ new Integer(97),
+ new Integer(iCurPosY + 10),
+ IStep,
+ new Short(curtabindex++),
+ new Integer(97)
+ });
+
+ lblMasterFields[i] = CurUnoDialog.insertLabel("lblMasterFieldLink" + new Integer(i + 1).toString(),
+ new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Boolean(bDoEnable), new Integer(8), sMasterListHeader[i], new Integer(206), new Integer(iCurPosY), IStep, new Short(curtabindex++), new Integer(97)
+ });
+
+ lstMasterFields[i] = CurUnoDialog.insertListBox("lstMasterFieldLink" + new Integer(i + 1).toString(), SOLINKLST[i], null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Dropdown",
+ "Enabled",
+ "Height",
+ "HelpURL",
+ "LineCount",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE,
+ new Boolean(bDoEnable),
+ UIConsts.INTEGER_12,
+ sMasterHidString,
+ Short.valueOf(UnoDialog.getListBoxLineCount()),
+ new Integer(206),
+ new Integer(iCurPosY + 10),
+ IStep,
+ new Short(curtabindex++),
+ new Integer(97)
+ });
+ iCurPosY = iCurPosY + 38;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ protected void enableNextControlRow(int curindex)
+ {
+ // setMaxSelIndex();
+ boolean bSlaveField = lstSlaveFields[curindex].getSelectedItemPos() > 0;
+ boolean bMasterField = lstMasterFields[curindex].getSelectedItemPos() > 0;
+ boolean bDoEnable = (bSlaveField && bMasterField);
+ if (!bDoEnable)
+ {
+ moveupSelectedItems(curindex, bDoEnable);
+ }
+ else
+ {
+ toggleControlRow(curindex + 1, true);
+ }
+ }
+
+ protected int getMaxSelIndex()
+ {
+ int MaxSelIndex = -1;
+ for (int i = 0; i < rowcount; i++)
+ {
+ if ((lstSlaveFields[i].getSelectedItemPos() > 0) && (lstMasterFields[i].getSelectedItemPos() > 0))
+ {
+ MaxSelIndex += 1;
+ }
+ }
+ return MaxSelIndex;
+ }
+
+ protected void toggleControlRow(int i, boolean bDoEnable)
+ {
+ if (i < rowcount)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblSlaveFields[i]), "Enabled", new Boolean(bDoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), "Enabled", new Boolean(bDoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblMasterFields[i]), "Enabled", new Boolean(bDoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), "Enabled", new Boolean(bDoEnable));
+ if (bDoEnable == false)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[i]), "SelectedItems", new short[] { 0 });
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[i]), "SelectedItems", new short[] { 0 });
+ }
+ }
+ }
+
+ protected void updateFromNextControlRow(int curindex)
+ {
+ short iNextMasterItemPos = lstMasterFields[curindex + 1].getSelectedItemPos();
+ short iNextSlaveItemPos = lstSlaveFields[curindex + 1].getSelectedItemPos();
+
+ if ((iNextMasterItemPos != 0) && (iNextSlaveItemPos != 0))
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex]), "SelectedItems", new short[] {iNextMasterItemPos });
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex]), "SelectedItems", new short[] {iNextSlaveItemPos});
+
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstMasterFields[curindex + 1]), "SelectedItems", new short[] { 0 });
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSlaveFields[curindex + 1]), "SelectedItems", new short[] { 0 });
+ toggleControlRow(curindex, true);
+ }
+ }
+
+ public void initialize(String[] _AllMasterFieldNames, String[] _AllSlaveFieldNames, String[][] _LinkFieldNames)
+ {
+ // short[] MasterSelList = null;
+ // short[] SlaveSelList = null;
+ String[] MasterLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOMASTERINDEX);
+ String[] SlaveLinkNames = JavaTools.ArrayOutOfMultiDimArray(_LinkFieldNames, SOSLAVEINDEX);
+ String[] ViewMasterFieldNames = addNoneFieldItemToList(_AllMasterFieldNames); // add '-undefiened-'
+ String[] ViewSlaveFieldNames = addNoneFieldItemToList(_AllSlaveFieldNames);
+ for (int i = 0; i < super.rowcount; i++)
+ {
+ super.initializeListBox(lstMasterFields[i], ViewMasterFieldNames, MasterLinkNames, i);
+ super.initializeListBox(lstSlaveFields[i], ViewSlaveFieldNames, SlaveLinkNames, i);
+ if (_LinkFieldNames != null)
+ {
+ toggleControlRow(i, (i <= _LinkFieldNames.length));
+ }
+ else
+ {
+ toggleControlRow(i, i == 0);
+ }
+ }
+ }
+
+ public String[][] getLinkFieldNames(RelationController _oRelationController, String _sReferencedTableName)
+ {
+ return _oRelationController.getImportedKeyColumns(_sReferencedTableName);
+ }
+
+ /**
+ * @return the LinkFieldnames of the joins. When no LinkFieldNames were selected the returned Array is empty.
+ * When Joins were assigned duplicate a null value is returned
+ *
+ */
+ public String[][] getLinkFieldNames()
+ {
+ // setMaxSelIndex();
+ int nSelectedIndex = getMaxSelIndex();
+ String[][] LinkFieldNames = new String[2][nSelectedIndex + 1];
+ for (int i = 0; i <= nSelectedIndex; i++)
+ {
+ LinkFieldNames[0][i] = lstSlaveFields[i].getSelectedItem();
+ LinkFieldNames[1][i] = lstMasterFields[i].getSelectedItem();
+ }
+ int iduplicate = JavaTools.getDuplicateFieldIndex(LinkFieldNames);
+ if (iduplicate != -1)
+ {
+ String sLinkFieldsAreDuplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 19);
+ String sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLinkFieldsAreDuplicate, LinkFieldNames[0][iduplicate], "<FIELDNAME1>");
+ sLocLinkFieldsAreDuplicate = JavaTools.replaceSubString(sLocLinkFieldsAreDuplicate, LinkFieldNames[1][iduplicate], "<FIELDNAME2>");
+ CurUnoDialog.setCurrentStep(FormWizard.SOFIELDLINKER_PAGE);
+ CurUnoDialog.enableNavigationButtons(true, true, true);
+ CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocLinkFieldsAreDuplicate);
+ CurUnoDialog.setFocus("lstSlaveFieldLink" + (iduplicate + 1));
+ return null;
+ }
+ return LinkFieldNames;
+
+ }
+
+ public void enable(boolean _bdoenable)
+ {
+ CurUnoDialog.setStepEnabled(IStep.intValue(), _bdoenable);
+ }
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(ItemEvent EventObject)
+ {
+ int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
+ enableNextControlRow(ikey);
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/Finalizer.java b/wizards/com/sun/star/wizards/form/Finalizer.java
new file mode 100644
index 000000000000..d8ce6262731a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/Finalizer.java
@@ -0,0 +1,139 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.ui.*;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class Finalizer
+{
+
+ WizardDialog CurUnoDialog;
+ short curtabindex;
+ XRadioButton optModifyForm;
+ XRadioButton optWorkWithForm;
+ XTextComponent txtFormName;
+ FormDocument oFormDocument;
+
+ public Finalizer(WizardDialog _CurUnoDialog)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (FormWizard.SOSTORE_PAGE * 100);
+
+ String slblFormName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 50);
+ String slblProceed = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 51);
+ String sWorkWithForm = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 52);
+ String sModifyForm = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 53);
+ CurUnoDialog.insertLabel("lblFormName",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], slblFormName, new Integer(97), new Integer(25), UIConsts.INTEGERS[8], new Short(curtabindex++), new Integer(111)
+ });
+ txtFormName = CurUnoDialog.insertTextField("txtFormName", "toggleFinishButton", this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGFORM_TXTPATH", new Integer(97), new Integer(35), UIConsts.INTEGERS[8], new Short((short) 82), "", new Integer(185)
+ });
+ CurUnoDialog.insertLabel("lblProceed",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], slblProceed, new Integer(97), new Integer(62), UIConsts.INTEGERS[8], new Short(curtabindex++), new Integer(185)
+ });
+ CurUnoDialog.insertRadioButton("optWorkWithForm", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTWORKWITHFORM", sWorkWithForm, new Integer(101), new Integer(77), new Short((short) 1), UIConsts.INTEGERS[8], new Short(curtabindex++), new Integer(107)
+ });
+ optModifyForm = CurUnoDialog.insertRadioButton("optModifyForm", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTMODIFYFORM", sModifyForm, new Integer(101), new Integer(89), UIConsts.INTEGERS[8], new Short(curtabindex++), new Integer(107)
+ });
+ }
+
+ public void initialize(String _formname, FormDocument _oFormDocument)
+ {
+ if (oFormDocument == null)
+ {
+ oFormDocument = _oFormDocument;
+ }
+ if (txtFormName.getText().length() == 0)
+ {
+ txtFormName.setText(Desktop.getUniqueName(_oFormDocument.oMainFormDBMetaData.getFormDocuments(), _formname));
+ }
+ }
+
+ public void toggleFinishButton()
+ {
+ CurUnoDialog.enableFinishButton(txtFormName.getText().length() > 0);
+ }
+
+ public String getName()
+ {
+ return txtFormName.getText();
+ }
+
+ public boolean getOpenForEditing()
+ {
+ return optModifyForm.getState() ? true : false;
+ }
+
+ public boolean finish()
+ {
+// if (!oFormDocument.oMainFormDBMetaData.hasFormDocumentByName(sFormName)){
+ return oFormDocument.oMainFormDBMetaData.storeDatabaseDocumentToTempPath(this.oFormDocument.xComponent, getName());
+// }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/FormConfiguration.java b/wizards/com/sun/star/wizards/form/FormConfiguration.java
new file mode 100644
index 000000000000..d1f1afdfac54
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/FormConfiguration.java
@@ -0,0 +1,241 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.ui.CommandFieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.WizardDialog;
+import com.sun.star.wizards.db.RelationController;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class FormConfiguration
+{
+
+ WizardDialog CurUnoDialog;
+ short curtabindex;
+ XRadioButton optOnExistingRelation;
+ XCheckBox chkcreateSubForm;
+ XRadioButton optSelectManually;
+ XFixedText lblSubFormDescription;
+ XFixedText lblRelations;
+ XListBox lstRelations;
+ String[] sreferencedTables;
+ // Integer ISubFormStep;
+ CommandFieldSelection CurSubFormFieldSelection;
+ String SSUBFORMMODE = "toggleSubFormMode";
+ String STOGGLESTEPS = "toggleSteps";
+ String SONEXISTINGRELATIONSELECTION = "onexistingRelationSelection";
+ boolean bsupportsRelations;
+ RelationController oRelationController = null;
+
+ public FormConfiguration(WizardDialog _CurUnoDialog)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (FormWizard.SOSUBFORM_PAGE * 100);
+ Integer ISubFormStep = new Integer(FormWizard.SOSUBFORM_PAGE);
+ String sOnExistingRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 5);
+ String sOnManualRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 7);
+ String sSelectManually = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 4);
+ String sSelectRelation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 8);
+ String sSubFormDescription = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 3);
+
+ // CheckBox 'Add sub form'
+ chkcreateSubForm = CurUnoDialog.insertCheckBox("chkcreateSubForm", SSUBFORMMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_CHKCREATESUBFORM", sSelectManually, new Integer(97), new Integer(26), ISubFormStep, new Short(curtabindex++), new Integer(160)
+ });
+ optOnExistingRelation = CurUnoDialog.insertRadioButton("optOnExistingRelation", STOGGLESTEPS, this,
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTONEXISTINGRELATION", sOnExistingRelation, new Integer(107), new Integer(43), ISubFormStep, new Short(curtabindex++), new Integer(160)
+ });
+ optSelectManually = CurUnoDialog.insertRadioButton("optSelectManually", STOGGLESTEPS, this,
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGFORM_OPTSELECTMANUALLY", sOnManualRelation, new Integer(107), new Integer(99), new Short((short) 1), ISubFormStep, new Short(curtabindex++), new Integer(160)
+ });
+ lblRelations = CurUnoDialog.insertLabel("lblSelectRelation",
+ new String[]
+ {
+ "Enabled", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(19), sSelectRelation, Boolean.TRUE, new Integer(119), new Integer(56), ISubFormStep, new Short(curtabindex++), new Integer(80)
+ });
+ lstRelations = CurUnoDialog.insertListBox("lstrelations", SONEXISTINGRELATIONSELECTION, SONEXISTINGRELATIONSELECTION, this,
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(37), "HID:WIZARDS_HID_DLGFORM_lstRELATIONS", new Integer(201), new Integer(55), ISubFormStep, new Short(curtabindex++), new Integer(103)
+ });
+ lblSubFormDescription = CurUnoDialog.insertLabel("lblSubFormDescription",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(59), sSubFormDescription, Boolean.TRUE, new Integer(110), new Integer(120), ISubFormStep, new Short(curtabindex++), new Integer(190)
+ });
+ CurUnoDialog.insertInfoImage(97, 120, ISubFormStep.intValue());
+ }
+
+ // public void disableSubFormCheckBox()
+ // {
+ // Helper.setUnoPropertyValue(UnoDialog.getModel(chkcreateSubForm), "Enabled", Boolean.FALSE);
+ // }
+
+ public RelationController getRelationController()
+ {
+ return oRelationController;
+ }
+
+ public boolean areexistingRelationsdefined()
+ {
+ return ((chkcreateSubForm.getState() == 1) && (optOnExistingRelation.getState()));
+ }
+
+ public void toggleSubFormMode()
+ {
+ boolean bdoEnable = (this.chkcreateSubForm.getState() == 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), "Enabled", new Boolean(bdoEnable && bsupportsRelations));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optSelectManually), "Enabled", new Boolean(bdoEnable));
+ toggleSteps();
+ }
+
+ public void initialize(CommandFieldSelection _CurSubFormFieldSelection, RelationController _oRelationController)
+ {
+ oRelationController = _oRelationController;
+ sreferencedTables = oRelationController.getExportedKeys();
+ bsupportsRelations = (sreferencedTables.length > 0);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), "StringItemList", sreferencedTables);
+ this.CurSubFormFieldSelection = _CurSubFormFieldSelection;
+ toggleRelationsListbox();
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optOnExistingRelation), "Enabled", new Boolean(bsupportsRelations && (chkcreateSubForm.getState() == 1)));
+ }
+
+ public void toggleSteps()
+ {
+ boolean bDoEnableFollowingSteps;
+ if (chkcreateSubForm.getState() == 1)
+ {
+ if (optOnExistingRelation.getState())
+ {
+ onexistingRelationSelection();
+ }
+ else if (optSelectManually.getState())
+ {
+ CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, (CurSubFormFieldSelection.getSelectedFieldNames().length > 0));
+ CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true);
+ }
+ }
+ else
+ {
+ CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, false);
+ CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false);
+ CurUnoDialog.enablefromStep(FormWizard.SOCONTROL_PAGE, true);
+ }
+ toggleRelationsListbox();
+ }
+
+ public String getreferencedTableName()
+ {
+ if (areexistingRelationsdefined())
+ {
+ short[] iselected = (short[]) Helper.getUnoArrayPropertyValue(UnoDialog.getModel(lstRelations), "SelectedItems");
+ if (iselected != null)
+ {
+ if (iselected.length > 0)
+ {
+ return sreferencedTables[iselected[0]];
+ }
+ }
+ }
+ return "";
+ }
+
+ public void onexistingRelationSelection()
+ {
+ String scurreferencedTableName = getreferencedTableName();
+ if (scurreferencedTableName.length() > 0)
+ {
+ if (CurSubFormFieldSelection.getSelectedCommandName().equals(scurreferencedTableName))
+ {
+ CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, true);
+ CurUnoDialog.setStepEnabled(FormWizard.SOFIELDLINKER_PAGE, false);
+ return;
+ }
+ else
+ {
+ CurUnoDialog.setStepEnabled(FormWizard.SOSUBFORMFIELDS_PAGE, true);
+ CurUnoDialog.enablefromStep(FormWizard.SOFIELDLINKER_PAGE, false);
+ return;
+ }
+ }
+ CurUnoDialog.enablefromStep(FormWizard.SOSUBFORMFIELDS_PAGE, false);
+ }
+
+ private void toggleRelationsListbox()
+ {
+ boolean bdoenable = bsupportsRelations && this.optOnExistingRelation.getState() && (chkcreateSubForm.getState() == 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblRelations), "Enabled", new Boolean(bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstRelations), "Enabled", new Boolean(bdoenable));
+ }
+
+ public boolean hasSubForm()
+ {
+ return (this.chkcreateSubForm.getState() == 1);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/FormControlArranger.java b/wizards/com/sun/star/wizards/form/FormControlArranger.java
new file mode 100644
index 000000000000..9a0c58fd41b8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/FormControlArranger.java
@@ -0,0 +1,731 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.task.XStatusIndicator;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.db.*;
+import com.sun.star.wizards.document.Control;
+import com.sun.star.wizards.document.DatabaseControl;
+import com.sun.star.wizards.document.FormHandler;
+import com.sun.star.wizards.document.Shape;
+import com.sun.star.wizards.document.TimeStampControl;
+
+public class FormControlArranger
+{
+
+ protected DatabaseControl[] DBControlList = null;
+
+ private XNameContainer xFormName;
+ private XMultiServiceFactory xMSF;
+ private Control[] LabelControlList = null;
+ private XStatusIndicator xProgressBar;
+ private FieldColumn[] FieldColumns;
+ private DatabaseControl curDBControl;
+ // Control curLabelControl;
+ private int icurArrangement;
+ private boolean bIsFirstRun;
+ private boolean bIsVeryFirstRun;
+ private boolean bControlsareCreated;
+ private int cXOffset;
+ private int cYOffset;
+ private static final int cVertDistance = 200;
+ private static final int cHoriDistance = 300;
+ private static final int cLabelGap = 100;
+ private static final double CMAXREDUCTION = 0.7;
+ private FormHandler oFormHandler;
+ private int iReduceWidth;
+ private int nXTCPos;
+ private int nYTCPos;
+ private int nXDBPos;
+ private int nYDBPos;
+ private int nTCHeight;
+ private int nTCWidth;
+ private int nDBHeight;
+ private int nDBWidth;
+ private int nMaxTCWidth;
+ private int nFormWidth;
+ private int nFormHeight;
+ private int nMaxRowY;
+ private int nSecMaxRowY;
+ private int nMaxColRightX;
+ private int a;
+ private int StartA;
+ private int nMaxDBYPos = 0; //the maximum YPosition of a DBControl in the form
+ private Short NBorderType = new Short((short) 1); //3-D Border
+
+ public FormControlArranger(FormHandler _oFormHandler, XNameContainer _xFormName, CommandMetaData oDBMetaData, XStatusIndicator _xProgressBar, Point _StartPoint, Size _FormSize)
+ {
+ FieldColumns = oDBMetaData.FieldColumns;
+ xMSF = oDBMetaData.xMSF;
+ xFormName = _xFormName;
+ xProgressBar = _xProgressBar;
+ LabelControlList = new Control[FieldColumns.length];
+ DBControlList = new DatabaseControl[FieldColumns.length];
+ oFormHandler = _oFormHandler;
+ cXOffset = _StartPoint.X;
+ cYOffset = _StartPoint.Y;
+ setFormSize(_FormSize);
+ }
+ // Note: on all Controls except for the checkbox the Label has to be set
+ // a bit under the DBControl because its Height is also smaller
+ private int getLabelDiffHeight(int _index)
+ {
+ if (curDBControl != null)
+ {
+ if (curDBControl.getControlType() == FormHandler.SOCHECKBOX)
+ {
+ return getCheckBoxDiffHeight(_index);
+ }
+ }
+ return oFormHandler.getBasicLabelDiffHeight();
+ }
+
+ public void setBorderType(short _nBorderType)
+ {
+ NBorderType = new Short(_nBorderType);
+ }
+
+ public Control[] getLabelControlList()
+ {
+ return LabelControlList;
+ }
+
+ private int getCheckBoxDiffHeight(int LastIndex)
+ {
+ if ((LastIndex < DBControlList.length))
+ {
+ if (DBControlList[LastIndex].getControlType() == FormHandler.SOCHECKBOX)
+ {
+ return (int) ((oFormHandler.getControlReferenceHeight() - DBControlList[LastIndex].getControlHeight()) / 2);
+ }
+ }
+ return 0;
+ }
+
+ private boolean isReducable(int _index)
+ {
+ boolean bisreducable = false;
+ int ntype = this.FieldColumns[_index].getFieldType();
+ switch (ntype)
+ {
+ case DataType.TINYINT:
+ case DataType.SMALLINT:
+ case DataType.INTEGER:
+ case DataType.FLOAT:
+ case DataType.DATE:
+ case DataType.TIME:
+ case DataType.TIMESTAMP:
+ case DataType.REAL:
+ case DataType.DOUBLE:
+ case DataType.NUMERIC:
+ case DataType.DECIMAL:
+ case DataType.BIT:
+ case DataType.BOOLEAN:
+ bisreducable = false;
+ break;
+ case DataType.VARCHAR:
+ short nTextLen;
+ try
+ {
+ nTextLen = AnyConverter.toShort(DBControlList[_index].xPropertySet.getPropertyValue("MaxTextLen"));
+ if ((nTextLen == 0) || (nTextLen > 20))
+ {
+ bisreducable = true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ break;
+ case DataType.BIGINT:
+ bisreducable = true;
+ break;
+ default:
+ bisreducable = true;
+ }
+ if (nTCWidth > 0.9 * CMAXREDUCTION * nDBWidth)
+ {
+ bisreducable = false;
+ }
+ return bisreducable;
+ }
+
+ private int getControlGroupWidth()
+ {
+ if (nDBWidth > nTCWidth)
+ {
+ return nDBWidth;
+ }
+ else
+ {
+ return nTCWidth;
+ }
+ }
+
+ private void checkJustifiedPosition(int a)
+ {
+ int nBaseWidth = nFormWidth + cXOffset;
+ int nLeftDist = nMaxColRightX - nBaseWidth;
+ int nRightDist = nBaseWidth - (DBControlList[a].getPosition().X - this.cHoriDistance);
+ if (nLeftDist < 0.5 * nRightDist)
+ {
+ // Fieldwidths in the line can be made smaller..
+ adjustLineWidth(StartA, a, nLeftDist, -1);
+ nYTCPos = nMaxRowY + cVertDistance;
+ nYDBPos = nYTCPos + nTCHeight;
+// if ((nYDBPos + nDBHeight) > nMaxDBYPos)
+// nMaxDBYPos = nYDBPos + nDBHeight;
+ nXTCPos = cXOffset;
+ nXDBPos = cXOffset;
+ bIsFirstRun = true;
+ StartA = a + 1;
+ }
+ else
+ {
+ // FieldWidths in the line can be made wider...
+ if (nYDBPos + nDBHeight == nMaxRowY)
+ {
+ // The last Control was the highest in the row
+ nYTCPos = nSecMaxRowY + cVertDistance;
+ }
+ else
+ {
+ nYTCPos = nMaxRowY + cVertDistance;
+ }
+ nYDBPos = nYTCPos + nTCHeight;
+ nXDBPos = cXOffset;
+ nXTCPos = cXOffset;
+ this.LabelControlList[a].setPosition(new Point(cXOffset, nYTCPos));
+ this.DBControlList[a].setPosition(new Point(cXOffset, nYDBPos));
+ bIsFirstRun = true;
+ if (nDBWidth > nTCWidth)
+ {
+ checkOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, true);
+ }
+ else
+ {
+ checkOuterPoints(nXDBPos, nTCWidth, nYDBPos, nDBHeight, true);
+ }
+ nXTCPos = nMaxColRightX + cHoriDistance;
+ nXDBPos = nXTCPos;
+ adjustLineWidth(StartA, a - 1, nRightDist, 1);
+ StartA = a;
+ }
+ }
+
+ private int getCorrWidth(int StartIndex, int EndIndex, int nDist, int Widthfactor)
+ {
+ int ShapeCount;
+ if (Widthfactor > 0)
+ {
+ // shapes are made wide
+ ShapeCount = EndIndex - StartIndex + 1;
+ }
+ else
+ {
+ // shapes are made more narrow
+ ShapeCount = iReduceWidth;
+ }
+ return (nDist) / ShapeCount;
+ }
+
+ /**
+ *
+ * @param StartIndex
+ * @param EndIndex
+ * @param nDist
+ * @param WidthFactor is either '+1' or '-1' and determines whether the control shapes widths are to be made smaller or larger
+ */
+ private void adjustLineWidth(int StartIndex, int EndIndex, int nDist, int WidthFactor)
+ {
+ int CorrWidth = getCorrWidth(StartIndex, EndIndex, nDist, WidthFactor);
+ int iLocTCPosX = cXOffset;
+ for (int i = StartIndex; i <= EndIndex; i++)
+ {
+ int nControlBaseWidth = 0;
+ curDBControl = this.DBControlList[i];
+ Control curLabelControl = this.LabelControlList[i];
+ if (i != StartIndex)
+ {
+ curLabelControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y));
+ curDBControl.setPosition(new Point(iLocTCPosX, curLabelControl.getPosition().Y + nTCHeight));
+ }
+ if (((curLabelControl.getSize().Width > curDBControl.getSize().Width)) && (WidthFactor > 0))
+ {
+ nControlBaseWidth = curLabelControl.getSize().Width;
+ }
+ else
+ {
+ nControlBaseWidth = curDBControl.getSize().Width;
+ }
+ if (FieldColumns[i].getFieldType() == DataType.TIMESTAMP)
+ {
+ TimeStampControl oDBTimeStampControl = (TimeStampControl) curDBControl;
+ nControlBaseWidth = oDBTimeStampControl.getSize().Width;
+ if (this.isReducable(i) || WidthFactor > 0)
+ {
+ oDBTimeStampControl.setSize(new Size(nControlBaseWidth + WidthFactor * CorrWidth, oDBTimeStampControl.getSize().Height));
+ }
+ }
+ else
+ {
+ if (this.isReducable(i) || WidthFactor > 0)
+ {
+ curDBControl.setSize(new Size(nControlBaseWidth + WidthFactor * CorrWidth, curDBControl.getSize().Height));
+ }
+ }
+ iLocTCPosX = curDBControl.getPosition().X + curDBControl.getSize().Width + cHoriDistance;
+ if (curLabelControl.getSize().Width > curDBControl.getSize().Width)
+ {
+ iLocTCPosX = curLabelControl.getPosition().X + curLabelControl.getSize().Width + cHoriDistance;
+ }
+ }
+ if (WidthFactor > 0)
+ {
+ iReduceWidth = 1;
+ }
+ else
+ {
+ iReduceWidth = 0;
+ }
+ }
+
+ private void checkOuterPoints(int nXPos, int nWidth, int nYPos, int nHeight, boolean bIsDBField)
+ {
+ int nColRightX;
+ if (icurArrangement == FormWizard.SOTOPJUSTIFIED)
+ {
+ if (bIsDBField)
+ {
+ // Only at DBControls you can measure the Value of nMaxRowY
+ if (bIsFirstRun)
+ {
+ nMaxRowY = nYPos + nHeight;
+ nSecMaxRowY = nMaxRowY;
+ }
+ else
+ {
+ int nRowY = nYPos + nHeight;
+ if (nRowY >= nMaxRowY)
+ {
+ int nOldMaxRowY = nMaxRowY;
+ nSecMaxRowY = nOldMaxRowY;
+ nMaxRowY = nRowY;
+ }
+ }
+ }
+ }
+ // Find the outer right point
+ if (bIsFirstRun)
+ {
+ nMaxColRightX = nXPos + nWidth;
+ bIsFirstRun = false;
+ }
+ else
+ {
+ nColRightX = nXPos + nWidth;
+ if (nColRightX > nMaxColRightX)
+ {
+ nMaxColRightX = nColRightX;
+ }
+ }
+ }
+
+ public void positionControls(int _icurArrangement, Point _aStartPoint, Size _aFormSize, short _iAlign, Short _NBorderType)
+ {
+ try
+ {
+ this.NBorderType = _NBorderType;
+ this.setStartPoint(_aStartPoint);
+ icurArrangement = _icurArrangement;
+ initializePosSizes();
+ initializeControlColumn(-1);
+ bIsVeryFirstRun = true;
+ nMaxRowY = 0;
+ nSecMaxRowY = 0;
+ this.nMaxColRightX = 0;
+ xProgressBar.start("", FieldColumns.length);
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ try
+ {
+ insertLabel(i, _iAlign);
+ insertDBControl(i);
+ bIsVeryFirstRun = false;
+ DBControlList[i].setPropertyValue("LabelControl", LabelControlList[i].xPropertySet);
+ resetPosSizes(i);
+ xProgressBar.setValue(i + 1);
+ }
+ catch (RuntimeException e)
+ {
+ int dummy = 0;
+ }
+ }
+ xProgressBar.end();
+ bControlsareCreated = true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public boolean areControlsexisting()
+ {
+ if (DBControlList != null)
+ {
+ if (DBControlList.length > 0)
+ {
+ return (DBControlList[0] != null);
+ }
+ }
+ return false;
+ }
+
+ private void initializeControlColumn(int LastIndex)
+ {
+ bIsFirstRun = true;
+ StartA = LastIndex + 1;
+ a = 0;
+ }
+
+ private void resetPosSizes(int LastIndex)
+ {
+ int nYRefPos = nYDBPos;
+ switch (icurArrangement)
+ {
+ case FormWizard.SOCOLUMNARLEFT:
+ nYDBPos = nYDBPos + nDBHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex);
+ nYRefPos = nYDBPos;
+ if ((nYDBPos > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1)))
+ {
+ repositionColumnarLeftControls(LastIndex);
+ nXTCPos = nMaxColRightX + 2 * cHoriDistance;
+ nXDBPos = nXTCPos + this.cLabelGap + nMaxTCWidth;
+ nYDBPos = cYOffset;
+ nYRefPos = nYDBPos;
+ initializeControlColumn(LastIndex);
+ }
+ else
+ {
+ /*a = a + 1;*/
+ /* a += 1;*/
+ ++a;
+ }
+ nYTCPos = nYDBPos + this.getLabelDiffHeight(LastIndex);
+ if ((nYRefPos + nDBHeight) > nMaxDBYPos)
+ {
+ nMaxDBYPos = nYRefPos + nDBHeight;
+ }
+
+ break;
+ case FormWizard.SOCOLUMNARTOP:
+ nYTCPos = nYDBPos + nDBHeight + cVertDistance + getCheckBoxDiffHeight(LastIndex);
+ ;
+ if ((nYTCPos > cYOffset + nFormHeight) || (LastIndex == (FieldColumns.length - 1)))
+ {
+ nXDBPos = nMaxColRightX + cHoriDistance;
+ nXTCPos = nXDBPos;
+ nYRefPos = nYDBPos;
+ nYDBPos = cYOffset + nTCHeight + cVertDistance;
+ nYTCPos = cYOffset;
+ initializeControlColumn(LastIndex);
+ }
+ else
+ {
+ a = a + 1;
+ }
+ if ((nYRefPos + nDBHeight + cVertDistance) > nMaxDBYPos)
+ {
+ nMaxDBYPos = nYRefPos + nDBHeight + cVertDistance;
+ }
+ break;
+
+ case FormWizard.SOTOPJUSTIFIED:
+ if (this.isReducable(a))
+ {
+ iReduceWidth = iReduceWidth + 1;
+ }
+ if (nMaxColRightX > cXOffset + nFormWidth)
+ {
+ int nOldYTCPos = nYTCPos;
+ checkJustifiedPosition(a);
+ nYRefPos = nYDBPos;
+ }
+ else
+ {
+ nXTCPos = nMaxColRightX + cHoriDistance;
+ }
+ a = a + 1;
+ if ((nYRefPos + nDBHeight) > nMaxDBYPos)
+ {
+ nMaxDBYPos = nYRefPos + nDBHeight;
+ }
+ break;
+ }
+// if ((nYRefPos + nDBHeight) > nMaxDBYPos)
+// nMaxDBYPos = nYRefPos + nDBHeight;
+ }
+
+ private void repositionColumnarLeftControls(int LastIndex)
+ {
+ bIsFirstRun = true;
+ for (int i = StartA; i <= LastIndex; i++)
+ {
+ if (i == StartA)
+ {
+ nXTCPos = LabelControlList[i].getPosition().X;
+ nXDBPos = nXTCPos + nMaxTCWidth + cHoriDistance;
+ }
+ LabelControlList[i].setSize(new Size(nMaxTCWidth, nTCHeight));
+ resetDBShape(DBControlList[i], nXDBPos);
+ checkOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, true);
+ }
+ }
+
+ private void resetDBShape(Shape _curDBControl, int iXPos)
+ {
+ int nYDBPos = _curDBControl.getPosition().Y;
+ nDBWidth = _curDBControl.getSize().Width;
+ nDBHeight = _curDBControl.getSize().Height;
+ _curDBControl.setPosition(new Point(iXPos, nYDBPos));
+ }
+
+ private void initializePosSizes()
+ {
+ this.nMaxDBYPos = 0;
+ nXTCPos = cXOffset;
+ nTCWidth = 2000;
+ nDBWidth = 2000;
+ nDBHeight = oFormHandler.getControlReferenceHeight();
+ nTCHeight = oFormHandler.getLabelHeight();
+ iReduceWidth = 0;
+ if (icurArrangement == FormWizard.SOCOLUMNARLEFT)
+ {
+ nYTCPos = cYOffset + this.getLabelDiffHeight(0);
+ nXDBPos = cXOffset + 3050;
+ nYDBPos = cYOffset;
+ }
+ else
+ {
+ nXDBPos = cXOffset;
+ nYTCPos = cYOffset;
+ }
+ }
+
+ private void insertLabel(int i, int _iAlign)
+ {
+ try
+ {
+ if (bControlsareCreated)
+ {
+ LabelControlList[i].setPosition(new Point(nXTCPos, nYTCPos));
+ if (icurArrangement != FormWizard.SOCOLUMNARLEFT)
+ {
+ nTCWidth = LabelControlList[i].getPreferredWidth(FieldColumns[i].getFieldTitle());
+ LabelControlList[i].setSize(new Size(nTCWidth, nTCHeight));
+ }
+ else
+ {
+ nTCWidth = LabelControlList[i].getSize().Width;
+ }
+ }
+ else
+ {
+ Point aPoint = new Point(nXTCPos, nYTCPos);
+ Size aSize = new Size(nTCWidth, nTCHeight);
+ final String sFieldName = FieldColumns[i].getFieldName();
+ this.LabelControlList[i] = new Control(oFormHandler, xFormName, FormHandler.SOLABEL, sFieldName, aPoint, aSize);
+ if (bIsVeryFirstRun)
+ {
+ if (icurArrangement == FormWizard.SOCOLUMNARTOP)
+ {
+ nYDBPos = nYTCPos + nTCHeight;
+ }
+ }
+ String sTitle = FieldColumns[i].getFieldTitle();
+ nTCWidth = LabelControlList[i].getPreferredWidth(sTitle);
+ }
+ Control curLabelControl = LabelControlList[i];
+ if (icurArrangement == FormWizard.SOCOLUMNARLEFT)
+ {
+ // Note This If Sequence must be called before retrieving the outer Points
+ if (bIsFirstRun)
+ {
+ nMaxTCWidth = nTCWidth;
+ bIsFirstRun = false;
+ }
+ else if (nTCWidth > nMaxTCWidth)
+ {
+ nMaxTCWidth = nTCWidth;
+ }
+ }
+ checkOuterPoints(nXTCPos, nTCWidth, nYTCPos, nTCHeight, false);
+ if ((icurArrangement == FormWizard.SOCOLUMNARTOP) || (icurArrangement == FormWizard.SOTOPJUSTIFIED))
+ {
+ nXDBPos = nXTCPos;
+ nYDBPos = nYTCPos + nTCHeight;
+ curLabelControl.xPropertySet.setPropertyValue("Align", new Short((short) com.sun.star.awt.TextAlign.LEFT));
+ }
+ else
+ {
+ curLabelControl.xPropertySet.setPropertyValue("Align", new Short((short) _iAlign));
+ }
+ if (!bControlsareCreated)
+ {
+ curLabelControl.setSize(new Size(nTCWidth, nTCHeight));
+ }
+// if (CurHelpText != ""){
+// oModel.HelpText = CurHelptext;
+// }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void insertDBControl(int i)
+ {
+ try
+ {
+ String sFieldName = FieldColumns[i].getFieldName();
+ int nFieldType = FieldColumns[i].getFieldType();
+
+ Point aPoint = new Point(nXDBPos, nYDBPos);
+ if (bControlsareCreated)
+ {
+ DBControlList[i].setPosition(aPoint);
+ }
+ else
+ {
+ if (nFieldType == DataType.TIMESTAMP)
+ {
+ DBControlList[i] = new TimeStampControl(new Resource(xMSF, "FormWizard", "dbw"), oFormHandler, xFormName, sFieldName, aPoint);
+ }
+ else
+ {
+ DBControlList[i] = new DatabaseControl(oFormHandler, xFormName, sFieldName, nFieldType, aPoint);
+ if (DBControlList[i].getControlType() == FormHandler.SOCHECKBOX)
+ {
+ // Checkboxes have no Label near by
+ DBControlList[i].setPropertyValue("Label", "");
+ }
+ }
+ }
+ DatabaseControl aDBControl = DBControlList[i];
+ nDBHeight = aDBControl.getControlHeight();
+ nDBWidth = aDBControl.getControlWidth();
+ if (nFieldType != DataType.TIMESTAMP)
+ {
+ aDBControl.setSize(new Size(nDBWidth, nDBHeight));
+ }
+ if (aDBControl.getControlType() == FormHandler.SOCHECKBOX)
+ {
+ nYDBPos = nYDBPos + /*(int)*/ ((oFormHandler.getControlReferenceHeight() - nDBHeight) / 2);
+ aPoint = new Point(nXDBPos, nYDBPos);
+ aDBControl.setPosition(aPoint);
+ }
+ if (nFieldType == DataType.LONGVARCHAR) /* memo */
+ {
+ Helper.setUnoPropertyValue(LabelControlList[i], "MultiLine", Boolean.TRUE);
+ }
+ checkOuterPoints(nXDBPos, nDBWidth, nYDBPos, nDBHeight, true);
+ aDBControl.setPropertyValue("Border", NBorderType);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private int assignFieldLength(int _fieldlength)
+ {
+ if (_fieldlength >= 65535)
+ {
+ return -1;
+ }
+ else
+ {
+ return _fieldlength;
+ }
+ }
+
+ public int getFormHeight()
+ {
+ return nMaxDBYPos - this.cYOffset;
+ }
+
+ public int getEntryPointY()
+ {
+ if (this.icurArrangement == FormWizard.SOCOLUMNARTOP)
+ {
+ Control curLabelControl2 = LabelControlList[0];
+ return curLabelControl2.getPosition().Y;
+ }
+ else
+ {
+ DatabaseControl curDBControl2 = DBControlList[0];
+ return curDBControl2.getPosition().Y;
+ }
+ }
+
+ public void setStartPoint(Point _aPoint)
+ {
+ this.cXOffset = _aPoint.X;
+ this.cYOffset = _aPoint.Y;
+ }
+
+ public void adjustYPositions(int _diffY)
+ {
+ for (int i = 0; i < DBControlList.length; i++)
+ {
+ Point aPoint = DBControlList[i].getPosition();
+ DBControlList[i].setPosition(new Point(aPoint.X, aPoint.Y - _diffY));
+ aPoint = this.LabelControlList[i].getPosition();
+ LabelControlList[i].setPosition(new Point(aPoint.X, aPoint.Y - _diffY));
+ }
+ nMaxDBYPos = -_diffY;
+ cYOffset = -_diffY;
+ }
+
+ public void setFormSize(Size _FormSize)
+ {
+ nFormHeight = _FormSize.Height;
+ nFormWidth = _FormSize.Width;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/FormDocument.java b/wizards/com/sun/star/wizards/form/FormDocument.java
new file mode 100644
index 000000000000..0070fed3ada1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/FormDocument.java
@@ -0,0 +1,596 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import java.util.Vector;
+
+import com.sun.star.wizards.text.TextDocument;
+import com.sun.star.awt.Point;
+import com.sun.star.awt.Size;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.XMultiServiceFactory;
+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.wizards.text.TextStyleHandler;
+import com.sun.star.wizards.text.ViewHandler;
+import com.sun.star.wizards.document.Control;
+import com.sun.star.wizards.document.DatabaseControl;
+import com.sun.star.wizards.document.FormHandler;
+import com.sun.star.wizards.document.GridControl;
+
+public class FormDocument extends TextDocument
+{
+ protected Vector oControlForms = new Vector();
+ protected CommandMetaData oMainFormDBMetaData;
+ protected CommandMetaData oSubFormDBMetaData;
+ protected String[][] LinkFieldNames;
+
+ private FormHandler oFormHandler;
+ private ViewHandler oViewHandler;
+ private TextStyleHandler oTextStyleHandler;
+ private XPropertySet xPropPageStyle;
+ private final int SOFORMGAP = 2000;
+ private boolean bhasSubForm;
+ private UIControlArranger curUIControlArranger;
+ private StyleApplier curStyleApplier;
+ private int nPageWidth;
+ private int nPageHeight;
+ private int nFormWidth;
+ private int nFormHeight;
+ private Point aMainFormPoint;
+ private final static String SOMAINFORM = "MainForm";
+ private final static String SOSUBFORM = "SubForm";
+
+ public FormDocument(XMultiServiceFactory xMSF)
+ {
+ super(xMSF, new TextDocument.ModuleIdentifier("com.sun.star.sdb.FormDesign"), true);
+ try
+ {
+ oFormHandler = new FormHandler(xMSF, xTextDocument);
+ oFormHandler.setDrawObjectsCaptureMode(false);
+ oTextStyleHandler = new TextStyleHandler(xMSFDoc, xTextDocument);
+ oViewHandler = new ViewHandler(xMSFDoc, xTextDocument);
+ oMainFormDBMetaData = new CommandMetaData(xMSF);// , CharLocale);
+ oSubFormDBMetaData = new CommandMetaData(xMSF);// , CharLocale);
+ ViewHandler oViewHandler = new ViewHandler(xMSF, xTextDocument);
+ TextStyleHandler oTextStyleSupplier = new TextStyleHandler(xMSFDoc, xTextDocument);
+ Helper.setUnoPropertyValue(xTextDocument, "ApplyFormDesignMode", Boolean.FALSE);
+ oViewHandler.setViewSetting("ShowTableBoundaries", Boolean.FALSE);
+ oViewHandler.setViewSetting("ShowOnlineLayout", Boolean.TRUE);
+ xPropPageStyle = oTextStyleSupplier.getStyleByName("PageStyles", "Standard");
+ Size aSize = oTextStyleHandler.changePageAlignment(xPropPageStyle, true);
+ nPageWidth = aSize.Width;
+ nPageHeight = aSize.Height;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void addUIFormController(UIControlArranger _curUIControlArranger)
+ {
+ this.curUIControlArranger = _curUIControlArranger;
+ }
+
+ public void addStyleApplier(StyleApplier _curStyleApplier)
+ {
+ this.curStyleApplier = _curStyleApplier;
+ }
+
+ private String getDataSourceName()
+ {
+ return this.oMainFormDBMetaData.DataSourceName;
+ }
+
+ private void adjustPageStyle()
+ {
+ try
+ {
+ int nMargin;
+ int totfieldcount = getMainFieldCount() + getSubFieldCount();
+ if (totfieldcount > 30)
+ {
+ nMargin = 500;
+ }
+ else if (totfieldcount > 20)
+ {
+ nMargin = 750;
+ }
+ else
+ {
+ nMargin = 1000;
+ }
+ xPropPageStyle.setPropertyValue("RightMargin", new Integer(nMargin));
+ xPropPageStyle.setPropertyValue("LeftMargin", new Integer(nMargin));
+ xPropPageStyle.setPropertyValue("TopMargin", new Integer(nMargin));
+ xPropPageStyle.setPropertyValue("BottomMargin", new Integer(nMargin));
+ aMainFormPoint = new Point(nMargin, nMargin);
+ nFormWidth = (int) (0.8 * (double) nPageWidth) - 2 * nMargin;
+ nFormHeight = (int) (0.65 * (double) nPageHeight) - 2 * nMargin;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void initialize(boolean _baddParentForm, boolean _bShouldHaveSubForm, boolean _bModifySubForm, Short _NBorderType)
+ {
+ bhasSubForm = _bShouldHaveSubForm;
+ adjustPageStyle();
+ if (_baddParentForm)
+ {
+ if (oControlForms.size() == 0)
+ {
+ final ControlForm aMainControlForm = new ControlForm(this, SOMAINFORM, aMainFormPoint, getMainFormSize(FormWizard.SOGRID));
+ oControlForms.addElement(aMainControlForm);
+ }
+ else
+ {
+ oFormHandler.removeControlsofForm(SOMAINFORM);
+ ((ControlForm) oControlForms.get(0)).oFormController = null;
+ }
+ ((ControlForm) oControlForms.get(0)).initialize(curUIControlArranger.getSelectedArrangement(0), _NBorderType);
+ }
+ if (_bShouldHaveSubForm)
+ {
+ if (oControlForms.size() == 1)
+ {
+ adjustMainFormSize(_NBorderType);
+ final ControlForm aSubControlForm = new ControlForm(this, SOSUBFORM, getSubFormPoint(), getSubFormSize());
+ oControlForms.addElement(aSubControlForm);
+ /* ((ControlForm) oControlForms.get(1))*/
+ aSubControlForm.initialize(curUIControlArranger.getSelectedArrangement(1), _NBorderType);
+ }
+ else if (_bModifySubForm)
+ {
+ if (oControlForms.size() > 1)
+ {
+ oFormHandler.removeControlsofForm(SOSUBFORM);
+ ((ControlForm) oControlForms.get(1)).oFormController = null;
+ ((ControlForm) oControlForms.get(1)).initialize(curUIControlArranger.getSelectedArrangement(1), _NBorderType);
+ }
+ }
+ }
+ else
+ {
+ ControlForm aMainForm = (ControlForm) oControlForms.get(0);
+ // boolean bHasSubForm = aMainForm.xFormContainer.hasByName(SOSUBFORM);
+ // WRONG if (oFormHandler.hasFormByName(SOSUBFORM))
+ if (aMainForm.xFormContainer != null && aMainForm.xFormContainer.hasByName(SOSUBFORM))
+ {
+ oFormHandler.removeControlsofForm(SOSUBFORM);
+ oFormHandler.removeElement( aMainForm.xFormContainer, SOSUBFORM );
+ ((ControlForm) oControlForms.get(1)).oFormController = null;
+ // aMainForm.xFormContainer = null; // .removeFormByName(SOSUBFORM);
+ oControlForms.remove(1);
+ adjustMainFormSize(_NBorderType);
+ }
+ }
+ }
+
+ private int getMainFieldCount()
+ {
+ return oMainFormDBMetaData.getFieldNames().length;
+ }
+ private int getSubFieldCount()
+ {
+ return oSubFormDBMetaData.getFieldNames().length;
+ }
+
+ private Size getMainFormSize(int _curArrangement)
+ {
+ int nMainFormHeight = nFormHeight;
+ if (bhasSubForm)
+ {
+ if (_curArrangement == FormWizard.SOGRID)
+ {
+ nMainFormHeight = (int) ((double) (nFormHeight - SOFORMGAP) / 2);
+ }
+ else
+ {
+ int nTotalFieldCount = getMainFieldCount() + getSubFieldCount();
+ nMainFormHeight = (int) (((double) getMainFieldCount() / (double) nTotalFieldCount) * ((double) (nFormHeight - SOFORMGAP) / 2));
+ }
+ }
+ Size aMainFormSize = new Size(nFormWidth, nMainFormHeight);
+ return aMainFormSize;
+ }
+
+ private Size getSubFormSize()
+ {
+// int nSubFormHeight = (int) ((double)nFormHeight/2) - SOFORMGAP;
+// int nSubFormFieldCount = this.oSubFormDBMetaData.FieldNames.length;
+// int totfieldcount = oMainFormDBMetaData.FieldNames.length + nSubFormFieldCount;
+ int nMainFormHeight = ((ControlForm) oControlForms.get(0)).getActualFormHeight();
+ Size aSubFormSize = new Size(nFormWidth, nFormHeight - nMainFormHeight - SOFORMGAP);
+ return aSubFormSize;
+ }
+
+ private Point getSubFormPoint()
+ {
+ ControlForm curMainControlForm = ((ControlForm) oControlForms.get(0));
+ return new Point(curMainControlForm.aStartPoint.X,
+ (curMainControlForm.aStartPoint.Y + curMainControlForm.getFormSize().Height + SOFORMGAP));
+ }
+
+ private void adjustMainFormSize(Short _NBorderType)
+ {
+ ControlForm oMainControlForm = (ControlForm) oControlForms.get(0);
+ oMainControlForm.setFormSize(getMainFormSize(oMainControlForm.curArrangement));
+ if (oMainControlForm.curArrangement == FormWizard.SOGRID)
+ {
+ oMainControlForm.oGridControl.setSize(oMainControlForm.getFormSize());
+ }
+ else
+ {
+ oMainControlForm.oFormController.positionControls(oMainControlForm.curArrangement,
+ oMainControlForm.aStartPoint,
+ oMainControlForm.getFormSize(),
+ curUIControlArranger.getAlignValue(), _NBorderType);
+ }
+ }
+
+ private void adjustSubFormPosSize(Short _NBorderType)
+ {
+ ControlForm oMainControlForm = (ControlForm) oControlForms.get(0);
+ ControlForm oSubControlForm = (ControlForm) oControlForms.get(1);
+ oSubControlForm.setFormSize(new Size(nFormWidth, (int) nFormHeight - oMainControlForm.getFormSize().Height));
+ if (oSubControlForm.curArrangement == FormWizard.SOGRID)
+ {
+ Point aPoint = oSubControlForm.oGridControl.getPosition();
+ int idiffheight = oSubControlForm.getEntryPointY() - oMainControlForm.getActualFormHeight() - oMainControlForm.aStartPoint.Y - SOFORMGAP;
+ oSubControlForm.setStartPoint(new Point(aPoint.X, (aPoint.Y - idiffheight)));
+ oSubControlForm.oGridControl.setPosition(oSubControlForm.aStartPoint);
+ oSubControlForm.oGridControl.setSize(getSubFormSize());
+ }
+ else
+ {
+// oSubControlForm.oFormController.adjustYPositions(_idiffheight);
+ oSubControlForm.setStartPoint(new Point(oSubControlForm.aStartPoint.X, oMainControlForm.getActualFormHeight() + oMainControlForm.aStartPoint.Y + SOFORMGAP));
+ oSubControlForm.oFormController.positionControls(oSubControlForm.curArrangement, oSubControlForm.aStartPoint, oSubControlForm.getAvailableFormSize(), curUIControlArranger.getAlignValue(), _NBorderType);
+ }
+ }
+
+ public ControlForm getControlFormByName(String _sname)
+ {
+ for (int i = 0; i < oControlForms.size(); i++)
+ {
+ ControlForm curControlForm = ((ControlForm) oControlForms.get(i));
+ if (curControlForm.Name.equals(_sname))
+ {
+ return curControlForm;
+ }
+ }
+ return null;
+ }
+
+ public ControlForm[] getControlForms()
+ {
+ ControlForm[] aResult = new ControlForm[oControlForms.size()];
+ oControlForms.toArray( aResult );
+ return aResult;
+ }
+
+ public boolean finalizeForms(DataEntrySetter _curDataEntrySetter, FieldLinker _curFieldLinker, FormConfiguration _curFormConfiguration)
+ {
+ try
+ {
+ this.xTextDocument.lockControllers();
+ PropertyValue[] aFormProperties = _curDataEntrySetter.getFormProperties();
+ ControlForm oMasterControlForm = getControlFormByName(SOMAINFORM);
+ oMasterControlForm.setFormProperties(aFormProperties, oMainFormDBMetaData);
+ oMasterControlForm.finalizeControls();
+ if (oMasterControlForm.xFormContainer.hasByName(SOSUBFORM))
+ {
+ ControlForm oSubControlForm = getControlFormByName(SOSUBFORM);
+ oSubControlForm.setFormProperties(aFormProperties, oSubFormDBMetaData);
+ String sRefTableName = _curFormConfiguration.getreferencedTableName();
+ if (sRefTableName.equals(""))
+ {
+ LinkFieldNames = _curFieldLinker.getLinkFieldNames();
+ }
+ else
+ {
+ LinkFieldNames = _curFieldLinker.getLinkFieldNames(_curFormConfiguration.getRelationController(), sRefTableName);
+ }
+ if (LinkFieldNames != null)
+ {
+ if (LinkFieldNames.length > 0)
+ {
+ oSubControlForm.xPropertySet.setPropertyValue("DetailFields", LinkFieldNames[0]);
+ oSubControlForm.xPropertySet.setPropertyValue("MasterFields", LinkFieldNames[1]);
+ oSubControlForm.finalizeControls();
+ return true;
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ finally
+ {
+ unlockallControllers();
+ }
+ }
+
+ public class ControlForm
+ {
+
+ XNameContainer xFormContainer;
+ GridControl oGridControl;
+ FormControlArranger oFormController;
+ int curArrangement;
+ FormDocument oFormDocument;
+ String Name;
+ Point aStartPoint;
+ private Size aFormSize;
+ CommandMetaData oDBMetaData;
+ XPropertySet xPropertySet;
+
+ public ControlForm(FormDocument _oFormDocument, String _sname, Point _astartPoint, Size _aFormSize)
+ {
+ aStartPoint = _astartPoint;
+ aFormSize = _aFormSize;
+ oFormDocument = _oFormDocument;
+ Name = _sname;
+ if (_sname.equals(SOSUBFORM))
+ {
+ ControlForm oMainControlForm = ((ControlForm) oControlForms.get(0));
+ xFormContainer = oFormHandler.insertFormbyName(_sname, oMainControlForm.xFormContainer);
+ }
+ else
+ {
+ xFormContainer = oFormHandler.insertFormbyName(_sname);
+ }
+ xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFormContainer);
+ if (_sname.equals(SOMAINFORM))
+ {
+ oDBMetaData = oFormDocument.oMainFormDBMetaData;
+ }
+ else
+ {
+ oDBMetaData = oFormDocument.oSubFormDBMetaData;
+ }
+ }
+
+ public void initialize(int _curArrangement, Short _NBorderType)
+ {
+ boolean badaptControlStyles = false;
+ xTextDocument.lockControllers();
+ curArrangement = _curArrangement;
+ if (oGridControl != null)
+ {
+ oFormHandler.xDrawPage.remove(oGridControl.xShape);
+ oGridControl.xComponent.dispose();
+ oGridControl = null;
+ }
+ if (oFormController == null)
+ {
+ oFormController = new FormControlArranger(oFormHandler, xFormContainer, oDBMetaData, xProgressBar, aStartPoint, aFormSize);
+ }
+ else
+ {
+ if (curArrangement == FormWizard.SOGRID)
+ {
+ oFormHandler.moveShapesToNirwana(getLabelControls());
+ oFormHandler.moveShapesToNirwana(getDatabaseControls());
+ }
+ }
+ if (curArrangement == FormWizard.SOGRID)
+ {
+ insertGridControl(_NBorderType);
+ badaptControlStyles = true;
+ }
+ else
+ {
+ badaptControlStyles = !oFormController.areControlsexisting();
+ oFormController.positionControls(_curArrangement, aStartPoint, getAvailableFormSize(), curUIControlArranger.getAlignValue(), _NBorderType);
+ }
+ if (badaptControlStyles)
+ {
+ curStyleApplier.applyStyle(false, true);
+ }
+ if ((Name.equals(SOMAINFORM)) && (oControlForms.size() > 1))
+ {
+ ControlForm curSubControlForm = ((ControlForm) oControlForms.get(1));
+ if (curSubControlForm != null)
+ {
+ adjustSubFormPosSize(_NBorderType);
+ }
+ }
+ setFormSize(new Size(aFormSize.Width, getActualFormHeight()));
+ unlockallControllers();
+ }
+
+ public Control[] getLabelControls()
+ {
+ if (oFormController != null)
+ {
+ return oFormController.getLabelControlList();
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public Size getFormSize()
+ {
+ return aFormSize;
+ }
+
+ private Size getAvailableFormSize()
+ {
+ if (this.Name.equals(SOMAINFORM))
+ {
+ setFormSize(getMainFormSize(curArrangement));
+ }
+ else
+ {
+ setFormSize(getSubFormSize());
+ }
+ return aFormSize;
+ }
+
+ public void setFormSize(Size _aSize)
+ {
+ aFormSize = _aSize;
+ oFormController.setFormSize(aFormSize);
+ }
+
+ private void setStartPoint(Point _aPoint)
+ {
+ aStartPoint = _aPoint;
+ if (oFormController != null)
+ {
+ oFormController.setStartPoint(_aPoint);
+ }
+ }
+
+ private int getActualFormHeight()
+ {
+ if (curArrangement == FormWizard.SOGRID)
+ {
+ return oGridControl.xShape.getSize().Height;
+ }
+ else
+ {
+ return oFormController.getFormHeight();
+ }
+ }
+
+ private int getEntryPointY()
+ {
+ if (curArrangement == FormWizard.SOGRID)
+ {
+ return oGridControl.xShape.getPosition().Y;
+ }
+ else
+ {
+ return oFormController.getEntryPointY();
+ }
+ }
+
+ private void setFormProperties(PropertyValue[] _aPropertySetList, CommandMetaData _oDBMetaData)
+ {
+ try
+ {
+ xPropertySet.setPropertyValue("DataSourceName", getDataSourceName());
+ xPropertySet.setPropertyValue("Command", _oDBMetaData.getCommandName());
+ xPropertySet.setPropertyValue("CommandType", new Integer(_oDBMetaData.getCommandType()));
+ for (int i = 0; i < _aPropertySetList.length; i++)
+ {
+ xPropertySet.setPropertyValue(_aPropertySetList[i].Name, _aPropertySetList[i].Value);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public DatabaseControl[] getDatabaseControls()
+ {
+ if (oFormController != null)
+ {
+ return oFormController.DBControlList;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ public GridControl getGridControl()
+ {
+ return oGridControl;
+ }
+
+ public int getArrangemode()
+ {
+ return curArrangement;
+ }
+
+ private void insertGridControl(Short _NBorderType)
+ {
+ try
+ {
+ curArrangement = FormWizard.SOGRID;
+ if (Name.equals(SOMAINFORM))
+ {
+ oGridControl = new GridControl(xMSF, Name + "_Grid", oFormHandler, xFormContainer, oDBMetaData.FieldColumns, aStartPoint, getMainFormSize(FormWizard.SOGRID));
+ }
+ else
+ {
+ oGridControl = new GridControl(xMSF, Name + "_Grid", oFormHandler, xFormContainer, oDBMetaData.FieldColumns, aStartPoint, getSubFormSize());
+ }
+ oGridControl.xPropertySet.setPropertyValue("Border", _NBorderType);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void finalizeControls()
+ {
+ Control[] oLabelControls = getLabelControls();
+ Control[] oDBControls = getDatabaseControls();
+ if (oLabelControls != null)
+ {
+ for (int i = 0; i < getLabelControls().length; i++)
+ {
+ if (curArrangement == FormWizard.SOGRID)
+ {
+ if ((oLabelControls[i] != null) && (oDBControls[i] != null))
+ {
+ oFormHandler.removeShape(oLabelControls[i].xShape);
+ oFormHandler.removeShape(oDBControls[i].xShape);
+ }
+ }
+ else
+ {
+ oFormHandler.groupShapesTogether(xMSF, oLabelControls[i].xShape, oDBControls[i].xShape);
+ }
+
+ }
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/FormWizard.java b/wizards/com/sun/star/wizards/form/FormWizard.java
new file mode 100644
index 000000000000..eb25fb65c78d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/FormWizard.java
@@ -0,0 +1,481 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.application.DatabaseObject;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.db.DatabaseObjectWizard;
+import com.sun.star.wizards.db.RelationController;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.ui.CommandFieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+
+public class FormWizard extends DatabaseObjectWizard
+{
+
+ private CommandFieldSelection curDBCommandFieldSelection;
+ private FormConfiguration curFormConfiguration;
+ private CommandFieldSelection curSubFormFieldSelection;
+ private FormDocument curFormDocument;
+ private FieldLinker curFieldLinker;
+ private UIControlArranger curControlArranger;
+ private DataEntrySetter CurDataEntrySetter;
+ private StyleApplier curStyleApplier;
+ private Finalizer curFinalizer;
+ private static String slblFields;
+ private static String slblSelFields;
+ private String sShowBinaryFields = "";
+ private String serrFormNameexists = "";
+ public static final int SOMAIN_PAGE = 1;
+ public static final int SOSUBFORM_PAGE = 2;
+ public static final int SOSUBFORMFIELDS_PAGE = 3;
+ public static final int SOFIELDLINKER_PAGE = 4;
+ public static final int SOCONTROL_PAGE = 5;
+ public static final int SODATA_PAGE = 6;
+ public static final int SOSTYLE_PAGE = 7;
+ public static final int SOSTORE_PAGE = 8;
+ public static final int SOCOLUMNARLEFT = 1;
+ public static final int SOCOLUMNARTOP = 2;
+ public static final int SOGRID = 3;
+ public static final int SOTOPJUSTIFIED = 4;
+ private String slblTables;
+ private boolean m_openForEditing;
+ private boolean m_success = false;
+ private String FormName;
+
+ public FormWizard( XMultiServiceFactory i_servicFactory, final PropertyValue[] i_wizardContext )
+ {
+ super( i_servicFactory, 34400, i_wizardContext );
+ super.addResourceHandler("FormWizard", "dbw");
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ new Integer(210), Boolean.TRUE, "DialogForm", new Integer(102), new Integer(41), new Integer(1), new Short((short) 0), m_oResource.getResText(UIConsts.RID_FORM), new Integer(310)
+ });
+ drawNaviBar();
+ if (getFormResources() == true)
+ {
+ setRightPaneHeaders(m_oResource, UIConsts.RID_FORM + 90, 8);
+ }
+ }
+
+ // @Override
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ try
+ {
+ if ((nOldStep < SOCONTROL_PAGE) && (nNewStep >= SOCONTROL_PAGE))
+ {
+ curFormDocument.initialize(curDBCommandFieldSelection.isModified(), curFormConfiguration.hasSubForm(), curSubFormFieldSelection.isModified(), getBorderType());
+ curDBCommandFieldSelection.setModified(false);
+ curSubFormFieldSelection.setModified(false);
+ }
+ switch (nNewStep)
+ {
+ case SOMAIN_PAGE:
+ curDBCommandFieldSelection.setModified(false);
+ break;
+ case SOSUBFORM_PAGE:
+ {
+ final String sCommandName = curDBCommandFieldSelection.getSelectedCommandName();
+ RelationController oRelationController = new RelationController(curFormDocument.oMainFormDBMetaData, sCommandName);
+ curFormConfiguration.initialize(curSubFormFieldSelection, oRelationController);
+ }
+ break;
+ case SOSUBFORMFIELDS_PAGE:
+ {
+ String sPreSelectedTableName = curFormConfiguration.getreferencedTableName();
+ boolean bReadOnly = (sPreSelectedTableName.length() > 0);
+ if (sPreSelectedTableName.length() == 0)
+ {
+ final String sTableName = curSubFormFieldSelection.getSelectedCommandName();
+ String[] aFieldNames = curSubFormFieldSelection.getSelectedFieldNames();
+ curFormDocument.oSubFormDBMetaData.initializeFieldColumns(true, sTableName, aFieldNames);
+ }
+ else
+ {
+ curSubFormFieldSelection.preselectCommand(sPreSelectedTableName, bReadOnly);
+ }
+ }
+ break;
+ case SOFIELDLINKER_PAGE:
+ {
+ final String[] aMainFieldNames = curFormDocument.oMainFormDBMetaData.getFieldNames();
+ final String[] aSubFieldNames = curFormDocument.oSubFormDBMetaData.getFieldNames();
+ curFieldLinker.initialize(aMainFieldNames, aSubFieldNames, curFormDocument.LinkFieldNames);
+ }
+ break;
+ case SOCONTROL_PAGE:
+ curControlArranger.enableSubFormImageList(curFormConfiguration.hasSubForm());
+ break;
+ case SODATA_PAGE:
+ break;
+ case SOSTYLE_PAGE:
+ break;
+ case SOSTORE_PAGE:
+ {
+ String sTableName = this.curDBCommandFieldSelection.getSelectedCommandName();
+ this.curFinalizer.initialize(sTableName, curFormDocument);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ protected Short getBorderType()
+ {
+ return curStyleApplier.getBorderType();
+ }
+
+ // @Override
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ switch (nOldStep)
+ {
+ case SOMAIN_PAGE:
+ {
+ final String sTableName = curDBCommandFieldSelection.getSelectedCommandName();
+ final String[] aFieldNames = curDBCommandFieldSelection.getSelectedFieldNames();
+ curFormDocument.oMainFormDBMetaData.initializeFieldColumns(true, sTableName, aFieldNames);
+
+ final String[] aMainFieldNames = curFormDocument.oMainFormDBMetaData.getFieldNames();
+ try
+ {
+ curFormDocument.LinkFieldNames = JavaTools.removeOutdatedFields(curFormDocument.LinkFieldNames, aMainFieldNames, 1);
+ }
+ catch (java.lang.Exception e)
+ {}
+ }
+ break;
+ case SOSUBFORM_PAGE:
+ break;
+ case SOSUBFORMFIELDS_PAGE:
+ {
+ final String sTableName = curSubFormFieldSelection.getSelectedCommandName();
+ final String[] aFieldNames = curSubFormFieldSelection.getSelectedFieldNames();
+ curFormDocument.oSubFormDBMetaData.initializeFieldColumns(true, sTableName, aFieldNames);
+
+ final String[] aSubFieldNames = curFormDocument.oSubFormDBMetaData.getFieldNames();
+ try
+ {
+ curFormDocument.LinkFieldNames = JavaTools.removeOutdatedFields(curFormDocument.LinkFieldNames, aSubFieldNames, 0);
+ }
+ catch (java.lang.Exception e)
+ {}
+ }
+ break;
+ case SOFIELDLINKER_PAGE:
+ curFormDocument.LinkFieldNames = curFieldLinker.getLinkFieldNames();
+ break;
+ case SOCONTROL_PAGE:
+ break;
+ case SODATA_PAGE:
+ break;
+ case SOSTYLE_PAGE:
+ break;
+ case SOSTORE_PAGE:
+ break;
+ default:
+ break;
+ }
+ }
+
+ public void buildSteps() throws NoValidPathException
+ {
+ curDBCommandFieldSelection = new CommandFieldSelection(this, curFormDocument.oMainFormDBMetaData, 92, slblFields, slblSelFields, slblTables, true, 34411);
+ curDBCommandFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
+ curFormDocument.xProgressBar.setValue(20);
+ // Label Help Text
+ insertLabel("lblBinaryHelpText",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(28), sShowBinaryFields, Boolean.TRUE, new Integer(95), new Integer(154), new Integer(SOMAIN_PAGE), new Integer(210)
+ });
+
+ curFormConfiguration = new FormConfiguration(this);
+ curFormDocument.xProgressBar.setValue(30);
+
+ curSubFormFieldSelection = new CommandFieldSelection(this, curFormDocument.oSubFormDBMetaData, SOSUBFORMFIELDS_PAGE, 92, slblFields, slblSelFields, slblTables, true, 34431);
+ curSubFormFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
+ insertLabel("lblSubFormBinaryHelpText",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(28), sShowBinaryFields, Boolean.TRUE, new Integer(95), new Integer(154), new Integer(SOSUBFORMFIELDS_PAGE), new Integer(210)
+ });
+
+ curFormDocument.xProgressBar.setValue(40);
+
+ curFieldLinker = new FieldLinker(this, SOFIELDLINKER_PAGE, 95, 30, 210, 34441);
+ curFormDocument.xProgressBar.setValue(50);
+
+ curControlArranger = new UIControlArranger(this, curFormDocument);
+ curFormDocument.addUIFormController(curControlArranger);
+ curFormDocument.xProgressBar.setValue(60);
+
+ CurDataEntrySetter = new DataEntrySetter(this);
+ curFormDocument.xProgressBar.setValue(70);
+
+ curStyleApplier = new StyleApplier(this, curFormDocument);
+ curFormDocument.addStyleApplier(curStyleApplier);
+ curFormDocument.xProgressBar.setValue(80);
+
+ curFinalizer = new Finalizer(this);
+ curFormDocument.xProgressBar.setValue(100);
+
+ enableNavigationButtons(false, false, false);
+ curFormDocument.xProgressBar.end();
+ }
+
+ // @Override
+ public boolean finishWizard()
+ {
+ int ncurStep = getCurrentStep();
+ if ((switchToStep(ncurStep, SOSTORE_PAGE)) || (ncurStep == SOSTORE_PAGE))
+ {
+ this.curFinalizer.initialize(curDBCommandFieldSelection.getSelectedCommandName(), this.curFormDocument);
+ String sNewFormName = curFinalizer.getName();
+ if (!curFormDocument.oMainFormDBMetaData.hasFormDocumentByName(sNewFormName))
+ {
+ m_openForEditing = curFinalizer.getOpenForEditing();
+ FormName = curFinalizer.getName();
+ if (curFormDocument.finalizeForms(CurDataEntrySetter, curFieldLinker, curFormConfiguration))
+ {
+
+ if (curFinalizer.finish())
+ {
+ m_success = true;
+ xDialog.endExecute();
+ return true;
+ }
+ }
+ }
+ else
+ {
+ String smessage = JavaTools.replaceSubString(serrFormNameexists, sNewFormName, "%FORMNAME");
+ showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage);
+ }
+ }
+ return false;
+ }
+
+ // @Override
+ public void cancelWizard()
+ {
+ m_success = false;
+ xDialog.endExecute();
+ }
+
+ public void insertFormRelatedSteps()
+ {
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_FORM + 80), SOMAIN_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 81), SOSUBFORM_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 82), SOSUBFORMFIELDS_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 83), SOFIELDLINKER_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 84), SOCONTROL_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 85), SODATA_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 86), SOSTYLE_PAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_FORM + 87), SOSTORE_PAGE);
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+
+ public void startFormWizard()
+ {
+ try
+ {
+ curFormDocument = new FormDocument(xMSF);
+ if ( curFormDocument.oMainFormDBMetaData.getConnection( m_wizardContext ) )
+ {
+ curFormDocument.oSubFormDBMetaData.getConnection(new PropertyValue[]
+ {
+ Properties.createProperty("ActiveConnection", curFormDocument.oMainFormDBMetaData.DBConnection)
+ });
+ curFormDocument.xProgressBar.setValue(20);
+ buildSteps();
+ this.curDBCommandFieldSelection.preselectCommand( m_wizardContext, false );
+ XWindowPeer xWindowPeer2 = createWindowPeer(curFormDocument.xWindowPeer);
+ curFormDocument.oMainFormDBMetaData.setWindowPeer( xWindowPeer2 );
+ insertFormRelatedSteps();
+ short dialogReturn = executeDialog(curFormDocument.xFrame);
+ xComponent.dispose();
+ if ( ( dialogReturn == 0 ) && m_success )
+ {
+ curFormDocument.oMainFormDBMetaData.addFormDocument( curFormDocument.xComponent );
+ loadSubComponent( DatabaseObject.FORM, FormName, m_openForEditing );
+ }
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ if ((!m_success) && (curFormDocument != null))
+ {
+ OfficeDocument.close(curFormDocument.xComponent);
+ }
+ }
+
+ private boolean getFormResources()
+ {
+ sShowBinaryFields = m_oResource.getResText(UIConsts.RID_FORM + 2);
+ slblTables = m_oResource.getResText(UIConsts.RID_FORM + 6);
+ slblFields = m_oResource.getResText(UIConsts.RID_FORM + 12);
+ slblSelFields = m_oResource.getResText(UIConsts.RID_FORM + 1);
+ serrFormNameexists = m_oResource.getResText(UIConsts.RID_FORM + 98);
+
+ return true;
+ }
+
+ public class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener
+ {
+
+ protected int ID;
+
+ // @Override
+ public int getID()
+ {
+ return ID;
+ }
+
+ // @Override
+ public void setID(String sIncSuffix)
+ {
+ ID = 1;
+ if (sIncSuffix != null)
+ {
+ if ((!sIncSuffix.equals("")) && (!sIncSuffix.equals("_")))
+ {
+ String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1];
+ ID = Integer.parseInt(sID);
+ int a = 0;
+ }
+ }
+ }
+
+ // @Override
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ if (ID == 1)
+ {
+ toggleMainFormSteps();
+ }
+ else
+ {
+ toggleSubFormSteps();
+ }
+ }
+
+ // @Override
+ 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 (ID == 1)
+ {
+ toggleMainFormSteps();
+ }
+ else
+ {
+ toggleSubFormSteps();
+ }
+ }
+ // @Override
+ public void moveItemDown(String item)
+ {
+ }
+
+ // @Override
+ public void moveItemUp(String item)
+ {
+ }
+
+ private boolean toggleSubFormSteps()
+ {
+ curSubFormFieldSelection.setModified(true);
+ boolean benable = curSubFormFieldSelection.getSelectedFieldNames().length > 0;
+ enablefromStep(SOFIELDLINKER_PAGE, benable);
+ if (benable)
+ {
+ curFieldLinker.enable(!curFormConfiguration.areexistingRelationsdefined());
+ }
+ return benable;
+ }
+
+ private void toggleMainFormSteps()
+ {
+ curDBCommandFieldSelection.setModified(true);
+ boolean benable = curDBCommandFieldSelection.getSelectedFieldNames().length > 0;
+ enablefromStep(SOSUBFORM_PAGE, benable);
+ setControlProperty("btnWizardNext", "Enabled", new Boolean(benable));
+ if (benable)
+ {
+ if (curFormConfiguration.hasSubForm())
+ {
+ benable = toggleSubFormSteps();
+ }
+ else
+ {
+ setStepEnabled(SOSUBFORMFIELDS_PAGE, false);
+ setStepEnabled(SOFIELDLINKER_PAGE, false);
+ }
+ }
+ setControlProperty("btnWizardFinish", "Enabled", new Boolean(benable));
+ }
+ }
+}
+
+
+
+
+
diff --git a/wizards/com/sun/star/wizards/form/MANIFEST.MF b/wizards/com/sun/star/wizards/form/MANIFEST.MF
new file mode 100644
index 000000000000..af4c0a07d529
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.form.CallFormWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/form/StyleApplier.java b/wizards/com/sun/star/wizards/form/StyleApplier.java
new file mode 100644
index 000000000000..e1b27c05e7aa
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/StyleApplier.java
@@ -0,0 +1,494 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.IllegalArgumentException;
+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.uno.XInterface;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.document.Control;
+import com.sun.star.wizards.document.DatabaseControl;
+import com.sun.star.wizards.document.GridControl;
+import com.sun.star.wizards.document.TimeStampControl;
+import com.sun.star.wizards.text.TextStyleHandler;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.wizards.ui.UIConsts;
+import java.util.ArrayList;
+
+// TODO: Style Templates fuer OOo?
+
+public class StyleApplier
+{
+
+ private WizardDialog CurUnoDialog;
+ private XPropertySet xPageStylePropertySet;
+ private XMultiServiceFactory xMSF;
+ private short curtabindex;
+ private XRadioButton optNoBorder;
+ private XRadioButton opt3DLook;
+ private XRadioButton optFlat;
+ private XListBox lstStyles;
+ private Desktop.OfficePathRetriever curofficepath;// String[][] sLayoutFiles;
+ private FormDocument curFormDocument;
+ private short iOldLayoutPos;
+ private int SOLAYOUTLST = 0;
+ private static final String SCHANGELAYOUT = "changeLayout";
+ private static final String SCHANGEBORDERTYPE = "changeBorderLayouts";
+ private String[] StyleNames;
+ private String[] StyleNodeNames;
+ private String[] FileNames;
+ // private String StylesPath;
+ private final static int SOBACKGROUNDCOLOR = 0;
+ private final static int SODBTEXTCOLOR = 1;
+ private final static int SOLABELTEXTCOLOR = 2;
+// final static int SODBCONTROLBACKGROUNDCOLOR = 3;
+ private final static int SOLABELBACKGROUNDCOLOR = 4;
+ private final static int SOBORDERCOLOR = 5;
+ private Short IBorderValue = new Short((short) 1);
+
+ public StyleApplier(WizardDialog _CurUnoDialog, FormDocument _curFormDocument) throws NoValidPathException
+ {
+// try
+// {
+ this.curFormDocument = _curFormDocument;
+ xMSF = curFormDocument.xMSF;
+
+ TextStyleHandler oTextStyleHandler = new TextStyleHandler(xMSF, curFormDocument.xTextDocument);
+ xPageStylePropertySet = oTextStyleHandler.getStyleByName("PageStyles", "Standard");
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (FormWizard.SOSTYLE_PAGE * 100);
+ Integer IStyleStep = new Integer(FormWizard.SOSTYLE_PAGE);
+ String sPageStyles = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 86);
+ String sNoBorder = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 29);
+ String s3DLook = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 30);
+ String sFlat = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 31);
+ String sFieldBorder = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 28);
+// XInterface xUcbInterface = (XInterface) _curFormDocument.xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ setStyles();
+ short[] SelLayoutPos;
+ SelLayoutPos = new short[]
+ {
+ 0
+ };
+
+ CurUnoDialog.insertLabel("lblStyles",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], sPageStyles, new Integer(92), new Integer(25), IStyleStep, new Short(curtabindex++), new Integer(90)
+ });
+
+ lstStyles = CurUnoDialog.insertListBox("lstStyles", null, SCHANGELAYOUT, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "SelectedItems", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(143), "HID:WIZARDS_HID_DLGFORM_LSTSTYLES", new Integer(92), new Integer(35), SelLayoutPos, IStyleStep, this.StyleNames, new Short(curtabindex++), new Integer(90)
+ });
+
+ optNoBorder = CurUnoDialog.insertRadioButton("otpNoBorder", SCHANGEBORDERTYPE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Tag", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDNOBORDER", sNoBorder, new Integer(196), new Integer(39), IStyleStep, new Short(curtabindex++), "0", new Integer(93)
+ });
+
+ opt3DLook = CurUnoDialog.insertRadioButton("otp3DLook", SCHANGEBORDERTYPE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Tag", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMD3DBORDER", s3DLook, new Integer(196), new Integer(53), new Short((short) 1), IStyleStep, new Short(curtabindex++), "1", new Integer(93)
+ });
+
+ optFlat = CurUnoDialog.insertRadioButton("otpFlat", SCHANGEBORDERTYPE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Tag", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDSIMPLEBORDER", sFlat, new Integer(196), new Integer(67), IStyleStep, new Short(curtabindex++), "2", new Integer(93)
+ });
+
+ CurUnoDialog.insertFixedLine("lnFieldBorder",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], sFieldBorder, new Integer(192), new Integer(25), IStyleStep, new Short(curtabindex++), new Integer(98)
+ });
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace(System.out);
+// }
+ }
+
+ /* public void initialize(short _iStyleindex){
+ if (_iStyleindex < lstStyles.getItemCount()){
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstStyles), "SelectedItems", new short[]{_iStyleindex});
+ applyStyle(true, false);
+ }
+ }
+ */
+ private void setStyles()
+ {
+ try
+ {
+ Object oRootNode = Configuration.getConfigurationRoot(xMSF, "org.openoffice.Office.FormWizard/FormWizard/Styles", false);
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oRootNode);
+ StyleNodeNames = xNameAccess.getElementNames();
+ StyleNames = new String[StyleNodeNames.length];
+ FileNames = new String[StyleNodeNames.length];
+ for (int i = 0; i < StyleNodeNames.length; i++)
+ {
+ Object oStyleNode = xNameAccess.getByName(StyleNodeNames[i]);
+ StyleNames[i] = (String) Helper.getUnoPropertyValue(oStyleNode, "Name");
+ FileNames[i] = (String) Helper.getUnoPropertyValue(oStyleNode, "CssHref");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private short getStyleIndex()
+ {
+ try
+ {
+ short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(lstStyles), "SelectedItems"));
+ if (SelFields != null)
+ {
+ return SelFields[0];
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return (short) -1;
+ }
+
+ public void applyStyle(boolean _bmodifyBackground, boolean _bapplyalways)
+ {
+ short iStyle = getStyleIndex();
+ if ((iStyle != iOldLayoutPos) || _bapplyalways)
+ {
+ if (iStyle > -1)
+ {
+ iOldLayoutPos = iStyle;
+ String sFileName = FileNames[iStyle]; //Style = lstStyles.getSelectedItem();
+ int[] iStyles = getStyleColors(sFileName);
+ applyDBControlProperties(iStyles);
+ }
+ }
+ }
+
+ public void changeLayout()
+ {
+ short iPos = lstStyles.getSelectedItemPos();
+ if (iPos != iOldLayoutPos)
+ {
+ iOldLayoutPos = iPos;
+ String sFileName = FileNames[iPos]; //Style = lstStyles.getSelectedItem();
+ int[] iStyles = getStyleColors(sFileName);
+ applyDBControlProperties(iStyles);
+ }
+ curFormDocument.unlockallControllers();
+ }
+
+ /* public void changeLayout(){
+ / curFormDocument.xTextDocument.lockControllers();
+ applyStyle(true, false);
+ curFormDocument.unlockallControllers();
+ }
+ */
+ public Short getBorderType()
+ {
+ return IBorderValue;
+ }
+
+ public void changeBorderLayouts()
+ {
+ try
+ {
+ curFormDocument.xTextDocument.lockControllers();
+
+ if (optNoBorder.getState())
+ {
+ IBorderValue = new Short((short) 0);
+ }
+ else if (opt3DLook.getState())
+ {
+ IBorderValue = new Short((short) 1);
+ }
+ else
+ {
+ IBorderValue = new Short((short) 2);
+ }
+ for (int m = 0; m < curFormDocument.oControlForms.size(); m++)
+ {
+ FormDocument.ControlForm curControlForm = ((FormDocument.ControlForm) curFormDocument.oControlForms.get(m));
+ if (curControlForm.getArrangemode() == FormWizard.SOGRID)
+ {
+ GridControl oGridControl = curControlForm.getGridControl();
+ oGridControl.xPropertySet.setPropertyValue("Border", IBorderValue);
+ }
+ else
+ {
+ DatabaseControl[] DBControls = curControlForm.getDatabaseControls();
+ for (int n = 0; n < DBControls.length; n++)
+ {
+ if (DBControls[n].xServiceInfo.supportsService("com.sun.star.drawing.ShapeCollection"))
+ {
+ TimeStampControl oTimeStampControl = (TimeStampControl) DBControls[n];
+ for (int i = 0; i < 2; i++)
+ {
+ XPropertySet xPropertySet = oTimeStampControl.getControlofGroupShapeByIndex(i);
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName("Border"))
+ {
+ xPropertySet.setPropertyValue("Border", IBorderValue);
+ }
+ }
+ }
+ else
+ {
+ if (DBControls[n].xPropertySet.getPropertySetInfo().hasPropertyByName("Border"))
+ {
+ DBControls[n].xPropertySet.setPropertyValue("Border", IBorderValue);
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ curFormDocument.unlockallControllers();
+ }
+
+ public void disposing(EventObject eventObject)
+ {
+ }
+
+ private int getStyleColor(String[] _sDataList, String _sHeader, String _sPropertyDescription)
+ {
+ int iColor = -1;
+ int index = JavaTools.FieldInList(_sDataList, _sHeader);
+ if (index > -1)
+ {
+ String sPropName = "";
+ int iStyleColor;
+ while (((sPropName.indexOf("}") < 0) && (index < _sDataList.length - 1)))
+ {
+ String scurline = _sDataList[index++];
+ if ((scurline.indexOf(_sPropertyDescription)) > 0)
+ {
+ if (scurline.indexOf(":") > 0)
+ {
+ String[] sPropList = JavaTools.ArrayoutofString(scurline, ":");
+ String sPropValue = sPropList[1];
+ sPropValue = sPropValue.trim();
+ if (sPropValue.indexOf("#") > 0)
+ {
+ sPropValue = JavaTools.replaceSubString(sPropValue, "", ";");
+ sPropValue = JavaTools.replaceSubString(sPropValue, "", " ");
+ return Integer.decode(sPropValue).intValue();
+ }
+ }
+ }
+ }
+ }
+ return -1;
+ }
+
+ private XMultiServiceFactory getMSF()
+ {
+ return xMSF;
+ }
+
+ private ArrayList<String> getStylePaths()
+ {
+ ArrayList<String> aStylePaths = new ArrayList<String>();
+ try
+ {
+ // TODO: check different languages in header layouts
+ aStylePaths = FileAccess.getOfficePaths(getMSF(), "Config", "", "");
+ FileAccess.combinePaths(getMSF(), aStylePaths, "/wizard/form/styles");
+
+ String[][] LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aStylePaths, ".css");
+
+ }
+ catch (com.sun.star.wizards.common.NoValidPathException e)
+ {
+ // if there are problems, don't show anything is a little bit hard.
+ aStylePaths.add("default");
+ }
+ return aStylePaths;
+ }
+
+ private String getStylePath()
+ {
+// TODO: umstellen auf mehrere Pfade
+ String StylesPath = "";
+ try
+ {
+ StylesPath = FileAccess.getOfficePath(xMSF, "Config", "", "");
+ StylesPath = FileAccess.combinePaths(xMSF, StylesPath, "/wizard/form/styles");
+ }
+ catch (NoValidPathException e)
+ {
+ }
+ return StylesPath;
+ }
+
+ private int[] getStyleColors(String _filename)
+ {
+ String sFilePath = getStylePath() + "/" + _filename;
+ int[] oStylePropList = new int[6];
+ String[] sData = FileAccess.getDataFromTextFile(xMSF, sFilePath);
+ oStylePropList[SOBACKGROUNDCOLOR] = getStyleColor(sData, ".toctitle {", "background-color:");
+ oStylePropList[SODBTEXTCOLOR] = getStyleColor(sData, ".doctitle {", "color:");
+ oStylePropList[SOLABELTEXTCOLOR] = getStyleColor(sData, ".toctitle {", "color:");
+// oStylePropList[SODBCONTROLBACKGROUNDCOLOR] = getStyleColor(sData, "body {", "background-color:");
+// oStylePropList[SOLABELBACKGROUNDCOLOR] = getStyleColor(sData, ".toctitle {", "background-color:");
+ oStylePropList[SOBORDERCOLOR] = getStyleColor(sData, ".tcolor {", "border-color:");
+ return oStylePropList;
+ }
+
+ private void setDBControlColors(XPropertySet xPropertySet, int[] _iStyleColors)
+ {
+ try
+ {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName("TextColor"))
+ {
+ if (_iStyleColors[SODBTEXTCOLOR] > -1)
+ {
+ xPropertySet.setPropertyValue("TextColor", Integer.decode("#00000"));
+ }
+ }
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName("BackgroundColor"))
+ {
+ xPropertySet.setPropertyValue("BackgroundColor", Integer.decode("#DDDDDD"));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void applyDBControlProperties(int[] _iStyleColors)
+ {
+ try
+ {
+ for (int m = 0; m < curFormDocument.oControlForms.size(); m++)
+ {
+ FormDocument.ControlForm curControlForm = ((FormDocument.ControlForm) curFormDocument.oControlForms.get(m));
+ if (curControlForm.getArrangemode() == FormWizard.SOGRID)
+ {
+ if (_iStyleColors[SOLABELTEXTCOLOR] > -1)
+ {
+ curControlForm.oGridControl.xPropertySet.setPropertyValue("TextColor", new Integer(_iStyleColors[SODBTEXTCOLOR]));
+ }
+ curControlForm.oGridControl.xPropertySet.setPropertyValue("BackgroundColor", Integer.decode("#DDDDDD"));
+ }
+ else
+ {
+ DatabaseControl[] DBControls = curControlForm.getDatabaseControls();
+ for (int n = 0; n < DBControls.length; n++)
+ {
+ if (_iStyleColors[SODBTEXTCOLOR] > -1)
+ {
+ DatabaseControl aDBControl = DBControls[n];
+ if (aDBControl != null)
+ {
+ if (aDBControl.xServiceInfo.supportsService("com.sun.star.drawing.ShapeCollection"))
+ {
+ TimeStampControl oTimeStampControl = (TimeStampControl) aDBControl;
+ for (int i = 0; i < 2; i++)
+ {
+ XPropertySet xPropertySet = oTimeStampControl.getControlofGroupShapeByIndex(i);
+ setDBControlColors(xPropertySet, _iStyleColors);
+ }
+ }
+ else
+ {
+ setDBControlColors(aDBControl.xPropertySet, _iStyleColors);
+ }
+ }
+ }
+ }
+ Control[] LabelControls = curControlForm.getLabelControls();
+ for (int n = 0; n < LabelControls.length; n++)
+ {
+ if (_iStyleColors[SOLABELTEXTCOLOR] > -1)
+ {
+ LabelControls[n].xPropertySet.setPropertyValue("TextColor", new Integer(_iStyleColors[SOLABELTEXTCOLOR]));
+// if (_iStyleColors[SOCONTROLBACKGROUNDCOLOR] > -1)
+// LabelControls[n].xPropertySet.setPropertyValue("BackgroundColor", new Integer(_iStyleColors[SOCONTROLBACKGROUNDCOLOR]));
+ }
+ }
+ }
+ }
+ xPageStylePropertySet.setPropertyValue("BackColor", new Integer(_iStyleColors[SOBACKGROUNDCOLOR]));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/UIControlArranger.java b/wizards/com/sun/star/wizards/form/UIControlArranger.java
new file mode 100644
index 000000000000..0add27db3625
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/UIControlArranger.java
@@ -0,0 +1,504 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.form;
+
+import com.sun.star.awt.ItemEvent;
+
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.lang.EventObject;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.document.Control;
+// import com.sun.star.wizards.ui.ImageList;
+import com.sun.star.wizards.ui.ButtonList;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+
+import javax.swing.DefaultListModel;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+public class UIControlArranger
+{
+
+ private FormWizard CurUnoDialog;
+ private FormDocument curFormDocument;
+ private short curtabindex;
+ private XRadioButton optAlignLeft;
+ private XRadioButton optAlignRight;
+ private XControl flnLabelPlacement;
+ private String[] HelpTexts = new String[4];
+ // private String[] sArrangementHeader = new String[2];
+ // private ArrangeImageList[] m_aArrangeList = new ArrangeImageList[2];
+ private ArrangeButtonList[] m_aArrangeList = new ArrangeButtonList[2];
+ private Integer IControlStep;
+ private final int SOBASEIMAGEYPOSITION = 66;
+ private final int SOIMAGELISTHEIGHT = 60;
+ private final String SOALIGNMETHOD = "alignLabelControls";
+
+ public UIControlArranger(FormWizard _CurUnoDialog, FormDocument _curFormDocument) throws NoValidPathException
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ this.curFormDocument = _curFormDocument;
+ curtabindex = (short) (FormWizard.SOCONTROL_PAGE * 100);
+ IControlStep = new Integer(FormWizard.SOCONTROL_PAGE);
+ String sLabelPlacment = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 32);
+ String sAlignLeft = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 33);
+ String sAlignRight = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 34);
+
+ // Label "Label Placement" -----------------
+ flnLabelPlacement = CurUnoDialog.insertFixedLine("lnLabelPlacement",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], sLabelPlacment, new Integer(97), new Integer(25), IControlStep, new Short(curtabindex++), new Integer(207)
+ });
+ // Radio Button "Align Left"
+ optAlignLeft = CurUnoDialog.insertRadioButton("optAlignLeft", SOALIGNMETHOD, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDALIGNLEFT", sAlignLeft, new Integer(107), new Integer(38), new Short((short) 1), IControlStep, new Short(curtabindex++), new Integer(171)
+ });
+ // Radio Button "Align Right"
+ optAlignRight = CurUnoDialog.insertRadioButton("optAlignRight", SOALIGNMETHOD, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[10], "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT", sAlignRight, Boolean.TRUE, new Integer(107), new Integer(50), IControlStep, new Short(curtabindex++), new Integer(171)
+ });
+
+
+ HelpTexts[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 36); // "Columnar - Labels Left"
+ HelpTexts[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 37); // "Columnar - Labels of Top"
+ HelpTexts[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 40); // "As Data Sheet"
+ HelpTexts[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 39); // In Blocks - Labels Above"
+
+// flnLabelPlacement = CurUnoDialog.insertFixedLine("lnArrangementHeader1",
+// new String[]
+// {
+// "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+// },
+// new Object[]
+// {
+// UIConsts.INTEGERS[8], sArrangementHeader[0], new Integer(97), new Integer(60), IControlStep, new Short(curtabindex++), new Integer(207)
+// });
+//
+// boolean bEnabled = true;
+// int nBtnWidth = 16;
+// int nXPos = 97;
+// int nYPos = 70;
+// CurUnoDialog.insertButton("btnLayout1", "btnLayout1",
+// new String[]
+// {
+// "Enabled",
+// "Height",
+// "HelpURL",
+// "Label",
+// "PositionX",
+// "PositionY",
+// "Step",
+// "TabIndex",
+// "Width"
+// },
+// new Object[]
+// {
+// Boolean.valueOf(bEnabled),
+// new Integer(14),
+///* TODO: WRONG!*/ "HID:WIZARDS_HID_DLGFORM_CMDALIGNRIGHT",
+// "1",
+// new Integer(nXPos + nBtnWidth),
+// new Integer(nYPos),
+// IControlStep,
+// new Short(curtabindex++),
+// new Integer(16)
+// });
+
+ DefaultListModel imageModel = new DefaultListModel();
+ for (int i = 0; i < HelpTexts.length; i++)
+ {
+ imageModel.addElement(new Integer(i));
+ }
+ String sMainArrangementHeader = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 41); // "Arrangement of the main form"
+ m_aArrangeList[0] = new ArrangeButtonList(0, imageModel, sMainArrangementHeader);
+
+ String sSubArrangementHeader = CurUnoDialog.m_oResource.getResText(UIConsts.RID_FORM + 42); // "Arrangement of the sub form"
+ m_aArrangeList[1] = new ArrangeButtonList(1, imageModel, sSubArrangementHeader);
+ enableAlignControlGroup(false);
+ }
+
+ public int getSelectedArrangement(int _formindex)
+ {
+ return m_aArrangeList[_formindex].m_aButtonList.getSelected() + 1;
+ }
+
+ private class LayoutRenderer implements ButtonList.IImageRenderer
+ {
+ int Index = 1;
+
+ public Object[] getImageUrls(Object listitem)
+ {
+
+ int ResId = UIConsts.RID_IMG_FORM + (2 * ((Integer) listitem).intValue());
+ Index++;
+ return new Integer[]
+ {
+ new Integer(ResId), new Integer(ResId + 1)
+ };
+// String s = CurUnoDialog.getWizardImageUrl(ResId, ResId + 1); //((Integer)listitem).intValue(), )sBitmapPath + "/Arrange_" + (((Integer)listitem).intValue() + 1) + ".gif";
+// return s;
+ }
+
+ public String render(Object listItem)
+ {
+ if (listItem == null)
+ {
+ return "";
+ }
+ return HelpTexts[((Integer) listItem).intValue()];
+
+ }
+ }
+
+ public void enableSubFormImageList(boolean _bdoEnable)
+ {
+ m_aArrangeList[1].m_aButtonList.setenabled(_bdoEnable);
+ CurUnoDialog.setControlProperty("lnLabelPlacment_2", "Enabled", new Boolean(_bdoEnable));
+ }
+
+ public short getAlignValue()
+ {
+ Short IAlignValue = null;
+ if (optAlignLeft.getState())
+ {
+ IAlignValue = new Short((short) 0);
+ }
+ else
+ {
+ IAlignValue = new Short((short) 2);
+ }
+ return IAlignValue.shortValue();
+ }
+
+ public void alignLabelControls()
+ {
+ try
+ {
+ short iAlignValue = getAlignValue();
+ for (int m = 0; m < curFormDocument.oControlForms.size(); m++)
+ {
+ FormDocument.ControlForm curControlForm = (FormDocument.ControlForm) curFormDocument.oControlForms.get(m);
+ if (curControlForm.getArrangemode() == FormWizard.SOCOLUMNARLEFT)
+ {
+ Control[] LabelControls = curControlForm.getLabelControls();
+ for (int n = 0; n < LabelControls.length; n++)
+ {
+ LabelControls[n].xPropertySet.setPropertyValue("Align", new Short(iAlignValue));
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void enableAlignControlGroup(boolean _bEnableAlignControlGroup)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(flnLabelPlacement), "Enabled", new Boolean(_bEnableAlignControlGroup));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignLeft), "Enabled", new Boolean(_bEnableAlignControlGroup));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignRight), "Enabled", new Boolean(_bEnableAlignControlGroup));
+ }
+
+// private class ArrangeImageList implements XItemListener
+// {
+//
+// private int formindex;
+// private ImageList m_aButtonList = null; // new ImageList();
+//
+// public ArrangeImageList(int _formindex, ListModel model, String _sArrangementHeader)
+// {
+// formindex = _formindex;
+// Integer YPos = new Integer(SOBASEIMAGEYPOSITION + _formindex * SOIMAGELISTHEIGHT);
+// // Label ArrangementHeader ----------------------
+// CurUnoDialog.insertFixedLine("lnLabelPlacment_" + (_formindex + 1),
+// new String[]
+// {
+// "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+// },
+// new Object[]
+// {
+// UIConsts.INTEGERS[8], _sArrangementHeader, new Integer(97), YPos, IControlStep, new Short(curtabindex++), new Integer(207)
+// });
+//
+// int nypos = SOBASEIMAGEYPOSITION + 12 + _formindex * SOIMAGELISTHEIGHT;
+// m_aButtonList = new ImageList();
+// m_aButtonList.setPos(new Size(107, nypos));
+// m_aButtonList.setImageSize(new Size(26, 26));
+// m_aButtonList.setCols(4);
+// m_aButtonList.setRows(1);
+// m_aButtonList.m_aControlName = "ImageList_" + formindex;
+// m_aButtonList.setStep(new Short((short) FormWizard.SOCONTROL_PAGE));
+// m_aButtonList.setShowButtons(false);
+// m_aButtonList.setRenderer(new LayoutRenderer());
+// m_aButtonList.setSelectionGap(new Size(2, 2));
+// m_aButtonList.setGap(new Size(3, 3));
+// m_aButtonList.scaleImages = Boolean.FALSE;
+// m_aButtonList.tabIndex = (int) curtabindex++;
+// m_aButtonList.helpURL = 34453 + (formindex * 4);
+//
+// m_aButtonList.setListModel(model);
+// m_aButtonList.create(CurUnoDialog);
+// m_aButtonList.setSelected(FormWizard.SOGRID - 1);
+// m_aButtonList.addItemListener(this);
+// }
+//
+// public void setToLeftAlign()
+// {
+// Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignLeft), "State", new Short((short) 1));
+// }
+//
+// /* (non-Javadoc)
+// * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+// */
+// public void addListDataListener(ListDataListener arg0)
+// {
+// // TODO Auto-generated method stub
+// }
+//
+// public void itemStateChanged(ItemEvent arg0)
+// {
+// try
+// {
+// if (m_aArrangeList[formindex].m_aButtonList.isenabled())
+// {
+// boolean bEnableAlignControlGroup;
+// if (curFormDocument.oControlForms.size() == 2)
+// {
+// final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1);
+// final int nSelected1 = (m_aArrangeList[1].m_aButtonList.getSelected() + 1);
+//
+// bEnableAlignControlGroup = ((nSelected0 == FormWizard.SOCOLUMNARLEFT) ||
+// (nSelected1 == FormWizard.SOCOLUMNARLEFT));
+// }
+// else
+// {
+// final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1);
+// bEnableAlignControlGroup = (nSelected0 == FormWizard.SOCOLUMNARLEFT);
+// }
+// enableAlignControlGroup(bEnableAlignControlGroup);
+// final Short nBorderType = CurUnoDialog.getBorderType();
+// final int nSelected = m_aButtonList.getSelected() + 1;
+// ((FormDocument.ControlForm) curFormDocument.oControlForms.get(formindex)).initialize(nSelected, nBorderType);
+// }
+// }
+// catch (RuntimeException e)
+// {
+// e.printStackTrace();
+// }
+// }
+//
+// /* (non-Javadoc)
+// * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
+// */
+// public void contentsChanged(ListDataEvent arg0)
+// {
+// // TODO Auto-generated method stub
+// }
+//
+// /* (non-Javadoc)
+// * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
+// */
+// public void intervalAdded(ListDataEvent arg0)
+// {
+// // TODO Auto-generated method stub
+// }
+//
+// /* (non-Javadoc)
+// * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
+// */
+// public void intervalRemoved(ListDataEvent arg0)
+// {
+// // TODO Auto-generated method stub
+// }
+//
+// /* (non-Javadoc)
+// * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+// */
+// public void disposing(EventObject arg0)
+// {
+// // TODO Auto-generated method stub
+// }
+// }
+
+ private class ArrangeButtonList implements XItemListener
+ {
+
+ private int formindex;
+ private ButtonList m_aButtonList = null; // new ImageList();
+
+ public ArrangeButtonList(int _formindex, ListModel model, String _sArrangementHeader)
+ {
+ formindex = _formindex;
+ Integer YPos = new Integer(SOBASEIMAGEYPOSITION + _formindex * SOIMAGELISTHEIGHT);
+ // Label ArrangementHeader ----------------------
+ CurUnoDialog.insertFixedLine("lnLabelPlacment_" + (_formindex + 1),
+ new String[]
+ {
+ "Height",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8],
+ _sArrangementHeader,
+ new Integer(97),
+ YPos,
+ IControlStep,
+ new Short(curtabindex++),
+ new Integer(207)
+ });
+
+ int nypos = SOBASEIMAGEYPOSITION + 12 - 5 + _formindex * SOIMAGELISTHEIGHT;
+ m_aButtonList = new ButtonList();
+ m_aButtonList.setPos(new Size(107, nypos));
+ m_aButtonList.setButtonSize(new Size(26 + 6, 26 + 5));
+ m_aButtonList.setCols(4);
+ m_aButtonList.setRows(1);
+ m_aButtonList.setName( "ButtonList_" + formindex );
+ m_aButtonList.setStep(Short.valueOf((short) FormWizard.SOCONTROL_PAGE));
+ m_aButtonList.setShowButtons(false); // shows a button line at ''wrong'' position like |<| 1..4/4 |>|
+ m_aButtonList.setRenderer(new LayoutRenderer());
+ m_aButtonList.setSelectionGap(new Size(2, 2));
+ m_aButtonList.setGap(new Size(3, 3));
+// m_aButtonList.scaleImages = Boolean.FALSE;
+ m_aButtonList.tabIndex = (int) curtabindex++;
+ m_aButtonList.helpURL = 34453 + (formindex * 4);
+
+ m_aButtonList.setListModel(model);
+ m_aButtonList.create(CurUnoDialog);
+ m_aButtonList.setSelected(FormWizard.SOGRID - 1);
+ m_aButtonList.addItemListener(this);
+ }
+
+ public void setToLeftAlign()
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optAlignLeft), "State", new Short((short) 1));
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.ListModel#addListDataListener(javax.swing.event.ListDataListener)
+ */
+ public void addListDataListener(ListDataListener arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ try
+ {
+ if (m_aArrangeList[formindex].m_aButtonList.isenabled())
+ {
+ boolean bEnableAlignControlGroup;
+ if (curFormDocument.oControlForms.size() == 2)
+ {
+ final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1);
+ final int nSelected1 = (m_aArrangeList[1].m_aButtonList.getSelected() + 1);
+
+ bEnableAlignControlGroup = ((nSelected0 == FormWizard.SOCOLUMNARLEFT) ||
+ (nSelected1 == FormWizard.SOCOLUMNARLEFT));
+ }
+ else
+ {
+ final int nSelected0 = (m_aArrangeList[0].m_aButtonList.getSelected() + 1);
+ bEnableAlignControlGroup = (nSelected0 == FormWizard.SOCOLUMNARLEFT);
+ }
+ enableAlignControlGroup(bEnableAlignControlGroup);
+ final Short nBorderType = CurUnoDialog.getBorderType();
+ final int nSelected = m_aButtonList.getSelected() + 1;
+ ((FormDocument.ControlForm) curFormDocument.oControlForms.get(formindex)).initialize(nSelected, nBorderType);
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
+ */
+ public void contentsChanged(ListDataEvent arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
+ */
+ public void intervalAdded(ListDataEvent arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
+ */
+ public void intervalRemoved(ListDataEvent arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/form/form.component b/wizards/com/sun/star/wizards/form/form.component
new file mode 100644
index 000000000000..3f010d8bc88f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/form.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.wizards.form.CallFormWizard$FormWizardImplementation">
+ <service name="com.sun.star.wizards.form.CallFormWizard"/>
+ </implementation>
+</component>
diff --git a/wizards/com/sun/star/wizards/form/makefile.mk b/wizards/com/sun/star/wizards/form/makefile.mk
new file mode 100644
index 000000000000..b6366607324e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/form/makefile.mk
@@ -0,0 +1,75 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = form
+PACKAGE = com$/sun$/star$/wizards$/form
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/form
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+#SRS2NAME = dbwizres
+#SRC2FILES= dbwizres.src
+#RESLIB2SRSFILES= $(SRS)$/dbwizres.srs
+#RESLIB2NAME= dbw
+
+JAVAFILES= \
+ CallFormWizard.java \
+ Finalizer.java \
+ FormWizard.java \
+ DataEntrySetter.java \
+ FieldLinker.java \
+ FormConfiguration.java \
+ FormControlArranger.java\
+ FormDocument.java \
+ StyleApplier.java \
+ UIControlArranger.java \
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/form.component
+
+$(MISC)/form.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ form.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt form.component
diff --git a/wizards/com/sun/star/wizards/letter/CGLetter.java b/wizards/com/sun/star/wizards/letter/CGLetter.java
new file mode 100644
index 000000000000..986d43bac5bb
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/CGLetter.java
@@ -0,0 +1,66 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGLetter extends ConfigGroup
+{
+
+ public int cp_Style;
+ public boolean cp_BusinessPaper;
+ public CGPaperElementLocation cp_CompanyLogo = new CGPaperElementLocation();
+ public CGPaperElementLocation cp_CompanyAddress = new CGPaperElementLocation();
+ public boolean cp_PaperCompanyAddressReceiverField;
+ public boolean cp_PaperFooter;
+ public double cp_PaperFooterHeight;
+ public int cp_Norm;
+ public boolean cp_PrintCompanyLogo;
+ public boolean cp_PrintCompanyAddressReceiverField;
+ public boolean cp_PrintLetterSigns;
+ public boolean cp_PrintSubjectLine;
+ public boolean cp_PrintSalutation;
+ public boolean cp_PrintBendMarks;
+ public boolean cp_PrintGreeting;
+ public boolean cp_PrintFooter;
+ public String cp_Salutation;
+ public String cp_Greeting;
+ public int cp_SenderAddressType;
+ public String cp_SenderCompanyName;
+ public String cp_SenderStreet;
+ public String cp_SenderPostCode;
+ public String cp_SenderState;
+ public String cp_SenderCity;
+ public int cp_ReceiverAddressType;
+ public String cp_Footer;
+ public boolean cp_FooterOnlySecondPage;
+ public boolean cp_FooterPageNumbers;
+ public int cp_CreationType;
+ public String cp_TemplateName;
+ public String cp_TemplatePath;
+}
diff --git a/wizards/com/sun/star/wizards/letter/CGLetterWizard.java b/wizards/com/sun/star/wizards/letter/CGLetterWizard.java
new file mode 100644
index 000000000000..0a6cfd90ab42
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/CGLetterWizard.java
@@ -0,0 +1,39 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGLetterWizard extends ConfigGroup
+{
+
+ public int cp_LetterType;
+ public CGLetter cp_BusinessLetter = new CGLetter();
+ public CGLetter cp_PrivateOfficialLetter = new CGLetter();
+ public CGLetter cp_PrivateLetter = new CGLetter();
+}
diff --git a/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.java b/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.java
new file mode 100644
index 000000000000..7c8b28bc93ed
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/CGPaperElementLocation.java
@@ -0,0 +1,40 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGPaperElementLocation extends ConfigGroup
+{
+
+ public boolean cp_Display;
+ public double cp_Width;
+ public double cp_Height;
+ public double cp_X;
+ public double cp_Y;
+}
diff --git a/wizards/com/sun/star/wizards/letter/CallWizard.java b/wizards/com/sun/star/wizards/letter/CallWizard.java
new file mode 100644
index 000000000000..ff993c61e506
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/CallWizard.java
@@ -0,0 +1,240 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.task.XJob;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.Type;
+
+/**
+ * This class capsulates the class, that implements the minimal component, a factory for
+ * creating the service (<CODE>__getServiceFactory</CODE>).
+ *
+ * @author $author$
+ * @version $Revision: 1.3.192.1 $
+ */
+public class CallWizard
+{
+
+ /**
+ * Gives a factory for creating the service. This method is called by the
+ * <code>JavaLoader</code>
+ *
+ * <p></p>
+ *
+ * @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 tree
+ * structures) of a single registry key accessible.
+ *
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the component.
+ *
+ * @see com.sun.star.comp.loader.JavaLoader#
+ */
+ public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey)
+ {
+ XSingleServiceFactory xsingleservicefactory = null;
+
+ if (stringImplementationName.equals(WizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__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 WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor
+ {
+
+ /**
+ * The constructor of the inner class has a XMultiServiceFactory parameter.
+ *
+ * @param xmultiservicefactoryInitialization A special service factory could be
+ * introduced while initializing.
+ */
+ public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization)
+ {
+ xmultiservicefactory = xmultiservicefactoryInitialization;
+
+ if (xmultiservicefactory != null)
+ {
+ }
+ }
+
+ /**
+ * Execute Wizard
+ *
+ * @param str only valid parameter is 'start' at the moment.
+ */
+ public void trigger(String str)
+ {
+ if (str.equalsIgnoreCase("start"))
+ {
+ LetterWizardDialogImpl lw = new LetterWizardDialogImpl(xmultiservicefactory);
+ if (!LetterWizardDialogImpl.running)
+ {
+ lw.startWizard(xmultiservicefactory, null);
+ }
+ }
+ } //*******************************************
+ /**
+ * The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "com.sun.star.wizards.letter.CallWizard";
+ /**
+ * The service manager, that gives access to all registered services.
+ */
+ private 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 method returns an array of all supported service names.
+ *
+ * @return Array of supported service names.
+ */
+ public java.lang.String[] getSupportedServiceNames()
+ {
+ String[] stringSupportedServiceNames = new String[1];
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /**
+ * This method returns an array of bytes, that can be used to unambiguously
+ * distinguish between two sets of types, e.g. to realise hashing functionality
+ * when the object is introspected. Two objects that return the same ID also
+ * have to return the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to return an empty
+ * sequence. Important: If the object aggregates other objects the ID has to be
+ * unique for the whole combination of objects.
+ *
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = ("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /**
+ * Return the class name of the component.
+ *
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (WizardImplementation.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.
+ */
+ public com.sun.star.uno.Type[] getTypes()
+ {
+ Type[] typeReturn =
+ {
+ };
+
+ try
+ {
+ typeReturn = new Type[]
+ {
+ new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class)
+ };
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/LetterDocument.java b/wizards/com/sun/star/wizards/letter/LetterDocument.java
new file mode 100644
index 000000000000..0c981c6e066e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterDocument.java
@@ -0,0 +1,330 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.text.*;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.table.BorderLine;
+import com.sun.star.text.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.drawing.XShape;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.style.NumberingType;
+import com.sun.star.style.ParagraphAdjust;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.style.XStyle;
+
+public class LetterDocument extends TextDocument
+{
+
+ XDesktop xDesktop;
+ boolean keepLogoFrame = true;
+ boolean keepBendMarksFrame = true;
+ boolean keepLetterSignsFrame = true;
+ boolean keepSenderAddressRepeatedFrame = true;
+ boolean keepAddressFrame = true;
+
+ public LetterDocument(XMultiServiceFactory xMSF, XTerminateListener listener)
+ {
+ super(xMSF, listener, "WIZARD_LIVE_PREVIEW");
+ }
+
+ public XWindowPeer getWindowPeer()
+ {
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xTextDocument);
+ return xWindowPeer;
+ }
+
+ public void switchElement(String sElement, boolean bState)
+ {
+ try
+ {
+ TextSectionHandler mySectionHandler = new TextSectionHandler(xMSF, xTextDocument);
+ Object oSection = mySectionHandler.xTextSectionsSupplier.getTextSections().getByName(sElement);
+ Helper.setUnoPropertyValue(oSection, "IsVisible", new Boolean(bState));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void updateDateFields()
+ {
+ TextFieldHandler FH = new TextFieldHandler(xMSFDoc, xTextDocument);
+ FH.updateDateFields();
+ }
+
+ public void switchFooter(String sPageStyle, boolean bState, boolean bPageNumber, String sText)
+ {
+ if (xTextDocument != null)
+ {
+ try
+ {
+ xTextDocument.lockControllers();
+ XStyleFamiliesSupplier xStyleFamiliesSupplier = (XStyleFamiliesSupplier) com.sun.star.uno.UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument);
+ com.sun.star.container.XNameAccess xNameAccess = null;
+ xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
+
+ com.sun.star.container.XNameContainer xPageStyleCollection = null;
+ xPageStyleCollection = (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xNameAccess.getByName("PageStyles"));
+
+ XText xFooterText;
+ XStyle xPageStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, xPageStyleCollection.getByName(sPageStyle));
+
+ if (bState)
+ {
+ Helper.setUnoPropertyValue(xPageStyle, "FooterIsOn", new Boolean(true));
+ xFooterText = (XText) UnoRuntime.queryInterface(XText.class, Helper.getUnoPropertyValue(xPageStyle, "FooterText"));
+ xFooterText.setString(sText);
+ if (bPageNumber)
+ {
+ //Adding the Page Number
+ XTextCursor myCursor = xFooterText.createTextCursor();
+ myCursor.gotoEnd(false);
+ xFooterText.insertControlCharacter(myCursor, ControlCharacter.PARAGRAPH_BREAK, false);
+ XPropertySet xCursorPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, myCursor);
+ xCursorPSet.setPropertyValue("ParaAdjust", ParagraphAdjust.CENTER);
+ XTextField xPageNumberField = (XTextField) UnoRuntime.queryInterface(XTextField.class, xMSFDoc.createInstance("com.sun.star.text.TextField.PageNumber"));
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageNumberField);
+ xPSet.setPropertyValue("SubType", PageNumberType.CURRENT);
+ xPSet.setPropertyValue("NumberingType", new Short(NumberingType.ARABIC));
+ xFooterText.insertTextContent(xFooterText.getEnd(), xPageNumberField, false);
+ }
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(xPageStyle, "FooterIsOn", new Boolean(false));
+ }
+ xTextDocument.unlockControllers();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public boolean hasElement(String sElement)
+ {
+ if (xTextDocument != null)
+ {
+ TextSectionHandler SH = new TextSectionHandler(xMSF, xTextDocument);
+ return SH.hasTextSectionByName(sElement);
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public void switchUserField(String sFieldName, String sNewContent, boolean bState)
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument);
+ if (bState)
+ {
+ myFieldHandler.changeUserFieldContent(sFieldName, sNewContent);
+ }
+ else
+ {
+ myFieldHandler.changeUserFieldContent(sFieldName, "");
+ }
+ }
+
+ public void fillSenderWithUserData()
+ {
+ try
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSFDoc, xTextDocument);
+ Object oUserDataAccess = Configuration.getConfigurationRoot(xMSF, "org.openoffice.UserProfile/Data", false);
+ myFieldHandler.changeUserFieldContent("Company", (String) Helper.getUnoObjectbyName(oUserDataAccess, "o"));
+ myFieldHandler.changeUserFieldContent("Street", (String) Helper.getUnoObjectbyName(oUserDataAccess, "street"));
+ myFieldHandler.changeUserFieldContent("PostCode", (String) Helper.getUnoObjectbyName(oUserDataAccess, "postalcode"));
+ myFieldHandler.changeUserFieldContent("City", (String) Helper.getUnoObjectbyName(oUserDataAccess, "l"));
+ myFieldHandler.changeUserFieldContent("State", (String) Helper.getUnoObjectbyName(oUserDataAccess, "st"));
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void killEmptyUserFields()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument);
+ myFieldHandler.removeUserFieldByContent("");
+ }
+
+ public void killEmptyFrames()
+ {
+ try
+ {
+ if (!keepLogoFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Company Logo", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ if (!keepBendMarksFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Bend Marks", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ if (!keepLetterSignsFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Letter Signs", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ if (!keepSenderAddressRepeatedFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Sender Address Repeated", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+ if (!keepAddressFrame)
+ {
+ XTextFrame xTF = TextFrameHandler.getFrameByName("Sender Address", xTextDocument);
+ if (xTF != null)
+ {
+ xTF.dispose();
+ }
+ }
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ }
+
+ public class BusinessPaperObject
+ {
+
+ public int iWidth;
+ public int iHeight;
+ public int iXPos;
+ public int iYPos;
+ XTextFrame xFrame;
+ XShape xShape;
+
+ public BusinessPaperObject(String FrameText, int Width, int Height, int XPos, int YPos)
+ {
+
+ iWidth = Width;
+ iHeight = Height;
+ iXPos = XPos;
+ iYPos = YPos;
+
+ try
+ {
+ xFrame = (XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, xMSFDoc.createInstance("com.sun.star.text.TextFrame"));
+ xShape = (XShape) UnoRuntime.queryInterface(XShape.class, xFrame);
+
+ setFramePosition();
+ Helper.setUnoPropertyValue(xShape, "AnchorType", TextContentAnchorType.AT_PAGE);
+ Helper.setUnoPropertyValue(xShape, "SizeType", new Short(SizeType.FIX));
+
+ Helper.setUnoPropertyValue(xFrame, "TextWrap", WrapTextMode.THROUGHT);
+ Helper.setUnoPropertyValue(xFrame, "Opaque", Boolean.TRUE);
+ Helper.setUnoPropertyValue(xFrame, "BackColor", new Integer(15790320));
+
+ BorderLine myBorder = new BorderLine();
+ myBorder.OuterLineWidth = 0;
+ Helper.setUnoPropertyValue(xFrame, "LeftBorder", myBorder);
+ Helper.setUnoPropertyValue(xFrame, "RightBorder", myBorder);
+ Helper.setUnoPropertyValue(xFrame, "TopBorder", myBorder);
+ Helper.setUnoPropertyValue(xFrame, "BottomBorder", myBorder);
+ Helper.setUnoPropertyValue(xFrame, "Print", new Boolean(false));
+
+ XTextCursor xTextCursor = xTextDocument.getText().createTextCursor();
+ xTextCursor.gotoEnd(true);
+ XText xText = xTextDocument.getText();
+ xText.insertTextContent(xTextCursor, xFrame, false);
+
+ XText xFrameText = xFrame.getText();
+ XTextCursor xFrameCursor = xFrameText.createTextCursor();
+ XPropertySet xCursorProps = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xFrameCursor);
+ xCursorProps.setPropertyValue("CharWeight", new Float(com.sun.star.awt.FontWeight.BOLD));
+ xCursorProps.setPropertyValue("CharColor", new Integer(16777215));
+ xCursorProps.setPropertyValue("CharFontName", new String("Albany"));
+ xCursorProps.setPropertyValue("CharHeight", new Float(18));
+
+ xFrameText.insertString(xFrameCursor, FrameText, false);
+
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void setFramePosition()
+ {
+ Helper.setUnoPropertyValue(xFrame, "HoriOrient", new Short(HoriOrientation.NONE));
+ Helper.setUnoPropertyValue(xFrame, "VertOrient", new Short(VertOrientation.NONE));
+ Helper.setUnoPropertyValue(xFrame, "Height", new Integer(iHeight));
+ Helper.setUnoPropertyValue(xFrame, "Width", new Integer(iWidth));
+ Helper.setUnoPropertyValue(xFrame, "HoriOrientPosition", new Integer(iXPos));
+ Helper.setUnoPropertyValue(xFrame, "VertOrientPosition", new Integer(iYPos));
+ Helper.setUnoPropertyValue(xFrame, "HoriOrientRelation", new Short(RelOrientation.PAGE_FRAME));
+ Helper.setUnoPropertyValue(xFrame, "VertOrientRelation", new Short(RelOrientation.PAGE_FRAME));
+ }
+
+ public void removeFrame()
+ {
+ if (xFrame != null)
+ {
+ try
+ {
+ xTextDocument.getText().removeTextContent(xFrame);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialog.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialog.java
new file mode 100644
index 000000000000..ffdec06942a6
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialog.java
@@ -0,0 +1,913 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.ui.*;
+
+public abstract class LetterWizardDialog extends WizardDialog implements LetterWizardDialogConst, UIConsts
+{
+ //GUI Components as Class members.
+ XRadioButton optBusinessLetter;
+ XListBox lstBusinessStyle;
+ XCheckBox chkBusinessPaper;
+ XRadioButton optPrivOfficialLetter;
+ XListBox lstPrivOfficialStyle;
+ XRadioButton optPrivateLetter;
+ XListBox lstPrivateStyle;
+ XFixedText lblBusinessStyle;
+ XFixedText lblPrivOfficialStyle;
+ XFixedText lblTitle1;
+ XFixedText lblPrivateStyle;
+ XFixedText lblIntroduction;
+ //Image Control
+ XControl ImageControl3;
+ XCheckBox chkPaperCompanyLogo;
+ XNumericField numLogoHeight;
+ XNumericField numLogoX;
+ XNumericField numLogoWidth;
+ XNumericField numLogoY;
+ XCheckBox chkPaperCompanyAddress;
+ XNumericField numAddressHeight;
+ XNumericField numAddressX;
+ XNumericField numAddressWidth;
+ XNumericField numAddressY;
+ XCheckBox chkCompanyReceiver;
+ XCheckBox chkPaperFooter;
+ XNumericField numFooterHeight;
+ XFixedText lblLogoHeight;
+ XFixedText lblLogoWidth;
+ //Fixed Line
+ XControl FixedLine5;
+ //Fixed Line
+ XControl FixedLine6;
+ XFixedText lblFooterHeight;
+ XFixedText lblLogoX;
+ XFixedText lblLogoY;
+ XFixedText lblAddressHeight;
+ XFixedText lblAddressWidth;
+ XFixedText lblAddressX;
+ XFixedText lblAddressY;
+ XFixedText lblTitle2;
+ XListBox lstLetterNorm;
+ XCheckBox chkUseLogo;
+ XCheckBox chkUseAddressReceiver;
+ XCheckBox chkUseSigns;
+ XCheckBox chkUseSubject;
+ XCheckBox chkUseSalutation;
+ XComboBox lstSalutation;
+ XCheckBox chkUseBendMarks;
+ XCheckBox chkUseGreeting;
+ XComboBox lstGreeting;
+ XCheckBox chkUseFooter;
+ XFixedText lblLetterNorm;
+ XFixedText lblTitle3;
+ XRadioButton optSenderPlaceholder;
+ XRadioButton optSenderDefine;
+ XTextComponent txtSenderName;
+ XTextComponent txtSenderStreet;
+ XTextComponent txtSenderPostCode;
+ XTextComponent txtSenderState;
+ XTextComponent txtSenderCity;
+ XRadioButton optReceiverPlaceholder;
+ XRadioButton optReceiverDatabase;
+ XFixedText lblSenderAddress;
+ //Fixed Line
+ XControl FixedLine2;
+ XFixedText lblReceiverAddress;
+ XFixedText lblSenderName;
+ XFixedText lblSenderStreet;
+ XFixedText lblPostCodeCity;
+ XFixedText lblTitle4;
+ XTextComponent txtFooter;
+ XCheckBox chkFooterNextPages;
+ XCheckBox chkFooterPageNumbers;
+ XFixedText lblFooter;
+ XFixedText lblTitle5;
+ XTextComponent txtTemplateName;
+ //File Control
+ XControl fileTemplatePath;
+ XRadioButton optCreateLetter;
+ XRadioButton optMakeChanges;
+ XFixedText lblFinalExplanation1;
+ XFixedText lblProceed;
+ XFixedText lblFinalExplanation2;
+ //Image Control
+ XControl ImageControl2;
+ XFixedText lblTemplateName;
+ XFixedText lblTemplatePath;
+ XFixedText lblTitle6;
+ XFixedText Label9;
+ //Font Descriptors as Class members.
+ FontDescriptor fontDescriptor1 = new FontDescriptor();
+ FontDescriptor fontDescriptor2 = new FontDescriptor();
+ FontDescriptor fontDescriptor5 = new FontDescriptor();
+ FontDescriptor fontDescriptor6 = new FontDescriptor(); //Resources Object
+ LetterWizardDialogResources resources;
+
+ public LetterWizardDialog(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, HIDMAIN);
+ //Load Resources
+ resources = new LetterWizardDialogResources(xmsf);
+
+
+ //set dialog properties...
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(210), Boolean.TRUE, "LetterWizardDialog", new Integer(104), new Integer(52), INTEGERS[1], new Short((short) 1), resources.resLetterWizardDialog_title, new Integer(310)
+ });
+
+
+
+ //Set member- FontDescriptors...
+ fontDescriptor1.Weight = 150;
+ fontDescriptor1.Underline = com.sun.star.awt.FontUnderline.SINGLE;
+ fontDescriptor2.Weight = 100;
+ fontDescriptor5.Weight = 100;
+ fontDescriptor6.Weight = 150;
+ }
+ //build components
+ public void buildStep1()
+ {
+ optBusinessLetter = insertRadioButton("optBusinessLetter", OPTBUSINESSLETTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 1), resources.resoptBusinessLetter_value, "optBusinessLetter", new Integer(97), new Integer(28), INTEGERS[1], new Short((short) 1), new Integer(184)
+ });
+ optPrivOfficialLetter = insertRadioButton("optPrivOfficialLetter", OPTPRIVOFFICIALLETTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 2), resources.resoptPrivOfficialLetter_value, "optPrivOfficialLetter", new Integer(97), new Integer(74), INTEGERS[1], new Short((short) 2), new Integer(184)
+ });
+ optPrivateLetter = insertRadioButton("optPrivateLetter", OPTPRIVATELETTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 3), resources.resoptPrivateLetter_value, "optPrivateLetter", new Integer(97), new Integer(106), INTEGERS[1], new Short((short) 3), new Integer(184)
+ });
+ lstBusinessStyle = insertListBox("lstBusinessStyle", LSTBUSINESSSTYLE_ACTION_PERFORMED, LSTBUSINESSSTYLE_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 4), "lstBusinessStyle", new Integer(180), INTEGER_40, INTEGERS[1], new Short((short) 4), new Integer(74)
+ });
+ chkBusinessPaper = insertCheckBox("chkBusinessPaper", CHKBUSINESSPAPER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 5), resources.reschkBusinessPaper_value, "chkBusinessPaper", new Integer(110), new Integer(56), new Short((short) 0), INTEGERS[1], new Short((short) 5), new Integer(168)
+ });
+ lstPrivOfficialStyle = insertListBox("lstPrivOfficialStyle", LSTPRIVOFFICIALSTYLE_ACTION_PERFORMED, LSTPRIVOFFICIALSTYLE_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 6), "lstPrivOfficialStyle", new Integer(180), new Integer(86), INTEGERS[1], new Short((short) 6), new Integer(74)
+ });
+ lstPrivateStyle = insertListBox("lstPrivateStyle", LSTPRIVATESTYLE_ACTION_PERFORMED, LSTPRIVATESTYLE_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 7), "lstPrivateStyle", new Integer(180), new Integer(118), INTEGERS[1], new Short((short) 7), new Integer(74)
+ });
+ lblBusinessStyle = insertLabel("lblBusinessStyle",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblBusinessStyle_value, "lblBusinessStyle", new Integer(110), new Integer(42), INTEGERS[1], new Short((short) 48), new Integer(60)
+ });
+ lblPrivOfficialStyle = insertLabel("lblPrivOfficialStyle",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPrivOfficialStyle_value, "lblPrivOfficialStyle", new Integer(110), new Integer(88), INTEGERS[1], new Short((short) 49), new Integer(60)
+ });
+ lblTitle1 = insertLabel("lblTitle1",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle1_value, Boolean.TRUE, "lblTitle1", new Integer(91), INTEGERS[8], INTEGERS[1], new Short((short) 55), new Integer(212)
+ });
+ lblPrivateStyle = insertLabel("lblPrivateStyle",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPrivateStyle_value, "lblPrivateStyle", new Integer(110), new Integer(120), INTEGERS[1], new Short((short) 74), new Integer(60)
+ });
+ lblIntroduction = insertLabel("lblIntroduction",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(39), resources.reslblIntroduction_value, Boolean.TRUE, "lblIntroduction", new Integer(104), new Integer(145), INTEGERS[1], new Short((short) 80), new Integer(199)
+ });
+ ImageControl3 = insertInfoImage(92, 145, 1);
+
+// ImageControl3 = insertImage("ImageControl3",
+// new String[] {"Border", "Height", "ImageURL", "Name", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"},
+// new Object[] { new Short((short)0), INTEGERS[10],"private:resource/dbu/image/19205","ImageControl3",new Integer(92),new Integer(145),Boolean.FALSE,INTEGERS[1],new Short((short)81),INTEGERS[10]}
+// );
+ }
+
+ public void buildStep2()
+ {
+ chkPaperCompanyLogo = insertCheckBox("chkPaperCompanyLogo", CHKPAPERCOMPANYLOGO_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 8), resources.reschkPaperCompanyLogo_value, "chkPaperCompanyLogo", new Integer(97), new Integer(28), new Short((short) 0), INTEGERS[2], new Short((short) 8), new Integer(68)
+ });
+ numLogoHeight = insertNumericField("numLogoHeight", NUMLOGOHEIGHT_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "StrictFormat", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 9), "numLogoHeight", new Integer(138), INTEGER_40, Boolean.TRUE, INTEGERS[2], Boolean.TRUE, new Short((short) 9), INTEGERS[3], new Integer(30)
+ });
+ numLogoX = insertNumericField("numLogoX", NUMLOGOX_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 10), "numLogoX", new Integer(266), INTEGER_40, Boolean.TRUE, INTEGERS[2], new Short((short) 10), INTEGERS[0], new Integer(30)
+ });
+ numLogoWidth = insertNumericField("numLogoWidth", NUMLOGOWIDTH_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 11), "numLogoWidth", new Integer(138), new Integer(56), Boolean.TRUE, INTEGERS[2], new Short((short) 11), new Double(3.8), new Integer(30)
+ });
+ numLogoY = insertNumericField("numLogoY", NUMLOGOY_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 12), "numLogoY", new Integer(266), new Integer(56), Boolean.TRUE, INTEGERS[2], new Short((short) 12), new Double(-3.4), new Integer(30)
+ });
+ chkPaperCompanyAddress = insertCheckBox("chkPaperCompanyAddress", CHKPAPERCOMPANYADDRESS_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 13), resources.reschkPaperCompanyAddress_value, "chkPaperCompanyAddress", new Integer(98), new Integer(84), new Short((short) 0), INTEGERS[2], new Short((short) 13), new Integer(68)
+ });
+ numAddressHeight = insertNumericField("numAddressHeight", NUMADDRESSHEIGHT_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "StrictFormat", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 14), "numAddressHeight", new Integer(138), new Integer(96), Boolean.TRUE, INTEGERS[2], Boolean.TRUE, new Short((short) 14), INTEGERS[3], new Integer(30)
+ });
+ numAddressX = insertNumericField("numAddressX", NUMADDRESSX_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 15), "numAddressX", new Integer(266), new Integer(96), Boolean.TRUE, INTEGERS[2], new Short((short) 15), new Double(3.8), new Integer(30)
+ });
+ numAddressWidth = insertNumericField("numAddressWidth", NUMADDRESSWIDTH_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 16), "numAddressWidth", new Integer(138), new Integer(112), Boolean.TRUE, INTEGERS[2], new Short((short) 16), new Double(13.8), new Integer(30)
+ });
+ numAddressY = insertNumericField("numAddressY", NUMADDRESSY_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 17), "numAddressY", new Integer(266), new Integer(112), Boolean.TRUE, INTEGERS[2], new Short((short) 17), new Double(-3.4), new Integer(30)
+ });
+ chkCompanyReceiver = insertCheckBox("chkCompanyReceiver", CHKCOMPANYRECEIVER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 18), resources.reschkCompanyReceiver_value, "chkCompanyReceiver", new Integer(103), new Integer(131), new Short((short) 0), INTEGERS[2], new Short((short) 18), new Integer(185)
+ });
+ chkPaperFooter = insertCheckBox("chkPaperFooter", CHKPAPERFOOTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 19), resources.reschkPaperFooter_value, "chkPaperFooter", new Integer(97), new Integer(158), new Short((short) 0), INTEGERS[2], new Short((short) 19), new Integer(68)
+ });
+ numFooterHeight = insertNumericField("numFooterHeight", NUMFOOTERHEIGHT_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Spin", "Step", "TabIndex", "Value", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 20), "numFooterHeight", new Integer(236), new Integer(156), Boolean.TRUE, INTEGERS[2], new Short((short) 20), INTEGERS[5], new Integer(30)
+ });
+ lblLogoHeight = insertLabel("lblLogoHeight",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLogoHeight_value, "lblLogoHeight", new Integer(103), new Integer(42), INTEGERS[2], new Short((short) 68), new Integer(32)
+ });
+ lblLogoWidth = insertLabel("lblLogoWidth",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLogoWidth_value, "lblLogoWidth", new Integer(103), new Integer(58), INTEGERS[2], new Short((short) 69), new Integer(32)
+ });
+ FixedLine5 = insertFixedLine("FixedLine5",
+ new String[]
+ {
+ "Height", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[2], "FixedLine5", new Integer(90), new Integer(78), INTEGERS[2], new Short((short) 70), new Integer(215)
+ });
+ FixedLine6 = insertFixedLine("FixedLine6",
+ new String[]
+ {
+ "Height", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[2], "FixedLine6", new Integer(90), new Integer(150), INTEGERS[2], new Short((short) 71), new Integer(215)
+ });
+ lblFooterHeight = insertLabel("lblFooterHeight",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblFooterHeight_value, "lblFooterHeight", new Integer(200), new Integer(158), INTEGERS[2], new Short((short) 72), new Integer(32)
+ });
+ lblLogoX = insertLabel("lblLogoX",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLogoX_value, "lblLogoX", new Integer(170), new Integer(42), INTEGERS[2], new Short((short) 84), new Integer(94)
+ });
+ lblLogoY = insertLabel("lblLogoY",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLogoY_value, "lblLogoY", new Integer(170), new Integer(58), INTEGERS[2], new Short((short) 85), new Integer(94)
+ });
+ lblAddressHeight = insertLabel("lblAddressHeight",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblAddressHeight_value, "lblAddressHeight", new Integer(103), new Integer(98), INTEGERS[2], new Short((short) 86), new Integer(32)
+ });
+ lblAddressWidth = insertLabel("lblAddressWidth",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblAddressWidth_value, "lblAddressWidth", new Integer(103), new Integer(114), INTEGERS[2], new Short((short) 87), new Integer(32)
+ });
+ lblAddressX = insertLabel("lblAddressX",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblAddressX_value, "lblAddressX", new Integer(170), new Integer(98), INTEGERS[2], new Short((short) 88), new Integer(94)
+ });
+ lblAddressY = insertLabel("lblAddressY",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblAddressY_value, "lblAddressY", new Integer(170), new Integer(114), INTEGERS[2], new Short((short) 89), new Integer(94)
+ });
+ lblTitle2 = insertLabel("lblTitle2",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle2_value, Boolean.TRUE, "lblTitle2", new Integer(91), INTEGERS[8], INTEGERS[2], new Short((short) 91), new Integer(212)
+ });
+ }
+
+ public void buildStep3()
+ {
+ lstLetterNorm = insertListBox("lstLetterNorm", LSTLETTERNORM_ACTION_PERFORMED, LSTLETTERNORM_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 21), "lstLetterNorm", new Integer(210), new Integer(34), INTEGERS[3], new Short((short) 21), new Integer(74)
+ });
+ chkUseLogo = insertCheckBox("chkUseLogo", CHKUSELOGO_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 22), resources.reschkUseLogo_value, "chkUseLogo", new Integer(97), new Integer(54), new Short((short) 0), INTEGERS[3], new Short((short) 22), new Integer(212)
+ });
+ chkUseAddressReceiver = insertCheckBox("chkUseAddressReceiver", CHKUSEADDRESSRECEIVER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 23), resources.reschkUseAddressReceiver_value, "chkUseAddressReceiver", new Integer(97), new Integer(69), new Short((short) 0), INTEGERS[3], new Short((short) 23), new Integer(212)
+ });
+ chkUseSigns = insertCheckBox("chkUseSigns", CHKUSESIGNS_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 24), resources.reschkUseSigns_value, "chkUseSigns", new Integer(97), new Integer(82), new Short((short) 0), INTEGERS[3], new Short((short) 24), new Integer(212)
+ });
+ chkUseSubject = insertCheckBox("chkUseSubject", CHKUSESUBJECT_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 25), resources.reschkUseSubject_value, "chkUseSubject", new Integer(97), new Integer(98), new Short((short) 0), INTEGERS[3], new Short((short) 25), new Integer(212)
+ });
+ chkUseSalutation = insertCheckBox("chkUseSalutation", CHKUSESALUTATION_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 26), resources.reschkUseSalutation_value, "chkUseSalutation", new Integer(97), new Integer(113), new Short((short) 0), INTEGERS[3], new Short((short) 26), new Integer(66)
+ });
+ lstSalutation = insertComboBox("lstSalutation", LSTSALUTATION_ACTION_PERFORMED, LSTSALUTATION_ITEM_CHANGED, LSTSALUTATION_TEXT_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 27), "lstSalutation", new Integer(210), new Integer(110), INTEGERS[3], new Short((short) 27), new Integer(74)
+ });
+ chkUseBendMarks = insertCheckBox("chkUseBendMarks", CHKUSEBENDMARKS_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 28), resources.reschkUseBendMarks_value, "chkUseBendMarks", new Integer(97), new Integer(127), new Short((short) 0), INTEGERS[3], new Short((short) 28), new Integer(212)
+ });
+ chkUseGreeting = insertCheckBox("chkUseGreeting", CHKUSEGREETING_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 29), resources.reschkUseGreeting_value, "chkUseGreeting", new Integer(97), new Integer(142), new Short((short) 0), INTEGERS[3], new Short((short) 29), new Integer(66)
+ });
+ lstGreeting = insertComboBox("lstGreeting", LSTGREETING_ACTION_PERFORMED, LSTGREETING_ITEM_CHANGED, LSTGREETING_TEXT_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID + 30), "lstGreeting", new Integer(210), new Integer(141), INTEGERS[3], new Short((short) 30), new Integer(74)
+ });
+ chkUseFooter = insertCheckBox("chkUseFooter", CHKUSEFOOTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 31), resources.reschkUseFooter_value, "chkUseFooter", new Integer(97), new Integer(158), new Short((short) 0), INTEGERS[3], new Short((short) 31), new Integer(212)
+ });
+ lblLetterNorm = insertLabel("lblLetterNorm",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_16, resources.reslblLetterNorm_value, Boolean.TRUE, "lblLetterNorm", new Integer(97), new Integer(28), INTEGERS[3], new Short((short) 50), new Integer(109)
+ });
+ lblTitle3 = insertLabel("lblTitle3",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle3_value, Boolean.TRUE, "lblTitle3", new Integer(91), INTEGERS[8], INTEGERS[3], new Short((short) 90), new Integer(212)
+ });
+ }
+
+ public void buildStep4()
+ {
+ optSenderPlaceholder = insertRadioButton("optSenderPlaceholder", OPTSENDERPLACEHOLDER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 32), resources.resoptSenderPlaceholder_value, "optSenderPlaceholder", new Integer(104), new Integer(42), INTEGERS[4], new Short((short) 32), new Integer(149)
+ });
+ optSenderDefine = insertRadioButton("optSenderDefine", OPTSENDERDEFINE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 33), resources.resoptSenderDefine_value, "optSenderDefine", new Integer(104), new Integer(54), INTEGERS[4], new Short((short) 33), new Integer(149)
+ });
+ txtSenderName = insertTextField("txtSenderName", TXTSENDERNAME_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 34), "txtSenderName", new Integer(182), new Integer(67), INTEGERS[4], new Short((short) 34), new Integer(119)
+ });
+ txtSenderStreet = insertTextField("txtSenderStreet", TXTSENDERSTREET_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 35), "txtSenderStreet", new Integer(182), new Integer(81), INTEGERS[4], new Short((short) 35), new Integer(119)
+ });
+ txtSenderPostCode = insertTextField("txtSenderPostCode", TXTSENDERPOSTCODE_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 36), "txtSenderPostCode", new Integer(182), new Integer(95), INTEGERS[4], new Short((short) 36), new Integer(25)
+ });
+ txtSenderState = insertTextField("txtSenderState", TXTSENDERSTATE_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 37), "txtSenderState", new Integer(211), new Integer(95), INTEGERS[4], new Short((short) 37), new Integer(21)
+ });
+ txtSenderCity = insertTextField("txtSenderCity", TXTSENDERCITY_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 38), "txtSenderCity", new Integer(236), new Integer(95), INTEGERS[4], new Short((short) 38), new Integer(65)
+ });
+ optReceiverPlaceholder = insertRadioButton("optReceiverPlaceholder", OPTRECEIVERPLACEHOLDER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 39), resources.resoptReceiverPlaceholder_value, "optReceiverPlaceholder", new Integer(104), new Integer(145), INTEGERS[4], new Short((short) 39), new Integer(200)
+ });
+ optReceiverDatabase = insertRadioButton("optReceiverDatabase", OPTRECEIVERDATABASE_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 40), resources.resoptReceiverDatabase_value, "optReceiverDatabase", new Integer(104), new Integer(157), INTEGERS[4], new Short((short) 40), new Integer(200)
+ });
+ lblSenderAddress = insertLabel("lblSenderAddress",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderAddress_value, "lblSenderAddress", new Integer(97), new Integer(28), INTEGERS[4], new Short((short) 64), new Integer(136)
+ });
+ FixedLine2 = insertFixedLine("FixedLine2",
+ new String[]
+ {
+ "Height", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[5], "FixedLine2", new Integer(90), new Integer(126), INTEGERS[4], new Short((short) 75), new Integer(212)
+ });
+ lblReceiverAddress = insertLabel("lblReceiverAddress",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblReceiverAddress_value, "lblReceiverAddress", new Integer(97), new Integer(134), INTEGERS[4], new Short((short) 76), new Integer(136)
+ });
+ lblSenderName = insertLabel("lblSenderName",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderName_value, "lblSenderName", new Integer(113), new Integer(69), INTEGERS[4], new Short((short) 77), new Integer(68)
+ });
+ lblSenderStreet = insertLabel("lblSenderStreet",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSenderStreet_value, "lblSenderStreet", new Integer(113), new Integer(82), INTEGERS[4], new Short((short) 78), new Integer(68)
+ });
+ lblPostCodeCity = insertLabel("lblPostCodeCity",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPostCodeCity_value, "lblPostCodeCity", new Integer(113), new Integer(97), INTEGERS[4], new Short((short) 79), new Integer(68)
+ });
+ lblTitle4 = insertLabel("lblTitle4",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle4_value, Boolean.TRUE, "lblTitle4", new Integer(91), INTEGERS[8], INTEGERS[4], new Short((short) 92), new Integer(212)
+ });
+ }
+
+ public void buildStep5()
+ {
+ txtFooter = insertTextField("txtFooter", TXTFOOTER_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(47), HelpIds.getHelpIdString(HID + 41), Boolean.TRUE, "txtFooter", new Integer(97), INTEGER_40, INTEGERS[5], new Short((short) 41), new Integer(203)
+ });
+ chkFooterNextPages = insertCheckBox("chkFooterNextPages", CHKFOOTERNEXTPAGES_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 42), resources.reschkFooterNextPages_value, "chkFooterNextPages", new Integer(97), new Integer(92), new Short((short) 0), INTEGERS[5], new Short((short) 42), new Integer(202)
+ });
+ chkFooterPageNumbers = insertCheckBox("chkFooterPageNumbers", CHKFOOTERPAGENUMBERS_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 43), resources.reschkFooterPageNumbers_value, "chkFooterPageNumbers", new Integer(97), new Integer(106), new Short((short) 0), INTEGERS[5], new Short((short) 43), new Integer(201)
+ });
+ lblFooter = insertLabel("lblFooter",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor5, INTEGERS[8], resources.reslblFooter_value, "lblFooter", new Integer(97), new Integer(28), INTEGERS[5], new Short((short) 52), new Integer(116)
+ });
+ lblTitle5 = insertLabel("lblTitle5",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle5_value, Boolean.TRUE, "lblTitle5", new Integer(91), INTEGERS[8], INTEGERS[5], new Short((short) 93), new Integer(212)
+ });
+ }
+
+ public void buildStep6()
+ {
+ txtTemplateName = insertTextField("txtTemplateName", TXTTEMPLATENAME_TEXT_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID + 44), "txtTemplateName", new Integer(202), new Integer(56), INTEGERS[6], new Short((short) 44), resources.restxtTemplateName_value, new Integer(100)
+ });
+ optCreateLetter = insertRadioButton("optCreateLetter", OPTCREATELETTER_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 45), resources.resoptCreateLetter_value, "optCreateLetter", new Integer(104), new Integer(111), INTEGERS[6], new Short((short) 50), new Integer(198)
+ });
+ optMakeChanges = insertRadioButton("optMakeChanges", OPTMAKECHANGES_ITEM_CHANGED,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID + 46), resources.resoptMakeChanges_value, "optMakeChanges", new Integer(104), new Integer(123), INTEGERS[6], new Short((short) 51), new Integer(198)
+ });
+ lblFinalExplanation1 = insertLabel("lblFinalExplanation1",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(26), resources.reslblFinalExplanation1_value, Boolean.TRUE, "lblFinalExplanation1", new Integer(97), new Integer(28), INTEGERS[6], new Short((short) 52), new Integer(205)
+ });
+ lblProceed = insertLabel("lblProceed",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblProceed_value, "lblProceed", new Integer(97), new Integer(100), INTEGERS[6], new Short((short) 53), new Integer(204)
+ });
+ lblFinalExplanation2 = insertLabel("lblFinalExplanation2",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(33), resources.reslblFinalExplanation2_value, Boolean.TRUE, "lblFinalExplanation2", new Integer(104), new Integer(145), INTEGERS[6], new Short((short) 54), new Integer(199)
+ });
+ ImageControl2 = insertImage("ImageControl2",
+ new String[]
+ {
+ "Border", "Height", "ImageURL", "Name", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 0), INTEGERS[10], "private:resource/dbu/image/19205", "ImageControl2", new Integer(92), new Integer(145), Boolean.FALSE, INTEGERS[6], new Short((short) 66), INTEGERS[10]
+ });
+ lblTemplateName = insertLabel("lblTemplateName",
+ new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblTemplateName_value, "lblTemplateName", new Integer(97), new Integer(58), INTEGERS[6], new Short((short) 82), new Integer(101)
+ });
+ lblTitle6 = insertLabel("lblTitle6",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor6, INTEGER_16, resources.reslblTitle6_value, Boolean.TRUE, "lblTitle6", new Integer(91), INTEGERS[8], INTEGERS[6], new Short((short) 94), new Integer(212)
+ });
+
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.java
new file mode 100755
index 000000000000..b94ac6f0c0ac
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogConst.java
@@ -0,0 +1,93 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+public interface LetterWizardDialogConst
+{
+
+ public static final String OPTBUSINESSLETTER_ITEM_CHANGED = "optBusinessLetterItemChanged";
+ public static final String OPTPRIVOFFICIALLETTER_ITEM_CHANGED = "optPrivOfficialLetterItemChanged";
+ public static final String OPTPRIVATELETTER_ITEM_CHANGED = "optPrivateLetterItemChanged";
+ public static final String LSTBUSINESSSTYLE_ACTION_PERFORMED = null;
+ public static final String LSTBUSINESSSTYLE_ITEM_CHANGED = "lstBusinessStyleItemChanged";
+ public static final String LSTPRIVOFFICIALSTYLE_ACTION_PERFORMED = null;
+ public static final String LSTPRIVOFFICIALSTYLE_ITEM_CHANGED = "lstPrivOfficialStyleItemChanged";
+ public static final String CHKBUSINESSPAPER_ITEM_CHANGED = "chkBusinessPaperItemChanged";
+ public static final String LSTPRIVATESTYLE_ACTION_PERFORMED = null;
+ public static final String LSTPRIVATESTYLE_ITEM_CHANGED = "lstPrivateStyleItemChanged";
+ public static final String CHKPAPERCOMPANYLOGO_ITEM_CHANGED = "chkPaperCompanyLogoItemChanged";
+ public static final String NUMLOGOHEIGHT_TEXT_CHANGED = "numLogoHeightTextChanged";
+ public static final String NUMLOGOX_TEXT_CHANGED = "numLogoXTextChanged";
+ public static final String NUMLOGOWIDTH_TEXT_CHANGED = "numLogoWidthTextChanged";
+ public static final String NUMLOGOY_TEXT_CHANGED = "numLogoYTextChanged";
+ public static final String CHKCOMPANYRECEIVER_ITEM_CHANGED = "chkCompanyReceiverItemChanged";
+ public static final String CHKPAPERFOOTER_ITEM_CHANGED = "chkPaperFooterItemChanged";
+ public static final String NUMFOOTERHEIGHT_TEXT_CHANGED = "numFooterHeightTextChanged";
+ public static final String CHKPAPERCOMPANYADDRESS_ITEM_CHANGED = "chkPaperCompanyAddressItemChanged";
+ public static final String NUMADDRESSHEIGHT_TEXT_CHANGED = "numAddressHeightTextChanged";
+ public static final String NUMADDRESSX_TEXT_CHANGED = "numAddressXTextChanged";
+ public static final String NUMADDRESSWIDTH_TEXT_CHANGED = "numAddressWidthTextChanged";
+ public static final String NUMADDRESSY_TEXT_CHANGED = "numAddressYTextChanged";
+ public static final String LSTLETTERNORM_ACTION_PERFORMED = null;
+ public static final String LSTLETTERNORM_ITEM_CHANGED = "lstLetterNormItemChanged";
+ public static final String CHKUSELOGO_ITEM_CHANGED = "chkUseLogoItemChanged";
+ public static final String CHKUSEADDRESSRECEIVER_ITEM_CHANGED = "chkUseAddressReceiverItemChanged";
+ public static final String CHKUSESIGNS_ITEM_CHANGED = "chkUseSignsItemChanged";
+ public static final String CHKUSESUBJECT_ITEM_CHANGED = "chkUseSubjectItemChanged";
+ public static final String CHKUSEBENDMARKS_ITEM_CHANGED = "chkUseBendMarksItemChanged";
+ public static final String CHKUSEFOOTER_ITEM_CHANGED = "chkUseFooterItemChanged";
+ public static final String CHKUSESALUTATION_ITEM_CHANGED = "chkUseSalutationItemChanged";
+ public static final String CHKUSEGREETING_ITEM_CHANGED = "chkUseGreetingItemChanged";
+ public static final String LSTSALUTATION_ACTION_PERFORMED = null;
+ public static final String LSTSALUTATION_ITEM_CHANGED = "lstSalutationItemChanged";
+ public static final String LSTSALUTATION_TEXT_CHANGED = "lstSalutationTextChanged";
+ public static final String LSTGREETING_ACTION_PERFORMED = null;
+ public static final String LSTGREETING_ITEM_CHANGED = "lstGreetingItemChanged";
+ public static final String LSTGREETING_TEXT_CHANGED = "lstGreetingTextChanged";
+ public static final String OPTSENDERPLACEHOLDER_ITEM_CHANGED = "optSenderPlaceholderItemChanged";
+ public static final String OPTSENDERDEFINE_ITEM_CHANGED = "optSenderDefineItemChanged";
+ public static final String OPTRECEIVERPLACEHOLDER_ITEM_CHANGED = "optReceiverPlaceholderItemChanged";
+ public static final String OPTRECEIVERDATABASE_ITEM_CHANGED = "optReceiverDatabaseItemChanged";
+ public static final String TXTSENDERNAME_TEXT_CHANGED = "txtSenderNameTextChanged";
+ public static final String TXTSENDERSTREET_TEXT_CHANGED = "txtSenderStreetTextChanged";
+ public static final String TXTSENDERCITY_TEXT_CHANGED = "txtSenderCityTextChanged";
+ public static final String TXTSENDERPOSTCODE_TEXT_CHANGED = "txtSenderPostCodeTextChanged";
+ public static final String TXTSENDERSTATE_TEXT_CHANGED = "txtSenderStateTextChanged";
+ public static final String TXTFOOTER_TEXT_CHANGED = "txtFooterTextChanged";
+ public static final String CHKFOOTERNEXTPAGES_ITEM_CHANGED = "chkFooterNextPagesItemChanged";
+ public static final String CHKFOOTERPAGENUMBERS_ITEM_CHANGED = "chkFooterPageNumbersItemChanged";
+ public static final String TXTTEMPLATENAME_TEXT_CHANGED = "txtTemplateNameTextChanged";
+ public static final String OPTCREATELETTER_ITEM_CHANGED = "optCreateLetterItemChanged";
+ public static final String OPTMAKECHANGES_ITEM_CHANGED = "optMakeChangesItemChanged";
+ public static final String FILETEMPLATEPATH_TEXT_CHANGED = null;
+ public static final String imageURLImageControl1 = null;
+ public static final String imageURLImageControl2 = null;
+ public static final String imageURLImageControl3 = null;
+ public static final int HID = 40768;
+ public static final int HIDMAIN = 40820;
+} \ No newline at end of file
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogEvents.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogEvents.java
new file mode 100644
index 000000000000..0a6407dbde1d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogEvents.java
@@ -0,0 +1,89 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+public interface LetterWizardDialogEvents
+{
+
+ public static final String OPTBUSINESSLETTER_ITEM_CHANGED = null;
+ public static final String OPTPRIVOFFICIALLETTER_ITEM_CHANGED = null;
+ public static final String OPTPRIVATELETTER_ITEM_CHANGED = null;
+ public static final String LSTBUSINESSSTYLE_ACTION_PERFORMED = null;
+ public static final String LSTBUSINESSSTYLE_ITEM_CHANGED = null;
+ public static final String LSTPRIVOFFICIALSTYLE_ACTION_PERFORMED = null;
+ public static final String LSTPRIVOFFICIALSTYLE_ITEM_CHANGED = null;
+ public static final String CHKBUSINESSPAPER_ITEM_CHANGED = null;
+ public static final String LSTPRIVATESTYLE_ACTION_PERFORMED = null;
+ public static final String LSTPRIVATESTYLE_ITEM_CHANGED = null;
+ public static final String CHKPAPERCOMPANYLOGO_ITEM_CHANGED = null;
+ public static final String NUMLOGOHEIGHT_TEXT_CHANGED = null;
+ public static final String NUMLOGOX_TEXT_CHANGED = null;
+ public static final String NUMLOGOWIDTH_TEXT_CHANGED = null;
+ public static final String NUMLOGOY_TEXT_CHANGED = null;
+ public static final String CHKCOMPANYRECEIVER_ITEM_CHANGED = null;
+ public static final String CHKPAPERFOOTER_ITEM_CHANGED = null;
+ public static final String NUMFOOTERHEIGHT_TEXT_CHANGED = null;
+ public static final String CHKPAPERCOMPANYADDRESS_ITEM_CHANGED = null;
+ public static final String NUMADDRESSHEIGHT_TEXT_CHANGED = null;
+ public static final String NUMADDRESSX_TEXT_CHANGED = null;
+ public static final String NUMADDRESSWIDTH_TEXT_CHANGED = null;
+ public static final String NUMADDRESSY_TEXT_CHANGED = null;
+ public static final String LSTLETTERNORM_ACTION_PERFORMED = null;
+ public static final String LSTLETTERNORM_ITEM_CHANGED = null;
+ public static final String CHKUSELOGO_ITEM_CHANGED = null;
+ public static final String CHKUSEADDRESSRECEIVER_ITEM_CHANGED = null;
+ public static final String CHKUSESIGNS_ITEM_CHANGED = null;
+ public static final String CHKUSESUBJECT_ITEM_CHANGED = null;
+ public static final String CHKUSEBENDMARKS_ITEM_CHANGED = null;
+ public static final String CHKUSEFOOTER_ITEM_CHANGED = null;
+ public static final String CHKUSESALUTATION_ITEM_CHANGED = null;
+ public static final String CHKUSEGREETING_ITEM_CHANGED = null;
+ public static final String LSTSALUTATION_ACTION_PERFORMED = null;
+ public static final String LSTSALUTATION_ITEM_CHANGED = null;
+ public static final String LSTGREETING_ACTION_PERFORMED = null;
+ public static final String LSTGREETING_ITEM_CHANGED = null;
+ public static final String OPTSENDERFIXED_ITEM_CHANGED = null;
+ public static final String OPTSENDERPLACEHOLDER_ITEM_CHANGED = null;
+ public static final String OPTSENDERDEFINE_ITEM_CHANGED = null;
+ public static final String OPTRECEIVERPLACEHOLDER_ITEM_CHANGED = null;
+ public static final String OPTRECEIVERDATABASE_ITEM_CHANGED = null;
+ public static final String TXTSENDERNAME_TEXT_CHANGED = null;
+ public static final String TXTSENDERSTREET_TEXT_CHANGED = null;
+ public static final String TXTSENDERCITY_TEXT_CHANGED = null;
+ public static final String TXTSENDERPOSTCODE_TEXT_CHANGED = null;
+ public static final String TXTFOOTER_TEXT_CHANGED = null;
+ public static final String CHKFOOTERNEXTPAGES_ITEM_CHANGED = null;
+ public static final String CHKFOOTERPAGENUMBERS_ITEM_CHANGED = null;
+ public static final String TXTTEMPLATENAME_TEXT_CHANGED = null;
+ public static final String OPTCREATELETTER_ITEM_CHANGED = null;
+ public static final String OPTMAKECHANGES_ITEM_CHANGED = null;
+ public static final String FILETEMPLATEPATH_TEXT_CHANGED = null;
+ public static final String imageURLImageControl1 = "images/ImageControl1";
+ public static final String imageURLImageControl2 = "images/ImageControl2";
+ public static final String imageURLImageControl3 = "images/ImageControl3";
+}
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java
new file mode 100644
index 000000000000..9fb6c2e4b2e7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogImpl.java
@@ -0,0 +1,1543 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import java.util.Vector;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.document.MacroExecMode;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.document.XDocumentPropertiesSupplier;
+import com.sun.star.ucb.CommandAbortedException;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.text.*;
+import com.sun.star.wizards.common.*;
+import com.sun.star.task.XInteractionHandler;
+import com.sun.star.text.XTextFrame;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.document.*;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.wizards.ui.event.*;
+import com.sun.star.wizards.common.Helper;
+
+public class LetterWizardDialogImpl extends LetterWizardDialog
+{
+
+ protected void enterStep(int OldStep, int NewStep)
+ {
+ }
+
+ protected void leaveStep(int OldStep, int NewStep)
+ {
+ }
+ static LetterDocument myLetterDoc;
+ static boolean running;
+ XMultiServiceFactory xmsf;
+ XTextDocument xTextDocument;
+ PathSelection myPathSelection;
+ CGLetterWizard myConfig;
+ Vector mainDA = new Vector();
+ Vector letterDA = new Vector();
+ Vector businessDA = new Vector();
+ String[][] BusinessFiles;
+ String[][] OfficialFiles;
+ String[][] PrivateFiles;
+ String[] Norms;
+ String[] NormPaths;
+ String[] NormNames;
+ String sTemplatePath;
+ String sUserTemplatePath;
+ String sBitmapPath;
+ String sLetterPath;
+ String sLetterLangPackPath;
+ String sWorkPath;
+ String sCurrentNorm;
+ String sPath;
+ boolean bEditTemplate;
+ boolean bSaveSuccess = false;
+ private boolean filenameChanged = false;
+ LetterDocument.BusinessPaperObject BusCompanyLogo = null;
+ LetterDocument.BusinessPaperObject BusCompanyAddress = null;
+ LetterDocument.BusinessPaperObject BusCompanyAddressReceiver = null;
+ LetterDocument.BusinessPaperObject BusFooter = null;
+ final static int RM_TYPESTYLE = 1;
+ final static int RM_BUSINESSPAPER = 2;
+ final static int RM_ELEMENTS = 3;
+ final static int RM_SENDERRECEIVER = 4;
+ final static int RM_FOOTER = 5;
+ final static int RM_FINALSETTINGS = 6;
+
+ public LetterWizardDialogImpl(XMultiServiceFactory xmsf)
+ {
+ super(xmsf);
+ this.xmsf = xmsf;
+ }
+
+ public static void main(String args[])
+ {
+ //only being called when starting wizard remotely
+ String ConnectStr = "uno:socket,host=127.0.0.1,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ XMultiServiceFactory xLocMSF = null;
+ try
+ {
+ xLocMSF = Desktop.connect(ConnectStr);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ catch (java.lang.Exception e)
+ {
+ e.printStackTrace();
+ }
+ LetterWizardDialogImpl lw = new LetterWizardDialogImpl(xLocMSF);
+ lw.startWizard(xLocMSF, null);
+
+ }
+
+ public void startWizard(XMultiServiceFactory xMSF, Object[] CurPropertyValue)
+ {
+
+ running = true;
+ try
+ {
+ //Number of steps on WizardDialog:
+ setMaxStep(6);
+
+ //instatiate The Document Frame for the Preview
+ myLetterDoc = new LetterDocument(xMSF, this);
+
+ //create the dialog:
+ drawNaviBar();
+ buildStep1();
+ buildStep2();
+ buildStep3();
+ buildStep4();
+ buildStep5();
+ buildStep6();
+
+ initializePaths();
+ initializeNorms();
+ initializeSalutation();
+ initializeGreeting();
+
+
+ //special Control for setting the save Path:
+ insertPathSelectionControl();
+
+ //load the last used settings from the registry and apply listeners to the controls:
+ initConfiguration();
+
+ //set the language according to the Linguistic
+ int oL = getOfficeLinguistic();
+ myConfig.cp_BusinessLetter.cp_Norm = oL;
+ myConfig.cp_PrivateOfficialLetter.cp_Norm = oL;
+ myConfig.cp_PrivateLetter.cp_Norm = oL;
+ initializeTemplates(xMSF);
+
+ if (myConfig.cp_BusinessLetter.cp_Greeting.equals(""))
+ {
+ myConfig.cp_BusinessLetter.cp_Greeting = resources.GreetingLabels[0];
+ }
+ if (myConfig.cp_BusinessLetter.cp_Salutation.equals(""))
+ {
+ myConfig.cp_BusinessLetter.cp_Salutation = resources.SalutationLabels[0];
+ }
+ if (myConfig.cp_PrivateOfficialLetter.cp_Greeting.equals(""))
+ {
+ myConfig.cp_PrivateOfficialLetter.cp_Greeting = resources.GreetingLabels[1];
+ }
+ if (myConfig.cp_PrivateOfficialLetter.cp_Salutation.equals(""))
+ {
+ myConfig.cp_PrivateOfficialLetter.cp_Salutation = resources.SalutationLabels[1];
+ }
+ if (myConfig.cp_PrivateLetter.cp_Greeting.equals(""))
+ {
+ myConfig.cp_PrivateLetter.cp_Greeting = resources.GreetingLabels[2];
+ }
+ if (myConfig.cp_PrivateLetter.cp_Salutation.equals(""))
+ {
+ myConfig.cp_PrivateLetter.cp_Salutation = resources.SalutationLabels[2];
+ }
+
+ //update the dialog UI according to the loaded Configuration
+ updateUI();
+
+ if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(""))
+ {
+ myPathSelection.initializePath();
+ }
+
+ XWindow xContainerWindow = myLetterDoc.xFrame.getContainerWindow();
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xContainerWindow);
+ createWindowPeer(xWindowPeer);
+
+ //add the Roadmap to the dialog:
+ insertRoadmap();
+
+ //load the last used document and apply last used settings:
+ setConfiguration();
+
+ //If the configuration does not define Greeting/Salutation yet choose a default
+ setDefaultForGreetingAndSalutation();
+
+ //disable funtionality that is not supported by the template:
+ initializeElements();
+
+ //disable the document, so that the user cannot change anything:
+ myLetterDoc.xFrame.getComponentWindow().setEnable(false);
+
+ executeDialog(myLetterDoc.xFrame);
+ removeTerminateListener();
+ closeDocument();
+ running = false;
+
+ }
+ catch (Exception exception)
+ {
+ removeTerminateListener();
+ exception.printStackTrace(System.out);
+ running = false;
+ return;
+ }
+ }
+
+ public void cancelWizard()
+ {
+ xDialog.endExecute();
+ running = false;
+ }
+
+ public boolean finishWizard()
+ {
+ switchToStep(getCurrentStep(), getMaxStep());
+ try
+ {
+ //myLetterDoc.xTextDocument.lockControllers();
+ FileAccess fileAccess = new FileAccess(xMSF);
+ sPath = myPathSelection.getSelectedPath();
+ if (sPath.equals(""))
+ {
+ myPathSelection.triggerPathPicker();
+ sPath = myPathSelection.getSelectedPath();
+ }
+ sPath = fileAccess.getURL(sPath);
+
+ //first, if the filename was not changed, thus
+ //it is coming from a saved session, check if the
+ // file exists and warn the user.
+ if (!filenameChanged)
+ {
+ if (fileAccess.exists(sPath, true))
+ {
+
+ int answer = SystemDialog.showMessageBox(xMSF, xControl.getPeer(), "MessBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, resources.resOverwriteWarning);
+ if (answer == 3) // user said: no, do not overwrite....
+ {
+ return false;
+ }
+ }
+ }
+ myLetterDoc.setWizardTemplateDocInfo(resources.resLetterWizardDialog_title, resources.resTemplateDescription);
+ myLetterDoc.killEmptyUserFields();
+ myLetterDoc.keepLogoFrame = (chkUseLogo.getState() != 0);
+ if ((chkBusinessPaper.getState() != 0) && (chkPaperCompanyLogo.getState() != 0))
+ {
+ myLetterDoc.keepLogoFrame = false;
+ }
+ myLetterDoc.keepBendMarksFrame = (chkUseBendMarks.getState() != 0);
+ myLetterDoc.keepLetterSignsFrame = (chkUseSigns.getState() != 0);
+ myLetterDoc.keepSenderAddressRepeatedFrame = (chkUseAddressReceiver.getState() != 0);
+
+ if (optBusinessLetter.getState())
+ {
+ if ((chkBusinessPaper.getState() != 0) && (chkCompanyReceiver.getState() != 0))
+ {
+ myLetterDoc.keepSenderAddressRepeatedFrame = false;
+ }
+ if ((chkBusinessPaper.getState() != 0) && (chkPaperCompanyAddress.getState() != 0))
+ {
+ myLetterDoc.keepAddressFrame = false;
+ }
+ }
+
+ myLetterDoc.killEmptyFrames();
+
+
+ bSaveSuccess = OfficeDocument.store(xMSF, xTextDocument, sPath, "writer8_template", false);
+
+ if (bSaveSuccess)
+ {
+ saveConfiguration();
+ XInteractionHandler xIH = (XInteractionHandler) UnoRuntime.queryInterface(XInteractionHandler.class, xMSF.createInstance("com.sun.star.comp.uui.UUIInteractionHandler"));
+ PropertyValue loadValues[] = new PropertyValue[4];
+ loadValues[0] = new PropertyValue();
+ loadValues[0].Name = "AsTemplate";
+ loadValues[1] = new PropertyValue();
+ loadValues[1].Name = "MacroExecutionMode";
+ loadValues[1].Value = new Short(MacroExecMode.ALWAYS_EXECUTE);
+ loadValues[2] = new PropertyValue();
+ loadValues[2].Name = "UpdateDocMode";
+ loadValues[2].Value = new Short(com.sun.star.document.UpdateDocMode.FULL_UPDATE);
+ loadValues[3] = new PropertyValue();
+ loadValues[3].Name = "InteractionHandler";
+ loadValues[3].Value = xIH;
+
+ if (bEditTemplate)
+ {
+ loadValues[0].Value = Boolean.FALSE;
+ }
+ else
+ {
+ loadValues[0].Value = Boolean.TRUE;
+ }
+ Object oDoc = OfficeDocument.load(Desktop.getDesktop(xMSF), sPath, "_default", loadValues);
+ XTextDocument xTextDocument = (com.sun.star.text.XTextDocument) oDoc;
+ XMultiServiceFactory xDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ ViewHandler myViewHandler = new ViewHandler(xDocMSF, xTextDocument);
+ myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.OPTIMAL));
+ }
+ else
+ {
+ //TODO: Error Handling
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ finally
+ {
+ xDialog.endExecute();
+ running = false;
+ }
+ return true;
+ }
+
+ public void closeDocument()
+ {
+ try
+ {
+ //xComponent.dispose();
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, myLetterDoc.xFrame);
+ xCloseable.close(false);
+ }
+ catch (CloseVetoException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void optBusinessLetterItemChanged()
+ {
+ DataAware.setDataObject(letterDA, myConfig.cp_BusinessLetter, true);
+ setControlProperty("lblBusinessStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lstBusinessStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("chkBusinessPaper", "Enabled", Boolean.TRUE);
+ setControlProperty("lblPrivOfficialStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstPrivOfficialStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPrivateStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstPrivateStyle", "Enabled", Boolean.FALSE);
+ lstBusinessStyleItemChanged();
+ enableSenderReceiver();
+ setPossibleFooter(true);
+ if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(""))
+ {
+ myPathSelection.initializePath();
+ }
+ }
+
+ public void optPrivOfficialLetterItemChanged()
+ {
+ DataAware.setDataObject(letterDA, myConfig.cp_PrivateOfficialLetter, true);
+ setControlProperty("lblBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("chkBusinessPaper", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPrivOfficialStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lstPrivOfficialStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lblPrivateStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstPrivateStyle", "Enabled", Boolean.FALSE);
+ lstPrivOfficialStyleItemChanged();
+ disableBusinessPaper();
+ enableSenderReceiver();
+ setPossibleFooter(true);
+ if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(""))
+ {
+ myPathSelection.initializePath();
+ }
+ }
+
+ public void optPrivateLetterItemChanged()
+ {
+ DataAware.setDataObject(letterDA, myConfig.cp_PrivateLetter, true);
+ setControlProperty("lblBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstBusinessStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("chkBusinessPaper", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPrivOfficialStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lstPrivOfficialStyle", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPrivateStyle", "Enabled", Boolean.TRUE);
+ setControlProperty("lstPrivateStyle", "Enabled", Boolean.TRUE);
+ lstPrivateStyleItemChanged();
+ disableBusinessPaper();
+ disableSenderReceiver();
+ setPossibleFooter(false);
+ if (myPathSelection.xSaveTextBox.getText().equalsIgnoreCase(""))
+ {
+ myPathSelection.initializePath();
+ }
+ }
+
+ public void optSenderPlaceholderItemChanged()
+ {
+ setControlProperty("lblSenderName", "Enabled", Boolean.FALSE);
+ setControlProperty("lblSenderStreet", "Enabled", Boolean.FALSE);
+ setControlProperty("lblPostCodeCity", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderName", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderStreet", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderPostCode", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderState", "Enabled", Boolean.FALSE);
+ setControlProperty("txtSenderCity", "Enabled", Boolean.FALSE);
+ myLetterDoc.fillSenderWithUserData();
+ }
+
+ public void optSenderDefineItemChanged()
+ {
+ setControlProperty("lblSenderName", "Enabled", Boolean.TRUE);
+ setControlProperty("lblSenderStreet", "Enabled", Boolean.TRUE);
+ setControlProperty("lblPostCodeCity", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderName", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderStreet", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderPostCode", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderState", "Enabled", Boolean.TRUE);
+ setControlProperty("txtSenderCity", "Enabled", Boolean.TRUE);
+ txtSenderNameTextChanged();
+ txtSenderStreetTextChanged();
+ txtSenderPostCodeTextChanged();
+ txtSenderStateTextChanged();
+ txtSenderCityTextChanged();
+ }
+
+ public void optCreateLetterItemChanged()
+ {
+ bEditTemplate = false;
+ }
+
+ public void optMakeChangesItemChanged()
+ {
+ bEditTemplate = true;
+ }
+
+ public void optReceiverPlaceholderItemChanged()
+ {
+ OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Placeholder()");
+ }
+
+ public void optReceiverDatabaseItemChanged()
+ {
+ OfficeDocument.attachEventCall(xTextDocument, "OnNew", "StarBasic", "macro:///Template.Correspondence.Database()");
+ }
+
+ public void lstBusinessStyleItemChanged()
+ {
+ xTextDocument = myLetterDoc.loadAsPreview(BusinessFiles[1][lstBusinessStyle.getSelectedItemPos()], false);
+ myLetterDoc.xTextDocument.lockControllers();
+ initializeElements();
+ chkBusinessPaperItemChanged();
+ setElements(false);
+ myLetterDoc.xTextDocument.unlockControllers();
+ activate();
+ }
+
+ public void lstPrivOfficialStyleItemChanged()
+ {
+ xTextDocument = myLetterDoc.loadAsPreview(OfficialFiles[1][lstPrivOfficialStyle.getSelectedItemPos()], false);
+ myLetterDoc.xTextDocument.lockControllers();
+ initializeElements();
+ setPossibleSenderData(true);
+ setElements(false);
+ myLetterDoc.xTextDocument.unlockControllers();
+ activate();
+ }
+
+ public void lstPrivateStyleItemChanged()
+ {
+ xTextDocument = myLetterDoc.loadAsPreview(PrivateFiles[1][lstPrivateStyle.getSelectedItemPos()], false);
+ myLetterDoc.xTextDocument.lockControllers();
+ initializeElements();
+ setElements(true);
+ myLetterDoc.xTextDocument.unlockControllers();
+ activate();
+ }
+
+ public void numLogoHeightTextChanged()
+ {
+ BusCompanyLogo.iHeight = (int) (numLogoHeight.getValue() * 1000);
+ BusCompanyLogo.setFramePosition();
+ }
+
+ public void numLogoWidthTextChanged()
+ {
+ BusCompanyLogo.iWidth = (int) (numLogoWidth.getValue() * 1000);
+ BusCompanyLogo.setFramePosition();
+ }
+
+ public void numLogoXTextChanged()
+ {
+ BusCompanyLogo.iXPos = (int) (numLogoX.getValue() * 1000);
+ BusCompanyLogo.setFramePosition();
+ }
+
+ public void numLogoYTextChanged()
+ {
+ BusCompanyLogo.iYPos = (int) (numLogoY.getValue() * 1000);
+ BusCompanyLogo.setFramePosition();
+ }
+
+ public void numAddressWidthTextChanged()
+ {
+ BusCompanyAddress.iWidth = (int) (numAddressWidth.getValue() * 1000);
+ BusCompanyAddress.setFramePosition();
+ }
+
+ public void numAddressXTextChanged()
+ {
+ BusCompanyAddress.iXPos = (int) (numAddressX.getValue() * 1000);
+ BusCompanyAddress.setFramePosition();
+ }
+
+ public void numAddressYTextChanged()
+ {
+ BusCompanyAddress.iYPos = (int) (numAddressY.getValue() * 1000);
+ BusCompanyAddress.setFramePosition();
+ }
+
+ public void numAddressHeightTextChanged()
+ {
+ BusCompanyAddress.iHeight = (int) (numAddressHeight.getValue() * 1000);
+ BusCompanyAddress.setFramePosition();
+ }
+
+ public void numFooterHeightTextChanged()
+ {
+ BusFooter.iHeight = (int) (numFooterHeight.getValue() * 1000);
+ BusFooter.iYPos = myLetterDoc.DocSize.Height - BusFooter.iHeight;
+ BusFooter.setFramePosition();
+ }
+
+ public void chkPaperCompanyLogoItemChanged()
+ {
+ if (chkPaperCompanyLogo.getState() != 0)
+ {
+ //minimal value is required, otherwise the frame creation fails
+ if (numLogoWidth.getValue() == 0)
+ {
+ numLogoWidth.setValue(0.1);
+ }
+ if (numLogoHeight.getValue() == 0)
+ {
+ numLogoHeight.setValue(0.1);
+ }
+ BusCompanyLogo = myLetterDoc.new BusinessPaperObject("Company Logo", (int) (numLogoWidth.getValue() * 1000), (int) (numLogoHeight.getValue() * 1000), (int) (numLogoX.getValue() * 1000), (int) (numLogoY.getValue() * 1000));
+ setControlProperty("numLogoHeight", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyLogoHeight", "Enabled", Boolean.TRUE);
+ setControlProperty("numLogoWidth", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyLogoWidth", "Enabled", Boolean.TRUE);
+ setControlProperty("numLogoX", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyLogoX", "Enabled", Boolean.TRUE);
+ setControlProperty("numLogoY", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyLogoY", "Enabled", Boolean.TRUE);
+ setPossibleLogo(false);
+ }
+ else
+ {
+ if (BusCompanyLogo != null)
+ {
+ BusCompanyLogo.removeFrame();
+ }
+ setControlProperty("numLogoHeight", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyLogoHeight", "Enabled", Boolean.FALSE);
+ setControlProperty("numLogoWidth", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyLogoWidth", "Enabled", Boolean.FALSE);
+ setControlProperty("numLogoX", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyLogoX", "Enabled", Boolean.FALSE);
+ setControlProperty("numLogoY", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyLogoY", "Enabled", Boolean.FALSE);
+ setPossibleLogo(true);
+ }
+ }
+
+ public void chkPaperCompanyAddressItemChanged()
+ {
+ if (chkPaperCompanyAddress.getState() != 0)
+ {
+// minimal value is required, otherwise the frame creation fails
+ if (numAddressWidth.getValue() == 0)
+ {
+ numAddressWidth.setValue(0.1);
+ }
+ if (numAddressHeight.getValue() == 0)
+ {
+ numAddressHeight.setValue(0.1);
+ }
+ BusCompanyAddress = myLetterDoc.new BusinessPaperObject("Company Address", (int) (numAddressWidth.getValue() * 1000), (int) (numAddressHeight.getValue() * 1000), (int) (numAddressX.getValue() * 1000), (int) (numAddressY.getValue() * 1000));
+ setControlProperty("numAddressHeight", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyAddressHeight", "Enabled", Boolean.TRUE);
+ setControlProperty("numAddressWidth", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyAddressWidth", "Enabled", Boolean.TRUE);
+ setControlProperty("numAddressX", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyAddressX", "Enabled", Boolean.TRUE);
+ setControlProperty("numAddressY", "Enabled", Boolean.TRUE);
+ setControlProperty("lblCompanyAddressY", "Enabled", Boolean.TRUE);
+ if (myLetterDoc.hasElement("Sender Address"))
+ {
+ myLetterDoc.switchElement("Sender Address", (false));
+ }
+ if (chkCompanyReceiver.getState() != 0)
+ {
+ setPossibleSenderData(false);
+ }
+ }
+ else
+ {
+ if (BusCompanyAddress != null)
+ {
+ BusCompanyAddress.removeFrame();
+ }
+ setControlProperty("numAddressHeight", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyAddressHeight", "Enabled", Boolean.FALSE);
+ setControlProperty("numAddressWidth", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyAddressWidth", "Enabled", Boolean.FALSE);
+ setControlProperty("numAddressX", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyAddressX", "Enabled", Boolean.FALSE);
+ setControlProperty("numAddressY", "Enabled", Boolean.FALSE);
+ setControlProperty("lblCompanyAddressY", "Enabled", Boolean.FALSE);
+ if (myLetterDoc.hasElement("Sender Address"))
+ {
+ myLetterDoc.switchElement("Sender Address", (true));
+ }
+ setPossibleSenderData(true);
+ if (optSenderDefine.getState())
+ {
+ optSenderDefineItemChanged();
+ }
+ if (optSenderPlaceholder.getState())
+ {
+ optSenderPlaceholderItemChanged();
+ }
+ }
+ }
+
+ public void chkCompanyReceiverItemChanged()
+ {
+ XTextFrame xReceiverFrame = null;
+
+ if (chkCompanyReceiver.getState() != 0)
+ {
+ try
+ {
+ xReceiverFrame = TextFrameHandler.getFrameByName("Receiver Address", xTextDocument);
+ Integer FrameWidth = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, "Width");
+ int iFrameWidth = FrameWidth.intValue();
+ Integer FrameX = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, "HoriOrientPosition");
+ int iFrameX = FrameX.intValue();
+ Integer FrameY = (Integer) Helper.getUnoPropertyValue(xReceiverFrame, "VertOrientPosition");
+ int iFrameY = FrameY.intValue();
+
+ //Height of the Company Address in the Receiver Field
+ int iReceiverHeight = (int) (0.5 * 1000);
+ BusCompanyAddressReceiver = myLetterDoc.new BusinessPaperObject(" ", iFrameWidth, iReceiverHeight, iFrameX, (iFrameY - iReceiverHeight));
+
+ setPossibleAddressReceiver(false);
+ }
+ catch (NoSuchElementException e)
+ {
+ // TODO Error Message: Template modified!
+ e.printStackTrace();
+ }
+ catch (WrappedTargetException e)
+ {
+ e.printStackTrace();
+ }
+ if (chkPaperCompanyAddress.getState() != 0)
+ {
+ setPossibleSenderData(false);
+ }
+ }
+ else
+ {
+ if (BusCompanyAddressReceiver != null)
+ {
+ BusCompanyAddressReceiver.removeFrame();
+ }
+ setPossibleAddressReceiver(true);
+ setPossibleSenderData(true);
+ if (optSenderDefine.getState())
+ {
+ optSenderDefineItemChanged();
+ }
+ if (optSenderPlaceholder.getState())
+ {
+ optSenderPlaceholderItemChanged();
+ }
+ }
+ }
+
+ public void chkPaperFooterItemChanged()
+ {
+
+ if (chkPaperFooter.getState() != 0)
+ {
+ //minimal value is required, otherwise the frame creation fails
+ if (numFooterHeight.getValue() == 0)
+ {
+ numFooterHeight.setValue(0.1);
+ }
+ BusFooter = myLetterDoc.new BusinessPaperObject("Footer", (int) myLetterDoc.DocSize.Width, (int) (numFooterHeight.getValue() * 1000), (int) 0, (int) (myLetterDoc.DocSize.Height - (numFooterHeight.getValue() * 1000)));
+ this.setControlProperty("numFooterHeight", "Enabled", Boolean.TRUE);
+ this.setControlProperty("lblFooterHeight", "Enabled", Boolean.TRUE);
+ setPossibleFooter(false);
+ }
+ else
+ {
+ if (BusFooter != null)
+ {
+ BusFooter.removeFrame();
+ }
+ setControlProperty("numFooterHeight", "Enabled", Boolean.FALSE);
+ setControlProperty("lblFooterHeight", "Enabled", Boolean.FALSE);
+ setPossibleFooter(true);
+ }
+ }
+
+ //switch Elements on/off -------------------------------------------------------
+ public void chkUseLogoItemChanged()
+ {
+ try
+ {
+ if (myLetterDoc.hasElement("Company Logo"))
+ {
+ boolean logostatus = AnyConverter.toBoolean(getControlProperty("chkUseLogo", "Enabled")) && (chkUseLogo.getState() != 0);
+ myLetterDoc.switchElement("Company Logo", logostatus);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void chkUseAddressReceiverItemChanged()
+ {
+ try
+ {
+ if (myLetterDoc.hasElement("Sender Address Repeated"))
+ {
+ boolean rstatus = AnyConverter.toBoolean(getControlProperty("chkUseAddressReceiver", "Enabled")) && (chkUseAddressReceiver.getState() != 0);
+ myLetterDoc.switchElement("Sender Address Repeated", rstatus);
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void chkUseSignsItemChanged()
+ {
+ if (myLetterDoc.hasElement("Letter Signs"))
+ {
+ myLetterDoc.switchElement("Letter Signs", (chkUseSigns.getState() != 0));
+ }
+ }
+
+ public void chkUseSubjectItemChanged()
+ {
+ if (myLetterDoc.hasElement("Subject Line"))
+ {
+ myLetterDoc.switchElement("Subject Line", (chkUseSubject.getState() != 0));
+ }
+ }
+
+ public void chkUseBendMarksItemChanged()
+ {
+ if (myLetterDoc.hasElement("Bend Marks"))
+ {
+ myLetterDoc.switchElement("Bend Marks", (chkUseBendMarks.getState() != 0));
+ }
+ }
+
+ public void chkUseFooterItemChanged()
+ {
+ try
+ {
+ boolean bFooterPossible = (chkUseFooter.getState() != 0) && AnyConverter.toBoolean(getControlProperty("chkUseFooter", "Enabled"));
+
+ if (chkFooterNextPages.getState() != 0)
+ {
+ myLetterDoc.switchFooter("First Page", false, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ myLetterDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ }
+ else
+ {
+ myLetterDoc.switchFooter("First Page", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ myLetterDoc.switchFooter("Standard", bFooterPossible, (chkFooterPageNumbers.getState() != 0), txtFooter.getText());
+ }
+
+ //enable/disable roadmap item for footer page
+ XInterface BPaperItem = getRoadmapItemByID(RM_FOOTER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", new Boolean(bFooterPossible));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void chkFooterNextPagesItemChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ public void chkFooterPageNumbersItemChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ private void setPossibleFooter(boolean bState)
+ {
+ setControlProperty("chkUseFooter", "Enabled", new Boolean(bState));
+ chkUseFooterItemChanged();
+ }
+
+ private void setPossibleAddressReceiver(boolean bState)
+ {
+ if (myLetterDoc.hasElement("Sender Address Repeated"))
+ {
+ setControlProperty("chkUseAddressReceiver", "Enabled", new Boolean(bState));
+ chkUseAddressReceiverItemChanged();
+ }
+ }
+
+ private void setPossibleLogo(boolean bState)
+ {
+ if (myLetterDoc.hasElement("Company Logo"))
+ {
+ setControlProperty("chkUseLogo", "Enabled", new Boolean(bState));
+ chkUseLogoItemChanged();
+ }
+ }
+
+ public void txtFooterTextChanged()
+ {
+ chkUseFooterItemChanged();
+ }
+
+ public void txtSenderNameTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("Company", txtSenderName.getText());
+ }
+
+ public void txtSenderStreetTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("Street", txtSenderStreet.getText());
+ }
+
+ public void txtSenderCityTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("City", txtSenderCity.getText());
+ }
+
+ public void txtSenderPostCodeTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("PostCode", txtSenderPostCode.getText());
+ }
+
+ public void txtSenderStateTextChanged()
+ {
+ TextFieldHandler myFieldHandler = new TextFieldHandler(myLetterDoc.xMSF, xTextDocument);
+ myFieldHandler.changeUserFieldContent("State", txtSenderState.getText());
+ }
+
+ public void txtTemplateNameTextChanged()
+ {
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ XDocumentProperties xDocProps = xDocPropsSuppl.getDocumentProperties();
+ String TitleName = txtTemplateName.getText();
+ xDocProps.setTitle(TitleName);
+ }
+
+ public void chkUseSalutationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ myLetterDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0));
+ setControlProperty("lstSalutation", "Enabled", new Boolean(chkUseSalutation.getState() != 0));
+ }
+
+ public void lstSalutationItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ myLetterDoc.switchUserField("Salutation", xTextComponent.getText(), (chkUseSalutation.getState() != 0));
+ }
+
+ public void lstSalutationTextChanged()
+ {
+ }
+
+ public void chkUseGreetingItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ myLetterDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0));
+ setControlProperty("lstGreeting", "Enabled", new Boolean(chkUseGreeting.getState() != 0));
+ }
+
+ private void setDefaultForGreetingAndSalutation()
+ {
+ XTextComponent xTextComponent;
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstSalutation);
+ if (xTextComponent.getText().equals(""))
+ {
+ xTextComponent.setText(resources.SalutationLabels[0]);
+ }
+ xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ if (xTextComponent.getText().equals(""))
+ {
+ xTextComponent.setText(resources.GreetingLabels[0]);
+ }
+ }
+
+ public void lstGreetingItemChanged()
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, lstGreeting);
+ myLetterDoc.switchUserField("Greeting", xTextComponent.getText(), (chkUseGreeting.getState() != 0));
+ }
+
+ public void lstGreetingTextChanged()
+ {
+ }
+
+ // ----------------------------------------------------------------------------
+ public void chkBusinessPaperItemChanged()
+ {
+ //enable/disable Roadmap Entry Business Paper
+ if (chkBusinessPaper.getState() != 0)
+ {
+ enableBusinessPaper();
+ }
+ else
+ {
+ disableBusinessPaper();
+ setPossibleSenderData(true);
+ }
+ }
+
+ private int getOfficeLinguistic()
+ {
+ int oL = 0;
+ boolean found = false;
+ String OfficeLinguistic = Configuration.getOfficeLinguistic(xMSF);
+ for (int i = 0; i < Norms.length; i++)
+ {
+ if (Norms[i].equalsIgnoreCase(OfficeLinguistic))
+ {
+ oL = i;
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ //fall back to English:
+ for (int i = 0; i < Norms.length; i++)
+ {
+ if (Norms[i].equalsIgnoreCase("en-US"))
+ {
+ oL = i;
+ found = true;
+ break;
+ }
+ }
+ }
+ return oL;
+ }
+
+ private void setPossibleSenderData(boolean bState)
+ {
+ setControlProperty("optSenderDefine", "Enabled", new Boolean(bState));
+ setControlProperty("optSenderPlaceholder", "Enabled", new Boolean(bState));
+ setControlProperty("lblSenderAddress", "Enabled", new Boolean(bState));
+ if (!bState)
+ {
+ setControlProperty("txtSenderCity", "Enabled", new Boolean(bState));
+ setControlProperty("txtSenderName", "Enabled", new Boolean(bState));
+ setControlProperty("txtSenderPostCode", "Enabled", new Boolean(bState));
+ setControlProperty("txtSenderStreet", "Enabled", new Boolean(bState));
+ setControlProperty("txtSenderCity", "Enabled", new Boolean(bState));
+ setControlProperty("txtSenderState", "Enabled", new Boolean(bState));
+ setControlProperty("lblSenderName", "Enabled", new Boolean(bState));
+ setControlProperty("lblSenderStreet", "Enabled", new Boolean(bState));
+ setControlProperty("lblPostCodeCity", "Enabled", new Boolean(bState));
+ }
+ }
+
+ private void enableSenderReceiver()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.TRUE);
+ }
+
+ private void disableSenderReceiver()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_SENDERRECEIVER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.FALSE);
+ }
+
+ private void enableBusinessPaper()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_BUSINESSPAPER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.TRUE);
+ chkPaperCompanyLogoItemChanged();
+ chkPaperCompanyAddressItemChanged();
+ chkPaperFooterItemChanged();
+ chkCompanyReceiverItemChanged();
+ }
+
+ private void disableBusinessPaper()
+ {
+ XInterface BPaperItem = getRoadmapItemByID(RM_BUSINESSPAPER);
+ Helper.setUnoPropertyValue(BPaperItem, "Enabled", Boolean.FALSE);
+ if (BusCompanyLogo != null)
+ {
+ BusCompanyLogo.removeFrame();
+ }
+ if (BusCompanyAddress != null)
+ {
+ BusCompanyAddress.removeFrame();
+ }
+ if (BusFooter != null)
+ {
+ BusFooter.removeFrame();
+ }
+ if (BusCompanyAddressReceiver != null)
+ {
+ BusCompanyAddressReceiver.removeFrame();
+ }
+ setPossibleAddressReceiver(true);
+ setPossibleFooter(true);
+ setPossibleLogo(true);
+ if (myLetterDoc.hasElement("Sender Address"))
+ {
+ myLetterDoc.switchElement("Sender Address", (true));
+ }
+
+ }
+
+ public void lstLetterNormItemChanged()
+ {
+ //when the norm changes, the correct template needs to be reloaded
+ sCurrentNorm = Norms[getCurrentLetter().cp_Norm];
+ initializeTemplates(xMSF);
+ if (optBusinessLetter.getState())
+ {
+ lstBusinessStyleItemChanged();
+ }
+ if (optPrivOfficialLetter.getState())
+ {
+ lstPrivOfficialStyleItemChanged();
+ }
+ if (optPrivateLetter.getState())
+ {
+ lstPrivateStyleItemChanged();
+ }
+ }
+
+ public void initializeSalutation()
+ {
+ setControlProperty("lstSalutation", "StringItemList", resources.SalutationLabels);
+ }
+
+ public void initializeGreeting()
+ {
+ setControlProperty("lstGreeting", "StringItemList", resources.GreetingLabels);
+ }
+
+ public void initializeNorms()
+ {
+
+ LocaleCodes lc = new LocaleCodes(xmsf);
+ String[] allLocales = lc.getIDs();
+ Object[] nameList =
+ {
+ "", ""
+ };
+ String[] nameList1 =
+ {
+ "", ""
+ };
+ String[] nameList1b =
+ {
+ "", ""
+ };
+ String[] nameList2 =
+ {
+ "", ""
+ };
+ Vector allPaths = new Vector();
+ String sLetterSubPath = "/wizard/letter/";
+
+ try
+ {
+ sTemplatePath = FileAccess.deleteLastSlashfromUrl(sTemplatePath);
+ String[] PathParts = sTemplatePath.split("/");
+ String nuString = "";
+ String sMainPath;
+ for (int i = 0; i < (PathParts.length - 1); i++)
+ {
+ nuString = nuString + PathParts[i] + "/";
+ }
+ String sLocLetterPath;
+ sMainPath = nuString;
+ sMainPath = FileAccess.deleteLastSlashfromUrl(sMainPath);
+
+ sLetterPath = sMainPath + sLetterSubPath;
+ //sLetterLangPackPath = FileAccess.combinePaths(xMSF, sTemplatePath, sLetterSubPath);
+
+ XInterface xInterface = (XInterface) xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ com.sun.star.ucb.XSimpleFileAccess xSimpleFileAccess = (com.sun.star.ucb.XSimpleFileAccess) UnoRuntime.queryInterface(com.sun.star.ucb.XSimpleFileAccess.class, xInterface);
+ nameList1 = xSimpleFileAccess.getFolderContents(sMainPath, true);
+ nameList2 = xSimpleFileAccess.getFolderContents(sLetterPath, true);
+ for (int i = 0; i < nameList1.length; i++)
+ {
+ String theFileName = FileAccess.getFilename(nameList1[i]);
+ if (!theFileName.equalsIgnoreCase("wizard"))
+ {
+ sLocLetterPath = FileAccess.deleteLastSlashfromUrl(nameList1[i] + sLetterSubPath);
+ try
+ {
+ nameList1b = xSimpleFileAccess.getFolderContents(sLocLetterPath, true);
+ for (int j = 0; j < nameList1b.length; j++)
+ {
+ String theFileNameb = FileAccess.getFilename(nameList1b[j]);
+ allPaths.add(nameList1[i] + sLetterSubPath + theFileNameb);
+ }
+ }
+ catch (Exception e)
+ {
+ //if the path is invalid an exception is thrown - try the fallback below then
+ }
+ }
+ }
+ for (int i = 0; i < nameList2.length; i++)
+ {
+ boolean found = false;
+ for (int t = 0; t < nameList1.length; t++)
+ {
+ if (FileAccess.getFilename(nameList2[i]).equalsIgnoreCase(FileAccess.getFilename(nameList1[t])))
+ {
+ found = true;
+ }
+ }
+ if (!found)
+ {
+ allPaths.add(nameList2[i]);
+ }
+ }
+ nameList = allPaths.toArray();
+
+
+ }
+ catch (CommandAbortedException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ //} catch (NoValidPathException e) {
+ // TODO Auto-generated catch block
+ // e.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ Vector NormsVector = new Vector();
+ Vector NormsPathVector = new Vector();
+ Vector LanguageLabelsVector = new Vector();
+ String[] LanguageLabels;
+
+ boolean found = false;
+ String cIsoCode = "";
+ String MSID = "";
+ int z = 0;
+ for (int i = 0; i < nameList.length; i++)
+ {
+ found = false;
+ cIsoCode = FileAccess.getFilename((String) nameList[i]);
+ for (int t = 0; t < allLocales.length; t++)
+ {
+ String[] aLang = allLocales[t].split(";");
+ if (cIsoCode.equalsIgnoreCase(aLang[1]))
+ {
+ MSID = aLang[2];
+ found = true;
+ t = allLocales.length;
+ }
+ }
+ if (!found)
+ {
+ for (int t = 0; t < allLocales.length; t++)
+ {
+ String[] aLang = allLocales[t].split(";");
+ if (cIsoCode.equalsIgnoreCase(aLang[1].substring(0, 2)))
+ {
+ MSID = aLang[2];
+ found = true;
+ t = allLocales.length;
+ }
+ }
+ }
+
+ if (found)
+ {
+ NormsVector.add(cIsoCode);
+ NormsPathVector.add((String) nameList[i]);
+ LanguageLabelsVector.add(lc.getLanguageString(MSID));
+ /*
+ Norms[z] = cIsoCode;
+ NormPaths[z] = (String) nameList[i];
+ LanguageLabels[z] = lc.getLanguageString(MSID);
+ z++;
+ **/
+ }
+ }
+
+
+ Norms = new String[NormsVector.size()];
+ NormsVector.toArray(Norms);
+
+ NormPaths = new String[NormsPathVector.size()];
+ NormsPathVector.toArray(NormPaths);
+
+ LanguageLabels = new String[LanguageLabelsVector.size()];
+ LanguageLabelsVector.toArray(LanguageLabels);
+
+ //Norms = new String[nameList.length];
+ //NormPaths = new String[nameList.length];
+ //LanguageLabels = new String[Norms.length];
+
+ setControlProperty("lstLetterNorm", "StringItemList", LanguageLabels);
+ }
+
+ private CGLetter getCurrentLetter()
+ {
+ switch (myConfig.cp_LetterType)
+ {
+ case 0:
+ return myConfig.cp_BusinessLetter;
+ case 1:
+ return myConfig.cp_PrivateOfficialLetter;
+ case 2:
+ return myConfig.cp_PrivateLetter;
+ default:
+ return null;
+ }
+ }
+
+ private void initializePaths()
+ {
+ try
+ {
+ sTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "share", "/wizard");
+ sUserTemplatePath = FileAccess.getOfficePath(xMSF, "Template", "user", "");
+ sBitmapPath = FileAccess.combinePaths(xMSF, sTemplatePath, "/../wizard/bitmap");
+ }
+ catch (NoValidPathException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean initializeTemplates(XMultiServiceFactory xMSF)
+ {
+ sCurrentNorm = Norms[getCurrentLetter().cp_Norm];
+ //creation of the language independent path:
+ String sLetterPath = NormPaths[getCurrentLetter().cp_Norm];
+
+ // try
+ // {
+ BusinessFiles = FileAccess.getFolderTitles(xMSF, "bus", sLetterPath);
+ OfficialFiles = FileAccess.getFolderTitles(xMSF, "off", sLetterPath);
+ PrivateFiles = FileAccess.getFolderTitles(xMSF, "pri", sLetterPath);
+
+ setControlProperty("lstBusinessStyle", "StringItemList", BusinessFiles[0]);
+ setControlProperty("lstPrivOfficialStyle", "StringItemList", OfficialFiles[0]);
+ setControlProperty("lstPrivateStyle", "StringItemList", PrivateFiles[0]);
+
+ setControlProperty("lstBusinessStyle", "SelectedItems", new short[]
+ {
+ 0
+ });
+ setControlProperty("lstPrivOfficialStyle", "SelectedItems", new short[]
+ {
+ 0
+ });
+ setControlProperty("lstPrivateStyle", "SelectedItems", new short[]
+ {
+ 0
+ });
+// }
+// catch (com.sun.star.wizards.common.NoValidPathException e)
+// {
+// return false;
+// }
+ return true;
+ }
+
+ public void initializeElements()
+ {
+ setControlProperty("chkUseLogo", "Enabled", new Boolean(myLetterDoc.hasElement("Company Logo")));
+ setControlProperty("chkUseBendMarks", "Enabled", new Boolean(myLetterDoc.hasElement("Bend Marks")));
+ setControlProperty("chkUseAddressReceiver", "Enabled", new Boolean(myLetterDoc.hasElement("Sender Address Repeated")));
+ setControlProperty("chkUseSubject", "Enabled", new Boolean(myLetterDoc.hasElement("Subject Line")));
+ setControlProperty("chkUseSigns", "Enabled", new Boolean(myLetterDoc.hasElement("Letter Signs")));
+ myLetterDoc.updateDateFields();
+ }
+
+ public void setConfiguration()
+ {
+ //set correct Configuration tree:
+
+ if (optBusinessLetter.getState())
+ {
+ optBusinessLetterItemChanged();
+ }
+ if (optPrivOfficialLetter.getState())
+ {
+ optPrivOfficialLetterItemChanged();
+ }
+ if (optPrivateLetter.getState())
+ {
+ optPrivateLetterItemChanged();
+ }
+ }
+
+ public void setElements(boolean privLetter)
+ {
+ //UI relevant:
+ if (optSenderDefine.getState())
+ {
+ optSenderDefineItemChanged();
+ }
+ if (optSenderPlaceholder.getState())
+ {
+ optSenderPlaceholderItemChanged();
+ }
+ chkUseSignsItemChanged();
+ chkUseSubjectItemChanged();
+ chkUseSalutationItemChanged();
+ chkUseGreetingItemChanged();
+ chkUseBendMarksItemChanged();
+ chkUseAddressReceiverItemChanged();
+ txtTemplateNameTextChanged();
+
+ //not UI relevant:
+ if (optReceiverDatabase.getState() && !privLetter)
+ {
+ optReceiverDatabaseItemChanged();
+ }
+ if (optReceiverPlaceholder.getState() && !privLetter)
+ {
+ optReceiverPlaceholderItemChanged();
+ }
+ if (optCreateLetter.getState())
+ {
+ optCreateLetterItemChanged();
+ }
+ if (optMakeChanges.getState())
+ {
+ optMakeChangesItemChanged();
+ }
+ }
+
+ public void insertRoadmap()
+ {
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, resources.RoadmapLabels[RM_TYPESTYLE], RM_TYPESTYLE);
+ i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_BUSINESSPAPER], RM_BUSINESSPAPER);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_ELEMENTS], RM_ELEMENTS);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_SENDERRECEIVER], RM_SENDERRECEIVER);
+ i = insertRoadmapItem(i, false, resources.RoadmapLabels[RM_FOOTER], RM_FOOTER);
+ i = insertRoadmapItem(i, true, resources.RoadmapLabels[RM_FINALSETTINGS], RM_FINALSETTINGS);
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+
+ private class myPathSelectionListener implements XPathSelectionListener
+ {
+
+ public void validatePath()
+ {
+ if (myPathSelection.usedPathPicker)
+ {
+ filenameChanged = true;
+ }
+ myPathSelection.usedPathPicker = false;
+ }
+ }
+
+ public void insertPathSelectionControl()
+ {
+ myPathSelection = new PathSelection(xMSF, this, PathSelection.TransferMode.SAVE, PathSelection.DialogTypes.FILE);
+ myPathSelection.insert(6, 97, 70, 205, (short) 45, resources.reslblTemplatePath_value, true, HelpIds.getHelpIdString(HID + 47), HelpIds.getHelpIdString(HID + 48));
+ myPathSelection.sDefaultDirectory = sUserTemplatePath;
+ myPathSelection.sDefaultName = "myLetterTemplate.ott";
+ myPathSelection.sDefaultFilter = "writer8_template";
+ myPathSelection.addSelectionListener(new myPathSelectionListener());
+ }
+
+ public void initConfiguration()
+ {
+ try
+ {
+ myConfig = new CGLetterWizard();
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Letter", false);
+ myConfig.readConfiguration(root, "cp_");
+ mainDA.add(RadioDataAware.attachRadioButtons(myConfig, "cp_LetterType", new Object[]
+ {
+ optBusinessLetter, optPrivOfficialLetter, optPrivateLetter
+ }, null, true));
+ mainDA.add(UnoDataAware.attachListBox(myConfig.cp_BusinessLetter, "cp_Style", lstBusinessStyle, null, true));
+ mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateOfficialLetter, "cp_Style", lstPrivOfficialStyle, null, true));
+ mainDA.add(UnoDataAware.attachListBox(myConfig.cp_PrivateLetter, "cp_Style", lstPrivateStyle, null, true));
+ mainDA.add(UnoDataAware.attachCheckBox(myConfig.cp_BusinessLetter, "cp_BusinessPaper", chkBusinessPaper, null, true));
+
+ CGLetter cgl = myConfig.cp_BusinessLetter;
+
+ CGPaperElementLocation cgpl = myConfig.cp_BusinessLetter.cp_CompanyLogo;
+ CGPaperElementLocation cgpa = myConfig.cp_BusinessLetter.cp_CompanyAddress;
+
+ businessDA.add(UnoDataAware.attachCheckBox(cgpl, "cp_Display", chkPaperCompanyLogo, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Width", numLogoWidth, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Height", numLogoHeight, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_X", numLogoX, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpl, "cp_Y", numLogoY, null, true));
+ businessDA.add(UnoDataAware.attachCheckBox(cgpa, "cp_Display", chkPaperCompanyAddress, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Width", numAddressWidth, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Height", numAddressHeight, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_X", numAddressX, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgpa, "cp_Y", numAddressY, null, true));
+
+ businessDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PaperCompanyAddressReceiverField", chkCompanyReceiver, null, true));
+ businessDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PaperFooter", chkPaperFooter, null, true));
+ businessDA.add(UnoDataAware.attachNumericControl(cgl, "cp_PaperFooterHeight", numFooterHeight, null, true));
+
+ letterDA.add(UnoDataAware.attachListBox(cgl, "cp_Norm", lstLetterNorm, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyLogo", chkUseLogo, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintCompanyAddressReceiverField", chkUseAddressReceiver, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintLetterSigns", chkUseSigns, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSubjectLine", chkUseSubject, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintSalutation", chkUseSalutation, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintBendMarks", chkUseBendMarks, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintGreeting", chkUseGreeting, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_PrintFooter", chkUseFooter, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Salutation", lstSalutation, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Greeting", lstGreeting, null, true));
+ letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_SenderAddressType", new Object[]
+ {
+ optSenderDefine, optSenderPlaceholder
+ }, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCompanyName", txtSenderName, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderStreet", txtSenderStreet, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderPostCode", txtSenderPostCode, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderState", txtSenderState, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_SenderCity", txtSenderCity, null, true));
+ letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_ReceiverAddressType", new Object[]
+ {
+ optReceiverDatabase, optReceiverPlaceholder
+ }, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_Footer", txtFooter, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterOnlySecondPage", chkFooterNextPages, null, true));
+ letterDA.add(UnoDataAware.attachCheckBox(cgl, "cp_FooterPageNumbers", chkFooterPageNumbers, null, true));
+ letterDA.add(RadioDataAware.attachRadioButtons(cgl, "cp_CreationType", new Object[]
+ {
+ optCreateLetter, optMakeChanges
+ }, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplateName", txtTemplateName, null, true));
+ letterDA.add(UnoDataAware.attachEditControl(cgl, "cp_TemplatePath", myPathSelection.xSaveTextBox, null, true));
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ }
+
+ }
+
+ private void updateUI()
+ {
+ UnoDataAware.updateUI(mainDA);
+ UnoDataAware.updateUI(letterDA);
+ UnoDataAware.updateUI(businessDA);
+ }
+
+ public void saveConfiguration()
+ {
+ try
+ {
+ Object root = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.Office.Writer/Wizards/Letter", true);
+ myConfig.writeConfiguration(root, "cp_");
+ Configuration.commit(root);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.java b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.java
new file mode 100644
index 000000000000..01731d989ebc
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LetterWizardDialogResources.java
@@ -0,0 +1,207 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Resource;
+
+public class LetterWizardDialogResources extends Resource
+{
+
+ final static String UNIT_NAME = "dbwizres";
+ final static String MODULE_NAME = "dbw";
+ final static int RID_LETTERWIZARDDIALOG_START = 3000;
+ final static int RID_LETTERWIZARDGREETING_START = 3080;
+ final static int RID_LETTERWIZARDSALUTATION_START = 3090;
+ final static int RID_LETTERWIZARDROADMAP_START = 3100;
+ final static int RID_LETTERWIZARDLANGUAGE_START = 3110;
+ final static int RID_RID_COMMON_START = 500;
+ protected String[] RoadmapLabels = new String[7];
+ protected String[] SalutationLabels = new String[3];
+ protected String[] GreetingLabels = new String[3];
+ protected String[] LanguageLabels = new String[16];
+ String resOverwriteWarning;
+ String resTemplateDescription;
+ String resLetterWizardDialog_title;
+ String resLabel9_value;
+ String resoptBusinessLetter_value;
+ String resoptPrivOfficialLetter_value;
+ String resoptPrivateLetter_value;
+ String reschkBusinessPaper_value;
+ String reschkPaperCompanyLogo_value;
+ String reschkPaperCompanyAddress_value;
+ String reschkPaperFooter_value;
+ String reschkCompanyReceiver_value;
+ String reschkUseLogo_value;
+ String reschkUseAddressReceiver_value;
+ String reschkUseSigns_value;
+ String reschkUseSubject_value;
+ String reschkUseSalutation_value;
+ String reschkUseBendMarks_value;
+ String reschkUseGreeting_value;
+ String reschkUseFooter_value;
+ String resoptSenderPlaceholder_value;
+ String resoptSenderDefine_value;
+ String resoptReceiverPlaceholder_value;
+ String resoptReceiverDatabase_value;
+ String reschkFooterNextPages_value;
+ String reschkFooterPageNumbers_value;
+ String restxtTemplateName_value;
+ String resoptCreateLetter_value;
+ String resoptMakeChanges_value;
+ String reslblBusinessStyle_value;
+ String reslblPrivOfficialStyle_value;
+ String reslblPrivateStyle_value;
+ String reslblIntroduction_value;
+ String reslblLogoHeight_value;
+ String reslblLogoWidth_value;
+ String reslblLogoX_value;
+ String reslblLogoY_value;
+ String reslblAddressHeight_value;
+ String reslblAddressWidth_value;
+ String reslblAddressX_value;
+ String reslblAddressY_value;
+ String reslblFooterHeight_value;
+ String reslblLetterNorm_value;
+ String reslblSenderAddress_value;
+ String reslblSenderName_value;
+ String reslblSenderStreet_value;
+ String reslblPostCodeCity_value;
+ String reslblReceiverAddress_value;
+ String reslblFooter_value;
+ String reslblFinalExplanation1_value;
+ String reslblFinalExplanation2_value;
+ String reslblTemplateName_value;
+ String reslblTemplatePath_value;
+ String reslblProceed_value;
+ String reslblTitle1_value;
+ String reslblTitle3_value;
+ String reslblTitle2_value;
+ String reslblTitle4_value;
+ String reslblTitle5_value;
+ String reslblTitle6_value;
+
+ public LetterWizardDialogResources(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, UNIT_NAME, MODULE_NAME);
+
+ resLetterWizardDialog_title = getResText(RID_LETTERWIZARDDIALOG_START + 1);
+ resLabel9_value = getResText(RID_LETTERWIZARDDIALOG_START + 2);
+ resoptBusinessLetter_value = getResText(RID_LETTERWIZARDDIALOG_START + 3);
+ resoptPrivOfficialLetter_value = getResText(RID_LETTERWIZARDDIALOG_START + 4);
+ resoptPrivateLetter_value = getResText(RID_LETTERWIZARDDIALOG_START + 5);
+ reschkBusinessPaper_value = getResText(RID_LETTERWIZARDDIALOG_START + 6);
+ reschkPaperCompanyLogo_value = getResText(RID_LETTERWIZARDDIALOG_START + 7);
+ reschkPaperCompanyAddress_value = getResText(RID_LETTERWIZARDDIALOG_START + 8);
+ reschkPaperFooter_value = getResText(RID_LETTERWIZARDDIALOG_START + 9);
+ reschkCompanyReceiver_value = getResText(RID_LETTERWIZARDDIALOG_START + 10);
+ reschkUseLogo_value = getResText(RID_LETTERWIZARDDIALOG_START + 11);
+ reschkUseAddressReceiver_value = getResText(RID_LETTERWIZARDDIALOG_START + 12);
+ reschkUseSigns_value = getResText(RID_LETTERWIZARDDIALOG_START + 13);
+ reschkUseSubject_value = getResText(RID_LETTERWIZARDDIALOG_START + 14);
+ reschkUseSalutation_value = getResText(RID_LETTERWIZARDDIALOG_START + 15);
+ reschkUseBendMarks_value = getResText(RID_LETTERWIZARDDIALOG_START + 16);
+ reschkUseGreeting_value = getResText(RID_LETTERWIZARDDIALOG_START + 17);
+ reschkUseFooter_value = getResText(RID_LETTERWIZARDDIALOG_START + 18);
+ resoptSenderPlaceholder_value = getResText(RID_LETTERWIZARDDIALOG_START + 19);
+ resoptSenderDefine_value = getResText(RID_LETTERWIZARDDIALOG_START + 20);
+ resoptReceiverPlaceholder_value = getResText(RID_LETTERWIZARDDIALOG_START + 21);
+ resoptReceiverDatabase_value = getResText(RID_LETTERWIZARDDIALOG_START + 22);
+ reschkFooterNextPages_value = getResText(RID_LETTERWIZARDDIALOG_START + 23);
+ reschkFooterPageNumbers_value = getResText(RID_LETTERWIZARDDIALOG_START + 24);
+ restxtTemplateName_value = getResText(RID_LETTERWIZARDDIALOG_START + 25);
+ resoptCreateLetter_value = getResText(RID_LETTERWIZARDDIALOG_START + 26);
+ resoptMakeChanges_value = getResText(RID_LETTERWIZARDDIALOG_START + 27);
+ reslblBusinessStyle_value = getResText(RID_LETTERWIZARDDIALOG_START + 28);
+ reslblPrivOfficialStyle_value = getResText(RID_LETTERWIZARDDIALOG_START + 29);
+ reslblPrivateStyle_value = getResText(RID_LETTERWIZARDDIALOG_START + 30);
+ reslblIntroduction_value = getResText(RID_LETTERWIZARDDIALOG_START + 31);
+ reslblLogoHeight_value = getResText(RID_LETTERWIZARDDIALOG_START + 32);
+ reslblLogoWidth_value = getResText(RID_LETTERWIZARDDIALOG_START + 33);
+ reslblLogoX_value = getResText(RID_LETTERWIZARDDIALOG_START + 34);
+ reslblLogoY_value = getResText(RID_LETTERWIZARDDIALOG_START + 35);
+ reslblAddressHeight_value = getResText(RID_LETTERWIZARDDIALOG_START + 36);
+ reslblAddressWidth_value = getResText(RID_LETTERWIZARDDIALOG_START + 37);
+ reslblAddressX_value = getResText(RID_LETTERWIZARDDIALOG_START + 38);
+ reslblAddressY_value = getResText(RID_LETTERWIZARDDIALOG_START + 39);
+ reslblFooterHeight_value = getResText(RID_LETTERWIZARDDIALOG_START + 40);
+ reslblLetterNorm_value = getResText(RID_LETTERWIZARDDIALOG_START + 41);
+ reslblSenderAddress_value = getResText(RID_LETTERWIZARDDIALOG_START + 42);
+ reslblSenderName_value = getResText(RID_LETTERWIZARDDIALOG_START + 43);
+ reslblSenderStreet_value = getResText(RID_LETTERWIZARDDIALOG_START + 44);
+ reslblPostCodeCity_value = getResText(RID_LETTERWIZARDDIALOG_START + 45);
+ reslblReceiverAddress_value = getResText(RID_LETTERWIZARDDIALOG_START + 46);
+ reslblFooter_value = getResText(RID_LETTERWIZARDDIALOG_START + 47);
+ reslblFinalExplanation1_value = getResText(RID_LETTERWIZARDDIALOG_START + 48);
+ reslblFinalExplanation2_value = getResText(RID_LETTERWIZARDDIALOG_START + 49);
+ reslblTemplateName_value = getResText(RID_LETTERWIZARDDIALOG_START + 50);
+ reslblTemplatePath_value = getResText(RID_LETTERWIZARDDIALOG_START + 51);
+ reslblProceed_value = getResText(RID_LETTERWIZARDDIALOG_START + 52);
+ reslblTitle1_value = getResText(RID_LETTERWIZARDDIALOG_START + 53);
+ reslblTitle3_value = getResText(RID_LETTERWIZARDDIALOG_START + 54);
+ reslblTitle2_value = getResText(RID_LETTERWIZARDDIALOG_START + 55);
+ reslblTitle4_value = getResText(RID_LETTERWIZARDDIALOG_START + 56);
+ reslblTitle5_value = getResText(RID_LETTERWIZARDDIALOG_START + 57);
+ reslblTitle6_value = getResText(RID_LETTERWIZARDDIALOG_START + 58);
+
+ loadRoadmapResources();
+ loadSalutationResources();
+ loadGreetingResources();
+ loadCommonResources();
+ }
+
+ private void loadCommonResources()
+ {
+ resOverwriteWarning = getResText(RID_RID_COMMON_START + 19);
+ resTemplateDescription = getResText(RID_RID_COMMON_START + 20);
+ }
+
+ private void loadRoadmapResources()
+ {
+ for (int i = 1; i < 7; i++)
+ {
+ RoadmapLabels[i] = getResText(RID_LETTERWIZARDROADMAP_START + i);
+ }
+ }
+
+ private void loadSalutationResources()
+ {
+ for (int i = 1; i < 4; i++)
+ {
+ SalutationLabels[i - 1] = getResText(RID_LETTERWIZARDSALUTATION_START + i);
+ }
+ }
+
+ private void loadGreetingResources()
+ {
+ for (int i = 1; i < 4; i++)
+ {
+ GreetingLabels[i - 1] = getResText(RID_LETTERWIZARDGREETING_START + i);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/LocaleCodes.java b/wizards/com/sun/star/wizards/letter/LocaleCodes.java
new file mode 100644
index 000000000000..82994f40dc6b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/LocaleCodes.java
@@ -0,0 +1,202 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.letter;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.beans.PropertyValue;
+
+public class LocaleCodes extends Resource
+{
+
+ final static String UNIT_NAME = "svtres";
+ final static String MODULE_NAME = "svt";
+ PropertyValue[] allLanguageStrings;
+
+ public LocaleCodes(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, UNIT_NAME, MODULE_NAME);
+ allLanguageStrings = getStringList(16635); // STR_ARR_SVT_LANGUAGE_TABLE from svtools/source/misc/langtab.src
+ }
+
+ public String getLanguageString(String MSID)
+ {
+ String LS = "unknown Language";
+ for (int i = 0; i < allLanguageStrings.length; i++)
+ {
+ if (allLanguageStrings[i].Value.toString().equalsIgnoreCase(MSID))
+ {
+ LS = allLanguageStrings[i].Name;
+ }
+ }
+ return LS;
+ }
+
+ public String[] getIDs()
+ {
+ String[] Ids = new String[135];
+
+ Ids[0] = "Afrikaans;af;1078";
+ Ids[1] = "Albanian;sq;1052";
+ Ids[2] = "Arabic - United Arab Emirates;ar-ae;14337";
+ Ids[3] = "Arabic - Bahrain;ar-bh;15361";
+ Ids[4] = "Arabic - Algeria;ar-dz;5121";
+ Ids[5] = "Arabic - Egypt;ar-eg;3073";
+ Ids[6] = "Arabic - Iraq;ar-iq;2049";
+ Ids[7] = "Arabic - Jordan;ar-jo;11265";
+ Ids[8] = "Arabic - Kuwait;ar-kw;13313";
+ Ids[9] = "Arabic - Lebanon;ar-lb;12289";
+ Ids[10] = "Arabic - Libya;ar-ly;4097";
+ Ids[11] = "Arabic - Morocco;ar-ma;6145";
+ Ids[12] = "Arabic - Oman;ar-om;8193";
+ Ids[13] = "Arabic - Qatar;ar-qa;16385";
+ Ids[14] = "Arabic - Saudi Arabia;ar-sa;1025";
+ Ids[15] = "Arabic - Syria;ar-sy;10241";
+ Ids[16] = "Arabic - Tunisia;ar-tn;7169";
+ Ids[17] = "Arabic - Yemen;ar-ye;9217";
+ Ids[18] = "Armenian;hy;1067";
+ Ids[19] = "Azeri - Latin;az-az;1068";
+ Ids[20] = "Azeri - Cyrillic;az-az;2092";
+ Ids[21] = "Basque;eu;1069";
+ Ids[22] = "Belarusian;be;1059";
+ Ids[23] = "Bulgarian;bg;1026";
+ Ids[24] = "Catalan;ca;1027";
+ Ids[25] = "Chinese - China;zh-cn;2052";
+ Ids[26] = "Chinese - Hong Kong SAR;zh-hk;3076";
+ Ids[27] = "Chinese - Macau SAR;zh-mo;5124";
+ Ids[28] = "Chinese - Singapore;zh-sg;4100";
+ Ids[29] = "Chinese - Taiwan;zh-tw;1028";
+ Ids[30] = "Croatian;hr;1050";
+ Ids[31] = "Czech;cs;1029";
+ Ids[32] = "Danish;da;1030";
+ Ids[33] = "Dutch - The Netherlands;nl-nl;1043";
+ Ids[34] = "Dutch - Belgium;nl-be;2067";
+ Ids[35] = "English - Australia;en-au;3081";
+ Ids[36] = "English - Belize;en-bz;10249";
+ Ids[37] = "English - Canada;en-ca;4105";
+ Ids[38] = "English - Caribbean;en-cb;9225";
+ Ids[39] = "English - Ireland;en-ie;6153";
+ Ids[40] = "English - Jamaica;en-jm;8201";
+ Ids[41] = "English - New Zealand;en-nz;5129";
+ Ids[42] = "English - Phillippines;en-ph;13321";
+ Ids[43] = "English - South Africa;en-za;7177";
+ Ids[44] = "English - Trinidad;en-tt;11273";
+ Ids[45] = "English - United Kingdom;en-gb;2057";
+ Ids[46] = "English - United States;en-us;1033";
+ Ids[47] = "Estonian;et;1061";
+ Ids[48] = "Farsi;fa;1065";
+ Ids[49] = "Finnish;fi;1035";
+ Ids[50] = "Faroese;fo;1080";
+ Ids[51] = "French - France;fr-fr;1036";
+ Ids[52] = "French - Belgium;fr-be;2060";
+ Ids[53] = "French - Canada;fr-ca;3084";
+ Ids[54] = "French - Luxembourg;fr-lu;5132";
+ Ids[55] = "French - Switzerland;fr-ch;4108";
+ Ids[56] = "Gaelic - Ireland;gd-ie;2108";
+ Ids[57] = "Gaelic - Scotland;gd;1084";
+ Ids[58] = "German - Germany;de-de;1031";
+ Ids[59] = "German - Austria;de-at;3079";
+ Ids[60] = "German - Liechtenstein;de-li;5127";
+ Ids[61] = "German - Luxembourg;de-lu;4103";
+ Ids[62] = "German - Switzerland;de-ch;2055";
+ Ids[63] = "Greek;el;1032";
+ Ids[64] = "Hebrew;he;1037";
+ Ids[65] = "Hindi;hi;1081";
+ Ids[66] = "Hungarian;hu;1038";
+ Ids[67] = "Icelandic;is;1039";
+ Ids[68] = "Indonesian;id;1057";
+ Ids[69] = "Italian - Italy;it-it;1040";
+ Ids[70] = "Italian - Switzerland;it-ch;2064";
+ Ids[71] = "Japanese;ja;1041";
+ Ids[72] = "Korean;ko;1042";
+ Ids[73] = "Latvian;lv;1062";
+ Ids[74] = "Lithuanian;lt;1063";
+ Ids[75] = "FYRO Macedonian;mk;1071";
+ Ids[76] = "Malay - Malaysia;ms-my;1086";
+ Ids[77] = "Malay - Brunei;ms-bn;2110";
+ Ids[78] = "Maltese;mt;1082";
+ Ids[79] = "Marathi;mr;1102";
+ Ids[80] = "Norwegian - Bokm?l;no-no;1044";
+ Ids[81] = "Norwegian - Nynorsk;no-no;2068";
+ Ids[82] = "Polish;pl;1045";
+ Ids[83] = "Portuguese - Portugal;pt-pt;2070";
+ Ids[84] = "Portuguese - Brazil;pt-br;1046";
+ Ids[85] = "Raeto-Romance;rm;1047";
+ Ids[86] = "Romanian - Romania;ro;1048";
+ Ids[87] = "Romanian - Moldova;ro-mo;2072";
+ Ids[88] = "Russian;ru;1049";
+ Ids[89] = "Russian - Moldova;ru-mo;2073";
+ Ids[90] = "Sanskrit;sa;1103";
+ Ids[91] = "Serbian - Cyrillic;sr-sp;3098";
+ Ids[92] = "Serbian - Latin;sr-sp;2074";
+ Ids[93] = "Setsuana;tn;1074";
+ Ids[94] = "Slovenian;sl;1060";
+ Ids[95] = "Slovak;sk;1051";
+ Ids[96] = "Sorbian;sb;1070";
+ Ids[97] = "Spanish - Spain;es-es;1034";
+ Ids[98] = "Spanish - Argentina;es-ar;11274";
+ Ids[99] = "Spanish - Bolivia;es-bo;16394";
+ Ids[100] = "Spanish - Chile;es-cl;13322";
+ Ids[101] = "Spanish - Colombia;es-co;9226";
+ Ids[102] = "Spanish - Costa Rica;es-cr;5130";
+ Ids[103] = "Spanish - Dominican Republic;es-do;7178";
+ Ids[104] = "Spanish - Ecuador;es-ec;12298";
+ Ids[105] = "Spanish - Guatemala;es-gt;4106";
+ Ids[106] = "Spanish - Honduras;es-hn;18442";
+ Ids[107] = "Spanish - Mexico;es-mx;2058";
+ Ids[108] = "Spanish - Nicaragua;es-ni;19466";
+ Ids[109] = "Spanish - Panama;es-pa;6154";
+ Ids[110] = "Spanish - Peru;es-pe;10250";
+ Ids[111] = "Spanish - Puerto Rico;es-pr;20490";
+ Ids[112] = "Spanish - Paraguay;es-py;15370";
+ Ids[113] = "Spanish - El Salvador;es-sv;17418";
+ Ids[114] = "Spanish - Uruguay;es-uy;14346";
+ Ids[115] = "Spanish - Venezuela;es-ve;8202";
+ Ids[116] = "Sutu;sx;1072";
+ Ids[117] = "Swahili;sw;1089";
+ Ids[118] = "Swedish - Sweden;sv-se;1053";
+ Ids[119] = "Swedish - Finland;sv-fi;2077";
+ Ids[120] = "Tamil;ta;1097";
+ Ids[121] = "Tatar;tt;1092";
+ Ids[122] = "Thai;th;1054";
+ Ids[123] = "Turkish;tr;1055";
+ Ids[124] = "Tsonga;ts;1073";
+ Ids[125] = "Ukrainian;uk;1058";
+ Ids[126] = "Urdu;ur;1056";
+ Ids[127] = "Uzbek - Cyrillic;uz-uz;2115";
+ Ids[128] = "Uzbek - Latin;uz-uz;1091";
+ Ids[129] = "Vietnamese;vi;1066";
+ Ids[130] = "Xhosa;xh;1076";
+ Ids[131] = "Yiddish;yi;1085";
+ Ids[132] = "Zulu;zu;1077";
+ Ids[133] = "Khmer;km-kh;1107";
+ Ids[134] = "Burmese;my-mm;1109";
+
+ return Ids;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/letter/MANIFEST.MF b/wizards/com/sun/star/wizards/letter/MANIFEST.MF
new file mode 100644
index 000000000000..a83d3a91d4f0
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.letter.CallWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/letter/letter.component b/wizards/com/sun/star/wizards/letter/letter.component
new file mode 100644
index 000000000000..277aae81e90a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/letter.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.wizards.letter.CallWizard$WizardImplementation">
+ <service name="com.sun.star.wizards.letter.CallWizard"/>
+ </implementation>
+</component>
diff --git a/wizards/com/sun/star/wizards/letter/makefile.mk b/wizards/com/sun/star/wizards/letter/makefile.mk
new file mode 100644
index 000000000000..ca6c750bac81
--- /dev/null
+++ b/wizards/com/sun/star/wizards/letter/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = letter
+PACKAGE = com$/sun$/star$/wizards$/letter
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar java_uno_accessbridge commonwizards.jar
+
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/letter
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ LetterDocument.java \
+ LetterWizardDialogConst.java \
+ LetterWizardDialogImpl.java \
+ CallWizard.java \
+ LetterWizardDialog.java \
+ LetterWizardDialogEvents.java \
+ LetterWizardDialogResources.java \
+ LocaleCodes.java \
+ CGLetter.java \
+ CGLetterWizard.java \
+ CGPaperElementLocation.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/letter.component
+
+$(MISC)/letter.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ letter.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt letter.component
diff --git a/wizards/com/sun/star/wizards/makefile.mk b/wizards/com/sun/star/wizards/makefile.mk
new file mode 100644
index 000000000000..a9ec3e2d5735
--- /dev/null
+++ b/wizards/com/sun/star/wizards/makefile.mk
@@ -0,0 +1,150 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..
+PRJNAME = wizards
+TARGET = wizards_common
+PACKAGE = com$/sun$/star$/wizards
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar jut.jar java_uno.jar java_uno_accessbridge
+
+.IF "$(SYSTEM_SAXON)" == "YES"
+EXTRAJARFILES = $(SAXON_JAR)
+.ELSE
+JARFILES += saxon9.jar
+.ENDIF
+
+
+JARCLASSDIRS = \
+ com$/sun$/star$/wizards$/common \
+ com$/sun$/star$/wizards$/db \
+ com$/sun$/star$/wizards$/ui \
+ com$/sun$/star$/wizards$/document \
+ com$/sun$/star$/wizards$/text
+
+JARTARGET = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ common$/HelpIds.java \
+ common$/Desktop.java \
+ common$/NumberFormatter.java \
+ common$/FileAccess.java \
+ common$/Helper.java \
+ common$/InvalidQueryException.java \
+ common$/JavaTools.java \
+ common$/NoValidPathException.java \
+ common$/Properties.java \
+ common$/Resource.java \
+ common$/SystemDialog.java \
+ common$/Configuration.java \
+ common$/ConfigNode.java \
+ common$/ConfigGroup.java \
+ common$/ConfigSet.java \
+ common$/XMLProvider.java \
+ common$/XMLHelper.java \
+ common$/IRenderer.java \
+ common$/Indexable.java \
+ common$/TerminateWizardException.java \
+ common$/UCB.java \
+ common$/DebugHelper.java \
+ common$/PropertySetHelper.java \
+ common$/NumericalHelper.java \
+ common$/NamedValueCollection.java \
+ db$/DBMetaData.java \
+ db$/CommandMetaData.java \
+ db$/QueryMetaData.java \
+ db$/BlindtextCreator.java \
+ db$/FieldColumn.java \
+ db$/CommandName.java \
+ db$/RecordParser.java \
+ db$/TypeInspector.java \
+ db$/ColumnPropertySet.java \
+ db$/RelationController.java \
+ db$/TableDescriptor.java \
+ db$/SQLQueryComposer.java \
+ db$/DatabaseObjectWizard.java \
+ ui$/event$/AbstractListener.java \
+ ui$/event$/CommonListener.java \
+ ui$/event$/DataAware.java \
+ ui$/event$/DataAwareFields.java \
+ ui$/event$/EventNames.java \
+ ui$/event$/ListModelBinder.java \
+ ui$/event$/MethodInvocation.java \
+ ui$/event$/RadioDataAware.java \
+ ui$/event$/SimpleDataAware.java \
+ ui$/event$/Task.java \
+ ui$/event$/TaskEvent.java \
+ ui$/event$/TaskListener.java \
+ ui$/event$/UnoDataAware.java \
+ ui$/AggregateComponent.java \
+ ui$/CommandFieldSelection.java \
+ ui$/ControlScroller.java \
+ ui$/DBLimitedFieldSelection.java \
+ ui$/DocumentPreview.java \
+ ui$/FilterComponent.java \
+ ui$/FieldSelection.java \
+ ui$/ImageList.java \
+ ui$/ButtonList.java \
+ ui$/PathSelection.java \
+ ui$/PeerConfig.java \
+ ui$/SortingComponent.java \
+ ui$/TitlesComponent.java \
+ ui$/WizardDialog.java \
+ ui$/UIConsts.java \
+ ui$/UnoDialog.java \
+ ui$/UnoDialog2.java \
+ ui$/XCommandSelectionListener.java \
+ ui$/XFieldSelectionListener.java \
+ ui$/XPathSelectionListener.java \
+ ui$/XCompletion.java \
+ document$/Control.java \
+ document$/DatabaseControl.java \
+ document$/FormHandler.java \
+ document$/GridControl.java \
+ document$/OfficeDocument.java \
+ document$/Shape.java \
+ document$/TimeStampControl.java \
+ text$/TextDocument.java \
+ text$/TextFieldHandler.java \
+ text$/TextFrameHandler.java \
+ text$/TextSectionHandler.java \
+ text$/TextStyleHandler.java \
+ text$/TextTableHandler.java \
+ text$/ViewHandler.java
+
+
+#JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:s/.java/.class/))
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/wizards/com/sun/star/wizards/query/CallQueryWizard.java b/wizards/com/sun/star/wizards/query/CallQueryWizard.java
new file mode 100644
index 000000000000..fe18fd13f6d0
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/CallQueryWizard.java
@@ -0,0 +1,215 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.query;
+
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Type;
+import com.sun.star.wizards.common.Properties;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>).
+ * @author Bertram Nolte
+ */
+public class CallQueryWizard
+{
+
+ /** 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 xmultiservicefactory The service manager, who gives access to every
+ * known service.
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) 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(QueryWizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(QueryWizardImplementation.class, QueryWizardImplementation.__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 QueryWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor
+ {
+ private PropertyValue[] m_wizardContext;
+ // <properties>
+ public String Command;
+ public final Integer CommandType = com.sun.star.sdb.CommandType.QUERY;
+ // </properties>
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param xmultiservicefactoryInitialization A special service factory
+ * could be introduced while initializing.
+ */
+ public QueryWizardImplementation( XMultiServiceFactory i_serviceFactory )
+ {
+ super();
+ m_serviceFactory = i_serviceFactory;
+ registerProperty( "Command", (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) );
+ registerProperty( "CommandType", PropertyAttribute.READONLY );
+ }
+
+ public void trigger(String sEvent)
+ {
+ try
+ {
+ if (sEvent.compareTo("start") == 0)
+ {
+ QueryWizard CurQueryWizard = new QueryWizard( m_serviceFactory, m_wizardContext );
+ Command = CurQueryWizard.startQueryWizard();
+ }
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+ 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.query.CallQueryWizard";
+ /** The service manager, that gives access to all registered services.
+ */
+ private com.sun.star.lang.XMultiServiceFactory m_serviceFactory;
+
+ /** 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 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
+ {
+ 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[1];
+
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /** This method returns an array of bytes, that can be used to
+ * unambiguously distinguish between two sets of types, e.g.
+ * to realise hashing functionality when the object is introspected.
+ * Two objects that return the same ID also have to return
+ * the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to
+ * return an empty sequence. Important: If the object
+ * aggregates other objects the ID has to be unique for the
+ * whole combination of objects.
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = new String("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (QueryWizardImplementation.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.
+ */
+ 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 exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/query/Finalizer.java b/wizards/com/sun/star/wizards/query/Finalizer.java
new file mode 100644
index 000000000000..f60422503be3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/Finalizer.java
@@ -0,0 +1,195 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.query;
+
+import com.sun.star.wizards.common.*;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.wizards.db.*;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.uno.*;
+import com.sun.star.wizards.ui.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class Finalizer
+{
+ private QueryWizard m_queryWizard;
+ private String resQuery;
+ private XTextComponent m_aTxtTitle;
+ private XRadioButton xRadioDisplayQuery;
+ private QuerySummary CurDBMetaData;
+
+ public Finalizer( QueryWizard i_queryWizard, QuerySummary _CurDBMetaData )
+ {
+ short curtabindex = (short) (100 * QueryWizard.SOSUMMARY_PAGE);
+ String reslblQueryTitle;
+ String resoptDisplayQuery;
+ String resoptModifyQuery;
+ String resflnSummary;
+ String reslblHowGoOn;
+ this.m_queryWizard = i_queryWizard;
+ this.CurDBMetaData = _CurDBMetaData;
+ reslblQueryTitle = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 5);
+ resoptDisplayQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 6);
+ resoptModifyQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 7);
+ resflnSummary = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 87);
+ reslblHowGoOn = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 8);
+ resQuery = m_queryWizard.m_oResource.getResText(UIConsts.RID_QUERY + 1);
+ int curHelpIndex = 40955;
+
+ m_queryWizard.insertLabel("lblQueryTitle", new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), reslblQueryTitle, new Integer(95), new Integer(27), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(52)
+ });
+ m_aTxtTitle = m_queryWizard.insertTextField("txtQueryTitle", "changeTitle", this, new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(12), HelpIds.getHelpIdString(curHelpIndex++), new Integer(95), new Integer(37), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(90)
+ });
+ m_queryWizard.insertLabel("lblHowGoOn", new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(16), reslblHowGoOn, Boolean.TRUE, new Integer(192), new Integer(27), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(112)
+ });
+ this.xRadioDisplayQuery = m_queryWizard.insertRadioButton("optDisplayQuery",
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(9), HelpIds.getHelpIdString(curHelpIndex++), resoptDisplayQuery, new Integer(192), new Integer(46), new Short((short) 1), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(118)
+ });
+
+ m_queryWizard.insertRadioButton("optModifyQuery",
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), HelpIds.getHelpIdString(curHelpIndex++), resoptModifyQuery, new Integer(192), new Integer(56), new Integer(QueryWizard.SOSUMMARY_PAGE), new Short(curtabindex++), new Integer(118)
+ });
+ m_queryWizard.insertFixedLine("flnSummary", new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), resflnSummary, new Integer(95), new Integer(68), new Integer(8), new Short(curtabindex++), new Integer(209)
+ });
+ m_queryWizard.insertTextField("txtSummary", 0, null, new String[]
+ {
+ "Height", "HelpURL", "MultiLine", "PositionX", "PositionY", "ReadOnly", "Step", "VScroll", "Width"
+ },
+ new Object[]
+ {
+ new Integer(96), HelpIds.getHelpIdString(curHelpIndex++), Boolean.TRUE, new Integer(95), new Integer(80), Boolean.TRUE, new Integer(8), Boolean.TRUE, new Integer(209)
+ });
+ }
+
+ public void changeTitle()
+ {
+ final String TitleName = m_aTxtTitle.getText();
+ m_queryWizard.enableFinishButton( TitleName.length() > 0 );
+ }
+
+ /* TODO: The title textbox always has to be updated when
+ a new Table has been selected if it is clear that the user has not made any input meanwhile
+ */
+ protected String initialize()
+ {
+ try
+ {
+ String sCurQueryName = AnyConverter.toString(Helper.getUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text"));
+ if (sCurQueryName != null)
+ {
+ if (sCurQueryName.equals(""))
+ {
+ String[] sCommandNames = CurDBMetaData.getIncludedCommandNames();
+ sCurQueryName = resQuery + "_" + sCommandNames[0];
+ sCurQueryName = CurDBMetaData.ConnectionTools.getObjectNames().suggestName(CommandType.QUERY, sCurQueryName);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text", sCurQueryName);
+ }
+ }
+
+ CurDBMetaData.setSummaryString();
+ m_queryWizard.setControlProperty("txtSummary", "Text", CurDBMetaData.getSummaryString());
+ return sCurQueryName;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return "";
+ }
+ }
+
+ private String getTitle()
+ {
+ final String sTitle = (String) Helper.getUnoPropertyValue(UnoDialog.getModel(m_aTxtTitle), "Text");
+ return sTitle;
+ }
+
+ public String finish()
+ {
+ String queryName = getTitle();
+ if ( CurDBMetaData.getSQLQueryComposer().setQueryCommand( m_queryWizard.xWindow, true, true )
+ && CurDBMetaData.createQuery( CurDBMetaData.getSQLQueryComposer(), queryName )
+ )
+ return queryName;
+
+ return "";
+ }
+
+ public final boolean displayQueryDesign()
+ {
+ try
+ {
+ final short state = AnyConverter.toShort( Helper.getUnoPropertyValue( UnoDialog.getModel( xRadioDisplayQuery ), "State" ) );
+ final boolean viewMode = state == (short)1;
+ return !viewMode;
+ }
+ catch ( IllegalArgumentException ex )
+ {
+ Logger.getLogger( Finalizer.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ return false;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/query/MANIFEST.MF b/wizards/com/sun/star/wizards/query/MANIFEST.MF
new file mode 100644
index 000000000000..abb009f220e9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.query.CallQueryWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/query/QuerySummary.java b/wizards/com/sun/star/wizards/query/QuerySummary.java
new file mode 100644
index 000000000000..f570970e0fe8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/QuerySummary.java
@@ -0,0 +1,254 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.query;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.*;
+//import com.sun.star.wizards.ui.FilterComponent;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.wizards.db.*;
+import com.sun.star.beans.*;
+
+public class QuerySummary extends QueryMetaData
+{
+
+ final protected int RID_QUERY = 2300;
+ final protected int RID_REPORT = 2400;
+ String sSummary;
+ Resource oResource;
+ // XMultiServiceFactory xMSF;
+ private String sSeparator;
+ private String sReturnChar;
+ private String sAnd;
+ private String sOr;
+
+ public QuerySummary(XMultiServiceFactory _xMSF, Resource _oResource)
+ {
+ super(_xMSF);
+ this.oResource = _oResource;
+ // this.xMSF = _xMSF;
+ sAnd = oResource.getResText(RID_QUERY + 38);
+ sOr = oResource.getResText(RID_QUERY + 39);
+ sSeparator = oResource.getResText(RID_QUERY + 91);
+ sReturnChar = String.valueOf((char) 13) + String.valueOf((char) 13);
+ }
+
+ /* boolean bAssignAliases = xDBMetaData.supportsColumnAliasing();
+ boolean bSupportsGroupByUnrelated = xDBMetaData.supportsGroupByUnrelated();
+ boolean bSupportsOrderByUnrelated = xDBMetaData.supportsOrderByUnrelated();
+ boolean bSupportsNumericFunctions = xDBMetaData.getNumericFunctions() != "";
+ xDBMetaData.getMaxColumnsInGroupBy();
+ xDBMetaData.getMaxColumnsInOrderBy();
+ xDBMetaData.getMaxColumnsInSelect();
+ xDBMetaData.getMaxCharLiteralLength(); // gef?hrlich, da h?chstwahrscheinlich nicht sauber in jedem Treiber implementiert!!!!!
+ * */
+ public void setSummaryString()
+ {
+ try
+ {
+ String sFieldNamesFraction = "";
+ String sSortingFraction = "";
+ String sFilterFraction = "";
+ String sAggregateFraction = "";
+ String sGroupByFraction = "";
+ String sHavingFraction = "";
+ sFieldNamesFraction = combineFieldNameFraction() + sReturnChar;
+ sSortingFraction = combinePartString(RID_QUERY + 51, getSortFieldNames(), RID_QUERY + 52, RID_QUERY + 93, new String[]
+ {
+ "<FIELDNAME>", "<SORTMODE>"
+ }) + sReturnChar;
+ sFilterFraction = combineFilterNameFraction(this.getFilterConditions(), RID_QUERY + 53, RID_QUERY + 54) + sReturnChar;
+ // if (xDBMetaData.getNumericFunctions().length() > 0)
+ // sAggregateFraction = combinePartString(RID_QUERY + 55, AggregateFieldNames, RID_QUERY + 56, RID_QUERY + 95, new String[]{ "<CALCULATEDFUNCTION>", "<FIELDNAME>"}) + sReturnChar;
+ if (xDBMetaData.supportsGroupBy())
+ {
+ sGroupByFraction = combinePartString(RID_QUERY + 57, GroupFieldNames, RID_QUERY + 58) + sReturnChar;
+ sHavingFraction = combineFilterNameFraction(getGroupByFilterConditions(), RID_QUERY + 59, RID_QUERY + 60);
+ }
+ // TODO: remove the last return from the string
+ sSummary = sFieldNamesFraction + sSortingFraction + sFilterFraction + sAggregateFraction + sGroupByFraction + sHavingFraction;
+ sSummary = JavaTools.replaceSubString(sSummary, "", "~");
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public String getSummaryString()
+ {
+ return sSummary;
+ }
+
+ private String combineFilterNameFraction(PropertyValue[][] _filterconditions, int _InitResID, int _AlternativeResID)
+ {
+ if (_filterconditions != null)
+ {
+ if (_filterconditions.length > 0)
+ {
+ String sconditions = "";
+ String sStart = oResource.getResText(_InitResID);
+ String BaseString = oResource.getResText(RID_QUERY + 96);
+ if (_filterconditions.length == 1)
+ {
+ PropertyValue[] curfilterconditions = _filterconditions[0];
+ for (int i = 0; i < curfilterconditions.length; i++)
+ {
+ sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[0][i], this);
+ sconditions = appendClauseSeparator(sconditions, " " + sAnd + " ", i, curfilterconditions.length);
+ }
+ }
+ else
+ {
+
+ for (int i = 0; i < _filterconditions.length; i++)
+ {
+ sconditions += FilterComponent.getDisplayCondition(BaseString, _filterconditions[i][0], this);
+ sconditions = appendClauseSeparator(sconditions, " " + sOr + " ", i, _filterconditions.length);
+ }
+ }
+ String sreturn = sStart + sconditions;
+ return sreturn;
+ }
+ }
+ return oResource.getResText(_AlternativeResID);
+ }
+
+ private String combineFieldNameFraction()
+ {
+ String CurString = "";
+ String sReturn = oResource.getResText(RID_QUERY + 50);
+ String BaseString = oResource.getResText(RID_QUERY + 92);
+ for (int i = 0; i < FieldColumns.length; i++)
+ {
+ CurString = BaseString;
+ FieldColumn CurDBFieldColumn = super.getFieldColumnByDisplayName(FieldColumns[i].getDisplayFieldName());
+ int iAggregate = getAggregateIndex(FieldColumns[i].getFieldName());
+ if (iAggregate > -1)
+ {
+ String sAggregateDisplay = AggregateFieldNames[iAggregate][1] + "(" + AggregateFieldNames[iAggregate][0] + ")";
+ CurString = JavaTools.replaceSubString(CurString, sAggregateDisplay, "<FIELDNAME>");
+ }
+ else
+ {
+ CurString = JavaTools.replaceSubString(CurString, CurDBFieldColumn.getDisplayFieldName(), "<FIELDNAME>");
+ }
+ sReturn += JavaTools.replaceSubString(CurString, CurDBFieldColumn.getFieldTitle(), "<FIELDTITLE>");
+ sReturn = appendClauseSeparator(sReturn, sSeparator, i, FieldColumns.length);
+ }
+ return sReturn;
+ }
+
+ private String appendClauseSeparator(String _basestring, String _suffix, int _i, int _fieldcount)
+ {
+ if (_i < _fieldcount - 1)
+ {
+ _basestring += _suffix;
+ }
+ return _basestring;
+ }
+ // TODO: How can you merge the following two methods to a single one in a smarter way??
+ public String combinePartString(int _InitResID, String[] _FieldNames, int _AlternativeResID)
+ {
+ if (_FieldNames != null)
+ {
+ if (_FieldNames.length > 0)
+ {
+ return ArrayFieldsToString(_InitResID, _FieldNames);
+ }
+ }
+ return oResource.getResText(_AlternativeResID);
+ }
+
+ protected String ArrayFieldsToString(int _InitResID, String[] _FieldNames)
+ {
+ String sReturn = oResource.getResText(_InitResID);
+ int FieldCount = _FieldNames.length;
+ for (int i = 0; i < FieldCount; i++)
+ {
+ sReturn += this.getFieldColumnByDisplayName(_FieldNames[i]).getFieldTitle();
+ if (i < FieldCount - 1)
+ {
+ sReturn += sSeparator;
+ }
+ }
+ return (sReturn);
+ }
+
+ public String combinePartString(int _InitResID, String[][] _FieldNames, int _AlternativeResID, int _BaseStringID, String[] _ReplaceTags)
+ {
+ if (_FieldNames != null)
+ {
+ if (_FieldNames.length > 0)
+ {
+ return ArrayFieldsToString(_InitResID, _FieldNames, _BaseStringID, _ReplaceTags);
+ }
+ }
+ return oResource.getResText(_AlternativeResID);
+ }
+
+ public String ArrayFieldsToString(int _InitResID, String[][] _FieldNames, int _BaseStringID, String[] _ReplaceTags)
+ {
+ String CurString = "";
+ String sReturn = oResource.getResText(_InitResID);
+ int FieldCount = _FieldNames.length;
+ if (FieldCount > 0)
+ {
+ int DimCount = _FieldNames[0].length;
+ String BaseString = oResource.getResText(_BaseStringID);
+ for (int i = 0; i < FieldCount; i++)
+ {
+ for (int a = 0; a < DimCount; a++)
+ {
+ if (a == 0)
+ {
+ int iAggregate = getAggregateIndex(this.getFieldColumnByDisplayName(_FieldNames[i][a]).getDisplayFieldName());
+ if (iAggregate > -1)
+ {
+ String sAggregateDisplay = AggregateFieldNames[iAggregate][1] + "(" + AggregateFieldNames[iAggregate][0] + ")";
+ CurString = JavaTools.replaceSubString(BaseString, sAggregateDisplay, _ReplaceTags[a]);
+ }
+ else
+ {
+ CurString = JavaTools.replaceSubString(BaseString, this.getFieldColumnByDisplayName(_FieldNames[i][a]).getFieldTitle(), _ReplaceTags[a]);
+ }
+ }
+ else
+ {
+ CurString = JavaTools.replaceSubString(CurString, _FieldNames[i][a], _ReplaceTags[a]);
+ }
+ }
+ sReturn += CurString;
+ if (i < FieldCount - 1)
+ {
+ sReturn += sSeparator;
+ }
+ }
+ }
+ return sReturn;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/query/QueryWizard.java b/wizards/com/sun/star/wizards/query/QueryWizard.java
new file mode 100644
index 000000000000..a0970534d657
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/QueryWizard.java
@@ -0,0 +1,557 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.query;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XFrame;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.db.DatabaseObjectWizard;
+import com.sun.star.wizards.db.QueryMetaData;
+import com.sun.star.wizards.ui.AggregateComponent;
+import com.sun.star.wizards.ui.CommandFieldSelection;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.FilterComponent;
+import com.sun.star.wizards.ui.SortingComponent;
+import com.sun.star.wizards.ui.TitlesComponent;
+
+public class QueryWizard extends DatabaseObjectWizard
+{
+ public static final String SFILLUPFIELDSLISTBOX = "fillUpFieldsListbox";
+ private static final int SOFIELDSELECTION_PAGE = 1;
+ private static final int SOSORTING_PAGE = 2;
+ private static final int SOFILTER_PAGE = 3;
+ private static final int SOAGGREGATE_PAGE = 4;
+ private static final int SOGROUPSELECTION_PAGE = 5;
+ private static final int SOGROUPFILTER_PAGE = 6;
+ private static final int SOTITLES_PAGE = 7;
+ protected static final int SOSUMMARY_PAGE = 8;
+ private CommandFieldSelection m_DBCommandFieldSelectio;
+ private SortingComponent m_sortingComponent;
+ private FieldSelection m_groupFieldSelection;
+ private TitlesComponent m_titlesComponent;
+ private FilterComponent m_filterComponent;
+ private FilterComponent m_groupFilterComponent;
+ private AggregateComponent m_aggregateComponent;
+ private Finalizer m_finalizer;
+ private QuerySummary m_DBMetaData;
+ private String reslblFieldHeader;
+ private String reslblAliasHeader;
+ private String reslblFields;
+ private String reslblSelFields;
+ private String reslblTables;
+ private String resQueryWizard;
+ private String reslblGroupBy;
+ private String resmsgNonNumericAsGroupBy;
+ private String m_createdQuery;
+
+ public QueryWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext )
+ {
+ super( xMSF, 40970, i_wizardContext );
+ addResourceHandler("QueryWizard", "dbw");
+ m_DBMetaData = new QuerySummary(xMSF, m_oResource);
+ }
+
+ public static void main(String i_args[])
+ {
+ final String settings[] = new String[] { null, null, null };
+ final int IDX_PIPE_NAME = 0;
+ final int IDX_LOCATION = 1;
+ final int IDX_DSN = 2;
+
+ // some simple parsing
+ boolean failure = false;
+ int settingsIndex = -1;
+ for ( int i=0; i<i_args.length; ++i )
+ {
+ if ( settingsIndex >= 0 )
+ {
+ settings[ settingsIndex ] = i_args[i];
+ settingsIndex = -1;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--pipe-name" ) )
+ {
+ settingsIndex = IDX_PIPE_NAME;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--database-location" ) )
+ {
+ settingsIndex = IDX_LOCATION;
+ continue;
+ }
+
+ if ( i_args[i].equals( "--data-source-name" ) )
+ {
+ settingsIndex = IDX_DSN;
+ continue;
+ }
+
+ failure = true;
+ }
+
+ if ( settings[ IDX_PIPE_NAME ] == null )
+ failure = true;
+
+ if ( ( settings[ IDX_DSN ] == null ) && ( settings[ IDX_LOCATION ] == null ) )
+ failure = true;
+
+ if ( failure )
+ {
+ System.err.println( "supported arguments: " );
+ System.err.println( " --pipe-name <name> : specifies the name of the pipe to connect to the running OOo instance" );
+ System.err.println( " --database-location <url> : specifies the URL of the database document to work with" );
+ System.err.println( " --data-source-name <name> : specifies the name of the data source to work with" );
+ return;
+ }
+
+ final String ConnectStr = "uno:pipe,name=" + settings[IDX_PIPE_NAME] + ";urp;StarOffice.ServiceManager";
+ try
+ {
+ final XMultiServiceFactory serviceFactory = Desktop.connect(ConnectStr);
+ if (serviceFactory != null)
+ {
+ PropertyValue[] curproperties = new PropertyValue[1];
+ if ( settings[ IDX_LOCATION ] != null )
+ curproperties[0] = Properties.createProperty( "DatabaseLocation", settings[ IDX_LOCATION ] );
+ else
+ curproperties[0] = Properties.createProperty( "DataSourceName", settings[ IDX_DSN ] );
+
+ QueryWizard CurQueryWizard = new QueryWizard( serviceFactory, curproperties );
+ CurQueryWizard.startQueryWizard();
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ public final XFrame getFrame()
+ {
+ return m_frame;
+ }
+
+ public String startQueryWizard()
+ {
+ try
+ {
+ if ( m_DBMetaData.getConnection( m_wizardContext ) )
+ {
+ reslblFields = m_oResource.getResText(UIConsts.RID_QUERY + 4);
+ reslblFieldHeader = m_oResource.getResText(UIConsts.RID_QUERY + 19); //Fielnames in AliasComponent
+ reslblAliasHeader = m_oResource.getResText(UIConsts.RID_QUERY + 20); //Fieldtitles header in AliasComponent
+ reslblSelFields = m_oResource.getResText(UIConsts.RID_QUERY + 50);
+ reslblTables = m_oResource.getResText(UIConsts.RID_QUERY + 3);
+ reslblGroupBy = m_oResource.getResText(UIConsts.RID_QUERY + 18);
+ resQueryWizard = m_oResource.getResText(UIConsts.RID_QUERY + 2);
+ resmsgNonNumericAsGroupBy = m_oResource.getResText(UIConsts.RID_QUERY + 88);
+ Helper.setUnoPropertyValues(xDialogModel, new String[]
+ {
+ "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ new Integer(210), Boolean.TRUE, "DialogQuery", new Integer(102), new Integer(41), new Integer(1), new Short((short) 0), resQueryWizard, new Integer(310)
+ });
+ drawNaviBar();
+ setRightPaneHeaders(m_oResource, UIConsts.RID_QUERY + 70, 8);
+ this.setMaxStep(8);
+ buildSteps();
+ this.m_DBCommandFieldSelectio.preselectCommand( m_wizardContext, false );
+
+ XWindowPeer windowPeer = UnoRuntime.queryInterface( XWindowPeer.class, m_frame.getContainerWindow() );
+ createWindowPeer(windowPeer);
+ m_DBMetaData.setWindowPeer(this.xControl.getPeer());
+ insertQueryRelatedSteps();
+ executeDialog( m_frame.getContainerWindow().getPosSize() );
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ m_groupFilterComponent = null;
+ m_titlesComponent = null;
+ m_aggregateComponent = null;
+ m_DBCommandFieldSelectio = null;
+ xWindowPeer = null;
+ m_finalizer = null;
+ m_DBMetaData.finish();
+ m_DBMetaData = null;
+ System.gc();
+
+ return m_createdQuery;
+ }
+
+ public void enableRoadmapItems(String[] _FieldNames, boolean _bEnabled)
+ {
+ try
+ {
+ Object oRoadmapItem;
+ int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, "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"));
+ switch (CurItemID)
+ {
+ case SOAGGREGATE_PAGE:
+ if (_bEnabled == true)
+ {
+ bEnabled = ((m_DBMetaData.hasNumericalFields()) && (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar()));
+ }
+ break;
+ case SOGROUPSELECTION_PAGE:
+ bEnabled = m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY;
+ break;
+ case SOGROUPFILTER_PAGE:
+ bEnabled = false;
+ if (_bEnabled == true)
+ {
+ bEnabled = (m_DBMetaData.GroupByFilterConditions.length > 0);
+ }
+
+ break;
+ default:
+ if (CurItemID > CurStep)
+ {
+ bEnabled = _bEnabled;
+ }
+ else
+ {
+ bEnabled = true;
+ }
+ break;
+ }
+ super.setStepEnabled(CurItemID, bEnabled);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void insertQueryRelatedSteps()
+ {
+ try
+ {
+ setRMItemLabels(m_oResource, UIConsts.RID_QUERY + 80);
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, SOFIELDSELECTION_PAGE - 1, SOFIELDSELECTION_PAGE);
+ i = insertRoadmapItem(i, false, SOSORTING_PAGE - 1, SOSORTING_PAGE); // Orderby is always supported
+ i = insertRoadmapItem(i, false, SOFILTER_PAGE - 1, SOFILTER_PAGE);
+ if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar())
+ {
+ i = insertRoadmapItem(i, m_DBMetaData.hasNumericalFields(), SOAGGREGATE_PAGE - 1, SOAGGREGATE_PAGE);
+ }
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
+ {
+ i = insertRoadmapItem(i, false, SOGROUPSELECTION_PAGE - 1, SOGROUPSELECTION_PAGE);
+ i = insertRoadmapItem(i, false, SOGROUPFILTER_PAGE - 1, SOGROUPFILTER_PAGE);
+ }
+ // if (CurDBMetaData.xDBMetaData.supportsColumnAliasing()) don't use -> too dangerous!!!
+ i = insertRoadmapItem(i, false, SOTITLES_PAGE - 1, SOTITLES_PAGE);
+ i = insertRoadmapItem(i, false, SOSUMMARY_PAGE - 1, SOSUMMARY_PAGE);
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ Resource.showCommonResourceError(xMSF);
+ }
+ }
+
+ public void buildSteps()
+ {
+ try
+ {
+ m_DBCommandFieldSelectio = new CommandFieldSelection(this, m_DBMetaData, 120, reslblFields, reslblSelFields, reslblTables, true, 40850);
+ m_DBCommandFieldSelectio.setAppendMode(true);
+ m_DBCommandFieldSelectio.addFieldSelectionListener(new FieldSelectionListener());
+ m_sortingComponent = new SortingComponent(this, SOSORTING_PAGE, 95, 27, 210, 40865);
+ m_filterComponent = new FilterComponent(this, xMSF, SOFILTER_PAGE, 97, 27, 209, 3, m_DBMetaData, 40878);
+ m_filterComponent.addNumberFormats();
+
+ if (m_DBMetaData.xDBMetaData.supportsCoreSQLGrammar())
+ {
+ m_aggregateComponent = new AggregateComponent(this, m_DBMetaData, SOAGGREGATE_PAGE, 97, 69, 209, 5, 40895);
+ }
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
+ {
+ m_groupFieldSelection = new FieldSelection(this, SOGROUPSELECTION_PAGE, 95, 27, 210, 150, reslblFields, this.reslblGroupBy, 40915, false);
+ m_groupFieldSelection.addFieldSelectionListener(new FieldSelectionListener());
+ m_groupFilterComponent = new FilterComponent(this, xMSF, SOGROUPFILTER_PAGE, 97, 27, 209, 3, m_DBMetaData, 40923);
+ }
+ m_titlesComponent = new TitlesComponent(this, SOTITLES_PAGE, 97, 37, 207, 7, reslblFieldHeader, reslblAliasHeader, 40940);
+ m_finalizer = new Finalizer(this, m_DBMetaData);
+ enableNavigationButtons(false, false, false);
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ Resource.showCommonResourceError(xMSF);
+ }
+ }
+
+ public boolean finishWizard()
+ {
+ int ncurStep = getCurrentStep();
+ if ( ( ncurStep == SOSUMMARY_PAGE )
+ || ( switchToStep( ncurStep, SOSUMMARY_PAGE ) )
+ )
+ {
+ m_createdQuery = m_finalizer.finish();
+ if ( m_createdQuery.length() > 0 )
+ {
+ loadSubComponent( CommandType.QUERY, m_createdQuery, m_finalizer.displayQueryDesign() );
+ xDialog.endExecute();
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ try
+ {
+ if (nOldStep <= SOGROUPSELECTION_PAGE && nNewStep > SOGROUPSELECTION_PAGE)
+ {
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
+ {
+ m_DBMetaData.setGroupFieldNames(m_groupFieldSelection.getSelectedFieldNames());
+ m_DBMetaData.GroupFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.GroupFieldNames, m_DBMetaData.NonAggregateFieldNames);
+ m_DBMetaData.GroupByFilterConditions = JavaTools.removeOutdatedFields(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.GroupFieldNames);
+ }
+ }
+ switch (nNewStep)
+ {
+ case SOFIELDSELECTION_PAGE:
+ break;
+ case SOSORTING_PAGE:
+ m_sortingComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.getSortFieldNames());
+ break;
+ case SOFILTER_PAGE:
+ m_filterComponent.initialize(m_DBMetaData.getFilterConditions(), m_DBMetaData.getDisplayFieldNames());
+ break;
+ case SOAGGREGATE_PAGE:
+ m_aggregateComponent.initialize();
+ break;
+ case SOGROUPSELECTION_PAGE:
+ break;
+ case SOGROUPFILTER_PAGE:
+ m_groupFilterComponent.initialize(m_DBMetaData.GroupByFilterConditions, m_DBMetaData.getGroupFieldNames());
+ break;
+ case SOTITLES_PAGE:
+ m_titlesComponent.initialize(m_DBMetaData.getDisplayFieldNames(), m_DBMetaData.FieldTitleSet);
+ break;
+ case SOSUMMARY_PAGE:
+ m_finalizer.initialize();
+ break;
+ default:
+ break;
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ switch (nOldStep)
+ {
+ case SOFIELDSELECTION_PAGE:
+ m_DBMetaData.reorderFieldColumns(m_DBCommandFieldSelectio.getSelectedFieldNames());
+ m_DBMetaData.initializeFieldTitleSet(true);
+ m_DBMetaData.setNumericFields();
+ searchForOutdatedFields();
+ break;
+ case SOSORTING_PAGE:
+ m_DBMetaData.setSortFieldNames(m_sortingComponent.getSortFieldNames());
+ break;
+ case SOFILTER_PAGE:
+ m_DBMetaData.setFilterConditions(m_filterComponent.getFilterConditions());
+ break;
+ case SOAGGREGATE_PAGE:
+ m_DBMetaData.AggregateFieldNames = m_aggregateComponent.getAggregateFieldNames();
+ break;
+ case SOGROUPSELECTION_PAGE:
+ break;
+ case SOGROUPFILTER_PAGE:
+ m_DBMetaData.setGroupByFilterConditions(this.m_groupFilterComponent.getFilterConditions());
+ break;
+ case SOTITLES_PAGE:
+ m_DBMetaData.setFieldTitles(m_titlesComponent.getFieldTitles());
+ break;
+ case SOSUMMARY_PAGE:
+ break;
+ default:
+ break;
+ }
+ if (nOldStep < SOGROUPSELECTION_PAGE && nNewStep >= SOGROUPSELECTION_PAGE)
+ {
+ try
+ {
+ if (m_DBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)
+ {
+ if (m_DBMetaData.xDBMetaData.supportsGroupBy())
+ {
+ m_DBMetaData.setNonAggregateFieldNames();
+ m_groupFieldSelection.initialize(m_DBMetaData.getUniqueAggregateFieldNames(), false, m_DBMetaData.xDBMetaData.getMaxColumnsInGroupBy());
+ m_groupFieldSelection.intializeSelectedFields(m_DBMetaData.NonAggregateFieldNames);
+ m_groupFieldSelection.setMultipleMode(false);
+ setStepEnabled(SOGROUPFILTER_PAGE, m_aggregateComponent.isGroupingpossible() && m_DBMetaData.NonAggregateFieldNames.length > 0);
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ private void searchForOutdatedFields()
+ {
+ String[] sFieldNames = m_DBMetaData.getFieldNames();
+ String[][] sRemovedFields = JavaTools.removeOutdatedFields(m_DBMetaData.getSortFieldNames(), sFieldNames);
+ m_DBMetaData.setSortFieldNames(sRemovedFields);
+ m_DBMetaData.setFilterConditions(JavaTools.removeOutdatedFields(m_DBMetaData.getFilterConditions(), sFieldNames));
+ m_DBMetaData.AggregateFieldNames = JavaTools.removeOutdatedFields(m_DBMetaData.AggregateFieldNames, sFieldNames);
+ }
+
+ private void enableWizardSteps(String[] NewItems)
+ {
+ boolean bEnabled = NewItems.length > 0;
+ setControlProperty("btnWizardNext", "Enabled", bEnabled);
+ setControlProperty("btnWizardFinish", "Enabled", bEnabled);
+ enableRoadmapItems(NewItems, bEnabled); // Note: Performancewise this could be improved
+ }
+
+ public class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener
+ {
+
+ protected int ID;
+
+ public int getID()
+ {
+ return ID;
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ ID = 1;
+ if (sIncSuffix != null)
+ {
+ if ((!sIncSuffix.equals("")) && (!sIncSuffix.equals("_")))
+ {
+ String sID = JavaTools.ArrayoutofString(sIncSuffix, "_")[1];
+ ID = Integer.parseInt(sID);
+ int a = 0;
+ }
+ }
+ }
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ if (ID == 1)
+ {
+ m_DBMetaData.addSeveralFieldColumns(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName());
+ enableWizardSteps(NewItems);
+ m_DBCommandFieldSelectio.changeSelectedFieldNames(m_DBMetaData.getDisplayFieldNames());
+ m_DBCommandFieldSelectio.toggleCommandListBox(NewItems);
+ }
+ else
+ {
+ boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0);
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", bEnabled);
+ }
+ }
+
+ 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 (ID == 1)
+ {
+ enableWizardSteps(NewItems);
+ String[] sSelfieldNames = m_DBMetaData.getFieldNames(SelItems, m_DBCommandFieldSelectio.getSelectedCommandName());
+ m_DBCommandFieldSelectio.addItemsToFieldsListbox(sSelfieldNames);
+ m_DBMetaData.removeSeveralFieldColumnsByDisplayFieldName(SelItems);
+ m_DBCommandFieldSelectio.toggleCommandListBox(NewItems);
+
+ }
+ else
+ {
+ boolean bEnabled = (m_groupFieldSelection.getSelectedFieldNames().length > 0);
+ String CurDisplayFieldName = SelItems[0];
+ if (JavaTools.FieldInList(m_DBMetaData.NonAggregateFieldNames, CurDisplayFieldName) > -1)
+ {
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, resmsgNonNumericAsGroupBy);
+ m_groupFieldSelection.xSelectedFieldsListBox.addItems(SelItems, m_groupFieldSelection.xSelectedFieldsListBox.getItemCount());
+ String FieldList[] = m_groupFieldSelection.xFieldsListBox.getItems();
+ int index = JavaTools.FieldInList(FieldList, CurDisplayFieldName);
+ if (index > -1)
+ {
+ m_groupFieldSelection.xFieldsListBox.removeItems((short) index, (short) 1);
+ }
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPFILTER_PAGE), "Enabled", bEnabled);
+ }
+ }
+ }
+
+ public void moveItemDown(String item)
+ {
+ }
+
+ public void moveItemUp(String item)
+ {
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/query/makefile.mk b/wizards/com/sun/star/wizards/query/makefile.mk
new file mode 100644
index 000000000000..080076668ce8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/makefile.mk
@@ -0,0 +1,69 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = query
+PACKAGE = com$/sun$/star$/wizards$/query
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar jut.jar java_uno.jar commonwizards.jar
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/query
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+#SRS2NAME = dbwizres
+#SRC2FILES= dbwizres.src
+#RESLIB2SRSFILES= $(SRS)$/dbwizres.srs
+#RESLIB2NAME= dbw
+
+JAVAFILES= \
+ CallQueryWizard.java \
+ Finalizer.java \
+ QueryWizard.java \
+ QuerySummary.java\
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/query.component
+
+$(MISC)/query.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ query.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt query.component
diff --git a/wizards/com/sun/star/wizards/query/query.component b/wizards/com/sun/star/wizards/query/query.component
new file mode 100644
index 000000000000..d1d708c6b91b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/query/query.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name=
+ "com.sun.star.wizards.query.CallQueryWizard$QueryWizardImplementation">
+ <service name="com.sun.star.wizards.query.CallQueryWizard"/>
+ </implementation>
+</component>
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 000000000000..c66596e11c02
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/CallReportWizard.java
@@ -0,0 +1,263 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.wizards.common.NamedValueCollection;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>).
+ * @author Bertram Nolte
+ */
+public class CallReportWizard
+{
+
+ static boolean bWizardstartedalready;
+
+/* public static void main(String args[])
+ {
+ String ConnectStr = "uno:pipe,name=fs93730;urp;StarOffice.ServiceManager";
+ try
+ {
+ XMultiServiceFactory orb = Desktop.connect(ConnectStr);
+ if ( orb != null )
+ {
+ PropertyValue[] curproperties = new PropertyValue[1];
+ curproperties[0] = Properties.createProperty("DataSourceName", "countries");
+
+ ReportWizard wizard = new ReportWizard( orb, curproperties );
+ wizard.startReportWizard();
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }*/
+
+ /** Gives a factory for creating the service.
+ * This method is called by the <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 tree
+ * structures) 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.lang.XTypeProvider, 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.compareTo("start") == 0)
+ {
+ if (bWizardstartedalready != true)
+ {
+ ReportWizard CurReportWizard = new ReportWizard( xmultiservicefactory, m_wizardContext );
+ CurReportWizard.startReportWizard();
+ }
+ bWizardstartedalready = false;
+ }
+ else if (sEvent.compareTo("fill") == 0)
+ {
+ 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 exception)
+ {
+ System.err.println(exception);
+ }
+ 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 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);
+
+ // xmultiservicefactory = (XMultiservicefactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, object[0]);
+ }
+
+ /** 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[1];
+
+ stringSupportedServiceNames[ 0] = __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);
+ }
+
+ /** This method returns an array of bytes, that can be used to
+ * unambiguously distinguish between two sets of types, e.g.
+ * to realise hashing functionality when the object is introspected.
+ * Two objects that return the same ID also have to return
+ * the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to
+ * return an empty sequence. Important: If the object
+ * aggregates other objects the ID has to be unique for the
+ * whole combination of objects.
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = new String("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /** 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.
+ */
+ 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 exception)
+ {
+ System.err.println(exception);
+ }
+
+ 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 000000000000..eb6ce3229ac4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/DBColumn.java
@@ -0,0 +1,482 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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.lang.IndexOutOfBoundsException;
+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.util.XNumberFormats;
+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
+{
+
+ public XCell xValCell;
+ public XTextRange xValTextCell;
+ public XTextCursor xValCellCursor;
+ public XNumberFormats xValCellNumberFormats;
+ public XCell xNameCell;
+ public XTextRange xNameTextCell;
+ public boolean bAlignLeft;
+ public Object DefaultValue;
+ public String CharFontName;
+ public int FormatKey;
+ public PropertyState PropertyState;
+ public int ValColumn = 1;
+ public int ValRow = 0;
+ public FieldColumn CurDBField;
+ private XTextTable xTextTable;
+ private XTableColumns xTableColumns;
+ private XCellRange xCellRange;
+ public XNamed xTableName;
+ private boolean bIsGroupColumn;
+ TextDocument oTextDocument;
+ RecordParser CurDBMetaData;
+ RecordTable CurRecordTable;
+ TextTableHandler oTextTableHandler;
+
+ public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i) throws Exception
+ {
+ CurRecordTable = new RecordTable(_oTextTableHandler);
+ initializeRecordTableMembers(CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, false);
+ }
+
+ public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bforce) throws Exception
+ {
+ initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, _bforce);
+ }
+
+ public DBColumn(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i) throws Exception
+ {
+ initializeRecordTableMembers(_CurRecordTable, _oTextTableHandler, _CurDBMetaData, i, false);
+ }
+
+ private void initializeRecordTableMembers(RecordTable _CurRecordTable, TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, int i, boolean _bForce) throws Exception
+ {
+ 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 = (XTextRange) 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 = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xValCell);
+ xValCellCursor = TextDocument.createTextCursor(xValCell);
+ ValColumn = _nColumn;
+ return true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public DBColumn(TextTableHandler _oTextTableHandler, RecordParser _CurDBMetaData, String _FieldName, int GroupIndex, String TableName, DBColumn OldDBColumn) throws Exception
+ {
+ 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, int GroupIndex, 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 = (XTextRange) 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) == true)
+ {
+ Object oTextTable = xAllTextTables.getByName(TableName);
+ xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, oTextTable);
+ xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, oTextTable);
+ xTableName = (XNamed) 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);
+ }
+
+ public void insertUserFieldToTableCell(TextFieldHandler oTextFieldHandler)
+ {
+ XTextCursor xTextCursor = TextDocument.createTextCursor(xNameCell);
+ xTextCursor.gotoStart(false);
+ xTextCursor.gotoEnd(true);
+ xTextCursor.setString("");
+ oTextFieldHandler.insertUserField(xTextCursor, CurDBField.getFieldName(), CurDBField.getFieldTitle());
+ }
+
+ public void insertUserFieldToTableCell(TextFieldHandler oTextFieldHandler, XCell xCell)
+ {
+ XTextCursor xTextCursor = TextDocument.createTextCursor(xCell);
+ xTextCursor.gotoStart(false);
+ xTextCursor.gotoEnd(true);
+ xTextCursor.setString("");
+ 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 = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xValCell);
+ modifyCellContent(CurGroupValue);
+ if (bAlignLeft)
+ {
+ xValCellCursor = TextDocument.createTextCursor(xValCell);
+ Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", new Integer(com.sun.star.style.ParagraphAdjust.LEFT_value));
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public 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 = (double) AnyConverter.toInt(CurGroupValue);
+ }
+ if (AnyConverter.isByte(CurGroupValue))
+ {
+ dblValue = (double) AnyConverter.toByte(CurGroupValue);
+ }
+ else if (AnyConverter.isDouble(CurGroupValue))
+ {
+ dblValue = AnyConverter.toDouble(CurGroupValue);
+ }
+ else if (AnyConverter.isFloat(CurGroupValue))
+ {
+ dblValue = (double) AnyConverter.toFloat(CurGroupValue);
+ }
+ else if (AnyConverter.isInt(CurGroupValue))
+ {
+ dblValue = (double) AnyConverter.toInt(CurGroupValue);
+ }
+ else if (AnyConverter.isLong(CurGroupValue))
+ {
+ dblValue = (double) AnyConverter.toLong(CurGroupValue);
+ }
+ else if (AnyConverter.isShort(CurGroupValue))
+ {
+ dblValue = (double) AnyConverter.toShort(CurGroupValue);
+ }
+ xValCell.setValue(dblValue);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+ }
+ // If the parameter CurGroupValue is null the placeholders are inserted
+ public void replaceValueCellofTable(boolean _bIsLandscape)
+ {
+ try
+ {
+ Object CurGroupValue;
+ if (bIsGroupColumn == false && CurDBField.isNumberFormat() == false)
+ {
+ CurGroupValue = BlindtextCreator.adjustBlindTextlength(CurDBField.getFieldTitle(), CurDBField.getFieldWidth(), _bIsLandscape, bIsGroupColumn, CurDBMetaData.getRecordFieldNames());
+ }
+ else
+ {
+ CurGroupValue = CurDBField.getDefaultValue();
+ }
+ modifyCellContent(CurGroupValue);
+ if (bAlignLeft)
+ {
+ Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", new Integer(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 == false)
+ {
+ Helper.setUnoPropertyValue(xValCellCursor, "ParaAdjust", new Integer(ParagraphAdjust.CENTER_value));
+ }
+ }
+ else
+ {
+ if (PropertyState == com.sun.star.beans.PropertyState.DEFAULT_VALUE)
+ {
+ XPropertyState xPropState = (XPropertyState) 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.out);
+ }
+ }
+
+ 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 = (XPropertyState) UnoRuntime.queryInterface(XPropertyState.class, xValCellCursor);
+ PropertyState = xPropertyState.getPropertyState("CharFontName");
+ CharFontName = AnyConverter.toString(Helper.getUnoPropertyValue(xValCellCursor, "CharFontName"));
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ 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 = (XDependentTextField) UnoRuntime.queryInterface(XDependentTextField.class, oTextField);
+ XPropertySet xMaster = xDependent.getTextFieldMaster();
+ String UserFieldName = (String) xMaster.getPropertyValue("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)
+ {
+// sMsgInvalidTextField = oResource.getResText(UIConsts.RID_REPORT + 73);
+// SystemDialog.showMessageBox(oTextTableHandler.xMSFDoc, "ErrorBox", VclWindowPeerAttribute.OK, sMsgInvalidTextField);
+ exception.printStackTrace(System.out);
+ 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 000000000000..7c3aeaaab073
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/Dataimport.java
@@ -0,0 +1,222 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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;
+
+public class Dataimport extends UnoDialog2 implements com.sun.star.awt.XActionListener
+{ // extends ReportWizard
+
+ // ReportTextDocument CurReportDocument;
+ IReportDocument CurReportDocument;
+
+// PropertyValue[] CurProperties;
+ static boolean bStopProcess;
+ static String sProgressDBConnection;
+ static String sProgressDataImport;
+ static String sProgressBaseCurRecord;
+ static String sProgressCurRecord;
+ static String sProgressTitle;
+ static String sStop;
+
+// public static final String TBLRECORDSECTION = ReportTextDocument.TBLRECORDSECTION;
+// public static final String TBLGROUPSECTION = ReportTextDocument.TBLGROUPSECTION;
+// public static final String RECORDSECTION = ReportTextDocument.RECORDSECTION;
+// public static final String GROUPSECTION = ReportTextDocument.GROUPSECTION;
+// public static final String COPYOFTBLRECORDSECTION = ReportTextDocument.COPYOFTBLRECORDSECTION;
+// public static final String COPYOFTBLGROUPSECTION = ReportTextDocument.COPYOFTBLGROUPSECTION;
+// public static final String COPYOFRECORDSECTION = ReportTextDocument.COPYOFRECORDSECTION;
+// public static final String COPYOFGROUPSECTION = ReportTextDocument.COPYOFGROUPSECTION;
+ public Dataimport(XMultiServiceFactory _xMSF)
+ {
+ super(_xMSF);
+ super.addResourceHandler("ReportWizard", "dbw");
+ sProgressDBConnection = m_oResource.getResText(UIConsts.RID_DB_COMMON + 34);
+ sProgressDataImport = m_oResource.getResText(UIConsts.RID_REPORT + 67);
+ sProgressTitle = m_oResource.getResText(UIConsts.RID_REPORT + 62);
+ sProgressBaseCurRecord = m_oResource.getResText(UIConsts.RID_REPORT + 63);
+ sStop = m_oResource.getResText(UIConsts.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();
+ }
+
+// public static void main(String args[])
+// {
+// String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService";
+// XMultiServiceFactory xMSF = null;
+// try
+// {
+// xMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr);
+// if (xMSF != null)
+// {
+// System.out.println("Connected to " + ConnectStr);
+// }
+// PropertyValue[] curproperties = new PropertyValue[3];
+// curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/MyHSQL.odb");
+//// curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///C:/Documents and Settings/bc93774.EHAM02-DEV/My Documents/MyDocAssign.odb"); //baseLocation ); "DataSourceName", "db1");
+//// curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography");
+// curproperties[1] = Properties.createProperty("CommandType", new Integer(CommandType.TABLE));
+// curproperties[2] = Properties.createProperty("Command", "Table2");
+//
+// Dataimport CurDataimport = new Dataimport(xMSF);
+// TextDocument oTextDocument = new TextDocument(xMSF, true, null);
+// CurDataimport.createReport(xMSF, oTextDocument.xTextDocument, curproperties);
+//
+// }
+// catch (Exception e)
+// {
+// e.printStackTrace(System.out);
+// }
+// catch (java.lang.Exception javaexception)
+// {
+// javaexception.printStackTrace(System.out);
+// }
+// }
+ public void showProgressDisplay(XMultiServiceFactory xMSF, boolean bgetConnection)
+ {
+ try
+ {
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Height", "Step", "Title", "Width"
+ },
+ new Object[]
+ {
+ new Integer(84), new Integer(0), sProgressTitle, new Integer(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[]
+ {
+ "FontDescriptor", "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ oFontDesc, new Integer(10), sProgressDBConnection, new Integer(6), new Integer(6), new Integer(0), new Integer(150)
+ });
+
+ insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), sProgressDataImport, new Integer(6), new Integer(24), new Integer(0), new Integer(120)
+ });
+ }
+ else
+ {
+ insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblProgressDataImport",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ oFontDesc, new Integer(10), sProgressDataImport, new Integer(6), new Integer(24), new Integer(0), new Integer(120)
+ });
+ }
+ insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblCurProgress",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "", new Integer(12), new Integer(42), new Integer(0), new Integer(120)
+ });
+
+ insertButton("cmdCancel", 10000, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width", "Label"
+ },
+ new Object[]
+ {
+ new Integer(14), HelpIds.getHelpIdString(34321), new Integer(74), new Integer(58), new Integer(0), new Short((short) 1), new Integer(40), sStop
+ });
+ createWindowPeer(CurReportDocument.getWizardParent());
+ calculateDialogPosition(CurReportDocument.getFrame().getComponentWindow().getPosSize());
+ xWindow.setVisible(true);
+ super.xReschedule.reschedule();
+ return;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ // return;
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ // return;
+ }
+ }
+
+ // public void importReportData(final XMultiServiceFactory xMSF, final Dataimport CurDataimport, final ReportTextDocument CurReportDocument.getDoc()) {
+ public void importReportData(final XMultiServiceFactory _xMSF, final Dataimport _CurDataimport, IReportDocument _CurReportDocument, 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(xMSF, true);
+ importReportData(xMSF, this, CurReportDocument, 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 000000000000..82e478bac781
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/GroupFieldHandler.java
@@ -0,0 +1,196 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.wizards.db.*;
+
+import java.util.Vector;
+
+public class GroupFieldHandler extends FieldSelection
+{
+
+ private IReportDocument CurReportDocument;
+ private Vector GroupFieldVector = new Vector();
+ private QueryMetaData CurDBMetaData;
+ private WizardDialog oWizardDialog;
+ private static final short MAXSELFIELDS = 4;
+
+ public GroupFieldHandler(IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog)
+ {
+ super(_CurUnoDialog, ReportWizard.SOGROUPPAGE, 95, 27, 210, 127,
+ _CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 19),
+ _CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 50), 34340, false);
+
+ try
+ {
+ this.oWizardDialog = _CurUnoDialog;
+ this.CurReportDocument = _CurReportDocument;
+ this.CurDBMetaData = CurReportDocument.getRecordParser();
+ CurUnoDialog.setControlProperty("lstFields_2", "MultiSelection", new Boolean(false));
+ CurUnoDialog.setControlProperty("lstSelFields_2", "MultiSelection", new Boolean(false));
+ addFieldSelectionListener(new FieldSelectionListener());
+ String sNote = ReportWizard.getBlindTextNote(_CurReportDocument, _CurUnoDialog.m_oResource);
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_1",
+ new String[]
+ {
+ "Enabled", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Boolean(false), new Integer(18), sNote, new Boolean(true), new Integer(95), new Integer(158), new Integer(ReportWizard.SOGROUPPAGE), new Integer(209)
+ });
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public boolean isGroupField(String _FieldName)
+ {
+ return (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, _FieldName) != -1);
+ }
+
+ public void initialize()
+ {
+ try
+ {
+ Vector NormalFieldsVector = new Vector();
+ Vector SelFieldsVector = new Vector();
+ 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.out);
+ }
+ }
+
+ public void removeGroupFieldNames()
+ {
+ emptyFieldsListBoxes();
+ GroupFieldVector.removeAllElements();
+ CurUnoDialog.setControlProperty("lblBlindTextNote_1", "Enabled", new Boolean(false));
+ }
+
+ public void getGroupFieldNames(CommandMetaData CurDBMetaData)
+ {
+ String[] GroupFieldNames = new String[GroupFieldVector.size()];
+ GroupFieldVector.copyInto(GroupFieldNames);
+ CurDBMetaData.GroupFieldNames = GroupFieldNames;
+ }
+ // @Override
+ protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex)
+ {
+ super.toggleListboxButtons(iFieldsSelIndex, iSelFieldsSelIndex);
+ int iSelCount = xSelectedFieldsListBox.getItemCount();
+ if (iSelCount >= MAXSELFIELDS)
+ {
+ CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, "Enabled", Boolean.FALSE);
+ }
+ }
+
+ public void selectFields(boolean bMoveAll)
+ {
+ int iSelCount = xSelectedFieldsListBox.getItemCount();
+ if (iSelCount < MAXSELFIELDS)
+ {
+ super.selectFields(bMoveAll);
+ }
+
+ }
+
+ /* protected */ 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", "Enabled", new 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", "Enabled", new Boolean(NewSelGroupNames.length == 0));
+
+ // CurReportDocument.refreshGroupFields(xSelectedFieldsListBox.getItems());
+ }
+ }
+
+ public int getID()
+ {
+ // TODO: here is a good place for a comment, isn't it?
+ return 2;
+ }
+
+ 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 100755
index 000000000000..6422befd65f0
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/IReportBuilderLayouter.java
@@ -0,0 +1,119 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+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.
+ * @author ll93751
+ */
+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.
+ */
+ public 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.
+ */
+ public String getLocalizedName();
+
+ /**
+ * For Landscape give nOrientation == com.sun.star.wizards.report.ReportLayouter.SOOPTLANDSCAPE
+ * All other numbers are interpreted as portrait format.
+ * @param nOrientation
+ */
+ public void setPageOrientation(int nOrientation);
+
+ /**
+ * dispose the layouter
+ */
+ public 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
+ * @param TableName
+ */
+ public void setTableName(int _nType, String TableName);
+
+ /**
+ * Insert the field names, these are the field names out of a given datebase table
+ * @param FieldNames
+ */
+ public void insertFieldNames(final String[] FieldNames);
+
+ /**
+ * Insert the field type (Varchar, int, ...) as internal an int representation.
+ * @param FieldTypes
+ */
+ public void insertFieldTypes(int[] FieldTypes);
+
+ /**
+ * Insert the field width in count of chars as given in the database.
+ * @param FieldWidths
+ */
+ public void insertFieldWidths(int[] FieldWidths);
+
+ /**
+ * Insert the titles of the field names. This names are free formed
+ * @param _aFieldTitles
+ */
+ public 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.
+ * @param _aGroupFieldNames
+ */
+ public void insertGroupNames(String[] _aGroupFieldNames);
+
+ /**
+ * This method redraws the whole layout with all it's content
+ */
+ public void layout();
+
+ /**
+ * Initialize the current Layouter with data's out of an other Layouter.
+ *
+ * This Method copies the internal fields, groups and titles
+ * @param aOtherLayouter
+ */
+ public void initializeData(IReportBuilderLayouter aOtherLayouter);
+
+ public 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 100755
index 000000000000..59fd096fe363
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/IReportDefinitionReadAccess.java
@@ -0,0 +1,61 @@
+ /*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ***********************************************************************
+ */
+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.
+ * @author ll93751
+ */
+public interface IReportDefinitionReadAccess
+{
+
+ /**
+ * Gives access to a ReportDefinition, if initialized.
+ * @return a ReportDefinition or null.
+ */
+ public XReportDefinition getReportDefinition(); /* should throw NullPointerException but does not. */
+
+
+ /**
+ * This ServiceFactory is the 'global' Service Factory, which knows all and every thing in the program.
+ * @return the global service factory of the program
+ */
+ public XMultiServiceFactory getGlobalMSF();
+
+ /**
+ * Returns the file path to the default report definition, we need this name for early initialisation
+ * @return
+ */
+ public 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 000000000000..702a776f9c98
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/IReportDocument.java
@@ -0,0 +1,268 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.wizards.common.Resource;
+import java.util.ArrayList;
+import java.util.Vector;
+
+/**
+ * New Interface which gives us the possibility to switch on the fly between the old
+ * Wizard and the new Sun Report Builder Wizard, which use the same UI.
+ *
+ * @author ll93751
+ */
+public interface IReportDocument
+{
+ // -------------------------------------------------------------------------
+ // initialisation
+ // -------------------------------------------------------------------------
+ public void initialize(
+ final XDatabaseDocumentUI i_documentUI,
+ final Resource i_resource
+ );
+
+ // -------------------------------------------------------------------------
+ // Access Helper
+ // -------------------------------------------------------------------------
+ /**
+ * Gives access to the DB Values
+ * @return
+ */
+ public 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
+ * @return
+ */
+ public com.sun.star.awt.XWindowPeer getWizardParent();
+
+ /**
+ *
+ * @return the Frame of the document Window or Report Builder Window
+ */
+ public com.sun.star.frame.XFrame getFrame();
+
+ public 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.
+ * @param _aType
+ * @param TableName
+ * @param FieldNames
+ */
+ public void initializeFieldColumns(final int _aType, final String TableName, final String[] FieldNames);
+
+ /**
+ * Empties the report document
+ */
+ public void clearDocument();
+
+ /**
+ * Empties the report document, if we called back, don't remove Grouping/Sorting
+ */
+ public void removeTextTableAndTextSection();
+
+ // -------------------------------------------------------------------------
+ // Second step: Label field titles
+ // -------------------------------------------------------------------------
+ /**
+ * Set new names for the titles
+ * @param sFieldTitles
+ */
+ public void setFieldTitles(final String[] sFieldTitles);
+
+ /**
+ * Change a 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
+ * @param FieldName
+ * @param TitleName
+ */
+ public 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 then') add a group to the group list
+ * @param GroupNames
+ * @param CurGroupTitle
+ * @param GroupFieldVector
+ * @param ReportPath
+ * @param iSelCount
+ * @return
+ */
+ public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount);
+
+ public void refreshGroupFields(String[] _sNewNames);
+ // public boolean isGroupField(String _FieldName);
+ /**
+ * Called by press ('less then') Removes an already set Groupname out of the list
+ * @param NewSelGroupNames
+ * @param CurGroupTitle
+ * @param GroupFieldVector
+ */
+ public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.Vector GroupFieldVector);
+
+ /**
+ * set the list how to group
+ * @param aGroupList
+ */
+ public void setGrouping(String[] aGroupList);
+ // -------------------------------------------------------------------------
+ // Fourth step: Sorting
+ // -------------------------------------------------------------------------
+ /**
+ * Set the list how to sort
+ * @param aSort
+ */
+ public void setSorting(String[][] aSort);
+ // -------------------------------------------------------------------------
+ // Fivth step: Templates / Layout
+ // -------------------------------------------------------------------------
+ /* Template Page */
+ public void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException;
+
+ public int getDefaultPageOrientation();
+
+ public ArrayList getReportPath();
+
+ public String getLayoutPath();
+
+ public String getContentPath();
+
+ /**
+ * Called if a new Layout is selected
+ * @param LayoutTemplatePath
+ */
+ public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/);
+
+ /**
+ * Called if a new Template is selected
+ * @param ContentTemplatePath
+ */
+ public void liveupdate_changeContentTemplate(String ContentTemplatePath);
+
+ // public String[] getLayoutTemplates();
+ // public String[] getContentTemplates();
+ public void layout_selectFirstPage();
+
+ public 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.
+ * @param _sTitleName
+ */
+ public void liveupdate_updateReportTitle(String _sTitleName);
+
+ /**
+ * Store the document by the given name
+ * @param Name
+ * @param OpenMode
+ */
+ public 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
+ */
+ public void addReportToDBView();
+
+ public void importReportData(ReportWizard aWizard);
+
+ /**
+ * Create the final Report document
+ * @param Name
+ * @param _bAsTemplate
+ * @param _bOpenInDesign
+ * @return
+ */
+ public void createAndOpenReportDocument(
+ final String Name,
+ final boolean _bAsTemplate,
+ final boolean _bOpenInDesign
+ );
+
+ public void dispose();
+ // -------------------------------------------------------------------------
+ // Garbage dump
+ // -------------------------------------------------------------------------
+ /* DataImport */
+ // ???
+ // public void addTextSectionCopies();
+ // ???
+ public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties);
+ // ???
+ public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF);
+ // ???
+ // public com.sun.star.lang.XMultiServiceFactory getDocumentServiceFactory();
+ /**
+ * set a internal variable to stop a maybe longer DB access.
+ */
+ public void StopProcess(); // cancel
+
+ /**
+ * Returns a string list of layouts.
+ * @return
+ */
+ public String[][] getDataLayout();
+
+ /**
+ * Returns a string list of header layouts
+ * @return
+ */
+ public String[][] getHeaderLayout();
+
+ public void setCommandType(int CommandType);
+
+ public void setCommand(String Command);
+
+ /**
+ * check internal invariants
+ * @throws a
+ */
+ public 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 000000000000..1a4f8da6e3b0
--- /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 000000000000..b4af7f7fa94b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/RecordTable.java
@@ -0,0 +1,99 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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.table.XTableRows;
+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
+{
+
+ String CurFieldName;
+ String LabelDescription;
+ public XNamed xTableName;
+ public XCellRange xCellRange;
+ public XTextTable xTextTable;
+ private TextTableHandler oTextTableHandler;
+ public XTableColumns xTableColumns;
+ public XTableRows xTableRows;
+
+ public RecordTable(TextTableHandler _oTextTableHandler)
+ {
+ try
+ {
+ this.oTextTableHandler = _oTextTableHandler;
+ String[] TableNames = oTextTableHandler.xTextTablesSupplier.getTextTables().getElementNames();
+ 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 = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, oTable);
+ xTableName = (XNamed) UnoRuntime.queryInterface(XNamed.class, xTextTable);
+ }
+ else
+ {
+ XIndexAccess xTableIndex = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xAllTextTables);
+ int n = xTableIndex.getCount() - 1;
+ Object x = xTableIndex.getByIndex(n);
+ xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, x);
+ xTableName = (XNamed) UnoRuntime.queryInterface(XNamed.class, xTextTable);
+ xTableName.setName(ReportTextDocument.TBLRECORDSECTION);
+ }
+ xTableRows = xTextTable.getRows();
+ xTableColumns = xTextTable.getColumns();
+ xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, xTextTable);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ 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 000000000000..7c40c01809d2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportFinalizer.java
@@ -0,0 +1,293 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+//import com.sun.star.ucb.CommandAbortedException;
+import com.sun.star.ucb.XSimpleFileAccess;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.ui.*;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XTextComponent;
+//import com.sun.star.container.XHierarchicalNameAccess;
+//import com.sun.star.container.XNameAccess;
+//import com.sun.star.lang.EventObject;
+//import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.db.RecordParser;
+//import com.sun.star.wizards.document.OfficeDocument;
+public class ReportFinalizer
+{
+
+ WizardDialog CurUnoDialog;
+ XTextComponent xTitleTextBox;
+ XTextComponent[] xSaveTextBox = new XTextComponent[2];
+ Object chkTemplate;
+ String CHANGEREPORTTITLE_FUNCNAME = "changeReportTitle";
+ String TOGGLESUBTEMPLATECONTROLS_FUNCNAME = "toggleSubTemplateControls";
+// String slblHowProceed;
+// String slblChooseReportKind;
+ String TemplatePath;
+ String StoreName;
+ boolean bfinalaskbeforeOverwrite;
+ String DefaultName;
+ String OldDefaultName;
+ // ReportTextDocument CurReportDocument;
+ IReportDocument CurReportDocument;
+ // Desktop.OfficePathRetriever curofficepath;
+// short curtabindex;
+// String sMsgReportDocumentNameDuplicate;
+ public static final int SOCREATEDOCUMENT = 1;
+ public static final int SOCREATETEMPLATE = 2;
+ public static final int SOUSETEMPLATE = 3;
+ private XMultiServiceFactory m_xMSF;
+ // public Finalizer(ReportTextDocument _CurReportDocument, WizardDialog _CurUnoDialog) {
+ public ReportFinalizer(XMultiServiceFactory _xMSF, IReportDocument _CurReportDocument, WizardDialog _CurUnoDialog)
+ {
+ m_xMSF = _xMSF;
+
+ this.CurUnoDialog = _CurUnoDialog;
+ this.CurReportDocument = _CurReportDocument;
+ short curtabindex = (short) (ReportWizard.SOSTOREPAGE * 100);
+ Desktop odesktop = new Desktop();
+ // curofficepath = odesktop.new OfficePathRetriever(m_xMSF);
+
+ String sSaveAsTemplate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 40);
+ String sUseTemplate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 41);
+ String sEditTemplate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 42);
+ String sSaveAsDocument = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 43);
+// String sSaveAs = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 44);
+ String sReportTitle = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 33);
+ String slblHowProceed = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 78);
+ String slblChooseReportKind = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 79);
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblTitle",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sReportTitle, new Integer(95), new Integer(27), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(68)
+ });
+
+ xTitleTextBox = CurUnoDialog.insertTextField("txtTitle", CHANGEREPORTTITLE_FUNCNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(12), "HID:WIZARDS_HID_DLGREPORT_4_TITLE", new Integer(95), new Integer(37), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(209)
+ });
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblChooseReportKind",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblChooseReportKind, new Integer(95), new Integer(57), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(209)
+ });
+
+ CurUnoDialog.insertRadioButton("optCreateDocument", TOGGLESUBTEMPLATECONTROLS_FUNCNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "HID:WIZARDS_HID_DLGREPORT_5_OPTSTATDOCUMENT", sSaveAsDocument, new Integer(95), new Integer(69), new Short((short) 0), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(138)
+ });
+
+ CurUnoDialog.insertRadioButton("optCreateReportTemplate", TOGGLESUBTEMPLATECONTROLS_FUNCNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), "HID:WIZARDS_HID_DLGREPORT_5_OPTDYNTEMPLATE", sSaveAsTemplate, new Integer(95), new Integer(81), new Short((short) 1), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(209)
+ });
+
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblHowProceed",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblHowProceed, new Integer(105), new Integer(93), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(209)
+ });
+
+
+ CurUnoDialog.insertRadioButton("optEditTemplate", TOGGLESUBTEMPLATECONTROLS_FUNCNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "HID:WIZARDS_HID_DLGREPORT_5_OPTEDITTEMPLATE", sEditTemplate, new Integer(111), new Integer(105), new Integer(6), new Short(curtabindex++), new Integer(138)
+ });
+
+ CurUnoDialog.insertRadioButton("optUseTemplate", TOGGLESUBTEMPLATECONTROLS_FUNCNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "HID:WIZARDS_HID_DLGREPORT_5_OPTUSETEMPLATE", sUseTemplate, new Integer(111), new Integer(115), new Short((short) 1), new Integer(ReportWizard.SOSTOREPAGE), new Short(curtabindex++), new Integer(138)
+ });
+ }
+
+
+ /*
+ * This function is called if one of the radio buttons is pressed
+ */
+ public void toggleSubTemplateControls()
+ {
+ // String sStorePath = "";
+ Short iState = (Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", "State");
+ boolean bDoTemplateEnable = iState.shortValue() == 1;
+ CurUnoDialog.setControlProperty("optEditTemplate", "Enabled", new Boolean(bDoTemplateEnable));
+ CurUnoDialog.setControlProperty("optUseTemplate", "Enabled", new Boolean(bDoTemplateEnable));
+ CurUnoDialog.setControlProperty("lblHowProceed", "Enabled", new Boolean(bDoTemplateEnable));
+
+ String sTitle = xTitleTextBox.getText();
+ boolean bDoEnable = sTitle.equals("");
+ CurUnoDialog.enableFinishButton(!bDoEnable);
+ }
+// private boolean fileexists(XMultiServiceFactory _xMSF, String _spath){
+// try {
+// XInterface xUcbInterface = (XInterface) _xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+// XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+// return xSimpleFileAccess.exists(_spath);
+// } catch (Exception exception) {
+// exception.printStackTrace(System.out);
+// return false;
+// }}
+ public void initialize(RecordParser _CurDBMetaData)
+ {
+ String FirstCommandName = (_CurDBMetaData.getIncludedCommandNames())[0];
+ DefaultName = Desktop.getUniqueName(_CurDBMetaData.getReportDocuments(), FirstCommandName);
+ if (DefaultName.equals(OldDefaultName) == false)
+ {
+ OldDefaultName = DefaultName;
+ }
+ xTitleTextBox.setText(DefaultName);
+ }
+
+ public String getStoreName()
+ {
+ if (CurUnoDialog != null)
+ {
+ String LocStoreName = xTitleTextBox.getText();
+ if (!LocStoreName.equals(""))
+ {
+ StoreName = LocStoreName;
+ }
+ }
+ return (StoreName);
+ }
+
+ public String getStorePath()
+ {
+ try
+ {
+ StoreName = getStoreName();
+ String StorePath;
+ XInterface xInterface = (XInterface) m_xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) UnoRuntime.queryInterface(XSimpleFileAccess.class, xInterface);
+ StorePath = FileAccess.getOfficePath(m_xMSF, "Temp", xSimpleFileAccess) + "/" + StoreName;
+ return StorePath;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return "";
+ }
+ }
+
+ public void changeReportTitle()
+ {
+ final String TitleName = xTitleTextBox.getText();
+ CurReportDocument.liveupdate_updateReportTitle(TitleName);
+ CurUnoDialog.enableFinishButton(!"".equals(TitleName));
+ }
+
+ public int getReportOpenMode()
+ {
+ int ReportMode = SOCREATEDOCUMENT;
+ boolean bcreateTemplate = ((Short) CurUnoDialog.getControlProperty("optCreateReportTemplate", "State")).shortValue() == (short) 1;
+ if (bcreateTemplate)
+ {
+ ReportMode = SOCREATETEMPLATE;
+ }
+ boolean buseTemplate = ((Short) CurUnoDialog.getControlProperty("optUseTemplate", "State")).shortValue() == (short) 1;
+ if (buseTemplate)
+ {
+ ReportMode = SOUSETEMPLATE;
+ }
+ boolean buseDocument = ((Short) CurUnoDialog.getControlProperty("optCreateDocument", "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(UIConsts.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 000000000000..a8d26d68cd41
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportImplementationHelper.java
@@ -0,0 +1,68 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.db.RecordParser;
+
+/**
+ *
+ * @author ll93751
+ */
+public class ReportImplementationHelper
+{
+
+ private RecordParser m_aCurDBMetaData;
+ private XMultiServiceFactory m_xMSF;
+ protected int m_nDefaultPageOrientation;
+
+ /**
+ *
+ * @param _aMSF
+ * @param _nOrientation
+ */
+ 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 000000000000..355188e7e675
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportLayouter.java
@@ -0,0 +1,341 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.awt.XListBox;
+// import com.sun.star.awt.XTextComponent;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.ui.*;
+
+public class ReportLayouter
+{
+
+ UnoDialog CurUnoDialog;
+// static String sOrientationHeader;
+// static String sOrientVertical;
+// static String sOrientHorizontal;
+ final int SOTXTTITLE = 28;
+ final int SOCONTENTLST = 29;
+ final static public int SOOPTLANDSCAPE = 30;
+ final static public int SOOPTPORTRAIT = 31;
+ final int SOLAYOUTLST = 32;
+// static String sReportTitle;
+// static String slblDataStructure;
+// static String slblPageLayout;
+// static String sOrganizeFields;
+ XListBox xContentListBox;
+ XListBox xLayoutListBox;
+ int iOldContentPos;
+ int iOldLayoutPos;
+ // ReportTextDocument CurReportDocument;
+ IReportDocument CurReportDocument;
+ public String[][] LayoutFiles;
+ public String[][] ContentFiles;
+ // private Desktop.OfficePathRetriever curofficepath;
+ Object aOrientationImage;
+ // boolean m_bLandscape = true;
+ private XMultiServiceFactory m_xMSF;
+
+ public ReportLayouter(XMultiServiceFactory _xMSF, IReportDocument _CurReportDocument, UnoDialog _CurUnoDialog)
+ {
+ m_xMSF = _xMSF;
+ 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
+ // Desktop odesktop = new Desktop();
+ // curofficepath = odesktop.new OfficePathRetriever(m_xMSF);
+ String slblDataStructure = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 15);
+ String slblPageLayout = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 16);
+// String sOrganizeFields = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 19);
+
+ String sOrientationHeader = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 22);
+ String sOrientVertical = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 23);
+ String sOrientHorizontal = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 24);
+
+ // XInterface xUcbInterface = (XInterface) m_xMSF.createInstance("com.sun.star.ucb.SimpleFileAccess");
+ // XSimpleFileAccess xSimpleFileAccess = (XSimpleFileAccess) com.sun.star.uno.UnoRuntime.queryInterface(XSimpleFileAccess.class, xUcbInterface);
+ // boolean bcntexists = xSimpleFileAccess.exists(CurReportDocument.getReportPath() + "/cnt-default.ott");
+ // boolean bstlexists = xSimpleFileAccess.exists(CurReportDocument.getReportPath() + "/stl-default.ott");
+ // if ((bcntexists == false) || (bstlexists == false))
+ // throw new NoValidPathException(CurReportDocument.xMSF);
+
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblContent",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblDataStructure, new Integer(95), new Integer(27), new Integer(ReportWizard.SOTEMPLATEPAGE), new Short(curtabindex++), new Integer(99)
+ });
+
+ short iSelPos = 0;
+// ContentFiles = FileAccess.getFolderTitles(m_xMSF, "cnt", CurReportDocument.getReportPath());
+ ContentFiles = CurReportDocument.getDataLayout();
+ iSelPos = (short) JavaTools.FieldInList(ContentFiles[1], CurReportDocument.getContentPath());
+ if (iSelPos < 0)
+ {
+ iSelPos = 0;
+ }
+ iOldContentPos = (int) iSelPos;
+ xContentListBox = CurUnoDialog.insertListBox("lstContent", SOCONTENTLST, new ActionListenerImpl(), new ItemListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "SelectedItems", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(108), "HID:WIZARDS_HID_DLGREPORT_4_DATALAYOUT", new Integer(95), new Integer(37), new short[]
+ {
+ iSelPos
+ }, new Integer(ReportWizard.SOTEMPLATEPAGE), ContentFiles[0], new Short(curtabindex++), new Integer(99)
+ });
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblLayout",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblPageLayout, new Integer(205), new Integer(27), new Integer(ReportWizard.SOTEMPLATEPAGE), new Short(curtabindex++), new Integer(99)
+ });
+
+ short iSelLayoutPos = 0;
+// LayoutFiles = FileAccess.getFolderTitles(m_xMSF, "stl", CurReportDocument.getReportPath());
+ 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[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "SelectedItems", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(108), "HID:WIZARDS_HID_DLGREPORT_4_PAGELAYOUT", new Integer(205), new Integer(37), new short[]
+ {
+ iSelLayoutPos
+ }, new Integer(ReportWizard.SOTEMPLATEPAGE), LayoutFiles[0], new Short(curtabindex++), new Integer(99)
+ });
+ iOldLayoutPos = (int) iSelPos;
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblOrientation",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sOrientationHeader, new Integer(95), new Integer(148), new Integer(ReportWizard.SOTEMPLATEPAGE), new Short(curtabindex++), new Integer(74)
+ });
+
+ short m_nLandscapeState = CurReportDocument.getDefaultPageOrientation() == SOOPTLANDSCAPE ? (short) 1 : 0;
+ CurUnoDialog.insertRadioButton("optLandscape", SOOPTLANDSCAPE, new ItemListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "HID:WIZARDS_HID_DLGREPORT_4_LANDSCAPE", sOrientHorizontal, new Integer(101), new Integer(158), new Short(m_nLandscapeState), new Integer(ReportWizard.SOTEMPLATEPAGE), new Short(curtabindex++), new Integer(60)
+ });
+
+ short m_nPortraitState = CurReportDocument.getDefaultPageOrientation() == SOOPTPORTRAIT ? (short) 1 : (short) 0;
+ CurUnoDialog.insertRadioButton("optPortrait", SOOPTPORTRAIT, new ItemListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), "HID:WIZARDS_HID_DLGREPORT_4_PORTRAIT", sOrientVertical, new Integer(101), new Integer(171), new Short(m_nPortraitState), new Integer(ReportWizard.SOTEMPLATEPAGE), new Short(curtabindex++), new Integer(60)
+ });
+
+ aOrientationImage = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgOrientation",
+ new String[]
+ {
+ "Border", "Height", "PositionX", "PositionY", "ScaleImage", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Short("0"), new Integer(23), new Integer(164), new Integer(158), new Boolean(false), new Integer(ReportWizard.SOTEMPLATEPAGE), new Integer(30)
+ });
+
+ String sNote = ReportWizard.getBlindTextNote(CurReportDocument, CurUnoDialog.m_oResource);
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblBlindTextNote_2",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(34), sNote, new Boolean(true), new Integer(205), new Integer(148), new Integer(ReportWizard.SOTEMPLATEPAGE), new Integer(99)
+ });
+ if (m_nLandscapeState == 1)
+ {
+ CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, 1002, 1003);
+ }
+ else
+ {
+ CurUnoDialog.getPeerConfiguration().setImageUrl(aOrientationImage, 1000, 1001);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void initialize(String _defaultTemplatePath)
+ {
+// CurReportDocument.getDoc().xTextDocument.lockControllers();
+ CurReportDocument.layout_setupRecordSection(_defaultTemplatePath);
+ if (CurUnoDialog.getControlProperty("txtTitle", "Text").equals(""))
+ {
+ String[] sCommandNames = CurReportDocument.getRecordParser().getIncludedCommandNames();
+ CurUnoDialog.setControlProperty("txtTitle", "Text", sCommandNames[0]);
+ }
+ // CurReportDocument.getDoc().oViewHandler.selectFirstPage(CurReportDocument.getDoc().oTextTableHandler);
+ CurReportDocument.layout_selectFirstPage();
+ CurUnoDialog.setFocus("lblContent");
+// CurReportDocument.getDoc().unlockallControllers();
+ }
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
+ {
+ try
+ {
+ int iPos;
+ Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", new 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]);
+ }
+ break;
+
+ case SOLAYOUTLST:
+ iPos = xLayoutListBox.getSelectedItemPos();
+ if (iPos != iOldLayoutPos)
+ {
+ iOldLayoutPos = iPos;
+ CurReportDocument.liveupdate_changeLayoutTemplate(LayoutFiles[1][iPos]/*, Desktop.getBitmapPath(m_xMSF)*/);
+ }
+ break;
+
+ case SOOPTLANDSCAPE:
+ // CurReportDocument.getDoc().changePageOrientation(true);
+ try
+ {
+ CurReportDocument.setPageOrientation(SOOPTLANDSCAPE);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+ Helper.setUnoPropertyValue(aOrientationImage, "ImageURL", CurUnoDialog.getWizardImageUrl(1002, 1003));
+
+ break;
+
+ case SOOPTPORTRAIT:
+ // CurReportDocument.getDoc().changePageOrientation( false);
+ try
+ {
+ CurReportDocument.setPageOrientation(SOOPTPORTRAIT);
+ }
+ catch (com.sun.star.lang.IllegalArgumentException e)
+ {
+ }
+
+ CurUnoDialog.setControlProperty("imgOrientation", "ImageURL", Desktop.getBitmapPath(m_xMSF) + "/portrait.gif");
+ Helper.setUnoPropertyValue(aOrientationImage, "ImageURL", CurUnoDialog.getWizardImageUrl(1000, 1001));
+ break;
+
+ default:
+ break;
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace();
+ }
+ // CurReportDocument.getDoc().unlockallControllers();
+ Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", new 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, "Enabled", new Boolean(false));
+// CurReportDocument.getDoc().xTextDocument.lockControllers();
+ boolean blandscape = (((Short) CurUnoDialog.getControlProperty("optLandscape", "State")).shortValue() == 1);
+ CurReportDocument.setPageOrientation((blandscape == true) ? SOOPTLANDSCAPE : SOOPTPORTRAIT);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+// CurReportDocument.getDoc().unlockallControllers();
+ Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", new Boolean(true));
+ }
+ }
+}
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 000000000000..3ab9e704b9b9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportTextDocument.java
@@ -0,0 +1,786 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+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 java.util.Vector;
+
+import com.sun.star.awt.Rectangle;
+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.table.XCell;
+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;
+
+class ReportTextDocument extends com.sun.star.wizards.text.TextDocument implements Comparator
+{
+ // private XMultiServiceFactory xMSF;
+ // private XMultiServiceFactory xMSFDoc;
+ private Object ReportPageStyle;
+ private Object FirstPageStyle;
+ private int PageWidth;
+ private Rectangle PosSize;
+ // private String ReportFolderName;
+ public Vector DBColumnsVector;
+ private RecordTable CurRecordTable;
+ private String sMsgTableNotExisting;
+ private String sMsgCommonReportError;
+ private String ContentTemplatePath;
+ private String LayoutTemplatePath;
+ // private String sMsgInvalidTextField;
+ private String sMsgEndAutopilot;
+ public boolean bIsCurLandscape;
+ public TextTableHandler oTextTableHandler;
+ public TextSectionHandler oTextSectionHandler;
+ public FormHandler oFormHandler;
+ public TextStyleHandler oTextStyleHandler;
+ public TextFieldHandler oTextFieldHandler;
+ public ViewHandler oViewHandler;
+ public NumberFormatter oNumberFormatter;
+ 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);
+ }
+
+ void lateInit(Resource oResource, RecordParser _aRecordParser)
+ {
+ oTextTableHandler = new TextTableHandler(xMSFDoc, xTextDocument);
+ oTextSectionHandler = new TextSectionHandler(xMSFDoc, xTextDocument);
+ oFormHandler = new FormHandler(xMSFDoc, xTextDocument);
+ oTextStyleHandler = new TextStyleHandler(xMSFDoc, xTextDocument);
+ oViewHandler = new ViewHandler(xMSFDoc, xTextDocument);
+ oTextFieldHandler = new TextFieldHandler(xMSFDoc, xTextDocument);
+ DBColumnsVector = new java.util.Vector();
+ oNumberFormatter = oTextTableHandler.getNumberFormatter();
+ // CurDBMetaData = new RecordParser(xMSF); //, CharLocale, oNumberFormatter);
+ CurDBMetaData = _aRecordParser;
+ long lDateCorrection = oNumberFormatter.getNullDateCorrection();
+ oNumberFormatter.setBooleanReportDisplayNumberFormat();
+ oNumberFormatter.setNullDateCorrection(lDateCorrection);
+ // sMsgInvalidTextField = oResource.getResText(UIConsts.RID_REPORT + 73);
+ sMsgTableNotExisting = oResource.getResText(UIConsts.RID_REPORT + 61);
+ sMsgCommonReportError = oResource.getResText(UIConsts.RID_REPORT + 72);
+ sMsgCommonReportError = JavaTools.replaceSubString(sMsgCommonReportError, String.valueOf((char) 13), "<BR>");
+ sMsgEndAutopilot = oResource.getResText(UIConsts.RID_DB_COMMON + 33);
+ sMsgTableNotExisting = sMsgTableNotExisting + (char) 13 + sMsgEndAutopilot;
+ bIsCurLandscape = true;
+ getReportPageStyles();
+ }
+
+ public NumberFormatter getNumberFormatter()
+ {
+ return oNumberFormatter;
+ }
+
+ public boolean checkReportLayoutMode(String[] GroupFieldNames)
+ {
+ try
+ {
+ XNameAccess xTextSections = oTextSectionHandler.xTextSectionsSupplier.getTextSections();
+ Object oTextSection;
+ if (GroupFieldNames.length > 0)
+ {
+ oTextSection = xTextSections.getByName(GROUPSECTION + String.valueOf(1));
+ }
+ else
+ {
+ oTextSection = xTextSections.getByName(RECORDSECTION);
+ }
+ boolean bLayoutMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(oTextSection, "IsVisible"));
+ return bLayoutMode;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ // In doubt we rather suggest this is LayoutMode...
+ return true;
+ }
+ }
+
+ public void swapContentTemplate(String ContentTemplatePath)
+ {
+// unlockallControllers();
+ //xProgressBar.start("", 10);
+ this.ContentTemplatePath = ContentTemplatePath;
+ loadSectionsfromTemplate(ContentTemplatePath);
+ // xProgressBar.setValue(40);
+ oTextStyleHandler.loadStyleTemplates(ContentTemplatePath, "LoadTextStyles");
+ // xProgressBar.setValue(70);
+ if (CurRecordTable != null)
+ {
+ CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler);
+ }
+ // xProgressBar.setValue(100);
+ oViewHandler.selectFirstPage(oTextTableHandler);
+ // xProgressBar.end();
+ }
+
+ public void swapLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/)
+ {
+ try
+ {
+ // xProgressBar.start("", 10);
+ this.LayoutTemplatePath = LayoutTemplatePath;
+ boolean bOldIsCurLandscape = AnyConverter.toBoolean(Helper.getUnoPropertyValue(ReportPageStyle, "IsLandscape"));
+ oTextStyleHandler.loadStyleTemplates(LayoutTemplatePath, "LoadPageStyles");
+ // xProgressBar.setValue(60);
+ changePageOrientation(bOldIsCurLandscape);
+ // xProgressBar.setValue(100);
+ oViewHandler.selectFirstPage(oTextTableHandler);
+ // xProgressBar.end();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void createReportForm(String SOREPORTFORMNAME)
+ {
+ com.sun.star.container.XNameContainer xNamedForm = oFormHandler.insertFormbyName(SOREPORTFORMNAME);
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xNamedForm);
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "CommandType", new String(Integer.toString(CurDBMetaData.getCommandType())));
+ if (CurDBMetaData.getCommandType() == CommandType.QUERY)
+ {
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "QueryName", CurDBMetaData.getCommandName());
+ // oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", "");
+ DBMetaData.CommandObject oCommand = CurDBMetaData.getQueryByName(CurDBMetaData.getCommandName());
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", CurDBMetaData.Command);
+ }
+ else
+ {
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "QueryName", "");
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "Command", CurDBMetaData.Command);
+ }
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "GroupFieldNames", JavaTools.ArraytoString(CurDBMetaData.GroupFieldNames));
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "FieldNames", JavaTools.ArraytoString(CurDBMetaData.getFieldNames()));
+ oFormHandler.insertHiddenControl(xNameAccess, xNamedForm, "RecordFieldNames", JavaTools.ArraytoString(CurDBMetaData.getRecordFieldNames()));
+ }
+
+ public void updateReportTitle(String _sTitleName)
+ {
+ m_xDocProps.setTitle(_sTitleName);
+ }
+
+ public void getReportPageStyles()
+ {
+ try
+ {
+ Object oPageStyleFamily = oTextStyleHandler.xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles");
+ ReportPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "Standard");
+ FirstPageStyle = Helper.getUnoObjectbyName(oPageStyleFamily, "First Page");
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ 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", new Boolean(bNewLandscape));
+ Helper.setUnoPropertyValue(ReportPageStyle, "Size", oNewSize);
+ Helper.setUnoPropertyValue(FirstPageStyle, "IsLandscape", new Boolean(bNewLandscape));
+ Helper.setUnoPropertyValue(FirstPageStyle, "Size", oNewSize);
+ int iLeftMargin = AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "LeftMargin"));
+ int iRightMargin = AnyConverter.toInt(Helper.getUnoPropertyValue(ReportPageStyle, "RightMargin"));
+ PageWidth = oNewSize.Width - iLeftMargin - iRightMargin;
+ if (CurRecordTable != null)
+ {
+ CurRecordTable.adjustOptimalTableWidths(xMSF, oViewHandler);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public 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], i, TBLGROUPSECTION + (i + 1));
+ if (CurDBColumn == null)
+ {
+ return false;
+ }
+ else
+ {
+ CurDBColumn.formatValueCell();
+ DBColumnsVector.set(i, CurDBColumn);
+ replaceFieldValueInGroupTable(CurDBColumn, i);
+ }
+ }
+ return true;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ 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 = (DBColumn) DBColumnsVector.elementAt(i);
+ String sFieldName = CurDBColumn.CurDBField.getFieldName();
+ if (!sFieldName.equals(_sNewNames[i]))
+ {
+ CurDBColumn.CurDBField = CurDBMetaData.getFieldColumnByDisplayName(_sNewNames[i]);
+ CurDBColumn.insertColumnData(oTextFieldHandler, bIsCurLandscape);
+ }
+ }
+ }
+ //public boolean isGroupField(String _FieldName)
+ // {
+ // return (JavaTools.FieldInList(CurDBMetaData.GroupFieldNames, _FieldName) != -1);
+ // }
+ public void replaceFieldValueInRecordSection(int RecordCount)
+ {
+ int GroupCount = CurDBMetaData.GroupFieldNames.length;
+ int FieldCount = CurDBMetaData.getFieldNames().length;
+ for (int i = GroupCount; i < FieldCount; i++)
+ {
+ ((DBColumn) DBColumnsVector.elementAt(i)).insertColumnData(oTextFieldHandler, this.bIsCurLandscape);
+ }
+ }
+
+ public void updateTextSections(String[] SelGroupNames) throws Exception
+ {
+ 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 = (DBColumn) DBColumnsVector.get(i);
+ CurDBColumn = new DBColumn(oTextTableHandler, CurDBMetaData, SelGroupNames[i], i, TableName, OldDBColumn);
+ CurDBColumn.formatValueCell();
+ DBColumnsVector.setElementAt(CurDBColumn, i);
+ CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape);
+ }
+ }
+
+ public 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 therefor
+ String OldTableName = CurDBColumn.xTableName.getName();
+ if (OldTableName.compareTo(TableName) != 0)
+ {
+ CurDBColumn.xTableName.setName(TableName);
+ }
+ CurDBColumn.insertColumnData(oTextFieldHandler, this.bIsCurLandscape);
+ CurDBColumn.setCellFont();
+ }
+
+ public void replaceFieldValueInRecordTable()
+ {
+ String TableName = TBLRECORDSECTION;
+ String OldTableName = CurRecordTable.xTableName.getName();
+ if (OldTableName.compareTo(TableName) != 0)
+ {
+ CurRecordTable.xTableName.setName(TableName);
+ }
+ int GroupCount = CurDBMetaData.GroupFieldNames.length;
+ int RecordCount = CurDBMetaData.getRecordFieldNames().length;
+ for (int i = GroupCount; i < RecordCount; i++)
+ {
+ ((DBColumn) DBColumnsVector.elementAt(i)).insertColumnData(oTextFieldHandler, this.bIsCurLandscape);
+ }
+ }
+
+ public void insertColumnstoRecordTable()
+ {
+ try
+ {
+ int GroupCount = CurDBMetaData.GroupFieldNames.length;
+ DBColumn CurDBColumn;
+ // Note for some reason the table might lose its name and has to be renamed therefor
+ 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);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ showCommonReportErrorBox(exception);
+ }
+ }
+
+ public boolean addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)
+ {
+ DBColumn CurDBColumn = null;
+ int GroupCount = GroupFieldVector.size();
+ if (GroupCount < 4)
+ {
+ removeGroupNamesofRecordTable(iSelCount);
+ FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle);
+ GroupFieldVector.addElement(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(), GroupCount - 1, TBLGROUPSECTION + (GroupCount));
+ CurDBColumn.formatValueCell();
+ if (CurDBColumn != null)
+ {
+ DBColumnsVector.addElement(CurDBColumn);
+ replaceFieldValueInGroupTable(CurDBColumn, GroupCount - 1);
+ }
+ else
+ {
+ String sMessage = JavaTools.replaceSubString(sMsgTableNotExisting, TBLGROUPSECTION + (GroupCount), "<TABLENAME>");
+ CurDBMetaData.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMessage);
+ }
+ }
+ catch (Exception exception)
+ {
+ showCommonReportErrorBox(exception);
+ }
+
+ }
+
+ return (CurDBColumn != null);
+ }
+
+ public void removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, java.util.Vector GroupFieldVector)
+ {
+ removeGroupNamesofRecordTable(NewSelGroupNames.length + 1);
+ FieldColumn CurFieldColumn = CurDBMetaData.getFieldColumnByTitle(CurGroupTitle);
+ GroupFieldVector.removeElement(CurFieldColumn.getFieldName());
+ try
+ {
+ 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);
+ }
+ catch (Exception exception)
+ {
+ showCommonReportErrorBox(exception);
+ }
+ }
+
+ public void removeGroupNamesofRecordTable(int GroupFieldCount)
+ {
+ int CurFieldCount = DBColumnsVector.size();
+ if (CurFieldCount > GroupFieldCount)
+ {
+ for (int i = CurFieldCount - 1; i >= GroupFieldCount; i--)
+ {
+ DBColumnsVector.removeElementAt(i);
+ }
+ }
+ }
+
+ public 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.out);
+ }
+
+ 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], i, COPYOFTBLGROUPSECTION + (i + 1));
+ }
+ else
+ {
+ if (CurRecordTable == null)
+ {
+ CurRecordTable = new RecordTable(oTextTableHandler);
+ }
+ CurDBColumn = new DBColumn(CurRecordTable, oTextTableHandler, CurDBMetaData, i - CurDBMetaData.GroupFieldNames.length);
+ }
+ if (CurDBColumn != null)
+ {
+ if (CurDBColumn.xNameCell != null)
+ {
+ DBColumnsVector.addElement(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--;
+ }
+ }
+ else
+ {
+ String sMessage = JavaTools.replaceSubString(sMsgTableNotExisting, TBLGROUPSECTION + (CurDBMetaData.GroupFieldNames.length), "<TABLENAME>");
+ CurDBMetaData.showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sMessage);
+ }
+ }
+ java.util.Arrays.sort(CurDBMetaData.RecordFieldColumns, this);
+ }
+ catch (Exception exception)
+ {
+ showCommonReportErrorBox(exception);
+ }
+ }
+
+ public int compare(Object _oObject1, Object _oObject2)
+ {
+ FieldColumn oFieldColumn1 = (FieldColumn) _oObject1;
+ FieldColumn oFieldColumn2 = (FieldColumn) _oObject2;
+ 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 = (DBColumn) DBColumnsVector.get(i);
+ if (oDBColumn.CurDBField.getFieldName().equals(_FieldName))
+ {
+ return oDBColumn;
+ }
+ }
+ return null;
+ }
+
+ public static FieldColumn[] removeFieldColumnByFieldName(String _FieldName, FieldColumn[] _FieldColumns)
+ {
+ try
+ {
+ Vector aFieldColumns = new Vector();
+ 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)
+ {
+ e.printStackTrace(System.out);
+ 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 = (XNameAccess) 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 = (XNameAccess) 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 = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables());
+ XRelativeTextContentRemove 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 = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, oTextTableHandler.getByName(sTableName));
+ boolean bleaveloop = false;
+ while (!bleaveloop)
+ {
+ try
+ {
+// xRelativeTextContentRemove.removeTextContentBefore(xTextContent);
+ 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", new Boolean(_IsVisible));
+ }
+ if (xTextSections.hasByName(RECORDSECTION))
+ {
+ oTextSection = xTextSections.getByName(RECORDSECTION);
+ Helper.setUnoPropertyValue(oTextSection, "IsVisible", new Boolean(_IsVisible));
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ 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 000000000000..05f7ad2a6a5b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportTextImplementation.java
@@ -0,0 +1,734 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.container.XNamed;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.table.XCellRange;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+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.SystemDialog;
+import com.sun.star.wizards.db.DBMetaData;
+import com.sun.star.wizards.db.SQLQueryComposer;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.ui.UIConsts;
+import java.util.ArrayList;
+import java.util.Vector;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ *
+ * @author ll93751
+ */
+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
+ */
+ 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 Vector();
+ }
+
+ 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;
+ }
+ static String sMsgQueryCreationImpossible;
+ static String sReportFormNotExisting;
+ static String sMsgHiddenControlMissing;
+ static String sMsgEndAutopilot;
+ static String sMsgConnectionImpossible;
+ static String sMsgNoConnection;
+ static String[] ReportMessages = new String[4];
+
+ private void initialResources()
+ {
+ sReportFormNotExisting = m_resource.getResText(UIConsts.RID_REPORT + 64);
+ sMsgQueryCreationImpossible = m_resource.getResText(UIConsts.RID_REPORT + 65);
+ sMsgHiddenControlMissing = m_resource.getResText(UIConsts.RID_REPORT + 66);
+ sMsgEndAutopilot = m_resource.getResText(UIConsts.RID_DB_COMMON + 33);
+ sMsgNoConnection = m_resource.getResText(UIConsts.RID_DB_COMMON + 14);
+ }
+
+ public void addTextSectionCopies()
+ {
+ 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) != true);
+ if (bIsGroupTable == true)
+ {
+ XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
+ XCellRange xCellRange = UnoRuntime.queryInterface( XCellRange.class, xTextTable );
+ CurDBColumn.modifyCellContent(xCellRange, CurGroupValue);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ 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;
+ String sQueryName = "";
+ if (oDBForm != null)
+ {
+ String sMsg = sMsgHiddenControlMissing + (char) 13 + sMsgEndAutopilot;
+ XNameAccess xNamedForm = UnoRuntime.queryInterface( XNameAccess.class, oDBForm );
+ getRecordParser().Command = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Command", sMsg);
+ String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "CommandType", sMsg);
+ String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames", sMsg);
+ String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames", sMsg);
+ String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames", sMsg);
+ if (xNamedForm.hasByName("QueryName"))
+ {
+ sQueryName = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "QueryName", sMsg);
+ }
+ String[] sFieldNameList = JavaTools.ArrayoutofString(sFieldNames, ";");
+ String[] sNewList = JavaTools.ArrayoutofString(sRecordFieldNames, ";");
+ getRecordParser().setRecordFieldNames(sNewList);
+ getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, ";");
+ getRecordParser().setCommandType(Integer.valueOf(sCommandType).intValue());
+ sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>");
+ bgetConnection = getRecordParser().getConnection(_properties);
+ int nCommandType = com.sun.star.sdb.CommandType.COMMAND;
+ boolean bexecute = false;
+ if (bgetConnection)
+ {
+
+ if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals("")))
+ {
+ DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName);
+ if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
+ {
+ getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue("Command");
+ getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command);
+ getRecordParser().getSQLQueryComposer().prependSortingCriteria();
+ }
+ 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);
+ }
+ 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 javaexception)
+ {
+ javaexception.printStackTrace(System.out);
+ return false;
+ }
+ catch (com.sun.star.wizards.document.FormHandler.UnknownHiddenControlException exception)
+ {
+ return false;
+ }
+ }
+ private boolean m_bStopProcess;
+
+ public void StopProcess()
+ {
+ m_bStopProcess = true;
+ }
+
+ public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF)
+ {
+ try
+ {
+ int ColIndex;
+ boolean breset;
+ Object oTable;
+ Vector DataVector = new Vector();
+ DBColumn CurDBColumn;
+ Object CurGroupValue;
+ String CurGroupTableName;
+// RecordParser CurDBMetaData = getRecordParser();
+ com.sun.star.style.BreakType CorrBreakValue = null;
+ String CorrPageDescName = "";
+ 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];
+ XTextTable[] xGroupBaseTables = new XTextTable[GroupFieldCount];
+ int RecordFieldCount = FieldCount - GroupFieldCount;
+ XTextDocument xTextDocument = getDoc().xTextDocument;
+ XTextCursor xTextCursor = ReportTextDocument.createTextCursor(getDoc().xTextDocument.getText());
+ xTextDocument.lockControllers();
+
+ if (getRecordParser().ResultSet.next() == true)
+ {
+ 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);
+ xGroupBaseTables[ColIndex] = UnoRuntime.queryInterface( XTextTable.class, oTable );
+ CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex);
+ OldGroupFieldValues[ColIndex] = CurGroupValue;
+ CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
+ addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); //COPYOF!!!!
+ }
+ if (getRecordParser().getcurrentRecordData(DataVector) == true)
+ {
+ // int RowIndex = 1;
+ m_bStopProcess = false;
+ while ((getRecordParser().ResultSet.next() == true) && (m_bStopProcess == false))
+ {
+ // RowIndex += 1;
+ breset = false;
+ for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++)
+ {
+ CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex);
+ if ((CurGroupValue.equals(OldGroupFieldValues[ColIndex]) == false) || (breset))
+ {
+ breset = true;
+ insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount);
+ CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
+ addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue);
+ OldGroupFieldValues[ColIndex] = CurGroupValue;
+ breset = !(ColIndex == GroupFieldCount - 1);
+ }
+ }
+ getRecordParser().getcurrentRecordData(DataVector);
+ // updateProgressDisplay(RowIndex);
+ }
+ insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount);
+ }
+ else
+ {
+ getDoc().unlockallControllers();
+ return;
+ }
+ }
+ else
+ {
+ for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++)
+ {
+ CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
+ Object oValue = "";
+ 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 exception)
+ {
+ }
+// catch (java.lang.Exception javaexception)
+// {
+// javaexception.printStackTrace(System.out);
+// }
+ getDoc().unlockallControllers();
+ getDoc().setLayoutSectionsVisible(false);
+ getDoc().removeCopiedTextSections();
+ getDoc().oTextSectionHandler.removeInvisibleTextSections();
+ getDoc().removeLayoutTextTables();
+ }
+
+ private void insertDataToRecordTable(XTextCursor xTextCursor, Vector 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.copyInto(RecordArray);
+ XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
+ if (DataLength > 1)
+ {
+ xTextTable.getRows().insertByIndex(xTextTable.getRows().getCount(), DataLength - 1);
+ }
+ OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1);
+ }
+ DataVector.removeAllElements();
+ }
+// public void updateProgressDisplay(int iCounter)
+// {
+// try
+// {
+// if (iCounter % 10 == 0)
+// {
+// sProgressCurRecord = JavaTools.replaceSubString(sProgressBaseCurRecord, String.valueOf(iCounter), "<COUNT>");
+// setControlProperty("lblCurProgress", "Label", sProgressCurRecord);
+// super.xReschedule.reschedule();
+// }
+// }
+// catch (java.lang.Exception jexception)
+// {
+// jexception.printStackTrace(System.out);
+// }
+// }
+ private void replaceUserFields()
+ {
+ DBColumn CurDBColumn;
+ XTextCursor xNameCellCursor;
+ String FieldContent;
+ int iCount = getDoc().DBColumnsVector.size();
+ for (int i = 0; i < iCount; i++)
+ {
+ CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(i);
+ xNameCellCursor = ReportTextDocument.createTextCursor(CurDBColumn.xNameCell);
+ xNameCellCursor.gotoStart(false);
+ FieldContent = getDoc().oTextFieldHandler.getUserFieldContent(xNameCellCursor);
+ if (!FieldContent.equals(""))
+ {
+ xNameCellCursor.goRight((short) 1, true);
+ xNameCellCursor.setString(FieldContent);
+ }
+ }
+ }
+
+ public XFrame getFrame()
+ {
+ return m_aDoc.xFrame;
+ }
+
+ public XMultiServiceFactory getDocumentServiceFactory()
+ {
+ return m_aDoc.xMSFDoc;
+ }
+
+ public void store(String _sName, int _nOpenMode) throws com.sun.star.uno.Exception
+ {
+ getDoc().createReportForm(ReportWizard.SOREPORTFORMNAME);
+ // int nOpenMode = getReportOpenMode();
+ 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, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)
+ {
+ return getDoc().addGroupNametoDocument(GroupNames, CurGroupTitle, GroupFieldVector, ReportPath, iSelCount);
+ }
+
+ public void refreshGroupFields(String[] _sNewNames)
+ {
+ getDoc().refreshGroupFields(_sNewNames);
+ }
+
+ // public boolean isGroupField(String _FieldName)
+ // {
+ // return getDoc().isGroupField(_FieldName);
+ // }
+ public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector 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.");
+ }
+ // CurReportDocument.getDoc().unlockallControllers();
+ }
+
+ 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 m_aReportPath = null;
+
+ public ArrayList getReportPath()
+ {
+ if (m_aReportPath == null)
+ {
+ // Check general availability of office paths
+ try
+ {
+ m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard");
+ // m_sReportPath = FileAccess.combinePaths(getMSF(), m_sReportPath, "/wizard/report");
+ FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report");
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ return m_aReportPath;
+ }
+
+ public String getContentPath()
+ {
+ ArrayList aReportPath = getReportPath();
+ for (int i = 0; i < aReportPath.size(); i++)
+ {
+ String sPath = (String) aReportPath.get(i);
+ sPath += "/cnt-default.ott";
+ if (FileAccess.isPathValid(getMSF(), sPath))
+ {
+ return sPath;
+ }
+ }
+ return "";
+ }
+
+ public String getLayoutPath()
+ {
+ ArrayList aReportPath = getReportPath();
+ for (int i = 0; i < aReportPath.size(); i++)
+ {
+ String sPath = (String) aReportPath.get(i);
+ sPath += "/stl-default.ott";
+ if (FileAccess.isPathValid(getMSF(), sPath))
+ {
+ return sPath;
+ }
+ }
+ return "";
+ }
+
+ public int getDefaultPageOrientation()
+ {
+ return m_nDefaultPageOrientation;
+ }
+
+ public String[][] getDataLayout()
+ {
+ String[][] ContentFiles;
+ try
+ {
+// ContentFiles = FileAccess.getFolderTitles(m_xMSF, "cnt", CurReportDocument.getReportPath());
+ ContentFiles = FileAccess.getFolderTitles(getMSF(), "cnt", getReportPath());
+ }
+ catch (com.sun.star.wizards.common.NoValidPathException e)
+ {
+ ContentFiles = new String[2][];
+ String[] a = new String[1];
+ String[] b = new String[1];
+ a[0] = "DefaultLayoutOfData";
+ b[0] = "default";
+ ContentFiles[1] = a;
+ ContentFiles[0] = b;
+ }
+ return ContentFiles;
+ }
+
+ public String[][] getHeaderLayout()
+ {
+ String[][] LayoutFiles;
+ try
+ {
+// LayoutFiles = FileAccess.getFolderTitles(m_xMSF, "stl", CurReportDocument.getReportPath());
+ LayoutFiles = FileAccess.getFolderTitles(getMSF(), "stl", getReportPath());
+ }
+ catch (com.sun.star.wizards.common.NoValidPathException e)
+ {
+ LayoutFiles = new String[2][];
+ String[] a = new String[1];
+ String[] b = new String[1];
+ a[0] = "DefaultLayoutOfHeaders";
+ b[0] = "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
+ {
+ }
+}
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 000000000000..2bffd2b4bea3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/ReportWizard.java
@@ -0,0 +1,761 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.report;
+
+// import java.util.Vector;
+
+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.deployment.XPackageInformationProvider;
+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.db.DBMetaData;
+import com.sun.star.wizards.db.DatabaseObjectWizard;
+import com.sun.star.wizards.db.SQLQueryComposer;
+import com.sun.star.wizards.ui.CommandFieldSelection;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.SortingComponent;
+import com.sun.star.wizards.ui.TitlesComponent;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.XCompletion;
+import java.lang.reflect.Method;
+import java.net.URI;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Map;
+
+public class ReportWizard extends DatabaseObjectWizard implements XTextListener, XCompletion
+{
+ protected FieldSelection CurGroupFieldSelection;
+ 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 = "";
+ 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("Report Wizard", "dbw");
+ if (getReportResources(false) == true)
+ {
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Height",
+ "Moveable",
+ "Name",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Title",
+ "Width"
+ },
+ new Object[]
+ {
+ Integer.valueOf(210),
+ Boolean.TRUE,
+ "DialogReport",
+ new Integer(102),
+ new Integer(41),
+ new Integer(1),
+ new Short((short) 0),
+ sMsgWizardName,
+ new Integer(310)
+ });
+ drawNaviBar();
+ setRightPaneHeaders(this.WizardHeaderText);
+ }
+ }
+
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ if ((nOldStep >= SOTEMPLATEPAGE) && (nNewStep < SOTEMPLATEPAGE))
+ {
+ // CurReportDocument.getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection");
+ // CurReportDocument.getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection");
+ m_reportDocument.removeTextTableAndTextSection();
+ }
+ switch (nNewStep)
+ {
+ case SOMAINPAGE:
+ CurDBCommandFieldSelection.setModified(false);
+ break;
+
+ case SOTITLEPAGE:
+ String[] aFieldNames = m_reportDocument.getRecordParser().getFieldNames();
+ Map 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, false);
+ break;
+
+ case SOTEMPLATEPAGE:
+ break;
+
+ case SOSTOREPAGE:
+ //TODO initialize with suitable PathName
+ CurReportFinalizer.initialize(m_reportDocument.getRecordParser());
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ 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 == true)
+ {
+ m_reportDocument.dispose();
+ return;
+ }
+
+ if ( ( nReportMode == ReportFinalizer.SOCREATETEMPLATE )
+ || ( nReportMode == ReportFinalizer.SOUSETEMPLATE )
+ )
+ {
+ m_reportDocument.addReportToDBView();
+ boolean bOpenInDesign = (nReportMode == ReportFinalizer.SOCREATETEMPLATE);
+ m_reportDocument.createAndOpenReportDocument( m_sReportName, true, bOpenInDesign);
+ }
+ else
+ {
+ m_reportDocument.importReportData(this);
+ m_reportDocument.createAndOpenReportDocument( m_sReportName, false, false );
+ }
+ }
+
+ private boolean executeQuery()
+ {
+ boolean bQueryCreated = false;
+ if (this.CurDBCommandFieldSelection.getSelectedCommandType() == CommandType.TABLE)
+ {
+ bQueryCreated = m_reportDocument.getRecordParser().getSQLQueryComposer().setQueryCommand(this.xWindow, false, false);
+
+ m_reportDocument.setCommandType(CommandType.COMMAND);
+ String sQuery = m_reportDocument.getRecordParser().getSQLQueryComposer().getQuery();
+ m_reportDocument.setCommand(sQuery);
+ }
+ else
+ {
+ try
+ {
+ String sQueryName = CurDBCommandFieldSelection.getSelectedCommandName();
+ DBMetaData.CommandObject oCommand = m_reportDocument.getRecordParser().getQueryByName(sQueryName);
+ bHasEscapeProcessing = m_reportDocument.getRecordParser().hasEscapeProcessing(oCommand.getPropertySet());
+ String sCommand = (String) oCommand.getPropertySet().getPropertyValue("Command");
+ if (bHasEscapeProcessing)
+ {
+ // String sCommand = (String) oCommand.xPropertySet.getPropertyValue("Command");
+ bQueryCreated = (!sCommand.equals(""));
+ m_reportDocument.getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(sCommand);
+ m_reportDocument.getRecordParser().getSQLQueryComposer().prependSortingCriteria();
+// TODO: check with query
+ m_reportDocument.setCommandType(CommandType.COMMAND);
+ m_reportDocument.setCommand(m_reportDocument.getRecordParser().getSQLQueryComposer().getQuery());
+ bQueryCreated = true;
+ }
+ else
+ {
+ m_reportDocument.setCommandType(CommandType.COMMAND);
+ m_reportDocument.setCommand(sCommand);
+ bQueryCreated = true;
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ if (!bQueryCreated)
+ {
+ super.vetoableChange(null);
+ }
+ return bQueryCreated;
+ }
+ public 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[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(16), sShowBinaryFields, new Integer(95), new Integer(162), new Integer(1), new Integer(210)
+ });
+ }
+ // CurReportDocument.getDoc().xProgressBar.setValue(40);
+ CurTitlesComponent = new TitlesComponent(this, SOTITLEPAGE, 97, 37, 210, 7, slblColumnNames, slblColumnTitles, 34381);
+ CurTitlesComponent.addTextListener(this);
+ // CurReportDocument.getDoc().xProgressBar.setValue(50);
+ CurGroupFieldHandler = new GroupFieldHandler(m_reportDocument, this);
+ // CurReportDocument.getDoc().xProgressBar.setValue(60);
+ CurSortingComponent = new SortingComponent(this, SOSORTPAGE, 95, 30, 210, 34346);
+ // CurReportDocument.getDoc().xProgressBar.setValue(70);
+ CurReportLayouter = new ReportLayouter(xMSF, m_reportDocument, this);
+ // CurReportDocument.getDoc().xProgressBar.setValue(80);
+ CurReportFinalizer = new ReportFinalizer(xMSF, m_reportDocument, this);
+ // CurReportDocument.getDoc().xProgressBar.setValue(100);
+ bCloseDocument = true;
+ // CurReportDocument.getDoc().xProgressBar.end();
+ enableNavigationButtons(false, false, false);
+ }
+
+ 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;
+ }
+
+ public void cancelWizard()
+ {
+ xDialog.endExecute();
+ }
+
+ public void insertQueryRelatedSteps()
+ {
+ setRMItemLabels(m_oResource, UIConsts.RID_QUERY + 80);
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_QUERY + 80), SOMAINPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 68), SOTITLEPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 11), SOGROUPPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 12), SOSORTPAGE); // Orderby is always supported
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_REPORT + 13), SOTEMPLATEPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.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("com.sun.star.report.pentaho.SOReportJobFactory");
+ if (e == null)
+ {
+ return false;
+ }
+ if (e.hasMoreElements())
+ {
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * Return the path to the "com.sun.reportdesigner" extension
+ * @param _xMSF
+ * @return
+ */
+ public static String getPathToExtension(XMultiServiceFactory _xMSF)
+ {
+ // Get the path to the extension and try to add the path to the class loader
+ final XComponentContext xComponentContext = Helper.getComponentContext(_xMSF);
+ final Object aSingleton = xComponentContext.getValueByName("/singletons/com.sun.star.deployment.PackageInformationProvider");
+ XPackageInformationProvider xProvider = UnoRuntime.queryInterface( XPackageInformationProvider.class, aSingleton );
+ final String sLocation = xProvider.getPackageLocation("com.sun.reportdesigner");
+ return sLocation;
+ }
+
+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() )
+ {
+ // Get the path to the extension and try to add the path to the class loader
+ String sLocation = getPathToExtension(xMSF);
+ // TODO: Umlaut in filename!
+ if ( sLocation.length() > 0 )
+ {
+ try
+ {
+ URI aLocationURI = URI.create(sLocation + "/" + "reportbuilderwizard.jar");
+
+ URL[] aURLs = new URL[1];
+ aURLs[0] = aLocationURI.toURL();
+ URLClassLoader aClassLoader = new URLClassLoader(aURLs, this.getClass().getClassLoader());
+ Class a = aClassLoader.loadClass("com.sun.star.wizards.reportbuilder.ReportBuilderImplementation");
+ Method aMethod = a.getMethod("create", new Class[] { XMultiServiceFactory.class });
+ m_reportDocument = (IReportDocument) aMethod.invoke(a, new Object[] { xMSF });
+ }
+ catch (Exception e)
+ {
+ // Maybe problems in URI create() if a wrong char is used like '[' ']', ...
+ System.out.println("There could be a problem with the path '" + sLocation + "'");
+ }
+ }
+ }
+
+ try
+ {
+ if (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();
+
+ 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(UIConsts.RID_REPORT + 92);
+ }
+ else
+ {
+ }
+ // show a dialog with the error message
+ SystemDialog.showMessageBox(xMSF, "ErrorBox", VclWindowPeerAttribute.OK, sMessage);
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ 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();
+ }
+
+ public boolean getReportResources(boolean bgetProgressResourcesOnly)
+ {
+ sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_REPORT);
+ if (bgetProgressResourcesOnly == false)
+ {
+ sShowBinaryFields = m_oResource.getResText(UIConsts.RID_REPORT + 60);
+ slblTables = m_oResource.getResText(UIConsts.RID_FORM + 6);
+ slblFields = m_oResource.getResText(UIConsts.RID_FORM + 12);
+ slblSelFields = m_oResource.getResText(UIConsts.RID_REPORT + 9);
+ WizardHeaderText[0] = m_oResource.getResText(UIConsts.RID_REPORT + 28);
+ WizardHeaderText[1] = m_oResource.getResText(UIConsts.RID_REPORT + 69);
+ WizardHeaderText[2] = m_oResource.getResText(UIConsts.RID_REPORT + 29);
+ WizardHeaderText[3] = m_oResource.getResText(UIConsts.RID_REPORT + 30);
+ WizardHeaderText[4] = m_oResource.getResText(UIConsts.RID_REPORT + 31);
+ WizardHeaderText[5] = m_oResource.getResText(UIConsts.RID_REPORT + 32);
+ }
+ slblColumnTitles = m_oResource.getResText(UIConsts.RID_REPORT + 70);
+ slblColumnNames = m_oResource.getResText(UIConsts.RID_REPORT + 71);
+ return true;
+ }
+
+ public static String getBlindTextNote(Object _aDocument, Resource _oResource)
+ {
+ String sBlindTextNote = "";
+ if (_aDocument instanceof ReportTextImplementation)
+ {
+ sBlindTextNote = _oResource.getResText(UIConsts.RID_REPORT + 75);
+ sBlindTextNote = JavaTools.replaceSubString(sBlindTextNote, String.valueOf((char) 13), "<BR>");
+ }
+ return sBlindTextNote;
+ }
+
+ public void enableRoadmapItems(boolean _bEnabled)
+ {
+ try
+ {
+ Object oRoadmapItem = null;
+ int CurStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, "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, "Enabled", new Boolean(bEnabled));
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ private void enableWizardSteps(String[] NewItems)
+ {
+ boolean bEnabled = NewItems.length > 0;
+ setControlProperty("btnWizardNext", "Enabled", new Boolean(bEnabled));
+ setControlProperty("btnWizardFinish", "Enabled", new Boolean(bEnabled));
+ enableRoadmapItems(bEnabled); // Note: Performancewise 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.out);
+ }
+ }
+
+ public void disposing(EventObject EventObject)
+ {
+ }
+
+ public void setmodified(int _ndialogpage, Object ooldValue, Object onewValue)
+ {
+ switch (_ndialogpage)
+ {
+ case SOMAINPAGE:
+ break;
+ default:
+ break;
+ }
+ }
+
+ 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);
+
+ // int nCommandType = this.CurDBCommandFieldSelection.getSelectedCommandType();
+ // super.setStepEnabled(SOSORTPAGE, (nCommandType == CommandType.TABLE));
+ }
+
+ public class FieldSelectionListener implements com.sun.star.wizards.ui.XFieldSelectionListener
+ {
+
+ protected int m_nID;
+
+ public int getID()
+ {
+ return m_nID;
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ m_nID = 1;
+ if (sIncSuffix != null)
+ {
+ if ((!sIncSuffix.equals("")) && (!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();
+ }
+ else
+ {
+ boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0);
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPPAGE), "Enabled", new Boolean(bEnabled));
+ }
+ }
+
+ 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);
+ }
+ else
+ {
+ boolean bEnabled = (CurGroupFieldSelection.getSelectedFieldNames().length > 0);
+ Helper.setUnoPropertyValue(getRoadmapItemByID(SOGROUPPAGE), "Enabled", new Boolean(bEnabled));
+ }
+ }
+
+ public void moveItemDown(String item)
+ {
+ }
+
+ public void moveItemUp(String item)
+ {
+ }
+ }
+// public void tests()
+// {
+//
+// Calendar aCalendar = new GregorianCalendar();
+// aCalendar.setTimeInMillis(1202382900000L);
+// String aCalStr = aCalendar.toString();
+//
+// Date aDate = new Date();
+// aDate.setSeconds(0);
+// aDate.setMinutes(15);
+// aDate.setHours(12);
+// // aDate.setMonth(2);
+// // aDate.setYear(2008);
+// // aDate.setDay(7);
+// long nTime = aDate.getTime();
+// Long aLong = new Long(nTime);
+// String aStr = aLong.toString();
+//
+// Date aNewDate = new Date(1202382900000L);
+//// aNewDate.
+// String aDateStr = aNewDate.toString();
+//// Datetime aNewTime = new Time(1202382900);
+//// String aTimeStr = aNewTime.toString();
+//
+// }
+}
diff --git a/wizards/com/sun/star/wizards/report/delzip b/wizards/com/sun/star/wizards/report/delzip
new file mode 100644
index 000000000000..e69de29bb2d1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/delzip
diff --git a/wizards/com/sun/star/wizards/report/makefile.mk b/wizards/com/sun/star/wizards/report/makefile.mk
new file mode 100644
index 000000000000..62b948674530
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/makefile.mk
@@ -0,0 +1,76 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = report
+PACKAGE = com$/sun$/star$/wizards$/report
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar
+
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/report
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ CallReportWizard.java \
+ DBColumn.java \
+ Dataimport.java \
+ GroupFieldHandler.java \
+ IReportDocument.java \
+ IReportBuilderLayouter.java \
+ IReportDefinitionReadAccess.java \
+ RecordTable.java \
+ ReportFinalizer.java \
+ ReportImplementationHelper.java \
+ ReportLayouter.java \
+ ReportTextDocument.java \
+ ReportTextImplementation.java \
+ ReportWizard.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/report.component
+
+$(MISC)/report.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ report.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt report.component
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 000000000000..67efca9273e7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/report/report.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<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>
diff --git a/wizards/com/sun/star/wizards/reportbuilder/Manifest.mf b/wizards/com/sun/star/wizards/reportbuilder/Manifest.mf
new file mode 100644
index 000000000000..53dbd3422d9c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/Manifest.mf
@@ -0,0 +1,2 @@
+Class-Path: report.jar commonwizards.jar
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java
new file mode 100644
index 000000000000..6a90214696a5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/ReportBuilderImplementation.java
@@ -0,0 +1,748 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.reportbuilder;
+
+import com.sun.star.util.XModeSelector;
+
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XHierarchicalNameContainer;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XDispatchProvider;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.report.XReportDefinition;
+import com.sun.star.sdb.XSubDocument;
+import com.sun.star.sdb.application.DatabaseObject;
+import com.sun.star.sdb.application.XDatabaseDocumentUI;
+import com.sun.star.sdbc.XConnection;
+import com.sun.star.ucb.XCommandProcessor;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XModifiable;
+import com.sun.star.util.XURLTransformer;
+import com.sun.star.wizards.common.NoValidPathException;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.db.FieldColumn;
+import java.lang.reflect.Constructor;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.LinkedHashMap;
+import java.util.Set;
+import java.util.Vector;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.NamedValueCollection;
+import com.sun.star.wizards.report.IReportBuilderLayouter;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.report.IReportDocument;
+import com.sun.star.wizards.report.ReportImplementationHelper;
+import com.sun.star.wizards.report.ReportLayouter;
+import com.sun.star.wizards.report.ReportWizard;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * This class use the IReportDocument Interface to communicate between the UI
+ * and the ReportBuilderLayouter which communicates to the new Sun Report Builder.
+ *
+ * @author ll93751
+ */
+public class ReportBuilderImplementation extends ReportImplementationHelper
+ implements IReportDocument, IReportDefinitionReadAccess
+{
+ private Resource m_resource;
+ private XDatabaseDocumentUI m_documentUI;
+
+ private static final int MAXIMUM_GROUPCOUNT = 4;
+
+ private ReportBuilderImplementation( XMultiServiceFactory _serviceFactory )
+ {
+ // creates an access to the ReportBuilder Extension
+ super(_serviceFactory, ReportLayouter.SOOPTLANDSCAPE);
+ }
+
+ public static IReportDocument create( XMultiServiceFactory i_serviceFactory )
+ {
+ return new ReportBuilderImplementation( i_serviceFactory );
+ }
+
+ public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource )
+ {
+ m_documentUI = i_documentUI;
+ m_resource = i_resource;
+ }
+
+ public void clearDocument()
+ {
+ }
+
+ public XWindowPeer getWizardParent()
+ {
+ final XWindowPeer aWindowPeer = UnoRuntime.queryInterface( XWindowPeer.class, getFrame().getComponentWindow() );
+ return aWindowPeer;
+ }
+ private XFrame m_xFrame = null;
+ // private ReportBuilderLayouter m_aReportBuilderLayouter = null;
+ private String m_sReportBuilderLayoutName = "";
+
+ /**
+ * Get access to the current ReportLayouter, which depends on the name.
+ * To change the ReportBuilderLayouter use <code>setReportBuilderLayouterName(String Name)</code>.
+ * @return
+ */
+ private IReportBuilderLayouter getReportBuilderLayouter()
+ {
+ final IReportBuilderLayouter aReportBuilderLayouter = (IReportBuilderLayouter) getLayoutMap().get(m_sReportBuilderLayoutName);
+ return aReportBuilderLayouter;
+ }
+ private Object m_aReportDocument;
+ private XPropertySet m_documentDefinition;
+ private XReportDefinition m_reportDocument;
+
+ /**
+ * initialize the Report Builder and open it representation
+ * @param _aDoc
+ * @param _xConnection
+ */
+ private void initialize(Object _aDoc)
+ {
+ m_aReportDocument = _aDoc;
+
+ try
+ {
+ NamedValueCollection creationArgs = new NamedValueCollection();
+ creationArgs.put( "DocumentServiceName", "com.sun.star.report.ReportDefinition" );
+ creationArgs.put( "Mode", "remote" );
+
+ XComponent[] docDefinition = new XComponent[] { null };
+ XComponent reportDefinitionComp = m_documentUI.createComponentWithArguments(
+ DatabaseObject.REPORT, creationArgs.getPropertyValues(), docDefinition );
+
+ m_documentDefinition = UnoRuntime.queryInterface( XPropertySet.class, docDefinition[0] );
+ m_reportDocument = UnoRuntime.queryInterface( XReportDefinition.class, reportDefinitionComp );
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ ReportWizard.getLogger().log(com.sun.star.logging.LogLevel.SEVERE, "Problems with initialize the ReportDefinition" + e.getMessage());
+
+ }
+
+ switchOffPropertyBrowser();
+ switchOffAddFieldWindow();
+
+ setPageOrientation(m_nDefaultPageOrientation, false /* NO_LAYOUT*/);
+ }
+
+ private XModeSelector getModeSelector()
+ {
+ final XController xController = getReportDefinition().getCurrentController();
+ final XModeSelector xModeSelector = UnoRuntime.queryInterface( XModeSelector.class, xController );
+ return xModeSelector;
+ }
+
+ private void switchOffAddFieldWindow()
+ {
+ try
+ {
+ getModeSelector().setMode("remote");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ int dummy = 0;
+ }
+ }
+
+ private void switchOnAddFieldWindow()
+ {
+ try
+ {
+ getModeSelector().setMode("normal");
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ int dummy = 0;
+ }
+ }
+
+ private void sleep(int _nSeconds)
+ {
+ try
+ {
+ Thread.sleep(_nSeconds * 1000);
+ }
+ catch (java.lang.InterruptedException e)
+ {
+ }
+
+ }
+
+ private void switchOffPropertyBrowser()
+ {
+ try
+ {
+ final XController xController = getReportDefinition().getCurrentController();
+ final XDispatchProvider xDP = UnoRuntime.queryInterface( XDispatchProvider.class, xController );
+
+ // Create special service for parsing of given URL.
+ final Object aURLTransformer = getMSF().createInstance("com.sun.star.util.URLTransformer");
+ final XURLTransformer xURLTransformer = UnoRuntime.queryInterface( com.sun.star.util.XURLTransformer.class, aURLTransformer );
+
+ com.sun.star.util.URL[] aURL = new com.sun.star.util.URL[1];
+ aURL[0] = new com.sun.star.util.URL();
+ aURL[0].Complete = ".uno:ControlProperties";
+ xURLTransformer.parseStrict(aURL);
+
+ final XDispatch xDispatch = xDP.queryDispatch(aURL[0], "_self", 0);
+ PropertyValue[] xEmpty = new PropertyValue[0];
+ xDispatch.dispatch(aURL[0], xEmpty);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ int dummy = 0;
+ }
+ }
+
+ private void switchOnPropertyBrowser()
+ {
+ // This is implemented with a toggle algorithm.
+ switchOffPropertyBrowser();
+ }
+
+ /**
+ * Returns the Frame of the underlieing Document
+ * @return Returns the Frame of the parent (underlieing) Document
+ */
+ public XFrame getFrame()
+ {
+ if (m_xFrame == null)
+ {
+ initialize(getRecordParser().getReportDocuments());
+ m_xFrame = getReportDefinition().getCurrentController().getFrame();
+ setPageOrientation(m_nDefaultPageOrientation, true /* NO_LAYOUT*/);
+ }
+ return m_xFrame;
+ }
+
+ public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] Properties)
+ {
+ return false;
+ }
+
+ public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF)
+ {
+ }
+
+ public void StopProcess()
+ {
+ }
+
+ public void store(String Name, int OpenMode) throws com.sun.star.uno.Exception
+ {
+ // store into the ZIP Storage
+ if (OpenMode == 1 /* static Report */)
+ {
+ // we will store later
+ return;
+ }
+
+ final XCommandProcessor xProcessor = UnoRuntime.queryInterface( XCommandProcessor.class, m_documentDefinition );
+ final com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command();
+ aCommand.Name = "store";
+
+ xProcessor.execute(aCommand, xProcessor.createCommandIdentifier(), null);
+
+ final XHierarchicalNameContainer aNameContainer = UnoRuntime.queryInterface(XHierarchicalNameContainer.class, m_aReportDocument);
+ aNameContainer.insertByHierarchicalName( Name, m_documentDefinition );
+ }
+
+ public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)
+ {
+ final int GroupCount = GroupFieldVector.size();
+ if (GroupCount < MAXIMUM_GROUPCOUNT)
+ {
+ final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle);
+ GroupFieldVector.addElement(CurFieldColumn.getFieldName());
+ }
+ return true;
+ }
+
+ public void refreshGroupFields(String[] _sNewNames)
+ {
+ }
+
+ public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector)
+ {
+ final FieldColumn CurFieldColumn = getRecordParser().getFieldColumnByTitle(CurGroupTitle);
+ GroupFieldVector.removeElement(CurFieldColumn.getFieldName());
+ }
+
+ private void setPageOrientation(int nOrientation, boolean bDoLayout)
+ {
+ getReportBuilderLayouter().setPageOrientation(nOrientation);
+ if (bDoLayout)
+ {
+ getReportBuilderLayouter().layout();
+ }
+ }
+
+ public void setPageOrientation(int nOrientation)
+ {
+ setPageOrientation(nOrientation, true);
+ }
+
+ public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/)
+ {
+ /* Right Listbox */
+ final IReportBuilderLayouter aLayouter = getReportBuilderLayouter();
+ aLayouter.loadAndSetBackgroundTemplate(LayoutTemplatePath);
+ aLayouter.layout();
+ }
+
+ /**
+ * Change the current Layouter by a new one with the given Name _sName.
+ * If there exist no other layouter with the given name, nothing happens, the layouter will not change to
+ * an illegal one.
+ * @param _sName Name of the other layouter.
+ */
+ public void setReportBuilderLayouterName(String _sName)
+ {
+ final IReportBuilderLayouter aCurrentLayouter = getReportBuilderLayouter();
+ final IReportBuilderLayouter aNewLayouter = (IReportBuilderLayouter) m_aLayoutMap.get(_sName);
+ if (aNewLayouter != null)
+ {
+ m_sReportBuilderLayoutName = _sName;
+ aNewLayouter.initializeData(aCurrentLayouter);
+ aNewLayouter.layout();
+ }
+ }
+
+ public void liveupdate_changeContentTemplate(String ContentTemplatePath)
+ {
+ /* Left Listbox */
+ setReportBuilderLayouterName(ContentTemplatePath);
+ }
+
+ public void layout_setupRecordSection(String TemplateName)
+ {
+ }
+
+ public void removeTextTableAndTextSection()
+ {
+ }
+
+ public void layout_selectFirstPage()
+ {
+ }
+
+ private void closeReportDefinition()
+ {
+ try
+ {
+ if ( m_documentDefinition != null )
+ {
+ // set the document to "not modified", to ensure that it won't ask the user before closing
+ XModifiable documentModify = UnoRuntime.queryInterface( XModifiable.class, m_reportDocument );
+ documentModify.setModified( false );
+ // actually close
+ XSubDocument subComponent = UnoRuntime.queryInterface( XSubDocument.class, m_documentDefinition );
+ subComponent.close();
+ }
+ }
+ catch ( Exception ex )
+ {
+ Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ m_documentDefinition = null;
+ m_reportDocument = null;
+ }
+
+ public void dispose()
+ {
+ getReportBuilderLayouter().dispose();
+ closeReportDefinition();
+ }
+
+ public XComponent getComponent()
+ {
+ return null;
+ }
+
+ public void liveupdate_changeUserFieldContent(String fieldName, String titlename)
+ {
+ }
+
+ public void liveupdate_updateReportTitle(String _sTitleName)
+ {
+ }
+
+ public void addReportToDBView()
+ {
+ }
+
+ private XComponent loadReport( final String i_reportName )
+ {
+ try
+ {
+ return m_documentUI.loadComponent( DatabaseObject.REPORT, i_reportName, false );
+ }
+ catch ( Exception ex )
+ {
+ Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ return null;
+ }
+
+ private XComponent loadReportFromDocumentDefinition()
+ {
+ final XCommandProcessor commandProcessor = UnoRuntime.queryInterface(XCommandProcessor.class, m_documentDefinition);
+
+ com.sun.star.ucb.Command aCommand = new com.sun.star.ucb.Command();
+ aCommand.Name = "open";
+ try
+ {
+ final Object result = commandProcessor.execute( aCommand, commandProcessor.createCommandIdentifier(), null );
+ return UnoRuntime.queryInterface( XComponent.class, result );
+ }
+ catch ( Exception ex )
+ {
+ Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ return null;
+ }
+
+ public void createAndOpenReportDocument( String i_name, boolean i_asTemplate, boolean i_openForEditing )
+ {
+ if ( i_openForEditing )
+ {
+ // we won't destroy the report builder window, also don't create a document
+ // Do we need to reopen the report builder with the known name?
+ switchOnAddFieldWindow();
+ switchOnPropertyBrowser();
+ return;
+ }
+
+ if ( i_asTemplate )
+ {
+ // don't need the report definition anymore - the document it represents has already been stored
+ closeReportDefinition();
+
+ // open the report, again, this time not in design, but containing data
+ loadReport( i_name );
+ }
+ else
+ {
+ // execute the report from the (yet unsaved) report definition
+ XComponent document = loadReportFromDocumentDefinition();
+
+ // don't need the report definition anymore
+ closeReportDefinition();
+
+ // store the generated report
+ if ( getRecordParser().storeDatabaseDocumentToTempPath( document, i_name ) )
+ getRecordParser().addReportDocument( document, false );
+ }
+
+ dispose();
+ }
+
+ private XConnection getConnection()
+ {
+ return getRecordParser().DBConnection;
+ }
+
+ public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames)
+ {
+ getRecordParser().initializeFieldColumns(FieldNames, TableName);
+
+ final com.sun.star.wizards.db.RecordParser a = getRecordParser();
+ int[] FieldTypes = new int[FieldNames.length];
+ int[] FieldWidths = new int[FieldNames.length];
+ for (int i = 0; i < FieldNames.length; i++)
+ {
+ FieldTypes[i] = a.FieldColumns[i].getFieldType();
+ FieldWidths[i] = a.FieldColumns[i].getFieldWidth();
+ }
+ getReportBuilderLayouter().setTableName(_nType, TableName);
+ getReportBuilderLayouter().insertFieldNames(FieldNames);
+ getReportBuilderLayouter().insertFieldTypes(FieldTypes);
+ getReportBuilderLayouter().insertFieldWidths(FieldWidths);
+
+ getReportBuilderLayouter().layout();
+ }
+
+ public void setFieldTitles(String[] _aFieldTitles)
+ {
+ getRecordParser().setFieldTitles(_aFieldTitles);
+
+ getReportBuilderLayouter().insertFieldTitles(_aFieldTitles);
+ getReportBuilderLayouter().layout();
+ }
+
+ public void setSorting(String[][] _aSortFieldNames)
+ {
+ getRecordParser().setSortFieldNames(_aSortFieldNames);
+ }
+
+ public void setGrouping(String[] _aGroupFieldNames)
+ {
+ getRecordParser().prependSortFieldNames(_aGroupFieldNames);
+
+ getReportBuilderLayouter().insertGroupNames(_aGroupFieldNames);
+ getReportBuilderLayouter().layout();
+ }
+
+ public String getLayoutPath()
+ {
+ return "default";
+ }
+ private ArrayList m_aReportPath;
+
+ public ArrayList getReportPath()
+ {
+ if (m_aReportPath == null)
+ {
+ try
+ {
+ // Check general availability of office paths
+ m_aReportPath = FileAccess.getOfficePaths( getMSF(), "Template", "share", "/wizard" );
+ FileAccess.combinePaths( getMSF(), m_aReportPath, "/wizard/report" );
+ }
+ catch ( NoValidPathException ex )
+ {
+ Logger.getLogger( ReportBuilderImplementation.class.getName() ).log( Level.SEVERE, null, ex );
+ }
+ }
+ return m_aReportPath;
+ }
+
+ public String getContentPath()
+ {
+ return "";
+ }
+
+ public int getDefaultPageOrientation()
+ {
+ return m_nDefaultPageOrientation;
+ }
+
+ /**
+ * Helper function to get a com.sun.star.wizards.report.layout.ReportBuilderLayouter by it's name
+ *
+ * @param _sClassName
+ * @return the object or null
+ */
+ private IReportBuilderLayouter getLayoutInstanceFrom(String _sClassName)
+ {
+ try
+ {
+ // TODO: Use Package.getPackages(...)
+ final Class a = Class.forName(_sClassName);
+
+ final Constructor cTor = a.getConstructor(new Class[]
+ {
+ IReportDefinitionReadAccess.class, Resource.class
+ });
+ Object[] aParams = new Object[2];
+ aParams[0] = this;
+ aParams[1] = m_resource;
+ final IReportBuilderLayouter aReportBuilderLayouter = (IReportBuilderLayouter) cTor.newInstance(aParams);
+ return aReportBuilderLayouter;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ return null;
+ }
+ private LinkedHashMap m_aLayoutMap = null;
+
+ private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout)
+ {
+ insertIntoLayoutMap(_aLayout, false);
+ }
+
+ private void insertIntoLayoutMap(IReportBuilderLayouter _aLayout, boolean _bDefault)
+ {
+ if (_aLayout != null)
+ {
+ final String sName = _aLayout.getName();
+ if (_bDefault)
+ {
+ m_sReportBuilderLayoutName = sName; // here we set the default layout name!
+ }
+ m_aLayoutMap.put(sName, _aLayout);
+ }
+ }
+
+ /**
+ * Initialize all well known com.sun.star.wizards.report.layout.ReportBuilderLayouter Objects and create exact one instance.
+ */
+ private LinkedHashMap getLayoutMap()
+ {
+ if (m_aLayoutMap == null)
+ {
+ // The LayoutMap is empty, so we create a new LinkedHashMap
+ m_aLayoutMap = new LinkedHashMap();
+
+ // TODO: We must know the name of a layouts, There should be a way to say where to find, not the names.
+ IReportBuilderLayouter aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.Tabular");
+ insertIntoLayoutMap(aLayout, true);
+ aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarSingleColumn");
+ insertIntoLayoutMap(aLayout);
+ aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarTwoColumns");
+ insertIntoLayoutMap(aLayout);
+ aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.ColumnarThreeColumns");
+ insertIntoLayoutMap(aLayout);
+ aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsAbove");
+ insertIntoLayoutMap(aLayout);
+ aLayout = getLayoutInstanceFrom("com.sun.star.wizards.reportbuilder.layout.InBlocksLabelsLeft");
+ insertIntoLayoutMap(aLayout);
+
+ }
+ return m_aLayoutMap;
+ }
+
+ /**
+ * Return a string array array with all found layouts
+ * At the moment these layout are hard coded
+ * @return
+ */
+ public String[][] getDataLayout()
+ {
+ String[][] ContentFiles;
+ ContentFiles = new String[2][];
+ String[] a = new String[getLayoutMap().size()];
+ String[] b = new String[getLayoutMap().size()];
+
+ // run through the whole layoutmap and
+ final Set aKeys = getLayoutMap().keySet();
+ final Iterator aKeyIterator = aKeys.iterator();
+ int i = 0;
+ while (aKeyIterator.hasNext())
+ {
+ final String sKey = (String) aKeyIterator.next();
+ a[i] = sKey;
+ final IReportBuilderLayouter aLayouter = (IReportBuilderLayouter) m_aLayoutMap.get(sKey);
+ b[i++] = aLayouter.getLocalizedName();
+ }
+
+ ContentFiles[1] = a;
+ ContentFiles[0] = b;
+ return ContentFiles;
+ }
+ private String m_sDefaultHeaderLayoutPath;
+
+ public String[][] getHeaderLayout()
+ {
+ String[][] LayoutFiles;
+ try
+ {
+ // TODO: check different languages in header layouts
+ ArrayList aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard");
+ FileAccess.combinePaths(getMSF(), aReportPath, "/wizard/report");
+
+ LayoutFiles = FileAccess.getFolderTitles(getMSF(), null, aReportPath, ".otr");
+ }
+ catch (com.sun.star.wizards.common.NoValidPathException e)
+ {
+ // if there are problems, don't show anything is a little bit hard.
+ LayoutFiles = new String[2][];
+ String[] a = new String[1];
+ String[] b = new String[1];
+ a[0] = "DefaultLayoutOfHeaders";
+ b[0] = "default";
+ LayoutFiles[1] = a;
+ LayoutFiles[0] = b;
+ }
+ for (int i = 0; i < LayoutFiles[0].length; i++)
+ {
+ if (LayoutFiles[0][i].equals("default"))
+ {
+ m_sDefaultHeaderLayoutPath = LayoutFiles[1][i];
+ break;
+ }
+ }
+ return LayoutFiles;
+ }
+
+ public XReportDefinition getReportDefinition()
+ {
+ if (m_reportDocument == null)
+ {
+ throw new NullPointerException("Report Definition is not already initialized, check if you too early access the report definition.");
+ }
+ return m_reportDocument;
+ }
+
+ public XMultiServiceFactory getGlobalMSF()
+ {
+ return getMSF();
+ }
+
+ public void importReportData(ReportWizard aWizard)
+ {
+ }
+
+ public String getDefaultHeaderLayout()
+ {
+ return m_sDefaultHeaderLayoutPath;
+ }
+
+ public void setCommand(String _sCommand)
+ {
+ getRecordParser().Command = _sCommand;
+ getReportDefinition().setCommand(_sCommand);
+ }
+
+ public void setCommandType(int _nCommand)
+ {
+ getReportDefinition().setCommandType(_nCommand);
+ }
+
+
+ public void checkInvariants() throws java.lang.Exception
+ {
+ final String sDefaultHeaderLayoutPath = getDefaultHeaderLayout();
+ if (sDefaultHeaderLayoutPath == null)
+ {
+ throw new java.io.IOException("default.otr");
+ }
+
+ FileAccess aAccess = new FileAccess(getGlobalMSF());
+ if (! aAccess.exists(sDefaultHeaderLayoutPath, true))
+ {
+ throw new java.io.IOException("default.otr");
+ }
+ }
+
+}
+
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java
new file mode 100644
index 000000000000..ccb74ebf6f07
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarSingleColumn.java
@@ -0,0 +1,105 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.report.XSection;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.UIConsts;
+
+/**
+ *
+ * @author ll93751
+ */
+public class ColumnarSingleColumn extends ReportBuilderLayouter
+{
+
+ public ColumnarSingleColumn(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "ColumnarSingleColumnLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ final String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 81);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ copyDetailProperties();
+
+ final String[] aFieldTitleNames = getFieldTitleNames();
+ if (aFieldTitleNames == null)
+ {
+ return;
+ }
+ final String[] aFieldNames = getFieldNames();
+ if (aFieldNames == null)
+ {
+ return;
+ }
+// int nGroups = getReportDefinition().getGroups().getCount();
+
+ final XSection xSection = getReportDefinition().getDetail();
+
+ Rectangle aRect = new Rectangle();
+
+ final int nLabelWidth = getMaxLabelWidth();
+ final SectionObject aSOLabel = getDesignTemplate().getDetailLabel();
+ aSOLabel.setFontToBold();
+ final SectionObject aSOTextField = getDesignTemplate().getDetailTextField();
+
+ final int nWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups()) - nLabelWidth;
+
+ for (int i = 0; i < aFieldNames.length; i++)
+ {
+ aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+ final String sLabel = aFieldTitleNames[i];
+ aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel);
+ final String sFieldName = convertToFieldName(aFieldNames[i]);
+ aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField);
+ int nHeight = aRect.Height;
+ aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), nHeight);
+ }
+ aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line
+ xSection.setHeight(aRect.Y);
+ doNotBreakInTable(xSection);
+ }
+
+ protected void insertDetailFieldTitles()
+ {
+ // we won't extra field titles
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java
new file mode 100644
index 000000000000..2dc468fb09e7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarThreeColumns.java
@@ -0,0 +1,62 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.*;
+
+/**
+ *
+ * @author ll93751
+ */
+public class ColumnarThreeColumns extends ColumnarTwoColumns
+{
+
+ public ColumnarThreeColumns(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "ColumnarThreeColumnsLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ final String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 83);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ insertDetailFields(3);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java
new file mode 100644
index 000000000000..d79713524021
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ColumnarTwoColumns.java
@@ -0,0 +1,137 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.report.XSection;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.UIConsts;
+
+/**
+ *
+ * @author ll93751
+ */
+public class ColumnarTwoColumns extends ReportBuilderLayouter
+{
+
+ public ColumnarTwoColumns(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "ColumnarTwoColumnsLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ final String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 82);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ insertDetailFields(2);
+ }
+
+ protected void insertDetailFields(int _nColumns)
+ {
+ copyDetailProperties();
+
+ if (_nColumns < 1)
+ {
+ return;
+ }
+ final String[] aFieldTitleNames = getFieldTitleNames();
+ if (aFieldTitleNames == null)
+ {
+ return;
+ }
+ final String[] aFieldNames = getFieldNames();
+ if (aFieldNames == null)
+ {
+ return;
+ }
+// int nGroups = getReportDefinition().getGroups().getCount();
+
+ final XSection xSection = getReportDefinition().getDetail();
+
+ Rectangle aRect = new Rectangle();
+
+ final int nLabelWidth = getMaxLabelWidth(); // 3000;
+
+ final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups());
+ int i = 0;
+ int nRows = aFieldNames.length / _nColumns;
+ if ((aFieldNames.length % _nColumns) != 0)
+ {
+ ++nRows;
+ }
+ final int nWidth = (nUsablePageWidth - nLabelWidth * _nColumns) / _nColumns;
+ if (nWidth < 0)
+ {
+ // TODO: error message in logging
+ return;
+ }
+
+ final SectionObject aSOLabel = getDesignTemplate().getDetailLabel();
+ aSOLabel.setFontToBold();
+ final SectionObject aSOTextField = getDesignTemplate().getDetailTextField();
+ int nMaxHeight = 0;
+ for (int x = 0; x < _nColumns; x++)
+ {
+ aRect.Y = 0;
+ for (int y = 0; y < nRows; y++)
+ {
+ aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups()) + x * (nWidth + nLabelWidth);
+ if (i < aFieldNames.length)
+ {
+ final String sLabel = aFieldTitleNames[i];
+ aRect = insertLabel(xSection, sLabel, aRect, nLabelWidth, aSOLabel);
+ final String sFieldName = convertToFieldName(aFieldNames[i]);
+ aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSOTextField);
+
+ aRect.Y += Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight), aRect.Height);
+ ++i;
+ }
+ }
+ nMaxHeight = Math.max(aRect.Y, nMaxHeight);
+ }
+ aRect.Y = Math.max(aSOLabel.getHeight(LayoutConstants.LabelHeight) * nRows, nMaxHeight);
+ aRect.Y += aSOLabel.getHeight(LayoutConstants.EmptyLineHeight); // one empty line
+ xSection.setHeight(aRect.Y);
+ doNotBreakInTable(xSection);
+ }
+
+ protected void insertDetailFieldTitles()
+ {
+ // we won't extra field titles
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java b/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java
new file mode 100644
index 000000000000..55fdafe6c79a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/DesignTemplate.java
@@ -0,0 +1,333 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.beans.PropertyValue;
+// import com.sun.star.container.NoSuchElementException;
+// import com.sun.star.lang.IndexOutOfBoundsException;
+// import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.report.XFixedText;
+import com.sun.star.report.XFormattedField;
+import com.sun.star.report.XGroup;
+import com.sun.star.report.XGroups;
+import com.sun.star.report.XReportDefinition;
+import com.sun.star.report.XSection;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Properties;
+
+/**
+ *
+ * @author ll93751
+ */
+public class DesignTemplate
+{
+
+ private XReportDefinition m_xReportDefinition;
+ XMultiServiceFactory m_xGlobalMSF;
+ String m_sFilename;
+
+ private DesignTemplate()
+ {
+ }
+ // -------------------------------------------------------------------------
+ // All functions from XReportDefinition, we use
+ // -------------------------------------------------------------------------
+ XGroups getGroups()
+ {
+ return m_xReportDefinition.getGroups();
+ }
+
+ XSection getDetail()
+ {
+ return m_xReportDefinition.getDetail();
+ }
+
+ boolean getReportHeaderOn()
+ {
+ return m_xReportDefinition.getReportHeaderOn();
+ }
+
+ XSection getReportHeader() throws com.sun.star.container.NoSuchElementException
+ {
+ return m_xReportDefinition.getReportHeader();
+ }
+
+ boolean getReportFooterOn()
+ {
+ return m_xReportDefinition.getReportFooterOn();
+ }
+
+ XSection getReportFooter() throws com.sun.star.container.NoSuchElementException
+ {
+ return m_xReportDefinition.getReportFooter();
+ }
+
+ boolean getPageHeaderOn()
+ {
+ return m_xReportDefinition.getPageHeaderOn();
+ }
+
+ XSection getPageHeader() throws com.sun.star.container.NoSuchElementException
+ {
+ return m_xReportDefinition.getPageHeader();
+ }
+
+ boolean getPageFooterOn()
+ {
+ return m_xReportDefinition.getPageFooterOn();
+ }
+
+ XSection getPageFooter() throws com.sun.star.container.NoSuchElementException
+ {
+ return m_xReportDefinition.getPageFooter();
+ } // -------------------------------------------------------------------------
+ private SectionObject m_aDetailLabel;
+ private SectionObject m_aDetailTextField;
+ private SectionObject[] m_aGroupLabel;
+ private SectionObject[] m_aGroupTextField;
+
+ SectionObject getDetailLabel()
+ {
+ if (m_aDetailLabel == null)
+ {
+ return SectionEmptyObject.create();
+ }
+ return m_aDetailLabel;
+ }
+
+ SectionObject getDetailTextField()
+ {
+ if (m_aDetailTextField == null)
+ {
+ return SectionEmptyObject.create();
+ }
+ return m_aDetailTextField;
+ }
+
+ SectionObject getGroupTextField(int _nGroup)
+ {
+ return getGroupSectionObject(m_aGroupTextField, _nGroup);
+ }
+
+ SectionObject getGroupLabel(int _nGroup)
+ {
+ return getGroupSectionObject(m_aGroupLabel, _nGroup);
+ }
+
+ private SectionObject getGroupSectionObject(SectionObject _aGroupList[], int _nGroup)
+ {
+ SectionObject a = null;
+ if (_nGroup < _aGroupList.length)
+ {
+ a = _aGroupList[_nGroup];
+ }
+ else
+ {
+ // if there are not enough groups, the last one will win
+ if (_aGroupList.length > 0)
+ {
+ a = _aGroupList[_aGroupList.length - 1];
+ }
+ }
+ // we show if the group is null
+ if (a == null)
+ {
+ a = SectionEmptyObject.create();
+ // a empty group has to use bold font
+ a.setPropertyValue("CharWeight", new Float(com.sun.star.awt.FontWeight.BOLD));
+ }
+ return a;
+ }
+
+ // we analyse the loaded ReportDefinition, we want to know the FontDescriptor of all XSections
+ private void analyseReportDefinition()
+ {
+ final XSection xDetailSection = m_xReportDefinition.getDetail();
+ final int nDetailCount = xDetailSection.getCount();
+ for (int i = 0; i < nDetailCount; i++)
+ {
+ try
+ {
+ Object aObj = xDetailSection.getByIndex(i);
+ // is aObj a label
+ // is aObj a textfield
+ // m_aDetailLabel_FD
+ // m_aDetailTextField_FD
+ XFixedText aFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, aObj);
+ if (aFixedText != null &&
+ m_aDetailLabel == null)
+ {
+ m_aDetailLabel = SectionLabel.create(aFixedText);
+ }
+ else
+ {
+ XFormattedField aFormattedField = (XFormattedField) UnoRuntime.queryInterface(XFormattedField.class, aObj);
+ if (aFormattedField != null &&
+ m_aDetailTextField == null)
+ {
+ m_aDetailTextField = SectionTextField.create(aFormattedField);
+ }
+ }
+ int dummy = 0;
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException ex)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException ex)
+ {
+ }
+ }
+
+ final XGroups xGroups = m_xReportDefinition.getGroups();
+ final int nGroupCount = xGroups.getCount();
+ // create a m_aGroupLabel_FD[]
+ // create a m_aGroupTextField_FD[]
+ m_aGroupLabel = new SectionObject[nGroupCount];
+ m_aGroupTextField = new SectionObject[nGroupCount];
+
+ for (int nGroup = 0; nGroup < nGroupCount; nGroup++)
+ {
+ try
+ {
+ Object aGroup = xGroups.getByIndex(nGroup);
+ XGroup xGroup = (XGroup) UnoRuntime.queryInterface(XGroup.class, aGroup);
+ XSection xGroupSection = xGroup.getHeader();
+
+ final int nCount = xGroupSection.getCount();
+ for (int i = 0; i < nCount; i++)
+ {
+ try
+ {
+ Object aObj = xGroupSection.getByIndex(i);
+ XFixedText aFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, aObj);
+ // is aObj a label
+ // is aObj a textfield
+ if (aFixedText != null &&
+ m_aGroupLabel[nGroup] == null)
+ {
+ m_aGroupLabel[nGroup] = SectionLabel.create(aFixedText);
+ }
+ else
+ {
+ XFormattedField aFormattedField = (XFormattedField) UnoRuntime.queryInterface(XFormattedField.class, aObj);
+ if (aFormattedField != null &&
+ m_aGroupTextField[nGroup] == null)
+ {
+ m_aGroupTextField[nGroup] = SectionTextField.create(aFormattedField);
+ }
+ }
+ int dummy = 0;
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException ex)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException ex)
+ {
+ }
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException ex)
+ {
+ }
+ catch (com.sun.star.lang.IndexOutOfBoundsException ex)
+ {
+ }
+ catch (com.sun.star.lang.WrappedTargetException ex)
+ {
+ }
+ }
+ }
+
+ /**
+ * close our current ReportDefinition
+ */
+ void close()
+ {
+ try
+ {
+ m_xReportDefinition.close(true);
+ }
+ catch (com.sun.star.util.CloseVetoException e)
+ {
+ }
+ }
+
+ /**
+ * create a new DesignTemplate by try to load a otr file from the given path.
+ * Internally we store the loaded ReportDefinition.
+ *
+ * @param _xMSF
+ * @param _sPath
+ * @return
+ */
+ public static DesignTemplate create(XMultiServiceFactory _xMSF, String _sPath)
+ {
+ DesignTemplate a = new DesignTemplate();
+ try
+ {
+ a.load(_xMSF, _sPath);
+ }
+ catch (com.sun.star.lang.WrappedTargetRuntimeException e)
+ {
+ // this should not happen
+ a = null;
+ throw new java.lang.RuntimeException(e.getMessage());
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ a = null;
+ }
+ catch (Exception e)
+ {
+ a = null;
+ }
+ return a;
+ }
+
+ private void load(XMultiServiceFactory _xMSF, String _sPath) throws com.sun.star.uno.Exception
+ {
+ m_xGlobalMSF = _xMSF;
+ m_sFilename = _sPath;
+ final Object aObj = _xMSF.createInstance("com.sun.star.report.ReportDefinition");
+ m_xReportDefinition = (XReportDefinition) UnoRuntime.queryInterface(XReportDefinition.class, aObj);
+
+ PropertyValue[] aLoadProps = new PropertyValue[2];
+ aLoadProps[0] = Properties.createProperty("URL", _sPath);
+ aLoadProps[1] = Properties.createProperty("ReadOnly", Boolean.TRUE);
+
+ m_xReportDefinition.load(aLoadProps);
+ analyseReportDefinition();
+ }
+
+ public XReportDefinition getReportDefinition()
+ {
+ return m_xReportDefinition;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java
new file mode 100644
index 000000000000..9fd891a446f2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsAbove.java
@@ -0,0 +1,166 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.report.XSection;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.*;
+
+/**
+ *
+ * @author ll93751
+ */
+public class InBlocksLabelsAbove extends ColumnarTwoColumns
+{
+
+ public InBlocksLabelsAbove(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "InBlocksLabelsAboveLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ final String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 85);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ copyDetailProperties();
+
+ final String[] aFieldTitleNames = getFieldTitleNames();
+ if (aFieldTitleNames == null)
+ {
+ return;
+ }
+ final String[] aFieldNames = getFieldNames();
+ if (aFieldNames == null)
+ {
+ return;
+ }
+// int nGroups = getReportDefinition().getGroups().getCount();
+
+ final XSection xSection = getReportDefinition().getDetail();
+
+ Rectangle aRectLabels = new Rectangle();
+ Rectangle aRectFields = new Rectangle();
+
+
+ final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups());
+
+ int i = 0;
+ int nCount = aFieldTitleNames.length;
+ // int x = 0;
+ aRectLabels.Y = 0;
+ aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ aRectFields.Y = LayoutConstants.LabelHeight;
+ aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ // first run only calculates the width.
+ int nDelta = 0;
+ int nFieldWidth = 3000;
+ while (nCount > 0)
+ {
+ // String sLabel = aFieldTitleNames[i];
+ // int nLabelWidth = 3000;
+ // String sFieldName = convertToFieldName(aFieldNames[i]);
+ aRectFields.X += nFieldWidth;
+ // aRectLabels.X += nFieldWidth;
+
+ final int nNextX = aRectFields.X + nFieldWidth;
+ if (nNextX > (getPageWidth() - getRightPageIndent()))
+ {
+ // all other values are not from interest.
+ break;
+ }
+
+ ++i;
+ --nCount;
+ }
+ final int nDeltaTotal = nUsablePageWidth - i * nFieldWidth;
+ nDelta = nDeltaTotal;
+ if (i > 0)
+ {
+ nDelta = nDeltaTotal / i;
+ }
+
+ aRectLabels.Y = 0;
+ aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ final SectionObject aSOLabel = getDesignTemplate().getDetailLabel();
+ aSOLabel.setFontToBold();
+ final SectionObject aSOTextField = getDesignTemplate().getDetailTextField();
+
+ aRectFields.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight);
+ aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+ i = 0;
+ nCount = aFieldTitleNames.length;
+ int nLastHeight = 0;
+ while (nCount > 0)
+ {
+ final String sLabel = aFieldTitleNames[i];
+ final int nLabelWidth = 3000 + nDelta;
+ aRectLabels = insertLabel(xSection, sLabel, aRectLabels, nLabelWidth, aSOLabel);
+ final String sFieldName = convertToFieldName(aFieldNames[i]);
+ nFieldWidth = 3000 + nDelta;
+ aRectFields = insertFormattedField(xSection, sFieldName, aRectFields, nFieldWidth, aSOTextField);
+ nLastHeight = Math.max(nLastHeight, aRectFields.Height);
+ int nNextX = aRectFields.X + nFieldWidth;
+ if (nNextX > (getPageWidth() - getRightPageIndent()) & nCount > 1)
+ {
+ int nHeight = (aSOLabel.getHeight(LayoutConstants.LabelHeight) + Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight));
+ nLastHeight = 0;
+ aRectLabels.Y += nHeight; // 2 * label height
+ aRectLabels.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ aRectFields.Y += nHeight;
+ aRectFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+ }
+ ++i;
+ --nCount;
+ }
+ aRectFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight);
+ aRectFields.Y += aSOTextField.getHeight(LayoutConstants.EmptyLineHeight); // one empty line
+ xSection.setHeight(aRectFields.Y);
+ doNotBreakInTable(xSection);
+ }
+
+ protected void insertDetailFieldTitles()
+ {
+ // we won't extra field titles
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java
new file mode 100644
index 000000000000..c03cf7cec909
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/InBlocksLabelsLeft.java
@@ -0,0 +1,133 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.report.XSection;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.*;
+
+/**
+ *
+ * @author ll93751
+ */
+public class InBlocksLabelsLeft extends ColumnarTwoColumns
+{
+
+ public InBlocksLabelsLeft(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "InBlocksLabelsLeftLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ final String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 84);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ copyDetailProperties();
+
+ final String[] aFieldTitleNames = getFieldTitleNames();
+ if (aFieldTitleNames == null)
+ {
+ return;
+ }
+ final String[] aFieldNames = getFieldNames();
+ if (aFieldNames == null)
+ {
+ return;
+ }
+// int nGroups = getReportDefinition().getGroups().getCount();
+
+ final XSection xSection = getReportDefinition().getDetail();
+
+ Rectangle aRectLabelFields = new Rectangle();
+
+ final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups());
+
+ final int nLabelWidth = getMaxLabelWidth(); // 3000;
+ int nFieldWidth = 3000;
+
+ final int nFactor = nUsablePageWidth / (nLabelWidth + nFieldWidth);
+ int nDeltaTotal = 0;
+ int nDelta = 0;
+ if (nFactor > 0)
+ {
+ nDeltaTotal = nUsablePageWidth - (nFactor * (nLabelWidth + nFieldWidth));
+ nDelta = nDeltaTotal / nFactor;
+ }
+
+ int i = 0;
+ int nCount = aFieldTitleNames.length;
+ // int x = 0;
+ aRectLabelFields.Y = 0;
+ aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ SectionObject aSOLabel = getDesignTemplate().getDetailLabel();
+ aSOLabel.setFontToBold();
+ SectionObject aSOTextField = getDesignTemplate().getDetailTextField();
+ int nLastHeight = 0;
+ while (nCount > 0)
+ {
+ final String sLabel = aFieldTitleNames[i];
+// nLabelWidth = 3000;
+ aRectLabelFields = insertLabel(xSection, sLabel, aRectLabelFields, nLabelWidth, aSOLabel);
+ final String sFieldName = convertToFieldName(aFieldNames[i]);
+ nFieldWidth = 3000 + nDelta;
+ aRectLabelFields = insertFormattedField(xSection, sFieldName, aRectLabelFields, nFieldWidth, aSOTextField);
+ nLastHeight = Math.max(aRectLabelFields.Height, nLastHeight);
+ final int nNextX = aRectLabelFields.X + nLabelWidth + nFieldWidth;
+ if (nNextX > (getPageWidth() - getRightPageIndent()))
+ {
+ // TODO: label height is fix
+ aRectLabelFields.Y += Math.max(aSOTextField.getHeight(LayoutConstants.FormattedFieldHeight), nLastHeight);
+ nLastHeight = 0;
+ aRectLabelFields.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+ }
+ ++i;
+ --nCount;
+ }
+ aRectLabelFields.Y += Math.max(aSOLabel.getHeight(LayoutConstants.EmptyLineHeight), nLastHeight); // one empty line
+ xSection.setHeight(aRectLabelFields.Y);
+ doNotBreakInTable(xSection);
+ }
+
+ protected void insertDetailFieldTitles()
+ {
+ // we won't extra field titles
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java
new file mode 100644
index 000000000000..c31ce4b5f277
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/LayoutConstants.java
@@ -0,0 +1,52 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+
+package com.sun.star.wizards.reportbuilder.layout;
+
+/**
+ *
+ * @author ll93751
+ */
+public class LayoutConstants
+{
+ public static final int LabelHeight = 500;
+ public static final int FormattedFieldHeight = 500;
+ public static final int EmptyLineHeight = 500;
+
+ public static final int BinaryHeight = 4000;
+ public static final int MemoFieldHeight = 4000;
+
+ public static final int LineHeight = 250;
+
+ /**
+ * Groups will indent
+ * This is the factor (5mm) which will multiply with the current indent
+ */
+ public static final int IndentFactorWidth = 500;
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java
new file mode 100644
index 000000000000..a10affa9ea2c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/ReportBuilderLayouter.java
@@ -0,0 +1,1693 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.Rectangle;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XLayoutConstrains;
+import com.sun.star.awt.XUnitConversion;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.beans.XPropertySetInfo;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.report.XFixedLine;
+import com.sun.star.report.XFixedText;
+import com.sun.star.report.XFormattedField;
+import com.sun.star.report.XGroup;
+import com.sun.star.report.XGroups;
+import com.sun.star.report.XImageControl;
+import com.sun.star.report.XReportComponent;
+import com.sun.star.report.XReportControlModel;
+import com.sun.star.report.XReportDefinition;
+import com.sun.star.report.XSection;
+import com.sun.star.drawing.XShape;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.style.XStyle;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XNumberFormatTypes;
+import com.sun.star.util.XNumberFormats;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.PropertySetHelper;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportBuilderLayouter;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.UIConsts;
+import java.util.HashMap;
+import java.util.Locale;
+
+/**
+ * This class is abstract and more like a helper for create different layouts for Report Builder Wizard.
+ * @author ll93751
+ */// TODO: let a little bit place between 2 formatted fields
+// TODO: move all sectionobjects which have a connect to the right max page width to left if there is a orientation change.
+abstract public class ReportBuilderLayouter implements IReportBuilderLayouter
+{
+
+ private IReportDefinitionReadAccess m_xReportDefinitionReadAccess;
+ private Resource m_aResource;
+
+ /**
+ * dispose the ReportBuilderLayouter
+ */
+ public void dispose()
+ {
+ closeDesignTemplate();
+ m_xReportDefinitionReadAccess = null;
+ // m_xReportBuilderLayouter = null;
+ }
+
+ /**
+ * The Constructor is protected, this is a abstract class, use Tabular or other to create an instance.
+ * @param _xDefinitionAccess
+ * @param _aResource
+ */
+ protected ReportBuilderLayouter(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ m_xReportDefinitionReadAccess = _xDefinitionAccess;
+ m_aResource = _aResource;
+ }
+
+ /**
+ * Access to the current ReportDefinition
+ * @return the ReportDefinition
+ */
+ public XReportDefinition getReportDefinition()
+ {
+ // we have to ask our parent for this value
+ return m_xReportDefinitionReadAccess.getReportDefinition();
+ }
+
+ /**
+ * Access to the global MultiServiceFactory
+ * @return the global Service Factory
+ */
+ private XMultiServiceFactory getGlobalMSF()
+ {
+ return m_xReportDefinitionReadAccess.getGlobalMSF();
+ }
+
+ /**
+ * Layout the complete report new, by all information we know until this time.
+ *
+ * If there are some information less, it is no problem for this function, they will be leaved out.
+ * It is possible to call this function after every change, but be careful, could take a little bit longer.
+ */
+ public synchronized void layout()
+ {
+ try
+ {
+ // we bring the clear and insert methods together, this should be a little bit smoother
+ clearReportHeader();
+ insertReportHeader();
+
+ clearReportFooter();
+ insertReportFooter();
+
+ clearPageHeader();
+ insertPageHeader();
+
+ clearPageFooter();
+ insertPageFooter();
+
+ clearGroups();
+ insertGroups();
+
+ clearDetails();
+ // clearFieldTitles();
+ insertDetailFieldTitles();
+ insertDetailFields();
+ }
+ catch (java.lang.ArrayIndexOutOfBoundsException e)
+ {
+ // could happen, if you change the count of values
+ }
+ catch (java.lang.RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Exception e)
+ {
+ // Exception not set. Not from interest here.
+ int dummy = 0;
+ }
+ }
+ // -------------------------------------------------------------------------
+ /**
+ * Remove all Groups
+ */
+ protected void clearGroups()
+ {
+ final XGroups xGroups = getReportDefinition().getGroups();
+// int nCount = xGroups.getCount();
+ while (xGroups.hasElements())
+ {
+ try
+ {
+ xGroups.removeByIndex(0);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // Exception not set. Not from interest here.
+ }
+ }
+ }
+ // -------------------------------------------------------------------------
+ /**
+ * Remove all fields
+ * @param _xSectionToClear
+ */
+ private void emptySection(XSection _xSectionToClear)
+ {
+ if (_xSectionToClear == null)
+ {
+ return;
+ }
+ // int nCount = _xSectionToClear.getCount();
+ while (_xSectionToClear.hasElements())
+ {
+ try
+ {
+ final Object aObj = _xSectionToClear.getByIndex(0);
+ final XShape aShape = (XShape) UnoRuntime.queryInterface(XShape.class, aObj);
+ _xSectionToClear.remove(aShape);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // Exception not set.
+ int dummy = 0;
+ }
+
+ }
+ }
+
+ private void clearDetails()
+ {
+ final XSection xSection = getReportDefinition().getDetail();
+ emptySection(xSection);
+ }
+// public void clearFieldTitles()
+// {
+// }
+ /**
+ *
+ * @param _nGroupCount
+ * @return the left indent in 1/100mm
+ */
+ protected int getLeftGroupIndent(int _nGroupCount)
+ {
+// TODO: Fix values for group indent (1/2cm) only the first 2 groups
+ int nIndent = 0;
+ final int MAX_INDENT = 2;
+ if (_nGroupCount <= MAX_INDENT)
+ {
+ nIndent = _nGroupCount * LayoutConstants.IndentFactorWidth;
+ }
+ else
+ {
+ nIndent = MAX_INDENT * LayoutConstants.IndentFactorWidth;
+ }
+ return nIndent;
+ }
+ /**
+ * Get left page indent.
+ * The left indent is the area on the left side which will no be printed.
+ * The default is 2000 1/100mm what is 2cm of DIN A4.
+ * @return the left indent in 1/100mm
+ */
+ int m_nLeftIndent = -1;
+
+ protected int getLeftPageIndent()
+ {
+ if (m_nLeftIndent < 0)
+ {
+ m_nLeftIndent = getFromPageStyles("LeftMargin", 2000);
+ }
+ return m_nLeftIndent;
+ }
+ /**
+ * Get right page indent.
+ * The right indent is the area on the right side which will no be printed.
+ * The default is 2000 1/100mm what is 2cm of DIN A4.
+ * @return the right indent in 1/100mm
+ */
+ int m_nRightIndent = -1;
+
+ protected int getRightPageIndent()
+ {
+ if (m_nRightIndent < 0)
+ {
+ m_nRightIndent = getFromPageStyles("RightMargin", 2000);
+ }
+ return m_nRightIndent;
+ }
+
+ private XStyle getUsedStyle(String _sStyleName)
+ {
+ XStyle aUsedStyle = null;
+ final XNameAccess xNameAccess = getReportDefinition().getStyleFamilies();
+ try
+ {
+ // <Analysecode>
+ // String[] aNames = xNameAccess.getElementNames();
+ // </Analysecode>
+
+ // get all Page Styles
+ final Object aPageStylesObj = xNameAccess.getByName(_sStyleName);
+ final XNameAccess xContainer = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, aPageStylesObj);
+
+ // step over all Page Styles, search the one which is in use
+ final String[] aElementNames = xContainer.getElementNames();
+ for (int i = 0; i < aElementNames.length; i++)
+ {
+ final String sName = aElementNames[i];
+ final Object aObj = xContainer.getByName(sName);
+ final XStyle xStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, aObj);
+ if (xStyle.isInUse())
+ {
+ aUsedStyle = xStyle;
+ break;
+ }
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ e.printStackTrace();
+ }
+ return aUsedStyle;
+ }
+
+ protected int getFromPageStyles(String _sStyleName, int _nDefault)
+ {
+ int nValue = _nDefault;
+ final XStyle xStyle = getUsedStyle("PageStyles");
+ if (xStyle != null)
+ {
+ // we found the page style which is in use
+ final PropertySetHelper aHelper = new PropertySetHelper(xStyle);
+ nValue = aHelper.getPropertyValueAsInteger(_sStyleName, nValue);
+ }
+ return nValue;
+ }
+
+ protected void setToPageStyles(String _sStyleName, Object _aObj)
+ {
+ final XStyle xStyle = getUsedStyle("PageStyles");
+ if (xStyle != null)
+ {
+ final PropertySetHelper aHelper = new PropertySetHelper(xStyle);
+ aHelper.setPropertyValueDontThrow(_sStyleName, _aObj);
+ }
+ }
+ /**
+ * Get page width. The default is 21000 1/100mm what is 21cm of DIN A4.
+ * @return the Width of the page in 1/100mm
+ */
+ int m_nPageWidth = -1;
+
+ protected int getPageWidth()
+ {
+ if (m_nPageWidth < 0)
+ {
+ m_nPageWidth = getFromPageStyles("Width", 21000);
+ }
+ return m_nPageWidth;
+ }
+ // -------------------------------------------------------------------------
+ /**
+ * Stores the Group names. To insert/create a report with such group names, call layout()
+ * @param _aGroupNames
+ */
+ public void insertGroupNames(String[] _aGroupNames)
+ {
+ m_aGroupNames = _aGroupNames;
+ }
+
+ protected void copyGroupProperties(int _nGroup)
+ {
+ if (getDesignTemplate() != null)
+ {
+ try
+ {
+ final XGroups xForeignGroups = getDesignTemplate().getGroups();
+ int nGroups = xForeignGroups.getCount();
+ Object aForeignGroup = xForeignGroups.getByIndex(_nGroup);
+ XGroup xForeignGroup = (XGroup) UnoRuntime.queryInterface(XGroup.class, aForeignGroup);
+ XSection xForeignGroupSection = xForeignGroup.getHeader();
+
+ if (xForeignGroupSection != null)
+ {
+ final XGroups xGroups = getReportDefinition().getGroups();
+ Object aGroup = xGroups.getByIndex(_nGroup);
+ XGroup xGroup = (XGroup) UnoRuntime.queryInterface(XGroup.class, aGroup);
+ XSection xGroupSection = xGroup.getHeader();
+
+ // copy Properties
+ copyProperties(xForeignGroupSection, xGroupSection);
+ }
+ }
+ catch (Exception e)
+ {
+ int dummy = 0;
+ }
+ }
+ }
+ // -------------------------------------------------------------------------
+ protected void insertGroups()
+ {
+ if (m_aGroupNames == null)
+ {
+ return;
+ }
+
+ final XGroups xGroups = getReportDefinition().getGroups();
+ final int nLeftPageIndent = getLeftPageIndent();
+ final int nLabelWidth = getMaxLabelWidth(); // 3000;
+ final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - getLeftGroupIndent(getCountOfGroups());
+ final int nFieldWidth = nUsablePageWidth - nLabelWidth;
+
+ // after done with all groups, we need access to the last group, for set property 'KeepTogether' so we remember it.
+ XGroup aLastGroup = null;
+
+ for (int i = 0; i < m_aGroupNames.length; i++)
+ {
+ final XGroup xGroup = xGroups.createGroup();
+ aLastGroup = xGroup;
+
+ // TODO: debug what the m_aGroupNames are, "field:[...]" or the "fieldname"
+ xGroup.setExpression(m_aGroupNames[i]);
+ xGroup.setHeaderOn(true);
+ // we don't want any group footer (default off)
+ // xGroup.setFooterOn(true);
+
+ try
+ {
+ // we need to append by hand
+ // TODO: documentation is unclear here, that we have to insert by hand
+ int nCount = xGroups.getCount();
+ xGroups.insertByIndex(nCount, xGroup);
+
+ final XSection xGroupSection = xGroup.getHeader();
+ copyGroupProperties(nCount);
+
+ Rectangle aRect = new Rectangle();
+ aRect.X = nLeftPageIndent + getLeftGroupIndent(i);
+ SectionObject aSO = getDesignTemplate().getGroupLabel(i);
+ int nLabelHeight = 0;
+// if (aSO != null)
+// {
+ nLabelHeight = aSO.getHeight(LayoutConstants.LabelHeight);
+ aRect = insertLabel(xGroupSection, getTitleFromFieldName(m_aGroupNames[i]), aRect, nLabelWidth, aSO);
+// }
+// else
+// {
+// nLabelHeight = 500;
+// aRect = insertBoldLabel(xGroupSection, getTitleFromFieldName(m_aGroupNames[i]), aRect, nLabelWidth);
+// }
+ final String sGroupName = convertToFieldName(m_aGroupNames[i]);
+ aSO = getDesignTemplate().getGroupTextField(i);
+ insertFormattedField(xGroupSection, sGroupName, aRect, nFieldWidth, aSO);
+
+ // draw a line under the label/formattedfield
+ aRect.X = nLeftPageIndent + getLeftGroupIndent(i);
+ aRect.Y = nLabelHeight;
+ final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X;
+ final int nLineHeight = LayoutConstants.LineHeight;
+ insertHorizontalLine(xGroupSection, aRect, nLineWidth, nLineHeight);
+ xGroupSection.setHeight(nLabelHeight + nLineHeight);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ }
+ }
+
+ // hold the inner group together
+ if (aLastGroup != null)
+ {
+ doNotBreakInTable(aLastGroup);
+ }
+ }
+
+ // -------------------------------------------------------------------------
+ /**
+ * Give a list off all field title names to insert the field title names, call layout()
+ * @param _aFieldTitleNames
+ */
+ public void insertFieldTitles(String[] _aFieldTitleNames)
+ {
+ m_aFieldTitleNames = _aFieldTitleNames;
+ }
+
+ // -------------------------------------------------------------------------
+ protected String getTitleFromFieldName(String _sField)
+ {
+ for (int i = 0; i < m_aFieldNames.length; i++)
+ {
+ if (m_aFieldNames[i].equals(_sField))
+ {
+ return m_aFieldTitleNames[i];
+ }
+ }
+ return "";
+ }
+
+ protected int getTypeFromFieldName(String _sField)
+ {
+ for (int i = 0; i < m_aFieldNames.length; i++)
+ {
+ if (m_aFieldNames[i].equals(_sField))
+ {
+ return m_aFieldTypes[i];
+ }
+ }
+ return 0;
+ }
+
+ protected boolean listContains(String[] _aList, String _aValue)
+ {
+ for (int i = 0; i < _aList.length; i++)
+ {
+ if (_aList[i].equals(_aValue))
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+ // -------------------------------------------------------------------------
+ /**
+ * Helper to get all field names without the names which are already in the group names
+ * @param _aList
+ * @param _aGetResultFrom
+ * @return
+ */
+ protected String[] getNamesWithoutGroupNames(String[] _aList, String[] _aGetResultFrom)
+ {
+ if (_aList == null /* || _aGetResultsFrom == null */)
+ {
+ return new String[]
+ {
+ }; /* empty list */
+ }
+ if (getCountOfGroups() == 0)
+ {
+ if (_aGetResultFrom != null)
+ {
+ return _aGetResultFrom;
+ }
+ return _aList;
+ }
+ final int nNewLength = _aList.length - getCountOfGroups();
+ String[] aNewList = new String[nNewLength];
+ int j = 0;
+ for (int i = 0; i < _aList.length; i++)
+ {
+ final String sField = _aList[i];
+ if (listContains(m_aGroupNames, sField) == true)
+ {
+ continue;
+ }
+ if (_aGetResultFrom != null)
+ {
+ aNewList[j++] = _aGetResultFrom[i];
+ }
+ else
+ {
+ aNewList[j++] = sField;
+ }
+ if (j == nNewLength)
+ {
+ break; // Emergency break, we leave the result list.
+ }
+ }
+ return aNewList;
+ }
+
+ // -------------------------------------------------------------------------
+ protected int calculateFieldWidth(int _nLeftIndent, int _nFieldCount)
+ {
+ int nWidth = 3000;
+ if (_nFieldCount > 0)
+ {
+ nWidth = (getPageWidth() - getLeftPageIndent() - getRightPageIndent() - _nLeftIndent) / _nFieldCount;
+ }
+ return nWidth;
+ }
+
+ protected String[] getFieldTitleNames()
+ {
+ return getNamesWithoutGroupNames(m_aFieldNames, m_aFieldTitleNames);
+ }
+ // -------------------------------------------------------------------------
+ abstract protected void insertDetailFieldTitles();
+ // -------------------------------------------------------------------------
+ /**
+ * Give a list off all field names to insert the field names, call layout()
+ * @param _aFieldNames
+ */
+ public void insertFieldNames(String[] _aFieldNames)
+ {
+ m_aFieldNames = _aFieldNames;
+ }
+
+ public void insertFieldTypes(int[] _aFieldTypes)
+ {
+ m_aFieldTypes = _aFieldTypes;
+ }
+
+ public void insertFieldWidths(int[] _aFieldWidths)
+ {
+ m_aFieldWidths = _aFieldWidths;
+ }
+
+ protected int getCountOfGroups()
+ {
+ return ((m_aGroupNames == null) ? 0 : m_aGroupNames.length);
+ }
+
+ // -------------------------------------------------------------------------
+ protected String[] getFieldNames()
+ {
+ return getNamesWithoutGroupNames(m_aFieldNames, null);
+ }
+
+ abstract protected void insertDetailFields();
+
+ protected void copyDetailProperties()
+ {
+ if (getDesignTemplate() != null)
+ {
+ try
+ {
+ XSection xForeignSection = getDesignTemplate().getDetail();
+ if (xForeignSection != null)
+ {
+ XSection xSection = getReportDefinition().getDetail();
+
+ // copy Properties
+ copyProperties(xForeignSection, xSection);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ // -------------------------------------------------------------------------
+ protected Rectangle insertLabel(XSection _xSection, String _sLabel, Rectangle _aRect, int _nWidth, SectionObject _aSO)
+ {
+ if (_xSection != null)
+ {
+ try
+ {
+ final Object aFixedText = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedText");
+ final XFixedText xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, aFixedText);
+
+
+ int nHeight = LayoutConstants.LabelHeight; // default height of label is fixed.
+ if (_aSO != null)
+ {
+ if (_aSO instanceof SectionEmptyObject)
+ {
+ float fCharWeight = _aSO.getCharWeight(com.sun.star.awt.FontWeight.NORMAL);
+ if (fCharWeight > 0.1f)
+ {
+ xFixedText.setCharWeight(fCharWeight);
+ }
+ }
+ else
+ {
+// TODO: there seems to be some problems with copy all properties from the design template to the current design
+ final FontDescriptor aFD = _aSO.getFontDescriptor();
+ if (aFD != null)
+ {
+ xFixedText.setFontDescriptor(aFD);
+ copyProperties(_aSO.getParent(), xFixedText);
+ }
+ nHeight = _aSO.getHeight(LayoutConstants.LabelHeight);
+ }
+ }
+ xFixedText.setLabel(_sLabel);
+
+ xFixedText.setPositionX(_aRect.X);
+ xFixedText.setPositionY(_aRect.Y);
+
+ // Width will calculate from outside.
+ // We have to set, because there exist no right default (0)
+ xFixedText.setWidth(_nWidth);
+ _aRect.X += _nWidth;
+ xFixedText.setHeight(nHeight);
+ _xSection.add(xFixedText);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ int dummy = 0;
+ }
+ }
+ return _aRect;
+ }
+ // -------------------------------------------------------------------------
+ protected String convertToFieldName(String _sElementName)
+ {
+ final StringBuffer aDataField = new StringBuffer(32);
+ aDataField.append("field:[").append(_sElementName).append(']');
+ return aDataField.toString();
+
+ }
+ protected String convertFromFieldName(String _sName)
+ {
+ if (_sName.startsWith("field:["))
+ {
+ int nCloseBrace = _sName.lastIndexOf("]");
+ final String sName = _sName.substring(7, nCloseBrace).trim();
+ return sName;
+ }
+ return _sName;
+ }
+ // -------------------------------------------------------------------------
+ /**
+ * Insert a already formatted field name into a given section
+ *
+ * Use 'convertToFieldName(dbfield)' to convert a dbfield name in the right.
+ *
+ * @param _xSection in which section the formatted field will store
+ * @param _sFormattedfield as String a dbfield or an other function
+ * @param _aRect .X, .Y are the absolute position (1/100mm) where the formatted field will set
+ * @param _nWidth the width of the field in 1/100mm
+ * @param _aSO
+ * @return a new Rectangle with the new Rect.X position, Rect.Y will not change.
+ */
+ protected Rectangle insertFormattedField(XSection _xSection, String _sFormattedfield, Rectangle _aRect, int _nWidth, SectionObject _aSO)
+ {
+ return insertFormattedField(_xSection, _sFormattedfield, _aRect, _nWidth, _aSO, (short) com.sun.star.awt.TextAlign.LEFT);
+ }
+
+ protected Rectangle insertFormattedField(XSection _xSection, String _sFormattedfield, Rectangle _aRect, int _nWidth, SectionObject _aSO, short _nAlignment)
+ {
+ if (_xSection != null)
+ {
+ try
+ {
+ Object aField;
+ int nHeight = LayoutConstants.FormattedFieldHeight;
+
+ int nType = getTypeFromFieldName(convertFromFieldName(_sFormattedfield));
+ if (nType == DataType.BINARY ||
+ nType == DataType.VARBINARY ||
+ nType == DataType.LONGVARBINARY)
+ {
+ aField = getMSFofReportDefinition().createInstance("com.sun.star.report.ImageControl");
+ nHeight = LayoutConstants.BinaryHeight;
+ }
+ else
+ {
+ aField = getMSFofReportDefinition().createInstance("com.sun.star.report.FormattedField");
+ nHeight = LayoutConstants.FormattedFieldHeight;
+ if (nType == DataType.LONGVARCHAR) /* memo */
+ {
+ nHeight = LayoutConstants.MemoFieldHeight; // special case for memo
+ }
+ }
+ _aRect.Height = nHeight;
+
+ final XReportControlModel xReportControlModel = (XReportControlModel) UnoRuntime.queryInterface(XReportControlModel.class, aField);
+ if (xReportControlModel != null)
+ {
+ // #i86907# not documented right in idl description.
+ xReportControlModel.setDataField(_sFormattedfield);
+ if (_aSO != null)
+ {
+ // TODO: there seems to be some problems with copy all properties from the design template to the current design
+ final FontDescriptor aFD = _aSO.getFontDescriptor();
+ if (aFD != null)
+ {
+ xReportControlModel.setFontDescriptor(aFD);
+ copyProperties(_aSO.getParent(), xReportControlModel);
+ }
+ nHeight = _aSO.getHeight(nHeight);
+ }
+ xReportControlModel.setPositionX(_aRect.X);
+ xReportControlModel.setPositionY(_aRect.Y);
+ xReportControlModel.setWidth(_nWidth);
+ _aRect.X += _nWidth;
+ xReportControlModel.setHeight(nHeight);
+
+ if (nType == DataType.BINARY ||
+ nType == DataType.VARBINARY ||
+ nType == DataType.LONGVARBINARY)
+ {
+ // aField = getMSFofReportDefinition().createInstance("com.sun.star.report.ImageControl");
+ final XImageControl xImageControl = (XImageControl) UnoRuntime.queryInterface(XImageControl.class, xReportControlModel);
+ if (xImageControl != null)
+ {
+ // xImageControl.setScaleImage(true);
+
+ xImageControl.setScaleMode(com.sun.star.awt.ImageScaleMode.Isotropic);
+ }
+ }
+ else
+ {
+ try
+ {
+ xReportControlModel.setParaAdjust(_nAlignment);
+ // if (nType == DataType.LONGVARCHAR)
+ // {
+ // xReportControlModel.???
+ // }
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ // seems we not able to set ParaAdjust
+ }
+ }
+ // spezial case rpt:now() (default date format)
+ if (_sFormattedfield.equals("rpt:now()"))
+ {
+ final XFormattedField xFormattedField = (XFormattedField) UnoRuntime.queryInterface(XFormattedField.class, xReportControlModel);
+
+ XNumberFormatsSupplier x = xFormattedField.getFormatsSupplier();
+ XNumberFormats xFormats = x.getNumberFormats();
+ XNumberFormatTypes x3 = (XNumberFormatTypes) UnoRuntime.queryInterface(XNumberFormatTypes.class, xFormats);
+ Locale.getDefault();
+ com.sun.star.lang.Locale aLocale = new com.sun.star.lang.Locale();
+ aLocale.Country = Locale.getDefault().getCountry();
+ aLocale.Language = Locale.getDefault().getLanguage();
+
+ int nFormat = x3.getStandardFormat(com.sun.star.util.NumberFormat.DATE, aLocale);
+ xFormattedField.setFormatKey(nFormat);
+ }
+ _xSection.add(xReportControlModel);
+ }
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ int dummy = 0;
+ }
+ }
+ return _aRect;
+ }
+
+ // -------------------------------------------------------------------------
+// TODO: check with Query, this code will not work with Queries
+ public void setTableName(int _aType, String _sTableName)
+ {
+ m_aCommandType = _aType;
+ m_sTableName = _sTableName;
+
+ // getReportDefinition().setCommandType(com.sun.star.sdb.CommandType.TABLE);
+ getReportDefinition().setCommandType(_aType);
+ getReportDefinition().setCommand(_sTableName);
+ } // -------------------------------------------------------------------------
+ protected XMultiServiceFactory m_xMSF;
+
+ protected XMultiServiceFactory getMSFofReportDefinition()
+ {
+ if (m_xMSF == null)
+ {
+ final XMultiServiceFactory xMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, getReportDefinition());
+ m_xMSF = xMSF;
+ }
+ return m_xMSF;
+ }
+ // -------------------------------------------------------------------------
+ protected Rectangle insertVerticalLine(XSection _xSection, Rectangle _aRect, int _nWidth, int _nHeight)
+ {
+ return insertLine(_xSection, _aRect, _nWidth, _nHeight, 1);
+ }
+
+ protected Rectangle insertHorizontalLine(XSection _xSection, Rectangle _aRect, int _nWidth, int _nHeight)
+ {
+ return insertLine(_xSection, _aRect, _nWidth, _nHeight, 0);
+ }
+
+ protected Rectangle insertLine(XSection _xSection, Rectangle _aRect, int _nWidth, int _nHeight, int _nOrientation)
+ {
+ if (_xSection != null)
+ {
+ try
+ {
+ final Object aFixedLine = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedLine");
+ final XFixedLine xFixedLine = (XFixedLine) UnoRuntime.queryInterface(XFixedLine.class, aFixedLine);
+
+ xFixedLine.setOrientation(_nOrientation);
+ // TODO: line width is fixed
+ xFixedLine.setLineWidth(8);
+
+ xFixedLine.setPositionX(_aRect.X);
+ xFixedLine.setPositionY(_aRect.Y);
+
+ xFixedLine.setWidth(_nWidth);
+ _aRect.X += _nWidth;
+ xFixedLine.setHeight(_nHeight);
+ _xSection.add(xFixedLine);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ int dummy = 0;
+ }
+ }
+ return _aRect;
+ }
+ // -------------------------------------------------------------------------
+ protected void clearReportHeader()
+ {
+ XSection xSection;
+ try
+ {
+ if (getReportDefinition().getReportHeaderOn())
+ {
+ xSection = getReportDefinition().getReportHeader();
+ emptySection(xSection);
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ // Exception not set. Not really from interest.
+ }
+ }
+
+ protected void insertReportHeader()
+ {
+ if (getDesignTemplate() != null)
+ {
+ if (getDesignTemplate().getReportHeaderOn())
+ {
+ // copy all Section information from Page Header to our Header
+ try
+ {
+ XSection xForeignSection = getDesignTemplate().getReportHeader();
+
+ if (xForeignSection != null)
+ {
+ getReportDefinition().setReportHeaderOn(true);
+ XSection xSection = getReportDefinition().getReportHeader();
+
+ // copy Sections
+ copySection(xForeignSection, xSection);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ else
+ {
+ // we won't a page header
+ getReportDefinition().setReportHeaderOn(false);
+ }
+ }
+ }
+
+ protected void clearReportFooter()
+ {
+ XSection xSection;
+ try
+ {
+ if (getReportDefinition().getReportFooterOn())
+ {
+ xSection = getReportDefinition().getReportFooter();
+ emptySection(xSection);
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ // Exception not set. Not really from interest.
+ }
+ }
+
+ protected void insertReportFooter()
+ {
+ if (getDesignTemplate() != null)
+ {
+ if (getDesignTemplate().getReportFooterOn())
+ {
+ // copy all Section information from Page Header to our Header
+ try
+ {
+ XSection xForeignSection = getDesignTemplate().getReportFooter();
+
+ if (xForeignSection != null)
+ {
+ getReportDefinition().setReportFooterOn(true);
+ XSection xSection = getReportDefinition().getReportFooter();
+
+ // copy Sections
+ copySection(xForeignSection, xSection);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ else
+ {
+ // we won't a page header
+ getReportDefinition().setReportFooterOn(false);
+ }
+ }
+ }
+ // -------------------------------------------------------------------------
+ protected void clearPageHeader()
+ {
+ XSection xSection;
+ try
+ {
+ if (getReportDefinition().getPageHeaderOn())
+ {
+ xSection = getReportDefinition().getPageHeader();
+ emptySection(xSection);
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ // Exception not set. Not really from interest.
+ }
+ }
+
+// protected static String getDateString(String _sFormat)
+// {
+// GregorianCalendar aCalendar = new GregorianCalendar();
+// StringBuffer aBuf = new StringBuffer();
+//
+// Locale aLocale = new Locale("en","US");
+// SimpleDateFormat aFormat = new SimpleDateFormat(_sFormat, aLocale);
+// aBuf = aFormat.format(aCalendar.getTime(), aBuf, new FieldPosition(0) );
+// // DebugHelper.writeInfo("Date: " + aBuf.toString());
+// return aBuf.toString();
+// }
+
+// protected String getCurrentDate()
+// {
+// Calendar aCalendar = Calendar.getInstance();
+//// aCalendar.setTimeInMillis(1202382900000L);
+//// aCalendar.
+// Date aDate = new Date();
+// String sDate = DateFormat.getDateInstance().format(aDate);
+// // String aCalStr = aCalendar.toString();
+// return sDate;
+// //
+//// Date aDate = new Date();
+//// aDate.setSeconds(0);
+//// aDate.setMinutes(15);
+//// aDate.setHours(12);
+//// // aDate.setMonth(2);
+//// // aDate.setYear(2008);
+//// // aDate.setDay(7);
+//// long nTime = aDate.getTime();
+//// Long aLong = new Long(nTime);
+//// String aStr = aLong.toString();
+////
+//// Date aNewDate = new Date(1202382900000L);
+////// aNewDate.
+//// String aDateStr = aNewDate.toString();
+////// Datetime aNewTime = new Time(1202382900);
+////// String aTimeStr = aNewTime.toString();
+////
+//
+// }
+ protected void clearPageFooter()
+ {
+ XSection xSection;
+ try
+ {
+ if (getReportDefinition().getPageFooterOn())
+ {
+ xSection = getReportDefinition().getPageFooter();
+ emptySection(xSection);
+ }
+ }
+ catch (com.sun.star.container.NoSuchElementException e)
+ {
+ // Exception not set. Should not from interest here.
+ }
+ }
+
+ public void setPageOrientation(int _nOrientation)
+ {
+ final int nWidth = getFromPageStyles("Width", 0);
+ final int nHeight = getFromPageStyles("Height", 0);
+
+ if (com.sun.star.wizards.report.ReportLayouter.SOOPTLANDSCAPE == _nOrientation)
+ {
+ setToPageStyles("IsLandscape", Boolean.TRUE);
+ if (nWidth < nHeight)
+ {
+ setToPageStyles("Width", new Integer(nHeight));
+ setToPageStyles("Height", new Integer(nWidth));
+ }
+ }
+ else
+ {
+ setToPageStyles("IsLandscape", Boolean.FALSE);
+ if (nHeight < nWidth)
+ {
+ setToPageStyles("Width", new Integer(nHeight));
+ setToPageStyles("Height", new Integer(nWidth));
+ }
+ }
+ // dirty the PageWidth
+ m_nPageWidth = -1;
+ }
+
+ /**
+ * Returns the width and height of a given string (_sText) in 1/100mm drawn in the given font descriptor.
+ * TODO: This function is a performance leak, we could store already calculated values in a map, to build a cache. Access should be much faster then.
+ *
+ * @param _sText
+ * @param _aFont
+ * @return width of given text in 1/100mm
+ */
+ Size getPreferredSize(String _sText, FontDescriptor _aFont)
+ {
+ Size aSizeMM_100TH = new Size(0, 0);
+ try
+ {
+ // Object aControlContainer = getGlobalMSF().createInstance("com.sun.star.awt.UnoControlContainer");
+ // XControlContainer xControlContainer = (XControlContainer)UnoRuntime.queryInterface(XControlContainer.class, aControlContainer);
+
+ final Object aFixedTextModel = getGlobalMSF().createInstance("com.sun.star.awt.UnoControlFixedTextModel");
+ final XControlModel xFixedTextModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, aFixedTextModel);
+
+ final PropertySetHelper aPropertySetHelper = new PropertySetHelper(xFixedTextModel);
+// aPropertySetHelper.showProperties();
+ aPropertySetHelper.setPropertyValueDontThrow("FontDescriptor", _aFont);
+
+ final Object aUnoCtrlFixedText = getGlobalMSF().createInstance("com.sun.star.awt.UnoControlFixedText");
+// XServiceInfo xServiceInfo2 = (XServiceInfo)UnoRuntime.queryInterface(XServiceInfo.class, aUnoCtrlFixedText);
+// String[] sServices2 = xServiceInfo2.getSupportedServiceNames();
+
+ final XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, aUnoCtrlFixedText);
+ xWindow.setVisible(false);
+
+ final XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, aUnoCtrlFixedText);
+ xControl.setModel(xFixedTextModel);
+
+ final com.sun.star.awt.XFixedText xFixedText = (com.sun.star.awt.XFixedText) UnoRuntime.queryInterface(com.sun.star.awt.XFixedText.class, aUnoCtrlFixedText);
+ xFixedText.setText(_sText);
+
+ final XLayoutConstrains xLayoutConstraints = (XLayoutConstrains) UnoRuntime.queryInterface(XLayoutConstrains.class, aUnoCtrlFixedText);
+ final Size aSizeInPixel = xLayoutConstraints.getPreferredSize();
+
+ final XWindowPeer xPeerOfReportDefinition = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, getReportDefinition().getCurrentController().getFrame().getComponentWindow());
+ xControl.createPeer(null, xPeerOfReportDefinition);
+
+ final XWindowPeer x = xControl.getPeer();
+
+ final XUnitConversion xConversion = (XUnitConversion) UnoRuntime.queryInterface(XUnitConversion.class, x);
+ aSizeMM_100TH = xConversion.convertSizeToLogic(aSizeInPixel, com.sun.star.util.MeasureUnit.MM_100TH);
+ // xToolkit.createScreenCompatibleDevice(_nWidth, _nWidth).
+ // XWindow x = getReportDefinition().getCurrentController().getFrame().getContainerWindow();
+ // Object aObj = _xSection.getParent();
+
+ // we don't need the created objects any longer
+ final XComponent xFixedTextDeleter = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFixedText);
+ xFixedTextDeleter.dispose();
+
+ final XComponent xFixedTextModelDeleter = (XComponent) UnoRuntime.queryInterface(XComponent.class, aFixedTextModel);
+ xFixedTextModelDeleter.dispose();
+ }
+ catch (Exception e)
+ {
+ // TODO: Exception not set.
+ }
+ return aSizeMM_100TH;
+ }
+
+ protected String getTableName()
+ {
+ if (m_sTableName != null)
+ {
+ return m_sTableName;
+ }
+ return "";
+ }
+
+ protected String getUserNameFromConfiguration()
+ {
+ String sFirstName = "";
+ String sLastName = "";
+ try
+ {
+ Object oProdNameAccess = Configuration.getConfigurationRoot(getGlobalMSF(), "org.openoffice.UserProfile/Data", false);
+ sFirstName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "givenname");
+ sLastName = (String) Helper.getUnoObjectbyName(oProdNameAccess, "sn");
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return sFirstName + " " + sLastName;
+ }
+
+ /**
+ * Helper function, to copy all not read only properties of _xFromSection to _xToSection
+ * @param _xFromSection
+ * @param _xToSection
+ */
+ private void copyProperties(Object _aFrom, Object _aTo)
+ {
+ XPropertySet xFrom = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _aFrom);
+ XPropertySet xTo = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _aTo);
+
+
+ XPropertySetInfo xForeignPropInfo = xFrom.getPropertySetInfo();
+ XPropertySetInfo xSectionPropInfo = xTo.getPropertySetInfo();
+ Property[] aAllProperties = xForeignPropInfo.getProperties();
+ for (int i = 0; i < aAllProperties.length; i++)
+ {
+ String sPropertyName = aAllProperties[i].Name;
+ if (xSectionPropInfo.hasPropertyByName(sPropertyName))
+ {
+ try
+ {
+ Property aDestProp = xForeignPropInfo.getPropertyByName(sPropertyName);
+ if ((aDestProp.Attributes & PropertyAttribute.READONLY) == 0)
+ {
+ xTo.setPropertyValue(sPropertyName, xFrom.getPropertyValue(sPropertyName));
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ }
+ }
+
+ /**
+ * Helper Funktion to copy the whole content of _xFromSection to the _xToSection
+ * @param _xFromSection
+ * @param _xToSection
+ */
+ private void copySection(XSection _xFromSection, XSection _xToSection)
+ {
+ copyProperties(_xFromSection, _xToSection);
+
+ try
+ {
+ XEnumeration xEnum = _xFromSection.createEnumeration();
+ while (xEnum.hasMoreElements())
+ {
+ Object aEnumObj = xEnum.nextElement();
+ XReportComponent aComponent = (XReportComponent) UnoRuntime.queryInterface(XReportComponent.class, aEnumObj);
+
+ // XCloneable aClone = (XCloneable)UnoRuntime.queryInterface(XCloneable.class, aEnumObj);
+ if (aComponent != null)
+ {
+ Object aClone = aComponent.createClone();
+ if (aClone != null)
+ {
+ String sName = aComponent.getName();
+ com.sun.star.awt.Point aPosition = aComponent.getPosition();
+ Size aSize = aComponent.getSize();
+
+ XShape aShape = (XShape) UnoRuntime.queryInterface(XShape.class, aClone);
+ String sShapeType = aShape.getShapeType();
+ com.sun.star.awt.Point aShapePoint = aShape.getPosition();
+ Size aShapeSize = aShape.getSize();
+
+ // normally 'createClone' will create a real clone of the component,
+ // but there seems some problems, we have to controll.
+ copyProperties(aComponent, aClone);
+
+ // aShape.setPosition(aComponent.getPosition());
+ // aShape.setSize(aComponent.getSize());
+ _xToSection.add(aShape);
+ }
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ // String sName = xForeignSection.getName();
+ // int dummy = 0;
+ }
+
+ protected void insertPageHeader()
+ {
+ if (getDesignTemplate() != null)
+ {
+ if (getDesignTemplate().getPageHeaderOn())
+ {
+ // copy all Section information from Page Header to our Header
+ try
+ {
+ XSection xForeignSection = getDesignTemplate().getPageHeader();
+
+ if (xForeignSection != null)
+ {
+ getReportDefinition().setPageHeaderOn(true);
+ XSection xSection = getReportDefinition().getPageHeader();
+
+ // copy Sections
+ copySection(xForeignSection, xSection);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ return;
+ }
+ else
+ {
+ // we won't a page header
+ // getReportDefinition().setPageHeaderOn(true);
+ getReportDefinition().setPageHeaderOn(false);
+ }
+ }
+ else
+ {
+ if (getReportDefinition() == null)
+ {
+ return;
+ }
+ // there is no foreign report definition
+ // TODO: #i86902# rpt:Title() out of the document
+
+ // TODO: #i86902# rpt:Author() can't set with something like rpt:author()
+ // TODO: #i86902# more fieldnames need.
+ final String sTitleTitle = getResource().getResText(UIConsts.RID_REPORT + 86); // "Title:"
+ final String sTitle = getTableName(); // "Default title, this is a first draft report generated by the new report wizard.";
+ final String sAuthorTitle = getResource().getResText(UIConsts.RID_REPORT + 87); // "Author:"
+ final String sAuthor = getUserNameFromConfiguration(); // "You"; // rpt:fieldvalue();
+ final String sDateTitle = getResource().getResText(UIConsts.RID_REPORT + 88); // "Date:"
+ // TODO: #i86911# Date: we need to set the style of the date.
+ final String sDate = "rpt:now()"; // getDateString("EEE, d MMM yyyy HH:mm:ss zzzz");
+
+ try
+ {
+ getReportDefinition().setPageHeaderOn(true);
+ XSection xSection = null;
+ xSection = getReportDefinition().getPageHeader();
+
+ Rectangle aRect = new Rectangle();
+ aRect.X = getLeftPageIndent();
+ SectionObject aSOLabel = SectionEmptyObject.create();
+ aSOLabel.setFontToBold();
+ aRect.Y = aSOLabel.getHeight(LayoutConstants.LabelHeight);
+
+ final int nWidth = 3000;
+
+ aRect = insertLabel(xSection, sTitleTitle, aRect, nWidth, aSOLabel);
+
+ final int nTitleWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent() - 3000;
+ // aRect = insertFormattedField(xSection, "rpt:Title()", aRect, nTitleWidth);
+ aRect = insertLabel(xSection, sTitle, aRect, nTitleWidth, aSOLabel);
+
+ aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight;
+
+ aRect.X = getLeftPageIndent();
+ aRect = insertLabel(xSection, sAuthorTitle, aRect, nWidth, aSOLabel);
+ // aRect = insertFormattedField(xSection, "rpt:Author()", aRect, nWidth);
+ aRect = insertLabel(xSection, sAuthor, aRect, nTitleWidth, aSOLabel);
+
+ aRect.Y += aSOLabel.getHeight(LayoutConstants.LabelHeight);
+
+ aRect.X = getLeftPageIndent();
+ aRect = insertLabel(xSection, sDateTitle, aRect, nWidth, aSOLabel);
+ // aRect = insertFormattedField(xSection, "rpt:Date()", aRect, nWidth);
+ aRect = insertFormattedField(xSection, sDate, aRect, nTitleWidth, aSOLabel);
+
+ aRect.Y += aSOLabel.getHeight(LayoutConstants.FormattedFieldHeight) + LayoutConstants.LineHeight;
+
+ // draw a line under the label/formattedfield
+ aRect.X = getLeftPageIndent();
+ final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X;
+ final int nLineHeight = LayoutConstants.LineHeight;
+ insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight);
+
+ aRect.Y += nLineHeight;
+
+ xSection.setHeight(aRect.Y);
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ }
+ }
+ }
+
+ protected void insertPageFooter()
+ {
+ if (getDesignTemplate() != null)
+ {
+ if (getDesignTemplate().getPageFooterOn())
+ {
+ try
+ {
+ XSection xForeignSection = getDesignTemplate().getPageFooter();
+
+ if (xForeignSection != null)
+ {
+ getReportDefinition().setPageFooterOn(true);
+ XSection xSection = getReportDefinition().getPageFooter();
+
+ // copy Sections
+ copySection(xForeignSection, xSection);
+ }
+ }
+ catch (Exception e)
+ {
+ }
+ }
+ else
+ {
+ // getReportDefinition().setPageFooterOn(true);
+ getReportDefinition().setPageFooterOn(false);
+ }
+ }
+ else
+ {
+ if (getReportDefinition() == null)
+ {
+ return;
+ }
+
+ // TODO: how should we arrive this code (set page and pagecount in the middle of the page footer)
+ // If there exists a design template, don't use it.
+
+ // we don't have a default report definition
+ final String sPageOf = getResource().getResText(UIConsts.RID_REPORT + 89); // 'Page #page# of #count#'
+
+ // Convert
+ // 'Page #page# of #count#'
+ // to something like
+ // '\"Page \" & PageNumber() & \" of \" & PageCount()'
+ // due to the fact that is is not fixed, where #page# or #count# occurs, we make it
+ // a little bit trickier.
+ // we first surround the string with double quotes,
+ // second, replace the #...#
+ // last, we remove double 'double quotes'.
+ final String sSurroundDoubleQuotes = "\"" + sPageOf + "\"";
+ final String sPageNumber = sSurroundDoubleQuotes.replaceAll("#page#", "\" & PageNumber() & \"");
+ final String sPageCount = sPageNumber.replaceAll("#count#", "\" & PageCount() & \"");
+ final String sNoLastUnusedQuotes = sPageCount.replaceAll(" & \\\"\\\"", "");
+ final String sNoFirstUnusedQuotes = sNoLastUnusedQuotes.replaceAll("\\\"\\\" & ", "");
+
+ final int nUsablePageWidth = getPageWidth() - getLeftPageIndent() - getRightPageIndent();
+
+ try
+ {
+ getReportDefinition().setPageFooterOn(true);
+ XSection xSection = null;
+ xSection = getReportDefinition().getPageFooter();
+
+ Rectangle aRect = new Rectangle();
+ aRect.X = getLeftPageIndent();
+
+ // draw a line over the label/formattedfield
+ final int nLineWidth = getPageWidth() - getRightPageIndent() - aRect.X;
+ final int nLineHeight = LayoutConstants.LineHeight;
+ insertHorizontalLine(xSection, aRect, nLineWidth, nLineHeight);
+
+ aRect.Y += nLineHeight;
+ aRect.Y += LayoutConstants.LabelHeight;
+
+ final int nWidth = nUsablePageWidth;
+ aRect.X = getLeftPageIndent();
+
+ aRect = insertFormattedField(xSection, "rpt:" + sNoFirstUnusedQuotes, aRect, nWidth, null, (short) com.sun.star.awt.TextAlign.CENTER);
+
+ aRect.Y += LayoutConstants.FormattedFieldHeight + LayoutConstants.LineHeight;
+ xSection.setHeight(aRect.Y);
+ }
+ catch (Exception e)
+ {
+ // TODO: Exception not set.
+ }
+ }
+ }
+
+ protected Resource getResource()
+ {
+ return m_aResource;
+ }
+ protected int m_aCommandType; // Table or Query
+ protected String m_sTableName;
+ protected String[] m_aGroupNames;
+ protected String[] m_aFieldNames;
+ protected String[] m_aFieldTitleNames;
+ protected int[] m_aFieldWidths;
+ protected int[] m_aFieldTypes;
+ // protected int[] m_nLeftIndent;
+ private DesignTemplate m_xDesignTemplate = null;
+
+ public void initializeData(IReportBuilderLayouter _aOther)
+ {
+ if (_aOther instanceof ReportBuilderLayouter)
+ {
+ final ReportBuilderLayouter aOther = (ReportBuilderLayouter) _aOther;
+ m_aCommandType = aOther.m_aCommandType;
+ m_sTableName = aOther.m_sTableName;
+ m_aGroupNames = aOther.m_aGroupNames;
+ m_aFieldNames = aOther.m_aFieldNames;
+ m_aFieldTitleNames = aOther.m_aFieldTitleNames;
+ m_aFieldWidths = aOther.m_aFieldWidths;
+ m_aFieldTypes = aOther.m_aFieldTypes;
+ // m_nLeftIndent = aOther.m_nLeftIndent;
+ m_xDesignTemplate = aOther.m_xDesignTemplate;
+
+ // dirty PageWidth
+ m_nPageWidth = -1;
+ }
+ }
+
+ /**
+ * Get the maximal label width of all labels
+ * @return the width in 1/100mm
+ */
+ protected int getMaxLabelWidth()
+ {
+ int nWidth = 0;
+ final String[] aFieldTitles = m_aFieldTitleNames; // we want all Field Titles here // getFieldTitleNames();
+ for (int i = 0; i < aFieldTitles.length; i++)
+ {
+ final String sLabel = aFieldTitles[i];
+ nWidth = Math.max(nWidth, getLabelWidth(sLabel));
+ }
+ for (int i = 0; i < m_aGroupNames.length; i++)
+ {
+ final String sGroupName = m_aGroupNames[i];
+ final SectionObject a = getDesignTemplate().getGroupLabel(i);
+ final FontDescriptor aFD = a.getFontDescriptor();
+ nWidth = Math.max(nWidth, getLabelWidth(sGroupName, aFD));
+ }
+
+ if (nWidth == 0)
+ {
+ nWidth = 3000;
+ }
+ else
+ {
+ nWidth += 500;
+ }
+ return nWidth;
+ }
+
+ /**
+ * Get width of a given string (Label) in 1/100mm
+ * @param _sLabel
+ * @return the width in 1/100mm
+ */
+ protected int getLabelWidth(String _sLabel)
+ {
+ return getLabelWidth(_sLabel, 0.0f, 0.0f);
+ }
+ XFixedText m_aFixedTextHelper = null;
+ HashMap m_aLabelWidthMap;
+
+ protected int getLabelWidth(String _sLabel, FontDescriptor _aFD)
+ {
+ float fCharWeight = 0.0f;
+ float fCharHeight = 0.0f;
+ if (_aFD != null)
+ {
+ fCharWeight = _aFD.Weight;
+ fCharHeight = _aFD.Height;
+ }
+ return getLabelWidth(_sLabel, fCharWeight, fCharHeight);
+ }
+
+ protected int getLabelWidth(String _sLabel, float _nCharWeight, float _nCharHeight)
+ {
+ int nWidth = 0;
+
+ if (m_aLabelWidthMap == null)
+ {
+ m_aLabelWidthMap = new HashMap();
+ }
+ // At first, try to get the Width out of a HashMap (Cache)
+ StringBuffer aKey = new StringBuffer(40);
+ final String sKey = aKey.append(_sLabel).append(_nCharWeight).append(_nCharHeight).toString();
+ if (m_aLabelWidthMap.containsKey(sKey))
+ {
+ final Object aWidth = m_aLabelWidthMap.get(sKey);
+ final Integer aIntegerWidth = (Integer) aWidth;
+ nWidth = aIntegerWidth.intValue();
+ }
+ else
+ {
+ try
+ {
+ if (m_aFixedTextHelper == null)
+ {
+ final Object aFixedText = getMSFofReportDefinition().createInstance("com.sun.star.report.FixedText");
+ m_aFixedTextHelper = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, aFixedText);
+ }
+
+ m_aFixedTextHelper.setLabel(_sLabel);
+ if (_nCharWeight > 0.1f)
+ {
+ m_aFixedTextHelper.setCharWeight(_nCharWeight);
+ }
+ if (_nCharHeight > 0.1f)
+ {
+ m_aFixedTextHelper.setCharHeight(_nCharHeight);
+ }
+
+ final FontDescriptor xFont = m_aFixedTextHelper.getFontDescriptor();
+ final Size aSize = getPreferredSize(_sLabel, xFont);
+ nWidth = aSize.Width;
+ // cache the found width
+ m_aLabelWidthMap.put(sKey, new Integer(nWidth));
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ // TODO: Exception not set.
+ }
+ }
+ return nWidth;
+ }
+
+ protected void doNotBreakInTable(Object _xSectionOrGroup)
+ {
+// try
+// {
+// _xSection.setKeepTogether(true);
+ final PropertySetHelper aHelper = new PropertySetHelper(_xSectionOrGroup);
+ aHelper.setPropertyValueDontThrow("KeepTogether", Boolean.TRUE);
+// }
+// catch (com.sun.star.uno.Exception e)
+// {
+// // Exception not set, but not really from interest.
+// }
+ }
+
+ protected DesignTemplate getDesignTemplate()
+ {
+ if (m_xDesignTemplate == null)
+ {
+ // initialise the report definition.
+ String sDefaultHeaderLayout = m_xReportDefinitionReadAccess.getDefaultHeaderLayout();
+ loadAndSetBackgroundTemplate(sDefaultHeaderLayout);
+
+ // copy all functions from the design template to the current report definition
+// XFunctions xOtherFunctions = m_xDesignTemplate.getReportDefinition().getFunctions();
+// final int nFunctionCount = xOtherFunctions.getCount();
+// for (int i=0;i<nFunctionCount;i++)
+// {
+// try
+// {
+// Object aOtherFunction = xOtherFunctions.getByIndex(i);
+// XFunctions xFunctions = getReportDefinition().getFunctions();
+// XFunction xFunction = xFunctions.createFunction();
+//
+// copyProperties(aOtherFunction, xFunction);
+// xFunctions.insertByIndex(xFunctions.getCount(), xFunction);
+// }
+// catch (com.sun.star.lang.IllegalArgumentException e)
+// {
+// }
+// catch (IndexOutOfBoundsException ex)
+// {
+// ex.printStackTrace();
+// }
+// catch (WrappedTargetException ex)
+// {
+// ex.printStackTrace();
+// }
+//
+// }
+
+ }
+ return m_xDesignTemplate;
+ }
+
+ /**
+ * If there already exists a foreign report definition, which we use to get the layout from
+ * close it.
+ * Veto is not allowed here.
+ */
+ private void closeDesignTemplate()
+ {
+ if (m_xDesignTemplate != null)
+ {
+ m_xDesignTemplate.close();
+ m_xDesignTemplate = null;
+ }
+ }
+
+ /**
+ * load the given string as a template and use it's content to paint the other
+ * @param LayoutTemplatePath
+ */
+ public void loadAndSetBackgroundTemplate(String LayoutTemplatePath)
+ {
+ closeDesignTemplate();
+
+ String sName = FileAccess.getFilename(LayoutTemplatePath);
+ if (sName.toLowerCase().equals("default.otr_") ||
+ LayoutTemplatePath.equals("DefaultLayoutOfHeaders"))
+ {
+ // this is the default layout, we don't want to have a layout for this.
+ }
+ else
+ {
+ XMultiServiceFactory xMSF = getGlobalMSF();
+ m_xDesignTemplate = DesignTemplate.create(xMSF, LayoutTemplatePath);
+ }
+ }
+}
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java
new file mode 100644
index 000000000000..8df754795e63
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionEmptyObject.java
@@ -0,0 +1,55 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.FontDescriptor;
+
+/**
+ *
+ * @author ll93751
+ */
+public class SectionEmptyObject extends SectionObject
+{
+
+ protected SectionEmptyObject()
+ {
+ m_aParentObject = null;
+ }
+
+ public static SectionObject create()
+ {
+ SectionEmptyObject a = new SectionEmptyObject();
+ return a;
+ }
+
+ public FontDescriptor getFontDescriptor()
+ {
+ return null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java
new file mode 100644
index 000000000000..ae3766fd3391
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionLabel.java
@@ -0,0 +1,74 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.report.XFixedText;
+// import com.sun.star.wizards.common.PropertySetHelper;
+/**
+ *
+ * @author ll93751
+ */
+public class SectionLabel extends SectionObject
+{
+
+ protected SectionLabel(XFixedText _aFixedText)
+ {
+ m_aParentObject = _aFixedText;
+ // We would like to know, what properties are in this object.
+// PropertySetHelper aHelper = new PropertySetHelper(_aFixedText);
+// aHelper.showProperties();
+ }
+
+ public static SectionObject create(XFixedText _aFixedText)
+ {
+ final SectionLabel a = new SectionLabel(_aFixedText);
+ return a;
+ }
+
+ /**
+ * Return the current FontDescriptor
+ * @return
+ */
+ public FontDescriptor getFontDescriptor()
+ {
+ FontDescriptor a = null;
+ try
+ {
+ final XFixedText aLabel = (XFixedText) getParent();
+ a = aLabel.getFontDescriptor();
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ }
+ return a;
+ }
+}
+
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java
new file mode 100644
index 000000000000..fa33e85d39cb
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionObject.java
@@ -0,0 +1,86 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.wizards.common.PropertySetHelper;
+
+/**
+ *
+ * @author ll93751
+ */
+abstract public class SectionObject
+{
+
+ Object m_aParentObject; // this could be FixedText or FormattedField or null
+ PropertySetHelper m_aPropertySetHelper;
+
+ public SectionObject()
+ {
+ m_aParentObject = null;
+ }
+
+ protected Object getParent()
+ {
+ return m_aParentObject;
+ }
+
+ abstract public FontDescriptor getFontDescriptor();
+
+ private PropertySetHelper getPropertySetHelper()
+ {
+ if (m_aPropertySetHelper == null)
+ {
+ m_aPropertySetHelper = new PropertySetHelper(getParent());
+ }
+ return m_aPropertySetHelper;
+ }
+
+ public int getHeight(int _nDefault)
+ {
+ final int nHeight = getPropertySetHelper().getPropertyValueAsInteger("Height", _nDefault);
+ return nHeight;
+ }
+
+ public float getCharWeight(float _nDefault)
+ {
+ final float fCharWeight = (float) getPropertySetHelper().getPropertyValueAsDouble("CharWeight", _nDefault);
+ return fCharWeight;
+ }
+
+ public void setFontToBold()
+ {
+ setPropertyValue("CharWeight", new Float(com.sun.star.awt.FontWeight.BOLD));
+ }
+
+ public void setPropertyValue(String _sKey, Object _nValue)
+ {
+ getPropertySetHelper().setPropertyValueDontThrow(_sKey, _nValue);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java
new file mode 100644
index 000000000000..2a11fcd56f04
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/SectionTextField.java
@@ -0,0 +1,67 @@
+/*
+ * ***********************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ * **********************************************************************
+ */
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.report.XFormattedField;
+
+/**
+ *
+ * @author ll93751
+ */
+public class SectionTextField extends SectionObject
+{
+
+ protected SectionTextField(XFormattedField _aFormattedField)
+ {
+ m_aParentObject = _aFormattedField;
+ // We would like to know, what properties are in this object.
+ }
+
+ public static SectionObject create(XFormattedField _aFormattedField)
+ {
+ SectionTextField a = new SectionTextField(_aFormattedField);
+ return a;
+ }
+
+ public FontDescriptor getFontDescriptor()
+ {
+ FontDescriptor a = null;
+ try
+ {
+ XFormattedField aField = (XFormattedField) getParent();
+ a = aField.getFontDescriptor();
+ }
+ catch (com.sun.star.beans.UnknownPropertyException e)
+ {
+ }
+ return a;
+ }
+}
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java
new file mode 100644
index 000000000000..0fe168b28263
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/Tabular.java
@@ -0,0 +1,154 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.reportbuilder.layout;
+
+import com.sun.star.awt.Rectangle;
+import com.sun.star.report.XGroup;
+import com.sun.star.report.XGroups;
+import com.sun.star.report.XSection;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.report.IReportDefinitionReadAccess;
+import com.sun.star.wizards.ui.UIConsts;
+
+/**
+ *
+ * @author ll93751
+ */
+public class Tabular extends ReportBuilderLayouter
+{
+
+ public Tabular(IReportDefinitionReadAccess _xDefinitionAccess, Resource _aResource)
+ {
+ super(_xDefinitionAccess, _aResource);
+ }
+
+ public String getName()
+ {
+ return "DefaultLayoutOfData";
+ }
+
+ public String getLocalizedName()
+ {
+ String sLocalizedName = getResource().getResText(UIConsts.RID_REPORT + 80);
+ return sLocalizedName;
+ }
+
+ protected void insertDetailFields()
+ {
+ copyDetailProperties();
+
+ String[] aFieldNames = getFieldNames();
+ if (aFieldNames == null)
+ {
+ return;
+ }
+ if (aFieldNames.length == 0)
+ {
+ return;
+ }
+// int nGroups = getReportDefinition().getGroups().getCount();
+
+ final XSection xSection = getReportDefinition().getDetail();
+
+ Rectangle aRect = new Rectangle();
+ aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+
+ final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldNames.length);
+ final SectionObject aSO = getDesignTemplate().getDetailTextField();
+ int nHeight = LayoutConstants.FormattedFieldHeight;
+ for (int i = 0; i < aFieldNames.length; i++)
+ {
+ final String sFieldName = convertToFieldName(aFieldNames[i]);
+ aRect = insertFormattedField(xSection, sFieldName, aRect, nWidth, aSO);
+ nHeight = Math.max(aRect.Height, nHeight);
+ }
+ nHeight = Math.max(aSO.getHeight(nHeight), nHeight);
+ xSection.setHeight(nHeight);
+ }
+
+ protected void insertDetailFieldTitles()
+ {
+ final String[] aFieldTitleNames = getFieldTitleNames();
+ if (aFieldTitleNames == null)
+ {
+ return;
+ }
+ if (aFieldTitleNames.length == 0)
+ {
+ return;
+ }
+ final int nGroups = getReportDefinition().getGroups().getCount();
+ try
+ {
+ XSection xSection = null;
+ SectionObject aSO = null;
+ if (nGroups == 0)
+ {
+ // Spezial case, there is no Group.
+ final XGroups xGroups = getReportDefinition().getGroups();
+ final XGroup xGroup = xGroups.createGroup();
+ xGroup.setHeaderOn(true);
+
+ xGroups.insertByIndex(xGroups.getCount(), xGroup);
+ xSection = xGroup.getHeader();
+ copyGroupProperties(0);
+ aSO = getDesignTemplate().getDetailLabel();
+ aSO.setFontToBold();
+ }
+ else
+ {
+ final XGroups xGroups = getReportDefinition().getGroups();
+ // we insert the titles in the last group
+ final Object aGroup = xGroups.getByIndex(nGroups - 1);
+ final XGroup xGroup = (XGroup) UnoRuntime.queryInterface(XGroup.class, aGroup);
+ xSection = xGroup.getHeader();
+
+ // We don't need to copy the GroupProperties, because this is done in the insertGroup() member function
+ // copyGroupProperties(0);
+ aSO = getDesignTemplate().getGroupLabel(nGroups - 1);
+ }
+
+ Rectangle aRect = new Rectangle();
+// TODO: getCountOfGroups() == nGroups???
+ aRect.X = getLeftPageIndent() + getLeftGroupIndent(getCountOfGroups());
+ // TODO: group line is fix
+ aRect.Y = aSO.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight; // group height + a little empty line
+ final int nWidth = calculateFieldWidth(getLeftGroupIndent(getCountOfGroups()), aFieldTitleNames.length);
+
+ for (int i = 0; i < aFieldTitleNames.length; i++)
+ {
+ aRect = insertLabel(xSection, aFieldTitleNames[i], aRect, nWidth, aSO);
+ }
+ xSection.setHeight(aSO.getHeight(LayoutConstants.LabelHeight) + LayoutConstants.LineHeight + aSO.getHeight(LayoutConstants.LabelHeight));
+ }
+ catch (com.sun.star.uno.Exception e)
+ {
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk b/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk
new file mode 100644
index 000000000000..1af9e7c53862
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/layout/makefile.mk
@@ -0,0 +1,71 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = reportbuilderwizardlayouts
+PACKAGE = com$/sun$/star$/wizards$/reportbuilder$/layout
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar report.jar
+
+# CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = \
+ com$/sun$/star$/wizards$/reportbuilder$/layout \
+ com$/sun$/star$/wizards$/report
+
+# JARTARGET = $(TARGET).jar
+# JARCLASSPATH = commonwizards.jar report.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ LayoutConstants.java \
+ ReportBuilderLayouter.java \
+ Tabular.java \
+ ColumnarSingleColumn.java \
+ ColumnarTwoColumns.java \
+ ColumnarThreeColumns.java \
+ InBlocksLabelsAbove.java \
+ InBlocksLabelsLeft.java \
+ SectionObject.java \
+ SectionEmptyObject.java \
+ SectionLabel.java \
+ SectionTextField.java \
+ DesignTemplate.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
diff --git a/wizards/com/sun/star/wizards/reportbuilder/makefile.mk b/wizards/com/sun/star/wizards/reportbuilder/makefile.mk
new file mode 100644
index 000000000000..d9a1a7447fe8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/reportbuilder/makefile.mk
@@ -0,0 +1,55 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = reportbuilderwizard
+PACKAGE = com$/sun$/star$/wizards$/reportbuilder
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar report.jar
+
+# CUSTOMMANIFESTFILE= Manifest.mf
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/reportbuilder
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar report.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ ReportBuilderImplementation.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/wizards/com/sun/star/wizards/table/CGCategory.java b/wizards/com/sun/star/wizards/table/CGCategory.java
new file mode 100644
index 000000000000..ea74b33f09ad
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CGCategory.java
@@ -0,0 +1,88 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Configuration;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+// import com.sun.star.wizards.common.ConfigGroup;
+public class CGCategory
+{
+
+ public String Name;
+ public int Index;
+ private String[] Tables;
+ private final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/";
+ XMultiServiceFactory xMSF;
+ XNameAccess xNameAccessTablesNode;
+ XNameAccess xNameAccessCurBusinessNode;
+ Object oconfigView;
+
+ public CGCategory(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public void initialize(String category)
+ {
+ try
+ {
+ oconfigView = Configuration.getConfigurationRoot(xMSF, CGROOTPATH, false); //business/Tables
+ xNameAccessCurBusinessNode = Configuration.getChildNodebyName(
+ UnoRuntime.queryInterface(XNameAccess.class, oconfigView),
+ category);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getTableNames()
+ {
+ try
+ {
+ xNameAccessTablesNode = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xNameAccessCurBusinessNode.getByName("Tables"));
+ String[] sTableNames = Configuration.getNodeDisplayNames(xNameAccessTablesNode);
+ return sTableNames;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/CGTable.java b/wizards/com/sun/star/wizards/table/CGTable.java
new file mode 100644
index 000000000000..a1878bdeb02f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CGTable.java
@@ -0,0 +1,95 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+
+public class CGTable
+{
+
+ XMultiServiceFactory xMSF;
+ XNameAccess xNameAccessFieldsNode;
+ XNameAccess xNameAccessTableNode;
+ public String Index;
+ public String Name;
+ private Object oconfigView;
+ private final String CGROOTPATH = "/org.openoffice.Office.TableWizard/TableWizard/";
+
+ public CGTable(XMultiServiceFactory _xMSF)
+ {
+ xMSF = _xMSF;
+ }
+
+ public void initialize(XNameAccess _xNameAccessParentNode, int _index)
+ {
+ try
+ {
+ xNameAccessTableNode = Configuration.getChildNodebyIndex(_xNameAccessParentNode, _index);
+ xNameAccessFieldsNode = Configuration.getChildNodebyName(xNameAccessTableNode, "Fields");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public String[] getFieldNames(boolean _bgetbyShortName, int _imaxcolumnchars)
+ {
+ try
+ {
+ String[] fieldnames = null;
+ if (_bgetbyShortName)
+ {
+ fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, "ShortName");
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ if (fieldnames[i].length() > _imaxcolumnchars)
+ {
+ fieldnames[i] = fieldnames[i].substring(0, _imaxcolumnchars);
+ }
+ }
+ }
+ else
+ {
+ fieldnames = Configuration.getNodeChildNames(xNameAccessFieldsNode, "Name");
+ }
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ fieldnames[i] = Desktop.removeSpecialCharacters(xMSF, Configuration.getOfficeLocale(xMSF), fieldnames[i]);
+ }
+ return fieldnames;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/CallTableWizard.java b/wizards/com/sun/star/wizards/table/CallTableWizard.java
new file mode 100644
index 000000000000..af685eadf343
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/CallTableWizard.java
@@ -0,0 +1,213 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.uno.Type;
+import com.sun.star.wizards.common.Properties;
+
+/** This class capsulates the class, that implements the minimal component, a
+ * factory for creating the service (<CODE>__getServiceFactory</CODE>).
+ * @author Bertram Nolte
+ */
+public class CallTableWizard
+{
+
+ /** 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 xmultiservicefactory The service manager, who gives access to every
+ * known service.
+ * @param xregistrykey Makes structural information (except regarding tree
+ * structures) 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(TableWizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = com.sun.star.comp.loader.FactoryHelper.getServiceFactory(TableWizardImplementation.class, TableWizardImplementation.__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 TableWizardImplementation extends com.sun.star.lib.uno.helper.PropertySet implements com.sun.star.lang.XInitialization, com.sun.star.lang.XServiceInfo, com.sun.star.lang.XTypeProvider, com.sun.star.task.XJobExecutor
+ {
+
+ private PropertyValue[] m_wizardContext;
+ // <properties>
+ public String Command;
+ public final Integer CommandType = com.sun.star.sdb.CommandType.TABLE;
+ // </properties>
+
+ /** The constructor of the inner class has a XMultiServiceFactory parameter.
+ * @param i_serviceFactory
+ */
+ public TableWizardImplementation(com.sun.star.lang.XMultiServiceFactory i_serviceFactory)
+ {
+ super();
+ m_serviceFactory = i_serviceFactory;
+ registerProperty( "Command", (short)( PropertyAttribute.READONLY | PropertyAttribute.MAYBEVOID ) );
+ registerProperty( "CommandType", PropertyAttribute.READONLY );
+ }
+
+ public void trigger( String sEvent )
+ {
+ try
+ {
+ if ( sEvent.compareTo("start") == 0 )
+ {
+ TableWizard CurTableWizard = new TableWizard( m_serviceFactory, m_wizardContext );
+ Command = CurTableWizard.startTableWizard();
+ }
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+ 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.table.CallTableWizard";
+ /** The service manager, that gives access to all registered services.
+ */
+ private com.sun.star.lang.XMultiServiceFactory m_serviceFactory;
+
+ /** 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 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
+ {
+ 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[1];
+
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /** This method returns an array of bytes, that can be used to
+ * unambiguously distinguish between two sets of types, e.g.
+ * to realise hashing functionality when the object is introspected.
+ * Two objects that return the same ID also have to return
+ * the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to
+ * return an empty sequence. Important: If the object
+ * aggregates other objects the ID has to be unique for the
+ * whole combination of objects.
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = new String("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /** Return the class name of the component.
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (TableWizardImplementation.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.
+ */
+ 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 exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/FieldDescription.java b/wizards/com/sun/star/wizards/table/FieldDescription.java
new file mode 100644
index 000000000000..d26e58783aba
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/FieldDescription.java
@@ -0,0 +1,176 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import java.util.Vector;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Properties;
+
+public class FieldDescription
+{
+ private String tablename = "";
+// String fieldname;
+ private String keyname;
+ private XNameAccess xNameAccessTableNode;
+ private XPropertySet xPropertySet;
+ private Vector aPropertyValues;
+// PropertyValue[] aPropertyValues;
+ private Integer Type;
+ private Integer Scale;
+ private Integer Precision;
+ private Boolean DefaultValue;
+ private String Name;
+ private XMultiServiceFactory xMSF;
+ private Locale aLocale;
+
+ public FieldDescription(XMultiServiceFactory _xMSF, Locale _aLocale, ScenarioSelector _curscenarioselector, String _fieldname, String _keyname, int _nmaxcharCount)
+ {
+ xMSF = _xMSF;
+ aLocale = _aLocale;
+ tablename = _curscenarioselector.getTableName();
+ Name = _fieldname;
+ keyname = _keyname;
+ aPropertyValues = new Vector();
+ xNameAccessTableNode = _curscenarioselector.oCGTable.xNameAccessFieldsNode;
+ XNameAccess xNameAccessFieldNode;
+ if (_curscenarioselector.bcolumnnameislimited)
+ {
+ xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(xMSF, aLocale, xNameAccessTableNode, keyname, "ShortName", _nmaxcharCount);
+ }
+ else
+ {
+ xNameAccessFieldNode = Configuration.getChildNodebyDisplayName(xMSF, aLocale, xNameAccessTableNode, keyname, "Name", _nmaxcharCount);
+ }
+ setFieldProperties(xNameAccessFieldNode);
+ }
+
+ public FieldDescription(String _fieldname)
+ {
+ Name = _fieldname;
+ aPropertyValues = new Vector();
+ Type = new Integer(com.sun.star.sdbc.DataType.VARCHAR);
+ aPropertyValues.addElement(Properties.createProperty("Name", _fieldname));
+ aPropertyValues.addElement(Properties.createProperty("Type", Type));
+ }
+
+ public void setName(String _newfieldname)
+ {
+ for (int i = 0; i < aPropertyValues.size(); i++)
+ {
+ PropertyValue aPropertyValue = (PropertyValue) aPropertyValues.get(i);
+ if (aPropertyValue.Name.equals("Name"))
+ {
+ aPropertyValue.Value = _newfieldname;
+ aPropertyValues.set(i, aPropertyValue);
+ Name = _newfieldname;
+ return;
+ }
+ }
+ }
+
+ public String getName()
+ {
+ return Name;
+ }
+
+ public String gettablename()
+ {
+ return tablename;
+ }
+
+ private boolean propertyexists(String _propertyname)
+ {
+ boolean bexists = false;
+ try
+ {
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName(_propertyname))
+ {
+ Object oValue = xPropertySet.getPropertyValue(_propertyname);
+ bexists = (!com.sun.star.uno.AnyConverter.isVoid(oValue));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return bexists;
+ }
+
+ public void setFieldProperties(XNameAccess _xNameAccessFieldNode)
+ {
+ try
+ {
+ xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, _xNameAccessFieldNode);
+// Integer Index = (Integer) xPropertySet.getPropertyValue("Index");
+ if (propertyexists("Name"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Name", Name));
+ }
+ if (propertyexists("Type"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Type", (Integer) xPropertySet.getPropertyValue("Type")));
+ }
+ if (propertyexists("Scale"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Scale", (Integer) xPropertySet.getPropertyValue("Scale")));
+// Scale =
+ }
+ if (propertyexists("Precision"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("Precision", (Integer) xPropertySet.getPropertyValue("Precision")));
+// Precision = (Integer) xPropertySet.getPropertyValue("Precision");
+ }
+ if (propertyexists("DefaultValue"))
+ {
+ aPropertyValues.addElement(Properties.createProperty("DefaultValue", (Boolean) xPropertySet.getPropertyValue("DefaultValue")));// DefaultValue = (Boolean) xPropertySet.getPropertyValue("DefaultValue");
+ //Type = new Integer(4); // TODO wo ist der Fehler?(Integer) xPropertySet.getPropertyValue("Type");
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public PropertyValue[] getPropertyValues()
+ {
+ if (aPropertyValues != null)
+ {
+ PropertyValue[] aProperties = new PropertyValue[aPropertyValues.size()];
+ aPropertyValues.toArray(aProperties);
+ return aProperties;
+ }
+ return null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/FieldFormatter.java b/wizards/com/sun/star/wizards/table/FieldFormatter.java
new file mode 100644
index 000000000000..1c79b36cba58
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/FieldFormatter.java
@@ -0,0 +1,433 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+
+public class FieldFormatter implements XItemListener
+{
+
+ TableWizard CurUnoDialog;
+ TableDescriptor curTableDescriptor;
+ Object oColumnDescriptorModel;
+ XTextComponent txtfieldname;
+ XListBox xlstFieldNames;
+ XButton btnplus;
+ XButton btnminus;
+ XButton btnShiftUp;
+ XButton btnShiftDown;
+ short curtabindex;
+ String TOGGLEBUTTONS = "toggleButtons";
+ String ADDFIELDNAME = "addFieldName";
+ String REMOVEFIELDNAME = "removeFieldName";
+ String MODIFYFIELDNAME = "modifyFieldName";
+ String[] fieldnames;
+ String suntitled;
+ Integer IFieldFormatStep;
+
+ public FieldFormatter(TableWizard _CurUnoDialog, TableDescriptor _curTableDescriptor)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curtabindex = (short) (TableWizard.SOFIELDSFORMATPAGE * 100);
+ IFieldFormatStep = new Integer(TableWizard.SOFIELDSFORMATPAGE);
+ String sFieldName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 23);
+ String sFieldNames = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 25);
+ String sfieldinfo = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 20);
+ String sbtnplushelptext = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 45);
+ String sbtnminushelptext = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 46);
+
+ suntitled = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 43);
+
+ CurUnoDialog.insertLabel("lblFieldNames",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], sFieldNames, new Integer(91), new Integer(27), IFieldFormatStep, new Short(curtabindex++), new Integer(90)
+ });
+
+ try
+ {
+ xlstFieldNames = CurUnoDialog.insertListBox("lstfieldnames", 3, null, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(133), "HID:WIZARDS_HID_DLGTABLE_LB_SELFIELDNAMES", new Integer(92), new Integer(37), IFieldFormatStep, new Short(curtabindex++), new Integer(62)
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+
+ FontDescriptor oFontDesc = new FontDescriptor();
+ oFontDesc.Name = "StarSymbol";
+
+ btnShiftUp = CurUnoDialog.insertButton("btnShiftUp", "shiftFieldNameUp", this,
+ new String[]
+ {
+ "Enabled", "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, oFontDesc, new Integer(14), "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDUP", String.valueOf((char) 8743), new Integer(158), new Integer(139), IFieldFormatStep, new Short(curtabindex++), new Integer(14)
+ });
+
+ btnShiftDown = CurUnoDialog.insertButton("btnShiftDown", "shiftFieldNameDown", this,
+ new String[]
+ {
+ "Enabled", "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, oFontDesc, new Integer(14), "HID:WIZARDS_HID_DLGTABLE_CMDMOVEFIELDDOWN", String.valueOf((char) 8744), new Integer(158), new Integer(156), IFieldFormatStep, new Short(curtabindex++), new Integer(14)
+ });
+ oFontDesc = new FontDescriptor();
+ oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD;
+ oFontDesc.Height = (short) 13;
+ btnminus = CurUnoDialog.insertButton("btnminus", "removeFieldName", this,
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ oFontDesc, new Integer(14), "HID:WIZARDS_HID_DLGTABLE_CMDMINUS", "-", new Integer(118), new Integer(175), IFieldFormatStep, new Short(curtabindex++), new Integer(14)
+ });
+
+ btnplus = CurUnoDialog.insertButton("btnplus", "addFieldName", this,
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ oFontDesc, new Integer(14), "HID:WIZARDS_HID_DLGTABLE_CMDPLUS", "+", new Integer(137), new Integer(175), IFieldFormatStep, new Short(curtabindex++), new Integer(14)
+ });
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "ColDescriptorHeader",
+ new String[]
+ {
+ "Height", "Label", "Orientation", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sfieldinfo, new Integer(0), new Integer(158), new Integer(27), IFieldFormatStep, new Short(curtabindex++), new Integer(165)
+ });
+
+
+ CurUnoDialog.insertLabel("lblFieldName",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], sFieldName, new Integer(158), new Integer(39), IFieldFormatStep, new Short(curtabindex++), new Integer(94)
+ });
+
+ txtfieldname = CurUnoDialog.insertTextField("txtfieldname", MODIFYFIELDNAME, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_COLNAME", new Integer(274), new Integer(37), IFieldFormatStep, new Short(curtabindex++), "", new Integer(50)
+ });
+ txtfieldname.addTextListener(CurUnoDialog);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnplus, sbtnplushelptext);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnminus, sbtnminushelptext);
+ }
+
+ public void initialize(TableDescriptor _curTableDescriptor, String[] _fieldnames)
+ {
+ if (oColumnDescriptorModel == null)
+ {
+ oColumnDescriptorModel = CurUnoDialog.insertControlModel("com.sun.star.sdb.ColumnDescriptorControlModel", "oColumnDescriptor",
+ new String[]
+ {
+ "Height", "PositionX", "PositionY", "Step", "TabIndex", "Width", "EditWidth"
+ }, // "HelpURL"
+ new Object[]
+ {
+ new Integer(85), new Integer(158), new Integer(49), IFieldFormatStep, new Short(curtabindex++), new Integer(166), new Integer(50)
+ }); //, "HID:WIZARDS_HID_DLGTABLE_COLMODIFIER"
+ curTableDescriptor = _curTableDescriptor;
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, "ActiveConnection", _curTableDescriptor.DBConnection);
+ txtfieldname.setMaxTextLen((short) this.curTableDescriptor.getMaxColumnNameLength());
+ }
+ else
+ {
+ int nStep = ((Integer) Helper.getUnoPropertyValue(oColumnDescriptorModel, "Step")).intValue();
+ if (nStep > IFieldFormatStep.intValue())
+ {
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, "Step", IFieldFormatStep);
+ CurUnoDialog.repaintDialogStep();
+ }
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", _fieldnames);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ 0
+ });
+ updateColumnDescriptor(_fieldnames[0], curTableDescriptor.getByName(_fieldnames[0]));
+ toggleButtons();
+ CurUnoDialog.setFocus("lstfieldnames");
+ }
+
+ public void toggleButtons()
+ {
+ boolean benableShiftUpButton = false;
+ boolean benableShiftDownButton = false;
+ boolean bfieldnameisselected = Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems") != null;
+ int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames);
+ boolean blistispopulated = (ilistcount > 0);
+ if (bfieldnameisselected)
+ {
+ int iselpos = xlstFieldNames.getSelectedItemPos();
+ benableShiftUpButton = (iselpos != 0);
+ benableShiftDownButton = (iselpos != ilistcount - 1);
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftUp), "Enabled", new Boolean(benableShiftUpButton));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnShiftDown), "Enabled", new Boolean(benableShiftDownButton));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), "Enabled", new Boolean(blistispopulated));
+ CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, blistispopulated);
+ }
+
+ public void addFieldName()
+ {
+ String snewfieldname = Desktop.getUniqueName(xlstFieldNames.getItems(), suntitled, "");
+ short icount = xlstFieldNames.getItemCount();
+ if (CurUnoDialog.verifyfieldcount(icount))
+ {
+ xlstFieldNames.addItem(snewfieldname, icount);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ icount
+ });
+ toggleButtons();
+ FieldDescription curfielddescription = new FieldDescription(snewfieldname);
+ CurUnoDialog.fielditems.put(snewfieldname, curfielddescription);
+ curTableDescriptor.addColumn(curfielddescription.getPropertyValues());
+ updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname));
+ CurUnoDialog.setControlVisible("oColumnDescriptor", true);
+ CurUnoDialog.repaintDialogStep();
+ }
+ }
+
+ public void removeFieldName()
+ {
+ String[] fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ short ipos = UnoDialog.getSelectedItemPos(xlstFieldNames);
+ String fieldname = fieldnames[ipos];
+ xlstFieldNames.removeItems(ipos, (short) 1);
+ CurUnoDialog.fielditems.remove(fieldname);
+ int ilistcount = /* xlstFieldNames.getItemCount();*/ UnoDialog.getListBoxItemCount(xlstFieldNames);
+ if ((ipos) < ilistcount)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ else
+ {
+ if (ilistcount > -1)
+ {
+ ipos = (short) ((short) ilistcount - (short) 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ }
+ curTableDescriptor.dropColumnbyName(fieldname);
+ fieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ boolean benable = ((ipos > -1) && (ipos < fieldnames.length));
+ if (benable)
+ {
+ String snewfieldname = fieldnames[ipos];
+ updateColumnDescriptor(snewfieldname, curTableDescriptor.getByName(snewfieldname));
+ toggleButtons();
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(txtfieldname), "Text", "");
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), "Enabled", new Boolean(benable));
+ CurUnoDialog.setcompleted(TableWizard.SOFIELDSFORMATPAGE, benable);
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(btnminus), "Enabled", new Boolean(benable));
+ CurUnoDialog.setControlVisible("oColumnDescriptor", benable);
+ CurUnoDialog.repaintDialogStep();
+ }
+
+ public void modifyFieldName()
+ {
+ String newfieldname = txtfieldname.getText();
+ String oldfieldname = xlstFieldNames.getSelectedItem();
+ if (!newfieldname.equals(oldfieldname))
+ {
+ if (curTableDescriptor.modifyColumnName(oldfieldname, newfieldname))
+ {
+ Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column");
+ Helper.setUnoPropertyValue(oColumn, "Name", newfieldname);
+ FieldDescription curfielddescription = (FieldDescription) CurUnoDialog.fielditems.get(oldfieldname);
+ CurUnoDialog.fielditems.remove(oldfieldname);
+ curfielddescription.setName(newfieldname);
+ CurUnoDialog.fielditems.put(newfieldname, curfielddescription);
+ String[] fieldnames = xlstFieldNames.getItems();
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ fieldnames[ipos] = newfieldname;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", fieldnames);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ ipos
+ });
+ }
+ }
+ }
+
+ public void shiftFieldNameUp()
+ {
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, -1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", snewlist);
+ if ((ipos - 1) > -1)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ (short) (ipos - 1)
+ });
+ curTableDescriptor.moveColumn(ipos, ipos - 1);
+ }
+ toggleButtons();
+ }
+
+ public void shiftFieldNameDown()
+ {
+ short ipos = xlstFieldNames.getSelectedItemPos();
+ String[] snewlist = shiftArrayItem(xlstFieldNames.getItems(), ipos, 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList", snewlist);
+ if ((ipos + 1) < xlstFieldNames.getItemCount())
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "SelectedItems", new short[]
+ {
+ (short) (ipos + 1)
+ });
+ curTableDescriptor.moveColumn(ipos, ipos + 1);
+ }
+ toggleButtons();
+ }
+
+ public String[] shiftArrayItem(String[] _slist, int _oldindex, int _shiftcount)
+ {
+ int newindex = _oldindex + _shiftcount;
+ if ((newindex >= 0) && (newindex < _slist.length))
+ {
+ String buffer = _slist[newindex];
+ _slist[newindex] = _slist[_oldindex];
+ _slist[_oldindex] = buffer;
+ }
+ return _slist;
+ }
+
+ public boolean updateColumnofColumnDescriptor()
+ {
+ Object oColumn = Helper.getUnoPropertyValue(oColumnDescriptorModel, "Column");
+ XPropertySet xColPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oColumn);
+ if (xColPropertySet != null)
+ {
+ curTableDescriptor.modifyColumn(txtfieldname.getText(), xColPropertySet);
+ return true;
+ }
+ return false;
+ }
+
+ private void updateColumnDescriptor(String _ColumnName, XPropertySet _xColumn)
+ {
+ updateColumnofColumnDescriptor();
+ XPropertySet xNewPropertySet = curTableDescriptor.clonePropertySet(_ColumnName, _xColumn);
+ if (xNewPropertySet != null)
+ {
+ Helper.setUnoPropertyValue(oColumnDescriptorModel, "Column", xNewPropertySet);
+ }
+ txtfieldname.setText(_ColumnName);
+ }
+
+ public XPropertySet clonePropertySet(XPropertySet _xPropertySet)
+ {
+ XPropertySet xlocpropertyset = null;
+ return xlocpropertyset;
+ }
+
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ String fieldname = xlstFieldNames.getSelectedItem();
+ XPropertySet xColumn = curTableDescriptor.getByName(fieldname);
+ updateColumnDescriptor(fieldname, xColumn);
+ toggleButtons();
+ }
+
+ public boolean iscompleted()
+ {
+ String[] sfieldnames = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ return sfieldnames.length > 0;
+ }
+
+ public String[] getFieldNames()
+ {
+ return (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xlstFieldNames), "StringItemList");
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/Finalizer.java b/wizards/com/sun/star/wizards/table/Finalizer.java
new file mode 100644
index 000000000000..17db2aea61a3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/Finalizer.java
@@ -0,0 +1,364 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.*;
+
+public class Finalizer
+{
+
+ TableWizard CurUnoDialog;
+ short curtabindex;
+ XRadioButton optModifyTable;
+ XRadioButton optWorkWithTable;
+ XRadioButton optStartFormWizard;
+ XTextComponent txtTableName;
+ XListBox xCatalogListBox;
+ XListBox xSchemaListBox;
+ TableDescriptor curtabledescriptor;
+ public String SETCOMPLETIONFLAG = "setCompletionFlag";
+ public static int WORKWITHTABLEMODE = 0;
+ public static int MODIFYTABLEMODE = 1;
+ public static int STARTFORMWIZARDMODE = 2;
+
+ public Finalizer(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor)
+ {
+ try
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ this.curtabledescriptor = _curtabledescriptor;
+ curtabindex = (short) (TableWizard.SOFINALPAGE * 100);
+ Integer IFINALSTEP = new Integer(TableWizard.SOFINALPAGE);
+ String slblTableName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 34);
+ String slblProceed = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 36);
+ String sWorkWithTable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 38);
+ String sStartFormWizard = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 39);
+ String sModifyTable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 37);
+ String sCongratulations = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 35);
+ String slblCatalog = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 49);
+ String slblSchema = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 50);
+ String[] sCatalogNames = curtabledescriptor.getCatalogNames();
+ String[] sSchemaNames = curtabledescriptor.getSchemaNames();
+ int nListBoxPosX = 97;
+ int ndiffPosY = 0;
+ boolean bsupportsSchemata = false;
+ boolean bsupportsCatalogs = false;
+
+ CurUnoDialog.insertLabel("lblTableName",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], slblTableName, new Integer(97), new Integer(25), IFINALSTEP, new Integer(220)
+ });
+ txtTableName = CurUnoDialog.insertTextField("txtTableName", SETCOMPLETIONFLAG, this,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGER_12, "HID:WIZARDS_HID_DLGTABLE_TXT_NAME", new Integer(97), new Integer(35), IFINALSTEP, new Short(curtabindex++), "", new Integer(223)
+ });
+ txtTableName.addTextListener(CurUnoDialog);
+ txtTableName.setMaxTextLen((short) this.curtabledescriptor.getMaxTableNameLength());
+ if (this.curtabledescriptor.xDBMetaData.supportsCatalogsInTableDefinitions())
+ {
+ if (sCatalogNames != null)
+ {
+ if (sCatalogNames.length > 0)
+ {
+ bsupportsCatalogs = true;
+ String sCatalog = "";
+ try
+ {
+ sCatalog = curtabledescriptor.DBConnection.getCatalog();
+ }
+ catch (SQLException e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ CurUnoDialog.insertLabel("lblCatalog",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblCatalog, new Integer(nListBoxPosX), new Integer(52), IFINALSTEP, new Short(curtabindex++), new Integer(120)
+ });
+
+ try
+ {
+ xCatalogListBox = CurUnoDialog.insertListBox("lstCatalog", null, null,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "PositionX", "PositionY", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(12), "HID:WIZARDS_HID_DLGTABLE_LST_CATALOG", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sCatalogNames, new Short(curtabindex++), new Integer(80)
+ });
+ int isel = JavaTools.FieldInList(sCatalogNames, sCatalog);
+ if (isel < 0)
+ {
+ isel = 0;
+ }
+ CurUnoDialog.setControlProperty("lstCatalog", "SelectedItems", new short[]
+ {
+ (short) isel
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ nListBoxPosX = 200;
+ }
+ }
+ }
+ if (this.curtabledescriptor.xDBMetaData.supportsSchemasInTableDefinitions())
+ {
+ if (sSchemaNames != null)
+ {
+ if (sSchemaNames.length > 0)
+ {
+ bsupportsSchemata = true;
+ String sSchema = "";
+ try
+ {
+ sSchema = (String) curtabledescriptor.getDataSourcePropertySet().getPropertyValue("User");
+ }
+ catch (Exception e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ CurUnoDialog.insertLabel("lblSchema",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblSchema, new Integer(nListBoxPosX), new Integer(52), IFINALSTEP, new Short(curtabindex++), new Integer(80)
+ });
+
+ try
+ {
+ xSchemaListBox = CurUnoDialog.insertListBox("lstSchema", null, null,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "PositionX", "PositionY", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(12), "HID:WIZARDS_HID_DLGTABLE_LST_SCHEMA", new Short(UnoDialog.getListBoxLineCount()), new Integer(nListBoxPosX), new Integer(62), IFINALSTEP, sSchemaNames, new Short(curtabindex++), new Integer(80)
+ });
+ int isel = JavaTools.FieldInList(sSchemaNames, sSchema);
+ if (isel < 0)
+ {
+ isel = 0;
+ }
+ CurUnoDialog.setControlProperty("lstSchema", "SelectedItems", new short[]
+ {
+ (short) isel
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+ }
+ if ((!bsupportsCatalogs) && (!bsupportsSchemata))
+ {
+ CurUnoDialog.insertLabel("lblcongratulations",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(16), sCongratulations, Boolean.TRUE, new Integer(97), new Integer(62), IFINALSTEP, new Short(curtabindex++), new Integer(226)
+ });
+ }
+ else
+ {
+ ndiffPosY = 10;
+ }
+ CurUnoDialog.insertLabel("lblProceed",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], slblProceed, new Integer(97), new Integer(82 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), new Integer(227)
+ });
+ optWorkWithTable = CurUnoDialog.insertRadioButton("optWorkWithTable", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_WORKWITHTABLE", sWorkWithTable, new Integer(101), new Integer(97 + ndiffPosY), new Short((short) 1), IFINALSTEP, new Short(curtabindex++), new Integer(177)
+ });
+ optModifyTable = CurUnoDialog.insertRadioButton("optModifyTable", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_MODIFYTABLE", sModifyTable, new Integer(101), new Integer(109 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), new Integer(177)
+ });
+ optStartFormWizard = CurUnoDialog.insertRadioButton("optStartFormWizard", null,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_STARTFORMWIZARD", sStartFormWizard, new Integer(101), new Integer(121 + ndiffPosY), IFINALSTEP, new Short(curtabindex++), new Integer(177)
+ });
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void initialize(String _firsttablename)
+ {
+ setTableName(_firsttablename);
+ }
+
+ public int finish()
+ {
+ if (optWorkWithTable.getState())
+ {
+ return WORKWITHTABLEMODE;
+ }
+ else if (optModifyTable.getState())
+ {
+ return MODIFYTABLEMODE;
+ }
+ else
+ {
+ return STARTFORMWIZARDMODE;
+ }
+ }
+
+ public String getComposedTableName(String _stablename)
+ {
+ String scatalogname = null;
+ String sschemaname = null;
+ if (xCatalogListBox != null)
+ {
+ scatalogname = xCatalogListBox.getSelectedItem();
+ }
+ if (xSchemaListBox != null)
+ {
+ sschemaname = xSchemaListBox.getSelectedItem();
+ }
+ return curtabledescriptor.getComposedTableName(scatalogname, sschemaname, _stablename);
+ }
+
+ public void setTableName(String _tablename)
+ {
+ if (txtTableName.getText().equals(""))
+ {
+ String ssuffix = Desktop.getIncrementSuffix(curtabledescriptor.getTableNamesAsNameAccess(), getComposedTableName(_tablename));
+ txtTableName.setText(_tablename + ssuffix);
+ setCompletionFlag();
+ }
+ }
+
+ public String getTableName()
+ {
+ return txtTableName.getText();
+ }
+
+ public String getTableName(String _firsttablename)
+ {
+ if (txtTableName.getText().equals(""))
+ {
+ setTableName(_firsttablename);
+ }
+ return txtTableName.getText();
+ }
+
+ public String getSchemaName()
+ {
+ if (xSchemaListBox != null)
+ {
+ return this.xSchemaListBox.getSelectedItem();
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public String getCatalogName()
+ {
+ if (xCatalogListBox != null)
+ {
+ return this.xCatalogListBox.getSelectedItem();
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ public boolean iscompleted()
+ {
+ return (txtTableName.getText().length() > 0);
+ }
+
+ public void setCompletionFlag()
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOFINALPAGE, iscompleted());
+ }
+
+ public void setFocusToTableNameControl()
+ {
+ CurUnoDialog.setFocus("txtTableName");
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/MANIFEST.MF b/wizards/com/sun/star/wizards/table/MANIFEST.MF
new file mode 100644
index 000000000000..0fcfe1d3e8f1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.table.CallTableWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java
new file mode 100644
index 000000000000..2a59ece3e5f1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/PrimaryKeyHandler.java
@@ -0,0 +1,460 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.db.TypeInspector;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.XFieldSelectionListener;
+
+public class PrimaryKeyHandler implements XFieldSelectionListener
+{
+
+ private TableWizard CurUnoDialog;
+ private short curtabindex;
+ private final static String SPRIMEKEYMODE = "togglePrimeKeyFields";
+ private final static String SSINGLEKEYMODE = "toggleSinglePrimeKeyFields";
+ private final static String SSEVERALKEYMODE = "toggleSeveralPrimeKeyFields";
+ private XRadioButton optAddAutomatically;
+ private XRadioButton optUseExisting;
+ private XRadioButton optUseSeveral;
+ private XCheckBox chkUsePrimaryKey;
+ private XCheckBox chkcreatePrimaryKey;
+ private XCheckBox chkApplyAutoValueExisting;
+ private XCheckBox chkApplyAutoValueAutomatic;
+ private XListBox lstSinglePrimeKey;
+ private XFixedText lblPrimeFieldName;
+ private FieldSelection curPrimaryKeySelection;
+ private String[] fieldnames;
+ private TableDescriptor curTableDescriptor;
+ private int nAutoPrimeKeyDataType;
+ private boolean bAutoPrimaryKeysupportsAutoIncrmentation;
+ private final static String SAUTOMATICKEYFIELDNAME = "ID";
+
+ public PrimaryKeyHandler(TableWizard _CurUnoDialog, TableDescriptor _curTableDescriptor)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ curTableDescriptor = _curTableDescriptor;
+ bAutoPrimaryKeysupportsAutoIncrmentation = isAutoPrimeKeyAutoIncrementationsupported();
+ curtabindex = (short) ((TableWizard.SOPRIMARYKEYPAGE * 100) - 20);
+ Integer IPRIMEKEYSTEP = new Integer(TableWizard.SOPRIMARYKEYPAGE);
+ final String sExplanations = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 26);
+ final String screatePrimaryKey = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 27);
+ final String slblPrimeFieldName = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 31);
+ final String sApplyAutoValue = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 33);
+ final String sAddAutomatically = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 28);
+ final String sUseExisting = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 29);
+ final String sUseSeveral = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 30);
+ final String slblAvailableFields = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 4);
+ final String slblSelPrimaryFields = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 32);
+ CurUnoDialog.insertLabel("lblExplanation",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(40), sExplanations, Boolean.TRUE, new Integer(91), new Integer(27), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(233)
+ });
+
+ chkcreatePrimaryKey = CurUnoDialog.insertCheckBox("chkcreatePrimaryKey", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CHK_USEPRIMEKEY", screatePrimaryKey, new Integer(97), new Integer(70), new Short((short) 1), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(160)
+ });
+
+ optAddAutomatically = CurUnoDialog.insertRadioButton("optAddAutomatically", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_AUTOMATIC", sAddAutomatically, new Integer(106), new Integer(82), new Short((short) 1), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(200)
+ });
+
+ optUseExisting = CurUnoDialog.insertRadioButton("optUseExisting", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, //94
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SINGLE", sUseExisting, new Integer(106), new Integer(104), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(200)
+ });
+
+ optUseSeveral = CurUnoDialog.insertRadioButton("optUseSeveral", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPT_PK_SEVERAL", sUseSeveral, new Integer(106), new Integer(132), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(200)
+ });
+
+ chkApplyAutoValueAutomatic = CurUnoDialog.insertCheckBox("chkApplyAutoValueAutomatic", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, //107
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE_AUTOMATIC", sApplyAutoValue, new Integer(116), new Integer(92), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(68)
+ });
+
+ lblPrimeFieldName = CurUnoDialog.insertLabel("lblPrimeFieldName",
+ new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, UIConsts.INTEGERS[8], slblPrimeFieldName, new Integer(116), new Integer(117), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(46)
+ });
+
+ lstSinglePrimeKey = CurUnoDialog.insertListBox("lstSinglePrimeKey", "onPrimeKeySelected", null, this,
+ new String[]
+ {
+ "Dropdown",
+ "Enabled",
+ "Height",
+ "HelpURL",
+ "LineCount",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE,
+ Boolean.FALSE,
+ new Integer(12),
+ "HID:WIZARDS_HID_DLGTABLE_LB_PK_FIELDNAME",
+ Short.valueOf(UnoDialog.getListBoxLineCount()),
+ new Integer(162),
+ new Integer(115),
+ IPRIMEKEYSTEP,
+ new Short(curtabindex++),
+ new Integer(80)
+ });
+
+ chkApplyAutoValueExisting = CurUnoDialog.insertCheckBox("chkApplyAutoValueExisting", SPRIMEKEYMODE, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, //107
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_CK_PK_AUTOVALUE", sApplyAutoValue, new Integer(248), new Integer(117), IPRIMEKEYSTEP, new Short(curtabindex++), new Integer(66)
+ });
+ curPrimaryKeySelection = new FieldSelection(CurUnoDialog, IPRIMEKEYSTEP.intValue(), 116, 142, 208, 47, slblAvailableFields, slblSelPrimaryFields, 41234, false);
+ curPrimaryKeySelection.addFieldSelectionListener(this);
+
+ }
+
+ public void initialize()
+ {
+ // boolean breselect;
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames();
+ curPrimaryKeySelection.initialize(fieldnames, false);
+ if (skeyfieldnames != null)
+ {
+ if (skeyfieldnames.length > 0)
+ {
+ String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames);
+ curPrimaryKeySelection.setSelectedFieldNames(snewkeyfieldnames);
+ }
+ }
+ String selfield = lstSinglePrimeKey.getSelectedItem();
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), "StringItemList", fieldnames);
+ if (selfield != null)
+ {
+ if (JavaTools.FieldInList(fieldnames, selfield) > -1)
+ {
+ lstSinglePrimeKey.selectItem(selfield, true);
+ }
+ }
+ togglePrimeKeyFields();
+ }
+
+ private boolean isAutoPrimeKeyAutoIncrementationsupported()
+ {
+ TypeInspector.TypeInfo aAutoPrimeTypeInfo;
+ aAutoPrimeTypeInfo = curTableDescriptor.oTypeInspector.findAutomaticPrimaryKeyType();
+ return aAutoPrimeTypeInfo.bisAutoIncrementable;
+ }
+
+ public boolean iscompleted()
+ {
+ if (chkcreatePrimaryKey.getState() == 0)
+ {
+ return true;
+ }
+ if (this.optAddAutomatically.getState())
+ {
+ return true;
+ }
+ if (optUseExisting.getState())
+ {
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String selfield = lstSinglePrimeKey.getSelectedItem();
+ if (selfield != null)
+ {
+ return (JavaTools.FieldInList(fieldnames, selfield) > -1);
+ }
+ }
+ if (optUseSeveral.getState())
+ {
+ fieldnames = curTableDescriptor.getNonBinaryFieldNames();
+ String[] skeyfieldnames = curPrimaryKeySelection.getSelectedFieldNames();
+ String[] snewkeyfieldnames = JavaTools.removeOutdatedFields(skeyfieldnames, fieldnames);
+ return (snewkeyfieldnames.length > 0);
+ }
+ return false;
+ }
+
+ public void togglePrimeKeyFields()
+ {
+ boolean bdoEnable = (this.chkcreatePrimaryKey.getState() == 1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), "Enabled", new Boolean(bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), "Enabled", new Boolean(bAutoPrimaryKeysupportsAutoIncrmentation && bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optUseExisting), "Enabled", new Boolean(bdoEnable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(optUseSeveral), "Enabled", new Boolean(bdoEnable));
+ //toggle subcontrols of the radiobuttons...
+ toggleAutomaticAutoValueCheckBox();
+ boolean benableSinglePrimekeyControls = bdoEnable && optUseExisting.getState();
+ toggleSinglePrimeKeyFields(benableSinglePrimekeyControls);
+ boolean benableSeveralPrimekeyControls = bdoEnable && optUseSeveral.getState();
+ curPrimaryKeySelection.toggleListboxControls(new Boolean(benableSeveralPrimekeyControls));
+ // toggle the following steps of the dialog...
+ if (!bdoEnable)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true);
+ }
+ else
+ {
+ if (benableSeveralPrimekeyControls)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+ else if (benableSinglePrimekeyControls)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, UnoDialog.isListBoxSelected(lstSinglePrimeKey)); //.getSelectedItemPos() != -1);
+ }
+ else if (optAddAutomatically.getState())
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, true);
+ }
+ }
+ }
+
+ private boolean isAutoIncrementatable(String _fieldname)
+ {
+ boolean bisAutoIncrementable = false;
+ try
+ {
+ XPropertySet xColPropertySet = curTableDescriptor.getByName(_fieldname);
+ if (xColPropertySet != null)
+ {
+ if (curTableDescriptor.getDBDataTypeInspector() != null)
+ {
+ return curTableDescriptor.getDBDataTypeInspector().isAutoIncrementable(xColPropertySet);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ public boolean isAutomaticMode()
+ {
+ boolean bisAutomaticMode = false;
+ if (chkcreatePrimaryKey.getState() == 1)
+ {
+ bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), "State")).shortValue() == (short) 1;
+ }
+ return bisAutomaticMode;
+ }
+
+ public String getAutomaticFieldName()
+ {
+ return SAUTOMATICKEYFIELDNAME;
+ }
+
+ public boolean isAutoIncremented()
+ {
+ boolean bischecked = false;
+ if (chkcreatePrimaryKey.getState() == 1)
+ {
+ boolean bisAutomaticMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), "State")).shortValue() == (short) 1;
+ boolean bisExistingMode = ((Short) Helper.getUnoPropertyValue(UnoDialog.getModel(optUseExisting), "State")).shortValue() == (short) 1;
+ if (bisAutomaticMode)
+ {
+ bischecked = chkApplyAutoValueAutomatic.getState() == (short) 1;
+ }
+ else if (bisExistingMode)
+ {
+ bischecked = chkApplyAutoValueExisting.getState() == (short) 1;
+ }
+ }
+ return bischecked;
+ }
+
+ public void onPrimeKeySelected()
+ {
+ try
+ {
+ String selfieldname = lstSinglePrimeKey.getSelectedItem();
+ boolean bdoenable = isAutoIncrementatable(selfieldname);
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, lstSinglePrimeKey.getSelectedItemPos() != -1);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), "Enabled", new Boolean(bdoenable));
+ XPropertySet xColPropertySet = curTableDescriptor.getByName(selfieldname);
+ boolean bIsAutoIncremented = ((Boolean) xColPropertySet.getPropertyValue("IsAutoIncrement")).booleanValue();
+ if (bIsAutoIncremented)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), "State", new Short((short) 1));
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), "State", new Short((short) 0));
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void toggleAutomaticAutoValueCheckBox()
+ {
+ try
+ {
+ boolean bisAutomaticMode = AnyConverter.toBoolean(Helper.getUnoPropertyValue(UnoDialog.getModel(optAddAutomatically), "Enabled"));
+ boolean bdoenable = bAutoPrimaryKeysupportsAutoIncrmentation && optAddAutomatically.getState() && bisAutomaticMode;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueAutomatic), "Enabled", new Boolean(bdoenable));
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ private void toggleSinglePrimeKeyFields(boolean _bdoenable)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblPrimeFieldName), "Enabled", new Boolean(_bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lstSinglePrimeKey), "Enabled", new Boolean(_bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), "Enabled", new Boolean(_bdoenable));
+ boolean bdoenableAutoValueCheckBox = (isAutoIncrementatable(lstSinglePrimeKey.getSelectedItem()) && _bdoenable);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(chkApplyAutoValueExisting), "Enabled", new Boolean(bdoenableAutoValueCheckBox));
+ }
+
+ private void toggleSeveralPrimeKeyFields()
+ {
+ boolean bdoEnable = (this.optUseSeveral.getState());
+ curPrimaryKeySelection.toggleListboxControls(new Boolean(bdoEnable));
+ }
+
+ public String[] getPrimaryKeyFields(TableDescriptor _curtabledescriptor)
+ {
+ if (chkcreatePrimaryKey.getState() == 0)
+ {
+ return null;
+ }
+ if (fieldnames == null)
+ {
+ initialize();
+ }
+ if (optUseSeveral.getState())
+ {
+ return curPrimaryKeySelection.getSelectedFieldNames();
+ }
+ else if (optUseExisting.getState())
+ {
+ return (new String[]
+ {
+ lstSinglePrimeKey.getSelectedItem()
+ });
+ }
+ else if (optAddAutomatically.getState())
+ {
+ return (new String[]
+ {
+ SAUTOMATICKEYFIELDNAME
+ });
+ }
+ return null;
+ }
+
+ public int getID()
+ {
+ return 0;
+ }
+
+ public void moveItemDown(String Selitem)
+ {
+ }
+
+ public void moveItemUp(String Selitem)
+ {
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ }
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+
+ public void shiftFromRightToLeft(String[] OldSelItems, String[] NewItems)
+ {
+ CurUnoDialog.setcompleted(TableWizard.SOPRIMARYKEYPAGE, (curPrimaryKeySelection.getSelectedFieldNames().length > 0));
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/ScenarioSelector.java b/wizards/com/sun/star/wizards/table/ScenarioSelector.java
new file mode 100644
index 000000000000..8936f43e3250
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/ScenarioSelector.java
@@ -0,0 +1,385 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import java.util.Vector;
+
+import com.sun.star.awt.ItemEvent;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.FieldSelection;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.XFieldSelectionListener;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public class ScenarioSelector extends FieldSelection implements XItemListener, XFieldSelectionListener
+{
+ final static int PRIVATE = 0;
+ final static int BUSINESS = 1;
+
+ private XFixedText lblExplanation;
+ private XFixedText lblCategories;
+ private XRadioButton optBusiness;
+ private XRadioButton optPrivate;
+ private XListBox xTableListBox;
+ private TableWizard CurTableWizardUnoDialog;
+ private TableDescriptor curtabledescriptor;
+ private CGCategory oCGCategory;
+ protected CGTable oCGTable;
+ private String SELECTCATEGORY = "selectCategory";
+ private int curcategory;
+ protected boolean bcolumnnameislimited;
+ private int imaxcolumnchars;
+ private String smytable;
+ private Locale aLocale;
+ private XMultiServiceFactory xMSF;
+
+ public ScenarioSelector(TableWizard _CurUnoDialog, TableDescriptor _curtabledescriptor, String _reslblFields, String _reslblSelFields)
+ {
+ super(_CurUnoDialog, TableWizard.SOMAINPAGE, 91, 108, 230, 80, _reslblFields, _reslblSelFields, 41209, true);
+ CurTableWizardUnoDialog = _CurUnoDialog;
+ xMSF = CurUnoDialog.xMSF;
+ aLocale = Configuration.getOfficeLocale(xMSF);
+ curtabledescriptor = _curtabledescriptor;
+ imaxcolumnchars = this.curtabledescriptor.getMaxColumnNameLength();
+ bcolumnnameislimited = (imaxcolumnchars > 0) && (imaxcolumnchars < 16);
+ addFieldSelectionListener(this);
+ short pretabindex = (short) (50);
+ String sExplanation = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 14);
+ String sCategories = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 15);
+ String sBusiness = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 16);
+ String sPrivate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 17);
+ String sTableNames = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 18);
+ smytable = CurUnoDialog.m_oResource.getResText(UIConsts.RID_TABLE + 44);
+ Integer IMAINSTEP = new Integer(TableWizard.SOMAINPAGE);
+ oCGCategory = new CGCategory(CurUnoDialog.xMSF);
+ oCGTable = new CGTable(CurUnoDialog.xMSF);
+ lblExplanation = CurUnoDialog.insertLabel("lblScenarioExplanation",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(32), sExplanation, Boolean.TRUE, new Integer(91), new Integer(27), IMAINSTEP, new Short(pretabindex++), new Integer(233)
+ });
+
+ lblCategories = CurUnoDialog.insertLabel("lblCategories",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sCategories, new Integer(91), new Integer(60), IMAINSTEP, new Short(pretabindex++), new Integer(100)
+ });
+
+ optBusiness = CurTableWizardUnoDialog.insertRadioButton("optBusiness", SELECTCATEGORY, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPTBUSINESS", sBusiness, new Integer(98), new Integer(70), new Short((short) 1), IMAINSTEP, new Short(pretabindex++), new Integer(78)
+ });
+
+ optPrivate = CurTableWizardUnoDialog.insertRadioButton("optPrivate", SELECTCATEGORY, this,
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ UIConsts.INTEGERS[8], "HID:WIZARDS_HID_DLGTABLE_OPTPRIVATE", sPrivate, new Integer(182), new Integer(70), IMAINSTEP, new Short(pretabindex++), new Integer(90)
+ });
+
+ CurUnoDialog.insertLabel("lblTableNames",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), sTableNames, new Integer(91), new Integer(82), IMAINSTEP, new Short(pretabindex++), new Integer(80)
+ });
+
+ try
+ {
+ xTableListBox = CurUnoDialog.insertListBox("lstTableNames", 3, null, this,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(12), "HID:WIZARDS_HID_DLGTABLE_LBTABLES", new Short(UnoDialog.getListBoxLineCount()), new Integer(91), new Integer(92), IMAINSTEP, new Short(pretabindex++), getListboxWidth()
+ });
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ initializeCategory(BUSINESS);
+ }
+
+ public void selectCategory()
+ {
+ if (optBusiness.getState())
+ {
+ initializeCategory(BUSINESS);
+ }
+ else
+ {
+ initializeCategory(PRIVATE);
+ }
+ }
+
+ public void initializeCategory(int _iCategory)
+ {
+ try
+ {
+ oCGCategory.initialize(
+ _iCategory == PRIVATE ? "private" : "business");
+ xTableListBox.removeItems((short) 0, xTableListBox.getItemCount());
+ xTableListBox.addItems(oCGCategory.getTableNames(), (short) _iCategory);
+ initializeTable(0);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void initializeTable(int _iTable)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[]
+ {
+ (short) _iTable
+ });
+ oCGTable.initialize(oCGCategory.xNameAccessTablesNode, _iTable);
+ super.initialize(oCGTable.getFieldNames(bcolumnnameislimited, imaxcolumnchars), true);
+ }
+
+ public String[] getSelectedFieldNames()
+ {
+ String[] displayfieldnames = super.getSelectedFieldNames();
+ Vector<String> afieldnameVector = new Vector<String>();
+ int a = 0;
+ for (int i = 0; i < displayfieldnames.length; i++)
+ {
+ try
+ {
+ FieldDescription ofielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(displayfieldnames[i]);
+ if (ofielddescription != null)
+ {
+ afieldnameVector.addElement(ofielddescription.getName());
+ a++;
+ }
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ String[] fieldnames = new String[a];
+ afieldnameVector.toArray(fieldnames);
+ return fieldnames;
+ }
+
+ public boolean iscompleted()
+ {
+ return getSelectedFieldNames().length > 0;
+ }
+
+ public void addColumnsToDescriptor()
+ {
+ XNameAccess xNameAccessFieldNode;
+ String[] fieldnames = getSelectedFieldNames();
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ try
+ {
+ FieldDescription curfielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(fieldnames[i]);
+ PropertyValue[] aProperties = curfielddescription.getPropertyValues();
+ this.curtabledescriptor.addColumn(aProperties);
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public String getTableName()
+ {
+ return xTableListBox.getSelectedItem();
+ }
+
+ public String getFirstTableName()
+ {
+ String[] fieldnames = super.getSelectedFieldNames();
+ if ((fieldnames.length) > 0)
+ {
+ for (int i = 0; i < CurTableWizardUnoDialog.fielditems.size(); i++)
+ {
+ String stablename = "";
+ try
+ {
+ FieldDescription ofielddescription = (FieldDescription) CurTableWizardUnoDialog.fielditems.get(fieldnames[i]);
+ stablename = ofielddescription.gettablename();
+ }
+ catch (RuntimeException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ if (!stablename.equals(""))
+ {
+ return stablename;
+ }
+ }
+ }
+ return smytable;
+ }
+
+ public void fillupTables()
+ {
+// if (optBusiness.getState())
+// else
+ }
+
+ public void fillupFieldsListbox()
+ {
+ super.emptyFieldsListBoxes();
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XItemListener#itemStateChanged(com.sun.star.awt.ItemEvent)
+ */
+ public void itemStateChanged(ItemEvent arg0)
+ {
+ initializeTable((int) xTableListBox.getSelectedItemPos());
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+ public void disposing(EventObject arg0)
+ {
+ }
+ protected int ID;
+
+ public int getID()
+ {
+ return ID;
+ }
+
+ public void setID(String sIncSuffix)
+ {
+ }
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems)
+ {
+ if (!CurTableWizardUnoDialog.verifyfieldcount(NewItems.length))
+ {
+ for (int i = 0; i < SelItems.length; i++)
+ {
+ int selindex = JavaTools.FieldInList(NewItems, SelItems[i]);
+ super.xSelectedFieldsListBox.removeItems((short) selindex, (short) 1);
+ /**TODO In this context the items should be better placed at their original position.
+ * but how is this position retrieved?
+ */
+ super.xFieldsListBox.addItem(SelItems[i], xFieldsListBox.getItemCount());
+ }
+ }
+ else
+ {
+ for (int i = 0; i < NewItems.length; i++)
+ {
+ int iduplicate;
+ if (CurTableWizardUnoDialog.fielditems.containsKey(NewItems[i]))
+ {
+ iduplicate = JavaTools.getDuplicateFieldIndex(NewItems, NewItems[i]);
+ if (iduplicate != -1)
+ {
+ XNameAccess xNameAccessFieldNode;
+ String sdisplayname = Desktop.getUniqueName(NewItems, NewItems[iduplicate], "");
+ FieldDescription curfielddescription = new FieldDescription(xMSF, aLocale, this, sdisplayname, NewItems[iduplicate], imaxcolumnchars);
+ CurTableWizardUnoDialog.fielditems.put(sdisplayname, curfielddescription);
+ NewItems[iduplicate] = sdisplayname;
+ setSelectedFieldNames(NewItems);
+ }
+ }
+ else
+ {
+ CurTableWizardUnoDialog.fielditems.put(NewItems[i], new FieldDescription(xMSF, aLocale, this, NewItems[i], NewItems[i], imaxcolumnchars));
+ }
+ }
+ }
+ CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0);
+ }
+
+ public void shiftFromRightToLeft(String[] SelItems, String[] NewItems)
+ {
+ for (int i = 0; i < SelItems.length; i++)
+ {
+ if (CurTableWizardUnoDialog.fielditems.containsKey(SelItems[i]))
+ {
+ CurTableWizardUnoDialog.fielditems.remove(SelItems[i]);
+ this.curtabledescriptor.dropColumnbyName(SelItems[i]);
+ }
+ }
+ CurTableWizardUnoDialog.setcompleted(TableWizard.SOMAINPAGE, NewItems.length > 0);
+ }
+
+ public void moveItemDown(String item)
+ {
+ }
+
+ public void moveItemUp(String item)
+ {
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/TableWizard.java b/wizards/com/sun/star/wizards/table/TableWizard.java
new file mode 100644
index 000000000000..1444cc946675
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/TableWizard.java
@@ -0,0 +1,438 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.table;
+
+import java.util.Hashtable;
+
+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.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.CommandType;
+import com.sun.star.sdb.application.DatabaseObject;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.DatabaseObjectWizard;
+import com.sun.star.wizards.db.TableDescriptor;
+import com.sun.star.wizards.ui.*;
+
+public class TableWizard extends DatabaseObjectWizard implements XTextListener, XCompletion
+{
+
+ static String slblFields;
+ static String slblSelFields;
+ Finalizer curFinalizer;
+ ScenarioSelector curScenarioSelector;
+ FieldFormatter curFieldFormatter;
+ PrimaryKeyHandler curPrimaryKeyHandler;
+ String sMsgWizardName = "";
+ public Hashtable fielditems;
+ int wizardmode;
+ String tablename;
+ String serrToManyFields;
+ String serrTableNameexists;
+ String scomposedtablename;
+ TableDescriptor curTableDescriptor;
+ public static final int SONULLPAGE = 0;
+ public static final int SOMAINPAGE = 1;
+ public static final int SOFIELDSFORMATPAGE = 2;
+ public static final int SOPRIMARYKEYPAGE = 3;
+ public static final int SOFINALPAGE = 4;
+ private String sMsgColumnAlreadyExists = "";
+ String WizardHeaderText[] = new String[8];
+
+ private String m_tableName;
+
+ public TableWizard( XMultiServiceFactory xMSF, PropertyValue[] i_wizardContext )
+ {
+ super( xMSF, 41200, i_wizardContext );
+ super.addResourceHandler("TableWizard", "dbw");
+ String sTitle = m_oResource.getResText(UIConsts.RID_TABLE + 1);
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Height", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ new Integer(218), Boolean.TRUE, "DialogTable", new Integer(102), new Integer(41), new Integer(1), new Short((short) 0), sTitle, new Integer(330)
+ });
+ drawNaviBar();
+ fielditems = new Hashtable();
+ //TODO if reportResouces cannot be gotten dispose officedocument
+ if (getTableResources() == true)
+ {
+ setRightPaneHeaders(m_oResource, UIConsts.RID_TABLE + 8, 4);
+ }
+ }
+
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ switch (nOldStep)
+ {
+ case SOMAINPAGE:
+ curScenarioSelector.addColumnsToDescriptor();
+ break;
+ case SOFIELDSFORMATPAGE:
+ curFieldFormatter.updateColumnofColumnDescriptor();
+ String[] sfieldnames = curFieldFormatter.getFieldNames();
+ super.setStepEnabled(SOFIELDSFORMATPAGE, sfieldnames.length > 0);
+ curScenarioSelector.setSelectedFieldNames(sfieldnames);
+ break;
+ case SOPRIMARYKEYPAGE:
+ break;
+ case SOFINALPAGE:
+ break;
+ default:
+ break;
+ }
+ }
+
+ protected void enterStep(int nOldStep, int nNewStep)
+ {
+ switch (nNewStep)
+ {
+ case SOMAINPAGE:
+ break;
+ case SOFIELDSFORMATPAGE:
+ curFieldFormatter.initialize(curTableDescriptor, this.curScenarioSelector.getSelectedFieldNames());
+ break;
+ case SOPRIMARYKEYPAGE:
+ curPrimaryKeyHandler.initialize();
+ break;
+ case SOFINALPAGE:
+ curFinalizer.initialize(curScenarioSelector.getFirstTableName());
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#iscompleted(int)
+ */
+ public boolean iscompleted(int _ndialogpage)
+ {
+ switch (_ndialogpage)
+ {
+ case SOMAINPAGE:
+ return curScenarioSelector.iscompleted();
+ case SOFIELDSFORMATPAGE:
+ return this.curFieldFormatter.iscompleted();
+ case SOPRIMARYKEYPAGE:
+ if (curPrimaryKeyHandler != null)
+ {
+ return this.curPrimaryKeyHandler.iscompleted();
+ }
+ case SOFINALPAGE:
+ return this.curFinalizer.iscompleted();
+ default:
+ return false;
+ }
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#setcompleted(int, boolean)
+ */
+ public void setcompleted(int _ndialogpage, boolean _biscompleted)
+ {
+ boolean bScenarioiscompleted = _biscompleted;
+ boolean bFieldFormatsiscompleted = _biscompleted;
+ boolean bPrimaryKeysiscompleted = _biscompleted;
+ boolean bFinalPageiscompleted = _biscompleted;
+ if (_ndialogpage == SOMAINPAGE)
+ {
+ curFinalizer.initialize(curScenarioSelector.getFirstTableName());
+ }
+ else
+ {
+ bScenarioiscompleted = iscompleted(SOMAINPAGE);
+ }
+ if (_ndialogpage != TableWizard.SOFIELDSFORMATPAGE)
+ {
+ bFieldFormatsiscompleted = iscompleted(SOFIELDSFORMATPAGE);
+ if (!bFieldFormatsiscompleted) // it might be that the Fieldformatter has not yet been initialized
+ {
+ bFieldFormatsiscompleted = bScenarioiscompleted; // in this case query the scenarioselector
+ }
+ }
+ if (_ndialogpage != TableWizard.SOPRIMARYKEYPAGE && (this.curPrimaryKeyHandler != null))
+ {
+ bPrimaryKeysiscompleted = iscompleted(SOPRIMARYKEYPAGE);
+ }
+ if (_ndialogpage != TableWizard.SOFINALPAGE)
+ {
+ bFinalPageiscompleted = iscompleted(SOFINALPAGE); // Basically the finalpage is always enabled
+ }
+ if (bScenarioiscompleted)
+ {
+ super.setStepEnabled(SOFIELDSFORMATPAGE, true);
+ super.setStepEnabled(SOPRIMARYKEYPAGE, true);
+ if (bPrimaryKeysiscompleted)
+ {
+ super.enablefromStep(SOFINALPAGE, true);
+ super.enableFinishButton(bFinalPageiscompleted);
+ }
+ else
+ {
+ super.enablefromStep(SOFINALPAGE, false);
+ enableNextButton(false);
+ }
+ }
+ else if (_ndialogpage == SOFIELDSFORMATPAGE)
+ {
+ super.enablefromStep(super.getCurrentStep() + 1, iscompleted(SOFIELDSFORMATPAGE));
+ }
+ else
+ {
+ super.enablefromStep(super.getCurrentStep() + 1, false);
+ }
+ }
+
+/*
+ public static void main(String args[])
+ {
+ String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.NamingService";
+ PropertyValue[] curproperties = null;
+ try
+ {
+ XMultiServiceFactory xLocMSF = com.sun.star.wizards.common.Desktop.connect(ConnectStr);
+ TableWizard CurTableWizard = new TableWizard(xLocMSF);
+ if (xLocMSF != null)
+ {
+ System.out.println("Connected to " + ConnectStr);
+ curproperties = new PropertyValue[1];
+ curproperties[0] = Properties.createProperty("DataSourceName", "Bibliography");
+ //curproperties[0] = Properties.createProperty("DatabaseLocation", "file:///path/to/database.odb");
+ CurTableWizard.startTableWizard(xLocMSF, curproperties);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+*/
+ public void buildSteps()
+ {
+ curScenarioSelector = new ScenarioSelector(this, this.curTableDescriptor, slblFields, slblSelFields);
+ curFieldFormatter = new FieldFormatter(this, curTableDescriptor);
+ if ( this.curTableDescriptor.supportsPrimaryKeys() )
+ {
+ curPrimaryKeyHandler = new PrimaryKeyHandler(this, curTableDescriptor);
+ }
+ curFinalizer = new Finalizer(this, curTableDescriptor);
+ enableNavigationButtons(false, false, false);
+ }
+
+ public boolean createTable()
+ {
+ boolean bIsSuccessfull = true;
+ boolean bTableCreated = false;
+ String schemaname = curFinalizer.getSchemaName();
+ String catalogname = curFinalizer.getCatalogName();
+ if (curTableDescriptor.supportsPrimaryKeys())
+ {
+ String[] keyfieldnames = curPrimaryKeyHandler.getPrimaryKeyFields(curTableDescriptor);
+ if (keyfieldnames != null)
+ {
+ if (keyfieldnames.length > 0)
+ {
+ boolean bIsAutoIncrement = curPrimaryKeyHandler.isAutoIncremented();
+ bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, keyfieldnames, bIsAutoIncrement, curScenarioSelector.getSelectedFieldNames());
+ bTableCreated = true;
+ }
+ }
+ }
+ if (!bTableCreated)
+ {
+ bIsSuccessfull = curTableDescriptor.createTable(catalogname, schemaname, tablename, curScenarioSelector.getSelectedFieldNames());
+ }
+ if ((!bIsSuccessfull) && (curPrimaryKeyHandler.isAutomaticMode()))
+ {
+ curTableDescriptor.dropColumnbyName(curPrimaryKeyHandler.getAutomaticFieldName());
+ }
+ return bIsSuccessfull;
+ }
+
+ public boolean finishWizard()
+ {
+ super.switchToStep(super.getCurrentStep(), SOFINALPAGE);
+ tablename = curFinalizer.getTableName(curScenarioSelector.getFirstTableName());
+ scomposedtablename = curFinalizer.getComposedTableName(tablename);
+ if (this.curTableDescriptor.isSQL92CheckEnabled())
+ {
+ Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(this.curTableDescriptor.xMSF), tablename);
+ }
+ if ( tablename.length() > 0 )
+ {
+ if (!curTableDescriptor.hasTableByName(scomposedtablename))
+ {
+ wizardmode = curFinalizer.finish();
+ if (createTable())
+ {
+ final boolean editTableDesign = (wizardmode == Finalizer.MODIFYTABLEMODE );
+ loadSubComponent( DatabaseObject.TABLE, curTableDescriptor.getComposedTableName(), editTableDesign );
+ m_tableName = curTableDescriptor.getComposedTableName();
+ super.xDialog.endExecute();
+ return true;
+ }
+ }
+ else
+ {
+ String smessage = JavaTools.replaceSubString(serrTableNameexists, tablename, "%TABLENAME");
+ super.showMessageBox("WarningBox", com.sun.star.awt.VclWindowPeerAttribute.OK, smessage);
+ curFinalizer.setFocusToTableNameControl();
+ }
+ }
+ return false;
+ }
+
+ private void callFormWizard()
+ {
+ try
+ {
+ Object oFormWizard = this.xMSF.createInstance("com.sun.star.wizards.form.CallFormWizard");
+
+ NamedValueCollection wizardContext = new NamedValueCollection();
+ wizardContext.put( "ActiveConnection", curTableDescriptor.DBConnection );
+ wizardContext.put( "DataSource", curTableDescriptor.getDataSource() );
+ wizardContext.put( "CommandType", CommandType.TABLE );
+ wizardContext.put( "Command", scomposedtablename );
+ wizardContext.put( "DocumentUI", m_docUI );
+ XInitialization xInitialization = UnoRuntime.queryInterface( XInitialization.class, oFormWizard );
+ xInitialization.initialize( wizardContext.getPropertyValues() );
+ XJobExecutor xJobExecutor = UnoRuntime.queryInterface( XJobExecutor.class, oFormWizard );
+ xJobExecutor.trigger("start");
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void cancelWizard()
+ {
+ xDialog.endExecute();
+ }
+
+ public void insertFormRelatedSteps()
+ {
+ addRoadmap();
+ int i = 0;
+ i = insertRoadmapItem(0, true, m_oResource.getResText(UIConsts.RID_TABLE + 2), SOMAINPAGE);
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 3), SOFIELDSFORMATPAGE);
+ if (this.curTableDescriptor.supportsPrimaryKeys())
+ {
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 4), SOPRIMARYKEYPAGE);
+ }
+ i = insertRoadmapItem(i, false, m_oResource.getResText(UIConsts.RID_TABLE + 5), SOFINALPAGE); // Orderby is always supported
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ }
+
+ public String startTableWizard( )
+ {
+ try
+ {
+ curTableDescriptor = new TableDescriptor(xMSF, super.xWindow, this.sMsgColumnAlreadyExists);
+ if ( curTableDescriptor.getConnection( m_wizardContext ) )
+ {
+ buildSteps();
+ createWindowPeer();
+ curTableDescriptor.setWindowPeer(this.xControl.getPeer());
+ insertFormRelatedSteps();
+ short RetValue = executeDialog();
+ xComponent.dispose();
+ if ( RetValue == 0 )
+ {
+ if ( wizardmode == Finalizer.STARTFORMWIZARDMODE )
+ callFormWizard();
+ return m_tableName;
+ }
+ }
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ return "";
+ }
+
+ public boolean getTableResources()
+ {
+ sMsgWizardName = super.m_oResource.getResText(UIConsts.RID_TABLE + 1);
+ slblFields = m_oResource.getResText(UIConsts.RID_TABLE + 19);
+ slblSelFields = m_oResource.getResText(UIConsts.RID_TABLE + 25);
+ serrToManyFields = m_oResource.getResText(UIConsts.RID_TABLE + 47);
+ serrTableNameexists = m_oResource.getResText(UIConsts.RID_TABLE + 48);
+ sMsgColumnAlreadyExists = m_oResource.getResText(UIConsts.RID_TABLE + 51);
+ return true;
+ }
+
+ public boolean verifyfieldcount(int _icount)
+ {
+ try
+ {
+ int maxfieldcount = curTableDescriptor.getMaxColumnsInTable();
+ if (_icount >= (maxfieldcount - 1))
+ { // keep one column as reserve for the automaticcally created key
+ String smessage = serrToManyFields;
+ smessage = JavaTools.replaceSubString(smessage, String.valueOf(maxfieldcount), "%COUNT");
+ showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, smessage);
+ return false;
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return true;
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XTextListener#textChanged(com.sun.star.awt.TextEvent)
+ */
+ public void textChanged(TextEvent aTextEvent)
+ {
+ if (this.curTableDescriptor.isSQL92CheckEnabled())
+ {
+ Object otextcomponent = UnoDialog.getModel(aTextEvent.Source);
+ String sName = (String) Helper.getUnoPropertyValue(otextcomponent, "Text");
+ sName = Desktop.removeSpecialCharacters(curTableDescriptor.xMSF, Configuration.getOfficeLocale(curTableDescriptor.xMSF), sName);
+ Helper.setUnoPropertyValue(otextcomponent, "Text", sName);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/table/makefile.mk b/wizards/com/sun/star/wizards/table/makefile.mk
new file mode 100644
index 000000000000..4343af99d45d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/makefile.mk
@@ -0,0 +1,73 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = table
+PACKAGE = com$/sun$/star$/wizards$/table
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar commonwizards.jar
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/table
+JARTARGET = $(TARGET).jar
+JARCLASSPATH = commonwizards.jar
+
+# --- Files --------------------------------------------------------
+#SRS2NAME = dbwizres
+#SRC2FILES= dbwizres.src
+#RESLIB2SRSFILES= $(SRS)$/dbwizres.srs
+#RESLIB2NAME= dbw
+
+JAVAFILES= \
+ CallTableWizard.java \
+ Finalizer.java \
+ FieldDescription.java \
+ CGCategory.java \
+ CGTable.java \
+ FieldFormatter.java \
+ PrimaryKeyHandler.java \
+ ScenarioSelector.java \
+ TableWizard.java \
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/table.component
+
+$(MISC)/table.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ table.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt table.component
diff --git a/wizards/com/sun/star/wizards/table/table.component b/wizards/com/sun/star/wizards/table/table.component
new file mode 100644
index 000000000000..24cacd225181
--- /dev/null
+++ b/wizards/com/sun/star/wizards/table/table.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name=
+ "com.sun.star.wizards.table.CallTableWizard$TableWizardImplementation">
+ <service name="com.sun.star.wizards.table.CallTableWizard"/>
+ </implementation>
+</component>
diff --git a/wizards/com/sun/star/wizards/text/TextDocument.java b/wizards/com/sun/star/wizards/text/TextDocument.java
new file mode 100644
index 000000000000..4fe2e9f0d710
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextDocument.java
@@ -0,0 +1,483 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.document.XDocumentPropertiesSupplier;
+import com.sun.star.frame.XController;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFramesSupplier;
+import com.sun.star.frame.XLoadable;
+import com.sun.star.frame.XModel;
+import com.sun.star.frame.XModule;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.frame.XStorable;
+import com.sun.star.i18n.NumberFormatIndex;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+
+import com.sun.star.style.XStyle;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.task.XStatusIndicatorFactory;
+import com.sun.star.text.XPageCursor;
+import com.sun.star.text.XSimpleText;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextViewCursor;
+import com.sun.star.text.XTextViewCursorSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.XModifiable;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.util.XRefreshable;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.Helper.DateUtils;
+import com.sun.star.wizards.document.OfficeDocument;
+
+public class TextDocument
+{
+
+ public XComponent xComponent;
+ public com.sun.star.text.XTextDocument xTextDocument;
+ public com.sun.star.util.XNumberFormats NumberFormats;
+ public com.sun.star.document.XDocumentProperties m_xDocProps;
+ public com.sun.star.task.XStatusIndicator xProgressBar;
+ public com.sun.star.frame.XFrame xFrame;
+ public XText xText;
+ public XMultiServiceFactory xMSFDoc;
+ public XMultiServiceFactory xMSF;
+ public com.sun.star.util.XNumberFormatsSupplier xNumberFormatsSupplier;
+ public com.sun.star.awt.XWindowPeer xWindowPeer;
+ public int PageWidth;
+ public int ScaleWidth;
+ public Size DocSize;
+ public com.sun.star.awt.Rectangle PosSize;
+ public com.sun.star.lang.Locale CharLocale;
+ public XStorable xStorable;
+
+ // creates an instance of TextDocument and creates a named frame. No document is actually loaded into this frame.
+ public TextDocument(XMultiServiceFactory xMSF, XTerminateListener listener, String FrameName)
+ {
+ this.xMSF = xMSF;
+ xFrame = OfficeDocument.createNewFrame(xMSF, listener, FrameName);
+ }
+
+ // creates an instance of TextDocument by loading a given URL as preview
+ public TextDocument(XMultiServiceFactory xMSF, String _sPreviewURL, boolean bShowStatusIndicator, XTerminateListener listener)
+ {
+ this.xMSF = xMSF;
+
+ xFrame = OfficeDocument.createNewFrame(xMSF, listener);
+ xTextDocument = loadAsPreview(_sPreviewURL, true);
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xTextDocument);
+
+ if (bShowStatusIndicator)
+ {
+ showStatusIndicator();
+ }
+ init();
+ }
+
+ // creates an instance of TextDocument from the desktop's current frame
+ public TextDocument(XMultiServiceFactory xMSF, boolean bShowStatusIndicator, XTerminateListener listener)
+ {
+ this.xMSF = xMSF;
+
+ XDesktop xDesktop = Desktop.getDesktop(xMSF);
+ XFramesSupplier xFrameSupplier = (XFramesSupplier) UnoRuntime.queryInterface(XFramesSupplier.class, xDesktop);
+ xFrame = xFrameSupplier.getActiveFrame();
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xFrame.getController().getModel());
+ xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+
+ if (bShowStatusIndicator)
+ {
+ showStatusIndicator();
+ }
+ init();
+ }
+
+ public static class ModuleIdentifier
+ {
+
+ private String m_identifier;
+
+ protected final String getIdentifier()
+ {
+ return m_identifier;
+ }
+
+ public ModuleIdentifier(String _identifier)
+ {
+ m_identifier = _identifier;
+ }
+ };
+
+ // creates an instance of TextDocument containing a blank text document
+ public TextDocument(XMultiServiceFactory xMSF, ModuleIdentifier _moduleIdentifier, boolean bShowStatusIndicator)
+ {
+ this.xMSF = xMSF;
+
+ try
+ {
+ // create the empty document, and set its module identifier
+ xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class,
+ xMSF.createInstance("com.sun.star.text.TextDocument"));
+
+ XLoadable xLoadable = (XLoadable) UnoRuntime.queryInterface(XLoadable.class, xTextDocument);
+ xLoadable.initNew();
+
+ XModule xModule = (XModule) UnoRuntime.queryInterface(XModule.class,
+ xTextDocument);
+ xModule.setIdentifier(_moduleIdentifier.getIdentifier());
+
+ // load the document into a blank frame
+ XDesktop xDesktop = Desktop.getDesktop(xMSF);
+ XComponentLoader xLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, xDesktop);
+ PropertyValue[] loadArgs = new PropertyValue[]
+ {
+ new PropertyValue("Model", -1, xTextDocument, com.sun.star.beans.PropertyState.DIRECT_VALUE)
+ };
+ xLoader.loadComponentFromURL("private:object", "_blank", 0, loadArgs);
+
+ // remember some things for later usage
+ xFrame = xTextDocument.getCurrentController().getFrame();
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xTextDocument);
+ }
+ catch (Exception e)
+ {
+ // TODO: it seems the whole project does not really have an error handling. Other menthods
+ // seem to generally silence errors, so we can't do anything else here ...
+ }
+
+ if (bShowStatusIndicator)
+ {
+ showStatusIndicator();
+ }
+ init();
+ }
+
+ //creates an instance of TextDocument from a given XTextDocument
+ public TextDocument(XMultiServiceFactory xMSF, XTextDocument _textDocument, boolean bshowStatusIndicator)
+ {
+ this.xMSF = xMSF;
+ xFrame = _textDocument.getCurrentController().getFrame();
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, _textDocument);
+ xTextDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xComponent);
+ //PosSize = xFrame.getComponentWindow().getPosSize();
+ if (bshowStatusIndicator)
+ {
+ XStatusIndicatorFactory xStatusIndicatorFactory = (XStatusIndicatorFactory) UnoRuntime.queryInterface(XStatusIndicatorFactory.class, xFrame);
+ xProgressBar = xStatusIndicatorFactory.createStatusIndicator();
+ xProgressBar.start("", 100);
+ xProgressBar.setValue(5);
+ }
+ xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow());
+ xMSFDoc = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument);
+
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ m_xDocProps = xDocPropsSuppl.getDocumentProperties();
+ CharLocale = (Locale) Helper.getUnoStructValue((Object) xComponent, "CharLocale");
+ xText = xTextDocument.getText();
+ }
+
+ private void init()
+ {
+ xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow());
+ xMSFDoc = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument);
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ m_xDocProps = xDocPropsSuppl.getDocumentProperties();
+ CharLocale = (Locale) Helper.getUnoStructValue((Object) xComponent, "CharLocale");
+ xStorable = (XStorable) UnoRuntime.queryInterface(XStorable.class, xTextDocument);
+ xText = xTextDocument.getText();
+ }
+
+ private void showStatusIndicator()
+ {
+ XStatusIndicatorFactory xStatusIndicatorFactory = (XStatusIndicatorFactory) UnoRuntime.queryInterface(XStatusIndicatorFactory.class, xFrame);
+ xProgressBar = xStatusIndicatorFactory.createStatusIndicator();
+ xProgressBar.start("", 100);
+ xProgressBar.setValue(5);
+ }
+
+ public XTextDocument loadAsPreview(String sDefaultTemplate, boolean asTemplate)
+ {
+ PropertyValue loadValues[] = new PropertyValue[3];
+ // open document in the Preview mode
+ loadValues[0] = new PropertyValue();
+ loadValues[0].Name = "ReadOnly";
+ loadValues[0].Value = Boolean.TRUE;
+ loadValues[1] = new PropertyValue();
+ loadValues[1].Name = "AsTemplate";
+ loadValues[1].Value = asTemplate ? Boolean.TRUE : Boolean.FALSE;
+ loadValues[2] = new PropertyValue();
+ loadValues[2].Name = "Preview";
+ loadValues[2].Value = Boolean.TRUE;
+
+ //set the preview document to non-modified mode in order to avoid the 'do u want to save' box
+ if (xTextDocument != null)
+ {
+ try
+ {
+ XModifiable xModi = (XModifiable) UnoRuntime.queryInterface(XModifiable.class, xTextDocument);
+ xModi.setModified(false);
+ }
+ catch (PropertyVetoException e1)
+ {
+ e1.printStackTrace(System.out);
+ }
+ }
+ Object oDoc = OfficeDocument.load(xFrame, sDefaultTemplate, "_self", loadValues);
+ xTextDocument = (com.sun.star.text.XTextDocument) oDoc;
+ DocSize = getPageSize();
+ xMSFDoc = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+
+ ViewHandler myViewHandler = new ViewHandler(xMSFDoc, xTextDocument);
+ try
+ {
+ myViewHandler.setViewSetting("ZoomType", new Short(com.sun.star.view.DocumentZoomType.ENTIRE_PAGE));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ TextFieldHandler myFieldHandler = new TextFieldHandler(xMSF, xTextDocument);
+ myFieldHandler.updateDocInfoFields();
+
+ return xTextDocument;
+
+ }
+
+ public Size getPageSize()
+ {
+ try
+ {
+ XStyleFamiliesSupplier xStyleFamiliesSupplier = (XStyleFamiliesSupplier) com.sun.star.uno.UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument);
+ com.sun.star.container.XNameAccess xNameAccess = null;
+ xNameAccess = xStyleFamiliesSupplier.getStyleFamilies();
+ com.sun.star.container.XNameContainer xPageStyleCollection = null;
+ xPageStyleCollection = (com.sun.star.container.XNameContainer) UnoRuntime.queryInterface(com.sun.star.container.XNameContainer.class, xNameAccess.getByName("PageStyles"));
+ XStyle xPageStyle = (XStyle) UnoRuntime.queryInterface(XStyle.class, xPageStyleCollection.getByName("First Page"));
+ return (Size) Helper.getUnoPropertyValue(xPageStyle, "Size");
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ //creates an instance of TextDocument and creates a frame and loads a document
+ public TextDocument(XMultiServiceFactory xMSF, String URL, PropertyValue[] xArgs, XTerminateListener listener)
+ {
+ this.xMSF = xMSF;
+ XDesktop xDesktop = Desktop.getDesktop(xMSF);
+
+ xFrame = OfficeDocument.createNewFrame(xMSF, listener);
+ Object oDoc = OfficeDocument.load(xFrame, URL, "_self", xArgs);
+ xTextDocument = (XTextDocument) oDoc;
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xTextDocument);
+ XWindow xWindow = xFrame.getComponentWindow();
+
+ xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xFrame.getComponentWindow());
+ xMSFDoc = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xTextDocument);
+ xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument);
+
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ m_xDocProps = xDocPropsSuppl.getDocumentProperties();
+ CharLocale = (Locale) Helper.getUnoStructValue((Object) xComponent, "CharLocale");
+ }
+
+ public static XTextCursor createTextCursor(Object oCursorContainer)
+ {
+ XSimpleText xText = (XSimpleText) UnoRuntime.queryInterface(XSimpleText.class, oCursorContainer);
+ XTextCursor xTextCursor = xText.createTextCursor();
+ return xTextCursor;
+ }
+
+ // Todo: This method is unsecure because the last index is not necessarily the last section
+
+ // Todo: This Routine should be modified, because I cannot rely on the last Table in the document to be the last in the TextTables sequence
+ // to make it really safe you must acquire the Tablenames before the insertion and after the insertion of the new Table. By comparing the
+ // two sequences of tablenames you can find out the tablename of the last inserted Table
+
+ // Todo: This method is unsecure because the last index is not necessarily the last section
+ public int getCharWidth(String ScaleString)
+ {
+ int iScale = 200;
+ xTextDocument.lockControllers();
+ int iScaleLen = ScaleString.length();
+ com.sun.star.text.XTextCursor xTextCursor = createTextCursor(xTextDocument.getText());
+ xTextCursor.gotoStart(false);
+ com.sun.star.wizards.common.Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page");
+ xTextCursor.setString(ScaleString);
+ XTextViewCursorSupplier xViewCursor = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xTextDocument.getCurrentController());
+ XTextViewCursor xTextViewCursor = xViewCursor.getViewCursor();
+ xTextViewCursor.gotoStart(false);
+ int iFirstPos = xTextViewCursor.getPosition().X;
+ xTextViewCursor.gotoEnd(false);
+ int iLastPos = xTextViewCursor.getPosition().X;
+ iScale = (iLastPos - iFirstPos) / iScaleLen;
+ xTextCursor.gotoStart(false);
+ xTextCursor.gotoEnd(true);
+ xTextCursor.setString("");
+ unlockallControllers();
+ return iScale;
+ }
+
+ public void unlockallControllers()
+ {
+ while (xTextDocument.hasControllersLocked() == true)
+ {
+ xTextDocument.unlockControllers();
+ }
+ }
+
+ public void refresh()
+ {
+ XRefreshable xRefreshable = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, xTextDocument);
+ xRefreshable.refresh();
+ }
+
+ /**
+ * This method sets the Author of a Wizard-generated template correctly
+ * and adds a explanatory sentence to the template description.
+ * @param WizardName The name of the Wizard.
+ * @param TemplateDescription The old Description which is being appended with another sentence.
+ * @return void.
+ */
+ public void setWizardTemplateDocInfo(String WizardName, String TemplateDescription)
+ {
+ try
+ {
+ Object uD = Configuration.getConfigurationRoot(xMSF, "/org.openoffice.UserProfile/Data", false);
+ XNameAccess xNA = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, uD);
+ Object gn = xNA.getByName("givenname");
+ Object sn = xNA.getByName("sn");
+ String fullname = (String) gn + " " + (String) sn;
+
+ Calendar cal = new GregorianCalendar();
+ int year = cal.get(Calendar.YEAR);
+ int month = cal.get(Calendar.MONTH);
+ int day = cal.get(Calendar.DAY_OF_MONTH);
+ DateTime currentDate = new DateTime();
+ currentDate.Day = (short) day;
+ currentDate.Month = (short) month;
+ currentDate.Year = (short) year;
+ DateUtils du = new DateUtils(xMSF, this.xTextDocument);
+ int ff = du.getFormat(NumberFormatIndex.DATE_SYS_DDMMYY);
+ String myDate = du.format(ff, currentDate);
+
+ XDocumentPropertiesSupplier xDocPropsSuppl = (XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, xTextDocument);
+ XDocumentProperties xDocProps2 = xDocPropsSuppl.getDocumentProperties();
+ xDocProps2.setAuthor(fullname);
+ xDocProps2.setModifiedBy(fullname);
+ String description = xDocProps2.getDescription();
+ description = description + " " + TemplateDescription;
+ description = JavaTools.replaceSubString(description, WizardName, "<wizard_name>");
+ description = JavaTools.replaceSubString(description, myDate, "<current_date>");
+ xDocProps2.setDescription(description);
+ }
+ catch (NoSuchElementException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (WrappedTargetException e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * removes an arbitrary Object which supports the 'XTextContent' interface
+ * @param oTextContent
+ * @return
+ */
+ public boolean removeTextContent(Object oTextContent)
+ {
+ try
+ {
+ XTextContent xTextContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, oTextContent);
+ xText.removeTextContent(xTextContent);
+ return true;
+ }
+ catch (NoSuchElementException e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ /**
+ * Apparently there is no other way to get the
+ * page count of a text document other than using a cursor and
+ * making it jump to the last page...
+ * @param model the document model.
+ * @return the page count of the document.
+ */
+ public static int getPageCount(Object model)
+ {
+ XModel xModel = (XModel) UnoRuntime.queryInterface(XModel.class, model);
+ XController xController = xModel.getCurrentController();
+ XTextViewCursorSupplier xTextVCS = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController);
+ XTextViewCursor xTextVC = xTextVCS.getViewCursor();
+ XPageCursor xPC = (XPageCursor) UnoRuntime.queryInterface(XPageCursor.class, xTextVC);
+ xPC.jumpToLastPage();
+ return xPC.getPage();
+ }
+
+ /* Possible Values for "OptionString" are: "LoadCellStyles", "LoadTextStyles", "LoadFrameStyles",
+ "LoadPageStyles", "LoadNumberingStyles", "OverwriteStyles" */
+}
diff --git a/wizards/com/sun/star/wizards/text/TextFieldHandler.java b/wizards/com/sun/star/wizards/text/TextFieldHandler.java
new file mode 100644
index 000000000000..5d8c677c621e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextFieldHandler.java
@@ -0,0 +1,348 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.Vector;
+
+import com.sun.star.text.XDependentTextField;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextFieldsSupplier;
+import com.sun.star.text.XTextRange;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XEnumeration;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.DateTime;
+import com.sun.star.util.XRefreshable;
+import com.sun.star.util.XUpdatable;
+import com.sun.star.wizards.common.Helper;
+
+public class TextFieldHandler
+{
+
+ public XTextFieldsSupplier xTextFieldsSupplier;
+ private XMultiServiceFactory xMSFDoc;
+
+ /**
+ * Creates a new instance of TextFieldHandler
+ * @param xMSF
+ * @param xTextDocument
+ */
+ public TextFieldHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument)
+ {
+ this.xMSFDoc = xMSF;
+ xTextFieldsSupplier = (XTextFieldsSupplier) UnoRuntime.queryInterface(XTextFieldsSupplier.class, xTextDocument);
+ }
+
+ public void refreshTextFields()
+ {
+ XRefreshable xUp = (XRefreshable) UnoRuntime.queryInterface(XRefreshable.class, xTextFieldsSupplier.getTextFields());
+ xUp.refresh();
+ }
+
+ public String getUserFieldContent(XTextCursor xTextCursor)
+ {
+ try
+ {
+ XTextRange xTextRange = xTextCursor.getEnd();
+ Object oTextField = Helper.getUnoPropertyValue(xTextRange, "TextField");
+ if (com.sun.star.uno.AnyConverter.isVoid(oTextField))
+ {
+ return "";
+ }
+ else
+ {
+ XDependentTextField xDependent = (XDependentTextField) UnoRuntime.queryInterface(XDependentTextField.class, oTextField);
+ XPropertySet xMaster = xDependent.getTextFieldMaster();
+ String UserFieldContent = (String) xMaster.getPropertyValue("Content");
+ return UserFieldContent;
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return "";
+ }
+
+ public void insertUserField(XTextCursor xTextCursor, String FieldName, String FieldTitle)
+ {
+ try
+ {
+ XInterface xField = (XInterface) xMSFDoc.createInstance("com.sun.star.text.TextField.User");
+ XDependentTextField xDepField = (XDependentTextField) UnoRuntime.queryInterface(XDependentTextField.class, xField);
+ XTextContent xFieldContent = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xField);
+ if (xTextFieldsSupplier.getTextFieldMasters().hasByName("com.sun.star.text.FieldMaster.User." + FieldName))
+ {
+ Object oMaster = xTextFieldsSupplier.getTextFieldMasters().getByName("com.sun.star.text.FieldMaster.User." + FieldName);
+ XComponent xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, oMaster);
+ xComponent.dispose();
+ }
+ XPropertySet xPSet = createUserField(FieldName, FieldTitle);
+ xDepField.attachTextFieldMaster(xPSet);
+ xTextCursor.getText().insertTextContent(xTextCursor, xFieldContent, false);
+
+// try
+// {
+// XPropertySet xTestProp = xDepField.getTextFieldMaster();
+// String UserFieldName = (String) xTestProp.getPropertyValue("Name");
+// // UserFieldName == FieldName?
+// int dummy = 0;
+// }
+// catch (com.sun.star.uno.Exception e)
+// {
+// int dummy2 = 0;
+// }
+
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public XPropertySet createUserField(String FieldName, String FieldTitle) throws com.sun.star.uno.Exception
+ {
+ Object oMaster = xMSFDoc.createInstance("com.sun.star.text.FieldMaster.User");
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oMaster);
+ xPSet.setPropertyValue("Name", FieldName);
+ xPSet.setPropertyValue("Content", FieldTitle);
+
+ // DEBUG
+ // String sFieldName = (String)xPSet.getPropertyValue("Name");
+
+ return xPSet;
+ }
+
+ private XDependentTextField[] getTextFieldsByProperty(String _PropertyName, Object _aPropertyValue, String _TypeName) throws Exception
+ {
+ try
+ {
+ XDependentTextField[] xDependentFields;
+ Vector xDependentVector = new Vector();
+ if (xTextFieldsSupplier.getTextFields().hasElements())
+ {
+ XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration();
+ while (xEnum.hasMoreElements())
+ {
+ Object oTextField = xEnum.nextElement();
+ XDependentTextField xDependent = (XDependentTextField) UnoRuntime.queryInterface(XDependentTextField.class, oTextField);
+ XPropertySet xPropertySet = xDependent.getTextFieldMaster();
+ if (xPropertySet.getPropertySetInfo().hasPropertyByName(_PropertyName))
+ {
+ Object oValue = xPropertySet.getPropertyValue(_PropertyName);
+ // TODO replace the following comparison via com.sun.star.uno.Any.Type
+ if (AnyConverter.isString(oValue))
+ {
+ if (_TypeName.equals("String"))
+ {
+ String sValue = AnyConverter.toString(oValue);
+ if (sValue.equals(_aPropertyValue))
+ {
+ xDependentVector.addElement(xDependent);
+ }
+ }
+ }
+ else if (AnyConverter.isShort(oValue))
+ {
+ if (_TypeName.equals("Short"))
+ {
+ short iShortParam = ((Short) _aPropertyValue).shortValue();
+ short ishortValue = AnyConverter.toShort(oValue);
+ if (ishortValue == iShortParam)
+ {
+ xDependentVector.addElement(xDependent);
+ }
+ }
+ }
+ }
+ }
+ }
+ if (xDependentVector.size() > 0)
+ {
+ xDependentFields = new XDependentTextField[xDependentVector.size()];
+ xDependentVector.toArray(xDependentFields);
+ return xDependentFields;
+ }
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public void changeUserFieldContent(String _FieldName, String _FieldContent)
+ {
+ try
+ {
+ XDependentTextField[] xDependentTextFields = getTextFieldsByProperty("Name", _FieldName, "String");
+ if (xDependentTextFields != null)
+ {
+ for (int i = 0; i < xDependentTextFields.length; i++)
+ {
+ xDependentTextFields[i].getTextFieldMaster().setPropertyValue("Content", _FieldContent);
+ }
+ refreshTextFields();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void updateDocInfoFields()
+ {
+ try
+ {
+ XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration();
+ while (xEnum.hasMoreElements())
+ {
+ Object oTextField = xEnum.nextElement();
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oTextField);
+
+ if (xSI.supportsService("com.sun.star.text.TextField.ExtendedUser"))
+ {
+ XUpdatable xUp = (XUpdatable) UnoRuntime.queryInterface(XUpdatable.class, oTextField);
+ xUp.update();
+ }
+ if (xSI.supportsService("com.sun.star.text.TextField.User"))
+ {
+ XUpdatable xUp = (XUpdatable) UnoRuntime.queryInterface(XUpdatable.class, oTextField);
+ xUp.update();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void updateDateFields()
+ {
+ try
+ {
+ XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration();
+ Calendar cal = new GregorianCalendar();
+ DateTime dt = new DateTime();
+ dt.Day = (short) cal.get(Calendar.DAY_OF_MONTH);
+ dt.Year = (short) cal.get(Calendar.YEAR);
+ dt.Month = (short) cal.get(Calendar.MONTH);
+ dt.Month++;
+
+ while (xEnum.hasMoreElements())
+ {
+ Object oTextField = xEnum.nextElement();
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oTextField);
+
+ if (xSI.supportsService("com.sun.star.text.TextField.DateTime"))
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTextField);
+ xPSet.setPropertyValue("IsFixed", Boolean.FALSE);
+ xPSet.setPropertyValue("DateTimeValue", dt);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void fixDateFields(boolean _bSetFixed)
+ {
+ try
+ {
+ XEnumeration xEnum = xTextFieldsSupplier.getTextFields().createEnumeration();
+ while (xEnum.hasMoreElements())
+ {
+ Object oTextField = xEnum.nextElement();
+ XServiceInfo xSI = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oTextField);
+ if (xSI.supportsService("com.sun.star.text.TextField.DateTime"))
+ {
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oTextField);
+ xPSet.setPropertyValue("IsFixed", new Boolean(_bSetFixed));
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void removeUserFieldByContent(String _FieldContent)
+ {
+ try
+ {
+ XDependentTextField[] xDependentTextFields = getTextFieldsByProperty("Content", _FieldContent, "String");
+ if (xDependentTextFields != null)
+ {
+ for (int i = 0; i < xDependentTextFields.length; i++)
+ {
+ xDependentTextFields[i].dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void changeExtendedUserFieldContent(short UserDataPart, String _FieldContent)
+ {
+ try
+ {
+ XDependentTextField[] xDependentTextFields = getTextFieldsByProperty("UserDataType", new Short(UserDataPart), "Short");
+ if (xDependentTextFields != null)
+ {
+ for (int i = 0; i < xDependentTextFields.length; i++)
+ {
+ xDependentTextFields[i].getTextFieldMaster().setPropertyValue("Content", _FieldContent);
+ }
+ }
+ refreshTextFields();
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/text/TextFrameHandler.java b/wizards/com/sun/star/wizards/text/TextFrameHandler.java
new file mode 100644
index 000000000000..562444a1ad84
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextFrameHandler.java
@@ -0,0 +1,51 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextFrame;
+import com.sun.star.text.XTextFramesSupplier;
+import com.sun.star.uno.UnoRuntime;
+
+public class TextFrameHandler
+{
+
+ public static XTextFrame getFrameByName(String sFrameName, XTextDocument xTD) throws NoSuchElementException, WrappedTargetException
+ {
+ XTextFramesSupplier xFrameSupplier = (XTextFramesSupplier) UnoRuntime.queryInterface(XTextFramesSupplier.class, xTD);
+ if (xFrameSupplier.getTextFrames().hasByName(sFrameName))
+ {
+ Object oTextFrame = xFrameSupplier.getTextFrames().getByName(sFrameName);
+ XTextFrame xTextFrame = (XTextFrame) UnoRuntime.queryInterface(XTextFrame.class, oTextFrame);
+ return xTextFrame;
+ }
+ return null;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/text/TextSectionHandler.java b/wizards/com/sun/star/wizards/text/TextSectionHandler.java
new file mode 100644
index 000000000000..42fd75879c3c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextSectionHandler.java
@@ -0,0 +1,271 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNamed;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.text.ControlCharacter;
+import com.sun.star.text.SectionFileLink;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextSectionsSupplier;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+public class TextSectionHandler
+{
+
+ public XTextSectionsSupplier xTextSectionsSupplier;
+ private XMultiServiceFactory xMSFDoc;
+ private XTextDocument xTextDocument;
+ private XText xText;
+
+ /** Creates a new instance of TextSectionHandler */
+ public TextSectionHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument)
+ {
+ this.xMSFDoc = xMSF;
+ this.xTextDocument = xTextDocument;
+ xText = xTextDocument.getText();
+ xTextSectionsSupplier = (XTextSectionsSupplier) UnoRuntime.queryInterface(XTextSectionsSupplier.class, xTextDocument);
+ }
+
+ public void removeTextSectionbyName(String SectionName)
+ {
+ try
+ {
+ XNameAccess xAllTextSections = xTextSectionsSupplier.getTextSections();
+ if (xAllTextSections.hasByName(SectionName) == true)
+ {
+ Object oTextSection = xTextSectionsSupplier.getTextSections().getByName(SectionName);
+ removeTextSection(oTextSection);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public boolean hasTextSectionByName(String SectionName)
+ {
+ com.sun.star.container.XNameAccess xAllTextSections = xTextSectionsSupplier.getTextSections();
+ return xAllTextSections.hasByName(SectionName);
+ }
+
+ public void removeLastTextSection()
+ {
+ try
+ {
+ XIndexAccess xAllTextSections = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections());
+ Object oTextSection = xAllTextSections.getByIndex(xAllTextSections.getCount() - 1);
+ removeTextSection(oTextSection);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeTextSection(Object _oTextSection)
+ {
+ try
+ {
+ XTextContent xTextContentTextSection = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, _oTextSection);
+ xText.removeTextContent(xTextContentTextSection);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeInvisibleTextSections()
+ {
+ try
+ {
+ XIndexAccess xAllTextSections = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections());
+ int TextSectionCount = xAllTextSections.getCount();
+ for (int i = TextSectionCount - 1; i >= 0; i--)
+ {
+ XTextContent xTextContentTextSection = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xAllTextSections.getByIndex(i));
+ XPropertySet xTextSectionPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextContentTextSection);
+ boolean bRemoveTextSection = (!AnyConverter.toBoolean(xTextSectionPropertySet.getPropertyValue("IsVisible")));
+ if (bRemoveTextSection)
+ {
+ xText.removeTextContent(xTextContentTextSection);
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeAllTextSections()
+ {
+ try
+ {
+ XIndexAccess xAllTextSections = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections());
+ int TextSectionCount = xAllTextSections.getCount();
+ for (int i = TextSectionCount - 1; i >= 0; i--)
+ {
+ XTextContent xTextContentTextSection = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xAllTextSections.getByIndex(i));
+ XPropertySet xTextSectionPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextContentTextSection);
+ xText.removeTextContent(xTextContentTextSection);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void breakLinkofTextSections()
+ {
+ try
+ {
+ Object oTextSection;
+ XIndexAccess xAllTextSections = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextSectionsSupplier.getTextSections());
+ int iSectionCount = xAllTextSections.getCount();
+ SectionFileLink oSectionLink = new SectionFileLink();
+ oSectionLink.FileURL = "";
+ for (int i = 0; i < iSectionCount; i++)
+ {
+ oTextSection = xAllTextSections.getByIndex(i);
+ Helper.setUnoPropertyValues(oTextSection, new String[]
+ {
+ "FileLink", "LinkRegion"
+ }, new Object[]
+ {
+ oSectionLink, ""
+ });
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void breakLinkOfTextSection(Object oTextSection)
+ {
+ SectionFileLink oSectionLink = new SectionFileLink();
+ oSectionLink.FileURL = "";
+ Helper.setUnoPropertyValues(oTextSection, new String[]
+ {
+ "FileLink", "LinkRegion"
+ }, new Object[]
+ {
+ oSectionLink, ""
+ });
+ }
+
+ public void linkSectiontoTemplate(String TemplateName, String SectionName)
+ {
+ try
+ {
+ Object oTextSection = xTextSectionsSupplier.getTextSections().getByName(SectionName);
+ linkSectiontoTemplate(oTextSection, TemplateName, SectionName);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void linkSectiontoTemplate(Object oTextSection, String TemplateName, String SectionName)
+ {
+ SectionFileLink oSectionLink = new SectionFileLink();
+ oSectionLink.FileURL = TemplateName;
+ Helper.setUnoPropertyValues(oTextSection, new String[]
+ {
+ "FileLink", "LinkRegion"
+ }, new Object[]
+ {
+ oSectionLink, SectionName
+ });
+ XNamed xSectionName = (XNamed) UnoRuntime.queryInterface(XNamed.class, oTextSection);
+ String NewSectionName = xSectionName.getName();
+ if (NewSectionName.compareTo(SectionName) != 0)
+ {
+ xSectionName.setName(SectionName);
+ }
+ }
+
+ public void insertTextSection(String GroupName, String TemplateName, boolean _bAddParagraph)
+ {
+ try
+ {
+ if (_bAddParagraph)
+ {
+ XTextCursor xTextCursor = xText.createTextCursor();
+ xText.insertControlCharacter(xTextCursor, ControlCharacter.PARAGRAPH_BREAK, false);
+ // Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page");
+ xTextCursor.collapseToEnd();
+ }
+ XTextCursor xSecondTextCursor = xText.createTextCursor();
+ xSecondTextCursor.gotoEnd(false);
+ insertTextSection(GroupName, TemplateName, xSecondTextCursor);
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public void insertTextSection(String sectionName, String templateName, XTextCursor position)
+ {
+ try
+ {
+ Object xTextSection;
+ if (xTextSectionsSupplier.getTextSections().hasByName(sectionName) == true)
+ {
+ xTextSection = xTextSectionsSupplier.getTextSections().getByName(sectionName);
+ }
+ else
+ {
+ xTextSection = xMSFDoc.createInstance("com.sun.star.text.TextSection");
+ XTextContent xTextContentSection = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xTextSection);
+ position.getText().insertTextContent(position, xTextContentSection, false);
+ }
+ linkSectiontoTemplate(xTextSection, templateName, sectionName);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/text/TextStyleHandler.java b/wizards/com/sun/star/wizards/text/TextStyleHandler.java
new file mode 100644
index 000000000000..e6c952e65785
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextStyleHandler.java
@@ -0,0 +1,114 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import com.sun.star.awt.Size;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.style.XStyleLoader;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+
+public class TextStyleHandler
+{
+
+ public XStyleFamiliesSupplier xStyleFamiliesSupplier;
+ private XMultiServiceFactory xMSFDoc;
+ private XTextDocument xTextDocument;
+
+ /** Creates a new instance of TextStyleHandler */
+ public TextStyleHandler(com.sun.star.lang.XMultiServiceFactory xMSF, XTextDocument xTextDocument)
+ {
+ this.xMSFDoc = xMSF;
+ this.xTextDocument = xTextDocument;
+ xStyleFamiliesSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument);
+ }
+
+ public void loadStyleTemplates(String sTemplateUrl, String OptionString)
+ {
+ try
+ {
+ XStyleLoader xStyleLoader = (XStyleLoader) UnoRuntime.queryInterface(XStyleLoader.class, xStyleFamiliesSupplier.getStyleFamilies());
+ com.sun.star.beans.PropertyValue[] StyleOptions = xStyleLoader.getStyleLoaderOptions();
+ String CurOptionName = "";
+ int PropCount = StyleOptions.length;
+ for (int i = 0; i < PropCount; i++)
+ {
+ CurOptionName = StyleOptions[i].Name;
+ StyleOptions[i].Value = new Boolean((CurOptionName.compareTo(OptionString) == 0) || (CurOptionName.compareTo("OverwriteStyles") == 0));
+ }
+ xStyleLoader.loadStylesFromURL(sTemplateUrl, StyleOptions);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public XPropertySet getStyleByName(String sStyleFamily, String sStyleName)
+ {
+ try
+ {
+ XPropertySet xPropertySet = null;
+ Object oStyleFamily = xStyleFamiliesSupplier.getStyleFamilies().getByName(sStyleFamily);
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oStyleFamily);
+ if (xNameAccess.hasByName(sStyleName))
+ {
+ xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xNameAccess.getByName(sStyleName));
+ }
+ return xPropertySet;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ public Size changePageAlignment(XPropertySet _xPropPageStyle, boolean _bIsLandscape)
+ {
+ try
+ {
+ _xPropPageStyle.setPropertyValue("IsLandscape", new Boolean(_bIsLandscape));
+ Size aPageSize = (Size) AnyConverter.toObject(Size.class, _xPropPageStyle.getPropertyValue("Size"));
+ int nPageWidth = aPageSize.Width;
+ int nPageHeight = aPageSize.Height;
+ Size aSize = new Size(nPageHeight, nPageWidth);
+ _xPropPageStyle.setPropertyValue("Size", aSize);
+ return (Size) AnyConverter.toObject(Size.class, _xPropPageStyle.getPropertyValue("Size"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ return null;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/text/TextTableHandler.java b/wizards/com/sun/star/wizards/text/TextTableHandler.java
new file mode 100644
index 000000000000..d3646a7cfa37
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/TextTableHandler.java
@@ -0,0 +1,253 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNamed;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.Locale;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.style.BreakType;
+import com.sun.star.table.XCellRange;
+import com.sun.star.text.XSimpleText;
+import com.sun.star.text.XText;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextTable;
+import com.sun.star.text.XTextTablesSupplier;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.util.XNumberFormatsSupplier;
+import com.sun.star.view.XSelectionSupplier;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.NumberFormatter;
+
+public class TextTableHandler
+{
+
+ public XTextTablesSupplier xTextTablesSupplier;
+ public XMultiServiceFactory xMSFDoc;
+ public XTextDocument xTextDocument;
+ public XSimpleText xSimpleText;
+ private XText xText;
+ private NumberFormatter oNumberFormatter;
+ private Locale aCharLocale;
+
+ /** Creates a new instance of TextTableHandler */
+ public TextTableHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument)
+ {
+ try
+ {
+ this.xMSFDoc = xMSF;
+ this.xTextDocument = xTextDocument;
+ xText = xTextDocument.getText();
+ xTextTablesSupplier = (XTextTablesSupplier) UnoRuntime.queryInterface(XTextTablesSupplier.class, xTextDocument);
+ xSimpleText = (XSimpleText) UnoRuntime.queryInterface(XSimpleText.class, xTextDocument.getText());
+ XNumberFormatsSupplier xNumberFormatsSupplier = (XNumberFormatsSupplier) UnoRuntime.queryInterface(XNumberFormatsSupplier.class, xTextDocument);
+ aCharLocale = (Locale) Helper.getUnoStructValue((Object) xTextDocument, "CharLocale");
+ oNumberFormatter = new NumberFormatter(xNumberFormatsSupplier, aCharLocale);
+ }
+ catch (java.lang.Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ public NumberFormatter getNumberFormatter()
+ {
+ return oNumberFormatter;
+ }
+
+ public XTextTable getByName(String _sTableName)
+ {
+ XTextTable xTextTable = null;
+ try
+ {
+ XNameAccess xAllTextTables = xTextTablesSupplier.getTextTables();
+ if (xAllTextTables.hasByName(_sTableName))
+ {
+ Object oTable = xAllTextTables.getByName(_sTableName);
+ xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, oTable);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return xTextTable;
+ }
+
+ public com.sun.star.text.XTextTable getlastTextTable()
+ {
+ try
+ {
+ XIndexAccess xAllTextTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables());
+ int MaxIndex = xAllTextTables.getCount() - 1;
+ Object oTable = xAllTextTables.getByIndex(MaxIndex);
+ XTextTable xTextTable = (XTextTable) UnoRuntime.queryInterface(XTextTable.class, oTable);
+ return xTextTable;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void insertTextTable(com.sun.star.text.XTextCursor xTextCursor)
+ {
+ try
+ {
+ com.sun.star.uno.XInterface xTextTable = (XInterface) xMSFDoc.createInstance("com.sun.star.text.TextTable");
+ XTextContent xTextContentTable = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xTextTable);
+ if (xTextCursor == null)
+ {
+ xTextCursor = xTextDocument.getText().createTextCursor();
+ xTextCursor.gotoEnd(false);
+ }
+ xTextCursor.getText().insertTextContent(xTextCursor, xTextContentTable, false);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeAllTextTables()
+ {
+ try
+ {
+ XIndexAccess xAllTextTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables());
+ int TextTableCount = xAllTextTables.getCount();
+ for (int i = TextTableCount - 1; i >= 0; i--)
+ {
+ removeTextTable(xAllTextTables.getByIndex(i));
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeLastTextTable()
+ {
+ try
+ {
+ XIndexAccess xAllTextTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, xTextTablesSupplier.getTextTables());
+ Object oTextTable = xAllTextTables.getByIndex(xAllTextTables.getCount() - 1);
+ removeTextTable(oTextTable);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeTextTable(Object oTextTable)
+ {
+ try
+ {
+ XTextContent xTextContentTable = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, oTextTable);
+ xTextDocument.getText().removeTextContent(xTextContentTable);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void removeTextTablebyName(String TableName)
+ {
+ try
+ {
+ XNameAccess xAllTextTables = xTextTablesSupplier.getTextTables();
+ if (xAllTextTables.hasByName(TableName) == true)
+ {
+ removeTextTable(xAllTextTables.getByName(TableName));
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void renameTextTable(String OldTableName, String NewTableName)
+ {
+ try
+ {
+ XNameAccess xTextTableNames = xTextTablesSupplier.getTextTables();
+ if (xTextTableNames.hasByName(OldTableName))
+ {
+ Object oTextTable = xTextTableNames.getByName(OldTableName);
+ XNamed xTextTableName = (XNamed) UnoRuntime.queryInterface(XNamed.class, oTextTable);
+ xTextTableName.setName(NewTableName);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public static BreakType resetBreakTypeofTextTable(Object oTextTable)
+ {
+ BreakType CorrBreakValue = null;
+ BreakType BreakValue = (BreakType) com.sun.star.wizards.common.Helper.getUnoStructValue(oTextTable, "BreakType");
+ // if (BreakValue.equals(BreakType.NONE) == false){
+ // CorrBreakValue = BreakValue;
+ Helper.setUnoPropertyValue(oTextTable, "BreakType", BreakType.NONE);
+ // }
+ return BreakType.NONE;
+ }
+
+ public void adjustOptimalTableWidths(XMultiServiceFactory _xMSF, XTextTable xTextTable)
+ { // setTableColumnSeparators(){
+ try
+ {
+ XFrame xFrame = this.xTextDocument.getCurrentController().getFrame();
+ int ColCount = xTextTable.getColumns().getCount();
+ XCellRange xCellRange = (XCellRange) UnoRuntime.queryInterface(XCellRange.class, xTextTable);
+ XCellRange xLocCellRange = xCellRange.getCellRangeByPosition(0, 0, ColCount - 1, 1);
+ short iHoriOrient = AnyConverter.toShort(Helper.getUnoPropertyValue(xTextTable, "HoriOrient"));
+ XSelectionSupplier xSelection = (XSelectionSupplier) UnoRuntime.queryInterface(XSelectionSupplier.class, xTextDocument.getCurrentController());
+ xSelection.select(xLocCellRange);
+ Desktop.dispatchURL(_xMSF, ".Uno:DistributeColumns", xFrame);
+ Desktop.dispatchURL(_xMSF, ".Uno:SetOptimalColumnWidth", xFrame);
+ Helper.setUnoPropertyValue(xTextTable, "HoriOrient", new Short(iHoriOrient));
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/text/ViewHandler.java b/wizards/com/sun/star/wizards/text/ViewHandler.java
new file mode 100644
index 000000000000..e29ad10cfbb1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/text/ViewHandler.java
@@ -0,0 +1,115 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.text;
+
+import com.sun.star.beans.PropertyVetoException;
+import com.sun.star.beans.UnknownPropertyException;
+import com.sun.star.container.XIndexAccess;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.style.XStyleFamiliesSupplier;
+import com.sun.star.text.XPageCursor;
+import com.sun.star.text.XTextContent;
+import com.sun.star.text.XTextCursor;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextRange;
+import com.sun.star.text.XTextViewCursor;
+import com.sun.star.text.XTextViewCursorSupplier;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.view.XViewSettingsSupplier;
+import com.sun.star.wizards.common.Helper;
+
+public class ViewHandler
+{
+
+ private XTextViewCursorSupplier xTextViewCursorSupplier;
+ private XMultiServiceFactory xMSFDoc;
+ private XTextDocument xTextDocument;
+ private XStyleFamiliesSupplier xStyleFamiliesSupplier;
+ private XViewSettingsSupplier xViewSettingsSupplier;
+
+ /** Creates a new instance of View */
+ public ViewHandler(XMultiServiceFactory xMSF, XTextDocument xTextDocument)
+ {
+ this.xMSFDoc = xMSF;
+ this.xTextDocument = xTextDocument;
+ xTextViewCursorSupplier = (XTextViewCursorSupplier) UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xTextDocument.getCurrentController());
+ xViewSettingsSupplier = (XViewSettingsSupplier) UnoRuntime.queryInterface(XViewSettingsSupplier.class, xTextDocument.getCurrentController());
+ xStyleFamiliesSupplier = (XStyleFamiliesSupplier) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, xTextDocument);
+ }
+
+ public void selectFirstPage(TextTableHandler oTextTableHandler)
+ {
+ try
+ {
+ XPageCursor xPageCursor = (XPageCursor) UnoRuntime.queryInterface(XPageCursor.class, xTextViewCursorSupplier.getViewCursor());
+ XTextCursor xViewTextCursor = (XTextCursor) UnoRuntime.queryInterface(XTextCursor.class, xPageCursor);
+ xPageCursor.jumpToFirstPage();
+ xPageCursor.jumpToStartOfPage();
+ Helper.setUnoPropertyValue(xPageCursor, "PageDescName", "First Page");
+ Object oPageStyles = xStyleFamiliesSupplier.getStyleFamilies().getByName("PageStyles");
+ XNameAccess xName = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, oPageStyles);
+ Object oPageStyle = xName.getByName("First Page");
+ XIndexAccess xAllTextTables = (XIndexAccess) UnoRuntime.queryInterface(XIndexAccess.class, oTextTableHandler.xTextTablesSupplier.getTextTables());
+ XTextContent xTextTable = (XTextContent) UnoRuntime.queryInterface(XTextContent.class, xAllTextTables.getByIndex(0));
+ XTextRange xRange = (XTextRange) UnoRuntime.queryInterface(XTextRange.class, xTextTable.getAnchor().getText());
+ xViewTextCursor.gotoRange(xRange, false);
+// if (xPageCursor.getPage() == (short) 1) {
+// Helper.setUnoPropertyValue(xTextTable, "PageDescName", "First Page");
+// TextTableHandler.resetBreakTypeofTextTable(xTextTable);
+// }
+ // }
+ XTextRange xHeaderRange = (XTextRange) Helper.getUnoPropertyValue(oPageStyle, "HeaderText", XTextRange.class);
+ if (!com.sun.star.uno.AnyConverter.isVoid(xHeaderRange))
+ {
+ xViewTextCursor.gotoRange(xHeaderRange, false);
+ xViewTextCursor.collapseToStart();
+ }
+ else
+ {
+ System.out.println("No Headertext available");
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void setViewSetting(String Setting, Object Value) throws UnknownPropertyException, PropertyVetoException, IllegalArgumentException, WrappedTargetException
+ {
+ xViewSettingsSupplier.getViewSettings().setPropertyValue(Setting, Value);
+ }
+
+ public void collapseViewCursorToStart()
+ {
+ XTextViewCursor xTextViewCursor = xTextViewCursorSupplier.getViewCursor();
+ xTextViewCursor.collapseToStart();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/AggregateComponent.java b/wizards/com/sun/star/wizards/ui/AggregateComponent.java
new file mode 100644
index 000000000000..f59d06772a83
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/AggregateComponent.java
@@ -0,0 +1,610 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import java.util.Vector;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.*;
+import com.sun.star.lang.EventObject;
+import com.sun.star.beans.*;
+import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.AnyConverter;
+
+import com.sun.star.awt.*;
+
+public class AggregateComponent extends ControlScroller
+{
+
+ String[] sFunctions;
+ String[] sFunctionOperators = new String[]
+ {
+ "SUM", "AVG", "MIN", "MAX"
+ };
+ ;
+ QueryMetaData CurDBMetaData;
+ XButton optDetailQuery;
+ XButton optSummaryQuery;
+ String soptDetailQuery;
+ String soptSummaryQuery;
+ String slblAggregate;
+ String slblFieldNames;
+ String sDuplicateAggregateFunction;
+ int Count;
+ int iQueryType;
+ final int SOADDROW = 1;
+ final int SOREMOVEROW = 2;
+ final int CONTROLROWDIST = 18;
+ Vector ControlRowVector;
+ String OPTIONBUTTONDETAILQUERY_ITEM_CHANGED = "toggleComponent";
+ String OPTIONBUTTONSUMMARYQUERY_ITEM_CHANGED = "toggleComponent";
+ String LISTBOXFUNCTIONS_ACTION_PERFORMED;
+ String LISTBOXFUNCTIONS_ITEM_CHANGED;
+ String LISTBOXFIELDNAMES_ACTION_PERFORMED;
+ String LISTBOXFIELDNAMES_ITEM_CHANGED;
+ String COMMANDBUTTONPLUS_ACTION_PERFORMED = "addRow";
+ String COMMANDBUTTONMINUS_ACTION_PERFORMED = "removeRow";
+ Vector ControlRows;
+ int curHelpID;
+ int lastHelpIndex;
+
+ /** Creates a new instance of AggrgateComponent */
+ public AggregateComponent(WizardDialog _CurUnoDialog, QueryMetaData _CurDBMetaData, int _iStep, int _iPosX, int _iPosY, int _iWidth, int _uitextfieldcount, int _firstHelpID)
+ {
+ super(_CurUnoDialog, _CurDBMetaData.xMSF, _iStep, _iPosX + 10, _iPosY, _iWidth - 12, _uitextfieldcount, 18, _firstHelpID + 2);
+ try
+ {
+ curHelpID = _firstHelpID;
+ this.CurDBMetaData = _CurDBMetaData;
+ ;
+ Count = 1;
+ optDetailQuery = CurUnoDialog.insertRadioButton("optDetailQuery", 0, new ActionListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), HelpIds.getHelpIdString(curHelpID), soptDetailQuery, new Integer(_iPosX), new Integer(iCompPosY - 42), new Short((short) 1), IStep, new Short(curtabindex++), new Integer(iCompWidth)
+ });
+
+ optSummaryQuery = CurUnoDialog.insertRadioButton("optSummaryQuery", 0, new ActionListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(16), HelpIds.getHelpIdString(curHelpID + 1), soptSummaryQuery, Boolean.TRUE, new Integer(_iPosX), new Integer(iCompPosY - 32), IStep, new Short(curtabindex++), new Integer(iCompWidth)
+ });
+ CurUnoDialog.insertLabel("lblAggregate",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblAggregate, new Integer(iCompPosX + 5), new Integer(iCompPosY - 10), IStep, new Short(curtabindex++), new Integer(90)
+ });
+ CurUnoDialog.insertLabel("lblFieldnames",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblFieldNames, new Integer(iCompPosX + 101), new Integer(iCompPosY - 10), IStep, new Short(curtabindex++), new Integer(90)
+ });
+ this.setTotalFieldCount(1);
+ FontDescriptor oFontDescriptor = new FontDescriptor();
+ oFontDescriptor.Weight = com.sun.star.awt.FontWeight.BOLD;
+ oFontDescriptor.Height = (short) 14;
+
+ int iButtonPosY = iCompPosY + iCompHeight + 3;
+ CurUnoDialog.insertButton("btnplus", SOADDROW, new ActionListenerImpl(),
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ oFontDescriptor, new Integer(14), HelpIds.getHelpIdString(lastHelpIndex + 1), "+", new Integer(_iPosX + iCompWidth - 36), new Integer(iButtonPosY), IStep, new Short((curtabindex++)), new Integer(16)
+ });
+ CurUnoDialog.insertButton("btnminus", SOREMOVEROW, new ActionListenerImpl(),
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ oFontDescriptor, new Integer(14), HelpIds.getHelpIdString(lastHelpIndex + 2), "-", new Integer(_iPosX + iCompWidth - 16), new Integer(iButtonPosY), IStep, new Short(curtabindex++), new Integer(16)
+ });
+ CurDBMetaData.Type = getQueryType();
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ Resource.showCommonResourceError(CurDBMetaData.xMSF);
+ }
+ }
+
+ public int getQueryType()
+ {
+ if (((Short) CurUnoDialog.getControlProperty("optDetailQuery", "State")).intValue() == 1)
+ {
+ return QueryMetaData.QueryType.SODETAILQUERY;
+ }
+ else
+ {
+ return QueryMetaData.QueryType.SOSUMMARYQUERY;
+ }
+ }
+
+ class ActionListenerImpl implements com.sun.star.awt.XActionListener
+ {
+
+ public void disposing(EventObject eventObject)
+ {
+ }
+
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ try
+ {
+ int iKey = CurUnoDialog.getControlKey(actionEvent.Source, CurUnoDialog.ControlList);
+ switch (iKey)
+ {
+ case SOADDROW:
+ addRow();
+ break;
+
+ case SOREMOVEROW:
+ removeRow();
+ break;
+
+ default:
+ toggleComponent();
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public int getCount()
+ {
+ return Count;
+ }
+
+ protected void insertControlGroup(int i, int ypos)
+ {
+ if (i == 0)
+ {
+ int BaseID = 2300;
+ soptDetailQuery = CurUnoDialog.m_oResource.getResText(BaseID + 11);
+ soptSummaryQuery = CurUnoDialog.m_oResource.getResText(BaseID + 12);
+ slblAggregate = CurUnoDialog.m_oResource.getResText(BaseID + 16);
+ slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17);
+ sFunctions = CurUnoDialog.m_oResource.getResArray(BaseID + 40, 4);
+
+ sDuplicateAggregateFunction = CurUnoDialog.m_oResource.getResText(BaseID + 90);
+ }
+ if (ControlRowVector == null)
+ {
+ ControlRowVector = new Vector();
+ }
+ int locHelpID = curHelpIndex + (i * 2);
+ ControlRow oControlRow = new ControlRow(i, ypos, locHelpID);
+ ControlRowVector.add(oControlRow);
+ }
+
+ protected void setControlGroupVisible(int _index, boolean _bIsVisible)
+ {
+ ControlRow oControlRow = (ControlRow) ControlRowVector.elementAt(_index);
+ oControlRow.setVisible(_bIsVisible);
+ if (_index >= (this.CurDBMetaData.AggregateFieldNames.length))
+ {
+ oControlRow.settovoid();
+ }
+ }
+
+ protected void addRow()
+ {
+ int fieldcount = super.getTotalFieldCount();
+ registerControlGroupAtIndex(fieldcount);
+ if (fieldcount < super.getBlockIncrementation())
+ {
+ ControlRow oControlRow = (ControlRow) ControlRowVector.elementAt(fieldcount);
+ oControlRow.setVisible(true);
+ oControlRow.settovoid();
+ }
+ else
+ {
+ ControlRow oControlRow = (ControlRow) ControlRowVector.elementAt(super.getBlockIncrementation() - 1);
+ super.setScrollValue(getScrollValue() + 1, (fieldcount + 1));
+ oControlRow.settovoid();
+ }
+ fieldcount++;
+ super.setTotalFieldCount(fieldcount);
+ toggleButtons();
+ CurUnoDialog.repaintDialogStep();
+ }
+
+ protected void removeRow()
+ {
+ int fieldcount = super.getTotalFieldCount();
+ if (fieldcount > 0)
+ {
+ ControlRow oControlRow;
+ fieldcount--;
+ if ((fieldcount + 1) <= super.getBlockIncrementation())
+ {
+ oControlRow = (ControlRow) ControlRowVector.elementAt(fieldcount);
+ oControlRow.setVisible(false);
+ }
+ super.setScrollValue(getScrollValue() - 1, (fieldcount));
+ super.unregisterControlGroup(fieldcount);
+
+ }
+ toggleButtons();
+ CurUnoDialog.repaintDialogStep();
+ }
+
+ protected void toggleButtons()
+ {
+ ControlRow curcontrolrow = null;
+ boolean biscomplete = true;
+ CurDBMetaData.Type = getQueryType();
+ CurUnoDialog.setControlProperty("btnminus", "Enabled", new Boolean((super.getTotalFieldCount() > 0) && (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)));
+ int fieldcount = super.getCurFieldCount();
+ if (fieldcount > 0)
+ {
+ curcontrolrow = (ControlRow) ControlRowVector.elementAt(super.getCurFieldCount() - 1);
+ biscomplete = curcontrolrow.isComplete();
+ }
+ CurUnoDialog.setControlProperty("btnplus", "Enabled", new Boolean(biscomplete && (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)));
+ togglefollowingDialogSteps();
+ }
+
+ public void toggleComponent()
+ {
+ CurDBMetaData.Type = getQueryType();
+ boolean benableComponent = isAggregateComponentEnabled();
+ CurUnoDialog.setControlProperty("lblAggregate", "Enabled", new Boolean(benableComponent));
+ CurUnoDialog.setControlProperty("lblFieldnames", "Enabled", new Boolean(benableComponent));
+ toggleButtons();
+ super.toggleComponent(benableComponent);
+ super.toggleControls(benableComponent);
+ togglefollowingDialogSteps();
+ }
+
+ private boolean isAggregateComponentEnabled()
+ {
+ return (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY);
+ }
+
+ public boolean isGroupingpossible()
+ {
+ try
+ {
+ boolean benableGroupPage = isAggregateComponentEnabled() && CurDBMetaData.xDBMetaData.supportsGroupBy() && hasonlycompletefunctions();
+ String[][] sAggregateFieldNames = this.getAggregateFieldNames();
+ if (benableGroupPage)
+ {
+ for (int i = 0; i < CurDBMetaData.NumericFieldNames.length; i++)
+ {
+ boolean bisthere = (JavaTools.FieldInTable(sAggregateFieldNames, CurDBMetaData.NumericFieldNames[i]) > -1);
+ if (!bisthere)
+ {
+ return true;
+ }
+ }
+ }
+ }
+ catch (SQLException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return false;
+ }
+
+ private void togglefollowingDialogSteps()
+ {
+ boolean benabletherest = true;
+ boolean benableGroupPage = isGroupingpossible();
+ CurUnoDialog.setStepEnabled(UIConsts.SOGROUPSELECTIONPAGE, benableGroupPage);
+ CurUnoDialog.setStepEnabled(UIConsts.SOGROUPFILTERPAGE, benableGroupPage && CurDBMetaData.GroupFieldNames.length > 0);
+ if (isAggregateComponentEnabled())
+ {
+ benabletherest = hasonlycompletefunctions();
+ }
+ CurUnoDialog.enablefromStep(UIConsts.SOTITLESPAGE, benabletherest);
+ CurUnoDialog.enableNextButton(benabletherest);
+ }
+
+ private void hideControlRowsfromindex(int _index)
+ {
+ if (_index < this.ControlRowVector.size())
+ {
+ for (int i = _index; i < ControlRowVector.size(); i++)
+ {
+ ControlRow oControlRow = (ControlRow) ControlRowVector.elementAt(i);
+// if (i == _index)
+// oControlRow.settovoid();
+// else
+ oControlRow.setVisible(false);
+ }
+ }
+
+ }
+
+ public String[][] getAggregateFieldNames()
+ {
+ try
+ {
+ CurDBMetaData.Type = getQueryType();
+ if (CurDBMetaData.Type == QueryMetaData.QueryType.SOSUMMARYQUERY)
+ {
+ Vector aggregatevector = new Vector();
+ PropertyValue[][] aggregatelist = this.getScrollFieldValues();
+ PropertyValue[] currowproperties;
+ PropertyValue curaggregateproperty;
+ int a = 0;
+ if (CurDBMetaData.AggregateFieldNames != null)
+ {
+ for (int i = 0; i < aggregatelist.length; i++)
+ {
+ currowproperties = aggregatelist[i];
+ if ((currowproperties[0].Value != null) && (currowproperties[1].Value != null))
+ {
+ short[] iselfield = (short[]) AnyConverter.toArray(currowproperties[1].Value);
+ short[] iselfunction = (short[]) AnyConverter.toArray(currowproperties[0].Value);
+ if ((iselfield.length > 0) && (iselfunction.length > 0))
+ {
+ String[] curaggregatename = new String[2];
+ curaggregatename[0] = CurDBMetaData.NumericFieldNames[iselfield[0]];
+ curaggregatename[1] = this.sFunctionOperators[iselfunction[0]];
+ aggregatevector.add(curaggregatename);
+ a++;
+ }
+ }
+ }
+ }
+ CurDBMetaData.AggregateFieldNames = new String[a][2];
+ aggregatevector.toArray(CurDBMetaData.AggregateFieldNames);
+ }
+
+ int iduplicate = JavaTools.getDuplicateFieldIndex(CurDBMetaData.AggregateFieldNames);
+ if (iduplicate != -1)
+ {
+ sDuplicateAggregateFunction = JavaTools.replaceSubString(sDuplicateAggregateFunction, CurDBMetaData.AggregateFieldNames[iduplicate][0], "<NUMERICFIELD>");
+ int index = JavaTools.FieldInList(sFunctionOperators, CurDBMetaData.AggregateFieldNames[iduplicate][1]);
+ String sDisplayFunction = sFunctions[index];
+ sDuplicateAggregateFunction = JavaTools.replaceSubString(sDuplicateAggregateFunction, sDisplayFunction, "<FUNCTION>");
+ CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sDuplicateAggregateFunction);
+ CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", new Integer(1), new Integer(2)));
+ return new String[][]
+ {
+ };
+ }
+ else
+ {
+ return CurDBMetaData.AggregateFieldNames;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void initialize()
+ {
+ CurDBMetaData.setNumericFields();
+ initializeScrollFields();
+ int icount = CurDBMetaData.AggregateFieldNames.length;
+ if (icount == 0)
+ {
+ super.initialize(1);
+ hideControlRowsfromindex(1);
+ }
+ else
+ {
+ super.initialize(icount);
+ hideControlRowsfromindex(icount);
+ }
+ toggleComponent();
+ CurUnoDialog.repaintDialogStep();
+ }
+
+ protected void initializeScrollFields()
+ {
+ ControlRow curControlRow;
+ if (CurDBMetaData.AggregateFieldNames != null)
+ {
+ for (int i = 0; i < this.getBlockIncrementation(); i++)
+ {
+ curControlRow = (ControlRow) ControlRowVector.elementAt(i);
+ curControlRow.insertFieldNames();
+ }
+ for (int i = 0; i <= CurDBMetaData.AggregateFieldNames.length; i++)
+ {
+ registerControlGroupAtIndex(i);
+ }
+ }
+ }
+
+ private void registerControlGroupAtIndex(int _index)
+ {
+ short[] iselfunctionlist = new short[]
+ {
+ };
+ short[] iselfieldslist = new short[]
+ {
+ };
+ PropertyValue[] currowproperties = new PropertyValue[2];
+ if (_index < CurDBMetaData.AggregateFieldNames.length)
+ {
+ short iselfieldsindex = (short) JavaTools.FieldInList(CurDBMetaData.NumericFieldNames, CurDBMetaData.AggregateFieldNames[_index][0]);
+ iselfieldslist = new short[]
+ {
+ iselfieldsindex
+ };
+ short iselfunctionindex = (short) JavaTools.FieldInList(sFunctionOperators, CurDBMetaData.AggregateFieldNames[_index][1]);
+ iselfunctionlist = new short[]
+ {
+ iselfunctionindex
+ };
+ }
+ currowproperties[0] = Properties.createProperty(getFunctionControlName(_index), iselfunctionlist, _index);
+ currowproperties[1] = Properties.createProperty(getFieldsControlName(_index), iselfieldslist, _index); //getTitleName(i)
+ super.registerControlGroup(currowproperties, _index);
+ }
+
+ private String getFunctionControlName(int _index)
+ {
+ String namesuffix = "_" + String.valueOf(_index + 1);
+ return "lstfunctions" + namesuffix;
+ }
+
+ private String getFieldsControlName(int _index)
+ {
+ String namesuffix = "_" + String.valueOf(_index + 1);
+ return "lstFieldnames" + namesuffix;
+ }
+
+ private boolean hasonlycompletefunctions()
+ {
+ int maxfieldcount = super.getCurFieldCount();
+ if (maxfieldcount > 0)
+ {
+ ControlRow curcontrolrow = (ControlRow) this.ControlRowVector.elementAt(maxfieldcount - 1);
+ return curcontrolrow.isComplete();
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ protected class ControlRow
+ {
+
+ private XListBox xFieldListBox;
+ private XListBox xFunctionListBox;
+ private int index;
+
+ protected ControlRow(int _index, int ypos, int _curHelpID)
+ {
+ try
+ {
+ this.index = _index;
+ xFunctionListBox = CurUnoDialog.insertListBox(getFunctionControlName(index), 1, null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "StringItemList", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(12), HelpIds.getHelpIdString(_curHelpID++), new Integer(iCompPosX + 4), new Integer(ypos), UIConsts.INVISIBLESTEP, sFunctions, new Short(curtabindex++), new Integer(88)
+ });
+
+ xFieldListBox = CurUnoDialog.insertListBox(getFieldsControlName(index), 1, null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(12), HelpIds.getHelpIdString(_curHelpID++), new Integer(iCompPosX + 98), new Integer(ypos), UIConsts.INVISIBLESTEP, new Short(curtabindex++), new Integer(86)
+ });
+ lastHelpIndex = _curHelpID - 1;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ private String getSelectedFieldName()
+ {
+ return xFieldListBox.getSelectedItem();
+ }
+
+ private String getSelectedFunction()
+ {
+ return xFunctionListBox.getSelectedItem();
+ }
+
+ private void setVisible(boolean _bvisible)
+ {
+ CurUnoDialog.setControlVisible(getFunctionControlName(index), _bvisible);
+ CurUnoDialog.setControlVisible(getFieldsControlName(index), _bvisible);
+ }
+
+ private void insertFieldNames()
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xFieldListBox), "StringItemList", CurDBMetaData.NumericFieldNames);
+ }
+
+ private boolean isComplete()
+ {
+ boolean bfieldnameisselected = (Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xFieldListBox), "SelectedItems") != null);
+ boolean bfunctionisselected = (Helper.getUnoArrayPropertyValue(UnoDialog.getModel(xFunctionListBox), "SelectedItems") != null);
+ return (bfieldnameisselected && bfunctionisselected);
+ }
+
+ private void settovoid()
+ {
+ CurUnoDialog.deselectListBox(xFieldListBox);
+ CurUnoDialog.deselectListBox(xFunctionListBox);
+ }
+
+ protected class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
+ {
+ try
+ {
+ toggleButtons();
+ togglefollowingDialogSteps();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/ButtonList.java b/wizards/com/sun/star/wizards/ui/ButtonList.java
new file mode 100644
index 000000000000..770210e04706
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/ButtonList.java
@@ -0,0 +1,907 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XActionListener;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XControlModel;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XItemEventBroadcaster;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.IRenderer;
+import com.sun.star.wizards.common.PropertySetHelper;
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import com.sun.star.wizards.common.HelpIds;
+
+/**
+ *
+ * @author rpiterman,ll93751
+ */
+public class ButtonList implements XItemEventBroadcaster, XActionListener
+{
+
+ private XFixedText lblImageText;
+ private XButton btnBack;
+ private XButton btnNext;
+ private XFixedText lblCounter;
+ private XControl m_aButtons[];
+ private boolean benabled = true;
+ private UnoDialog2 oUnoDialog;
+ private Size gap = new Size(4, 4);
+ private int cols = 4;
+ private int rows = 3;
+ private Size m_aButtonSize = new Size(20, 20);
+ private Size pos;
+ private Size selectionGap = new Size(2, 2);
+ private boolean showButtons = true;
+ private Short step;
+ private boolean refreshOverNull = true;
+ private int imageTextLines = 1;
+ private boolean rowSelect = false;
+ public int tabIndex;
+ public Boolean scaleImages = Boolean.TRUE;
+ private String m_aControlName = "il";
+ private int m_nCurrentSelection = -1;
+ private int pageStart = 0;
+ public int helpURL = 0;
+ private IImageRenderer renderer;
+ private ListModel listModel;
+ public IRenderer counterRenderer = new SimpleCounterRenderer();
+ private final static int LINE_HEIGHT = 8; //private MethodInvocation METHOD_MOUSE_ENTER_IMAGE;
+
+ /** Getter for property m_aButtonSize.
+ * @return Value of property m_aButtonSize.
+ *
+ */
+ public Size getButtonSize()
+ {
+ return this.m_aButtonSize;
+ }
+ public void setName(String _sName)
+ {
+ m_aControlName = _sName;
+ }
+
+ /** Setter for property m_aButtonSize.
+ * @param imageSize New value of property m_aButtonSize.
+ */
+ public void setButtonSize(Size imageSize)
+ {
+ this.m_aButtonSize = imageSize;
+ }
+
+// @Override
+ public void disposing(EventObject arg0)
+ {
+ // throw new UnsupportedOperationException("Not supported yet.");
+ }
+
+ public void create(UnoDialog2 dialog)
+ {
+ oUnoDialog = dialog;
+
+ int imageTextHeight = imageTextLines * LINE_HEIGHT;
+
+ int nXPos = pos.Width + 1;
+ int nYPos = pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height;
+ int nWidth = cols * (m_aButtonSize.Width + gap.Width) + gap.Width - 2;
+
+ lblImageText = dialog.insertLabel(m_aControlName + "_imageText",
+ new String[]
+ {
+ "Height",
+ "HelpURL",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Width"
+ },
+ new Object[]
+ {
+ Integer.valueOf(imageTextHeight),
+ "",
+ "(1)",
+ Integer.valueOf(nXPos),
+ Integer.valueOf(nYPos),
+ step,
+ Short.valueOf((short) 0),
+ Boolean.FALSE,
+ Integer.valueOf(nWidth)
+ });
+
+
+ if (showButtons)
+ {
+ final String[] pNames1 = new String[]
+ {
+ "Height",
+ "HelpURL",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Width"
+ };
+
+ final Integer btnSize = Integer.valueOf(14);
+
+// TODO: if list of strings not the same length of list object, office will die.
+ btnBack = dialog.insertButton(m_aControlName + "_btnBack", "prevPage", this, pNames1, new Object[]
+ {
+ btnSize,
+ HelpIds.getHelpIdString(helpURL++),
+ Integer.valueOf(pos.Width),
+ Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1),
+ step,
+ Short.valueOf((short) (tabIndex + 1)),
+ Boolean.TRUE,
+ btnSize
+ });
+
+ btnNext = dialog.insertButton(m_aControlName + "_btnNext", "nextPage", this, pNames1, new Object[]
+ {
+ btnSize,
+ HelpIds.getHelpIdString(helpURL++),
+ Integer.valueOf(pos.Width + (m_aButtonSize.Width + gap.Width) * cols + gap.Width - btnSize.intValue() + 1),
+ Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1),
+ step,
+ new Short((short) (tabIndex + 2)),
+ Boolean.TRUE,
+ btnSize
+ });
+
+ lblCounter = dialog.insertLabel(m_aControlName + "_lblCounter", pNames1, new Object[]
+ {
+ Integer.valueOf(LINE_HEIGHT),
+ "",
+ Integer.valueOf(pos.Width + btnSize.intValue() + 1),
+ Integer.valueOf(pos.Height + (m_aButtonSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + ((btnSize.intValue() - LINE_HEIGHT) / 2)),
+ step,
+ Short.valueOf((short) 0),
+ Boolean.FALSE,
+ Integer.valueOf(cols * (m_aButtonSize.Width + gap.Width) + gap.Width - 2 * btnSize.intValue() - 1)
+ });
+
+ Helper.setUnoPropertyValue(getModel(lblCounter), "Align", new Short((short) 1));
+ Helper.setUnoPropertyValue(getModel(btnBack), "Label", "<");
+ Helper.setUnoPropertyValue(getModel(btnNext), "Label", ">");
+
+
+ }
+
+ m_tabIndex = new Short((short) tabIndex);
+
+ m_aButtons = new XControl[rows * cols];
+
+
+ m_aButtonHeight = Integer.valueOf(m_aButtonSize.Height);
+ m_aButtonWidth = Integer.valueOf(m_aButtonSize.Width);
+
+ for (int r = 0; r < rows; r++)
+ {
+ for (int c = 0; c < cols; c++)
+ {
+ XButton aButton = createButton(dialog, r, c);
+ XControl aControl = (XControl)UnoRuntime.queryInterface(XControl.class, aButton);
+ m_aButtons[r * cols + c] = aControl;
+ }
+ }
+ refreshImages();
+ }
+
+ private Integer m_aButtonHeight;
+ private Integer m_aButtonWidth;
+ private Short m_tabIndex;
+
+ private XButton createButton(UnoDialog2 dialog, int _row, int _col)
+ {
+ String sButtonName = m_aControlName + "_button" + (_row * cols + _col);
+ int nButtonX = getButtonPosX(_col);
+ int nButtonY = getButtonPosY(_row);
+ XButton aButton = dialog.insertImageButton(sButtonName, this,
+ new String[]
+ {
+ /* "Border", */
+ /* "BackgroundColor", */
+ "Height",
+ "HelpURL",
+ /* "Label", */
+ "PositionX",
+ "PositionY",
+ /* "ScaleImage", */
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Toggle",
+ "Width"
+ },
+ new Object[]
+ {
+ /* Short.valueOf((short) 1), */ /* NO_BORDER, */
+ /* BACKGROUND_COLOR, */
+ m_aButtonHeight,
+ HelpIds.getHelpIdString(helpURL++),
+ /* "Test", */
+ Integer.valueOf(nButtonX),
+ Integer.valueOf(nButtonY),
+ /* scaleImages, */
+ step,
+ m_tabIndex,
+ Boolean.TRUE,
+ Boolean.TRUE, /* Toggle */
+ m_aButtonWidth
+ });
+
+ XWindow win = (XWindow) UnoRuntime.queryInterface(XWindow.class, aButton);
+ win.setEnable(true);
+ win.setVisible(true);
+ return aButton;
+ }
+
+ private int getButtonPosX(int _col)
+ {
+ final int nXPos = pos.Width + _col * (m_aButtonSize.Width + gap.Width) + gap.Width;
+ return nXPos;
+ }
+
+ private int getButtonPosY(int _row)
+ {
+ final int nYPos = pos.Height + _row * (m_aButtonSize.Height + gap.Height) + gap.Height;
+ return nYPos;
+ }
+
+ private void refreshImages()
+ {
+ if (showButtons)
+ {
+ refreshCounterText();
+ }
+ if (refreshOverNull)
+ {
+ for (int i = 0; i < m_aButtons.length; i++)
+ {
+ setVisible(m_aButtons[i], false);
+ }
+ }
+ boolean focusable = true;
+ for (int i = 0; i < m_aButtons.length; i++)
+ {
+ Object[] oResources = renderer.getImageUrls(getObjectFor(i));
+ if (oResources != null)
+ {
+ if (oResources.length == 1)
+ {
+ Helper.setUnoPropertyValue(m_aButtons[i].getModel(), "ImageURL", (String) oResources[0]);
+ }
+ else if (oResources.length == 2)
+ {
+ oUnoDialog.getPeerConfiguration().setImageUrl(m_aButtons[i].getModel(), oResources[0], oResources[1]);
+// Helper.setUnoPropertyValue(m_aButtons[i].getModel(), "ImageURL", oResources[0]);
+ }
+ boolean bTabStop = Boolean.TRUE; // focusable ? Boolean.TRUE : Boolean.FALSE;
+ Helper.setUnoPropertyValue(m_aButtons[i].getModel(), "Tabstop", bTabStop);
+ // Object aEnabled = Helper.getUnoPropertyValue(m_aButtons[i].getModel(), "Enabled");
+ if (refreshOverNull)
+ {
+ setVisible(m_aButtons[i], true);
+ }
+ focusable = false;
+ }
+ }
+// refreshSelection();
+ }
+
+ private void refreshCounterText()
+ {
+ Helper.setUnoPropertyValue(getModel(lblCounter), "Label", counterRenderer.render(new Counter(pageStart + 1, pageEnd(), listModel.getSize())));
+ }
+
+ private int pageEnd()
+ {
+ int i = pageStart + cols * rows;
+ if (i > listModel.getSize() - 1)
+ {
+ return listModel.getSize();
+ }
+ else
+ {
+ return i;
+ }
+ }
+
+ /** Utility field holding list of ItemListeners. */
+ private transient java.util.ArrayList<XItemListener> m_aItemListenerList;
+ private void setVisible(Object control, boolean visible)
+ {
+ final XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, control);
+ xWindow.setVisible(visible);
+ }
+
+ /**
+ *
+ * @param i
+ * @return the Object in the list model corresponding to the given image index.
+ */
+ private Object getObjectFor(int i)
+ {
+ int ii = getIndexFor(i);
+ if (listModel.getSize() <= ii)
+ {
+ return null;
+ }
+ else
+ {
+ return listModel.getElementAt(ii);
+ }
+ }
+
+ /**
+ *
+ * @param i
+ * @return the index in the listModel for the given image index.
+ */
+ private int getIndexFor(int i)
+ {
+ return pageStart + i;
+ }
+
+ private int getImageIndexFor(int i)
+ {
+ return i - pageStart;
+ }
+
+ public void contentsChanged(ListDataEvent event)
+ {
+ /*//if the content that was changed is in the displayed range, refresh...
+ if ( (event.getIndex1() < getIndexFor(0)) // range is before...
+ || event.getIndex0() > getIndexFor( cols*rows - 1)) ; //do nothing
+ else
+ refreshImages();
+ */ //m_nCurrentSelection = 0;
+ //pageStart = 0;
+ //if (event.refreshImages();
+ }
+
+ public void intervalAdded(ListDataEvent event)
+ {
+ if (event.getIndex0() <= m_nCurrentSelection)
+ {
+ if (event.getIndex1() <= m_nCurrentSelection)
+ {
+ m_nCurrentSelection += event.getIndex1() - event.getIndex0() + 1;
+ }
+ }
+ if (event.getIndex0() < pageStart || event.getIndex1() < (pageStart + getRows() + getCols()))
+ {
+ refreshImages();
+ }
+ }
+
+ public void intervalRemoved(ListDataEvent event)
+ {
+ //contentsChanged(event);
+ }
+
+ /** Registers ItemListener to receive events.
+ * @param listener The listener to register.
+ *
+ */
+ // @Override
+ public synchronized void addItemListener(XItemListener listener)
+ {
+ if (m_aItemListenerList == null)
+ {
+ m_aItemListenerList = new java.util.ArrayList<XItemListener>();
+ }
+ m_aItemListenerList.add(listener);
+ }
+
+ /** Removes ItemListener from the list of listeners.
+ * @param listener The listener to remove.
+ *
+ */
+ public synchronized void removeItemListener(XItemListener listener)
+ {
+ if (m_aItemListenerList != null)
+ {
+ m_aItemListenerList.remove(listener);
+ }
+ }
+
+ /** Notifies all registered listeners about the event.
+ *
+ * @param event The event to be fired
+ *
+ */
+ private void fireItemSelected()
+ {
+// java.awt.event.ItemEvent event = new java.awt.event.ItemEvent(this, 0,
+// getSelectedObject(), java.awt.event.ItemEvent.SELECTED);
+ java.util.ArrayList list;
+ synchronized(this)
+ {
+ if (m_aItemListenerList == null)
+ {
+ return;
+ }
+ list = (java.util.ArrayList) m_aItemListenerList.clone();
+ }
+ for (int i = 0; i < list.size(); i++)
+ {
+ ((com.sun.star.awt.XItemListener) list.get(i)).itemStateChanged(null);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public int getCols()
+ {
+ return cols;
+ }
+
+ /**
+ * @return
+ */
+ public Size getGap()
+ {
+ return gap;
+ }
+
+ /**
+ * @return
+ */
+ public ListModel getListModel()
+ {
+ return listModel;
+ }
+
+ /**
+ * @return
+ */
+ public Short getStep()
+ {
+ return step;
+ }
+
+ /**
+ * @return
+ */
+ public int getPageStart()
+ {
+ return pageStart;
+ }
+
+ /**
+ * @return
+ */
+ public Size getPos()
+ {
+ return pos;
+ }
+
+ /**
+ * @return
+ */
+ public IImageRenderer getRenderer()
+ {
+ return renderer;
+ }
+
+ /**
+ * @return
+ */
+ public int getRows()
+ {
+ return rows;
+ }
+
+ /**
+ * @return
+ */
+ public int getSelected()
+ {
+ return m_nCurrentSelection;
+ }
+
+ /**
+ * @return
+ */
+ public Size getSelectionGap()
+ {
+ return selectionGap;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isShowButtons()
+ {
+ return showButtons;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCols(int i)
+ {
+ cols = i;
+ }
+
+ /**
+ * @param size
+ */
+ public void setGap(Size size)
+ {
+ gap = size;
+ }
+
+ /**
+ * @param model
+ */
+ public void setListModel(ListModel model)
+ {
+ listModel = model;
+ }
+
+ /**
+ * @param short1
+ */
+ public void setStep(Short short1)
+ {
+ step = short1;
+ }
+
+ /**
+ * @param i
+ */
+ public void setPageStart(int i)
+ {
+ if (i == pageStart)
+ {
+ return;
+ }
+ pageStart = i;
+ enableButtons();
+ refreshImages();
+ }
+
+ /**
+ * @param _size
+ */
+ public void setPos(Size _size)
+ {
+ pos = _size;
+ }
+
+ /**
+ * @param _renderer
+ */
+ public void setRenderer(IImageRenderer _renderer)
+ {
+ this.renderer = _renderer;
+ }
+
+ /**
+ * @param i
+ */
+ public void setRows(int i)
+ {
+ rows = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setSelected(int i)
+ {
+ if (rowSelect && (i >= 0))
+ {
+ i = (i / cols) * cols;
+ }
+ if (m_nCurrentSelection == i)
+ {
+ return;
+ }
+ m_nCurrentSelection = i;
+ refreshImageText();
+ refreshSelection();
+ fireItemSelected();
+ }
+
+/*
+ public void setSelected(Object object)
+ {
+ if (object == null)
+ {
+ setSelected(-1);
+ }
+ else
+ {
+ for (int i = 0; i < getListModel().getSize(); i++)
+ {
+ if (getListModel().getElementAt(i).equals(object))
+ {
+ setSelected(i);
+ return;
+ }
+ }
+ }
+ setSelected(-1);
+
+ }
+*/
+
+ /**
+ * set the text under the button list
+ */
+ private void refreshImageText()
+ {
+ Object item = m_nCurrentSelection >= 0 ? getListModel().getElementAt(m_nCurrentSelection) : null;
+ final String sText = " " + renderer.render(item);
+ Helper.setUnoPropertyValue(getModel(lblImageText), "Label", sText);
+ }
+
+ /**
+ * @param size
+ */
+ public void setSelectionGap(Size size)
+ {
+ selectionGap = size;
+ }
+
+ /**
+ * @param b
+ */
+ public void setShowButtons(boolean b)
+ {
+ showButtons = b;
+ }
+
+ public void nextPage()
+ {
+ if (pageStart < getListModel().getSize() - rows * cols)
+ {
+ setPageStart(pageStart + rows * cols);
+ }
+ }
+
+ public void prevPage()
+ {
+ if (pageStart == 0)
+ {
+ return;
+ }
+ int i = pageStart - rows * cols;
+ if (i < 0)
+ {
+ i = 0;
+ }
+ setPageStart(i);
+ }
+
+ private void enableButtons()
+ {
+ enable(btnNext, new Boolean(pageStart + rows * cols < listModel.getSize()));
+ enable(btnBack, new Boolean(pageStart > 0));
+ }
+
+ private void enable(Object control, Boolean enable)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Enabled", enable);
+ }
+
+ private Object getModel(Object control)
+ {
+ return ((XControl) UnoRuntime.queryInterface(XControl.class, control)).getModel();
+ }
+
+ private void setBorder(Object control, Short border)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Border", border);
+ //XWindowPeer peer = ((XControl)UnoRuntime.queryInterface(XControl.class,control)).getPeer();
+ //peer.invalidate(InvalidateStyle.CHILDREN);
+ }
+
+
+ public Object[] getSelectedObjects()
+ {
+ return new Object[]
+ {
+ getListModel().getElementAt(m_nCurrentSelection)
+ };
+ }
+
+
+ /**
+ */
+ public static interface IImageRenderer extends IRenderer
+ {
+
+ /**
+ *
+ * @param listItem
+ * @return two resource ids for an image referenced in the imaglist resourcefile of the
+ * wizards project; The second one of them is designed to be used for High Contrast Mode.
+ */
+ public Object[] getImageUrls(Object listItem);
+ }
+
+ private static class SimpleCounterRenderer implements IRenderer
+ {
+
+ // @Override
+ public String render(Object counter)
+ {
+ return "" + ((Counter) counter).start + ".." + ((Counter) counter).end + "/" + ((Counter) counter).max;
+ }
+ }
+
+ public static class Counter
+ {
+
+ public int start, end, max;
+
+ public Counter(int start_, int end_, int max_)
+ {
+ start = start_;
+ end = end_;
+ max = max_;
+ }
+ }
+
+ public Object getSelectedObject()
+ {
+ return m_nCurrentSelection >= 0 ? getListModel().getElementAt(m_nCurrentSelection) : null;
+ }
+
+
+ public void setRowSelect(boolean b)
+ {
+ rowSelect = b;
+ }
+
+ public boolean isRowSelect()
+ {
+ return rowSelect;
+ }
+
+
+ /**
+ * jump to the given item (display the screen
+ * that contains the given item).
+ * @param i
+ */
+ public void display(int i)
+ {
+ int is = (getCols() * getRows());
+ int ps = (listModel.getSize() / is) * is;
+ setPageStart(ps);
+ }
+
+ /**
+ * @return
+ */
+ public boolean isenabled()
+ {
+ return benabled;
+ }
+
+ /**
+ * @param b
+ */
+ public void setenabled(boolean b)
+ {
+
+ for (int i = 0; i < m_aButtons.length; i++)
+ {
+ UnoDialog2.setEnabled(m_aButtons[i], b);
+ }
+// UnoDialog2.setEnabled(grbxSelectedImage, b);
+ UnoDialog2.setEnabled(lblImageText, b);
+ if (showButtons)
+ {
+ UnoDialog2.setEnabled(btnBack, b);
+ UnoDialog2.setEnabled(btnNext, b);
+ UnoDialog2.setEnabled(lblCounter, b);
+ }
+ benabled = b;
+ }
+
+/**
+ * refresh on all buttons, the selected button will get state pressed
+ */
+ private void refreshSelection()
+ {
+ // reset all buttons to not set
+ for (int i = 0; i < m_aButtons.length; i++)
+ {
+ if (m_aButtons[i] != null)
+ {
+ XControlModel xModel = (XControlModel)UnoDialog2.getModel(m_aButtons[i]);
+ PropertySetHelper aHelper = new PropertySetHelper(xModel);
+ if (i == m_nCurrentSelection)
+ {
+ final short one = 1;
+ aHelper.setPropertyValueDontThrow("State", Short.valueOf(one));
+ }
+ else
+ {
+ final short zero = 0;
+ aHelper.setPropertyValueDontThrow("State", Short.valueOf(zero));
+ }
+ }
+ }
+ }
+
+/**
+ * implementation of XActionListener
+ * will call if a button from the m_aButtonList is pressed.
+ * @param actionEvent
+ */
+// @Override
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ // bStopProcess = true;
+ XControlModel xModel = (XControlModel)UnoDialog2.getModel(actionEvent.Source);
+ PropertySetHelper aHelper = new PropertySetHelper(xModel);
+
+ int nState = aHelper.getPropertyValueAsInteger("State", -1);
+ if (nState == 0)
+ {
+ // this will avoid a wrong state, if already pressed.
+ aHelper.setPropertyValueDontThrow("State", Short.valueOf((short)1));
+ }
+
+ // check which Button is pressed.
+ String sControlName = aHelper.getPropertyValueAsString("Name", "");
+ final String sButton = sControlName.substring(7 + m_aControlName.length());
+ int nButton = new Integer(sButton).intValue();
+
+ // int image = getImageFromEvent(event);
+ int index = getIndexFor(nButton);
+ if (index < listModel.getSize())
+ {
+ // focus(image);
+ setSelected(index);
+ }
+
+ }
+
+
+}
diff --git a/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java
new file mode 100644
index 000000000000..c239c9fec4d2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/CommandFieldSelection.java
@@ -0,0 +1,474 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.db.*;
+// import com.sun.star.awt.XWindow;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.sdb.CommandType;
+// import com.sun.star.sdbc.SQLException;
+import com.sun.star.uno.AnyConverter;
+// import com.sun.star.uno.UnoRuntime;
+import com.sun.star.awt.*;
+import com.sun.star.beans.PropertyValue;
+import java.text.Collator;
+import java.util.Comparator;
+
+public class CommandFieldSelection extends FieldSelection implements Comparator
+{
+
+ private CommandMetaData CurDBMetaData;
+ private XListBox xTableListBox;
+ private XFixedText xlblTable;
+ // private String SFILLUPFIELDSLISTBOX = "fillUpFieldsListbox";
+ private String sTableListBoxName;
+ private String sTableLabelName;
+ private String sQueryPrefix;
+ private String sTablePrefix;
+ private short m_iSelPos = -1;
+ private short iOldSelPos = -1;
+ private boolean bpreselectCommand = true;
+ private boolean bgetQueries;
+ // boolean AppendMode;
+ private WizardDialog oWizardDialog;
+ private Collator aCollator = null;
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
+ {
+ short[] SelItems = (short[]) CurUnoDialog.getControlProperty(sTableListBoxName, "SelectedItems");
+ if (SelItems.length > 0)
+ {
+ iOldSelPos = m_iSelPos;
+ m_iSelPos = SelItems[0];
+ if ((m_iSelPos > -1) && (m_iSelPos != iOldSelPos))
+ {
+ if (!AppendMode)
+ {
+ oWizardDialog.enablefromStep(IStep.intValue() + 1, false);
+ }
+ fillUpFieldsListbox();
+ }
+ }
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+
+ /**
+ * instantiates a CommandFieldSelection with a preselected command
+ * @param _CurUnoDialog
+ * @param _CurDBMetaData
+ * @param iStep
+ * @param _iHeight
+ * @param _reslblFields
+ * @param _reslblSelFields
+ * @param _reslblTables
+ * @param _bgetQueries
+ * @param _ifirstHID
+ */
+ public CommandFieldSelection(WizardDialog _CurUnoDialog, CommandMetaData _CurDBMetaData, int iStep, int _iHeight, String _reslblFields, String _reslblSelFields, String _reslblTables, boolean _bgetQueries, int _ifirstHID)
+ {
+ super(_CurUnoDialog, iStep, 95, 57, 210, _iHeight, _reslblFields, _reslblSelFields, (_ifirstHID + 1), true);
+ insertControls(_CurDBMetaData, _bgetQueries, _reslblTables);
+ oWizardDialog = (WizardDialog) CurUnoDialog;
+ }
+
+ /**
+ * instantiates a CommandFieldSelection with a preselected command
+ * @param _CurUnoDialog
+ * @param _CurDBMetaData
+ * @param _iHeight
+ * @param _reslblFields
+ * @param _reslblSelFields
+ * @param _reslblTables
+ * @param _bgetQueries
+ * @param _ifirstHID
+ */
+ public CommandFieldSelection(UnoDialog _CurUnoDialog, CommandMetaData _CurDBMetaData, int _iHeight, String _reslblFields, String _reslblSelFields, String _reslblTables, boolean _bgetQueries, int _ifirstHID)
+ {
+ super(_CurUnoDialog, 1, 95, 57, 210, _iHeight, _reslblFields, _reslblSelFields, (_ifirstHID + 1), true);
+ insertControls(_CurDBMetaData, _bgetQueries, _reslblTables);
+ oWizardDialog = (WizardDialog) CurUnoDialog;
+ }
+
+ private void insertControls(CommandMetaData _CurDBMetaData, boolean _bgetQueries, String _reslblTables)
+ {
+ try
+ {
+ this.AppendMode = !_bgetQueries;
+ this.bgetQueries = _bgetQueries;
+ this.CurDBMetaData = _CurDBMetaData;
+ toggleListboxControls(Boolean.FALSE);
+ sTableLabelName = "lblTables_" + super.sIncSuffix;
+ sTableListBoxName = "lstTables_" + super.sIncSuffix;
+ sTablePrefix = getTablePrefix();
+ sQueryPrefix = getQueryPrefix();
+ Integer LabelWidth = new Integer(getListboxWidth().intValue() + 6);
+ // Label 'Tables or Queries'
+ xlblTable = CurUnoDialog.insertLabel(sTableLabelName,
+ new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(8), _reslblTables, new Integer(95), new Integer(27), IStep, new Short((short) 3), LabelWidth
+ });
+ // DropDown Listbox TableNames
+ xTableListBox = CurUnoDialog.insertListBox(sTableListBoxName, 0, null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Dropdown", "Enabled", "Height", "HelpURL", "LineCount", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, Boolean.FALSE, new Integer(12), HelpIds.getHelpIdString(super.FirstHelpIndex - 1), new Short(UnoDialog.getListBoxLineCount()), new Integer(95), new Integer(37), IStep, new Short((short) 4), getListboxWidth()
+ });
+ // XWindow xTableListBoxWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xTableListBox);
+ fillupCommandListBox();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * @return Returns the sQueryPrefix.
+ */
+ public String getQueryPrefix()
+ {
+ if (sQueryPrefix == null)
+ {
+ sQueryPrefix = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 22);
+ }
+ return sQueryPrefix;
+ }
+
+ private String getCommandPrefix(int _nCommandType)
+ {
+ if (_nCommandType == CommandType.TABLE)
+ {
+ return getTablePrefix();
+ }
+ else if (_nCommandType == CommandType.QUERY)
+ {
+ return getQueryPrefix();
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ /**
+ * @return Returns the sTablePrefix.
+ */
+ public String getTablePrefix()
+ {
+ if (sTablePrefix == null)
+ {
+ sTablePrefix = CurUnoDialog.m_oResource.getResText(UIConsts.RID_QUERY + 21);
+ }
+ return sTablePrefix;
+ }
+
+ private short getselectedItemPos()
+ {
+ short[] iSelPoses = ((short[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems"));
+ if (iSelPoses.length > 0)
+ {
+ return iSelPoses[0];
+ }
+ else
+ {
+ if (this.bpreselectCommand)
+ {
+ String[] sItemList = ((String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), "StringItemList"));
+ if (sItemList.length > 0)
+ {
+ return (short) 0;
+ }
+ }
+ return (short) -1;
+ }
+ }
+
+ public void fillUpFieldsListbox()
+ {
+ try
+ {
+ boolean binitialize = false;
+ String curCommandName = "";
+ //As the peer of the control might not yet exist we have to query the model for the SelectedItems
+ short iSelPos = getselectedItemPos();
+ // String[] sLocList = (String[]) CurUnoDialog.getControlProperty(sTableListBoxName, "StringItemList");
+ final String sSelectedTableName = xTableListBox.getItem(iSelPos);
+ if (!bgetQueries)
+ {
+ curCommandName = sSelectedTableName; // sLocList[iSelPos];
+ CurDBMetaData.setTableByName(curCommandName);
+ binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.TABLE, AppendMode);
+ }
+ else
+ {
+ if (sSelectedTableName.startsWith(sTablePrefix))
+ {
+ CurDBMetaData.setCommandType(CommandType.TABLE);
+ curCommandName = JavaTools.replaceSubString(sSelectedTableName, "", sTablePrefix);
+ CurDBMetaData.setTableByName(curCommandName);
+ binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.TABLE, AppendMode);
+ }
+ else
+ {
+ CurDBMetaData.setCommandType(CommandType.QUERY);
+ curCommandName = JavaTools.replaceSubString(sSelectedTableName, "", sQueryPrefix);
+ CurDBMetaData.setQueryByName(curCommandName);
+ binitialize = CurDBMetaData.getFieldNamesOfCommand(curCommandName, CommandType.QUERY, AppendMode);
+ }
+ }
+ if (binitialize)
+ {
+ CurDBMetaData.setCommandName(curCommandName);
+ if (CurDBMetaData.m_aAllFieldNames != null)
+ {
+ if (CurDBMetaData.m_aAllFieldNames.length > 0)
+ {
+ initialize(CurDBMetaData.m_aAllFieldNames, AppendMode, CurDBMetaData.getMaxColumnsInSelect());
+ return;
+ }
+ }
+ }
+ emptyFieldsListBoxes();
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /** returns the selected entry index in the commandListbox
+ *
+ * @return
+ * @throws com.sun.star.wizards.common.TerminateWizardException
+ */
+ private short fillupCommandListBox() throws com.sun.star.wizards.common.TerminateWizardException
+ {
+ short[] iSelArray = new short[0];
+ boolean bgetFields = false;
+ String[] ContentList = new String[0];
+ // CurDBMetaData.initCommandNames();
+ if (bgetQueries)
+ {
+ ContentList = new String[CurDBMetaData.getTableNames().length + CurDBMetaData.getQueryNames().length];
+ System.arraycopy(CurDBMetaData.getQueryNames(), 0, ContentList, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length);
+ ContentList = setPrefixinArray(ContentList, sQueryPrefix, CurDBMetaData.getTableNames().length, CurDBMetaData.getQueryNames().length);
+ }
+ else
+ {
+ ContentList = new String[CurDBMetaData.getTableNames().length];
+ }
+ System.arraycopy(CurDBMetaData.getTableNames(), 0, ContentList, 0, CurDBMetaData.getTableNames().length);
+ if (bgetQueries)
+ {
+ ContentList = setPrefixinArray(ContentList, sTablePrefix, 0, CurDBMetaData.getTableNames().length);
+ }
+ java.util.Arrays.sort(ContentList, this);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "StringItemList", ContentList);
+ short iSelPos = getselectedItemPos();
+ if (bpreselectCommand)
+ {
+ if (iSelPos > -1)
+ {
+ bgetFields = true;
+ iSelArray = new short[]
+ {
+ iSelPos
+ };
+ }
+ }
+ else
+ {
+ emptyFieldsListBoxes();
+ iSelArray = new short[] { (short) iSelPos };
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", iSelArray);
+ toggleCommandListBox(true);
+ if (bgetFields)
+ {
+ fillUpFieldsListbox();
+ }
+ return iSelPos;
+ }
+
+ private Collator getCollator()
+ {
+ if (this.aCollator == null)
+ {
+ com.sun.star.lang.Locale aOfficeLocale = Configuration.getOfficeLocale(this.CurDBMetaData.xMSF);
+ java.util.Locale aJavaLocale = new java.util.Locale(aOfficeLocale.Language, aOfficeLocale.Country, aOfficeLocale.Variant);
+ //Get the Collator for US English and set its strength to PRIMARY
+ this.aCollator = Collator.getInstance(aJavaLocale);
+ aCollator.setStrength(Collator.TERTIARY);
+ }
+ return aCollator;
+ }
+
+ public int compare(Object _oObject1, Object _oObject2)
+ {
+ return this.getCollator().compare(_oObject1, _oObject2);
+ }
+
+ private String[] setPrefixinArray(String[] _ContentList, String _sprefix, int _startindex, int _nlen)
+ {
+ for (int i = _startindex; i < _startindex + _nlen; i++)
+ {
+ _ContentList[i] = _sprefix + _ContentList[i];
+ }
+ return _ContentList;
+ }
+
+ public void toggleCommandListBox(String[] _NewItems)
+ {
+ boolean bdoenable = !(QueryMetaData.getIncludedCommandNames(_NewItems).length >= CurDBMetaData.getMaxTablesInSelect());
+ toggleCommandListBox(bdoenable);
+ }
+
+ public void toggleCommandListBox(boolean _bdoenable)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "Enabled", new Boolean(_bdoenable));
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xlblTable), "Enabled", new Boolean(_bdoenable));
+ }
+
+ public String getSelectedCommandName()
+ {
+ String sCommandname = xTableListBox.getSelectedItem();
+ if (sCommandname.startsWith(this.sTablePrefix))
+ {
+ return sCommandname.substring(sTablePrefix.length());
+ }
+ else if ((sCommandname.startsWith(this.sQueryPrefix)))
+ {
+ return sCommandname.substring(sQueryPrefix.length());
+ }
+ else
+ {
+ return sCommandname;
+ }
+ }
+
+ public int getSelectedCommandType()
+ {
+ String sCommandname = xTableListBox.getSelectedItem();
+ if (sCommandname.startsWith(this.sTablePrefix))
+ {
+ return CommandType.TABLE;
+ }
+ else
+ {
+ return CommandType.QUERY;
+ }
+ }
+
+ public void preselectCommand(PropertyValue[] _aPropertyValue, boolean _bReadOnly)
+ {
+ try
+ {
+ if (Properties.hasPropertyValue(_aPropertyValue, "CommandType"))
+ {
+ int nCommandType = AnyConverter.toInt(Properties.getPropertyValue(_aPropertyValue, "CommandType"));
+ String sCommand = AnyConverter.toString(Properties.getPropertyValue(_aPropertyValue, "Command"));
+ if (sCommand != null)
+ {
+ preselectCommand(sCommand, nCommandType, _bReadOnly);
+ }
+ }
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void preselectCommand(String _selitem, int _nCommandType, boolean _bReadOnly)
+ {
+ if (_selitem.length() > 0)
+ {
+ String[] sitems = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), "StringItemList");
+ String sPrefix = getCommandPrefix(_nCommandType);
+ short iselpos = (short) JavaTools.FieldInList(sitems, sPrefix + _selitem);
+ if (iselpos > -1)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[]
+ {
+ iselpos
+ });
+ }
+ this.fillUpFieldsListbox();
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[]
+ {
+ });
+ }
+ if (_bReadOnly)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "ReadOnly", new Boolean(_selitem.length() > 0));
+ }
+ }
+
+ public void preselectCommand(String _selitem, boolean _bReadOnly)
+ {
+ if (_selitem.length() > 0)
+ {
+ String[] sitems = (String[]) Helper.getUnoPropertyValue(UnoDialog.getModel(xTableListBox), "StringItemList");
+ short iselpos = (short) JavaTools.FieldInList(sitems, getTablePrefix() + _selitem);
+ if (iselpos > -1)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[] { iselpos });
+ }
+ this.fillUpFieldsListbox();
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "SelectedItems", new short[] {} );
+ this.fillUpFieldsListbox();
+ }
+ if (_bReadOnly)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xTableListBox), "ReadOnly", new Boolean(_selitem.length() > 0));
+ }
+ toggleListboxButtons((short)-1,(short)-1);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/ControlScroller.java b/wizards/com/sun/star/wizards/ui/ControlScroller.java
new file mode 100644
index 000000000000..aff4de7127c9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/ControlScroller.java
@@ -0,0 +1,510 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.XScrollBar;
+import com.sun.star.awt.AdjustmentEvent;
+import com.sun.star.beans.*;
+import com.sun.star.awt.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.common.HelpIds;
+
+import java.util.*;
+
+public abstract class ControlScroller
+{
+
+ protected WizardDialog CurUnoDialog;
+ protected XMultiServiceFactory xMSF;
+ private Object oImgControl;
+ protected int ncurfieldcount;
+ protected int nblockincrement;
+ private int nlineincrement;
+ protected int nscrollvalue = 0;
+ protected int ntotfieldcount;
+ XScrollBar xScrollBar;
+ protected Vector scrollfields;
+ protected Integer ICompPosX;
+ protected int iCompPosX;
+ protected Integer ICompPosY;
+ protected int iCompPosY;
+ protected Integer ICompWidth;
+ protected int iCompWidth;
+ protected Integer ICompHeight;
+ protected int iCompHeight;
+ protected int iStartPosY;
+ protected short curtabindex;
+ int iStep;
+ protected Integer IStep;
+ protected int linedistance;
+ int iScrollBarWidth = 10;
+ int SORELFIRSTPOSY = 3;
+ protected int curHelpIndex;
+ String sIncSuffix;
+ protected Vector ControlGroupVector = new Vector();
+ protected PeerConfig oTitlePeerConfig;
+
+ class AdjustmentListenerImpl implements com.sun.star.awt.XAdjustmentListener
+ {
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+
+ public void adjustmentValueChanged(AdjustmentEvent AdjustEvent)
+ {
+ scrollControls();
+ }
+ }
+
+ /**
+ *
+ * @param _CurUnoDialog
+ * @param iStep
+ * @param iCompPosX
+ * @param iCompPosY
+ * @param iCompWidth
+ * @param _nblockincrement
+ * @param _firsthelpindex
+ * @author bc93774
+ */
+ // TODO add parameters for tabindices and helpindex
+ protected ControlScroller(WizardDialog _CurUnoDialog, XMultiServiceFactory _xMSF, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _nblockincrement, int _nlinedistance, int _firsthelpindex)
+ {
+ this.xMSF = _xMSF;
+ this.nblockincrement = _nblockincrement;
+ this.CurUnoDialog = _CurUnoDialog;
+ this.iStep = _iStep;
+ this.curHelpIndex = _firsthelpindex;
+ curtabindex = UnoDialog.setInitialTabindex(iStep);
+ this.linedistance = _nlinedistance;
+ IStep = new Integer(iStep);
+ this.iCompPosX = _iCompPosX;
+ this.iCompPosY = _iCompPosY;
+ this.ICompPosX = new Integer(iCompPosX);
+ this.ICompPosY = new Integer(iCompPosY);
+ this.iCompWidth = _iCompWidth;
+ this.ICompWidth = new Integer(iCompWidth);
+ this.iCompHeight = 2 * SORELFIRSTPOSY + nblockincrement * linedistance;
+ iStartPosY = iCompPosY + SORELFIRSTPOSY;
+ int ScrollHeight = iCompHeight - 2;
+ nlineincrement = 1;
+ sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "imgBackground");
+ oImgControl = CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlImageControlModel", "imgBackground" + sIncSuffix,
+ new String[]
+ {
+ "Border", "Height", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Short("1"), new Integer(iCompHeight), ICompPosX, new Integer(iCompPosY), IStep, ICompWidth
+ });
+ oImgControl = CurUnoDialog.xDlgContainer.getControl("imgBackground" + sIncSuffix);
+ setComponentMouseTransparent();
+ xScrollBar = CurUnoDialog.insertScrollBar("TitleScrollBar" + sIncSuffix, 0,
+ new AdjustmentListenerImpl(),
+ new String[]
+ {
+ "Border", "Enabled", "Height", "HelpURL", "Orientation", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 0), new Boolean(true), new Integer(ScrollHeight), HelpIds.getHelpIdString(curHelpIndex), new Integer(ScrollBarOrientation.VERTICAL), new Integer(iCompPosX + iCompWidth - iScrollBarWidth - 1), new Integer(iCompPosY + 1), IStep, new Integer(iScrollBarWidth)
+ });
+ scrollfields = new Vector();
+ int ypos = iStartPosY + SORELFIRSTPOSY;
+ for (int i = 0; i < nblockincrement; i++)
+ {
+ insertControlGroup(i, ypos);
+ ypos += linedistance;
+ }
+ }
+
+ public void setComponentMouseTransparent()
+ {
+ CurUnoDialog.getPeerConfiguration().setPeerProperties(oImgControl, new String[]
+ {
+ "MouseTransparent"
+ }, new Boolean[]
+ {
+ Boolean.TRUE
+ });
+ }
+
+ protected void setScrollBarOrientationHorizontal()
+ {
+ Helper.setUnoPropertyValue(xScrollBar, "Orientation", new Integer(ScrollBarOrientation.HORIZONTAL));
+ }
+
+ /**
+ * @author bc93774
+ * @param _ntotfieldcount: The number of fields that are to be administered by the ControlScroller
+ */
+ protected void initialize(int _ntotfieldcount)
+ {
+ try
+ {
+ boolean bisVisible;
+ ntotfieldcount = _ntotfieldcount;
+ setCurFieldCount();
+ nscrollvalue = 0;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), new String("ScrollValue"), new Integer(nscrollvalue));
+ if (ntotfieldcount > nblockincrement)
+ {
+ Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
+ {
+ "Enabled", "BlockIncrement", "LineIncrement", "ScrollValue", "ScrollValueMax"
+ }, new Object[]
+ {
+ Boolean.TRUE, new Integer(nblockincrement), new Integer(nlineincrement), new Integer(nscrollvalue), new Integer(ntotfieldcount - nblockincrement)
+ });
+ }
+ else
+ {
+ Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
+ {
+ "Enabled", "ScrollValue"
+ }, new Object[]
+ {
+ Boolean.FALSE, new Integer(nscrollvalue)
+ });
+ }
+ fillupControls(true);
+ }
+ catch (java.lang.Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void fillupControls(boolean binitialize)
+ {
+ int newindex;
+ PropertyValue[] oldproperties;
+ PropertyValue[] newproperties;
+ for (int a = 0; a < this.nblockincrement; a++)
+ {
+ if (a < ncurfieldcount)
+ {
+ fillupControls(a);
+ }
+ if (binitialize)
+ {
+ setControlGroupVisible(a, (a < this.ncurfieldcount));
+ }
+ }
+ if (binitialize)
+ {
+ CurUnoDialog.repaintDialogStep();
+ }
+ }
+
+ protected void fillupControls(int guiRow)
+ {
+ PropertyValue[] nameProps = (PropertyValue[]) scrollfields.get(guiRow);
+ PropertyValue[] valueProps = (PropertyValue[]) scrollfields.get(guiRow + nscrollvalue);
+ for (int n = 0; n < nameProps.length; n++)
+ {
+ if (CurUnoDialog.getDlgNameAccess().hasByName(nameProps[n].Name))
+ {
+ setControlData(nameProps[n].Name, valueProps[n].Value);
+ }
+ else
+ {
+ throw new IllegalArgumentException("No such control !");
+ }
+ }
+ }
+
+ protected void setScrollValue(int _nscrollvalue)
+ {
+ if (_nscrollvalue >= 0)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), new String("ScrollValue"), new Integer(_nscrollvalue));
+ scrollControls();
+ }
+ }
+
+ protected void setScrollValue(int _nscrollvalue, int _ntotfieldcount)
+ {
+ setTotalFieldCount(_ntotfieldcount);
+ setScrollValue(_nscrollvalue);
+ }
+
+ protected int getTotalFieldCount()
+ {
+ return ntotfieldcount;
+ }
+
+ protected int getCurFieldCount()
+ {
+ return ncurfieldcount;
+ }
+
+ private void setCurFieldCount()
+ {
+ if (ntotfieldcount > nblockincrement)
+ {
+ ncurfieldcount = nblockincrement;
+ }
+ else
+ {
+ ncurfieldcount = ntotfieldcount;
+ }
+ }
+
+ protected void setTotalFieldCount(int _ntotfieldcount)
+ {
+ this.ntotfieldcount = _ntotfieldcount;
+ setCurFieldCount();
+ if (ntotfieldcount > nblockincrement)
+ {
+ Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
+ {
+ "Enabled", "ScrollValueMax"
+ }, new Object[]
+ {
+ Boolean.TRUE, new Integer(ntotfieldcount - nblockincrement)
+ });
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), "Enabled", Boolean.FALSE);
+ }
+ }
+
+ protected void toggleComponent(boolean _bdoenable)
+ {
+ boolean bdoenable = _bdoenable && (ntotfieldcount > nblockincrement);
+ CurUnoDialog.setControlProperty("TitleScrollBar" + sIncSuffix, "Enabled", new Boolean(bdoenable));
+ }
+
+ protected void toggleControls(boolean _bdoenable)
+ {
+ for (int n = 0; n < scrollfields.size(); n++)
+ {
+ PropertyValue[] curproperties = (PropertyValue[]) scrollfields.elementAt(n);
+ for (int m = 0; m < curproperties.length; m++)
+ {
+ PropertyValue curproperty = curproperties[m];
+ CurUnoDialog.setControlProperty(curproperty.Name, "Enabled", new Boolean(_bdoenable));
+ }
+ }
+
+ }
+
+ protected int getScrollValue()
+ {
+ return nscrollvalue;
+ }
+
+ protected void setLineIncrementation(int _nlineincrement)
+ {
+ this.nlineincrement = _nlineincrement;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xScrollBar), new String("LineIncrement"), new Integer(nlineincrement));
+
+ }
+
+ protected int getLineIncrementation()
+ {
+ return nlineincrement;
+ }
+
+ protected void setBlockIncrementation(int _nblockincrement)
+ {
+ this.nblockincrement = _nblockincrement;
+ Helper.setUnoPropertyValues(UnoDialog.getModel(xScrollBar), new String[]
+ {
+ "Enabled", "BlockIncrement", "ScrollValueMax"
+ }, new Object[]
+ {
+ new Boolean(ntotfieldcount > nblockincrement), new Integer(nblockincrement), new Integer(ntotfieldcount - nblockincrement)
+ });
+ }
+
+ protected int getBlockIncrementation()
+ {
+ return nblockincrement;
+ }
+
+ private void scrollControls()
+ {
+ try
+ {
+ scrollRowsInfo();
+ nscrollvalue = ((Integer) Helper.getUnoPropertyValue(UnoDialog.getModel(xScrollBar), "ScrollValue")).intValue();
+ if (nscrollvalue + nblockincrement >= ntotfieldcount)
+ {
+ nscrollvalue = (ntotfieldcount) - nblockincrement;
+ }
+ fillupControls(false);
+ }
+ catch (java.lang.Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void scrollRowsInfo()
+ {
+ int cols =
+ scrollfields.size() > 0
+ ? ((PropertyValue[]) scrollfields.get(0)).length
+ : 0;
+ for (int a = 0; a < ncurfieldcount; a++)
+ {
+ for (int n = 0; n < cols; n++)
+ {
+ fieldInfo(a, n);
+ }
+ }
+ }
+
+ /**
+ * updates the corresponding data to
+ * the control in guiRow and column
+ * @param guiRow 0 based row index
+ * @param column 0 based column index
+ * @return the propertyValue object corresponding to
+ * this control.
+ */
+ protected PropertyValue fieldInfo(int guiRow, int column)
+ {
+ if (guiRow + nscrollvalue < scrollfields.size())
+ {
+ PropertyValue pv = fieldInfo(
+ ((PropertyValue[]) scrollfields.elementAt(guiRow + nscrollvalue))[column],
+ ((PropertyValue[]) scrollfields.elementAt(guiRow))[column]);
+ //System.out.println("getting field info for : " + guiRow + "/" + column + ":" + pv.Value + "(" + pv.Name + ")" );
+
+ return pv;
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected PropertyValue fieldInfo(PropertyValue valueProp, PropertyValue nameProp)
+ {
+ if (CurUnoDialog.getDlgNameAccess().hasByName(nameProp.Name))
+ {
+ valueProp.Value = getControlData(nameProp.Name);
+ }
+ else
+ {
+ valueProp.Value = nameProp.Value;
+ }
+ return valueProp;
+ }
+
+ protected void unregisterControlGroup(int _index)
+ {
+ scrollfields.remove(_index);
+ }
+
+ protected void registerControlGroup(PropertyValue[] _currowproperties, int _i)
+ {
+ if (_i == 0)
+ {
+ scrollfields.removeAllElements();
+ }
+ if (_i >= scrollfields.size())
+ {
+ scrollfields.addElement(_currowproperties);
+ }
+ else
+ {
+ scrollfields.setElementAt(_currowproperties, _i);
+ }
+ }
+
+ protected PropertyValue[] getControlGroupInfo(int _i)
+ {
+ return (PropertyValue[]) scrollfields.elementAt(_i);
+ }
+
+ protected void setControlData(String controlname, Object newvalue)
+ {
+ Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname));
+ String propertyname = UnoDialog.getDisplayProperty(oControlModel);
+ if (propertyname != "")
+ {
+ CurUnoDialog.setControlProperty(controlname, propertyname, newvalue);
+ }
+ }
+
+ protected Object getControlData(String controlname)
+ {
+ Object oControlModel = UnoDialog.getModel(CurUnoDialog.xDlgContainer.getControl(controlname));
+ String propertyname = UnoDialog.getDisplayProperty(oControlModel);
+ if (propertyname != "")
+ {
+ return CurUnoDialog.getControlProperty(controlname, propertyname);
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ protected PropertyValue[][] getScrollFieldValues()
+ {
+ scrollRowsInfo();
+ PropertyValue[] curproperties;
+ PropertyValue[][] retproperties;
+ retproperties = new PropertyValue[scrollfields.size()][];
+ try
+ {
+ for (int i = 0; i < scrollfields.size(); i++)
+ {
+ curproperties = (PropertyValue[]) scrollfields.elementAt(i);
+ retproperties[i] = curproperties;
+ }
+ return retproperties;
+ }
+ catch (java.lang.Exception ex)
+ {
+ ex.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ protected abstract void initializeScrollFields();
+
+ /** inserts a group of controls into the component. The group may either be a row or a column of controls
+ * The controls should be put on Step 99 (means made invisible at first). All the controlrows that are needed are than
+ * made visible automatically when calling "initialize(_fieldcount)"
+ * @author bc93774
+ * @param i: The index of the control group
+ * @param npos: Can be an x coordinate or an y coordinate which depends on the orientation of the scrollbar
+ */
+ protected abstract void insertControlGroup(int _index, int npos);
+
+ protected abstract void setControlGroupVisible(int _index, boolean _bIsVisible);
+}
diff --git a/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java
new file mode 100644
index 000000000000..341ab73828c5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/DBLimitedFieldSelection.java
@@ -0,0 +1,158 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.XListBox;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+
+/**
+ * @author Administrator
+ *
+ * To change the template for this generated type comment go to
+ * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
+ */
+public abstract class DBLimitedFieldSelection
+{
+
+ protected XMultiServiceFactory xMSF;
+ protected WizardDialog CurUnoDialog;
+ protected String sNoField;
+ protected Integer IStep;
+ protected Integer ICompPosX;
+ protected Integer ICompPosY;
+ protected Integer ICompWidth;
+ protected final int rowcount = 4;
+ protected final int MAXSELINDEX = rowcount - 1;
+ protected short curtabindex;
+ protected int iCurPosY;
+ protected int FirstHelpIndex;
+ protected int iCompPosX;
+ // protected int MaxSelIndex;
+
+ public DBLimitedFieldSelection(WizardDialog _CurUnoDialog, int iStep, int _iCompPosX, int iCompPosY, int iCompWidth, int _FirstHelpIndex)
+ {
+ this.CurUnoDialog = _CurUnoDialog;
+ xMSF = CurUnoDialog.xMSF;
+ FirstHelpIndex = _FirstHelpIndex;
+ curtabindex = (short) (iStep * 100);
+ sNoField = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 8);
+ IStep = new Integer(iStep);
+ iCompPosX = _iCompPosX;
+ ICompPosX = new Integer(iCompPosX);
+ ICompPosY = new Integer(iCompPosY);
+ ICompWidth = new Integer(iCompWidth);
+ // boolean bDoEnable;
+ iCurPosY = iCompPosY;
+ for (int i = 0; i < rowcount; i++)
+ {
+ insertControlGroup(i);
+ }
+ }
+
+ protected abstract void insertControlGroup(int index);
+
+ protected abstract void toggleControlRow(int CurIndex, boolean bDoEnable);
+
+ protected abstract void enableNextControlRow(int CurIndex);
+
+ protected abstract void updateFromNextControlRow(int CurIndex);
+
+ // protected abstract void setMaxSelIndex();
+
+ protected abstract int getMaxSelIndex();
+
+ protected void moveupSelectedItems(int CurIndex, boolean bDoEnable)
+ {
+ // short iNextItemPos;
+ if ((bDoEnable == false) && (MAXSELINDEX > CurIndex))
+ {
+ for (int i = CurIndex; i < MAXSELINDEX; i++)
+ {
+ updateFromNextControlRow(i);
+ }
+ if (getMaxSelIndex() < rowcount - 2)
+ {
+ toggleControlRow(getMaxSelIndex() + 2, false);
+ }
+ }
+ else
+ {
+ toggleControlRow(CurIndex + 1, bDoEnable);
+ }
+ }
+
+ protected String[] addNoneFieldItemToList(String[] _FieldNames)
+ {
+ int FieldCount = _FieldNames.length;
+ String[] ViewFieldNames = new String[FieldCount + 1];
+ ViewFieldNames[0] = sNoField;
+ for (int i = 0; i < FieldCount; i++)
+ {
+ ViewFieldNames[i + 1] = _FieldNames[i];
+ }
+ return ViewFieldNames;
+ }
+
+ protected void initializeListBox(XListBox xListBox, String[] _AllFieldNames, String[] _SelFieldNames, int curindex)
+ {
+ short[] SelList = null;
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), "StringItemList", _AllFieldNames);
+ if (_SelFieldNames != null)
+ {
+ if (curindex < _SelFieldNames.length)
+ {
+ int index = JavaTools.FieldInList(_AllFieldNames, _SelFieldNames[curindex]);
+ if (index > -1)
+ {
+ SelList = new short[] { (short) (index) };
+ }
+ else
+ {
+ SelList = new short[] { (short) (0) };
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), "SelectedItems", SelList);
+ return;
+ }
+ }
+ SelList = new short[] { (short) (0) };
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), "SelectedItems", SelList);
+
+ }
+
+ protected void initializeListBox(XListBox xListBox, String[] _AllFieldNames, String _SelFieldName)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), "StringItemList", _AllFieldNames);
+ short[] SelList = null;
+ int index = JavaTools.FieldInList(_AllFieldNames, _SelFieldName);
+ SelList = new short[] { (short) (index) };
+ Helper.setUnoPropertyValue(UnoDialog.getModel(xListBox), "SelectedItems", SelList);
+ }
+}
+
+
diff --git a/wizards/com/sun/star/wizards/ui/DocumentPreview.java b/wizards/com/sun/star/wizards/ui/DocumentPreview.java
new file mode 100644
index 000000000000..173fae87f01b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/DocumentPreview.java
@@ -0,0 +1,186 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.*;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XFrame;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.CloseVetoException;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.common.Properties;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class DocumentPreview
+{
+
+ /**
+ * The window in which the preview is showed.
+ */
+ private XWindow xWindow;
+ /**
+ * The frame service which is used to show the preview
+ */
+ private XFrame xFrame;
+ /**
+ * The content component of the frame.
+ */
+ private XComponent xComponent;
+ private XControl xControl;
+ private int step;
+ private PropertyValue[] loadArgs;
+ private String url;
+ public static final int PREVIEW_MODE = 1;
+
+ /*********************************************************************
+ main
+
+ - create new frame with window inside
+ - load a component as preview into this frame
+ */
+ public DocumentPreview(XMultiServiceFactory xmsf, Object control) throws Exception
+ {
+
+ //((XWindow)UnoRuntime.queryInterface(XWindow.class,control)).addPaintListener(this);
+ xControl = (XControl) UnoRuntime.queryInterface(XControl.class, control);
+ //register this object as a listener, to close the frame when disposing.
+ //((XComponent) UnoRuntime.queryInterface(XComponent.class, control)).addEventListener(this);
+
+ createPreviewFrame(xmsf, xControl);
+ }
+
+ protected XComponent setDocument(String url_, String[] propNames, Object[] propValues) throws com.sun.star.lang.IllegalArgumentException, IOException, CloseVetoException
+ {
+ url = url_;
+
+ Properties ps = new Properties();
+
+ for (int i = 0; i < propNames.length; i++)
+ {
+ ps.put(propNames[i], propValues[i]);
+ }
+ return setDocument(url, ps.getProperties());
+ }
+
+ protected XComponent setDocument(String url, PropertyValue[] lArgs) throws com.sun.star.lang.IllegalArgumentException, IOException, CloseVetoException
+ {
+ loadArgs = lArgs;
+ XComponentLoader xCompLoader = (XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, xFrame);
+ xFrame.activate();
+ return xComponent = xCompLoader.loadComponentFromURL(url, "_self", 0, loadArgs);
+ }
+
+ public void reload(XMultiServiceFactory xmsf) throws com.sun.star.lang.IllegalArgumentException, IOException, CloseVetoException, com.sun.star.uno.Exception
+ {
+ closeFrame();
+ createPreviewFrame(xmsf, xControl);
+ //System.out.println(xControl);
+ setDocument(url, loadArgs);
+ }
+
+ private void closeFrame() throws CloseVetoException
+ {
+ if (xFrame != null)
+ {
+ ((XCloseable) UnoRuntime.queryInterface(XCloseable.class, xFrame)).close(false);
+ }
+ }
+
+ public XComponent setDocument(String url, int mode) throws com.sun.star.lang.IllegalArgumentException, IOException, CloseVetoException
+ {
+ switch (mode)
+ {
+ case PREVIEW_MODE:
+ return setDocument(url, new String[]
+ {
+ "Preview", "ReadOnly"
+ }, new Object[]
+ {
+ Boolean.TRUE, Boolean.TRUE
+ });
+ }
+ return null;
+ }
+
+ /*********************************************************************
+ create a new frame with a new container window inside,
+ which isnt part of the global frame tree.
+
+ Attention:
+ a) This frame wont be destroyed by the office. It must be closed by you!
+ Do so - please call XCloseable::close().
+ b) The container window is part of the frame. Dont hold it alive - nor try to kill it.
+ It will be destroyed inside close().
+ */
+ public void createPreviewFrame(XMultiServiceFactory xmsf, XControl xControl) throws com.sun.star.uno.Exception, com.sun.star.lang.IllegalArgumentException
+ {
+ XWindowPeer controlPeer = xControl.getPeer();
+ XWindow controlWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xControl);
+ Rectangle r = controlWindow.getPosSize();
+
+ Object toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit");
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, toolkit);
+
+ WindowDescriptor aDescriptor = new WindowDescriptor();
+ aDescriptor.Type = WindowClass.SIMPLE;
+ aDescriptor.WindowServiceName = "window";
+ aDescriptor.ParentIndex = -1;
+ aDescriptor.Parent = controlPeer; //xWindowPeer; //argument !
+ aDescriptor.Bounds = new Rectangle(0, 0, r.Width, r.Height);
+ aDescriptor.WindowAttributes = VclWindowPeerAttribute.CLIPCHILDREN | WindowAttribute.SHOW;
+
+ XWindowPeer xPeer = xToolkit.createWindow(aDescriptor);
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xPeer);
+ Object frame = xmsf.createInstance("com.sun.star.frame.Frame");
+ xFrame = (XFrame) UnoRuntime.queryInterface(XFrame.class, frame);
+// XFrame xF = (XFrame) UnoRuntime.queryInterface(XFrame.class, Desktop.getDesktop(xmsf));
+// xFrame = xF.findFrame("_blank", 0);
+ xFrame.initialize(xWindow);
+ xWindow.setVisible(true);
+ }
+
+ public void dispose()
+ {
+ try
+ {
+ closeFrame();
+ }
+ catch (CloseVetoException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/FieldSelection.java b/wizards/com/sun/star/wizards/ui/FieldSelection.java
new file mode 100644
index 000000000000..ce3c7c8c4849
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/FieldSelection.java
@@ -0,0 +1,697 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.XListBox;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.common.JavaTools;
+
+import java.util.*;
+
+/**
+ *
+ * @author bc93774
+ */
+public class FieldSelection
+{
+ public XListBox xFieldsListBox; // Left ListBox
+ public XListBox xSelectedFieldsListBox; // right (selected) ListBox
+
+ protected UnoDialog CurUnoDialog;
+ protected String sIncSuffix;
+ protected int FirstHelpIndex;
+ protected boolean AppendMode = false;
+ protected Integer IStep;
+
+ protected int CompPosX;
+ protected int CompPosY;
+ protected int CompHeight;
+ protected int CompWidth;
+
+ private XFieldSelectionListener xFieldSelection;
+ private int maxfieldcount = 10000000;
+ private String[] AllFieldNames;
+ private Integer ListBoxWidth;
+
+ private Integer SelListBoxPosX;
+
+ private boolean bisModified = false;
+
+ private final static int SOCMDMOVESEL = 1;
+ private final static int SOCMDMOVEALL = 2;
+ private final static int SOCMDREMOVESEL = 3;
+ private final static int SOCMDREMOVEALL = 4;
+ private final static int SOCMDMOVEUP = 5;
+ private final static int SOCMDMOVEDOWN = 6;
+ private final static int SOFLDSLST = 7;
+ private final static int SOSELFLDSLST = 8;
+
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
+ {
+ // int iPos;
+ com.sun.star.wizards.common.Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", Boolean.FALSE);
+ int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
+ switch (iKey)
+ {
+
+ case SOFLDSLST:
+ toggleListboxButtons((short) - 1, (short) - 1);
+ break;
+
+ case SOSELFLDSLST:
+ toggleListboxButtons((short) - 1, (short) - 1);
+ break;
+ default:
+ break;
+ }
+ com.sun.star.wizards.common.Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", Boolean.TRUE);
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+
+ class ActionListenerImpl implements com.sun.star.awt.XActionListener
+ {
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ try
+ {
+ int iKey = CurUnoDialog.getControlKey(actionEvent.Source, CurUnoDialog.ControlList);
+ switch (iKey)
+ {
+ case SOFLDSLST:
+ selectFields(false);
+ break;
+
+ case SOSELFLDSLST:
+ deselectFields(false);
+ break;
+
+ case SOCMDMOVESEL:
+ selectFields(false);
+ break;
+
+ case SOCMDMOVEALL:
+ selectFields(true);
+ break;
+
+ case SOCMDREMOVESEL:
+ deselectFields(false);
+ break;
+
+ case SOCMDREMOVEALL:
+ deselectFields(true);
+ break;
+
+ case SOCMDMOVEUP:
+ changeSelectionOrder(-1);
+ break;
+
+ case SOCMDMOVEDOWN:
+ changeSelectionOrder(1);
+ break;
+
+ default:
+ // System.err.println( exception);
+ break;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+ }
+
+ public void addFieldSelectionListener(XFieldSelectionListener xFieldSelection)
+ {
+ this.xFieldSelection = xFieldSelection;
+ this.xFieldSelection.setID(sIncSuffix);
+ }
+
+ public void setAppendMode(boolean _AppendMode)
+ {
+ AppendMode = _AppendMode;
+ }
+
+ public boolean getAppendMode()
+ {
+ return AppendMode;
+ }
+
+ public FieldSelection(UnoDialog CurUnoDialog, int _iStep, int CompPosX, int CompPosY, int CompWidth, int CompHeight, String slblFields, String slblSelFields, int _FirstHelpIndex, boolean bshowFourButtons)
+ {
+ try
+ {
+ final String AccessTextMoveSelected = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 39);
+ final String AccessTextRemoveSelected = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 40);
+ final String AccessTextMoveAll = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 41);
+ final String AccessTextRemoveAll = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 42);
+ final String AccessMoveFieldUp = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 43);
+ final String AccessMoveFieldDown = CurUnoDialog.m_oResource.getResText(UIConsts.RID_DB_COMMON + 44);
+
+ FirstHelpIndex = _FirstHelpIndex;
+ short curtabindex = UnoDialog.setInitialTabindex(_iStep);
+ int ShiftButtonCount = 2;
+ int a = 0;
+ this.CurUnoDialog = CurUnoDialog;
+ this.CompPosX = CompPosX;
+ this.CompPosY = CompPosY;
+ this.CompHeight = CompHeight;
+ this.CompWidth = CompWidth;
+ Object btnmoveall = null;
+ Object btnremoveall = null;
+
+ final int cmdButtonWidth = 16;
+ final int cmdButtonHoriDist = 4;
+ final int lblHeight = 8;
+ final int lblVertiDist = 2;
+
+ ListBoxWidth = new Integer(((CompWidth - 3 * cmdButtonHoriDist - 2 * cmdButtonWidth) / 2));
+ Integer cmdShiftButtonPosX = new Integer((CompPosX + ListBoxWidth.intValue() + cmdButtonHoriDist));
+ Integer ListBoxPosY = new Integer(CompPosY + lblVertiDist + lblHeight);
+ Integer ListBoxHeight = new Integer(CompHeight - 8 - 2);
+ SelListBoxPosX = new Integer(cmdShiftButtonPosX.intValue() + cmdButtonWidth + cmdButtonHoriDist);
+
+ IStep = new Integer(_iStep);
+ if (bshowFourButtons == true)
+ {
+ ShiftButtonCount = 4;
+ }
+ Integer[] ShiftButtonPosY = getYButtonPositions(ShiftButtonCount);
+ Integer[] MoveButtonPosY = getYButtonPositions(2);
+ Integer cmdMoveButtonPosX = new Integer(SelListBoxPosX.intValue() + ListBoxWidth.intValue() + cmdButtonHoriDist);
+
+ Integer CmdButtonWidth = new Integer(cmdButtonWidth);
+
+ sIncSuffix = "_" + com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "lblFields_");
+
+ // Label
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblFields" + sIncSuffix,
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblFields, new Integer(CompPosX), new Integer(CompPosY), IStep, new Short(curtabindex), new Integer(109)
+ });
+
+ // Listbox 'Available fields'
+ xFieldsListBox = CurUnoDialog.insertListBox("lstFields" + sIncSuffix, SOFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "MultiSelection", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ ListBoxHeight, HelpIds.getHelpIdString(_FirstHelpIndex), Boolean.TRUE, new Integer(CompPosX), ListBoxPosY, IStep, new Short((curtabindex++)), ListBoxWidth
+ });
+
+ Object btnmoveselected = CurUnoDialog.insertButton("cmdMoveSelected" + sIncSuffix, SOCMDMOVESEL, new ActionListenerImpl(),
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 1), ">", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+
+ if (bshowFourButtons == true)
+ {
+ btnmoveall = CurUnoDialog.insertButton("cmdMoveAll" + sIncSuffix, SOCMDMOVEALL, new ActionListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 2), ">>", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+ }
+ Object btnremoveselected = CurUnoDialog.insertButton("cmdRemoveSelected" + sIncSuffix, SOCMDREMOVESEL, new ActionListenerImpl(),
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 3), "<", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+
+ if (bshowFourButtons == true)
+ {
+ btnremoveall = CurUnoDialog.insertButton("cmdRemoveAll" + sIncSuffix, SOCMDREMOVEALL, new ActionListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 4), "<<", cmdShiftButtonPosX, ShiftButtonPosY[a++], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+ }
+
+ FontDescriptor oFontDesc = new FontDescriptor();
+ oFontDesc.Name = "StarSymbol";
+
+ // Label 'Fields in the form'
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblSelFields" + sIncSuffix,
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), slblSelFields, SelListBoxPosX, new Integer(CompPosY), IStep, new Short(curtabindex++), ListBoxWidth
+ });
+
+ // ListBox 'Fields in the form'
+ xSelectedFieldsListBox = CurUnoDialog.insertListBox("lstSelFields" + sIncSuffix, SOSELFLDSLST, new ActionListenerImpl(), new ItemListenerImpl(),
+ new String[]
+ {
+ "Height", "HelpURL", "MultiSelection", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ ListBoxHeight, HelpIds.getHelpIdString(_FirstHelpIndex + 5), Boolean.TRUE, SelListBoxPosX, ListBoxPosY, IStep, new Short(curtabindex++), ListBoxWidth
+ });
+
+ Object btnmoveup = CurUnoDialog.insertButton("cmdMoveUp" + sIncSuffix, SOCMDMOVEUP, new ActionListenerImpl(),
+ new String[]
+ {
+ "Enabled", "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, oFontDesc, new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 6), String.valueOf((char) 8743), cmdMoveButtonPosX, MoveButtonPosY[0], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+
+ Object btnmovedown = CurUnoDialog.insertButton("cmdMoveDown" + sIncSuffix, SOCMDMOVEDOWN, new ActionListenerImpl(),
+ new String[]
+ {
+ "Enabled", "FontDescriptor", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, oFontDesc, new Integer(14), HelpIds.getHelpIdString(_FirstHelpIndex + 7), String.valueOf((char) 8744), cmdMoveButtonPosX, MoveButtonPosY[1], IStep, new Short(curtabindex++), CmdButtonWidth
+ });
+
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveselected, AccessTextMoveSelected);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnremoveselected, AccessTextRemoveSelected);
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(xFieldsListBox, JavaTools.replaceSubString(slblFields, "", "~"));
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(xSelectedFieldsListBox, JavaTools.replaceSubString(slblSelFields, "", "~"));
+ if (btnmoveall != null)
+ {
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveall, AccessTextMoveAll);
+ }
+ if (btnremoveall != null)
+ {
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnremoveall, AccessTextRemoveAll);
+ }
+ if (btnmoveup != null)
+ {
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmoveup, AccessMoveFieldUp);
+ }
+ if (btnmovedown != null)
+ {
+ CurUnoDialog.getPeerConfiguration().setAccessibleName(btnmovedown, AccessMoveFieldDown);
+ }
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ // Todo: If Value is getting smaller than zero -> throw exception
+ private Integer[] getYButtonPositions(int ButtonCount)
+ {
+ Integer[] YPosArray;
+ if (ButtonCount > 0)
+ {
+ YPosArray = new Integer[ButtonCount];
+ final int cmdButtonHeight = 14;
+ final int cmdButtonVertiDist = 2;
+
+ YPosArray[0] = new Integer( (CompPosY + 10 + (((CompHeight - 10) - (ButtonCount * cmdButtonHeight) - ((ButtonCount - 1) * cmdButtonVertiDist)) / 2)));
+ if (ButtonCount > 1)
+ {
+ for (int i = 1; i < ButtonCount; i++)
+ {
+ YPosArray[i] = new Integer(YPosArray[i - 1].intValue() + cmdButtonHeight + cmdButtonVertiDist);
+ }
+ }
+ return YPosArray;
+ }
+ return null;
+ }
+
+ public Integer getListboxWidth()
+ {
+ return this.ListBoxWidth;
+ }
+
+ private void changeSelectionOrder(int iNeighbor)
+ {
+ short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos();
+ // Todo: we are assuming that the array starts with the lowest index. Verfy this assumption!!!!!
+ if (iSelIndices.length == 1)
+ {
+ short iSelIndex = iSelIndices[0];
+ String[] NewItemList = xSelectedFieldsListBox.getItems();
+ String CurItem = NewItemList[iSelIndex];
+ String NeighborItem = NewItemList[iSelIndex + iNeighbor];
+ NewItemList[iSelIndex + iNeighbor] = CurItem;
+ NewItemList[iSelIndex] = NeighborItem;
+ CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "StringItemList", NewItemList);
+ xSelectedFieldsListBox.selectItem(CurItem, true);
+ if (xFieldSelection != null)
+ {
+ if (iNeighbor < 0)
+ {
+ xFieldSelection.moveItemUp(CurItem);
+ }
+ else
+ {
+ xFieldSelection.moveItemDown(CurItem);
+ }
+ }
+ }
+ }
+
+ public void toggleListboxControls(Boolean BDoEnable)
+ {
+ try
+ {
+ CurUnoDialog.setControlProperty("lblFields" + sIncSuffix, "Enabled", BDoEnable);
+ CurUnoDialog.setControlProperty("lblSelFields" + sIncSuffix, "Enabled", BDoEnable);
+ CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, "Enabled", BDoEnable);
+ CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "Enabled", BDoEnable);
+
+ if (BDoEnable.booleanValue() == true)
+ {
+ toggleListboxButtons((short) - 1, (short) - 1);
+ }
+ else
+ {
+ CurUnoDialog.setControlProperty("cmdRemoveAll" + sIncSuffix, "Enabled", BDoEnable);
+ CurUnoDialog.setControlProperty("cmdRemoveSelected" + sIncSuffix, "Enabled", BDoEnable);
+ toggleMoveButtons(BDoEnable.booleanValue(), BDoEnable.booleanValue());
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ // Enable or disable the buttons used for moving the available
+ // fields between the two list boxes.
+ protected void toggleListboxButtons(short iFieldsSelIndex, short iSelFieldsSelIndex)
+ {
+ try
+ {
+ boolean bmoveUpenabled = false;
+ boolean bmoveDownenabled = false;
+ CurUnoDialog.selectListBoxItem(xFieldsListBox, iFieldsSelIndex);
+ CurUnoDialog.selectListBoxItem(xSelectedFieldsListBox, iSelFieldsSelIndex);
+ int SelListBoxSelLength = xSelectedFieldsListBox.getSelectedItems().length;
+ int ListBoxSelLength = xFieldsListBox.getSelectedItems().length;
+ boolean bIsFieldSelected = (ListBoxSelLength > 0);
+ int FieldCount = xFieldsListBox.getItemCount();
+ boolean bSelectSelected = (SelListBoxSelLength > 0);
+ int SelectCount = xSelectedFieldsListBox.getItemCount();
+ if (bSelectSelected)
+ {
+ short[] iSelIndices = xSelectedFieldsListBox.getSelectedItemsPos();
+ bmoveUpenabled = ((iSelIndices[0] > 0) && (iSelIndices.length == 1));
+ bmoveDownenabled = (((iSelIndices[SelListBoxSelLength - 1]) < (short) (SelectCount - 1)) && (iSelIndices.length == 1));
+ }
+ CurUnoDialog.setControlProperty("cmdRemoveAll" + sIncSuffix, "Enabled", new Boolean(SelectCount >= 1));
+ CurUnoDialog.setControlProperty("cmdRemoveSelected" + sIncSuffix, "Enabled", new Boolean(bSelectSelected));
+ toggleMoveButtons((FieldCount >= 1), bIsFieldSelected);
+ CurUnoDialog.setControlProperty("cmdMoveUp" + sIncSuffix, "Enabled", new Boolean(bmoveUpenabled));
+ CurUnoDialog.setControlProperty("cmdMoveDown" + sIncSuffix, "Enabled", new Boolean(bmoveDownenabled));
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ protected void toggleMoveButtons(boolean _btoggleMoveAll, boolean _btoggleMoveSelected)
+ {
+ boolean btoggleMoveAll = (((xFieldsListBox.getItemCount() + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveAll));
+ boolean btoggleMoveSelected = (((xFieldsListBox.getSelectedItems().length + xSelectedFieldsListBox.getItemCount()) < maxfieldcount) && (_btoggleMoveSelected));
+ CurUnoDialog.setControlProperty("cmdMoveAll" + sIncSuffix, "Enabled", new Boolean(btoggleMoveAll));
+ CurUnoDialog.setControlProperty("cmdMoveSelected" + sIncSuffix, "Enabled", new Boolean(btoggleMoveSelected));
+ }
+
+ public void setMultipleMode(boolean _bisMultiple)
+ {
+ xFieldsListBox.setMultipleMode(_bisMultiple);
+ xSelectedFieldsListBox.setMultipleMode(_bisMultiple);
+ }
+
+ public void emptyFieldsListBoxes()
+ {
+ try
+ {
+ toggleListboxControls(Boolean.FALSE);
+ CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "StringItemList", new String[]
+ {
+ });
+ CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, "StringItemList", new String[]
+ {
+ });
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void mergeList(String[] AllFieldNames, String[] SecondList)
+ {
+ // int MaxIndex = SecondList.length;
+ xFieldsListBox.addItems(AllFieldNames, (short) 0);
+ toggleListboxButtons((short) - 1, (short) - 1);
+ }
+
+ public void intializeSelectedFields(String[] _SelectedFieldNames)
+ {
+ xSelectedFieldsListBox.addItems(_SelectedFieldNames, xSelectedFieldsListBox.getItemCount());
+ }
+
+ private void removeAllItems(XListBox _xListBox)
+ {
+ _xListBox.removeItems((short) 0, _xListBox.getItemCount());
+ }
+
+ // Note Boolean Parameter
+ public void initialize(String[] _AllFieldNames, boolean _AppendMode)
+ {
+ AppendMode = _AppendMode;
+ removeAllItems(xFieldsListBox);
+ xFieldsListBox.addItems(_AllFieldNames, (short) 0);
+ AllFieldNames = xFieldsListBox.getItems();
+ if ((xSelectedFieldsListBox.getItemCount() > 0) && (!AppendMode))
+ {
+ removeAllItems(xSelectedFieldsListBox);
+ }
+ toggleListboxControls(Boolean.TRUE);
+ }
+
+ public void initialize(String[][] _AllFieldNamesTable, boolean _AppendMode, int _maxfieldcount)
+ {
+ String[] AllFieldNames_ = new String[_AllFieldNamesTable.length];
+ for (int i = 0; i < _AllFieldNamesTable.length; i++)
+ {
+ AllFieldNames_[i] = _AllFieldNamesTable[i][0];
+ }
+ initialize(AllFieldNames_, _AppendMode, _maxfieldcount);
+ }
+
+ public void initialize(String[] _AllFieldNames, boolean _AppendMode, int _maxfieldcount)
+ {
+ maxfieldcount = _maxfieldcount;
+ initialize(_AllFieldNames, _AppendMode);
+ }
+
+ public void initialize(String[] _AllFieldNames, String[] _SelFieldNames, boolean _AppendMode)
+ {
+ removeAllItems(xSelectedFieldsListBox);
+ xSelectedFieldsListBox.addItems(_SelFieldNames, (short) 0);
+ initialize(_AllFieldNames, _AppendMode);
+ }
+
+ public void selectFields(boolean bMoveAll)
+ {
+ // int CurIndex;
+ short iFieldSelected = (short) - 1;
+ short iSelFieldSelected = (short) - 1;
+ // int MaxCurTarget = xSelectedFieldsListBox.getItemCount();
+ String[] SelFieldItems;
+ if (bMoveAll)
+ {
+ SelFieldItems = xFieldsListBox.getItems();
+ removeAllItems(xFieldsListBox);
+ if (!AppendMode)
+ {
+ removeAllItems(xSelectedFieldsListBox);
+ xSelectedFieldsListBox.addItems(AllFieldNames, (short) 0);
+ }
+ else
+ {
+ xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount());
+ }
+ }
+ else
+ {
+ SelFieldItems = xFieldsListBox.getSelectedItems();
+ int MaxSourceSelected = SelFieldItems.length;
+ if (MaxSourceSelected > 0)
+ {
+ iFieldSelected = xFieldsListBox.getSelectedItemPos();
+ iSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos();
+ short[] SourceSelList = new short[xFieldsListBox.getSelectedItemsPos().length];
+ SourceSelList = xFieldsListBox.getSelectedItemsPos();
+ xSelectedFieldsListBox.addItems(SelFieldItems, xSelectedFieldsListBox.getItemCount());
+ CurUnoDialog.removeSelectedItems(xFieldsListBox);
+ xSelectedFieldsListBox.selectItemPos((short) 0, xSelectedFieldsListBox.getSelectedItems().length > 0);
+ }
+ }
+ toggleListboxButtons(iFieldSelected, iSelFieldSelected);
+ if (xFieldSelection != null)
+ {
+ xFieldSelection.shiftFromLeftToRight(SelFieldItems, xSelectedFieldsListBox.getItems());
+ }
+ }
+
+ public void deselectFields(boolean bMoveAll)
+ {
+ // int m = 0;
+ String SearchString;
+ short iOldFieldSelected = xFieldsListBox.getSelectedItemPos();
+ short iOldSelFieldSelected = xSelectedFieldsListBox.getSelectedItemPos();
+ String[] OldSelFieldItems = xSelectedFieldsListBox.getSelectedItems();
+ if (bMoveAll)
+ {
+ OldSelFieldItems = xSelectedFieldsListBox.getItems();
+ removeAllItems(xFieldsListBox);
+ xFieldsListBox.addItems(AllFieldNames, (short) 0);
+ removeAllItems(xSelectedFieldsListBox);
+ }
+ else
+ {
+ int MaxOriginalCount = AllFieldNames.length;
+ // int MaxSelected = OldSelFieldItems.length;
+ String[] SelList = xFieldsListBox.getItems();
+ Vector<String> NewSourceVector = new Vector<String>();
+ for (int i = 0; i < MaxOriginalCount; i++)
+ {
+ SearchString = AllFieldNames[i];
+ if (JavaTools.FieldInList(SelList, SearchString) != -1)
+ {
+ NewSourceVector.addElement(SearchString);
+ }
+ else if (JavaTools.FieldInList(OldSelFieldItems, SearchString) != -1)
+ {
+ NewSourceVector.addElement(SearchString);
+ }
+ }
+ xFieldsListBox.removeItems((short) 0, xFieldsListBox.getItemCount());
+ if (NewSourceVector.size() > 0)
+ {
+ String[] NewSourceList = new String[NewSourceVector.size()];
+ NewSourceVector.toArray(NewSourceList);
+ xFieldsListBox.addItems(NewSourceList, (short) 0);
+ }
+ CurUnoDialog.removeSelectedItems(xSelectedFieldsListBox);
+ }
+ toggleListboxButtons(iOldFieldSelected, iOldSelFieldSelected);
+ String[] NewSelFieldItems = xSelectedFieldsListBox.getItems();
+ if (xFieldSelection != null)
+ {
+ xFieldSelection.shiftFromRightToLeft(OldSelFieldItems, NewSelFieldItems);
+ }
+ }
+
+ public void addItemsToFieldsListbox(String[] _sItems)
+ {
+ String[] sOldList = xFieldsListBox.getItems();
+ for (int i = 0; i < _sItems.length; i++)
+ {
+ if (JavaTools.FieldInList(sOldList, _sItems[i]) < 0)
+ {
+ xFieldsListBox.addItem(_sItems[i], xFieldsListBox.getItemCount());
+ }
+ }
+ }
+
+ public String[] getSelectedFieldNames()
+ {
+ return (String[]) CurUnoDialog.getControlProperty("lstSelFields" + sIncSuffix, "StringItemList");
+ }
+
+ public void setSelectedFieldNames(String[] _sfieldnames)
+ {
+ CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "StringItemList", _sfieldnames);
+ String[] sleftboxfieldnames = JavaTools.removefromList(xFieldsListBox.getItems(), _sfieldnames);
+ CurUnoDialog.setControlProperty("lstFields" + sIncSuffix, "StringItemList", sleftboxfieldnames);
+ }
+
+ public void setModified(boolean _bModified)
+ {
+ bisModified = _bModified;
+ }
+
+ public boolean isModified()
+ {
+ return bisModified;
+ }
+
+ public void changeSelectedFieldNames(String[] _sfieldnames)
+ {
+ CurUnoDialog.setControlProperty("lstSelFields" + sIncSuffix, "StringItemList", _sfieldnames);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/FilterComponent.java b/wizards/com/sun/star/wizards/ui/FilterComponent.java
new file mode 100644
index 000000000000..e53f0792e268
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/FilterComponent.java
@@ -0,0 +1,954 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+// import java.util.Vector;
+import com.sun.star.awt.TextEvent;
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.beans.PropertyAttribute;
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.beans.XPropertyContainer;
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.sdb.SQLFilterOperator;
+import com.sun.star.sdbc.DataType;
+import com.sun.star.uno.Any;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.Exception;
+import com.sun.star.uno.Type;
+import com.sun.star.uno.TypeClass;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.wizards.common.NumberFormatter;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.db.FieldColumn;
+import com.sun.star.wizards.db.QueryMetaData;
+import com.sun.star.wizards.db.SQLQueryComposer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class FilterComponent
+{
+
+ private Integer IStep;
+ private int RowCount;
+ private static String[] sLogicOperators;
+ private XRadioButton optMatchAny;
+ private String slblFieldNames;
+ private String slblOperators;
+ private String slblValue;
+ WizardDialog CurUnoDialog;
+ private int BaseID = 2300;
+ private String sIncSuffix;
+ private ControlRow[] oControlRows;
+ private String sDuplicateCondition;
+ final int SOOPTORMODE = 100;
+ final int SOOPTANDMODE = 101;
+ QueryMetaData oQueryMetaData;
+ int iDateTimeFormat;
+ int iDateFormat;
+ int iTimeFormat;
+ private PropertyValue[][] filterconditions;
+ private short curtabindex;
+ XMultiServiceFactory xMSF;
+ final int SO_FIRSTFIELDNAME = 1;
+ final int SO_SECONDFIELDNAME = 2;
+ final int SO_THIRDFIELDNAME = 3;
+ final int SO_FOURTHFIELDNAME = 4;
+ int[] SO_FIELDNAMELIST = new int[]
+ {
+ SO_FIRSTFIELDNAME, SO_SECONDFIELDNAME, SO_THIRDFIELDNAME, SO_FOURTHFIELDNAME
+ };
+ final int SO_FIRSTCONDITION = 5;
+ final int SO_SECONDCONDITION = 6;
+ final int SO_THIRDCONDITION = 7;
+ final int SO_FOURTHCONDITION = 8;
+ int[] SO_CONDITIONLIST = new int[]
+ {
+ SO_FIRSTCONDITION, SO_SECONDCONDITION, SO_THIRDCONDITION, SO_FOURTHCONDITION
+ };
+ final int SO_FIRSTTEXTFIELD = 1;
+ final int SO_SECONDTEXTFIELD = 2;
+ final int SO_THIRDTEXTFIELD = 3;
+ final int SO_FOURTHTEXTFIELD = 4;
+ int[] SO_TEXTFIELDLIST = new int[]
+ {
+ SO_FIRSTTEXTFIELD, SO_SECONDTEXTFIELD, SO_THIRDTEXTFIELD, SO_FOURTHTEXTFIELD
+ };
+ final int SO_FIRSTBOOLFIELDNAME = 256 + 1;
+ final int SO_SECONDBOOLFIELDNAME = 256 + 2;
+ final int SO_THIRDBOOLFIELDNAME = 256 + 3;
+ final int SO_FOURTHBOOLFIELDNAME = 256 + 4;
+ int SO_BOOLEANLIST[] =
+ {
+ SO_FIRSTBOOLFIELDNAME, SO_SECONDBOOLFIELDNAME, SO_THIRDBOOLFIELDNAME, SO_FOURTHBOOLFIELDNAME
+ };
+ final int SO_OPTQUERYMODE = 5;
+ int SOI_MATCHALL = 0;
+ int SOI_MATCHANY = 1;
+ int curHelpID;
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+ public void itemStateChanged(com.sun.star.awt.ItemEvent EventObject)
+ {
+ int iKey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
+ String sControlName = "";
+ switch (iKey)
+ {
+ case SO_FIRSTFIELDNAME:
+ case SO_SECONDFIELDNAME:
+ case SO_THIRDFIELDNAME:
+ case SO_FOURTHFIELDNAME:
+ sControlName = getControlName(EventObject.Source);
+ String sControlNameSuffix = sIncSuffix + "_" + getIndexNumber(sControlName);
+ XListBox xCurFieldListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, CurUnoDialog.xDlgContainer.getControl(sControlName));
+ String CurDisplayFieldName = xCurFieldListBox.getSelectedItem();
+ FieldColumn CurFieldColumn = new FieldColumn(oQueryMetaData, CurDisplayFieldName);
+
+ String sControlNameTextValue = "txtValue" + sControlNameSuffix;
+ XControl xValueControl = CurUnoDialog.xDlgContainer.getControl(sControlNameTextValue);
+ XInterface xValueModel = (XInterface) UnoDialog.getModel(xValueControl);
+ Helper.setUnoPropertyValue(xValueModel, "TreatAsNumber", Boolean.valueOf(CurFieldColumn.isNumberFormat()));
+ final NumberFormatter aNumberFormatter = oQueryMetaData.getNumberFormatter();
+ aNumberFormatter.setNumberFormat(xValueModel, CurFieldColumn.getDBFormatKey(), aNumberFormatter);
+
+ break;
+ case SO_FIRSTCONDITION:
+ case SO_SECONDCONDITION:
+ case SO_THIRDCONDITION:
+ case SO_FOURTHCONDITION:
+ sControlName = getControlName(EventObject.Source);
+ break;
+ case SOOPTORMODE:
+ case SOOPTANDMODE:
+ return;
+
+ case SO_FIRSTBOOLFIELDNAME:
+ case SO_SECONDBOOLFIELDNAME:
+ case SO_THIRDBOOLFIELDNAME:
+ case SO_FOURTHBOOLFIELDNAME:
+ sControlName = getControlName(EventObject.Source);
+ break;
+
+ default:
+ break;
+ }
+ togglefollowingControlRow(sControlName);
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+
+ class TextListenerImpl implements com.sun.star.awt.XTextListener
+ {
+
+ public void textChanged(TextEvent EventObject)
+ {
+ String sName = getControlName(EventObject.Source);
+ togglefollowingControlRow(sName);
+ }
+
+ public void disposing(EventObject eventObject)
+ {
+ }
+
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ getfilterstate();
+ }
+ }
+
+ public static String getIndexNumber(String _sStr)
+ {
+ String sLastNumber = _sStr.substring(_sStr.length() - 1, _sStr.length());
+ return sLastNumber;
+ }
+
+ /**
+ * Enable the next ControlRow if the Condition is complete in the current line
+ *
+ * @param _scurName every control name ends with something like _1, _2, _3 this is the index number
+ * we try to interpret to check which line we currently use. (number - 1)
+ */
+ private void togglefollowingControlRow(String _scurName)
+ {
+ // String sNameSuffix = sIncSuffix + "_" + _scurName.substring(_scurName.length() - 1, _scurName.length());
+ int Index = Integer.valueOf(getIndexNumber(_scurName)).intValue();
+ if (Index < oControlRows.length)
+ {
+ boolean bValue = oControlRows[Index - 1].isConditionComplete();
+ oControlRows[Index].setEnabled(bValue);
+ }
+ }
+
+ private String getControlName(Object _oSourceevent)
+ {
+ try
+ {
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, _oSourceevent);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControl.getModel());
+ final String sName = AnyConverter.toString(xPSet.getPropertyValue("Name"));
+ return sName;
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return "";
+ }
+
+ public PropertyValue[][] getFilterConditions()
+ {
+ // ControlRow CurControlRow;
+ // getfilterstate();
+ int nFilterCount = getFilterCount();
+ if (nFilterCount > 0)
+ {
+ final SQLQueryComposer composer = oQueryMetaData.getSQLQueryComposer();
+ try
+ {
+ final String serviceName = "com.sun.star.beans.PropertyBag";
+ final XPropertyContainer column = (XPropertyContainer) UnoRuntime.queryInterface(XPropertyContainer.class, oQueryMetaData.xMSF.createInstance(serviceName));
+
+ column.addProperty("Type", PropertyAttribute.BOUND, DataType.VARCHAR);
+ column.addProperty("Name", PropertyAttribute.BOUND, "");
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), null );
+ final XPropertySet columnSet = UnoRuntime.queryInterface(XPropertySet.class, column);
+
+ if ( composer.getQuery().length() == 0)
+ {
+ final String fromClause = composer.getFromClause();
+ StringBuilder sql = new StringBuilder();
+ sql.append(composer.getSelectClause(true));
+ sql.append(' ');
+ sql.append(fromClause);
+ composer.getQueryComposer().setElementaryQuery(sql.toString());
+ }
+ composer.getQueryComposer().setStructuredFilter( new PropertyValue[][] {} );
+ for (int i = 0; i < RowCount; i++)
+ {
+ ControlRow currentControlRow = oControlRows[i];
+ if (currentControlRow.isEnabled())
+ {
+ if (currentControlRow.isConditionComplete())
+ {
+ String sFieldName = currentControlRow.getSelectedFieldName();
+ int nOperator = (int) currentControlRow.getSelectedOperator();
+ FieldColumn aFieldColumn = oQueryMetaData.getFieldColumnByDisplayName(sFieldName);
+ columnSet.setPropertyValue("Name", aFieldColumn.getFieldName());
+ columnSet.setPropertyValue("Type", aFieldColumn.getXColumnPropertySet().getPropertyValue("Type"));
+ Object value = currentControlRow.getValue();
+ switch(aFieldColumn.getFieldType())
+ {
+ case DataType.TIMESTAMP:
+ case DataType.DATE:
+ value = ((Double)value) - oQueryMetaData.getNullDateCorrection();
+ break;
+ }
+ column.removeProperty( "Value" );
+ final short operator = currentControlRow.getSelectedOperator();
+ if ( ( operator == SQLFilterOperator.SQLNULL )
+ || ( operator == SQLFilterOperator.NOT_SQLNULL )
+ || AnyConverter.isVoid( value )
+ )
+ {
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), new String() );
+ value = new Any( new Type( TypeClass.VOID ), null );
+ }
+ else
+ column.addProperty("Value", (short)( PropertyAttribute.MAYBEVOID | PropertyAttribute.REMOVABLE ), value );
+ columnSet.setPropertyValue("Value", value);
+ composer.getQueryComposer().appendFilterByColumn(columnSet, getfilterstate() == this.SOI_MATCHALL,nOperator);
+ }
+ }
+ }
+ filterconditions = composer.getNormalizedStructuredFilter();
+ int[] iduplicate = JavaTools.getDuplicateFieldIndex(filterconditions);
+ if (iduplicate[0] != -1)
+ {
+ PropertyValue aduplicatecondition = filterconditions[iduplicate[0]][iduplicate[1]];
+ String smsgDuplicateCondition = getDisplayCondition(sDuplicateCondition, aduplicatecondition, null);
+ CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, smsgDuplicateCondition);
+ CurUnoDialog.vetoableChange(new java.beans.PropertyChangeEvent(CurUnoDialog, "Steps", Integer.valueOf(1), Integer.valueOf(2)));
+ return new PropertyValue[][]{};
+ }
+ }
+ catch (Exception ex)
+ {
+ Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ else
+ {
+ filterconditions = new PropertyValue[0][0];
+ }
+ return filterconditions;
+ }
+
+ public static String getDisplayCondition(String _BaseString, PropertyValue _filtercondition, QueryMetaData _CurDBMetaData)
+ {
+ try
+ {
+ String FieldName;
+ if (_CurDBMetaData != null)
+ {
+ FieldColumn CurDBFieldColumn = _CurDBMetaData.getFieldColumnByDisplayName(_filtercondition.Name);
+ FieldName = CurDBFieldColumn.getFieldTitle();
+ }
+ else
+ {
+ FieldName = _filtercondition.Name;
+ }
+ String sreturn = JavaTools.replaceSubString(_BaseString, FieldName, "<FIELDNAME>");
+ String soperator = sLogicOperators[_filtercondition.Handle - 1];
+ sreturn = JavaTools.replaceSubString(sreturn, soperator, "<LOGICOPERATOR>");
+ String sDisplayValue = "";
+ if (!AnyConverter.isVoid(_filtercondition.Value))
+ {
+ sDisplayValue = AnyConverter.toString(_filtercondition.Value);
+ }
+ sreturn = JavaTools.replaceSubString(sreturn, sDisplayValue, "<VALUE>");
+ return sreturn;
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ }
+ return "";
+ }
+
+ private int getfilterstate()
+ {
+ boolean bisany = true;
+ int ifilterstate = SOI_MATCHALL;
+ bisany = (this.optMatchAny.getState()) == true;
+ if (bisany)
+ {
+ ifilterstate = SOI_MATCHANY;
+ }
+ else
+ {
+ ifilterstate = SOI_MATCHALL;
+ }
+ return ifilterstate;
+ }
+
+ private int getFilterCount()
+ {
+ int a = 0;
+ for (int i = 0; i < RowCount; i++)
+ {
+ if (oControlRows[i].isEnabled() && oControlRows[i].isConditionComplete())
+ {
+ a++;
+ }
+ }
+ return a;
+ }
+
+ /** Creates a new instance of FilterComponent
+ * @param CurUnoDialog
+ * @param _xMSF
+ * @param iStep
+ * @param iPosX
+ * @param iPosY
+ * @param iWidth
+ * @param FilterCount
+ * @param _oQueryMetaData
+ * @param _firstHelpID
+ */
+ public FilterComponent(WizardDialog CurUnoDialog, XMultiServiceFactory _xMSF, int iStep, int iPosX, int iPosY, int iWidth, int FilterCount, QueryMetaData _oQueryMetaData, int _firstHelpID)
+ {
+ this.curHelpID = _firstHelpID;
+ this.xMSF = _xMSF;
+ this.IStep = Integer.valueOf(iStep);
+
+ curtabindex = UnoDialog.setInitialTabindex(iStep);
+ this.CurUnoDialog = CurUnoDialog;
+ this.RowCount = FilterCount;
+ this.oQueryMetaData = _oQueryMetaData;
+ boolean bEnabled;
+ sIncSuffix = com.sun.star.wizards.common.Desktop.getIncrementSuffix(CurUnoDialog.getDlgNameAccess(), "optMatchAll");
+
+ String soptMatchAll = CurUnoDialog.m_oResource.getResText(BaseID + 9);
+ String soptMatchAny = CurUnoDialog.m_oResource.getResText(BaseID + 10);
+ slblFieldNames = CurUnoDialog.m_oResource.getResText(BaseID + 17);
+ slblOperators = CurUnoDialog.m_oResource.getResText(BaseID + 24);
+ slblValue = CurUnoDialog.m_oResource.getResText(BaseID + 25);
+ sLogicOperators = CurUnoDialog.m_oResource.getResArray(BaseID + 26, 10 /* 7 */); // =, <>, <, >, <=, >=, like, !like, is null, !is null
+
+ sDuplicateCondition = CurUnoDialog.m_oResource.getResText(BaseID + 89);
+
+ // create Radiobuttons
+ // * match all
+ // * match one
+ CurUnoDialog.insertRadioButton("optMatchAll" + sIncSuffix, SOOPTANDMODE, new ItemListenerImpl(),
+ new String[]
+ {
+ "Height",
+ "HelpURL",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "State",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Integer.valueOf(9),
+ HelpIds.getHelpIdString(curHelpID++),
+ soptMatchAll,
+ Integer.valueOf(iPosX),
+ Integer.valueOf(iPosY),
+ Short.valueOf((short) 1),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(203)
+ });
+ optMatchAny = CurUnoDialog.insertRadioButton("optMatchAny" + sIncSuffix, SOOPTORMODE, new ItemListenerImpl(),
+ new String[]
+ {
+ "Height",
+ "HelpURL",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Integer.valueOf(9),
+ HelpIds.getHelpIdString(curHelpID++),
+ soptMatchAny,
+ Integer.valueOf(iPosX),
+ Integer.valueOf(iPosY + 12),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(203)
+ });
+ getfilterstate();
+
+ oControlRows = new ControlRow[FilterCount];
+ for (int i = 0; i < FilterCount; i++)
+ {
+ bEnabled = (i == 0);
+ oControlRows[i] = new ControlRow(iPosX, iPosY + 20, i, bEnabled, (this.curHelpID + (i * 3)));
+ iPosY += 43;
+ }
+ }
+
+ public void initialize(PropertyValue[][] _filterconditions, String[] _fieldnames)
+ {
+ int i;
+ for (i = 0; i < RowCount; i++)
+ {
+ oControlRows[i].setFieldNames(_fieldnames);
+ // oControlRows[i].setFieldNames(aFieldNamesWithAdditionalEmpty);
+ }
+ this.filterconditions = _filterconditions;
+ PropertyValue[] curfilterconditions;
+ // int a;
+ if (_filterconditions.length == 1)
+ {
+ curfilterconditions = filterconditions[0];
+ for (i = 0; i < curfilterconditions.length; i++)
+ {
+ oControlRows[i].setCondition(filterconditions[0][i]);
+ }
+ }
+ else
+ {
+ for (i = 0; i < filterconditions.length; i++)
+ {
+ oControlRows[i].setCondition(filterconditions[i][0]);
+ }
+ }
+ while (i < oControlRows.length)
+ {
+ oControlRows[i].settovoid();
+ boolean bdoenable;
+ if (i > 0)
+ {
+ bdoenable = oControlRows[i - 1].isConditionComplete();
+ }
+ else
+ {
+ bdoenable = true;
+ }
+ oControlRows[i].setEnabled(bdoenable);
+ i++;
+ }
+ }
+
+ public void addNumberFormats()
+ {
+ iDateFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD");
+ iTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("HH:MM:SS");
+ iDateTimeFormat = oQueryMetaData.getNumberFormatter().defineNumberFormat("YYYY-MM-DD HH:MM:SS");
+ }
+
+ // -------------------------------------------------------------------------
+ //
+ //
+ // -------------------------------------------------------------------------
+ final class ControlRow
+ {
+ private final static int SOLSTFIELDNAME = 3;
+ private final static int SOLSTOPERATOR = 4;
+ private final static int SOTXTVALUE = 5;
+ protected XInterface[] ControlElements = new XInterface[6];
+ private boolean m_bEnabled;
+ String[] FieldNames;
+
+ protected ControlRow(int iCompPosX, int iCompPosY, int Index, boolean _bEnabled, int _firstRowHelpID)
+ {
+ int nFieldWidth = 71;
+ int nOperatorWidth = 70;
+ int nValueWidth = 44;
+
+ int nPosX1 = iCompPosX + 10;
+ int nPosX2 = iCompPosX + 10 + nFieldWidth + 6; // 87
+ int nPosX3 = iCompPosX + 10 + nFieldWidth + 6 + nOperatorWidth + 6;
+
+
+ try
+ {
+ String sCompSuffix = sIncSuffix + "_" + String.valueOf(Index + 1);
+ m_bEnabled = _bEnabled;
+
+ // Label Field
+ ControlElements[0] = (XInterface) CurUnoDialog.insertLabel("lblFieldNames" + sCompSuffix,
+ new String[]
+ {
+ "Enabled",
+ "Height",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Integer.valueOf(9),
+ slblFieldNames,
+ Integer.valueOf(nPosX1),
+ Integer.valueOf(iCompPosY + 13),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nFieldWidth)
+ });
+
+ // Label Operator
+ ControlElements[1] = (XInterface) CurUnoDialog.insertLabel("lblOperators" + sCompSuffix,
+ new String[]
+ {
+ "Enabled",
+ "Height",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Integer.valueOf(9),
+ slblOperators,
+ Integer.valueOf(nPosX2),
+ Integer.valueOf(iCompPosY + 13),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nOperatorWidth)
+ });
+
+ // Label Value
+ ControlElements[2] = (XInterface) CurUnoDialog.insertLabel("lblValue" + sCompSuffix,
+ new String[]
+ {
+ "Enabled",
+ "Height",
+ "Label",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Integer.valueOf(9),
+ slblValue,
+ Integer.valueOf(nPosX3),
+ Integer.valueOf(iCompPosY + 13),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nValueWidth)
+ });
+
+ // Listbox Fields
+ ControlElements[SOLSTFIELDNAME] = (XInterface) CurUnoDialog.insertListBox("lstFieldName" + sCompSuffix, SO_FIELDNAMELIST[Index], null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Enabled",
+ "Dropdown",
+ "Height",
+ "HelpURL",
+ "LineCount",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Boolean.TRUE,
+ Integer.valueOf(13),
+ HelpIds.getHelpIdString(_firstRowHelpID++),
+ Short.valueOf(UnoDialog.getListBoxLineCount() /* 7 */),
+ Integer.valueOf(nPosX1),
+ Integer.valueOf(iCompPosY + 23),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nFieldWidth)
+ });
+
+ // Listbox Operators
+ ControlElements[SOLSTOPERATOR] = (XInterface) CurUnoDialog.insertListBox("lstOperator" + sCompSuffix, SO_CONDITIONLIST[Index], null, new ItemListenerImpl(),
+ new String[]
+ {
+ "Enabled",
+ "Dropdown",
+ "Height",
+ "HelpURL",
+ "LineCount",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "StringItemList",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Boolean.TRUE,
+ Integer.valueOf(13),
+ HelpIds.getHelpIdString(_firstRowHelpID++),
+ Short.valueOf((short) sLogicOperators.length /* 7 */),
+ Integer.valueOf(nPosX2),
+ Integer.valueOf(iCompPosY + 23),
+ IStep,
+ sLogicOperators,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nOperatorWidth)
+ });
+ ControlElements[SOTXTVALUE] = (XInterface) CurUnoDialog.insertFormattedField("txtValue" + sCompSuffix, SO_TEXTFIELDLIST[Index], new TextListenerImpl(),
+ new String[]
+ {
+ "Enabled",
+ "Height",
+ "HelpURL",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Width"
+ },
+ new Object[]
+ {
+ Boolean.valueOf(isEnabled()),
+ Integer.valueOf(13),
+ HelpIds.getHelpIdString(_firstRowHelpID++),
+ Integer.valueOf(nPosX3),
+ Integer.valueOf(iCompPosY + 23),
+ IStep,
+ Short.valueOf(curtabindex++),
+ Integer.valueOf(nValueWidth)
+ });
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * @returns true if the current condition is complete, all needed fields are filled with values.
+ * So we can enable the next.
+ */
+ boolean isConditionComplete()
+ {
+ try
+ {
+ short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), "SelectedItems"));
+ if (SelFields.length > 0)
+ {
+ int nSelOperator = getSelectedOperator();
+ // short[] SelOperator = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems"));
+ if (nSelOperator == com.sun.star.sdb.SQLFilterOperator.SQLNULL
+ || /* is null */ nSelOperator == com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL) /* is not null */
+
+ {
+ // disable value field
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.FALSE);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.FALSE);
+
+ return true;
+ }
+ else
+ {
+ // enable value field
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[2]), "Enabled", Boolean.TRUE);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Enabled", Boolean.TRUE);
+ }
+ if (nSelOperator != -1)
+ {
+ Object oValue = Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue");
+ if (!AnyConverter.isVoid(oValue))
+ {
+ String sValue = (String.valueOf(oValue));
+ return (!sValue.equals(""));
+ }
+ }
+ }
+ return false;
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ protected void setCondition(PropertyValue _filtercondition)
+ {
+ try
+ {
+ XListBox xFieldsListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTFIELDNAME]);
+ xFieldsListBox.selectItem(_filtercondition.Name, true);
+ XListBox xOperatorListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, ControlElements[SOLSTOPERATOR]);
+ xOperatorListBox.selectItemPos((short) (_filtercondition.Handle - 1), true);
+
+ if (AnyConverter.isString(_filtercondition.Value))
+ {
+ String sValue = AnyConverter.toString(_filtercondition.Value);
+ if (sValue.indexOf("{D '") > -1)
+ {
+ sValue = JavaTools.replaceSubString(sValue, "", "{D '");
+ sValue = JavaTools.replaceSubString(sValue, "", "' }");
+ try
+ {
+ oQueryMetaData.getNumberFormatter().convertStringToNumber(iDateFormat, sValue);
+ }
+ catch (java.lang.Exception ex)
+ {
+ Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ else if (sValue.indexOf("{T '") > -1)
+ {
+ sValue = JavaTools.replaceSubString(sValue, "", "{T '");
+ sValue = JavaTools.replaceSubString(sValue, "", "' }");
+ try
+ {
+ oQueryMetaData.getNumberFormatter().convertStringToNumber(iTimeFormat, sValue);
+ }
+ catch (java.lang.Exception ex)
+ {
+ Logger.getLogger(FilterComponent.class.getName()).log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+ else if (AnyConverter.isBoolean(_filtercondition.Value))
+ {
+ boolean b = AnyConverter.toBoolean(_filtercondition.Value);
+ double nValue = 0.0;
+ if (b)
+ {
+ nValue = 1.0;
+ }
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", nValue);
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", _filtercondition.Value);
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ }
+
+ protected void setFieldNames(String[] _FieldNames)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), "StringItemList", _FieldNames);
+ FieldNames = _FieldNames;
+ }
+
+ protected boolean isEnabled()
+ {
+ return m_bEnabled;
+ }
+
+ private void settovoid()
+ {
+ WizardDialog.deselectListBox(ControlElements[SOLSTFIELDNAME]);
+ WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue", com.sun.star.uno.Any.VOID);
+ }
+
+ private void setEnabled(boolean _bEnabled)
+ {
+ // enable all Controls Fieldname, operator, value
+ for (int i = 0; i < ControlElements.length; i++)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[i]), "Enabled", Boolean.valueOf(_bEnabled));
+ }
+ m_bEnabled = _bEnabled;
+ if (isEnabled())
+ {
+ short[] iselected = new short[]
+ {
+ };
+ try
+ {
+ iselected = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems"));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace(System.out);
+ }
+ if ((iselected.length) == 0)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems", new short[]
+ {
+ 0
+ });
+ }
+ }
+ else if (!isConditionComplete())
+ {
+ WizardDialog.deselectListBox(ControlElements[SOLSTOPERATOR]);
+ }
+ }
+
+ protected String getSelectedFieldName()
+ {
+ try
+ {
+ short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTFIELDNAME]), "SelectedItems"));
+ return FieldNames[SelFields[0]];
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return null;
+ }
+
+ // TODO: check if it is really useful to match the indices of the listbox the API constants
+ // =, <>, <, >, <=, >=, like, !like, is null, !is null
+ protected short getSelectedOperator()
+ {
+ try
+ {
+ short[] SelFields = (short[]) AnyConverter.toArray(Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOLSTOPERATOR]), "SelectedItems"));
+ switch (SelFields[0])
+ {
+ case 0:
+ return com.sun.star.sdb.SQLFilterOperator.EQUAL;
+ case 1:
+ return com.sun.star.sdb.SQLFilterOperator.NOT_EQUAL;
+ case 2:
+ return com.sun.star.sdb.SQLFilterOperator.LESS;
+ case 3:
+ return com.sun.star.sdb.SQLFilterOperator.GREATER;
+ case 4:
+ return com.sun.star.sdb.SQLFilterOperator.LESS_EQUAL;
+ case 5:
+ return com.sun.star.sdb.SQLFilterOperator.GREATER_EQUAL;
+ case 6:
+ return com.sun.star.sdb.SQLFilterOperator.LIKE;
+ case 7:
+ return com.sun.star.sdb.SQLFilterOperator.NOT_LIKE;
+ case 8:
+ return com.sun.star.sdb.SQLFilterOperator.SQLNULL;
+ case 9:
+ return com.sun.star.sdb.SQLFilterOperator.NOT_SQLNULL;
+ default:
+ return -1;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ return -1;
+ }
+
+ // TODO make a difference between Text and Numbers
+ protected Object getValue()
+ {
+ return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "EffectiveValue"));
+ }
+
+ protected Object getText()
+ {
+ return (Helper.getUnoPropertyValue(UnoDialog.getModel(ControlElements[SOTXTVALUE]), "Text"));
+ }
+
+ protected String getDateTimeString(boolean bgetDate)
+ {
+ double dblValue = ((Double) getValue()).doubleValue();
+ NumberFormatter oNumberFormatter = oQueryMetaData.getNumberFormatter();
+ return oNumberFormatter.convertNumberToString(iDateTimeFormat, dblValue);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/ImageList.java b/wizards/com/sun/star/wizards/ui/ImageList.java
new file mode 100644
index 000000000000..56e2edb3172f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/ImageList.java
@@ -0,0 +1,1134 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+// import com.sun.star.awt.*;
+
+import com.sun.star.awt.Key;
+import com.sun.star.awt.KeyEvent;
+import com.sun.star.awt.MouseEvent;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XItemEventBroadcaster;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XKeyListener;
+import com.sun.star.awt.XMouseListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.IRenderer;
+import com.sun.star.wizards.ui.event.*;
+
+
+//import com.sun.star.awt.ItemEvent;
+//import com.sun.star.awt.XItemListener;
+
+
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class ImageList implements XItemEventBroadcaster, ListDataListener
+{
+
+ // private XControl imgContainer;
+ private XFixedText lblImageText;
+ private XFixedText grbxSelectedImage;
+ private XButton btnBack;
+ private XButton btnNext;
+ private XFixedText lblCounter;
+ private XControl m_aImages[];
+ private boolean benabled = true;
+ private UnoDialog2 oUnoDialog;
+ private Size gap = new Size(4, 4);
+ private int cols = 4;
+ private int rows = 3;
+ private Size imageSize = new Size(20, 20);
+ private Size pos;
+ private Size selectionGap = new Size(2, 2);
+ private boolean showButtons = true;
+ private Short step;
+ private final static Short NO_BORDER = new Short((short) 0);
+ private boolean refreshOverNull = true;
+ private int imageTextLines = 1;
+ private boolean rowSelect = false;
+ public int tabIndex;
+ public Boolean scaleImages = Boolean.TRUE;
+ public String name = "il";
+ private int selected = -1;
+ private int pageStart = 0;
+ public int helpURL = 0;
+ private CommonListener uiEventListener = new CommonListener();
+ private IImageRenderer renderer;
+ private ListModel listModel;
+ public IRenderer counterRenderer = new SimpleCounterRenderer();
+ private Object dialogModel;
+ private ImageKeyListener imageKeyListener;
+ private static final Integer BACKGROUND_COLOR = new Integer(16777216); //new Integer(SystemColor.window.getRGB() + 16777216);
+ private final static Short HIDE_PAGE = new Short((short) 99);
+ private final static Integer TRANSPARENT = new Integer(-1);
+ private final static int LINE_HEIGHT = 8; //private MethodInvocation METHOD_MOUSE_ENTER_IMAGE;
+ //private MethodInvocation METHOD_MOUSE_EXIT_IMAGE;
+ private MethodInvocation METHOD_MOUSE_PRESSED;
+
+ /** Getter for property imageSize.
+ * @return Value of property imageSize.
+ *
+ */
+ public Size getImageSize()
+ {
+ return this.imageSize;
+ }
+
+ /** Setter for property imageSize.
+ * @param imageSize New value of property imageSize.
+ *
+ */
+ public void setImageSize(Size imageSize)
+ {
+ this.imageSize = imageSize;
+ }
+
+ class OMouseListener implements XMouseListener
+ {
+ public OMouseListener()
+ {}
+ public void mousePressed(MouseEvent arg0)
+ {
+ focus(getImageIndexFor(getSelected()));
+ }
+
+ public void mouseReleased(MouseEvent arg0)
+ {
+ }
+
+ public void mouseEntered(MouseEvent arg0)
+ {
+ }
+
+ public void mouseExited(MouseEvent arg0)
+ {
+ }
+
+ public void disposing(EventObject arg0)
+ {
+ }
+ }
+
+ public void create(UnoDialog2 dialog)
+ {
+ oUnoDialog = dialog;
+ dialogModel = dialog.xDialogModel;
+
+ int imageTextHeight = imageTextLines * LINE_HEIGHT;
+
+ PeerConfig opeerConfig = new PeerConfig(dialog);
+
+ MOVE_SELECTION_VALS[2] = step;
+
+ XControl imgContainer = dialog.insertImage(name + "lblContainer",
+ new String[]
+ {
+ "BackgroundColor",
+ "Border",
+ "Height",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "Width"
+ },
+ new Object[]
+ {
+ BACKGROUND_COLOR,
+ new Short((short) 1),
+ new Integer((imageSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1),
+ new Integer(pos.Width),
+ new Integer(pos.Height),
+ step,
+ new Integer((imageSize.Width + gap.Width) * cols + gap.Width)
+ });
+
+ opeerConfig.setPeerProperties(imgContainer, new String[]
+ {
+ "MouseTransparent"
+ }, new Object[]
+ {
+ Boolean.TRUE
+ });
+
+ //XWindow win = (XWindow)UnoRuntime.queryInterface(XWindow.class,lblContainer);
+ /*dialog.xWindow.addWindowListener(uiEventListener);
+ String dName = (String)Helper.getUnoPropertyValue(dialog.xDialogModel,"Name");
+
+ uiEventListener.add(dName,EventNames.EVENT_WINDOW_SHOWN,"disableContainerMouseEvents",this);
+ */
+ int selectionWidth = rowSelect ?
+ (imageSize.Width + gap.Width) * cols - gap.Width + (selectionGap.Width * 2) :
+ imageSize.Width + (selectionGap.Width * 2);
+
+ grbxSelectedImage = dialog.insertLabel(name + "_grbxSelected", new String[]
+ {
+ "BackgroundColor",
+ "Border",
+ "Height",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "Tabstop",
+ "Width"
+ }, new Object[]
+ {
+ TRANSPARENT,
+ new Short((short) 1),
+ new Integer(imageSize.Height + (selectionGap.Height * 2)),
+ //height
+ new Integer(0), //posx
+ new Integer(0), //posy
+ step,
+ Boolean.TRUE,
+ new Integer(selectionWidth)
+ });
+
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, grbxSelectedImage);
+ xWindow.addMouseListener(new OMouseListener());
+
+ final String[] pNames1 = new String[]
+ {
+ "Height",
+ "HelpURL",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Width"
+ };
+
+ lblImageText = dialog.insertLabel(name + "_imageText", pNames1, new Object[]
+ {
+ new Integer(imageTextHeight),
+ "",
+ new Integer(pos.Width + 1),
+ new Integer(pos.Height + (imageSize.Height + gap.Height) * rows + gap.Height),
+ step,
+ new Short((short) 0),
+ Boolean.FALSE,
+ new Integer(cols * (imageSize.Width + gap.Width) + gap.Width - 2)
+ });
+
+
+ if (showButtons)
+ {
+ final Integer btnSize = new Integer(14);
+
+ btnBack = dialog.insertButton(name + "_btnBack", "prevPage", this, pNames1, new Object[]
+ {
+ btnSize,
+ HelpIds.getHelpIdString(helpURL++),
+ new Integer(pos.Width),
+ new Integer(pos.Height + (imageSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1),
+ step,
+ new Short((short) (tabIndex + 1)),
+ Boolean.TRUE,
+ btnSize
+ });
+
+ btnNext = dialog.insertButton(name + "_btnNext", "nextPage", this, pNames1, new Object[]
+ {
+ btnSize,
+ HelpIds.getHelpIdString(helpURL++),
+ new Integer(pos.Width + (imageSize.Width + gap.Width) * cols + gap.Width - btnSize.intValue() + 1),
+ new Integer(pos.Height + (imageSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + 1),
+ step,
+ new Short((short) (tabIndex + 2)),
+ Boolean.TRUE,
+ btnSize
+ });
+
+ lblCounter = dialog.insertLabel(name + "_lblCounter", pNames1, new Object[]
+ {
+ new Integer(LINE_HEIGHT),
+ "",
+ new Integer(pos.Width + btnSize.intValue() + 1),
+ new Integer(pos.Height + (imageSize.Height + gap.Height) * rows + gap.Height + imageTextHeight + ((btnSize.intValue() - LINE_HEIGHT) / 2)),
+ step,
+ new Short((short) 0),
+ Boolean.FALSE,
+ new Integer(cols * (imageSize.Width + gap.Width) + gap.Width - 2 * btnSize.intValue() - 1)
+ });
+
+ Helper.setUnoPropertyValue(getModel(lblCounter), "Align", new Short((short) 1));
+ Helper.setUnoPropertyValue(getModel(btnBack), "Label", "<");
+ Helper.setUnoPropertyValue(getModel(btnNext), "Label", ">");
+
+
+ }
+
+ imageKeyListener = new ImageKeyListener();
+ m_tabIndex = new Short((short) tabIndex);
+
+ m_aImages = new XControl[rows * cols];
+
+ try
+ {
+ //METHOD_MOUSE_ENTER_IMAGE = new MethodInvocation("mouseEnterImage",this,Object.class);
+ //METHOD_MOUSE_EXIT_IMAGE = new MethodInvocation("mouseExitImage",this,Object.class);
+ METHOD_MOUSE_PRESSED = new MethodInvocation("mousePressed", this, Object.class);
+ }
+ catch (NoSuchMethodException e)
+ {
+ e.printStackTrace();
+ }
+
+ m_imageHeight = new Integer(imageSize.Height);
+ m_imageWidth = new Integer(imageSize.Width);
+
+ for (int r = 0; r < rows; r++)
+ {
+ for (int c = 0; c < cols; c++)
+ {
+ m_aImages[r * cols + c] = createImage(dialog, r, c);
+ }
+ }
+ refreshImages();
+
+ listModel.addListDataListener(this);
+
+ }
+ private Integer m_imageHeight, m_imageWidth;
+ private final static String[] IMAGE_PROPS = new String[]
+ {
+ "Border",
+ "BackgroundColor",
+ "Height",
+ "HelpURL",
+ "PositionX",
+ "PositionY",
+ "ScaleImage",
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Width"
+ };
+ //used for optimization
+ private Short m_tabIndex;
+
+ private XControl createImage(UnoDialog2 dialog, int _row, int _col)
+ {
+ String imageName = name + "_image" + (_row * cols + _col);
+ XControl image = dialog.insertImage(imageName,
+ IMAGE_PROPS,
+ new Object[]
+ {
+ NO_BORDER,
+ BACKGROUND_COLOR,
+ m_imageHeight,
+ HelpIds.getHelpIdString(helpURL++),
+ new Integer(getImagePosX(_col)),
+ new Integer(getImagePosY(_row)),
+ scaleImages,
+ step,
+ m_tabIndex,
+ Boolean.FALSE,
+ m_imageWidth
+ });
+
+ XWindow win = (XWindow) UnoRuntime.queryInterface(XWindow.class, image);
+ win.addMouseListener(uiEventListener);
+ win.addKeyListener(imageKeyListener);
+ //uiEventListener.add(imageName,EventNames.EVENT_MOUSE_ENTERED,METHOD_MOUSE_ENTER_IMAGE);
+ //uiEventListener.add(imageName,EventNames.EVENT_MOUSE_EXITED,METHOD_MOUSE_EXIT_IMAGE);
+ uiEventListener.add(imageName, EventNames.EVENT_MOUSE_PRESSED, METHOD_MOUSE_PRESSED);
+
+ return image;
+ }
+
+ private int getImagePosX(int col)
+ {
+ return pos.Width + col * (imageSize.Width + gap.Width) + gap.Width;
+ }
+
+ private int getImagePosY(int row)
+ {
+ return pos.Height + row * (imageSize.Height + gap.Height) + gap.Height;
+ }
+
+ private void refreshImages()
+ {
+ if (showButtons)
+ {
+ refreshCounterText();
+ }
+ hideSelection();
+ if (refreshOverNull)
+ {
+ for (int i = 0; i < m_aImages.length; i++)
+ {
+ setVisible(m_aImages[i], false);
+ }
+ }
+ boolean focusable = true;
+ for (int i = 0; i < m_aImages.length; i++)
+ {
+ Object[] oResources = renderer.getImageUrls(getObjectFor(i));
+ if (oResources != null)
+ {
+ if (oResources.length == 1)
+ {
+ Helper.setUnoPropertyValue(m_aImages[i].getModel(), "ImageURL", (String) oResources[0]);
+ }
+ else if (oResources.length == 2)
+ {
+ oUnoDialog.getPeerConfiguration().setImageUrl(m_aImages[i].getModel(), oResources[0], oResources[1]);
+ }
+ Helper.setUnoPropertyValue(m_aImages[i].getModel(), "Tabstop", focusable ? Boolean.TRUE : Boolean.FALSE);
+ if (refreshOverNull)
+ {
+ setVisible(m_aImages[i], true);
+ }
+ focusable = false;
+ }
+ }
+ refreshSelection();
+ }
+
+ private void refreshCounterText()
+ {
+ Helper.setUnoPropertyValue(getModel(lblCounter), "Label", counterRenderer.render(new Counter(pageStart + 1, pageEnd(), listModel.getSize())));
+ }
+
+ private int pageEnd()
+ {
+ int i = pageStart + cols * rows;
+ if (i > listModel.getSize() - 1)
+ {
+ return listModel.getSize();
+ }
+ else
+ {
+ return i;
+ }
+ }
+
+ private void refreshSelection()
+ {
+ if (selected < pageStart || selected >= (pageStart + rows * cols))
+ {
+ hideSelection();
+ }
+ else
+ {
+ moveSelection(getImageIndexFor(selected));
+ }
+ }
+
+ private void hideSelection()
+ {
+ Helper.setUnoPropertyValue(getModel(grbxSelectedImage), "Step", HIDE_PAGE);
+ setVisible(grbxSelectedImage, false);
+ }
+ private final static String[] MOVE_SELECTION = new String[]
+ {
+ "PositionX", "PositionY", "Step"
+ };
+ private Object[] MOVE_SELECTION_VALS = new Object[3];
+ /** Utility field holding list of ItemListeners. */
+ private transient java.util.ArrayList itemListenerList;
+
+ private void moveSelection(int image)
+ {
+ //System.out.println(image);
+ setVisible(grbxSelectedImage, false);
+
+ int row = image / cols;
+ int col = rowSelect ? 0 : image - (row * cols);
+
+ MOVE_SELECTION_VALS[0] = new Integer(getImagePosX(col) - selectionGap.Width);
+ MOVE_SELECTION_VALS[1] = new Integer(getImagePosY(row) - selectionGap.Height);
+
+ Helper.setUnoPropertyValues(getModel(grbxSelectedImage), MOVE_SELECTION, MOVE_SELECTION_VALS);
+
+ if (((Number) Helper.getUnoPropertyValue(dialogModel, "Step")).shortValue() == step.shortValue())
+ {
+ setVisible(grbxSelectedImage, true); //now focus...
+ }
+ for (int i = 0; i < m_aImages.length; i++)
+ {
+ if (i != image)
+ {
+ defocus(i);
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(m_aImages[image].getModel(), "Tabstop", Boolean.TRUE);
+ }
+ }
+ }
+
+ private void setVisible(Object control, boolean visible)
+ {
+ ((XWindow) UnoRuntime.queryInterface(XWindow.class, control)).setVisible(visible);
+ }
+
+ /**
+ *
+ * @param i
+ * @return the Object in the list model corresponding to the given image index.
+ */
+ private Object getObjectFor(int i)
+ {
+ int ii = getIndexFor(i);
+ if (listModel.getSize() <= ii)
+ {
+ return null;
+ }
+ else
+ {
+ return listModel.getElementAt(ii);
+ }
+ }
+
+ /**
+ *
+ * @param i
+ * @return the index in the listModel for the given image index.
+ */
+ private int getIndexFor(int i)
+ {
+ return pageStart + i;
+ }
+
+ private int getImageIndexFor(int i)
+ {
+ return i - pageStart;
+ }
+
+ public void contentsChanged(ListDataEvent event)
+ {
+ /*//if the content that was changed is in the displayed range, refresh...
+ if ( (event.getIndex1() < getIndexFor(0)) // range is before...
+ || event.getIndex0() > getIndexFor( cols*rows - 1)) ; //do nothing
+ else
+ refreshImages();
+ */ //selected = 0;
+ //pageStart = 0;
+ //if (event.refreshImages();
+ }
+
+ public void intervalAdded(ListDataEvent event)
+ {
+ if (event.getIndex0() <= selected)
+ {
+ if (event.getIndex1() <= selected)
+ {
+ selected += event.getIndex1() - event.getIndex0() + 1;
+ }
+ }
+ if (event.getIndex0() < pageStart || event.getIndex1() < (pageStart + getRows() + getCols()))
+ {
+ refreshImages();
+ }
+ }
+
+ public void intervalRemoved(ListDataEvent event)
+ {
+ //contentsChanged(event);
+ }
+
+ /** Registers ItemListener to receive events.
+ * @param listener The listener to register.
+ *
+ */
+ public synchronized void addItemListener(XItemListener listener)
+ {
+ if (itemListenerList == null)
+ {
+ itemListenerList = new java.util.ArrayList();
+ }
+ itemListenerList.add(listener);
+ }
+
+ /** Removes ItemListener from the list of listeners.
+ * @param listener The listener to remove.
+ *
+ */
+ public synchronized void removeItemListener(XItemListener listener)
+ {
+ if (itemListenerList != null)
+ {
+ itemListenerList.remove(listener);
+ }
+ }
+
+ /** Notifies all registered listeners about the event.
+ *
+ * @param event The event to be fired
+ *
+ */
+ private void fireItemSelected()
+ {
+// java.awt.event.ItemEvent event = new java.awt.event.ItemEvent(this, 0,
+// getSelectedObject(), java.awt.event.ItemEvent.SELECTED);
+ java.util.ArrayList list;
+ synchronized(this)
+ {
+ if (itemListenerList == null)
+ {
+ return;
+ }
+ list = (java.util.ArrayList) itemListenerList.clone();
+ }
+ for (int i = 0; i < list.size(); i++)
+ {
+ ((com.sun.star.awt.XItemListener) list.get(i)).itemStateChanged(null);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public int getCols()
+ {
+ return cols;
+ }
+
+ /**
+ * @return
+ */
+ public Size getGap()
+ {
+ return gap;
+ }
+
+ /**
+ * @return
+ */
+ public ListModel getListModel()
+ {
+ return listModel;
+ }
+
+ /**
+ * @return
+ */
+ public Short getStep()
+ {
+ return step;
+ }
+
+ /**
+ * @return
+ */
+ public int getPageStart()
+ {
+ return pageStart;
+ }
+
+ /**
+ * @return
+ */
+ public Size getPos()
+ {
+ return pos;
+ }
+
+ /**
+ * @return
+ */
+ public IImageRenderer getRenderer()
+ {
+ return renderer;
+ }
+
+ /**
+ * @return
+ */
+ public int getRows()
+ {
+ return rows;
+ }
+
+ /**
+ * @return
+ */
+ public int getSelected()
+ {
+ return selected;
+ }
+
+ /**
+ * @return
+ */
+ public Size getSelectionGap()
+ {
+ return selectionGap;
+ }
+
+ /**
+ * @return
+ */
+ public boolean isShowButtons()
+ {
+ return showButtons;
+ }
+
+ /**
+ * @param i
+ */
+ public void setCols(int i)
+ {
+ cols = i;
+ }
+
+ /**
+ * @param size
+ */
+ public void setGap(Size size)
+ {
+ gap = size;
+ }
+
+ /**
+ * @param model
+ */
+ public void setListModel(ListModel model)
+ {
+ listModel = model;
+ }
+
+ /**
+ * @param short1
+ */
+ public void setStep(Short short1)
+ {
+ step = short1;
+ }
+
+ /**
+ * @param i
+ */
+ public void setPageStart(int i)
+ {
+ if (i == pageStart)
+ {
+ return;
+ }
+ pageStart = i;
+ enableButtons();
+ refreshImages();
+ }
+
+ /**
+ * @param size
+ */
+ public void setPos(Size size)
+ {
+ pos = size;
+ }
+
+ /**
+ * @param renderer
+ */
+ public void setRenderer(IImageRenderer renderer)
+ {
+ this.renderer = renderer;
+ }
+
+ /**
+ * @param i
+ */
+ public void setRows(int i)
+ {
+ rows = i;
+ }
+
+ /**
+ * @param i
+ */
+ public void setSelected(int i)
+ {
+ if (rowSelect && (i >= 0))
+ {
+ i = (i / cols) * cols;
+ }
+ if (selected == i)
+ {
+ return;
+ }
+ selected = i;
+ refreshImageText();
+ refreshSelection();
+ fireItemSelected();
+ }
+
+ public void setSelected(Object object)
+ {
+ if (object == null)
+ {
+ setSelected(-1);
+ }
+ else
+ {
+ for (int i = 0; i < getListModel().getSize(); i++)
+ {
+ if (getListModel().getElementAt(i).equals(object))
+ {
+ setSelected(i);
+ return;
+ }
+ }
+ }
+ setSelected(-1);
+
+ }
+
+ private void refreshImageText()
+ {
+ Object item = selected >= 0 ? getListModel().getElementAt(selected) : null;
+ Helper.setUnoPropertyValue(getModel(lblImageText), "Label", " " + renderer.render(item));
+ }
+
+ /**
+ * @param size
+ */
+ public void setSelectionGap(Size size)
+ {
+ selectionGap = size;
+ }
+
+ /**
+ * @param b
+ */
+ public void setShowButtons(boolean b)
+ {
+ showButtons = b;
+ }
+
+ public void nextPage()
+ {
+ if (pageStart < getListModel().getSize() - rows * cols)
+ {
+ setPageStart(pageStart + rows * cols);
+ }
+ }
+
+ public void prevPage()
+ {
+ if (pageStart == 0)
+ {
+ return;
+ }
+ int i = pageStart - rows * cols;
+ if (i < 0)
+ {
+ i = 0;
+ }
+ setPageStart(i);
+ }
+
+ private void enableButtons()
+ {
+ enable(btnNext, new Boolean(pageStart + rows * cols < listModel.getSize()));
+ enable(btnBack, new Boolean(pageStart > 0));
+ }
+
+ private void enable(Object control, Boolean enable)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Enabled", enable);
+ }
+
+ private Object getModel(Object control)
+ {
+ return ((XControl) UnoRuntime.queryInterface(XControl.class, control)).getModel();
+ }
+
+ /*
+ public void mouseEnterImage(Object event) {
+ System.out.println("mouse enter");
+ int i = getImageFromEvent(event);
+ //TODO what is when the image does not display an image?
+ if (getIndexFor(i) != selected)
+ setBorder(m_aImages[i],imageBorderMO);
+ }
+
+ public void mouseExitImage(Object event) {
+ //System.out.println("mouse exit");
+ int i = getImageFromEvent(event);
+ //TODO what is when the image does not display an image?
+ if (getIndexFor(i) != selected)
+ setBorder(m_aImages[i],imageBorder);
+ }
+ */
+ private void setBorder(Object control, Short border)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Border", border);
+ //XWindowPeer peer = ((XControl)UnoRuntime.queryInterface(XControl.class,control)).getPeer();
+ //peer.invalidate(InvalidateStyle.CHILDREN);
+ }
+
+ private int getImageFromEvent(Object event)
+ {
+ Object image = ((EventObject) event).Source;
+ String controlName = (String) Helper.getUnoPropertyValue(getModel(image), "Name");
+ return Integer.valueOf(controlName.substring(6 + name.length())).intValue();
+
+ }
+
+ public void mousePressed(Object event)
+ {
+ int image = getImageFromEvent(event);
+ int index = getIndexFor(image);
+ if (index < listModel.getSize())
+ {
+ focus(image);
+ setSelected(index);
+ }
+ }
+
+ public Object[] getSelectedObjects()
+ {
+ return new Object[]
+ {
+ getListModel().getElementAt(selected)
+ };
+ }
+
+ /**
+ */
+ public static interface IImageRenderer extends IRenderer
+ {
+
+ /**
+ *
+ * @param listItem
+ * @return two resource ids for an image referenced in the imaglist resourcefile of the
+ * wizards project; The second one of them is designed to be used for High Contrast Mode.
+ */
+ public Object[] getImageUrls(Object listItem);
+ }
+
+ private static class SimpleCounterRenderer implements IRenderer
+ {
+
+ public String render(Object counter)
+ {
+ return "" + ((Counter) counter).start + ".." + ((Counter) counter).end + "/" + ((Counter) counter).max;
+ }
+ }
+
+ public static class Counter
+ {
+
+ public int start, end, max;
+
+ public Counter(int start_, int end_, int max_)
+ {
+ start = start_;
+ end = end_;
+ max = max_;
+ }
+ }
+
+ public Object getSelectedObject()
+ {
+ return selected >= 0 ? getListModel().getElementAt(selected) : null;
+ }
+
+ public void showSelected()
+ {
+ int oldPageStart = pageStart;
+ if (selected == -1)
+ {
+ pageStart += 0;
+ }
+ else
+ {
+ pageStart = (selected / m_aImages.length) * m_aImages.length;
+ }
+ if (oldPageStart != pageStart)
+ {
+ enableButtons();
+ refreshImages();
+ }
+ }
+
+ public void setRowSelect(boolean b)
+ {
+ rowSelect = b;
+ }
+
+ public boolean isRowSelect()
+ {
+ return rowSelect;
+ }
+
+ private class ImageKeyListener implements XKeyListener
+ {
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XKeyListener#keyPressed(com.sun.star.awt.KeyEvent)
+ */
+ public void keyPressed(KeyEvent ke)
+ {
+ int image = getImageFromEvent(ke);
+ int r = image / getCols();
+ int c = image - (r * getCols());
+ int d = getKeyMove(ke, r, c);
+ int newImage = image + d;
+ if (newImage == image)
+ {
+ return;
+ }
+ if (isFocusable(newImage))
+ {
+ changeFocus(image, newImage);
+ }
+ }
+
+ private boolean isFocusable(int image)
+ {
+ return (image >= 0) && (getIndexFor(image) < listModel.getSize());
+ }
+
+ private void changeFocus(int oldFocusImage, int newFocusImage)
+ {
+ focus(newFocusImage);
+ defocus(oldFocusImage);
+ }
+
+ private final int getKeyMove(KeyEvent ke, int row, int col)
+ {
+ switch (ke.KeyCode)
+ {
+ case Key.UP:
+ if (row > 0)
+ {
+ return 0 - getCols();
+ }
+ break;
+ case Key.DOWN:
+ if (row < getRows() - 1)
+ {
+ return getCols();
+ }
+ break;
+ case Key.LEFT:
+ if (col > 0)
+ {
+ return -1;
+ }
+ break;
+ case Key.RIGHT:
+ if (col < getCols() - 1)
+ {
+ return 1;
+ }
+ break;
+ case Key.SPACE:
+ select(ke);
+ }
+ return 0;
+ }
+
+ private void select(KeyEvent ke)
+ {
+ setSelected(getIndexFor(getImageFromEvent(ke)));
+ }
+
+ public void keyReleased(KeyEvent ke)
+ {
+ }
+
+ public void disposing(EventObject arg0)
+ {
+ }
+ }
+
+ private final void focus(int image)
+ {
+ Helper.setUnoPropertyValue(m_aImages[image].getModel(), "Tabstop",
+ Boolean.TRUE);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, m_aImages[image]);
+ xWindow.setFocus();
+ }
+
+ private final void defocus(int image)
+ {
+ Helper.setUnoPropertyValue(UnoDialog.getModel(m_aImages[image]), "Tabstop",
+ Boolean.FALSE);
+
+ }
+
+ /**
+ * jump to the given item (display the screen
+ * that contains the given item).
+ * @param i
+ */
+ public void display(int i)
+ {
+ int is = (getCols() * getRows());
+ int ps = (listModel.getSize() / is) * is;
+ setPageStart(ps);
+ }
+
+ /**
+ * @return
+ */
+ public boolean isenabled()
+ {
+ return benabled;
+ }
+
+ /**
+ * @param b
+ */
+ public void setenabled(boolean b)
+ {
+
+ for (int i = 0; i < m_aImages.length; i++)
+ {
+ UnoDialog2.setEnabled(m_aImages[i], b);
+ }
+ UnoDialog2.setEnabled(grbxSelectedImage, b);
+ UnoDialog2.setEnabled(lblImageText, b);
+ if (showButtons)
+ {
+ UnoDialog2.setEnabled(btnBack, b);
+ UnoDialog2.setEnabled(btnNext, b);
+ UnoDialog2.setEnabled(lblCounter, b);
+ }
+ benabled = b;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/PathSelection.java b/wizards/com/sun/star/wizards/ui/PathSelection.java
new file mode 100755
index 000000000000..4cb101382c6d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/PathSelection.java
@@ -0,0 +1,188 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.Exception;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.SystemDialog;
+
+public class PathSelection
+{
+
+ UnoDialog2 CurUnoDialog;
+ XMultiServiceFactory xMSF;
+ int iDialogType;
+ int iTransferMode;
+ public String sDefaultDirectory = "";
+ public String sDefaultName = "";
+ public String sDefaultFilter = "";
+ public boolean usedPathPicker = false;
+ public XPathSelectionListener xAction;
+ public XTextComponent xSaveTextBox;
+ private final int CMDSELECTPATH = 1;
+ private final int TXTSAVEPATH = 1;
+
+ public static class DialogTypes
+ {
+
+ public static final int FOLDER = 0;
+ public static final int FILE = 1;
+ }
+
+ public static class TransferMode
+ {
+
+ public static final int SAVE = 0;
+ public static final int LOAD = 1;
+ }
+
+ public PathSelection(XMultiServiceFactory xMSF, UnoDialog2 CurUnoDialog, int TransferMode, int DialogType)
+ {
+ this.CurUnoDialog = CurUnoDialog;
+ this.xMSF = xMSF;
+ this.iDialogType = DialogType;
+ this.iTransferMode = TransferMode;
+
+ }
+
+ public void insert(int DialogStep, int XPos, int YPos, int Width, short CurTabIndex, String LabelText, boolean Enabled, String TxtHelpURL, String BtnHelpURL)
+ {
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblSaveAs", new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, new Object[]
+ {
+ new Boolean(Enabled), new Integer(8), LabelText, new Integer(XPos), new Integer(YPos), new Integer(DialogStep), new Short(CurTabIndex), new Integer(Width)
+ });
+
+ xSaveTextBox = CurUnoDialog.insertTextField("txtSavePath", "callXPathSelectionListener", this, new String[]
+ {
+ "Enabled", "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, new Object[]
+ {
+ new Boolean(Enabled), new Integer(12), TxtHelpURL, new Integer(XPos), new Integer(YPos + 10), new Integer(DialogStep), new Short((short) (CurTabIndex + 1)), new Integer(Width - 26)
+ });
+ //CurUnoDialog.setControlProperty("txtSavePath", "ReadOnly", Boolean.TRUE);
+ CurUnoDialog.setControlProperty("txtSavePath", "Enabled", Boolean.FALSE);
+ CurUnoDialog.insertButton("cmdSelectPath", "triggerPathPicker", this, new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, new Object[]
+ {
+ new Boolean(Enabled), new Integer(14), BtnHelpURL, "...", new Integer(XPos + Width - 16), new Integer(YPos + 9), new Integer(DialogStep), new Short((short) (CurTabIndex + 2)), new Integer(16)
+ });
+
+ }
+
+ public void addSelectionListener(XPathSelectionListener xAction)
+ {
+ this.xAction = xAction;
+ }
+
+ public String getSelectedPath()
+ {
+ return xSaveTextBox.getText();
+ }
+
+ public void initializePath()
+ {
+ try
+ {
+ FileAccess myFA = new FileAccess(xMSF);
+ xSaveTextBox.setText(myFA.getPath(sDefaultDirectory + "/" + sDefaultName, null));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ public void triggerPathPicker()
+ {
+ try
+ {
+ switch (iTransferMode)
+ {
+ case TransferMode.SAVE:
+ switch (iDialogType)
+ {
+ case DialogTypes.FOLDER:
+ //TODO: write code for picking a folder for saving
+ break;
+ case DialogTypes.FILE:
+ usedPathPicker = true;
+ SystemDialog myFilePickerDialog = SystemDialog.createStoreDialog(xMSF);
+ myFilePickerDialog.callStoreDialog(sDefaultDirectory, sDefaultName, sDefaultFilter);
+ String sStorePath = myFilePickerDialog.sStorePath;
+ if (sStorePath != null)
+ {
+ FileAccess myFA = new FileAccess(xMSF);
+ xSaveTextBox.setText(myFA.getPath(sStorePath, null));
+ sDefaultDirectory = FileAccess.getParentDir(sStorePath);
+ sDefaultName = myFA.getFilename(sStorePath);
+ }
+ break;
+ default:
+ break;
+ }
+ break;
+ case TransferMode.LOAD:
+ switch (iDialogType)
+ {
+ case DialogTypes.FOLDER:
+ //TODO: write code for picking a folder for loading
+ break;
+ case DialogTypes.FILE:
+ //TODO: write code for picking a file for loading
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ public void callXPathSelectionListener()
+ {
+ if (xAction != null)
+ {
+ xAction.validatePath();
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/PeerConfig.java b/wizards/com/sun/star/wizards/ui/PeerConfig.java
new file mode 100644
index 000000000000..d3871ee62a5b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/PeerConfig.java
@@ -0,0 +1,261 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import java.util.Vector;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class PeerConfig implements XWindowListener
+{
+
+ private Vector m_aPeerTasks = new Vector();
+ Vector aControlTasks = new Vector();
+ Vector aImageUrlTasks = new Vector();
+ UnoDialog oUnoDialog = null;
+
+ public PeerConfig(UnoDialog _oUnoDialog)
+ {
+ oUnoDialog = _oUnoDialog;
+ oUnoDialog.xWindow.addWindowListener(this);
+ }
+
+ class PeerTask
+ {
+
+ XControl xControl;
+ String[] propnames;
+ Object[] propvalues;
+
+ public PeerTask(XControl _xControl, String[] propNames_, Object[] propValues_)
+ {
+ propnames = propNames_;
+ propvalues = propValues_;
+ xControl = _xControl;
+ }
+ }
+
+ class ControlTask
+ {
+
+ Object oModel;
+ String propname;
+ Object propvalue;
+
+ public ControlTask(Object _oModel, String _propName, Object _propValue)
+ {
+ propname = _propName;
+ propvalue = _propValue;
+ oModel = _oModel;
+ }
+ }
+
+ class ImageUrlTask
+ {
+
+ Object oModel;
+ Object oResource;
+ Object oHCResource;
+
+ public ImageUrlTask(Object _oModel, Object _oResource, Object _oHCResource)
+ {
+ oResource = _oResource;
+ oHCResource = _oHCResource;
+ oModel = _oModel;
+ }
+ }
+
+ public void windowResized(WindowEvent arg0)
+ {
+ }
+
+ public void windowMoved(WindowEvent arg0)
+ {
+ }
+
+ public void windowShown(EventObject arg0)
+ {
+ try
+ {
+ for (int i = 0; i < this.m_aPeerTasks.size(); i++)
+ {
+ PeerTask aPeerTask = (PeerTask) m_aPeerTasks.elementAt(i);
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, aPeerTask.xControl.getPeer());
+ for (int n = 0; n < aPeerTask.propnames.length; n++)
+ {
+ xVclWindowPeer.setProperty(aPeerTask.propnames[n], aPeerTask.propvalues[n]);
+ }
+ }
+ for (int i = 0; i < this.aControlTasks.size(); i++)
+ {
+ ControlTask aControlTask = (ControlTask) aControlTasks.elementAt(i);
+ Helper.setUnoPropertyValue(aControlTask.oModel, aControlTask.propname, aControlTask.propvalue);
+ }
+ for (int i = 0; i < this.aImageUrlTasks.size(); i++)
+ {
+ ImageUrlTask aImageUrlTask = (ImageUrlTask) aImageUrlTasks.elementAt(i);
+ String sImageUrl = "";
+ if (AnyConverter.isInt(aImageUrlTask.oResource))
+ {
+ sImageUrl = oUnoDialog.getWizardImageUrl(((Integer) aImageUrlTask.oResource).intValue(), ((Integer) aImageUrlTask.oHCResource).intValue());
+ }
+ else if (AnyConverter.isString(aImageUrlTask.oResource))
+ {
+ sImageUrl = oUnoDialog.getImageUrl(((String) aImageUrlTask.oResource), ((String) aImageUrlTask.oHCResource));
+ }
+ if (!sImageUrl.equals(""))
+ {
+ Helper.setUnoPropertyValue(aImageUrlTask.oModel, "ImageURL", sImageUrl);
+ }
+ }
+
+ }
+ catch (RuntimeException re)
+ {
+ re.printStackTrace(System.out);
+ throw re;
+ }
+ }
+
+ public void windowHidden(EventObject arg0)
+ {
+ }
+
+ public void disposing(EventObject arg0)
+ {
+ }
+
+ /**
+ *
+ * @param oAPIControl an API control that the interface XControl can be derived from
+ * @param _saccessname
+ */
+ public void setAccessibleName(Object oAPIControl, String _saccessname)
+ {
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, oAPIControl);
+ setPeerProperties(xControl, new String[]
+ {
+ "AccessibleName"
+ }, new String[]
+ {
+ _saccessname
+ });
+ }
+
+ public void setAccessibleName(XControl _xControl, String _saccessname)
+ {
+ setPeerProperties(_xControl, new String[]
+ {
+ "AccessibleName"
+ }, new String[]
+ {
+ _saccessname
+ });
+ }
+
+ /**
+ *
+ * @param oAPIControl an API control that the interface XControl can be derived from
+ * @param _propnames
+ * @param _propvalues
+ */
+ public void setPeerProperties(Object oAPIControl, String[] _propnames, Object[] _propvalues)
+ {
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, oAPIControl);
+ setPeerProperties(xControl, _propnames, _propvalues);
+ }
+
+ public void setPeerProperties(XControl _xControl, String[] propnames, Object[] propvalues)
+ {
+ PeerTask oPeerTask = new PeerTask(_xControl, propnames, propvalues);
+ this.m_aPeerTasks.add(oPeerTask);
+ }
+
+ /**
+ * assigns an arbitrary property to a control as soon as the peer is created
+ * Note: The property 'ImageUrl' should better be assigned with 'setImageurl(...)', to consider the High Contrast Mode
+ * @param _ocontrolmodel
+ * @param _spropname
+ * @param _propvalue
+ */
+ public void setControlProperty(Object _ocontrolmodel, String _spropname, Object _propvalue)
+ {
+ ControlTask oControlTask = new ControlTask(_ocontrolmodel, _spropname, _propvalue);
+ this.aControlTasks.add(oControlTask);
+ }
+
+ /**
+ * Assigns an image to the property 'ImageUrl' of a dialog control. The image id must be assigned in a resource file
+ * within the wizards project
+ * wizards project
+ * @param _ocontrolmodel
+ * @param _nResId
+ * @param _nhcResId
+ */
+ public void setImageUrl(Object _ocontrolmodel, int _nResId, int _nhcResId)
+ {
+ ImageUrlTask oImageUrlTask = new ImageUrlTask(_ocontrolmodel, new Integer(_nResId), new Integer(_nhcResId));
+ this.aImageUrlTasks.add(oImageUrlTask);
+ }
+
+ /**
+ * Assigns an image to the property 'ImageUrl' of a dialog control. The image ids that the Resource urls point to
+ * may be assigned in a Resource file outside the wizards project
+ * @param _ocontrolmodel
+ * @param _sResourceUrl
+ * @param _sHCResourceUrl
+ */
+ public void setImageUrl(Object _ocontrolmodel, String _sResourceUrl, String _sHCResourceUrl)
+ {
+ ImageUrlTask oImageUrlTask = new ImageUrlTask(_ocontrolmodel, _sResourceUrl, _sHCResourceUrl);
+ this.aImageUrlTasks.add(oImageUrlTask);
+ }
+
+ /**
+ * Assigns an image to the property 'ImageUrl' of a dialog control. The image id must be assigned in a resource file
+ * within the wizards project
+ * wizards project
+ * @param _ocontrolmodel
+ * @param _oResource
+ * @param _oHCResource
+ */
+ public void setImageUrl(Object _ocontrolmodel, Object _oResource, Object _oHCResource)
+ {
+ ImageUrlTask oImageUrlTask = new ImageUrlTask(_ocontrolmodel, _oResource, _oHCResource);
+ this.aImageUrlTasks.add(oImageUrlTask);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/SortingComponent.java b/wizards/com/sun/star/wizards/ui/SortingComponent.java
new file mode 100644
index 000000000000..75194d21b199
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/SortingComponent.java
@@ -0,0 +1,384 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import java.beans.PropertyChangeEvent;
+
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.*;
+import com.sun.star.awt.*;
+
+public class SortingComponent
+{
+
+ com.sun.star.lang.XMultiServiceFactory xMSF;
+ WizardDialog CurUnoDialog;
+ int MaxSortIndex = -1;
+ public String[][] FieldNames;
+ static String sNoSorting;
+ static String sSortCriteriaisduplicate;
+ static String[] sSortHeader = new String[4];
+ static String[] sSortAscend = new String[4];
+ static String[] sSortDescend = new String[4];
+ static short[] bOldSortValues = new short[4];
+ public int MAXSORTCRITERIAINDEX = 3;
+ final int SOFIRSTSORTLST = 0;
+ final int SOSECSORTLST = 1;
+ final int SOTHIRDSORTLST = 2;
+ final int SOFOURTHSORTLST = 3;
+ final int[] SOSORTLST = new int[]
+ {
+ SOFIRSTSORTLST, SOSECSORTLST, SOTHIRDSORTLST, SOFOURTHSORTLST
+ };
+ XListBox[] xSortListBox = new XListBox[4];
+
+ class ItemListenerImpl implements com.sun.star.awt.XItemListener
+ {
+
+ public void itemStateChanged(ItemEvent EventObject)
+ {
+ Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", new Boolean(false));
+ int ikey = CurUnoDialog.getControlKey(EventObject.Source, CurUnoDialog.ControlList);
+ enableNextSortListBox(ikey);
+ Helper.setUnoPropertyValue(CurUnoDialog.xDialogModel, "Enabled", new Boolean(true));
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+ }
+
+ public SortingComponent(WizardDialog CurUnoDialog, int iStep, int iCompPosX, int iCompPosY, int iCompWidth, int FirstHelpIndex)
+ {
+ try
+ {
+ this.CurUnoDialog = CurUnoDialog;
+ short curtabindex = UnoDialog.setInitialTabindex(iStep);
+ xMSF = CurUnoDialog.xMSF;
+ Integer IStep = new Integer(iStep);
+ Integer ICompPosX = new Integer(iCompPosX);
+ Integer ICompPosY = new Integer(iCompPosY);
+ Integer ICompWidth = new Integer(iCompWidth);
+
+ Integer IListBoxPosX = new Integer(iCompPosX + 6);
+ int iOptButtonWidth = 65;
+ Integer IOptButtonWidth = new Integer(iOptButtonWidth);
+ Integer IListBoxWidth = new Integer(iCompWidth - iOptButtonWidth - 12);
+ Integer IOptButtonPosX = new Integer(IListBoxPosX.intValue() + IListBoxWidth.intValue() + 6);
+ getResources();
+ com.sun.star.awt.XWindow[] xListBoxWindow = new com.sun.star.awt.XWindow[4];
+ boolean bDoEnable;
+ String HIDString;
+ int iCurPosY = iCompPosY;
+ for (int i = 0; i < 4; i++)
+ {
+ bDoEnable = (i < 2);
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lblSort" + new Integer(i + 1).toString(), new String[]
+ {
+ "Enabled", "Height", "Label", "Orientation", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, new Object[]
+ {
+ new Boolean(bDoEnable), new Integer(8), sSortHeader[i], new Integer(0), ICompPosX, new Integer(iCurPosY), IStep, new Short(curtabindex++), ICompWidth
+ });
+
+ HIDString = HelpIds.getHelpIdString(FirstHelpIndex);
+ xSortListBox[i] = CurUnoDialog.insertListBox("lstSort" + new Integer(i + 1).toString(), SOSORTLST[i], null, new ItemListenerImpl(), new String[]
+ {
+ "Dropdown", "Enabled", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ }, new Object[]
+ {
+ new Boolean(true), new Boolean(bDoEnable), new Integer(12), HIDString, new Short(UnoDialog.getListBoxLineCount()), "lstSort" + new Integer(i + 1), IListBoxPosX, new Integer(iCurPosY + 14), IStep, new Short(curtabindex++), IListBoxWidth
+ }); //new Short((short) (17+i*4))
+
+ HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 1);
+ XRadioButton xRadioButtonAsc = CurUnoDialog.insertRadioButton("optAscend" + Integer.toString(i + 1), 0, new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Tag", "Width"
+ }, new Object[]
+ {
+ new Boolean(bDoEnable), new Integer(10), HIDString, sSortAscend[i], IOptButtonPosX, new Integer(iCurPosY + 10), new Short((short) 1), IStep, new Short(curtabindex++), new String("ASC"), IOptButtonWidth
+ }); //, new Short((short) (18+i*4))
+
+ HIDString = HelpIds.getHelpIdString(FirstHelpIndex + 2);
+ XRadioButton xRadioButtonDesc = CurUnoDialog.insertRadioButton("optDescend" + Integer.toString(i + 1), 0, new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "State", "Step", "TabIndex", "Tag", "Width"
+ }, new Object[]
+ {
+ new Boolean(bDoEnable), new Integer(10), HIDString, sSortDescend[i], IOptButtonPosX, new Integer(iCurPosY + 24), new Short((short) 0), IStep, new Short(curtabindex++), new String("DESC"), IOptButtonWidth
+ }); //, new Short((short) (19+i*4))
+ iCurPosY = iCurPosY + 36;
+ FirstHelpIndex += 3;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ private boolean getResources()
+ {
+ sSortHeader[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 20);
+ sSortHeader[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 21);
+ sSortHeader[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 51);
+ sSortHeader[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 52);
+ sSortAscend[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 36);
+ sSortAscend[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 53);
+ sSortAscend[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 54);
+ sSortAscend[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 55);
+ sSortDescend[0] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 37);
+ sSortDescend[1] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 56);
+ sSortDescend[2] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 57);
+ sSortDescend[3] = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 58);
+ sSortCriteriaisduplicate = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 74);
+ sNoSorting = CurUnoDialog.m_oResource.getResText(UIConsts.RID_REPORT + 8);
+ return true;
+ }
+
+ public void initialize(String[] _FieldNames, String[][] _SortFieldNames)
+ {
+ int FieldCount = _FieldNames.length;
+ String[] ViewFieldNames = new String[FieldCount + 1];
+ ViewFieldNames[0] = sNoSorting;
+ for (int i = 0; i < FieldCount; i++)
+ {
+ ViewFieldNames[i + 1] = _FieldNames[i];
+ }
+ short[] SelList = null;
+ for (int i = 0; i < 4; i++)
+ {
+ if (i < _SortFieldNames.length)
+ {
+ SelList = new short[]
+ {
+ (short) (JavaTools.FieldInList(_FieldNames, _SortFieldNames[i][0]) + 1)
+ };
+ }
+ else
+ {
+ SelList = new short[]
+ {
+ (short) 0
+ };
+ }
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 1).toString(), "StringItemList", ViewFieldNames);
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 1).toString(), "SelectedItems", SelList);
+ toggleSortListBox(i, (i <= _SortFieldNames.length));
+ }
+ }
+
+ private void setMaxSortIndex()
+ {
+ MaxSortIndex = -1;
+ for (int i = 0; i <= MAXSORTCRITERIAINDEX; i++)
+ {
+ if (xSortListBox[i].getSelectedItemPos() > 0)
+ {
+ MaxSortIndex += 1;
+ }
+ }
+ }
+
+ /**
+ * sets the controls of a Sorting criterion to readonly or not.
+ * @param _index index of the Sorting criterion
+ * @param _breadonly
+ */
+ public void setReadOnly(int _index, boolean _breadonly)
+ {
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(_index + 1).toString(), "ReadOnly", new Boolean(_breadonly));
+ }
+
+ /**
+ *
+ * @param _index the first Sorting criterion in which 'ReadOnly is set to 'false'
+ * @param _bcomplete
+ */
+ public void setReadOnlyUntil(int _index, boolean _bcomplete)
+ {
+ for (int i = 0; i <= 4; i++)
+ {
+ boolean breadonly = i < _index;
+ setReadOnly(i, breadonly);
+ }
+ }
+
+ private void enableNextSortListBox(int CurIndex)
+ {
+ try
+ {
+ setMaxSortIndex();
+ boolean bDoEnable = (xSortListBox[CurIndex].getSelectedItemPos() != 0);
+ if (!bDoEnable)
+ {
+ moveupSortItems(CurIndex, bDoEnable); //disableListBoxesfromIndex(CurIndex);
+ }
+ else
+ {
+ toggleSortListBox(CurIndex + 1, true);
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public String[][] getSortFieldNames()
+ {
+ try
+ {
+ short iCurState;
+ String CurFieldName;
+ String CurFieldTitle;
+ setMaxSortIndex();
+ String[][] SortFieldNames = new String[MaxSortIndex + 1][2];
+ String[] SortDescriptions = new String[MaxSortIndex + 1];
+ for (int i = 0; i <= MaxSortIndex; i++)
+ {
+ CurFieldName = xSortListBox[i].getSelectedItem();
+ SortFieldNames[i][0] = CurFieldName;
+ SortDescriptions[i] = CurFieldName;
+ iCurState = ((Short) CurUnoDialog.getControlProperty("optAscend" + new Integer(i + 1).toString(), "State")).shortValue();
+ SortFieldNames[i][0] = CurFieldName;
+ if (iCurState == 1)
+ {
+ SortFieldNames[i][1] = "ASC";
+ }
+ else
+ {
+ SortFieldNames[i][1] = "DESC";
+ }
+ }
+ // When searching for a duplicate entry we can neglect wether the entries are to be sorted ascending or descending
+ // TODO for the future we should deliver a messagebox when two different sorting modes have been applied to one field
+ int iduplicate = JavaTools.getDuplicateFieldIndex(SortDescriptions);
+ if (iduplicate != -1)
+ {
+ String sLocSortCriteriaisduplicate = JavaTools.replaceSubString(sSortCriteriaisduplicate, SortFieldNames[iduplicate][0], "<FIELDNAME>");
+ CurUnoDialog.showMessageBox("WarningBox", VclWindowPeerAttribute.OK, sLocSortCriteriaisduplicate);
+ CurUnoDialog.vetoableChange(new PropertyChangeEvent(CurUnoDialog, "Steps", new Integer(1), new Integer(2)));
+ CurUnoDialog.setFocus("lstSort" + (iduplicate + 1));
+ return new String[][]
+ {
+ };
+ }
+ else
+ {
+ return SortFieldNames;
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void disableListBoxesfromIndex(int CurIndex)
+ {
+ if (CurIndex < MAXSORTCRITERIAINDEX)
+ {
+ for (int i = CurIndex + 1; i <= MAXSORTCRITERIAINDEX; i++)
+ {
+ toggleSortListBox(i, (false));
+ if (i < MaxSortIndex)
+ {
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 2).toString(), "SelectedItems", new short[]
+ {
+ 0
+ });
+ }
+ // xSortListBox[i+1].selectItemPos((short)0, true);
+ }
+ CurUnoDialog.setFocus("lblSort" + new Integer(CurIndex + 1));
+ MaxSortIndex = CurIndex - 1;
+ }
+ }
+
+ // The following code can be reactivated in a future version when task #100799 will be fixed
+ private void moveupSortItems(int CurIndex, boolean bDoEnable)
+ {
+ short iNextItemPos;
+ if ((bDoEnable == false) && (MAXSORTCRITERIAINDEX > CurIndex))
+ {
+ for (int i = CurIndex; i < MAXSORTCRITERIAINDEX; i++)
+ {
+ iNextItemPos = xSortListBox[i + 1].getSelectedItemPos();
+ if (iNextItemPos != 0)
+ {
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 1).toString(), "SelectedItems", new short[]
+ {
+ iNextItemPos
+ });
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 2).toString(), "SelectedItems", new short[]
+ {
+ });
+ toggleSortListBox(i, true);
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(i + 2).toString(), "SelectedItems", new short[]
+ {
+ 0
+ });
+ }
+ }
+ if (MaxSortIndex < xSortListBox.length - 2)
+ {
+ toggleSortListBox(MaxSortIndex + 2, false);
+ }
+ }
+ else
+ {
+ toggleSortListBox(CurIndex + 1, bDoEnable);
+ }
+ }
+
+ private void toggleSortListBox(int CurIndex, boolean bDoEnable)
+ {
+ try
+ {
+ if (CurIndex < xSortListBox.length)
+ {
+ CurUnoDialog.setControlProperty("lblSort" + new Integer(CurIndex + 1).toString(), "Enabled", new Boolean(bDoEnable));
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(CurIndex + 1).toString(), "Enabled", new Boolean(bDoEnable));
+ CurUnoDialog.setControlProperty("optAscend" + new Integer(CurIndex + 1).toString(), "Enabled", new Boolean(bDoEnable));
+ CurUnoDialog.setControlProperty("optDescend" + new Integer(CurIndex + 1).toString(), "Enabled", new Boolean(bDoEnable));
+ if (bDoEnable == false)
+ {
+ CurUnoDialog.setControlProperty("lstSort" + new Integer(CurIndex + 1).toString(), "SelectedItems", new short[]
+ {
+ 0
+ });
+ }
+ }
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/TitlesComponent.java b/wizards/com/sun/star/wizards/ui/TitlesComponent.java
new file mode 100644
index 000000000000..892a59c669f8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/TitlesComponent.java
@@ -0,0 +1,249 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.*;
+import com.sun.star.beans.*;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.awt.XTextListener;
+
+import java.util.*;
+
+public class TitlesComponent extends ControlScroller
+{
+
+ int iLabelPosX;
+ final int iRelLabelPosXDist = 6;
+ public String[] fieldnames;
+ public Map fieldtitleset;
+ public String[] fieldtitles;
+ public XTextListener xTextListener;
+ final String SOLABELPREFIX = "lblColumnName_";
+ final String SOTITLEPREFIX = "lblTitleName_";
+
+ public TitlesComponent(WizardDialog _CurUnoDialog, int _iStep, int _iCompPosX, int _iCompPosY, int _iCompWidth, int _uitextfieldcount, String _slblColumnNames, String _slblColumnTitles, int _firsthelpindex)
+ {
+ super(_CurUnoDialog, null, _iStep, _iCompPosX, _iCompPosY, _iCompWidth, _uitextfieldcount, 18, _firsthelpindex);
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblColumnNames", new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ }, new Object[]
+ {
+ new Integer(8), _slblColumnNames, new Integer(iLabelPosX), new Integer(iCompPosY - 10), IStep, new Integer(60)
+ });
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", "lblColumnTitles", new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "Step", "Width"
+ }, new Object[]
+ {
+ new Integer(8), _slblColumnTitles, new Integer(90), new Integer(iCompPosY - 10), IStep, new Integer(152)
+ });
+ }
+
+ protected void insertControlGroup(int i, int ypos)
+ {
+ iLabelPosX = iCompPosX + iRelLabelPosXDist;
+ ControlRow oControlRow = new ControlRow(i, ypos);
+ ControlGroupVector.addElement(oControlRow);
+
+ }
+
+ protected void setControlGroupVisible(int _index, boolean _bIsVisible)
+ {
+ CurUnoDialog.setControlVisible(getColumnName(_index), _bIsVisible);
+ CurUnoDialog.setControlVisible(getTitleName(_index), _bIsVisible);
+ }
+
+ public void addTextListener(XTextListener _xTextListener)
+ {
+ for (int i = 0; i < super.ControlGroupVector.size(); i++)
+ {
+ ControlRow curControlRow = (ControlRow) ControlGroupVector.elementAt(i);
+ XTextComponent xTextBox = curControlRow.xTextComponent;
+ if ((xTextBox != null) && (_xTextListener != null))
+ {
+ xTextBox.addTextListener(_xTextListener);
+ }
+ }
+ }
+
+ class ControlRow
+ {
+
+ PropertyValue[] regproperties;
+ XTextComponent xTextComponent;
+
+ public ControlRow(int _index, int _iCompPosY)
+ {
+ String slabelname = getColumnName(_index);
+ String stextfieldname = getTitleName(_index);
+
+ CurUnoDialog.insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", slabelname,
+ new String[]
+ {
+ "Height", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(16), new Boolean(true), new Integer(iLabelPosX), new Integer(_iCompPosY + 1), UIConsts.INVISIBLESTEP, new Short(curtabindex++), new Integer(30)
+ });
+
+ xTextComponent = CurUnoDialog.insertTextField(stextfieldname, 0, null,
+ new String[]
+ {
+ "Height", "HelpURL", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(12), HelpIds.getHelpIdString(curHelpIndex++), new Integer(iLabelPosX + 30), new Integer(_iCompPosY), UIConsts.INVISIBLESTEP, new Short(curtabindex++), new Integer(iCompWidth - 90 - 20)
+ });
+ }
+ }
+
+ private String getColumnName(int _index)
+ {
+ return SOLABELPREFIX + Integer.toString(_index + 1);
+ }
+
+ private String getTitleName(int _index)
+ {
+ return SOTITLEPREFIX + Integer.toString(_index + 1);
+ }
+
+ protected void initializeScrollFields()
+ {
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ PropertyValue[] currowproperties = new PropertyValue[2];
+ currowproperties[0] = Properties.createProperty(getColumnName(i), fieldnames[i], i);
+ currowproperties[1] = Properties.createProperty(getTitleName(i), fieldtitles[i], i); //getTitleName(i)
+ registerControlGroup(currowproperties, i);
+ }
+ }
+
+ private void adjustPosSizes()
+ {
+ String sLongestFieldName = JavaTools.getlongestArrayItem(fieldnames);
+ Size aSize = CurUnoDialog.getpreferredLabelSize(getColumnName(0), sLongestFieldName);
+ double dblMAPConversion = CurUnoDialog.getMAPConversionFactor(getColumnName(0));
+ int iFieldNameWidth = getFieldNameWidth(aSize.Width, dblMAPConversion) + 10;
+ Integer FieldNameWidth = new Integer(iFieldNameWidth);
+ Integer TitlePosX = new Integer(iLabelPosX + iFieldNameWidth + 2);
+ Integer TitleWidth = new Integer(iCompPosX + iCompWidth - TitlePosX.intValue() - iScrollBarWidth - 6);
+ for (short i = 0; i <= ncurfieldcount; i++)
+ {
+ CurUnoDialog.setControlProperty(getColumnName(i), "Width", FieldNameWidth);
+ CurUnoDialog.setControlProperties(getTitleName(i), new String[]
+ {
+ "PositionX", "Width"
+ }, new Object[]
+ {
+ TitlePosX, TitleWidth
+ });
+ }
+ CurUnoDialog.setControlProperty("lblColumnNames", "Width", FieldNameWidth);
+ CurUnoDialog.setControlProperty("lblColumnTitles", "PositionX", TitlePosX);
+ }
+
+ public void initialize(String[] _fieldnames, Map _fieldtitleset)
+ {
+ this.fieldnames = _fieldnames;
+ this.fieldtitleset = _fieldtitleset;
+ setFieldTitles();
+ initializeScrollFields();
+ super.initialize(fieldnames.length);
+ adjustPosSizes();
+// setComponentMouseTransparent();
+ }
+
+ private void setFieldTitles()
+ {
+ fieldtitles = new String[fieldnames.length];
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ if (this.fieldtitleset.containsKey(fieldnames[i]))
+ {
+ Object curvalue = fieldtitleset.get(fieldnames[i]);
+ if (curvalue != null)
+ {
+ fieldtitles[i] = (String) curvalue;
+ }
+ else
+ {
+ fieldtitles[i] = fieldnames[i];
+ }
+ }
+ else
+ {
+ fieldtitles[i] = fieldnames[i];
+ }
+ }
+ }
+
+ public String getFieldNameByTitleControl(Object _fieldtitlemodel)
+ {
+ String sTitleModelName = (String) Helper.getUnoPropertyValue(_fieldtitlemodel, "Name");
+ String sindex = JavaTools.getSuffixNumber(sTitleModelName);
+ return (String) CurUnoDialog.getControlProperty(this.SOLABELPREFIX + sindex, "Label");
+ }
+
+ public String[] getFieldTitles()
+ {
+ PropertyValue[][] titlelist = this.getScrollFieldValues();
+ PropertyValue[] currowproperties;
+ PropertyValue curtitleproperty;
+ for (int i = 0; i < titlelist.length; i++)
+ {
+ currowproperties = titlelist[i];
+ curtitleproperty = currowproperties[1];
+ fieldtitles[i] = (String) curtitleproperty.Value;
+ }
+ refreshtitleset();
+ return fieldtitles;
+ }
+
+ private void refreshtitleset()
+ {
+ for (int i = 0; i < fieldnames.length; i++)
+ {
+ fieldtitleset.put(fieldnames[i], fieldtitles[i]);
+ }
+ }
+
+ private int getFieldNameWidth(int iMAPControlWidth, double dblMAPConversion)
+ {
+ int iFieldNameWidth = (int) (1.15 * ((double) (iMAPControlWidth)) / dblMAPConversion);
+ double dblAvailableWidth = (double) (iCompWidth - iScrollBarWidth - iRelLabelPosXDist);
+ if (iFieldNameWidth > (0.5 * (dblAvailableWidth)))
+ {
+ iFieldNameWidth = (int) (0.5 * (dblAvailableWidth));
+ }
+ return iFieldNameWidth;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/UIConsts.java b/wizards/com/sun/star/wizards/ui/UIConsts.java
new file mode 100644
index 000000000000..bac864ecd09c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/UIConsts.java
@@ -0,0 +1,83 @@
+/*
+ * Created on 14.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.ui;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface UIConsts
+{
+
+ public static final int RID_COMMON = 500;
+ public static final int RID_DB_COMMON = 1000;
+ public static final int RID_FORM = 2200;
+ public static final int RID_QUERY = 2300;
+ public static final int RID_REPORT = 2400;
+ public static final int RID_TABLE = 2500;
+ public static final int RID_IMG_REPORT = 1000;
+ public static final int RID_IMG_FORM = 1100;
+ public static final int RID_IMG_WEB = 1200;
+ public static final Integer INVISIBLESTEP = new Integer(99);
+ public static final String INFOIMAGEURL = "private:resource/dbu/image/19205";
+ public static final String INFOIMAGEURL_HC = "private:resource/dbu/image/19230";
+ /**
+ * The tabindex of the navigation buttons in a wizard must be assigned a very
+ * high tabindex because on every step their taborder must appear at the end
+ */
+ public static final short SOFIRSTWIZARDNAVITABINDEX = 30000;
+ public static final Integer INTEGER_8 = new Integer(8);
+ public static final Integer INTEGER_12 = new Integer(12);
+ public static final Integer INTEGER_14 = new Integer(14);
+ public static final Integer INTEGER_16 = new Integer(16);
+ public static final Integer INTEGER_40 = new Integer(40);
+ public static final Integer INTEGER_50 = new Integer(50);
+ /**Steps of the QueryWizard
+ *
+ */
+ public static final int SOFIELDSELECTIONPAGE = 1;
+ public static final int SOSORTINGPAGE = 2;
+ public static final int SOFILTERPAGE = 3;
+ public static final int SOAGGREGATEPAGE = 4;
+ public static final int SOGROUPSELECTIONPAGE = 5;
+ public static final int SOGROUPFILTERPAGE = 6;
+ public static final int SOTITLESPAGE = 7;
+ public static final int SOSUMMARYPAGE = 8;
+ public static final Integer[] INTEGERS = new Integer[]
+ {
+ new Integer(0), new Integer(1), new Integer(2), new Integer(3), new Integer(4), new Integer(5), new Integer(6), new Integer(7), new Integer(8), new Integer(9), new Integer(10)
+ };
+
+ class CONTROLTYPE
+ {
+
+ public static final int BUTTON = 1;
+ public static final int IMAGECONTROL = 2;
+ public static final int LISTBOX = 3;
+ public static final int COMBOBOX = 4;
+ public static final int CHECKBOX = 5;
+ public static final int RADIOBUTTON = 6;
+ public static final int DATEFIELD = 7;
+ public static final int EDITCONTROL = 8;
+ public static final int FILECONTROL = 9;
+ public static final int FIXEDLINE = 10;
+ public static final int FIXEDTEXT = 11;
+ public static final int FORMATTEDFIELD = 12;
+ public static final int GROUPBOX = 13;
+ public static final int HYPERTEXT = 14;
+ public static final int NUMERICFIELD = 15;
+ public static final int PATTERNFIELD = 16;
+ public static final int PROGRESSBAR = 17;
+ public static final int ROADMAP = 18;
+ public static final int SCROLLBAR = 19;
+ public static final int TIMEFIELD = 20;
+ public static final int CURRENCYFIELD = 21;
+ public static final int UNKNOWN = -1;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog.java b/wizards/com/sun/star/wizards/ui/UnoDialog.java
new file mode 100644
index 000000000000..5a181b84c4b5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog.java
@@ -0,0 +1,1148 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.*;
+import com.sun.star.awt.XReschedule;
+import com.sun.star.beans.Property;
+import com.sun.star.beans.XMultiPropertySet;
+
+import com.sun.star.beans.XPropertySet;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.container.XNameContainer;
+import com.sun.star.lang.*;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.*;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.ui.event.*;
+
+import java.util.Hashtable;
+
+public class UnoDialog implements EventNames
+{
+
+ public XMultiServiceFactory xMSF;
+ public XMultiServiceFactory MSFDialogModel;
+ public XNameContainer xDlgNames;
+ public XControlContainer xDlgContainer;
+ private XNameAccess m_xDlgNameAccess;
+ public XControl xControl;
+ public XDialog xDialog;
+ public XReschedule xReschedule;
+ public XWindow xWindow;
+ public XComponent xComponent;
+ public XInterface xDialogModel;
+ public XInterface xUnoDialog;
+ public XPropertySet xPSetDlg;
+ public XVclWindowPeer xVclWindowPeer;
+ public Hashtable ControlList;
+ public Resource m_oResource;
+ public XWindowPeer xWindowPeer = null;
+ private PeerConfig m_oPeerConfig;
+ protected AbstractListener guiEventListener;
+
+ public AbstractListener getGuiEventListener()
+ {
+ return guiEventListener;
+ }
+
+ public UnoDialog(XMultiServiceFactory xMSF, String[] PropertyNames, Object[] PropertyValues)
+ {
+ try
+ {
+ this.xMSF = xMSF;
+ ControlList = new Hashtable();
+ xDialogModel = (XInterface) xMSF.createInstance("com.sun.star.awt.UnoControlDialogModel");
+ XMultiPropertySet xMultiPSetDlg = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, xDialogModel);
+ xMultiPSetDlg.setPropertyValues(PropertyNames, PropertyValues);
+ MSFDialogModel = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, xDialogModel);
+ xUnoDialog = (XInterface) xMSF.createInstance("com.sun.star.awt.UnoControlDialog");
+ xControl = (XControl) UnoRuntime.queryInterface(XControl.class, xUnoDialog);
+ XControlModel xControlModel = (XControlModel) UnoRuntime.queryInterface(XControlModel.class, xDialogModel);
+ xControl.setModel(xControlModel);
+ xPSetDlg = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xDialogModel);
+ xDlgContainer = (XControlContainer) UnoRuntime.queryInterface(XControlContainer.class, xUnoDialog);
+ xDlgNames = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xDialogModel);
+ // xDlgNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDialogModel);
+ xComponent = (XComponent) UnoRuntime.queryInterface(XComponent.class, xUnoDialog);
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, xUnoDialog);
+
+ // setPeerConfiguration(); // LLA: will be done, if really used!
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public int getControlKey(Object EventObject, Hashtable ControlList)
+ {
+ int iKey;
+ XControl xContrl = (XControl) UnoRuntime.queryInterface(XControl.class, EventObject);
+ XControlModel xControlModel = xContrl.getModel();
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ try
+ {
+ String sName = (String) xPSet.getPropertyValue("Name");
+ Integer KeyObject = (Integer) ControlList.get(sName);
+ iKey = KeyObject.intValue();
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ iKey = 2000;
+ }
+ return iKey;
+ }
+
+ public void createPeerConfiguration()
+ {
+ m_oPeerConfig = new PeerConfig(this);
+ }
+
+ public PeerConfig getPeerConfiguration()
+ {
+ if (m_oPeerConfig == null)
+ {
+ createPeerConfiguration();
+ }
+ return m_oPeerConfig;
+ }
+
+ XNameAccess getDlgNameAccess()
+ {
+ if (m_xDlgNameAccess == null)
+ {
+ m_xDlgNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, xDialogModel);
+ }
+ return m_xDlgNameAccess;
+ }
+ public void setControlProperty(String ControlName, String PropertyName, Object PropertyValue)
+ {
+ try
+ {
+ if (PropertyValue != null)
+ {
+ if (getDlgNameAccess().hasByName(ControlName) == false)
+ {
+ return;
+ }
+ Object xControlModel = getDlgNameAccess().getByName(ControlName);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ if (AnyConverter.isArray(PropertyValue))
+ {
+ com.sun.star.uno.Type seqType = new com.sun.star.uno.Type(PropertyValue.getClass());
+ PropertyValue = new com.sun.star.uno.Any(seqType, PropertyValue);
+ /* PropertyValue = Helper.getArrayValue(PropertyValue);
+ if (PropertyValue == null)
+ PropertyValue = new short[]{};
+ */
+ }
+ xPSet.setPropertyValue(PropertyName, PropertyValue);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public Resource getResource()
+ {
+ return m_oResource;
+ }
+
+ public void setControlProperties(String ControlName, String[] PropertyNames, Object[] PropertyValues)
+ {
+ try
+ {
+ if (PropertyValues != null)
+ {
+ if (getDlgNameAccess().hasByName(ControlName) == false)
+ {
+ return;
+ }
+ Object xControlModel = getDlgNameAccess().getByName(ControlName);
+ XMultiPropertySet xMultiPSet = (XMultiPropertySet) UnoRuntime.queryInterface(XMultiPropertySet.class, xControlModel);
+ xMultiPSet.setPropertyValues(PropertyNames, PropertyValues);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public Object getControlProperty(String ControlName, String PropertyName)
+ {
+ try
+ {
+ Object xControlModel = getDlgNameAccess().getByName(ControlName);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ Object oPropValue = xPSet.getPropertyValue(PropertyName);
+ // if (AnyConverter.isArray(oPropValue))
+ // return Helper.getArrayValue(oPropValue);
+ // else
+ return oPropValue;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ { // com.sun.star.container.NoSuchElementException, com.sun.star.beans.UnknownPropertyException,
+ exception.printStackTrace(System.out); // com.sun.star.lang.WrappedTargetException, com.sun.star.beans.PropertyVetoException
+ return null; // com.sun.star.lang.IllegalArgumentException
+ }
+ }
+
+ public void printControlProperties(String ControlName)
+ {
+ try
+ {
+ Object xControlModel = getDlgNameAccess().getByName(ControlName);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xControlModel);
+ Property[] allProps = xPSet.getPropertySetInfo().getProperties();
+ for (int i = 0; i < allProps.length; i++)
+ {
+ String sName = allProps[i].Name;
+ System.out.println(sName);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ { // com.sun.star.container.NoSuchElementException, com.sun.star.beans.UnknownPropertyException,
+ exception.printStackTrace(System.out); // com.sun.star.lang.WrappedTargetException, com.sun.star.beans.PropertyVetoException
+ }
+ }
+
+ public double getMAPConversionFactor(String ControlName)
+ {
+ XControl xControl2 = xDlgContainer.getControl(ControlName);
+ XView xView = (XView) UnoRuntime.queryInterface(XView.class, xControl2);
+ Size aSize = xView.getSize();
+ double dblMAPWidth = (double) (((Integer) Helper.getUnoPropertyValue(xControl2.getModel(), "Width")).intValue());
+ double dblFactor = (((double) (aSize.Width)) / dblMAPWidth);
+ return dblFactor;
+ }
+
+ public Size getpreferredLabelSize(String LabelName, String sLabel)
+ {
+ XControl xControl2 = xDlgContainer.getControl(LabelName);
+ XFixedText xFixedText = (XFixedText) UnoRuntime.queryInterface(XFixedText.class, xControl2);
+ String OldText = xFixedText.getText();
+ xFixedText.setText(sLabel);
+ XLayoutConstrains xLayoutConstrains = (XLayoutConstrains) UnoRuntime.queryInterface(XLayoutConstrains.class, xControl2);
+ Size aSize = xLayoutConstrains.getPreferredSize();
+ xFixedText.setText(OldText);
+ return aSize;
+ }
+
+ public void removeSelectedItems(XListBox xListBox)
+ {
+ short[] SelList = xListBox.getSelectedItemsPos();
+ int Sellen = SelList.length;
+ for (int i = Sellen - 1; i >= 0; i--)
+ {
+ xListBox.removeItems(SelList[i], (short) 1);
+ }
+ }
+
+ public static int getListBoxItemCount(XListBox _xListBox)
+ {
+ // This function may look ugly, but this is the only way to check the count
+ // of values in the model,which is always right.
+ // the control is only a view and could be right or not.
+ final String[] fieldnames = (String[]) Helper.getUnoPropertyValue(getModel(_xListBox), "StringItemList");
+ return fieldnames.length;
+ }
+
+ public static short getSelectedItemPos(XListBox _xListBox)
+ {
+ short ipos[] = (short[]) Helper.getUnoPropertyValue(getModel(_xListBox), "SelectedItems");
+ return ipos[0];
+ }
+
+ public static boolean isListBoxSelected(XListBox _xListBox)
+ {
+ short ipos[] = (short[]) Helper.getUnoPropertyValue(getModel(_xListBox), "SelectedItems");
+ return ipos.length > 0;
+ }
+
+ public void addSingleItemtoListbox(XListBox xListBox, String ListItem, short iSelIndex)
+ {
+ xListBox.addItem(ListItem, xListBox.getItemCount());
+ if (iSelIndex != -1)
+ {
+ xListBox.selectItemPos(iSelIndex, true);
+ }
+ }
+
+ public XFixedText insertLabel(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ try
+ {
+ Object oFixedText = insertControlModel("com.sun.star.awt.UnoControlFixedTextModel", sName, sPropNames, oPropValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oFixedText);
+ xPSet.setPropertyValue("Name", sName);
+ Object oLabel = xDlgContainer.getControl(new String(sName));
+ return (XFixedText) UnoRuntime.queryInterface(XFixedText.class, oLabel);
+ }
+ catch (java.lang.Exception ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ /* public XButton insertButton(String sName, int iControlKey, XActionListener xActionListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception{
+ Object oButtonModel = insertControlModel("com.sun.star.awt.UnoControlButtonModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oButtonModel);
+ xPSet.setPropertyValue("Name", sName);
+ Object objectButton = xDlgContainer.getControl( new String(sName));
+ XButton xButton = ( XButton ) UnoRuntime.queryInterface( XButton.class, objectButton );
+ xButton.addActionListener(xActionListener);
+ Integer ControlKey = new Integer(iControlKey);
+ if (ControlList != null)
+ ControlList.put(sName, ControlKey);
+ return xButton;
+ } */
+ public XButton insertButton(String sName, int iControlKey, XActionListener xActionListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ Object oButtonModel = insertControlModel("com.sun.star.awt.UnoControlButtonModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oButtonModel);
+ xPSet.setPropertyValue("Name", sName);
+ Object objectButton = xDlgContainer.getControl(new String(sName));
+ XButton xButton = (XButton) UnoRuntime.queryInterface(XButton.class, objectButton);
+ if (xActionListener != null)
+ {
+ xButton.addActionListener(xActionListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ if (ControlList != null)
+ {
+ ControlList.put(sName, ControlKey);
+ }
+ return xButton;
+ }
+
+ public void insertCheckBox(String sName, int iControlKey, XItemListener xItemListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ Object oButtonModel = insertControlModel("com.sun.star.awt.UnoControlCheckBoxModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oButtonModel);
+ xPSet.setPropertyValue("Name", sName);
+ Object objectCheckBox = xDlgContainer.getControl(new String(sName));
+ XCheckBox xCheckBox = (XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, objectCheckBox);
+ if (xItemListener != null)
+ {
+ xCheckBox.addItemListener(xItemListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ if (ControlList != null)
+ {
+ ControlList.put(sName, ControlKey);
+ }
+ }
+
+ public void insertNumericField(String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ Object oNumericFieldModel = insertControlModel("com.sun.star.awt.UnoControlNumericFieldModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oNumericFieldModel);
+ xPSet.setPropertyValue("Name", sName);
+ Object objectNumericField = xDlgContainer.getControl(new String(sName));
+ XTextComponent xNumericField = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, objectNumericField);
+ if (xTextListener != null)
+ {
+ xNumericField.addTextListener(xTextListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ if (ControlList != null)
+ {
+ ControlList.put(sName, ControlKey);
+ }
+ }
+
+ public XScrollBar insertScrollBar(String sName, int iControlKey, XAdjustmentListener xAdjustmentListener, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ Object oScrollModel = insertControlModel("com.sun.star.awt.UnoControlScrollBarModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oScrollModel);
+ xPSet.setPropertyValue("Name", sName);
+ Object oScrollBar = xDlgContainer.getControl(new String(sName));
+ XScrollBar xScrollBar = (XScrollBar) UnoRuntime.queryInterface(XScrollBar.class, oScrollBar);
+ if (xAdjustmentListener != null)
+ {
+ xScrollBar.addAdjustmentListener(xAdjustmentListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ if (ControlList != null)
+ {
+ ControlList.put(sName, ControlKey);
+ }
+ return xScrollBar;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public XTextComponent insertTextField(String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues)
+ {
+ XTextComponent xTextBox = insertEditField("com.sun.star.awt.UnoControlEditModel", sName, iControlKey, xTextListener, sProperties, sValues);
+ return xTextBox;
+ }
+
+ public XTextComponent insertFormattedField(String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues)
+ {
+ XTextComponent xTextBox = insertEditField("com.sun.star.awt.UnoControlFormattedFieldModel", sName, iControlKey, xTextListener, sProperties, sValues);
+ return xTextBox;
+ }
+
+ public XTextComponent insertEditField(String ServiceName, String sName, int iControlKey, XTextListener xTextListener, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ XInterface xTextModel = insertControlModel(ServiceName, sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xTextModel);
+ xPSet.setPropertyValue("Name", sName);
+ XControl xTextField = xDlgContainer.getControl(new String(sName));
+ XTextComponent xTextBox = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xTextField);
+ if (xTextListener != null)
+ {
+ xTextBox.addTextListener(xTextListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ ControlList.put(sName, ControlKey);
+ return xTextBox;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public XListBox insertListBox(String sName, int iControlKey, XActionListener xActionListener, XItemListener xItemListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ XInterface xListBoxModel = insertControlModel("com.sun.star.awt.UnoControlListBoxModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xListBoxModel);
+ xPSet.setPropertyValue("Name", sName);
+ XControl xControlListBox = xDlgContainer.getControl(new String(sName));
+ XListBox xListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, xControlListBox);
+ if (xItemListener != null)
+ {
+ xListBox.addItemListener(xItemListener);
+ }
+ if (xActionListener != null)
+ {
+ xListBox.addActionListener(xActionListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ ControlList.put(sName, ControlKey);
+ return xListBox;
+ }
+
+ public XComboBox insertComboBox(String sName, int iControlKey, XActionListener xActionListener, XTextListener xTextListener, XItemListener xItemListener, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ XInterface xComboBoxModel = insertControlModel("com.sun.star.awt.UnoControlComboBoxModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xComboBoxModel);
+ xPSet.setPropertyValue("Name", sName);
+ XControl xControlComboBox = xDlgContainer.getControl(new String(sName));
+ XComboBox xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, xControlComboBox);
+ if (xItemListener != null)
+ {
+ xComboBox.addItemListener(xItemListener);
+ }
+ if (xTextListener != null)
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xComboBox);
+ xTextComponent.addTextListener(xTextListener);
+ }
+ if (xActionListener != null)
+ {
+ xComboBox.addActionListener(xActionListener);
+ }
+ Integer ControlKey = new Integer(iControlKey);
+ ControlList.put(sName, ControlKey);
+ return xComboBox;
+ }
+
+ public XRadioButton insertRadioButton(String sName, int iControlKey, XItemListener xItemListener, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ XRadioButton xRadioButton = insertRadioButton(sName, iControlKey, sProperties, sValues);
+ if (xItemListener != null)
+ {
+ xRadioButton.addItemListener(xItemListener);
+ }
+ return xRadioButton;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public XButton insertRadioButton(String sName, int iControlKey, XActionListener xActionListener, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ XRadioButton xRadioButton = insertRadioButton(sName, iControlKey, sProperties, sValues);
+ XButton xButton = (com.sun.star.awt.XButton) UnoRuntime.queryInterface(XButton.class, xRadioButton);
+ if (xActionListener != null)
+ {
+ xButton.addActionListener(xActionListener);
+ }
+ return xButton;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public XRadioButton insertRadioButton(String sName, int iControlKey, String[] sProperties, Object[] sValues) throws com.sun.star.uno.Exception
+ {
+ XRadioButton xRadioButton = insertRadioButton(sName, sProperties, sValues);
+ Integer ControlKey = new Integer(iControlKey);
+ ControlList.put(sName, ControlKey);
+ return xRadioButton;
+ }
+
+ public XRadioButton insertRadioButton(String sName, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ XInterface oRadioButtonModel = insertControlModel("com.sun.star.awt.UnoControlRadioButtonModel", sName, sProperties, sValues);
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRadioButtonModel);
+ xPSet.setPropertyValue("Name", sName);
+ XControl xControlRadioButton = xDlgContainer.getControl(new String(sName));
+ XRadioButton xRadioButton = (XRadioButton) UnoRuntime.queryInterface(XRadioButton.class, xControlRadioButton);
+ return xRadioButton;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ /**
+ * @author bc93774
+ * The problem with setting the visibility of controls is that changing the current step
+ * of a dialog will automatically make all controls visible. The "Step" property always wins against
+ * the property "visible". Therfor a control meant to be invisible is placed on a step far far away.
+ * @param the name of the control
+ * @param iStep change the step if you want to make the control invisible
+ */
+ private void setControlVisible(String controlname, int iStep)
+ {
+ try
+ {
+ int iCurStep = AnyConverter.toInt(getControlProperty(controlname, "Step"));
+ setControlProperty(controlname, "Step", new Integer(iStep));
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * @author bc93774
+ * The problem with setting the visibility of controls is that changing the current step
+ * of a dialog will automatically make all controls visible. The "Step" property always wins against
+ * the property "visible". Therfor a control meant to be invisible is placed on a step far far away.
+ * Afterwards the step property of the dialog has to be set with "repaintDialogStep". As the performance
+ * of that method is very bad it should be used only once for all controls
+ * @param controlname the name of the control
+ * @param bIsVisible sets the control visible or invisible
+ */
+ public void setControlVisible(String controlname, boolean bIsVisible)
+ {
+ try
+ {
+ int iCurControlStep = AnyConverter.toInt(getControlProperty(controlname, "Step"));
+ int iCurDialogStep = AnyConverter.toInt(Helper.getUnoPropertyValue(this.xDialogModel, "Step"));
+ int iNewStep;
+ if (bIsVisible)
+ {
+ setControlProperty(controlname, "Step", new Integer(iCurDialogStep));
+ }
+ else
+ {
+ setControlProperty(controlname, "Step", UIConsts.INVISIBLESTEP);
+ }
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * repaints the currentDialogStep
+ * @author bc93774
+ */
+ public void repaintDialogStep()
+ {
+ try
+ {
+ int ncurstep = AnyConverter.toInt(Helper.getUnoPropertyValue(this.xDialogModel, "Step"));
+ Helper.setUnoPropertyValue(xDialogModel, "Step", new Integer(99));
+ Helper.setUnoPropertyValue(xDialogModel, "Step", new Integer(ncurstep));
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public XInterface insertControlModel(String ServiceName, String sName, String[] sProperties, Object[] sValues)
+ {
+ try
+ {
+ XInterface xControlModel = (XInterface) MSFDialogModel.createInstance(ServiceName);
+ Helper.setUnoPropertyValues(xControlModel, sProperties, sValues);
+ xDlgNames.insertByName(sName, xControlModel);
+ return xControlModel;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void setFocus(String ControlName)
+ {
+ Object oFocusControl = xDlgContainer.getControl(ControlName);
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, oFocusControl);
+ xWindow.setFocus();
+ }
+
+ public static String[] combineListboxList(String sFirstEntry, String[] MainList)
+ {
+ try
+ {
+ String[] FirstList = new String[]
+ {
+ sFirstEntry
+ };
+ String[] ResultList = new String[MainList.length + 1];
+ System.arraycopy(FirstList, 0, ResultList, 0, 1);
+ System.arraycopy(MainList, 0, ResultList, 1, MainList.length);
+ return ResultList;
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public void selectListBoxItem(XListBox xListBox, short iFieldsSelIndex)
+ {
+ if (iFieldsSelIndex > -1)
+ {
+ int FieldCount = xListBox.getItemCount();
+ if (FieldCount > 0)
+ {
+ if (iFieldsSelIndex < FieldCount)
+ {
+ xListBox.selectItemPos(iFieldsSelIndex, true);
+ }
+ else
+ {
+ xListBox.selectItemPos((short) (iFieldsSelIndex - 1), true);
+ }
+ }
+ }
+ }
+
+ /** deselects a Listbox. MultipleMode is not supported
+ *
+ * @param _xBasisListBox
+ */
+ public static void deselectListBox(XInterface _xBasisListBox)
+ {
+ Object oListBoxModel = getModel(_xBasisListBox);
+ Object sList = Helper.getUnoPropertyValue(oListBoxModel, "StringItemList");
+ Helper.setUnoPropertyValue(oListBoxModel, "StringItemList", new String[]
+ {
+ });
+ Helper.setUnoPropertyValue(oListBoxModel, "StringItemList", sList);
+ }
+
+ public void calculateDialogPosition(Rectangle FramePosSize)
+ {
+ // Todo: check if it would be useful or possible to create a dialog peer, that can be used for the messageboxes to
+ // maintain modality when they pop up.
+ Rectangle CurPosSize = xWindow.getPosSize();
+ int WindowHeight = FramePosSize.Height;
+ int WindowWidth = FramePosSize.Width;
+ int DialogWidth = CurPosSize.Width;
+ int DialogHeight = CurPosSize.Height;
+ int iXPos = ((WindowWidth / 2) - (DialogWidth / 2));
+ int iYPos = ((WindowHeight / 2) - (DialogHeight / 2));
+ xWindow.setPosSize(iXPos, iYPos, DialogWidth, DialogHeight, PosSize.POS);
+ }
+
+ /**
+ *
+ * @param FramePosSize
+ * @return 0 for cancel, 1 for ok
+ * @throws com.sun.star.uno.Exception
+ */
+ public short executeDialog(Rectangle FramePosSize) throws com.sun.star.uno.Exception
+ {
+ if (xControl.getPeer() == null)
+ {
+ throw new java.lang.IllegalArgumentException("Please create a peer, using your own frame");
+ }
+ calculateDialogPosition(FramePosSize);
+ if (xWindowPeer == null)
+ {
+ createWindowPeer();
+ }
+ xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer);
+// xVclWindowPeer.setProperty("AutoMnemonics", new Boolean(true));
+ this.BisHighContrastModeActivated = new Boolean(this.isHighContrastModeActivated());
+ xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, xUnoDialog);
+ return xDialog.execute();
+ }
+
+ public void setVisible(UnoDialog parent) throws com.sun.star.uno.Exception
+ {
+ calculateDialogPosition(parent.xWindow.getPosSize());
+ if (xWindowPeer == null)
+ {
+ createWindowPeer();
+ }
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, xWindowPeer);
+ xDialog = (XDialog) UnoRuntime.queryInterface(XDialog.class, xUnoDialog);
+ this.xWindow.setVisible(true);
+ }
+
+ /**
+ *
+ * @param parent
+ * @return 0 for cancel, 1 for ok.
+ * @throws com.sun.star.uno.Exception
+ */
+ public short executeDialog(UnoDialog parent)
+ throws com.sun.star.uno.Exception
+ {
+ return executeDialog(parent.xWindow.getPosSize());
+ }
+
+ /**
+ *
+ * @param xComponent
+ * @return 0 for cancel, 1 for ok.
+ * @throws com.sun.star.uno.Exception
+ */
+ public short executeDialog(XInterface xComponent) throws com.sun.star.uno.Exception
+ {
+ XFrame frame = (XFrame) UnoRuntime.queryInterface(XFrame.class, xComponent);
+ if (frame != null)
+ {
+ XWindow w = frame.getComponentWindow();
+ if (w != null)
+ {
+ return executeDialog(w.getPosSize());
+ }
+ }
+
+ return executeDialog(new Rectangle(0, 0, 640, 400));
+ }
+
+ /**
+ * When possible, use the other executeDialog methods, since
+ * there may be problems retrieving the actual active frame,
+ * for example under linux.
+ * @return 0 for cancel, 1 for ok
+ */
+ public short executeDialog() throws com.sun.star.uno.Exception
+ {
+ return executeDialog(Desktop.getActiveFrame(xMSF));
+ }
+
+ public void setAutoMnemonic(String ControlName, boolean bValue)
+ {
+ Object oControl = xDlgContainer.getControl(ControlName);
+ xControl = (XControl) UnoRuntime.queryInterface(XControl.class, oControl);
+ XWindowPeer xWindowPeer = xControl.getPeer();
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, xControl.getPeer());
+ xVclWindowPeer.setProperty("AutoMnemonics", new Boolean(bValue));
+ }
+
+ public void modifyFontWeight(String ControlName, float FontWeight)
+ {
+ FontDescriptor oFontDesc = new FontDescriptor();
+ oFontDesc.Weight = FontWeight;
+ setControlProperty(ControlName, "FontDescriptor", oFontDesc);
+ }
+
+ /**
+ * create a peer for this
+ * dialog, using the given
+ * peer as a parent.
+ * @param parentPeer
+ * @return
+ * @throws java.lang.Exception
+ */
+ public XWindowPeer createWindowPeer(XWindowPeer parentPeer) throws com.sun.star.uno.Exception
+ {
+ xWindow.setVisible(false);
+ Object tk = xMSF.createInstance("com.sun.star.awt.Toolkit");
+ if (parentPeer == null)
+ {
+ parentPeer = ((XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk)).getDesktopWindow();
+ }
+ XToolkit xToolkit = (XToolkit) UnoRuntime.queryInterface(XToolkit.class, tk);
+ xReschedule = (XReschedule) UnoRuntime.queryInterface(XReschedule.class, xToolkit);
+ // TEUER!
+ xControl.createPeer(xToolkit, parentPeer);
+ xWindowPeer = xControl.getPeer();
+ return xControl.getPeer();
+ }
+
+ /**
+ * Creates a peer for this
+ * dialog, using the active OO frame
+ * as the parent window.
+ * @return
+ * @throws java.lang.Exception
+ */
+ public XWindowPeer createWindowPeer() throws com.sun.star.uno.Exception
+ {
+ return createWindowPeer(null);
+ }
+
+ // deletes the first entry when this is equal to "DelEntryName"
+ // returns true when a new item is selected
+ public void deletefirstListboxEntry(String ListBoxName, String DelEntryName)
+ {
+ XControl xListControl = xDlgContainer.getControl(ListBoxName);
+ XListBox xListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, xListControl);
+ String FirstItem = xListBox.getItem((short) 0);
+ if (FirstItem.equals(DelEntryName))
+ {
+ short SelPos = xListBox.getSelectedItemPos();
+ xListBox.removeItems((short) 0, (short) 1);
+ if (SelPos > 0)
+ {
+ setControlProperty(ListBoxName, "SelectedItems", new short[SelPos]);
+ xListBox.selectItemPos((short) (SelPos - 1), true);
+ }
+ }
+ }
+
+ public void setPeerProperty(String ControlName, String PropertyName, Object PropertyValue)
+ {
+ Object oControl = xDlgContainer.getControl(ControlName);
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, oControl);
+ XWindowPeer xControlPeer = xControl.getPeer();
+ XVclWindowPeer xVclWindowPeer = (XVclWindowPeer) UnoRuntime.queryInterface(XVclWindowPeer.class, xControlPeer);
+ xVclWindowPeer.setProperty(PropertyName, PropertyValue);
+ }
+
+ public static Object getModel(Object control)
+ {
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, control);
+ XControlModel xModel = xControl.getModel();
+ return xModel;
+ }
+
+ public static void setEnabled(Object control, boolean enabled)
+ {
+ setEnabled(control, enabled ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public static void setEnabled(Object control, Boolean enabled)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Enabled", enabled);
+ }
+
+ /**
+ * @author bc93774
+ * @param oControlModel the model of a control
+ * @return the LabelType according to UIConsts.CONTROLTYPE
+ */
+ public static int getControlModelType(Object oControlModel)
+ {
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oControlModel);
+ if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFixedTextModel"))
+ {
+ return UIConsts.CONTROLTYPE.FIXEDTEXT;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlButtonModel"))
+ {
+ return UIConsts.CONTROLTYPE.BUTTON;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlCurrencyFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.CURRENCYFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlDateFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.DATEFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFixedLineModel"))
+ {
+ return UIConsts.CONTROLTYPE.FIXEDLINE;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlFormattedFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.FORMATTEDFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlRoadmapModel"))
+ {
+ return UIConsts.CONTROLTYPE.ROADMAP;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlNumericFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.NUMERICFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlPatternFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.PATTERNFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlHyperTextModel"))
+ {
+ return UIConsts.CONTROLTYPE.HYPERTEXT;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlProgressBarModel"))
+ {
+ return UIConsts.CONTROLTYPE.PROGRESSBAR;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlTimeFieldModel"))
+ {
+ return UIConsts.CONTROLTYPE.TIMEFIELD;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlImageControlModel"))
+ {
+ return UIConsts.CONTROLTYPE.IMAGECONTROL;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlRadioButtonModel"))
+ {
+ return UIConsts.CONTROLTYPE.RADIOBUTTON;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlCheckBoxModel"))
+ {
+ return UIConsts.CONTROLTYPE.CHECKBOX;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlEditModel"))
+ {
+ return UIConsts.CONTROLTYPE.EDITCONTROL;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlComboBoxModel"))
+ {
+ return UIConsts.CONTROLTYPE.COMBOBOX;
+ }
+ else if (xServiceInfo.supportsService("com.sun.star.awt.UnoControlListBoxModel")) // TODO Comboboxes??
+ {
+ return UIConsts.CONTROLTYPE.LISTBOX;
+ }
+ else
+ {
+ return UIConsts.CONTROLTYPE.UNKNOWN;
+ }
+ }
+
+ /**
+ * @author bc93774
+ * @param oControlModel
+ * @return the name of the property that contains the value of a controlmodel
+ */
+ public static String getDisplayProperty(Object oControlModel)
+ {
+ XServiceInfo xServiceInfo = (XServiceInfo) UnoRuntime.queryInterface(XServiceInfo.class, oControlModel);
+ int itype = getControlModelType(oControlModel);
+ return getDisplayProperty(itype);
+ }
+
+ /**
+ * @author bc93774
+ * @param itype The type of the control conforming to UIConst.ControlType
+ * @return the name of the property that contains the value of a controlmodel
+ */
+ public static String getDisplayProperty(int itype)
+ {
+ // String propertyname = "";
+ switch (itype)
+ {
+ case UIConsts.CONTROLTYPE.FIXEDTEXT:
+ return "Label";
+ case UIConsts.CONTROLTYPE.BUTTON:
+ return "Label";
+ case UIConsts.CONTROLTYPE.FIXEDLINE:
+ return "Label";
+ case UIConsts.CONTROLTYPE.NUMERICFIELD:
+ return "Value";
+ case UIConsts.CONTROLTYPE.CURRENCYFIELD:
+ return "Value";
+ case UIConsts.CONTROLTYPE.FORMATTEDFIELD:
+ return "EffectiveValue";
+ case UIConsts.CONTROLTYPE.DATEFIELD:
+ return "Date";
+ case UIConsts.CONTROLTYPE.TIMEFIELD:
+ return "Time";
+ case UIConsts.CONTROLTYPE.SCROLLBAR:
+ return "ScrollValue";
+ case UIConsts.CONTROLTYPE.PROGRESSBAR:
+ return "ProgressValue";
+ case UIConsts.CONTROLTYPE.IMAGECONTROL:
+ return "ImageURL";
+ case UIConsts.CONTROLTYPE.RADIOBUTTON:
+ return "State";
+ case UIConsts.CONTROLTYPE.CHECKBOX:
+ return "State";
+ case UIConsts.CONTROLTYPE.EDITCONTROL:
+ return "Text";
+ case UIConsts.CONTROLTYPE.COMBOBOX:
+ return "Text";
+ case UIConsts.CONTROLTYPE.PATTERNFIELD:
+ return "Text";
+ case UIConsts.CONTROLTYPE.LISTBOX:
+ return "SelectedItems";
+ default:
+ return "";
+ }
+ }
+
+ public void addResourceHandler(String _Unit, String _Module)
+ {
+ m_oResource = new Resource(xMSF, _Unit, _Module);
+ }
+
+ public static short setInitialTabindex(int _istep)
+ {
+ return (short) (_istep * 100);
+ }
+ private Boolean BisHighContrastModeActivated = null;
+
+ public boolean isHighContrastModeActivated()
+ {
+ if (xVclWindowPeer != null)
+ {
+ if (BisHighContrastModeActivated == null)
+ {
+ int nUIColor;
+ try
+ {
+ nUIColor = AnyConverter.toInt(this.xVclWindowPeer.getProperty("DisplayBackgroundColor"));
+ }
+ catch (IllegalArgumentException e)
+ {
+ e.printStackTrace(System.out);
+ return false;
+ }
+ //TODO: The following methods could be wrapped in an own class implementation
+ int nRed = getRedColorShare(nUIColor);
+ int nGreen = getGreenColorShare(nUIColor);
+ int nBlue = getBlueColorShare(nUIColor);
+ int nLuminance = ((nBlue * 28 + nGreen * 151 + nRed * 77) / 256);
+ boolean bisactivated = (nLuminance <= 25);
+ BisHighContrastModeActivated = new Boolean(bisactivated);
+ return bisactivated;
+ }
+ else
+ {
+ return BisHighContrastModeActivated.booleanValue();
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public static int getRedColorShare(int _nColor)
+ {
+ int nRed = (int) _nColor / 65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ int nGreenModulo = (nRedModulo % 256);
+ int nBlue = nGreenModulo;
+ return nRed;
+ }
+
+ public static int getGreenColorShare(int _nColor)
+ {
+ int nRed = (int) _nColor / 65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ return nGreen;
+ }
+
+ public static int getBlueColorShare(int _nColor)
+ {
+ int nRed = (int) _nColor / 65536;
+ int nRedModulo = _nColor % 65536;
+ int nGreen = (int) (nRedModulo / 256);
+ int nGreenModulo = (nRedModulo % 256);
+ int nBlue = nGreenModulo;
+ return nBlue;
+ }
+
+ public String getWizardImageUrl(int _nResId, int _nHCResId)
+ {
+ if (isHighContrastModeActivated())
+ {
+ return "private:resource/wzi/image/" + _nHCResId;
+ }
+ else
+ {
+ return "private:resource/wzi/image/" + _nResId;
+ }
+ }
+
+ public String getImageUrl(String _surl, String _shcurl)
+ {
+ if (isHighContrastModeActivated())
+ {
+ return _shcurl;
+ }
+ else
+ {
+ return _surl;
+ }
+ }
+
+ public static short getListBoxLineCount()
+ {
+ return (short)20;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/UnoDialog2.java b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
new file mode 100644
index 000000000000..184a4a354b0c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/UnoDialog2.java
@@ -0,0 +1,384 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XInterface;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.ui.event.*;
+
+/**
+ * This class contains convenience methods for inserting components to a dialog.
+ * It was created for use with the automatic conversion of Basic XML Dialog
+ * description files to a Java class which builds the same dialog through the UNO API.<br/>
+ * It uses an Event-Listener method, which calls a method through reflection
+ * wenn an event on a component is trigered.
+ * see the classes AbstractListener, CommonListener, MethodInvocation for details.
+ */
+public class UnoDialog2 extends UnoDialog implements EventNames
+{
+
+ /**
+ * Override this method to return another listener.
+ * @return
+ */
+ protected AbstractListener createListener()
+ {
+ return new CommonListener();
+ }
+
+ public UnoDialog2(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, new String[]
+ {
+ }, new Object[]
+ {
+ });
+ guiEventListener = createListener();
+ }
+
+ public XButton insertButton(String sName, String actionPerformed, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+
+ XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class);
+
+ if (actionPerformed != null)
+ {
+ xButton.addActionListener((XActionListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ }
+ return xButton;
+ }
+
+ public XButton insertButton(String sName, String actionPerformed, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertButton(sName, actionPerformed, this, sPropNames, oPropValues);
+ }
+
+ public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+
+ XButton xButton = (XButton) insertControlModel2("com.sun.star.awt.UnoControlButtonModel", sName, sPropNames, oPropValues, XButton.class);
+
+ if (actionPerformed != null)
+ {
+ xButton.addActionListener(actionPerformed);
+ }
+ return xButton;
+ }
+
+ public XButton insertImageButton(String sName, com.sun.star.awt.XActionListener actionPerformed, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertImageButton(sName, actionPerformed, this, sPropNames, oPropValues);
+ }
+
+ public XCheckBox insertCheckBox(String sName, String itemChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+
+ XCheckBox xCheckBox = (XCheckBox) insertControlModel2("com.sun.star.awt.UnoControlCheckBoxModel", sName, sPropNames, oPropValues, XCheckBox.class);
+
+ if (itemChanged != null)
+ {
+ xCheckBox.addItemListener((XItemListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ }
+ return xCheckBox;
+ }
+
+ public XCheckBox insertCheckBox(String sName, String itemChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertCheckBox(sName, itemChanged, this, sPropNames, oPropValues);
+ }
+
+ public XComboBox insertComboBox(String sName, String actionPerformed, String itemChanged, String textChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ XComboBox xComboBox = (XComboBox) insertControlModel2("com.sun.star.awt.UnoControlComboBoxModel", sName, sPropNames, oPropValues, XComboBox.class);
+ if (actionPerformed != null)
+ {
+ xComboBox.addActionListener((XActionListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ }
+ if (itemChanged != null)
+ {
+ xComboBox.addItemListener((XItemListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ }
+ if (textChanged != null)
+ {
+ XTextComponent xTextComponent = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, xComboBox);
+ xTextComponent.addTextListener((XTextListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_TEXT_CHANGED, textChanged, eventTarget);
+ }
+ return xComboBox;
+ }
+
+ public XComboBox insertComboBox(String sName, String actionPerformed, String itemChanged, String textChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertComboBox(sName, actionPerformed, textChanged, itemChanged, this, sPropNames, oPropValues);
+ }
+
+ public XListBox insertListBox(String sName, String actionPerformed, String itemChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ XListBox xListBox = (XListBox) insertControlModel2("com.sun.star.awt.UnoControlListBoxModel", sName, sPropNames, oPropValues, XListBox.class);
+ if (actionPerformed != null)
+ {
+ xListBox.addActionListener((XActionListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ACTION_PERFORMED, actionPerformed, eventTarget);
+ }
+ if (itemChanged != null)
+ {
+ xListBox.addItemListener((XItemListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ }
+ return xListBox;
+ }
+
+ public XListBox insertListBox(String sName, String actionPerformed, String itemChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertListBox(sName, actionPerformed, itemChanged, this, sPropNames, oPropValues);
+ }
+
+ public XRadioButton insertRadioButton(String sName, String itemChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ XRadioButton xRadioButton = (XRadioButton) insertControlModel2("com.sun.star.awt.UnoControlRadioButtonModel", sName, sPropNames, oPropValues, XRadioButton.class);
+ if (itemChanged != null)
+ {
+ xRadioButton.addItemListener((XItemListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_ITEM_CHANGED, itemChanged, eventTarget);
+ }
+ return xRadioButton;
+ }
+
+ public XRadioButton insertRadioButton(String sName, String itemChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertRadioButton(sName, itemChanged, this, sPropNames, oPropValues);
+ }
+
+ public XControl insertTitledBox(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ Object oTitledBox = insertControlModel2("com.sun.star.awt.UnoControlGroupBoxModel", sName, sPropNames, oPropValues);
+ return (XControl) UnoRuntime.queryInterface(XControl.class, oTitledBox);
+ }
+
+ public XTextComponent insertTextField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XTextComponent) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlEditModel", sPropNames, oPropValues, XTextComponent.class);
+ }
+
+ public XTextComponent insertTextField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertTextField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XControl insertImage(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XControl) insertControlModel2("com.sun.star.awt.UnoControlImageControlModel", sName, sPropNames, oPropValues, XControl.class);
+ }
+
+ public XControl insertInfoImage(int _posx, int _posy, int _iStep)
+ {
+ XControl xImgControl = insertImage(Desktop.getUniqueName(getDlgNameAccess(), "imgHint"),
+ new String[]
+ {
+ "Border", "Height", "ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 0), new Integer(10), UIConsts.INFOIMAGEURL, new Integer(_posx), new Integer(_posy), Boolean.FALSE, new Integer(_iStep), new Integer(10)
+ });
+ super.getPeerConfiguration().setImageUrl(getModel(xImgControl), UIConsts.INFOIMAGEURL, UIConsts.INFOIMAGEURL_HC);
+ return xImgControl;
+ }
+
+ /**
+ * This method is used for creating Edit, Currency, Date, Formatted, Pattern, File
+ * and Time edit components.
+ */
+ private Object insertEditField(String sName, String sTextChanged, Object eventTarget, String sModelClass, String[] sPropNames, Object[] oPropValues, Class type)
+ {
+ XTextComponent xField = (XTextComponent) insertControlModel2(sModelClass, sName, sPropNames, oPropValues, XTextComponent.class);
+ if (sTextChanged != null)
+ {
+ xField.addTextListener((XTextListener) guiEventListener);
+ guiEventListener.add(sName, EVENT_TEXT_CHANGED, sTextChanged, eventTarget);
+ }
+ return UnoRuntime.queryInterface(type, xField);
+ }
+
+ public XControl insertFileControl(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XControl) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlFileControlModel", sPropNames, oPropValues, XControl.class);
+ }
+
+ public XControl insertFileControl(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertFileControl(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XCurrencyField insertCurrencyField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XCurrencyField) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlCurrencyFieldModel", sPropNames, oPropValues, XCurrencyField.class);
+ }
+
+ public XCurrencyField insertCurrencyField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertCurrencyField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XDateField insertDateField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XDateField) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlDateFieldModel", sPropNames, oPropValues, XDateField.class);
+ }
+
+ public XDateField insertDateField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertDateField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XNumericField insertNumericField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XNumericField) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlNumericFieldModel", sPropNames, oPropValues, XNumericField.class);
+ }
+
+ public XNumericField insertNumericField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertNumericField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XTimeField insertTimeField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XTimeField) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlTimeFieldModel", sPropNames, oPropValues, XTimeField.class);
+ }
+
+ public XTimeField insertTimeField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertTimeField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XPatternField insertPatternField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XPatternField) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlPatternFieldModel", sPropNames, oPropValues, XPatternField.class);
+ }
+
+ public XPatternField insertPatternField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertPatternField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XTextComponent insertFormattedField(String sName, String sTextChanged, Object eventTarget, String[] sPropNames, Object[] oPropValues)
+ {
+ return (XTextComponent) insertEditField(sName, sTextChanged, eventTarget, "com.sun.star.awt.UnoControlFormattedFieldModel", sPropNames, oPropValues, XTextComponent.class);
+ }
+
+ public XTextComponent insertFormattedField(String sName, String sTextChanged, String[] sPropNames, Object[] oPropValues)
+ {
+ return insertFormattedField(sName, sTextChanged, this, sPropNames, oPropValues);
+ }
+
+ public XControl insertFixedLine(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ Object oLine = insertControlModel2("com.sun.star.awt.UnoControlFixedLineModel", sName, sPropNames, oPropValues);
+ return (XControl) UnoRuntime.queryInterface(XControl.class, oLine);
+ }
+
+ public XScrollBar insertScrollBar(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ Object oScrollBar = insertControlModel2("com.sun.star.awt.UnoControlScrollBarModel", sName, sPropNames, oPropValues);
+ return (XScrollBar) UnoRuntime.queryInterface(XScrollBar.class, oScrollBar);
+ }
+
+ public XProgressBar insertProgressBar(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ Object oProgressBar = insertControlModel2("com.sun.star.awt.UnoControlProgressBarModel", sName, sPropNames, oPropValues);
+ return (XProgressBar) UnoRuntime.queryInterface(XProgressBar.class, oProgressBar);
+ }
+
+ public XControl insertGroupBox(String sName, String[] sPropNames, Object[] oPropValues)
+ {
+ Object oGroupBox = insertControlModel2("com.sun.star.awt.UnoControlGroupBoxModel", sName, sPropNames, oPropValues);
+ return (XControl) UnoRuntime.queryInterface(XControl.class, oGroupBox);
+ }
+
+ public Object insertControlModel2(String serviceName, String componentName, String[] sPropNames, Object[] oPropValues)
+ {
+ try
+ {
+ //System.out.println("Inserting : " + componentName);
+ XInterface xControlModel = insertControlModel(serviceName, componentName, new String[]
+ {
+ }, new Object[]
+ {
+ });
+ Helper.setUnoPropertyValues(xControlModel, sPropNames, oPropValues);
+ //setControlPropertiesDebug(xControlModel, sPropNames, oPropValues);
+ //System.out.println(" Setting props successfull !");
+ Helper.setUnoPropertyValue(xControlModel, "Name", componentName);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ final Object aObj = xDlgContainer.getControl(componentName);
+ return aObj;
+ }
+
+ private void setControlPropertiesDebug(Object model, String[] names, Object[] values)
+ {
+ for (int i = 0; i < names.length; i++)
+ {
+ System.out.println(" Settings: " + names[i]);
+ Helper.setUnoPropertyValue(model, names[i], values[i]);
+ }
+
+
+ }
+
+ public Object insertControlModel2(String serviceName, String componentName, String[] sPropNames, Object[] oPropValues, Class type)
+ {
+ return UnoRuntime.queryInterface(type, insertControlModel2(serviceName, componentName, sPropNames, oPropValues));
+ }
+
+ public String translateURL(String relativeURL)
+ {
+ return "";
+ }
+
+ public static Object getControlModel(Object unoControl)
+ {
+ Object obj = ((XControl) UnoRuntime.queryInterface(XControl.class, unoControl)).getModel();
+ return obj;
+ }
+
+ public int showMessageBox(String windowServiceName, int windowAttribute, String MessageText)
+ {
+ return SystemDialog.showMessageBox(xMSF, this.xControl.getPeer(), windowServiceName, windowAttribute, MessageText);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/WizardDialog.java b/wizards/com/sun/star/wizards/ui/WizardDialog.java
new file mode 100644
index 000000000000..50ff51c5bbd4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/WizardDialog.java
@@ -0,0 +1,811 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+import java.beans.*;
+
+import com.sun.star.wizards.ui.event.CommonListener;
+import com.sun.star.wizards.ui.event.EventNames;
+import com.sun.star.wizards.ui.event.MethodInvocation;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.awt.*;
+import com.sun.star.uno.AnyConverter;
+import com.sun.star.uno.XInterface;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.container.XIndexContainer;
+import com.sun.star.frame.XTerminateListener;
+import com.sun.star.frame.TerminationVetoException;
+import com.sun.star.lang.IllegalArgumentException;
+import com.sun.star.beans.*;
+import com.sun.star.wizards.common.HelpIds;
+
+public abstract class WizardDialog extends UnoDialog2 implements VetoableChangeListener, XTerminateListener, XCompletion
+{
+
+ private static final String NEXT_ACTION_PERFORMED = "gotoNextAvailableStep";
+ private static final String BACK_ACTION_PERFORMED = "gotoPreviousAvailableStep";
+ private static final String FINISH_ACTION_PERFORMED = "finishWizard_1";
+ private static final String CANCEL_ACTION_PERFORMED = "cancelWizard_1";
+ private static final String HELP_ACTION_PERFORMED = "callHelp";
+ public VetoableChangeSupport vetos = new VetoableChangeSupport(this);
+ private String[] sRightPaneHeaders;
+ private int iButtonWidth = 50;
+ private int nNewStep = 1;
+ private int nOldStep = 1;
+ private int nMaxStep = 1;
+ protected XItemListener RoadmapItemListener;
+ protected XControl xRoadmapControl;
+ XItemEventBroadcaster xRoadmapBroadcaster;
+ String[] sRMItemLabels;
+ private Object oRoadmap;
+ private XSingleServiceFactory xSSFRoadmap;
+ public XIndexContainer xIndexContRoadmap;
+ private Resource oWizardResource;
+ public String sMsgEndAutopilot;
+ private int hid;
+ private boolean bTerminateListenermustberemoved = true;
+
+ /** Creates a new instance of WizardDialog
+ * the hid is used as following :
+ * "HID:(hid)" - the dialog
+ * "HID:(hid+1) - the help button
+ * "HID:(hid+2)" - the back button
+ * "HID:(hid+3)" - the next button
+ * "HID:(hid+4)" - the create button
+ * "HID:(hid+5)" - the cancel button
+ * @param xMSF
+ * @param hid_
+ */
+ public WizardDialog(XMultiServiceFactory xMSF, int hid_)
+ {
+ super(xMSF);
+ hid = hid_;
+ oWizardResource = new Resource(xMSF, "Common", "dbw");
+ sMsgEndAutopilot = oWizardResource.getResText(UIConsts.RID_DB_COMMON + 33);
+
+ //new Resource(xMSF,"Common","com");
+ }
+
+ /**
+ *
+ * @return
+ */
+ public Resource getResource()
+ {
+ return oWizardResource;
+ }
+
+ public void activate()
+ {
+ try
+ {
+ XTopWindow top = (XTopWindow) UnoRuntime.queryInterface(XTopWindow.class, xWindow);
+ if (top != null)
+ {
+ top.toFront();
+ }
+ }
+ catch (Exception ex)
+ {
+ // do nothing;
+ }
+ }
+
+ public void setMaxStep(int i)
+ {
+ nMaxStep = i;
+ }
+
+ public int getMaxStep()
+ {
+ return nMaxStep;
+ }
+
+ public void setOldStep(int i)
+ {
+ nOldStep = i;
+ }
+
+ public int getOldStep()
+ {
+ return nOldStep;
+ }
+
+ public void setNewStep(int i)
+ {
+ nNewStep = i;
+ }
+
+ public int getNewStep()
+ {
+ return nNewStep;
+ }
+
+ /**
+ * @see java.beans.VetoableChangeListener#vetoableChange(java.beans.PropertyChangeEvent)
+ */
+ public void vetoableChange(java.beans.PropertyChangeEvent arg0)
+ {
+ nNewStep = nOldStep;
+ }
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent)
+ {
+ try
+ {
+ nNewStep = itemEvent.ItemId;
+ nOldStep = AnyConverter.toInt(Helper.getUnoPropertyValue(xDialogModel, "Step"));
+ if (nNewStep != nOldStep)
+ {
+ switchToStep();
+ }
+ }
+ catch (com.sun.star.lang.IllegalArgumentException exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+
+ public void setRoadmapInteractive(boolean _bInteractive)
+ {
+ Helper.setUnoPropertyValue(oRoadmap, "Activated", new Boolean(_bInteractive));
+ }
+
+ public void setRoadmapComplete(boolean bComplete)
+ {
+ Helper.setUnoPropertyValue(oRoadmap, "Complete", new Boolean(bComplete));
+ }
+
+ public boolean isRoadmapComplete()
+ {
+ try
+ {
+ return AnyConverter.toBoolean(Helper.getUnoPropertyValue(oRoadmap, "Complete"));
+ }
+ catch (IllegalArgumentException exception)
+ {
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public void setCurrentRoadmapItemID(short ID)
+ {
+ if (oRoadmap != null)
+ {
+ int nCurItemID = getCurrentRoadmapItemID();
+ if (nCurItemID != ID)
+ {
+ Helper.setUnoPropertyValue(oRoadmap, "CurrentItemID", new Short(ID));
+ }
+ }
+ }
+
+ public int getCurrentRoadmapItemID()
+ {
+ try
+ {
+ return AnyConverter.toInt(Helper.getUnoPropertyValue(oRoadmap, "CurrentItemID"));
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+ public void addRoadmap()
+ {
+ try
+ {
+ int iDialogHeight = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, "Height")).intValue();
+
+ // the roadmap control has got no real TabIndex ever
+ // that is not correct, but changing this would need time, so it is used
+ // without TabIndex as before
+ oRoadmap = insertControlModel("com.sun.star.awt.UnoControlRoadmapModel", "rdmNavi",
+ new String[]
+ {
+ "Height",
+ "PositionX",
+ "PositionY",
+ "Step",
+ "TabIndex",
+ "Tabstop",
+ "Width"
+ },
+ new Object[]
+ {
+ new Integer(iDialogHeight - 26),
+ new Integer(0),
+ new Integer(0),
+ new Integer(0),
+ new Short((short)0),
+ Boolean.TRUE,
+ new Integer(85)
+ });
+ XPropertySet xPSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmap);
+ xPSet.setPropertyValue("Name", "rdmNavi");
+
+ xSSFRoadmap = (XSingleServiceFactory) UnoRuntime.queryInterface(XSingleServiceFactory.class, oRoadmap);
+ xIndexContRoadmap = (XIndexContainer) UnoRuntime.queryInterface(XIndexContainer.class, oRoadmap);
+ // XPropertySet xPropRoadmapModel = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, oRoadmap);
+ // xPropRoadmapModel.addPropertyChangeListener("CurrentItemID", new WizardDialog.RoadmapItemListener(this.xDialogModel));
+
+ MethodInvocation mi = new MethodInvocation("itemStateChanged", this, com.sun.star.awt.ItemEvent.class);
+ getGuiEventListener().add("rdmNavi", EventNames.EVENT_ITEM_CHANGED, mi);
+ xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
+ xRoadmapBroadcaster = (XItemEventBroadcaster) UnoRuntime.queryInterface(XItemEventBroadcaster.class, xRoadmapControl);
+ xRoadmapBroadcaster.addItemListener((XItemListener) getGuiEventListener());
+
+ // xRoadmapControl = this.xDlgContainer.getControl("rdmNavi");
+ // xRoadmapBroadcaster.addItemListener(new RoadmapItemListener());
+ Helper.setUnoPropertyValue(oRoadmap, "Text", oWizardResource.getResText(UIConsts.RID_COMMON + 16));
+ }
+ catch (NoSuchMethodException ex)
+ {
+ Resource.showCommonResourceError(xMSF);
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ public void setRMItemLabels(Resource _oResource, int StartResID)
+ {
+ sRMItemLabels = _oResource.getResArray(StartResID, nMaxStep);
+ }
+
+ public String[] getRMItemLabels()
+ {
+ return sRMItemLabels;
+ }
+
+ /* public void insertRoadmapItems(int StartIndex, int RMCount)
+ {
+ Object oRoadmapItem;
+ boolean bEnabled;
+ for (int i = StartIndex; i < (StartIndex + RMCount); i++)
+ insertSingleRoadmapItem(i, true, sRMItemLabels[i], i);
+ }*/
+ public int insertRoadmapItem(int _Index, boolean _bEnabled, int _LabelID, int _CurItemID)
+ {
+ return insertRoadmapItem(_Index, _bEnabled, sRMItemLabels[_LabelID], _CurItemID);
+ }
+
+ public int insertRoadmapItem(int Index, boolean _bEnabled, String _sLabel, int _CurItemID)
+ {
+ try
+ {
+ Object oRoadmapItem = xSSFRoadmap.createInstance();
+ Helper.setUnoPropertyValue(oRoadmapItem, "Label", _sLabel);
+ Helper.setUnoPropertyValue(oRoadmapItem, "Enabled", new Boolean(_bEnabled));
+ Helper.setUnoPropertyValue(oRoadmapItem, "ID", new Integer(_CurItemID));
+ xIndexContRoadmap.insertByIndex(Index, oRoadmapItem);
+ int NextIndex = Index + 1;
+ return NextIndex;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+ public int getRMItemCount()
+ {
+ return xIndexContRoadmap.getCount();
+ }
+
+ public XInterface getRoadmapItemByID(int _ID)
+ {
+ try
+ {
+ int CurID;
+ XInterface CurRoadmapItem;
+ for (int i = 0; i < xIndexContRoadmap.getCount(); i++)
+ {
+ CurRoadmapItem = (XInterface) xIndexContRoadmap.getByIndex(i);
+ CurID = AnyConverter.toInt(Helper.getUnoPropertyValue(CurRoadmapItem, "ID"));
+ if (CurID == _ID)
+ {
+ return CurRoadmapItem;
+ }
+ }
+ return null;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return null;
+ }
+ }
+
+ public boolean switchToStep(int _nOldStep, int _nNewStep)
+ {
+ nOldStep = _nOldStep;
+ nNewStep = _nNewStep;
+ return switchToStep();
+ }
+
+ private boolean switchToStep()
+ {
+ leaveStep(nOldStep, nNewStep);
+ if (nNewStep != nOldStep)
+ {
+ if (nNewStep == nMaxStep)
+ {
+ setControlProperty("btnWizardNext", "DefaultButton", Boolean.FALSE);
+ setControlProperty("btnWizardFinish", "DefaultButton", Boolean.TRUE);
+ }
+ else
+ {
+ setControlProperty("btnWizardNext", "DefaultButton", Boolean.TRUE);
+ setControlProperty("btnWizardFinish", "DefaultButton", Boolean.FALSE);
+ }
+ changeToStep(nNewStep);
+ enterStep(nOldStep, nNewStep);
+ return true;
+ }
+ return false;
+ }
+
+ abstract protected void leaveStep(int nOldStep, int nNewStep);
+
+ abstract protected void enterStep(int nOldStep, int nNewStep);
+
+ protected void changeToStep(int nNewStep)
+ {
+ Helper.setUnoPropertyValue(xDialogModel, "Step", new Integer(nNewStep));
+ setCurrentRoadmapItemID((short) (nNewStep));
+ enableNextButton(getNextAvailableStep() > 0);
+ enableBackButton(nNewStep != 1);
+ }
+
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#iscompleted(int)
+ */
+ /**
+ *
+ * @param _ndialogpage
+ * @return
+ */
+ public boolean iscompleted(int _ndialogpage)
+ {
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#ismodified(int)
+ */
+
+ /**
+ *
+ * @param _ndialogpage
+ * @return
+ */
+ public boolean ismodified(int _ndialogpage)
+ {
+ return false;
+ }
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#setcompleted(int, boolean)
+ */
+
+ /**
+ *
+ * @param _ndialogpage
+ * @param _biscompleted
+ */
+ public void setcompleted(int _ndialogpage, boolean _biscompleted)
+ {
+ }
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.XCompletion#setmodified(int, java.lang.Object, java.lang.Object)
+ */
+
+ /**
+ *
+ * @param _ndialogpage
+ * @param ooldValue
+ * @param onewValue
+ */
+ public void setmodified(int _ndialogpage, Object ooldValue, Object onewValue)
+ {
+ }
+
+ public void drawNaviBar()
+ {
+
+ try
+ {
+ short curtabindex = UIConsts.SOFIRSTWIZARDNAVITABINDEX;
+ Integer IButtonWidth = new Integer(iButtonWidth);
+ int iButtonHeight = 14;
+ Integer IButtonHeight = new Integer(iButtonHeight);
+ Integer ICurStep = new Integer(0);
+ int iDialogHeight = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, "Height")).intValue();
+ int iDialogWidth = ((Integer) Helper.getUnoPropertyValue(this.xDialogModel, "Width")).intValue();
+ int iHelpPosX = 8;
+ int iBtnPosY = iDialogHeight - iButtonHeight - 6;
+ int iCancelPosX = iDialogWidth - iButtonWidth - 6;
+ int iFinishPosX = iCancelPosX - 6 - iButtonWidth;
+ int iNextPosX = iFinishPosX - 6 - iButtonWidth;
+ int iBackPosX = iNextPosX - 3 - iButtonWidth;
+
+ insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lnNaviSep",
+ new String[]
+ {
+ "Height", "Orientation", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(1), new Integer(0), new Integer(0), new Integer(iDialogHeight - 26), ICurStep, new Integer(iDialogWidth)
+ });
+
+ insertControlModel("com.sun.star.awt.UnoControlFixedLineModel", "lnRoadSep",
+ new String[]
+ {
+ "Height", "Orientation", "PositionX", "PositionY", "Step", "Width"
+ },
+ new Object[]
+ {
+ new Integer(iBtnPosY - 6), new Integer(1), new Integer(85), new Integer(0), ICurStep, new Integer(1)
+ });
+
+ String[] propNames = new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Label", "PositionX", "PositionY", "PushButtonType", "Step", "TabIndex", "Width"
+ };
+
+ Helper.setUnoPropertyValue(super.xDialogModel, "HelpURL", HelpIds.getHelpIdString(hid));
+ insertButton("btnWizardHelp", HELP_ACTION_PERFORMED, new String[]
+ {
+ "Enabled", "Height", "Label", "PositionX", "PositionY", "PushButtonType", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Boolean(true), IButtonHeight, oWizardResource.getResText(UIConsts.RID_COMMON + 15), new Integer(iHelpPosX), new Integer(iBtnPosY), new Short((short) PushButtonType.HELP_value), ICurStep, new Short(curtabindex++), IButtonWidth
+ });
+ insertButton("btnWizardBack", BACK_ACTION_PERFORMED, propNames,
+ new Object[]
+ {
+ new Boolean(false), IButtonHeight, HelpIds.getHelpIdString(hid + 2), oWizardResource.getResText(UIConsts.RID_COMMON + 13), new Integer(iBackPosX), new Integer(iBtnPosY), new Short((short) PushButtonType.STANDARD_value), ICurStep, new Short(curtabindex++), IButtonWidth
+ });
+
+ insertButton("btnWizardNext", NEXT_ACTION_PERFORMED, propNames,
+ new Object[]
+ {
+ new Boolean(true), IButtonHeight, HelpIds.getHelpIdString(hid + 3), oWizardResource.getResText(UIConsts.RID_COMMON + 14), new Integer(iNextPosX), new Integer(iBtnPosY), new Short((short) PushButtonType.STANDARD_value), ICurStep, new Short(curtabindex++), IButtonWidth
+ });
+
+ insertButton("btnWizardFinish", FINISH_ACTION_PERFORMED, propNames,
+ new Object[]
+ {
+ new Boolean(true), IButtonHeight, HelpIds.getHelpIdString(hid + 4), oWizardResource.getResText(UIConsts.RID_COMMON + 12), new Integer(iFinishPosX), new Integer(iBtnPosY), new Short((short) PushButtonType.STANDARD_value), ICurStep, new Short(curtabindex++), IButtonWidth
+ });
+
+ insertButton("btnWizardCancel", CANCEL_ACTION_PERFORMED, propNames,
+ new Object[]
+ {
+ new Boolean(true), IButtonHeight, HelpIds.getHelpIdString(hid + 5), oWizardResource.getResText(UIConsts.RID_COMMON + 11), new Integer(iCancelPosX), new Integer(iBtnPosY), new Short((short) PushButtonType.STANDARD_value), ICurStep, new Short(curtabindex++), IButtonWidth
+ });
+
+ setControlProperty("btnWizardNext", "DefaultButton", Boolean.TRUE);
+ // add a window listener, to know
+ // if the user used "escape" key to
+ // close the dialog.
+ MethodInvocation windowHidden = new MethodInvocation("windowHidden", this);
+ xWindow.addWindowListener((CommonListener) getGuiEventListener());
+ String dialogName = (String) Helper.getUnoPropertyValue(xDialogModel, "Name");
+ getGuiEventListener().add(dialogName, EVENT_ACTION_PERFORMED, windowHidden);
+
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ protected void insertRoadMapItems(String[] items, int[] steps, boolean[] enabled)
+ {
+ for (int i = 0; i < items.length; i++)
+ {
+ insertRoadmapItem(i, enabled[i], items[i], steps[i]);
+ }
+ }
+
+ /** This method also enables and disables the "next" button,
+ * if the step currently dis/enabled is the one of the next steps.
+ * @param _nStep
+ * @param bEnabled
+ * @param enableNextButton
+ */
+ public void setStepEnabled(int _nStep, boolean bEnabled, boolean enableNextButton)
+ {
+ setStepEnabled(_nStep, bEnabled);
+ if (getNextAvailableStep() > 0)
+ {
+ enableNextButton(bEnabled);
+ }
+ }
+
+ public void enableNavigationButtons(boolean _bEnableBack, boolean _bEnableNext, boolean _bEnableFinish)
+ {
+ enableBackButton(_bEnableBack);
+ enableNextButton(_bEnableNext);
+ enableFinishButton(_bEnableFinish);
+ }
+
+ public void enableBackButton(boolean enabled)
+ {
+ setControlProperty("btnWizardBack", "Enabled", enabled ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public void enableNextButton(boolean enabled)
+ {
+ setControlProperty("btnWizardNext", "Enabled", enabled ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public void enableFinishButton(boolean enabled)
+ {
+ setControlProperty("btnWizardFinish", "Enabled", enabled ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public void setStepEnabled(int _nStep, boolean bEnabled)
+ {
+ XInterface xRoadmapItem = getRoadmapItemByID(_nStep);
+ if (xRoadmapItem != null)
+ {
+ Helper.setUnoPropertyValue(xRoadmapItem, "Enabled", new Boolean(bEnabled));
+ }
+ }
+
+ public void enablefromStep(int _iStep, boolean _bDoEnable)
+ {
+ if (_iStep <= this.nMaxStep)
+ {
+ for (int i = _iStep; i <= nMaxStep; i++)
+ {
+ setStepEnabled(i, _bDoEnable);
+ }
+ enableFinishButton(_bDoEnable);
+ if (!_bDoEnable)
+ {
+ enableNextButton(_iStep > getCurrentStep() + 1);
+ }
+ else
+ {
+ enableNextButton(!(getCurrentStep() == nMaxStep));
+ }
+ }
+ }
+
+ public boolean isStepEnabled(int _nStep)
+ {
+ try
+ {
+ boolean bIsEnabled;
+ XInterface xRoadmapItem = getRoadmapItemByID(_nStep);
+ if (xRoadmapItem == null)
+ // Todo: In this case an exception should be thrown
+ {
+ return false;
+ }
+ bIsEnabled = AnyConverter.toBoolean(Helper.getUnoPropertyValue(xRoadmapItem, "Enabled"));
+ return bIsEnabled;
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return false;
+ }
+ }
+
+ public synchronized void gotoPreviousAvailableStep()
+ {
+ boolean bIsEnabled;
+ if (nNewStep > 1)
+ {
+ nOldStep = nNewStep;
+ nNewStep--;
+ while (nNewStep > 0)
+ {
+ bIsEnabled = isStepEnabled(nNewStep);
+ if (bIsEnabled)
+ {
+ break;
+ }
+ nNewStep--;
+ }
+ if (nNewStep == 0) // Exception???
+ {
+ nNewStep = nOldStep;
+ }
+ switchToStep();
+ }
+ }
+
+ //TODO discuss with rp
+ protected int getNextAvailableStep()
+ {
+ if (isRoadmapComplete())
+ {
+ for (int i = nNewStep + 1; i <= nMaxStep; i++)
+ {
+ if (isStepEnabled(i))
+ {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public synchronized void gotoNextAvailableStep()
+ {
+ nOldStep = nNewStep;
+ nNewStep = getNextAvailableStep();
+ if (nNewStep > -1)
+ {
+ switchToStep();
+ }
+ }
+
+ public abstract boolean finishWizard();
+
+ /**
+ * This function will call if the finish button is pressed on the UI.
+ */
+ public void finishWizard_1()
+ {
+ enableFinishButton(false);
+ boolean success = false;
+ try
+ {
+ success = finishWizard();
+ }
+ finally
+ {
+ if ( !success )
+ enableFinishButton( true );
+ }
+ if ( success )
+ removeTerminateListener();
+ }
+
+ public int getMaximalStep()
+ {
+ return this.nMaxStep;
+ }
+
+ public int getCurrentStep()
+ {
+ try
+ {
+ return AnyConverter.toInt(Helper.getUnoPropertyValue(this.MSFDialogModel, "Step"));
+ }
+ catch (com.sun.star.uno.Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ return -1;
+ }
+ }
+
+ public void setCurrentStep(int _nNewstep)
+ {
+ nNewStep = _nNewstep;
+ changeToStep(nNewStep);
+ }
+
+ public void setRightPaneHeaders(Resource _oResource, int StartResID, int _nMaxStep)
+ {
+ String[] sRightPaneHeaders = _oResource.getResArray(StartResID, _nMaxStep);
+ setRightPaneHeaders(sRightPaneHeaders);
+ }
+
+ public void setRightPaneHeaders(String[] _sRightPaneHeaders)
+ {
+ this.nMaxStep = _sRightPaneHeaders.length;
+ this.sRightPaneHeaders = _sRightPaneHeaders;
+ FontDescriptor oFontDesc = new FontDescriptor();
+ oFontDesc.Weight = com.sun.star.awt.FontWeight.BOLD;
+
+ for (int i = 0; i < sRightPaneHeaders.length; i++)
+ {
+ insertLabel("lblQueryTitle" + String.valueOf(i),
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ oFontDesc, new Integer(16), sRightPaneHeaders[i], Boolean.TRUE, new Integer(91), new Integer(8), new Integer(i + 1), new Short((short) 12), new Integer(212)
+ });
+ }
+ }
+
+ public void cancelWizard()
+ {
+ //can be overwritten by extending class
+ xDialog.endExecute();
+ }
+
+ public void callHelp()
+ {
+ //should be overwritten by extending class
+ }
+
+ public void removeTerminateListener()
+ {
+ if (bTerminateListenermustberemoved)
+ {
+ Desktop.getDesktop(xMSF).removeTerminateListener(this);
+ bTerminateListenermustberemoved = false;
+ }
+ }
+
+ /**
+ * called by the cancel button and
+ * by the window hidden event.
+ * if this method was not called before,
+ * perform a cancel.
+ */
+ public void cancelWizard_1()
+ {
+ cancelWizard();
+ removeTerminateListener();
+ }
+
+ public void windowHidden()
+ {
+ cancelWizard_1();
+ }
+
+ public void notifyTermination(EventObject arg0)
+ {
+ cancelWizard_1();
+ }
+
+ public void queryTermination(EventObject arg0)
+ throws TerminationVetoException
+ {
+ activate();
+ throw new TerminationVetoException();
+ }
+
+ public void disposing(EventObject arg0)
+ {
+ cancelWizard_1();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/XCommandSelectionListener.java b/wizards/com/sun/star/wizards/ui/XCommandSelectionListener.java
new file mode 100644
index 000000000000..24fbd10eb9dd
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/XCommandSelectionListener.java
@@ -0,0 +1,43 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * XDSFieldSelection.java
+ *
+ * Created on July 23, 2003, 5:05 PM
+ */
+package com.sun.star.wizards.ui;
+
+/**
+ *
+ * @author bc93774
+ */
+public interface XCommandSelectionListener
+{
+
+ public void CommandSelected(String CommandName);
+}
diff --git a/wizards/com/sun/star/wizards/ui/XCompletion.java b/wizards/com/sun/star/wizards/ui/XCompletion.java
new file mode 100644
index 000000000000..545345731e39
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/XCompletion.java
@@ -0,0 +1,39 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+public interface XCompletion
+{
+
+ public void setcompleted(int _ndialogpage, boolean _biscompleted);
+
+ public boolean iscompleted(int _ndialogpage);
+
+ public void setmodified(int _ndialogpage, Object ooldValue, Object onewValue);
+
+ public boolean ismodified(int _ndialogpage);
+}
diff --git a/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java b/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java
new file mode 100644
index 000000000000..b47ad2363709
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/XFieldSelectionListener.java
@@ -0,0 +1,53 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * FieldSelectionActions.java
+ *
+ * Created on July 14, 2003, 5:42 PM
+ */
+package com.sun.star.wizards.ui;
+
+/**
+ *
+ * @author bc93774
+ */
+public interface XFieldSelectionListener
+{
+
+ public void shiftFromLeftToRight(String[] SelItems, String[] NewItems);
+
+ public void shiftFromRightToLeft(String[] OldSelItems, String[] NewItems);
+
+ public void moveItemUp(String Selitem);
+
+ public void moveItemDown(String Selitem);
+
+ public void setID(String sIncSuffix);
+
+ public int getID();
+}
diff --git a/wizards/com/sun/star/wizards/ui/XPathSelectionListener.java b/wizards/com/sun/star/wizards/ui/XPathSelectionListener.java
new file mode 100755
index 000000000000..5c76c092a46f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/XPathSelectionListener.java
@@ -0,0 +1,34 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui;
+
+public interface XPathSelectionListener
+{
+
+ public void validatePath();
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/AbstractListener.java b/wizards/com/sun/star/wizards/ui/event/AbstractListener.java
new file mode 100644
index 000000000000..ebbcba96f58c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/AbstractListener.java
@@ -0,0 +1,133 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.XControl;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Hashtable;
+
+/**
+ * This class is a base class for listener classes.
+ * It uses a hashtable to map between a ComponentName, EventName and a MethodInvokation Object.
+ * To use this class do the following:<br/>
+ * <list>
+ * <li>Write a subclass which implements the needed Listener(s).</li>
+ * in the even methods, use invoke(...).
+ * <li>When instanciating the component, register the subclass as the event listener.</li>
+ * <li>Write the methods which should be performed when the event occures.</li>
+ * <li>call the "add" method, to define a component-event-action mapping.</li>
+ * </list>
+ * @author rpiterman
+ */
+public class AbstractListener
+{
+
+ private Hashtable mHashtable = new Hashtable();
+
+ /** Creates a new instance of AbstractListener */
+ public AbstractListener()
+ {
+ }
+
+ public void add(String componentName, String eventName, String methodName, Object target)
+ {
+ try
+ {
+ add(componentName, eventName, new MethodInvocation(methodName, target));
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public void add(String componentName, String eventName, MethodInvocation mi)
+ {
+ mHashtable.put(componentName + eventName, mi);
+ }
+
+ public MethodInvocation get(String componentName, String eventName)
+ {
+ return (MethodInvocation) mHashtable.get(componentName + eventName);
+ }
+
+ public Object invoke(String componentName, String eventName, Object param)
+ {
+ try
+ {
+ MethodInvocation mi = get(componentName, eventName);
+ if (mi != null)
+ {
+ return mi.invoke(param);
+ }
+ else
+ {
+ return null;
+ }
+ }
+ catch (InvocationTargetException ite)
+ {
+
+ System.out.println("=======================================================");
+ System.out.println("=== Note: An Exception was thrown which should have ===");
+ System.out.println("=== caused a crash. I caught it. Please report this ===");
+ System.out.println("=== to openoffice.org ===");
+ System.out.println("=======================================================");
+
+ ite.printStackTrace();
+
+ }
+ catch (IllegalAccessException iae)
+ {
+ iae.printStackTrace();
+ }
+ catch (Exception ex)
+ {
+ System.out.println("=======================================================");
+ System.out.println("=== Note: An Exception was thrown which should have ===");
+ System.out.println("=== caused a crash. I Catched it. Please report this ==");
+ System.out.println("=== to openoffice.org ==");
+ System.out.println("=======================================================");
+ ex.printStackTrace();
+ }
+
+ return null;
+ }
+
+ /**
+ * Rerurns the property "name" of the Object which is the source of the event.
+ */
+ public static String getEventSourceName(EventObject eventObject)
+ {
+ XControl xControl = (XControl) UnoRuntime.queryInterface(XControl.class, eventObject.Source);
+ return (String) Helper.getUnoPropertyValue(xControl.getModel(), "Name", String.class);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/CommonListener.java b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
new file mode 100644
index 000000000000..18f33af2cef8
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/CommonListener.java
@@ -0,0 +1,167 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.EventObject;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class CommonListener extends AbstractListener implements XActionListener, XItemListener, XTextListener, EventNames, XWindowListener, XMouseListener, XFocusListener, XKeyListener
+{
+
+ /** Creates a new instance of CommonListener */
+ public CommonListener()
+ {
+ }
+
+ /**
+ * Implementation of com.sun.star.awt.XActionListener
+ */
+ public void actionPerformed(com.sun.star.awt.ActionEvent actionEvent)
+ {
+ invoke(getEventSourceName(actionEvent), EVENT_ACTION_PERFORMED, actionEvent);
+ }
+
+ public void disposing(com.sun.star.lang.EventObject eventObject)
+ {
+ }
+
+ /**
+ * Implementation of com.sun.star.awt.XItemListener
+ */
+ public void itemStateChanged(ItemEvent itemEvent)
+ {
+ invoke(getEventSourceName(itemEvent), EVENT_ITEM_CHANGED, itemEvent);
+ }
+
+ /**
+ * Implementation of com.sun.star.awt.XTextListener
+ */
+ public void textChanged(TextEvent textEvent)
+ {
+ invoke(getEventSourceName(textEvent), EVENT_TEXT_CHANGED, textEvent);
+ }
+
+ /**
+ * @see com.sun.star.awt.XWindowListener#windowResized(com.sun.star.awt.WindowEvent)
+ */
+ public void windowResized(WindowEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_WINDOW_RESIZED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XWindowListener#windowMoved(com.sun.star.awt.WindowEvent)
+ */
+ public void windowMoved(WindowEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_WINDOW_MOVED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XWindowListener#windowShown(com.sun.star.lang.EventObject)
+ */
+ public void windowShown(EventObject event)
+ {
+ invoke(getEventSourceName(event), EVENT_WINDOW_SHOWN, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XWindowListener#windowHidden(com.sun.star.lang.EventObject)
+ */
+ public void windowHidden(EventObject event)
+ {
+ invoke(getEventSourceName(event), EVENT_WINDOW_HIDDEN, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XMouseListener#mousePressed(com.sun.star.awt.MouseEvent)
+ */
+ public void mousePressed(MouseEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_MOUSE_PRESSED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XMouseListener#mouseReleased(com.sun.star.awt.MouseEvent)
+ */
+ public void mouseReleased(MouseEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_KEY_RELEASED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XMouseListener#mouseEntered(com.sun.star.awt.MouseEvent)
+ */
+ public void mouseEntered(MouseEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_MOUSE_ENTERED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XMouseListener#mouseExited(com.sun.star.awt.MouseEvent)
+ */
+ public void mouseExited(MouseEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_MOUSE_EXITED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XFocusListener#focusGained(com.sun.star.awt.FocusEvent)
+ */
+ public void focusGained(FocusEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_FOCUS_GAINED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XFocusListener#focusLost(com.sun.star.awt.FocusEvent)
+ */
+ public void focusLost(FocusEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_FOCUS_LOST, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XKeyListener#keyPressed(com.sun.star.awt.KeyEvent)
+ */
+ public void keyPressed(KeyEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_KEY_PRESSED, event);
+ }
+
+ /**
+ * @see com.sun.star.awt.XKeyListener#keyReleased(com.sun.star.awt.KeyEvent)
+ */
+ public void keyReleased(KeyEvent event)
+ {
+ invoke(getEventSourceName(event), EVENT_KEY_RELEASED, event);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.java b/wizards/com/sun/star/wizards/ui/event/DataAware.java
new file mode 100644
index 000000000000..b81b8e71bcdb
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/DataAware.java
@@ -0,0 +1,365 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * @author rpiterman
+ * DataAware objects are used to live-synchronize UI and DataModel/DataObject.
+ * It is used as listener on UI events, to keep the DataObject up to date.
+ * This class, as a base abstract class, sets a frame of functionality,
+ * delegating the data Object get/set methods to a Value object,
+ * and leaving the UI get/set methods abstract.
+ * Note that event listenning is *not* a part of this model.
+ * the updateData() or updateUI() methods should be porogramatically called.
+ * in child classes, the updateData() will be binded to UI event calls.
+ * <br><br>
+ * This class holds references to a Data Object and a Value object.
+ * The Value object "knows" how to get and set a value from the
+ * Data Object.
+ */
+public abstract class DataAware {
+
+ /**
+ * this is the data object.
+ */
+ protected Object dataObject;
+ //protected Method setMethod;
+ //protected Method getMethod;
+ /**
+ * A Value Object knows how to get/set a value
+ * from/to the data object.
+ */
+ protected Value value;
+
+ /**
+ * creates a DataAware object for the given data object and Value object.
+ * @param dataObject_
+ * @param value_
+ */
+ protected DataAware(Object dataObject_, Value value_) {
+ dataObject = dataObject_;
+ value = value_;
+ //getMethod = createGetMethod(dataPropName, dataObject);
+ //setMethod = createSetMethod(dataPropName, dataObject, getMethod.getReturnType());
+ }
+
+ /**
+ * returns the data object.
+ * @return
+ */
+ public Object getDataObject() {
+ return dataObject;
+ }
+
+ /**
+ * sets a new data object. Optionally
+ * update the UI.
+ * @param obj the new data object.
+ * @param updateUI if true updateUI() will be called.
+ */
+ public void setDataObject(Object obj, boolean updateUI) {
+
+ if (obj != null && !value.isAssignable(obj.getClass()))
+ throw new ClassCastException("can not cast new DataObject to original Class");
+
+ dataObject = obj;
+
+ if (updateUI)
+ updateUI();
+
+ }
+
+ /**
+ * Sets the given value to the data object.
+ * this method delegates the job to the
+ * Value object, but can be overwritten if
+ * another kind of Data is needed.
+ * @param newValue the new value to set to the DataObject.
+ */
+ protected void setToData(Object newValue) {
+ value.set(newValue,getDataObject());
+ }
+
+ /**
+ * gets the current value from the data obejct.
+ * this method delegates the job to
+ * the value object.
+ * @return the current value of the data object.
+ */
+ protected Object getFromData() {
+ return value.get(getDataObject());
+ }
+
+ /**
+ * sets the given value to the UI control
+ * @param newValue the value to set to the ui control.
+ */
+ protected abstract void setToUI(Object newValue);
+
+ /**
+ * gets the current value from the UI control.
+ * @return the current value from the UI control.
+ */
+ protected abstract Object getFromUI();
+
+ /**
+ * updates the UI control according to the
+ * current state of the data object.
+ */
+ public void updateUI() {
+ Object data = getFromData();
+ Object ui = getFromUI();
+ if (!equals(data, ui))
+ try {
+ setToUI(data);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ //TODO tell user...
+ }
+ enableControls(data);
+ }
+
+ /**
+ * enables
+ * @param currentValue
+ */
+ protected void enableControls(Object currentValue) {
+ }
+
+ /**
+ * updates the DataObject according to
+ * the current state of the UI control.
+ */
+ public void updateData() {
+ Object data = getFromData();
+ Object ui = getFromUI();
+ if (!equals(data, ui))
+ setToData(ui);
+ enableControls(ui);
+ }
+
+ public interface Listener {
+ public void eventPerformed(Object event);
+ }
+
+ /**
+ * compares the two given objects.
+ * This method is null safe and returns true also if both are null...
+ * If both are arrays, treats them as array of short and compares them.
+ * @param a first object to compare
+ * @param b second object to compare.
+ * @return true if both are null or both are equal.
+ */
+ protected boolean equals(Object a, Object b) {
+ if (a == null && b == null)
+ return true;
+ if (a == null || b == null)
+ return false;
+ if (a.getClass().isArray()) {
+ if (b.getClass().isArray())
+ return Arrays.equals((short[]) a, (short[]) b);
+ else
+ return false;
+ }
+ return a.equals(b);
+ }
+
+ /**
+ * given a collection containing DataAware objects,
+ * calls updateUI() on each memebr of the collection.
+ * @param dataAwares a collection containing DataAware objects.
+ */
+ public static void updateUI(Collection dataAwares) {
+ for (Iterator i = dataAwares.iterator(); i.hasNext();)
+ ((DataAware) i.next()).updateUI();
+ }
+
+ public static void updateData(Collection dataAwares) {
+ for (Iterator i = dataAwares.iterator(); i.hasNext();)
+ ((DataAware) i.next()).updateData();
+ }
+
+ /**
+ * /**
+ * Given a collection containing DataAware objects,
+ * sets the given DataObject to each DataAware object
+ * in the given collection
+ * @param dataAwares a collection of DataAware objects.
+ * @param dataObject new data object to set to the DataAware objects in the given collection.
+ * @param updateUI if true, calls updateUI() on each DataAware object.
+ */public static void setDataObject(Collection dataAwares, Object dataObject, boolean updateUI) {
+ for (Iterator i = dataAwares.iterator(); i.hasNext();)
+ ((DataAware) i.next()).setDataObject(dataObject, updateUI);
+ }
+
+ /**
+ * Value objects read and write a value from and
+ * to an object. Typically using reflection and JavaBeans properties
+ * or directly using memeber reflection API.
+ * DataAware delegates the handling of the DataObject
+ * to a Value object.
+ * 2 implementations currently exist: PropertyValue,
+ * using JavaBeans properties reflection, and DataAwareFields classes
+ * which implement different memeber types.
+ */
+ public interface Value {
+ /**
+ * gets a value from the given object.
+ * @param target the object to get the value from.
+ * @return the value from the given object.
+ */
+ public Object get(Object target);
+ /**
+ * sets a value to the given object.
+ * @param value the value to set to the object.
+ * @param target the object to set the value to.
+ */
+ public void set(Object value, Object target);
+ /**
+ * checks if this Value object can handle
+ * the given object type as a target.
+ * @param type the type of a target to check
+ * @return true if the given class is acceptible for
+ * the Value object. False if not.
+ */
+ public boolean isAssignable(Class type);
+ }
+
+ /**
+ * implementation of Value, handling JavaBeans properties through
+ * reflection.
+ * This Object gets and sets a value a specific
+ * (JavaBean-style) property on a given object.
+ * @author rp143992
+ */
+ public static class PropertyValue implements Value {
+ /**
+ * the get method of the JavaBean-style property
+ */
+ private Method getMethod;
+ /**
+ * the set method of the JavaBean-style property
+ */
+ private Method setMethod;
+
+ /**
+ * creates a PropertyValue for the property with
+ * the given name, of the given JavaBean object.
+ * @param propertyName the property to access. Must be a Cup letter (e.g. "Name" for getName() and setName("..."). )
+ * @param propertyOwner the object which "own" or "contains" the property.
+ */
+ public PropertyValue(String propertyName, Object propertyOwner) {
+ getMethod = createGetMethod(propertyName, propertyOwner);
+ setMethod = createSetMethod(propertyName, propertyOwner, getMethod.getReturnType());
+ }
+
+ /**
+ * called from the constructor, and creates a get method reflection object
+ * for the given property and object.
+ * @param propName the property name0
+ * @param obj the object which contains the property.
+ * @return the get method reflection object.
+ */
+ private static Class[] EMPTY_ARRAY = new Class[0];
+
+ protected Method createGetMethod(String propName, Object obj)
+ {
+ Method m = null;
+ try
+ { //try to get a "get" method.
+
+ m = obj.getClass().getMethod("get" + propName, EMPTY_ARRAY);
+ }
+ catch (NoSuchMethodException ex1)
+ {
+ throw new IllegalArgumentException("get" + propName + "() method does not exist on " + obj.getClass().getName());
+ }
+ return m;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+ public Object get(Object target) {
+ try {
+ return getMethod.invoke(target, EMPTY_ARRAY);
+ } catch (IllegalAccessException ex1) {
+ ex1.printStackTrace();
+ } catch (InvocationTargetException ex2) {
+ ex2.printStackTrace();
+ } catch (NullPointerException npe) {
+ if (getMethod.getReturnType().equals(String.class))
+ return "";
+ if (getMethod.getReturnType().equals(Short.class))
+ return new Short((short) 0);
+ if (getMethod.getReturnType().equals(Integer.class))
+ return new Integer(0);
+ if (getMethod.getReturnType().equals(short[].class))
+ return new short[0];
+ }
+ return null;
+
+ }
+
+ protected Method createSetMethod(String propName, Object obj, Class paramClass) {
+ Method m = null;
+ try {
+ m = obj.getClass().getMethod("set" + propName, new Class[] { paramClass });
+ } catch (NoSuchMethodException ex1) {
+ throw new IllegalArgumentException("set" + propName + "(" + getMethod.getReturnType().getName() + ") method does not exist on " + obj.getClass().getName());
+ }
+ return m;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#set(java.lang.Object, java.lang.Object)
+ */
+ public void set(Object value, Object target) {
+ try {
+ setMethod.invoke(target, new Object[] {value});
+ } catch (IllegalAccessException ex1) {
+ ex1.printStackTrace();
+ } catch (InvocationTargetException ex2) {
+ ex2.printStackTrace();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#isAssignable(java.lang.Class)
+ */
+ public boolean isAssignable(Class type) {
+ return getMethod.getDeclaringClass().isAssignableFrom(type) &&
+ setMethod.getDeclaringClass().isAssignableFrom(type);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java
new file mode 100644
index 000000000000..74881d7b1f23
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/DataAwareFields.java
@@ -0,0 +1,507 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.lang.reflect.Field;
+
+import com.sun.star.uno.Any;
+
+/**
+ * This class is a factory for Value objects for different types of
+ * memebers.
+ * Other than some Value implementations classes this class contains static
+ * type conversion methods and factory methods.
+ *
+ * @see com.sun.star.wizards.ui.event.DataAware.Value
+ */
+public class DataAwareFields
+{
+
+ private static final String TRUE = "true";
+ private static final String FALSE = "false";
+
+ /**
+ * returns a Value Object which sets and gets values
+ * and converting them to other types, according to the "value" argument.
+ *
+ * @param owner
+ * @param fieldname
+ * @param value
+ * @return
+ * @throws NoSuchFieldException
+ */
+ public static DataAware.Value getFieldValueFor(Object owner, String fieldname, Object value)
+ {
+ try
+ {
+ Field f = owner.getClass().getField(fieldname);
+
+ Class c = f.getType();
+ Class c2 = value.getClass();
+ if (c.equals(Boolean.TYPE))
+ {
+ return new BooleanFieldValue(f, c2);
+ }
+ else if (c.equals(Integer.TYPE))
+ {
+ return new IntFieldValue(f, c2);
+ }
+ else if (c.equals(Double.TYPE))
+ {
+ return new DoubleFieldValue(f, c2);
+ }
+ else if (c.equals(String.class) && c2.equals(Integer.class))
+ {
+ return new ConvertedStringValue(f, c2);
+ }
+ else
+ {
+ return new SimpleFieldValue(f);
+ }
+ }
+ catch (NoSuchFieldException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ /**
+ * an abstract implementation of DataAware.Value to access
+ * object memebers (fields) usign reflection.
+ */
+ private static abstract class FieldValue implements DataAware.Value
+ {
+
+ Field field;
+
+ public FieldValue(Field field_)
+ {
+ field = field_;
+ }
+
+ public boolean isAssignable(Class type)
+ {
+ return field.getDeclaringClass().isAssignableFrom(type);
+ }
+ }
+
+ private static class BooleanFieldValue extends FieldValue
+ {
+
+ private Class convertTo;
+
+ public BooleanFieldValue(Field f, Class convertTo_)
+ {
+ super(f);
+ convertTo = convertTo_;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+ public Object get(Object target)
+ {
+ try
+ {
+ boolean b = field.getBoolean(target);
+ if (convertTo.equals(Boolean.class))
+ {
+ return b ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (Number.class.isAssignableFrom(convertTo))
+ {
+ return toNumber(b ? 1 : 0, convertTo);
+ }
+ else if (convertTo.equals(String.class))
+ {
+ return String.valueOf(b);
+ }
+ else if (convertTo.isArray())
+ {
+ return toShortArray(toInt(b));
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert boolean value to given type (" + convertTo.getName() + ").");
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ public void set(Object value, Object target)
+ {
+ try
+ {
+ field.setBoolean(target, toBoolean(value));
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static class IntFieldValue extends FieldValue
+ {
+
+ private Class convertTo;
+
+ public IntFieldValue(Field f, Class convertTo_)
+ {
+ super(f);
+ convertTo = convertTo_;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+ public Object get(Object target)
+ {
+ try
+ {
+ int i = field.getInt(target);
+ if (convertTo.equals(Boolean.class))
+ {
+ return i != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (Number.class.isAssignableFrom(convertTo))
+ {
+ return toNumber(i, convertTo);
+ }
+ else if (convertTo.equals(String.class))
+ {
+ return String.valueOf(i);
+ }
+ else if (convertTo.isArray())
+ {
+ return toShortArray(i);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ public void set(Object value, Object target)
+ {
+ try
+ {
+ field.setInt(target, (int) toDouble(value));
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static class DoubleFieldValue extends FieldValue
+ {
+
+ private Class convertTo;
+
+ public DoubleFieldValue(Field f, Class convertTo_)
+ {
+ super(f);
+ convertTo = convertTo_;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+ public Object get(Object target)
+ {
+ try
+ {
+ double d = field.getDouble(target);
+ if (convertTo.equals(Boolean.class))
+ {
+ return d != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (Number.class.isAssignableFrom(convertTo))
+ {
+ return toNumber(d, convertTo);
+ }
+ else if (convertTo.equals(String.class))
+ {
+ return String.valueOf(d);
+ }
+ else if (convertTo.isArray())
+ {
+ return toShortArray(d);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ public void set(Object value, Object target)
+ {
+ try
+ {
+ field.setDouble(target, toDouble(value));
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static class ConvertedStringValue extends FieldValue
+ {
+
+ private Class convertTo;
+
+ public ConvertedStringValue(Field f, Class convertTo_)
+ {
+ super(f);
+ convertTo = convertTo_;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+ public Object get(Object target)
+ {
+ try
+ {
+ String s = (String) field.get(target);
+
+ if (convertTo.equals(Boolean.class))
+ {
+ return (s != null && !s.equals("") && s.equals("true")) ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (convertTo.equals(Integer.class))
+ {
+ if (s == null || s.equals(""))
+ {
+ return Any.VOID;
+ }
+ else
+ {
+ return new Integer(s);
+ }
+ }
+ else if (convertTo.equals(Double.class))
+ {
+ if (s == null || s.equals(""))
+ {
+ return Any.VOID;
+ }
+ else
+ {
+ return new Double(s);
+ }
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert int value to given type (" + convertTo.getName() + ").");
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ public void set(Object value, Object target)
+ {
+ try
+ {
+ field.set(target, value == null || (value.equals(Any.VOID)) ? "" : value.toString());
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static class SimpleFieldValue extends FieldValue
+ {
+
+ public SimpleFieldValue(Field f)
+ {
+ super(f);
+ }
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.event.DataAware.Value#get(java.lang.Object)
+ */
+
+ public Object get(Object target)
+ {
+ try
+ {
+ if (target == null)
+ {
+ if (field.getType().equals(String.class))
+ {
+ return "";
+ }
+ if (field.getType().equals(Short.class))
+ {
+ return new Short((short) 0);
+ }
+ if (field.getType().equals(Integer.class))
+ {
+ return new Integer(0);
+ }
+ if (field.getType().equals(short[].class))
+ {
+ return new short[0];
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else
+ {
+ return field.get(target);
+ }
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ return null;
+ }
+ }
+
+ public void set(Object value, Object target)
+ {
+ try
+ {
+ field.set(target, value);
+ }
+ catch (IllegalAccessException ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+
+ private static double toDouble(Object value)
+ {
+ if (value instanceof Boolean)
+ {
+ return ((Boolean) value).booleanValue() ? 1 : 0;
+ }
+ else if (value instanceof Number)
+ {
+ return ((Number) value).doubleValue();
+ }
+ else if (value instanceof String)
+ {
+ return Double.valueOf((String) value).doubleValue();
+ }
+ else if (value instanceof short[])
+ {
+ return ((short[]) value).length == 0 ? 0 : ((short[]) value)[0];
+ }
+ else
+ {
+ throw new IllegalArgumentException("Can't convert value to double." + value.getClass().getName());
+ }
+ }
+
+ private static boolean toBoolean(Object value)
+ {
+ if (value instanceof Boolean)
+ {
+ return ((Boolean) value).booleanValue();
+ }
+ else if (value instanceof Number)
+ {
+ return ((Number) value).intValue() != 0;
+ }
+ else if (value instanceof String)
+ {
+ return ((String) value).equals(TRUE);
+ }
+ else if (value instanceof short[])
+ {
+ return ((short[]) value).length != 0 && ((short[]) value)[0] != 0;
+ }
+ else
+ {
+ throw new IllegalArgumentException("Can't convert value to boolean." + value.getClass().getName());
+ }
+ }
+
+ private static int toInt(boolean b)
+ {
+ return b ? 1 : 0;
+ }
+
+ private static short[] toShortArray(double i)
+ {
+ return new short[]
+ {
+ (short) i
+ };
+ }
+
+ private static Number toNumber(double i, Class c)
+ {
+ if (c.equals(Integer.class))
+ {
+ return new Integer((int) i);
+ }
+ else if (c.equals(Short.class))
+ {
+ return new Short((short) i);
+ }
+ else if (c.equals(Double.class))
+ {
+ return new Double(i);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot convert to the given Number type.");
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/EventNames.java b/wizards/com/sun/star/wizards/ui/event/EventNames.java
new file mode 100644
index 000000000000..50aa32dc57aa
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/EventNames.java
@@ -0,0 +1,52 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+/**
+ *
+ * @author rpiterman
+ */
+public interface EventNames
+{
+
+ //common listener events
+ public static final String EVENT_ACTION_PERFORMED = "APR";
+ public static final String EVENT_ITEM_CHANGED = "ICH";
+ public static final String EVENT_TEXT_CHANGED = "TCH"; //window events (XWindow)
+ public static final String EVENT_WINDOW_RESIZED = "WRE";
+ public static final String EVENT_WINDOW_MOVED = "WMO";
+ public static final String EVENT_WINDOW_SHOWN = "WSH";
+ public static final String EVENT_WINDOW_HIDDEN = "WHI"; //focus events (XWindow)
+ public static final String EVENT_FOCUS_GAINED = "FGA";
+ public static final String EVENT_FOCUS_LOST = "FLO"; //keyboard events
+ public static final String EVENT_KEY_PRESSED = "KPR";
+ public static final String EVENT_KEY_RELEASED = "KRE"; //mouse events
+ public static final String EVENT_MOUSE_PRESSED = "MPR";
+ public static final String EVENT_MOUSE_RELEASED = "MRE";
+ public static final String EVENT_MOUSE_ENTERED = "MEN";
+ public static final String EVENT_MOUSE_EXITED = "MEX"; //other events
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/ListModelBinder.java b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.java
new file mode 100644
index 000000000000..b2dc75f22f48
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/ListModelBinder.java
@@ -0,0 +1,209 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import javax.swing.ListModel;
+import javax.swing.event.ListDataEvent;
+import javax.swing.event.ListDataListener;
+
+import com.sun.star.awt.XComboBox;
+import com.sun.star.awt.XListBox;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+/**
+ * @author rpiterman
+
+ * */
+public class ListModelBinder implements ListDataListener
+{
+
+ private XListBox unoList;
+ private Object unoListModel;
+ private ListModel listModel;
+ private Renderer renderer = new Renderer()
+ {
+
+ public String render(Object item)
+ {
+ if (item == null)
+ {
+ return "";
+ }
+ else
+ {
+ return item.toString();
+ }
+ }
+ };
+
+ public ListModelBinder(Object unoListBox, ListModel listModel_)
+ {
+ unoList = (XListBox) UnoRuntime.queryInterface(XListBox.class, unoListBox);
+ unoListModel = UnoDataAware.getModel(unoListBox);
+ setListModel(listModel_);
+ }
+
+ public void setListModel(ListModel newListModel)
+ {
+ if (listModel != null)
+ {
+ listModel.removeListDataListener(this);
+ }
+ listModel = newListModel;
+ listModel.addListDataListener(this);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#contentsChanged(javax.swing.event.ListDataEvent)
+ */
+ public void contentsChanged(ListDataEvent lde)
+ {
+ short[] selected = getSelectedItems();
+ for (short i = (short) lde.getIndex0(); i <= lde.getIndex1(); i++)
+ {
+ update(i);
+ }
+ setSelectedItems(selected);
+ }
+
+ protected void update(short i)
+ {
+ remove(i, i);
+ insert(i);
+ }
+
+ protected void remove(short i1, short i2)
+ {
+ unoList.removeItems((short) i1, (short) (i2 - i1 + 1));
+ }
+
+ protected void insert(short i)
+ {
+ unoList.addItem(getItemString(i), i);
+ }
+
+ protected String getItemString(short i)
+ {
+ return getItemString(listModel.getElementAt((int) i));
+ }
+
+ protected String getItemString(Object item)
+ {
+ return renderer.render(item);
+ }
+
+ protected short[] getSelectedItems()
+ {
+ return (short[]) Helper.getUnoPropertyValue(unoListModel, "SelectedItems");
+ }
+
+ protected void setSelectedItems(short[] selected)
+ {
+ Helper.setUnoPropertyValue(unoListModel, "SelectedItems", selected);
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#intervalAdded(javax.swing.event.ListDataEvent)
+ */
+ public void intervalAdded(ListDataEvent lde)
+ {
+ //Short[] selected = getSelectedItems();
+ for (short i = (short) lde.getIndex0(); i <= lde.getIndex1(); i++)
+ {
+ insert(i);
+
+ /*int insertedItems = lde.getIndex1() - lde.getIndex0() + 1;
+
+ for (int i = 0; i<selected.length; i++)
+ if (selected[i].intValue() >= lde.getIndex0())
+ selected[i] = new Short((short)(selected[i].shortValue() + insertedItems));
+ setSelectedItems(selected);*/
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.event.ListDataListener#intervalRemoved(javax.swing.event.ListDataEvent)
+ */
+ public void intervalRemoved(ListDataEvent lde)
+ {
+ //Short[] selected = getSelectedItems();
+
+ remove((short) lde.getIndex0(), (short) lde.getIndex1());
+
+ /*int removed = 0;
+ for (int i = 0; i<selected.length; i++) {
+ short s = selected[i].shortValue();
+ if (s>=lde.getIndex0() && s<==lde.getIndex1()) {
+ selected[i] = null;
+ removed++;
+ }
+ }
+
+ Short[] newSelected = (removed > 0 ? new Short[selected.length - removed] : selected;
+ if (removed>0)
+
+ if (selected[i].intValue() >= lde.getIndex0())
+ */
+ }
+
+ public static interface Renderer
+ {
+
+ public String render(Object item);
+ }
+
+ public static void fillList(Object list, Object[] items, Renderer renderer)
+ {
+ XListBox xlist = (XListBox) UnoRuntime.queryInterface(XListBox.class, list);
+ Helper.setUnoPropertyValue(UnoDataAware.getModel(list), "StringItemList", new String[]
+ {
+ });
+ for (short i = 0; i < items.length; i++)
+ {
+ if (items[i] != null)
+ {
+ xlist.addItem((renderer != null ? renderer.render(items[i]) : items[i].toString()), i);
+ }
+ }
+ }
+
+ public static void fillComboBox(Object list, Object[] items, Renderer renderer)
+ {
+ XComboBox xComboBox = (XComboBox) UnoRuntime.queryInterface(XComboBox.class, list);
+ Helper.setUnoPropertyValue(UnoDataAware.getModel(list), "StringItemList", new String[]
+ {
+ });
+ for (short i = 0; i < items.length; i++)
+ {
+ if (items[i] != null)
+ {
+ xComboBox.addItem((renderer != null ? renderer.render(items[i]) : items[i].toString()), i);
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java
new file mode 100644
index 000000000000..c45a496c7849
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/MethodInvocation.java
@@ -0,0 +1,108 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+/**
+ * Encapsulate a Method invocation.
+ * In the constructor one defines a method, a target object and an optional
+ * Parameter.
+ * Then one calls "invoke", with or without a parameter. <br/>
+ * Limitations: I do not check anything myself. If the param is not ok, from the
+ * wrong type, or the mothod doesnot exist on the given object.
+ * You can trick this class howmuch you want: it will all throw exceptions
+ * on the java level. i throw no error warnings or my own excceptions...
+ * @author rpiterman
+ */
+public class MethodInvocation
+{
+
+ static final Class[] EMPTY_ARRAY =
+ {
+ };
+ //the method to invoke.
+ Method mMethod;
+ //the object to invoke the method on.
+ Object mObject;
+ //with one Parameter / without
+ boolean mWithParam;
+
+ /** Creates a new instance of MethodInvokation */
+ public MethodInvocation(String methodName, Object obj) throws NoSuchMethodException
+ {
+ this(methodName, obj, null);
+ }
+
+ public MethodInvocation(Method method, Object obj)
+ {
+ this(method, obj, null);
+ }
+
+ public MethodInvocation(String methodName, Object obj, Class paramClass) throws NoSuchMethodException
+ {
+ this(paramClass == null ? obj.getClass().getMethod(methodName, null) : obj.getClass().getMethod(methodName, new Class[]
+ {
+ paramClass
+ }), obj, paramClass);
+ }
+
+ public MethodInvocation(Method method, Object obj, Class paramClass)
+ {
+ mMethod = method;
+ mObject = obj;
+ mWithParam = !(paramClass == null);
+ }
+
+ /**
+ * Returns the result of calling the method on the object, or null, if no result.
+ */
+ public Object invoke(Object param) throws IllegalAccessException, InvocationTargetException
+ {
+ if (mWithParam)
+ {
+ return mMethod.invoke(mObject, new Object[]
+ {
+ (Object) param
+ });
+ }
+ else
+ {
+ return mMethod.invoke(mObject, EMPTY_ARRAY);
+ }
+ }
+
+ /**
+ * This method is a convenience method.
+ * It is the same as calling invoke(null);
+ */
+ public Object invoke() throws IllegalAccessException, InvocationTargetException
+ {
+ return invoke(null);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/RadioDataAware.java b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.java
new file mode 100644
index 000000000000..7dddea572503
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/RadioDataAware.java
@@ -0,0 +1,101 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.uno.UnoRuntime;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class RadioDataAware extends DataAware
+{
+
+ protected XRadioButton[] radioButtons;
+
+ public RadioDataAware(Object data, Value value, Object[] radioButs)
+ {
+ super(data, value);
+ radioButtons = new XRadioButton[radioButs.length];
+ for (int i = 0; i < radioButs.length; i++)
+ {
+ radioButtons[i] = (XRadioButton) UnoRuntime.queryInterface(XRadioButton.class, radioButs[i]);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.DataAware#setToUI(java.lang.Object)
+ */
+ protected void setToUI(Object value)
+ {
+ int selected = ((Number) value).intValue();
+ if (selected == -1)
+ {
+ for (int i = 0; i < radioButtons.length; i++)
+ {
+ radioButtons[i].setState(false);
+ }
+ }
+ else
+ {
+ radioButtons[selected].setState(true);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.DataAware#getFromUI()
+ */
+ protected Object getFromUI()
+ {
+ for (int i = 0; i < radioButtons.length; i++)
+ {
+ if (radioButtons[i].getState())
+ {
+ return new Integer(i);
+ }
+ }
+ return new Integer(-1);
+ }
+
+ public static DataAware attachRadioButtons(Object data, String dataProp, Object[] buttons, final Listener listener, boolean field)
+ {
+ final RadioDataAware da = new RadioDataAware(data,
+ field
+ ? DataAwareFields.getFieldValueFor(data, dataProp, new Integer(0))
+ : new DataAware.PropertyValue(dataProp, data), buttons);
+ XItemListener xil = UnoDataAware.itemListener(da, listener);
+ for (int i = 0; i < da.radioButtons.length; i++)
+ {
+ da.radioButtons[i].addItemListener(xil);
+ }
+ return da;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/SimpleDataAware.java b/wizards/com/sun/star/wizards/ui/event/SimpleDataAware.java
new file mode 100644
index 000000000000..8a9c2200d76d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/SimpleDataAware.java
@@ -0,0 +1,84 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+public class SimpleDataAware extends DataAware
+{
+
+ protected Object control;
+ protected Object[] disableObjects = new Object[0];
+ protected Value controlValue;
+
+ public SimpleDataAware(Object dataObject, Value value, Object control_, Value controlValue_)
+ {
+ super(dataObject, value);
+ control = control_;
+ controlValue = controlValue_;
+ }
+
+ /*
+ protected void enableControls(Object value) {
+ Boolean b = getBoolean(value);
+ for (int i = 0; i<disableObjects.length; i++)
+ UIHelper.setEnabled(disableObjects[i],b);
+ }
+ */
+ protected void setToUI(Object value)
+ {
+ controlValue.set(value, control);
+ }
+
+ /**
+ * Try to get from an arbitrary object a boolean value.
+ * Null returns Boolean.FALSE;
+ * A Boolean object returns itself.
+ * An Array returns true if it not empty.
+ * An Empty String returns Boolean.FALSE.
+ * everything else returns a Boolean.TRUE.
+ * @param value
+ * @return
+ */
+ /*protected Boolean getBoolean(Object value) {
+ if (value==null)
+ return Boolean.FALSE;
+ if (value instanceof Boolean)
+ return (Boolean)value;
+ else if (value.getClass().isArray())
+ return ((short[])value).length != 0 ? Boolean.TRUE : Boolean.FALSE;
+ else if (value.equals("")) return Boolean.FALSE;
+ else return Boolean.TRUE;
+ }
+
+ public void disableControls(Object[] controls) {
+ disableObjects = controls;
+ }
+ */
+ protected Object getFromUI()
+ {
+ return controlValue.get(control);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/Task.java b/wizards/com/sun/star/wizards/ui/event/Task.java
new file mode 100644
index 000000000000..16feacd5e1fa
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/Task.java
@@ -0,0 +1,204 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class Task
+{
+
+ private int successfull = 0;
+ private int failed = 0;
+ private int max = 0;
+ private String taskName;
+ private List listeners = new Vector();
+ private String subtaskName;
+
+ public Task(String taskName_, String subtaskName_, int max_)
+ {
+ taskName = taskName_;
+ subtaskName = subtaskName_;
+ max = max_;
+ }
+
+ public void start()
+ {
+ fireTaskStarted();
+ }
+
+ public void fail()
+ {
+ fireTaskFailed();
+ }
+
+ public int getMax()
+ {
+ return max;
+ }
+
+ public void setMax(int max_)
+ {
+ max = max_;
+ fireTaskStatusChanged();
+ }
+
+ public void advance(boolean success_)
+ {
+ if (success_)
+ {
+ successfull++;
+ }
+ else
+ {
+ failed++;
+ }
+ fireTaskStatusChanged();
+ if (failed + successfull == max)
+ {
+ fireTaskFinished();
+ }
+ }
+
+ public void advance(boolean success_, String nextSubtaskName)
+ {
+ advance(success_);
+ setSubtaskName(nextSubtaskName);
+ }
+
+ public int getStatus()
+ {
+ return successfull + failed;
+ }
+
+ public void addTaskListener(TaskListener tl)
+ {
+ listeners.add(tl);
+ }
+
+ public void removeTaskListener(TaskListener tl)
+ {
+ listeners.remove(tl);
+ }
+
+ protected void fireTaskStatusChanged()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_STATUS_CHANGED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskStatusChanged(te);
+ }
+ }
+
+ protected void fireTaskStarted()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_STARTED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskStarted(te);
+ }
+ }
+
+ protected void fireTaskFailed()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_FAILED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskFinished(te);
+ }
+ }
+
+ protected void fireTaskFinished()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_FINISHED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskFinished(te);
+ }
+ }
+
+ protected void fireSubtaskNameChanged()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.SUBTASK_NAME_CHANGED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).subtaskNameChanged(te);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public String getSubtaskName()
+ {
+ return subtaskName;
+ }
+
+ /**
+ * @return
+ */
+ public String getTaskName()
+ {
+ return taskName;
+ }
+
+ /**
+ * @param string
+ */
+ public void setSubtaskName(String string)
+ {
+ subtaskName = string;
+ fireSubtaskNameChanged();
+ }
+
+ /**
+ * @return
+ */
+ public int getFailed()
+ {
+ return failed;
+ }
+
+ /**
+ * @return
+ */
+ public int getSuccessfull()
+ {
+ return successfull;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/TaskEvent.java b/wizards/com/sun/star/wizards/ui/event/TaskEvent.java
new file mode 100644
index 000000000000..1c54cfea2fa6
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/TaskEvent.java
@@ -0,0 +1,65 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.util.EventObject;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class TaskEvent extends EventObject
+{
+
+ public static final int TASK_STARTED = 1;
+ public static final int TASK_FINISHED = 2;
+ public static final int TASK_STATUS_CHANGED = 3;
+ public static final int SUBTASK_NAME_CHANGED = 4;
+ public static final int TASK_FAILED = 5;
+ private int type;
+
+ /**
+ * general constructor-
+ * @param source
+ * @param type_
+ * @param max_
+ * @param success_
+ * @param failed_
+ */
+ public TaskEvent(Task source, int type_)
+ {
+ super(source);
+ type = type_;
+ }
+
+ public Task getTask()
+ {
+ return (Task) getSource();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/TaskListener.java b/wizards/com/sun/star/wizards/ui/event/TaskListener.java
new file mode 100644
index 000000000000..114747c30776
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/TaskListener.java
@@ -0,0 +1,51 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import java.util.EventListener;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface TaskListener extends EventListener
+{
+
+ public void taskStarted(TaskEvent te);
+
+ public void taskFinished(TaskEvent te);
+
+ /**
+ * is called when the status of the task has advanced.
+ * @param te
+ */
+ public void taskStatusChanged(TaskEvent te);
+
+ public void subtaskNameChanged(TaskEvent te);
+}
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.java b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.java
new file mode 100644
index 000000000000..632609d85f05
--- /dev/null
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.java
@@ -0,0 +1,265 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.ui.event;
+
+import com.sun.star.awt.*;
+import com.sun.star.lang.EventObject;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.Helper;
+
+/**
+ * @author rpiterman
+ *
+ * This class suppoprts imple cases where a UI control can
+ * be directly synchronized with a data property.
+ * Such controls are: the different text controls
+ * (synchronizing the "Text" , "Value", "Date", "Time" property),
+ * Checkbox controls, Dropdown listbox controls (synchronizing the
+ * SelectedItems[] property.
+ * For those controls, static convenience methods are offered, to simplify use.
+ */
+public class UnoDataAware extends DataAware
+{
+
+ protected Object unoControl;
+ protected Object unoModel;
+ protected String unoPropName;
+ protected Object[] disableObjects = new Object[0];
+ protected boolean inverse = false;
+
+ protected UnoDataAware(Object dataObject, Value value, Object unoObject_, String unoPropName_)
+ {
+ super(dataObject, value);
+ unoControl = unoObject_;
+ unoModel = getModel(unoControl);
+ unoPropName = unoPropName_;
+ }
+
+ public void setInverse(boolean i)
+ {
+ inverse = i;
+ }
+
+ protected void enableControls(Object value)
+ {
+ Boolean b = getBoolean(value);
+ if (inverse)
+ {
+ b = b.booleanValue() ? Boolean.FALSE : Boolean.TRUE;
+ }
+ for (int i = 0; i < disableObjects.length; i++)
+ {
+ setEnabled(disableObjects[i], b);
+ }
+ }
+
+ protected void setToUI(Object value)
+ {
+ //System.out.println("Settings uno property : "+ Helper.getUnoPropertyValue(this.unoModel,"Name") + "<-" +stringof(value));
+ Helper.setUnoPropertyValue(unoModel, unoPropName, value);
+ }
+
+ private String stringof(Object value)
+ {
+ if (value.getClass().isArray())
+ {
+ StringBuffer sb = new StringBuffer("[");
+ for (int i = 0; i < ((short[]) value).length; i++)
+ {
+ sb.append(((short[]) value)[i]).append(" , ");
+ }
+ sb.append("]");
+ return sb.toString();
+ }
+ else
+ {
+ return value.toString();
+ }
+ }
+
+ /**
+ * Try to get from an arbitrary object a boolean value.
+ * Null returns Boolean.FALSE;
+ * A Boolean object returns itself.
+ * An Array returns true if it not empty.
+ * An Empty String returns Boolean.FALSE.
+ * everything else returns a Boolean.TRUE.
+ * @param value
+ * @return
+ */
+ protected Boolean getBoolean(Object value)
+ {
+ if (value == null)
+ {
+ return Boolean.FALSE;
+ }
+ if (value instanceof Boolean)
+ {
+ return (Boolean) value;
+ }
+ else if (value.getClass().isArray())
+ {
+ return ((short[]) value).length != 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else if (value.equals(""))
+ {
+ return Boolean.FALSE;
+ }
+ else if (value instanceof Number)
+ {
+ return ((Number) value).intValue() == 0 ? Boolean.TRUE : Boolean.FALSE;
+ }
+ else
+ {
+ return Boolean.TRUE;
+ }
+ }
+
+ public void disableControls(Object[] controls)
+ {
+ disableObjects = controls;
+ }
+
+ protected Object getFromUI()
+ {
+ return Helper.getUnoPropertyValue(unoModel, unoPropName);
+ }
+
+ private static UnoDataAware attachTextControl(Object data, String prop, Object unoText, final Listener listener, String unoProperty, boolean field, Object value)
+ {
+ XTextComponent text = (XTextComponent) UnoRuntime.queryInterface(XTextComponent.class, unoText);
+ final UnoDataAware uda = new UnoDataAware(data,
+ field
+ ? DataAwareFields.getFieldValueFor(data, prop, value)
+ : new DataAware.PropertyValue(prop, data),
+ text, unoProperty);
+ text.addTextListener(new XTextListener()
+ {
+
+ public void textChanged(TextEvent te)
+ {
+ uda.updateData();
+ if (listener != null)
+ {
+ listener.eventPerformed(te);
+ }
+ }
+
+ public void disposing(EventObject eo)
+ {
+ }
+ });
+ return uda;
+ }
+
+ public static UnoDataAware attachEditControl(Object data, String prop, Object unoControl, Listener listener, boolean field)
+ {
+ return attachTextControl(data, prop, unoControl, listener, "Text", field, "");
+ }
+
+ public static UnoDataAware attachDateControl(Object data, String prop, Object unoControl, Listener listener, boolean field)
+ {
+ return attachTextControl(data, prop, unoControl, listener, "Date", field, new Integer(0));
+ }
+
+ public static UnoDataAware attachTimeControl(Object data, String prop, Object unoControl, Listener listener, boolean field)
+ {
+ return attachTextControl(data, prop, unoControl, listener, "Time", field, new Integer(0));
+ }
+
+ public static UnoDataAware attachNumericControl(Object data, String prop, Object unoControl, Listener listener, boolean field)
+ {
+ return attachTextControl(data, prop, unoControl, listener, "Value", field, new Double(0));
+ }
+
+ public static UnoDataAware attachCheckBox(Object data, String prop, Object checkBox, final Listener listener, boolean field)
+ {
+ XCheckBox xcheckBox = ((XCheckBox) UnoRuntime.queryInterface(XCheckBox.class, checkBox));
+ final UnoDataAware uda = new UnoDataAware(data,
+ field
+ ? DataAwareFields.getFieldValueFor(data, prop, new Short((short) 0))
+ : new DataAware.PropertyValue(prop, data),
+ checkBox, "State");
+ xcheckBox.addItemListener(itemListener(uda, listener));
+ return uda;
+ }
+
+ static XItemListener itemListener(final DataAware da, final Listener listener)
+ {
+ return new XItemListener()
+ {
+
+ public void itemStateChanged(ItemEvent ie)
+ {
+ da.updateData();
+ if (listener != null)
+ {
+ listener.eventPerformed(ie);
+ }
+ }
+
+ public void disposing(EventObject eo)
+ {
+ }
+ };
+ }
+
+ public static UnoDataAware attachLabel(Object data, String prop, Object label, final Listener listener, boolean field)
+ {
+ return new UnoDataAware(data,
+ field ? DataAwareFields.getFieldValueFor(data, prop, "")
+ : new DataAware.PropertyValue(prop, data),
+ label, "Label");
+ }
+
+ public static UnoDataAware attachListBox(Object data, String prop, Object listBox, final Listener listener, boolean field)
+ {
+ XListBox xListBox = (XListBox) UnoRuntime.queryInterface(XListBox.class, listBox);
+ final UnoDataAware uda = new UnoDataAware(data,
+ field
+ ? DataAwareFields.getFieldValueFor(data, prop, new short[0])
+ : new DataAware.PropertyValue(prop, data),
+ listBox, "SelectedItems");
+ xListBox.addItemListener(itemListener(uda, listener));
+ return uda;
+ }
+
+ public static Object getModel(Object control)
+ {
+ return ((XControl) UnoRuntime.queryInterface(XControl.class, control)).getModel();
+ }
+
+ public static void setEnabled(Object control, boolean enabled)
+ {
+ setEnabled(control, enabled ? Boolean.TRUE : Boolean.FALSE);
+ }
+
+ public static void setEnabled(Object control, Boolean enabled)
+ {
+ Helper.setUnoPropertyValue(getModel(control), "Enabled", enabled);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/AbstractErrorHandler.java b/wizards/com/sun/star/wizards/web/AbstractErrorHandler.java
new file mode 100644
index 000000000000..6a6c5a0c220f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/AbstractErrorHandler.java
@@ -0,0 +1,238 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.SystemDialog;
+
+/**
+ * An abstract implementation of ErrorHandler, which
+ * uses a renderer method geMessageFor(Exception, Object, int, int)
+ * (in this class still abstract...)
+ * to render the errors, and displays
+ * error messeges.
+ */
+public abstract class AbstractErrorHandler implements ErrorHandler
+{
+
+ XMultiServiceFactory xmsf;
+ XWindowPeer peer;
+
+ protected AbstractErrorHandler(XMultiServiceFactory xmsf, XWindowPeer peer_)
+ {
+ this.xmsf = xmsf;
+ peer = peer_;
+ }
+
+ /**
+ * Implementation of ErrorHandler:
+ * shows a message box with the rendered error.
+ * @param arg identifies the error. This object is passed to the render method
+ * which returns the right error message.
+ * @return true/false for continue/abort.
+ */
+ public boolean error(Exception ex, Object arg, int ix, int errorType)
+ {
+ //ex.printStackTrace();
+ switch (errorType)
+ {
+ case ErrorHandler.ERROR_FATAL:
+ return !showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_PROCESS_FATAL:
+ return !showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_NORMAL_ABORT:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_NORMAL_IGNORE:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_QUESTION_CANCEL:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_QUESTION_OK:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_QUESTION_NO:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_QUESTION_YES:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_WARNING:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ case ErrorHandler.ERROR_MESSAGE:
+ return showMessage(getMessageFor(ex, arg, ix, errorType), errorType);
+ }
+ throw new IllegalArgumentException("unknown error type");
+ }
+
+ /**
+ * @deprecated
+ * @param message
+ * @param errorType
+ * @return true if the ok/yes button is clicked, false otherwise.
+ */
+ protected boolean showMessage(String message, int errorType)
+ {
+ return showMessage(xmsf, peer, message, errorType);
+ }
+
+ /**
+ * display a message
+ * @deprecated
+ * @param xmsf
+ * @param message the message to display
+ * @param errorType an int constant from the ErrorHandler interface.
+ * @return
+ */
+ public static boolean showMessage(XMultiServiceFactory xmsf, XWindowPeer peer, String message, int errorType)
+ {
+ String serviceName = getServiceNameFor(errorType);
+ int attribute = getAttributeFor(errorType);
+ int b = SystemDialog.showMessageBox(xmsf, peer, serviceName, attribute, message);
+ return b == getTrueFor(errorType);
+ }
+
+ public static boolean showMessage(XMultiServiceFactory xmsf, XWindowPeer peer,
+ String message,
+ String dialogtype,
+ int buttons,
+ int defaultButton,
+ int returnTrueOn)
+ {
+ int b = SystemDialog.showMessageBox(xmsf, peer, dialogtype, defaultButton + buttons, message);
+ return b == returnTrueOn;
+ }
+
+ /**
+ * normally ok(1) is the value for true.
+ * but a question dialog may use yes. so i use this method
+ * for each error type to get its type of "true" value.
+ * @param errorType
+ * @return
+ */
+ private static int getTrueFor(int errorType)
+ {
+ switch (errorType)
+ {
+ case ErrorHandler.ERROR_FATAL:
+ case ErrorHandler.ERROR_PROCESS_FATAL:
+ case ErrorHandler.ERROR_NORMAL_ABORT:
+ case ErrorHandler.ERROR_NORMAL_IGNORE:
+ case ErrorHandler.ERROR_QUESTION_CANCEL:
+ case ErrorHandler.ERROR_QUESTION_OK:
+
+ return 1;
+
+ case ErrorHandler.ERROR_QUESTION_NO:
+ case ErrorHandler.ERROR_QUESTION_YES:
+
+ return 2;
+
+ case ErrorHandler.ERROR_WARNING:
+ case ErrorHandler.ERROR_MESSAGE:
+
+ return 1;
+ }
+ throw new IllegalArgumentException("unkonown error type");
+ }
+
+ /**
+ * @param errorType
+ * @return the Uno attributes for each error type.
+ */
+ private static int getAttributeFor(int errorType)
+ {
+ switch (errorType)
+ {
+ case ErrorHandler.ERROR_FATAL:
+ return VclWindowPeerAttribute.OK;
+ case ErrorHandler.ERROR_PROCESS_FATAL:
+ return VclWindowPeerAttribute.OK;
+ case ErrorHandler.ERROR_NORMAL_ABORT:
+ return VclWindowPeerAttribute.OK_CANCEL + VclWindowPeerAttribute.DEF_CANCEL;
+ case ErrorHandler.ERROR_NORMAL_IGNORE:
+ return VclWindowPeerAttribute.OK_CANCEL + VclWindowPeerAttribute.DEF_OK;
+ case ErrorHandler.ERROR_QUESTION_CANCEL:
+ return VclWindowPeerAttribute.OK_CANCEL + VclWindowPeerAttribute.DEF_CANCEL;
+ case ErrorHandler.ERROR_QUESTION_OK:
+ return VclWindowPeerAttribute.OK_CANCEL + VclWindowPeerAttribute.DEF_OK;
+ case ErrorHandler.ERROR_QUESTION_NO:
+ return VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO;
+ case ErrorHandler.ERROR_QUESTION_YES:
+ return VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_YES;
+ case ErrorHandler.ERROR_WARNING:
+ return VclWindowPeerAttribute.OK;
+ case ErrorHandler.ERROR_MESSAGE:
+ return VclWindowPeerAttribute.OK;
+ }
+ throw new IllegalArgumentException("unkonown error type");
+ }
+
+ /**
+ * @deprecated
+ * @param errorType
+ * @return the uno service name for each error type
+ */
+ private static String getServiceNameFor(int errorType)
+ {
+ switch (errorType)
+ {
+ case ErrorHandler.ERROR_FATAL:
+ return "errorbox";
+ case ErrorHandler.ERROR_PROCESS_FATAL:
+ return "errorbox";
+ case ErrorHandler.ERROR_NORMAL_ABORT:
+ return "errorbox";
+ case ErrorHandler.ERROR_NORMAL_IGNORE:
+ return "warningbox";
+ case ErrorHandler.ERROR_QUESTION_CANCEL:
+ return "querybox";
+ case ErrorHandler.ERROR_QUESTION_OK:
+ return "querybox";
+ case ErrorHandler.ERROR_QUESTION_NO:
+ return "querybox";
+ case ErrorHandler.ERROR_QUESTION_YES:
+ return "querybox";
+ case ErrorHandler.ERROR_WARNING:
+ return "warningbox";
+ case ErrorHandler.ERROR_MESSAGE:
+ return "infobox";
+ }
+ throw new IllegalArgumentException("unkonown error type");
+ }
+
+ /**
+ * renders the error
+ * @param ex the exception
+ * @param arg a free argument
+ * @param ix a free argument
+ * @param type the error type (from the int constants
+ * in ErrorHandler interface)
+ * @return a Strings which will be displayed in the message box,
+ * and which describes the error, and the needed action from the user.
+ */
+ protected abstract String getMessageFor(Exception ex, Object arg, int ix, int type);
+}
+
+
diff --git a/wizards/com/sun/star/wizards/web/BackgroundsDialog.java b/wizards/com/sun/star/wizards/web/BackgroundsDialog.java
new file mode 100644
index 000000000000..70c40fbc6072
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/BackgroundsDialog.java
@@ -0,0 +1,290 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import javax.swing.DefaultListModel;
+
+import com.sun.star.awt.Size;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.ConfigSet;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.ui.ImageList;
+import com.sun.star.wizards.web.data.CGImage;
+import com.sun.star.wizards.web.data.CGSettings;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class BackgroundsDialog extends ImageListDialog
+{
+
+ private FileAccess fileAccess;
+ private SystemDialog sd;
+ private CGSettings settings;
+
+ /**
+ * @param xmsf
+ */
+ public BackgroundsDialog(
+ XMultiServiceFactory xmsf,
+ ConfigSet set_, WebWizardDialogResources resources) throws Exception
+ {
+
+ super(xmsf, WWHID.HID_BG, new String[]
+ {
+ resources.resBackgroundsDialog,
+ resources.resBackgroundsDialogCaption,
+ resources.resOK,
+ resources.resCancel,
+ resources.resHelp,
+ resources.resDeselect,
+ resources.resOther,
+ resources.resCounter
+ });
+
+ sd = SystemDialog.createOpenDialog(xmsf);
+ sd.addFilter(resources.resImages, "*.jpg;*.jpeg;*.jpe;*.gif", true);
+ sd.addFilter(resources.resAllFiles, "*.*", false);
+
+ settings = (CGSettings) set_.root;
+
+ fileAccess = new FileAccess(xmsf);
+ il.setListModel(new Model(set_));
+ il.setImageSize(new Size(40, 40));
+ il.setRenderer(new BGRenderer(0));
+ build();
+
+
+ }
+
+ /**
+ * trigered when the user clicks the "other" button.
+ * opens a "file open" dialog, adds the selected
+ * image to the list and to the web wizard configuration,
+ * and then jumps to the new image, selecting it in the list.
+ * @see add(String)
+ */
+ public void other()
+ {
+ String filename[] = sd.callOpenDialog(false, settings.cp_DefaultSession.cp_InDirectory);
+ if (filename != null && filename.length > 0 && filename[0] != null)
+ {
+ settings.cp_DefaultSession.cp_InDirectory = FileAccess.getParentDir(filename[0]);
+ int i = add(filename[0]);
+ il.setSelected(i);
+ il.display(i);
+ }
+ }
+
+ /**
+ * adds the given image to the image list (to the model)
+ * and to the web wizard configuration.
+ * @param s
+ * @return
+ */
+ private int add(String s)
+ {
+
+ //first i check the item does not already exists in the list...
+ for (int i = 0; i < il.getListModel().getSize(); i++)
+ {
+ if (il.getListModel().getElementAt(i).equals(s))
+ {
+ return i;
+ }
+ }
+ ((DefaultListModel) il.getListModel()).addElement(s);
+ try
+ {
+ Object configView = Configuration.getConfigurationRoot(xMSF, FileAccess.connectURLs(WebWizardConst.CONFIG_PATH, "BackgroundImages"), true);
+ int i = Configuration.getChildrenNames(configView).length + 1;
+ Object o = Configuration.addConfigNode(configView, "" + i);
+ Configuration.set(s, "Href", o);
+ Configuration.commit(configView);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ return il.getListModel().getSize() - 1;
+
+ }
+
+ /**
+ * an ImageList Imagerenderer implemtation.
+ * The image URL is the object given from the list model.
+ * the image name, got from the "render" method is
+ * the filename portion of the url.
+ * @author rpiterman
+ *
+ */
+ private class BGRenderer implements ImageList.IImageRenderer
+ {
+
+ private int cut;
+
+ public BGRenderer(int cut_)
+ {
+ cut = cut_;
+ }
+
+ public Object[] getImageUrls(Object listItem)
+ {
+ Object[] sRetUrls;
+ if (listItem != null)
+ {
+ sRetUrls = new Object[1];
+ sRetUrls[0] = listItem;
+ return sRetUrls;
+ }
+ return null;
+ }
+
+ public String render(Object object)
+ {
+ return object == null ? "" : FileAccess.getPathFilename(fileAccess.getPath((String) object, null));
+ }
+ }
+
+ /**
+ * This is a list model for the image list of the
+ * backgrounds dialog.
+ * It takes the Backgrounds config set as an argument,
+ * and "parses" it to a list of files:
+ * It goes through each image in the set, and checks it:
+ * if it is a directory it lists all image files in this directory.
+ * if it is a file, it adds the file to the list.
+ * @author rpiterman
+ */
+ private class Model extends DefaultListModel
+ {
+
+ /**
+ * constructor. </br>
+ * see class description for a description of
+ * the handling of the given model
+ * @param model the configuration set of the background images.
+ */
+ public Model(ConfigSet model)
+ {
+ try
+ {
+ for (int i = 0; i < model.getSize(); i++)
+ {
+ CGImage image = (CGImage) model.getElementAt(i);
+ String path = sd.xStringSubstitution.substituteVariables(image.cp_Href, false);
+ if (fileAccess.exists(path, false))
+ {
+ addDir(path);
+ }
+ else
+ {
+ remove((String) model.getKey(image));
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * when instanciating the model, it checks if each image
+ * exists. If it doesnot, it will be removed from
+ * the configuration.
+ * This is what this method does...
+ * @param imageName
+ */
+ private void remove(String imageName)
+ {
+ try
+ {
+ Object conf = Configuration.getConfigurationRoot(xMSF, WebWizardConst.CONFIG_PATH + "/BackgroundImages", true);
+ Configuration.removeNode(conf, imageName);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * if the given url is a directory
+ * adds the images in the given directory,
+ * otherwise (if it is a file) adds the file to the list.
+ * @param url
+ */
+ private void addDir(String url)
+ {
+ if (fileAccess.isDirectory(url))
+ {
+ add(fileAccess.listFiles(url, false));
+ }
+ else
+ {
+ add(url);
+ }
+ }
+
+ /**
+ * adds the given filenames (urls) to
+ * the list
+ * @param filenames
+ */
+ private void add(String[] filenames)
+ {
+ for (int i = 0; i < filenames.length; i++)
+ {
+ add(filenames[i]);
+ }
+ }
+
+ /**
+ * adds the given image url to the list.
+ * if and only if it ends with jpg, jpeg or gif
+ * (case insensitive)
+ * @param filename image url.
+ */
+ private void add(String filename)
+ {
+ String lcase = filename.toLowerCase();
+ if (lcase.endsWith("jpg") ||
+ lcase.endsWith("jpeg") ||
+ lcase.endsWith("gif"))
+ {
+ Model.this.addElement(filename);
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/CallWizard.java b/wizards/com/sun/star/wizards/web/CallWizard.java
new file mode 100644
index 000000000000..4fab3ea43bf9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/CallWizard.java
@@ -0,0 +1,295 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.beans.XPropertyAccess;
+import com.sun.star.comp.loader.FactoryHelper;
+import com.sun.star.lang.XInitialization;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.lang.XServiceInfo;
+import com.sun.star.lang.XSingleServiceFactory;
+import com.sun.star.lang.XTypeProvider;
+import com.sun.star.registry.XRegistryKey;
+import com.sun.star.task.XJob;
+import com.sun.star.task.XJobExecutor;
+import com.sun.star.uno.Type;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.Resource;
+
+/**
+ * This class capsulates the class, that implements the minimal component, a factory for
+ * creating the service (<CODE>__getServiceFactory</CODE>).
+ *
+ * @author rpiterman
+ * @version $Revision: 1.10.52.1 $
+ */
+public class CallWizard
+{
+
+ /**
+ * Gives a factory for creating the service. This method is called by the
+ * <code>JavaLoader</code>
+ *
+ * <p></p>
+ *
+ * @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 tree
+ * structures) of a single registry key accessible.
+ *
+ * @return Returns a <code>XSingleServiceFactory</code> for creating the component.
+ *
+ * @see com.sun.star.comp.loader.JavaLoader#
+ */
+ public static XSingleServiceFactory __getServiceFactory(String stringImplementationName, XMultiServiceFactory xMSF, XRegistryKey xregistrykey)
+ {
+ XSingleServiceFactory xsingleservicefactory = null;
+
+ if (stringImplementationName.equals(WizardImplementation.class.getName()))
+ {
+ xsingleservicefactory = FactoryHelper.getServiceFactory(WizardImplementation.class, WizardImplementation.__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 WizardImplementation implements XInitialization, XTypeProvider, XServiceInfo, XJobExecutor
+ {
+
+ /**
+ * The constructor of the inner class has a XMultiServiceFactory parameter.
+ *
+ * @param xmultiservicefactoryInitialization A special service factory could be
+ * introduced while initializing.
+ */
+ public WizardImplementation(XMultiServiceFactory xmultiservicefactoryInitialization)
+ {
+ xmultiservicefactory = xmultiservicefactoryInitialization;
+
+ if (xmultiservicefactory != null)
+ {
+ }
+ }
+ private static WebWizard webWizard = null;
+
+ /**
+ * Execute Wizard
+ *
+ * @param str only valid parameter is 'start' at the moment.
+ */
+ public void trigger(String str)
+ {
+ if (str.equalsIgnoreCase("start"))
+ {
+ if (webWizard == null)
+ {
+ WebWizard ww = null;
+ try
+ {
+ webWizard = new WebWizard(xmultiservicefactory);
+ ww = webWizard;
+ webWizard.show();
+ webWizard = null;
+ }
+ catch (Exception ex)
+ {
+ webWizard = null;
+ ex.printStackTrace();
+ Resource.showCommonResourceError(xmultiservicefactory);
+ }
+ finally
+ {
+ webWizard = null;
+ try
+ {
+ if (ww != null)
+ {
+ ww.cleanup();
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+ }
+ else
+ {
+ webWizard.activate();
+ }
+
+
+ }
+ } //*******************************************
+ /**
+ * The service name, that must be used to get an instance of this service.
+ */
+ private static final String __serviceName = "com.sun.star.wizards.web.CallWizard";
+ /**
+ * The service manager, that gives access to all registered services.
+ */
+ private 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
+ {
+ //wizardStarted = false;
+ }
+
+ /**
+ * 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[1];
+ stringSupportedServiceNames[0] = __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);
+ }
+
+ /**
+ * This method returns an array of bytes, that can be used to unambiguously
+ * distinguish between two sets of types, e.g. to realise hashing functionality
+ * when the object is introspected. Two objects that return the same ID also
+ * have to return the same set of types in getTypes(). If an unique
+ * implementation Id cannot be provided this method has to return an empty
+ * sequence. Important: If the object aggregates other objects the ID has to be
+ * unique for the whole combination of objects.
+ *
+ * @return Array of bytes, in order to distinguish between two sets.
+ */
+ public byte[] getImplementationId()
+ {
+ byte[] byteReturn =
+ {
+ };
+
+ try
+ {
+ byteReturn = ("" + this.hashCode()).getBytes();
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (byteReturn);
+ }
+
+ /**
+ * Return the class name of the component.
+ *
+ * @return Class name of the component.
+ */
+ public java.lang.String getImplementationName()
+ {
+ return (WizardImplementation.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.
+ */
+ public com.sun.star.uno.Type[] getTypes()
+ {
+ Type[] typeReturn =
+ {
+ };
+
+ try
+ {
+ typeReturn = new Type[]
+ {
+ new Type(XPropertyAccess.class), new Type(XJob.class), new Type(XJobExecutor.class), new Type(XTypeProvider.class), new Type(XServiceInfo.class), new Type(XInitialization.class)
+ };
+ }
+ catch (Exception exception)
+ {
+ System.err.println(exception);
+ }
+
+ return (typeReturn);
+ }
+ }
+
+ public static void main(String[] s)
+ {
+
+ String ConnectStr =
+ "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ try
+ {
+ XMultiServiceFactory xmsf = Desktop.connect(ConnectStr);
+ CallWizard.WizardImplementation ww = new CallWizard.WizardImplementation(xmsf);
+ ww.trigger("start");
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/ErrorHandler.java b/wizards/com/sun/star/wizards/web/ErrorHandler.java
new file mode 100644
index 000000000000..f330532a3058
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ErrorHandler.java
@@ -0,0 +1,117 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface ErrorHandler
+{
+
+ public static final String MESSAGE_INFO = "infobox";
+ public static final String MESSAGE_QUESTION = "querybox";
+ public static final String MESSAGE_ERROR = "errorbox";
+ public static final String MESSAGE_WARNING = "warningbox";
+ public static int BUTTONS_OK = VclWindowPeerAttribute.OK;
+ public static int BUTTONS_OK_CANCEL = VclWindowPeerAttribute.OK_CANCEL;
+ public static int BUTTONS_YES_NO = VclWindowPeerAttribute.YES_NO;
+ public static int RESULT_CANCEL = 0;
+ public static int RESULT_OK = 1;
+ public static int RESULT_YES = 2;
+ public static int DEF_OK = VclWindowPeerAttribute.DEF_OK;
+ public static int DEF_CANCEL = VclWindowPeerAttribute.DEF_CANCEL;
+ public static int DEF_YES = VclWindowPeerAttribute.DEF_YES;
+ public static int DEF_NO = VclWindowPeerAttribute.DEF_NO;
+ /**
+ * Error type for fatal errors which should abort application
+ * execution. Should actually never be used :-)
+ */
+ public static final int ERROR_FATAL = 0;
+ /**
+ * An Error type for errors which should stop the current process.
+ */
+ public static final int ERROR_PROCESS_FATAL = 1;
+ /**
+ * An Error type for errors to which the user can choose, whether
+ * to continue or to abort the current process.
+ * default is abort.
+ */
+ public static final int ERROR_NORMAL_ABORT = 2;
+ /**
+ * An Error type for errors to which the user can choose, whether
+ * to continue or to abort the current process.
+ * default is continue.
+ */
+ public static final int ERROR_NORMAL_IGNORE = 3;
+ /**
+ * An error type for warnings which requires user interaction.
+ * (a question :-) )
+ * Default is abort (cancel).
+ */
+ public static final int ERROR_QUESTION_CANCEL = 4;
+ /**
+ * An error type for warnings which requires user interaction
+ * (a question :-) )
+ * Default is to continue (ok).
+ */
+ public static final int ERROR_QUESTION_OK = 5;
+ /**
+ * An error type for warnings which requires user interaction.
+ * (a question :-) )
+ * Default is abort (No).
+ */
+ public static final int ERROR_QUESTION_NO = 6;
+ /**
+ * An error type for warnings which requires user interaction
+ * (a question :-) )
+ * Default is to continue (Yes).
+ */
+ public static final int ERROR_QUESTION_YES = 7;
+ /**
+ * An error type which is just a warning...
+ */
+ public static final int ERROR_WARNING = 8;
+ /**
+ * An error type which just tells the user something
+ * ( like "you look tired! you should take a bath! and so on)
+ */
+ public static final int ERROR_MESSAGE = 9;
+
+ /**
+ * @param ex the exception that accured
+ * @param arg an object as help for recognizing the exception
+ * @param ix an integer which helps for detailed recognizing of the exception
+ * @param errorType one of the int constants defined by this Interface
+ * @return true if the execution should continue, false if it should stop.
+ */
+ public boolean error(Exception ex, Object arg, int ix, int errorType);
+}
diff --git a/wizards/com/sun/star/wizards/web/ExtensionVerifier.java b/wizards/com/sun/star/wizards/web/ExtensionVerifier.java
new file mode 100644
index 000000000000..8bc036131b70
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ExtensionVerifier.java
@@ -0,0 +1,63 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.wizards.common.UCB;
+
+/**
+ * @author rpiterman
+ * Verifies all String that do not end with
+ * the given extension.
+ * This is used to exclude from a copy all the
+ * xsl files, so I copy from a layout directory
+ * all the files that do *not* end with xsl.
+ *
+ */
+public class ExtensionVerifier implements UCB.Verifier
+{
+
+ private String extension;
+
+ public ExtensionVerifier(String extension_)
+ {
+ extension = "." + extension_;
+ }
+
+ /**
+ * @return true if the given object is
+ * a String which does not end with the
+ * given extension.
+ */
+ public boolean verify(Object object)
+ {
+ if (object instanceof String)
+ {
+ return !((String) object).endsWith(extension);
+ }
+ return false;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/FTPDialog.java b/wizards/com/sun/star/wizards/web/FTPDialog.java
new file mode 100644
index 000000000000..ca6f70add7b6
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/FTPDialog.java
@@ -0,0 +1,752 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import java.util.List;
+import java.util.Vector;
+
+import com.sun.star.awt.PushButtonType;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.ucb.AuthenticationRequest;
+import com.sun.star.ucb.InteractiveAugmentedIOException;
+import com.sun.star.ucb.InteractiveNetworkConnectException;
+import com.sun.star.ucb.InteractiveNetworkResolveNameException;
+import com.sun.star.ucb.OpenCommandArgument2;
+import com.sun.star.ucb.OpenMode;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.common.UCB;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.UnoDialog2;
+import com.sun.star.wizards.ui.event.DataAware;
+import com.sun.star.wizards.ui.event.UnoDataAware;
+import com.sun.star.wizards.web.data.CGPublish;
+import com.sun.star.wizards.web.data.CGSettings;
+import com.sun.star.wizards.common.HelpIds;
+
+/**
+ * This is the FTP Dialog. <br/>
+ * The Dialog enables the user:
+ * (*) entering FTP server and user information.
+ * (*) testing the connection.
+ * (*) choosing a directory on the server.
+ * If a connection was established succesfully, the user may
+ * press OK, which will change
+ * the CGPublish object propertiers according the user's input.
+ * If no connection was established. the OK and Choose-Dir button are disabled.
+ * See the method "disconnect()" which disables them.
+ *
+ * I use here the DataAware concept to automatically update
+ * the members ip, username, and password (via the methods setXXX(...))
+ * for details see the ui.events.DataAware classes. <br/>
+ */
+public class FTPDialog extends UnoDialog2 implements UIConsts, WWHID
+{
+
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display. "unknown" is the status when the user first
+ * opens the dialog, or changes the servername/username/password.
+ */
+ private final static int STATUS_UNKONWN = 0;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display. (connection established)
+ */
+ private final static int STATUS_OK = 1;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display.
+ */
+ private final static int STATUS_USER_PWD_WRONG = 2;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display.
+ */
+ private final static int STATUS_SERVER_NOT_FOUND = 3;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display.
+ */
+ private final static int STATUS_NO_RIGHTS = 4;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display.
+ */
+ private final static int STATUS_HOST_UNREACHABLE = 5;
+ /**
+ * A Constant used for the setLabel(int) method to change the
+ * status-display.
+ */
+ private final static int STATUS_CONNECTING = 6;
+ /**
+ * The icon url for error
+ */
+ private final static String ICON_ERROR = "ftperror.gif";
+ /**
+ * The icon url for ok (connection ok)
+ */
+ private final static String ICON_OK = "ftpconnected.gif";
+ /**
+ * The icon url for unknown - this is the status when
+ * the user first opens the dialog
+ */
+ private final static String ICON_UNKNOWN = "ftpunknown.gif";
+ /**
+ * The icon url for an icon representing the "connecting" state.
+ */
+ private final static String ICON_CONNECTING = "ftpconnecting.gif"; //GUI Components as Class members.
+ //Fixed Line
+ private XControl ln1;
+ private XFixedText lblFTPAddress;
+ private XTextComponent txtHost;
+ private XFixedText lblUsername;
+ private XTextComponent txtUsername;
+ private XFixedText lblPassword;
+ private XTextComponent txtPassword;
+ //Fixed Line
+ private XControl ln2;
+ private XButton btnTestConnection;
+ private XControl imgStatus;
+ private XFixedText lblStatus;
+ //Fixed Line
+ private XControl ln3;
+ private XTextComponent txtDir;
+ private XButton btnDir;
+ private XButton btnOK;
+ private XButton btnCancel;
+ private XButton btnHelp;
+ //Font Descriptors as Class members.
+
+ //Resources Object
+ private FTPDialogResources resources;
+ private List dataAware = new Vector();
+ public String username = "";
+ public String password = "";
+ /**
+ * The ftp host name
+ */
+ public String host = "";
+ /**
+ * The ftp directory.
+ */
+ private String dir = "";
+ /**
+ * the ftp publish object which contains the
+ * data for this dialog.
+ */
+ private CGPublish publish;
+ private UCB ucb;
+ /**
+ * used for the status images url.
+ */
+ private String imagesDirectory;
+
+ /**
+ * constructor.
+ * constructs the UI.
+ * @param xmsf
+ * @param p the publishert object that contains the data
+ * for this dialog
+ * @throws Exception
+ */
+ public FTPDialog(XMultiServiceFactory xmsf, CGPublish p) throws Exception
+ {
+ super(xmsf);
+ publish = p;
+
+
+ imagesDirectory = FileAccess.connectURLs(((CGSettings) (publish.root)).soTemplateDir, "../wizard/bitmap/");
+
+ //Load Resources
+ resources = new FTPDialogResources(xmsf);
+ ucb = new UCB(xmsf);
+
+ //set dialog properties...
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "HelpURL", "Moveable", "Name", "PositionX", "PositionY", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(160), HelpIds.getHelpIdString(HID_FTP), Boolean.TRUE, "FTPDialog", new Integer(167), new Integer(82), resources.resFTPDialog_title, new Integer(222)
+ });
+
+ //add controls to dialog
+ build();
+ //make the hostname, username and password textfield data-aware.
+ configure();
+ //make sure we display a disconnected status.
+ disconnect();
+ }
+
+ /**
+ * Add controls to dialog.
+ */
+ public void build()
+ {
+ final String[] PROPNAMES_LABEL = new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "TabIndex", "Width"
+ };
+ final String[] PROPNAMES_BUTTON = new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "TabIndex", "Width"
+ };
+ final String[] PROPNAMES_BUTTON2 = new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "PushButtonType", "TabIndex", "Width"
+ };
+
+ ln1 = insertFixedLine("ln1",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.resln1_value, "ln1", INTEGERS[6], INTEGERS[6], new Short((short) 0), new Integer(210)
+ });
+ lblFTPAddress = insertLabel("lblFTPAddress",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblFTPAddress_value, "lblFTPAddress", INTEGER_12, new Integer(20), new Short((short) 1), new Integer(95)
+ });
+ txtHost = insertTextField("txtHost", "disconnect",
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID_FTP_SERVER), "txtIP", new Integer(110), new Integer(18), new Short((short) 2), new Integer(106)
+ });
+ lblUsername = insertLabel("lblUsername",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblUsername_value, "lblUsername", INTEGER_12, new Integer(36), new Short((short) 3), new Integer(85)
+ });
+ txtUsername = insertTextField("txtUsername", "disconnect",
+ new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID_FTP_USERNAME), "txtUsername", new Integer(110), new Integer(34), new Short((short) 4), new Integer(106)
+ });
+ lblPassword = insertLabel("lblPassword",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblPassword_value, "lblPassword", INTEGER_12, new Integer(52), new Short((short) 5), new Integer(85)
+ });
+ txtPassword = insertTextField("txtPassword", "disconnect",
+ new String[]
+ {
+ "EchoChar", "Height", "HelpURL", "Name", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 42), INTEGER_12, HelpIds.getHelpIdString(HID_FTP_PASS), "txtPassword", new Integer(110), new Integer(50), new Short((short) 6), new Integer(106)
+ });
+ ln2 = insertFixedLine("ln2",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.resln2_value, "ln2", INTEGERS[6], new Integer(68), new Short((short) 7), new Integer(210)
+ });
+ btnTestConnection = insertButton("btnConnect", "connect",
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID_FTP_TEST), resources.resbtnConnect_value, "btnConnect", INTEGER_12, new Integer(80), new Short((short) 8), INTEGER_50
+ });
+
+ imgStatus = insertImage("imgStatus",
+ new String[]
+ {
+ "Border", "Height", "PositionX", "PositionY", "ScaleImage", "Tabstop", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 0), INTEGER_14, new Integer(68), new Integer(80), Boolean.FALSE, Boolean.FALSE, INTEGER_14
+ });
+
+ lblStatus = insertLabel("lblStatus",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.resFTPDisconnected, "lblStatus", new Integer(86), new Integer(82), new Short((short) 9), new Integer(99)
+ });
+
+ ln3 = insertFixedLine("ln3",
+ PROPNAMES_LABEL,
+ new Object[]
+ {
+ INTEGERS[8], resources.resln3_value, "ln3", INTEGERS[6], new Integer(100), new Short((short) 10), new Integer(210)
+ });
+
+ txtDir = insertTextField("txtDir",
+ null, new String[]
+ {
+ "Enabled", "Height", "HelpURL", "Name", "PositionX", "PositionY", "TabIndex", "Text", "Width"
+ },
+ new Object[]
+ {
+ new Boolean(false), INTEGER_12, HelpIds.getHelpIdString(HID_FTP_TXT_PATH), "txtDir", INTEGER_12, new Integer(113), new Short((short) 11), resources.restxtDir_value, new Integer(184)
+ });
+ btnDir = insertButton("btnDir", "chooseDirectory",
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID_FTP_BTN_PATH), resources.resbtnDir_value, "btnDir", new Integer(199), new Integer(112), new Short((short) 12), INTEGER_16
+ });
+
+ btnOK = insertButton("btnOK", null,
+ PROPNAMES_BUTTON2,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID_FTP_OK), resources.resbtnOK_value, "btnOK", new Integer(165), new Integer(142), new Short((short) PushButtonType.OK_value), new Short((short) 13), INTEGER_50
+ });
+
+ btnCancel = insertButton("btnCancel",
+ null, PROPNAMES_BUTTON2,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID_FTP_CANCEL), resources.resbtnCancel_value, "btnCancel", new Integer(113), new Integer(142), new Short((short) PushButtonType.CANCEL_value), new Short((short) 14), INTEGER_50
+ });
+
+ btnHelp = insertButton("btnHelp", null,
+ PROPNAMES_BUTTON2,
+ new Object[]
+ {
+ INTEGER_14, "", resources.resbtnHelp_value, "btnHelp", new Integer(57), new Integer(142), new Short((short) PushButtonType.HELP_value), new Short((short) 15), INTEGER_50
+ });
+
+ }
+
+ /**
+ * Make hostname, username and password text fields data aware.
+ */
+ private void configure()
+ {
+ dataAware.add(UnoDataAware.attachEditControl(this, "host", txtHost, null, true));
+ dataAware.add(UnoDataAware.attachEditControl(this, "username", txtUsername, null, true));
+ dataAware.add(UnoDataAware.attachEditControl(this, "password", txtPassword, null, true));
+ }
+
+ /**
+ * Shows the dialog.
+ * If the user clicks ok, changes the given CGPublish properties to the
+ * user input.
+ * @param parent a dialog to center this dialog to.
+ * @return 0 for cancel, 1 for ok.
+ * @throws Exception - well, if something goes wrong...
+ */
+ public short execute(UnoDialog parent) throws Exception
+ {
+ host = extractHost(publish.cp_URL);
+ username = publish.cp_Username == null ? "" : publish.cp_Username;
+ password = publish.password == null ? "" : publish.password;
+ dir = extractDir(publish.cp_URL);
+ setLabel(STATUS_UNKONWN);
+
+ enableTestButton();
+ updateUI();
+ short result = executeDialog(parent);
+ //change the CGPublish properties
+ if (result == 1)
+ {
+ publish.cp_URL = "ftp://" + host() + getDir();
+ publish.cp_Username = username;
+ publish.password = password;
+ }
+
+ return result;
+ }
+
+ /**
+ * updates the hostname, username, password and
+ * directory text fields.
+ * is called uppon initialization.
+ */
+ private void updateUI()
+ {
+ DataAware.updateUI(dataAware);
+ setDir(dir);
+ }
+
+ /**
+ * extract the hostname out of the url used by the
+ * publisher. This url does not include the username:password string.
+ * @param ftpUrl
+ * @return
+ */
+ private String extractHost(String ftpUrl)
+ {
+ if (ftpUrl == null || ftpUrl.length() < 6)
+ {
+ return "";
+ }
+ String url = ftpUrl.substring(6);
+ int i = url.indexOf("/");
+ if (i == -1)
+ {
+ return url;
+ }
+ else
+ {
+ return url.substring(0, i);
+ }
+ }
+
+ /**
+ * used to get data from the CGPublish object.
+ * @param ftpUrl
+ * @return the directory portion of the ftp-url
+ */
+ private String extractDir(String ftpUrl)
+ {
+ if (ftpUrl == null || ftpUrl.length() < 6)
+ {
+ return "/";
+ }
+ String url = ftpUrl.substring(6);
+ int i = url.indexOf("/");
+ if (i == -1)
+ {
+ return "/";
+ }
+ else
+ {
+ return url.substring(i);
+ }
+ }
+
+ /**
+ * enables/disables the "test" button
+ * according to the status of the hostname, username, password text fields.
+ * If one of these fields is empty, the button is disabled.
+ */
+ private void enableTestButton()
+ {
+ setEnabled(btnTestConnection, !(isEmpty(host) || isEmpty(username) || isEmpty(password)));
+
+ }
+
+ /**
+ * @param s
+ * @return true if the string is null or "".
+ */
+ private final boolean isEmpty(String s)
+ {
+ return (s == null) || (s.equals(""));
+ }
+
+ /**
+ * @return the ftp url with username and password,
+ * but without the directory portion.
+ */
+ public String getAcountUrl()
+ {
+ return "ftp://" + username + ":" + password + "@" + host();
+ }
+
+ /**
+ * return the host name without the "ftp://"
+ * @return
+ */
+ private String host()
+ {
+ return host(host);
+ }
+
+ private static String host(String s)
+ {
+ return (s.startsWith("ftp://") ? s.substring(6) : s);
+ }
+
+ /**
+ * @return the full ftp url including username, password and directory portion.
+ */
+ private String getFullUrl()
+ {
+ return getAcountUrl() + dir;
+ }
+
+ /**
+ * First I try to connect to the full url, including directory.
+ * If an InteractiveAugmentedIOException accures, I try again,
+ * this time without the dir spec. If this works, I change the dir
+ * to "/", if not I say to the user its his problem...
+ *
+ */
+ public void connect()
+ {
+ setEnabled(btnTestConnection, false);
+ setLabel(STATUS_CONNECTING);
+ boolean success = false;
+ try
+ {
+ connect(getFullUrl());
+ success = true;
+ }
+ catch (InteractiveAugmentedIOException iaioex)
+ {
+ try
+ {
+ connect(getAcountUrl());
+ setDir("/");
+ success = true;
+ }
+ catch (Exception ex)
+ {
+ setLabel(STATUS_NO_RIGHTS);
+ }
+ }
+ catch (InteractiveNetworkResolveNameException inrne)
+ {
+ setLabel(STATUS_SERVER_NOT_FOUND);
+ }
+ catch (AuthenticationRequest ar)
+ {
+ setLabel(STATUS_USER_PWD_WRONG);
+ }
+ catch (InteractiveNetworkConnectException incx)
+ {
+ setLabel(STATUS_HOST_UNREACHABLE);
+ }
+ catch (Exception ex)
+ {
+ setLabel(-1);
+ ex.printStackTrace();
+ }
+
+
+ if (success)
+ {
+ setLabel(STATUS_OK);
+ setEnabled(btnDir, true);
+ setEnabled(btnOK, true);
+ }
+
+ setEnabled(btnTestConnection, true);
+
+ }
+
+ /**
+ * To try the conenction I do some actions that
+ * seem logical to me: <br/>
+ * I get a ucb content.
+ * I list the files in this content.
+ * I call the ucb "open" command.
+ * I get the "Title" property of this content.
+ * @param acountUrl
+ * @throws Exception
+ */
+ private void connect(String acountUrl) throws Exception
+ {
+ Object content = ucb.getContent(acountUrl);
+
+ //list files in the content.
+ List l = ucb.listFiles(acountUrl, null);
+
+ //open the content
+ OpenCommandArgument2 aArg = new OpenCommandArgument2();
+ aArg.Mode = OpenMode.FOLDERS; // FOLDER, DOCUMENTS -> simple filter
+ aArg.Priority = 32768; // Ignored by most implementations
+
+ ucb.executeCommand(content, "open", aArg);
+
+ //get the title property of the content.
+ Object obj = ucb.getContentProperty(content, "Title", String.class);
+
+ }
+
+ /**
+ * changes the ftp subdirectory, in both
+ * the UI and the data.
+ * @param s the directory.
+ */
+ public void setDir(String s)
+ {
+ dir = s;
+ Helper.setUnoPropertyValue(getModel(txtDir), "Text", dir);
+ }
+
+ /**
+ * @return the ftp subdirecrtory.
+ */
+ public String getDir()
+ {
+ return dir;
+ }
+
+ /**
+ * changes the status label to disconnected status, and
+ * disables the ok and choose-dir buttons.
+ * This method is called also when the hostname, username
+ * and passwordtext fields change.
+ */
+ public void disconnect()
+ {
+ enableTestButton();
+ setEnabled(btnOK, false);
+ setEnabled(btnDir, false);
+ setLabel(STATUS_UNKONWN);
+ }
+
+ /**
+ * used for debuging.
+ * @param args
+ */
+ public static void main(String args[])
+ {
+ String ConnectStr = "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ try
+ {
+ XMultiServiceFactory xLocMSF = Desktop.connect(ConnectStr);
+ CGPublish p = new CGPublish();
+ p.cp_URL = "ftp://tv-1/Folder";
+ p.cp_Username = "ronftp";
+ p.password = "ronftp";
+
+ FTPDialog dialog = new FTPDialog(xLocMSF, p);
+ dialog.execute(null);
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace();
+ }
+ }
+
+ /**
+ * changes the status label and icon, according to the
+ * given status
+ * @param status one opf the private status-constants.
+ * if this param is not one of them, an "unknown error" status is displayed.
+ */
+ private void setLabel(int status)
+ {
+ switch (status)
+ {
+ //not connected yet
+ case STATUS_UNKONWN:
+ setLabel(resources.resFTPDisconnected, ICON_UNKNOWN);
+ break;
+ //connected!
+ case STATUS_OK:
+ setLabel(resources.resFTPConnected, ICON_OK);
+ break;
+ case STATUS_USER_PWD_WRONG:
+ setLabel(resources.resFTPUserPwdWrong, ICON_ERROR);
+ break;
+ //problem resolving server name
+ case STATUS_SERVER_NOT_FOUND:
+ setLabel(resources.resFTPServerNotFound, ICON_ERROR);
+ break;
+ //rights problem
+ case STATUS_NO_RIGHTS:
+ setLabel(resources.resFTPRights, ICON_ERROR);
+ break;
+ //host unreachable (firewall?)
+ case STATUS_HOST_UNREACHABLE:
+ setLabel(resources.resFTPHostUnreachable, ICON_ERROR);
+ break;
+ case STATUS_CONNECTING:
+ setLabel(resources.resConnecting, ICON_CONNECTING);
+ break;
+ default:
+ setLabel(resources.resFTPUnknownError, ICON_ERROR);
+ }
+ }
+
+ /**
+ * changes the text of the status label and
+ * (TODO) the status image.
+ * @param label
+ * @param color
+ */
+ private void setLabel(String label, String image)
+ {
+ Helper.setUnoPropertyValue(getModel(lblStatus), "Label", label);
+ Helper.setUnoPropertyValue(getModel(imgStatus), "ImageURL", imageUrl(image));
+ }
+
+ private String imageUrl(String s)
+ {
+ String t = imagesDirectory + s;
+ //System.out.println(t);
+ return t;
+
+ }
+
+ /**
+ * called when the user clicks
+ * the choose-dir button. ("...")
+ * Opens the pickFolder dialog.
+ * checks if the returned folder is an ftp folder.
+ * sets the textbox and the data to the new selected dir.
+ */
+ public void chooseDirectory()
+ {
+ SystemDialog sd = SystemDialog.createOfficeFolderDialog(xMSF);
+ String newUrl = sd.callFolderDialog(resources.resFTPDirectory, "", getFullUrl());
+ if (newUrl != null)
+ {
+ /* if the user chose a local directory,
+ * sI do not accept it.
+ */
+ if (newUrl.startsWith("ftp://"))
+ {
+ setDir(extractDir(newUrl));
+ }
+ else
+ {
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), resources.resIllegalFolder, ErrorHandler.ERROR_PROCESS_FATAL);
+ }
+ }
+ }
+
+ /**
+ * practical to have such a method...
+ * @param p the publisher obejct that contains the ftp connection info.
+ * @return the full ftp url with username password and everything one needs.
+ */
+ public static final String getFullURL(CGPublish p)
+ {
+ return "ftp://" + p.cp_Username + ":" + p.password + "@" + host(p.cp_URL);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/FTPDialogResources.java b/wizards/com/sun/star/wizards/web/FTPDialogResources.java
new file mode 100644
index 000000000000..b9a5fe7548d6
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/FTPDialogResources.java
@@ -0,0 +1,98 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Resource;
+
+public class FTPDialogResources extends Resource
+{
+
+ final static String UNIT_NAME = "dbwizres";
+ final static String MODULE_NAME = "dbw";
+ final static int RID_FTPDIALOG_START = 4200;
+ final static int RID_COMMON_START = 500;
+ String resFTPDialog_title;
+ String reslblUsername_value;
+ String reslblPassword_value;
+ String resbtnConnect_value;
+ String resbtnOK_value;
+ String resbtnHelp_value;
+ String resbtnCancel_value;
+ String resln1_value;
+ String reslblFTPAddress_value;
+ String resln2_value;
+ String resln3_value;
+ String restxtDir_value;
+ String resbtnDir_value;
+ String resFTPDisconnected;
+ String resFTPConnected;
+ String resFTPUserPwdWrong;
+ String resFTPServerNotFound;
+ String resFTPRights;
+ String resFTPHostUnreachable;
+ String resFTPUnknownError;
+ String resFTPDirectory;
+ String resIllegalFolder;
+ String resConnecting;
+
+ public FTPDialogResources(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, UNIT_NAME, MODULE_NAME);
+
+ /**
+ * Delete the String, uncomment the getResText method
+ *
+ */
+ resFTPDialog_title = getResText(RID_FTPDIALOG_START + 0);
+ reslblUsername_value = getResText(RID_FTPDIALOG_START + 1);
+ reslblPassword_value = getResText(RID_FTPDIALOG_START + 2);
+ resbtnConnect_value = getResText(RID_FTPDIALOG_START + 3);
+ resln1_value = getResText(RID_FTPDIALOG_START + 4);
+ reslblFTPAddress_value = getResText(RID_FTPDIALOG_START + 5);
+ resln2_value = getResText(RID_FTPDIALOG_START + 6);
+ resln3_value = getResText(RID_FTPDIALOG_START + 7);
+ resbtnDir_value = getResText(RID_FTPDIALOG_START + 8);
+ resFTPDisconnected = getResText(RID_FTPDIALOG_START + 9);
+ resFTPConnected = getResText(RID_FTPDIALOG_START + 10);
+ resFTPUserPwdWrong = getResText(RID_FTPDIALOG_START + 11);
+ resFTPServerNotFound = getResText(RID_FTPDIALOG_START + 12);
+ resFTPRights = getResText(RID_FTPDIALOG_START + 13);
+ resFTPHostUnreachable = getResText(RID_FTPDIALOG_START + 14);
+ resFTPUnknownError = getResText(RID_FTPDIALOG_START + 15);
+ resFTPDirectory = getResText(RID_FTPDIALOG_START + 16);
+ resIllegalFolder = getResText(RID_FTPDIALOG_START + 17);
+ resConnecting = getResText(RID_FTPDIALOG_START + 18);
+
+ resbtnCancel_value = getResText(RID_COMMON_START + 11);
+ resbtnOK_value = getResText(RID_COMMON_START + 18);
+ resbtnHelp_value = getResText(RID_COMMON_START + 15);
+
+ restxtDir_value = "/";
+
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/IconsDialog.java b/wizards/com/sun/star/wizards/web/IconsDialog.java
new file mode 100644
index 000000000000..6228180a75f4
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/IconsDialog.java
@@ -0,0 +1,208 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import javax.swing.ListModel;
+
+import com.sun.star.awt.Size;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.ConfigSet;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.ui.ImageList;
+import com.sun.star.wizards.web.data.CGIconSet;
+
+/**
+ * @author rpiterman
+ * The dialog class for choosing an icon set.
+ * This class simulates a model, though it does not functions really as one,
+ * since it does not cast events.
+ * It also implements the ImageList.ImageRenderer interface, to handle
+ * its own objects.
+ */
+public class IconsDialog extends ImageListDialog implements ImageList.IImageRenderer, ListModel
+{
+
+ private ConfigSet set;
+ String htmlexpDirectory;
+ /**
+ * this icons filename prefixes are used to display the icons.
+ */
+ private String[] icons = new String[]
+ {
+ "firs", "prev", "next", "last", "nav", "text", "up", "down"
+ };
+ private Integer[] objects;
+
+ /**
+ * @param xmsf
+ * @param set_ the configuration set of the supported
+ * icon sets.
+ */
+ public IconsDialog(XMultiServiceFactory xmsf,
+ ConfigSet set_,
+ WebWizardDialogResources resources)
+ throws Exception
+ {
+ super(xmsf, WWHID.HID_IS, new String[]
+ {
+ resources.resIconsDialog,
+ resources.resIconsDialogCaption,
+ resources.resOK,
+ resources.resCancel,
+ resources.resHelp,
+ resources.resDeselect,
+ resources.resOther,
+ resources.resCounter
+ });
+
+ htmlexpDirectory = FileAccess.getOfficePath(xmsf, "Gallery", "share", "");
+ set = set_;
+ objects = new Integer[set.getSize() * icons.length];
+ for (int i = 0; i < objects.length; i++)
+ {
+ objects[i] = new Integer(i);
+ }
+ il.setListModel(this);
+ il.setRenderer(this);
+ il.setRows(4);
+ il.setCols(8);
+ il.setImageSize(new Size(20, 20));
+ il.setShowButtons(false);
+ il.setRowSelect(true);
+ il.scaleImages = Boolean.FALSE;
+
+ showDeselectButton = true;
+ showOtherButton = false;
+
+ build();
+ }
+
+ public String getIconset()
+ {
+ if (getSelected() == null)
+ {
+ return null;
+ }
+ else
+ {
+ return (String) set.getKey(((Number) getSelected()).intValue() / icons.length);
+ }
+ }
+
+ public void setIconset(String iconset)
+ {
+ int icon = set.getIndexOf(set.getElement(iconset)) * icons.length;
+ this.setSelected(icon >= 0 ? objects[icon] : null);
+ }
+
+ /**
+ * dummy
+ */
+ public synchronized void addListDataListener(javax.swing.event.ListDataListener listener)
+ {
+ }
+
+ /**
+ * dummy
+ */
+ public synchronized void removeListDataListener(javax.swing.event.ListDataListener listener)
+ {
+ }
+
+ /* (non-Javadoc)
+ * @see javax.swing.ListModel#getSize()
+ */
+ public int getSize()
+ {
+ return set.getSize() * icons.length;
+ }
+ /* (non-Javadoc)
+ * @see javax.swing.ListModel#getElementAt(int)
+ */
+
+ public Object getElementAt(int arg0)
+ {
+ return objects[arg0];
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.ui.ImageList.ImageRenderer#getImageUrls(java.lang.Object)
+ */
+ public Object[] getImageUrls(Object listItem)
+ {
+ int i = ((Number) listItem).intValue();
+ int iset = getIconsetNum(i);
+ int icon = getIconNum(i);
+ String[] sRetUrls = new String[2];
+ sRetUrls[0] = htmlexpDirectory + "/htmlexpo/" +
+ getIconsetPref(iset) +
+ icons[icon] +
+ getIconsetPostfix(iset);
+ sRetUrls[1] = sRetUrls[0];
+ //System.out.println(s);
+ return sRetUrls;
+ }
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.common.Renderer#render(java.lang.Object)
+ */
+
+ public String render(Object object)
+ {
+ if (object == null)
+ {
+ return "";
+ }
+ int i = ((Number) object).intValue();
+ int iset = getIconsetNum(i);
+ return getIconset(iset).cp_Name;
+ }
+
+ private int getIconsetNum(int i)
+ {
+ return i / icons.length;
+ }
+
+ private int getIconNum(int i)
+ {
+ return i % icons.length;
+ }
+
+ private String getIconsetPref(int iconset)
+ {
+ return getIconset(iconset).cp_FNPrefix;
+ }
+
+ private String getIconsetPostfix(int iconset)
+ {
+ return getIconset(iconset).cp_FNPostfix;
+ }
+
+ private CGIconSet getIconset(int i)
+ {
+ return (CGIconSet) set.getElementAt(i);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/ImageListDialog.java b/wizards/com/sun/star/wizards/web/ImageListDialog.java
new file mode 100644
index 000000000000..c3ea98688c64
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ImageListDialog.java
@@ -0,0 +1,283 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.IRenderer;
+import com.sun.star.wizards.ui.ImageList;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.UnoDialog2;
+import com.sun.star.wizards.ui.ImageList.Counter;
+
+/**
+ * This class is a general implementation for a
+ * dialog which displays a choice of images.
+ * The model and the renderer are
+ * still abstract in this class.
+ * To use the class one should extend it,
+ * in the constructor then set the imageList
+ * properties (member name il) like image size, grid size,
+ * model renderer aso, and then call "build".
+ * This class uses a counter renderer which
+ * gets an expression which contains %START %END %TOTAL and replaces
+ * them with the actual numbers.
+ * <BR/>
+ * two buttons: "other" and "none" which are there
+ * to enable choosing images that are not in the list and
+ * "no image" respectivley, are optional, with default to true,
+ * so dialogs which do not need those, should set the corresponding
+ * members showDeselectButton and/or showOtherButton to false.
+ * <br/>
+ * the consturctor should recieve, among others, an Array of String resources - see
+ * constructor documentation for details.
+ *
+ * @author rpiterman
+ */
+public abstract class ImageListDialog extends UnoDialog2 implements UIConsts
+{
+
+ private String[] resources;
+ private final static int RES_TITLE = 0;
+ private final static int RES_LABEL = 1;
+ private final static int RES_OK = 2;
+ private final static int RES_CANCEL = 3;
+ private final static int RES_HELP = 4;
+ private final static int RES_DESELECT = 5;
+ private final static int RES_OTHER = 6;
+ private final static int RES_COUNTER = 7; //GUI Components as Class members.
+ private XButton btnOK;
+ private XButton btnCancel;
+ private XButton btnHelp;
+ private XButton btnOther;
+ private XButton btnDeselect;
+ private static final String START = "%START";
+ private static final String END = "%END";
+ private static final String TOTAL = "%TOTAL";
+ protected int cutFilename = 0;
+ protected boolean showDeselectButton = true;
+ protected boolean showOtherButton = true;
+ private XFixedText lblTitle;
+ //Font Descriptors as Class members.
+ private FontDescriptor fontDescriptor1 = new FontDescriptor();
+ protected ImageList il; //private FileAccess fileAccess;
+ private Object result;
+ private int hid;
+
+ /**
+ *
+ * @param xmsf
+ * @param resources_ a string array with the following strings :
+ * dialog title, label text, ok, cancel, help, deselect, other.
+ * <br/> if "deselect" and "other" are not displayed,
+ * the array can also be shorter. but if "other" is displayed
+ * and "deselect" not, both must be there :-(
+ */
+ public ImageListDialog(
+ XMultiServiceFactory xmsf, int hid_, String[] resources_)
+ {
+ super(xmsf);
+ hid = hid_;
+ resources = resources_;
+ il = new ImageList();
+ il.counterRenderer = new ARenderer(resources[RES_COUNTER]);
+ }
+
+ /**
+ * adds the controls to the dialog, depending on
+ * the size of the image list.
+ * This method should be called by subclasses after setting
+ * the il ImageList member properties
+ */
+ protected void build()
+ {
+ //set dialog properties...
+
+ int ilWidth = (il.getImageSize().Width + il.getGap().Width) * il.getCols() + il.getGap().Width;
+ int ilHeight = (il.getImageSize().Height + il.getGap().Height) * il.getRows() + il.getGap().Height;
+
+ int dialogWidth = 6 + ilWidth + 6 + 50 + 6;
+ int dialogHeight = 3 + 16 + 3 + (ilHeight + 8 + 14) + 6;
+
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "HelpURL", "Moveable", "Name", "PositionX", "PositionY", "Step", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(dialogHeight), HelpIds.getHelpIdString(hid), Boolean.TRUE, "imgDialog", new Integer(59), new Integer(24), INTEGERS[1], resources[RES_TITLE], new Integer(dialogWidth)
+ });
+ //Set member- FontDescriptors...
+ fontDescriptor1.Weight = 150;
+
+ final String[] PROPNAMES = new String[]
+ {
+ "DefaultButton", "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "PushButtonType", "TabIndex", "Width"
+ };
+
+ Integer iButtonsX = new Integer(6 + ilWidth + 6);
+
+ btnOK = insertButton("btnOK", null,
+ PROPNAMES,
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_14, HelpIds.getHelpIdString(hid + 3), resources[RES_OK], "btnOK", iButtonsX, new Integer(22), new Short((short) com.sun.star.awt.PushButtonType.OK_value), new Short((short) 7), INTEGER_50
+ });
+ btnCancel = insertButton("btnCancel", null,
+ PROPNAMES,
+ new Object[]
+ {
+ Boolean.FALSE, INTEGER_14, HelpIds.getHelpIdString(hid + 4), resources[RES_CANCEL], "btnCancel", iButtonsX, new Integer(41), new Short((short) com.sun.star.awt.PushButtonType.CANCEL_value), new Short((short) 8), INTEGER_50
+ });
+ btnHelp = insertButton("btnHelp", null,
+ PROPNAMES,
+ new Object[]
+ {
+ Boolean.FALSE, INTEGER_14, "", resources[RES_HELP], "CommandButton3", iButtonsX, new Integer(71), new Short((short) com.sun.star.awt.PushButtonType.HELP_value), new Short((short) 9), INTEGER_50
+ });
+
+ if (showOtherButton)
+ {
+
+ int otherY = 22 + ilHeight - 14 - (showDeselectButton ? 19 : 0);
+
+ btnOther = insertButton("btnOther", "other",
+ PROPNAMES,
+ new Object[]
+ {
+ Boolean.FALSE, INTEGER_14, HelpIds.getHelpIdString(hid + 1), resources[RES_OTHER], "btnOther", iButtonsX, new Integer(otherY), new Short((short) com.sun.star.awt.PushButtonType.STANDARD_value), new Short((short) 5), INTEGER_50
+ });
+ }
+
+ if (showDeselectButton)
+ {
+
+ int deselectY = 22 + ilHeight - 14;
+
+ btnDeselect = insertButton("btnNoImage", "deselect",
+ PROPNAMES,
+ new Object[]
+ {
+ Boolean.FALSE, INTEGER_14, HelpIds.getHelpIdString(hid + 2), resources[RES_DESELECT], "btnNoImage", iButtonsX, new Integer(deselectY), new Short((short) com.sun.star.awt.PushButtonType.STANDARD_value), new Short((short) 4), INTEGER_50
+ });
+ }
+
+ il.setStep(new Short((short) 1));
+ il.setPos(new Size(6, 22));
+ il.helpURL = hid + 5;
+ il.tabIndex = 1;
+ il.create(this);
+
+ /*lblContainer = insertLabel("lblContainer",
+ new String[] {"Height", "Name", "PositionX", "PositionY", "TabIndex", "Width"},
+ new Object[] { new Integer(176),"lblContainer",new Integer(6),new Integer(17),new Short((short)5),new Integer(214)}
+ );*/
+
+ lblTitle = insertLabel("lblTitle",
+ new String[]
+ {
+ "FontDescriptor", "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor1, INTEGERS[8], resources[RES_LABEL], "lblTitle", INTEGERS[6], INTEGERS[6], INTEGERS[1], new Short((short) 4), new Integer(216)
+ });
+
+ }
+
+ /**
+ * is called when the user clicks "none"
+ */
+ public void deselect()
+ {
+ il.setSelected(-1);
+ }
+
+ /**
+ * is called when the user clicks "other"
+ *
+ */
+ public void other()
+ {
+ }
+
+ /**
+ * @return the currently elected object.
+ */
+ public Object getSelected()
+ {
+ return il.getSelectedObject();
+ }
+
+ /**
+ * sets the currently selected object.
+ * @param obj the object (out of the model) to be selected.
+ */
+ public void setSelected(Object obj)
+ {
+ il.setSelected(obj);
+ il.showSelected();
+ }
+
+ /**
+ * The counter renderer, which uses a template.
+ * The template replaces the Strings "%START", "%END" and
+ * "%TOTAL" with the respective values.
+ * @author rpiterman
+ *
+ */
+ public static class ARenderer implements IRenderer
+ {
+
+ String template;
+
+ /**
+ * @param aTempalte a template for this renderer.
+ * The strings %START, %END ,%TOTAL will be replaced
+ * with the actual values.
+ */
+ public ARenderer(String aTemplate)
+ {
+ template = aTemplate;
+ }
+
+ public String render(Object counter)
+ {
+ String s = JavaTools.replaceSubString(template, "" + ((Counter) counter).start, START);
+ s = JavaTools.replaceSubString(s, "" + ((Counter) counter).end, END);
+ s = JavaTools.replaceSubString(s, "" + ((Counter) counter).max, TOTAL);
+ return s;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/LogTaskListener.java b/wizards/com/sun/star/wizards/web/LogTaskListener.java
new file mode 100644
index 000000000000..f1814f9e4cb6
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/LogTaskListener.java
@@ -0,0 +1,103 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 04.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web;
+
+import java.io.PrintStream;
+
+import com.sun.star.wizards.ui.event.TaskEvent;
+import com.sun.star.wizards.ui.event.TaskListener;
+
+/**
+ * used for debugging.
+ * @author rpiterman
+ */
+public class LogTaskListener implements TaskListener, ErrorHandler
+{
+
+ private PrintStream out;
+
+ public LogTaskListener(PrintStream os)
+ {
+ out = os;
+ }
+
+ public LogTaskListener()
+ {
+ this(System.out);
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskStarted(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskStarted(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " STARTED.");
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskFinished(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskFinished(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " FINISHED: " + te.getTask().getSuccessfull() + "/" + te.getTask().getMax() + "Succeeded.");
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskStatusChanged(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskStatusChanged(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " status : " + te.getTask().getSuccessfull() + "(+" + te.getTask().getFailed() + ")/" + te.getTask().getMax());
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#subtaskNameChanged(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void subtaskNameChanged(TaskEvent te)
+ {
+ out.println("SUBTASK Name:" + te.getTask().getSubtaskName());
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.ErrorReporter#error(java.lang.Exception, java.lang.Object, java.lang.String)
+ */
+ public boolean error(Exception ex, Object arg, int ix, int i)
+ {
+ System.out.println("" + arg + "//" + ix + "//Exception: " + ex.getLocalizedMessage());
+ ex.printStackTrace();
+ return true;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/MANIFEST.MF b/wizards/com/sun/star/wizards/web/MANIFEST.MF
new file mode 100644
index 000000000000..1a7a0e51b83a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/MANIFEST.MF
@@ -0,0 +1,2 @@
+RegistrationClassName: com.sun.star.wizards.web.CallWizard
+UNO-Type-Path:
diff --git a/wizards/com/sun/star/wizards/web/Process.java b/wizards/com/sun/star/wizards/web/Process.java
new file mode 100644
index 000000000000..d1ae8e23763e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/Process.java
@@ -0,0 +1,844 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.xml.transform.Templates;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
+import org.w3c.dom.Document;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.ConfigSet;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.UCB;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGContent;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGExporter;
+import com.sun.star.wizards.web.data.CGLayout;
+import com.sun.star.wizards.web.data.CGPublish;
+import com.sun.star.wizards.web.data.CGSettings;
+import com.sun.star.wizards.web.export.Exporter;
+
+/**
+ * @author rpiterman
+ * This class is used to process a CGSession object
+ * and generate a site. </br>
+ * it does the following: <br/>
+ * 1. create a temporary directory.<br/>
+ * 2. export documents to the temporary directory.<br/>
+ * 3. generate the TOC page, includes copying images from the
+ * web wizard work directory and other layout files.<br/>
+ * 4. publish, or copy, from the temporary directory to
+ * different destinations.<br/>
+ * 5. delete the temporary directory.<br/>
+ * <br/>
+ * to follow up the status/errors it uses a TaskListener object,
+ * and an ErrorHandler. <br/>
+ * in practice, the TaskListener is the status dialog,
+ * and the Errorhandler does the interaction with the user,
+ * if something goes wrong.<br/>
+ * Note that this class takes it in count that
+ * the given session object is prepared for it -
+ * all preparations are done in WWD_Events.finishWizard methods.
+ * <br/>
+ * <br/>
+ *
+ * note on error handling: <br/>
+ * on "catch" clauses I tries to decide whether the
+ * exception is fatal or not. For fatal exception an error message
+ * is displayed (or rather: the errorHandler is being called...)
+ * and a false is returned.
+ * In less-fatal errors, the errorHandler "should decide" which means,
+ * the user is given the option to "OK" or to "Cancel" and depending
+ * on that interaction I cary on.
+ */
+public class Process implements WebWizardConst, ProcessErrors
+{
+
+ private static final int TASKS_PER_DOC = 5;
+ private static final int TASKS_PER_XSL = 2;
+ private static final int TASKS_PER_PUBLISH = 2;
+ private static final int TASKS_IN_PREPARE = 1;
+ private static final int TASKS_IN_EXPORT = 2;
+ private static final int TASKS_IN_GENERATE = 2;
+ private static final int TASKS_IN_PUBLISH = 2;
+ private static final int TASKS_IN_FINISHUP = 1;
+ private CGSettings settings;
+ private XMultiServiceFactory xmsf;
+ private ErrorHandler errorHandler;
+ private String tempDir;
+ private FileAccess fileAccess;
+ private UCB ucb;
+ public Task myTask;
+ /**
+ * This is a cache for exporters, so I do not need to
+ * instanciate the same exporter more than once.
+ */
+ private Map exporters = new Hashtable(3);
+ private boolean result;
+
+ public Process(
+ CGSettings settings,
+ XMultiServiceFactory xmsf,
+ ErrorHandler er)
+ throws Exception
+ {
+ this.xmsf = xmsf;
+ this.settings = settings;
+ fileAccess = new FileAccess(xmsf);
+ errorHandler = er;
+
+ ucb = new UCB(xmsf);
+
+ int taskSteps = getTaskSteps();
+ myTask = new Task(TASK, TASK_PREPARE, taskSteps);
+
+ }
+
+ /**
+ * @return to how many destinations should the
+ * generated site be published.
+ */
+ private int countPublish()
+ {
+ int count = 0;
+ ConfigSet publishers = settings.cp_DefaultSession.cp_Publishing;
+ for (int i = 0; i < publishers.getSize(); i++)
+ {
+ if (((CGPublish) publishers.getElementAt(i)).cp_Publish)
+ {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ /**
+ * @return the number of task steps that this
+ * session should have
+ */
+ private int getTaskSteps()
+ {
+ int docs = settings.cp_DefaultSession.cp_Content.cp_Documents.getSize();
+ int xsl = 0;
+ try
+ {
+ xsl = settings.cp_DefaultSession.getLayout().getTemplates(xmsf).size();
+ }
+ catch (Exception ex)
+ {
+ }
+ int publish = countPublish();
+ int taskSteps =
+ TASKS_IN_PREPARE +
+ TASKS_IN_EXPORT + docs * TASKS_PER_DOC +
+ TASKS_IN_GENERATE + xsl * TASKS_PER_XSL +
+ TASKS_IN_PUBLISH + publish * TASKS_PER_PUBLISH +
+ TASKS_IN_FINISHUP;
+ return taskSteps;
+ }
+
+ /**
+ * does the job
+ */
+ public void runProcess()
+ {
+ myTask.start();
+ try
+ {
+ try
+ {
+ /*
+ * I use here '&&' so if one of the
+ * methods returns false, the next
+ * will not be called.
+ */
+ result = createTempDir(myTask) && export(myTask) && generate(tempDir, myTask) && publish(tempDir, myTask);
+
+ }
+ finally
+ {
+ //cleanup must be called.
+ result = result & cleanup(myTask);
+ }
+ }
+ catch (Exception ex)
+ {
+ result = false;
+ }
+
+ if (!result)
+ {
+ myTask.fail(); //this is a bug protection.
+ }
+ while (myTask.getStatus() < myTask.getMax())
+ {
+ myTask.advance(true);
+ }
+ }
+
+ /**
+ * creates a temporary directory.
+ * @param task
+ * @return true should continue
+ */
+ private boolean createTempDir(Task task)
+ {
+
+ tempDir = fileAccess.createNewDir(getSOTempDir(xmsf), "wwiztemp");
+ if (tempDir == null)
+ {
+ error(null, null, ERROR_MKDIR, ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ else
+ {
+ task.advance(true);
+ return true;
+ }
+ }
+
+ /**
+ * @param xmsf
+ * @return the staroffice /openoffice temporary directory
+ */
+ static String getSOTempDir(XMultiServiceFactory xmsf)
+ {
+ try
+ {
+ String s = FileAccess.getOfficePath(xmsf, "Temp", "", "");
+ return s;
+ }
+ catch (Exception e)
+ {
+ }
+ return null;
+ }
+
+ // CLEANUP
+ /**
+ * delete the temporary directory
+ * @return true should continue
+ */
+ private boolean cleanup(Task task)
+ {
+
+ task.setSubtaskName(TASK_FINISH);
+ boolean b = fileAccess.delete(tempDir);
+ if (!b)
+ {
+ error(null, null, ERROR_CLEANUP, ErrorHandler.ERROR_WARNING);
+ }
+ task.advance(b);
+ return b;
+ }
+
+// /**
+// * deletes the given directory
+// * @param dir the directory to delete
+// * @return true if should continue
+// */
+// private boolean cleanup(String dir) {
+//
+// boolean success = true;
+//
+// if (dir != null && fileAccess.exists(dir,false)) {
+//
+// String[] files = fileAccess.listFiles(dir,true);
+//
+// for (int i = 0; i < files.length; i++) {
+// if (fileAccess.isDirectory(files[i]))
+// success = success && cleanup(files[i]);
+// else
+// success = success && fileAccess.delete(files[i]);
+//
+// }
+// }
+// return success && fileAccess.delete(dir);
+// }
+ /**
+ * This method is used to copy style files to a target
+ * Directory: css and background.
+ * Note that this method is static since it is
+ * also used when displaying a "preview"
+ */
+ public static void copyMedia(UCB copy, CGSettings settings, String targetDir, Task task) throws Exception
+ {
+
+ //1. .css
+ String sourceDir = FileAccess.connectURLs(settings.workPath, "styles");
+ String filename = settings.cp_DefaultSession.getStyle().cp_CssHref;
+ copy.copy(sourceDir, filename, targetDir, "style.css");
+
+ task.advance(true);
+
+ //2. background image
+ String background = settings.cp_DefaultSession.cp_Design.cp_BackgroundImage;
+ if (background != null && !background.equals(""))
+ {
+ sourceDir = FileAccess.getParentDir(background);
+ filename = background.substring(sourceDir.length());
+ copy.copy(sourceDir, filename, targetDir + "/images", "background.gif");
+ }
+
+ task.advance(true);
+ }
+
+ /**
+ * Copy "static" files (which are always the same,
+ * thus not user-input-dependant) to a target directory.
+ * Note that this method is static since it is
+ * also used when displaying a "preview"
+ * @param copy
+ * @param settings
+ * @param targetDir
+ * @throws Exception
+ */
+ public static void copyStaticImages(UCB copy, CGSettings settings, String targetDir)
+ throws Exception
+ {
+ copy.copy(FileAccess.connectURLs(settings.workPath, "images"), targetDir + "/images");
+ }
+
+ /**
+ * publish the given directory.
+ * @param dir the source directory to publish from
+ * @param task task tracking.
+ * @return true if should continue
+ */
+ private boolean publish(String dir, Task task)
+ {
+ task.setSubtaskName(TASK_PUBLISH_PREPARE);
+ ConfigSet set = settings.cp_DefaultSession.cp_Publishing;
+ try
+ {
+
+ copyMedia(ucb, settings, dir, task);
+ copyStaticImages(ucb, settings, dir);
+ task.advance(true);
+ }
+ catch (Exception ex)
+ {
+ //error in copying media
+ error(ex, "", ERROR_PUBLISH_MEDIA, ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+
+ boolean result = true;
+
+ for (int i = 0; i < set.getSize(); i++)
+ {
+
+ CGPublish p = (CGPublish) set.getElementAt(i);
+
+ if (p.cp_Publish)
+ {
+
+ String key = (String) set.getKey(p);
+ task.setSubtaskName(key);
+
+ if (key.equals(ZIP_PUBLISHER))
+ {
+ fileAccess.delete(p.cp_URL);
+ }
+ if (!publish(dir, p, ucb, task))
+ {
+ return false;
+ }
+
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * publish the given directory to the
+ * given target CGPublish.
+ * @param dir the dir to copy from
+ * @param publish the object that specifies the target
+ * @param copy ucb encapsulation
+ * @param task task tracking
+ * @return true if should continue
+ */
+ private boolean publish(String dir, CGPublish publish, UCB copy, Task task)
+ {
+ try
+ {
+ //copy.deleteDirContent(publish.url);
+ task.advance(true);
+ copy.copy(dir, publish.url);
+ task.advance(true);
+ return true;
+ }
+ catch (Exception e)
+ {
+ task.advance(false);
+ return error(e, publish, ERROR_PUBLISH, ErrorHandler.ERROR_NORMAL_IGNORE);
+ }
+ }
+ //GENERATING METHODS
+ /**
+ * Generates the TOC pages for the current session.
+ * @param targetDir generating to this directory.
+ */
+ public boolean generate(String targetDir, Task task)
+ {
+ boolean result = false;
+ task.setSubtaskName(TASK_GENERATE_PREPARE);
+
+
+ CGLayout layout = settings.cp_DefaultSession.getLayout();
+
+ try
+ {
+ /*
+ * here I create the DOM of the TOC to pass to the XSL
+ */
+ Document doc = (Document) settings.cp_DefaultSession.createDOM();
+ generate(xmsf, layout, doc, fileAccess, targetDir, task);
+
+ }
+ catch (Exception ex)
+ {
+ error(ex, "", ERROR_GENERATE_XSLT, ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+
+ /* copy files which are not xsl from layout directory to
+ * website root.
+ */
+ try
+ {
+
+ task.setSubtaskName(TASK_GENERATE_COPY);
+
+ copyLayoutFiles(ucb, fileAccess, settings, layout, targetDir);
+
+ task.advance(true);
+
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ task.advance(false);
+ return error(ex, null, ERROR_GENERATE_COPY, ErrorHandler.ERROR_NORMAL_ABORT);
+ }
+
+
+
+ return result;
+
+ }
+
+ /**
+ * copies layout files which are not .xsl files
+ * to the target directory.
+ * @param ucb UCB encapsulatzion object
+ * @param fileAccess filaAccess encapsulation object
+ * @param settings web wizard settings
+ * @param layout the layout object
+ * @param targetDir the target directory to copy to
+ * @throws Exception
+ */
+ public static void copyLayoutFiles(UCB ucb, FileAccess fileAccess, CGSettings settings, CGLayout layout, String targetDir)
+ throws Exception
+ {
+ String filesPath = fileAccess.getURL(
+ FileAccess.connectURLs(settings.workPath, "layouts/"), layout.cp_FSName);
+ ucb.copy(filesPath, targetDir, new ExtensionVerifier("xsl"));
+
+ }
+
+ /**
+ * generates the TOC page for the given layout.
+ * This method might generate more than one file, depending
+ * on how many .xsl files are in the
+ * directory specifies by the given layout object.
+ * @param xmsf
+ * @param layout specifies the layout to use.
+ * @param doc the DOM representation of the web wizard session
+ * @param fileAccess encapsulation of FileAccess
+ * @param targetPath target directory
+ * @param task
+ * @throws Exception
+ */
+ public static void generate(
+ XMultiServiceFactory xmsf,
+ CGLayout layout,
+ Document doc,
+ FileAccess fileAccess,
+ String targetPath,
+ Task task)
+ throws Exception
+ {
+ /*
+ * a map that contains xsl templates. the keys are the xsl file names.
+ */
+ Map templates = layout.getTemplates(xmsf);
+
+ task.advance(true, TASK_GENERATE_XSL);
+
+ /*
+ * each template generates a page.
+ */
+ for (Iterator i = templates.keySet().iterator(); i.hasNext();)
+ {
+
+ String key = "";
+
+ key = (String) i.next();
+
+ Transformer transformer = ((Templates) templates.get(key)).newTransformer();
+
+ doc.normalize();
+ task.advance(true);
+
+ /*
+ * The target file name is like the xsl template filename
+ * without the .xsl extension.
+ */
+ String fn = fileAccess.getPath(targetPath, key.substring(0, key.length() - 4));
+ File f = new File(fn);
+ FileOutputStream oStream = new FileOutputStream(f);
+ // Due to a problem occuring when using Xalan-Java 2.6.0 and
+ // Java 1.5.0, wrap f in a FileOutputStream here (otherwise, the
+ // StreamResult's getSystemId would return a "file:/..." URL while
+ // the Xalan code expects a "file:///..." URL):
+ transformer.transform(
+ new DOMSource(doc), new StreamResult(oStream));
+ oStream.close();
+ task.advance(true);
+ }
+ }
+
+ /**
+ * I broke the export method to two methods
+ * in a time where a tree with more than one contents was planned.
+ * I left it that way, because it may be used in the future.
+ * @param task
+ * @return
+ */
+ private boolean export(Task task)
+ {
+
+ return export(settings.cp_DefaultSession.cp_Content, tempDir, task);
+
+ }
+
+ /**
+ * This method could actually, with light modification, use recursion.
+ * In the present situation, where we only use a "flat" list of
+ * documents, instead of the original plan to use a tree,
+ * the recursion is not implemented.
+ * @param content the content ( directory-like, contains documents)
+ * @param dir (target directory for exporting this content.
+ * @param task
+ * @return true if should continue
+ */
+ private boolean export(CGContent content, String dir, Task task)
+ {
+ int toPerform = 1;
+ String contentDir = dir;
+
+ try
+ {
+
+ task.setSubtaskName(TASK_EXPORT_PREPARE);
+
+ /* 1. create a content directory.
+ * each content (at the moment there is only one :-( )
+ * is created in its own directory.
+ * faileure here is fatal.
+ */
+ contentDir = fileAccess.createNewDir(dir, content.cp_Name);
+ if (contentDir == null || contentDir.equals(""))
+ {
+ throw new IOException("Directory " + dir + " could not be created.");
+ }
+ content.dirName = FileAccess.getFilename(contentDir);
+
+ task.advance(true, TASK_EXPORT_DOCUMENTS);
+ toPerform--;
+
+ /*2. export all documents and sub contents.
+ * (at the moment, only documents, no subcontents)
+ */
+ Object item = null;
+ for (int i = 0; i < content.cp_Documents.getSize(); i++)
+ {
+ try
+ {
+ item = content.cp_Documents.getElementAt(i);
+ /*
+ * In present this is always the case.
+ * may be in the future, when
+ * a tree is used, it will be abit different.
+ */
+ if (item instanceof CGDocument)
+ {
+ if (!export((CGDocument) item, contentDir, task))
+ {
+ return false;
+ }
+ }
+ else /*
+ * we never get here since we
+ * did not implement sub-contents.
+ */ if (!export((CGContent) item, contentDir, task))
+ {
+ return false;
+ }
+ }
+ catch (SecurityException sx)
+ {
+ // nonfatal
+ if (!error(sx, item, ERROR_EXPORT_SECURITY, ErrorHandler.ERROR_NORMAL_IGNORE))
+ {
+ return false;
+ }
+ result = false;
+ }
+ }
+ }
+ catch (IOException iox)
+ {
+ //nonfatal
+ return error(iox, content, ERROR_EXPORT_IO, ErrorHandler.ERROR_NORMAL_IGNORE);
+
+ }
+ catch (SecurityException se)
+ {
+ //nonfatal
+ return error(se, content, ERROR_EXPORT_SECURITY, ErrorHandler.ERROR_NORMAL_IGNORE);
+ }
+ failTask(task, toPerform);
+ return true;
+
+ }
+
+ /**
+ * exports a single document
+ * @param doc the document to export
+ * @param dir the target directory
+ * @param task task tracking
+ * @return true if should continue
+ */
+ private boolean export(CGDocument doc, String dir, Task task)
+ {
+
+ //first I check if the document was already validated...
+ if (!doc.valid)
+ {
+ try
+ {
+ doc.validate(xmsf, null);
+ }
+ catch (Exception ex)
+ {
+ //fatal
+ error(ex, doc, ERROR_DOC_VALIDATE, ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ //get the exporter specified for this document
+ }
+ CGExporter exporter = (CGExporter) settings.cp_Exporters.getElement(doc.cp_Exporter);
+
+
+ try
+ {
+
+ /*
+ * here I calculate the destination filename.
+ * I take the original filename (docFilename), substract the extension, (docExt) -> (fn)
+ * and find an available filename which starts with
+ * this filename, but with the new extension. (destExt)
+ */
+ String docFilename = FileAccess.getFilename(doc.cp_URL);
+
+ String docExt = FileAccess.getExtension(docFilename);
+ String fn = doc.localFilename.substring(0, doc.localFilename.length() - docExt.length() - 1); //filename without extension
+
+ /*
+ * the copyExporter does not change
+ * the extension of the target...
+ */
+ String destExt = (exporter.cp_Extension.equals("")
+ ? FileAccess.getExtension(docFilename)
+ : exporter.cp_Extension);
+
+ /* if this filter needs to export to its own directory...
+ * this is the case in, for example, impress html export
+ */
+ if (exporter.cp_OwnDirectory)
+ { //+++
+ dir = fileAccess.createNewDir(dir, fn);
+ doc.dirName = FileAccess.getFilename(dir);
+ }
+
+ /*
+ * if two files with the same name
+ * need to be exported ? So here
+ * i get a new filename, so I do not
+ * overwrite files...
+ */
+ String file = fileAccess.getNewFile(dir, fn, destExt);
+
+
+ /* set filename with extension.
+ * this will be used by the exporter,
+ * and to generate the TOC.
+ */
+ doc.urlFilename = FileAccess.getFilename(file);
+
+ task.advance(true);
+
+ try
+ {
+ //export
+ getExporter(exporter).export(doc, file, xmsf, task);
+ task.advance(true);
+ }
+ /*
+ * getExporter(..) throws
+ * IllegalAccessException, InstantiationException, ClassNotFoundException
+ * export() throws Exception
+ */
+ catch (Exception ex)
+ {
+ //nonfatal
+ if (!error(ex, doc, ERROR_EXPORT, ErrorHandler.ERROR_NORMAL_IGNORE))
+ {
+ return false;
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ //nonfatal
+ if (!error(ex, doc, ERROR_EXPORT_MKDIR, ErrorHandler.ERROR_NORMAL_ABORT))
+ {
+ return false;
+ }
+ }
+
+ return true;
+
+ }
+
+ /**
+ * submit an error.
+ * @param ex the exception
+ * @param arg1 error argument
+ * @param arg2 error argument 2
+ * @param errType error type
+ * @return the interaction result
+ */
+ private boolean error(Exception ex, Object arg1, int arg2, int errType)
+ {
+ result = false;
+ return errorHandler.error(ex, arg1, arg2, errType);
+ }
+
+ /**
+ * advances the given task in the given count of steps,
+ * marked as failed.
+ * @param task the task to advance
+ * @param count the number of steps to advance
+ */
+ private void failTask(Task task, int count)
+ {
+ while (count-- > 0)
+ {
+ task.advance(false);
+ }
+ }
+
+ /**
+ * creates an instance of the exporter class
+ * as specified by the
+ * exporter object.
+ * @param export specifies the exporter to be created
+ * @return the Exporter instance
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws InstantiationException
+ */
+ private Exporter createExporter(CGExporter export)
+ throws ClassNotFoundException,
+ IllegalAccessException,
+ InstantiationException
+ {
+ Exporter e = (Exporter) Class.forName(export.cp_ExporterClass).newInstance();
+ e.init(export);
+ return e;
+ }
+
+ /**
+ * searches the an exporter for the given CGExporter object
+ * in the cache.
+ * If its not there, creates it, stores it in the cache and
+ * returns it.
+ * @param export specifies the needed exporter.
+ * @return an Exporter instance
+ * @throws ClassNotFoundException thrown when using Class.forName(string)
+ * @throws IllegalAccessException thrown when using Class.forName(string)
+ * @throws InstantiationException thrown when using Class.forName(string)
+ */
+ private Exporter getExporter(CGExporter export)
+ throws ClassNotFoundException,
+ IllegalAccessException,
+ InstantiationException
+ {
+ Exporter exp = (Exporter) exporters.get(export);
+ if (exp == null)
+ {
+ exp = createExporter(export);
+ exporters.put(export, exp);
+ }
+ return exp;
+ }
+
+ /**
+ * @return tru if everything went smooth, false
+ * if error(s) accured.
+ */
+ public boolean getResult()
+ {
+ return (myTask.getFailed() == 0) && result;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/ProcessErrorHandler.java b/wizards/com/sun/star/wizards/web/ProcessErrorHandler.java
new file mode 100644
index 000000000000..96106986515c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ProcessErrorHandler.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGPublish;
+
+/**
+ * @author rpiterman
+ * used to interact error accuring when generating the
+ * web-site to the user.
+ * This class renders the different errors,
+ * replaceing some strings from the resources with
+ * content of the given arguments, depending on the error
+ * that accured.
+ */
+public class ProcessErrorHandler extends AbstractErrorHandler
+ implements WebWizardConst,
+ ProcessErrors
+{
+
+ private static final String FILENAME = "%FILENAME";
+ private static final String URL = "%URL";
+ private static final String ERROR = "%ERROR";
+ WebWizardDialogResources resources;
+
+ public ProcessErrorHandler(XMultiServiceFactory xmsf, XWindowPeer peer, WebWizardDialogResources res)
+ {
+ super(xmsf, peer);
+ resources = res;
+ }
+
+ protected String getMessageFor(Exception ex, Object obj, int ix, int errType)
+ {
+
+ switch (ix)
+ {
+
+ case ERROR_MKDIR:
+ return JavaTools.replaceSubString(resources.resErrDocExport, ((CGDocument) obj).localFilename, FILENAME);
+ case ERROR_EXPORT_MKDIR:
+ return JavaTools.replaceSubString(resources.resErrMkDir, ((CGDocument) obj).localFilename, FILENAME);
+ case ERROR_DOC_VALIDATE:
+ return JavaTools.replaceSubString(resources.resErrDocInfo, ((CGDocument) obj).localFilename, FILENAME);
+ case ERROR_EXPORT_IO:
+ return JavaTools.replaceSubString(resources.resErrExportIO, ((CGDocument) obj).localFilename, FILENAME);
+ case ERROR_EXPORT_SECURITY:
+ return JavaTools.replaceSubString(resources.resErrSecurity, ((CGDocument) obj).localFilename, FILENAME);
+ case ERROR_GENERATE_XSLT:
+ return resources.resErrTOC;
+ case ERROR_GENERATE_COPY:
+ return resources.resErrTOCMedia;
+ case ERROR_PUBLISH:
+ return JavaTools.replaceSubString(resources.resErrPublish, ((CGPublish) obj).cp_URL, URL);
+ case ERROR_EXPORT:
+ case ERROR_PUBLISH_MEDIA:
+ return resources.resErrPublishMedia;
+ case ERROR_CLEANUP:
+ return resources.resErrUnexpected;
+
+ default:
+ return JavaTools.replaceSubString(resources.resErrUnknown, ex.getClass().getName() + "/" + obj.getClass().getName() + "/" + ix, ERROR);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/ProcessErrors.java b/wizards/com/sun/star/wizards/web/ProcessErrors.java
new file mode 100644
index 000000000000..ca6da968654f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ProcessErrors.java
@@ -0,0 +1,48 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+/**
+ * @author rpiterman
+ * Error IDs for errors that can accure
+ * in the interaction with the Process class.
+ */
+public interface ProcessErrors
+{
+
+ public final static int ERROR_MKDIR = 0;
+ public final static int ERROR_EXPORT = 1;
+ public final static int ERROR_EXPORT_MKDIR = 2;
+ public final static int ERROR_DOC_VALIDATE = 3;
+ public final static int ERROR_EXPORT_IO = 4;
+ public final static int ERROR_EXPORT_SECURITY = 5;
+ public final static int ERROR_GENERATE_XSLT = 6;
+ public final static int ERROR_GENERATE_COPY = 7;
+ public final static int ERROR_PUBLISH = 8;
+ public final static int ERROR_PUBLISH_MEDIA = 9;
+ public final static int ERROR_CLEANUP = 10;
+}
diff --git a/wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java b/wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java
new file mode 100644
index 000000000000..3fa3726f2e8f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/ProcessStatusRenderer.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+import com.sun.star.wizards.common.IRenderer;
+
+/**
+ * @author rpiterman
+ * recieves status calls from the status dialog which
+ * apears when the user clicks "create".
+ * allocates strings from the resources to
+ * display the current task status.
+ * (renders the state to resource strings)
+ */
+public class ProcessStatusRenderer implements IRenderer, WebWizardConst
+{
+
+ Map strings = new Hashtable(12);
+
+ public ProcessStatusRenderer(WebWizardDialogResources res)
+ {
+ strings.put(TASK_EXPORT_DOCUMENTS, res.resTaskExportDocs);
+ strings.put(TASK_EXPORT_PREPARE, res.resTaskExportPrepare);
+ strings.put(TASK_GENERATE_COPY, res.resTaskGenerateCopy);
+ strings.put(TASK_GENERATE_PREPARE, res.resTaskGeneratePrepare);
+ strings.put(TASK_GENERATE_XSL, res.resTaskGenerateXsl);
+ strings.put(TASK_PREPARE, res.resTaskPrepare);
+ //strings.put(TASK_PUBLISH , res.resTaskPublish );
+ strings.put(LOCAL_PUBLISHER, res.resTaskPublishLocal);
+ strings.put(ZIP_PUBLISHER, res.resTaskPublishZip);
+ strings.put(FTP_PUBLISHER, res.resTaskPublishFTP);
+
+ strings.put(TASK_PUBLISH_PREPARE, res.resTaskPublishPrepare);
+ strings.put(TASK_FINISH, res.resTaskFinish);
+ }
+
+ public String render(Object object)
+ {
+ return (String) strings.get(object);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/StatusDialog.java b/wizards/com/sun/star/wizards/web/StatusDialog.java
new file mode 100644
index 000000000000..ab1e7a0b6bc7
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/StatusDialog.java
@@ -0,0 +1,305 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XProgressBar;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.IRenderer;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.UnoDialog2;
+import com.sun.star.wizards.ui.event.MethodInvocation;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.ui.event.TaskEvent;
+import com.sun.star.wizards.ui.event.TaskListener;
+
+/**
+ * @author rpiterman
+ * A Class which displays a Status Dialog with status bars.
+ * This can display an X number of bars, to enable the
+ * status display of more complex tasks.
+ *
+ */
+public class StatusDialog extends UnoDialog2 implements TaskListener
+{
+
+ public static final int STANDARD_WIDTH = 240;
+ private XProgressBar progressBar;
+ private XFixedText lblTaskName;
+ private XFixedText lblCounter;
+ private XButton btnCancel;
+ private String[] res;
+ private IRenderer renderer;
+ private boolean enableBreak = false;
+ private boolean closeOnFinish = true;
+ private MethodInvocation finishedMethod;
+ private UnoDialog parent;
+ private boolean finished;
+
+ /**
+ * Note on the argument resource:
+ * This should be a String array containing the followin strings, in the
+ * following order:
+ * dialog title, cancel, close, counter prefix, counter midfix, counter postfix
+ */
+ public StatusDialog(XMultiServiceFactory xmsf, int width, String taskName, boolean displayCount, String[] resources, String hid)
+ {
+ super(xmsf);
+
+ res = resources;
+ if (res.length != 6)
+ {
+ throw new IllegalArgumentException("The resources argument should contain 6 Strings, see Javadoc on constructor."); //display a close button?
+ // if enableBreak == false and closeOnFinsih == false;
+ }
+ boolean b = !enableBreak && !closeOnFinish;
+
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "HelpURL", "Moveable", "Name", "PositionX", "PositionY", "Step", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, new Integer(6 + 25 + (b ? 27 : 7)), hid, Boolean.TRUE, "StatusDialog", new Integer(102), new Integer(52), new Integer(0), res[0], new Integer(width)
+ });
+
+ short tabstop = 1;
+
+ lblTaskName = insertLabel("lblTask",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), taskName, new Integer(6), new Integer(6), new Short(tabstop++), new Integer(width * 2 / 3)
+ });
+ lblCounter = insertLabel("lblCounter",
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(8), "", new Integer(width * 2 / 3), new Integer(6), new Short(tabstop++), new Integer(width / 3 - 4)
+ });
+ progressBar = insertProgressBar("progress",
+ new String[]
+ {
+ "Height", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(10), new Integer(6), new Integer(16), new Short(tabstop++), new Integer(width - 12)
+ });
+
+
+ if (b)
+ {
+ btnCancel = insertButton("btnCancel", "performCancel", this,
+ new String[]
+ {
+ "Height", "Label", "PositionX", "PositionY", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(14), res[1], new Integer(width / 2 - 20), new Integer(6 + 25 + 7), new Short(tabstop++), new Integer(40)
+ });
+ }
+
+// xWindow.addWindowListener((XWindowListener)guiEventListener);
+// guiEventListener.add("StatusDialog" ,EVENT_WINDOW_SHOWN, "performRunnable",this);
+
+ }
+
+ private void initProgressBar(Task t)
+ {
+ progressBar.setRange(0, t.getMax());
+ progressBar.setValue(0);
+ }
+
+ private void setStatus(int status)
+ {
+ if (finished)
+ {
+ return;
+ }
+ progressBar.setValue(status);
+ xReschedule.reschedule();
+ }
+
+ public void setLabel(String s)
+ {
+// lblTaskName.setText(s);
+ Helper.setUnoPropertyValue(UnoDialog.getModel(lblTaskName), "Label", s);
+ xReschedule.reschedule();
+ }
+
+ /**
+ * change the max property of the status bar
+ * @param max
+ */
+ private void setMax(int max)
+ {
+ if (finished)
+ {
+ return;
+ }
+ Helper.setUnoPropertyValue(getModel(progressBar), "ProgressValueMax", new Integer(max));
+ }
+
+ /**
+ * initialize the status bar according
+ * to the given event.
+ */
+ public void taskStarted(TaskEvent te)
+ {
+ finished = false;
+ initProgressBar(te.getTask());
+ }
+
+ /**
+ * closes the dialog.
+ */
+ public void taskFinished(TaskEvent te)
+ {
+ finished = true;
+ if (closeOnFinish)
+ {
+// xDialog.endExecute();
+ parent.xWindow.setEnable(true);
+ try
+ {
+ xWindow.setVisible(false);
+ xComponent.dispose();
+ //System.out.println("disposed");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ else
+ {
+ Helper.setUnoPropertyValue(getModel(btnCancel), "Label", res[2]);
+ }
+ }
+
+ /**
+ * changes the status display
+ */
+ public void taskStatusChanged(TaskEvent te)
+ {
+ setMax(te.getTask().getMax());
+ setStatus(te.getTask().getStatus());
+ }
+
+ /**
+ * changes the displayed text.
+ * A renderer is used to render
+ * the task's subtask name to a resource string.
+ */
+ public void subtaskNameChanged(TaskEvent te)
+ {
+ if (renderer != null)
+ {
+ setLabel(renderer.render(te.getTask().getSubtaskName()));
+ }
+ }
+
+ /**
+ * displays the status dialog
+ * @param parent the parent dialog
+ * @param r what to do
+ */
+ public void execute(final UnoDialog parent_, final Task task, String title)
+ {
+ try
+ {
+ this.parent = parent_;
+ Helper.setUnoPropertyValue(this.xDialogModel, "Title", title);
+ try
+ {
+ //TODO change this to another execute dialog method.
+ task.addTaskListener(StatusDialog.this);
+ setMax(10);
+ setStatus(0);
+ setLabel(task.getSubtaskName());
+ parent.xWindow.setEnable(false);
+ setVisible(parent);
+ if (finishedMethod != null)
+ {
+ finishedMethod.invoke();
+ }
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * not supported !
+ */
+ public void performCancel()
+ {//TODO - implement a thread thing here...
+ xWindow.setVisible(false);
+ }
+
+ /**
+ * @return the subTask renderer object
+ */
+ public IRenderer getRenderer()
+ {
+ return renderer;
+ }
+
+ /**
+ * @param renderer
+ */
+ public void setRenderer(IRenderer renderer)
+ {
+ this.renderer = renderer;
+ }
+
+ /**
+ * sets a method to be invoced when the
+ *
+ */
+ public void setFinishedMethod(MethodInvocation mi)
+ {
+ finishedMethod = mi;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/StylePreview.java b/wizards/com/sun/star/wizards/web/StylePreview.java
new file mode 100644
index 000000000000..93507929d84b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/StylePreview.java
@@ -0,0 +1,154 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.web.data.CGStyle;
+
+/**
+ * @author rpiterman
+ * the style preview, which is a OOo Document Preview in
+ * an Image Control.
+ * This class copies the files needed for this
+ * preview from the web wizard work directory
+ * to a given temporary directory, and updates them
+ * on request, according to the current style/background selection
+ * of the user.
+ */
+public class StylePreview
+{
+
+ private FileAccess fileAccess;
+ /**
+ * the destination html url.
+ */
+ public String htmlFilename;
+ /**
+ * the destination css url
+ */
+ private String cssFilename;
+ /**
+ * destination directory
+ */
+ public String tempDir;
+ /**
+ * destination background file url
+ */
+ private String backgroundFilename;
+ /**
+ * web wizard work directory
+ */
+ private String wwRoot;
+
+ /**
+ * copies the html file to the temp directory, and calculates the
+ * destination names of the background and css files.
+ * @param wwRoot is the root directory of the web wizard files (
+ * usually [oo]/share/template/[lang]/wizard/web
+ */
+ public StylePreview(XMultiServiceFactory xmsf, String wwRoot_) throws Exception
+ {
+ fileAccess = new FileAccess(xmsf);
+
+ tempDir = createTempDir(xmsf);
+
+ htmlFilename = FileAccess.connectURLs(tempDir, "wwpreview.html");
+ cssFilename = FileAccess.connectURLs(tempDir, "style.css");
+ backgroundFilename = FileAccess.connectURLs(tempDir, "images/background.gif");
+
+ wwRoot = wwRoot_;
+
+ fileAccess.copy(FileAccess.connectURLs(wwRoot, "preview.html"), htmlFilename);
+ }
+
+ /**
+ * copies the given style and background files to the temporary
+ * directory.
+ * @param style
+ * @param background
+ * @throws Exception
+ */
+ public void refresh(CGStyle style, String background) throws Exception
+ {
+
+ String css = FileAccess.connectURLs(wwRoot, "styles/" + style.cp_CssHref);
+
+ if (background == null || background.equals(""))
+ {
+ //delete the background image
+ if (fileAccess.exists(backgroundFilename, false))
+ {
+ fileAccess.delete(backgroundFilename);
+ }
+ }
+ else
+ {
+ // a solaris bug workaround
+ // TODO
+ //copy the background image to the temp directory.
+ fileAccess.copy(background, backgroundFilename);
+ }
+ //copy the actual css to the temp directory
+ fileAccess.copy(css, cssFilename);
+ }
+
+ public void cleanup()
+ {
+ try
+ {
+ removeTempDir();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * creates a temporary directory.
+ * @param xmsf
+ * @return the url of the new directory.
+ * @throws Exception
+ */
+ private String createTempDir(XMultiServiceFactory xmsf) throws Exception
+ {
+ String tempPath = FileAccess.getOfficePath(xmsf, "Temp", "", "");
+ String s = fileAccess.createNewDir(tempPath, "wwiz");
+ fileAccess.createNewDir(s, "images");
+ return s;
+ }
+
+ /**
+ * deletes/removes the temporary directroy.
+ * @throws Exception
+ */
+ private void removeTempDir() throws Exception
+ {
+ fileAccess.delete(tempDir);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/TOCPreview.java b/wizards/com/sun/star/wizards/web/TOCPreview.java
new file mode 100644
index 000000000000..1fb70a11d4b5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/TOCPreview.java
@@ -0,0 +1,120 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import org.w3c.dom.Document;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.frame.XDispatch;
+import com.sun.star.frame.XFrame;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.util.URL;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.UCB;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGLayout;
+import com.sun.star.wizards.web.data.CGSettings;
+
+/**
+ * @author rpiterman
+ * This class both copies necessary files to
+ * a temporary directory, generates a temporary TOC page,
+ * and opens the generated html document in a web browser,
+ * by default "index.html" (unchangeable).
+ * <br/>
+ * Since the files are both static and dynamic (some are always the same,
+ * while other change according to user choices)
+ * I divide this tasks to two: all necessary
+ * static files, which should not regularily update are copied upon
+ * instanciation.
+ * The TOC is generated in refresh(...);
+ */
+public class TOCPreview
+{
+
+ private String tempDir = null;
+ private XMultiServiceFactory xmsf;
+ private FileAccess fileAccess;
+ private WebWizardDialogResources resources;
+ private URL openHyperlink;
+ private XDispatch xDispatch;
+ private PropertyValue[] loadArgs;
+ private UCB ucb;
+ private XFrame xFrame;
+
+ /**
+ * @param xmsf_
+ * @param settings web wizard settings
+ * @param res resources
+ * @param tempDir_ destination
+ * @throws Exception
+ */
+ public TOCPreview(XMultiServiceFactory xmsf_, CGSettings settings, WebWizardDialogResources res, String tempDir_, XFrame _xFrame)
+ throws Exception
+ {
+ xFrame = _xFrame;
+ xmsf = xmsf_;
+ resources = res;
+ fileAccess = new FileAccess(xmsf);
+ tempDir = tempDir_;
+ loadArgs = loadArgs(FileAccess.connectURLs(tempDir, "/index.html"));
+ openHyperlink = Desktop.getDispatchURL(xmsf, ".uno:OpenHyperlink");
+ xDispatch = Desktop.getDispatcher(xmsf, xFrame, "_top", openHyperlink);
+ ucb = new UCB(xmsf);
+
+ Process.copyStaticImages(ucb, settings, tempDir);
+ }
+
+ /**
+ * generates a TOC, copies the layout-specific files, and
+ * calles a browser to show "index.html".
+ * @param settings
+ * @throws Exception
+ */
+ public void refresh(CGSettings settings)
+ throws Exception
+ {
+ Document doc = (Document) settings.cp_DefaultSession.createDOM();
+ CGLayout layout = settings.cp_DefaultSession.getLayout();
+ Task task = new Task("", "", 10000);
+ Process.generate(xmsf, layout, doc, fileAccess, tempDir, task);
+ Process.copyLayoutFiles(ucb, fileAccess, settings, layout, tempDir);
+ xDispatch.dispatch(openHyperlink, loadArgs); //Dispatch.dispatch(openHyperlink, loadArgs);
+ }
+
+ private PropertyValue[] loadArgs(String url)
+ {
+ PropertyValue pv = new PropertyValue();
+ pv.Name = "URL";
+ pv.Value = url;
+ return new PropertyValue[]
+ {
+ pv
+ };
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.java b/wizards/com/sun/star/wizards/web/WWD_Events.java
new file mode 100644
index 000000000000..6e8d0f2e614e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WWD_Events.java
@@ -0,0 +1,1305 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import javax.swing.ListModel;
+
+import com.sun.star.awt.KeyEvent;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XKeyListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.ui.UnoDialog;
+import com.sun.star.wizards.ui.event.DataAware;
+import com.sun.star.wizards.ui.event.ListModelBinder;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGPublish;
+import com.sun.star.wizards.web.data.CGSession;
+import com.sun.star.wizards.web.data.CGSessionName;
+
+/**
+ * This class implements the ui-events of the
+ * web wizard.
+ * it is therfore sorted to steps.
+ * not much application-logic here - just plain
+ * methods which react to events.
+ * The only exception are the finish methods with the save
+ * session methods.
+ */
+public abstract class WWD_Events extends WWD_Startup
+{
+
+ private static final short[] EMPTY_SHORT_ARRAY = new short[0];
+ /**
+ * Tracks the current loaded session.
+ * If "" - it means the current session is the default one (empty)
+ * If a session is loaded, this will be the name of the loaded session.
+ */
+ protected String currentSession = "";
+
+ /**
+ * He - my constructor !
+ * I add a window listener, which, when
+ * the window closes, deltes the temp directory.
+ */
+ public WWD_Events(XMultiServiceFactory xmsf) throws Exception
+ {
+ super(xmsf);
+ Create c = new Create();
+ XWindow xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, chkFTP);
+ xWindow.addKeyListener(c);
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, chkLocalDir);
+ xWindow.addKeyListener(c);
+ xWindow = (XWindow) UnoRuntime.queryInterface(XWindow.class, chkZip);
+ xWindow.addKeyListener(c);
+ }
+
+ /* *********************************************************
+ * *******************************************************
+ * EVENT and UI METHODS
+ * *******************************************************
+ * *********************************************************/
+ protected void leaveStep(int nOldStep, int nNewStep)
+ {
+ if (nOldStep == 1 && nNewStep == 2)
+ {
+ // 1. check if the selected session is the same as the current one.
+ }
+ }
+
+ protected void enterStep(int old, int newStep)
+ {
+ if ((old == 1))
+ {
+ String sessionToLoad = "";
+ short[] s = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems");
+ if (s.length == 0 || s[0] == 0)
+ {
+ sessionToLoad = "";
+ }
+ else
+ {
+ sessionToLoad = ((CGSessionName) settings.cp_SavedSessions.getElementAt(s[0])).cp_Name;
+ }
+ if (!sessionToLoad.equals(currentSession))
+ {
+ loadSession(sessionToLoad);
+ }
+ }
+ if (newStep == 5)
+ {
+ }
+ }
+
+ /* *********************************
+ * STEP 1
+ */
+ /**
+ * Called from the Uno event dispatcher when the
+ * user selects a saved session.
+ */
+ public void sessionSelected()
+ {
+ short[] s = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems");
+ setEnabled(btnDelSession, s.length > 0 && s[0] > 0);
+ }
+
+ /**
+ * Ha ! the session should be loaded :-)
+ */
+ public void loadSession(final String sessionToLoad)
+ {
+ try
+ {
+ final StatusDialog sd = getStatusDialog();
+
+ final Task task = new Task("LoadDocs", "", 10);
+
+ sd.execute(this, task, resources.resLoadingSession);
+ task.start();
+
+ setSelectedDoc(EMPTY_SHORT_ARRAY);
+ Helper.setUnoPropertyValue(getModel(lstDocuments), "SelectedItems", EMPTY_SHORT_ARRAY);
+ Helper.setUnoPropertyValue(getModel(lstDocuments), "StringItemList", EMPTY_STRING_ARRAY);
+
+ Object view = null;
+
+ if (sessionToLoad.equals(""))
+ {
+ view = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/DefaultSession", false);
+ }
+ else
+ {
+ view = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", false);
+ view = Configuration.getNode(sessionToLoad, view);
+ }
+
+ CGSession session = new CGSession();
+ session.setRoot(settings);
+ session.readConfiguration(view, CONFIG_READ_PARAM);
+ task.setMax(session.cp_Content.cp_Documents.getSize() * 5 + 7);
+ task.advance(true);
+
+ if (sessionToLoad.equals(""))
+ {
+ setSaveSessionName(session);
+ }
+ mount(session, task, false, sd.xControl);
+
+ checkSteps();
+ currentSession = sessionToLoad;
+
+ while (task.getStatus() <= task.getMax())
+ {
+ task.advance(false);
+ }
+ task.removeTaskListener(sd);
+ }
+ catch (Exception ex)
+ {
+ unexpectedError(ex);
+ }
+
+ try
+ {
+ refreshStylePreview();
+ updateIconsetText();
+ }
+ catch (Exception e)
+ {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ /**
+ * hmm. the user clicked the delete button.
+ */
+ public void delSession()
+ {
+ short[] selected = (short[]) Helper.getUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems");
+ if (selected.length == 0)
+ {
+ return;
+ }
+ if (selected[0] == 0)
+ {
+ return;
+ }
+ boolean confirm = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), resources.resDelSessionConfirm, ErrorHandler.ERROR_QUESTION_NO);
+ if (confirm)
+ {
+ try
+ {
+ String name = (String) settings.cp_SavedSessions.getKey(selected[0]);
+ // first delete the session from the registry/configuration.
+
+ Configuration.removeNode(xMSF, CONFIG_PATH + "/SavedSessions", name);
+
+ // then delete the session from the java-set (settings.cp_SavedSessions)
+ settings.cp_SavedSessions.remove(selected[0]);
+ settings.savedSessions.remove(selected[0] - 1);
+
+ short[] nextSelected = new short[]
+ {
+ (short) 0
+ };
+ // We try to select the same item index again, if possible
+ if (settings.cp_SavedSessions.getSize() > selected[0])
+ {
+ nextSelected[0] = selected[0];
+ }
+ else
+ // this will always be available because
+ // the user can not remove item 0.
+ {
+ nextSelected[0] = (short) (selected[0] - 1); // if the <none> session will be selected, disable the remove button...
+ }
+ if (nextSelected[0] == 0)
+ {
+ Helper.setUnoPropertyValue(getModel(btnDelSession), "Enabled", Boolean.FALSE); // select...
+ }
+ Helper.setUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems", nextSelected);
+
+ //ListModelBinder.fillComboBox(cbSaveSettings, settings.savedSessions.items(), null);
+
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ unexpectedError(ex);
+ }
+ }
+ }
+
+ /* ********************************
+ * STEP 2
+ */
+ /**
+ * A method used by the UnoDataAware attached
+ * to the Documents listbox.
+ * See the concept of the DataAware objects to undestand
+ * why it is there...
+ */
+ public short[] getSelectedDoc()
+ {
+ return selectedDoc;
+ }
+ private static String[] EMPTY_STRING_ARRAY = new String[0];
+
+ /* public void loadSessionSelected() {
+ UIHelper.setEnabled(btnLoadSession,true);
+ UIHelper.setEnabled(btnDelSession,true);
+ }
+ */
+ /**
+ * when the user clicks another document
+ * in the listbox, this method is called,
+ * and couses the display in
+ * the textboxes title,description, author and export format
+ * to change
+ */
+ public void setSelectedDoc(short[] s)
+ {
+ CGDocument oldDoc = getDoc(selectedDoc);
+ CGDocument doc = getDoc(s);
+
+ if (doc == null)
+ {
+ fillExportList(EMPTY_STRING_ARRAY);
+ //I try to avoid refreshing the export list if
+ //the same type of document is chosen.
+ }
+ else if (oldDoc == null || (!oldDoc.appType.equals(doc.appType)))
+ {
+ fillExportList(settings.getExporters(doc.appType));
+ }
+ else; // do nothing
+
+ selectedDoc = s;
+
+ mount(doc, docAware);
+ disableDocUpDown();
+ }
+
+ /**
+ * The user clicks the "Add" button.
+ * This will open a "FileOpen" dialog,
+ * and, if the user chooses more than one file,
+ * will open a status dialog, when validating each document.
+ */
+ public void addDocument()
+ {
+
+ final String[] files = getDocAddDialog().callOpenDialog(true, settings.cp_DefaultSession.cp_InDirectory);
+ if (files == null)
+ {
+ return;
+ }
+ final Task task = new Task("", "", files.length * 5);
+
+ /*
+ * If more than a certain number
+ * of documents have been added,
+ * open the status dialog.
+ */
+ if (files.length > MIN_ADD_FILES_FOR_DIALOG)
+ {
+ StatusDialog sd = getStatusDialog();
+ sd.setLabel(resources.resValidatingDocuments);
+ sd.execute(this, task, resources.prodName); // new LoadDocs( sd.xControl, files, task )
+ LoadDocs oLoadDocs = new LoadDocs(this.xControl, files, task);
+ oLoadDocs.loadDocuments();
+ task.removeTaskListener(sd);
+ }
+ /*
+ * When adding a single document, do not use a
+ * status dialog...
+ */
+ else
+ {
+ LoadDocs oLoadDocs = new LoadDocs(this.xControl, files, task);
+ oLoadDocs.loadDocuments();
+ }
+
+ }
+
+ /**
+ * The user clicked delete.
+ */
+ public void removeDocument()
+ {
+ if (selectedDoc.length == 0)
+ {
+ return;
+ }
+ settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]);
+
+ // update the selected document
+ while (selectedDoc[0] >= getDocsCount())
+ {
+ selectedDoc[0]--; // if there are no documents...
+ }
+ if (selectedDoc[0] == -1)
+ {
+ selectedDoc = EMPTY_SHORT_ARRAY; // update the list to show the right selection.
+ }
+ docListDA.updateUI();
+ // disables all the next steps, if the list of docuemnts
+ // is empty.
+ checkSteps();
+ }
+
+ /**
+ * doc up.
+ */
+ public void docUp()
+ {
+ Object doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(selectedDoc[0]);
+ settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]);
+ settings.cp_DefaultSession.cp_Content.cp_Documents.add(--selectedDoc[0], doc);
+ docListDA.updateUI();
+ disableDocUpDown();
+ }
+
+ /**
+ * doc down
+ */
+ public void docDown()
+ {
+ Object doc = settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(selectedDoc[0]);
+ settings.cp_DefaultSession.cp_Content.cp_Documents.remove(selectedDoc[0]);
+ settings.cp_DefaultSession.cp_Content.cp_Documents.add(++selectedDoc[0], doc);
+ docListDA.updateUI();
+ disableDocUpDown();
+ }
+
+ /* ******************************
+ * STEP 5
+ */
+ /**
+ * invoked when the user clicks "Choose backgrounds" button.
+ */
+ private ImageListDialog bgDialog;
+
+ /**
+ * the user clicked the "backgrounds" button
+ */
+ public void chooseBackground()
+ {
+ try
+ {
+ setEnabled(btnBackgrounds, false);
+ if (bgDialog == null)
+ {
+ bgDialog = new BackgroundsDialog(xMSF, settings.cp_BackgroundImages, resources);
+ bgDialog.createWindowPeer(xControl.getPeer());
+ }
+ bgDialog.setSelected(settings.cp_DefaultSession.cp_Design.cp_BackgroundImage);
+ short i = bgDialog.executeDialog((UnoDialog) WWD_Events.this);
+ if (i == 1) //ok
+ {
+ setBackground(bgDialog.getSelected());
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ setEnabled(btnBackgrounds, true);
+ }
+ }
+
+ /**
+ * invoked when the BackgorundsDialog is "OKed".
+ */
+ public void setBackground(Object background)
+ {
+ if (background == null)
+ {
+ background = "";
+ }
+ settings.cp_DefaultSession.cp_Design.cp_BackgroundImage = (String) background;
+ refreshStylePreview();
+ }
+ private IconsDialog iconsDialog;
+
+ /**
+ * is called when the user clicks "Icon sets" button.
+ *
+ */
+ public void chooseIconset()
+ {
+ try
+ {
+ setEnabled(btnIconSets, false);
+ if (iconsDialog == null)
+ {
+ iconsDialog = new IconsDialog(xMSF, settings.cp_IconSets, resources);
+ iconsDialog.createWindowPeer(xControl.getPeer());
+ }
+
+ iconsDialog.setIconset(settings.cp_DefaultSession.cp_Design.cp_IconSet);
+
+ short i = iconsDialog.executeDialog((UnoDialog) WWD_Events.this);
+ if (i == 1) //ok
+ {
+ setIconset(iconsDialog.getIconset());
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ finally
+ {
+ setEnabled(btnIconSets, true);
+ }
+ }
+
+ /**
+ * invoked when the Iconsets Dialog is OKed.
+ */
+ public void setIconset(String icon)
+ {
+ settings.cp_DefaultSession.cp_Design.cp_IconSet = icon;
+ updateIconsetText();
+ }
+
+ /* ******************************
+ * STEP 7
+ */
+ /**
+ * sets the publishing url of either a local/zip or ftp publisher.
+ * updates the ui....
+ */
+ private CGPublish setPublishUrl(String publisher, String url, int number)
+ {
+ if (url == null)
+ {
+ return null;
+ }
+ CGPublish p = getPublisher(publisher);
+ p.cp_URL = url;
+ p.cp_Publish = true;
+ updatePublishUI(number);
+ p.overwriteApproved = true;
+ return p;
+ }
+
+ /**
+ * updates the ui of a certain publisher
+ * (the text box url)
+ * @param number
+ */
+ private void updatePublishUI(int number)
+ {
+ ((DataAware) pubAware.get(number)).updateUI();
+ ((DataAware) pubAware.get(number + 1)).updateUI();
+ checkPublish();
+ }
+
+ /**
+ * The user clicks the local "..." button.
+ *
+ */
+ public void setPublishLocalDir()
+ {
+ String dir = showFolderDialog("Local destination directory", "", settings.cp_DefaultSession.cp_OutDirectory);
+ //if ok was pressed...
+ setPublishUrl(LOCAL_PUBLISHER, dir, 0);
+
+ }
+
+ /**
+ * The user clicks the "Configure" FTP button.
+ *
+ */
+ public void setFTPPublish()
+ {
+ if (showFTPDialog(getPublisher(FTP_PUBLISHER)))
+ {
+ getPublisher(FTP_PUBLISHER).cp_Publish = true;
+ updatePublishUI(2);
+ }
+ }
+
+ /**
+ * show the ftp dialog
+ * @param pub
+ * @return true if OK was pressed, otherwise false.
+ */
+ private boolean showFTPDialog(CGPublish pub)
+ {
+ try
+ {
+ return getFTPDialog(pub).execute(this) == 1;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return false;
+ }
+ }
+
+ /**
+ * the user clicks the zip "..." button.
+ * Choose a zip file...
+ */
+ public void setZipFilename()
+ {
+ SystemDialog sd = getZipDialog();
+ String zipFile = sd.callStoreDialog(settings.cp_DefaultSession.cp_OutDirectory, resources.resDefaultArchiveFilename);
+ setPublishUrl(ZIP_PUBLISHER, zipFile, 4);
+ getPublisher(ZIP_PUBLISHER).overwriteApproved = true;
+ }
+ private TOCPreview docPreview;
+
+ /**
+ * the user clicks the "Preview" button.
+ */
+ public void documentPreview()
+ {
+ try
+ {
+ if (docPreview == null)
+ {
+ docPreview = new TOCPreview(xMSF, settings, resources, stylePreview.tempDir, myFrame);
+ }
+ docPreview.refresh(settings);
+ }
+ catch (Exception ex)
+ {
+ unexpectedError(ex);
+ }
+ }
+
+ /* **********************
+ * FINISH
+ */
+ /**
+ * This method checks if the given target's path, added the pathExtension argument,
+ * exists, and asks the user what to do about it.
+ * If the user says its all fine, then the target will
+ * be replaced.
+ * @return true if "create" should continue. false if "create" should abort.
+ */
+ private boolean publishTargetApproved()
+ {
+ boolean result = true;
+ // 1. check local publish target
+
+ CGPublish p = getPublisher(LOCAL_PUBLISHER);
+
+ // should publish ?
+ if (p.cp_Publish)
+ {
+ String path = getFileAccess().getPath(p.url, null);
+ // target exists?
+ if (getFileAccess().exists(p.url, false))
+ {
+ //if its a directory
+ if (getFileAccess().isDirectory(p.url))
+ {
+ //check if its empty
+ String[] files = getFileAccess().listFiles(p.url, true);
+ if (files.length > 0)
+ {
+ /* it is not empty :-(
+ * it either a local publisher or an ftp (zip uses no directories
+ * as target...)
+ */
+ String message = JavaTools.replaceSubString(resources.resLocalTragetNotEmpty,
+ path, "%FILENAME");
+ result = AbstractErrorHandler.showMessage(
+ xMSF, xControl.getPeer(), message,
+ ErrorHandler.MESSAGE_WARNING, ErrorHandler.BUTTONS_YES_NO,
+ ErrorHandler.DEF_NO, ErrorHandler.RESULT_YES);
+
+ if (!result)
+ {
+ return result;
+ }
+ }
+ }
+ else
+ {//not a directory, but still exists
+ String message = JavaTools.replaceSubString(resources.resLocalTargetExistsAsfile,
+ path, "%FILENAME");
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+
+ // try to write to the path...
+ }
+ else
+ {
+ // the local target directory does not exist.
+ String message = JavaTools.replaceSubString(resources.resLocalTargetCreate,
+ path, "%FILENAME");
+ try
+ {
+ result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_QUESTION_YES);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ if (!result)
+ {
+ return result;
+ // try to create the directory...
+ }
+ try
+ {
+ getFileAccess().fileAccess.createFolder(p.cp_URL);
+ }
+ catch (Exception ex)
+ {
+ message = JavaTools.replaceSubString(resources.resLocalTargetCouldNotCreate,
+ path, "%FILENAME");
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ }
+ }
+
+ // 2. Check ZIP
+ // should publish ?
+ p = getPublisher(ZIP_PUBLISHER);
+
+ if (p.cp_Publish)
+ {
+
+ String path = getFileAccess().getPath(p.cp_URL, null);
+ // target exists?
+ if (getFileAccess().exists(p.cp_URL, false))
+ {
+ //if its a directory
+ if (getFileAccess().isDirectory(p.cp_URL))
+ {
+ String message = JavaTools.replaceSubString(resources.resZipTargetIsDir,
+ path, "%FILENAME");
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ else
+ {//not a directory, but still exists ( a file...)
+ if (!p.overwriteApproved)
+ {
+ String message = JavaTools.replaceSubString(resources.resZipTargetExists,
+ path, "%FILENAME");
+ result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_QUESTION_YES);
+ if (!result)
+ {
+ return false;
+ }
+ }
+ }
+ }
+ }
+
+ // 3. check FTP
+ p = getPublisher(FTP_PUBLISHER);
+
+ // should publish ?
+ if (p.cp_Publish)
+ {
+
+ String path = getFileAccess().getPath(p.cp_URL, null);
+
+ // target exists?
+ if (getFileAccess().exists(p.url, false))
+ {
+ //if its a directory
+ if (getFileAccess().isDirectory(p.url))
+ {
+ //check if its empty
+ String[] files = getFileAccess().listFiles(p.url, true);
+ if (files.length > 0)
+ {
+ /* it is not empty :-(
+ * it either a local publisher or an ftp (zip uses no directories
+ * as target...)
+ */
+ String message = JavaTools.replaceSubString(resources.resFTPTargetNotEmpty,
+ path, "%FILENAME");
+ result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_QUESTION_CANCEL);
+ if (!result)
+ {
+ return result;
+ }
+ }
+ }
+ else
+ {//not a directory, but still exists (as a file)
+ String message = JavaTools.replaceSubString(resources.resFTPTargetExistsAsfile,
+ path, "%FILENAME");
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+
+ // try to write to the path...
+ }
+ else
+ {
+ // the ftp target directory does not exist.
+ String message = JavaTools.replaceSubString(resources.resFTPTargetCreate,
+ path, "%FILENAME");
+ result = AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_QUESTION_YES);
+ if (!result)
+ {
+ return result;
+ // try to create the directory...
+ }
+ try
+ {
+ getFileAccess().fileAccess.createFolder(p.url);
+ }
+ catch (Exception ex)
+ {
+ message = JavaTools.replaceSubString(resources.resFTPTargetCouldNotCreate,
+ path, "%FILENAME");
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message,
+ ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /*
+ * return false if "create" should be aborted. true if everything is fine.
+ */
+ private boolean saveSession()
+ {
+ try
+ {
+ Object node = null;
+ String name = getSessionSaveName();
+
+ //set documents index field.
+ ListModel docs = settings.cp_DefaultSession.cp_Content.cp_Documents;
+
+ for (int i = 0; i < docs.getSize(); i++)
+ {
+ ((CGDocument) docs.getElementAt(i)).cp_Index = i;
+ }
+ Object conf = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", true);
+ // first I check if a session with the given name exists
+ try
+ {
+ node = Configuration.getNode(name, conf);
+ if (node != null)
+ {
+ if (!AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(),
+ JavaTools.replaceSubString(resources.resSessionExists, name, "${NAME}"),
+ ErrorHandler.ERROR_NORMAL_IGNORE))
+ {
+ return false; //remove the old session
+ }
+ }
+ Configuration.removeNode(conf, name);
+
+ }
+ catch (NoSuchElementException nsex)
+ {
+ }
+
+ settings.cp_DefaultSession.cp_Index = 0;
+ node = Configuration.addConfigNode(conf, name);
+ settings.cp_DefaultSession.cp_Name = name;
+ settings.cp_DefaultSession.writeConfiguration(node, CONFIG_READ_PARAM);
+ settings.cp_SavedSessions.reindexSet(conf, name, "Index");
+ Configuration.commit(conf);
+
+ // now I reload the sessions to actualize the list/combo boxes load/save sessions.
+ settings.cp_SavedSessions.clear();
+
+ Object confView = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH + "/SavedSessions", false);
+ settings.cp_SavedSessions.readConfiguration(confView, CONFIG_READ_PARAM);
+
+ settings.cp_LastSavedSession = name;
+ currentSession = name;
+ // now save the name of the last saved session...
+
+ settings.cp_LastSavedSession = name;
+
+ // TODO add the <none> session...
+ prepareSessionLists();
+ ListModelBinder.fillList(lstLoadSettings, settings.cp_SavedSessions.items(), null);
+ ListModelBinder.fillComboBox(cbSaveSettings, settings.savedSessions.items(), null);
+ selectSession();
+
+ currentSession = settings.cp_LastSavedSession;
+
+ return true;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return false;
+ }
+ }
+
+ private String targetStringFor(String publisher)
+ {
+ CGPublish p = getPublisher(publisher);
+ if (p.cp_Publish)
+ {
+ return "\n" + getFileAccess().getPath(p.cp_URL, null);
+ }
+ else
+ {
+ return "";
+ }
+ }
+
+ /**
+ * this method will be called when the Status Dialog
+ * is hidden.
+ * It checks if the "Process" was successfull, and if so,
+ * it closes the wizard dialog.
+ */
+ public void finishWizardFinished()
+ {
+ if (process.getResult())
+ {
+ String targets =
+ targetStringFor(LOCAL_PUBLISHER) +
+ targetStringFor(ZIP_PUBLISHER) +
+ targetStringFor(FTP_PUBLISHER);
+ String message = JavaTools.replaceSubString(resources.resFinishedSuccess, targets, "%FILENAME");
+
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), message, ErrorHandler.ERROR_MESSAGE);
+ if (exitOnCreate)
+ {
+ this.xDialog.endExecute();
+ }
+ }
+ else
+ {
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(), resources.resFinishedNoSuccess, ErrorHandler.ERROR_WARNING);
+ }
+ }
+
+ public void cancel()
+ {
+ xDialog.endExecute();
+ }
+ private Process process;
+ private boolean exitOnCreate = true;
+
+ /**
+ * the user clicks the finish/create button.
+ */
+ public boolean finishWizard()
+ {
+ finishWizard(true);
+ return true;
+ }
+
+ /**
+ * finish the wizard
+ * @param exitOnCreate_ should the wizard close after
+ * a successfull create.
+ * Default is true,
+ * I have a hidden feature which enables false here
+ */
+ public void finishWizard(boolean exitOnCreate_)
+ {
+
+ exitOnCreate = exitOnCreate_;
+
+ /**
+ * First I check if ftp password was set, if not - the ftp dialog pops up...
+ * This may happen when a session is loaded, since the
+ * session saves the ftp url and username, but not the password.
+ */
+ final CGPublish p = getPublisher(FTP_PUBLISHER);
+ // if ftp is checked, and no proxies are set, and password is empty...
+ if (p.cp_Publish && (!proxies) && (p.password == null || p.password.equals("")))
+ {
+ if (showFTPDialog(p))
+ {
+ updatePublishUI(2);
+ //now continue...
+ finishWizard2();
+ }
+ }
+ else
+ {
+ finishWizard2();
+ }
+ }
+
+ /**
+ * this method is only called
+ * if ftp-password was eather set, or
+ * the user entered one in the FTP Dialog which
+ * popped up when clicking "Create".
+ *
+ */
+ private void finishWizard2()
+ {
+
+ CGPublish p = getPublisher(LOCAL_PUBLISHER);
+ p.url = p.cp_URL;
+
+ /*
+ * zip publisher is using another url form...
+ */
+ p = getPublisher(ZIP_PUBLISHER);
+ //replace the '%' with '%25'
+ String url1 = JavaTools.replaceSubString(p.cp_URL, "%25", "%");
+ //replace all '/' with '%2F'
+ url1 = JavaTools.replaceSubString(url1, "%2F", "/");
+
+ p.url = "vnd.sun.star.zip://" + url1 + "/";
+
+ /*
+ * and now ftp...
+ */
+ p = getPublisher(FTP_PUBLISHER);
+ p.url = FTPDialog.getFullURL(p);
+
+
+ /* first we check the publishing targets. If they exist we warn and ask
+ * what to do. a False here means the user said "cancel" (or rather: clicked...)
+ */
+ if (!publishTargetApproved())
+ {
+ return;
+ /*
+ * In order to save the session correctly,
+ * I return the value of the ftp publisher cp_Publish
+ * property to its original value...
+ */
+ }
+ p.cp_Publish = __ftp;
+
+ //if the "save settings" checkbox is on...
+ if (isSaveSession())
+ {
+ // if canceled by user
+ if (!saveSession())
+ {
+ return;
+ }
+ }
+ else
+ {
+ settings.cp_LastSavedSession = "";
+ }
+ try
+ {
+ Object conf = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH, true);
+ Configuration.set(
+ settings.cp_LastSavedSession,
+ "LastSavedSession", conf);
+ Configuration.commit(conf);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ /*
+ * again, if proxies are on, I disable ftp before the creation process
+ * starts.
+ */
+ if (proxies)
+ {
+ p.cp_Publish = false;
+
+ /*
+ * There is currently a bug, which crashes office when
+ * writing folders to an existing zip file, after deleting
+ * its content, so I "manually" delete it here...
+ */
+ }
+ p = getPublisher(ZIP_PUBLISHER);
+ if (getFileAccess().exists(p.cp_URL, false))
+ {
+ getFileAccess().delete(p.cp_URL);
+ }
+ try
+ {
+
+ ErrorHandler eh = new ProcessErrorHandler(xMSF, xControl.getPeer(), resources);
+
+ process = new Process(settings, xMSF, eh);
+
+ StatusDialog pd = getStatusDialog();
+
+ pd.setRenderer(new ProcessStatusRenderer(resources));
+ pd.execute(this, process.myTask, resources.prodName); //process,
+ process.runProcess();
+ finishWizardFinished();
+ process.myTask.removeTaskListener(pd);
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ /**
+ * implements a hidden feature for "finishing" without
+ * closing the wizard.
+ * press "&%" quite fast when the focus is on one
+ * of the last steps' checkboxes.
+ * @author rp143992
+ */
+ private class Create implements XKeyListener
+ {
+
+ long time = 0;
+ int count = 0;
+
+ /* (non-Javadoc)
+ * @see com.sun.star.awt.XKeyListener#keyPressed(com.sun.star.awt.KeyEvent)
+ */
+ public void keyPressed(KeyEvent ke)
+ {
+ if (ke.KeyChar == '&')
+ {
+ time = System.currentTimeMillis();
+ }
+ else if (ke.KeyChar == '%' && ((System.currentTimeMillis() - time) < 300))
+ {
+ Boolean b = (Boolean) getControlProperty("btnWizardFinish", "Enabled");
+ if (b.booleanValue())
+ {
+ finishWizard(false);
+ }
+ }
+ }
+
+ public void keyReleased(KeyEvent arg0)
+ {
+ }
+
+ public void disposing(EventObject arg0)
+ {
+ }
+ }
+
+ /**
+ * is called on the WindowHidden event,
+ * deletes the temporary directory.
+ */
+ public void cleanup()
+ {
+
+
+ try
+ {
+ dpStylePreview.dispose();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ stylePreview.cleanup();
+
+ try
+ {
+ if (bgDialog != null)
+ {
+ bgDialog.xComponent.dispose();
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ if (iconsDialog != null)
+ {
+ iconsDialog.xComponent.dispose();
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ if (ftpDialog != null)
+ {
+ ftpDialog.xComponent.dispose();
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ xComponent.dispose();
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ try
+ {
+ //XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, myDocument);
+ //if (xCloseable != null)
+ // xCloseable.close(false);
+
+ XCloseable xCloseable = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, myFrame);
+ if (xCloseable != null)
+ {
+ xCloseable.close(false);
+ }
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+
+ public class LoadDocs
+ {
+
+ private XControl xC;
+ String[] files;
+ Task task;
+
+ public LoadDocs(XControl xC_, String[] files_, Task task_)
+ {
+ xC = xC_;
+ files = files_;
+ task = task_;
+ }
+
+ public void loadDocuments()
+ {
+ //LogTaskListener lts = new LogTaskListener();
+ //task.addTaskListener(lts);
+
+// task.start();
+
+ // where the documents are added to in the list (offset)
+ int offset = (getSelectedDoc().length > 0 ? selectedDoc[0] + 1 : getDocsCount());
+
+ /* if the user chose one file, the list starts at 0,
+ * if he chose more than one, the first entry is a directory name,
+ * all the others are filenames.
+ */
+ int start = (files.length > 1 ? 1 : 0);
+ /*
+ * Number of documents failed to validate.
+ */
+ int failed = 0;
+
+ // store the directory
+ settings.cp_DefaultSession.cp_InDirectory = start == 1 ? files[0] : FileAccess.getParentDir(files[0]);
+
+ /*
+ * Here i go through each file, and validate it.
+ * If its ok, I add it to the ListModel/ConfigSet
+ */
+ for (int i = start; i < files.length; i++)
+ {
+ CGDocument doc = new CGDocument();
+ doc.setRoot(settings);
+
+ doc.cp_URL = (start == 0) ? files[i] : FileAccess.connectURLs(files[0], files[i]);
+
+ /* so - i check each document and if it is ok I add it.
+ * The failed variable is used only to calculate the place to add -
+ * Error reporting to the user is (or should (-: )done in the checkDocument(...) method
+ */
+ if (checkDocument(doc, task, xC))
+ {
+ settings.cp_DefaultSession.cp_Content.cp_Documents.add(offset + i - failed - start, doc);
+ }
+ else
+ {
+ failed++;
+ }
+ }
+
+ // if any documents where added,
+ // set the first one to be the current-selected document.
+ if (files.length > start + failed)
+ {
+ setSelectedDoc(new short[]
+ {
+ (short) offset
+ });
+ }
+ // update the ui...
+ docListDA.updateUI();
+ // this enables/disables the next steps.
+ // when no documents in the list, all next steps are disabled
+ checkSteps();
+ /* a small insurance that the status dialog will
+ * really close...
+ */
+ while (task.getStatus() < task.getMax())
+ {
+ task.advance(false);
+ }
+ }
+ };
+}
+
diff --git a/wizards/com/sun/star/wizards/web/WWD_General.java b/wizards/com/sun/star/wizards/web/WWD_General.java
new file mode 100644
index 000000000000..551a4b1437f2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WWD_General.java
@@ -0,0 +1,393 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.util.XStringSubstitution;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.ui.event.ListModelBinder;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGFilter;
+import com.sun.star.wizards.web.data.CGPublish;
+import com.sun.star.wizards.web.data.CGSettings;
+
+/**
+ * @author rpiterman
+ * This class implements general methods, used by different sub-classes (either WWD_Sturtup, or WWD_Events)
+ * or both.
+ */
+public abstract class WWD_General extends WebWizardDialog
+{
+
+ private FileAccess fileAccess;
+ private SystemDialog docAddDialog, folderDialog, favIconDialog, zipDialog;
+ protected FTPDialog ftpDialog;
+ protected CGSettings settings;
+ /**
+ * true if proxies are on, which means, ftp is disabled.
+ */
+ protected boolean proxies;
+ private XStringSubstitution xStringSubstitution;
+
+ protected StatusDialog getStatusDialog()
+ {
+
+ StatusDialog statusDialog = new StatusDialog(xMSF, StatusDialog.STANDARD_WIDTH, resources.resLoadingSession, false, new String[]
+ {
+ resources.prodName, "", "", "", "", ""
+ }, HelpIds.getHelpIdString(HID0_STATUS_DIALOG));
+ try
+ {
+ statusDialog.createWindowPeer(xControl.getPeer());
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+
+ return statusDialog;
+ }
+
+ /**
+ * @param xmsf
+ */
+ public WWD_General(XMultiServiceFactory xmsf)
+ {
+ super(xmsf);
+ xStringSubstitution = SystemDialog.createStringSubstitution(xmsf);
+ }
+
+ /*
+ * File Dialog methods
+ */
+ protected SystemDialog getDocAddDialog()
+ {
+ //if (docAddDialog == null) {
+ docAddDialog = SystemDialog.createOpenDialog(xMSF);
+ for (int i = 0; i < settings.cp_Filters.getSize(); i++)
+ {
+ CGFilter f = ((CGFilter) settings.cp_Filters.getElementAt(i));
+ docAddDialog.addFilter(
+ JavaTools.replaceSubString(f.cp_Name, resources.prodName, "%PRODNAME"), f.cp_Filter, i == 0);
+ }
+ //docAddDialog.addFilter(resources.resSODocs, "*.oxt;*.sxw;*.sxc;*.sxd;*.sxi;*.sdw;*.sdc;*.sdd;*.sdi;*.sda;*.sdp" ,true);
+ //docAddDialog.addFilter(resources.resMSDocs, "*.doc;*.xls;*.ppt;*.pps",false);
+ //docAddDialog.addFilter(resources.resImages, "*.jpg;*.gif;*.png;*.bmp;*.tiff;*.jpeg;*.jpe",false);
+ //docAddDialog.addFilter(resources.resAllFiles,"*.*",false);
+ //}
+ return docAddDialog;
+ }
+
+ protected SystemDialog getZipDialog()
+ {
+ if (zipDialog == null)
+ {
+ zipDialog = SystemDialog.createStoreDialog(xMSF);
+ zipDialog.addFilter(resources.resZipFiles, "*.zip", true);
+ }
+ return zipDialog;
+ }
+
+ protected FTPDialog getFTPDialog(CGPublish pub)
+ {
+ if (ftpDialog == null)
+ {
+ try
+ {
+ ftpDialog = new FTPDialog(xMSF, pub);
+ ftpDialog.createWindowPeer(xControl.getPeer());
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ return ftpDialog;
+ }
+
+ protected String showFolderDialog(String title, String description, String dir)
+ {
+ if (folderDialog == null)
+ {
+ folderDialog = SystemDialog.createFolderDialog(xMSF);
+ }
+ return folderDialog.callFolderDialog(title, description, dir);
+ }
+
+ protected FileAccess getFileAccess()
+ {
+ if (fileAccess == null)
+ {
+ try
+ {
+ fileAccess = new FileAccess(xMSF);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ return fileAccess;
+ }
+
+ /**
+ * returns the document specified
+ * by the given short array.
+ * @param s
+ * @return
+ */
+ protected CGDocument getDoc(short[] s)
+ {
+ if (s.length == 0)
+ {
+ return null;
+ }
+ else if (settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() <= s[0])
+ {
+ return null;
+ }
+ else
+ {
+ return (CGDocument) settings.cp_DefaultSession.cp_Content.cp_Documents.getElementAt(s[0]);
+ }
+ }
+
+ /**
+ * how many documents are in the list?
+ * @return the number of documents in the docs list.
+ */
+ protected int getDocsCount()
+ {
+ return settings.cp_DefaultSession.cp_Content.cp_Documents.getSize();
+ }
+
+ /**
+ * fills the export listbox.
+ * @param listContent
+ */
+ protected void fillExportList(Object[] listContent)
+ {
+ ListModelBinder.fillList(lstDocTargetType, listContent, null);
+ }
+
+ /**
+ * returns a publisher object for the given name
+ * @param name one of the WebWizardConst constants : FTP
+ * @return
+ */
+ protected CGPublish getPublisher(String name)
+ {
+ return (CGPublish) settings.cp_DefaultSession.cp_Publishing.getElement(name);
+ }
+
+ /**
+ * @return true if the checkbox "save session" is checked.
+ */
+ protected boolean isSaveSession()
+ {
+ return (((Number) Helper.getUnoPropertyValue(
+ getModel(chkSaveSettings), "State")).intValue() == 1);
+ }
+
+ /**
+ * @return the name to save the session (step 7)
+ */
+ protected String getSessionSaveName()
+ {
+ return (String) Helper.getUnoPropertyValue(
+ getModel(cbSaveSettings), "Text");
+ }
+
+ /**
+ * This method checks the status of the wizards and
+ * enables or disables the 'next' and the 'create' button.
+ *
+ */
+ protected void checkSteps()
+ {
+ /* first I check the document list.
+ * If it is empty, then step3 and on are disabled.
+ */
+ if (checkDocList())
+ {
+ checkPublish();
+ }
+ }
+
+ /**
+ * enables/disables the steps 3 to 7)
+ * @param enabled true = enabled, false = disabled.
+ */
+ private void enableSteps(boolean enabled)
+ {
+
+ if (!enabled && !isStepEnabled(3))
+ {
+ return;
+ /*
+ * disbale steps 3-7
+ */
+ }
+ for (int i = 3; i < 8; i++)
+ {
+ setStepEnabled(i, enabled, true);
+ /* in this place i just disable the finish button.
+ * later, in the checkPublish, which is only performed if
+ * this one is true, it will be enabled (if the check
+ * is positive)
+ */
+ }
+ if (!enabled)
+ {
+ enableFinishButton(false);
+ }
+ }
+
+ /**
+ * Checks if the documents list is
+ * empty. If it is, disables the steps 3-7, and the
+ * create button.
+ * @return
+ */
+ protected boolean checkDocList()
+ {
+ if (settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() == 0)
+ {
+ enableSteps(false);
+ return false;
+ }
+ else
+ {
+ enableSteps(true);
+ return true;
+ }
+ }
+
+ /**
+ * check if the save-settings input is ok.
+ * (eather the checkbox is unmarked, or,
+ * if it is marked, a session name exists.
+ *
+ */
+ public boolean checkSaveSession()
+ {
+ return (!isSaveSession() ||
+ !getSessionSaveName().equals(""));
+
+ }
+
+ /**
+ * @return false if this publisher is not active, or, if it
+ * active, returns true if the url is not empty...
+ * if the url is empty, throws an exception
+ */
+ private boolean checkPublish(String s, Object text, String property)
+ {
+ CGPublish p = getPublisher(s);
+ if (p.cp_Publish)
+ {
+ String url = (String) Helper.getUnoPropertyValue(getModel(text), property);
+ if ((url == null) || (url.equals("")))
+ {
+ throw new IllegalArgumentException();
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ /**
+ *
+ * @return false either if publishing input is wrong or there
+ * are no publishing targets chosen. returns true when at least
+ * one target is chosen, *and* all
+ * which are chosen are legal.
+ * If proxies are on, ftp publisher is ignored.
+ */
+ private boolean checkPublish_()
+ {
+ try
+ {
+ return (checkPublish(LOCAL_PUBLISHER, txtLocalDir, "Text") | (!proxies && checkPublish(FTP_PUBLISHER, lblFTP, "Label")) | checkPublish(ZIP_PUBLISHER, txtZip, "Text")) && checkSaveSession();
+ }
+ catch (IllegalArgumentException ex)
+ {
+ return false;
+ }
+ }
+
+ /**
+ * This method checks if the publishing
+ * input is ok, and enables and disables
+ * the 'create' button.
+ * public because it is called from
+ * an event listener object.
+ */
+ public void checkPublish()
+ {
+ enableFinishButton(checkPublish_());
+ }
+
+ /**
+ * shows a message box "Unexpected Error... " :-)
+ * @param ex
+ */
+ protected void unexpectedError(Exception ex)
+ {
+ ex.printStackTrace();
+ XWindowPeer peer = xControl.getPeer();
+ AbstractErrorHandler.showMessage(xMSF, peer, resources.resErrUnexpected, ErrorHandler.ERROR_PROCESS_FATAL);
+ }
+
+ /**
+ * substitutes path variables with the corresponding values.
+ * @param path a path, which might contain OOo path variables.
+ * @return the path, after substituing path variables.
+ */
+ protected String substitute(String path)
+ {
+ try
+ {
+ return xStringSubstitution.substituteVariables(path, false);
+ }
+ catch (Exception ex)
+ {
+ return path;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/WWD_Startup.java b/wizards/com/sun/star/wizards/web/WWD_Startup.java
new file mode 100644
index 000000000000..200f70a32383
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WWD_Startup.java
@@ -0,0 +1,984 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+//import com.sun.star.awt.ItemEvent;
+//import com.sun.star.awt.XItemListener;
+import java.io.FileNotFoundException;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Vector;
+
+import com.sun.star.awt.VclWindowPeerAttribute;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XItemListener;
+import com.sun.star.awt.XWindow;
+import com.sun.star.awt.XWindowPeer;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XFrame;
+import com.sun.star.frame.XModel;
+import com.sun.star.lang.EventObject;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.wizards.common.ConfigSet;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.SystemDialog;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.ui.DocumentPreview;
+import com.sun.star.wizards.ui.event.DataAware;
+import com.sun.star.wizards.ui.event.ListModelBinder;
+import com.sun.star.wizards.ui.event.RadioDataAware;
+import com.sun.star.wizards.ui.event.SimpleDataAware;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.ui.event.UnoDataAware;
+import com.sun.star.wizards.web.data.CGContent;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGIconSet;
+import com.sun.star.wizards.web.data.CGPublish;
+import com.sun.star.wizards.web.data.CGSession;
+import com.sun.star.wizards.web.data.CGSessionName;
+import com.sun.star.wizards.web.data.CGSettings;
+import com.sun.star.wizards.web.data.CGStyle;
+
+/**
+ * Web Wizard Dialog implementation : Startup.
+ * This class contains the startup implementation and session mounting methods.<p/>
+ * <h2> Data Aware Concept </h2>
+ * <p> I use DataAware objects, which synchronize
+ * UI and Data. A DataAware object a kind of interface
+ * between a Value and a UI element.
+ * </P>
+ * <p>
+ * A Value is either a JavaBean property with
+ * a Getter and a Setter or a public class Memeber.
+ * </P>
+ * When the UI Control changes, the Value changes correspondingly.
+ * This depends on settings a Listener which calls the updateData()
+ * method od the DataAware object.
+ * When the Value changes, the UI Control changes respopndingly.
+ * This also depends on settings a Listener which calls the updateUI()
+ * method of the DataAware object.
+ * </P>
+ * <P>
+ * here I use only UI Listeners, and keep calling
+ * the updateUI() method whenever I change the Value.
+ * </P>
+ * To contain the Data, I use the Configuration Data Objects
+ * which read themselfs out of the Configuration. they are all located under
+ * the data package.
+ * <p/>
+ * Different groups of DataAware objects are grouped into vectors.
+ * Each group (all elements of a vector) uses the same DataObject,
+ * so when I change the underlying dataObject, I change the whole vector's DataObject,
+ * thus actualizing UI.<br/>
+ * This is what happends when a session loads: I Load the session into
+ * a tree of DataObjects, and change the DataAware's DataObject. <br/>
+ * One could also look at this as a kind of "View-Model" relationship.
+ * The controls are the View, The DataObjects are the Model, containing the
+ * Data rad directly from the configuration, and the DataAware objects
+ * are the controller inbetween.
+ *
+ * @author rpiterman
+ *
+ */
+public abstract class WWD_Startup extends WWD_General
+{
+
+ SimpleDataAware sda = null;
+ /**
+ * This is currently not used.
+ * It should have been a Listener which invoces
+ * an Update to the Preview-Document, only
+ * We did not implement the live-preview document,
+ * so this became obsolete.
+ */
+ protected DataAware.Listener refresh;
+ /**
+ * Is called whenever a field is changed which
+ * could affect the "create" button enable state,
+ * like publishing-checkboxes, save-session check- and textbox.
+ */
+ protected DataAware.Listener checkPublish = new CheckPublish();
+ /**
+ * The Vector containing DataAware objects
+ * which relay on the selected document
+ * as DataObject (or Model).
+ */
+ protected List docAware = new Vector();
+ /**
+ * The Vector containing DataAware objects
+ * which relay on the session's generalInfo
+ * Object (CGSession.cp_GeneralInfo) as
+ * DataObject (or model).
+ */
+ protected List genAware = new Vector();
+ /**
+ * The vector containing DataAware objectscm25npd ..
+ * which relay on the session's Design Object
+ * (CGSession.cp_Design) as DataObject
+ * (or model).
+ *
+ */
+ protected List designAware = new Vector();
+ /**
+ * A Vector containig the DataAware objects
+ * which relay on Publishing Objects.
+ * Differently from other Vectors, each
+ * DataAware object in this Vector relays
+ * on a <b>different</b> CGPublish object,
+ * So they are handled with more care.
+ */
+ protected List pubAware = new Vector(3);
+ /**
+ * The DataAware object which handles
+ * the documents-list events.
+ * This will call the set/getDocument() method
+ * implemented in WWD_General.
+ */
+ protected UnoDataAware docListDA;
+ /**
+ * DataAware object which synchronizes the session
+ * name in step 7 with the CGSession.cp_Name
+ */
+ protected UnoDataAware sessionNameDA;
+ /**
+ * Binds a ListModel to the UnoControlListBox.
+ */
+ protected ListModelBinder docsBinder;
+ /**
+ * a DocumentPreview object is
+ * the UI OO Document preview
+ * in the Dialog
+ */
+ protected DocumentPreview dpStylePreview;
+ /**
+ * An Object that implements the
+ * File-copy and refresh of the
+ * style preview
+ */
+ protected StylePreview stylePreview;
+ /**
+ * the currently selected document.
+ */
+ protected short[] selectedDoc = new short[0];
+ /**
+ * If ftp proxies are on, ftp is disabled, and
+ * the true/false of the FTP publisher is set to false.
+ * In order to save it correctly when saving the session
+ * at the end, the original loaded value is saved to this variable;
+ */
+ boolean __ftp;
+ /**
+ * When the wizard starts, a new document opens.
+ * The backgroundDoc memeber contains the TextDocument
+ * instance used for that purpose.
+ */
+ protected XFrame myFrame;
+
+
+ /* ******************************************
+ * ****************************************
+ * General Methods
+ * ****************************************
+ * ****************************************** */
+
+ /*
+ * GENERAL Initialization methods
+ */
+ /**
+ * He - my constructor !
+ * I call/do here in this order: <br/>
+ * Check if ftp http proxy is set, and warn user he can not use
+ * ftp if it is.<br/>
+ * draw NaviBar and steps 1 to 7, incl. Step X,
+ * which is the Layouts ImageList on step 3.<br/>
+ * load the settings from the configuration. <br/>
+ * set the default save session name to the first
+ * available one (sessionX or something like that). <br/>
+ * set the Layouts ImageList ListModel, and call
+ * its "create()" method. <br/>
+ * check the content (documents) specified in the default session.<br/>
+ * fill the list boxes (saved sessions, styles, combobox save session). <br/>
+ * make data aware. <br/>
+ * updateUI (refreshes the display to crrespond to the data in
+ * the default session.)<br/>
+ * fill the documents listbox. <br/>
+ * if proxies are set, disable the ftp controls in step 7.
+ */
+ public WWD_Startup(XMultiServiceFactory xmsf) throws Exception
+ {
+ super(xmsf);
+
+ proxies = getOOProxies();
+
+ String soTemplateDir = FileAccess.getOfficePath(xmsf, "Template", "share", "/wizard");
+
+ String exclamationURL = FileAccess.connectURLs(soTemplateDir, "../wizard/bitmap/caution_16.png");
+ this.drawNaviBar();
+ this.buildStep1();
+ this.buildStep2();
+ this.buildStep3();
+
+ this.buildStep4();
+ this.buildStep5();
+ this.buildStep6();
+ this.buildStep7(proxies, exclamationURL);
+ buildStepX();
+
+ this.xMSF = xMSF;
+ XDesktop xDesktop = Desktop.getDesktop(xMSF);
+ myFrame = OfficeDocument.createNewFrame(xMSF, this);
+ Object doc = OfficeDocument.createNewDocument(myFrame, "swriter", false, true);
+
+ loadSettings(doc);
+ setSaveSessionName(settings.cp_DefaultSession);
+
+ ilLayouts.setListModel(settings.cp_Layouts);
+ ilLayouts.create(this);
+
+ checkContent(settings.cp_DefaultSession.cp_Content, new Task("", "", 99999), this.xControl);
+
+ //saved sessions, styles, combobox save session.
+ // also set the chosen saved session...
+ fillLists();
+ makeDataAware();
+ // change the display to correspond to the current session.
+ updateUI();
+ // fill the documents listbox.
+ mount(settings.cp_DefaultSession.cp_Content);
+
+
+ if (proxies)
+ {
+ setEnabled(btnFTP, false);
+ setEnabled(chkFTP, false);
+ }
+ }
+
+ /**
+ * return true if http proxies or other proxies
+ * which do not enable ftp to function correctly are set.
+ * @return true if (http) proxies are on.
+ * @throws Exception
+ */
+ private boolean getOOProxies() throws Exception
+ {
+ Object node = Configuration.getConfigurationRoot(xMSF, "org.openoffice.Inet/Settings", false);
+ int i = Configuration.getInt("ooInetProxyType", node);
+ //System.out.println("WWD:Startup:getOOProxies:" + i);
+ switch (i)
+ {
+ case 0: //no proxies
+ return false;
+ case 2: //http proxies
+ return true;
+ default:
+ return true;
+ }
+ }
+
+ /**
+ * calculates the first available session name,
+ * and sets the current session name to it.
+ * The combobox text in step 7 will be updated
+ * automatically when updateUI() is called.
+ */
+ protected void setSaveSessionName(CGSession session)
+ {
+ int max = 0;
+ int len = resources.resSessionName.length();
+ // traverse between the sessions and find the one that
+ // has the biggest number.
+ for (int i = 0; i < settings.cp_SavedSessions.getSize(); i++)
+ {
+ String sessionName = ((CGSessionName) settings.cp_SavedSessions.getElementAt(i)).cp_Name;
+ if (sessionName.startsWith(resources.resSessionName))
+ {
+ max = max(max, Integer.valueOf(sessionName.substring(len)).intValue());
+ }
+ }
+
+ session.cp_Name = resources.resSessionName + ++max;
+
+ }
+
+ private int max(int i1, int i2)
+ {
+ if (i1 > i2)
+ {
+ return i1;
+ }
+ else
+ {
+ return i2;
+ }
+ }
+
+ /**
+ * fills the road map, and sets the necessary properties,
+ * like MaxStep, Complete, Interactive-
+ * Disables the finbihButton.
+ */
+ private void addRoadMapItems()
+ {
+ insertRoadMapItems(new String[]
+ {
+ resources.resStep1, resources.resStep2, resources.resStep3, resources.resStep4, resources.resStep5, resources.resStep6, resources.resStep7
+ }, new int[]
+ {
+ 1, 2, 3, 4, 5, 6, 7
+ }, new boolean[]
+ {
+ true, true, false, false, false, false, false
+ });
+
+ setRoadmapInteractive(true);
+ setRoadmapComplete(true);
+ setCurrentRoadmapItemID((short) 1);
+ setMaxStep(7);
+ enableFinishButton(false);
+
+ }
+
+ /**
+ * This method goes through all
+ * the DataAware vectors and objects and
+ * calls their updateUI() method.
+ * In response, the UI is synchronized to
+ * the state of the corresponding data objects.
+ *
+ */
+ private void updateUI()
+ {
+ DataAware.updateUI(designAware);
+ DataAware.updateUI(genAware);
+ DataAware.updateUI(pubAware);
+ sessionNameDA.updateUI();
+ checkPublish();
+ }
+
+ private XFrame getFrame(Object model)
+ {
+ XModel xmodel = (XModel) UnoRuntime.queryInterface(XModel.class, model);
+ return xmodel.getCurrentController().getFrame();
+ }
+
+ /**
+ * create the peer, add roadmap,
+ * add roadmap items, add style-preview,
+ * disable the steps 3 to 7 if no documents are
+ * on the list, and... show the dialog!
+ */
+ public void show()
+ {
+ try
+ {
+
+
+ /* myFrame.initialize(docWindow);
+ * */
+
+ //desktopFrame = Desktop.findAFrame(xMSF, myFrame, desktopFrame);
+
+ //XWindow xContainerWindow = myFrame.getContainerWindow();
+
+ XWindow xContainerWindow = myFrame.getComponentWindow();
+ XWindowPeer xWindowPeer = (XWindowPeer) UnoRuntime.queryInterface(XWindowPeer.class, xContainerWindow);
+
+ createWindowPeer(xWindowPeer);
+
+ addRoadmap();
+ addRoadMapItems();
+ addStylePreview();
+ checkSteps();
+
+ executeDialog(myFrame);
+ removeTerminateListener();
+
+ }
+ catch (java.lang.Exception jexception)
+ {
+ jexception.printStackTrace(System.out);
+ }
+ }
+
+ /**
+ * initializes the style preview.
+ */
+ private void addStylePreview()
+ {
+ try
+ {
+ dpStylePreview = new DocumentPreview(xMSF, imgPreview);
+ stylePreview = new StylePreview(xMSF, settings.workPath);
+ stylePreview.refresh(settings.cp_DefaultSession.getStyle(), settings.cp_DefaultSession.cp_Design.cp_BackgroundImage);
+ dpStylePreview.setDocument(stylePreview.htmlFilename, DocumentPreview.PREVIEW_MODE);
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Loads the web wizard settings from the registry.
+ */
+ private void loadSettings(Object document)
+ {
+ try
+ {
+ // instanciate
+ String[] settingsResources = new String[]
+ {
+ resources.resPages,
+ resources.resSlides,
+ resources.resCreatedTemplate,
+ resources.resUpdatedTemplate,
+ resources.resSizeTemplate
+ };
+
+ settings = new CGSettings(xMSF, settingsResources, document);
+
+ // get configuration view
+ Object confRoot = Configuration.getConfigurationRoot(xMSF, CONFIG_PATH, false);
+ // read
+ settings.readConfiguration(confRoot, CONFIG_READ_PARAM);
+
+ ConfigSet set = settings.cp_DefaultSession.cp_Publishing;
+
+ // now if path variables are used in publisher pathes, they
+ // are getting replaced here...
+ for (int i = 0; i < set.getSize(); i++)
+ {
+ CGPublish p = (CGPublish) set.getElementAt(i);
+ p.cp_URL = substitute(p.cp_URL);
+ }
+
+ // initialize the settings.
+ settings.configure(xMSF);
+
+ // set resource needed for web page.
+
+ // sort the styles alphabetically
+ settings.cp_Styles.sort(new StylesComparator());
+
+ prepareSessionLists();
+
+ if (proxies)
+ {
+ __ftp = getPublisher(FTP_PUBLISHER).cp_Publish;
+ getPublisher(FTP_PUBLISHER).cp_Publish = false;
+
+ }
+
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ protected void prepareSessionLists()
+ {
+ // now copy the sessions list...
+ Object[] sessions = settings.cp_SavedSessions.items();
+ settings.savedSessions.clear();
+ for (int i = 0; i < sessions.length; i++)
+ {
+ settings.savedSessions.add(i, sessions[i]); // add an empty session to the saved session list which apears in step 1
+ }
+ CGSessionName sn = new CGSessionName();
+ sn.cp_Name = resources.resSessionNameNone;
+ settings.cp_SavedSessions.add(0, sn);
+ }
+
+ /**
+ * fills the saved session list, the styles list,
+ * and save session combo box.
+ * Also set the selected "load" session to the last session
+ * which was saved.
+ */
+ private void fillLists()
+ {
+ // fill the saved session list.
+ ListModelBinder.fillList(lstLoadSettings, settings.cp_SavedSessions.items(), null);
+
+ // set the selected session to load. (step 1)
+ selectSession();
+
+ // fill the styles list.
+ ListModelBinder.fillList(lstStyles, settings.cp_Styles.items(), null);
+
+ // fill the save session combobox (step 7)
+ ListModelBinder.fillComboBox(cbSaveSettings, settings.savedSessions.items(), null);
+
+
+ }
+
+ protected void selectSession()
+ {
+ int selectedSession = 0;
+ if (settings.cp_LastSavedSession != null && !settings.cp_LastSavedSession.equals(""))
+ {
+
+ Object ses = settings.cp_SavedSessions.getElement(settings.cp_LastSavedSession);
+ if (ses != null)
+ {
+ selectedSession = settings.cp_SavedSessions.getIndexOf(ses);
+ }
+ }
+ Helper.setUnoPropertyValue(getModel(lstLoadSettings), "SelectedItems", new short[]
+ {
+ (short) selectedSession
+ });
+
+ }
+
+ public class SimpleDataawareUpdater implements XItemListener
+ {
+ /* (non-Javadoc)
+ * @see com.sun.star.lang.XEventListener#disposing(com.sun.star.lang.EventObject)
+ */
+
+ public void disposing(EventObject arg0)
+ {
+ // TODO Auto-generated method stub
+ }
+
+ public void itemStateChanged(com.sun.star.awt.ItemEvent itemEvent)
+ {
+ sda.updateData();
+ //TODO xf uncomment
+ //refresh.eventPerformed(ie);
+ }
+ }
+
+ /**
+ * attaches to each ui-data-control (like checkbox, groupbox or
+ * textbox, no buttons though), a DataObject's JavaBean Property,
+ * or class member.
+ */
+ private void makeDataAware()
+ {
+ //page 1
+ new ListModelBinder(lstLoadSettings, settings.cp_SavedSessions);
+
+ //page 2 : document properties
+
+ docListDA = (UnoDataAware) UnoDataAware.attachListBox(this, "SelectedDoc", lstDocuments, null, false);
+ docListDA.disableControls(new Object[]
+ {
+ /*btnDocDown, btnDocUp, */
+ lnDocsInfo, btnRemoveDoc, lblDocTitle, txtDocTitle, lblDocInfo, txtDocInfo, lblDocAuthor, txtDocAuthor, lblDocExportFormat, lstDocTargetType
+ });
+ docListDA.updateUI();
+
+ CGDocument doc = new CGDocument(); //dummy
+
+ docsBinder = new ListModelBinder(lstDocuments, settings.cp_DefaultSession.cp_Content.cp_Documents);
+
+ docAware.add(UnoDataAware.attachEditControl(doc, "cp_Title", txtDocTitle, refresh, true));
+ docAware.add(UnoDataAware.attachEditControl(doc, "cp_Description", txtDocInfo, refresh, true));
+ docAware.add(UnoDataAware.attachEditControl(doc, "cp_Author", txtDocAuthor, refresh, true));
+ docAware.add(UnoDataAware.attachListBox(doc, "Exporter", lstDocTargetType, refresh, false));
+
+ //page 3 : Layout
+ Object design = settings.cp_DefaultSession.cp_Design;
+ sda = new SimpleDataAware(design, new DataAware.PropertyValue("Layout", design), ilLayouts, new DataAware.PropertyValue("Selected", ilLayouts));
+ ilLayouts.addItemListener(new SimpleDataawareUpdater());
+ designAware.add(sda);
+
+ //page 4 : layout 2
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayDescription", chbDocDesc, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayAuthor", chbDocAuthor, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayCreateDate", chkDocCreated, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayUpdateDate", chkDocChanged, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayFilename", chkDocFilename, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayFileFormat", chkDocFormat, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayFormatIcon", chkDocFormatIcon, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplayPages", chkDocPages, refresh, true));
+ designAware.add(UnoDataAware.attachCheckBox(design, "cp_DisplaySize", chkDocSize, refresh, true));
+ designAware.add(RadioDataAware.attachRadioButtons(settings.cp_DefaultSession.cp_Design, "cp_OptimizeDisplaySize", new Object[]
+ {
+ optOptimize640x480, optOptimize800x600, optOptimize1024x768
+ }, refresh, true));
+
+
+ //page 5 : Style
+ /*
+ * note : on style change, i do not call here refresh ,but rather on
+ * a special method which will perform some display, background and Iconsets changes.
+ */
+ designAware.add(UnoDataAware.attachListBox(settings.cp_DefaultSession.cp_Design, "Style", lstStyles, null, false));
+
+ //page 6 : site general props
+ genAware.add(UnoDataAware.attachEditControl(settings.cp_DefaultSession.cp_GeneralInfo, "cp_Title", txtSiteTitle, refresh, true));
+ genAware.add(UnoDataAware.attachEditControl(settings.cp_DefaultSession.cp_GeneralInfo, "cp_Description", txtSiteDesc, refresh, true));
+
+ genAware.add(UnoDataAware.attachDateControl(settings.cp_DefaultSession.cp_GeneralInfo, "CreationDate", dateSiteCreated, refresh, false));
+ genAware.add(UnoDataAware.attachDateControl(settings.cp_DefaultSession.cp_GeneralInfo, "UpdateDate", dateSiteUpdate, refresh, false));
+ genAware.add(UnoDataAware.attachEditControl(settings.cp_DefaultSession.cp_GeneralInfo, "cp_Email", txtEmail, refresh, true));
+ genAware.add(UnoDataAware.attachEditControl(settings.cp_DefaultSession.cp_GeneralInfo, "cp_Copyright", txtCopyright, refresh, true));
+
+ //page 7 : publishing
+
+ pubAware(LOCAL_PUBLISHER, chkLocalDir, txtLocalDir, false);
+ pubAware(FTP_PUBLISHER, chkFTP, lblFTP, true);
+ pubAware(ZIP_PUBLISHER, chkZip, txtZip, false);
+
+ sessionNameDA = UnoDataAware.attachEditControl(settings.cp_DefaultSession, "cp_Name", cbSaveSettings, null, true);
+
+ //cleanup when exiting wizard.
+ //guiEventListener.add("WebWizardDialog",EventNames.EVENT_WINDOW_HIDDEN, "cleanup", this);
+ //xWindow.addWindowListener((XWindowListener)guiEventListener);
+ }
+
+ /**
+ * A help method to attach a Checkbox and a TextBox to
+ * a CGPublish object properties/class members,
+ * @param publish
+ * @param checkbox
+ * @param textbox
+ */
+ private void pubAware(String publish, Object checkbox, Object textbox, boolean isLabel)
+ {
+ Object p = settings.cp_DefaultSession.cp_Publishing.getElement(publish);
+ UnoDataAware uda = UnoDataAware.attachCheckBox(p, "cp_Publish", checkbox, checkPublish, true);
+ uda.setInverse(true);
+
+ uda.disableControls(new Object[]
+ {
+ textbox
+ });
+ pubAware.add(uda);
+ pubAware.add(
+ isLabel ? UnoDataAware.attachLabel(p, "URL", textbox, checkPublish, false)
+ : UnoDataAware.attachEditControl(p, "URL", textbox, checkPublish, false));
+
+ }
+
+ /*
+ * Session load methods
+ * (are used both on the start of the wizard and
+ * when the user loads a session)
+ */
+ /**
+ * Is called when a new session/settings is
+ * loaded. <br/>
+ * Checks the documents (validate), fills the
+ * documents listbox, and changes the
+ * DataAware data objects to the
+ * new session's objects.<br/>
+ * Task advances 4 times in the mount method,
+ * and ??? times for each document in the session.
+ *
+ */
+ protected void mount(CGSession session, Task task, boolean refreshStyle, XControl xC)
+ {
+ /* This checks the documents. If the user
+ * chooses to cancel, the session is not loaded.
+ */
+ checkContent(session.cp_Content, task, xC);
+
+ settings.cp_DefaultSession = session;
+
+ mount(session.cp_Content);
+
+ task.advance(true);
+
+ mount(session.cp_Design, designAware);
+ mount(session.cp_GeneralInfo, genAware);
+
+ task.advance(true);
+
+ mount(session.cp_Publishing.getElement(LOCAL_PUBLISHER), 0);
+ mount(session.cp_Publishing.getElement(FTP_PUBLISHER), 1);
+ mount(session.cp_Publishing.getElement(ZIP_PUBLISHER), 2);
+
+ task.advance(true);
+
+ sessionNameDA.setDataObject(session, true);
+ Helper.setUnoPropertyValue(getModel(chkSaveSettings), "State", new Short((short) 1));
+ docListDA.updateUI();
+
+ task.advance(true);
+
+ if (refreshStyle)
+ {
+ refreshStylePreview();
+ updateIconsetText();
+ }
+
+ //updateUI();
+ }
+
+ /**
+ * used to mount the publishing objects. This is somehow cryptic -
+ * there are 6 DataAware objects, 2 for each Publishing Object (CGPublish).
+ * All 6 reside on one Vector (pubAware).
+ * Since, otherwise than other DataAware objects, different
+ * Objects on the same Vector need different DataObjectBinding,
+ * I use this method...
+ * @param data the CGPublish object
+ * @param i the number of the object (0 = local, 1 = ftp, 2 = zip)
+ */
+ private void mount(Object data, int i)
+ {
+ ((DataAware) pubAware.get(i * 2)).setDataObject(data, true);
+ ((DataAware) pubAware.get(i * 2 + 1)).setDataObject(data, true);
+ }
+
+ /**
+ * Fills the documents listbox.
+ * @param root the CGContent object
+ * that contains the documents (a ListModel)
+ */
+ private void mount(CGContent root)
+ {
+ ListModelBinder.fillList(lstDocuments, root.cp_Documents.items(), null);
+ docsBinder.setListModel(root.cp_Documents);
+ disableDocUpDown();
+
+ }
+
+ /**
+ * changes the DataAwares Objects' (in
+ * the gioen list) DataObject to the
+ * @param data
+ * @param list
+ */
+ protected void mount(Object data, List list)
+ {
+ for (int i = 0; i < list.size(); i++)
+ {
+ ((DataAware) list.get(i)).setDataObject(data, true);
+ }
+ }
+
+ /**
+ * Checks if the document specified by the given CGDocument
+ * object (cp_URL) exists. Calls also the validate(...) method
+ * of this document.
+ * If the document does not exist, it asks the user whether
+ * to specify a new URL, or forget about this document.
+ * @param doc the document to check.
+ * @param task while loading a session, a status is
+ * displayed, using the Task object to monitor progress.
+ * @return true if the document is ok (a file exists in the given url).
+ */
+ protected boolean checkDocument(CGDocument doc, Task task, XControl xC)
+ {
+ try
+ {
+ doc.validate(xMSF, task);
+ return true;
+ }
+ catch (FileNotFoundException ex)
+ {
+
+ int relocate = SystemDialog.showMessageBox(xMSF, xC.getPeer(), "WarningBox", VclWindowPeerAttribute.YES_NO + VclWindowPeerAttribute.DEF_NO, getFileAccess().getPath(doc.cp_URL, "") + "\n\n" + resources.resSpecifyNewFileLocation);
+
+ if (relocate == 2)
+ {
+ String[] file = getDocAddDialog().callOpenDialog(false, FileAccess.getParentDir(doc.cp_URL));
+ if (file == null)
+ {
+ return false;
+ }
+ else
+ {
+ doc.cp_URL = file[0];
+ return checkDocument(doc, task, xC);
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+ catch (IllegalArgumentException iaex)
+ {
+ //file is a directory
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(),
+ JavaTools.replaceSubString(resources.resErrIsDirectory,
+ getFileAccess().getPath(doc.cp_URL, ""),
+ "%FILENAME"),
+ ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+ catch (Exception exp)
+ {
+ //something went wrong.
+ exp.printStackTrace();
+ AbstractErrorHandler.showMessage(xMSF, xControl.getPeer(),
+ JavaTools.replaceSubString(resources.resErrDocValidate,
+ getFileAccess().getPath(doc.cp_URL, ""),
+ "%FILENAME"), ErrorHandler.ERROR_PROCESS_FATAL);
+ return false;
+ }
+
+ }
+
+ /**
+ * Checks the documents contained in this content.
+ * @param content
+ * @param task
+ */
+ private void checkContent(CGContent content, Task task, XControl xC)
+ {
+ for (int i = 0; i < content.cp_Documents.getSize(); i++)
+ {
+ if (!checkDocument((CGDocument) content.cp_Documents.getElementAt(i), task, xC))
+ // I use here 'i--' since, when the document is removed
+ // an index change accures
+ {
+ content.cp_Documents.remove(i--);
+ /*for (Iterator i = content.cp_Contents.childrenMap.values().iterator(); i.hasNext();)
+ checkContent((CGContent)i.next(),task);*/
+ }
+ }
+ }
+
+ /**
+ * A Listener which is called whenever
+ * a Publish checkbox/textbox state changes, and
+ * changes the "create" button enable state accordingly.
+ * @author rpiterman
+ */
+ private class CheckPublish implements DataAware.Listener
+ {
+
+ public void eventPerformed(Object event)
+ {
+ checkPublish();
+ }
+ }
+
+ /**
+ * Disables/enables the docUpDown buttons (step 2)
+ * according to the currently selected document
+ * (no doc selected - both disbaled, last doc selected,
+ * down disabled and so on...)
+ *
+ */
+ protected void disableDocUpDown()
+ {
+ try
+ {
+ setEnabled(btnDocUp, selectedDoc.length == 0 ? Boolean.FALSE : (selectedDoc[0] == 0 ? Boolean.FALSE : Boolean.TRUE));
+ setEnabled(btnDocDown, selectedDoc.length == 0 ? Boolean.FALSE : (selectedDoc[0] + 1 < settings.cp_DefaultSession.cp_Content.cp_Documents.getSize() ? Boolean.TRUE : Boolean.FALSE));
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ void updateBackgroundText()
+ {
+ String bg = settings.cp_DefaultSession.cp_Design.cp_BackgroundImage;
+ if (bg == null || bg.equals(""))
+ {
+ bg = resources.resBackgroundNone;
+ }
+ else
+ {
+ bg = FileAccess.getPathFilename(getFileAccess().getPath(bg, null));
+ }
+ Helper.setUnoPropertyValue(getModel(txtBackground), "Label", bg);
+ }
+
+ void updateIconsetText()
+ {
+ String iconset = settings.cp_DefaultSession.cp_Design.cp_IconSet;
+ String iconsetName;
+ if (iconset == null || iconset.equals(""))
+ {
+ iconsetName = resources.resIconsetNone;
+ }
+ else
+ {
+ CGIconSet is = (CGIconSet) settings.cp_IconSets.getElement(iconset);
+ if (is == null)
+ {
+ iconsetName = resources.resIconsetNone;
+ }
+ else
+ {
+ iconsetName = is.cp_Name;
+ }
+ }
+
+ Helper.setUnoPropertyValue(getModel(txtIconset), "Label", iconsetName);
+ }
+
+ /**
+ * refreshes the style preview.
+ * I also call here "updateBackgroundtext", because always
+ * when the background is changed, this method
+ * has to be called, so I am walking on the safe side here...
+ */
+ public void refreshStylePreview()
+ {
+ try
+ {
+ updateBackgroundText();
+ stylePreview.refresh(settings.cp_DefaultSession.getStyle(), settings.cp_DefaultSession.cp_Design.cp_BackgroundImage);
+ dpStylePreview.reload(xMSF);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private class StylesComparator implements Comparator
+ {
+
+ /* (non-Javadoc)
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2)
+ {
+ // TODO Auto-generated method stub
+ if (o1 instanceof CGStyle && o2 instanceof CGStyle)
+ {
+ return ((CGStyle) o1).cp_Name.compareTo(
+ ((CGStyle) o2).cp_Name);
+ }
+ else
+ {
+ throw new IllegalArgumentException("Cannot compare objects which are not CGStyle.");
+ }
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/WWHID.java b/wizards/com/sun/star/wizards/web/WWHID.java
new file mode 100644
index 000000000000..6d9a4882fcb9
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WWHID.java
@@ -0,0 +1,186 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on May 5, 2004
+ *
+ * TODO To change the template for this generated file go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+package com.sun.star.wizards.web;
+
+/**
+ * @author rp143992
+ *
+ * TODO To change the template for this generated type comment go to
+ * Window - Preferences - Java - Code Generation - Code and Comments
+ */
+public interface WWHID
+{
+
+// web wizard general controls
+ public static final int HID0_WEBWIZARD = 34200 + 0;
+ public static final int HID0_HELP = 34200 + 1;
+ public static final int HID0_NEXT = 34200 + 2;
+ public static final int HID0_PREV = 34200 + 3;
+ public static final int HID0_CREATE = 34200 + 4;
+ public static final int HID0_CANCEL = 34200 + 5;
+ public static final int HID0_STATUS_DIALOG = 34200 + 6;// step 1
+ public static final int HID1_LST_SESSIONS = 34200 + 7;
+ public static final int HID1_BTN_DEL_SES = 34200 + 9;// step 2
+ public static final int HID2_LST_DOCS = 34200 + 10;
+ public static final int HID2_BTN_ADD_DOC = 34200 + 11;
+ public static final int HID2_BTN_REM_DOC = 34200 + 12;
+ public static final int HID2_BTN_DOC_UP = 34200 + 13;
+ public static final int HID2_BTN_DOC_DOWN = 34200 + 14;
+ public static final int HID2_TXT_DOC_TITLE = 34200 + 15;
+ public static final int HID2_TXT_DOC_DESC = 34200 + 16;
+ public static final int HID2_TXT_DOC_AUTHOR = 34200 + 17;
+ public static final int HID2_LST_DOC_EXPORT = 34200 + 18;
+ public static final int HID2_STATUS_ADD_DOCS = 34200 + 19;// step 3
+ public static final int HID3_IL_LAYOUTS_IMG1 = 34200 + 20;
+ public static final int HID3_IL_LAYOUTS_IMG2 = 34200 + 21;
+ public static final int HID3_IL_LAYOUTS_IMG3 = 34200 + 22;
+ public static final int HID3_IL_LAYOUTS_IMG4 = 34200 + 23;
+ public static final int HID3_IL_LAYOUTS_IMG5 = 34200 + 24;
+ public static final int HID3_IL_LAYOUTS_IMG6 = 34200 + 25;
+ public static final int HID3_IL_LAYOUTS_IMG7 = 34200 + 26;
+ public static final int HID3_IL_LAYOUTS_IMG8 = 34200 + 27;
+ public static final int HID3_IL_LAYOUTS_IMG9 = 34200 + 28;
+ public static final int HID3_IL_LAYOUTS_IMG10 = 34200 + 29;
+ public static final int HID3_IL_LAYOUTS_IMG11 = 34200 + 30;
+ public static final int HID3_IL_LAYOUTS_IMG12 = 34200 + 31;
+ public static final int HID3_IL_LAYOUTS_IMG13 = 34200 + 32;
+ public static final int HID3_IL_LAYOUTS_IMG14 = 34200 + 33;
+ public static final int HID3_IL_LAYOUTS_IMG15 = 34200 + 34;// step 4
+ public static final int HID4_CHK_DISPLAY_FILENAME = 34200 + 35;
+ public static final int HID4_CHK_DISPLAY_DESCRIPTION = 34200 + 36;
+ public static final int HID4_CHK_DISPLAY_AUTHOR = 34200 + 37;
+ public static final int HID4_CHK_DISPLAY_CR_DATE = 34200 + 38;
+ public static final int HID4_CHK_DISPLAY_UP_DATE = 34200 + 39;
+ public static final int HID4_CHK_DISPLAY_FORMAT = 34200 + 40;
+ public static final int HID4_CHK_DISPLAY_F_ICON = 34200 + 41;
+ public static final int HID4_CHK_DISPLAY_PAGES = 34200 + 42;
+ public static final int HID4_CHK_DISPLAY_SIZE = 34200 + 43;
+ public static final int HID4_GRP_OPTIMAIZE_640 = 34200 + 44;
+ public static final int HID4_GRP_OPTIMAIZE_800 = 34200 + 45;
+ public static final int HID4_GRP_OPTIMAIZE_1024 = 34200 + 46;// step 5
+ public static final int HID5_LST_STYLES = 34200 + 47;
+ public static final int HID5_BTN_BACKGND = 34200 + 48;
+ public static final int HID5_BTN_ICONS = 34200 + 49;// step 6
+ public static final int HID6_TXT_SITE_TITLE = 34200 + 50;
+ public static final int HID6_TXT_SITE_ICON = 34200 + 51;
+ public static final int HID6_BTN_SITE_ICON = 34200 + 52;
+ public static final int HID6_TXT_SITE_DESC = 34200 + 53;
+ public static final int HID6_TXT_SITE_KEYWRDS = 34200 + 54;
+ public static final int HID6_DATE_SITE_CREATED = 34200 + 55;
+ public static final int HID6_DATE_SITE_UPDATED = 34200 + 56;
+ public static final int HID6_NUM_SITE_REVISTS = 34200 + 57;
+ public static final int HID6_TXT_SITE_EMAIL = 34200 + 58;
+ public static final int HID6_TXT_SITE_COPYRIGHT = 34200 + 59;// step 7
+ public static final int HID7_BTN_PREVIEW = 34200 + 60;
+ public static final int HID7_CHK_PUBLISH_LOCAL = 34200 + 61;
+ public static final int HID7_TXT_LOCAL = 34200 + 62;
+ public static final int HID7_BTN_LOCAL = 34200 + 63;
+ public static final int HID7_CHK_PUBLISH_ZIP = 34200 + 64;
+ public static final int HID7_TXT_ZIP = 34200 + 65;
+ public static final int HID7_BTN_ZIP = 34200 + 66;
+ public static final int HID7_CHK_PUBLISH_FTP = 34200 + 67;
+ //public static final int HID7_TXT_FTP = 34200 + 68 ;
+ public static final int HID7_BTN_FTP = 34200 + 69;
+ public static final int HID7_CHK_SAVE = 34200 + 70;
+ public static final int HID7_TXT_SAVE = 34200 + 71;// web wizard backgrounds dialog
+ public static final int HID_BG = 34200 + 90;
+ public static final int HID_BG_BTN_OTHER = 34200 + 91;
+ public static final int HID_BG_BTN_NONE = 34200 + 92;
+ public static final int HID_BG_BTN_OK = 34200 + 93;
+ public static final int HID_BG_BTN_CANCEL = 34200 + 94;
+ public static final int HID_BG_BTN_BACK = 34200 + 95;
+ public static final int HID_BG_BTN_FW = 34200 + 96;
+ public static final int HID_BG_BTN_IMG1 = 34200 + 97;
+ public static final int HID_BG_BTN_IMG2 = 34200 + 98;
+ public static final int HID_BG_BTN_IMG3 = 34200 + 99;
+ public static final int HID_BG_BTN_IMG4 = 34200 + 100;
+ public static final int HID_BG_BTN_IMG5 = 34200 + 101;
+ public static final int HID_BG_BTN_IMG6 = 34200 + 102;
+ public static final int HID_BG_BTN_IMG7 = 34200 + 103;
+ public static final int HID_BG_BTN_IMG8 = 34200 + 104;
+ public static final int HID_BG_BTN_IMG9 = 34200 + 105;
+ public static final int HID_BG_BTN_IMG10 = 34200 + 106;
+ public static final int HID_BG_BTN_IMG11 = 34200 + 107;
+ public static final int HID_BG_BTN_IMG12 = 34200 + 108;
+ public static final int HID_BG_BTN_IMG13 = 34200 + 109;
+ public static final int HID_BG_BTN_IMG14 = 34200 + 100;
+ public static final int HID_BG_BTN_IMG15 = 34200 + 111;
+ public static final int HID_BG_BTN_IMG16 = 34200 + 112;// web wizard icons sets dialog
+ public static final int HID_IS = 41000 + 0;
+ public static final int HID_IS_ICONSETS = 41000 + 1;
+ public static final int HID_IS_BTN_NONE = 41000 + 2;
+ public static final int HID_IS_BTN_OK = 41000 + 3;
+ public static final int HID_IS_BTN_IMG1 = 41000 + 5;
+ public static final int HID_IS_BTN_IMG2 = 41000 + 6;
+ public static final int HID_IS_BTN_IMG3 = 41000 + 7;
+ public static final int HID_IS_BTN_IMG4 = 41000 + 8;
+ public static final int HID_IS_BTN_IMG5 = 41000 + 9;
+ public static final int HID_IS_BTN_IMG6 = 41000 + 10;
+ public static final int HID_IS_BTN_IMG7 = 41000 + 11;
+ public static final int HID_IS_BTN_IMG8 = 41000 + 12;
+ public static final int HID_IS_BTN_IMG9 = 41000 + 13;
+ public static final int HID_IS_BTN_IMG10 = 41000 + 14;
+ public static final int HID_IS_BTN_IMG11 = 41000 + 15;
+ public static final int HID_IS_BTN_IMG12 = 41000 + 16;
+ public static final int HID_IS_BTN_IMG13 = 41000 + 17;
+ public static final int HID_IS_BTN_IMG14 = 41000 + 18;
+ public static final int HID_IS_BTN_IMG15 = 41000 + 19;
+ public static final int HID_IS_BTN_IMG16 = 41000 + 20;
+ public static final int HID_IS_BTN_IMG17 = 41000 + 21;
+ public static final int HID_IS_BTN_IMG18 = 41000 + 22;
+ public static final int HID_IS_BTN_IMG19 = 41000 + 23;
+ public static final int HID_IS_BTN_IMG20 = 41000 + 24;
+ public static final int HID_IS_BTN_IMG21 = 41000 + 25;
+ public static final int HID_IS_BTN_IMG22 = 41000 + 26;
+ public static final int HID_IS_BTN_IMG23 = 41000 + 27;
+ public static final int HID_IS_BTN_IMG24 = 41000 + 28;
+ public static final int HID_IS_BTN_IMG25 = 41000 + 29;
+ public static final int HID_IS_BTN_IMG26 = 41000 + 30;
+ public static final int HID_IS_BTN_IMG27 = 41000 + 31;
+ public static final int HID_IS_BTN_IMG28 = 41000 + 32;
+ public static final int HID_IS_BTN_IMG29 = 41000 + 33;
+ public static final int HID_IS_BTN_IMG30 = 41000 + 34;
+ public static final int HID_IS_BTN_IMG31 = 41000 + 35;
+ public static final int HID_IS_BTN_IMG32 = 41000 + 36;
+// web wizard ftp dialog
+ public static final int HID_FTP = 41000 + 40;
+ public static final int HID_FTP_SERVER = 41000 + 41;
+ public static final int HID_FTP_USERNAME = 41000 + 42;
+ public static final int HID_FTP_PASS = 41000 + 43;
+ public static final int HID_FTP_TEST = 41000 + 44;
+ public static final int HID_FTP_TXT_PATH = 41000 + 45;
+ public static final int HID_FTP_BTN_PATH = 41000 + 46;
+ public static final int HID_FTP_OK = 41000 + 47;
+ public static final int HID_FTP_CANCEL = 41000 + 48;
+}
diff --git a/wizards/com/sun/star/wizards/web/WebWizard.java b/wizards/com/sun/star/wizards/web/WebWizard.java
new file mode 100644
index 000000000000..87ea5217b11e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WebWizard.java
@@ -0,0 +1,72 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Start1.java
+ *
+ * Created on 19. September 2003, 12:09
+ */
+package com.sun.star.wizards.web;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Desktop;
+
+/**
+ * The last class in the WebWizard Dialog class hirarchy.
+ * Has no functionality, is just nice to have it instanciated.
+ * @author rpiterman
+ */
+public class WebWizard extends WWD_Events
+{
+
+ /**
+ * @param xmsf
+ */
+ public WebWizard(XMultiServiceFactory xmsf) throws Exception
+ {
+ super(xmsf);
+ }
+
+ public static void main(String args[])
+ {
+
+ String ConnectStr =
+ "uno:socket,host=localhost,port=8100;urp,negotiate=0,forcesynchronous=1;StarOffice.ServiceManager";
+ try
+ {
+ XMultiServiceFactory xmsf = Desktop.connect(ConnectStr);
+ WebWizard ww = new WebWizard(xmsf);
+ ww.show();
+ ww.cleanup();
+
+ }
+ catch (Exception exception)
+ {
+ exception.printStackTrace(System.out);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/WebWizardConst.java b/wizards/com/sun/star/wizards/web/WebWizardConst.java
new file mode 100644
index 000000000000..7ef17f134458
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WebWizardConst.java
@@ -0,0 +1,73 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+public interface WebWizardConst
+{
+
+ public static final String LSTLOADSETTINGS_ITEM_CHANGED = "sessionSelected"; // "lstLoadSettingsItemChanged";
+ public static final String BTNLOADSESSION_ACTION_PERFORMED = "loadSession"; // "btnLoadSessionActionPerformed";
+ public static final String BTNDELSESSION_ACTION_PERFORMED = "delSession"; // "btnDelSessionActionPerformed";
+ public static final String BTNADDDOC_ACTION_PERFORMED = "addDocument"; // "btnAddDocActionPerformed";
+ public static final String BTNREMOVEDOC_ACTION_PERFORMED = "removeDocument"; // "btnRemoveDocActionPerformed";
+ public static final String BTNDOCUP_ACTION_PERFORMED = "docUp"; // "btnDocUpActionPerformed";
+ public static final String BTNDOCDOWN_ACTION_PERFORMED = "docDown"; // "btnDocDownActionPerformed";
+ public static final String LSTSTYLES_ITEM_CHANGED = "refreshStylePreview"; // "lstStylesItemChanged";
+ public static final String BTNBACKGROUNDS_ACTION_PERFORMED = "chooseBackground"; // "btnBackgroundsActionPerformed";
+ public static final String BTNICONSETS_ACTION_PERFORMED = "chooseIconset"; // "btnIconSetsActionPerformed";
+ public static final String BTNFAVICON_ACTION_PERFORMED = "chooseFavIcon"; // "btnFavIconActionPerformed";
+ public static final String BTNPREVIEW_ACTION_PERFORMED = "documentPreview"; // "btnPreviewActionPerformed";
+ public static final String BTNFTP_ACTION_PERFORMED = "setFTPPublish"; // "btnFTPActionPerformed";
+ public static final String CHKLOCALDIR_ITEM_CHANGED = "checkPublish"; // "chkLocalDirItemChanged";
+ public static final String CHKSAVESETTINGS_ITEM_CHANGED = "checkPublish"; // "chkSaveSettingsItemChanged";
+ public static final String TXTSAVESETTINGS_TEXT_CHANGED = "checkPublish"; // "txtSaveSettingsTextChanged";
+ public static final String BTNLOCALDIR_ACTION_PERFORMED = "setPublishLocalDir"; // "btnLocalDirActionPerformed";
+ public static final String BTNZIP_ACTION_PERFORMED = "setZipFilename";// "btnZipActionPerformed";
+ public static final String CONFIG_PATH = "/org.openoffice.Office.WebWizard/WebWizard";
+ public static final String CONFIG_READ_PARAM = "cp_";
+ public static final String TASK = "WWIZ";
+ public static final String TASK_PREPARE = "t-prep";
+ public static final String LOCAL_PUBLISHER = "local";
+ public static final String FTP_PUBLISHER = "ftp";
+ public static final String ZIP_PUBLISHER = "zip";
+ public static final String TASK_EXPORT = "t_exp";
+ public static final String TASK_EXPORT_PREPARE = "t_exp_prep";
+ public static final String TASK_EXPORT_DOCUMENTS = "t_exp_docs";
+ public static final String TASK_GENERATE_PREPARE = "t_gen_prep";
+ public static final String TASK_GENERATE_XSL = "t_gen_x";
+ public static final String TASK_GENERATE_COPY = "t_gen_cp";
+ public static final String TASK_PUBLISH_PREPARE = "t_pub_prep";
+ //public static final String TASK_PUBLISH = "t_pub";
+ public static final String TASK_FINISH = "t_fin";
+ /**
+ * when the user adds more than this number
+ * of documents to the list, a status dialog opens.
+ */
+ public static final int MIN_ADD_FILES_FOR_DIALOG = 2;
+}
+ \ No newline at end of file
diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialog.java b/wizards/com/sun/star/wizards/web/WebWizardDialog.java
new file mode 100644
index 000000000000..23adc86dfca1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WebWizardDialog.java
@@ -0,0 +1,931 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.awt.FontDescriptor;
+import com.sun.star.awt.Size;
+import com.sun.star.awt.XButton;
+import com.sun.star.awt.XCheckBox;
+import com.sun.star.awt.XComboBox;
+import com.sun.star.awt.XControl;
+import com.sun.star.awt.XDateField;
+import com.sun.star.awt.XFixedText;
+import com.sun.star.awt.XListBox;
+import com.sun.star.awt.XRadioButton;
+import com.sun.star.awt.XTextComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Helper;
+import com.sun.star.wizards.common.HelpIds;
+import com.sun.star.wizards.ui.ImageList;
+import com.sun.star.wizards.ui.UIConsts;
+import com.sun.star.wizards.ui.WizardDialog;
+import com.sun.star.wizards.web.data.CGLayout;
+
+/**
+ * This class is generated Automatically....
+ * bla bla bla
+ */
+public abstract class WebWizardDialog extends WizardDialog implements WebWizardConst, UIConsts, WWHID
+{
+ //GUI Components as Class members.
+ XFixedText lbIntroTitle;
+ XFixedText lblIntroduction;
+ //Fixed Line
+ XControl lnLoadSettings;
+ XFixedText lblLoadSettings;
+ XListBox lstLoadSettings;
+ XButton btnDelSession;
+ XFixedText lblContentTitle;
+ //Fixed Line
+ XFixedText lblSiteContent;
+ XListBox lstDocuments;
+ XButton btnAddDoc;
+ XButton btnRemoveDoc;
+ XButton btnDocUp;
+ XButton btnDocDown;
+ //Fixed Line
+ XControl lnDocsInfo;
+ XFixedText lblDocTitle;
+ XTextComponent txtDocTitle;
+ XFixedText lblDocInfo;
+ XTextComponent txtDocInfo;
+ XFixedText lblDocAuthor;
+ XTextComponent txtDocAuthor;
+ XFixedText lblDocExportFormat;
+ XListBox lstDocTargetType;
+ XFixedText lblLayoutTitle;
+ XFixedText lblLayouts;
+ /*XFixedText Label1;
+ //Image Control
+ XControl ImageControl1;
+ //Image Control
+ XControl ImageControl3;
+ //Image Control
+ XControl ImageControl4;
+ //Image Control
+ XControl ImageControl5;
+ //Image Control
+ XControl ImageControl6;
+ XFixedText Label3;
+ //titled box
+ XControl FrameControl1;
+ //Image Control
+ XControl ImageControl2;
+ //Image Control
+ XControl ImageControl7;
+ //Image Control
+ XControl ImageControl8;
+ //Image Control
+ XControl ImageControl9;
+ //Image Control
+ XControl ImageControl10;
+ //Image Control
+ XControl ImageControl11;
+ //Image Control
+ XControl ImageControl12;
+ //Image Control
+ XControl ImageControl13;
+ //Image Control
+ XControl ImageControl14;
+ //Image Control
+ XControl ImageControl15;
+ */
+ XCheckBox chbDocDesc;
+ XCheckBox chkDocFilename;
+ XCheckBox chbDocAuthor;
+ XCheckBox chkDocFormat;
+ XCheckBox chkDocFormatIcon;
+ XCheckBox chkDocCreated;
+ XCheckBox chkDocChanged;
+ XCheckBox chkDocPages;
+ XCheckBox chkDocSize;
+ XFixedText lnDisplay;
+ XRadioButton optOptimize640x480;
+ XRadioButton optOptimize800x600;
+ XRadioButton optOptimize1024x768;
+ XFixedText lblLayout2Title;
+ XFixedText lblOptimizeFor; // Step 5
+ XFixedText lblStyle;
+ XFixedText lblStyleTitle;
+ XListBox lstStyles; //Image Control
+ XFixedText txtBackground;
+ XFixedText txtIconset;
+ XButton btnBackgrounds;
+ XButton btnIconSets;
+ XControl imgPreview; // Step 6
+ XFixedText lblSiteTitle;
+ XFixedText lblSiteCreated;
+ XFixedText lblEmail;
+ XFixedText lblSiteDesc;
+ XTextComponent txtSiteTitle;
+ XTextComponent txtSiteDesc;
+ XTextComponent txtEmail;
+ XDateField dateSiteCreated;
+ XDateField dateSiteUpdate;
+ XFixedText lblSiteUpdated;
+ XTextComponent txtCopyright;
+ XFixedText lblCopyright;
+ XFixedText lblTitleGeneralPage;
+ XButton btnPreview;
+ XButton btnFTP;
+ XCheckBox chkLocalDir;
+ //Fixed Line
+ XControl lblCreateSite;
+ XCheckBox chkFTP;
+ XFixedText lblFTP;
+ XCheckBox chkZip;
+ XCheckBox chkSaveSettings;
+ XFixedText lblSaveSettings;
+ //Fixed Line
+ XControl lnSaveSetting;
+ XComboBox cbSaveSettings;
+ XTextComponent txtLocalDir;
+ XTextComponent txtZip;
+ XButton btnLocalDir;
+ XButton btnZip;
+ XFixedText lblTitlePublish;
+ //Fixed Line
+ XControl FixedLine1;
+ //Font Descriptors as Class members.
+ FontDescriptor fontDescriptor0 = new FontDescriptor();
+ FontDescriptor fontDescriptor1 = new FontDescriptor();
+ FontDescriptor fontDescriptor4 = new FontDescriptor();
+ FontDescriptor fontDescriptor5 = new FontDescriptor();
+ FontDescriptor fontDescriptor6 = new FontDescriptor();
+ FontDescriptor fontDescriptor7 = new FontDescriptor(); //private static String[] PROPNAMES_LBL_NOFOCUS = new String[] {"Height", "Label", "Name", "PositionX", "PositionY", "Step", "Width"};
+ private static String[] PROPNAMES_LBL = new String[]
+ {
+ "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+ private static String[] PROPNAMES_CHKBOX = new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "State", "Step", "TabIndex", "Width"
+ };
+ private static String[] PROPNAMES_BUTTON = new String[]
+ {
+ "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+ private static String[] PROPNAMES_TXT = new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+ private static String[] PROPNAMES_TXT_2 = new String[]
+ {
+ "Height", "HelpURL", "Name", "PositionX", "PositionY", "ReadOnly", "Step", "TabIndex", "Width"
+ };
+ private static String[] PROPNAMES_TITLE = new String[]
+ {
+ "FontDescriptor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ };
+ private static Integer INTEGER_91 = new Integer(91);
+ private static Integer INTEGER_97 = new Integer(97);
+ private static Integer INTEGER_103 = new Integer(103);
+ private static Integer INTEGER_169 = new Integer(169); //Resources Object
+ WebWizardDialogResources resources;
+
+ public WebWizardDialog(XMultiServiceFactory xmsf)
+ {
+ super(xmsf, HID0_WEBWIZARD);
+ //Load Resources
+ resources = new WebWizardDialogResources(xmsf, super.getResource());
+
+
+ //set dialog properties...
+ Helper.setUnoPropertyValues(xDialogModel,
+ new String[]
+ {
+ "Closeable", "Height", "HelpURL", "Moveable", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Title", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, new Integer(210), HelpIds.getHelpIdString(HID0_WEBWIZARD), Boolean.TRUE, "WebWizardDialog", new Integer(102), new Integer(52), INTEGERS[1], new Short((short) 6), resources.resWebWizardDialog_title, new Integer(330)
+ });
+
+ //Set member- FontDescriptors...
+ fontDescriptor0.Weight = 100;
+ fontDescriptor1.Weight = 150;
+ fontDescriptor1.Underline = com.sun.star.awt.FontUnderline.SINGLE;
+ fontDescriptor4.Weight = 150;
+ fontDescriptor5.Name = "Angsana New";
+ fontDescriptor5.Height = 16;
+ fontDescriptor5.StyleName = "Regular";
+ fontDescriptor5.Family = com.sun.star.awt.FontFamily.ROMAN;
+ fontDescriptor5.Weight = 100;
+ fontDescriptor6.Name = "Andalus";
+ fontDescriptor6.Height = 22;
+ fontDescriptor6.StyleName = "Bold Italic";
+ fontDescriptor6.Weight = 150;
+ fontDescriptor6.Slant = com.sun.star.awt.FontSlant.ITALIC;
+ fontDescriptor7.Name = "StarSymbol";
+ fontDescriptor7.Height = 9;
+ fontDescriptor7.StyleName = "Regular";
+ fontDescriptor7.Weight = 100;
+ }
+ //build components
+ public void buildStep1()
+ {
+ short tabIndex = 100;
+ lbIntroTitle = insertLabel("lbIntroTitle",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslbIntroTitle_value, Boolean.TRUE, "lbIntroTitle", new Integer(91), INTEGERS[8], INTEGERS[1], new Short(tabIndex++), new Integer(232)
+ });
+ lblIntroduction = insertLabel("lblIntroduction",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(119), resources.reslblIntroduction_value, Boolean.TRUE, "lblIntroduction", new Integer(97), new Integer(28), INTEGERS[1], new Short(tabIndex++), new Integer(226)
+ });
+
+ lnLoadSettings = insertFixedLine("lnLoadSettings",
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGERS[2], "", "lnLoadSettings", new Integer(91), new Integer(147), INTEGERS[1], new Short(tabIndex++), new Integer(234)
+ });
+ lblLoadSettings = insertLabel("lblLoadSettings",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLoadSettings_value, Boolean.TRUE, "lblLoadSettings", new Integer(97), new Integer(153), INTEGERS[1], new Short(tabIndex++), new Integer(226)
+ });
+ lstLoadSettings = insertListBox("lstLoadSettings", null, LSTLOADSETTINGS_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID1_LST_SESSIONS), new Short((short) 14), "lstLoadSettings", new Integer(97), new Integer(165), INTEGERS[1], new Short(tabIndex++), new Integer(173)
+ });
+ btnDelSession = insertButton("btnDelSession", BTNDELSESSION_ACTION_PERFORMED,
+ new String[]
+ {
+ "Enabled", "Height", "HelpURL", "ImageAlign", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.FALSE, INTEGER_14, HelpIds.getHelpIdString(HID1_BTN_DEL_SES), new Short(com.sun.star.awt.ImageAlign.LEFT), resources.resbtnDelSession_value, "btnDelSession", new Integer(274), new Integer(164), INTEGERS[1], new Short(tabIndex++), INTEGER_50
+ });
+ }
+
+ public void buildStep2()
+ {
+ short tabIndex = 200;
+
+ lblContentTitle = insertLabel("lblContentTitle",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslblContentTitle_value, Boolean.TRUE, "lblContentTitle", new Integer(91), INTEGERS[8], INTEGERS[2], new Short(tabIndex++), new Integer(232)
+ });
+ lblSiteContent = insertLabel("lblSiteContent",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSiteContent_value, "lblSiteContent", new Integer(97), new Integer(28), INTEGERS[2], new Short(tabIndex++), new Integer(105)
+ });
+ lstDocuments = insertListBox("lstDocuments", null, null,
+ new String[]
+ {
+ "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(123), HelpIds.getHelpIdString(HID2_LST_DOCS), new Short((short) 9), "lstDocuments", new Integer(97), new Integer(38), INTEGERS[2], new Short(tabIndex++), new Integer(103)
+ });
+ btnAddDoc = insertButton("btnAddDoc", BTNADDDOC_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID2_BTN_ADD_DOC), resources.resbtnAddDoc_value, "btnAddDoc", new Integer(97), new Integer(165), INTEGERS[2], new Short(tabIndex++), INTEGER_50
+ });
+ btnRemoveDoc = insertButton("btnRemoveDoc", BTNREMOVEDOC_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID2_BTN_REM_DOC), resources.resbtnRemoveDoc_value, "btnRemoveDoc", new Integer(150), new Integer(165), INTEGERS[2], new Short(tabIndex++), INTEGER_50
+ });
+ btnDocUp = insertButton("btnDocUp", BTNDOCUP_ACTION_PERFORMED,
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor7, INTEGER_14, HelpIds.getHelpIdString(HID2_BTN_DOC_UP), resources.resbtnDocUp_value, "btnDocUp", new Integer(205), new Integer(87), INTEGERS[2], new Short(tabIndex++), new Integer(18)
+ });
+ btnDocDown = insertButton("btnDocDown", BTNDOCDOWN_ACTION_PERFORMED,
+ new String[]
+ {
+ "FontDescriptor", "Height", "HelpURL", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ fontDescriptor7, INTEGER_14, HelpIds.getHelpIdString(HID2_BTN_DOC_DOWN), resources.resbtnDocDown_value, "btnDocDown", new Integer(205), new Integer(105), INTEGERS[2], new Short(tabIndex++), new Integer(18)
+ });
+
+ lblDocExportFormat = insertLabel("lblDocExportFormat",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblDocExportFormat_value, "lblDocExportFormat", new Integer(235), new Integer(28), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ lstDocTargetType = insertListBox("lstDocTargetType", null, null,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID2_LST_DOC_EXPORT), new Short((short) 14), "lstDocTargetType", new Integer(235), new Integer(38), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+
+
+
+
+ lnDocsInfo = insertFixedLine("lnDocsInfo",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslnDocsInfo_value, "lnDocsInfo", new Integer(235), new Integer(66), INTEGERS[2], new Short(tabIndex++), new Integer(90)
+ });
+ lblDocTitle = insertLabel("lblDocTitle",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblDocTitle_value, "lblDocTitle", new Integer(235), new Integer(78), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ txtDocTitle = insertTextField("txtDocTitle", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID2_TXT_DOC_TITLE), "txtDocTitle", new Integer(235), new Integer(88), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ lblDocInfo = insertLabel("lblDocInfo",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblDocInfo_value, "lblDocInfo", new Integer(235), new Integer(103), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ txtDocInfo = insertTextField("txtDocInfo", null,
+ new String[]
+ {
+ "Height", "HelpURL", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_40, HelpIds.getHelpIdString(HID2_TXT_DOC_DESC), Boolean.TRUE, "txtDocInfo", new Integer(235), new Integer(113), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ lblDocAuthor = insertLabel("lblDocAuthor",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblDocAuthor_value, "lblDocAuthor", new Integer(235), new Integer(155), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ txtDocAuthor = insertTextField("txtDocAuthor", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID2_TXT_DOC_AUTHOR), "txtDocAuthor", new Integer(235), new Integer(165), INTEGERS[2], new Short(tabIndex++), new Integer(89)
+ });
+ }
+
+ public void buildStep3()
+ {
+ lblLayoutTitle = insertLabel("lblLayoutTitle",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslblLayoutTitle_value, Boolean.TRUE, "lblLayoutTitle", new Integer(91), INTEGERS[8], INTEGERS[3], new Short((short) 29), new Integer(232)
+ });
+ lblLayouts = insertLabel("lblLayouts",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblLayouts_value, "lblLayouts", new Integer(97), new Integer(28), INTEGERS[3], new Short((short) 30), new Integer(206)
+ });
+
+ }
+
+ public void buildStep4()
+ {
+ lblLayout2Title = insertLabel("lblLayout2Title",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslblLayout2Title_value, Boolean.TRUE, "lblLayout2Title", new Integer(91), INTEGERS[8], INTEGERS[4], new Short((short) 33), new Integer(232)
+ });
+ lnDisplay = insertLabel("lblDisplay",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_16, resources.reslblDisplay_value, Boolean.TRUE, "lblDisplay", new Integer(97), new Integer(28), INTEGERS[4], new Short((short) 34), new Integer(226)
+ });
+ chkDocFilename = insertCheckBox("chkDocFilename", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_FILENAME), resources.reschkDocFilename_value, "chkDocFilename", new Integer(103), new Integer(50), new Short((short) 0), INTEGERS[4], new Short((short) 35), new Integer(99)
+ });
+ chbDocDesc = insertCheckBox("chbDocDesc", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_DESCRIPTION), resources.reschbDocDesc_value, "chbDocDesc", new Integer(103), new Integer(60), new Short((short) 0), INTEGERS[4], new Short((short) 36), new Integer(99)
+ });
+ chbDocAuthor = insertCheckBox("chbDocAuthor", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_AUTHOR), resources.reschbDocAuthor_value, "chbDocAuthor", new Integer(103), new Integer(70), new Short((short) 0), INTEGERS[4], new Short((short) 37), new Integer(99)
+ });
+ chkDocCreated = insertCheckBox("chkDocCreated", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_CR_DATE), resources.reschkDocCreated_value, "chkDocCreated", new Integer(103), new Integer(80), new Short((short) 0), INTEGERS[4], new Short((short) 38), new Integer(99)
+ });
+ chkDocChanged = insertCheckBox("chkDocChanged", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_UP_DATE), resources.reschkDocChanged_value, "chkDocChanged", new Integer(103), new Integer(90), new Short((short) 0), INTEGERS[4], new Short((short) 39), new Integer(99)
+ });
+
+ chkDocFormat = insertCheckBox("chkDocFormat", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_FORMAT), resources.reschkDocFormat_value, "chkDocFormat", new Integer(200), new Integer(50), new Short((short) 0), INTEGERS[4], new Short((short) 40), new Integer(110)
+ });
+ chkDocFormatIcon = insertCheckBox("chkDocFormatIcon", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_F_ICON), resources.reschkDocFormatIcon_value, "chkDocFormatIcon", new Integer(200), new Integer(60), new Short((short) 0), INTEGERS[4], new Short((short) 41), new Integer(110)
+ });
+ chkDocPages = insertCheckBox("chkDocPages", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_PAGES), resources.reschkDocPages_value, "chkDocPages", new Integer(200), new Integer(70), new Short((short) 0), INTEGERS[4], new Short((short) 42), new Integer(110)
+ });
+ chkDocSize = insertCheckBox("chkDocSize", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID4_CHK_DISPLAY_SIZE), resources.reschkDocSize_value, "chkDocSize", new Integer(200), new Integer(80), new Short((short) 0), INTEGERS[4], new Short((short) 43), new Integer(110)
+ });
+ lblOptimizeFor = insertLabel("lblOptimizeFor",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblOptimizeFor_value, "lblOptimizeFor", new Integer(97), new Integer(113), INTEGERS[4], new Short((short) 44), new Integer(226)
+ });
+ optOptimize640x480 = insertRadioButton("optOptimize640x480", null,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGERS[10], HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_640), resources.resoptOptimize640x480_value, "optOptimize640x480", new Integer(103), new Integer(133), INTEGERS[4], new Short((short) 45), new Integer(44)
+ });
+ optOptimize800x600 = insertRadioButton("optOptimize800x600", null,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGERS[10], HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_800), resources.resoptOptimize800x600_value, "optOptimize800x600", new Integer(103), new Integer(146), INTEGERS[4], new Short((short) 46), new Integer(44)
+ });
+ optOptimize1024x768 = insertRadioButton("optOptimize1024x768", null,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGERS[10], HelpIds.getHelpIdString(HID4_GRP_OPTIMAIZE_1024), resources.resoptOptimize1024x768_value, "optOptimize1024x768", new Integer(103), new Integer(158), INTEGERS[4], new Short((short) 47), new Integer(44)
+ });
+
+ }
+
+ public void buildStep5()
+ {
+ lblStyleTitle = insertLabel("lblStyleTitle", PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslblStyleTitle_value, Boolean.TRUE, "lblStyleTitle", new Integer(91), INTEGERS[8], INTEGERS[5], new Short((short) 50), new Integer(232)
+ });
+
+ lblStyle = insertLabel("lblStyle", PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblStyle_value, "lblStyle", new Integer(97), new Integer(28), INTEGERS[5], new Short((short) 51), new Integer(80)
+ });
+ lstStyles = insertListBox("lstStyles", null, LSTSTYLES_ITEM_CHANGED,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID5_LST_STYLES), new Short((short) 14), "lstStyles", new Integer(179), new Integer(26), INTEGERS[5], new Short((short) 52), new Integer(145)
+ });
+
+ insertLabel("lblBackground", PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblBackground, "lblBackground", new Integer(97), new Integer(46), INTEGERS[5], new Short((short) 51), new Integer(70)
+ });
+ txtBackground = insertLabel("txtBackground",
+ new String[]
+ {
+ "Border", "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 1), INTEGER_12, resources.resBackgroundNone, "txtBackground", new Integer(179), new Integer(44), INTEGERS[5], new Short((short) 52), new Integer(90)
+ });
+ btnBackgrounds = insertButton("btnBackgrounds", BTNBACKGROUNDS_ACTION_PERFORMED, PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID5_BTN_BACKGND), resources.resBtnChooseBackground, "btnBackgrounds", new Integer(274), new Integer(43), INTEGERS[5], new Short((short) 53), INTEGER_50
+ });
+
+ insertLabel("lblIconset", PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblIconset, "lblIconset", new Integer(97), new Integer(64), INTEGERS[5], new Short((short) 51), new Integer(70)
+ });
+ txtIconset = insertLabel("txtIconset",
+ new String[]
+ {
+ "Border", "Height", "Label", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 1), INTEGER_12, resources.resIconsetNone, "txtIconset", new Integer(179), new Integer(62), INTEGERS[5], new Short((short) 52), new Integer(90)
+ });
+ btnIconSets = insertButton("btnIconSets", BTNICONSETS_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID5_BTN_ICONS), resources.resBtnChooseIconset, "btnIconSets", new Integer(274), new Integer(61), INTEGERS[5], new Short((short) 54), INTEGER_50
+ });
+ insertLabel("lblIconsetInfo",
+ new String[]
+ {
+ "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ INTEGER_16, resources.reslblIconSetInfo, Boolean.TRUE, "lblIconsetInfo", new Integer(179), new Integer(78), INTEGERS[5], new Short((short) 51), new Integer(145)
+ });
+
+
+ imgPreview = insertImage("imgPreview",
+ new String[]
+ {
+ "BackgroundColor", "Enabled", "Height", "ImageURL", "Name", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(0), Boolean.FALSE, new Integer(78), "", "imgPreview", new Integer(91), new Integer(100), Boolean.FALSE, INTEGERS[5], new Short((short) 55), new Integer(232)
+ });
+
+ }
+
+ public void buildStep6()
+ {
+ short tabIndex = 60;
+ lblTitleGeneralPage = insertLabel("lblTitleGeneralPage",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGERS[8], resources.reslblTitleGeneralPage_value, Boolean.TRUE, "lblTitleGeneralPage", new Integer(90), INTEGERS[9], INTEGERS[6], new Short(tabIndex++), new Integer(232)
+ });
+ lblSiteTitle = insertLabel("lblSiteTitle",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSiteTitle_value, "lblSiteTitle", new Integer(97), new Integer(28), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+ txtSiteTitle = insertTextField("txtSiteTitle", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID6_TXT_SITE_TITLE), "txtSiteTitle", new Integer(179), new Integer(26), INTEGERS[6], new Short(tabIndex++), new Integer(145)
+ });
+
+
+ insertFixedLine("FixedLineMetaData",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[9], resources.reslblMetaData, "FixedLineMetaData", new Integer(97), new Integer(56), INTEGERS[6], new Short(tabIndex++), new Integer(228)
+ });
+
+
+ lblSiteDesc = insertLabel("lblSiteDesc",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSiteDesc_value, "lblSiteDesc", new Integer(103), new Integer(72), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+ txtSiteDesc = insertTextField("txtSiteDesc", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID6_TXT_SITE_DESC), "txtSiteDesc", new Integer(179), new Integer(70), INTEGERS[6], new Short(tabIndex++), new Integer(145)
+ });
+
+ lblEmail = insertLabel("lblEmail", PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblEmail_value, "lblEmail", new Integer(103), new Integer(90), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+ txtEmail = insertTextField("txtEmail", null, PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID6_TXT_SITE_EMAIL), "txtEmail", new Integer(179), new Integer(87), INTEGERS[6], new Short(tabIndex++), new Integer(145)
+ });
+
+ lblCopyright = insertLabel("lblCopyright", PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblCopyright_value, "lblCopyright", new Integer(103), new Integer(108), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+ txtCopyright = insertTextField("txtCopyright", null, PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID6_TXT_SITE_COPYRIGHT), "txtCopyright", new Integer(179), new Integer(106), INTEGERS[6], new Short(tabIndex++), new Integer(145)
+ });
+
+
+ lblSiteCreated = insertLabel("lblSiteCreated",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSiteCreated_value, "lblSiteCreated", new Integer(103), new Integer(126), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+ dateSiteCreated = insertDateField("dateSiteCreated", null,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID6_DATE_SITE_CREATED), "dateSiteCreated", new Integer(179), new Integer(124), INTEGERS[6], new Short(tabIndex++), new Integer(49)
+ });
+ lblSiteUpdated = insertLabel("lblSiteUpdated",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSiteUpdated_value, "lblSiteUpdated", new Integer(103), new Integer(144), INTEGERS[6], new Short(tabIndex++), new Integer(80)
+ });
+
+ dateSiteUpdate = insertDateField("dateSiteUpdate", null,
+ new String[]
+ {
+ "Dropdown", "Height", "HelpURL", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID6_DATE_SITE_UPDATED), "dateSiteUpdate", new Integer(179), new Integer(142), INTEGERS[6], new Short(tabIndex++), new Integer(49)
+ });
+
+
+
+ }
+
+ public void buildStep7(boolean disableFTP, String exclamationURL)
+ {
+ short tabIndex = 700;
+
+ lblTitlePublish = insertLabel("lblTitlePublish",
+ PROPNAMES_TITLE,
+ new Object[]
+ {
+ fontDescriptor4, INTEGER_16, resources.reslblTitlePublish_value, Boolean.TRUE, "lblTitlePublish", new Integer(91), INTEGERS[8], INTEGERS[7], new Short(tabIndex++), new Integer(232)
+ });
+
+ FixedLine1 = insertFixedLine("FixedLine1",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[9], resources.resFixedLine1_value, "FixedLine1", new Integer(97), new Integer(28), INTEGERS[7], new Short(tabIndex++), new Integer(228)
+ });
+
+ btnPreview = insertButton("btnPreview", BTNPREVIEW_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID7_BTN_PREVIEW), resources.resbtnPreview_value, "btnPreview", new Integer(103), new Integer(40), INTEGERS[7], new Short(tabIndex++), INTEGER_50
+ });
+
+ lblCreateSite = insertFixedLine("lblCreateSite",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[9], resources.reslblCreateSite_value, "lblCreateSite", new Integer(97), new Integer(56), INTEGERS[7], new Short(tabIndex++), new Integer(228)
+ });
+
+ chkLocalDir = insertCheckBox("chkLocalDir", CHKLOCALDIR_ITEM_CHANGED,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID7_CHK_PUBLISH_LOCAL), resources.reschkLocalDir_value, "chkLocalDir", new Integer(103), new Integer(68), new Short((short) 0), INTEGERS[7], new Short(tabIndex++), new Integer(215)
+ });
+ txtLocalDir = insertTextField("txtLocalDir", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID7_TXT_LOCAL), "txtLocalDir", new Integer(113), new Integer(78), INTEGERS[7], new Short(tabIndex++), new Integer(190)
+ });
+ btnLocalDir = insertButton("btnLocalDir", BTNLOCALDIR_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID7_BTN_LOCAL), resources.resbtnLocalDir_value, "btnLocalDir", new Integer(308), new Integer(77), INTEGERS[7], new Short(tabIndex++), INTEGER_16
+ });
+
+ chkZip = insertCheckBox("chkZip", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[9], HelpIds.getHelpIdString(HID7_CHK_PUBLISH_ZIP), resources.reschkZip_value, "chkZip", new Integer(103), new Integer(96), new Short((short) 0), INTEGERS[7], new Short(tabIndex++), new Integer(215)
+ });
+ txtZip = insertTextField("txtZip", null,
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGER_12, HelpIds.getHelpIdString(HID7_TXT_ZIP), "txtZip", new Integer(113), new Integer(108), INTEGERS[7], new Short(tabIndex++), new Integer(190)
+ });
+ btnZip = insertButton("btnZip", BTNZIP_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID7_BTN_ZIP), resources.resbtnZip_value, "btnZip", new Integer(308), new Integer(107), INTEGERS[7], new Short(tabIndex++), INTEGER_16
+ });
+
+ chkFTP = insertCheckBox("chkFTP", null,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[8], HelpIds.getHelpIdString(HID7_CHK_PUBLISH_FTP), resources.reschkFTP_value, "chkFTP", new Integer(103), new Integer(124), new Short((short) 0), INTEGERS[7], new Short(tabIndex++), new Integer(215)
+ });
+
+ Integer FTP_STEP = disableFTP ? new Integer(99) : INTEGERS[7];
+
+ lblFTP = insertLabel("lblFTP",
+ new String[]
+ {
+ "Border", "Height", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Short((short) 1), INTEGER_12, "txtFTP", new Integer(113), new Integer(134), FTP_STEP, new Short(tabIndex++), new Integer(156)
+ });
+
+ btnFTP = insertButton("btnFTP", BTNFTP_ACTION_PERFORMED,
+ PROPNAMES_BUTTON,
+ new Object[]
+ {
+ INTEGER_14, HelpIds.getHelpIdString(HID7_BTN_FTP), resources.resbtnFTP_value, "btnFTP", new Integer(274), new Integer(133), FTP_STEP, new Short(tabIndex++), INTEGER_50
+ });
+
+ if (disableFTP)
+ {
+
+ insertImage("imgFTPDisabled",
+ new String[]
+ {
+ "BackgroundColor", "Border", "Enabled", "Height", "ImageURL", "Name", "PositionX", "PositionY", "ScaleImage", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(-1), new Short((short) 0), Boolean.FALSE, new Integer(10), exclamationURL, "imgFTPDisabled", new Integer(115), new Integer(135), Boolean.FALSE, INTEGERS[7], new Short(tabIndex++), new Integer(8)
+ });
+ insertLabel("lblFTPDisabled",
+ new String[]
+ {
+ "BackgroundColor", "Height", "Label", "MultiLine", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ new Integer(-1), INTEGER_8, resources.reslblFTPDisabled, Boolean.TRUE, "lblFTPDisabled", new Integer(125), new Integer(136), INTEGERS[7], new Short(tabIndex++), new Integer(226)
+ });
+ //FTP_STEP = new Integer(99);
+ }
+ //else
+
+ lnSaveSetting = insertFixedLine("lnSaveSetting",
+ PROPNAMES_TXT,
+ new Object[]
+ {
+ INTEGERS[2], "", "lnSaveSetting", new Integer(97), new Integer(151), INTEGERS[7], new Short(tabIndex++), new Integer(228)
+ });
+ chkSaveSettings = insertCheckBox("chkSaveSettings", CHKSAVESETTINGS_ITEM_CHANGED,
+ PROPNAMES_CHKBOX,
+ new Object[]
+ {
+ INTEGERS[9], HelpIds.getHelpIdString(HID7_CHK_SAVE), resources.reschkSaveSettings_value, "chkSaveSettings", new Integer(97), new Integer(157), new Short((short) 1), INTEGERS[7], new Short(tabIndex++), new Integer(215)
+ });
+ lblSaveSettings = insertLabel("lblSaveSettings",
+ PROPNAMES_LBL,
+ new Object[]
+ {
+ INTEGERS[8], resources.reslblSaveSettings_value, "lblSaveSettings", new Integer(107), new Integer(169), INTEGERS[7], new Short(tabIndex++), new Integer(45)
+ });
+ cbSaveSettings = insertComboBox("txtSaveSettings", TXTSAVESETTINGS_TEXT_CHANGED, TXTSAVESETTINGS_TEXT_CHANGED, TXTSAVESETTINGS_TEXT_CHANGED,
+ new String[]
+ {
+ "Autocomplete", "Dropdown", "Height", "HelpURL", "LineCount", "Name", "PositionX", "PositionY", "Step", "TabIndex", "Width"
+ },
+ new Object[]
+ {
+ Boolean.TRUE, Boolean.TRUE, INTEGER_12, HelpIds.getHelpIdString(HID7_TXT_SAVE), new Short((short) 14), "txtSaveSettings", new Integer(179), new Integer(167), INTEGERS[7], new Short(tabIndex++), new Integer(145)
+ });
+
+ }
+ XControl[] imgIconsPrev = new XControl[8];
+ ImageList ilLayouts;
+
+ /**
+ * builds the layouts image list.
+ */
+ public void buildStepX()
+ {
+ ilLayouts = new ImageList();
+ ilLayouts.setPos(new Size(97, 38));
+ ilLayouts.setImageSize(new Size(34, 30));
+ ilLayouts.setCols(5);
+ ilLayouts.setRows(3);
+ ilLayouts.setStep(new Short((short) 3));
+ ilLayouts.setShowButtons(false);
+ ilLayouts.setRenderer(new LayoutRenderer());
+ ilLayouts.scaleImages = Boolean.FALSE;
+ ilLayouts.tabIndex = 31;
+ ilLayouts.helpURL = HID3_IL_LAYOUTS_IMG1;
+
+ /*for (int i = 0; i<8; i++)
+ imgIconsPrev[i] = insertImage("imgIconPrev" + i,
+ new String[] { "BackgroundColor","Border","Height","ImageURL", "PositionX", "PositionY", "ScaleImage", "Step", "Tabstop", "Width"},
+ new Object[] { new Integer(-1), new Short((short)0),new Integer(14),"file:///c:/bludisk.gif", new Integer(97 + i * 20 + 7 ),new Integer(147),Boolean.FALSE,INTEGERS[5],Boolean.FALSE,new Integer(14)});
+ */
+ }
+
+ /**
+ * renders the images and titles of
+ * the layouts
+ * @author rpiterman
+
+ */
+ private class LayoutRenderer implements ImageList.IImageRenderer
+ {
+
+ public Object[] getImageUrls(Object listItem)
+ {
+ Object[] oResIds = null;
+ if (listItem != null)
+ {
+ oResIds = ((CGLayout) listItem).getImageUrls();
+ }
+ return oResIds;
+ }
+
+ public String render(Object listItem)
+ {
+ return listItem == null ? "" : ((CGLayout) listItem).cp_Name;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialogResources.java b/wizards/com/sun/star/wizards/web/WebWizardDialogResources.java
new file mode 100644
index 000000000000..c4a4f0cf58cd
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/WebWizardDialogResources.java
@@ -0,0 +1,349 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Configuration;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.Resource;
+import com.sun.star.wizards.document.OfficeDocument;
+
+public class WebWizardDialogResources
+{
+
+ String resSessionName;
+ String resSizeTemplate;
+ String resSpecifyNewFileLocation;
+ String resCreatedTemplate;
+ String resUpdatedTemplate;
+ String resSlides;
+ String resDelSessionConfirm;
+ String resErrIsDirectory;
+ String resErrDocValidate;
+ String resStep1;
+ String resStep2;
+ String resStep3;
+ String resStep4;
+ String resStep5;
+ String resStep6;
+ String resStep7;
+ String resDefaultArchiveFilename;
+ String resValidatingDocuments;
+ String resErrUnexpected;
+ String resLoadingSession;
+ String resErrExportIO;
+ String resErrPublishMedia;
+ String resErrPublish;
+ String resErrUnknown;
+ //String resErrDocClose;
+ String resErrSecurity;
+ String resErrMkDir;
+ //String resErrDocOpen;
+ String resErrDocExport;
+ String resErrDocInfo;
+ String resErrTOCMedia;
+ String resErrTOC;
+ final static String UNIT_NAME = "dbwizres";
+ final static String MODULE_NAME = "dbw";
+ final static int RID_WEBWIZARDDIALOG_START = 4000;
+ final static int RID_COMMON_START = 500;
+ final static int RID_DB_COMMON_START = 1000;
+ String resWebWizardDialog_title;
+ String reslblIntroduction_value;
+ String resbtnDelSession_value;
+ String reslbIntroTitle_value;
+ String reslblContentTitle_value;
+ String reslnDocsInfo_value;
+ String reslblDocTitle_value;
+ String reslblDocInfo_value;
+ String reslblDocAuthor_value;
+ String reslblDocExportFormat_value;
+ String reslblTitleGeneralPage_value;
+ String reslblSiteTitle_value;
+ String reslblSiteDesc_value;
+ String reslblSiteCreated_value;
+ String reslblEmail_value;
+ String reslblCopyright_value;
+ String reslblSiteUpdated_value;
+ String resbtnPreview_value;
+ String reslblTitlePublish_value;
+ String reslblCreateSite_value;
+ String reschkLocalDir_value;
+ String resbtnLocalDir_value;
+ String reschkFTP_value;
+ String resbtnFTP_value;
+ String reschkZip_value;
+ String resbtnZip_value;
+ String reschkSaveSettings_value;
+ String reslblSaveSettings_value;
+ String reslblLoadSettings_value;
+ String reslblSiteContent_value;
+ String resbtnAddDoc_value;
+ String resbtnRemoveDoc_value;
+ String reslblLayoutTitle_value;
+ String reslblStyleTitle_value;
+ String reslblStyle_value;
+ String reslblLayouts_value;
+ String reschbDocDesc_value;
+ String reschbDocAuthor_value;
+ String reschkDocCreated_value;
+ String reschkDocChanged_value;
+ String reschkDocFilename_value;
+ String reschkDocFormat_value;
+ String reschkDocFormatIcon_value;
+ String reschkDocPages_value;
+ String reschkDocSize_value;
+ String resFixedLine1_value;
+ String reslblLayout2Title_value;
+ String reslblDisplay_value;
+ String reslblOptimizeFor_value;
+ String resoptOptimize640x480_value;
+ String resoptOptimize800x600_value;
+ String resoptOptimize1024x768_value;
+ final String resbtnDocUp_value = String.valueOf((char) 8743);
+ final String resbtnDocDown_value = String.valueOf((char) 8744);
+ String reslblBackground;
+ String reslblIconset;
+ String reslblIconSetInfo;
+ String reslblMetaData;
+ String resBtnChooseBackground;
+ String resBtnChooseIconset; //String resGenerate;
+ //String resPublish;
+ //String resExport;
+ String resCancel;
+ String resClose;
+ String resCounter;
+ String resStatusDialogTitle;
+ String resPublishDir;
+ String resFTPTargetExistsAsfile;
+ String resLocalTargetExistsAsfile;
+ String resZipTargetExists;
+ String resFTPTargetNotEmpty;
+ String resLocalTragetNotEmpty;
+ String resSessionExists;
+ String resTaskExport;
+ String resTaskExportDocs;
+ String resTaskExportPrepare;
+ String resTaskGenerateCopy;
+ String resTaskGeneratePrepare;
+ String resTaskGenerateXsl;
+ String resTaskPrepare;
+ String resTaskPublishPrepare;
+ String resTaskPublishLocal;
+ String resTaskPublishFTP;
+ String resTaskPublishZip;
+ String resTaskFinish;
+ String resPages;
+ String resImages;
+ String resAllFiles;
+ String resZipFiles;
+ String resGifFiles;
+ String resOK;
+ String resHelp;
+ String resBackgroundsDialog;
+ String resBackgroundsDialogCaption;
+ String resIconsDialog;
+ String resIconsDialogCaption;
+ String resOther;
+ String resDeselect;
+ String resFinishedSuccess;
+ String resFinishedNoSuccess;
+ String resSessionNameNone;
+ String reslblFTPDisabled;
+ String resBackgroundNone;
+ String resIconsetNone;
+ String prodName;
+ String resFTPTargetCouldNotCreate;
+ String resFTPTargetCreate;
+ String resZipTargetIsDir;
+ String resLocalTargetCouldNotCreate;
+ String resLocalTargetCreate;
+ Resource oResource;
+
+ public WebWizardDialogResources(XMultiServiceFactory xmsf, Resource _oResource)
+ {
+ oResource = _oResource;
+ /**
+ * Delete the String, uncomment the getResText method
+ *
+ */
+ resWebWizardDialog_title = oResource.getResText(RID_WEBWIZARDDIALOG_START + 1);
+ reslblIntroduction_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 2);
+ resbtnDelSession_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 4);
+ reslbIntroTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 5);
+ reslblContentTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 6);
+ reslnDocsInfo_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 8);
+ reslblDocTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 9);
+ reslblDocInfo_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 10);
+ reslblDocAuthor_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 11);
+ reslblDocExportFormat_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 12);
+ reslblTitleGeneralPage_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 13);
+ reslblSiteTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 14);
+ reslblSiteDesc_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 16);
+ reslblSiteCreated_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 18);
+ reslblEmail_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 20);
+ reslblCopyright_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 21);
+ reslblSiteUpdated_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 22);
+ resbtnPreview_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 24);
+ reslblTitlePublish_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 25);
+ reslblCreateSite_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 26);
+ reschkLocalDir_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 27);
+ resbtnLocalDir_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 28);
+ reschkFTP_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 29);
+ //
+ resbtnFTP_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 31);
+ reschkZip_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 32);
+ resbtnZip_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 33);
+ reschkSaveSettings_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 34);
+ reslblSaveSettings_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 35);
+ reslblLoadSettings_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 36);
+ reslblSiteContent_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 37);
+ resbtnAddDoc_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 38);
+ resbtnRemoveDoc_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 39);
+ reslblLayoutTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 40);
+ reslblStyleTitle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 41);
+ reslblStyle_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 42);
+ //
+ reslblLayouts_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 48);
+ //
+ reschbDocDesc_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 50);
+ reschbDocAuthor_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 51);
+ reschkDocCreated_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 52);
+ reschkDocChanged_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 53);
+ reschkDocFilename_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 54);
+ reschkDocFormat_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 55);
+ reschkDocFormatIcon_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 56);
+ reschkDocPages_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 57);
+ reschkDocSize_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 58);
+ resFixedLine1_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 59);
+ reslblLayout2Title_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 60);
+ reslblDisplay_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 61);
+ reslblOptimizeFor_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 62);
+ resoptOptimize640x480_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 64);
+ resoptOptimize800x600_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 65);
+ resoptOptimize1024x768_value = oResource.getResText(RID_WEBWIZARDDIALOG_START + 66);
+ //resExport = oResource.getResText(RID_WEBWIZARDDIALOG_START + 67);
+ //resGenerate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 68);
+ //resPublish = oResource.getResText(RID_WEBWIZARDDIALOG_START + 69);
+ resStatusDialogTitle = oResource.getResText(RID_WEBWIZARDDIALOG_START + 70);
+ resCounter = oResource.getResText(RID_WEBWIZARDDIALOG_START + 71);
+ resPublishDir = oResource.getResText(RID_WEBWIZARDDIALOG_START + 72);
+ resFTPTargetExistsAsfile = oResource.getResText(RID_WEBWIZARDDIALOG_START + 73);
+ resLocalTargetExistsAsfile = oResource.getResText(RID_WEBWIZARDDIALOG_START + 74);
+ resZipTargetExists = oResource.getResText(RID_WEBWIZARDDIALOG_START + 75);
+ resFTPTargetNotEmpty = oResource.getResText(RID_WEBWIZARDDIALOG_START + 76);
+ resLocalTragetNotEmpty = oResource.getResText(RID_WEBWIZARDDIALOG_START + 77);
+ resSessionExists = oResource.getResText(RID_WEBWIZARDDIALOG_START + 78);
+ resTaskExportDocs = oResource.getResText(RID_WEBWIZARDDIALOG_START + 79);
+ resTaskExportPrepare = oResource.getResText(RID_WEBWIZARDDIALOG_START + 80);
+ resTaskGenerateCopy = oResource.getResText(RID_WEBWIZARDDIALOG_START + 81);
+ resTaskGeneratePrepare = oResource.getResText(RID_WEBWIZARDDIALOG_START + 82);
+ resTaskGenerateXsl = oResource.getResText(RID_WEBWIZARDDIALOG_START + 83);
+ resTaskPrepare = oResource.getResText(RID_WEBWIZARDDIALOG_START + 84);
+ resTaskPublishPrepare = oResource.getResText(RID_WEBWIZARDDIALOG_START + 86);
+ resTaskPublishLocal = oResource.getResText(RID_WEBWIZARDDIALOG_START + 87);
+ resTaskPublishFTP = oResource.getResText(RID_WEBWIZARDDIALOG_START + 88);
+ resTaskPublishZip = oResource.getResText(RID_WEBWIZARDDIALOG_START + 89);
+ resTaskFinish = oResource.getResText(RID_WEBWIZARDDIALOG_START + 90);
+ //resPages = oResource.getResText(RID_WEBWIZARDDIALOG_START + 91);
+ resImages = oResource.getResText(RID_WEBWIZARDDIALOG_START + 94);
+ resAllFiles = oResource.getResText(RID_WEBWIZARDDIALOG_START + 95);
+ resZipFiles = oResource.getResText(RID_WEBWIZARDDIALOG_START + 96);
+ resBackgroundsDialog = oResource.getResText(RID_WEBWIZARDDIALOG_START + 98);
+ resBackgroundsDialogCaption = oResource.getResText(RID_WEBWIZARDDIALOG_START + 99);
+ resIconsDialog = oResource.getResText(RID_WEBWIZARDDIALOG_START + 100);
+ resIconsDialogCaption = oResource.getResText(RID_WEBWIZARDDIALOG_START + 101);
+ resOther = oResource.getResText(RID_WEBWIZARDDIALOG_START + 102);
+ resDeselect = oResource.getResText(RID_WEBWIZARDDIALOG_START + 103);
+ resFinishedSuccess = oResource.getResText(RID_WEBWIZARDDIALOG_START + 104);
+ resFinishedNoSuccess = oResource.getResText(RID_WEBWIZARDDIALOG_START + 105);
+ resErrTOC = oResource.getResText(RID_WEBWIZARDDIALOG_START + 106);
+ resErrTOCMedia = oResource.getResText(RID_WEBWIZARDDIALOG_START + 107);
+ resErrDocInfo = oResource.getResText(RID_WEBWIZARDDIALOG_START + 108);
+ resErrDocExport = oResource.getResText(RID_WEBWIZARDDIALOG_START + 109);
+ resErrMkDir = oResource.getResText(RID_WEBWIZARDDIALOG_START + 110);
+ resErrSecurity = oResource.getResText(RID_WEBWIZARDDIALOG_START + 111);
+ resErrExportIO = oResource.getResText(RID_WEBWIZARDDIALOG_START + 112);
+ resErrPublishMedia = oResource.getResText(RID_WEBWIZARDDIALOG_START + 113);
+ resErrPublish = oResource.getResText(RID_WEBWIZARDDIALOG_START + 114);
+ resErrUnknown = oResource.getResText(RID_WEBWIZARDDIALOG_START + 115);
+ resErrDocValidate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 116);
+ resErrIsDirectory = oResource.getResText(RID_WEBWIZARDDIALOG_START + 117);
+ resLoadingSession = oResource.getResText(RID_WEBWIZARDDIALOG_START + 118);
+ resErrUnexpected = oResource.getResText(RID_WEBWIZARDDIALOG_START + 119);
+ resValidatingDocuments = oResource.getResText(RID_WEBWIZARDDIALOG_START + 120);
+ resDefaultArchiveFilename = oResource.getResText(RID_WEBWIZARDDIALOG_START + 121);
+ resStep1 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 122);
+ resStep2 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 123);
+ resStep3 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 124);
+ resStep4 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 125);
+ resStep5 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 126);
+ resStep6 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 127);
+ resStep7 = oResource.getResText(RID_WEBWIZARDDIALOG_START + 128);
+ resDelSessionConfirm = oResource.getResText(RID_WEBWIZARDDIALOG_START + 130);
+ resPages = oResource.getResText(RID_WEBWIZARDDIALOG_START + 131);
+ resSlides = oResource.getResText(RID_WEBWIZARDDIALOG_START + 132);
+ resCreatedTemplate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 133);
+ resUpdatedTemplate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 134);
+ resSessionName = oResource.getResText(RID_WEBWIZARDDIALOG_START + 135);
+
+ reslblBackground = oResource.getResText(RID_WEBWIZARDDIALOG_START + 136);
+ reslblIconset = oResource.getResText(RID_WEBWIZARDDIALOG_START + 137);
+ reslblIconSetInfo = oResource.getResText(RID_WEBWIZARDDIALOG_START + 138);
+ reslblMetaData = oResource.getResText(RID_WEBWIZARDDIALOG_START + 139);
+ resBtnChooseBackground = oResource.getResText(RID_WEBWIZARDDIALOG_START + 140);
+ resBtnChooseIconset = oResource.getResText(RID_WEBWIZARDDIALOG_START + 141);
+ resSessionNameNone = oResource.getResText(RID_WEBWIZARDDIALOG_START + 142);
+ reslblFTPDisabled = oResource.getResText(RID_WEBWIZARDDIALOG_START + 143);
+ resBackgroundNone = oResource.getResText(RID_WEBWIZARDDIALOG_START + 144);
+ resIconsetNone = oResource.getResText(RID_WEBWIZARDDIALOG_START + 145);
+ resFTPTargetCouldNotCreate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 146);
+ resFTPTargetCreate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 147);
+ resZipTargetIsDir = oResource.getResText(RID_WEBWIZARDDIALOG_START + 148);
+ resLocalTargetCouldNotCreate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 149);
+ resLocalTargetCreate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 150);
+ resSizeTemplate = oResource.getResText(RID_WEBWIZARDDIALOG_START + 151);
+ resSpecifyNewFileLocation = oResource.getResText(RID_WEBWIZARDDIALOG_START + 152);
+
+ resClose = oResource.getResText(RID_COMMON_START + 17);
+ resCancel = oResource.getResText(RID_COMMON_START + 11);
+ resOK = oResource.getResText(RID_COMMON_START + 18);
+ resHelp = oResource.getResText(RID_COMMON_START + 15);
+
+ try
+ {
+ prodName = Configuration.getProductName(xmsf);
+ resGifFiles = (String) Properties.getPropertyValue(OfficeDocument.getTypeMediaDescriptor(xmsf, "gif_Graphics_Interchange"), "UIName");
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGArgument.java b/wizards/com/sun/star/wizards/web/data/CGArgument.java
new file mode 100644
index 000000000000..2ae2c70ce69c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGArgument.java
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+public class CGArgument extends ConfigGroup
+{
+
+ public String cp_Value;
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGContent.java b/wizards/com/sun/star/wizards/web/data/CGContent.java
new file mode 100644
index 000000000000..9bf32f26ff48
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGContent.java
@@ -0,0 +1,68 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.*;
+
+import org.w3c.dom.*;
+
+public class CGContent extends ConfigSetItem implements XMLProvider
+{
+
+ public String dirName;
+ public String cp_Name;
+ public String cp_Description;
+ public ConfigSet cp_Contents = new ConfigSet(CGContent.class);
+ public ConfigSet cp_Documents = new ConfigSet(CGDocument.class);
+
+ public CGContent()
+ {
+ /*cp_Documents = new ConfigSet(CGDocument.class) {
+ protected DefaultListModel createChildrenList() {
+ return cp_Contents.getChildrenList();
+ }
+ };*/
+ }
+
+ public Node createDOM(Node parent)
+ {
+
+ Node myElement = XMLHelper.addElement(parent, "content",
+ new String[]
+ {
+ "name", "directory-name", "description", "directory"
+ },
+ new String[]
+ {
+ cp_Name, dirName, cp_Description, dirName
+ });
+
+ cp_Documents.createDOM(myElement);
+
+ return myElement;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGDesign.java b/wizards/com/sun/star/wizards/web/data/CGDesign.java
new file mode 100644
index 000000000000..00c1ea10b949
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGDesign.java
@@ -0,0 +1,91 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.*;
+import org.w3c.dom.Node;
+
+public class CGDesign extends ConfigGroup implements XMLProvider
+{
+
+ public String cp_Layout;
+ public String cp_Style;
+ public String cp_BackgroundImage;
+ public String cp_IconSet;
+ //public int cp_OptimizeDisplay;
+ public boolean cp_DisplayTitle;
+ public boolean cp_DisplayDescription;
+ public boolean cp_DisplayAuthor;
+ public boolean cp_DisplayCreateDate;
+ public boolean cp_DisplayUpdateDate;
+ public boolean cp_DisplayFilename;
+ public boolean cp_DisplayFileFormat;
+ public boolean cp_DisplayFormatIcon;
+ public boolean cp_DisplayPages;
+ public boolean cp_DisplaySize;
+ public int cp_OptimizeDisplaySize;
+ private final String TRUE = "true";
+ private final String FALSE = null;
+ private String styleName;
+
+ public Node createDOM(Node parent)
+ {
+ return XMLHelper.addElement(parent, "design", new String[0],
+ new String[0]);
+
+ }
+ private static final Short SHORT_TRUE = new Short((short) 1);
+ private static final Short SHORT_FALSE = new Short((short) 0);
+
+ public short[] getStyle()
+ {
+ CGStyle style = ((CGStyle) ((CGSettings) root).cp_Styles.getElement(cp_Style));
+ return new short[]
+ {
+ (short) ((CGSettings) root).cp_Styles.getIndexOf(style)
+ };
+ }
+
+ public void setStyle(short[] newStyle)
+ {
+ Object o = ((CGStyle) ((CGSettings) root).cp_Styles.getElementAt(newStyle[0]));
+ cp_Style = (String) ((CGSettings) root).cp_Styles.getKey(o);
+ }
+
+ public int getLayout()
+ {
+ CGLayout layout = ((CGLayout) ((CGSettings) root).cp_Layouts.getElement(cp_Layout));
+ return layout.cp_Index;
+ }
+
+ public void setLayout(int layoutIndex)
+ {
+ CGLayout layout = (CGLayout) ((CGSettings) root).cp_Layouts.getElementAt(layoutIndex);
+ cp_Layout = (String) ((CGSettings) root).cp_Layouts.getKey(layout);
+ }
+}
+
diff --git a/wizards/com/sun/star/wizards/web/data/CGDocument.java b/wizards/com/sun/star/wizards/web/data/CGDocument.java
new file mode 100644
index 000000000000..177355612675
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGDocument.java
@@ -0,0 +1,453 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+import org.w3c.dom.Node;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.MacroExecMode;
+import com.sun.star.document.UpdateDocMode;
+import com.sun.star.document.XDocumentProperties;
+import com.sun.star.document.XDocumentPropertiesSupplier;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.lang.XComponent;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.DateTime;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.JavaTools;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.common.XMLHelper;
+import com.sun.star.wizards.common.XMLProvider;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.ui.event.Task;
+
+/**
+ * About the member fields Title, Decription and Author:
+ * There is an ambiguicy in handling these fields.
+ * On the one hand, the user can set those fields to a custom value,
+ * relevant only for the web-wizard.
+ * On the other-hand, the web-wizard can read those fields automatically
+ * from SO documents.
+ * In order to avoid conflict by saving, I use two fields: "cp_title", which
+ * should be read from the configuratin (saved session), and "title" which is
+ * the value read from the document.
+ * The *cp_title* "overrides" *title*, if exists. if not, *title* is used.
+ * The same is valid for *description* and *author*.
+ * @author rpiterman
+ */
+public class CGDocument extends ConfigSetItem implements XMLProvider
+{
+
+ public static final int PAGE_TYPE_UNKNOWN = 0;
+ public static final int PAGE_TYPE_PAGE = 1;
+ public static final int PAGE_TYPE_SLIDE = 2;
+ public String cp_Title = "";
+ public String cp_Description = "";
+ public String cp_URL;
+ public String cp_Author = "";
+ public String cp_Exporter;
+ /**
+ * the destination filename to which this
+ * document will be exported to.
+ */
+ public String localFilename = "";
+ public String urlFilename = "";
+ public String title = "";
+ public String description = "";
+ public String author = "";
+ public DateTime createDate;
+ public DateTime updateDate;
+ public int sizeBytes = -1;
+ public int pages = -1;
+ /**
+ * The contents subdirectory name in which the document is in.
+ * This subdirectory will be created in the content's "docs"
+ * subdirectory.
+ */
+ public String dirName;
+ /**
+ * contains an identifier of the type of this document.
+ */
+ public String appType;
+ public PropertyValue[] mediaDescriptor;
+ /**
+ * Is this document an original SO Document (different versions).
+ */
+ public boolean isSODocument;
+ /**
+ * can this document be opend through SO?
+ */
+ public boolean isSOOpenable;
+ /**
+ * This flag is set to true after the validate method is called.
+ */
+ public boolean valid = false;
+ public String targetTypeName;
+
+ public CGDocument()
+ {
+ }
+
+ public CGDocument(String url, XMultiServiceFactory xmsf, Task task) throws Exception
+ {
+ cp_URL = getSettings().getFileAccess(xmsf).getURL(url);
+ if (task == null)
+ {
+ task = new Task("", "", 5);
+ }
+ validate(xmsf, task);
+ }
+
+ /**
+ * the task will advance 5 times during validate.
+ * @param xmsf
+ * @param task
+ * @throws Exception
+ */
+ public void validate(XMultiServiceFactory xmsf, Task task)
+ throws FileNotFoundException,
+ IllegalArgumentException,
+ Exception
+ {
+
+ if (!getSettings().getFileAccess(xmsf).exists(cp_URL, false))
+ {
+ throw new FileNotFoundException("The given URL does not point to a file");
+ }
+ if (getSettings().getFileAccess(xmsf).isDirectory(cp_URL))
+ {
+ throw new IllegalArgumentException("The given URL points to a directory"); //create a TypeDetection service
+ }
+ mediaDescriptor = OfficeDocument.getFileMediaDecriptor(xmsf, cp_URL);
+
+ task.advance(true); //1
+
+ //System.out.println(Properties.getPropertyValue(mediaDescriptor,"UIName"));
+
+ analyzeFileType(mediaDescriptor);
+
+ task.advance(true); //2
+
+ String path = getSettings().getFileAccess(xmsf).getPath(cp_URL, "");
+ localFilename = FileAccess.getFilename(path, File.separator);
+
+ /* if the type is a star office convertable document
+ * We try to open the document to get some properties
+ */
+
+ XDocumentProperties xProps = null;
+
+ task.advance(true); //3
+
+ if (isSOOpenable)
+ { // for documents which are openable through SO, use DocumentProperties service.
+ XDesktop desktop = Desktop.getDesktop(xmsf);
+ PropertyValue[] props = new PropertyValue[3];
+ props[0] = Properties.createProperty("Hidden", Boolean.TRUE);
+ props[1] = Properties.createProperty("MacroExecutionMode", new Short(MacroExecMode.NEVER_EXECUTE));
+ props[2] = Properties.createProperty("UpdateDocMode", new Short(UpdateDocMode.NO_UPDATE));
+ XComponent component = ((XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop)).loadComponentFromURL(cp_URL, "_default", 0, props);
+ xProps = ((XDocumentPropertiesSupplier) UnoRuntime.queryInterface(XDocumentPropertiesSupplier.class, component)).getDocumentProperties();
+ }
+
+ task.advance(true); //4
+
+ //now use the object to read some document properties.
+ if (xProps != null)
+ {
+ title = xProps.getTitle();
+ description = xProps.getDescription();
+ author = xProps.getAuthor();
+ createDate = xProps.getCreationDate();
+ updateDate = xProps.getModificationDate();
+ }
+ else
+ { //get some information from OS.
+ title = localFilename;
+ updateDate = getSettings().getFileAccess(xmsf).getLastModified(cp_URL);
+ }
+
+ task.advance(true); //5
+
+ valid = true;
+
+ if (cp_Title.equals(""))
+ {
+ cp_Title = title;
+ }
+ if (cp_Title.equals(""))
+ {
+ cp_Title = localFilename;
+ }
+ if (cp_Description.equals(""))
+ {
+ cp_Description = description;
+ }
+ if (cp_Author.equals(""))
+ {
+ cp_Author = author;
+ }
+ if (cp_Exporter == null || cp_Exporter.equals(""))
+ {
+ cp_Exporter = (String) getSettings().cp_Exporters.getKey(
+ getSettings().getExporters(appType)[0]);
+ }
+ }
+
+ /**
+ * Analyzes a type-detection string, returned from the TypeDetection service,
+ * and sets the appType, isSOOpenable and isSODocument members.
+ */
+ private void analyzeFileType(PropertyValue[] mediaDesc)
+ {
+
+ if (mediaDesc == null)
+ {
+ }
+
+ String media = (mediaDesc == null)
+ ? "" : (String) Properties.getPropertyValue(mediaDescriptor, "Name");
+ appType = getDocType(media);
+
+ //System.out.println(appType);
+
+ isSOOpenable =
+ (appType == TypeDetection.WRITER_DOC || appType == TypeDetection.CALC_DOC || appType == TypeDetection.IMPRESS_DOC || appType == TypeDetection.DRAW_DOC) || appType == TypeDetection.HTML_DOC;
+
+// String[] parts = media.split("_"); // line removed because of compatibility to JDK13
+ String[] parts = JavaTools.ArrayoutofString(media, "_");
+
+
+ isSODocument = parts.length < 2 ? false : isSOOpenable && (parts[1].startsWith("Star"));
+
+ }
+
+ /**
+ * @param media is the media description string returned by an UNO TypeDetection object.
+ * @return one of the constants in the interface TypeDetection.
+ *
+ */
+ private String getDocType(String media)
+ {
+ if (media.equals(""))
+ {
+ return TypeDetection.NO_TYPE;
+ }
+ if (media.startsWith("writer"))
+ {
+ if (media.startsWith("writer_web_HTML"))
+ {
+ return TypeDetection.HTML_DOC;
+ }
+ else
+ {
+ return TypeDetection.WRITER_DOC;
+ }
+ }
+ else if (media.startsWith("calc"))
+ {
+ return TypeDetection.CALC_DOC;
+ }
+ else if (media.startsWith("draw"))
+ {
+ return TypeDetection.DRAW_DOC;
+ }
+ else if (media.startsWith("impress"))
+ {
+ return TypeDetection.IMPRESS_DOC;
+ }
+ else if (media.startsWith("pdf"))
+ {
+ return TypeDetection.PDF_DOC;
+ }
+ else if (media.startsWith("gif") || media.startsWith("jpg"))
+ {
+ return TypeDetection.WEB_GRAPHICS;
+ }
+ else if (media.startsWith("wav"))
+ {
+ return TypeDetection.SOUND_FILE;
+ }
+ else
+ {
+ return TypeDetection.NO_TYPE;
+ }
+ }
+
+ public Node createDOM(Node parent)
+ {
+ CGDesign d = getSettings().cp_DefaultSession.cp_Design;
+ CGExporter exp = (CGExporter) getSettings().cp_Exporters.getElement(cp_Exporter);
+
+ return XMLHelper.addElement(parent, "document",
+ new String[]
+ {
+ "title", "description", "author", "format", "filename", "create-date", "update-date", "pages", "size", "icon", "dir", "fn"
+ },
+ new String[]
+ {
+ d.cp_DisplayTitle ? cp_Title : "",
+ d.cp_DisplayDescription ? cp_Description : "",
+ d.cp_DisplayAuthor ? cp_Author : "",
+ d.cp_DisplayFileFormat ? getTargetTypeName(exp) : "",
+ d.cp_DisplayFilename ? localFilename : "",
+ d.cp_DisplayCreateDate ? createDate() : "",
+ d.cp_DisplayUpdateDate ? updateDate() : "",
+ d.cp_DisplayPages && (pages > -1) ? "" + pages() : "", //TODO when do i calculate pages?
+ d.cp_DisplaySize ? sizeKB() : "",//TODO when do i calculate size?
+ d.cp_DisplayFormatIcon ? getIcon(exp) : "",
+ dirName, urlFilename
+ });
+ }
+
+ private String updateDate()
+ {
+ if (this.updateDate == null)
+ {
+ return "";
+ }
+ return getSettings().formatter.formatCreated(this.updateDate);
+ }
+
+ private String createDate()
+ {
+ if (this.createDate == null)
+ {
+ return "";
+ }
+ return getSettings().formatter.formatCreated(this.createDate);
+ }
+
+ private String sizeKB()
+ {
+ if (sizeBytes == -1)
+ {
+ return "";
+ }
+ else
+ {
+ return getSettings().formatter.formatFileSize(sizeBytes);
+ }
+ }
+
+ private String pages()
+ {
+ return pages == -1 ? ""
+ : JavaTools.replaceSubString(pagesTemplate(), "" + pages, "%NUMBER");
+ }
+
+ private String pagesTemplate()
+ {
+ int pagesType = ((CGExporter) getSettings().cp_Exporters.getElement(cp_Exporter)).cp_PageType;
+ switch (pagesType)
+ {
+ case PAGE_TYPE_UNKNOWN:
+ return "";
+ case PAGE_TYPE_PAGE:
+ return getSettings().resources[CGSettings.RESOURCE_PAGES_TEMPLATE];
+ case PAGE_TYPE_SLIDE:
+ return getSettings().resources[CGSettings.RESOURCE_SLIDES_TEMPLATE];
+ default:
+ return "";
+ }
+ }
+
+ private String getTargetTypeName(CGExporter exp)
+ {
+ return (exp.targetTypeName.equals(""))
+ ? (String) Properties.getPropertyValue(mediaDescriptor, "UIName")
+ : exp.targetTypeName;
+ }
+
+ private String getIcon(CGExporter exporter)
+ {
+ return exporter.cp_Icon.equals("") ? getIcon(this.appType) : exporter.cp_Icon;
+ }
+
+ private String getIcon(String appType)
+ {
+ //System.out.println("Getting Icon for: " + appType);
+ return appType + ".gif";
+ }
+
+ /**
+ * This method is used by the DataAware model
+ * and returns the index of the exporter of
+ * this document, <b>in the list of the
+ * exporters available for this type of document</b>
+ * @return
+ */
+ public short[] getExporter()
+ {
+ return new short[]
+ {
+ getExporterIndex()
+ };
+ }
+
+ /**
+ * @see getExporter()
+ */
+ public void setExporter(short[] exporter_)
+ {
+ Object exp = getSettings().getExporters(appType)[exporter_[0]];
+ cp_Exporter = (String) getSettings().cp_Exporters.getKey(exp);
+ }
+
+ /**
+ * @see getExporter()
+ * @return
+ */
+ private short getExporterIndex()
+ {
+ if (cp_Exporter == null)
+ {
+ return 0;
+ }
+ Object exporter = getSettings().cp_Exporters.getElement(cp_Exporter);
+ Object[] exporters = getSettings().getExporters(appType);
+ for (short i = 0; i < exporters.length; i++)
+ {
+ if (exporters[i] == exporter)
+ {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public String toString()
+ {
+ return localFilename;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGExporter.java b/wizards/com/sun/star/wizards/web/data/CGExporter.java
new file mode 100644
index 000000000000..c23073fbed01
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGExporter.java
@@ -0,0 +1,57 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.ConfigSet;
+
+public class CGExporter extends ConfigSetItem
+{
+
+ public String cp_Name;
+ public String cp_ExporterClass;
+ public boolean cp_OwnDirectory;
+ public boolean cp_SupportsFilename;
+ public String cp_DefaultFilename;
+ public String cp_Extension;
+ public String cp_SupportedMimeTypes;
+ public String cp_Icon;
+ public String cp_TargetType;
+ public boolean cp_Binary;
+ public int cp_PageType;
+ public String targetTypeName = "";
+ public ConfigSet cp_Arguments = new ConfigSet(CGArgument.class);
+
+ public String toString()
+ {
+ return cp_Name;
+ }
+
+ public boolean supports(String mime)
+ {
+ return (cp_SupportedMimeTypes.equals("") || cp_SupportedMimeTypes.indexOf(mime) > -1);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGFilter.java b/wizards/com/sun/star/wizards/web/data/CGFilter.java
new file mode 100644
index 000000000000..dc4f41df746b
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGFilter.java
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+public class CGFilter extends ConfigSetItem
+{
+
+ public String cp_Name;
+ //public boolean cp_Readonly;
+ public String cp_Filter;
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.java b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.java
new file mode 100644
index 000000000000..c12d4c92f535
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGGeneralInfo.java
@@ -0,0 +1,92 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.util.DateTime;
+import com.sun.star.wizards.common.*;
+import org.w3c.dom.Node;
+
+public class CGGeneralInfo extends ConfigGroup implements XMLProvider
+{
+
+ public String cp_Title;
+ public String cp_Description;
+ public String cp_Author;
+ public int cp_CreationDate;
+ public int cp_UpdateDate;
+ public String cp_Email;
+ public String cp_Copyright;
+
+ public Node createDOM(Node parent)
+ {
+ return XMLHelper.addElement(parent, "general-info",
+ new String[]
+ {
+ "title", "author", "description", "creation-date", "update-date", "email", "copyright"
+ },
+ new String[]
+ {
+ cp_Title, cp_Author, cp_Description, String.valueOf(cp_CreationDate), String.valueOf(cp_UpdateDate), cp_Email, cp_Copyright
+ });
+ }
+
+ public Integer getCreationDate()
+ {
+ if (cp_CreationDate == 0)
+ {
+ cp_CreationDate = currentDate();
+ }
+ return new Integer(cp_CreationDate);
+ }
+
+ public Integer getUpdateDate()
+ {
+ if (cp_UpdateDate == 0)
+ {
+ cp_UpdateDate = currentDate();
+ }
+ return new Integer(cp_UpdateDate);
+ }
+
+ public void setCreationDate(Integer i)
+ {
+ //System.out.println(i);
+ cp_CreationDate = i.intValue();
+ }
+
+ public void setUpdateDate(Integer i)
+ {
+ cp_UpdateDate = i.intValue();
+ }
+
+ private int currentDate()
+ {
+ DateTime dt = JavaTools.getDateTime(System.currentTimeMillis());
+ //System.out.println();
+ return dt.Day + dt.Month * 100 + dt.Year * 10000;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGIconSet.java b/wizards/com/sun/star/wizards/web/data/CGIconSet.java
new file mode 100644
index 000000000000..197c6c3e44b5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGIconSet.java
@@ -0,0 +1,35 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+public class CGIconSet extends ConfigSetItem
+{
+
+ public String cp_FNPrefix;
+ public String cp_FNPostfix;
+ public String cp_Name;
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGImage.java b/wizards/com/sun/star/wizards/web/data/CGImage.java
new file mode 100644
index 000000000000..e6d459bf48d5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGImage.java
@@ -0,0 +1,45 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * IconSet.java
+ *
+ * Created on 12. September 2003, 17:16
+ */
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class CGImage extends ConfigGroup
+{
+
+ public String cp_Href;
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGLayout.java b/wizards/com/sun/star/wizards/web/data/CGLayout.java
new file mode 100644
index 000000000000..9d9557c1615a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGLayout.java
@@ -0,0 +1,87 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.ui.UIConsts;
+import java.util.Hashtable;
+import java.util.Map;
+
+import javax.xml.transform.*;
+import javax.xml.transform.stream.StreamSource;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.FileAccess;
+
+public class CGLayout extends ConfigSetItem
+{
+
+ public String cp_Name;
+ public String cp_FSName;
+ private Map templates;
+
+ private void createTemplates(XMultiServiceFactory xmsf) throws Exception
+ {
+
+ templates = new Hashtable(3);
+
+ TransformerFactory tf = TransformerFactory.newInstance();
+
+ String workPath = getSettings().workPath;
+ FileAccess fa = new FileAccess(xmsf);
+ String stylesheetPath = fa.getURL(getSettings().workPath, "layouts/" + cp_FSName);
+
+ String[] files = fa.listFiles(stylesheetPath, false);
+
+ for (int i = 0; i < files.length; i++)
+ {
+ if (FileAccess.getExtension(files[i]).equals("xsl"))
+ {
+ templates.put(FileAccess.getFilename(files[i]), tf.newTemplates(new StreamSource(files[i])));
+ }
+ }
+ }
+
+ public Object[] getImageUrls()
+ {
+ Object[] sRetUrls = new Object[1];
+ int ResId = UIConsts.RID_IMG_WEB + (cp_Index * 2);
+ return new Integer[]
+ {
+ new Integer(ResId), new Integer(ResId + 1)
+ };
+ }
+
+ public Map getTemplates(XMultiServiceFactory xmsf) throws Exception
+ {
+
+ // TODO uncomment...
+ // if (templates==null)
+ createTemplates(xmsf);
+
+ return templates;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGPublish.java b/wizards/com/sun/star/wizards/web/data/CGPublish.java
new file mode 100644
index 000000000000..1a3746a3873d
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGPublish.java
@@ -0,0 +1,94 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.ConfigGroup;
+
+/**
+ *
+ * A Class which describes the publishing arguments
+ * in a session.
+ * Each session can contain different publishers, which are configured
+ * through such a CGPublish object.
+ */
+public class CGPublish extends ConfigGroup
+{
+
+ public boolean cp_Publish;
+ public String cp_URL;
+ public String cp_Username;
+ public String password;
+ /**
+ * cp_URL is the url given by the user
+ * for this publisher. (in UCB URL form)
+ * This one will be edited to result the "url"
+ * field, which is the true url, ucb uses to publish.
+ * It is used for example to add ftp username and password, or zip url
+ */
+ public String url;
+ /**
+ * if the user approved overwriting files in this publisher target
+ */
+ public boolean overwriteApproved;
+
+ /**
+ * here I get an URL from user input, and parse it to
+ * a UCB url...
+ * @param url
+ */
+ public void setURL(String path)
+ {
+ try
+ {
+ this.cp_URL = ((CGSettings) this.root).getFileAccess().getURL(path);
+ overwriteApproved = false;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ public String getURL()
+ {
+ try
+ {
+ return ((CGSettings) this.root).getFileAccess().getPath(cp_URL, null);
+ }
+ catch (Exception e)
+ {
+ e.printStackTrace();
+ return "";
+ }
+ }
+
+ private String ftpURL()
+ {
+ return "ftp://" + cp_Username +
+ ((password != null && password.length() > 0) ? ":" + password : "") + "@" + cp_URL.substring(7);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGSession.java b/wizards/com/sun/star/wizards/web/data/CGSession.java
new file mode 100644
index 000000000000..3acd570b7878
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGSession.java
@@ -0,0 +1,110 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import com.sun.star.wizards.common.*;
+
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+
+public class CGSession extends ConfigSetItem implements XMLProvider
+{
+
+ public String cp_InDirectory;
+ public String cp_OutDirectory;
+ public String cp_Name;
+ public CGContent cp_Content = new CGContent();
+ public CGDesign cp_Design = new CGDesign();
+ public CGGeneralInfo cp_GeneralInfo = new CGGeneralInfo();
+ public ConfigSet cp_Publishing = new ConfigSet(CGPublish.class);
+ public CGStyle style; // !!!
+ public boolean valid = false;
+
+ public Node createDOM(Node parent)
+ {
+ Node root = XMLHelper.addElement(parent, "session",
+ new String[]
+ {
+ "name", "screen-size"
+ },
+ new String[]
+ {
+ cp_Name, getScreenSize()
+ });
+
+ //cp_Design.createDOM(root);
+ cp_GeneralInfo.createDOM(root);
+ //cp_Publishing.createDOM(root);
+ cp_Content.createDOM(root);
+
+ return root;
+ }
+
+ private String getScreenSize()
+ {
+ switch (cp_Design.cp_OptimizeDisplaySize)
+ {
+ case 0:
+ return "640";
+ case 1:
+ return "800";
+ case 2:
+ return "1024";
+ default:
+ return "800";
+ }
+ }
+
+ public CGLayout getLayout()
+ {
+ return (CGLayout) ((CGSettings) root).cp_Layouts.getElement(cp_Design.cp_Layout);
+ }
+
+ public CGStyle getStyle()
+ {
+ return (CGStyle) ((CGSettings) root).cp_Styles.getElement(cp_Design.cp_Style);
+ }
+
+ public void setLayout(short[] layout)
+ {
+ //dummy
+ }
+
+ public Node createDOM()
+ throws ParserConfigurationException
+ {
+
+ DocumentBuilderFactory factory =
+ DocumentBuilderFactory.newInstance();
+ Document doc = factory.newDocumentBuilder().newDocument();
+ createDOM(doc);
+ return doc;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGSessionName.java b/wizards/com/sun/star/wizards/web/data/CGSessionName.java
new file mode 100644
index 000000000000..77cde79a8ca2
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGSessionName.java
@@ -0,0 +1,38 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+public class CGSessionName extends ConfigSetItem
+{
+
+ public String cp_Name;
+
+ public String toString()
+ {
+ return cp_Name;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGSettings.java b/wizards/com/sun/star/wizards/web/data/CGSettings.java
new file mode 100644
index 000000000000..ecc538b9fa83
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGSettings.java
@@ -0,0 +1,212 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * IconSet.java
+ *
+ * Created on 12. September 2003, 17:16
+ */
+package com.sun.star.wizards.web.data;
+
+import java.util.Hashtable;
+import java.util.Map;
+import java.util.Vector;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.container.NoSuchElementException;
+import com.sun.star.container.XNameAccess;
+import com.sun.star.i18n.NumberFormatIndex;
+import com.sun.star.lang.WrappedTargetException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.DateTime;
+import com.sun.star.wizards.common.*;
+import com.sun.star.wizards.common.Helper.DateUtils;
+
+/**
+ * @author rpiterman
+ */
+public class CGSettings extends ConfigGroup
+{
+
+ public String soTemplateDir;
+ public String soGalleryDir;
+ public String workPath = null;
+ public String cp_WorkDir;
+ public ConfigSet cp_Exporters = new ConfigSet(CGExporter.class);
+ public ConfigSet cp_Layouts = new ConfigSet(CGLayout.class);
+ public ConfigSet cp_Styles = new ConfigSet(CGStyle.class);
+ public ConfigSet cp_IconSets = new ConfigSet(CGIconSet.class);
+ public ConfigSet cp_BackgroundImages = new ConfigSet(CGImage.class);
+ public ConfigSet cp_SavedSessions = new ConfigSet(CGSessionName.class);
+ public ConfigSet cp_Filters = new ConfigSet(CGFilter.class);
+ public ConfigSet savedSessions = new ConfigSet(CGSessionName.class);
+ public CGSession cp_DefaultSession = new CGSession();
+ public String cp_LastSavedSession;
+ private Map exportersMap = new Hashtable();
+ private XMultiServiceFactory xmsf;
+ String[] resources;
+ public Formatter formatter;
+ public static final int RESOURCE_PAGES_TEMPLATE = 0;
+ public static final int RESOURCE_SLIDES_TEMPLATE = 1;
+ public static final int RESOURCE_CREATED_TEMPLATE = 2;
+ public static final int RESOURCE_UPDATED_TEMPLATE = 3;
+ public static final int RESOURCE_SIZE_TEMPLATE = 4;
+
+ public CGSettings(XMultiServiceFactory xmsf_, String[] resources_, Object document)
+ {
+ xmsf = xmsf_;
+ try
+ {
+ soTemplateDir = FileAccess.getOfficePath(xmsf, "Config", "", "");
+ soGalleryDir = FileAccess.getOfficePath(xmsf, "Gallery", "share", "");
+ root = this;
+ formatter = new Formatter(xmsf, document);
+ resources = resources_;
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ private static final CGExporter[] EMPTY_ARRAY_1 = new CGExporter[0];
+
+ public CGExporter[] getExporters(String mime)
+ {
+ CGExporter[] exps = (CGExporter[]) exportersMap.get(mime);
+ if (exps == null)
+ {
+ exportersMap.put(mime, exps = createExporters(mime));
+ }
+ return exps;
+ }
+
+ private CGExporter[] createExporters(String mime)
+ {
+ Object[] exporters = cp_Exporters.items();
+ Vector v = new Vector();
+ for (int i = 0; i < exporters.length; i++)
+ {
+ if (((CGExporter) exporters[i]).supports(mime))
+ {
+ try
+ {
+ v.add(exporters[i]);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+ }
+ return (CGExporter[]) v.toArray(EMPTY_ARRAY_1);
+ }
+
+ /**
+ * call after read.
+ * @param xmsf
+ * @param document the background document. used for date/number formatting.
+ */
+ public void configure(XMultiServiceFactory xmsf) throws Exception
+ {
+ workPath = FileAccess.connectURLs(soTemplateDir, cp_WorkDir);
+ calcExportersTargetTypeNames(xmsf);
+ }
+
+ private void calcExportersTargetTypeNames(XMultiServiceFactory xmsf) throws Exception
+ {
+ Object typeDetect = xmsf.createInstance("com.sun.star.document.TypeDetection");
+ XNameAccess xNameAccess = (XNameAccess) UnoRuntime.queryInterface(XNameAccess.class, typeDetect);
+ for (int i = 0; i < cp_Exporters.getSize(); i++)
+ {
+ calcExporterTargetTypeName(xNameAccess, (CGExporter) cp_Exporters.getElementAt(i));
+ }
+ }
+
+ private void calcExporterTargetTypeName(XNameAccess xNameAccess, CGExporter exporter)
+ throws NoSuchElementException,
+ WrappedTargetException
+ {
+ if (!exporter.cp_TargetType.equals(""))
+ {
+ exporter.targetTypeName =
+ (String) Properties.getPropertyValue(
+ (PropertyValue[]) xNameAccess.getByName(exporter.cp_TargetType),
+ "UIName");
+ }
+ }
+ FileAccess fileAccess;
+
+ FileAccess getFileAccess() throws Exception
+ {
+ return getFileAccess(xmsf);
+ }
+
+ FileAccess getFileAccess(XMultiServiceFactory xmsf) throws Exception
+ {
+ if (fileAccess == null)
+ {
+ fileAccess = new FileAccess(xmsf);
+ }
+ return fileAccess;
+ }
+
+ public class Formatter
+ {
+
+ private long docNullTime;
+ private int dateFormat, numberFormat;
+ private DateUtils dateUtils;
+
+ public Formatter(XMultiServiceFactory xmsf, Object document) throws Exception
+ {
+ dateUtils = new DateUtils(xmsf, document);
+ dateFormat = dateUtils.getFormat(NumberFormatIndex.DATE_SYS_DMMMYYYY);
+ numberFormat = dateUtils.getFormat(NumberFormatIndex.NUMBER_1000DEC2);
+ }
+
+ public String formatCreated(DateTime date)
+ {
+ String sDate = dateUtils.format(dateFormat, date);
+ return JavaTools.replaceSubString(resources[CGSettings.RESOURCE_CREATED_TEMPLATE], sDate, "%DATE");
+ }
+
+ public String formatUpdated(DateTime date)
+ {
+ String sDate = dateUtils.format(dateFormat, date);
+ return JavaTools.replaceSubString(resources[CGSettings.RESOURCE_UPDATED_TEMPLATE], sDate, "%DATE");
+ }
+
+ public String formatFileSize(int size)
+ {
+ float sizeInKB = ((float) size) / 1024f;
+ String sSize = dateUtils.getFormatter().convertNumberToString(numberFormat, sizeInKB);
+ return JavaTools.replaceSubString(resources[CGSettings.RESOURCE_SIZE_TEMPLATE], sSize, "%NUMBER");
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/CGStyle.java b/wizards/com/sun/star/wizards/web/data/CGStyle.java
new file mode 100644
index 000000000000..e6258d8c5fe1
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/CGStyle.java
@@ -0,0 +1,54 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.data;
+
+public class CGStyle extends ConfigSetItem
+{
+
+ public String cp_Name;
+ //public boolean cp_Readonly;
+ public String cp_CssHref;
+ public String cp_BackgroundImage;
+ public String cp_IconSet;
+
+ public String toString()
+ {
+ return cp_Name;
+ }
+
+ public String getBackgroundUrl()
+ {
+ if (cp_BackgroundImage == null || cp_BackgroundImage.equals(""))
+ {
+ return null;
+ }
+ else
+ {
+ return cp_BackgroundImage;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/ConfigSetItem.java b/wizards/com/sun/star/wizards/web/data/ConfigSetItem.java
new file mode 100644
index 000000000000..06c11a06178e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/ConfigSetItem.java
@@ -0,0 +1,55 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * SetItem.java
+ *
+ * Created on 16. September 2003, 12:29
+ */
+package com.sun.star.wizards.web.data;
+
+import com.sun.star.wizards.common.*;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class ConfigSetItem extends ConfigGroup implements Indexable
+{
+
+ public int cp_Index = -1;
+
+ public int getIndex()
+ {
+ return cp_Index;
+ }
+
+ public CGSettings getSettings()
+ {
+ return (CGSettings) root;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/data/TypeDetection.java b/wizards/com/sun/star/wizards/web/data/TypeDetection.java
new file mode 100644
index 000000000000..d6998ac74814
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/TypeDetection.java
@@ -0,0 +1,79 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * FileTypes.java
+ *
+ * Created on 29. September 2003, 18:52
+ */
+package com.sun.star.wizards.web.data;
+
+/**
+ *
+ * @author rpiterman
+ */
+public class TypeDetection
+{
+
+ /**
+ * a document which will open in writer.
+ */
+ public final static String WRITER_DOC = "writer";
+ /**
+ * a document which will open in calc.
+ */
+ public final static String CALC_DOC = "calc";
+ /**
+ * a document which will open in impress.
+ */
+ public final static String IMPRESS_DOC = "impress";
+ /**
+ * a document which will open in draw.
+ */
+ public final static String DRAW_DOC = "draw";
+ /**
+ * an HTML document
+ */
+ public final static String HTML_DOC = "html";
+ /**
+ * a GIF or an JPG file.
+ */
+ public final static String WEB_GRAPHICS = "graphics";
+ /**
+ * a PDF document.
+ */
+ public final static String PDF_DOC = "pdf";
+ /**
+ * a Sound file (mp3/wav ect.)
+ */
+ public final static String SOUND_FILE = "sound";
+ /**
+ * a File which can not be handled by neither SO or a Web browser (exe, jar, zip ect.)
+ */
+ public final static String NO_TYPE = "other";
+}
diff --git a/wizards/com/sun/star/wizards/web/data/makefile.mk b/wizards/com/sun/star/wizards/web/data/makefile.mk
new file mode 100644
index 000000000000..1bfc02cf8351
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/data/makefile.mk
@@ -0,0 +1,74 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = web_data
+PACKAGE = com$/sun$/star$/wizards$/web$/data
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar jut.jar java_uno.jar java_uno_accessbridge commonwizards.jar
+
+.IF "$(SYSTEM_SAXON)" == "YES"
+EXTRAJARFILES = $(SAXON_JAR)
+.ELSE
+JARFILES += saxon9.jar
+.ENDIF
+
+#JARCLASSDIRS = com$/sun$/star$/wizards$/web
+#JARTARGET = $(TARGET).jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ CGArgument.java \
+ CGContent.java \
+ CGDesign.java \
+ CGDocument.java \
+ CGExporter.java \
+ CGFilter.java \
+ CGGeneralInfo.java \
+ CGIconSet.java \
+ CGImage.java \
+ CGLayout.java \
+ CGPublish.java \
+ CGSession.java \
+ CGSessionName.java \
+ CGSettings.java \
+ CGStyle.java \
+ ConfigSetItem.java \
+ TypeDetection.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/wizards/com/sun/star/wizards/web/export/AbstractExporter.java b/wizards/com/sun/star/wizards/web/export/AbstractExporter.java
new file mode 100644
index 000000000000..97b1109add01
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/AbstractExporter.java
@@ -0,0 +1,192 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * AbstractExporter.java
+ *
+ * Created on 1. Oktober 2003, 16:12
+ */
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.beans.PropertyValue;
+import com.sun.star.document.MacroExecMode;
+import com.sun.star.document.UpdateDocMode;
+import com.sun.star.frame.XComponentLoader;
+import com.sun.star.frame.XDesktop;
+import com.sun.star.frame.XStorable;
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.util.XCloseable;
+import com.sun.star.wizards.common.Desktop;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.document.OfficeDocument;
+import com.sun.star.wizards.text.TextDocument;
+import com.sun.star.wizards.web.data.CGArgument;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGExporter;
+import com.sun.star.wizards.web.data.TypeDetection;
+
+/**
+ *
+ * @author rpiterman
+ */
+public abstract class AbstractExporter implements Exporter
+{
+
+ protected CGExporter exporter;
+ protected FileAccess fileAccess;
+
+ protected void storeToURL(Object officeDocument, Properties props, String targetUrl, String filterName, PropertyValue[] filterData)
+ throws IOException
+ {
+
+ props = new Properties();
+ props.put("FilterName", filterName);
+
+ if (filterData.length > 0)
+ {
+ props.put("FilterData", filterData);
+ }
+ XStorable xs = ((XStorable) UnoRuntime.queryInterface(XStorable.class, officeDocument));
+ PropertyValue[] o = props.getProperties();
+ xs.storeToURL(targetUrl, o);
+ }
+
+ protected void storeToURL(Object officeDocument, String targetUrl, String filterName, PropertyValue[] filterData)
+ throws IOException
+ {
+
+ storeToURL(officeDocument, new Properties(), targetUrl, filterName, filterData);
+ }
+
+ protected void storeToURL(Object officeDocument, String targetUrl, String filterName)
+ throws IOException
+ {
+
+ storeToURL(officeDocument, new Properties(), targetUrl, filterName, new PropertyValue[0]);
+
+ }
+
+ protected String getArgument(String name, CGExporter p)
+ {
+ return ((CGArgument) p.cp_Arguments.getElement(name)).cp_Value;
+ }
+
+ protected Object openDocument(CGDocument doc, XMultiServiceFactory xmsf)
+ throws com.sun.star.io.IOException
+ {
+ Object document = null;
+ //open the document.
+ try
+ {
+ XDesktop desktop = Desktop.getDesktop(xmsf);
+ Properties props = new Properties();
+ props.put("Hidden", Boolean.TRUE);
+ props.put("MacroExecutionMode", new Short(MacroExecMode.NEVER_EXECUTE));
+ props.put("UpdateDocMode", new Short(UpdateDocMode.NO_UPDATE));
+ document = ((XComponentLoader) UnoRuntime.queryInterface(XComponentLoader.class, desktop)).loadComponentFromURL(doc.cp_URL, "_blank", 0, props.getProperties());
+ }
+ catch (com.sun.star.lang.IllegalArgumentException iaex)
+ {
+ }
+ //try to get the number of pages in the document;
+ try
+ {
+ pageCount(doc, document);
+ }
+ catch (Exception ex)
+ {
+ //Here i do nothing since pages is not *so* important.
+ }
+ return document;
+ }
+
+ protected void closeDocument(Object doc, XMultiServiceFactory xmsf)
+ {
+ /*OfficeDocument.dispose(
+ xmsf,
+ (XComponent) UnoRuntime.queryInterface(XComponent.class, doc));*/
+ try
+ {
+ XCloseable xc = (XCloseable) UnoRuntime.queryInterface(XCloseable.class, doc);
+ xc.close(false);
+ }
+ catch (Exception ex)
+ {
+ ex.printStackTrace();
+ }
+ }
+
+ private void pageCount(CGDocument doc, Object document)
+ {
+ if (doc.appType.equals(TypeDetection.WRITER_DOC))
+ {
+ doc.pages = TextDocument.getPageCount(document);
+ }
+ else if (doc.appType.equals(TypeDetection.IMPRESS_DOC))
+ {
+ doc.pages = OfficeDocument.getSlideCount(document);
+ }
+ else if (doc.appType.equals(TypeDetection.DRAW_DOC))
+ {
+ doc.pages = OfficeDocument.getSlideCount(document);
+ }
+ }
+
+ public void init(CGExporter exporter_)
+ {
+ exporter = exporter_;
+ }
+
+ protected FileAccess getFileAccess(XMultiServiceFactory xmsf)
+ {
+ if (fileAccess == null)
+ {
+ try
+ {
+ fileAccess = new FileAccess(xmsf);
+ }
+ catch (Exception ex)
+ {
+ }
+ }
+ return fileAccess;
+ }
+
+ protected void calcFileSize(CGDocument doc, String url, XMultiServiceFactory xmsf)
+ {
+ /*if the exporter exports to a
+ * binary format, get the size of the destination.
+ */
+ if (exporter.cp_Binary)
+ {
+ doc.sizeBytes = getFileAccess(xmsf).getSize(url);
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.java b/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.java
new file mode 100644
index 000000000000..de13a8c31bbe
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/ConfiguredExporter.java
@@ -0,0 +1,98 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+
+/*
+ * Created on 31.10.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.export;
+
+import java.util.Iterator;
+
+import com.sun.star.wizards.web.data.CGArgument;
+import com.sun.star.wizards.web.data.CGExporter;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ConfiguredExporter extends FilterExporter
+{
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.export.Exporter#init(com.sun.star.wizards.web.data.CGExporter)
+ */
+ public void init(CGExporter exporter)
+ {
+ super.init(exporter);
+ for (Iterator i = exporter.cp_Arguments.keys().iterator(); i.hasNext();)
+ {
+ Object key = i.next();
+ if (!key.equals("Filter"))
+ {
+ Object value = exporter.cp_Arguments.getElement(key);
+ props.put(key, cast(((CGArgument) value).cp_Value));
+ }
+ }
+ }
+
+ private Object cast(String s)
+ {
+ String s1 = s.substring(1);
+ char c = s.charAt(0);
+ switch (c)
+ {
+ case '$':
+ return s1;
+ case '%':
+ return Integer.valueOf(s1);
+ case '#':
+ return Short.valueOf(s1);
+ case '&':
+ return Double.valueOf(s1);
+ case 'f':
+ if (s.equals("false"))
+ {
+ return Boolean.FALSE;
+ }
+ break;
+ case 't':
+ if (s.equals("true"))
+ {
+ return Boolean.TRUE;
+ }
+ break;
+ }
+ return null;
+ }
+}
+
diff --git a/wizards/com/sun/star/wizards/web/export/CopyExporter.java b/wizards/com/sun/star/wizards/web/export/CopyExporter.java
new file mode 100644
index 000000000000..f620e3b106d3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/CopyExporter.java
@@ -0,0 +1,88 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 17.10.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.FileAccess;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGDocument;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class CopyExporter extends AbstractExporter
+{
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.export.Exporter#export(java.lang.Object, java.io.File, com.sun.star.wizards.web.data.CGSettings, com.sun.star.lang.XMultiServiceFactory)
+ */
+ public boolean export(CGDocument source, String target, XMultiServiceFactory xmsf, Task task)
+ {
+ try
+ {
+ task.advance(true);
+
+
+ /*
+ * this will open the document, and calculate the pages/slides number
+ * in it.
+ */
+ if (exporter.cp_PageType > 0)
+ {
+ closeDocument(openDocument(source, xmsf), xmsf);
+ }
+
+ task.advance(true);
+
+ String newTarget = FileAccess.connectURLs(
+ FileAccess.getParentDir(target), source.urlFilename);
+
+ boolean b = getFileAccess(xmsf).copy(source.cp_URL, newTarget);
+
+ task.advance(true);
+
+ calcFileSize(source, newTarget, xmsf);
+
+ return b;
+
+ }
+ catch (Exception ex)
+ {
+ return false;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/export/Exporter.java b/wizards/com/sun/star/wizards/web/export/Exporter.java
new file mode 100644
index 000000000000..90f145cf1241
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/Exporter.java
@@ -0,0 +1,61 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.*;
+
+/**
+ *
+ * @author rpiterman
+ */
+public interface Exporter
+{
+
+ /**
+ * This method exports a document with a specified filter.<br/>
+ * The method is responsible for exporting the given source document
+ * to the given target directory.
+ * The exporter *must* also set the given CGDocument sizeBytes field to the
+ * size of the converted document, *if* the target document is
+ * of a binary format.
+ * always use source.urlFilename as destination filename.
+ * @param source is a CGDocument object.
+ * @param target contains the URL of a directory to which the
+ * file should be exported to.
+ * @param xmsf this is a basic multiServiceFactory.
+ * @param task - a task monitoring object. This should advance
+ * (call task.advacne(true) ) 3 times, while exporting.
+ *
+ */
+ public boolean export(CGDocument source, String targetDirectory, XMultiServiceFactory xmsf, Task task) throws IOException;
+
+ public void init(CGExporter exporter);
+}
+
diff --git a/wizards/com/sun/star/wizards/web/export/FilterExporter.java b/wizards/com/sun/star/wizards/web/export/FilterExporter.java
new file mode 100644
index 000000000000..8ff666d5ec87
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/FilterExporter.java
@@ -0,0 +1,89 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.common.Properties;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGExporter;
+
+/**
+ * @author rpiterman
+ *
+ * An exporter which is configured with a filter name, and
+ * uses the specified filter to export documents.
+ */
+public class FilterExporter extends AbstractExporter
+{
+
+ protected String filterName;
+ protected Properties props = new Properties();
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.export.Exporter#export(java.lang.Object, java.io.File, com.sun.star.wizards.web.data.CGSettings, com.sun.star.lang.XMultiServiceFactory)
+ */
+ public boolean export(CGDocument source, String target, XMultiServiceFactory xmsf, Task task) throws IOException
+ {
+
+ boolean result = true;
+ Object document = null;
+
+ try
+ {
+ document = openDocument(source, xmsf);
+ task.advance(true);
+ storeToURL(document, target, filterName, props.getProperties());
+ task.advance(true);
+
+ }
+ catch (IOException iox)
+ {
+ iox.printStackTrace(System.out);
+ result = false;
+ throw iox;
+ }
+ finally
+ {
+ closeDocument(document, xmsf);
+ calcFileSize(source, target, xmsf);
+ task.advance(true);
+ }
+ return result;
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.export.Exporter#init(com.sun.star.wizards.web.data.CGExporter)
+ */
+ public void init(CGExporter exporter_)
+ {
+ super.init(exporter_);
+ filterName = getArgument("Filter", exporter_);
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java
new file mode 100644
index 000000000000..07a79e15040e
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/ImpressHTMLExporter.java
@@ -0,0 +1,105 @@
+/*************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+package com.sun.star.wizards.web.export;
+
+import com.sun.star.io.IOException;
+import com.sun.star.lang.XMultiServiceFactory;
+import com.sun.star.wizards.ui.event.Task;
+import com.sun.star.wizards.web.data.CGDocument;
+import com.sun.star.wizards.web.data.CGSession;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ImpressHTMLExporter extends ConfiguredExporter
+{
+
+ private static final Integer SMALL_IMAGE = new Integer(512);
+ private static final Integer MEDIUM_IMAGE = new Integer(640);
+ private static final Integer LARGE_IMAGE = new Integer(800);
+
+ public boolean export(CGDocument source, String targetDirectory, XMultiServiceFactory xmsf, Task task) throws IOException
+ {
+
+ /* here set some filter specific properties.
+ * other properties, which are not dependant on
+ * user input are set through the exporter
+ * configuration.
+ */
+
+ CGSession session = getSession(source);
+
+ props.put("Author", source.cp_Author);
+ props.put("Email", session.cp_GeneralInfo.cp_Email);
+ props.put("HomepageURL", getHomepageURL(session));
+ props.put("UserText", source.cp_Title);
+
+ props.put("Width", getImageWidth(session));
+
+ /*
+ * props.put("BackColor",...);
+ * props.put("TextColor",...);
+ * props.put("LinkColor",...);
+ * props.put("VLinkColor",...);
+ * props.put("ALinkColor",...);
+ */
+ props.put("UseButtonSet", new Integer(session.cp_Design.cp_IconSet));
+
+
+ //now export
+ return super.export(source, targetDirectory, xmsf, task);
+
+ }
+
+ private String getHomepageURL(CGSession session)
+ {
+ return "../" +
+ (exporter.cp_OwnDirectory ? "../index.html" : "index.html");
+ }
+
+ private Integer getImageWidth(CGSession session)
+ {
+ switch (session.cp_Design.cp_OptimizeDisplaySize)
+ {
+ case 0:
+ return SMALL_IMAGE;
+ case 1:
+ return MEDIUM_IMAGE;
+ case 2:
+ return LARGE_IMAGE;
+ }
+ return MEDIUM_IMAGE;
+ }
+
+ private CGSession getSession(CGDocument doc)
+ {
+ return doc.getSettings().cp_DefaultSession;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/export/makefile.mk b/wizards/com/sun/star/wizards/web/export/makefile.mk
new file mode 100644
index 000000000000..46cd65044e81
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/export/makefile.mk
@@ -0,0 +1,63 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = web_export
+PACKAGE = com$/sun$/star$/wizards$/web$/export
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar java_uno.jar java_uno_accessbridge commonwizards.jar
+
+.IF "$(SYSTEM_SAXON)" == "YES"
+EXTRAJARFILES = $(SAXON_JAR)
+.ELSE
+JARFILES += saxon9.jar
+.ENDIF
+
+#JARCLASSDIRS = com$/sun$/star$/wizards$/web
+#JARTARGET = $(TARGET).jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ AbstractExporter.java \
+ ConfiguredExporter.java \
+ CopyExporter.java \
+ Exporter.java \
+ FilterExporter.java \
+ ImpressHTMLExporter.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
diff --git a/wizards/com/sun/star/wizards/web/makefile.mk b/wizards/com/sun/star/wizards/web/makefile.mk
new file mode 100644
index 000000000000..2e0394d2971c
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/makefile.mk
@@ -0,0 +1,93 @@
+#*************************************************************************
+#
+# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+#
+# Copyright 2000, 2010 Oracle and/or its affiliates.
+#
+# OpenOffice.org - a multi-platform office productivity suite
+#
+# This file is part of OpenOffice.org.
+#
+# OpenOffice.org is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License version 3
+# only, as published by the Free Software Foundation.
+#
+# OpenOffice.org is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License version 3 for more details
+# (a copy is included in the LICENSE file that accompanied this code).
+#
+# You should have received a copy of the GNU Lesser General Public License
+# version 3 along with OpenOffice.org. If not, see
+# <http://www.openoffice.org/license.html>
+# for a copy of the LGPLv3 License.
+#
+#*************************************************************************
+
+PRJ = ..$/..$/..$/..$/..
+PRJNAME = wizards
+TARGET = web
+PACKAGE = com$/sun$/star$/wizards$/web
+
+# --- Settings -----------------------------------------------------
+
+.INCLUDE : settings.mk
+#.INCLUDE : $(PRJ)$/util$/makefile.pmk
+JARFILES= unoil.jar jurt.jar ridl.jar juh.jar jut.jar java_uno.jar java_uno_accessbridge commonwizards.jar
+
+.IF "$(SYSTEM_SAXON)" == "YES"
+EXTRAJARFILES = $(SAXON_JAR)
+.ELSE
+JARFILES += saxon9.jar
+.ENDIF
+
+CUSTOMMANIFESTFILE= MANIFEST.MF
+
+JARCLASSDIRS = com$/sun$/star$/wizards$/web
+JARTARGET = web.jar
+JARCLASSPATH = \
+ commonwizards.jar saxon9.jar
+
+# --- Files --------------------------------------------------------
+
+JAVAFILES= \
+ AbstractErrorHandler.java \
+ BackgroundsDialog.java \
+ CallWizard.java \
+ ErrorHandler.java \
+ ExtensionVerifier.java \
+ FTPDialog.java \
+ FTPDialogResources.java \
+ IconsDialog.java \
+ ImageListDialog.java \
+ LogTaskListener.java \
+ Process.java \
+ ProcessErrorHandler.java \
+ ProcessErrors.java \
+ ProcessStatusRenderer.java \
+ StatusDialog.java \
+ StylePreview.java \
+ TOCPreview.java \
+ WebWizard.java \
+ WebWizardConst.java \
+ WebWizardDialog.java \
+ WebWizardDialogResources.java \
+ WWD_Events.java \
+ WWD_General.java \
+ WWD_Startup.java \
+ WWHID.java
+
+JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class)
+
+# --- Targets ------------------------------------------------------
+
+.INCLUDE : target.mk
+
+ALLTAR : $(MISC)/web.component
+
+$(MISC)/web.component .ERRREMOVE : $(SOLARENV)/bin/createcomponent.xslt \
+ web.component
+ $(XSLTPROC) --nonet --stringparam uri \
+ '$(COMPONENTPREFIX_BASIS_JAVA)$(JARTARGET)' -o $@ \
+ $(SOLARENV)/bin/createcomponent.xslt web.component
diff --git a/wizards/com/sun/star/wizards/web/status/ErrorLog.java b/wizards/com/sun/star/wizards/web/status/ErrorLog.java
new file mode 100644
index 000000000000..d039fa5c64a3
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/ErrorLog.java
@@ -0,0 +1,69 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 04.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class ErrorLog implements ErrorReporter
+{
+
+ private List errors = new Vector();
+
+ public void error(Exception ex, Object obj, String s)
+ {
+ errors.add(new Err(ex, obj, s));
+ }
+
+ public class Err
+ {
+
+ public Exception exception;
+ public Object argument;
+ public String string;
+
+ public Err(Exception ex, Object arg, String s)
+ {
+ exception = ex;
+ argument = arg;
+ string = s;
+ }
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/status/ErrorReporter.java b/wizards/com/sun/star/wizards/web/status/ErrorReporter.java
new file mode 100644
index 000000000000..4d967e24f3df
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/ErrorReporter.java
@@ -0,0 +1,46 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 14.10.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface ErrorReporter
+{
+
+ public void error(Exception ex, Object arg, String st);
+}
diff --git a/wizards/com/sun/star/wizards/web/status/LogTaskListener.java b/wizards/com/sun/star/wizards/web/status/LogTaskListener.java
new file mode 100644
index 000000000000..d4109da3406f
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/LogTaskListener.java
@@ -0,0 +1,87 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 04.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+import java.io.PrintStream;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class LogTaskListener implements TaskListener
+{
+
+ private PrintStream out;
+
+ public LogTaskListener(PrintStream os)
+ {
+ out = os;
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskStarted(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskStarted(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " STARTED.");
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskFinished(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskFinished(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " FINISHED: " + te.getTask().getSuccessfull() + "/" + te.getTask().getMax() + "Succeeded.");
+
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#taskStatusChanged(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void taskStatusChanged(TaskEvent te)
+ {
+ out.println("TASK " + te.getTask().getTaskName() + " status : " + te.getTask().getSuccessfull() + "(+" + te.getTask().getFailed() + ")/" + te.getTask().getMax());
+ }
+
+ /* (non-Javadoc)
+ * @see com.sun.star.wizards.web.status.TaskListener#subtaskNameChanged(com.sun.star.wizards.web.status.TaskEvent)
+ */
+ public void subtaskNameChanged(TaskEvent te)
+ {
+ out.println("SUBTASK Name:" + te.getTask().getSubtaskName());
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/status/Task.java b/wizards/com/sun/star/wizards/web/status/Task.java
new file mode 100644
index 000000000000..0fb0bf494286
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/Task.java
@@ -0,0 +1,196 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 17.10.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class Task
+{
+
+ private int successfull = 0;
+ private int failed = 0;
+ private int max = 0;
+ private String taskName;
+ private List listeners = new Vector();
+ private String subtaskName;
+
+ public Task(String taskName_, String subtaskName_, int max_)
+ {
+ taskName = taskName_;
+ subtaskName = subtaskName_;
+ max = max_;
+ }
+
+ public void start()
+ {
+ fireTaskStarted();
+ }
+
+ public int getMax()
+ {
+ return max;
+ }
+
+ public void setMax(int max_)
+ {
+ max = max_;
+ fireTaskStatusChanged();
+ }
+
+ public void advance(boolean success_)
+ {
+ if (success_)
+ {
+ successfull++;
+ }
+ else
+ {
+ failed++;
+ }
+ fireTaskStatusChanged();
+ if (failed + successfull == max)
+ {
+ fireTaskFinished();
+ }
+ }
+
+ public void advance(boolean success_, String nextSubtaskName)
+ {
+ advance(success_);
+ setSubtaskName(nextSubtaskName);
+ }
+
+ public int getStatus()
+ {
+ return successfull + failed;
+ }
+
+ public void addTaskListener(TaskListener tl)
+ {
+ listeners.add(tl);
+ }
+
+ public void removeTaskListener(TaskListener tl)
+ {
+ listeners.remove(tl);
+ }
+
+ protected void fireTaskStatusChanged()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_STATUS_CHANGED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskStatusChanged(te);
+ }
+ }
+
+ protected void fireTaskStarted()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_STARTED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskStarted(te);
+ }
+ }
+
+ protected void fireTaskFinished()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.TASK_FINISHED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).taskFinished(te);
+ }
+ }
+
+ protected void fireSubtaskNameChanged()
+ {
+ TaskEvent te = new TaskEvent(this, TaskEvent.SUBTASK_NAME_CHANGED);
+
+ for (int i = 0; i < listeners.size(); i++)
+ {
+ ((TaskListener) listeners.get(i)).subtaskNameChanged(te);
+ }
+ }
+
+ /**
+ * @return
+ */
+ public String getSubtaskName()
+ {
+ return subtaskName;
+ }
+
+ /**
+ * @return
+ */
+ public String getTaskName()
+ {
+ return taskName;
+ }
+
+ /**
+ * @param string
+ */
+ public void setSubtaskName(String string)
+ {
+ subtaskName = string;
+ fireSubtaskNameChanged();
+ }
+
+ /**
+ * @return
+ */
+ public int getFailed()
+ {
+ return failed;
+ }
+
+ /**
+ * @return
+ */
+ public int getSuccessfull()
+ {
+ return successfull;
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/status/TaskEvent.java b/wizards/com/sun/star/wizards/web/status/TaskEvent.java
new file mode 100644
index 000000000000..dd1d06c1938a
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/TaskEvent.java
@@ -0,0 +1,71 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 04.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+import java.util.EventObject;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public class TaskEvent extends EventObject
+{
+
+ public static final int TASK_STARTED = 1;
+ public static final int TASK_FINISHED = 2;
+ public static final int TASK_STATUS_CHANGED = 3;
+ public static final int SUBTASK_NAME_CHANGED = 4;
+ private int type;
+
+ /**
+ * general constructor-
+ * @param source
+ * @param type_
+ * @param max_
+ * @param success_
+ * @param failed_
+ */
+ public TaskEvent(Task source, int type_)
+ {
+ super(source);
+ type = type_;
+ }
+
+ public Task getTask()
+ {
+ return (Task) getSource();
+ }
+}
diff --git a/wizards/com/sun/star/wizards/web/status/TaskListener.java b/wizards/com/sun/star/wizards/web/status/TaskListener.java
new file mode 100644
index 000000000000..63745bf83a62
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/status/TaskListener.java
@@ -0,0 +1,58 @@
+/*
+ ************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * Copyright 2000, 2010 Oracle and/or its affiliates.
+ *
+ * OpenOffice.org - a multi-platform office productivity suite
+ *
+ * This file is part of OpenOffice.org.
+ *
+ * OpenOffice.org is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License version 3
+ * only, as published by the Free Software Foundation.
+ *
+ * OpenOffice.org is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License version 3 for more details
+ * (a copy is included in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * version 3 along with OpenOffice.org. If not, see
+ * <http://www.openoffice.org/license.html>
+ * for a copy of the LGPLv3 License.
+ *
+ ************************************************************************/
+/*
+ * Created on 04.11.2003
+ *
+ * To change the template for this generated file go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+package com.sun.star.wizards.web.status;
+
+import java.util.EventListener;
+
+/**
+ * @author rpiterman
+ *
+ * To change the template for this generated type comment go to
+ * Window>Preferences>Java>Code Generation>Code and Comments
+ */
+public interface TaskListener extends EventListener
+{
+
+ public void taskStarted(TaskEvent te);
+
+ public void taskFinished(TaskEvent te);
+
+ /**
+ * is called when the status of the task has advanced.
+ * @param te
+ */
+ public void taskStatusChanged(TaskEvent te);
+
+ public void subtaskNameChanged(TaskEvent te);
+}
diff --git a/wizards/com/sun/star/wizards/web/web.component b/wizards/com/sun/star/wizards/web/web.component
new file mode 100644
index 000000000000..763438f965a5
--- /dev/null
+++ b/wizards/com/sun/star/wizards/web/web.component
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--**********************************************************************
+*
+* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+*
+* Copyright 2000, 2010 Oracle and/or its affiliates.
+*
+* OpenOffice.org - a multi-platform office productivity suite
+*
+* This file is part of OpenOffice.org.
+*
+* OpenOffice.org is free software: you can redistribute it and/or modify
+* it under the terms of the GNU Lesser General Public License version 3
+* only, as published by the Free Software Foundation.
+*
+* OpenOffice.org is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU Lesser General Public License version 3 for more details
+* (a copy is included in the LICENSE file that accompanied this code).
+*
+* You should have received a copy of the GNU Lesser General Public License
+* version 3 along with OpenOffice.org. If not, see
+* <http://www.openoffice.org/license.html>
+* for a copy of the LGPLv3 License.
+*
+**********************************************************************-->
+
+<component loader="com.sun.star.loader.Java2"
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation
+ name="com.sun.star.wizards.web.CallWizard$WizardImplementation">
+ <service name="com.sun.star.wizards.web.CallWizard"/>
+ </implementation>
+</component>