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: adjushdl.cxx,v $
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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_xmloff.hxx"
33 #include <adjushdl.hxx>
34 #include <tools/solar.h>
35 #include <xmloff/xmltoken.hxx>
36 #include <xmloff/xmluconv.hxx>
37 #include <rtl/ustrbuf.hxx>
38 #include <com/sun/star/style/ParagraphAdjust.hpp>
39 #include <com/sun/star/uno/Any.hxx>
41 #ifndef _XMLOFF_XMLEMENT_HXX
42 #include <xmloff/xmlelement.hxx>
45 using namespace ::com::sun::star
;
46 using ::rtl::OUString
;
47 using ::rtl::OUStringBuffer
;
49 using namespace ::xmloff::token
;
51 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Adjust_Enum
[] =
53 { XML_START
, style::ParagraphAdjust_LEFT
},
54 { XML_END
, style::ParagraphAdjust_RIGHT
},
55 { XML_CENTER
, style::ParagraphAdjust_CENTER
},
56 { XML_JUSTIFY
, style::ParagraphAdjust_BLOCK
},
57 { XML_JUSTIFIED
, style::ParagraphAdjust_BLOCK
}, // obsolete
58 { XML_LEFT
, style::ParagraphAdjust_LEFT
},
59 { XML_RIGHT
, style::ParagraphAdjust_RIGHT
},
60 { XML_TOKEN_INVALID
, 0 }
63 SvXMLEnumMapEntry __READONLY_DATA pXML_Para_Align_Last_Enum
[] =
65 { XML_START
, style::ParagraphAdjust_LEFT
},
66 { XML_CENTER
, style::ParagraphAdjust_CENTER
},
67 { XML_JUSTIFY
, style::ParagraphAdjust_BLOCK
},
68 { XML_JUSTIFIED
, style::ParagraphAdjust_BLOCK
}, // obsolete
69 { XML_TOKEN_INVALID
, 0 }
72 ///////////////////////////////////////////////////////////////////////////////
74 // class XMLParaAdjustPropHdl
77 XMLParaAdjustPropHdl::~XMLParaAdjustPropHdl()
82 sal_Bool
XMLParaAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
85 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Adjust_Enum
);
87 rValue
<<= (sal_Int16
)eAdjust
;
92 sal_Bool
XMLParaAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
94 if(!rValue
.hasValue())
95 return sal_False
; //added by BerryJia for fixing Bug102407 2002-11-5
101 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( aOut
, nVal
, pXML_Para_Adjust_Enum
, XML_START
);
103 rStrExpValue
= aOut
.makeStringAndClear();
108 ///////////////////////////////////////////////////////////////////////////////
110 // class XMLLastLineAdjustPropHdl
113 XMLLastLineAdjustPropHdl::~XMLLastLineAdjustPropHdl()
118 sal_Bool
XMLLastLineAdjustPropHdl::importXML( const OUString
& rStrImpValue
, uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
121 sal_Bool bRet
= SvXMLUnitConverter::convertEnum( eAdjust
, rStrImpValue
, pXML_Para_Align_Last_Enum
);
123 rValue
<<= (sal_Int16
)eAdjust
;
128 sal_Bool
XMLLastLineAdjustPropHdl::exportXML( OUString
& rStrExpValue
, const uno::Any
& rValue
, const SvXMLUnitConverter
& ) const
132 sal_Bool bRet
= sal_False
;
136 if( nVal
!= style::ParagraphAdjust_LEFT
)
137 bRet
= SvXMLUnitConverter::convertEnum( aOut
, nVal
, pXML_Para_Align_Last_Enum
, XML_START
);
139 rStrExpValue
= aOut
.makeStringAndClear();