xmloff/inc/txtvfldi.hxx | 16 + xmloff/source/style/GradientStyle.cxx | 2 xmloff/source/text/XMLTextListBlockContext.cxx | 225 +++++++++++++++++++++++++ xmloff/source/text/XMLTextListBlockContext.hxx | 10 + xmloff/source/text/XMLTextListItemContext.cxx | 117 +++++++++++++ xmloff/source/text/XMLTextListItemContext.hxx | 10 + xmloff/source/text/txtvfldi.cxx | 155 +++++++++++++++++ 7 files changed, 533 insertions(+), 2 deletions(-)
New commits: commit 4b67e0c6f725851c90caab2af2fda8f8809b69b9 Author: Daniel Sikeler <[email protected]> Date: Fri Feb 13 09:21:12 2015 +0100 fix XMLGradientStyleImport::importXML Change-Id: If41fd5e0617768bc52e494c918048608f88d4334 diff --git a/xmloff/source/style/GradientStyle.cxx b/xmloff/source/style/GradientStyle.cxx index 26ec0b9..647cc1d 100644 --- a/xmloff/source/style/GradientStyle.cxx +++ b/xmloff/source/style/GradientStyle.cxx @@ -429,7 +429,7 @@ bool XMLGradientStyleImport::importXML( case XML_TOK_GRADIENT_ANGLE: { sal_Int32 nValue; - sax::Converter::convertNumber( nTmpValue, attr->Value, 0, 3600 ); + sax::Converter::convertNumber( nValue, attr->Value, 0, 3600 ); aGradient.Angle = sal_Int16( nValue ); } break; commit 99105e20cb5b32a676407699d1268e878ac3d623 Author: Daniel Sikeler <[email protected]> Date: Fri Feb 13 09:14:34 2015 +0100 XMLVariableDeclsImportContext impl. fast interface all methods implemented Change-Id: Ia1943c2de2034607a7cb1d4a26e2321c96aea53a diff --git a/xmloff/inc/txtvfldi.hxx b/xmloff/inc/txtvfldi.hxx index 6383260..86adcd6 100644 --- a/xmloff/inc/txtvfldi.hxx +++ b/xmloff/inc/txtvfldi.hxx @@ -473,12 +473,21 @@ public: sal_uInt16 nPrfx, /// namespace prefix const OUString& rLocalName, /// element name w/o prefix enum VarType eVarType); /// variable type + XMLVariableDeclsImportContext( + SvXMLImport& rImport, /// XML Import + XMLTextImportHelper& rHlp, /// text import helper + sal_Int32 Element, /// xml-tag specifier + enum VarType eVarType ); /// variable type virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList> & xAttrList ) SAL_OVERRIDE; + virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; }; /** diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index 948fe08..a4b0175 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -779,6 +779,15 @@ XMLVariableDeclsImportContext::XMLVariableDeclsImportContext( { } +XMLVariableDeclsImportContext::XMLVariableDeclsImportContext( + SvXMLImport& rImport, XMLTextImportHelper& rHlp, sal_Int32 /*Element*/, + enum VarType eVarType ) +: SvXMLImportContext( rImport ), + eVarDeclsContextType(eVarType), + rImportHelper(rHlp) +{ +} + SvXMLImportContext* XMLVariableDeclsImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const Reference<xml::sax::XAttributeList> & xAttrList ) @@ -823,8 +832,44 @@ SvXMLImportContext* XMLVariableDeclsImportContext::CreateChildContext( return pImportContext; } +Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLVariableDeclsImportContext::createFastChildContext( sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + sal_Int32 ElementToken = NAMESPACE | XML_NAMESPACE_TEXT; + Reference< xml::sax::XFastContextHandler > pImportContext = NULL; + switch( eVarDeclsContextType ) + { + case VarTypeSequence: + ElementToken = ElementToken | XML_sequence_decl; + break; + case VarTypeSimple: + ElementToken = ElementToken | XML_variable_decl; + break; + case VarTypeUserField: + ElementToken = ElementToken | XML_user_field_decl; + default: + OSL_FAIL("unknown field type!"); + ElementToken = ElementToken | XML_sequence_decl; + break; + } + + if( Element == ElementToken ) + { + pImportContext = new XMLVariableDeclImportContext( + GetImport(), rImportHelper, Element, xAttrList, eVarDeclsContextType ); + } + // if no context was created, use default context + if( !pImportContext.is() ) { + pImportContext = SvXMLImportContext::createFastChildContext( + Element, xAttrList ); + } + + return pImportContext; +} // declaration import (<variable/user-field/sequence-decl> elements) commit 388080679fd1695ecd090053709c7f4af7158508 Author: Daniel Sikeler <[email protected]> Date: Fri Feb 13 09:13:03 2015 +0100 XMLVariableDeclImportContext impl. fast interface all methods implemented Change-Id: Id4c6cc1966d682096911ebaa38bc434cb2033e50 diff --git a/xmloff/inc/txtvfldi.hxx b/xmloff/inc/txtvfldi.hxx index 276dc9b..6383260 100644 --- a/xmloff/inc/txtvfldi.hxx +++ b/xmloff/inc/txtvfldi.hxx @@ -509,6 +509,13 @@ public: const ::com::sun::star::uno::Reference< /// list of element attributes ::com::sun::star::xml::sax::XAttributeList> & xAttrList, enum VarType eVarType); /// variable type + XMLVariableDeclImportContext( + SvXMLImport& rImport, /// XML Import + XMLTextImportHelper& rHlp, /// text import helper + sal_Int32 Element, /// XML-tag specifier + const css::uno::Reference< /// list of element attributes + css::xml::sax::XFastAttributeList >& xAttrList, + enum VarType eVarType ); /// variable type /// get field master for name and rename if appropriate static bool FindFieldMaster(::com::sun::star::uno::Reference< diff --git a/xmloff/source/text/txtvfldi.cxx b/xmloff/source/text/txtvfldi.cxx index 89f4047..948fe08 100644 --- a/xmloff/source/text/txtvfldi.cxx +++ b/xmloff/source/text/txtvfldi.cxx @@ -32,6 +32,7 @@ #include <xmloff/xmlimp.hxx> #include <xmloff/xmluconv.hxx> #include <xmloff/xmlement.hxx> +#include <xmloff/token/tokens.hxx> #include <com/sun/star/text/SetVariableType.hpp> #include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/text/XDependentTextField.hpp> @@ -40,6 +41,7 @@ #include <com/sun/star/beans/XPropertySetInfo.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp> +#include <com/sun/star/xml/sax/FastToken.hpp> #include <sax/tools/converter.hxx> @@ -90,6 +92,8 @@ using namespace ::com::sun::star::beans; using namespace ::com::sun::star::text; using namespace ::com::sun::star::style; using namespace ::xmloff::token; +using namespace xmloff; +using css::xml::sax::FastToken::NAMESPACE; @@ -936,6 +940,110 @@ XMLVariableDeclImportContext::XMLVariableDeclImportContext( } // else: no sequence-decl } +XMLVariableDeclImportContext::XMLVariableDeclImportContext( + SvXMLImport& rImport, XMLTextImportHelper& rHlp, + sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList, + enum VarType eVarType ) +: SvXMLImportContext( rImport ), + // bug?? which properties for userfield/userfieldmaster + sPropertySubType(sAPI_sub_type), + sPropertyNumberingLevel(sAPI_chapter_numbering_level), + sPropertyNumberingSeparator(sAPI_numbering_separator), + sPropertyIsExpression(sAPI_is_expression), + aValueHelper(rImport, rHlp, true, false, true, false), + nNumLevel(-1), cSeparationChar('.') +{ + if( Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_sequence_decl) + || Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_variable_decl) + || Element == (NAMESPACE | XML_NAMESPACE_TEXT | XML_user_field_decl) ) + { + // TODO: check validity (need name!) + + // parse attributes + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + sal_uInt16 nToken = rHlp.GetTextFieldAttrTokenMap(). + Get( attribute.Token ); + + switch( nToken ) + { + case XML_TOK_TEXTFIELD_NAME: + sName = attribute.Value; + break; + case XML_TOK_TEXTFIELD_NUMBERING_LEVEL: + { + sal_Int32 nLevel; + bool const bRet = ::sax::Converter::convertNumber( + nLevel, attribute.Value, 0, + GetImport().GetTextImport()->GetChapterNumbering()-> + getCount() ); + + if( bRet ) + { + nNumLevel = static_cast< sal_Int8 >( nLevel-1 ); // API numbers -1..9 + } + break; + } + case XML_TOK_TEXTFIELD_NUMBERING_SEPARATOR: + cSeparationChar = + static_cast< sal_Char >( attribute.Value.toChar() ); + break; + default: + // delegate to value helper + aValueHelper.ProcessAttribute( nToken, attribute.Value ); + break; + } + } + + Reference<XPropertySet> xFieldMaster; + if( FindFieldMaster(xFieldMaster, GetImport(), rHlp, + sName, eVarType)) + { + // now we have a field master: process attributes! + Any aAny; + + switch( eVarType ) + { + case VarTypeSequence: + aAny <<= nNumLevel; + xFieldMaster->setPropertyValue(sPropertyNumberingLevel, aAny); + + if( nNumLevel >= 0 ) + { + OUString sStr(&cSeparationChar, 1); + aAny <<= sStr; + xFieldMaster->setPropertyValue( + sPropertyNumberingSeparator, aAny); + } + break; + case VarTypeSimple: + { + // set string or non-string SubType (#93192#) + // The SubType was already set in the FindFieldMaster + // method, but it needs to be adjusted if it's a string. + aAny <<= aValueHelper.IsStringValue() + ? SetVariableType::STRING : SetVariableType::VAR; + xFieldMaster->setPropertyValue(sPropertySubType, aAny); + } + break; + case VarTypeUserField: + { + sal_Bool bTmp = !aValueHelper.IsStringValue(); + aAny.setValue(&bTmp, ::getBooleanCppuType()); + xFieldMaster->setPropertyValue(sPropertyIsExpression, aAny); + aValueHelper.PrepareField(xFieldMaster); + break; + } + default: + OSL_FAIL("unknown varfield type"); + } // switch + } // else: no field master found/constructed + } // else: no sequence-decl +} + + bool XMLVariableDeclImportContext::FindFieldMaster( @@ -1241,7 +1349,7 @@ static SvXMLEnumMapEntry const aValueTypeMap[] = { XML_TIME, XML_VALUE_TYPE_TIME }, { XML_BOOLEAN, XML_VALUE_TYPE_BOOLEAN }, { XML_STRING, XML_VALUE_TYPE_STRING }, - { XML_TOKEN_INVALID, 0 } + { xmloff::token::XML_TOKEN_INVALID, 0 } }; XMLValueImportHelper::XMLValueImportHelper( commit d78c898a7d1005be8005e5573803fdc3bf7ebc49 Author: Daniel Sikeler <[email protected]> Date: Thu Feb 12 14:12:16 2015 +0100 XMLTextListBlockContext implements fast interface all methods are implemented Change-Id: Ibb50c09e3e7a8dfbe2feb78461de63c02b27b38c diff --git a/xmloff/source/text/XMLTextListBlockContext.cxx b/xmloff/source/text/XMLTextListBlockContext.cxx index f8f9d37..5ad79e3 100644 --- a/xmloff/source/text/XMLTextListBlockContext.cxx +++ b/xmloff/source/text/XMLTextListBlockContext.cxx @@ -231,6 +231,185 @@ XMLTextListBlockContext::XMLTextListBlockContext( mrTxtImport.GetTextListHelper().PushListContext( this ); } +// OD 2008-05-07 #refactorlists# +// add optional parameter <bRestartNumberingAtSubList> and its handling +XMLTextListBlockContext::XMLTextListBlockContext( + SvXMLImport& rImport, XMLTextImportHelper& rTxtImp, sal_Int32 /*Element*/, + const Reference< xml::sax::XFastAttributeList >& xAttrList, + const bool bRestartNumberingAtSubList ) +: SvXMLImportContext( rImport ), + mrTxtImport( rTxtImp ), + msListStyleName(), + mxParentListBlock( ), + mnLevel( 0 ), + mbRestartNumbering( false ), + mbSetDefaults( false ), + msListId(), + msContinueListId() +{ + static const char s_PropNameDefaultListId[] = "DefaultListId"; + { + // get the parent list block context (if any); this is a bit ugly... + XMLTextListBlockContext * pLB(0); + XMLTextListItemContext * pLI(0); + XMLNumberedParaContext * pNP(0); + rTxtImp.GetTextListHelper().ListContextTop(pLB, pLI, pNP); + } + // Inherit style name from parent list, as well as the flags whether + // numbering must be restarted and formats have to be created. + OUString sParentListStyleName; + if( mxParentListBlock.Is() ) + { + XMLTextListBlockContext *pParent = + static_cast<XMLTextListBlockContext *>(&mxParentListBlock); + msListStyleName = pParent->GetListStyleName(); + sParentListStyleName = msListStyleName; + mxNumRules = pParent->GetNumRules(); + mnLevel = pParent->GetLevel() + 1; + mbRestartNumbering = pParent->IsRestartNumbering() || + bRestartNumberingAtSubList; + mbSetDefaults = pParent->mbSetDefaults; + msListId = pParent->GetListId(); + msContinueListId = pParent->GetContinueListId(); + } + + const SvXMLTokenMap& rTokenMap = mrTxtImport.GetTextListBlockAttrTokenMap(); + + bool bIsContinueNumberingAttributePresent( false ); + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + switch( rTokenMap.Get( attribute.Token ) ) + { + case XML_TOK_TEXT_LIST_BLOCK_XMLID: + sXmlId = attribute.Value; +//FIXME: there is no UNO API for lists + // xml:id is also the list ID (#i92221#) + if( mnLevel == 0) // root <list> element + { + msListId = attribute.Value; + } + break; + case XML_TOK_TEXT_LIST_BLOCK_CONTINUE_NUMBERING: + mbRestartNumbering = !attribute.Value.equals("true"); + bIsContinueNumberingAttributePresent = true; + break; + case XML_TOK_TEXT_LIST_BLOCK_STYLE_NAME: + msListStyleName = attribute.Value; + break; + case XML_TOK_TEXT_LIST_BLOCK_CONTINUE_LIST: + if( mnLevel == 0) // root <list> element + { + msContinueListId = attribute.Value; + } + break; + } + } + + mxNumRules = XMLTextListsHelper::MakeNumRule(GetImport(), mxNumRules, + sParentListStyleName, msListStyleName, + mnLevel, &mbRestartNumbering, &mbSetDefaults ); + if( !mxNumRules.is() ) + return; + + if( mnLevel == 0) // root <list> element + { + XMLTextListsHelper& rTextListsHelper( mrTxtImport.GetTextListHelper() ); + // Inconsistent behavior regarding lists (#i92811#) + OUString sListStyleDefaultListId; + { + uno::Reference< beans::XPropertySet > xNumRuleProps( mxNumRules, UNO_QUERY ); + if( xNumRuleProps.is() ) + { + uno::Reference< beans::XPropertySetInfo > xNumRulePropSetInfo( + xNumRuleProps->getPropertySetInfo() ); + if( xNumRulePropSetInfo.is() && + xNumRulePropSetInfo->hasPropertyByName( + s_PropNameDefaultListId) ) + { + xNumRuleProps->getPropertyValue(s_PropNameDefaultListId) + >>= sListStyleDefaultListId; + DBG_ASSERT( !sListStyleDefaultListId.isEmpty(), + "no default list id found at numbering rules instance. Serious defect -> please inform OD." ); + } + } + } + if( msListId.isEmpty() ) // no text:id property found + { + sal_Int32 nUPD( 0 ); + sal_Int32 nBuild( 0 ); + const bool bBuildIdFound = GetImport().getBuildIds( nUPD, nBuild ); + if( rImport.IsTextDocInOOoFileFormat() || + ( bBuildIdFound && nUPD == 680 ) ) + { + /* handling former documents written by OpenOffice.org: + use default list id of numbering rules instance, if existing + (#i92811#) + */ + if( !sListStyleDefaultListId.isEmpty() ) + { + msListId = sListStyleDefaultListId; + if( !bIsContinueNumberingAttributePresent && + !mbRestartNumbering && + rTextListsHelper.IsListProcessed( msListId ) ) + { + mbRestartNumbering = true; + } + } + } + if( msListId.isEmpty() ) + { + // generate a new list id for the list + msListId = rTextListsHelper.GenerateNewListId(); + } + } + + if( bIsContinueNumberingAttributePresent && !mbRestartNumbering && + msContinueListId.isEmpty() ) + { + OUString Last( rTextListsHelper.GetLastProcessedListId() ); + if( rTextListsHelper.GetListStyleOfLastProcessedList() == msListStyleName + && Last != msListId ) + { + msContinueListId = Last; + } + } + + if( !msContinueListId.isEmpty() ) + { + if( !rTextListsHelper.IsListProcessed( msContinueListId ) ) + { + msContinueListId.clear(); + } + else + { + // search continue list chain for master list and + // continue the master list. + OUString sTmpStr = + rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); + while( !sTmpStr.isEmpty() ) + { + msContinueListId = sTmpStr; + + sTmpStr = + rTextListsHelper.GetContinueListIdOfProcessedList( msContinueListId ); + } + } + } + + if( !rTextListsHelper.IsListProcessed( msListId ) ) + { + // Inconsistent behavior regarding lists (#i92811#) + rTextListsHelper.KeepListAsProcessed( + msListId, msListStyleName, msContinueListId, + sListStyleDefaultListId ); + } + } + + // Remember this list block. + mrTxtImport.GetTextListHelper().PushListContext( this ); +} + XMLTextListBlockContext::~XMLTextListBlockContext() { } @@ -254,6 +433,26 @@ void XMLTextListBlockContext::EndElement() mrTxtImport.GetTextListHelper().SetListItem( 0 ); } +void SAL_CALL XMLTextListBlockContext::endFastElement( sal_Int32 /*Element*/ ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + // Numbering has not to be restarted if it has been restarted within + // a child list. + XMLTextListBlockContext *pParent = + static_cast<XMLTextListBlockContext *>(&mxParentListBlock); + if( pParent ) + { + pParent->mbRestartNumbering = mbRestartNumbering; + } + + // Restore current list block. + mrTxtImport.GetTextListHelper().PopListContext(); + + // Any paragraph following the list within the same list item must not + // be numbered. + mrTxtImport.GetTextListHelper().SetListItem( 0 ); +} + SvXMLImportContext *XMLTextListBlockContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -282,6 +481,32 @@ SvXMLImportContext *XMLTextListBlockContext::CreateChildContext( return pContext; } +Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLTextListBlockContext::createFastChildContext( sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + Reference< xml::sax::XFastContextHandler > pContext = 0; + + const SvXMLTokenMap& rTokenMap = + mrTxtImport.GetTextListBlockElemTokenMap(); + bool bHeader = false; + switch( rTokenMap.Get( Element ) ) + { + case XML_TOK_TEXT_LIST_HEADER: + bHeader = true; + //fall-through + case XML_TOK_TEXT_LIST_ITEM: + pContext = new XMLTextListItemContext( GetImport(), mrTxtImport, + Element, xAttrList, bHeader ); + break; + } + + if( !pContext.is() ) + pContext = new SvXMLImportContext( GetImport() ); + + return pContext; +} /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLTextListBlockContext.hxx b/xmloff/source/text/XMLTextListBlockContext.hxx index 2796178..1263fc1 100644 --- a/xmloff/source/text/XMLTextListBlockContext.hxx +++ b/xmloff/source/text/XMLTextListBlockContext.hxx @@ -60,14 +60,24 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, const bool bRestartNumberingAtSubList = false ); + XMLTextListBlockContext( SvXMLImport& rImport, + XMLTextImportHelper& rTxtImp, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const bool bRestartNumberingAtSubList = false ); virtual ~XMLTextListBlockContext(); virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; const OUString& GetListStyleName() const { return msListStyleName; } sal_Int16 GetLevel() const { return mnLevel; } commit 43fc4909e5e51e3b79b4784ee8d95be53f16c364 Author: Daniel Sikeler <[email protected]> Date: Thu Feb 12 14:10:31 2015 +0100 XMLTextListItemContext implements fast interface all methods are implemented Change-Id: I5d7b99e998a3f17a0ce3500fa55b2def82fd23ca diff --git a/xmloff/source/text/XMLTextListItemContext.cxx b/xmloff/source/text/XMLTextListItemContext.cxx index 71dea66..9c23610 100644 --- a/xmloff/source/text/XMLTextListItemContext.cxx +++ b/xmloff/source/text/XMLTextListItemContext.cxx @@ -21,6 +21,8 @@ #include <xmloff/nmspmap.hxx> #include <xmloff/xmlnmspe.hxx> #include <xmloff/xmltoken.hxx> +#include <xmloff/token/tokens.hxx> +#include <com/sun/star/xml/sax/FastToken.hpp> #include "txtparai.hxx" #include "txtlists.hxx" #include "XMLTextListBlockContext.hxx" @@ -34,6 +36,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::xmloff::token; +using namespace xmloff; +using css::xml::sax::FastToken::NAMESPACE; TYPEINIT1( XMLTextListItemContext, SvXMLImportContext ); @@ -121,6 +125,79 @@ XMLTextListItemContext::XMLTextListItemContext( } +XMLTextListItemContext::XMLTextListItemContext( + SvXMLImport& rImport, XMLTextImportHelper& rTxtImp, sal_Int32 /*Element*/, + const Reference< xml::sax::XFastAttributeList >& xAttrList, + const bool bIsHeader ) +: SvXMLImportContext( rImport ), + rTxtImport( rTxtImp ), + nStartValue( -1 ), + mnSubListCount( 0 ), + mxNumRulesOverride() +{ + static const char s_NumberingRules[] = "NumberingRules"; + uno::Sequence< xml::FastAttribute > attributes = xAttrList->getFastAttributes(); + for( xml::FastAttribute attribute : attributes ) + { + if( !bIsHeader && attribute.Token == + (NAMESPACE | XML_NAMESPACE_TEXT | XML_start_value) ) + { + sal_Int32 nTmp = attribute.Value.toInt32(); + if( nTmp >= 0 && nTmp <= SHRT_MAX ) + nStartValue = static_cast< sal_Int16 >( nTmp ); + } + else if( attribute.Token == + (NAMESPACE | XML_NAMESPACE_TEXT | XML_style_override) ) + { + const OUString sListStyleOverrideName = attribute.Value; + if( !sListStyleOverrideName.isEmpty() ) + { + OUString sDisplayStyleName( + GetImport().GetStyleDisplayName( XML_STYLE_FAMILY_TEXT_LIST, + sListStyleOverrideName ) ); + const Reference< container::XNameContainer >& rNumStyles = + rTxtImp.GetNumberingStyles(); + if( rNumStyles.is() && rNumStyles->hasByName( sDisplayStyleName ) ) + { + Reference< style::XStyle > xStyle; + Any aAny = rNumStyles->getByName( sDisplayStyleName ); + aAny >>= xStyle; + + uno::Reference< beans::XPropertySet > xPropSet( xStyle, UNO_QUERY ); + aAny = xPropSet->getPropertyValue(s_NumberingRules); + aAny >>= mxNumRulesOverride; + } + else + { + const SvxXMLListStyleContext* pListStyle = + rTxtImp.FindAutoListStyle( sListStyleOverrideName ); + if( pListStyle ) + { + mxNumRulesOverride = pListStyle->GetNumRules(); + if( !mxNumRulesOverride.is() ) + { + pListStyle->CreateAndInsertAuto(); + mxNumRulesOverride = pListStyle->GetNumRules(); + } + } + } + } + } + else if( attribute.Token == + (NAMESPACE | XML_NAMESPACE_XML | XML_id) ) + { + ; +//FIXME: there is no UNO API for list items + } + } + + // If this is a <text:list-item> element, then remember it as a sign + // that a bullet has to be generated. + if( !bIsHeader ) { + rTxtImport.GetTextListHelper().SetListItem( this ); + } +} + XMLTextListItemContext::~XMLTextListItemContext() { } @@ -131,6 +208,13 @@ void XMLTextListItemContext::EndElement() rTxtImport.GetTextListHelper().SetListItem( 0 ); } +void SAL_CALL XMLTextListItemContext::endFastElement( sal_Int32 /*Element*/ ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + // finish current list item + rTxtImport.GetTextListHelper().SetListItem( 0 ); +} + SvXMLImportContext *XMLTextListItemContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, @@ -167,4 +251,37 @@ SvXMLImportContext *XMLTextListItemContext::CreateChildContext( return pContext; } +Reference< xml::sax::XFastContextHandler > SAL_CALL + XMLTextListItemContext::createFastChildContext( sal_Int32 Element, + const Reference< xml::sax::XFastAttributeList >& xAttrList ) + throw(RuntimeException, xml::sax::SAXException, std::exception) +{ + Reference< xml::sax::XFastContextHandler > pContext = 0; + + const SvXMLTokenMap& rTokenMap = rTxtImport.GetTextElemTokenMap(); + bool bHeading = false; + switch( rTokenMap.Get( Element ) ) + { + case XML_TOK_TEXT_H: + bHeading = true; + case XML_TOK_TEXT_P: + pContext = new XMLParaContext( GetImport(), Element, + xAttrList, bHeading ); + if( rTxtImport.IsProgress() ) + GetImport().GetProgressBarHelper()->Increment(); + + break; + case XML_TOK_TEXT_LIST: + ++mnSubListCount; + pContext = new XMLTextListBlockContext( GetImport(), rTxtImport, + Element, xAttrList, (mnSubListCount > 1) ); + break; + } + + if( !pContext.is() ) + pContext = new SvXMLImportContext( GetImport() ); + + return pContext; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/xmloff/source/text/XMLTextListItemContext.hxx b/xmloff/source/text/XMLTextListItemContext.hxx index 069484a..f370ff8 100644 --- a/xmloff/source/text/XMLTextListItemContext.hxx +++ b/xmloff/source/text/XMLTextListItemContext.hxx @@ -48,14 +48,24 @@ public: const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList, const bool bIsHeader = false ); + XMLTextListItemContext( SvXMLImport& rImport, + XMLTextImportHelper& rTxtImp, sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList, + const bool bIsHeader = false ); virtual ~XMLTextListItemContext(); virtual void EndElement() SAL_OVERRIDE; + virtual void SAL_CALL endFastElement( sal_Int32 Element ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & xAttrList ) SAL_OVERRIDE; + css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL + createFastChildContext( sal_Int32 Element, + const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) + throw(css::uno::RuntimeException, css::xml::sax::SAXException, std::exception) SAL_OVERRIDE; bool HasStartValue() const { return -1 != nStartValue; } sal_Int16 GetStartValue() const { return nStartValue; } _______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
