svgtools.cxx (e92bb418) svgtools.cxx (52cb04b8)
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 632 unchanged lines hidden (view full) ---

641 }
642 else
643 {
644 // error
645 return 0;
646 }
647 }
648
1/**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance

--- 632 unchanged lines hidden (view full) ---

641 }
642 else
643 {
644 // error
645 return 0;
646 }
647 }
648
649 bool match_colorKeyword(basegfx::BColor& rColor, const rtl::OUString& rName)
649 bool match_colorKeyword(
650 basegfx::BColor& rColor,
651 const rtl::OUString& rName,
652 bool bCaseIndependent)
650 {
651 typedef std::hash_map< rtl::OUString, Color, rtl::OUStringHash > ColorTokenMapper;
652 typedef std::pair< rtl::OUString, Color > ColorTokenValueType;
653 ColorTokenMapper aColorTokenMapperList;
654
655 if(aColorTokenMapperList.empty())
656 {
657 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("aliceblue"), Color(240, 248, 255)));

--- 140 unchanged lines hidden (view full) ---

798 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("violet"), Color(238, 130, 238)));
799 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("wheat"), Color(245, 222, 179)));
800 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("white"), Color(255, 255, 255)));
801 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("whitesmoke"), Color(245, 245, 245)));
802 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("yellow"), Color(255, 255, 0)));
803 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("yellowgreen"), Color(154, 205, 50)));
804 }
805
653 {
654 typedef std::hash_map< rtl::OUString, Color, rtl::OUStringHash > ColorTokenMapper;
655 typedef std::pair< rtl::OUString, Color > ColorTokenValueType;
656 ColorTokenMapper aColorTokenMapperList;
657
658 if(aColorTokenMapperList.empty())
659 {
660 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("aliceblue"), Color(240, 248, 255)));

--- 140 unchanged lines hidden (view full) ---

801 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("violet"), Color(238, 130, 238)));
802 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("wheat"), Color(245, 222, 179)));
803 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("white"), Color(255, 255, 255)));
804 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("whitesmoke"), Color(245, 245, 245)));
805 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("yellow"), Color(255, 255, 0)));
806 aColorTokenMapperList.insert(ColorTokenValueType(rtl::OUString::createFromAscii("yellowgreen"), Color(154, 205, 50)));
807 }
808
806 const ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName));
809 ColorTokenMapper::const_iterator aResult(aColorTokenMapperList.find(rName));
807
810
811 if(bCaseIndependent && aResult == aColorTokenMapperList.end())
812 {
813 // also try case independent match (e.g. for Css styles)
814 aResult = aColorTokenMapperList.find(rName.toAsciiLowerCase());
815 }
816
808 if(aResult == aColorTokenMapperList.end())
809 {
810 return false;
811 }
812 else
813 {
814 rColor = aResult->second.getBColor();
815 return true;
816 }
817 }
818
817 if(aResult == aColorTokenMapperList.end())
818 {
819 return false;
820 }
821 else
822 {
823 rColor = aResult->second.getBColor();
824 return true;
825 }
826 }
827
819 bool read_color(const rtl::OUString& rCandidate, basegfx::BColor& rColor)
828 bool read_color(
829 const rtl::OUString& rCandidate,
830 basegfx::BColor& rColor,
831 bool bCaseIndependent)
820 {
821 const sal_Int32 nLen(rCandidate.getLength());
822
823 if(nLen)
824 {
825 const sal_Unicode aChar(rCandidate[0]);
826 const double fFactor(1.0 / 255.0);
827

--- 91 unchanged lines hidden (view full) ---

919 }
920 }
921 }
922 }
923 }
924 else
925 {
926 // color keyword
832 {
833 const sal_Int32 nLen(rCandidate.getLength());
834
835 if(nLen)
836 {
837 const sal_Unicode aChar(rCandidate[0]);
838 const double fFactor(1.0 / 255.0);
839

--- 91 unchanged lines hidden (view full) ---

931 }
932 }
933 }
934 }
935 }
936 else
937 {
938 // color keyword
927 if(match_colorKeyword(rColor, rCandidate))
939 if(match_colorKeyword(rColor, rCandidate, bCaseIndependent))
928 {
929 return true;
930 }
931 }
932 }
933 }
934
935 return false;

--- 268 unchanged lines hidden (view full) ---

1204 rURL = aTokenValue.makeStringAndClear();
1205
1206 return true;
1207 }
1208
1209 return false;
1210 }
1211
940 {
941 return true;
942 }
943 }
944 }
945 }
946
947 return false;

--- 268 unchanged lines hidden (view full) ---

1216 rURL = aTokenValue.makeStringAndClear();
1217
1218 return true;
1219 }
1220
1221 return false;
1222 }
1223
1212 bool readSvgPaint(const rtl::OUString& rCandidate, SvgPaint& rSvgPaint, rtl::OUString& rURL)
1224 bool readSvgPaint(
1225 const rtl::OUString& rCandidate,
1226 SvgPaint& rSvgPaint,
1227 rtl::OUString& rURL,
1228 bool bCaseIndependent)
1213 {
1214 const sal_Int32 nLen(rCandidate.getLength());
1215
1216 if(nLen)
1217 {
1218 basegfx::BColor aColor;
1219
1229 {
1230 const sal_Int32 nLen(rCandidate.getLength());
1231
1232 if(nLen)
1233 {
1234 basegfx::BColor aColor;
1235
1220 if(read_color(rCandidate, aColor))
1236 if(read_color(rCandidate, aColor, bCaseIndependent))
1221 {
1222 rSvgPaint = SvgPaint(aColor, true, true);
1223 return true;
1224 }
1225 else
1226 {
1227 static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
1228 static rtl::OUString aStrCurrentColor(rtl::OUString::createFromAscii("currentColor"));

--- 58 unchanged lines hidden (view full) ---

1287 {
1288 const sal_Int32 nInitPos(nPos);
1289 skip_char(rCandidate, sal_Unicode(' '), nPos, nLen);
1290 rtl::OUStringBuffer aTokenName;
1291 copyString(rCandidate, nPos, aTokenName, nLen);
1292
1293 if(aTokenName.getLength())
1294 {
1237 {
1238 rSvgPaint = SvgPaint(aColor, true, true);
1239 return true;
1240 }
1241 else
1242 {
1243 static rtl::OUString aStrNone(rtl::OUString::createFromAscii("none"));
1244 static rtl::OUString aStrCurrentColor(rtl::OUString::createFromAscii("currentColor"));

--- 58 unchanged lines hidden (view full) ---

1303 {
1304 const sal_Int32 nInitPos(nPos);
1305 skip_char(rCandidate, sal_Unicode(' '), nPos, nLen);
1306 rtl::OUStringBuffer aTokenName;
1307 copyString(rCandidate, nPos, aTokenName, nLen);
1308
1309 if(aTokenName.getLength())
1310 {
1295 switch(StrToSVGToken(aTokenName.makeStringAndClear()))
1311 switch(StrToSVGToken(aTokenName.makeStringAndClear(), false))
1296 {
1297 case SVGTokenDefer:
1298 {
1299 bDefer = true;
1300 bChanged = true;
1301 break;
1302 }
1303 case SVGTokenNone:

--- 327 unchanged lines hidden ---
1312 {
1313 case SVGTokenDefer:
1314 {
1315 bDefer = true;
1316 bChanged = true;
1317 break;
1318 }
1319 case SVGTokenNone:

--- 327 unchanged lines hidden ---