Files
libreoffice/xmloff/source/draw/XMLNumberStyles.cxx

724 lines
23 KiB
C++
Raw Normal View History

/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
re-base on ALv2 code. Includes: Patches contributed by: Armin Le Grand. #118558# Correcting OLE attributes of LO3.4 at load time by loading as OOo3.3, details see task. http://svn.apache.org/viewvc?view=revision&revision=1195906 #118485# - Styles for OLEs are not saved. http://svn.apache.org/viewvc?view=revision&revision=1182166 #118898# Adapted ImpGraphic::ImplGetBitmap to correctly convert metafiles http://svn.apache.org/viewvc?view=revision&revision=1293316 #119337# Solves the wrong get/setPropertyValue calls in SvxShapeText (and thus in SvxOle2Shape) http://svn.apache.org/viewvc?view=revision&revision=1344156 Patches contributed by Mathias Bauer (and others) gnumake4 work variously http://svn.apache.org/viewvc?view=revision&revision=1394707 http://svn.apache.org/viewvc?view=revision&revision=1394326 cws mba34issues01: #i117717#: remove wrong assertion http://svn.apache.org/viewvc?view=revision&revision=1172349 Patch contributed by Herbert Duerr goodbye Registration and License dialogs, don't let the door hit you http://svn.apache.org/viewvc?view=revision&revision=1172613 help gcc 4.6.0 on 32bit ubuntu 11.10" http://svn.apache.org/viewvc?view=revision&revision=1245357 Do not add targets for junit tests when junit is disabled. Patch contributed by Andre Fischer http://svn.apache.org/viewvc?view=revision&revision=1241508 Revert "sb140: #i117082# avoid unncessary static class data members commit 21d97438e2944861e26e4984195f959a0cce1e41. remove obsolete FreeBSD visibility special case. retain consolidated BSD bridge code, remove OS/2 pieces.
2012-11-12 17:21:24 +00:00
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include <boost/shared_ptr.hpp>
#include <tools/debug.hxx>
#include <XMLNumberStylesExport.hxx>
#include <XMLNumberStylesImport.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/xmlimp.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmltoken.hxx>
#include "sdxmlexp_impl.hxx"
#include "sdxmlimp_impl.hxx"
using namespace ::xmloff::token;
struct SdXMLDataStyleNumber
{
enum XMLTokenEnum meNumberStyle;
bool mbLong;
bool mbTextual;
bool mbDecimal02;
const char* mpText;
}
aSdXMLDataStyleNumbers[] =
{
{ XML_DAY, false, false, false, NULL },
{ XML_DAY, true, false, false, NULL },
{ XML_MONTH, true, false, false, NULL },
{ XML_MONTH, false, true, false, NULL },
{ XML_MONTH, true, true, false, NULL },
{ XML_YEAR, false, false, false, NULL },
{ XML_YEAR, true, false, false, NULL },
{ XML_DAY_OF_WEEK, false, false, false, NULL },
{ XML_DAY_OF_WEEK, true, false, false, NULL },
{ XML_TEXT, false, false, false, "." },
{ XML_TEXT, false, false, false, " " },
{ XML_TEXT, false, false, false, ", " },
{ XML_TEXT, false, false, false, ". " },
{ XML_HOURS, false, false, false, NULL },
{ XML_MINUTES, false, false, false, NULL },
{ XML_TEXT, false, false, false, ":" },
{ XML_AM_PM, false, false, false, NULL },
{ XML_SECONDS, false, false, false, NULL },
{ XML_SECONDS, false, false, true, NULL },
{ XML_TOKEN_INVALID, false, false, false, NULL }
};
// date
#define DATA_STYLE_NUMBER_DAY 1 // <number:day/>
#define DATA_STYLE_NUMBER_DAY_LONG 2 // <number:day number:style="long"/>
#define DATA_STYLE_NUMBER_MONTH_LONG 3 // <number:month number:style="long"/>
#define DATA_STYLE_NUMBER_MONTH_TEXT 4 // <number:month number:textual="true"/>
#define DATA_STYLE_NUMBER_MONTH_LONG_TEXT 5 // <number:month number:style="long" number:textual="true"/>
#define DATA_STYLE_NUMBER_YEAR 6 // <number:year/>
#define DATA_STYLE_NUMBER_YEAR_LONG 7 // <number:year number:style="long"/>
#define DATA_STYLE_NUMBER_DAYOFWEEK 8 // <number:day-of-week/>
#define DATA_STYLE_NUMBER_DAYOFWEEK_LONG 9 // <number:day-of-week number:style="long"/>
#define DATA_STYLE_NUMBER_TEXT_POINT 10 // <number:text>.</number:text>
#define DATA_STYLE_NUMBER_TEXT_SPACE 11 // <number:text> </number:text>
#define DATA_STYLE_NUMBER_TEXT_COMMASPACE 12 // <number:text>, </number:text>
#define DATA_STYLE_NUMBER_TEXT_POINTSPACE 13 // <number:text>. </number:text>
#define DATA_STYLE_NUMBER_HOURS 14 // <number:hours/>
#define DATA_STYLE_NUMBER_MINUTES 15 // <number:minutes/>
#define DATA_STYLE_NUMBER_TEXT_COLON 16 // <number:text>:</number:text>
#define DATA_STYLE_NUMBER_AMPM 17 // <number:am-pm/>
#define DATA_STYLE_NUMBER_SECONDS 18 // <number:seconds/>
#define DATA_STYLE_NUMBER_SECONDS_02 19 // <number:seconds number:/>
struct SdXMLFixedDataStyle
{
const char* mpName;
bool mbAutomatic;
bool mbDateStyle;
sal_uInt8 mpFormat[8];
};
const SdXMLFixedDataStyle aSdXML_Standard_Short =
{
"D1", true, true,
{
DATA_STYLE_NUMBER_DAY_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_MONTH_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_YEAR_LONG,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_Standard_Long =
{
"D2", true, true,
{
DATA_STYLE_NUMBER_DAYOFWEEK_LONG,
DATA_STYLE_NUMBER_TEXT_COMMASPACE,
DATA_STYLE_NUMBER_DAY,
DATA_STYLE_NUMBER_TEXT_POINTSPACE,
DATA_STYLE_NUMBER_MONTH_LONG_TEXT,
DATA_STYLE_NUMBER_TEXT_SPACE,
DATA_STYLE_NUMBER_YEAR_LONG,
0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_1 =
{
"D3", false, true,
{
DATA_STYLE_NUMBER_DAY_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_MONTH_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_YEAR,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_2 =
{
"D4", false, true,
{
DATA_STYLE_NUMBER_DAY_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_MONTH_LONG,
DATA_STYLE_NUMBER_TEXT_POINT,
DATA_STYLE_NUMBER_YEAR_LONG,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_3 =
{
"D5", false, true,
{
DATA_STYLE_NUMBER_DAY,
DATA_STYLE_NUMBER_TEXT_POINTSPACE,
DATA_STYLE_NUMBER_MONTH_TEXT,
DATA_STYLE_NUMBER_TEXT_SPACE,
DATA_STYLE_NUMBER_YEAR_LONG,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_4 =
{
"D6", false, true,
{
DATA_STYLE_NUMBER_DAY,
DATA_STYLE_NUMBER_TEXT_POINTSPACE,
DATA_STYLE_NUMBER_MONTH_LONG_TEXT,
DATA_STYLE_NUMBER_TEXT_SPACE,
DATA_STYLE_NUMBER_YEAR_LONG,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_5 =
{
"D7", false, true,
{
DATA_STYLE_NUMBER_DAYOFWEEK,
DATA_STYLE_NUMBER_TEXT_COMMASPACE,
DATA_STYLE_NUMBER_DAY,
DATA_STYLE_NUMBER_TEXT_POINTSPACE,
DATA_STYLE_NUMBER_MONTH_LONG_TEXT,
DATA_STYLE_NUMBER_TEXT_SPACE,
DATA_STYLE_NUMBER_YEAR_LONG,
0
}
};
const SdXMLFixedDataStyle aSdXML_DateStyle_6 =
{
"D8", false, true,
{
DATA_STYLE_NUMBER_DAYOFWEEK_LONG,
DATA_STYLE_NUMBER_TEXT_COMMASPACE,
DATA_STYLE_NUMBER_DAY,
DATA_STYLE_NUMBER_TEXT_POINTSPACE,
DATA_STYLE_NUMBER_MONTH_LONG_TEXT,
DATA_STYLE_NUMBER_TEXT_SPACE,
DATA_STYLE_NUMBER_YEAR_LONG,
0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_1 =
{ "T1", true, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_SECONDS,
DATA_STYLE_NUMBER_AMPM,
0, 0,
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_2 =
{ "T2", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
0, 0, 0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_3 =
{ "T3", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_SECONDS,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_4 =
{ "T4", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_SECONDS_02,
0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_5 =
{ "T5", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_AMPM,
0, 0, 0, 0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_6 =
{ "T6", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_SECONDS,
DATA_STYLE_NUMBER_AMPM,
0, 0
}
};
const SdXMLFixedDataStyle aSdXML_TimeStyle_7 =
{ "T7", false, false,
{
DATA_STYLE_NUMBER_HOURS,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_MINUTES,
DATA_STYLE_NUMBER_TEXT_COLON,
DATA_STYLE_NUMBER_SECONDS_02,
DATA_STYLE_NUMBER_AMPM,
0, 0
}
};
const SdXMLFixedDataStyle* aSdXMLFixedDateFormats[SdXMLDateFormatCount] =
{
&aSdXML_Standard_Short,
&aSdXML_Standard_Long,
&aSdXML_DateStyle_1,
&aSdXML_DateStyle_2,
&aSdXML_DateStyle_3,
&aSdXML_DateStyle_4,
&aSdXML_DateStyle_5,
&aSdXML_DateStyle_6,
};
const SdXMLFixedDataStyle* aSdXMLFixedTimeFormats[SdXMLTimeFormatCount] =
{
&aSdXML_TimeStyle_1,
&aSdXML_TimeStyle_2,
&aSdXML_TimeStyle_3,
&aSdXML_TimeStyle_4,
&aSdXML_TimeStyle_5,
&aSdXML_TimeStyle_6,
&aSdXML_TimeStyle_7
};
// export
static void SdXMLExportDataStyleNumber( SdXMLExport& rExport, SdXMLDataStyleNumber& rElement )
{
if( rElement.mbDecimal02 )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_DECIMAL_PLACES, XML_2 );
}
if( rElement.mbLong )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_STYLE, XML_LONG );
}
if( rElement.mbTextual )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_TEXTUAL, XML_TRUE );
}
SvXMLElementExport aNumberStyle( rExport, XML_NAMESPACE_NUMBER, rElement.meNumberStyle, true, false );
if( rElement.mpText )
{
OUString sAttrValue( OUString::createFromAscii( rElement.mpText ) );
rExport.GetDocHandler()->characters( sAttrValue );
}
}
static void SdXMLExportStyle( SdXMLExport& rExport, const SdXMLFixedDataStyle* pStyle, const SdXMLFixedDataStyle* pStyle2 = NULL )
{
OUString sAttrValue;
// name
sAttrValue = OUString::createFromAscii( pStyle->mpName );
if( pStyle2 )
sAttrValue += OUString::createFromAscii( pStyle2->mpName );
rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_NAME, sAttrValue );
if( pStyle->mbAutomatic )
{
rExport.AddAttribute( XML_NAMESPACE_NUMBER, XML_AUTOMATIC_ORDER, XML_TRUE );
}
SvXMLElementExport aElement( rExport, XML_NAMESPACE_NUMBER, pStyle->mbDateStyle ? XML_DATE_STYLE : XML_TIME_STYLE, true, true );
do
{
const sal_uInt8* pElements = (const sal_uInt8*)&pStyle->mpFormat[0];
while( *pElements )
{
SdXMLDataStyleNumber& rElement = aSdXMLDataStyleNumbers[ (*pElements++) - 1 ];
SdXMLExportDataStyleNumber( rExport, rElement );
}
if( pStyle2 )
{
SdXMLDataStyleNumber& rElement = aSdXMLDataStyleNumbers[ DATA_STYLE_NUMBER_TEXT_SPACE - 1 ];
SdXMLExportDataStyleNumber( rExport, rElement );
}
pStyle = pStyle2;
pStyle2 = NULL;
}
while( pStyle );
}
void SdXMLNumberStylesExporter::exportTimeStyle( SdXMLExport& rExport, sal_Int32 nStyle )
{
DBG_ASSERT( (nStyle >= 0) && (nStyle < SdXMLTimeFormatCount), "Unknown time style!" );
if( (nStyle >= 0) && (nStyle < SdXMLTimeFormatCount) )
SdXMLExportStyle( rExport, aSdXMLFixedTimeFormats[ nStyle ] );
}
void SdXMLNumberStylesExporter::exportDateStyle( SdXMLExport& rExport, sal_Int32 nStyle )
{
if( nStyle > 0x0f )
{
int nDateStyle = nStyle & 0x0f;
bool bHasDate = nDateStyle != 0;
if( nDateStyle > 1 )
nDateStyle -= 2;
DBG_ASSERT( (nDateStyle >= 0) && (nDateStyle < SdXMLDateFormatCount), "unknown date style!" );
int nTimeStyle = (nStyle >> 4) & 0x0f;
bool bHasTime = nTimeStyle != 0;
if( nTimeStyle > 1 )
nTimeStyle -= 2;
DBG_ASSERT( (nTimeStyle >= 0) && (nTimeStyle < SdXMLTimeFormatCount), "Unknown time style!" );
if( (nDateStyle >= 0) && (nDateStyle < SdXMLDateFormatCount) && (nTimeStyle >= 0) && (nTimeStyle < SdXMLTimeFormatCount) )
{
if( bHasDate )
{
if( bHasTime )
{
SdXMLExportStyle( rExport, aSdXMLFixedDateFormats[ nDateStyle ], aSdXMLFixedTimeFormats[ nTimeStyle ] );
}
else
{
SdXMLExportStyle( rExport, aSdXMLFixedDateFormats[ nDateStyle ] );
}
}
else if( bHasTime )
{
SdXMLExportStyle( rExport, aSdXMLFixedTimeFormats[ nTimeStyle ] );
}
}
}
else
{
DBG_ASSERT( (nStyle >= 0) && (nStyle < SdXMLDateFormatCount), "unknown date style!" );
if( (nStyle >= 0) && (nStyle < SdXMLDateFormatCount) )
SdXMLExportStyle( rExport, aSdXMLFixedDateFormats[ nStyle ] );
}
}
OUString SdXMLNumberStylesExporter::getTimeStyleName(const sal_Int32 nTimeFormat )
{
sal_Int32 nFormat = nTimeFormat;
if( nFormat > 1 )
nFormat -= 2;
if( (nFormat >= 0) && (nFormat < SdXMLTimeFormatCount) )
{
return OUString::createFromAscii(aSdXMLFixedTimeFormats[nFormat]->mpName );
}
else
{
return OUString();
}
}
OUString SdXMLNumberStylesExporter::getDateStyleName(const sal_Int32 nDateFormat )
{
sal_Int32 nFormat = nDateFormat;
if( nFormat > 0x0f )
{
OUString aStr;
if( nFormat & 0x0f )
aStr = getDateStyleName( nFormat & 0x0f );
aStr += getTimeStyleName( (nFormat >> 4) & 0x0f );
return aStr;
}
if( nFormat > 1 )
nFormat -= 2;
if( (nFormat >= 0) && (nFormat < SdXMLDateFormatCount) )
{
return OUString::createFromAscii(aSdXMLFixedDateFormats[nFormat]->mpName );
}
else
{
return OUString();
}
}
// import
class SdXMLNumberFormatMemberImportContext : public SvXMLImportContext
{
private:
SdXMLNumberFormatImportContext* mpParent;
OUString maNumberStyle;
bool mbLong;
bool mbTextual;
bool mbDecimal02;
OUString maText;
boost::shared_ptr< SvXMLImportContext > mpSlaveContext;
public:
TYPEINFO_OVERRIDE();
SdXMLNumberFormatMemberImportContext( SvXMLImport& rImport,
sal_uInt16 nPrfx,
const OUString& rLocalName,
const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList,
SdXMLNumberFormatImportContext* pParent,
SvXMLImportContext* pSlaveContext );
virtual ~SdXMLNumberFormatMemberImportContext();
virtual SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList ) SAL_OVERRIDE;
virtual void EndElement() SAL_OVERRIDE;
virtual void Characters( const OUString& rChars ) SAL_OVERRIDE;
};
TYPEINIT1( SdXMLNumberFormatMemberImportContext, SvXMLImportContext );
SdXMLNumberFormatMemberImportContext::SdXMLNumberFormatMemberImportContext( SvXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, SdXMLNumberFormatImportContext* pParent, SvXMLImportContext* pSlaveContext )
: SvXMLImportContext(rImport, nPrfx, rLocalName),
mpParent( pParent ),
maNumberStyle( rLocalName ),
mpSlaveContext( pSlaveContext )
{
mbLong = false;
mbTextual = false;
mbDecimal02 = false;
const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
OUString sValue = xAttrList->getValueByIndex( i );
if( nPrefix == XML_NAMESPACE_NUMBER )
{
if( IsXMLToken( aLocalName, XML_DECIMAL_PLACES ) )
{
mbDecimal02 = IsXMLToken( sValue, XML_2 );
}
else if( IsXMLToken( aLocalName, XML_STYLE ) )
{
mbLong = IsXMLToken( sValue, XML_LONG );
}
else if( IsXMLToken( aLocalName, XML_TEXTUAL ) )
{
mbTextual = IsXMLToken( sValue, XML_TRUE );
}
}
}
}
SdXMLNumberFormatMemberImportContext::~SdXMLNumberFormatMemberImportContext()
{
}
SvXMLImportContext *SdXMLNumberFormatMemberImportContext::CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
{
return mpSlaveContext->CreateChildContext( nPrefix, rLocalName, xAttrList );
}
void SdXMLNumberFormatMemberImportContext::StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList )
{
mpSlaveContext->StartElement( xAttrList );
}
void SdXMLNumberFormatMemberImportContext::EndElement()
{
mpSlaveContext->EndElement();
if( mpParent )
mpParent->add( maNumberStyle, mbLong, mbTextual, mbDecimal02, maText );
}
void SdXMLNumberFormatMemberImportContext::Characters( const OUString& rChars )
{
mpSlaveContext->Characters( rChars );
maText += rChars;
}
TYPEINIT1( SdXMLNumberFormatImportContext, SvXMLImportContext );
SdXMLNumberFormatImportContext::SdXMLNumberFormatImportContext( SdXMLImport& rImport, sal_uInt16 nPrfx, const OUString& rLocalName, SvXMLNumImpData* pNewData, sal_uInt16 nNewType, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList, SvXMLStylesContext& rStyles)
: SvXMLNumFormatContext(rImport, nPrfx, rLocalName, pNewData, nNewType, xAttrList, rStyles),
mbAutomatic( false ),
mnIndex(0),
mnKey( -1 )
{
mbTimeStyle = IsXMLToken( rLocalName, XML_TIME_STYLE );
const sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
for(sal_Int16 i=0; i < nAttrCount; i++)
{
OUString sAttrName = xAttrList->getNameByIndex( i );
OUString aLocalName;
sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( sAttrName, &aLocalName );
OUString sValue = xAttrList->getValueByIndex( i );
if( nPrefix == XML_NAMESPACE_NUMBER )
{
if( IsXMLToken( aLocalName, XML_AUTOMATIC_ORDER ) )
{
mbAutomatic = IsXMLToken( sValue, XML_TRUE );
}
}
}
}
SdXMLNumberFormatImportContext::~SdXMLNumberFormatImportContext()
{
}
void SdXMLNumberFormatImportContext::add( OUString& rNumberStyle, bool bLong, bool bTextual, bool bDecimal02, OUString& rText )
{
if( mnIndex == -1 || mnIndex == 16 )
{
mnIndex = -1;
return;
}
const SdXMLDataStyleNumber* pStyleMember = aSdXMLDataStyleNumbers;
for( sal_uInt8 nIndex = 0; pStyleMember->meNumberStyle != XML_TOKEN_INVALID; nIndex++, pStyleMember++ )
{
if( (IsXMLToken(rNumberStyle, pStyleMember->meNumberStyle) &&
(pStyleMember->mbLong == bLong) &&
(pStyleMember->mbTextual == bTextual) &&
(pStyleMember->mbDecimal02 == bDecimal02) &&
( ( (pStyleMember->mpText == NULL) && (rText.isEmpty()) ) ||
( pStyleMember->mpText && (rText.equalsAscii( pStyleMember->mpText ) ) ) ) ) )
{
mnElements[mnIndex++] = nIndex + 1;
return;
}
}
}
bool SdXMLNumberFormatImportContext::compareStyle( const SdXMLFixedDataStyle* pStyle, sal_Int16& nIndex ) const
{
if( (pStyle->mbAutomatic != mbAutomatic) && (nIndex == 0))
return false;
sal_Int16 nCompareIndex;
for( nCompareIndex = 0; nCompareIndex < 8; nIndex++, nCompareIndex++ )
{
if( pStyle->mpFormat[nCompareIndex] != mnElements[nIndex] )
return false;
}
return true;
}
void SdXMLNumberFormatImportContext::EndElement()
{
SvXMLNumFormatContext::EndElement();
for( ; mnIndex < 16; mnIndex++ )
{
mnElements[mnIndex] = 0;
}
if( mbTimeStyle )
{
// compare import with all time styles
for( sal_Int16 nFormat = 0; nFormat < SdXMLTimeFormatCount; nFormat++ )
{
sal_Int16 nIndex = 0;
if( compareStyle( aSdXMLFixedTimeFormats[nFormat], nIndex ) )
{
mnKey = nFormat + 2;
break;
}
}
}
else
{
// compare import with all date styles
for( sal_Int16 nFormat = 0; nFormat < SdXMLDateFormatCount; nFormat++ )
{
sal_Int16 nIndex = 0;
if( compareStyle( aSdXMLFixedDateFormats[nFormat], nIndex ) )
{
mnKey = nFormat + 2;
break;
}
else if( mnElements[nIndex] == DATA_STYLE_NUMBER_TEXT_SPACE )
{
// if it's a valid date ending with a space, see if a time style follows
for( sal_Int16 nTimeFormat = 0; nTimeFormat < SdXMLTimeFormatCount; nTimeFormat++ )
{
sal_Int16 nIndex2 = nIndex + 1;
if( compareStyle( aSdXMLFixedTimeFormats[nTimeFormat], nIndex2 ) )
{
CWS-TOOLING: integrate CWS cmcfixes51 2008-12-08 10:12:55 +0100 cmc r264975 : #i96203# protect with ifdefs to avoid unused symbol on mac 2008-12-05 12:23:47 +0100 cmc r264898 : CWS-TOOLING: rebase CWS cmcfixes51 to trunk@264807 (milestone: DEV300:m37) 2008-12-01 14:45:17 +0100 cmc r264606 : #i76655# ehlos apparently required 2008-11-28 17:49:30 +0100 cmc r264567 : #i96655# remove newly unused method 2008-11-28 10:41:28 +0100 cmc r264531 : #i96647# better ppc-bridges flushCode impl 2008-11-27 12:58:40 +0100 cmc r264478 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:32:49 +0100 cmc r264476 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 12:26:02 +0100 cmc r264475 : #i96655# redundant old table export helpers 2008-11-27 11:49:06 +0100 cmc r264473 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:38:35 +0100 cmc r264471 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:14:21 +0100 cmc r264467 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 11:06:22 +0100 cmc r264464 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:58:18 +0100 cmc r264462 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:41:44 +0100 cmc r264461 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:19:24 +0100 cmc r264460 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:13:39 +0100 cmc r264459 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 10:06:14 +0100 cmc r264458 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:59:54 +0100 cmc r264457 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:52:51 +0100 cmc r264456 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:48:26 +0100 cmc r264454 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:40:20 +0100 cmc r264452 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:35:26 +0100 cmc r264451 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:31:00 +0100 cmc r264450 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 09:24:08 +0100 cmc r264449 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:26:15 +0100 cmc r264443 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:21:01 +0100 cmc r264442 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-27 00:09:40 +0100 cmc r264441 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:51:56 +0100 cmc r264440 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 23:49:09 +0100 cmc r264439 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:09:54 +0100 cmc r264432 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 18:07:40 +0100 cmc r264431 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:28:02 +0100 cmc r264429 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:27:39 +0100 cmc r264428 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 17:18:36 +0100 cmc r264426 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 16:22:16 +0100 cmc r264415 : #i96624# make implicit braces and brackets explicit to avoid warnings 2008-11-26 16:00:23 +0100 cmc r264409 : #i90426# remove warnings from svtools 2008-11-26 15:59:17 +0100 cmc r264408 : #i90426# remove warnings 2008-11-26 15:47:32 +0100 cmc r264404 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:46:57 +0100 cmc r264394 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:19:50 +0100 cmc r264387 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:15:26 +0100 cmc r264386 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 14:11:26 +0100 cmc r264384 : #i96084# confirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:44:23 +0100 cmc r264380 : #i96084# comfirm existing logic with explicit brackets to remove new gcc warnings 2008-11-26 13:12:24 +0100 cmc r264372 : #i96604# silence new warnings 2008-11-26 12:35:02 +0100 cmc r264369 : #i96203# make qstarter work in 3-layer land 2008-11-26 12:33:04 +0100 cmc r264368 : #i96170# ensure gtypes are up and running
2008-12-11 07:05:03 +00:00
mnKey = (nFormat + 2) | ((nTimeFormat + 2) << 4);
break;
}
}
}
}
// no date style found? maybe its an extended time style
if( mnKey == -1 )
{
// compare import with all time styles
for( sal_Int16 nFormat = 0; nFormat < SdXMLTimeFormatCount; nFormat++ )
{
sal_Int16 nIndex = 0;
if( compareStyle( aSdXMLFixedTimeFormats[nFormat], nIndex ) )
{
mnKey = (nFormat + 2) << 4;
break;
}
}
}
}
}
SvXMLImportContext * SdXMLNumberFormatImportContext::CreateChildContext( sal_uInt16 nPrefix, const OUString& rLocalName, const com::sun::star::uno::Reference< com::sun::star::xml::sax::XAttributeList>& xAttrList )
{
return new SdXMLNumberFormatMemberImportContext( GetImport(), nPrefix, rLocalName, xAttrList, this, SvXMLNumFormatContext::CreateChildContext( nPrefix, rLocalName, xAttrList ) );
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */