1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_xmloff.hxx" 30 31 32 #include "XMLIndexObjectSourceContext.hxx" 33 #include <com/sun/star/beans/XPropertySet.hpp> 34 #include <com/sun/star/container/XIndexReplace.hpp> 35 #include "XMLIndexTemplateContext.hxx" 36 #include "XMLIndexTitleTemplateContext.hxx" 37 #include "XMLIndexTOCStylesContext.hxx" 38 #include <xmloff/xmlictxt.hxx> 39 #include <xmloff/xmlimp.hxx> 40 #include <xmloff/txtimp.hxx> 41 #include "xmloff/xmlnmspe.hxx" 42 #include <xmloff/nmspmap.hxx> 43 #include <xmloff/xmltoken.hxx> 44 #include <xmloff/xmluconv.hxx> 45 #include <tools/debug.hxx> 46 #include <rtl/ustring.hxx> 47 48 49 using ::rtl::OUString; 50 using ::com::sun::star::beans::XPropertySet; 51 using ::com::sun::star::uno::Reference; 52 using ::com::sun::star::uno::Any; 53 using ::com::sun::star::xml::sax::XAttributeList; 54 using ::xmloff::token::IsXMLToken; 55 using ::xmloff::token::XML_OBJECT_INDEX_ENTRY_TEMPLATE; 56 using ::xmloff::token::XML_TOKEN_INVALID; 57 58 const sal_Char sAPI_CreateFromStarCalc[] = "CreateFromStarCalc"; 59 const sal_Char sAPI_CreateFromStarChart[] = "CreateFromStarChart"; 60 const sal_Char sAPI_CreateFromStarDraw[] = "CreateFromStarDraw"; 61 const sal_Char sAPI_CreateFromStarImage[] = "CreateFromStarImage"; 62 const sal_Char sAPI_CreateFromStarMath[] = "CreateFromStarMath"; 63 const sal_Char sAPI_CreateFromOtherEmbeddedObjects[] = "CreateFromOtherEmbeddedObjects"; 64 65 66 TYPEINIT1( XMLIndexObjectSourceContext, XMLIndexSourceBaseContext ); 67 68 XMLIndexObjectSourceContext::XMLIndexObjectSourceContext( 69 SvXMLImport& rImport, 70 sal_uInt16 nPrfx, 71 const OUString& rLocalName, 72 Reference<XPropertySet> & rPropSet) : 73 XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, 74 rPropSet, sal_False), 75 sCreateFromStarCalc(RTL_CONSTASCII_USTRINGPARAM( 76 sAPI_CreateFromStarCalc)), 77 sCreateFromStarChart(RTL_CONSTASCII_USTRINGPARAM( 78 sAPI_CreateFromStarChart)), 79 sCreateFromStarDraw(RTL_CONSTASCII_USTRINGPARAM( 80 sAPI_CreateFromStarDraw)), 81 sCreateFromStarMath(RTL_CONSTASCII_USTRINGPARAM( 82 sAPI_CreateFromStarMath)), 83 sCreateFromOtherEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM( 84 sAPI_CreateFromOtherEmbeddedObjects)), 85 bUseCalc(sal_False), 86 bUseChart(sal_False), 87 bUseDraw(sal_False), 88 bUseMath(sal_False), 89 bUseOtherObjects(sal_False) 90 { 91 } 92 93 XMLIndexObjectSourceContext::~XMLIndexObjectSourceContext() 94 { 95 } 96 97 void XMLIndexObjectSourceContext::ProcessAttribute( 98 enum IndexSourceParamEnum eParam, 99 const OUString& rValue) 100 { 101 switch (eParam) 102 { 103 sal_Bool bTmp; 104 105 case XML_TOK_INDEXSOURCE_USE_OTHER_OBJECTS: 106 if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 107 { 108 bUseOtherObjects = bTmp; 109 } 110 break; 111 112 case XML_TOK_INDEXSOURCE_USE_SHEET: 113 if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 114 { 115 bUseCalc = bTmp; 116 } 117 break; 118 119 case XML_TOK_INDEXSOURCE_USE_CHART: 120 if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 121 { 122 bUseChart = bTmp; 123 } 124 break; 125 126 case XML_TOK_INDEXSOURCE_USE_DRAW: 127 if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 128 { 129 bUseDraw = bTmp; 130 } 131 break; 132 133 case XML_TOK_INDEXSOURCE_USE_MATH: 134 if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 135 { 136 bUseMath = bTmp; 137 } 138 break; 139 140 default: 141 XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); 142 break; 143 } 144 } 145 146 void XMLIndexObjectSourceContext::EndElement() 147 { 148 Any aAny; 149 150 aAny.setValue(&bUseCalc, ::getBooleanCppuType()); 151 rIndexPropertySet->setPropertyValue(sCreateFromStarCalc, aAny); 152 153 aAny.setValue(&bUseChart, ::getBooleanCppuType()); 154 rIndexPropertySet->setPropertyValue(sCreateFromStarChart, aAny); 155 156 aAny.setValue(&bUseDraw, ::getBooleanCppuType()); 157 rIndexPropertySet->setPropertyValue(sCreateFromStarDraw, aAny); 158 159 aAny.setValue(&bUseMath, ::getBooleanCppuType()); 160 rIndexPropertySet->setPropertyValue(sCreateFromStarMath, aAny); 161 162 aAny.setValue(&bUseOtherObjects, ::getBooleanCppuType()); 163 rIndexPropertySet->setPropertyValue(sCreateFromOtherEmbeddedObjects, aAny); 164 165 XMLIndexSourceBaseContext::EndElement(); 166 } 167 168 SvXMLImportContext* XMLIndexObjectSourceContext::CreateChildContext( 169 sal_uInt16 nPrefix, 170 const OUString& rLocalName, 171 const Reference<XAttributeList> & xAttrList ) 172 { 173 if ( (XML_NAMESPACE_TEXT == nPrefix) && 174 (IsXMLToken(rLocalName, XML_OBJECT_INDEX_ENTRY_TEMPLATE)) ) 175 { 176 return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet, 177 nPrefix, rLocalName, 178 aLevelNameTableMap, 179 XML_TOKEN_INVALID, // no outline-level attr 180 aLevelStylePropNameTableMap, 181 aAllowedTokenTypesTable); 182 } 183 else 184 { 185 return XMLIndexSourceBaseContext::CreateChildContext(nPrefix, 186 rLocalName, 187 xAttrList); 188 } 189 190 } 191