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
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24 #include <tools/debug.hxx>
25 #include "XMLTextPropertySetContext.hxx"
26 #include "XMLTextColumnsContext.hxx"
27 #include "XMLBackgroundImageContext.hxx"
28 #include "XMLSectionFootnoteConfigImport.hxx"
29
30 #ifndef _XMLOFF_TXTPRMAP_HXX
31 #include <xmloff/txtprmap.hxx>
32 #endif
33 #include "xmltabi.hxx"
34 #ifndef _XMLOFF_TXTDROPI_HXX
35 #include "txtdropi.hxx"
36 #endif
37
38 using ::rtl::OUString;
39
40 using namespace ::com::sun::star::uno;
41 using namespace ::com::sun::star;
42
XMLTextPropertySetContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<xml::sax::XAttributeList> & xAttrList,sal_uInt32 nFamily,::std::vector<XMLPropertyState> & rProps,const UniReference<SvXMLImportPropertyMapper> & rMap,OUString & rDCTextStyleName)43 XMLTextPropertySetContext::XMLTextPropertySetContext(
44 SvXMLImport& rImport, sal_uInt16 nPrfx,
45 const OUString& rLName,
46 const Reference< xml::sax::XAttributeList > & xAttrList,
47 sal_uInt32 nFamily,
48 ::std::vector< XMLPropertyState > &rProps,
49 const UniReference < SvXMLImportPropertyMapper > &rMap,
50 OUString& rDCTextStyleName ) :
51 SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
52 rProps, rMap ),
53 rDropCapTextStyleName( rDCTextStyleName )
54 {
55 }
56
~XMLTextPropertySetContext()57 XMLTextPropertySetContext::~XMLTextPropertySetContext()
58 {
59 }
60
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<xml::sax::XAttributeList> & xAttrList,::std::vector<XMLPropertyState> & rProperties,const XMLPropertyState & rProp)61 SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
62 sal_uInt16 nPrefix,
63 const OUString& rLocalName,
64 const Reference< xml::sax::XAttributeList > & xAttrList,
65 ::std::vector< XMLPropertyState > &rProperties,
66 const XMLPropertyState& rProp )
67 {
68 SvXMLImportContext *pContext = 0;
69
70 switch( mxMapper->getPropertySetMapper()
71 ->GetEntryContextId( rProp.mnIndex ) )
72 {
73 case CTF_TABSTOP:
74 pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
75 rLocalName, rProp,
76 rProperties );
77 break;
78 case CTF_TEXTCOLUMNS:
79 #ifndef SVX_LIGHT
80 pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
81 rLocalName, xAttrList, rProp,
82 rProperties );
83 #else
84 // create default context to skip content
85 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
86 #endif // #ifndef SVX_LIGHT
87 break;
88
89 case CTF_DROPCAPFORMAT:
90 {
91 DBG_ASSERT( rProp.mnIndex >= 2 &&
92 CTF_DROPCAPWHOLEWORD == mxMapper->getPropertySetMapper()
93 ->GetEntryContextId( rProp.mnIndex-2 ),
94 "invalid property map!");
95 XMLTextDropCapImportContext *pDCContext =
96 new XMLTextDropCapImportContext( GetImport(), nPrefix,
97 rLocalName, xAttrList,
98 rProp,
99 rProp.mnIndex-2,
100 rProperties );
101 rDropCapTextStyleName = pDCContext->GetStyleName();
102 pContext = pDCContext;
103 }
104 break;
105
106 case CTF_BACKGROUND_URL:
107 {
108 DBG_ASSERT( rProp.mnIndex >= 2 &&
109 CTF_BACKGROUND_POS == mxMapper->getPropertySetMapper()
110 ->GetEntryContextId( rProp.mnIndex-2 ) &&
111 CTF_BACKGROUND_FILTER == mxMapper->getPropertySetMapper()
112 ->GetEntryContextId( rProp.mnIndex-1 ),
113 "invalid property map!");
114
115 // #99657# Transparency might be there as well... but doesn't have
116 // to. Thus, this is checked with an if, rather than with an assertion.
117 sal_Int32 nTranspIndex = -1;
118 if( (rProp.mnIndex >= 3) &&
119 ( CTF_BACKGROUND_TRANSPARENCY ==
120 mxMapper->getPropertySetMapper()->GetEntryContextId(
121 rProp.mnIndex-3 ) ) )
122 nTranspIndex = rProp.mnIndex-3;
123
124 pContext =
125 new XMLBackgroundImageContext( GetImport(), nPrefix,
126 rLocalName, xAttrList,
127 rProp,
128 rProp.mnIndex-2,
129 rProp.mnIndex-1,
130 nTranspIndex,
131 rProperties );
132 }
133 break;
134 #ifndef SVX_LIGHT
135 case CTF_SECTION_FOOTNOTE_END:
136 case CTF_SECTION_ENDNOTE_END:
137 pContext = new XMLSectionFootnoteConfigImport(
138 GetImport(), nPrefix, rLocalName, rProperties,
139 mxMapper->getPropertySetMapper());
140 break;
141 #endif // #ifndef SVX_LIGHT
142 }
143
144 if( !pContext )
145 pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
146 xAttrList,
147 rProperties, rProp );
148
149 return pContext;
150 }
151
152 /* vim: set noet sw=4 ts=4: */
153