void SAL_CALL OOXMLDocPropHandler::characters()

in main/oox/source/docprop/docprophandler.cxx [392:671]


void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars )
    throw (xml::sax::SAXException, uno::RuntimeException)
{
    try
    {
        if ( (m_nInBlock == 2) || ((m_nInBlock == 3) && m_nType) )
        {
            if ( m_nState == COREPR_TOKEN( coreProperties ) )
            {
                switch( m_nBlock )
                {
                    case COREPR_TOKEN( category ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "category" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case COREPR_TOKEN( contentStatus ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "contentStatus" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case COREPR_TOKEN( contentType ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "contentType" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case COREPR_TOKEN( identifier ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "identifier" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case COREPR_TOKEN( version ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "version" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case DCT_TOKEN( created ):
                        if ( aChars.getLength() >= 4 )
                            m_xDocProp->setCreationDate( GetDateTimeFromW3CDTF( aChars ) );
                        break;

                    case DC_TOKEN( creator ):
                        m_xDocProp->setAuthor( aChars );
                        break;

                    case DC_TOKEN( description ):
                        m_xDocProp->setDescription( aChars );
                        break;

                    case COREPR_TOKEN( keywords ):
                        m_xDocProp->setKeywords( GetKeywordsSet( aChars ) );
                        break;

                    case DC_TOKEN( language ):
                        if ( aChars.getLength() >= 2 )
                            m_xDocProp->setLanguage( GetLanguage( aChars ) );
                        break;

                    case COREPR_TOKEN( lastModifiedBy ):
                        m_xDocProp->setModifiedBy( aChars );
                        break;

                    case COREPR_TOKEN( lastPrinted ):
                        if ( aChars.getLength() >= 4 )
                            m_xDocProp->setPrintDate( GetDateTimeFromW3CDTF( aChars ) );
                        break;

                    case DCT_TOKEN( modified ):
                        if ( aChars.getLength() >= 4 )
                            m_xDocProp->setModificationDate( GetDateTimeFromW3CDTF( aChars ) );
                        break;

                    case COREPR_TOKEN( revision ):
                        try
                        {
                            m_xDocProp->setEditingCycles(
                                static_cast<sal_Int16>(aChars.toInt32()) );
                        }
                        catch (lang::IllegalArgumentException &)
                        {
                            // ignore
                        }
                        break;

                    case DC_TOKEN( subject ):
                        m_xDocProp->setSubject( aChars );
                        break;

                    case DC_TOKEN( title ):
                        m_xDocProp->setTitle( aChars );
                        break;

                    default:
                        OSL_ASSERT( "Unexpected core property!" );
                }
            }
            else if ( m_nState == EXTPR_TOKEN( Properties ) )
            {
                switch( m_nBlock )
                {
                    case EXTPR_TOKEN( Application ):
                        m_xDocProp->setGenerator( aChars );
                        break;

                    case EXTPR_TOKEN( Template ):
                        m_xDocProp->setTemplateName( aChars );
                        break;

                    case EXTPR_TOKEN( TotalTime ):
                        try
                        {
                            m_xDocProp->setEditingDuration( aChars.toInt32() );
                        }
                        catch (lang::IllegalArgumentException &)
                        {
                            // ignore
                        }
                        break;

                    case EXTPR_TOKEN( Characters ):
                    case EXTPR_TOKEN( Pages ):
                    case EXTPR_TOKEN( Words ):
                    case EXTPR_TOKEN( Paragraphs ):
                        UpdateDocStatistic( aChars );
                        break;

                    case EXTPR_TOKEN( HyperlinksChanged ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HyperlinksChanged" ) );
                        AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
                        break;

                    case EXTPR_TOKEN( LinksUpToDate ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LinksUpToDate" ) );
                        AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
                        break;

                    case EXTPR_TOKEN( ScaleCrop ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScaleCrop" ) );
                        AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
                        break;

                    case EXTPR_TOKEN( SharedDoc ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ShareDoc" ) );
                        AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
                        break;

                    case EXTPR_TOKEN( DocSecurity ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocSecurity" ) );
                        AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
                        break;

                    case EXTPR_TOKEN( HiddenSlides ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HiddenSlides" ) );
                        AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
                        break;

                    case EXTPR_TOKEN( MMClips ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MMClips" ) );
                        AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
                        break;

                    case EXTPR_TOKEN( Notes ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Notes" ) );
                        AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
                        break;

                    case EXTPR_TOKEN( Slides ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Slides" ) );
                        AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
                        break;

                    case EXTPR_TOKEN( AppVersion ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AppVersion" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case EXTPR_TOKEN( Company ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Company" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case EXTPR_TOKEN( HyperlinkBase ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HyperlinkBase" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case EXTPR_TOKEN( Manager ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Manager" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case EXTPR_TOKEN( PresentationFormat ):
                        m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PresentationFormat" ) );
                        AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
                        break;

                    case EXTPR_TOKEN( CharactersWithSpaces ):
                    case EXTPR_TOKEN( Lines ):
                    case EXTPR_TOKEN( DigSig ):
                    case EXTPR_TOKEN( HeadingPairs ):
                    case EXTPR_TOKEN( HLinks ):
                    case EXTPR_TOKEN( TitlesOfParts ):
                        // ignored during the import currently
                        break;

                    default:
                        OSL_ASSERT( "Unexpected extended property!" );
                }
            }
            else if ( m_nState == CUSTPR_TOKEN( Properties ) )
            {
                if ( m_nBlock == CUSTPR_TOKEN( property ) )
                {
                    // this is a custom property
                    switch( m_nType )
                    {
                        case VT_TOKEN( bool ):
                            AddCustomProperty( uno::makeAny( aChars.toBoolean() ) );
                            break;

                        case VT_TOKEN( bstr ):
                        case VT_TOKEN( lpstr ):
                        case VT_TOKEN( lpwstr ):
                            AddCustomProperty( uno::makeAny( AttributeConversion::decodeXString( aChars ) ) ); // the property has string type
                            break;

                        case VT_TOKEN( date ):
                        case VT_TOKEN( filetime ):
                            AddCustomProperty( uno::makeAny( GetDateTimeFromW3CDTF( aChars ) ) );

                        case VT_TOKEN( i1 ):
                        case VT_TOKEN( i2 ):
                            AddCustomProperty( uno::makeAny( (sal_Int16)aChars.toInt32() ) );
                            break;

                        case VT_TOKEN( i4 ):
                        case VT_TOKEN( int ):
                            AddCustomProperty( uno::makeAny( aChars.toInt32() ) );
                            break;

                        case VT_TOKEN( i8 ):
                            AddCustomProperty( uno::makeAny( aChars.toInt64() ) );
                            break;

                        case VT_TOKEN( r4 ):
                            AddCustomProperty( uno::makeAny( aChars.toFloat() ) );
                            break;

                        case VT_TOKEN( r8 ):
                            AddCustomProperty( uno::makeAny( aChars.toDouble() ) );
                            break;

                        default:
                            // all the other types are ignored;
                            break;
                    }
                }
                else
                {
                    OSL_ASSERT( "Unexpected tag in custom property!" );
                }
            }
        }
    }
    catch( uno::RuntimeException& )
    {
        throw;
    }
    catch( xml::sax::SAXException& )
    {
        throw;
    }
    catch( uno::Exception& e )
    {
        throw xml::sax::SAXException(
            ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Error while setting document property!" ) ),
            uno::Reference< uno::XInterface >(),
            uno::makeAny( e ) );
    }
}