1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "XMLIndexUserSourceContext.hxx"
21 #include <com/sun/star/beans/XPropertySet.hpp>
22 #include <com/sun/star/container/XIndexReplace.hpp>
23 #include <sax/tools/converter.hxx>
24 #include "XMLIndexTemplateContext.hxx"
25 #include "XMLIndexTitleTemplateContext.hxx"
26 #include "XMLIndexTOCStylesContext.hxx"
27 #include <xmloff/xmlictxt.hxx>
28 #include <xmloff/xmlimp.hxx>
29 #include <xmloff/txtimp.hxx>
30 #include <xmloff/xmlnmspe.hxx>
31 #include <xmloff/nmspmap.hxx>
32 #include <xmloff/xmltoken.hxx>
33 #include <rtl/ustring.hxx>
36 using ::com::sun::star::beans::XPropertySet
;
37 using ::com::sun::star::uno::Reference
;
38 using ::com::sun::star::uno::Any
;
39 using ::com::sun::star::xml::sax::XAttributeList
;
40 using ::xmloff::token::IsXMLToken
;
41 using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE
;
42 using ::xmloff::token::XML_OUTLINE_LEVEL
;
45 const sal_Char sAPI_CreateFromEmbeddedObjects
[] = "CreateFromEmbeddedObjects";
46 const sal_Char sAPI_CreateFromGraphicObjects
[] = "CreateFromGraphicObjects";
47 const sal_Char sAPI_CreateFromMarks
[] = "CreateFromMarks";
48 const sal_Char sAPI_CreateFromTables
[] = "CreateFromTables";
49 const sal_Char sAPI_CreateFromTextFrames
[] = "CreateFromTextFrames";
50 const sal_Char sAPI_UseLevelFromSource
[] = "UseLevelFromSource";
51 const sal_Char sAPI_CreateFromLevelParagraphStyles
[] = "CreateFromLevelParagraphStyles";
52 const sal_Char sAPI_UserIndexName
[] = "UserIndexName";
55 TYPEINIT1(XMLIndexUserSourceContext
, XMLIndexSourceBaseContext
);
58 XMLIndexUserSourceContext::XMLIndexUserSourceContext(
61 const OUString
& rLocalName
,
62 Reference
<XPropertySet
> & rPropSet
) :
63 XMLIndexSourceBaseContext(rImport
, nPrfx
, rLocalName
,
65 sCreateFromEmbeddedObjects(sAPI_CreateFromEmbeddedObjects
),
66 sCreateFromGraphicObjects(sAPI_CreateFromGraphicObjects
),
67 sCreateFromMarks(sAPI_CreateFromMarks
),
68 sCreateFromTables(sAPI_CreateFromTables
),
69 sCreateFromTextFrames(sAPI_CreateFromTextFrames
),
70 sUseLevelFromSource(sAPI_UseLevelFromSource
),
71 sCreateFromLevelParagraphStyles(sAPI_CreateFromLevelParagraphStyles
),
72 sUserIndexName(sAPI_UserIndexName
),
78 bUseLevelFromSource(false),
79 bUseLevelParagraphStyles(false)
83 XMLIndexUserSourceContext::~XMLIndexUserSourceContext()
87 void XMLIndexUserSourceContext::ProcessAttribute(
88 enum IndexSourceParamEnum eParam
,
89 const OUString
& rValue
)
95 case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS
:
96 if (::sax::Converter::convertBool(bTmp
, rValue
))
102 case XML_TOK_INDEXSOURCE_USE_OBJECTS
:
103 if (::sax::Converter::convertBool(bTmp
, rValue
))
109 case XML_TOK_INDEXSOURCE_USE_GRAPHICS
:
110 if (::sax::Converter::convertBool(bTmp
, rValue
))
116 case XML_TOK_INDEXSOURCE_USE_TABLES
:
117 if (::sax::Converter::convertBool(bTmp
, rValue
))
123 case XML_TOK_INDEXSOURCE_USE_FRAMES
:
124 if (::sax::Converter::convertBool(bTmp
, rValue
))
130 case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS
:
131 if (::sax::Converter::convertBool(bTmp
, rValue
))
133 bUseLevelFromSource
= bTmp
;
137 case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES
:
138 if (::sax::Converter::convertBool(bTmp
, rValue
))
140 bUseLevelParagraphStyles
= bTmp
;
144 case XML_TOK_INDEXSOURCE_USER_INDEX_NAME
:
149 XMLIndexSourceBaseContext::ProcessAttribute(eParam
, rValue
);
155 void XMLIndexUserSourceContext::EndElement()
159 aAny
.setValue(&bUseObjects
, cppu::UnoType
<bool>::get());
160 rIndexPropertySet
->setPropertyValue(sCreateFromEmbeddedObjects
, aAny
);
162 aAny
.setValue(&bUseGraphic
, cppu::UnoType
<bool>::get());
163 rIndexPropertySet
->setPropertyValue(sCreateFromGraphicObjects
, aAny
);
165 aAny
.setValue(&bUseLevelFromSource
, cppu::UnoType
<bool>::get());
166 rIndexPropertySet
->setPropertyValue(sUseLevelFromSource
, aAny
);
168 aAny
.setValue(&bUseMarks
, cppu::UnoType
<bool>::get());
169 rIndexPropertySet
->setPropertyValue(sCreateFromMarks
, aAny
);
171 aAny
.setValue(&bUseTables
, cppu::UnoType
<bool>::get());
172 rIndexPropertySet
->setPropertyValue(sCreateFromTables
, aAny
);
174 aAny
.setValue(&bUseFrames
, cppu::UnoType
<bool>::get());
175 rIndexPropertySet
->setPropertyValue(sCreateFromTextFrames
, aAny
);
177 aAny
.setValue(&bUseLevelParagraphStyles
, cppu::UnoType
<bool>::get());
178 rIndexPropertySet
->setPropertyValue(sCreateFromLevelParagraphStyles
, aAny
);
180 if( !sIndexName
.isEmpty() )
183 rIndexPropertySet
->setPropertyValue(sUserIndexName
, aAny
);
186 XMLIndexSourceBaseContext::EndElement();
190 SvXMLImportContext
* XMLIndexUserSourceContext::CreateChildContext(
192 const OUString
& rLocalName
,
193 const Reference
<XAttributeList
> & xAttrList
)
195 if ( (XML_NAMESPACE_TEXT
== nPrefix
) &&
196 (IsXMLToken(rLocalName
, XML_USER_INDEX_ENTRY_TEMPLATE
)) )
198 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet
,
202 aLevelStylePropNameTOCMap
,
203 aAllowedTokenTypesUser
);
207 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix
,
214 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */