/* -*- 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 . */ #include #include #include namespace svgio::svgreader { void SvgPatternNode::tryToFindLink() { if(!mpXLink && !maXLink.isEmpty()) { mpXLink = dynamic_cast< const SvgPatternNode* >(getDocument().findSvgNodeById(maXLink)); } } SvgPatternNode::SvgPatternNode( SvgDocument& rDocument, SvgNode* pParent) : SvgNode(SVGToken::Pattern, rDocument, pParent), maSvgStyleAttributes(*this), mbResolvingLink(false), mpXLink(nullptr) { } SvgPatternNode::~SvgPatternNode() { } const SvgStyleAttributes* SvgPatternNode::getSvgStyleAttributes() const { return checkForCssStyle(maSvgStyleAttributes); } void SvgPatternNode::parseAttribute(SVGToken aSVGToken, const OUString& aContent) { // call parent SvgNode::parseAttribute(aSVGToken, aContent); // read style attributes maSvgStyleAttributes.parseStyleAttribute(aSVGToken, aContent); // parse own switch(aSVGToken) { case SVGToken::Style: { readLocalCssStyle(aContent); break; } case SVGToken::ViewBox: { const basegfx::B2DRange aRange(readViewBox(aContent, *this)); if(!aRange.isEmpty()) { setViewBox(&aRange); } break; } case SVGToken::PreserveAspectRatio: { maSvgAspectRatio = readSvgAspectRatio(aContent); break; } case SVGToken::X: { SvgNumber aNum; if(readSingleNumber(aContent, aNum)) { maX = aNum; } break; } case SVGToken::Y: { SvgNumber aNum; if(readSingleNumber(aContent, aNum)) { maY = aNum; } break; } case SVGToken::Width: { SvgNumber aNum; if(readSingleNumber(aContent, aNum)) { if(aNum.isPositive()) { maWidth = aNum; } } break; } case SVGToken::Height: { SvgNumber aNum; if(readSingleNumber(aContent, aNum)) { if(aNum.isPositive()) { maHeight = aNum; } } break; } case SVGToken::PatternUnits: { if(!aContent.isEmpty()) { if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), commonStrings::aStrUserSpaceOnUse)) { setPatternUnits(SvgUnits::userSpaceOnUse); } else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), commonStrings::aStrObjectBoundingBox)) { setPatternUnits(SvgUnits::objectBoundingBox); } } break; } case SVGToken::PatternContentUnits: { if(!aContent.isEmpty()) { if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), commonStrings::aStrUserSpaceOnUse)) { setPatternContentUnits(SvgUnits::userSpaceOnUse); } else if(o3tl::equalsIgnoreAsciiCase(o3tl::trim(aContent), commonStrings::aStrObjectBoundingBox)) { setPatternContentUnits(SvgUnits::objectBoundingBox); } } break; } case SVGToken::PatternTransform: { const basegfx::B2DHomMatrix aMatrix(readTransform(aContent, *this)); if(!aMatrix.isIdentity()) { setPatternTransform(aMatrix); } break; } case SVGToken::Href: case SVGToken::XlinkHref: { readLocalLink(aContent, maXLink); tryToFindLink(); break; } default: { break; } } } void SvgPatternNode::getValuesRelative(double& rfX, double& rfY, double& rfW, double& rfH, const basegfx::B2DRange& rGeoRange, SvgNode const & rUser) const { double fTargetWidth(rGeoRange.getWidth()); double fTargetHeight(rGeoRange.getHeight()); if(fTargetWidth <= 0.0 || fTargetHeight <= 0.0) return; const SvgUnits aPatternUnits(getPatternUnits() ? *getPatternUnits() : SvgUnits::objectBoundingBox); if (SvgUnits::objectBoundingBox == aPatternUnits) { rfW = (getWidth().isSet()) ? getWidth().getNumber() : 0.0; rfH = (getHeight().isSet()) ? getHeight().getNumber() : 0.0; if(SvgUnit::percent == getWidth().getUnit()) { rfW *= 0.01; } if(SvgUnit::percent == getHeight().getUnit()) { rfH *= 0.01; } } else { rfW = (getWidth().isSet()) ? getWidth().solve(rUser, NumberType::xcoordinate) : 0.0; rfH = (getHeight().isSet()) ? getHeight().solve(rUser, NumberType::ycoordinate) : 0.0; // make relative to rGeoRange rfW /= fTargetWidth; rfH /= fTargetHeight; } if(rfW <= 0.0 || rfH <= 0.0) return; if (SvgUnits::objectBoundingBox == aPatternUnits) { rfX = (getX().isSet()) ? getX().getNumber() : 0.0; rfY = (getY().isSet()) ? getY().getNumber() : 0.0; if(SvgUnit::percent == getX().getUnit()) { rfX *= 0.01; } if(SvgUnit::percent == getY().getUnit()) { rfY *= 0.01; } } else { rfX = (getX().isSet()) ? getX().solve(rUser, NumberType::xcoordinate) : 0.0; rfY = (getY().isSet()) ? getY().solve(rUser, NumberType::ycoordinate) : 0.0; // make relative to rGeoRange rfX = (rfX - rGeoRange.getMinX()) / fTargetWidth; rfY = (rfY - rGeoRange.getMinY()) / fTargetHeight; } } const drawinglayer::primitive2d::Primitive2DContainer& SvgPatternNode::getPatternPrimitives() const { if(aPrimitives.empty() && Display::None != getDisplay()) { decomposeSvgNode(const_cast< SvgPatternNode* >(this)->aPrimitives, true); } if(aPrimitives.empty() && !maXLink.isEmpty()) { const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const drawinglayer::primitive2d::Primitive2DContainer& ret = mpXLink->getPatternPrimitives(); mbResolvingLink = false; return ret; } } return aPrimitives; } basegfx::B2DRange SvgPatternNode::getCurrentViewPort() const { if(getViewBox()) { return *(getViewBox()); } else { return SvgNode::getCurrentViewPort(); } } const basegfx::B2DRange* SvgPatternNode::getViewBox() const { if(mpViewBox) { return mpViewBox.get(); } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; auto ret = mpXLink->getViewBox(); mbResolvingLink = false; return ret; } return nullptr; } const SvgAspectRatio& SvgPatternNode::getSvgAspectRatio() const { if(maSvgAspectRatio.isSet()) { return maSvgAspectRatio; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const SvgAspectRatio& ret = mpXLink->getSvgAspectRatio(); mbResolvingLink = false; return ret; } return maSvgAspectRatio; } const SvgNumber& SvgPatternNode::getX() const { if(maX.isSet()) { return maX; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const SvgNumber& ret = mpXLink->getX(); mbResolvingLink = false; return ret; } return maX; } const SvgNumber& SvgPatternNode::getY() const { if(maY.isSet()) { return maY; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const SvgNumber& ret = mpXLink->getY(); mbResolvingLink = false; return ret; } return maY; } const SvgNumber& SvgPatternNode::getWidth() const { if(maWidth.isSet()) { return maWidth; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const SvgNumber& ret = mpXLink->getWidth(); mbResolvingLink = false; return ret; } return maWidth; } const SvgNumber& SvgPatternNode::getHeight() const { if(maHeight.isSet()) { return maHeight; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; const SvgNumber& ret = mpXLink->getHeight(); mbResolvingLink = false; return ret; } return maHeight; } const SvgUnits* SvgPatternNode::getPatternUnits() const { if(moPatternUnits) { return &*moPatternUnits; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; auto ret = mpXLink->getPatternUnits(); mbResolvingLink = false; return ret; } return nullptr; } const SvgUnits* SvgPatternNode::getPatternContentUnits() const { if(moPatternContentUnits) { return &*moPatternContentUnits; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; auto ret = mpXLink->getPatternContentUnits(); mbResolvingLink = false; return ret; } return nullptr; } std::optional SvgPatternNode::getPatternTransform() const { if(mpaPatternTransform) { return mpaPatternTransform; } const_cast< SvgPatternNode* >(this)->tryToFindLink(); if (mpXLink && !mbResolvingLink) { mbResolvingLink = true; auto ret = mpXLink->getPatternTransform(); mbResolvingLink = false; return ret; } return std::nullopt; } } // end of namespace svgio::svgreader /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ ct57e LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
path: root/sysui
AgeCommit message (Expand)Author
2018-06-25update app icns iconsandreas kainz
2018-06-17fix packaging break after bindir handling & new iconsChristian Lohmaier
2018-06-13Respect --bindir..orbea
2018-06-12app icons: update locolor iconsandreas kainz
2018-06-11app icon update ico png and svg support finishedandreas kainz
2018-06-09App icons: add 22,24,64px size app and mimetype LibO iconsandreas kainz
2018-06-06App and Mimetype update to new flat designandreas kainz
2018-06-04update writer app ico fileandreas kainz
2018-06-02Removed executable permission on data filesAndrea Gelmini
2018-06-01Mimetype icon update for apps and impressandreas kainz
2018-05-31Mimetype icon update writer and calcandreas kainz
2018-05-24revert accidentially committed partRene Engelhard
2018-05-24apparmor: allow also /usr/lib{,32,64}/jvm/**/bin/javaRene Engelhard
2018-05-23deb#899380 apparmor: fix gpg encryption hang trying to lock random_seedRene Engelhard
2018-05-23remove Linux ("UNX") systray "Quickstarter"Rene Engelhard
2018-05-04Removed executable permission on data fileAndrea Gelmini
2018-04-15use the standard name pattern for a packageDavid Tardon
2018-03-01tdf#116086 Apparmor profiles fixes for xslm file extensionOlivier Tilloy
2018-02-19apparmor: allow cert9.dbRene Engelhard
2018-02-18tdf#115554: Fix ownership in desktop-integration tarsMichael Weghorn
2018-02-18tdf#115554: Use 'fakeroot' to build Debian packagesMichael Weghorn
2018-02-14initial apparmor stuff for lo_kde5filepickerRene Engelhard
2018-02-14tdf#115659 Apparmor profile fixes for senddocOlivier Tilloy
2018-02-06state that you're doing the re-revert because the previous revert was by acci...andreas_kainz
2018-02-02Revert "tdf#98141 add svg file for all app icons in all sizes"andreas_kainz
2018-02-01apparmor: fix @{HOME}/.mozilla/firefox access for XML signingRene Engelhard
2018-02-01Pass also webdavs:// URLs directly to soffice binaryKatarina Behrens
2018-01-28tdf#115208 Apparmor profile update (allow JVM execution)Olivier Tilloy
2018-01-21deb#887593 apparmor: allow reading device informationVincas Dargis
2018-01-21remove accidentially committed flags=(complain)Rene Engelhard
2018-01-21apparmor: allow running the "certificate manager" applications for gpgRene Engelhard
2018-01-20readd lost commentRene Engelhard
2018-01-20deb#887593 make gpg child profile really workRene Engelhard
2018-01-20deb#887593 use child profile for gpgRene Engelhard
2018-01-18update copyright yearsRene Engelhard
2018-01-18deb#887593 apparmor: allow soffice.bin reading .mozilla/firefox and .gnupgRene Engelhard
2018-01-18deb#887593 add gpg and gpgsm to soffice.bin apparmor profileRene Engelhard
2018-01-18deb#887593 add #include <abstractions/X> to oosplash apparmor profileRene Engelhard
2018-01-18Resolves: rhbz#1535541 fdo#88004 mimetypes are .macroEnabled not .macroenabledCaolán McNamara
2018-01-13tdf#114915 Apparmor profile update (invalid comments syntax)Olivier Tilloy
2018-01-05Include new .svg icons in freedesktop-menus.specStephan Bergmann
2018-01-04tdf#98141 add svg file for all app icons in all sizesandreas kainz
2017-12-31App icons: shrink svg files to a minimumandreas kainz
2017-12-11copyrightRene Engelhard
2017-12-11apparmor: copy xpdfimport definition into xpdfimport and allow "m"Rene Engelhard
2017-12-11revert accidentially committed local changeRene Engelhard
2017-12-11sysui/desktop/apparmor/program.soffice.bin: allow /usr/bin/gpgconfRene Engelhard
2017-12-11also allow /usr/bin/dash (etc.) for merged-/usr-scenarioRene Engelhard