merge the formfield patch from ooo-build
[ooovba.git] / oox / source / docprop / docprophandler.cxx
blobbfff11b8b5254b237de6f4bdafa9858422079285
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: docprophandler.cxx,v $
10 * $Revision: 1.2.22.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "docprophandler.hxx"
33 #include <com/sun/star/beans/PropertyAttribute.hpp>
34 #include <com/sun/star/beans/PropertyExistException.hpp>
35 #include <com/sun/star/lang/Locale.hpp>
37 #include <osl/time.h>
39 #include "tokens.hxx"
40 #include "oox/helper/attributelist.hxx"
41 #include "oox/core/namespaces.hxx"
43 using namespace ::com::sun::star;
45 namespace oox {
46 namespace docprop {
48 // ------------------------------------------------
49 OOXMLDocPropHandler::OOXMLDocPropHandler( const uno::Reference< uno::XComponentContext >& xContext, const uno::Reference< document::XDocumentProperties > xDocProp )
50 : m_xContext( xContext )
51 , m_xDocProp( xDocProp )
52 , m_nState( 0 )
53 , m_nBlock( 0 )
54 , m_nType( 0 )
55 , m_nInBlock( 0 )
57 if ( !xContext.is() || !xDocProp.is() )
58 throw uno::RuntimeException();
61 // ------------------------------------------------
62 OOXMLDocPropHandler::~OOXMLDocPropHandler()
66 // ------------------------------------------------
67 void OOXMLDocPropHandler::InitNew()
69 m_nState = 0;
70 m_nBlock = 0;
71 m_aCustomPropertyName = ::rtl::OUString();
72 m_nType = 0;
73 m_nInBlock = 0;
76 // ------------------------------------------------
77 void OOXMLDocPropHandler::AddCustomProperty( const uno::Any& aAny )
79 if ( m_aCustomPropertyName.getLength() )
81 uno::Reference< beans::XPropertyContainer > xUserProps = m_xDocProp->getUserDefinedProperties();
82 if ( !xUserProps.is() )
83 throw uno::RuntimeException();
85 try
87 xUserProps->addProperty( m_aCustomPropertyName, beans::PropertyAttribute::TRANSIENT, aAny );
89 catch( beans::PropertyExistException& )
91 // conflicts with core and extended properties are possible
93 catch( uno::Exception& )
95 OSL_ASSERT( "Can not add custom property!" );
100 // ------------------------------------------------
101 util::DateTime OOXMLDocPropHandler::GetDateTimeFromW3CDTF( const ::rtl::OUString& aChars )
103 oslDateTime aOslDTime = { 0, 0, 0, 0, 0, 0, 0, 0 };
104 sal_Int32 nLen = aChars.getLength();
105 if ( nLen >= 4 )
107 aOslDTime.Year = (sal_uInt16)aChars.copy( 0, 4 ).toInt32();
109 if ( nLen >= 7 && aChars.getStr()[4] == (sal_Unicode)'-' )
111 aOslDTime.Month = (sal_uInt16)aChars.copy( 5, 2 ).toInt32();
113 if ( nLen >= 10 && aChars.getStr()[7] == (sal_Unicode)'-' )
115 aOslDTime.Day = (sal_uInt16)aChars.copy( 8, 2 ).toInt32();
117 if ( nLen >= 16 && aChars.getStr()[10] == (sal_Unicode)'T' && aChars.getStr()[13] == (sal_Unicode)':' )
119 aOslDTime.Hours = (sal_uInt16)aChars.copy( 11, 2 ).toInt32();
120 aOslDTime.Minutes = (sal_uInt16)aChars.copy( 14, 2 ).toInt32();
122 sal_Int32 nOptTime = 0;
123 if ( nLen >= 19 && aChars.getStr()[16] == (sal_Unicode)':' )
125 aOslDTime.Seconds = (sal_uInt16)aChars.copy( 17, 2 ).toInt32();
126 nOptTime += 3;
127 if ( nLen >= 21 && aChars.getStr()[19] == (sal_Unicode)'.' )
129 aOslDTime.NanoSeconds = (sal_uInt32)(aChars.copy( 20, 1 ).toInt32() * 10e8);
130 nOptTime += 2;
134 sal_Int32 nModif = 0;
135 if ( nLen >= 16 + nOptTime + 6 )
137 if ( ( aChars.getStr()[16 + nOptTime] == (sal_Unicode)'+' || aChars.getStr()[16 + nOptTime] == (sal_Unicode)'-' )
138 && aChars.getStr()[16 + nOptTime + 3] == (sal_Unicode)':' )
141 nModif = aChars.copy( 16 + nOptTime + 1, 2 ).toInt32() * 3600;
142 nModif += aChars.copy( 16 + nOptTime + 4, 2 ).toInt32() * 60;
143 if ( aChars.getStr()[16 + nOptTime] == (sal_Unicode)'-' )
144 nModif *= -1;
148 if ( nModif )
150 // convert to UTC time
151 TimeValue aTmp;
152 if ( osl_getTimeValueFromDateTime( &aOslDTime, &aTmp ) )
154 aTmp.Seconds += nModif;
155 osl_getDateTimeFromTimeValue( &aTmp, &aOslDTime );
163 return util::DateTime( (sal_uInt16)( aOslDTime.NanoSeconds / 1e7 ), aOslDTime.Seconds, aOslDTime.Minutes, aOslDTime.Hours, aOslDTime.Day, aOslDTime.Month, aOslDTime.Year );
166 // ------------------------------------------------
167 uno::Sequence< ::rtl::OUString > OOXMLDocPropHandler::GetKeywordsSet( const ::rtl::OUString& aChars )
169 if ( aChars.getLength() )
171 uno::Sequence< ::rtl::OUString > aResult( 20 );
172 sal_Int32 nCounter = 0;
174 const sal_Unicode* pStr = aChars.getStr();
175 for( sal_Int32 nInd = 0; nInd < aChars.getLength() && pStr[nInd] != 0; nInd++ )
177 switch( pStr[nInd] )
179 case (sal_Unicode)' ':
180 case (sal_Unicode)',':
181 case (sal_Unicode)';':
182 case (sal_Unicode)':':
183 case (sal_Unicode)' ':
184 // this is a delimiter
185 // unfortunately I did not find any specification for the possible delimiters
186 if ( aResult[nCounter].getLength() )
188 if ( nCounter >= aResult.getLength() )
189 aResult.realloc( nCounter + 10 );
190 nCounter++;
192 break;
194 default:
195 // this should be a part of keyword
196 aResult[nCounter] += ::rtl::OUString( (sal_Unicode)pStr[nInd] );
200 aResult.realloc( nCounter + 1 );
201 return aResult;
204 return uno::Sequence< ::rtl::OUString >();
206 // ------------------------------------------------
207 lang::Locale OOXMLDocPropHandler::GetLanguage( const ::rtl::OUString& aChars )
209 lang::Locale aResult;
210 if ( aChars.getLength() >= 2 )
212 aResult.Language = aChars.copy( 0, 2 );
213 if ( aChars.getLength() >= 5 && aChars.getStr()[2] == (sal_Unicode)'-' )
214 aResult.Country = aChars.copy( 3, 2 );
216 // TODO/LATER: the variant could be also detected
219 return aResult;
222 // ------------------------------------------------
223 void OOXMLDocPropHandler::UpdateDocStatistic( const ::rtl::OUString& aChars )
225 uno::Sequence< beans::NamedValue > aSet = m_xDocProp->getDocumentStatistics();
226 ::rtl::OUString aName;
228 switch( m_nBlock )
230 case XML_Characters|NMSP_EXTPR:
231 aName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "CharacterCount" ) );
232 break;
234 case XML_Pages|NMSP_EXTPR:
235 aName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PageCount" ) );
236 break;
238 case XML_Words|NMSP_EXTPR:
239 aName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "WordCount" ) );
240 break;
242 case XML_Paragraphs|NMSP_EXTPR:
243 aName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ParagraphCount" ) );
244 break;
246 default:
247 OSL_ASSERT( "Unexpected statistic!" );
248 break;
251 if ( aName.getLength() )
253 sal_Bool bFound = sal_False;
254 sal_Int32 nLen = aSet.getLength();
255 for ( sal_Int32 nInd = 0; nInd < nLen; nInd++ )
256 if ( aSet[nInd].Name.equals( aName ) )
258 aSet[nInd].Value = uno::makeAny( aChars.toInt32() );
259 bFound = sal_True;
260 break;
263 if ( !bFound )
265 aSet.realloc( nLen + 1 );
266 aSet[nLen].Name = aName;
267 aSet[nLen].Value = uno::makeAny( aChars.toInt32() );
270 m_xDocProp->setDocumentStatistics( aSet );
274 // ------------------------------------------------
275 // com.sun.star.xml.sax.XFastDocumentHandler
276 // ------------------------------------------------
277 void SAL_CALL OOXMLDocPropHandler::startDocument()
278 throw (xml::sax::SAXException, uno::RuntimeException)
282 // ------------------------------------------------
283 void SAL_CALL OOXMLDocPropHandler::endDocument()
284 throw (xml::sax::SAXException, uno::RuntimeException)
286 InitNew();
289 // ------------------------------------------------
290 void SAL_CALL OOXMLDocPropHandler::setDocumentLocator( const uno::Reference< xml::sax::XLocator >& )
291 throw (xml::sax::SAXException, uno::RuntimeException)
296 // com.sun.star.xml.sax.XFastContextHandler
297 // ------------------------------------------------
298 void SAL_CALL OOXMLDocPropHandler::startFastElement( ::sal_Int32 nElement, const uno::Reference< xml::sax::XFastAttributeList >& xAttribs )
299 throw (xml::sax::SAXException, uno::RuntimeException)
301 if ( !m_nInBlock && !m_nState )
303 if ( nElement == ( XML_coreProperties|NMSP_COREPR )
304 || nElement == ( XML_Properties|NMSP_EXTPR )
305 || nElement == ( XML_Properties|NMSP_CUSTPR ) )
307 m_nState = nElement;
309 else
311 OSL_ASSERT( "Unexpected file format!" );
314 else if ( m_nState && m_nInBlock == 1 ) // that tag should contain the property name
316 // Currently the attributes are ignored for the core properties since the only
317 // known attribute is xsi:type that can only be used with dcterms:created and
318 // dcterms:modified, and this element is allowed currently to have only one value dcterms:W3CDTF
319 m_nBlock = nElement;
321 if ( xAttribs.is() && xAttribs->hasAttribute( XML_name ) )
322 m_aCustomPropertyName = xAttribs->getValue( XML_name );
324 else if ( m_nState && m_nInBlock && m_nInBlock == 2 && ( nElement >> 16 ) == ( NMSP_VT >> 16 ) )
326 m_nType = nElement;
328 else
330 OSL_ASSERT( "For now unexpected tags are ignored!" );
333 if ( m_nInBlock == SAL_MAX_INT32 )
334 throw uno::RuntimeException();
336 m_nInBlock++;
339 // ------------------------------------------------
340 void SAL_CALL OOXMLDocPropHandler::startUnknownElement( const ::rtl::OUString& aNamespace, const ::rtl::OUString& aName, const uno::Reference< xml::sax::XFastAttributeList >& )
341 throw (xml::sax::SAXException, uno::RuntimeException)
343 ::rtl::OUString aUnknown = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown element" ) );
344 aUnknown += aNamespace;
345 aUnknown += ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( ":" ) );
346 aUnknown += aName;
347 OSL_ASSERT( ::rtl::OUStringToOString( aUnknown, RTL_TEXTENCODING_UTF8 ).getStr() );
349 if ( m_nInBlock == SAL_MAX_INT32 )
350 throw uno::RuntimeException();
352 m_nInBlock++;
355 // ------------------------------------------------
356 void SAL_CALL OOXMLDocPropHandler::endFastElement( ::sal_Int32 )
357 throw (xml::sax::SAXException, uno::RuntimeException)
359 if ( m_nInBlock )
361 m_nInBlock--;
363 if ( !m_nInBlock )
364 m_nState = 0;
365 else if ( m_nInBlock == 1 )
367 m_nBlock = 0;
368 m_aCustomPropertyName = ::rtl::OUString();
370 else if ( m_nInBlock == 2 )
371 m_nType = 0;
375 // ------------------------------------------------
376 void SAL_CALL OOXMLDocPropHandler::endUnknownElement( const ::rtl::OUString&, const ::rtl::OUString& )
377 throw (xml::sax::SAXException, uno::RuntimeException)
379 if ( m_nInBlock )
380 m_nInBlock--;
383 // ------------------------------------------------
384 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL OOXMLDocPropHandler::createFastChildContext( ::sal_Int32, const uno::Reference< xml::sax::XFastAttributeList >& )
385 throw (xml::sax::SAXException, uno::RuntimeException)
387 // Should the arguments be parsed?
388 return uno::Reference< xml::sax::XFastContextHandler >( static_cast< xml::sax::XFastContextHandler* >( this ) );
391 // ------------------------------------------------
392 uno::Reference< xml::sax::XFastContextHandler > SAL_CALL OOXMLDocPropHandler::createUnknownChildContext( const ::rtl::OUString&, const ::rtl::OUString&, const uno::Reference< xml::sax::XFastAttributeList >& )
393 throw (xml::sax::SAXException, uno::RuntimeException)
395 return uno::Reference< xml::sax::XFastContextHandler >( static_cast< xml::sax::XFastContextHandler* >( this ) );
398 // ------------------------------------------------
399 void SAL_CALL OOXMLDocPropHandler::characters( const ::rtl::OUString& aChars )
400 throw (xml::sax::SAXException, uno::RuntimeException)
404 if ( (m_nInBlock == 2) || ((m_nInBlock == 3) && m_nType) )
406 if ( m_nState == ( XML_coreProperties|NMSP_COREPR ) )
408 switch( m_nBlock )
410 case XML_category|NMSP_COREPR:
411 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "category" ) );
412 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
413 break;
415 case XML_contentStatus|NMSP_COREPR:
416 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "contentStatus" ) );
417 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
418 break;
420 case XML_contentType|NMSP_COREPR:
421 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "contentType" ) );
422 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
423 break;
425 case XML_identifier|NMSP_COREPR:
426 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "identifier" ) );
427 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
428 break;
430 case XML_version|NMSP_COREPR:
431 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "version" ) );
432 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
433 break;
435 case XML_created|NMSP_DCTERMS:
436 if ( aChars.getLength() >= 4 )
437 m_xDocProp->setCreationDate( GetDateTimeFromW3CDTF( aChars ) );
438 break;
440 case XML_creator|NMSP_DC:
441 m_xDocProp->setAuthor( aChars );
442 break;
444 case XML_description|NMSP_DC:
445 m_xDocProp->setDescription( aChars );
446 break;
448 case XML_keywords|NMSP_COREPR:
449 m_xDocProp->setKeywords( GetKeywordsSet( aChars ) );
450 break;
452 case XML_language|NMSP_DC:
453 if ( aChars.getLength() >= 2 )
454 m_xDocProp->setLanguage( GetLanguage( aChars ) );
455 break;
457 case XML_lastModifiedBy|NMSP_COREPR:
458 m_xDocProp->setModifiedBy( aChars );
459 break;
461 case XML_lastPrinted|NMSP_COREPR:
462 if ( aChars.getLength() >= 4 )
463 m_xDocProp->setPrintDate( GetDateTimeFromW3CDTF( aChars ) );
464 break;
466 case XML_modified|NMSP_DCTERMS:
467 if ( aChars.getLength() >= 4 )
468 m_xDocProp->setModificationDate( GetDateTimeFromW3CDTF( aChars ) );
469 break;
471 case XML_revision|NMSP_COREPR:
474 m_xDocProp->setEditingCycles(
475 static_cast<sal_Int16>(aChars.toInt32()) );
477 catch (lang::IllegalArgumentException &)
479 // ignore
481 break;
483 case XML_subject|NMSP_DC:
484 m_xDocProp->setSubject( aChars );
485 break;
487 case XML_title|NMSP_DC:
488 m_xDocProp->setTitle( aChars );
489 break;
491 default:
492 OSL_ASSERT( "Unexpected core property!" );
495 else if ( m_nState == ( XML_Properties|NMSP_EXTPR ) )
497 switch( m_nBlock )
499 case XML_Application|NMSP_EXTPR:
500 m_xDocProp->setGenerator( aChars );
501 break;
503 case XML_Template|NMSP_EXTPR:
504 m_xDocProp->setTemplateName( aChars );
505 break;
507 case XML_TotalTime|NMSP_EXTPR:
510 m_xDocProp->setEditingDuration( aChars.toInt32() );
512 catch (lang::IllegalArgumentException &)
514 // ignore
516 break;
518 case XML_Characters|NMSP_EXTPR:
519 case XML_Pages|NMSP_EXTPR:
520 case XML_Words|NMSP_EXTPR:
521 case XML_Paragraphs|NMSP_EXTPR:
522 UpdateDocStatistic( aChars );
523 break;
525 case XML_HyperlinksChanged|NMSP_EXTPR:
526 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HyperlinksChanged" ) );
527 AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
528 break;
530 case XML_LinksUpToDate|NMSP_EXTPR:
531 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "LinksUpToDate" ) );
532 AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
533 break;
535 case XML_ScaleCrop|NMSP_EXTPR:
536 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ScaleCrop" ) );
537 AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
538 break;
540 case XML_SharedDoc|NMSP_EXTPR:
541 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "ShareDoc" ) );
542 AddCustomProperty( uno::makeAny( aChars.toBoolean() ) ); // the property has boolean type
543 break;
545 case XML_DocSecurity|NMSP_EXTPR:
546 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DocSecurity" ) );
547 AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
548 break;
550 case XML_HiddenSlides|NMSP_EXTPR:
551 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HiddenSlides" ) );
552 AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
553 break;
555 case XML_MMClips|NMSP_EXTPR:
556 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "MMClips" ) );
557 AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
558 break;
560 case XML_Notes|NMSP_EXTPR:
561 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Notes" ) );
562 AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
563 break;
565 case XML_Slides|NMSP_EXTPR:
566 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Slides" ) );
567 AddCustomProperty( uno::makeAny( aChars.toInt32() ) ); // the property has sal_Int32 type
568 break;
570 case XML_AppVersion|NMSP_EXTPR:
571 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "AppVersion" ) );
572 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
573 break;
575 case XML_Company|NMSP_EXTPR:
576 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Company" ) );
577 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
578 break;
580 case XML_HyperlinkBase|NMSP_EXTPR:
581 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "HyperlinkBase" ) );
582 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
583 break;
585 case XML_Manager|NMSP_EXTPR:
586 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Manager" ) );
587 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
588 break;
590 case XML_PresentationFormat|NMSP_EXTPR:
591 m_aCustomPropertyName = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "PresentationFormat" ) );
592 AddCustomProperty( uno::makeAny( aChars ) ); // the property has string type
593 break;
595 case XML_CharactersWithSpaces|NMSP_EXTPR:
596 case XML_Lines|NMSP_EXTPR:
597 case XML_DigSig|NMSP_EXTPR:
598 case XML_HeadingPairs|NMSP_EXTPR:
599 case XML_HLinks|NMSP_EXTPR:
600 case XML_TitlesOfParts|NMSP_EXTPR:
601 // ignored during the import currently
602 break;
604 default:
605 OSL_ASSERT( "Unexpected extended property!" );
608 else if ( m_nState == ( XML_Properties|NMSP_CUSTPR ) )
610 if ( m_nBlock == ( XML_property|NMSP_CUSTPR ) )
612 // this is a custom property
613 switch( m_nType )
615 case XML_bool|NMSP_VT:
616 AddCustomProperty( uno::makeAny( aChars.toBoolean() ) );
617 break;
619 case XML_bstr|NMSP_VT:
620 case XML_lpstr|NMSP_VT:
621 case XML_lpwstr|NMSP_VT:
622 AddCustomProperty( uno::makeAny( AttributeList::decodeXString( aChars ) ) ); // the property has string type
623 break;
625 case XML_date|NMSP_VT:
626 case XML_filetime|NMSP_VT:
627 AddCustomProperty( uno::makeAny( GetDateTimeFromW3CDTF( aChars ) ) );
629 case XML_i1|NMSP_VT:
630 case XML_i2|NMSP_VT:
631 AddCustomProperty( uno::makeAny( (sal_Int16)aChars.toInt32() ) );
632 break;
634 case XML_i4|NMSP_VT:
635 case XML_int|NMSP_VT:
636 AddCustomProperty( uno::makeAny( aChars.toInt32() ) );
637 break;
639 case XML_i8|NMSP_VT:
640 AddCustomProperty( uno::makeAny( aChars.toInt64() ) );
641 break;
643 case XML_r4|NMSP_VT:
644 AddCustomProperty( uno::makeAny( aChars.toFloat() ) );
645 break;
647 case XML_r8|NMSP_VT:
648 AddCustomProperty( uno::makeAny( aChars.toDouble() ) );
649 break;
651 default:
652 // all the other types are ignored;
653 break;
656 else
658 OSL_ASSERT( "Unexpected tag in custom property!" );
663 catch( uno::RuntimeException& )
665 throw;
667 catch( xml::sax::SAXException& )
669 throw;
671 catch( uno::Exception& e )
673 throw xml::sax::SAXException(
674 ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Error while setting document property!" ) ),
675 uno::Reference< uno::XInterface >(),
676 uno::makeAny( e ) );
680 // ------------------------------------------------
681 void SAL_CALL OOXMLDocPropHandler::ignorableWhitespace( const ::rtl::OUString& )
682 throw (xml::sax::SAXException, uno::RuntimeException)
686 // ------------------------------------------------
687 void SAL_CALL OOXMLDocPropHandler::processingInstruction( const ::rtl::OUString&, const ::rtl::OUString& )
688 throw (xml::sax::SAXException, uno::RuntimeException)
692 } // namespace docprop
693 } // namespace oox