// 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 stringBugID = xtextrange.getString();
if ( !stringBugID.startsWith( "http://so-web1.germany.sun.com/bis/servlet/" +
"intray.ControlPanel?system=1&update=true&id=" ) ) {
String stringBugIDLink = "http://so-web1.germany.sun.com/bis/servlet/" +
"intray.ControlPanel?system=1&update=true&id=" + stringBugID +
"&showframeset=true";
// Querying for the interface XMultiServiceFactory
XMultiServiceFactory xmultiservicefactoryTextField =
(XMultiServiceFactory)UnoRuntime.queryInterface(XMultiServiceFactory.class,
aInstance );
// Creating an instance of the text field URL
Object objectTextField =
xmultiservicefactoryTextField.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", stringBugIDLink );
// Setting the representation of the URL
xpropertysetTextField.setPropertyValue( "Representation", stringBugID );
// 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++ ) {
// Getting the cell of the column "Needed Days" in the current row
XCell xcell = xcellrange.getCellByPosition( INT_COLUMN_NEEDEDDAYS, intRow );
// 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 stringStatus = 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" */
if ( ( intNeededDays > 0 )
&& !( stringStatus.toLowerCase().trim().equals( "done" ) ) ) {
// Getting the start date after a specified number of workdays
gregoriancalendarStartDate = this.getWorkday(
gregoriancalendarStartDate, 1, objectHolidays,
xfunctionaccess );
// Getting a string with the date format jjjj-mm-dd from the gregorian calendar
String stringDate = this.getStringFromGregorianCalendar(
gregoriancalendarStartDate );
// Set the start date in the specified cell of the table
this.setStringToCell( xcellrange, intRow,
this.INT_COLUMN_STARTDATE, stringDate );
// For the start day set the day of week in the specified cell of the table
this.setDayOfWeek( gregoriancalendarStartDate,
xcellrange, intRow, this.INT_COLUMN_START_DAY_OF_WEEK );
// Getting the end date after a specified number of workdays
GregorianCalendar gregoriancalendarEndDate =
this.getWorkday( gregoriancalendarStartDate,
intNeededDays - 1,
objectHolidays, xfunctionaccess );
// Creating a string with the date format jjjj-mm-dd
stringDate = this.getStringFromGregorianCalendar(
gregoriancalendarEndDate );
// Set the end date in the specified cell of the table
this.setStringToCell( xcellrange, intRow,
this.INT_COLUMN_ENDDATE, stringDate );
// For the end day set the day of week in the specified cell of the table
this.setDayOfWeek( gregoriancalendarEndDate, xcellrange,
intRow, this.INT_COLUMN_END_DAY_OF_WEEK );
// Set the initial date for the next loop
gregoriancalendarStartDate = ( GregorianCalendar )
gregoriancalendarEndDate.clone();
// Get the due date from the table
String stringDueDate = this.getStringFromCell(
xcellrange, intRow, this.INT_COLUMN_DUEDATE );
// Testing if the due date is not empty
if ( !stringDueDate.equals( "" ) ) {
GregorianCalendar gregoriancalendarDueDate =
this.getGregorianCalendarFromString( stringDueDate );
// Testing if the due date is before the calculated end date
if ( gregoriancalendarDueDate.before( gregoriancalendarEndDate ) ) {
/* Getting the date when the processing of the feature/bug should
be started at the latest */
GregorianCalendar gregoriancalendarLatestDateToStart =
this.getWorkday( gregoriancalendarDueDate,
-( 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 gregoriancalendarPreviousStartDate =
this.getGregorianCalendarFromString(
this.getStringFromCell(
xcellrange, intRowToInsert,
this.INT_COLUMN_STARTDATE ) );
// Testing if we have to search for an earlier date to begin
while ( ( gregoriancalendarLatestDateToStart.before(
gregoriancalendarPreviousStartDate ) ) &&
( INT_ROW_FROM != intRowToInsert ) ) {
// Decrease the row
intRowToInsert--;
// Get the start date for the feature/bug in the current row
String stringStartDate = this.getStringFromCell(
xcellrange, intRowToInsert, this.INT_COLUMN_STARTDATE );
// Search until a valid start date is found
while ( stringStartDate.equals( "" ) ) {
// Decrease the row
intRowToInsert--;
// Get the start date for the feature/bug in the current row
stringStartDate = this.getStringFromCell(
xcellrange, intRowToInsert, this.INT_COLUMN_STARTDATE );
}
// Get the GregorianCalender format for the start date
gregoriancalendarPreviousStartDate =
this.getGregorianCalendarFromString( stringStartDate );
}
// Getting the cell of the column "Needed Days" in the row where to insert
XCell xcellNeededDaysWhereToInsert =
xcellrange.getCellByPosition( INT_COLUMN_NEEDEDDAYS, intRowToInsert );
// Getting the number of needed days to perform the feature
int intNeededDaysWhereToInsert = (int)
Math.round( xcellNeededDaysWhereToInsert.getValue() );
GregorianCalendar gregoriancalendarPreviousNewEndDate =
this.getWorkday( gregoriancalendarPreviousStartDate,
intNeededDays - 1 + intNeededDaysWhereToInsert,
objectHolidays, xfunctionaccess );