2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-12 17:21:24 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2001-02-16 15:39:27 +00:00
|
|
|
|
|
|
|
#include "XMLSectionFootnoteConfigImport.hxx"
|
|
|
|
|
2006-06-19 17:44:03 +00:00
|
|
|
#include <rtl/ustring.hxx>
|
2001-02-16 15:39:27 +00:00
|
|
|
#include <com/sun/star/uno/Reference.h>
|
|
|
|
#include <com/sun/star/xml/sax/XAttributeList.hpp>
|
2001-03-19 08:41:43 +00:00
|
|
|
#include <com/sun/star/style/NumberingType.hpp>
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
#include <sax/tools/converter.hxx>
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/xmlimp.hxx>
|
|
|
|
#include <xmloff/xmltoken.hxx>
|
|
|
|
#include <xmloff/xmluconv.hxx>
|
|
|
|
#include <xmloff/xmlprmap.hxx>
|
2010-04-16 23:04:00 +02:00
|
|
|
#include "xmloff/xmlnmspe.hxx"
|
2007-06-27 15:06:29 +00:00
|
|
|
#include <xmloff/nmspmap.hxx>
|
|
|
|
#include <xmloff/maptype.hxx>
|
|
|
|
#include <xmloff/xmlnumi.hxx>
|
|
|
|
#include <xmloff/txtprmap.hxx>
|
2001-04-17 11:01:21 +00:00
|
|
|
|
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 ::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;
|
#i108468#: clean up xmluconv code duplication, part 1:
move convertNumber64 from SvXMLUnitConverter to sax::converter.
remove duplicate methods from SvXMLUnitConverter:
convertBool, convertPercent, convertColor, convertNumber, convertDouble,
indexOfComma, encodeBase64, decodeBase64, decodeBase64SomeChars,
clearUndefinedChars
2011-10-11 14:19:00 +02:00
|
|
|
if (::sax::Converter::convertNumber(nTmp, sAttrValue))
|
2001-02-16 15:39:27 +00:00
|
|
|
{
|
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
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|