Kaydet (Commit) 4e0e0d47 authored tarafından Noel Power's avatar Noel Power

don't let numforats in dxf entries clobber global number formats & update test

* Enabling the disabled test which checked a cell style attribute ( that was
getting clobbered by the dxf entries above )
* squash the 'escape' characters in dxf num formats ( probably should do this
in general
* regenerate the formats.xlsx file ( I had to manually tweak this as the conditional tests were failing with the excel created document )
üst 211916f8
......@@ -656,9 +656,7 @@ void testFormats_Impl(ScFiltersTest* pFiltersTest, ScDocument* pDoc, sal_Int32 n
// check actual align applied to cell, should be the same as
// the style
eHorJustify = static_cast<SvxCellHorJustify>(static_cast< const SvxHorJustifyItem& >(pPattern->GetItem( ATTR_HOR_JUSTIFY ) ).GetValue() );
#if ENABLE_WHEN_FIXED
CPPUNIT_ASSERT_EQUAL_MESSAGE("cell with 'Excel Built-in Date' style should be aligned centre horizontally", SVX_HOR_JUSTIFY_CENTER, eHorJustify);
#endif
}
}
......
......@@ -119,7 +119,7 @@ public:
/** Writes the specified number format to the passed property map. */
void writeToPropertyMap( PropertyMap& rPropMap, sal_Int32 nNumFmtId ) const;
sal_Int32 nextFreeId(){ return ++mnHighestId; }
private:
/** Inserts built-in number formats for the current system language. */
void insertBuiltinFormats();
......@@ -129,6 +129,7 @@ private:
NumberFormatMap maNumFmts; /// List of number formats.
::rtl::OUString maLocaleStr; /// Current office locale.
sal_Int32 mnHighestId;
};
// ============================================================================
......
......@@ -909,6 +909,7 @@ public:
FontRef createFont( sal_Int32* opnFontId = 0 );
/** Creates a number format. */
NumberFormatRef createNumFmt( sal_Int32 nNumFmtId, const ::rtl::OUString& rFmtCode );
sal_Int32 nextFreeNumFmtId();
/** Creates a new empty border object.
@param opnBorderId (out-param) The identifier of the new border object. */
BorderRef createBorder( sal_Int32* opnBorderId = 0 );
......
......@@ -1981,6 +1981,8 @@ NumberFormatRef NumberFormatsBuffer::createNumFmt( sal_Int32 nNumFmtId, const OU
{
xNumFmt.reset( new NumberFormat( *this ) );
maNumFmts[ nNumFmtId ] = xNumFmt;
if ( nNumFmtId > mnHighestId )
mnHighestId = nNumFmtId;
xNumFmt->setFormatCode( rFmtCode );
}
return xNumFmt;
......@@ -2081,7 +2083,11 @@ void NumberFormatsBuffer::insertBuiltinFormats()
// copy reused number formats
for( ReuseMap::const_iterator aRIt = aReuseMap.begin(), aREnd = aReuseMap.end(); aRIt != aREnd; ++aRIt )
{
maNumFmts[ aRIt->first ] = maNumFmts[ aRIt->second ];
if ( aRIt->first > mnHighestId )
mnHighestId = aRIt->first;
}
}
// ============================================================================
......
......@@ -2445,7 +2445,19 @@ FillRef Dxf::createFill( bool bAlwaysNew )
void Dxf::importNumFmt( const AttributeList& rAttribs )
{
mxNumFmt = getStyles().importNumFmt( rAttribs );
// don't propagate number formats defined in Dxf entries
// they can have the same id ( but different format codes ) as those
// defined globally earlier. We discard the id defined in XML_numFmtId
// and generate one ourselves ( this assumes that the normal numberformat
// import has already taken place )
sal_Int32 nNumFmtId = getStyles().nextFreeNumFmtId();
OUString aFmtCode = rAttribs.getXString( XML_formatCode, OUString() );
// we might need to do this generally for format codes,
// specifically for a fraction code '\ ?/?' is passed to us in xml, the '\' is not
// an escape character but merely should be telling the formatter to display the next
// char in the format ( afaics it does that anyhow )
aFmtCode = aFmtCode.replaceAll("\\", "");
mxNumFmt = getStyles().createNumFmt( nNumFmtId, aFmtCode );
}
void Dxf::importDxf( SequenceInputStream& rStrm )
......@@ -2942,6 +2954,11 @@ NumberFormatRef StylesBuffer::createNumFmt( sal_Int32 nNumFmtId, const OUString&
return maNumFmts.createNumFmt( nNumFmtId, rFmtCode );
}
sal_Int32 StylesBuffer::nextFreeNumFmtId()
{
return maNumFmts.nextFreeId();
}
BorderRef StylesBuffer::createBorder( sal_Int32* opnBorderId )
{
if( opnBorderId ) *opnBorderId = static_cast< sal_Int32 >( maBorders.size() );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment