Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include "XMLIndexUserSourceContext.hxx"
30 : : #include <com/sun/star/beans/XPropertySet.hpp>
31 : : #include <com/sun/star/container/XIndexReplace.hpp>
32 : : #include <sax/tools/converter.hxx>
33 : : #include "XMLIndexTemplateContext.hxx"
34 : : #include "XMLIndexTitleTemplateContext.hxx"
35 : : #include "XMLIndexTOCStylesContext.hxx"
36 : : #include <xmloff/xmlictxt.hxx>
37 : : #include <xmloff/xmlimp.hxx>
38 : : #include <xmloff/txtimp.hxx>
39 : : #include "xmloff/xmlnmspe.hxx"
40 : : #include <xmloff/nmspmap.hxx>
41 : : #include <xmloff/xmltoken.hxx>
42 : : #include <rtl/ustring.hxx>
43 : :
44 : :
45 : : using ::rtl::OUString;
46 : : using ::com::sun::star::beans::XPropertySet;
47 : : using ::com::sun::star::uno::Reference;
48 : : using ::com::sun::star::uno::Any;
49 : : using ::com::sun::star::xml::sax::XAttributeList;
50 : : using ::xmloff::token::IsXMLToken;
51 : : using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE;
52 : : using ::xmloff::token::XML_OUTLINE_LEVEL;
53 : :
54 : :
55 : : const sal_Char sAPI_CreateFromEmbeddedObjects[] = "CreateFromEmbeddedObjects";
56 : : const sal_Char sAPI_CreateFromGraphicObjects[] = "CreateFromGraphicObjects";
57 : : const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
58 : : const sal_Char sAPI_CreateFromTables[] = "CreateFromTables";
59 : : const sal_Char sAPI_CreateFromTextFrames[] = "CreateFromTextFrames";
60 : : const sal_Char sAPI_UseLevelFromSource[] = "UseLevelFromSource";
61 : : const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles";
62 : : const sal_Char sAPI_UserIndexName[] = "UserIndexName";
63 : :
64 : :
65 [ # # ][ # # ]: 0 : TYPEINIT1(XMLIndexUserSourceContext, XMLIndexSourceBaseContext);
66 : :
67 : :
68 : 4 : XMLIndexUserSourceContext::XMLIndexUserSourceContext(
69 : : SvXMLImport& rImport,
70 : : sal_uInt16 nPrfx,
71 : : const OUString& rLocalName,
72 : : Reference<XPropertySet> & rPropSet) :
73 : : XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
74 : : rPropSet, sal_True),
75 : : sCreateFromEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM(
76 : : sAPI_CreateFromEmbeddedObjects)),
77 : : sCreateFromGraphicObjects(RTL_CONSTASCII_USTRINGPARAM(
78 : : sAPI_CreateFromGraphicObjects)),
79 : : sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks)),
80 : : sCreateFromTables(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromTables)),
81 : : sCreateFromTextFrames(RTL_CONSTASCII_USTRINGPARAM(
82 : : sAPI_CreateFromTextFrames)),
83 : : sUseLevelFromSource(RTL_CONSTASCII_USTRINGPARAM(
84 : : sAPI_UseLevelFromSource)),
85 : : sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM(
86 : : sAPI_CreateFromLevelParagraphStyles)),
87 : : sUserIndexName(RTL_CONSTASCII_USTRINGPARAM(sAPI_UserIndexName)),
88 : : bUseObjects(sal_False),
89 : : bUseGraphic(sal_False),
90 : : bUseMarks(sal_False),
91 : : bUseTables(sal_False),
92 : : bUseFrames(sal_False),
93 : : bUseLevelFromSource(sal_False),
94 [ + - ][ + - ]: 4 : bUseLevelParagraphStyles(sal_False)
[ + - ][ + - ]
[ + - ][ + - ]
[ + - ][ + - ]
95 : : {
96 : 4 : }
97 : :
98 : 4 : XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
99 : : {
100 [ - + ]: 8 : }
101 : :
102 : 8 : void XMLIndexUserSourceContext::ProcessAttribute(
103 : : enum IndexSourceParamEnum eParam,
104 : : const OUString& rValue)
105 : : {
106 : 8 : bool bTmp(false);
107 : :
108 [ + - - - : 8 : switch (eParam)
- - - +
- ]
109 : : {
110 : : case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
111 [ + - ][ + - ]: 4 : if (::sax::Converter::convertBool(bTmp, rValue))
112 : : {
113 : 4 : bUseMarks = bTmp;
114 : : }
115 : 4 : break;
116 : :
117 : : case XML_TOK_INDEXSOURCE_USE_OBJECTS:
118 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
119 : : {
120 : 0 : bUseObjects = bTmp;
121 : : }
122 : 0 : break;
123 : :
124 : : case XML_TOK_INDEXSOURCE_USE_GRAPHICS:
125 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
126 : : {
127 : 0 : bUseGraphic = bTmp;
128 : : }
129 : 0 : break;
130 : :
131 : : case XML_TOK_INDEXSOURCE_USE_TABLES:
132 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
133 : : {
134 : 0 : bUseTables = bTmp;
135 : : }
136 : 0 : break;
137 : :
138 : : case XML_TOK_INDEXSOURCE_USE_FRAMES:
139 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
140 : : {
141 : 0 : bUseFrames = bTmp;
142 : : }
143 : 0 : break;
144 : :
145 : : case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS:
146 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
147 : : {
148 : 0 : bUseLevelFromSource = bTmp;
149 : : }
150 : 0 : break;
151 : :
152 : : case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES:
153 [ # # ][ # # ]: 0 : if (::sax::Converter::convertBool(bTmp, rValue))
154 : : {
155 : 0 : bUseLevelParagraphStyles = bTmp;
156 : : }
157 : 0 : break;
158 : :
159 : : case XML_TOK_INDEXSOURCE_USER_INDEX_NAME:
160 : 4 : sIndexName = rValue;
161 : 4 : break;
162 : :
163 : : default:
164 [ # # ]: 0 : XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
165 : 0 : break;
166 : : }
167 : 8 : }
168 : :
169 : :
170 : 4 : void XMLIndexUserSourceContext::EndElement()
171 : : {
172 : 4 : Any aAny;
173 : :
174 [ + - ]: 4 : aAny.setValue(&bUseObjects, ::getBooleanCppuType());
175 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromEmbeddedObjects, aAny);
176 : :
177 [ + - ]: 4 : aAny.setValue(&bUseGraphic, ::getBooleanCppuType());
178 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromGraphicObjects, aAny);
179 : :
180 [ + - ]: 4 : aAny.setValue(&bUseLevelFromSource, ::getBooleanCppuType());
181 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sUseLevelFromSource, aAny);
182 : :
183 [ + - ]: 4 : aAny.setValue(&bUseMarks, ::getBooleanCppuType());
184 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
185 : :
186 [ + - ]: 4 : aAny.setValue(&bUseTables, ::getBooleanCppuType());
187 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromTables, aAny);
188 : :
189 [ + - ]: 4 : aAny.setValue(&bUseFrames, ::getBooleanCppuType());
190 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromTextFrames, aAny);
191 : :
192 [ + - ]: 4 : aAny.setValue(&bUseLevelParagraphStyles, ::getBooleanCppuType());
193 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny);
194 : :
195 [ + - ]: 4 : if( !sIndexName.isEmpty() )
196 : : {
197 [ + - ]: 4 : aAny <<= sIndexName;
198 [ + - ][ + - ]: 4 : rIndexPropertySet->setPropertyValue(sUserIndexName, aAny);
199 : : }
200 : :
201 [ + - ]: 4 : XMLIndexSourceBaseContext::EndElement();
202 : 4 : }
203 : :
204 : :
205 : 44 : SvXMLImportContext* XMLIndexUserSourceContext::CreateChildContext(
206 : : sal_uInt16 nPrefix,
207 : : const OUString& rLocalName,
208 : : const Reference<XAttributeList> & xAttrList )
209 : : {
210 [ + - + + ]: 88 : if ( (XML_NAMESPACE_TEXT == nPrefix) &&
[ + + ]
211 : 44 : (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) )
212 : : {
213 : 40 : return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
214 : : nPrefix, rLocalName,
215 : : aLevelNameTOCMap,
216 : : XML_OUTLINE_LEVEL,
217 : : aLevelStylePropNameTOCMap,
218 [ + - ]: 40 : aAllowedTokenTypesUser);
219 : : }
220 : : else
221 : : {
222 : : return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
223 : : rLocalName,
224 : 44 : xAttrList);
225 : : }
226 : :
227 : : }
228 : :
229 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|