cui/source/inc/autocdlg.hxx | 4 ++-- cui/source/tabpages/autocdlg.cxx | 37 ++++++++++++++++--------------------- hwpfilter/source/hwpeq.cxx | 19 ++++++++----------- sw/source/core/edit/edglss.cxx | 6 +----- sw/source/uibase/envelp/envimg.cxx | 10 +++------- 5 files changed, 30 insertions(+), 46 deletions(-)
New commits: commit 4805a1348bb3749d468656a4e648064dabe1fd04 Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Feb 27 09:30:46 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Feb 27 09:54:20 2023 +0000 Optional may be avoided here, too Change-Id: I6320f8b745ead030cb7ae304bdf85e0064a57380 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147751 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/cui/source/inc/autocdlg.hxx b/cui/source/inc/autocdlg.hxx index 8e31011e7a33..7b4842314779 100644 --- a/cui/source/inc/autocdlg.hxx +++ b/cui/source/inc/autocdlg.hxx @@ -166,7 +166,7 @@ private: std::set<OUString> aFormatText; std::map<LanguageType, DoubleStringArray> aDoubleStringTable; - std::optional<CollatorWrapper> moCompareClass; + CollatorWrapper maCompareClass; std::unique_ptr<CharClass> pCharClass; LanguageType eLang; @@ -227,7 +227,7 @@ class OfaAutocorrExceptPage : public SfxTabPage { private: StringsTable aStringsTable; - std::optional<CollatorWrapper> moCompareClass; + CollatorWrapper maCompareClass; LanguageType eLang; std::unique_ptr<weld::Entry> m_xAbbrevED; diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index f8c4a16d0c6e..446775c6abad 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -667,6 +667,7 @@ IMPL_LINK_NOARG(OfaSwAutoFmtOptionsPage, EditHdl, weld::Button&, void) OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorreplacepage.ui", "AcorReplacePage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , bHasSelectionText(false) , bFirstSelect(true) @@ -698,8 +699,7 @@ OfaAutocorrReplacePage::OfaAutocorrReplacePage(weld::Container* pPage, weld::Dia bSWriter = pMod == SfxModule::GetActiveModule(); LanguageTag aLanguageTag( eLastDialogLanguage ); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); auto nColWidth = m_xReplaceTLB->get_approximate_digit_width() * 32; @@ -722,7 +722,6 @@ OfaAutocorrReplacePage::~OfaAutocorrReplacePage() aDoubleStringTable.clear(); aChangesTable.clear(); - moCompareClass.reset(); pCharClass.reset(); } @@ -904,8 +903,8 @@ void OfaAutocorrReplacePage::SetLanguage(LanguageType eSet) eLastDialogLanguage = eSet; LanguageTag aLanguageTag( eLastDialogLanguage ); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLanguageTag.getLocale(), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( aLanguageTag.getLocale(), 0 ); pCharClass.reset( new CharClass( std::move(aLanguageTag) ) ); ModifyHdl(*m_xShortED); } @@ -919,7 +918,7 @@ IMPL_LINK(OfaAutocorrReplacePage, SelectHdl, weld::TreeView&, rBox, void) OUString sTmpShort(rBox.get_text(nEntry, 0)); // if the text is set via ModifyHdl, the cursor is always at the beginning // of a word, although you're editing here - bool bSameContent = 0 == moCompareClass->compareString(sTmpShort, m_xShortED->get_text()); + bool bSameContent = 0 == maCompareClass.compareString(sTmpShort, m_xShortED->get_text()); int nStartPos, nEndPos; m_xShortED->get_selection_bounds(nStartPos, nEndPos); if (m_xShortED->get_text() != sTmpShort) @@ -1057,7 +1056,7 @@ bool OfaAutocorrReplacePage::NewDelHdl(const weld::Widget* pBtn) int nCount = m_xReplaceTLB->n_children(); for (j = 0; j < nCount; ++j) { - if (0 >= moCompareClass->compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) + if (0 >= maCompareClass.compareString(sEntry, m_xReplaceTLB->get_text(j, 0))) break; } nPos = j; @@ -1110,7 +1109,7 @@ IMPL_LINK(OfaAutocorrReplacePage, ModifyHdl, weld::Entry&, rEdt, void) &bTmpSelEntry, &bFirstSelIterSet, &xFirstSel, &aWordStr](weld::TreeIter& rIter){ OUString aTestStr = m_xReplaceTLB->get_text(rIter, 0); - if( moCompareClass->compareString(rEntry, aTestStr ) == 0 ) + if( maCompareClass.compareString(rEntry, aTestStr ) == 0 ) { if (!rRepString.isEmpty()) bFirstSelect = true; @@ -1191,6 +1190,7 @@ static bool lcl_FindInArray(std::vector<OUString>& rStrings, std::u16string_view OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rSet) : SfxTabPage(pPage, pController, "cui/ui/acorexceptpage.ui", "AcorExceptPage", &rSet) + , maCompareClass(comphelper::getProcessComponentContext()) , eLang(eLastDialogLanguage) , m_xAbbrevED(m_xBuilder->weld_entry("abbrev")) , m_xAbbrevLB(m_xBuilder->weld_tree_view("abbrevlist")) @@ -1210,8 +1210,7 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo m_xDoubleCapsLB->set_size_request(-1, m_xDoubleCapsLB->get_height_rows(6)); css::lang::Locale aLcl( LanguageTag::convertToLocale(eLastDialogLanguage )); - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( aLcl, 0 ); + maCompareClass.loadDefaultCollator( aLcl, 0 ); m_xNewAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); m_xDelAbbrevPB->connect_clicked(LINK(this, OfaAutocorrExceptPage, NewDelButtonHdl)); @@ -1230,7 +1229,6 @@ OfaAutocorrExceptPage::OfaAutocorrExceptPage(weld::Container* pPage, weld::Dialo OfaAutocorrExceptPage::~OfaAutocorrExceptPage() { aStringsTable.clear(); - moCompareClass.reset(); } std::unique_ptr<SfxTabPage> OfaAutocorrExceptPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -1365,8 +1363,8 @@ void OfaAutocorrExceptPage::SetLanguage(LanguageType eSet) // save old settings and fill anew RefillReplaceBoxes(false, eLang, eSet); eLastDialogLanguage = eSet; - moCompareClass.emplace( comphelper::getProcessComponentContext() ); - moCompareClass->loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); + maCompareClass = CollatorWrapper( comphelper::getProcessComponentContext() ); + maCompareClass.loadDefaultCollator( LanguageTag::convertToLocale( eLastDialogLanguage ), 0 ); ModifyHdl(*m_xAbbrevED); ModifyHdl(*m_xDoubleCapsED); } @@ -1511,7 +1509,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) bool bEntryLen = !sEntry.isEmpty(); if (&rEdt == m_xAbbrevED.get()) { - bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, *moCompareClass); + bool bSame = lcl_FindEntry(*m_xAbbrevLB, sEntry, maCompareClass); if(bSame && sEntry != m_xAbbrevLB->get_selected_text()) rEdt.set_text(m_xAbbrevLB->get_selected_text()); m_xNewAbbrevPB->set_sensitive(!bSame && bEntryLen); @@ -1519,7 +1517,7 @@ IMPL_LINK(OfaAutocorrExceptPage, ModifyHdl, weld::Entry&, rEdt, void) } else { - bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, *moCompareClass); + bool bSame = lcl_FindEntry(*m_xDoubleCapsLB, sEntry, maCompareClass); if(bSame && sEntry != m_xDoubleCapsLB->get_selected_text()) rEdt.set_text(m_xDoubleCapsLB->get_selected_text()); m_xNewDoublePB->set_sensitive(!bSame && bEntryLen); commit 59bc90c9d60b5f425f29ce42d1db9381eb2c1f4d Author: Mike Kaganski <mike.kagan...@collabora.com> AuthorDate: Mon Feb 27 09:26:41 2023 +0300 Commit: Mike Kaganski <mike.kagan...@collabora.com> CommitDate: Mon Feb 27 09:54:16 2023 +0000 Use SAL_NEWLINE_STRING to avoid some wheel re-invention Change-Id: Ib60ddf2b1111fb2d6caf22ac6e0848bd27373b9e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147750 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com> diff --git a/cui/source/tabpages/autocdlg.cxx b/cui/source/tabpages/autocdlg.cxx index 21716d43a1a9..f8c4a16d0c6e 100644 --- a/cui/source/tabpages/autocdlg.cxx +++ b/cui/source/tabpages/autocdlg.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <i18nutil/unicode.hxx> #include <o3tl/safeint.hxx> #include <utility> @@ -2113,12 +2115,7 @@ void OfaAutoCompleteTabPage::CopyToClipboard() const for (auto a : rows) { - sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode)); -#if defined(_WIN32) - sData.append("\015\012"); -#else - sData.append("\012"); -#endif + sData.append(OUStringToOString(m_xLBEntries->get_text(a), nEncode) + SAL_NEWLINE_STRING); } pCntnr->CopyByteString( SotClipboardFormatId::STRING, sData.makeStringAndClear() ); pCntnr->CopyToClipboard(m_xLBEntries->get_clipboard()); diff --git a/hwpfilter/source/hwpeq.cxx b/hwpfilter/source/hwpeq.cxx index a19bee24acbb..30e12e4e5e9e 100644 --- a/hwpfilter/source/hwpeq.cxx +++ b/hwpfilter/source/hwpeq.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <assert.h> #include <stdio.h> #include <string.h> @@ -33,11 +35,6 @@ #include <rtl/character.hxx> /* @Man: change the hwp formula to LaTeX */ -#ifdef _WIN32 -# define ENDL "\r\n" -#else /* !_WIN32 */ -# define ENDL "\n" -#endif #define EQ_CASE 0x01 // case sensitive cmd #define EQ_ENV 0x02 // equiv to latex environment @@ -740,11 +737,11 @@ static char eq2ltxconv(MzString& sstr, std::istream *strm, const char *sentinel) next_token(white, token, strm); if( token[0] != '{' ) return 0; - sstr << "\\begin" << "{" << eq->key << "}" << ENDL ; + sstr << "\\begin" << "{" << eq->key << "}" << SAL_NEWLINE_STRING ; eq2ltxconv(sstr, strm, "}"); if( sstr[sstr.length() - 1] != '\n' ) - sstr << ENDL ; - sstr << "\\end" << "{" << eq->key << "}" << ENDL ; + sstr << SAL_NEWLINE_STRING ; + sstr << "\\end" << "{" << eq->key << "}" << SAL_NEWLINE_STRING ; } else if( eq && (eq->flag & EQ_ATOP) ) { if( sstr.length() == 0 ) @@ -788,11 +785,11 @@ void eq2latex(MzString& outs, char const *s) std::istringstream strm(tstr.c_str()); if( eqnarray ) - outs << "\\begin{array}{rllll}" << ENDL; + outs << "\\begin{array}{rllll}" << SAL_NEWLINE_STRING; eq2ltxconv(outs, &strm, nullptr); - outs << ENDL; + outs << SAL_NEWLINE_STRING; if( eqnarray ) - outs << "\\end{array}" << ENDL; + outs << "\\end{array}" << SAL_NEWLINE_STRING; delete stk; stk = nullptr; } diff --git a/sw/source/core/edit/edglss.cxx b/sw/source/core/edit/edglss.cxx index 836658d17236..4f1f69971f75 100644 --- a/sw/source/core/edit/edglss.cxx +++ b/sw/source/core/edit/edglss.cxx @@ -269,11 +269,7 @@ void SwEditShell::GetSelectedText( OUString &rBuf, ParaBreakType nHndlParaBrk ) else if( IsSelFullPara() && ParaBreakType::ToOnlyCR != nHndlParaBrk ) { -#ifdef _WIN32 - rBuf += "\015\012"; -#else - rBuf += "\012"; -#endif + rBuf += SAL_NEWLINE_STRING; } } else if( IsSelection() ) diff --git a/sw/source/uibase/envelp/envimg.cxx b/sw/source/uibase/envelp/envimg.cxx index 317179e570c2..b36cfdfa51f3 100644 --- a/sw/source/uibase/envelp/envimg.cxx +++ b/sw/source/uibase/envelp/envimg.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + #include <o3tl/any.hxx> #include <o3tl/string_view.hxx> #include <osl/diagnose.h> @@ -34,12 +36,6 @@ #include <unomid.h> -#ifdef _WIN32 -constexpr OUStringLiteral NEXTLINE = u"\r\n"; -#else -constexpr OUStringLiteral NEXTLINE = u"\n"; -#endif - using namespace utl; using namespace ::com::sun::star::uno; @@ -68,7 +64,7 @@ OUString MakeSender() else if (sToken == u"CR") { if(bLastLength) - sRet.append(NEXTLINE); + sRet.append(SAL_NEWLINE_STRING); bLastLength = true; } else if (sToken == u"FIRSTNAME")