summaryrefslogtreecommitdiff
path: root/sw/source/filter/xml
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2020-08-29 11:19:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-12-07 08:52:49 +0100
commit5080bb930de3ecfce8ab78bbd23a9d48c2f2bfa0 (patch)
tree9f92d184627177dbd83dedda40d4a4abb531381e /sw/source/filter/xml
parent121464be43830a6f6bfbc27a17c8e0bc7577f455 (diff)
convert SvXMLImport to fastparser, drop slowparser paths
Change-Id: I0f880a7680373043fecf083cdf4de8b0bb7041a2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103775 Tested-by: Noel Grandin <noel.grandin@collabora.co.uk> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/xml')
-rw-r--r--sw/source/filter/xml/xmlfmt.cxx2
-rw-r--r--sw/source/filter/xml/xmlimp.cxx26
-rw-r--r--sw/source/filter/xml/xmltbli.cxx137
-rw-r--r--sw/source/filter/xml/xmltbli.hxx2
-rw-r--r--sw/source/filter/xml/xmltexti.cxx4
-rw-r--r--sw/source/filter/xml/xmltexti.hxx4
6 files changed, 19 insertions, 156 deletions
diff --git a/sw/source/filter/xml/xmlfmt.cxx b/sw/source/filter/xml/xmlfmt.cxx
index 50a6aead1671..fa0b31a5e78d 100644
--- a/sw/source/filter/xml/xmlfmt.cxx
+++ b/sw/source/filter/xml/xmlfmt.cxx
@@ -608,7 +608,7 @@ css::uno::Reference< css::xml::sax::XFastContextHandler > SwXMLItemSetStyleConte
pTextStyle->startFastElement( nElement, xTmpAttrList.get() );
rStyles.AddStyle( *pTextStyle );
}
- return pTextStyle->createFastChildContextFallback( nElement, xAttrList );
+ return pTextStyle->createFastChildContext( nElement, xAttrList );
}
default:
XMLOFF_WARN_UNKNOWN_ELEMENT("sw", nElement);
diff --git a/sw/source/filter/xml/xmlimp.cxx b/sw/source/filter/xml/xmlimp.cxx
index 0a5c68b18719..feda4bec3ff4 100644
--- a/sw/source/filter/xml/xmlimp.cxx
+++ b/sw/source/filter/xml/xmlimp.cxx
@@ -151,12 +151,13 @@ namespace {
// in SwXMLOfficeDocContext_Impl
class SwXMLDocContext_Impl : public virtual SvXMLImportContext
{
+ sal_Int32 mnElement;
protected: // #i69629#
SwXMLImport& GetSwImport() { return static_cast<SwXMLImport&>(GetImport()); }
public:
- SwXMLDocContext_Impl( SwXMLImport& rImport );
+ SwXMLDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement );
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList ) override;
@@ -164,8 +165,8 @@ public:
}
-SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport ) :
- SvXMLImportContext( rImport )
+SwXMLDocContext_Impl::SwXMLDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement ) :
+ SvXMLImportContext( rImport ), mnElement(nElement)
{
}
@@ -186,7 +187,7 @@ uno::Reference< xml::sax::XFastContextHandler > SAL_CALL SwXMLDocContext_Impl::c
break;
case XML_ELEMENT(OFFICE, XML_AUTOMATIC_STYLES):
// don't use the autostyles from the styles-document for the progress
- if ( !IsPrefixFilledIn() || ! IsXMLToken( GetLocalName(), XML_DOCUMENT_STYLES ) )
+ if ( mnElement != 0 && (mnElement & TOKEN_MASK) != XML_DOCUMENT_STYLES )
GetSwImport().GetProgressBarHelper()->Increment
( PROGRESS_BAR_STEP );
return GetSwImport().CreateStylesContext( true );
@@ -221,7 +222,7 @@ class SwXMLOfficeDocContext_Impl :
{
public:
- SwXMLOfficeDocContext_Impl( SwXMLImport& rImport,
+ SwXMLOfficeDocContext_Impl( SwXMLImport& rImport, sal_Int32 nElement,
const Reference< document::XDocumentProperties >& xDocProps);
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(
@@ -232,9 +233,10 @@ public:
SwXMLOfficeDocContext_Impl::SwXMLOfficeDocContext_Impl(
SwXMLImport& rImport,
+ sal_Int32 nElement,
const Reference< document::XDocumentProperties >& xDocProps) :
SvXMLImportContext( rImport ),
- SwXMLDocContext_Impl( rImport ),
+ SwXMLDocContext_Impl( rImport, nElement ),
SvXMLMetaDocumentContext( rImport, xDocProps )
{
}
@@ -269,16 +271,16 @@ class SwXMLDocStylesContext_Impl : public SwXMLDocContext_Impl
{
public:
- SwXMLDocStylesContext_Impl( SwXMLImport& rImport );
+ SwXMLDocStylesContext_Impl( SwXMLImport& rImport, sal_Int32 nElement );
virtual void SAL_CALL endFastElement(sal_Int32 nElement) override;
};
}
-SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl( SwXMLImport& rImport ) :
+SwXMLDocStylesContext_Impl::SwXMLDocStylesContext_Impl( SwXMLImport& rImport, sal_Int32 nElement ) :
SvXMLImportContext( rImport ),
- SwXMLDocContext_Impl( rImport )
+ SwXMLDocContext_Impl( rImport, nElement )
{
}
@@ -306,16 +308,16 @@ SvXMLImportContext *SwXMLImport::CreateFastContext( sal_Int32 nElement,
uno::Reference<document::XDocumentProperties> const xDocProps(
GetDocumentProperties());
// flat OpenDocument file format
- pContext = new SwXMLOfficeDocContext_Impl( *this, xDocProps );
+ pContext = new SwXMLOfficeDocContext_Impl( *this, nElement, xDocProps );
}
break;
// #i69629# - own subclasses for <office:document> and <office:document-styles>
case XML_ELEMENT(OFFICE, XML_DOCUMENT_SETTINGS):
case XML_ELEMENT(OFFICE, XML_DOCUMENT_CONTENT):
- pContext = new SwXMLDocContext_Impl( *this );
+ pContext = new SwXMLDocContext_Impl( *this, nElement );
break;
case XML_ELEMENT(OFFICE, XML_DOCUMENT_STYLES):
- pContext = new SwXMLDocStylesContext_Impl( *this );
+ pContext = new SwXMLDocStylesContext_Impl( *this, nElement );
break;
}
return pContext;
diff --git a/sw/source/filter/xml/xmltbli.cxx b/sw/source/filter/xml/xmltbli.cxx
index 22be0dad5587..39b9fabe39c3 100644
--- a/sw/source/filter/xml/xmltbli.cxx
+++ b/sw/source/filter/xml/xmltbli.cxx
@@ -1180,143 +1180,6 @@ SwXMLTableCell_Impl *SwXMLTableContext::GetCell( sal_uInt32 nRow,
SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
- const Reference< xml::sax::XAttributeList > & xAttrList ) :
- XMLTextTableContext( rImport ),
- m_pRows( new SwXMLTableRows_Impl ),
- m_pTableNode( nullptr ),
- m_pBox1( nullptr ),
- m_bOwnsBox1( false ),
- m_pSttNd1( nullptr ),
- m_pBoxFormat( nullptr ),
- m_pLineFormat( nullptr ),
- m_bFirstSection( true ),
- m_bRelWidth( true ),
- m_bHasSubTables( false ),
- m_nHeaderRows( 0 ),
- m_nCurRow( 0 ),
- m_nCurCol( 0 ),
- m_nWidth( 0 )
-{
- OUString aName;
- OUString sXmlId;
-
- // this method will modify the document directly -> lock SolarMutex
- SolarMutexGuard aGuard;
-
- sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
- for( sal_Int16 i=0; i < nAttrCount; i++ )
- {
- const OUString& rAttrName = xAttrList->getNameByIndex( i );
-
- OUString aLocalName;
- const sal_uInt16 nPrefix =
- GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
- &aLocalName );
- const OUString& rValue = xAttrList->getValueByIndex( i );
- if( XML_NAMESPACE_TABLE == nPrefix )
- {
- if( IsXMLToken( aLocalName, XML_STYLE_NAME ) )
- m_aStyleName = rValue;
- else if( IsXMLToken( aLocalName, XML_NAME ) )
- aName = rValue;
- else if( IsXMLToken( aLocalName, XML_DEFAULT_CELL_STYLE_NAME ) )
- m_aDfltCellStyleName = rValue;
- else if( IsXMLToken( aLocalName, XML_TEMPLATE_NAME ) )
- m_aTemplateName = rValue;
- }
- else if ( (XML_NAMESPACE_XML == nPrefix) &&
- IsXMLToken( aLocalName, XML_ID ) )
- {
- sXmlId = rValue;
- }
- }
-
- SwDoc *pDoc = SwImport::GetDocFromXMLImport( GetSwImport() );
-
- OUString sTableName;
- if( !aName.isEmpty() )
- {
- const SwTableFormat *pTableFormat = pDoc->FindTableFormatByName( aName );
- if( !pTableFormat )
- sTableName = aName;
- }
- if( sTableName.isEmpty() )
- {
- sTableName = pDoc->GetUniqueTableName();
- GetImport().GetTextImport()
- ->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_TABLE, aName, sTableName );
- }
-
- Reference< XTextTable > xTable;
- SwXTextTable *pXTable = nullptr;
- Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
- UNO_QUERY );
- OSL_ENSURE( xFactory.is(), "factory missing" );
- if( xFactory.is() )
- {
- Reference<XInterface> xIfc = xFactory->createInstance( "com.sun.star.text.TextTable" );
- OSL_ENSURE( xIfc.is(), "Couldn't create a table" );
-
- if( xIfc.is() )
- xTable.set( xIfc, UNO_QUERY );
- }
-
- if( xTable.is() )
- {
- xTable->initialize( 1, 1 );
-
- try
- {
- m_xTextContent = xTable;
- GetImport().GetTextImport()->InsertTextContent( m_xTextContent );
- }
- catch( IllegalArgumentException& )
- {
- xTable = nullptr;
- }
- }
-
- if( xTable.is() )
- {
- //FIXME
- // xml:id for RDF metadata
- GetImport().SetXmlId(xTable, sXmlId);
-
- Reference<XUnoTunnel> xTableTunnel( xTable, UNO_QUERY);
- if( xTableTunnel.is() )
- {
- pXTable = reinterpret_cast< SwXTextTable * >(
- sal::static_int_cast< sal_IntPtr >( xTableTunnel->getSomething( SwXTextTable::getUnoTunnelId() )));
- OSL_ENSURE( pXTable, "SwXTextTable missing" );
- }
-
- Reference < XCellRange > xCellRange( xTable, UNO_QUERY );
- Reference < XCell > xCell = xCellRange->getCellByPosition( 0, 0 );
- Reference < XText> xText( xCell, UNO_QUERY );
- m_xOldCursor = GetImport().GetTextImport()->GetCursor();
- GetImport().GetTextImport()->SetCursor( xText->createTextCursor() );
-
- // take care of open redlines for tables
- GetImport().GetTextImport()->RedlineAdjustStartNodeCursor();
- }
- if( !pXTable )
- return;
-
- SwFrameFormat *const pTableFrameFormat = pXTable->GetFrameFormat();
- OSL_ENSURE( pTableFrameFormat, "table format missing" );
- SwTable *pTable = SwTable::FindTable( pTableFrameFormat );
- OSL_ENSURE( pTable, "table missing" );
- m_pTableNode = pTable->GetTableNode();
- OSL_ENSURE( m_pTableNode, "table node missing" );
-
- pTableFrameFormat->SetName( sTableName );
-
- SwTableLine *pLine1 = m_pTableNode->GetTable().GetTabLines()[0U];
- m_pBox1 = pLine1->GetTabBoxes()[0U];
- m_pSttNd1 = m_pBox1->GetSttNd();
-}
-
-SwXMLTableContext::SwXMLTableContext( SwXMLImport& rImport,
const Reference< xml::sax::XFastAttributeList > & xAttrList ) :
XMLTextTableContext( rImport ),
m_pRows( new SwXMLTableRows_Impl ),
diff --git a/sw/source/filter/xml/xmltbli.hxx b/sw/source/filter/xml/xmltbli.hxx
index 4f71f7a5a164..fc544f6c6886 100644
--- a/sw/source/filter/xml/xmltbli.hxx
+++ b/sw/source/filter/xml/xmltbli.hxx
@@ -137,8 +137,6 @@ public:
SwXMLTableContext( SwXMLImport& rImport,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList );
- SwXMLTableContext( SwXMLImport& rImport,
const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList );
SwXMLTableContext( SwXMLImport& rImport,
SwXMLTableContext *pTable );
diff --git a/sw/source/filter/xml/xmltexti.cxx b/sw/source/filter/xml/xmltexti.cxx
index 37402c63daf5..be863f65bfa3 100644
--- a/sw/source/filter/xml/xmltexti.cxx
+++ b/sw/source/filter/xml/xmltexti.cxx
@@ -180,8 +180,8 @@ SwXMLTextImportHelper::~SwXMLTextImportHelper()
SvXMLImportContext *SwXMLTextImportHelper::CreateTableChildContext(
SvXMLImport& rImport,
- sal_uInt16 /*nPrefix*/, const OUString& /*rLocalName*/,
- const uno::Reference< XAttributeList > & xAttrList )
+ sal_Int32 /*nElement*/,
+ const uno::Reference< XFastAttributeList > & xAttrList )
{
return new SwXMLTableContext( static_cast<SwXMLImport&>(rImport), xAttrList );
}
diff --git a/sw/source/filter/xml/xmltexti.hxx b/sw/source/filter/xml/xmltexti.hxx
index 1aefcfe641e0..067472e5a98f 100644
--- a/sw/source/filter/xml/xmltexti.hxx
+++ b/sw/source/filter/xml/xmltexti.hxx
@@ -31,8 +31,8 @@ class SwXMLTextImportHelper : public XMLTextImportHelper
protected:
virtual SvXMLImportContext *CreateTableChildContext(
SvXMLImport& rImport,
- sal_uInt16 nPrefix, const OUString& rLocalName,
- const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList ) override;
+ sal_Int32 nElement,
+ const css::uno::Reference< css::xml::sax::XFastAttributeList > & xAttrList ) override;
public:
SwXMLTextImportHelper(