62#include <rtl/ustrbuf.hxx>
64#include <osl/process.h>
65#include <osl/thread.h>
66#include <osl/file.hxx>
69#include <unicode/datefmt.h>
70#include <unicode/udat.h>
85 OUString& str, sal_uInt16 strlen, rtl_TextEncoding aEncoding)
88 OUStringBuffer strBuf(128);
97 len = std::min(sal_uInt16(1023), strlen);
100 strBuf.append( OUString(buf, len, aEncoding) );
104 str = strBuf.makeStringAndClear();
114 sal_uInt16 sublen = 0;
116 sal_uInt16 readLen = 0;
117 while(readLen<strlen)
124 readLen+=
sizeof(readbyte);
131 strBuf.append( OUString(buf, sublen, aEncoding) );
137 buf[sublen++] = readbyte;
139 if(sublen>=1023 || readLen==strlen)
141 strBuf.append( OUString(buf, sublen, aEncoding) );
150 readLen+=
sizeof(readword);
152 if(readword == 0x0000)
157 unibuf[sublen] =
'\0';
158 strBuf.append( unibuf );
164 unibuf[sublen++] = readword;
166 if(sublen>=1023 || readLen==strlen)
168 unibuf[sublen] =
'\0';
169 strBuf.append( unibuf );
174 str = strBuf.makeStringAndClear();
184 sal_uInt16 oldpos = pObjStrm->
GetPos();
186 for (sal_uInt16
i = 0;
i < len;
i++)
191 pObjStrm->
Seek(oldpos);
195 pObjStrm->
Seek(oldpos);
208 return OStringToOUString(fileName, osl_getThreadTextEncoding());
211 OUString uUrlFileName;
212 OUString uFileName(fileName.getStr(), fileName.getLength(), osl_getThreadTextEncoding());
213 if ( fileName.startsWith(
".") || fileName.indexOf(
SEPARATOR) < 0 )
215 OUString uWorkingDir;
216 OSL_VERIFY( osl_getProcessWorkingDir(&uWorkingDir.pData) == osl_Process_E_None );
217 OSL_VERIFY( FileBase::getAbsoluteFileURL(uWorkingDir, uFileName, uUrlFileName) == FileBase::E_None );
220 OSL_VERIFY( FileBase::getFileURLFromSystemPath(uFileName, uUrlFileName) == FileBase::E_None );
228 OUString aResult = OUString::number(dt.
tm_year) +
"-" + OUString::number(dt.
tm_mon) +
"-" + OUString::number(dt.
tm_mday) +
229 "T" + OUString::number(dt.
tm_hour) +
":" + OUString::number(dt.
tm_min) +
":" + OUString::number(dt.
tm_sec);
239 icu::DateFormat::EStyle style;
241 style = icu::DateFormat::FULL;
243 style = icu::DateFormat::SHORT;
248 icu::DateFormat* fmt = icu::DateFormat::createDateInstance(style,aLocale);
252 UErrorCode status = U_ZERO_ERROR;
253 UChar* pattern =
nullptr;
255 nLengthNeed = udat_toPattern(
reinterpret_cast<void **
>(fmt),
false,
nullptr,
nLength,&status);
256 if (status == U_BUFFER_OVERFLOW_ERROR)
258 status = U_ZERO_ERROR;
260 pattern =
static_cast<UChar*
>(malloc(
sizeof(UChar)*
nLength));
261 udat_toPattern(
reinterpret_cast<void **
>(fmt),
false,pattern,
nLength,&status);
263 if (pattern ==
nullptr)
272 std::unique_ptr<XFDateStyle> pDateStyle(
new XFDateStyle);
274 for (int32_t
i=0;
i<nLengthNeed;)
276 cSymbol = pattern[
i];
291 pDateStyle->AddEra();
306 pDateStyle->AddYear(
false);
308 pDateStyle->AddYear();
323 pDateStyle->AddMonth(
false);
325 pDateStyle->AddMonth();
327 pDateStyle->AddMonth(
false,
true);
329 pDateStyle->AddMonth(
true,
true);
344 pDateStyle->AddMonthDay(
false);
346 pDateStyle->AddMonthDay();
361 pDateStyle->AddHour(
false);
363 pDateStyle->AddHour();
378 pDateStyle->AddHour(
false);
380 pDateStyle->AddHour();
395 pDateStyle->AddMinute(
false);
397 pDateStyle->AddMinute();
412 pDateStyle->AddSecond(
false);
414 pDateStyle->AddSecond();
446 pDateStyle->AddWeekDay(
false);
448 pDateStyle->AddWeekDay();
530 pDateStyle->AddAmPm();
558 pDateStyle->AddHour(
false);
560 pDateStyle->AddHour();
591 pDateStyle->AddText(
"'");
596 if ((cSymbol>=
'A' && cSymbol<=
'Z') || (cSymbol>=
'a' && cSymbol<=
'z') )
608 if ((cTmp>=
'A' && cTmp<=
'Z') || (cTmp>=
'a' && cTmp<=
'z') ||
609 cTmp==
'\'' || cTmp==
'"' )
619 pDateStyle->AddText(OUString(buffer));
636 icu::DateFormat* fmt = icu::DateFormat::createTimeInstance(icu::DateFormat::DEFAULT,aLocale);
640 UErrorCode status = U_ZERO_ERROR;
641 UChar* pattern =
nullptr;
642 nLengthNeed = udat_toPattern(
reinterpret_cast<void **
>(fmt),
false,
nullptr,
nLength,&status);
643 if (status == U_BUFFER_OVERFLOW_ERROR)
645 status = U_ZERO_ERROR;
647 pattern =
static_cast<UChar*
>(malloc(
sizeof(UChar)*
nLength));
648 udat_toPattern(
reinterpret_cast<void **
>(fmt),
false,pattern,
nLength,&status);
651 if (pattern ==
nullptr)
661 std::unique_ptr<XFTimeStyle> pTimeStyle(
new XFTimeStyle);
663 for (int32_t
i=0;
i<nLengthNeed;)
665 cSymbol = pattern[
i];
681 pTimeStyle->AddHour(
false);
683 pTimeStyle->AddHour();
698 pTimeStyle->AddHour(
false);
700 pTimeStyle->AddHour();
715 pTimeStyle->AddMinute(
false);
717 pTimeStyle->AddMinute();
732 pTimeStyle->AddSecond(
false);
734 pTimeStyle->AddSecond();
765 pTimeStyle->SetAmPm(
true);
793 pTimeStyle->AddHour(
false);
795 pTimeStyle->AddHour();
813 pTimeStyle->AddText(
"'");
818 if ((cSymbol>=
'A' && cSymbol<=
'Z') || (cSymbol>=
'a' && cSymbol<=
'z') )
830 if ((cTmp>=
'A' && cTmp<=
'Z') || (cTmp>=
'a' && cTmp<=
'z') ||
831 cTmp==
'\'' || cTmp==
'"' )
840 pTimeStyle->AddText(OUString(buffer));
static const AllSettings & GetSettings()
static icu::Locale getIcuLocale(const LanguageTag &rLanguageTag)
stream class for LwpObject body data provide stream like interface to read object data
sal_uInt16 QuickReaduInt16(bool *pFailure=nullptr)
@descr Quick read sal_uInt32
sal_uInt16 QuickRead(void *buf, sal_uInt16 len)
@descr read len bytes from object stream to buffer
sal_uInt16 GetPos() const
sal_uInt8 QuickReaduInt8(bool *pFailure=nullptr)
@descr Quick read sal_uInt8
void Seek(sal_uInt16 pos)
@descr Seek to pos in object buffer/buffer
constexpr bool starts_with(std::basic_string_view< charT, traits > sv, std::basic_string_view< charT, traits > x) noexcept