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 10999 : 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 rtl::Reference < SvXMLImportPropertyMapper > &rMap,
41 : OUString& rDCTextStyleName ) :
42 : SvXMLPropertySetContext( rImport, nPrfx, rLName, xAttrList, nFamily,
43 : rProps, rMap ),
44 10999 : rDropCapTextStyleName( rDCTextStyleName )
45 : {
46 10999 : }
47 :
48 21998 : XMLTextPropertySetContext::~XMLTextPropertySetContext()
49 : {
50 21998 : }
51 :
52 707 : 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 707 : SvXMLImportContext *pContext = 0;
60 :
61 1414 : switch( mxMapper->getPropertySetMapper()
62 1414 : ->GetEntryContextId( rProp.mnIndex ) )
63 : {
64 : case CTF_TABSTOP:
65 577 : pContext = new SvxXMLTabStopImportContext( GetImport(), nPrefix,
66 : rLocalName, rProp,
67 577 : rProperties );
68 577 : break;
69 : case CTF_TEXTCOLUMNS:
70 39 : pContext = new XMLTextColumnsContext( GetImport(), nPrefix,
71 : rLocalName, xAttrList, rProp,
72 39 : rProperties );
73 39 : 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 11 : new XMLTextDropCapImportContext( GetImport(), nPrefix,
83 : rLocalName, xAttrList,
84 : rProp,
85 : rProp.mnIndex-2,
86 11 : rProperties );
87 11 : rDropCapTextStyleName = pDCContext->GetStyleName();
88 11 : pContext = pDCContext;
89 : }
90 11 : 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 76 : sal_Int32 nTranspIndex = -1;
104 152 : if( (rProp.mnIndex >= 3) &&
105 : ( CTF_BACKGROUND_TRANSPARENCY ==
106 76 : mxMapper->getPropertySetMapper()->GetEntryContextId(
107 152 : rProp.mnIndex-3 ) ) )
108 0 : nTranspIndex = rProp.mnIndex-3;
109 :
110 : pContext =
111 76 : new XMLBackgroundImageContext( GetImport(), nPrefix,
112 : rLocalName, xAttrList,
113 : rProp,
114 : rProp.mnIndex-2,
115 : rProp.mnIndex-1,
116 : nTranspIndex,
117 76 : rProperties );
118 : }
119 76 : break;
120 : case CTF_SECTION_FOOTNOTE_END:
121 : case CTF_SECTION_ENDNOTE_END:
122 : pContext = new XMLSectionFootnoteConfigImport(
123 4 : GetImport(), nPrefix, rLocalName, rProperties,
124 4 : mxMapper->getPropertySetMapper());
125 4 : break;
126 : }
127 :
128 707 : if( !pContext )
129 : pContext = SvXMLPropertySetContext::CreateChildContext( nPrefix, rLocalName,
130 : xAttrList,
131 0 : rProperties, rProp );
132 :
133 707 : return pContext;
134 : }
135 :
136 :
137 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|