Issue 68819

Summary: API: i18n.CalendarImpl::com::sun::star::i18n::XCalendar
Product: App Dev Reporter: chne
Component: apiAssignee: AOO issues mailing list <issues>
Status: CONFIRMED --- QA Contact:
Severity: Trivial    
Priority: P3 CC: issues
Version: 3.3.0 or older (OOo)   
Target Milestone: ---   
Hardware: All   
OS: All   
Issue Type: DEFECT Latest Confirmation in: ---
Developer Difficulty: ---

Description chne 2006-08-21 10:34:28 UTC
while running and enhancing the UNO-API-Tests for StarOffice I stumble
over a problem:

Language: he, Country: IL, Variant: IL, Name: jewish

xCalender.setValue(CalendarFieldIndex.MONTH, 2);
short set = xCalneder.getValue(CalendarFieldIndex.MONTH);

=> failed for MONTH expected 2 gained 1 
To reproduce this behavior just start your office with parameter

"-accept=socket,host=0,port=8100;urp;" 

and call inside a solar shell:

checkapi -o i18n.CalendarImpl::com::sun::star::i18n::XCalendar

Note: since the childworkspace "qadev27" is not integrated please use this cws
to execute the test. I have enhanced the test to display the failure.
Comment 1 karl.hong 2006-10-10 22:44:37 UTC
fixed.
Comment 2 karl.hong 2006-10-10 22:45:31 UTC
.
Comment 3 karl.hong 2006-10-13 17:25:16 UTC
ready for QA.
Comment 4 chne 2006-10-19 16:06:28 UTC
while executing the test the office crashes
Comment 5 chne 2006-10-19 16:07:16 UTC
office crashes in i18n27
Comment 6 karl.hong 2006-10-20 08:56:13 UTC
Fixed.
Comment 7 karl.hong 2006-10-20 09:22:09 UTC
Hi Christoph,

I have fixed the problem and rebuilt install set. Please try again.

Thanks,
Karl.
Comment 8 chne 2006-10-23 18:19:44 UTC
cn->khong: the following methods does not work:
getValue() - PASSED.FAILED
isValid() - PASSED.FAILED


Comment 9 karl.hong 2006-10-23 23:35:37 UTC
khong->cn,  I have modified your test cases in _XCalendar.java, and the test is
passed.

    public void _getValue() {
        boolean res = true;

        requiredMethod("setValue()");
 new=>    oObj.setValue(CalendarFieldIndex.MONTH, newValue);
        short aValue = oObj.getValue(CalendarFieldIndex.MONTH);
        res &= (aValue == newValue);
        tRes.tested("getValue()", res);
    }

newValue needs to be set before you can get it, requiredMethod("serValue()")
seems not doing right thing.

    public void _isValid() {
        boolean res = true;

  new=>   oObj.loadDefaultCalendar(installed_locales[0]);

        oObj.setValue(CalendarFieldIndex.MONTH, (short) 37);
        res &= !oObj.isValid();
        oObj.setValue(CalendarFieldIndex.MONTH, (short) 10);
        res &= oObj.isValid();

        tRes.tested("isValid()", res);
    }

It looks like calendar is not loaded in this case, only set one field will not
make calendar valid.
Comment 10 chne 2006-10-24 14:48:42 UTC
cn->khong: in the current i18n27 version the initial issue occure again. And as
a result of this the getValue() and isValid() methods failed.
Comment 11 stefan.baltzer 2006-10-24 16:32:23 UTC
SBA: Set status back to NEW.
Comment 12 karl.hong 2006-10-24 17:04:35 UTC
khong->cn, I have run your test on m186 without my fix for this issue, it got
exact same same error, what do you mean it occured again? 



Comment 13 karl.hong 2006-10-24 19:12:01 UTC
khong->cn, I made wrong assumption of the test case _isValid(). 

The calendar is loaded, it is Arabic hijri calendar in this case.

The problem is the case set MONTH to 37 first, which makes the calendar invalid.
During calculation for hijri calendar, other fields, like day, year, are also
re-calculated, and may contain invalid values, just resetting MONTH to 10 in
next statement may not make the calendar valid.

The calendar should be recovered between two test statements.

    public void _isValid() {
        boolean res = true;

        oObj.setValue(CalendarFieldIndex.MONTH, (short) 37);
        res &= !oObj.isValid();
 new=>  oObj.setDateTime(aOriginalDTime);
        oObj.setValue(CalendarFieldIndex.MONTH, (short) 10);
        res &= oObj.isValid();

        tRes.tested("isValid()", res);
    }
Comment 14 karl.hong 2006-10-24 19:45:58 UTC
BTW, when creating or loading a new calendar, the calendar is not initialized to
0, but today's date. getValue without setValue will get today's date, like 9 for
this month Oct for CalendarFieldIndex.MONTH, not newValue (0) as you expected in
the case _getValue().
Comment 15 chne 2006-10-27 10:31:52 UTC
cn->khong: 

1.) in the current cws I get the initial error: That means:

Language: he, Country: IL, Variant: IL, Name: jewish

xCalender.setValue(CalendarFieldIndex.MONTH, 2);
short set = xCalneder.getValue(CalendarFieldIndex.MONTH);

=> failed for MONTH expected 2 gained 1 

2.) isValid(): in the past the test code works. 
Comment 16 ooo 2006-10-27 18:24:07 UTC
As communicated with 'cn' and 'sba' we'll remove this issue from CWS
i18n27. The related overall code changes to the calendar source file are
very small and effectively only remove a possible unwanted side effect.

However, there is some yet unidentified behavior to be investigated for
the Jewish calendar. The testcase script portion of method _setValue()

    short[] fields = new short[]{CalendarFieldIndex.DAY_OF_MONTH,
                                 CalendarFieldIndex.HOUR,
                                 CalendarFieldIndex.MINUTE,
                                 CalendarFieldIndex.SECOND,
                                 CalendarFieldIndex.MILLISECOND,
                                 CalendarFieldIndex.YEAR,
                                 CalendarFieldIndex.MONTH
    };
    for (int k=0; k<fields.length;k++) {
        //log.println("Setting: " + names[k]+" to "+ valueSet[k]);
        oObj.setDateTime(0.0);
        short set = oObj.getValue(fields[k]);
        if (fields[k] == CalendarFieldIndex.MONTH) set = newValue;
        oObj.setValue(fields[k],set);
        short get = oObj.getValue(fields[k]);
        if (get != set) {
            error += "failed for "+names[k]+" expected "+
                        set+" gained "+get+" ; ";
        }
    }

with newValue==2 leads to the condition (get != set) being fulfilled,
which is strange enough.
Comment 17 karl.hong 2006-10-30 17:32:46 UTC
Thanks, Eike. I could reproduce the problem. setDateTime(0.0) somehow makes
jewish calendar invalid. I fixed a problem in initializing non-gregorian
calendars in contructor, setDateTime seems another place has similar problem. 
Comment 18 Martin Hollmichel 2007-11-09 17:28:41 UTC
set target from 2.x to 3.x according to
http://wiki.services.openoffice.org/wiki/Target_3x
Comment 19 Rob Weir 2013-07-30 02:42:37 UTC
Reset assignee on issues not touched by assignee in more than 1000 days.