1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#include "xmlSubDocument.hxx"
#include "xmlCell.hxx"
#include "xmlfilter.hxx"
#include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnmspe.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/ProgressBarHelper.hxx>
#include "xmlEnums.hxx"
#include "xmlMasterFields.hxx"
#include "xmlTable.hxx"
#include <comphelper/property.hxx>
#include <com/sun/star/report/XReportControlModel.hpp>
#include <osl/diagnose.h>
namespace rptxml
{
using namespace ::com::sun::star;
using namespace ::com::sun::star::report;
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::xml::sax;
OXMLSubDocument::OXMLSubDocument( ORptFilter& rImport
,const Reference< XReportComponent > & _xComponent
,OXMLTable* _pContainer
,OXMLCell* _pCellParent) :
OXMLReportElementBase( rImport,_xComponent.get(),_pContainer)
,m_xFake(_xComponent)
,m_pCellParent(_pCellParent)
,m_nCurrentCount(0)
,m_bContainsShape(false)
{
}
OXMLSubDocument::~OXMLSubDocument()
{
}
SvXMLImportContextRef OXMLSubDocument::CreateChildContext( sal_uInt16 nPrefix,
const OUString& rLocalName,
const css::uno::Reference< css::xml::sax::XAttributeList > & xAttrList )
{
SvXMLImportContextRef xContext;
const SvXMLTokenMap& rTokenMap = static_cast<ORptFilter&>(GetImport()).GetReportElemTokenMap();
switch( rTokenMap.Get( nPrefix, rLocalName ) )
{
case XML_TOK_SUB_FRAME:
{
if ( !m_bContainsShape )
m_nCurrentCount = m_pContainer->getSection()->getCount();
rtl::Reference< XMLShapeImportHelper > xShapeImportHelper = GetImport().GetShapeImport();
uno::Reference< drawing::XShapes > xShapes = m_pContainer->getSection().get();
xContext = xShapeImportHelper->CreateGroupChildContext(GetImport(),nPrefix,rLocalName,xAttrList,xShapes);
m_bContainsShape = true;
if (m_pCellParent)
{
// #i94115 say to the parent Cell it contains shapes
m_pCellParent->setContainsShape(true);
}
}
break;
}
return xContext;
}
css::uno::Reference< css::xml::sax::XFastContextHandler > OXMLSubDocument::createFastChildContext(
sal_Int32 nElement,
const Reference< XFastAttributeList > & xAttrList )
{
css::uno::Reference< css::xml::sax::XFastContextHandler > xContext = OXMLReportElementBase::createFastChildContext(nElement,xAttrList);
if (xContext)
return xContext;
switch( nElement )
{
case XML_ELEMENT(REPORT, XML_MASTER_DETAIL_FIELDS):
{
GetImport().GetProgressBarHelper()->Increment( PROGRESS_BAR_STEP );
xContext = new OXMLMasterFields(static_cast<ORptFilter&>(GetImport()),xAttrList ,this);
}
break;
// FIXME: is it *intentional* that this is supported?
// ORptExport::exportContainer() can export this but the import
// used to be rather accidental previously
case XML_ELEMENT(OFFICE, XML_BODY):
xContext = new RptXMLDocumentBodyContext(GetImport());
break;
default:
break;
}
return xContext;
}
void OXMLSubDocument::endFastElement(sal_Int32 )
{
if ( !m_bContainsShape )
return;
m_xReportComponent.set(m_pContainer->getSection()->getByIndex(m_nCurrentCount),uno::UNO_QUERY);
if ( !m_xReportComponent.is() )
return;
if ( !m_aMasterFields.empty() )
m_xReportComponent->setMasterFields(Sequence< OUString>(&*m_aMasterFields.begin(),m_aMasterFields.size()));
if ( !m_aDetailFields.empty() )
m_xReportComponent->setDetailFields(Sequence< OUString>(&*m_aDetailFields.begin(),m_aDetailFields.size()));
m_xReportComponent->setName(m_xFake->getName());
m_xReportComponent->setPrintRepeatedValues(m_xFake->getPrintRepeatedValues());
uno::Reference< report::XReportControlModel > xFakeModel(m_xFake,uno::UNO_QUERY);
uno::Reference< report::XReportControlModel > xComponentModel(m_xReportComponent,uno::UNO_QUERY);
if ( !(xComponentModel.is() && xFakeModel.is()) )
return;
xComponentModel->setPrintWhenGroupChange(xFakeModel->getPrintWhenGroupChange());
const sal_Int32 nCount = xFakeModel->getCount();
try
{
for (sal_Int32 i = 0; i < nCount ; ++i)
{
uno::Reference< report::XFormatCondition > xCond(xFakeModel->getByIndex(i),uno::UNO_QUERY);
uno::Reference< report::XFormatCondition > xNewCond = xComponentModel->createFormatCondition();
::comphelper::copyProperties(xCond.get(),xNewCond.get());
xComponentModel->insertByIndex(xComponentModel->getCount(),uno::makeAny(xNewCond));
}
}
catch(uno::Exception&)
{
OSL_FAIL("Can not access format condition!");
}
}
void OXMLSubDocument::addMasterDetailPair(const ::std::pair< OUString,OUString >& _aPair)
{
m_aMasterFields.push_back(_aPair.first);
m_aDetailFields.push_back(_aPair.second);
}
} // namespace rptxml
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|