SSL calendarImpl.cxx
Interaktion und PortierbarkeitC
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * 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 regarding copyright * ownership. The ASF licenses this file 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 .
*/
for (i = 0; i < sal::static_int_cast<sal_Int32>(lookupTable.size()); i++) {
lookupTableItem &listItem = lookupTable[i]; if (aCacheID == listItem.m_aCacheID) {
xCalendar = listItem.xCalendar; break;
}
}
if (i >= sal::static_int_cast<sal_Int32>(lookupTable.size())) {
Reference < XInterface > xI = m_xContext->getServiceManager()->createInstanceWithContext( "com.sun.star.i18n.Calendar_" + uniqueID, m_xContext);
if ( ! xI.is() ) { // check if the calendar is defined in localedata, load gregorian calendar service. const Sequence< Calendar2 > xC = LocaleDataImpl::get()->getAllCalendars2(rLocale); if (std::any_of(xC.begin(), xC.end(), [&uniqueID](const Calendar2& rCal) { return uniqueID == rCal.Name; }))
xI = m_xContext->getServiceManager()->createInstanceWithContext(u"com.sun.star.i18n.Calendar_gregorian"_ustr, m_xContext);
}
if ( !xI.is() ) throw RuntimeException(u"CalendarImpl::loadCalendarTZ: no calendar found for this locale"_ustr);
xCalendar.set(xI, UNO_QUERY);
if (!rTimeZone.isEmpty())
{ /* XXX NOTE: currently (2019-06-19) calendar implementations derive * from Calendar_gregorian, even Hijri and Jewish. If that should
* change in future this should be adapted. */
Calendar_gregorian* pCal = dynamic_cast<Calendar_gregorian*>(xCalendar.get());
bTimeZone = (pCal && pCal->setTimeZone(rTimeZone));
}
if ( !xCalendar.is() )
{
xCalendar = xOldCalendar; throw RuntimeException(u"CalendarImpl::loadCalendarTZ: no calendar found for this locale, should use old one?"_ustr);
}
if (!bTimeZone) // The calendar is usable but is not in the expected time zone. throw RuntimeException(u"CalendarImpl::loadCalendarTZ: the calendar is usable but is not in the expected time zone"_ustr);
}
Calendar2 SAL_CALL
CalendarImpl::getLoadedCalendar2()
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getLoadedCalendar2: no calendar"_ustr); return xCalendar->getLoadedCalendar2();
}
::css::i18n::Calendar SAL_CALL
CalendarImpl::getLoadedCalendar()
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getLoadedCalendar: no calendar"_ustr); return xCalendar->getLoadedCalendar();
}
OUString SAL_CALL
CalendarImpl::getUniqueID()
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getUniqueID: no calendar"_ustr); return xCalendar->getUniqueID();
}
void SAL_CALL
CalendarImpl::setValue( sal_Int16 fieldIndex, sal_Int16 value )
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::setValue: no calendar"_ustr);
xCalendar->setValue( fieldIndex, value );
}
sal_Int16 SAL_CALL
CalendarImpl::getValue( sal_Int16 fieldIndex )
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getValue: no calendar"_ustr); return xCalendar->getValue( fieldIndex );
}
void SAL_CALL
CalendarImpl::addValue( sal_Int16 fieldIndex, sal_Int32 amount )
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::addValue: no calendar"_ustr);
xCalendar->addValue( fieldIndex, amount);
}
sal_Int16 SAL_CALL
CalendarImpl::getFirstDayOfWeek()
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getFirstDayOfWeek: no calendar"_ustr); return xCalendar->getFirstDayOfWeek();
}
void SAL_CALL
CalendarImpl::setFirstDayOfWeek( sal_Int16 day )
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::setFirstDayOfWeek: no calendar"_ustr);
xCalendar->setFirstDayOfWeek(day);
}
void SAL_CALL
CalendarImpl::setMinimumNumberOfDaysForFirstWeek( sal_Int16 days )
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::setMinimumNumberOfDaysForFirstWeek: no calendar"_ustr);
xCalendar->setMinimumNumberOfDaysForFirstWeek(days);
}
sal_Int16 SAL_CALL
CalendarImpl::getMinimumNumberOfDaysForFirstWeek()
{ if (!xCalendar.is()) throw RuntimeException(u"CalendarImpl::getMinimumNumberOfDaysForFirstWeek: no calendar"_ustr); return xCalendar->getMinimumNumberOfDaysForFirstWeek();
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.