xref: /AOO41X/main/svgio/inc/svgio/svgreader/svgnode.hxx (revision b3ba8dd4bb7f270457be79b3e01a4e0e91f712b8)
1ddde725dSArmin Le Grand /**************************************************************
2ddde725dSArmin Le Grand  *
3ddde725dSArmin Le Grand  * Licensed to the Apache Software Foundation (ASF) under one
4ddde725dSArmin Le Grand  * or more contributor license agreements.  See the NOTICE file
5ddde725dSArmin Le Grand  * distributed with this work for additional information
6ddde725dSArmin Le Grand  * regarding copyright ownership.  The ASF licenses this file
7ddde725dSArmin Le Grand  * to you under the Apache License, Version 2.0 (the
8ddde725dSArmin Le Grand  * "License"); you may not use this file except in compliance
9ddde725dSArmin Le Grand  * with the License.  You may obtain a copy of the License at
10ddde725dSArmin Le Grand  *
11ddde725dSArmin Le Grand  *   http://www.apache.org/licenses/LICENSE-2.0
12ddde725dSArmin Le Grand  *
13ddde725dSArmin Le Grand  * Unless required by applicable law or agreed to in writing,
14ddde725dSArmin Le Grand  * software distributed under the License is distributed on an
15ddde725dSArmin Le Grand  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16ddde725dSArmin Le Grand  * KIND, either express or implied.  See the License for the
17ddde725dSArmin Le Grand  * specific language governing permissions and limitations
18ddde725dSArmin Le Grand  * under the License.
19ddde725dSArmin Le Grand  *
20ddde725dSArmin Le Grand  *************************************************************/
21ddde725dSArmin Le Grand 
22ddde725dSArmin Le Grand #ifndef INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX
23ddde725dSArmin Le Grand #define INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX
24ddde725dSArmin Le Grand 
25ddde725dSArmin Le Grand #include <svgio/svgiodllapi.h>
26ddde725dSArmin Le Grand #include <svgio/svgreader/svgtools.hxx>
27ddde725dSArmin Le Grand #include <svgio/svgreader/svgtoken.hxx>
28ddde725dSArmin Le Grand #include <svgio/svgreader/svgpaint.hxx>
29ddde725dSArmin Le Grand #include <basegfx/matrix/b2dhommatrix.hxx>
30ddde725dSArmin Le Grand #include <com/sun/star/xml/sax/XAttributeList.hpp>
31ddde725dSArmin Le Grand #include <vector>
32ddde725dSArmin Le Grand #include <hash_map>
33ddde725dSArmin Le Grand 
34ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
35ddde725dSArmin Le Grand // predefines
36ddde725dSArmin Le Grand namespace svgio
37ddde725dSArmin Le Grand {
38ddde725dSArmin Le Grand     namespace svgreader
39ddde725dSArmin Le Grand     {
40ddde725dSArmin Le Grand         class SvgNode;
41ddde725dSArmin Le Grand         class SvgDocument;
42ddde725dSArmin Le Grand         class SvgStyleAttributes;
43ddde725dSArmin Le Grand     }
44ddde725dSArmin Le Grand }
45ddde725dSArmin Le Grand 
46ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
47ddde725dSArmin Le Grand 
48ddde725dSArmin Le Grand namespace svgio
49ddde725dSArmin Le Grand {
50ddde725dSArmin Le Grand     namespace svgreader
51ddde725dSArmin Le Grand     {
52ddde725dSArmin Le Grand         typedef ::std::vector< SvgNode* > SvgNodeVector;
5350b37974SArmin Le Grand         typedef ::std::vector< const SvgStyleAttributes* > SvgStyleAttributeVector;
54ddde725dSArmin Le Grand 
55ddde725dSArmin Le Grand         enum XmlSpace
56ddde725dSArmin Le Grand         {
57ddde725dSArmin Le Grand             XmlSpace_notset,
58ddde725dSArmin Le Grand             XmlSpace_default,
59ddde725dSArmin Le Grand             XmlSpace_preserve
60ddde725dSArmin Le Grand         };
61ddde725dSArmin Le Grand 
62a275c134SArmin Le Grand         // display property (see SVG 1.1. 11.5), not inheritable
63a275c134SArmin Le Grand         enum Display // #121656#
64a275c134SArmin Le Grand         {
65a275c134SArmin Le Grand             Display_inline, // the default
66a275c134SArmin Le Grand             Display_block,
67a275c134SArmin Le Grand             Display_list_item,
68a275c134SArmin Le Grand             Display_run_in,
69a275c134SArmin Le Grand             Display_compact,
70a275c134SArmin Le Grand             Display_marker,
71a275c134SArmin Le Grand             Display_table,
72a275c134SArmin Le Grand             Display_inline_table,
73a275c134SArmin Le Grand             Display_table_row_group,
74a275c134SArmin Le Grand             Display_table_header_group,
75a275c134SArmin Le Grand             Display_table_footer_group,
76a275c134SArmin Le Grand             Display_table_row,
77a275c134SArmin Le Grand             Display_table_column_group,
78a275c134SArmin Le Grand             Display_table_column,
79a275c134SArmin Le Grand             Display_table_cell,
80a275c134SArmin Le Grand             Display_table_caption,
81a275c134SArmin Le Grand             Display_none,
82a275c134SArmin Le Grand             Display_inherit
83a275c134SArmin Le Grand         };
84a275c134SArmin Le Grand 
8501e92ad6SArmin Le Grand         // helper to convert a string associated with a token of type SVGTokenDisplay
8601e92ad6SArmin Le Grand         // to the enum Display. Empty trings return the default 'Display_inline' with
8701e92ad6SArmin Le Grand         // which members should be initialized
8801e92ad6SArmin Le Grand         Display getDisplayFromContent(const rtl::OUString& aContent);
8901e92ad6SArmin Le Grand 
90ddde725dSArmin Le Grand         class SvgNode : private boost::noncopyable, public InfoProvider
91ddde725dSArmin Le Grand         {
92ddde725dSArmin Le Grand         private:
93ddde725dSArmin Le Grand             /// basic data, Type, document we belong to and parent (if not root)
94ddde725dSArmin Le Grand             SVGToken                    maType;
95ddde725dSArmin Le Grand             SvgDocument&                mrDocument;
96ddde725dSArmin Le Grand             const SvgNode*              mpParent;
97ddde725dSArmin Le Grand             const SvgNode*              mpAlternativeParent;
98ddde725dSArmin Le Grand 
99ddde725dSArmin Le Grand             /// sub hierarchy
100ddde725dSArmin Le Grand             SvgNodeVector               maChildren;
101ddde725dSArmin Le Grand 
102ddde725dSArmin Le Grand             /// Id svan value
103ddde725dSArmin Le Grand             rtl::OUString*              mpId;
104ddde725dSArmin Le Grand 
105ddde725dSArmin Le Grand             /// Class svan value
106ddde725dSArmin Le Grand             rtl::OUString*              mpClass;
107ddde725dSArmin Le Grand 
108ddde725dSArmin Le Grand             /// XmlSpace value
109ddde725dSArmin Le Grand             XmlSpace                    maXmlSpace;
110ddde725dSArmin Le Grand 
111a275c134SArmin Le Grand             /// Display value #121656#
112a275c134SArmin Le Grand             Display                     maDisplay;
113a275c134SArmin Le Grand 
11450b37974SArmin Le Grand             /// CSS styles
11550b37974SArmin Le Grand             SvgStyleAttributeVector     maCssStyleVector;
11650b37974SArmin Le Grand 
11750b37974SArmin Le Grand         protected:
11850b37974SArmin Le Grand             /// helper to evtl. link to css style
11950b37974SArmin Le Grand             const SvgStyleAttributes* checkForCssStyle(const rtl::OUString& rClassStr, const SvgStyleAttributes& rOriginal) const;
12050b37974SArmin Le Grand 
121ddde725dSArmin Le Grand         public:
122ddde725dSArmin Le Grand             SvgNode(
123ddde725dSArmin Le Grand                 SVGToken aType,
124ddde725dSArmin Le Grand                 SvgDocument& rDocument,
125ddde725dSArmin Le Grand                 SvgNode* pParent);
126ddde725dSArmin Le Grand             virtual ~SvgNode();
127ddde725dSArmin Le Grand 
128ddde725dSArmin Le Grand             void parseAttributes(const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList >& xAttribs);
129ddde725dSArmin Le Grand             virtual const SvgStyleAttributes* getSvgStyleAttributes() const;
130ddde725dSArmin Le Grand             virtual void parseAttribute(const rtl::OUString& rTokenName, SVGToken aSVGToken, const rtl::OUString& aContent);
131ddde725dSArmin Le Grand             virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DSequence& rTarget, bool bReferenced) const;
132ddde725dSArmin Le Grand 
133*b3ba8dd4SArmin Le Grand             /// #125258# tell if this node is allowed to have a parent style (e.g. defs do not)
134*b3ba8dd4SArmin Le Grand             virtual bool supportsParentStyle() const;
135*b3ba8dd4SArmin Le Grand 
136ddde725dSArmin Le Grand             /// basic data read access
getType() const137e2bf1e9dSArmin Le Grand             SVGToken getType() const { return maType; }
getDocument() const138ddde725dSArmin Le Grand             const SvgDocument& getDocument() const { return mrDocument; }
getParent() const139ddde725dSArmin Le Grand             const SvgNode* getParent() const { if(mpAlternativeParent) return mpAlternativeParent; return mpParent; }
getChildren() const140ddde725dSArmin Le Grand             const SvgNodeVector& getChildren() const { return maChildren; }
141ddde725dSArmin Le Grand 
142ddde725dSArmin Le Grand             /// InfoProvider support for %, em and ex values
143e92bb418SOliver-Rainer Wittmann             virtual const basegfx::B2DRange getCurrentViewPort() const;
144ddde725dSArmin Le Grand             virtual double getCurrentFontSize() const;
145ddde725dSArmin Le Grand             virtual double getCurrentXHeight() const;
146ddde725dSArmin Le Grand 
147ddde725dSArmin Le Grand             /// Id access
getId() const148ddde725dSArmin Le Grand             const rtl::OUString* getId() const { return mpId; }
149ddde725dSArmin Le Grand             void setId(const rtl::OUString* pfId = 0);
150ddde725dSArmin Le Grand 
151ddde725dSArmin Le Grand             /// Class access
getClass() const152ddde725dSArmin Le Grand             const rtl::OUString* getClass() const { return mpClass; }
153ddde725dSArmin Le Grand             void setClass(const rtl::OUString* pfClass = 0);
154ddde725dSArmin Le Grand 
155ddde725dSArmin Le Grand             /// XmlSpace access
156ddde725dSArmin Le Grand             XmlSpace getXmlSpace() const;
setXmlSpace(XmlSpace eXmlSpace=XmlSpace_notset)157ddde725dSArmin Le Grand             void setXmlSpace(XmlSpace eXmlSpace = XmlSpace_notset) { maXmlSpace = eXmlSpace; }
158ddde725dSArmin Le Grand 
159a275c134SArmin Le Grand             /// Display access #121656#
getDisplay() const160a275c134SArmin Le Grand             Display getDisplay() const { return maDisplay; }
setDisplay(Display eDisplay=Display_inherit)161a275c134SArmin Le Grand             void setDisplay(Display eDisplay = Display_inherit) { maDisplay = eDisplay; }
162a275c134SArmin Le Grand 
163ddde725dSArmin Le Grand             /// alternative parent
setAlternativeParent(const SvgNode * pAlternativeParent=0)164ddde725dSArmin Le Grand             void setAlternativeParent(const SvgNode* pAlternativeParent = 0) { mpAlternativeParent = pAlternativeParent; }
165ddde725dSArmin Le Grand         };
166ddde725dSArmin Le Grand     } // end of namespace svgreader
167ddde725dSArmin Le Grand } // end of namespace svgio
168ddde725dSArmin Le Grand 
169ddde725dSArmin Le Grand //////////////////////////////////////////////////////////////////////////////
170ddde725dSArmin Le Grand 
171ddde725dSArmin Le Grand #endif //INCLUDED_SVGIO_SVGREADER_SVGNODE_HXX
172ddde725dSArmin Le Grand 
173ddde725dSArmin Le Grand // eof
174