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