Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : :
30 : : #include <com/sun/star/style/TabStop.hpp>
31 : : #include <com/sun/star/style/TabAlign.hpp>
32 : : #include <rtl/ustrbuf.hxx>
33 : : #include <xmloff/nmspmap.hxx>
34 : : #include "xmloff/xmlnmspe.hxx"
35 : : #include <xmloff/xmltoken.hxx>
36 : : #include <xmloff/xmluconv.hxx>
37 : : #include <xmloff/xmlexp.hxx>
38 : : #include "xmloff/xmltabe.hxx"
39 : :
40 : : using ::rtl::OUString;
41 : : using ::rtl::OUStringBuffer;
42 : :
43 : : using namespace ::com::sun::star;
44 : : using namespace ::xmloff::token;
45 : :
46 : : SvXMLEnumMapEntry pXML_tabstop_style[] =
47 : : {
48 : : { XML_LEFT, style::TabAlign_LEFT },
49 : : { XML_CENTER, style::TabAlign_CENTER },
50 : : { XML_RIGHT, style::TabAlign_RIGHT },
51 : : { XML_CHAR, style::TabAlign_DECIMAL },
52 : : { XML_DEFAULT, style::TabAlign_DEFAULT }, // ?????????????????????????????????????
53 : : { XML_TOKEN_INVALID, 0 }
54 : : };
55 : :
56 : 0 : void SvxXMLTabStopExport::exportTabStop( const ::com::sun::star::style::TabStop* pTabStop )
57 : : {
58 : 0 : SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter();
59 : :
60 : : // text:level
61 : 0 : OUStringBuffer sBuffer;
62 : :
63 : : // position attribute
64 [ # # ]: 0 : rUnitConv.convertMeasureToXML( sBuffer, pTabStop->Position );
65 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION,
66 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
67 : :
68 : : // type attribute
69 [ # # ]: 0 : if( style::TabAlign_LEFT != pTabStop->Alignment )
70 : : {
71 : : rUnitConv.convertEnum( sBuffer, pTabStop->Alignment,
72 [ # # ]: 0 : pXML_tabstop_style );
73 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_TYPE,
74 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
75 : : }
76 : :
77 : : // char
78 [ # # ][ # # ]: 0 : if( style::TabAlign_DECIMAL == pTabStop->Alignment &&
79 : : pTabStop->DecimalChar != 0 )
80 : : {
81 [ # # ]: 0 : sBuffer.append( pTabStop->DecimalChar );
82 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_CHAR,
83 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
84 : : }
85 : :
86 : : // leader-char
87 [ # # ][ # # ]: 0 : if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar )
88 : : {
89 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_STYLE,
90 : : GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED
91 [ # # ][ # # ]: 0 : : XML_SOLID) );
[ # # ]
92 : :
93 [ # # ]: 0 : sBuffer.append( pTabStop->FillChar );
94 : : rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_TEXT,
95 [ # # ][ # # ]: 0 : sBuffer.makeStringAndClear() );
96 : : }
97 : :
98 : : SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOP,
99 [ # # ][ # # ]: 0 : sal_True, sal_True );
100 : 0 : }
101 : :
102 : :
103 : 753 : SvxXMLTabStopExport::SvxXMLTabStopExport(
104 : : SvXMLExport& rExp)
105 : 753 : : rExport( rExp )
106 : : {
107 : 753 : }
108 : :
109 : 743 : SvxXMLTabStopExport::~SvxXMLTabStopExport()
110 : : {
111 [ - + ]: 743 : }
112 : :
113 : 33 : void SvxXMLTabStopExport::Export( const uno::Any& rAny )
114 : : {
115 [ + - ]: 33 : uno::Sequence< ::com::sun::star::style::TabStop> aSeq;
116 [ + - ][ + - ]: 33 : if(!(rAny >>= aSeq))
117 : : {
118 : : OSL_FAIL( "SvxXMLTabStopExport needs a Sequence ::com::sun::star::style::TabStop>" );
119 : : }
120 : : else
121 : : {
122 : 33 : const ::com::sun::star::style::TabStop* pTabs = aSeq.getConstArray();
123 : 33 : const sal_Int32 nTabs = aSeq.getLength();
124 : :
125 : : SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS,
126 [ + - ]: 33 : sal_True, sal_True );
127 : :
128 [ + + ]: 54 : for( sal_Int32 nIndex = 0; nIndex < nTabs; nIndex++ )
129 : : {
130 [ - + ]: 21 : if( style::TabAlign_DEFAULT != pTabs[nIndex].Alignment )
131 [ # # ]: 0 : exportTabStop( &(pTabs[nIndex]) );
132 [ + - ]: 33 : }
133 [ + - ]: 33 : }
134 : 33 : }
135 : :
136 : :
137 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|