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;
39using ::com::sun::star::xml::sax::XAttributeList;
40
41
43 SvXMLImport& rImport,
44 XMLIndexTemplateContext& rTemplate ) :
45 XMLIndexSimpleEntryContext(rImport, "TokenTabStop",
46 rTemplate),
47 nTabPosition(0),
48 bTabPositionOK(false),
49 bTabRightAligned(false),
50 bLeaderCharOK(false),
51 bWithTab(true) // #i21237#
52{
53}
54
56{
57}
58
60 sal_Int32 nElement,
61 const css::uno::Reference< css::xml::sax::XFastAttributeList >& xAttrList )
62{
63 // process three attributes: type, position, leader char
64 for( auto& aIter : sax_fastparser::castToFastAttributeList(xAttrList) )
65 {
66 switch(aIter.getToken())
67 {
69 {
70 // if it's neither left nor right, value is
71 // ignored. Since left is default, we only need to
72 // check for right
74 break;
75 }
77 {
78 sal_Int32 nTmp;
79 if (GetImport().GetMM100UnitConverter().
80 convertMeasureToCore(nTmp, aIter.toView()))
81 {
82 nTabPosition = nTmp;
83 bTabPositionOK = true;
84 }
85 break;
86 }
88 {
89 sLeaderChar = aIter.toString();
90 // valid only, if we have a char!
91 bLeaderCharOK = !sLeaderChar.isEmpty();
92 break;
93 }
95 {
96 // #i21237#
97 bool bTmp(false);
98 if (::sax::Converter::convertBool(bTmp, aIter.toView()))
99 bWithTab = bTmp;
100 break;
101 }
102 default:
103 XMLOFF_WARN_UNKNOWN("xmloff", aIter);
104 // else: unknown style: attribute -> ignore
105 }
106 }
107
108 // how many entries? #i21237#
109 m_nValues += 2 + (bTabPositionOK ? 1 : 0) + (bLeaderCharOK ? 1 : 0);
110
111 // now try parent class (for character style)
113}
114
116 Sequence<PropertyValue> & rValues)
117{
118 // fill values from parent class (type + style name)
120
121 // get values array and next entry to be written;
122 sal_Int32 nNextEntry = m_bCharStyleNameOK ? 2 : 1;
123 PropertyValue* pValues = rValues.getArray();
124
125 // right aligned?
126 pValues[nNextEntry].Name = "TabStopRightAligned";
127 pValues[nNextEntry].Value <<= bTabRightAligned;
128 nNextEntry++;
129
130 // position
131 if (bTabPositionOK)
132 {
133 pValues[nNextEntry].Name = "TabStopPosition";
134 pValues[nNextEntry].Value <<= nTabPosition;
135 nNextEntry++;
136 }
137
138 // leader char
139 if (bLeaderCharOK)
140 {
141 pValues[nNextEntry].Name = "TabStopFillCharacter";
142 pValues[nNextEntry].Value <<= sLeaderChar;
143 nNextEntry++;
144 }
145
146 // tab character #i21237#
147 pValues[nNextEntry].Name = "WithTab";
148 pValues[nNextEntry].Value <<= bWithTab;
149 nNextEntry++;
150
151 // check whether we really filled all elements of the sequence
152 SAL_WARN_IF( nNextEntry != rValues.getLength(), "xmloff",
153 "length incorrectly precomputed!" );
154}
155
156/* 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:3573
#define XMLOFF_WARN_UNKNOWN(area, rIter)
Definition: xmlictxt.hxx:114
#define XML_ELEMENT(prefix, name)
Definition: xmlimp.hxx:97