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