Line data Source code
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 : #include "xmlSubDocument.hxx"
20 : #include "xmlCell.hxx"
21 : #include "xmlfilter.hxx"
22 : #include <xmloff/xmltoken.hxx>
23 : #include <xmloff/xmlnmspe.hxx>
24 : #include <xmloff/nmspmap.hxx>
25 : #include "xmlEnums.hxx"
26 : #include "xmlMasterFields.hxx"
27 : #include "xmlTable.hxx"
28 : #include <tools/debug.hxx>
29 : #include <comphelper/property.hxx>
30 : #include <com/sun/star/report/XReportControlModel.hpp>
31 :
32 : namespace rptxml
33 : {
34 : using namespace ::com::sun::star;
35 : using namespace ::com::sun::star::report;
36 : using namespace ::com::sun::star::uno;
37 : using namespace ::com::sun::star::xml::sax;
38 :
39 0 : OXMLSubDocument::OXMLSubDocument( ORptFilter& rImport,
40 : sal_uInt16 nPrfx
41 : ,const OUString& rLName
42 : ,const Reference< XReportComponent > & _xComponent
43 : ,OXMLTable* _pContainer
44 : ,OXMLCell* _pCellParent) :
45 : OXMLReportElementBase( rImport, nPrfx, rLName,_xComponent.get(),_pContainer)
46 : ,m_xFake(_xComponent)
47 : ,m_pCellParent(_pCellParent)
48 : ,m_nCurrentCount(0)
49 0 : ,m_bContainsShape(false)
50 : {
51 :
52 0 : }
53 :
54 :
55 0 : OXMLSubDocument::~OXMLSubDocument()
56 : {
57 0 : }
58 :
59 :
60 0 : SvXMLImportContext* OXMLSubDocument::_CreateChildContext(
61 : sal_uInt16 _nPrefix,
62 : const OUString& _rLocalName,
63 : const Reference< XAttributeList > & xAttrList )
64 : {
65 0 : SvXMLImportContext *pContext = OXMLReportElementBase::_CreateChildContext(_nPrefix,_rLocalName,xAttrList);
66 0 : if ( pContext )
67 0 : return pContext;
68 0 : const SvXMLTokenMap& rTokenMap = static_cast<ORptFilter&>(GetImport()).GetReportElemTokenMap();
69 :
70 0 : switch( rTokenMap.Get( _nPrefix, _rLocalName ) )
71 : {
72 : case XML_TOK_MASTER_DETAIL_FIELDS:
73 : {
74 0 : GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
75 0 : pContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()), _nPrefix, _rLocalName,xAttrList ,this);
76 : }
77 0 : break;
78 : case XML_TOK_SUB_FRAME:
79 : {
80 0 : if ( !m_bContainsShape )
81 0 : m_nCurrentCount = m_pContainer->getSection()->getCount();
82 0 : rtl::Reference< XMLShapeImportHelper > xShapeImportHelper = GetImport().GetShapeImport();
83 0 : uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
84 0 : pContext = xShapeImportHelper->CreateGroupChildContext(GetImport(),_nPrefix,_rLocalName,xAttrList,xShapes);
85 0 : m_bContainsShape = true;
86 0 : if (m_pCellParent)
87 : {
88 : // #i94115 say to the parent Cell it contains shapes
89 0 : m_pCellParent->setContainsShape(true);
90 0 : }
91 : }
92 0 : break;
93 : default:
94 0 : break;
95 : }
96 :
97 0 : if( !pContext )
98 0 : pContext = new SvXMLImportContext( GetImport(), _nPrefix, _rLocalName );
99 :
100 0 : return pContext;
101 : }
102 :
103 0 : void OXMLSubDocument::EndElement()
104 : {
105 0 : if ( m_bContainsShape )
106 : {
107 0 : m_xComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY);
108 0 : if ( m_xComponent.is() )
109 : {
110 0 : if ( !m_aMasterFields.empty() )
111 0 : m_xComponent->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
112 0 : if ( !m_aDetailFields.empty() )
113 0 : m_xComponent->setDetailFields(Sequence< OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
114 :
115 0 : m_xComponent->setName(m_xFake->getName());
116 0 : m_xComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues());
117 0 : uno::Reference< report::XReportControlModel > xFakeModel(m_xFake,uno::UNO_QUERY);
118 0 : uno::Reference< report::XReportControlModel > xComponentModel(m_xComponent,uno::UNO_QUERY);
119 0 : if ( xComponentModel.is() && xFakeModel.is() )
120 : {
121 0 : xComponentModel->setPrintWhenGroupChange(xFakeModel->getPrintWhenGroupChange());
122 0 : const sal_Int32 nCount = xFakeModel->getCount();
123 : try
124 : {
125 0 : for (sal_Int32 i = 0; i < nCount ; ++i)
126 : {
127 0 : uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY);
128 0 : uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition();
129 0 : ::comphelper::copyProperties(xCond.get(),xNewCond.get());
130 0 : xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond));
131 0 : }
132 : }
133 0 : catch(uno::Exception&)
134 : {
135 : OSL_FAIL("Can not access format condition!");
136 : }
137 :
138 0 : }
139 : }
140 : }
141 0 : }
142 :
143 0 : void OXMLSubDocument::addMasterDetailPair(const ::std::pair< OUString,OUString >& _aPair)
144 : {
145 0 : m_aMasterFields.push_back(_aPair.first);
146 0 : m_aDetailFields.push_back(_aPair.second);
147 0 : }
148 :
149 : } // namespace rptxml
150 :
151 :
152 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|