[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/undo.hxx |1 + sc/source/ui/drawfunc/futext3.cxx |2 ++ svl/source/undo/undo.cxx |5 - 3 files changed, 7 insertions(+), 1 deletion(-) New commits: commit b50df5aa72fb1259734794222119c5ad3017ba26 Author: Caolán McNamara AuthorDate: Thu May 4 09:10:31 2023 +0100 Commit: Caolán McNamara CommitDate: Thu May 4 15:14:53 2023 +0200 Resolves: tdf#134308 if max undo is 0, treat as if no undo Change-Id: I7eaa71d80718a4350ba6a3d7ff19ce09e1ac3aa3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151354 Tested-by: Jenkins Reviewed-by: Caolán McNamara diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index a64a1f5151f3..a7d1e4753712 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -198,6 +198,7 @@ public: virtual ~SfxUndoManager(); voidSetMaxUndoActionCount( size_t nMaxUndoActionCount ); +size_t GetMaxUndoActionCount() const; virtual voidAddUndoAction( std::unique_ptr pAction, bool bTryMerg=false ); virtual size_t GetUndoActionCount( bool const i_currentLevel = CurrentLevel ) const; OUStringGetUndoActionComment( size_t nNo=0, bool const i_currentLevel = CurrentLevel ) const; diff --git a/sc/source/ui/drawfunc/futext3.cxx b/sc/source/ui/drawfunc/futext3.cxx index a0db57860945..c7e59c5beaba 100644 --- a/sc/source/ui/drawfunc/futext3.cxx +++ b/sc/source/ui/drawfunc/futext3.cxx @@ -64,6 +64,8 @@ void FuText::StopEditMode() ScDocShell* pDocShell = rViewData.GetDocShell(); SfxUndoManager* pUndoMgr = rDoc.IsUndoEnabled() ? pDocShell->GetUndoManager() : nullptr; +if (pUndoMgr && !pUndoMgr->GetMaxUndoActionCount()) // tdf#134308 if max undo is 0, treat as if no undo +pUndoMgr = nullptr; bool bNewNote = false; if( pNote && pUndoMgr ) { diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 31269438f938..9b90495d593a 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -376,7 +376,6 @@ bool SfxUndoManager::ImplIsUndoEnabled_Lock() const return m_xData->mbUndoEnabled; } - void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount ) { UndoManagerGuard aGuard( *m_xData ); @@ -411,6 +410,10 @@ void SfxUndoManager::SetMaxUndoActionCount( size_t nMaxUndoActionCount ) ImplCheckEmptyActions(); } +size_t SfxUndoManager::GetMaxUndoActionCount() const +{ +return m_xData->pActUndoArray->nMaxUndoActions; +} void SfxUndoManager::ImplClearCurrentLevel_NoNotify( UndoManagerGuard& i_guard ) {
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/sharedstring.hxx |7 --- sc/source/core/tool/interpr8.cxx | 18 +- svl/source/misc/sharedstring.cxx |1 + 3 files changed, 14 insertions(+), 12 deletions(-) New commits: commit b392d0a25e229f305497ab5f9f084b71b24cc387 Author: Noel Grandin AuthorDate: Thu Sep 1 16:03:10 2022 +0200 Commit: Noel Grandin CommitDate: Fri Sep 2 11:56:45 2022 +0200 tdf#150712 reduce cost of SharedString::getString where the construction of empty strings is significant here which required fixing a couple of places that ended up using a reference to a temporary. Change-Id: I52feb1673bd39db4060585ac8d9ae2f3dea27fc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/139210 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/sharedstring.hxx b/include/svl/sharedstring.hxx index 5b5c35b95a92..d84b5a16a2c9 100644 --- a/include/svl/sharedstring.hxx +++ b/include/svl/sharedstring.hxx @@ -22,6 +22,7 @@ class SVL_DLLPUBLIC SharedString public: static const SharedString & getEmptyString(); +static const OUString EMPTY_STRING; SharedString(); SharedString( rtl_uString* pData, rtl_uString* pDataIgnoreCase ); @@ -36,7 +37,7 @@ public: bool operator== ( const SharedString& r ) const; bool operator!= ( const SharedString& r ) const; -OUString getString() const; +const OUString & getString() const; rtl_uString* getData(); const rtl_uString* getData() const; @@ -111,9 +112,9 @@ inline bool SharedString::operator!= ( const SharedString& r ) const return !operator== (r); } -inline OUString SharedString::getString() const +inline const OUString & SharedString::getString() const { -return mpData ? OUString(mpData) : OUString(); +return mpData ? OUString::unacquired(&mpData) : EMPTY_STRING; } inline rtl_uString* SharedString::getData() diff --git a/sc/source/core/tool/interpr8.cxx b/sc/source/core/tool/interpr8.cxx index df75c92d41f1..8d3f7c25f489 100644 --- a/sc/source/core/tool/interpr8.cxx +++ b/sc/source/core/tool/interpr8.cxx @@ -1395,9 +1395,9 @@ void ScInterpreter::ScConcat_MS() case svString: case svDouble: { -const OUString& rStr = GetString().getString(); -if (CheckStringResultLen(aResBuf, rStr.getLength())) -aResBuf.append( rStr); +OUString aStr = GetString().getString(); +if (CheckStringResultLen(aResBuf, aStr.getLength())) +aResBuf.append(aStr); } break; case svSingleRef : @@ -1476,17 +1476,17 @@ void ScInterpreter::ScConcat_MS() { if ( pMat->IsStringOrEmpty( j, k ) ) { -const OUString& rStr = pMat->GetString( j, k ).getString(); -if (CheckStringResultLen(aResBuf, rStr.getLength())) -aResBuf.append( rStr); +OUString aStr = pMat->GetString( j, k ).getString(); +if (CheckStringResultLen(aResBuf, aStr.getLength())) +aResBuf.append(aStr); } else { if ( pMat->IsValue( j, k ) ) { -const OUString& rStr = pMat->GetString( *pFormatter, j, k ).getString(); -if (CheckStringResultLen(aResBuf, rStr.getLength())) -aResBuf.append( rStr); +OUString aStr = pMat->GetString( *pFormatter, j, k ).getString(); +if (CheckStringResultLen(aResBuf, aStr.getLength())) +aResBuf.append(aStr); } } } diff --git a/svl/source/misc/sharedstring.cxx b/svl/source/misc/sharedstring.cxx index 1bb05c6ace50..71f3354eca51 100644 --- a/svl/source/misc/sharedstring.cxx +++ b/svl/source/misc/sharedstring.cxx @@ -14,6 +14,7 @@ namespace svl { /** ref-counting traffic associated with SharedString temporaries can be significant, so use a singleton here, so we can return a const& from getEmptyString */ static OUString EMPTY(u""); const SharedString EMPTY_SHARED_STRING(EMPTY.pData, EMPTY.pData); +const OUString SharedString::EMPTY_STRING {}; const SharedString & SharedString::getEmptyString() {
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/ilstitem.hxx |2 +- sc/source/ui/view/tabvwsh3.cxx |2 +- sc/source/ui/view/tabvwsha.cxx |5 ++--- svl/source/items/ilstitem.cxx |4 ++-- 4 files changed, 6 insertions(+), 7 deletions(-) New commits: commit 2ad7e095078e09bc27608d5b1fedb8809656abbe Author: Noel Grandin AuthorDate: Wed Oct 6 20:32:58 2021 +0200 Commit: Noel Grandin CommitDate: Fri Oct 8 07:28:43 2021 +0200 loplugin:moveparam in svl Change-Id: I58c1ef97fd6cba281c90cc7ed9917e04b7f265ba Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123187 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/ilstitem.hxx b/include/svl/ilstitem.hxx index af4932999dbd..bb49d18c9dbb 100644 --- a/include/svl/ilstitem.hxx +++ b/include/svl/ilstitem.hxx @@ -33,7 +33,7 @@ class SVL_DLLPUBLIC SfxIntegerListItem final : public SfxPoolItem public: static SfxPoolItem* CreateDefault(); SfxIntegerListItem(); -SfxIntegerListItem( sal_uInt16 nWhich, const ::std::vector < sal_Int32 >& rList ); +SfxIntegerListItem( sal_uInt16 nWhich, std::vector < sal_Int32 >&& rList ); SfxIntegerListItem( sal_uInt16 nWhich, const css::uno::Sequence < sal_Int32 >& rList ); virtual ~SfxIntegerListItem() override; diff --git a/sc/source/ui/view/tabvwsh3.cxx b/sc/source/ui/view/tabvwsh3.cxx index 4ad0eb9de120..03e8dd4f9593 100644 --- a/sc/source/ui/view/tabvwsh3.cxx +++ b/sc/source/ui/view/tabvwsh3.cxx @@ -915,7 +915,7 @@ void ScTabViewShell::Execute( SfxRequest& rReq ) { aIndexList = pDlg->GetSelectedRows(); pDlg.disposeAndClear(); -rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, aIndexList ) ); +rReq.AppendItem( SfxIntegerListItem( SID_SELECT_TABLES, std::vector(aIndexList) ) ); } else rReq.Ignore(); diff --git a/sc/source/ui/view/tabvwsha.cxx b/sc/source/ui/view/tabvwsha.cxx index 8a47fc8ff94b..31c087e00d41 100644 --- a/sc/source/ui/view/tabvwsha.cxx +++ b/sc/source/ui/view/tabvwsha.cxx @@ -517,7 +517,7 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName pOldSet->MergeRange(SID_ATTR_BORDER_STYLES, SID_ATTR_BORDER_DEFAULT_WIDTH); // We only allow these border line types. -const std::vector aBorderStyles{ +std::vector aBorderStyles{ table::BorderLineStyle::SOLID, table::BorderLineStyle::DOTTED, table::BorderLineStyle::DASHED, @@ -526,8 +526,7 @@ void ScTabViewShell::ExecuteCellFormatDlg(SfxRequest& rReq, const OString &rName table::BorderLineStyle::DASH_DOT_DOT, table::BorderLineStyle::DOUBLE_THIN }; -SfxIntegerListItem aBorderStylesItem(SID_ATTR_BORDER_STYLES, aBorderStyles); -pOldSet->Put(aBorderStylesItem); +pOldSet->Put(SfxIntegerListItem(SID_ATTR_BORDER_STYLES, std::move(aBorderStyles))); // Set the default border width to 0.75 points. SfxInt64Item aBorderWidthItem(SID_ATTR_BORDER_DEFAULT_WIDTH, 75); diff --git a/svl/source/items/ilstitem.cxx b/svl/source/items/ilstitem.cxx index d9ddeae2182e..0cb9ea8e6c49 100644 --- a/svl/source/items/ilstitem.cxx +++ b/svl/source/items/ilstitem.cxx @@ -31,9 +31,9 @@ SfxIntegerListItem::SfxIntegerListItem() { } -SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, const ::std::vector < sal_Int32 >& rList ) +SfxIntegerListItem::SfxIntegerListItem( sal_uInt16 which, ::std::vector < sal_Int32 >&& rList ) : SfxPoolItem( which ) -, m_aList( rList ) +, m_aList( std::move(rList) ) { }
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zformat.hxx | 11 --- sc/source/core/data/documen4.cxx | 17 + svl/source/numbers/zformat.cxx | 16 3 files changed, 37 insertions(+), 7 deletions(-) New commits: commit 71b003a12f8afdff42a25786ad0a12ddd6609d59 Author: Eike Rathke AuthorDate: Wed Sep 1 15:35:11 2021 +0200 Commit: Eike Rathke CommitDate: Wed Sep 1 22:53:55 2021 +0200 Resolves: tdf#144209 Handle General containing formats in RoundValueAsShown() Calling SvNumberformat::GetThousandDivisorPrecision() for a "AA "General format resulted in 3000 as that was implemented for tdf#106253 without taking into account that ImpSvNumberformatInfo::nThousand may be abused under some conditions, which here is having FLAG_STANDARD_IN_FORMAT = 1000 as nThousand, multiplied by 3 gives 3000. Subtracted from the 0 precision gave -3000 decimals for which of course the new rounding produced 0 where it previously simply ignored the decimals and returned the original value. Change-Id: I66afaf1e2d8b2654d9f7cc8cfb66389357fb742d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121447 Reviewed-by: Eike Rathke Tested-by: Jenkins diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index 3fdee06d99dc..cd04f96ac8a1 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -272,10 +272,15 @@ public: { return NumFor[nIx].Info().nCntPre; } /** Count of hidden integer digits with thousands divisor: - * formats like "0," to show only thousands +formats like "0," to show only thousands. + +Works only with SvNumFormatType::NUMBER and SvNumFormatType::CURRENCY, +returns 0 otherwise. + +Returns SvNumberFormatter::UNLIMITED_PRECISION for formats that contain +the General keyword. */ -sal_uInt16 GetThousandDivisorPrecision( sal_uInt16 nIx = 0 ) const -{ return NumFor[nIx].Info().nThousand * 3; } +sal_uInt16 GetThousandDivisorPrecision( sal_uInt16 nIx = 0 ) const; //! Read/write access on a special sal_uInt16 component, may only be used on the //! standard format 0, 1, ... and only by the number formatter! diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index 951a02700ec6..8f8bd3d43e98 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -641,8 +641,12 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScI SvNumFormatType nType = pFormat->GetMaskedType(); if (nType != SvNumFormatType::DATE && nType != SvNumFormatType::TIME && nType != SvNumFormatType::DATETIME ) { -short nPrecision; -if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) +// MSVC doesn't recognize all paths init nPrecision and wails about +// "potentially uninitialized local variable 'nPrecision' used" +// so init to some random sensible value preserving all decimals. +short nPrecision = 20; +bool bStdPrecision = ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) == 0); +if (!bStdPrecision) { sal_uInt16 nIdx = pFormat->GetSubformatIndex( fVal ); nPrecision = static_cast(pFormat->GetFormatPrecision( nIdx )); @@ -679,13 +683,18 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat, const ScI case SvNumFormatType::NUMBER: case SvNumFormatType::CURRENCY: { // tdf#106253 Thousands divisors for format "0," -nPrecision -= pFormat->GetThousandDivisorPrecision( nIdx ); +const sal_uInt16 nTD = pFormat->GetThousandDivisorPrecision( nIdx ); +if (nTD == SvNumberFormatter::UNLIMITED_PRECISION) +// Format contains General keyword, handled below. +bStdPrecision = true; +else +nPrecision -= nTD; break; } default: break; } } -else +if (bStdPrecision) { nPrecision = static_cast(GetDocOptions().GetStdPrecision()); // #i115512# no rounding for automatic decimals diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 6b68e79f1517..22a377a6cc69 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -5947,6 +5947,22 @@ OUString SvNumberformat::GetFormatStringForTimePrecision( int nPrecision ) const return sString.makeStringAndClear(); } +sal_uInt16 SvNumberformat::GetThousandDivisorPrecision( sal_uInt16 nIx ) const +{ +if (nIx >= 4) +return 0; + +const ImpSvNumberformatInfo& rInfo = NumFor[nIx].Info(); + +if (rInfo.eScannedType != SvNumFormatType::NUMBER && rInfo.eScannedType != SvNumFormatType::CURRENCY) +return 0; + +if
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx | 13 - sc/source/core/tool/interpr2.cxx |2 +- svl/source/numbers/zforfind.cxx | 19 --- svl/source/numbers/zforfind.hxx |8 +--- svl/source/numbers/zforlist.cxx |5 +++-- svl/source/numbers/zformat.cxx |2 +- 6 files changed, 34 insertions(+), 15 deletions(-) New commits: commit f106bb4471b6d3627311980ed727459b2da8e448 Author: Eike Rathke AuthorDate: Thu Jul 2 20:49:56 2020 +0200 Commit: Eike Rathke CommitDate: Thu Jul 2 23:54:09 2020 +0200 Resolves: tdf#134455 Let TIMEVALUE() use lax time recognition ... to accept minutes or seconds >59 Prepare SvNumInputOptions as enum class in case further options would be needed for anything else. Change-Id: Ie9ae62adf68f9948e23f55ac32c09a6b992a36e2 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97784 Reviewed-by: Eike Rathke Tested-by: Jenkins diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 244121d4afe7..2cc857b5e6cb 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -377,6 +377,16 @@ public: typedef std::vector< OUString > NfWSStringsDtor; +/** Input options to be used with IsNumberFormat() */ +enum class SvNumInputOptions : sal_uInt16 +{ +NONE = 0, +LAX_TIME = 1///< allow input of minutes or seconds >59 +}; +namespace o3tl { +template<> struct typed_flags : is_typed_flags {}; +} + class SvNumberFormatterRegistry_Impl; class NfCurrencyTable; @@ -536,7 +546,8 @@ public: returned in fOutNumber if input is not a number */ -bool IsNumberFormat( const OUString& sString, sal_uInt32& F_Index, double& fOutNumber ); +bool IsNumberFormat( const OUString& sString, sal_uInt32& F_Index, double& fOutNumber, + SvNumInputOptions eInputOptions = SvNumInputOptions::NONE ); /// Format a number according to a format index, return string and color void GetOutputString( const double& fOutNumber, sal_uInt32 nFIndex, diff --git a/sc/source/core/tool/interpr2.cxx b/sc/source/core/tool/interpr2.cxx index de63442eaf0e..6d202166db54 100644 --- a/sc/source/core/tool/interpr2.cxx +++ b/sc/source/core/tool/interpr2.cxx @@ -935,7 +935,7 @@ void ScInterpreter::ScGetTimeValue() OUString aInputString = GetString().getString(); sal_uInt32 nFIndex = 0; // damit default Land/Spr. double fVal; -if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal)) +if (pFormatter->IsNumberFormat(aInputString, nFIndex, fVal, SvNumInputOptions::LAX_TIME)) { SvNumFormatType eType = pFormatter->GetType(nFIndex); if (eType == SvNumFormatType::TIME || eType == SvNumFormatType::DATETIME) diff --git a/svl/source/numbers/zforfind.cxx b/svl/source/numbers/zforfind.cxx index e5dc78fe89b3..2e62b277e6c8 100644 --- a/svl/source/numbers/zforfind.cxx +++ b/svl/source/numbers/zforfind.cxx @@ -956,7 +956,9 @@ inline bool ImpSvNumberInputScan::GetNextNumber( sal_uInt16& i, sal_uInt16& j ) bool ImpSvNumberInputScan::GetTimeRef( double& fOutNumber, sal_uInt16 nIndex, // j-value of the first numeric time part of input, default 0 - sal_uInt16 nCnt ) const // count of numeric time parts + sal_uInt16 nCnt, // count of numeric time parts + SvNumInputOptions eInputOptions + ) const { bool bRet = true; sal_uInt16 nHour; @@ -1005,13 +1007,15 @@ bool ImpSvNumberInputScan::GetTimeRef( double& fOutNumber, else if (nIndex - nStartIndex < nCnt) { nMinute = static_cast(sStrArray[nNums[nIndex++]].toInt32()); -if (nIndex > 1 && nMinute > 59) +if (!(eInputOptions & SvNumInputOptions::LAX_TIME) +&& nIndex > 1 && nMinute > 59) bRet = false; // 1:60 or 1:123 is invalid, 123:1 is valid } if (nIndex - nStartIndex < nCnt) { nSecond = static_cast(sStrArray[nNums[nIndex++]].toInt32()); -if (nIndex > 1 && nSecond > 59 && !(nHour == 23 && nMinute == 59 && nSecond == 60)) +if (!(eInputOptions & SvNumInputOptions::LAX_TIME) +&& nIndex > 1 && nSecond > 59 && !(nHour == 23 && nMinute == 59 && nSecond == 60)) bRet = false; // 1:60 or 1:123 or 1:1:123 is invalid, 123:1 or 123:1:1 is valid, or leap second } if (nIndex - nStartIndex < nCnt) @@ -3659,9 +3663,10 @@ void ImpSvNumberInputScan::ChangeNullDate( const sal_uInt16 Day, * Does rString represent a number (also date, time et al) */ bool ImpSvNumberInputScan::IsNumberFormat( const OUString& rString, // string to be analyzed - SvNumFormatType& F_Type, // IN: old type, OUT: new type +
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx |3 + sc/source/core/tool/interpr1.cxx | 55 svl/source/numbers/zforlist.cxx | 74 +++ 3 files changed, 78 insertions(+), 54 deletions(-) New commits: commit dbda099d198a2236bafea2209cb5e3fc58ee8741 Author: Eike Rathke AuthorDate: Fri Apr 17 21:20:41 2020 +0200 Commit: Eike Rathke CommitDate: Sat Apr 18 03:08:03 2020 +0200 Move implementation of CELL("format";...) to SvNumberFormatter, tdf#132106 prep In preparation of further detailed handling. Change-Id: I9e4d916de031b742d0af1025b945b7608fed8266 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92462 Reviewed-by: Eike Rathke Tested-by: Jenkins diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 70371d59a1bd..664ddbc25de7 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -616,6 +616,9 @@ public: sal_uInt16& nPrecision, sal_uInt16& nLeadingCnt, LanguageType eLnge = LANGUAGE_DONTKNOW ); +/// Get return string for Calc CELL() function, "G", "D1", ... +OUString GetCalcCellReturn( sal_uInt32 nFormat ) const; + /// Check if format code string may be deleted by user bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 8f54c25d258b..03a8f46731a6 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -2202,60 +2202,7 @@ namespace { void getFormatString(SvNumberFormatter* pFormatter, sal_uLong nFormat, OUString& rFmtStr) { -boolbAppendPrec = true; -sal_uInt16 nPrec, nLeading; -boolbThousand, bIsRed; -pFormatter->GetFormatSpecialInfo( nFormat, bThousand, bIsRed, nPrec, nLeading ); - -switch( pFormatter->GetType( nFormat ) ) -{ -case SvNumFormatType::NUMBER: -if(bThousand) rFmtStr = ","; else rFmtStr = "F"; -break; -case SvNumFormatType::CURRENCY: -rFmtStr = "C"; -break; -case SvNumFormatType::SCIENTIFIC: -rFmtStr = "S"; -break; -case SvNumFormatType::PERCENT: -rFmtStr = "P"; -break; -default: -{ -bAppendPrec = false; -switch( pFormatter->GetIndexTableOffset( nFormat ) ) -{ -case NF_DATE_SYSTEM_SHORT: -case NF_DATE_SYS_DMMMYY: -case NF_DATE_SYS_DDMMYY: -case NF_DATE_SYS_DDMM: -case NF_DATE_SYS_DMMM: -case NF_DATE_DIN_DMMM: -case NF_DATE_SYS_D: -case NF_DATE_DIN_D: rFmtStr = "D1"; break; -case NF_DATE_SYS_DDMMM: rFmtStr = "D2"; break; -case NF_DATE_SYS_MMYY: rFmtStr = "D3"; break; -case NF_DATETIME_SYSTEM_SHORT_HHMM: -case NF_DATETIME_SYS_DDMM_HHMM: -case NF_DATETIME_SYS_DDMM_HHMMSS: -rFmtStr = "D4"; break; -case NF_DATE_DIN_MMDD: rFmtStr = "D5"; break; -case NF_TIME_HHMMSSAMPM:rFmtStr = "D6"; break; -case NF_TIME_HHMMAMPM: rFmtStr = "D7"; break; -case NF_TIME_HHMMSS:rFmtStr = "D8"; break; -case NF_TIME_HHMM: rFmtStr = "D9"; break; -default:rFmtStr = "G"; -} -} -} -if( bAppendPrec ) -rFmtStr += OUString::number(nPrec); -const SvNumberformat* pFormat = pFormatter->GetEntry( nFormat ); -if( lcl_FormatHasNegColor( pFormat ) ) -rFmtStr += "-"; -if( lcl_FormatHasOpenPar( pFormat ) ) -rFmtStr += "()"; +rFmtStr = pFormatter->GetCalcCellReturn( nFormat); } } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 21886b25d04e..4edf0692a41e 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -2179,6 +2179,80 @@ sal_uInt32 SvNumberFormatter::GetFormatSpecialInfo( const OUString& rFormatStrin return nCheckPos; } +OUString SvNumberFormatter::GetCalcCellReturn( sal_uInt32 nFormat ) const +{ +::osl::MutexGuard aGuard( GetInstanceMutex() ); +const SvNumberformat* pFormat = GetFormatEntry( nFormat ); +if (!pFormat) +return "G"; + +OUStringaStr; +boolbAppendPrec = true; +sal_uInt16 nPrec, nLeading; +boolbThousand, bIsRed; +pFormat->GetFormatSpecialInfo( bThousand, bIsRed, nPrec, nLeading ); + +switch (pFormat->GetMaskedType()) +{ +case SvNumFormatType::NUMBER: +if (bThousand) +aStr = ","; +else +aStr = "F"; +
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx|2 +- sc/source/core/data/formulacell.cxx |5 + sc/source/core/tool/interpr4.cxx|5 - svl/source/numbers/zforlist.cxx | 34 ++ 4 files changed, 32 insertions(+), 14 deletions(-) New commits: commit d77495060016c5e97d6e367c2a44fec83cf441f2 Author: Eike Rathke AuthorDate: Fri May 10 17:26:57 2019 +0200 Commit: Eike Rathke CommitDate: Fri May 10 20:57:52 2019 +0200 Apply duration format for such newly entered formula cells ... and the cell didn't have a number format applied already, [HH]:MM:SS instead of wall clock time format HH:MM:SS which comes to a surprise anyway if the result is >=24h. Related to tdf#125099 Change-Id: I6c19a86177f8714ac588d6798acf86e247a79b26 Reviewed-on: https://gerrit.libreoffice.org/72131 Reviewed-by: Eike Rathke Tested-by: Jenkins diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 8caa7fb3d276..032809b8f82e 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -640,7 +640,7 @@ public: bool IsSpecialStandardFormat( sal_uInt32 nFIndex, LanguageType eLnge ); /** Return a time format that best matches fNumber. */ -sal_uInt32 GetTimeFormat( double fNumber, LanguageType eLnge ); +sal_uInt32 GetTimeFormat( double fNumber, LanguageType eLnge, bool bForceDuration ); /** Return a format and type that best matches the value of fNumber if fNumber is assumed to be a date, time or datetime value, but unknown diff --git a/sc/source/core/data/formulacell.cxx b/sc/source/core/data/formulacell.cxx index 4b2a06fe548d..48cb55fae27a 100644 --- a/sc/source/core/data/formulacell.cxx +++ b/sc/source/core/data/formulacell.cxx @@ -2115,6 +2115,11 @@ void ScFormulaCell::InterpretTail( ScInterpreterContext& rContext, ScInterpretTa bChanged = true; } +// Currently (2019-05-10) nothing else can cope with a duration +// format type, change to time as it was before. +if (nFormatType == SvNumFormatType::DURATION) +nFormatType = SvNumFormatType::TIME; + mbNeedsNumberFormat = false; } diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 286583e875c5..8cd191c6e00b 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -4667,11 +4667,6 @@ StackVar ScInterpreter::Interpret() else nRetFmtType = SvNumFormatType::NUMBER; -// Currently (2019-05-06) nothing else can cope with a duration format -// type, change to time as it was before. -if (nRetFmtType == SvNumFormatType::DURATION) -nRetFmtType = SvNumFormatType::TIME; - if (nGlobalError != FormulaError::NONE && GetStackType() != svError ) PushError( nGlobalError); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 01b9453ed9eb..705e0624c785 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -68,6 +68,7 @@ using namespace ::std; #define ZF_STANDARD_CURRENCY20 #define ZF_STANDARD_DATE30 #define ZF_STANDARD_TIME40 +#define ZF_STANDARD_DURATION(ZF_STANDARD_TIME + 4) #define ZF_STANDARD_DATETIME50 #define ZF_STANDARD_SCIENTIFIC 60 #define ZF_STANDARD_FRACTION65 @@ -1224,6 +1225,8 @@ bool SvNumberFormatter::IsCompatible(SvNumFormatType eOldType, SvNumFormatType e return false; } break; +case SvNumFormatType::DURATION: +return false; default: return false; } @@ -1246,6 +1249,9 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultFormat( SvNumFormatType nType ) case SvNumFormatType::DATETIME: nSearch = CLOffset + ZF_STANDARD_DATETIME; break; +case SvNumFormatType::DURATION: +nSearch = CLOffset + ZF_STANDARD_DURATION; +break; case SvNumFormatType::PERCENT: nSearch = CLOffset + ZF_STANDARD_PERCENT; break; @@ -1289,6 +1295,9 @@ sal_uInt32 SvNumberFormatter::ImpGetDefaultFormat( SvNumFormatType nType ) case SvNumFormatType::DATETIME: nDefaultFormat = CLOffset + ZF_STANDARD_DATETIME; break; +case SvNumFormatType::DURATION: +nDefaultFormat = CLOffset + ZF_STANDARD_DURATION; +break; case SvNumFormatType::PERCENT: nDefaultFormat = CLOffset + ZF_STANDARD_PERCENT+1; break; @@ -1317,6 +1326,8 @@ sal_uInt32 SvNumberFormatter::GetStandardFormat( SvNumFormatType eType, Language { case SvNumFormatType::CURRENCY: return ( eLnge == LANGUAGE_SYSTEM ) ? ImpGetDefaultSystemCurrencyFormat() : ImpGetDefaultCurrencyFormat(); +case SvNumFormatType::DURATION : +return GetFormatIndex( NF_TIME_HH_MMSS, eLnge); case
[Libreoffice-commits] core.git: include/svl sc/source svl/source sw/source
include/svl/itempool.hxx |8 sc/source/core/data/attarray.cxx | 27 --- sc/source/core/data/column.cxx|2 +- sc/source/core/data/patattr.cxx |3 +-- sc/source/filter/excel/xistyle.cxx|2 +- sc/source/filter/oox/stylesbuffer.cxx |4 ++-- sc/source/ui/undo/undoblk3.cxx|6 +++--- sc/source/ui/undo/undocell.cxx|6 +++--- svl/source/items/poolcach.cxx |2 +- sw/source/core/undo/rolbck.cxx|2 +- sw/source/filter/writer/writer.cxx|4 ++-- 11 files changed, 31 insertions(+), 35 deletions(-) New commits: commit 57de1a3c279d4ecfaa020626296f7e667765e5a3 Author: Noel Grandin AuthorDate: Wed Apr 24 08:37:28 2019 +0200 Commit: Noel Grandin CommitDate: Wed Apr 24 10:53:05 2019 +0200 simplify call sites of SfxItemPool::Put use template to make return type match input type, so we don't need to cast at the call sites Change-Id: I1e65f362c67f74c9a230cdbc1db12545b28eb499 Reviewed-on: https://gerrit.libreoffice.org/71216 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 391e1b942544..7f74cb85c11d 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -146,10 +146,10 @@ public: virtual SfxItemPool*Clone() const; const OUString& GetName() const; -const SfxPoolItem& Put( std::unique_ptr xItem, sal_uInt16 nWhich = 0 ) -{ return PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true); } -const SfxPoolItem& Put( const SfxPoolItem& rItem, sal_uInt16 nWhich = 0 ) -{ return PutImpl( rItem, nWhich, /*bPassingOwnership*/false); } +template const T& Put( std::unique_ptr xItem, sal_uInt16 nWhich = 0 ) +{ return static_cast(PutImpl( *xItem.release(), nWhich, /*bPassingOwnership*/true)); } +template const T& Put( const T& rItem, sal_uInt16 nWhich = 0 ) +{ return static_cast(PutImpl( rItem, nWhich, /*bPassingOwnership*/false)); } voidRemove( const SfxPoolItem& ); const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; diff --git a/sc/source/core/data/attarray.cxx b/sc/source/core/data/attarray.cxx index 3c91d5b9dc03..3805ad4fa662 100644 --- a/sc/source/core/data/attarray.cxx +++ b/sc/source/core/data/attarray.cxx @@ -60,7 +60,7 @@ ScAttrArray::ScAttrArray( SCCOL nNewCol, SCTAB nNewTab, ScDocument* pDoc, ScAttr { mvData[nIdx].nEndRow = pDefaultColAttrArray->mvData[nIdx].nEndRow; ScPatternAttr aNewPattern( *(pDefaultColAttrArray->mvData[nIdx].pPattern) ); -mvData[nIdx].pPattern = static_cast( &pDocument->GetPool()->Put( aNewPattern ) ); +mvData[nIdx].pPattern = &pDocument->GetPool()->Put( aNewPattern ); bool bNumFormatChanged = false; if ( ScGlobal::CheckWidthInvalidate( bNumFormatChanged, mvData[nIdx].pPattern->GetItemSet(), pDocument->GetDefPattern()->GetItemSet() ) ) @@ -145,7 +145,7 @@ void ScAttrArray::Reset( const ScPatternAttr* pPattern ) pDocument->SetStreamValid(nTab, false); mvData.resize(1); -const ScPatternAttr* pNewPattern = static_cast( &pDocPool->Put(*pPattern) ); +const ScPatternAttr* pNewPattern = &pDocPool->Put(*pPattern); mvData[0].nEndRow = MAXROW; mvData[0].pPattern = pNewPattern; } @@ -455,9 +455,9 @@ const ScPatternAttr* ScAttrArray::SetPatternAreaImpl(SCROW nStartRow, SCROW nEnd if (bPutToPool) { if (bPassingOwnership) -pPattern = static_cast(&pDocument->GetPool()->Put(std::unique_ptr(const_cast(pPattern; +pPattern = &pDocument->GetPool()->Put(std::unique_ptr(const_cast(pPattern))); else -pPattern = static_cast(&pDocument->GetPool()->Put(*pPattern)); +pPattern = &pDocument->GetPool()->Put(*pPattern); } if ((nStartRow == 0) && (nEndRow == MAXROW)) Reset(pPattern); @@ -684,8 +684,7 @@ void ScAttrArray::ApplyStyleArea( SCROW nStartRow, SCROW nEndRow, const ScStyleS } pDocument->GetPool()->Remove(*mvData[nPos].pPattern); -mvData[nPos].pPattern = static_cast( - &pDocument->GetPool()->Put(*pNewPattern)); +mvData[nPos].pPattern = &pDocument->GetPool()->Put(*pNewPattern); if (Concat(nPos)) Search(nStart, nPos); else @@ -825,8 +824,8 @@ void ScAttrArray::ApplyLineStyleArea( SCROW nStartRow, SCROW nEndRow, { // remove from pool ? pDocument->GetPool()->Remove(*mvData[nPos].pPattern); -mvData[nPos].pPattern = static_cast( - &
[Libreoffice-commits] core.git: include/svl sc/source svl/source sw/source
include/svl/poolitem.hxx |6 +++--- sc/source/filter/excel/xlroot.cxx |4 ++-- sc/source/ui/Accessibility/AccessibleText.cxx |4 ++-- sc/source/ui/pagedlg/tphfedit.cxx |4 ++-- sc/source/ui/unoobj/textuno.cxx |4 ++-- sc/source/ui/view/printfun.cxx|4 ++-- svl/source/items/poolitem.cxx |4 ++-- sw/source/core/doc/tblafmt.cxx|8 sw/source/uibase/app/appopt.cxx |6 ++ 9 files changed, 21 insertions(+), 23 deletions(-) New commits: commit d4dff7dc148080da437ed2e46cd08ded044e64a7 Author: Noel Grandin AuthorDate: Thu Oct 25 12:21:25 2018 +0200 Commit: Noel Grandin CommitDate: Thu Oct 25 14:25:30 2018 +0200 return std::unique_ptr from CloneSetWhich Change-Id: I709122cb8cd7c257e7eb2bd564c529689e6d555a Reviewed-on: https://gerrit.libreoffice.org/62350 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 25a5a83a2d05..6964f776c63d 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -173,10 +173,10 @@ public: virtual SvStream&Store( SvStream &, sal_uInt16 nItemVersion ) const; virtual SfxPoolItem* Clone( SfxItemPool *pPool = nullptr ) const = 0; // clone and call SetWhich -SfxPoolItem* CloneSetWhich( sal_uInt16 nNewWhich ) const; -template T* CloneSetWhich( TypedWhichId nId ) const +std::unique_ptr CloneSetWhich( sal_uInt16 nNewWhich ) const; +template std::unique_ptr CloneSetWhich( TypedWhichId nId ) const { -return static_cast(CloneSetWhich(sal_uInt16(nId))); +return std::unique_ptr(static_cast(CloneSetWhich(sal_uInt16(nId)).release())); } sal_uInt32 GetRefCount() const { return m_nRefCount; } diff --git a/sc/source/filter/excel/xlroot.cxx b/sc/source/filter/excel/xlroot.cxx index c114d859a54e..358e89b89333 100644 --- a/sc/source/filter/excel/xlroot.cxx +++ b/sc/source/filter/excel/xlroot.cxx @@ -392,9 +392,9 @@ ScHeaderEditEngine& XclRoot::GetHFEditEngine() const // FillToEditItemSet() adjusts font height to 1/100th mm, we need twips std::unique_ptr pNewItem( aItemSet.Get( ATTR_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT)); pEditSet->Put( *pNewItem ); -pNewItem.reset( aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); +pNewItem = aItemSet.Get( ATTR_CJK_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK); pEditSet->Put( *pNewItem ); -pNewItem.reset( aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); +pNewItem = aItemSet.Get( ATTR_CTL_FONT_HEIGHT ).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL); pEditSet->Put( *pNewItem ); rEE.SetDefaults( pEditSet );// takes ownership } diff --git a/sc/source/ui/Accessibility/AccessibleText.cxx b/sc/source/ui/Accessibility/AccessibleText.cxx index 33ee6abac74a..54b254dc3d03 100644 --- a/sc/source/ui/Accessibility/AccessibleText.cxx +++ b/sc/source/ui/Accessibility/AccessibleText.cxx @@ -1139,9 +1139,9 @@ SvxTextForwarder* ScAccessibleHeaderTextData::GetTextForwarder() // but for header/footer twips is needed, as in the PatternAttr: std::unique_ptr pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT)); aDefaults.Put( *pNewItem ); - pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); +pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK); aDefaults.Put( *pNewItem ); - pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); +pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL); aDefaults.Put( *pNewItem ); aDefaults.Put( SvxAdjustItem( meAdjust, EE_PARA_JUST ) ); pHdrEngine->SetDefaults( aDefaults ); diff --git a/sc/source/ui/pagedlg/tphfedit.cxx b/sc/source/ui/pagedlg/tphfedit.cxx index fbb75dfacfe7..d55e0d5fc359 100644 --- a/sc/source/ui/pagedlg/tphfedit.cxx +++ b/sc/source/ui/pagedlg/tphfedit.cxx @@ -163,9 +163,9 @@ void ScEditWindow::SetFont( const ScPatternAttr& rPattern ) // but for header/footer twips is needed, as in the PatternAttr: std::unique_ptr pNewItem(rPattern.GetItem(ATTR_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT)); pSet->Put( *pNewItem ); - pNewItem.reset(rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK)); +pNewItem = rPattern.GetItem(ATTR_CJK_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CJK); pSet->Put( *pNewItem ); - pNewItem.reset(rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHEIGHT_CTL)); +pNewItem = rPattern.GetItem(ATTR_CTL_FONT_HEIGHT).CloneSetWhich(EE_CHAR_FONTHE
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zformat.hxx|4 +++- sc/source/filter/excel/xestyle.cxx | 16 ++-- svl/source/numbers/zforlist.cxx|7 ++- svl/source/numbers/zformat.cxx | 27 +-- 4 files changed, 48 insertions(+), 6 deletions(-) New commits: commit d0f8daa0980ba8e403b32006831657c5a0a4ea17 Author: Eike Rathke AuthorDate: Wed Aug 22 13:16:19 2018 +0200 Commit: Eike Rathke CommitDate: Wed Aug 22 19:03:27 2018 +0200 Resolves: tdf#73063 preserve and roundtrip LCID from/to Excel number formats Change-Id: I8e3e5ef5873af108596b387e8900d038e3942981 Reviewed-on: https://gerrit.libreoffice.org/59441 Tested-by: Jenkins Reviewed-by: Eike Rathke diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index b1f941656078..88b015f4adce 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -153,6 +153,7 @@ class SVL_DLLPUBLIC SvNumberformat }; LanguageType meLanguage; +LanguageType meLanguageWithoutLocaleData; Substitute meSubstitute; sal_uInt8 mnNumeralShape; sal_uInt8 mnCalendarType; @@ -225,7 +226,8 @@ public: // Build a format string of application defined keywords OUString GetMappedFormatstring( const NfKeywordTable& rKeywords, const LocaleDataWrapper& rLoc, -LanguageType nOriginalLang = LANGUAGE_DONTKNOW ) const; +LanguageType nOriginalLang = LANGUAGE_DONTKNOW, +bool bSystemLanguage = false ) const; void SetStarFormatSupport( bool b ) { bStarFlag = b; } diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index f0c4b5e83e08..04884494f467 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -44,6 +44,7 @@ #include #include #include +#include #include #include #include @@ -2135,10 +2136,21 @@ void XclExpXF::Init( const SfxItemSet& rItemSet, sal_Int16 nScript, } // number format -mnScNumFmt = (nForceScNumFmt == NUMBERFORMAT_ENTRY_NOT_FOUND) ? -rItemSet.Get( ATTR_VALUE_FORMAT ).GetValue() : nForceScNumFmt; +if (nForceScNumFmt != NUMBERFORMAT_ENTRY_NOT_FOUND) +mnXclNumFmt = nForceScNumFmt; +else +{ +// Built-in formats of dedicated languages may be attributed using the +// system language (or even other?) format with a language attribute, +// obtain the "real" format key. +mnScNumFmt = rItemSet.Get( ATTR_VALUE_FORMAT ).GetValue(); +LanguageType nLang = rItemSet.Get( ATTR_LANGUAGE_FORMAT).GetLanguage(); +if (mnScNumFmt >= SV_COUNTRY_LANGUAGE_OFFSET || nLang != LANGUAGE_SYSTEM) +mnScNumFmt = GetFormatter().GetFormatForLanguageIfBuiltIn( mnScNumFmt, nLang); +} mnXclNumFmt = GetNumFmtBuffer().Insert( mnScNumFmt ); mbFmtUsed = ScfTools::CheckItem( rItemSet, ATTR_VALUE_FORMAT, IsStyleXF() ); + // alignment mbAlignUsed = maAlignment.FillFromItemSet( rItemSet, bForceLineBreak, GetBiff(), IsStyleXF() ); diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 9d4a630df51b..023bc3788793 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -811,9 +811,13 @@ OUString SvNumberFormatter::GetFormatStringForExcel( sal_uInt32 nKey, const NfKe } else { +bool bSystemLanguage = false; LanguageType nLang = pEntry->GetLanguage(); if (nLang == LANGUAGE_SYSTEM) +{ +bSystemLanguage = true; nLang = SvtSysLocale().GetLanguageTag().getLanguageType(); +} if (nLang != LANGUAGE_ENGLISH_US) { sal_Int32 nCheckPos; @@ -833,7 +837,8 @@ OUString SvNumberFormatter::GetFormatStringForExcel( sal_uInt32 nKey, const NfKe // before (which doesn't do anything if it was the same locale // already). rTempFormatter.ChangeIntl( LANGUAGE_ENGLISH_US); -aFormatStr = pEntry->GetMappedFormatstring( rKeywords, *rTempFormatter.GetLocaleData(), nLang ); +aFormatStr = pEntry->GetMappedFormatstring( rKeywords, *rTempFormatter.GetLocaleData(), nLang, +bSystemLanguage); } } } diff --git a/svl/source/numbers/zformat.cxx b/svl/source/numbers/zformat.cxx index 1d591f6e5dff..3d7e1c42bd8e 100644 --- a/svl/source/numbers/zformat.cxx +++ b/svl/source/numbers/zformat.cxx @@ -1042,6 +1042,10 @@ SvNumberformat::SvNumberformat(OUString& rString, } else { +if (nIndex == 0) +// Locale data not available, remember. +
[Libreoffice-commits] core.git: include/svl sc/source svl/source sw/inc sw/source
include/svl/style.hxx |2 +- sc/source/core/data/patattr.cxx |2 +- sc/source/core/data/stlsheet.cxx|2 +- sc/source/filter/xml/xmlfonte.cxx |2 +- svl/source/items/style.cxx |4 ++-- sw/inc/docstyle.hxx |2 +- sw/source/core/unocore/unostyle.cxx |2 +- sw/source/uibase/app/docstyle.cxx |5 +++-- 8 files changed, 11 insertions(+), 10 deletions(-) New commits: commit db85d367c266898d4b98fc18c9318b6bcc83725a Author: Noel Grandin AuthorDate: Tue Jul 17 16:13:12 2018 +0200 Commit: Noel Grandin CommitDate: Thu Jul 19 15:40:45 2018 +0200 return SfxStyleSheetIterator by std::unique_ptr std::shared_ptr overkill here Change-Id: I9bd6ee5b92f9c04e0ca48d25eba99e5c232643c7 Reviewed-on: https://gerrit.libreoffice.org/57570 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/style.hxx b/include/svl/style.hxx index 6f328a2b7143..4bf91c357765 100644 --- a/include/svl/style.hxx +++ b/include/svl/style.hxx @@ -255,7 +255,7 @@ public: SfxItemPool&GetPool() { return rPool;} const SfxItemPool& GetPool() const { return rPool;} -virtual std::shared_ptr CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask); +virtual std::unique_ptr CreateIterator(SfxStyleFamily, SfxStyleSearchBits nMask); sal_uInt16 Count(); SfxStyleSheetBase* operator[](sal_uInt16 nIdx); diff --git a/sc/source/core/data/patattr.cxx b/sc/source/core/data/patattr.cxx index 70070fa52ac4..9dbf1bf83773 100644 --- a/sc/source/core/data/patattr.cxx +++ b/sc/source/core/data/patattr.cxx @@ -1173,7 +1173,7 @@ void ScPatternAttr::UpdateStyleSheet(const ScDocument* pDoc) // Assumes that "Standard" is always the 1st entry! if (!pStyle) { -std::shared_ptr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SfxStyleFamily::Para, SfxStyleSearchBits::All ); +std::unique_ptr pIter = pDoc->GetStyleSheetPool()->CreateIterator( SfxStyleFamily::Para, SfxStyleSearchBits::All ); pStyle = dynamic_cast< ScStyleSheet* >(pIter->First()); } diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx index d9a42eb06778..21c24e4ec913 100644 --- a/sc/source/core/data/stlsheet.cxx +++ b/sc/source/core/data/stlsheet.cxx @@ -97,7 +97,7 @@ bool ScStyleSheet::SetParent( const OUString& rParentName ) SfxStyleSheetBase* pStyle = m_pPool->Find( aEffName, nFamily ); if (!pStyle) { -std::shared_ptr pIter = m_pPool->CreateIterator( nFamily, SfxStyleSearchBits::All ); +std::unique_ptr pIter = m_pPool->CreateIterator( nFamily, SfxStyleSearchBits::All ); pStyle = pIter->First(); if (pStyle) aEffName = pStyle->GetName(); diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx index b4c7e7a8808c..eeb50130fbbc 100644 --- a/sc/source/filter/xml/xmlfonte.cxx +++ b/sc/source/filter/xml/xmlfonte.cxx @@ -86,7 +86,7 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP, const SfxItemPool* pEditPool(rExportP.GetDocument()->GetEditPool()); AddFontItems(aEditWhichIds, 3, pEditPool, false); -std::shared_ptr pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SfxStyleFamily::Page, SfxStyleSearchBits::All); +std::unique_ptr pItr = rExportP.GetDocument()->GetStyleSheetPool()->CreateIterator(SfxStyleFamily::Page, SfxStyleSearchBits::All); m_bEmbedUsedOnly = rExportP.GetDocument()->IsEmbedUsedFontsOnly(); m_bEmbedLatinScript = rExportP.GetDocument()->IsEmbedFontScriptLatin(); diff --git a/svl/source/items/style.cxx b/svl/source/items/style.cxx index 01873c282455..5856393f57e9 100644 --- a/svl/source/items/style.cxx +++ b/svl/source/items/style.cxx @@ -613,13 +613,13 @@ void SfxStyleSheetBasePool::SetSearchMask(SfxStyleFamily eFam, SfxStyleSearchBit } -std::shared_ptr SfxStyleSheetBasePool::CreateIterator +std::unique_ptr SfxStyleSheetBasePool::CreateIterator ( SfxStyleFamily eFam, SfxStyleSearchBits mask ) { -return std::make_shared(this,eFam,mask); +return o3tl::make_unique(this,eFam,mask); } SfxStyleSheetBase* SfxStyleSheetBasePool::Create diff --git a/sw/inc/docstyle.hxx b/sw/inc/docstyle.hxx index 85c7fa4ea558..0e159ac881ca 100644 --- a/sw/inc/docstyle.hxx +++ b/sw/inc/docstyle.hxx @@ -216,7 +216,7 @@ public: boolIsOrganizerMode() const { return bOrganizer; } -virtual std::shared_ptr CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask ) override; +virtual std::unique_ptr CreateIterator( SfxStyleFamily, SfxStyleSearchBits nMask ) override; SwDoc& GetDoc() const { return rDoc; } diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index e126864d756d..1f341cad9b35 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/cor
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/adrparse.hxx |4 - include/svl/instrm.hxx|3 - include/svl/itemiter.hxx |4 - include/svl/itemset.hxx |8 +-- include/svl/languageoptions.hxx |5 +- include/svl/ondemand.hxx | 19 ++- include/svl/zforlist.hxx | 10 ++-- sc/source/core/data/patattr.cxx |4 - svl/source/config/languageoptions.cxx |8 +-- svl/source/fsstor/fsstorage.cxx | 18 ++- svl/source/items/itemiter.cxx |4 - svl/source/items/itemset.cxx | 85 -- svl/source/items/stylepool.cxx| 46 ++ svl/source/misc/adrparse.cxx |6 -- svl/source/misc/strmadpt.cxx |3 - svl/source/numbers/zforfind.cxx |6 -- svl/source/numbers/zforfind.hxx |2 svl/source/numbers/zforlist.cxx | 77 ++ svl/source/undo/undo.cxx |6 -- 19 files changed, 137 insertions(+), 181 deletions(-) New commits: commit ccf986a77a4b218964033e70601ae220eb2c9b13 Author: Noel Grandin Date: Wed Jan 10 14:54:10 2018 +0200 loplugin:useuniqueptr in svl Change-Id: I2fdb63517349474d90cb17ad2bd667f30840e83d Reviewed-on: https://gerrit.libreoffice.org/47727 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/adrparse.hxx b/include/svl/adrparse.hxx index 2213e26c66f5..0961158a52e7 100644 --- a/include/svl/adrparse.hxx +++ b/include/svl/adrparse.hxx @@ -47,7 +47,7 @@ class SVL_DLLPUBLIC SvAddressParser friend class SvAddressParser_Impl; SvAddressEntry_Impl m_aFirst; -::std::vector< SvAddressEntry_Impl* > +::std::vector< SvAddressEntry_Impl > m_aRest; boolm_bHasFirst; @@ -61,7 +61,7 @@ public: const OUString& GetEmailAddress(sal_Int32 nIndex) const { return nIndex == 0 ? m_aFirst.m_aAddrSpec : - m_aRest[ nIndex - 1 ]->m_aAddrSpec; + m_aRest[ nIndex - 1 ].m_aAddrSpec; } }; diff --git a/include/svl/instrm.hxx b/include/svl/instrm.hxx index c8c914546e45..21e8ea6c3c2d 100644 --- a/include/svl/instrm.hxx +++ b/include/svl/instrm.hxx @@ -23,6 +23,7 @@ #include #include #include +#include namespace com { namespace sun { namespace star { namespace io { class XInputStream; @@ -36,7 +37,7 @@ class SVL_DLLPUBLIC SvInputStream: public SvStream { css::uno::Reference< css::io::XInputStream > m_xStream; css::uno::Reference< css::io::XSeekable > m_xSeekable; -SvDataPipe_Impl * m_pPipe; +std::unique_ptr m_pPipe; sal_uInt64 m_nSeekedFrom; SVL_DLLPRIVATE bool open(); diff --git a/include/svl/itemiter.hxx b/include/svl/itemiter.hxx index aba136d2aa85..08aef0ea4f66 100644 --- a/include/svl/itemiter.hxx +++ b/include/svl/itemiter.hxx @@ -41,11 +41,11 @@ public: const SfxPoolItem* FirstItem() { m_nCurrent = m_nStart; -return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; +return m_rSet.m_nCount ? *(m_rSet.m_pItems.get() + m_nCurrent) : nullptr; } const SfxPoolItem* GetCurItem() const { -return m_rSet.m_nCount ? *(m_rSet.m_pItems + m_nCurrent) : nullptr; +return m_rSet.m_nCount ? *(m_rSet.m_pItems.get() + m_nCurrent) : nullptr; } const SfxPoolItem* NextItem(); diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx index ca944d282ad4..d5a2b5eb5ad7 100644 --- a/include/svl/itemset.hxx +++ b/include/svl/itemset.hxx @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -34,8 +35,6 @@ class SfxItemPool; class SfxPoolItem; class SvStream; -typedef SfxPoolItem const** SfxItemArray; - namespace svl { namespace detail { @@ -84,7 +83,8 @@ class SAL_WARN_UNUSED SVL_DLLPUBLIC SfxItemSet SfxItemPool* m_pPool; ///< pool that stores the items const SfxItemSet* m_pParent; ///< derivation -SfxItemArray m_pItems;///< array of items +std::unique_ptr + m_pItems;///< array of items sal_uInt16* m_pWhichRanges; ///< array of Which Ranges sal_uInt16m_nCount;///< number of items @@ -99,7 +99,7 @@ private: std::size_t items); public: -SfxItemArrayGetItems_Impl() const { return m_pItems; } +SfxPoolItem const** GetItems_Impl() const { return m_pItems.get(); } private: const SfxItemSet& operator=(const SfxItemSet &) = delete; diff --git a/include/svl/languageoptions.hxx b/include/svl/languageoptions.hxx index 6de8eb566c5b..fadd74f08893 100644 --- a/include/svl/languageoptions.hxx +++ b/include/svl/languageoptions.hxx @@ -25,6 +25,7 @@ #include #include #include +#includ
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx |4 ++-- sc/source/ui/unoobj/cellsuno.cxx |2 +- sc/source/ui/view/viewfunc.cxx |2 +- svl/source/numbers/zforlist.cxx | 14 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) New commits: commit fad0ddcb8804e16c7eba5c8582c9a189a962abaf Author: Noel Grandin Date: Thu Aug 3 11:01:18 2017 +0200 rename SV_MAX_ANZ_STANDARD_FORMATE->SV_MAX_COUNT_STANDARD_FORMATS Change-Id: I83df4ecabcbc98b5a75f93e44b584291068c6e94 Reviewed-on: https://gerrit.libreoffice.org/40702 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index a22e05afb731..6c1036b98ea8 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -51,8 +51,8 @@ namespace com { namespace sun { namespace star { } }}} -#define SV_COUNTRY_LANGUAGE_OFFSET 1// Max count of formats per country/language -#define SV_MAX_ANZ_STANDARD_FORMATE 100// Max count of builtin default formats per CL +#define SV_COUNTRY_LANGUAGE_OFFSET 1 // Max count of formats per country/language +#define SV_MAX_COUNT_STANDARD_FORMATS 100// Max count of builtin default formats per CL #define NUMBERFORMAT_ENTRY_NOT_FOUND (sal_uInt32)(0x) /// MAX_ULONG diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx index 19e54619e45e..84d97df0f383 100644 --- a/sc/source/ui/unoobj/cellsuno.cxx +++ b/sc/source/ui/unoobj/cellsuno.cxx @@ -2166,7 +2166,7 @@ static void lcl_SetCellProperty( const SfxItemPropertySimpleEntry& rEntry, const // don't touch number format attribute sal_uLong nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET; if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) && - nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE ) + nNewMod <= SV_MAX_COUNT_STANDARD_FORMATS ) { rFirstItemId = 0; // don't use ATTR_VALUE_FORMAT value } diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx index 8175d3b767de..bb2dfeda707d 100644 --- a/sc/source/ui/view/viewfunc.cxx +++ b/sc/source/ui/view/viewfunc.cxx @@ -918,7 +918,7 @@ void ScViewFunc::ApplyAttributes( const SfxItemSet* pDialogSet, // only the language has changed -> do not touch numberformat-attribute sal_uInt32 nNewMod = nNewFormat % SV_COUNTRY_LANGUAGE_OFFSET; if ( nNewMod == ( nOldFormat % SV_COUNTRY_LANGUAGE_OFFSET ) && - nNewMod <= SV_MAX_ANZ_STANDARD_FORMATE ) + nNewMod <= SV_MAX_COUNT_STANDARD_FORMATS ) aNewAttrs.GetItemSet().ClearItem( ATTR_VALUE_FORMAT ); } } diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index d22f489a8a41..6756639e2cf0 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -83,8 +83,8 @@ using namespace ::std; #define ZF_STANDARD_NEWEXTENDED_DATE_DIN_MMDD 84 #define ZF_STANDARD_NEWEXTENDED_DATE_WW 85 -#define ZF_STANDARD_LOGICAL SV_MAX_ANZ_STANDARD_FORMATE-1 // 99 -#define ZF_STANDARD_TEXTSV_MAX_ANZ_STANDARD_FORMATE // 100 +#define ZF_STANDARD_LOGICAL SV_MAX_COUNT_STANDARD_FORMATS-1 // 99 +#define ZF_STANDARD_TEXTSV_MAX_COUNT_STANDARD_FORMATS // 100 /* Locale that is set if an unknown locale (from another system) is loaded of * legacy documents. Can not be SYSTEM because else, for example, a German "DM" @@ -427,7 +427,7 @@ void SvNumberFormatter::ReplaceSystemCL( LanguageType eOldLanguage ) { return ;// no SYSTEM entries to replace } -const sal_uInt32 nMaxBuiltin = nCLOffset + SV_MAX_ANZ_STANDARD_FORMATE; +const sal_uInt32 nMaxBuiltin = nCLOffset + SV_MAX_COUNT_STANDARD_FORMATS; const sal_uInt32 nNextCL = nCLOffset + SV_COUNTRY_LANGUAGE_OFFSET; sal_uInt32 nKey; @@ -2241,7 +2241,7 @@ void SvNumberFormatter::ImpGenerateFormats( sal_uInt32 CLOffset, bool bNoAdditio } pStdFormat->SetType( css::util::NumberFormat::NUMBER ); pStdFormat->SetStandard(); -pStdFormat->SetLastInsertKey( SV_MAX_ANZ_STANDARD_FORMATE, SvNumberformat::FormatterPrivateAccess() ); +pStdFormat->SetLastInsertKey( SV_MAX_COUNT_STANDARD_FORMATS, SvNumberformat::FormatterPrivateAccess() ); } else { @@ -3052,7 +3052,7 @@ SvNumberFormatterIndexTable* SvNumberFormatter::MergeFormatter(SvNumberFormatter { nCLOffset = ImpGenerateCL(pFormat->GetLanguage()); } -if (nOffset <= SV_MAX_ANZ_STANDARD_FORMATE) // Std.form. +if (nOffset <= SV_MAX_COUNT_STANDARD_FORMATS) // Std.form. { nNewKey = nCLOffset + nOffset; if (aFTable.find( nNewKey) == aFTable.end(
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx |3 +++ include/svl/zformat.hxx |3 ++- sc/source/core/data/documen4.cxx |2 +- svl/source/numbers/zforlist.cxx | 12 4 files changed, 18 insertions(+), 2 deletions(-) New commits: commit e7f769bc67d3f132b477b3c253f8065243b9b8ac Author: Laurent Balland-Poirier Date: Thu Feb 16 22:15:37 2017 +0100 tdf#106052 Treat SubFormat for "Precision as shown" Get precision from the correct subformat Change-Id: I458e5b3d1fb515864f19499ac9ac529e1d68a267 Reviewed-on: https://gerrit.libreoffice.org/34505 Tested-by: Jenkins Reviewed-by: Eike Rathke diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index fdc0062..81c57d7 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -516,6 +516,9 @@ public: /// Count of decimals sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat ) const; +/// Count of decimals with correct subformat according to fValue +sal_uInt16 GetFormatPrecision( sal_uInt32 nFormat, double fValue ) const; + /// Count of integer digits sal_uInt16 GetFormatIntegerDigits( sal_uInt32 nFormat ) const; diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index a50281b..cfb3e3a 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -219,7 +219,8 @@ public: sal_uInt16 GetSubformatIndex( double fNumber ) const; /// Count of decimal precision -sal_uInt16 GetFormatPrecision() const { return NumFor[0].Info().nCntPost; } +sal_uInt16 GetFormatPrecision( sal_uInt16 nIx = 0 ) const +{ return NumFor[nIx].Info().nCntPost; } /// Count of integer digits sal_uInt16 GetFormatIntegerDigits() const { return NumFor[0].Info().nCntPre; } diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index fed6c0d..6a1110b 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -660,7 +660,7 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const short nPrecision; if ((nFormat % SV_COUNTRY_LANGUAGE_OFFSET) != 0) { -nPrecision = (short)pFormat->GetFormatPrecision(); +nPrecision = (short)GetFormatTable()->GetFormatPrecision( nFormat, fVal ); switch ( nType ) { case css::util::NumberFormat::PERCENT: // 0.41% == 0.0041 diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 2ddd642..b4621bc 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1980,6 +1980,18 @@ sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat ) const return pFormatScanner->GetStandardPrec(); } +sal_uInt16 SvNumberFormatter::GetFormatPrecision( sal_uInt32 nFormat, double fValue ) const +{ +const SvNumberformat* pFormat = GetFormatEntry( nFormat ); +if ( pFormat ) +{ +sal_uInt16 nIx = pFormat->GetSubformatIndex( fValue ); +return pFormat->GetFormatPrecision( nIx ); +} +else +return pFormatScanner->GetStandardPrec(); +} + sal_uInt16 SvNumberFormatter::GetFormatIntegerDigits( sal_uInt32 nFormat ) const { const SvNumberformat* pFormat = GetFormatEntry( nFormat ); ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/zforlist.hxx |3 include/svl/zformat.hxx | 19 + sc/source/core/data/documen4.cxx |4 + svl/source/numbers/zforlist.cxx |9 ++ svl/source/numbers/zformat.cxx | 147 ++- 5 files changed, 119 insertions(+), 63 deletions(-) New commits: commit 5706b29974c1c3ab0ba5a23685accf2fbebc3e06 Author: Laurent Balland-Poirier Date: Wed Feb 15 23:27:34 2017 +0100 tdf#105657 Treat "Precision as shown" for fractions For Option "Precision as shown", fraction must specificly be treated ImpGetFractionElements retrieves values of each part of fraction (integer, numerator, denominator) independently from its exact representation Update: avoid include of zformat.hxx in document4.cxx Change-Id: Ia3ea2322f3d311c04ef71f3260730c7154c3dc15 Reviewed-on: https://gerrit.libreoffice.org/34331 Reviewed-by: Eike Rathke Tested-by: Eike Rathke diff --git a/include/svl/zforlist.hxx b/include/svl/zforlist.hxx index 37c2b26..fdc0062 100644 --- a/include/svl/zforlist.hxx +++ b/include/svl/zforlist.hxx @@ -530,6 +530,9 @@ public: sal_uInt16& nPrecision, sal_uInt16& nAnzLeading, LanguageType eLnge = LANGUAGE_DONTKNOW ); +/// Get round value with fraction representation +double GetRoundFractionValue( sal_uInt32 nFormat, double fValue ) const; + /// Check if format code string may be deleted by user bool IsUserDefined( const OUString& sStr, LanguageType eLnge = LANGUAGE_DONTKNOW ); diff --git a/include/svl/zformat.hxx b/include/svl/zformat.hxx index ce632ae..d68a100 100644 --- a/include/svl/zformat.hxx +++ b/include/svl/zformat.hxx @@ -212,6 +212,9 @@ public: sal_uInt16& nPrecision, sal_uInt16& nAnzLeading) const; +/// Get index of subformat (0..3) according to conditions and fNumber value +sal_uInt16 GetSubformatIndex( double fNumber ) const; + /// Count of decimal precision sal_uInt16 GetFormatPrecision() const { return NumFor[0].Info().nCntPost; } @@ -242,6 +245,9 @@ public: OUString GetDenominatorString( sal_uInt16 nNumFor ) const; OUString GetNumeratorString( sal_uInt16 nNumFor ) const; OUString GetIntegerFractionDelimiterString( sal_uInt16 nNumFor ) const; +/// Round fNumber to its fraction representation +double GetRoundFractionValue ( double fNumber ) const; + /** If the count of string elements (substrings, ignoring [modifiers] and so on) in a subformat code nNumFor (0..3) is equal to the given number. Used by ImpSvNumberInputScan::IsNumberFormatMain() to detect a matched @@ -579,6 +585,19 @@ private: sal_uInt16 nIx, bool bInteger ); +/** Calculate each element of fraction: + * integer part, numerator part, denominator part + * @param fNumber value to be represented as fraction. Will contain absolute fractional part + * @param nIx subformat number 0..3 + * @param fIntPart integral part of fraction + * @param nFrac numerator of fraction + * @param nDic denominator of fraction + */ +SVL_DLLPRIVATE void ImpGetFractionElements( double& fNumber, +sal_uInt16 nIx, +double& fIntPart, +sal_uInt64& nFrac, +sal_uInt64& nDiv ) const; SVL_DLLPRIVATE bool ImpGetFractionOutput(double fNumber, sal_uInt16 nIx, OUStringBuffer& OutString); diff --git a/sc/source/core/data/documen4.cxx b/sc/source/core/data/documen4.cxx index c503b2f..09b7c54 100644 --- a/sc/source/core/data/documen4.cxx +++ b/sc/source/core/data/documen4.cxx @@ -672,6 +672,10 @@ double ScDocument::RoundValueAsShown( double fVal, sal_uInt32 nFormat ) const nPrecision = sal::static_int_cast( nPrecision - (short)floor( log10( -fVal ) ) ); break; } +case css::util::NumberFormat::FRACTION: // get value of fraction representation +{ +return GetFormatTable()->GetRoundFractionValue( nFormat, fVal ); +} } } else diff --git a/svl/source/numbers/zforlist.cxx b/svl/source/numbers/zforlist.cxx index 964abdc..71a0718 100644 --- a/svl/source/numbers/zforlist.cxx +++ b/svl/source/numbers/zforlist.cxx @@ -1963,6 +1963,15 @@ void SvNumberFormatter::GetFormatSpecialInfo(sal_uInt32 nFormat, } } +double SvNumberFormatter::GetRoundFractionValue( sal_uInt32 nFormat, double fValue ) const +{ +const SvNumberformat* pFormat = GetFormatEntry( nFormat ); +if ( pFormat )
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/filerec.hxx | 19 +++ include/svl/itempool.hxx |1 - include/svl/itemprop.hxx |4 ++-- include/svl/poolcach.hxx |2 +- sc/source/core/data/attarray.cxx |2 +- sc/source/core/data/column.cxx |2 +- svl/source/filerec/filerec.cxx |5 ++--- svl/source/items/itemprop.cxx|3 +-- svl/source/items/itemset.cxx |2 +- svl/source/items/poolcach.cxx|8 +++- svl/source/items/poolio.cxx | 29 + 11 files changed, 32 insertions(+), 45 deletions(-) New commits: commit 07da25064f75cdf7163669f9bf860a9ee2f8b33c Author: Noel Grandin Date: Thu Mar 17 09:45:22 2016 +0200 loplugin:constantparam in svl Change-Id: If23e43beb401047825641817e09d7fdeb904f9d9 Reviewed-on: https://gerrit.libreoffice.org/23317 Tested-by: Jenkins Reviewed-by: Noel Grandin diff --git a/include/svl/filerec.hxx b/include/svl/filerec.hxx index 107dd61..6581610 100644 --- a/include/svl/filerec.hxx +++ b/include/svl/filerec.hxx @@ -236,11 +236,11 @@ protected: , _nPreTag(0) { } -void Construct_Impl( SvStream *pStream, sal_uInt8 nTag ) +void Construct_Impl( SvStream *pStream ) { _pStream = pStream; _bSkipped = false; -_nPreTag = nTag; +_nPreTag = SFX_REC_PRETAG_EXT; } inline bool SetHeader_Impl( sal_uInt32 nHeader ); @@ -319,8 +319,7 @@ protected: } voidConstruct_Impl( SvStream *pStream ) { -SfxMiniRecordReader::Construct_Impl( -pStream, SFX_REC_PRETAG_EXT ); +SfxMiniRecordReader::Construct_Impl( pStream ); } boolFindHeader_Impl( sal_uInt16 nTypes, sal_uInt16 nTag ); }; @@ -444,8 +443,7 @@ protected: public: SfxMultiVarRecordWriter( SvStream *pStream, - sal_uInt16 nRecordTag, - sal_uInt8 nRecordVer ); + sal_uInt16 nRecordTag ); virtual ~SfxMultiVarRecordWriter(); voidNewContent(); @@ -484,8 +482,7 @@ class SVL_DLLPUBLIC SfxMultiMixRecordWriter: public SfxMultiVarRecordWriter { public: inline SfxMultiMixRecordWriter( SvStream *pStream, - sal_uInt16 nRecordTag, - sal_uInt8 nRecordVer ); + sal_uInt16 nRecordTag ); voidNewContent( sal_uInt16 nTag, sal_uInt8 nVersion ); }; @@ -627,12 +624,10 @@ inline SfxMultiFixRecordWriter::~SfxMultiFixRecordWriter() * * @param pStreamtarget stream in which the record will be created * @param nRecordTag tag for the total record - * @param nRecordVer version for the total record */ inline SfxMultiMixRecordWriter::SfxMultiMixRecordWriter( SvStream* pStream, - sal_uInt16 nRecordTag, - sal_uInt8 nRecordVer ) -: SfxMultiVarRecordWriter( SFX_REC_TYPE_MIXTAGS, pStream, nRecordTag, nRecordVer ) + sal_uInt16 nRecordTag ) +: SfxMultiVarRecordWriter( SFX_REC_TYPE_MIXTAGS, pStream, nRecordTag, 0 ) { } diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 2ca544d..f3ef335 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -151,7 +151,6 @@ public: const SfxPoolItem& GetDefaultItem( sal_uInt16 nWhich ) const; const SfxPoolItem* LoadItem( SvStream &rStream, - bool bDirect = false, const SfxItemPool *pRefPool = nullptr ); boolStoreItem( SvStream &rStream, const SfxPoolItem &rItem, diff --git a/include/svl/itemprop.hxx b/include/svl/itemprop.hxx index 1c8923f..f9f332b 100644 --- a/include/svl/itemprop.hxx +++ b/include/svl/itemprop.hxx @@ -57,11 +57,11 @@ struct SfxItemPropertySimpleEntry } SfxItemPropertySimpleEntry(sal_uInt16 _nWID, css::uno::Type const & _rType, - long _nFlags, sal_uInt8 _nMemberId) + long _nFlags) : nWID( _nWID ) , aType( _rType ) , nFlags(_nFlags ) -, nMemberId( _nMemberId ) +, nMemberId( 0 ) { } diff --git a/include/svl/poolcach.hxx b/include/svl/pool
[Libreoffice-commits] core.git: include/svl sc/source svl/source
include/svl/itempool.hxx |1 + include/svl/poolitem.hxx |4 sc/source/ui/unoobj/defltuno.cxx |2 +- svl/source/inc/poolio.hxx|4 svl/source/items/itempool.cxx|5 + svl/source/items/itemset.cxx |1 + 6 files changed, 12 insertions(+), 5 deletions(-) New commits: commit 2a19718575e4b9c5757da55ab64dd17ef7d3c9c4 Author: Noel Grandin Date: Wed Jul 23 15:09:14 2014 +0200 move SFX_ITEMS_DIRECT etc. definitions inside the module These are internal constants, they don't need to be visible to the rest of LO Change-Id: I313def85b8c404948ec9ecb3996fed03b32ff9bf diff --git a/include/svl/itempool.hxx b/include/svl/itempool.hxx index 09c1305..5b6a14d 100644 --- a/include/svl/itempool.hxx +++ b/include/svl/itempool.hxx @@ -163,6 +163,7 @@ public: sal_uInt32 GetSurrogate(const SfxPoolItem *) const; const SfxPoolItem * GetItem2(sal_uInt16 nWhich, sal_uInt32 nSurrogate) const; +const SfxPoolItem * GetItem2Default(sal_uInt16 nWhich) const; sal_uInt32 GetItemCount2(sal_uInt16 nWhich) const; const SfxPoolItem* LoadSurrogate(SvStream& rStream, sal_uInt16 &rWhich, sal_uInt16 nSlotId, diff --git a/include/svl/poolitem.hxx b/include/svl/poolitem.hxx index 718a78b..f19003e 100644 --- a/include/svl/poolitem.hxx +++ b/include/svl/poolitem.hxx @@ -37,10 +37,6 @@ class IntlWrapper; namespace com { namespace sun { namespace star { namespace uno { class Any; } } } } -static const sal_uInt32 SFX_ITEMS_DIRECT = 0x; -static const sal_uInt32 SFX_ITEMS_NULL= 0xfff0; // instead StoreSurrogate -static const sal_uInt32 SFX_ITEMS_DEFAULT = 0xfffe; - enum SfxItemKind { SFX_ITEMS_NONE, SFX_ITEMS_DELETEONIDLE, diff --git a/sc/source/ui/unoobj/defltuno.cxx b/sc/source/ui/unoobj/defltuno.cxx index 155f24f..a091677 100644 --- a/sc/source/ui/unoobj/defltuno.cxx +++ b/sc/source/ui/unoobj/defltuno.cxx @@ -339,7 +339,7 @@ uno::Any SAL_CALL ScDocDefaultsObj::getPropertyDefault( const OUString& aPropert if (pEntry->nWID) { ScDocumentPool* pPool = pDocShell->GetDocument().GetPool(); -const SfxPoolItem* pItem = pPool->GetItem2( pEntry->nWID, SFX_ITEMS_DEFAULT ); +const SfxPoolItem* pItem = pPool->GetItem2Default( pEntry->nWID ); if (pItem) pItem->QueryValue( aRet, pEntry->nMemberId ); } diff --git a/svl/source/inc/poolio.hxx b/svl/source/inc/poolio.hxx index 2dcd2ca..80eaa18 100644 --- a/svl/source/inc/poolio.hxx +++ b/svl/source/inc/poolio.hxx @@ -33,6 +33,10 @@ class SfxItemPoolUser; #define DELETEZ(pPtr) { delete pPtr; pPtr = 0; } #endif +static const sal_uInt32 SFX_ITEMS_DIRECT = 0x; +static const sal_uInt32 SFX_ITEMS_NULL= 0xfff0; // instead StoreSurrogate +static const sal_uInt32 SFX_ITEMS_DEFAULT = 0xfffe; + struct SfxPoolVersion_Impl { sal_uInt16 _nVer; diff --git a/svl/source/items/itempool.cxx b/svl/source/items/itempool.cxx index 5508499..0638eec 100644 --- a/svl/source/items/itempool.cxx +++ b/svl/source/items/itempool.cxx @@ -979,6 +979,11 @@ const sal_uInt16* SfxItemPool::GetFrozenIdRanges() const return pImp->mpPoolRanges; } +const SfxPoolItem *SfxItemPool::GetItem2Default(sal_uInt16 nWhich) const +{ +return GetItem2(nWhich, SFX_ITEMS_DEFAULT); +} + const SfxPoolItem *SfxItemPool::GetItem2(sal_uInt16 nWhich, sal_uInt32 nOfst) const { if ( !IsInRange(nWhich) ) diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx index 3050442..f773fb5 100644 --- a/svl/source/items/itemset.cxx +++ b/svl/source/items/itemset.cxx @@ -41,6 +41,7 @@ static sal_uLong nRangesCopyCount = 0; // How often have ranges been copied? #endif #include "nranges.cxx" +#include "poolio.hxx" #ifdef DBG_UTIL ___ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits