sw/source/ui/vba/vbaselection.cxx | 10 ++++---- sw/source/uibase/dochdl/swdtflvr.cxx | 36 ++++++++++--------------------- vcl/source/edit/texteng.cxx | 2 - vcl/source/filter/FilterConfigItem.cxx | 3 +- vcl/source/filter/graphicfilter.cxx | 7 +++--- vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx | 33 ++++++++++++++++++---------- 6 files changed, 45 insertions(+), 46 deletions(-)
New commits: commit 565340d457f41197474a75ba1b036bdc3d569041 Author: Matteo Casalin <[email protected]> Date: Sat Jun 2 23:55:42 2018 +0200 Fix tdf#100937: LO Freezed when I insert a very long text in... ... the Description box The issue was triggered by ImpVclMEdit::Resize initially calling TextEngine::SetMaxTextWidth() with a negative width (due to an initial empty area, further "reduced" to take into account a vertical scroll bar) and then with positive values in following iterations. I preferred to consider such negative widths a no-op instead of extending them to the "maximum" possible width. Change-Id: I756652a30c23ebe6674e481e7d8d6e0d8ba45e75 diff --git a/vcl/source/edit/texteng.cxx b/vcl/source/edit/texteng.cxx index 3beff673c1be..90f40a0f939d 100644 --- a/vcl/source/edit/texteng.cxx +++ b/vcl/source/edit/texteng.cxx @@ -219,7 +219,7 @@ void TextEngine::SetMaxTextLen( sal_Int32 nLen ) void TextEngine::SetMaxTextWidth( long nMaxWidth ) { - if ( nMaxWidth != mnMaxTextWidth ) + if ( nMaxWidth>=0 && nMaxWidth != mnMaxTextWidth ) { mnMaxTextWidth = nMaxWidth; FormatFullDoc(); commit 91b5e86d5ef1318bd894b1fc3b537fb4615673da Author: Matteo Casalin <[email protected]> Date: Wed May 30 20:49:22 2018 +0200 Improve 1a2ee0ecd5b0cff52922c1d261f7d03a57a52ca0 Change-Id: I50f369f28c3b97ba7fed494cb238b7756920abc6 diff --git a/vcl/source/filter/graphicfilter.cxx b/vcl/source/filter/graphicfilter.cxx index 9f5d6caeb0eb..1ba3d1d776ec 100644 --- a/vcl/source/filter/graphicfilter.cxx +++ b/vcl/source/filter/graphicfilter.cxx @@ -2439,8 +2439,9 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r } else { - sal_Int32 nIdx{0}; - do { + sal_Int32 nIdx {aFilterPath.isEmpty() ? -1 : 0}; + while (nIdx>=0) + { #ifndef DISABLE_DYNLOADING OUString aPhysicalName( ImpCreateFullFilterPath( aFilterPath.getToken(0, ';', nIdx), aFilterName ) ); osl::Module aLibrary( aPhysicalName ); @@ -2471,7 +2472,7 @@ ErrCode GraphicFilter::ExportGraphic( const Graphic& rGraphic, const OUString& r } else nStatus = ERRCODE_GRFILTER_FILTERERROR; - } while (nIdx>=0); + } } } if( nStatus != ERRCODE_NONE ) commit 3c78a19ed66b44ebb2db7b160fa92a010a3c42aa Author: Matteo Casalin <[email protected]> Date: Wed May 30 20:37:20 2018 +0200 Try harder to find a matching file extension Potential regression from 2a39163aef4211c9d19cb1faee7f55d3718355b6 Change-Id: I67f1f11bd52a1dbf0f77a35df7ad556437ccd39b diff --git a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx index a222d603270c..e4f5ac395b8d 100644 --- a/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx +++ b/vcl/unx/gtk/fpicker/SalGtkFilePicker.cxx @@ -705,23 +705,32 @@ namespace bool lcl_matchFilter( const rtl::OUString& rFilter, const rtl::OUString& rExt ) { - const sal_Int32 nBegin = rFilter.indexOf(rExt); + const sal_Unicode cSep {';'}; + sal_Int32 nIdx {0}; - if (nBegin<0) // not found - return false; + for (;;) + { + const sal_Int32 nBegin = rFilter.indexOf(rExt, nIdx); - const sal_Unicode cSep{';'}; + if (nBegin<0) // not found + break; - // Check if the found occurrence is an exact match: left side - if (nBegin>0 && rFilter[nBegin-1]!=cSep) - return false; + // Let nIdx point to end of matched string, useful in order to + // check string boundaries and also for a possible next iteration + nIdx = nBegin + rExt.getLength(); - // Check if the found occurrence is an exact match: right side - const sal_Int32 nEnd = nBegin + rExt.getLength(); - if (nEnd<rFilter.getLength() && rFilter[nEnd]!=cSep) - return false; + // Check if the found occurrence is an exact match: right side + if (nIdx<rFilter.getLength() && rFilter[nIdx]!=cSep) + continue; - return true; + // Check if the found occurrence is an exact match: left side + if (nBegin>0 && rFilter[nBegin-1]!=cSep) + continue; + + return true; + } + + return false; } } commit 85613aa81a885488f99ed038f2254ddb0c8a1037 Author: Matteo Casalin <[email protected]> Date: Wed May 16 23:26:44 2018 +0200 Fix tdf#117410 - UI: Settings in PDF Options not remembered... for next export Change-Id: I6f066c81d96595a4560f5bb9e148001b004b38f0 diff --git a/vcl/source/filter/FilterConfigItem.cxx b/vcl/source/filter/FilterConfigItem.cxx index 170e4b956046..0eedb63b408d 100644 --- a/vcl/source/filter/FilterConfigItem.cxx +++ b/vcl/source/filter/FilterConfigItem.cxx @@ -68,7 +68,8 @@ static bool ImpIsTreeAvailable( Reference< XMultiServiceFactory > const & rXCfgP } if ( xReadAccess.is() ) { - while (bAvailable && nIdx>=0 ) + const sal_Int32 nEnd {rTree.getLength()}; + while (bAvailable && nIdx>=0 && nIdx<nEnd) { Reference< XHierarchicalNameAccess > xHierarchicalNameAccess ( xReadAccess, UNO_QUERY ); commit c4fb67f712ddde0e31bda0f22ef4e4247d63ea9a Author: Matteo Casalin <[email protected]> Date: Tue May 1 10:58:16 2018 +0200 Simplify: not empty OUString has at least one token Change-Id: Iae1ce8dc951f394effb942cba0f19a531b42aea0 diff --git a/sw/source/ui/vba/vbaselection.cxx b/sw/source/ui/vba/vbaselection.cxx index 0edfc055cd12..55e16e70490b 100644 --- a/sw/source/ui/vba/vbaselection.cxx +++ b/sw/source/ui/vba/vbaselection.cxx @@ -27,7 +27,6 @@ #include <com/sun/star/text/ControlCharacter.hpp> #include <com/sun/star/table/XCell.hpp> #include <basic/sberrors.hxx> -#include <comphelper/string.hxx> #include <ooo/vba/word/WdUnits.hpp> #include <ooo/vba/word/WdMovementType.hpp> #include <ooo/vba/word/WdGoToItem.hpp> @@ -976,11 +975,12 @@ void SwVbaSelection::GetSelectedCellRange( OUString& sTLName, OUString& sBRName uno::Reference< text::XTextTableCursor > xTextTableCursor( mxModel->getCurrentSelection(), uno::UNO_QUERY ); if( xTextTableCursor.is() ) { - OUString sRange( xTextTableCursor->getRangeName() ); - if( comphelper::string::getTokenCount(sRange, ':') > 0 ) + const OUString sRange( xTextTableCursor->getRangeName() ); + if (!sRange.isEmpty()) { - sTLName = sRange.getToken(0, ':'); - sBRName = sRange.getToken(1, ':'); + sal_Int32 nIdx{0}; + sTLName = sRange.getToken(0, ':', nIdx); + sBRName = sRange.getToken(0, ':', nIdx); } } if( sTLName.isEmpty() ) commit 7723926deb6dcea1049faf49c2b34e27297a8bda Author: Matteo Casalin <[email protected]> Date: Tue May 1 10:48:49 2018 +0200 Optimize: low-complexity checks first Change-Id: Icbd126e098873f17d8e4f1d3127c0c0b7a0a82eb diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index ac12153aa2b3..996632519910 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2140,9 +2140,9 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, 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() ) + if( !aExpand.isEmpty() && + ( rData.HasFormat( SotClipboardFormatId::SYLK ) || + rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) ) { const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); commit 856c1ea7c6f0ff08b3fb0dc23e9eb9483fa501ba Author: Matteo Casalin <[email protected]> Date: Tue May 1 10:30:40 2018 +0200 Simplify: not empty OUString has at least one token Change-Id: I2ab30dc532e3778a6101757bd0f2957c2311c3e9 diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index d1f7b5e662e1..ac12153aa2b3 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2142,9 +2142,7 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, // When data comes from a spreadsheet, we add a DDE-table if( ( rData.HasFormat( SotClipboardFormatId::SYLK ) || rData.HasFormat( SotClipboardFormatId::SYLK_BIGCAPS ) ) && - !aExpand.isEmpty() && - ( 1 < nNewlines || - comphelper::string::getTokenCount(aExpand, '\t') ) ) + !aExpand.isEmpty() ) { const sal_Int32 nRows = nNewlines ? nNewlines-1 : 0; const sal_Int32 nCols = comphelper::string::getTokenCount(aExpand.getToken(0, '\n'), '\t'); commit e0349dc6587f77e69ed6586a095d9a215a834a77 Author: Matteo Casalin <[email protected]> Date: Tue May 1 10:21:41 2018 +0200 Simplify: reduce calls to getTokenCount Change-Id: I740a910cfc5f42b71b91f597d23f7d53dca89643 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() ) commit 436191347914b81bb4d4cc02e594f4b47b8df8f5 Author: Matteo Casalin <[email protected]> Date: Tue May 1 10:03:44 2018 +0200 OUString: simplify and reduce temporaries Change-Id: I86abb83cad333ff2d119d33d767f54be206e90da diff --git a/sw/source/uibase/dochdl/swdtflvr.cxx b/sw/source/uibase/dochdl/swdtflvr.cxx index 5c7a9f474780..408e1509856c 100644 --- a/sw/source/uibase/dochdl/swdtflvr.cxx +++ b/sw/source/uibase/dochdl/swdtflvr.cxx @@ -2102,15 +2102,13 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, const ::utl::TransliterationWrapper& rColl = ::GetAppCmpStrIgnore(); do { - aName = aApp; - aName += OUString::number( i ); + aName = aApp + OUString::number( i ); for( j = INIT_FLDTYPES; j < nSize; j++ ) { pTyp = rWrtShell.GetFieldType( j ); if( SwFieldIds::Dde == pTyp->Which() ) { - OUString sTmp( static_cast<SwDDEFieldType*>(pTyp)->GetCmd() ); - if( rColl.isEqual( sTmp, aCmd ) && + if( rColl.isEqual( static_cast<SwDDEFieldType*>(pTyp)->GetCmd(), aCmd ) && SfxLinkUpdateMode::ALWAYS == static_cast<SwDDEFieldType*>(pTyp)->GetType() ) { aName = pTyp->GetName(); @@ -2147,12 +2145,10 @@ bool SwTransferable::PasteDDE( TransferableDataHelper& rData, ( 1 < comphelper::string::getTokenCount(aExpand, '\n') || comphelper::string::getTokenCount(aExpand, '\t') ) ) { - OUString sTmp( aExpand ); - sal_Int32 nRows = comphelper::string::getTokenCount(sTmp, '\n'); + sal_Int32 nRows = comphelper::string::getTokenCount(aExpand, '\n'); if( nRows ) --nRows; - sTmp = sTmp.getToken( 0, '\n' ); - sal_Int32 nCols = comphelper::string::getTokenCount(sTmp, '\t'); + 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) @@ -2787,14 +2783,9 @@ bool SwTransferable::CheckForURLOrLNKFile( TransferableDataHelper& rData, } else { - sal_Int32 nLen = rFileName.getLength(); - if( 4 < nLen && '.' == rFileName[ nLen - 4 ]) + if( rFileName.getLength()>4 && rFileName.endsWithIgnoreAsciiCase(".url") ) { - OUString sExt( rFileName.copy( nLen - 3 )); - if( sExt.equalsIgnoreAsciiCase( "url" )) - { - OSL_ENSURE( false, "how do we read today .URL - Files?" ); - } + OSL_ENSURE( false, "how do we read today .URL - Files?" ); } } return bIsURLFile; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
