summaryrefslogtreecommitdiff
path: root/xmloff/source/text
diff options
context:
space:
mode:
authorDaniel Vogelheim <dvo@openoffice.org>2001-04-17 11:01:21 +0000
committerDaniel Vogelheim <dvo@openoffice.org>2001-04-17 11:01:21 +0000
commit1be8c839d70f581d920f5d33611c7918a2a2eed9 (patch)
tree55d51a3a1ed6d55ef32d7293532426ed9f6b8308 /xmloff/source/text
parent5fb0d8578ecd7fc358e10b9cdfbf4c0b1d570dc2 (diff)
fixed: footnote configuration and footnote separator do not rely on ordering of
property set maps any more
Diffstat (limited to 'xmloff/source/text')
-rw-r--r--xmloff/source/text/XMLSectionFootnoteConfigExport.cxx158
-rw-r--r--xmloff/source/text/XMLSectionFootnoteConfigImport.cxx63
-rw-r--r--xmloff/source/text/XMLSectionFootnoteConfigImport.hxx13
-rw-r--r--xmloff/source/text/XMLTextPropertySetContext.cxx60
4 files changed, 146 insertions, 148 deletions
diff --git a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
index 3e1ad4a0e7..095ed9d25a 100644
--- a/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
+++ b/xmloff/source/text/XMLSectionFootnoteConfigExport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XMLSectionFootnoteConfigExport.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: mib $ $Date: 2001-03-19 09:41:43 $
+ * last change: $Author: dvo $ $Date: 2001-04-17 12:01:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -71,8 +71,8 @@
#include "xmlprmap.hxx"
#endif
-#ifndef _COM_SUN_STAR_UNO_ANY_HXX_
-#include <com/sun/star/uno/Any.hxx>
+#ifndef _COM_SUN_STAR_STYLE_NUMBERINGTYPE_HPP_
+#include <com/sun/star/style/NumberingType.hpp>
#endif
#ifndef _XMLOFF_PROPMAPPINGTYPES_HXX
@@ -121,6 +121,7 @@
using ::std::vector;
using ::rtl::OUString;
using ::rtl::OUStringBuffer;
+using ::com::sun::star::style::NumberingType::ARABIC;
void XMLSectionFootnoteConfigExport::exportXML(
@@ -130,76 +131,81 @@ void XMLSectionFootnoteConfigExport::exportXML(
sal_uInt32 nIdx,
const UniReference<XMLPropertySetMapper> & rMapper)
{
-
-#ifndef PRODUCT
- // check whether the properties are in the property state vector as
- // expected. If any of these assertions fail, someone messed up the
- // propertymap in txtprmap.cxx
-
- static sal_Int16 aFootnoteIds[] =
- {
- CTF_SECTION_FOOTNOTE_NUM_OWN,
- CTF_SECTION_FOOTNOTE_NUM_RESTART,
- CTF_SECTION_FOOTNOTE_NUM_RESTART_AT,
- CTF_SECTION_FOOTNOTE_NUM_TYPE,
- CTF_SECTION_FOOTNOTE_NUM_PREFIX,
- CTF_SECTION_FOOTNOTE_NUM_SUFFIX,
- CTF_SECTION_FOOTNOTE_END
- };
-
- static sal_Int16 aEndnoteIds[] =
- {
- CTF_SECTION_ENDNOTE_NUM_OWN,
- CTF_SECTION_ENDNOTE_NUM_RESTART,
- CTF_SECTION_ENDNOTE_NUM_RESTART_AT,
- CTF_SECTION_ENDNOTE_NUM_TYPE,
- CTF_SECTION_ENDNOTE_NUM_PREFIX,
- CTF_SECTION_ENDNOTE_NUM_SUFFIX,
- CTF_SECTION_ENDNOTE_END
- };
-
- sal_Int16* pIds = bEndnote ? aEndnoteIds : aFootnoteIds;
-
- // check map entries
- DBG_ASSERT( pIds[0] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-6].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[1] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-5].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[2] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-4].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[3] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-3].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[4] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-2].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[5] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx-1].mnIndex),
- "expect consecutive map entries" );
- DBG_ASSERT( pIds[6] ==
- rMapper->GetEntryContextId((*pProperties)[nIdx].mnIndex),
- "expect consecutive map entries" );
-#endif
-
- // get the values from the properties
- sal_Bool bNumOwn;
- sal_Bool bNumRestart;
- sal_Int16 nNumRestartAt;
- sal_Int16 nNumberingType;
+ // store and initialize the values
+ sal_Bool bNumOwn = sal_False;
+ sal_Bool bNumRestart = sal_False;
+ sal_Int16 nNumRestartAt = 0;
+ sal_Int16 nNumberingType = ARABIC;
OUString sNumPrefix;
OUString sNumSuffix;
- sal_Bool bEnd;
+ sal_Bool bEnd = sal_False;
+
+ // find entries in property states vector
+ sal_uInt32 nCount = pProperties->size();
+ for(sal_uInt32 i = 0; i < nCount; i++)
+ {
+ const XMLPropertyState& rState = (*pProperties)[i];
- (*pProperties)[nIdx-6].maValue >>= bNumOwn;
- (*pProperties)[nIdx-5].maValue >>= bNumRestart;
- (*pProperties)[nIdx-4].maValue >>= nNumRestartAt;
- (*pProperties)[nIdx-3].maValue >>= nNumberingType;
- (*pProperties)[nIdx-2].maValue >>= sNumPrefix;
- (*pProperties)[nIdx-1].maValue >>= sNumSuffix;
- (*pProperties)[nIdx ].maValue >>= bEnd;
+ sal_Int16 nContextId = rMapper->GetEntryContextId(rState.mnIndex);
+ if (!bEndnote)
+ {
+ switch (nContextId)
+ {
+ case CTF_SECTION_FOOTNOTE_NUM_OWN:
+ rState.maValue >>= bNumOwn;
+ break;
+ case CTF_SECTION_FOOTNOTE_NUM_RESTART:
+ rState.maValue >>= bNumRestart;
+ break;
+ case CTF_SECTION_FOOTNOTE_NUM_RESTART_AT:
+ rState.maValue >>= nNumRestartAt;
+ break;
+ case CTF_SECTION_FOOTNOTE_NUM_TYPE:
+ rState.maValue >>= nNumberingType;
+ break;
+ case CTF_SECTION_FOOTNOTE_NUM_PREFIX:
+ rState.maValue >>= sNumPrefix;
+ break;
+ case CTF_SECTION_FOOTNOTE_NUM_SUFFIX:
+ rState.maValue >>= sNumSuffix;
+ break;
+ case CTF_SECTION_FOOTNOTE_END:
+ DBG_ASSERT( i == nIdx,
+ "received wrong property state index" );
+ rState.maValue >>= bEnd;
+ break;
+ }
+ }
+ else
+ {
+ switch (nContextId)
+ {
+ case CTF_SECTION_ENDNOTE_NUM_OWN:
+ rState.maValue >>= bNumOwn;
+ break;
+ case CTF_SECTION_ENDNOTE_NUM_RESTART:
+ rState.maValue >>= bNumRestart;
+ break;
+ case CTF_SECTION_ENDNOTE_NUM_RESTART_AT:
+ rState.maValue >>= nNumRestartAt;
+ break;
+ case CTF_SECTION_ENDNOTE_NUM_TYPE:
+ rState.maValue >>= nNumberingType;
+ break;
+ case CTF_SECTION_ENDNOTE_NUM_PREFIX:
+ rState.maValue >>= sNumPrefix;
+ break;
+ case CTF_SECTION_ENDNOTE_NUM_SUFFIX:
+ rState.maValue >>= sNumSuffix;
+ break;
+ case CTF_SECTION_ENDNOTE_END:
+ DBG_ASSERT( i == nIdx,
+ "received wrong property state index" );
+ rState.maValue >>= bEnd;
+ break;
+ }
+ }
+ }
// we only make an element if we have an own footnote/endnote numbering
if (bEnd)
@@ -230,17 +236,19 @@ void XMLSectionFootnoteConfigExport::exportXML(
}
// number type: num format
- rExport.GetMM100UnitConverter().convertNumFormat( sBuf, nNumberingType );
+ rExport.GetMM100UnitConverter().convertNumFormat( sBuf,
+ nNumberingType );
rExport.AddAttribute(XML_NAMESPACE_STYLE, sXML_num_format,
sBuf.makeStringAndClear());
// and letter sync, if applicable
- rExport.GetMM100UnitConverter().convertNumLetterSync( sBuf, nNumberingType );
+ rExport.GetMM100UnitConverter().convertNumLetterSync(
+ sBuf, nNumberingType );
if (sBuf.getLength())
{
rExport.AddAttribute(XML_NAMESPACE_STYLE,
- sXML_num_letter_sync,
- sBuf.makeStringAndClear());
+ sXML_num_letter_sync,
+ sBuf.makeStringAndClear());
}
}
diff --git a/xmloff/source/text/XMLSectionFootnoteConfigImport.cxx b/xmloff/source/text/XMLSectionFootnoteConfigImport.cxx
index 529aeb1574..ccdb516096 100644
--- a/xmloff/source/text/XMLSectionFootnoteConfigImport.cxx
+++ b/xmloff/source/text/XMLSectionFootnoteConfigImport.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XMLSectionFootnoteConfigImport.cxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: mib $ $Date: 2001-03-19 09:41:43 $
+ * last change: $Author: dvo $ $Date: 2001-04-17 12:01:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -110,6 +110,14 @@
#include "xmlnumi.hxx"
#endif
+#ifndef _XMLOFF_TEXTPRMAP_HXX_
+#include "txtprmap.hxx"
+#endif
+
+#ifndef _TOOLS_DEBUG_HXX
+#include <tools/debug.hxx>
+#endif
+
#include <vector>
using namespace ::com::sun::star::style;
@@ -128,10 +136,12 @@ XMLSectionFootnoteConfigImport::XMLSectionFootnoteConfigImport(
sal_uInt16 nPrefix,
const OUString& rLocalName,
vector<XMLPropertyState> & rProps,
+ const UniReference<XMLPropertySetMapper> & rMapperRef,
sal_Int32 nIndex) :
SvXMLImportContext(rImport, nPrefix, rLocalName),
rProperties(rProps),
- nPropIndex(nIndex)
+ nPropIndex(nIndex),
+ rMapper(rMapperRef)
{
}
@@ -205,36 +215,55 @@ void XMLSectionFootnoteConfigImport::StartElement(
// OK, now we have all values and can fill the XMLPropertyState vector
Any aAny;
+ sal_Bool bEndnote = GetLocalName().equalsAsciiL(
+ sXML_endnotes_configuration,
+ sizeof(sXML_endnotes_configuration)-1 );
aAny.setValue( &bNumOwn, ::getBooleanCppuType() );
- XMLPropertyState aNumOwn( nPropIndex-6, aAny );
- rProperties.push_back(aNumOwn);
+ sal_Int32 nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_OWN : CTF_SECTION_FOOTNOTE_NUM_OWN );
+ XMLPropertyState aNumOwn( nIndex, aAny );
+ rProperties.push_back( aNumOwn );
aAny.setValue( &bNumRestart, ::getBooleanCppuType() );
- XMLPropertyState aNumRestart( nPropIndex-5, aAny );
- rProperties.push_back(aNumRestart);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_RESTART : CTF_SECTION_FOOTNOTE_NUM_RESTART );
+ XMLPropertyState aNumRestart( nIndex, aAny );
+ rProperties.push_back( aNumRestart );
aAny <<= nNumRestartAt;
- XMLPropertyState aNumRestartAtState( nPropIndex-4, aAny );
- rProperties.push_back(aNumRestartAtState);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_RESTART_AT :
+ CTF_SECTION_FOOTNOTE_NUM_RESTART_AT );
+ XMLPropertyState aNumRestartAtState( nIndex, aAny );
+ rProperties.push_back( aNumRestartAtState );
sal_Int16 nNumType = NumberingType::ARABIC;
GetImport().GetMM100UnitConverter().convertNumFormat( nNumType,
sNumFormat,
sNumLetterSync );
aAny <<= nNumType;
- XMLPropertyState aNumFormatState( nPropIndex-3, aAny);
- rProperties.push_back(aNumFormatState);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_TYPE : CTF_SECTION_FOOTNOTE_NUM_TYPE );
+ XMLPropertyState aNumFormatState( nIndex, aAny );
+ rProperties.push_back( aNumFormatState );
aAny <<= sNumPrefix;
- XMLPropertyState aPrefixState( nPropIndex-2, aAny);
- rProperties.push_back(aPrefixState);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_PREFIX : CTF_SECTION_FOOTNOTE_NUM_PREFIX );
+ XMLPropertyState aPrefixState( nIndex, aAny );
+ rProperties.push_back( aPrefixState );
aAny <<= sNumSuffix;
- XMLPropertyState aSuffixState( nPropIndex-1, aAny);
- rProperties.push_back(aSuffixState);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_NUM_SUFFIX : CTF_SECTION_FOOTNOTE_NUM_SUFFIX );
+ XMLPropertyState aSuffixState( nIndex, aAny );
+ rProperties.push_back( aSuffixState );
aAny.setValue( &bEnd, ::getBooleanCppuType() );
- XMLPropertyState aEndState( nPropIndex, aAny );
- rProperties.push_back(aEndState);
+ nIndex = rMapper->FindEntryIndex( bEndnote ?
+ CTF_SECTION_ENDNOTE_END : CTF_SECTION_FOOTNOTE_END );
+ DBG_ASSERT( nIndex == nPropIndex, "Wrong property mapper index received.");
+ XMLPropertyState aEndState( nIndex, aAny );
+ rProperties.push_back( aEndState );
}
diff --git a/xmloff/source/text/XMLSectionFootnoteConfigImport.hxx b/xmloff/source/text/XMLSectionFootnoteConfigImport.hxx
index 6879c5f2e8..8689528f0e 100644
--- a/xmloff/source/text/XMLSectionFootnoteConfigImport.hxx
+++ b/xmloff/source/text/XMLSectionFootnoteConfigImport.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XMLSectionFootnoteConfigImport.hxx,v $
*
- * $Revision: 1.1 $
+ * $Revision: 1.2 $
*
- * last change: $Author: dvo $ $Date: 2001-02-16 16:39:27 $
+ * last change: $Author: dvo $ $Date: 2001-04-17 12:01:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -68,11 +68,16 @@
#include "xmlictxt.hxx"
#endif
+#ifndef _UNIVERSALL_REFERENCE_HXX
+#include "uniref.hxx"
+#endif
+
#include <vector>
class SvXMLImport;
struct XMLPropertyState;
+class XMLPropertySetMapper;
namespace rtl { class OUString; }
namespace com { namespace sun { namespace star {
namespace uno { template<class X> class Reference; }
@@ -86,6 +91,7 @@ namespace com { namespace sun { namespace star {
class XMLSectionFootnoteConfigImport : public SvXMLImportContext
{
::std::vector<XMLPropertyState> & rProperties;
+ UniReference<XMLPropertySetMapper> rMapper;
sal_Int32 nPropIndex;
public:
@@ -97,8 +103,7 @@ public:
sal_uInt16 nPrefix,
const ::rtl::OUString& rLocalName,
::std::vector<XMLPropertyState> & rProperties,
- /// Careful: we use indices nIndex-6..nIndex; the correctness must be
- /// checked before calling the constructor
+ const UniReference<XMLPropertySetMapper> & rMapperRef,
sal_Int32 nIndex);
~XMLSectionFootnoteConfigImport();
diff --git a/xmloff/source/text/XMLTextPropertySetContext.cxx b/xmloff/source/text/XMLTextPropertySetContext.cxx
index 7c47422d77..a9c0428da2 100644
--- a/xmloff/source/text/XMLTextPropertySetContext.cxx
+++ b/xmloff/source/text/XMLTextPropertySetContext.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: XMLTextPropertySetContext.cxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.5 $
*
- * last change: $Author: dvo $ $Date: 2001-02-16 16:39:27 $
+ * last change: $Author: dvo $ $Date: 2001-04-17 12:01:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -161,58 +161,14 @@ SvXMLImportContext *XMLTextPropertySetContext::CreateChildContext(
rProperties );
break;
case CTF_SECTION_FOOTNOTE_END:
- DBG_ASSERT( rProp.mnIndex >= 7, "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_OWN ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-6 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_RESTART ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-5 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_RESTART_AT ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-4 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_TYPE ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-3 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_PREFIX ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-2 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_NUM_SUFFIX ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-1 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_FOOTNOTE_END ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex ), "invalid property map!");
- pContext =
- new XMLSectionFootnoteConfigImport(
- GetImport(), nPrefix, rLocalName, rProperties, rProp.mnIndex);
+ pContext = new XMLSectionFootnoteConfigImport(
+ GetImport(), nPrefix, rLocalName, rProperties,
+ xMapper->getPropertySetMapper(), rProp.mnIndex);
break;
case CTF_SECTION_ENDNOTE_END:
- DBG_ASSERT( rProp.mnIndex >= 7, "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_OWN ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-6 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_RESTART ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-5 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_RESTART_AT ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-4 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_TYPE ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-3 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_PREFIX ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-2 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_NUM_SUFFIX ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex-1 ), "invalid property map!");
- DBG_ASSERT( CTF_SECTION_ENDNOTE_END ==
- xMapper->getPropertySetMapper()->GetEntryContextId(
- rProp.mnIndex ), "invalid property map!");
- pContext =
- new XMLSectionFootnoteConfigImport(
- GetImport(), nPrefix, rLocalName, rProperties, rProp.mnIndex);
+ pContext = new XMLSectionFootnoteConfigImport(
+ GetImport(), nPrefix, rLocalName, rProperties,
+ xMapper->getPropertySetMapper(), rProp.mnIndex);
break;
}