/src/libreoffice/xmloff/source/style/xmltabe.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | |
21 | | #include <com/sun/star/style/TabStop.hpp> |
22 | | #include <com/sun/star/style/TabAlign.hpp> |
23 | | #include <rtl/ustrbuf.hxx> |
24 | | #include <osl/diagnose.h> |
25 | | #include <xmloff/xmlement.hxx> |
26 | | #include <xmloff/xmlnamespace.hxx> |
27 | | #include <xmloff/xmltoken.hxx> |
28 | | #include <xmloff/xmluconv.hxx> |
29 | | #include <xmloff/xmlexp.hxx> |
30 | | #include <xmltabe.hxx> |
31 | | |
32 | | |
33 | | using namespace ::com::sun::star; |
34 | | using namespace ::xmloff::token; |
35 | | |
36 | | SvXMLEnumMapEntry<style::TabAlign> const pXML_tabstop_style[] = |
37 | | { |
38 | | { XML_LEFT, style::TabAlign_LEFT }, |
39 | | { XML_CENTER, style::TabAlign_CENTER }, |
40 | | { XML_RIGHT, style::TabAlign_RIGHT }, |
41 | | { XML_CHAR, style::TabAlign_DECIMAL }, |
42 | | { XML_DEFAULT, style::TabAlign_DEFAULT }, // ????????????????????????????????????? |
43 | | { XML_TOKEN_INVALID, style::TabAlign(0) } |
44 | | }; |
45 | | |
46 | | void SvxXMLTabStopExport::exportTabStop( const css::style::TabStop* pTabStop ) |
47 | 0 | { |
48 | 0 | SvXMLUnitConverter& rUnitConv = rExport.GetMM100UnitConverter(); |
49 | | |
50 | | // text:level |
51 | 0 | OUStringBuffer sBuffer; |
52 | | |
53 | | // position attribute |
54 | 0 | rUnitConv.convertMeasureToXML( sBuffer, pTabStop->Position ); |
55 | 0 | rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_POSITION, |
56 | 0 | sBuffer.makeStringAndClear() ); |
57 | | |
58 | | // type attribute |
59 | 0 | if( style::TabAlign_LEFT != pTabStop->Alignment ) |
60 | 0 | { |
61 | 0 | SvXMLUnitConverter::convertEnum( sBuffer, pTabStop->Alignment, |
62 | 0 | pXML_tabstop_style ); |
63 | 0 | rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_TYPE, |
64 | 0 | sBuffer.makeStringAndClear() ); |
65 | 0 | } |
66 | | |
67 | | // char |
68 | 0 | if( style::TabAlign_DECIMAL == pTabStop->Alignment && |
69 | 0 | pTabStop->DecimalChar != 0 ) |
70 | 0 | { |
71 | 0 | sBuffer.append( pTabStop->DecimalChar ); |
72 | 0 | rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_CHAR, |
73 | 0 | sBuffer.makeStringAndClear() ); |
74 | 0 | } |
75 | | |
76 | | // leader-char |
77 | 0 | if( ' ' != pTabStop->FillChar && 0 != pTabStop->FillChar ) |
78 | 0 | { |
79 | 0 | rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_STYLE, |
80 | 0 | GetXMLToken('.' == pTabStop->FillChar ? XML_DOTTED |
81 | 0 | : XML_SOLID) ); |
82 | |
|
83 | 0 | sBuffer.append( pTabStop->FillChar ); |
84 | 0 | rExport.AddAttribute( XML_NAMESPACE_STYLE, XML_LEADER_TEXT, |
85 | 0 | sBuffer.makeStringAndClear() ); |
86 | 0 | } |
87 | |
|
88 | 0 | SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOP, |
89 | 0 | true, true ); |
90 | 0 | } |
91 | | |
92 | | |
93 | | SvxXMLTabStopExport::SvxXMLTabStopExport( |
94 | | SvXMLExport& rExp) |
95 | 0 | : rExport( rExp ) |
96 | 0 | { |
97 | 0 | } |
98 | | |
99 | | void SvxXMLTabStopExport::Export( const uno::Any& rAny ) |
100 | 0 | { |
101 | 0 | uno::Sequence< css::style::TabStop> aSeq; |
102 | 0 | if(!(rAny >>= aSeq)) |
103 | 0 | { |
104 | 0 | OSL_FAIL( "SvxXMLTabStopExport needs a Sequence css::style::TabStop>" ); |
105 | 0 | } |
106 | 0 | else |
107 | 0 | { |
108 | 0 | SvXMLElementExport rElem( rExport, XML_NAMESPACE_STYLE, XML_TAB_STOPS, |
109 | 0 | true, true ); |
110 | |
|
111 | 0 | for (const auto& rTab : aSeq) |
112 | 0 | { |
113 | 0 | if( style::TabAlign_DEFAULT != rTab.Alignment ) |
114 | 0 | exportTabStop( &rTab ); |
115 | 0 | } |
116 | 0 | } |
117 | 0 | } |
118 | | |
119 | | |
120 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |