2001-02-16 15:39:27 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* $RCSfile: XMLSectionFootnoteConfigImport.cxx,v $
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2007-06-27 15:06:29 +00:00
|
|
|
* $Revision: 1.9 $
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2007-06-27 15:06:29 +00:00
|
|
|
* last change: $Author: hr $ $Date: 2007-06-27 16:05:03 $
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* The Contents of this file are made available subject to
|
|
|
|
* the terms of GNU Lesser General Public License Version 2.1.
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2005 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
2005-09-09 14:17:03 +00:00
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
2001-02-16 15:39:27 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
2006-09-17 10:11:08 +00:00
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_xmloff.hxx"
|
|
|
|
|
2001-02-16 15:39:27 +00:00
|
|
|
#ifndef _XMLOFF_XMLSECTIONFOOTNOTECONFIGIMPORT_HXX
|
|
|
|
#include "XMLSectionFootnoteConfigImport.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _RTL_USTRING
|
2006-06-19 17:44:03 +00:00
|
|
|
#include <rtl/ustring.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
|
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _COM_SUN_STAR_XML_SAX_XATTRIBUTELIST_HPP_
|
|
|
|
#include <com/sun/star/xml/sax/XAttributeList.hpp>
|
|
|
|
#endif
|
2001-03-19 08:41:43 +00:00
|
|
|
#ifndef _COM_SUN_STAR_STYLE_NUMBERINGTYPE_HPP_
|
|
|
|
#include <com/sun/star/style/NumberingType.hpp>
|
|
|
|
#endif
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLIMP_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmlimp.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
#ifndef _XMLOFF_XMLTOKEN_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmltoken.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLUCONV_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmluconv.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_PROPERTYSETMAPPER_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmlprmap.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNMSPE_HXX
|
|
|
|
#include "xmlnmspe.hxx"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_NMSPMAP_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/nmspmap.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/maptype.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _XMLOFF_XMLNUMI_HXX
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmlnumi.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#endif
|
|
|
|
|
2001-04-17 11:01:21 +00:00
|
|
|
#ifndef _XMLOFF_TEXTPRMAP_HXX_
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/txtprmap.hxx>
|
2001-04-17 11:01:21 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef _TOOLS_DEBUG_HXX
|
|
|
|
#include <tools/debug.hxx>
|
|
|
|
#endif
|
|
|
|
|
2001-02-16 15:39:27 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2001-06-29 20:07:26 +00:00
|
|
|
|
|
|
|
using namespace ::xmloff::token;
|
2001-03-19 08:41:43 +00:00
|
|
|
using namespace ::com::sun::star::style;
|
2001-06-29 20:07:26 +00:00
|
|
|
|
2001-02-16 15:39:27 +00:00
|
|
|
using ::rtl::OUString;
|
|
|
|
using ::std::vector;
|
|
|
|
using ::com::sun::star::uno::Any;
|
|
|
|
using ::com::sun::star::uno::Reference;
|
|
|
|
using ::com::sun::star::xml::sax::XAttributeList;
|
|
|
|
|
|
|
|
|
|
|
|
TYPEINIT1(XMLSectionFootnoteConfigImport, SvXMLImportContext);
|
|
|
|
|
|
|
|
|
|
|
|
XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
|
|
|
|
SvXMLImport& rImport,
|
|
|
|
sal_uInt16 nPrefix,
|
|
|
|
const OUString& rLocalName,
|
|
|
|
vector<XMLPropertyState> & rProps,
|
2004-11-09 11:18:50 +00:00
|
|
|
const UniReference<XMLPropertySetMapper> & rMapperRef) :
|
2001-02-16 15:39:27 +00:00
|
|
|
SvXMLImportContext(rImport, nPrefix, rLocalName),
|
|
|
|
rProperties(rProps),
|
2001-04-17 11:01:21 +00:00
|
|
|
rMapper(rMapperRef)
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
XMLSectionFootnoteConfigImport::~XMLSectionFootnoteConfigImport()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void XMLSectionFootnoteConfigImport::StartElement(
|
|
|
|
const Reference<XAttributeList> & xAttrList)
|
|
|
|
{
|
|
|
|
sal_Bool bEnd = sal_True; // we're inside the element, so this is true
|
|
|
|
sal_Bool bNumOwn = sal_False;
|
|
|
|
sal_Bool bNumRestart = sal_False;
|
2004-11-09 11:18:50 +00:00
|
|
|
sal_Bool bEndnote = sal_False;
|
2001-02-16 15:39:27 +00:00
|
|
|
sal_Int16 nNumRestartAt = 0;
|
|
|
|
OUString sNumPrefix;
|
|
|
|
OUString sNumSuffix;
|
|
|
|
OUString sNumFormat;
|
|
|
|
OUString sNumLetterSync;
|
|
|
|
|
|
|
|
// iterate over xattribute list and fill values
|
|
|
|
sal_Int16 nLength = xAttrList->getLength();
|
|
|
|
for(sal_Int16 nAttr = 0; nAttr < nLength; nAttr++)
|
|
|
|
{
|
|
|
|
OUString sLocalName;
|
|
|
|
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
|
|
|
|
GetKeyByAttrName( xAttrList->getNameByIndex(nAttr),
|
|
|
|
&sLocalName );
|
|
|
|
OUString sAttrValue = xAttrList->getValueByIndex(nAttr);
|
|
|
|
|
|
|
|
if (XML_NAMESPACE_TEXT == nPrefix)
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
if (IsXMLToken(sLocalName, XML_START_VALUE))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
sal_Int32 nTmp;
|
|
|
|
if (SvXMLUnitConverter::convertNumber(nTmp, sAttrValue))
|
|
|
|
{
|
2004-11-09 11:18:50 +00:00
|
|
|
nNumRestartAt = static_cast< sal_Int16 >( nTmp ) - 1;
|
2001-02-16 15:39:27 +00:00
|
|
|
bNumRestart = sal_True;
|
|
|
|
}
|
|
|
|
}
|
2004-11-09 11:18:50 +00:00
|
|
|
else if( IsXMLToken( sLocalName, XML_NOTE_CLASS ) )
|
|
|
|
{
|
|
|
|
if( IsXMLToken( sAttrValue, XML_ENDNOTE ) )
|
|
|
|
bEndnote = sal_True;
|
|
|
|
}
|
2001-02-16 15:39:27 +00:00
|
|
|
}
|
|
|
|
else if (XML_NAMESPACE_STYLE == nPrefix)
|
|
|
|
{
|
2001-06-29 20:07:26 +00:00
|
|
|
if (IsXMLToken(sLocalName, XML_NUM_PREFIX))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
sNumPrefix = sAttrValue;
|
|
|
|
bNumOwn = sal_True;
|
|
|
|
}
|
2001-06-29 20:07:26 +00:00
|
|
|
else if (IsXMLToken(sLocalName, XML_NUM_SUFFIX))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
sNumSuffix = sAttrValue;
|
|
|
|
bNumOwn = sal_True;
|
|
|
|
}
|
2001-06-29 20:07:26 +00:00
|
|
|
else if (IsXMLToken(sLocalName, XML_NUM_FORMAT))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
sNumFormat = sAttrValue;
|
|
|
|
bNumOwn = sal_True;
|
|
|
|
}
|
2001-06-29 20:07:26 +00:00
|
|
|
else if (IsXMLToken(sLocalName, XML_NUM_LETTER_SYNC))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
|
|
|
sNumLetterSync = sAttrValue;
|
|
|
|
bNumOwn = sal_True;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// OK, now we have all values and can fill the XMLPropertyState vector
|
|
|
|
Any aAny;
|
|
|
|
|
|
|
|
aAny.setValue( &bNumOwn, ::getBooleanCppuType() );
|
2001-04-17 11:01:21 +00:00
|
|
|
sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_OWN : CTF_SECTION_FOOTNOTE_NUM_OWN );
|
|
|
|
XMLPropertyState aNumOwn( nIndex, aAny );
|
|
|
|
rProperties.push_back( aNumOwn );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
aAny.setValue( &bNumRestart, ::getBooleanCppuType() );
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_RESTART : CTF_SECTION_FOOTNOTE_NUM_RESTART );
|
|
|
|
XMLPropertyState aNumRestart( nIndex, aAny );
|
|
|
|
rProperties.push_back( aNumRestart );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
aAny <<= nNumRestartAt;
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_RESTART_AT :
|
|
|
|
CTF_SECTION_FOOTNOTE_NUM_RESTART_AT );
|
|
|
|
XMLPropertyState aNumRestartAtState( nIndex, aAny );
|
|
|
|
rProperties.push_back( aNumRestartAtState );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
2001-03-19 08:41:43 +00:00
|
|
|
sal_Int16 nNumType = NumberingType::ARABIC;
|
|
|
|
GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
|
|
|
|
sNumFormat,
|
|
|
|
sNumLetterSync );
|
|
|
|
aAny <<= nNumType;
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_TYPE : CTF_SECTION_FOOTNOTE_NUM_TYPE );
|
|
|
|
XMLPropertyState aNumFormatState( nIndex, aAny );
|
|
|
|
rProperties.push_back( aNumFormatState );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
aAny <<= sNumPrefix;
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_PREFIX : CTF_SECTION_FOOTNOTE_NUM_PREFIX );
|
|
|
|
XMLPropertyState aPrefixState( nIndex, aAny );
|
|
|
|
rProperties.push_back( aPrefixState );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
aAny <<= sNumSuffix;
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_NUM_SUFFIX : CTF_SECTION_FOOTNOTE_NUM_SUFFIX );
|
|
|
|
XMLPropertyState aSuffixState( nIndex, aAny );
|
|
|
|
rProperties.push_back( aSuffixState );
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
aAny.setValue( &bEnd, ::getBooleanCppuType() );
|
2001-04-17 11:01:21 +00:00
|
|
|
nIndex = rMapper->FindEntryIndex( bEndnote ?
|
|
|
|
CTF_SECTION_ENDNOTE_END : CTF_SECTION_FOOTNOTE_END );
|
|
|
|
XMLPropertyState aEndState( nIndex, aAny );
|
|
|
|
rProperties.push_back( aEndState );
|
2001-02-16 15:39:27 +00:00
|
|
|
}
|