sw/inc/index.hxx | 4 +++ sw/inc/ndindex.hxx | 3 ++ sw/inc/pam.hxx | 6 +++++ sw/qa/extras/inc/swmodeltestbase.hxx | 37 +++++++++++++++++++++++++++++++++++ sw/source/core/bastyp/index.cxx | 5 ++++ sw/source/core/crsr/pam.cxx | 14 +++++++++++++ sw/source/core/docnode/ndindex.cxx | 5 ++++ sw/source/core/layout/frmtool.cxx | 29 +++++++++++++++++---------- 8 files changed, 92 insertions(+), 11 deletions(-)
New commits: commit 2bd1896e207f7fda2861d019702b931f07c9c4e1 Author: LuboÅ¡ LuÅák <[email protected]> Date: Wed Oct 22 18:23:34 2014 +0200 allow checking odt docs with assertXPath() etc. too Change-Id: I01469514372ad5aab8cb81feb5e09f3315162e2a diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx index aae1f4d..b642abc 100644 --- a/sw/qa/extras/inc/swmodeltestbase.hxx +++ b/sw/qa/extras/inc/swmodeltestbase.hxx @@ -707,6 +707,7 @@ protected: */ virtual void registerNamespaces(xmlXPathContextPtr& pXmlXpathCtx) SAL_OVERRIDE { + // docx xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("w"), BAD_CAST("http://schemas.openxmlformats.org/wordprocessingml/2006/main")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("v"), BAD_CAST("urn:schemas-microsoft-com:vml")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("mc"), BAD_CAST("http://schemas.openxmlformats.org/markup-compatibility/2006")); @@ -724,6 +725,42 @@ protected: xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("extended-properties"), BAD_CAST("http://schemas.openxmlformats.org/officeDocument/2006/extended-properties")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("a14"), BAD_CAST("http://schemas.microsoft.com/office/drawing/2010/main")); xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("o"), BAD_CAST("urn:schemas-microsoft-com:office:office")); + // odt + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("office"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:office:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("style"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:style:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("text"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:text:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("table"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:table:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("draw"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:drawing:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("fo"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xlink"), BAD_CAST("http://www.w3.org/1999/xlink")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dc"), BAD_CAST("http://purl.org/dc/elements/1.1/")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("meta"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:meta:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("number"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("svg"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("chart"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:chart:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dr3d"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("math"), BAD_CAST("http://www.w3.org/1998/Math/MathML")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("form"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:form:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("script"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:script:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooo"), BAD_CAST("http://openoffice.org/2004/office")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("ooow"), BAD_CAST("http://openoffice.org/2004/writer")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("oooc"), BAD_CAST("http://openoffice.org/2004/calc")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("dom"), BAD_CAST("http://www.w3.org/2001/xml-events")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xforms"), BAD_CAST("http://www.w3.org/2002/xforms")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsd"), BAD_CAST("http://www.w3.org/2001/XMLSchema")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xsi"), BAD_CAST("http://www.w3.org/2001/XMLSchema-instance")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("rpt"), BAD_CAST("http://openoffice.org/2005/report")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("of"), BAD_CAST("urn:oasis:names:tc:opendocument:xmlns:of:1.2")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("xhtml"), BAD_CAST("http://www.w3.org/1999/xhtml")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("grddl"), BAD_CAST("http://www.w3.org/2003/g/data-view#")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("officeooo"), BAD_CAST("http://openoffice.org/2009/office")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("tableooo"), BAD_CAST("http://openoffice.org/2009/table")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("drawooo"), BAD_CAST("http://openoffice.org/2010/draw")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("calcext"), BAD_CAST("urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("loext"), BAD_CAST("urn:org:documentfoundation:names:experimental:office:xmlns:loext:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("field"), BAD_CAST("urn:openoffice:names:experimental:ooo-ms-interop:xmlns:field:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("formx"), BAD_CAST("urn:openoffice:names:experimental:ooxml-odf-interop:xmlns:form:1.0")); + xmlXPathRegisterNs(pXmlXpathCtx, BAD_CAST("css3t"), BAD_CAST("http://www.w3.org/TR/css3-text/")); } virtual OUString registerDBsource( const OUString &aURI, const OUString &aPrefix, const OUString &aWorkDir ) commit 6557b081b9d2390396408a97bbf0b50a2830b747 Author: LuboÅ¡ LuÅák <[email protected]> Date: Tue Oct 21 19:57:45 2014 +0200 more local variable Change-Id: Ibe67ecdd5b121ad5624bfd111dca33897d6e1991 diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f9a275d..a2cda52 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1076,9 +1076,9 @@ void AppendObjs( const SwFrmFmts *pTbl, sal_uLong nIndex, static bool lcl_ObjConnected( SwFrmFmt *pFmt, const SwFrm* pSib ) { - SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt ); if ( RES_FLYFRMFMT == pFmt->Which() ) { + SwIterator<SwFlyFrm,SwFmt> aIter( *pFmt ); const SwRootFrm* pRoot = pSib ? pSib->getRootFrm() : 0; const SwFlyFrm* pTmpFrm; for( pTmpFrm = aIter.First(); pTmpFrm; pTmpFrm = aIter.Next() ) commit 16f18fb34b5cfae86a48e8e360d98b95d458ee85 Author: LuboÅ¡ LuÅák <[email protected]> Date: Tue Oct 21 19:06:20 2014 +0200 repeated vector::erase() is a bad idea for performance Especially given that it seems here it was usually called on every single element. Change-Id: Ifc5497aac5108481595df80d00c6e00c00f17596 diff --git a/sw/source/core/layout/frmtool.cxx b/sw/source/core/layout/frmtool.cxx index f45b6a8..f9a275d 100644 --- a/sw/source/core/layout/frmtool.cxx +++ b/sw/source/core/layout/frmtool.cxx @@ -1123,16 +1123,21 @@ void AppendAllObjs( const SwFrmFmts *pTbl, const SwFrm* pSib ) //because we neither use character bound frames nor objects which //are anchored to character bounds. - SwFrmFmts aCpy( *pTbl ); + // Optimization: This code used to make a copy of pTbl and erase() handled items, but using + // vector::erase() is a bad idea for performance (especially with large mailmerge documents + // it results in extensive repeated copying). Use another vector for marking whether the item + // has been handled and operate on the original data without altering them. + std::vector< bool > handled( pTbl->size(), false ); + size_t handledCount = 0; - sal_uInt16 nOldCnt = USHRT_MAX; - - while ( !aCpy.empty() && aCpy.size() != nOldCnt ) + while ( handledCount < pTbl->size()) { - nOldCnt = aCpy.size(); - for ( int i = 0; i < int(aCpy.size()); ++i ) + bool changed = false; + for ( int i = 0; i < int(pTbl->size()); ++i ) { - SwFrmFmt *pFmt = (SwFrmFmt*)aCpy[ sal_uInt16(i) ]; + if( handled[ i ] ) + continue; + SwFrmFmt *pFmt = (*pTbl)[ i ]; const SwFmtAnchor &rAnch = pFmt->GetAnchor(); bool bRemove = false; if ((rAnch.GetAnchorId() == FLY_AT_PAGE) || @@ -1156,12 +1161,14 @@ void AppendAllObjs( const SwFrmFmts *pTbl, const SwFrm* pSib ) } if ( bRemove ) { - aCpy.erase( aCpy.begin() + i ); - --i; + handled[ i ] = true; + ++handledCount; + changed = true; } } + if( !changed ) + break; } - aCpy.clear(); } /** local method to set 'working' position for newly inserted frames commit 12637c634cfaebb4213f32cc83dcd0a2028c3d55 Author: LuboÅ¡ LuÅák <[email protected]> Date: Thu Oct 16 16:02:23 2014 +0200 operator<< for SwPosition/SwPaM/etc. for use with SAL_DEBUG Change-Id: I99ffa87afa6dbdbd20042a882af428d166546af3 diff --git a/sw/inc/index.hxx b/sw/inc/index.hxx index e364853..3330861 100644 --- a/sw/inc/index.hxx +++ b/sw/inc/index.hxx @@ -23,6 +23,8 @@ #include <tools/rtti.hxx> #include <swdllapi.h> +#include <iostream> + class SwIndexReg; struct SwPosition; @@ -107,6 +109,8 @@ public: void SetMark(const sw::mark::IMark* pMark); }; +std::ostream& operator <<(std::ostream& s, const SwIndex& index); + class SwIndexReg { friend class SwIndex; diff --git a/sw/inc/ndindex.hxx b/sw/inc/ndindex.hxx index 028ce54..c8221c2 100644 --- a/sw/inc/ndindex.hxx +++ b/sw/inc/ndindex.hxx @@ -20,6 +20,7 @@ #define INCLUDED_SW_INC_NDINDEX_HXX #include <limits.h> +#include <iostream> #include <tools/solar.h> @@ -92,6 +93,8 @@ public: SwNode& GetNode() const { return *pNd; } }; +std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index); + // SwRange class SW_DLLPUBLIC SwNodeRange diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx index dd95d13..8614453 100644 --- a/sw/inc/pam.hxx +++ b/sw/inc/pam.hxx @@ -28,6 +28,8 @@ #include <ndindex.hxx> #include "swdllapi.h" +#include <iostream> + class SwFmt; class SfxPoolItem; class SfxItemSet; @@ -74,6 +76,8 @@ struct SW_DLLPUBLIC SwPosition bool operator !=(const SwPosition &) const; }; +std::ostream &operator <<(std::ostream& s, const SwPosition& position); + // Result of comparing positions. enum SwComparePosition { POS_BEFORE, ///< Pos1 before Pos2. @@ -301,6 +305,8 @@ public: void InvalidatePaM(); }; +std::ostream &operator <<(std::ostream& s, const SwPaM& pam); + bool CheckNodesRange( const SwNodeIndex&, const SwNodeIndex&, bool bChkSection ); #endif // INCLUDED_SW_INC_PAM_HXX diff --git a/sw/source/core/bastyp/index.cxx b/sw/source/core/bastyp/index.cxx index b6f7632..d77e2396 100644 --- a/sw/source/core/bastyp/index.cxx +++ b/sw/source/core/bastyp/index.cxx @@ -392,4 +392,9 @@ SwIndex& SwIndex::operator= ( sal_Int32 const nVal ) #endif +std::ostream& operator <<(std::ostream& s, const SwIndex& index) +{ + return s << "SwIndex offset (" << index.GetIndex() << ")"; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx index 5a1d1fa..ad5bbf5 100644 --- a/sw/source/core/crsr/pam.cxx +++ b/sw/source/core/crsr/pam.cxx @@ -190,6 +190,11 @@ SwDoc * SwPosition::GetDoc() const return nNode.GetNode().GetDoc(); } +std::ostream &operator <<(std::ostream& s, const SwPosition& position) +{ + return s << "SwPosition (node " << position.nNode.GetIndex() << ", offset " << position.nContent.GetIndex() << ")"; +} + enum CHKSECTION { Chk_Both, Chk_One, Chk_None }; static CHKSECTION lcl_TstIdx( sal_uLong nSttIdx, sal_uLong nEndIdx, const SwNode& rEndNd ) @@ -1085,4 +1090,13 @@ void SwPaM::InvalidatePaM() } } +std::ostream &operator <<(std::ostream& s, const SwPaM& pam) +{ + if( pam.HasMark()) + return s << "SwPaM (point " << *pam.GetPoint() << ", mark " << *pam.GetMark() << ")"; + else + return s << "SwPaM (point " << *pam.GetPoint() << ")"; +} + + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/docnode/ndindex.cxx b/sw/source/core/docnode/ndindex.cxx index 3c3a9f6..03e98be 100644 --- a/sw/source/core/docnode/ndindex.cxx +++ b/sw/source/core/docnode/ndindex.cxx @@ -130,4 +130,9 @@ SwNodeIndex& SwNodeIndex::Assign( const SwNode& rNd, long nOffset ) return *this; } +std::ostream &operator <<(std::ostream& s, const SwNodeIndex& index) +{ + return s << "SwNodeIndex (node " << index.GetIndex() << ")"; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
_______________________________________________ Libreoffice-commits mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
