LibreOffice Module reportdesign (master) 1
xmlColumn.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#include "xmlColumn.hxx"
21#include <xmloff/xmluconv.hxx>
22#include "xmlfilter.hxx"
23#include <xmloff/xmltoken.hxx>
25#include <xmloff/xmlstyle.hxx>
26#include <xmloff/prstylei.hxx>
28#include "xmlEnums.hxx"
29#include "xmlCell.hxx"
30#include "xmlTable.hxx"
33#include <com/sun/star/beans/PropertyAttribute.hpp>
34#include <strings.hxx>
35
36#define PROPERTY_ID_WIDTH 1
37#define PROPERTY_ID_HEIGHT 2
38#define PROPERTY_ID_MINHEIGHT 3
39
40namespace rptxml
41{
42 using namespace ::comphelper;
43 using namespace ::com::sun::star::uno;
44 using namespace ::com::sun::star::beans;
45 using namespace ::com::sun::star::xml::sax;
46
47
48OXMLRowColumn::OXMLRowColumn( ORptFilter& rImport
49 ,const Reference< XFastAttributeList > & _xAttrList
50 ,OXMLTable* _pContainer
51 ) :
52 SvXMLImportContext( rImport )
53 ,m_pContainer(_pContainer)
54{
55 for (auto &aIter : sax_fastparser::castToFastAttributeList( _xAttrList ))
56 {
57 switch( aIter.getToken() )
58 {
60 fillStyle(aIter.toString());
61 break;
62 default:
63 XMLOFF_WARN_UNKNOWN("reportdesign", aIter);
64 break;
65 }
66 }
67}
68
69
71{
72}
73
74css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLRowColumn::createFastChildContext(
75 sal_Int32 nElement,
76 const Reference< XFastAttributeList > & xAttrList )
77{
78 css::uno::Reference< css::xml::sax::XFastContextHandler > xContext;
79 ORptFilter& rImport = GetOwnImport();
80
81 switch( nElement )
82 {
84 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
85 xContext = new OXMLRowColumn( rImport,xAttrList,m_pContainer);
86 break;
89 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
90 xContext = new OXMLRowColumn( rImport,xAttrList,m_pContainer);
91 break;
94 rImport.GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
95 xContext = new OXMLCell( rImport,xAttrList,m_pContainer);
96 break;
99 m_pContainer->addCell(nullptr);
100 break;
101 default:
102 break;
103 }
104
105 return xContext;
106}
107
108void OXMLRowColumn::fillStyle(const OUString& _sStyleName)
109{
110 if ( _sStyleName.isEmpty() )
111 return;
112
113 const SvXMLStylesContext* pAutoStyles = GetOwnImport().GetAutoStyles();
114 if ( !pAutoStyles )
115 return;
116
118 static PropertyMapEntry const pMap[] =
119 {
120 {OUString(PROPERTY_WIDTH), PROPERTY_ID_WIDTH, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0},
121 {OUString(PROPERTY_HEIGHT), PROPERTY_ID_HEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 },
122 {OUString(PROPERTY_MINHEIGHT), PROPERTY_ID_MINHEIGHT, ::cppu::UnoType<sal_Int32>::get() ,PropertyAttribute::BOUND,0 },
123 };
124 pInfo->add(pMap);
125 Reference<XPropertySet> xProp = GenericPropertySet_CreateInstance(pInfo.get());
126 XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext*>(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_COLUMN,_sStyleName)));
127 if ( pAutoStyle )
128 {
129 pAutoStyle->FillPropertySet(xProp);
130 sal_Int32 nWidth = 0;
131 xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth;
132 m_pContainer->addWidth(nWidth);
133 }
134 else
135 {
136 pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_ROW,_sStyleName)));
137 if ( pAutoStyle )
138 {
139 pAutoStyle->FillPropertySet(xProp);
140 sal_Int32 nHeight = 0;
141 sal_Int32 nMinHeight = 0;
142 xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight;
143 xProp->getPropertyValue(PROPERTY_MINHEIGHT) >>= nMinHeight;
144 if (nHeight == 0 && nMinHeight > 0)
145 {
146 m_pContainer->addHeight(nMinHeight);
148 }
149 else
150 {
151 m_pContainer->addHeight(nHeight);
153 }
154 }
155 }
156}
157
159{
160 return static_cast<ORptFilter&>(GetImport());
161}
162
163} // namespace rptxml
164
165
166/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SvXMLImport & GetImport()
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
css::uno::Type const & get()
virtual ~OXMLRowColumn() override
Definition: xmlColumn.cxx:70
OXMLTable * m_pContainer
Definition: xmlColumn.hxx:30
OXMLRowColumn(const OXMLRowColumn &)=delete
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList) override
Definition: xmlColumn.cxx:74
ORptFilter & GetOwnImport()
Definition: xmlColumn.cxx:158
void fillStyle(const OUString &_sStyleName)
Definition: xmlColumn.cxx:108
void addCell(const css::uno::Reference< css::report::XReportComponent > &_xElement)
Definition: xmlTable.cxx:256
void addWidth(sal_Int32 _nWidth)
Definition: xmlTable.hxx:72
void addHeight(sal_Int32 _nHeight)
Definition: xmlTable.hxx:70
void incrementRowIndex()
Definition: xmlTable.cxx:280
void addAutoHeight(bool _bAutoHeight)
Definition: xmlTable.hxx:71
void incrementColumnIndex()
Definition: xmlTable.hxx:78
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_TABLE_ROW
XML_COVERED_TABLE_CELL
XML_TABLE_COLUMN
XML_STYLE_NAME
XML_TABLE_CELL
constexpr OUStringLiteral PROPERTY_MINHEIGHT
Definition: strings.hxx:77
constexpr OUStringLiteral PROPERTY_HEIGHT
Definition: strings.hxx:37
constexpr OUStringLiteral PROPERTY_WIDTH
Definition: strings.hxx:73
#define PROPERTY_ID_WIDTH
Definition: xmlColumn.cxx:36
#define PROPERTY_ID_MINHEIGHT
Definition: xmlColumn.cxx:38
#define PROPERTY_ID_HEIGHT
Definition: xmlColumn.cxx:37
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:22
TABLE
#define XMLOFF_WARN_UNKNOWN(area, rIter)
#define XML_ELEMENT(prefix, name)