1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svgio/svgreader/svgstylenode.hxx>
21 #include <svgio/svgreader/svgdocument.hxx>
23 //////////////////////////////////////////////////////////////////////////////
29 SvgStyleNode::SvgStyleNode(
30 SvgDocument
& rDocument
,
32 : SvgNode(SVGTokenStyle
, rDocument
, pParent
),
33 maSvgStyleAttributes(),
38 SvgStyleNode::~SvgStyleNode()
40 while(!maSvgStyleAttributes
.empty())
42 delete *(maSvgStyleAttributes
.end() - 1);
43 maSvgStyleAttributes
.pop_back();
47 void SvgStyleNode::parseAttribute(const OUString
& rTokenName
, SVGToken aSVGToken
, const OUString
& aContent
)
50 SvgNode::parseAttribute(rTokenName
, aSVGToken
, aContent
);
57 if(aContent
.getLength())
59 static OUString
aStrTextCss(OUString::createFromAscii("text/css"));
61 if(aContent
.match(aStrTextCss
))
75 void SvgStyleNode::addCssStyleSheet(const OUString
& aContent
)
77 const sal_Int32
nLen(aContent
.getLength());
82 OUStringBuffer aTokenValue
;
86 const sal_Int32
nInitPos(nPos
);
87 skip_char(aContent
, sal_Unicode(' '), sal_Unicode('#'), nPos
, nLen
);
88 copyToLimiter(aContent
, sal_Unicode('{'), nPos
, aTokenValue
, nLen
);
89 const OUString aStyleName
= aTokenValue
.makeStringAndClear().trim();
91 if(aStyleName
.getLength() && nPos
< nLen
)
93 skip_char(aContent
, sal_Unicode(' '), sal_Unicode('{'), nPos
, nLen
);
94 copyToLimiter(aContent
, sal_Unicode('}'), nPos
, aTokenValue
, nLen
);
95 skip_char(aContent
, sal_Unicode(' '), sal_Unicode('}'), nPos
, nLen
);
96 const OUString aStyleContent
= aTokenValue
.makeStringAndClear().trim();
98 if(aStyleContent
.getLength())
101 SvgStyleAttributes
* pNewStyle
= new SvgStyleAttributes(*this);
102 maSvgStyleAttributes
.push_back(pNewStyle
);
105 pNewStyle
->readStyle(aStyleContent
);
107 // register new style at document
108 const_cast< SvgDocument
& >(getDocument()).addSvgStyleAttributesToMapper(aStyleName
, *pNewStyle
);
114 OSL_ENSURE(false, "Could not interpret on current position (!)");
121 } // end of namespace svgreader
122 } // end of namespace svgio
124 //////////////////////////////////////////////////////////////////////////////
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */