1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_xmloff.hxx"
26 #include "durationhdl.hxx"
27 #include <com/sun/star/uno/Any.hxx>
28 #include <com/sun/star/util/DateTime.hpp>
29 #include <rtl/ustrbuf.hxx>
30 #include <xmloff/xmluconv.hxx>
31 
32 using ::rtl::OUString;
33 using ::rtl::OUStringBuffer;
34 
35 using namespace ::com::sun::star::uno;
36 using namespace ::com::sun::star::util;
37 
38 // ---------------------------------------------------------------------------
39 
40 
importXML(const OUString & rStrImpValue,Any & rValue,const SvXMLUnitConverter &) const41 sal_Bool XMLDurationMS16PropHdl_Impl::importXML(
42 		const OUString& rStrImpValue,
43 	   	Any& rValue,
44 		const SvXMLUnitConverter& ) const
45 {
46 	DateTime aTime;
47 	if( !SvXMLUnitConverter::convertTime( aTime,  rStrImpValue ) )
48 		return false;
49 
50 	const sal_Int16 nMS = ( ( aTime.Hours * 60 + aTime.Minutes ) * 60 + aTime.Seconds ) * 100 + aTime.HundredthSeconds;
51 	rValue <<= nMS;
52 
53 	return sal_True;
54 }
55 
exportXML(OUString & rStrExpValue,const Any & rValue,const SvXMLUnitConverter &) const56 sal_Bool XMLDurationMS16PropHdl_Impl::exportXML(
57 		OUString& rStrExpValue,
58 		const Any& rValue,
59 		const SvXMLUnitConverter& ) const
60 {
61 	sal_Int16 nMS = sal_Int16();
62 
63 	if(rValue >>= nMS)
64 	{
65 		OUStringBuffer aOut;
66 		DateTime aTime( nMS, 0, 0, 0, 0, 0, 0 );
67 		SvXMLUnitConverter::convertTime( aOut, aTime );
68 		rStrExpValue = aOut.makeStringAndClear();
69 		return sal_True;
70 	}
71 
72 	return sal_False;
73 }
74 
~XMLDurationMS16PropHdl_Impl()75 XMLDurationMS16PropHdl_Impl::~XMLDurationMS16PropHdl_Impl()
76 {
77 }
78