This is an automated email from the ASF dual-hosted git repository.
mseidel pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
The following commit(s) were added to refs/heads/trunk by this push:
new 61c0a82 Fixed links to Wiki
61c0a82 is described below
commit 61c0a822c84ddc89fb4c03e77796922521862647
Author: mseidel <[email protected]>
AuthorDate: Wed Apr 7 01:00:23 2021 +0200
Fixed links to Wiki
---
.../AsciiFilter/AsciiReplaceFilter.java | 122 ++++-----
.../Spreadsheet/ExampleDataPilotSource.java | 18 +-
main/odk/examples/java/ToDo/ToDo.java | 288 ++++++++++-----------
3 files changed, 214 insertions(+), 214 deletions(-)
diff --git
a/main/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
b/main/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
index da22366..659d514 100644
---
a/main/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
+++
b/main/odk/examples/DevelopersGuide/OfficeDev/FilterDevelopment/AsciiFilter/AsciiReplaceFilter.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -57,7 +57,7 @@ import com.sun.star.lang.IllegalArgumentException;
User can decide at runtime which functionality really should
be used by selecting it in an extra filter property dialog.
- So we show how a filter works fro iport/export, use or create
+ So we show how a filter works for import/export, use or create
streams and how a filter can offer properties for filtering
which can be edit by the user.
************************************************************************-*/
@@ -77,7 +77,7 @@ public class AsciiReplaceFilter
{
//______________________________
// const
-
+
// the supported service names, the first one being the service name
of the component itself
public static final String[] m_serviceNames = {
"com.sun.star.comp.ansifilter.AsciiReplaceFilter" ,
"com.sun.star.document.ImportFilter", "com.sun.star.document.ExportFilter" };
@@ -232,8 +232,8 @@ public class AsciiReplaceFilter
/**
* It's not allowed for us - neither very easy to change our internal
* name during runtime of an office. Because every filter name must
- * be unambigous ...
- * So we doesn't implement this method here.
+ * be unambiguous ...
+ * So we don't implement this method here.
*/
public void setName( String sName )
{
@@ -343,12 +343,12 @@ public class AsciiReplaceFilter
bImport = m_bImport;
xText = m_xDocument;
}
-
+
measure("options analyzed");
-
+
if (aOptions.isValid()==false)
return false;
-
+
// start real filtering
boolean bState = false;
if (bImport)
@@ -396,9 +396,9 @@ public class AsciiReplaceFilter
* But if some optional filter options are given
* we make some changes: replace chars or complete strings.
*
- * Note: It's not alloed for a filter to seek inside the stream.
+ * Note: It's not allowed for a filter to seek inside the stream.
* Because the outside frameloader has to set the stream position
- * right and a filter must read till EOF occures only.
+ * right and a filter must read till EOF occurs only.
*
* @param xTarget
* the target text model to put the data in
@@ -413,33 +413,33 @@ public class AsciiReplaceFilter
FilterOptions
aOptions )
{
measure("implts_import {");
-
+
com.sun.star.text.XSimpleText xText =
(com.sun.star.text.XSimpleText)UnoRuntime.queryInterface(
com.sun.star.text.XSimpleText.class,
xTarget.getText());
-
+
measure("cast XSimpleText");
-
+
boolean bBreaked = false;
-
+
try
{
StringBuffer sBuffer = new StringBuffer(100000);
byte[][] lData = new byte[1][];
int nRead = aOptions.m_xInput.readBytes( lData,
4096 );
-
+
measure("read first bytes");
-
+
while (nRead>0 && !bBreaked)
{
// copy data from stream to temp. buffer
sBuffer.append( new String(lData[0]) );
measure("buffer append ["+nRead+"]");
-
+
nRead = aOptions.m_xInput.readBytes( lData, 2048 );
measure("read next bytes");
-
- // check for cancelled filter proc on every loop!
+
+ // check for canceled filter proc on every loop!
synchronized(this)
{
if (m_nFilterProcState==FILTERPROC_BREAK)
@@ -450,41 +450,41 @@ public class AsciiReplaceFilter
}
measure("break check");
}
-
+
// Make some replacements inside the buffer.
String sText = implts_replace( sBuffer, aOptions );
measure("replace");
-
+
// copy current buffer to the document model.
// Create a new paragraph for every line inside original file.
- // May not all data could be readed - but that doesn't matter
here.
- // Reason: somewhere cancelled this function.
- // But check for optioanl replace request before ...
+ // May not all data could be read - but that doesn't matter
here.
+ // Reason: somewhere canceled this function.
+ // But check for optional replace request before ...
int nStart = 0;
int nEnd = -1;
int nLength = sText.length();
-
+
com.sun.star.text.XTextRange xCursor =
(com.sun.star.text.XTextRange)UnoRuntime.queryInterface(
com.sun.star.text.XTextRange.class,
xText.createTextCursor());
-
+
while (true)
{
nEnd = sText.indexOf('\n',nStart);
-
+
if (nEnd==-1 && nStart<nLength)
nEnd = nLength;
-
+
if (nEnd==-1)
break;
-
+
String sLine = sText.substring(nStart,nEnd);
nStart = nEnd+1;
-
+
xText.insertString(xCursor,sLine,false);
xText.insertControlCharacter(xCursor,com.sun.star.text.ControlCharacter.PARAGRAPH_BREAK,false);
-
- // check for cancelled filter proc on every loop!
+
+ // check for canceled filter proc on every loop!
synchronized(this)
{
if (m_nFilterProcState==FILTERPROC_BREAK)
@@ -495,9 +495,9 @@ public class AsciiReplaceFilter
}
measure("break check");
}
-
+
measure("set on model");
-
+
// with refreshing the document we are on the safe-side,
otherwise the first time the filter is used the document is not fully shown
(flaw!).
com.sun.star.util.XRefreshable xRefresh =
(com.sun.star.util.XRefreshable)UnoRuntime.queryInterface(
com.sun.star.util.XRefreshable.class,
@@ -515,11 +515,11 @@ public class AsciiReplaceFilter
catch(com.sun.star.io.BufferSizeExceededException exExceed ) {
bBreaked = true; }
catch(com.sun.star.io.NotConnectedException exConnect ) {
bBreaked = true; }
catch(com.sun.star.io.IOException exIO ) {
bBreaked = true; }
-
+
measure("} implts_import");
-
+
return !bBreaked;
}
@@ -528,9 +528,9 @@ public class AsciiReplaceFilter
* a text model. We copy every letter from the document.
* There are no checks.
*
- * Note: It's not alloed for a filter to seek inside the stream.
+ * Note: It's not allowed for a filter to seek inside the stream.
* Because the outside frameloader has to set the stream position
- * right and a filter must read till EOF occures only.
+ * right and a filter must read till EOF occurs only.
*
* @param xSource
* the source text model to get the data from
@@ -545,22 +545,22 @@ public class AsciiReplaceFilter
FilterOptions
aOptions)
{
measure("implts_export {");
-
+
com.sun.star.text.XTextRange xText =
(com.sun.star.text.XSimpleText)UnoRuntime.queryInterface(
com.sun.star.text.XSimpleText.class,
xSource.getText());
-
+
measure("cast XTextRange");
-
+
boolean bBreaked = false;
-
+
try
{
StringBuffer sBuffer = new StringBuffer(xText.getString());
String sText = implts_replace(sBuffer,aOptions);
-
+
measure("get text from model");
-
+
// Normally this function isn't really cancelable
// But the following operation can be very expensive. So
// this place is the last one to stop it.
@@ -572,12 +572,12 @@ public class AsciiReplaceFilter
return false;
}
}
-
+
aOptions.m_xOutput.writeBytes(sText.getBytes());
aOptions.m_xOutput.flush();
-
+
measure("written to file");
-
+
// If we created used stream - we must close it too.
if (aOptions.m_bStreamOwner==true)
{
@@ -588,21 +588,21 @@ public class AsciiReplaceFilter
catch(com.sun.star.io.BufferSizeExceededException exExceed ) {
bBreaked = true; }
catch(com.sun.star.io.NotConnectedException exConnect ) {
bBreaked = true; }
catch(com.sun.star.io.IOException exIO ) {
bBreaked = true; }
-
+
measure("} implts_export");
-
+
return !bBreaked;
}
-
+
/**
- * helper function to convert the used StringBuffer into a Strig value.
+ * helper function to convert the used StringBuffer into a String
value.
* And we use this chance to have a look on optional filter options
* which can invite replacing of strings.
*/
private String implts_replace( StringBuffer rBuffer, FilterOptions
aOptions )
{
// replace complete strings first
- // Because its easiear on a buffer then on a string
+ // Because it's easier on a buffer than on a string
if ( ! aOptions.m_sOld.equals(aOptions.m_sNew) )
{
int nStart = rBuffer.indexOf(aOptions.m_sOld);
@@ -615,7 +615,7 @@ public class AsciiReplaceFilter
nEnd = nStart+nLength;
}
}
-
+
// convert buffer into return format [string]
// and convert to lower or upper case if required.
String sResult = rBuffer.toString();
@@ -626,11 +626,11 @@ public class AsciiReplaceFilter
else
sResult = sResult.toUpperCase();
}
-
+
return sResult;
}
-
-
+
+
//______________________________
// interface XServiceInfo
/**
@@ -661,7 +661,7 @@ public class AsciiReplaceFilter
sService.equals( m_serviceNames[2] )
);
}
-
+
/**
* Return the real class name of the component
*
@@ -714,7 +714,7 @@ public class AsciiReplaceFilter
*/
// This method not longer necessary since OOo 3.4 where the component
registration
// was changed to passive component registration. For more details see
- // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
+ // https://wiki.openoffice.org/wiki/Passive_Component_Registration
// public static boolean __writeRegistryServiceInfo(
com.sun.star.registry.XRegistryKey xRegistryKey )
// {
diff --git
a/main/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
b/main/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
index 50554ee..a3f4fa6 100644
--- a/main/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
+++ b/main/odk/examples/DevelopersGuide/Spreadsheet/ExampleDataPilotSource.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -298,7 +298,7 @@ class ExampleLevel implements
aResults[nResultPos].Name =
ExampleSettings.getMemberName(nMember);
aResults[nResultPos].Caption = aResults[nResultPos].Name;
aResults[nResultPos].Flags =
- com.sun.star.sheet.MemberResultFlags.HASMEMBER;
+ com.sun.star.sheet.MemberResultFlags.HASMEMBER;
++nResultPos;
for (int nInner=1; nInner<nFill; nInner++)
@@ -312,7 +312,7 @@ class ExampleLevel implements
}
return aResults;
}
-
+
// XPropertySet
public com.sun.star.beans.XPropertySetInfo getPropertySetInfo()
@@ -799,7 +799,7 @@ public class ExampleDataPilotSource
}
// XDataPilotResults
-
+
public com.sun.star.sheet.DataResult[][] getResults()
{
int[] nDigits = new int[ExampleSettings.nDimensionCount];
@@ -965,10 +965,10 @@ public class ExampleDataPilotSource
return xSingleServiceFactory;
}
-
+
// This method not longer necessary since OOo 3.4 where the component
registration
// was changed to passive component registration. For more details see
- // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
+ // https://wiki.openoffice.org/wiki/Passive_Component_Registration
// public static boolean __writeRegistryServiceInfo(
// com.sun.star.registry.XRegistryKey regKey)
diff --git a/main/odk/examples/java/ToDo/ToDo.java
b/main/odk/examples/java/ToDo/ToDo.java
index b758dba..56c48b6 100644
--- a/main/odk/examples/java/ToDo/ToDo.java
+++ b/main/odk/examples/java/ToDo/ToDo.java
@@ -1,5 +1,5 @@
/**************************************************************
- *
+ *
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
@@ -7,16 +7,16 @@
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
- *
+ *
*************************************************************/
@@ -37,7 +37,7 @@ import com.sun.star.uno.XWeak;
import com.sun.star.uno.XComponentContext;
import org.openoffice.*;
-// addintional interfaces used by the implementation
+// additional interfaces used by the implementation
import com.sun.star.sheet.XSpreadsheetDocument;
import com.sun.star.sheet.XSpreadsheet;
import com.sun.star.sheet.XCellRangeMovement;
@@ -67,17 +67,17 @@ import java.util.Arrays;
* (<CODE>__writeRegistryServiceInfo</CODE>).
*/
public class ToDo {
-
+
/** This class implements the component. At least the interfaces
* XInterface, XTypeProvider, and XWeak implemented by the helper class
* WeakBase and XServiceInfo should be provided by the service.
*/
public static class ToDoImpl extends WeakBase implements XServiceInfo,
XToDo {
-
+
/** The service name, that must be used to get an instance of this
service.
*/
private static final String __serviceName = "org.openoffice.ToDo";
-
+
/** The initial component contextr, that gives access to
* the service manager, supported singletons, ...
* It's often later used
@@ -99,28 +99,28 @@ public class ToDo {
static private final int INT_COLUMN_END_DAY_OF_WEEK = 6;
static private final int INT_COLUMN_DUEDATE = 7;
static private final int INT_COLUMN_STATUS = 8;
-
+
static private final int INT_ROW_FROM = 14; // 8
-
+
static private final int INT_ROW_HOLIDAYS_START = 4;
static private final int INT_COLUMN_HOLIDAYS_START = 7; // 10
-
+
static private final String STRING_SEPARATOR = "/";
-
+
/** The constructor of the inner class has a XComponenContext
parameter.
* @param xCompContext the initial component context
*/
public ToDoImpl(XComponentContext xCompContext) {
try {
m_cmpCtx = xCompContext;
- m_xMCF = m_cmpCtx.getServiceManager();
+ m_xMCF = m_cmpCtx.getServiceManager();
}
catch( Exception e ) {
e.printStackTrace(System.err);
}
}
-
+
/** This method returns an array of all supported service names.
* @return Array of supported service names.
*/
@@ -131,8 +131,8 @@ public class ToDo {
public static String[] getServiceNames() {
String[] sSupportedServiceNames = { __serviceName };
return sSupportedServiceNames;
- }
-
+ }
+
/** This method returns true, if the given service will be
* supported by the component.
* @param sService Service name.
@@ -141,14 +141,14 @@ public class ToDo {
public boolean supportsService(String sServiceName) {
return sServiceName.equals( __serviceName );
}
-
+
/** Return the class name of the component.
* @return Class name of the component.
*/
public String getImplementationName() {
return ToDoImpl.class.getName();
}
-
+
/** For every bug/feature listed in a spreadsheet document this method
* calculates the start date, day of week of the start date, the end
date
* and the day of week of the end date. All calculations are dependent
@@ -170,74 +170,74 @@ public class ToDo {
XSpreadsheetDocument xspreadsheetdocument =
( XSpreadsheetDocument ) UnoRuntime.queryInterface(
XSpreadsheetDocument.class, aInstance );
-
+
// Querying for the interface XIndexAccess
XIndexAccess xindexaccess = ( XIndexAccess )
UnoRuntime.queryInterface( XIndexAccess.class,
xspreadsheetdocument.getSheets() );
-
+
// Getting the first XSpreadsheet
XSpreadsheet xspreadsheet =
(XSpreadsheet)UnoRuntime.queryInterface(
XSpreadsheet.class, xindexaccess.getByIndex( 0 ));
-
+
// Querying for the interface XCellRange on the XSpeadsheet
XCellRange xcellrange = ( XCellRange )
UnoRuntime.queryInterface( XCellRange.class, xspreadsheet );
-
- /* Getting the gregorian calendar with the date on which to
start
+
+ /* Getting the Gregorian calendar with the date on which to
start
the calculation */
GregorianCalendar gregCalAbsoluteStartDate =
this.getGregorianCalendarFromString(this.getStringFromCell(
xcellrange, 5, 2 )
);
gregCalAbsoluteStartDate.add( Calendar.DATE, -1 );
-
+
// Set the start date with the absolute start date
GregorianCalendar gregCalStartDate =
(GregorianCalendar) gregCalAbsoluteStartDate.clone();
-
+
/* Creating the service FunctionAccess, which allows generic
access to all spreadsheet functions */
Object objectFunctionAccess =
m_xMCF.createInstanceWithContext(
"com.sun.star.sheet.FunctionAccess", m_cmpCtx );
-
+
// Querying for the interface XFunctionAccess on service
// FunctionAccess
XFunctionAccess xfunctionaccess = (XFunctionAccess)
UnoRuntime.queryInterface(XFunctionAccess.class,
objectFunctionAccess );
-
+
// Creating vector for holidays
Vector vectorHolidays = new Vector();
-
+
// Get the Official Holidays
this.getOfficialHolidays( vectorHolidays, xcellrange,
xfunctionaccess,
gregCalStartDate.get(
Calendar.YEAR ) );
-
+
// Get the private holidays
this.getPrivateHolidays(vectorHolidays, xcellrange,
xfunctionaccess);
-
+
// Getting the object array of holidays
Object[] objectSortedHolidays = vectorHolidays.toArray();
-
+
// Sorting the holidays
Arrays.sort( objectSortedHolidays );
-
+
// Collect the Official Holidays and the private holidays
Object [][]objectHolidays =
new Object[][] { objectSortedHolidays };
-
+
// Row index
int intRowTo = this.INT_ROW_FROM - 1;
-
+
// Getting the feature of the first cell
String sFeature = this.getStringFromCell(xcellrange,
intRowTo + 1,
this.INT_COLUMN_FEATURE);
-
+
// Determine the last row with an entry in the first column
while ( ( sFeature != null ) &&
( !sFeature.equals( "" ) ) ) {
@@ -245,10 +245,10 @@ public class ToDo {
sFeature = this.getStringFromCell( xcellrange,
intRowTo + 1, this.INT_COLUMN_FEATURE );
}
-
+
// Setting the last row to be calculated
final int INT_ROW_TO = intRowTo + 1;
-
+
// Deleting cells which will be recalculated
for ( int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO + 5;
intRow++ ) {
@@ -258,11 +258,11 @@ public class ToDo {
this.setStringToCell(xcellrange, intRow, intColumn,
"");
}
}
-
+
/* Clearing the background color of the due date cells and
setting
the hyperlink to the bugtracker */
for (int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO;
intRow++)
- {
+ {
// Querying for the interface XPropertySet for the cell
// providing the due date
XPropertySet xpropertyset = ( XPropertySet )
@@ -270,73 +270,73 @@ public class ToDo {
xcellrange.getCellByPosition(
this.INT_COLUMN_DUEDATE,
intRow ));
-
+
// Changing the background color of the cell to white
xpropertyset.setPropertyValue( "CellBackColor",
new Integer( 16777215 ) );
-
+
// Getting the cell of the bug id
XCell xcell = xcellrange.getCellByPosition(
this.INT_COLUMN_FEATURE, intRow );
-
+
// Querying for the interface XSimpleText
XSimpleText xsimpletext = ( XSimpleText )
UnoRuntime.queryInterface( XSimpleText.class, xcell );
-
+
// Getting the text cursor
XTextCursor xtextcursor = xsimpletext.createTextCursor();
-
+
// Querying for the interface XTextRange
XTextRange xtextrange = ( XTextRange )
UnoRuntime.queryInterface( XTextRange.class, xtextcursor );
-
+
// Getting the bug ID from the cell
- String sBugID = xtextrange.getString();
+ String sBugID = xtextrange.getString();
if ( !sBugID.startsWith(
"http://www.openoffice.org/issues/show_bug.cgi?id=") ) {
String sBugIDLink =
"http://www.openoffice.org/issues/show_bug.cgi?id=" + sBugID;
-
+
// Querying for the interface XMultiServiceFactory
XMultiServiceFactory xMSFTextField =
(XMultiServiceFactory)UnoRuntime.queryInterface(
XMultiServiceFactory.class, aInstance );
-
+
// Creating an instance of the text field URL
Object objectTextField =
xMSFTextField.createInstance(
"com.sun.star.text.TextField.URL" );
-
+
// Querying for the interface XTextField
XTextField xtextfield = ( XTextField )
UnoRuntime.queryInterface( XTextField.class,
objectTextField );
-
+
// Querying for the interface XPropertySet
XPropertySet xpropertysetTextField = ( XPropertySet )
UnoRuntime.queryInterface( XPropertySet.class,
xtextfield );
-
+
// Setting the URL
xpropertysetTextField.setPropertyValue( "URL",
sBugIDLink );
-
+
// Setting the representation of the URL
xpropertysetTextField.setPropertyValue(
"Representation",
sBugID );
-
+
// Querying for the interface XText
XText xtext = ( XText )UnoRuntime.queryInterface(
XText.class, xcell );
-
+
// Delete cell content
xtextrange.setString( "" );
-
+
// Inserting the text field URL to the cell
xtext.insertTextContent( xtextrange, xtextfield, false
);
}
}
-
+
// Processing all features/bugs in the table
for (int intRow = this.INT_ROW_FROM; intRow < INT_ROW_TO;
intRow++)
{
@@ -347,11 +347,11 @@ public class ToDo {
// Getting the number of needed days to perform the feature
int intNeededDays = (int) Math.round( xcell.getValue() );
-
+
// Getting the content of a specified cell
String sStatus = this.getStringFromCell( xcellrange,
intRow, this.INT_COLUMN_STATUS );
-
+
/* Testing if the number of needed days is greater than
zero and if
the status is not "done" */
@@ -362,54 +362,54 @@ public class ToDo {
gregCalStartDate = this.getWorkday(
gregCalStartDate, 1, objectHolidays,
xfunctionaccess );
-
+
// Getting a string with the date format jjjj-mm-dd
from
- // the gregorian calendar
+ // the Gregorian calendar
String sDate = this.getStringFromGregorianCalendar(
gregCalStartDate );
-
+
// Set the start date in the specified cell of the
table
this.setStringToCell(xcellrange, intRow,
this.INT_COLUMN_STARTDATE, sDate);
-
+
// For the start day set the day of week in the
specified
// cell of the table
this.setDayOfWeek( gregCalStartDate,
xcellrange, intRow,
this.INT_COLUMN_START_DAY_OF_WEEK );
-
+
// Getting the end date after a specified number of
workdays
GregorianCalendar gregCalEndDate =
this.getWorkday( gregCalStartDate,
intNeededDays - 1,
objectHolidays, xfunctionaccess );
-
+
// Creating a string with the date format jjjj-mm-dd
sDate = this.getStringFromGregorianCalendar(
gregCalEndDate );
-
+
// Set the end date in the specified cell of the table
this.setStringToCell( xcellrange, intRow,
this.INT_COLUMN_ENDDATE, sDate );
-
+
// For the end day set the day of week in the specified
// cell of the table
this.setDayOfWeek(gregCalEndDate, xcellrange,
intRow,
this.INT_COLUMN_END_DAY_OF_WEEK);
-
+
// Set the initial date for the next loop
gregCalStartDate = ( GregorianCalendar )
gregCalEndDate.clone();
-
+
// Get the due date from the table
String sDueDate = this.getStringFromCell(
xcellrange, intRow, this.INT_COLUMN_DUEDATE );
-
+
// Testing if the due date is not empty
if ( !sDueDate.equals( "" ) ) {
GregorianCalendar gregCalDueDate =
this.getGregorianCalendarFromString(sDueDate);
-
+
// Testing if the due date is before the calculated
// end date
if ( gregCalDueDate.before(
@@ -422,10 +422,10 @@ public class ToDo {
-( intNeededDays - 1 ),
objectHolidays,
xfunctionaccess);
-
+
// Begin with the current row
int intRowToInsert = intRow;
-
+
// Get the start date for the feature/bug in
the
// current row
GregorianCalendar gregCalPreviousStartDate =
@@ -433,7 +433,7 @@ public class ToDo {
this.getStringFromCell(
xcellrange, intRowToInsert,
this.INT_COLUMN_STARTDATE ) );
-
+
// Testing if we have to search for an earlier
date
// to begin
while ((gregCalLatestDateToStart.before(
@@ -441,32 +441,32 @@ public class ToDo {
(INT_ROW_FROM != intRowToInsert)) {
// Decrease the row
intRowToInsert--;
-
+
// Get the start date for the feature/bug
in
// the current row
String sStartDate = this.getStringFromCell(
xcellrange, intRowToInsert,
this.INT_COLUMN_STARTDATE );
-
+
// Search until a valid start date is found
while ( sStartDate.equals( "" ) ) {
// Decrease the row
intRowToInsert--;
-
+
// Get the start date for the
feature/bug
// in the current row
sStartDate = this.getStringFromCell(
xcellrange, intRowToInsert,
this.INT_COLUMN_STARTDATE );
}
-
+
// Get the GregorianCalender format for the
// start date
gregCalPreviousStartDate =
this.getGregorianCalendarFromString(
sStartDate );
}
-
+
// Getting the cell of the column "Needed Days"
// in the row where to insert
XCell xcellNeededDaysWhereToInsert =
@@ -477,25 +477,25 @@ public class ToDo {
int intNeededDaysWhereToInsert = (int)
Math.round(
xcellNeededDaysWhereToInsert.getValue());
-
+
GregorianCalendar gregCalPreviousNewEndDate =
this.getWorkday(gregCalPreviousStartDate,
intNeededDays - 1 +
intNeededDaysWhereToInsert,
objectHolidays,
- xfunctionaccess);
+ xfunctionaccess);
String sPreviousDueDate =
this.getStringFromCell(
xcellrange, intRowToInsert,
this.INT_COLUMN_DUEDATE );
-
+
GregorianCalendar gregCalPreviousDueDate =
null;
-
+
if ( !sPreviousDueDate.equals( "" ) ) {
gregCalPreviousDueDate =
this.getGregorianCalendarFromString(
sPreviousDueDate );
}
-
+
if ( ( intRowToInsert == intRow ) ||
( gregCalPreviousNewEndDate.after(
gregCalPreviousDueDate ) ) ) {
@@ -507,7 +507,7 @@ public class ToDo {
xcellrange.getCellByPosition(
this.INT_COLUMN_DUEDATE,
intRow ) );
-
+
// Changing the background color of the
cell
// to red
xpropertyset.setPropertyValue(
@@ -522,19 +522,19 @@ public class ToDo {
XTableRows xTableRows =
xcolumnrowrange.getRows();
xTableRows.insertByIndex( intRowToInsert,
1 );
-
+
// Querying for the interface
// XCellRangeMovement on XCellRange
XCellRangeMovement xcellrangemovement =
(XCellRangeMovement)UnoRuntime.queryInterface(
XCellRangeMovement.class, xcellrange
);
-
+
// Creating the cell address of the
destination
CellAddress celladdress = new
CellAddress();
celladdress.Sheet = 0;
celladdress.Column = 0;
celladdress.Row = intRowToInsert;
-
+
// Creating the cell range of the source
CellRangeAddress cellrangeaddress =
new CellRangeAddress();
@@ -543,20 +543,20 @@ public class ToDo {
cellrangeaddress.StartRow = intRow + 1;
cellrangeaddress.EndColumn = 8;
cellrangeaddress.EndRow = intRow + 1;
-
+
// Moves the cell range to another
position in
// the document
xcellrangemovement.moveRange(celladdress,
cellrangeaddress);
-
+
// Removing the row not needed anymore
xcolumnrowrange.getRows().removeByIndex(intRow
+
1, 1);
-
+
// Set the current row, because we want to
// recalculate all rows below
intRow = intRowToInsert - 1;
-
+
// Tests at which line we want to insert
if ( intRow >= this.INT_ROW_FROM ) {
// Get the start date
@@ -580,56 +580,56 @@ public class ToDo {
catch( Exception exception ) {
showExceptionMessage( exception );
}
- }
-
- /** Getting a string from a gregorian calendar.
+ }
+
+ /** Getting a string from a Gregorian calendar.
* @param gregCal Date to be converted.
- * @return string (converted gregorian calendar).
+ * @return string (converted Gregorian calendar).
*/
public String getStringFromGregorianCalendar( GregorianCalendar
gregCal ) {
String sDate = ( gregCal.get( Calendar.MONTH ) + 1 )
+ STRING_SEPARATOR + gregCal.get( Calendar.DATE )
// + STRING_SEPARATOR + ( gregCal.get( Calendar.MONTH ) + 1 )
+ STRING_SEPARATOR + gregCal.get( Calendar.YEAR );
-
- return sDate;
+
+ return sDate;
}
-
+
/** Getting a GregorianCalendar from a string.
* @param sDate String to be converted.
* @return The result of the converting of the string.
*/
public GregorianCalendar getGregorianCalendarFromString( String sDate
) {
int []intDateValue = this.getDateValuesFromString( sDate );
-
+
return( new GregorianCalendar( intDateValue[ 2 ], intDateValue[ 0
],
intDateValue[ 1 ] ) );
}
-
+
/** Getting the day, month and year from a string.
* @param sDate String to be parsed.
* @return Returns an array of integer variables.
*/
public int[] getDateValuesFromString( String sDate) {
int[] intDateValues = new int[ 3 ];
-
+
int intPositionFirstTag = sDate.indexOf( STRING_SEPARATOR );
int intPositionSecondTag = sDate.indexOf(STRING_SEPARATOR,
intPositionFirstTag + 1);
-
+
// Getting the value of the month
intDateValues[ 0 ] = Integer.parseInt(
sDate.substring(0, intPositionFirstTag)) - 1;
// Getting the value of the day
intDateValues[ 1 ] = Integer.parseInt(
- sDate.substring(intPositionFirstTag + 1,
intPositionSecondTag));
+ sDate.substring(intPositionFirstTag + 1,
intPositionSecondTag));
// Getting the value of the year
intDateValues[ 2 ] = Integer.parseInt(
sDate.substring(intPositionSecondTag + 1, sDate.length()));
-
+
return intDateValues;
}
-
+
/** Getting a content from a specified cell.
* @param xcellrange Providing access to cells.
* @param intRow Number of row.
@@ -639,7 +639,7 @@ public class ToDo {
public String getStringFromCell( XCellRange xcellrange, int intRow,
int intColumn ) {
XTextRange xtextrangeStartDate = null;
-
+
try {
// Getting the cell holding the information about the start
date
XCell xcellStartDate = xcellrange.getCellByPosition(intColumn,
@@ -651,11 +651,11 @@ public class ToDo {
catch( Exception exception ) {
this.showExceptionMessage( exception );
}
-
+
// Getting the start date
- return xtextrangeStartDate.getString().trim();
+ return xtextrangeStartDate.getString().trim();
}
-
+
/** Writing a specified string to a specified cell.
* @param xcellrange Providing access to the cells.
* @param intRow Number of row.
@@ -678,7 +678,7 @@ public class ToDo {
this.showExceptionMessage( exception );
}
}
-
+
/** Calculates the week of day and calls the method "setStringToCell".
* @param gregCal Day to be written to the cell.
* @param xcellrange Providing access to the cells.
@@ -701,11 +701,11 @@ public class ToDo {
} else if ( intDayOfWeek == Calendar.FRIDAY ) {
sDayOfWeek = "FRI";
}
-
+
this.setStringToCell( xcellrange, intRow, intColumn,
sDayOfWeek );
}
-
+
/** Calculates the dates of the official holidays with help of Calc
* functions.
* @param vectorHolidays Holding all holidays.
@@ -727,15 +727,15 @@ public class ToDo {
intNumberOfYear <= ( intHowManyYears - 1 );
intNumberOfYear++ ) {
intYear += intNumberOfYear;
-
- // Getting the Easter sunday
+
+ // Getting the Easter Sunday
Double dEasterSunday = ( Double )
xfunctionaccess.callFunction(
"EASTERSUNDAY", new Object[] { new
Integer(intYear) });
-
+
int intEasterSunday = (int)Math.round(
dEasterSunday.doubleValue());
-
+
// New-year
vectorHolidays.addElement( xfunctionaccess.callFunction(
"DATE",
@@ -743,15 +743,15 @@ public class ToDo {
new Integer( intYear ),
new Integer( 1 ),
new Integer( 1 ) } ));
-
+
// Good Friday
vectorHolidays.addElement(
new Double( intEasterSunday - 2 ) );
-
- // Easter monday
+
+ // Easter Monday
vectorHolidays.addElement(
new Double( intEasterSunday + 1 ) );
-
+
// Labour Day
vectorHolidays.addElement( xfunctionaccess.callFunction(
"DATE",
@@ -759,13 +759,13 @@ public class ToDo {
new Integer( intYear ),
new Integer( 5 ),
new Integer( 1 ) } ));
-
+
// Ascension Day
vectorHolidays.addElement(new Double(intEasterSunday + 39
));
-
- // Pentecost monday
+
+ // Pentecost Monday
vectorHolidays.addElement(new Double(intEasterSunday + 50
));
-
+
// German Unification
vectorHolidays.addElement( xfunctionaccess.callFunction(
"DATE",
@@ -773,7 +773,7 @@ public class ToDo {
new Integer( intYear ),
new Integer( 10 ),
new Integer( 3 ) } ));
-
+
// Christmas Day First
vectorHolidays.addElement( xfunctionaccess.callFunction(
"DATE",
@@ -781,7 +781,7 @@ public class ToDo {
new Integer( intYear ),
new Integer( 12 ),
new Integer( 25 ) } ));
-
+
// Christmas Day Second
vectorHolidays.addElement( xfunctionaccess.callFunction(
"DATE",
@@ -795,7 +795,7 @@ public class ToDo {
this.showExceptionMessage( exception );
}
}
-
+
/** Returns the serial number of the date before or after a specified
* number of workdays.
* @param gregCalStartDate Date to start with the calculation.
@@ -810,7 +810,7 @@ public class ToDo {
int intDays, Object[][] objectHolidays,
XFunctionAccess xfunctionaccess ) {
GregorianCalendar gregCalWorkday = null;
-
+
try {
// Getting the value of the start date
Double dDate = ( Double ) xfunctionaccess.callFunction(
@@ -820,18 +820,18 @@ public class ToDo {
new Integer( gregCalStartDate.get( Calendar.MONTH ) +
1 ),
new Integer( gregCalStartDate.get( Calendar.DATE ) )
} );
-
+
Double dWorkday = ( Double ) xfunctionaccess.callFunction(
"com.sun.star.sheet.addin.Analysis.getWorkday",
new Object[] { dDate, new Integer( intDays ), objectHolidays }
);
-
+
Double dYear = ( Double ) xfunctionaccess.callFunction(
"YEAR", new Object[] { dWorkday } );
Double dMonth = ( Double ) xfunctionaccess.callFunction(
"MONTH", new Object[] { dWorkday } );
Double dDay = ( Double ) xfunctionaccess.callFunction(
"DAY", new Object[] { dWorkday } );
-
+
gregCalWorkday = new GregorianCalendar(
dYear.intValue(),
dMonth.intValue() - 1,
@@ -840,10 +840,10 @@ public class ToDo {
catch( Exception exception ) {
this.showExceptionMessage( exception );
}
-
+
return gregCalWorkday;
}
-
+
/** Getting the holidays from the spreadsheet.
* @param vectorHolidays Holding all holidays.
* @param xcellrange Providing the cells.
@@ -855,13 +855,13 @@ public class ToDo {
try {
int intRow = this.INT_ROW_HOLIDAYS_START;
int intColumn = this.INT_COLUMN_HOLIDAYS_START;
-
+
double dHolidayStart = xcellrange.getCellByPosition(
intColumn, intRow ).getValue();
-
+
double dHolidayEnd = xcellrange.getCellByPosition(
intColumn + 1, intRow ).getValue();
-
+
while ( dHolidayStart != 0 ) {
if ( dHolidayEnd == 0 ) {
vectorHolidays.addElement(
@@ -876,7 +876,7 @@ public class ToDo {
vectorHolidays.addElement( new Double( intHoliday
) );
}
}
-
+
intRow++;
dHolidayStart = xcellrange.getCellByPosition(
intColumn, intRow).getValue();
@@ -888,7 +888,7 @@ public class ToDo {
this.showExceptionMessage( exception );
}
}
-
+
/** Showing the stack trace in a JOptionPane.
* @param sMessage The message to show.
*/
@@ -902,7 +902,7 @@ public class ToDo {
javax.swing.JOptionPane.INFORMATION_MESSAGE);
jframe.dispose();
}
-
+
/** Writing the stack trace from an exception to a string and calling
* the method showMessage() with this string.
* @param exception The occurred exception.
@@ -915,9 +915,9 @@ public class ToDo {
exception.printStackTrace( printwriter);
System.err.println( exception );
this.showMessage( swriter.getBuffer().substring(0) );
- }
+ }
}
-
+
/**
* Gives a factory for creating the service.
* This method is called by the <code>JavaLoader</code>
@@ -930,11 +930,11 @@ public class ToDo {
*/
public static XSingleComponentFactory __getComponentFactory(String
sImplName) {
XSingleComponentFactory xFactory = null;
-
+
if ( sImplName.equals( ToDoImpl.class.getName() ) )
xFactory = Factory.createComponentFactory(ToDoImpl.class,
ToDoImpl.getServiceNames());
-
+
return xFactory;
}
@@ -948,7 +948,7 @@ public class ToDo {
*/
// This method not longer necessary since OOo 3.4 where the component
registration
// was changed to passive component registration. For more details see
- // http://wiki.services.openoffice.org/wiki/Passive_Component_Registration
+ // https://wiki.openoffice.org/wiki/Passive_Component_Registration
// public static boolean __writeRegistryServiceInfo(XRegistryKey regKey) {
// return Factory.writeRegistryServiceInfo(ToDoImpl.class.getName(),