21#include <osl/diagnose.h>
22#include <rtl/character.hxx>
23#include <rtl/ustrbuf.hxx>
36#define LOOP_CHECK_DECL \
37 sal_Int32 nOldInPos = SAL_MAX_INT32;
38#define LOOP_CHECK_RESTART \
39 nOldInPos = SAL_MAX_INT32;
40#define LOOP_CHECK_CHECK( where ) \
41 OSL_ENSURE( nOldInPos!=m_nInPos || m_cNextCh==sal_Unicode(EOF), where ); \
42 if( nOldInPos==m_nInPos && m_cNextCh!=sal_Unicode(EOF) ) \
49#define LOOP_CHECK_DECL
50#define LOOP_CHECK_RESTART
51#define LOOP_CHECK_CHECK( where )
124 bool bAsterisk =
false;
146 OUStringBuffer sTmpBuffer(32);
150 }
while( (rtl::isAsciiAlphanumeric(
m_cNextCh) ||
160 if(
m_aToken.equalsIgnoreAsciiCase(
"import" ) )
165 if(
m_aToken.equalsIgnoreAsciiCase(
"page" ) )
177 bool bDone =
false, bEscape =
false;
178 while( !bDone && !
IsEOF() )
180 bool bOldEscape = bEscape;
185 if( !cQuoteCh && !bOldEscape )
189 if( !cQuoteCh && !bOldEscape )
190 bDone = nBlockLvl==0;
193 if( !cQuoteCh && !bOldEscape )
194 bDone = --nBlockLvl==0;
239 OUStringBuffer sTmpBuffer(32);
243 }
while( (rtl::isAsciiAlphanumeric(
m_cNextCh) ||
249 m_aToken.equalsIgnoreAsciiCase(
"important" ) )
278 OUStringBuffer sTmpBuffer(
MAX_LEN );
309 OUStringBuffer sTmpBuffer( 16 );
313 }
while( sTmpBuffer.getLength() < 7 &&
319 if( sTmpBuffer.getLength()==6 )
337 sTmpBuffer.setLength( 0 );
383 OUStringBuffer sTmpBuffer2(64);
387 }
while( (rtl::isAsciiAlphanumeric(
m_cNextCh) ||
390 aIdent += sTmpBuffer2;
393 const char *pCmp1 =
nullptr, *pCmp2 =
nullptr, *pCmp3 =
nullptr;
394 double nScale1 = 1., nScale2 = 1.;
403 nScale1 = (72.*20.)/2.54;
421 nScale1 = (72.*20.)/25.4;
437 OSL_ENSURE( pCmp1,
"Where does the first digit come from?" );
438 if( aIdent.equalsIgnoreAsciiCaseAscii( pCmp1 ) )
444 aIdent.equalsIgnoreAsciiCaseAscii( pCmp2 ) )
450 aIdent.equalsIgnoreAsciiCaseAscii( pCmp3 ) )
533 OUStringBuffer sTmpBuffer(8);
537 }
while( sTmpBuffer.getLength() < 9 &&
543 if( sTmpBuffer.getLength()==6 || sTmpBuffer.getLength()==3 )
553 if( sTmpBuffer.getLength()==8 )
557 sal_uInt32 nColor = sTmpBuffer.makeStringAndClear().toUInt32(16);
558 sal_uInt32 nRed = (nColor & 0xff000000) >> 24;
559 sal_uInt32 nGreen = (nColor & 0xff0000) >> 16;
560 sal_uInt32 nBlue = (nColor & 0xff00) >> 8;
561 double nAlpha = (nColor & 0xff) / 255.0;
562 nRed = (1 - nAlpha) * 255 + nAlpha * nRed;
563 nGreen = (1 - nAlpha) * 255 + nAlpha * nGreen;
564 nBlue = (1 - nAlpha) * 255 + nAlpha * nBlue;
565 nColor = (nRed << 16) + (nGreen << 8) + nBlue;
566 m_aToken += OUString::number(nColor, 16);
606 bool bHexColor =
true;
609 OUStringBuffer sTmpBuffer(64);
614 bHexColor = sTmpBuffer.getLength()<7 &&
620 }
while( (rtl::isAsciiAlphanumeric(
m_cNextCh) ||
625 if( bHexColor && sTmpBuffer.getLength()==6 )
634 m_aToken.equalsIgnoreAsciiCase(
"url" )) ||
636 (
m_aToken.equalsIgnoreAsciiCase(
"rgb" ) ||
m_aToken.equalsIgnoreAsciiCase(
"rgba" ) )
640 OUStringBuffer sTmpBuffer2(64);
645 case '(': nNestCnt++;
break;
646 case ')': nNestCnt--;
break;
844 std::unique_ptr<CSS1Selector> pRoot;
857 bool bNextToken =
true;
946 OSL_ENSURE( (pRoot!=
nullptr) == (pLast!=
nullptr),
947 "Root-Selector, but no Last" );
957 if( bNextToken && !bDone )
1013 std::unique_ptr<CSS1Expression> pRoot;
1095 OSL_ENSURE( (pRoot!=
nullptr) == (pLast!=
nullptr),
1096 "Root-Selector, but no Last" );
1127 : m_bWhiteSpace(false)
1145 OUString aTmp( rIn );
1148 while( !aTmp.isEmpty() &&
1149 (
' '==(c=aTmp[0]) ||
'\t'==c ||
'\r'==c ||
'\n'==c ) )
1150 aTmp = aTmp.copy( 1 );
1152 while( !aTmp.isEmpty() && (
' '==(c=aTmp[aTmp.getLength()-1])
1153 ||
'\t'==c ||
'\r'==c ||
'\n'==c ) )
1154 aTmp = aTmp.copy( 0, aTmp.getLength()-1 );
1157 if( aTmp.getLength() >= 4 &&
1158 aTmp.startsWith(
"<!--" ) )
1159 aTmp = aTmp.copy( 4 );
1161 if( aTmp.getLength() >=3 &&
1162 aTmp.endsWith(
"-->") )
1163 aTmp = aTmp.copy( 0, aTmp.getLength() - 3 );
1165 if( aTmp.isEmpty() )
1219 std::unique_ptr<CSS1Expression> )
1235 OSL_ENSURE(
CSS1_URL==
eType,
"CSS1-Expression is not URL" );
1237 OSL_ENSURE(
aValue.startsWithIgnoreAsciiCase(
"url" ) &&
1238 aValue.getLength() > 5 &&
1241 "no valid URL(...)" );
1243 if(
aValue.getLength() <= 5 )
1263 "CSS1-Expression cannot be colour" );
1274 sal_uInt8 aColors[4] = { 0, 0, 0, 255 };
1277 if (!
aValue.startsWithIgnoreAsciiCase(
"rgb" ) ||
aValue.getLength() < 6 ||
1283 sal_Int32
nPos =
aValue.startsWithIgnoreAsciiCase(
"rgba" )?5:4;
1284 char cSep = (
aValue.indexOf(
',') != -1)?
',':
' ';
1286 bool bIsSepAlphaDiv = (
aValue.indexOf(
'/') != -1)?
true:
false;
1287 for (
int nCol = 0; nCol < 4 && nPos > 0; ++nCol )
1296 else if( aNumber.find(
'%') != std::u16string_view::npos )
1303 else if( nNumber > 255 )
1305 else if( aNumber.find(
'.') != std::u16string_view::npos )
1310 aColors[nCol] =
static_cast<sal_uInt8>(nNumber);
1312 if (bIsSepAlphaDiv && nCol == 2)
1320 rColor.
SetRed( aColors[0] );
1332 OUString aTmp(
aValue.toAsciiUpperCase() );
1344 bool bDouble =
aValue.getLength()-nOffset == 3;
1345 sal_Int32
i = nOffset, nEnd = (bDouble ? 3 : 6) + nOffset;
1348 for( ;
i<nEnd;
i++ )
1352 if( c >=
'0' && c <=
'9' )
1354 else if( c >=
'A' && c <=
'F' )
1356 else if( c >=
'a' && c <=
'f' )
1380 rColor.
SetRed(
static_cast<sal_uInt8>((nColor & 0x00ff0000UL) >> 16) );
bool IsParserWorking() const
Is the parser still working?
void InitRead(const OUString &rIn)
prepare parsing
virtual void SelectorParsed(std::unique_ptr< CSS1Selector > pSelector, bool bFirst)
Called after a selector was parsed.
virtual void DeclarationParsed(const OUString &rProperty, std::unique_ptr< CSS1Expression > pExpr)
Called after a declaration or property was parsed.
sal_Unicode GetNextChar()
std::unique_ptr< CSS1Expression > ParseDeclaration(OUString &rProperty)
void ParseStyleOption(const OUString &rIn)
parse the content of a HTML style option
std::unique_ptr< CSS1Selector > ParseSelector()
void SetNext(CSS1Selector *pNxt)
void SetGreen(sal_uInt8 nGreen)
void SetRed(sal_uInt8 nRed)
void SetAlpha(sal_uInt8 nAlpha)
void SetBlue(sal_uInt8 nBlue)
SVT_DLLPUBLIC sal_uInt32 GetHTMLColor(const rtl::OUString &rName)
if(aStr !=aBuf) UpdateName_Impl(m_xFollowLb.get()
OString strip(const OString &rIn, char c)
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
std::basic_string_view< charT, traits > getToken(std::basic_string_view< charT, traits > sv, charT delimiter, std::size_t &position)
double toDouble(std::u16string_view str)
#define LOOP_CHECK_RESTART
#define LOOP_CHECK_CHECK(where)
@ CSS1_SELTYPE_ELEM_CLASS
a subexpression of a CSS1 declaration
void SetNext(CSS1Expression *pNxt)
void GetURL(OUString &rURL) const
bool GetColor(Color &rRGB) const