diff options
Diffstat (limited to 'xmloff/source')
-rw-r--r-- | xmloff/source/style/xmlstyle.cxx | 14 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx | 323 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexBibliographyEntryContext.cxx | 6 | ||||
-rw-r--r-- | xmloff/source/text/XMLIndexBibliographyEntryContext.hxx | 7 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionExport.cxx | 269 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionExport.hxx | 35 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionImportContext.cxx | 35 | ||||
-rw-r--r-- | xmloff/source/text/XMLSectionImportContext.hxx | 8 | ||||
-rw-r--r-- | xmloff/source/text/makefile.mk | 6 | ||||
-rw-r--r-- | xmloff/source/text/txtimp.cxx | 8 | ||||
-rw-r--r-- | xmloff/source/text/txtstyle.cxx | 8 |
11 files changed, 634 insertions, 85 deletions
diff --git a/xmloff/source/style/xmlstyle.cxx b/xmloff/source/style/xmlstyle.cxx index 51fb5cc8278c..f3863f21df2c 100644 --- a/xmloff/source/style/xmlstyle.cxx +++ b/xmloff/source/style/xmlstyle.cxx @@ -2,9 +2,9 @@ * * $RCSfile: xmlstyle.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: cl $ $Date: 2000-11-28 14:25:18 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:39 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -167,6 +167,9 @@ #ifndef _XMLOFF_XMLFOOTNOTECONFIGURATIONIMPORTCONTEXT_HXX #include "XMLFootnoteConfigurationImportContext.hxx" #endif +#ifndef _XMLOFF_XMLINDEXBIBLIOGRAPHYCONFIGURATIONCONTEXT_HXX_ +#include "XMLIndexBibliographyConfigurationContext.hxx" +#endif #ifndef _XMLOFF_PAGEMASTERIMPORTCONTEXT_HXX #include "PageMasterImportContext.hxx" #endif @@ -198,6 +201,8 @@ static __FAR_DATA SvXMLTokenMapEntry aStyleStylesElemTokenMap[] = XML_TOK_TEXT_FOOTNOTE_CONFIG }, { XML_NAMESPACE_TEXT, sXML_endnotes_configuration, XML_TOK_TEXT_ENDNOTE_CONFIG }, + { XML_NAMESPACE_TEXT, sXML_bibliography_configuration, + XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG }, XML_TOKEN_MAP_END }; @@ -571,6 +576,11 @@ SvXMLStyleContext *SvXMLStylesContext::CreateStyleChildContext( xAttrList, sal_True); break; + case XML_TOK_TEXT_BIBLIOGRAPHY_CONFIG: + pStyle = new XMLIndexBibliographyConfigurationContext( + GetImport(), nPrefix, rLocalName, xAttrList); + break; + // // FillStyles // diff --git a/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx new file mode 100644 index 000000000000..0320ee9df6f8 --- /dev/null +++ b/xmloff/source/text/XMLIndexBibliographyConfigurationContext.cxx @@ -0,0 +1,323 @@ +/************************************************************************* + * + * $RCSfile: XMLIndexBibliographyConfigurationContext.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * 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. + * + * 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. + * + * 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 + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (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.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + + +#ifndef _XMLOFF_XMLINDEXBIBLIOGRAPHYCONFIGURATIONCONTEXT_HXX_ +#include "XMLIndexBibliographyConfigurationContext.hxx" +#endif + +#ifndef _XMLOFF_XMLINDEXBIBLIOGRAPHYENTRYCONTEXT_HXX_ +#include "XMLIndexBibliographyEntryContext.hxx" +#endif + +#ifndef _XMLOFF_XMLICTXT_HXX +#include "xmlictxt.hxx" +#endif + +#ifndef _XMLOFF_XMLIMP_HXX +#include "xmlimp.hxx" +#endif + +#ifndef _XMLOFF_TEXTIMP_HXX_ +#include "txtimp.hxx" +#endif + +#ifndef _XMLOFF_NMSPMAP_HXX +#include "nmspmap.hxx" +#endif + +#ifndef _XMLOFF_XMLNMSPE_HXX +#include "xmlnmspe.hxx" +#endif + +#ifndef _XMLOFF_XMLKYWD_HXX +#include "xmlkywd.hxx" +#endif + +#ifndef _XMLOFF_XMLUCONV_HXX +#include "xmluconv.hxx" +#endif + +#ifndef _TOOLS_DEBUG_HXX +#include <tools/debug.hxx> +#endif + +#ifndef _RTL_USTRING_HXX_ +#include <rtl/ustring.hxx> +#endif + +#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_ +#include <com/sun/star/beans/XPropertySet.hpp> +#endif + +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +using namespace ::com::sun::star::text; +using namespace ::com::sun::star::uno; + +using ::rtl::OUString; +using ::com::sun::star::xml::sax::XAttributeList; +using ::com::sun::star::beans::PropertyValue; +using ::com::sun::star::beans::XPropertySet; +using ::com::sun::star::lang::XMultiServiceFactory; + +const sal_Char sAPI_FieldMaster_Bibliography[] = + "com.sun.star.text.FieldMaster.Bibliography"; + + +TYPEINIT1( XMLIndexBibliographyConfigurationContext, SvXMLStyleContext ); + +XMLIndexBibliographyConfigurationContext::XMLIndexBibliographyConfigurationContext( + SvXMLImport& rImport, + sal_uInt16 nPrfx, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList) : + SvXMLStyleContext(rImport, nPrfx, rLocalName, xAttrList), + sFieldMaster_Bibliography( + RTL_CONSTASCII_USTRINGPARAM(sAPI_FieldMaster_Bibliography)), + sBracketBefore(RTL_CONSTASCII_USTRINGPARAM("BracketBefore")), + sBracketAfter(RTL_CONSTASCII_USTRINGPARAM("BracketAfter")), + sIsNumberEntries(RTL_CONSTASCII_USTRINGPARAM("IsNumberEntries")), + sIsSortByPosition(RTL_CONSTASCII_USTRINGPARAM("IsSortByPosition")), + sSortKeys(RTL_CONSTASCII_USTRINGPARAM("SortKeys")), + sSortKey(RTL_CONSTASCII_USTRINGPARAM("SortKey")), + sIsSortAscending(RTL_CONSTASCII_USTRINGPARAM("IsSortAscending")), + sSuffix(), + sPrefix(), + bNumberedEntries(sal_False), + bSortByPosition(sal_True) +{ + SetFamily(XML_STYLE_FAMILY_TEXT_BIBLIOGRAPHYCONFIG); +} + +XMLIndexBibliographyConfigurationContext::~XMLIndexBibliographyConfigurationContext() +{ +} + +void XMLIndexBibliographyConfigurationContext::StartElement( + const Reference<XAttributeList> & xAttrList) +{ + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrefix = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + + if (nPrefix == XML_NAMESPACE_TEXT) + { + ProcessAttribute(sLocalName, xAttrList->getValueByIndex(nAttr)); + } + // else: ignore + } +} + +void XMLIndexBibliographyConfigurationContext::ProcessAttribute( + OUString sLocalName, + OUString sValue) +{ + if (sLocalName.equalsAsciiL(sXML_prefix, sizeof(sXML_prefix)-1)) + { + sPrefix = sValue; + } + else if (sLocalName.equalsAsciiL(sXML_suffix, sizeof(sXML_suffix)-1)) + { + sSuffix = sValue; + } + else if (sLocalName.equalsAsciiL(sXML_numbered_entries, + sizeof(sXML_numbered_entries)-1)) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, sValue)) + { + bNumberedEntries = bTmp; + } + } + else if (sLocalName.equalsAsciiL(sXML_sort_by_position, + sizeof(sXML_sort_by_position)-1)) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool(bTmp, sValue)) + { + bSortByPosition = bTmp; + } + } +} + + +SvXMLImportContext *XMLIndexBibliographyConfigurationContext::CreateChildContext( + sal_uInt16 nPrefix, + const OUString& rLocalName, + const Reference<XAttributeList> & xAttrList ) +{ + OUString sKey; + sal_Bool bSort(sal_True); + + // process children here and use default context! + if ((nPrefix == XML_NAMESPACE_TEXT) && + rLocalName.equalsAsciiL(sXML_sort_key, sizeof(sXML_sort_key)-1)) + { + sal_Int32 nLength = xAttrList->getLength(); + for(sal_Int32 nAttr = 0; nAttr < nLength; nAttr++) + { + OUString sLocalName; + sal_uInt16 nPrfx = GetImport().GetNamespaceMap(). + GetKeyByAttrName( xAttrList->getNameByIndex(nAttr), + &sLocalName ); + + if (nPrfx == XML_NAMESPACE_TEXT) + { + if (sLocalName.equalsAsciiL(sXML_key, sizeof(sXML_key)-1)) + { + sKey = xAttrList->getValueByIndex(nAttr); + } + else if (sLocalName.equalsAsciiL(sXML_sort_ascending, + sizeof(sXML_sort_ascending)-1)) + { + sal_Bool bTmp; + if (SvXMLUnitConverter::convertBool( + bTmp, xAttrList->getValueByIndex(nAttr))) + { + bSort = bTmp; + } + } + } + } + + // valid data? + sal_uInt16 nKey; + if (SvXMLUnitConverter::convertEnum(nKey, sKey, + aBibliographyDataFieldMap)) + { + + Any aAny; + Sequence<PropertyValue> aKey(2); + + PropertyValue aNameValue; + aNameValue.Name = sSortKey; + aAny <<= (sal_Int16)nKey; + aNameValue.Value = aAny; + aKey[0] = aNameValue; + + PropertyValue aSortValue; + aSortValue.Name = sIsSortAscending; + aAny.setValue(&bSort, ::getBooleanCppuType()); + aSortValue.Value = aAny; + aKey[1] = aSortValue; + + aSortKeys.push_back(aKey); + } + } + + return SvXMLImportContext::CreateChildContext(nPrefix, rLocalName, + xAttrList); +} + +void XMLIndexBibliographyConfigurationContext::EndElement() +{ + // (code almost the same as export...) + + // first: get field master + // (we'll create one, and get the only master for this type) + Reference<XMultiServiceFactory> xFactory(GetImport().GetModel(),UNO_QUERY); + if( xFactory.is() ) + { + Reference<XInterface> xIfc = + xFactory->createInstance(sFieldMaster_Bibliography); + if( xIfc.is() ) + { + Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); + Any aAny; + + if (sSuffix.getLength() > 0) + { + aAny <<= sSuffix; + xPropSet->setPropertyValue(sBracketAfter, aAny); + } + + if (sPrefix.getLength() > 0) + { + aAny <<= sPrefix; + xPropSet->setPropertyValue(sBracketBefore, aAny); + } + + aAny.setValue(&bNumberedEntries, ::getBooleanCppuType()); + xPropSet->setPropertyValue(sIsNumberEntries, aAny); + + aAny.setValue(&bSortByPosition, ::getBooleanCppuType()); + xPropSet->setPropertyValue(sIsSortByPosition, aAny); + + sal_Int32 nCount = aSortKeys.size(); + Sequence<Sequence<PropertyValue> > aKeysSeq(nCount); + for(sal_Int32 i = 0; i < nCount; i++) + { + aKeysSeq[i] = aSortKeys[i]; + } + aAny <<= aKeysSeq; + xPropSet->setPropertyValue(sSortKeys, aAny); + } + // else: can't get FieldMaster -> ignore + } + // else: can't even get Factory -> ignore +} diff --git a/xmloff/source/text/XMLIndexBibliographyEntryContext.cxx b/xmloff/source/text/XMLIndexBibliographyEntryContext.cxx index 324064a00ae5..db2c232726e5 100644 --- a/xmloff/source/text/XMLIndexBibliographyEntryContext.cxx +++ b/xmloff/source/text/XMLIndexBibliographyEntryContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLIndexBibliographyEntryContext.cxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: dvo $ $Date: 2000-11-14 14:42:50 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -135,7 +135,7 @@ XMLIndexBibliographyEntryContext::~XMLIndexBibliographyEntryContext() { } -SvXMLEnumMapEntry __READONLY_DATA aBibliographyDataFieldMap[] = +static const SvXMLEnumMapEntry aBibliographyDataFieldMap[] = { { sXML_address, BibliographyDataField::ADDRESS }, { sXML_annote, BibliographyDataField::ANNOTE }, diff --git a/xmloff/source/text/XMLIndexBibliographyEntryContext.hxx b/xmloff/source/text/XMLIndexBibliographyEntryContext.hxx index 52958be7657c..e1516236f618 100644 --- a/xmloff/source/text/XMLIndexBibliographyEntryContext.hxx +++ b/xmloff/source/text/XMLIndexBibliographyEntryContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLIndexBibliographyEntryContext.hxx,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: dvo $ $Date: 2000-11-14 14:42:50 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -84,6 +84,9 @@ namespace com { namespace sun { namespace star { } } } namespace rtl { class OUString; } class XMLIndexTemplateContext; +struct SvXMLEnumMapEntry; + +extern const SvXMLEnumMapEntry aBibliographyDataFieldMap[]; /** * Import bibliography index entry templates diff --git a/xmloff/source/text/XMLSectionExport.cxx b/xmloff/source/text/XMLSectionExport.cxx index ce11bdba4d24..e4b6582692f7 100644 --- a/xmloff/source/text/XMLSectionExport.cxx +++ b/xmloff/source/text/XMLSectionExport.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionExport.cxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -124,6 +124,14 @@ #include <com/sun/star/text/XDocumentIndex.hpp> #endif +#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_ +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#endif + +#ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ +#include <com/sun/star/uno/XInterface.hpp> +#endif + #ifndef _COM_SUN_STAR_TEXT_BIBLIOGRAPHYDATAFIELD_HPP_ #include <com/sun/star/text/BibliographyDataField.hpp> #endif @@ -178,6 +186,8 @@ using ::com::sun::star::beans::PropertyState; using ::com::sun::star::container::XIndexReplace; using ::com::sun::star::container::XNamed; using ::com::sun::star::lang::XServiceInfo; +using ::com::sun::star::lang::XMultiServiceFactory; +using ::com::sun::star::uno::XInterface; @@ -237,6 +247,7 @@ XMLSectionExport::XMLSectionExport( RTL_CONSTASCII_USTRINGPARAM("CreateFromLevelParagraphStyles")), sDocumentIndex(RTL_CONSTASCII_USTRINGPARAM("DocumentIndex")), sContentSection(RTL_CONSTASCII_USTRINGPARAM("ContentSection")), + sHeaderSection(RTL_CONSTASCII_USTRINGPARAM("HeaderSection")), sTableOfContent(RTL_CONSTASCII_USTRINGPARAM(sXML_table_of_content)), sIllustrationIndex(RTL_CONSTASCII_USTRINGPARAM(sXML_illustration_index)), sAlphabeticalIndex(RTL_CONSTASCII_USTRINGPARAM(sXML_alphabetical_index)), @@ -245,6 +256,7 @@ XMLSectionExport::XMLSectionExport( sBibliography(RTL_CONSTASCII_USTRINGPARAM(sXML_bibliography)), sUserIndex(RTL_CONSTASCII_USTRINGPARAM(sXML_user_index)), sIndexBody(RTL_CONSTASCII_USTRINGPARAM(sXML_index_body)), + sIndexTitle(RTL_CONSTASCII_USTRINGPARAM(sXML_index_title)), sEmpty() { } @@ -271,11 +283,18 @@ void XMLSectionExport::ExportSectionStart( // export index or regular section Reference<XDocumentIndex> xIndex; - GetIndex(rSection, xIndex); - if (xIndex.is()) + if (GetIndex(rSection, xIndex)) { - // we are an index - ExportIndexStart(xIndex); + if (xIndex.is()) + { + // we are an index + ExportIndexStart(xIndex); + } + else + { + // we are an index header + ExportIndexHeaderStart(rSection); + } } else { @@ -285,11 +304,12 @@ void XMLSectionExport::ExportSectionStart( } } -void XMLSectionExport::GetIndex( +sal_Bool XMLSectionExport::GetIndex( const Reference<XTextSection> & rSection, Reference<XDocumentIndex> & rIndex) { // first, reset result + sal_Bool bRet = sal_False; rIndex = NULL; // get section Properties @@ -316,12 +336,27 @@ void XMLSectionExport::GetIndex( if (rSection == xEnclosingSection) { rIndex = xDocumentIndex; + bRet = sal_True; + } + // else: index header or regular section + + // is the enclosing index identical with the header section? + aAny = xIndexPropSet->getPropertyValue(sHeaderSection); + // now mis-named: contains header section + aAny >>= xEnclosingSection; + + // if the enclosing section is "our" section, then we are an index! + if (rSection == xEnclosingSection) + { + bRet = sal_True; } - // else: we are no index + // else: regular section } // else: we aren't even inside of an index } // else: we don't even know what an index is. + + return bRet; } @@ -336,51 +371,58 @@ void XMLSectionExport::ExportSectionEnd( // export index or regular section end Reference<XDocumentIndex> xIndex; - GetIndex(rSection, xIndex); - if (xIndex.is()) + if (GetIndex(rSection, xIndex)) { - - // index end: close index body element - GetExport().GetDocHandler()->ignorableWhitespace(GetExport().sWS); - GetExport().GetDocHandler()->endElement( - GetExport().GetNamespaceMap().GetQNameByKey( - XML_NAMESPACE_TEXT, sIndexBody)); - GetExport().GetDocHandler()->ignorableWhitespace(GetExport().sWS); - - switch (MapSectionType(xIndex->getServiceName())) + if (xIndex.is()) { - case TEXT_SECTION_TYPE_TOC: - pElementName = sXML_table_of_content; - break; - - case TEXT_SECTION_TYPE_ILLUSTRATION: - pElementName = sXML_illustration_index; - break; - - case TEXT_SECTION_TYPE_ALPHABETICAL: - pElementName = sXML_alphabetical_index; - break; - - case TEXT_SECTION_TYPE_TABLE: - pElementName = sXML_table_index; - break; - - case TEXT_SECTION_TYPE_OBJECT: - pElementName = sXML_object_index; - break; - - case TEXT_SECTION_TYPE_USER: - pElementName = sXML_user_index; - break; - - case TEXT_SECTION_TYPE_BIBLIOGRAPHY: - pElementName = sXML_bibliography; - break; - - default: - DBG_ERROR("unknown index type"); - // default: skip index! - break; + // index end: close index body element + GetExport().GetDocHandler()->ignorableWhitespace( + GetExport().sWS); + GetExport().GetDocHandler()->endElement( + GetExport().GetNamespaceMap().GetQNameByKey( + XML_NAMESPACE_TEXT, sIndexBody)); + GetExport().GetDocHandler()->ignorableWhitespace( + GetExport().sWS); + + switch (MapSectionType(xIndex->getServiceName())) + { + case TEXT_SECTION_TYPE_TOC: + pElementName = sXML_table_of_content; + break; + + case TEXT_SECTION_TYPE_ILLUSTRATION: + pElementName = sXML_illustration_index; + break; + + case TEXT_SECTION_TYPE_ALPHABETICAL: + pElementName = sXML_alphabetical_index; + break; + + case TEXT_SECTION_TYPE_TABLE: + pElementName = sXML_table_index; + break; + + case TEXT_SECTION_TYPE_OBJECT: + pElementName = sXML_object_index; + break; + + case TEXT_SECTION_TYPE_USER: + pElementName = sXML_user_index; + break; + + case TEXT_SECTION_TYPE_BIBLIOGRAPHY: + pElementName = sXML_bibliography; + break; + + default: + DBG_ERROR("unknown index type"); + // default: skip index! + break; + } + } + else + { + pElementName = sXML_index_title; } } else @@ -452,6 +494,23 @@ void XMLSectionExport::ExportIndexStart( } } +void XMLSectionExport::ExportIndexHeaderStart( + const Reference<XTextSection> & rSection) +{ + // export name, dammit! + Reference<XNamed> xName(rSection, UNO_QUERY); + GetExport().AddAttribute(XML_NAMESPACE_TEXT, sXML_name, xName->getName()); + + // format already handled -> export only start element + GetExport().GetDocHandler()->ignorableWhitespace(GetExport().sWS); + GetExport().GetDocHandler()->startElement( + GetExport().GetNamespaceMap().GetQNameByKey(XML_NAMESPACE_TEXT, + sIndexTitle), + GetExport().GetXAttrList() ); + GetExport().GetDocHandler()->ignorableWhitespace(GetExport().sWS); + GetExport().ClearAttrList(); +} + SvXMLEnumMapEntry __READONLY_DATA aIndexTypeMap[] = { @@ -1517,3 +1576,111 @@ void XMLSectionExport::ExportBoolean( bDefault ? sXML_false : sXML_true); } } + +const sal_Char sAPI_FieldMaster_Bibliography[] = + "com.sun.star.text.FieldMaster.Bibliography"; +const sal_Char sAPI_SortKey[] = "SortKey"; +const sal_Char sAPI_IsSortAscending[] = "IsSortAscending"; + +void XMLSectionExport::ExportBibliographyConfiguration(SvXMLExport& rExport) +{ + // first: get field master + // (we'll create one, and get the only master for this type) + Reference<XMultiServiceFactory> xFactory(rExport.GetModel(),UNO_QUERY); + if( xFactory.is() ) + { + const OUString sFieldMaster_Bibliography( + RTL_CONSTASCII_USTRINGPARAM(sAPI_FieldMaster_Bibliography)); + + const OUString sBracketBefore( + RTL_CONSTASCII_USTRINGPARAM("BracketBefore")); + const OUString sBracketAfter( + RTL_CONSTASCII_USTRINGPARAM("BracketAfter")); + const OUString sIsNumberEntries( + RTL_CONSTASCII_USTRINGPARAM("IsNumberEntries")); + const OUString sIsSortByPosition( + RTL_CONSTASCII_USTRINGPARAM("IsSortByPosition")); + const OUString sSortKeys( + RTL_CONSTASCII_USTRINGPARAM("SortKeys")); + + Reference<XInterface> xIfc = + xFactory->createInstance(sFieldMaster_Bibliography); + if( xIfc.is() ) + { + Reference<XPropertySet> xPropSet( xIfc, UNO_QUERY ); + + Any aAny; + OUString sTmp; + + aAny = xPropSet->getPropertyValue(sBracketBefore); + aAny >>= sTmp; + rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_prefix, sTmp); + + aAny = xPropSet->getPropertyValue(sBracketAfter); + aAny >>= sTmp; + rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_suffix, sTmp); + + aAny = xPropSet->getPropertyValue(sIsNumberEntries); + if (*(sal_Bool*)aAny.getValue()) + { + rExport.AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_numbered_entries, sXML_true); + } + + aAny = xPropSet->getPropertyValue(sIsSortByPosition); + if (! *(sal_Bool*)aAny.getValue()) + { + rExport.AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_sort_by_position, sXML_false); + } + + // configuration elementXML_CONSTASCII_ACTION( sXML_suffix, "suffix" ); + + SvXMLElementExport aElement(rExport, XML_NAMESPACE_TEXT, + sXML_bibliography_configuration, + sal_True, sal_True); + + // sort keys + aAny = xPropSet->getPropertyValue(sSortKeys); + Sequence<Sequence<PropertyValue> > aKeys; + aAny >>= aKeys; + sal_Int32 nKeysCount = aKeys.getLength(); + for(sal_Int32 nKeys = 0; nKeys < nKeysCount; nKeys++) + { + Sequence<PropertyValue> & rKey = aKeys[nKeys]; + + sal_Int32 nKeyCount = rKey.getLength(); + for(sal_Int32 nKey = 0; nKey < nKeyCount; nKey++) + { + PropertyValue& rValue = rKey[nKey]; + + if (rValue.Name.equalsAsciiL(sAPI_SortKey, + sizeof(sAPI_SortKey)-1)) + { + sal_Int16 nKey; + rValue.Value >>= nKey; + OUStringBuffer sBuf; + if (SvXMLUnitConverter::convertEnum( sBuf, nKey, + aBibliographyDataFieldMap ) ) + { + rExport.AddAttribute(XML_NAMESPACE_TEXT, sXML_key, + sBuf.makeStringAndClear()); + } + } + else if (rValue.Name.equalsAsciiL(sAPI_IsSortAscending, + sizeof(sAPI_IsSortAscending)-1)) + { + sal_Bool bTmp = *(sal_Bool*)rValue.Value.getValue(); + rExport.AddAttributeASCII(XML_NAMESPACE_TEXT, + sXML_sort_ascending, + bTmp ? sXML_true : sXML_false); + } + } + + SvXMLElementExport aKeyElem(rExport, + XML_NAMESPACE_TEXT, sXML_sort_key, + sal_True, sal_True); + } + } + } +} diff --git a/xmloff/source/text/XMLSectionExport.hxx b/xmloff/source/text/XMLSectionExport.hxx index 0c756e22b3d0..d598b299a196 100644 --- a/xmloff/source/text/XMLSectionExport.hxx +++ b/xmloff/source/text/XMLSectionExport.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionExport.hxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -109,7 +109,7 @@ enum SectionTypeEnum TEXT_SECTION_TYPE_BIBLIOGRAPHY, // index header sections: - // todo + TEXT_SECTION_TYPE_HEADER, TEXT_SECTION_TYPE_UNKNOWN }; @@ -168,6 +168,7 @@ class XMLSectionExport const ::rtl::OUString sCreateFromLevelParagraphStyles; const ::rtl::OUString sDocumentIndex; const ::rtl::OUString sContentSection; + const ::rtl::OUString sHeaderSection; const ::rtl::OUString sTableOfContent; const ::rtl::OUString sIllustrationIndex; @@ -177,6 +178,7 @@ class XMLSectionExport const ::rtl::OUString sBibliography; const ::rtl::OUString sUserIndex; const ::rtl::OUString sIndexBody; + const ::rtl::OUString sIndexTitle; const ::rtl::OUString sEmpty; @@ -205,6 +207,13 @@ public: ::com::sun::star::text::XTextSection > & rSection, sal_Bool bAutoStyles); + /** + * Export the configuration element for bibliography indices. + * + * (This is part of XMLSectionExport because all section- and + * index-related items are handled here.) + */ + static void ExportBibliographyConfiguration(SvXMLExport& rExport); protected: @@ -213,11 +222,16 @@ protected: // export methods for section and index start: - /// export an index start element. This method is to be called + /// export an index start element. void ExportIndexStart( const ::com::sun::star::uno::Reference < ::com::sun::star::text::XDocumentIndex > & rSection); + /// export an index header start element. + void ExportIndexHeaderStart( + const ::com::sun::star::uno::Reference < + ::com::sun::star::text::XTextSection > & rSection); + /// export a proper section (and source elements) void ExportRegularSectionStart( const ::com::sun::star::uno::Reference < @@ -262,10 +276,15 @@ protected: // helper methods: /** - * If this section is an index, return the index; else return an - * empty reference. - */ - void GetIndex( + * If this section is an index, the index is written in the + * rIndex parameter. The return value is sal_True for all "special" + * sections. + * + * Thus we have: + * return sal_False: regular section + * return sal_True, xIndex is empty: index header section + * return sal_True, xIndex is set: index section */ + sal_Bool GetIndex( const ::com::sun::star::uno::Reference < ::com::sun::star::text::XTextSection > & rSection, ::com::sun::star::uno::Reference < diff --git a/xmloff/source/text/XMLSectionImportContext.cxx b/xmloff/source/text/XMLSectionImportContext.cxx index bc6841c9037d..ada310ffed6f 100644 --- a/xmloff/source/text/XMLSectionImportContext.cxx +++ b/xmloff/source/text/XMLSectionImportContext.cxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionImportContext.cxx,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -141,6 +141,7 @@ using namespace ::com::sun::star::text; TYPEINIT1( XMLSectionImportContext, SvXMLImportContext ); const sal_Char sAPI_TextSection[] = "com.sun.star.text.TextSection"; +const sal_Char sAPI_IndexHeaderSection[] = "com.sun.star.text.IndexHeaderSection"; const sal_Char sAPI_IsProtected[] = "IsProtected"; const sal_Char sAPI_Condition[] = "Condition"; const sal_Char sAPI_IsVisible[] = "IsVisible"; @@ -176,6 +177,8 @@ XMLSectionImportContext::XMLSectionImportContext( xEndRange(), xSectionPropertySet(), sTextSection(RTL_CONSTASCII_USTRINGPARAM(sAPI_TextSection)), + sIndexHeaderSection(RTL_CONSTASCII_USTRINGPARAM( + sAPI_IndexHeaderSection)), sCondition(RTL_CONSTASCII_USTRINGPARAM(sAPI_Condition)), sIsVisible(RTL_CONSTASCII_USTRINGPARAM(sAPI_IsVisible)), sStyleName(), @@ -198,6 +201,14 @@ void XMLSectionImportContext::StartElement( // process attributes ProcessAttributes(xAttrList); + // process index headers: + sal_Bool bIsIndexHeader = GetLocalName().equalsAsciiL( + sXML_index_title, sizeof(sXML_index_title)-1); + if (bIsIndexHeader) + { + bValid = sal_True; + } + UniReference<XMLTextImportHelper> rHelper = GetImport().GetTextImport(); // valid? @@ -209,7 +220,8 @@ void XMLSectionImportContext::StartElement( if (xFactory.is()) { Reference<XInterface> xIfc = - xFactory->createInstance( sTextSection ); + xFactory->createInstance( bIsIndexHeader ? sIndexHeaderSection + : sTextSection ); if (xIfc.is()) { Reference<XPropertySet> xPropSet(xIfc, UNO_QUERY); @@ -233,14 +245,17 @@ void XMLSectionImportContext::StartElement( } } - // IsVisible and condition - Any aAny; - aAny.setValue( &bIsVisible, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( sIsVisible, aAny ); - if (bCondOK) + // IsVisible and condition (not for index headers) + if (! bIsIndexHeader) { - aAny <<= sCond; - xPropSet->setPropertyValue( sCondition, aAny ); + Any aAny; + aAny.setValue( &bIsVisible, ::getBooleanCppuType() ); + xPropSet->setPropertyValue( sIsVisible, aAny ); + if (bCondOK) + { + aAny <<= sCond; + xPropSet->setPropertyValue( sCondition, aAny ); + } } // insert X, <paragraph>, X; then insert diff --git a/xmloff/source/text/XMLSectionImportContext.hxx b/xmloff/source/text/XMLSectionImportContext.hxx index 4d17948261ee..74078f3f30a5 100644 --- a/xmloff/source/text/XMLSectionImportContext.hxx +++ b/xmloff/source/text/XMLSectionImportContext.hxx @@ -2,9 +2,9 @@ * * $RCSfile: XMLSectionImportContext.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: dvo $ $Date: 2000-11-02 15:51:18 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -81,6 +81,9 @@ class XMLTextImportHelper; /** * Import text sections. + * + * This context may *also* be used for index header sections. The + * differentiates its behaviour based on GetLocalName(). */ class XMLSectionImportContext : public SvXMLImportContext { @@ -97,6 +100,7 @@ class XMLSectionImportContext : public SvXMLImportContext ::com::sun::star::beans::XPropertySet> xSectionPropertySet; const ::rtl::OUString sTextSection; + const ::rtl::OUString sIndexHeaderSection; const ::rtl::OUString sCondition; const ::rtl::OUString sIsVisible; const ::rtl::OUString sEmpty; diff --git a/xmloff/source/text/makefile.mk b/xmloff/source/text/makefile.mk index ff7efce0a77f..4dc69994295e 100644 --- a/xmloff/source/text/makefile.mk +++ b/xmloff/source/text/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.12 $ +# $Revision: 1.13 $ # -# last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ +# last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -97,6 +97,7 @@ CXXFILES = \ XMLFootnoteConfigurationImportContext.cxx \ XMLFootnoteImportContext.cxx \ XMLIndexAlphabeticalSourceContext.cxx \ + XMLIndexBibliographyConfigurationContext.cxx \ XMLIndexBibliographyEntryContext.cxx \ XMLIndexBibliographySourceContext.cxx \ XMLIndexBodyContext.cxx \ @@ -159,6 +160,7 @@ SLOFILES = \ $(SLO)$/XMLFootnoteImportContext.obj \ $(SLO)$/XMLIndexAlphabeticalSourceContext.obj \ $(SLO)$/XMLIndexBodyContext.obj \ + $(SLO)$/XMLIndexBibliographyConfigurationContext.obj \ $(SLO)$/XMLIndexBibliographyEntryContext.obj \ $(SLO)$/XMLIndexBibliographySourceContext.obj \ $(SLO)$/XMLIndexChapterInfoEntryContext.obj \ diff --git a/xmloff/source/text/txtimp.cxx b/xmloff/source/text/txtimp.cxx index 9f299011039a..0384b097693f 100644 --- a/xmloff/source/text/txtimp.cxx +++ b/xmloff/source/text/txtimp.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtimp.cxx,v $ * - * $Revision: 1.29 $ + * $Revision: 1.30 $ * - * last change: $Author: dvo $ $Date: 2000-11-30 16:46:20 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -214,7 +214,8 @@ static __FAR_DATA SvXMLTokenMapEntry aTextElemTokenMap[] = { XML_NAMESPACE_TEXT, sXML_illustration_index, XML_TOK_TEXT_ILLUSTRATION_INDEX }, { XML_NAMESPACE_TEXT, sXML_user_index, XML_TOK_TEXT_USER_INDEX }, { XML_NAMESPACE_TEXT, sXML_alphabetical_index, XML_TOK_TEXT_ALPHABETICAL_INDEX }, - { XML_NAMESPACE_TEXT, sXML_bibliography, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX }, + { XML_NAMESPACE_TEXT, sXML_bibliography, XML_TOK_TEXT_BIBLIOGRAPHY_INDEX }, + { XML_NAMESPACE_TEXT, sXML_index_title, XML_TOK_TEXT_INDEX_TITLE }, XML_TOKEN_MAP_END }; @@ -1085,6 +1086,7 @@ SvXMLImportContext *XMLTextImportHelper::CreateTextChildContext( } break; + case XML_TOK_TEXT_INDEX_TITLE: case XML_TOK_TEXT_SECTION: pContext = new XMLSectionImportContext( rImport, nPrefix, rLocalName ); break; diff --git a/xmloff/source/text/txtstyle.cxx b/xmloff/source/text/txtstyle.cxx index d49e051b30e4..2ae17f23a344 100644 --- a/xmloff/source/text/txtstyle.cxx +++ b/xmloff/source/text/txtstyle.cxx @@ -2,9 +2,9 @@ * * $RCSfile: txtstyle.cxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mib $ $Date: 2000-11-07 13:33:09 $ + * last change: $Author: dvo $ $Date: 2000-12-02 21:43:40 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -102,6 +102,9 @@ #ifndef _XMLOFF_XMLEXP_HXX #include "xmlexp.hxx" #endif +#ifndef _XMLOFF_XMLSECTIONEXPORT_HXX +#include "XMLSectionExport.hxx" +#endif #ifndef _XMLOFF_STYLEEXP_HXX //#include "styleexp.hxx" @@ -190,6 +193,7 @@ void XMLTextParagraphExport::exportTextStyles( sal_Bool bUsed ) bUsed, XML_STYLE_FAMILY_TEXT_FRAME ); exportNumStyles( bUsed ); exportTextFootnoteConfiguration(); + XMLSectionExport::ExportBibliographyConfiguration(GetExport()); } |