diff options
author | Matteo Casalin <matteo.casalin@yahoo.com> | 2018-05-01 10:21:41 +0200 |
---|---|---|
committer | Matteo Casalin <matteo.casalin@yahoo.com> | 2018-06-03 12:17:43 +0200 |
commit | e0349dc6587f77e69ed6586a095d9a215a834a77 (patch) | |
tree | 434a27ac9038aa6d9f4348d23559c3fe9bfa8be2 /sw/source/uibase/dochdl | |
parent | 436191347914b81bb4d4cc02e594f4b47b8df8f5 (diff) |
Simplify: reduce calls to getTokenCount
Change-Id: I740a910cfc5f42b71b91f597d23f7d53dca89643
Diffstat (limited to 'sw/source/uibase/dochdl')
-rw-r--r-- | sw/source/uibase/dochdl/swdtflvr.cxx | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 408e1509856c..d1f7b5e662e1 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2138,17 +2138,16 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, { do { // middle checked loop + const sal_Int32 nNewlines{comphelper::string::getTokenCount(aExpand, '\n')}; // When data comes from a spreadsheet, we add a DDE-table if( ( rData.HasFormat( SotClipboardFormatId::SYLK ) || rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) && !aExpand.isEmpty() && - ( 1 < comphelper::string::getTokenCount(aExpand, '\n') || + ( 1 < nNewlines || comphelper::string::getTokenCount(aExpand, '\t') ) ) { - sal_Int32 nRows = comphelper::string::getTokenCount(aExpand, '\n'); - if( nRows ) - --nRows; - sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); + const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; + const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); // don't try to insert tables that are too large for writer if (nRows > SAL_MAX_UINT16 || nCols > SAL_MAX_UINT16) @@ -2182,7 +2181,7 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, SwInsertTableOptions( SwInsertTableFlags::SplitLayout, 1 ), // TODO MULTIHEADER pDDETyp, nRows, nCols ); } - else if( 1 < comphelper::string::getTokenCount(aExpand, '\n') ) + else if( nNewlines > 1 ) { // multiple paragraphs -> insert a protected section if( rWrtShell.HasSelection() ) |