LibreOffice Module xmloff (master) 1
XMLIndexTabStopEntryContext.cxx
Go to the documentation of this file.
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
22
24
26#include <xmloff/xmlimp.hxx>
29#include <xmloff/xmltoken.hxx>
30#include <xmloff/xmluconv.hxx>
31#include <rtl/ustring.hxx>
32#include <sal/log.hxx>
33
34using namespace ::xmloff::token;
35
36using ::com::sun::star::uno::Sequence;
37using ::com::sun::star::uno::Reference;
38using ::com::sun::star::beans::PropertyValue;
39
40
42 SvXMLImport& rImport,
43 XMLIndexTemplateContext& rTemplate ) :
44 XMLIndexSimpleEntryContext(rImport, "TokenTabStop",
45 rTemplate),
46 nTabPosition(0),
47 bTabPositionOK(false),
48 bTabRightAligned(false),
49 bLeaderCharOK(false),
50 bWithTab(true) // #i21237#
51{
52}
53
55{
56}
57
59 sal_Int32 nElement,
60 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
61{
62 // process three attributes: type, position, leader char
63 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
64 {
65 switch(aIter.getToken())
66 {
68 {
69 // if it's neither left nor right, value is
70 // ignored. Since left is default, we only need to
71 // check for right
73 break;
74 }
76 {
77 sal_Int32 nTmp;
78 if (GetImport().GetMM100UnitConverter().
79 convertMeasureToCore(nTmp, aIter.toView()))
80 {
81 nTabPosition = nTmp;
82 bTabPositionOK = true;
83 }
84 break;
85 }
87 {
88 sLeaderChar = aIter.toString();
89 // valid only, if we have a char!
90 bLeaderCharOK = !sLeaderChar.isEmpty();
91 break;
92 }
94 {
95 // #i21237#
96 bool bTmp(false);
97 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
98 bWithTab = bTmp;
99 break;
100 }
101 default:
102 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
103 // else: unknown style: attribute -> ignore
104 }
105 }
106
107 // how many entries? #i21237#
108 m_nValues += 2 + (bTabPositionOK ? 1 : 0) + (bLeaderCharOK ? 1 : 0);
109
110 // now try parent class (for character style)
112}
113
115 Sequence<PropertyValue> & rValues)
116{
117 // fill values from parent class (type + style name)
119
120 // get values array and next entry to be written;
121 sal_Int32 nNextEntry = m_bCharStyleNameOK ? 2 : 1;
122 PropertyValue* pValues = rValues.getArray();
123
124 // right aligned?
125 pValues[nNextEntry].Name = "TabStopRightAligned";
126 pValues[nNextEntry].Value <<= bTabRightAligned;
127 nNextEntry++;
128
129 // position
130 if (bTabPositionOK)
131 {
132 pValues[nNextEntry].Name = "TabStopPosition";
133 pValues[nNextEntry].Value <<= nTabPosition;
134 nNextEntry++;
135 }
136
137 // leader char
138 if (bLeaderCharOK)
139 {
140 pValues[nNextEntry].Name = "TabStopFillCharacter";
141 pValues[nNextEntry].Value <<= sLeaderChar;
142 nNextEntry++;
143 }
144
145 // tab character #i21237#
146 pValues[nNextEntry].Name = "WithTab";
147 pValues[nNextEntry].Value <<= bWithTab;
148 nNextEntry++;
149
150 // check whether we really filled all elements of the sequence
151 SAL_WARN_IF( nNextEntry != rValues.getLength(), "xmloff",
152 "length incorrectly precomputed!" );
153}
154
155/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
SvXMLImport & GetImport()
Definition: xmlictxt.hxx:60
Import index entry templates.
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
process parameters
virtual void FillPropertyValues(css::uno::Sequence< css::beans::PropertyValue > &rValues)
fill property values for this template entry
sal_Int32 nTabPosition
fill ("leader") character
virtual void FillPropertyValues(css::uno::Sequence< css::beans::PropertyValue > &rValues) override
fill property values for this template entry
bool bTabRightAligned
is tab right aligned?
XMLIndexTabStopEntryContext(SvXMLImport &rImport, XMLIndexTemplateContext &rTemplate)
is tab char present? #i21237#
bool bLeaderCharOK
is nTabPosition valid?
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
process parameters
Import index entry templates.
static bool convertBool(bool &rBool, std::u16string_view rString)
#define SAL_WARN_IF(condition, area, stream)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
Handling of tokens in XML:
bool IsXMLToken(std::u16string_view rString, enum XMLTokenEnum eToken)
compare eToken to the string
Definition: xmltoken.cxx:3597
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97