1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 package com.sun.star.wizards.report;
24 
25 import com.sun.star.awt.VclWindowPeerAttribute;
26 import com.sun.star.awt.XWindowPeer;
27 import com.sun.star.beans.PropertyValue;
28 import com.sun.star.container.XNameAccess;
29 import com.sun.star.container.XNameContainer;
30 import com.sun.star.container.XNamed;
31 import com.sun.star.frame.XFrame;
32 import com.sun.star.lang.XComponent;
33 import com.sun.star.sdb.CommandType;
34 import com.sun.star.table.XCellRange;
35 import com.sun.star.text.XTextContent;
36 import com.sun.star.text.XTextCursor;
37 import com.sun.star.text.XTextDocument;
38 import com.sun.star.text.XTextTable;
39 import com.sun.star.uno.Any;
40 import com.sun.star.uno.UnoRuntime;
41 import com.sun.star.uno.XInterface;
42 import com.sun.star.wizards.common.FileAccess;
43 import com.sun.star.wizards.common.Helper;
44 import com.sun.star.wizards.common.InvalidQueryException;
45 import com.sun.star.wizards.common.JavaTools;
46 import com.sun.star.wizards.common.Resource;
47 import com.sun.star.lang.XMultiServiceFactory;
48 
49 import com.sun.star.sdb.application.DatabaseObject;
50 import com.sun.star.sdb.application.XDatabaseDocumentUI;
51 import com.sun.star.wizards.common.PropertyNames;
52 import com.sun.star.wizards.common.SystemDialog;
53 import com.sun.star.wizards.db.DBMetaData;
54 import com.sun.star.wizards.document.OfficeDocument;
55 import com.sun.star.wizards.ui.UIConsts;
56 import java.util.ArrayList;
57 import java.util.Vector;
58 import java.util.logging.Level;
59 import java.util.logging.Logger;
60 
61 /**
62  *
63  * @author ll93751
64  */
65 public class ReportTextImplementation extends ReportImplementationHelper implements IReportDocument
66 {
67 
68     private ReportTextDocument  m_aDoc;
69     private Object              m_aInitialDoc;
70     private Resource            m_resource;
71     private XDatabaseDocumentUI m_documentUI;
72 
setInitialDocument(Object _aDoc)73     private void setInitialDocument(Object _aDoc)
74     {
75         m_aInitialDoc = _aDoc;
76     }
77 
78     /**
79      * This is a TEMPORARY function to give direct access to the old text document.
80      * We have to remove this!!!
81      * @return
82      */
getDoc()83     ReportTextDocument getDoc()
84     {
85         if (m_aDoc == null)
86         {
87             if (m_aInitialDoc instanceof XTextDocument)
88             {
89                 m_aDoc = new ReportTextDocument(getMSF(), (XTextDocument) m_aInitialDoc, m_resource, getRecordParser());
90             }
91             else if (m_aInitialDoc instanceof String)
92             {
93                 m_aDoc = new ReportTextDocument(getMSF(), (String) m_aInitialDoc, m_resource, getRecordParser());
94             }
95             else
96             {
97                 throw new RuntimeException("Unknown type for setInitialDocument() given.");
98             }
99         }
100         return m_aDoc;
101     }
102 
clearDocument()103     public void clearDocument()
104     {
105         getDoc().oTextSectionHandler.removeAllTextSections();
106         getDoc().oTextTableHandler.removeAllTextTables();
107         getDoc().DBColumnsVector = new Vector();
108     }
109 
ReportTextImplementation( XMultiServiceFactory i_serviceFactory )110     protected ReportTextImplementation( XMultiServiceFactory i_serviceFactory )
111     {
112         super( i_serviceFactory, ReportLayouter.SOOPTLANDSCAPE );
113     }
114 
initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource )115     public void initialize( final XDatabaseDocumentUI i_documentUI, final Resource i_resource )
116     {
117         m_documentUI = i_documentUI;
118         m_resource = i_resource;
119 
120 		if ( m_aInitialDoc == null )
121 			setInitialDocument( getLayoutPath() );
122 
123         initialResources();
124     }
125 
create( XMultiServiceFactory i_serviceFactory, XDatabaseDocumentUI i_documentUI, XTextDocument i_initialDocument, Resource i_resources )126     static IReportDocument create( XMultiServiceFactory i_serviceFactory, XDatabaseDocumentUI i_documentUI, XTextDocument i_initialDocument, Resource i_resources )
127     {
128         ReportTextImplementation a = new ReportTextImplementation( i_serviceFactory );
129         a.setInitialDocument(i_initialDocument);
130         a.initialize( i_documentUI, i_resources );
131         return a;
132     }
133 
getWizardParent()134     public XWindowPeer getWizardParent()
135     {
136         return getDoc().xWindowPeer;
137     }
138     static String sMsgQueryCreationImpossible;
139     static String sReportFormNotExisting;
140     static String sMsgHiddenControlMissing;
141     static String sMsgEndAutopilot;
142     static String sMsgConnectionImpossible;
143     static String sMsgNoConnection;
144     static String[] ReportMessages = new String[4];
145 
initialResources()146     private void initialResources()
147     {
148         sReportFormNotExisting = m_resource.getResText(UIConsts.RID_REPORT + 64);
149         sMsgQueryCreationImpossible = m_resource.getResText(UIConsts.RID_REPORT + 65);
150         sMsgHiddenControlMissing = m_resource.getResText(UIConsts.RID_REPORT + 66);
151         sMsgEndAutopilot = m_resource.getResText(UIConsts.RID_DB_COMMON + 33);
152         sMsgNoConnection = m_resource.getResText(UIConsts.RID_DB_COMMON + 14);
153     }
154 
addTextSectionCopies()155     public void addTextSectionCopies()
156     {
157         m_aDoc.setLayoutSectionsVisible(false);
158         XTextCursor xTextCursor = ReportTextDocument.createTextCursor(m_aDoc.xTextDocument.getText());
159         xTextCursor.gotoStart(false);
160         for (int i = 0; i < getRecordParser().GroupFieldNames.length; i++)
161         {
162             XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(i + 1), null, null);
163             xNamedTextSection.setName(ReportTextDocument.COPYOFGROUPSECTION + (i + 1));
164             renameTableofLastSection(ReportTextDocument.COPYOFTBLGROUPSECTION + (i + 1));
165         }
166         if (getRecordParser().getRecordFieldNames().length > 0)
167         {
168             XNamed xNamedTextSection = addLinkedTextSection(xTextCursor, ReportTextDocument.RECORDSECTION, null, null);
169             xNamedTextSection.setName(ReportTextDocument.COPYOFRECORDSECTION);
170             renameTableofLastSection(ReportTextDocument.COPYOFTBLRECORDSECTION);
171         }
172     }
173 
addLinkedTextSection(XTextCursor xTextCursor, String sLinkRegion, DBColumn CurDBColumn, Object CurGroupValue)174     private XNamed addLinkedTextSection(XTextCursor xTextCursor, String sLinkRegion, DBColumn CurDBColumn, Object CurGroupValue)
175     {
176         XNamed xNamedTextSection = null;
177         try
178         {
179             XInterface xTextSection = (XInterface) getDocumentServiceFactory().createInstance("com.sun.star.text.TextSection");
180             XTextContent xTextSectionContent = UnoRuntime.queryInterface( XTextContent.class, xTextSection );
181             xNamedTextSection = UnoRuntime.queryInterface( XNamed.class, xTextSection );
182             xTextCursor.gotoEnd(false);
183             xTextCursor.getText().insertTextContent(xTextCursor, xTextSectionContent, true);
184             Helper.setUnoPropertyValue(xTextSection, "LinkRegion", sLinkRegion);
185             if (CurDBColumn != null)
186             {
187                 boolean bIsGroupTable = (!sLinkRegion.equals(ReportTextDocument.RECORDSECTION));
188                 if (bIsGroupTable)
189                 {
190                     XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
191                     XCellRange xCellRange = UnoRuntime.queryInterface( XCellRange.class, xTextTable );
192                     CurDBColumn.modifyCellContent(xCellRange, CurGroupValue);
193                 }
194             }
195         }
196         catch (Exception ex)
197         {
198             Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex );
199         }
200         return xNamedTextSection;
201     }
202 
renameTableofLastSection(String _snewname)203     private void renameTableofLastSection(String _snewname)
204     {
205         XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
206         XNamed xNamedTable = UnoRuntime.queryInterface( XNamed.class, xTextTable );
207         xNamedTable.setName(_snewname);
208     }
209 
showMessageBox(String windowServiceName, int windowAttribute, String MessageText)210     private int showMessageBox(String windowServiceName, int windowAttribute, String MessageText)
211     {
212         return SystemDialog.showMessageBox(getMSF(), getWizardParent(), windowServiceName, windowAttribute, MessageText);
213     }
214 
reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] _properties)215     public boolean reconnectToDatabase(XMultiServiceFactory xMSF, PropertyValue[] _properties)
216     {
217         try
218         {
219             XNameContainer xNamedForms = getDoc().oFormHandler.getDocumentForms();
220             Object oDBForm = Helper.getUnoObjectbyName(xNamedForms, ReportWizard.SOREPORTFORMNAME);
221             boolean bgetConnection;
222             if (oDBForm != null)
223             {
224                 String sMsg = sMsgHiddenControlMissing + (char) 13 + sMsgEndAutopilot;
225                 XNameAccess xNamedForm = UnoRuntime.queryInterface( XNameAccess.class, oDBForm );
226                 getRecordParser().Command = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND);
227                 String sCommandType = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, PropertyNames.COMMAND_TYPE);
228                 String sGroupFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "GroupFieldNames");
229                 String sFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "FieldNames");
230                 String sRecordFieldNames = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "RecordFieldNames");
231 
232                 String sorting = PropertyNames.EMPTY_STRING;
233                 if ( xNamedForm.hasByName( "Sorting" ) )
234                     sorting = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "Sorting");
235 
236                 String sQueryName = PropertyNames.EMPTY_STRING;
237                 if ( xNamedForm.hasByName( "QueryName" ) )
238                     sQueryName = getDoc().oFormHandler.getValueofHiddenControl(xNamedForm, "QueryName");
239 
240                 String[] sFieldNameList = JavaTools.ArrayoutofString(sFieldNames, PropertyNames.SEMI_COLON);
241                 String[] sNewList = JavaTools.ArrayoutofString(sRecordFieldNames, PropertyNames.SEMI_COLON);
242                 if ( sorting.length() > 0)
243                 {
244                     String[] sortList = JavaTools.ArrayoutofString(sorting, PropertyNames.SEMI_COLON);
245                     ArrayList<String[]> aSortFields = new ArrayList<String[]>();
246                     for (String sortEntry : sortList)
247                     {
248                         aSortFields.add(JavaTools.ArrayoutofString(sortEntry, ","));
249                     }
250                     String[][] sortFieldNames = new String[aSortFields.size()][2];
251                     aSortFields.toArray(sortFieldNames);
252                     getRecordParser().setSortFieldNames(sortFieldNames);
253                 }
254                 getRecordParser().setRecordFieldNames(sNewList);
255                 getRecordParser().GroupFieldNames = JavaTools.ArrayoutofString(sGroupFieldNames, PropertyNames.SEMI_COLON);
256                 getRecordParser().setCommandType(Integer.valueOf(sCommandType).intValue());
257 
258                 sMsgQueryCreationImpossible = JavaTools.replaceSubString(sMsgQueryCreationImpossible, getRecordParser().Command, "<STATEMENT>");
259                 bgetConnection = getRecordParser().getConnection(_properties);
260                 int nCommandType = com.sun.star.sdb.CommandType.COMMAND;
261                 boolean bexecute = false;
262                 if (bgetConnection)
263                 {
264                     if ((getRecordParser().getCommandType() == CommandType.QUERY) && (getRecordParser().Command.equals(PropertyNames.EMPTY_STRING)))
265                     {
266                         DBMetaData.CommandObject oCommand = getRecordParser().getQueryByName(sQueryName);
267                         if (getRecordParser().hasEscapeProcessing(oCommand.getPropertySet()))
268                         {
269                             getRecordParser().Command = (String) oCommand.getPropertySet().getPropertyValue(PropertyNames.COMMAND);
270                             getRecordParser().getSQLQueryComposer().m_xQueryAnalyzer.setQuery(getRecordParser().Command);
271                             getRecordParser().getSQLQueryComposer().prependSortingCriteria();
272                             getRecordParser().Command = getRecordParser().getSQLQueryComposer().getQuery();
273                         }
274                         else
275                         {
276                             nCommandType = com.sun.star.sdb.CommandType.QUERY;
277                             getRecordParser().Command = sQueryName;
278                         }
279                     }
280 
281                     bexecute = getRecordParser().executeCommand(nCommandType); //sMsgQueryCreationImpossible + (char) 13 + sMsgEndAutopilot, sFieldNameList, true);
282                     if (bexecute)
283                     {
284                         bexecute = getRecordParser().getFields(sFieldNameList, true);
285                     }
286                     return bexecute;
287                 }
288                 else
289                 {
290                     return false;
291                 }
292             }
293             else
294             {
295                 sReportFormNotExisting = JavaTools.replaceSubString(sReportFormNotExisting, ReportWizard.SOREPORTFORMNAME, "<REPORTFORM>");
296                 showMessageBox("ErrorBox", VclWindowPeerAttribute.OK, sReportFormNotExisting + (char) 13 + sMsgEndAutopilot);
297                 return false;
298             }
299         }
300         catch (InvalidQueryException queryexception)
301         {
302             return false;
303         }
304         catch (java.lang.Exception ex)
305         {
306             Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex );
307             return false;
308         }
309     }
310     private boolean m_bStopProcess;
311 
StopProcess()312     public void StopProcess()
313     {
314         m_bStopProcess = true;
315     }
316 
insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF)317     public void insertDatabaseDatatoReportDocument(XMultiServiceFactory xMSF)
318     {
319         try
320         {
321             int ColIndex;
322             boolean breset;
323             Object oTable;
324             Vector DataVector = new Vector();
325             DBColumn CurDBColumn;
326             Object CurGroupValue;
327             String CurGroupTableName;
328 //                RecordParser CurDBMetaData = getRecordParser();
329             getDoc().oTextFieldHandler.fixDateFields(true);
330             getDoc().removeAllVisibleTextSections();
331             getDoc().removeNonLayoutTextTables();
332             addTextSectionCopies();
333             getDoc().getallDBColumns();
334             int GroupFieldCount = getRecordParser().GroupFieldNames.length;
335             int FieldCount = getRecordParser().FieldColumns.length;
336             Object[] OldGroupFieldValues = new Object[GroupFieldCount];
337             XTextTable[] xGroupBaseTables = new XTextTable[GroupFieldCount];
338             int RecordFieldCount = FieldCount - GroupFieldCount;
339             XTextDocument xTextDocument = getDoc().xTextDocument;
340             XTextCursor xTextCursor = ReportTextDocument.createTextCursor(getDoc().xTextDocument.getText());
341             xTextDocument.lockControllers();
342 
343             if (getRecordParser().ResultSet.next())
344             {
345                 replaceUserFields();
346                 Helper.setUnoPropertyValue(xTextCursor, "PageDescName", "First Page");
347                 for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++)
348                 {
349                     CurGroupTableName = ReportTextDocument.TBLGROUPSECTION + Integer.toString(ColIndex + 1);
350                     oTable = getDoc().oTextTableHandler.xTextTablesSupplier.getTextTables().getByName(CurGroupTableName);
351                     xGroupBaseTables[ColIndex] = UnoRuntime.queryInterface( XTextTable.class, oTable );
352                     CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex);
353                     OldGroupFieldValues[ColIndex] = CurGroupValue;
354                     CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
355                     addLinkedTextSection(xTextCursor, ReportTextDocument.GROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue); //COPYOF!!!!
356                 }
357                 if (getRecordParser().getcurrentRecordData(DataVector))
358                 {
359                     // int RowIndex = 1;
360                     m_bStopProcess = false;
361                     while ((getRecordParser().ResultSet.next()) && (!m_bStopProcess))
362                     {
363                         // RowIndex += 1;
364                         breset = false;
365                         for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++)
366                         {
367                             CurGroupValue = getRecordParser().getGroupColumnValue(ColIndex);
368                             if ((!CurGroupValue.equals(OldGroupFieldValues[ColIndex])) || (breset))
369                             {
370                                 breset = true;
371                                 insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount);
372                                 CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
373                                 addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, CurGroupValue);
374                                 OldGroupFieldValues[ColIndex] = CurGroupValue;
375                                 breset = !(ColIndex == GroupFieldCount - 1);
376                             }
377                         }
378                         getRecordParser().getcurrentRecordData(DataVector);
379                     // updateProgressDisplay(RowIndex);
380                     }
381                     insertDataToRecordTable(xTextCursor, DataVector, RecordFieldCount);
382                 }
383                 else
384                 {
385                     getDoc().unlockallControllers();
386                     return;
387                 }
388             }
389             else
390             {
391                 for (ColIndex = 0; ColIndex < GroupFieldCount; ColIndex++)
392                 {
393                     CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(ColIndex);
394                     Object oValue = PropertyNames.EMPTY_STRING;
395                     addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFGROUPSECTION + Integer.toString(ColIndex + 1), CurDBColumn, oValue);
396                 }
397                 addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null);
398                 Object[][] RecordArray = new Object[1][RecordFieldCount];
399                 for (int i = 0; i < RecordArray[0].length; i++)
400                 {
401                     RecordArray[0][i] = Any.VOID;
402                 }
403                 XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
404                 OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1);
405             }
406             getDoc().oTextSectionHandler.breakLinkofTextSections();
407         }
408         catch (Exception ex)
409         {
410             Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex );
411         }
412 //            catch (java.lang.Exception javaexception)
413 //            {
414 //                javaexception.printStackTrace(System.out);
415 //            }
416         getDoc().unlockallControllers();
417         getDoc().setLayoutSectionsVisible(false);
418         getDoc().removeCopiedTextSections();
419         getDoc().oTextSectionHandler.removeInvisibleTextSections();
420         getDoc().removeLayoutTextTables();
421     }
422 
insertDataToRecordTable(XTextCursor xTextCursor, Vector DataVector, int FieldCount)423     private void insertDataToRecordTable(XTextCursor xTextCursor, Vector DataVector, int FieldCount)
424     {
425         int DataLength = DataVector.size();
426         if ((FieldCount > 0) && (DataLength > 0))
427         {
428             addLinkedTextSection(xTextCursor, ReportTextDocument.COPYOFRECORDSECTION, null, null);
429             Object[][] RecordArray = new Object[DataLength][FieldCount];
430             DataVector.copyInto(RecordArray);
431             XTextTable xTextTable = getDoc().oTextTableHandler.getlastTextTable();
432             if (DataLength > 1)
433             {
434                 xTextTable.getRows().insertByIndex(xTextTable.getRows().getCount(), DataLength - 1);
435             }
436             OfficeDocument.ArraytoCellRange(RecordArray, xTextTable, 0, 1);
437         }
438         DataVector.removeAllElements();
439     }
440 //    public void updateProgressDisplay(int iCounter)
441 //        {
442 //            try
443 //            {
444 //                if (iCounter % 10 == 0)
445 //                {
446 //                    sProgressCurRecord = JavaTools.replaceSubString(sProgressBaseCurRecord, String.valueOf(iCounter), "<COUNT>");
447 //                    setControlProperty("lblCurProgress", PropertyNames.PROPERTY_LABEL, sProgressCurRecord);
448 //                    super.xReschedule.reschedule();
449 //                }
450 //            }
451 //            catch (java.lang.Exception jexception)
452 //            {
453 //                jexception.printStackTrace(System.out);
454 //            }
455 //        }
replaceUserFields()456     private void replaceUserFields()
457     {
458         DBColumn CurDBColumn;
459         XTextCursor xNameCellCursor;
460         String FieldContent;
461         int iCount = getDoc().DBColumnsVector.size();
462         for (int i = 0; i < iCount; i++)
463         {
464             CurDBColumn = (DBColumn) getDoc().DBColumnsVector.elementAt(i);
465             xNameCellCursor = ReportTextDocument.createTextCursor(CurDBColumn.xNameCell);
466             xNameCellCursor.gotoStart(false);
467             FieldContent = getDoc().oTextFieldHandler.getUserFieldContent(xNameCellCursor);
468             if (!FieldContent.equals(PropertyNames.EMPTY_STRING))
469             {
470                 xNameCellCursor.goRight((short) 1, true);
471                 xNameCellCursor.setString(FieldContent);
472             }
473         }
474     }
475 
getFrame()476     public XFrame getFrame()
477     {
478         return m_aDoc.xFrame;
479     }
480 
getDocumentServiceFactory()481     public XMultiServiceFactory getDocumentServiceFactory()
482     {
483         return m_aDoc.xMSFDoc;
484     }
485 
store(String _sName, int _nOpenMode)486     public void store(String _sName, int _nOpenMode) throws com.sun.star.uno.Exception
487     {
488         getDoc().createReportForm(ReportWizard.SOREPORTFORMNAME);
489         // int nOpenMode = getReportOpenMode();
490         getDoc().oTextFieldHandler.updateDateFields();
491         getDoc().oTextFieldHandler.fixDateFields(false);
492         if ((_nOpenMode == ReportFinalizer.SOCREATETEMPLATE || _nOpenMode == ReportFinalizer.SOUSETEMPLATE))
493         {
494             getDoc().oTextSectionHandler.breakLinkofTextSections();
495             getRecordParser().storeDatabaseDocumentToTempPath(getComponent(), _sName);
496         }
497     }
498 
liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)499     public boolean liveupdate_addGroupNametoDocument(String[] GroupNames, String CurGroupTitle, Vector GroupFieldVector, ArrayList ReportPath, int iSelCount)
500     {
501         return getDoc().addGroupNametoDocument(GroupNames, CurGroupTitle, GroupFieldVector, ReportPath, iSelCount);
502     }
503 
refreshGroupFields(String[] _sNewNames)504     public void refreshGroupFields(String[] _sNewNames)
505     {
506         getDoc().refreshGroupFields(_sNewNames);
507     }
508 
509     // public boolean isGroupField(String _FieldName)
510     // {
511     //    return getDoc().isGroupField(_FieldName);
512     // }
liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector)513     public void liveupdate_removeGroupName(String[] NewSelGroupNames, String CurGroupTitle, Vector GroupFieldVector)
514     {
515         getDoc().removeGroupName(NewSelGroupNames, CurGroupTitle, GroupFieldVector);
516     }
517 
setPageOrientation(int nOrientation)518     public void setPageOrientation(int nOrientation) throws com.sun.star.lang.IllegalArgumentException
519     {
520         // LLA: should we lock controllers here?
521         // CurReportDocument.getDoc().xTextDocument.lockControllers();
522         if (nOrientation == ReportLayouter.SOOPTLANDSCAPE)
523         {
524             getDoc().changePageOrientation(true);
525         }
526         else if (nOrientation == ReportLayouter.SOOPTPORTRAIT)
527         {
528             getDoc().changePageOrientation(false);
529         }
530         else
531         {
532             throw new com.sun.star.lang.IllegalArgumentException("Unknown Orientation.");
533         }
534     // CurReportDocument.getDoc().unlockallControllers();
535     }
536 
liveupdate_changeLayoutTemplate(String LayoutTemplatePath )537     public void liveupdate_changeLayoutTemplate(String LayoutTemplatePath/*, String BitmapPath*/)
538     {
539         getDoc().swapLayoutTemplate(LayoutTemplatePath/*, BitmapPath*/);
540     }
541 
liveupdate_changeContentTemplate(String ContentTemplatePath)542     public void liveupdate_changeContentTemplate(String ContentTemplatePath)
543     {
544         getDoc().swapContentTemplate(ContentTemplatePath);
545     }
546 
layout_setupRecordSection(String TemplateName)547     public void layout_setupRecordSection(String TemplateName)
548     {
549         getDoc().setupRecordSection(TemplateName);
550     }
551 
removeTextTableAndTextSection()552     public void removeTextTableAndTextSection()
553     {
554         getDoc().oTextSectionHandler.removeTextSectionbyName("RecordSection");
555         getDoc().oTextTableHandler.removeTextTablebyName("Tbl_RecordSection");
556     }
557 
layout_selectFirstPage()558     public void layout_selectFirstPage()
559     {
560         getDoc().oViewHandler.selectFirstPage(getDoc().oTextTableHandler);
561     }
562 
dispose()563     public void dispose()
564     {
565         OfficeDocument.dispose(getMSF(), getComponent());
566     }
567 
getComponent()568     public XComponent getComponent()
569     {
570         return getDoc().xComponent;
571     }
572 
liveupdate_changeUserFieldContent(String fieldname, String sfieldtitle)573     public void liveupdate_changeUserFieldContent(String fieldname, String sfieldtitle)
574     {
575         getDoc().oTextFieldHandler.changeUserFieldContent(fieldname, sfieldtitle);
576     }
577 
liveupdate_updateReportTitle(String _sTitleName)578     public void liveupdate_updateReportTitle(String _sTitleName)
579     {
580     }
581 
addReportToDBView()582     public void addReportToDBView()
583     {
584         getRecordParser().addReportDocument(getComponent(), true);
585     }
586 
createAndOpenReportDocument( String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign )587     public void createAndOpenReportDocument( String sReportName, boolean _bAsTemplate, boolean _bOpenInDesign )
588     {
589         try
590         {
591             m_documentUI.loadComponent( DatabaseObject.REPORT, sReportName, _bOpenInDesign );
592         }
593         catch ( Exception ex )
594         {
595             Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, ex );
596         }
597     }
598 
initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames)599     public void initializeFieldColumns(final int _nType, final String TableName, final String[] FieldNames)
600     {
601         getRecordParser().initializeFieldColumns(FieldNames, TableName);
602     }
603 
setFieldTitles(String[] sFieldTitles)604     public void setFieldTitles(String[] sFieldTitles)
605     {
606         getRecordParser().setFieldTitles(sFieldTitles);
607     }
608 
setSorting(String[][] aSortFieldNames)609     public void setSorting(String[][] aSortFieldNames)
610     {
611         getRecordParser().setSortFieldNames(aSortFieldNames);
612     }
613 
setGrouping(String[] aGroupFieldNames)614     public void setGrouping(String[] aGroupFieldNames)
615     {
616         getRecordParser().prependSortFieldNames(aGroupFieldNames);
617     }
618 
619 // TODO: we have to change to String List!!!!
620     private ArrayList m_aReportPath = null;
621 
getReportPath()622     public ArrayList getReportPath()
623     {
624         if (m_aReportPath == null)
625         {
626             // Check general availability of office paths
627             try
628             {
629                 m_aReportPath = FileAccess.getOfficePaths(getMSF(), "Template", "share", "/wizard");
630                 // m_sReportPath = FileAccess.combinePaths(getMSF(), m_sReportPath, "/wizard/report");
631                 FileAccess.combinePaths(getMSF(), m_aReportPath, "/wizard/report");
632             }
633             catch (Exception e)
634             {
635                 Logger.getLogger( ReportTextImplementation.class.getName() ).log( Level.SEVERE, null, e );
636             }
637         }
638         return m_aReportPath;
639     }
640 
getContentPath()641     public String getContentPath()
642     {
643         ArrayList aReportPath = getReportPath();
644         for (int i = 0; i < aReportPath.size(); i++)
645         {
646             String sPath = (String) aReportPath.get(i);
647             sPath += "/cnt-default.ott";
648             if (FileAccess.isPathValid(getMSF(), sPath))
649             {
650                 return sPath;
651             }
652         }
653         return PropertyNames.EMPTY_STRING;
654     }
655 
getLayoutPath()656     public String getLayoutPath()
657     {
658         ArrayList aReportPath = getReportPath();
659         for (int i = 0; i < aReportPath.size(); i++)
660         {
661             String sPath = (String) aReportPath.get(i);
662             sPath += "/stl-default.ott";
663             if (FileAccess.isPathValid(getMSF(), sPath))
664             {
665                 return sPath;
666             }
667         }
668         return PropertyNames.EMPTY_STRING;
669     }
670 
getDefaultPageOrientation()671     public int getDefaultPageOrientation()
672     {
673         return m_nDefaultPageOrientation;
674     }
675 
getDataLayout()676     public String[][] getDataLayout()
677     {
678         String[][] ContentFiles;
679         try
680         {
681 //                    ContentFiles = FileAccess.getFolderTitles(m_xMSF, "cnt", CurReportDocument.getReportPath());
682             ContentFiles = FileAccess.getFolderTitles(getMSF(), "cnt", getReportPath());
683         }
684         catch (com.sun.star.wizards.common.NoValidPathException e)
685         {
686             ContentFiles = new String[2][];
687             String[] a = new String[1];
688             String[] b = new String[1];
689             a[0] = "DefaultLayoutOfData";
690             b[0] = "default";
691             ContentFiles[1] = a;
692             ContentFiles[0] = b;
693         }
694         return ContentFiles;
695     }
696 
getHeaderLayout()697     public String[][] getHeaderLayout()
698     {
699         String[][] LayoutFiles;
700         try
701         {
702 //                    LayoutFiles = FileAccess.getFolderTitles(m_xMSF, "stl", CurReportDocument.getReportPath());
703             LayoutFiles = FileAccess.getFolderTitles(getMSF(), "stl", getReportPath());
704         }
705         catch (com.sun.star.wizards.common.NoValidPathException e)
706         {
707             LayoutFiles = new String[2][];
708             String[] a = new String[1];
709             String[] b = new String[1];
710             a[0] = "DefaultLayoutOfHeaders";
711             b[0] = "default";
712             LayoutFiles[1] = a;
713             LayoutFiles[0] = b;
714         }
715         return LayoutFiles;
716     }
717 
importReportData(ReportWizard _aWizard)718     public void importReportData(ReportWizard _aWizard)
719     {
720         Dataimport CurDataimport = new Dataimport(_aWizard.xMSF);
721         CurDataimport.CurReportDocument = this;
722         _aWizard.importReportData(_aWizard.xMSF, CurDataimport);
723     }
724 
setCommandType(int _nCommand)725     public void setCommandType(int _nCommand)
726     {
727         // already set somewhere else
728     }
729 
setCommand(String _sCommand)730     public void setCommand(String _sCommand)
731     {
732         getRecordParser().Command = _sCommand;
733     }
734 
checkInvariants()735     public void checkInvariants() throws java.lang.Exception
736     {
737     }
738 }
739