[Libreoffice-commits] core.git: 2 commits - include/xmloff sc/source xmloff/source

2023-04-17 Thread Caolán McNamara (via logerrit)
 include/xmloff/txtparae.hxx   |5 +
 sc/source/filter/xml/xmlcelli.cxx |2 +-
 xmloff/source/text/txtparae.cxx   |   33 -
 3 files changed, 34 insertions(+), 6 deletions(-)

New commits:
commit 7773932ba7c4bafeed7fba0a5d87f75eed09f850
Author: Caolán McNamara 
AuthorDate: Mon Apr 17 09:17:43 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 17 17:03:17 2023 +0200

tdf#151560 don't crash on loading dubious fods

Change-Id: Ib41b3a95dd3829e8d3eca61621257fdd416bd8dc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150483
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/sc/source/filter/xml/xmlcelli.cxx 
b/sc/source/filter/xml/xmlcelli.cxx
index dbbfccf5a5a0..c2841fa33c7f 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1493,7 +1493,7 @@ bool ScXMLTableRowCellContext::IsPossibleErrorString() 
const
 return false;
 else if(mbNewValueType && mbErrorValue)
 return true;
-return mbPossibleErrorCell || (mbCheckWithCompilerForError &&
+return mbPossibleErrorCell || (mbCheckWithCompilerForError && 
maStringValue &&
 GetScImport().GetFormulaErrorConstant(*maStringValue) != 
FormulaError::NONE);
 }
 
commit d405ddce1fca35e088d35805345571687c46ff5f
Author: Caolán McNamara 
AuthorDate: Sun Apr 16 20:44:25 2023 +0100
Commit: Caolán McNamara 
CommitDate: Mon Apr 17 17:03:07 2023 +0200

crashtesting: crash on export of forum-mso-de-102589.docx to odt

recurses to death

Change-Id: I4474de502df0924176cbe8d6c9244d0b73838458
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/150460
Tested-by: Jenkins
Reviewed-by: Caolán McNamara 

diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index 36d554be2a20..1ba8b0b1a0c8 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -30,6 +30,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -51,6 +52,7 @@ namespace com::sun::star
 namespace beans { class XPropertySet; class XPropertyState;
   class XPropertySetInfo; }
 namespace container { class XEnumeration; class XIndexAccess; class 
XNameReplace; }
+namespace drawing { class XShape; }
 namespace text { class XTextContent; class XTextRange; class XText;
  class XFootnote; class XTextFrame; class XTextSection;
  class XTextField; }
@@ -110,6 +112,9 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public 
XMLStyleExport
 XMLTextListsHelper* mpTextListsHelper;
 ::std::vector< std::unique_ptr > 
maTextListsHelperStack;
 
+o3tl::sorted_vector> 
maFrameRecurseGuard;
+o3tl::sorted_vector> 
maShapeRecurseGuard;
+
 bool mbCollected;
 
 enum class FrameType { Text, Graphic, Embedded, Shape };
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index aaf47ddd4b71..1e02dbce341d 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -110,6 +110,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 using namespace ::com::sun::star;
@@ -3054,17 +3055,39 @@ void XMLTextParagraphExport::exportAnyTextFrame(
 if ( bExportContent )
 {
 Reference < XTextFrame > xTxtFrame( rTxtCntnt, UNO_QUERY );
-Reference < XText > xTxt(xTxtFrame->getText());
-exportFrameFrames( true, bIsProgress, xTxtFrame );
-exportText( xTxt, bAutoStyles, bIsProgress, true );
+bool bAlreadySeen = 
!maFrameRecurseGuard.insert(xTxtFrame).second;
+if (bAlreadySeen)
+{
+SAL_WARN("xmloff", "loop in frame export, ditching");
+}
+else
+{
+comphelper::ScopeGuard const g([this, xTxtFrame]() {
+maFrameRecurseGuard.erase(xTxtFrame);
+});
+Reference < XText > xTxt(xTxtFrame->getText());
+exportFrameFrames( true, bIsProgress, xTxtFrame );
+exportText( xTxt, bAutoStyles, bIsProgress, true );
+}
 }
 }
 break;
 case FrameType::Shape:
 {
 Reference < XShape > xShape( rTxtCntnt, UNO_QUERY );
-css::uno::Sequence aAutoStylePropNames = 
GetAutoStylePool().GetPropertyNames();
-GetExport().GetShapeExport()->collectShapeAutoStyles( xShape, 
aAutoStylePropNames );
+bool bAlreadySeen = !maShapeRecurseGuard.insert(xShape).second;
+if (bAlreadySeen)
+{
+SAL_WARN("xmloff", "loop in shape export, ditching");
+}
+else
+

[Libreoffice-commits] core.git: 2 commits - include/xmloff sc/source xmloff/source

2019-10-31 Thread Noel Grandin (via logerrit)
 include/xmloff/fasttokenhandler.hxx   |   16 ++--
 include/xmloff/xmlimp.hxx |7 +--
 sc/source/filter/xml/XMLTrackedChangesContext.cxx |6 +++---
 xmloff/source/core/fasttokenhandler.cxx   |   11 ++-
 xmloff/source/core/xmlimp.cxx |   10 --
 5 files changed, 36 insertions(+), 14 deletions(-)

New commits:
commit 885ae558d34dd76955c727b90eb9ae52ce85df7f
Author: Noel Grandin 
AuthorDate: Thu Oct 31 14:06:21 2019 +0200
Commit: Noel Grandin 
CommitDate: Thu Oct 31 18:54:45 2019 +0100

tdf#125688, cache token names as OUString

to avoid construction cost, shaves 2% off load time

Change-Id: I37a70a6e989f53d67911a6cb217d07e2db55cb44
Reviewed-on: https://gerrit.libreoffice.org/81841
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/include/xmloff/fasttokenhandler.hxx 
b/include/xmloff/fasttokenhandler.hxx
index a95b3506a5f1..e134604eae70 100644
--- a/include/xmloff/fasttokenhandler.hxx
+++ b/include/xmloff/fasttokenhandler.hxx
@@ -32,10 +32,18 @@ public:
 {
 SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "xmloff", "Wrong 
nToken parameter");
 if( 0 <= nToken && nToken < XML_TOKEN_COUNT )
-return maTokenNames[ nToken ];
+return maTokenNamesUtf8[ nToken ];
 return EMPTY_BYTE_SEQ;
 }
 
+const OUString& getTokenName( sal_Int32 nToken ) const
+{
+SAL_WARN_IF(nToken < 0 || nToken >= XML_TOKEN_COUNT, "xmloff", "Wrong 
nToken parameter");
+if( 0 <= nToken && nToken < XML_TOKEN_COUNT )
+return maTokenNames[ nToken ];
+return EMPTY_STRING;
+}
+
 /** Returns the token identifier for the passed UTF-8 token name. */
 static sal_Int32 getTokenFromUtf8( const css::uno::Sequence< sal_Int8 >& 
rUtf8Name )
 {
@@ -52,9 +60,11 @@ public:
 private:
 static sal_Int32 getTokenPerfectHash( const char *pToken, sal_Int32 
nLength );
 
-std::vector< css::uno::Sequence< sal_Int8 > > maTokenNames;
+std::vector< css::uno::Sequence< sal_Int8 > > maTokenNamesUtf8;
+std::vector< OUString > maTokenNames;
 
 static const css::uno::Sequence< sal_Int8 > EMPTY_BYTE_SEQ;
+static const OUString EMPTY_STRING;
 };
 
 struct StaticTokenMap : public rtl::Static< TokenMap, StaticTokenMap > {};
@@ -71,6 +81,8 @@ public:
 virtual css::uno::Sequence< sal_Int8 > SAL_CALL getUTF8Identifier( 
sal_Int32 nToken ) override;
 virtual sal_Int32 SAL_CALL getTokenFromUTF8( const css::uno::Sequence< 
sal_Int8 >& Identifier ) override;
 
+const OUString & getIdentifier( sal_Int32 nToken ) const;
+
 // Much faster direct C++ shortcut to the method that matters
 virtual sal_Int32 getTokenDirect( const char *pToken, sal_Int32 nLength ) 
const override;
 
diff --git a/include/xmloff/xmlimp.hxx b/include/xmloff/xmlimp.hxx
index 78bc26a7c234..0007f6dd5086 100644
--- a/include/xmloff/xmlimp.hxx
+++ b/include/xmloff/xmlimp.hxx
@@ -90,6 +90,9 @@ enum class SvXMLErrorFlags;
 namespace xmloff {
 class RDFaImportHelper;
 }
+namespace xmloff::token {
+class FastTokenHandler;
+}
 
 enum class SvXMLImportFlags {
 NONE= 0x,
@@ -219,7 +222,7 @@ class XMLOFF_DLLPUBLIC SvXMLImport : public 
cppu::WeakImplHelper<
 rtl::Reference < comphelper::AttributeList > maAttrList;
 rtl::Reference < comphelper::AttributeList > maNamespaceAttrList;
 css::uno::Reference< css::xml::sax::XFastDocumentHandler > 
mxFastDocumentHandler;
-static css::uno::Reference< css::xml::sax::XFastTokenHandler > 
xTokenHandler;
+static rtl::Reference< xmloff::token::FastTokenHandler > xTokenHandler;
 static std::unordered_map< sal_Int32, std::pair< OUString, OUString > > 
aNamespaceMap;
 static std::unordered_map< OUString, OUString > aNamespaceURIPrefixMap;
 static bool bIsNSMapsInitialized;
@@ -377,7 +380,7 @@ public:
 // get import helper for events
 XMLEventImportHelper& GetEventImport();
 
-static OUString getNameFromToken( sal_Int32 nToken );
+static const OUString & getNameFromToken( sal_Int32 nToken );
 static OUString getNamespacePrefixFromToken(sal_Int32 nToken, const 
SvXMLNamespaceMap* pMap);
 static OUString getNamespaceURIFromToken( sal_Int32 nToken );
 static OUString getNamespacePrefixFromURI( const OUString& rURI );
diff --git a/xmloff/source/core/fasttokenhandler.cxx 
b/xmloff/source/core/fasttokenhandler.cxx
index 319bdce5f367..7e7673bfb791 100644
--- a/xmloff/source/core/fasttokenhandler.cxx
+++ b/xmloff/source/core/fasttokenhandler.cxx
@@ -33,8 +33,10 @@ namespace token {
 using namespace css;
 
 const css::uno::Sequence< sal_Int8 > TokenMap::EMPTY_BYTE_SEQ;
+const OUString TokenMap::EMPTY_STRING;
 
 TokenMap::TokenMap() :
+maTokenNamesUtf8( static_cast< size_t >( XML_TOKEN_COUNT ) ),
 maTokenNames( static_cast< size_t >( XML_TOKEN_COUNT ) )
 {
 static const sal_Char* sppcTokenNames[] =
@@ 

[Libreoffice-commits] core.git: 2 commits - include/xmloff sc/source xmloff/source

2017-04-11 Thread Noel Grandin
 include/xmloff/txtparae.hxx|5 +++--
 sc/source/core/inc/jumpmatrix.hxx  |4 ++--
 sc/source/core/tool/jumpmatrix.cxx |9 -
 xmloff/source/text/txtparae.cxx|   11 +--
 xmloff/source/text/txtstyle.cxx|2 +-
 5 files changed, 15 insertions(+), 16 deletions(-)

New commits:
commit 4e162517869c811c06242bb8eb08001dfcf3b714
Author: Noel Grandin 
Date:   Tue Apr 11 09:43:53 2017 +0200

loplugin:inlinefields in ScJumpMatrix

Change-Id: I8fea7185c6ccd1c023835da41ab184351d5cac01
Reviewed-on: https://gerrit.libreoffice.org/36403
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/sc/source/core/inc/jumpmatrix.hxx 
b/sc/source/core/inc/jumpmatrix.hxx
index 4ef4f87b282a..94b8dc1737aa 100644
--- a/sc/source/core/inc/jumpmatrix.hxx
+++ b/sc/source/core/inc/jumpmatrix.hxx
@@ -45,7 +45,7 @@ struct ScJumpMatrixEntry
 nNext = nNextP;
 nStop = nStopP;
 }
-voidGetJump( double& rBool, short& rStart, short& rNext, short& rStop )
+voidGetJump( double& rBool, short& rStart, short& rNext, short& rStop 
) const
 {
 rBool = fBool;
 rStart = nStart;
@@ -56,7 +56,7 @@ struct ScJumpMatrixEntry
 
 class ScJumpMatrix
 {
-ScJumpMatrixEntry*  pJump;  // the jumps
+std::vector mvJump;  // the jumps
 ScMatrixRef pMat;   // the results
 ScTokenVec* pParams;// parameter stack
 SCSIZE  nCols;
diff --git a/sc/source/core/tool/jumpmatrix.cxx 
b/sc/source/core/tool/jumpmatrix.cxx
index 0961e78ff49d..760f89735db6 100644
--- a/sc/source/core/tool/jumpmatrix.cxx
+++ b/sc/source/core/tool/jumpmatrix.cxx
@@ -28,7 +28,7 @@ const SCSIZE kBufferThreshold = 128;
 }
 
 ScJumpMatrix::ScJumpMatrix(SCSIZE nColsP, SCSIZE nRowsP)
-: pJump(new ScJumpMatrixEntry[nColsP * nRowsP])
+: mvJump(nColsP * nRowsP)
 , pMat(new ScFullMatrix(nColsP, nRowsP))
 , pParams(nullptr)
 , nCols(nColsP)
@@ -62,7 +62,6 @@ ScJumpMatrix::~ScJumpMatrix()
 }
 delete pParams;
 }
-delete[] pJump;
 }
 
 void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& rRows) const
@@ -74,7 +73,7 @@ void ScJumpMatrix::GetDimensions(SCSIZE& rCols, SCSIZE& 
rRows) const
 void ScJumpMatrix::SetJump(SCSIZE nCol, SCSIZE nRow, double fBool,
short nStart, short nNext)
 {
-pJump[(sal_uLong)nCol * nRows + nRow].SetJump(fBool, nStart, nNext, 
SHRT_MAX);
+mvJump[(sal_uLong)nCol * nRows + nRow].SetJump(fBool, nStart, nNext, 
SHRT_MAX);
 }
 
 void ScJumpMatrix::GetJump(
@@ -93,7 +92,7 @@ void ScJumpMatrix::GetJump(
 nCol = 0;
 nRow = 0;
 }
-pJump[(sal_uLong)nCol * nRows + nRow].
+mvJump[(sal_uLong)nCol * nRows + nRow].
 GetJump(rBool, rStart, rNext, rStop);
 }
 
@@ -102,7 +101,7 @@ void ScJumpMatrix::SetAllJumps(double fBool, short nStart, 
short nNext, short nS
 sal_uLong n = (sal_uLong)nCols * nRows;
 for (sal_uLong j = 0; j < n; ++j)
 {
-pJump[j].SetJump(fBool, nStart,
+mvJump[j].SetJump(fBool, nStart,
  nNext, nStop);
 }
 }
commit 25e92d7f7c915e26febd8c868a6531d99aac30cd
Author: Noel Grandin 
Date:   Mon Apr 10 10:15:59 2017 +0200

loplugin:inlinefields in XMLTextParagraphExport

Change-Id: If0e80fbe21b6d8bed55357d7fc09027fc4a37e06
Reviewed-on: https://gerrit.libreoffice.org/36373
Tested-by: Jenkins 
Reviewed-by: Noel Grandin 

diff --git a/include/xmloff/txtparae.hxx b/include/xmloff/txtparae.hxx
index 070c392cc7bc..9f737e665b1b 100644
--- a/include/xmloff/txtparae.hxx
+++ b/include/xmloff/txtparae.hxx
@@ -29,6 +29,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -86,7 +87,7 @@ class XMLOFF_DLLPUBLIC XMLTextParagraphExport : public 
XMLStyleExport
 const ::std::unique_ptr< ::xmloff::BoundFrameSets > pBoundFrameSets;
 XMLTextFieldExport  *pFieldExport;
 std::vector  *pListElements;
-XMLTextListAutoStylePool*pListAutoPool;
+XMLTextListAutoStylePoolmaListAutoPool;
 XMLSectionExport*pSectionExport;
 XMLIndexMarkExport  *pIndexMarkExport;
 
@@ -587,7 +588,7 @@ private:
 inline const XMLTextListAutoStylePool&
 XMLTextParagraphExport::GetListAutoStylePool() const
 {
-return *pListAutoPool;
+return maListAutoPool;
 }
 
 inline void XMLTextParagraphExport::exportTextFrame(
diff --git a/xmloff/source/text/txtparae.cxx b/xmloff/source/text/txtparae.cxx
index 62491265a464..c64d8662794a 100644
--- a/xmloff/source/text/txtparae.cxx
+++ b/xmloff/source/text/txtparae.cxx
@@ -531,7 +531,7 @@ void XMLTextParagraphExport::Add( sal_uInt16 nFamily,
 }
 }
   

[Libreoffice-commits] core.git: 2 commits - include/xmloff sc/source xmloff/source

2013-05-23 Thread Markus Mohrhard
 include/xmloff/numehelp.hxx   |3 ++-
 sc/source/filter/xml/xmlexprt.cxx |   18 +-
 xmloff/source/style/numehelp.cxx  |6 +-
 3 files changed, 16 insertions(+), 11 deletions(-)

New commits:
commit be9034ec5c43a3dcbebaa75e9eb47a024d4c6072
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Thu May 23 16:09:36 2013 +0200

prevent invalid files if file contains currency formats

A regression from writing error cell information into the file.

Change-Id: Idb55646094fcd76912bdcd2102370681bcc8703d

diff --git a/include/xmloff/numehelp.hxx b/include/xmloff/numehelp.hxx
index 7aa3922..22bf181 100644
--- a/include/xmloff/numehelp.hxx
+++ b/include/xmloff/numehelp.hxx
@@ -104,7 +104,8 @@ public :
   sal_Bool bExportValue = sal_True, 
sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
 void SetNumberFormatAttributes(const sal_Int32 nNumberFormat,
   const double rValue,
-  sal_Bool bExportValue = sal_True, 
sal_uInt16 nNamespace = XML_NAMESPACE_OFFICE);
+  sal_Bool bExportValue = sal_True,
+  sal_uInt16 nNamespace = 
XML_NAMESPACE_OFFICE, bool bExportCurrencySymbol = true);
 void SetNumberFormatAttributes(const OUString rValue,
   const OUString rCharacters,
   sal_Bool bExportValue = sal_True,
diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 05d8da8..a4cbb40 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++ b/sc/source/filter/xml/xmlexprt.cxx
@@ -2876,7 +2876,7 @@ void ScXMLExport::WriteCell(ScMyCell aCell, sal_Int32 
nEqualCellCount)
 aCell.nNumberFormat, aCell.fValue);
 if( getDefaultVersion()  SvtSaveOptions::ODFVER_012 )
 
GetNumberFormatAttributesExportHelper()-SetNumberFormatAttributes(
-aCell.nNumberFormat, aCell.fValue, false, 
XML_NAMESPACE_CALC_EXT);
+aCell.nNumberFormat, aCell.fValue, false, 
XML_NAMESPACE_CALC_EXT, false);
 }
 break;
 case table::CellContentType_TEXT :
@@ -2940,7 +2940,7 @@ void ScXMLExport::WriteCell(ScMyCell aCell, sal_Int32 
nEqualCellCount)
 {
 
GetNumberFormatAttributesExportHelper()-SetNumberFormatAttributes(
 
pFormulaCell-GetStandardFormat(*pDoc-GetFormatTable(), 0),
-pDoc-GetValue( aCellPos ), false, 
XML_NAMESPACE_CALC_EXT);
+pDoc-GetValue( aCellPos ), false, 
XML_NAMESPACE_CALC_EXT, false);
 }
 }
 }
@@ -2953,7 +2953,7 @@ void ScXMLExport::WriteCell(ScMyCell aCell, sal_Int32 
nEqualCellCount)
 if( getDefaultVersion()  
SvtSaveOptions::ODFVER_012 )
 {
 
GetNumberFormatAttributesExportHelper()-SetNumberFormatAttributes(
-aCell.nNumberFormat, 
pDoc-GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT );
+aCell.nNumberFormat, 
pDoc-GetValue( aCellPos ), false, XML_NAMESPACE_CALC_EXT, false );
 
 }
 }
diff --git a/xmloff/source/style/numehelp.cxx b/xmloff/source/style/numehelp.cxx
index f510bd5..33396f1 100644
--- a/xmloff/source/style/numehelp.cxx
+++ b/xmloff/source/style/numehelp.cxx
@@ -517,13 +517,17 @@ void 
XMLNumberFormatAttributesExportHelper::WriteAttributes(
 }
 
 void XMLNumberFormatAttributesExportHelper::SetNumberFormatAttributes(
-const sal_Int32 nNumberFormat, const double rValue, sal_Bool 
bExportValue, sal_uInt16 nNamespace)
+const sal_Int32 nNumberFormat, const double rValue, sal_Bool bExportValue,
+sal_uInt16 nNamespace, bool bExportCurrencySymbol)
 {
 if (pExport)
 {
 bool bIsStandard;
 OUString sCurrency;
 sal_Int16 nTypeKey = GetCellType(nNumberFormat, sCurrency, 
bIsStandard);
+if(!bExportCurrencySymbol)
+sCurrency = OUString();
+
 WriteAttributes(nTypeKey, rValue, sCurrency, bExportValue, nNamespace);
 }
 else {
commit cb92803765275eb2a9b4f92b63dd01350ee81c32
Author: Markus Mohrhard markus.mohrh...@googlemail.com
Date:   Wed May 22 23:11:06 2013 +0200

only export these attributes into ODF1.2 extended

Change-Id: I6a7fcb55287e61af3a3cd041d187d5d4c693bc6c

diff --git a/sc/source/filter/xml/xmlexprt.cxx 
b/sc/source/filter/xml/xmlexprt.cxx
index 28a155a..05d8da8 100644
--- a/sc/source/filter/xml/xmlexprt.cxx
+++