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: XMLTextColumnsExport.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 <tools/debug.hxx>
34 #include <rtl/ustrbuf.hxx>
37 #include <com/sun/star/text/XTextColumns.hpp>
38 #include <com/sun/star/text/TextColumn.hpp>
39 #include <com/sun/star/style/VerticalAlignment.hpp>
40 #include <com/sun/star/beans/XPropertySet.hpp>
43 #include <xmloff/xmltoken.hxx>
44 #include "xmlnmspe.hxx"
45 #include <xmloff/xmluconv.hxx>
46 #include <xmloff/xmlexp.hxx>
47 #include "XMLTextColumnsExport.hxx"
49 using namespace ::com::sun::star::style
;
50 using namespace ::com::sun::star::text
;
51 using namespace ::com::sun::star::uno
;
52 using namespace ::com::sun::star::beans
;
53 using ::rtl::OUString
;
54 using ::rtl::OUStringBuffer
;
55 using namespace ::xmloff::token
;
58 XMLTextColumnsExport::XMLTextColumnsExport( SvXMLExport
& rExp
) :
60 sSeparatorLineIsOn(RTL_CONSTASCII_USTRINGPARAM("SeparatorLineIsOn")),
61 sSeparatorLineWidth(RTL_CONSTASCII_USTRINGPARAM("SeparatorLineWidth")),
62 sSeparatorLineColor(RTL_CONSTASCII_USTRINGPARAM("SeparatorLineColor")),
63 sSeparatorLineRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("SeparatorLineRelativeHeight")),
64 sSeparatorLineVerticalAlignment(RTL_CONSTASCII_USTRINGPARAM("SeparatorLineVerticalAlignment")),
65 sIsAutomatic(RTL_CONSTASCII_USTRINGPARAM("IsAutomatic")),
66 sAutomaticDistance(RTL_CONSTASCII_USTRINGPARAM("AutomaticDistance"))
70 void XMLTextColumnsExport::exportXML( const Any
& rAny
)
72 Reference
< XTextColumns
> xColumns
;
75 Sequence
< TextColumn
> aColumns
= xColumns
->getColumns();
76 const TextColumn
*pColumns
= aColumns
.getArray();
77 sal_Int32 nCount
= aColumns
.getLength();
79 OUStringBuffer sValue
;
80 GetExport().GetMM100UnitConverter().convertNumber( sValue
, nCount
? nCount
: 1 );
81 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_COLUMN_COUNT
,
82 sValue
.makeStringAndClear() );
84 // handle 'automatic' columns
85 Reference
< XPropertySet
> xPropSet( xColumns
, UNO_QUERY
);
88 Any aAny
= xPropSet
->getPropertyValue( sIsAutomatic
);
89 if ( *(sal_Bool
*)aAny
.getValue() )
91 aAny
= xPropSet
->getPropertyValue( sAutomaticDistance
);
92 sal_Int32 nDistance
= 0;
94 OUStringBuffer aBuffer
;
95 GetExport().GetMM100UnitConverter().convertMeasure(
97 GetExport().AddAttribute( XML_NAMESPACE_FO
,
99 aBuffer
.makeStringAndClear() );
103 SvXMLElementExport
aElem( GetExport(), XML_NAMESPACE_STYLE
, XML_COLUMNS
,
104 sal_True
, sal_True
);
108 Any aAny
= xPropSet
->getPropertyValue( sSeparatorLineIsOn
);
109 if( *(sal_Bool
*)aAny
.getValue() )
112 aAny
= xPropSet
->getPropertyValue( sSeparatorLineWidth
);
113 sal_Int32 nWidth
= 0;
115 GetExport().GetMM100UnitConverter().convertMeasure( sValue
,
117 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_WIDTH
,
118 sValue
.makeStringAndClear() );
121 aAny
= xPropSet
->getPropertyValue( sSeparatorLineColor
);
122 sal_Int32 nColor
= 0;
124 GetExport().GetMM100UnitConverter().convertColor( sValue
,
126 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_COLOR
,
127 sValue
.makeStringAndClear() );
130 aAny
= xPropSet
->getPropertyValue( sSeparatorLineRelativeHeight
);
131 sal_Int8 nHeight
= 0;
133 GetExport().GetMM100UnitConverter().convertPercent( sValue
,
135 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_HEIGHT
,
136 sValue
.makeStringAndClear() );
138 // style:vertical-align
139 aAny
= xPropSet
->getPropertyValue( sSeparatorLineVerticalAlignment
);
140 VerticalAlignment eVertAlign
;
143 enum XMLTokenEnum eStr
= XML_TOKEN_INVALID
;
146 // case VerticalAlignment_TOP: eStr = XML_TOP;
147 case VerticalAlignment_MIDDLE
: eStr
= XML_MIDDLE
; break;
148 case VerticalAlignment_BOTTOM
: eStr
= XML_BOTTOM
; break;
153 if( eStr
!= XML_TOKEN_INVALID
)
154 GetExport().AddAttribute( XML_NAMESPACE_STYLE
,
155 XML_VERTICAL_ALIGN
, eStr
);
158 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
,
160 sal_True
, sal_True
);
167 GetExport().GetMM100UnitConverter().convertNumber( sValue
,
169 sValue
.append( (sal_Unicode
)'*' );
170 GetExport().AddAttribute( XML_NAMESPACE_STYLE
, XML_REL_WIDTH
,
171 sValue
.makeStringAndClear() );
174 GetExport().GetMM100UnitConverter().convertMeasure( sValue
,
175 pColumns
->LeftMargin
);
176 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_START_INDENT
,
177 sValue
.makeStringAndClear() );
180 GetExport().GetMM100UnitConverter().convertMeasure( sValue
,
181 pColumns
->RightMargin
);
182 GetExport().AddAttribute( XML_NAMESPACE_FO
, XML_END_INDENT
,
183 sValue
.makeStringAndClear() );
186 SvXMLElementExport
aElement( GetExport(), XML_NAMESPACE_STYLE
, XML_COLUMN
,
187 sal_True
, sal_True
);