From dde3a753cead04915259d3fde0e913096f1a3922 Mon Sep 17 00:00:00 2001 From: Ivan Timofeev Date: Wed, 14 Aug 2013 18:41:28 +0400 Subject: convert Read/WriteUserData methods to OUString and bool Change-Id: I06a8158b7f503976b19383014a7c8a867c0184ea --- sw/inc/shellio.hxx | 4 +- sw/source/filter/basflt/fltini.cxx | 111 +++++++++++++++++----------------- sw/source/ui/dbui/mmoutputpage.cxx | 4 +- sw/source/ui/dialog/ascfldlg.cxx | 4 +- sw/source/ui/inc/pview.hxx | 6 +- sw/source/ui/inc/view.hxx | 4 +- sw/source/ui/uiview/pview.cxx | 2 +- sw/source/ui/uiview/view.cxx | 42 ++++++------- sw/source/ui/uiview/view1.cxx | 2 +- sw/source/ui/uno/SwXFilterOptions.cxx | 4 +- 10 files changed, 90 insertions(+), 93 deletions(-) (limited to 'sw') diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx index fa3f34bb8255..b58dceff1993 100644 --- a/sw/inc/shellio.hxx +++ b/sw/inc/shellio.hxx @@ -90,8 +90,8 @@ public: nLanguage = 0; } // for the automatic conversion (mail/news/...) - void ReadUserData( const String& ); - void WriteUserData( String& ); + void ReadUserData( const OUString& ); + void WriteUserData( OUString& ); SwAsciiOptions() { Reset(); } }; diff --git a/sw/source/filter/basflt/fltini.cxx b/sw/source/filter/basflt/fltini.cxx index 963156e236d5..f90d0e3750cb 100644 --- a/sw/source/filter/basflt/fltini.cxx +++ b/sw/source/filter/basflt/fltini.cxx @@ -598,71 +598,70 @@ String NameFromCharSet(rtl_TextEncoding nChrSet) // the delimetercharacter is "," // -void SwAsciiOptions::ReadUserData( const String& rStr ) +void SwAsciiOptions::ReadUserData( const OUString& rStr ) { - sal_Int32 nToken = 0; - sal_uInt16 nCnt = 0; - String sToken; - do { - if( 0 != (sToken = rStr.GetToken( 0, ',', nToken )).Len() ) - { - switch( nCnt ) - { - case 0: // CharSet + sal_Int32 nToken = 0; + sal_uInt16 nCnt = 0; + OUString sToken; + do { + if( !(sToken = rStr.getToken( 0, ',', nToken )).isEmpty() ) + { + switch( nCnt ) + { + case 0: // CharSet eCharSet = CharSetFromName(sToken); - break; - case 1: // LineEnd - if( sToken.EqualsIgnoreCaseAscii( "CRLF" )) - eCRLF_Flag = LINEEND_CRLF; - else if( sToken.EqualsIgnoreCaseAscii( "LF" )) - eCRLF_Flag = LINEEND_LF; - else - eCRLF_Flag = LINEEND_CR; - break; - case 2: // fontname - sFont = sToken; - break; - case 3: // Language + break; + case 1: // LineEnd + if( sToken.equalsIgnoreAsciiCase( "CRLF" )) + eCRLF_Flag = LINEEND_CRLF; + else if( sToken.equalsIgnoreAsciiCase( "LF" )) + eCRLF_Flag = LINEEND_LF; + else + eCRLF_Flag = LINEEND_CR; + break; + case 2: // fontname + sFont = sToken; + break; + case 3: // Language nLanguage = LanguageTag::convertToLanguageType( sToken ); - break; - } - } - ++nCnt; - } while( -1 != nToken ); + break; + } + } + ++nCnt; + } while( -1 != nToken ); } -void SwAsciiOptions::WriteUserData( String& rStr ) +void SwAsciiOptions::WriteUserData(OUString& rStr) { - // 1. charset - rStr = NameFromCharSet(eCharSet); - rStr += ','; + // 1. charset + rStr = NameFromCharSet(eCharSet); + rStr += ","; - // 2. LineEnd - switch(eCRLF_Flag) - { - case LINEEND_CRLF: - rStr.AppendAscii( "CRLF" ); - break; - case LINEEND_CR: - rStr.AppendAscii( "CR" ); - break; - case LINEEND_LF: - rStr.AppendAscii( "LF" ); - break; - } - rStr += ','; + // 2. LineEnd + switch(eCRLF_Flag) + { + case LINEEND_CRLF: + rStr += "CRLF"; + break; + case LINEEND_CR: + rStr += "CR"; + break; + case LINEEND_LF: + rStr += "LF"; + break; + } + rStr += ","; - // 3. Fontname - rStr += sFont; - rStr += ','; + // 3. Fontname + rStr += sFont; + rStr += ","; - // 4. Language - if (nLanguage) - { - OUString sTmp = LanguageTag::convertToBcp47( nLanguage ); - rStr += (String)sTmp; - } - rStr += ','; + // 4. Language + if (nLanguage) + { + rStr += LanguageTag::convertToBcp47(nLanguage); + } + rStr += ","; } #ifdef DISABLE_DYNLOADING diff --git a/sw/source/ui/dbui/mmoutputpage.cxx b/sw/source/ui/dbui/mmoutputpage.cxx index cf3d9b06b20e..7d239ae21a02 100644 --- a/sw/source/ui/dbui/mmoutputpage.cxx +++ b/sw/source/ui/dbui/mmoutputpage.cxx @@ -1139,7 +1139,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) if(!sEMailColumn.Len() || !xColAccess.is() || !xColAccess->hasByName(sEMailColumn)) return 0; - String sFilterOptions; + OUString sFilterOptions; if(MM_DOCTYPE_TEXT == nDocType) { SwAsciiOptions aOpt; @@ -1212,7 +1212,7 @@ IMPL_LINK(SwMailMergeOutputPage, SendDocumentsHdl_Impl, PushButton*, pButton) if(MM_DOCTYPE_TEXT == nDocType) { pFilterValues[1].Name = "FilterOptions"; - pFilterValues[1].Value <<= OUString(sFilterOptions); + pFilterValues[1].Value <<= sFilterOptions; } uno::Reference< frame::XStorable > xTempStore( pTempView->GetDocShell()->GetModel(), uno::UNO_QUERY); diff --git a/sw/source/ui/dialog/ascfldlg.cxx b/sw/source/ui/dialog/ascfldlg.cxx index b808142a158f..bad86da75832 100644 --- a/sw/source/ui/dialog/ascfldlg.cxx +++ b/sw/source/ui/dialog/ascfldlg.cxx @@ -259,9 +259,9 @@ void SwAsciiFilterDlg::FillOptions( SwAsciiOptions& rOptions ) rOptions.SetParaFlags( GetCRLF() ); // save the user settings - String sData; + OUString sData; rOptions.WriteUserData( sData ); - if( sData.Len() ) + if (!sData.isEmpty()) { const OUString sFindNm = OUString::createFromAscii( m_pFontLB->IsVisible() ? sDialogImpExtraData diff --git a/sw/source/ui/inc/pview.hxx b/sw/source/ui/inc/pview.hxx index fbb8a725395f..3ca1ebc47032 100644 --- a/sw/source/ui/inc/pview.hxx +++ b/sw/source/ui/inc/pview.hxx @@ -151,9 +151,9 @@ class SW_DLLPUBLIC SwPagePreView: public SfxViewShell // current dispatcher shell SwPagePreViewWin aViewWin; //viewdata of the previous SwView and the new crsrposition - String sSwViewData, + OUString sSwViewData; //and the new cursor position if the user double click in the PagePreView - sNewCrsrPos; + String sNewCrsrPos; // to support keyboard the number of the page to go to can be set too sal_uInt16 nNewPage; // visible range @@ -246,7 +246,7 @@ public: sal_Bool HandleWheelCommands( const CommandEvent& ); - const String& GetPrevSwViewData() const { return sSwViewData; } + OUString GetPrevSwViewData() const { return sSwViewData; } void SetNewCrsrPos( const String& rStr ) { sNewCrsrPos = rStr; } const String& GetNewCrsrPos() const { return sNewCrsrPos; } diff --git a/sw/source/ui/inc/view.hxx b/sw/source/ui/inc/view.hxx index d7f538d1ac05..cd7a323d0fb7 100644 --- a/sw/source/ui/inc/view.hxx +++ b/sw/source/ui/inc/view.hxx @@ -598,8 +598,8 @@ public: // so that in the SubShells' DTors m_pShell can be reset if applicable void ResetSubShell() { m_pShell = 0; } - virtual void WriteUserData(String &, sal_Bool bBrowse = sal_False ); - virtual void ReadUserData(const String &, sal_Bool bBrowse = sal_False ); + virtual void WriteUserData(OUString &, bool bBrowse = false); + virtual void ReadUserData(const OUString &, bool bBrowse = false); virtual void ReadUserDataSequence ( const com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse ); virtual void WriteUserDataSequence ( com::sun::star::uno::Sequence < com::sun::star::beans::PropertyValue >&, sal_Bool bBrowse ); diff --git a/sw/source/ui/uiview/pview.cxx b/sw/source/ui/uiview/pview.cxx index 838462d30201..ca2c767a9e42 100644 --- a/sw/source/ui/uiview/pview.cxx +++ b/sw/source/ui/uiview/pview.cxx @@ -1185,7 +1185,7 @@ SwPagePreView::SwPagePreView(SfxViewFrame *pViewFrame, SfxViewShell* pOldSh): { pVS = ((SwView*)pOldSh)->GetWrtShellPtr(); // save the current ViewData of the previous SwView - pOldSh->WriteUserData( sSwViewData, sal_False ); + pOldSh->WriteUserData( sSwViewData, false ); } else pVS = GetDocShell()->GetWrtShell(); diff --git a/sw/source/ui/uiview/view.cxx b/sw/source/ui/uiview/view.cxx index 94fd75e401de..129c1d783eab 100644 --- a/sw/source/ui/uiview/view.cxx +++ b/sw/source/ui/uiview/view.cxx @@ -1086,7 +1086,7 @@ SwDocShell* SwView::GetDocShell() // Remember CursorPos -void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse ) +void SwView::WriteUserData( OUString &rUserData, bool bBrowse ) { // The browse flag will be passed from Sfx when documents are browsed // (not to be confused with the BrowseMode). @@ -1096,23 +1096,23 @@ void SwView::WriteUserData( String &rUserData, sal_Bool bBrowse ) const Rectangle& rVis = GetVisArea(); rUserData = OUString::number( rRect.Left() ); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( rRect.Top() ); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( m_pWrtShell->GetViewOptions()->GetZoom() ); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( rVis.Left() ); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( rVis.Top() ); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Right()); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( bBrowse ? SAL_MIN_INT32 : rVis.Bottom()); - rUserData += ';'; + rUserData += ";"; rUserData += OUString::number( (sal_uInt16)m_pWrtShell->GetViewOptions()->GetZoomType());//eZoom; - rUserData += ';'; - rUserData += FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? '0' : '1'; + rUserData += ";"; + rUserData += FRMTYPE_NONE == m_pWrtShell->GetSelFrmType() ? OUString("0") : OUString("1"); } // Set CursorPos @@ -1131,7 +1131,7 @@ static bool lcl_IsOwnDocument( SwView& rView ) (!Changed.Len() && Created.Len() && Created == FullName ); } -void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse ) +void SwView::ReadUserData( const OUString &rUserData, bool bBrowse ) { if ( comphelper::string::getTokenCount(rUserData, ';') > 1 && // For document without layout only in the onlinelayout or @@ -1146,17 +1146,17 @@ void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse ) // No it is *no* good idea to call GetToken within Point-Konstr. immediately, // because which parameter is evaluated first? - long nX = rUserData.GetToken( 0, ';', nPos ).ToInt32(), - nY = rUserData.GetToken( 0, ';', nPos ).ToInt32(); + long nX = rUserData.getToken( 0, ';', nPos ).toInt32(), + nY = rUserData.getToken( 0, ';', nPos ).toInt32(); Point aCrsrPos( nX, nY ); sal_uInt16 nZoomFactor = - static_cast< sal_uInt16 >( rUserData.GetToken(0, ';', nPos ).ToInt32() ); + static_cast< sal_uInt16 >( rUserData.getToken(0, ';', nPos ).toInt32() ); - long nLeft = rUserData.GetToken(0, ';', nPos ).ToInt32(), - nTop = rUserData.GetToken(0, ';', nPos ).ToInt32(), - nRight = rUserData.GetToken(0, ';', nPos ).ToInt32(), - nBottom= rUserData.GetToken(0, ';', nPos ).ToInt32(); + long nLeft = rUserData.getToken(0, ';', nPos ).toInt32(), + nTop = rUserData.getToken(0, ';', nPos ).toInt32(), + nRight = rUserData.getToken(0, ';', nPos ).toInt32(), + nBottom= rUserData.getToken(0, ';', nPos ).toInt32(); const long nAdd = m_pWrtShell->GetViewOptions()->getBrowseMode() ? DOCUMENTBORDER : DOCUMENTBORDER*2; if ( nBottom <= (m_pWrtShell->GetDocSize().Height()+nAdd) ) @@ -1165,17 +1165,17 @@ void SwView::ReadUserData( const String &rUserData, sal_Bool bBrowse ) const Rectangle aVis( nLeft, nTop, nRight, nBottom ); - sal_uInt16 nOff = 0; + sal_Int32 nOff = 0; SvxZoomType eZoom; if( !m_pWrtShell->GetViewOptions()->getBrowseMode() ) - eZoom = (SvxZoomType) (sal_uInt16)rUserData.GetToken(nOff, ';', nPos ).ToInt32(); + eZoom = (SvxZoomType) (sal_uInt16)rUserData.getToken(nOff, ';', nPos ).toInt32(); else { eZoom = SVX_ZOOM_PERCENT; ++nOff; } - sal_Bool bSelectObj = (0 != rUserData.GetToken( nOff, ';', nPos ).ToInt32()) + sal_Bool bSelectObj = (0 != rUserData.getToken( nOff, ';', nPos ).toInt32()) && m_pWrtShell->IsObjSelectable( aCrsrPos ); // restore editing position diff --git a/sw/source/ui/uiview/view1.cxx b/sw/source/ui/uiview/view1.cxx index c97a4ae82d7f..35edaf869c4f 100644 --- a/sw/source/ui/uiview/view1.cxx +++ b/sw/source/ui/uiview/view1.cxx @@ -77,7 +77,7 @@ void SwView::Activate(sal_Bool bMDIActivate) if( m_sSwViewData.Len() ) { - ReadUserData( m_sSwViewData, sal_False ); + ReadUserData(m_sSwViewData, false); m_sSwViewData.Erase(); } diff --git a/sw/source/ui/uno/SwXFilterOptions.cxx b/sw/source/ui/uno/SwXFilterOptions.cxx index 7ea106da173c..8d73f13fe4f8 100644 --- a/sw/source/ui/uno/SwXFilterOptions.cxx +++ b/sw/source/ui/uno/SwXFilterOptions.cxx @@ -126,9 +126,7 @@ sal_Int16 SwXFilterOptions::execute() throw (uno::RuntimeException) { SwAsciiOptions aOptions; pAsciiDlg->FillOptions( aOptions ); - String sTmp; - aOptions.WriteUserData(sTmp); - sFilterOptions = sTmp; + aOptions.WriteUserData(sFilterOptions); nRet = ui::dialogs::ExecutableDialogResults::OK; } delete pAsciiDlg; -- cgit