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(6);
537 }
while( sTmpBuffer.getLength() < 7 &&
543 if( sTmpBuffer.getLength()==6 || sTmpBuffer.getLength()==3 )
586 bool bHexColor =
true;
589 OUStringBuffer sTmpBuffer(64);
594 bHexColor = sTmpBuffer.getLength()<7 &&
600 }
while( (rtl::isAsciiAlphanumeric(
m_cNextCh) ||
605 if( bHexColor && sTmpBuffer.getLength()==6 )
614 m_aToken.equalsIgnoreAsciiCase(
"url" )) ||
616 m_aToken.equalsIgnoreAsciiCase(
"rgb" )) ) )
619 OUStringBuffer sTmpBuffer2(64);
624 case '(': nNestCnt++;
break;
625 case ')': nNestCnt--;
break;
823 std::unique_ptr<CSS1Selector> pRoot;
836 bool bNextToken =
true;
925 OSL_ENSURE( (pRoot!=
nullptr) == (pLast!=
nullptr),
926 "Root-Selector, but no Last" );
936 if( bNextToken && !bDone )
992 std::unique_ptr<CSS1Expression> pRoot;
1074 OSL_ENSURE( (pRoot!=
nullptr) == (pLast!=
nullptr),
1075 "Root-Selector, but no Last" );
1106 : m_bWhiteSpace(false)
1124 OUString aTmp( rIn );
1127 while( !aTmp.isEmpty() &&
1128 (
' '==(c=aTmp[0]) ||
'\t'==c ||
'\r'==c ||
'\n'==c ) )
1129 aTmp = aTmp.copy( 1 );
1131 while( !aTmp.isEmpty() && (
' '==(c=aTmp[aTmp.getLength()-1])
1132 ||
'\t'==c ||
'\r'==c ||
'\n'==c ) )
1133 aTmp = aTmp.copy( 0, aTmp.getLength()-1 );
1136 if( aTmp.getLength() >= 4 &&
1137 aTmp.startsWith(
"<!--" ) )
1138 aTmp = aTmp.copy( 4 );
1140 if( aTmp.getLength() >=3 &&
1141 aTmp.endsWith(
"-->") )
1142 aTmp = aTmp.copy( 0, aTmp.getLength() - 3 );
1144 if( aTmp.isEmpty() )
1198 std::unique_ptr<CSS1Expression> )
1214 OSL_ENSURE(
CSS1_URL==
eType,
"CSS1-Expression is not URL" );
1216 OSL_ENSURE(
aValue.startsWithIgnoreAsciiCase(
"url" ) &&
1217 aValue.getLength() > 5 &&
1220 "no valid URL(...)" );
1222 if(
aValue.getLength() <= 5 )
1242 "CSS1-Expression cannot be colour" );
1253 if (!
aValue.startsWithIgnoreAsciiCase(
"rgb" ) ||
aValue.getLength() < 6 ||
1260 for (
int nCol = 0; nCol < 3 && nPos > 0; ++nCol )
1269 else if( aNumber.find(
'%') != std::u16string_view::npos )
1276 else if( nNumber > 255 )
1279 aColors[nCol] =
static_cast<sal_uInt8>(nNumber);
1282 rColor.
SetRed( aColors[0] );
1293 OUString aTmp(
aValue.toAsciiUpperCase() );
1305 bool bDouble =
aValue.getLength()-nOffset == 3;
1306 sal_Int32
i = nOffset, nEnd = (bDouble ? 3 : 6) + nOffset;
1309 for( ;
i<nEnd;
i++ )
1313 if( c >=
'0' && c <=
'9' )
1315 else if( c >=
'A' && c <=
'F' )
1317 else if( c >=
'a' && c <=
'f' )
1341 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 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)
#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