1*63bba73cSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*63bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*63bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*63bba73cSAndrew Rist * distributed with this work for additional information 6*63bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*63bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*63bba73cSAndrew Rist * "License"); you may not use this file except in compliance 9*63bba73cSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*63bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*63bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*63bba73cSAndrew Rist * software distributed under the License is distributed on an 15*63bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*63bba73cSAndrew Rist * KIND, either express or implied. See the License for the 17*63bba73cSAndrew Rist * specific language governing permissions and limitations 18*63bba73cSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*63bba73cSAndrew Rist *************************************************************/ 21*63bba73cSAndrew Rist 22*63bba73cSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_xmloff.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include "XMLIndexUserSourceContext.hxx" 29cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 30cdf0e10cSrcweir #include <com/sun/star/container/XIndexReplace.hpp> 31cdf0e10cSrcweir #include "XMLIndexTemplateContext.hxx" 32cdf0e10cSrcweir #include "XMLIndexTitleTemplateContext.hxx" 33cdf0e10cSrcweir #include "XMLIndexTOCStylesContext.hxx" 34cdf0e10cSrcweir #include <xmloff/xmlictxt.hxx> 35cdf0e10cSrcweir #include <xmloff/xmlimp.hxx> 36cdf0e10cSrcweir #include <xmloff/txtimp.hxx> 37cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx" 38cdf0e10cSrcweir #include <xmloff/nmspmap.hxx> 39cdf0e10cSrcweir #include <xmloff/xmltoken.hxx> 40cdf0e10cSrcweir #include <xmloff/xmluconv.hxx> 41cdf0e10cSrcweir #include <tools/debug.hxx> 42cdf0e10cSrcweir #include <rtl/ustring.hxx> 43cdf0e10cSrcweir 44cdf0e10cSrcweir 45cdf0e10cSrcweir using ::rtl::OUString; 46cdf0e10cSrcweir using ::com::sun::star::beans::XPropertySet; 47cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 48cdf0e10cSrcweir using ::com::sun::star::uno::Any; 49cdf0e10cSrcweir using ::com::sun::star::xml::sax::XAttributeList; 50cdf0e10cSrcweir using ::xmloff::token::IsXMLToken; 51cdf0e10cSrcweir using ::xmloff::token::XML_USER_INDEX_ENTRY_TEMPLATE; 52cdf0e10cSrcweir using ::xmloff::token::XML_OUTLINE_LEVEL; 53cdf0e10cSrcweir 54cdf0e10cSrcweir 55cdf0e10cSrcweir const sal_Char sAPI_CreateFromEmbeddedObjects[] = "CreateFromEmbeddedObjects"; 56cdf0e10cSrcweir const sal_Char sAPI_CreateFromGraphicObjects[] = "CreateFromGraphicObjects"; 57cdf0e10cSrcweir const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks"; 58cdf0e10cSrcweir const sal_Char sAPI_CreateFromTables[] = "CreateFromTables"; 59cdf0e10cSrcweir const sal_Char sAPI_CreateFromTextFrames[] = "CreateFromTextFrames"; 60cdf0e10cSrcweir const sal_Char sAPI_UseLevelFromSource[] = "UseLevelFromSource"; 61cdf0e10cSrcweir const sal_Char sAPI_CreateFromLevelParagraphStyles[] = "CreateFromLevelParagraphStyles"; 62cdf0e10cSrcweir const sal_Char sAPI_UserIndexName[] = "UserIndexName"; 63cdf0e10cSrcweir 64cdf0e10cSrcweir 65cdf0e10cSrcweir TYPEINIT1(XMLIndexUserSourceContext, XMLIndexSourceBaseContext); 66cdf0e10cSrcweir 67cdf0e10cSrcweir 68cdf0e10cSrcweir XMLIndexUserSourceContext::XMLIndexUserSourceContext( 69cdf0e10cSrcweir SvXMLImport& rImport, 70cdf0e10cSrcweir sal_uInt16 nPrfx, 71cdf0e10cSrcweir const OUString& rLocalName, 72cdf0e10cSrcweir Reference<XPropertySet> & rPropSet) : 73cdf0e10cSrcweir XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName, 74cdf0e10cSrcweir rPropSet, sal_True), 75cdf0e10cSrcweir sCreateFromEmbeddedObjects(RTL_CONSTASCII_USTRINGPARAM( 76cdf0e10cSrcweir sAPI_CreateFromEmbeddedObjects)), 77cdf0e10cSrcweir sCreateFromGraphicObjects(RTL_CONSTASCII_USTRINGPARAM( 78cdf0e10cSrcweir sAPI_CreateFromGraphicObjects)), 79cdf0e10cSrcweir sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks)), 80cdf0e10cSrcweir sCreateFromTables(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromTables)), 81cdf0e10cSrcweir sCreateFromTextFrames(RTL_CONSTASCII_USTRINGPARAM( 82cdf0e10cSrcweir sAPI_CreateFromTextFrames)), 83cdf0e10cSrcweir sUseLevelFromSource(RTL_CONSTASCII_USTRINGPARAM( 84cdf0e10cSrcweir sAPI_UseLevelFromSource)), 85cdf0e10cSrcweir sCreateFromLevelParagraphStyles(RTL_CONSTASCII_USTRINGPARAM( 86cdf0e10cSrcweir sAPI_CreateFromLevelParagraphStyles)), 87cdf0e10cSrcweir sUserIndexName(RTL_CONSTASCII_USTRINGPARAM(sAPI_UserIndexName)), 88cdf0e10cSrcweir bUseObjects(sal_False), 89cdf0e10cSrcweir bUseGraphic(sal_False), 90cdf0e10cSrcweir bUseMarks(sal_False), 91cdf0e10cSrcweir bUseTables(sal_False), 92cdf0e10cSrcweir bUseFrames(sal_False), 93cdf0e10cSrcweir bUseLevelFromSource(sal_False), 94cdf0e10cSrcweir bUseLevelParagraphStyles(sal_False) 95cdf0e10cSrcweir { 96cdf0e10cSrcweir } 97cdf0e10cSrcweir 98cdf0e10cSrcweir XMLIndexUserSourceContext::~XMLIndexUserSourceContext() 99cdf0e10cSrcweir { 100cdf0e10cSrcweir } 101cdf0e10cSrcweir 102cdf0e10cSrcweir void XMLIndexUserSourceContext::ProcessAttribute( 103cdf0e10cSrcweir enum IndexSourceParamEnum eParam, 104cdf0e10cSrcweir const OUString& rValue) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir sal_Bool bTmp; 107cdf0e10cSrcweir 108cdf0e10cSrcweir switch (eParam) 109cdf0e10cSrcweir { 110cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS: 111cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 112cdf0e10cSrcweir { 113cdf0e10cSrcweir bUseMarks = bTmp; 114cdf0e10cSrcweir } 115cdf0e10cSrcweir break; 116cdf0e10cSrcweir 117cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_OBJECTS: 118cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 119cdf0e10cSrcweir { 120cdf0e10cSrcweir bUseObjects = bTmp; 121cdf0e10cSrcweir } 122cdf0e10cSrcweir break; 123cdf0e10cSrcweir 124cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_GRAPHICS: 125cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir bUseGraphic = bTmp; 128cdf0e10cSrcweir } 129cdf0e10cSrcweir break; 130cdf0e10cSrcweir 131cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_TABLES: 132cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 133cdf0e10cSrcweir { 134cdf0e10cSrcweir bUseTables = bTmp; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir break; 137cdf0e10cSrcweir 138cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_FRAMES: 139cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 140cdf0e10cSrcweir { 141cdf0e10cSrcweir bUseFrames = bTmp; 142cdf0e10cSrcweir } 143cdf0e10cSrcweir break; 144cdf0e10cSrcweir 145cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_COPY_OUTLINE_LEVELS: 146cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 147cdf0e10cSrcweir { 148cdf0e10cSrcweir bUseLevelFromSource = bTmp; 149cdf0e10cSrcweir } 150cdf0e10cSrcweir break; 151cdf0e10cSrcweir 152cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USE_INDEX_SOURCE_STYLES: 153cdf0e10cSrcweir if (SvXMLUnitConverter::convertBool(bTmp, rValue)) 154cdf0e10cSrcweir { 155cdf0e10cSrcweir bUseLevelParagraphStyles = bTmp; 156cdf0e10cSrcweir } 157cdf0e10cSrcweir break; 158cdf0e10cSrcweir 159cdf0e10cSrcweir case XML_TOK_INDEXSOURCE_USER_INDEX_NAME: 160cdf0e10cSrcweir sIndexName = rValue; 161cdf0e10cSrcweir break; 162cdf0e10cSrcweir 163cdf0e10cSrcweir default: 164cdf0e10cSrcweir XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue); 165cdf0e10cSrcweir break; 166cdf0e10cSrcweir } 167cdf0e10cSrcweir } 168cdf0e10cSrcweir 169cdf0e10cSrcweir 170cdf0e10cSrcweir void XMLIndexUserSourceContext::EndElement() 171cdf0e10cSrcweir { 172cdf0e10cSrcweir Any aAny; 173cdf0e10cSrcweir 174cdf0e10cSrcweir aAny.setValue(&bUseObjects, ::getBooleanCppuType()); 175cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromEmbeddedObjects, aAny); 176cdf0e10cSrcweir 177cdf0e10cSrcweir aAny.setValue(&bUseGraphic, ::getBooleanCppuType()); 178cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromGraphicObjects, aAny); 179cdf0e10cSrcweir 180cdf0e10cSrcweir aAny.setValue(&bUseLevelFromSource, ::getBooleanCppuType()); 181cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sUseLevelFromSource, aAny); 182cdf0e10cSrcweir 183cdf0e10cSrcweir aAny.setValue(&bUseMarks, ::getBooleanCppuType()); 184cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny); 185cdf0e10cSrcweir 186cdf0e10cSrcweir aAny.setValue(&bUseTables, ::getBooleanCppuType()); 187cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromTables, aAny); 188cdf0e10cSrcweir 189cdf0e10cSrcweir aAny.setValue(&bUseFrames, ::getBooleanCppuType()); 190cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromTextFrames, aAny); 191cdf0e10cSrcweir 192cdf0e10cSrcweir aAny.setValue(&bUseLevelParagraphStyles, ::getBooleanCppuType()); 193cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sCreateFromLevelParagraphStyles, aAny); 194cdf0e10cSrcweir 195cdf0e10cSrcweir if( sIndexName.getLength() > 0 ) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir aAny <<= sIndexName; 198cdf0e10cSrcweir rIndexPropertySet->setPropertyValue(sUserIndexName, aAny); 199cdf0e10cSrcweir } 200cdf0e10cSrcweir 201cdf0e10cSrcweir XMLIndexSourceBaseContext::EndElement(); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir 205cdf0e10cSrcweir SvXMLImportContext* XMLIndexUserSourceContext::CreateChildContext( 206cdf0e10cSrcweir sal_uInt16 nPrefix, 207cdf0e10cSrcweir const OUString& rLocalName, 208cdf0e10cSrcweir const Reference<XAttributeList> & xAttrList ) 209cdf0e10cSrcweir { 210cdf0e10cSrcweir if ( (XML_NAMESPACE_TEXT == nPrefix) && 211cdf0e10cSrcweir (IsXMLToken(rLocalName, XML_USER_INDEX_ENTRY_TEMPLATE)) ) 212cdf0e10cSrcweir { 213cdf0e10cSrcweir return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet, 214cdf0e10cSrcweir nPrefix, rLocalName, 215cdf0e10cSrcweir aLevelNameTOCMap, 216cdf0e10cSrcweir XML_OUTLINE_LEVEL, 217cdf0e10cSrcweir aLevelStylePropNameTOCMap, 218cdf0e10cSrcweir aAllowedTokenTypesUser); 219cdf0e10cSrcweir } 220cdf0e10cSrcweir else 221cdf0e10cSrcweir { 222cdf0e10cSrcweir return XMLIndexSourceBaseContext::CreateChildContext(nPrefix, 223cdf0e10cSrcweir rLocalName, 224cdf0e10cSrcweir xAttrList); 225cdf0e10cSrcweir } 226cdf0e10cSrcweir 227cdf0e10cSrcweir } 228