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>
24 #include <xmloff/xmlnamespace.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 
40 namespace 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 
48 OXMLRowColumn::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 
74 css::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  {
85  xContext = new OXMLRowColumn( rImport,xAttrList,m_pContainer);
86  break;
90  xContext = new OXMLRowColumn( rImport,xAttrList,m_pContainer);
91  break;
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 
108 void 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  {OUString(), 0, css::uno::Type(), 0, 0 }
124  };
125  pInfo->add(pMap);
127  XMLPropStyleContext* pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext*>(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_COLUMN,_sStyleName)));
128  if ( pAutoStyle )
129  {
130  pAutoStyle->FillPropertySet(xProp);
131  sal_Int32 nWidth = 0;
132  xProp->getPropertyValue(PROPERTY_WIDTH) >>= nWidth;
133  m_pContainer->addWidth(nWidth);
134  }
135  else
136  {
137  pAutoStyle = const_cast<XMLPropStyleContext*>(dynamic_cast< const XMLPropStyleContext* >(pAutoStyles->FindStyleChildContext(XmlStyleFamily::TABLE_ROW,_sStyleName)));
138  if ( pAutoStyle )
139  {
140  pAutoStyle->FillPropertySet(xProp);
141  sal_Int32 nHeight = 0;
142  sal_Int32 nMinHeight = 0;
143  xProp->getPropertyValue(PROPERTY_HEIGHT) >>= nHeight;
144  xProp->getPropertyValue(PROPERTY_MINHEIGHT) >>= nMinHeight;
145  if (nHeight == 0 && nMinHeight > 0)
146  {
147  m_pContainer->addHeight(nMinHeight);
149  }
150  else
151  {
152  m_pContainer->addHeight(nHeight);
153  m_pContainer->addAutoHeight(false);
154  }
155  }
156  }
157 }
158 
160 {
161  return static_cast<ORptFilter&>(GetImport());
162 }
163 
164 } // namespace rptxml
165 
166 
167 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void addHeight(sal_Int32 _nHeight)
Definition: xmlTable.hxx:70
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
void addWidth(sal_Int32 _nWidth)
Definition: xmlTable.hxx:72
ORptFilter & GetOwnImport()
Definition: xmlColumn.cxx:159
SvXMLImport & GetImport()
FastAttributeList & castToFastAttributeList(const css::uno::Reference< css::xml::sax::XFastAttributeList > &xAttrList)
XML_TABLE_CELL
void incrementRowIndex()
Definition: xmlTable.cxx:279
#define PROPERTY_WIDTH
Definition: strings.hxx:73
#define XMLOFF_WARN_UNKNOWN(area, rIter)
void Increment(sal_Int32 nInc=1)
XML_TABLE_ROW
void incrementColumnIndex()
Definition: xmlTable.hxx:78
#define PROPERTY_ID_MINHEIGHT
Definition: xmlColumn.cxx:38
virtual void FillPropertySet(const css::uno::Reference< css::beans::XPropertySet > &rPropSet)
COMPHELPER_DLLPUBLIC css::uno::Reference< css::beans::XPropertySet > GenericPropertySet_CreateInstance(PropertySetInfo *pInfo)
virtual ~OXMLRowColumn() override
Definition: xmlColumn.cxx:70
OXMLRowColumn(const OXMLRowColumn &)=delete
ProgressBarHelper * GetProgressBarHelper()
css::uno::Type const & get()
#define PROPERTY_MINHEIGHT
Definition: strings.hxx:77
XML_COVERED_TABLE_CELL
XML_TABLE_COLUMN
void fillStyle(const OUString &_sStyleName)
Definition: xmlColumn.cxx:108
OXMLTable * m_pContainer
Definition: xmlColumn.hxx:30
void addAutoHeight(bool _bAutoHeight)
Definition: xmlTable.hxx:71
#define XML_ELEMENT(prefix, name)
#define PROPERTY_HEIGHT
Definition: strings.hxx:37
#define PROGRESS_BAR_STEP
Definition: xmlEnums.hxx:22
XML_STYLE_NAME
#define PROPERTY_ID_WIDTH
Definition: xmlColumn.cxx:36
TABLE
void addCell(const css::uno::Reference< css::report::XReportComponent > &_xElement)
Definition: xmlTable.cxx:255
const SvXMLStyleContext * FindStyleChildContext(XmlStyleFamily nFamily, const OUString &rName, bool bCreateIndex=false) const
#define PROPERTY_ID_HEIGHT
Definition: xmlColumn.cxx:37
SvXMLStylesContext * GetAutoStyles()