#80284# XML im-/export continued
- changed: section and TOC im-/export restructured to accomodate indices - added: im-/export of all index types (implemented but disabled due to API problems) - changed: auto style Add(), Find() made public on txtparae.hxx - changed: text:section-source-dde into office:dde-source - changed: dde attribute names now use standard terminology
This commit is contained in:
@@ -2,9 +2,9 @@
|
||||
*
|
||||
* $RCSfile: XMLIndexTOCSourceContext.cxx,v $
|
||||
*
|
||||
* $Revision: 1.1 $
|
||||
* $Revision: 1.2 $
|
||||
*
|
||||
* last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $
|
||||
* last change: $Author: dvo $ $Date: 2000-11-14 14:42:50 $
|
||||
*
|
||||
* The Contents of this file are made available subject to the terms of
|
||||
* either of the following licenses
|
||||
@@ -134,26 +134,23 @@ const sal_Char sAPI_CreateFromOutline[] = "CreateFromOutline";
|
||||
const sal_Char sAPI_CreateFromMarks[] = "CreateFromMarks";
|
||||
const sal_Char sAPI_Level[] = "Level";
|
||||
|
||||
TYPEINIT1( XMLIndexTOCSourceContext, SvXMLImportContext );
|
||||
TYPEINIT1( XMLIndexTOCSourceContext, XMLIndexSourceBaseContext );
|
||||
|
||||
XMLIndexTOCSourceContext::XMLIndexTOCSourceContext(
|
||||
SvXMLImport& rImport,
|
||||
sal_uInt16 nPrfx,
|
||||
const OUString& rLocalName,
|
||||
Reference<XPropertySet> & rPropSet) :
|
||||
SvXMLImportContext(rImport, nPrfx, rLocalName),
|
||||
rTOCPropertySet(rPropSet),
|
||||
XMLIndexSourceBaseContext(rImport, nPrfx, rLocalName,
|
||||
rPropSet, sal_True),
|
||||
// use all chapters by default
|
||||
nOutlineLevel(rImport.GetTextImport()->GetChapterNumbering()->
|
||||
getCount()),
|
||||
bUseOutline(sal_True),
|
||||
bUseMarks(sal_True),
|
||||
bChapterIndex(sal_False),
|
||||
bRelativeTabs(sal_True),
|
||||
sCreateFromMarks(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromMarks)),
|
||||
sLevel(RTL_CONSTASCII_USTRINGPARAM(sAPI_Level)),
|
||||
sCreateFromChapter(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromChapter)),
|
||||
sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromOutline))
|
||||
sCreateFromOutline(RTL_CONSTASCII_USTRINGPARAM(sAPI_CreateFromOutline))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -161,92 +158,44 @@ XMLIndexTOCSourceContext::~XMLIndexTOCSourceContext()
|
||||
{
|
||||
}
|
||||
|
||||
enum IndexTOCSourceTokenEnum
|
||||
void XMLIndexTOCSourceContext::ProcessAttribute(
|
||||
enum IndexSourceParamEnum eParam,
|
||||
const OUString& rValue)
|
||||
{
|
||||
XML_TOK_TOCSOURCE_OUTLINE_LEVEL,
|
||||
XML_TOK_TOCSOURCE_USE_INDEX_MARKS,
|
||||
XML_TOK_TOCSOURCE_INDEX_SCOPE,
|
||||
XML_TOK_TOCSOURCE_RELATIVE_TABS
|
||||
};
|
||||
|
||||
static __FAR_DATA SvXMLTokenMapEntry aIndexTOCSourceTokenMap[] =
|
||||
{
|
||||
{ XML_NAMESPACE_TEXT, sXML_outline_level, XML_TOK_TOCSOURCE_OUTLINE_LEVEL},
|
||||
{ XML_NAMESPACE_TEXT, sXML_use_index_marks,
|
||||
XML_TOK_TOCSOURCE_USE_INDEX_MARKS },
|
||||
{ XML_NAMESPACE_TEXT, sXML_index_scope, XML_TOK_TOCSOURCE_INDEX_SCOPE },
|
||||
{ XML_NAMESPACE_TEXT, sXML_relative_tab_stop_position,
|
||||
XML_TOK_TOCSOURCE_RELATIVE_TABS } ,
|
||||
XML_TOKEN_MAP_END
|
||||
};
|
||||
|
||||
void XMLIndexTOCSourceContext::StartElement(
|
||||
const Reference<XAttributeList> & xAttrList)
|
||||
{
|
||||
SvXMLTokenMap aTokenMap(aIndexTOCSourceTokenMap);
|
||||
|
||||
// process attributes
|
||||
sal_Int32 nLength = xAttrList->getLength();
|
||||
for(sal_Int32 i=0; i<nLength; i++)
|
||||
switch (eParam)
|
||||
{
|
||||
case XML_TOK_INDEXSOURCE_OUTLINE_LEVEL:
|
||||
if (rValue.equalsAsciiL(sXML_none, sizeof(sXML_none)-1))
|
||||
{
|
||||
bUseOutline = sal_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int32 nTmp;
|
||||
if (SvXMLUnitConverter::convertNumber(
|
||||
nTmp, rValue, 1, GetImport().GetTextImport()->
|
||||
GetChapterNumbering()->getCount()))
|
||||
{
|
||||
bUseOutline = sal_True;
|
||||
nOutlineLevel = nTmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
OUString sLocalName;
|
||||
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().
|
||||
GetKeyByAttrName( xAttrList->getNameByIndex(i), &sLocalName );
|
||||
|
||||
OUString sAttr = xAttrList->getValueByIndex(i);
|
||||
|
||||
switch (aTokenMap.Get(nPrefix, sLocalName))
|
||||
case XML_TOK_INDEXSOURCE_USE_INDEX_MARKS:
|
||||
{
|
||||
case XML_TOK_TOCSOURCE_OUTLINE_LEVEL:
|
||||
if (sAttr.equalsAsciiL(sXML_none, sizeof(sXML_none)-1))
|
||||
{
|
||||
bUseOutline = sal_False;
|
||||
}
|
||||
else
|
||||
{
|
||||
sal_Int32 nTmp;
|
||||
if (SvXMLUnitConverter::convertNumber(
|
||||
nTmp, sAttr, 1, GetImport().GetTextImport()->
|
||||
GetChapterNumbering()->getCount()))
|
||||
{
|
||||
bUseOutline = sal_True;
|
||||
nOutlineLevel = nTmp;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case XML_TOK_TOCSOURCE_USE_INDEX_MARKS:
|
||||
sal_Bool bTmp;
|
||||
if (SvXMLUnitConverter::convertBool(bTmp, rValue))
|
||||
{
|
||||
sal_Bool bTmp;
|
||||
if (SvXMLUnitConverter::convertBool(bTmp, sAttr))
|
||||
{
|
||||
bUseMarks = bTmp;
|
||||
}
|
||||
break;
|
||||
bUseMarks = bTmp;
|
||||
}
|
||||
|
||||
case XML_TOK_TOCSOURCE_INDEX_SCOPE:
|
||||
if (sAttr.equalsAsciiL(sXML_chapter, sizeof(sXML_chapter)-1))
|
||||
{
|
||||
bChapterIndex = sal_True;
|
||||
}
|
||||
break;
|
||||
|
||||
case XML_TOK_TOCSOURCE_RELATIVE_TABS:
|
||||
{
|
||||
sal_Bool bTmp;
|
||||
if (SvXMLUnitConverter::convertBool(bTmp, sAttr))
|
||||
{
|
||||
bRelativeTabs = bTmp;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// unknown attribute -> ignore
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// default: ask superclass
|
||||
XMLIndexSourceBaseContext::ProcessAttribute(eParam, rValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -254,62 +203,37 @@ void XMLIndexTOCSourceContext::EndElement()
|
||||
{
|
||||
Any aAny;
|
||||
|
||||
aAny.setValue(&bRelativeTabs, ::getBooleanCppuType());
|
||||
// rTOCPropertySet->setPropertyValue(s..., aAny);
|
||||
|
||||
aAny.setValue(&bChapterIndex, ::getBooleanCppuType());
|
||||
rTOCPropertySet->setPropertyValue(sCreateFromChapter, aAny);
|
||||
|
||||
aAny.setValue(&bUseMarks, ::getBooleanCppuType());
|
||||
rTOCPropertySet->setPropertyValue(sCreateFromMarks, aAny);
|
||||
rIndexPropertySet->setPropertyValue(sCreateFromMarks, aAny);
|
||||
|
||||
aAny.setValue(&bUseOutline, ::getBooleanCppuType());
|
||||
rTOCPropertySet->setPropertyValue(sCreateFromOutline, aAny);
|
||||
rIndexPropertySet->setPropertyValue(sCreateFromOutline, aAny);
|
||||
|
||||
aAny <<= (sal_Int16)nOutlineLevel;
|
||||
rTOCPropertySet->setPropertyValue(sLevel, aAny);
|
||||
rIndexPropertySet->setPropertyValue(sLevel, aAny);
|
||||
}
|
||||
|
||||
|
||||
SvXMLImportContext* XMLIndexTOCSourceContext::CreateChildContext(
|
||||
sal_uInt16 nPrefix,
|
||||
const OUString& rLocalName,
|
||||
const Reference<XAttributeList> & xAttrList )
|
||||
{
|
||||
SvXMLImportContext* pContext = NULL;
|
||||
|
||||
if (XML_NAMESPACE_TEXT == nPrefix)
|
||||
if ( (XML_NAMESPACE_TEXT == nPrefix) &&
|
||||
(rLocalName.equalsAsciiL(sXML_table_of_content_entry_template,
|
||||
sizeof(sXML_table_of_content_entry_template)-1)))
|
||||
{
|
||||
if (rLocalName.equalsAsciiL(sXML_index_entry_template,
|
||||
sizeof(sXML_index_entry_template)-1))
|
||||
{
|
||||
pContext = new XMLIndexTemplateContext(GetImport(),
|
||||
rTOCPropertySet,
|
||||
nPrefix, rLocalName);
|
||||
}
|
||||
else if (rLocalName.equalsAsciiL(sXML_index_title_template,
|
||||
sizeof(sXML_index_title_template)-1))
|
||||
{
|
||||
pContext = new XMLIndexTitleTemplateContext(GetImport(),
|
||||
rTOCPropertySet,
|
||||
nPrefix, rLocalName);
|
||||
}
|
||||
else if (rLocalName.equalsAsciiL(sXML_index_source_styles,
|
||||
sizeof(sXML_index_source_styles)-1))
|
||||
{
|
||||
pContext = new XMLIndexTOCStylesContext(GetImport(),
|
||||
rTOCPropertySet,
|
||||
nPrefix, rLocalName);
|
||||
}
|
||||
// else: unknown element in text namespace -> ignore
|
||||
return new XMLIndexTemplateContext(GetImport(), rIndexPropertySet,
|
||||
nPrefix, rLocalName,
|
||||
aLevelNameTOCMap,
|
||||
sXML_outline_level,
|
||||
aLevelStylePropNameTOCMap,
|
||||
aAllowedTokenTypesTOC);
|
||||
}
|
||||
// else: unknown namespace -> ignore
|
||||
|
||||
// use default namespace
|
||||
if (pContext == NULL)
|
||||
else
|
||||
{
|
||||
pContext = SvXMLImportContext::CreateChildContext(nPrefix, rLocalName,
|
||||
xAttrList);
|
||||
return XMLIndexSourceBaseContext::CreateChildContext(nPrefix,
|
||||
rLocalName,
|
||||
xAttrList);
|
||||
}
|
||||
|
||||
return pContext;
|
||||
}
|
||||
|
Reference in New Issue
Block a user