Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #include <tools/debug.hxx>
21 : #include "XMLTextPropertySetContext.hxx"
22 : #include "XMLTextColumnsContext.hxx"
23 : #include "XMLBackgroundImageContext.hxx"
24 : #include "XMLSectionFootnoteConfigImport.hxx"
25 :
26 : #include <xmloff/txtprmap.hxx>
27 : #include "xmltabi.hxx"
28 : #include "txtdropi.hxx"
29 :
30 :
31 : using namespace ::com::sun::star::uno;
32 : using namespace ::com::sun::star;
33 :
34 0 : XMLTextPropertySetContext::XMLTextPropertySetContext(
35 : SvXMLImport& rImport, sal_uInt16 nPrfx,
36 : const OUString& rLName,
37 : const Reference< xml::sax::XAttributeList > & xAttrList,
38 : sal_uInt32 nFamily,
39 : ::std::vector< XMLPropertyState > &rProps,
40 : const UniReference < SvXMLImportPropertyMapper > &rMap,
41 : OUString& rDCTextStyleName ) :
42 : SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
43 : rProps, rMap ),
44 0 : rDropCapTextStyleName( rDCTextStyleName )
45 : {
46 0 : }
47 :
48 0 : XMLTextPropertySetContext::~XMLTextPropertySetContext()
49 : {
50 0 : }
51 :
52 0 : SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
53 : sal_uInt16 nPrefix,
54 : const OUString& rLocalName,
55 : const Reference< xml::sax::XAttributeList > & xAttrList,
56 : ::std::vector< XMLPropertyState > &rProperties,
57 : const XMLPropertyState& rProp )
58 : {
59 0 : SvXMLImportContext *pContext = 0;
60 :
61 0 : switch( mxMapper->getPropertySetMapper()
62 0 : ->GetEntryContextId( rProp.mnIndex ) )
63 : {
64 : case CTF_TABSTOP:
65 0 : pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
66 : rLocalName, rProp,
67 0 : rProperties );
68 0 : break;
69 : case CTF_TEXTCOLUMNS:
70 0 : pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
71 : rLocalName, xAttrList, rProp,
72 0 : rProperties );
73 0 : break;
74 :
75 : case CTF_DROPCAPFORMAT:
76 : {
77 : DBG_ASSERT( rProp.mnIndex >= 2 &&
78 : CTF_DROPCAPWHOLEWORD == mxMapper->getPropertySetMapper()
79 : ->GetEntryContextId( rProp.mnIndex-2 ),
80 : "invalid property map!");
81 : XMLTextDropCapImportContext *pDCContext =
82 0 : new XMLTextDropCapImportContext( GetImport(), nPrefix,
83 : rLocalName, xAttrList,
84 : rProp,
85 : rProp.mnIndex-2,
86 0 : rProperties );
87 0 : rDropCapTextStyleName = pDCContext->GetStyleName();
88 0 : pContext = pDCContext;
89 : }
90 0 : break;
91 :
92 : case CTF_BACKGROUND_URL:
93 : {
94 : DBG_ASSERT( rProp.mnIndex >= 2 &&
95 : CTF_BACKGROUND_POS == mxMapper->getPropertySetMapper()
96 : ->GetEntryContextId( rProp.mnIndex-2 ) &&
97 : CTF_BACKGROUND_FILTER == mxMapper->getPropertySetMapper()
98 : ->GetEntryContextId( rProp.mnIndex-1 ),
99 : "invalid property map!");
100 :
101 : // #99657# Transparency might be there as well... but doesn't have
102 : // to. Thus, this is checked with an if, rather than with an assertion.
103 0 : sal_Int32 nTranspIndex = -1;
104 0 : if( (rProp.mnIndex >= 3) &&
105 : ( CTF_BACKGROUND_TRANSPARENCY ==
106 0 : mxMapper->getPropertySetMapper()->GetEntryContextId(
107 0 : rProp.mnIndex-3 ) ) )
108 0 : nTranspIndex = rProp.mnIndex-3;
109 :
110 : pContext =
111 0 : new XMLBackgroundImageContext( GetImport(), nPrefix,
112 : rLocalName, xAttrList,
113 : rProp,
114 : rProp.mnIndex-2,
115 : rProp.mnIndex-1,
116 : nTranspIndex,
117 0 : rProperties );
118 : }
119 0 : break;
120 : case CTF_SECTION_FOOTNOTE_END:
121 : case CTF_SECTION_ENDNOTE_END:
122 : pContext = new XMLSectionFootnoteConfigImport(
123 0 : GetImport(), nPrefix, rLocalName, rProperties,
124 0 : mxMapper->getPropertySetMapper());
125 0 : break;
126 : }
127 :
128 0 : if( !pContext )
129 : pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
130 : xAttrList,
131 0 : rProperties, rProp );
132 :
133 0 : return pContext;
134 : }
135 :
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|